Changeset 64 for ctrl/firmware/Main/CubeMX/Core/Src
- Timestamp:
- Jan 15, 2025, 4:04:20 PM (16 hours ago)
- Location:
- ctrl/firmware/Main/CubeMX/Core/Src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
ctrl/firmware/Main/CubeMX/Core/Src/app_threadx.c
r61 r64 82 82 /* USER CODE BEGIN App_ThreadX_Init */ 83 83 84 // Allocate the stack for mainthread84 // Allocate the stack for key thread 85 85 ret = tx_byte_allocate(byte_pool, &keys_thread_pointer, KEYS_THREAD_STACK_SIZE_BYTES, TX_NO_WAIT); 86 86 if (ret != TX_SUCCESS) { printf("Cannot allocate bytes of memory!\n"); return ret; } 87 87 88 88 char* scan_keys_thread_name = "Scan Keys Thread"; 89 ret = tx_thread_create(&scan_keys_thread_ptr, scan_keys_thread_name, scanKeysThread, 0x0001, 89 ret = tx_thread_create(&scan_keys_thread_ptr, scan_keys_thread_name, scanKeysThread, 0x0001, keys_thread_pointer, KEYS_THREAD_STACK_SIZE_BYTES, TX_MAX_PRIORITIES-1, TX_MAX_PRIORITIES-1, TX_NO_TIME_SLICE, TX_AUTO_START); 90 90 if (ret != TX_SUCCESS) { printf("Cannot create %s!\n", scan_keys_thread_name); return ret; } 91 91 92 92 93 93 // Allocate the stack for gsm thread 94 94 ret = tx_byte_allocate(byte_pool, &gsm_thread_pointer, GSM_THREAD_STACK_SIZE_BYTES, TX_NO_WAIT); 95 95 if (ret != TX_SUCCESS) { printf("Cannot allocate bytes of memory!\n"); return ret; } -
ctrl/firmware/Main/CubeMX/Core/Src/dma.c
r47 r64 47 47 HAL_NVIC_SetPriority(DMA1_Stream0_IRQn, 0, 0); 48 48 HAL_NVIC_EnableIRQ(DMA1_Stream0_IRQn); 49 /* DMA1_Stream1_IRQn interrupt configuration */ 50 HAL_NVIC_SetPriority(DMA1_Stream1_IRQn, 0, 0); 51 HAL_NVIC_EnableIRQ(DMA1_Stream1_IRQn); 52 /* DMA1_Stream2_IRQn interrupt configuration */ 53 HAL_NVIC_SetPriority(DMA1_Stream2_IRQn, 0, 0); 54 HAL_NVIC_EnableIRQ(DMA1_Stream2_IRQn); 49 55 50 56 } -
ctrl/firmware/Main/CubeMX/Core/Src/stm32h7xx_it.c
r63 r64 62 62 extern DMA_HandleTypeDef hdma_spi4_tx; 63 63 extern SPI_HandleTypeDef hspi4; 64 extern DMA_HandleTypeDef hdma_usart3_rx; 65 extern DMA_HandleTypeDef hdma_usart3_tx; 64 66 extern UART_HandleTypeDef huart3; 65 67 extern TIM_HandleTypeDef htim7; … … 182 184 183 185 /** 186 * @brief This function handles DMA1 stream1 global interrupt. 187 */ 188 void DMA1_Stream1_IRQHandler(void) 189 { 190 /* USER CODE BEGIN DMA1_Stream1_IRQn 0 */ 191 192 /* USER CODE END DMA1_Stream1_IRQn 0 */ 193 HAL_DMA_IRQHandler(&hdma_usart3_rx); 194 /* USER CODE BEGIN DMA1_Stream1_IRQn 1 */ 195 196 /* USER CODE END DMA1_Stream1_IRQn 1 */ 197 } 198 199 /** 200 * @brief This function handles DMA1 stream2 global interrupt. 201 */ 202 void DMA1_Stream2_IRQHandler(void) 203 { 204 /* USER CODE BEGIN DMA1_Stream2_IRQn 0 */ 205 206 /* USER CODE END DMA1_Stream2_IRQn 0 */ 207 HAL_DMA_IRQHandler(&hdma_usart3_tx); 208 /* USER CODE BEGIN DMA1_Stream2_IRQn 1 */ 209 210 /* USER CODE END DMA1_Stream2_IRQn 1 */ 211 } 212 213 /** 184 214 * @brief This function handles USART3 global interrupt. 185 215 */ … … 239 269 /* USER CODE BEGIN 1 */ 240 270 241 void HAL_UART_RxCpltCallback(UART_HandleTypeDef * huart)242 {243 if (huart->Instance == USART3) gsmUnitSentData();244 }245 246 271 //------------------------------------------------------------------------------ 247 272 273 void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size) 274 { 275 if (huart->Instance == USART3) gsmUnitSentData(Size); 276 } 277 278 //------------------------------------------------------------------------------ 279 280 /*void HAL_UART_RxCpltCallback(UART_HandleTypeDef * huart) 281 { 282 //if (huart->Instance == USART3) gsmUnitSentData(); 283 }*/ 284 285 //------------------------------------------------------------------------------ 286 248 287 /* USER CODE END 1 */ -
ctrl/firmware/Main/CubeMX/Core/Src/usart.c
r63 r64 26 26 27 27 UART_HandleTypeDef huart3; 28 DMA_HandleTypeDef hdma_usart3_rx; 29 DMA_HandleTypeDef hdma_usart3_tx; 28 30 29 31 /* USART3 init function */ … … 119 121 HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); 120 122 123 /* USART3 DMA Init */ 124 /* USART3_RX Init */ 125 hdma_usart3_rx.Instance = DMA1_Stream1; 126 hdma_usart3_rx.Init.Request = DMA_REQUEST_USART3_RX; 127 hdma_usart3_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; 128 hdma_usart3_rx.Init.PeriphInc = DMA_PINC_DISABLE; 129 hdma_usart3_rx.Init.MemInc = DMA_MINC_ENABLE; 130 hdma_usart3_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; 131 hdma_usart3_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; 132 hdma_usart3_rx.Init.Mode = DMA_CIRCULAR; 133 hdma_usart3_rx.Init.Priority = DMA_PRIORITY_LOW; 134 hdma_usart3_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; 135 if (HAL_DMA_Init(&hdma_usart3_rx) != HAL_OK) 136 { 137 Error_Handler(); 138 } 139 140 __HAL_LINKDMA(uartHandle,hdmarx,hdma_usart3_rx); 141 142 /* USART3_TX Init */ 143 hdma_usart3_tx.Instance = DMA1_Stream2; 144 hdma_usart3_tx.Init.Request = DMA_REQUEST_USART3_TX; 145 hdma_usart3_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; 146 hdma_usart3_tx.Init.PeriphInc = DMA_PINC_DISABLE; 147 hdma_usart3_tx.Init.MemInc = DMA_MINC_ENABLE; 148 hdma_usart3_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; 149 hdma_usart3_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; 150 hdma_usart3_tx.Init.Mode = DMA_NORMAL; 151 hdma_usart3_tx.Init.Priority = DMA_PRIORITY_HIGH; 152 hdma_usart3_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; 153 if (HAL_DMA_Init(&hdma_usart3_tx) != HAL_OK) 154 { 155 Error_Handler(); 156 } 157 158 __HAL_LINKDMA(uartHandle,hdmatx,hdma_usart3_tx); 159 121 160 /* USART3 interrupt Init */ 122 161 HAL_NVIC_SetPriority(USART3_IRQn, 0, 0); … … 147 186 HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_11|GPIO_PIN_12); 148 187 188 /* USART3 DMA DeInit */ 189 HAL_DMA_DeInit(uartHandle->hdmarx); 190 HAL_DMA_DeInit(uartHandle->hdmatx); 191 149 192 /* USART3 interrupt Deinit */ 150 193 HAL_NVIC_DisableIRQ(USART3_IRQn);
Note: See TracChangeset
for help on using the changeset viewer.