Updated zh_onewire

This commit is contained in:
2024-05-31 10:42:39 +03:00
parent 97c8418bda
commit fe1cabef6d
4 changed files with 54 additions and 19 deletions

View File

@ -20,9 +20,9 @@ extern "C"
#endif
/**
* @brief Initialize 1-Wire interface.
* @brief Initialize 1-Wire interface.
*
* @param[in] pin 1-Wire bus gpio connection.
* @param[in] pin 1-Wire bus gpio connection.
*
* @return
* - ESP_OK if initialization was successful
@ -31,59 +31,61 @@ extern "C"
esp_err_t zh_onewire_init(const uint8_t pin);
/**
* @brief Reset command for all 1-Wire devices on bus.
* @brief Reset command for all 1-Wire devices on bus.
*
* @return
* - ESP_OK if reset was successful
* - ESP_ERR_INVALID_STATE if 1-Wire bus not initialized
* - ESP_ERR_INVALID_RESPONSE if the bus is busy
* - ESP_ERR_TIMEOUT if there are no 1-Wire devices available on the bus or the devices are not responding
*/
esp_err_t zh_onewire_reset(void);
/**
* @brief Send one byte to 1-Wire device.
*
* @param[in] byte Byte value.
* @brief Send one byte to 1-Wire device.
*
* @param[in] byte Byte value.
*/
void zh_onewire_send_byte(uint8_t byte);
/**
* @brief Read one byte from 1-Wire device.
* @brief Read one byte from 1-Wire device.
*
* @return
* - Byte value
* @return Byte value
*/
uint8_t zh_onewire_read_byte(void);
/**
* @brief Initializes the bus master to address all 1-Wire devices on the bus.
* @brief Initialize the bus master to address all 1-Wire devices on the bus.
*
* @return
* - ESP_OK if initialization was successful
* - ESP_ERR_INVALID_STATE if 1-Wire bus not initialized
* - ESP_FAIL if there are no 1-Wire devices available on the bus or the devices are not responding
*/
esp_err_t zh_onewire_skip_rom(void);
/**
* @brief Read rom value if only one 1-Wire device is present on the bus.
* @brief Read rom value if only one 1-Wire device is present on the bus.
*
* @param[out] buf Pointer to a buffer containing an eight-byte rom value.
* @param[out] buf Pointer to a buffer containing an eight-byte rom value.
*
* @return
* - ESP_OK if read was successful
* - ESP_ERR_INVALID_STATE if 1-Wire bus not initialized
* - ESP_FAIL if there are no 1-Wire devices available on the bus or the devices are not responding
* - ESP_ERR_INVALID_CRC if more than one 1-Wire device is present on the bus
*/
esp_err_t zh_onewire_read_rom(uint8_t *buf);
/**
* @brief Initialize the bus master to address a specific 1-Wire device on bus.
* @brief Initialize the bus master to address a specific 1-Wire device on bus.
*
* @param[in] data Pointer to a buffer containing an eight-byte rom value.
* @param[in] data Pointer to a buffer containing an eight-byte rom value.
*
* @return
* - ESP_OK if initialization was successful
* - ESP_ERR_INVALID_STATE if 1-Wire bus not initialized
* - ESP_FAIL if there are no 1-Wire devices available on the bus or the devices are not responding
*/
esp_err_t zh_onewire_match_rom(const uint8_t *data);
@ -93,17 +95,18 @@ extern "C"
*
* @return
* - ESP_OK if initialization was successful
* - ESP_ERR_INVALID_STATE if 1-Wire bus not initialized
*/
esp_err_t zh_onewire_search_rom_init(void);
/**
* @brief Search next 1-Wire device on bus.
* @brief Search next 1-Wire device on bus.
*
* @attention Initialize search 1-Wire devices on bus must be initialized first. @code zh_onewire_search_rom_init() @endcode
* @attention Initialize search 1-Wire devices on bus must be initialized first. @code zh_onewire_search_rom_init() @endcode
*
* @return
* - Pointer to a buffer containing an eight-byte rom value
* - NULL if the search is terminated or if there are no 1-Wire devices available on the bus or the devices are not responding
* - NULL if the search is terminated or if there are no 1-Wire devices available on the bus or the devices are not responding or if 1-Wire bus not initialized
*/
uint8_t *zh_onewire_search_rom_next(void);