Commit Graph

627 Commits

Author SHA1 Message Date
Damien George
7be5bb3672 stm32/adc: Fix ADC reading on F0 MCUs to only sample a single channel.
And increase sampling time to get better results for internal channels.
2018-08-04 13:33:02 +10:00
Damien George
c62b23094f stm32/adc: Disable VBAT in read channel helper function.
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.
2018-08-04 13:25:43 +10:00
Ayke van Laethem
e755bd4932
nrf/uart: Fix UART.writechar() to write just 1 byte. 2018-08-02 22:21:24 +02:00
Ayke van Laethem
60a05485cb
nrf/uart: Remove unused UART.char_width field.
Also, clean up some code.
Code size change:
nrf51: -24
nrf52: -28
2018-08-02 22:18:16 +02:00
Stig Bjørlykke
2cf2ad943e nrf: Use separate config for each PWM instance.
The hard_configs table has entries for each PWM instance. Use them.
2018-08-02 20:36:18 +02:00
Damien George
da2d2b6d88 py/mpconfig.h: Introduce MICROPY_DEBUG_PRINTER for debugging output.
This patch in effect renames MICROPY_DEBUG_PRINTER_DEST to
MICROPY_DEBUG_PRINTER, moving its default definition from
lib/utils/printf.c to py/mpconfig.h to make it official and documented, and
makes this macro a pointer rather than the actual mp_print_t struct.  This
is done to get consistency with MICROPY_ERROR_PRINTER, and provide this
macro for use outside just lib/utils/printf.c.

Ports are updated to use the new macro name.
2018-08-02 14:04:44 +10:00
Stig Bjørlykke
0c161691b4 nrf: Correct index checking of ADC/PWM/RTCounter instances.
Avoid trying to use ADC, PWM and RTCounter instances which is
one past last available, because this will give a HardFault.
2018-08-01 14:56:07 +02:00
Stig Bjørlykke
7f0c5f2ef9 nrf: Enable all PWM, RTC and Timer instances for nrf52840.
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.
2018-08-01 14:36:07 +02:00
Stig Bjørlykke
b6e49da407
nrf/uos: Add mbfs __enter__ and __exit__ handlers.
This will make 'with open('file', 'r') as f:' work by properly close
the file after the suite is finished.
2018-08-01 14:12:34 +02:00
Damien George
5482d84673 stm32/modmachine: Get machine.sleep working on L4 MCUs.
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.
2018-08-01 17:14:19 +10:00
Damien George
c12348700f stm32/extint.h: Use correct EXTI lines for RTC interrupts. 2018-08-01 17:13:49 +10:00
Damien George
21dae87710 stm32/modmachine: Get machine.sleep working on F0 MCUs. 2018-07-31 17:25:53 +10:00
Damien George
9dfbb6cc16 stm32/rtc: Get rtc.wakeup working on F0 MCUs.
The problem was that the EXTI line for the RTC wakeup event is line 20 on
the F0, so the interrupt was not firing.
2018-07-31 17:24:10 +10:00
Damien George
f6f6452b6f stm32/Makefile: Use -Wno-attributes for ll_usb.c HAL source file.
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.
2018-07-30 15:35:05 +10:00
Damien George
90fc7c5cfa stm32/sdcard: Get SDMMC alt func macro names working with F4,F7,H7 MCUs. 2018-07-30 15:33:33 +10:00
Andrew Leech
434975defa stm32/boards/STM32F429DISC: Enable onboard SDRAM. 2018-07-23 23:16:32 +10:00
Andrew Leech
968fa47392 stm32/sdram: On F7 MCUs enable MPU on external SDRAM.
This prevents hard-faults on non-aligned accesses.

Reference: http://www.keil.com/support/docs/3777.htm
2018-07-23 23:15:18 +10:00
Andrew Leech
a1db1506a2 stm32/sdram: Integrate SDRAM driver into rest of code.
If SDRAM is configured and enabled for a board then it is used for the
MicroPython GC heap.
2018-07-23 23:14:23 +10:00
Andrew Leech
7ae053abfd stm32/sdram: Add SDRAM driver from OpenMV project.
Taken from 7fbe54ad4e/src/omv/sdram.c

