sparkfun / OpenLog_Artemis

The OpenLog Artemis is an open source datalogger the comes preprogrammed to automatically log IMU, GPS, serial data, and various pressure, humidity, and distance sensors. All without writing a single line of code!
https://www.sparkfun.com/products/15846
Other
88 stars 47 forks source link

When the OLA goes to sleep, yet the QWIIC bus stays powered on, sometimes an I2C devices misses the next command #155

Closed whipple63 closed 9 months ago

whipple63 commented 1 year ago

When the OLA goes to sleep, yet the QWIIC bus stays powered on, sometimes an I2C devices misses the next command.

Here is what I believe is happening. “goToSleep” is called which disables SDA and SCL. The QWIIC bus power is left on. The still on I2C devices see a signal like this:

image

Sometimes this confuses the I2C device and leaves it in a state where it does not see the next command. Perhaps if the SDA line falls faster than SCL it gets interpreted as an I2C start condition.

Whatever the reason, I propose only disabling SDA and SCL if I2C power is to be shut off during sleep. This may be a defensible choice if the user opts to leave I2C power on, the additional power due to leaving these pins enabled may not be of consequence. If I2C power is turned off during sleep the I2C devices re-initialize upon power-up and do not exhibit this problem.

I have compiled a version where I have moved the two lines that disable SDA and SCL into the if block as follows:

//Keep Qwiic bus powered on if user desires it if (settings.powerDownQwiicBusBetweenReads == true) { //Do disable qwiic SDA and SCL to minimise the current draw during deep sleep am_hal_gpio_pinconfig(PIN_QWIIC_SDA , g_AM_HAL_GPIO_DISABLE); am_hal_gpio_pinconfig(PIN_QWIIC_SCL , g_AM_HAL_GPIO_DISABLE); qwiicPowerOff(); } else ...

This works for my case. I would be happy to pull-request this change (although it is just moving two lines of code.)

PaulZC commented 1 year ago

Hi Tony,

This looks like a sensible and useful change. I don't think it will cause any unexpected backward compatibility issues. I'm happy to include it.

If you submit a Pull Request, you get the full fame and glory in the GitHub stats... ;-)

All the best, Paul

PaulZC commented 9 months ago

This change is included in v2.6 of the firmware... Thanks Tony!