Browse Source

[fix] 格式化代码风格

Sherman 3 years ago
parent
commit
ff45ee7bbb

+ 5 - 5
bsp/ra6m4-cpk/drivers/drv_common.c

@@ -17,11 +17,11 @@
 #endif
 
 #ifdef RT_USING_SERIAL
-#ifdef RT_USING_SERIAL_V2
-#include <drv_usart_v2.h>
-#else
-#include <drv_usart.h>
-#endif
+    #ifdef RT_USING_SERIAL_V2
+        #include <drv_usart_v2.h>
+    #else
+        #include <drv_usart.h>
+    #endif
 #endif
 
 #ifdef RT_USING_FINSH

+ 1 - 1
bsp/ra6m4-cpk/drivers/drv_common.h

@@ -14,7 +14,7 @@
 #include <rtthread.h>
 #include <rthw.h>
 #ifdef RT_USING_DEVICE
-#include <rtdevice.h>
+    #include <rtdevice.h>
 #endif
 
 #ifdef __cplusplus

+ 13 - 13
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;

+ 12 - 12
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 <rtdbg.h>
 
@@ -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);
     }
 

+ 2 - 2
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

+ 6 - 6
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;