Ejemplo n.º 1
0
/**************************************************************************//**
* @brief    Main function of example.
******************************************************************************/
void main(void)
{
    volatile uint32_t ui32Loop;

    //
    // Init LEDs (turned off)
    //
    bspLedInit();

    //
    // Turn on LED1 and LED4
    //
    bspLedSet(BSP_LED_1|BSP_LED_4);

    //
    // Infinite loop
    //
    while(1)
    {
        //
        // Toggle LED2 and LED3
        //
        bspLedToggle(BSP_LED_2|BSP_LED_3);

        //
        // Simple wait
        //
        for(ui32Loop = 0; ui32Loop < 500000; ui32Loop++)
        {
        }
    }
}
Ejemplo n.º 2
0
void leds_error_blink() {
   uint8_t i;
   volatile uint16_t delay;
   // turn all LEDs off
   bspLedClear(BSP_LED_ALL);
     
   // blink error LED for ~10s
   for (i=0;i<80;i++) {
	  bspLedToggle(BSP_LED_1); //10 seconds more or less..
      for (delay=0xffff;delay>0;delay--);
      for (delay=0xffff;delay>0;delay--);
   }
}
Ejemplo n.º 3
0
static void
state_led_timer(void)
{
    switch(app_state)
    {
    case APP_STATE_INIT:
        bspLedSet(BSP_LED_1);
        break;

    case APP_STATE_SCANNING:
        bspLedToggle(BSP_LED_1);
        WS_TIMER_SET(state_led_timer, 200);
        break;

    case APP_STATE_ASSOCIATING:
    case APP_STATE_AUTHENTICATING:
        bspLedClear(BSP_LED_1);
        bspLedToggle(BSP_LED_2);
        WS_TIMER_SET(state_led_timer, 200);
        break;

    case APP_STATE_CONNECTED:
        bspLedClear(BSP_LED_1);
        bspLedClear(BSP_LED_2);
        if (connected_led)
            bspLedSet(BSP_LED_3);
        else
            bspLedClear(BSP_LED_3);
        break;

    default:
        bspLedClear(BSP_LED_1);
        bspLedClear(BSP_LED_2);
        break;
    }
}
Ejemplo n.º 4
0
/**************************************************************************//**
* @brief    Main function of example.
******************************************************************************/
void main(void)
{
    uint8_t ui8KeyBm = 0;
    uint_fast16_t ui16Cnt = 0;
    uint8_t ui8Byte = APP_TX_BYTE;

    //
    // Initialize clocks and board I/O
    //
    bspInit(BSP_SYS_CLK_SPD);

    //
    // Set LED1 to indicate life
    //
    bspLedSet(BSP_LED_1);

    //
    // Initialize key driver
    //
    bspKeyInit(BSP_KEY_MODE_ISR);
    bspKeyIntEnable(BSP_KEY_SELECT|BSP_KEY_UP);

    //
    // Initialize UART to USB MCU
    //
    bspUartBufInit(pui8TxBuf, sizeof(pui8TxBuf), pui8RxBuf, sizeof(pui8RxBuf));

    //
    // Application must register the UART interrupt handler
    //
    UARTIntRegister(BSP_UART_BASE, &appUartIsr);

    //
    // Open UART connection
    //
    if(bspUartOpen(eBaudRate115200) != BSP_UART_SUCCESS)
    {
        //
        // Failed to initialize UART handler
        //
        bspAssert();
    }

    //
    // Initialize SPI interface to LCD, configure LCD, and display information.
    //
    bspSpiInit(BSP_SPI_CLK_SPD);
    lcdInit();
    lcdBufferPrintStringAligned(0, "UART example", eLcdAlignCenter, eLcdPage0);
    lcdBufferInvertPage(0, 0,127, eLcdPage0);
    lcdBufferPrintString(0, "Baud rate   :", 6, eLcdPage2);
    lcdBufferPrintIntAligned(0, bspUartBaudRateGet(), eLcdAlignRight, eLcdPage2);
    lcdBufferPrintString(0, "Format      :", 6, eLcdPage3);
    lcdBufferPrintStringAligned(0, "8-N-1", eLcdAlignRight, eLcdPage3);
    lcdBufferPrintString(0, "Flow control:", 6, eLcdPage4);
    lcdBufferPrintStringAligned(0, "No", eLcdAlignRight, eLcdPage4);
    lcdBufferPrintStringAligned(0, "Transmit: UP key", eLcdAlignRight, eLcdPage6);
    lcdBufferPrintStringAligned(0, "SELECT to toggle mode", eLcdAlignCenter, eLcdPage7);
    lcdBufferInvertPage(0, 0,127, eLcdPage7);
    lcdSendBuffer(0);

    //
    // Enable global interrupts
    //
    IntMasterEnable();

    while(1)
    {
        ui8KeyBm = bspKeyPushed(BSP_KEY_ALL);

        if(BSP_KEY_SELECT & ui8KeyBm)
        {
            //
            // Change mode
            //
            bRepeaterMode ^= 1;
            bspLedToggle(BSP_LED_3);

            //
            // Update LCD for the new mode
            //
            lcdBufferClearPart(0, 0,127, eLcdPage6, eLcdPage6);
            if(bRepeaterMode)
            {
                lcdBufferPrintStringAligned(0, "Repeater mode",
                                            eLcdAlignCenter, eLcdPage6);
            }
            else
            {
                lcdBufferPrintStringAligned(0, "Transmit: UP key",
                                            eLcdAlignCenter, eLcdPage6);
            }
            lcdSendBufferPart(0, 0,127, eLcdPage6, eLcdPage6);
        }

        //
        // Read data from UART RX buffer to application buffer
        //
        ui16Cnt = bspUartDataGet(pui8AppBuf, bspUartRxCharsAvail());

        if(bRepeaterMode)
        {
            //
            // Repeater mode
            //

            if(ui16Cnt)
            {
                //
                // Send data from application buffer to UART TX buffer
                //
                bspUartDataPut(pui8AppBuf, ui16Cnt);
            }
        }
        else
        {
            //
            // Transmit mode
            //

            if(BSP_KEY_UP & ui8KeyBm)
            {
                //
                // Transmit a single character
                //
                bspUartDataPut(&ui8Byte, 1);
            }
        }
    }
}
Ejemplo n.º 5
0
static void
blinky_timer(void)
{
    bspLedToggle(BSP_LED_1);
    WS_TIMER_SET(blinky_timer, 200);
}
Ejemplo n.º 6
0
void    leds_radio_toggle() {
	bspLedToggle(BSP_LED_4);
}
Ejemplo n.º 7
0
void    leds_sync_toggle() {
	bspLedToggle(BSP_LED_2);
}
Ejemplo n.º 8
0
void    leds_error_toggle() {
	bspLedToggle(BSP_LED_1);
}
Ejemplo n.º 9
0
void leds_all_toggle() {
	bspLedToggle(BSP_LED_ALL);
}
Ejemplo n.º 10
0
void    leds_debug_toggle() {
	bspLedToggle(BSP_LED_3);
}