/*********************************************************************************** * @fn main * * @brief This is the main entry of the RF Modem 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) { char *szTitle= "MRFI RF modem"; appUartRxIdle = FALSE; // Initialise board peripherals halBoardInit(); halUartInit(HAL_UART_BAUDRATE_38400, 0); // 100 ms RX idle timeout appConfigTimer(1000/UART_RX_IDLE_TIME); // Indicate that the application has been initialised halLcdClear(); halLcdWriteLine(HAL_LCD_LINE_1, szTitle); halLedSet(1); // Select application role (Device 1, Device 2 or Loopback) appSelectRole(); if (appRole != DEVICE_LOOPBACK) { // Initialize the MRFI RF link layer mrfiLinkInit(appLocalAddr,appRemoteAddr,MRFI_CHANNEL); } // Indicate that the modem is operating halLcdWriteLine(HAL_LCD_LINE_1, szTitle); // Initialise error counters nTxErr= nRxErr= 0; // Enable RX idle timeout interrupt halTimer32kIntEnable(); // Main processing loop while(TRUE) { // On-board device processing (UART etc.) HAL_PROCESS(); if (appRole == DEVICE_LOOPBACK) { // Loopback processing appLoopbackTask(); } else { // RF transmitter processing appRfSenderTask(); // RF receiver processing appRfReceiverTask(); } } }
/*********************************************************************************** * @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); } } } } }