32 #ifndef __STC8x_SPI_H_
33 #define __STC8x_SPI_H_
44 #if (PER_LIB_MCU_MUODEL == STC8Ax)
46 #elif (PER_LIB_MCU_MUODEL == STC8Cx)
48 #elif (PER_LIB_MCU_MUODEL == STC8Fx)
50 #elif (PER_LIB_MCU_MUODEL == STC8Gx)
52 #elif (PER_LIB_MCU_MUODEL == STC8Hx)
62 #ifndef PER_LIB_MCU_MUODEL
63 #define PER_LIB_MCU_MUODEL STC8Ax
69 #ifndef PER_LIB_SPI_CTRL
70 #define PER_LIB_SPI_CTRL 1
76 #ifndef PER_LIB_SPI_INIT_CTRL
77 #define PER_LIB_SPI_INIT_CTRL 1
83 #ifndef PER_LIB_SPI_NVIC_CTRL
84 #define PER_LIB_SPI_NVIC_CTRL 1
90 #ifndef PER_LIB_SPI_WORK_CTRL
91 #define PER_LIB_SPI_WORK_CTRL 1
164 #if (PER_LIB_SPI_CTRL == 1)
166 #if (PER_LIB_SPI_INIT_CTRL == 1)
181 #if (PER_LIB_SPI_NVIC_CTRL == 1)
199 #define NVIC_SPI_CTRL(run) do{ IE2 = (IE2 & 0xFD) | (run << 1); }while(0)
206 #define NVIC_SPI_PRI(pri) \
208 IP2H = (IP2H & 0xFD) | (pri & 0x02); \
209 IP2 = (IP2 & 0xFD) | ((pri & 0x01) << 1); \
217 #define SPI_GET_FLAG() (SPSTAT & 0x80)
223 #define SPI_CLEAR_FLAG() do{SPSTAT = 0xC0;}while(0)
227 #if (PER_LIB_SPI_WORK_CTRL == 1)
NVICPri_Type
Definition: ELL_CORE.h:99
BOOL
Definition: ELL_CORE.h:50
FSCSTATE
Definition: ELL_CORE.h:65
GPIOSWPort_Type
Definition: ELL_CORE.h:81
unsigned char uint8_t
Definition: ELL_TYPE.h:72
FSCSTATE NVIC_SPI_Init(NVICPri_Type pri, BOOL run)
SPI中断初始化函数。
SPIType_Type
SPI工作类型枚举体。
Definition: STC8x_SPI.h:100
@ SPI_Type_Master_Slave
Definition: STC8x_SPI.h:101
@ SPI_Type_Master
Definition: STC8x_SPI.h:102
@ SPI_Type_Slave
Definition: STC8x_SPI.h:103
FSCSTATE SPI_Init(const SPIInit_Type *spix)
SPI初始化函数。
uint8_t SPI_Receive_Data(void)
SPI接收数据(一个字节)函数。
SPIMode_Type
SPI模式枚举体。
Definition: STC8x_SPI.h:138
@ SPI_Mode_3
Definition: STC8x_SPI.h:142
@ SPI_Mode_1
Definition: STC8x_SPI.h:140
@ SPI_Mode_2
Definition: STC8x_SPI.h:141
@ SPI_Mode_0
Definition: STC8x_SPI.h:139
FSCSTATE GPIO_SPI_SWPort(GPIOSWPort_Type port)
SPI切换复用IO函数。
SPITran_Type
SPI传输类型枚举体。
Definition: STC8x_SPI.h:125
@ SPI_Tran_LSB
Definition: STC8x_SPI.h:128
@ SPI_Tran_MSB
Definition: STC8x_SPI.h:126
FSCSTATE SPI_Send_Data(uint8_t dat)
SPI发送数据(一个字节)函数。
SPIClkSrc_Type
SPI时钟源选择枚举体。
Definition: STC8x_SPI.h:112
@ SPI_SCLK_DIV_16
Definition: STC8x_SPI.h:115
@ SPI_SCLK_DIV_8
Definition: STC8x_SPI.h:114
@ SPI_SCLK_DIV_4
Definition: STC8x_SPI.h:113
@ SPI_SCLK_DIV_32
Definition: STC8x_SPI.h:116
SPI初始化枚举体,需要你定义它,并用它的地址来传参给初始化函数。
Definition: STC8x_SPI.h:152
SPIMode_Type Mode
Definition: STC8x_SPI.h:155
SPIType_Type Type
Definition: STC8x_SPI.h:153
SPITran_Type Tran
Definition: STC8x_SPI.h:156
BOOL Run
Definition: STC8x_SPI.h:157
SPIClkSrc_Type ClkSrc
Definition: STC8x_SPI.h:154