inline int initTemperatureSensor() { int ret = I2C_IF_Open(I2C_MASTER_MODE_FST); if (ret < 0) { UART_PRINT("i2c failure\r\n"); return ret; } return TMP006DrvOpen(); }
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("Blink - Parse for IoT sample application\r\n"); UART_PRINT("----------------------------------------\r\n"); UART_PRINT("\r\n"); UART_PRINT("[Blink] Board init\r\n"); // start the spawn task short status = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if (status < 0) { UART_PRINT("[Blink] Spawn task failed\r\n"); ERR_PRINT(status); LOOP_FOREVER(); } // initialize the I2C bus status = I2C_IF_Open(I2C_MASTER_MODE_FST); if (status < 0) { UART_PRINT("[Blink] I2C opening error\r\n"); ERR_PRINT(status); LOOP_FOREVER(); } UART_PRINT("[Blink] Device : TI SimpleLink CC3200\r\n"); #ifdef USE_TIRTOS UART_PRINT("[Blink] Operating system : TI-RTOS\r\n"); #endif #ifdef USE_FREERTOS UART_PRINT("[Blink] Operating system : FreeRTOS\r\n"); #endif #ifndef SL_PLATFORM_MULTI_THREADED UART_PRINT("[Blink] Operating system : None\r\n"); #endif }
int main() { #ifndef USE_TIRTOS MAP_IntVTableBaseSet((unsigned long) &g_pfnVectors[0]); #endif MAP_IntEnable(FAULT_SYSTICK); MAP_IntMasterEnable(); PRCMCC3200MCUInit(); /* Console UART init. */ MAP_PRCMPeripheralClkEnable(CONSOLE_UART_PERIPH, PRCM_RUN_MODE_CLK); MAP_PinTypeUART(PIN_55, PIN_MODE_3); /* PIN_55 -> UART0_TX */ MAP_PinTypeUART(PIN_57, PIN_MODE_3); /* PIN_57 -> UART0_RX */ MAP_UARTConfigSetExpClk( CONSOLE_UART, MAP_PRCMPeripheralClockGet(CONSOLE_UART_PERIPH), CONSOLE_BAUD_RATE, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); MAP_UARTFIFOLevelSet(CONSOLE_UART, UART_FIFO_TX1_8, UART_FIFO_RX4_8); MAP_UARTFIFOEnable(CONSOLE_UART); setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(stderr, NULL, _IOLBF, 0); cs_log_set_level(LL_INFO); cs_log_set_file(stdout); LOG(LL_INFO, ("Hello, world!")); MAP_PinTypeI2C(PIN_01, PIN_MODE_1); /* SDA */ MAP_PinTypeI2C(PIN_02, PIN_MODE_1); /* SCL */ I2C_IF_Open(I2C_MASTER_MODE_FST); /* Set up the red LED. Note that amber and green cannot be used as they share * pins with I2C. */ MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK); MAP_PinTypeGPIO(PIN_64, PIN_MODE_0, false); MAP_GPIODirModeSet(GPIOA1_BASE, 0x2, GPIO_DIR_MODE_OUT); GPIO_IF_LedConfigure(LED1); GPIO_IF_LedOn(MCU_RED_LED_GPIO); if (VStartSimpleLinkSpawnTask(8) != 0) { LOG(LL_ERROR, ("Failed to create SL task")); } if (!mg_start_task(MG_TASK_PRIORITY, MG_TASK_STACK_SIZE, mg_init)) { LOG(LL_ERROR, ("Failed to create MG task")); } osi_start(); return 0; }
void launchpad_init(void){ long lRetVal = -1; PinConfigSet(PIN_58, PIN_STRENGTH_2MA | PIN_STRENGTH_4MA, PIN_TYPE_STD_PD); GPIO_IF_LedConfigure(LED1|LED2|LED3); GPIO_IF_LedOff(MCU_ALL_LED_IND); MAP_UtilsDelay(8000000); GPIO_IF_LedOn(MCU_GREEN_LED_GPIO); Report ("Initialize I2C..."); // // I2C Init // lRetVal = I2C_IF_Open(I2C_MASTER_MODE_FST); if(lRetVal < 0) { Report ("Fail!\r\n"); while(1); } Report ("Success\r\n"); }
//**************************************************************************** // 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) { } }
//****************************************************************************** // 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 handling the I2C example //! //! \param None //! //! \return None //! //***************************************************************************** void main() { int iRetVal; char acCmdStore[512]; // // Initialize board configurations // BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); // // Configuring UART // InitTerm(); // // I2C Init // I2C_IF_Open(I2C_MASTER_MODE_FST); // // Display the banner followed by the usage description // DisplayBanner(APP_NAME); DisplayUsage(); while(FOREVER) { // // Provide a prompt for the user to enter a command // DisplayPrompt(); // // Get the user command line // iRetVal = GetCmd(acCmdStore, sizeof(acCmdStore)); if(iRetVal < 0) { // // Error in parsing the command as length is exceeded. // UART_PRINT("Command length exceeded 512 bytes \n\r"); DisplayUsage(); } else if(iRetVal == 0) { // // No input. Just an enter pressed probably. Display a prompt. // } else { // // Parse the user command and try to process it. // iRetVal = ParseNProcessCmd(acCmdStore); if(iRetVal < 0) { UART_PRINT("Error in processing command\n\r"); DisplayUsage(); } } } }
//**************************************************************************** // MAIN FUNCTION //**************************************************************************** void main() { long lRetVal = -1; // // Board Initilization // BoardInit(); // // Configure the pinmux settings for the peripherals exercised // PinMuxConfig(); PinConfigSet(PIN_58,PIN_STRENGTH_2MA|PIN_STRENGTH_4MA,PIN_TYPE_STD_PD); // Initialize Global Variables InitializeAppVariables(); // // UART Init // InitTerm(); DisplayBanner(APP_NAME); // // LED Init // GPIO_IF_LedConfigure(LED1); //Turn Off the LEDs GPIO_IF_LedOff(MCU_RED_LED_GPIO); // // I2C Init // lRetVal = I2C_IF_Open(I2C_MASTER_MODE_FST); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } //Init Temprature Sensor lRetVal = TMP006DrvOpen(); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } //Init Accelerometer Sensor lRetVal = BMA222Open(); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Simplelinkspawntask // lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Create OOB Task // lRetVal = osi_TaskCreate(OOBTask, (signed char*)"OOBTask", \ OSI_STACK_SIZE, NULL, \ OOB_TASK_PRIORITY, NULL ); if(lRetVal < 0) { ERR_PRINT(lRetVal); LOOP_FOREVER(); } // // Start OS Scheduler // osi_start(); while (1) { } }
int main(void) { /* Init board */ BoardInit(); /* Init GPIO */ InitGPIO(); /* Init UART */ MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK); InitTerm(); /* Init I2C */ I2C_IF_Open(I2C_MASTER_MODE_FST); /* Init the internet! */ // http://azug.minpet.unibas.ch/~lukas/bricol/ti_simplelink/resources/swru368.pdf SECTION 10 dhcpParams.lease_time = 1000; dhcpParams.ipv4_addr_start = 0xc0a80102; dhcpParams.ipv4_addr_last = 0xc0a801fe; sl_Start(NULL,NULL,NULL); MAP_UtilsDelay(8000000); // config IP etc ipV4.ipV4 = 0xc0a80101; ipV4.ipV4Mask = 0xFFFFFF00; ipV4.ipV4Gateway = 0xc0a80101; ipV4.ipV4DnsServer = 0xc0a80101; sl_NetCfgSet(SL_IPV4_AP_P2P_GO_STATIC_ENABLE, 1 ,sizeof(SlNetCfgIpV4Args_t), (unsigned char*) &ipV4); sl_WlanSetMode(ROLE_AP); // config SSID sl_WlanSet(SL_WLAN_CFG_AP_ID,WLAN_AP_OPT_SSID, strlen(myssid), (unsigned char*) myssid); sl_Stop(100); sl_Start(NULL,NULL,NULL); // start DHCP server sl_NetAppStop(SL_NET_APP_DHCP_SERVER_ID); sl_NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, outLen,(unsigned char*) &dhcpParams); sl_NetAppStart(SL_NET_APP_DHCP_SERVER_ID); //Stop Internal HTTP Serve long lRetVal = -1; lRetVal = sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID); ASSERT_ON_ERROR( lRetVal); //Start Internal HTTP Server lRetVal = sl_NetAppStart(SL_NET_APP_HTTP_SERVER_ID); ASSERT_ON_ERROR( lRetVal); /* Finished init the internet! */ setRLED(); /* Wait for operator */ while(!readDIP1()); clearRLED(); /* Init IMU (alongside timers and interrupt */ imu_setup(); /* Init odometers */ odometer_setup(); set_controller_parameters(kp, ki, kd); set__odo_controller_parameters(kp_odo, ki_odo, kd_odo); /* Init motors (alongside motor GPIO, timers and interrupt */ motorSetup(); controller_setup(); odometer_controller_setup(); // MUST be the last init called! while(1) { _SlNonOsMainLoopTask(); } }
//****************************************************************************** // 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(); }