 **    Perform basic board/device level initialization.
 */
 
-void
-DeviceInit()
-{
-
-  /* Set the LED pins to be outputs. Some boards support more
-  ** than two LEDs. On those boards, also blink the additional
-  ** LEDs.
-  */
-  pinMode(PIN_LED1, OUTPUT);
-  pinMode(PIN_LED2, OUTPUT);
-  
-  #if defined(PIN_LED3)
-  pinMode(PIN_LED3, OUTPUT);
-  #endif
-  
-  #if defined(PIN_LED4)
-  pinMode(PIN_LED4, OUTPUT);
-  #endif
-
-  /* Initialize the SPI port.
-  ** Note: The pmodJSTK requires a delay of at least 6uS between
-  ** bytes, so the delay is set to 6uS below.
-  */
-  spi.begin(pinSS, pinMOSI, pinMISO, pinSCK);
-  spi.setSpeed(250000);
-  spi.setMode(SSPI_MODE0);
-  spi.setDirection(SSPI_SHIFT_LEFT);
-  spi.setDelay(6);
-  
+void DeviceInit() {
+    /* Set the LED pins to be outputs. Some boards support more
+    ** than two LEDs. On those boards, also blink the additional
+    ** LEDs.
+    */
+    pinMode(PIN_LED1, OUTPUT);
+    pinMode(PIN_LED2, OUTPUT);
+#if defined(PIN_LED3)
+    pinMode(PIN_LED3, OUTPUT);
+#endif
+#if defined(PIN_LED4)
+    pinMode(PIN_LED4, OUTPUT);
+#endif
+    /* Initialize the SPI port.
+    ** Note: The pmodJSTK requires a delay of at least 6uS between
+    ** bytes, so the delay is set to 6uS below.
+    */
+    spi.begin(pinSS, pinMOSI, pinMISO, pinSCK);
+    spi.setSpeed(250000);
+    spi.setMode(SSPI_MODE0);
+    spi.setDirection(SSPI_SHIFT_LEFT);
+    spi.setDelay(6);
 }
 
 /* ------------------------------------------------------------ */

**    init functions to initalize the application subsystems.
*/

void
AppInit()
  {

  /* Init program state variables.
  */
  cntBtnBlink = cntBlinkInit;
  fbLedPmod = 0x01;
  fbBtnPmod = 0;
  xcoPmod = 0;
  ycoPmod = 0;

  /* Start with LED3 on and LED4 off
  */
  fLed3 = HIGH;
  fLed4 = LOW;

}

/* ------------------------------------------------------------ */

**    each time through the main program loop.
*/

void AppTask() {
    unsigned int	dwBtn;
    /* Check the state of button 1 on the PmodJSTK and set LED 1
    ** accordingly
    */
    dwBtn = fbBtnPmod & 0x01;

    if (dwBtn == 0) {
        digitalWrite(PIN_LED1, LOW);
    } else {
        digitalWrite(PIN_LED1, HIGH);
    }

    /* Check the state of button 2 and set LED 2 accordingly
    */
    dwBtn = fbBtnPmod & 0x02;

    if (dwBtn == 0) {
        digitalWrite(PIN_LED2, LOW);
    } else {
        digitalWrite(PIN_LED2, HIGH);
    }

    /* Check if it is time to blink LED3 & LED4 and update
    ** the joystick.
    */
    cntBtnBlink -= 1;

    if (cntBtnBlink == 0) {
#if defined(PIN_LED3)
        digitalWrite(PIN_LED3, fLed3);
        fLed3 = (fLed3 == HIGH) ? LOW : HIGH;
#endif
#if defined(PIN_LED4)
        digitalWrite(PIN_LED4, fLed4);
        fLed4 = (fLed4 == HIGH) ? LOW : HIGH;
#endif
        /* Toggle the setting for the LEDs on the joystick.
        */
        fbLedPmod ^= 0x03;
        /* Update the joystick.
        */
        ReadJoystick(fbLedPmod, &fbBtnPmod, &xcoPmod, &ycoPmod);
        cntBtnBlink = cntBlinkInit;
    }
}

/* ------------------------------------------------------------ */
