Beispiel #1
0
/**************************************************************************************************
 * @fn      Hal_DriverInit
 *
 * @brief   Initialize HW - These need to be initialized before anyone.
 *
 * @param   task_id - Hal TaskId
 *
 * @return  None
 **************************************************************************************************/
void HalDriverInit (void)
{
  /* TIMER */
#if (defined HAL_TIMER) && (HAL_TIMER == TRUE)
  #error "The hal timer driver module is removed."
#endif

  /* ADC */
#if (defined HAL_ADC) && (HAL_ADC == TRUE)
  HalAdcInit();
#endif

  /* DMA */
#if (defined HAL_DMA) && (HAL_DMA == TRUE)
  // Must be called before the init call to any module that uses DMA.
  HalDmaInit();
#endif

  /* AES */
#if (defined HAL_AES) && (HAL_AES == TRUE)
  HalAesInit();
#endif

  /* LCD */
#if (defined HAL_LCD) && (HAL_LCD == TRUE)
  HalLcdInit();
#endif

  /* LED */
#if (defined HAL_LED) && (HAL_LED == TRUE)
  HalLedInit();
#endif

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

  /* KEY */
#if (defined HAL_KEY) && (HAL_KEY == TRUE)
  HalKeyInit();
#endif

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

  /* HID */
#if (defined HAL_HID) && (HAL_HID == TRUE)
  usbHidInit();
#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);
                }

            }

        }

    }

}
Beispiel #3
0
int main(void)
{
  /* Initialize hardware */
  HAL_BOARD_INIT();

  // Initialize board I/O
  InitBoard( OB_COLD );

  /* Initialze the HAL driver */
  HalDriverInit();

  /* Initialize NV system */
  osal_snv_init();

  /* Initialize LL */

  /* Initialize the operating system */
  osal_init_system();

  /* Enable interrupts */
  HAL_ENABLE_INTERRUPTS();

  // Final board initialization
  InitBoard( OB_READY );

  #if defined ( POWER_SAVING )
    osal_pwrmgr_device( /*PWRMGR_ALWAYS_ON*/ PWRMGR_BATTERY );
  #endif

  usbHidInit();

  /* Start OSAL */
  osal_start_system(); // No Return from here

  return 0;
}
Beispiel #4
0
/**************************************************************************************************
 * @fn      Hal_DriverInit (ªì©l¤ÆµwÅ骺ÅX°Êµ{§Ç, ¨Ï¥ÎªÌ¥i¦b¦¹¨ç¼Æ²K¥[¬ÛÃöµwÅé)
 *
 * @brief   Initialize HW - These need to be initialized before anyone.
 *
 * @param   task_id - Hal TaskId
 *
 * @return  None
 **************************************************************************************************/
void HalDriverInit (void)
{
  /* TIMER */
#if (defined HAL_TIMER) && (HAL_TIMER == TRUE)
  HalTimerInit();
#endif

  /* ADC */
#if (defined HAL_ADC) && (HAL_ADC == TRUE)
  HalAdcInit();
  #if defined(M170)
    M170_Init();
  #endif
#endif

  /* DMA */
#if (defined HAL_DMA) && (HAL_DMA == TRUE)
  // Must be called before the init call to any module that uses DMA.
  HalDmaInit();
#endif

  /* Flash */
#if (defined HAL_FLASH) && (HAL_FLASH == TRUE)
  // Must be called before the init call to any module that uses Flash access or NV.
  HalFlashInit();
#endif

  /* AES */
#if (defined HAL_AES) && (HAL_AES == TRUE)
  HalAesInit();
#endif

  /* LCD */
#if (defined HAL_LCD) && (HAL_LCD == TRUE)
  HalLcdInit();
#endif

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

  /* KEY */
#if (defined HAL_KEY) && (HAL_KEY == TRUE)
  HalKeyInit();
#endif
  
  /* SPI */
#if (defined HAL_SPI) && (HAL_SPI == TRUE)
  HalSpiInit();
#endif

  /* HID */
#if (defined HAL_HID) && (HAL_HID == TRUE)
  usbHidInit();
#endif
    
  /* KEYPAD */
#if (defined HAL_KEYPAD) && (HAL_KEYPAD == TRUE)
  halKeypadInit();
#endif
  
  /* BUZZER */
#if (defined HAL_BUZZER) && (HAL_BUZZER == TRUE)
  halBuzzerInit();
#endif
  
  /* I2C (M200 module) */
#if (defined HAL_I2C) && (HAL_I2C == TRUE)
  #if defined(M200)
    M200_Init();
  #endif
#endif
    
  /* LED */
#if (defined HAL_LED) && (HAL_LED == TRUE)
  HalLedInit();
#endif
  
}
Beispiel #5
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;
            }
        }
    }

}