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

Implementing the readTemp-CC1120 #310

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions obc/app/drivers/cc1120/cc1120.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,24 @@ obc_error_code_t cc1120GetBytesInRxFifo(uint8_t *numBytes) {
RETURN_IF_ERROR_CODE(cc1120ReadExtAddrSpi(CC1120_REGS_EXT_NUM_RXBYTES, numBytes, 1));
return OBC_ERR_CODE_SUCCESS;
}

/**
* @brief Read the temperature from the cc1120
*
* @param temp Pointer to float to store the temperature in degrees Celsius
* @return OBC_ERR_CODE_SUCCESS if successful, invalid-arg error code otherwise
*/
obc_error_code_t readTempCC1120(float *temp){
if (temp == NULL) {
return OBC_ERR_CODE_INVALID_ARG;
}

obc_error_code_t errCode;
uint8_t rawTemp = 0;
// The CC1120 device can be configured to provide a voltage proportional to temperature on GPIO1, not sure if it's the correct reg
RETURN_IF_ERROR_CODE(cc1120ReadExtAddrSpi(CC1120_REGS_EXT_GPIO_STATUS, &rawTemp, 1));

*temp = ((float)rawTemp / 2.0f) - 40.0f;

return OBC_ERR_CODE_SUCCESS;
}
10 changes: 10 additions & 0 deletions obc/app/drivers/cc1120/cc1120.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,13 @@ obc_error_code_t cc1120GetState(cc1120_state_t *stateNum);
* @return obc_error_code_t - Whether or not the setup was a success
*/
obc_error_code_t cc1120Init(void);

/**
* @brief Read the temperature from the cc1120
*
* @param temp Pointer to float to store the temperature in degrees Celsius
* @return OBC_ERR_CODE_SUCCESS if successful, invalid-arg error code otherwise
*/
obc_error_code_t readTempCC1120(float *temp);


Loading