mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
cpu/stm32l1: uart: make sure 'dev' is != NULL to avoid nullPointer errors
This commit is contained in:
parent
39ecc12d9d
commit
c5cfacebc3
@ -113,6 +113,10 @@ static int init_base(uart_t uart, uint32_t baudrate)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make sure dev is != NULL here, i.e. that the variable is assigned in
|
||||||
|
* all non-returning branches of the switch at the top of this function. */
|
||||||
|
assert(dev != NULL);
|
||||||
|
|
||||||
/* uart_configure RX and TX pins, set pin to use alternative function mode */
|
/* uart_configure RX and TX pins, set pin to use alternative function mode */
|
||||||
gpio_init(tx_pin, GPIO_OUT);
|
gpio_init(tx_pin, GPIO_OUT);
|
||||||
gpio_init_af(tx_pin, af);
|
gpio_init_af(tx_pin, af);
|
||||||
@ -157,6 +161,10 @@ void uart_write(uart_t uart, const uint8_t *data, size_t len)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make sure dev is != NULL here, i.e. that the variable is assigned in
|
||||||
|
* all non-returning branches of the switch at the top of this function. */
|
||||||
|
assert(dev != NULL);
|
||||||
|
|
||||||
for (size_t i = 0; i < len; i++) {
|
for (size_t i = 0; i < len; i++) {
|
||||||
while (!(dev->SR & USART_SR_TXE)) {}
|
while (!(dev->SR & USART_SR_TXE)) {}
|
||||||
dev->DR = data[i];
|
dev->DR = data[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user