SWM320_i2c.h 1.0 KB

12345678910111213141516171819202122232425262728293031
  1. #ifndef __SWM320_I2C_H__
  2. #define __SWM320_I2C_H__
  3. typedef struct
  4. {
  5. uint8_t Master; //1 主机模式
  6. uint8_t Addr7b; //1 7位地址 0 10位地址
  7. uint32_t MstClk; //主机传输时钟频率
  8. uint8_t MstIEn; //主机模式中断使能
  9. uint16_t SlvAddr; //从机地址
  10. uint8_t SlvRxEndIEn; //从机接收完成中断使能
  11. uint8_t SlvTxEndIEn; //从机发送完成中断使能
  12. uint8_t SlvSTADetIEn; //从机检测到起始中断使能
  13. uint8_t SlvSTODetIEn; //从机检测到终止中断使能
  14. uint8_t SlvRdReqIEn; //从机接收到读请求中断使能
  15. uint8_t SlvWrReqIEn; //从机接收到写请求中断使能
  16. } I2C_InitStructure;
  17. void I2C_Init(I2C_TypeDef *I2Cx, I2C_InitStructure *initStruct);
  18. void I2C_Open(I2C_TypeDef *I2Cx);
  19. void I2C_Close(I2C_TypeDef *I2Cx);
  20. uint8_t I2C_Start(I2C_TypeDef *I2Cx, uint8_t addr);
  21. void I2C_Stop(I2C_TypeDef *I2Cx);
  22. uint8_t I2C_Write(I2C_TypeDef *I2Cx, uint8_t data);
  23. uint8_t I2C_Read(I2C_TypeDef *I2Cx, uint8_t ack);
  24. #endif //__SWM320_I2C_H__