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

NRF52840 Dongle Missing Green LED on LD2

Hello All,

I've recently run into an issue with the nRF52840 Dongle where the Green channel for LD2 is not lighting up, this is a problem that is persistent across all four nRF2840 Dongles in my possession.

Two of the dongles are dated 2018.42, and the other two are dated 2018.34.

I can see 4 traces leading into the LEDs so I am assuming all 3 channels are connected, perhaps it's a misconfiguration in the BSP?

LEDs are defined as follow in pca10059.h from nRF5 SDK 15.2.0.

// LED definitions for PCA10059
// Each LED color is considered a separate LED
#define LEDS_NUMBER    4

#define LED1_G         NRF_GPIO_PIN_MAP(0,6)
#define LED2_R         NRF_GPIO_PIN_MAP(0,8)
#define LED2_G         NRF_GPIO_PIN_MAP(1,9)
#define LED2_B         NRF_GPIO_PIN_MAP(0,12)

#define LED_1          LED1_G
#define LED_2          LED2_R
#define LED_3          LED2_G
#define LED_4          LED2_B

#define LED_START      LED_1
#define LED_STOP       LED_4

#define LEDS_ACTIVE_STATE 0

#define LEDS_LIST { LED_1, LED_2, LED_3, LED_4 }

#define LEDS_INV_MASK  LEDS_MASK

#define BSP_LED_0      LED_1
#define BSP_LED_1      LED_2
#define BSP_LED_2      LED_3
#define BSP_LED_3      LED_4

Any comments on the matter would be appreciated.

Thanks in advanced!

-jdts

