Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 53a270f

Browse files
committed
extmod/modonewire.c: Redefine C-level pin HAL functions from vanilla MPY
1 parent 8a48b92 commit 53a270f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

esp32/hal/esp32_mphal.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,16 @@ void mp_hal_reset_safe_and_boot(bool reset);
3535
#define mp_hal_quiet_timing_exit(irq_state) MICROPY_END_ATOMIC_SECTION(irq_state)
3636
#define mp_hal_delay_us_fast(us) ets_delay_us(us)
3737

38+
// C-level pin HAL
39+
#include "py/obj.h"
40+
#include "machpin.h"
41+
#define mp_hal_pin_obj_t mp_obj_t
42+
#define mp_hal_get_pin_obj(pin) (pin)
43+
#define mp_hal_pin_write(p, v) do { \
44+
pin_obj_t *npin = pin_find(p); \
45+
npin->value = v; \
46+
pin_set_value(npin); \
47+
} while (0)
48+
#define mp_hal_pin_read(p) pin_get_value(pin_find(p))
49+
3850
#endif // _INCLUDED_MPHAL_H_

0 commit comments

Comments
 (0)