Updates to PWM for IOTDEV-1573

- Missed some NRFX defines that needed to changed
- Set PWM base clock to 125kHz (needs to be reverted back to 1 MHz)
- Updated sdk_config.h for nRF52_DK builds
- Brought in updates from PR7779 (fix for nRF52 PWM issues)
pull/10652/head
RFulchiero 2018-08-23 15:23:57 -05:00 committed by desmond.chen
parent cc54611f02
commit 9593a53e25
2 changed files with 50 additions and 61 deletions

View File

@ -46,7 +46,7 @@
#endif #endif
// <h> nRF_BLE // <h> nRF_BLE
//========================================================== //==========================================================
// <q> BLE_ADVERTISING_ENABLED - ble_advertising - Advertising module // <q> BLE_ADVERTISING_ENABLED - ble_advertising - Advertising module
@ -187,7 +187,7 @@
// <4=> Yellow // <4=> Yellow
// <5=> Blue // <5=> Blue
// <6=> Magenta // <6=> Magenta
// <7=> Cyan // <7=> Cyan
// <8=> White // <8=> White
#ifndef BLE_BAS_CONFIG_INFO_COLOR #ifndef BLE_BAS_CONFIG_INFO_COLOR
@ -1862,7 +1862,7 @@
// <e> NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver // <e> NRFX_GPIOTE_ENABLED - nrfx_gpiote - GPIOTE peripheral driver
//========================================================== //==========================================================
#ifndef NRFX_GPIOTE_ENABLED #ifndef NRFX_GPIOTE_ENABLED
#define NRFX_GPIOTE_ENABLED 0 #define NRFX_GPIOTE_ENABLED 1
#endif #endif
// <o> NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins // <o> NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS - Number of lower power input pins
#ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS #ifndef NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS
@ -2463,31 +2463,31 @@
// <e> NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver // <e> NRFX_PWM_ENABLED - nrfx_pwm - PWM peripheral driver
//========================================================== //==========================================================
#ifndef NRFX_PWM_ENABLED #ifndef NRFX_PWM_ENABLED
#define NRFX_PWM_ENABLED 0 #define NRFX_PWM_ENABLED 1
#endif #endif
// <q> NRFX_PWM0_ENABLED - Enable PWM0 instance // <q> NRFX_PWM0_ENABLED - Enable PWM0 instance
#ifndef NRFX_PWM0_ENABLED #ifndef NRFX_PWM0_ENABLED
#define NRFX_PWM0_ENABLED 0 #define NRFX_PWM0_ENABLED 1
#endif #endif
// <q> NRFX_PWM1_ENABLED - Enable PWM1 instance // <q> NRFX_PWM1_ENABLED - Enable PWM1 instance
#ifndef NRFX_PWM1_ENABLED #ifndef NRFX_PWM1_ENABLED
#define NRFX_PWM1_ENABLED 0 #define NRFX_PWM1_ENABLED 1
#endif #endif
// <q> NRFX_PWM2_ENABLED - Enable PWM2 instance // <q> NRFX_PWM2_ENABLED - Enable PWM2 instance
#ifndef NRFX_PWM2_ENABLED #ifndef NRFX_PWM2_ENABLED
#define NRFX_PWM2_ENABLED 0 #define NRFX_PWM2_ENABLED 1
#endif #endif
// <q> NRFX_PWM3_ENABLED - Enable PWM3 instance // <q> NRFX_PWM3_ENABLED - Enable PWM3 instance
#ifndef NRFX_PWM3_ENABLED #ifndef NRFX_PWM3_ENABLED
#define NRFX_PWM3_ENABLED 0 #define NRFX_PWM3_ENABLED 0
@ -2921,7 +2921,7 @@
// <e> NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver // <e> NRFX_RNG_ENABLED - nrfx_rng - RNG peripheral driver
//========================================================== //==========================================================
#ifndef NRFX_RNG_ENABLED #ifndef NRFX_RNG_ENABLED
#define NRFX_RNG_ENABLED 0 #define NRFX_RNG_ENABLED 1
#endif #endif
// <q> NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction // <q> NRFX_RNG_CONFIG_ERROR_CORRECTION - Error correction
@ -3114,7 +3114,7 @@
// <e> NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver // <e> NRFX_SAADC_ENABLED - nrfx_saadc - SAADC peripheral driver
//========================================================== //==========================================================
#ifndef NRFX_SAADC_ENABLED #ifndef NRFX_SAADC_ENABLED
#define NRFX_SAADC_ENABLED 0 #define NRFX_SAADC_ENABLED 1
#endif #endif
// <o> NRFX_SAADC_CONFIG_RESOLUTION - Resolution // <o> NRFX_SAADC_CONFIG_RESOLUTION - Resolution
@ -3218,40 +3218,34 @@
// </e> // </e>
// needed to build
#define NRFX_SPIM0_ENABLED 1
#define NRFX_SPIM1_ENABLED 1
#define NRFX_SPIM2_ENABLED 1
// <e> NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver // <e> NRFX_SPIM_ENABLED - nrfx_spim - SPIM peripheral driver
//========================================================== //==========================================================
#ifndef NRFX_SPIM_ENABLED #ifndef NRFX_SPIM_ENABLED
#define NRFX_SPIM_ENABLED 0 #define NRFX_SPIM_ENABLED 1
#endif #endif
// <q> NRFX_SPIM0_ENABLED - Enable SPIM0 instance // <q> NRFX_SPIM0_ENABLED - Enable SPIM0 instance
#ifndef NRFX_SPIM0_ENABLED #ifndef NRFX_SPIM0_ENABLED
#define NRFX_SPIM0_ENABLED 0 #define NRFX_SPIM0_ENABLED 1
#endif #endif
// <q> NRFX_SPIM1_ENABLED - Enable SPIM1 instance // <q> NRFX_SPIM1_ENABLED - Enable SPIM1 instance
#ifndef NRFX_SPIM1_ENABLED #ifndef NRFX_SPIM1_ENABLED
#define NRFX_SPIM1_ENABLED 0 #define NRFX_SPIM1_ENABLED 1
#endif #endif
// <q> NRFX_SPIM2_ENABLED - Enable SPIM2 instance // <q> NRFX_SPIM2_ENABLED - Enable SPIM2 instance
#ifndef NRFX_SPIM2_ENABLED #ifndef NRFX_SPIM2_ENABLED
#define NRFX_SPIM2_ENABLED 0 #define NRFX_SPIM2_ENABLED 1
#endif #endif
// <q> NRFX_SPIM3_ENABLED - Enable SPIM3 instance // <q> NRFX_SPIM3_ENABLED - Enable SPIM3 instance
#ifndef NRFX_SPIM3_ENABLED #ifndef NRFX_SPIM3_ENABLED
#define NRFX_SPIM3_ENABLED 0 #define NRFX_SPIM3_ENABLED 0
@ -3460,14 +3454,14 @@
#ifndef NRFX_SPI0_ENABLED #ifndef NRFX_SPI0_ENABLED
#define NRFX_SPI0_ENABLED 1 #define NRFX_SPI0_ENABLED 0
#endif #endif
// <q> NRFX_SPI1_ENABLED - Enable SPI1 instance // <q> NRFX_SPI1_ENABLED - Enable SPI1 instance
#ifndef NRFX_SPI1_ENABLED #ifndef NRFX_SPI1_ENABLED
#define NRFX_SPI1_ENABLED 0 #define NRFX_SPI1_ENABLED 1
#endif #endif
// <q> NRFX_SPI2_ENABLED - Enable SPI2 instance // <q> NRFX_SPI2_ENABLED - Enable SPI2 instance
@ -5032,7 +5026,7 @@
#endif #endif
// <q> RTC1_ENABLED - Enable RTC1 instance // <q> RTC1_ENABLED - Enable RTC1 instance
#ifndef RTC1_ENABLED #ifndef RTC1_ENABLED
#define RTC1_ENABLED 0 #define RTC1_ENABLED 0
@ -5055,7 +5049,7 @@
// <e> SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer // <e> SAADC_ENABLED - nrf_drv_saadc - SAADC peripheral driver - legacy layer
//========================================================== //==========================================================
#ifndef SAADC_ENABLED #ifndef SAADC_ENABLED
#define SAADC_ENABLED 0 #define SAADC_ENABLED 1
#endif #endif
// <o> SAADC_CONFIG_RESOLUTION - Resolution // <o> SAADC_CONFIG_RESOLUTION - Resolution
@ -5074,7 +5068,7 @@
// <1=> 2x // <1=> 2x
// <2=> 4x // <2=> 4x
// <3=> 8x // <3=> 8x
// <4=> 16x // <4=> 16x
// <5=> 32x // <5=> 32x
// <6=> 64x // <6=> 64x
// <7=> 128x // <7=> 128x
@ -5221,18 +5215,13 @@
#define NRF_SPI_DRV_MISO_PULLUP_CFG 1 #define NRF_SPI_DRV_MISO_PULLUP_CFG 1
#endif #endif
// needed these to build!
#define SPI0_ENABLED 1
#define SPI1_ENABLED 1
#define SPI2_ENABLED 1
// <e> SPI0_ENABLED - Enable SPI0 instance // <e> SPI0_ENABLED - Enable SPI0 instance
//========================================================== //==========================================================
#ifndef SPI0_ENABLED #ifndef SPI0_ENABLED
#define SPI0_ENABLED 0 #define SPI0_ENABLED 1
#endif #endif
// <q> SPI0_USE_EASY_DMA - Use EasyDMA // <q> SPI0_USE_EASY_DMA - Use EasyDMA
#ifndef SPI0_USE_EASY_DMA #ifndef SPI0_USE_EASY_DMA
#define SPI0_USE_EASY_DMA 1 #define SPI0_USE_EASY_DMA 1
@ -5243,10 +5232,10 @@
// <e> SPI1_ENABLED - Enable SPI1 instance // <e> SPI1_ENABLED - Enable SPI1 instance
//========================================================== //==========================================================
#ifndef SPI1_ENABLED #ifndef SPI1_ENABLED
#define SPI1_ENABLED 0 #define SPI1_ENABLED 1
#endif #endif
// <q> SPI1_USE_EASY_DMA - Use EasyDMA // <q> SPI1_USE_EASY_DMA - Use EasyDMA
#ifndef SPI1_USE_EASY_DMA #ifndef SPI1_USE_EASY_DMA
#define SPI1_USE_EASY_DMA 1 #define SPI1_USE_EASY_DMA 1
@ -5257,10 +5246,10 @@
// <e> SPI2_ENABLED - Enable SPI2 instance // <e> SPI2_ENABLED - Enable SPI2 instance
//========================================================== //==========================================================
#ifndef SPI2_ENABLED #ifndef SPI2_ENABLED
#define SPI2_ENABLED 0 #define SPI2_ENABLED 1
#endif #endif
// <q> SPI2_USE_EASY_DMA - Use EasyDMA // <q> SPI2_USE_EASY_DMA - Use EasyDMA
#ifndef SPI2_USE_EASY_DMA #ifndef SPI2_USE_EASY_DMA
#define SPI2_USE_EASY_DMA 1 #define SPI2_USE_EASY_DMA 1
@ -5605,12 +5594,10 @@
#define UART_LEGACY_SUPPORT 1 #define UART_LEGACY_SUPPORT 1
#endif #endif
// needed for Mbed build
#define UART0_ENABLED 1
// <e> UART0_ENABLED - Enable UART0 instance // <e> UART0_ENABLED - Enable UART0 instance
//========================================================== //==========================================================
#ifndef UART0_ENABLED #ifndef UART0_ENABLED
#define UART0_ENABLED 0 #define UART0_ENABLED 1
#endif #endif
// <q> UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA // <q> UART0_CONFIG_USE_EASY_DMA - Default setting for using EasyDMA
@ -6127,7 +6114,7 @@
// <e> FDS_ENABLED - fds - Flash data storage module // <e> FDS_ENABLED - fds - Flash data storage module
//========================================================== //==========================================================
#ifndef FDS_ENABLED #ifndef FDS_ENABLED
#define FDS_ENABLED 0 #define FDS_ENABLED 1
#endif #endif
// <h> Pages - Virtual page settings // <h> Pages - Virtual page settings
@ -6171,7 +6158,7 @@
// <2=> NRF_FSTORAGE_SD // <2=> NRF_FSTORAGE_SD
#ifndef FDS_BACKEND #ifndef FDS_BACKEND
#define FDS_BACKEND 2 #define FDS_BACKEND 1
#endif #endif
// </h> // </h>
@ -6663,7 +6650,7 @@
// <e> NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library // <e> NRF_FSTORAGE_ENABLED - nrf_fstorage - Flash abstraction library
//========================================================== //==========================================================
#ifndef NRF_FSTORAGE_ENABLED #ifndef NRF_FSTORAGE_ENABLED
#define NRF_FSTORAGE_ENABLED 0 #define NRF_FSTORAGE_ENABLED 1
#endif #endif
// <h> nrf_fstorage - Common settings // <h> nrf_fstorage - Common settings

