comparison Small_CPU/Src/baseCPU2.c @ 120:6347a86caa18 FlipDisplay

Cleanup warning and disable printf calls
author Ideenmodellierer
date Tue, 08 Jan 2019 22:31:17 +0100
parents 68181cd61f20
children 0586ae83a243
comparison
equal deleted inserted replaced
119:76fa42fc0b20 120:6347a86caa18
276 /** 276 /**
277 * @brief Main program 277 * @brief Main program
278 * @param None 278 * @param None
279 * @retval None 279 * @retval None
280 */ 280 */
281 /* #define DEBUG_RUNTIME TRUE */
282 #ifdef DEBUG_RUNTIME
283 #define MEASURECNT 60 /* number of measuremets to be stored */
284 static uint32_t loopcnt[MEASURECNT];
285 extern RTC_HandleTypeDef RTCHandle;
286 #endif
281 287
282 int main(void) { 288 int main(void) {
289
290 #ifdef DEBUG_RUNTIME
291 RTC_TimeTypeDef Stime;
292 uint8_t measurementindex = 0;
293 uint8_t lastsecond = 0xFF;
294 #endif
295
283 HAL_Init(); 296 HAL_Init();
284 SystemClock_Config(); 297 SystemClock_Config();
285 298
286 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000); 299 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / 1000);
287 HAL_SYSTICK_CLKSourceConfig( SYSTICK_CLKSOURCE_HCLK); 300 HAL_SYSTICK_CLKSourceConfig( SYSTICK_CLKSOURCE_HCLK);
290 MX_RTC_init(); 303 MX_RTC_init();
291 GPIO_LED_Init(); 304 GPIO_LED_Init();
292 GPIO_new_DEBUG_Init(); // added 170322 hw 305 GPIO_new_DEBUG_Init(); // added 170322 hw
293 initGlobals(); 306 initGlobals();
294 307
295 printf("CPU2-RTE running...\n"); 308 /* printf("CPU2-RTE running...\n"); */
296 309
297 MX_I2C1_Init(); 310 MX_I2C1_Init();
298 if (global.I2C_SystemStatus != HAL_OK) { 311 if (global.I2C_SystemStatus != HAL_OK) {
299 if (MX_I2C1_TestAndClear() == GPIO_PIN_RESET) { 312 if (MX_I2C1_TestAndClear() == GPIO_PIN_RESET) {
300 MX_I2C1_TestAndClear(); // do it a second time 313 MX_I2C1_TestAndClear(); // do it a second time
350 ADCx_Init(); 363 ADCx_Init();
351 GPIO_Power_MainCPU_Init(); 364 GPIO_Power_MainCPU_Init();
352 global.mode = MODE_TEST; 365 global.mode = MODE_TEST;
353 #endif 366 #endif
354 while (1) { 367 while (1) {
355 printf("Global mode = %d\n", global.mode); 368 /* printf("Global mode = %d\n", global.mode); */
356 369
357 switch (global.mode) { 370 switch (global.mode) {
358 case MODE_POWERUP: 371 case MODE_POWERUP:
359 case MODE_BOOT: 372 case MODE_BOOT:
360 // ReInit_battery_charger_status_pins(); 373 // ReInit_battery_charger_status_pins();
473 // SPI_Start_single_TxRx_with_Master(); 486 // SPI_Start_single_TxRx_with_Master();
474 487
475 // EXTILine0_Button_DeInit(); not now, later after testing 488 // EXTILine0_Button_DeInit(); not now, later after testing
476 break; 489 break;
477 } 490 }
491
492 #ifdef DEBUG_RUNTIME
493 HAL_RTC_GetTime(&RTCHandle, &Stime, RTC_FORMAT_BCD);
494
495 if(lastsecond == 0xFF)
496 {
497 measurementindex = 0;
498 loopcnt[measurementindex] = 0;
499 lastsecond = Stime.Seconds;
500 }
501 loopcnt[measurementindex]++;
502
503 if(lastsecond != Stime.Seconds)
504 {
505 measurementindex++;
506 if (measurementindex == MEASURECNT) measurementindex = 0;
507 loopcnt[measurementindex] = 0;
508 lastsecond = Stime.Seconds;
509 if(measurementindex +1 < MEASURECNT) loopcnt[measurementindex +1] = 0xffff; /* helps to identify the latest value */
510 }
511 #endif
478 } 512 }
479 } 513 }
480 514
481 /** @brief Button feedback - EXTI line detection callbacks 515 /** @brief Button feedback - EXTI line detection callbacks
482 * @param GPIO_Pin: Specifies the pins connected EXTI line 516 * @param GPIO_Pin: Specifies the pins connected EXTI line