Skip to content

Commit

Permalink
No longer use Deep sleep for when waiting for GPS fix (#439)
Browse files Browse the repository at this point in the history
Its proving hard to program, and makes it hard to program the Hardware independent watchdog option byte(IWDG_SW). There is no avoiding the spikes due to processor turning on, so keep it on always. Only exception is when doing TX, then put processor in low power mode.
  • Loading branch information
MedadRufus authored Apr 12, 2022
1 parent dfa429a commit 567bc8f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/boards/B-L072Z-LRWAN1/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ void BoardInitMcu( void )

RtcInit( );

DeepSleepDelayMsInit();

for (uint8_t i = 0; i < 5; i++)
{
Expand Down
6 changes: 3 additions & 3 deletions src/peripherals/SparkFun_Ublox_Arduino_Library.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include "SparkFun_Ublox_Arduino_Library.h"
#include <systime.h>
#include "string.h"
#include "deep_sleep_delay.h"
#include "delay.h"

extern I2c_t I2c;

Expand Down Expand Up @@ -1203,7 +1203,7 @@ sfe_ublox_status_e waitForACKResponse(ubxPacket *outgoingUBX, uint8_t requestedC
unsigned long startTime = SysTimeToMs(SysTimeGet());
while (SysTimeToMs(SysTimeGet()) - startTime < maxTime)
{
DeepSleepDelayMs(i2cPollingWait);
DelayMs(i2cPollingWait);

if (checkUbloxInternal(outgoingUBX, requestedClass, requestedID) == true) //See if new data is available. Process bytes as they come in.
{
Expand Down Expand Up @@ -1371,7 +1371,7 @@ sfe_ublox_status_e waitForNoACKResponse(ubxPacket *outgoingUBX, uint8_t requeste
unsigned long startTime = SysTimeToMs(SysTimeGet());
while (SysTimeToMs(SysTimeGet()) - startTime < maxTime)
{
DeepSleepDelayMs(i2cPollingWait);
DelayMs(i2cPollingWait);

if (checkUbloxInternal(outgoingUBX, requestedClass, requestedID) == true) //See if new data is available. Process bytes as they come in.
{
Expand Down
12 changes: 6 additions & 6 deletions src/peripherals/i2c_middleware.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ I2C_MIDDLEWARE_STATUS_t reinit_i2c()

/* disable power to GPS */
GpioWrite(&Load_enable, 1);
DeepSleepDelayMs(100);
DelayMs(100);

/* Make I2C bus pins GPIO */
GpioInit(&i2c_scl, PB_8, PIN_INPUT, PIN_PUSH_PULL, PIN_PULL_DOWN, 1);
Expand All @@ -82,22 +82,22 @@ I2C_MIDDLEWARE_STATUS_t reinit_i2c()
GpioWrite(&i2c_scl, 0);
GpioWrite(&i2c_sda, 0);

DeepSleepDelayMs(100);
DelayMs(100);

/* Enable power to GPS */
GpioWrite(&Load_enable, 0);
DeepSleepDelayMs(1000);
DelayMs(1000);

/* send 9 clock pulses to the GPS ref: https://www.microchip.com/forums/FindPost/175578 */
for (uint8_t i = 0; i < 9; i++)
{
GpioWrite(&i2c_scl, 0);
DeepSleepDelayMs(1);
DelayMs(1);
GpioWrite(&i2c_scl, 1);
DeepSleepDelayMs(1);
DelayMs(1);
}

DeepSleepDelayMs(100);
DelayMs(100);

I2cInit(&I2c, I2C_1, PB_8, PB_9);

Expand Down
12 changes: 6 additions & 6 deletions src/peripherals/ublox.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <systime.h>
#include <string.h>
#include "iwdg.h"
#include "deep_sleep_delay.h"
#include "delay.h"

#include "SparkFun_Ublox_Arduino_Library.h"

Expand Down Expand Up @@ -99,7 +99,7 @@ gps_status_t setup_GPS()
{
IWDG_reset();

DeepSleepDelayMs(GPS_WAKEUP_TIMEOUT); // Wait for things to be setup
DelayMs(GPS_WAKEUP_TIMEOUT); // Wait for things to be setup

/* Check if we are in airbourne mode. check if dynamic mode is correct. If its not, then setup the GPS */
uint8_t newDynamicModel = getDynamicModel(defaultMaxWait);
Expand Down Expand Up @@ -227,7 +227,7 @@ gps_status_t get_location_fix(uint32_t timeout)
return GPS_SUCCESS;
}
IWDG_reset();
DeepSleepDelayMs(2000);
DelayMs(2000);
IWDG_reset();
}

Expand All @@ -244,7 +244,7 @@ gps_status_t get_location_fix(uint32_t timeout)
static gps_status_t display_still_searching()
{
GpioWrite(&Led1, 1);
DeepSleepDelayMs(100);
DelayMs(100);
GpioWrite(&Led1, 0);

return GPS_SUCCESS;
Expand All @@ -258,9 +258,9 @@ static gps_status_t display_fix_found()
IWDG_reset();

GpioWrite(&Led1, 1);
DeepSleepDelayMs(50);
DelayMs(50);
GpioWrite(&Led1, 0);
DeepSleepDelayMs(50);
DelayMs(50);
}

return GPS_SUCCESS;
Expand Down

0 comments on commit 567bc8f

Please sign in to comment.