generated from hulk/gd32e23x_template_cmake_vscode
fix iic driver
This commit is contained in:
59
Inc/i2c.h
59
Inc/i2c.h
@@ -32,15 +32,15 @@
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
/* I2C status enumeration */
|
||||
/* I2C result enumeration */
|
||||
typedef enum {
|
||||
I2C_STATUS_SUCCESS = 0, /* Operation successful */
|
||||
I2C_STATUS_TIMEOUT, /* Timeout occurred */
|
||||
I2C_STATUS_NACK, /* No acknowledge received */
|
||||
I2C_STATUS_BUS_BUSY, /* Bus is busy */
|
||||
I2C_STATUS_ERROR, /* General error */
|
||||
I2C_STATUS_INVALID_PARAM /* Invalid parameter */
|
||||
} i2c_status_t;
|
||||
I2C_RESULT_SUCCESS = 0, /* Operation successful */
|
||||
I2C_RESULT_TIMEOUT, /* Timeout occurred */
|
||||
I2C_RESULT_NACK, /* No acknowledge received */
|
||||
I2C_RESULT_BUS_BUSY, /* Bus is busy */
|
||||
I2C_RESULT_ERROR, /* General error */
|
||||
I2C_RESULT_INVALID_PARAM /* Invalid parameter */
|
||||
} i2c_result_t;
|
||||
|
||||
/* I2C state machine enumeration */
|
||||
typedef enum {
|
||||
@@ -67,31 +67,26 @@ typedef enum {
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
||||
/* Function declarations */
|
||||
|
||||
/*!
|
||||
\brief configure the GPIO ports for I2C
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval none
|
||||
*/
|
||||
void i2c_gpio_config(void);
|
||||
|
||||
// TODO I2C Result
|
||||
/*!
|
||||
\brief configure the I2C interface
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval i2c_status_t
|
||||
\retval i2c_result_t
|
||||
*/
|
||||
i2c_status_t i2c_config(void);
|
||||
void i2c_config(void);
|
||||
|
||||
// TODO I2C Result
|
||||
/*!
|
||||
\brief reset I2C bus with proper recovery
|
||||
\param[in] none
|
||||
\param[out] none
|
||||
\retval i2c_status_t
|
||||
\retval i2c_result_t
|
||||
*/
|
||||
i2c_status_t i2c_bus_reset(void);
|
||||
void i2c_bus_reset(void);
|
||||
|
||||
/*!
|
||||
\brief scan I2C bus for devices
|
||||
@@ -101,31 +96,43 @@ i2c_status_t i2c_bus_reset(void);
|
||||
*/
|
||||
void i2c_scan(void);
|
||||
|
||||
// TODO I2C Result
|
||||
/*!
|
||||
\brief write 16-bit data to I2C device
|
||||
\param[in] slave_addr: 7-bit slave address
|
||||
\param[in] reg_addr: register address
|
||||
\param[in] data: pointer to 2-byte data array
|
||||
\param[out] none
|
||||
\retval i2c_status_t
|
||||
\retval i2c_result_t
|
||||
*/
|
||||
i2c_status_t i2c_write_16bits(uint8_t slave_addr, uint8_t reg_addr, const uint8_t data[2]);
|
||||
uint8_t i2c_write_16bits(uint8_t slave_addr, uint8_t reg_addr, uint8_t data[2]);
|
||||
|
||||
// TODO I2C Result
|
||||
/*!
|
||||
\brief read 16-bit data from I2C device
|
||||
\param[in] slave_addr: 7-bit slave address
|
||||
\param[in] reg_addr: register address
|
||||
\param[out] data: pointer to 2-byte data buffer
|
||||
\retval i2c_status_t
|
||||
\retval i2c_result_t
|
||||
*/
|
||||
i2c_status_t i2c_read_16bits(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data);
|
||||
uint8_t i2c_read_16bits(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data);
|
||||
|
||||
// TODO I2C Result
|
||||
/*!
|
||||
\brief read 16-bit data from I2C device
|
||||
\param[in] slave_addr: 7-bit slave address
|
||||
\param[in] reg_addr: register address
|
||||
\param[out] data: pointer to 2-byte data buffer
|
||||
\retval i2c_result_t
|
||||
*/
|
||||
uint8_t i2c_read_16bits(uint8_t slave_addr, uint8_t reg_addr, uint8_t *data);
|
||||
|
||||
/*!
|
||||
\brief get status string for debugging
|
||||
\param[in] status: i2c_status_t value
|
||||
\param[in] status: i2c_result_t value
|
||||
\param[out] none
|
||||
\retval const char* status string
|
||||
*/
|
||||
const char* i2c_get_status_string(i2c_status_t status);
|
||||
const char* i2c_get_status_string(i2c_result_t status);
|
||||
|
||||
#endif //I2C_H
|
||||
|
Reference in New Issue
Block a user