 **    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;
-
+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;
 }
 
 /* ------------------------------------------------------------ */

**    Initialize the system.
*/

void
setup() {

    DeviceInit();
    AppInit();
    
}

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

**  Description:
**    Read the current position of the joystick and buttons.
*/
void ReadJoystick(uint8_t fbLed, uint8_t * pfbBtn, int * pxco, int * pyco) {
    uint8_t    rgbSnd[5];
    uint8_t    rgbRcv[5];
    int	     ib;

    /* Initialize the transmit buffer.
    */
    for (ib = 0; ib < 5; ib++) {
        rgbSnd[ib] = 0x50 + ib;
    }

    rgbSnd[0] = fbLedPmod + 0x80;  //first byte sent sets the LEDs
    /* Bring SS low to begin the transaction.
    */
    spi.setSelect(LOW);
    /* Wait 10us for Pmod to become ready
    */
    Delay10us();
    /* Send the data to the Pmod and get the response.
    */
    spi.transfer(5, rgbSnd, rgbRcv);
    /* Bring SS high to end the transaction.
    */
    spi.setSelect(HIGH);
    /* Set up the return values.
    */
    *pfbBtn = rgbRcv[4] >> 1;
    *pxco = (uint16_t)((rgbRcv[1] << 8) + rgbRcv[0]);
    *pyco = (uint16_t)((rgbRcv[3] << 8) + rgbRcv[2]);
}

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