From ff45ee7bbbaacf89e41bb1111a77f347f48466d1 Mon Sep 17 00:00:00 2001 From: Sherman Date: Wed, 27 Oct 2021 11:29:28 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/ra6m4-cpk/drivers/drv_common.c | 10 +++++----- bsp/ra6m4-cpk/drivers/drv_common.h | 2 +- bsp/ra6m4-cpk/drivers/drv_soft_i2c.c | 26 +++++++++++++------------- bsp/ra6m4-cpk/drivers/drv_usart_v2.c | 24 ++++++++++++------------ bsp/ra6m4-cpk/drivers/drv_usart_v2.h | 4 ++-- bsp/ra6m4-cpk/drivers/drv_wdt.c | 12 ++++++------ 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/bsp/ra6m4-cpk/drivers/drv_common.c b/bsp/ra6m4-cpk/drivers/drv_common.c index 1f48e7938c..aeb5017485 100644 --- a/bsp/ra6m4-cpk/drivers/drv_common.c +++ b/bsp/ra6m4-cpk/drivers/drv_common.c @@ -17,11 +17,11 @@ #endif #ifdef RT_USING_SERIAL -#ifdef RT_USING_SERIAL_V2 -#include -#else -#include -#endif + #ifdef RT_USING_SERIAL_V2 + #include + #else + #include + #endif #endif #ifdef RT_USING_FINSH diff --git a/bsp/ra6m4-cpk/drivers/drv_common.h b/bsp/ra6m4-cpk/drivers/drv_common.h index 83ef259308..2c2a76334f 100644 --- a/bsp/ra6m4-cpk/drivers/drv_common.h +++ b/bsp/ra6m4-cpk/drivers/drv_common.h @@ -14,7 +14,7 @@ #include #include #ifdef RT_USING_DEVICE -#include + #include #endif #ifdef __cplusplus diff --git a/bsp/ra6m4-cpk/drivers/drv_soft_i2c.c b/bsp/ra6m4-cpk/drivers/drv_soft_i2c.c index 323777a8d6..2bd18241fa 100644 --- a/bsp/ra6m4-cpk/drivers/drv_soft_i2c.c +++ b/bsp/ra6m4-cpk/drivers/drv_soft_i2c.c @@ -16,14 +16,14 @@ #define DBG_TAG "drv.i2c" #ifdef DRV_DEBUG -#define DBG_LVL DBG_LOG + #define DBG_LVL DBG_LOG #else -#define DBG_LVL DBG_INFO + #define DBG_LVL DBG_INFO #endif /* DRV_DEBUG */ #if !defined(BSP_USING_I2C0) && !defined(BSP_USING_I2C1) -#error "Please define at least one BSP_USING_I2Cx" -/* this driver can be disabled at menuconfig → RT-Thread Components → Device Drivers */ + #error "Please define at least one BSP_USING_I2Cx" + /* this driver can be disabled at menuconfig → RT-Thread Components → Device Drivers */ #endif static const struct ra_soft_i2c_config soft_i2c_config[] = @@ -45,7 +45,7 @@ static struct ra_i2c i2c_obj[sizeof(soft_i2c_config) / sizeof(soft_i2c_config[0] */ static void ra_i2c_gpio_init(struct ra_i2c *i2c) { - struct ra_soft_i2c_config* cfg = (struct ra_soft_i2c_config*)i2c->ops.data; + struct ra_soft_i2c_config *cfg = (struct ra_soft_i2c_config *)i2c->ops.data; rt_pin_mode(cfg->scl, PIN_MODE_OUTPUT_OD); rt_pin_mode(cfg->sda, PIN_MODE_OUTPUT_OD); @@ -62,7 +62,7 @@ static void ra_i2c_gpio_init(struct ra_i2c *i2c) */ static void ra_set_sda(void *data, rt_int32_t state) { - struct ra_soft_i2c_config* cfg = (struct ra_soft_i2c_config*)data; + struct ra_soft_i2c_config *cfg = (struct ra_soft_i2c_config *)data; if (state) { rt_pin_write(cfg->sda, PIN_HIGH); @@ -81,7 +81,7 @@ static void ra_set_sda(void *data, rt_int32_t state) */ static void ra_set_scl(void *data, rt_int32_t state) { - struct ra_soft_i2c_config* cfg = (struct ra_soft_i2c_config*)data; + struct ra_soft_i2c_config *cfg = (struct ra_soft_i2c_config *)data; if (state) { rt_pin_write(cfg->scl, PIN_HIGH); @@ -99,7 +99,7 @@ static void ra_set_scl(void *data, rt_int32_t state) */ static rt_int32_t ra_get_sda(void *data) { - struct ra_soft_i2c_config* cfg = (struct ra_soft_i2c_config*)data; + struct ra_soft_i2c_config *cfg = (struct ra_soft_i2c_config *)data; return rt_pin_read(cfg->sda); } @@ -110,7 +110,7 @@ static rt_int32_t ra_get_sda(void *data) */ static rt_int32_t ra_get_scl(void *data) { - struct ra_soft_i2c_config* cfg = (struct ra_soft_i2c_config*)data; + struct ra_soft_i2c_config *cfg = (struct ra_soft_i2c_config *)data; return rt_pin_read(cfg->scl); } /** @@ -198,7 +198,7 @@ int rt_hw_i2c_init(void) for (int i = 0; i < obj_num; i++) { i2c_obj[i].ops = ra_bit_ops_default; - i2c_obj[i].ops.data = (void*)&soft_i2c_config[i]; + i2c_obj[i].ops.data = (void *)&soft_i2c_config[i]; i2c_obj[i].i2c2_bus.priv = &i2c_obj[i].ops; ra_i2c_gpio_init(&i2c_obj[i]); result = rt_i2c_bit_add_bus(&i2c_obj[i].i2c2_bus, soft_i2c_config[i].bus_name); @@ -206,9 +206,9 @@ int rt_hw_i2c_init(void) ra_i2c_bus_unlock(&soft_i2c_config[i]); LOG_D("software simulation %s init done, pin scl: %d, pin sda %d", - soft_i2c_config[i].bus_name, - soft_i2c_config[i].scl, - soft_i2c_config[i].sda); + soft_i2c_config[i].bus_name, + soft_i2c_config[i].scl, + soft_i2c_config[i].sda); } return RT_EOK; diff --git a/bsp/ra6m4-cpk/drivers/drv_usart_v2.c b/bsp/ra6m4-cpk/drivers/drv_usart_v2.c index 9338bd427f..080d89d022 100644 --- a/bsp/ra6m4-cpk/drivers/drv_usart_v2.c +++ b/bsp/ra6m4-cpk/drivers/drv_usart_v2.c @@ -15,9 +15,9 @@ //#define DRV_DEBUG #define DBG_TAG "drv.usart" #ifdef DRV_DEBUG -#define DBG_LVL DBG_LOG + #define DBG_LVL DBG_LOG #else -#define DBG_LVL DBG_INFO + #define DBG_LVL DBG_INFO #endif /* DRV_DEBUG */ #include @@ -81,7 +81,7 @@ static rt_err_t ra_uart_configure(struct rt_serial_device *serial, struct serial uart = rt_container_of(serial, struct ra_uart, serial); RT_ASSERT(uart != RT_NULL); - err = R_SCI_UART_Open (uart->config->p_api_ctrl, uart->config->p_cfg); + err = R_SCI_UART_Open(uart->config->p_api_ctrl, uart->config->p_cfg); if (FSP_SUCCESS != err) { return RT_ERROR; @@ -103,10 +103,10 @@ static int ra_uart_putc(struct rt_serial_device *serial, char c) uart = rt_container_of(serial, struct ra_uart, serial); RT_ASSERT(uart != RT_NULL); - sci_uart_instance_ctrl_t * p_ctrl = (sci_uart_instance_ctrl_t *)uart->config->p_api_ctrl; + sci_uart_instance_ctrl_t *p_ctrl = (sci_uart_instance_ctrl_t *)uart->config->p_api_ctrl; p_ctrl->p_reg->TDR = c; - while((p_ctrl->p_reg->SSR_b.TEND) == 0); + while ((p_ctrl->p_reg->SSR_b.TEND) == 0); return RT_EOK; } @@ -125,13 +125,13 @@ void uart7_isr_cb(uart_callback_args_t *p_args) struct rt_serial_device *serial = &uart_obj[0].serial; RT_ASSERT(serial != RT_NULL); - if(UART_EVENT_RX_CHAR == p_args->event) + if (UART_EVENT_RX_CHAR == p_args->event) { struct rt_serial_rx_fifo *rx_fifo; rx_fifo = (struct rt_serial_rx_fifo *) serial->serial_rx; RT_ASSERT(rx_fifo != RT_NULL); - rt_ringbuffer_putchar(&(rx_fifo->rb), (rt_uint8_t )p_args->data); + rt_ringbuffer_putchar(&(rx_fifo->rb), (rt_uint8_t)p_args->data); rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND); } @@ -149,13 +149,13 @@ void uart1_isr_cb(uart_callback_args_t *p_args) struct rt_serial_device *serial = &uart_obj[1].serial; RT_ASSERT(serial != RT_NULL); - if(UART_EVENT_RX_CHAR == p_args->event) + if (UART_EVENT_RX_CHAR == p_args->event) { struct rt_serial_rx_fifo *rx_fifo; rx_fifo = (struct rt_serial_rx_fifo *) serial->serial_rx; RT_ASSERT(rx_fifo != RT_NULL); - rt_ringbuffer_putchar(&(rx_fifo->rb), (rt_uint8_t )p_args->data); + rt_ringbuffer_putchar(&(rx_fifo->rb), (rt_uint8_t)p_args->data); rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND); } @@ -187,9 +187,9 @@ int rt_hw_usart_init(void) uart_obj[i].serial.ops = &ra_uart_ops; /* register UART device */ result = rt_hw_serial_register(&uart_obj[i].serial, - uart_obj[i].config->name, - RT_DEVICE_FLAG_RDWR, - NULL); + uart_obj[i].config->name, + RT_DEVICE_FLAG_RDWR, + NULL); RT_ASSERT(result == RT_EOK); } diff --git a/bsp/ra6m4-cpk/drivers/drv_usart_v2.h b/bsp/ra6m4-cpk/drivers/drv_usart_v2.h index adbfbc2911..d4fe7eb327 100644 --- a/bsp/ra6m4-cpk/drivers/drv_usart_v2.h +++ b/bsp/ra6m4-cpk/drivers/drv_usart_v2.h @@ -22,8 +22,8 @@ struct ra_uart_config { const char *name; - uart_ctrl_t * const p_api_ctrl; - uart_cfg_t const * const p_cfg; + uart_ctrl_t *const p_api_ctrl; + uart_cfg_t const *const p_cfg; }; struct ra_uart diff --git a/bsp/ra6m4-cpk/drivers/drv_wdt.c b/bsp/ra6m4-cpk/drivers/drv_wdt.c index 280c1444bf..56acd86088 100644 --- a/bsp/ra6m4-cpk/drivers/drv_wdt.c +++ b/bsp/ra6m4-cpk/drivers/drv_wdt.c @@ -34,30 +34,30 @@ static rt_err_t wdt_control(rt_watchdog_t *wdt, int cmd, void *arg) struct st_wdt_timeout_values *wdt_value = {0}; switch (cmd) { - /* feed the watchdog */ + /* feed the watchdog */ case RT_DEVICE_CTRL_WDT_KEEPALIVE: - if(R_WDT_Refresh(&g_wdt_ctrl) != FSP_SUCCESS) + if (R_WDT_Refresh(&g_wdt_ctrl) != FSP_SUCCESS) { LOG_E("watch dog keepalive fail."); } break; - /* set watchdog timeout */ + /* set watchdog timeout */ case RT_DEVICE_CTRL_WDT_SET_TIMEOUT: /**< set*/ // g_wdt_cfg.timeout = *(rt_uint32_t *)arg; break; case RT_DEVICE_CTRL_WDT_GET_TIMEOUT: wdt_value = (struct st_wdt_timeout_values *)arg; - if(R_WDT_TimeoutGet(&g_wdt_ctrl,wdt_value) != FSP_SUCCESS) + if (R_WDT_TimeoutGet(&g_wdt_ctrl, wdt_value) != FSP_SUCCESS) { LOG_E("wdt get timeout failed."); return -RT_ERROR; } break; case RT_DEVICE_CTRL_WDT_START: - if(R_WDT_Open(&g_wdt_ctrl, &g_wdt_cfg) == FSP_SUCCESS) + if (R_WDT_Open(&g_wdt_ctrl, &g_wdt_cfg) == FSP_SUCCESS) { - if(R_WDT_Refresh(&g_wdt_ctrl) != FSP_SUCCESS) + if (R_WDT_Refresh(&g_wdt_ctrl) != FSP_SUCCESS) { LOG_E("wdt start failed."); return -RT_ERROR;