Skip to content

Commit e68aa40

Browse files
committed
extmod/modmachine: Add MICROPY_PY_MACHINE_PIN_BASE option.
And use it in qemu-arm, unix and windows ports to enable PinBase. Signed-off-by: Damien George <[email protected]>
1 parent 30a63a2 commit e68aa40

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

extmod/machine_pinbase.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
#include "py/mpconfig.h"
28-
#if MICROPY_PY_MACHINE
29-
3027
#include "py/runtime.h"
28+
29+
#if MICROPY_PY_MACHINE_PIN_BASE
30+
3131
#include "extmod/modmachine.h"
3232
#include "extmod/virtpin.h"
3333

@@ -84,4 +84,4 @@ MP_DEFINE_CONST_OBJ_TYPE(
8484
protocol, &pinbase_pin_p
8585
);
8686

87-
#endif // MICROPY_PY_MACHINE
87+
#endif // MICROPY_PY_MACHINE_PIN_BASE

extmod/modmachine.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = {
8181
{ MP_ROM_QSTR(MP_QSTR_time_pulse_us), MP_ROM_PTR(&machine_time_pulse_us_obj) },
8282
#endif
8383

84-
// Class for Signal.
84+
// Classes for PinBase and Signal.
85+
#if MICROPY_PY_MACHINE_PIN_BASE
86+
{ MP_ROM_QSTR(MP_QSTR_PinBase), MP_ROM_PTR(&machine_pinbase_type) },
87+
#endif
8588
{ MP_ROM_QSTR(MP_QSTR_Signal), MP_ROM_PTR(&machine_signal_type) },
8689

8790
// Classes for software bus protocols.

ports/qemu-arm/modmachine.c

-3
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
// This file is never compiled standalone, it's included directly from
2828
// extmod/modmachine.c via MICROPY_PY_MACHINE_INCLUDEFILE.
2929

30-
#define MICROPY_PY_MACHINE_EXTRA_GLOBALS \
31-
{ MP_ROM_QSTR(MP_QSTR_PinBase), MP_ROM_PTR(&machine_pinbase_type) }, \
32-
3330
// This variable is needed for machine.soft_reset(), but the variable is otherwise unused.
3431
int pyexec_system_exit = 0;
3532

ports/qemu-arm/mpconfigport.h

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#define MICROPY_PY_HASHLIB (1)
4949
#define MICROPY_PY_MACHINE (1)
5050
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/qemu-arm/modmachine.c"
51+
#define MICROPY_PY_MACHINE_PIN_BASE (1)
5152
#define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
5253
#define MICROPY_USE_INTERNAL_PRINTF (1)
5354
#define MICROPY_VFS (1)

ports/unix/modmachine.c

-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
#define MICROPY_PAGE_MASK (MICROPY_PAGE_SIZE - 1)
3737
#endif
3838

39-
#define MICROPY_PY_MACHINE_EXTRA_GLOBALS \
40-
{ MP_ROM_QSTR(MP_QSTR_PinBase), MP_ROM_PTR(&machine_pinbase_type) }, \
41-
4239
// This variable is needed for machine.soft_reset(), but the variable is otherwise unused.
4340
int pyexec_system_exit = 0;
4441

ports/unix/variants/mpconfigvariant_common.h

+1
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,4 @@
116116
// Enable the "machine" module, mostly for machine.mem*.
117117
#define MICROPY_PY_MACHINE (1)
118118
#define MICROPY_PY_MACHINE_PULSE (1)
119+
#define MICROPY_PY_MACHINE_PIN_BASE (1)

ports/windows/mpconfigport.h

+1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
#define MICROPY_PY_MACHINE (1)
157157
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/unix/modmachine.c"
158158
#define MICROPY_PY_MACHINE_PULSE (1)
159+
#define MICROPY_PY_MACHINE_PIN_BASE (1)
159160
#define MICROPY_MACHINE_MEM_GET_READ_ADDR mod_machine_mem_get_addr
160161
#define MICROPY_MACHINE_MEM_GET_WRITE_ADDR mod_machine_mem_get_addr
161162

0 commit comments

Comments
 (0)