diff options
| author | Dan Halbert <halbert@halwitz.org> | 2018-07-23 21:34:25 -0400 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2018-07-23 21:34:25 -0400 |
| commit | bc760dd34100099c352a0f185ec54ceae23d036d (patch) | |
| tree | cdbf3137eab7adec885ddb812daeda9b7069d679 /ports | |
| parent | 2809b4f9dd08dd1e83e87f1f4088ba22f3f66cd2 (diff) | |
WIP: complete manual inspection of all significant changes
Diffstat (limited to 'ports')
| -rw-r--r-- | ports/esp8266/Makefile | 6 | ||||
| -rw-r--r-- | ports/esp8266/common-hal/busio/UART.c | 2 | ||||
| -rw-r--r-- | ports/esp8266/common-hal/os/__init__.c | 15 | ||||
| -rw-r--r-- | ports/esp8266/esp_mphal.c | 2 | ||||
| -rw-r--r-- | ports/esp8266/espneopixel.c | 19 | ||||
| -rw-r--r-- | ports/esp8266/espneopixel.h | 2 | ||||
| -rw-r--r-- | ports/esp8266/etshal.h | 8 | ||||
| -rw-r--r-- | ports/esp8266/machine_uart.c | 2 | ||||
| -rw-r--r-- | ports/esp8266/main.c | 19 | ||||
| -rw-r--r-- | ports/esp8266/modesp.c | 2 | ||||
| -rw-r--r-- | ports/esp8266/modnetwork.c | 4 | ||||
| -rw-r--r-- | ports/esp8266/modules/inisetup.py | 2 | ||||
| -rw-r--r-- | ports/esp8266/modules/webrepl_setup.py | 10 | ||||
| -rw-r--r-- | ports/esp8266/modutime.c | 12 | ||||
| -rw-r--r-- | ports/esp8266/mpconfigport.h | 2 | ||||
| -rw-r--r-- | ports/esp8266/uart.c (renamed from ports/esp8266/espuart.c) | 2 | ||||
| -rw-r--r-- | ports/esp8266/uart.h (renamed from ports/esp8266/espuart.h) | 0 | ||||
| -rw-r--r-- | ports/nrf/mpconfigport.h | 4 |
18 files changed, 54 insertions, 59 deletions
diff --git a/ports/esp8266/Makefile b/ports/esp8266/Makefile index 5c0983fe7..89e9be0c3 100644 --- a/ports/esp8266/Makefile +++ b/ports/esp8266/Makefile @@ -77,7 +77,7 @@ SRC_C = \ esp_init_data.c \ gccollect.c \ lexerstr32.c \ - espuart.c \ + uart.c \ esppwm.c \ espneopixel.c \ intr.c \ @@ -193,7 +193,10 @@ LIB_SRC_C += \ lib/oofatfs/option/unicode.c endif +DRIVERS_SRC_C = $(addprefix drivers/,\ bus/softspi.c \ + ) + SRC_S = \ gchelper.s \ @@ -206,6 +209,7 @@ 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)) # List of sources for qstr extraction SRC_QSTR += $(SRC_C) $(SRC_COMMON_HAL_EXPANDED) $(SRC_SHARED_MODULE_EXPANDED) $(STM_SRC_C) $(EXTMOD_SRC_C) $(DRIVERS_SRC_C) diff --git a/ports/esp8266/common-hal/busio/UART.c b/ports/esp8266/common-hal/busio/UART.c index 9b5d86ef5..5540e3573 100644 --- a/ports/esp8266/common-hal/busio/UART.c +++ b/ports/esp8266/common-hal/busio/UART.c @@ -29,7 +29,7 @@ #include "shared-bindings/busio/UART.h" #include "ets_sys.h" -#include "espuart.h" +#include "uart.h" #include "py/nlr.h" diff --git a/ports/esp8266/common-hal/os/__init__.c b/ports/esp8266/common-hal/os/__init__.c index b9773d186..a686964be 100644 --- a/ports/esp8266/common-hal/os/__init__.c +++ b/ports/esp8266/common-hal/os/__init__.c @@ -27,9 +27,11 @@ #include <string.h> +#include "esp_mphal.h" #include "etshal.h" #include "py/objtuple.h" #include "py/objstr.h" +#include "extmod/misc.h" #include "genhdr/mpversion.h" #include "user_interface.h" @@ -75,19 +77,6 @@ bool common_hal_os_urandom(uint8_t* buffer, uint32_t length) { i++; new_random >>= 8; } -// We wrap the mp_uos_dupterm function to detect if a UART is attached or not -mp_obj_t os_dupterm(size_t n_args, const mp_obj_t *args) { - mp_obj_t prev_obj = mp_uos_dupterm_obj.fun.var(n_args, args); - if (mp_obj_get_type(args[0]) == &pyb_uart_type) { - ++uart_attached_to_dupterm; - } - if (mp_obj_get_type(prev_obj) == &pyb_uart_type) { - --uart_attached_to_dupterm; - } - return prev_obj; -} -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(os_dupterm_obj, 1, 2, os_dupterm); - } return true; } diff --git a/ports/esp8266/esp_mphal.c b/ports/esp8266/esp_mphal.c index 5dcdd6fba..be284c8f3 100644 --- a/ports/esp8266/esp_mphal.c +++ b/ports/esp8266/esp_mphal.c @@ -27,7 +27,7 @@ #include <stdio.h> #include "ets_sys.h" #include "etshal.h" -#include "espuart.h" +#include "uart.h" #include "esp_mphal.h" #include "user_interface.h" #include "ets_alt_task.h" diff --git a/ports/esp8266/espneopixel.c b/ports/esp8266/espneopixel.c index f3827283d..6c7659186 100644 --- a/ports/esp8266/espneopixel.c +++ b/ports/esp8266/espneopixel.c @@ -16,7 +16,7 @@ #define NEO_KHZ400 (1) -void /*ICACHE_RAM_ATTR*/ esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32_t numBytes) { +void /*ICACHE_RAM_ATTR*/ esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32_t numBytes, bool is800KHz) { uint8_t *p, *end, pix, mask; uint32_t t, time0, time1, period, c, startTime, pinMask; @@ -30,10 +30,19 @@ void /*ICACHE_RAM_ATTR*/ esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32 uint32_t fcpu = system_get_cpu_freq() * 1000000; - - time0 = fcpu / 2857143; // 0.35us - time1 = fcpu / 1250000; // 0.8us - period = fcpu / 800000; // 1.25us per bit +#ifdef NEO_KHZ400 + if(is800KHz) { +#endif + time0 = fcpu / 2857143; // 0.35us + time1 = fcpu / 1250000; // 0.8us + period = fcpu / 800000; // 1.25us per bit +#ifdef NEO_KHZ400 + } else { // 400 KHz bitstream + time0 = fcpu / 2000000; // 0.5uS + time1 = fcpu / 833333; // 1.2us + period = fcpu / 400000; // 2.5us per bit + } +#endif uint32_t irq_state = mp_hal_quiet_timing_enter(); for(t = time0;; t = time0) { diff --git a/ports/esp8266/espneopixel.h b/ports/esp8266/espneopixel.h index 6743b3b97..c444740ff 100644 --- a/ports/esp8266/espneopixel.h +++ b/ports/esp8266/espneopixel.h @@ -1,6 +1,6 @@ #ifndef MICROPY_INCLUDED_ESP8266_ESPNEOPIXEL_H #define MICROPY_INCLUDED_ESP8266_ESPNEOPIXEL_H -void esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32_t numBytes); +void esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32_t numBytes, bool is800KHz); #endif // MICROPY_INCLUDED_ESP8266_ESPNEOPIXEL_H diff --git a/ports/esp8266/etshal.h b/ports/esp8266/etshal.h index 7f6962d7a..8d6457311 100644 --- a/ports/esp8266/etshal.h +++ b/ports/esp8266/etshal.h @@ -6,12 +6,14 @@ // see http://esp8266-re.foogod.com/wiki/Random_Number_Generator #define WDEV_HWRNG ((volatile uint32_t*)0x3ff20e44) +void ets_delay_us(uint16_t us); void ets_intr_lock(void); void ets_intr_unlock(void); void ets_isr_mask(uint32_t mask); void ets_isr_unmask(uint32_t mask); void ets_isr_attach(int irq_no, void (*handler)(void *), void *arg); void ets_install_putc1(); +void uart_div_modify(uint8_t uart, uint32_t divisor); void ets_set_idle_cb(void (*handler)(void *), void *arg); void ets_timer_arm_new(os_timer_t *tim, uint32_t millis, bool repeat, bool is_milli_timer); @@ -30,6 +32,12 @@ void MD5Init(MD5_CTX *context); void MD5Update(MD5_CTX *context, const void *data, unsigned int len); void MD5Final(unsigned char digest[16], MD5_CTX *context); +// These prototypes are for recent SDKs with "malloc tracking" +void *pvPortMalloc(size_t sz, const char *fname, unsigned line); +void *pvPortZalloc(size_t sz, const char *fname, unsigned line); +void *pvPortRealloc(void *p, unsigned sz, const char *fname, unsigned line); +void vPortFree(void *p, const char *fname, unsigned line); + uint32_t SPIRead(uint32_t offset, void *buf, uint32_t len); uint32_t SPIWrite(uint32_t offset, const void *buf, uint32_t len); uint32_t SPIEraseSector(int sector); diff --git a/ports/esp8266/machine_uart.c b/ports/esp8266/machine_uart.c index 28fbfbaff..e8be5e538 100644 --- a/ports/esp8266/machine_uart.c +++ b/ports/esp8266/machine_uart.c @@ -29,7 +29,7 @@ #include <string.h> #include "ets_sys.h" -#include "espuart.h" +#include "uart.h" #include "py/runtime.h" #include "py/stream.h" diff --git a/ports/esp8266/main.c b/ports/esp8266/main.c index da41b00c9..4882bf599 100644 --- a/ports/esp8266/main.c +++ b/ports/esp8266/main.c @@ -111,25 +111,6 @@ STATIC void mp_reset(void) { readline_init0(); dupterm_task_init(); pwmout_reset(); - - // Check if there are any dupterm objects registered and if not then - // activate UART(0), or else there will never be any chance to get a REPL - size_t idx; - for (idx = 0; idx < MICROPY_PY_OS_DUPTERM; ++idx) { - if (MP_STATE_VM(dupterm_objs[idx]) != MP_OBJ_NULL) { - break; - } - } - if (idx == MICROPY_PY_OS_DUPTERM) { - mp_obj_t args[2]; - args[0] = MP_OBJ_NEW_SMALL_INT(0); - args[1] = MP_OBJ_NEW_SMALL_INT(115200); - args[0] = pyb_uart_type.make_new(&pyb_uart_type, 2, 0, args); - args[1] = MP_OBJ_NEW_SMALL_INT(1); - extern mp_obj_t os_dupterm(size_t n_args, const mp_obj_t *args); - os_dupterm(2, args); - mp_hal_stdout_tx_str("Activated UART(0) for REPL\r\n"); - } } bool soft_reset(void) { diff --git a/ports/esp8266/modesp.c b/ports/esp8266/modesp.c index ec4e73503..76aa2cc21 100644 --- a/ports/esp8266/modesp.c +++ b/ports/esp8266/modesp.c @@ -30,7 +30,7 @@ #include "py/runtime.h" #include "py/mperrno.h" #include "py/mphal.h" -#include "espuart.h" +#include "uart.h" #include "user_interface.h" #include "mem.h" #include "modmachine.h" diff --git a/ports/esp8266/modnetwork.c b/ports/esp8266/modnetwork.c index e220808b1..c7f3397c4 100644 --- a/ports/esp8266/modnetwork.c +++ b/ports/esp8266/modnetwork.c @@ -426,9 +426,9 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs } case MP_QSTR_essid: if (self->if_id == STATION_IF) { - val = mp_obj_new_str((char*)cfg.sta.ssid, strlen((char*)cfg.sta.ssid), false); + val = mp_obj_new_str((char*)cfg.sta.ssid, strlen((char*)cfg.sta.ssid)); } else { - val = mp_obj_new_str((char*)cfg.ap.ssid, cfg.ap.ssid_len, false); + val = mp_obj_new_str((char*)cfg.ap.ssid, cfg.ap.ssid_len); } break; case MP_QSTR_hidden: diff --git a/ports/esp8266/modules/inisetup.py b/ports/esp8266/modules/inisetup.py index 7aa8bd435..46f089248 100644 --- a/ports/esp8266/modules/inisetup.py +++ b/ports/esp8266/modules/inisetup.py @@ -48,8 +48,6 @@ def setup(): # This file is executed on every boot (including wake-boot from deepsleep) #import esp #esp.osdebug(None) -import uos, machine -uos.dupterm(machine.UART(0, 115200), 1) import gc #import webrepl #webrepl.start() diff --git a/ports/esp8266/modules/webrepl_setup.py b/ports/esp8266/modules/webrepl_setup.py index 00b7c89e6..e87fac99e 100644 --- a/ports/esp8266/modules/webrepl_setup.py +++ b/ports/esp8266/modules/webrepl_setup.py @@ -34,6 +34,12 @@ def exists(fname): except OSError: return False +def copy_stream(s_in, s_out): + buf = bytearray(64) + while 1: + sz = s_in.readinto(buf) + s_out.write(buf, sz) + def get_daemon_status(): with open(RC) as f: @@ -44,6 +50,10 @@ def get_daemon_status(): return True return None +def add_daemon(): + with open(RC) as old_f, open(RC + ".tmp", "w") as new_f: + new_f.write("import webrepl\nwebrepl.start()\n") + copy_stream(old_f, new_f) def change_daemon(action): LINES = ("import webrepl", "webrepl.start()") diff --git a/ports/esp8266/modutime.c b/ports/esp8266/modutime.c index 64ecefb41..ab9cb7dc2 100644 --- a/ports/esp8266/modutime.c +++ b/ports/esp8266/modutime.c @@ -75,7 +75,7 @@ STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) { }; return mp_obj_new_tuple(8, tuple); } -MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(utime_localtime_obj, 0, 1, time_localtime); +MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(time_localtime_obj, 0, 1, time_localtime); /// \function mktime() /// This is inverse function of localtime. It's argument is a full 8-tuple @@ -95,7 +95,7 @@ STATIC mp_obj_t time_mktime(mp_obj_t tuple) { mp_obj_get_int(elem[1]), mp_obj_get_int(elem[2]), mp_obj_get_int(elem[3]), mp_obj_get_int(elem[4]), mp_obj_get_int(elem[5]))); } -MP_DEFINE_CONST_FUN_OBJ_1(utime_mktime_obj, time_mktime); +MP_DEFINE_CONST_FUN_OBJ_1(time_mktime_obj, time_mktime); /// \function time() /// Returns the number of seconds, as an integer, since 1/1/2000. @@ -103,13 +103,13 @@ STATIC mp_obj_t time_time(void) { // get date and time return mp_obj_new_int(pyb_rtc_get_us_since_2000() / 1000 / 1000); } -MP_DEFINE_CONST_FUN_OBJ_0(utime_time_obj, time_time); +MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time); STATIC const mp_rom_map_elem_t time_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_utime) }, - { MP_ROM_QSTR(MP_QSTR_localtime), MP_ROM_PTR(&utime_localtime_obj) }, - { MP_ROM_QSTR(MP_QSTR_mktime), MP_ROM_PTR(&utime_mktime_obj) }, + { MP_ROM_QSTR(MP_QSTR_localtime), MP_ROM_PTR(&time_localtime_obj) }, + { MP_ROM_QSTR(MP_QSTR_mktime), MP_ROM_PTR(&time_mktime_obj) }, { MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&mp_utime_sleep_obj) }, { MP_ROM_QSTR(MP_QSTR_sleep_ms), MP_ROM_PTR(&mp_utime_sleep_ms_obj) }, { MP_ROM_QSTR(MP_QSTR_sleep_us), MP_ROM_PTR(&mp_utime_sleep_us_obj) }, @@ -118,7 +118,7 @@ STATIC const mp_rom_map_elem_t time_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_ticks_cpu), MP_ROM_PTR(&mp_utime_ticks_cpu_obj) }, { MP_ROM_QSTR(MP_QSTR_ticks_add), MP_ROM_PTR(&mp_utime_ticks_add_obj) }, { MP_ROM_QSTR(MP_QSTR_ticks_diff), MP_ROM_PTR(&mp_utime_ticks_diff_obj) }, - { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&utime_time_obj) }, + { MP_ROM_QSTR(MP_QSTR_time), MP_ROM_PTR(&time_time_obj) }, }; STATIC MP_DEFINE_CONST_DICT(time_module_globals, time_module_globals_table); diff --git a/ports/esp8266/mpconfigport.h b/ports/esp8266/mpconfigport.h index 84c18f996..eca3f525d 100644 --- a/ports/esp8266/mpconfigport.h +++ b/ports/esp8266/mpconfigport.h @@ -91,7 +91,7 @@ #define MICROPY_PY_FRAMEBUF (1) #define MICROPY_PY_MICROPYTHON_MEM_INFO (1) #define MICROPY_PY_OS_DUPTERM (2) -#define MICROPY_CPYTHON_COMPAT (0) +#define MICROPY_CPYTHON_COMPAT (1) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_FLOAT) #define MICROPY_FLOAT_HIGH_QUALITY_HASH (1) diff --git a/ports/esp8266/espuart.c b/ports/esp8266/uart.c index 557b771a3..52707f981 100644 --- a/ports/esp8266/espuart.c +++ b/ports/esp8266/uart.c @@ -11,7 +11,7 @@ *******************************************************************************/ #include "ets_sys.h" #include "osapi.h" -#include "espuart.h" +#include "uart.h" #include "osapi.h" #include "uart_register.h" #include "etshal.h" diff --git a/ports/esp8266/espuart.h b/ports/esp8266/uart.h index 684689a0e..684689a0e 100644 --- a/ports/esp8266/espuart.h +++ b/ports/esp8266/uart.h diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h index 85396e5dd..8e279e98d 100644 --- a/ports/nrf/mpconfigport.h +++ b/ports/nrf/mpconfigport.h @@ -67,10 +67,6 @@ #define MICROPY_VFS (1) #define MICROPY_VFS_FAT (MICROPY_VFS) -// TODO these should be generic, not bound to fatfs -#define mp_type_fileio fatfs_type_fileio -#define mp_type_textio fatfs_type_textio - // use vfs's functions for import stat and builtin open #if MICROPY_VFS #define mp_import_stat mp_vfs_import_stat |
