Skip to content

Commit 0f847db

Browse files
Remove ARM assembly from RISC-V CYW43 SPI PIO (#2045)
Add hand-coded assembly RISC-V version of swap16x2 for CYW32 SPI PIO driver. Fixes #2044
1 parent 1b64cac commit 0f847db

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,15 @@ static uint32_t counter = 0;
8080

8181
//#define SWAP32(A) ((((A) & 0xff000000U) >> 8) | (((A) & 0xff0000U) << 8) | (((A) & 0xff00U) >> 8) | (((A) & 0xffU) << 8))
8282
__force_inline static uint32_t __swap16x2(uint32_t a) {
83+
#ifndef __riscv
8384
pico_default_asm ("rev16 %0, %0" : "+l" (a) : : );
85+
#else
86+
uint32_t tmp;
87+
pico_default_asm (
88+
"rev8 %1, %0\n"
89+
"rori %0, %1, 16\n"
90+
: "+l" (a), "=l" (tmp));
91+
#endif
8492
return a;
8593
}
8694
#define SWAP32(a) __swap16x2(a)
@@ -596,4 +604,4 @@ uint cyw43_get_pin_wl(cyw43_pin_index_t pin_id) {
596604
assert(cyw43_pin_array[pin_id] < NUM_BANK0_GPIOS);
597605
return cyw43_pin_array[pin_id];
598606
}
599-
#endif // CYW43_PIN_WL_DYNAMIC
607+
#endif // CYW43_PIN_WL_DYNAMIC

0 commit comments

Comments
 (0)