add presence bit to 1-wire reset command

This commit is contained in:
Kilian Bracher 2024-06-27 02:12:50 +02:00
parent 2f47a8f763
commit fa9ab6a252
Signed by: k.bracher
SSH Key Fingerprint: SHA256:mXpyZkK7RDiJ7qeHCKJX108woM0cl5TrCvNBJASu6lM
2 changed files with 7 additions and 6 deletions

@ -43,7 +43,7 @@ HAL_StatusTypeDef ds2482_set_read_ptr(uint8_t read_ptr) {
return HAL_I2C_Master_Transmit(hi2c, DS2482_I2C_ADDR, data, sizeof(data), DS2482_TIMEOUT_I2C);
}
HAL_StatusTypeDef ds2482_1w_reset() {
HAL_StatusTypeDef ds2482_1w_reset(bool* presence) {
uint8_t data[1] = {DS2482_CMD_1W_RESET};
HAL_StatusTypeDef status = HAL_I2C_Master_Transmit(hi2c, DS2482_I2C_ADDR, data, sizeof(data), DS2482_TIMEOUT_I2C);
if (status != HAL_OK) {
@ -65,6 +65,8 @@ HAL_StatusTypeDef ds2482_1w_reset() {
return HAL_ERROR;
}
*presence = status_reg.PPD;
return HAL_OK;
}
@ -222,10 +224,9 @@ static void OWFamilySkipSetup() {
// false : no device present
//
static bool OWReset() {
ds2482_1w_reset();
DS2482_Status status_reg = {};
HAL_I2C_Master_Receive(hi2c, DS2482_I2C_ADDR, (uint8_t*)&status_reg, 1, DS2482_TIMEOUT_I2C);
return status_reg.PPD;
bool presence;
ds2482_1w_reset(&presence);
return presence;
}
//--------------------------------------------------------------------------

@ -41,7 +41,7 @@ HAL_StatusTypeDef ds2482_init(I2C_HandleTypeDef* handle);
HAL_StatusTypeDef ds2482_reset();
HAL_StatusTypeDef ds2482_write_config(uint8_t config);
HAL_StatusTypeDef ds2482_set_read_ptr(uint8_t read_ptr);
HAL_StatusTypeDef ds2482_1w_reset();
HAL_StatusTypeDef ds2482_1w_reset(bool* presence);
HAL_StatusTypeDef ds2482_1w_write_byte(uint8_t byte);
HAL_StatusTypeDef ds2482_1w_read_byte(uint8_t* byte);
HAL_StatusTypeDef ds2482_1w_triplet(uint8_t dir);