Rev 15 | Rev 17 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 15 | Rev 16 | ||
|---|---|---|---|
| Line 71... | Line 71... | ||
| 71 | // compensated temperature |
71 | // compensated temperature |
| 72 | int32_t comp_temp = -10000; |
72 | int32_t comp_temp = -10000; |
| 73 | 73 | ||
| 74 | int32_t timing = 0; |
74 | int32_t timing = 0; |
| 75 | 75 | ||
| 76 | /// A timer flag used to tell the PLX scanning code that it is time to send a frame |
- | |
| 77 | int8_t timerFlag = 0; |
- | |
| 78 | /// @brief count of how many consecutive timeouts before auto sending begins |
- | |
| 79 | int8_t timeoutCount = 0; |
- | |
| 80 | - | ||
| 81 | /* USER CODE END PV */ |
76 | /* USER CODE END PV */ |
| 82 | 77 | ||
| 83 | /* Private function prototypes -----------------------------------------------*/ |
78 | /* Private function prototypes -----------------------------------------------*/ |
| 84 | void SystemClock_Config(void); |
79 | void SystemClock_Config(void); |
| 85 | static void MX_GPIO_Init(void); |
80 | static void MX_GPIO_Init(void); |
| Line 98... | Line 93... | ||
| 98 | { |
93 | { |
| 99 | for (int i = 0; i < sizeof(PLX_SensorInfo); ++i) |
94 | for (int i = 0; i < sizeof(PLX_SensorInfo); ++i) |
| 100 | PutCharSerial(uc, info->bytes[i]); |
95 | PutCharSerial(uc, info->bytes[i]); |
| 101 | } |
96 | } |
| 102 | 97 | ||
| 103 | void libPLXcallbackResetSerialTimeout() |
- | |
| 104 | { |
- | |
| 105 | timerFlag = 0; |
- | |
| 106 | timeoutCount = 0; |
- | |
| 107 | } |
- | |
| 108 | 98 | ||
| 109 | void libPLXcallbackSendUserData() |
99 | void libPLXcallbackSendUserData() |
| 110 | { |
100 | { |
| 111 | // send MAP |
101 | // send MAP |
| 112 | PLX_SensorInfo info; |
102 | PLX_SensorInfo info; |
| Line 205... | Line 195... | ||
| 205 | uint32_t displayOff = lastTick + 10000; |
195 | uint32_t displayOff = lastTick + 10000; |
| 206 | uint32_t displayReinitialise = lastTick + DISPLAY_REINITIALISE; // every minute, reinitialise display because of risk of noise |
196 | uint32_t displayReinitialise = lastTick + DISPLAY_REINITIALISE; // every minute, reinitialise display because of risk of noise |
| 207 | 197 | ||
| 208 | uint8_t intensity = 2; |
198 | uint8_t intensity = 2; |
| 209 | 199 | ||
| 210 | /// @brief time of next auto send if needed |
- | |
| 211 | uint32_t timeout = 0; |
- | |
| 212 | 200 | ||
| 213 | ResetRxBuffer(&uc2); |
201 | ResetRxBuffer(&uc2); |
| 214 | 202 | ||
| 215 | resetPLX(); |
203 | resetPLX(); |
| 216 | // HAL_IWDG_Init(&hiwdg); |
204 | // HAL_IWDG_Init(&hiwdg); |
| Line 292... | Line 280... | ||
| 292 | int microsecs = mapTimingToMicroseconds(timing, 0); |
280 | int microsecs = mapTimingToMicroseconds(timing, 0); |
| 293 | __HAL_TIM_SET_AUTORELOAD(&htim1, microsecs + SAW_DELAY); |
281 | __HAL_TIM_SET_AUTORELOAD(&htim1, microsecs + SAW_DELAY); |
| 294 | } |
282 | } |
| 295 | } |
283 | } |
| 296 | 284 | ||
| 297 | // sort out auto-sending |
- | |
| 298 | if (HAL_GetTick() > timeout) |
- | |
| 299 | { |
285 | |
| 300 | timeout = HAL_GetTick() + T100MS; |
- | |
| 301 | if (timeoutCount < 2) |
- | |
| 302 | timeoutCount++; |
- | |
| 303 | else |
- | |
| 304 | timerFlag = 1; |
- | |
| 305 | } |
- | |
| 306 | - | ||
| 307 | // Handle PLX |
286 | // Handle PLX |
| 308 | libPLXpollData(&uc2, timerFlag); |
287 | libPLXpollData(&uc2); |
| 309 | 288 | ||
| 310 | /* USER CODE END WHILE */ |
289 | /* USER CODE END WHILE */ |
| 311 | 290 | ||
| 312 | /* USER CODE BEGIN 3 */ |
291 | /* USER CODE BEGIN 3 */ |
| 313 | watchdogWrite(); |
292 | watchdogWrite(); |