Skip to content

Commit c02e8eb

Browse files
committed
rp2: Add mp_hal_is_pin_reserved.
As cyw43 pins might be dynamic, add a function that returns if a pin is reserved. This is used by MICROPY_HW_PIN_RESERVED Signed-off-by: Peter Harper <[email protected]>
1 parent 3c2c427 commit c02e8eb

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
@@ -268,3 +268,11 @@ void soft_timer_init(void) {
268268
void mp_wfe_or_timeout(uint32_t timeout_ms) {
269269
best_effort_wfe_or_timeout(delayed_by_ms(get_absolute_time(), timeout_ms));
270270
}
271+
272+
int mp_hal_is_pin_reserved(int n) {
273+
#if MICROPY_PY_NETWORK_CYW43
274+
return n == CYW43_PIN_WL_HOST_WAKE;
275+
#else
276+
return false;
277+
#endif
278+
}

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)