12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #ifndef _API_I2C_LOW_H_
- #define _API_I2C_LOW_H_
- #include <stdint.h>
- #include "api_i2c.h"
- #include "api_rt_common.h"
- #include "gd32f30x.h"
- #define I2C_TIME_OUT (uint16_t)(10000)
- typedef struct
- {
- uint32_t I2CBase;
- } ApiRtI2C_Handle;
- extern ApiRtI2C_Handle I2Cs[1];
- typedef enum
- {
- I2C_START = 0,
- I2C_SEND_ADDRESS,
- I2C_CLEAR_ADDRESS_FLAG,
- I2C_TRANSMIT_DATA,
- I2C_STOP,
- I2C_COMPLETE
- } ApiRtI2C_Process;
- /**
- * @brief I2C初始化
- */
- void iRtI2C_Init();
- /**
- * @brief I2C等待EE可写入
- */
- void iRtI2C_WaitEEReady();
- /**
- * @brief I2C总线复位
- *
- * @return 总线复位次数
- */
- int iRtI2C_BusReset(uint8_t devIndex);
- /**
- * @brief I2C同步页写入EE
- *
- * @param devIndex 外设序号
- * @param devAddr 设备地址
- * @param memAddr 内存地址
- * @param memAddrSize 内存地址宽度
- * @param data 写入数据Buffer
- * @param count 写入数据长度
- * @return 写入结果
- */
- int iRtI2C_PageWrite2EE(uint8_t devIndex, uint16_t devAddr, uint16_t memAddr, uint8_t *data, uint8_t count);
- #endif
|