Wykres commitów

290 Commity (fdfe4eca745dce5f20fb65a3c197006b9053999a)

Autor SHA1 Wiadomość Data
Damien George badd351150 lib/timeutils: Add helper functions to deal with nanosecs since 1970.
Signed-off-by: Damien George <damien@micropython.org>
2020-08-22 15:41:10 +10:00
Damien George d9b7261024 lib/libc: Fix string0's implementation of strncpy.
Fixing 98e583430f, the semantics of strncpy
require that the remainder of dst be filled with null bytes.

Signed-off-by: Damien George <damien@micropython.org>
2020-07-22 16:29:54 +10:00
Zoltán Vörös 27767aafa2 lib/libm_dbl: Add round.c source code.
This code is imported from musl, to match existing code in libm_dbl.

The file is also added to the build in stm32/Makefile.  It's not needed by
the core code but, similar to c5cc64175b,
allows round() to be used by user C modules or board extensions.
2020-07-21 11:07:19 +10:00
Damien George f80b1d8535 lib/stm32lib: Update library for H7 v1.6.0 and WB v1.6.0.
Changes in this new library version are:
- Update H7 HAL to v1.6.0.
- Update WB HAL to v1.6.0.
- Add patches to fix F4 ll_uart clock selection for UART9/UART10.

Signed-off-by: Damien George <damien@micropython.org>
2020-07-21 01:02:58 +10:00
Thorsten von Eicken 3e758ef235 lib/mbedtls_errors: Add code to patch mbedtls for shortened error strs.
The file `mbedtls_errors/mp_mbedtls_errors.c` can be used instead of
`mbedtls/library/error.c` to give shorter error strings, reducing the build
size of the error strings from about 12-16kB down to about 2-5kB.
2020-07-20 23:53:27 +10:00
Thorsten von Eicken 98e583430f lib/libc: Add implementation of strncpy. 2020-07-20 23:42:04 +10:00
Damien George 9d5edb3559 lib/utils: Protect all of mpirq.c with MICROPY_ENABLE_SCHEDULER.
So it can be unconditionally included in a port's build even if certain
configurations in that port do not use its features, to simplify the
Makefile.

Signed-off-by: Damien George <damien@micropython.org>
2020-06-30 22:31:41 +10:00
David Lechner 77ed6f69ac tools/uncrustify: Enable more opts to remove space between func and '('.
With only `sp_func_proto_paren = remove` set there are some cases where
uncrustify misses removing a space between the function name and the
opening '('.  This sets all of the related options to `force` as well.
2020-06-19 22:07:32 +10:00
Damien George b2030e1661 lib/utils/pyexec: Add missing MP_ERROR_TEXT when compiler disabled. 2020-06-02 15:43:44 +10:00
Damien George 4bbba3060d lib/utils: Lock the scheduler when executing hard callback functions.
Otherwise scheduled functions may execute during the hard callback and then
fail if they try to allocate heap memory.
2020-05-27 17:53:31 +10:00
Damien George 9ee5aff334 lib/nrfx: Upgrade to nrfx v2.0.0. 2020-05-15 15:06:02 +10:00
Jim Mussared 710426024a all: Factor gchelper code to one place and use it for unix & ARM ports.
No functionality change is intended with this commit, it just consolidates
the separate implementations of GC helper code to the lib/utils/ directory
as a general set of helper functions useful for any port.  This reduces
duplication of code, and makes it easier for future ports or embedders to
get the GC implementation correct.

Ports should now link against gchelper_native.c and either gchelper_m0.s or
gchelper_m3.s (currently only Cortex-M is supported but other architectures
can follow), or use the fallback gchelper_generic.c which will work on
x86/x64/ARM.

The gc_helper_get_sp function from gchelper_m3.s is not really GC related
and was only used by cc3200, so it has been moved to that port and renamed
to cortex_m3_get_sp.
2020-04-29 23:45:19 +10:00
Jim Mussared c37fd78071 lib/btstack: Update to c8b9823 for USB HCI reset timeout fix. 2020-04-29 16:54:12 +10:00
Damien George e08ca78f40 py/stream: Remove mp_stream_errno and use system errno instead.
This change is made for two reasons:

1. A 3rd-party library (eg berkeley-db-1.xx, axtls) may use the system
   provided errno for certain errors, and yet MicroPython stream objects
   that it calls will be using the internal mp_stream_errno.  So if the
   library returns an error it is not known whether the corresponding errno
   code is stored in the system errno or mp_stream_errno.  Using the system
   errno in all cases (eg in the mp_stream_posix_XXX wrappers) fixes this
   ambiguity.

