mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
refactor(rmt): use gdma link list driver to mount buffer
This commit is contained in:
committed by
Chen Ji Chang
parent
844dc17b43
commit
4ee0feeb6f
@@ -227,17 +227,21 @@ uintptr_t gdma_link_get_head_addr(gdma_link_list_handle_t list)
|
||||
|
||||
esp_err_t gdma_link_concat(gdma_link_list_handle_t first_link, int first_link_item_index, gdma_link_list_handle_t second_link, int second_link_item_index)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(first_link && second_link, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
|
||||
ESP_RETURN_ON_FALSE(first_link, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
|
||||
gdma_link_list_item_t *lli_nc = NULL;
|
||||
// ensure the first_link_item_index is between 0 and `num_items - 1`
|
||||
int num_items = first_link->num_items;
|
||||
first_link_item_index = (first_link_item_index % num_items + num_items) % num_items;
|
||||
lli_nc = (gdma_link_list_item_t *)(first_link->items_nc + first_link_item_index * first_link->item_size);
|
||||
// ensure the second_link_item_index is between 0 and `num_items - 1`
|
||||
num_items = second_link->num_items;
|
||||
second_link_item_index = (second_link_item_index % num_items + num_items) % num_items;
|
||||
// concatenate the two link lists
|
||||
lli_nc->next = (gdma_link_list_item_t *)(second_link->items + second_link_item_index * second_link->item_size);
|
||||
if (second_link == NULL) {
|
||||
lli_nc->next = NULL;
|
||||
} else {
|
||||
// ensure the second_link_item_index is between 0 and `num_items - 1`
|
||||
num_items = second_link->num_items;
|
||||
second_link_item_index = (second_link_item_index % num_items + num_items) % num_items;
|
||||
// concatenate the two link lists
|
||||
lli_nc->next = (gdma_link_list_item_t *)(second_link->items + second_link_item_index * second_link->item_size);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -284,7 +288,7 @@ size_t gdma_link_count_buffer_size_till_eof(gdma_link_list_handle_t list, int st
|
||||
return buf_size;
|
||||
}
|
||||
|
||||
void *gdma_link_get_buffer(gdma_link_list_handle_t list, int item_index)
|
||||
void* gdma_link_get_buffer(gdma_link_list_handle_t list, int item_index)
|
||||
{
|
||||
if (!list) {
|
||||
return NULL;
|
||||
@@ -307,3 +311,26 @@ size_t gdma_link_get_length(gdma_link_list_handle_t list, int item_index)
|
||||
gdma_link_list_item_t *lli = (gdma_link_list_item_t *)(list->items_nc + item_index * list->item_size);
|
||||
return lli->dw0.length;
|
||||
}
|
||||
|
||||
esp_err_t gdma_link_set_length(gdma_link_list_handle_t list, int item_index, size_t length)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE_ISR(list, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
|
||||
int num_items = list->num_items;
|
||||
// ensure the item_index is between 0 and `num_items - 1`
|
||||
item_index = (item_index % num_items + num_items) % num_items;
|
||||
gdma_link_list_item_t *lli = (gdma_link_list_item_t *)(list->items_nc + item_index * list->item_size);
|
||||
lli->dw0.length = length;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
bool gdma_link_check_end(gdma_link_list_handle_t list, int item_index)
|
||||
{
|
||||
if (!list) {
|
||||
return false;
|
||||
}
|
||||
int num_items = list->num_items;
|
||||
// ensure the item_index is between 0 and `num_items - 1`
|
||||
item_index = (item_index % num_items + num_items) % num_items;
|
||||
gdma_link_list_item_t *lli = (gdma_link_list_item_t *)(list->items_nc + item_index * list->item_size);
|
||||
return lli->next == NULL;
|
||||
}
|
||||
|
||||
@@ -121,6 +121,8 @@ uintptr_t gdma_link_get_head_addr(gdma_link_list_handle_t list);
|
||||
* Link A: A1 --> B3 --> B4
|
||||
* Link B: B1 --> B2 --> B3 --> B4
|
||||
*
|
||||
* @note If the second link is NULL, the next item of the first_link_item will be set to NULL. And the second_link_item_index is meaningless.
|
||||
*
|
||||
* @param[in] first_link First link list handle, allocated by `gdma_new_link_list`
|
||||
* @param[in] first_link_item_index Index of the item in the first link list (-1 means the last item)
|
||||
* @param[in] second_link Second link list handle, allocated by `gdma_new_link_list`
|
||||
@@ -194,6 +196,28 @@ void* gdma_link_get_buffer(gdma_link_list_handle_t list, int item_index);
|
||||
*/
|
||||
size_t gdma_link_get_length(gdma_link_list_handle_t list, int item_index);
|
||||
|
||||
/**
|
||||
* @brief Set the length of the buffer of a DMA link list item
|
||||
*
|
||||
* @param[in] list Link list handle, allocated by `gdma_new_link_list`
|
||||
* @param[in] item_index Index of the link list item
|
||||
* @param[in] length Length of the buffer of the link list item
|
||||
* @return
|
||||
* - ESP_OK: Set the length successfully
|
||||
* - ESP_ERR_INVALID_ARG: Set the length failed because of invalid argument
|
||||
* - ESP_FAIL: Set the length failed because of other error
|
||||
*/
|
||||
esp_err_t gdma_link_set_length(gdma_link_list_handle_t list, int item_index, size_t length);
|
||||
|
||||
/**
|
||||
* @brief Check if a DMA link list item is the last item (has no next item)
|
||||
*
|
||||
* @param[in] list Link list handle, allocated by `gdma_new_link_list`
|
||||
* @param[in] item_index Index of the link list item
|
||||
* @return True if the link list item is the last item, false otherwise
|
||||
*/
|
||||
bool gdma_link_check_end(gdma_link_list_handle_t list, int item_index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user