Exemple #1
0
/**************************************************************************************************
 * @fn      Hal_ProcessPoll
 *
 * @brief   This routine will be called by OSAL to poll UART, TIMER...
 *
 * @param   task_id - Hal TaskId
 *
 * @return  None
 **************************************************************************************************/
void Hal_ProcessPoll ()
{

  /* Timer Poll */
#if (defined HAL_TIMER) && (HAL_TIMER == TRUE)
  #error "The hal timer driver module is removed."
#endif

  /* UART Poll */
#if (defined HAL_UART) && (HAL_UART == TRUE)
  HalUARTPoll();
#endif  

  /* SPI Poll */
#if (defined HAL_SPI) && (HAL_SPI == TRUE)
  HalSpiPoll();
#endif

  /* HID poll */
#if (defined HAL_HID) && (HAL_HID == TRUE)
  usbHidProcessEvents();
#endif
  
#if defined( POWER_SAVING )
  /* Allow sleep before the next OSAL event loop */
  ALLOW_SLEEP_MODE();
#endif

}
/***********************************************************************************
* @fn          main
*
* @brief       This is the main entry of the RF HID application. It sets
*              distinct short addresses for the nodes, initalises and runs
*              receiver and sender tasks sequentially in an endless loop.
*
* @return      none
*/
void main(void)
{

    // Initialise board peripherals
    halBoardInit();

    // Initialise USB
    usbHidInit();

    // Initialize MRFI
    mrfiLinkInit(DONGLE_ADDRESS,EB_ADDRESS,MRFI_CHANNEL);

    // Indicate that the device is initialised
    halLedSet(1);

    //  Main processing loop
    while (TRUE) {

        // Process USB standard requests
        usbHidProcessEvents();

        // Process incoming radio traffic from HID devices
        if (mrfiLinkDataRdy()) {

            uint8 numBytes;

            // Receive RF packet
            numBytes = mrfiLinkRecv(pRfData);

            // If reception successful, ACK it and send packet to host over USB
            if(numBytes>0) {

                if (pRfData[0]==KEYBOARD_DATA_ID && numBytes==KEYBOARD_DATA_SIZE) {
                    // Process keyboard data
                    usbHidProcessKeyboard(pRfData);
                    halLedToggle(1);
                }

                if (pRfData[0]==MOUSE_DATA_ID && numBytes==MOUSE_DATA_SIZE) {
                    // Process mouse data
                    usbHidProcessMouse(pRfData);
                    halLedToggle(1);
                }

            }

        }

    }

}
Exemple #3
0
/**************************************************************************************************
 * @fn      Hal_ProcessPoll
 *
 * @brief   This routine will be called by OSAL to poll UART, TIMER...
 *
 * @param   task_id - Hal TaskId
 *
 * @return  None
 **************************************************************************************************/
void Hal_ProcessPoll ()
{
    /* UART Poll */
#if (defined HAL_UART) && (HAL_UART == TRUE)
    HalUARTPoll();
#endif

    /* HID poll */
#if (defined HAL_HID) && (HAL_HID == TRUE)
    usbHidProcessEvents();
#endif

#if defined( POWER_SAVING )
    /* Allow sleep before the next OSAL event loop */
    ALLOW_SLEEP_MODE();
#endif
}
Exemple #4
0
/**************************************************************************************************
 * @fn      Hal_ProcessPoll
 *
 * @brief   This routine will be called by OSAL to poll UART, TIMER...
 *
 * @param   task_id - Hal TaskId
 *
 * @return  None
 **************************************************************************************************/
void Hal_ProcessPoll ()
{
#if (defined HAL_VDDMON) && (HAL_VDDMON == TRUE)
    HalVddMonPoll();
#endif
#if ((defined HAL_I2C) && (HAL_I2C == TRUE) && (defined HAL_I2C_POLLED) && (HAL_I2C_POLLED == TRUE))
    HalI2CPoll();
#endif
#if (defined HAL_UART) && (HAL_UART == TRUE)
    HalUARTPoll();
#endif
#if (defined HAL_SPI) && (HAL_SPI == TRUE)
    HalSpiPoll();
#endif
#if (defined HAL_HID) && (HAL_HID == TRUE)
    extern void usbHidProcessEvents(void);
    usbHidProcessEvents();
#endif
}
Exemple #5
0
void Hal_ProcessPoll ()
{
  /* Timer Poll */
#if (defined HAL_TIMER) && (HAL_TIMER == TRUE)
  HalTimerTick();  // Àˬd²×¤îªºcounter
#endif

  /* UART Poll */
#if (defined HAL_UART) && (HAL_UART == TRUE)
  HalUARTPoll();  // Poll the UART
#endif  

  /* SPI Poll */
#if (defined HAL_SPI) && (HAL_SPI == TRUE)
  HalSpiPoll();  
#endif

  /* HID poll */
#if (defined HAL_HID) && (HAL_HID == TRUE)
  usbHidProcessEvents();
#endif
}
Exemple #6
0
//
// Application entry point
//
int main(void)
{
    KEYBOARD_IN_REPORT keybReport;
    uint8_t keybReportSendReq = false;
    uint8_t currKey = 0x00;

    //
    // Initialize board and system clock
    //
    bspInit(SYS_CTRL_32MHZ);

    //
    // Enable the USB interface
    //
    usbHidInit();

    //
    // Initialize GPIO pins for keyboard LEDs (LED 1 on PC0 is used by USB to
    // control D+ pull-up)
    //
    GPIOPinTypeGPIOOutput(BSP_LED_BASE, BSP_LED_2 | BSP_LED_3 | BSP_LED_4);

    //
    // Configure interrupt with wakeup for all buttons
    //
    IntRegister(INT_GPIOA, selKeyRemoteWakeupIsr);
    GPIOPowIntTypeSet(BSP_KEY_SEL_BASE, BSP_KEY_SELECT, GPIO_POW_RISING_EDGE);
    IntRegister(INT_GPIOC, dirKeyRemoteWakeupIsr);
    GPIOPowIntTypeSet(BSP_KEY_DIR_BASE, BSP_KEY_DIR_ALL, GPIO_POW_RISING_EDGE);

    //
    // Initialize button polling for keyboard HID reports
    //
    memset(&keybReport, 0x00, sizeof(KEYBOARD_IN_REPORT));

    //
    // Main loop
    //
    while (1)
    {

        //
        // Process USB events
        //
        usbHidProcessEvents();

        //
        // Generate keyboard input
        //
        if (!keybReportSendReq)
        {
            switch (bspKeyPushed(BSP_KEY_ALL))
            {
            case BSP_KEY_LEFT:
                currKey = 0x50;
                break;
            case BSP_KEY_RIGHT:
                currKey = 0x4F;
                break;
            case BSP_KEY_UP:
                currKey = 0x52;
                break;
            case BSP_KEY_DOWN:
                currKey = 0x51;
                break;
            case BSP_KEY_SELECT:
                currKey = 0x28;
                break;
            default:
                currKey = 0x00;
                break;
            }
            if (currKey != keybReport.pKeyCodes[0])
            {
                keybReport.pKeyCodes[0] = currKey;
                hidUpdateKeyboardInReport(&keybReport);
                keybReportSendReq = true;
            }
        }
        if (keybReportSendReq)
        {
            if (hidSendKeyboardInReport())
            {
                keybReportSendReq = false;
            }
        }
    }

}