comparison Small_CPU/Src/uart.c @ 803:96ffad0a4e57

Cleanup initialisation / deinitialization: The UART1 is now deactivated during sleep and will be reactivated with the default baudrate 19200. This avoid unpredicted behavior in case of sleep => awake transitions (always start from scratch)
author Ideenmodellierer
date Thu, 10 Aug 2023 21:30:24 +0200
parents e9eba334b942
children 9602a7338f28
comparison
equal deleted inserted replaced
802:91d5ef16f1fd 803:96ffad0a4e57
53 void MX_USART1_UART_Init(void) 53 void MX_USART1_UART_Init(void)
54 { 54 {
55 /* regular init */ 55 /* regular init */
56 56
57 huart1.Instance = USART1; 57 huart1.Instance = USART1;
58 58 huart1.Init.BaudRate = 19200;
59 if(externalInterface_GetUARTProtocol() == 0x04)
60 {
61 huart1.Init.BaudRate = 19200;
62 }
63 else
64 {
65 huart1.Init.BaudRate = 9600;
66 }
67 huart1.Init.WordLength = UART_WORDLENGTH_8B; 59 huart1.Init.WordLength = UART_WORDLENGTH_8B;
68 huart1.Init.StopBits = UART_STOPBITS_1; 60 huart1.Init.StopBits = UART_STOPBITS_1;
69 huart1.Init.Parity = UART_PARITY_NONE; 61 huart1.Init.Parity = UART_PARITY_NONE;
70 huart1.Init.Mode = UART_MODE_TX_RX; 62 huart1.Init.Mode = UART_MODE_TX_RX;
71 huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE; 63 huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
88 void MX_USART1_UART_DeInit(void) 80 void MX_USART1_UART_DeInit(void)
89 { 81 {
90 HAL_DMA_Abort(&hdma_usart1_rx); 82 HAL_DMA_Abort(&hdma_usart1_rx);
91 HAL_DMA_DeInit(&hdma_usart1_rx); 83 HAL_DMA_DeInit(&hdma_usart1_rx);
92 HAL_UART_DeInit(&huart1); 84 HAL_UART_DeInit(&huart1);
85 dmaActive = 0;
93 } 86 }
94 87
95 void MX_USART1_DMA_Init() 88 void MX_USART1_DMA_Init()
96 { 89 {
97 /* DMA controller clock enable */ 90 /* DMA controller clock enable */