From dafd4ef30b82a1d974e499c56070aab13ffef2bd Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Fri, 15 Nov 2024 12:19:30 -0800 Subject: [PATCH] Remove ARM assembly from RISC-V CYW43 SPI PIO Add hand-coded assembly RISC-V version of swap16x2 for CYW32 SPI PIO driver. Fixes #2044 --- src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c b/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c index d9265dd0b..73996a8f9 100644 --- a/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c +++ b/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c @@ -80,7 +80,15 @@ static uint32_t counter = 0; //#define SWAP32(A) ((((A) & 0xff000000U) >> 8) | (((A) & 0xff0000U) << 8) | (((A) & 0xff00U) >> 8) | (((A) & 0xffU) << 8)) __force_inline static uint32_t __swap16x2(uint32_t a) { +#ifndef __riscv pico_default_asm ("rev16 %0, %0" : "+l" (a) : : ); +#else + uint32_t tmp; + pico_default_asm ( + "rev8 %1, %0\n" + "rori %0, %1, 16\n" + : "+l" (a), "=l" (tmp)); +#endif return a; } #define SWAP32(a) __swap16x2(a) @@ -596,4 +604,4 @@ uint cyw43_get_pin_wl(cyw43_pin_index_t pin_id) { assert(cyw43_pin_array[pin_id] < NUM_BANK0_GPIOS); return cyw43_pin_array[pin_id]; } -#endif // CYW43_PIN_WL_DYNAMIC \ No newline at end of file +#endif // CYW43_PIN_WL_DYNAMIC