void BoardInitMcu( void ) { if( McuInitialized == false ) { // We use IRQ priority group 4 for the entire project // When setting the IRQ, only the preemption priority is used NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); // Disable Systick SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; // Systick IRQ off SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk; // Clear SysTick Exception pending flag AdcInit( &Adc, POTI ); SpiInit( &SX1272.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); SX1272IoInit( ); #if( LOW_POWER_MODE_ENABLE ) TimerSetLowPowerEnable( true ); #else TimerSetLowPowerEnable( false ); #endif BoardUnusedIoInit( ); if( TimerGetLowPowerEnable( ) == true ) { RtcInit( ); } else { TimerHwInit( ); } McuInitialized = true; } }
void BoardInitMcu( void ) { Gpio_t ioPin; if( McuInitialized == false ) { HAL_Init( ); // LEDs GpioInit( &Led1, LED_1, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 1 ); GpioInit( &Led2, LED_2, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 1 ); GpioInit( &Led3, LED_3, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, Led3Status ); SystemClockConfig( ); GpioInit( &ioPin, UART_RX, PIN_INPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); if( GpioRead( &ioPin ) == 1 ) // Debug Mode { UsbIsConnected = true; FifoInit( &Uart1.FifoTx, UartTxBuffer, UART_FIFO_TX_SIZE ); FifoInit( &Uart1.FifoRx, UartRxBuffer, UART_FIFO_RX_SIZE ); // Configure your terminal for 8 Bits data (7 data bit + 1 parity bit), no parity and no flow ctrl UartInit( &Uart1, UART_1, UART_TX, UART_RX ); UartConfig( &Uart1, RX_TX, 115200, UART_8_BIT, UART_1_STOP_BIT, NO_PARITY, NO_FLOW_CTRL ); } else { UsbIsConnected = false; UartDeInit( &Uart1 ); } RtcInit( ); BoardUnusedIoInit( ); } else { SystemClockReConfig( ); } I2cInit( &I2c, I2C_SCL, I2C_SDA ); AdcInit( &Adc, BAT_LEVEL_PIN ); SpiInit( &SX1272.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); SX1272IoInit( ); if( McuInitialized == false ) { McuInitialized = true; if( GetBoardPowerSource( ) == BATTERY_POWER ) { CalibrateSystemWakeupTime( ); } } }
void BoardInitMcu( void ) { if( McuInitialized == false ) { // We use IRQ priority group 4 for the entire project // When setting the IRQ, only the preemption priority is used NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); // Disable Systick // SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; // Systick IRQ off // SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk; // Clear SysTick Exception pending flag /* Setup SysTick Timer for 1 ms interrupts (not too often to save power) */ if (SysTick_Config(SystemCoreClock / 1000)) { /* Capture error */ while (1); } I2cInit( &I2c, I2C_SCL, I2C_SDA ); SpiInit( &SX1276.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); SX1276IoInit( ); #if defined( USE_DEBUG_PINS ) GpioInit( &DbgPin1, J1_1, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin2, J1_2, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin3, J1_3, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin4, J1_4, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); #endif BoardInitPeriph( ); #if( LOW_POWER_MODE_ENABLE ) TimerSetLowPowerEnable( true ); #else TimerSetLowPowerEnable( false ); #endif BoardUnusedIoInit( ); if( TimerGetLowPowerEnable( ) == true ) { RtcInit( ); } else { TimerHwInit( ); } McuInitialized = true; } }
void BoardInitMcu( void ) { if ( McuInitialized == false ) { /* Initialize low level components */ low_level_init(); /*! SPI channel to be used by Semtech SX1276 */ #if defined(SX1276_BOARD_EMBED) SpiInit(&SX1276.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC); SX1276IoInit(); #endif #if defined (USE_USB_CDC) UartInit( &UartUsb, UART_USB_CDC, NC, NC ); UartConfig( &UartUsb, RX_TX, 115200, UART_8_BIT, UART_1_STOP_BIT, NO_PARITY, NO_FLOW_CTRL ); TimerSetLowPowerEnable(false); #elif defined(DEBUG) #if defined(USE_SHELL) Shell_Init(); #else #if !defined(USE_CUSTOM_UART_HAL) FifoInit(&Uart1.FifoRx, DbgRxBuffer, DBG_FIFO_RX_SIZE); FifoInit(&Uart1.FifoTx, DbgTxBuffer, DBG_FIFO_TX_SIZE); #endif UartInit(&Uart1, UART_1, UART1_TX, UART1_RX); UartConfig(&Uart1, RX_TX, 115200, UART_8_BIT, UART_1_STOP_BIT, NO_PARITY, NO_FLOW_CTRL); #endif DbgConsole_Init(&Uart1); TimerSetLowPowerEnable(false); #elif( LOW_POWER_MODE_ENABLE ) TimerSetLowPowerEnable(true); #else TimerSetLowPowerEnable(false); #endif BoardUnusedIoInit(); #if !defined(USE_FREE_RTOS) if ( TimerGetLowPowerEnable() == true ) { RtcInit(); } else { TimerHwInit(); } #endif /* USE_FREE_RTOS */ McuInitialized = true; } }
int main(void) { RtcInit(); PortGroup *const port = SaLGetPort(pin); uint32_t pin_mask = (1UL << (pin % 32)); volatile uint32_t microseconds = 0; /* Replace with your application code */ while (1) { counts++; microseconds = micros(); } }
int main(void) { PreSetupHardware(); UartDebugInit(); RtcInit(); #if defined(__SPKEAER__) SoundControlInit(); #endif XfsInit(); GSMInit(); #if defined(__LED__) DisplayInit(); SevenSegLedInit(); SHT10TestInit(); #endif vTaskStartScheduler(); return 0; }
void BoardInitMcu( void ) { if( McuInitialized == false ) { #if defined( USE_BOOTLOADER ) // Set the Vector Table base location at 0x3000 NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x3000 ); #endif // We use IRQ priority group 4 for the entire project // When setting the IRQ, only the preemption priority is used NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); // Disable Systick SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; // Systick IRQ off SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk; // Clear SysTick Exception pending flag I2cInit( &I2c, I2C_SCL, I2C_SDA ); AdcInit( &Adc, BAT_LEVEL ); SpiInit( &SX1272.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); SX1272IoInit( ); #if defined( USE_DEBUG_PINS ) GpioInit( &DbgPin1, CON_EXT_1, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin2, CON_EXT_3, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin3, CON_EXT_7, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin4, CON_EXT_9, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); #endif BoardUnusedIoInit( ); #if defined( USE_USB_CDC ) UsbMcuInit( ); UartInit( &UartUsb, UART_USB_CDC, NC, NC ); UartConfig( &UartUsb, RX_TX, 115200, UART_8_BIT, UART_1_STOP_BIT, NO_PARITY, NO_FLOW_CTRL ); #endif #ifdef LOW_POWER_MODE_ENABLE RtcInit( ); #else TimerHwInit( ); #endif McuInitialized = true; } }
void BoardInitMcu( void ) { if( McuInitialized == false ) { #if defined( USE_BOOTLOADER ) // Set the Vector Table base location at 0x3000 SCB->VTOR = FLASH_BASE | 0x3000; #endif HAL_Init( ); SystemClockConfig( ); #if defined( USE_USB_CDC ) UartInit( &UartUsb, UART_USB_CDC, NC, NC ); UartConfig( &UartUsb, RX_TX, 115200, UART_8_BIT, UART_1_STOP_BIT, NO_PARITY, NO_FLOW_CTRL ); DelayMs( 1000 ); // 1000 ms for Usb initialization #endif RtcInit( ); BoardUnusedIoInit( ); I2cInit( &I2c, I2C_1, I2C_SCL, I2C_SDA ); } else { SystemClockReConfig( ); } AdcInit( &Adc, BAT_LEVEL_PIN ); SpiInit( &SX1272.Spi, SPI_1, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); SX1272IoInit( ); if( McuInitialized == false ) { McuInitialized = true; if( GetBoardPowerSource( ) == BATTERY_POWER ) { CalibrateSystemWakeupTime( ); } } }
void BoardInitMcu( void ) { if( McuInitialized == false ) { // We use IRQ priority group 4 for the entire project // When setting the IRQ, only the preemption priority is used NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); // Disable Systick SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; // Systick IRQ off SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk; // Clear SysTick Exception pending flag I2cInit( &I2c, I2C_SCL, I2C_SDA ); SpiInit( &SX1272.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); SX1272IoInit( ); #if defined( USE_DEBUG_PINS ) GpioInit( &DbgPin1, J5_1, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin2, J5_2, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin3, J5_3, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); GpioInit( &DbgPin4, J5_4, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, 0 ); #endif BoardInitPeriph( ); #if( LOW_POWER_MODE_ENABLE ) TimerSetLowPowerEnable( true ); #else TimerSetLowPowerEnable( false ); #endif BoardUnusedIoInit( ); if( TimerGetLowPowerEnable( ) == true ) { RtcInit( ); } else { TimerHwInit( ); } McuInitialized = true; } }
/** * @brief Initializes the Global MSP. * @param None * @retval None */ void HAL_MspInit(void) { /* NOTE : This function is generated automatically by STM32CubeMX and eventually modified by the user */ SystemClock_Config(); //initiate LEDs HalLedInit(); //initiate KEY //KEY_Init(); HalKeyInit( ); //initiate OLED OLED_Init(); //initiate SPI (for sx1276/1279) SPI1_Init(); SX1276IoInit( ); //sx1279 active crystal initiate and power on SX1276Q1CtrlInit(); //initiate 3-wire UART UART_Init(); #if defined( LOW_POWER_MODE_ENABLE ) TimerSetLowPowerEnable( true ); //initiate RTC and stop mode RtcInit( ); #else TimerSetLowPowerEnable( false ); TimerHwInit( ); #endif }
void BoardInitMcu( void ) { if( McuInitialized == false ) { /* Chip errata */ CHIP_Init(); CMU_OscillatorEnable(cmuOsc_HFXO, true, true); CMU_ClockSelectSet(cmuClock_HF,cmuSelect_HFXO); /* Enable clock for HF peripherals */ CMU_ClockEnable(cmuClock_HFPER, true); CMU_ClockEnable(cmuClock_GPIO, true); GpioInit( &Led1, LED_1, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, LED_1_ON_STATE ); GpioInit( &Led2, LED_2, PIN_OUTPUT, PIN_PUSH_PULL, PIN_NO_PULL, LED_2_ON_STATE ); #ifdef USE_I2C I2cInit( &I2c, I2C_SCL, I2C_SDA ); #endif SX1272IoInit( ); SpiInit( &SX1272.Spi, RADIO_MOSI, RADIO_MISO, RADIO_SCLK, NC ); BoardUnusedIoInit( ); #ifdef LOW_POWER_MODE_ENABLE #error LOW_POWER_MODE_ENABLE not supported RtcInit( ); #else TimerHwInit( ); #endif Led_1_Off(); Led_2_Off(); McuInitialized = true; } }
int main(void) { MainInit(); I2C1init(); RtcInit(); LcdInit(); DataLogInit(); StringInit(); Mct485Init(); FieldInit(); Ads1115Init(); Ads1244Init(); USBInit(); RtuInit(); AdcInit(); TC74Init(); // enable multi-vector interrupts INTEnableSystemMultiVectoredInt(); MainDelay(50); DataLogDateTime(DLOG_SFC_POWERUP); // init param after interrupts are enabled ParamInit(); // wait to init desiccant until after ParamInit DesiccantInit(); string[0].mct[0].chan[4] = 0x7FFF; // // Begin Main Loop // for (;;) { if (test == 1) { test = 0; FieldNewState((FIELD_STATE_m)t1); } USBUpdate(); // called as often as possible //sysTickEvent every ms if (sysTickEvent) { sysTickEvent = 0; sysTicks++; UsbTimeoutUpdate(); LcdUpdate(); // fill time before dropping LCD_E if (sysTicks >= 1000) { sysSec++; sysTicks = 0; mPORTDToggleBits(PD_LED_HEARTBEAT); // These Updates are // called once a second //TODO if any of these are long, we could split them on separate milliseconds. DesiccantUpdate(); AdcUpdate(); TC74Update(); }// end 1 Hz else if (sysTicks == 250) { mPORTDToggleBits(PD_LED_HEARTBEAT); } else if (sysTicks == 500) { mPORTDToggleBits(PD_LED_HEARTBEAT); } else if (sysTicks == 750) { mPORTDToggleBits(PD_LED_HEARTBEAT); } // Complete LcdUpdate() by dropping LCD_E) PORTClearBits(IOPORT_G, PG_LCD_E); // These Updates called once each millisecond RtcUpdate(); I2C1update(); StringUpdate(); Mct485Update(); FieldUpdate(); RtuUpdate(); DessicantFanPWMupdate(); } // if (sysTickEvent) } // for (;;) } // main()
void my_task_Startup() { DebugManager(1, 0x1F, 0x180000, 0x40000, 0x1C0000); dmstart(); dmProcInit(); #ifdef ENABLE_MASSIVE_DEBUG // the 2nd level is 32 flags for debug classes // the 3rd arg is log level, 0 == full debug, >0 == less debug dmSetStoreLevel(hDbgMgr, 0xFF, 0); dmSetPrintLevel(hDbgMgr, 0xFF, 0); #endif initialize(); sub_FFAFE5BC(); SetAssert(); EventProcedureServiceInit(); ShutDownProcInit(); Install3VMemory(0xF8000000); RomManagerInit(); CreateParamPubInstance(); PropertyServiceInit(); ErrorNumberListInit(); FatalErrorsProcInit(); RegisterISRs_OCH(); BlockUntilAfterTimeoutProcInit(50); sub_FFB07740(0x10, 8, 0x1BBC); ResourceNameServiceInit(); MemorySuite(0); sysClockRateSet_100(3); sub_FFB2BD6C(); InitializeSerialIO(); RtcInit(0x386D4380); AdjDefectsInit(); CameraAdjsInit(); SetAssertProc(AssertPrepare, 0); my_InitializeIntercom(); // InitializeIntercom(); AfeGainCmosParamInit(); EngineInit(); EDmacPriorityManager(); EngineResourceInit(); PowerMgrInit(0); ClockInit(1); RegisterISR_CAPREADY(); FaceSensorInit(); RemDrvInit(); ActSweepInit(); LcdInit(); DisplayInit1(); DisplayInit2(); PowerSaveProcInit(); sub_FFA03B0C(); sub_FFA05114(); InitializeImagePlayDriver(); LensNameTblInit(); LensPOTblInit(); FlyingInit(); CaptureInit(); BathtubSaturateInit(); Module_CaptureImagePass(); ClearSomeCapMem(); ColorAdjustmentsInit(); Module_PreDarkPassInit(); LoadSystemInfo(); SharedBufferInit(0x10800000, 0x18000000, 0xEE0000, 0xEE0000); FileCacheInit(); PackMemInit(); ImagePropInit(); DigPropInit(); ShootMainInit(); OlcInfoInit(); RegisterISR_EMERGENCY_CARDDOOR(); my_MainCtrlInit(); CaptureSemaphoreInit(); VShadingInit(); Module_CaptureDarkPassInit(); Module_DarkSubtractionPassInit(); BathtubInit(); Module_BathtubCorrectPassInit(); Module_VObIntegPassInit(); SetProjectionInit(); Module_DefectsDetectPassInit(); DefsInit(); WbDetectionInit(); ObInit(); Module_WbDetectionPassInit(); DefsProcInit(); Module_ObAreaCopyPassInit(); Module_AdditionVTwoLinePassInit(); VShadingProcInit(); Module_VShadingCorrectPassInit(); sub_FFA24838(); HuffmanInit(); RawToJpegPass_L_Init(); RawToJpegPass_M2_Init(); RawToJpegPass_S_Init(); YcToJpegLargeFastInit(); YcToJpegM2FastInit(); YcToJpegSFastInit(); RawToLosslessInit(); Module_YcToTwainInit(); RawToYcPass_S_Init(); RawToYPackPass_S_Init(); DvlpInit(); DecodeJpegPassInit(); HistPassInit(); RectangleColorPassInit(); RectangleCopyPassInit(); ResizeYuvPassInit(); sub_FFA35354(); LpfPassInit(); EncodeJpegPassInit(); AdjRgbGainInit(); LuckyInit(); SysInfoProcInit(); TablesInit(); ColorInit(); CtrlManRecursiveLock(); CtrlSrvInit(0x19); LangConInit(); sub_FF926E40(); CreateDispSwControlPubInstance(); CreateMemoryManagerPubInstance(); my_GUIInit(); //GUIInit(); GUIApiCalls(); InitializeImagePlayer(); ColorBarProcsInit(); LcdAdjustProcsInit(); sub_FFB29348(); CMOSParamInit(); CameraSettingsInit(); BootDiskProcsInit(); DDDInit(); TFTInit(); RegisterResourceName(hResourceName, "USR ROOT DEVICE HANDLE", 0x7B); RegisterResource_env(0xC02200B8, "U2VBUS"); RegisterResource_env(1, "USBC20 VBUS SUPPORT"); RegisterResource_env(0x14, "DEVICESPEED"); USBC20_Init(); USBC20_USBIF_Init(); USBC20_BUFCON_Init(); USBC20_CLK_Init(); USBC20_HDMAC_Init(); DCPClassFunctionsInit(); USBDriverInit(); RapiSwitcherInit(); DCPClassInit(); RAPITransportUSBInit(); PTPRespondInit(); PTPFrameworkInit(); StartupPtpResponder(); RapiTransportManagerInit(); DCPClassInit(); EventProcServerInit(); sub_FFA5D8A0(); DCPInit(); SesnMngrInit(); MemMngrInit(); InitializeRapiTransportManager(); PrintInit(); sub_FF95EC54(); SomePrintInit(); sub_FF9EB94C(); InitializeUSBDriver(); TransMemoryInit(); InitializeComCtrl(); FactoryModeInit(); DP_Init(0, 0x1B, 0, 0); return_0(); sub_FF98CF4C(); EdLedProcsInit(); CallBacksInit(); RegistNotifyConnectDT(); DPOF_Initialize(); MpuMonInit(); StartConsole(); }
/*#####################################################*/ bool board_init() { core_init(); timer_init(); RtcInit(); /*-----------------------------------------------------*/ /* Set up the Uart 0 like debug interface with RxBuff = 256, TxBuff = 256, 115200b/s*/ Uart[0] = new_(new_uart); Uart[0]->TxPin = Uart0_Tx_PinMux_E16; Uart[0]->RxPin = Uart0_Rx_PinMux_E15; Uart[0]->BaudRate = 115200; Uart[0]->RxBuffSize = 256; Uart[0]->TxBuffSize = 256; Uart[0]->rxFifoTrigLevel = 1; Uart[0]->txFifoTrigLevel = 1; Uart[0]->UartNr = 0; uart_open(Uart[0]); DebugCom = Uart[0]; /*-----------------------------------------------------*/ LED[0] = gpio_assign(1, 21, GPIO_DIR_OUTPUT, false); LED[1] = gpio_assign(1, 22, GPIO_DIR_OUTPUT, false); LED[2] = gpio_assign(1, 23, GPIO_DIR_OUTPUT, false); LED[3] = gpio_assign(1, 24, GPIO_DIR_OUTPUT, false); /*-----------------------------------------------------*/ /* Display board message*/ #if defined(BOARD_MESSAGE) UARTprintf(DebugCom, "Use %s Board.\n\r", BOARD_MESSAGE); #endif /*-----------------------------------------------------*/ /* Set up the Twi 0 to communicate with PMIC and the Onboard serial EEprom memory */ UARTPuts(DebugCom, "Setup TWI 0 with RxBuff = 258, TxBuff = 258....." , -1); TWI[0] = new_(new_twi); TWI[0]->SdaPin = Twi0_Sda_PinMux_C17; TWI[0]->SclPin = Twi0_Scl_PinMux_C16; TWI[0]->BaudRate = 100000; TWI[0]->TwiNr = 0; TWI[0]->Priority = 0; TWI[0]->UseInterrupt = TRUE; TWI[0]->RxBuffSize = 258; TWI[0]->TxBuffSize = 258; twi_open(TWI[0]); UARTPuts(DebugCom, "OK.\n\r" , -1); /*-----------------------------------------------------*/ if(!is_beaglebone()) return false; /*-----------------------------------------------------*/ /* Set up the Twi 1 to communicate with PMIC and the Onboard serial EEprom memory */ UARTPuts(DebugCom, "Setup TWI 1 with RxBuff = 258, TxBuff = 258....." , -1); TWI[1] = new_(new_twi); TWI[1]->SdaPin = Twi1_Sda_PinMux_B16; TWI[1]->SclPin = Twi1_Scl_PinMux_A16; TWI[1]->BaudRate = 100000; TWI[1]->TwiNr = 1; TWI[1]->Priority = 0; TWI[1]->UseInterrupt = TRUE; TWI[1]->RxBuffSize = 258; TWI[1]->TxBuffSize = 258; twi_open(TWI[1]); UARTPuts(DebugCom, "OK.\n\r" , -1); /*-----------------------------------------------------*/ /* Set up the Twi 2 to communicate with PMIC and the Onboard serial EEprom memory */ UARTPuts(DebugCom, "Setup TWI 2 with RxBuff = 258, TxBuff = 258....." , -1); TWI[2] = new_(new_twi); TWI[2]->SdaPin = Twi2_Sda_PinMux_D18; TWI[2]->SclPin = Twi2_Scl_PinMux_D17; TWI[2]->BaudRate = 100000; TWI[2]->TwiNr = 2; TWI[2]->Priority = 0; TWI[2]->UseInterrupt = TRUE; TWI[2]->RxBuffSize = 258; TWI[2]->TxBuffSize = 258; twi_open(TWI[2]); UARTPuts(DebugCom, "OK.\n\r" , -1); /*-----------------------------------------------------*/ beaglebone_detect_extension_boards(); /*-----------------------------------------------------*/ #if USE_ADXL345 ADXL345_1 = new_(new_adxl345); ADXL345_1->MasterSlaveAddr = ADXL345_SLAVE_ADDR_ALT_0; ADXL345_1->TwiStruct = TWI[2]; ADXL345_1->Calibration_X = -14; ADXL345_1->Calibration_Y = 11; ADXL345_1->Calibration_Z = 24; ADXL345_1->FilterBuffSize = 4; if(adxl345_init(ADXL345_1)) { UARTPuts(DebugCom, "ADXL345 detected on TWI2.\n\r" , -1); } else { if(ADXL345_1) free(ADXL345_1); UARTPuts(DebugCom, "ADXL345 not detected.\n\r" , -1); } #endif /*-----------------------------------------------------*/ UARTPuts(DebugCom, "Init MMCSD0 .......", -1); sdCtrl[0].SdNr = 0; mmcsd_init(&sdCtrl[0], 0, 6, LED[0]); UARTPuts(DebugCom, "OK.\n\r", -1); mmcsd_idle(&sdCtrl[0]); /*-----------------------------------------------------*/ eMMC_Res = gpio_assign(1, 20, GPIO_DIR_OUTPUT, false); gpio_out(eMMC_Res, 0); Sysdelay(10); gpio_out(eMMC_Res, 1); UARTPuts(DebugCom, "Init MMCSD1 .......", -1); sdCtrl[1].SdNr = 1; mmcsd_init(&sdCtrl[1], -1, -1, LED[0]); UARTPuts(DebugCom, "OK.\n\r", -1); mmcsd_idle(&sdCtrl[1]); /*-----------------------------------------------------*/ #ifdef usb_1_msc UARTPuts(DebugCom, "Init USBMSC1 Host.......", -1); usb_msc_host_init(1, LED[2]); UARTPuts(DebugCom, "OK.\n\r", -1); usb_msc_host_idle(1); #elif defined( usb_1_mouse ) && !defined( touch ) /*-----------------------------------------------------*/ UARTPuts(DebugCom, "Init USBMOUSE1 Host.......", -1); usb_mouse_host_init(1); UARTPuts(DebugCom, "OK.\n\r", -1); #endif /*-----------------------------------------------------*/ #if defined( usb_0_dev_msc ) && defined ( BridgeUsbDev0ToMmcSd0) UARTPuts(DebugCom, "Bridge USBMSC0 Dev for MMCSD0 Interface.......", -1); drv_rw_func.DriveStruct = &sdCtrl[0]; drv_rw_func.drv_ioctl_func = mmcsd_ioctl; drv_rw_func.drv_r_func = mmcsd_read; drv_rw_func.drv_w_func = mmcsd_write; usb_msc_dev_init(0); UARTPuts(DebugCom, "OK.\n\r", -1); /*-----------------------------------------------------*/ #elif defined( usb_0_dev_msc ) && defined ( BridgeUsbDev0ToMmcSd1) UARTPuts(DebugCom, "Bridge USBMSC0 Dev for MMCSD1 Interface.......", -1); drv_rw_func.DriveStruct = &sdCtrl[1]; drv_rw_func.drv_ioctl_func = mmcsd_ioctl; drv_rw_func.drv_r_func = mmcsd_read; drv_rw_func.drv_w_func = mmcsd_write; usb_msc_dev_init(0); UARTPuts(DebugCom, "OK.\n\r", -1); /*-----------------------------------------------------*/ #elif defined( usb_0_dev_msc ) && defined ( BridgeUsbDev0ToUsbHost1) && defined(usb_1_msc) && !defined(usb_1_mouse) extern unsigned int g_ulMSCInstance0Usb1;//UsbMsc driver UARTPuts(DebugCom, "Bridge USBMSC0 Dev for USBMSC1Host Interface.......", -1); drv_rw_func.DriveStruct = (void *)g_ulMSCInstance0Usb1; drv_rw_func.drv_ioctl_func = usb_msc_host_ioctl; drv_rw_func.drv_r_func = usb_msc_host_read; drv_rw_func.drv_w_func = usb_msc_host_write; usb_msc_dev_init(0); UARTPuts(DebugCom, "OK.\n\r", -1); #endif /*-----------------------------------------------------*/ #ifdef lcd TouchScreen = new_(new_touchscreen); TouchScreen->TwiStruct = TWI[1]; #endif bool LCD3_Cape_Detected = false; if(Board1ConfigData) if(!memcmp(Board1ConfigData + 4, "A0BeagleBone LCD3 CAPE", 22)) LCD3_Cape_Detected = true; if(Board2ConfigData) if(!memcmp(Board2ConfigData + 4, "A0BeagleBone LCD3 CAPE", 22)) LCD3_Cape_Detected = true; if(Board3ConfigData) if(!memcmp(Board3ConfigData + 4, "A0BeagleBone LCD3 CAPE", 22)) LCD3_Cape_Detected = true; if(Board4ConfigData) if(!memcmp(Board4ConfigData + 4, "A0BeagleBone LCD3 CAPE", 22)) LCD3_Cape_Detected = true; if(LCD3_Cape_Detected) { /*-----------------------------------------------------*/ HARDBTN[0] = gpio_assign(1, 16, GPIO_DIR_INPUT, false); HARDBTN[1] = gpio_assign(1, 17, GPIO_DIR_INPUT, false); HARDBTN[2] = gpio_assign(3, 19, GPIO_DIR_INPUT, false); HARDBTN[3] = gpio_assign(1, 28, GPIO_DIR_INPUT, false); HARDBTN[4] = gpio_assign(0, 7, GPIO_DIR_INPUT, false); /*-----------------------------------------------------*/ LED[4] = gpio_assign(1, 28, GPIO_DIR_OUTPUT, false); LED[5] = gpio_assign(1, 18, GPIO_DIR_OUTPUT, false); /*-----------------------------------------------------*/ #ifdef lcd ScreenBuff = new_(new_screen); ScreenBuff->raster_timings = &lcd_S035Q01_beaglebone_exp; ScreenBuff->BackLightLevel = 60; ScreenBuff->PmicTwiModuleStruct = TWI[0]; screen_init(ScreenBuff); UARTprintf(DebugCom, "LCD display initialize successful for %dx%d resolution, %d Bit bus.\n\r" , ScreenBuff->raster_timings->X, ScreenBuff->raster_timings->Y, ScreenBuff->raster_timings->bus_size); TouchScreen->screen_max_x = (double)ScreenBuff->raster_timings->X; TouchScreen->screen_max_y = (double)ScreenBuff->raster_timings->Y; TouchScreen->pDisplay = ScreenBuff; InitTouchScreen(TouchScreen); UARTPuts(DebugCom, "Init calibration of LCD resistive touch screen....." , -1); TouchCalibrate(TouchScreen, ScreenBuff); UARTPuts(DebugCom, "OK.\n\r" , -1); put_rectangle(ScreenBuff, 0, 0, ScreenBuff->raster_timings->X, ScreenBuff->raster_timings->Y, true, controls_color.Scren); box_cache_clean(ScreenBuff, 0, 0, ScreenBuff->raster_timings->X, ScreenBuff->raster_timings->Y); #endif } else { #ifdef lcd if(ft5x06_init(TouchScreen, 0, 30)) { UARTPuts(DebugCom, "Capacitive touch screen detected and set up successful.\n\r" , -1); #endif UARTPuts(DebugCom, "I suppose that is BeagleBone Multimedia cape from Chipsee.\n\r" , -1); /*-----------------------------------------------------*/ HARDBTN[0] = gpio_assign(1, 19, GPIO_DIR_INPUT, false); HARDBTN[1] = gpio_assign(1, 16, GPIO_DIR_INPUT, false); HARDBTN[2] = gpio_assign(1, 17, GPIO_DIR_INPUT, false); HARDBTN[3] = gpio_assign(0, 7, GPIO_DIR_INPUT, false); //HARDBTN[4] = gpio_assign(1, 3, GPIO_DIR_INPUT, false); If you use BBB this pin is used by the DAT3 of eMMC onboard memory(if you want to use this pin you will use the eMMC in 1 bit data bus mode). /*-----------------------------------------------------*/ #ifdef lcd ScreenBuff = new_(new_screen); ScreenBuff->raster_timings = &lcd_AT070TN92_beaglebone_exp; ScreenBuff->BackLightPort = 1; ScreenBuff->BackLightPin = 18; screen_init(ScreenBuff); TouchScreen->screen_max_x = ScreenBuff->raster_timings->X; TouchScreen->screen_max_y = ScreenBuff->raster_timings->Y; TouchScreen->pDisplay = ScreenBuff; UARTprintf(DebugCom, "LCD display initialize successful for %dx%d resolution, %d Bit bus.\n\r" , ScreenBuff->raster_timings->X, ScreenBuff->raster_timings->Y, ScreenBuff->raster_timings->bus_size); put_rectangle(ScreenBuff, 0, 0, ScreenBuff->raster_timings->X, ScreenBuff->raster_timings->Y, true, controls_color.Scren); box_cache_clean(ScreenBuff, 0, 0, ScreenBuff->raster_timings->X, ScreenBuff->raster_timings->Y); backlight_on(ScreenBuff); } else { //UARTPuts(DebugCom, "No display detected.\n\r" , -1); //free_touchscreen(TouchScreen); UARTPuts(DebugCom, "I suppose that is BeagleBone Multimedia cape from Chipsee.\n\r" , -1); /*-----------------------------------------------------*/ HARDBTN[0] = gpio_assign(1, 19, GPIO_DIR_INPUT, false); HARDBTN[1] = gpio_assign(1, 16, GPIO_DIR_INPUT, false); HARDBTN[2] = gpio_assign(1, 17, GPIO_DIR_INPUT, false); HARDBTN[3] = gpio_assign(0, 7, GPIO_DIR_INPUT, false); //HARDBTN[4] = gpio_assign(1, 3, GPIO_DIR_INPUT, false); /*-----------------------------------------------------*/ ScreenBuff = new_(new_screen); ScreenBuff->raster_timings = &HDMI_DISPLAY_MODE_STRUCT; ScreenBuff->BackLightPort = 1; ScreenBuff->BackLightPin = 18; screen_init(ScreenBuff); #ifdef touch TouchScreen->screen_max_x = ScreenBuff->raster_timings->X; TouchScreen->screen_max_y = ScreenBuff->raster_timings->Y; TouchScreen->pDisplay = ScreenBuff; InitTouchScreen(TouchScreen); UARTPuts(DebugCom, "Init calibration of LCD resistive touch screen....." , -1); TouchCalibrate(TouchScreen, ScreenBuff); UARTPuts(DebugCom, "OK.\n\r" , -1); #endif UARTprintf(DebugCom, "LCD display initialize successful for %dx%d resolution, %d Bit bus.\n\r" , ScreenBuff->raster_timings->X, ScreenBuff->raster_timings->Y, ScreenBuff->raster_timings->bus_size); put_rectangle(ScreenBuff, 0, 0, ScreenBuff->raster_timings->X, ScreenBuff->raster_timings->Y, true, controls_color.Scren); box_cache_clean(ScreenBuff, 0, 0, ScreenBuff->raster_timings->X, ScreenBuff->raster_timings->Y); backlight_on(ScreenBuff); } #endif } return true; }
/* ** Main function. The application starts here. */ int main(void) { unsigned char rxByte; unsigned int value = (unsigned int)E_FAIL; #ifdef __TMS470__ /* Relocate the required section to internal RAM */ memcpy((void *)(&relocstart), (const void *)(&iram_start), (unsigned int)(&iram_size)); #elif defined(__IAR_SYSTEMS_ICC__) #pragma section = "CodeRelocOverlay" #pragma section = "DataRelocOverlay" #pragma section = "DataOverlayBlk" #pragma section = "CodeOverlayBlk" char* srcAddr = (__section_begin("CodeRelocOverlay")); char* endAddr = (__section_end("DataRelocOverlay")); memcpy((void *)(__section_begin("CodeRelocOverlay")), (const void *)(__section_begin("CodeOverlayBlk")), endAddr - srcAddr); #else memcpy((void *)&(relocstart), (const void *)&(iram_start), (unsigned int)(((&(relocend)) - (&(relocstart))) * (sizeof(unsigned int)))); #endif MMUConfigAndEnable(); /* Enable Instruction Cache */ CacheEnable(CACHE_ALL); PeripheralsSetUp(); /* Initialize the ARM Interrupt Controller */ IntAINTCInit(); /* Register the ISRs */ Timer2IntRegister(); Timer4IntRegister(); EnetIntRegister(); RtcIntRegister(); CM3IntRegister(); HSMMCSDIntRegister(); IntRegister(127, dummyIsr); IntMasterIRQEnable(); pageIndex = 0; prevAction = 0; /* Enable system interrupts */ IntSystemEnable(SYS_INT_RTCINT); IntPrioritySet(SYS_INT_RTCINT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_3PGSWTXINT0); IntPrioritySet(SYS_INT_3PGSWTXINT0, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_3PGSWRXINT0); IntPrioritySet(SYS_INT_3PGSWRXINT0, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_TINT2); IntPrioritySet(SYS_INT_TINT2, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_TINT4); IntPrioritySet(SYS_INT_TINT4, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_MMCSD0INT); IntPrioritySet(SYS_INT_MMCSD0INT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_EDMACOMPINT); IntPrioritySet(SYS_INT_EDMACOMPINT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntPrioritySet(SYS_INT_M3_TXEV, 0, AINTC_HOSTINT_ROUTE_IRQ ); IntSystemEnable(SYS_INT_M3_TXEV); IntSystemEnable(127); IntPrioritySet(127, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_UART0INT); IntPrioritySet(SYS_INT_UART0INT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntRegister(SYS_INT_UART0INT, uartIsr); /* GPIO interrupts */ IntSystemEnable(SYS_INT_GPIOINT0A); IntPrioritySet(SYS_INT_GPIOINT0A, 0, AINTC_HOSTINT_ROUTE_IRQ); IntRegister(SYS_INT_GPIOINT0A, gpioIsr); IntSystemEnable(SYS_INT_GPIOINT0B); IntPrioritySet(SYS_INT_GPIOINT0B, 0, AINTC_HOSTINT_ROUTE_IRQ); IntRegister(SYS_INT_GPIOINT0B, gpioIsr); BoardInfoInit(); deviceVersion = DeviceVersionGet(); CM3EventsClear(); CM3LoadAndRun(); waitForM3Txevent(); /* Initialize console for communication with the Host Machine */ ConsoleUtilsInit(); /* ** Select the console type based on compile time check ** Note: This example is not fully complaint to semihosting. It is ** recommended to use Uart console interface only. */ ConsoleUtilsSetType(CONSOLE_UART); /* Print Board and SoC information on console */ ConsoleUtilsPrintf("\n\r Board Name : %s", BoardNameGet()); ConsoleUtilsPrintf("\n\r Board Version : %s", BoardVersionGet()); ConsoleUtilsPrintf("\n\r SoC Version : %d", deviceVersion); /* On CM3 init firmware version is loaded onto the IPC Message Reg */ ConsoleUtilsPrintf("\n CM3 Firmware Version: %d", readCM3FWVersion()); I2CIntRegister(I2C_0); IntPrioritySet(SYS_INT_I2C0INT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_I2C0INT); I2CInit(I2C_0); IntSystemEnable(SYS_INT_TINT1_1MS); IntPrioritySet(SYS_INT_TINT1_1MS, 0, AINTC_HOSTINT_ROUTE_IRQ); IntRegister(SYS_INT_TINT1_1MS,clearTimerInt); configVddOpVoltage(); RtcInit(); HSMMCSDContolInit(); DelayTimerSetup(); initializeTimer1(); ConsoleUtilsPrintf("\r\n After intializing timer"); Timer2Config(); Timer4Config(); LedIfConfig(); MailBoxInit(); Timer2IntEnable(); Timer4IntEnable(); RtcSecIntEnable(); Timer4Start(); while(FALSE == tmr4Flag); tmr4Flag = FALSE; Timer4Stop(); ConsoleUtilsPrintf("\n\r Configuring for maximum OPP"); mpuOpp = ConfigMaximumOPP(); mpuFreq = FrequencyGet(mpuOpp); mpuVdd1 = VddVoltageGet(mpuOpp); PrintConfigDVFS(); /* Create menu page */ pageIndex = MENU_IDX_MAIN; ActionEnetInit(); /* ** Loop for ever. Necessary actions shall be taken ** after detecting the click. */ while(1) { /* ** Check for any any activity on Uart Console and process it. */ if (true == UARTCharsAvail(SOC_UART_0_REGS)) { /* Receiving bytes from the host machine through serial console. */ rxByte = UARTGetc(); /* ** Checking if the entered character is a carriage return. ** Pressing the 'Enter' key on the keyboard executes a ** carriage return on the serial console. */ if('\r' == rxByte) { ConsoleUtilsPrintf("\n"); UartAction(value); value = (unsigned int)E_FAIL; rxByte = 0; } /* ** Checking if the character entered is one among the decimal ** number set 0,1,2,3,....9 */ if(('0' <= rxByte) && (rxByte <= '9')) { ConsoleUtilsPrintf("%c", rxByte); if((unsigned int)E_FAIL == value) { value = 0; } value = value*10 + (rxByte - 0x30); } } /* ** Check if click is detected */ if(clickIdx != 0) { /* ** Take the Action for click */ ClickAction(); clickIdx = 0; } /* ** Check if the Timer Expired */ if(TRUE == tmrFlag) { /* Toggle the LED state */ LedToggle(); tmrFlag = FALSE; } /* ** Check if RTC Time is set */ if(TRUE == rtcSetFlag) { if(TRUE == rtcSecUpdate) { rtcSecUpdate = FALSE; RtcTimeCalDisplay(); ConsoleUtilsPrintf(" --- Selected: "); } } if(TRUE == tmr4Flag) { tmr4Flag = FALSE; /* Make sure that interrupts are disabled and no lwIP functions are executed while calling an lwIP exported API */ IntMasterIRQDisable(); etharp_tmr(); IntMasterIRQEnable(); } } }
/* ** Main function. The application starts here. */ int main(void) { unsigned int index; unsigned int j; int result = 0; /* ** Sets up Section page tables. This is only first level ** page table, each page is of size 1MB */ for(index = 0; index < (4*1024); index++) { /* Set the cacheable memory attributes */ if((index >= 0x800 && index < 0x880) || (index == 0x403)) { pageTable[index] = (index << 20) | CACHEABLE_TLB_ATTR; } /* Set the non-cacheable memory attributes */ else { pageTable[index] = (index << 20) | NORM_TLB_ATTR; } } /* Invalidate the TLB, pipeline */ CP15TlbInvalidate(); CP15BranchPredictorInvalidate(); CP15BranchPredictionEnable(); CP15DomainAccessClientSet(); /* Set TTB0 value. We use only TTB0 here (N = 0) */ CP15Ttb0Set(((unsigned int )pageTable) | RGN_L2_WBWA); /* Enables MMU */ CP15MMUEnable(); /* Flush and enable Instruction Cache */ CP15ICacheFlush(); CP15ICacheEnable(); PeripheralsSetUp(); /* Initialize the ARM Interrupt Controller */ IntAINTCInit(); /* Register the ISRs */ Timer2IntRegister(); Timer4IntRegister(); EnetIntRegister(); RtcIntRegister(); HSMMCSDIntRegister(); IntRegister(127, dummyIsr); IntMasterIRQEnable(); /* Enable system interrupts */ IntSystemEnable(SYS_INT_RTCINT); IntPrioritySet(SYS_INT_RTCINT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_3PGSWTXINT0); IntPrioritySet(SYS_INT_3PGSWTXINT0, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_3PGSWRXINT0); IntPrioritySet(SYS_INT_3PGSWRXINT0, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_TINT2); IntPrioritySet(SYS_INT_TINT2, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_TINT4); IntPrioritySet(SYS_INT_TINT4, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_MMCSD0INT); IntPrioritySet(SYS_INT_MMCSD0INT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(SYS_INT_EDMACOMPINT); IntPrioritySet(SYS_INT_EDMACOMPINT, 0, AINTC_HOSTINT_ROUTE_IRQ); IntSystemEnable(127); IntPrioritySet(127, 0, AINTC_HOSTINT_ROUTE_IRQ); RtcInit(); UARTStdioInit(); HSMMCSDContolInit(); DelayTimerSetup(); Timer2Config(); Timer4Config(); LedIfConfig(); Timer2IntEnable(); Timer4IntEnable(); RtcSecIntEnable(); InitI2C(); Timer4Start(); // Read config from files HSMMCSDCardAccessSetup(); configRead(); LedOn( USER_LED_1 ); for( j = 0; j < 1000000; ++j ); LedOff( USER_LED_1 ); LedOn( USER_LED_2 ); for( j = 0; j < 1000000; ++j ); LedOff( USER_LED_2 ); LedOn( USER_LED_3 ); for( j = 0; j < 1000000; ++j ); LedOff( USER_LED_3 ); LedOn( USER_LED_4 ); for( j = 0; j < 1000000; ++j ); LedOff( USER_LED_4 ); // TEMP //i2cTest(); /* ** Loop for ever. Necessary actions shall be taken ** after detecting the click. */ while( 1 ) { EnetStatusCheckNUpdate(); if( runCommand ) { // Command blink LedOn( USER_LED_1 ); if( runData[ runIndex + 1 ] == 'D' ) { if( runData[ runIndex + 2 ] == 'S' ) { UARTPuts( "** DAC SET\n\r", -1 ); if( runData[ runIndex + 3 ] == 'A' ) { i2cDAC_Set( 0, runData[ runIndex + 4 ], runData[ runIndex + 5 ] ); } if( runData[ runIndex + 6 ] == 'B' ) { i2cDAC_Set( 1, runData[ runIndex + 7 ], runData[ runIndex + 8 ] ); } if( runData[ runIndex + 9 ] == 'C' ) { i2cDAC_Set( 2, runData[ runIndex + 10 ], runData[ runIndex + 11 ] ); } if( runData[ runIndex + 12 ] == 'D' ) { i2cDAC_Set( 3, runData[ runIndex + 13 ], runData[ runIndex + 14 ] ); } } else if( runData[ runIndex + 2 ] == 'G' ) { UARTPuts( "** DAC GET\n\r", -1 ); uartData[ 0 ] = 15; uartData[ 1 ] = 'D'; uartData[ 2 ] = 'G'; uartData[ 3 ] = 'A'; i2cDAC_Get( 0, &uartData[ 4 ] ); uartData[ 6 ] = 'B'; i2cDAC_Get( 1, &uartData[ 7 ] ); uartData[ 9 ] = 'C'; i2cDAC_Get( 2, &uartData[ 10 ] ); uartData[ 12 ] = 'D'; i2cDAC_Get( 3, &uartData[ 13 ] ); net_ext_send( uartData, 15 ); } } else if( runData[ runIndex + 1 ] == 'G' ) { if( runData[ runIndex + 2 ] == 'S' ) { if( runData[ runIndex + 3 ] == 0 ) // Off { UARTPuts( "** GPIO OFF\n\r", -1 ); i2cGPIO_Off( 0, 1 << runData[ runIndex + 4 ] ); } else if( runData[ runIndex + 3 ] == 1 ) // On { UARTPuts( "** GPIO ON\n\r", -1 ); i2cGPIO_On( 0, 1 << runData[ runIndex + 4 ] ); } } else if( runData[ runIndex + 2 ] == 'G' ) { UARTPuts( "** GPIO GET\n\r", -1 ); uartData[ 0 ] = 5; uartData[ 1 ] = 'G'; uartData[ 2 ] = 'G'; i2cGPIO_Get( &uartData[ 3 ] ); net_ext_send( uartData, 5 ); } } else if( runData[ runIndex + 1 ] == 'U' ) { UARTPuts( "** UART\n\r", -1 ); i2cUART_Send( &(runData[ runIndex + 2 ]), 6 ); } runCommand -= runData[ runIndex + 0 ]; if( runCommand > 0 ) { runIndex += runData[ runIndex + 0 ]; } else { runIndex = 0; } LedOff( USER_LED_1 ); } result = i2cUART_Recv( &( uartData[ 2 ] ), 30 ); if( result > 0 ) { UARTPuts( "** UART Recv: ", -1 ); for( index = 0; index < result; ++index ) { UARTPutHexNum( uartData[ index + 2 ] ); UARTPutc( ' ' ); } UARTPutc( '\n' ); UARTPutc( '\r' ); // Return the stage position info to the GUI if( uartData[ 3 ] == 0x0A || uartData[ 3 ] == 0x3C ) { uartData[ 0 ] = result + 2; uartData[ 1 ] = 'U'; net_ext_send( uartData, result + 2 ); } } } }