mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 13:44:32 +02:00
gdma: support override default channel priority
This commit is contained in:
@@ -359,6 +359,24 @@ err:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_err_t gdma_set_priority(gdma_channel_handle_t dma_chan, uint32_t priority)
|
||||||
|
{
|
||||||
|
gdma_pair_t *pair = NULL;
|
||||||
|
gdma_group_t *group = NULL;
|
||||||
|
ESP_RETURN_ON_FALSE(dma_chan && priority <= GDMA_LL_CHANNEL_MAX_PRIORITY, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
|
||||||
|
pair = dma_chan->pair;
|
||||||
|
group = pair->group;
|
||||||
|
|
||||||
|
if (dma_chan->direction == GDMA_CHANNEL_DIRECTION_TX) {
|
||||||
|
gdma_ll_tx_set_priority(group->hal.dev, pair->pair_id, priority);
|
||||||
|
} else {
|
||||||
|
gdma_ll_rx_set_priority(group->hal.dev, pair->pair_id, priority);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
esp_err_t gdma_register_tx_event_callbacks(gdma_channel_handle_t dma_chan, gdma_tx_event_callbacks_t *cbs, void *user_data)
|
esp_err_t gdma_register_tx_event_callbacks(gdma_channel_handle_t dma_chan, gdma_tx_event_callbacks_t *cbs, void *user_data)
|
||||||
{
|
{
|
||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
@@ -651,6 +669,8 @@ static esp_err_t gdma_del_tx_channel(gdma_channel_t *dma_channel)
|
|||||||
ESP_LOGD(TAG, "uninstall interrupt service for tx channel (%d,%d)", group_id, pair_id);
|
ESP_LOGD(TAG, "uninstall interrupt service for tx channel (%d,%d)", group_id, pair_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gdma_ll_tx_set_priority(group->hal.dev, pair_id, 0); // reset the priority to 0 (lowest)
|
||||||
|
|
||||||
free(tx_chan);
|
free(tx_chan);
|
||||||
ESP_LOGD(TAG, "del tx channel (%d,%d)", group_id, pair_id);
|
ESP_LOGD(TAG, "del tx channel (%d,%d)", group_id, pair_id);
|
||||||
// channel has a reference on pair, release it now
|
// channel has a reference on pair, release it now
|
||||||
@@ -679,6 +699,8 @@ static esp_err_t gdma_del_rx_channel(gdma_channel_t *dma_channel)
|
|||||||
ESP_LOGD(TAG, "uninstall interrupt service for rx channel (%d,%d)", group_id, pair_id);
|
ESP_LOGD(TAG, "uninstall interrupt service for rx channel (%d,%d)", group_id, pair_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gdma_ll_rx_set_priority(group->hal.dev, pair_id, 0); // reset the priority to 0 (lowest)
|
||||||
|
|
||||||
free(rx_chan);
|
free(rx_chan);
|
||||||
ESP_LOGD(TAG, "del rx channel (%d,%d)", group_id, pair_id);
|
ESP_LOGD(TAG, "del rx channel (%d,%d)", group_id, pair_id);
|
||||||
gdma_release_pair_handle(pair);
|
gdma_release_pair_handle(pair);
|
||||||
|
@@ -177,14 +177,28 @@ esp_err_t gdma_set_transfer_ability(gdma_channel_handle_t dma_chan, const gdma_t
|
|||||||
/**
|
/**
|
||||||
* @brief Apply channel strategy for GDMA channel
|
* @brief Apply channel strategy for GDMA channel
|
||||||
*
|
*
|
||||||
* @param dma_chan GDMA channel handle, allocated by `gdma_new_channel`
|
* @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel`
|
||||||
* @param config Configuration of GDMA channel strategy
|
* @param[in] config Configuration of GDMA channel strategy
|
||||||
* - ESP_OK: Apply channel strategy successfully
|
* - ESP_OK: Apply channel strategy successfully
|
||||||
* - ESP_ERR_INVALID_ARG: Apply channel strategy failed because of invalid argument
|
* - ESP_ERR_INVALID_ARG: Apply channel strategy failed because of invalid argument
|
||||||
* - ESP_FAIL: Apply channel strategy failed because of other error
|
* - ESP_FAIL: Apply channel strategy failed because of other error
|
||||||
*/
|
*/
|
||||||
esp_err_t gdma_apply_strategy(gdma_channel_handle_t dma_chan, const gdma_strategy_config_t *config);
|
esp_err_t gdma_apply_strategy(gdma_channel_handle_t dma_chan, const gdma_strategy_config_t *config);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set GDMA channel priority
|
||||||
|
*
|
||||||
|
* @note By default, all GDMA channels are with the same priority: 0. Channels with the same priority are served in round-robin manner.
|
||||||
|
*
|
||||||
|
* @param[in] dma_chan GDMA channel handle, allocated by `gdma_new_channel`
|
||||||
|
* @param[in] priority Priority of GDMA channel, higher value means higher priority
|
||||||
|
* @return
|
||||||
|
* - ESP_OK: Set GDMA channel priority successfully
|
||||||
|
* - ESP_ERR_INVALID_ARG: Set GDMA channel priority failed because of invalid argument, e.g. priority out of range [0,GDMA_LL_CHANNEL_MAX_PRIORITY]
|
||||||
|
* - ESP_FAIL: Set GDMA channel priority failed because of other error
|
||||||
|
*/
|
||||||
|
esp_err_t gdma_set_priority(gdma_channel_handle_t dma_chan, uint32_t priority);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Delete GDMA channel
|
* @brief Delete GDMA channel
|
||||||
* @note If you call `gdma_new_channel` several times for a same peripheral, make sure you call this API the same times.
|
* @note If you call `gdma_new_channel` several times for a same peripheral, make sure you call this API the same times.
|
||||||
|
@@ -18,6 +18,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
||||||
|
|
||||||
|
#define GDMA_LL_CHANNEL_MAX_PRIORITY 5 // supported priority levels: [0,5]
|
||||||
|
|
||||||
#define GDMA_LL_RX_EVENT_MASK (0x06A7)
|
#define GDMA_LL_RX_EVENT_MASK (0x06A7)
|
||||||
#define GDMA_LL_TX_EVENT_MASK (0x1958)
|
#define GDMA_LL_TX_EVENT_MASK (0x1958)
|
||||||
|
|
||||||
|
@@ -18,6 +18,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
||||||
|
|
||||||
|
#define GDMA_LL_CHANNEL_MAX_PRIORITY 5 // supported priority levels: [0,5]
|
||||||
|
|
||||||
#define GDMA_LL_RX_EVENT_MASK (0x06A7)
|
#define GDMA_LL_RX_EVENT_MASK (0x06A7)
|
||||||
#define GDMA_LL_TX_EVENT_MASK (0x1958)
|
#define GDMA_LL_TX_EVENT_MASK (0x1958)
|
||||||
|
|
||||||
|
@@ -19,6 +19,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
||||||
|
|
||||||
|
#define GDMA_LL_CHANNEL_MAX_PRIORITY 5 // supported priority levels: [0,5]
|
||||||
|
|
||||||
#define GDMA_LL_RX_EVENT_MASK (0x7F)
|
#define GDMA_LL_RX_EVENT_MASK (0x7F)
|
||||||
#define GDMA_LL_TX_EVENT_MASK (0x3F)
|
#define GDMA_LL_TX_EVENT_MASK (0x3F)
|
||||||
|
|
||||||
|
@@ -19,6 +19,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
||||||
|
|
||||||
|
#define GDMA_LL_CHANNEL_MAX_PRIORITY 5 // supported priority levels: [0,5]
|
||||||
|
|
||||||
#define GDMA_LL_RX_EVENT_MASK (0x7F)
|
#define GDMA_LL_RX_EVENT_MASK (0x7F)
|
||||||
#define GDMA_LL_TX_EVENT_MASK (0x3F)
|
#define GDMA_LL_TX_EVENT_MASK (0x3F)
|
||||||
|
|
||||||
|
@@ -18,6 +18,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
||||||
|
|
||||||
|
#define GDMA_LL_CHANNEL_MAX_PRIORITY 5 // supported priority levels: [0,5]
|
||||||
|
|
||||||
#define GDMA_LL_RX_EVENT_MASK (0x06A7)
|
#define GDMA_LL_RX_EVENT_MASK (0x06A7)
|
||||||
#define GDMA_LL_TX_EVENT_MASK (0x1958)
|
#define GDMA_LL_TX_EVENT_MASK (0x1958)
|
||||||
|
|
||||||
|
@@ -18,6 +18,8 @@ extern "C" {
|
|||||||
|
|
||||||
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
||||||
|
|
||||||
|
#define GDMA_LL_CHANNEL_MAX_PRIORITY 5 // supported priority levels: [0,5]
|
||||||
|
|
||||||
#define GDMA_LL_RX_EVENT_MASK (0x3FF)
|
#define GDMA_LL_RX_EVENT_MASK (0x3FF)
|
||||||
#define GDMA_LL_TX_EVENT_MASK (0xFF)
|
#define GDMA_LL_TX_EVENT_MASK (0xFF)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user