I'm trying to figure out how I can modify the compdcm_mpu9150 project so that instead of having the mpu9150 constantly updating/interrupting, forever collecting data I can get it to do a single reading or series of readings and shut it off until I want to use it again.
The pseudo I'm working with is as follows:
configureI2CBus // set up the bus for the boostxl-senshub configureMPU9150 /* enable the pin for gpio interrupts from the * MPU9150. Initialize the MPU9150 driver. * configure the sensor ranges/filters. */ /* Time here to do other things while we wait * for the GPIO interrupt */ gpioInterrupt /* data is ready*/ readData /* get the data from the sensor into our * mpu9150 instance variable */ sleep /* we have the data we want, put the sensor * back to sleep */ handleData // other stuff wake /* we're looking for more readings wake up the * MPU9150 */ gpioInterrupt read data sleep
I think the part that I'm having the most trouble with is trying to write the wake portion.
I found the sleep command in the MPU9150_O_PWR_MGMT_1 register but all the wake-up stuff seems to be waking it on an interval rather than on demand. It almost seems like the only way to use this sensor is to have it running at all times but I doubt that is the case.
After I put it to sleep do I need to call MPU9150Init() again and wipe out my range/filter settings?