From 641a44e3e9d69349bdc525865b164c983e7ca40c Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Fri, 23 Feb 2018 10:57:59 -0500 Subject: [PATCH] Remove obsolete periphal drivers in esp module --- esp8266/Makefile | 6 -- esp8266/espapa102.c | 115 ------------------------------------- esp8266/espapa102.h | 31 ---------- esp8266/modesp.c | 35 ----------- esp8266/modules/apa102.py | 17 ------ esp8266/modules/dht.py | 32 ----------- esp8266/modules/ds18x20.py | 1 - esp8266/modules/onewire.py | 1 - esp8266/mpconfigport.h | 1 - 9 files changed, 239 deletions(-) delete mode 100644 esp8266/espapa102.c delete mode 100644 esp8266/espapa102.h delete mode 100644 esp8266/modules/apa102.py delete mode 100644 esp8266/modules/dht.py delete mode 120000 esp8266/modules/ds18x20.py delete mode 120000 esp8266/modules/onewire.py diff --git a/esp8266/Makefile b/esp8266/Makefile index d177bee58c..1eaa3a0bed 100644 --- a/esp8266/Makefile +++ b/esp8266/Makefile @@ -78,7 +78,6 @@ SRC_C = \ espuart.c \ esppwm.c \ espneopixel.c \ - espapa102.c \ intr.c \ modpyb.c \ modmachine.c \ @@ -190,10 +189,6 @@ LIB_SRC_C += \ lib/oofatfs/option/unicode.c endif -DRIVERS_SRC_C = $(addprefix drivers/,\ - dht/dht.c \ - ) - SRC_S = \ gchelper.s \ @@ -206,7 +201,6 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_SHARED_MODULE_EXPANDED:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(STM_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(EXTMOD_SRC_C:.c=.o)) OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o)) -OBJ += $(addprefix $(BUILD)/, $(DRIVERS_SRC_C:.c=.o)) #OBJ += $(BUILD)/pins_$(BOARD).o # List of sources for qstr extraction diff --git a/esp8266/espapa102.c b/esp8266/espapa102.c deleted file mode 100644 index 4295fe42d8..0000000000 --- a/esp8266/espapa102.c +++ /dev/null @@ -1,115 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 Robert Foss, Daniel Busch - * - * 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. - */ - -#include "py/mpconfig.h" -#if MICROPY_ESP8266_APA102 - -#include -#include "c_types.h" -#include "eagle_soc.h" -#include "user_interface.h" -#include "espapa102.h" - -#define NOP asm volatile(" nop \n\t") - -static inline void _esp_apa102_send_byte(uint32_t clockPinMask, uint32_t dataPinMask, uint8_t byte) { - for (uint32_t i = 0; i < 8; i++) { - if (byte & 0x80) { - // set data pin high - GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, dataPinMask); - } else { - // set data pin low - GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, dataPinMask); - } - - // set clock pin high - GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, clockPinMask); - byte <<= 1; - NOP; - NOP; - - // set clock pin low - GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, clockPinMask); - NOP; - NOP; - } -} - -static inline void _esp_apa102_send_colors(uint32_t clockPinMask, uint32_t dataPinMask, uint8_t *pixels, uint32_t numBytes) { - for (uint32_t i = 0; i < numBytes / 4; i++) { - _esp_apa102_send_byte(clockPinMask, dataPinMask, pixels[i * 4 + 3] | 0xE0); - _esp_apa102_send_byte(clockPinMask, dataPinMask, pixels[i * 4 + 2]); - _esp_apa102_send_byte(clockPinMask, dataPinMask, pixels[i * 4 + 1]); - _esp_apa102_send_byte(clockPinMask, dataPinMask, pixels[i * 4]); - } -} - -static inline void _esp_apa102_start_frame(uint32_t clockPinMask, uint32_t dataPinMask) { - for (uint32_t i = 0; i < 4; i++) { - _esp_apa102_send_byte(clockPinMask, dataPinMask, 0x00); - } -} - -static inline void _esp_apa102_append_additionial_cycles(uint32_t clockPinMask, uint32_t dataPinMask, uint32_t numBytes) { - GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, dataPinMask); - - // we need to write some more clock cycles, because each led - // delays the data by one edge after inverting the clock - for (uint32_t i = 0; i < numBytes / 8 + ((numBytes / 4) % 2); i++) { - GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, clockPinMask); - NOP; - NOP; - - GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, clockPinMask); - NOP; - NOP; - } -} - -static inline void _esp_apa102_end_frame(uint32_t clockPinMask, uint32_t dataPinMask) { - for (uint32_t i = 0; i < 4; i++) { - _esp_apa102_send_byte(clockPinMask, dataPinMask, 0xFF); - } -} - -void esp_apa102_write(uint8_t clockPin, uint8_t dataPin, uint8_t *pixels, uint32_t numBytes) { - uint32_t clockPinMask, dataPinMask; - - clockPinMask = 1 << clockPin; - dataPinMask = 1 << dataPin; - - // start the frame - _esp_apa102_start_frame(clockPinMask, dataPinMask); - - // write pixels - _esp_apa102_send_colors(clockPinMask, dataPinMask, pixels, numBytes); - - // end the frame - _esp_apa102_append_additionial_cycles(clockPinMask, dataPinMask, numBytes); - _esp_apa102_end_frame(clockPinMask, dataPinMask); -} - -#endif diff --git a/esp8266/espapa102.h b/esp8266/espapa102.h deleted file mode 100644 index dd7c5ab729..0000000000 --- a/esp8266/espapa102.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of the MicroPython project, http://micropython.org/ - * - * The MIT License (MIT) - * - * Copyright (c) 2016 Robert Foss, Daniel Busch - * - * 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_ESPAPA102_H -#define MICROPY_INCLUDED_ESP8266_ESPAPA102_H - -void esp_apa102_write(uint8_t clockPin, uint8_t dataPin, uint8_t *pixels, uint32_t numBytes); - -#endif // MICROPY_INCLUDED_ESP8266_ESPAPA102_H diff --git a/esp8266/modesp.c b/esp8266/modesp.c index cecedeb03f..6df79e889d 100644 --- a/esp8266/modesp.c +++ b/esp8266/modesp.c @@ -30,12 +30,9 @@ #include "py/runtime.h" #include "py/mperrno.h" #include "py/mphal.h" -#include "drivers/dht/dht.h" #include "espuart.h" #include "user_interface.h" #include "mem.h" -#include "espneopixel.h" -#include "espapa102.h" #include "modmachine.h" #define MODESP_INCLUDE_CONSTANTS (1) @@ -193,31 +190,6 @@ STATIC mp_obj_t esp_check_fw(void) { } STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_check_fw_obj, esp_check_fw); - -STATIC mp_obj_t esp_neopixel_write_(mp_obj_t pin, mp_obj_t buf, mp_obj_t is800k) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ); - if (!mp_obj_is_true(is800k)) { - nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "Only 800khz neopixels are supported.")); - } - esp_neopixel_write(mp_obj_get_pin_obj(pin)->phys_port, - (uint8_t*)bufinfo.buf, bufinfo.len); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(esp_neopixel_write_obj, esp_neopixel_write_); - -#if MICROPY_ESP8266_APA102 -STATIC mp_obj_t esp_apa102_write_(mp_obj_t clockPin, mp_obj_t dataPin, mp_obj_t buf) { - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ); - esp_apa102_write(mp_obj_get_pin_obj(clockPin)->phys_port, - mp_obj_get_pin_obj(dataPin)->phys_port, - (uint8_t*)bufinfo.buf, bufinfo.len); - return mp_const_none; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_3(esp_apa102_write_obj, esp_apa102_write_); -#endif - STATIC mp_obj_t esp_freemem() { return MP_OBJ_NEW_SMALL_INT(system_get_free_heap_size()); } @@ -362,13 +334,6 @@ STATIC const mp_rom_map_elem_t esp_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_flash_erase), MP_ROM_PTR(&esp_flash_erase_obj) }, { MP_ROM_QSTR(MP_QSTR_flash_size), MP_ROM_PTR(&esp_flash_size_obj) }, { MP_ROM_QSTR(MP_QSTR_flash_user_start), MP_ROM_PTR(&esp_flash_user_start_obj) }, - #if MICROPY_ESP8266_NEOPIXEL - { MP_ROM_QSTR(MP_QSTR_neopixel_write), MP_ROM_PTR(&esp_neopixel_write_obj) }, - #endif - #if MICROPY_ESP8266_APA102 - { MP_ROM_QSTR(MP_QSTR_apa102_write), MP_ROM_PTR(&esp_apa102_write_obj) }, - #endif - { MP_ROM_QSTR(MP_QSTR_dht_readinto), MP_ROM_PTR(&dht_readinto_obj) }, { MP_ROM_QSTR(MP_QSTR_freemem), MP_ROM_PTR(&esp_freemem_obj) }, { MP_ROM_QSTR(MP_QSTR_meminfo), MP_ROM_PTR(&esp_meminfo_obj) }, { MP_ROM_QSTR(MP_QSTR_check_fw), MP_ROM_PTR(&esp_check_fw_obj) }, diff --git a/esp8266/modules/apa102.py b/esp8266/modules/apa102.py deleted file mode 100644 index 41b7c0485c..0000000000 --- a/esp8266/modules/apa102.py +++ /dev/null @@ -1,17 +0,0 @@ -# APA102 driver for MicroPython on ESP8266 -# MIT license; Copyright (c) 2016 Robert Foss, Daniel Busch - -from esp import apa102_write -from neopixel import NeoPixel - - -class APA102(NeoPixel): - ORDER = (0, 1, 2, 3) - - def __init__(self, clock_pin, data_pin, n, bpp=4): - super().__init__(data_pin, n, bpp) - self.clock_pin = clock_pin - self.clock_pin.init(clock_pin.OUT) - - def write(self): - apa102_write(self.clock_pin, self.pin, self.buf) diff --git a/esp8266/modules/dht.py b/esp8266/modules/dht.py deleted file mode 100644 index 9a69e7e07e..0000000000 --- a/esp8266/modules/dht.py +++ /dev/null @@ -1,32 +0,0 @@ -# DHT11/DHT22 driver for MicroPython on ESP8266 -# MIT license; Copyright (c) 2016 Damien P. George - -import esp - -class DHTBase: - def __init__(self, pin): - self.pin = pin - self.buf = bytearray(5) - - def measure(self): - buf = self.buf - esp.dht_readinto(self.pin, buf) - if (buf[0] + buf[1] + buf[2] + buf[3]) & 0xff != buf[4]: - raise Exception("checksum error") - -class DHT11(DHTBase): - def humidity(self): - return self.buf[0] - - def temperature(self): - return self.buf[2] - -class DHT22(DHTBase): - def humidity(self): - return (self.buf[0] << 8 | self.buf[1]) * 0.1 - - def temperature(self): - t = ((self.buf[2] & 0x7f) << 8 | self.buf[3]) * 0.1 - if self.buf[2] & 0x80: - t = -t - return t diff --git a/esp8266/modules/ds18x20.py b/esp8266/modules/ds18x20.py deleted file mode 120000 index faae59d909..0000000000 --- a/esp8266/modules/ds18x20.py +++ /dev/null @@ -1 +0,0 @@ -../../drivers/onewire/ds18x20.py \ No newline at end of file diff --git a/esp8266/modules/onewire.py b/esp8266/modules/onewire.py deleted file mode 120000 index f6ec745e85..0000000000 --- a/esp8266/modules/onewire.py +++ /dev/null @@ -1 +0,0 @@ -../../drivers/onewire/onewire.py \ No newline at end of file diff --git a/esp8266/mpconfigport.h b/esp8266/mpconfigport.h index 1542147ad6..b0021ddcb6 100644 --- a/esp8266/mpconfigport.h +++ b/esp8266/mpconfigport.h @@ -106,7 +106,6 @@ #define MICROPY_FATFS_MAX_SS (4096) #define MICROPY_FATFS_LFN_CODE_PAGE (437) /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */ #define MICROPY_VFS_FAT (1) -#define MICROPY_ESP8266_APA102 (1) #define MICROPY_ESP8266_NEOPIXEL (1) extern void ets_event_poll(void);