Commit Graph

807 Commits

Author SHA1 Message Date
Ayke van Laethem
2d293873a6 nrf/pin: Cleanup Pin.__str__ to print relevant information.
Code size change:
nrf51: -44
nrf52: -52
2019-01-31 17:31:58 +11:00
Ayke van Laethem
4e1c2fc831 nrf: Shrink "<peripheral> does not exist" error messages.
Code size reductions:
nrf51: -132
nrf52: -188
2019-01-31 17:26:26 +11:00
Ayke van Laethem
1ba962ff57 nrf/uart: Remove unused machine.UART() parameters.
If needed these parameters can be added back and made functional one at a
time.  It's better to explicitly not support them than to silently allow
but ignore them.
2019-01-31 17:18:23 +11:00
Ayke van Laethem
a293fa3d6d nrf/uart: Use formula instead of switch for baudrate calculation.
This saves a bit of code:
nrf51: -176
nrf52: -152
2019-01-31 17:06:59 +11:00
Paul Sokolovsky
2f5d113fad py/warning: Support categories for warnings.
Python defines warnings as belonging to categories, where category is a
warning type (descending from exception type). This is useful, as e.g.
allows to disable warnings selectively and provide user-defined warning
types.  So, implement this in MicroPython, except that categories are
represented just with strings.  However, enough hooks are left to implement
categories differently per-port (e.g. as types), without need to patch each
and every usage.
2019-01-31 16:48:30 +11:00
Damien George
86f06d6a87 stm32/sdcard: Don't use SD clock bypass on F7 MCUs.
With clock bypass enabled the attached SD card is clocked at the maximum
48MHz.  But some SD cards are unreliable at these rates.  Although it's
nice to have high speed transfers it's more important that the transfers
are reliable for all cards.  So disable this clock bypass option.
2019-01-31 12:49:48 +11:00
Damien George
e5509a910f stm32/mboot: Add option to autodetect the USB port that DFU uses.
Enable in mpconfigboard.h via #define MBOOT_USB_AUTODETECT_USB (1).
Requires MICROPY_HW_USB_FS and MICROPY_HW_USB_HS to be enabled as well.
2019-01-31 12:05:39 +11:00
Damien George
4bed17e786 stm32/boards/stm32f429_af.csv: Fix typos in UART defs Tx->TX and Rx->RX.
Fixes issue #4445.
2019-01-31 01:02:42 +11:00
Damien George
3ff3e96865 esp8266/modmachine: In lightsleep, only waiti if wifi is turned off.
Otherwise the STA interface can't do DTIM sleeping correctly and power
consumption goes up.
2019-01-31 00:05:00 +11:00
Damien George
d5d060ead9 nrf/modmachine: Rename machine.sleep to machine.lightsleep. 2019-01-30 14:15:38 +11:00
Damien George
0a954e0196 cc3200/modmachine: Rename machine.sleep to machine.lightsleep. 2019-01-30 14:15:08 +11:00
Damien George
808dc95ab8 esp8266/modmachine: Implement simple machine.lightsleep function.
Use of "waiti 0" reduces power consumption by about 3mA compared to a
time.sleep_ms call.
2019-01-30 14:05:53 +11:00
Damien George
2911e3554a esp8266/modmachine: Rename machine.sleep to machine.lightsleep.
While keeping machine.sleep as an alias for machine.lightsleep for
backwards compatibility.
2019-01-30 14:05:53 +11:00
Damien George
d7cc92383c esp8266/modmachine: Implement optional time_ms arg to machine.deepsleep. 2019-01-30 14:05:53 +11:00
Damien George
8de17b3d96 esp32/modmachine: Rename machine.sleep to machine.lightsleep.
While keeping machine.sleep as an alias for machine.lightsleep for
backwards compatibility.
2019-01-30 13:00:26 +11:00
Damien George
dadee5fa24 esp32/modsocket: Fix crashes when connect/bind can't resolve given addr.
Fixes issue #4441.
2019-01-30 12:40:50 +11:00
Damien George
38022ddb2c stm32/main: Make board-defined UART REPL use a static object and buffer.
This way the UART REPL does not need the MicroPython heap and exists
outside the MicroPython runtime, allowing characters to still be received
during a soft reset.
2019-01-28 22:56:55 +11:00
Damien George
f431795caf esp32/boards: Use auto xtal freq config instead of default 40MHz.
Auto-detection of the crystal frequency is convenient and allows for a
single binary for many different boards.  But it can be unreliable in
certain situations so in production, for a given board, it's recommended to
configure the correct fixed frequency.
2019-01-28 20:42:12 +11:00
Damien George
5d88272342 esp32/Makefile: Make sure that directory exists for sdkconfig.h. 2019-01-28 20:41:13 +11:00
Damien George
9ac9aa989c esp32/machine_timer: Deinit all active timers on soft reset.
Otherwise they will keep triggering the callback and access invalid data on
the heap.
2019-01-28 16:16:03 +11:00
Damien George
3d49b157b8 esp32: Update to latest ESP IDF using sdkconfig and new ldgen procedure.
Configuration for the build is now specified using sdkconfig rather than
sdkconfig.h, which allows for much easier configuration with defaults from
the ESP IDF automatically applied.  sdkconfig.h is generated using the new
ESP IDF kconfig_new tool written in Python.  Custom configuration for a
particular ESP32 board can be specified via the make variable SDKCONFIG.

The esp32.common.ld file is also now generated using the standard ESP IDF
ldgen.py tool.
2019-01-28 12:44:03 +11:00
Damien George
f59904f799 esp32/Makefile: Put all IDF compenents in .a libs to use IDF ld script.
When the ESP IDF builds a project it puts all separate components into
separate .a library archives.  And then the esp32.common.ld linker script
references these .a libraries by explicit name to put certain object files
in iRAM.

This patch does a similar thing for the custom build system used here,
putting all IDF .o's into their respective .a.  So a custom linker script
is no longer needed.
2019-01-28 12:41:37 +11:00
Damien George
e7ab475276 esp32: Don't put py/scheduler.o in iRAM, it's no longer needed.
ISR's no longer need to be in iRAM, and the ESP IDF provides an option to
specify that they are in iRAM if an application needs lower latency when
handling them.  But we don't use this feature for user interrupts: both
timer and gpio ISR routines are registered without the ESP_INTR_FLAG_IRAM
option, and so the scheduling code no longer needs to be in iRAM.
2019-01-27 16:15:47 +11:00
Damien George
4caf5b2358 stm32/usbdev: Add USB config option for max power drawn by the board.
The new compile-time option is MICROPY_HW_USB_MAX_POWER_MA.  Set this in
the board configuration file to the maximum current in mA that the board
will draw over USB.  The default is 500mA.
2019-01-27 14:02:10 +11:00
Damien George
7d8db42d17 stm32/usbdev: Add USB config option for board being self powered.
The new compile-time option is MICROPY_HW_USB_SELF_POWERED.  Set this
option to 1 in the board configuration file to indicate that the USB device
is self powered.  This option is disabled by default (previous behaviour).
2019-01-27 13:52:43 +11:00
Damien George
c2886868b9 stm32/rtc: Check RTCEN=1 when testing if RTC is already running on boot.
It can be that LSEON and LSERDY are set yet the RTC is not enabled (this
can happen for example when coming out of the ST DFU mode on an F405 with
the RTC not previously initialised).  In such a case the RTC is never
started because the code thinks it's already running.  This patch fixes
this case by always checking if RTCEN is set when booting up (and also
testing for a valid RTCSEL value in the case of using an LSE).
2019-01-27 13:21:31 +11:00
stijn
42863830be py: Add optional support for 2-argument version of built-in next().
Configurable via MICROPY_PY_BUILTINS_NEXT2, disabled by default.
2019-01-27 13:01:28 +11:00
Reagan Sanders
51577629b2 cc3200/mods/modussl: Fix ca_certs arg validation in mod_ssl_wrap_socket.
Commit a0d97fe408 changed the argument index
of ca_certs but missed updating one of the references to the new index.
2019-01-27 12:51:34 +11:00
Mikhail Zakharov
18723e9889 unix/mpthreadport: Remove busy wait loop in thread garbage collection.
One can't use pthread calls in a signal handler because they are not
async-signal-safe (see man signal-safety).  Instead, sem_post can be used
to post from within a signal handler and this should be more efficient than
using a busy wait loop, waiting on a volatile variable.
2019-01-27 12:40:10 +11:00
Mikhail Zakharov
1e7b422226 unix/mpthreadport: Cleanup used memory on thread exit. 2019-01-27 12:39:45 +11:00
Mikhail Zakharov
f8c1be85d1 unix/mpthreadport: Add thread deinit code to stop threads on exit.
Free unused memory for threads and cancel any outstanding threads on
interpreter exit to avoid possible segmentaiton fault.
2019-01-27 12:38:23 +11:00
Damien George
285d265eee stm32: Implement machine.lightsleep(). 2019-01-27 11:13:32 +11:00
Damien George
6d480f50ac pic16bit: Update to compile with latest xc16 v1.35 compiler.
This port has been verified to work with these latest changes.
2019-01-25 16:06:13 +11:00
Damien George
da72bb6833 esp32/machine_hw_spi: Make HW SPI objects statically allocated.
This aligns more closely with the hardware, that there are two, fixed HW
SPI peripherals.  And it allows to recreate the HW SPI objects without
error, as well as create them again after a soft reset.

