aboutsummaryrefslogtreecommitdiff
path: root/ports/nrf/modules
AgeCommit message (Collapse)Author
2020-11-23extmod/machine_i2c: Add init protocol method for generic I2C bindings.Damien George
Hardware I2C implementations must provide a .init() protocol method if they want to support reconfiguration. Otherwise the default is that i2c.init() raises an OSError (currently the case for all ports). mp_machine_soft_i2c_locals_dict is renamed to mp_machine_i2c_locals_dict to match the generic SPI bindings. Fixes issue #6623 (where calling .init() on a HW I2C would crash). Signed-off-by: Damien George <damien@micropython.org>
2020-10-01ports: Support legacy soft I2C/SPI construction via id=-1 arg.Damien George
With a warning that this way of constructing software I2C/SPI is deprecated. The check and warning will be removed in a future release. This should help existing code to migrate to the new SoftI2C/SoftSPI types. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01ports: Add SoftI2C and SoftSPI to machine module where appropriate.Damien George
Previous commits removed the ability for one I2C/SPI constructor to construct both software- or hardware-based peripheral instances. Such construction is now split to explicit soft and non-soft types. This commit makes both types available in all ports that previously could create both software and hardware peripherals: machine.I2C and machine.SPI construct hardware instances, while machine.SoftI2C and machine.SoftSPI create software instances. This is a breaking change for use of software-based I2C and SPI. Code that constructed I2C/SPI peripherals in the following way will need to be changed: machine.I2C(-1, ...) -> machine.SoftI2C(...) machine.I2C(scl=scl, sda=sda) -> machine.SoftI2C(scl=scl, sda=sda) machine.SPI(-1, ...) -> machine.SoftSPI(...) machine.SPI(sck=sck, mosi=mosi, miso=miso) -> machine.SoftSPI(sck=sck, mosi=mosi, miso=miso) Code which uses machine.I2C and machine.SPI classes to access hardware peripherals does not need to change. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01extmod/machine_i2c: Rename type to SoftI2C and add custom print method.Damien George
Also rename machine_i2c_type to mp_machine_soft_i2c_type. These changes make it clear that it's a soft-I2C implementation, and match SoftSPI. Signed-off-by: Damien George <damien@micropython.org>
2020-09-09nrf: Remove unnecessary includes of mpconfigport.h and its header guard.Damien George
The mpconfigport.h file is an internal header and should only ever be included once by mpconfig.h. Signed-off-by: Damien George <damien@micropython.org>
2020-07-08nrf: Add support for time.ticks_xxx functions using RTC1.Martin Fischer
This commit adds time.ticks_ms/us support using RTC1 as the timebase. It also adds the time.ticks_add/diff helper functions. This feature can be enabled using MICROPY_PY_TIME_TICKS. If disabled the system uses the legacy sleep methods and does not have any ticks functions. In addition support for MICROPY_EVENT_POLL_HOOK was added to the time.sleep_ms(x) function, making this function more power efficient and allows support for select.poll/asyncio. To support this, the RTC's CCR0 was used to schedule a ~1msec event to wakeup the CPU. Some important notes about the RTC timebase: - Since the granularity of RTC1's ticks are approx 30usec, time.ticks_us is not perfect, does not have 1us resolution, but is otherwise quite usable. For tighter measurments the ticker's 1MHz counter should be used. - time.ticks_ms(x) should *not* be called in an IRQ with higher prio than the RTC overflow irq (3). If so it introduces a race condition and possibly leads to wrong tick calculations. See #6171 and #6202.
2020-05-15nrf: Update to work with nrfx v2.0.0, to match TinyUSB.Jim Mussared
Commit 6cea369b89b2223cf07ff8768e50dc39bbb770fe updated the TinyUSB submodule to a version based on nrfx v2.0.0. This commit updates the nrf port to work with the latest TinyUSB and nrfx v2.0.0.
2020-04-23all: Remove commented-out include statements.stijn
2020-04-05all: Use MP_ERROR_TEXT for all error messages.Jim Mussared
2020-02-18nrf: Use MICROPY_HW_ENABLE_RNG instead of MICROPY_PY_RANDOM_HW_RNG.Damien George
The "random" module no longer uses the hardware RNG (the extmod version of this module has a pseudo-random number generator), so the config option MICROPY_PY_RANDOM_HW_RNG is no longer meaningful. This commit replaces it with MICROPY_HW_ENABLE_RNG, which controls whether the hardware RNG is included in the build.
2020-02-18nrf: Remove custom "random" module and use extmod version instead.Damien George
Hardware RNG code is moved to drivers/rng.[ch].
2020-02-13py: Add mp_raise_msg_varg helper and use it where appropriate.Damien George
This commit adds mp_raise_msg_varg(type, fmt, ...) as a helper for nlr_raise(mp_obj_new_exception_msg_varg(type, fmt, ...)). It makes the C-level API for raising exceptions more consistent, and reduces code size on most ports: bare-arm: +28 +0.042% minimal x86: +100 +0.067% unix x64: -56 -0.011% unix nanbox: -300 -0.068% stm32: -204 -0.054% PYBV10 cc3200: +0 +0.000% esp8266: -64 -0.010% GENERIC esp32: -104 -0.007% GENERIC nrf: -136 -0.094% pca10040 samd: +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
2020-02-13py: Add mp_raise_type helper macro and use it where appropriate.Damien George
This provides a more consistent C-level API to raise exceptions, ie moving away from nlr_raise towards mp_raise_XXX. It also reduces code size by a small amount on some ports.
2019-12-28lib/utils/pyexec: Introduce MICROPY_REPL_INFO, wrap debug prints in it.Yonatan Goldschmidt
For the 3 ports that already make use of this feature (stm32, nrf and teensy) this doesn't make any difference, it just allows to disable it from now on. For other ports that use pyexec, this decreases code size because the debug printing code is dead (it can't be enabled) but the compiler can't deduce that, so code is still emitted.
2019-10-10nrf: Add nrf9160 base support.Glenn Ruben Bakke
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.
2019-10-02nrf/led: Expose public API for LED manipulation.roland van straten
Aligned implementation with the STM32 port. Added empty functions to be used when no LED is available.
2019-10-02nrf/uart: Add support for UARTE (EasyDMA).Glenn Ruben Bakke
2019-10-02nrf/temp: Move module configuration guard.Glenn Ruben Bakke
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.
2019-10-02nrf/i2c: Add support for TWIM (EasyDMA).Glenn Ruben Bakke
2019-09-05nrf/boards/make-pins.py: Fix gen of board pins to use correct index.Jim Mussared
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).
2019-09-05nrf/machine/adc: Fix mapping of ADC channel to pin.Damien George
2019-09-05nrf/machine/adc: Allow to pass a Pin object in to ADC constructor.Damien George
2019-09-05nrf/machine/adc: Add ADC.read_u16() method.Damien George
2019-08-28nrf: Clean up source by removing tabs, trailing spaces, non-ASCII chars.Damien George
2019-06-25nrf/led: Adjust how board LEDs are defined.Glenn Ruben Bakke
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.
2019-05-22nrf/uart: Make UART print output something, and add write method.Damien George
2019-05-22nrf/uart: Change UART driver to be non-blocking and use IRQs.Damien George
As part of this, ctrl-C is now able to interrupt a running program.
2019-05-20nrf/machine/i2c: Update to support new C-level I2C API.Damien George
2019-05-13nrf: Change types to size_t for all uses of mp_obj_str_get_data.Damien George
2019-05-02nrf/boards: Add support for BLYST Nano module based boards.Nguyen Hoan Hoang
- 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.
2019-02-20nrf/pwm: Remove superfluous NULL in machine_hard_pwm_instances.Stig Bjørlykke
Remove unneeded NULL entry in machine_hard_pwm_instances[] when not building for NRF52_SERIES.
2019-02-12ports: Convert legacy uppercase macro names to lowercase.Damien George
2019-02-02nrf/timer: Fix disabling Timer 1 when using soft PWM.Stig Bjørlykke
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.
2019-01-31nrf/pin: Print pull information in Pin.__str__.Ayke van Laethem
2019-01-31nrf/pin: Cleanup Pin.__str__ to print relevant information.Ayke van Laethem
Code size change: nrf51: -44 nrf52: -52
2019-01-31nrf: Shrink "<peripheral> does not exist" error messages.Ayke van Laethem
Code size reductions: nrf51: -132 nrf52: -188
2019-01-31nrf/uart: Remove unused machine.UART() parameters.Ayke van Laethem
If needed these parameters can be added back and made functional one at a time. It's better to explicitly not support them than to silently allow but ignore them.
2019-01-31nrf/uart: Use formula instead of switch for baudrate calculation.Ayke van Laethem
This saves a bit of code: nrf51: -176 nrf52: -152
2019-01-30nrf/modmachine: Rename machine.sleep to machine.lightsleep.Damien George
2018-08-02nrf/uart: Fix UART.writechar() to write just 1 byte.Ayke van Laethem
2018-08-02nrf/uart: Remove unused UART.char_width field.Ayke van Laethem
Also, clean up some code. Code size change: nrf51: -24 nrf52: -28
2018-08-02nrf: Use separate config for each PWM instance.Stig Bjørlykke
The hard_configs table has entries for each PWM instance. Use them.
2018-08-01nrf: Correct index checking of ADC/PWM/RTCounter instances.Stig Bjørlykke
Avoid trying to use ADC, PWM and RTCounter instances which is one past last available, because this will give a HardFault.
2018-08-01nrf: Enable all PWM, RTC and Timer instances for nrf52840.Stig Bjørlykke
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-01nrf/uos: Add mbfs __enter__ and __exit__ handlers.Stig Bjørlykke
This will make 'with open('file', 'r') as f:' work by properly close the file after the suite is finished.
2018-07-20nrf: Properly use (void) instead of () for function definitions.Damien George
2018-07-18nrf: Use mp_raise_ValueError instead of nlr_raise(...)Ayke van Laethem
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-18nrf: Quick-fix on const objects with open array dimension in objtuples.Glenn Ruben Bakke
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-18nrf/bluetooth: Add support for s132/s140 v6, remove s132 v2/3/5Glenn Ruben Bakke
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-18nrf: Move pyb module to boards moduleGlenn Ruben Bakke
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.