-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Thermal Mgr Task #285
base: main
Are you sure you want to change the base?
Changes from 1 commit
c2caffd
d13a987
72b7235
38111b7
19bd58c
fb02de2
83d5389
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,10 +25,7 @@ | |
void obcTaskInitThermalMgr() {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This task should init the lm75bd |
||
static obc_error_code_t collectObcLm75bdTemp(void); | ||
static obc_error_code_t collectObcDs3232Temp(void); | ||
|
||
static obc_error_code_t collectObcCC1120Temp(void); | ||
static obc_error_code_t setObcCC1120TempReading(void); | ||
static obc_error_code_t resetObcCC120TempConfig(void); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will be handled in a different PR (driver functions are being written in it - not in the scope of this PR) |
||
|
||
void obcTaskFunctionThermalMgr(void* pvParameters) { | ||
obc_error_code_t errCode; | ||
|
@@ -39,7 +36,9 @@ void obcTaskFunctionThermalMgr(void* pvParameters) { | |
while (1) { | ||
LOG_IF_ERROR_CODE(collectObcLm75bdTemp()); | ||
LOG_IF_ERROR_CODE(collectObcCC1120Temp()); | ||
LOG_IF_ERROR_CODE(collectObcDs3232Temp()); | ||
LOG_IF_ERROR_CODE(collectObcDs3232Temp()); // RTC | ||
// BMS in pr https://github.com/UWOrbital/OBC-firmware/pull/187 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BMS driver code does not exist; still in PR #187 |
||
digitalWatchdogTaskCheckIn(OBC_SCHEDULER_CONFIG_ID_THERMAL_MGR); | ||
|
||
vTaskDelayUntil(&xLastWakeTime, pdMS_TO_TICKS(THERMAL_MGR_PERIOD_MS)); | ||
|
@@ -60,64 +59,15 @@ static obc_error_code_t collectObcLm75bdTemp(void) { | |
} | ||
|
||
static obc_error_code_t collectObcCC1120Temp(void) { | ||
obc_error_code_t errCode; | ||
// function commented out due to cc1120 driver function being implemented in a different PR | ||
// obc_error_code_t errCode; | ||
|
||
float temp = 0.0f; | ||
RETURN_IF_ERROR_CODE(setObcCC1120TempReading()); | ||
|
||
uint8_t tempData = 0; | ||
// read output voltage on GPIO1 | ||
RETURN_IF_ERROR_CODE( | ||
cc1120ReadSpi(CC1120_REGS_IOCFG1, &tempData, | ||
sizeof(tempData))); // this voltage represents the PTAT voltage but has an error of +/- 10C | ||
// float temp = 0.0f; | ||
// RETURN_IF_ERROR_CODE(readTempCC1120(&temp)); | ||
|
||
// Use Single Point Calibration to get a more accurate temperature reading (within +/- 1C for limited temperature | ||
// range or +/- 2C across -40C to 85C) Can also use Two Point Calibtration for better accuracy | ||
// See sections 1.4 and 1.5 of https://www.ti.com/lit/an/swra415d/swra415d.pdf?ts=1730233031162 (CC112x datasheet) | ||
// for more information | ||
// telemetry_data_t obcTempVal = {.obcTemp = temp, .id = TELEM_OBC_TEMP, .timestamp = getCurrentUnixTime()}; | ||
|
||
telemetry_data_t obcTempVal = {.obcTemp = temp, .id = TELEM_OBC_TEMP, .timestamp = getCurrentUnixTime()}; | ||
|
||
RETURN_IF_ERROR_CODE(addTelemetryData(&obcTempVal)); | ||
|
||
RETURN_IF_ERROR_CODE(resetObcCC120TempConfig()); | ||
|
||
return OBC_ERR_CODE_SUCCESS; | ||
} | ||
|
||
static obc_error_code_t setObcCC1120TempReading(void) { | ||
obc_error_code_t errCode; | ||
|
||
// To read the temperature sensor on the CC1120, first set the GPIO1 pin to analog output via setting 0x80 on IOCFG1 | ||
// (It has no digital reading for temperature) | ||
uint8_t data = 0x80; | ||
RETURN_IF_ERROR_CODE(cc1120WriteSpi(CC1120_REGS_IOCFG1, &data, sizeof(data))); | ||
|
||
// Conifiguration of registers to read output: GBIAS1 to 0x07, ATEST_MODE to 0x0C, ATEST to 0x2A | ||
data = 0x07; | ||
RETURN_IF_ERROR_CODE(cc1120WriteExtAddrSpi(CC1120_REGS_EXT_GBIAS1, &data, sizeof(data))); | ||
data = 0x0C; | ||
RETURN_IF_ERROR_CODE(cc1120WriteExtAddrSpi(CC1120_REGS_EXT_ATEST_MODE, &data, sizeof(data))); | ||
data = 0x2A; | ||
RETURN_IF_ERROR_CODE(cc1120WriteExtAddrSpi(CC1120_REGS_EXT_ATEST, &data, sizeof(data))); | ||
|
||
return OBC_ERR_CODE_SUCCESS; | ||
} | ||
|
||
static obc_error_code_t resetObcCC120TempConfig(void) { | ||
obc_error_code_t errCode; | ||
// reset registers | ||
|
||
uint8_t data = 0; | ||
data = 0x30; | ||
RETURN_IF_ERROR_CODE(cc1120WriteSpi(CC1120_REGS_IOCFG1, &data, sizeof(data))); | ||
|
||
data = CC1120_EXT_DEFAULTS_GBIAS1; | ||
RETURN_IF_ERROR_CODE(cc1120WriteExtAddrSpi(CC1120_REGS_EXT_GBIAS1, &data, sizeof(data))); | ||
data = CC1120_EXT_DEFAULTS_ATEST_MODE; | ||
RETURN_IF_ERROR_CODE(cc1120WriteExtAddrSpi(CC1120_REGS_EXT_ATEST_MODE, &data, sizeof(data))); | ||
data = CC1120_EXT_DEFAULTS_ATEST; | ||
RETURN_IF_ERROR_CODE(cc1120WriteExtAddrSpi(CC1120_REGS_EXT_ATEST, &data, sizeof(data))); | ||
// RETURN_IF_ERROR_CODE(addTelemetryData(&obcTempVal)); | ||
|
||
return OBC_ERR_CODE_SUCCESS; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://discord.com/channels/831191521595621387/1124186460866740314/1301569668242472980
Adding common interface into the header file