2. For systems that have threading the system-provided errno should always
   be used because the errno value is thread-local.

For systems that do not have an errno, the new lib/embed/__errno.c file is
provided.
2020-04-27 23:58:46 +10:00
Jim Mussared 0dceab0ddf lib/mynewt-nimble: Update submodule to NimBLE release 1.3.0. 2020-04-27 22:50:42 +10:00
stijn 84fa3312cf all: Format code to add space after C++-style comment start.
Note: the uncrustify configuration is explicitly set to 'add' instead of
'force' in order not to alter the comments which use extra spaces after //
as a means of indenting text for clarity.
2020-04-23 11:24:25 +10:00
stijn d6243568a0 all: Remove commented-out include statements. 2020-04-23 11:24:15 +10:00
stijn 70affd9ba2 all: Fix implicit floating point to integer conversions.
These are found when building with -Wfloat-conversion.
2020-04-18 22:42:24 +10:00
stijn bcf01d1686 all: Fix implicit conversion from double to float.
These are found when building with -Wfloat-conversion.
2020-04-18 22:42:24 +10:00
Damien George 7a07e71915 lib/littlefs: Update littlefs2 to v2.2.0.
At commit a049f1318eecbe502549f9d74a41951985fb956f
2020-04-09 15:59:28 +10:00
Damien George fa285be9d7 lib/btstack: Update to latest master btstack commit. 2020-04-07 13:46:56 +10:00
Jim Mussared def76fe4d9 all: Use MP_ERROR_TEXT for all error messages. 2020-04-05 15:02:06 +10:00
Jim Mussared f46782dde9 mimxrt: Add new, minimal port to NXP i.MX RT series CPUs.
This is an extremely minimal port to the NXP i.MX RT, in the style of the
SAMD port  It's largely based on the TinyUSB mimxrt implementation, using
the NXP SDK.  It currently supports the Teensy 4.0 board with a REPL over
the USB-VCP interface.

This commit also adds the NXP SDK submodule (also from TinyUSB) to
lib/nxp_driver.

Note: if you already have the tinyusb submodule initialized recursively you
will need to run the following as the tinyusb sub-submodules have been
rearranged (upstream):

    git submodule deinit lib/tinyusb
    rm -rf .git/modules/lib/tinyusb
    git submodule update --init lib/tinyusb
2020-03-11 15:34:13 +11:00
Jim Mussared 6cea369b89 lib/tinyusb: Update to a6b916ba for i.MX support. 2020-03-11 15:32:55 +11:00
Damien George d35fefe30a lib: Add BlueKitchen BTstack submodule. 2020-03-10 01:53:42 +11:00
Damien George 69661f3343 all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-28 10:33:03 +11:00
Damien George abe2caf6df py/scheduler: Move clearing of kbd traceback to mp_keyboard_interrupt.
This is a more logical place to clear the KeyboardInterrupt traceback,
right before it is set as a pending exception.  The clearing is also
optimised from a function call to a simple store of NULL.
2020-02-07 16:08:31 +11:00
Damien George 9efb36bfa6 py/scheduler: Move mp_keyboard_interrupt from lib/utils to py core.
This function is tightly coupled to the state and behaviour of the
scheduler, and is a core part of the runtime: to schedule a pending
exception.  So move it there.
2020-02-07 16:08:26 +11:00
Damien George 5a91cd9ff3 lib/utils/pyexec: Handle pending exceptions after disabling kbd intrs.
Pending exceptions would otherwise be handled later on where there may not
be an NLR handler in place.

A similar fix is also made to the unix port's REPL handler.

Fixes issues #4921 and #5488.
2020-02-07 16:08:26 +11:00
odewdney b51a2c266a lib/utils: Change default value of pyexec_mode_kind to 0 to put in bss.
By simply reordering the enums for pyexec_mode_kind_t it eliminates a data
variable which costs ROM to initialise it.  And the minimal build now has
nothing in the data section.

It seems the compiler is smart enough so that the generated code for
if-logic which tests these enum values is unchanged.
2020-02-04 18:10:26 +11:00
Yonatan Goldschmidt 853aaa06f2 lib/mp-readline: Add word-based move/delete EMACS key sequences.
This commit adds backward-word, backward-kill-word, forward-word,
forward-kill-word sequences for the REPL, with bindings to Alt+F, Alt+B,
Alt+D and Alt+Backspace respectively.  It is disabled by default and can be
enabled via MICROPY_REPL_EMACS_WORDS_MOVE.

