CPython also has os.environ, which should be used instead of os.getenv()
due to caching in the os.environ mapping. But for MicroPython it makes
sense to only implement the basic underlying methods, ie getenv/putenv/
unsetenv.
This adds a -h option to print the usage help text and adds a new, shorter
error message that is printed when invalid arguments are given. This
behaviour follows CPython (and other tools) more closely.
This commit modifies the usage() function to only print the -v option help
text when MICROPY_DEBUG_PRINTERS is enabled. The -v option requires this
build option to be enabled for it to have any effect.
The usage text is also modified to show the -i and -m options, and also
show that running a command, module or file are mutually exclusive.
This adds support for a MICROPYINSPECT environment variable that works
exactly like PYTHONINSPECT; per CPython docs:
If this is set to a non-empty string it is equivalent to specifying the
-i option.
This variable can also be modified by Python code using os.environ to
force inspect mode on program termination.
Zephyr removed the build target syscall_macros_h_target in commit
f4adf107f31674eb20881531900ff092cc40c07f. Removes reference from
MicroPython to fix build errors in the zephyr port.
This change is not compatible with zephyr v2.1 or earlier. It will be
compatible with Zephyr v2.2 when released.
The SYS_CLOCK_HW_CYCLES_TO_NS macro was deprecated in zephyr commit
8892406c1de21bd5de5877f39099e3663a5f3af1. This commit updates MicroPython
to use the new k_cyc_to_ns_floor64 api and fix build warnings in the zephyr
port.
This change is compatible with Zephyr v2.1 and later.
Zephyr restructured its includes in v2.0 and removed compatibility shims
after two releases in commit 1342dadc365ee22199e51779185899ddf7478686.
Updates include paths in MicroPython accordingly to fix build errors in
the zephyr port.
These changes are compatible with Zephyr v2.0 and later.
When stdout is redirected it is useful to have errors printed to stderr
instead of being redirected.
mp_stderr_print() can't be used in these two instances since the
MicroPython runtime is not running so we use fprintf(stderr) instead.
The ability to change the host is a frequently requested feature, so
explicitly document how it can be achieved using the existing code.
See issues #2121, #4385, #4622, #5122, #5536.
This commit improves pllvalues.py to generate PLL values for H7 MCUs that
are valid (VCO in and out are in range) and extend for the entire range of
SYSCLK values up to 400MHz (up to 480MHz is currently unsupported).
This board now has the following 3 build configurations:
- mboot + external QSPI in XIP mode + internal filesystem
- mboot + external QSPI with filesystem (the default)
- no mboot + external QSPI with filesystem
With a SPI flash that has more than 16MB, 32-bit addressing is required
rather than the standard 24-bit. This commit adds support for 32-bit
addressing so that the SPI flash commands (read/write/erase) are selected
automatically depending on the size of the address being used at each
operation.
This modifies the signature of mp_thread_set_state() to use
mp_state_thread_t* instead of void*. This matches the return type of
mp_thread_get_state(), which returns the same value.
`struct _mp_state_thread_t;` had to be moved before
`#include <mpthreadport.h>` since the stm32 port uses it in its
mpthreadport.h file.
PLLM is shared among all PLL blocks on F7 MCUs, and this calculation to
configure PLLSAI to have 48MHz on the P output previously assumed that PLLM
is equal to HSE (eg PLLM=25 for HSE=25MHz). This commit relaxes this
assumption to allow other values of PLLM.
It is not safe to enable MICROPY_ASYNC_KBD_INTR and MICROPY_PY_THREAD_GIL
at the same time. This will trigger a compiler error to ensure that it
is not possible to make this mistake.
Addition of GIL EXIT/ENTER pairs are:
- modos: release the GIL during system calls. CPython does this as well.
- moduselect: release the GIL during the poll() syscall. This call can be
blocking, so it is important to allow other threads to run at this time.
- modusocket: release the GIL during system calls. Many of these calls can
be blocking, so it is important to allow other threads to run.
- unix_mphal: release the GIL during the read and write syscalls in
mp_hal_stdin_rx_chr and mp_hal_stdout_tx_strn. If we don't do this
threads are blocked when the REPL or the builtin input function are used.
- file, main, mpconfigport.h: release GIL during syscalls in built-in
functions that could block.
When CFLAGS_EXTRA/LDFLAGS_EXTRA (or anything) is set on the command line of
a make invocation then it will completely override any setting or appending
of these variables in the makefile(s). This means builds like the coverage
variant will have their mpconfigvariant.mk settings overridden. Fix this
by using CFLAGS/LDFLAGS exclusively in the makefile(s), reserving the
CFLAGS_EXTRA/LDFLAGS_EXTRA variables for external command-line use only.
Translate common Ctrl-Left/Right/Delete/Backspace to the EMACS-style
sequences (i.e. Alt key based) for forward-word, backward-word, forwad-kill
and backward-kill. Requires MICROPY_REPL_EMACS_WORDS_MOVE to be defined so
the readline implementation interprets these.
Prior to this commit, if the flash filesystem was not formatted then it
would error: "AttributeError: 'FlashBdev' object has no attribute 'mount'".
That is due to it not being able to detect the filesystem on the block
device and just trying to mount the block device directly.
This commit fixes the issue by just catching all exceptions. Also it's not
needed to try the mount if `flashbdev.bdev` is None.
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.
Invoking "make" will still build the standard "micropython" executable, but
other variants are now build using, eg, "make VARIANT=minimal". This
follows how bare-metal ports specify a particular board, and allows running
any make target (eg clean, test) with any variant.
Convenience targets (eg "make coverage") are provided to retain the old
behaviour, at least for now.
See issue #3043.
Most types are in rodata/ROM, and mp_obj_base_t.type is a constant pointer,
so enforce this const-ness throughout the code base. If a type ever needs
to be modified (eg a user type) then a simple cast can be used.
This change has the following effects:
- Reduces the resolution of the RTC sub-second counter from 30.52us to
122.07us.
- Allows RTC.calibration() to now support positive values (as well as
negative values).
- Reduces VBAT current consumption in standby mode by a small amount.
For general purpose use 122us resolution of the sub-second counter is
good enough, and the benefits of full range calibration and minor reduction
in VBAT consumption are worth the change.
Make version 4.1 and lower does not allow $call as the main expression on a
line, so assign the result of the $call to a dummy variable.
Fixes issue #5426.
Instances of the slice class are passed to __getitem__() on objects when
the user indexes them with a slice. In practice the majority of the time
(other than passing it on untouched) is to work out what the slice means in
the context of an array dimension of a particular length. Since Python 2.3
there has been a method on the slice class, indices(), that takes a
dimension length and returns the real start, stop and step, accounting for
missing or negative values in the slice spec. This commit implements such
a indices() method on the slice class.
It is configurable at compile-time via MICROPY_PY_BUILTINS_SLICE_INDICES,
disabled by default, enabled on unix, stm32 and esp32 ports.
This commit also adds new tests for slice indices and for slicing unicode
strings.
The existing uos.remove cannot be used to remove directories, instead
uos.rmdir is needed. And also provide uos.rename to get a good set of
filesystem functionality without requiring additional Python-level os
functions (eg using ffi).
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.
Most stm32 boards can now be built in nan-boxing mode via:
$ make NANBOX=1
Note that if float is enabled then it will be forced to double-precision.
Also, native emitters will be disabled.
Move webrepl support code from ports/esp8266/modules into extmod/webrepl
(to be alongside extmod/modwebrepl.c), and use frozen manifests to include
it in the build on esp8266 and esp32.
A small modification is made to webrepl.py to make it work on non-ESP
ports, i.e. don't call dupterm_notify if not available.
- Corrected pin assignments and checked with CubeMX.
- Added additional I2C and UARTs.
- Added Ethernet interface definitions with lwIP and SSL support (but
Ethernet is currently unsupported on H7 MCUs so not fully enabled).
- Removed remarks on DFU/OCD in mpconfigboard.h because deploy-stlink works
fine too.
- Added more UARTs, I2C, corrected SPI, CAN, etc; verified against CubeMX.
- Adapted pins.csv to remove errors, add omissions, etc. according to
NUCLEO-144 User Manual.
- Changed linker file stm32f767.ld to reflect correct size of the Flash.
- Tested with LAN and SD card.
The Nucleo board does not have an SD card slot but does have the requisite
pins next to each other and labelled, so provide the configuration for
convenience.
Implements text, rodata and bss generalised relocations, as well as generic
qstr-object linking. This allows importing dynamic native modules on all
supported architectures in a unified way.
The default protection for the BLE ringbuf is to use
MICROPY_BEGIN_ATOMIC_SECTION, which disables all interrupts. On stm32 it
only needs to disable the lowest priority IRQ, pendsv, because that's the
IRQ level at which the BLE stack is driven.
qstrs in this file are always included in all builds, even if not used
anywhere. So remove those that are never needed, and make USB names
conditional on having USB enabled.
And return -MP_EIO if calling storage_read_block/storage_write_block fails.
This lines up with the return type and value (negative for error) of the
calls to MICROPY_HW_BDEV_READBLOCKS (and WRITEBLOCKS, and BDEV2 versions).
The pyb.Flash() class can now be used to construct objects which reference
sections of the flash storage, starting at a certain offset and going for a
certain length. Such objects also support the extended block protocol.
The signature for the constructor is: pyb.Flash(start=-1, len=-1).
This commit refactors and generalises the boot-mount routine on stm32 so
that it can mount filesystems of arbitrary type. That is, it no longer
assumes that the filesystem is FAT. It does this by using mp_vfs_mount()
which does auto-detection of the filesystem type.
Using mp_hal_delay_ms allows the scheduler to run, which might result in
another transmit operation happening, which would bypass the sleep (and
fail). Use mp_hal_delay_us instead.
The compile-time configuration value MICROPY_HW_RTC_USER_MEM_MAX can now be
used to define the amount of memory set aside for RTC.memory(). If this
value is configured to zero then the RTC.memory functionality is not
included in the build.
The IDF heap is more fragmented with IDF 4 and mbedtls cannot allocate
enough RAM with 16+16kiB for both in and out buffers, so reduce output
buffer size.
Fixes issue #5303.
This commit removes the Makefile-level MICROPY_FATFS config and moves the
MICROPY_VFS_FAT config to the Makefile level to replace it. It also moves
the include of the oofatfs source files in the build from each port to a
central place in extmod/extmod.mk.
For a port to enabled VFS FAT support it should now set MICROPY_VFS_FAT=1
at the level of the Makefile. This will include the relevant oofatfs files
in the build and set MICROPY_VFS_FAT=1 at the C (preprocessor) level.
This commit adds support for littlefs (v2) on all esp32 boards.
The original FAT filesystem still works and any board with a preexisting
FAT filesystem will still work as normal. It's possible to switch to
littlefs by reformatting the block device using:
import uos, flashbdev
uos.VfsLfs2.mkfs(flashbdev.bdev)
Then when the board reboots (soft or hard) the new littlefs filesystem will
be mounted. It's possible to switch back to a FAT filesystem by formatting
with uos.VfsFat.mkfs(flashbdev.bdev).
This commit adds an implementation of machine.Timer backed by the soft
timer mechanism. It allows an arbitrary number of timers with 1ms
resolution, with an associated Python callback. The Python-level API
matches existing ports that have a soft timer, and is used as:
from machine import Timer
t = Timer(freq=10, callback=lambda t:print(t))
...
t = Timer(mode=Timer.ONE_SHOT, period=2000, callback=lambda t:print(t))
...
t.deinit()
This commit adds an implementation of a "software timer" with a 1ms
resolution, using SysTick. It allows unlimited number of concurrent
timers (limited only by memory needed for each timer entry). They can be
one-shot or periodic, and associated with a Python callback.
There is a very small overhead added to the SysTick IRQ, which could be
further optimised in the future, eg by patching SysTick_Handler code
dynamically.
The MP_STATE_THREAD(stack_top) is always available so use it instead of
creating a separate variable. This also allows gc_collect() to be used as
an independent function, without real_main() being called.
When a SPI bus is initialized with a SPI host that is currently in use the
exception msg incorrectly indicates "SPI device already in use". The
mention of "device" in the exception msg is confusing because the error is
about trying to use a SPI host that is already claimed. A better exception
msg is "SPI host already in use".
For consistency with "umachine". Now that weak links are enabled
by default for built-in modules, this should be a no-op, but allows
extension of the bluetooth module by user code.
Also move registration of ubluetooth to objmodule rather than
port-specific.
This commit implements automatic module weak links for all built-in
modules, by searching for "ufoo" in the built-in module list if "foo"
cannot be found. This means that all modules named "ufoo" are always
available as "foo". Also, a port can no longer add any other weak links,
which makes strict the definition of a weak link.
It saves some code size (about 100-200 bytes) on ports that previously had
lots of weak links.
Some changes from the previous behaviour:
- It doesn't intern the non-u module names (eg "foo" is not interned),
which saves code size, but will mean that "import foo" creates a new qstr
(namely "foo") in RAM (unless the importing module is frozen).
- help('modules') no longer lists non-u module names, only the u-variants;
this reduces duplication in the help listing.
Weak links are effectively the same as having a set of symbolic links on
the filesystem that is searched last. So an "import foo" will search
built-in modules first, then all paths in sys.path, then weak links last,
importing "ufoo" if it exists. Thus a file called "foo.py" somewhere in
sys.path will still have precedence over the weak link of "foo" to "ufoo".
See issues: #1740, #4449, #5229, #5241.
When loading a manifest file, e.g. by include(), it will chdir first to the
directory of that manifest. This means that all file operations within a
manifest are relative to that manifest's location.
As a consequence of this, additional environment variables are needed to
find absolute paths, so the following are added: $(MPY_LIB_DIR),
$(PORT_DIR), $(BOARD_DIR). And rename $(MPY) to $(MPY_DIR) to be
consistent.
Existing manifests are updated to match.
Prior to this commit the systick IRQ priority was set at lowest priority on
F0/L0/WB MCUs, because it was left at the default and never configured.
This commit ensures the priority is configured and sets it to the highest
priority.
Remove the 240MHz CPU config option from sdkconfig.base and create a new
sdkconfig.240mhz file for those boards that want to use 240MHz on boot.
The default CPU frequency is now 160MHz (was 240MHz), to align with the ESP
IDF and support more boards (eg those with D2WD chips).
Fixes issue #5169.
This prevents issues with concurrent access to the ringbuf.
MICROPY_BEGIN_ATOMIC_SECTION is only atomic to the same core. We could
address this with a mutex, but it's also not safe to call mp_sched_schedule
across cores.
This avoids a confusing ENOMEM raised from gap_advertise if there is
currently an active connection. This refers to the static connection
buffer pre-allocated by Nimble (nothing to do with MicroPython heap
memory).
This patch add basic building blocks for nrf9P60.
It also includes a secure bootloader which forwards all
possible peripherals that are user selectable to become
non-secure. After configuring Flash, RAM and peripherals
the secure bootloader will jump to the non-secure domain
where MicroPython is placed.
The minimum size of a secure boot has to be a flash
block of 32Kb, hence why the linker scripts are
offsetting the main application this much.
The RAM offset is set to 128K, to allow for later
integration of Nordic Semiconductor's BSD socket
library which reserves the range 0x20010000 - 0x2001FFFF.
Add support for pca10059 with REPL over tinyusb USB CDC.
The board also includes a board specific module that will
recover UICR->REGOUT0 in case this has been erased.
This initial support does not preserve any existing bootloader
on the pca10090 in case this was present, and expects to use all
available flash on the device.
Add nrf-port finyusb driver files. USB CDC can be activated
by board configuration files using the MICROPY_HW_USB_CDC.
Updating BLE driver, Makefile, nrfx-glue and main.c to plug
in the tinyusb stack.
The specific board can be selected with the BOARD makefile variable. This
defaults (if not specified) to BOARD=GENERIC, which is the original default
firmware build. For the 512k target use BOARD=GENERIC_512K.
On other ports (e.g. ESP32) they provide a complete Nimble implementation
(i.e. we don't need to use the code in extmod/nimble). This change
extracts out the bits that we don't need to use in other ports:
- malloc/free/realloc for Nimble memory.
- pendsv poll handler
- depowering the cywbt
Also cleans up the root pointer management.
STM32F0 has PCLK=48MHz and maximum ADC clock is 14MHz so use PCLK/4=12MHz
to stay within spec of the ADC peripheral. In pyb.ADC set common sampling
time to approx 4uS for internal and external sources. In machine.ADC
reduce sample time to approx 1uS for external source, leave internal at
maximum sampling time.
This commit adds the option to use HSE or MSI system clock, and LSE or LSI
RTC clock, on L4 MCUs.
Note that prior to this commit the default clocks on an L4 part were MSI
and LSE. The defaults are now MSI and LSI.
In mpconfigboard.h select the clock source via:
#define MICROPY_HW_RTC_USE_LSE (0) or (1)
#define MICROPY_HW_CLK_USE_HSE (0) or (1)
and the PLLSAI1 N,P,Q,R settings:
#define MICROPY_HW_CLK_PLLSAIN (12)
#define MICROPY_HW_CLK_PLLSAIP (RCC_PLLP_DIV7)
#define MICROPY_HW_CLK_PLLSAIQ (RCC_PLLQ_DIV2)
#define MICROPY_HW_CLK_PLLSAIR (RCC_PLLR_DIV2)
The the nrfx driver is aware of chip specific registers, while
the raw HAL abstraction is not. This driver enables use of NVMC
in non-secure domain for nrf9160.
This patch moves the check for MICROPY_PY_MACHINE_TEMP to come
before the inclusion of nrf_temp.h. The nrf_temp.h depends on
the NRF_TEMP_Type which might not be defined for all nRF devices.
For use with F0 MCUs that don't have HSI48. Select the clock source
explicitly in mpconfigboard.h.
On the NUCLEO_F091RC board use HSE bypass when HSE is chosen because the
NUCLEO clock source is STLINK not a crystal.
Before this patch the UART baudrate on F0 MCUs was wrong because the
stm32lib SystemCoreClockUpdate sets SystemCoreClock to 8MHz instead of
48MHz if HSI48 is routed directly to SYSCLK.
The workaround is to use HSI48 -> PREDIV (/2) -> PLL (*2) -> SYSCLK.
Fixes issue #5049.
Enabled by default, but disabled when REPL is connected to the VCP (this is
the existing behaviour). Can be configured at run-time with, eg:
pyb.USB_VCP().init(flow=pyb.USB_VCP.RTS | pyb.USB_VCP.CTS)
The new fdcan.c file provides the low-level C interface to the FDCAN
peripheral, and pyb_can.c is updated to support both traditional CAN and
FDCAN, depending on the MCU being compiled for.
Add the project file to the mpy-cross directory, which is also where the
executable ends up, and change the Appveyor settings to build mpy-cross
with both msvc and mingw-w64 and verify this all works by running tests
with --via-mpy.
If this is not set it might default to calls to open() to use text mode
which is usually not wanted, and even wrong and leading to incorrect
results when loading binary .mpy files.
This also means that text files written and read will not have line-ending
translation from \n to \r\n and vice-versa anymore. This shouldn't be much
of a problem though since most tools dealing with text files adapt
automatically to any of the 2 formats.
Reserve sources.props for listing just the MicroPython core and extmod
files, similar to how py.mk lists port-independent source files. This
allows reusing the source list, for instance for building mpy-cross. The
sources for building the executable itself are listed in the corresponding
project file, similar to how the other ports specify the source files in
their Makefile.
Append to PyIncDirs, used to define include directories specific to
MicroPython, instead of just overwriting it so project files importing this
file can define additional directories. And allow defining the target
directory for the executable instead of hardcoding it to the windows
directory. Main reason for this change is that it will allow building
mpy-cross with msvc.
We want the .vcxproj to be just a container with the minimum content for
making it work as a project file for Visual Studio and MSBuild, whereas the
actual build options and actions get placed in separate reusable files.
This was roughly the case already except some compiler options were
overlooked; fix this here: we'll need those common options when adding a
project file for building mpy-cross.
These were probably added to detect more qstrs but as long as the
micropython executable itself doesn't use the same build options the qstrs
would be unused anyway. Furthermore these definitions are for internal use
and get enabled when corresponding MICROPY_EMIT_XXX are defined, in which
case the compiler would warn about symbol redefinitions since they'd be
defined both here and in the source.
This commit adds support for a second supported hash (currently set to the
4.0-beta1 tag). When this hash is detected, the relevant changes are
applied.
This allows to start using v4 features (e.g. BLE with Nimble), and also
start doing testing, while still supporting the original, stable, v3.3 IDF.
Note: this feature is experimental, not well tested, and network.LAN and
network.PPP are currently unsupported.
This option affects py/vm.c and py/gc.c and using -Os gets them compiling a
bit smaller, and small firmware is the aim of these two ports. Also,
having these files compiled with -Os on these ports, and -O3 as the default
on other ports, gives a better understanding of code-size changes when
making changes to these files.
According to the schematic, the SDRAM part on this board is a
MT48LC4M32B2B5-6A, with "Row addressing 4K A[11:0]" (per datasheet). This
commit updates mpconfigboard.h from 13 to 12 to match.
This patch uses the newly-added esp32.Partition class to replace the
existing FlashBdev class. Partition objects implement the block protocol
so can be directly mounted via uos.mount(). This has the following
benefits:
- allows the filesystem partition location and size to be specified in
partitions.csv, and overridden by a particular board
- very easily allows to have multiple filesystems by simply adding extra
entries to partitions.csv
- improves efficiency/speed of filesystem operations because the block
device is implemented fully in C
- opens the possibility to have encrypted flash storage (since Partitions
can be encrypted)
Note that this patch is fully backwards compatible: existing filesystems
remain untouched and work with this new code.
- STM32F407VGT6 (1MB of Flash, 192+4 Kbytes of SRAM)
- 5V (via USB) or Li-Polymer Battery (3.7V) power input
- 2 x LEDs
- 2 x user switches
- 2 x mikroBUS sockets
- 2 x 1x26 mikromedia-compatible headers (52 pins)
https://www.mikroe.com/clicker-2-stm32f4
Mboot currently requires at least three LEDs to display each of the four
states. However, since there are only four possible states, the states can
be displayed via binary counting on only 2 LEDs (if only 2 are available).
The existing patterns are still used for 3 or 4 LEDs.
It was previously not taking into account that the list of pins was sparse,
so using the wrong index. The boards/X/pins.csv was generating the wrong
data for machine.Pin.board.
As part of this fix rename the variables to make it more clear what the
list contains (only board pins).
This commit adds support for sys.settrace, allowing to install Python
handlers to trace execution of Python code. The interface follows CPython
as closely as possible. The feature is disabled by default and can be
enabled via MICROPY_PY_SYS_SETTRACE.
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.
- Split 'qemu-arm' from 'unix' for generating tests.
- Add frozen module to the qemu-arm test build.
- Add test that reproduces the requirement to half-word align native
function data.
Enabled via MICROPY_PY_URE_DEBUG, disabled by default (but enabled on unix
coverage build). This is a rarely used feature that costs a lot of code
(500-800 bytes flash). Debugging of regular expressions can be done
offline with other tools.
As per PEP 485, this function appeared in for Python 3.5. Configured via
MICROPY_PY_MATH_ISCLOSE which is disabled by default, but enabled for the
ports which already have MICROPY_PY_MATH_SPECIAL_FUNCTIONS enabled.
Before this patch I2C transactions using a hardware I2C peripheral on F0/F7
MCUs would not correctly generate the I2C restart condition, and instead
would generate a stop followed by a start. This is because the CR2 AUTOEND
bit was being set before CR2 START when the peripheral already had the I2C
bus from a previous transaction that did not generate a stop.
As a consequence all combined transactions, eg read-then-write for an I2C
memory transfer, generated a stop condition after the first transaction and
didn't generate a stop at the very end (but still released the bus). Some
I2C devices require a repeated start to function correctly.
This patch fixes this by making sure the CR2 AUTOEND bit is set after the
start condition and slave address have been fully transferred out.
Replaces the `SDKCONFIG` makefile variable with `BOARD`. Defaults to
BOARD=GENERIC. spiram can be enabled with `BOARD=GENERIC_SPIRAM`
Add example definition for TINYPICO, currently identical to GENERIC_SPIRAM
but with custom board/SoC names for the uPy banner.
They are both enabled by default, but can be disabled by defining
MICROPY_HW_ENABLE_MDNS_QUERIES and/or MICROPY_HW_ENABLE_MDNS_RESPONDER to
0. The hostname for the responder is currently taken from
tcpip_adapter_get_hostname() but should eventually be configurable.
This commit adds the connect() method to the PPP interface and requires
that connect() be called after active(1). This is a breaking change for
the PPP API.
With the connect() method it's now possible to pass in authentication
information for PAP/CHAP, eg:
ppp.active(1)
ppp.connect(authmode=ppp.AUTH_PAP, username="user", "password="password")
If no authentication is needed simply call connect() without any
parameters. This will get the original behaviour of calling active(1).
Some SD/MMC breakout boards don't support 4-bit bus mode. This adds a new
macro MICROPY_HW_SDMMC_BUS_WIDTH that allows each board to define the width
of the SD/MMC bus interface used on that board, defaulting to 4 bits.
The previous version did not work on MCUs that only had USB device mode
(compared to OTG) because of the handling of NAK. And this previous
handling of NAK had a race condition where a new packet could come in
before USBD_HID_SetNAK was called (since USBD_HID_ReceivePacket clears NAK
as part of its operation). Furthermore, the double buffering of incoming
reports was not working, only one buffer could be used at a time.
This commit rewrites the HID interface code to have a single incoming
buffer, and only calls USBD_HID_ReceivePacket after the user has read the
incoming report (similar to how the VCP does its flow control). As such,
USBD_HID_SetNAK and USBD_HID_ClearNAK are no longer needed.
API functionality from the user's point of view should be unchanged with
this commit.
On this port the GIL is enabled and everything works under the assumption
of the GIL, ie that a given task has exclusive access to the uPy state, and
any ISRs interrupt the current task and therefore the ISR inherits
exclusive access to the uPy state for the duration of its execution.
If the MicroPython tasks are not pinned to a specific core then an ISR may
be executed on a different core to the task, making it possible for the
main task and an ISR to execute in parallel, breaking the assumption of the
GIL.
The easiest and safest fix for this is to pin all MicroPython related code
to the same CPU core, as done by this patch. Then any ISR that accesses
MicroPython state must be registered from a MicroPython task, to ensure it
is invoked on the same core.
See issue #4895.
The C++ standard forbids redefining keywords, like inline and alignof, so
guard these definitions to avoid that, allowing to include the MicroPython
headers by C++ code.
This new series of MCUs is similar to the L4 series with an additional
Cortex-M0 coprocessor. The firmware for the wireless stack must be managed
separately and MicroPython does not currently interface to it. Supported
features so far include: RTC, UART, USB, internal flash filesystem.
The new configurations MICROPY_HW_USB_MSC and MICROPY_HW_USB_HID can be
used by a board to enabled or disable MSC and/or HID. They are both
enabled by default.
In a non-thread build, using &_ram_end as the top-of-stack is no longer
correct because the stack is not always at the very top end of RAM. See
eg 04c7cdb668 and
3786592097. The correct value to use is
&_estack, which is the value stored in MP_STATE_THREAD(stack_top), and
using the same code for both thread and non-thread builds makes the code
cleaner.
stm32lib now provides system_stm32XXxx.c source files for all MCU variants,
which includes SystemInit and prescaler tables. Since these are quite
standard and don't need to be changed, switch to use them instead of custom
variants, making the start-up code cleaner.
The SystemInit code in stm32lib was checked and is equivalent to what is
removed from the stm32 port in this commit.
Without this you often don't get any DNS server from your network provider.
Additionally, setting your own DNS _does not work_ without this option set
(which could be a bug in the PPP stack).
This is a start to make a more consistent machine.RTC class across ports.
The stm32 pyb.RTC class at least has the datetime() method which behaves
the same as esp8266 and esp32, and with this patch the ntptime.py script
now works with stm32.
If both FS and HS USB peripherals are enabled for a board then the active
one used for the REPL will now be auto-detected, by checking to see if both
the DP and DM lines are actively pulled low. By default the code falls
back to use MICROPY_HW_USB_MAIN_DEV if nothing can be detected.
When going out of memory-mapped mode to do a control transfer to the QSPI
flash, the MPU settings must be changed to forbid access to the memory
mapped region. And any ongoing transfer (eg memory mapped continuous read)
must be aborted.
The Cortex-M7 CPU will do speculative loads from any memory location that
is not explicitly forbidden. This includes the QSPI memory-mapped region
starting at 0x90000000 and with size 256MiB. Speculative loads to this
QSPI region may 1) interfere with the QSPI peripheral registers (eg the
address register) if the QSPI is not in memory-mapped mode; 2) attempt to
access data outside the configured size of the QSPI flash when it is in
memory-mapped mode. Both of these scenarios will lead to issues with the
QSPI peripheral (eg Cortex bus lock up in scenario 2).
To prevent such speculative loads from interfering with the peripheral the
MPU is configured in this commit to restrict access to the QSPI mapped
region: when not memory mapped the entire region is forbidden; when memory
mapped only accesses to the valid flash size are permitted.
When compiled with hard float the system should enable FP access when it
starts or else FP instructions lead to a fault. But this minimal port does
not enable (or use) FP and so, to keep it minimal, switch to use soft
floating point. (This became an issue due to the recent commit
34c04d2319 which saves/restores FP registers
in the NLR state.)
Change static LED functions to lowercase names, and trim down source code
lines for variants of MICROPY_HW_LED_COUNT. Also rename configuration for
MICROPY_HW_LEDx_LEVEL to MICROPY_HW_LEDx_PULLUP to align with global PULLUP
configuration.
Commit 9e68eec8ea introduced a regression
where the PID of the USB device would be 0xffff if the default value was
used. This commit fixes that by using a signed int type.
Entering a bootloader (ST system bootloader, or custom mboot) from software
by directly branching to it is not reliable, and the reliability of it
working can depend on the peripherals that were enabled by the application
code. It's also not possible to branch to a bootloader if the WDT is
enabled (unless the bootloader has specific provisions to feed the WDT).
This patch changes the way a bootloader is entered from software by first
doing a complete system reset, then branching to the desired bootloader
early on in the start-up process. The top two words of RAM (of the stack)
are reserved to store flags indicating that the bootloader should be
entered after a reset.
WIFI_REASON_AUTH_FAIL does not necessarily mean the password is wrong, and
a wrong password may not lead to a WIFI_REASON_AUTH_FAIL error code. So to
improve reliability connecting to a WLAN always reconnect regardless of the
error.
This updates ESP IDF to use v3.3-beta3. And also adjusts README.md to
point to stable docs which provide a link to download the correct toolchain
for this IDF version, namely 1.22.0-80-g6c4433a-5.2.0
Previously the end of the heap was the start (lowest address) of the stack.
With the changes in this commit these addresses are now independent,
allowing a board to place the heap and stack in separate locations.
With this the user can select multiple logical units to expose over USB MSC
at once, eg: pyb.usb_mode('VCP+MSC', msc=(pyb.Flash(), pyb.SDCard())). The
default behaviour is the original behaviour of just one unit at a time.
Eventually these responses could be filled in by a function to make their
contents dynamic, depending on the attached logical units. But for now
they are fixed, and this patch fixes the MODE SENSE(6) responses so it is
the correct length with the correct header.
SCSI can support multiple logical units over the one interface (in this
case over USBD MSC) and here the MSC code is reworked to support this
feature. At this point only one LU is used and the behaviour is mostly
unchanged from before, except the INQUIRY result is different (it will
report "Flash" for both flash and SD card).
To use it a board should define MICROPY_PY_USSL=1 and MICROPY_SSL_MBEDTLS=1
at the Makefile level. With the provided configuration it adds about 64k
to the build.
It doesn't work to tie the polling of an underlying NIC driver (eg to check
the NIC for pending Ethernet frames) with its associated lwIP netif. This
is because most NICs are implemented with IRQs and don't need polling,
because there can be multiple lwIP netif's per NIC driver, and because it
restricts the use of the netif->state variable. Instead the NIC should
have its own specific way of processing incoming Ethernet frame.
This patch removes this generic NIC polling feature, and for the only
driver that uses it (Wiznet5k) replaces it with an explicit call to the
poll function (which could eventually be improved by using a proper
external interrupt).
This adds support for SD cards using the ESP32's built-in hardware SD/MMC
host controller, over either the SDIO bus or SPI. The class is available
as machine.SDCard and using it can be as simple as:
uos.mount(machine.SDCard(), '/sd')
If the board-pin name is left empty then only the cpu-pin name is used, eg
",PA0". If the board-pin name starts with a hyphen then it's available as
a C definition but not in the firmware, eg "-X1,PA0".
The patch solves the problem where multiple Timer objects (e.g. multiple
Timer(0) instances) could initialise multiple handles to the same internal
timer. The list of timers is now maintained not for "active" timers (where
init is called), but for all timers created. The timers are only removed
from the list of timers on soft-reset (machine_timer_deinit_all).
Fixes#4078.
The board config option MICROPY_HW_USB_ENABLE_CDC2 is now changed to
MICROPY_HW_USB_CDC_NUM, and the latter should be defined to the maximum
number of CDC interfaces to support (defaults to 1).
Set the active MPU region to the actual size of SDRAM configured and
invalidate the rest of the memory-mapped region, to prevent errors due to
CPU speculation. Also update the attributes of the SDRAM region as per ST
recommendations, and change region numbers to avoid conflicts elsewhere in
the codebase (see eth usage).
I2C can't be enabled in prj_base.conf because it's a board-specific
feature. For example, if a board doesn't have I2C but CONFIG_I2C=y then
the build will fail (on Zephyr build system side). The patch here gets the
qemu_cortex_m3 build working again.
This enables going back to previous wrapped lines using backspace or left
arrow: instead of just sticking to the beginning of a line, the cursor will
move a line up.
On MCUs that have an I2C TIMINGR register, this can now be explicitly set
via the "timingr" keyword argument to the I2C constructor, for both
machine.I2C and pyb.I2C. This allows to configure precise timing values
when the defaults are inadequate.
Previously the hardware I2C timeout was hard coded to 50ms which isn't
guaranteed to be enough depending on the clock stretching specs of the I2C
device(s) in use.
This patch ensures the hardware I2C implementation honors the existing
timeout argument passed to the machine.I2C constructor. The default
timeout for software and hardware I2C is now 50ms.
Recent gcc versions (at least 9.1) give a warning about using "sp" in the
clobber list. Such code is removed by this patch. A dedicated function is
instead used to set SP and branch to the bootloader so the code has full
control over what happens.
Fixes issue #4785.
This also fixes deleting the PPP task, since eTaskGetState() never returns
eDeleted.
A limitation with this patch: once the PPP is deactivated (ppp.active(0))
it cannot be used again. A new PPP instance must be created instead.
This allows figuring out the number of bytes in the memoryview object as
len(memview) * memview.itemsize.
The feature is enabled via MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE and is
disabled by default.
The original code called setsockopt(SO_RCVTIMEO/SO_SNDTIMEO) with NULL
timeout structure argument, which is an illegal usage of that function.
The old code also didn't validate the return value of setsockopt, missing
the bug completely.
Before this change, if the USB was reconnected it was possible that some
characters in the TX buffer were retransmitted because tx_buf_ptr_out and
tx_buf_ptr_out_shadow were reset while tx_buf_ptr_in wasn't. That
behaviour is fixed here by retaining the TX buffer state across reconnects.
Fixes issue #4761.
The new function factory_reset_make_files() populates the given filesystem
with the default factory files. It is defined with weak linkage so it can
be overridden by a board.
This commit also brings some minor user-facing changes:
- boot.py is now no longer created unconditionally if it doesn't exist, it
is now only created when the filesystem is formatted and the other files
are populated (so, before, if the user deleted boot.py it would be
recreated at next boot; now it won't be).
- pybcdc.inf and README.txt are only created if the board has USB, because
they only really make sense if the filesystem is exposed via USB.
It's more common to need non-blocking behaviour when reading from a UART,
rather than having a large timeout like 1000ms (the original behaviour).
With a large timeout it's 1) likely that the function will read forever if
characters keep trickling it; or 2) the function will unnecessarily wait
when characters come sporadically, eg at a REPL prompt.
- IBK-BLYST-NANO: Breakout board
- IDK-BLYST-NANO: DevKit board with builtin IDAP-M CMSIS-DAP Debug JTAG,
RGB led
- BLUEIO-TAG-EVIM: Sensor tag board (environmental sensor
(T, H, P, Air quality) + 9 axis motion sensor)
Also, the LED module has been updated to support individual base level
configuration of each LED. If set, this will be used instead of the
common configuration, MICROPY_HW_LED_PULLUP. The new configuration,
MICROPY_HW_LEDX_LEVEL, where X is the LED number can be used to set
the base level of the specific LED.
The alternate function pin allocations are different to other NUCLEO-144
boards. This is because the STM32F413 has a very high peripheral count:
10x UART, 5x SPI, 3x I2C, 3x CAN. The pinout was chosen to expose all
these devices on separate pins except CAN3 which shares a pin with UART1
and SPI1 which shares pins with DAC.
Includes:
- Support for CAN3.
- Support for UART9 and UART10.
- stm32f413xg.ld and stm32f413xh.ld linker scripts.
- stm32f413_af.csv alternate function mapping.
- startup_stm32f413xx.s because F413 has different interrupt vector table.
- Memory configuration with: 240K filesystem, 240K heap, 16K stack.
This patch makes pllvalues.py generate two tables: one for when HSI is used
and one for when HSE is used. The correct table is then selected at
compile time via the existing MICROPY_HW_CLK_USE_HSI.
When building with link time optimization enabled it is possible both
gc_collect() and gc_collect_regs_and_stack() get inlined into gc_alloc()
which can result in the regs variable being pushed on the stack earlier
than some of the registers. Depending on the calling convention, those
registers might however contain pointers to blocks which have just been
allocated in the caller of gc_alloc(). Then those pointers end up higher on
the stack than regs, aren't marked by gc_collect_root() and hence get
sweeped, even though they're still in use.
As reported in #4652 this happened for in 32-bit msvc release builds:
mp_lexer_new() does two consecutive allocations and the latter triggered a
gc_collect() which would sweep the memory of the first allocation again.
The machine.WDT() now accepts the "timeout" keyword argument to select the
WDT interval. And the WDT is changed to panic mode which means it will
reset the device if the interval expires (instead of just printing an error
message).
On the STM32F722 (at least, but STM32F767 is not affected) the CK48MSEL bit
must be deselected before PLLSAION is turned off, or else the 48MHz
peripherals (RNG, SDMMC, USB) may get stuck without a clock source.
In such "lock up" cases it seems that these peripherals are still being
clocked from the PLLSAI even though the CK48MSEL bit is turned off. A hard
reset does not get them out of this stuck state. Enabling the PLLSAI and
then disabling it does get them out. A test case to see this is:
import machine, pyb
for i in range(100):
machine.freq(122_000000)
machine.freq(120_000000)
print(i, [pyb.rng() for _ in range(4)])
On occasion the RNG will just return 0's, but will get fixed again on the
next loop (when PLLSAI is enabled by the change to a SYSCLK of 122MHz).
Fixes issue #4696.
The stm32 and nrf ports already had the behaviour that they would first
check if the script exists before executing it, and this patch makes all
other ports work the same way. This helps when developing apps because
it's hard to tell (when unconditionally trying to execute the scripts) if
the resulting OSError at boot up comes from missing boot.py or main.py, or
from some other error. And it's not really an error if these scripts don't
exist.
This patch makes the DAC driver simpler and removes the need for the ST
HAL. As part of it, new helper functions are added to the DMA driver,
which also use direct register access instead of the ST HAL.
Main changes to the DAC interface are:
- The DAC uPy object is no longer allocated dynamically on the heap,
rather it's statically allocated and the same object is retrieved for
subsequent uses of pyb.DAC(<id>). This allows to access the DAC objects
without resetting the DAC peripheral. It also means that the DAC is only
reset if explicitly passed initialisation parameters, like "bits" or
"buffering".
- The DAC.noise() and DAC.triangle() methods now output a signal which is
full scale (previously it was a fraction of the full output voltage).
- The DAC.write_timed() method is fixed so that it continues in the
background when another peripheral (eg SPI) uses the DMA (previously the
DAC would stop if another peripheral finished with the DMA and shut the
DMA peripheral off completely).
Based on the above, the following backwards incompatibilities are
introduced:
- pyb.DAC(id) will now only reset the DAC the first time it is called,
whereas previously each call to create a DAC object would reset the DAC.
To get the old behaviour pass the bits parameter like: pyb.DAC(id, bits).
- DAC.noise() and DAC.triangle() are now full scale. To get previous
behaviour (to change the amplitude and offset) write to the DAC_CR (MAMP
bits) and DAC_DHR12Rx registers manually.
If MICROPY_HW_RTC_USE_BYPASS is enabled the RTC startup goes as follows:
- RTC is started with LSE in bypass mode to begin with
- if that fails to start (after a given timeout) then LSE is reconfigured
in non-bypass
- if that fails to start then RTC is switched to LSI
Use uos.dupterm for REPL configuration of the main USB_VCP(0) stream on
dupterm slot 1, if USB is enabled. This means dupterm can also be used to
disable the boot REPL port if desired, via uos.dupterm(None, 1).
For efficiency this adds a simple hook to the global uos.dupterm code to
work with streams that are known to be native streams.
These macros are unused, and they can conflict with other entities by the
same name. If needed they can be provided as static inline functions, or
just functions.
Fixes issue #4559.
Adds support for hardware i2c to the zephyr port. Similar to other ports
such as stm32 and nrf, we only implement the i2c protocol functions
(readfrom and writeto) and defer memory operations (readfrom_mem,
readfrom_mem_into, and writeto_mem) to the software i2c implementation.
This may need to change in the future because zephyr is considering
deprecating its i2c_transfer function in favor of i2c_write_read; in this
case we would probably want to implement the memory operations directly
using i2c_write_read.
Tested with the accelerometer on frdm_k64f and bbc_microbit boards.
For gpio_hold_en() to work properly (not draw additional current) pull
up/down must be disabled when hold is enabled. This patch makes sure this
is the case by reworking the pull constants to be a bit mask.
Adding section about on how to disable use of the linker flag
-flto, by setting the LTO=0 argument to Make. Also, added a
note on recommended toolchains to use that works well with
LTO enabled.
Removing linker script for nrf52840 s140 v6.0.0 as pca10056
target board now points to the new v6.1.1. Also, removing the
entry from the download_ble_stack.sh script.
Removing linker script for nrf52832 s132 v6.0.0 as all target
boards now points to the new v6.1.1. Also, removing the entry
from the download_ble_stack.sh script.
Previously specifying None as the pull value would leave the pull up/down
state unchanged. This change makes it so -1 leaves the state unchanged and
None makes the pin float, as per the docs.
In this port JavaScript is the underlying "machine" and MicroPython is
transmuted into JavaScript by Emscripten. MicroPython can then run under
Node.js or in the browser.
Functions in these files may be needed when certain features are enabled
(eg dual core mode), even if the linker does not give a warning or error
about unresolved symbols.
During make, makemoduledefs.py parses the current builds c files for
MP_REGISTER_MODULE(module_name, obj_module, enabled_define)
These are used to generate a header with the required entries for
"mp_rom_map_elem_t mp_builtin_module_table[]" in py/objmodule.c
To use HSI instead of HSE define MICROPY_HW_CLK_USE_HSI as 1 in the board
configuration file. The default is to use HSE.
HSI has been made the default for the NUCLEO_F401RE board to serve as an
example, and because early revisions of this board need a hardware
modification to get HSE working.
This demonstrates how to use external QSPI flash in XIP (execute in place)
mode. The default configuration has all extmod/ code placed into external
QSPI flash, but other code can easily be put there by modifying the custom
f769_qspi.ld script.
A board can now use the make variables TEXT0_SECTIONS and TEXT1_SECTIONS to
specify the linker sections that should go in its firmware. Defaults are
provided which give the existing behaviour.
esp_wifi_connect will return ESP_OK for the normal path of execution which
just means the reconnect is started, not that it is actually reconnected.
In such a case wifi.isconnected() should return False until the
reconnection is complete. After reconnect a GOT_IP event is called and it
will change wifi_sta_connected back to True.
This patch makes sure that the char_data.props is first
assigned a value before other flags are OR'd in.
Resolves compilation warning on possible unitialized variable.
This patch makes sure that advertisment data is located in
persistent static RAM memory throughout the advertisment.
Also, setting m_adv_handle to predifined
BLE_GAP_ADV_SET_HANDLE_NOT_SET value to indicate first time
usage of the handle. Upon first advertisment configuration
this will be populated with a handle value returned by the
stack (s132/s140).
After new layout of nordicsemi.com the direct links to
command line tools (nrfjprog) has changed to become dynamic.
This patch removes the old direct links to each specific OS
variant and is replaced with one single link to the download
landing page instead.
Currently all usages of mp_hal_pin_config_alt_static() set the pin speed to
"high" (50Mhz). The SDRAM interface typically runs much faster than this
so should be set to the maximum pin speed.
This commit adds mp_hal_pin_config_alt_static_speed() which allows setting
the pin speed along with the other alternate function details.
A few RTC constants weren't being parsed properly due to whitespace
differences, and this patch makes certain whitespace optional. Changes
made:
- allow for no space between /*!< and EXTI, eg for:
__IO uint32_t IMR; /*!<EXTI Interrupt mask register, Address offset: 0x00 */
- allow for no space between semicolon and start of comment, eg for:
__IO uint32_t ALRMASSR;/*!< RTC alarm A sub second register, Address offset: 0x44 */
As mentioned in #4450, `websocket` was experimental with a single intended
user, `webrepl`. Therefore, we'll make this change without a weak
link `websocket` -> `uwebsocket`.
If opening of /dev/mem has failed an `OSError` is appropriately raised, but
the next time `mem8/16/32` is accessed the invalid file descriptor is used
and the program gets a SIGSEGV.
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".
Adds support for 3 Cortex-M boards, selectable via "BOARD" in the Makefile:
- microbit, Cortex-M0 via nRF51822
- netduino2, Cortex-M3 via STM32F205
- mps2-an385, Cortex-M3 via FPGA
netduino2 is the default board because it's supported by older qemu
versions (down to at least 2.5.0).
Instead of checking each callback (currently storage and dma) explicitly
for each SysTick IRQ, use a simple circular function table indexed by the
lower bits of the millisecond tick counter. This allows callbacks to be
easily enabled/disabled at runtime, and scales well to a large number of
callbacks.
This is a good board to demonstrate the use of Mboot because it only has a
USB HS port exposed so the native ST DFU mode cannot be used. With Mboot
this port can be used.
If a custom bootloader is enabled (eg mboot) then machine.bootloader() will
now enter that loader. To get the original ST DFU loader pass any argument
to the function, like machine.bootloader(1).
Don't exclude the Timer instance 1 entry from machine_timer_obj[] when
using soft PWM. The usage is already checked when creating the Timer,
so just create an empty entry.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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).
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
The new option MICROPY_HW_SDCARD_MOUNT_AT_BOOT can now be defined to 0 in
mpconfigboard.h to allow SD hardware to be enabled but not auto-mounted at
boot. This feature is enabled by default to retain previous behaviour.
Previously, if an SD card is enabled in hardware it is also used to boot
from. While this can be disabled with a SKIPSD file on internal flash,
this wont be available at first boot or if the internal flash gets
corrupted.
Due to new webpages at nordicsemi.com, the download links
for Bluetooth LE stacks were broken.
This patch updates the links to new locations for the current
targets.
This UART_HandleTypeDef is quite large (around 70 bytes in RAM needed for
each UART object) and is not needed: instead the state of the peripheral
held in its registers provides all the required information.
The pin alternate function information is derived from ST's datasheet
https://www.st.com/resource/en/datasheet/stm32l432kc.pdf
In the datasheet, the line 2 of AF4 includes I2C2 but actually the chip
does not have I2C2 so it is removed.
As per the machine.UART documentation, this is used to set the length of
the RX buffer. The legacy read_buf_len argument is retained for backwards
compatibility, with rxbuf overriding it if provided.
Also change the order of printing of flow so it is after stop (so bits,
parity, stop are one after the other), and reduce code size by using
mp_print_str instead of mp_printf where possible.
See issue #1981.
This is necessary for two reasons: 1) FreeRTOS still needs the TCB data
structure even after vPortCleanUpTCB has been called, so this latter hook
function cannot free the TCB, and there is no where else to safely delete
it (this behaviour has changed recently in the ESP IDF); 2) when using
external SPI RAM the uPy heap is in this external memory but the task stack
must be allocated from internal SRAM.
Fixes issue #3904.
We standardized to provide uos.remove() as a more obvious and user-friendly
name. That's what written in the docs. The Unix port implementation
predates this convention, so update it now.
Building axtls gives a lot of warnings with -Wall enabled, and explicitly
disabling all of them cannot be done in a way compatible with gcc and
clang, and likely other compilers. So just use -Wno-all to prevent all of
the extra warnings (in addition to the necessary -Wno-unused-parameter,
-Wno-uninitialized, -Wno-sign-compare and -Wno-old-style-definition).
Fixes issue #4182.
Configurable via MICROPY_MODULE_GETATTR, disabled by default. Among other
things __getattr__ for modules can help to build lazy loading / code
unloading at runtime.
Configurable via MICROPY_PY_BUILTINS_STR_COUNT. Default is enabled.
Disabled for bare-arm, minimal, unix-minimal and zephyr ports. Disabling
it saves 408 bytes on x86.
1. Return correct error code for non-blocking vs timed out socket
(POSIX returns EAGAIN for both, we want ETIMEDOUT in case of timed
out socket). To achieve this, blocking/non-blocking flag is added
to the mp_obj_socket_t, to avoid issuing fcntl() syscall each time
EAGAIN occurs. (mp_obj_socket_t used to be 8 bytes, having some room
in a standard 16-byte alloc block.)
2. Handle socket.settimeout(0) properly - in Python, that means
non-blocking mode, but SO_RCVTIMEO/SO_SNDTIMEO of 0 is infinite
timeout.
3. Overall, make sure that socket.settimeout() call switches blocking
state as expected.
Prior to this commit the USB CDC used the USB start-of-frame (SOF) IRQ to
regularly check if buffered data needed to be sent out to the USB host.
This wasted resources (CPU, power) if no data needed to be sent.
This commit changes how the USB CDC transmits buffered data:
- When new data is first available to send the data is queued immediately
on the USB IN endpoint, ready to be sent as soon as possible.
- Subsequent additions to the buffer (via usbd_cdc_try_tx()) will wait.
- When the low-level USB driver has finished sending out the data queued
in the USB IN endpoint it calls usbd_cdc_tx_ready() which immediately
queues any outstanding data, waiting for the next IN frame.
The benefits on this new approach are:
- SOF IRQ does not need to run continuously so device has a better chance
to sleep for longer, and be more responsive to other IRQs.
- Because SOF IRQ is off, current consumption is reduced by a small amount,
roughly 200uA when USB is connected (measured on PYBv1.0).
- CDC tx throughput (USB IN) on PYBv1.0 is about 2.3 faster (USB OUT is
unchanged).
- When USB is connected, Python code that is executing is slightly faster
because SOF IRQ no longer interrupts continuously.
- On F733 with USB HS, CDC tx throughput is about the same as prior to this
commit.
- On F733 with USB HS, Python code is about 5% faster because of no SOF.
As part of this refactor, the serial port should no longer echo initial
characters when the serial port is first opened (this only used to happen
rarely on USB FS, but on USB HS is was more evident).
For s132 and s140, GAP_ADV_MAX_SIZE was currently set to
BLE_GATT_ATT_MTU_DEFAULT, which is 23. The correct value
should have been 31, but there are no define for this in
the s132/s140 header files as for s110.
Updating define in ble_drv.c to the correct value of 31.
The macros are MICROPY_HEAP_START and MICROPY_HEAP_END, and if not defined
by a board then the default values will be used (maximum heap from SRAM as
defined by linker symbols).
As part of this commit the SDRAM initialisation is moved to much earlier in
main() to potentially make it available to other peripherals and avoid
re-initialisation on soft-reboot. On boards with SDRAM enabled the heap
has been set to use that.
Add some more POSIX compatibility by adding a d_type field to the
dirent structure and defining corresponding macros so listdir_next
in the unix' port modos.c can use it, end result being uos.ilistdir
now reports the file type.
This will allow to e.g. implement HTTP Digest authentication.
Adds 540 bytes for x86_32, 332 for arm_thumb2 (for Unix port, which already
includes axTLS library).
This commit adds the math.factorial function in two variants:
- squared difference, which is faster than the naive version, relatively
compact, and non-recursive;
- a mildly optimised recursive version, faster than the above one.
There are some more optimisations that could be done, but they tend to take
more code, and more storage space. The recursive version seems like a
sensible compromise.
The new function is disabled by default, and uses the non-optimised version
by default if it is enabled. The options are MICROPY_PY_MATH_FACTORIAL
and MICROPY_OPT_MATH_FACTORIAL.
Configuring clocks is a critical operation and is best to avoid when
possible. If the clocks really need to be reset to the same values then
one can pass in a slightly higher value, eg 168000001 Hz to get 168MHz.
This ensures that on first boot the most optimal settings are used for the
voltage scaling and flash latency (for F7 MCUs).
This commit also provides more fine-grained control for the flash latency
settings.
Power and clock control is low-level functionality and it makes sense to
have it in a dedicated file, at least so it can be reused by other parts of
the code.
On F7s PLLSAI is used as a 48MHz clock source if the main PLL cannot
provide such a frequency, and on L4s PLLSAI1 is always used as a clock
source for the peripherals. This commit makes sure these PLLs are
re-enabled upon waking from stop mode so the peripherals work.
See issues #4022 and #4178 (L4 specific).
Changes made:
- make use of MP_OBJ_TO_PTR and MP_OBJ_FROM_PTR where necessary
- fix shadowing of index variable i, renamed to j
- fix type of above variable to size_t to prevent comparison warning
- fix shadowing of res variable
- use "(void)" instead of "()" for functions that take no arguments
This part is functionally similar to STM32F767xx (they share a datasheet)
so support is generally comparable. When adding board support the
stm32f767_af.csv and stm32f767.ld should be used.
If DTTOIF() macro is not defined, the code refers to MP_S_IFDIR, etc.
symbols defined in extmod/vfs.h, so should include it.
This fixes build for Android.
The HAL DMA functions enable SDMMC interrupts before fully resetting the
peripheral, and this can lead to a DTIMEOUT IRQ during the initialisation
of the DMA transfer, which then clears out the DMA state and leads to the
read/write not working at all. The DTIMEOUT is there from previous SDMMC
DMA transfers, even those that succeeded, and is of duration ~180 seconds,
which is 0xffffffff / 24MHz (default DTIMER value, and clock of
peripheral).
To work around this issue, fully reset the SDMMC peripheral before calling
the HAL SD DMA functions.
Fixes issue #4110.
The flash-IRQ handler is used to flush the storage cache, ie write
outstanding block data from RAM to flash. This is triggered by a timeout,
or by a direct call to flush all storage caches.
Prior to this commit, a timeout could trigger the cache flushing to occur
during the execution of a read/write to external SPI flash storage. In
such a case the storage subsystem would break down.
SPI storage transfers are already protected against USB IRQs, so by
changing the priority of the flash IRQ to that of the USB IRQ (what is
done in this commit) the SPI transfers can be protected against any
timeouts triggering a cache flush (the cache flush would be postponed until
after the transfer finished, but note that in the case of SPI writes the
timeout is rescheduled after the transfer finishes).
The handling of internal flash sync'ing needs to be changed to directly
call flash_bdev_irq_handler() sync may be called with the IRQ priority
already raised (eg when called from a USB MSC IRQ handler).
MCUs that have a PLLSAI can use it to generate a 48MHz clock for USB, SDIO
and RNG peripherals. In such cases the SYSCLK is not restricted to values
that allow the system PLL to generate 48MHz, but can be any frequency.
This patch allows such configurability for F7 MCUs, allowing the SYSCLK to
be set in 2MHz increments via machine.freq(). PLLSAI will only be enabled
if needed, and consumes about 1mA extra. This fine grained control of
frequency is useful to get accurate SPI baudrates, for example.
A recent version of arm-none-eabi-gcc (8.2.0) will warn about unused packed
attributes in USB_WritePacket and USB_ReadPacket. This patch suppresses
such warnings for this file only.
The aim here is to have spi.c contain the low-level SPI driver which is
independent (not fully but close) of MicroPython objects and methods, and
the higher-level bindings are separated out to pyb_spi.c and machine_spi.c.
Among other things, this requires putting bootloader object files in to
their relevant .a archive, so that they can be correctly referenced by the
ESP IDF's linker script.
- Allow configuration by a board of autorefresh number and burst length.
- Increase MPU region size to 8MiB.
- Make SDRAM region cacheable and executable.
"coverage" build uses different BUILD directory comparing to the normal
build. Previously, any build picked up libaxtls.a from normal build's
directory, but that was fixed recently. So, for each build, we must
build axtls explicitly.
This fixes Travis build in particular.
Use overrideable properties instead of hardcoding the use of the
default cl executable used by msvc toolsets. This allows using
arbitrary compiler commands for qstr header generation.
The CLToolExe and CLToolPath properties are used because they are,
even though absent from any official documentation, the de-facto
standard as used by the msvc toolsets themselves.
Requesting a baudrate of X should never configure the peripheral to have a
baudrate greater than X because connected hardware may not be able to
handle higher speeds. This patch makes sure to round the prescaler up so
that the actual baudrate is rounded down.
Prior to this patch, if VBAT was read via ADC.read() or
ADCAll.read_channel(), then it would remain enabled and subsequent reads
of TEMPSENSOR or VREFINT would not work. This patch makes sure that VBAT
is disabled for all cases that it could be read.
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.
The NRF52 define only covers nrf52832, so update the define checks
to use NRF52_SERIES to cover both nrf52832 and nrf52840.
Fixed machine_hard_pwm_instances table in modules/machine/pwm.c
This enables PWM(0) to PWM(3), RTCounter(2), Timer(3) and Timer(4),
in addition to NFC reset cause, on nrf52840.
When waking from stop mode most of the system is still in the same state as
before entering stop, so only minimal configuration is needed to bring the
system clock back online.
A recent version of arm-none-eabi-gcc (8.2.0) will warn about unused packed
attributes in USB_WritePacket and USB_ReadPacket. This patch suppresses
such warnings for this file only.
Works with pins declared normally in mpconfigboard.h, eg. (pin_XX), as well
as (pyb_pin_XX).
Provides new mp_hal_pin_config_alt_static(pin_obj, mode, pull, fn_type)
function declared in pin_static_af.h to allow configuring pin alternate
functions by name at compile time.
This mechanism will scale to to an arbitrary number of pollable objects, so
long as they implement the MP_STREAM_GET_FILENO ioctl. Since ussl objects
pass through ioctl requests transparently to the underlying socket object,
it will allow ussl sockets to be polled. And a user object with uio.IOBase
as a base could support polling.
The code was dereferencing 0x800 and loading a value from there, trying to
use a literal value (not address) defined in the linker script
(_ram_fs_cache_block_size) which was 0x800.
Adding MICROPY_FATFS as makefile flag in order to explicitly
include oofatfs files to be compiled into the build.
The flag is set to 0 by default. Must be set in addition to
MICROPY_VFS and MICROPY_VFS_FAT in mpconfigport.h.
Temporarly solving the issue of
"differ from the size of original declaration [-Werror=lto-type-mismatch]
until linker is fixed in upcomming release of gcc.
Bug is reported by others, and will be fixed in next version of arm-gcc.
However, this patch makes it possible to use modmusic and modimage
with current compilers.
Alternativly, the code can be compiled with LTO=0, but uses valuable 9K
more on this already squeezed target (microbit).
Support added for s132/s140 v6 in linker scripts and boards.
Support removed for s132 v2/3/5.
Download script updated to fetch new stacks and removed the
non-supported ones.
ble_drv.c updated to only handle s110 v8, and s132/s140 v6.
ubluepy updated to continue scanning after each individual scan
report reported to the module to keep old behaviour of the
Scanner class.
This patch generalize the feather52 target to be a board without
an in-built Bluetooth stack or bootloader giving all flash memory to
micropython code.
This way the feather52 target can run any supported Bluetooth LE
stack the port supports for other nrf52832 targets. Hence, this
make Makefiles/linker scripts and BLE driver support easier
to maintain in the future.
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)
Cleaning up use of "pyb" module.
Moving the file to a new folder and updating the
makefile accordingly. New module created called
"board" to take over the functionality of the legacy
"pyb" module.
Updating outdated documentation referring to pyb.Pin,
to now point to machine.Pin.
As EasyDMA variant of SPI(M) might clock out an additional byte
in single byte transactions this patch moves the nrf52832 to
use SPI and not SPIM to get more stable data transactions.
Ref: nrf52832 rev2 errata v1.1, suggested workaround is:
"Use the SPI module (deprecated but still available) or
use the following workaround with SPIM ..."
Current nrfx SPIM driver does not contain this workaround,
and in the meanwhile moving back to SPI fixes the issue.
Also, tabbing the nrfx_config.h a bit to make it more readable.
This patch moves the check of SPI configuration before
including any SPI header files. As targets might disable SPI
support, current code ends up in including SPIM if not SPI
is configured. Hence, this is why the check whether the module is
enabled should be done before including headers.
dfu-gen .PHONY target is run unconditionally as first build
target when included, and might fail if the hex file is not
yet generated.
To prevent this, the dfu-gen and dfu-flash targets are moved
to the main Makefile and only exposed if feather52 is the
defined BOARD.
Update configuration define from
MICROPY_HW_HAS_BUILTIN_FLASH to MICROPY_MBFS.
MICROPY_MBFS will enable the builtin flash as
part of enabling the micro:bit FS.
Clang understands only -fshort-enums, not --short-enums. As
--short-enums isn't even mentioned in the gcc man page, I think this
alias exists more for backwards compatibility.
Removing unused nrf52832_512k_64k_s132_5.0.0.ld.
Adding new linker script s132_5.0.0 following new
linker script scheme.
Updating ble_drv.c to handle de-increment of
outstanding tx packets on hvx for s132 v5.
After nrfx 1.0.0 a new macro was introduced to do a common
hardware timeout. The macro function triggers a counter of
retries or a timeout in us. However, in many cases, like in
nrfx_adc.c the timeout value is set to 0, leading to a infinite
loop in mp_hal_delay_us. This patch prevents this from happening.
Path of error:
nrfx_adc.c -> NRFX_WAIT_FOR -> NRFX_DELAY_US -> mp_hal_delay_us.
This patch also opens up for all arguments to be set as positional
arguments such that an external user of the make_new function can set
provide all parameters as positional arguments.
machine/i2c already uses mp_hal_get_pin_obj which
points to pin_find function in order to locate correct
pin object to use.
The pin_find function was recently updated to also
being able to locate pins based on an integer value,
such that pin number can be used as argument to object
constructors.
This patch modfies and uniforms pin object lookup for
SPI, music and pwm.
Renaming config for enabling random module with hw
random number generator from MICROPY_PY_HW_RNG to
MICROPY_PY_RANDOM_HW_RNG to indicate which module it
is configuring.
Also, disabling the config by default in mpconfigport.h.
Adding the enable of RNG in all board configs.
Moving ifdef in modrandom, which test for the config being
set, earlier in the code. This is to prevent un-necessary
includes if not needed.
Increase the maximum number of queued notifications from 1 to 6. This
massively speeds up the NUS console - especially when printing large
amounts of text. The reason is that multiple transfers can be done in a
single connection event, in ideal cases 6 at a time.
This patch moves all nrf52 targets to use SPIM backend
for SPI which features EasyDMA. The main benefit of doing
this is to utilize the SPIM3 on nrf52840 which is
EasyDMA only peripheral.
This patch ads irq method to the pin object. Handlers
registered in the irq method will be kept as part of the
ROOT_POINTERS.
In order to resolve which pin object is the root of the
IRQ, the pin_find has been extended to also be able to
search up Pin objects based on mp_int_t pin number.
This also implies that the Pin.new API is now also supporting
creation of Pin objects based on the integer value of the
pin instead of old style mandating string name of the Pin.
All boards have been updated to use real pin number from
0-48 instead of pin_Pxx for UART/SPI and music module pins.
UART/SPI/modmusic has also been updated to use pin number
provided directly or look up the Pin object based on the
integer value of the pin (modmusic).
Pin generation has been updated to create a list of pins, where
the board/cpu dicts are now refering to an index in this list
instead of having one const declaration for each pin. This new
const table makes it possible to iterate through all pins generated
in order to locate the correct Pin object.
In order to be able to support GPIO1 port on nrf52840
the port has been removed from the Pin object.
All pins on port1 will now be incrementally on top of
the pin numbers for gpio0. Hence, Pin 1.00 will become
P32, and Pin 1.15 will become P47.
The modification is done to address the new gpio HAL
interface in nrfx, which resolves the port to be
configured base on a multiple of 32.
The patch also affects the existing devices which does
not have a second GPIO port in the way that the
port indication A and B is removed from Pin generation.
This means that the port which was earlier addressed
as PA0 is now P0, and PA31 is P31.
Also, this patch removes the gpio member which earlier
pointed to the perihperal GPIO base address. This is not
needed anymore, hence removed.
With all the variation in chips and boards it's tedious to copy and
redefine linker scripts for every option. Making linker scripts more
modular also opens up more possibilities, like enabling/disabling the
flash file system from the Makefile - or even defining it's size from a
Makefile argument (FS_SIZE=12 for a 12kB filesystem if tight on space).
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
When compiling for microbit with LTO=0, a compiler error occurs due to
'ms' variable in the microbit_sleep function has not been initialized.
This patch initialize the variable to 0.
The nrf51x22_256k_16k_s110_8.0.0.ld had a stack size of only 1kB, which
is way too low. Additionally, the indicated _minimum_stack_size (set at
2kB for that chip) isn't respected.
This commit sets the heap end based on the stack size (heap end = RAM
end - stack size) making it much easier to configure.
Additionally, the stack/heap size of nrf52 chips has been set to a more
sane value of 8kB.
Leave it enabled by default on all targets.
This is only possible when using UART-over-BLE (NUS) instead of the
default hardware peripheral. The flash area saved is quite substantial
(about 2.2KB) so this is useful for custom builds that do not need UART.
Feather52 target which is using SD s132 v.2.0.1 cannot compile
due to variable containing RAM start address is not used.
This patch enables the correct sd_ble_enable variant for this SD.
Similar commit to this one:
6e56e6269f
When .text + .data oveflow available flash, the linker may not show an
error. This change makes sure .data is included in the size calculation.
This frees 128 bytes of .bss RAM on the nRF51, at the cost of possibly
more expensive GC cycles. Leave it as-is on the nRF52 as that chip has a
lot more RAM.
This is also done in the micro:bit:
a7544718a7/inc/microbit/mpconfigport.h (L6)
* ports/nrf/boards: Adding linker script for nrf52832 using BLE stack s132 v.5.0.0.
* ports/nrf/drivers/bluetooth: Updating makefile to add BLE_API_VERSION=4 if s132 v5.0.0 is used.
* ports/nrf/drivers/bluetooth: Updating BLE stack download script to also download S132 v5.0.0.
* ports/nrf/drivers/bluetooth: Updating ble_drv.c to handle BLE_API_VERSION=4 (s132 v5.0.0).
* ports/nrf/boards: Updating linker script for nrf52832 with s132 v.5.0.0 bluetooth stack.
* ports/nrf/drivers/bluetooth: Removing commented out code in ble_drv.c
* ports/nrf/drivers/bluetooth: Updating define of GATT_MTU_SIZE_DEFAULT for SD132v5 to be defined using the new name defined in the SD headers in a more generic way.
* ports/nrf/drivers/bluetooth: Cleaning up use of BLE_API_VERSION in the ble_drv.c. Also considering s140v6 API, so not all has been changed to >= if API version 3 and 4 in combo is used. New s140v6 will differ on these, and add a new API not compatible with the API for 3 and 4.
- Rename microbit_module_init to board_module_init0 which is the generic
board module init function.
- Add low priority callback registration of display tick handler in the
module init function.
- Rename init function to ticker_init0.
- Implement ticker_register_low_pri_callback (recycle of unused
set_low_priority_callback function which was unimplemented).
- Add support for registering 2 low pri callbacks. For now, one intended
for microbit display, and one for modmusic.
* ports/nrf: Add micro:bit filesystem.
This filesystem has been copied from BBC micro:bit sources [1] and
modified to work with the nRF5x port.
[1]: https://github.com/bbcmicrobit/micropython/blob/master/source/microbit/filesystem.c
* ports/nrf/modules/uos: Make listdir() and ilistdir() consistent.
This removes the optional direcotry paramter from ilistdir(). This is
not consistent with VFS, but makes more sense when using only the
microbit filesystem.
Saves about 100 bytes.
* ports/nrf/modules/uos: Add code size comment.
* Remove FLASH_ISR and merge .isr_vector into FLASH_TEXT. This saves
some code space, especially on nRF52 devices.
* Reserve space for nonvolatile storage of data. This is the place for
a filesystem (to be added).
This commit is a combination of about 802 commits from the initial stages
of development of this port, up to and including the point where the code
was moved to the ports/nrf directory. The following is a digest of the
original commits in their original order (most recent listed first),
grouped where possible by author. The list is here to give credit for the
work and provide some level of traceability and accountability. For the
full history of development please consult the following repository:
https://github.com/tralamazza/micropython
Unless otherwise explicitly state in a sub-directory or file, all code is
MIT licensed and the relevant copyright holders are listed in the
comment-header of each file.
Glenn Ruben Bakke <glennbakke@gmail.com>
ports/nrf: Moving nrf51/52 port to new ports directory
nrf: Aligning with upstream the use of nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, ...)
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf/modules/random: Backport of microbit random number generator module
Backport of micro:bit random module.
Plugged into the port as a general random module for all nrf51/nrf52 targets. Works both with and without Bluetooth LE stack enabled.
Behavioral change: seed() method has been removed, as the use of RNG peripheral generates true random sequences and not pseudo-random sequences.
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf/hal/rng: Adding HAL driver for accessing RNG peripheral
The driver also takes care of calling the Bluetooth LE stack for random values if the stack is enabled. The reason for this is that the Bluetooth LE stack take ownership of the NRF_RNG when enabled. Tolerate to enable/disable on the fly, and will choose to use direct access to the peripheral if Bluetooth LE stack is disabled or not compiled in at all.
Driver has been included in the top Makefile, and will not be compiled in unless nrf51_hal_conf.h/nrf52_hal_conf.h defines HAL_RNG_MODULE_ENABLED (1).
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf/boards: Adding Arduino Primo board support (#88)
* nrf: Adding Arduino Primo board support
* nrf: Adding arduino_primo to target boards table in readme.md
* nrf/boards: Activating pyb.LED module for arduino_primo board.
* nrf/boards: Removing define not needed for arduino_primo
Updating arduino_primo board mpconfigboard.h. Removing a define
that was wrongly named. Instead of renaming it, it was removed as
it was never used.
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf: Add support for floating point on nrf52 targets.
Duplicating pattern for detecting location of libm, libc and libgcc
from teensy port. Activating MICROPY_FLOAT_IMPL (FLOAT) for nrf52 targets
and adding libs into the compile. For nrf51 targets it is still set to
NONE as code grows to much (about 30k).
Some numbers on flash use if MICROPY_FLOAT_IMPL is set to
MICROPY_FLOAT_IMPL_FLOAT and math libraries are enabled (lgcc, lc, lm).
nrf51:
======
without float support:
text data bss dec hex filename
144088 260 30020 174368 2a920 build-pca10028/firmware.elf
with float support:
text data bss dec hex filename
176228 1336 30020 207584 32ae0 build-pca10028/firmware.elf
nrf52:
======
without float support:
text data bss dec hex filename
142040 356 36236 178632 2b9c8 build-pca10040/firmware.elf
with float support:
text data bss dec hex filename
165068 1436 36236 202740 317f4 build-pca10040/firmware.elf
Daniel Tralamazza <daniel@tralamazza.com>
nrf: add a note for running the nrfjprog tool on Linux, and touch up the make sd comment
nrf: clean compiler warnings
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf/drivers/bluetooth: Speedup Bluetooth LE REPL.
Updating mp_hal_stdout_tx_strn_cooked to pass on the whole string
to mp_hal_stdout_tx_strn instead of passing byte by byte.
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf: Use the name MicroPython consistently in comments
nrf5: Updating readme with BLE REPL
Ben Whitten <ben.whitten@lairdtech.com>
nrf/boards: Add DVK BL652 from Laird
To build run 'make BOARD=dvk_bl652 SD=s132'
To flash with jlink run 'make sd BOARD=dvk_bl652 SD=s132'
This will remove the existing licences in the bl652
Ben Whitten <ben.whitten@lairdtech.com>
nrf/drivers/bluetooth: Allow s132 to use LFCLK
nrf: Add nordic sd folders to the .gitignore
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf/boards: Updating microbit pin mapping for SPI and I2C.
nrf/boards: Correcting feather52 I2C SDA pin assigned to the board.
nrf/examples: Update ssd1306 modification example to import correct class.
nrf/boards: Activate RTC and Timer module and HAL on pca10056. Also swapping out UART with UART DMA variant on this target board.
nrf/boards: Activate RTC, Timer, I2C, ADC and HW_SPI module and HAL on pca10031.
nrf/boards: Activate RTC, Timer, I2C and ADC module and HAL on pca10001.
nrf/boards: Adding RTC and Timer module and HAL to pca10000.
nrf: Updating README.
nrf: Removing unused font header.
Daniel Tralamazza <daniel@tralamazza.com>
rename temperature example
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/examples: Adding ubluepy peripheral example that works across nrf51 and nrf52. The example uses Environmenting Sensing Service to provide the temperature characteristic. The temperature is fetched from the machine.Temp module. One note is that the example uses 1 LED which is not present on all boards.
nrf5/modules/ubluepy: Adding new event constant for gatts write (80) events from bluetooth stacks.
nrf5/hal/timer: Add support for fetching temperature if bluetooth stack is enabled.
nrf5/drivers/bluetooth: Make printf in 'ble_drv_service_add' function part of debug log.
Daniel Tralamazza <daniel@tralamazza.com>
implement #50
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/examples: Updating mountsd example with comment from deleted sdcard.py on how to wire SD directly to SPI.
nrf5/examples: Removing copy of sdcard.py also found in drivers/sdcard.
nrf5/examples: Removing copy of ssd1306 driver, creating a new class that overrides the needed function for i2c. Also adding some example usage in the comment in top of the file for both SPI and I2C variant.
nrf5/hal/gpio: Updating toggle inline function to work correctly, currently only used by LED module.
nrf5/examples: Renaming servo.py to nrf52_servo.py as it is only implemented machine.PWM for nrf52.
nrf5/freeze: Adding generic example to freeze. Hello world with board name as parameter.
nrf5/examples: Moving nrf52 specific HW example from freeze to examples to replace test.py with a more generic example.
nrf5: Update pyb module, and led module to only be compiled in if MICROPY_HW_HAS_LED is set to 1.
nrf5/boards: Updating boards with correct LED count. Also adding new flag, MICROPY_HW_HAS_LED, to select whether the board has LED's at all. If not, this will unselect LED module from being compiled in.
nrf5/boards: Updating pca10040 board header to set the LED count.
nrf5: Generalize script setting LED(1) on to be applied only when there are leds present on the board.
nrf5: Updating mpconfigport.h to set default values for MICROPY_HW_LED_COUNT (0) and MICROPY_HW_LED_PULLUP (0).
nrf5/boards/feather52: Update s132 target makefile with dfu-gen and dfu-flash. This enables feather52 with Bluetooth LE. Features to be configured in bluetooth_conf.h.
nrf5/boards/feather52: Add SERIAL makeflag if dfu-flash target is used.
nrf5: Updating readme.md file based on review comments.
nrf5: Update help.c with documentation of CTRL-A and CTRL-B to enter and exit raw REPL mode.
nrf5: Updating main.c to support RAW REPL.
Update README.md
nrf5/modules/music: Updating pitch method to also use configured pin from mpconfigboard.h if set, in the case of lacking kwarg for pin. Also removing some commented out arguments to remove some confusion in the argument list. Done for both play() and pitch().
nrf5/modules/music: Correct parameter checking of pin argument to deside whether to use MUSIC_PIN define or throw an error. If MUSIC_PIN define is configured the pin argument to music module play() can be elided.
nrf5/modules/machine: Update timer init to set default IRQ priority before initializing Timer instance.
nrf5/hal/timer: Update timer hal to use value provided in init to configure the irq_priority.
nrf5/modules/machine: Reserving timer0 instance for bluetooth if compiled in. Leaving timer1 and timer2 for application. Note that music module soft-pwm will also occupy timer1 if enabled.
nrf5/modules/machine: Updating timer module to use new hal. Adding new parameters to the init to set period, mode and callback.
nrf5/hal/timer: Implementing hal_timer to 1us prescaler. Multiplier inside to get to millisecond resolution. Callback must be registered before starting a timer.
nrf5: Makefile cleanup. Removing duplicate include and unused netutils.c used by BLE 6lowpan network which has been removed for now.
nrf5/modules/machine: Indention fix in uart module.
nrf5/modules/machine: Removing unused code from uart module.
nrf5/hal/rtc: Updating hal driver to calculate prescaler a bit more verbose. Using 1 second interval ticks.
nrf5/modules/machine: Fixing type in RTC.
nrf5/modules/machine: Update rtc init to set default IRQ priority before initializing RTC instance.
nrf5/hal/rtc: Aligning RTC (real-time counter) HAL driver with Timer HAL driver. To make api's symetric. Also updating modules/rtc to get aligned with new HAL api.
nrf5/drivers/bluetooth: Moving stop condition initialization before call to bluetooth stack write function is done, to make sure that its not overwritten after reception of the write event in case of with_response writes.
nrf5/drivers/bluetooth: Removing duplicate static variable declaration.
nrf5/modules/ubluepy: Updating characteristic write method to take in an additional keyword, 'with_response'. Default value is False. Only activated in central role.
nrf5/drivers/bluetooth: Updating ble_drv_attr_c_write with possibility to do client write with response. Blocking call.
nrf5/examples: Adding some notes on which pin layout that has been used in the seeed_tft.py ILI9341 driver for driving the display.
nrf5/examples: Shorten name on seeedstudio_tft_shield_v2.py to seeed_tft.py.
nrf5/examples: Updating ili9341 example to use new Frambuffer object instead of legacy Framebuffer1.
nrf5/examples: Removing seeed.py which used a lcd mono framebuffer has been removed.
Matt Trentini <matt.trentini@gmail.com>
Adding a README for the nRF5 port
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/examples: Updating documentation in SDCard module example. Correcting typo and adding SD card wireing documentation for direct SPI connection.
nrf5/modules/pin: Adding on() and off() methods to Pin object to be forward compatible with upstream master. Legacy high() and low() methods are kept.
nrf5/modules/spi: Remove pyb abstraction from SPI module, as there was a bug in transfer of bytes due to casting errors. The update removes the pyb_spi_obj_t wrapper going directly on the machine_hard_spi_obj_t as base for machine SPI objects. SDCard mounting is also tested.
nrf5/drivers/bluetooth: Enable ubluepy central by default if running nrf52/s132 bluetooth stack. Maturity of the module is pretty OK now.
nrf5/boards/feather52: Updating pins.csv for the feather52 board.
nrf5/boards/feather52: Updating LED pull to low.
nrf5/boards/feather52: Update SPI pinout.
nrf5/main: Move initializaton of modmusic to the module itself. Upon init of the module, the hardware, pwm and ticker will be started. Could be moved back to main if pwm or ticker should be shared among more modules and have to be initialized more global.
nrf5/modules/machine/timer: If timer is used in combination with SOFT_PWM (implicitly use of ticker.c) guard the Timer1 instance from being instantiated trough python timer module. Also disable implementation of the HAL IRQ handler which is for now explicitly implemented in ticker.c for Timer1.
nrf5/modules/music: Update ticker and modmusic to share global ticks counter as a volatile variable. Use Timer1 hardware peripheral instead of instance 0. Timer0 is not free if used in combination with a bluetooth stack. Update IRQ priority to levels that are compatible in use with a bluetooth stack for both nrf51 and nrf52. Apply nrf51 PAN fixes for Timer1 instead of original Timer0.
nrf5/drivers/bluetooth: Updating bluetooth driver to initialize nrf_nvic_state_t struct during declaration of the global variable instead of explicit memset.
nrf5/hal/irq: Adding wrappers for handling nvic calls when Bluetooth LE stack is enabled.
nrf5/modules/machine: Updating IRQ levels in SPI with IRQ priorities compatible with Bluetooth stacks.
nrf5/device: Remove old startup files in asm, which has now been replaced with c-implementation.
nrf5: Update Makefile to add c-implementation of startup scripts instead of the .s files.
nrf5/device: Adding startup files in .c to replace current asm versions.
nrf5/examples: Tuning Bluetooth LE example controller python script after testing out the example live. Motor speed of 100 was not enought to lift the airplane. Also turning was hard without setting higher angle values. The new values are just guessed values. However, the flying experience was good.
nrf5/hal/irq: Adding include of nrf_nvic.h if s132 bluetooth stack is used to resolve IRQ function wrappers on newer bluetooth stacks.
nrf5/drivers/ticker: Removing unused code.
nrf5/examples: Adding music example. Only working if bluetooth stack is not enabled.
nrf5/boards/microbit: Disable music and softPWM as there are some issues with the ticker.
nrf5: Adding -fstack-usage flag to gcc CFLAGS to be able to trace stack usage on modules.
nrf5/drivers/ticker: Removing LowPriority callback from nrf51 as there is only one SoftwareIRQ free if bluetooth stack is enabled. Also setting new IRQ priority on SlowTicker to 3 instead of 2, to interleave with bluetooth stack if needed. Updating all NVIC calls to use hal_irq.h defined static inlines instead of direct access.
nrf5/hal/irq: Adding IRQ wrappers if Bluetooth Stack is present.
nrf5: Facilitate option to configure away the modble if needed. Enabled if MICROPY_PY_BLE config is enabled in bluetooth_conf.h.
nrf5/boards/microbit: Enable music module by default. However, timer and rtc module has to be disabled. Bluetooth support broken. Optimization needed.
nrf5/modules/machine: Quickfix. Update timer object to not allow instanciation of Timer(0) if SOFT_PWM is enabled by board.
nrf5/hal/timer: Quickfix. Disable IRQ handler if SOFT_PWM is configured to be enabled. Ticker driver has in current driver a seperate IRQ handler for this timer instance.
nrf5/drivers/ticker: Add compile config guard in ticker.c to only include the driver if SOFT_PWM is configured in by board.
nrf5/drivers/softpwm: Renaming pwm_init to softpwm_init to not collide on symbol name with pwm_init in nrf52 machine PWM object.
nrf5: Add modmusic QSTR definition of notes to qstrdefsport.h.
nrf5: Update Makefile to include ticker.c and renamed softpwm. Updating also include paths to include modules/music and drivers/.
nrf5: Adding include of modmusic.h in main.c.
nrf5: Call microbit_music_init0() if enabled in main.c.
nrf5/modules/music: Expose public init function for music module.
nrf5/modules/music: Update modmusic to use updated includes. Add extern ticks. Add function which implements initialization of pwm and ticker, register ticker callback, and start the pwm and ticker. This corresponds to microbit port main.cpp init.
nrf5/drivers/softpwm: Enable use of ticker in softpwm driver.
nrf5/drivers/ticker: Adding ticker.c/.h from microbit port.
nrf5/drivers/pwm: Renaming pwm.c/.h to softpwm.c/.h
nrf5/drivers/pwm: Expose pwm_init() as public function.
nrf5/modules/ubluepy: Making peripheral conn_handle volatile. Upon connection event, the variable is accessed in thread mode. However, the main-loop is blocking on conn_handle != 0xFFFF. If this is not volatile, optimized code will not exit the loop.
nrf5/drivers/bluetooth: As callback functions are in most usecases are set to NULL upon last event to get public API function out of blocking mode, these function pointers has to be set as volatile, as they are updated to NULL in interrupt context, but read in blocking main-thread.
nrf5/examples: Fixing overlapping function names and variable names inside the object. Also removing some print statements. Tuning max angle from -7/7 to -25/25.
Glenn Ruben Bakke <glennbakke@gmail.com>
Powerup (#26)
* nrf5/examples: Adding python example template for PowerUp 3.0 Bluetooth LE controlled Paper Airplane.
* nrf5: Enable bluetooth le central while developing powerup 3.0 example.
* nrf5/examples: Backing up powerup 3.0 progress.
* nrf5/examples: Adding working example on how to control PowerUp 3.0 paper airplane using bluetooth le.
* nrf5/bluetooth: Disable central role.
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/modules/ubluepy: Correcting alignment of enum values in modubluepy.h.
nrf5/drivers/bluetooth: Add implementation of client attribute write without response.
nrf5/modules/ubluepy: Pass on buffer to write in characteristic write central mode.
nrf5/modules/ubluepy: Updating characteristic object write function to be role aware. Either peripheral or central (gatts or gattc). Adding dummy call to attr_c_write if central is compiled in. Still in progress to be implemented.
nrf5/drivers/bluetooth: Adding template function for attr_c_write.
nrf5/drivers/bluetooth: Renaming attr_write and attr_notify to attr_s_write and attr_s_notify to prepare for introduction of attribute write for gatt client.
nrf5/modules/ubluepy: Fixing type in ubluepy_peripheral.c.
nrf5/modules/ubluepy: Setting peripheral role upon advertise() or connect().
nrf5/drivers/bluetooth: Adding role member to peripheral object to indicate whether Peripheral object is Peripheral or Central role.
nrf5/modules/ubluepy: Continue characteristic discovery until nothing more is found during connect proceedure.
nrf5/drivers/bluetooth: Refactoring code to group statics for s130 and s132 into the same ifdef. Also adding two empty lines in discovery functions to make it more easy to read.
nrf5/drivers/bluetooth: Updating characteristic discovery to signal whether anything was found or not.
nrf5/modules/ubluepy: Continue primary service discovery until nothing more is found in connect proceedure.
nrf5/drivers/bluetooth: Updating primary service discovery api to take in start handle from where to start the service discovery. Also adjusting return parameter to signal whether anything was found or not.
nrf5/modules/ubluepy: Remove duplication GAP event handler registration in peripheral.connect().
Glenn Ruben Bakke <glennbakke@gmail.com>
Support address types (#18)
* nrf5/modules/ubluepy: Adding new enumeration of address types.
* nrf5/modules/ubluepy: Adding constants that can be used from micropython for public and random static address types.
* nrf5/modules/ubluepy: Adding support for optionally setting address type in Peripheral.connect(). Public address is used as default. Address types can be retrieved from 'constants'. Either constants.ADDR_TYPE_PUBLIC or constants.ADDR_TYPE_RANDOM_STATIC.
* nrf5/modules/ubluepy: Register central GAP event handler before issuing connect to a peripheral. Has to be done before connect() function as a connected event will be propergated upon successfull connection. The handler will set the connection handle which gets connect function out of the busy loop waiting for connection to succeed.
* nrf5/modules/ubluepy: Removing duplicate setting of GAP event handler in connect().
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/modules/ubluepy: Register central GAP event handler before issuing connect to a peripheral. Has to be done before connect() function as a connected event will be propergated upon successfull connection. The handler will set the connection handle which gets connect function out of the busy loop waiting for connection to succeed.
nrf5/modules/ubluepy: Fixing compilation bug of wrong variable name when registering gattc event handler in ublupy peripheral connect function (central mode).
nrf5/bluetooth: Updating makefiles with updated paths to bluetooth le components after moving files.
nrf5/bluetooth: Moving stack download script to drivers/bluetooth folder.
nrf5/bluetooth: Move bluetooth driver files to drivers/bluetooth. Move bluetooth stack download script to root folder.
nrf5/bluetooth: Guarding implementation against being linked in by surrounding it with BLUETOOTH_SD flag. Flag is only set if SD=<sdname> parameter is provided during make.
nrf5/bluetooth: Moving makefile include folder and source files of bluetooth driver, ble uart and ble module to main Makefile.
nrf5/bluetooth: Moving help_sd.h and modble.c to modules/ble.
nrf5/modules/machine: bugfix after changing to MP_ROM_PTR in machine module local dict.
nrf5: Syncing code with upstream master and converting all module and method tables to use MP_ROM macros. Also adding explicit casting of local dicts to (mp_obj_dict_t*).
nrf5/modules/timer: Fixing bug in timer_find(). Function allowed to locate index out of range and started to look up in config pointer (index == size of array).
nrf5/modules/timer: Remove test which is covered by timer_find() function in the line below.
nrf5/modules/timer: Adding locals dict table and adding start/stop template functions. Also adding constants for oneshot and periodic to locals dict.
nrf5/modules/timer: Adding timer module to modmachine.
nrf5/boards: Adding micro:bit default music pin definition. Also adding config flag for enabling pwm machine module.
nrf5/hal/timer: Adding start/stop template functions to hal_timer.h/.c
nrf5/Makefile: Adding drivers/pwm.c and modules/music files to the source file list.
nrf5/modules/music: Adding config guard in musictunes.c and adding import of mphal.h.
nrf5/modules/music: Including mphal.h before config guard in modmusic.c. Also changed name on config guard to MICROPY_PY_MUSIC. Missing PWM functions during linkage will show up if PWM module has not not configured.
nrf5/drivers/pwm: Including mphal.h before config guard in pwm.c.
nrf5: Updating mpconfigport.h to include music module as builtin. Adding new configuration for enabling music module. Activating MODULE_BUILTIN_INIT in order to run music module init function on import.
nrf5/modules/music: Backing up progress in music module.
nrf5/drivers/pwm: Updating soft PWM driver to only be included if SOFT_PWM config is set.
nrf5/hal/gpio: Add function to clear output register using a pin mask.
nrf5: Adding new configuration called MICROPY_PY_MACHINE_SOFT_PWM to mpconfigport.h. This config will enable software defined PWM using timer instead of using dedicated PWM hardware. Aimed to be used in nrf51 targets.
nrf5/boards: Removing PWM config set to 0 from pca10001 board. Config will later be re-introduced as SOFT_PWM variant.
nrf5/pwm: Updating config name of PWM to hardware PWM to prepare for introduction of soft variant.
nrf5/modules/music: Backing up progress in modmusic.
nrf5/modules/music: backing up porting progress in modmusic.c.
nrf5/modules/music: Commenting out backend function calls in modmusic.c to make module compile for now.
nrf5/modules/music: Updating music module to use pin_obj_t instad of microbit_pin_obj_t. Update include to drivers/pwm.h to resolve some undefined functions.
nrf5/modules/music: Removing c++ extern definition. Updating include list in modmusic.c. Removing module name from module struct.
nrf5/modules/music: Removing include of modmicrobit.h in musictunes.c.
nrf5/modules/music: Adding header to expose extern structs defined in musictunes.c
nrf5/drivers: Adding copy of microbit soft pwm.
nrf5/modules/music: Renaming microbitmusic files to modmusic/music.
nrf5/modules/music: Renaming microbit module to music.
nrf5/modules/microbit: Copying microbit music module to the port.
nrf5/modules/timer: Adding timer3 and timer4 to timer object in case of nrf52 target.
nrf5/modules/timer: Optimizing timer object structure and updating the module to use new hal_timer_init structures and parameters.
nrf5/hal/timer: Adding empty IRQ handlers for all timers.
nrf5/hal/timer: Changing hardcoded hal timer instance base to a lookup, so that IRQ num can be detected automatically without the need of using struct param on it. Size of binary does not increase when using Os.
nrf5: Updating example in main.c on how to execute string before REPL is set up, to allow for boards with two leds. Todo for later is to update this code such that it will skip this LED toggle when there are no leds defined. Or use an example not depending on LEDs.
nrf5/bluetooth: Updating Bluetooth LE stack download script to allow to be invoked from any parent folder. No need to change directory to bluetooth/ in order to get the correct download target folder position. Using the script location to determine the target folder.
nrf5/boards: Adding board target for feather52 using s132 v.2.0.1 application offset even if the device is not using softdevice. To be worked on later.
nrf5/boards: decrease size of ISR region from 4k to 1k in custom feather52 linker script to get some more flash space.
nrf5/boards: Updating feather52 mpconfigboard.h to use correct uart pins, flow control disabled. Also adjusting leds down to two leds.
nrf5/boards: Updating path to custom linker script for feather52 board.
nrf5/boards: Renaming bluefruit_nrf52_feather to feather52 to shorten down the name quite drastically.
nrf5/boards: Updating path to custom bluefruit feather linker script after renaming board folder.
nrf5/boards: Renaming bluefruit_feather to bluefruit_nrf52_feather as it also exist a m0 variant of the board name.
nrf5/boards: Updating mpconfigboard.h for bluefruit nrf52 feather with correct board, mcu and platform name.
nrf5/boards: Updating adafruit bluefruit nrf52 feather linker script to use 0x1c000 application offset.
nrf5/boards: Renaming custom linker script for bluefruit feather to reflect that the purpose of the custom linker script is DFU. The script is diverging from the generic s132 v2 linker script in the offset of the application.
nrf5/boards: Adding custom linker script for adafruit nrf52 bluefruit feather to be able to detect application upper boundry in flash. Pointing s132 mk file to use this new custom linker script instead of the generic s132 v2 linker script.
nrf5/boards: Adding linker script for nrf52832 s132 v.2.0.1.
nrf5/boards: Adding template board makefiles and configs for bluefruit nrf52 feather. Copied from pca10040 target board. Linker script reference updated to use s132 v2.0.1. Non-BLE enable build disabled for now. Board configuration for leds, uart etc has not been updated yet from pca10040 layout.
nrf5/bluetooth: Correcting typo in test where s132 API version is settled.
nrf5/bluetooth: Updating bluetooth le driver to compile with s132 v.2.0.1 stack.
nrf5/bluetooth: Add new compiler flag to signal API variants of the s132 bluetooth le stack. The version is derived from the major number of the stack name.
nrf5/bluetooth: Remove hardcoded softdevice version as this now comes as parameter from board makefile.
nrf5/boards: Updating makefiles using bluetooth stack to use updated linker script file names.
nrf5/boards: Renaming bluetooth stack linker scripts to reflect version of the stack.
nrf5/boards: adding some spaces in s132 makefile for pca10040.
nrf5/boards: Renaming linker script for nrf52832 using bluetooth stack such that it also holds the version number of the stack. Updating linkerscript using the target linker script.
nrf5/bluetooth: Add support for downloading s132_2.0.1 bluetooth stack.
nrf5/bluetooth: Switch over to downloaded bluetooth stacks from nordicsemi.com instead of getting them through the SDK's. This will facilitate download of s132 v2.0.0 later.
nrf5/bluetooth: Fixing bug found when testing microbit. Newly introduced advertisment data pointer was not cleared on nrf51 targets. Explicit set to NULL as no additional advertisment data is set. Raises a question on why the nrf51 static variable was not zero initialized. To be checked up.
nrf5: Removing SDK_ROOT parameter to Makefile. Bluetooth stacks should be downloaded using the download_ble_stack.sh. The script should be run inside the bluetooth folder to work properly.
nrf5/bluetooth: Adding back SOFTDEV_HEX as flash tools in main Makefile uses this to locate hex file.
nrf5/bluetooth: Including bluetooth stack version in folder name after download to be able to detect if stack has been updated.
nrf5/bluetooth: Updating Bluetooth LE stack download script.
nrf5/bluetooth: Adding bash script to automate download of bluetooth le stacks
nrf5/examples: Adding example to show how to use current PWM module to control servo motors.
nrf5/modules/machine: Updating PWM module with two new kwargs parameters. One for setting pulse with more fine grained. This value should not exceed the period value. Also, adding support for setting PWM mode, whether it is LOW duty cycle or HIGH duty cycle. By default, high to low is set (this could be changed).
nrf5/hal/pwm: Updating PWM implementation to support manually set duty cycle period. Pulse width has precidence over duty cycle percentage. Also adding support for the two configurable modes, high to low, and low to high, duty cycles.
nrf5/hal/pwm: Adding more configuration options to the PWM peripheral wrapper. Possibility to set pulse with manually, and also mode. The mode indicates whether duty cycle is low and then goes high, or if it is high and then go low. Added new type to describe the two modes.
nrf5: Adding hal_gpio.c to Makefile's source list.
nrf5/modules/machine: Updating Pin module to register a IRQ callback upon GPIO polarity change events.
nrf5/hal/gpio: Adding initial gpiote implementation to handle IRQ on polarity change on a gpio.
nrf5: Moving initialization of pin til after uart has been initialized for debugging purposes. This will make it possible to use uart to print out debug data when adding gpio irq handlers.
nrf5/hal/gpio: Adding some new structures and functions to register irq channels to gpio's using GPIOTE peripheral
nrf5/hal/gpio: Adding missing include.
nrf5/modules/machine: Style fix in pin object, indention.
nrf5/modules/machine: Adding placeholder for irq method to pin object class.
nrf5/modules/machine: Adding pin irq type and basic functions and structures.
nrf5/hal/gpio: Reintroducing gpio polarity toggle event to be able to reference the short form of adding high_to_low and low_to_high together.
nrf5/hal/gpio: Updating hal_gpio.h with some tab-fixes in order to make the file a bit consistent in style.
nrf5/hal/gpio: Removing toggle event from the enumeration as that will be a combination of the rising and falling together.
nrf5/modules/machine: Removing toggle event trigger as that will be a combination of the rising and falling together.
nrf5/modules/machine: Adding new constants to pin object for polarity change triggers using the enumerated values in hal_gpio.h.
nrf5/hal/gpio: Adding new enumeration for input polarity change events.
nrf5/hal: Moving hal_gpio functions, types and defines from mphalport.h to a new hal_gpio.h.
Revert "lib/netutils: Adding some basic parsing and formating of ipv6 address strings. Only working with full length ipv6 strings. Short forms not supported at the moment (for example FE80::1, needs to be expressed as FE80:0000:0000:0000:0000:0000:0000:0001)."
nrf5: Removing leftover reference to deleted display module.
nrf5/usocket: Removing network modules related to Bluetooth 6lowpan implementation as it depends on SDK libraries for now. Will be moved to seperate working branch.
nrf5: Removing custom display, framebuffer and graphics module to make branch contain core components instead of playground modules.
nrf5/modules/usocket: Updating import of netutils.h after upmerge with upstream master.
nrf5/bluetooth: Add some comment on the destination of the eddystone short-url.
nrf5/bluetooth: Updating Eddystone URL to point to https://goo.gl/x46FES which hosts the MicroPython WebBluetooth application which will be able to connect to the Bluetooth LE UART service of the device and create the REPL.
nrf5/bluetooth: Adding webbluetooth REPL template. Alternating advertisment of eddystone URL and UART BLE service every 500 ms. Adding new config parameter to bluetooth_conf.h to enable webbluetooth repl. Has to be configured in combination with BLE_NUS. Eddystone URL not pointing to a valid WebBluetooth application at the moment, but rather to micropython.org as a placeholder for now.
nrf5/modules/ubluepy: Adding method Peripheral object to stop any ongoing advertisment. Adding compile guard to only include advertise and advertise_stop if peripheral role is compiled in.
nrf5/bluetooth: Adding function to stop advertisment if onging
nrf5/modules/ubluepy: Adding support for starting advertisment from BLE UART REPL, by delaying registration of gatt/gatts and gattc handlers until needed in advertise or connect. If non connectable advertisment is selected, handlers in peripheral new is not anymore overriding the other peripheral instances which has set the callbacks.
nrf5/bluetooth: Adding possibility to configure whether advertisment should be connectable or not.
nrf5/bluetooth: Removing legacy advertise function in the bluetooth driver, which only did a hardcoded eddystone beacone advertisment.
nrf5/help: Updating ble module help description to also include the address method.
nrf5/bluetooth: Renaming the ble module method address_print() to address(), as it will now return a string of the resolved local address. Updating the function to create a string out the local address and return this.
nrf5/bluetooth: Update ble_drv_address_get to new api which pass in a address struct to fill by reference. Updating implementation to copy the address data. Also ensuring that the bluetooth stack has been enabled before fetching the address from the bluetooth stack.
nrf5/bluetooth: Adding new structure which can hold local address. Updating api prototype for ble_drv_address_get with a address structure by reference.
nrf5/bluetooth: Updating help text for ble module to also list up enabled() function which queries the bluetooth stack on whether it is enabled or not.
nrf5/bluetooth: Removing advertise from ble module. Removing help text as well.
nrf5/examples: Adding python eddystone example using ubluepy api.
nrf5/modules/ubluepy: Open up Peripheral advertise method to pass custom data to the bluetooth driver. Allowing method to allow kwargs only if no args is set. To support setting data kwarg only.
nrf5/modules/ubluepy: Adding new members to the ublupy advertisment parameters, to hold custom data payload if set.
nrf5/bluetooth: Cleaning up stack enable function, to not set device name twice. Also, adding support for setting custom advertisment data.
nrf5/modules/ubluepy: Adding compile guard for UBLUEPY_CENTRAL around the char_read() call to ble_drv_attr_c_read().
nrf5/bluetooth: Moving central code inside central bluetooth stack defines to make peripheral only code compile again.
nrf5/examples: Updating ubluepy scan example to use constant value from ubluepy instead of hardcoded value.
nrf5/examples: Adding example on how to use the ubluepy Scanner object in order to scan for a device name and find the address of the device. This can subsequently be used to perform a Central role connect() using the Peripheral object.
nrf5/modules/ubluepy: Turn all attributes (addr, addr_type and rssi) to method calls instead of using common .attr callback. Adding getScanData implementation, which parses the advertisment data and returns a list of tuples containing (ad_type, desc, value). Description is generated by peeking into the ad_types local dicts map table, and do a reverse lookup on the value to find the QSTR.
nrf5/modules/ubluepy: Adding ad_types constants in new object. Linking in ad_types object into the ubluepy.constants local dict.
nrf5/modules/ubluepy: Expose ubluepy constant objects as externs in modubluepy.h to be able to get access to the local dict tables in order to do a reverse lookup on value to resolve QSTR from external modules in c.
nrf5/modules/ubluepy: Upon advertisment event, also store the advertisment data.
nrf5/modules/ubluepy: Adding callback function to handle read response if gatt client has issued a read request. Also adding method for returning the uuid instance from the object.
nrf5/modules/ubluepy: Adding value data member to the characteristic object. This can hold the value data when gatt client perform a read and value has to be transferred between interrupt and main thread.
nrf5/bluetooth: Updating bluetooth driver to support GATT client read of a characteristic value. Data passed to caller in interrupt context, and copy has to be performed. The function call is itself blocking.
nrf5/modules/ubluepy: Adding uuid() function to service object to return UUID instance of the service.
nrf5/modules/ubluepy: Adding binVal() function to the ubluepy UUID object. For now returning the uint16_t value of the UUID as a small integer.
nrf5/modules/ubluepy: Adding dummy function call to ble_drv_attr_c_read.
nrf5/bluetooth: Adding new api for reading attribute as gatt client. Renaming old ble_drv_attr_read function to ble_drv_attr_s_read to indicate the server role.
nrf5/bluetooth: Adding event handling cases for gatt client read, write and hvx events.
nrf5/modules/ubluepy: Tab-fix
nrf5/modules/ubluepy: Updating peripheral object to handle characteristic discovery (central mode).
nrf5/modules/ubluepy: Adding start and end handle to service object.
nrf5/bluetooth: Adding support for central characteristic service discovery. Updating primary service discovery to block until all services has been created in the peripheral object before returning from the bluetooth driver. This pattern is also applied to the characteristic discovery.
nrf5/modules/ubluepy: Updating ubluepy peripheral object to new bluetooth driver API. Starting to populate service objects and uuid objects. Also adding the service to the peripheral object throught the regular static function for adding services. Handle value for the primary service is assuming that it is the first element in the handle range; start_handle reported by the service discovery.
nrf5/bluetooth: Updating bluetooth driver to do service discovery, doing callbacks to ubluepy upon each individual primary service discovered. Using intermediate structure defined by the driver, to abstract bluetooth stack specific data in ubluepy.
nrf5/modules/ubluepy: Adding some work in progress on service discovery.
nrf5/bluetooth: Adding implementation to the discover service function. Adding handler for gatt client primary service discovery response events, and passing this to the ubluepy upon reception.
nrf5/bluetooth: Adding function parameters and return type to service and characteristic discovery template functions.
nrf5/bluetooth: Adding template functions for service discovery in bluetooth driver.
nrf5/bluetooth: Adding function to register gattc event handler (central).
nrf5/bluetooth: Adding intermediate gattc callback function type in bluetooth driver.
nrf5/bluetooth: Turning off debug logging in bluetooth driver, which does not work well with bluetooth REPL mode.
nrf5/bluetooth: Fixing some smaller tab errors in the bluetooth driver.
nrf5/bluetooth: Updating bluetooth le driver to handle GAP conn param update request. Also updating minor syntax in previous switch case.
nrf5/boards: Inrease heap size in the nrf52832 w/s132 bluetooth stack linker script.
nrf5/modules/ubluepy: Update connect method to parse dev_addr parameter and pass it to the bluetooth driver, going through a allocated heap buffer. Adding call to the bluetooth driver to issue a connect. Hardcoding address type for now.
nrf5/bluetooth: Updating connect function in the bluetooth driver to do a successful connect to a peripheral device.
nrf5/modules/ubluepy: Adding template function for central connect() in peripheral object.
nrf5/modules/ubluepy: Adding locals dict to Scan Entry introducing function to retreive Scan Data. Not working as expected together with .attr. It looks like locals dict functions are treated to be attributes and cannot be resolved.
nrf5/bluetooth: Adding function for connecting to a device (in central role). Not yet tested.
nrf5/modules/ubluepy: Return BLE peer address as string instead of bytearray. Updated struct in modubluepy.h to use a mp_obj_t to hold a string instead of a fixed 6-byte array. Stripped down ScanEntry print out to only contain class name, peer address available through addr attribute.
nrf5/bluetooth: capture address type in addition to advertisment type in bluetooth advertisment reports.
nrf5/modules/ubluepy: Correcting rssi member in scan_entry object to be int instead of uint.
nrf5/modules/ubluepy: Adding attribute to ScanEntry object for getting address (returning bytearray), type (returning int) and rssi (returning int).
nrf5/modules/ubluepy: Copy address type and rssi to the ScanEntry object upon reception of an advertisment report callback.
nrf5/bluetooth: Adding address type to bluetooth stack driver advertisment structure, and fill the member when advertisment report is received.
nrf5/modules/ubluepy: Swapping address bytes when copying bluetooth address over to ScanEntry object during advertisment scan report event.
nrf5/modules/ubluepy: Extending print of ScanEntry object to also include the bluetooth le address.
nrf5/modules/ubluepy: Create new adv report list for each individual scan. Create a new ScanEntry object instance on each advertisment event recieved and append this to the current adv_report list.
nrf5/modules/ubluepy: Adding print function to scan_entry object.
nrf5/modules/ubluepy: Populating ubluepy_scan_entry_obj_t with members that are interesting to keep for the ScanEntry object.
nrf5/bluetooth: Moving callback definitions to bluetooth driver header. Refactoring bluetooth driver, setting new names on callback functions and updating api to use new callback function name prefix.
nrf5/modules/ubluepy: Extracting advertisment reports and adding some data to list before returning it in scan() method.
nrf5/bluetooth: Adding handling of advertisment reports in bluetooth driver and issue callback to ubluepy. A bit ugly implmentation and has to be re-worked.
nrf5/bluetooth: adding adv report data structure to pass to ubluepy upon adv report event. Adding new api for setting callack where to handle advertisment events in ubluepy.
nrf5/modules/ubluepy: Adding adv_reports member to scanner object, to hold the result of scan.
nrf5/modules/machine: Cleaning up uart a bit more. Removing unused any() method, and aligning print and local dict names to use machine_uart prefix.
nrf5/bluetooth: Turn off bluetooth printf logging.
nrf5: Add back ublupy scanner and scan entry source files in Makefile.
nrf5/bluetooth: Enable implementation in scan start function in the bluetooth stack driver.
nrf5/boards: Adjust heap end after increased .data usage in nrf52832 s132 linker script.
nrf5/bluetooth: Adding more implementation in scan start function. However, commented out for time beeing, as there is some memory issues when activating central.
nrf5: Removing ubluepy scanner and scan entry from Makefile source list until nrf52 central issues has been resolved.
nrf5/bluetooth: Correcting indention.
nrf5/bluetooth: Adding some implementation to scan_start function.
nrf5/modules/ubluepy: Adding scan method to the Scanner object. Adding locals dict table.
nrf5/bluetooth: Adding empty scan_start and scan_stop function to the bluetooth driver.
nrf5/modules/ubluepy: Adding constructor function to scanner object.
nrf5/modules/ubluepy: Adding print function to Scanner object.
nrf5/modules/ubluepy: Disable all functions central related functions in the Peripheral object for now, even if MICROPY_PY_UBLUEPY_CENTRAL is enabled.
nrf5/modules/ubluepy: Activate Scanner and ScanEntry objects if MICROPY_PY_UBLUPY_CENTRAL is set.
nrf5/bluetooth: Adding new configuration flag for s132 bluetooth stack, to enable/disable ubluepy central. Disabled by default.
nrf5: Adding ubluepy_scanner.c and ubluepy_scan_entry.c to Makefile source list.
nrf5/modules/ubluepy: Adding template object typedefs for scanner and scan entry, and extern definition for scanner and scan_entry object type in modubluepy.h
nrf5/modules/ubluepy: Adding templates for central role Scanner and ScanEntry objects.
nrf5/uart: Moving UART from pyb to machine module.
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/uart: Refactoring UART module and HAL driver
Facilitating for adding second HW uart. Moving pyb_uart into
machine_uart. Adding return error codes from hal_uart functions,
if the hardware detects an error.
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/modules: Updating uart object to allow baudrate configuration.
nrf5/bluetooth: Moving bluetooth_conf.h to port root folder to make it more exposed.
nrf5/boards: Remove define of machine PWM module configuration in nrf51 targets, as the device does not have a HW PWM peripheral.
nrf5: Disable machine PWM module by default if board does not define it.
nrf5/boards: Disable all display modules in pca10028 board config.
nrf5: Updated after merge with master. Updating nlr_jump_fail to call __fatal_error in order to provide a non-returning function call.
nrf5/boards: Adding more heap memory to the nrf51 256k/32k s110 linker script. Leaving 2k for stack.
nrf5/modules/machine: Adding __WFI() on machine.deepsleep()
nrf5/modules/machine: Adding __WFE() on machine.sleep()
nrf5/modules/machine: Adding enable_irq() and disable_irq() method to the machine module. No implementation yet for the case where bluetooth stack is used.
nrf5/modules/rtc: Adding support for stopping and restarting rtc (if periodic) for all the instances of RTC.
nrf5/modules: Updating RTC kwarg from type to mode to set ONESHOT or PERIODIC mode.
nrf5/modules: Adding support for periodic RTC callback.
nrf5/hal: hal_rtc update. Adding current counter value to period value before setting it in the compare register.
nrf5/modules: Updating rtc module with non-const machine object list in order to allow setting callback function in constructor.
nrf5/hal: Adding initialization of LFCLK if not already enabled in hal_rtc.
nrf5/modules: Moving irq priority settings in RTC object to rtc_init0 when initializing the hardware instances. Also modifying comments a bit. Adding simple example in comment above make_new function on how the object is intended to work.
nrf5: Updating main.c to initialize the rtc module if enabled.
nrf5/modules: Added RTC into the machine module globals dict.
nrf5/modules: Updating rtc module. Not working yet. Updated to align with new hal_rtc interface. Added start and stop methods. Allowing callback function set from init. This should be moved to start function, not set in main.
nrf5/hal: Updating hal RTC implementation.
nrf5/hal: Adding hal_irq.h which defines a set of static inline functions to do nvic irq operations.
nrf5/modules: Updating machine uart module to use new hal uart interface name.
nrf5/hal: Renaming uart hal function to use hal_uart prefix.
nrf5/modules: Updating readfrom function in machine i2c module to use the new hal function which has been implemented.
nrf5/hal: Adding untested implementation of twi read. Lacking sensors to test with :)
nrf5/boards: Renaming linker script for all nrf51 and nrf52 into more logical names. Updating all boards with new names.
nrf5/bluetooth: Updating header guard in bluetooth_conf.h to reflect new filename.
nrf5/bluetooth: Updating old references to 'sdk' to use the new folder name 'bluetooth' in makefiles.
nrf5: Renaming sdk folder to bluetooth.
nrf5: Merging sdk makefiles into bluetooth_common.mk. s1xx_iot is still left out of this refactoring.
nrf5: Renaming nrf5_sdk_conf.h to bluetooth_conf.h
nrf5: Starting process of renaming files in sdk folder to facilitate renaming of the folder and make it more logical. Transition will be from sdk to bluetooth.
nrf5/boards: Adding support for SPI, I2C, ADC, and Temp in machine modules in micro:bit target. Also activating hal drivers for the peripherals.
nrf5/sdk: Updating low frequency clock calibration from 4 seconds to 250 ms for stack enable when BLUETOOTH_LFCLK_RC is enabled.
nrf5/boards: Updating nrf51822_aa_s110.ld to be more generic, leaving all RAM not used for stack, .bss and .data to the heap.
nrf51: Removing stack section from startup file as it got added to the final hex file. Thanks dhylands for helping out.
nrf5/boards: Adding BLUETOOTH_LFCLK_RC to CFLAGS in microbit s110 makefile.
nrf5/sdk: Adding support for initializing the bluetooth stack using RC oscillator instead of crystal. If BLUETOOTH_LFCLK_RC is set in CFLAGS, this variant of softdevice enable will be activated.
nrf5: Initialize repl_display_debugging_info in pyexec.c for cortex-m0 targets.
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/sdk: Updating ringbuffer.h to use volatile variables for start and end.
nrf5/sdk: Rename cccd_enable variable to m_cccd_enable in bluetooth le UART driver. Also made the variable volatile.
nrf5/modules: Updating example in ubluepy header to use handle instead of data length upon reception of an event.
nrf5/modules: Updating ubluepy peripheral to pass handle value to python event handler instead of data length. Data length can be derived from the bytearray structure.
nrf5/sdk: Updating bluetooth le driver to handle SEC PARAM REQUEST by replying that pairing is not supported. Moving initialization of adv and tx in progress state variables to stack enable function.
nrf5/modules: Enable ubluepy constants for CONNECT and DISCONNECT for other bluetooth stacks than s132.
nrf5/sdk: Fixing unaligned access issues for nrf51 (cortex-m0) in bluetooth le driver
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/sdk: Removing SDK dependant BLE UART Service implementation
The sdk_12.1.0 nrf52_ble.c implementation was dependent on SDK components.
This has been replaced with the ble_uart.c implementation using a standalone
bluetooth driver implementation without need of SDK components.
Also, sdk.mk has been updated to not use a special linker script.
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf52: Removing folder to not confuse which folder is in development
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/sdk: Removing ble_repl_linux.py
Script does not really work very well with blocking char read and
async ble notifications printing data when terminal stdout is blocked
by readchar. Bluetooth UART profile implemented in ble_uart.c is
now working with tralamazza's nus_console nodejs script.
Ref: https://github.com/tralamazza/nus_console
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5: Add default config for MICROPY_PY_BLE_NUS (0)
Disable Bluetooth UART to be used for REPL by default. Can be overridden
in nrf5_sdk_conf.h. It is defined in mpconfigport.h as it is connected to
mphalport.c, where the config is used to determine whether default print
functions should be using HW UART or Bluetooth UART.
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/sdk: Add ble_uart.c to source list
ble_uart.c implements UART Bluetooth service on top of the
bluetooth stack driver api calls. Can be enabled to be compiled
in by defining MICROPY_PY_BLE_NUS = 1 in nrf5_sdk_conf.h.
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/sdk: Removing include of sdk_12.1.0's build.mk
As no sources are needed from the SDK this build makefile
can be deleted.
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5: Force implementation of tx_str_cooked function if BLE NUS enabled.
If BLE UART service has been enabled, the mp_hal_stdout_tx_strn_cooked
is not defined by default anymore, and has to be implemented by the
UART driver (in this case BLE).
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/sdk: Adding compiler guard around exchange MTU request event.
As s110 is not having this event or function call to answer on a MTU
exchange request, this is excluded for all other version than s132
for now.
Bander Ajba <banderajba@macwan.local>
minor documentation and extra tabs removal fixes
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/sdk: Updating BLE UART implementation by swapping TX and RX uuid and characterisitic handling. Removed dummy write delay of 10 ms.
nrf5/sdk: Backing up progress in bluetooth le driver. Adding new gap and gatts handlers. Added handling of tx complete events when using notification, responding to MTU request, and setting of default connection parameters.
Bander Ajba <banderajba@macwan.local>
fixed temp module to allow for instance support
did required modification to merge the temperature sensore module
Dave Hylands <dhylands@gmail.com>
Fix up Makefile dependencies
I also didn't see any real reason for mkrules.mk to exist,
so I merged the contents into Makefile.
Now you can do:
```
make BOARD=pca10028 clean
make BOARD=pca10028 flash
```
and it will work properly.
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5: Updating Makefile to use correct variable for setting directory of file to freeze as mpy.
nrf5: Setting stack top in main.c. Thanks dhylands for pointing this out.
nrf5/sdk: Backing up progress in BLE UART driver. Adding ringbuffer in order to poll bytes from recieved data in REPL main loop.
nrf5/modules: Updating ubluepy example to print out gatts write events with data.
nrf5/boards: Updating pca10028 bluetooth stack targets to have a MCU_SUB_VARIANT.
Bander Ajba <banderajba@macwan.local>
added support for hardware temperature sensor
Glenn Ruben Bakke <glennbakke@gmail.com>
nrf5/sdk: Adding macro based ringbuffer written by Philip Thrasher. source: https://github.com/pthrasher/c-generic-ring-buffer/blob/master/ringbuffer.h. Copyright noticed copied into the file, and file reviewed by Philip.
nrf5/sdk: Updating bluetooth le driver to extract data length and pointer from the event structure upon gatts write operation.
nrf5/modules: Expose ubluepy characteristic and peripheral types as external declaration in ublupy header.
nrf5: Updating main to initialize bluetooth le uart module right before bluetooth REPL is started.
nrf5/sdk: Updating bluetooth le uart implemenatation to block until cccd is written.
nrf5/sdk: Backing up ubluepy version of ble uart service for Bluetooth LE REPL.
nrf5/modules: Updating ubluepy example in header to align with bluetooth uart service characteristic's.
nrf5/modules: Implementing characteristic write method. Possible to use write for both write and notifications.
nrf5/sdk: Remaning bluetooth driver function ble_drv_attr_notif to *_notify.
nrf5/modules: Adding props and attrs parameter to ubluepy characteristic constructor to override default values. Adding method for reading characteristic properties. Adding values to the local dict table that gives possibility to OR together a configuration of properties and attributes in the keyword argument during construction.
nrf5/sdk: Adding parsing of characteristic properties and attributes (extra descriptions for the characteristic, for now cccd).
nrf5/modules: Adding new members to ubluepy characteristic object, props and attrs. Adding enum typedefs for various properties and attributes.
nrf5/modules: Syncing uart module code after upmerge with upstream master.
nrf5/boards: Releasing more RAM for heap use in the nrf51 s110 linker script.
nrf5/modules: Adding new gatts handler and registration of it during creation of a peripheral object. Also, added forwarding to python callback function (for now the same as for GAP).
nrf5/modules: Adding new callback type in modubluepy for gatts events.
nrf5/sdk: Adding support for setting gatts handler in the bluetooth le driver.
nrf5/modules: Adding constant for CCCD uuid in ubluepy constants dict.
nrf5: Adding ubluepy_descriptor.c into source list to compile.
nrf5/modules: Adding template for ubluepy descriptor class implementation.
nrf5/modules: Adding object structure for ubluepy descriptor.
nrf5/sdk: Adding template functions for attribute read/write/notify in bluetooth le driver.
nrf5/modules: Adding getCharacteristic method in ublupy service class. This function returns the characteristic with the given UUID if found, else None. The UUID parameter has to be of UUID class type, any other value, like strings will throw an exception.
nrf5/modules: Updating method documentation in ubluepy peripheral and service.
nrf5/modules: Adding new method, getCharacteristics(), in the ubluepy service class. The method returns the list of characteristics which has been added to the service instance.
nrf5/modules: Updating method documentation in ubluepy peripheral class.
nrf5/modules: Updating ubluepy service. Creating empty characteristic list in constructor. Appending characteristic to the list when added.
nrf5/modules: Changed return in ubluepy addService() function to return mp_const_none instead of boolean.
nrf5/modules: Correcting tabbing in ubluepy periheral impl.
nrf5/modules: Updating ubluepy peripheral. Creating empty service list in constructor. Appending services to the list when added. Added new function for retreiving the service list; getServices().
nrf5/modules: Adding new members in ubluepy peripheral and service object to keep track of child elements. Peripheral will have a list of services, and service will have a list of charactaristics.
nrf5/modules: Removing connection handle from python gap event handler callback function.
nrf5/modules: Updating ubluepy example in the header file with new function call to add service to a peripheral instance.
nrf5/modules: Updating peripheral class to assign periopheral parent pointer to service's thats added. Also added a hook in the bluetooth le event handler to store the connection handle value, to prevent any services or characteristics to handle this value themselves.
nrf5/modules: Updating service object to clear pointer to parent peripheral instance. Also assinging pointer to the service when adding a new characteristic.
nrf5/modules: Updating print to also include peripheral's connection handle. Setting pointer to service parent instance to NULL.
nrf5/modules: Correcting event id numbers for connect and disconnect event in ubluepy_constants.py
nrf5/modules: Shuffle order of typedef in ubluepy header. Adding service pointer in characteristic object. Adding peripheral pointer to the service structure. When populated, the characteristic would get access to conn_handle and service handle through pointers. Also service would get access to peripheral instance.
nrf5/modules: adding template functions for characteristic read and write.
nrf5/modules: Adding constants class to ubluepy which will contain easy access to common bluetooth le numbers and definitions for the bluetooth stack.
nrf5/modules: Updating example in ubluepy header with 16-bit uuid's commented out, to show usage.
nrf5/sdk: Adding support for adding 16-bit uuid's in advertisment packet. The services in paramter list can mix 16-bit and 128-bit.
nrf5/sdk: Updating sdk_common.mk with new filename of bluetooth le driver.
nrf5: Updating all includes of softdevice.h to ble_drv.h
nrf5/sdk: renaming softdevice.* to ble_drv.*
nrf5/sdk: Renaming bluetooth driver functions to have ble_drv* prefix. Updating modules using it.
nrf5/sdk: Enable ubluepy module if s110 bluetooth stack is enabled.
nrf5/sdk: Updating bluetooth driver to only set periph and central count if s132 bluetooth stack. These parameters does not exist in older stacks.
nrf5/modules: Updating bluetooth driver and ubluepy to use explicit gap event handler. Adding connection handle parameter to the gap handler from ubluepy. Resetting advertisment flag if connection event is recieved, in order to allow for subsequent advertisment if disconnected again. Example in ublupy header updated.
nrf5: Adding target to flash bluetooth stack when using pyocd-flashtool.
nrf5/modules: Guarding callback to python event handler before issue the call in case it is not set.
nrf5/modules: Updating ubluepy example to turn led2 on and off when receiving connected and disconnect bluetooth event.
nrf5/sdk: Updating bluetooth driver to have configurable logs.
nrf5/modules: updating ubluepy and bluetooth driver to support python created event handler. Added registration of callback from ubluepy against the bluetooth driver and dispatching of events to the user supplied python function.
nrf5/modules: Splitting includes to be inside or outside of the compile guard in ubluepy. This way, all micropython specific includes will be outside, and internal will be inside. This way, there will not be any dependency towards ubluepy headers if not compiled in.
nrf5/modules: Adding two new functions to ubluepy peripheral class to set specific handlers for notificaitons and connection related events.
nrf5: Set ubluepy to disabled by default in mpconfigport.h if not configured.
nrf5/modules: Moving includes inside config defines to make non-ubluepy targets compile again.
nrf5/modules: Adding 'withDelegate' function to peripheral class.
nrf5/modules: Adding ubluepy delegate type to modubluepy globals table.
nrf5: Adding ubluepy_delegate.c to list of source files to compile.
nrf5/modules: Adding new object struct for delegate class and adding a delegate struct member to Peripheral class to bookeep callback object when event occurs.
nrf5/modules: Adding template for ubluepy delegate class.
nrf5/sdk: Fixing debug print in bluetooth driver to not use >>> prefix. Adding one more print for connection parameter update.
nrf5/sdk: Correcting advertisment packet in bluetooth driver in order to make the device connectable.
nrf5/sdk: Implementing simple event handler for bluetooth stack driver.
nrf5/sdk: Disable all sdk components from being included in the build while implementing ubluepy, overlap in IRQ handler symbol.
nrf5/modules: Shortening down the device name to be advertised in the example to make it fit with a 128-bit complete UUID.
nrf5/modules: Bugfix in ubluepy_uuid_make_new. Used wrong buffer to register vendor specific uuid to the bluetooth stack.
nrf5/sdk: Updating advertisment function in bluetooth le driver to add 128-bit complete service UUID provided in service list to the advertisment packet.
nrf5/sdk: Updating advertisment funciton in bluetooth le driver to iterate through services passed in and calculate individiual uuid sizes.
nrf5/modules: Updating advertisment method in peripheral class to memset advertisment structure. Also applying service list if set to the advertisment structure.
nrf5/modules: Updating ubluepy module header usage example. Correcting enum for UUID types to start index from 1. Expanding advertisment data structure to also include service list members.
nrf5/sdk: Adding static boolean for keeping track of whether advertisment is in progress in the bluetooth driver. Now, advertisment can be restarted with new data any time.
nrf5/modules: Updating ubluepy peripheral class to use mp_const_none instead of MP_OBJ_NULL for unset values in advertisment method parameter list. Adding extraction of the service list in the advertisment method. The list is not yet handled.
nrf5/modules: Adding a few examples in the modubluepy.h to get easier copy paste when implementing.
nrf5/sdk: Successful device name advertisment. Added flags to advertisment packet and enable device name byte copy into the advertisment data.
nrf5/modules: Turning ubluepy peripheral advertisment function into a keyword argument function so that it would be possible to set device name, service uuids, or manually constructed data payload.
nrf5/sdk: Updating softdevice driver with function to set advertisment data and start advertisment. Does not apply device name yet. Work in progress.
nrf5/modules: Adding new structure to ubluepy in order to pass advertisment data information to the bluetooth le stack.
nrf5/modules: Adding function function to add characteristics to the ubluepy service. Enable function in service's local dict table.
nrf5/modules: Adding function in bluetooth le driver to add characteristic to the bluetooth le stack.
nrf5/modules: Adding more members to ublue characteristic object structure.
nrf5/modules: Adding characteristic class to ubluepy globals table.
nrf5/modules: Updating ubluepy characteristic implementation.
nrf5/modules: Re-arranging includes in ubluepy_service.c
nrf5/modules: Adding ubluepy charactaristic type struct.
nrf5/modules: Updating ubluepy with more implementation in UUID and Service. Adding function in bluetooth le driver which adds services to the bluetooth stack. Making service take UUID object and Service type (primary/secondary) as constructor parameter in Service class.
nrf5: Adding ubluepy to include path.
nrf5/modules: Updating ubluepy UUID class constructor with some naive parsing of 128-bit UUIDs, and pass this to the softdevice driver for registration.
nrf5/sdk: Adding new function to the softdevice handler driver to add vendor specific uuids and return an index to the entry back by reference.
nrf5/modules: Updating ubluepy UUID class with constructor that can construct an object based on hex value of 16-bit or string of 16-bit prefixed with '0x'.
nrf5/modules: Adding Peripheral, Service and UUID class to the ubluepy module globals table.
nrf5/modules: Extending the implementation of Peripheral class in ubluepy.
nrf5/modules: Extending the implementation of UUID class in ubluepy.
nrf5/sdk: Adding configuration to enable the ubluepy peripheral class when using softdevice 132 from the SDK.
nrf5: Adding ubluepy module to builtins if bluetooth stack is selected. Disable NUS profile by default. Adding source for ubluepy module into makefile to be included in build. The source is only linked if MICROPY_PY_UBLUEPY is set.
nrf5: Aligning code after upmerge with master. Mostly FAT FS related updates. Not tested after merge.
nrf5/modules: Adding new and print function to ubluepy peripheral class. Template functions only.
nrf5/modules: Adding ubluepy UUID class template.
nrf5/modules: Adding ubluepy characteristic class template.
nrf5/modules: Adding missing #endif. Also adding to property templates to the lolcal dict.
nrf5/modules: Adding ubluepy service class template.
nrf5/modules: Updating ubluepy with class function placeholders.
nrf5/modules: Renaming ble module folder to ubluepy.
nrf5/modules: Adding new template file for ubluepy Peripheral class.
nrf5/pyb: Moving pyb module into modules/pyb.
nrf5/utime: Moving utime module into modules/utime.
nrf5/uos: Moving uos module into modules/uos.
nrf5/network: Moving network module into modules/network. Adding include path to network as its needed by the usocket module.
nrf5/usocket: Moving usocket module into modules/usocket.
nrf5/led: Moving led module into modules/machine.
nrf5/led: Moving led module into modules/machine.
nrf5/pwm: Moving pwm module into modules/machine.
nrf5/rtc: Moving rtc module into modules/machine.
nrf5/timer: Moving timer module into modules/machine.
nrf5/pin: Moving pin module into modules/machine.
nrf5/adc: Moving adc module into modules/machine.
nrf5/i2c: Moving i2c module into modules/machine.
nrf5/spi: Moving spi module into modules/machine.
nrf5/uart: Moving uart module into modules/machine to start converting it into machine module and not pyb.
nrf5/machine: Moving modmachine into modules/machine folder. Updating Makefile.
nrf5/drivers: Renaming folder to modules.
nrf5: Renaming python modules folder to freeze to give the folder its right meaning. The scripts put into this folder will be frozen.
nrf5/drivers: Adding template for ubluepy module.
nrf5/sdk: Adding compilation config whether to include BLE NUS implementation. Config found in sdk/nrf5_sdk_conf.h. NUS enabled for s132 targets by default.
nrf5: Fallback to HW UART when not Bluetooth LE UART has been enabled.
nrf5: Updating main.c to use MICROPY_PY_BLE_NUS as switch for regular uart initialization or bluetooth le uart initialization.
nrf5/sdk: Adding work-in-progress script to connect to bluetooth le REPL using bluepy python module in linux.
nrf5/boards: Updating board makefiles for s132 and s1xx target for pca10040 (nrf52832) by adding sub variant and device define to the makefiles.
nrf5/examples: Updating ssd1306.py example with a comment describing proceedure on how to use the I2C variant of the driver.
nrf5/hal: Line wrapping params in hal_spi.c to make it easier to read.
nrf5/hal: Updating hal_twi.c tx implementation to a working state. STARTTX only issued once, before looping bytes.
nrf5/examples: Updating ssd1306.py driver to work with i2c master write implementation.
nrf5/hal: Updating hal_twi.c with tx function. Gets multiple startup bytes for each clocked byte.
nrf5/hal: Updating hal_twi.c with tx function which partly works. Bytes are clocked out a bit out of order.
nrf5/hal: Started implementation of hal_twi.c (non-DMA). Init function started.
nrf5: Removing hal_twie.c from being compiled in.
nrf5: Renaming configuration define in board configs using i2c from MICROPY_PY_MACHINE_HW_I2C to MICROPY_PY_MACHINE_I2C as the config is overlapping with the latter.
nrf5: Renaming configuration define in board configs using i2c from MICROPY_PY_MACHINE_HW_I2C to MICROPY_PY_MACHINE_I2C as the config is overlapping with the latter.
nrf5: Making i2c configurable from board configuration in case board has to sacrifice the i2c machine module.
nrf5/boards: Activating all display drivers in pca10056 board.
nrf5/boards: Updating s110 SD linker script for micro:bit.
nrf5/i2c: Making use of hal twi tx function in writeto function.
nrf5/hal: Updating twi driver with template functions.
nrf5/hal: Updating TWI DMA implementation. Suspend not working on tx. Rx not implemented yet.
nrf5/hal: Updating twi master tx with stop parameter.
nrf5/hal: Adding i2c master functions for tx and rx in hal header.
nrf5/hal: Adding new macros functions to mphalport.h which are used by extmod i2c machine module.
nrf5/i2c: Adopting use of extmod/machine_i2c module as base for port's machine i2c module.
nrf5/i2c: Backing up before trying out extmod i2c integration.
nrf5: Adding i2c class to machine module globals table.
nrf5: Updating main.c to initialize the i2c machine module if selected.
nrf5/i2c: Updating i2c machine module with new constructor parameters to set scl and sda pins. Also updating print funciton to debug pin number and port number for the gpio set.
nrf5/i2c: Updating i2c module to new new hal api, as master is initialized with its own init function.
nrf5/hal: Adding members to TWI config struct, device address and scl/sda pin. Renaming and adding function such that twi slave and master has seperate init function. Started implementation of master init function for nrf52 using DMA (hal_twie.c).
nrf5/i2c: Updating module to use new struct layout from hal_twi.h
nrf5/hal: Updating TWI with frequency enums.
nrf5/examples: Updating game file to use ssd1305 display driver.
nrf5/drivers: Updating examples in comment in oled ssd1305 object to use the draw module.
nrf5/hal: Fixing nrf51 SPI pin configuration to use pin member of struct.
nrf5/boards: Updating boards to comply to new style of configuring pins for uart and spi.
nrf5/boards: Updating board configuration for pca10056 (nrf52840) with new pin configuration scheme for SPI and UART.
nrf5/hal: Updating hal QSPI header with define guard to filter out usage of undefined structures and names when compiling against non-52840 targets.
nrf5/drivers: Updating display objects to use new SPI pin configuration in print function.
nrf5/hal: Updating SPI DMA variant with more frequencies, and allowing rx and tx buffers to be NULL.
nrf5/uart: Updating uart module to use new config hal config structure members for pins. Changing board config provided pins to use const pointers from generated pins instead of pin name.
nrf5/hal: Updating uart hal to use pointers to Pin objects instead of uint pin and port number.
nrf5/hal: Updating uart hal to use pointers to Pin objects instead of uint pin and port number.
nrf5: Updating modmachine to add SPI in globals dict when MICROPY_PY_MACHINE_HW_SPI define is set. This diverge from regular MICROPY_PY_MACHINE_SPI config. Fixes missing SPI in the machine module after renaming port SPI enable define.
nrf5: Updating main.c to enable SPI if MICROPY_PY_MACHINE_HW_SPI is set. This diverge from regular MICROPY_PY_MACHINE_SPI config. Fixing missing init of SPI after renaming port SPI enable define.
nrf5/spi: Adding multiple instances of machine SPI depending on which chip is targeted (nrf51/nrf52832/nrf52540). Updating board config requirement to give variable name of const pointer to Pin instead of a Pin name. Adding support of giving keyword set mosi/miso/clk pin through constructor.
nrf5/hal: Updating SPI hal with full list of SPI interfaces as lookup tables for all devices. Updating init struct to pass Pin instance pointers instead of uint pin number and ports.
nrf5/drivers: Activate ssd1289 object in the display module.
nrf5/boards: Adding ssd1289 lcd module in pca10040 (nrf52832) board.
nrf5: Adding ssd1289 driver and python module into build.
nrf5/drivers: Adding ssd1289 lcd tft driver and python module.
nrf5/hal: Fixing compile issues in quad SPI driver.
nrf5/hal: Updating Quad SPI hal driver.
nrf5/hal: Aligning assignment in hal_adc.c
nrf5/hal: Adding more types to quad SPI header.
nrf5: Syncing code after upmerge with master.
nrf5/hal: Updating clock frequency enums and lookup table for quad spi.
nrf5/hal: Adding QSPI base and IRQ num in c-file.
nrf5/hal: Adding hal template files for 32mhz Quad SPI peripheral.
nrf5/drivers: Optimizing update_line in ili9341 driver a bit.
nrf5/drivers: Adding space in macro.
nrf5/drivers: Adding rgb16.h with macro to convert 5-6-5 rgb values into a 16-bit value.
nrf5: Adding configuration defines for SSD1289 lcd driver.
nrf5: Removing old framebuffer implementation.
nrf5: Remove old framebuffer implementation from being included into the build.
nrf5/drivers: Enable framebuffer and graphics module to be compiled in by default if display is selected into the compilation.
nrf5/drivers: Updating epaper driver sld00200p to use new framebuffer.
nrf5/drivers: Removing debug printf's from epaper display python module.
nrf5/drivers: Updating python example in comment for ls0xxb7dxx display module.
nrf5/boards: Enable LS0XXB7DXXX display module in pca10056 board config.
nrf5/drivers: Adding ls0xxb7dxx to display module.
nrf5: Adding ssd1305 and ls0xxb7dxxx (sharp memory display) drivers to be included in build.
nrf5/drivers: Updating sharp memory display driver and python module to a working state.
nrf5/spi: Adding posibility to configure SPI firstbit mode to LSB or MSB. Default is MSB. Updating python module and hal driver.
nrf5/drivers: Tuning memory lcd driver a bit. Fixing small mp_printf usage bug.
nrf5/drivers: Adding sharp memory display driver. For now hardcoded to 2.7 inch variant.
nrf5: Adding configuration define for sharp memory display series in mpconfigport.h preparing for driver to be included.
nrf5/boards: Enable ssd1305 oled display to be default for pca10028 for now.
nrf5/drivers: Adding ssd1305 oled driver. This is very similar to ssd1306, so a merge will happen soon.
nrf5/drivers: Adding ssd1305 oled driver. This is very similar to ssd1306, so a merge will happen soon.
nrf5/drivers: Updating ili9341 display object to use new framebuffer.
nrf5/drivers: Updating ili9341 driver to use new framebuffer, and removing the compressed param from the line update function.
nrf5: Adding micropython mem_info() to be included in mpconfigport.h.
nrf5/drivers: Adding example in comment on how to use the ili9341 driver with nrf51/pca10028 board.
nrf5/examples: Adding a extra global variable to the game which breaks the game execution.
nrf5/examples: Adding 2048 game using OLED SSD1306 128x64 display and analog joystick.
nrf52/boards: Increasing the stack and heap in pca10056 (nrf52840) target from 2k/32k to 40k/128k to debug some buffer problems when running large frozen python programs.
nrf51/boards: Increasing heap and stack size in the pca10028 board.
nrf51/boards: Enable display driver and oled ssd1306 (also bringing in framebuffer and graphics module) into the pca10028 target.
nrf5: Enable display/framebuffer.c and graphic/draw.c into the build.
nrf5/drivers: Adding defines to exclude implementation of draw.c module if not enabled.
nrf5: Adding configuration defines for the graphics module (draw) and enabling this by default if using oled ssd1306 display which has a compatible python object definition.
nrf5/drivers: Adding draw module with circle, rectangle and text functions. Can be used by any display object which implements display callback functions.
nrf5/drivers: Moving oled ssd1306 driver over to new framebuffer layout. Moving some of the draw algorithms into the object in order to optimize the speed on writing data from the framebuffer.
nrf5/hal: Removing stdio.h include in adce.c which were used for debugging.
nrf5/boards: Adding ADC pins in pins.csv file for pca10056 (nrf52840).
nrf52/hal: Adding adce (saadc) implementation for nrf52 to sample values on a channel.
nrf5/adc: Adding all 8 instances to adc python module. Valid for both nrf51 and nrf52.
nrf5/drivers: Adding new structures to moddisplay. Adding a display_t structure to cast all other displays into, to retrieve function pointer table of a display object type. Also adding the function table structure which needs to be filled by any display object.
nrf5/drivers: Adding a new framebuffer implementation to replace the mono_fb.
nrf5/boards: Updating pca10028 (nrf51) board config. Enable SPI machine module. Enable flow control on UART. Correcting SPI CLK, MISO and MOSI pin assignments.
nrf5/adc: Updating adc module and hal with a new interface. No need for keeping peripheral base address in structure when there is only one peripheral (nrf51).
nrf5/rtc: Correcting RTC1 base error in rtc template.
nrf5: Adding adc module to machine module.
nrf5/hal: Updating hal_adc* with more api functions.
nrf5/adc: Adding updated adc module.
nrf5/boards: Enabling ADCE (SAADC) variant of adc hal to match hardware on nrf52 series.
nrf5/boards: Adding ADC config to pca10028 pins.csv
nrf5/boards: Tuning linker script for nrf51822_ac to get some more heap.
nrf5: Updating nrf51_af.csv to reflect pins having ADC on the chip.
nrf5/boards: Updating make-pins.py to generate ADC pin settings from board pins.csv.
nrf5/hal: Updating hal_adc header to use correct Type for ADC on nrf52.
nrf5/adc: Updating module to compile.
nrf5/boards: Enable ADC machine module for pca10028, pca10040 and pca10056.
nrf5: Add add ADC machine module into build.
nrf5: Adding new config for ADC module in mpconfigport.h.
nrf5/adc: Adding ADC machine module base files. Implementation missing.
nrf5: Adding hal_adc* into build.
nrf5/boards: Enable ADC/SAADC hal for pca10028 (nrf51), pca10040 (nrf52832) and pca10056 (nrf52840) boards.
nrf5/hal: Removing chip variant guard for hal_adc*, and let this be up to the hal conf file to not mess up at the moment.
nrf5: Add i2c.c, i2c machine module, and hal_twi into build.
nrf5/boards: Enable hardware I2C machine module for pca10028 (nrf51), pca10040 (nrf52832) and pca10056 (nrf52840) boards.
nrf5/boards: Enable TWI hal for pca10028 (nrf51), pca10040 (nrf52832) and pca10056 (nrf52840) boards.
nrf5/i2c: Adding files for hardware i2c machine module and adding config param in mpconfigport to disable by default.
nrf5/hal: Adding template files for TWI (i2c) hal.
nrf5/hal: Adding template files for ADC hal.
nrf5/drivers: Correcting tabbing in oled ssd1306 c-module.
nrf5/boards: Enable SSD1306 spi driver for pca10040 (nrf52832) and pca10056 (nrf52840) boards.
nrf5/drivers: Adding SSD1306 SPI display driver. Not complete, but can do fill screen operation atm.
nrf5/drivers: Adding epaper display example script in comment for pca10056 / nrf52840 in the display module.
nrf5/boards: Enable PWM module and epaper display module in pca10056 board config.
nrf5/drivers: Adding some more delay on bootup to ensure display recovers after reset.
nrf5/examples: Adding copy of ssd1306.py driver hardcoded with SPI and Pin assignments.
nrf5/drivers: Updating ili9341 driver to set CS high after cmd or data write.
nrf5/drivers: Extending print function for ili9341 object to also print out gpio port of the SPI pins.
nrf5/boards: Giving a bit more heap for nrf52840 linker script.
nrf5/drivers: bugfix of the sld00200p driver. Stopping the pwm instead of restarting it. Shuffle placement of static function.
nrf5/drivers: Correcting object print function to also include port number of the SPI pins. Correcting usage script example in comment.
nrf5/drivers: Adding an initial script as comment for ili9341 on nrf52840/pca10056 in the driver module comment.
nrf5/examples: Removing tabs from epaper python script usage comment, so that it is easier to copy paste.
nrf5/hal: Refining if-defs to set up GPIO base pointers in mphalport.h
nrf5/devices: Removing define which clutters ported modules from nrf.h.
nrf5/boards: Enabling spi in pca10056 hal config.
nrf5/boards: Enabling ili9341 display drivers and to be compiled in on pca10056 target board. Updating SPI configuration with gpio port.
nrf5/boards: Enabling display drivers/spi/pwm to be compiled in on pca10040 target board. Updating SPI configuration with gpio port.
nrf5/hal: Correcting SPI psel port position define name to the one defined in nrf52840_bitfields.h
nrf5/led: Hardcoding GPIO port 0 for Led module for now.
nrf5/hal: Changing import of nrf52 includes in hal_uarte.c to not be explicit. Now only nrf.h is included.
nrf5: Updating pin, spi and uart to use port configuration for gpio pins. Update pin generation script, macros for PIN generation. Updating macros for setting pin values adding new port parameter to select the correct GPIO peripheral port.
nrf5/boards: Disable SPI hal from pca10001 board.
nrf5/boards: Disable SPI/Timer/RTC hal from microbit board.
nrf5: Exclude import of pwm.h in modmachine.c if MICROPY_PY_MACHINE_PWM is not set, as nrf51 does not yet have this module yet.
nrf5: Exclude import of pwm.h in main.c if MICROPY_PY_MACHINE_PWM is not set, as nrf51 does not yet have this module yet.
nrf5/drivers: Block nrf51 from compiling epaper_sld00200p for the moment. There is no soft-pwm present yet, and including pwm would just make compilation fail now.
nrf5/hal: Making nrf51/2_hal.h go trough nrf.h to find bitfields and other mcu headers instead of explicit include.
nrf5/boards: Adding more pins to nrf52840 / pca10056 target board.
nrf5/pin: Adding more pins to nrf52_af.csv file for nrf52840. Port '1' will be prefixed 'B'.
nrf5/pin: Adding PORT_B to Pin port enum to reflect gpio port 1 on nrf52840.
nrf5/boards: Updating all board configs with gpio port configuration for uart/spi pins. Leds still not defined by gpio port.
nrf5/devices: Updating header files for nrf51 and nrf52. Adding headers for nrf52840.
nrf5: Updating to use new nrfjprog in makefile. Needed for nrf52840 targets. Changed from pinreset to debug reset.
nrf5/boards: Updating makefiles to use system.c files based on sub-variant of mcu.
nrf5/devices: Renaming system.c files for nrf51 and nrf52 to be more explicit on which version of chip they are referring to.
nrf5/drivers: Backing up working epaper display (sld00200p shield) driver before refactoring.
nrf5/drivers: Fixing parenthesis in ILI9341 __str__ print function.
nrf5/pwm: Moving out object types to header file so that it can be resused by other modules.
nrf5/drivers: Updating a working version of ili9341 module and driver. About 10 times faster than python implementation to update a full screen.
nrf5: Started to split up lcd_mono_fb such that it can be used as a c-library and python module with the same implementaton.
nrf5/hal: Adding include of stdbool.h in hal_spi.h as it is used by the header.
nrf5/drivers: Adding preliminary file for ili9341 lcd driver.
nrf5/hal: Adding support for NULL pointer to be set if no rx buffer is of interest in SPI rx_tx function.
nrf5: Adding ili9341 class and driver files in Makefile to be included in build.
nrf5/drivers: Adding template files for upcomming ili9341 driver.
nrf5/drivers: Adding lcd ili9341 object implementation to make a new instance. print implemented for debugging pins assigned to the display driver. No interaction yet with the hal driver.
nrf5/drivers: Adding ILI9341 class to the display global dict.
nrf5/boards: Changing tft lcd display name from SLD10261P to ILI9341 in pca10040 board configuration.
nrf5: Moving out mp_obj_framebuf_t to the header file to get access to it from other modules. Exposing helper function to make new framebuffer object from c-code.
nrf5: Trimming down display configurations in mpconfigport.h
nrf5/spi: Moving *_spi_obj_t out of implementation file to header. Setting hal init structure in the object structure instead of making a temp struct to configure hal. This would enable lookup of the spi settings later.
nrf5: Removing epaper, lcd and oled modules from Makefile source list as the display modules has been moved to display root folder.
nrf5/drivers: Removing one level of module hierarchy in display drivers. Removed epaper, lcd and oled modules, making import of classes happen directly from display module.
nrf5/drivers: Creating python object implementation (locals) to be used for epaper sld00200p.
nrf5: Moving color defines in lcd_mono_fb from .c to .h so that it can be reused by other modules.
nrf5: Enable MICROPY_FINALISER and REPL_AUTO_INDENT.
nrf5/drivers: Adding requirement for nrf52 target on the epaper sld00200p for now. There is no ported PWM module for nrf51 target yet. Hence, soft PWM for nrf51 needs to be added.
nrf5: Adding suffix to _obj on epaper_sld00200p module.
nrf5: Correcting define name for epaper sld00200p, missing 0.
nrf5/drivers: Enable EPAPER_SLD00200P in epaper module globals table.
nrf5/drivers: Adding missing file for epaper module / driver.
nrf5/modules: Moving python scripts to examples folder to free up some flash space on constrained targets as modules folder is used as frozen files folder.
nrf5/boards: Enable display module to be built in. Also adding one epaper display and one tft lcd to test display module when porting the corresponding drivers to micropython.
nrf5/drivers: Removing external decleration of display module in header.
nrf5/drivers: Renaming display module to mp_module prefix as it is going to be inbuilt. ifdef'ing all submodules based on type of display configured through mpconfigport.h
nrf5/drivers: Adding ifdef sourrounding the implementation of module. Configurable with mpconfigport.h.
nrf5: Adding display module to port builtins.
nrf5/drivers: Adding driver files to makefile. Implicitly adding display module.
nrf5/drivers: Adding template for c-implementation of lcd, epaper and oled drivers as a display module.
nrf5/modules: Updating to correct name of display in epaper driver.
nrf5/modules: Adding python epaper display driver. Currently colors have been reversed.
nrf5/hal: Fixing bug in mp_hal_pin_read in mphalport.h which tried to read an OUT register. Corrected to read the IN register.
nrf5: Adding sleep_us to modutime.c and exposing mp_hal_delay_us in hal/hal_time.h
nrf5/lcd: Updating framebuffer with double buffer for epaper displays. Moving statics into instance struct. Adding new function to refresh using old buffer, such that epaper can get a cleaner image after update.
nrf5/boards: Adding initial microbit build files and board configurations.
nrf5: Makefile option to set FLASHER when doing flash target. If defined in board .mk file, this will be used, else nrfjprog will be used by default (segger). This opens up for using pyocd flashtool and still run 'make flash'.
nrf5/boards: Updating pca10028 board config to not define RTS/CTS pins when HWFC is set to 0.
nrf5/uart: Making compile time exclusion of RTS/CTS if not defined to use flow control by board configuration.
nrf5/spi: Removing automatic chip select (NSS) in hal_spi.c. Also removing configuration of this pin as it is confusing to pass it if not used. User of SPI has to set the NSS/CS itself.
nrf5/modules: Updating PWM test python script to cope with new api.
nrf5/hal: Fixing some issues in PWM stop function. Doing a proper stop and disable the peripheral.
nrf5/pwm: Implementing start and stop call to hal on init and deinit as hal_init does not longer start the PWM automatically.
nrf5/hal: Exposing two new PWM hal functions start() and stop().
nrf5/hal: Moving enablement of PWM task from init to a start function. Also activating code in stop function to stop the PWM.
nrf5/modules: Adding licence text on seeedstudio tft shield python modules.
nrf52/boards: Tuning linker script for nrf52832 when using iot softdevice. Need more heap for LCD framebuffer.
nrf5/lcd: Adding lcd_mono_fb.c to source list in the makefile. Adding define in implementation to de-select the file from being included. Adding module to PORT BUILTIN in mpconfigport.h
nrf52/sdk: Correcting path to iot softdevice if SDK is enabled.
nrf5: Adding help text for CTRL-D (soft reset) and and CTRL-E (paste mode) in help.c
nrf5: Adding handling of CTRL+D to reset chip in main.c. Call to NVIC System Reset is issued.
nrf5/lcd: Correcting indention (tabs with space) in framebuffer module source and header.
nrf5/lcd: Changing framebuffer to use petme128 8x8 font. This is vertical font. Code modified to flip and mirror the font when rendering a character. Adding copy of the font from stmhal.
nrf5/modules: Adding new driver for seeedstudio tft shield v2, using new framebuffer module which handles faster update on single lines, callback driven write on each line which is touched in the framebuffer.
nrf5/lcd: Adding header file for lcd_mono_fb.
nrf5/lcd: Updating brackets in framebuffer module.
nrf5/lcd: Renaming variable name from m_ to p_
nrf5/lcd: Cleaning up a bit in lcd framebuffer.
nrf5/lcd: Adding work in progress monochrome lcd framebuffer driver which only updates modified (dirty) display lines.
nrf5/modules: Updating pulse test to set output direction on the LED pin used in the test.
nrf5/modules: Updating seeedstudio tft lcd driver to render using already existing framebuffer implementation.
nrf5/boards: Bouncing up heap to 32k on pca10040 to allow for application to allocate 9600bytes+ framebuffer when using LCD screen (240x320).
nrf5/modules: Adding a function to get access to the SD card flash drive on the seeedstudio tft shield.
nrf5/modules: Adding new python script to initialize and clear the display on Seeedstudio 2.8 TFT Touch Shield v2.
nrf5/modules: Updating documentation on sdcard.py copy to use new params in the example description
nrf5/modules: Updating mountsd, SD card test script with new params.
nrf5/pin: Merging input and output pin configuration to one comon function. Adding implementation in Pin class to be able to configure mode and pull. Updating drivers which uses gpio pin configuration to use new function parameters.
nrf5: Adding rtc.c which implements the machine rtc module to be included in build.
nrf5/boards: Enable MICROPY_PY_MACHINE_RTC in pca10028 (nrf51) and pca10040 (nrf52) targets.
nrf5/hal: Adding empty init function in hal_rtc.c
nrf5/hal: Adding structures and init function prototype to hal_rtc.h.
nrf5: Setting MICROPY_PY_MACHINE_RTC to disabled by default (during development) in mpconfigport.h. This can be overriden by board config.
nrf5/rtc: Adding skeleton for machine rtc module for nrf51/52.
nrf5: Adding timer.c which implements the machine timer module to be included in build.
nrf5: Setting MICROPY_PY_MACHINE_TIMER to disabled by default (during development) in mpconfigport.h. This can be overriden by board config.
nrf5/boards: Enable MICROPY_PY_MACHINE_TIMER in pca10028 (nrf51) and pca10040 (nrf52) targets.
nrf5: Adding initialization of timer module if enabled by MICROPY_PY_MACHINE_TIMER.
nrf5/timer: Adding initializaton of id field for Timer_HandleTypeDef's. Adding simple print function. Adding make_new function. Enabling the functions in machine_timer_type.
nrf5/hal: Adding empty init function in hal_timer.c
nrf5/hal: Adding structures and init function prototype to hal_timer.h.
nrf5/timer: Adding skeleton for machine timer module for nrf51/52.
nrf/boards: Adding RTC and TIMER hal to be linked in when implemented. Enable one board for nrf51 and one for nrf52 for ease of debugging when implementing the hal.
nrf5: Adding rtc and timer hal to Makefile.
nrf5/hal: Adding skeleton files for rtc and timer driver.
nrf5/modules: Updating pulse example to work with Pin object instead of hard coded pin number.
nrf5/pwm: Switching from hardcoded pin number to Pin object type as input to the new() function. Also changing the parameter from kw to arg.
nrf5/modules: updating test python file with correct PWM frequency type.
nrf5/modules: Adding a python test file with function to dim a specific led (17).
nrf5/pwm: Updating pwm module with freq function which re-initilises the PWM instance such that new frequency will be applied.
nrf5/pwm: Initializing pwm instances in main.c if enabled by MICROPY_PY_MACHINE_PWM.
nrf5/pwm: Adding api to initialize pwm instances.
nrf5: Updating mpconfigport.h to set a default for PWM machine module to be enabled by default, if not disabled in a board config. Refactoring order in the file.
nrf52: Set names to be used on PWM0-2 in board config. For nrf52840, the PWM3 is excluded as repo does not have latest headers to reflect this yet. Bump up to be done soon.
nrf52: Enable PWM HAL for both pca10040 (nrf52832) and pca10056 (nrf52840).
nrf51: Disable MICROPY_PY_MACHINE_PWM for now in all nrf51 target boards as sw impl. is not yet included in the repo.
nrf5: Only enable hal_pwm.c if nrf52 target as nrf51 must have a sw implementation.
nrf5/pwm: Adding pwm to modmachine.c
nrf5/hal: Updating PWM header file with init function prototype. Also added PWM_HandleTypeDef structure that can be used in the pwm python module.
nrf5/pwm: Updating PWM dict table to have freq and duty function. Also added creation of default objects based on PWM name set in board config. Adding ifdef surrounding the import of hal_pwm.h as this module might be used by software implmentation of PWM later.
nrf5/pwm: Removing include of hal_pwm.h as pwm.c might not use a hal, but sw implementation.
nrf5: Updating makefile to compile in pwm.c and hal_pwm.c
nrf5/boards: Adding config flag for HAL_PWM in pca10040 and pca10056.
nrf5: Adding pwm work in progress machine PWM module.
nrf5/hal: Starting implementation of PWM hal to be used by PWM python module later.
nrf5: Adding initial board files for pca10056. The files are not complete (only 32 pins are added for now). UART REPL, leds, and Pins (up to 31) are functional.
nrf5: Updating comment in linker script for nrf52832 and nrf52840 to distinguish between the two nrf52 variants.
nrf5: Adding new linker script for nrf52840.
nrf5: updating flash size comment in nrf52832 linker script.
lib/netutils: Adding some basic parsing and formating of ipv6 address strings. Only working with full length ipv6 strings. Short forms not supported at the moment (for example FE80::1, needs to be expressed as FE80:0000:0000:0000:0000:0000:0000:0001).
nrf5: Updating port with new content. SPI, SDcard (trough sdcard.py), Pin, and machine module. Also adding some basic modules depending on SDK and bluetooth stack from nordic semiconductor. NUS is module copied from original port by tralamazza, and new basic module for 6lowpan over BLE which can be used by modnetwork and modusocket. Basic BLE module to enable bluetooth stack and start a eddystone advertisment is kept, and still works without SDK, even if in the SDK folder (its placed there as it needs bluetooth stack from an SDK).
Renaming softdevice folder to sdk.
Removing unused 'NRF_SOFTDEVICE' compile variable from all board .mk softdevice targets.
Fixing main Makefile CFLAGS concatination error when setting softdevice param
Daniel Tralamazza <daniel@tralamazza.com>
ignore default build folders
move softdevice (SD) specific code from the main Makefile to their respective board/SD makefiles
Glenn Ruben Bakke <glennbakke@gmail.com>
Updating Makefile by removing unwanted LDFLAG setting cpu to cortex-m0 in all cases.
Updating modble.c method doc of address_print() to reflect the actual function name.
Base support for nrf51 and nrf52 base without depending on SDK. SoftDevice usage optional.
Daniel Tralamazza <daniel@tralamazza.com>
remove dup declaration mp_builtin_open_obj
init
Date of "init" commit: Wed Jun 22 22:34:11 2016 +0200
The period of the timer can now be specified using the "period" and
"tick_hz" args. The period in seconds will be: period/tick_hz. tick_hz
defaults to 1000, so if period is specified on its own then it will be in
units of milliseconds.
machine.Timer now takes a new argument in its constructor (or init method):
tick_hz which specified the units for the period argument. The period of
the timer in seconds is: period/tick_hz.
For backwards compatibility tick_hz defaults to 1000. If the user wants to
specify the period (numerator) in microseconds then tick_hz can be set to
1000000. The user can also specify a period of an arbitrary number of
cycles of an arbitrary frequency using these two arguments.
An additional freq argument has been added to allow frequencies to be
specified directly in Hertz. This supports floating point values when
available.
Using direct register control as specified by ESP-IDF in
components/esp32/test/test_tsens.c. Temperature doesn't represent any
particular unit, isn't calibrated and will vary from device to device.
Prior to this patch, get_fattime() was calling a HAL RTC function with the
HW instance pointer as null because rtc_init_start() was never called.
Also marked it as a weak function, to allow a board to override it.
With this and previous patches the stm32 port can now be compiled using
object representation D (nan boxing). Note that native code and frozen mpy
files with float constants are currently not supported with this object
representation.
Printing debugging info by defining MICROPY_DEBUG_VERBOSE expects
a definition of the DEBUG_printf function which is readily available
in printf.c so include that file in the build. Before this patch
one would have to manually provide such definition which is tedious.
For the msvc port disable MICROPY_USE_INTERNAL_PRINTF though: the
linker provides no (easy) way to replace printf with the custom
version as defined in printf.c.
Prior to this patch there was a large latency for executing scheduled
callbacks when when Python code is sleeping: at the heart of the
implementation of sleep_ms() is a call to vTaskDelay(1), which always
sleeps for one 100Hz tick, before performing another call to
MICROPY_EVENT_POLL_HOOK.
This patch fixes this issue by using FreeRTOS Task Notifications to signal
the main thread that a new callback is pending.
This patch allows scripts to have more control over the software WDT. If
an instance of machine.WDT is created then the underlying OS is prevented
from feeding the software WDT, and it is up to the user script to feed it
instead via WDT.feed(). The timeout for this WDT is currently fixed and
will be between 1.6 and 3.2 seconds.
A flash erase/write takes a while and during that time tasks may be
scheduled via an IRQ. To prevent overflow of the task queue (and loss of
tasks) call ets_loop_iter() before and after slow flash operations.
Note: if a task is posted to a full queue while a flash operation is in
progress then this leads to a fault when trying to print out the error
message that the queue is full. This patch doesn't try to fix this
particular issue, it just prevents it from happening in the first place.
This function may be called from a UART IRQ, which may interrupt the system
when it is erasing/reading/writing flash. In such a case all code
executing from the IRQ must be in iRAM (because the SPI flash is busy), so
put mp_keyboard_interrupt in iRAM so ctrl-C can be caught during flash
access.
This patch also takes get_fattime out of iRAM and puts it in iROM to make
space for mp_keyboard_interrupt. There's no real need to have get_fattime
in iRAM because it calls other functions in iROM.
Fixes issue #3897.
Target RAM size is no longer set using Kconfig options, but instead using
DTS (device tree config). Fortunately, the default is now set to a high
value, so we don't need to use DTS fixup.
CONFIG_NET_NBUF_RX_COUNT no longer exists in Zephyr, for a while. That
means we build with the default RX buf count for a while too, and it works,
so just remove it (instead of switching to what it was renamed to,
CONFIG_NET_PKT_RX_COUNT).
The API follows guidelines of https://www.python.org/dev/peps/pep-0272/,
but is optimized for code size, with the idea that full PEP 0272
compatibility can be added with a simple Python wrapper mode.
The naming of the module follows (u)hashlib pattern.
At the bare minimum, this module is expected to provide:
* AES128, ECB (i.e. "null") mode, encrypt only
Implementation in this commit is based on axTLS routines, and implements
following:
* AES 128 and 256
* ECB and CBC modes
* encrypt and decrypt
Prior to this patch, if both USB FS and HS were enabled via the
configuration file then code was included to handle both of their IRQs.
But mboot only supports listening on a single USB peripheral, so this patch
excludes the code for the USB that is not used.
Only one of pcd_fs_handle/pcd_hs_handle is ever initialised, so if both of
these USB peripherals are enabled then one of these if-statements will
access invalid memory pointed to by an uninitialised Instance. This patch
fixes this bug by explicitly referencing the peripheral struct.
This patch adds support to mboot for programming external SPI flash. It
allows SPI flash to be programmed via a USB DFU utility in the same way
that internal MCU flash is programmed.
Prior to this patch the QSPI driver assumed that the length of all data
reads and writes was a multiple of 4. This patch allows any length. Reads
are optimised for speed by using 32-bit transfers when possible, but writes
always use a byte transfer because they only use a single data IO line and
are relatively slow.
The DMA peripheral is limited to transferring 65535 elements at a time so
in order to send more than that the SPI driver must split the transfers up.
The user must be aware of this limit if they are relying on precise timing
of the entire SPI transfer, because there might be a small delay between
the split transfers.
Fixes issue #3851, and thanks to @kwagyeman for the original fix.
This behaviour of a NULL write C method on a stream that uses the write
adaptor objects is no longer supported. It was only ever used by the
coverage build for testing the fail path of mp_get_stream_raise().
If the user button is held down indefinitely (eg unintenionally, or because
the GPIO signal of the user button is connected to some external device)
then it makes sense to end the reset mode cycle with the default mode of
1, which executes code as normal.
It's possible (at least on F4 MCU's) to have RXNE and STOPF set at the same
time during a call to the slave IRQ handler. In such cases RXNE should be
handled before STOPF so that all bytes are processed before
i2c_slave_process_rx_end() is called.
Due to buffering of outgoing bytes on the I2C bus, detection of a NACK
using the ISR_NACKF flag needs to account for the case where ISR_NACKF
corresponds to the previous-to-previous byte.
This patch renames the existing SPI flash API functions to reflect the fact
that the go through the cache:
mp_spiflash_flush -> mp_spiflash_cache_flush
mp_spiflash_read -> mp_spiflash_cached_read
mp_spiflash_write -> mp_spiflash_cached_write
The DFU USB config descriptor returns 0x0800=2048 for the supported
transfer size, and this applies to both TX (IN) and RX (OUT). So increase
the rx_buf to support this size without having a buffer overflow on
received data.
With this patch mboot in USB DFU mode now works with dfu-util.
Currently <WLAN>.isconnected() always returns True if a static IP is set,
regardless of the state of the connection.
This patch introduces a new flag 'wifi_sta_connected' which is set in
event_handler() when GOT_IP event is received and reset when DISCONNECTED
event is received (unless re-connect is successful). isconnected() now
simply returns the status of this flag (for STA_IF).
The pre-existing flag misleadingly named 'wifi_sta_connected" is also
renamed to 'wifi_sta_connect_requested'.
Fixes issue #3837
MICROPY_PY_DELATTR_SETATTR can now be enabled without a performance hit for
classes that don't use this feature.
MICROPY_PY_BUILTINS_NOTIMPLEMENTED is a minor addition that improves
compatibility with CPython.
They are now efficient (in runtime performance) and provide a useful
feature that's hard to obtain without them enabled.
See issue #3644 and PR #3826 for background.
Now that the coverage build has fully switched to the VFS sub-system these
functions were no longer available, so add them to the uos_vfs module.
Also, vfs_open is no longer needed, it's available as the built-in open.
The unix coverage build is now switched fully to the VFS implementation, ie
the uos module is the uos_vfs module. For example, one can now sandbox uPy
to their home directory via:
$ ./micropython_coverage
>>> import uos
>>> uos.umount('/') # unmount existing root VFS
>>> vfs = uos.VfsPosix('/home/user') # create new POSIX VFS
>>> uos.mount(vfs, '/') # mount new POSIX VFS at root
Some filesystem/OS features may no longer work with the coverage build due
to this change, and these need to be gradually fixed.
The standard unix port remains unchanged, it still uses the traditional uos
module which directly accesses the underlying host filesystem.
This patch adds support for building the firmware with external SPI RAM
enabled. It is disabled by default because it adds overhead (due to
silicon workarounds) and reduces performance (because it's slower to have
bytecode and objects stored in external RAM).
To enable it, either use "make CONFIG_SPIRAM_SUPPORT=1", or add this line
to you custom makefile/GNUmakefile (before "include Makefile"):
CONFIG_SPIRAM_SUPPORT = 1
When this option is enabled the MicroPython heap is automatically allocated
in external SPI RAM.
Thanks to Angus Gratton for help with the compiler and linker settings.
The Wiznet5k series of chips support a MACRAW mode which allows the host to
send and receive Ethernet frames directly. This can be hooked into the
lwIP stack to provide a full "socket" implementation using this Wiznet
Ethernet device. This patch adds support for this feature.
To enable the feature one must add the following to mpconfigboard.mk, or
mpconfigport.mk:
MICROPY_PY_WIZNET5K = 5500
and the following to mpconfigboard.h, or mpconfigport.h:
#define MICROPY_PY_LWIP (1)
After wiring up the module (X5=CS, X4=RST), usage on a pyboard is:
import time, network
nic = network.WIZNET5K(pyb.SPI(1), pyb.Pin.board.X5, pyb.Pin.board.X4)
nic.active(1)
while not nic.isconnected():
time.sleep_ms(50) # needed to poll the NIC
print(nic.ifconfig())
Then use the socket module as usual.
Compared to using the built-in TCP/IP stack on the Wiznet module, some
performance is lost in MACRAW mode: with a lot of memory allocated to lwIP
buffers, lwIP gives Around 750,000 bytes/sec max TCP download, compared
with 1M/sec when using the TCP/IP stack on the Wiznet module.
It should be up to the NIC itself to decide if the network interface is
removed upon soft reset. Some NICs can keep the interface up over a soft
reset, which improves usability of the network.
Pins with multiple alt-funcs for the same peripheral (eg USART_CTS_NSS)
need to be split into individual alt-funcs for make-pins.py to work
correctly.
This patch changes the following:
- Split `..._CTS_NSS` into `..._CTS/..._NSS`
- Split `..._RTS_DE` into `..._RTS/..._DE`
- Split `JTDO_SWO` into `JTDO/TRACESWO` for consistency
- Fixed `TRACECK` to `TRACECLK` for consistency
If no block devices are defined by a board then storage support will be
disabled. This means there is no filesystem provided by either the
internal flash or external SPI flash. But the VFS system can still be
enabled and filesystems provided on external devices like an SD card.
Mboot is a custom bootloader for STM32 MCUs. It can provide a USB DFU
interface on either the FS or HS peripherals, as well as a custom I2C
bootloader interface.
These files provide no additional information, all the version and license
information is captured in the relevant files in these subdirectories.
Thanks to @JoeSc for the original patch.
This patch allows to use lwIP as the implementation of the usocket module,
instead of the existing socket-multiplexer that delegates the entire TCP/IP
layer to the NIC itself.
This is disabled by default, and enabled by defining MICROPY_PY_LWIP to 1.
When enabled, the lwIP TCP/IP stack will be included in the build with
default settings for memory usage and performance (see
lwip_inc/lwipopts.h). It is then up to a particular NIC to register itself
with lwIP using the standard lwIP netif API.
This patch makes it so that UART(0) can by dynamically attached to and
detached from the REPL by using the uos.dupterm function. Since WebREPL
uses dupterm slot 0 the UART uses dupterm slot 1 (a slot which is newly
introduced by this patch). UART(0) must now be attached manually in
boot.py (or otherwise) and inisetup.py is changed to provide code to do
this. For example, to attach use:
import uos, machine
uart = machine.UART(0, 115200)
uos.dupterm(uart, 1)
and to detach use:
uos.dupterm(None, 1)
When attached, all incoming chars on UART(0) go straight to stdin so
uart.read() will always return None. Use sys.stdin.read() if it's needed
to read characters from the UART(0) while it's also used for the REPL (or
detach, read, then reattach). When detached the UART(0) can be used for
other purposes.
If there are no objects in any of the dupterm slots when the REPL is
started (on hard or soft reset) then UART(0) is automatically attached.
Without this, the only way to recover a board without a REPL would be to
completely erase and reflash (which would install the default boot.py which
attaches the REPL).
Add CONFIG_NET_DHCPV4, which, after
https://github.com/zephyrproject-rtos/zephyr/pull/5750 works as follows:
static addresses are configured after boot, and DHCP requests are sent
at the same time. If valid DHCP reply is received, it overrides static
addresses.
This setup works out of the box for both direct connection to a
workstation (DHCP server usually is not available) and for connection
to a router (DHCP is available and required).
This patch adds the configuration MICROPY_HW_USB_ENABLE_CDC2 which enables
a new USB device configuration at runtime: VCP+VCP+MSC. It will give two
independent VCP interfaces available via pyb.USB_VCP(0) and pyb.USB_VCP(1).
The first one is the usual one and has the REPL on it. The second one is
available for general use.
This configuration is disabled by default because if the mode is not used
then it takes up about 2200 bytes of RAM. Also, F4 MCUs can't support this
mode on their USB FS peripheral (eg PYBv1.x) because they don't have enough
endpoints. The USB HS peripheral of an F4 supports it, as well as both the
USB FS and USB HS peripherals of F7 MCUs.
The documentation (including the examples) for elapsed_millis and
elapsed_micros can be found in docs/library/pyb.rst so doesn't need to be
written in full in the source code.
When disabled, the pyb.I2C class saves around 8k of code space and 172
bytes of RAM. The same functionality is now available in machine.I2C
(for F4 and F7 MCUs).
It is still enabled by default.