kopia lustrzana https://github.com/bristol-seds/pico-tracker
Added UBX CFG PWR frame to GPS. Useful for putting GPS in "shutdown"
rodzic
014a9dc568
commit
68c9614efa
|
@ -25,6 +25,9 @@
|
||||||
#ifndef GPS_H
|
#ifndef GPS_H
|
||||||
#define GPS_H
|
#define GPS_H
|
||||||
|
|
||||||
|
#include "samd20.h"
|
||||||
|
#include "hw_config.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GPS Error types
|
* GPS Error types
|
||||||
*/
|
*/
|
||||||
|
@ -45,6 +48,10 @@ struct ubx_nav_sol gps_get_nav_sol();
|
||||||
struct ubx_nav_timeutc gps_get_nav_timeutc();
|
struct ubx_nav_timeutc gps_get_nav_timeutc();
|
||||||
|
|
||||||
uint8_t gps_is_locked(void);
|
uint8_t gps_is_locked(void);
|
||||||
|
|
||||||
|
void gps_set_powersave(bool powersave_on);
|
||||||
|
void gps_set_power_state(bool gnss_running);
|
||||||
|
|
||||||
void gps_set_powersave_auto(void);
|
void gps_set_powersave_auto(void);
|
||||||
|
|
||||||
void gps_usart_init_enable(uint32_t baud_rate);
|
void gps_usart_init_enable(uint32_t baud_rate);
|
||||||
|
|
|
@ -157,6 +157,19 @@ __PACKED__ struct ubx_cfg_prt {
|
||||||
uint16_t res3;
|
uint16_t res3;
|
||||||
} payload;
|
} payload;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* UBX CFG PWR Put receiver in a defined power state
|
||||||
|
*/
|
||||||
|
__PACKED__ struct ubx_cfg_pwr {
|
||||||
|
ubx_message_id_t id;
|
||||||
|
enum ubx_packet_state state;
|
||||||
|
struct {
|
||||||
|
uint8_t messageVersion;
|
||||||
|
uint8_t res0;
|
||||||
|
uint16_t res1;
|
||||||
|
uint32_t state;
|
||||||
|
} payload;
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* UBX CFG RXM Set powersave mode
|
* UBX CFG RXM Set powersave mode
|
||||||
*/
|
*/
|
||||||
|
@ -193,6 +206,13 @@ enum {
|
||||||
UBX_GNSS_QZSS = 5,
|
UBX_GNSS_QZSS = 5,
|
||||||
UBX_GNSS_GLONASS = 6,
|
UBX_GNSS_GLONASS = 6,
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* UBX PWR Power States
|
||||||
|
*/
|
||||||
|
enum {
|
||||||
|
UBX_PWR_STATE_GNSS_RUNNING = 0x52554E20,
|
||||||
|
UBX_PWR_STATE_GNSS_STOPPED = 0x53544F50,
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* UBX Powersave Modes
|
* UBX Powersave Modes
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -76,6 +76,7 @@ volatile struct ubx_cfg_gnss ubx_cfg_gnss = { .id = (UBX_CFG | (0x3E << 8)
|
||||||
volatile struct ubx_cfg_nav5 ubx_cfg_nav5 = { .id = (UBX_CFG | (0x24 << 8)) };
|
volatile struct ubx_cfg_nav5 ubx_cfg_nav5 = { .id = (UBX_CFG | (0x24 << 8)) };
|
||||||
volatile struct ubx_cfg_tp5 ubx_cfg_tp5 = { .id = (UBX_CFG | (0x31 << 8)) };
|
volatile struct ubx_cfg_tp5 ubx_cfg_tp5 = { .id = (UBX_CFG | (0x31 << 8)) };
|
||||||
volatile struct ubx_cfg_prt ubx_cfg_prt = { .id = (UBX_CFG | (0x00 << 8)) };
|
volatile struct ubx_cfg_prt ubx_cfg_prt = { .id = (UBX_CFG | (0x00 << 8)) };
|
||||||
|
volatile struct ubx_cfg_pwr ubx_cfg_pwr = { .id = (UBX_CFG | (0x57 << 8)) };
|
||||||
volatile struct ubx_cfg_rxm ubx_cfg_rxm = { .id = (UBX_CFG | (0x11 << 8)) };
|
volatile struct ubx_cfg_rxm ubx_cfg_rxm = { .id = (UBX_CFG | (0x11 << 8)) };
|
||||||
volatile struct ubx_nav_posllh ubx_nav_posllh = { .id = (UBX_NAV | (0x02 << 8)) };
|
volatile struct ubx_nav_posllh ubx_nav_posllh = { .id = (UBX_NAV | (0x02 << 8)) };
|
||||||
volatile struct ubx_nav_timeutc ubx_nav_timeutc = { .id = (UBX_NAV | (0x21 << 8)) };
|
volatile struct ubx_nav_timeutc ubx_nav_timeutc = { .id = (UBX_NAV | (0x21 << 8)) };
|
||||||
|
@ -90,6 +91,7 @@ volatile ubx_message_t* const ubx_messages[] = {
|
||||||
(ubx_message_t*)&ubx_cfg_nav5,
|
(ubx_message_t*)&ubx_cfg_nav5,
|
||||||
(ubx_message_t*)&ubx_cfg_tp5,
|
(ubx_message_t*)&ubx_cfg_tp5,
|
||||||
(ubx_message_t*)&ubx_cfg_prt,
|
(ubx_message_t*)&ubx_cfg_prt,
|
||||||
|
(ubx_message_t*)&ubx_cfg_pwr,
|
||||||
(ubx_message_t*)&ubx_cfg_rxm,
|
(ubx_message_t*)&ubx_cfg_rxm,
|
||||||
(ubx_message_t*)&ubx_nav_posllh,
|
(ubx_message_t*)&ubx_nav_posllh,
|
||||||
(ubx_message_t*)&ubx_nav_timeutc,
|
(ubx_message_t*)&ubx_nav_timeutc,
|
||||||
|
@ -447,6 +449,19 @@ void gps_set_powersave(bool powersave_on)
|
||||||
(uint8_t*)&ubx_cfg_rxm.payload,
|
(uint8_t*)&ubx_cfg_rxm.payload,
|
||||||
sizeof(ubx_cfg_rxm.payload));
|
sizeof(ubx_cfg_rxm.payload));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Sets the PWR power state
|
||||||
|
*/
|
||||||
|
void gps_set_power_state(bool gnss_running)
|
||||||
|
{
|
||||||
|
ubx_cfg_pwr.payload.messageVersion = 1;
|
||||||
|
ubx_cfg_pwr.payload.state = (gnss_running ? UBX_PWR_STATE_GNSS_RUNNING : UBX_PWR_STATE_GNSS_STOPPED);
|
||||||
|
|
||||||
|
/* Write the new settings */
|
||||||
|
_ubx_send_message((ubx_message_t*)&ubx_cfg_pwr,
|
||||||
|
(uint8_t*)&ubx_cfg_pwr.payload,
|
||||||
|
sizeof(ubx_cfg_pwr.payload));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Sets the powersave mode automatically based on if we're locked.
|
* Sets the powersave mode automatically based on if we're locked.
|
||||||
*
|
*
|
||||||
|
|
Ładowanie…
Reference in New Issue