This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is there a NRF_GPIO_Type for P1 gpio?

Hi.

HW:custom nRF52840 board

SW:nRF5_SDK_15.2.0_9412b96

Sample code:\nRF5_SDK_15.2.0_9412b96\examples\dfu\open_bootloader\pca10056_usb\ses

I encounter problem with the sample code, I was trying to use the led_softblink function on the pin P0.6, P0.8, P01.9 led and was surprised to notice  there are no NRF_GPIO_Type for P1 gpio. Please advice me how to control this 3 pin at once with the led_softblink function.

  • Hi,

    The same NRF_GPIO_Type structure is used for both GPIO Port 0 and Port 1. Look for these lines in your nrf52840.h MDK header file.

    Best regards,
    Jørgen

  • Noted with thanks. I tested with red, green and blue. it only works for red color, and how can I integrate 3 led in a single softblink?

    I attached my code for your reference.

    main.c

    /**
     * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA
     *
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without modification,
     * are permitted provided that the following conditions are met:
     *
     * 1. Redistributions of source code must retain the above copyright notice, this
     *    list of conditions and the following disclaimer.
     *
     * 2. Redistributions in binary form, except as embedded into a Nordic
     *    Semiconductor ASA integrated circuit in a product or a software update for
     *    such product, must reproduce the above copyright notice, this list of
     *    conditions and the following disclaimer in the documentation and/or other
     *    materials provided with the distribution.
     *
     * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
     *    contributors may be used to endorse or promote products derived from this
     *    software without specific prior written permission.
     *
     * 4. This software, with or without modification, must only be used with a
     *    Nordic Semiconductor ASA integrated circuit.
     *
     * 5. Any software provided in binary form under this license must not be reverse
     *    engineered, decompiled, modified and/or disassembled.
     *
     * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    /** @file
     *
     * @defgroup bootloader_secure_ble main.c
     * @{
     * @ingroup dfu_bootloader_api
     * @brief Bootloader project main file for secure DFU.
     *
     */
    
    #include <stdint.h>
    #include "boards.h"
    #include "nrf_mbr.h"
    #include "nrf_bootloader.h"
    #include "nrf_bootloader_app_start.h"
    #include "nrf_bootloader_dfu_timers.h"
    #include "nrf_dfu.h"
    #include "nrf_log.h"
    #include "nrf_log_ctrl.h"
    #include "nrf_log_default_backends.h"
    #include "app_error.h"
    #include "app_error_weak.h"
    #include "nrf_bootloader_info.h"
    #include "nrf_delay.h"
    #include "led_softblink.h"
    #include "app_timer.h"
    #include "nrf_delay.h"
    #include "nrf_clock.h"
    
    #define LED_RED         NRF_GPIO_PIN_MAP(0,6)
    #define LED_BLU         NRF_GPIO_PIN_MAP(0,8)
    #define LED_GRN         NRF_GPIO_PIN_MAP(1,9)
    
    /* Timer used to blink LED on DFU progress. */
    APP_TIMER_DEF(m_dfu_progress_led_timer);
    
    static void port_init(void)
    {
      nrf_gpio_cfg_output(LED_RED);
      nrf_gpio_cfg_output(LED_BLU);
      nrf_gpio_pin_set(LED_RED);
      nrf_gpio_pin_set(LED_BLU);
      nrf_gpio_cfg_output(LED_GRN);
      nrf_gpio_pin_set(LED_GRN);
    }
    
    static void on_error(void)
    {
        NRF_LOG_FINAL_FLUSH();
    
    #if NRF_MODULE_ENABLED(NRF_LOG_BACKEND_RTT)
        // To allow the buffer to be flushed by the host.
        nrf_delay_ms(100);
    #endif
    #ifdef NRF_DFU_DEBUG_VERSION
        NRF_BREAKPOINT_COND;
    #endif
        NVIC_SystemReset();
    }
    
    
    void app_error_handler(uint32_t error_code, uint32_t line_num, const uint8_t * p_file_name)
    {
        NRF_LOG_ERROR("%s:%d", p_file_name, line_num);
        on_error();
    }
    
    
    void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
    {
        NRF_LOG_ERROR("Received a fault! id: 0x%08x, pc: 0x%08x, info: 0x%08x", id, pc, info);
        on_error();
    }
    
    
    void app_error_handler_bare(uint32_t error_code)
    {
        NRF_LOG_ERROR("Received an error: 0x%08x!", error_code);
        on_error();
    }
    
    static void dfu_progress_led_timeout_handler(void * p_context)
    {
        app_timer_id_t timer = (app_timer_id_t)p_context;
    
        uint32_t err_code = app_timer_start(timer,
                                            APP_TIMER_TICKS(DFU_LED_CONFIG_PROGRESS_BLINK_MS),
                                            p_context);
        APP_ERROR_CHECK(err_code);
    
    //    bsp_board_led_invert(BSP_BOARD_LED_1);
    }
    
    /**
     * @brief Function notifies certain events in DFU process.
     */
    static void dfu_observer(nrf_dfu_evt_type_t evt_type)
    {
        static bool timer_created = false;
        uint32_t err_code;
    
        if (!timer_created)
        {
            err_code = app_timer_create(&m_dfu_progress_led_timer,
                                        APP_TIMER_MODE_SINGLE_SHOT,
                                        dfu_progress_led_timeout_handler);
            APP_ERROR_CHECK(err_code);
            timer_created = true;
        }
    
        switch (evt_type)
        {
            case NRF_DFU_EVT_DFU_FAILED:
            case NRF_DFU_EVT_DFU_ABORTED:
                err_code = led_softblink_stop();
                APP_ERROR_CHECK(err_code);
    
                err_code = app_timer_stop(m_dfu_progress_led_timer);
                APP_ERROR_CHECK(err_code);
    
               err_code = led_softblink_start(RED_LED_0_MASK);
                APP_ERROR_CHECK(err_code);
               err_code = led_softblink_start(GRN_LED_1_MASK);
                APP_ERROR_CHECK(err_code);
               err_code = led_softblink_start(BLU_LED_2_MASK);
                APP_ERROR_CHECK(err_code);
                break;
            case NRF_DFU_EVT_DFU_INITIALIZED:
            {
                port_init();
                if (!nrf_clock_lf_is_running())
                {
                    nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTART);
                }
                err_code = app_timer_init();
                APP_ERROR_CHECK(err_code);
    
                //init red led
                led_sb_init_params_t led_sb_init_param_red = LED_SB_INIT_DEFAULT_PARAMS(RED_LED_0_MASK);
                uint32_t redticks = APP_TIMER_TICKS(DFU_LED_CONFIG_TRANSPORT_INACTIVE_BREATH_MS);
                led_sb_init_param_red.p_leds_port    = RED_LED_0_PORT;
                led_sb_init_param_red.on_time_ticks  = redticks;
                led_sb_init_param_red.off_time_ticks = redticks;
                led_sb_init_param_red.duty_cycle_max = 255;
    
                //init green led
                led_sb_init_params_t led_sb_init_param_grn = LED_SB_INIT_DEFAULT_PARAMS(GRN_LED_1_MASK);
                uint32_t grnticks = APP_TIMER_TICKS(DFU_LED_CONFIG_TRANSPORT_INACTIVE_BREATH_MS);
                led_sb_init_param_grn.p_leds_port    = GRN_LED_1_PORT;
                led_sb_init_param_grn.on_time_ticks  = grnticks;
                led_sb_init_param_grn.off_time_ticks = grnticks;
                led_sb_init_param_grn.duty_cycle_max = 45;
    
                //init blue led
                led_sb_init_params_t led_sb_init_param_blu = LED_SB_INIT_DEFAULT_PARAMS(BLU_LED_2_MASK);
                uint32_t bluticks = APP_TIMER_TICKS(DFU_LED_CONFIG_TRANSPORT_INACTIVE_BREATH_MS);
                led_sb_init_param_blu.p_leds_port    = BLU_LED_2_PORT;
                led_sb_init_param_blu.on_time_ticks  = bluticks;
                led_sb_init_param_blu.off_time_ticks = bluticks;
                led_sb_init_param_blu.duty_cycle_max = 20;
    
                err_code = led_softblink_init(&led_sb_init_param_red);
                APP_ERROR_CHECK(err_code);
    
                err_code = led_softblink_init(&led_sb_init_param_grn);
                APP_ERROR_CHECK(err_code);
    
                err_code = led_softblink_init(&led_sb_init_param_blu);
                APP_ERROR_CHECK(err_code);
    
    
                err_code = led_softblink_start(RED_LED_0_MASK);
                APP_ERROR_CHECK(err_code);
                err_code = led_softblink_start(GRN_LED_1_MASK);
                APP_ERROR_CHECK(err_code);
                err_code = led_softblink_start(BLU_LED_2_MASK);
                APP_ERROR_CHECK(err_code);
    
                break;
            }
            case NRF_DFU_EVT_TRANSPORT_ACTIVATED:
            {
                uint32_t ticks = APP_TIMER_TICKS(DFU_LED_CONFIG_TRANSPORT_ACTIVE_BREATH_MS);
                led_softblink_off_time_set(ticks);
                led_softblink_on_time_set(ticks);
                break;
            }
            case NRF_DFU_EVT_TRANSPORT_DEACTIVATED:
            {
                uint32_t ticks =  APP_TIMER_TICKS(DFU_LED_CONFIG_PROGRESS_BLINK_MS);
                err_code = led_softblink_stop();
                APP_ERROR_CHECK(err_code);
    
                err_code = app_timer_start(m_dfu_progress_led_timer, ticks, m_dfu_progress_led_timer);
                APP_ERROR_CHECK(err_code);
    
                break;
            }
            case NRF_DFU_EVT_DFU_STARTED:
                break;
            default:
                break;
        }
    }
    
    
    /**@brief Function for application main entry. */
    int main(void)
    {
        uint32_t ret_val;
    
        // Protect MBR and bootloader code from being overwritten.
        ret_val = nrf_bootloader_flash_protect(0, MBR_SIZE, false);
        APP_ERROR_CHECK(ret_val);
        ret_val = nrf_bootloader_flash_protect(BOOTLOADER_START_ADDR, BOOTLOADER_SIZE, false);
        APP_ERROR_CHECK(ret_val);
    
        (void) NRF_LOG_INIT(nrf_bootloader_dfu_timer_counter_get);
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    
        NRF_LOG_INFO("Inside main");
    
        ret_val = nrf_bootloader_init(dfu_observer);
        APP_ERROR_CHECK(ret_val);
    
        // Either there was no DFU functionality enabled in this project or the DFU module detected
        // no ongoing DFU operation and found a valid main application.
        // Boot the main application.
        nrf_bootloader_app_start();
    
        // Should never be reached.
        NRF_LOG_INFO("After main");
    }
    
    /**
     * @}
     */
    

    pca10056.h

    /**
     * Copyright (c) 2014 - 2018, Nordic Semiconductor ASA
     *
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without modification,
     * are permitted provided that the following conditions are met:
     *
     * 1. Redistributions of source code must retain the above copyright notice, this
     *    list of conditions and the following disclaimer.
     *
     * 2. Redistributions in binary form, except as embedded into a Nordic
     *    Semiconductor ASA integrated circuit in a product or a software update for
     *    such product, must reproduce the above copyright notice, this list of
     *    conditions and the following disclaimer in the documentation and/or other
     *    materials provided with the distribution.
     *
     * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
     *    contributors may be used to endorse or promote products derived from this
     *    software without specific prior written permission.
     *
     * 4. This software, with or without modification, must only be used with a
     *    Nordic Semiconductor ASA integrated circuit.
     *
     * 5. Any software provided in binary form under this license must not be reverse
     *    engineered, decompiled, modified and/or disassembled.
     *
     * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
     * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
     * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     */
    #ifndef BOARDS_H
    #define BOARDS_H
    
    #include "nrf_gpio.h"
    #include "nordic_common.h"
    
    #if defined(BOARD_NRF6310)
      #include "nrf6310.h"
    #elif defined(BOARD_PCA10000)
      #include "pca10000.h"
    #elif defined(BOARD_PCA10001)
      #include "pca10001.h"
    #elif defined(BOARD_PCA10002)
      #include "pca10000.h"
    #elif defined(BOARD_PCA10003)
      #include "pca10003.h"
    #elif defined(BOARD_PCA20006)
      #include "pca20006.h"
    #elif defined(BOARD_PCA10028)
      #include "pca10028.h"
    #elif defined(BOARD_PCA10031)
      #include "pca10031.h"
    #elif defined(BOARD_PCA10036)
      #include "pca10036.h"
    #elif defined(BOARD_PCA10040)
      #include "pca10040.h"
    #elif defined(BOARD_PCA10056)
      #include "pca10056.h"
    #elif defined(BOARD_PCA20020)
      #include "pca20020.h"
    #elif defined(BOARD_PCA10059)
      #include "pca10059.h"
    #elif defined(BOARD_WT51822)
      #include "wt51822.h"
    #elif defined(BOARD_N5DK1)
      #include "n5_starterkit.h"
    #elif defined (BOARD_D52DK1)
      #include "d52_starterkit.h"
    #elif defined (BOARD_ARDUINO_PRIMO)
      #include "arduino_primo.h"
    #elif defined (CUSTOM_BOARD_INC)
      #include STRINGIFY(CUSTOM_BOARD_INC.h)
    #elif defined(BOARD_CUSTOM)
      #include "custom_board.h"
    #else
    #error "Board is not defined"
    
    #endif
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    /**@defgroup BSP_BOARD_INIT_FLAGS Board initialization flags.
     * @{ */
    #define BSP_INIT_NONE    0        /**< No initialization of LEDs or buttons (@ref bsp_board_init).*/
    #define BSP_INIT_LEDS    (1 << 0) /**< Enable LEDs during initialization (@ref bsp_board_init).*/
    #define BSP_INIT_BUTTONS (1 << 1) /**< Enable buttons during initialization (@ref bsp_board_init).*/
    /**@} */
    
    /**
     * Function for returning the state of an LED.
     *
     * @param led_idx LED index (starting from 0), as defined in the board-specific header.
     *
     * @return True if the LED is turned on.
     */
    bool bsp_board_led_state_get(uint32_t led_idx);
    
    /**
     * Function for turning on an LED.
     *
     * @param led_idx LED index (starting from 0), as defined in the board-specific header.
     */
    void bsp_board_led_on(uint32_t led_idx);
    
    /**
     * Function for turning off an LED.
     *
     * @param led_idx LED index (starting from 0), as defined in the board-specific header.
     */
    void bsp_board_led_off(uint32_t led_idx);
    
    /**
     * Function for inverting the state of an LED.
     *
     * @param led_idx LED index (starting from 0), as defined in the board-specific header.
     */
    void bsp_board_led_invert(uint32_t led_idx);
    /**
     * Function for turning off all LEDs.
     */
    void bsp_board_leds_off(void);
    
    /**
     * Function for turning on all LEDs.
     */
    void bsp_board_leds_on(void);
    
    /**
     * Function for initializing the BSP handling for the board.
     *
     * @note This also initializes the USB DFU trigger library if @ref BOARDS_WITH_USB_DFU_TRIGGER is 1.
     *
     * @param[in]  init_flags  Flags specifying what to initialize (LEDs/buttons).
     *                         See @ref BSP_BOARD_INIT_FLAGS.
     */
    void bsp_board_init(uint32_t init_flags);
    
    /**
     * Function for converting pin number to LED index.
     *
     * @param pin_number Pin number.
     *
     * @return LED index of the given pin or 0xFFFFFFFF if invalid pin provided.
     */
    uint32_t bsp_board_pin_to_led_idx(uint32_t pin_number);
    
    /**
     * Function for converting LED index to pin number.
     *
     * @param led_idx LED index.
     *
     * @return Pin number.
     */
    uint32_t bsp_board_led_idx_to_pin(uint32_t led_idx);
    
    /**
     * Function for returning the state of a button.
     *
     * @param button_idx Button index (starting from 0), as defined in the board-specific header.
     *
     * @return True if the button is pressed.
     */
    bool bsp_board_button_state_get(uint32_t button_idx);
    
    /**
     * Function for converting pin number to button index.
     *
     * @param pin_number Pin number.
     *
     * @return Button index of the given pin or 0xFFFFFFFF if invalid pin provided.
     */
    uint32_t bsp_board_pin_to_button_idx(uint32_t pin_number);
    
    
    /**
     * Function for converting button index to pin number.
     *
     * @param button_idx Button index.
     *
     * @return Pin number.
     */
    uint32_t bsp_board_button_idx_to_pin(uint32_t button_idx);
    
    #define BSP_BOARD_LED_0 0
    #define BSP_BOARD_LED_1 1
    #define BSP_BOARD_LED_2 2
    #define BSP_BOARD_LED_3 3
    #define BSP_BOARD_LED_4 4
    #define BSP_BOARD_LED_5 5
    #define BSP_BOARD_LED_6 6
    #define BSP_BOARD_LED_7 7
    
    #define PIN_MASK(_pin)  /*lint -save -e504 */                     \
                            (1u << (uint32_t)((_pin) & (~P0_PIN_NUM))) \
                            /*lint -restore    */
    
    #define PIN_PORT(_pin) (((_pin) >= P0_PIN_NUM) ? NRF_P1 : NRF_GPIO)
    
    #define LED_RED         NRF_GPIO_PIN_MAP(0,6)
    #define LED_BLU         NRF_GPIO_PIN_MAP(0,8)
    #define LED_GRN         NRF_GPIO_PIN_MAP(1,9)
    
    #define RED_LED_0_MASK PIN_MASK(LED_RED)
    #define RED_LED_0_PORT PIN_PORT(LED_RED)
    #define GRN_LED_1_MASK PIN_MASK(LED_GRN)
    #define GRN_LED_1_PORT PIN_PORT(LED_GRN)
    #define BLU_LED_2_MASK PIN_MASK(LED_BLU)
    #define BLU_LED_2_PORT PIN_PORT(LED_BLU)
    
    #ifdef BSP_LED_0
    #define BSP_LED_0_MASK PIN_MASK(BSP_LED_0)
    #define BSP_LED_0_PORT PIN_PORT(BSP_LED_0)
    #else
    #define BSP_LED_0_MASK 0
    #define BSP_LED_0_PORT 0
    #endif
    #ifdef BSP_LED_1
    #define BSP_LED_1_MASK PIN_MASK(BSP_LED_1)
    #define BSP_LED_1_PORT PIN_PORT(BSP_LED_1)
    #else
    #define BSP_LED_1_MASK 0
    #define BSP_LED_1_PORT 0
    #endif
    #ifdef BSP_LED_2
    #define BSP_LED_2_MASK PIN_MASK(BSP_LED_2)
    #define BSP_LED_2_PORT PIN_PORT(BSP_LED_2)
    #else
    #define BSP_LED_2_MASK 0
    #define BSP_LED_2_PORT 0
    #endif
    #ifdef BSP_LED_3
    #define BSP_LED_3_MASK PIN_MASK(BSP_LED_3)
    #define BSP_LED_3_PORT PIN_PORT(BSP_LED_3)
    #else
    #define BSP_LED_3_MASK 0
    #define BSP_LED_3_PORT 0
    #endif
    #ifdef BSP_LED_4
    #define BSP_LED_4_MASK PIN_MASK(BSP_LED_4)
    #define BSP_LED_4_PORT PIN_PORT(BSP_LED_4)
    #else
    #define BSP_LED_4_MASK 0
    #define BSP_LED_4_PORT 0
    #endif
    #ifdef BSP_LED_5
    #define BSP_LED_5_MASK PIN_MASK(BSP_LED_5)
    #define BSP_LED_5_PORT PIN_PORT(BSP_LED_5)
    #else
    #define BSP_LED_5_MASK 0
    #define BSP_LED_5_PORT 0
    #endif
    #ifdef BSP_LED_6
    #define BSP_LED_6_MASK PIN_MASK(BSP_LED_6)
    #define BSP_LED_6_PORT PIN_PORT(BSP_LED_6)
    #else
    #define BSP_LED_6_MASK 0
    #define BSP_LED_6_PORT 0
    #endif
    #ifdef BSP_LED_7
    #define BSP_LED_7_MASK PIN_MASK(BSP_LED_7)
    #define BSP_LED_7_PORT PIN_PORT(BSP_LED_7)
    #else
    #define BSP_LED_7_MASK 0
    #define BSP_LED_7_PORT 0
    #endif
    
    
    #define LEDS_MASK      (BSP_LED_0_MASK | BSP_LED_1_MASK | \
                            BSP_LED_2_MASK | BSP_LED_3_MASK | \
                            BSP_LED_4_MASK | BSP_LED_5_MASK | \
                            BSP_LED_6_MASK | BSP_LED_7_MASK)
    
    #define MWDS_LEDS_MASK  (RED_LED_0_MASK | \
                             GRN_LED_1_MASK )
    
    #define MWDS_LEDS_PORT (RED_LED_0_PORT | \
                            GRN_LED_1_PORT | \
                             BLU_LED_2_PORT)
    
    #define BSP_BOARD_BUTTON_0 0
    #define BSP_BOARD_BUTTON_1 1
    #define BSP_BOARD_BUTTON_2 2
    #define BSP_BOARD_BUTTON_3 3
    #define BSP_BOARD_BUTTON_4 4
    #define BSP_BOARD_BUTTON_5 5
    #define BSP_BOARD_BUTTON_6 6
    #define BSP_BOARD_BUTTON_7 7
    
    
    #ifdef BSP_BUTTON_0
    #define BSP_BUTTON_0_MASK (1<<BSP_BUTTON_0)
    #else
    #define BSP_BUTTON_0_MASK 0
    #endif
    #ifdef BSP_BUTTON_1
    #define BSP_BUTTON_1_MASK (1<<BSP_BUTTON_1)
    #else
    #define BSP_BUTTON_1_MASK 0
    #endif
    #ifdef BSP_BUTTON_2
    #define BSP_BUTTON_2_MASK (1<<BSP_BUTTON_2)
    #else
    #define BSP_BUTTON_2_MASK 0
    #endif
    #ifdef BSP_BUTTON_3
    #define BSP_BUTTON_3_MASK (1<<BSP_BUTTON_3)
    #else
    #define BSP_BUTTON_3_MASK 0
    #endif
    #ifdef BSP_BUTTON_4
    #define BSP_BUTTON_4_MASK (1<<BSP_BUTTON_4)
    #else
    #define BSP_BUTTON_4_MASK 0
    #endif
    #ifdef BSP_BUTTON_5
    #define BSP_BUTTON_5_MASK (1<<BSP_BUTTON_5)
    #else
    #define BSP_BUTTON_5_MASK 0
    #endif
    #ifdef BSP_BUTTON_6
    #define BSP_BUTTON_6_MASK (1<<BSP_BUTTON_6)
    #else
    #define BSP_BUTTON_6_MASK 0
    #endif
    #ifdef BSP_BUTTON_7
    #define BSP_BUTTON_7_MASK (1<<BSP_BUTTON_7)
    #else
    #define BSP_BUTTON_7_MASK 0
    #endif
    
    #define BUTTONS_MASK   (BSP_BUTTON_0_MASK | BSP_BUTTON_1_MASK | \
                            BSP_BUTTON_2_MASK | BSP_BUTTON_3_MASK | \
                            BSP_BUTTON_4_MASK | BSP_BUTTON_5_MASK | \
                            BSP_BUTTON_6_MASK | BSP_BUTTON_7_MASK)
    
    
    #define LEDS_OFF(leds_mask) do {  ASSERT(sizeof(leds_mask) == 4);                     \
                            NRF_GPIO->OUTSET = (leds_mask) & (LEDS_MASK & LEDS_INV_MASK); \
                            NRF_GPIO->OUTCLR = (leds_mask) & (LEDS_MASK & ~LEDS_INV_MASK); } while (0)
    
    #define LEDS_ON(leds_mask) do {  ASSERT(sizeof(leds_mask) == 4);                     \
                           NRF_GPIO->OUTCLR = (leds_mask) & (LEDS_MASK & LEDS_INV_MASK); \
                           NRF_GPIO->OUTSET = (leds_mask) & (LEDS_MASK & ~LEDS_INV_MASK); } while (0)
    
    #define LED_IS_ON(leds_mask) ((leds_mask) & (NRF_GPIO->OUT ^ LEDS_INV_MASK) )
    
    #define LEDS_INVERT(leds_mask) do { uint32_t gpio_state = NRF_GPIO->OUT;      \
                                  ASSERT(sizeof(leds_mask) == 4);                 \
                                  NRF_GPIO->OUTSET = ((leds_mask) & ~gpio_state); \
                                  NRF_GPIO->OUTCLR = ((leds_mask) & gpio_state); } while (0)
    
    #define LEDS_CONFIGURE(leds_mask) do { uint32_t pin;                  \
                                      ASSERT(sizeof(leds_mask) == 4);     \
                                      for (pin = 0; pin < 32; pin++)      \
                                          if ( (leds_mask) & (1 << pin) ) \
                                              nrf_gpio_cfg_output(pin); } while (0)
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif
    

  • There seems to be an issue with the low_power_pwm library that is used by led_softblink library that prevents you from using pins on both P0 and P1 simultaneously. I compared the library in SDK 15.2.0 with SDK 15.3.0, and there is no changes.

  • Thanks for the info. But our project urgently need this feature, is there any alternative solution available? If I want to both P0 and P1 simultaneously

  • You don't have to use the led_softblink or low_power_pwm libraries. You should be able to control LEDs using PWM library or PWM driver.

Related