Mercurial > public > ostc4
comparison Discovery/Src/ostc.c @ 981:c6c781a2e85b default
Merge into default
| author | heinrichsweikamp |
|---|---|
| date | Tue, 11 Feb 2025 18:12:00 +0100 |
| parents | 8d3f3a635397 |
| children | 33b91584d827 |
comparison
equal
deleted
inserted
replaced
| 871:f7318457df4d | 981:c6c781a2e85b |
|---|---|
| 44 UART_HandleTypeDef UartPiezoTxHandle; | 44 UART_HandleTypeDef UartPiezoTxHandle; |
| 45 #endif | 45 #endif |
| 46 UART_HandleTypeDef UartIR_HUD_Handle; | 46 UART_HandleTypeDef UartIR_HUD_Handle; |
| 47 | 47 |
| 48 __IO ITStatus UartReady = RESET; | 48 __IO ITStatus UartReady = RESET; |
| 49 __IO ITStatus UartReadyHUD = RESET; | |
| 49 | 50 |
| 50 /* Private types -------------------------------------------------------------*/ | 51 /* Private types -------------------------------------------------------------*/ |
| 51 | 52 |
| 52 /* Private variables ---------------------------------------------------------*/ | 53 /* Private variables ---------------------------------------------------------*/ |
| 53 | 54 |
| 54 /* Private variables with external access via get_xxx() function -------------*/ | 55 /* Private variables with external access via get_xxx() function -------------*/ |
| 55 | 56 static uint8_t hardwareDisplay = 0; //< either OSTC4 LCD (=0) or new Screen (=1) |
| 56 /* Private function prototypes -----------------------------------------------*/ | 57 /* Private function prototypes -----------------------------------------------*/ |
| 57 | 58 |
| 58 /* Exported functions --------------------------------------------------------*/ | 59 /* Exported functions --------------------------------------------------------*/ |
| 59 | 60 |
| 60 /** SPI init function | 61 /** SPI init function |
| 89 cpu2DmaSpi.Init.CRCPolynomial = 7; | 90 cpu2DmaSpi.Init.CRCPolynomial = 7; |
| 90 | 91 |
| 91 HAL_SPI_Init(&cpu2DmaSpi); | 92 HAL_SPI_Init(&cpu2DmaSpi); |
| 92 } | 93 } |
| 93 | 94 |
| 95 | |
| 96 void MX_GPIO_Backlight_max_static_only_Init(void) | |
| 97 { | |
| 98 GPIO_InitTypeDef GPIO_InitStruct; | |
| 99 TIM_BACKLIGHT_GPIO_ENABLE(); | |
| 100 | |
| 101 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
| 102 GPIO_InitStruct.Pull = GPIO_NOPULL;//GPIO_PULLUP; /* should be normally high */ | |
| 103 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
| 104 | |
| 105 GPIO_InitStruct.Pin = TIM_BACKLIGHT_PIN; | |
| 106 HAL_GPIO_Init(TIM_BACKLIGHT_GPIO_PORT, &GPIO_InitStruct); | |
| 107 | |
| 108 HAL_GPIO_WritePin(TIM_BACKLIGHT_GPIO_PORT,TIM_BACKLIGHT_PIN,GPIO_PIN_SET); | |
| 109 } | |
| 110 | |
| 111 | |
| 112 void MX_GPIO_One_Button_only_Init(void) | |
| 113 { | |
| 114 GPIO_InitTypeDef GPIO_InitStruct; | |
| 115 BUTTON_NEXT_GPIO_ENABLE(); | |
| 116 | |
| 117 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
| 118 GPIO_InitStruct.Pull = GPIO_NOPULL;//GPIO_PULLUP; /* should be normally high */ | |
| 119 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
| 120 | |
| 121 GPIO_InitStruct.Pin = BUTTON_NEXT_PIN; | |
| 122 HAL_GPIO_Init(BUTTON_NEXT_GPIO_PORT, &GPIO_InitStruct); | |
| 123 } | |
| 124 | |
| 125 | |
| 126 GPIO_PinState MX_GPIO_Read_The_One_Button(void) | |
| 127 { | |
| 128 return HAL_GPIO_ReadPin(BUTTON_NEXT_GPIO_PORT, BUTTON_NEXT_PIN); | |
| 129 } | |
| 130 | |
| 94 void MX_GPIO_Init(void) | 131 void MX_GPIO_Init(void) |
| 95 { | 132 { |
| 96 GPIO_InitTypeDef GPIO_InitStruct; | 133 GPIO_InitTypeDef GPIO_InitStruct; |
| 97 | 134 |
| 98 DISPLAY_CSB_GPIO_ENABLE(); | 135 DISPLAY_CSB_GPIO_ENABLE(); |
| 99 DISPLAY_RESETB_GPIO_ENABLE(); | 136 DISPLAY_RESETB_GPIO_ENABLE(); |
| 100 EXTFLASH_CSB_GPIO_ENABLE(); | 137 EXTFLASH_CSB_GPIO_ENABLE(); |
| 101 SMALLCPU_CSB_GPIO_ENABLE(); | 138 SMALLCPU_CSB_GPIO_ENABLE(); |
| 102 OSCILLOSCOPE_GPIO_ENABLE(); | 139 OSCILLOSCOPE_GPIO_ENABLE(); |
| 103 OSCILLOSCOPE2_GPIO_ENABLE(); | 140 OSCILLOSCOPE2_GPIO_ENABLE(); |
| 141 BLE_UBLOX_DSR_GPIO_ENABLE(); | |
| 104 | 142 |
| 105 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | 143 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
| 106 GPIO_InitStruct.Pull = GPIO_PULLUP; | 144 GPIO_InitStruct.Pull = GPIO_PULLUP; |
| 107 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | 145 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; |
| 108 | 146 |
| 191 GPIO_InitStruct.Pull = GPIO_NOPULL; | 229 GPIO_InitStruct.Pull = GPIO_NOPULL; |
| 192 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | 230 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; |
| 193 GPIO_InitStruct.Pin = BLE_NENABLE_PIN; | 231 GPIO_InitStruct.Pin = BLE_NENABLE_PIN; |
| 194 HAL_GPIO_Init(BLE_NENABLE_GPIO_PORT, &GPIO_InitStruct); | 232 HAL_GPIO_Init(BLE_NENABLE_GPIO_PORT, &GPIO_InitStruct); |
| 195 HAL_GPIO_WritePin(BLE_NENABLE_GPIO_PORT,BLE_NENABLE_PIN,GPIO_PIN_RESET); | 233 HAL_GPIO_WritePin(BLE_NENABLE_GPIO_PORT,BLE_NENABLE_PIN,GPIO_PIN_RESET); |
| 234 | |
| 235 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
| 236 GPIO_InitStruct.Pull = GPIO_PULLDOWN; | |
| 237 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
| 238 GPIO_InitStruct.Pin = BLE_UBLOX_DSR_PIN; | |
| 239 HAL_GPIO_Init(BLE_UBLOX_DSR_GPIO_PORT, &GPIO_InitStruct); | |
| 240 HAL_GPIO_WritePin(BLE_UBLOX_DSR_GPIO_PORT,BLE_UBLOX_DSR_PIN,GPIO_PIN_RESET); | |
| 196 } | 241 } |
| 197 | 242 |
| 198 | 243 |
| 199 void MX_Bluetooth_PowerOff(void) | 244 void MX_Bluetooth_PowerOff(void) |
| 200 { | 245 { |
| 201 GPIO_InitTypeDef GPIO_InitStruct; | 246 GPIO_InitTypeDef GPIO_InitStruct; |
| 202 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | 247 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
| 203 GPIO_InitStruct.Pin = BLE_NENABLE_PIN; | 248 GPIO_InitStruct.Pin = BLE_NENABLE_PIN; |
| 204 GPIO_InitStruct.Pull = GPIO_NOPULL; | 249 GPIO_InitStruct.Pull = GPIO_NOPULL; |
| 205 HAL_GPIO_Init(BLE_NENABLE_GPIO_PORT, &GPIO_InitStruct); | 250 HAL_GPIO_Init(BLE_NENABLE_GPIO_PORT, &GPIO_InitStruct); |
| 251 HAL_GPIO_WritePin(BLE_UBLOX_DSR_GPIO_PORT,BLE_UBLOX_DSR_PIN,GPIO_PIN_RESET); | |
| 206 } | 252 } |
| 207 | 253 |
| 208 | 254 |
| 209 void MX_SmallCPU_Reset_To_Boot(void) | 255 void MX_SmallCPU_Reset_To_Boot(void) |
| 210 { | 256 { |
| 226 HAL_Delay(100); | 272 HAL_Delay(100); |
| 227 HAL_GPIO_WritePin(SMALLCPU_BOOT0_GPIO_PORT,SMALLCPU_BOOT0_PIN,GPIO_PIN_RESET); | 273 HAL_GPIO_WritePin(SMALLCPU_BOOT0_GPIO_PORT,SMALLCPU_BOOT0_PIN,GPIO_PIN_RESET); |
| 228 #endif | 274 #endif |
| 229 } | 275 } |
| 230 | 276 |
| 277 | |
| 278 void MX_SmallCPU_NO_Reset_Helper(void) | |
| 279 { | |
| 280 #ifdef SMALLCPU_NRESET_PIN | |
| 281 GPIO_InitTypeDef GPIO_InitStruct; | |
| 282 | |
| 283 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
| 284 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
| 285 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
| 286 | |
| 287 SMALLCPU_NRESET_GPIO_ENABLE(); | |
| 288 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); | |
| 289 HAL_GPIO_WritePin(SMALLCPU_NRESET_GPIO_PORT,SMALLCPU_NRESET_PIN,GPIO_PIN_SET); | |
| 290 // HAL_Delay(100); | |
| 291 // GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
| 292 // HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); | |
| 293 #endif | |
| 294 } | |
| 295 | |
| 296 | |
| 231 void MX_SmallCPU_Reset_To_Standard(void) | 297 void MX_SmallCPU_Reset_To_Standard(void) |
| 232 { | 298 { |
| 233 #ifdef SMALLCPU_NRESET_PIN | 299 #ifdef SMALLCPU_NRESET_PIN |
| 234 GPIO_InitTypeDef GPIO_InitStruct; | 300 GPIO_InitTypeDef GPIO_InitStruct; |
| 235 | 301 |
| 246 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | 312 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
| 247 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); | 313 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); |
| 248 #endif | 314 #endif |
| 249 } | 315 } |
| 250 | 316 |
| 317 | |
| 318 uint8_t MX_UART_ButtonAdjust(uint8_t *array) | |
| 319 { | |
| 320 #ifdef USART_PIEZO | |
| 321 uint8_t answer[4]; | |
| 322 HAL_UART_Transmit(&UartPiezoTxHandle,array,4,1000); | |
| 323 HAL_UART_Receive(&UartPiezoTxHandle,answer,4,2000); | |
| 324 if( (answer[0] == array[0]) | |
| 325 &&(answer[1] == array[1]) | |
| 326 &&(answer[2] == array[2]) | |
| 327 &&(answer[3] == array[3])) | |
| 328 return 1; | |
| 329 #endif | |
| 330 return 0; | |
| 331 } | |
| 332 | |
| 333 | |
| 251 void MX_UART_Init(void) | 334 void MX_UART_Init(void) |
| 252 { | 335 { |
| 253 /*##-1- Configure the UART peripheral ######################################*/ | 336 /*##-1- Configure the UART peripheral ######################################*/ |
| 254 /* Put the USART peripheral in the Asynchronous mode (UART Mode) */ | 337 /* Put the USART peripheral in the Asynchronous mode (UART Mode) */ |
| 255 /* UART1 configured as follow: | 338 /* UART1 configured as follow: |
| 309 if(huart == &UartHandle) | 392 if(huart == &UartHandle) |
| 310 UartReady = SET; | 393 UartReady = SET; |
| 311 else | 394 else |
| 312 if(huart == &UartIR_HUD_Handle) | 395 if(huart == &UartIR_HUD_Handle) |
| 313 { | 396 { |
| 397 #ifndef BOOTLOADER_STANDALONE | |
| 314 tCCR_SetRXIndication(); | 398 tCCR_SetRXIndication(); |
| 399 #endif | |
| 400 UartReadyHUD = SET; | |
| 315 } | 401 } |
| 316 } | 402 } |
| 317 | 403 |
| 318 void MX_tell_reset_logik_alles_ok(void) | 404 void MX_tell_reset_logik_alles_ok(void) |
| 319 { | 405 { |
| 334 | 420 |
| 335 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | 421 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
| 336 HAL_GPIO_Init(RESET_LOGIC_ALLES_OK_GPIO_PORT, &GPIO_InitStruct); | 422 HAL_GPIO_Init(RESET_LOGIC_ALLES_OK_GPIO_PORT, &GPIO_InitStruct); |
| 337 #endif | 423 #endif |
| 338 } | 424 } |
| 339 | 425 void SetDisplayVersion(uint8_t version) |
| 426 { | |
| 427 if(version < 2) | |
| 428 { | |
| 429 hardwareDisplay = version; | |
| 430 } | |
| 431 } | |
| 432 uint8_t isNewDisplay() | |
| 433 { | |
| 434 uint8_t ret = 0; | |
| 435 if(hardwareDisplay == DISPLAY_VERSION_NEW) | |
| 436 { | |
| 437 ret = 1; | |
| 438 } | |
| 439 return ret; | |
| 440 } | |
| 340 | 441 |
| 341 #ifndef BOOTLOADER_STANDALONE | 442 #ifndef BOOTLOADER_STANDALONE |
| 342 void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart) | 443 void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart) |
| 343 { | 444 { |
| 344 if(huart == &UartIR_HUD_Handle) | 445 if(huart == &UartIR_HUD_Handle) |
