[Optimization] Calling hwConfig.setLedOn() consumes too much resources
In most of our examples, the application task looks like this :
void loop_application_task()
{
while (1)
{
if (mode == IDLEMODE)
{
hwConfig.setLedOff();
//do
}else if(mode==POWERMODE)
{
hwConfig.setLedOn();
//do
}
printk("%.2f:", duty_cycle);
}
scheduling.suspendCurrentTaskMs(serial_refresh_rate_ms);
}
}
In order not to call hwConfig.setLedOn() each time the loop operates, I recommand the code below. It becomes relevant when serial_refresh_rate_ms becomes low (around 5ms).
void loop_application_task()
{
u_int8_t led_status=0;
while (1)
{
if (mode == IDLEMODE)
{
if(led_status == 1)
{
hwConfig.setLedOff();
led_status = 0;
}
}
}else if(mode==POWERMODE) {
if(led_status == 0)
{
hwConfig.setLedOn();
led_status = 1;
}
printk("%.2f:", duty_cycle);
}
scheduling.suspendCurrentTaskMs(serial_refresh_rate_ms);
}
}