diff 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
line wrap: on
line diff
--- a/Small_CPU/Src/baseCPU2.c	Sun Jan 06 22:33:26 2019 +0100
+++ b/Small_CPU/Src/baseCPU2.c	Tue Jan 08 22:31:17 2019 +0100
@@ -278,8 +278,21 @@
  * @param  None
  * @retval None
  */
+/* #define DEBUG_RUNTIME TRUE */
+#ifdef DEBUG_RUNTIME
+#define MEASURECNT 60	/* number of measuremets to be stored */
+static uint32_t loopcnt[MEASURECNT];
+extern RTC_HandleTypeDef RTCHandle;
+#endif
 
 int main(void) {
+
+#ifdef DEBUG_RUNTIME
+    RTC_TimeTypeDef Stime;
+    uint8_t measurementindex = 0;
+    uint8_t lastsecond = 0xFF;
+#endif
+
 	HAL_Init();
 	SystemClock_Config();
 
@@ -292,7 +305,7 @@
 	GPIO_new_DEBUG_Init(); // added 170322 hw
 	initGlobals();
 
-	printf("CPU2-RTE running...\n");
+/*	printf("CPU2-RTE running...\n"); */
 
 	MX_I2C1_Init();
 	if (global.I2C_SystemStatus != HAL_OK) {
@@ -352,7 +365,7 @@
 	global.mode = MODE_TEST;
 #endif
 	while (1) {
-		printf("Global mode = %d\n", global.mode);
+/*		printf("Global mode = %d\n", global.mode); */
 
 		switch (global.mode) {
 		case MODE_POWERUP:
@@ -475,6 +488,27 @@
 			// EXTILine0_Button_DeInit(); not now, later after testing
 			break;
 		}
+
+#ifdef DEBUG_RUNTIME
+		HAL_RTC_GetTime(&RTCHandle, &Stime, RTC_FORMAT_BCD);
+
+        if(lastsecond == 0xFF)
+        {
+        	measurementindex = 0;
+        	loopcnt[measurementindex] = 0;
+        	lastsecond = Stime.Seconds;
+        }
+        loopcnt[measurementindex]++;
+
+        if(lastsecond != Stime.Seconds)
+        {
+        	measurementindex++;
+        	if (measurementindex == MEASURECNT) measurementindex = 0;
+        	loopcnt[measurementindex] = 0;
+        	lastsecond = Stime.Seconds;
+        	if(measurementindex +1 < MEASURECNT) loopcnt[measurementindex +1] = 0xffff;	/* helps to identify the latest value */
+        }
+#endif
 	}
 }