comparison Small_CPU/Src/uart.c @ 890:651d21777b61 Evo_2_23

cleanup and disable function for GNSS uart and DMA
author heinrichsweikamp
date Fri, 06 Sep 2024 18:43:30 +0200
parents cf3967fe6924
children 9e2f9b91e827
comparison
equal deleted inserted replaced
889:cf3967fe6924 890:651d21777b61
37 37
38 38
39 39
40 DMA_HandleTypeDef hdma_usart1_rx, hdma_usart6_rx, hdma_usart6_tx; 40 DMA_HandleTypeDef hdma_usart1_rx, hdma_usart6_rx, hdma_usart6_tx;
41 41
42 uint8_t rxBuffer[CHUNK_SIZE * CHUNKS_PER_BUFFER]; /* The complete buffer has a X * chunk size to allow fariations in buffer read time */ 42 uint8_t rxBuffer[CHUNK_SIZE * CHUNKS_PER_BUFFER]; /* The complete buffer has a X * chunk size to allow variations in buffer read time */
43 uint8_t rxBufferUart6[CHUNK_SIZE * CHUNKS_PER_BUFFER]; /* The complete buffer has a X * chunk size to allow fariations in buffer read time */ 43 uint8_t rxBufferUart6[CHUNK_SIZE * CHUNKS_PER_BUFFER]; /* The complete buffer has a X * chunk size to allow variations in buffer read time */
44 uint8_t txBufferUart6[CHUNK_SIZE * CHUNKS_PER_BUFFER]; /* The complete buffer has a X * chunk size to allow fariations in buffer read time */ 44 uint8_t txBufferUart6[CHUNK_SIZE * CHUNKS_PER_BUFFER]; /* The complete buffer has a X * chunk size to allow variations in buffer read time */
45 45
46 static uint8_t rxWriteIndex; /* Index of the data item which is analysed */ 46 static uint8_t rxWriteIndex; /* Index of the data item which is analysed */
47 static uint8_t rxReadIndex; /* Index at which new data is stared */ 47 static uint8_t rxReadIndex; /* Index at which new data is stared */
48 static uint8_t lastCmdIndex; /* Index of last command which has not been completly received */ 48 static uint8_t lastCmdIndex; /* Index of last command which has not been completely received */
49 static uint8_t dmaActive; /* Indicator if DMA reception needs to be started */ 49 static uint8_t dmaActive; /* Indicator if DMA reception needs to be started */
50 50
51 51
52 52
53 53
111 /* DMA interrupt init */ 111 /* DMA interrupt init */
112 HAL_NVIC_SetPriority(DMA2_Stream5_IRQn, 0, 0); 112 HAL_NVIC_SetPriority(DMA2_Stream5_IRQn, 0, 0);
113 HAL_NVIC_EnableIRQ(DMA2_Stream5_IRQn); 113 HAL_NVIC_EnableIRQ(DMA2_Stream5_IRQn);
114 } 114 }
115 115
116
116 void GNSS_IO_init() { 117 void GNSS_IO_init() {
117 118
118 GPIO_InitTypeDef GPIO_InitStruct = { 0 }; 119 GPIO_InitTypeDef GPIO_InitStruct = { 0 };
119 /* Peripheral clock enable */ 120 /* Peripheral clock enable */
120 __HAL_RCC_USART6_CLK_ENABLE(); 121 __HAL_RCC_USART6_CLK_ENABLE()
121 122 ;
122 __HAL_RCC_GPIOA_CLK_ENABLE(); 123
124 __HAL_RCC_GPIOA_CLK_ENABLE()
125 ;
123 /**USART6 GPIO Configuration 126 /**USART6 GPIO Configuration
124 PA11 ------> USART6_TX 127 PA11 ------> USART6_TX
125 PA12 ------> USART6_RX 128 PA12 ------> USART6_RX
126 */ 129 */
127 GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12; 130 GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
163 __HAL_LINKDMA(&huart6, hdmatx, hdma_usart6_tx); 166 __HAL_LINKDMA(&huart6, hdmatx, hdma_usart6_tx);
164 167
165 /* USART6 interrupt Init */ 168 /* USART6 interrupt Init */
166 HAL_NVIC_SetPriority(USART6_IRQn, 0, 0); 169 HAL_NVIC_SetPriority(USART6_IRQn, 0, 0);
167 HAL_NVIC_EnableIRQ(USART6_IRQn); 170 HAL_NVIC_EnableIRQ(USART6_IRQn);
168 /* USER CODE BEGIN USART6_MspInit 1 */
169
170 /* USER CODE END USART6_MspInit 1 */
171 171
172 MX_USART6_DMA_Init(); 172 MX_USART6_DMA_Init();
173 173
174 } 174 }
175 175
184 /* DMA2_Stream6_IRQn interrupt configuration */ 184 /* DMA2_Stream6_IRQn interrupt configuration */
185 HAL_NVIC_SetPriority(DMA2_Stream6_IRQn, 0, 0); 185 HAL_NVIC_SetPriority(DMA2_Stream6_IRQn, 0, 0);
186 HAL_NVIC_EnableIRQ(DMA2_Stream6_IRQn); 186 HAL_NVIC_EnableIRQ(DMA2_Stream6_IRQn);
187 } 187 }
188 188
189 /** 189
190 * @brief USART6 Initialization Function 190 void MX_USART6_UART_DeInit(void)
191 * @param None 191 {
192 * @retval None 192 HAL_DMA_Abort(&hdma_usart6_rx);
193 */ 193 HAL_DMA_DeInit(&hdma_usart6_rx);
194 void MX_USART6_UART_Init(void) 194 HAL_DMA_Abort(&hdma_usart6_tx);
195 { 195 HAL_DMA_DeInit(&hdma_usart6_tx);
196 /* USER CODE BEGIN USART6_Init 0 */ 196 HAL_UART_DeInit(&huart6);
197 197 HAL_UART_DeInit(&huart6);
198 /* USER CODE END USART6_Init 0 */ 198 }
199 199
200 /* USER CODE BEGIN USART6_Init 1 */ 200 void MX_USART6_UART_Init(void) {
201 201 huart6.Instance = USART6;
202 /* USER CODE END USART6_Init 1 */ 202 huart6.Init.BaudRate = 9600;
203 huart6.Instance = USART6; 203 huart6.Init.WordLength = UART_WORDLENGTH_8B;
204 huart6.Init.BaudRate = 9600; 204 huart6.Init.StopBits = UART_STOPBITS_1;
205 huart6.Init.WordLength = UART_WORDLENGTH_8B; 205 huart6.Init.Parity = UART_PARITY_NONE;
206 huart6.Init.StopBits = UART_STOPBITS_1; 206 huart6.Init.Mode = UART_MODE_TX_RX;
207 huart6.Init.Parity = UART_PARITY_NONE; 207 huart6.Init.HwFlowCtl = UART_HWCONTROL_NONE;
208 huart6.Init.Mode = UART_MODE_TX_RX; 208 huart6.Init.OverSampling = UART_OVERSAMPLING_16;
209 huart6.Init.HwFlowCtl = UART_HWCONTROL_NONE; 209 HAL_UART_Init(&huart6);
210 huart6.Init.OverSampling = UART_OVERSAMPLING_16;
211 HAL_UART_Init(&huart6);
212
213 /* USER CODE BEGIN USART6_Init 2 */
214
215 /* USER CODE END USART6_Init 2 */
216 } 210 }
217 211
218 void UART_MUX_SelectAddress(uint8_t muxAddress) 212 void UART_MUX_SelectAddress(uint8_t muxAddress)
219 { 213 {
220 uint8_t indexstr[4]; 214 uint8_t indexstr[4];