20-151-0178 Rabbit Semiconductor, 20-151-0178 Datasheet - Page 83

CABLE CONVERTER RS-232 TO USB

20-151-0178

Manufacturer Part Number
20-151-0178
Description
CABLE CONVERTER RS-232 TO USB
Manufacturer
Rabbit Semiconductor
Datasheet

Specifications of 20-151-0178

Accessory Type
USB to RS232 Adapter
Product
Microcontroller Accessories
For Use With/related Products
Rabbit-based Boards
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
Other names
20-151-0178
316-1181
Now we will go through each part of the while loop step-by-step.
Note that we are using a costate in this sample. The costate will allow us to more easily delay for imple-
menting switch debouncing. Also note that we set switch_pressed to NULL. Recall that
switch_pressed is of the type Flex_IOPin*. It will be used to point to a switch (or digital input)
that has been engaged. We initialize this to NULL, and will remain in the loop until a switch has been
pressed.
We have already seen that flexDigOut() manipulates digital outputs. Therefore, it is not surprising
that flexDigIn() manipulates digital inputs. In this case, flex_digin31 indicates the digital input
that the program is reading. Always remember that you must pass a pointer to the RabbitFLEX I/O struc-
tures, and not the structure itself.
If flexDigIn() indicates that flex_digin31 has been pressed, then we save off the switch that has
been pressed, the LED that we should turn on, and the number of the switch that has been pressed.
RabbitFLEX User’s Manual
} // end main while loop
while (1) {
} // end costate
costate {
} // end if statement
switch_pressed = NULL;
while (!switch_pressed) {
while (1) {
} // end while loop
if (flexDigIn(&flex_digin31)) {
}
else if (flexDigIn(&flex_digin33)) {
}
// Wait for the switch to be released
waitfor(flexDigIn(switch_pressed) == 0);
// Wait additional 200 ms
waitfor(DelayMs(200));
// If the switch is still released, then break out of the while loop
if (flexDigIn(switch_pressed) == 0) {
} // end if statement
switch_pressed = &flex_digin31;
led = &flex_digout32;
switchnum = 1;
switch_pressed = &flex_digin33;
led = &flex_digout34;
switchnum = 2;
// Turn the LED back off
flexDigOut(led, 1);
break;
www.rabbit.com
77

Related parts for 20-151-0178