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

Support modonewire from vanilla MicroPython #356

Open
wants to merge 2 commits into
base: Dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions esp32/hal/esp32_mphal.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,21 @@ void mp_hal_set_interrupt_char(int c);
void mp_hal_set_reset_char(int c);
void mp_hal_reset_safe_and_boot(bool reset);

// https://github.com/micropython/micropython/blob/master/ports/esp32/mphalport.h
#define mp_hal_quiet_timing_enter() MICROPY_BEGIN_ATOMIC_SECTION()
#define mp_hal_quiet_timing_exit(irq_state) MICROPY_END_ATOMIC_SECTION(irq_state)
#define mp_hal_delay_us_fast(us) ets_delay_us(us)

// C-level pin HAL
#include "py/obj.h"
#include "machpin.h"
#define mp_hal_pin_obj_t mp_obj_t
#define mp_hal_get_pin_obj(pin) (pin)
#define mp_hal_pin_write(p, v) do { \
pin_obj_t *npin = pin_find(p); \
npin->value = v; \
pin_set_value(npin); \
} while (0)
#define mp_hal_pin_read(p) pin_get_value(pin_find(p))

#endif // _INCLUDED_MPHAL_H_
2 changes: 2 additions & 0 deletions esp32/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ extern const struct _mp_obj_module_t mp_module_uhashlib;
extern const struct _mp_obj_module_t module_ucrypto;
extern const struct _mp_obj_module_t mp_module_ussl;
extern const struct _mp_obj_module_t mp_module_uqueue;
extern const struct _mp_obj_module_t mp_module_onewire;

#define MICROPY_PORT_BUILTIN_MODULES \
{ MP_OBJ_NEW_QSTR(MP_QSTR_umachine), (mp_obj_t)&machine_module }, \
Expand All @@ -206,6 +207,7 @@ extern const struct _mp_obj_module_t mp_module_uqueue;
{ MP_OBJ_NEW_QSTR(MP_QSTR_ussl), (mp_obj_t)&mp_module_ussl }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_uerrno), (mp_obj_t)&mp_module_uerrno }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR_uqueue), (mp_obj_t)&mp_module_uqueue }, \
{ MP_OBJ_NEW_QSTR(MP_QSTR__onewire), (mp_obj_t)&mp_module_onewire }, \

#define MICROPY_PORT_BUILTIN_MODULE_WEAK_LINKS \
{ MP_OBJ_NEW_QSTR(MP_QSTR_machine), (mp_obj_t)&machine_module }, \
Expand Down
1 change: 1 addition & 0 deletions py/py.mk
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ PY_EXTMOD_O_BASENAME = \
extmod/moduwebsocket.o \
extmod/modwebrepl.o \
extmod/modframebuf.o \
extmod/modonewire.o \
extmod/vfs.o \
extmod/vfs_reader.o \
extmod/vfs_posix.o \
Expand Down