-
Notifications
You must be signed in to change notification settings - Fork 0
/
spi.h
40 lines (32 loc) · 826 Bytes
/
spi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef __SPI_H
#define __SPI_H
#include "STC15Fxxxx.H"
#define SPI_MODE_Master 1
#define SPI_MODE_Slave 0
#define SPI_ENABLE 0xC0
#define SPI_ENABLE_MASK 0xC0
#define MSBFIRST 1
#define LSBFIRST 0
#define SPI_MODE0 0x00
#define SPI_MODE1 0x04
#define SPI_MODE2 0x08
#define SPI_MODE3 0x0C
#define SPI_MODE_MASK 0x0C
#define SPI_CLOCK_DIV4 0x00
#define SPI_CLOCK_DIV16 0x01
#define SPI_CLOCK_DIV64 0x02
#define SPI_CLOCK_DIV128 0x03
#define SPI_CLOCK_MASK 0x03
#define SPI_PIN0 0x00
#define SPI_PIN1 0x04
#define SPI_PIN2 0x08
#define SPI_PIN_MASK 0x0C
void SPI_begin(u8 mode);
void SPI_attachInterrupt(void);
void SPI_detachInterrupt(void);
void SPI_setBitOrder(u8 bitOrder);
void SPI_setDataMode(u8 dataMode);
void SPI_setClockDivider(u8 rate);
void SPI_pin(u8 pinSelect);
u8 SPI_transfer(u8 SPI_data);
#endif