-
Notifications
You must be signed in to change notification settings - Fork 171
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
Completed Bootcamp #93
Conversation
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.
Looks good, just a few things, but I would try to fix the indentation to make it easier to read and review
lm75bd/lm75bd.c
Outdated
const uint16_t sign_bit_mask = 0x0400; | ||
const uint16_t temperature_bits_mask = 0x03FF; |
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.
use macros for these instead of const variables
lm75bd/lm75bd.c
Outdated
|
||
|
||
// uint16_t numBytes = 2; | ||
errCode = i2cSendTo(devAddr,&pointer_register_value, 1U); // read the temperature from the sensor |
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.
not need to explicitly typecast the constant
services/thermal_mgr/thermal_mgr.c
Outdated
error_code_t errCode = readTempLM75BD(LM75BD_OBC_I2C_ADDR, temperature); // Use your readTempLM75BD function | ||
|
||
if (temperature > HYS_THRESHOLD) { | ||
// Temperature is above or equal to the overtemperature threshold | ||
overTemperatureDetected(); | ||
} else if (temperature <= HYS_THRESHOLD) { | ||
// Temperature is below or equal to the hysteresis threshold | ||
safeOperatingConditions(); | ||
} |
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.
we should not be calling readTemp in an ISR for 2 reasons
- readTemp will call the i2c helper functions which will block on the I2C bus mutex and we should never be trying to block in an ISR
- I2C is relatively slow and we want ISRs to always be as short and quick as possible to keep our system responsive
services/thermal_mgr/thermal_mgr.c
Outdated
float* temperature; | ||
// Question: a, I using the correct devAddr | ||
error_code_t errCode = readTempLM75BD(LM75BD_OBC_I2C_ADDR, temperature); // Use your readTempLM75BD function |
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.
since you are declaring temperature to be a pointer to a float but not setting it to anything, when you pass it into this function it is a NULL pointer so readTemp will return an error
@@ -43,18 +46,46 @@ void initThermalSystemManager(lm75bd_config_t *config) { | |||
|
|||
error_code_t thermalMgrSendEvent(thermal_mgr_event_t *event) { | |||
/* Send an event to the thermal manager queue */ | |||
|
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.
check if event is null
@@ -43,18 +46,46 @@ void initThermalSystemManager(lm75bd_config_t *config) { | |||
|
|||
error_code_t thermalMgrSendEvent(thermal_mgr_event_t *event) { | |||
/* Send an event to the thermal manager queue */ |
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.
check to make sure queue has been created
services/thermal_mgr/thermal_mgr.c
Outdated
BaseType_t send = xQueueSend(thermalMgrQueueHandle, event, 0); // 0 ticks to wait | ||
if (send != pdPASS) return ERR_CODE_INVALID_QUEUE_MSG/*failed case*/; |
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.
you can just do if(xQueueSend(thermalMgrQueueHandle, event, 0) != pdPASS)
instead of declaring a new variable
services/thermal_mgr/thermal_mgr.c
Outdated
if (errCode != ERR_CODE_SUCCESS) /*do something*/; | ||
// Send it as telemetry | ||
addTemperatureTelemetry(*temperature); |
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.
you shuld only be adding the telemetry temperature if the read was successful
services/thermal_mgr/thermal_mgr.c
Outdated
// Kemi: Obtain type how | ||
if (receivedEvent.type == THERMAL_MGR_EVENT_MEASURE_TEMP_CMD) { | ||
// collect temperature data using drive fcn | ||
float* temperature; |
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.
same comment as in the os handler
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.
Just a couple more small changes
lm75bd/lm75bd.c
Outdated
|
||
// to implement this we need to select the sensor's internaltemeprature register (7.4.1) | ||
uint8_t pointer_register_value = 0x00; // Point to the Temperature Register | ||
devAddr = LM75BD_OBC_I2C_ADDR; |
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.
device address is passed into the function, so you don't need to set it again. You can just use the address that was passed in, this is because if we have multiple lm75bd temperature sensors each would have a different address, so we would want the address to be a parameter to choose which sensor we want to read from
services/thermal_mgr/thermal_mgr.c
Outdated
|
||
if(event == NULL) return ERR_CODE_INVALID_ARG; | ||
if(thermalMgrQueueHandle == NULL) return ERR_CODE_INVALID_QUEUE_MSG; | ||
if (xQueueSend(thermalMgrQueueHandle, event, 0) != pdPASS) return ERR_CODE_INVALID_QUEUE_MSG/*failed case*/; |
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.
this function would only fail if the queue is full, not due to an invalid queue msg
// Team Lead -> u dont necessarily need to read the temperature in the OShandler, u just need a way to communicate that an | ||
// interrupt has happened so that u can read the temperature and deal with it from outside to OS handler | ||
float temperature; | ||
error_code_t errCode = readTempLM75BD(LM75BD_OBC_I2C_ADDR, &temperature); // Use your readTempLM75BD function |
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.
check whether the readTempLM75BD was successful or not
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.
LGTM
Purpose
Changes
Testing
Outstanding Changes
None.