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

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
Note that as we iterate through the loop, we keep track of the switch, LED, and switch number that we are
on. Incrementing the switch_pressed and led pointers will make them point to the next member in
the respective group.
Now we begin switch debouncing. We wait 50 ms, and then check if the switch has been pressed again.
Note that switch_pressed indicates which pin has been pressed—this is one of the results from the
loop above. However, switch_pressed is a double pointer (Flex_IOPin **), whereas
flexDigIn() expects a single pointer (Flex_IOPin *). Therefore, we need to dereference
switch_pressed in the call to flexDigIn().
At this point, the code here is very similar to the debouncing code in the previous section. The only differ-
ences are the references to switch_pressed and led. Because those variables are now both double
pointers, we must dereference them when making calls to flexDigIn() and flexDigOut().
This section demonstrated how to use the grouping functionality in the RabbitFLEX API. The techniques
described in this chapter should now have given you a running start to implementing your own Rabbit-
FLEX applications.
RabbitFLEX User’s Manual
}
}
// Wait 50 ms to make sure the switch stays pressed (debouncing)
waitfor(DelayMs(50));
// Check if the switch is still pressed
if (flexDigIn(*switch_pressed) == 1) {
}
//
flexDigOut(*led, 0);
//
flexToneLoad(tones[switchnum], tone_len[switchnum], REPEAT_TONE);
while (1) {
} // end of while loop
Light the corresponding output LED
Play the tone
// 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) {
}
// Turn the LED back off
flexDigOut(*led, 1);
break;
www.rabbit.com
83

Related parts for 20-151-0178