ethernet: support pin emac task to core
This commit is contained in:
parent
9718338984
commit
d96d68ea38
4 changed files with 16 additions and 4 deletions
|
@ -275,6 +275,7 @@ typedef struct {
|
|||
} eth_mac_config_t;
|
||||
|
||||
#define ETH_MAC_FLAG_WORK_WITH_CACHE_DISABLE (1 << 0) /*!< MAC driver can work when cache is disabled */
|
||||
#define ETH_MAC_FLAG_PIN_TO_CORE (1 << 1) /*!< Pin MAC task to the CPU core where driver installation happened */
|
||||
|
||||
/**
|
||||
* @brief Default configuration for Ethernet MAC object
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/portable.h"
|
||||
#include "dm9051.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
|
@ -750,8 +751,12 @@ esp_eth_mac_t *esp_eth_mac_new_dm9051(const eth_dm9051_config_t *dm9051_config,
|
|||
emac->spi_lock = xSemaphoreCreateMutex();
|
||||
MAC_CHECK(emac->spi_lock, "create lock failed", err, NULL);
|
||||
/* create dm9051 task */
|
||||
BaseType_t xReturned = xTaskCreate(emac_dm9051_task, "dm9051_tsk", mac_config->rx_task_stack_size, emac,
|
||||
mac_config->rx_task_prio, &emac->rx_task_hdl);
|
||||
BaseType_t core_num = tskNO_AFFINITY;
|
||||
if (mac_config->flags & ETH_MAC_FLAG_PIN_TO_CORE) {
|
||||
core_num = xPortGetCoreID();
|
||||
}
|
||||
BaseType_t xReturned = xTaskCreatePinnedToCore(emac_dm9051_task, "dm9051_tsk", mac_config->rx_task_stack_size, emac,
|
||||
mac_config->rx_task_prio, &emac->rx_task_hdl, core_num);
|
||||
MAC_CHECK(xReturned == pdPASS, "create dm9051 task failed", err, NULL);
|
||||
return &(emac->parent);
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/portable.h"
|
||||
#include "hal/emac.h"
|
||||
#include "soc/soc.h"
|
||||
#include "sdkconfig.h"
|
||||
|
@ -451,8 +452,12 @@ esp_eth_mac_t *esp_eth_mac_new_esp32(const eth_mac_config_t *config)
|
|||
"create pm lock failed", err, NULL);
|
||||
#endif
|
||||
/* create rx task */
|
||||
BaseType_t xReturned = xTaskCreate(emac_esp32_rx_task, "emac_rx", config->rx_task_stack_size, emac,
|
||||
config->rx_task_prio, &emac->rx_task_hdl);
|
||||
BaseType_t core_num = tskNO_AFFINITY;
|
||||
if (config->flags & ETH_MAC_FLAG_PIN_TO_CORE) {
|
||||
core_num = xPortGetCoreID();
|
||||
}
|
||||
BaseType_t xReturned = xTaskCreatePinnedToCore(emac_esp32_rx_task, "emac_rx", config->rx_task_stack_size, emac,
|
||||
config->rx_task_prio, &emac->rx_task_hdl, core_num);
|
||||
MAC_CHECK(xReturned == pdPASS, "create emac_rx task failed", err, NULL);
|
||||
return &(emac->parent);
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ static esp_err_t test_uninstall_driver(esp_eth_handle_t eth_hdl, uint32_t ms_to_
|
|||
TEST_CASE("esp32 ethernet io test", "[ethernet][test_env=UT_T2_Ethernet]")
|
||||
{
|
||||
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
|
||||
mac_config.flags = ETH_MAC_FLAG_PIN_TO_CORE; // pin to core
|
||||
esp_eth_mac_t *mac = esp_eth_mac_new_esp32(&mac_config);
|
||||
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
|
||||
esp_eth_phy_t *phy = esp_eth_phy_new_ip101(&phy_config);
|
||||
|
|
Loading…
Reference in a new issue