Ft 5000 evb, Mini gizmo i/o board, Conditional compilation example – Echelon Mini FX User Manual

Page 89

Advertising
background image

76 Developing

Device

Applications

FT 5000 EVB

The FT 5000 EVB includes two LEDs: LED1 and LED2. LED1 and LED2 are
connected to pins I/O 2 and I/O 3, respectively. You can drive the state of these LEDs by

simply declaring a one bit output model for each LED, and assigning the desired output

value with the io_out() Neuron C library function:

IO_2 output bit ioLed1 = 1;
IO_3 output bit ioLed2 = 1;

For use with the examples provided in this chapter, a SetLeds() function takes two

arguments, the logical on/off state for each LED. The function provides hardware
abstraction, translates the logical on/off state into the physical signal, and drives the I/O

lines accordingly:

void SetLeds(boolean led1, boolean led2)
{
io_out(ioLed1, !led1);
io_out(ioLed2, !led2);
}

Mini Gizmo I/O Board

The Mini Gizmo I/O board includes eight LEDs that are connected to the Smart

Transceiver using a serial-in/parallel-out shift register. To control any of these LEDs,
the desired state of all eight LEDs must be shifted into this register. Similar to the

SetLeds() function for the FT 5000 EVB, the SetLeds() function for the Mini Gizmo I/O
board in this example only supports two LEDs, LED1 and LED2. The remaining six

LEDs are always off.
The following is an implementation of the SetLeds() function for use with the Mini
Gizmo I/O board. The function uses a bitshift output model for the serialized data, and a

bit output object to drive the shift register’s low-active Load signal.

IO_2 output bitshift numbits(8) ioLeds;
IO_1 output bit ioLedLoad = 1;

void SetLeds(boolean led1, boolean led2)
{
unsigned data;

// Compute the data byte for the shift register:
data = led1 ? 0x80 : 0x00;
data |= led2 ? 0x40 : 0x00;

// Push inverted data into shift register:
io_out(ioLeds, ~data);

// Strobe:
io_out(ioLedLoad, 0);
io_out(ioLedLoad, 1);
}

Conditional Compilation Example

The following is the combined code for the LED driver, capable of driving two LEDs on

FT 5000 EVB and the Mini Gizmo I/O board:

Advertising