add presence bit to 1-wire reset command
This commit is contained in:
		
							
								
								
									
										11
									
								
								DS2482_HAL.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								DS2482_HAL.c
									
									
									
									
									
								
							@ -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);
 | 
					    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};
 | 
					    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);
 | 
					    HAL_StatusTypeDef status = HAL_I2C_Master_Transmit(hi2c, DS2482_I2C_ADDR, data, sizeof(data), DS2482_TIMEOUT_I2C);
 | 
				
			||||||
    if (status != HAL_OK) {
 | 
					    if (status != HAL_OK) {
 | 
				
			||||||
@ -65,6 +65,8 @@ HAL_StatusTypeDef ds2482_1w_reset() {
 | 
				
			|||||||
        return HAL_ERROR;
 | 
					        return HAL_ERROR;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    *presence = status_reg.PPD;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return HAL_OK;
 | 
					    return HAL_OK;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -222,10 +224,9 @@ static void OWFamilySkipSetup() {
 | 
				
			|||||||
//        false : no device present
 | 
					//        false : no device present
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
static bool OWReset() {
 | 
					static bool OWReset() {
 | 
				
			||||||
    ds2482_1w_reset();
 | 
					    bool presence;
 | 
				
			||||||
    DS2482_Status status_reg = {};
 | 
					    ds2482_1w_reset(&presence);
 | 
				
			||||||
    HAL_I2C_Master_Receive(hi2c, DS2482_I2C_ADDR, (uint8_t*)&status_reg, 1, DS2482_TIMEOUT_I2C);
 | 
					    return presence;
 | 
				
			||||||
    return status_reg.PPD;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//--------------------------------------------------------------------------
 | 
					//--------------------------------------------------------------------------
 | 
				
			||||||
 | 
				
			|||||||
@ -41,7 +41,7 @@ HAL_StatusTypeDef ds2482_init(I2C_HandleTypeDef* handle);
 | 
				
			|||||||
HAL_StatusTypeDef ds2482_reset();
 | 
					HAL_StatusTypeDef ds2482_reset();
 | 
				
			||||||
HAL_StatusTypeDef ds2482_write_config(uint8_t config);
 | 
					HAL_StatusTypeDef ds2482_write_config(uint8_t config);
 | 
				
			||||||
HAL_StatusTypeDef ds2482_set_read_ptr(uint8_t read_ptr);
 | 
					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_write_byte(uint8_t byte);
 | 
				
			||||||
HAL_StatusTypeDef ds2482_1w_read_byte(uint8_t* byte);
 | 
					HAL_StatusTypeDef ds2482_1w_read_byte(uint8_t* byte);
 | 
				
			||||||
HAL_StatusTypeDef ds2482_1w_triplet(uint8_t dir);
 | 
					HAL_StatusTypeDef ds2482_1w_triplet(uint8_t dir);
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user