Skip to content

Commit 5d49a68

Browse files
committed
Merge branch 'refactor/esp_hal_parlio' into 'master'
feat(hal): graudate the parlio hal driver into a new component Closes IDF-14099 See merge request espressif/esp-idf!43359
2 parents e50f129 + 873d902 commit 5d49a68

File tree

43 files changed

+195
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+195
-172
lines changed

components/esp_driver_parlio/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ endif()
2121
idf_component_register(SRCS ${srcs}
2222
INCLUDE_DIRS ${public_include}
2323
PRIV_REQUIRES "${priv_requires}"
24+
REQUIRES esp_hal_parlio
2425
LDFRAGMENTS "linker.lf"
2526
)

components/esp_driver_parlio/linker.lf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ entries:
3333
esp_dma_utils: esp_dma_split_rx_buffer_to_cache_aligned (noflash)
3434
esp_dma_utils: esp_dma_merge_aligned_rx_buffers (noflash)
3535

36-
[mapping:parlio_driver_soc_periph]
37-
archive: libsoc.a
36+
[mapping:parlio_driver_hal_periph]
37+
archive: libesp_hal_parlio.a
3838
entries:
3939
if PARLIO_RX_ISR_HANDLER_IN_IRAM = y:
4040
parlio_periph: parlio_periph_signals (noflash)

components/esp_driver_parlio/src/parlio_common.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
typedef struct parlio_platform_t {
1313
_lock_t mutex; // platform level mutex lock
14-
parlio_group_t *groups[SOC_PARLIO_GROUPS]; // array of parallel IO group instances
15-
int group_ref_counts[SOC_PARLIO_GROUPS]; // reference count used to protect group install/uninstall
14+
parlio_group_t *groups[PARLIO_LL_GET(INST_NUM)]; // array of parallel IO group instances
15+
int group_ref_counts[PARLIO_LL_GET(INST_NUM)]; // reference count used to protect group install/uninstall
1616
} parlio_platform_t;
1717

