kopia lustrzana https://github.com/bristol-seds/pico-tracker
[New Feature] Enabled cyclic tracking on the GPS
rodzic
bad5cc913d
commit
33733e77ca
|
@ -139,6 +139,33 @@ __PACKED__ struct ubx_cfg_tp5 {
|
|||
uint32_t flags;
|
||||
} payload;
|
||||
};
|
||||
/**
|
||||
* UBX CFG PM2 Extended Power Management Configuration
|
||||
*/
|
||||
__PACKED__ struct ubx_cfg_pm2 {
|
||||
ubx_message_id_t id;
|
||||
enum ubx_packet_state state;
|
||||
struct {
|
||||
uint8_t version;
|
||||
uint8_t reserved1;
|
||||
uint8_t reserved2;
|
||||
uint8_t reserved3;
|
||||
uint32_t flags;
|
||||
uint32_t updatePeriod;
|
||||
uint32_t searchPeriod;
|
||||
uint32_t gridOffset;
|
||||
uint16_t onTime;
|
||||
uint16_t minAcqTime;
|
||||
uint16_t reserved4;
|
||||
uint16_t reserved5;
|
||||
uint32_t reserved6;
|
||||
uint32_t reserved7;
|
||||
uint8_t reserved8;
|
||||
uint8_t reserved9;
|
||||
uint16_t reserved10;
|
||||
uint32_t reserved11;
|
||||
} payload;
|
||||
};
|
||||
/**
|
||||
* UBX CFG PRT Polls the configuration for one I/O Port
|
||||
*/
|
||||
|
@ -157,6 +184,17 @@ __PACKED__ struct ubx_cfg_prt {
|
|||
uint16_t res3;
|
||||
} payload;
|
||||
};
|
||||
/**
|
||||
* UBX CFG RXM Power Managerment
|
||||
*/
|
||||
__PACKED__ struct ubx_cfg_rxm {
|
||||
ubx_message_id_t id;
|
||||
enum ubx_packet_state state;
|
||||
struct {
|
||||
uint8_t reserved1;
|
||||
uint8_t lpMode;
|
||||
} payload;
|
||||
};
|
||||
|
||||
/**
|
||||
* UBX Dynamic Platform Model
|
||||
|
@ -182,6 +220,30 @@ enum {
|
|||
UBX_GNSS_QZSS = 5,
|
||||
UBX_GNSS_GLONASS = 6,
|
||||
};
|
||||
/**
|
||||
* UBX PM2 Power Management Flags
|
||||
*/
|
||||
enum {
|
||||
UBX_PM_EXTINT_EXTINT0 = (0 << 4),
|
||||
UBX_PM_EXTINT_EXTINT1 = (1 << 4),
|
||||
UBX_PM_EXTINT_WAKE = (1 << 5),
|
||||
UBX_PM_EXTINT_BACKUP = (1 << 6),
|
||||
UBX_PM_LIMIT_PEAK_CURRENT = (1 << 8),
|
||||
UBX_PM_ONLY_WAIT_FOR_TIMEFIX = (1 << 10),
|
||||
UBX_PM_WAKE_FOR_RTC = (1 << 11),
|
||||
UBX_PM_WAKE_FOR_EPHERMERIS = (1 << 12),
|
||||
UBX_PM_DO_NOT_ENTER_OFF = (1 << 16),
|
||||
UBX_PM_MODE_ON_OFF = (0 << 17),
|
||||
UBX_PM_MODE_CYCLIC = (1 << 17)
|
||||
};
|
||||
/**
|
||||
* UBX RXM Power Modes
|
||||
*/
|
||||
enum {
|
||||
UBX_LPMODE_CONTINOUS = 0,
|
||||
UBX_LPMODE_POWERSAVE = 1,
|
||||
UBX_LPMODE_CONTINOUS2 = 4,
|
||||
};
|
||||
|
||||
/**
|
||||
* =============================================================================
|
||||
|
|
|
@ -72,7 +72,9 @@ volatile struct ubx_cfg_ant ubx_cfg_ant = { .id = (UBX_CFG | (0x13 << 8)) };
|
|||
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_tp5 ubx_cfg_tp5 = { .id = (UBX_CFG | (0x31 << 8)) };
|
||||
volatile struct ubx_cfg_pm2 ubx_cfg_pm2 = { .id = (UBX_CFG | (0x3B << 8)) };
|
||||
volatile struct ubx_cfg_prt ubx_cfg_prt = { .id = (UBX_CFG | (0x00 << 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_timeutc ubx_nav_timeutc = { .id = (UBX_NAV | (0x21 << 8)) };
|
||||
volatile struct ubx_nav_sol ubx_nav_sol = { .id = (UBX_NAV | (0x06 << 8)) };
|
||||
|
@ -85,7 +87,9 @@ volatile ubx_message_t* const ubx_messages[] = {
|
|||
(ubx_message_t*)&ubx_cfg_gnss,
|
||||
(ubx_message_t*)&ubx_cfg_nav5,
|
||||
(ubx_message_t*)&ubx_cfg_tp5,
|
||||
(ubx_message_t*)&ubx_cfg_pm2,
|
||||
(ubx_message_t*)&ubx_cfg_prt,
|
||||
(ubx_message_t*)&ubx_cfg_rxm,
|
||||
(ubx_message_t*)&ubx_nav_posllh,
|
||||
(ubx_message_t*)&ubx_nav_timeutc,
|
||||
(ubx_message_t*)&ubx_nav_sol,
|
||||
|
@ -409,7 +413,32 @@ void gps_set_gnss(void)
|
|||
(uint8_t*)&ubx_cfg_gnss.payload,
|
||||
4 + (8 * ubx_cfg_gnss.payload.numConfigBlocks));
|
||||
}
|
||||
/**
|
||||
* Sets the power saving mode
|
||||
*/
|
||||
void gps_set_powermanagement(void)
|
||||
{
|
||||
/* Read the current settings */
|
||||
_ubx_poll((ubx_message_t*)&ubx_cfg_pm2);
|
||||
|
||||
/* Update for cyclic powersave mode */
|
||||
ubx_cfg_pm2.payload.flags = UBX_PM_MODE_CYCLIC | UBX_PM_DO_NOT_ENTER_OFF;
|
||||
ubx_cfg_pm2.payload.onTime = 30; /* 30 seconds of on time after aquisition */
|
||||
ubx_cfg_pm2.payload.updatePeriod = 2*1000; /* Calcuate fixes every 2 seconds */
|
||||
|
||||
/* Enable powersave mode */
|
||||
ubx_cfg_rxm.payload.reserved1 = 8;
|
||||
ubx_cfg_rxm.payload.lpMode = UBX_LPMODE_POWERSAVE;
|
||||
|
||||
/* Write the new settings */
|
||||
_ubx_send_message((ubx_message_t*)&ubx_cfg_pm2,
|
||||
(uint8_t*)&ubx_cfg_pm2.payload,
|
||||
sizeof(ubx_cfg_pm2.payload));
|
||||
_ubx_send_message((ubx_message_t*)&ubx_cfg_rxm,
|
||||
(uint8_t*)&ubx_cfg_rxm.payload,
|
||||
sizeof(ubx_cfg_rxm.payload));
|
||||
|
||||
}
|
||||
/**
|
||||
* Init
|
||||
*/
|
||||
|
@ -457,6 +486,9 @@ void gps_init(void)
|
|||
/* Set which GNSS constellation we'd like to use */
|
||||
gps_set_gnss();
|
||||
|
||||
/* Set the power management settings */
|
||||
gps_set_powermanagement();
|
||||
|
||||
/* Set the timepulse */
|
||||
gps_set_timepulse_five(GPS_TIMEPULSE_FREQ);
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue