diff options
Diffstat (limited to 'esp8266')
| -rw-r--r-- | esp8266/Makefile | 28 | ||||
| -rw-r--r-- | esp8266/common-hal/analogio/AnalogIn.c (renamed from esp8266/common-hal/nativeio/AnalogIn.c) | 10 | ||||
| -rw-r--r-- | esp8266/common-hal/analogio/AnalogIn.h (renamed from esp8266/common-hal/nativeio/TouchIn.c) | 29 | ||||
| -rw-r--r-- | esp8266/common-hal/analogio/AnalogOut.c (renamed from esp8266/common-hal/nativeio/AnalogOut.c) | 9 | ||||
| -rw-r--r-- | esp8266/common-hal/analogio/AnalogOut.h | 37 | ||||
| -rw-r--r-- | esp8266/common-hal/analogio/__init__.c | 1 | ||||
| -rw-r--r-- | esp8266/common-hal/busio/I2C.h | 33 | ||||
| -rw-r--r-- | esp8266/common-hal/busio/OneWire.h | 33 | ||||
| -rw-r--r-- | esp8266/common-hal/busio/SPI.c (renamed from esp8266/common-hal/nativeio/SPI.c) | 18 | ||||
| -rw-r--r-- | esp8266/common-hal/busio/SPI.h (renamed from esp8266/common-hal/nativeio/types.h) | 47 | ||||
| -rw-r--r-- | esp8266/common-hal/busio/UART.c (renamed from esp8266/common-hal/nativeio/UART.c) | 16 | ||||
| -rw-r--r-- | esp8266/common-hal/busio/UART.h | 38 | ||||
| -rw-r--r-- | esp8266/common-hal/busio/__init__.c | 1 | ||||
| -rw-r--r-- | esp8266/common-hal/digitalio/DigitalInOut.c (renamed from esp8266/common-hal/nativeio/DigitalInOut.c) | 52 | ||||
| -rw-r--r-- | esp8266/common-hal/digitalio/DigitalInOut.h (renamed from esp8266/common-hal/nativeio/DigitalInOut.h) | 9 | ||||
| -rw-r--r-- | esp8266/common-hal/digitalio/__init__.c | 1 | ||||
| -rw-r--r-- | esp8266/common-hal/nativeio/__init__.c | 1 | ||||
| -rw-r--r-- | esp8266/common-hal/neopixel_write/__init__.c | 2 | ||||
| -rw-r--r-- | esp8266/common-hal/pulseio/PWMOut.c (renamed from esp8266/common-hal/nativeio/PWMOut.c) | 16 | ||||
| -rw-r--r-- | esp8266/common-hal/pulseio/PWMOut.h (renamed from esp8266/common-hal/nativeio/PWMOut.h) | 14 | ||||
| -rw-r--r-- | esp8266/common-hal/pulseio/PulseIn.c (renamed from esp8266/common-hal/nativeio/PulseIn.c) | 20 | ||||
| -rw-r--r-- | esp8266/common-hal/pulseio/PulseIn.h | 38 | ||||
| -rw-r--r-- | esp8266/common-hal/pulseio/PulseOut.c (renamed from esp8266/common-hal/nativeio/PulseOut.c) | 10 | ||||
| -rw-r--r-- | esp8266/common-hal/pulseio/PulseOut.h | 38 | ||||
| -rw-r--r-- | esp8266/common-hal/pulseio/__init__.c | 1 | ||||
| -rw-r--r-- | esp8266/esp_mphal.c | 2 | ||||
| -rw-r--r-- | esp8266/espuart.c (renamed from esp8266/uart.c) | 2 | ||||
| -rw-r--r-- | esp8266/espuart.h (renamed from esp8266/uart.h) | 0 | ||||
| -rw-r--r-- | esp8266/machine_uart.c | 2 | ||||
| -rw-r--r-- | esp8266/main.c | 2 | ||||
| -rw-r--r-- | esp8266/modesp.c | 2 | ||||
| -rw-r--r-- | esp8266/mpconfigport.h | 10 |
32 files changed, 356 insertions, 166 deletions
diff --git a/esp8266/Makefile b/esp8266/Makefile index eac6eddc5..93e424112 100644 --- a/esp8266/Makefile +++ b/esp8266/Makefile @@ -79,7 +79,7 @@ SRC_C = \ esp_init_data.c \ gccollect.c \ lexerstr32.c \ - uart.c \ + espuart.c \ esppwm.c \ esponewire.c \ espneopixel.c \ @@ -109,16 +109,18 @@ SRC_C = \ SRC_COMMON_HAL = \ microcontroller/__init__.c \ microcontroller/Pin.c \ - nativeio/__init__.c \ - nativeio/AnalogIn.c \ - nativeio/AnalogOut.c \ - nativeio/DigitalInOut.c \ - nativeio/PulseIn.c \ - nativeio/PulseOut.c \ - nativeio/PWMOut.c \ - nativeio/SPI.c \ - nativeio/TouchIn.c \ - nativeio/UART.c \ + analogio/__init__.c \ + analogio/AnalogIn.c \ + analogio/AnalogOut.c \ + digitalio/__init__.c \ + digitalio/DigitalInOut.c \ + pulseio/__init__.c \ + pulseio/PulseIn.c \ + pulseio/PulseOut.c \ + pulseio/PWMOut.c \ + busio/__init__.c \ + busio/SPI.c \ + busio/UART.c \ neopixel_write/__init__.c \ time/__init__.c \ board/__init__.c @@ -131,8 +133,8 @@ SRC_SHARED_MODULE = \ bitbangio/I2C.c \ bitbangio/OneWire.c \ bitbangio/SPI.c \ - nativeio/I2C.c \ - nativeio/OneWire.c \ + busio/I2C.c \ + busio/OneWire.c \ SRC_SHARED_MODULE_EXPANDED = $(addprefix shared-bindings/, $(SRC_SHARED_MODULE)) \ $(addprefix shared-module/, $(SRC_SHARED_MODULE)) diff --git a/esp8266/common-hal/nativeio/AnalogIn.c b/esp8266/common-hal/analogio/AnalogIn.c index 57ff607a3..0f43a0879 100644 --- a/esp8266/common-hal/nativeio/AnalogIn.c +++ b/esp8266/common-hal/analogio/AnalogIn.c @@ -32,13 +32,13 @@ #include "py/binary.h" #include "py/mphal.h" #include "common-hal/microcontroller/__init__.h" -#include "shared-bindings/nativeio/AnalogIn.h" +#include "shared-bindings/analogio/AnalogIn.h" #include "user_interface.h" volatile bool adc_in_use __attribute__((aligned(4))) = false; -void common_hal_nativeio_analogin_construct(nativeio_analogin_obj_t* self, +void common_hal_analogio_analogin_construct(analogio_analogin_obj_t* self, const mcu_pin_obj_t *pin) { if (pin != &pin_TOUT) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Pin %q does not have ADC capabilities", pin->name)); @@ -46,15 +46,15 @@ void common_hal_nativeio_analogin_construct(nativeio_analogin_obj_t* self, adc_in_use = true; } -void common_hal_nativeio_analogin_deinit(nativeio_analogin_obj_t* self) { +void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t* self) { adc_in_use = false; } -uint16_t common_hal_nativeio_analogin_get_value(nativeio_analogin_obj_t *self) { +uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) { // ADC is 10 bit so shift by 6 to make it 16-bit. return system_adc_read() << 6; } -float common_hal_nativeio_analogin_get_reference_voltage(nativeio_analogin_obj_t *self) { +float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) { return 1.0f; } diff --git a/esp8266/common-hal/nativeio/TouchIn.c b/esp8266/common-hal/analogio/AnalogIn.h index 1501a7936..a4edd233d 100644 --- a/esp8266/common-hal/nativeio/TouchIn.c +++ b/esp8266/common-hal/analogio/AnalogIn.h @@ -1,9 +1,9 @@ /* - * This file is part of the Micro Python project, http://micropython.org/ + * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) * - * Copyright (c) 2016 Scott Shawcroft for Adafruit Industries + * 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 @@ -24,23 +24,16 @@ * THE SOFTWARE. */ -#include <string.h> +#ifndef __MICROPY_INCLUDED_ESP8266_COMMON_HAL_ANALOGIO_ANALOGIN_H__ +#define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_ANALOGIO_ANALOGIN_H__ -#include "py/nlr.h" -#include "py/runtime.h" -#include "py/binary.h" -#include "py/mphal.h" -#include "shared-bindings/nativeio/TouchIn.h" +#include "common-hal/microcontroller/types.h" -void common_hal_nativeio_touchin_construct(nativeio_touchin_obj_t* self, - const mcu_pin_obj_t *pin) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, - "No hardware support for capacitive touch.")); -} +#include "py/obj.h" -void common_hal_nativeio_touchin_deinit(nativeio_touchin_obj_t* self) { -} +typedef struct { + mp_obj_base_t base; + const mcu_pin_obj_t * pin; +} analogio_analogin_obj_t; -bool common_hal_nativeio_touchin_get_value(nativeio_touchin_obj_t *self) { - return false; -} +#endif // __MICROPY_INCLUDED_ESP8266_COMMON_HAL_ANALOGIO_ANALOGIN_H__ diff --git a/esp8266/common-hal/nativeio/AnalogOut.c b/esp8266/common-hal/analogio/AnalogOut.c index 06b1880c3..30dc44830 100644 --- a/esp8266/common-hal/nativeio/AnalogOut.c +++ b/esp8266/common-hal/analogio/AnalogOut.c @@ -30,18 +30,17 @@ #include "py/runtime.h" -#include "shared-bindings/nativeio/AnalogOut.h" +#include "shared-bindings/analogio/AnalogOut.h" - -void common_hal_nativeio_analogout_construct(nativeio_analogout_obj_t* self, +void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self, const mcu_pin_obj_t *pin) { nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "No hardware support for analog out.")); } -void common_hal_nativeio_analogout_deinit(nativeio_analogout_obj_t *self) { +void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) { } -void common_hal_nativeio_analogout_set_value(nativeio_analogout_obj_t *self, +void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self, uint16_t value) { } diff --git a/esp8266/common-hal/analogio/AnalogOut.h b/esp8266/common-hal/analogio/AnalogOut.h new file mode 100644 index 000000000..146a6571c --- /dev/null +++ b/esp8266/common-hal/analogio/AnalogOut.h @@ -0,0 +1,37 @@ +/* + * 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_ESP8266_COMMON_HAL_ANALOGIO_ANALOGOUT_H__ +#define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_ANALOGIO_ANALOGOUT_H__ + +#include "py/obj.h" + +// Not supported, throws error on construction. +typedef struct { + mp_obj_base_t base; +} analogio_analogout_obj_t; + +#endif // __MICROPY_INCLUDED_ESP8266_COMMON_HAL_ANALOGIO_ANALOGOUT_H__ diff --git a/esp8266/common-hal/analogio/__init__.c b/esp8266/common-hal/analogio/__init__.c new file mode 100644 index 000000000..eea58c77d --- /dev/null +++ b/esp8266/common-hal/analogio/__init__.c @@ -0,0 +1 @@ +// No analogio module functions. diff --git a/esp8266/common-hal/busio/I2C.h b/esp8266/common-hal/busio/I2C.h new file mode 100644 index 000000000..5877e6c31 --- /dev/null +++ b/esp8266/common-hal/busio/I2C.h @@ -0,0 +1,33 @@ +/* + * 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_ESP8266_COMMON_HAL_BUSIO_I2C_H__ +#define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_BUSIO_I2C_H__ + +// Use the bitbang wrapper for I2C +#include "shared-module/busio/I2C.h" + +#endif // __MICROPY_INCLUDED_ESP8266_COMMON_HAL_BUSIO_I2C_H__ diff --git a/esp8266/common-hal/busio/OneWire.h b/esp8266/common-hal/busio/OneWire.h new file mode 100644 index 000000000..3c52ced38 --- /dev/null +++ b/esp8266/common-hal/busio/OneWire.h @@ -0,0 +1,33 @@ +/* + * 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_ESP8266_COMMON_HAL_BUSIO_ONEWIRE_H__ +#define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_BUSIO_ONEWIRE_H__ + +// Use the bitbang wrapper for OneWire +#include "shared-module/busio/OneWire.h" + +#endif // __MICROPY_INCLUDED_ESP8266_COMMON_HAL_BUSIO_ONEWIRE_H__ diff --git a/esp8266/common-hal/nativeio/SPI.c b/esp8266/common-hal/busio/SPI.c index 427c0d33c..9ffb0294d 100644 --- a/esp8266/common-hal/nativeio/SPI.c +++ b/esp8266/common-hal/busio/SPI.c @@ -27,7 +27,7 @@ #include "esp8266/ets_alt_task.h" #include "esp8266/hspi.h" #include "shared-bindings/microcontroller/__init__.h" -#include "shared-bindings/nativeio/SPI.h" +#include "common-hal/busio/SPI.h" #include "py/nlr.h" #include "eagle_soc.h" @@ -38,7 +38,7 @@ extern const mcu_pin_obj_t pin_MTMS; extern const mcu_pin_obj_t pin_MTCK; extern const mcu_pin_obj_t pin_MTDI; -void common_hal_nativeio_spi_construct(nativeio_spi_obj_t *self, +void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t * clock, const mcu_pin_obj_t * mosi, const mcu_pin_obj_t * miso) { if (clock != &pin_MTMS || !((mosi == &pin_MTCK && miso == MP_OBJ_TO_PTR(mp_const_none)) || @@ -73,7 +73,7 @@ void common_hal_nativeio_spi_construct(nativeio_spi_obj_t *self, CLEAR_PERI_REG_MASK(SPI_USER(HSPI), SPI_FLASH_MODE); } -void common_hal_nativeio_spi_deinit(nativeio_spi_obj_t *self) { +void common_hal_busio_spi_deinit(busio_spi_obj_t *self) { PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, 0); PIN_PULLUP_DIS(PERIPHS_IO_MUX_MTDI_U); @@ -87,7 +87,7 @@ void common_hal_nativeio_spi_deinit(nativeio_spi_obj_t *self) { gpio_output_set(0x0, 0x0, 0x0, 0x7 << 12); } -bool common_hal_nativeio_spi_configure(nativeio_spi_obj_t *self, +bool common_hal_busio_spi_configure(busio_spi_obj_t *self, uint32_t baudrate, uint8_t polarity, uint8_t phase, uint8_t bits) { if (bits != 8) { return false; @@ -112,7 +112,7 @@ bool common_hal_nativeio_spi_configure(nativeio_spi_obj_t *self, return true; } -bool common_hal_nativeio_spi_try_lock(nativeio_spi_obj_t *self) { +bool common_hal_busio_spi_try_lock(busio_spi_obj_t *self) { bool success = false; common_hal_mcu_disable_interrupts(); if (!self->locked) { @@ -123,15 +123,15 @@ bool common_hal_nativeio_spi_try_lock(nativeio_spi_obj_t *self) { return success; } -bool common_hal_nativeio_spi_has_lock(nativeio_spi_obj_t *self) { +bool common_hal_busio_spi_has_lock(busio_spi_obj_t *self) { return self->locked; } -void common_hal_nativeio_spi_unlock(nativeio_spi_obj_t *self) { +void common_hal_busio_spi_unlock(busio_spi_obj_t *self) { self->locked = false; } -bool common_hal_nativeio_spi_write(nativeio_spi_obj_t *self, +bool common_hal_busio_spi_write(busio_spi_obj_t *self, const uint8_t * data, size_t len) { size_t chunk_size = 1024; size_t count = len / chunk_size; @@ -151,7 +151,7 @@ bool common_hal_nativeio_spi_write(nativeio_spi_obj_t *self, return true; } -bool common_hal_nativeio_spi_read(nativeio_spi_obj_t *self, +bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t * data, size_t len, uint8_t write_value) { // Process data in chunks, let the pending tasks run in between size_t chunk_size = 1024; // TODO this should depend on baudrate diff --git a/esp8266/common-hal/nativeio/types.h b/esp8266/common-hal/busio/SPI.h index 05b7d28c2..baff10b70 100644 --- a/esp8266/common-hal/nativeio/types.h +++ b/esp8266/common-hal/busio/SPI.h @@ -24,55 +24,16 @@ * THE SOFTWARE. */ -// This defines the types used to underly the standard nativeio Python objects. -// The shared API is defined in terms of these types. - -#ifndef __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_NATIVEIO_TYPES_H__ -#define __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_NATIVEIO_TYPES_H__ +#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 "py/obj.h" -// Use the bitbang wrapper for I2C and OneWire -#include "shared-module/nativeio/I2C.h" -#include "shared-module/nativeio/OneWire.h" - -typedef struct { - mp_obj_base_t base; - const mcu_pin_obj_t * pin; -} nativeio_analogin_obj_t; - -// Not supported, throws error on construction. -typedef struct { - mp_obj_base_t base; -} nativeio_analogout_obj_t; - typedef struct { mp_obj_base_t base; bool locked; -} nativeio_spi_obj_t; - -typedef struct { - mp_obj_base_t base; -} nativeio_pulsein_obj_t; - -typedef struct { - mp_obj_base_t base; -} nativeio_pulseout_obj_t; - -typedef struct { - mp_obj_base_t base; - int channel; - const mcu_pin_obj_t* pin; -} nativeio_pwmout_obj_t; - -typedef struct { - mp_obj_base_t base; -} nativeio_touchin_obj_t; - -typedef struct { - mp_obj_base_t base; -} nativeio_uart_obj_t; +} busio_spi_obj_t; -#endif // __MICROPY_INCLUDED_ATMEL_SAMD_COMMON_HAL_NATIVEIO_TYPES_H__ +#endif // __MICROPY_INCLUDED_ESP8266_COMMON_HAL_BUSIO_SPI_H__ diff --git a/esp8266/common-hal/nativeio/UART.c b/esp8266/common-hal/busio/UART.c index 8509dec64..b2a1d69b8 100644 --- a/esp8266/common-hal/nativeio/UART.c +++ b/esp8266/common-hal/busio/UART.c @@ -26,17 +26,17 @@ #include "common-hal/microcontroller/__init__.h" #include "shared-bindings/microcontroller/__init__.h" -#include "shared-bindings/nativeio/UART.h" +#include "shared-bindings/busio/UART.h" #include "ets_sys.h" -#include "uart.h" +#include "espuart.h" #include "py/nlr.h" // UartDev is defined and initialized in rom code. extern UartDevice UartDev; -void common_hal_nativeio_uart_construct(nativeio_uart_obj_t *self, +void common_hal_busio_uart_construct(busio_uart_obj_t *self, const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate, uint8_t bits, uart_parity_t parity, uint8_t stop, uint32_t timeout, uint8_t receiver_buffer_size) { @@ -92,16 +92,16 @@ void common_hal_nativeio_uart_construct(nativeio_uart_obj_t *self, uart_setup(UART1); } -void common_hal_nativeio_uart_deinit(nativeio_uart_obj_t *self) { +void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { PIN_FUNC_SELECT(FUNC_U1TXD_BK, 0); } -size_t common_hal_nativeio_uart_read(nativeio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { +size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { return 0; } // Write characters. -size_t common_hal_nativeio_uart_write(nativeio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { +size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { // write the data for (size_t i = 0; i < len; ++i) { uart_tx_one_char(UART1, *data++); @@ -111,10 +111,10 @@ size_t common_hal_nativeio_uart_write(nativeio_uart_obj_t *self, const uint8_t * return len; } -uint32_t common_hal_nativeio_uart_rx_characters_available(nativeio_uart_obj_t *self) { +uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) { return 0; } -bool common_hal_nativeio_uart_ready_to_tx(nativeio_uart_obj_t *self) { +bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) { return true; } diff --git a/esp8266/common-hal/busio/UART.h b/esp8266/common-hal/busio/UART.h new file mode 100644 index 000000000..a87e7c9b2 --- /dev/null +++ b/esp8266/common-hal/busio/UART.h @@ -0,0 +1,38 @@ +/* + * 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_ESP8266_COMMON_HAL_BUSIO_UART_H__ +#define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_BUSIO_UART_H__ + +#include "common-hal/microcontroller/types.h" + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; +} busio_uart_obj_t; + +#endif // __MICROPY_INCLUDED_ESP8266_COMMON_HAL_BUSIO_UART_H__ diff --git a/esp8266/common-hal/busio/__init__.c b/esp8266/common-hal/busio/__init__.c new file mode 100644 index 000000000..41761b674 --- /dev/null +++ b/esp8266/common-hal/busio/__init__.c @@ -0,0 +1 @@ +// No busio module functions. diff --git a/esp8266/common-hal/nativeio/DigitalInOut.c b/esp8266/common-hal/digitalio/DigitalInOut.c index e6a28ed75..356d0f3b8 100644 --- a/esp8266/common-hal/nativeio/DigitalInOut.c +++ b/esp8266/common-hal/digitalio/DigitalInOut.c @@ -32,16 +32,16 @@ #include "py/runtime.h" #include "py/mphal.h" -#include "shared-bindings/nativeio/DigitalInOut.h" +#include "shared-bindings/digitalio/DigitalInOut.h" -digitalinout_result_t common_hal_nativeio_digitalinout_construct( - nativeio_digitalinout_obj_t* self, const mcu_pin_obj_t* pin) { +digitalinout_result_t common_hal_digitalio_digitalinout_construct( + digitalio_digitalinout_obj_t* self, const mcu_pin_obj_t* pin) { self->pin = pin; PIN_FUNC_SELECT(self->pin->peripheral, self->pin->gpio_function); return DIGITALINOUT_OK; } -void common_hal_nativeio_digitalinout_deinit(nativeio_digitalinout_obj_t* self) { +void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t* self) { if (self->pin->gpio_number < 16) { uint32_t pin_mask = 1 << self->pin->gpio_number; gpio_output_set(0x0, 0x0, 0x0, pin_mask); @@ -50,8 +50,8 @@ void common_hal_nativeio_digitalinout_deinit(nativeio_digitalinout_obj_t* self) } } -void common_hal_nativeio_digitalinout_switch_to_input( - nativeio_digitalinout_obj_t* self, enum digitalinout_pull_t pull) { +void common_hal_digitalio_digitalinout_switch_to_input( + digitalio_digitalinout_obj_t* self, enum digitalinout_pull_t pull) { self->output = false; if (self->pin->gpio_number == 16) { @@ -62,11 +62,11 @@ void common_hal_nativeio_digitalinout_switch_to_input( PIN_PULLUP_DIS(self->pin->peripheral); gpio_output_set(0, 0, 0, 1 << self->pin->gpio_number); } - common_hal_nativeio_digitalinout_set_pull(self, pull); + common_hal_digitalio_digitalinout_set_pull(self, pull); } -void common_hal_nativeio_digitalinout_switch_to_output( - nativeio_digitalinout_obj_t* self, bool value, +void common_hal_digitalio_digitalinout_switch_to_output( + digitalio_digitalinout_obj_t* self, bool value, enum digitalinout_drive_mode_t drive_mode) { self->output = true; self->open_drain = drive_mode == DRIVE_MODE_OPEN_DRAIN; @@ -78,16 +78,16 @@ void common_hal_nativeio_digitalinout_switch_to_output( gpio_output_set(0, 0, 1 << self->pin->gpio_number, 0); PIN_PULLUP_DIS(self->pin->peripheral); } - common_hal_nativeio_digitalinout_set_value(self, value); + common_hal_digitalio_digitalinout_set_value(self, value); } -enum digitalinout_direction_t common_hal_nativeio_digitalinout_get_direction( - nativeio_digitalinout_obj_t* self) { +enum digitalinout_direction_t common_hal_digitalio_digitalinout_get_direction( + digitalio_digitalinout_obj_t* self) { return self->output? DIRECTION_OUT : DIRECTION_IN; } -void common_hal_nativeio_digitalinout_set_value( - nativeio_digitalinout_obj_t* self, bool value) { +void common_hal_digitalio_digitalinout_set_value( + digitalio_digitalinout_obj_t* self, bool value) { if (value) { if (self->open_drain) { // Disable output. @@ -109,8 +109,8 @@ void common_hal_nativeio_digitalinout_set_value( // Register addresses taken from: https://github.com/esp8266/esp8266-wiki/wiki/gpio-registers volatile uint32_t* PIN_DIR = (uint32_t *) 0x6000030C; volatile uint32_t* PIN_OUT = (uint32_t *) 0x60000300; -bool common_hal_nativeio_digitalinout_get_value( - nativeio_digitalinout_obj_t* self) { +bool common_hal_digitalio_digitalinout_get_value( + digitalio_digitalinout_obj_t* self) { if (!self->output) { if (self->pin->gpio_number == 16) { return READ_PERI_REG(RTC_GPIO_IN_DATA) & 1; @@ -126,20 +126,20 @@ bool common_hal_nativeio_digitalinout_get_value( } } -void common_hal_nativeio_digitalinout_set_drive_mode( - nativeio_digitalinout_obj_t* self, +void common_hal_digitalio_digitalinout_set_drive_mode( + digitalio_digitalinout_obj_t* self, enum digitalinout_drive_mode_t drive_mode) { - bool value = common_hal_nativeio_digitalinout_get_value(self); + bool value = common_hal_digitalio_digitalinout_get_value(self); self->open_drain = drive_mode == DRIVE_MODE_OPEN_DRAIN; // True is implemented differently between modes so reset the value to make // sure its correct for the new mode. if (value) { - common_hal_nativeio_digitalinout_set_value(self, value); + common_hal_digitalio_digitalinout_set_value(self, value); } } -enum digitalinout_drive_mode_t common_hal_nativeio_digitalinout_get_drive_mode( - nativeio_digitalinout_obj_t* self) { +enum digitalinout_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode( + digitalio_digitalinout_obj_t* self) { if (self->open_drain) { return DRIVE_MODE_OPEN_DRAIN; } else { @@ -147,8 +147,8 @@ enum digitalinout_drive_mode_t common_hal_nativeio_digitalinout_get_drive_mode( } } -void common_hal_nativeio_digitalinout_set_pull( - nativeio_digitalinout_obj_t* self, enum digitalinout_pull_t pull) { +void common_hal_digitalio_digitalinout_set_pull( + digitalio_digitalinout_obj_t* self, enum digitalinout_pull_t pull) { if (pull == PULL_DOWN) { nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "ESP8266 does not support pull down.")); @@ -166,8 +166,8 @@ void common_hal_nativeio_digitalinout_set_pull( } } -enum digitalinout_pull_t common_hal_nativeio_digitalinout_get_pull( - nativeio_digitalinout_obj_t* self) { +enum digitalinout_pull_t common_hal_digitalio_digitalinout_get_pull( + digitalio_digitalinout_obj_t* self) { if (self->pin->gpio_number < 16 && (READ_PERI_REG(self->pin->peripheral) & PERIPHS_IO_MUX_PULLUP) != 0) { return PULL_UP; diff --git a/esp8266/common-hal/nativeio/DigitalInOut.h b/esp8266/common-hal/digitalio/DigitalInOut.h index 6325b978b..94de1bca5 100644 --- a/esp8266/common-hal/nativeio/DigitalInOut.h +++ b/esp8266/common-hal/digitalio/DigitalInOut.h @@ -24,9 +24,10 @@ * THE SOFTWARE. */ -#ifndef __MICROPY_INCLUDED_ESP8266_COMMON_HAL_NATIVEIO_DIGITALINOUT_H__ -#define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_NATIVEIO_DIGITALINOUT_H__ +#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 "py/obj.h" typedef struct { @@ -34,6 +35,6 @@ typedef struct { const mcu_pin_obj_t * pin; bool output; bool open_drain; -} nativeio_digitalinout_obj_t; +} digitalio_digitalinout_obj_t; -#endif // __MICROPY_INCLUDED_ESP8266_COMMON_HAL_NATIVEIO_DIGITALINOUT_H__ +#endif // __MICROPY_INCLUDED_ESP8266_COMMON_HAL_DIGITALIO_DIGITALINOUT_H__ diff --git a/esp8266/common-hal/digitalio/__init__.c b/esp8266/common-hal/digitalio/__init__.c new file mode 100644 index 000000000..20fad4595 --- /dev/null +++ b/esp8266/common-hal/digitalio/__init__.c @@ -0,0 +1 @@ +// No digitalio module functions. diff --git a/esp8266/common-hal/nativeio/__init__.c b/esp8266/common-hal/nativeio/__init__.c deleted file mode 100644 index e0ec8acfb..000000000 --- a/esp8266/common-hal/nativeio/__init__.c +++ /dev/null @@ -1 +0,0 @@ -// No nativeio module functions. diff --git a/esp8266/common-hal/neopixel_write/__init__.c b/esp8266/common-hal/neopixel_write/__init__.c index daaeead43..84a743d11 100644 --- a/esp8266/common-hal/neopixel_write/__init__.c +++ b/esp8266/common-hal/neopixel_write/__init__.c @@ -28,6 +28,6 @@ #include "espneopixel.h" -void common_hal_neopixel_write(const nativeio_digitalinout_obj_t* digitalinout, uint8_t *pixels, uint32_t numBytes) { +void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* digitalinout, uint8_t *pixels, uint32_t numBytes) { esp_neopixel_write(digitalinout->pin->gpio_number, pixels, numBytes); } diff --git a/esp8266/common-hal/nativeio/PWMOut.c b/esp8266/common-hal/pulseio/PWMOut.c index 234246d15..40a46e392 100644 --- a/esp8266/common-hal/nativeio/PWMOut.c +++ b/esp8266/common-hal/pulseio/PWMOut.c @@ -30,7 +30,7 @@ #include "esppwm.h" #include "py/runtime.h" -#include "shared-bindings/nativeio/PWMOut.h" +#include "shared-bindings/pulseio/PWMOut.h" #include "eagle_soc.h" #include "c_types.h" @@ -46,7 +46,7 @@ void pwmout_reset(void) { first_channel_variable = false; } -void common_hal_nativeio_pwmout_construct(nativeio_pwmout_obj_t* self, const mcu_pin_obj_t* pin, uint16_t duty, uint32_t frequency, +void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, const mcu_pin_obj_t* pin, uint16_t duty, uint32_t frequency, bool variable_frequency) { if (frequency > PWM_FREQ_MAX) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, @@ -77,7 +77,7 @@ void common_hal_nativeio_pwmout_construct(nativeio_pwmout_obj_t* self, const mcu } } -extern void common_hal_nativeio_pwmout_deinit(nativeio_pwmout_obj_t* self) { +extern void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) { pwm_delete(self->channel); pwm_start(); if (self->pin->gpio_number < 16) { @@ -88,17 +88,17 @@ extern void common_hal_nativeio_pwmout_deinit(nativeio_pwmout_obj_t* self) { } } -extern void common_hal_nativeio_pwmout_set_duty_cycle(nativeio_pwmout_obj_t* self, uint16_t duty) { +extern void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty) { // We get 16 bits of duty in but the underlying code is only ten bit. pwm_set_duty(duty >> 6, self->channel); pwm_start(); } -uint16_t common_hal_nativeio_pwmout_get_duty_cycle(nativeio_pwmout_obj_t* self) { +uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) { return pwm_get_duty(self->channel) << 6; } -void common_hal_nativeio_pwmout_set_frequency(nativeio_pwmout_obj_t* self, uint32_t frequency) { +void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) { if (frequency > PWM_FREQ_MAX) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "Maximum PWM frequency is %dhz.", PWM_FREQ_MAX)); @@ -109,10 +109,10 @@ void common_hal_nativeio_pwmout_set_frequency(nativeio_pwmout_obj_t* self, uint3 pwm_set_freq(frequency, 0); } -uint32_t common_hal_nativeio_pwmout_get_frequency(nativeio_pwmout_obj_t* self) { +uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) { return pwm_get_freq(0); } -bool common_hal_nativeio_pwmout_get_variable_frequency(nativeio_pwmout_obj_t* self) { +bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) { return first_channel_variable; } diff --git a/esp8266/common-hal/nativeio/PWMOut.h b/esp8266/common-hal/pulseio/PWMOut.h index 9406b4953..7eb22e6e1 100644 --- a/esp8266/common-hal/nativeio/PWMOut.h +++ b/esp8266/common-hal/pulseio/PWMOut.h @@ -24,9 +24,17 @@ * THE SOFTWARE. */ -#ifndef __MICROPY_INCLUDED_ESP8266_COMMON_HAL_NATIVEIO_PWMOUT_H__ -#define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_NATIVEIO_PWMOUT_H__ +#ifndef __MICROPY_INCLUDED_ESP8266_COMMON_HAL_PULSEIO_PWMOUT_H__ +#define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_PULSEIO_PWMOUT_H__ + +#include "common-hal/microcontroller/types.h" + +typedef struct { + mp_obj_base_t base; + int channel; + const mcu_pin_obj_t* pin; +} pulseio_pwmout_obj_t; void pwmout_reset(void); -#endif // __MICROPY_INCLUDED_ESP8266_COMMON_HAL_NATIVEIO_PWMOUT_H__ +#endif // __MICROPY_INCLUDED_ESP8266_COMMON_HAL_PULSEIO_PWMOUT_H__ diff --git a/esp8266/common-hal/nativeio/PulseIn.c b/esp8266/common-hal/pulseio/PulseIn.c index c4bd5a77c..784116bef 100644 --- a/esp8266/common-hal/nativeio/PulseIn.c +++ b/esp8266/common-hal/pulseio/PulseIn.c @@ -30,40 +30,40 @@ #include "py/gc.h" #include "py/runtime.h" #include "shared-bindings/microcontroller/__init__.h" -#include "shared-bindings/nativeio/PulseIn.h" +#include "shared-bindings/pulseio/PulseIn.h" -void common_hal_nativeio_pulsein_construct(nativeio_pulsein_obj_t* self, +void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu_pin_obj_t* pin, uint16_t maxlen, bool idle_state) { mp_raise_NotImplementedError(""); } -void common_hal_nativeio_pulsein_deinit(nativeio_pulsein_obj_t* self) { +void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t* self) { } -void common_hal_nativeio_pulsein_pause(nativeio_pulsein_obj_t* self) { +void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t* self) { } -void common_hal_nativeio_pulsein_resume(nativeio_pulsein_obj_t* self, +void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t* self, uint16_t trigger_duration) { } -void common_hal_nativeio_pulsein_clear(nativeio_pulsein_obj_t* self) { +void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t* self) { } -uint16_t common_hal_nativeio_pulsein_popleft(nativeio_pulsein_obj_t* self) { +uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t* self) { return 0; } -uint16_t common_hal_nativeio_pulsein_get_maxlen(nativeio_pulsein_obj_t* self) { +uint16_t common_hal_pulseio_pulsein_get_maxlen(pulseio_pulsein_obj_t* self) { return 0; } -uint16_t common_hal_nativeio_pulsein_get_len(nativeio_pulsein_obj_t* self) { +uint16_t common_hal_pulseio_pulsein_get_len(pulseio_pulsein_obj_t* self) { return 0; } -uint16_t common_hal_nativeio_pulsein_get_item(nativeio_pulsein_obj_t* self, +uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_t index) { return 0; } diff --git a/esp8266/common-hal/pulseio/PulseIn.h b/esp8266/common-hal/pulseio/PulseIn.h new file mode 100644 index 000000000..c3a27d929 --- /dev/null +++ b/esp8266/common-hal/pulseio/PulseIn.h @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * 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_ESP8266_COMMON_HAL_PULSEIO_PULSEIN_H__ +#define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_PULSEIO_PULSEIN_H__ + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; +} pulseio_pulsein_obj_t; + +void pwmout_reset(void); + +#endif // __MICROPY_INCLUDED_ESP8266_COMMON_HAL_PULSEIO_PULSEIN_H__ diff --git a/esp8266/common-hal/nativeio/PulseOut.c b/esp8266/common-hal/pulseio/PulseOut.c index d5d1e6366..1301abbf3 100644 --- a/esp8266/common-hal/nativeio/PulseOut.c +++ b/esp8266/common-hal/pulseio/PulseOut.c @@ -28,15 +28,15 @@ #include <stdint.h> #include "py/runtime.h" -#include "shared-bindings/nativeio/PulseOut.h" +#include "shared-bindings/pulseio/PulseOut.h" -void common_hal_nativeio_pulseout_construct(nativeio_pulseout_obj_t* self, - const nativeio_pwmout_obj_t* carrier) { +void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self, + const pulseio_pwmout_obj_t* carrier) { nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "No hardware support for PulseOut.")); } -void common_hal_nativeio_pulseout_deinit(nativeio_pulseout_obj_t* self) { +void common_hal_pulseio_pulseout_deinit(pulseio_pulseout_obj_t* self) { } -void common_hal_nativeio_pulseout_send(nativeio_pulseout_obj_t* self, uint16_t* pulses, uint16_t length) { +void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t* self, uint16_t* pulses, uint16_t length) { } diff --git a/esp8266/common-hal/pulseio/PulseOut.h b/esp8266/common-hal/pulseio/PulseOut.h new file mode 100644 index 000000000..c4c6ef616 --- /dev/null +++ b/esp8266/common-hal/pulseio/PulseOut.h @@ -0,0 +1,38 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * 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_ESP8266_COMMON_HAL_PULSEIO_PULSEOUT_H__ +#define __MICROPY_INCLUDED_ESP8266_COMMON_HAL_PULSEIO_PULSEOUT_H__ + +#include "py/obj.h" + +typedef struct { + mp_obj_base_t base; +} pulseio_pulseout_obj_t; + +void pwmout_reset(void); + +#endif // __MICROPY_INCLUDED_ESP8266_COMMON_HAL_PULSEIO_PULSEOUT_H__ diff --git a/esp8266/common-hal/pulseio/__init__.c b/esp8266/common-hal/pulseio/__init__.c new file mode 100644 index 000000000..2bee925bc --- /dev/null +++ b/esp8266/common-hal/pulseio/__init__.c @@ -0,0 +1 @@ +// No pulseio module functions. diff --git a/esp8266/esp_mphal.c b/esp8266/esp_mphal.c index f5e284fde..5db4f1968 100644 --- a/esp8266/esp_mphal.c +++ b/esp8266/esp_mphal.c @@ -27,7 +27,7 @@ #include <stdio.h> #include "ets_sys.h" #include "etshal.h" -#include "uart.h" +#include "espuart.h" #include "esp_mphal.h" #include "user_interface.h" #include "ets_alt_task.h" diff --git a/esp8266/uart.c b/esp8266/espuart.c index 001a9c673..ee893f4ec 100644 --- a/esp8266/uart.c +++ b/esp8266/espuart.c @@ -11,7 +11,7 @@ *******************************************************************************/ #include "ets_sys.h" #include "osapi.h" -#include "uart.h" +#include "espuart.h" #include "osapi.h" #include "uart_register.h" #include "etshal.h" diff --git a/esp8266/uart.h b/esp8266/espuart.h index 2b97683ff..2b97683ff 100644 --- a/esp8266/uart.h +++ b/esp8266/espuart.h diff --git a/esp8266/machine_uart.c b/esp8266/machine_uart.c index 9bc6422cc..0ae9c6e6c 100644 --- a/esp8266/machine_uart.c +++ b/esp8266/machine_uart.c @@ -29,7 +29,7 @@ #include <string.h> #include "ets_sys.h" -#include "uart.h" +#include "espuart.h" #include "py/runtime.h" #include "py/stream.h" diff --git a/esp8266/main.c b/esp8266/main.c index 0c1ad1bab..9ac728e38 100644 --- a/esp8266/main.c +++ b/esp8266/main.c @@ -40,7 +40,7 @@ #include "gccollect.h" #include "user_interface.h" #include "common-hal/microcontroller/Pin.h" -#include "common-hal/nativeio/PWMOut.h" +#include "common-hal/pulseio/PWMOut.h" STATIC char heap[36 * 1024]; diff --git a/esp8266/modesp.c b/esp8266/modesp.c index f13d94b32..77f8d1332 100644 --- a/esp8266/modesp.c +++ b/esp8266/modesp.c @@ -38,7 +38,7 @@ #include "netutils.h" #include "queue.h" #include "ets_sys.h" -#include "uart.h" +#include "espuart.h" #include "user_interface.h" #include "espconn.h" #include "spi_flash.h" diff --git a/esp8266/mpconfigport.h b/esp8266/mpconfigport.h index fa2e8bc1b..c4a375200 100644 --- a/esp8266/mpconfigport.h +++ b/esp8266/mpconfigport.h @@ -156,7 +156,10 @@ extern const struct _mp_obj_module_t mp_module_machine; extern const struct _mp_obj_module_t onewire_module; extern const struct _mp_obj_module_t microcontroller_module; extern const struct _mp_obj_module_t board_module; -extern const struct _mp_obj_module_t nativeio_module; +extern const struct _mp_obj_module_t analogio_module; +extern const struct _mp_obj_module_t digitalio_module; +extern const struct _mp_obj_module_t pulseio_module; +extern const struct _mp_obj_module_t busio_module; extern const struct _mp_obj_module_t bitbangio_module; extern const struct _mp_obj_module_t time_module; @@ -172,7 +175,10 @@ extern const struct _mp_obj_module_t time_module; { MP_OBJ_NEW_QSTR(MP_QSTR__onewire), (mp_obj_t)&onewire_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_microcontroller), (mp_obj_t)µcontroller_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_board), (mp_obj_t)&board_module }, \ - { MP_OBJ_NEW_QSTR(MP_QSTR_nativeio), (mp_obj_t)&nativeio_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_analogio), (mp_obj_t)&analogio_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_digitalio), (mp_obj_t)&digitalio_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_pulseio), (mp_obj_t)&pulseio_module }, \ + { MP_OBJ_NEW_QSTR(MP_QSTR_busio), (mp_obj_t)&busio_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_bitbangio), (mp_obj_t)&bitbangio_module }, \ { MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&time_module }, \ |
