mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(peripheral_drivers/dedicated_gpio): Remove dummy byte from the emulate_uart_send routine
Let the user application decide for when to send the dummy byte instead of hardcoding it from the assembly routine.
This commit is contained in:
parent
d922d4178f
commit
6519b60c47
@ -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.
|
||||
*
|
||||
* @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 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.
|
||||
|
@ -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
|
||||
*/
|
||||
@ -33,11 +33,6 @@ emulate_uart_send:
|
||||
sll a2, t0, a2
|
||||
/* Save return address in a4 */
|
||||
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
|
||||
* the process to be fast as the bottleneck is the UART speed */
|
||||
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
|
||||
*/
|
||||
@ -18,6 +18,7 @@ void app_main(void)
|
||||
esp_err_t ret = ESP_OK;
|
||||
uint8_t read_buffer[READ_COUNT] = { 0 };
|
||||
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_config_t config = {
|
||||
.tx_pin = CONFIG_EMULATE_UART_GPIO_TX,
|
||||
@ -29,6 +30,10 @@ void app_main(void)
|
||||
ret = soft_uart_new(&config, &port);
|
||||
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 */
|
||||
ret = soft_uart_send(port, write_buffer, sizeof(write_buffer));
|
||||
ESP_GOTO_ON_ERROR(ret, error, EXAMPLE_TAG, "Error writing to the software UART");
|
||||
|
Loading…
Reference in New Issue
Block a user