/** Configures hardware for the particular hardware platform: - Ports: sets direction, interrupts, pullup/pulldown resistors etc. - Holds radio in reset (active-low) */ void halInit() { // // Enable the floating-point unit. // FPUEnable(); // // Configure the floating-point unit to perform lazy stacking of the // floating-point state. // FPULazyStackingEnable(); oscInit(); portInit(); halUartInit(); //Point the function pointers to doNothing() so that they don't trigger a restart debugConsoleIsr = &doNothing; buttonIsr = &doNothing; clearLeds(); displayVersion(); #ifdef AF_VERBOSE printf("* AF_VERBOSE *\r\n"); #endif }
/*********************************************************************************** * @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(); } } }
/***************************************************************************//** * @brief Initialize MCU and BOARD Peripherals * * @note This function initializes the following * @note \li \b MCU \b Clock * @note \li \b BSP \b keys * @note \li \b BSP \b LEDs * @note \li \b LCD display (only for TRXEB) * @note \li \b RF_SPI Interface * @note \li \b UART interface * @note \li \b PA_LNA controls * @note \li \b TIMER Bit Rate for the symbols * @note \li \b INTERRUPT enable service *******************************************************************************/ static void initMCU(void) { // Initialize clocks and I/O //bspInit(BSP_SYS_CLK_20MHZ); bspInit(BSP_SYS_CLK_24MHZ); // Initialize buttons bspKeyInit(BSP_KEY_MODE_POLL); // Initialize leds bspLedInit(); #ifdef __MSP430F5438A__ // Initialize SPI interface to LCD (shared with SPI flash) bspIoSpiInit(BSP_FLASH_LCD_SPI, BSP_FLASH_LCD_SPI_SPD); // Initialize LCD lcdInit(); #endif // Instantiate transceiver RF SPI interface to SCLK ~ 8 MHz */ /* Input parameter is clockDivider * SCLK frequency = SMCLK/clockDivider */ //trxRfSpiInterfaceInit(2); trxRfSpiInterfaceInit(3); #ifdef AT_CMD // Initialize the UART interface halUartInit(); // Toggle UART Echo. Disabled by default. Might cause unwanted behaviour if enabled. // Note: Try enabling local echo on the host console instead! //uartDrvToggleEcho(); #endif #ifdef __MSP430F5529__ // remove the reset from the rf device RF_RESET_N_PORT_SEL &= ~RF_RESET_N_PIN; RF_RESET_N_PORT_DIR |= RF_RESET_N_PIN; RF_RESET_N_PORT_OUT |= RF_RESET_N_PIN; #endif #ifdef CC1190_PA_LNA // initialize the IO RF_PA_EN_PxDIR |= RF_PA_EN_PIN; RF_LNA_EN_PxDIR |= RF_LNA_EN_PIN; // configure idle RF_PA_EN_PxOUT &= ~RF_PA_EN_PIN; RF_LNA_EN_PxOUT &= ~RF_LNA_EN_PIN; #endif // Init Bitrate Timer /* - FCC bit rate = 1.66ms ( 600bps ) * - ETSI bit rate = 10 ms ( 100bps ) */ TIMER_bitrate_init(); // Enable global interrupt _BIS_SR(GIE); }