NRF52840 BLE LED/Button Pairing

Hello. 

I am modifying the nRF52840DK NRF desktop firmware for a custom mouse application. Using the standard firmware, LED2 is used as the status LED for connectivity. What is the best way to reconfigure the status LED (LED3 or LED4)? I can't find any setting in the nRF Kconfig GUI. Also, is there any way to reconfigure other buttons as the peer control? 

Thank you.

Parents
  • Hi tsroga,

    Alberto's suggestions are right for most common usage of LEDs in the nRF Connect SDK. The DTS approach is still the same for the nRF Desktop application.

    As for .c files changes, it's a little different for the nRF Desktop application.

    First, I will try to explain what is going on.
    If you cannot afford to dive into the details, just skip to the conclusion after the horizontal divider line.

    1. nRF Desktop is a full application based on the Common Application Framework. Functionalities are implemented in different modules that communicate with each other by events, via the Application Event Manager.

    2. For LEDs in particular, these modules are involved:
      1. LED state module
      2. LED stream module
      3. LEDs module
      4. HID state module

    3. The mapping of LEDs "roles" to available LEDs defined on the DTS is done in the configuration of the LED state module and HID state module.
      1. In /configuration/common/led_state.h, two roles are defined, System State LED and Peer State LED (the one you referred to as Connectivity State).
      2. In /configuration/common/hid_keyboard_leds.h, five more roles for a keyboard build are defined, Caps Lock, Num Lock, Scroll Lock, etc.

    4. The actuation of the LEDs is handled in the LED stream module.
      All available LEDs in the DTS are fetched automatically, and ID are given in the order they are found.
      Note that here, the ID are given from 0, versus on the nRF52840 DK, where the LED are numbered from 1.

    5. In each board's configurations, the roles are mapped to the LEDs available on the DTS. For example:
      1. In /configuration/nrf52840dk_nrf52840/led_state_def.h, the System State LED is mapped to LED 0, and the Peer State LED is mapped to LED 1
      2. In /configuration/nrf52840dk_nrf52840/hid_keyboard_leds_def_keyboard.h, the Caps Lock LED and Num Lock LED (for keyboard build) are mapped to LED 2 and 3, respectively.
      3. For an example of when the LED is physically unavailable, see /configuration/nrf52kbd_nrf52832/led_state_def.h

    Based on the facts above, there will be a number of approaches to reconfigure the connectivity LED 2 to LED 3. Here are the two simplest ones:

    • Just swap the two LEDs on the board overlay file.
    • Reconfigure the LED ID in led_state_def.h and hid_keyboard_leds_def_keyboard.h.

    I hope the explanation makes sense. The nRF Desktop application was designed with an architecture, and giving a brief summary of an aspect has been quite challenging for me.

    Please don't hesitate to let me know if anything doesn't make sense.

    Hieu

  • Hello Hieu. 

    Thank you for the information you provided. It did help me understand more of what is going on. I should be a little more clear on what I'm trying to do. I created a 52840DK board/configuration based on 52840 gmouse project. While the project flashes onto my board, I do not see a "breathing" led, like I do with the nrf52840dk_nrf52840 sample project. Diving further into the sample project, each LED on the DK are assigned their own PWM timer. On my firmware, pwm0 and pwm1 are used for RGB lighting. I did assign channel 3 of pwm1 to one of the LEDs, but this had no effect. Do I have to configure an event for both the system and peer LEDs? 

Reply
  • Hello Hieu. 

    Thank you for the information you provided. It did help me understand more of what is going on. I should be a little more clear on what I'm trying to do. I created a 52840DK board/configuration based on 52840 gmouse project. While the project flashes onto my board, I do not see a "breathing" led, like I do with the nrf52840dk_nrf52840 sample project. Diving further into the sample project, each LED on the DK are assigned their own PWM timer. On my firmware, pwm0 and pwm1 are used for RGB lighting. I did assign channel 3 of pwm1 to one of the LEDs, but this had no effect. Do I have to configure an event for both the system and peer LEDs? 

Children
Related