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

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
Each of the changes that are shown below are made to the main() function of speaker_tone.c.
First of all, at the top of main(), we need to add a few variables. The variable *switch_pressed
will point to the switch that has been pressed. The variable *led will point to the LED that we should
light up. And the variable switchnum indicates the number of the switch (1-4) that was pressed. We will
see how these will be used later in this walk-through.
We will now skip farther down over some code that does not need to change.
The above code should simply replace the menu of options that are presented to the user. Instead of using
the Stdio window to select the tone to play, we will be using switches on the demo board.
Again, we will skip down further, to just before the main while() loop.
The lines of code above will turn off the attached LEDs. Note that to turn off the LEDs on the demo board,
we must actually turn on the connected digital output. This is because the Flex library takes into account
drivers that invert the signal. All flexDigOut() calls always keep the logic uninverted. In the case of a
sinking driver, when flexDigOut() is called with a logic 1, the library turns the sinking transistor off
so that the output can go high and the logical 1 is available at the pin. So when using sinking drivers, the
transistor is turned on by calling flexDigOut() with a logic 0.
flexDigOut() is the function that manipulates a single digital output. Note that, like
flexSpeakerPWM(), this function takes a pointer to a Flex_IOPin structure. This first call to
flexDigOut() manipulates the flex_digout32 digital output. Note that “flex_digout32” should
correspond to how you have named your digital output. When you design your RabbitFLEX board, you
have the option of setting your own software name for each pin. If you designed your RabbitFLEX board
to have a digital output attach to an LED, then you might want to call that output “flex_led”. It the case
above, we used a different naming scheme. “digout” indicates that this is a digital output. “32” indicates
that this digital output is located on connector J3, pin 2. Again, when you design your board, you can name
your RabbitFLEX pins in whatever way makes the most sense for your application.
RabbitFLEX User’s Manual
Flex_IOPin *switch_pressed;
Flex_IOPin *led;
int switchnum;
// Display a menu of choices to the user
printf("Press a switch on the demo board to play a sound!\n");
// Initialize the output LEDs to turn off
flexDigOut(&flex_digout32, 1);
flexDigOut(&flex_digout34, 1);
flexDigOut(&flex_digout36, 1);
flexDigOut(&flex_digout38, 1);
www.rabbit.com
75

Related parts for 151-0153