Commit Graph

195 Commits (837ba72cc1debabca1443977f6521f53a519f023)

Author SHA1 Message Date
Marcus Chang 41c1654a49 Fix bug in MBR for NRF52 series
The MBR VTOR state depends on how the application is booted.
This makes it difficult to initialize the MBR correctly since a
bug prevents the MBR from being initialized more than once.

This commit resets the MBR and SoftDevice to a known state before
initializing the MBR and setting the VTOR through the SoftDevice.
2018-05-02 21:10:41 -07:00
Marcus Chang b8f22bbec1 Fix us_ticker for NRF52 series
Changed comparison function when setting ticker timeout to fix
tickers not set correctly.
2018-05-02 16:10:14 -07:00
Marcus Chang a1a329606b Fix UART initialization for NRF52
Delayed initialization can cause problems when both UARTE instances
are in use. This change causes each UART object to initialize the
underlying UARTE instance immediately.
2018-05-02 15:07:13 -07:00
Jimmy Brisson d08c819830
Merge pull request #6746 from marcuschangarm/fix-vector-relocation
Fix vector table relocation for NRF52
2018-04-30 13:51:22 -05:00
Cruz Monrreal e1cc4559cf
Merge pull request #6748 from andrewleech/nrf52_serial_match_assert
nrf5x: Fix assert test on SERIAL_RESERVED_CHAR_MATCH
2018-04-30 11:50:05 -05:00
Marcus Chang bb14051588 Fix vector table relocation for NRF52
The vector table relocation sequence depends on:

1. Whether the SoftDevice is present.
2. The Application is a bootloader or not.

If the SoftDevice is present and the application is a bootloader
the MBR must be initialized to trap SoftDevice service calls
before setting the new vector table address.

The SCB->VTOR must be set to point at the MBR as well.

If the SoftDevice is not present the SCB->VTOR can point at the
new vector table directly.
2018-04-27 13:40:50 -07:00
Cruz Monrreal 487576972b
Merge pull request #6720 from marcuschangarm/fix-sdk-spi
Fix bug in Nordic SDK 14.2 SPI driver
2018-04-26 20:17:36 -05:00
Cruz Monrreal 9d6d8c7273
Merge pull request #6721 from marcuschangarm/fix-sdk-i2c
Fix bug in Nordic SDK 14.2 I2C driver
2018-04-26 20:17:25 -05:00
Andrew Leech 627d028f3e nrf5x: Add description to assert on SERIAL_RESERVED_CHAR_MATCH 2018-04-27 11:05:47 +10:00
Marcus Chang 3edfc77949 Fix bug in Nordic SDK 14.2 I2C driver
Interrupts were not enabled before transmitting data leading to
missed interrupts.
2018-04-23 16:38:31 -07:00
Marcus Chang cba7e0df06 Fix bug in Nordic SDK 14.2 SPI driver
Interrupts were not enabled before transmitting data leading to
missed interrupts.
2018-04-23 16:08:44 -07:00
Marcus Chang 6db4425351 Fix NRF52 SPI pin initialization
SPI pins are not initialized correctly according to the current
SPI mode.

This commit changes how the SPI instance is configured and ensures
that:

1. SPI pins are initialized on each object initialization.
2. SPI pins are reinitialized on each mode or object change.
3. SPI instance is only initialized when a change has occured.
2018-04-23 14:27:33 -07:00
Marcus Chang b964420bbc Reorganize targets.json for NRF52 based targets
* Consolidated device_has and macros to the main MCU targets.
* Moved errata configuration to mbed_lib.json for HAL implementation.
* Moved clock configuration to mbed_lib.json for HAL implementation.
* Moved UART configuration to mbed_lib.json for HAL implementation.
2018-04-19 09:41:05 -07:00
Marcus Chang 2c651afd11 Updated target MTB_LAIRD_BL652 to use SDK 14.2 2018-04-19 09:40:41 -07:00
Marcus Chang b9f91b3839 Fix off-by-one error in NRF52 serial implementation 2018-04-19 09:40:41 -07:00
Marcus Chang 18fa9414cd Add resource management for serial for the NRF52 family
Instance counter keeps track of how many objects have been
initialized and freed. On the first object the instance is
enabled and on the last object the instance is disabled.
2018-04-19 09:40:41 -07:00
Marcus Chang cafa8ae752 Fix serial_putc bug in NRF52 family
serial_putc didn't work when called with interrupts disabled.
2018-04-19 09:40:41 -07:00
Marcus Chang 3663494bd9 Serial re-implementation for the NRF52 series
Serial implementation uses UARTE instead of UART peripheral:

* EasyDMA is used for reading and writing data.
* Triple buffering for receiving data.

