mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 09:39:10 -04:00
Merge branch 'bugfix/soft_uart_send_dummy_byte_v5.1' into 'release/v5.1'
fix(peripheral_drivers/dedicated_gpio): Remove dummy byte from the emulate_uart_send routine (backport v5.1) See merge request espressif/esp-idf!28687
This commit is contained in:
commit
37e0e8ab53
@ -65,6 +65,10 @@ esp_err_t soft_uart_del(soft_uart_port_t port);
|
|||||||
/**
|
/**
|
||||||
* @brief Send the given bytes on the software UART port.
|
* @brief Send the given bytes on the software UART port.
|
||||||
*
|
*
|
||||||
|
* @note Since toggling fast GPIOs for the first time may be slow (~1us), the first byte may be corrupted.
|
||||||
|
* If you are seeing this issue, prepend a dummy byte to the buffer to send when calling this
|
||||||
|
* function for the first time.
|
||||||
|
*
|
||||||
* @param port Software UART port to send data on.
|
* @param port Software UART port to send data on.
|
||||||
* @param write_buffer Buffer containing the bytes to send on the buffer. Must not be NULL.
|
* @param write_buffer Buffer containing the bytes to send on the buffer. Must not be NULL.
|
||||||
* @param write_size Size of the write buffer. Must not be 0.
|
* @param write_size Size of the write buffer. Must not be 0.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2010-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: CC0-1.0
|
* SPDX-License-Identifier: CC0-1.0
|
||||||
*/
|
*/
|
||||||
@ -33,11 +33,6 @@ emulate_uart_send:
|
|||||||
sll a2, t0, a2
|
sll a2, t0, a2
|
||||||
/* Save return address in a4 */
|
/* Save return address in a4 */
|
||||||
mv a4, ra
|
mv a4, ra
|
||||||
/* As UART is very time sensitive, we want each bit sent to be very precise in terms of duration.
|
|
||||||
* The first toggle of the fast GPIO register may be slow, ~1us, so let's send a dummy byte here
|
|
||||||
* before the actual UART emulation start, else the first byte sent would be corrupted.*/
|
|
||||||
li t0, 0
|
|
||||||
call uart_send_byte
|
|
||||||
/* Reading the characters 4 by 4 would be much faster, but in our case, we don't need
|
/* Reading the characters 4 by 4 would be much faster, but in our case, we don't need
|
||||||
* the process to be fast as the bottleneck is the UART speed */
|
* the process to be fast as the bottleneck is the UART speed */
|
||||||
uart_read_next:
|
uart_read_next:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2010-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: CC0-1.0
|
* SPDX-License-Identifier: CC0-1.0
|
||||||
*/
|
*/
|
||||||
@ -18,6 +18,7 @@ void app_main(void)
|
|||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
uint8_t read_buffer[READ_COUNT] = { 0 };
|
uint8_t read_buffer[READ_COUNT] = { 0 };
|
||||||
const uint8_t write_buffer[] = "Hello, world! This is a message.\r\n";
|
const uint8_t write_buffer[] = "Hello, world! This is a message.\r\n";
|
||||||
|
uint8_t dummy = 0;
|
||||||
soft_uart_port_t port = NULL;
|
soft_uart_port_t port = NULL;
|
||||||
soft_uart_config_t config = {
|
soft_uart_config_t config = {
|
||||||
.tx_pin = CONFIG_EMULATE_UART_GPIO_TX,
|
.tx_pin = CONFIG_EMULATE_UART_GPIO_TX,
|
||||||
@ -29,6 +30,10 @@ void app_main(void)
|
|||||||
ret = soft_uart_new(&config, &port);
|
ret = soft_uart_new(&config, &port);
|
||||||
ESP_GOTO_ON_ERROR(ret, error, EXAMPLE_TAG, "Error configuring software UART");
|
ESP_GOTO_ON_ERROR(ret, error, EXAMPLE_TAG, "Error configuring software UART");
|
||||||
|
|
||||||
|
/* Send a dummy byte as the software UART driver may corrupt the first byte */
|
||||||
|
ret = soft_uart_send(port, &dummy, sizeof(uint8_t));
|
||||||
|
ESP_GOTO_ON_ERROR(ret, error, EXAMPLE_TAG, "Error writing a dummy byte");
|
||||||
|
|
||||||
/* Write few bytes to the UART */
|
/* Write few bytes to the UART */
|
||||||
ret = soft_uart_send(port, write_buffer, sizeof(write_buffer));
|
ret = soft_uart_send(port, write_buffer, sizeof(write_buffer));
|
||||||
ESP_GOTO_ON_ERROR(ret, error, EXAMPLE_TAG, "Error writing to the software UART");
|
ESP_GOTO_ON_ERROR(ret, error, EXAMPLE_TAG, "Error writing to the software UART");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user