Skip to content

Commit 255edf0

Browse files
committed
bsp: k230: fix some cpp_check warnings
Signed-off-by: Chen Wang <[email protected]>
1 parent a53df5a commit 255edf0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

bsp/k230/board/board.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void init_bss(void)
7171
unsigned int *dst;
7272

7373
dst = &__bss_start;
74-
while (dst < &__bss_end)
74+
while ((rt_ubase_t)dst < (rt_ubase_t)&__bss_end)
7575
{
7676
*dst++ = 0;
7777
}

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

Lines changed: 11 additions & 1 deletion
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)