8000 rp2/mphalport: Add mp_hal_is_pin_reserved() function. · 32bitmicro/micropython@4a6c246 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4a6c246

Browse files
peterharperukdpgeorge
authored andcommitted
rp2/mphalport: Add mp_hal_is_pin_reserved() function.
As cyw43 pins might be dynamic, add a function that returns if a pin is reserved. This is used by `MICROPY_HW_PIN_RESERVED` to prevent the pin IRQ from being reset across a soft-reset. Signed-off-by: Peter Harper <peter.harper@raspberrypi.com>
1 parent 30163e0 commit 4a6c246

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

ports/rp2/boards/RPI_PICO_W/mpconfigboard.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@
2020

2121
#define MICROPY_HW_PIN_EXT_COUNT CYW43_WL_GPIO_COUNT
2222

23-
#define MICROPY_HW_PIN_RESERVED(i) ((i) == CYW43_PIN_WL_HOST_WAKE || (i) == CYW43_PIN_WL_REG_ON)
23+
// If this returns true for a pin then its irq will not be disabled on a soft reboot
24+
int mp_hal_is_pin_reserved(int n);
25+
#define MICROPY_HW_PIN_RESERVED(i) mp_hal_is_pin_reserved(i)

ports/rp2/mphalport.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,3 +278,11 @@ void mp_wfe_or_timeout(uint32_t timeout_ms) {
278278
// Clean up the timer node if it's not already
279279
soft_timer_remove(&timer);
280280
}
281+
282+
int mp_hal_is_pin_reserved(int n) {
283+
#if MICROPY_PY_NETWORK_CYW43
284+
return n == CYW43_PIN_WL_HOST_WAKE;
285+
#else
286+
return false;
287+
#endif
288+
}

ports/rp2/mphalport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,5 +210,6 @@ enum {
210210
void mp_hal_get_mac(int idx, uint8_t buf[6]);
211211
void mp_hal_get_mac_ascii(int idx, size_t chr_off, size_t chr_len, char *dest);
212212
void mp_hal_generate_laa_mac(int idx, uint8_t buf[6]);
213+
int mp_hal_is_pin_reserved(int n);
213214

214215
#endif // MICROPY_INCLUDED_RP2_MPHALPORT_H

0 commit comments

Comments
 (0)
0