Parents
  • Hi,

    I have booted up a nRF52840 Dongle dated 2018.34, and run the blinky LED example via nRF connect, and all all LEDs are working just fine. I suggest you try running this example to verify that your hardware is working.

    I also see that you have

     

    #define LED_START      LED_1
    #define LED_STOP       LED_4

    which does not exist in the original SDK header file.

    Could you please share your BSP-configurations and firmware so that I can look into it?

    Best regards,

    Simon

  • Hello Simonr,

    I am currently using the nRF Mesh SDK3.0.0 light_switch_server example and have (mostly) adapted it to the nrf52840 dongle, the LED_START and LED_STOP were added to suppress errors that were given by simple_hal.c in the hal_leds_init function found on line 167. It expects a start point and stop point in the for loop.

    Here's my firmware, other than adapting it to have 2 Generic OnOffs, it's mostly untouched.

    /* Copyright (c) 2010 - 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.
     */
    
    #include <stdint.h>
    #include <string.h>
    
    /* HAL */
    #include "boards.h"
    #include "simple_hal.h"
    #include "app_timer.h"
    
    /* Core */
    #include "nrf_mesh_config_core.h"
    #include "nrf_mesh_configure.h"
    #include "nrf_mesh.h"
    #include "mesh_stack.h"
    #include "device_state_manager.h"
    #include "access_config.h"
    #include "proxy.h"
    
    /* Provisioning and configuration */
    #include "mesh_provisionee.h"
    #include "mesh_app_utils.h"
    
    /* Models */
    #include "generic_onoff_server.h"
    
    /* Logging and RTT */
    #include "log.h"
    #include "rtt_input.h"
    
    /* Example specific includes */
    #include "app_config.h"
    #include "example_common.h"
    #include "nrf_mesh_config_examples.h"
    #include "light_switch_example_common.h"
    #include "app_onoff.h"
    #include "ble_softdevice_support.h"
    
    #define ONOFF_SERVER_0_LED          (BSP_LED_0)
    #define ONOFF_SERVER_1_LED          (BSP_LED_2)
    #define APP_ONOFF_ELEMENT_INDEX     (0)
    #define APP_ONOFF_ELEMENT_INDEX_1   (1)
    
    static bool m_device_provisioned;
    
    /*************************************************************************************************/
    static void app_onoff_server_set_cb(const app_onoff_server_t * p_server, bool onoff);
    static void app_onoff_server_get_cb(const app_onoff_server_t * p_server, bool * p_present_onoff);
    static void app_onoff_server_set_cb_1(const app_onoff_server_t * p_server, bool onoff);
    static void app_onoff_server_get_cb_1(const app_onoff_server_t * p_server, bool * p_present_onoff);
    /* Generic OnOff server structure definition and initialization */
    APP_ONOFF_SERVER_DEF(m_onoff_server_0,
                         APP_CONFIG_FORCE_SEGMENTATION,
                         APP_CONFIG_MIC_SIZE,
                         app_onoff_server_set_cb,
                         app_onoff_server_get_cb)
    
    APP_ONOFF_SERVER_DEF(m_onoff_server_1,
                         APP_CONFIG_FORCE_SEGMENTATION,
                         APP_CONFIG_MIC_SIZE,
                         app_onoff_server_set_cb_1,
                         app_onoff_server_get_cb_1)
    
    /* Callback for updating the hardware state */
    static void app_onoff_server_set_cb(const app_onoff_server_t * p_server, bool onoff)
    {
        /* Resolve the server instance here if required, this example uses only 1 instance. */
    
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Setting GPIO value: %d\n", onoff)
    
        hal_led_pin_set(ONOFF_SERVER_0_LED, onoff);
    }
    static void app_onoff_server_set_cb_1(const app_onoff_server_t * p_server, bool onoff)
    {
        /* Resolve the server instance here if required, this example uses only 1 instance. */
    
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Setting GPIO value: %d\n", onoff)
    
        hal_led_pin_set(ONOFF_SERVER_1_LED, onoff);
    }
    
    /* Callback for reading the hardware state */
    static void app_onoff_server_get_cb(const app_onoff_server_t * p_server, bool * p_present_onoff)
    {
        /* Resolve the server instance here if required, this example uses only 1 instance. */
    
        *p_present_onoff = hal_led_pin_get(ONOFF_SERVER_0_LED);
    }
    
    static void app_onoff_server_get_cb_1(const app_onoff_server_t * p_server, bool * p_present_onoff)
    {
        /* Resolve the server instance here if required, this example uses only 1 instance. */
    
        *p_present_onoff = hal_led_pin_get(ONOFF_SERVER_1_LED);
    }
    
    static void app_model_init(void)
    {
        /* Instantiate onoff server on element index APP_ONOFF_ELEMENT_INDEX */
        ERROR_CHECK(app_onoff_init(&m_onoff_server_0, APP_ONOFF_ELEMENT_INDEX));
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "App OnOff Model Handle: %d\n", m_onoff_server_0.server.model_handle);
        ERROR_CHECK(app_onoff_init(&m_onoff_server_1, APP_ONOFF_ELEMENT_INDEX_1));
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "App OnOff Model Handle: %d\n", m_onoff_server_0.server.model_handle);
    }
    
    /*************************************************************************************************/
    
    static void node_reset(void)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "----- Node reset  -----\n");
        hal_led_blink_ms(LEDS_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_RESET);
        /* This function may return if there are ongoing flash operations. */
        mesh_stack_device_reset();
    }
    
    static void config_server_evt_cb(const config_server_evt_t * p_evt)
    {
        if (p_evt->type == CONFIG_SERVER_EVT_NODE_RESET)
        {
            node_reset();
        }
    }
    
    static void button_event_handler(uint32_t button_number)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Button %u pressed\n", button_number);
        switch (button_number)
        {
            /* Pressing SW1 on the Development Kit will result in LED state to toggle and trigger
            the STATUS message to inform client about the state change. This is a demonstration of
            state change publication due to local event. */
            case 0:
            {
                __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "User action \n");
                hal_led_pin_set(ONOFF_SERVER_0_LED, !hal_led_pin_get(ONOFF_SERVER_0_LED));
                app_onoff_status_publish(&m_onoff_server_0);
                break;
            }
    
            /* Initiate node reset */
            /*
            case 3:
            {
                /* Clear all the states to reset the node. 8/
                if (mesh_stack_is_device_provisioned())
                {
    #if MESH_FEATURE_GATT_PROXY_ENABLED
                    (void) proxy_stop();
    #endif
                    mesh_stack_config_clear();
                    node_reset();
                }
                else
                {
                    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "The device is unprovisioned. Resetting has no effect.\n");
                }
                break;
            }*/
    
            default:
                break;
        }
    }
    
    static void app_rtt_input_handler(int key)
    {
        if (key >= '0' && key <= '4')
        {
            uint32_t button_number = key - '0';
            button_event_handler(button_number);
        }
    }
    
    static void device_identification_start_cb(uint8_t attention_duration_s)
    {
        hal_led_mask_set(LEDS_MASK, false);
        hal_led_blink_ms(BSP_LED_2_MASK  | BSP_LED_3_MASK, 
                         LED_BLINK_ATTENTION_INTERVAL_MS, 
                         LED_BLINK_ATTENTION_COUNT(attention_duration_s));
    }
    
    static void provisioning_aborted_cb(void)
    {
        hal_led_blink_stop();
    }
    
    static void provisioning_complete_cb(void)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Successfully provisioned\n");
    
    #if MESH_FEATURE_GATT_ENABLED
        /* Restores the application parameters after switching from the Provisioning
         * service to the Proxy  */
        gap_params_init();
        conn_params_init();
    #endif
    
        dsm_local_unicast_address_t node_address;
        dsm_local_unicast_addresses_get(&node_address);
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Node Address: 0x%04x \n", node_address.address_start);
    
        hal_led_blink_stop();
        hal_led_mask_set(LEDS_MASK, LED_MASK_STATE_OFF);
        hal_led_blink_ms(LEDS_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_PROV);
    }
    
    static void models_init_cb(void)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Initializing and adding models\n");
        app_model_init();
    }
    
    static void mesh_init(void)
    {
        uint8_t dev_uuid[NRF_MESH_UUID_SIZE];
        uint8_t node_uuid_prefix[NODE_UUID_PREFIX_LEN] = SERVER_NODE_UUID_PREFIX;
    
        ERROR_CHECK(mesh_app_uuid_gen(dev_uuid, node_uuid_prefix, NODE_UUID_PREFIX_LEN));
        mesh_stack_init_params_t init_params =
        {
            .core.irq_priority       = NRF_MESH_IRQ_PRIORITY_LOWEST,
            .core.lfclksrc           = DEV_BOARD_LF_CLK_CFG,
            .core.p_uuid             = dev_uuid,
            .models.models_init_cb   = models_init_cb,
            .models.config_server_cb = config_server_evt_cb
        };
        ERROR_CHECK(mesh_stack_init(&init_params, &m_device_provisioned));
    }
    
    static void initialize(void)
    {
        __LOG_INIT(LOG_SRC_APP | LOG_SRC_ACCESS | LOG_SRC_BEARER, LOG_LEVEL_INFO, LOG_CALLBACK_DEFAULT);
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "----- BLE Mesh Light Switch Server Demo -----\n");
    
        ERROR_CHECK(app_timer_init());
        hal_leds_init();
    
    #if BUTTON_BOARD
        ERROR_CHECK(hal_buttons_init(button_event_handler));
    #endif
    
        ble_stack_init();
    
    #if MESH_FEATURE_GATT_ENABLED
        gap_params_init();
        conn_params_init();
    #endif
    
        mesh_init();
    }
    
    static void start(void)
    {
        rtt_input_enable(app_rtt_input_handler, RTT_INPUT_POLL_PERIOD_MS);
    
        if (!m_device_provisioned)
        {
            static const uint8_t static_auth_data[NRF_MESH_KEY_SIZE] = STATIC_AUTH_DATA;
            mesh_provisionee_start_params_t prov_start_params =
            {
                .p_static_data    = static_auth_data,
                .prov_complete_cb = provisioning_complete_cb,
                .prov_device_identification_start_cb = device_identification_start_cb,
                .prov_device_identification_stop_cb = NULL,
                .prov_abort_cb = provisioning_aborted_cb,
                .p_device_uri = NULL
            };
            ERROR_CHECK(mesh_provisionee_prov_start(&prov_start_params));
        }
    
        const uint8_t *p_uuid = nrf_mesh_configure_device_uuid_get();
        UNUSED_VARIABLE(p_uuid);
        __LOG_XB(LOG_SRC_APP, LOG_LEVEL_INFO, "Device UUID ", p_uuid, NRF_MESH_UUID_SIZE);
    
        ERROR_CHECK(mesh_stack_start());
    
        hal_led_mask_set(LEDS_MASK, LED_MASK_STATE_OFF);
        hal_led_blink_ms(LEDS_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_START);
    }
    
    int main(void)
    {
        initialize();
        start();
    
        for (;;)
        {
            (void)sd_app_evt_wait();
        }
    }
    

    In the initial startup of the PCA10059 leds and PCA10056, all 4 LEDs work fine on PCA10056, but only 3 of the 4 light up on the PCA10059 (Green missing).

    I ran the blinky example and green led turned on just fine, so I am suspecting a bug in the SDK.

    I should also mention that the button doesn't work either; oddly enough.

    Preprocessor is set to include BOARD_PCA10059

    c_preprocessor_definitions="NO_VTOR_CONFIG;USE_APP_CONFIG;CONFIG_APP_IN_CORE;NRF52_SERIES;NRF52840;NRF52840_XXAA;S140;SOFTDEVICE_PRESENT;NRF_SD_BLE_API_VERSION=6;BOARD_PCA10059;CONFIG_GPIO_AS_PINRESET;"

    board.h (unchanged)

    /**
     * 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)
    
    #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 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
    

    pca10059.h

    /**
     * Copyright (c) 2017 - 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 PCA10059_H
    #define PCA10059_H
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    #include "nrf_gpio.h"
    
    // LED definitions for PCA10059
    // Each LED color is considered a separate LED
    #define LEDS_NUMBER    4
    
    #define LED1_G         NRF_GPIO_PIN_MAP(0,6)
    #define LED2_R         NRF_GPIO_PIN_MAP(0,8)
    #define LED2_G         NRF_GPIO_PIN_MAP(1,9)
    #define LED2_B         NRF_GPIO_PIN_MAP(0,12)
    
    #define LED_1          LED1_G
    #define LED_2          LED2_R
    #define LED_3          LED2_G
    #define LED_4          LED2_B
    
    #define LED_START      LED_1
    #define LED_STOP       LED_4
    
    #define LEDS_ACTIVE_STATE 0
    
    #define LEDS_LIST { LED_1, LED_2, LED_3, LED_4 }
    
    #define LEDS_INV_MASK  LEDS_MASK
    
    #define BSP_LED_0      LED_1
    #define BSP_LED_1      LED_2
    #define BSP_LED_2      LED_3
    #define BSP_LED_3      LED_4
    
    // There is only one button for the application
    // as the second button is used for a RESET.
    #define BUTTONS_NUMBER 1
    
    #define BUTTON_1       NRF_GPIO_PIN_MAP(1,6)
    #define BUTTON_PULL    NRF_GPIO_PIN_PULLUP
    
    #define BUTTONS_ACTIVE_STATE 0
    
    #define BUTTONS_LIST { BUTTON_1 }
    
    #define BSP_BUTTON_0   BUTTON_1
    
    #define BSP_SELF_PINRESET_PIN NRF_GPIO_PIN_MAP(0,19)
    
    #define HWFC           true
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif // PCA10059_H
    

Reply
  • Hello Simonr,

    I am currently using the nRF Mesh SDK3.0.0 light_switch_server example and have (mostly) adapted it to the nrf52840 dongle, the LED_START and LED_STOP were added to suppress errors that were given by simple_hal.c in the hal_leds_init function found on line 167. It expects a start point and stop point in the for loop.

    Here's my firmware, other than adapting it to have 2 Generic OnOffs, it's mostly untouched.

    /* Copyright (c) 2010 - 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.
     */
    
    #include <stdint.h>
    #include <string.h>
    
    /* HAL */
    #include "boards.h"
    #include "simple_hal.h"
    #include "app_timer.h"
    
    /* Core */
    #include "nrf_mesh_config_core.h"
    #include "nrf_mesh_configure.h"
    #include "nrf_mesh.h"
    #include "mesh_stack.h"
    #include "device_state_manager.h"
    #include "access_config.h"
    #include "proxy.h"
    
    /* Provisioning and configuration */
    #include "mesh_provisionee.h"
    #include "mesh_app_utils.h"
    
    /* Models */
    #include "generic_onoff_server.h"
    
    /* Logging and RTT */
    #include "log.h"
    #include "rtt_input.h"
    
    /* Example specific includes */
    #include "app_config.h"
    #include "example_common.h"
    #include "nrf_mesh_config_examples.h"
    #include "light_switch_example_common.h"
    #include "app_onoff.h"
    #include "ble_softdevice_support.h"
    
    #define ONOFF_SERVER_0_LED          (BSP_LED_0)
    #define ONOFF_SERVER_1_LED          (BSP_LED_2)
    #define APP_ONOFF_ELEMENT_INDEX     (0)
    #define APP_ONOFF_ELEMENT_INDEX_1   (1)
    
    static bool m_device_provisioned;
    
    /*************************************************************************************************/
    static void app_onoff_server_set_cb(const app_onoff_server_t * p_server, bool onoff);
    static void app_onoff_server_get_cb(const app_onoff_server_t * p_server, bool * p_present_onoff);
    static void app_onoff_server_set_cb_1(const app_onoff_server_t * p_server, bool onoff);
    static void app_onoff_server_get_cb_1(const app_onoff_server_t * p_server, bool * p_present_onoff);
    /* Generic OnOff server structure definition and initialization */
    APP_ONOFF_SERVER_DEF(m_onoff_server_0,
                         APP_CONFIG_FORCE_SEGMENTATION,
                         APP_CONFIG_MIC_SIZE,
                         app_onoff_server_set_cb,
                         app_onoff_server_get_cb)
    
    APP_ONOFF_SERVER_DEF(m_onoff_server_1,
                         APP_CONFIG_FORCE_SEGMENTATION,
                         APP_CONFIG_MIC_SIZE,
                         app_onoff_server_set_cb_1,
                         app_onoff_server_get_cb_1)
    
    /* Callback for updating the hardware state */
    static void app_onoff_server_set_cb(const app_onoff_server_t * p_server, bool onoff)
    {
        /* Resolve the server instance here if required, this example uses only 1 instance. */
    
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Setting GPIO value: %d\n", onoff)
    
        hal_led_pin_set(ONOFF_SERVER_0_LED, onoff);
    }
    static void app_onoff_server_set_cb_1(const app_onoff_server_t * p_server, bool onoff)
    {
        /* Resolve the server instance here if required, this example uses only 1 instance. */
    
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Setting GPIO value: %d\n", onoff)
    
        hal_led_pin_set(ONOFF_SERVER_1_LED, onoff);
    }
    
    /* Callback for reading the hardware state */
    static void app_onoff_server_get_cb(const app_onoff_server_t * p_server, bool * p_present_onoff)
    {
        /* Resolve the server instance here if required, this example uses only 1 instance. */
    
        *p_present_onoff = hal_led_pin_get(ONOFF_SERVER_0_LED);
    }
    
    static void app_onoff_server_get_cb_1(const app_onoff_server_t * p_server, bool * p_present_onoff)
    {
        /* Resolve the server instance here if required, this example uses only 1 instance. */
    
        *p_present_onoff = hal_led_pin_get(ONOFF_SERVER_1_LED);
    }
    
    static void app_model_init(void)
    {
        /* Instantiate onoff server on element index APP_ONOFF_ELEMENT_INDEX */
        ERROR_CHECK(app_onoff_init(&m_onoff_server_0, APP_ONOFF_ELEMENT_INDEX));
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "App OnOff Model Handle: %d\n", m_onoff_server_0.server.model_handle);
        ERROR_CHECK(app_onoff_init(&m_onoff_server_1, APP_ONOFF_ELEMENT_INDEX_1));
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "App OnOff Model Handle: %d\n", m_onoff_server_0.server.model_handle);
    }
    
    /*************************************************************************************************/
    
    static void node_reset(void)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "----- Node reset  -----\n");
        hal_led_blink_ms(LEDS_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_RESET);
        /* This function may return if there are ongoing flash operations. */
        mesh_stack_device_reset();
    }
    
    static void config_server_evt_cb(const config_server_evt_t * p_evt)
    {
        if (p_evt->type == CONFIG_SERVER_EVT_NODE_RESET)
        {
            node_reset();
        }
    }
    
    static void button_event_handler(uint32_t button_number)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Button %u pressed\n", button_number);
        switch (button_number)
        {
            /* Pressing SW1 on the Development Kit will result in LED state to toggle and trigger
            the STATUS message to inform client about the state change. This is a demonstration of
            state change publication due to local event. */
            case 0:
            {
                __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "User action \n");
                hal_led_pin_set(ONOFF_SERVER_0_LED, !hal_led_pin_get(ONOFF_SERVER_0_LED));
                app_onoff_status_publish(&m_onoff_server_0);
                break;
            }
    
            /* Initiate node reset */
            /*
            case 3:
            {
                /* Clear all the states to reset the node. 8/
                if (mesh_stack_is_device_provisioned())
                {
    #if MESH_FEATURE_GATT_PROXY_ENABLED
                    (void) proxy_stop();
    #endif
                    mesh_stack_config_clear();
                    node_reset();
                }
                else
                {
                    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "The device is unprovisioned. Resetting has no effect.\n");
                }
                break;
            }*/
    
            default:
                break;
        }
    }
    
    static void app_rtt_input_handler(int key)
    {
        if (key >= '0' && key <= '4')
        {
            uint32_t button_number = key - '0';
            button_event_handler(button_number);
        }
    }
    
    static void device_identification_start_cb(uint8_t attention_duration_s)
    {
        hal_led_mask_set(LEDS_MASK, false);
        hal_led_blink_ms(BSP_LED_2_MASK  | BSP_LED_3_MASK, 
                         LED_BLINK_ATTENTION_INTERVAL_MS, 
                         LED_BLINK_ATTENTION_COUNT(attention_duration_s));
    }
    
    static void provisioning_aborted_cb(void)
    {
        hal_led_blink_stop();
    }
    
    static void provisioning_complete_cb(void)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Successfully provisioned\n");
    
    #if MESH_FEATURE_GATT_ENABLED
        /* Restores the application parameters after switching from the Provisioning
         * service to the Proxy  */
        gap_params_init();
        conn_params_init();
    #endif
    
        dsm_local_unicast_address_t node_address;
        dsm_local_unicast_addresses_get(&node_address);
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Node Address: 0x%04x \n", node_address.address_start);
    
        hal_led_blink_stop();
        hal_led_mask_set(LEDS_MASK, LED_MASK_STATE_OFF);
        hal_led_blink_ms(LEDS_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_PROV);
    }
    
    static void models_init_cb(void)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Initializing and adding models\n");
        app_model_init();
    }
    
    static void mesh_init(void)
    {
        uint8_t dev_uuid[NRF_MESH_UUID_SIZE];
        uint8_t node_uuid_prefix[NODE_UUID_PREFIX_LEN] = SERVER_NODE_UUID_PREFIX;
    
        ERROR_CHECK(mesh_app_uuid_gen(dev_uuid, node_uuid_prefix, NODE_UUID_PREFIX_LEN));
        mesh_stack_init_params_t init_params =
        {
            .core.irq_priority       = NRF_MESH_IRQ_PRIORITY_LOWEST,
            .core.lfclksrc           = DEV_BOARD_LF_CLK_CFG,
            .core.p_uuid             = dev_uuid,
            .models.models_init_cb   = models_init_cb,
            .models.config_server_cb = config_server_evt_cb
        };
        ERROR_CHECK(mesh_stack_init(&init_params, &m_device_provisioned));
    }
    
    static void initialize(void)
    {
        __LOG_INIT(LOG_SRC_APP | LOG_SRC_ACCESS | LOG_SRC_BEARER, LOG_LEVEL_INFO, LOG_CALLBACK_DEFAULT);
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "----- BLE Mesh Light Switch Server Demo -----\n");
    
        ERROR_CHECK(app_timer_init());
        hal_leds_init();
    
    #if BUTTON_BOARD
        ERROR_CHECK(hal_buttons_init(button_event_handler));
    #endif
    
        ble_stack_init();
    
    #if MESH_FEATURE_GATT_ENABLED
        gap_params_init();
        conn_params_init();
    #endif
    
        mesh_init();
    }
    
    static void start(void)
    {
        rtt_input_enable(app_rtt_input_handler, RTT_INPUT_POLL_PERIOD_MS);
    
        if (!m_device_provisioned)
        {
            static const uint8_t static_auth_data[NRF_MESH_KEY_SIZE] = STATIC_AUTH_DATA;
            mesh_provisionee_start_params_t prov_start_params =
            {
                .p_static_data    = static_auth_data,
                .prov_complete_cb = provisioning_complete_cb,
                .prov_device_identification_start_cb = device_identification_start_cb,
                .prov_device_identification_stop_cb = NULL,
                .prov_abort_cb = provisioning_aborted_cb,
                .p_device_uri = NULL
            };
            ERROR_CHECK(mesh_provisionee_prov_start(&prov_start_params));
        }
    
        const uint8_t *p_uuid = nrf_mesh_configure_device_uuid_get();
        UNUSED_VARIABLE(p_uuid);
        __LOG_XB(LOG_SRC_APP, LOG_LEVEL_INFO, "Device UUID ", p_uuid, NRF_MESH_UUID_SIZE);
    
        ERROR_CHECK(mesh_stack_start());
    
        hal_led_mask_set(LEDS_MASK, LED_MASK_STATE_OFF);
        hal_led_blink_ms(LEDS_MASK, LED_BLINK_INTERVAL_MS, LED_BLINK_CNT_START);
    }
    
    int main(void)
    {
        initialize();
        start();
    
        for (;;)
        {
            (void)sd_app_evt_wait();
        }
    }
    

    In the initial startup of the PCA10059 leds and PCA10056, all 4 LEDs work fine on PCA10056, but only 3 of the 4 light up on the PCA10059 (Green missing).

    I ran the blinky example and green led turned on just fine, so I am suspecting a bug in the SDK.

    I should also mention that the button doesn't work either; oddly enough.

    Preprocessor is set to include BOARD_PCA10059

    c_preprocessor_definitions="NO_VTOR_CONFIG;USE_APP_CONFIG;CONFIG_APP_IN_CORE;NRF52_SERIES;NRF52840;NRF52840_XXAA;S140;SOFTDEVICE_PRESENT;NRF_SD_BLE_API_VERSION=6;BOARD_PCA10059;CONFIG_GPIO_AS_PINRESET;"

    board.h (unchanged)

    /**
     * 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)
    
    #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 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
    

    pca10059.h

    /**
     * Copyright (c) 2017 - 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 PCA10059_H
    #define PCA10059_H
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    #include "nrf_gpio.h"
    
    // LED definitions for PCA10059
    // Each LED color is considered a separate LED
    #define LEDS_NUMBER    4
    
    #define LED1_G         NRF_GPIO_PIN_MAP(0,6)
    #define LED2_R         NRF_GPIO_PIN_MAP(0,8)
    #define LED2_G         NRF_GPIO_PIN_MAP(1,9)
    #define LED2_B         NRF_GPIO_PIN_MAP(0,12)
    
    #define LED_1          LED1_G
    #define LED_2          LED2_R
    #define LED_3          LED2_G
    #define LED_4          LED2_B
    
    #define LED_START      LED_1
    #define LED_STOP       LED_4
    
    #define LEDS_ACTIVE_STATE 0
    
    #define LEDS_LIST { LED_1, LED_2, LED_3, LED_4 }
    
    #define LEDS_INV_MASK  LEDS_MASK
    
    #define BSP_LED_0      LED_1
    #define BSP_LED_1      LED_2
    #define BSP_LED_2      LED_3
    #define BSP_LED_3      LED_4
    
    // There is only one button for the application
    // as the second button is used for a RESET.
    #define BUTTONS_NUMBER 1
    
    #define BUTTON_1       NRF_GPIO_PIN_MAP(1,6)
    #define BUTTON_PULL    NRF_GPIO_PIN_PULLUP
    
    #define BUTTONS_ACTIVE_STATE 0
    
    #define BUTTONS_LIST { BUTTON_1 }
    
    #define BSP_BUTTON_0   BUTTON_1
    
    #define BSP_SELF_PINRESET_PIN NRF_GPIO_PIN_MAP(0,19)
    
    #define HWFC           true
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif // PCA10059_H
    

Children
  • Update

    Green LED seems to work fine if I use the GPIO approach, ie.

    #define PIN_LEDG                    NRF_GPIO_PIN_MAP(1,9)
    ...
    
    static void app_onoff_server_set_cb(const app_onoff_server_t * p_server, bool onoff)
    {
        if(onoff){
        nrf_gpio_pin_set(PIN_LEDG);
        }else{
        nrf_gpio_pin_clear(PIN_LEDG);
        }
    }
    
    static void initialize(void){
    ...
    nrf_gpio_cfg_output(PIN_LEDG);
    ...
    }

    Might just be a bug with how simple_hal is handling the dongle.

Related