Skip to content

Commit

Permalink
extmod/modmachine: Clean up decls of machine types to use common ones.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
dpgeorge committed Oct 26, 2023
1 parent 5b4a2ba commit 90023b4
Show file tree
Hide file tree
Showing 59 changed files with 44 additions and 87 deletions.
3 changes: 1 addition & 2 deletions drivers/esp-hosted/esp_hosted_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions drivers/ninaw10/nina_wifi_bsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions extmod/modmachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ports/esp32/boards/pins_prefix.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "py/obj.h"
#include "extmod/modmachine.h"
#include "machine_pin.h"
#include "modmachine.h"
#include "genhdr/pins.h"
2 changes: 1 addition & 1 deletion ports/esp32/machine_hw_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion ports/esp32/machine_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion ports/esp32/machine_pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion ports/esp32/machine_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions ports/esp32/modmachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion ports/esp8266/modmachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions ports/mimxrt/boards/mimxrt_prefix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
2 changes: 1 addition & 1 deletion ports/mimxrt/machine_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 1 addition & 0 deletions ports/mimxrt/machine_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion ports/mimxrt/machine_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions ports/mimxrt/machine_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down
4 changes: 0 additions & 4 deletions ports/mimxrt/modmachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions ports/mimxrt/pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/

#include "py/runtime.h"
#include "extmod/modmachine.h"
#include "pin.h"


Expand Down
1 change: 0 additions & 1 deletion ports/mimxrt/pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

// ------------------------------------------------------------------------------------------------------------------ //
Expand Down
1 change: 1 addition & 0 deletions ports/nrf/modules/machine/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 0 additions & 2 deletions ports/nrf/modules/machine/i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__
2 changes: 0 additions & 2 deletions ports/nrf/modules/machine/modmachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions ports/nrf/modules/machine/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion ports/nrf/modules/machine/spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ports/nrf/modules/machine/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 0 additions & 2 deletions ports/nrf/modules/machine/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__
1 change: 1 addition & 0 deletions ports/renesas-ra/boards/ra_pin_prefix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
2 changes: 1 addition & 1 deletion ports/renesas-ra/machine_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 2 additions & 1 deletion ports/renesas-ra/machine_pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions ports/renesas-ra/machine_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion ports/renesas-ra/machine_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions ports/renesas-ra/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 0 additions & 6 deletions ports/renesas-ra/modmachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down
1 change: 1 addition & 0 deletions ports/renesas-ra/modos.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include "py/runtime.h"
#include "extmod/modmachine.h"
#include "uart.h"
#include "rng.h"

Expand Down
2 changes: 1 addition & 1 deletion ports/renesas-ra/mpbthciport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion ports/renesas-ra/pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion ports/renesas-ra/rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
1 change: 0 additions & 1 deletion ports/renesas-ra/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions ports/rp2/boards/rp2_prefix.c
Original file line number Diff line number Diff line change
@@ -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) \
Expand Down
2 changes: 1 addition & 1 deletion ports/rp2/machine_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 2 additions & 1 deletion ports/rp2/machine_pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion ports/rp2/machine_pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ports/rp2/machine_rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 90023b4

Please sign in to comment.