Skip to content

Commit 283c2fb

Browse files
unicornxRbb666
authored andcommitted
bsp: k230: fix some cpp_check warnings
Signed-off-by: Chen Wang <[email protected]>
1 parent 919adbc commit 283c2fb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

bsp/k230/board/board.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void init_bss(void)
6464
unsigned int *dst;
6565

6666
dst = &__bss_start;
67-
while (dst < &__bss_end)
67+
while ((rt_ubase_t)dst < (rt_ubase_t)&__bss_end)
6868
{
6969
*dst++ = 0;
7070
}

bsp/k230/drivers/interdrv/uart/drv_uart.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,17 @@ static void _uart_init(void *uart_base)
129129
dlh = bdiv >> 12;
130130
dll = (bdiv - (dlh << 12)) / 16;
131131
dlf = bdiv - (dlh << 12) - dll * 16;
132-
if(dlh == 0 && dll == 0)
132+
// dlh can be 0 only if bdiv < 4096 (since we're shifting right by 12 bits)
133+
// bdiv = UART_CLK / UART_DEFAULT_BAUDRATE
134+
// = 50000000 / 115200
135+
// = 434.027
136+
// so when dlh is 0,
137+
// dll = (bdiv - (dlh << 12)) / 16
138+
// = (434.027 - 0) / 16
139+
// = 27.626
140+
// which means dll can not reach 0,
141+
// so we use 1 as the minimum value for dll
142+
if((dlh == 0) && (dll < 1))
133143
{
134144
dll = 1;
135145
dlf = 0;

0 commit comments

Comments
 (0)