Skip to content

Commit ae2f068

Browse files
committed
format
1 parent 70d1398 commit ae2f068

File tree

3 files changed

+30
-26
lines changed

3 files changed

+30
-26
lines changed

bsp/gd32/arm/gd32e230-lckfb/rtconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,4 @@
410410
/* end of Hardware Drivers Config */
411411

412412
#endif
413+

bsp/gd32/arm/libraries/gd32_drivers/drv_hw_i2c.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
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,
133134
static 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

182183
INIT_BOARD_EXPORT(rt_hw_i2c_init);
183184

184-
#endif
185+
#endif
186+

bsp/gd32/arm/libraries/gd32_drivers/drv_hw_i2c.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,28 @@ extern "C" {
1818

1919
struct gd32_i2c_config
2020
{
21-
rt_uint32_t i2c_periph;
22-
rcu_periph_enum periph_clk;
23-
24-
rcu_periph_enum scl_clk;
25-
rt_uint32_t scl_port;
26-
rt_uint32_t scl_pin;
27-
rt_uint32_t scl_af;
28-
29-
rcu_periph_enum sda_clk;
30-
rt_uint32_t sda_port;
31-
rt_uint32_t sda_pin;
32-
rt_uint32_t sda_af;
33-
21+
rt_uint32_t i2c_periph;
22+
rcu_periph_enum periph_clk;
23+
24+
rcu_periph_enum scl_clk;
25+
rt_uint32_t scl_port;
26+
rt_uint32_t scl_pin;
27+
rt_uint32_t scl_af;
28+
29+
rcu_periph_enum sda_clk;
30+
rt_uint32_t sda_port;
31+
rt_uint32_t sda_pin;
32+
rt_uint32_t sda_af;
33+
3434
rt_uint32_t i2c_clock_hz; /* I2C clock frequency in Hz */
35-
const char *device_name;
35+
const char *device_name;
3636
};
3737

3838
struct gd32_i2c
3939
{
40-
struct rt_i2c_bus_device parent;
40+
struct rt_i2c_bus_device parent;
4141
const struct gd32_i2c_config *config;
42-
rt_uint32_t i2c_clock_hz;
42+
rt_uint32_t i2c_clock_hz;
4343
};
4444

4545
int rt_hw_i2c_init(void);
@@ -48,4 +48,5 @@ int rt_hw_i2c_init(void);
4848
}
4949
#endif
5050

51-
#endif /* __DRV_HW_I2C_H__ */
51+
#endif /* __DRV_HW_I2C_H__ */
52+

0 commit comments

Comments
 (0)