Skip to content

Commit

Permalink
Fixed gnss reinitialization logic
Browse files Browse the repository at this point in the history
Made the system capable of reinitilizing the GNSS chip after powering it
off.

Signed-off-by: Jared Baumann <[email protected]>
  • Loading branch information
jtbaumann committed Jun 13, 2023
1 parent 65f2077 commit deab564
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
18 changes: 17 additions & 1 deletion samples/tmo_shell/src/tmo_gnss.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,23 @@ int gnss_version(void)
return rc;
}

int gnss_cold_start(void)
{
return sensor_attr_set(cxd5605,SENSOR_CHAN_ALL,SENSOR_ATTR_CXD5605_COLD_START, NULL);
}

int gnss_warm_start(void)
{
return sensor_attr_set(cxd5605,SENSOR_CHAN_ALL,SENSOR_ATTR_CXD5605_WARM_START, NULL);
}


int gnss_hot_start(void)
{
return sensor_attr_set(cxd5605,SENSOR_CHAN_ALL,SENSOR_ATTR_CXD5605_HOT_START_TTFF, NULL);
}


static uint8_t current_state = ENABLE_HARDWARE;

void gnss_enable_hardware(void)
Expand Down Expand Up @@ -166,7 +183,6 @@ void gnss_thread(void *a, void *b, void *c)

switch (current_state) {
case ENABLE_HARDWARE:
rc = sensor_attr_set(cxd5605,SENSOR_CHAN_ALL,SENSOR_ATTR_CXD5605_CALLBACK, &sens_values);
sens_values.val1 = 1;
sens_values.val2 = (int32_t)callback_1pps;
rc = sensor_attr_set(cxd5605,SENSOR_CHAN_ALL,SENSOR_ATTR_CXD5605_PULSE, &sens_values);
Expand Down
3 changes: 3 additions & 0 deletions samples/tmo_shell/src/tmo_gnss.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ void setup_gnss(void);
void readGNSSData(void);
void ln_buf_gen(void);
int gnss_version(void);
int gnss_cold_start(void);
int gnss_warm_start(void);
int gnss_hot_start(void);

#ifdef TMO_GNSS
/* variables for tmo_gnss.c */
Expand Down
52 changes: 49 additions & 3 deletions samples/tmo_shell/src/tmo_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -1677,13 +1677,52 @@ int cmd_gnss_version(const struct shell *shell, size_t argc, char **argv)

ret = gnss_version();
if (ret) {
printf("%s:%d - Error reading GNSS version (%d)\n", __FUNCTION__, __LINE__, ret);
shell_error(shell, "%s:%d - Error reading GNSS version (%d)\n", __FUNCTION__, __LINE__, ret);
return 1;
}

return 0;
}

int cmd_gnss_start_cold(const struct shell *shell, size_t argc, char **argv)
{
int ret;

ret = gnss_cold_start();
if (ret) {
shell_error(shell, "%s:%d - Error reading GNSS version (%d)\n", __FUNCTION__, __LINE__, ret);
return EIO;
}

return 0;
}

int cmd_gnss_start_warm(const struct shell *shell, size_t argc, char **argv)
{
int ret;

ret = gnss_warm_start();
if (ret) {
shell_error(shell, "%s:%d - Error reading GNSS version (%d)\n", __FUNCTION__, __LINE__, ret);
return EIO;
}

return 0;
}

int cmd_gnss_start_hot(const struct shell *shell, size_t argc, char **argv)
{
int ret;

ret = gnss_hot_start();
if (ret) {
shell_error(shell, "%s:%d - Error reading GNSS version (%d)\n", __FUNCTION__, __LINE__, ret);
return EIO;
}

return 0;
}

void print_set_modem_edrx_usage(const struct shell *shell)
{
shell_print(shell, "tmo modem <iface> edrx <mode> <Act-type> <edrx value>");
Expand Down Expand Up @@ -2755,6 +2794,14 @@ SHELL_STATIC_SUBCMD_SET_CREATE(tmo_file_sub, SHELL_CMD(cp, NULL, "Copy a file",
SHELL_CMD(sha1, NULL, "Compute a file SHA1", cmd_sha1),
SHELL_SUBCMD_SET_END);

SHELL_STATIC_SUBCMD_SET_CREATE(tmo_gnss_sub,
SHELL_CMD(location, NULL, "Get GNSS latitude and longitude", cmd_gnss),
SHELL_CMD(start_cold, NULL, "Perform a cold start", cmd_gnss_start_cold),
SHELL_CMD(start_hot, NULL, "Perform a hot start", cmd_gnss_start_hot),
SHELL_CMD(start_warm, NULL, "Perform a warm start", cmd_gnss_start_warm),
SHELL_CMD(version, NULL, "Get GNSS chip version", cmd_gnss_version),
SHELL_SUBCMD_SET_END);

SHELL_STATIC_SUBCMD_SET_CREATE(
sub_tmo, SHELL_CMD(battery, &tmo_battery_sub, "Battery and charger status", NULL),
SHELL_CMD(ble, &tmo_ble_sub, "BLE test commands", NULL),
Expand All @@ -2768,15 +2815,14 @@ SHELL_STATIC_SUBCMD_SET_CREATE(
SHELL_CMD(dfu, &tmo_dfu_sub, "Device FW updates", NULL),
SHELL_CMD(dns, NULL, "Perform dns lookup", cmd_dnslookup),
SHELL_CMD(file, &tmo_file_sub, "File commands", NULL),
SHELL_CMD(gnssversion, NULL, "Get GNSS chip version", cmd_gnss_version),
SHELL_CMD(gnss, &tmo_gnss_sub, "GNSS commands", NULL),
SHELL_CMD(http, NULL, "Get http URL", cmd_http),
SHELL_CMD(hwid, NULL, "Read the HWID divider voltage", cmd_hwid),
SHELL_CMD(ifaces, NULL, "List network interfaces", cmd_list_ifaces),
SHELL_CMD(json, &tmo_json_sub, "JSON data options", NULL),
#if CONFIG_TMO_SHELL_BUILD_EK
SHELL_CMD(kermit, NULL, "Embedded kermit", cmd_ekermit),
#endif
SHELL_CMD(location, NULL, "Get latitude and longitude", cmd_gnss),
#if CONFIG_MODEM
SHELL_CMD(modem, NULL, "Modem status and control", &cmd_modem),
#endif
Expand Down

0 comments on commit deab564

Please sign in to comment.