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

Shiv Krishnaswamy FW Onboarding #206

Closed
wants to merge 6 commits into from
Closed

Conversation

ShivK01
Copy link

@ShivK01 ShivK01 commented Jan 16, 2025

Purpose

Explain the purpose of the PR here, including references to any existing Notion tasks.

New Changes

  • Explain new changes

Testing

  • Explain tests that you ran to verify code functionality.

Outstanding Changes

  • If there are non-critical changes (i.e. additional features) that can be made to this feature in the future, indicate them here.

lm75bd/lm75bd.c Outdated
@@ -27,7 +27,17 @@ error_code_t lm75bdInit(lm75bd_config_t *config) {

error_code_t readTempLM75BD(uint8_t devAddr, float *temp) {
/* Implement this driver function */

error_code_t errCode;
uint8_t buf[2];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good practice to initialize arrays

lm75bd/lm75bd.c Outdated

error_code_t errCode;
uint8_t buf[2];
uint8_t tempReg = 0b00000000;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bits should be converted to hex for readability

lm75bd/lm75bd.c Outdated
Comment on lines 35 to 36
RETURN_IF_ERROR_CODE(i2cSendTo(devAddr, &tempReg, 1));
RETURN_IF_ERROR_CODE(i2cReceiveFrom(devAddr, buf, 2));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use sizeof here instead of hardcoding the size as 1 and 2

lm75bd/lm75bd.h Outdated
@@ -5,7 +5,7 @@
#include <stdint.h>

/* LM75BD I2C Device Address */
#define LM75BD_OBC_I2C_ADDR /* Define the address here */
#define LM75BD_OBC_I2C_ADDR 0b1001111 /* Define the address here */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convert to hex

@@ -27,7 +27,17 @@ error_code_t lm75bdInit(lm75bd_config_t *config) {

error_code_t readTempLM75BD(uint8_t devAddr, float *temp) {
/* Implement this driver function */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if pointer arguments are null, if they are return invalid arg error code

@@ -43,19 +43,36 @@ void initThermalSystemManager(lm75bd_config_t *config) {

error_code_t thermalMgrSendEvent(thermal_mgr_event_t *event) {
/* Send an event to the thermal manager queue */

error_code_t errCode;
if(xQueueSend(thermalMgrQueueHandle, event, (TickType_t)0) == pdFALSE)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if the queue has been initialized yet, return error code invalid state if it hasn't


error_code_t errCode;
if(xQueueSend(thermalMgrQueueHandle, event, (TickType_t)0) == pdFALSE)
return ERR_CODE_UNKNOWN;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the queue send fails, it means that the queue is full (we have an error code for that)

while (1) {
if (xQueueReceive(thermalMgrQueueHandle, &event, (TickType_t) 0) == pdTRUE) {
float temp;
readTempLM75BD(LM75BD_OBC_I2C_ADDR, &temp);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should be checking if the driver function fails, if it does you need to log it

/* Implement this task */
thermal_mgr_event_t event;
while (1) {
if (xQueueReceive(thermalMgrQueueHandle, &event, (TickType_t) 0) == pdTRUE) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when using event queues and an infinite loop in FreeRTOS, you want to set the receive wait period to portmax delay so that it blocks indefinitely until an event is received

Comment on lines 66 to 73
if (event.type == THERMAL_MGR_EVENT_MEASURE_TEMP_CMD) {
addTemperatureTelemetry(temp);
}else if (event.type == THERMAL_MGR_EVENT_INTERRUPT_MEASURE) {
if (temp > LM75BD_DEFAULT_HYST_THRESH)
overTemperatureDetected();
else
safeOperatingConditions();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log an error if the event type is unknown (just add an else statement)

@ShivK01 ShivK01 requested a review from kepler452b123 January 18, 2025 05:24
Copy link

@kepler452b123 kepler452b123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Yarik-Popov Yarik-Popov closed this Mar 7, 2025
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