//**************************************************************************** // //! \brief enables various peripheral after coming out of low power mode //! //! \param none //! //! \return none // //**************************************************************************** void enable_peripherals() { //Initialising uDMA UDMAInit(); //Initialising the link SPI spi_Open(NULL, NULL); //Initialising the UART terminal InitTerm(); }
int main(void) { long lRetVal = -1; // // initialize board configurations // BoardInit(); // // Pinmux GPIO for LEDs // PinMuxConfig(); #ifndef NOTERM // // Configuring UART // InitTerm(); #endif // // Configure LEDs // GPIO_IF_LedConfigure(LED1|LED2|LED3); GPIO_IF_LedOff(MCU_ALL_LED_IND); // // Simplelinkspawntask // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } lRetVal = osi_TaskCreate(XmppClient, (const signed char*)"XmppClient",\ OSI_STACK_SIZE, NULL, 1, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } osi_start(); while(1) { } }
//**************************************************************************** // //! Main function //! //! \param none //! //! This function //! 1. Invokes the SLHost task //! 2. Invokes the LPDSTCPServerTask //! //! \return None. // //**************************************************************************** void main() { long lRetVal = -1; // // Initialize the board // BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); #ifndef NOTERM // // Configuring UART // InitTerm(); ClearTerm(); #endif // // Start the SimpleLink Host // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the TCPServer task // lRetVal = osi_TaskCreate(TCPServerTask, (const signed char *)"DeepSleep TCP", OSI_STACK_SIZE, NULL, 1, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the task scheduler // osi_start(); }
//**************************************************************************** // MAIN FUNCTION //**************************************************************************** void main() { // // Board Initialization // BoardInit(); // // Enable and configure DMA // UDMAInit(); // // Pinmux for UART // PinMuxConfig(); #ifndef NOTERM // // Configuring UART // InitTerm(); // // Display Application Banner // DisplayBanner(APP_NAME); #endif // // Start the SimpleLink Host // VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); // // Start the HttpServer Task // // osi_TaskCreate(HttpServerAppTask, "WebSocketApp", OSI_STACK_SIZE, NULL, HTTP_SERVER_APP_TASK_PRIORITY, NULL ); UART_PRINT("HttpServerApp Initialized \n\r"); // // Start the task scheduler // osi_start(); return; }
//***************************************************************************** // //! Main //! //! \param none //! //! This function //! 1. Invokes the SLHost task //! 2. Invokes the MqttClient //! //! \return None //! //***************************************************************************** void main() { long lRetVal = -1; // // Initialize the board configurations // BoardInit(); // // Pinmux for UART // PinMuxConfig(); // // Configuring UART // InitTerm(); // // Display Application Banner // DisplayBanner("MQTT_Client"); // // Start the SimpleLink Host // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the MQTT Client task // osi_MsgQCreate(&g_PBQueue,"PBQueue",sizeof(event_msg),10); lRetVal = osi_TaskCreate(MqttClient, (const signed char *)"Mqtt Client App", OSI_STACK_SIZE, NULL, 2, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the task scheduler // osi_start(); }
//**************************************************************************** // //! Main function invoking the sleep and deepsleep functionality //! //! \param none //! //! This function //! 1. Invokes the API that implements Sleep followed by wakeup using WDT //! 2. Invokes the API that implements DeepSleep followed by wakeup //! using WDT //! 3. Invokes the API that implements Sleep followed by wakeup using GPT //! 4. Invokes the API that implements DeepSleep followed by wakeup //! using GPT //! //! \return None. // //**************************************************************************** void main() { // // Initialize the MCU // BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); // // Initialze the UART // InitTerm(); DisplayBanner(APP_NAME); DBG_PRINT("SLEEP_DEEPSLEEP: Test Begin\n\r"); // // Sleep followed by wakeup using WDT // PerformPRCMSleepWDTWakeup(); // // DeepSleep followed by wakeup using WDT // PerformPRCMDeepSleepWDTWakeup(); // // Sleep followed by wakeup using GPT // PerformPRCMSleepGPTWakeup(); // // DeepSleep followed by wakeup using GPT // PerformPRCMDeepSleepGPTWakeup(); DBG_PRINT("SLEEP_DEEPSLEEP: Test Complete\n\r"); // // Done. Loop here // while(1); }
void platform_init(void) { long lRetVal; // // Board Initialization // BoardInit(); // // configure the GPIO pins for LEDs,UART // PinMuxConfig(); // // Configure the UART // #ifndef NOTERM InitTerm(); ClearTerm(); #endif //NOTERM my_logger_init(logger_writer); // // Start the SimpleLink Host // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); ASSERT(lRetVal >= 0); // // Start the IoTKit runloop task // lRetVal = osi_TaskCreate(application_main, (const signed char*)"appmain", MAIN_TASK_STACK_SIZE, NULL, MAIN_TASK_PRIORITY, NULL); ASSERT(lRetVal >= 0); UDMAInit(); _platform_spi_init(); // // Start the task scheduler // osi_start(); }
//***************************************************************************** // MAIN FUNCTION //***************************************************************************** void main() { // // Board Initialization // BoardInit(); // // configure the GPIO pins for LEDs,UART // PinMuxConfig(); // // Configure the UART // #ifndef NOTERM InitTerm(); #endif //NOTERM // // Display Application Banner // DisplayBanner(APPLICATION_NAME); // // Configure all 3 LEDs // GPIO_IF_LedConfigure(LED1 | LED2 | LED3); // switch off all LEDs GPIO_IF_LedOff(MCU_ALL_LED_IND); FileTest(); /*// // Start the SimpleLink Host // VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); // // Start the WlanStationMode task // osi_TaskCreate( WlanStationMode, (const signed char*)"Wlan Station Task", OSI_STACK_SIZE, NULL, 1, NULL ); // // Start the task scheduler // osi_start();*/ }
static void BoardInit() { MAP_IntVTableBaseSet((unsigned long)&g_pfnVectors[0]); MAP_IntMasterEnable(); MAP_IntEnable(FAULT_SYSTICK); PRCMCC3200MCUInit(); UDMAInit(); MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK); MAP_PinTypeUART(PIN_55, PIN_MODE_3); MAP_PinTypeUART(PIN_57, PIN_MODE_3); InitTerm(); }
//**************************************************************************** // MAIN FUNCTION //**************************************************************************** void main() { char cMode = 0; // // Board Initialization // BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); // // Configuring UART // #ifndef NOTERM InitTerm(); #endif //NOTERM // // Display banner // DisplayBanner(APP_NAME); // // staring simplelink // cMode = sl_Start(NULL,NULL,NULL); // // Display current mode and ssid name(for AP mode) // DisplayCurrentConfig(cMode); // // Configure the networking mode and ssid name(for AP mode) // ConfigureMode(cMode); UART_PRINT("Please restart the device \n\r"); sl_Stop(SL_STOP_TIMEOUT); LOOP_FOREVER(line_number); }
//**************************************************************************** // //! Main function //! //! \param none //! //! This function //! 1. Invokes the SLHost task //! 2. Invokes the HIBUDPBroadcastTask //! //! \return None. // //**************************************************************************** void main() { long lRetVal = -1; // // Initialize board confifurations // BoardInit(); // // Pinmux for UART & LED // PinMuxConfig(); #ifndef NOTERM // // Configuring UART // InitTerm(); #endif // // Start the SimpleLink Host // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the HIBUDPBroadcast task // lRetVal = osi_TaskCreate(HIBUDPBroadcastTask, (const signed char *)"HIB UDP Broadcast", OSI_STACK_SIZE, NULL, 1, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the task scheduler // osi_start(); }
//***************************************************************************** // //! Main //! //! \param none //! //! \return None //! //***************************************************************************** void main() { long lRetVal = -1; // // Initialize board configuration // BoardInit(); PinMuxConfig(); //Initialize GPIO interrupt GPIOIntInit(); //Initialize Systick interrupt SystickIntInit(); //Initialize Uart interrupt UART1IntInit(); //Initialize SPI SPIInit(); //Initalize Adafruit Adafruit_Init(); InitTerm(); //Connect the CC3200 to the local access point lRetVal = connectToAccessPoint(); //Set time so that encryption can be used lRetVal = set_time(); if(lRetVal < 0) { UART_PRINT("Unable to set time in the device"); LOOP_FOREVER(); } //Connect to the website with TLS encryption lRetVal = tls_connect(); if(lRetVal < 0) { ERR_PRINT(lRetVal); } //remote calls sendMessage() which calls http_post() which requires the return value from tls_connect() remote(lRetVal); //http_post(lRetVal); sl_Stop(SL_STOP_TIMEOUT); LOOP_FOREVER(); }
void initBoard() { #ifndef USE_TIRTOS #if defined(ccs) || defined(gcc) MAP_IntVTableBaseSet((unsigned long) &g_pfnVectors[0]); #endif #if defined(ewarm) MAP_IntVTableBaseSet((unsigned long)&__vector_table); #endif #endif MAP_IntMasterEnable(); MAP_IntEnable(FAULT_SYSTICK); PRCMCC3200MCUInit(); PinMuxConfig(); GPIO_IF_LedConfigure(LED1); GPIO_IF_LedOff(MCU_RED_LED_GPIO); InitTerm(); ClearTerm(); UART_PRINT("QuickStart - Parse for IoT sample application\r\n"); UART_PRINT("---------------------------------------------\r\n"); UART_PRINT("\r\n"); UART_PRINT("[QuickStart] Board init\r\n"); // start the spawn task VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); // initialize the I2C bus I2C_IF_Open(I2C_MASTER_MODE_FST); UART_PRINT("[QuickStart] Device : TI SimpleLink CC3200\r\n"); #ifdef USE_TIRTOS UART_PRINT("[QuickStart] Operating system : TI-RTOS\r\n"); #endif #ifdef USE_FREERTOS UART_PRINT("[QuickStart] Operating system : FreeRTOS\r\n"); #endif #ifndef SL_PLATFORM_MULTI_THREADED UART_PRINT("[QuickStart] Operating system : None\r\n"); #endif }
int main() { long lRetVal = -1; // // Board Initialization // BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); // // Configuring UART // InitTerm(); // // Display banner // DisplayBanner(APP_NAME); InitializeAppVariables(); lRetVal = ServerFileDownload(); if(lRetVal < 0) { UART_PRINT("Server file download failed\n\r"); LOOP_FOREVER(); } else { UART_PRINT("Downloading File Completed\n\r"); } UART_PRINT("\nThank you\r\n"); // Stop the CC3200 device lRetVal = sl_Stop(SL_STOP_TIMEOUT); LOOP_FOREVER(); }
//**************************************************************************** // //! Main function //! //! \param none //! //! This function //! 1. Invokes the Loader Task //! //! \return None. // //**************************************************************************** void main() { BoardInit(); PinMuxConfig(); InitTerm(); DisplayBanner(APPLICATION_NAME); // Start the SimpleLink Host VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); // Start the Loader task osi_TaskCreate(Loader, (const signed char*)"Loader Task", \ OSI_STACK_SIZE, NULL, 1, NULL ); // Start the task scheduler osi_start(); }
//***************************************************************************** // MAIN FUNCTION //***************************************************************************** void main() { // // Board Initialization // BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); #ifndef NOTERM // // Configuring UART // InitTerm(); #endif // // Display banner // DisplayBanner(APP_NAME); // // Start the SimpleLink Host // VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); // // Start the WlanAPMode task // osi_TaskCreate( WlanAPMode, (const signed char*)"wireless LAN in AP mode", OSI_STACK_SIZE, NULL, 1, NULL ); // // Start the task scheduler // osi_start(); }
void UartTask(void *pvParameters) { //OsiReturnVal_e eRetVal; char * pcMsg; InitTerm(); ClearTerm(); /*eRetVal = */osi_MsgQCreate(&g_sUartQuee, "Uart Channel", sizeof(unsigned long), 10); //if(eRetVal != OSI_OK) //Report("ERROR: Failed to init Uart Quee, error code %d.\n\r", eRetVal); Message("Uart Channel Initialized.\n\r Waiting for messages.\n\r"); while (1) { osi_MsgQRead(&g_sUartQuee, &pcMsg, OSI_WAIT_FOREVER); Message(pcMsg); } }
int main() { long lRetVal = -1; // // Initialize Board configurations // BoardInit(); // // Configuring UART // #ifndef NOTERM InitTerm(); #endif //NOTERM // // Simplelinkspawntask // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Create 'CameraService' task // lRetVal = osi_TaskCreate(CameraService,(signed char *) "CameraService", OSI_STACK_SIZE, NULL, 1, NULL); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } osi_start(); return 0; }
//**************************************************************************** // //! Main function //! //! \param none //! //! This function //! 1. Invokes the LEDBlinkyTask //! //! \return None. // //**************************************************************************** int main() { // // Initialize Board configurations // BoardInit(); // // Power on the corresponding GPIO port B for 9,10,11. // Set up the GPIO lines to mode 0 (GPIO) // PinMuxConfig(); #ifndef NOTERM // // Configuring UART // InitTerm(); #endif DisplayBanner("Lab 0"); Message("\t\t****************************************************\n\r"); Message("\t\t\t CC3200 UART Echo Usage \n\r"); Message("\t\t To get to state 3, the user must press and hold SW2 \n\r"); Message("\t\t then press SW3 without releasing SW2 \n\r"); Message("\t\t and then release SW2 while continuing to press SW3\n\r"); Message("\n\n\n\r"); GPIO_IF_LedConfigure(LED1|LED2|LED3); GPIO_IF_LedOff(MCU_ALL_LED_IND); // // Start the LEDBlinkyRoutine // LEDBlinkyRoutine(); return 0; }
//***************************************************************************** // //! Main function handling the interrupt example //! //! \param none //! //! \return none //! //***************************************************************************** void main() { // // Initialize board configurations BoardInit(); PinMuxConfig(); // // Configuring UART // InitTerm(); // // Display Banner // DisplayBanner(APP_NAME); // // Do Interrupt Test // DoInterruptTest(); while(1); }
//***************************************************************************** // //! Main Function // //***************************************************************************** int main() { // // Initialize Board configurations // BoardInit(); // // Pinmux for UART // PinMuxConfig(); // // Configuring UART // InitTerm(); // // Display Application Banner // DisplayBanner(APP_NAME); // // Enable pull down // MAP_PinConfigSet(PIN_05,PIN_TYPE_STD_PD,PIN_STRENGTH_6MA); // // Register timer interrupt hander // MAP_TimerIntRegister(TIMERA2_BASE,TIMER_A,TimerIntHandler); // // Configure the timer in edge count mode // MAP_TimerConfigure(TIMERA2_BASE, (TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_CAP_TIME)); // // Set the detection edge // MAP_TimerControlEvent(TIMERA2_BASE,TIMER_A,TIMER_EVENT_POS_EDGE); // // Set the reload value // MAP_TimerLoadSet(TIMERA2_BASE,TIMER_A,0xffff); // // Enable capture event interrupt // MAP_TimerIntEnable(TIMERA2_BASE,TIMER_CAPA_EVENT); // // Enable Timer // MAP_TimerEnable(TIMERA2_BASE,TIMER_A); while(1) { // // Report the calculate frequency // Report("Frequency : %d Hz\n\n\r",g_ulFreq); // // Delay loop // MAP_UtilsDelay(80000000/5); } }
//**************************************************************************** // MAIN FUNCTION //**************************************************************************** void main() { long lRetVal = 0; char data[BUF_SIZE]; char sent_data[BUF_SIZE]; unsigned char highByte, lowByte; int i; unsigned long tempStartTimeStamp, tempStopTimeStamp; memset(sent_data, 0, 10); // Board Initialization BoardInit(); // Configure the pinmux settings for the peripherals exercised PinMuxConfig(); // Initialize the PWM outputs on the board InitServos(); // Initialize the sensor ADC InitSensorADC(); // Configuring UART InitTerm(); // Display banner DisplayBanner(APPLICATION_NAME); // Connect to WIFI using default info //WlanConnect(NULL, NULL, NULL); WlanConnect("Nagui's Network", "SL_SEC_TYPE_WPA", "19520605"); // Setup the TCP Server Socket BsdTcpServerSetup(PORT_NUM); // Recieve Data while (lRetVal >= 0) { lRetVal = BsdTcpServerReceive(data); //SysTickPeriodSet(800000000); // test //SysTickEnable(); // test Timer_IF_Init(PRCM_TIMERA0, TIMERA0_BASE, TIMER_CFG_PERIODIC, TIMER_A, 0); Timer_IF_Start(TIMERA0_BASE, TIMER_A, MILLISECONDS_TO_TICKS(2000)); //tempStartTimeStamp = SysTickValueGet(); // test tempStartTimeStamp = Timer_IF_GetCount(TIMERA0_BASE, TIMER_A); for (i = 0; i<NUM_SERVOS; i++) { MoveServo((unsigned char)data[i], (enum Servo_Joint_Type)i); UART_PRINT("%d", (unsigned int) data[i]); } for (i = 0; i< NUM_SENSORS; i++) { //UnsignedShort_to_UnsignedChar(GetSensorReading((enum Fingertip_Sensor_Type)i), &highByte, &lowByte); UnsignedShort_to_UnsignedChar(GetSensorReading(SENSOR_FINGER_INDEX), &highByte, &lowByte); sent_data[i*2] = (char)highByte; sent_data[i*2+1] = (char)lowByte; } //tempStopTimeStamp = SysTickValueGet(); // test tempStopTimeStamp = Timer_IF_GetCount(TIMERA0_BASE, TIMER_A); lRetVal = BsdTcpServerSend(sent_data, 10); UART_PRINT("timestamp start: %lu\n\r", tempStartTimeStamp); //test UART_PRINT("timestamp stop: %lu\n\r", tempStopTimeStamp); //test UART_PRINT("Sent 10 bytes to client.\n\r"); } UART_PRINT("Exiting Application ...\n\r"); // power of the Network processor lRetVal = sl_Stop(SL_STOP_TIMEOUT); }
//****************************************************************************** // MAIN FUNCTION //****************************************************************************** int main() { long lRetVal = -1; BoardInit(); // // Pinmux Configuration // PinMuxConfig(); // // Initialising the UART terminal // InitTerm(); // // Create RX and TX Buffer // pTxBuffer = CreateCircularBuffer(TX_BUFFER_SIZE); if(pTxBuffer == NULL) { UART_PRINT("Unable to Allocate Memory for Tx Buffer\n\r"); LOOP_FOREVER(); } pRxBuffer = CreateCircularBuffer(RX_BUFFER_SIZE); if(pRxBuffer == NULL) { UART_PRINT("Unable to Allocate Memory for Rx Buffer\n\r"); LOOP_FOREVER(); } // // Initialising the I2C Interface // lRetVal = I2C_IF_Open(1); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Configure Audio Codec // ConfigureAudioCodec(CODEC_I2S_WORD_LEN_24); GPIO_IF_LedConfigure(LED2|LED3); GPIO_IF_LedOff(MCU_RED_LED_GPIO); GPIO_IF_LedOff(MCU_GREEN_LED_GPIO); // // Configure PIN_01 for GPIOOutput // MAP_PinTypeGPIO(PIN_01, PIN_MODE_0, false); MAP_GPIODirModeSet(GPIOA1_BASE, 0x4, GPIO_DIR_MODE_OUT); // // Configure PIN_02 for GPIOOutput // MAP_PinTypeGPIO(PIN_02, PIN_MODE_0, false); MAP_GPIODirModeSet(GPIOA1_BASE, 0x8, GPIO_DIR_MODE_OUT); //Turning off Green,Orange LED after i2c writes completed - First Time GPIO_IF_LedOff(MCU_GREEN_LED_GPIO); GPIO_IF_LedOff(MCU_ORANGE_LED_GPIO); // // Initialize the Audio(I2S) Module // AudioCapturerInit(); // // Initialize the DMA Module // UDMAInit(); UDMAChannelSelect(UDMA_CH4_I2S_RX, NULL); UDMAChannelSelect(UDMA_CH5_I2S_TX, NULL); // // Setup the DMA Mode // SetupPingPongDMATransferTx(); SetupPingPongDMATransferRx(); // // Setup the Audio In/Out // lRetVal = AudioCapturerSetupDMAMode(DMAPingPongCompleteAppCB_opt, \ CB_EVENT_CONFIG_SZ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } AudioCaptureRendererConfigure(); // // Start Audio Tx/Rx // Audio_Start(); // // Start the simplelink thread // lRetVal = VStartSimpleLinkSpawnTask(9); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the Network Task // lRetVal = osi_TaskCreate( Network, (signed char*)"NetworkTask",\ OSI_STACK_SIZE, NULL, 1, &g_NetworkTask ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the Control Task // lRetVal = ControlTaskCreate(); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the Microphone Task // lRetVal = osi_TaskCreate( Microphone,(signed char*)"MicroPhone", \ OSI_STACK_SIZE, NULL, 1, &g_MicTask ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the Speaker Task // lRetVal = osi_TaskCreate( Speaker, (signed char*)"Speaker",OSI_STACK_SIZE, \ NULL, 1, &g_SpeakerTask ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the task scheduler // osi_start(); }
//**************************************************************************** // MAIN FUNCTION //**************************************************************************** void main() { long retVal = -1; unsigned long ulResetCause; unsigned long ulDestinationIP; // // Board Initialization // BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); // // Configuring UART // InitTerm(); // // Initialize WDT // WDT_IF_Init(NULL,80000000 * 10); // // Get the reset cause // ulResetCause = PRCMSysResetCauseGet(); // // If watchdog triggered reset request hibernate // to clean boot the system // if( ulResetCause == PRCM_WDT_RESET ) { HIBEntrePreamble(); MAP_PRCMOCRRegisterWrite(0,1); MAP_PRCMHibernateWakeupSourceEnable(PRCM_HIB_SLOW_CLK_CTR); MAP_PRCMHibernateIntervalSet(330); MAP_PRCMHibernateEnter(); } // // uDMA Initialization // UDMAInit(); // // Display banner // DisplayBanner(APPLICATION_NAME); if( ulResetCause == PRCM_HIB_EXIT && (MAP_PRCMOCRRegisterRead(0) & 1) == 1 ) { UART_PRINT("Reset Cause : Watchdog Reset\n\r"); } else { UART_PRINT("Reset Cause : Power On\n\r"); // // Initialize the variables. // InitializeAppVariables(); // // Following function configure the device to default state by cleaning // the persistent settings stored in NVMEM (viz. connection profiles & // policies, power policy etc) // // Applications may choose to skip this step if the developer is sure // that the device is in its desired state at start of applicaton // // Note that all profiles and persistent settings that were done on the // device will be lost // retVal = ConfigureSimpleLinkToDefaultState(); if(retVal < 0) { if (DEVICE_NOT_IN_STATION_MODE == retVal) UART_PRINT("Failed to configure the device in its default" " state \n\r"); LOOP_FOREVER(); } } // // Set destination IP // ulDestinationIP = IP_ADDR; // // Asumption is that the device is configured in station mode already // and it is in its default state // retVal = sl_Start(0, 0, 0); // // Acknowledge the watchdog so that it doesn't resets // WatchdogAck(); if (retVal < 0 || retVal != ROLE_STA) { UART_PRINT("Failed to start the device \n\r"); LOOP_FOREVER(); } // //Connecting to WLAN AP // retVal = WlanConnect(); // // Acknowledge the watchdog so that it doesn't resets // WatchdogAck(); if(retVal < 0) { UART_PRINT("Failed to establish connection w/ an AP \n\r"); LOOP_FOREVER(); } UART_PRINT("Connected to AP : %s \n\r",SSID_NAME); UART_PRINT("Device IP : %d.%d.%d.%d\n\r\n\r", SL_IPV4_BYTE(g_ulIpAddr,3), SL_IPV4_BYTE(g_ulIpAddr,2), SL_IPV4_BYTE(g_ulIpAddr,1), SL_IPV4_BYTE(g_ulIpAddr,0)); UART_PRINT("\nStarting UDP Client\n\n\r"); UART_PRINT("Source IP : %d.%d.%d.%d\n\r" "Destination IP : %d.%d.%d.%d\n\r" "PORT : %d\n\r", SL_IPV4_BYTE(g_ulIpAddr,3), SL_IPV4_BYTE(g_ulIpAddr,2), SL_IPV4_BYTE(g_ulIpAddr,1), SL_IPV4_BYTE(g_ulIpAddr,0), SL_IPV4_BYTE(ulDestinationIP,3), SL_IPV4_BYTE(ulDestinationIP,2), SL_IPV4_BYTE(ulDestinationIP,1), SL_IPV4_BYTE(ulDestinationIP,0), g_uiPortNum); // // Acknowledge the watchdog so that it doesn't resets // WatchdogAck(); // // Send packets // BsdUdpClient(PORT_NUM,ulDestinationIP); // // power off the network processor // sl_Stop(SL_STOP_TIMEOUT); while (1) { _SlNonOsMainLoopTask(); } }
//***************************************************************************** // //! main - populate the parameters from predefines Test Vector or User //! //! \param None //! //! \return None // //***************************************************************************** void main() { unsigned int uiConfig,uiHashLength,uiDataLength; unsigned char *puiKey1,*puiData,*puiResult; unsigned int u8count; #ifndef USER_INPUT unsigned char *puiTempExpResult; #endif // // Initialize board configurations BoardInit(); // // Configuring UART for Receiving input and displaying output // 1. PinMux setting // 2. Initialize UART // 3. Displaying Banner // PinMuxConfig(); InitTerm(); DisplayBanner(APP_NAME); // // Enable the module . // MAP_PRCMPeripheralClkEnable(PRCM_DTHE, PRCM_RUN_MODE_CLK); // // Enable interrupts. // MAP_SHAMD5IntRegister(SHAMD5_BASE, SHAMD5IntHandler); #ifdef USER_INPUT while(FOREVER) { // // Read values either from User or from Vector based on macro USER_INPUT // defined or not // // // Read the values from the user over uart and Populate the variables // puiData=ReadFromUser(&uiConfig,&uiHashLength,&puiKey1,&uiDataLength, &puiResult); if(puiData==NULL) { continue; } #else // // Load Default values // UART_PRINT("Running Keyed Hashing HMAC_MD5\n\r\n\r"); UART_PRINT("loading default values\n\r\n\r"); uiHMAC=1; puiData= LoadDefaultValues(SHAMD5_ALGO_HMAC_MD5,&uiConfig,&uiHashLength, &puiKey1,&uiDataLength,&puiResult); UART_PRINT("Data Length (in Bytes) %d\n\r\n\r",uiDataLength); #endif // // Generate Hash Value // UART_PRINT("\n\rHashing in Progress... \n\r"); GenerateHash(uiConfig,puiKey1,puiData,puiResult,uiDataLength); UART_PRINT("Hash Value is generated\n\r"); // // Display/Verify Result // #ifdef USER_INPUT // // Display Hash Value Generated // UART_PRINT("\n\r The Hash Value in Hex is: 0x%02x",*puiResult); for(u8count=0; u8count<(uiHashLength/4); u8count++) { UART_PRINT("%02x",*(puiResult+u8count)); } UART_PRINT("\n\r"); } //end while(FOREVER) #else // // Comapre Hash Generated and expected values from predefined vector // UART_PRINT("Hash Length (in Bytes) %d\n\r\n\r",uiHashLength); UART_PRINT("\n\r Computed Hash Value in Hex is: "); for(u8count=0; u8count<uiHashLength; u8count++) { UART_PRINT("%02x",*(puiResult+u8count)); } UART_PRINT("\n\r"); puiTempExpResult = (unsigned char *)g_psHMACShaMD5TestVectors.puiExpectedHash; UART_PRINT("\n\r Expected Hash Value in Hex is: "); for(u8count=0; u8count<uiHashLength; u8count++) { UART_PRINT("%02x",*(puiTempExpResult+u8count)); } UART_PRINT("\n\r"); if(memcmp(puiResult,g_psHMACShaMD5TestVectors.puiExpectedHash,uiHashLength)==0) { UART_PRINT("\n\r Hashing verified successfully"); } else { UART_PRINT("\n\r Error in Hashing computation"); } while(FOREVER); #endif }
//***************************************************************************** // //! main - calls Crypt function after populating either from pre- defined vector //! or from User //! //! \param none //! //! \return none //! //***************************************************************************** void main() { unsigned long uiAdcInputPin; unsigned int uiChannel; unsigned int uiIndex=0; unsigned long ulSample; // // Initialize Board configurations // BoardInit(); // // Configuring UART for Receiving input and displaying output // 1. PinMux setting // 2. Initialize UART // 3. Displaying Banner // PinMuxConfig(); InitTerm(); DisplayBanner(APP_NAME); while(FOREVER) { // // Initialize Array index for multiple execution // uiIndex=0; // // Read inputs from user // if(!ReadFromUser(&uiAdcInputPin)) { UART_PRINT("\n\rInvalid Input. Please try again. HAHAHAHAHAHAHAHAHA\n\r"); continue; } #ifdef CC3200_ES_1_2_1 // // Enable ADC clocks.###IMPORTANT###Need to be removed for PG 1.32 // HWREG(GPRCM_BASE + GPRCM_O_ADC_CLK_CONFIG) = 0x00000043; HWREG(ADC_BASE + ADC_O_ADC_CTRL) = 0x00000004; HWREG(ADC_BASE + ADC_O_ADC_SPARE0) = 0x00000100; HWREG(ADC_BASE + ADC_O_ADC_SPARE1) = 0x0355AA00; #endif // // Pinmux for the selected ADC input pin // MAP_PinTypeADC(uiAdcInputPin,PIN_MODE_255); // // Convert pin number to channel number // switch(uiAdcInputPin) { case PIN_58: uiChannel = ADC_CH_1; break; case PIN_59: uiChannel = ADC_CH_2; break; case PIN_60: uiChannel = ADC_CH_3; break; default: break; } // // Configure ADC timer which is used to timestamp the ADC data samples // MAP_ADCTimerConfig(ADC_BASE,2^17); // // Enable ADC timer which is used to timestamp the ADC data samples // MAP_ADCTimerEnable(ADC_BASE); // // Enable ADC module // MAP_ADCEnable(ADC_BASE); // // Enable ADC channel // MAP_ADCChannelEnable(ADC_BASE, uiChannel); while(uiIndex < NO_OF_SAMPLES + 4) { if(MAP_ADCFIFOLvlGet(ADC_BASE, uiChannel)) { ulSample = MAP_ADCFIFORead(ADC_BASE, uiChannel); pulAdcSamples[uiIndex++] = ulSample; } } MAP_ADCChannelDisable(ADC_BASE, uiChannel); uiIndex = 0; //UART_PRINT("\n\rTotal no of 32 bit ADC data printed :4096 \n\r"); //UART_PRINT("\n\rADC data format:\n\r"); //UART_PRINT("\n\rbits[13:2] : ADC sample\n\r"); //UART_PRINT("\n\rbits[31:14]: Time stamp of ADC sample \n\r"); // // Print out ADC samples // while(uiIndex < NO_OF_SAMPLES) { UART_PRINT("\n\rVoltage is %f\n\r",(((float)((pulAdcSamples[4+uiIndex] >> 2 ) & 0x0FFF))*1.4)/4096); uiIndex++; } //UART_PRINT("\n\rVoltage is %f\n\r",((pulAdcSamples[4] >> 2 ) & 0x0FFF)*1.4/4096); UART_PRINT("\n\r"); } }
int main(void) { long lRetVal = -1; // // Initialize Board configurations // BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); #ifndef NOTERM InitTerm(); #endif // configure RED LED GPIO_IF_LedConfigure(LED1); GPIO_IF_LedOff(MCU_RED_LED_GPIO); InitializeAppVariables(); // // Following function configure the device to default state by cleaning // the persistent settings stored in NVMEM (viz. connection profiles & // policies, power policy etc) // // Applications may choose to skip this step if the developer is sure // that the device is in its default state at start of applicaton // // Note that all profiles and persistent settings that were done on the // device will be lost // lRetVal = ConfigureSimpleLinkToDefaultState(); if(lRetVal < 0) { if (DEVICE_NOT_IN_STATION_MODE == lRetVal) UART_PRINT("Failed to configure the device in its " "default state \n\r"); LOOP_FOREVER(); } UART_PRINT("Device is configured in default state \n\r"); CLR_STATUS_BIT_ALL(g_ulStatus); //Start simplelink lRetVal = sl_Start(0,0,0); if (lRetVal < 0 || ROLE_STA != lRetVal) { UART_PRINT("Failed to start the device \n\r"); LOOP_FOREVER(); } UART_PRINT("Device started as STATION \n\r"); /* Connect to our AP using SmartConfig method */ lRetVal = SmartConfigConnect(); if(lRetVal < 0) { ERR_PRINT(lRetVal); } LOOP_FOREVER(); }
int main() { long lRetVal = -1; // // Initialize Board configurations // BoardInit(); // // Pinmuxing for GPIO,UART // PinMuxConfig(); // // configure LEDs // GPIO_IF_LedConfigure(LED1|LED2|LED3); GPIO_IF_LedOff(MCU_ALL_LED_IND); #ifndef NOTERM // // Configuring UART // InitTerm(); #endif // // Display Welcome Message // DisplayBanner(APP_NAME); // Generate Menu Output for Application OutputMenu(); // Initialize AP security params SecurityParams.Key = (signed char *)SECURITY_KEY; SecurityParams.KeyLen = strlen(SECURITY_KEY); SecurityParams.Type = SECURITY_TYPE; uiUartCmd=0; // // Simplelinkspawntask // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } lRetVal = osi_MsgQCreate(&g_PBQueue,"PBQueue",sizeof(tPushButtonMsg),1); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } lRetVal = osi_TaskCreate(PushButtonHandler, \ (signed char*)"PushButtonHandler", \ OSI_STACK_SIZE , NULL, \ TASK_PRIORITY+2, &g_PushButtonTask ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } lRetVal = osi_TaskCreate(SimpleEmail, (signed char*)"SimpleEmail", \ OSI_STACK_SIZE, \ NULL, TASK_PRIORITY+1, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } osi_start(); while(1) { } }
int main() { unsigned char ucP2PParam[4]; long lRetVal = -1; // // Initialize Board configurations // BoardInit(); // // Pinmuxing for GPIO, UART // PinMuxConfig(); // // configure LEDs // GPIO_IF_LedConfigure(LED1|LED2|LED3); // off all LEDs GPIO_IF_LedOff(MCU_ALL_LED_IND); #ifndef NOTERM // // Configuring UART // InitTerm(); #endif // // Display the Application Banner // DisplayBanner(APP_NAME); UART_PRINT("Scan Wi-FI direct device in your handheld device\n\r"); // Initializing the CC3200 device lRetVal = StartDeviceInP2P(); if(lRetVal < 0) { LOOP_FOREVER(__LINE__); } // Set any p2p option (SL_CONNECTION_POLICY(0,0,0,any_p2p,0)) to connect to // first available p2p device sl_WlanPolicySet(SL_POLICY_CONNECTION,SL_CONNECTION_POLICY(1,0,0,0,0),NULL,0); // Set the negotiation role (SL_P2P_ROLE_NEGOTIATE). // CC3200 will negotiate with remote device GO/client mode. // Other valid options are: // - SL_P2P_ROLE_GROUP_OWNER // - SL_P2P_ROLE_CLIENT sl_WlanPolicySet(SL_POLICY_P2P, SL_P2P_POLICY(SL_P2P_ROLE_NEGOTIATE, SL_P2P_NEG_INITIATOR_ACTIVE),NULL,0); // Set P2P Device name sl_NetAppSet(SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen(P2P_DEVICE_NAME), (unsigned char *)P2P_DEVICE_NAME); // Set P2P device type sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, WLAN_P2P_OPT_DEV_TYPE, strlen(P2P_CONFIG_VALUE), (unsigned char*)P2P_CONFIG_VALUE); // setting P2P channel parameters ucP2PParam[0] = LISENING_CHANNEL; ucP2PParam[1] = REGULATORY_CLASS; ucP2PParam[2] = OPERATING_CHANNEL; ucP2PParam[3] = REGULATORY_CLASS; // Set P2P Device listen and open channel valid channels are 1/6/11 sl_WlanSet(SL_WLAN_CFG_P2P_PARAM_ID, WLAN_P2P_OPT_CHANNEL_N_REGS, sizeof(ucP2PParam), ucP2PParam); // Restart as P2P device sl_Stop(SL_STOP_TIMEOUT); lRetVal = sl_Start(NULL,NULL,NULL); if(lRetVal < 0 || lRetVal != ROLE_P2P) { UART_PRINT("Failed to start the device \n\r"); LOOP_FOREVER(__LINE__); } else { UART_PRINT("Connect to %s \n\r",P2P_DEVICE_NAME); } /* Connect to configure P2P device */ lRetVal = WlanConnect(); if(lRetVal == 0) { GPIO_IF_LedOn(MCU_IP_ALLOC_IND); } else { UART_PRINT("Reset the device and try again\n\r"); LOOP_FOREVER(__LINE__); } DisplayIP(); UART_PRINT("Send TCP packets from your handheld device to CC3200's IP\n\r"); /*After calling this function, you can start sending data to CC3200 IP * address on PORT_NUM */ if(!(IS_CONNECT_FAILED(g_ulStatus))) BsdTcpServer(PORT_NUM); UART_PRINT("Received TCP packets successfully \n\r"); // revert Device into STA mode and power off Network Processor sl_WlanSetMode(ROLE_STA); sl_Stop(SL_STOP_TIMEOUT); UART_PRINT("Test passed, exiting application... \n\r"); while(1) { _SlNonOsMainLoopTask(); } }
//**************************************************************************** // MAIN FUNCTION //**************************************************************************** void main() { /* Display banner */ Report("\r\n\r\nTexas Instruments CC3200 Application - Powered by 2lemetry's ThingFabric Cloud\r\n\r\n"); BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); PinConfigSet(PIN_58,PIN_STRENGTH_2MA|PIN_STRENGTH_4MA,PIN_TYPE_STD_PD); // // UART Init // InitTerm(); // // LED Init // GPIO_IF_LedConfigure(LED1); //Turn Off the LEDs GPIO_IF_LedOff(MCU_RED_LED_GPIO); // // I2C Init // I2C_IF_Open(I2C_MASTER_MODE_FST); //Init Temprature Sensor TMP006DrvOpen(); //Init Accelerometer Sensor BMA222Open(); // // Simplelinkspawntask // VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); // Create semaphore to indicate CC3200 connected to an access point if (osi_SyncObjCreate(&semaphore_Connected) != 0) { Report("Semaphore not created\r\n"); } // // Create OOB Task // Report("Starting OOBTask\r\n"); osi_TaskCreate(OOBTask, (signed char*)"OOBTask", OSI_STACK_SIZE, NULL, OOB_TASK_PRIORITY, NULL ); // // Create mqtt Task // Report("Starting mqttTask\r\n"); osi_TaskCreate(mqttTask, (signed char*)"mqttTask", OSI_STACK_SIZE, NULL, OOB_TASK_PRIORITY, NULL ); // // Start OS Scheduler // osi_start(); while (1) { } }