Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void pin_clear(const ble_pa_lna_cfg_t * p_cfg)
- {
- if (p_cfg->enable)
- {
- if(p_cfg->gpio_pin <= ARRAY_SIZE(NRF_P0->PIN_CNF)) {
- if (p_cfg->active_high)
- {
- NRF_P0->OUTCLR = (1UL << p_cfg->gpio_pin);
- }
- else
- {
- NRF_P0->OUTSET = (1UL << p_cfg->gpio_pin);
- }
- } else {
- if (p_cfg->active_high)
- {
- NRF_P1->OUTCLR = (1UL << p_cfg->gpio_pin);
- }
- else
- {
- NRF_P1->OUTSET = (1UL << p_cfg->gpio_pin);
- }
- }
- }
- }
- static void pin_init(const ble_pa_lna_cfg_t * p_cfg)
- {
- if (p_cfg->enable)
- {
- uint32_t pinNumber = p_cfg->gpio_pin;
- NRF_GPIO_Type * reg = nrf_gpio_pin_port_decode(&pinNumber);
- reg->PIN_CNF[p_cfg->gpio_pin] =
- ((uint32_t) GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos) |
- ((uint32_t) GPIO_PIN_CNF_INPUT_Disconnect << GPIO_PIN_CNF_INPUT_Pos) |
- ((uint32_t) GPIO_PIN_CNF_PULL_Disabled << GPIO_PIN_CNF_PULL_Pos) |
- ((uint32_t) GPIO_PIN_CNF_DRIVE_S0S1 << GPIO_PIN_CNF_DRIVE_Pos) |
- ((uint32_t) GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos);
- reg->DIRSET = (GPIO_DIRSET_PIN0_Output << (GPIO_DIRSET_PIN0_Pos + p_cfg->gpio_pin));
- pin_clear(p_cfg);
- }
- }
- uint32_t m_mesh_pa_lna_gpiote_enable(const mesh_pa_lna_gpiote_params_t * p_params)
- {
- /*
- if(p_params->lna_cfg.gpio_pin > ARRAY_SIZE(NRF_P0->PIN_CNF)) {
- __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "LNA pin for mesh remapped!\n");
- p_params->lna_cfg.gpio_pin -= ARRAY_SIZE(NRF_P0->PIN_CNF);
- }
- if(p_params->_cfg.gpio_pin > ARRAY_SIZE(NRF_P0->PIN_CNF)) {
- __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "PA pin for mesh remapped!\n");
- p_params->pa_cfg.gpio_pin -= ARRAY_SIZE(NRF_P0->PIN_CNF);
- }
- */
- if (p_params == NULL)
- {
- return NRF_ERROR_NULL;
- }
- if ((p_params->ppi_ch_id_set >= TIMER_PPI_CH_START &&
- p_params->ppi_ch_id_set <= TIMER_PPI_CH_STOP) ||
- (p_params->ppi_ch_id_clr >= TIMER_PPI_CH_START &&
- p_params->ppi_ch_id_clr <= TIMER_PPI_CH_STOP) ||
- (p_params->ppi_ch_id_set >= ARRAY_SIZE(NRF_PPI->CH)) ||
- (p_params->ppi_ch_id_clr >= ARRAY_SIZE(NRF_PPI->CH)) ||
- (p_params->ppi_ch_id_set == p_params->ppi_ch_id_clr) ||
- (p_params->gpiote_ch_id >= ARRAY_SIZE(NRF_GPIOTE->CONFIG)))
- {
- return NRF_ERROR_INVALID_PARAM;
- }
- m_gpiote.enabled = false;
- m_gpiote.params = *p_params;
- m_gpiote.enabled = true;
- pin_init(&p_params->lna_cfg);
- pin_init(&p_params->pa_cfg);
- return NRF_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement