项目作者: t2t-sonbui

项目描述 :
nRF52832-PA-LNA-Blink example
高级语言: C
项目地址: git://github.com/t2t-sonbui/nRF52832-PA-LNA-Blink-Example.git


nRF52832-PA/LNA Blink Fix not work!

===================

Test with nRF5_SDK_14.0.0_3bcc1f7 Soft132 v5.0

Add define APP_PA_LAN

//sdk_config.h
Add define:

  1. #ifndef NRF_SDH_CLOCK_LF_XTAL_ACCURACY_PA
  2. #define NRF_SDH_CLOCK_LF_XTAL_ACCURACY_PA 0
  3. #endif

//nf_sdh.c
Edit

  1. ret_code_t nrf_sdh_enable_request(void)
  2. {
  3. ...
  4. nrf_clock_lf_cfg_t const clock_lf_cfg =
  5. #ifdef APP_PA_LAN
  6. { .source = NRF_CLOCK_LF_SRC_SYNTH,
  7. .rc_ctiv = NRF_SDH_CLOCK_LF_RC_CTIV,
  8. .rc_temp_ctiv = NRF_SDH_CLOCK_LF_RC_TEMP_CTIV,
  9. .accuracy = NRF_SDH_CLOCK_LF_XTAL_ACCURACY_PA
  10. };
  11. #else
  12. {
  13. .source = NRF_SDH_CLOCK_LF_SRC,
  14. .rc_ctiv = NRF_SDH_CLOCK_LF_RC_CTIV,
  15. .rc_temp_ctiv = NRF_SDH_CLOCK_LF_RC_TEMP_CTIV,
  16. #ifdef S132
  17. .accuracy = NRF_SDH_CLOCK_LF_XTAL_ACCURACY
  18. #else
  19. .xtal_accuracy = NRF_SDH_CLOCK_LF_XTAL_ACCURACY
  20. #endif
  21. };
  22. #endif
  23. ...
  24. }

//main.c
Add config the PA/LNA before main funciton

  1. #ifdef APP_PA_LAN
  2. static void pa_lna_assist(uint32_t gpio_pa_pin, uint32_t gpio_lna_pin)
  3. {
  4. ret_code_t err_code;
  5. nrf_gpio_cfg_output(gpio_pa_pin);
  6. nrf_gpio_pin_clear(gpio_pa_pin); //
  7. nrf_gpio_cfg_output(gpio_lna_pin);
  8. nrf_gpio_pin_clear(gpio_lna_pin); //
  9. static const uint32_t gpio_toggle_ch = 0;
  10. static const uint32_t ppi_set_ch = 0;
  11. static const uint32_t ppi_clr_ch = 1;
  12. // Configure SoftDevice PA/LNA assist
  13. static ble_opt_t opt;
  14. memset(&opt, 0, sizeof(ble_opt_t));
  15. // Common PA/LNA config
  16. opt.common_opt.pa_lna.gpiote_ch_id = gpio_toggle_ch; // GPIOTE channel
  17. opt.common_opt.pa_lna.ppi_ch_id_clr = ppi_clr_ch; // PPI channel for pin clearing
  18. opt.common_opt.pa_lna.ppi_ch_id_set = ppi_set_ch; // PPI channel for pin setting
  19. // PA config
  20. opt.common_opt.pa_lna.pa_cfg.active_high = 1; // Set the pin to be active high
  21. opt.common_opt.pa_lna.pa_cfg.enable = 1; // Enable toggling
  22. opt.common_opt.pa_lna.pa_cfg.gpio_pin = gpio_pa_pin; // The GPIO pin to toggle
  23. // LNA config
  24. opt.common_opt.pa_lna.lna_cfg.active_high = 1; // Set the pin to be active high
  25. opt.common_opt.pa_lna.lna_cfg.enable = 1; // Enable toggling
  26. opt.common_opt.pa_lna.lna_cfg.gpio_pin = gpio_lna_pin; // The GPIO pin to toggle
  27. err_code = sd_ble_opt_set(BLE_COMMON_OPT_PA_LNA, &opt);
  28. APP_ERROR_CHECK(err_code);
  29. }
  30. #endif

Main funciton:
Add after funciton “ble_stack_init()”

  1. #ifdef APP_PA_LAN
  2. pa_lna_assist(24,20);//Pin 0.24 and pin 0.20
  3. #endif

Support