Skip to content

Commit

Permalink
Merge pull request #1895 from bcostm/fix_l0_force_serial_reset
Browse files Browse the repository at this point in the history
[STM32L0] Add USART force/release Reset at Init phase
  • Loading branch information
0xc0170 authored Jun 14, 2016
2 parents 4dcefa6 + 6e645e5 commit 53d7115
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions hal/targets/hal/TARGET_STM/TARGET_STM32L0/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,30 +93,40 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
// Enable UART clock
#if defined(USART1_BASE)
if (obj->uart == UART_1) {
__HAL_RCC_USART1_FORCE_RESET();
__HAL_RCC_USART1_RELEASE_RESET();
__HAL_RCC_USART1_CLK_ENABLE();
obj->index = 0;
}
#endif

if (obj->uart == UART_2) {
__HAL_RCC_USART2_FORCE_RESET();
__HAL_RCC_USART2_RELEASE_RESET();
__HAL_RCC_USART2_CLK_ENABLE();
obj->index = 1;
}

if (obj->uart == LPUART_1) {
__HAL_RCC_LPUART1_FORCE_RESET();
__HAL_RCC_LPUART1_RELEASE_RESET();
__HAL_RCC_LPUART1_CLK_ENABLE();
obj->index = 2;
}

#if defined(USART4_BASE)
if (obj->uart == UART_4) {
__HAL_RCC_USART4_FORCE_RESET();
__HAL_RCC_USART4_RELEASE_RESET();
__HAL_RCC_USART4_CLK_ENABLE();
obj->index = 3;
}
#endif

#if defined(USART5_BASE)
if (obj->uart == UART_5) {
__HAL_RCC_USART5_FORCE_RESET();
__HAL_RCC_USART5_RELEASE_RESET();
__HAL_RCC_USART5_CLK_ENABLE();
obj->index = 4;
}
Expand Down

0 comments on commit 53d7115

Please sign in to comment.