Mercurial > public > ostc4
annotate Discovery/Src/ostc.c @ 1034:195bfbdf961d Puls_Integration
Pulse measurement integration:
Added function to parse standart GATT pulse service. Added compile switch to remove code from non dev builds.
| author | Ideenmodellierer |
|---|---|
| date | Thu, 07 Aug 2025 20:18:52 +0200 |
| parents | 33b91584d827 |
| children | 5865f0aeb438 |
| rev | line source |
|---|---|
| 38 | 1 /////////////////////////////////////////////////////////////////////////////// |
| 2 /// -*- coding: UTF-8 -*- | |
| 3 /// | |
| 4 /// \file Discovery/Src/ostc.c | |
| 5 /// \brief Hardware specific configuration | |
| 6 /// \author Heinrichs Weikamp gmbh | |
| 7 /// \date 05-Dec-2014 | |
| 8 /// | |
| 9 /// \details | |
| 10 /// | |
| 11 /// $Id$ | |
| 12 /////////////////////////////////////////////////////////////////////////////// | |
| 13 /// \par Copyright (c) 2014-2018 Heinrichs Weikamp gmbh | |
| 14 /// | |
| 15 /// This program is free software: you can redistribute it and/or modify | |
| 16 /// it under the terms of the GNU General Public License as published by | |
| 17 /// the Free Software Foundation, either version 3 of the License, or | |
| 18 /// (at your option) any later version. | |
| 19 /// | |
| 20 /// This program is distributed in the hope that it will be useful, | |
| 21 /// but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 22 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 23 /// GNU General Public License for more details. | |
| 24 /// | |
| 25 /// You should have received a copy of the GNU General Public License | |
| 26 /// along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 27 ////////////////////////////////////////////////////////////////////////////// | |
| 28 | |
| 29 /* Includes ------------------------------------------------------------------*/ | |
| 1032 | 30 #include "configuration.h" |
| 38 | 31 #include "ostc.h" |
| 32 #include "stm32f4xx_hal.h" | |
| 1032 | 33 #include "cv_heartbeat.h" |
| 38 | 34 |
| 35 #ifndef BOOTLOADER_STANDALONE | |
| 36 #include "tCCR.h" | |
| 37 #endif | |
| 38 | |
| 39 /* Exported variables --------------------------------------------------------*/ | |
| 40 SPI_HandleTypeDef hspiDisplay; | |
| 41 SPI_HandleTypeDef cpu2DmaSpi; | |
| 42 | |
| 43 | |
| 44 UART_HandleTypeDef UartHandle; | |
|
300
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
140
diff
changeset
|
45 #ifdef USART_PIEZO |
| 38 | 46 UART_HandleTypeDef UartPiezoTxHandle; |
|
300
5ca177d2df5d
cleanup: remove commented/unused code, make static
Jan Mulder <jlmulder@xs4all.nl>
parents:
140
diff
changeset
|
47 #endif |
| 38 | 48 UART_HandleTypeDef UartIR_HUD_Handle; |
| 49 | |
| 50 __IO ITStatus UartReady = RESET; | |
| 870 | 51 __IO ITStatus UartReadyHUD = RESET; |
| 38 | 52 |
| 53 /* Private types -------------------------------------------------------------*/ | |
| 54 | |
| 55 /* Private variables ---------------------------------------------------------*/ | |
| 56 | |
| 57 /* Private variables with external access via get_xxx() function -------------*/ | |
|
885
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
58 static uint8_t hardwareDisplay = 0; //< either OSTC4 LCD (=0) or new Screen (=1) |
| 1032 | 59 |
| 60 static uint16_t rxBufRead = 0; | |
| 61 static uint16_t rxBufWrite = 0; | |
| 62 static uint8_t rxBufferUart[CHUNK_SIZE * CHUNKS_PER_BUFFER]; /* The complete buffer has a X * chunk size to allow variations in buffer read time */ | |
| 63 | |
| 38 | 64 /* Private function prototypes -----------------------------------------------*/ |
| 65 | |
| 66 /* Exported functions --------------------------------------------------------*/ | |
| 67 | |
| 68 /** SPI init function | |
| 69 * called from HAL | |
| 70 */ | |
| 71 void MX_SPI_Init(void) | |
| 72 { | |
| 73 hspiDisplay.Instance = SPI5; | |
| 74 hspiDisplay.Init.Mode = SPI_MODE_MASTER; | |
| 75 hspiDisplay.Init.Direction = SPI_DIRECTION_2LINES; | |
| 76 hspiDisplay.Init.DataSize = SPI_DATASIZE_8BIT; | |
| 77 hspiDisplay.Init.CLKPolarity = SPI_POLARITY_LOW; | |
| 78 hspiDisplay.Init.CLKPhase = SPI_PHASE_1EDGE; | |
| 79 hspiDisplay.Init.NSS = SPI_NSS_SOFT; | |
| 80 hspiDisplay.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;//SPI_BAUDRATEPRESCALER_4;//SPI_BAUDRATEPRESCALER_256; | |
| 81 hspiDisplay.Init.FirstBit = SPI_FIRSTBIT_MSB; | |
| 82 hspiDisplay.Init.TIMode = SPI_TIMODE_DISABLED; | |
| 83 hspiDisplay.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED; | |
| 84 HAL_SPI_Init(&hspiDisplay); | |
| 85 | |
| 86 cpu2DmaSpi.Instance = SPI1; | |
| 87 cpu2DmaSpi.Init.Mode = SPI_MODE_MASTER; | |
| 88 cpu2DmaSpi.Init.Direction = SPI_DIRECTION_2LINES; | |
| 89 cpu2DmaSpi.Init.DataSize = SPI_DATASIZE_8BIT; | |
| 90 cpu2DmaSpi.Init.CLKPolarity = SPI_POLARITY_LOW; | |
| 91 cpu2DmaSpi.Init.CLKPhase = SPI_PHASE_1EDGE; | |
| 92 cpu2DmaSpi.Init.NSS = SPI_NSS_SOFT;//SPI_NSS_HARD_OUTPUT;//SPI_NSS_SOFT; | |
|
140
f6c52eb0e25d
Increase prescalar => frame takes about 4ms.
Ideenmodellierer
parents:
104
diff
changeset
|
93 cpu2DmaSpi.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_128; |
| 38 | 94 cpu2DmaSpi.Init.FirstBit = SPI_FIRSTBIT_MSB; |
| 95 cpu2DmaSpi.Init.TIMode = SPI_TIMODE_DISABLED; | |
| 96 cpu2DmaSpi.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLED; | |
| 97 cpu2DmaSpi.Init.CRCPolynomial = 7; | |
| 98 | |
| 99 HAL_SPI_Init(&cpu2DmaSpi); | |
| 100 } | |
| 101 | |
| 870 | 102 |
| 103 void MX_GPIO_Backlight_max_static_only_Init(void) | |
| 104 { | |
| 105 GPIO_InitTypeDef GPIO_InitStruct; | |
| 106 TIM_BACKLIGHT_GPIO_ENABLE(); | |
| 107 | |
| 108 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
| 109 GPIO_InitStruct.Pull = GPIO_NOPULL;//GPIO_PULLUP; /* should be normally high */ | |
| 110 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
| 111 | |
| 112 GPIO_InitStruct.Pin = TIM_BACKLIGHT_PIN; | |
| 113 HAL_GPIO_Init(TIM_BACKLIGHT_GPIO_PORT, &GPIO_InitStruct); | |
| 114 | |
| 115 HAL_GPIO_WritePin(TIM_BACKLIGHT_GPIO_PORT,TIM_BACKLIGHT_PIN,GPIO_PIN_SET); | |
| 116 } | |
| 117 | |
| 118 | |
| 119 void MX_GPIO_One_Button_only_Init(void) | |
| 120 { | |
| 121 GPIO_InitTypeDef GPIO_InitStruct; | |
| 122 BUTTON_NEXT_GPIO_ENABLE(); | |
| 123 | |
| 124 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
| 125 GPIO_InitStruct.Pull = GPIO_NOPULL;//GPIO_PULLUP; /* should be normally high */ | |
| 126 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
| 127 | |
| 128 GPIO_InitStruct.Pin = BUTTON_NEXT_PIN; | |
| 129 HAL_GPIO_Init(BUTTON_NEXT_GPIO_PORT, &GPIO_InitStruct); | |
| 130 } | |
| 131 | |
| 132 | |
| 133 GPIO_PinState MX_GPIO_Read_The_One_Button(void) | |
| 134 { | |
| 135 return HAL_GPIO_ReadPin(BUTTON_NEXT_GPIO_PORT, BUTTON_NEXT_PIN); | |
| 136 } | |
| 137 | |
| 38 | 138 void MX_GPIO_Init(void) |
| 139 { | |
| 140 GPIO_InitTypeDef GPIO_InitStruct; | |
| 141 | |
| 142 DISPLAY_CSB_GPIO_ENABLE(); | |
| 143 DISPLAY_RESETB_GPIO_ENABLE(); | |
| 144 EXTFLASH_CSB_GPIO_ENABLE(); | |
| 145 SMALLCPU_CSB_GPIO_ENABLE(); | |
| 146 OSCILLOSCOPE_GPIO_ENABLE(); | |
| 147 OSCILLOSCOPE2_GPIO_ENABLE(); | |
| 879 | 148 BLE_UBLOX_DSR_GPIO_ENABLE(); |
| 38 | 149 |
| 150 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
| 151 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
| 152 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
| 153 | |
| 154 GPIO_InitStruct.Pin = DISPLAY_CSB_PIN; | |
| 155 HAL_GPIO_Init(DISPLAY_CSB_GPIO_PORT, &GPIO_InitStruct); | |
| 156 | |
| 157 GPIO_InitStruct.Pin = DISPLAY_RESETB_PIN; | |
| 158 HAL_GPIO_Init(DISPLAY_RESETB_GPIO_PORT, &GPIO_InitStruct); | |
| 159 | |
| 160 GPIO_InitStruct.Pin = EXTFLASH_CSB_PIN; | |
| 161 HAL_GPIO_Init(EXTFLASH_CSB_GPIO_PORT, &GPIO_InitStruct); | |
| 162 | |
| 163 GPIO_InitStruct.Pin = OSCILLOSCOPE_PIN; | |
| 164 HAL_GPIO_Init(OSCILLOSCOPE_GPIO_PORT, &GPIO_InitStruct); | |
| 165 | |
| 166 GPIO_InitStruct.Pin = OSCILLOSCOPE2_PIN; | |
| 167 HAL_GPIO_Init(OSCILLOSCOPE2_GPIO_PORT, &GPIO_InitStruct); | |
| 168 | |
| 169 #ifdef DISPLAY_BACKLIGHT_PIN | |
| 170 DISPLAY_BACKLIGHT_GPIO_ENABLE(); | |
| 171 GPIO_InitStruct.Pin = DISPLAY_BACKLIGHT_PIN; | |
| 172 HAL_GPIO_Init(DISPLAY_BACKLIGHT_GPIO_PORT, &GPIO_InitStruct); | |
| 173 HAL_GPIO_WritePin(DISPLAY_BACKLIGHT_GPIO_PORT,DISPLAY_BACKLIGHT_PIN,GPIO_PIN_SET); | |
| 174 #endif | |
| 175 | |
| 176 #ifdef SMALLCPU_CSB_PIN | |
| 177 SMALLCPU_CSB_GPIO_ENABLE(); | |
| 178 GPIO_InitStruct.Pin = SMALLCPU_CSB_PIN; | |
| 179 HAL_GPIO_Init(SMALLCPU_CSB_GPIO_PORT, &GPIO_InitStruct); | |
| 180 HAL_GPIO_WritePin(SMALLCPU_CSB_GPIO_PORT,SMALLCPU_CSB_PIN,GPIO_PIN_SET); | |
| 181 #endif | |
| 182 | |
| 183 #ifdef SMALLCPU_BOOT0_PIN | |
| 184 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
| 185 SMALLCPU_BOOT0_GPIO_ENABLE(); | |
| 186 GPIO_InitStruct.Pin = SMALLCPU_BOOT0_PIN; | |
| 187 HAL_GPIO_Init(SMALLCPU_BOOT0_GPIO_PORT, &GPIO_InitStruct); | |
| 188 HAL_GPIO_WritePin(SMALLCPU_BOOT0_GPIO_PORT,SMALLCPU_BOOT0_PIN,GPIO_PIN_RESET); | |
| 189 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
| 190 #endif | |
| 191 | |
| 192 #ifdef IR_HUD_ENABLE_PIN | |
| 193 IR_HUD_ENABLE_GPIO_ENABLE(); | |
| 194 GPIO_InitStruct.Pin = IR_HUD_ENABLE_PIN; | |
| 195 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
| 196 HAL_GPIO_Init(IR_HUD_ENABLE_GPIO_PORT, &GPIO_InitStruct); | |
| 197 HAL_GPIO_WritePin(IR_HUD_ENABLE_GPIO_PORT,IR_HUD_ENABLE_PIN,GPIO_PIN_SET); | |
| 198 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
| 199 #endif | |
| 200 | |
| 201 #ifdef BLE_NENABLE_PIN | |
| 202 BLE_NENABLE_GPIO_ENABLE(); | |
| 203 MX_Bluetooth_PowerOff(); | |
| 204 #endif | |
| 205 | |
| 206 #ifdef TESTPIN | |
| 207 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
| 208 TEST_GPIO_ENABLE(); | |
| 209 GPIO_InitStruct.Pin = TEST_PIN; | |
| 210 HAL_GPIO_Init(TEST_GPIO_PORT, &GPIO_InitStruct); | |
| 211 HAL_GPIO_WritePin(TEST_GPIO_PORT,TEST_PIN,GPIO_PIN_SET); | |
| 212 GPIO_InitStruct.Pull = GPIO_PULLUP; | |
| 213 #endif | |
| 214 } | |
| 215 | |
| 216 | |
| 217 void MX_TestPin_High(void) | |
| 218 { | |
| 219 #ifdef TESTPIN | |
| 220 HAL_GPIO_WritePin(TEST_GPIO_PORT,TEST_PIN,GPIO_PIN_SET); | |
| 221 #endif | |
| 222 } | |
| 223 | |
| 224 | |
| 225 void MX_TestPin_Low(void) | |
| 226 { | |
| 227 #ifdef TESTPIN | |
| 228 HAL_GPIO_WritePin(TEST_GPIO_PORT,TEST_PIN,GPIO_PIN_RESET); | |
| 229 #endif | |
| 230 } | |
| 231 | |
| 232 void MX_Bluetooth_PowerOn(void) | |
| 233 { | |
| 234 GPIO_InitTypeDef GPIO_InitStruct; | |
| 235 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
| 236 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
| 237 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
| 238 GPIO_InitStruct.Pin = BLE_NENABLE_PIN; | |
| 239 HAL_GPIO_Init(BLE_NENABLE_GPIO_PORT, &GPIO_InitStruct); | |
| 240 HAL_GPIO_WritePin(BLE_NENABLE_GPIO_PORT,BLE_NENABLE_PIN,GPIO_PIN_RESET); | |
| 879 | 241 |
| 242 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
| 243 GPIO_InitStruct.Pull = GPIO_PULLDOWN; | |
| 244 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
| 245 GPIO_InitStruct.Pin = BLE_UBLOX_DSR_PIN; | |
| 246 HAL_GPIO_Init(BLE_UBLOX_DSR_GPIO_PORT, &GPIO_InitStruct); | |
| 247 HAL_GPIO_WritePin(BLE_UBLOX_DSR_GPIO_PORT,BLE_UBLOX_DSR_PIN,GPIO_PIN_RESET); | |
| 38 | 248 } |
| 249 | |
| 250 | |
| 251 void MX_Bluetooth_PowerOff(void) | |
| 252 { | |
| 253 GPIO_InitTypeDef GPIO_InitStruct; | |
| 254 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
| 255 GPIO_InitStruct.Pin = BLE_NENABLE_PIN; | |
| 256 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
| 257 HAL_GPIO_Init(BLE_NENABLE_GPIO_PORT, &GPIO_InitStruct); | |
| 879 | 258 HAL_GPIO_WritePin(BLE_UBLOX_DSR_GPIO_PORT,BLE_UBLOX_DSR_PIN,GPIO_PIN_RESET); |
| 38 | 259 } |
| 260 | |
| 261 | |
| 262 void MX_SmallCPU_Reset_To_Boot(void) | |
| 263 { | |
| 264 #ifdef SMALLCPU_NRESET_PIN | |
| 265 GPIO_InitTypeDef GPIO_InitStruct; | |
| 266 | |
| 267 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
| 268 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
| 269 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
| 270 | |
| 271 SMALLCPU_NRESET_GPIO_ENABLE(); | |
| 272 GPIO_InitStruct.Pin = SMALLCPU_NRESET_PIN; | |
| 273 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); | |
| 274 HAL_GPIO_WritePin(SMALLCPU_NRESET_GPIO_PORT,SMALLCPU_NRESET_PIN,GPIO_PIN_RESET); | |
| 275 HAL_GPIO_WritePin(SMALLCPU_BOOT0_GPIO_PORT,SMALLCPU_BOOT0_PIN,GPIO_PIN_SET); | |
| 276 HAL_Delay(2); | |
| 277 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
| 278 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); | |
| 279 HAL_Delay(100); | |
| 280 HAL_GPIO_WritePin(SMALLCPU_BOOT0_GPIO_PORT,SMALLCPU_BOOT0_PIN,GPIO_PIN_RESET); | |
| 281 #endif | |
| 282 } | |
| 283 | |
| 870 | 284 |
| 285 void MX_SmallCPU_NO_Reset_Helper(void) | |
| 286 { | |
| 287 #ifdef SMALLCPU_NRESET_PIN | |
| 288 GPIO_InitTypeDef GPIO_InitStruct; | |
| 289 | |
| 290 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
| 291 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
| 292 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
| 293 | |
| 294 SMALLCPU_NRESET_GPIO_ENABLE(); | |
| 295 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); | |
| 296 HAL_GPIO_WritePin(SMALLCPU_NRESET_GPIO_PORT,SMALLCPU_NRESET_PIN,GPIO_PIN_SET); | |
| 297 // HAL_Delay(100); | |
| 298 // GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
| 299 // HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); | |
| 300 #endif | |
| 301 } | |
| 302 | |
| 303 | |
| 38 | 304 void MX_SmallCPU_Reset_To_Standard(void) |
| 305 { | |
| 306 #ifdef SMALLCPU_NRESET_PIN | |
| 307 GPIO_InitTypeDef GPIO_InitStruct; | |
| 308 | |
| 309 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
| 310 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
| 311 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
| 312 | |
| 313 SMALLCPU_NRESET_GPIO_ENABLE(); | |
| 314 GPIO_InitStruct.Pin = SMALLCPU_NRESET_PIN; | |
| 315 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); | |
| 316 HAL_GPIO_WritePin(SMALLCPU_NRESET_GPIO_PORT,SMALLCPU_NRESET_PIN,GPIO_PIN_RESET); | |
| 317 HAL_GPIO_WritePin(SMALLCPU_BOOT0_GPIO_PORT,SMALLCPU_BOOT0_PIN,GPIO_PIN_RESET); | |
| 318 HAL_Delay(2); | |
| 319 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
| 320 HAL_GPIO_Init(SMALLCPU_NRESET_GPIO_PORT, &GPIO_InitStruct); | |
| 321 #endif | |
| 322 } | |
| 323 | |
| 870 | 324 |
| 325 uint8_t MX_UART_ButtonAdjust(uint8_t *array) | |
| 326 { | |
| 327 #ifdef USART_PIEZO | |
| 328 uint8_t answer[4]; | |
| 329 HAL_UART_Transmit(&UartPiezoTxHandle,array,4,1000); | |
| 330 HAL_UART_Receive(&UartPiezoTxHandle,answer,4,2000); | |
| 331 if( (answer[0] == array[0]) | |
| 332 &&(answer[1] == array[1]) | |
| 333 &&(answer[2] == array[2]) | |
| 334 &&(answer[3] == array[3])) | |
| 335 return 1; | |
| 336 #endif | |
| 337 return 0; | |
| 338 } | |
| 339 | |
| 340 | |
| 38 | 341 void MX_UART_Init(void) |
| 342 { | |
| 343 /*##-1- Configure the UART peripheral ######################################*/ | |
| 344 /* Put the USART peripheral in the Asynchronous mode (UART Mode) */ | |
| 345 /* UART1 configured as follow: | |
| 346 - Word Length = 8 Bits | |
| 347 - Stop Bit = One Stop bit | |
| 348 - Parity = None | |
| 349 - BaudRate = 9600 baud | |
| 350 - Hardware flow control disabled (RTS and CTS signals) */ | |
| 351 | |
| 352 #ifdef USARTx_CTS_PIN | |
| 353 UartHandle.Init.HwFlowCtl = UART_HWCONTROL_RTS_CTS; | |
| 354 #else | |
| 355 UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE; | |
| 356 #endif | |
| 357 UartHandle.Instance = USARTx; | |
| 358 UartHandle.Init.BaudRate = 115200; | |
| 359 UartHandle.Init.WordLength = UART_WORDLENGTH_8B; | |
| 360 UartHandle.Init.StopBits = UART_STOPBITS_1; | |
| 361 UartHandle.Init.Parity = UART_PARITY_NONE; | |
| 362 UartHandle.Init.Mode = UART_MODE_TX_RX; | |
| 363 HAL_UART_Init(&UartHandle); | |
| 364 | |
| 365 #ifdef USART_PIEZO | |
| 366 UartPiezoTxHandle.Instance = USART_PIEZO; | |
| 367 UartPiezoTxHandle.Init.BaudRate = 1200; | |
| 368 UartPiezoTxHandle.Init.WordLength = UART_WORDLENGTH_8B; | |
| 369 UartPiezoTxHandle.Init.StopBits = UART_STOPBITS_1; | |
| 370 UartPiezoTxHandle.Init.Parity = UART_PARITY_NONE; | |
| 371 UartPiezoTxHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE; | |
| 372 UartPiezoTxHandle.Init.Mode = UART_MODE_TX_RX; | |
| 373 | |
| 374 HAL_UART_Init(&UartPiezoTxHandle); | |
| 375 #endif | |
| 376 | |
| 377 #ifdef USART_IR_HUD | |
| 378 UartIR_HUD_Handle.Instance = USART_IR_HUD; | |
| 379 UartIR_HUD_Handle.Init.BaudRate = 2400; | |
| 380 UartIR_HUD_Handle.Init.WordLength = UART_WORDLENGTH_8B; | |
| 381 UartIR_HUD_Handle.Init.StopBits = UART_STOPBITS_1; | |
| 382 UartIR_HUD_Handle.Init.Parity = UART_PARITY_NONE; | |
| 383 UartIR_HUD_Handle.Init.HwFlowCtl = UART_HWCONTROL_NONE; | |
| 384 UartIR_HUD_Handle.Init.Mode = UART_MODE_TX_RX; | |
| 385 | |
| 386 HAL_UART_Init(&UartIR_HUD_Handle); | |
| 387 #endif | |
| 388 } | |
| 389 | |
| 1032 | 390 static DMA_HandleTypeDef hdma_uart_BT_rx; |
| 391 | |
| 392 void MX_UART_BT_Init_DMA() | |
| 393 { | |
| 394 | |
| 395 __DMA2_CLK_ENABLE(); | |
| 396 __HAL_RCC_DMA2_CLK_ENABLE(); | |
| 397 | |
| 398 hdma_uart_BT_rx.Instance = DMA2_Stream2; | |
| 399 hdma_uart_BT_rx.Init.Channel = DMA_CHANNEL_4; | |
| 400 hdma_uart_BT_rx.Init.Direction = DMA_PERIPH_TO_MEMORY; | |
| 401 hdma_uart_BT_rx.Init.PeriphInc = DMA_PINC_DISABLE; | |
| 402 hdma_uart_BT_rx.Init.MemInc = DMA_MINC_ENABLE; | |
| 403 hdma_uart_BT_rx.Init.PeriphDataAlignment = DMA_MDATAALIGN_BYTE; | |
| 404 hdma_uart_BT_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; | |
| 405 hdma_uart_BT_rx.Init.Mode = DMA_NORMAL; | |
| 406 hdma_uart_BT_rx.Init.Priority = DMA_PRIORITY_LOW; | |
| 407 hdma_uart_BT_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE; | |
| 408 HAL_DMA_Init(&hdma_uart_BT_rx); | |
| 409 | |
| 410 __HAL_LINKDMA(&UartHandle, hdmarx, hdma_uart_BT_rx); | |
| 411 | |
| 412 HAL_NVIC_SetPriority(DMA2_Stream2_IRQn, 0, 0); | |
| 413 HAL_NVIC_EnableIRQ(DMA2_Stream2_IRQn); | |
| 414 } | |
| 415 | |
| 416 | |
| 417 uint8_t UART_getChar() | |
| 418 { | |
| 419 uint8_t retChar = 0; | |
| 420 | |
| 421 if((rxBufRead != rxBufWrite) && (rxBufferUart[rxBufRead] != 0)) | |
| 422 { | |
| 423 retChar = rxBufferUart[rxBufRead]; | |
| 424 rxBufferUart[rxBufRead++] = 0; | |
| 425 if(rxBufRead == CHUNK_SIZE * CHUNKS_PER_BUFFER) | |
| 426 { | |
| 427 rxBufRead = 0; | |
| 428 } | |
| 429 } | |
| 430 return retChar; | |
| 431 } | |
| 432 | |
| 433 void UART_StartDMARx() | |
| 434 { | |
| 435 HAL_UART_Receive_DMA (&UartHandle, &rxBufferUart[rxBufWrite], CHUNK_SIZE); | |
| 436 rxBufWrite += CHUNK_SIZE; | |
| 437 if(rxBufWrite >= CHUNK_SIZE * CHUNKS_PER_BUFFER) | |
| 438 { | |
| 439 rxBufWrite = 0; | |
| 440 } | |
| 441 } | |
| 442 | |
| 443 void DMA2_Stream2_IRQHandler(void) | |
| 444 { | |
| 445 HAL_DMA_IRQHandler(&hdma_uart_BT_rx); | |
| 446 } | |
| 447 | |
| 38 | 448 void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) |
| 449 { | |
| 450 if(huart == &UartHandle) | |
| 451 UartReady = SET; | |
| 452 } | |
| 453 | |
|
321
37ee61f93124
Moved indication variable for received HUD data to tCCR file.
ideenmodellierer
parents:
300
diff
changeset
|
454 |
| 38 | 455 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) |
| 456 { | |
| 457 if(huart == &UartHandle) | |
| 1032 | 458 { |
| 459 #ifdef ENABLE_PULSE_SENSOR_BT | |
| 460 if(cv_heartbeat_getState() != SENSOR_HB_OFFLINE) | |
| 461 { | |
| 462 UART_StartDMARx(); | |
| 463 } | |
| 464 else | |
| 465 { | |
| 466 UartReady = SET; | |
| 467 } | |
| 468 #else | |
| 469 UartReady = SET; | |
| 470 #endif | |
| 471 } | |
| 38 | 472 else |
| 473 if(huart == &UartIR_HUD_Handle) | |
| 474 { | |
| 870 | 475 #ifndef BOOTLOADER_STANDALONE |
|
321
37ee61f93124
Moved indication variable for received HUD data to tCCR file.
ideenmodellierer
parents:
300
diff
changeset
|
476 tCCR_SetRXIndication(); |
| 870 | 477 #endif |
| 478 UartReadyHUD = SET; | |
| 38 | 479 } |
| 480 } | |
| 481 | |
| 482 void MX_tell_reset_logik_alles_ok(void) | |
| 483 { | |
| 484 #ifdef RESET_LOGIC_ALLES_OK_PIN | |
| 485 GPIO_InitTypeDef GPIO_InitStruct; | |
| 486 | |
| 487 RESET_LOGIC_ALLES_OK_GPIO_ENABLE(); | |
| 488 | |
| 489 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; | |
| 490 GPIO_InitStruct.Pull = GPIO_NOPULL; | |
| 491 GPIO_InitStruct.Speed = GPIO_SPEED_LOW; | |
| 492 GPIO_InitStruct.Pin = RESET_LOGIC_ALLES_OK_PIN; | |
| 493 HAL_GPIO_Init(RESET_LOGIC_ALLES_OK_GPIO_PORT, &GPIO_InitStruct); | |
| 494 | |
| 495 HAL_GPIO_WritePin(RESET_LOGIC_ALLES_OK_GPIO_PORT,RESET_LOGIC_ALLES_OK_PIN,GPIO_PIN_RESET); | |
| 496 HAL_Delay(1); | |
| 497 HAL_GPIO_WritePin(RESET_LOGIC_ALLES_OK_GPIO_PORT,RESET_LOGIC_ALLES_OK_PIN,GPIO_PIN_SET); | |
| 498 | |
| 499 GPIO_InitStruct.Mode = GPIO_MODE_INPUT; | |
| 500 HAL_GPIO_Init(RESET_LOGIC_ALLES_OK_GPIO_PORT, &GPIO_InitStruct); | |
| 501 #endif | |
| 502 } | |
|
885
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
503 void SetDisplayVersion(uint8_t version) |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
504 { |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
505 if(version < 2) |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
506 { |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
507 hardwareDisplay = version; |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
508 } |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
509 } |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
510 uint8_t isNewDisplay() |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
511 { |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
512 uint8_t ret = 0; |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
513 if(hardwareDisplay == DISPLAY_VERSION_NEW) |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
514 { |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
515 ret = 1; |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
516 } |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
517 return ret; |
|
8d3f3a635397
Replaced global hardwareDisplay with unit access:
Ideenmodellierer
parents:
879
diff
changeset
|
518 } |
| 38 | 519 |
| 520 #ifndef BOOTLOADER_STANDALONE | |
| 521 void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart) | |
| 522 { | |
| 523 if(huart == &UartIR_HUD_Handle) | |
| 524 tCCR_restart(); | |
| 525 } | |
| 526 #endif |
