|
@@ -6,9 +6,9 @@
|
|
|
* Change Logs:
|
|
|
* Date Author Notes
|
|
|
* 2020-10-30 CDT first version
|
|
|
+ * 2021-01-18 CDT modify i2c gpio init
|
|
|
*/
|
|
|
|
|
|
-
|
|
|
/*******************************************************************************
|
|
|
* Include files
|
|
|
******************************************************************************/
|
|
@@ -65,10 +65,8 @@ static const struct hc32_soft_i2c_config soft_i2c_config[] =
|
|
|
#endif
|
|
|
};
|
|
|
|
|
|
-
|
|
|
static struct hc32_i2c i2c_obj[sizeof(soft_i2c_config) / sizeof(soft_i2c_config[0])];
|
|
|
|
|
|
-
|
|
|
/*******************************************************************************
|
|
|
* Function implementation - global ('extern') and local ('static')
|
|
|
******************************************************************************/
|
|
@@ -81,8 +79,8 @@ static void hc32_i2c_gpio_init(struct hc32_i2c *i2c)
|
|
|
{
|
|
|
struct hc32_soft_i2c_config* cfg = (struct hc32_soft_i2c_config*)i2c->ops.data;
|
|
|
|
|
|
- rt_pin_mode(cfg->scl_pin, PIN_MODE_OUTPUT);
|
|
|
- rt_pin_mode(cfg->sda_pin, PIN_MODE_OUTPUT);
|
|
|
+ rt_pin_mode(cfg->scl_pin, PIN_MODE_OUTPUT_OD);
|
|
|
+ rt_pin_mode(cfg->sda_pin, PIN_MODE_OUTPUT_OD);
|
|
|
|
|
|
rt_pin_write(cfg->scl_pin, PIN_HIGH);
|
|
|
rt_pin_write(cfg->sda_pin, PIN_HIGH);
|
|
@@ -98,8 +96,6 @@ static void hc32_set_sda(void *data, rt_int32_t state)
|
|
|
{
|
|
|
struct hc32_soft_i2c_config* cfg = (struct hc32_soft_i2c_config*)data;
|
|
|
|
|
|
- rt_pin_mode(cfg->sda_pin, PIN_MODE_OUTPUT);
|
|
|
-
|
|
|
if (state)
|
|
|
rt_pin_write(cfg->sda_pin, PIN_HIGH);
|
|
|
else
|
|
@@ -116,8 +112,6 @@ static void hc32_set_scl(void *data, rt_int32_t state)
|
|
|
{
|
|
|
struct hc32_soft_i2c_config* cfg = (struct hc32_soft_i2c_config*)data;
|
|
|
|
|
|
- rt_pin_mode(cfg->scl_pin, PIN_MODE_OUTPUT);
|
|
|
-
|
|
|
if (state)
|
|
|
rt_pin_write(cfg->scl_pin, PIN_HIGH);
|
|
|
else
|
|
@@ -133,8 +127,6 @@ static rt_int32_t hc32_get_sda(void *data)
|
|
|
{
|
|
|
struct hc32_soft_i2c_config* cfg = (struct hc32_soft_i2c_config*)data;
|
|
|
|
|
|
- rt_pin_mode(cfg->sda_pin, PIN_MODE_INPUT);
|
|
|
-
|
|
|
return rt_pin_read(cfg->sda_pin);
|
|
|
}
|
|
|
|
|
@@ -147,8 +139,6 @@ static rt_int32_t hc32_get_scl(void *data)
|
|
|
{
|
|
|
struct hc32_soft_i2c_config* cfg = (struct hc32_soft_i2c_config*)data;
|
|
|
|
|
|
- rt_pin_mode(cfg->scl_pin, PIN_MODE_INPUT);
|
|
|
-
|
|
|
return rt_pin_read(cfg->scl_pin);
|
|
|
}
|
|
|
|
|
@@ -210,7 +200,6 @@ int hc32_hw_i2c_init(void)
|
|
|
}
|
|
|
INIT_BOARD_EXPORT(hc32_hw_i2c_init);
|
|
|
|
|
|
-
|
|
|
#endif /* RT_USING_I2C */
|
|
|
|
|
|
/*******************************************************************************
|