void rst_handler(void){ // Copy the .data section pointers to ram from flash. // Look at LD manual (Optional Section Attributes). // source and destination pointers unsigned long *src; unsigned long *dest; //this should be good! src = &_end_text; dest = &_start_data; FPUEnable(); FPULazyStackingEnable(); //this too while(dest < &_end_data) { *dest++ = *src++; } // now set the .bss segment to 0! dest = &_start_bss; while(dest < &_end_bss){ *dest++ = 0; } // after setting copying .data to ram and "zero-ing" .bss we are good // to start the main() method! // There you go! main(); }
void Board::init() // initialize the board specifics { // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. // FPUEnable(); FPULazyStackingEnable(); // // Set the clocking to run from the PLL at 50MHz // ROM_SysCtlClockSet( SYSCTL_SYSDIV_1 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); IntMasterEnable(); // Enable interrupts to the processor. // Set up the period for the SysTick timer for 1 mS. SysTickPeriodSet(SysCtlClockGet() / 1000); SysTickIntEnable(); // Enable the SysTick Interrupt. SysTickEnable(); // Enable SysTick. /* // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. FPUEnable(); FPULazyStackingEnable(); SysCtlClockSet( SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // Set the clocking to run directly from the crystal. IntMasterEnable(); // Enable interrupts to the processor.*/ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // Enable the GPIO port that is used for the on-board LED. GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); // Enable the GPIO pins for the LED (PF2). GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3); /* SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // Enable the peripherals used by this example. SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); IntMasterEnable(); // Enable processor interrupts. // Set up the period for the SysTick timer for 1 mS. SysTickPeriodSet(SysCtlClockGet() / 1000); SysTickIntEnable(); // Enable the SysTick Interrupt. SysTickEnable(); // Enable SysTick. GPIOPinConfigure(GPIO_PA0_U0RX); // Set GPIO A0 and A1 as UART pins. GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // Configure the UART for 115,200, 8-N-1 operation. IntEnable(INT_UART0); UARTFIFODisable(UART0_BASE); // UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8); UARTFlowControlSet(UART0_BASE, UART_FLOWCONTROL_NONE); UARTIntDisable(UART0_BASE, UART_INT_RT); UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_TX); // Enable the UART interrupt.*/ Board::setLedOn(Board::LED_GREEN, false); Board::setLedOn(Board::LED_RED, false); Board::setLedOn(Board::LED_BLUE, false); AdcInit(); }
/** Configures hardware for the particular hardware platform: - Ports: sets direction, interrupts, pullup/pulldown resistors etc. - Holds radio in reset (active-low) */ void halInit() { // // Enable the floating-point unit. // FPUEnable(); // // Configure the floating-point unit to perform lazy stacking of the // floating-point state. // FPULazyStackingEnable(); oscInit(); portInit(); halUartInit(); //Point the function pointers to doNothing() so that they don't trigger a restart debugConsoleIsr = &doNothing; buttonIsr = &doNothing; clearLeds(); displayVersion(); #ifdef AF_VERBOSE printf("* AF_VERBOSE *\r\n"); #endif }
void SystemInit(void) { //Enable floating-point unit FPUEnable(); //Run from the PLL at 120MHz SysCtlClockFreqSet(SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480, 120000000); }
int main(void) { // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. // FPULazyStackingEnable(); FPUEnable(); // // Set the clocking to run directly from the crystal. // Clock to 80MHZ // SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); IntMasterEnable(); //set up the radio if( !nrf24l01p_setup(&nrf, GPIO_PORTC_BASE, GPIO_PIN_4, SSI0_BASE) ){ //we couldn't communicate with the radio return 1; } nrf24l01p_set_PA_level(&nrf, RF24_PA_LOW); nrf24l01p_open_writing_pipe(&nrf, addresses[0]); nrf24l01p_open_reading_pipe(&nrf, 1,addresses[1]); nrf24l01p_start_listening(&nrf); while(1){ if (nrf24l01p_available(&nrf)) { uint32_t got_time; // Variable for the received timestamp while (nrf24l01p_available(&nrf)) { // While there is data ready nrf24l01p_read(&nrf, &got_time, sizeof(uint32_t)); // Get the payload } nrf24l01p_stop_listening(&nrf); // First, stop listening so we can talk nrf24l01p_write(&nrf, &got_time, sizeof(uint32_t)); // Send the final one back. nrf24l01p_start_listening(&nrf); // Now, resume listening so we catch the next packets. } //give it a little space SysCtlDelay((SysCtlClockGet() >> 12) * 5); } return 0; }
//***************************************************************************** // Initilizes hardware //***************************************************************************** void InitCortexHardware(void) { // // Enable FPU // FPUEnable(); FPULazyStackingEnable(); // Set clocking to 50 MHz, due to REV_A1 being a total ass. SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Configure UART0 for 115200-8n1 // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC); UARTStdioConfig(0, 115200, 16000000); UARTFIFODisable(UART0_BASE); UARTIntEnable(UART0_BASE, UART_INT_RX); UARTprintf("\n\nSystem initializing.\n"); // // Enable SysTick for periodic Interrupts // systick is used by command line process // SysTickEnable(); SysTickPeriodSet(SysCtlClockGet()/(SYSTICK_TIME/10)); SysTickIntEnable(); UARTprintf("- Systick timer enabled.\n"); // // Configure Heartbeat led // SysCtlPeripheralEnable(HEARTBEAT_CTRL_PORT); GPIOPinTypeGPIOOutput(HEARTBEAT_BASE_PORT, HEARTBEAT_PIN); GPIOPinWrite(HEARTBEAT_BASE_PORT, HEARTBEAT_PIN, 0xFF); UARTprintf("- GPIO enabled. \n"); // // Enable UART interrupts // IntMasterEnable(); IntEnable(INT_UART0); UARTprintf("- Interrupts enabled.\n"); }
// ---------------------------------------------------------------------------------- // // _reset_init() -- Reset entry point. // // The CPU reset vector points here. Initialize the CPU, and jump // to the C runtime start, which will eventually invoke main() // void _reset_init(void) { // Copy values to initialize data segment uint32_t *fr = __etext; uint32_t *to = __data_start__; unsigned int len = __data_end__ - __data_start__; while(len--) *to++ = *fr++; FPUEnable(); FPUStackingDisable(); main(); }
int main(void) { FPUEnable(); led_Init(); button_Init(); can_Init(); pcsr_Init(); //can_SetLogging(0, 0x001, 0x3FF, LogHandler); //uint8_t new_data[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; //uint8_t new_data_mask[] = { 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF }; //can_SetFiltering(0, 0x001, 0x3FF, new_data, new_data_mask); //uint8_t data[] = { 0xFF, 0x00, 0xFF, 0x00, '\n' }; //pcsr_WriteData("READY!\r\n", 8); while(UARTCharsAvail(UART2_BASE)) { led_Byte(UARTCharGetNonBlocking(UART2_BASE)); } while(1) { uint8_t buf[22]; pcsr_ReadData(buf, 1); if(buf[0] == FUNCTION_LOG) { pcsr_ReadData(buf + 1, 5); uint16_t arbid = buf[2] + (buf[3] << 8); uint16_t arbid_mask = buf[4] + (buf[5] << 8); can_SetLogging(buf[1], arbid, arbid_mask, LogHandler); } else if(buf[0] == FUNCTION_FILTER) { pcsr_ReadData(buf + 1, 21); uint16_t arbid = buf[2] + (buf[3] << 8); uint16_t arbid_mask = buf[4] + (buf[5] << 8); can_SetFiltering(buf[1], arbid, arbid_mask, buf + 6, buf + 14); } else if(buf[0] == FUNCTION_RESET) { can_ResetFunctions(); //led_Byte(buf[0]); } } }
int main(void) { //En vez de usar 16MHz, uso el PLL para conseguir 40MHz SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); unsigned long g=SysCtlClockGet(); FPUEnable(); FPUStackingEnable(); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); GPIOPinConfigure(GPIO_PC4_U4RX); GPIOPinConfigure(GPIO_PC5_U4TX); GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5); UARTConfigSetExpClk(UART4_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); rc = f_mount(0, &Fatfs); //registra un area de trabajo rc = f_open(&Fil, "BuffGPS.TXT", FA_WRITE | FA_OPEN_ALWAYS); //abre o crea un archivo rc = f_lseek(&Fil, Fil.fsize); rc = f_write(&Fil, &nuevo_registro, 15, &bw); rc = f_sync(&Fil); rc = f_close(&Fil); //Configuracion de timer y su interrupcion SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER); valor_timer = (SysCtlClockGet()/20); TimerLoadSet(TIMER0_BASE, TIMER_A, valor_timer -1); IntEnable(INT_TIMER0A); TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); TimerEnable(TIMER0_BASE, TIMER_A); //IntPrioritySet(FAULT_SYSTICK, 0x00); IntPrioritySet(INT_TIMER0A, 0x00); IntMasterEnable(); while(1); }
void main(void) { FPUEnable(); FPULazyStackingEnable(); SysCtlClockSet(SYSCTL_SYSDIV_4|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); while(1) { delta_params params; params.a = 70, params.b = 200; params.c = 50; params.d = 70; float alpha, beta, gamma; float X, Y, Z; X = 20; Y = -40; Z = 186; delta_calc(params, X, Y, Z, 0, &alpha, &beta, &gamma); } }
void initClk() { /*The FPU should be enabled because some compilers will use floating- * point registers, even for non-floating-point code. If the FPU is not * enabled this will cause a fault. This also ensures that floating- * point operations could be added to this application and would work * correctly and use the hardware floating-point unit. Finally, lazy * stacking is enabled for interrupt handlers. This allows floating- * point instructions to be used within interrupt handlers, but at the * expense of extra stack usage. */ FPUEnable(); FPULazyStackingEnable(); g_SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); }
int main(void) { #ifdef PART_LM4F120H5QR // ARM code SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN ); //set system clock to 80 MHz FPUEnable(); //enable the Floating Point Unit // FPULazyStackingEnable(); // Enable stacking for interrupt handlers #endif // Initialize system serial_init(); // Setup serial baud rate and interrupts settings_init(); // Load grbl settings from EEPROM st_init(); // Setup stepper pins and interrupt timers #ifdef PART_LM4F120H5QR // ARM code IntMasterEnable(); #else // AVR code sei(); // Enable interrupts #endif memset(&sys, 0, sizeof(sys)); // Clear all system variables sys.abort = true; // Set abort to complete initialization sys.state = STATE_INIT; // Set alarm state to indicate unknown initial position for(;;) { // Execute system reset upon a system abort, where the main program will return to this loop. // Once here, it is safe to re-initialize the system. At startup, the system will automatically // reset to finish the initialization process. if (sys.abort) { // Reset system. serial_reset_read_buffer(); // Clear serial read buffer plan_init(); // Clear block buffer and planner variables gc_init(); // Set g-code parser to default state protocol_init(); // Clear incoming line data and execute startup lines spindle_init(); coolant_init(); limits_init(); st_reset(); // Clear stepper subsystem variables. // Sync cleared gcode and planner positions to current system position, which is only // cleared upon startup, not a reset/abort. sys_sync_current_position(); // Reset system variables. sys.abort = false; sys.execute = 0; if (bit_istrue(settings.flags,BITFLAG_AUTO_START)) { sys.auto_start = true; } // Check for power-up and set system alarm if homing is enabled to force homing cycle // by setting Grbl's alarm state. Alarm locks out all g-code commands, including the // startup scripts, but allows access to settings and internal commands. Only a homing // cycle '$H' or kill alarm locks '$X' will disable the alarm. // NOTE: The startup script will run after successful completion of the homing cycle, but // not after disabling the alarm locks. Prevents motion startup blocks from crashing into // things uncontrollably. Very bad. #ifdef HOMING_INIT_LOCK if (sys.state == STATE_INIT && bit_istrue(settings.flags,BITFLAG_HOMING_ENABLE)) { sys.state = STATE_ALARM; } #endif // Check for and report alarm state after a reset, error, or an initial power up. if (sys.state == STATE_ALARM) { report_feedback_message(MESSAGE_ALARM_LOCK); } else { // All systems go. Set system to ready and execute startup script. sys.state = STATE_IDLE; protocol_execute_startup(); } } protocol_execute_runtime(); protocol_process(); // ... process the serial protocol // When the serial protocol returns, there are no more characters in the serial read buffer to // be processed and executed. This indicates that individual commands are being issued or // streaming is finished. In either case, auto-cycle start, if enabled, any queued moves. if (sys.auto_start) { st_cycle_start(); } } // return 0; /* never reached */ }
void pio_init() { // Board Initialization start // // // The FPU should be enabled because some compilers will use floating- // point registers, even for non-floating-point code. If the FPU is not // enabled this will cause a fault. This also ensures that floating- // point operations could be added to this application and would work // correctly and use the hardware floating-point unit. Finally, lazy // stacking is enabled for interrupt handlers. This allows floating- // point instructions to be used within interrupt handlers, but at the // expense of extra stack usage. // FPUEnable(); FPULazyStackingEnable(); //Init the device with 16 MHz clock. initClk(); /* Configure the system peripheral bus that IRQ & EN pin are map to */ MAP_SysCtlPeripheralEnable( SYSCTL_PERIPH_IRQ_PORT); // // Disable all the interrupts before configuring the lines // MAP_GPIOPinIntDisable(SPI_GPIO_IRQ_BASE, 0xFF); // // Cofigure WLAN_IRQ pin as input // MAP_GPIOPinTypeGPIOInput(SPI_GPIO_IRQ_BASE, SPI_IRQ_PIN); GPIOPadConfigSet(SPI_GPIO_IRQ_BASE, SPI_IRQ_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // // Setup the GPIO interrupt for this pin // MAP_GPIOIntTypeSet(SPI_GPIO_IRQ_BASE, SPI_IRQ_PIN, GPIO_FALLING_EDGE); // // Configure WLAN chip // MAP_GPIOPinTypeGPIOOutput(SPI_GPIO_IRQ_BASE, SPI_EN_PIN); MAP_GPIODirModeSet( SPI_GPIO_IRQ_BASE, SPI_EN_PIN, GPIO_DIR_MODE_OUT ); MAP_GPIOPadConfigSet( SPI_GPIO_IRQ_BASE, SPI_EN_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPD ); MAP_GPIOPinWrite(SPI_GPIO_IRQ_BASE, SPI_EN_PIN, PIN_LOW); SysCtlDelay(600000); SysCtlDelay(600000); SysCtlDelay(600000); // // Disable WLAN CS with pull up Resistor // MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SPI_PORT); MAP_GPIOPinTypeGPIOOutput(SPI_CS_PORT, SPI_CS_PIN); GPIOPadConfigSet(SPI_CS_PORT, SPI_CS_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); MAP_GPIOPinWrite(SPI_CS_PORT, SPI_CS_PIN, PIN_HIGH); // // Enable interrupt for WLAN_IRQ pin // MAP_GPIOPinIntEnable(SPI_GPIO_IRQ_BASE, SPI_IRQ_PIN); // // Clear interrupt status // SpiCleanGPIOISR(); MAP_IntEnable(INT_GPIO_SPI); //init LED initLEDs(); }
//***************************************************************************** // // A simple demonstration of the features of the TivaWare Graphics Library. // //***************************************************************************** int main(void) { tContext sContext; tRectangle sRect; // // The FPU should be enabled because some compilers will use floating- // point registers, even for non-floating-point code. If the FPU is not // enabled this will cause a fault. This also ensures that floating- // point operations could be added to this application and would work // correctly and use the hardware floating-point unit. Finally, lazy // stacking is enabled for interrupt handlers. This allows floating- // point instructions to be used within interrupt handlers, but at the // expense of extra stack usage. // FPUEnable(); FPULazyStackingEnable(); // // Run from the PLL at 120 MHz. // g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); // // Initialize the display driver. // Kentec320x240x16_SSD2119Init(g_ui32SysClock); // // Initialize the graphics context. // GrContextInit(&sContext, &g_sKentec320x240x16_SSD2119); // // Fill the top 24 rows of the screen with blue to create the banner. // sRect.i16XMin = 0; sRect.i16YMin = 0; sRect.i16XMax = GrContextDpyWidthGet(&sContext) - 1; sRect.i16YMax = 23; GrContextForegroundSet(&sContext, ClrDarkBlue); GrRectFill(&sContext, &sRect); // // Put a white box around the banner. // GrContextForegroundSet(&sContext, ClrWhite); GrRectDraw(&sContext, &sRect); // // Put the application name in the middle of the banner. // GrContextFontSet(&sContext, &g_sFontCm20); GrStringDrawCentered(&sContext, "grlib demo", -1, GrContextDpyWidthGet(&sContext) / 2, 8, 0); // // Configure and enable uDMA // SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); SysCtlDelay(10); uDMAControlBaseSet(&psDMAControlTable[0]); uDMAEnable(); // // Initialize the touch screen driver and have it route its messages to the // widget tree. // TouchScreenInit(g_ui32SysClock); TouchScreenCallbackSet(WidgetPointerMessage); // // Add the title block and the previous and next buttons to the widget // tree. // WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sPrevious); WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sTitle); WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sNext); // // Add the first panel to the widget tree. // g_ui32Panel = 0; WidgetAdd(WIDGET_ROOT, (tWidget *)g_psPanels); CanvasTextSet(&g_sTitle, g_pcPanei32Names[0]); // // Issue the initial paint request to the widgets. // WidgetPaint(WIDGET_ROOT); // // Loop forever handling widget messages. // while(1) { // // Process any messages in the widget message queue. // WidgetMessageQueueProcess(); } }
int main(void) { tContext sContext; tRectangle sRect; // // The FPU should be enabled because some compilers will use floating- // point registers, even for non-floating-point code. If the FPU is not // enabled this will cause a fault. This also ensures that floating- // point operations could be added to this application and would work // correctly and use the hardware floating-point unit. Finally, lazy // stacking is enabled for interrupt handlers. This allows floating- // point instructions to be used within interrupt handlers, but at the // expense of extra stack usage. // FPUEnable(); FPULazyStackingEnable(); // // Set the clock to 40Mhz derived from the PLL and the external oscillator // ROM_SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); // // Initialize the display driver. // Adafruit320x240x16_ILI9325Init(); // // Initialize the graphics context. // GrContextInit(&sContext, &g_sAdafruit320x240x16_ILI9325); // // Configure and enable uDMA // SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); SysCtlDelay(10); uDMAControlBaseSet(&sDMAControlTable[0]); uDMAEnable(); // // Initialize the touch screen driver and have it route its messages to the // widget tree. // TouchScreenInit(); // // Paint touch calibration targets and collect calibration data // GrContextForegroundSet(&sContext, ClrWhite); GrContextBackgroundSet(&sContext, ClrBlack); GrContextFontSet(&sContext, &g_sFontCm20); GrStringDraw(&sContext, "Touch center of circles to calibrate", -1, 0, 0, 1); GrCircleDraw(&sContext, 32, 24, 10); GrFlush(&sContext); TouchScreenCalibrationPoint(32, 24, 0); GrCircleDraw(&sContext, 280, 200, 10); GrFlush(&sContext); TouchScreenCalibrationPoint(280, 200, 1); GrCircleDraw(&sContext, 200, 40, 10); GrFlush(&sContext); TouchScreenCalibrationPoint(200, 40, 2); // // Calculate and set calibration matrix // long* plCalibrationMatrix = TouchScreenCalibrate(); // // Write out calibration data if successful // if(plCalibrationMatrix) { char pcStringBuf[20]; usprintf(pcStringBuf, "A %d", plCalibrationMatrix[0]); GrStringDraw(&sContext, pcStringBuf, -1, 0, 20, 1); usprintf(pcStringBuf, "B %d", plCalibrationMatrix[1]); GrStringDraw(&sContext, pcStringBuf, -1, 0, 40, 1); usprintf(pcStringBuf, "C %d", plCalibrationMatrix[2]); GrStringDraw(&sContext, pcStringBuf, -1, 0, 60, 1); usprintf(pcStringBuf, "D %d", plCalibrationMatrix[3]); GrStringDraw(&sContext, pcStringBuf, -1, 0, 80, 1); usprintf(pcStringBuf, "E %d", plCalibrationMatrix[4]); GrStringDraw(&sContext, pcStringBuf, -1, 0, 100, 1); usprintf(pcStringBuf, "F %d", plCalibrationMatrix[5]); GrStringDraw(&sContext, pcStringBuf, -1, 0, 120, 1); usprintf(pcStringBuf, "Div %d", plCalibrationMatrix[6]); GrStringDraw(&sContext, pcStringBuf, -1, 0, 140, 1); TouchScreenCalibrationPoint(0,0,0); // wait for dummy touch } // // Enable touch screen event handler for grlib widgets // TouchScreenCallbackSet(WidgetPointerMessage); // // Fill the top 24 rows of the screen with blue to create the banner. // sRect.sXMin = 0; sRect.sYMin = 0; sRect.sXMax = GrContextDpyWidthGet(&sContext) - 1; sRect.sYMax = 23; GrContextForegroundSet(&sContext, ClrDarkBlue); GrRectFill(&sContext, &sRect); // // Put a white box around the banner. // GrContextForegroundSet(&sContext, ClrWhite); GrRectDraw(&sContext, &sRect); // // Put the application name in the middle of the banner. // GrContextFontSet(&sContext, &g_sFontCm20); GrStringDrawCentered(&sContext, "grlib demo", -1, GrContextDpyWidthGet(&sContext) / 2, 8, 0); // // Add the title block and the previous and next buttons to the widget // tree. // WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sPrevious); WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sTitle); WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sNext); // // Add the first panel to the widget tree. // g_ulPanel = 0; WidgetAdd(WIDGET_ROOT, (tWidget *)g_psPanels); CanvasTextSet(&g_sTitle, g_pcPanelNames[0]); // // Issue the initial paint request to the widgets. // WidgetPaint(WIDGET_ROOT); // // Loop forever handling widget messages. // while(1) { // // Process any messages in the widget message queue. // WidgetMessageQueueProcess(); } }
/** * Initializes the FPU with lazy stacking enabled **/ void twe_initFPUlazy(void) { // Lazy Stacking increases interrupt latency and stack usage // (only need if doing floating pt. in interrupts) FPULazyStackingEnable(); FPUEnable(); }
/** * Initializes the FPU **/ void twe_initFPU(void) { FPUEnable(); }
/* * initialize tm4c */ void init_satellite() { FPUEnable(); FPULazyStackingEnable(); /* * init clock */ MAP_SysCtlClockSet(SYSCTL_SYSDIV_3 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN); //66.6..MHz MAP_IntMasterEnable(); /* * Enable peripherals */ MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //for LED indication MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); //for UART MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); //for IRQ and SW_EN MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); //for SPI /* * configure */ MAP_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); MAP_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, SIGNAL_LOW); //off MAP_GPIOPinConfigure(GPIO_PA0_U0RX); MAP_GPIOPinConfigure(GPIO_PA1_U0TX); MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTStdioConfig(UART_PORT, UART_BAUDRATE, SysCtlClockGet()); MAP_GPIOIntDisable(GPIO_PORTB_BASE, SIGNAL_HIGH); //interrupt disable MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_2); //IRQ as input MAP_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); MAP_GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_FALLING_EDGE); //enable interrupt MAP_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_5); //sw enable MAP_GPIODirModeSet(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_DIR_MODE_OUT); MAP_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPD); MAP_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, SIGNAL_LOW); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); MAP_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_0); MAP_GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); MAP_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_0, SIGNAL_HIGH); //chip select MAP_GPIOIntEnable(GPIO_PORTB_BASE, GPIO_PIN_2); //enable interrupt for WLAN_IRQ pin SpiCleanGPIOISR(); //clear interrupt status MAP_IntEnable(INT_GPIOB); //spi init_worker(); setState(READY); }
int main(void) { char cThisChar; /* Result code */ unsigned long ulResetCause; //SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); unsigned long g=SysCtlClockGet(); FPUEnable(); FPUStackingEnable(); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); ulResetCause = SysCtlResetCauseGet(); SysCtlResetCauseClear(ulResetCause); HibernateEnableExpClk(SysCtlClockGet()); ButtonsInit(); SysTickPeriodSet(SysCtlClockGet() / APP_SYSTICKS_PER_SEC); SysTickEnable(); SysTickIntEnable(); IntMasterEnable(); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART4); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); GPIOPinConfigure(GPIO_PC4_U4RX); GPIOPinConfigure(GPIO_PC5_U4TX); GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5); UARTConfigSetExpClk(UART4_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB0_U1RX); GPIOPinConfigure(GPIO_PB1_U1TX); GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); //Orden al PGS de que me devuelva solo un mensaje.. for(i=0; i<sizeof(buferA); i++){ UARTCharPut(UART1_BASE, buferA[i]);} GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); rc = f_mount(0, &Fatfs); //registra un area de trabajo rc = f_open(&Fil, "BuffGPS.TXT", FA_WRITE | FA_CREATE_ALWAYS); //abre o crea un archivo do { int contador1=0; cThisChar='0'; do{ cThisChar=UARTCharGet(UART1_BASE); BuffGPS[contador1]=cThisChar; contador1=contador1+1; } while((cThisChar != '\n')); cThisChar='0'; for(i=0; i<sizeof(cuaternion); i++){ UARTCharPut(UART4_BASE, cuaternion[i]);} do{ cThisChar=UARTCharGet(UART4_BASE); BuffGPS[contador1]=cThisChar; contador1=contador1+1; } while((cThisChar != '\n')); rc = f_write(&Fil, &BuffGPS, contador1, &bwGPS); rc = f_sync(&Fil); contador1=0; //while(UARTCharsAvail(UART1_BASE)==false){;} } while(1); }
int main(void) { unsigned long last_telemtry; char pbuff[100]; long lTemp; // // The FPU should be enabled because some compilers will use floating- // point registers, even for non-floating-point code. If the FPU is not // enabled this will cause a fault. This also ensures that floating- // point operations could be added to this application and would work // correctly and use the hardware floating-point unit. Finally, lazy // stacking is enabled for interrupt handlers. This allows floating- // point instructions to be used within interrupt handlers, but at the // expense of extra stack usage. // FPUEnable(); FPULazyStackingEnable(); HardwareInit(); SoftwareInit(); //last_telemtry = g_ulTickCount; while(1) { // Execute main loop to interpretation protocol command MainModeLoop(); EncoderTick(QEI0_BASE); // PITCH Encoder EncoderTick(QEI1_BASE); // ROLL Encoder #if 0 // restrict telemtry to about 10Hz, if ((g_ulTickCount - last_telemtry) > 10) //if(magready) { last_telemtry = g_ulTickCount; eCompassCalculate(); sprintf(pbuff,"%.2f,%.2f, ACC: %hd,%hd,%hd MAG: %hd,%hd,%hd\r\n",fRho6DOF,fFitErrorpc,iGpx,iGpy,iGpz,iBpx,iBpy,iBpz); UART0Send(pbuff, strlen(pbuff)); //sprintf(pbuff,"%.2f,%.2f,%.2f,%.2f, ACC: %hd,%hd,%hd MAG: %hd,%hd,%hd\r\n",fRho6DOF,fPhi6DOF,fThe6DOF,fPsi6DOF,iGpx,iGpy,iGpz,iBpx,iBpy,iBpz); //UART0Send(pbuff, strlen(pbuff)); //sprintf(pbuff,"%.2f,%.2f,%.2f,%.2f,ACC: %hd,%hd,%hd MAG: %hd,%hd,%hd\r\n",fRho6DOF,fPhi6DOF,fThe6DOF,fPsi6DOF,iGpx,iGpy,iGpz,iBpx,iBpy,iBpz); //UART0Send(pbuff, strlen(pbuff)); //sprintf(pbuff,"ROLL %.2f,PITCH %.2f,YAW %.2f\r\n",fPhi6DOF,fThe6DOF,fPsi6DOF); //UART0Send(pbuff, strlen(pbuff)); //sprintf(pbuff,"Phi %.2f The %.2f Psi %.2f Rho %.2f delta %.2f\n", fPhi6DOF, fThe6DOF, fPsi6DOF, fRho6DOF, fdelta6DOF); //sprintf(pbuff,"%lu,%.2f\r\n",g_ulTickCount,fRho6DOF); //UART0Send(pbuff, strlen(pbuff)); } #endif if(itgready == true) { //DEBUG_TP6(0); /*------------------------------------------------------------*/ /* ITG3200getXYZ() time is 30~ microsecond */ /*------------------------------------------------------------*/ ITG3200getXYZ(); #ifdef USE_BMA180_INTERRUPT /*------------------------------------------------------------*/ /* BMA180GetXYZ() time is 30~ microsecond */ /*------------------------------------------------------------*/ //BMA180GetXYZ(); /*------------------------------------------------------------*/ /* ITG3200getXYZ() time is 30~ microsecond */ /*------------------------------------------------------------*/ //MAG3110getXYZ(); eCompassCalculate(); /*------------------------------------------------------------*/ /* AHRS() time is 25~ microsecond */ /*------------------------------------------------------------*/ AHRS(); #endif if(g_tbstabilizer == true) { /*------------------------------------------------------------*/ /* Stabilize() time is 4~ microsecond */ /*------------------------------------------------------------*/ //Stabilize(ROLL_MOTOR); /*------------------------------------------------------------*/ /* Stabilize() time is 4~ microsecond */ /*------------------------------------------------------------*/ //Stabilize(PITCH_MOTOR); /*------------------------------------------------------------*/ /* Total time is 115~ microsecond test by EranS */ /* Gyro and Encoder dose not test yet. Need testing with new board */ /*------------------------------------------------------------*/ } } //DEBUG_TP6(0); #if 0 if(1)//new_adc == true) { new_adc=false; //PitchAmp = (float)PitchRollAmp[PITCH_MOTOR]; //PitchAmp = (PitchAmp /FULL_SCALE_BIT)*3; // 2Exp12 * 3V //PitchAmp = PitchAmp / 5; //PitchAmp*=1000; //sprintf(pbuff,"%.2fmA\r\n",PitchAmp); //sprintf(pbuff,"%lu,%u,%u\r\n",g_ulTickCount,PitchRollAmp[PITCH_MOTOR],PitchRollAmp[ROLL_MOTOR]); sprintf(pbuff,"%.2f\r\n",y_rate_roll); //sprintf(pbuff,"%lu,%lu\r\n",g_ulTickCount,g_ulAverage); UART0Send(pbuff, strlen(pbuff)); } #endif } }
/****************************************************************** * Main-function */ int main(void) { /************************************** * Set the clock to run at 80 MHz */ SysCtlClockSet(SYSCTL_SYSDIV_2_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); /************************************** * Enable the floating-point-unit */ FPUEnable(); // We also want Lazystacking, so enable that too FPULazyStackingEnable(); // We also want to put numbers close to zero to zero FPUFlushToZeroModeSet(FPU_FLUSH_TO_ZERO_EN); /************************************** * Init variables */ uint16_t mapData[MAP_DATA_SIZE]; uint8_t stepDir = 0; /************************************** * Init peripherals used */ bluetooth_init(); init_stepper(); // Init the GPIOs used for the stepper and loading LED InitI2C1(); // Init the communication with the lidar-unit through I2C InitPWM(); setupTimers(); /************************************** * State 2 */ // Disable the timers that are used disableTimer(TIMER1_BASE); disableTimer(TIMER2_BASE); // Enable all interrupts IntMasterEnable(); /************************************** * State 3 */ // Indicate we should start with a scan regardless of what other things we have already got // from UART-interrupt // This means setting the appropriate bit in the status vector stat_vec |= TAKE_MEAS; /************************************** * State 4 */ // Contains main-loop where decisions should be made for ( ; ; ) { /********************************** * Decision tree */ // Highest priority case first // Check both interrupts at each iteration in the loop if ( int_vec & UART_INT ) { // Reset the indication int_vec &= ~UART_INT; // Remove drive-stop flag to enable movement stat_vec &= ~DRIVE_STOP; // Init data array uint8_t dataArr[MAX_UART_MSG_SIZE]; // Collect the message if ( readUARTMessage(dataArr, MAX_UART_MSG_SIZE) < SUCCESS ) { // If we have recieved more data than fits in the vector we should simply // go in here again and grab data int_vec |= UART_INT; } // We have gathered a message // and now need to determine what the message is parseMsg(dataArr, MAX_UART_MSG_SIZE); } // Checking drive (movement) interrupt if ( int_vec & TIMER2_INT ) { int_vec &= ~TIMER2_INT; // Disable TIMER2 disableTimer(TIMER2_BASE); // Set drive-stop in status vector stat_vec |= DRIVE_STOP; } // Checking measure interrupt if ( int_vec & TIMER1_INT ) { int_vec &= ~TIMER1_INT; // Disable TIMER1 disableTimer(TIMER1_BASE); // Take reading from LIDAR mapData[stepCount++] = readLidar(); SysCtlDelay(2000); // Take step // Note: We need to take double meas at randvillkor (100) !!!!! if ( stepCount > 0 && stepCount < 100 ) { stepDir = 1; } else if ( stepCount >= 100 && stepCount < 200) { stepDir = 0; } else { stepDir = 1; stepCount = 0; // Reset busy-flag stat_vec &= ~TAKE_MEAS; } step = takeStep(step, stepDir); // Request reading from LIDAR reqLidarMeas(); if ( stat_vec & TAKE_MEAS ) { // Restart TIMER1 enableTimer(TIMER1_BASE, (SYSCLOCK / MEASUREMENT_DELAY)); } else { sendUARTDataVector(mapData, MAP_DATA_SIZE); stat_vec &= ~BUSY; } } // Check the drive_stop flag, which always should be set unless we should move if ( stat_vec & DRIVE_STOP ) { // Stop all movement SetPWMLevel(0,0); halt(); // MAKE SURE all drive-flags are not set stat_vec &= ~(DRIVE_F | DRIVE_L | DRIVE_R | DRIVE_LL | BUSY); } // Should we drive? else if ( stat_vec & DRIVE ) { // Remove drive flag stat_vec &= ~DRIVE; // Increase PWM increase_PWM(0,MAX_FORWARD_SPEED,0,MAX_FORWARD_SPEED); if ( stat_vec & DRIVE_F ) { enableTimer(TIMER2_BASE, DRIVE_FORWARD_TIME); } else if ( stat_vec & DRIVE_LL ) { enableTimer(TIMER2_BASE, DRIVE_TURN_180_TIME); } else { enableTimer(TIMER2_BASE, DRIVE_TURN_TIME); } } if ( !(stat_vec & BUSY) ) { // Tasks switch ( stat_vec ) { case ((uint8_t)DRIVE_F) : // Call drive function go_forward(); // Set the drive flag & BUSY stat_vec |= DRIVE | BUSY; break; case ((uint8_t)DRIVE_L) : // Call drive-left function go_left(); // Set the drive flag stat_vec |= DRIVE | BUSY; break; case ((uint8_t)DRIVE_R) : // Call drive-right function go_right(); // Set the drive flag stat_vec |= DRIVE | BUSY; break; case ((uint8_t)DRIVE_LL) : // Call turn 180-degrees function go_back(); // Set the drive flag stat_vec |= DRIVE | BUSY; break; case ((uint8_t)TAKE_MEAS) : // Request reading from LIDAR reqLidarMeas(); // Start TIMER1 enableTimer(TIMER1_BASE, (SYSCLOCK / MEASUREMENT_DELAY)); // if sysclock = 1 s, 1/120 = 8.3 ms // We are busy stat_vec |= BUSY; break; default: break; } } } }
int main(void) { // Status of Hibernation module uint32_t ui32Status = 0; // Length of time to hibernate uint32_t hibernationTime = 600; g_ui32SysClock = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000); //************************************************************************* //! I/O config and setup //************************************************************************* SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // UART SysCtlPeripheralEnable(SYSCTL_PERIPH_UART7); // UART SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // UART0 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); // UART7 SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); // SSI SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION); // GPIO SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2); // SSI SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK); // GPIO SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);// Hibernation // UART0 and UART7 GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PC4_U7RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinConfigure(GPIO_PC5_U7TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5); // LED indicators GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // SD Card Detect (PK3) and GPS Pulse Per Second (PK2) // GPIOPinTypeGPIOInput(GPIO_PORTK_BASE, GPIO_PIN_2|GPIO_PIN_3); // Pulse Per Second input pin config as weak pull-down GPIOPadConfigSet(GPIO_PORTK_BASE,GPIO_PIN_2,GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPD); // Pulse Per Second input pin config as rising edge triggered interrupt GPIOIntTypeSet(GPIO_PORTK_BASE,GPIO_PIN_2,GPIO_RISING_EDGE); // Register Port K as interrupt GPIOIntRegister(GPIO_PORTK_BASE, PortKIntHandler); // Enable Port K pin 2 interrupt GPIOIntEnable(GPIO_PORTK_BASE, GPIO_INT_PIN_2); // // Disable PPS pin interrupt by default // if(IntIsEnabled(INT_GPIOK)) { IntDisable(INT_GPIOK); } GPIOPinConfigure(GPIO_PD0_SSI2XDAT1); GPIOPinConfigure(GPIO_PD1_SSI2XDAT0); GPIOPinConfigure(GPIO_PD2_SSI2FSS); GPIOPinConfigure(GPIO_PD3_SSI2CLK); // SD Card Detect (CD) - weak pull-up input GPIOPadConfigSet(GPIO_PORTK_BASE, GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // Debug UART output config UARTConfigSetExpClk(UART0_BASE, g_ui32SysClock, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // GPS UART input config UARTConfigSetExpClk(UART7_BASE, g_ui32SysClock, 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // // Configure SysTick for a 100Hz interrupt. // SysTickPeriodSet(g_ui32SysClock / 100); SysTickIntEnable(); SysTickEnable(); // // Floating point enable // FPUEnable(); FPULazyStackingEnable(); // // Clear user LEDs // GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0 | GPIO_PIN_1, 0x00); //************************************************************************* //! Hibernation mode checks and setup //************************************************************************* // // Check to see if Hibernation module is already active, which could mean // that the processor is waking from a hibernation. // if(HibernateIsActive()) { // // Read the status bits to see what caused the wake. Clear the wake // source so that the device can be put into hibernation again. // ui32Status = HibernateIntStatus(0); HibernateIntClear(ui32Status); // // Wake was due to RTC match. // if(ui32Status & HIBERNATE_INT_RTC_MATCH_0) { // // TODO: add IMU check // } // // Wake was due to the External Wake pin. // else if(ui32Status & HIBERNATE_INT_PIN_WAKE) { // // Switch off low power mode // lowPowerOn = 0; } } // // Configure Hibernate module clock. // HibernateEnableExpClk(g_ui32SysClock); // // If the wake was not due to the above sources, then it was a system // reset. // if(!(ui32Status & (HIBERNATE_INT_PIN_WAKE | HIBERNATE_INT_RTC_MATCH_0))) { // // Configure the module clock source. // HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE); } // // Enable PPS for a single data log. Interrupt on next PPS logic high. // ppsDataLog(); // // Enable RTC mode. // HibernateRTCEnable(); // // Loop forever // while(1) { // // If low power mode is set (default), hibernate again // If not, spin in nested while(1) for faster updates from PPS pin ints. // if(lowPowerOn) { lowPowerMode(hibernationTime); } else { if(!IntIsEnabled(INT_GPIOK)) { IntEnable(INT_GPIOK); } while(1) { } } } } // End function main
//***************************************************************************** // // This example application demonstrates the use of the timers to generate // periodic interrupts. // //***************************************************************************** int main(void) { // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. // FPUEnable(); FPULazyStackingEnable(); // // Set the clocking to run directly from the crystal. // SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Enable processor interrupts. // IntMasterEnable(); // // Initialize the UART and write status. // ConfigureUART(); ConfigureXBeeUART(); ConfigureUARTSensores(); ButtonsInit(); inicializa_motores(); // // Enable the peripherals used by this example. // SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); // // Configure the two 32-bit periodic timers. // TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC); TimerLoadSet(TIMER1_BASE, TIMER_A, SysCtlClockGet()/200000); // // Setup the interrupts for the timer timeouts. // IntEnable(INT_TIMER1A); TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT); // // Enable the timers. // TimerEnable(TIMER1_BASE, TIMER_A); // Configure a wide timer for timing purposes SysCtlPeripheralEnable(SYSCTL_PERIPH_WTIMER0); TimerConfigure(WTIMER0_BASE, TIMER_CFG_PERIODIC_UP); TimerLoadSet64(WTIMER0_BASE, (((long long)1) << 60)); TimerEnable(WTIMER0_BASE, TIMER_A); int counter_verify_no_ar = 0; while(1) { SysCtlDelay(SysCtlClockGet() / 1000); checkButtons(); readPackage(); counter_verify_no_ar++; if (counter_verify_no_ar == 1000) { counter_verify_no_ar = 0; if (no_ar) { enviaNoAr(); no_ar = false; } if (no_chao) { enviaNoChao(); no_chao = false; } } } }
//***************************************************************************** // // This example demonstrates how to send a string of data to the UART. // //***************************************************************************** int main(void) { // // Enable lazy stacking for interrupt handlers. This allows floating-point // instructions to be used within interrupt handlers, but at the expense of // extra stack usage. // FPUEnable(); FPULazyStackingEnable(); // // Set the clocking to run directly from the crystal. // SysCtlClockSet( SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Enable the GPIO port that is used for the on-board LED. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // // Enable the GPIO pins for the LED (PF2). // GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); // // Enable the peripherals used by this example. // SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // // Enable processor interrupts. // IntMasterEnable(); // // Set GPIO A0 and A1 as UART pins. // GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Configure the UART for 115,200, 8-N-1 operation. // UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // // Enable the UART interrupt. // IntEnable(INT_UART0); UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); // // Prompt for text to be entered. // UARTSend((unsigned char *) "Enter text: ", 14); // // Loop forever echoing data through the UART. // while (1) { } }