Skip to content
Snippets Groups Projects
Commit b56c003f authored by Carl Philipp Klemm's avatar Carl Philipp Klemm
Browse files

add support for controling watchdog and periodic recal for newer firmwares

parent 998a059b
No related branches found
No related tags found
No related merge requests found
...@@ -300,6 +300,23 @@ int coincellhell_reset(struct coincellhell* hell) ...@@ -300,6 +300,23 @@ int coincellhell_reset(struct coincellhell* hell)
return 0; return 0;
} }
int coincellhell_enable_watchdog(struct coincellhell* hell)
{
int ret;
while((ret = usbshm_writeControlTransfer(hell->priv, COMMAND_ENABLE_WATCHDOG, NULL, 0, 0, 0)) == USBSHM_ERROR_AGAIN)
usleep(100000);
return ret;
}
int coincellhell_set_periodic_recal(struct coincellhell* hell, bool recal)
{
int ret;
while((ret = usbshm_writeControlTransfer(hell->priv, COMMAND_ENABLE_WATCHDOG, NULL, 0, recal, 0)) == USBSHM_ERROR_AGAIN)
usleep(100000);
return ret;
}
void coincellhell_disconnect(struct coincellhell* hell) void coincellhell_disconnect(struct coincellhell* hell)
{ {
if(!hell || !hell->priv) if(!hell || !hell->priv)
...@@ -329,3 +346,4 @@ const char* coincellhell_string_for_fault(fault_t fault) ...@@ -329,3 +346,4 @@ const char* coincellhell_string_for_fault(fault_t fault)
} }
} }
...@@ -176,6 +176,8 @@ uint16_t coincellhell_read_eeprom(struct coincellhell* hell, uint16_t addr); ...@@ -176,6 +176,8 @@ uint16_t coincellhell_read_eeprom(struct coincellhell* hell, uint16_t addr);
uint8_t coincellhell_read_oscal(struct coincellhell* hell); uint8_t coincellhell_read_oscal(struct coincellhell* hell);
uint32_t coincellhell_get_seconds(struct coincellhell* hell); uint32_t coincellhell_get_seconds(struct coincellhell* hell);
const uint8_t* coincellhell_get_fw_git_revision(struct coincellhell* hell); const uint8_t* coincellhell_get_fw_git_revision(struct coincellhell* hell);
int coincellhell_enable_watchdog(struct coincellhell* hell);
int coincellhell_set_periodic_recal(struct coincellhell* hell, bool recal);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
#pragma once #pragma once
/**
Api to controll EISmultiplexer devices.
* @addtogroup API User API
* This api allows you to controll the EISmultiplexer device.
* @{
*/
typedef enum { typedef enum {
COMMAND_LED_ON = 0, COMMAND_LED_ON = 0,
COMMAND_LED_OFF, COMMAND_LED_OFF,
...@@ -23,6 +16,8 @@ typedef enum { ...@@ -23,6 +16,8 @@ typedef enum {
COMMAND_WRITE_EEPROM, COMMAND_WRITE_EEPROM,
COMMAND_READ_OSCAL, COMMAND_READ_OSCAL,
COMMAND_GET_FIRMWARE_GITREV, COMMAND_GET_FIRMWARE_GITREV,
COMMAND_ENABLE_WATCHDOG,
COMMAND_SET_RECAL
} usb_command_t; } usb_command_t;
typedef enum { typedef enum {
...@@ -40,7 +35,3 @@ typedef enum { ...@@ -40,7 +35,3 @@ typedef enum {
FAULT_UNDERTEMP, FAULT_UNDERTEMP,
FAULT_UNSPECIFIED FAULT_UNSPECIFIED
} fault_t; } fault_t;
/*
* @}
*/
...@@ -50,6 +50,8 @@ static void print_commands(void) ...@@ -50,6 +50,8 @@ static void print_commands(void)
puts("read [ADDRESS] [LENGTH]\t | read from the device eeprom at address"); puts("read [ADDRESS] [LENGTH]\t | read from the device eeprom at address");
puts("write [ADDRESS] [LENGTH] | write to the device eeprom at address"); puts("write [ADDRESS] [LENGTH] | write to the device eeprom at address");
puts("git\t\t\t | get the git revision of the firmware on the device"); puts("git\t\t\t | get the git revision of the firmware on the device");
puts("watchdog\t\t\t | enables the on device command watchdog");
puts("recal [BOOLEAN]\t\t | enables or disables periodic recal");
} }
static int convert_string_to_heater_id(const char* str) static int convert_string_to_heater_id(const char* str)
...@@ -345,6 +347,26 @@ static int process_commands(char** commands, size_t command_count, struct coince ...@@ -345,6 +347,26 @@ static int process_commands(char** commands, size_t command_count, struct coince
const uint8_t* rev = coincellhell_get_fw_git_revision(hell); const uint8_t* rev = coincellhell_get_fw_git_revision(hell);
printf("Git: %x%x%x%x%x%x%x%x\n", rev[0], rev[1], rev[2], rev[3], rev[4], rev[5], rev[6], rev[7]); printf("Git: %x%x%x%x%x%x%x%x\n", rev[0], rev[1], rev[2], rev[3], rev[4], rev[5], rev[6], rev[7]);
} }
else if(strcmp(commands[0], "watchdog") == 0)
{
ret = coincellhell_enable_watchdog(hell);
if(ret < 0)
puts("could not enable watchdog");
}
else if(strcmp(commands[0], "recal") == 0)
{
if(command_count < 2)
{
printf("Usage %s %s [BLOOEAN]\n", name, commands[0]);
return 2;
}
bool enable = strtol(commands[1], NULL, 10);
printf("Seting recal to %s\n", enable ? "true" : "false");
ret = coincellhell_set_periodic_recal(hell, enable);
if(ret < 0)
puts("could not enable watchdog");
}
else else
{ {
printf("%s is not a valid command!", commands[0]); printf("%s is not a valid command!", commands[0]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment