Skip to content

Commit

Permalink
Implement OS Handler
Browse files Browse the repository at this point in the history
  • Loading branch information
elsaigh committed Oct 30, 2024
1 parent 3481a4b commit cc50f5b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lm75bd/lm75bd.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ error_code_t readTempLM75BD(uint8_t devAddr, float *temp) {
// if 11 bit is set, sign is -ve, so convert the 11 bit val to its equivalent 16 bit val
// otherwise, sign is +ve, and the 11 bit val will be the same in 16 bits
if (temp_reg_val & 0x0400U) {
// by simply setting everything above the 11 bits to 1 (top 5 bits here)
temp_reg_val |= 0xF800U;
// by simply setting everything above the 11 bits to 1 (top 5 bits here)
temp_reg_val |= 0xF800U;
}
printf("Temperature Register Value: %i\n", temp_reg_val);

Expand Down
22 changes: 18 additions & 4 deletions services/thermal_mgr/thermal_mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ error_code_t thermalMgrSendEvent(thermal_mgr_event_t *event) {

void osHandlerLM75BD(void) {
/* Implement this function */
thermal_mgr_event_t osEvent = {0};
osEvent.type = THERMAL_MGR_EVENT_OS_CMD;

thermalMgrSendEvent(&osEvent);
}

static void thermalMgr(void *pvParameters) { // what is pvParameters used for?
Expand All @@ -60,12 +64,22 @@ static void thermalMgr(void *pvParameters) { // what is pvParameters used for?

while (1) {

if (xQueueReceive(thermalMgrQueueHandle, &queueEventItemBuffer, (TickType_t) 10) == pdPASS
&& queueEventItemBuffer.type == THERMAL_MGR_EVENT_MEASURE_TEMP_CMD) {
if (xQueueReceive(thermalMgrQueueHandle, &queueEventItemBuffer, (TickType_t) 10) == pdPASS) {

float tempC;
readTempLM75BD(LM75BD_OBC_I2C_ADDR, &tempC);

float tempC;
readTempLM75BD(LM75BD_OBC_I2C_ADDR, &tempC);
if (queueEventItemBuffer.type == THERMAL_MGR_EVENT_MEASURE_TEMP_CMD) {
addTemperatureTelemetry(tempC);
} else if (queueEventItemBuffer.type == THERMAL_MGR_EVENT_OS_CMD) {
if (tempC > 75.0) {
overTemperatureDetected();
} else {
safeOperatingConditions();
}
// To reset the OS interrupt
readTempLM75BD(LM75BD_OBC_I2C_ADDR, &tempC);
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions services/thermal_mgr/thermal_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

typedef enum {
THERMAL_MGR_EVENT_MEASURE_TEMP_CMD,
THERMAL_MGR_EVENT_OS_CMD,

} thermal_mgr_event_type_t;

Expand Down

0 comments on commit cc50f5b

Please sign in to comment.