Skip to content

Commit b346543

Browse files
committed
[update][renesas/nano]Modify the semaphore used by the console to be statically created.
1 parent 98cb15a commit b346543

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

bsp/renesas/libraries/HAL_Drivers/nano/drv_console.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#if defined(RT_USING_CONSOLE) && defined(RT_USING_SEMAPHORE)
1616

17-
static rt_sem_t console_sem = RT_NULL;
17+
struct rt_semaphore console_sem;
1818

1919
#if defined(RT_NANO_CONSOLE_UART0)
2020
#define renesas_uart_ctrl g_uart0_ctrl
@@ -60,8 +60,11 @@ static rt_sem_t console_sem = RT_NULL;
6060

6161
void rt_hw_console_init(void)
6262
{
63-
fsp_err_t err;
64-
console_sem = rt_sem_create("console", 0, RT_IPC_FLAG_FIFO);
63+
fsp_err_t err = FSP_SUCCESS;
64+
rt_err_t res = RT_EOK;
65+
66+
res = rt_sem_init(&console_sem, "console", 0, RT_IPC_FLAG_FIFO);
67+
RT_ASSERT(res == RT_EOK);
6568

6669
/* Initialize UART using FSP */
6770
#ifdef SOC_SERIES_R7FA8M85
@@ -78,12 +81,12 @@ void rt_hw_console_init(void)
7881

7982
void console_send_byte(uint8_t ch)
8083
{
84+
renesas_uart_ctrl.p_reg->TDR = ch;
8185
#if defined(SOC_SERIES_R7FA8M85) || defined(SOC_SERIES_R9A07G0)
8286
while ((renesas_uart_ctrl.p_reg->CSR_b.TEND) == 0);
8387
#else
8488
while ((renesas_uart_ctrl.p_reg->SSR_b.TEND) == 0);
8589
#endif
86-
renesas_uart_ctrl.p_reg->TDR = ch;
8790
}
8891

8992
void rt_hw_console_output(const char *str)
@@ -111,7 +114,7 @@ void renesas_uart_callback(uart_callback_args_t *p_args)
111114
/* Received a character or receive completed */
112115
case UART_EVENT_RX_CHAR:
113116
case UART_EVENT_RX_COMPLETE:
114-
rt_sem_release(console_sem);
117+
rt_sem_release(&console_sem);
115118
break;
116119

117120
default:
@@ -122,7 +125,7 @@ void renesas_uart_callback(uart_callback_args_t *p_args)
122125
char rt_hw_console_getchar(void)
123126
{
124127
int ch = -1;
125-
rt_sem_take(console_sem, RT_WAITING_FOREVER);
128+
rt_sem_take(&console_sem, RT_WAITING_FOREVER);
126129
#ifdef SOC_SERIES_R7FA8M85
127130
fsp_err_t ret = R_SCI_B_UART_Read(&renesas_uart_ctrl, (uint8_t *)&ch, 1);
128131
#else

0 commit comments

Comments
 (0)