From cdaa741c9426002f29f26b0c5ee70fa50f1435cd Mon Sep 17 00:00:00 2001 From: "Eric B. Decker" Date: Wed, 30 Jun 2021 21:20:06 -0700 Subject: [PATCH] ubx: add basic support for upd/sos, save on shutdown --- include/ublox_msg.h | 32 ++++++++++++++++++++++ tools/utils/tagcore/tagcore/__init__.py | 2 +- tos/chips/ublox/ublox_driver.h | 36 +++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/include/ublox_msg.h b/include/ublox_msg.h index 1e932877..3a2a50e1 100644 --- a/include/ublox_msg.h +++ b/include/ublox_msg.h @@ -728,4 +728,36 @@ typedef struct { } PACKED ubx_tim_tp_t; +/* UBX_CLASS_UPD (09) */ +enum { + UBX_UPD_SOS = 0x14, /* save on shutdown */ + UBX_UPD_SOS_CREATE = 0, + UBX_UPD_SOS_CLEAR = 1, + UBX_UPD_SOS_ACK = 2, + UBX_UPD_SOS_RESTORED = 3, + + UBX_UPD_SOS_ACK_NACK = 0, + UBX_UPD_SOS_ACK_ACK = 1, + + UBX_UPD_SOS_RSP_UNK = 0, /* weird */ + UBX_UPD_SOS_RSP_FAIL = 1, /* nope */ + UBX_UPD_SOS_RSP_OK = 2, /* restored */ + UBX_UPD_SOS_RSP_NONE = 3, /* no backup present */ +}; + +typedef struct { + uint8_t sync1; + uint8_t sync2; + uint8_t class; /* upd - 09 */ + uint8_t id; /* sos - 14 */ + uint16_t len; /* 4/8 bytes */ + uint8_t cmd; + uint8_t reserved1[3]; + uint8_t rsp; + uint8_t reserved2[3]; + uint8_t chkA; + uint8_t chkB; +} PACKED ubx_upd_sos_t; + + #endif /* __UBLOX_MSG_H__ */ diff --git a/tools/utils/tagcore/tagcore/__init__.py b/tools/utils/tagcore/tagcore/__init__.py index d6b1b45d..fae58ca6 100644 --- a/tools/utils/tagcore/tagcore/__init__.py +++ b/tools/utils/tagcore/tagcore/__init__.py @@ -3,7 +3,7 @@ @author: Eric B. Decker """ -__version__ = '0.4.10.dev1' +__version__ = '0.4.10.dev2' __all__ = [ 'CORE_REV', # core_rev.py diff --git a/tos/chips/ublox/ublox_driver.h b/tos/chips/ublox/ublox_driver.h index 53af5b52..f270ab33 100644 --- a/tos/chips/ublox/ublox_driver.h +++ b/tos/chips/ublox/ublox_driver.h @@ -273,6 +273,16 @@ const uint8_t ubx_cfg_rst_full_hw[] = { 0x23, 0x9b, }; +const uint8_t ubx_cfg_rst_stop_gnss[] = { + UBX_SYNC1, UBX_SYNC2, + UBX_CLASS_CFG, UBX_CFG_RST, + 0x04, 0x00, /* len 4 bytes */ + 0x00, 0x00, /* no clear, hot start if possible */ + 0x08, /* resetMode: 8 gnss stop */ + 0x00, /* reserved */ + 0x16, 0x74, +}; + const uint8_t ubx_cfg_tp5_poll[] = { UBX_SYNC1, UBX_SYNC2, UBX_CLASS_CFG, UBX_CFG_TP5, /* time pulse 0 */ @@ -354,6 +364,32 @@ const uint8_t ubx_tim_tp_poll[] = { }; +const uint8_t ubx_upd_sos_create[] = { + UBX_SYNC1, UBX_SYNC2, + UBX_CLASS_UPD, UBX_UPD_SOS, /* save on shutdown */ + 0x04, 0x00, /* length, 4 bytes */ + 0x00, /* cmd 0, create */ + 0x00, 0x00, 0x00, + 0x21, 0xEC, +}; + +const uint8_t ubx_upd_sos_clear[] = { + UBX_SYNC1, UBX_SYNC2, + UBX_CLASS_UPD, UBX_UPD_SOS, /* save on shutdown */ + 0x04, 0x00, /* length, 4 bytes */ + 0x01, /* cmd 1, clear */ + 0x00, 0x00, 0x00, + 0x22, 0xF0, +}; + +const uint8_t ubx_upd_sos_poll[] = { + UBX_SYNC1, UBX_SYNC2, + UBX_CLASS_UPD, UBX_UPD_SOS, /* save on shutdown */ + 0x00, 0x00, /* length, 0 bytes */ + 0x22, 0xF0, +}; + + /* * Instrumentation, Stats *