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

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
Since we have accepted the switch press and turned on the corresponding LED, then we might as well play
the tone. We use the switchnum variable that we saved earlier to choose the tone to play.
This last section implements debouncing on switch release. We wait until the switch is released, and then
check the switch again 200 ms later. If the switch is still released, then we turn off the corresponding LED
and we break out of the while loop. The costatement starts over again, which means that we again monitor
all of the switches.
This concludes the main while() loop. With these changes, we can now use the switches on the demo
board to play a tone and light a corresponding LED.
6.4.3 Extending speaker_tone.c with I/O Grouping
In this section, we will make further changes to speaker_tone.c to use RabbitFLEX I/O grouping.
This will make the resulting code somewhat more flexible, and will demonstrate how to use I/O groups.
First, we need to declare some variables.
Note that switch_pressed and led are now double pointers (Flex_IOPin **). This is because
we will be using these variables to iterate through a group (or array) of Flex_IOPin* pointers. This will
become more apparent as we walk through this sample.
We have also created switch_values and value variables, which we will explain later.
RabbitFLEX User’s Manual
}
Flex_IOPin **switch_pressed;
Flex_IOPin **led;
int switchnum;
unsigned int switch_values;
unsigned int value;
static const Flex_IOPin *switches[] = {
};
}
&flex_digin31,
&flex_digin33,
&flex_digin35,
&flex_digin37,
FLEX_GROUP_END
}
while (1) {
}
// 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
79

Related parts for 20-151-0178