Further enabling MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE adds extra bindings
for these new sequences: Ctrl+Right, Ctrl+Left and Ctrl+W.

The features are enabled on unix micropython-coverage and micropython-dev.
2020-01-12 13:09:27 +11:00
Yonatan Goldschmidt dce590c29d lib/mp-readline: Add an assert() to catch buffer overflows.
During readline development, this function may receive bad `pos` values.
It's easier to understand the assert() failing error than to have a "stack
smashing detected" message.
2020-01-12 13:09:23 +11:00
Yonatan Goldschmidt 61d2b40ad5 lib/utils/pyexec: Introduce MICROPY_REPL_INFO, wrap debug prints in it.
For the 3 ports that already make use of this feature (stm32, nrf and
teensy) this doesn't make any difference, it just allows to disable it from
now on.

For other ports that use pyexec, this decreases code size because the debug
printing code is dead (it can't be enabled) but the compiler can't deduce
that, so code is still emitted.
2019-12-28 00:05:39 +11:00
Damien George 09376f0e47 py: Introduce MP_ROM_NONE macro for ROM to refer to None object.
This helps to prevent mistakes, and allows easily changing the ROM value of
None if needed.
2019-12-27 22:51:17 +11:00
David Lechner 1605c7e584 Revert "lib/tinytest: Clean up test reporting in the presence of std..."
This reverts commit f4ed2dfa94.

This lets tinytest work as it was originally designed.  An alternate
solution for the reverted commit will be implemented in a future commit.
2019-12-19 17:53:46 +11:00
Damien George 4e1b03d45c lib/libc/string0: Add simple implementations of strspn and strcspn.
They are needed for littlefs.
2019-10-30 12:14:52 +11:00
Damien George 22bfc47977 lib/littlefs: Add README describing origin and how to gen lfs1/lfs2. 2019-10-29 12:55:34 +11:00
Damien George 2e66d83ca4 lib/littlefs: Add littlefs v2.1.3 source. 2019-10-29 12:55:34 +11:00
Damien George 669d1d20ab lib/littlefs: Add littlefs v1.7.2 source. 2019-10-29 12:55:34 +11:00
Jim Mussared 580a2656d1 stm32: Use hardware double sqrt on F7/H7 MCUs.
Identical to cd527bb324 but for doubles.
This gives a -2.754% improvement on bm_float.py, and -35% improvement on
calling sqrt in a loop.
2019-10-10 17:39:32 +11:00
Damien George 21507a6f62 lib/mynewt-nimble: Add Apache mynewt nimble as a submodule.
Tag nimble_1_1_0_tag.
2019-10-01 09:51:02 +10:00
Damien George af20c2ead3 py: Add global default_emit_opt variable to make emit kind persistent.
mp_compile no longer takes an emit_opt argument, rather this setting is now
provided by the global default_emit_opt variable.

Now, when -X emit=native is passed as a command-line option, the emitter
will be set for all compiled modules (included imports), not just the
top-level script.

In the future there could be a way to also set this variable from a script.

Fixes issue #4267.
2019-08-28 12:47:58 +10:00
Damien George 1b79484ee3 lib/lwip: Update lwIP to v2.1.2, tag STABLE-2_1_2_RELEASE. 2019-07-04 10:36:23 +10:00
Damien George 9083166c4f lib/stm32lib: Update library for updated H7xx, new L0xx, new WBxx.
And this library now includes the startup_stm32*.s files for each MCU.
2019-07-03 23:36:43 +10:00
Damien George 258d10862d lib: Add tinyusb as a submodule. 2019-07-01 17:18:44 +10:00
Damien George 875af757bd lib: Add asf4 as a submodule. 2019-07-01 17:18:44 +10:00
Damien George b7da67cdaa lib/utils/sys_stdio_mphal: Add support to poll sys.stdin and sys.stdout.
A port must provide the following function for this to work:

    uintptr_t mp_hal_stdio_poll(uintptr_t poll_flags);
2019-07-01 17:10:12 +10:00
Damien George 399417adba lib: Add new submodule for mbedtls, currently at v2.17.0.
From upstream source: https://github.com/ARMmbed/mbedtls.git
2019-06-05 15:21:40 +10:00
Damien George 1043f1a047 lib/netutils: Add DHCP server component. 2019-06-03 14:57:50 +10:00
Damien George 0a6c479187 lib/cmsis: Upgrade to CMSIS 5.5.1.
From https://github.com/ARM-software/CMSIS_5.git, tag 5.5.1
2019-06-03 14:40:57 +10:00
Glenn Ruben Bakke 85bde0889d lib/nrfx: Upgrade nrfx to master.
Updating the nrfx git submodule containing HAL drivers for nrf-port
from v1.3.1 to current master. The version pointed to is one commit
ahead of v1.7.1 release. The extra commit contains a bugfix for
nrfx_uart_tx_in_progress() making it report correctly.

The general upgrade of nrfx is considered to be safe, as almost all
changes in between 1.3.1 and 1.7.1 are related to peripherals and
target devices not used by the nrf-port as of today.
2019-05-21 17:45:01 +02:00
Damien George 1b3c1f9e6b lib/stm32lib: Update library to fix UART9/10 baudrate on F4 MCUs. 2019-05-20 15:16:14 +10:00
Damien George 2459162599 lib/utils/interrupt_char: Invalidate interrupt char at start up.
Otherwise mp_interrupt_char will have a value of zero on start up (because
it's in the BSS) and a KeyboardInterrupt may be raised during start up.
For example this can occur if there is a UART attached to the REPL which
sends spurious null bytes when the device turns on.
2019-05-01 12:41:07 +10:00
Andrew Leech 859596ce25 lib/utils: Make pyexec_file_if_exists run frozen scripts if they exist.
So that boot.py and/or main.py can be frozen (either as STR or MPY) in the
same way that other scripts are frozen.  Frozen scripts have preference to
scripts in the VFS.
2019-05-01 11:27:51 +10:00
Damien George 06a532c227 lib/utils/pyexec: Add pyexec_file_if_exists() helper function.
It will only execute the script if it can be stat'd and is a file.
2019-04-26 15:21:09 +10:00
Damien George ca5f8975fa lib/stm32lib: Update library to fix F7 MMC capacity calculation. 2019-04-01 17:04:43 +11:00
Damien George 350dbb89e6 lib/oofatfs: Update oofatfs library to fix issue with logic not.
From https://github.com/micropython/oofatfs, branch work-R0.13c,
commit 3b4ee5a646af2769b3dddfe17d5d866233c1e45b.
2019-03-07 15:03:09 +11:00
Damien George 7eadcaa8c6 lib/oofatfs: Update ffconf.h config for new oofatfs version. 2019-03-05 15:56:39 +11:00
Damien George 1a24bac6cb lib/oofatfs: Update oofatfs library to R0.13c working branch.
From https://github.com/micropython/oofatfs, branch work-R0.13c,
commit cb05c9486d3b48ffd6bd7542d8dbbab4b1caf790.

Large code pages (932, 936, 949, 950) have been removed from ffunicode.c
because they were not included in previous versions here.
2019-03-05 15:56:39 +11:00
Damien George b6791ffbbe lib/netutils: Add function to print tracing info for Ethernet frames. 2019-02-26 23:32:19 +11:00
Mike Causer 812969d615 all: Change PYB message prefix to MPY.
Replaces "PYB: soft reboot" with "MPY: soft reboot", etc.

Having a consistent prefix across ports reduces the difference between
ports, which is a general goal.  And this change won't break pyboard.py
because that tool only looks for "soft reboot".
2019-02-12 15:18:33 +11:00
Damien George 8d1275ec0f lib/utils/gchelper: Add gchelper.h header file for assembler functions. 2019-02-12 14:37:41 +11:00
Damien George f608f54ab0 lib/utils/gchelper_m3: Add gc_helper_get_sp() function. 2019-02-12 14:37:01 +11:00
Damien George 90e1303b2d lib/utils/gchelper_m3: Add license header and clean up code.
This file generates the same code with the cortex-m3 and cortex-m4
assembler directive, so use cortex-m3 to support more CPUs.
2019-02-12 14:16:24 +11:00
Damien George e6d97e8a0b stm32: Move gchelper assembler code to lib/utils for use by other ports. 2019-02-12 14:11:21 +11:00
Damien George 7bbde67cb2 lib/utils/printf: Exclude __GI_vsnprintf alias for gcc 9 and above.
See issue #4457.
2019-02-06 01:12:51 +11:00
Damien George 8faf17b93c lib/nrfx: Upgrade to nrfx v1.3.1. 2019-01-31 17:38:13 +11:00
Damien George 1fa8f977f5 lib/utils/pyexec: Implement paste mode with event driven REPL. 2019-01-28 23:00:19 +11:00
Damien George f874e8184c lib/stm32lib: Update library to get F413 BOR defs and fix gcc 8 warning. 2019-01-24 11:33:59 +11:00
Tobias Badertscher 06236bf28e lib/utils: Add generic MicroPython IRQ helper functions.
Initial implementation of this is taken from the cc3200 port.
2018-12-29 17:08:55 +11:00
Damien George f5d46a88aa lib/utils/pyexec: Forcefully unlock the heap if locked and REPL active.
Otherwise there is really nothing that can be done, it can't be unlocked by
the user because there is no way to allocate memory to execute the unlock.

See issue #4205 and #4209.
2018-10-13 16:21:08 +11:00
Damien George 8960a28238 lib/libm/math: Add implementation of __signbitf, if needed by a port. 2018-09-27 15:21:04 +10:00
Damien George 4c08932e73 lib/libm/math: Fix int type in float union, uint64_t should be uint32_t.
A float is 32-bits wide.
2018-09-27 15:19:53 +10:00
Damien George 5f92756c2c lib/stm32lib: Update library to fix issue with filling USB TX FIFO. 2018-09-26 12:00:25 +10:00
Andrew Leech 57a73973ad lib/libm_dbl: Add implementation of copysign() for DEBUG builds.
This provides a double variant of the float copysignf from libm/math.c
which is required for DEBUG=1 builds when MICROPY_FLOAT_IMPL=double
2018-09-20 16:46:19 +10:00
Damien George b9a133e5ad lib/libm/wf_tgamma: Fix tgammaf handling of -inf, should return nan. 2018-09-04 17:00:35 +10:00
Damien George afc7ddca31 lib/libm/math: Make tanhf more efficient and handle large numbers.
Prior to this patch tanhf(large number) would return nan due to inf/inf.
2018-09-04 17:00:30 +10:00
Damien George 0b239d458c lib/libm_dbl/tanh: Make tanh more efficient and handle large numbers.
Prior to this patch tanh(large number) would return nan due to inf/inf.
2018-09-04 16:57:46 +10:00
Damien George da2d2b6d88 py/mpconfig.h: Introduce MICROPY_DEBUG_PRINTER for debugging output.
This patch in effect renames MICROPY_DEBUG_PRINTER_DEST to
MICROPY_DEBUG_PRINTER, moving its default definition from
lib/utils/printf.c to py/mpconfig.h to make it official and documented, and
makes this macro a pointer rather than the actual mp_print_t struct.  This
is done to get consistency with MICROPY_ERROR_PRINTER, and provide this
macro for use outside just lib/utils/printf.c.

Ports are updated to use the new macro name.
2018-08-02 14:04:44 +10:00
Glenn Ruben Bakke ab815788da nrf: Upgrade to nrfx 1.1.0 2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke b7ce2f1460 nrf: Add support for reading output pin state
Current adoption on top of nrfx only reads the GPIO->IN register.
In order to read back an output state, nrf_gpio_pin_out_read has
to be called.

This patch concatinate the two read functions such that, if
either IN or OUT register has a value 1 it will return this,
else 0.

Updating lib/nrfx submodule to latest version of master to get
the new GPIO API to read pin direction.
(nrfx: d37b16f2b894b0928395f6f56ca741287a31a244)
2018-07-18 17:12:26 +10:00
glennrub 002f7d1ad7 nrf: Replace custom-HAL with nrfx-HAL
Summarized this squashed PR replaces the hal/ folder in the port. This has been replaced the official
HAL layer from Nordic Semiconductor; https://github.com/NordicSemiconductor/nrfx.

A Git submodule has been added under lib/nrfx, for the nrfx dependency.

The drivers / modules has been updated to use this new HAL layer; nrfx at v1.0.0.

Also, header files and system files for nrf51/nrf52x chip variants has been deleted from the device/ folder, only keeping back the startup files written in C. All other files are now fetched from nrfx.

3 new header files in the ports/nrf/ folder has been added to configure nrfx (nrfx_config.h), logging (nrfx_log.h) and glue nrfx together with the drivers and modules from micropython (nrfx_glue.h).

The PR has been a joint effort from @aykevl (Ayke van Laethem) and @glennrub.

For reference, the commit log will be kept to get an overview of the changes done:

* ports/nrf: Initial commit for moving hal to Nordic Semiconductor BSD-3 licensed nrfx-hal.

* ports/nrf: Adding nrfx, Nordic Semiconductor BSD-3 hal layer, as git submodule checked out at lib/nrfx.

* ports/nrf/modules/machine/uart: Fixing bug which set hwfc to parity excluded, always resulting in no flow control, hence corrupted output. Also adding an extra loop on uart_tx_char to prevent any tx when any ongoing tx is in progress.

* ports/nrf/i2c: Moving I2C over to nrfx driver.

* ports/nrf/modules/machine/i2c: Alignment. Renaming print function param 'o' to 'self_in'

* ports/nrf/spi: Updating SPI machine module to use nrfx drivers.

* ports/nrf: Renaming modules/machine/rtc.c/.h to rtcounter.c/.h to not confuse the peripheral with Real-Time Clock:

* ports/nrf: Updating various files after renaming machine module RTC to RTCounter.

* ports/nrf: Renaming RTC to RTCounter in modmachine globals dict table. Also updating object type name to reflect new module name.

* ports/nrf: Fixing leftovers after renaming rtc to rtcounter.

* ports/nrf: Early untested adoption of nrfx_rtc in RTCounter. Untested.

* nrf/modules/machine/i2c: Improve keyword argument handling

* ports/nrf/modules/temp: Updating Temp machine module to use nrfx defined hal nrf_temp.h. Moving logic of BLE stack awareness to machine module.

* ports/nrf/boards/pca10040: Enable machine Temp module.

* nrf/modules/machine/rtcounter: Remove magic constants.

* ports/nrf: Adding base support for nrfx module logging. Adding option to disable logging of UART as it might log its own setup over UART while the peripheral is not yet set up. Logging of UART could make sense if other transport of log is used.

* ports/nrf: updating nrfx_log.h with more correct parenthisis on macro grouping.

* ports/nrf: Updating nrfx logging with configuration to disable logging of UART module. The pattern can be used to turn off other modules as well. However, for now UART is the only module locking itself by logging before the peripheral is configured. Logging is turned off by default, can be enabled in nrfx_config.h by setting NRFX_LOG_ENABLED=1.

* ports/nrf/modules/random: Updating modrandom to use nrfx hal for rng. Not using nrfx-driver for this peripheral as its blocking mode would do the trick on RNG. Moving softdevice aware code from legacy hal to modrandom.c.

* nrf: Enable Peripheral Resource Sharing.

This enables TWI and SPI to be enabled at the same time.

* nrf/Makefile: Define MCU sub variant (e.g. NRF51822/NRF51422)

* nrf: Port TIMER peripheral to nrfx HAL.

* nrf/modules/machine/uart: Optimize UART module

For a nRF51, this results in a size reduction of:
.text: -68 bytes
.data: -56 bytes

* nrf/modules/machine/uart: Don't use magic index numbers.

* nrf/modules/machine/uart: Fix off-by-one error.

For nrf51:
.text: -40 bytes

* nrf/modules/machine/rtcounter: Update for nrfx HAL.

* nrf/modules/machine/i2c: Reduce RAM consumption.

Reductions for the nrf51:
flash: -108 bytes
RAM:   -72 bytes

* nrf/mpconfigport: Avoid unnecessary root pointers.

This saves 92 bytes of RAM.

* nrf: Support SoftDevice with nrfx HAL.

* nrf: Add NVMC peripheral (microbitfs) support.

There is no support yet for a SoftDevice.

It also fixes a potentially serious bug in start_index generation.

* nrf/modules/machine/spi: Optimize SPI peripheral.

nrf51:
text: -340 bytes
data: -72  bytes

nrf52:
text: -352 bytes
data: -108 bytes

* nrf/modules/random: Forgot to commit header file.

* nrf: Make nrfx_config.h universal for all boards.

* nrf: Use SoftDevice API for flash access when built for SD

* nrf/drivers/bluetooth: Remove legacy HAL driver includes.

These were not used anymore so can be removed.

* ports/nrf/microbit: Port microbit targets to nrfx HAL

Initial port of microbit modules to use nrfx HAL layer.
Tested display/image and modmusic on micro:bit to verify that
softpwm and ticker for nrf51 is working as expected.

Changing IRQ priority on timer to priority 2, as 1 might collide if
used side by side of SD110 BLE stack.

The patch reserves Timer1 peripheral compile time. This is not ideal
and should be resolved in seperate task.

* nrf/boards/microbit: Remove custom nrfx_config.h from microbit target, adding disablement of timer1 if softpwm is enabled.

* nrf/adc: Update ADC module to use nrfx

* nrf/modules/machine/pwm: Updating machine PWM module to use nrfx HAL driver.

examples/nrf52_pwm.py and examples/nrf52_servo.py tested on pca10040.

* nrf: Removing hal folder and boards nrf5x_hal_conf.h headers.

* nrf/nrfx_glue: Adding direct NVIC access for S110 BLE stack

If SoftDevice s110 has not yet been initialized, the IRQ will not be forwarded to
the application using the sd_nvic* function calls. Hence, direct access to cmsi
nvic functions are used instead if SoftDevice is not enabled.

* nrf/drivers/ticker: Setting IRQ priority 3 on Timer1

SoftDevice fails to initilize if Timer1 has been configured to priority
level 2 before enabling the SD. The timer is set to priority 1, higher than BLE
stack in order to provide better quality of music rendering when used with the
music module. This might be too high, time will show.

* nrf/examples: Updating ubluepy_temp after moving RTCounter to nrfx.

* nrf: delete duplicate files from device folder which can be located in nrfx/mdk.

* nrf/Makefile: Fetch system files from nrfx.

Testing on each device sub-variant to figure out which system file to
use. Reason for this is that nrf52.c is actually defining nrf52832.

Removing NRF_DEFINES parameter setting the device in use into the
same sub-variant test, as NRF52 is unique to nrf52832 when using nrfx.
Without this exclusion of -DNRF52 in compilation for nrf52840, the
device will be interpreted as a nrf52, hence nrf52832.

Also, changing name on variable SRC_NRF_HAL to SRC_NRFX_HAL to
explicitly tell the origin of the file.

* nrf: Updating device #ifdefs to be more open to non-nrf51 targets.

* nrf/modules/machine/uart: Removing second instance of UART for nrf52840 as it only has one non-DMA variant.

* nrf/device: Removing system files as these are now used from nrfx/mdk

* nrf: Moving startup files in device one level up as there is no need for deep hierarchy.

* nrf: Use NRF52_SERIES defined in nrfx/mdk/nrf.h as define value when testing for both nrf52(832) and nrf52840 variants.

* nrf/modules/machine/uart: Enable UART RX by default

Enable rx by default after intiialization of the peripheral.
Else, the nrfx driver will re-enable rx for each byte read
on uart REPL, clearing the EVENT_RXDRDY before second byte,
which again will make second byte get lost and read will get stuck.

This happens if the bytes are transmitted nrf(51) while still
processing the previous byte. Not seen on nrf52, but should
also become an issue at higher speeds.

This patch sets rx to always be enabled. Hence, not clearing the event
between read bytes, and it will be able to detect next byte recieved
upon finishing the first.

* nrf/modules/machine/timer: Fixing defines excluding Timer1 if ticker/softpwm is used.

* nrf: Switching import form mpconfigboard.h to mpconfigport.h in nrfx_config.h as mpconfigboard.h might define default values for defines not set by board specific header.

* nrf/modules/machine/i2c: nrfx integration fixes

Increasing speed to 400K.

Returning Address NACK's as MP error code; MP_ENODEV.

Returning MP_ETIMEOUT on all other error codes from TWI nrfx driver
except the ANACK.

Enabling and disabling the TWI peripheral before and after each transaction.

* nrf/examples: Updating ssd1306_mod.py to split framebuffer transfer into multiple chunks

* nrf/modules/machine/i2c: Return MP_EIO error if Data NACK occurs.

* nrf: Addressing review comments.

* nrf: Updating git submodule and users to nrfx v1.0.0.

* nrf/modules/machine/adc: Update adc module to follow v1.0.0 nrfx API.

* nrf/modules/machine/spi: Implement init and deinit functions

Extending SPI objects with a config member such that
configuration can be kept between new() and init().

Moving initialization done in new() to common init
function shared between the module functions.

If SPI is already configured, the SPI peripheral will
be uninitialized before initalized again.

Adding logic to handle initialization of polarity and
phase. As well, updating default speed to 1M from 500K.

* nrf/modules/machine: Removing unused nrfx includes in machine module header files
2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke 8a4a05c1ee lib/utils: Expose pyb_set_repl_info function public
The patch enables the possibility to disable or initialize the repl
info from outside of the module. Can also be used to initialize the
repl_display_debugging_info in pyexec.c if not startup file is clearing
.bss segment.
2018-07-18 17:12:25 +10:00
Damien George b2b06450e3 lib/utils: Fix to support compiling with object representation D. 2018-07-08 23:13:37 +10:00
stijn 8ad30fa433 lib/utils/printf: Make DEBUG_printf implementation more accessible.
The definition of DEBUG_printf doesn't depend on
MICROPY_USE_INTERNAL_PRINTF so move it out of that preprocessor
block and compile it conditionally just depending on the
MICROPY_DEBUG_PRINTERS macro. This allows a port to use DEBUG_printf
while providing it's own printf definition.
2018-07-05 19:44:18 +10:00
Damien George 191e2cf90a lib/stm32lib: Update library to include support for STM32F0 MCUs.
Now points to branch: work-F0-1.9.0+F4-1.16.0+F7-1.7.0+H7-1.2.0+L4-1.8.1
2018-05-28 21:46:20 +10:00
Damien George 7d7b9cd5df lib/lwip: Update lwIP to v2.0.3, tag STABLE-2_0_3_RELEASE. 2018-05-17 13:11:31 +10:00
Damien George 23f07b77e5 lib/stm32lib: Update library for fix to H7 SPI strict aliasing error. 2018-03-25 23:58:56 +11:00
Damien George e22ef277b8 lib/stm32lib: Update library to include support for STM32H7 MCUs.
Now points to the branch: work-F4-1.16.0+F7-1.7.0+H7-1.2.0+L4-1.8.1
2018-03-09 14:31:34 +11:00
Damien George d9b9fbc41a lib/utils/pyexec: Update to work with new MICROPY_HW_ENABLE_USB option. 2018-02-13 18:56:12 +11:00
Damien George 925c5b1da2 lib/utils/pyexec.h: Include py/obj.h because its decls are needed. 2018-01-31 18:21:07 +11:00
Paul Sokolovsky f4ed2dfa94 lib/tinytest: Clean up test reporting in the presence of stdout output.
tinytest is written with the idea that tests won't write to stdout, so it
prints test name witjout newline, then executes test, then writes status.
But MicroPython tests write to stdout, so the test output becomes a mess.
So, instead print it like:

    # starting basics/andor.py
    ... test output ...
    basics/andor.py: OK
2017-12-15 19:41:08 +02:00
Paul Sokolovsky 140bbced6f lib/upytesthelper: MicroPython test helper layer on top of tinytest.
Tinytest is classical assert-style framework, but MicroPython tests work
in different way - they produce content, and that content should be matched
against expected one to see if test passes. upytesthelper exactly adds
helper functions to make that possible.
2017-12-13 09:07:51 +02:00
Paul Sokolovsky e9d29c9ba9 lib/tinytest: Move from tools/tinytest.
Tinytest library was misplaced under tools/. By convention, any target
libraries belong to lib/, while tools/ contains host-side tools.
2017-12-08 19:26:15 +02:00
Damien George 4601759bf5 py/objstr: Remove "make_qstr_if_not_already" arg from mp_obj_new_str.
This patch simplifies the str creation API to favour the common case of
creating a str object that is not forced to be interned.  To force
interning of a new str the new mp_obj_new_str_via_qstr function is added,
and should only be used if warranted.

Apart from simplifying the mp_obj_new_str function (and making it have the
same signature as mp_obj_new_bytes), this patch also reduces code size by a
bit (-16 bytes for bare-arm and roughly -40 bytes on the bare-metal archs).
2017-11-16 13:17:51 +11:00
Paul Sokolovsky 99bf5448bd axtls: Update, exposes AES functions to implement ECB chiper mode. 2017-11-05 11:37:05 +02:00
Paul Sokolovsky 8f9af63c20 lib/axtls: Update, support for SSL_EAGAIN return code.
A step towards implementing non-blocking stream support for SSL.
2017-10-29 19:53:59 +02:00
Damien George 81a06d2c9c lib/libm: Remove implementation of log2f, use MP_NEED_LOG2 instead. 2017-10-10 16:01:13 +11:00
Damien George f869d6b2e3 lib/libm: Fix tanhf so that it correctly handles +/- infinity args. 2017-10-04 21:14:00 +11:00
Damien George a3dc1b1957 all: Remove inclusion of internal py header files.
Header files that are considered internal to the py core and should not
normally be included directly are:
    py/nlr.h - internal nlr configuration and declarations
    py/bc0.h - contains bytecode macro definitions
    py/runtime0.h - contains basic runtime enums

Instead, the top-level header files to include are one of:
    py/obj.h - includes runtime0.h and defines everything to use the
        mp_obj_t type
    py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
        and defines everything to use the general runtime support functions

Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-10-04 12:37:50 +11:00