Download An Introduction to Embedded Programming in a Linux Environment
Transcript
Primitives for an I/O Control Language
TABLE 5.
I/O assignments
Port D bit
number
I/O type
I/O name
0
input
auto_mode switch
4
output
manual_mode panel light
5
output
auto_mode panel light
6
output
conveyor_belt motor
Our C language GSM might look like this:
switch(current_state) {
case 0: /* start_state */
wr_bit_on(4);
if (bit_on(0)) current_state = 1;
case 1: /* run_state */
wr_bit_on(5);
wr_bit_on(6);
if (bit_off(0)) current_state = 0;
}
Remember, this is inserted within the control algorithm shown earlier.
5 - 4.2 Broadening the State Engine Scope
Our interest here is in this chapter is in examples using the parallel I/O. Further, in
looking at today’s market for handheld devices that sort of application is what
comes first to mind looking at the uCsimm/uClinux system. Nevertheless, it should
be apparent that our state engine could easily be broadened in scope.
An Introduction to Embedded Programming in a Linux Environment
83