Skip to content

Commit

Permalink
Submission
Browse files Browse the repository at this point in the history
  • Loading branch information
wabarurse committed Oct 27, 2024
1 parent 7e1a8dc commit 7b200d4
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
1 change: 1 addition & 0 deletions Testing/Temporary/CTestCostData.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
3 changes: 3 additions & 0 deletions Testing/Temporary/LastTest.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Start testing: Oct 27 01:33 EDT
----------------------------------------------------------
End testing: Oct 27 01:33 EDT
16 changes: 16 additions & 0 deletions lm75bd/lm75bd.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,23 @@ error_code_t lm75bdInit(lm75bd_config_t *config) {

error_code_t readTempLM75BD(uint8_t devAddr, float *temp) {
/* Implement this driver function */
uint8_t buf[1] = {0x00};
uint8_t buf_[2];

i2cSendTo(devAddr, buf, 1);
i2cReceiveFrom(devAddr, buf_, 2);

uint16_t temperature = (buf_[0] << 8 | buf_[1]);
int16_t t = temperature >> 5;


if(t & 0x0400) { // if the first bit is 1
t |= 0xFC00;
}

*temp = t * 0.125;


return ERR_CODE_SUCCESS;
}

Expand Down
2 changes: 1 addition & 1 deletion lm75bd/lm75bd.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <stdint.h>

/* LM75BD I2C Device Address */
#define LM75BD_OBC_I2C_ADDR /* Define the address here */
#define LM75BD_OBC_I2C_ADDR 0b1001111 /* Define the address here */

/* LM75BD Configuration Values */
#define LM75BD_DEV_OP_MODE_NORMAL 0x00U
Expand Down
26 changes: 24 additions & 2 deletions services/thermal_mgr/thermal_mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,41 @@ void initThermalSystemManager(lm75bd_config_t *config) {

error_code_t thermalMgrSendEvent(thermal_mgr_event_t *event) {
/* Send an event to the thermal manager queue */

if(xQueueSend(thermalMgrQueueHandle, event, (TickType_t) 10) != pdTRUE) {
return ERR_CODE_QUEUE_FULL;
}
return ERR_CODE_SUCCESS;
}

void osHandlerLM75BD(void) {
/* Implement this function */
thermal_mgr_event_t event = { .type = OS_MGR_EVENT_OVER_TEMP };
xQueueSend(thermalMgrQueueHandle, &event, (TickType_t) 10);
}

static void thermalMgr(void *pvParameters) {
/* Implement this task */
thermal_mgr_event_t event;
float temp;

while (1) {

if(xQueueReceive(thermalMgrQueueHandle, &event, (TickType_t) 10) == pdTRUE) {
if(event.type == THERMAL_MGR_EVENT_MEASURE_TEMP_CMD) {
if(readTempLM75BD(LM75BD_OBC_I2C_ADDR, &temp) == ERR_CODE_SUCCESS) {
addTemperatureTelemetry(temp);
}
} else if(event.type == OS_MGR_EVENT_OVER_TEMP) {
if(readTempLM75BD(LM75BD_OBC_I2C_ADDR, &temp) == ERR_CODE_SUCCESS) {
if(temp > T_HYS) {
overTemperatureDetected();
} else {
safeOperatingConditions();
}
}
}
}
}

}

void addTemperatureTelemetry(float tempC) {
Expand Down
3 changes: 3 additions & 0 deletions services/thermal_mgr/thermal_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
#include "lm75bd.h"
#include "errors.h"

#define T_HYS 75

typedef enum {
THERMAL_MGR_EVENT_MEASURE_TEMP_CMD,
OS_MGR_EVENT_OVER_TEMP,

} thermal_mgr_event_type_t;

Expand Down

0 comments on commit 7b200d4

Please sign in to comment.