comparison Small_CPU/Src/baseCPU2.c @ 922:7c996354b8ac Evo_2_23

Moved UART6 into a separate unit: UART6 connects internal devices. As a first step the existing code sections have been moved into a new unit. As well the code of the external GNSS sensor has been copied into this unit as starting point for the further development. Later the internal part can be integrated into the common uart (code cleanup).
author Ideenmodellierer
date Sun, 03 Nov 2024 20:53:05 +0100
parents 0d6c4b40fae4
children effadaa3a1f7
comparison
equal deleted inserted replaced
921:eb4109d7d1e9 922:7c996354b8ac
141 #include "batteryCharger.h" 141 #include "batteryCharger.h"
142 #include "scheduler.h" 142 #include "scheduler.h"
143 #include "tm_stm32f4_otp.h" 143 #include "tm_stm32f4_otp.h"
144 #include "externalInterface.h" 144 #include "externalInterface.h"
145 #include "uart.h" 145 #include "uart.h"
146 #include "uart_Internal.h"
146 #include "GNSS.h" 147 #include "GNSS.h"
147 148
148 149
149 // From Common/Inc: 150 // From Common/Inc:
150 #include "calc_crush.h" 151 #include "calc_crush.h"
233 234
234 static void GPIO_LEDs_VIBRATION_Init(void); 235 static void GPIO_LEDs_VIBRATION_Init(void);
235 static void GPIO_Power_MainCPU_Init(void); 236 static void GPIO_Power_MainCPU_Init(void);
236 static void GPIO_Power_MainCPU_ON(void); 237 static void GPIO_Power_MainCPU_ON(void);
237 static void GPIO_Power_MainCPU_OFF(void); 238 static void GPIO_Power_MainCPU_OFF(void);
238 #ifdef ENABLE_GNSS 239 #ifdef ENABLE_GPIO_V2
239 static void GPIO_LED_RED_OFF(void); 240 static void GPIO_LED_RED_OFF(void);
240 static void GPIO_LED_RED_ON(void); 241 static void GPIO_LED_RED_ON(void);
241 static void GPIO_LED_GREEN_OFF(void); 242 static void GPIO_LED_GREEN_OFF(void);
242 static void GPIO_LED_GREEN_ON(void); 243 static void GPIO_LED_GREEN_ON(void);
243 static void GPIO_VIBRATION_OFF(void); 244 static void GPIO_VIBRATION_OFF(void);
410 accelerator_init(); 411 accelerator_init();
411 externalInterface_Init(); 412 externalInterface_Init();
412 413
413 if (global.mode == MODE_BOOT) { 414 if (global.mode == MODE_BOOT) {
414 GPIO_Power_MainCPU_OFF(); 415 GPIO_Power_MainCPU_OFF();
415 #ifdef ENABLE_GNSS 416 #ifdef ENABLE_GPIO_V2
416 GPIO_LED_GREEN_ON(); 417 GPIO_LED_GREEN_ON();
417 #endif 418 #endif
418 HAL_Delay(100); // for GPIO_Power_MainCPU_ON(); 419 HAL_Delay(100); // for GPIO_Power_MainCPU_ON();
419 GPIO_Power_MainCPU_ON(); 420 GPIO_Power_MainCPU_ON();
420 #ifdef ENABLE_GNSS 421 #ifdef ENABLE_GPIO_V2
421 GPIO_LED_GREEN_OFF(); 422 GPIO_LED_GREEN_OFF();
422 423
423 GPIO_LED_RED_ON(); 424 GPIO_LED_RED_ON();
424 GPIO_VIBRATION_ON(); 425 GPIO_VIBRATION_ON();
425 #endif 426 #endif
426 HAL_Delay(100); 427 HAL_Delay(100);
427 #ifdef ENABLE_GNSS 428 #ifdef ENABLE_GPIO_V2
428 GPIO_LED_RED_OFF(); 429 GPIO_LED_RED_OFF();
429 GPIO_VIBRATION_OFF(); 430 GPIO_VIBRATION_OFF();
430 #endif 431 #endif
431 } 432 }
432 #ifdef ENABLE_GNSS 433 #ifdef ENABLE_GPIO_V2
433 GPIO_LED_RED_OFF(); 434 GPIO_LED_RED_OFF();
434 GPIO_LED_GREEN_OFF(); 435 GPIO_LED_GREEN_OFF();
435 GPIO_VIBRATION_OFF(); 436 GPIO_VIBRATION_OFF();
436 #endif 437 #endif
437 SPI_synchronize_with_Master(); 438 SPI_synchronize_with_Master();
438 MX_DMA_Init(); 439 MX_DMA_Init();
439 MX_SPI1_Init(); 440 MX_SPI1_Init();
440 SPI_Start_single_TxRx_with_Master(); /* be prepared for the first data exchange */ 441 SPI_Start_single_TxRx_with_Master(); /* be prepared for the first data exchange */
441 Scheduler_Request_sync_with_SPI(SPI_SYNC_METHOD_HARD); 442 Scheduler_Request_sync_with_SPI(SPI_SYNC_METHOD_HARD);
442 443
443 #ifdef ENABLE_GNSS 444 #ifdef ENABLE_GPIO_V2
444 // GNSS tests 445 // GNSS tests
445 GNSS_IO_init(); 446 GNSS_IO_init();
446 GPIO_GPS_ON(); 447 GPIO_GPS_ON();
447 GPIO_GPS_BCKP_ON(); 448 GPIO_GPS_BCKP_ON();
448 MX_USART6_UART_Init(); 449 MX_USART6_UART_Init();
449 GNSS_Init(&GNSS_Handle, &huart6); 450 GNSS_Init(&GNSS_Handle, &huart6);
450 #endif 451 #endif
451 452
452 #if 0
453 HAL_Delay(1000);
454 GNSS_LoadConfig(&GNSS_Handle);
455 HAL_Delay(250);
456 GNSS_GetUniqID(&GNSS_Handle);
457 GNSS_ParseBuffer(&GNSS_Handle);
458 HAL_Delay(250);
459 GNSS_GetPVTData(&GNSS_Handle);
460 GNSS_ParseBuffer(&GNSS_Handle);
461 #endif
462 /* 453 /*
463 * Demo code from SimpleMethod 454 * Demo code from SimpleMethod
464 * called 1/second 455 * called 1/second
465 while (1) { 456 while (1) {
466 457
897 888
898 static void GPIO_Power_MainCPU_OFF(void) { 889 static void GPIO_Power_MainCPU_OFF(void) {
899 HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_SET); 890 HAL_GPIO_WritePin( GPIOC, MAINCPU_CONTROL_PIN, GPIO_PIN_SET);
900 } 891 }
901 892
902 #ifdef ENABLE_GNSS 893 #ifdef ENABLE_GPIO_V2
903 static void GPIO_LED_GREEN_ON(void) { 894 static void GPIO_LED_GREEN_ON(void) {
904 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_RESET); 895 HAL_GPIO_WritePin( GPIOA, LED_CONTROL_PIN_GREEN, GPIO_PIN_RESET);
905 } 896 }
906 897
907 static void GPIO_LED_GREEN_OFF(void) { 898 static void GPIO_LED_GREEN_OFF(void) {
1043 1034
1044 GPIO_InitStruct.Pin = GPIO_PIN_All; 1035 GPIO_InitStruct.Pin = GPIO_PIN_All;
1045 HAL_GPIO_Init( GPIOH, &GPIO_InitStruct); 1036 HAL_GPIO_Init( GPIOH, &GPIO_InitStruct);
1046 1037
1047 GPIO_Power_MainCPU_OFF(); 1038 GPIO_Power_MainCPU_OFF();
1048 #ifdef ENABLE_GNSS 1039 #ifdef ENABLE_GPIO_V2
1049 GPIO_LED_GREEN_OFF(); 1040 GPIO_LED_GREEN_OFF();
1050 GPIO_LED_RED_OFF(); 1041 GPIO_LED_RED_OFF();
1051 GPIO_VIBRATION_OFF(); 1042 GPIO_VIBRATION_OFF();
1052 GPIO_GPS_BCKP_ON(); // mH : costs 100µA in sleep - beware 1043 GPIO_GPS_BCKP_ON(); // mH : costs 100µA in sleep - beware
1053 GPIO_GPS_OFF(); 1044 GPIO_GPS_OFF();