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

Disable SoftDevice Control of the PA/LNA Control Lines and Returning to GPIOs

At certain times, I would like to disable the SoftDevice's control of the PA/LNA control lines and return them to normal GPIO lines.

When the SoftDevice is using the provided GPIOTE channel to control the PA & LNA control lines, is it updating the gpiote_control_block_t struct provided by the nrfx_gpiote.c driver as it turns the PA/LNA on and off? 

My worry is this: if the SoftDevice updates the control block that is part of the GPIOTE driver, then calling nrfx_gpiote_out_uninit()may fail depending on which pin (PA enable or LNA enable) is assigned to the allocated GPIOTE channel at the time the nrfx_gpiote_out_uninit() function is called.

After calling sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &opt) (with opt initialized to all 0's), should it work to simply call nrfx_gpiote_out_uninit()on whatever pin number is used to first allocate the GPIOTE channel?  (This is, if a PA pin is provided calling the nrfx_gpiote_out_uinit() function with the PA pin and if only a LNA pin is provided, calling nrfx_gpiote_out_uinit() function with the LNA pin.)

Thank you,

Kyle

  • Hi,

    The safest way to use the pins again would be to disable the task by calling sd_ble_opt_set() but with enable = 0 in the cnf struct. Such as this:

    static void de_pa_lna_assist(uint32_t gpio_pa_pin, uint32_t gpio_lna_pin)
    {
        ret_code_t err_code;
    
        static const uint32_t gpio_toggle_ch = 0;
        static const uint32_t ppi_set_ch = 0;
        static const uint32_t ppi_clr_ch = 1;
        
        // Configure SoftDevice PA/LNA assist
        ble_opt_t opt;
        memset(&opt, 0, sizeof(ble_opt_t));
        // Common PA/LNA config
        opt.common_opt.pa_lna.gpiote_ch_id  = gpio_toggle_ch;        // GPIOTE channel
        opt.common_opt.pa_lna.ppi_ch_id_clr = ppi_clr_ch;            // PPI channel for pin clearing
        opt.common_opt.pa_lna.ppi_ch_id_set = ppi_set_ch;            // PPI channel for pin setting
        // PA config
        opt.common_opt.pa_lna.pa_cfg.active_high = 1;                // Set the pin to be active high
        opt.common_opt.pa_lna.pa_cfg.enable      = 0;                // Disable
        opt.common_opt.pa_lna.pa_cfg.gpio_pin    = gpio_pa_pin;      // The GPIO pin to toggle
      
        // LNA config
        opt.common_opt.pa_lna.lna_cfg.active_high  = 1;              // Set the pin to be active high
        opt.common_opt.pa_lna.lna_cfg.enable       = 0;              // Disable
        opt.common_opt.pa_lna.lna_cfg.gpio_pin     = gpio_lna_pin;   // The GPIO pin to toggle
    
        err_code = sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &opt);
        APP_ERROR_CHECK(err_code);
    }

    best regards

    Jared 

Related