-
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
1SirFishy Onboarding #95
Conversation
data sheet and also started working on the function that reads temperatures from LM75BD. Positive readings work, but tests say that the address and negative readings are incorrect."
ure register of the driver is successful. Also successfully converts the readings to celsius
to static in the driver read function
JUST POINTERS TO FIRST INDEX, NOW PASSING buf1 and buf2 TO I2CSEND AND I2CRECEIVE INSTEAD OF &buf1 AND &buf2) TO FIX MEANINGLESS TESTING ERRORS
@@ -27,8 +27,34 @@ error_code_t lm75bdInit(lm75bd_config_t *config) { | |||
} | |||
|
|||
error_code_t readTempLM75BD(uint8_t devAddr, float *temp) { | |||
/* Implement this driver 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 if temp is NULL
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.
I dont think this was addressed
lm75bd/lm75bd.c
Outdated
buf1[0] = 0b00000000; | ||
i2cSendTo(devAddr, buf1 , 1); | ||
i2cReceiveFrom(devAddr, buf2, 2); | ||
uint16_t tempReading = 0b0000000000000000; |
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 use 0 for readabity since 0 = 0b0000000000000000
lm75bd/lm75bd.c
Outdated
tempReading = tempReading | buf2[0]; | ||
tempReading = tempReading << 8; | ||
tempReading = tempReading | buf2[1]; |
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 can be done in one step instead of splitting it up into 3 just do tempReading |= (buf2[0] << 8) | buf2[1];
lm75bd/lm75bd.c
Outdated
if (tempReading < 1024) | ||
{ | ||
*temp = (float)tempReading / 8.0; | ||
} | ||
|
||
else | ||
{ | ||
tempReading = tempReading ^ 0b0000011111111111; | ||
*temp = (float)((-(tempReading + 1.0)) / 8.0); | ||
} |
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.
if you make tempReading
and int you don't need this you can just do *temp = (float)tempReading*0.125
services/thermal_mgr/thermal_mgr.c
Outdated
if (event.type == THERMAL_MGR_EVENT_MEASURE_TEMP_CMD) | ||
{ | ||
float temp; | ||
readTempLM75BD(LM75BD_OBC_I2C_ADDR, &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 the return value to see if the function failed
services/thermal_mgr/thermal_mgr.c
Outdated
else if (event.type == THERMAL_MGR_EVENT_CHECK_FOR_INTPT) | ||
{ | ||
float temp; | ||
readTempLM75BD(LM75BD_OBC_I2C_ADDR, &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 the return value to see if the function failed
services/thermal_mgr/thermal_mgr.c
Outdated
{ | ||
overTemperatureDetected(); | ||
} | ||
if (temp <= 75) |
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 else since if its not > 75 then it will be <= 75
lm75bd/lm75bd.c
Outdated
uint8_t buf1[1]; | ||
uint8_t buf2[2]; | ||
buf1[0] = 0b00000000; | ||
i2cSendTo(devAddr, buf1 , 1); |
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 the return value to see if the function failed
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 the provided logging macros
lm75bd/lm75bd.c
Outdated
uint8_t buf2[2]; | ||
buf1[0] = 0b00000000; | ||
i2cSendTo(devAddr, buf1 , 1); | ||
i2cReceiveFrom(devAddr, buf2, 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.
check the return value to see if the function failed
changing binary representations to integers in driver functions. Also included error checks, as well as input validations for pointer arguments. Did not use error functions such as LOG_IF_ERROR_CODE(functionToCall()) and RETURN_IF_ERROR_CODE(functionToCall()), as these were added to the main repo after I had initially forked and cloned the repo.
in thermal_mgr 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.
just a couple more things
@@ -27,8 +27,34 @@ error_code_t lm75bdInit(lm75bd_config_t *config) { | |||
} | |||
|
|||
error_code_t readTempLM75BD(uint8_t devAddr, float *temp) { | |||
/* Implement this driver 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.
I dont think this was addressed
lm75bd/lm75bd.c
Outdated
/* Implement this driver function */ | ||
uint8_t bufRead[1]; | ||
uint8_t bufWrite[2]; | ||
bufRead[0] = 0; |
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 do uint8_t bufRead[1] = {0}
when you initialize the array
if (temp == NULL) | ||
{ | ||
return ERR_CODE_INVALID_ARG; | ||
} |
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 best to validate the parameters at the top of your function before you do anything else
lm75bd/lm75bd.c
Outdated
error_code_t sendResult = i2cSendTo(devAddr, bufRead , 1); | ||
if (sendResult != ERR_CODE_SUCCESS) | ||
{ | ||
return sendResult; | ||
} | ||
error_code_t receiveResult = i2cReceiveFrom(devAddr,bufWrite, 2); | ||
if (receiveResult != ERR_CODE_SUCCESS) | ||
{ | ||
return receiveResult; | ||
} |
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 use RETURN_IF_ERROR_CODE
so that these errors gets logged as well
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
I read instructions and executed instructions
New Changes
Nothing new, except the style
Testing
Absolutely none. Fully confident it works
Outstanding Changes
N.