-
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
Successfully completed the Onboarding Challenge #160
base: level3
Are you sure you want to change the base?
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.
Overall good first start. Some changes are needed
i2cSendTo(devAddr, &pointerRegister, sizeof(pointerRegister)); | ||
i2cReceiveFrom(devAddr, tempData, sizeof(tempData)); |
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.
These should be wrapped inside of the RETURN_IF_ERROR_CODE macro
if (rawTemperature & 0x0400) { | ||
// If the 11th bit is set, take the two's complement of the 11-bit number | ||
rawTemperature |= 0xF800; | ||
*temp = rawTemperature * 0.125; | ||
} else { | ||
// If the 11th bit is not set, temperature is positive | ||
*temp = rawTemperature * 0.125; | ||
} |
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 code is redundant, just do multiplication and store it
@@ -27,7 +27,27 @@ error_code_t lm75bdInit(lm75bd_config_t *config) { | |||
|
|||
error_code_t readTempLM75BD(uint8_t devAddr, float *temp) { |
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 that the temp is not null before use
@@ -42,19 +42,37 @@ void initThermalSystemManager(lm75bd_config_t *config) { | |||
} | |||
|
|||
error_code_t thermalMgrSendEvent(thermal_mgr_event_t *event) { | |||
/* Send an event to the thermal manager queue */ | |||
|
|||
xQueueSend(thermalMgrQueueHandle, event, portMAX_DELAY); |
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.
Lots of things need to be changed here
- always check non-void functions for a return code
- check that the event and thermalMgrQueueHandle aren't null, returning the appropriate error codes
- the delay should be 0 and not portMAX_DELAY as that will block when called in isr if the queue is full which is not what we want
if(xQueueReceive(thermalMgrQueueHandle, &pvbuffer, portMAX_DELAY)) { | ||
if (pvbuffer.type == THERMAL_MGR_EVENT_MEASURE_TEMP_CMD) { | ||
float temp; | ||
lm75bd_config_t config = *(lm75bd_config_t *) pvParameters; |
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.
Pull this to be before the loop
if (pvbuffer.type == THERMAL_MGR_EVENT_MEASURE_TEMP_CMD) { | ||
float temp; | ||
lm75bd_config_t config = *(lm75bd_config_t *) pvParameters; | ||
readTempLM75BD(config.devAddr, &temp); |
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.
LOG_IF_ERROR_CODE followed by a if(errCode != success) continue; line
if (pvbuffer.type == THERMAL_MGR_EVENT_INTERUPT) { | ||
float temp; | ||
lm75bd_config_t config = *(lm75bd_config_t *) pvParameters; | ||
readTempLM75BD(config.devAddr, &temp); |
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 thing here
|
||
thermal_mgr_event_t pvbuffer; | ||
if(xQueueReceive(thermalMgrQueueHandle, &pvbuffer, portMAX_DELAY)) { | ||
if (pvbuffer.type == THERMAL_MGR_EVENT_MEASURE_TEMP_CMD) { |
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.
Add an else clause that logs a custom error code for invalid events received
@@ -5,6 +5,7 @@ | |||
|
|||
typedef enum { | |||
THERMAL_MGR_EVENT_MEASURE_TEMP_CMD, | |||
THERMAL_MGR_EVENT_INTERUPT, |
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.
Make this name more descriptive by including OS or OVER_TEMP inside of it
error_code_t errCode; | ||
|
||
uint8_t pointerRegister = 0x00; | ||
uint8_t tempData[2]; |
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.
generally a good idea to initialize all variables. uint8_t tempData[2] = {0};
return ERR_CODE_SUCCESS; | ||
} | ||
|
||
void osHandlerLM75BD(void) { | ||
/* Implement this function */ | ||
thermal_mgr_event_type_t event = THERMAL_MGR_EVENT_INTERUPT; |
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 is of type thermal_mgr_event_type_t
, but the receiving queue is expecting type thermal_mgr_event_t
Passed Tests:
Integration Test: