22 * Copyright (c) 2006-2025, RT-Thread Development Team
33 *
44 * SPDX-License-Identifier: Apache-2.0
5+ *
56 */
67
78#include "drv_hw_i2c.h"
@@ -25,11 +26,11 @@ static const struct gd32_i2c_config i2c_configs[] =
2526 .scl_clk = RCU_GPIOA ,
2627 .scl_port = GPIOA ,
2728 .scl_pin = GPIO_PIN_9 ,
28- .scl_af = GPIO_AF_4 ,
29+ .scl_af = GPIO_AF_4 ,
2930 .sda_clk = RCU_GPIOA ,
3031 .sda_port = GPIOA ,
3132 .sda_pin = GPIO_PIN_10 ,
32- .sda_af = GPIO_AF_4 ,
33+ .sda_af = GPIO_AF_4 ,
3334
3435 .i2c_clock_hz = BSP_HW_I2C0_CLOCK_SPEED ,
3536 .device_name = "i2c0" ,
@@ -47,7 +48,7 @@ static const struct gd32_i2c_config i2c_configs[] =
4748 .sda_clk = RCU_GPIOB ,
4849 .sda_port = GPIOB ,
4950 .sda_pin = GPIO_PIN_11 ,
50- .sda_af = GPIO_AF_1 ,
51+ .sda_af = GPIO_AF_1 ,
5152 .i2c_clock_hz = BSP_HW_I2C1_CLOCK_SPEED ,
5253 .device_name = "i2c1" ,
5354 },
@@ -72,7 +73,7 @@ static rt_ssize_t gd32_i2c_master_xfer(struct rt_i2c_bus_device *bus,
7273 {
7374 struct rt_i2c_msg * msg = & msgs [i ];
7475 rt_uint16_t slave_addr = msg -> addr ;
75-
76+
7677 i2c_start_on_bus (i2c_periph );
7778 while (!i2c_flag_get (i2c_periph , I2C_FLAG_SBSEND ));
7879
@@ -87,7 +88,7 @@ static rt_ssize_t gd32_i2c_master_xfer(struct rt_i2c_bus_device *bus,
8788
8889 while (!i2c_flag_get (i2c_periph , I2C_FLAG_ADDSEND ));
8990 i2c_flag_clear (i2c_periph , I2C_FLAG_ADDSEND );
90-
91+
9192 if (msg -> flags & RT_I2C_RD )
9293 {
9394 if (msg -> len == 1 )
@@ -118,7 +119,7 @@ static rt_ssize_t gd32_i2c_master_xfer(struct rt_i2c_bus_device *bus,
118119 }
119120 while (!i2c_flag_get (i2c_periph , I2C_FLAG_BTC ));
120121 }
121-
122+
122123 if (!(msg -> flags & RT_I2C_NO_STOP ))
123124 {
124125 i2c_stop_on_bus (i2c_periph );
@@ -133,7 +134,7 @@ static rt_ssize_t gd32_i2c_master_xfer(struct rt_i2c_bus_device *bus,
133134static const struct rt_i2c_bus_device_ops gd32_i2c_ops =
134135{
135136 .master_xfer = gd32_i2c_master_xfer ,
136- .slave_xfer = RT_NULL ,
137+ .slave_xfer = RT_NULL ,
137138 .i2c_bus_control = RT_NULL ,
138139};
139140
@@ -148,7 +149,7 @@ int rt_hw_i2c_init(void)
148149 const struct gd32_i2c_config * config = & i2c_configs [i ];
149150
150151 i2c_obj -> config = config ;
151-
152+
152153 i2c_obj -> i2c_clock_hz = config -> i2c_clock_hz ;
153154
154155 rcu_periph_clock_enable (config -> periph_clk );
@@ -181,4 +182,5 @@ int rt_hw_i2c_init(void)
181182
182183INIT_BOARD_EXPORT (rt_hw_i2c_init );
183184
184- #endif
185+ #endif
186+
0 commit comments