void loop(void) { blink(3); /* Share current CPU load measurement with task code, which owns Serial and which can thus display it. */ _cpuLoad = gsl_getSystemLoad(); } /* End of loop */
void loop() { /* Give an alive sign. */ blink(3); #ifdef DEBUG printf("\nRTuinOS is idle\n"); #endif /* Share result of CPU load computation with the displaying idle follower task. No acces synchronization is needed here for two reasons: Writing a uint8 is atomic and we have a strict coupling in time between the idle task and the data reading task: They become active one after another. */ _cpuLoad = gsl_getSystemLoad(); #ifdef DEBUG cli(); uint16_t adcResult = adc_inputVoltage; uint16_t adcResultButton = adc_buttonVoltage; uint32_t noAdcResults = adc_noAdcResults; uint8_t hour = clk_noHour , min = clk_noMin , sec = clk_noSec; sei(); printf("At %02u:%02u:%02u:\n", hour, min, sec); printf( "ADC result %7lu at %7.2f s: %.4f V (input), %.4f V (buttons)\n" , noAdcResults , 1e-3*millis() , ADC_SCALING_BIN_TO_V(adcResult) , ADC_SCALING_BIN_TO_V(adcResultButton) ); printf("CPU load: %.1f %%\n", (double)_cpuLoad/2.0); ASSERT(rtos_getTaskOverrunCounter(/* idxTask */ idxTaskRTC, /* doReset */ false) == 0); uint8_t u; for(u=0; u<RTOS_NO_TASKS; ++u) printf("Unused stack area of task %u: %u Byte\n", u, rtos_getStackReserve(u)); #endif /* Trigger the follower task, which is capable to safely display the results. */ rtos_sendEvent(EVT_TRIGGER_IDLE_FOLLOWER_TASK); } /* End of loop */