//**************************************************************************** // //! Main function //! //! \param none //! //! This function //! 1. Invokes the SLHost task //! 2. Invokes the GetNTPTimeTask //! //! \return None. // //**************************************************************************** void main() { long lRetVal = -1; // // Initialize Board configurations // BoardInit(); // // Enable and configure DMA // UDMAInit(); // // Pinmux for UART // PinMuxConfig(); // // Configuring UART // InitTerm(); // // Display Application Banner // DisplayBanner(APP_NAME); // // Start the SimpleLink Host // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the GetNTPTime task // lRetVal = osi_TaskCreate(GetNTPTimeTask, (const signed char *)"Get NTP Time", OSI_STACK_SIZE, NULL, 1, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the task scheduler // osi_start(); }
static void Init() { long lRetVal = -1; BoardInit(); UDMAInit(); PinMuxConfig(); InitTerm(); 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() ; } // // Asumption is that the device is configured in station mode already // and it is in its default state // lRetVal = sl_Start(0, 0, 0); if (lRetVal < 0) { UART_PRINT("Failed to start the device \n\r"); LOOP_FOREVER() ; } UART_PRINT("Connecting to AP: '%s'...\r\n", SSID_NAME); // Connecting to WLAN AP - Set with static parameters defined at common.h // After this call we will be connected and have IP address lRetVal = WlanConnect(); if (lRetVal < 0) { UART_PRINT("Connection to AP failed \n\r"); LOOP_FOREVER() ; } UART_PRINT("Connected to AP: '%s' \n\r", SSID_NAME); #ifdef NEW_ID iobeam_Reset(); #endif }
//--tested, working--// bool WiFiClass::init() { // //only initialize once // if (_initialized) { return true; } // //Initialize the UDMA // UDMAInit(); // //start the SimpleLink driver (no callback) // int iRet = sl_Start(NULL, NULL, NULL); // //check if sl_start failed // if (iRet==ROLE_STA_ERR || iRet==ROLE_AP_ERR || iRet==ROLE_P2P_ERR) { return false; } // //set the mode to station if it's not already in station mode // if (iRet != ROLE_STA) { sl_WlanSetMode(ROLE_STA); sl_Stop(0); sl_Start(NULL, NULL, NULL); } // //Delete all profiles$ // sl_WlanProfileDel(0xff); // //disconnect from anything if for some reason it's connected // sl_WlanDisconnect(); sl_NetAppMDNSUnRegisterService(0, 0); _initialized = true; // // Start collecting statistics // sl_WlanRxStatStart(); return true; }
//**************************************************************************** // MAIN FUNCTION //**************************************************************************** int main() { long lRetVal = -1; // // Board Initialization // BoardInit(); // // Enable and configure DMA // UDMAInit(); // // Pinmux for UART // PinMuxConfig(); // // Configuring UART // InitTerm(); // // Display Application Banner // DisplayBanner(APP_NAME); // // Start the SimpleLink Host // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the Receiving file // lRetVal = osi_TaskCreate(cmd_dispatcher, (const signed char *)"TFTP", OSI_STACK_SIZE, NULL, 1, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start the task scheduler // osi_start(); return 0; }
//**************************************************************************** // MAIN FUNCTION //**************************************************************************** void main() { // // Board Initialization // BoardInit(); // // Pinmux for UART // PinMuxConfig(); #ifndef NOTERM // // Configuring UART // InitTerm(); // // Display Application Banner // DisplayBanner(APP_NAME); #endif // // Enable and configure DMA // UDMAInit(); // // 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; }
//**************************************************************************** // //! \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(); }
void SampleInit(void) { /* //UDMAInit(); // Reset SPI //MAP_SPIReset(GSPI_BASE); MAP_SPIConfigSetExpClk(GSPI_BASE,MAP_PRCMPeripheralClockGet(PRCM_GSPI), SPI_IF_BIT_RATE,SPI_MODE_MASTER,SPI_SUB_MODE_3, (SPI_HW_CTRL_CS | SPI_4PIN_MODE | SPI_TURBO_ON| SPI_CS_ACTIVELOW | SPI_WL_8)); MAP_SPIEnable(GSPI_BASE); MAP_SPICSEnable(GSPI_BASE); MAP_SPIFIFOEnable(GSPI_BASE,SPI_RX_FIFO); MAP_SPIFIFOEnable(GSPI_BASE,SPI_TX_FIFO); SPIFIFOLevelSet(GSPI_BASE,1,1); MAP_SPIIntEnable(GSPI_BASE,SPI_INT_DMARX|SPI_INT_DMATX); //MAP_SPIIntEnable(GSPI_BASE,SPI_INT_DMATX); //MAP_SPIIntRegister(GSPI_BASE,DMAIntHandler); osi_InterruptRegister(INT_GSPI, DMAIntHandler, 32); */ UDMAInit(); MAP_SPIConfigSetExpClk(GSPI_BASE,MAP_PRCMPeripheralClockGet(PRCM_GSPI), SPI_IF_BIT_RATE,SPI_MODE_MASTER,SPI_SUB_MODE_3, (SPI_HW_CTRL_CS | SPI_4PIN_MODE | SPI_TURBO_ON| SPI_CS_ACTIVEHIGH | SPI_WL_8)); MAP_SPIEnable(GSPI_BASE); MAP_SPICSEnable(GSPI_BASE); MAP_SPIFIFOEnable(GSPI_BASE,SPI_RX_FIFO); MAP_SPIFIFOEnable(GSPI_BASE,SPI_TX_FIFO); SPIFIFOLevelSet(GSPI_BASE,1,1); MAP_SPIIntEnable(GSPI_BASE,SPI_INT_DMARX); //MAP_SPIIntEnable(GSPI_BASE,SPI_INT_DMATX); //MAP_SPIIntRegister(GSPI_BASE,DMAIntHandler); osi_InterruptRegister(INT_GSPI, DMAIntHandler, 32); }
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(); }
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(); }
void SystemTaskCreate() { // Initializing DMA UDMAInit(); // Start the SimpleLink Host // VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); // // Start the GetWeather task // osi_TaskCreate(SystemTaskManager, (const signed char *)"system", OSI_STACK_SIZE, NULL, 1, NULL ); }
int main(void) { // // Board Initialization // BoardInit(); // // Enable and configure DMA // UDMAInit(); //Config pins PinMuxConfig(); InitPWMModules(); VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); osi_TaskCreate(HttpServerAppTask, "WebSocketApp", OSI_STACK_SIZE, NULL, HTTP_SERVER_APP_TASK_PRIORITY, NULL ); osi_TaskCreate(TargetTask, "Target", OSI_STACK_SIZE, NULL, TARGET_TASK_PRIORITY, NULL ); osi_start(); return 0; }
//**************************************************************************** // 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 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(); }
//***************************************************************************** // //***************************************************************************** void main() { // // Initialize Board configurations // BoardInit(); // // Do Pin mux // PinMuxConfig(); // // Enable and configure DMA // UDMAInit(); // // Initialize the display // InitTerm(); // // Initialize the buttons // Button_IF_Init(OnPressSW2Handler,OnPressSW3Handler); Button_IF_DisableInterrupt(SW3); // // Initialize OTA // pvOtaApp = sl_extLib_OtaInit(RUN_MODE_NONE_OS | RUN_MODE_BLOCKING,0); // // Initialize the global flag // g_ulSysState = SYS_STATE_RUN; // // Create sync object to signal Sl_Start and Wlan Connect complete // TaskSyncObjCreate(&g_NetStatSyncObj); // // Create sync object to signal OTA start // TaskSyncObjCreate(&g_OTAStatSyncObj); // // Create sync object to signal display refresh // TaskSyncObjCreate(&g_DispRefreshSyncObj); // // Create sync object to signal Factory reset event // TaskSyncObjCreate(&g_FactResetSyncObj); // // Initialize Display Info // memset(&sDisplayInfo,0,sizeof(tDisplayInfo)); sDisplayInfo.ucLocalTime[0] = '-'; sDisplayInfo.ucUTCTime[0] = '-'; sprintf(sDisplayInfo.ucTimeZone,"%+03d:%02d", (char)GMT_DIFF_TIME_HRS, (char)GMT_DIFF_TIME_MINS); sprintf(sDisplayInfo.ucAppVersion,"%d.%d.%d", APP_VER_MAJOR, APP_VER_MINOR, APP_VER_BUILD); // // Start the Print task // TaskCreate(DisplayTask, NULL); // // Start the GetNTPTime task // TaskCreate(GetNTPTimeTask, NULL); // // OTA Update Task // TaskCreate(OTAUpdateTask, NULL); // // SL main loop task; // TaskCreate(NonOSMainLoopTask, NULL); // // Factory Reset Task // TaskCreate(FactoryResetTask,NULL); // // Start the task scheduler // TaskMainLoopStart(); // // Infinite loop. Control Should never reach here // while(1) { } }
//***************************************************************************** // //! Main function handling the UART and DMA configuration. It takes 8 //! characters from terminal without displaying them. The string of 8 //! caracters will be printed on the terminal as soon as 8th character is //! typed in. //! //! \param None //! //! \return None //! //***************************************************************************** void main() { // // Initailizing the board // BoardInit(); // // Initialize the RX done flash // bRxDone = false; // // Initialize uDMA // UDMAInit(); // // Muxing for Enabling UART_TX and UART_RX. // PinMuxConfig(); // // Register interrupt handler for UART // MAP_UARTIntRegister(UARTA0_BASE,UARTIntHandler); // // Enable DMA done interrupts for uart // MAP_UARTIntEnable(UARTA0_BASE,UART_INT_DMARX); // // Initialising the Terminal. // MAP_UARTConfigSetExpClk(CONSOLE,MAP_PRCMPeripheralClockGet(CONSOLE_PERIPH), UART_BAUD_RATE, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // // Clear terminal // ClearTerm(); // // Display Banner // DisplayBanner(APP_NAME); Message("\t\t****************************************************\n\r"); Message("\t\t Type in a string of 8 characters, the characters \n\r"); Message("\t\t will not be displayed on the terminal until \n\r"); Message("\t\t 8th character is entered.\n\r") ; Message("\t\t****************************************************\n\r"); Message("\n\n\n\r"); // // Set the message // Message("Type in 8 characters:"); // // Configure the UART Tx and Rx FIFO level to 1/8 i.e 2 characters // UARTFIFOLevelSet(UARTA0_BASE,UART_FIFO_TX1_8,UART_FIFO_RX1_8); // // Setup DMA transfer for UART A0 // UDMASetupTransfer(UDMA_CH8_UARTA0_RX, UDMA_MODE_BASIC, 8, UDMA_SIZE_8, UDMA_ARB_2, (void *)(UARTA0_BASE+UART_O_DR), UDMA_SRC_INC_NONE, (void *)ucTextBuff, UDMA_DST_INC_8); // // Enable Rx DMA request from UART // MAP_UARTDMAEnable(UARTA0_BASE,UART_DMA_RX); // // Wait for RX to complete // while(!bRxDone) { } // // Setup DMA transfer for UART A0 // UDMASetupTransfer(UDMA_CH9_UARTA0_TX, UDMA_MODE_BASIC, 8, UDMA_SIZE_8, UDMA_ARB_2, (void *)ucTextBuff, UDMA_SRC_INC_8, (void *)(UARTA0_BASE+UART_O_DR), UDMA_DST_INC_NONE); // // Enable TX DMA request // MAP_UARTDMAEnable(UARTA0_BASE,UART_DMA_TX); while(1) { // // Inifite loop // } }
//***************************************************************************** // //! Main function for uDMA Application //! //! \param none //! //! \return none //! //***************************************************************************** void main() { static unsigned long ulPrevSeconds; static unsigned long ulPrevUARTCount = 0; unsigned long ulXfersCompleted; unsigned long ulBytesAvg=0; int iCount=0; // // Initailizing the board // BoardInit(); // // Muxing for Enabling UART_TX and UART_RX. // PinMuxConfig(); // // Initialising the Terminal. // InitTerm(); // // Display Welcome Message // DisplayBanner(); // // SysTick Enabling // SysTickIntRegister(SysTickHandler); SysTickPeriodSet(SYSTICK_RELOAD_VALUE); SysTickEnable(); // // uDMA Initialization // UDMAInit(); // // Register interrupt handler for UART // MAP_UARTIntRegister(UARTA0_BASE,UART0IntHandler); UART_PRINT("Completed DMA Initialization \n\r\n\r"); // // Auto DMA Transfer // UART_PRINT("Starting Auto DMA Transfer \n\r"); InitSWTransfer(); // // Scatter Gather DMA Transfer // UART_PRINT("Starting Scatter Gather DMA Operation\n\r"); InitSGTransfer(); while(!Done){} MAP_UtilsDelay(80000000); // // Ping Pong UART Transfer // InitUART0Transfer(); // // Remember the current SysTick seconds count. // ulPrevSeconds = g_ulSeconds; while(1) { // // Check to see if one second has elapsed. If so, the make some // updates. // if(g_ulSeconds != ulPrevSeconds) { uiCount++; // // Remember the new seconds count. // ulPrevSeconds = g_ulSeconds; // // Calculate how many UART transfers have occurred since the last // second. // ulXfersCompleted = (g_ulRxBufACount + g_ulRxBufBCount - ulPrevUARTCount); // // Remember the new UART transfer count. // ulPrevUARTCount = g_ulRxBufACount + g_ulRxBufBCount; // // Compute how many bytes were transferred by the UART. // ulBytesTransferred[iCount] = (ulXfersCompleted * UART_RXBUF_SIZE ); iCount++; // // Print a message to the display showing the memory transfer rate. // if(UARTDone) { MAP_PRCMPeripheralReset(PRCM_UARTA0); MAP_PRCMPeripheralClkEnable(PRCM_UARTA0,PRCM_RUN_MODE_CLK); UARTConfigSetExpClk(CONSOLE,SYSCLK, UART_BAUD_RATE, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); } } // // See if we have run long enough and exit the loop if so. // if(g_ulSeconds >= 6 && UARTDone) { break; } } // // Compute average Bytes Transfer Rate for the past 5 seconds // for(iCount=1;iCount<=5;iCount++) { ulBytesAvg += ulBytesTransferred[iCount]; } ulBytesAvg=ulBytesAvg/5; UART_PRINT("\n\r"); UART_PRINT("\n\r"); UART_PRINT("\n\rCompleted Ping Pong Transfer from Memory to UART " "Peripheral \n\r"); UART_PRINT(" \n\rTransfer Rate is %lu Bytes/Sec \n\r", ulBytesAvg); UART_PRINT("\n\rTest Ended\n\r"); return ; }
//****************************************************************************** // MAIN FUNCTION //****************************************************************************** int main() { long lRetVal = -1; unsigned char RecordPlay; BoardInit(); // // Pinmux Configuration // PinMuxConfig(); // // Initialising the UART terminal // InitTerm(); // // Initialising the I2C Interface // lRetVal = I2C_IF_Open(1); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } RecordPlay = I2S_MODE_RX_TX; g_loopback = 1; // // Create RX and TX Buffer // if(RecordPlay == I2S_MODE_RX_TX) { pRecordBuffer = CreateCircularBuffer(RECORD_BUFFER_SIZE); if(pRecordBuffer == NULL) { UART_PRINT("Unable to Allocate Memory for Tx Buffer\n\r"); LOOP_FOREVER(); } } /* Play */ if(RecordPlay & I2S_MODE_TX) { pPlayBuffer = CreateCircularBuffer(PLAY_BUFFER_SIZE); if(pPlayBuffer == NULL) { UART_PRINT("Unable to Allocate Memory for Rx Buffer\n\r"); LOOP_FOREVER(); } } // // Configure Audio Codec // AudioCodecReset(AUDIO_CODEC_TI_3254, NULL); AudioCodecConfig(AUDIO_CODEC_TI_3254, AUDIO_CODEC_16_BIT, 16000, AUDIO_CODEC_STEREO, AUDIO_CODEC_SPEAKER_ALL, AUDIO_CODEC_MIC_ALL); AudioCodecSpeakerVolCtrl(AUDIO_CODEC_TI_3254, AUDIO_CODEC_SPEAKER_ALL, 50); AudioCodecMicVolCtrl(AUDIO_CODEC_TI_3254, AUDIO_CODEC_SPEAKER_ALL, 50); 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 // AudioInit(); // // Initialize the DMA Module // UDMAInit(); if(RecordPlay & I2S_MODE_TX) { UDMAChannelSelect(UDMA_CH5_I2S_TX, NULL); SetupPingPongDMATransferRx(pPlayBuffer); } if(RecordPlay == I2S_MODE_RX_TX) { UDMAChannelSelect(UDMA_CH4_I2S_RX, NULL); SetupPingPongDMATransferTx(pRecordBuffer); } // // Setup the Audio In/Out // lRetVal = AudioSetupDMAMode(DMAPingPongCompleteAppCB_opt, \ CB_EVENT_CONFIG_SZ, RecordPlay); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } AudioCaptureRendererConfigure(AUDIO_CODEC_16_BIT, 16000, AUDIO_CODEC_STEREO, RecordPlay, 1); // // Start Audio Tx/Rx // Audio_Start(RecordPlay); // // 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 lRetVal = -1; // // Board Initialization // BoardInit(); // // uDMA Initialization // UDMAInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); // // Configuring UART // InitTerm(); // // Display banner // DisplayBanner(APPLICATION_NAME); 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 // 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"); // // Asumption is that the device is configured in station mode already // and it is in its default state // lRetVal = sl_Start(0, 0, 0); if (lRetVal < 0 || lRetVal != ROLE_STA) { UART_PRINT("Failed to start the device \n\r"); LOOP_FOREVER(); } UART_PRINT("Device started as STATION \n\r"); UART_PRINT("Connecting to AP: %s ...\r\n",SSID_NAME); // //Connecting to WLAN AP // lRetVal = WlanConnect(); if(lRetVal < 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)); #ifdef USER_INPUT_ENABLE lRetVal = UserInput(); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } #else lRetVal = BsdUdpClient(PORT_NUM); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } lRetVal = BsdUdpServer(PORT_NUM); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } #endif UART_PRINT("Exiting Application ...\n\r"); // // power off the network processor // lRetVal = sl_Stop(SL_STOP_TIMEOUT); while (1) { _SlNonOsMainLoopTask(); } }
//**************************************************************************** // MAIN FUNCTION //**************************************************************************** int main(void) { long lRetVal; char cCmdBuff[20]; signed char cCmd = APP_SLEEP; SlSockAddrIn_t sAddr; SlSockAddrIn_t sLocalAddr; SlSockAddrIn_t sBrdAddr; int iCounter; int iAddrSize; int iSockID; int iStatus; long lLoopCount = 0; short sTestBufLen; struct SlTimeval_t timeVal; // // Board Initialization // BoardInit(); // // uDMA Initialization // UDMAInit(); // // Configure the pinmux settings for the peripherals exercised // Note: pinmux has been modified after the output from pin mux tools // to enable sleep clk for the peripherals exercised // PinMuxConfig(); // // Initialize the platform // platform_init(); // // Initialise the UART terminal // InitTerm(); // // Display banner // DisplayBanner(); // // starting the simplelink // lRetVal = sl_Start(NULL, NULL, NULL); if (lRetVal < 0) { UART_PRINT("Failed to start the device \n\r"); LOOP_FOREVER(); } // // Swtich to STA mode if device is not // SwitchToStaMode(lRetVal); // // set connection policy // sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(0, 0, 0, 0, 0), NULL, 0); // // Set the power management policy of NWP // lRetVal = sl_WlanPolicySet(SL_POLICY_PM, SL_NORMAL_POLICY, NULL, 0); UART_PRINT("Trying to Connect to AP: %s ...\r\n",SSID_NAME); // //Connecting to WLAN AP // lRetVal = WlanConnect(); if(lRetVal < 0) { UART_PRINT("Failed to establish connection w/ an AP \n\r"); LOOP_FOREVER(); } // filling the buffer for (iCounter=0 ; iCounter<BUF_SIZE ; iCounter++) { g_cBsdBuf[iCounter] = (char)(iCounter % 10); } sTestBufLen = BUF_SIZE; //filling the UDP server socket address sLocalAddr.sin_family = SL_AF_INET; sLocalAddr.sin_port = sl_Htons((unsigned short)PORT_NUM); sLocalAddr.sin_addr.s_addr = 0; //filling the UDP server socket address sBrdAddr.sin_family = SL_AF_INET; sBrdAddr.sin_port = sl_Htons((unsigned short)PORT_NUM); sBrdAddr.sin_addr.s_addr = sl_Htonl((unsigned int)g_ulDestinationIp); iAddrSize = sizeof(SlSockAddrIn_t); // creating a UDP socket iSockID = sl_Socket(SL_AF_INET,SL_SOCK_DGRAM, 0); /* setting time out for socket recv */ timeVal.tv_sec = 5; // Seconds timeVal.tv_usec = 0; // Microseconds. 10000 microseconds resolution sl_SetSockOpt(iSockID,SL_SOL_SOCKET,SL_SO_RCVTIMEO, (_u8 *)&timeVal, sizeof(timeVal)); // binding the UDP socket to the UDP server address iStatus = sl_Bind(iSockID, (SlSockAddr_t *)&sLocalAddr, iAddrSize); if( iStatus < 0 ) { // error sl_Close(iSockID); ASSERT_ON_ERROR(iStatus); } // // setting Apps power policy // lp3p0_setup_power_policy(POWER_POLICY_STANDBY); UART_PRINT("enter one of the following command:\n\r"); UART_PRINT("sleep - for putting the system into LPDS mode\n\r"); UART_PRINT(" GPIO 13 and timer(5 sec) are the wk source configured\n\r"); UART_PRINT("recv - for receiving 1000 UDP packets\n\r"); UART_PRINT("send - for broadcasting 1000 UDP packets\n\r"); do{ UART_PRINT("cmd#"); // // get cmd over UART // GetCmd(cCmdBuff, 20); // // parse the command // ParseCmd(cCmdBuff, &cCmd); if(cCmd == APP_SLEEP) { // // set timer and gpio as wake src // set_rtc_as_wk_src(WK_LPDS, LPDS_DUR_SEC, false); set_gpio_as_wk_src(WK_LPDS, GPIO_SRC_WKUP, PRCM_LPDS_FALL_EDGE); cc_idle_task_pm(); } else if(cCmd == APP_RECV) { lLoopCount = 0; /// waits for 1000 packets from a UDP client while (lLoopCount < g_ulPacketCount) { iStatus = sl_RecvFrom(iSockID, g_cBsdBuf, sTestBufLen, 0, ( SlSockAddr_t *)&sAddr, (SlSocklen_t*)&iAddrSize ); if( iStatus < 0 ) { //error break; } lLoopCount++; } UART_PRINT("Recieved %u packets successfully \n\r",lLoopCount); if(lLoopCount != g_ulPacketCount) { if(iStatus == SL_EAGAIN) { UART_PRINT("timed out\n\r"); } else { UART_PRINT("recv error: %d\n\r", iStatus); } } } else if(cCmd == APP_SEND) { lLoopCount = 0; // sending 1000 packets to the UDP server while (lLoopCount < g_ulPacketCount) { // sending packet iStatus = sl_SendTo(iSockID, g_cBsdBuf, sTestBufLen, 0, (SlSockAddr_t *)&sBrdAddr, iAddrSize); if( iStatus <= 0 ) { // error UART_PRINT("send error\n\r"); break; } lLoopCount++; } UART_PRINT("Sent %u packets successfully\n\r",lLoopCount); } }while(FOREVER); }