Leds – Echelon Mini FX User Manual

Page 88

Advertising
background image

Mini FX User's Guide

75

#ifdef USE_5000EVB

IO_9 input bit ioSwitch1;

//
// when(io_changes…) executes whenever the button is pressed
//
when(io_changes(ioSwitch1) to 0)
{
OnButtonPressed();
}

#ifdef USE_MINIGIZMO

IO_4 input bitshift numbits(8) clockedge(-) ioButtons;
IO_6 output bit ioButtonLoad = 1;
boolean GetButton(void)
{
unsigned debounce;
unsigned data;
data = 0xFF;
for (debounce = 0; debounce < 3; ++debounce) {
// Strobe:
io_out(ioButtonLoad, 0);
io_out(ioButtonLoad, 1);
// Sample data and debounce:
data &= (unsigned)io_in(ioButtons);
}
return ~data & 0x01;
}

//
// buttonTimer expires every 25ms, and triggers the timer_expires event
// with each expiry
//
mtimer repeating buttonTimer = 25;
//
// The Neuron C scheduler activates the following when-task whenever the
// button timer expires. The task samples the button state, detects a
// newly activated SW1 button, and fires the OnButtonPressed() event when
// necessary.
//
when(timer_expires(buttonTimer)) {
static boolean previousButton = TRUE;
boolean currentButton;

currentButton = GetButton();
if (currentButton && !previousButton) {
OnButtonPressed();
}
previousButton = currentButton;
}

#else

#endif // 5000 evb
#endif // mini gizmo

LEDs

LEDs are normally connected to Vcc through a suitable resistor, and driven active low: a

‘0’ output signal normally switches the LED on, and a ‘1’ switches it off. The following
sections describe how to program the LEDs on the FT 5000 EVB and the Mini Gizmo I/O

Board that you can attach to a PL EVB. The code that drives the LEDs on both EVB
types can be combined using conditional compilation. The complete code for the I/O

drivers is provided in I/O Examples Toolkit at the end of this section

Advertising