See README for full description.
2018-04-19 09:40:41 -07:00
Marcus Chang 9502011d96 README file for NRF52 HAL implementation
Added SPI and I2C section.
2018-04-19 09:40:41 -07:00
Marcus Chang fc8f0e1aa4 I2C HAL update for NRF52
When possible, the I2C HAL will now use the TWI driver in SDK 14.

The manual I2C API still maps onto the old TWI peripheral directly
because the TWI driver doesn't provide the needed low-level functionality.
2018-04-19 09:40:41 -07:00
sarahmarshy c9d16e9e89 Implement SPI API for NRF52x
Implement spi_api.c for NRF52X boards using SDK14.

This driver does not implement SPI slave functions and does not use SPIM.
2018-04-19 09:40:41 -07:00
Marcus Chang d11f74cb4c NRF52 series PWM reimplementation for SDK 14.2
Driver uses new API in SDK 14.2
2018-04-19 09:40:41 -07:00
Marcus Chang cfb480447a NRF52: fix us_ticker IRQ handler
Applying PR to NRF52 SDK 14.2:
https://github.com/ARMmbed/mbed-os/pull/5046
2018-04-19 09:40:41 -07:00
Marcus Chang 8dd627621e Fix ISR stack size inconsistencies on NRF52 series
GCC and IAR ISR stack sizes have been set to 0x800.
(ARM compiler does not set stack size explicitly).
2018-04-19 09:40:41 -07:00
Marcus Chang 6db7e68db5 Helper functions for sharing hardware peripherals on NRF52
Common functions for getting and setting the instance owner of a
hardware peripheral. Used for reconfiguring SPI/I2C after change
of ownership.
2018-04-19 09:40:41 -07:00
Blackstone Engineering ea6c0078c7 Extended PeripheralPins and pinmap for NRF52 series
The NRF52 series can map digital signals to any physical pin which
makes it challenging to associate pin names with hardware instances.

pinmap_ex:
  Keep track of which hardware instance is in use and what pins are
  associated with it. Currently only supports I2C and SPI, but
  provides a mechanism for allocating the shared I2C/SPI hardware.

PeripheralPinsDefault:
  Optional pin map for pre-assigning hardware instances at compile
  time. This makes it easier to optimize hardware utilization.
2018-04-19 09:40:41 -07:00
Marcus Chang f0d1424768 Update analogin_api.c for NRF52 SDK 14.2
Use new SDK API and fixed return value to be normalized to 16 bit
as per the Mbed HAL specification.
2018-04-19 09:40:41 -07:00
Donatien Garnier 64baf717e8 Upgrade NRF52 BLE API to version 5
* Add NRF_SD_BLE_API_VERSION=5 macro to MCU_NRF52832 target
* Added initial Softdevice v5 API support for nRF5XPalGattClient.cpp
* Added initial Softdevice v5 API support for nRF5xGap.h
* Added initial Softdevice v5 API support for nRF5xGattServer.cpp
* Make sure the ah() hash function used by the security manager is declared with C linkage
* Removed 'ARM porting pending' checks in Nordic SDK
* Added BLE configuration to mbed_lib.json for NRF52x targets
* Migrated APIs and events model for Nordic SDK14.2 & SD API v5 in btle.cpp; adopted polling dispatch model
* Migrated APIs and events model for Nordic SDK14.2 & SD API v5 in nRF5xn.cpp
* Migrated APIs and events model for Nordic SDK14.2 & SD API v5 in nRF5xGap.cpp
* Added const qualifier to hwCallbacks's p_ble_evt parameter in nRF5xGattServer
* Add workaround to enable Radio Notification module from Nordic SDK
  * Disabled SWI1 interrupt manually from SWI driver module
    * Added missing include directive for "nrf_nvic.h" in ble_radio_notification.c
* Set correct number of custom UUIDs
* Adjust Softdevice RAM requirements for NRF52832/S132
  * RAM settings for the application were adjusted as follow:
    * Start: 0x20003800
    * Size: 0xC800
* Adjust Softdevice RAM requirements for NRF52840/S140
  * RAM settings for the application were adjusted as follow:
    * Start: 0x20003700 (was 0x20003000)
    * Size: 0xC900
* Added 3dBm as a permitted TX Power value for NRF52832
* Fix address type recovery in GAP
* Return min non-connectable adv interval compatible with infrastrcture's expectations
* Moved BLE driver from TARGET_SDK_14_2/FEATURE_BLE to TARGET_SDK_14_2/TARGET_SOFTDEVICE_COMMON/ble
2018-04-19 09:40:41 -07:00
Marcus Chang fa79e685fc Fix TRNG for NRF52
* When multiple TRNG objects are initialized, destroying the first
  object will turn the TRNG off for the other objects. This fix
  adds a counter to ensure that only when the last object is
  destroyed will it cause the TRNG to be disabled.

