//***************************************************************************** // // Main application entry function. // //***************************************************************************** int main(void) { tBoolean bRetcode; // // Set the system clock to run at 50MHz from the PLL // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // NB: We don't call PinoutSet() in this testcase since the EM header // expansion board doesn't currently have an I2C ID EEPROM. If we did // call PinoutSet() this would configure all the EPI pins for SDRAM and // we don't want to do this. // g_eDaughterType = DAUGHTER_NONE; // // Enable peripherals required to drive the LCD. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH); // // Configure SysTick for a 10Hz interrupt. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / TICKS_PER_SECOND); ROM_SysTickEnable(); ROM_SysTickIntEnable(); // // Initialize the display driver. // Kitronix320x240x16_SSD2119Init(); // // Initialize the touch screen driver. // TouchScreenInit(); // // Set the touch screen event handler. // TouchScreenCallbackSet(WidgetPointerMessage); // // Add the compile-time defined widgets to the widget tree. // WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sHeading); // // Initialize the status string. // UpdateStatus(true, "Monitoring..."); // // Paint the widget tree to make sure they all appear on the display. // WidgetPaint(WIDGET_ROOT); // // Initialize the SimpliciTI BSP. // BSP_Init(); // // Set the SimpliciTI device address using the current Ethernet MAC address // to ensure something like uniqueness. // bRetcode = SetSimpliciTIAddress(); // // Did we have a problem with the address? // if(!bRetcode) { // // Yes - make sure the display is updated then hang the app. // WidgetMessageQueueProcess(); while(1) { // // MAC address is not set so hang the app. // } } // // Initialize the SimpliciTI stack but don't set any receive callback. // SMPL_Init(0); // // Start monitoring for alert messages from other devices. This function // doesn't return. // MonitorForBadNews(); }
//***************************************************************************** // // Main application entry function. // //***************************************************************************** int main(void) { tBoolean bSuccess, bRetcode; unsigned char pucMsg[2]; unsigned char ucTid; unsigned char ucDelay; unsigned long ulLastRxCount, ulLastTxCount; smplStatus_t eRetcode; // // Set the system clock to run at 50MHz from the PLL // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // NB: We don't call PinoutSet() in this testcase since the EM header // expansion board doesn't currently have an I2C ID EEPROM. If we did // call PinoutSet() this would configure all the EPI pins for SDRAM and // we don't want to do this. // g_eDaughterType = DAUGHTER_NONE; // // Enable peripherals required to drive the LCD. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH); // // Configure SysTick for a 10Hz interrupt. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / TICKS_PER_SECOND); ROM_SysTickEnable(); ROM_SysTickIntEnable(); // // Initialize the display driver. // Kitronix320x240x16_SSD2119Init(); // // Initialize the touch screen driver. // TouchScreenInit(); // // Set the touch screen event handler. // TouchScreenCallbackSet(WidgetPointerMessage); // // Add the compile-time defined widgets to the widget tree. // WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sHeading); // // Initialize the status string. // UpdateStatus(true, "Please choose the operating mode."); // // Paint the widget tree to make sure they all appear on the display. // WidgetPaint(WIDGET_ROOT); // // Initialize the SimpliciTI BSP. // BSP_Init(); // // Set the SimpliciTI device address using the current Ethernet MAC address // to ensure something like uniqueness. // bRetcode = SetSimpliciTIAddress(); if(!bRetcode) { // // The board does not have a MAC address configured so we can't set // the SimpliciTI device address (which we derive from the MAC address). // while(1); } // // Initialize the SimpliciTI stack and supply our receive callback // function pointer. // SMPL_Init(RxCallback); // // Initialize our message ID, initial inter-message delay and packet // counters. // ucTid = 0; ucDelay = 0; ulLastRxCount = 0; ulLastTxCount = 0; // // Fall into the command line processing loop. // while (1) { // // Process any messages from or for the widgets. // WidgetMessageQueueProcess(); // // Check to see if we've been told to do anything. // if(g_ulCommandFlags) { // // Has the mode been set? If so, set up the display to show the // "LEDs" and then start communication. // if(HWREGBITW(&g_ulCommandFlags, COMMAND_MODE_SET)) { // // Clear the bit now that we have seen it. // HWREGBITW(&g_ulCommandFlags, COMMAND_MODE_SET) = 0; // // Remove the buttons and replace them with the LEDs then // repaint the display. // WidgetRemove((tWidget *)&g_sBtnContainer); WidgetAdd((tWidget *)&g_sBackground, (tWidget *)&g_sLEDContainer); WidgetPaint((tWidget *)&g_sBackground); // // Now call the function that initiates communication in // the desired mode. Note that these functions will not return // until communication is established or an error occurs. // if(g_ulMode == MODE_TALKER) { bSuccess = LinkTo(); } else { bSuccess = LinkFrom(); } // // If we were unsuccessfull, go back to the mode selection // display. // if(!bSuccess) { // // Remove the LEDs and show the buttons again. // WidgetRemove((tWidget *)&g_sLEDContainer); WidgetAdd((tWidget *)&g_sBackground, (tWidget *)&g_sBtnContainer); WidgetPaint((tWidget *)&g_sBackground); // // Tell the user what happened. // UpdateStatus(false, "Error establishing communication!"); UpdateStatus(true, "Please choose the operating mode."); // // Remember that we don't have an operating mode chosen. // g_ulMode = MODE_UNDEFINED; } } // // Have we been asked to toggle the first "LED"? // if(HWREGBITW(&g_ulCommandFlags, COMMAND_LED1_TOGGLE)) { // // Clear the bit now that we have seen it. // HWREGBITW(&g_ulCommandFlags, COMMAND_LED1_TOGGLE) = 0; // // Toggle the LED. // ToggleLED(1); } // // Have we been asked to toggle the second "LED"? // if(HWREGBITW(&g_ulCommandFlags, COMMAND_LED2_TOGGLE)) { // // Clear the bit now that we have seen it. // HWREGBITW(&g_ulCommandFlags, COMMAND_LED2_TOGGLE) = 0; // // Toggle the LED. // ToggleLED(2); } // // Have we been asked to send a packet back to our peer? This // command is only ever sent to the main loop when we are running // in listener mode (LinkListen). // if(HWREGBITW(&g_ulCommandFlags, COMMAND_SEND_REPLY)) { // // Clear the bit now that we have seen it. // HWREGBITW(&g_ulCommandFlags, COMMAND_SEND_REPLY) = 0; // // Create the message. The first byte tells the receiver to // toggle LED1 and the second is a sequence counter. // pucMsg[0] = 1; pucMsg[1] = ++ucTid; eRetcode = SMPL_Send(sLinkID, pucMsg, 2); // // Update our transmit counter if we transmitted the packet // successfully. // if(eRetcode == SMPL_SUCCESS) { g_ulTxCount++; } else { UpdateStatus(false, "TX error %s (%d)", MapSMPLStatus(eRetcode), eRetcode); } } } // // If we are the talker (LinkTo mode), check to see if it's time to // send another packet to our peer. // if((g_ulMode == MODE_TALKER) && (g_ulSysTickCount >= g_ulNextPacketTick)) { // // Create the message. The first byte tells the receiver to // toggle LED1 and the second is a sequence counter. // pucMsg[0] = 1; pucMsg[1] = ++ucTid; eRetcode = SMPL_Send(sLinkID, pucMsg, 2); // // Update our transmit counter if we transmitted the packet // correctly. // if(eRetcode == SMPL_SUCCESS) { g_ulTxCount++; } else { UpdateStatus(false, "TX error %s (%d)", MapSMPLStatus(eRetcode), eRetcode); } // // Set the delay before the next message. // #ifndef USE_2_SECOND_DELAY // // Set the delay before the next message. We increase this from 1 // second to 4 seconds then cycle back to 1. // ucDelay = (ucDelay == 4) ? 1 : (ucDelay + 1); #else // // Wait 2 seconds before sending the next message. // ucDelay = 2; #endif // // Calculate the system tick count when our delay has completed. // This algorithm will generate a spurious packet every 13.7 years // since I don't handle the rollover case in the comparison above // but I'm pretty sure you will forgive me for this oversight. // g_ulNextPacketTick = g_ulSysTickCount + (TICKS_PER_SECOND * ucDelay); } // // If either the transmit or receive packet count changed, update // the status on the display. // if((g_ulRxCount != ulLastRxCount) || (g_ulTxCount != ulLastTxCount)) { ulLastTxCount = g_ulTxCount; ulLastRxCount = g_ulRxCount; UpdateStatus(false, "Received %d pkts, sent %d (%d)", ulLastRxCount, ulLastTxCount); } } }
//***************************************************************************** // // Main application entry function. // //***************************************************************************** int main(void) { tBoolean bRetcode; smplStatus_t eRetcode; ioctlScanChan_t sScan; freqEntry_t pFreq[NWK_FREQ_TBL_SIZE]; tBoolean bFirstTimeThrough; unsigned long ulLoop; uint8_t ucLast; // // Set the system clock to run at 50MHz from the PLL // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // NB: We don't call PinoutSet() in this testcase since the EM header // expansion board doesn't currently have an I2C ID EEPROM. If we did // call PinoutSet() this would configure all the EPI pins for SDRAM and // we don't want to do this. // g_eDaughterType = DAUGHTER_NONE; // // Enable peripherals required to drive the LCD. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH); // // Configure SysTick for a 10Hz interrupt. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / TICKS_PER_SECOND); ROM_SysTickEnable(); ROM_SysTickIntEnable(); // // Initialize the display driver. // Kitronix320x240x16_SSD2119Init(); // // Initialize the touch screen driver. // TouchScreenInit(); // // Set the touch screen event handler. // TouchScreenCallbackSet(WidgetPointerMessage); // // Add the compile-time defined widgets to the widget tree. // WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sHeading); // // Initialize the status string. // UpdateStatus("Initializing..."); // // Paint the widget tree to make sure they all appear on the display. // WidgetPaint(WIDGET_ROOT); // // Initialize the SimpliciTI BSP. // BSP_Init(); // // Set the SimpliciTI device address using the current Ethernet MAC address // to ensure something like uniqueness. // bRetcode = SetSimpliciTIAddress(); // // Did we have a problem with the address? // if(!bRetcode) { // // Yes - make sure the display is updated then hang the app. // WidgetMessageQueueProcess(); while(1) { // // MAC address is not set so hang the app. // } } // // Turn on both our LEDs // SetLED(1, true); SetLED(2, true); UpdateStatus("Joining network..."); // // Initialize the SimpliciTI stack but don't set any receive callback. // while(1) { eRetcode = SMPL_Init((uint8_t (*)(linkID_t))0); if(eRetcode == SMPL_SUCCESS) { break; } ToggleLED(1); ToggleLED(2); SPIN_ABOUT_A_SECOND; } // // Tell the user what's up. // UpdateStatus("Sniffing..."); // // Set up for our first sniff. // sScan.freq = pFreq; bFirstTimeThrough = true; ucLast = 0xFF; // // Keep sniffing forever. // while (1) { // // Wait a while. // SPIN_ABOUT_A_QUARTER_SECOND; // // Scan for the active channel. // SMPL_Ioctl(IOCTL_OBJ_FREQ, IOCTL_ACT_SCAN, &sScan); // // Did we find a signal? // if (1 == sScan.numChan) { if (bFirstTimeThrough) { // // Set the initial LED state. // SetLED(1, false); SetLED(2, true); // // Wait a while. // for(ulLoop = 0; ulLoop < 15; ulLoop--) { // // Toggle both LEDs and wait a bit. // ToggleLED(1); ToggleLED(2); SPIN_ABOUT_A_QUARTER_SECOND; } bFirstTimeThrough = false; } // // Has the channel changed since the last time we updated the // display? // if(pFreq[0].logicalChan != ucLast) { // // Remember the channel we just detected. // ucLast = pFreq[0].logicalChan; // // Tell the user which channel we found to be active. // UpdateStatus("Active channel is %d.", pFreq[0].logicalChan); // // Set the "LEDs" to mimic the behavior of the MSP430 versions // of this application. // switch(pFreq[0].logicalChan) { case 0: { /* GREEN OFF */ /* RED OFF */ SetLED(1, false); SetLED(2, false); break; } case 1: { /* GREEN OFF */ /* RED ON */ SetLED(1, false); SetLED(2, true); break; } case 2: { /* GREEN ON */ /* RED OFF */ SetLED(1, true); SetLED(2, false); break; } case 3: { /* GREEN ON */ /* RED ON */ SetLED(1, true); SetLED(2, true); break; } case 4: { /* blink them both... */ SetLED(1, false); SetLED(2, false); SPIN_ABOUT_A_QUARTER_SECOND; SetLED(1, true); SetLED(2, true); SPIN_ABOUT_A_QUARTER_SECOND; SetLED(1, false); SetLED(2, false); } } } } } }
//***************************************************************************** // // Main application entry function. // //***************************************************************************** int main(void) { tBoolean bRetcode; bspIState_t intState; uint8_t ucLastChannel; // // Set the system clock to run at 50MHz from the PLL // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // NB: We don't call PinoutSet() in this testcase since the EM header // expansion board doesn't currently have an I2C ID EEPROM. If we did // call PinoutSet() this would configure all the EPI pins for SDRAM and // we don't want to do this. // g_eDaughterType = DAUGHTER_NONE; // // Enable peripherals required to drive the LCD. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH); // // Configure SysTick for a 10Hz interrupt. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / TICKS_PER_SECOND); ROM_SysTickEnable(); ROM_SysTickIntEnable(); // // Initialize the display driver. // Kitronix320x240x16_SSD2119Init(); // // Initialize the touch screen driver. // TouchScreenInit(); // // Set the touch screen event handler. // TouchScreenCallbackSet(WidgetPointerMessage); // // Add the compile-time defined widgets to the widget tree. // WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sHeading); // // Initialize the status string. // UpdateStatus(true, "Initializing..."); // // Paint the widget tree to make sure they all appear on the display. // WidgetPaint(WIDGET_ROOT); // // Initialize the SimpliciTI BSP. // BSP_Init(); // // Set the SimpliciTI device address using the current Ethernet MAC address // to ensure something like uniqueness. // bRetcode = SetSimpliciTIAddress(); // // Did we have a problem with the address? // if(!bRetcode) { // // Yes - make sure the display is updated then hang the app. // WidgetMessageQueueProcess(); while(1) { // // MAC address is not set so hang the app. // } } // // Turn on both our LEDs // SetLED(1, true); SetLED(2, true); UpdateStatus(true, "Waiting for a device..."); // // Initialize the SimpliciTI stack and register our receive callback. // SMPL_Init(ReceiveCallback); // // Tell the user what's up. // UpdateStatus(true, "Access point active."); // // Do nothing after this - the SimpliciTI stack code handles all the // access point function required. // while(1) { // // Wait for the Join semaphore to be set by the receipt of a Join // frame from a device that supports an end device. // // An external method could be used as well. A button press could be // connected to an ISR and the ISR could set a semaphore that is // checked by a function call here, or a command shell running in // support of a serial connection could set a semaphore that is // checked by a function call. // if (g_ucJoinSem && (g_ucNumCurrentPeers < NUM_CONNECTIONS)) { // // Listen for a new incoming connection. // while (1) { if (SMPL_SUCCESS == SMPL_LinkListen(&g_sLID[g_ucNumCurrentPeers])) { // // The connection attempt succeeded so break out of the // loop. // break; } // // Process our widget message queue. // WidgetMessageQueueProcess(); // // A "real" application would implement its fail-to-link // policy here. We go back and listen again. // } // // Increment our peer counter. // g_ucNumCurrentPeers++; // // Decrement the join semaphore. // BSP_ENTER_CRITICAL_SECTION(intState); g_ucJoinSem--; BSP_EXIT_CRITICAL_SECTION(intState); // // Tell the user how many devices we are now connected to. // UpdateStatus(false, "%d devices connected.", g_ucNumCurrentPeers); } // // Have we received a frame on one of the ED connections? We don't use // a critical section here since it doesn't really matter much if we // miss a poll. // if (g_ucPeerFrameSem) { uint8_t pucMsg[MAX_APP_PAYLOAD], ucLen, ucLoop; /* process all frames waiting */ for (ucLoop = 0; ucLoop < g_ucNumCurrentPeers; ucLoop++) { // // Receive the message. // if (SMPL_SUCCESS == SMPL_Receive(g_sLID[ucLoop], pucMsg, &ucLen)) { // // ...and pass it to the function that processes it. // ProcessMessage(g_sLID[ucLoop], pucMsg, ucLen); // // Decrement our frame semaphore. // BSP_ENTER_CRITICAL_SECTION(intState); g_ucPeerFrameSem--; BSP_EXIT_CRITICAL_SECTION(intState); } } } // // Have we been asked to change channel? // ucLastChannel = g_ucChannel; if (g_bChangeChannel) { // // Yes - go ahead and change to the next radio channel. // g_bChangeChannel = false; ChangeChannel(); } else { // // No - check to see if we need to automatically change channel // due to interference on the current one. // CheckChangeChannel(); } // // If the channel changed, update the display. // if(g_ucChannel != ucLastChannel) { UpdateStatus(false, "Changed to channel %d.", g_ucChannel); } // // If required, blink the "LEDs" to indicate we are waiting for a // message following a channel change. // BSP_ENTER_CRITICAL_SECTION(intState); if (g_ulBlinky) { if (++g_ulBlinky >= 0xF) { g_ulBlinky = 1; ToggleLED(1); ToggleLED(2); } } BSP_EXIT_CRITICAL_SECTION(intState); // // Process our widget message queue. // WidgetMessageQueueProcess(); } }
//***************************************************************************** // // Main application entry function. // //***************************************************************************** int main(void) { tBoolean bSuccess, bRetcode, bInitialized; // // Set the system clock to run at 50MHz from the PLL // MAP_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // NB: We don't call PinoutSet() in this testcase since the EM header // expansion board doesn't currently have an I2C ID EEPROM. If we did // call PinoutSet() this would configure all the EPI pins for SDRAM and // we don't want to do this. // g_eDaughterType = DAUGHTER_NONE; // // Enable peripherals required to drive the LCD. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH); // // Configure SysTick for a 10Hz interrupt. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / TICKS_PER_SECOND); ROM_SysTickEnable(); ROM_SysTickIntEnable(); // // Initialize the display driver. // Kitronix320x240x16_SSD2119Init(); // // Initialize the touch screen driver. // TouchScreenInit(); // // Set the touch screen event handler. // TouchScreenCallbackSet(WidgetPointerMessage); // // Add the compile-time defined widgets to the widget tree. // WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sHeading); // // Paint the widget tree to make sure they all appear on the display. // WidgetPaint(WIDGET_ROOT); // // Initialize the SimpliciTI BSP. // BSP_Init(); // // Set the SimpliciTI device address using the current Ethernet MAC address // to ensure something like uniqueness. // bRetcode = SetSimpliciTIAddress(); if(!bRetcode) { // // The Ethernet MAC address can't have been set so hang here since we // don't have an address to use for SimpliciTI. // WidgetMessageQueueProcess(); while(1) { // // MAC address is not set so hang the app. // } } // // First time through, we need to initialize the SimpliciTI stack. // bInitialized = false; // // The main loop starts here now that we have joined the network. // while(1) { // // Tell the user what to do. // UpdateStatus(true, "Please choose the operating mode."); // // Now wait until the user selects whether we should run as the sender // or the receiver. // while(g_ulMode == MODE_UNDEFINED) { // // Just spin, processing UI messages and waiting for someone to // press one of the mode buttons. // WidgetMessageQueueProcess(); } // // At this point, the mode is set so remove the buttons from the // display and replace them with the LEDs. // WidgetRemove((tWidget *)&g_sBtnContainer); WidgetAdd((tWidget *)&g_sBackground, (tWidget *)&g_sLEDContainer); WidgetPaint((tWidget *)&g_sBackground); // // Tell the user what we're doing now. // UpdateStatus(false, "Joining network..."); if(!bInitialized) { // // Initialize the SimpliciTI stack We keep trying to initialize until // we get a success return code. This indicates that we have also // successfully joined the network. // while(SMPL_SUCCESS != SMPL_Init((uint8_t (*)(linkID_t))0)) { ToggleLED(1); ToggleLED(2); SPIN_ABOUT_A_SECOND; } // // Now that we are initialized, remember not to call this again. // bInitialized = true; } // // Once we have joined, turn both LEDs on and tell the user what we want // them to do. // SetLED(1, true); SetLED(2, true); // // Now call the function that initiates communication in // the desired mode. Note that these functions will not return // until communication is established or an error occurs. // if(g_ulMode == MODE_SENDER) { bSuccess = LinkTo(); } else { bSuccess = LinkFrom(); } // // If we were unsuccessfull, go back to the mode selection // display. // if(!bSuccess) { // // Remove the LEDs and show the buttons again. // WidgetRemove((tWidget *)&g_sLEDContainer); WidgetAdd((tWidget *)&g_sBackground, (tWidget *)&g_sBtnContainer); WidgetPaint((tWidget *)&g_sBackground); // // Tell the user what happened. // UpdateStatus(false, "Error establishing communication!"); // // Remember that we don't have an operating mode chosen. // g_ulMode = MODE_UNDEFINED; } } }
//***************************************************************************** // // Main application entry function. // //***************************************************************************** int main(void) { tBoolean bRetcode; smplStatus_t eRetcode; // // Set the system clock to run at 50MHz from the PLL // MAP_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // NB: We don't call PinoutSet() in this testcase since the EM header // expansion board doesn't currently have an I2C ID EEPROM. If we did // call PinoutSet() this would configure all the EPI pins for SDRAM and // we don't want to do this. // g_eDaughterType = DAUGHTER_NONE; // // Enable peripherals required to drive the LCD. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH); // // Configure SysTick for a 10Hz interrupt. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / TICKS_PER_SECOND); ROM_SysTickEnable(); ROM_SysTickIntEnable(); // // Initialize the display driver. // Kitronix320x240x16_SSD2119Init(); // // Initialize the touch screen driver. // TouchScreenInit(); // // Set the touch screen event handler. // TouchScreenCallbackSet(WidgetPointerMessage); // // Add the compile-time defined widgets to the widget tree. // WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sHeading); // // Initialize the status string. // UpdateStatus("Initializing..."); // // Paint the widget tree to make sure they all appear on the display. // WidgetPaint(WIDGET_ROOT); // // Initialize the SimpliciTI BSP. // BSP_Init(); // // Set the SimpliciTI device address using the current Ethernet MAC address // to ensure something like uniqueness. // bRetcode = SetSimpliciTIAddress(); // // Did we have a problem with the address? // if(!bRetcode) { // // Yes - make sure the display is updated then hang the app. // WidgetMessageQueueProcess(); while(1) { // // MAC address is not set so hang the app. // } } // // Turn on both our LEDs // SetLED(1, true); SetLED(2, true); UpdateStatus("Waiting..."); // // Initialize the SimpliciTI stack but don't set any receive callback. // while(1) { eRetcode = SMPL_Init((uint8_t (*)(linkID_t))0); if(eRetcode == SMPL_SUCCESS) { break; } ToggleLED(1); ToggleLED(2); SPIN_ABOUT_A_SECOND; } // // Tell the user what's up. // UpdateStatus("Range Extender active."); // // Do nothing after this - the SimpliciTI stack code handles all the // access point function required. // while(1) { // // Process the widget message queue. // WidgetMessageQueueProcess(); } }
//***************************************************************************** // // Main application entry function. // //***************************************************************************** int main(void) { tBoolean bRetcode; smplStatus_t eRetcode; ioctlToken_t eToken; // // Set the system clock to run at 50MHz from the PLL // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // NB: We don't call PinoutSet() in this testcase since the EM header // expansion board doesn't currently have an I2C ID EEPROM. If we did // call PinoutSet() this would configure all the EPI pins for SDRAM and // we don't want to do this. // g_eDaughterType = DAUGHTER_NONE; // // Enable peripherals required to drive the LCD. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH); // // Configure SysTick for a 10Hz interrupt. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / TICKS_PER_SECOND); ROM_SysTickEnable(); ROM_SysTickIntEnable(); // // Initialize the display driver. // Kitronix320x240x16_SSD2119Init(); // // Initialize the touch screen driver. // TouchScreenInit(); // // Set the touch screen event handler. // TouchScreenCallbackSet(WidgetPointerMessage); // // Add the compile-time defined widgets to the widget tree. // WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sHeading); // // Initialize the status string. // UpdateStatus("Initializing..."); // // Paint the widget tree to make sure they all appear on the display. // WidgetPaint(WIDGET_ROOT); // // Initialize the SimpliciTI BSP. // BSP_Init(); // // Set the SimpliciTI device address using the current Ethernet MAC address // to ensure something like uniqueness. // bRetcode = SetSimpliciTIAddress(); // // Did we have a problem with the address? // if(!bRetcode) { // // Yes - make sure the display is updated then hang the app. // WidgetMessageQueueProcess(); while(1) { // // MAC address is not set so hang the app. // } } // // Turn on both our LEDs // SetLED(1, true); SetLED(2, true); UpdateStatus("Waiting..."); // // Initialize the SimpliciTI stack but don't set any receive callback. // while(1) { eRetcode = SMPL_Init((uint8_t (*)(linkID_t))0); if(eRetcode == SMPL_SUCCESS) { break; } ToggleLED(1); ToggleLED(2); SPIN_ABOUT_A_SECOND; } // This code example changes the Link token to be distributed to those who // Join. For the example here this should be done before anyone joins so // the Join context is defaulted to OFF for this scenario. See the // smpl_config.dat file. After the link token is set the Join context must // be enabled. // // NOTE that this is done after initialization. For APs the init sequence // consists of a step in which a link token is generated. The sequence here // overrides that setting. It can be used to distribute different link // tokens to different devices. The sequence here is a simple example of // how to use the IOCTL interface to set the Link token for subsequent // Joiners. // // You might want to be careful about following this particular example if // you are restoring from NV unless you are setting a fixed value as is // done here. Unconditionally setting a random value will make it // essentially impossible for newly joining devices to link to devices that // joined before the AP was reset since they will have different link // tokens. // eToken.tokenType = TT_LINK; eToken.token.linkToken = 0x78563412; SMPL_Ioctl(IOCTL_OBJ_TOKEN, IOCTL_ACT_SET, &eToken); // // Enable join context. // SMPL_Ioctl(IOCTL_OBJ_AP_JOIN, IOCTL_ACT_ON, 0); // // Tell the user what's up. // UpdateStatus("Access point active."); // // Do nothing after this - the SimpliciTI stack code handles all the // access point function required. // while(1) { // // Process the widget message queue. // WidgetMessageQueueProcess(); } }
//***************************************************************************** // // Main application entry function. // //***************************************************************************** int main(void) { tBoolean bRetcode; // // Set the system clock to run at 50MHz from the PLL // ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // NB: We don't call PinoutSet() in this testcase since the EM header // expansion board doesn't currently have an I2C ID EEPROM. If we did // call PinoutSet() this would configure all the EPI pins for SDRAM and // we don't want to do this. // g_eDaughterType = DAUGHTER_NONE; // // Enable peripherals required to drive the LCD. // ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH); // // Configure SysTick for a 10Hz interrupt. // ROM_SysTickPeriodSet(ROM_SysCtlClockGet() / TICKS_PER_SECOND); ROM_SysTickEnable(); ROM_SysTickIntEnable(); // // Initialize the display driver. // Kitronix320x240x16_SSD2119Init(); // // Initialize the touch screen driver. // TouchScreenInit(); // // Set the touch screen event handler. // TouchScreenCallbackSet(WidgetPointerMessage); // // Add the compile-time defined widgets to the widget tree. // WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sHeading); // // Initialize the status string. // UpdateStatus(true, "Joining network..."); // // Paint the widget tree to make sure they all appear on the display. // WidgetPaint(WIDGET_ROOT); // // Initialize the SimpliciTI BSP. // BSP_Init(); // // Set the SimpliciTI device address using the current Ethernet MAC address // to ensure something like uniqueness. // bRetcode = SetSimpliciTIAddress(); // // Did we have a problem with the address? // if(!bRetcode) { // // Yes - make sure the display is updated then hang the app. // WidgetMessageQueueProcess(); while(1) { // // MAC address is not set so hang the app. // } } // // Turn both "LEDs" off. // SetLED(1, false); SetLED(2, false); // // Keep trying to join (a side effect of successful initialization) until // successful. Toggle LEDS to indicate that joining has not occurred. // while(SMPL_SUCCESS != SMPL_Init(0)) { ToggleLED(1); ToggleLED(2); SPIN_ABOUT_A_SECOND; } // // We have joined the network so turn on both "LEDs" to indicate this. // SetLED(1, true); SetLED(2, true); UpdateStatus(true, "Joined network"); // // Link to the access point which is now listening for us and continue // processing. This function does not return. // LinkTo(); }