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

Add support for the new fault type value

parent d2647464
No related branches found
No related tags found
No related merge requests found
......@@ -117,6 +117,7 @@ int coincellhell_get_state(struct coincellhell* hell, uint8_t heater, struct hea
state->ready = buf[0] & (1 << 1);
state->ramp = buf[0] & (1 << 2);
state->fault = buf[0] & (1 << 3);
state->faultType = buf[6];
state->setpoint = *setpoint/10.0f;
state->rampTarget = *rampTarget/10.0f;
......@@ -234,3 +235,23 @@ void coincellhell_disconnect(struct coincellhell* hell)
hell->priv = NULL;
}
const char* coincellhell_string_for_fault(fault_t fault)
{
switch(fault)
{
case FAULT_NONE:
return "no fault detected";
case FAULT_FRONT_SENSOR:
return "unable to read from front sensor";
case FAULT_SIDE_SENSOR:
return "unable to read from side sensor";
case FAULT_OVERTEMP:
return "system shutdown due to a overtemperature event";
case FAULT_UNDERTEMP:
return "system shutdown due to a undertemperature event";
case FAULT_UNSPECIFIED:
default:
return "a unspecified fault occured";
}
}
......@@ -59,6 +59,8 @@ struct heater_state
bool ramp;
/** true if the system has detected a fault with this heater*/
bool fault;
/** the detected fault type as a fault_t enum*/
fault_t faultType;
/** current command (0-255) that is being sent to the dac for this heater*/
uint8_t dacCommand;
/** current target temperature for this heater*/
......@@ -156,6 +158,13 @@ int coincellhell_set_led(struct coincellhell* hell, bool on);
*/
void coincellhell_disconnect(struct coincellhell* hell);
/**
* @brief Returns a human readable string for a given fault.
* @param fault the fault code
* @return a const string describeing the fault
*/
const char* coincellhell_string_for_fault(fault_t fault);
int coincellhell_write_eeprom(struct coincellhell* hell, uint16_t addr, uint16_t value);
uint16_t coincellhell_read_eeprom(struct coincellhell* hell, uint16_t addr);
uint8_t coincellhell_read_oscal(struct coincellhell* hell);
......
......@@ -31,6 +31,15 @@ typedef enum {
TEMP_LOCATION_INVALID,
} temperature_sensor_location_t;
typedef enum {
FAULT_NONE = 0,
FAULT_FRONT_SENSOR,
FAULT_SIDE_SENSOR,
FAULT_OVERTEMP,
FAULT_UNDERTEMP,
FAULT_UNSPECIFIED
} fault_t;
/*
* @}
*/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment