151-0153 Rabbit Semiconductor, 151-0153 Datasheet - Page 89

no-image

151-0153

Manufacturer Part Number
151-0153
Description
ASSEMBLY - RABBITFLEX CABLES
Manufacturer
Rabbit Semiconductor
Series
RabbitFLEX™r
Datasheet

Specifications of 151-0153

Accessory Type
Cable Assembly
For Use With/related Products
BL300F
Lead Free Status / RoHS Status
Vendor undefined / Vendor undefined
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 151-0153