Commit Graph

243 Commits (5bb3ede8904d2488c60b1d7539dff2edcce87062)

Author SHA1 Message Date
Andrew Leech 5bb3ede890 Comment out the assert test that requires non-existent symbols from linker 2018-05-22 11:36:30 +10:00
Andrew Leech 244b7a5c69 Only enable DEBUG_NRF_USER when NDEBUG is not set 2018-05-22 11:36:30 +10:00
Andrew Leech f49070c876 Address known typo in nrf sdk 11
ref: https://devzone.nordicsemi.com/f/nordic-q-a/14000/nrf_drv_adc-c-doesn-t-compile-with--ddebug_nrf
2018-05-22 11:36:30 +10:00
Marcus Chang ef9bc9ccc9 Add NRF52 support for building bootloader and updateable firmware
New directory structure:

 * TARGET_SOFTDEVICE_COMMON
 * TARGET_SOFTDEVICE_S112
 * TARGET_SOFTDEVICE_S132_FULL (MBR + SoftDevice, default)
 * TARGET_SOFTDEVICE_S132_OTA (SoftDevice only, for firmware updates)
 * TARGET_SOFTDEVICE_S132_MBR (MBR only, for bootloader builds)
 * TARGET_SOFTDEVICE_S140_FULL (MBR + SoftDevice, default)
 * TARGET_SOFTDEVICE_S140_OTA (SoftDevice only, for firmware updates)
 * TARGET_SOFTDEVICE_S140_MBR (MBR only, for bootloader builds)
 * TARGET_SOFTDEVICE_NONE

The X_OTA and X_MBR binaries are obtained from the original x_FULL SoftDevice
by splitting it in an MBR part and a SoftDevice part. The MBR is needed for
the bootloader and the SoftDevice for firmware updates.

Build application without SoftDevice:

  "target_overrides": {
      "*": {
          "target.extra_labels_remove": ["SOFTDEVICE_COMMON", "SOFTDEVICE_X_FULL"],
          "target.extra_labels_add": ["SOFTDEVICE_NONE"]
      }
  }

Build application for firmware update using SoftDevice X:

  "target_overrides": {
      "*": {
          "target.extra_labels_remove": ["SOFTDEVICE_X_FULL"],
          "target.extra_labels_add": ["SOFTDEVICE_X_OTA"]
      }
  }

Build bootloader without SoftDevice X:

  "target_overrides": {
      "*": {
          "target.extra_labels_remove": ["SOFTDEVICE_COMMON", "SOFTDEVICE_X_FULL"],
          "target.extra_labels_add": ["SOFTDEVICE_X_MBR"]
      }
  }
2018-05-17 07:32:09 -07:00
Marcus Chang 6af843fceb Trim white space and clean up NRF52 configuration files
Removed unused and duplicate macros.
2018-05-13 22:31:17 -07:00
Cruz Monrreal 2104d8ab5b
Merge pull request #6711 from marcuschangarm/cleanup-nrf5x
Cleanup TARGET_NRF5 and TARGET_NRF5x
2018-05-11 19:15:05 -05:00
Marcus Chang 34775d6431 Remove obsolete OS_IDLE_THREAD_STACK_SIZE from NRF52
Custom size is the same as the default size anyway.
2018-05-08 15:51:39 -07:00
Marcus Chang 1aebdcbee5 Reorganize TARGET_MCU_NRF51822_UNIFIED directories
The unified NRF51 target and feature BLE directories have been
reorganized to follow the naming and directory structure of the
NRF52 implementation.

This reorganization does not include TARGET_MCU_NRF51822 and
derived targets.
2018-05-08 10:10:01 -07:00
Marcus Chang 1360920e77 Remove unused NRF52 SDK and MCU files
Superseded by new SDK 14.2 in https://github.com/ARMmbed/mbed-os/pull/6547
2018-05-07 12:18:29 -07:00
Cruz Monrreal e023bb67c4
Merge pull request #6771 from marcuschangarm/fix-uart-init
Fix UART initialization for NRF52
2018-05-07 10:35:40 -05:00
Martin Kojtal 5a77f42882
Merge pull request #6796 from marcuschangarm/fix-nrf52-tick
Fix us_ticker for NRF52 series
2018-05-07 08:17:58 +01:00
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