Skip to content

Commit

Permalink
fan i2c access protection
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Apr 11, 2020
1 parent 28d15d6 commit 0dcca1a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/eez/modules/aux_ps/fan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,16 @@ PWMMeasurement g_pwmMeasurement;
////////////////////////////////////////////////////////////////////////////////

HAL_StatusTypeDef readReg(uint8_t reg, uint8_t *value) {
taskENTER_CRITICAL();
HAL_StatusTypeDef returnValue = HAL_I2C_Master_Transmit(&hi2c1, MAX31760_DEVICE_ADDRESS, &reg, 1, 5);
taskEXIT_CRITICAL();
if (returnValue != HAL_OK) {
return returnValue;
}

taskENTER_CRITICAL();
returnValue = HAL_I2C_Master_Receive(&hi2c1, MAX31760_DEVICE_ADDRESS, value, 1, 5);
taskEXIT_CRITICAL();
if (returnValue != HAL_OK) {
return returnValue;
}
Expand All @@ -188,7 +192,9 @@ HAL_StatusTypeDef writeReg(uint8_t reg, uint8_t value) {
uint8_t data[2];
data[0] = reg;
data[1] = value;
taskENTER_CRITICAL();
HAL_StatusTypeDef returnValue = HAL_I2C_Master_Transmit(&hi2c1, MAX31760_DEVICE_ADDRESS, data, 2, 5);
taskEXIT_CRITICAL();
return returnValue;
}

Expand Down

0 comments on commit 0dcca1a

Please sign in to comment.