1818
static parlio_platform_t s_platform; // singleton platform
@@ -110,20 +110,20 @@ esp_err_t parlio_register_unit_to_group(parlio_unit_base_handle_t unit)
110110
{
111111
parlio_group_t *group = NULL;
112112
int unit_id = -1;
113-
for (int i = 0; i < SOC_PARLIO_GROUPS; i++) {
113+
for (int i = 0; i < PARLIO_LL_GET(INST_NUM); i++) {
114114
group = parlio_acquire_group_handle(i);
115115
ESP_RETURN_ON_FALSE(group, ESP_ERR_NO_MEM, TAG, "no memory for group (%d)", i);
116116
portENTER_CRITICAL(&group->spinlock);
117117
if (unit->dir == PARLIO_DIR_TX) {
118-
for (int j = 0; j < SOC_PARLIO_TX_UNITS_PER_GROUP; j++) {
118+
for (int j = 0; j < PARLIO_LL_GET(TX_UNITS_PER_INST); j++) {
119119
if (!group->tx_units[j]) {
120120
group->tx_units[j] = unit;
121121
unit_id = j;
122122
break;
123123
}
124124
}
125125
} else {
126-
for (int j = 0; j < SOC_PARLIO_RX_UNITS_PER_GROUP; j++) {
126+
for (int j = 0; j < PARLIO_LL_GET(RX_UNITS_PER_INST); j++) {
127127
if (!group->rx_units[j]) {
128128
group->rx_units[j] = unit;
129129
unit_id = j;

components/esp_driver_parlio/src/parlio_priv.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "freertos/idf_additions.h"
2929
#include "soc/soc_caps.h"
3030
#include "soc/gdma_channel.h"
31-
#include "soc/parlio_periph.h"
31+
#include "hal/parlio_periph.h"
3232
#include "hal/parlio_types.h"
3333
#include "hal/parlio_hal.h"
3434
#include "hal/parlio_ll.h"
@@ -133,8 +133,8 @@ typedef struct parlio_group_t {
133133
portMUX_TYPE spinlock; // to protect per-group register level concurrent access
134134
parlio_hal_context_t hal; // hal layer context
135135
uint32_t dma_align; // DMA buffer alignment
136-
parlio_unit_base_handle_t tx_units[SOC_PARLIO_TX_UNITS_PER_GROUP]; // tx unit handles
137-
parlio_unit_base_handle_t rx_units[SOC_PARLIO_RX_UNITS_PER_GROUP]; // rx unit handles
136+
parlio_unit_base_handle_t tx_units[PARLIO_LL_GET(TX_UNITS_PER_INST)]; // tx unit handles
137+
parlio_unit_base_handle_t rx_units[PARLIO_LL_GET(RX_UNITS_PER_INST)]; // rx unit handles
138138
} parlio_group_t;
139139

140140
/**

components/esp_driver_parlio/src/parlio_rx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,14 @@ static esp_err_t parlio_rx_unit_set_gpio(parlio_rx_unit_handle_t rx_unit, const
268268
/* When the source clock comes from internal and supported to output the internal clock,
269269
* enable the gpio output direction and connect to the clock output signal */
270270
if (config->clk_out_gpio_num >= 0) {
271-
#if SOC_PARLIO_RX_CLK_SUPPORT_OUTPUT
271+
#if PARLIO_LL_SUPPORT(RX_CLK_OUTPUT)
272272
gpio_func_sel(config->clk_out_gpio_num, PIN_FUNC_GPIO);
273273
// connect the signal to the GPIO by matrix, it will also enable the output path properly
274274
esp_rom_gpio_connect_out_signal(config->clk_out_gpio_num,
275275
parlio_periph_signals.groups[group_id].rx_units[unit_id].clk_out_sig, false, false);
276276
#else
277277
ESP_RETURN_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, TAG, "this target not support to output the clock");
278-
#endif // SOC_PARLIO_RX_CLK_SUPPORT_OUTPUT
278+
#endif // PARLIO_LL_SUPPORT(RX_CLK_OUTPUT)
279279
}
280280

281281
/* Initialize the valid GPIO as input */

components/esp_driver_parlio/src/parlio_tx.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,14 +520,14 @@ static void parlio_tx_do_transaction(parlio_tx_unit_t *tx_unit, parlio_tx_trans_
520520
}
521521
} else {
522522
// non-loop transmission
523-
#if SOC_PARLIO_TX_SUPPORT_EOF_FROM_DMA
523+
#if PARLIO_LL_SUPPORT(TX_EOF_FROM_DMA)
524524
// for DMA EOF supported target, we need to set the EOF condition to DMA EOF
525525
parlio_ll_tx_set_eof_condition(hal->regs, PARLIO_LL_TX_EOF_COND_DMA_EOF);
526526
#else
527527
// for DMA EOF not supported target, we need to set the bit length to the configured bit lens
528528
parlio_ll_tx_set_eof_condition(hal->regs, PARLIO_LL_TX_EOF_COND_DATA_LEN);
529529
parlio_ll_tx_set_trans_bit_len(hal->regs, t->payload_bits);
530-
#endif // SOC_PARLIO_TX_SUPPORT_EOF_FROM_DMA
530+
#endif // PARLIO_LL_SUPPORT(TX_EOF_FROM_DMA)
531531
}
532532

533533
if (tx_unit->bs_handle) {
@@ -641,9 +641,9 @@ esp_err_t parlio_tx_unit_transmit(parlio_tx_unit_handle_t tx_unit, const void *p
641641
ESP_RETURN_ON_FALSE(tx_unit && payload && payload_bits, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
642642
ESP_RETURN_ON_FALSE((payload_bits % tx_unit->data_width) == 0, ESP_ERR_INVALID_ARG, TAG, "payload bit length must align to bus width");
643643
ESP_RETURN_ON_FALSE(payload_bits <= tx_unit->max_transfer_bits, ESP_ERR_INVALID_ARG, TAG, "payload bit length too large");
644-
#if !SOC_PARLIO_TRANS_BIT_ALIGN
644+
#if !PARLIO_LL_SUPPORT(TRANS_BIT_ALIGN)
645645
ESP_RETURN_ON_FALSE((payload_bits % 8) == 0, ESP_ERR_INVALID_ARG, TAG, "payload bit length must be multiple of 8");
646-
#endif // !SOC_PARLIO_TRANS_BIT_ALIGN
646+
#endif // !PARLIO_LL_SUPPORT(TRANS_BIT_ALIGN)
647647

648648
#if SOC_PARLIO_TX_SUPPORT_LOOP_TRANSMISSION
649649
if (config->flags.loop_transmission) {
@@ -654,13 +654,13 @@ esp_err_t parlio_tx_unit_transmit(parlio_tx_unit_handle_t tx_unit, const void *p
654654
ESP_RETURN_ON_FALSE(config->flags.loop_transmission == false, ESP_ERR_NOT_SUPPORTED, TAG, "loop transmission is not supported on this chip");
655655
#endif
656656

657-
#if !SOC_PARLIO_TX_SUPPORT_EOF_FROM_DMA
657+
#if !PARLIO_LL_SUPPORT(TX_EOF_FROM_DMA)
658658
// check the max payload size if it's not a loop transmission and the DMA EOF is not supported
659659
if (!config->flags.loop_transmission) {
660660
ESP_RETURN_ON_FALSE(tx_unit->max_transfer_bits <= PARLIO_LL_TX_MAX_BITS_PER_FRAME,
661661
ESP_ERR_INVALID_ARG, TAG, "invalid transfer size, max transfer size should be less than %d", PARLIO_LL_TX_MAX_BITS_PER_FRAME / 8);
662662
}
663-
#endif // !SOC_PARLIO_TX_SUPPORT_EOF_FROM_DMA
663+
#endif // !PARLIO_LL_SUPPORT(TX_EOF_FROM_DMA)
664664

665665
size_t alignment = esp_ptr_external_ram(payload) ? tx_unit->ext_mem_align : tx_unit->int_mem_align;
666666
// check alignment

components/esp_driver_parlio/test_apps/parlio/CMakeLists.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ project(parlio_test)
99

1010
idf_build_get_property(elf EXECUTABLE)
1111
if(CONFIG_COMPILER_DUMP_RTL_FILES)
12-
add_custom_target(check_test_app_sections ALL
13-
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
14-
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/esp_driver_parlio/,${CMAKE_BINARY_DIR}/esp-idf/hal/
15-
--elf-file ${CMAKE_BINARY_DIR}/parlio_test.elf
16-
find-refs
17-
--from-sections=.iram0.text
18-
--to-sections=.flash.text,.flash.rodata
19-
--exit-code
20-
DEPENDS ${elf}
21-
)
12+
add_custom_target(
13+
check_test_app_sections ALL
14+
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
15+
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/esp_driver_parlio/,${CMAKE_BINARY_DIR}/esp-idf/esp_hal_parlio/
16+
--elf-file ${CMAKE_BINARY_DIR}/parlio_test.elf
17+
find-refs
18+
--from-sections=.iram0.text
19+
--to-sections=.flash.text,.flash.rodata
20+
--exit-code
21+
DEPENDS ${elf}
22+
)
2223
endif()
2324

2425
message(STATUS "Checking parlio registers are not read-write by half-word")

components/esp_driver_parlio/test_apps/parlio/main/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ endif()
1919
idf_component_register(SRCS ${srcs}
2020
PRIV_REQUIRES unity esp_driver_parlio esp_driver_gpio
2121
esp_driver_i2s esp_driver_spi esp_psram
22-
esp_driver_bitscrambler
22+
esp_driver_bitscrambler esp_hal_parlio
2323
WHOLE_ARCHIVE)
2424

2525
if(CONFIG_SOC_BITSCRAMBLER_SUPPORTED)

components/esp_driver_parlio/test_apps/parlio/main/test_parlio_bitscrambler.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ TEST_CASE("parlio_tx_bitscrambler_test", "[parlio_bitscrambler]")
202202
test_parlio_bitscrambler();
203203
}
204204

205-
#if SOC_PARLIO_TX_SUPPORT_EOF_FROM_DMA
205+
#if PARLIO_LL_SUPPORT(TX_EOF_FROM_DMA)
206206
static void test_parlio_bitscrambler_different_input_output_sizes(void)
207207
{
208208
parlio_tx_unit_handle_t tx_unit = NULL;
@@ -353,4 +353,4 @@ TEST_CASE("parlio_tx_bitscrambler_different_input_output_sizes_test", "[parlio_b
353353
{
354354
test_parlio_bitscrambler_different_input_output_sizes();
355355
}
356-
#endif // SOC_PARLIO_TX_SUPPORT_EOF_FROM_DMA
356+
#endif // PARLIO_LL_SUPPORT(TX_EOF_FROM_DMA)

components/esp_driver_parlio/test_apps/parlio/main/test_parlio_rx.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#include "hal/cache_ll.h"
2121
#include "soc/soc_caps.h"
2222
#include "soc/spi_periph.h"
23-
#include "soc/parlio_periph.h"
23+
#include "hal/parlio_periph.h"
24+
#include "hal/parlio_ll.h"
2425
#include "esp_attr.h"
2526
#include "test_board.h"
2627
#include "esp_private/parlio_rx_private.h"
@@ -29,7 +30,7 @@
2930
#define TEST_I2S_PORT I2S_NUM_0
3031
#define TEST_VALID_SIG (PARLIO_RX_UNIT_MAX_DATA_WIDTH - 1)
3132

32-
#if SOC_PARLIO_RX_CLK_SUPPORT_OUTPUT
33+
#if PARLIO_LL_SUPPORT(RX_CLK_OUTPUT)
3334
#define TEST_OUTPUT_CLK_PIN TEST_CLK_GPIO
3435
#else
3536
#define TEST_OUTPUT_CLK_PIN -1
@@ -399,11 +400,11 @@ TEST_CASE("parallel_rx_unit_pulse_delimiter_test_via_i2s", "[parlio_rx]")
399400
TEST_CASE("parallel_rx_unit_install_uninstall", "[parlio_rx]")
400401
{
401402
printf("install rx units exhaustively\r\n");
402-
parlio_rx_unit_handle_t units[SOC_PARLIO_GROUPS * SOC_PARLIO_RX_UNITS_PER_GROUP];
403+
parlio_rx_unit_handle_t units[PARLIO_LL_GET(INST_NUM) * PARLIO_LL_GET(RX_UNITS_PER_INST)];
403404
int k = 0;
404405
parlio_rx_unit_config_t config = TEST_DEFAULT_UNIT_CONFIG(PARLIO_CLK_SRC_DEFAULT, 1000000);
405-
for (int i = 0; i < SOC_PARLIO_GROUPS; i++) {
406-
for (int j = 0; j < SOC_PARLIO_RX_UNITS_PER_GROUP; j++) {
406+
for (int i = 0; i < PARLIO_LL_GET(INST_NUM); i++) {
407+
for (int j = 0; j < PARLIO_LL_GET(RX_UNITS_PER_INST); j++) {
407408
TEST_ESP_OK(parlio_new_rx_unit(&config, &units[k++]));
408409
}
409410
}
@@ -421,7 +422,7 @@ TEST_CASE("parallel_rx_unit_install_uninstall", "[parlio_rx]")
421422
// clock from internal
422423
config.clk_src = PARLIO_CLK_SRC_DEFAULT;
423424
config.clk_out_gpio_num = TEST_CLK_GPIO;
424-
#if SOC_PARLIO_RX_CLK_SUPPORT_OUTPUT
425+
#if PARLIO_LL_SUPPORT(RX_CLK_OUTPUT)
425426
TEST_ESP_OK(parlio_new_rx_unit(&config, &units[0]));
426427
TEST_ESP_OK(parlio_del_rx_unit(units[0]));
427428
#else

0 commit comments

Comments
 (0)