From 100603a60b36853cad3d68666a420db19fb11289 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Wed, 5 Sep 2018 17:38:59 -0400 Subject: [PATCH] neopixel_write merge; alphabetize stuff in Makefile --- ports/nrf/Makefile | 47 +++++++++---------- .../nrf/common-hal/neopixel_write/__init__.c | 12 ++--- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 75fc1cabdb..d3dc23262d 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -95,29 +95,29 @@ SRC_NRFX = $(addprefix nrfx/,\ ) SRC_C += \ - mphalport.c \ - fatfs_port.c \ - tick.c \ background.c \ + fatfs_port.c \ internal_flash.c \ - drivers/bluetooth/ble_drv.c \ - drivers/bluetooth/ble_uart.c \ + mphalport.c \ + tick.c \ boards/$(BOARD)/board.c \ boards/$(BOARD)/pins.c \ - nrfx/mdk/system_$(MCU_SUB_VARIANT).c \ - nrfx/hal/nrf_nvmc.c \ device/$(MCU_VARIANT)/startup_$(MCU_SUB_VARIANT).c \ + drivers/bluetooth/ble_drv.c \ + drivers/bluetooth/ble_uart.c \ + lib/libc/string0.c \ + lib/mp-readline/readline.c \ lib/oofatfs/ff.c \ lib/oofatfs/option/ccsbcs.c \ lib/timeutils/timeutils.c \ lib/utils/buffer_helper.c \ lib/utils/context_manager_helpers.c \ - lib/utils/pyexec.c \ lib/utils/interrupt_char.c \ + lib/utils/pyexec.c \ lib/utils/stdout_helpers.c \ lib/utils/sys_stdio_mphal.c \ - lib/libc/string0.c \ - lib/mp-readline/readline.c \ + nrfx/hal/nrf_nvmc.c \ + nrfx/mdk/system_$(MCU_SUB_VARIANT).c \ peripherals/nrf/$(MCU_CHIP)/pins.c \ supervisor/shared/memory.c @@ -135,30 +135,29 @@ DRIVERS_SRC_C += $(addprefix modules/,\ ) SRC_COMMON_HAL += \ - board/__init__.c \ - digitalio/__init__.c \ - digitalio/DigitalInOut.c \ - microcontroller/__init__.c \ - microcontroller/Pin.c \ - microcontroller/Processor.c \ - neopixel_write/__init__.c \ - os/__init__.c \ - time/__init__.c \ - analogio/__init__.c \ analogio/AnalogIn.c \ analogio/AnalogOut.c \ - busio/__init__.c\ + analogio/__init__.c \ + board/__init__.c \ busio/I2C.c \ busio/SPI.c \ busio/UART.c \ + busio/__init__.c\ + digitalio/DigitalInOut.c \ + digitalio/__init__.c \ + microcontroller/Pin.c \ + microcontroller/Processor.c \ + microcontroller/__init__.c \ neopixel_write/__init__.c \ - pulseio/__init__.c \ + os/__init__.c \ + pulseio/PWMOut.c \ pulseio/PulseIn.c \ pulseio/PulseOut.c \ - pulseio/PWMOut.c \ + pulseio/__init__.c \ storage/__init__.c \ - supervisor/__init__.c \ supervisor/Runtime.c \ + supervisor/__init__.c \ + time/__init__.c \ ifneq ($(SD), ) SRC_COMMON_HAL += \ diff --git a/ports/nrf/common-hal/neopixel_write/__init__.c b/ports/nrf/common-hal/neopixel_write/__init__.c index c84bc4381a..ef5e8beb17 100644 --- a/ports/nrf/common-hal/neopixel_write/__init__.c +++ b/ports/nrf/common-hal/neopixel_write/__init__.c @@ -166,7 +166,7 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout // pwm->INTEN |= (PWM_INTEN_SEQEND0_Enabled<pin->port*32 + digitalinout->pin->pin, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL} ); + nrf_pwm_pins_set(pwm, (uint32_t[]) {digitalinout->pin->number, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL} ); // Enable the PWM nrf_pwm_enable(pwm); @@ -205,12 +205,10 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout // the LEDs and if you are not using the EasyDMA feature. __disable_irq(); -#ifdef NRF_P1 - NRF_GPIO_Type* port = ( digitalinout->pin->port ? NRF_P1 : NRF_P0 ); -#else - NRF_GPIO_Type* port = NRF_P0; -#endif - uint32_t pinMask = ( 1UL << digitalinout->pin->pin ); + uint32_t decoded_pin = digitalinout->pin->number; + NRF_GPIO_Type* port = nrf_gpio_pin_port_decode(&decoded_pin); + + uint32_t pinMask = ( 1UL << decoded_pin ); uint32_t CYCLES_X00 = CYCLES_800; uint32_t CYCLES_X00_T1H = CYCLES_800_T1H;