[fix] 格式化代码风格

This commit is contained in:
Sherman 2021-10-27 11:29:28 +08:00
parent ec311ee500
commit ff45ee7bbb
6 changed files with 39 additions and 39 deletions

View File

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

View File

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

View File

@ -16,14 +16,14 @@
#define DBG_TAG "drv.i2c" #define DBG_TAG "drv.i2c"
#ifdef DRV_DEBUG #ifdef DRV_DEBUG
#define DBG_LVL DBG_LOG #define DBG_LVL DBG_LOG
#else #else
#define DBG_LVL DBG_INFO #define DBG_LVL DBG_INFO
#endif /* DRV_DEBUG */ #endif /* DRV_DEBUG */
#if !defined(BSP_USING_I2C0) && !defined(BSP_USING_I2C1) #if !defined(BSP_USING_I2C0) && !defined(BSP_USING_I2C1)
#error "Please define at least one BSP_USING_I2Cx" #error "Please define at least one BSP_USING_I2Cx"
/* this driver can be disabled at menuconfig → RT-Thread Components → Device Drivers */ /* this driver can be disabled at menuconfig → RT-Thread Components → Device Drivers */
#endif #endif
static const struct ra_soft_i2c_config soft_i2c_config[] = 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) 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->scl, PIN_MODE_OUTPUT_OD);
rt_pin_mode(cfg->sda, 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) 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) if (state)
{ {
rt_pin_write(cfg->sda, PIN_HIGH); 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) 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) if (state)
{ {
rt_pin_write(cfg->scl, PIN_HIGH); 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) 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); 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) 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); return rt_pin_read(cfg->scl);
} }
/** /**
@ -198,7 +198,7 @@ int rt_hw_i2c_init(void)
for (int i = 0; i < obj_num; i++) for (int i = 0; i < obj_num; i++)
{ {
i2c_obj[i].ops = ra_bit_ops_default; 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; i2c_obj[i].i2c2_bus.priv = &i2c_obj[i].ops;
ra_i2c_gpio_init(&i2c_obj[i]); ra_i2c_gpio_init(&i2c_obj[i]);
result = rt_i2c_bit_add_bus(&i2c_obj[i].i2c2_bus, soft_i2c_config[i].bus_name); result = rt_i2c_bit_add_bus(&i2c_obj[i].i2c2_bus, soft_i2c_config[i].bus_name);

View File

@ -15,9 +15,9 @@
//#define DRV_DEBUG //#define DRV_DEBUG
#define DBG_TAG "drv.usart" #define DBG_TAG "drv.usart"
#ifdef DRV_DEBUG #ifdef DRV_DEBUG
#define DBG_LVL DBG_LOG #define DBG_LVL DBG_LOG
#else #else
#define DBG_LVL DBG_INFO #define DBG_LVL DBG_INFO
#endif /* DRV_DEBUG */ #endif /* DRV_DEBUG */
#include <rtdbg.h> #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); uart = rt_container_of(serial, struct ra_uart, serial);
RT_ASSERT(uart != RT_NULL); 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) if (FSP_SUCCESS != err)
{ {
return RT_ERROR; 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); uart = rt_container_of(serial, struct ra_uart, serial);
RT_ASSERT(uart != RT_NULL); 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; 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; 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; struct rt_serial_device *serial = &uart_obj[0].serial;
RT_ASSERT(serial != RT_NULL); 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; struct rt_serial_rx_fifo *rx_fifo;
rx_fifo = (struct rt_serial_rx_fifo *) serial->serial_rx; rx_fifo = (struct rt_serial_rx_fifo *) serial->serial_rx;
RT_ASSERT(rx_fifo != RT_NULL); 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); 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; struct rt_serial_device *serial = &uart_obj[1].serial;
RT_ASSERT(serial != RT_NULL); 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; struct rt_serial_rx_fifo *rx_fifo;
rx_fifo = (struct rt_serial_rx_fifo *) serial->serial_rx; rx_fifo = (struct rt_serial_rx_fifo *) serial->serial_rx;
RT_ASSERT(rx_fifo != RT_NULL); 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); rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
} }

View File

@ -22,8 +22,8 @@
struct ra_uart_config struct ra_uart_config
{ {
const char *name; const char *name;
uart_ctrl_t * const p_api_ctrl; uart_ctrl_t *const p_api_ctrl;
uart_cfg_t const * const p_cfg; uart_cfg_t const *const p_cfg;
}; };
struct ra_uart struct ra_uart

View File

@ -36,7 +36,7 @@ static rt_err_t wdt_control(rt_watchdog_t *wdt, int cmd, void *arg)
{ {
/* feed the watchdog */ /* feed the watchdog */
case RT_DEVICE_CTRL_WDT_KEEPALIVE: 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."); LOG_E("watch dog keepalive fail.");
} }
@ -48,16 +48,16 @@ static rt_err_t wdt_control(rt_watchdog_t *wdt, int cmd, void *arg)
break; break;
case RT_DEVICE_CTRL_WDT_GET_TIMEOUT: case RT_DEVICE_CTRL_WDT_GET_TIMEOUT:
wdt_value = (struct st_wdt_timeout_values *)arg; 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."); LOG_E("wdt get timeout failed.");
return -RT_ERROR; return -RT_ERROR;
} }
break; break;
case RT_DEVICE_CTRL_WDT_START: 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."); LOG_E("wdt start failed.");
return -RT_ERROR; return -RT_ERROR;