Super-loop and motivation for a sequencer
Before we get into the design and implementation of a sequencer, we will first analyze the limitations of a super loop. In a usual super-loop scenario, we check flags that are set from an ISR. Below is an example pseudocode of a super loop:
bool data_read_ready = false;
bool data_send_timeout = false;
int main() {
// initialize hardware
while(1) {
if(data_read_ready) {
sensor_data_read_and_buffer();
data_read_ready = false;
}
if(data_send_timeout) {
data_send_from_buffer();
data_send_timeout = false;
}
if(!data_read_ready && !data_send_timeout) {
enter_sleep();
}
}
}
In the preceding pseudocode, we perform the following steps:
- Check the Boolean flag
data_read_readyand, if it is set, we execute the functionsensor_data_read_and_buffer. We then reset thedata_read_readyflag. - Check the...