Code is is MIT licensed.
2018-07-23 23:13:24 +10:00
Ayke van Laethem
7067ac3573 nrf/drivers/flash: Fix incorrect page alignment check. 2018-07-23 16:12:33 +10:00
roland
6a31dcd638 nrf: Update nrfjprog links to allow to download any version.
Instead of downloading "a" version, these links point to history from where
you can download the verson you like.
2018-07-23 16:11:40 +10:00
Damien George
6ac4304284 nrf/boards/microbit: Use MICROPY_PY_BUILTINS_FLOAT to detect FP support.
This works for both single and double precision float.
2018-07-20 14:11:28 +10:00
Damien George
9addc38af4 nrf: Properly use (void) instead of () for function definitions. 2018-07-20 14:11:28 +10:00
Damien George
55632af70a nrf/Makefile: Make sure dependencies for pins_gen.c are correct. 2018-07-20 14:11:28 +10:00
Damien George
4201f36a46 stm32/sdcard: Use mp_hal_pin_config_alt_static to configure SD card pins 2018-07-20 14:03:21 +10:00
Andrew Leech
4343c9330e stm32: Add method for statically configuring pin alternate function.
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.
2018-07-20 14:03:21 +10:00
Damien George
ef554ef9a2 unix: Use MP_STREAM_GET_FILENO to allow uselect to poll general objects.
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.
2018-07-20 13:09:49 +10:00
Peter D. Gray
a8736e5c36 stm32/flashbdev: Fix bug with L4 block cache, dereferencing block size.
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.
2018-07-19 12:15:34 +10:00
Ayke van Laethem
8df342d330 nrf: Include $(SRC_MOD) in the build.
Also, remove the unused $(SRC_LIB).
2018-07-19 00:35:24 +10:00
Ayke van Laethem
2f0f4fdcd3
nrf: Use mp_raise_ValueError instead of nlr_raise(...)
Saves 60 bytes on the nRF52 with SD disabled. There will be a bigger
saving with SD enabled and/or on the micro:bit board.
2018-07-18 15:25:17 +02:00
Glenn Ruben Bakke
264d80c84e nrf/drivers: Add license text to ticker.h and softpwm.h.
As per the LICENSE and AUTHORS files from the original source of these
header files.
2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke
ea00717a57 nrf: Compile nlr objects with -fno-lto flag
To prevent over-optimizations of nlr and nlrthumb when -flto is used
the flag -fno-lto is set on these modules during compilation.
2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke
14d257c66b nrf: Add explicit make flag for oofatfs
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.
2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke
50ee908896 nrf/bluetooth: Replace BLE REPL (WebBluetooth) URL
Updating URL of the WebBluetooth/PhysicalWeb from
https://glennrub.github.io/webbluetooth/micropython/repl to
https://aykevl.nl/apps/nus/.
2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke
cf58ef27af nrf: Quick-fix on const objects with open array dimension in objtuples.
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).
2018-07-18 17:12:26 +10:00
Ayke van Laethem
0e5f8425ea nrf/boards: Check for stack/heap size using an assert.
The main effect of this is that the .bss is now accurate and doesn't
include the stack and minimum heap size.
2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke
7144e87ced nrf/bluetooth: Add support for s132/s140 v6, remove s132 v2/3/5
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.
2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke
db67a5000f nrf: Generalize feather52 target
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.
2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke
b7ce2f1460 nrf: Add support for reading output pin state
Current adoption on top of nrfx only reads the GPIO->IN register.
In order to read back an output state, nrf_gpio_pin_out_read has
to be called.

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

Updating lib/nrfx submodule to latest version of master to get
the new GPIO API to read pin direction.
(nrfx: d37b16f2b894b0928395f6f56ca741287a31a244)
2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke
6011441342 nrf: Move pyb module to boards module
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.
2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke
4a323f8b80 nrf/nrfx_config: Move back nrf52832 to use non-EasyDMA SPI
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.
2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke
5925004da3 nrf/modules/machine/spi: Move enable-guard to prevent wrong includes
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.
2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke
774638e2a9 nrf/boards/feather52: Move phony targets to main Makefile
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.
2018-07-18 17:12:26 +10:00
Glenn Ruben Bakke
d3311681a9 nrf: Enable micro:bit FS by default
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.
2018-07-18 17:12:26 +10:00
Ayke van Laethem
a4615672d4 nrf/modules/uos/microbitfs: Remove unused uos_mbfs_mount.
It throws an error in GCC 6.3.
2018-07-18 17:12:26 +10:00
Ayke van Laethem
635064c432 nrf/modules/uos/microbitfs: Fix errno defines.
Probably broken after the recent Clang fixes to errno.h.
2018-07-18 17:12:26 +10:00
Ayke van Laethem
1aa9ff9141 nrf/mphalport: Remove divided assembly syntax. 2018-07-18 17:12:26 +10:00
Ayke van Laethem
fb17105183 nrf: Remove useless #include <errno.h>. 2018-07-18 17:12:26 +10:00
Ayke van Laethem
17769452d4 nrf/modules/machine/adc: Don't compare -1 to an unsigned number.
Clang warns about this.
2018-07-18 17:12:26 +10:00
Ayke van Laethem
4111206bd5 nrf/Makefile: Refine dead-code elimination parameters.
Clang warns about useless -Wl,--gc-sections passed in CFLAGS.
2018-07-18 17:12:26 +10:00