* The corner case where a user request 0 bytes is correctly handled
  and will now return immediately.
2018-04-19 09:40:41 -07:00
Marcus Chang 3b9ec4932c Flash storage for NRF52
Add fstorage and fds from Nordic SDK for SoftDevice compatible
flash storage. Mbed HAL flash API mapped to use fstorage API
to ensure write and erase doesn't conflict with BLE operation.
2018-04-19 09:40:41 -07:00
Marcus Chang 2e7b5ba27b Fix linker scripts and startup code for NRF52
Various bug fixes:

 * Moved SPIM3 location in vector table based on new location in SDK 14.2.
 * Updated vector table entries and size in startup code and linker scripts.
 * Added missing vector table RAM section to IAR linker script.
2018-04-19 09:40:41 -07:00
Marcus Chang 00713342b9 Switch to managed bootloader for SoftDevice merge on NRF52
SoftDevice can be swapped even easier now:

    "target_overrides": {
        "*": {
            "target.extra_labels_remove": ["SOFTDEVICE_COMMON", "SOFTDEVICE_S140"],
            "target.extra_labels_add": ["SOFTDEVICE_NONE"]
        }
    }
2018-04-19 09:40:41 -07:00
Marcus Chang 39c69f146c Optional SoftDevice for the NRF52 series
Ability to swap SoftDevices using the mbed configuration system.

For example, build NRF52840_DK without SoftDevice:

    "target_overrides": {
        "*": {
            "target.MERGE_SOFT_DEVICE": false,
            "target.extra_labels_remove": ["SOFTDEVICE_COMMON", "SOFTDEVICE_S140"],
            "target.extra_labels_add": ["SOFTDEVICE_NONE"]
        }
    }

Pinned down vector table to beginningn of RAM.
2018-04-19 09:40:41 -07:00
Marcus Chang 770b1a326e Simplified critical_section_api.c for NRF52 series
Critical section enter/exit is now delegated to Nordic SDK's

sd_nvic_critical_region_enter
sd_nvic_critical_region_exit

When the SoftDevice is not included these functions map to

__disable_irq
__enable_irq
2018-04-19 09:40:41 -07:00
Marcus Chang 5c3e494a7e Renamed MCU_NRF52832 inheritance in MTB_UBLOX_NINA_B1 2018-04-19 09:40:41 -07:00
Marcus Chang c049921064 Add GCC linker sections for NRF52 SoftDevice 2018-04-19 09:40:41 -07:00
Marcus Chang cf61c240bf Update critical section for NRF5x 2018-04-19 09:40:41 -07:00
Marcus Chang efa3461fd4 Change target.json to use new SDK and folder structure for NRF52 2018-04-19 09:40:41 -07:00
Marcus Chang 3940d3abaf Default SDK configuration for NRF52832 and NRF52840 2018-04-19 09:40:41 -07:00
Marcus Chang 0b40ddc530 Initial mbed HAL implementation for NRF5x family
Copied from previous location in targets/TARGET_NORDIC/TARGET_NRF5

Core functionality is working but some peripherals do not.
2018-04-19 09:40:41 -07:00
Marcus Chang d861bda214 Pin configurations for NRF52840 based boards 2018-04-19 09:40:41 -07:00
Marcus Chang 56cf0921ad Pin configurations for NRF52832 based boards 2018-04-19 09:40:41 -07:00
Marcus Chang ad1b986913 Linker scripts and startup files for NRF52840
Flash and RAM offsets have been modified to fit new SoftDevice
2018-04-19 09:40:41 -07:00
Marcus Chang bff552de6c Linker scripts and startup files for NRF52832
Flash and RAM offsets have been modified to fit new SoftDevice
2018-04-19 09:40:41 -07:00
Marcus Chang fc2760ad04 NRF52832 and NRF52840 upgraded to Nordic SDK 14 and SoftDevice 5.0
Initial commit for separating NRF52 code from the NRF51 and for
combining the NRF52832 and NRF52840 SDK to version 14.

nRF5_SDK_14.2.0_17b948a.zip has been used as baseline.

The folders in SDK/components:
 * ble
 * boards
 * device
 * drivers_nrf
 * libraries
 * softdevice

have been copied to TARGET_NORDIC/TARGET_NRF52/TARGET_SDK14.

Each folder contains a README.md file describing any modifications
made to that particular folder. Most common operation is deletion
of files.

If the need arise in the future the missing files can be added again.

The SoftDevices have been moved to TARGET_SOFTDEVICE_x folders for
flexible selection.

ble.h has been renamed to nrf_ble.h to avoid namespace clash with
mbed OS BLE.
2018-04-19 09:40:41 -07:00