Files
CHJ/user/MCU/lhl_i2c_soft.h

45 lines
1.2 KiB
C
Raw Normal View History

2026-03-20 21:19:04 +08:00
#ifndef __LHL_I2C_SOFT_H__
#define __LHL_I2C_SOFT_H__
2026-03-20 21:16:58 +08:00
//IIC<49>˿ڶ<CBBF><DAB6><EFBFBD>
#ifndef HIGH
2026-03-20 21:19:04 +08:00
#define HIGH 1 // HIGH
#define LOW 0 // LOW
#endif
2026-03-20 21:16:58 +08:00
#ifndef WR
2026-03-20 21:19:04 +08:00
#define WR 0 // WRITE
#define RD 1 // READ
2026-03-20 21:16:58 +08:00
#endif
/*******************************************************************************/
2026-03-20 21:19:04 +08:00
#define SDA_IN() EnableInput(I2C_SDA_GPIO, I2C_SDA_PINPOS)
2026-03-20 21:16:58 +08:00
#define SDA_OUT() EnableOutput(I2C_SDA_GPIO, I2C_SDA_PINPOS)
#define SET_SDA() SET_PIN(I2C_SDA_GPIO, I2C_SDA)
#define CLR_SDA() CLR_PIN(I2C_SDA_GPIO, I2C_SDA)
#define READ_SDA() READ_PIN(I2C_SDA_GPIO, I2C_SDA)
#define SCL_OUT() EnableOutput(I2C_SCL_GPIO, I2C_SCL_PINPOS)
#define SET_SCL() SET_PIN(I2C_SCL_GPIO, I2C_SCL)
#define CLR_SCL() CLR_PIN(I2C_SCL_GPIO, I2C_SCL)
/*******************************************************************************/
#define ENABLE_I2C_DELAY 0
2026-03-20 21:19:04 +08:00
#define SI2C_Delay() __NOP();
2026-03-20 21:16:58 +08:00
void SI2C_Init(void);
void SI2C_Start(void);
void SI2C_Stop(void);
void SI2C_Ack(void);
void SI2C_NoAck(void);
2026-03-20 21:19:04 +08:00
uint8_t SI2C_TestAck(void);
uint8_t SI2C_Write(uint8_t writeData);
uint8_t SI2C_Read(void);
2026-03-20 21:16:58 +08:00
#endif