View File

@ -39,6 +39,7 @@
#if DEVICE_PWMOUT #if DEVICE_PWMOUT
#include "hal/pwmout_api.h" #include "hal/pwmout_api.h"
#include "PeripheralPins.h"
#include "pinmap_ex.h" #include "pinmap_ex.h"
#include "nrfx_pwm.h" #include "nrfx_pwm.h"
@ -61,17 +62,17 @@
/* Allocate PWM instances. */ /* Allocate PWM instances. */
static nrfx_pwm_t nordic_nrf5_pwm_instance[] = { static nrfx_pwm_t nordic_nrf5_pwm_instance[] = {
#if PWM0_ENABLED #if NRFX_PWM0_ENABLED
NRF_DRV_PWM_INSTANCE(0), NRFX_PWM_INSTANCE(0),
#endif #endif
#if PWM1_ENABLED #if NRFX_PWM1_ENABLED
NRF_DRV_PWM_INSTANCE(1), NRFX_PWM_INSTANCE(1),
#endif #endif
#if PWM2_ENABLED #if NRFX_PWM2_ENABLED
NRF_DRV_PWM_INSTANCE(2), NRFX_PWM_INSTANCE(2),
#endif #endif
#if PWM3_ENABLED #if NRFX_PWM3_ENABLED
NRF_DRV_PWM_INSTANCE(3), NRFX_PWM_INSTANCE(3),
#endif #endif
}; };
@ -100,8 +101,8 @@ static void nordic_pwm_init(pwmout_t *obj)
.step_mode = NRF_PWM_STEP_AUTO, .step_mode = NRF_PWM_STEP_AUTO,
}; };
/* Make sure PWM instance is not running before making changes. */ // RF - test slowest prescalar setting (125kHz)
nrfx_pwm_uninit(&nordic_nrf5_pwm_instance[obj->instance]); config.base_clock = NRF_PWM_CLK_125kHz;
/* Initialize instance with new configuration. */ /* Initialize instance with new configuration. */
ret_code_t result = nrfx_pwm_init(&nordic_nrf5_pwm_instance[obj->instance], ret_code_t result = nrfx_pwm_init(&nordic_nrf5_pwm_instance[obj->instance],
@ -116,8 +117,8 @@ static void nordic_pwm_restart(pwmout_t *obj)
{ {
MBED_ASSERT(obj); MBED_ASSERT(obj);
/* Uninitialize PWM instace */ /* Uninitialize PWM instance */
nrf_drv_pwm_uninit(&nordic_nrf5_pwm_instance[obj->instance]); nrfx_pwm_uninit(&nordic_nrf5_pwm_instance[obj->instance]);
/* (Re)initialize PWM instance. */ /* (Re)initialize PWM instance. */
nordic_pwm_init(obj); nordic_pwm_init(obj);
@ -145,7 +146,7 @@ void pwmout_init(pwmout_t *obj, PinName pin)
/* Get hardware instance from pinmap. */ /* Get hardware instance from pinmap. */
int instance = pin_instance_pwm(pin); int instance = pin_instance_pwm(pin);
MBED_ASSERT(instance < (int)(sizeof(nordic_nrf5_pwm_instance) / sizeof(nrfx_pwm_t))); MBED_ASSERT(instance < (int) (sizeof(nordic_nrf5_pwm_instance) / sizeof(nrfx_pwm_t)));
/* Populate PWM object with default values. */ /* Populate PWM object with default values. */
obj->instance = instance; obj->instance = instance;
@ -356,3 +357,4 @@ const PinMap *pwmout_pinmap()
} }
#endif // DEVICE_PWMOUT #endif // DEVICE_PWMOUT