Fixes issue #4103.
2019-01-23 23:47:36 +11:00
Damien George
d82f344f61 esp32/machine_hw_spi: Use separate DMA channels for HSPI and VSPI.
Otherwise only one of HSPI or VSPI can be used at a time.  Fixes
issue #4068.
2019-01-23 23:40:06 +11:00
Matt Trentini
cd52d2c691 esp32/modules/neopixel.py: Change NeoPixel to different default timings.
In order to suit the more common 800KHz by default (instead of 400KHz), and
also have the same behaviour as the esp8266 port.

Resolves #4396.

Note! This is a breaking change. Anyone that has previously used the
NeoPixel class on an ESP32 board may be affected.
2019-01-23 14:22:38 +11:00
Damien George
18d3a5df26 esp8266/esp_mphal: Provide mp_hal_pin_od_high_dht so DHT works reliably.
The original behaviour of open-drain-high was to use the open-drain mode of
the GPIO pin, and this seems to make driving a DHT more reliable.  See
issue #4233.
2019-01-22 00:26:04 +11:00
Damien George
eb446ec227 esp32/Makefile: Use system provided math library rather than uPy one.
The ESP IDF system already provides a math library, and that one is likely
to be better tuned to the Xtensa architecture.  The IDF components are also
tested against its own math library, so best not to override it.  Using the
system provided library also allows to easily switch to double-precision
floating point by changing MICROPY_FLOAT_IMPL to MICROPY_FLOAT_IMPL_DOUBLE.
2019-01-17 16:43:20 +11:00
Damien George
90f86a0197 esp32/machine_pin: Add Pin.off() and Pin.on() methods. 2019-01-16 17:33:56 +11:00
Damien George
36808d4e6a esp8266/main: Activate UART(0) on dupterm for REPL before boot.py runs.
So that the user can explicitly deactivate UART(0) if needed.  See
issue #4314.

This introduces some risk to "brick" the device, if the user disables the
REPL without providing an alternative REPL (eg WebREPL), or any way to
reenable it.  In such a case the device needs to be erased and
reprogrammed.  This seems unavoidable, given the desire to have the option
to use the UART for something other than the REPL.
2019-01-16 17:24:23 +11:00
Damien George
3431ea7205 stm32/main: Make thread and FS state static and exclude when not needed.
Without the static qualifier these objects will be kept by the linker even
if they are unused.  So this patch saves some RAM when these features are
unused by a board.
2019-01-11 01:52:17 +11:00
Damien George
5b66c7b712 stm32/wdt: Make singleton WDT object const so it goes in ROM. 2019-01-11 01:51:57 +11:00
Damien George
f350b640a0 esp32/modsocket: For socket read only release GIL if socket would block.
If there are many short reads to a socket in a row (eg by readline) then
releasing and acquiring the GIL each time will give very poor throughput.
So first poll the socket to see if it has data, and if it does then don't
release the GIL.
2019-01-10 15:46:44 +11:00
Damien George
efe0569c26 esp32/mphalport: When tx'ing to REPL only release GIL if many chars sent
Otherwise, if multiple threads are active, printing data to the REPL may be
very slow because in some cases only one character is output per call to
mp_hal_stdout_tx_strn.
2019-01-10 15:43:47 +11:00
Damien George
b33f108cde stm32/sdcard: Properly reset SD periph when SDMMC2 is used on H7 MCUs. 2018-12-30 01:28:34 +11:00
roland
4d8504425a stm32/modmachine: Fix reset_cause to correctly give DEEPSLEEP on L4 MCU.
Before this fix it returned SOFT_RESET after waking from a deepsleep
(standby).
2018-12-30 01:11:25 +11:00
Damien George
f334816df0 stm32/uart: Make sure user IRQs are handled even with a keyboard intr. 2018-12-30 01:03:22 +11:00
Damien George
7bdbea9a0c stm32/uart: Clear overrun error flag after reading RX data register.
On MCUs other than F4 the ORE (overrun error) flag needs to be cleared
independently of clearing RXNE, even though both are wired to trigger the
same RXNE IRQ.  In the case that an overrun occurred it's necessary to
explicitly clear the ORE flag or else the RXNE interrupt will keep firing.
2018-12-30 00:59:16 +11:00
Damien George
0d860fdcd0 stm32/uart: Always enable global UART IRQ handler on init.
Otherwise IRQs may not be enabled for the user UART.irq() handler.  In
particular this fixes the user IRQ_RXIDLE interrupt so that it triggers
even when there is no RX buffer.
2018-12-29 22:44:41 +11:00
Damien George
a5f7a3022d stm32/uart: Fix uart_rx_any in case of no buffer to return 0 or 1. 2018-12-29 22:43:35 +11:00