diff options
62 files changed, 266 insertions, 113 deletions
diff --git a/atmel-samd/boards/feather_m0_express/mpconfigboard.h b/atmel-samd/boards/feather_m0_express/mpconfigboard.h index 9fd01d446..04b836b4e 100644 --- a/atmel-samd/boards/feather_m0_express/mpconfigboard.h +++ b/atmel-samd/boards/feather_m0_express/mpconfigboard.h @@ -3,7 +3,7 @@ #define MICROPY_HW_BOARD_NAME "Adafruit Feather M0 Express" #define MICROPY_HW_MCU_NAME "samd21g18" -#define MICROPY_HW_NEOPIXEL &pin_PA06 +#define MICROPY_HW_NEOPIXEL (&pin_PA06) #define SPI_FLASH_BAUDRATE (1000000) diff --git a/atmel-samd/boards/feather_m0_express/pins.c b/atmel-samd/boards/feather_m0_express/pins.c index 06a245ca4..57b51ebd6 100644 --- a/atmel-samd/boards/feather_m0_express/pins.c +++ b/atmel-samd/boards/feather_m0_express/pins.c @@ -23,5 +23,6 @@ STATIC const mp_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_D11), (mp_obj_t)&pin_PA16 }, { MP_OBJ_NEW_QSTR(MP_QSTR_D12), (mp_obj_t)&pin_PA19 }, { MP_OBJ_NEW_QSTR(MP_QSTR_D13), (mp_obj_t)&pin_PA17 }, + { MP_OBJ_NEW_QSTR(MP_QSTR_NEOPIXEL), (mp_obj_t)&pin_PA06 }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/atmel-samd/boards/gemma_m0/mpconfigboard.h b/atmel-samd/boards/gemma_m0/mpconfigboard.h index 165522fab..5368ad9b3 100644 --- a/atmel-samd/boards/gemma_m0/mpconfigboard.h +++ b/atmel-samd/boards/gemma_m0/mpconfigboard.h @@ -3,8 +3,10 @@ #define MICROPY_HW_BOARD_NAME "Adafruit Gemma M0" #define MICROPY_HW_MCU_NAME "samd21e18" -#define MICROPY_HW_APA102_MOSI &pin_PA04 -#define MICROPY_HW_APA102_SCK &pin_PA05 +#define MICROPY_HW_APA102_MOSI (&pin_PA04) +#define MICROPY_HW_APA102_SCK (&pin_PA05) + +// #define CIRCUITPY_BITBANG_APA102 #define MICROPY_PORT_A (PORT_PA04 | PORT_PA05 | PORT_PA24 | PORT_PA25) #define MICROPY_PORT_B (0) diff --git a/atmel-samd/boards/gemma_m0/pins.c b/atmel-samd/boards/gemma_m0/pins.c index ec78b9b1e..348f5fd1b 100644 --- a/atmel-samd/boards/gemma_m0/pins.c +++ b/atmel-samd/boards/gemma_m0/pins.c @@ -5,5 +5,7 @@ STATIC const mp_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_D1), (mp_obj_t)&pin_PA02 }, { MP_OBJ_NEW_QSTR(MP_QSTR_D2), (mp_obj_t)&pin_PA09 }, { MP_OBJ_NEW_QSTR(MP_QSTR_D0), (mp_obj_t)&pin_PA08 }, + { MP_OBJ_NEW_QSTR(MP_QSTR_APA102_MOSI), (mp_obj_t)&pin_PA04 }, + { MP_OBJ_NEW_QSTR(MP_QSTR_APA102_SCK), (mp_obj_t)&pin_PA05 }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/atmel-samd/boards/metro_m0_flash/mpconfigboard.h b/atmel-samd/boards/metro_m0_flash/mpconfigboard.h index d859f2198..b25596d1d 100644 --- a/atmel-samd/boards/metro_m0_flash/mpconfigboard.h +++ b/atmel-samd/boards/metro_m0_flash/mpconfigboard.h @@ -6,7 +6,7 @@ #define MICROPY_HW_LED_TX PIN_PA27 #define MICROPY_HW_LED_RX PIN_PA31 -#define MICROPY_HW_NEOPIXEL &pin_PA30 +#define MICROPY_HW_NEOPIXEL (&pin_PA30) #define SPI_FLASH_BAUDRATE (1000000) diff --git a/atmel-samd/boards/trinket_m0/mpconfigboard.h b/atmel-samd/boards/trinket_m0/mpconfigboard.h index e72b0a8eb..23e51e8d2 100644 --- a/atmel-samd/boards/trinket_m0/mpconfigboard.h +++ b/atmel-samd/boards/trinket_m0/mpconfigboard.h @@ -3,10 +3,11 @@ #define MICROPY_HW_BOARD_NAME "Adafruit Trinket M0" #define MICROPY_HW_MCU_NAME "samd21e18" -#define MICROPY_HW_APA102_MOSI &pin_PA01 -#define MICROPY_HW_APA102_SCK &pin_PA00 +// Rev B - Black +#define MICROPY_HW_APA102_MOSI (&pin_PA04) +#define MICROPY_HW_APA102_SCK (&pin_PA05) -#define MICROPY_PORT_A (PORT_PA00 | PORT_PA01 | PORT_PA24 | PORT_PA25) +#define MICROPY_PORT_A (PORT_PA04 | PORT_PA05 | PORT_PA24 | PORT_PA25) #define MICROPY_PORT_B (0) #define AUTORESET_DELAY_MS 500 diff --git a/atmel-samd/boards/trinket_m0/pins.c b/atmel-samd/boards/trinket_m0/pins.c index 348c8cb95..f621359c7 100644 --- a/atmel-samd/boards/trinket_m0/pins.c +++ b/atmel-samd/boards/trinket_m0/pins.c @@ -7,5 +7,7 @@ STATIC const mp_map_elem_t board_global_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_D4), (mp_obj_t)&pin_PA06 }, { MP_OBJ_NEW_QSTR(MP_QSTR_D3), (mp_obj_t)&pin_PA07 }, { MP_OBJ_NEW_QSTR(MP_QSTR_D13),(mp_obj_t)&pin_PA10 }, + { MP_OBJ_NEW_QSTR(MP_QSTR_APA102_MOSI), (mp_obj_t)&pin_PA04 }, + { MP_OBJ_NEW_QSTR(MP_QSTR_APA102_SCK), (mp_obj_t)&pin_PA05 }, }; MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table); diff --git a/atmel-samd/common-hal/analogio/AnalogIn.c b/atmel-samd/common-hal/analogio/AnalogIn.c index 59ea3b899..91322db82 100644 --- a/atmel-samd/common-hal/analogio/AnalogIn.c +++ b/atmel-samd/common-hal/analogio/AnalogIn.c @@ -48,6 +48,7 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t* self, // No ADC function on that pin mp_raise_ValueError("Pin does not have ADC capabilities"); } + claim_pin(pin); self->pin = pin; diff --git a/atmel-samd/common-hal/analogio/AnalogIn.h b/atmel-samd/common-hal/analogio/AnalogIn.h index 78c7b82e8..daf825f87 100644 --- a/atmel-samd/common-hal/analogio/AnalogIn.h +++ b/atmel-samd/common-hal/analogio/AnalogIn.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ANALOGIO_ANALOGIN_H__ #define __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ANALOGIO_ANALOGIN_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" // Don't reorder these includes because they are dependencies of adc_feature.h. // They should really be included by adc_feature.h. diff --git a/atmel-samd/common-hal/analogio/AnalogOut.c b/atmel-samd/common-hal/analogio/AnalogOut.c index a618a6eeb..caeddc1e7 100644 --- a/atmel-samd/common-hal/analogio/AnalogOut.c +++ b/atmel-samd/common-hal/analogio/AnalogOut.c @@ -49,6 +49,7 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self, mp_raise_OSError(MP_EIO); return; } + claim_pin(pin); struct dac_chan_config config_analogout_chan; dac_chan_get_config_defaults(&config_analogout_chan); diff --git a/atmel-samd/common-hal/analogio/AnalogOut.h b/atmel-samd/common-hal/analogio/AnalogOut.h index f74592d6a..5223f759d 100644 --- a/atmel-samd/common-hal/analogio/AnalogOut.h +++ b/atmel-samd/common-hal/analogio/AnalogOut.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ANALOGIO_ANALOGOUT_H__ #define __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_ANALOGIO_ANALOGOUT_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "asf/sam0/drivers/dac/dac.h" diff --git a/atmel-samd/common-hal/board/__init__.c b/atmel-samd/common-hal/board/__init__.c index acab1ac07..8dd093696 100644 --- a/atmel-samd/common-hal/board/__init__.c +++ b/atmel-samd/common-hal/board/__init__.c @@ -28,7 +28,7 @@ #include "py/runtime.h" #include "py/mphal.h" -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" // Pins aren't actually defined here. They are in the board specific directory // such as boards/arduino_zero/pins.c. diff --git a/atmel-samd/common-hal/busio/I2C.c b/atmel-samd/common-hal/busio/I2C.c index 7b7c6a52c..b49541735 100644 --- a/atmel-samd/common-hal/busio/I2C.c +++ b/atmel-samd/common-hal/busio/I2C.c @@ -77,6 +77,8 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, self->sda_pin = sda->pin; self->scl_pin = scl->pin; + claim_pin(sda); + claim_pin(scl); enum status_code status = i2c_master_init(&self->i2c_master_instance, sercom, &config_i2c_master); diff --git a/atmel-samd/common-hal/busio/I2C.h b/atmel-samd/common-hal/busio/I2C.h index 8f09cb343..c81794e08 100644 --- a/atmel-samd/common-hal/busio/I2C.h +++ b/atmel-samd/common-hal/busio/I2C.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_I2C_H__ #define __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_I2C_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "asf/sam0/drivers/sercom/i2c/i2c_master.h" #include "py/obj.h" diff --git a/atmel-samd/common-hal/busio/SPI.c b/atmel-samd/common-hal/busio/SPI.c index a7175f3d5..75891c6df 100644 --- a/atmel-samd/common-hal/busio/SPI.c +++ b/atmel-samd/common-hal/busio/SPI.c @@ -27,6 +27,7 @@ #include "shared-bindings/busio/SPI.h" #include "py/nlr.h" #include "py/runtime.h" +#include "rgb_led_status.h" #include "samd21_pins.h" // We use ENABLE registers below we don't want to treat as a macro. @@ -53,7 +54,13 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, for (int i = 0; i < NUM_SERCOMS_PER_PIN; i++) { Sercom* potential_sercom = clock->sercom[i].sercom; if (potential_sercom == NULL || + #if defined(MICROPY_HW_APA102_SCK) && defined(MICROPY_HW_APA102_MOSI) && !defined(CIRCUITPY_BITBANG_APA102) + (potential_sercom->SPI.CTRLA.bit.ENABLE != 0 && + potential_sercom != status_apa102.spi_master_instance.hw && + !apa102_sck_in_use)) { + #else potential_sercom->SPI.CTRLA.bit.ENABLE != 0) { + #endif continue; } clock_pinmux = PINMUX(clock->pin, (i == 0) ? MUX_C : MUX_D); @@ -122,15 +129,18 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, &config_spi_master.pinmux_pad3}; *pinmuxes[clock_pad] = clock_pinmux; self->clock_pin = clock->pin; + claim_pin(clock); self->MOSI_pin = NO_PIN; if (!mosi_none) { *pinmuxes[mosi_pad] = mosi_pinmux; self->MOSI_pin = mosi->pin; + claim_pin(mosi); } self->MISO_pin = NO_PIN; if (!miso_none) { *pinmuxes[miso_pad] = miso_pinmux; self->MISO_pin = miso->pin; + claim_pin(miso); } // Always start at 250khz which is what SD cards need. They are sensitive to diff --git a/atmel-samd/common-hal/busio/SPI.h b/atmel-samd/common-hal/busio/SPI.h index 10dbe5734..9016ecff2 100644 --- a/atmel-samd/common-hal/busio/SPI.h +++ b/atmel-samd/common-hal/busio/SPI.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_SPI_H__ #define __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_SPI_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "asf/sam0/drivers/sercom/spi/spi.h" #include "py/obj.h" diff --git a/atmel-samd/common-hal/busio/UART.c b/atmel-samd/common-hal/busio/UART.c index 8d39d5341..c682a14be 100644 --- a/atmel-samd/common-hal/busio/UART.c +++ b/atmel-samd/common-hal/busio/UART.c @@ -202,6 +202,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, if (rx != NULL) { *pinmuxes[rx_pad] = rx_pinmux; self->rx_pin = rx->pin; + claim_pin(rx); } self->tx_pin = NO_PIN; @@ -209,6 +210,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, if (tx != NULL) { *pinmuxes[tx_pad] = tx_pinmux; self->tx_pin = tx->pin; + claim_pin(tx); } self->timeout_ms = timeout; @@ -217,10 +219,12 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, self->buffer_length *= (bits + 7) / 8; self->buffer = (uint8_t *) gc_alloc(self->buffer_length * sizeof(uint8_t), false); if (self->buffer == NULL) { + common_hal_busio_uart_deinit(self); mp_raise_msg(&mp_type_MemoryError, "Failed to allocate RX buffer"); } if (usart_init(&self->uart_instance, sercom, &config_usart) != STATUS_OK) { + common_hal_busio_uart_deinit(self); mp_raise_OSError(MP_EIO); } diff --git a/atmel-samd/common-hal/busio/UART.h b/atmel-samd/common-hal/busio/UART.h index d9a001de4..411d7f588 100644 --- a/atmel-samd/common-hal/busio/UART.h +++ b/atmel-samd/common-hal/busio/UART.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_UART_H__ #define __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_BUSIO_UART_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "asf/sam0/drivers/sercom/usart/usart.h" #include "py/obj.h" diff --git a/atmel-samd/common-hal/digitalio/DigitalInOut.c b/atmel-samd/common-hal/digitalio/DigitalInOut.c index 391bf8992..9e69288f4 100644 --- a/atmel-samd/common-hal/digitalio/DigitalInOut.c +++ b/atmel-samd/common-hal/digitalio/DigitalInOut.c @@ -31,6 +31,7 @@ #include "py/runtime.h" #include "py/mphal.h" +#include "common-hal/microcontroller/Pin.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "asf/sam0/drivers/port/port.h" @@ -38,6 +39,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_construct( digitalio_digitalinout_obj_t* self, const mcu_pin_obj_t* pin) { + claim_pin(pin); self->pin = pin; struct port_config pin_conf; @@ -50,11 +52,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_construct( } void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t* self) { - struct port_config pin_conf; - port_get_config_defaults(&pin_conf); - - pin_conf.powersave = true; - port_pin_set_config(self->pin->pin, &pin_conf); + reset_pin(self->pin->pin); } void common_hal_digitalio_digitalinout_switch_to_input( diff --git a/atmel-samd/common-hal/digitalio/DigitalInOut.h b/atmel-samd/common-hal/digitalio/DigitalInOut.h index 1490765ab..eeeb3710f 100644 --- a/atmel-samd/common-hal/digitalio/DigitalInOut.h +++ b/atmel-samd/common-hal/digitalio/DigitalInOut.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DIGITALIO_DIGITALINOUT_H__ #define __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_DIGITALIO_DIGITALINOUT_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "py/obj.h" typedef struct { diff --git a/atmel-samd/common-hal/microcontroller/Pin.c b/atmel-samd/common-hal/microcontroller/Pin.c index cfe8762bd..fe8011ad8 100644 --- a/atmel-samd/common-hal/microcontroller/Pin.c +++ b/atmel-samd/common-hal/microcontroller/Pin.c @@ -26,7 +26,77 @@ #include "shared-bindings/microcontroller/Pin.h" +#include "rgb_led_status.h" +#include "samd21_pins.h" + +#ifdef MICROPY_HW_NEOPIXEL +bool neopixel_in_use; +#endif +#ifdef MICROPY_HW_APA102_MOSI +bool apa102_sck_in_use; +bool apa102_mosi_in_use; +#endif + +void reset_pin(uint8_t pin) { + if (pin >= PORT_BITS) { + return; + } + + #ifdef MICROPY_HW_NEOPIXEL + if (pin == MICROPY_HW_NEOPIXEL->pin) { + neopixel_in_use = false; + rgb_led_status_init(); + return; + } + #endif + #ifdef MICROPY_HW_APA102_MOSI + if (pin == MICROPY_HW_APA102_MOSI->pin || + pin == MICROPY_HW_APA102_SCK->pin) { + apa102_mosi_in_use = apa102_mosi_in_use && pin != MICROPY_HW_APA102_MOSI->pin; + apa102_sck_in_use = apa102_sck_in_use && pin != MICROPY_HW_APA102_SCK->pin; + if (!apa102_sck_in_use && !apa102_mosi_in_use) { + rgb_led_status_init(); + } + return; + } + #endif + + struct system_pinmux_config config; + system_pinmux_get_config_defaults(&config); + config.powersave = true; + system_pinmux_pin_set_config(pin, &config); +} + +void claim_pin(const mcu_pin_obj_t* pin) { + #ifdef MICROPY_HW_NEOPIXEL + if (pin == MICROPY_HW_NEOPIXEL) { + neopixel_in_use = true; + } + #endif + #ifdef MICROPY_HW_APA102_MOSI + if (pin == MICROPY_HW_APA102_MOSI) { + apa102_mosi_in_use = true; + } + if (pin == MICROPY_HW_APA102_SCK) { + apa102_sck_in_use = true; + } + #endif +} + bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t* pin) { + #ifdef MICROPY_HW_NEOPIXEL + if (pin == MICROPY_HW_NEOPIXEL) { + return !neopixel_in_use; + } + #endif + #ifdef MICROPY_HW_APA102_MOSI + if (pin == MICROPY_HW_APA102_MOSI) { + return !apa102_mosi_in_use; + } + if (pin == MICROPY_HW_APA102_SCK) { + return !apa102_sck_in_use; + } + #endif PortGroup *const port = system_pinmux_get_group_from_gpio_pin(pin->pin); uint32_t pin_index = (pin->pin); PORT_PINCFG_Type state = port->PINCFG[pin_index]; diff --git a/atmel-samd/common-hal/microcontroller/types.h b/atmel-samd/common-hal/microcontroller/Pin.h index d8fdc4c2e..27c998e5c 100644 --- a/atmel-samd/common-hal/microcontroller/types.h +++ b/atmel-samd/common-hal/microcontroller/Pin.h @@ -24,8 +24,8 @@ * THE SOFTWARE. */ -#ifndef __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_MICROCONTROLLER_TYPES_H__ -#define __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_MICROCONTROLLER_TYPES_H__ +#ifndef __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_MICROCONTROLLER_PIN_H__ +#define __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_MICROCONTROLLER_PIN_H__ // Don't reorder these includes because they are dependencies of adc_feature.h. // They should really be included by adc_feature.h. @@ -70,4 +70,17 @@ typedef struct { pin_sercom_t sercom[NUM_SERCOMS_PER_PIN]; } mcu_pin_obj_t; -#endif // __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_MICROCONTROLLER_TYPES_H__ +#ifdef MICROPY_HW_NEOPIXEL +extern bool neopixel_in_use; +#endif +#ifdef MICROPY_HW_APA102_MOSI +extern bool apa102_sck_in_use; +extern bool apa102_mosi_in_use; +#endif + +// reset_pin takes the pin number instead of the pointer so that objects don't +// need to store a full pointer. +void reset_pin(uint8_t pin); +void claim_pin(const mcu_pin_obj_t* pin); + +#endif // __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_MICROCONTROLLER_PIN_H__ diff --git a/atmel-samd/common-hal/pulseio/PWMOut.h b/atmel-samd/common-hal/pulseio/PWMOut.h index b8e207f3e..2673078e9 100644 --- a/atmel-samd/common-hal/pulseio/PWMOut.h +++ b/atmel-samd/common-hal/pulseio/PWMOut.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PWMOUT_H__ #define __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PWMOUT_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "asf/sam0/drivers/tc/tc.h" #include "asf/sam0/drivers/tcc/tcc.h" diff --git a/atmel-samd/common-hal/pulseio/PulseIn.h b/atmel-samd/common-hal/pulseio/PulseIn.h index 717b7267a..976af48a4 100644 --- a/atmel-samd/common-hal/pulseio/PulseIn.h +++ b/atmel-samd/common-hal/pulseio/PulseIn.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PULSEIN_H__ #define __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PULSEIN_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "py/obj.h" diff --git a/atmel-samd/common-hal/pulseio/PulseOut.h b/atmel-samd/common-hal/pulseio/PulseOut.h index f06dcc44f..08ed3277d 100644 --- a/atmel-samd/common-hal/pulseio/PulseOut.h +++ b/atmel-samd/common-hal/pulseio/PulseOut.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PULSEOUT_H__ #define __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_PULSEIO_PULSEOUT_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "asf/sam0/drivers/tc/tc.h" #include "asf/sam0/drivers/tcc/tcc.h" diff --git a/atmel-samd/common-hal/touchio/TouchIn.c b/atmel-samd/common-hal/touchio/TouchIn.c index a680294e2..0db4c5728 100644 --- a/atmel-samd/common-hal/touchio/TouchIn.c +++ b/atmel-samd/common-hal/touchio/TouchIn.c @@ -189,6 +189,7 @@ void common_hal_touchio_touchin_construct(touchio_touchin_obj_t* self, if (!pin->has_touch) { mp_raise_ValueError("Invalid pin"); } + claim_pin(pin); if (selfcap_config.num_channels > 0) { // Deinit the touch sensor, we're going to reinitialize it. diff --git a/atmel-samd/common-hal/touchio/TouchIn.h b/atmel-samd/common-hal/touchio/TouchIn.h index 85799529e..ad08e97e9 100644 --- a/atmel-samd/common-hal/touchio/TouchIn.h +++ b/atmel-samd/common-hal/touchio/TouchIn.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_TOUCHIO_TOUCHIN_H__ #define __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_TOUCHIO_TOUCHIN_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "QTouch/touch_api_ptc.h" diff --git a/atmel-samd/main.c b/atmel-samd/main.c index 4eb810b21..29806e8e4 100644 --- a/atmel-samd/main.c +++ b/atmel-samd/main.c @@ -117,6 +117,7 @@ static char *stack_top; static char heap[16384]; void reset_mp(void) { + reset_status_led(); new_status_color(0x8f008f); autoreset_stop(); autoreset_enable(); @@ -175,10 +176,11 @@ void reset_samd21(void) { pulsein_reset(); pulseout_reset(); - // Wait for the DAC to sync. + // Wait for the DAC to sync then reset. while (DAC->STATUS.reg & DAC_STATUS_SYNCBUSY) {} DAC->CTRLA.reg |= DAC_CTRLA_SWRST; + // Reset pins struct system_pinmux_config config; system_pinmux_get_config_defaults(&config); config.powersave = true; @@ -279,6 +281,7 @@ bool start_mp(void) { maybe_run("main.py", &result) || maybe_run("main.txt", &result); } + reset_status_led(); if (result.return_code & PYEXEC_FORCED_EXIT) { return reset_next_character; diff --git a/atmel-samd/rgb_led_status.c b/atmel-samd/rgb_led_status.c index e04f12339..f3c20992c 100644 --- a/atmel-samd/rgb_led_status.c +++ b/atmel-samd/rgb_led_status.c @@ -3,7 +3,9 @@ #include "mphalport.h" +#include "common-hal/microcontroller/Pin.h" #include "shared-bindings/bitbangio/SPI.h" +#include "shared-bindings/busio/SPI.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/neopixel_write/__init__.h" #include "shared-module/bitbangio/types.h" @@ -15,27 +17,75 @@ static uint8_t status_neopixel_color[3]; static digitalio_digitalinout_obj_t status_neopixel; #endif + #if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) static uint8_t status_apa102_color[12] = {0, 0, 0, 0, 0xff, 0, 0, 0}; +#ifdef CIRCUITPY_BITBANG_APA102 static bitbangio_spi_obj_t status_apa102; +#else +busio_spi_obj_t status_apa102; +#endif #endif #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) static uint32_t current_status_color = 0; #endif + void rgb_led_status_init() { #ifdef MICROPY_HW_NEOPIXEL common_hal_digitalio_digitalinout_construct(&status_neopixel, MICROPY_HW_NEOPIXEL); + // Pretend we aren't using the pins. digitalio.DigitalInOut + // will mark them as used. + neopixel_in_use = false; common_hal_digitalio_digitalinout_switch_to_output(&status_neopixel, false, DRIVE_MODE_PUSH_PULL); #endif #if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) + #ifdef CIRCUITPY_BITBANG_APA102 shared_module_bitbangio_spi_construct(&status_apa102, MICROPY_HW_APA102_SCK, MICROPY_HW_APA102_MOSI, - NULL); + mp_const_none); + #else + if (status_apa102.current_baudrate > 0) { + // Don't use spi_deinit because that leads to infinite + // recursion because reset_pin may call + // rgb_led_status_init. + spi_disable(&status_apa102.spi_master_instance); + } + common_hal_busio_spi_construct(&status_apa102, + MICROPY_HW_APA102_SCK, + MICROPY_HW_APA102_MOSI, + mp_const_none); + #endif + // Pretend we aren't using the pins. bitbangio.SPI will + // mark them as used. + apa102_mosi_in_use = false; + apa102_sck_in_use = false; + #ifdef CIRCUITPY_BITBANG_APA102 shared_module_bitbangio_spi_try_lock(&status_apa102); shared_module_bitbangio_spi_configure(&status_apa102, 100000, 0, 1, 8); + #else + common_hal_busio_spi_try_lock(&status_apa102); + common_hal_busio_spi_configure(&status_apa102, 100000, 0, 1, 8); + #endif + #endif + + #if defined(MICROPY_HW_NEOPIXEL) || (defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK)) + // Force a write of the current status color. + uint32_t rgb = current_status_color; + current_status_color = 0; + new_status_color(rgb); + #endif +} + +void reset_status_led() { + #ifdef MICROPY_HW_NEOPIXEL + reset_pin(MICROPY_HW_NEOPIXEL->pin); + #endif + #if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) + reset_pin(MICROPY_HW_APA102_MOSI->pin); + reset_pin(MICROPY_HW_APA102_SCK->pin); #endif } @@ -48,27 +98,48 @@ void new_status_color(uint32_t rgb) { #endif #ifdef MICROPY_HW_NEOPIXEL + if (neopixel_in_use) { + return; + } status_neopixel_color[0] = (rgb >> 8) & 0xff; status_neopixel_color[1] = (rgb >> 16) & 0xff; status_neopixel_color[2] = rgb & 0xff; common_hal_neopixel_write(&status_neopixel, status_neopixel_color, 3); #endif #if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) + if (apa102_mosi_in_use || apa102_sck_in_use) { + return; + } status_apa102_color[5] = rgb & 0xff; status_apa102_color[6] = (rgb >> 8) & 0xff; status_apa102_color[7] = (rgb >> 16) & 0xff; + + #ifdef CIRCUITPY_BITBANG_APA102 shared_module_bitbangio_spi_write(&status_apa102, status_apa102_color, 8); + #else + common_hal_busio_spi_write(&status_apa102, status_apa102_color, 8); + #endif #endif } void temp_status_color(uint32_t rgb) { #ifdef MICROPY_HW_NEOPIXEL + if (neopixel_in_use) { + return; + } uint8_t colors[3] = {(rgb >> 8) & 0xff, (rgb >> 16) & 0xff, rgb & 0xff}; common_hal_neopixel_write(&status_neopixel, colors, 3); #endif #if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) + if (apa102_mosi_in_use || apa102_sck_in_use) { + return; + } uint8_t colors[12] = {0, 0, 0, 0, 0xff, rgb & 0xff, (rgb >> 8) & 0xff, (rgb >> 16) & 0xff, 0x0, 0x0, 0x0, 0x0}; - shared_module_bitbangio_spi_write(&status_apa102, colors, 8); + #ifdef CIRCUITPY_BITBANG_APA102 + shared_module_bitbangio_spi_write(&status_apa102, colors, 12); + #else + common_hal_busio_spi_write(&status_apa102, colors, 12); + #endif #endif } @@ -77,7 +148,11 @@ void clear_temp_status() { common_hal_neopixel_write(&status_neopixel, status_neopixel_color, 3); #endif #if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) - shared_module_bitbangio_spi_write(&status_apa102, status_apa102_color, 12); + #ifdef CIRCUITPY_BITBANG_APA102 + shared_module_bitbangio_spi_write(&status_apa102, status_apa102_color, 8); + #else + common_hal_busio_spi_write(&status_apa102, status_apa102_color, 8); + #endif #endif } diff --git a/atmel-samd/rgb_led_status.h b/atmel-samd/rgb_led_status.h index be1227e9f..6d5d69373 100644 --- a/atmel-samd/rgb_led_status.h +++ b/atmel-samd/rgb_led_status.h @@ -4,12 +4,19 @@ #include <stdint.h> #include <stdbool.h> +#include "mpconfigport.h" #include "rgb_led_colors.h" -extern void rgb_led_status_init(void); -extern void new_status_color(uint32_t rgb); -extern void temp_status_color(uint32_t rgb); -extern void clear_temp_status(void); +#if defined(MICROPY_HW_APA102_MOSI) && defined(MICROPY_HW_APA102_SCK) && !defined(CIRCUITPY_BITBANG_APA102) +#include "common-hal/busio/SPI.h" +extern busio_spi_obj_t status_apa102; +#endif + +void rgb_led_status_init(void); +void reset_status_led(void); +void new_status_color(uint32_t rgb); +void temp_status_color(uint32_t rgb); +void clear_temp_status(void); uint32_t color_brightness(uint32_t color, uint8_t brightness); diff --git a/atmel-samd/samd21_pins.c b/atmel-samd/samd21_pins.c index 6be3197e4..32acca8da 100644 --- a/atmel-samd/samd21_pins.c +++ b/atmel-samd/samd21_pins.c @@ -66,16 +66,6 @@ const mcu_pin_obj_t pin_## p_name = { \ #define NO_ADC_INPUT (0) -void reset_pin(uint8_t pin) { - if (pin >= PORT_BITS) { - return; - } - struct system_pinmux_config config; - system_pinmux_get_config_defaults(&config); - config.powersave = true; - system_pinmux_pin_set_config(pin, &config); -} - // Pins in datasheet order. // NOTE(tannewt): TC wave out 0 is commented out because the first channel is // used to vary the 16 bit timer's frequency. diff --git a/atmel-samd/samd21_pins.h b/atmel-samd/samd21_pins.h index 0c7522e8b..629941f81 100644 --- a/atmel-samd/samd21_pins.h +++ b/atmel-samd/samd21_pins.h @@ -1,7 +1,7 @@ #ifndef __MICROPY_INCLUDED_ATMEL_SAMD_BOARDS_SAMD21_PINS_H__ #define __MICROPY_INCLUDED_ATMEL_SAMD_BOARDS_SAMD21_PINS_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" void reset_pin(uint8_t pin); diff --git a/esp8266/common-hal/analogio/AnalogIn.h b/esp8266/common-hal/analogio/AnalogIn.h index a4edd233d..e2867db43 100644 --- a/esp8266/common-hal/analogio/AnalogIn.h +++ b/esp8266/common-hal/analogio/AnalogIn.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ESP8266_COMMON_HAL_ANALOGIO_ANALOGIN_H__ #define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_ANALOGIO_ANALOGIN_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "py/obj.h" diff --git a/esp8266/common-hal/board/__init__.c b/esp8266/common-hal/board/__init__.c index 3893e70f7..9365f0fd9 100644 --- a/esp8266/common-hal/board/__init__.c +++ b/esp8266/common-hal/board/__init__.c @@ -28,7 +28,7 @@ #include "py/runtime.h" #include "py/mphal.h" -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" // Pins aren't actually defined here. They are in the board specific directory // such as boards/feather_huzzah/pins.c. diff --git a/esp8266/common-hal/busio/SPI.h b/esp8266/common-hal/busio/SPI.h index baff10b70..93d2fc79b 100644 --- a/esp8266/common-hal/busio/SPI.h +++ b/esp8266/common-hal/busio/SPI.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ESP8266_COMMON_HAL_BUSIO_SPI_H__ #define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_BUSIO_SPI_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "py/obj.h" diff --git a/esp8266/common-hal/busio/UART.h b/esp8266/common-hal/busio/UART.h index a87e7c9b2..febb81f89 100644 --- a/esp8266/common-hal/busio/UART.h +++ b/esp8266/common-hal/busio/UART.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ESP8266_COMMON_HAL_BUSIO_UART_H__ #define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_BUSIO_UART_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "py/obj.h" diff --git a/esp8266/common-hal/digitalio/DigitalInOut.h b/esp8266/common-hal/digitalio/DigitalInOut.h index 94de1bca5..13bc2af5b 100644 --- a/esp8266/common-hal/digitalio/DigitalInOut.h +++ b/esp8266/common-hal/digitalio/DigitalInOut.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ESP8266_COMMON_HAL_DIGITALIO_DIGITALINOUT_H__ #define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_DIGITALIO_DIGITALINOUT_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "py/obj.h" typedef struct { diff --git a/esp8266/common-hal/microcontroller/Pin.h b/esp8266/common-hal/microcontroller/Pin.h index a06e9c195..1381ab55a 100644 --- a/esp8266/common-hal/microcontroller/Pin.h +++ b/esp8266/common-hal/microcontroller/Pin.h @@ -27,6 +27,16 @@ #ifndef __MICROPY_INCLUDED_ESP8266_COMMON_HAL_MICROCONTROLLER_PIN_H__ #define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_MICROCONTROLLER_PIN_H__ +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; + qstr name; + uint8_t gpio_number; + uint8_t gpio_function; + uint32_t peripheral; +} mcu_pin_obj_t; + // Magic values for gpio_number. #define NO_GPIO 0xff #define SPECIAL_CASE 0xfe diff --git a/esp8266/common-hal/microcontroller/__init__.c b/esp8266/common-hal/microcontroller/__init__.c index f14143e7d..3a5ec92cd 100644 --- a/esp8266/common-hal/microcontroller/__init__.c +++ b/esp8266/common-hal/microcontroller/__init__.c @@ -25,7 +25,7 @@ */ #include "common-hal/microcontroller/Pin.h" -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "shared-bindings/microcontroller/Pin.h" #include "eagle_soc.h" diff --git a/esp8266/common-hal/microcontroller/__init__.h b/esp8266/common-hal/microcontroller/__init__.h index c82df49e9..a5f7baa25 100644 --- a/esp8266/common-hal/microcontroller/__init__.h +++ b/esp8266/common-hal/microcontroller/__init__.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ESP8266_COMMON_HAL_MICROCONTROLLER___INIT___H__ #define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_MICROCONTROLLER___INIT___H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" extern const mcu_pin_obj_t pin_TOUT; extern const mcu_pin_obj_t pin_XPD_DCDC; diff --git a/esp8266/common-hal/microcontroller/types.h b/esp8266/common-hal/microcontroller/types.h deleted file mode 100644 index 8245cd303..000000000 --- a/esp8266/common-hal/microcontroller/types.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 Scott Shawcroft - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#ifndef __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_MICROCONTROLLER_TYPES_H__ -#define __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_MICROCONTROLLER_TYPES_H__ - -#include "py/obj.h" - -typedef struct { - mp_obj_base_t base; - qstr name; - uint8_t gpio_number; - uint8_t gpio_function; - uint32_t peripheral; -} mcu_pin_obj_t; - -#endif // __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_MICROCONTROLLER_TYPES_H__ diff --git a/esp8266/common-hal/pulseio/PWMOut.h b/esp8266/common-hal/pulseio/PWMOut.h index 7eb22e6e1..ababba657 100644 --- a/esp8266/common-hal/pulseio/PWMOut.h +++ b/esp8266/common-hal/pulseio/PWMOut.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_ESP8266_COMMON_HAL_PULSEIO_PWMOUT_H__ #define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_PULSEIO_PWMOUT_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" typedef struct { mp_obj_base_t base; diff --git a/shared-bindings/analogio/AnalogIn.h b/shared-bindings/analogio/AnalogIn.h index 64ddaab0f..4f31537de 100644 --- a/shared-bindings/analogio/AnalogIn.h +++ b/shared-bindings/analogio/AnalogIn.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGIO_ANALOGIN_H__ #define __MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGIO_ANALOGIN_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "common-hal/analogio/AnalogIn.h" extern const mp_obj_type_t analogio_analogin_type; diff --git a/shared-bindings/analogio/AnalogOut.h b/shared-bindings/analogio/AnalogOut.h index 3aa19ac29..51b291afd 100644 --- a/shared-bindings/analogio/AnalogOut.h +++ b/shared-bindings/analogio/AnalogOut.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGIO_ANALOGOUT_H__ #define __MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGIO_ANALOGOUT_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "common-hal/analogio/AnalogOut.h" extern const mp_obj_type_t analogio_analogout_type; diff --git a/shared-bindings/bitbangio/I2C.h b/shared-bindings/bitbangio/I2C.h index 4d01230af..26a3d6d47 100644 --- a/shared-bindings/bitbangio/I2C.h +++ b/shared-bindings/bitbangio/I2C.h @@ -29,7 +29,7 @@ #include "py/obj.h" -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "shared-module/bitbangio/types.h" // Type object used in Python. Should be shared between ports. diff --git a/shared-bindings/bitbangio/OneWire.h b/shared-bindings/bitbangio/OneWire.h index a888dae04..c21bf7067 100644 --- a/shared-bindings/bitbangio/OneWire.h +++ b/shared-bindings/bitbangio/OneWire.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_SHARED_BINDINGS_BITBANGIO_ONEWIRE_H__ #define __MICROPY_INCLUDED_SHARED_BINDINGS_BITBANGIO_ONEWIRE_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "shared-module/bitbangio/types.h" extern const mp_obj_type_t bitbangio_onewire_type; diff --git a/shared-bindings/bitbangio/SPI.h b/shared-bindings/bitbangio/SPI.h index 7b851b30d..a36da949e 100644 --- a/shared-bindings/bitbangio/SPI.h +++ b/shared-bindings/bitbangio/SPI.h @@ -29,7 +29,7 @@ #include "py/obj.h" -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "shared-module/bitbangio/types.h" // Type object used in Python. Should be shared between ports. diff --git a/shared-bindings/busio/I2C.h b/shared-bindings/busio/I2C.h index 0d260a309..7b8b4573c 100644 --- a/shared-bindings/busio/I2C.h +++ b/shared-bindings/busio/I2C.h @@ -36,7 +36,7 @@ #include "py/obj.h" -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "common-hal/busio/I2C.h" // Type object used in Python. Should be shared between ports. diff --git a/shared-bindings/busio/OneWire.h b/shared-bindings/busio/OneWire.h index df5cecb7c..4a358ddd5 100644 --- a/shared-bindings/busio/OneWire.h +++ b/shared-bindings/busio/OneWire.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_ONEWIRE_H__ #define __MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_ONEWIRE_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "common-hal/busio/OneWire.h" extern const mp_obj_type_t busio_onewire_type; diff --git a/shared-bindings/busio/SPI.h b/shared-bindings/busio/SPI.h index e3deb0e72..97b92e377 100644 --- a/shared-bindings/busio/SPI.h +++ b/shared-bindings/busio/SPI.h @@ -29,7 +29,7 @@ #include "py/obj.h" -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "common-hal/busio/SPI.h" // Type object used in Python. Should be shared between ports. diff --git a/shared-bindings/busio/UART.h b/shared-bindings/busio/UART.h index e0a8a0b09..6311d21ce 100644 --- a/shared-bindings/busio/UART.h +++ b/shared-bindings/busio/UART.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_UART_H__ #define __MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_UART_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "common-hal/busio/UART.h" extern const mp_obj_type_t busio_uart_type; diff --git a/shared-bindings/digitalio/DigitalInOut.h b/shared-bindings/digitalio/DigitalInOut.h index 7fd6810f1..db83a27a4 100644 --- a/shared-bindings/digitalio/DigitalInOut.h +++ b/shared-bindings/digitalio/DigitalInOut.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_SHARED_BINDINGS_DIGITALIO_DIGITALINOUT_H__ #define __MICROPY_INCLUDED_SHARED_BINDINGS_DIGITALIO_DIGITALINOUT_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "common-hal/digitalio/DigitalInOut.h" extern const mp_obj_type_t digitalio_digitalinout_type; diff --git a/shared-bindings/microcontroller/Pin.h b/shared-bindings/microcontroller/Pin.h index 46a531a6d..75193bb78 100644 --- a/shared-bindings/microcontroller/Pin.h +++ b/shared-bindings/microcontroller/Pin.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_SHARED_BINDINGS_MICROCONTROLLER_PIN_H__ #define __MICROPY_INCLUDED_SHARED_BINDINGS_MICROCONTROLLER_PIN_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "py/obj.h" // Type object used in Python. Should be shared between ports. diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index 214436687..fbe359ed9 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -34,7 +34,7 @@ #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "py/runtime.h" diff --git a/shared-bindings/pulseio/PWMOut.h b/shared-bindings/pulseio/PWMOut.h index f7a0bff22..423acf0e9 100644 --- a/shared-bindings/pulseio/PWMOut.h +++ b/shared-bindings/pulseio/PWMOut.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PWMOUT_H__ #define __MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PWMOUT_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "common-hal/pulseio/PWMOut.h" extern const mp_obj_type_t pulseio_pwmout_type; diff --git a/shared-bindings/pulseio/PulseIn.h b/shared-bindings/pulseio/PulseIn.h index 5ffab1d67..52e0b861b 100644 --- a/shared-bindings/pulseio/PulseIn.h +++ b/shared-bindings/pulseio/PulseIn.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PULSEIN_H__ #define __MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PULSEIN_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "common-hal/pulseio/PulseIn.h" extern const mp_obj_type_t pulseio_pulsein_type; diff --git a/shared-bindings/pulseio/PulseOut.h b/shared-bindings/pulseio/PulseOut.h index 5365fd1f5..17f034fda 100644 --- a/shared-bindings/pulseio/PulseOut.h +++ b/shared-bindings/pulseio/PulseOut.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PULSEOUT_H__ #define __MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PULSEOUT_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "common-hal/pulseio/PulseOut.h" #include "common-hal/pulseio/PWMOut.h" diff --git a/shared-bindings/touchio/TouchIn.h b/shared-bindings/touchio/TouchIn.h index 04a72835e..495cb2b14 100644 --- a/shared-bindings/touchio/TouchIn.h +++ b/shared-bindings/touchio/TouchIn.h @@ -27,7 +27,7 @@ #ifndef __MICROPY_INCLUDED_SHARED_BINDINGS_TOUCHIO_TOUCHIN_H__ #define __MICROPY_INCLUDED_SHARED_BINDINGS_TOUCHIO_TOUCHIN_H__ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "common-hal/touchio/TouchIn.h" extern const mp_obj_type_t touchio_touchin_type; diff --git a/shared-module/bitbangio/I2C.c b/shared-module/bitbangio/I2C.c index 4c47629c7..0f017fc18 100644 --- a/shared-module/bitbangio/I2C.c +++ b/shared-module/bitbangio/I2C.c @@ -29,7 +29,7 @@ #include "py/mperrno.h" #include "py/obj.h" -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-module/bitbangio/types.h" diff --git a/shared-module/bitbangio/OneWire.c b/shared-module/bitbangio/OneWire.c index b78acc8ec..46c0c406c 100644 --- a/shared-module/bitbangio/OneWire.c +++ b/shared-module/bitbangio/OneWire.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "shared-bindings/bitbangio/OneWire.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/digitalio/DigitalInOut.h" diff --git a/shared-module/bitbangio/SPI.c b/shared-module/bitbangio/SPI.c index be0deda8f..a3c70dde9 100644 --- a/shared-module/bitbangio/SPI.c +++ b/shared-module/bitbangio/SPI.c @@ -29,7 +29,7 @@ #include "py/nlr.h" #include "py/obj.h" -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-module/bitbangio/types.h" diff --git a/shared-module/busio/OneWire.c b/shared-module/busio/OneWire.c index 0e3c2c384..73d3d29d7 100644 --- a/shared-module/busio/OneWire.c +++ b/shared-module/busio/OneWire.c @@ -25,7 +25,7 @@ */ // Wraps the bitbangio implementation of OneWire for use in busio. -#include "common-hal/microcontroller/types.h" +#include "common-hal/microcontroller/Pin.h" #include "shared-bindings/bitbangio/OneWire.h" #include "shared-module/busio/OneWire.h" |
