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

View File

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