Skip to content

Commit bd6b217

Browse files
authored
Merge pull request #710 from Narukara/feat/onewire_bus_uart
feat(1wire): add UART as onewire bus backend
2 parents 1387cec + 659267f commit bd6b217

13 files changed

Lines changed: 457 additions & 12 deletions

onewire_bus/.build-test-rules.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
onewire_bus/test_apps:
22
disable:
3-
- if: SOC_RMT_SUPPORTED != 1
4-
reason: Only RMT backend is implemented
3+
- if: CONFIG_NAME == "rmt" and SOC_RMT_SUPPORTED != 1
4+
reason: RMT backend variant requires SOC RMT support
5+
- if: CONFIG_NAME == "uart" and SOC_UART_SUPPORTED != 1
6+
reason: UART backend variant requires SOC UART support

onewire_bus/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.0
2+
3+
- Add UART backend support for 1-Wire bus (`onewire_new_bus_uart`) alongside the existing RMT backend.
4+
15
## 1.0.4
26

37
- Support `en_pull_up` config option in `onewire_bus_config_t`, which can enable the internal pull-up resistor on the GPIO pin used for the one-wire bus. This is useful when using a GPIO pin that does not have a pull-up resistor connected externally.

onewire_bus/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ if(CONFIG_SOC_RMT_SUPPORTED)
66
list(APPEND srcs "src/onewire_bus_impl_rmt.c")
77
endif()
88

9+
if(CONFIG_SOC_UART_SUPPORTED)
10+
list(APPEND srcs "src/onewire_bus_impl_uart.c")
11+
endif()
12+
913
set(priv_requires)
10-
# Starting from esp-idf v5.3, the RMT drivers are moved to separate components
14+
# Starting from esp-idf v5.3, the peripheral drivers are in separate components
1115
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.3")
12-
list(APPEND priv_requires "esp_driver_rmt" "esp_driver_gpio")
16+
list(APPEND priv_requires "esp_driver_rmt" "esp_driver_uart" "esp_driver_gpio")
1317
else()
1418
list(APPEND priv_requires "driver")
1519
endif()

onewire_bus/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
[![Component Registry](https://components.espressif.com/components/espressif/onewire_bus/badge.svg)](https://components.espressif.com/components/espressif/onewire_bus)
44

5-
This directory contains an implementation for Dallas 1-Wire bus by different peripherals. Currently only RMT is supported as the backend.
5+
This directory contains an implementation for Dallas 1-Wire bus by different peripherals.
6+
The following low-level backends are currently supported:
7+
8+
- RMT backend (`onewire_new_bus_rmt`)
9+
- UART backend (`onewire_new_bus_uart`)
610

711
## Appendix
812

onewire_bus/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.0.4"
1+
version: "1.1.0"
22
description: Driver for Dallas 1-Wire bus
33
url: https://github.com/espressif/idf-extra-components/tree/master/onewire_bus
44
issues: "https://github.com/espressif/idf-extra-components/issues"

onewire_bus/include/onewire_bus.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77

88
#include <stdint.h>
99
#include "esp_err.h"
10+
#include "soc/soc_caps.h"
1011
#include "onewire_types.h"
12+
#if SOC_RMT_SUPPORTED
1113
#include "onewire_bus_impl_rmt.h"
14+
#endif
15+
#if SOC_UART_SUPPORTED
16+
#include "onewire_bus_impl_uart.h"
17+
#endif
1218

1319
#ifdef __cplusplus
1420
extern "C" {
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#pragma once
7+
8+
#include <stdint.h>
9+
#include "esp_err.h"
10+
#include "onewire_types.h"
11+
12+
#ifdef __cplusplus
13+
extern "C" {
14+
#endif
15+
16+
/**
17+
* @brief 1-Wire bus UART specific configuration
18+
*/
19+
typedef struct {
20+
int uart_port_num; /*!< UART port number, e.g. UART_NUM_1 */
21+
} onewire_bus_uart_config_t;
22+
23+
/**
24+
* @brief Create 1-Wire bus with UART backend
25+
*
26+
* @note TX and RX will both be configured to bus_config->bus_gpio_num.
27+
* And this GPIO will be configured as open-drain mode.
28+
*
29+
* @param[in] bus_config 1-Wire bus configuration
30+
* @param[in] uart_config UART specific configuration
31+
* @param[out] ret_bus Returned 1-Wire bus handle
32+
* @return
33+
* - ESP_OK: create 1-Wire bus handle successfully
34+
* - ESP_ERR_INVALID_ARG: create 1-Wire bus handle failed because of invalid argument
35+
* - ESP_ERR_NO_MEM: create 1-Wire bus handle failed because of out of memory
36+
* - ESP_FAIL: create 1-Wire bus handle failed because some other error
37+
*/
38+
esp_err_t onewire_new_bus_uart(const onewire_bus_config_t *bus_config, const onewire_bus_uart_config_t *uart_config, onewire_bus_handle_t *ret_bus);
39+
40+
#ifdef __cplusplus
41+
}
42+
#endif

0 commit comments

Comments
 (0)