//***************************************************************************** // // Uses the fColorWheelPos variable to update the color mix shown on the RGB // // This function is called when system has decided it is time to enter // Hibernate. This will prepare the hibernate peripheral, save the system // state and then enter hibernate mode. // //***************************************************************************** void AppHibernateEnter(void) { // // Alert UART command line users that we are going to hibernate // UARTprintf("Entering Hibernate...\n"); // // Prepare Hibernation Module // HibernateGPIORetentionEnable(); HibernateRTCSet(0); HibernateRTCEnable(); HibernateRTCMatchSet(0, 5); HibernateWakeSet(HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RTC); // // Store state information to battery backed memory // since sizeof returns number of bytes we convert to words and force // a rounding up to next whole word. // HibernateDataSet((uint32_t*)&g_sAppState, sizeof(tAppState)/4+1); // // Disable the LED for 100 milliseconds to let user know we are // ready for hibernate and will hibernate on relase of buttons // RGBDisable(); SysCtlDelay(SysCtlClockGet()/3/10); RGBEnable(); // // Wait for wake button to be released prior to going into hibernate // while(g_sAppState.ui32Buttons & RIGHT_BUTTON) { // //Delay for about 300 clock ticks to allow time for interrupts to //sense that button is released // SysCtlDelay(100); } // // Disable the LED for power savings and go to hibernate mode // RGBDisable(); HibernateRequest(); }
//***************************************************************************** // //! Wide Timer interrupt to handle blinking effect of the RGB //! //! This function is called by the hardware interrupt controller on a timeout //! of the wide timer. This function must be in the NVIC table in the startup //! file. When called will toggle the enable flag to turn on or off the entire //! RGB unit. This creates a blinking effect. A wide timer is used since the //! blink is intended to be visible to the human eye and thus is expected to //! have a frequency between 15 and 0.1 hz. Currently blink duty is fixed at //! 50%. //! //! \return None. // //***************************************************************************** void RGBBlinkIntHandler(void) { static unsigned long ulFlags; // // Clear the timer interrupt. // ROM_TimerIntClear(WTIMER5_BASE, TIMER_TIMB_TIMEOUT); // // Toggle the flag for the blink timer. // ulFlags ^= 1; if(ulFlags) { RGBEnable(); } else { RGBDisable(); } }
//***************************************************************************** // // Initializes the switch task. // //***************************************************************************** unsigned long AccelerometerTaskInit(void) { // volatile unsigned char foo = 28; RGBInit(1); RGBIntensitySet(0.3f); // // Turn on the Green LED // g_ucColorsIndx = 0; g_ulColors[g_ucColorsIndx] = 0x8000; RGBColorSet(g_ulColors); RGBDisable(); ////////////// g_pAccelerometerQueue = xQueueCreate(ACCELEROMETER_QUEUE_SIZE, ACCELEROMETER_ITEM_SIZE); I2CSetup(I2C0BASEADDR, 40000); if (((I2CRegRead(I2C0BASEADDR, SLAVEID, DEVID)) & 0xE5) == 0) { while (1); } I2CRegWrite(I2C0BASEADDR, SLAVEID, THRESH_FF, 0x06); simple_delay(); I2CRegWrite(I2C0BASEADDR, SLAVEID, TIME_FF, 0x15); simple_delay(); I2CRegWrite(I2C0BASEADDR, SLAVEID, INT_MAP, 0x00); simple_delay(); I2CRegWrite(I2C0BASEADDR, SLAVEID, POWER_CTL, 0x08); simple_delay(); I2CRegWrite(I2C0BASEADDR, SLAVEID, INT_ENABLE, 0x04); simple_delay(); if(xTaskCreate(AccelerometerTask, (signed portCHAR *)"Acclerometer", ACCELEROMETERTASKSTACKSIZE, NULL, tskIDLE_PRIORITY + PRIORITY_ACCELEROMETER_TASK, NULL) != pdTRUE) { return(1); } // // Success. // return(0); }