Skip to content
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

Open
wants to merge 3 commits into
base: level3
Choose a base branch
from

Conversation

not-finley
Copy link

Passed Tests:
TestsSuite

Integration Test:
Integration Test

Copy link

@Yarik-Popov Yarik-Popov left a 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

Comment on lines +36 to +37
i2cSendTo(devAddr, &pointerRegister, sizeof(pointerRegister));
i2cReceiveFrom(devAddr, tempData, sizeof(tempData));

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

Comment on lines +42 to +49
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;
}

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) {

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);

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;

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);

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);

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) {

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,

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];
Copy link
Contributor

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;
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants