Rev 61 | Rev 63 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 61 | Rev 62 | ||
|---|---|---|---|
| Line 26... | Line 26... | ||
| 26 | #include "libPLX/plx.h" |
26 | #include "libPLX/plx.h" |
| 27 | #include "libSerial/serial.H" |
27 | #include "libSerial/serial.H" |
| 28 | #include "libSmallPrintf/small_printf.h" |
28 | #include "libSmallPrintf/small_printf.h" |
| 29 | #include "libNMEA/nmea.h" |
29 | #include "libNMEA/nmea.h" |
| 30 | #include "switches.h" |
30 | #include "switches.h" |
| - | 31 | #include<string.h> |
|
| 31 | 32 | ||
| 32 | /* USER CODE END Includes */ |
33 | /* USER CODE END Includes */ |
| 33 | 34 | ||
| 34 | /* Private typedef -----------------------------------------------------------*/ |
35 | /* Private typedef -----------------------------------------------------------*/ |
| 35 | /* USER CODE BEGIN PTD */ |
36 | /* USER CODE BEGIN PTD */ |
| Line 44... | Line 45... | ||
| 44 | /* USER CODE BEGIN PM */ |
45 | /* USER CODE BEGIN PM */ |
| 45 | 46 | ||
| 46 | /* USER CODE END PM */ |
47 | /* USER CODE END PM */ |
| 47 | 48 | ||
| 48 | /* Private variables ---------------------------------------------------------*/ |
49 | /* Private variables ---------------------------------------------------------*/ |
| 49 | SPI_HandleTypeDef hspi1; |
50 | SPI_HandleTypeDef hspi1; |
| 50 | 51 | ||
| 51 | TIM_HandleTypeDef htim2; |
52 | TIM_HandleTypeDef htim2; |
| 52 | TIM_HandleTypeDef htim3; |
53 | TIM_HandleTypeDef htim3; |
| 53 | TIM_HandleTypeDef htim9; |
54 | TIM_HandleTypeDef htim9; |
| 54 | 55 | ||
| Line 63... | Line 64... | ||
| 63 | context_t contexts[MAX_DISPLAYS]; |
64 | context_t contexts[MAX_DISPLAYS]; |
| 64 | 65 | ||
| 65 | /* timeout when the ignition is switched off */ |
66 | /* timeout when the ignition is switched off */ |
| 66 | #define IGNITION_OFF_TIMEOUT 30000UL |
67 | #define IGNITION_OFF_TIMEOUT 30000UL |
| 67 | 68 | ||
| - | 69 | // 500mS per logger period. |
|
| 68 | #define LOGGER_INTERVAL 500UL |
70 | #define LOGGER_INTERVAL 500UL |
| 69 | 71 | ||
| 70 | const int DialTimeout = 10000; // about 10 seconds after twiddle, save the dial position. |
72 | const int DialTimeout = 10000; // about 10 seconds after twiddle, save the dial position. |
| 71 | 73 | ||
| 72 | nvram_info_t dial_nvram[MAX_DISPLAYS] __attribute__((section(".NVRAM_Data"))); |
74 | nvram_info_t dial_nvram[MAX_DISPLAYS] __attribute__((section(".NVRAM_Data"))); |
| Line 113... | Line 115... | ||
| 113 | { |
115 | { |
| 114 | char initBuf[30]; |
116 | char initBuf[30]; |
| 115 | // switch to command mode |
117 | // switch to command mode |
| 116 | HAL_GPIO_WritePin(BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, GPIO_PIN_RESET); |
118 | HAL_GPIO_WritePin(BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, GPIO_PIN_RESET); |
| 117 | HAL_Delay(500); |
119 | HAL_Delay(500); |
| 118 | int initLen = small_sprintf(initBuf, "AT+UART=%ul,1,2\n", baudRate); |
120 | int initLen = small_sprintf(initBuf, "AT+UART=%lu,1,2\n", baudRate); |
| 119 | setBaud(ctl, 38400); |
121 | setBaud(ctl, 38400); |
| 120 | sendString(ctl, initBuf, initLen); |
122 | sendString(ctl, initBuf, initLen); |
| 121 | TxWaitEmpty(ctl); |
123 | TxWaitEmpty(ctl); |
| 122 | // switch back to normal comms at new baud rate |
124 | // switch back to normal comms at new baud rate |
| 123 | 125 | ||
| Line 126... | Line 128... | ||
| 126 | HAL_Delay(100); |
128 | HAL_Delay(100); |
| 127 | } |
129 | } |
| 128 | 130 | ||
| 129 | // workspace for RMC data read from GPS module. |
131 | // workspace for RMC data read from GPS module. |
| 130 | uint8_t rmc_buff[80]; |
132 | uint8_t rmc_buff[80]; |
| 131 | uint16_t rmc_length; |
133 | volatile uint16_t rmc_length; |
| 132 | 134 | ||
| 133 | uint8_t rmc_callback(uint8_t *data, uint16_t length) |
135 | uint8_t rmc_callback(uint8_t *data, uint16_t length) |
| 134 | { |
136 | { |
| 135 | rmc_length = length<sizeof(rmc_buff)?length : sizeof(rmc_buff); |
137 | rmc_length = length < sizeof(rmc_buff) ? length : sizeof(rmc_buff); |
| 136 | memcpy(rmc_buff, data, length); |
138 | memcpy(rmc_buff, data, length); |
| 137 | return 0; |
139 | return 0; |
| 138 | - | ||
| 139 | } |
140 | } |
| 140 | 141 | ||
| 141 | /* USER CODE END PFP */ |
142 | /* USER CODE END PFP */ |
| 142 | 143 | ||
| 143 | /* Private user code ---------------------------------------------------------*/ |
144 | /* Private user code ---------------------------------------------------------*/ |
| 144 | /* USER CODE BEGIN 0 */ |
145 | /* USER CODE BEGIN 0 */ |
| 145 | 146 | ||
| 146 | /* USER CODE END 0 */ |
147 | /* USER CODE END 0 */ |
| 147 | 148 | ||
| 148 | /** |
149 | /** |
| 149 | * @brief The application entry point. |
150 | * @brief The application entry point. |
| 150 | * @retval int |
151 | * @retval int |
| 151 | */ |
152 | */ |
| 152 | int main(void) |
153 | int main(void) |
| 153 | { |
154 | { |
| 154 | /* USER CODE BEGIN 1 */ |
155 | /* USER CODE BEGIN 1 */ |
| 155 | __HAL_RCC_SPI1_CLK_ENABLE(); |
156 | __HAL_RCC_SPI1_CLK_ENABLE(); |
| 156 | __HAL_RCC_USART1_CLK_ENABLE(); // PLX main port |
157 | __HAL_RCC_USART1_CLK_ENABLE(); // PLX main port |
| Line 270... | Line 271... | ||
| 270 | } |
271 | } |
| 271 | } |
272 | } |
| 272 | 273 | ||
| 273 | uint32_t timeout = 0; // |
274 | uint32_t timeout = 0; // |
| 274 | 275 | ||
| 275 | uint32_t nextTick = HAL_GetTick() + LOGGER_INTERVAL; |
276 | uint32_t nextTick = 0; |
| 276 | uint8_t log = 0; |
277 | uint8_t log = 0; |
| - | 278 | uint8_t logCount = 1000 / LOGGER_INTERVAL; |
|
| 277 | // PLX decoder protocols |
279 | // PLX decoder protocols |
| 278 | char PLXPacket = 0; |
280 | char PLXPacket = 0; |
| 279 | for (i = 0; i < MAXRDG; i++) |
281 | for (i = 0; i < MAXRDG; i++) |
| 280 | { |
282 | { |
| 281 | Info[i].Max = 0; |
283 | Info[i].Max = 0; |
| 282 | Info[i].Min = 0xFFF; // 12 bit max value |
284 | Info[i].Min = 0xFFF; // 12 bit max value |
| - | 285 | Info[i].sum = 0; // |
|
| - | 286 | Info[i].count=0; |
|
| 283 | } |
287 | } |
| 284 | 288 | ||
| 285 | int PLXPtr = 0; |
289 | int PLXPtr = 0; |
| 286 | 290 | ||
| 287 | while (1) |
291 | while (1) |
| 288 | { |
292 | { |
| 289 | 293 | ||
| 290 | // poll GPS Position/time on UART4 |
294 | // poll GPS Position/time on UART4 |
| 291 | (void) updateLocation(&loc, &uc4); |
295 | (void)updateLocation(&loc, &uc4); |
| 292 | if (loc.good) |
- | |
| 293 | { |
- | |
| 294 | - | ||
| 295 | loc.good = false; |
- | |
| 296 | } |
- | |
| 297 | if (loc.valid == 'V') |
296 | if (loc.valid == 'V') |
| 298 | memset(loc.time, '-', 6); |
297 | memset(loc.time, '-', 6); |
| 299 | 298 | ||
| - | 299 | // if permitted, log data from RMC packet |
|
| - | 300 | if (rmc_length && HAL_GPIO_ReadPin(BT_STATE_GPIO_Port, BT_STATE_Pin) == GPIO_PIN_SET) |
|
| - | 301 | { |
|
| - | 302 | sendString(&uc3, rmc_buff, rmc_length); |
|
| - | 303 | rmc_length = 0; |
|
| - | 304 | nextTick = HAL_GetTick() + LOGGER_INTERVAL; |
|
| - | 305 | logCount = 0; |
|
| - | 306 | log = 1; |
|
| - | 307 | } |
|
| - | 308 | ||
| - | 309 | // time several counted logger intervals after RMC recieved, enable logger each timeout. |
|
| - | 310 | if (logCount < ((1000 / LOGGER_INTERVAL)-1) && HAL_GetTick() > nextTick) |
|
| - | 311 | { |
|
| - | 312 | nextTick = HAL_GetTick() + LOGGER_INTERVAL; |
|
| - | 313 | ++logCount; |
|
| - | 314 | log = 1; |
|
| - | 315 | } |
|
| - | 316 | ||
| 300 | // Handle the bluetooth pairing / reset function by pressing both buttons. |
317 | // Handle the bluetooth pairing / reset function by pressing both buttons. |
| 301 | if ((push_pos[0] == 1) && (push_pos[1] == 1)) |
318 | if ((push_pos[0] == 1) && (push_pos[1] == 1)) |
| 302 | { |
319 | { |
| 303 | HAL_GPIO_WritePin(BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, |
320 | HAL_GPIO_WritePin(BT_BUTTON_GPIO_Port, BT_BUTTON_Pin, |
| 304 | GPIO_PIN_RESET); |
321 | GPIO_PIN_RESET); |
| Line 324... | Line 341... | ||
| 324 | { |
341 | { |
| 325 | 342 | ||
| 326 | // do turn off screen |
343 | // do turn off screen |
| 327 | } |
344 | } |
| 328 | } |
345 | } |
| - | 346 | ||
| - | 347 | ||
| 329 | for (chr = 0; chr < cc; chr++) |
348 | for (chr = 0; chr < cc; chr++) |
| 330 | { |
349 | { |
| 331 | char c = GetCharSerial(&uc1); |
350 | char c = GetCharSerial(&uc1); |
| 332 | 351 | ||
| 333 | if (c == PLX_Start) // at any time if the start byte appears, reset the pointers |
352 | if (c == PLX_Start) // at any time if the start byte appears, reset the pointers |
| 334 | { |
353 | { |
| 335 | PLXPtr = 0; // reset the pointer |
354 | PLXPtr = 0; // reset the pointer |
| 336 | PLXPacket = 1; |
355 | PLXPacket = 1; |
| 337 | timeout = 0; // Reset the timer |
356 | timeout = 0; // Reset the timer |
| 338 | if (HAL_GetTick() > nextTick) |
- | |
| 339 | { |
- | |
| 340 | nextTick = HAL_GetTick() + LOGGER_INTERVAL; |
- | |
| 341 | log = 1; |
- | |
| 342 | } |
- | |
| 343 | else |
- | |
| 344 | log = 0; |
- | |
| 345 | } |
357 | } |
| 346 | else if (c == PLX_Stop) |
358 | else if (c == PLX_Stop) |
| 347 | { |
359 | { |
| 348 | if (PLXPacket) |
360 | if (PLXPacket) |
| 349 | { |
361 | { |
| Line 365... | Line 377... | ||
| 365 | } |
377 | } |
| 366 | if (Info[i].data < Info[i].Min) |
378 | if (Info[i].data < Info[i].Min) |
| 367 | { |
379 | { |
| 368 | Info[i].Min = Info[i].data; |
380 | Info[i].Min = Info[i].data; |
| 369 | } |
381 | } |
| - | 382 | // take an avarage |
|
| - | 383 | Info[i].sum += Info[i].data; |
|
| - | 384 | Info[i].count ++; |
|
| 370 | 385 | ||
| 371 | // Send items to BT if it is in connected state |
386 | // Send items to BT if it is in connected state |
| 372 | if (HAL_GPIO_ReadPin(BT_STATE_GPIO_Port, BT_STATE_Pin) == GPIO_PIN_SET) |
387 | if (log && HAL_GPIO_ReadPin(BT_STATE_GPIO_Port, BT_STATE_Pin) == GPIO_PIN_SET) |
| 373 | { |
388 | { |
| 374 | if (rmc_length) |
- | |
| 375 | { |
- | |
| 376 | sendString(&uc3, rmc_buff, rmc_length); |
- | |
| 377 | rmc_length = 0; |
- | |
| 378 | } |
- | |
| 379 | 389 | ||
| 380 | if (log) |
- | |
| 381 | { |
- | |
| 382 | - | ||
| 383 | char outbuff[100]; |
390 | char outbuff[100]; |
| 384 | 391 | ||
| 385 | int cnt = small_sprintf(outbuff, |
392 | int cnt = small_sprintf(outbuff, |
| 386 | "$PLLOG,%d,%d,%d", |
393 | "$PLLOG,%d,%d,%d,%ld", |
| - | 394 | logCount, |
|
| 387 | Info[i].observation, |
395 | Info[i].observation, |
| 388 | Info[i].instance, |
396 | Info[i].instance, |
| 389 | Info[i].data); |
397 | Info[i].count==0? 0: Info[i].sum/Info[i].count); |
| 390 | 398 | ||
| 391 | // NMEA style checksum |
399 | // NMEA style checksum |
| 392 | int ck; |
400 | int ck; |
| 393 | int sum = 0; |
401 | int sum = 0; |
| 394 | for (ck = 1; ck < cnt; ck++) |
402 | for (ck = 1; ck < cnt; ck++) |
| 395 | sum += outbuff[ck]; |
403 | sum += outbuff[ck]; |
| 396 | cnt += small_sprintf(outbuff + cnt, "*%02X\n", |
404 | cnt += small_sprintf(outbuff + cnt, "*%02X\n", |
| 397 | sum & 0xFF); |
405 | sum & 0xFF); |
| 398 | sendString(&uc3, outbuff, cnt); |
406 | sendString(&uc3, outbuff, cnt); |
| 399 | } |
- | |
| 400 | } |
407 | } |
| 401 | } |
408 | } |
| 402 | - | ||
| - | 409 | log = 0; |
|
| 403 | // now to display the information |
410 | // now to display the information |
| 404 | int suppress = DisplayCurrent(0, -1); |
411 | int suppress = DisplayCurrent(0, -1); |
| 405 | DisplayCurrent(1, suppress); |
412 | DisplayCurrent(1, suppress); |
| 406 | } |
413 | } |
| 407 | PLXPtr = 0; |
414 | PLXPtr = 0; |
| 408 | PLXPacket = 0; |
415 | PLXPacket = 0; |
| Line 445... | Line 452... | ||
| 445 | } |
452 | } |
| 446 | /* USER CODE END 3 */ |
453 | /* USER CODE END 3 */ |
| 447 | } |
454 | } |
| 448 | 455 | ||
| 449 | /** |
456 | /** |
| 450 | * @brief System Clock Configuration |
457 | * @brief System Clock Configuration |
| 451 | * @retval None |
458 | * @retval None |
| 452 | */ |
459 | */ |
| 453 | void SystemClock_Config(void) |
460 | void SystemClock_Config(void) |
| 454 | { |
461 | { |
| 455 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
462 | RCC_OscInitTypeDef RCC_OscInitStruct = {0}; |
| 456 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
463 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; |
| 457 | 464 | ||
| 458 | /** Configure the main internal regulator output voltage |
465 | /** Configure the main internal regulator output voltage |
| 459 | */ |
466 | */ |
| 460 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); |
467 | __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); |
| 461 | 468 | ||
| 462 | /** Initializes the RCC Oscillators according to the specified parameters |
469 | /** Initializes the RCC Oscillators according to the specified parameters |
| 463 | * in the RCC_OscInitTypeDef structure. |
470 | * in the RCC_OscInitTypeDef structure. |
| 464 | */ |
471 | */ |
| 465 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; |
472 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; |
| 466 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
473 | RCC_OscInitStruct.HSEState = RCC_HSE_ON; |
| 467 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
474 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; |
| 468 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; |
475 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; |
| 469 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12; |
476 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12; |
| Line 472... | Line 479... | ||
| 472 | { |
479 | { |
| 473 | Error_Handler(); |
480 | Error_Handler(); |
| 474 | } |
481 | } |
| 475 | 482 | ||
| 476 | /** Initializes the CPU, AHB and APB buses clocks |
483 | /** Initializes the CPU, AHB and APB buses clocks |
| 477 | */ |
484 | */ |
| 478 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |
485 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; |
| 479 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; |
- | |
| 480 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
486 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; |
| 481 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
487 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; |
| 482 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
488 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; |
| 483 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
489 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; |
| 484 | 490 | ||
| Line 487... | Line 493... | ||
| 487 | Error_Handler(); |
493 | Error_Handler(); |
| 488 | } |
494 | } |
| 489 | } |
495 | } |
| 490 | 496 | ||
| 491 | /** |
497 | /** |
| 492 | * @brief SPI1 Initialization Function |
498 | * @brief SPI1 Initialization Function |
| 493 | * @param None |
499 | * @param None |
| 494 | * @retval None |
500 | * @retval None |
| 495 | */ |
501 | */ |
| 496 | static void MX_SPI1_Init(void) |
502 | static void MX_SPI1_Init(void) |
| 497 | { |
503 | { |
| 498 | 504 | ||
| 499 | /* USER CODE BEGIN SPI1_Init 0 */ |
505 | /* USER CODE BEGIN SPI1_Init 0 */ |
| 500 | 506 | ||
| Line 521... | Line 527... | ||
| 521 | Error_Handler(); |
527 | Error_Handler(); |
| 522 | } |
528 | } |
| 523 | /* USER CODE BEGIN SPI1_Init 2 */ |
529 | /* USER CODE BEGIN SPI1_Init 2 */ |
| 524 | 530 | ||
| 525 | /* USER CODE END SPI1_Init 2 */ |
531 | /* USER CODE END SPI1_Init 2 */ |
| 526 | - | ||
| 527 | } |
532 | } |
| 528 | 533 | ||
| 529 | /** |
534 | /** |
| 530 | * @brief TIM2 Initialization Function |
535 | * @brief TIM2 Initialization Function |
| 531 | * @param None |
536 | * @param None |
| 532 | * @retval None |
537 | * @retval None |
| 533 | */ |
538 | */ |
| 534 | static void MX_TIM2_Init(void) |
539 | static void MX_TIM2_Init(void) |
| 535 | { |
540 | { |
| 536 | 541 | ||
| 537 | /* USER CODE BEGIN TIM2_Init 0 */ |
542 | /* USER CODE BEGIN TIM2_Init 0 */ |
| 538 | 543 | ||
| Line 566... | Line 571... | ||
| 566 | Error_Handler(); |
571 | Error_Handler(); |
| 567 | } |
572 | } |
| 568 | /* USER CODE BEGIN TIM2_Init 2 */ |
573 | /* USER CODE BEGIN TIM2_Init 2 */ |
| 569 | 574 | ||
| 570 | /* USER CODE END TIM2_Init 2 */ |
575 | /* USER CODE END TIM2_Init 2 */ |
| 571 | - | ||
| 572 | } |
576 | } |
| 573 | 577 | ||
| 574 | /** |
578 | /** |
| 575 | * @brief TIM3 Initialization Function |
579 | * @brief TIM3 Initialization Function |
| 576 | * @param None |
580 | * @param None |
| 577 | * @retval None |
581 | * @retval None |
| 578 | */ |
582 | */ |
| 579 | static void MX_TIM3_Init(void) |
583 | static void MX_TIM3_Init(void) |
| 580 | { |
584 | { |
| 581 | 585 | ||
| 582 | /* USER CODE BEGIN TIM3_Init 0 */ |
586 | /* USER CODE BEGIN TIM3_Init 0 */ |
| 583 | 587 | ||
| Line 615... | Line 619... | ||
| 615 | Error_Handler(); |
619 | Error_Handler(); |
| 616 | } |
620 | } |
| 617 | /* USER CODE BEGIN TIM3_Init 2 */ |
621 | /* USER CODE BEGIN TIM3_Init 2 */ |
| 618 | 622 | ||
| 619 | /* USER CODE END TIM3_Init 2 */ |
623 | /* USER CODE END TIM3_Init 2 */ |
| 620 | - | ||
| 621 | } |
624 | } |
| 622 | 625 | ||
| 623 | /** |
626 | /** |
| 624 | * @brief TIM9 Initialization Function |
627 | * @brief TIM9 Initialization Function |
| 625 | * @param None |
628 | * @param None |
| 626 | * @retval None |
629 | * @retval None |
| 627 | */ |
630 | */ |
| 628 | static void MX_TIM9_Init(void) |
631 | static void MX_TIM9_Init(void) |
| 629 | { |
632 | { |
| 630 | 633 | ||
| 631 | /* USER CODE BEGIN TIM9_Init 0 */ |
634 | /* USER CODE BEGIN TIM9_Init 0 */ |
| 632 | 635 | ||
| Line 664... | Line 667... | ||
| 664 | Error_Handler(); |
667 | Error_Handler(); |
| 665 | } |
668 | } |
| 666 | /* USER CODE BEGIN TIM9_Init 2 */ |
669 | /* USER CODE BEGIN TIM9_Init 2 */ |
| 667 | 670 | ||
| 668 | /* USER CODE END TIM9_Init 2 */ |
671 | /* USER CODE END TIM9_Init 2 */ |
| 669 | - | ||
| 670 | } |
672 | } |
| 671 | 673 | ||
| 672 | /** |
674 | /** |
| 673 | * @brief UART4 Initialization Function |
675 | * @brief UART4 Initialization Function |
| 674 | * @param None |
676 | * @param None |
| 675 | * @retval None |
677 | * @retval None |
| 676 | */ |
678 | */ |
| 677 | static void MX_UART4_Init(void) |
679 | static void MX_UART4_Init(void) |
| 678 | { |
680 | { |
| 679 | 681 | ||
| 680 | /* USER CODE BEGIN UART4_Init 0 */ |
682 | /* USER CODE BEGIN UART4_Init 0 */ |
| 681 | 683 | ||
| Line 697... | Line 699... | ||
| 697 | Error_Handler(); |
699 | Error_Handler(); |
| 698 | } |
700 | } |
| 699 | /* USER CODE BEGIN UART4_Init 2 */ |
701 | /* USER CODE BEGIN UART4_Init 2 */ |
| 700 | 702 | ||
| 701 | /* USER CODE END UART4_Init 2 */ |
703 | /* USER CODE END UART4_Init 2 */ |
| 702 | - | ||
| 703 | } |
704 | } |
| 704 | 705 | ||
| 705 | /** |
706 | /** |
| 706 | * @brief USART1 Initialization Function |
707 | * @brief USART1 Initialization Function |
| 707 | * @param None |
708 | * @param None |
| 708 | * @retval None |
709 | * @retval None |
| 709 | */ |
710 | */ |
| 710 | static void MX_USART1_UART_Init(void) |
711 | static void MX_USART1_UART_Init(void) |
| 711 | { |
712 | { |
| 712 | 713 | ||
| 713 | /* USER CODE BEGIN USART1_Init 0 */ |
714 | /* USER CODE BEGIN USART1_Init 0 */ |
| 714 | 715 | ||
| Line 730... | Line 731... | ||
| 730 | Error_Handler(); |
731 | Error_Handler(); |
| 731 | } |
732 | } |
| 732 | /* USER CODE BEGIN USART1_Init 2 */ |
733 | /* USER CODE BEGIN USART1_Init 2 */ |
| 733 | 734 | ||
| 734 | /* USER CODE END USART1_Init 2 */ |
735 | /* USER CODE END USART1_Init 2 */ |
| 735 | - | ||
| 736 | } |
736 | } |
| 737 | 737 | ||
| 738 | /** |
738 | /** |
| 739 | * @brief USART2 Initialization Function |
739 | * @brief USART2 Initialization Function |
| 740 | * @param None |
740 | * @param None |
| 741 | * @retval None |
741 | * @retval None |
| 742 | */ |
742 | */ |
| 743 | static void MX_USART2_UART_Init(void) |
743 | static void MX_USART2_UART_Init(void) |
| 744 | { |
744 | { |
| 745 | 745 | ||
| 746 | /* USER CODE BEGIN USART2_Init 0 */ |
746 | /* USER CODE BEGIN USART2_Init 0 */ |
| 747 | 747 | ||
| Line 763... | Line 763... | ||
| 763 | Error_Handler(); |
763 | Error_Handler(); |
| 764 | } |
764 | } |
| 765 | /* USER CODE BEGIN USART2_Init 2 */ |
765 | /* USER CODE BEGIN USART2_Init 2 */ |
| 766 | 766 | ||
| 767 | /* USER CODE END USART2_Init 2 */ |
767 | /* USER CODE END USART2_Init 2 */ |
| 768 | - | ||
| 769 | } |
768 | } |
| 770 | 769 | ||
| 771 | /** |
770 | /** |
| 772 | * @brief USART3 Initialization Function |
771 | * @brief USART3 Initialization Function |
| 773 | * @param None |
772 | * @param None |
| 774 | * @retval None |
773 | * @retval None |
| 775 | */ |
774 | */ |
| 776 | static void MX_USART3_UART_Init(void) |
775 | static void MX_USART3_UART_Init(void) |
| 777 | { |
776 | { |
| 778 | 777 | ||
| 779 | /* USER CODE BEGIN USART3_Init 0 */ |
778 | /* USER CODE BEGIN USART3_Init 0 */ |
| 780 | 779 | ||
| Line 796... | Line 795... | ||
| 796 | Error_Handler(); |
795 | Error_Handler(); |
| 797 | } |
796 | } |
| 798 | /* USER CODE BEGIN USART3_Init 2 */ |
797 | /* USER CODE BEGIN USART3_Init 2 */ |
| 799 | 798 | ||
| 800 | /* USER CODE END USART3_Init 2 */ |
799 | /* USER CODE END USART3_Init 2 */ |
| 801 | - | ||
| 802 | } |
800 | } |
| 803 | 801 | ||
| 804 | /** |
802 | /** |
| 805 | * @brief GPIO Initialization Function |
803 | * @brief GPIO Initialization Function |
| 806 | * @param None |
804 | * @param None |
| 807 | * @retval None |
805 | * @retval None |
| 808 | */ |
806 | */ |
| 809 | static void MX_GPIO_Init(void) |
807 | static void MX_GPIO_Init(void) |
| 810 | { |
808 | { |
| 811 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
809 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
| 812 | 810 | ||
| 813 | /* GPIO Ports Clock Enable */ |
811 | /* GPIO Ports Clock Enable */ |
| Line 818... | Line 816... | ||
| 818 | 816 | ||
| 819 | /*Configure GPIO pin Output Level */ |
817 | /*Configure GPIO pin Output Level */ |
| 820 | HAL_GPIO_WritePin(SPI_NSS1_GPIO_Port, SPI_NSS1_Pin, GPIO_PIN_SET); |
818 | HAL_GPIO_WritePin(SPI_NSS1_GPIO_Port, SPI_NSS1_Pin, GPIO_PIN_SET); |
| 821 | 819 | ||
| 822 | /*Configure GPIO pin Output Level */ |
820 | /*Configure GPIO pin Output Level */ |
| 823 | HAL_GPIO_WritePin(GPIOA, SPI_CD_Pin|BT_BUTTON_Pin, GPIO_PIN_RESET); |
821 | HAL_GPIO_WritePin(GPIOA, SPI_CD_Pin | BT_BUTTON_Pin, GPIO_PIN_RESET); |
| 824 | 822 | ||
| 825 | /*Configure GPIO pin Output Level */ |
823 | /*Configure GPIO pin Output Level */ |
| 826 | HAL_GPIO_WritePin(GPIOC, SPI_RESET_Pin|POWER_LATCH_Pin|USB_PWR_Pin, GPIO_PIN_RESET); |
824 | HAL_GPIO_WritePin(GPIOC, SPI_RESET_Pin | POWER_LATCH_Pin | USB_PWR_Pin, GPIO_PIN_RESET); |
| 827 | 825 | ||
| 828 | /*Configure GPIO pin Output Level */ |
826 | /*Configure GPIO pin Output Level */ |
| 829 | HAL_GPIO_WritePin(SPI_NSS2_GPIO_Port, SPI_NSS2_Pin, GPIO_PIN_SET); |
827 | HAL_GPIO_WritePin(SPI_NSS2_GPIO_Port, SPI_NSS2_Pin, GPIO_PIN_SET); |
| 830 | 828 | ||
| 831 | /*Configure GPIO pins : SPI_NSS1_Pin SPI_CD_Pin */ |
829 | /*Configure GPIO pins : SPI_NSS1_Pin SPI_CD_Pin */ |
| 832 | GPIO_InitStruct.Pin = SPI_NSS1_Pin|SPI_CD_Pin; |
830 | GPIO_InitStruct.Pin = SPI_NSS1_Pin | SPI_CD_Pin; |
| 833 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
831 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
| 834 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
832 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| 835 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
833 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
| 836 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
834 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
| 837 | 835 | ||
| 838 | /*Configure GPIO pins : SPI_RESET_Pin SPI_NSS2_Pin POWER_LATCH_Pin USB_PWR_Pin */ |
836 | /*Configure GPIO pins : SPI_RESET_Pin SPI_NSS2_Pin POWER_LATCH_Pin USB_PWR_Pin */ |
| 839 | GPIO_InitStruct.Pin = SPI_RESET_Pin|SPI_NSS2_Pin|POWER_LATCH_Pin|USB_PWR_Pin; |
837 | GPIO_InitStruct.Pin = SPI_RESET_Pin | SPI_NSS2_Pin | POWER_LATCH_Pin | USB_PWR_Pin; |
| 840 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
838 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
| 841 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
839 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| 842 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
840 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
| 843 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
841 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
| 844 | 842 | ||
| 845 | /*Configure GPIO pins : BT_STATE_Pin SW1_PUSH_Pin SW2_PUSH_Pin */ |
843 | /*Configure GPIO pins : BT_STATE_Pin SW1_PUSH_Pin SW2_PUSH_Pin */ |
| 846 | GPIO_InitStruct.Pin = BT_STATE_Pin|SW1_PUSH_Pin|SW2_PUSH_Pin; |
844 | GPIO_InitStruct.Pin = BT_STATE_Pin | SW1_PUSH_Pin | SW2_PUSH_Pin; |
| 847 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
845 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
| 848 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
846 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
| 849 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
847 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| 850 | 848 | ||
| 851 | /*Configure GPIO pin : IGNITION_Pin */ |
849 | /*Configure GPIO pin : IGNITION_Pin */ |
| Line 858... | Line 856... | ||
| 858 | GPIO_InitStruct.Pin = BT_BUTTON_Pin; |
856 | GPIO_InitStruct.Pin = BT_BUTTON_Pin; |
| 859 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; |
857 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; |
| 860 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
858 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| 861 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
859 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
| 862 | HAL_GPIO_Init(BT_BUTTON_GPIO_Port, &GPIO_InitStruct); |
860 | HAL_GPIO_Init(BT_BUTTON_GPIO_Port, &GPIO_InitStruct); |
| 863 | - | ||
| 864 | } |
861 | } |
| 865 | 862 | ||
| 866 | /* USER CODE BEGIN 4 */ |
863 | /* USER CODE BEGIN 4 */ |
| 867 | 864 | ||
| 868 | /* USER CODE END 4 */ |
865 | /* USER CODE END 4 */ |
| 869 | 866 | ||
| 870 | /** |
867 | /** |
| 871 | * @brief This function is executed in case of error occurrence. |
868 | * @brief This function is executed in case of error occurrence. |
| 872 | * @retval None |
869 | * @retval None |
| 873 | */ |
870 | */ |
| 874 | void Error_Handler(void) |
871 | void Error_Handler(void) |
| 875 | { |
872 | { |
| 876 | /* USER CODE BEGIN Error_Handler_Debug */ |
873 | /* USER CODE BEGIN Error_Handler_Debug */ |
| 877 | /* User can add his own implementation to report the HAL error return state */ |
874 | /* User can add his own implementation to report the HAL error return state */ |
| 878 | 875 | ||
| 879 | /* USER CODE END Error_Handler_Debug */ |
876 | /* USER CODE END Error_Handler_Debug */ |
| 880 | } |
877 | } |
| 881 | 878 | ||
| 882 | #ifdef USE_FULL_ASSERT |
879 | #ifdef USE_FULL_ASSERT |
| 883 | /** |
880 | /** |
| 884 | * @brief Reports the name of the source file and the source line number |
881 | * @brief Reports the name of the source file and the source line number |
| 885 | * where the assert_param error has occurred. |
882 | * where the assert_param error has occurred. |
| 886 | * @param file: pointer to the source file name |
883 | * @param file: pointer to the source file name |
| 887 | * @param line: assert_param error line source number |
884 | * @param line: assert_param error line source number |
| 888 | * @retval None |
885 | * @retval None |
| 889 | */ |
886 | */ |
| 890 | void assert_failed(uint8_t *file, uint32_t line) |
887 | void assert_failed(uint8_t *file, uint32_t line) |
| 891 | { |
888 | { |
| 892 | /* USER CODE BEGIN 6 */ |
889 | /* USER CODE BEGIN 6 */ |
| 893 | /* User can add his own implementation to report the file name and line number, |
890 | /* User can add his own implementation to report the file name and line number, |
| 894 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |
891 | tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ |