mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/fix_stack_rs485_echo_example' into 'master'
fix(uart/example): Fixed the stack size allocation in uart echo examples Closes IDFGH-13483 See merge request espressif/esp-idf!33079
This commit is contained in:
commit
bd95e6955b
@ -38,7 +38,7 @@ menu "Echo Example Configuration"
|
|||||||
config EXAMPLE_TASK_STACK_SIZE
|
config EXAMPLE_TASK_STACK_SIZE
|
||||||
int "UART echo example task stack size"
|
int "UART echo example task stack size"
|
||||||
range 1024 16384
|
range 1024 16384
|
||||||
default 2048
|
default 3072
|
||||||
help
|
help
|
||||||
Defines stack size for UART echo example. Insufficient stack size can cause crash.
|
Defines stack size for UART echo example. Insufficient stack size can cause crash.
|
||||||
|
|
||||||
|
@ -48,4 +48,11 @@ menu "Echo RS485 Example Configuration"
|
|||||||
See UART documentation for more information about available pin
|
See UART documentation for more information about available pin
|
||||||
numbers for UART.
|
numbers for UART.
|
||||||
|
|
||||||
|
config ECHO_TASK_STACK_SIZE
|
||||||
|
int "UART echo RS485 example task stack size"
|
||||||
|
range 1024 16384
|
||||||
|
default 3072
|
||||||
|
help
|
||||||
|
Defines stack size for UART echo RS485 example. Insufficient stack size can cause crash.
|
||||||
|
|
||||||
endmenu
|
endmenu
|
||||||
|
@ -25,21 +25,21 @@
|
|||||||
|
|
||||||
// Note: Some pins on target chip cannot be assigned for UART communication.
|
// Note: Some pins on target chip cannot be assigned for UART communication.
|
||||||
// Please refer to documentation for selected board and target to configure pins using Kconfig.
|
// Please refer to documentation for selected board and target to configure pins using Kconfig.
|
||||||
#define ECHO_TEST_TXD (CONFIG_ECHO_UART_TXD)
|
#define ECHO_TEST_TXD (CONFIG_ECHO_UART_TXD)
|
||||||
#define ECHO_TEST_RXD (CONFIG_ECHO_UART_RXD)
|
#define ECHO_TEST_RXD (CONFIG_ECHO_UART_RXD)
|
||||||
|
|
||||||
// RTS for RS485 Half-Duplex Mode manages DE/~RE
|
// RTS for RS485 Half-Duplex Mode manages DE/~RE
|
||||||
#define ECHO_TEST_RTS (CONFIG_ECHO_UART_RTS)
|
#define ECHO_TEST_RTS (CONFIG_ECHO_UART_RTS)
|
||||||
|
|
||||||
// CTS is not used in RS485 Half-Duplex Mode
|
// CTS is not used in RS485 Half-Duplex Mode
|
||||||
#define ECHO_TEST_CTS (UART_PIN_NO_CHANGE)
|
#define ECHO_TEST_CTS (UART_PIN_NO_CHANGE)
|
||||||
|
|
||||||
#define BUF_SIZE (127)
|
#define BUF_SIZE (127)
|
||||||
#define BAUD_RATE (CONFIG_ECHO_UART_BAUD_RATE)
|
#define BAUD_RATE (CONFIG_ECHO_UART_BAUD_RATE)
|
||||||
|
|
||||||
// Read packet timeout
|
// Read packet timeout
|
||||||
#define PACKET_READ_TICS (100 / portTICK_PERIOD_MS)
|
#define PACKET_READ_TICS (100 / portTICK_PERIOD_MS)
|
||||||
#define ECHO_TASK_STACK_SIZE (2048)
|
#define ECHO_TASK_STACK_SIZE (CONFIG_ECHO_TASK_STACK_SIZE)
|
||||||
#define ECHO_TASK_PRIO (10)
|
#define ECHO_TASK_PRIO (10)
|
||||||
#define ECHO_UART_PORT (CONFIG_ECHO_UART_PORT_NUM)
|
#define ECHO_UART_PORT (CONFIG_ECHO_UART_PORT_NUM)
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ static void echo_task(void *arg)
|
|||||||
// Allocate buffers for UART
|
// Allocate buffers for UART
|
||||||
uint8_t* data = (uint8_t*) malloc(BUF_SIZE);
|
uint8_t* data = (uint8_t*) malloc(BUF_SIZE);
|
||||||
|
|
||||||
ESP_LOGI(TAG, "UART start recieve loop.\r");
|
ESP_LOGI(TAG, "UART start receive loop.\r");
|
||||||
echo_send(uart_num, "Start RS485 UART test.\r\n", 24);
|
echo_send(uart_num, "Start RS485 UART test.\r\n", 24);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -112,7 +112,7 @@ static void echo_task(void *arg)
|
|||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
printf("0x%.2X ", (uint8_t)data[i]);
|
printf("0x%.2X ", (uint8_t)data[i]);
|
||||||
echo_send(uart_num, (const char*)&data[i], 1);
|
echo_send(uart_num, (const char*)&data[i], 1);
|
||||||
// Add a Newline character if you get a return charater from paste (Paste tests multibyte receipt/buffer)
|
// Add a Newline character if you get a return character from paste (Paste tests multibyte receipt/buffer)
|
||||||
if (data[i] == '\r') {
|
if (data[i] == '\r') {
|
||||||
echo_send(uart_num, "\n", 1);
|
echo_send(uart_num, "\n", 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user