32 #ifndef __STC8x_I2C_H_
33 #define __STC8x_I2C_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)
61 #ifndef PER_LIB_MCU_MUODEL
64 #define PER_LIB_MCU_MUODEL STC8Ax
68 #ifndef PER_LIB_I2C_CTRL
71 #define PER_LIB_I2C_CTRL 1
75 #ifndef PER_LIB_I2C_INIT_CTRL
78 #define PER_LIB_I2C_INIT_CTRL 1
82 #ifndef PER_LIB_I2C_NVIC_CTRL
85 #define PER_LIB_I2C_NVIC_CTRL 1
89 #ifndef PER_LIB_I2C_WORK_CTRL
92 #define PER_LIB_I2C_WORK_CTRL 1
126 #if (PER_LIB_I2C_CTRL == 1)
128 #if (PER_LIB_I2C_INIT_CTRL == 1)
143 #if (PER_LIB_I2C_NVIC_CTRL == 1)
174 #define NVIC_I2C_HOST_CTRL(run) \
177 I2CMSCR = run << 7; \
186 #define NVIC_I2C_SLAVE_CTRL(run) \
189 I2CSLCR &= (I2CSLCR & 0x01 ) | \
190 (run << 6) | (run << 5) | \
191 (run << 4) | (run << 3) ; \
201 #define NVIC_I2C_PRI(pri) \
203 IP2H = (IP2H & 0xBF) | ((pri & 0x02) << 5); \
204 IP2 = (IP2 & 0xBF) | ((pri & 0x01) << 6); \
213 #define I2C_GET_HOST_FLAG() (I2CMSST & 0x40)
222 #define I2C_GET_HOST_BUSY_STATE() (I2CMSST & 0x80)
229 #define I2C_CLEAR_HOST_MASTER_FLAG() {I2CMSST &= 0xBF;}
238 #define I2C_GET_SLAVE_BUSY_STATE() (I2CMSST & 0x80)
247 #define I2C_GET_SLAVE_REVSTART_FLAG() (I2CSLST & 0x40)
256 #define I2C_GET_SLAVE_REVDATA_FLAG() (I2CSLST & 0x20)
265 #define I2C_GET_SLAVE_SENDATA_FLAG() (I2CSLST & 0x10)
274 #define I2C_GET_SLAVE_REVSTOP_FLAG() (I2CSLST & 0x08)
283 #define I2C_CLEAR_SLAVE_REVSTART_FLAG() {I2CSLST &= 0xBF;}
292 #define I2C_CLEAR_SLAVE_REVDATA_FLAG() {I2CSLST &= 0xDF;}
301 #define I2C_CLEAR_SLAVE_SENDATA_FLAG() {I2CSLST &= 0xEF;}
310 #define I2C_CLEAR_SLAVE_REVSTOP_FLAG() {I2CSLST &= 0xF7;}
314 #if (PER_LIB_I2C_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 I2C_Read_ACK(void)
I2C读取ACK信号函数。
I2CType_Type
I2C工作类型枚举体。
Definition: STC8x_I2C.h:101
@ I2C_Type_Host
Definition: STC8x_I2C.h:102
@ I2C_Type_Slave
Definition: STC8x_I2C.h:103
FSCSTATE I2C_Send_NACK(void)
I2C发送NACK信号函数。
FSCSTATE I2C_Send_Btye(uint8_t dat)
I2C发送一个字节函数。
FSCSTATE NVCI_I2C_Master_Init(NVICPri_Type pri, BOOL run)
I2C主机中断初始化函数。
I2CSTri_Type
I2C从机中断触发方式枚举体。
Definition: STC8x_I2C.h:116
@ I2C_STri_RevStart_Done
Definition: STC8x_I2C.h:117
@ I2C_STri_RevStop_Done
Definition: STC8x_I2C.h:120
@ I2C_STri_SendData_Done
Definition: STC8x_I2C.h:119
@ I2C_STri_RevData_Done
Definition: STC8x_I2C.h:118
FSCSTATE I2C_Send_ACK(void)
I2C发送ACK信号函数。
FSCSTATE I2C_Send_Start(void)
I2C发送开始信号函数。
FSCSTATE I2C_Init(I2CType_Type type, uint8_t wTime, BOOL state)
I2C初始化函数。
uint8_t I2C_Read_Byte(void)
I2C读取一个字节函数。
FSCSTATE GPIO_I2C_SWPort(GPIOSWPort_Type port)
I2C切换复用IO函数。
FSCSTATE I2C_Send_Stop(void)
I2C发送停止信号函数。
FSCSTATE NVCI_I2C_Slave_Init(NVICPri_Type pri, I2CSTri_Type triMode)
I2C从机中断初始化函数。