summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2023-10-26 11:39:40 +1100
committerDamien George <damien@micropython.org>2023-10-26 16:20:53 +1100
commit90023b4dcf7bfeb6eccd5d0d13efc4832cf187e7 (patch)
tree97cab73dc63d239084f2ee8a05d8d712da9cf60c
parent5b4a2baff6b42b2b428cd58a95407a66387e4305 (diff)
extmod/modmachine: Clean up decls of machine types to use common ones.
The machine_i2c_type, machine_spi_type and machine_timer_type symbols are already declared in extmod/modmachine.h and should not be declared anywhere else. Also move declarations of machine_pin_type and machine_rtc_type to the common header in extmod. Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--drivers/esp-hosted/esp_hosted_hal.c3
-rw-r--r--drivers/ninaw10/nina_wifi_bsp.c3
-rw-r--r--extmod/modmachine.h2
-rw-r--r--ports/esp32/boards/pins_prefix.c2
-rw-r--r--ports/esp32/machine_hw_spi.c2
-rw-r--r--ports/esp32/machine_i2c.c2
-rw-r--r--ports/esp32/machine_pin.c3
-rw-r--r--ports/esp32/machine_rtc.c2
-rw-r--r--ports/esp32/modmachine.h5
-rw-r--r--ports/esp8266/modmachine.h1
-rw-r--r--ports/mimxrt/boards/mimxrt_prefix.c1
-rw-r--r--ports/mimxrt/machine_i2c.c2
-rw-r--r--ports/mimxrt/machine_rtc.c1
-rw-r--r--ports/mimxrt/machine_spi.c2
-rw-r--r--ports/mimxrt/machine_uart.c2
-rw-r--r--ports/mimxrt/modmachine.h4
-rw-r--r--ports/mimxrt/pin.c1
-rw-r--r--ports/mimxrt/pin.h1
-rw-r--r--ports/nrf/modules/machine/i2c.c1
-rw-r--r--ports/nrf/modules/machine/i2c.h2
-rw-r--r--ports/nrf/modules/machine/modmachine.h2
-rw-r--r--ports/nrf/modules/machine/spi.c1
-rw-r--r--ports/nrf/modules/machine/spi.h1
-rw-r--r--ports/nrf/modules/machine/timer.c2
-rw-r--r--ports/nrf/modules/machine/timer.h2
-rw-r--r--ports/renesas-ra/boards/ra_pin_prefix.c1
-rw-r--r--ports/renesas-ra/machine_i2c.c2
-rw-r--r--ports/renesas-ra/machine_pin.c3
-rw-r--r--ports/renesas-ra/machine_rtc.c1
-rw-r--r--ports/renesas-ra/machine_spi.c2
-rw-r--r--ports/renesas-ra/main.c1
-rw-r--r--ports/renesas-ra/modmachine.h6
-rw-r--r--ports/renesas-ra/modos.c1
-rw-r--r--ports/renesas-ra/mpbthciport.c2
-rw-r--r--ports/renesas-ra/pin.h1
-rw-r--r--ports/renesas-ra/rtc.h1
-rw-r--r--ports/renesas-ra/uart.h1
-rw-r--r--ports/rp2/boards/rp2_prefix.c1
-rw-r--r--ports/rp2/machine_i2c.c2
-rw-r--r--ports/rp2/machine_pin.c3
-rw-r--r--ports/rp2/machine_pin.h1
-rw-r--r--ports/rp2/machine_rtc.c2
-rw-r--r--ports/rp2/machine_spi.c2
-rw-r--r--ports/rp2/modmachine.h6
-rw-r--r--ports/samd/machine_i2c.c2
-rw-r--r--ports/samd/machine_rtc.c2
-rw-r--r--ports/samd/machine_spi.c2
-rw-r--r--ports/samd/modmachine.h11
-rw-r--r--ports/samd/pin_af.c2
-rw-r--r--ports/samd/samd_spiflash.c2
-rw-r--r--ports/stm32/machine_i2c.c5
-rw-r--r--ports/stm32/machine_spi.c1
-rw-r--r--ports/stm32/modmachine.h4
-rw-r--r--ports/stm32/spi.c1
-rw-r--r--ports/stm32/spi.h1
-rw-r--r--ports/zephyr/machine_i2c.c2
-rw-r--r--ports/zephyr/machine_pin.c1
-rw-r--r--ports/zephyr/machine_spi.c2
-rw-r--r--ports/zephyr/modmachine.h4
59 files changed, 44 insertions, 87 deletions
diff --git a/drivers/esp-hosted/esp_hosted_hal.c b/drivers/esp-hosted/esp_hosted_hal.c
index 4c3ecad13..e33b2cce4 100644
--- a/drivers/esp-hosted/esp_hosted_hal.c
+++ b/drivers/esp-hosted/esp_hosted_hal.c
@@ -34,9 +34,8 @@
#include <string.h>
#include "py/runtime.h"
-#include "modmachine.h"
#include "extmod/machine_spi.h"
-#include "mpconfigboard.h"
+#include "extmod/modmachine.h"
#ifdef MICROPY_HW_WIFI_LED
#include "led.h"
#endif
diff --git a/drivers/ninaw10/nina_wifi_bsp.c b/drivers/ninaw10/nina_wifi_bsp.c
index c65fb111f..42770a33c 100644
--- a/drivers/ninaw10/nina_wifi_bsp.c
+++ b/drivers/ninaw10/nina_wifi_bsp.c
@@ -35,9 +35,8 @@
#include <string.h>
#include "py/runtime.h"
-#include "modmachine.h"
#include "extmod/machine_spi.h"
-#include "mpconfigboard.h"
+#include "extmod/modmachine.h"
#include "nina_bsp.h"
#include "nina_wifi_drv.h"
diff --git a/extmod/modmachine.h b/extmod/modmachine.h
index c18c55553..2a7ce336e 100644
--- a/extmod/modmachine.h
+++ b/extmod/modmachine.h
@@ -96,7 +96,9 @@ typedef struct _machine_wdt_obj_t machine_wdt_obj_t;
extern const mp_obj_type_t machine_adc_type;
extern const mp_obj_type_t machine_i2c_type;
extern const mp_obj_type_t machine_i2s_type;
+extern const mp_obj_type_t machine_pin_type;
extern const mp_obj_type_t machine_pwm_type;
+extern const mp_obj_type_t machine_rtc_type;
extern const mp_obj_type_t machine_spi_type;
extern const mp_obj_type_t machine_timer_type;
extern const mp_obj_type_t machine_uart_type;
diff --git a/ports/esp32/boards/pins_prefix.c b/ports/esp32/boards/pins_prefix.c
index 2733ddaab..61988be7e 100644
--- a/ports/esp32/boards/pins_prefix.c
+++ b/ports/esp32/boards/pins_prefix.c
@@ -1,4 +1,4 @@
#include "py/obj.h"
+#include "extmod/modmachine.h"
#include "machine_pin.h"
-#include "modmachine.h"
#include "genhdr/pins.h"
diff --git a/ports/esp32/machine_hw_spi.c b/ports/esp32/machine_hw_spi.c
index e09c493f5..3a1dd1064 100644
--- a/ports/esp32/machine_hw_spi.c
+++ b/ports/esp32/machine_hw_spi.c
@@ -32,7 +32,7 @@
#include "py/stream.h"
#include "py/mphal.h"
#include "extmod/machine_spi.h"
-#include "modmachine.h"
+#include "extmod/modmachine.h"
#include "driver/spi_master.h"
#include "soc/gpio_sig_map.h"
diff --git a/ports/esp32/machine_i2c.c b/ports/esp32/machine_i2c.c
index d498aa058..4e3a9ee81 100644
--- a/ports/esp32/machine_i2c.c
+++ b/ports/esp32/machine_i2c.c
@@ -28,7 +28,7 @@
#include "py/mphal.h"
#include "py/mperrno.h"
#include "extmod/machine_i2c.h"
-#include "modmachine.h"
+#include "extmod/modmachine.h"
#include "driver/i2c.h"
#include "hal/i2c_ll.h"
diff --git a/ports/esp32/machine_pin.c b/ports/esp32/machine_pin.c
index 9f1bc5798..d521e08e5 100644
--- a/ports/esp32/machine_pin.c
+++ b/ports/esp32/machine_pin.c
@@ -35,9 +35,10 @@
#include "py/runtime.h"
#include "py/mphal.h"
+#include "extmod/modmachine.h"
+#include "extmod/virtpin.h"
#include "mphalport.h"
#include "modmachine.h"
-#include "extmod/virtpin.h"
#include "machine_pin.h"
#include "machine_rtc.h"
#include "modesp32.h"
diff --git a/ports/esp32/machine_rtc.c b/ports/esp32/machine_rtc.c
index 3d620336c..f7b3ae66f 100644
--- a/ports/esp32/machine_rtc.c
+++ b/ports/esp32/machine_rtc.c
@@ -36,8 +36,8 @@
#include "py/obj.h"
#include "py/runtime.h"
#include "py/mphal.h"
+#include "extmod/modmachine.h"
#include "shared/timeutils/timeutils.h"
-#include "modmachine.h"
#include "machine_rtc.h"
typedef struct _machine_rtc_obj_t {
diff --git a/ports/esp32/modmachine.h b/ports/esp32/modmachine.h
index f60715f77..7b26df609 100644
--- a/ports/esp32/modmachine.h
+++ b/ports/esp32/modmachine.h
@@ -9,14 +9,9 @@ typedef enum {
MACHINE_WAKE_DEEPSLEEP=0x04
} wake_type_t;
-extern const mp_obj_type_t machine_timer_type;
-extern const mp_obj_type_t machine_pin_type;
extern const mp_obj_type_t machine_touchpad_type;
extern const mp_obj_type_t machine_adcblock_type;
extern const mp_obj_type_t machine_dac_type;
-extern const mp_obj_type_t machine_i2c_type;
-extern const mp_obj_type_t machine_spi_type;
-extern const mp_obj_type_t machine_rtc_type;
extern const mp_obj_type_t machine_sdcard_type;
void machine_init(void);
diff --git a/ports/esp8266/modmachine.h b/ports/esp8266/modmachine.h
index 0c6a6afbb..5a90a6c6f 100644
--- a/ports/esp8266/modmachine.h
+++ b/ports/esp8266/modmachine.h
@@ -5,7 +5,6 @@
extern const mp_obj_type_t pyb_pin_type;
extern const mp_obj_type_t pyb_rtc_type;
-extern const mp_obj_type_t pyb_i2c_type;
extern const mp_obj_type_t machine_hspi_type;
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_info_obj);
diff --git a/ports/mimxrt/boards/mimxrt_prefix.c b/ports/mimxrt/boards/mimxrt_prefix.c
index d7a2bcfc8..3097535c5 100644
--- a/ports/mimxrt/boards/mimxrt_prefix.c
+++ b/ports/mimxrt/boards/mimxrt_prefix.c
@@ -2,6 +2,7 @@
#include "py/obj.h"
#include "py/mphal.h"
+#include "extmod/modmachine.h"
#include "pin.h"
#define PIN_AF(_name, _af_mode, _input_daisy, _instance, _input_register, _pad_config) \
diff --git a/ports/mimxrt/machine_i2c.c b/ports/mimxrt/machine_i2c.c
index c0a3dee98..379001acd 100644
--- a/ports/mimxrt/machine_i2c.c
+++ b/ports/mimxrt/machine_i2c.c
@@ -28,7 +28,7 @@
#include "py/mphal.h"
#include "py/mperrno.h"
#include "extmod/machine_i2c.h"
-#include "modmachine.h"
+#include "extmod/modmachine.h"
#include CLOCK_CONFIG_H
#include "pin.h"
diff --git a/ports/mimxrt/machine_rtc.c b/ports/mimxrt/machine_rtc.c
index 169ec6b91..61b410a65 100644
--- a/ports/mimxrt/machine_rtc.c
+++ b/ports/mimxrt/machine_rtc.c
@@ -29,6 +29,7 @@
#include "py/runtime.h"
#include "shared/runtime/mpirq.h"
#include "shared/timeutils/timeutils.h"
+#include "extmod/modmachine.h"
#include "modmachine.h"
#include "ticks.h"
#include "fsl_snvs_lp.h"
diff --git a/ports/mimxrt/machine_spi.c b/ports/mimxrt/machine_spi.c
index bafe94b97..879687bd1 100644
--- a/ports/mimxrt/machine_spi.c
+++ b/ports/mimxrt/machine_spi.c
@@ -29,7 +29,7 @@
#include "py/mphal.h"
#include "py/mperrno.h"
#include "extmod/machine_spi.h"
-#include "modmachine.h"
+#include "extmod/modmachine.h"
#include CLOCK_CONFIG_H
#include "fsl_cache.h"
diff --git a/ports/mimxrt/machine_uart.c b/ports/mimxrt/machine_uart.c
index 7d228d915..4dbe1d2e5 100644
--- a/ports/mimxrt/machine_uart.c
+++ b/ports/mimxrt/machine_uart.c
@@ -73,8 +73,6 @@ typedef struct _iomux_table_t {
uint32_t configRegister;
} iomux_table_t;
-extern const mp_obj_type_t machine_uart_type;
-
STATIC const uint8_t uart_index_table[] = MICROPY_HW_UART_INDEX;
STATIC LPUART_Type *uart_base_ptr_table[] = LPUART_BASE_PTRS;
static const iomux_table_t iomux_table_uart[] = {
diff --git a/ports/mimxrt/modmachine.h b/ports/mimxrt/modmachine.h
index c6ac4eb39..34e93260f 100644
--- a/ports/mimxrt/modmachine.h
+++ b/ports/mimxrt/modmachine.h
@@ -29,11 +29,7 @@
#include "py/obj.h"
-extern const mp_obj_type_t machine_i2c_type;
-extern const mp_obj_type_t machine_rtc_type;
extern const mp_obj_type_t machine_sdcard_type;
-extern const mp_obj_type_t machine_spi_type;
-extern const mp_obj_type_t machine_timer_type;
void machine_adc_init(void);
void machine_pin_irq_deinit(void);
diff --git a/ports/mimxrt/pin.c b/ports/mimxrt/pin.c
index fcc986328..4403f6ac7 100644
--- a/ports/mimxrt/pin.c
+++ b/ports/mimxrt/pin.c
@@ -25,6 +25,7 @@
*/
#include "py/runtime.h"
+#include "extmod/modmachine.h"
#include "pin.h"
diff --git a/ports/mimxrt/pin.h b/ports/mimxrt/pin.h
index aa86f05e8..bf611aa98 100644
--- a/ports/mimxrt/pin.h
+++ b/ports/mimxrt/pin.h
@@ -140,7 +140,6 @@ typedef struct _machine_pin_irq_obj_t {
// ------------------------------------------------------------------------------------------------------------------ //
-extern const mp_obj_type_t machine_pin_type;
extern const mp_obj_type_t machine_pin_af_type;
// ------------------------------------------------------------------------------------------------------------------ //
diff --git a/ports/nrf/modules/machine/i2c.c b/ports/nrf/modules/machine/i2c.c
index fad1b7336..8bb9613df 100644
--- a/ports/nrf/modules/machine/i2c.c
+++ b/ports/nrf/modules/machine/i2c.c
@@ -35,6 +35,7 @@
#if MICROPY_PY_MACHINE_I2C
#include "extmod/machine_i2c.h"
+#include "extmod/modmachine.h"
#include "i2c.h"
#if NRFX_TWI_ENABLED
#include "nrfx_twi.h"
diff --git a/ports/nrf/modules/machine/i2c.h b/ports/nrf/modules/machine/i2c.h
index 5c5befc28..3c4fde983 100644
--- a/ports/nrf/modules/machine/i2c.h
+++ b/ports/nrf/modules/machine/i2c.h
@@ -29,8 +29,6 @@
#include "extmod/machine_i2c.h"
-extern const mp_obj_type_t machine_i2c_type;
-
void i2c_init0(void);
#endif // I2C_H__
diff --git a/ports/nrf/modules/machine/modmachine.h b/ports/nrf/modules/machine/modmachine.h
index e5412673f..45847d407 100644
--- a/ports/nrf/modules/machine/modmachine.h
+++ b/ports/nrf/modules/machine/modmachine.h
@@ -28,8 +28,6 @@
#ifndef __MICROPY_INCLUDED_NRF5_MODMACHINE_H__
#define __MICROPY_INCLUDED_NRF5_MODMACHINE_H__
-#include "py/mpstate.h"
-#include "py/nlr.h"
#include "py/obj.h"
void machine_init(void);
diff --git a/ports/nrf/modules/machine/spi.c b/ports/nrf/modules/machine/spi.c
index 0dee20027..46f2eba29 100644
--- a/ports/nrf/modules/machine/spi.c
+++ b/ports/nrf/modules/machine/spi.c
@@ -36,6 +36,7 @@
#include "py/nlr.h"
#include "py/mphal.h"
#include "extmod/machine_spi.h"
+#include "extmod/modmachine.h"
#include "pin.h"
#include "genhdr/pins.h"
#include "spi.h"
diff --git a/ports/nrf/modules/machine/spi.h b/ports/nrf/modules/machine/spi.h
index e1505781a..1a1998d25 100644
--- a/ports/nrf/modules/machine/spi.h
+++ b/ports/nrf/modules/machine/spi.h
@@ -27,7 +27,6 @@
#include "py/obj.h"
typedef struct _machine_hard_spi_obj_t machine_hard_spi_obj_t;
-extern const mp_obj_type_t machine_spi_type;
void spi_init0(void);
void spi_transfer(const machine_hard_spi_obj_t * self,
diff --git a/ports/nrf/modules/machine/timer.c b/ports/nrf/modules/machine/timer.c
index fbef0b0ef..db9f04c2f 100644
--- a/ports/nrf/modules/machine/timer.c
+++ b/ports/nrf/modules/machine/timer.c
@@ -24,8 +24,8 @@
* THE SOFTWARE.
*/
-#include "py/nlr.h"
#include "py/runtime.h"
+#include "extmod/modmachine.h"
#include "timer.h"
#include "nrfx_timer.h"
diff --git a/ports/nrf/modules/machine/timer.h b/ports/nrf/modules/machine/timer.h
index bfbe07974..e483c3928 100644
--- a/ports/nrf/modules/machine/timer.h
+++ b/ports/nrf/modules/machine/timer.h
@@ -27,8 +27,6 @@
#ifndef TIMER_H__
#define TIMER_H__
-extern const mp_obj_type_t machine_timer_type;
-
void timer_init0(void);
#endif // TIMER_H__
diff --git a/ports/renesas-ra/boards/ra_pin_prefix.c b/ports/renesas-ra/boards/ra_pin_prefix.c
index c9aa3d888..918c84e63 100644
--- a/ports/renesas-ra/boards/ra_pin_prefix.c
+++ b/ports/renesas-ra/boards/ra_pin_prefix.c
@@ -4,6 +4,7 @@
#include "py/obj.h"
#include "py/mphal.h"
+#include "extmod/modmachine.h"
#include "pin.h"
#define PIN_AD(p_name, p_pin, ad_bit, ad_channel) \
diff --git a/ports/renesas-ra/machine_i2c.c b/ports/renesas-ra/machine_i2c.c
index 16bd58996..a642b8117 100644
--- a/ports/renesas-ra/machine_i2c.c
+++ b/ports/renesas-ra/machine_i2c.c
@@ -32,7 +32,7 @@
#include "py/mphal.h"
#include "py/mperrno.h"
#include "extmod/machine_i2c.h"
-#include "modmachine.h"
+#include "extmod/modmachine.h"
#include "ra_i2c.h"
diff --git a/ports/renesas-ra/machine_pin.c b/ports/renesas-ra/machine_pin.c
index 0e393b64e..70f98cd03 100644
--- a/ports/renesas-ra/machine_pin.c
+++ b/ports/renesas-ra/machine_pin.c
@@ -31,9 +31,10 @@
#include "py/runtime.h"
#include "py/mphal.h"
+#include "extmod/modmachine.h"
+#include "extmod/virtpin.h"
#include "shared/runtime/mpirq.h"
#include "modmachine.h"
-#include "extmod/virtpin.h"
#include "pin.h"
#include "extint.h"
diff --git a/ports/renesas-ra/machine_rtc.c b/ports/renesas-ra/machine_rtc.c
index e699bea0b..6637ea44c 100644
--- a/ports/renesas-ra/machine_rtc.c
+++ b/ports/renesas-ra/machine_rtc.c
@@ -28,6 +28,7 @@
#include <stdio.h>
#include "py/runtime.h"
+#include "extmod/modmachine.h"
#include "shared/timeutils/timeutils.h"
#include "extint.h"
#include "rtc.h"
diff --git a/ports/renesas-ra/machine_spi.c b/ports/renesas-ra/machine_spi.c
index 6755ab73c..977635f16 100644
--- a/ports/renesas-ra/machine_spi.c
+++ b/ports/renesas-ra/machine_spi.c
@@ -32,10 +32,10 @@
#include "py/mphal.h"
#include "py/mperrno.h"
#include "extmod/machine_spi.h"
+#include "extmod/modmachine.h"
#include "pin.h"
#include "spi.h"
#include "ra/ra_spi.h"
-#include "modmachine.h"
typedef struct _machine_hard_spi_obj_t {
mp_obj_base_t base;
diff --git a/ports/renesas-ra/main.c b/ports/renesas-ra/main.c
index c4cb7cc9d..761420423 100644
--- a/ports/renesas-ra/main.c
+++ b/ports/renesas-ra/main.c
@@ -41,6 +41,7 @@
#include "lib/littlefs/lfs1_util.h"
#include "lib/littlefs/lfs2.h"
#include "lib/littlefs/lfs2_util.h"
+#include "extmod/modmachine.h"
#include "extmod/vfs.h"
#include "extmod/vfs_fat.h"
#include "extmod/vfs_lfs.h"
diff --git a/ports/renesas-ra/modmachine.h b/ports/renesas-ra/modmachine.h
index ddf212221..9bb3196b3 100644
--- a/ports/renesas-ra/modmachine.h
+++ b/ports/renesas-ra/modmachine.h
@@ -29,15 +29,9 @@
#include "py/obj.h"
-extern const mp_obj_type_t machine_timer_type;
-extern const mp_obj_type_t machine_pin_type;
extern const mp_obj_type_t machine_touchpad_type;
extern const mp_obj_type_t machine_adcblock_type;
extern const mp_obj_type_t machine_dac_type;
-extern const mp_obj_type_t machine_i2c_type;
-extern const mp_obj_type_t machine_spi_type;
-extern const mp_obj_type_t machine_i2s_type;
-extern const mp_obj_type_t machine_rtc_type;
extern const mp_obj_type_t machine_sdcard_type;
diff --git a/ports/renesas-ra/modos.c b/ports/renesas-ra/modos.c
index 0884a0b2c..8fd11007e 100644
--- a/ports/renesas-ra/modos.c
+++ b/ports/renesas-ra/modos.c
@@ -26,6 +26,7 @@
*/
#include "py/runtime.h"
+#include "extmod/modmachine.h"
#include "uart.h"
#include "rng.h"
diff --git a/ports/renesas-ra/mpbthciport.c b/ports/renesas-ra/mpbthciport.c
index 5092f8709..2e9f6d916 100644
--- a/ports/renesas-ra/mpbthciport.c
+++ b/ports/renesas-ra/mpbthciport.c
@@ -29,9 +29,9 @@
#include "py/stream.h"
#include "py/mphal.h"
#include "extmod/modbluetooth.h"
+#include "extmod/modmachine.h"
#include "extmod/mpbthci.h"
#include "shared/runtime/softtimer.h"
-#include "modmachine.h"
#include "mpbthciport.h"
#include "uart.h"
diff --git a/ports/renesas-ra/pin.h b/ports/renesas-ra/pin.h
index 32aa96075..ac84b7f66 100644
--- a/ports/renesas-ra/pin.h
+++ b/ports/renesas-ra/pin.h
@@ -58,7 +58,6 @@ typedef struct {
const pin_ad_obj_t *ad;
} machine_pin_obj_t;
-extern const mp_obj_type_t machine_pin_type;
extern const mp_obj_type_t pin_af_type;
// Include all of the individual pin objects
diff --git a/ports/renesas-ra/rtc.h b/ports/renesas-ra/rtc.h
index 793720341..5f7701185 100644
--- a/ports/renesas-ra/rtc.h
+++ b/ports/renesas-ra/rtc.h
@@ -28,7 +28,6 @@
#define MICROPY_INCLUDED_RA_RTC_H
#include "py/obj.h"
-extern const mp_obj_type_t machine_rtc_type;
typedef struct
{
diff --git a/ports/renesas-ra/uart.h b/ports/renesas-ra/uart.h
index 245be24d1..ee8eb321d 100644
--- a/ports/renesas-ra/uart.h
+++ b/ports/renesas-ra/uart.h
@@ -89,7 +89,6 @@ typedef struct _machine_uart_obj_t {
mp_irq_obj_t *mp_irq_obj; // user IRQ object
} machine_uart_obj_t;
-extern const mp_obj_type_t machine_uart_type;
extern const mp_irq_methods_t uart_irq_methods;
void uart_init0(void);
diff --git a/ports/rp2/boards/rp2_prefix.c b/ports/rp2/boards/rp2_prefix.c
index 50f2852a8..5e27364cc 100644
--- a/ports/rp2/boards/rp2_prefix.c
+++ b/ports/rp2/boards/rp2_prefix.c
@@ -1,6 +1,7 @@
#include <stdint.h>
#include "py/obj.h"
#include "py/mphal.h"
+#include "extmod/modmachine.h"
#include "machine_pin.h"
#define AF(af_idx, af_fn, af_unit) \
diff --git a/ports/rp2/machine_i2c.c b/ports/rp2/machine_i2c.c
index fc4c0723a..467c4e7e6 100644
--- a/ports/rp2/machine_i2c.c
+++ b/ports/rp2/machine_i2c.c
@@ -28,7 +28,7 @@
#include "py/mphal.h"
#include "py/mperrno.h"
#include "extmod/machine_i2c.h"
-#include "modmachine.h"
+#include "extmod/modmachine.h"
#include "hardware/i2c.h"
diff --git a/ports/rp2/machine_pin.c b/ports/rp2/machine_pin.c
index 3470f3869..77d9e1348 100644
--- a/ports/rp2/machine_pin.c
+++ b/ports/rp2/machine_pin.c
@@ -29,10 +29,11 @@
#include "py/runtime.h"
#include "py/mphal.h"
+#include "extmod/modmachine.h"
+#include "extmod/virtpin.h"
#include "shared/runtime/mpirq.h"
#include "modmachine.h"
#include "machine_pin.h"
-#include "extmod/virtpin.h"
#include "hardware/irq.h"
#include "hardware/regs/intctrl.h"
diff --git a/ports/rp2/machine_pin.h b/ports/rp2/machine_pin.h
index aa5ea641b..d2a39f8e3 100644
--- a/ports/rp2/machine_pin.h
+++ b/ports/rp2/machine_pin.h
@@ -59,7 +59,6 @@ typedef struct _machine_pin_obj_t {
const machine_pin_af_obj_t *af;
} machine_pin_obj_t;
-extern const mp_obj_type_t machine_pin_type;
extern const mp_obj_type_t machine_pin_af_type;
// Include all of the individual pin objects
diff --git a/ports/rp2/machine_rtc.c b/ports/rp2/machine_rtc.c
index 25d65eda6..eb2e1615b 100644
--- a/ports/rp2/machine_rtc.c
+++ b/ports/rp2/machine_rtc.c
@@ -35,10 +35,10 @@
#include "py/runtime.h"
#include "py/mphal.h"
#include "py/mperrno.h"
+#include "extmod/modmachine.h"
#include "shared/timeutils/timeutils.h"
#include "hardware/rtc.h"
#include "pico/util/datetime.h"
-#include "modmachine.h"
typedef struct _machine_rtc_obj_t {
mp_obj_base_t base;
diff --git a/ports/rp2/machine_spi.c b/ports/rp2/machine_spi.c
index b2b879c9a..3d7f2d6ab 100644
--- a/ports/rp2/machine_spi.c
+++ b/ports/rp2/machine_spi.c
@@ -28,7 +28,7 @@
#include "py/mphal.h"
#include "py/mperrno.h"
#include "extmod/machine_spi.h"
-#include "modmachine.h"
+#include "extmod/modmachine.h"
#include "hardware/spi.h"
#include "hardware/dma.h"
diff --git a/ports/rp2/modmachine.h b/ports/rp2/modmachine.h
index 4e4245ed3..6ef722279 100644
--- a/ports/rp2/modmachine.h
+++ b/ports/rp2/modmachine.h
@@ -3,12 +3,6 @@
#include "py/obj.h"
-extern const mp_obj_type_t machine_i2c_type;
-extern const mp_obj_type_t machine_pin_type;
-extern const mp_obj_type_t machine_rtc_type;
-extern const mp_obj_type_t machine_spi_type;
-extern const mp_obj_type_t machine_timer_type;
-
void machine_pin_init(void);
void machine_pin_deinit(void);
void machine_i2s_init0(void);
diff --git a/ports/samd/machine_i2c.c b/ports/samd/machine_i2c.c
index 5606d7b62..afd5921d5 100644
--- a/ports/samd/machine_i2c.c
+++ b/ports/samd/machine_i2c.c
@@ -32,7 +32,7 @@
#include "py/mphal.h"
#include "py/mperrno.h"
#include "extmod/machine_i2c.h"
-#include "modmachine.h"
+#include "extmod/modmachine.h"
#include "samd_soc.h"
#include "pin_af.h"
#include "clock_config.h"
diff --git a/ports/samd/machine_rtc.c b/ports/samd/machine_rtc.c
index 57bfa998e..e6237f3f3 100644
--- a/ports/samd/machine_rtc.c
+++ b/ports/samd/machine_rtc.c
@@ -27,8 +27,8 @@
#include "py/runtime.h"
#include "shared/timeutils/timeutils.h"
-#include "modmachine.h"
#include "py/mphal.h"
+#include "extmod/modmachine.h"
#include "sam.h"
#if MICROPY_PY_MACHINE_RTC
diff --git a/ports/samd/machine_spi.c b/ports/samd/machine_spi.c
index b00eb4271..9d9928bb0 100644
--- a/ports/samd/machine_spi.c
+++ b/ports/samd/machine_spi.c
@@ -31,7 +31,7 @@
#include "py/mphal.h"
#include "extmod/machine_spi.h"
-#include "modmachine.h"
+#include "extmod/modmachine.h"
#include "samd_soc.h"
#include "pin_af.h"
#include "clock_config.h"
diff --git a/ports/samd/modmachine.h b/ports/samd/modmachine.h
index 4f287bde3..5baaf5f7e 100644
--- a/ports/samd/modmachine.h
+++ b/ports/samd/modmachine.h
@@ -32,17 +32,6 @@
#if MICROPY_PY_MACHINE_DAC
extern const mp_obj_type_t machine_dac_type;
#endif
-#if MICROPY_PY_MACHINE_I2C
-extern const mp_obj_type_t machine_i2c_type;
-#endif
-extern const mp_obj_type_t machine_pin_type;
-#if MICROPY_PY_MACHINE_SPI
-extern const mp_obj_type_t machine_spi_type;
-#endif
-extern const mp_obj_type_t machine_timer_type;
-#if MICROPY_PY_MACHINE_RTC
-extern const mp_obj_type_t machine_rtc_type;
-#endif
NORETURN mp_obj_t machine_bootloader(size_t n_args, const mp_obj_t *args);
diff --git a/ports/samd/pin_af.c b/ports/samd/pin_af.c
index 419b81477..6de9a7477 100644
--- a/ports/samd/pin_af.c
+++ b/ports/samd/pin_af.c
@@ -31,9 +31,9 @@
#include <stdint.h>
#include "string.h"
-#include "modmachine.h"
#include "py/runtime.h"
#include "py/misc.h"
+#include "extmod/modmachine.h"
#include "pin_af.h"
#include "sam.h"
diff --git a/ports/samd/samd_spiflash.c b/ports/samd/samd_spiflash.c
index eaa0ec143..833e3efa8 100644
--- a/ports/samd/samd_spiflash.c
+++ b/ports/samd/samd_spiflash.c
@@ -31,8 +31,8 @@
#include "py/runtime.h"
#include "py/mphal.h"
#include "extmod/machine_spi.h"
+#include "extmod/modmachine.h"
#include "extmod/vfs.h"
-#include "modmachine.h"
#include "pin_af.h"
#if MICROPY_HW_SPIFLASH
diff --git a/ports/stm32/machine_i2c.c b/ports/stm32/machine_i2c.c
index f4b0b3312..1876c9a14 100644
--- a/ports/stm32/machine_i2c.c
+++ b/ports/stm32/machine_i2c.c
@@ -24,15 +24,12 @@
* THE SOFTWARE.
*/
-#include <stdio.h>
-#include <string.h>
-
#include "py/runtime.h"
#include "py/mphal.h"
#include "py/mperrno.h"
#include "extmod/machine_i2c.h"
+#include "extmod/modmachine.h"
#include "i2c.h"
-#include "modmachine.h"
#if MICROPY_HW_ENABLE_HW_I2C
diff --git a/ports/stm32/machine_spi.c b/ports/stm32/machine_spi.c
index c6d601573..bc526635b 100644
--- a/ports/stm32/machine_spi.c
+++ b/ports/stm32/machine_spi.c
@@ -26,6 +26,7 @@
#include "py/runtime.h"
#include "extmod/machine_spi.h"
+#include "extmod/modmachine.h"
#include "spi.h"
/******************************************************************************/
diff --git a/ports/stm32/modmachine.h b/ports/stm32/modmachine.h
index 882057c60..096666eb5 100644
--- a/ports/stm32/modmachine.h
+++ b/ports/stm32/modmachine.h
@@ -28,10 +28,6 @@
#include "py/obj.h"
-extern const mp_obj_type_t machine_i2c_type;
-extern const mp_obj_type_t machine_spi_type;
-extern const mp_obj_type_t machine_timer_type;
-
void machine_init(void);
void machine_deinit(void);
void machine_i2s_init0();
diff --git a/ports/stm32/spi.c b/ports/stm32/spi.c
index 1f5996165..a2a337f1e 100644
--- a/ports/stm32/spi.c
+++ b/ports/stm32/spi.c
@@ -29,6 +29,7 @@
#include "py/mphal.h"
#include "spi.h"
#include "extmod/machine_spi.h"
+#include "extmod/modmachine.h"
// Possible DMA configurations for SPI buses:
// SPI1_TX: DMA2_Stream3.CHANNEL_3 or DMA2_Stream5.CHANNEL_3
diff --git a/ports/stm32/spi.h b/ports/stm32/spi.h
index fe7f2f661..a8bc9d2cf 100644
--- a/ports/stm32/spi.h
+++ b/ports/stm32/spi.h
@@ -58,7 +58,6 @@ extern const spi_t spi_obj[6];
extern const mp_spi_proto_t spi_proto;
extern const mp_obj_type_t pyb_spi_type;
-extern const mp_obj_type_t machine_spi_type;
// A transfer of "len" bytes should take len*8*1000/baudrate milliseconds.
// To simplify the calculation we assume the baudrate is never less than 8kHz
diff --git a/ports/zephyr/machine_i2c.c b/ports/zephyr/machine_i2c.c
index c261ffad0..a4b48e996 100644
--- a/ports/zephyr/machine_i2c.c
+++ b/ports/zephyr/machine_i2c.c
@@ -37,7 +37,7 @@
#include "py/mphal.h"
#include "py/mperrno.h"
#include "extmod/machine_i2c.h"
-#include "modmachine.h"
+#include "extmod/modmachine.h"
#if MICROPY_PY_MACHINE_I2C
diff --git a/ports/zephyr/machine_pin.c b/ports/zephyr/machine_pin.c
index be0698651..d27b59009 100644
--- a/ports/zephyr/machine_pin.c
+++ b/ports/zephyr/machine_pin.c
@@ -35,6 +35,7 @@
#include "py/runtime.h"
#include "py/gc.h"
#include "py/mphal.h"
+#include "extmod/modmachine.h"
#include "shared/runtime/mpirq.h"
#include "modmachine.h"
diff --git a/ports/zephyr/machine_spi.c b/ports/zephyr/machine_spi.c
index 507d839c6..6475018b0 100644
--- a/ports/zephyr/machine_spi.c
+++ b/ports/zephyr/machine_spi.c
@@ -36,7 +36,7 @@
#include "py/mphal.h"
#include "py/mperrno.h"
#include "extmod/machine_spi.h"
-#include "modmachine.h"
+#include "extmod/modmachine.h"
#if MICROPY_PY_MACHINE_SPI
diff --git a/ports/zephyr/modmachine.h b/ports/zephyr/modmachine.h
index 520b36396..e3a69d8c1 100644
--- a/ports/zephyr/modmachine.h
+++ b/ports/zephyr/modmachine.h
@@ -3,10 +3,6 @@
#include "py/obj.h"
-extern const mp_obj_type_t machine_pin_type;
-extern const mp_obj_type_t machine_i2c_type;
-extern const mp_obj_type_t machine_spi_type;
-
MP_DECLARE_CONST_FUN_OBJ_0(machine_info_obj);
typedef struct _machine_pin_obj_t {