mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
freemodbus: add affinity option for modbus stack tasks
This commit is contained in:
parent
8f0bcc570a
commit
e1374b9c7c
@ -33,6 +33,29 @@ menu "Modbus configuration"
|
|||||||
Modbus UART driver event task priority.
|
Modbus UART driver event task priority.
|
||||||
The priority of Modbus controller task is equal to (CONFIG_MB_SERIAL_TASK_PRIO - 1).
|
The priority of Modbus controller task is equal to (CONFIG_MB_SERIAL_TASK_PRIO - 1).
|
||||||
|
|
||||||
|
choice MB_PORT_TASK_AFFINITY
|
||||||
|
prompt "Modbus task affinity"
|
||||||
|
default MB_PORT_TASK_AFFINITY_CPU0
|
||||||
|
depends on !FREERTOS_UNICORE
|
||||||
|
help
|
||||||
|
Allows setting the core affinity of the Modbus controller task, i.e. whether the task is pinned to
|
||||||
|
particular CPU, or allowed to run on any CPU.
|
||||||
|
|
||||||
|
config MB_PORT_TASK_AFFINITY_NO_AFFINITY
|
||||||
|
bool "No affinity"
|
||||||
|
config MB_PORT_TASK_AFFINITY_CPU0
|
||||||
|
bool "CPU0"
|
||||||
|
config MB_PORT_TASK_AFFINITY_CPU1
|
||||||
|
bool "CPU1"
|
||||||
|
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
config MB_PORT_TASK_AFFINITY
|
||||||
|
hex
|
||||||
|
default FREERTOS_NO_AFFINITY if MB_PORT_TASK_AFFINITY_NO_AFFINITY || FREERTOS_UNICORE
|
||||||
|
default 0x0 if MB_PORT_TASK_AFFINITY_CPU0
|
||||||
|
default 0x1 if MB_PORT_TASK_AFFINITY_CPU1
|
||||||
|
|
||||||
config MB_CONTROLLER_SLAVE_ID_SUPPORT
|
config MB_CONTROLLER_SLAVE_ID_SUPPORT
|
||||||
bool "Modbus controller slave ID support"
|
bool "Modbus controller slave ID support"
|
||||||
default n
|
default n
|
||||||
|
@ -66,6 +66,9 @@
|
|||||||
#define EXIT_CRITICAL_SECTION( ) { vMBPortExitCritical(); \
|
#define EXIT_CRITICAL_SECTION( ) { vMBPortExitCritical(); \
|
||||||
ESP_LOGD(MB_PORT_TAG,"%s: Port exit critical", __func__); }
|
ESP_LOGD(MB_PORT_TAG,"%s: Port exit critical", __func__); }
|
||||||
|
|
||||||
|
// The task affinity for Modbus stack tasks
|
||||||
|
#define MB_PORT_TASK_AFFINITY (CONFIG_MB_PORT_TASK_AFFINITY)
|
||||||
|
|
||||||
typedef char BOOL;
|
typedef char BOOL;
|
||||||
|
|
||||||
typedef unsigned char UCHAR;
|
typedef unsigned char UCHAR;
|
||||||
|
@ -241,8 +241,10 @@ BOOL xMBPortSerialInit(UCHAR ucPORT, ULONG ulBaudRate,
|
|||||||
"mb serial set rx timeout failure, uart_set_rx_timeout() returned (0x%x).", (uint32_t)xErr);
|
"mb serial set rx timeout failure, uart_set_rx_timeout() returned (0x%x).", (uint32_t)xErr);
|
||||||
#endif
|
#endif
|
||||||
// Create a task to handle UART events
|
// Create a task to handle UART events
|
||||||
BaseType_t xStatus = xTaskCreate(vUartTask, "uart_queue_task", MB_SERIAL_TASK_STACK_SIZE,
|
BaseType_t xStatus = xTaskCreatePinnedToCore(vUartTask, "uart_queue_task",
|
||||||
NULL, MB_SERIAL_TASK_PRIO, &xMbTaskHandle);
|
MB_SERIAL_TASK_STACK_SIZE,
|
||||||
|
NULL, MB_SERIAL_TASK_PRIO,
|
||||||
|
&xMbTaskHandle, MB_PORT_TASK_AFFINITY);
|
||||||
if (xStatus != pdPASS) {
|
if (xStatus != pdPASS) {
|
||||||
vTaskDelete(xMbTaskHandle);
|
vTaskDelete(xMbTaskHandle);
|
||||||
// Force exit from function with failure
|
// Force exit from function with failure
|
||||||
|
Loading…
Reference in New Issue
Block a user