Commit ae754489 authored by Donald Chen's avatar Donald Chen
Browse files

pa/lna active

parent 92f843de
**/_build
**/ses/Output
This diff is collapsed.
......@@ -230,27 +230,6 @@ void pin_to_default(uint8_t pin)
}
#endif
#if defined(BOARD_PCA10056)
static void pa_lna_passthrough(void)
{
#define PA_RX_EN_PIN 38 //p1.06
#define PA_TX_EN_PIN 37 //p1.05
#define PA_MODE_PIN 36 //p1.04
#define ANT_SEL_PIN 34 //p1.02
//configure PA-LNA pins as outputs
nrf_gpio_cfg_output(PA_RX_EN_PIN);
nrf_gpio_cfg_output(PA_TX_EN_PIN);
nrf_gpio_cfg_output(PA_MODE_PIN);
nrf_gpio_cfg_output(ANT_SEL_PIN);
//set PA-LNA pins for bypass mode, using the internal antenna
nrf_gpio_pin_clear(PA_RX_EN_PIN);
nrf_gpio_pin_clear(PA_TX_EN_PIN);
nrf_gpio_pin_set(PA_MODE_PIN);
nrf_gpio_pin_set(ANT_SEL_PIN);
}
#endif
/**@brief Main function of the connectivity application. */
int main(void)
......@@ -258,10 +237,6 @@ int main(void)
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
#if defined(BOARD_PCA10056)
pa_lna_passthrough();
#endif
uint32_t err_code = NRF_SUCCESS;
APP_ERROR_CHECK(NRF_LOG_INIT(timestamp, 64000000));
......
#include <stdint.h>
#include <string.h>
#include "pa_lna.h"
#include "ble.h"
#include "ble_gap.h"
#include "nrf_gpio.h"
#if defined(PA_LNA_ACTIVE)
#pragma message("pa/lna: active")
static void pa_lna_assist(uint32_t gpio_pa_pin, uint32_t gpio_lna_pin)
{
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;
ret_code_t err_code;
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 = 1; // Enable toggling
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 = 1; // Enable toggling
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);
}
void pa_lna_init(void)
{
//must run after softdevice is initialized
//Set PA-LNA Mode Pin: Low for Normal operation
nrf_gpio_cfg_output(PA_MODE_PIN);
nrf_gpio_pin_clear(PA_MODE_PIN);
//Set PA-lNA Antenna Select Pin: high for internal antenna
nrf_gpio_cfg_output(ANT_SEL_PIN);
nrf_gpio_pin_set(ANT_SEL_PIN);
//Setup PA-LNA TX and RX control pins with the SoftDevice
pa_lna_assist(PA_TX_EN_PIN,PA_RX_EN_PIN);
//Set TX powerfor scan responses
sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_SCAN_INIT, 0, RADIO_TXPOWER_TXPOWER_Neg12dBm);
//Set TX power for advertisements
sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, 0, RADIO_TXPOWER_TXPOWER_Neg12dBm);
//Tx power for connections inherit the scan or advertising powers
}
#elif defined(PA_LNA_PASSTHROUGH)
#pragma message("pa/lna: passthrough")
void pa_lna_init(void)
{
//configure PA-LNA pins as outputs
nrf_gpio_cfg_output(PA_RX_EN_PIN);
nrf_gpio_cfg_output(PA_TX_EN_PIN);
nrf_gpio_cfg_output(PA_MODE_PIN);
nrf_gpio_cfg_output(ANT_SEL_PIN);
//set PA-LNA pins for bypass mode, using the internal antenna
nrf_gpio_pin_clear(PA_RX_EN_PIN);
nrf_gpio_pin_clear(PA_TX_EN_PIN);
nrf_gpio_pin_set(PA_MODE_PIN);
nrf_gpio_pin_set(ANT_SEL_PIN);
}
#else
#pragma message("pa/lna: n/a")
void pa_lna_init(void)
{
//nothing to do
}
#endif
\ No newline at end of file
#ifndef PA_LNA_H__
#define PA_LNA_H__
#define PA_RX_EN_PIN 38 //p1.06
#define PA_TX_EN_PIN 37 //p1.05
#define PA_MODE_PIN 36 //p1.04
#define ANT_SEL_PIN 34 //p1.02
//define PA_LNA_ACTIVE or PA_LNA_PASSTHROUGH
#define PA_LNA_ACTIVE
void pa_lna_init(void);
#endif
\ No newline at end of file
......@@ -85,10 +85,11 @@ SRC_FILES += \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_clock.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_power_clock.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/prs/nrfx_prs.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_qspi.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_qspi.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uart.c \
$(SDK_ROOT)/modules/nrfx/drivers/src/nrfx_uarte.c \
$(PROJ_DIR)/main.c \
$(PROJ_DIR)/pa_lna.c \
$(SDK_ROOT)/external/segger_rtt/SEGGER_RTT.c \
$(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_Syscalls_GCC.c \
$(SDK_ROOT)/external/segger_rtt/SEGGER_RTT_printf.c \
......@@ -141,6 +142,7 @@ INC_FOLDERS += \
$(SDK_ROOT)/modules/nrfx/drivers/include \
$(SDK_ROOT)/external/fprintf \
$(SDK_ROOT)/components/libraries/log/src \
$(PROJ_DIR) \
# Libraries common to all targets
LIB_FILES += \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment