1 /*
2 * Copyright (c) 2024 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 /* Extracted from radio_nrf_dppi.h functions that reference gpiote variables. */
8
9 #if defined(HAL_RADIO_GPIO_HAVE_PA_PIN) || defined(HAL_RADIO_GPIO_HAVE_LNA_PIN)
hal_palna_ppi_setup(void)10 static inline void hal_palna_ppi_setup(void)
11 {
12 nrf_timer_publish_set(EVENT_TIMER, NRF_TIMER_EVENT_COMPARE2,
13 HAL_ENABLE_PALNA_PPI);
14 nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_EVENT_DISABLED,
15 HAL_DISABLE_PALNA_PPI);
16
17 #if !defined(HAL_RADIO_FEM_IS_NRF21540)
18 nrf_gpiote_task_t task;
19
20 task = nrf_gpiote_out_task_get(gpiote_ch_palna);
21 nrf_gpiote_subscribe_set(gpiote_palna.p_reg, task, HAL_DISABLE_PALNA_PPI);
22 #endif
23 }
24 #endif /* defined(HAL_RADIO_GPIO_HAVE_PA_PIN) || defined(HAL_RADIO_GPIO_HAVE_LNA_PIN) */
25
26 /******************************************************************************/
27 #if defined(HAL_RADIO_FEM_IS_NRF21540)
hal_gpiote_tasks_setup(NRF_GPIOTE_Type * gpiote,uint8_t gpiote_ch,bool inv,uint8_t ppi_ch_enable,uint8_t ppi_ch_disable)28 static inline void hal_gpiote_tasks_setup(NRF_GPIOTE_Type *gpiote,
29 uint8_t gpiote_ch,
30 bool inv,
31 uint8_t ppi_ch_enable,
32 uint8_t ppi_ch_disable)
33 {
34 nrf_gpiote_task_t task;
35
36 task = inv ? nrf_gpiote_clr_task_get(gpiote_ch) :
37 nrf_gpiote_set_task_get(gpiote_ch);
38 nrf_gpiote_subscribe_set(gpiote, task, ppi_ch_enable);
39
40 task = inv ? nrf_gpiote_set_task_get(gpiote_ch) :
41 nrf_gpiote_clr_task_get(gpiote_ch);
42 nrf_gpiote_subscribe_set(gpiote, task, ppi_ch_disable);
43 }
44
hal_pa_ppi_setup(void)45 static inline void hal_pa_ppi_setup(void)
46 {
47 hal_gpiote_tasks_setup(gpiote_palna.p_reg, gpiote_ch_palna,
48 IS_ENABLED(HAL_RADIO_GPIO_PA_POL_INV),
49 HAL_ENABLE_PALNA_PPI, HAL_DISABLE_PALNA_PPI);
50 }
51
hal_lna_ppi_setup(void)52 static inline void hal_lna_ppi_setup(void)
53 {
54 hal_gpiote_tasks_setup(gpiote_palna.p_reg, gpiote_ch_palna,
55 IS_ENABLED(HAL_RADIO_GPIO_LNA_POL_INV),
56 HAL_ENABLE_PALNA_PPI, HAL_DISABLE_PALNA_PPI);
57 }
58
hal_fem_ppi_setup(void)59 static inline void hal_fem_ppi_setup(void)
60 {
61 nrf_timer_publish_set(EVENT_TIMER, NRF_TIMER_EVENT_COMPARE3,
62 HAL_ENABLE_FEM_PPI);
63 nrf_radio_publish_set(NRF_RADIO, NRF_RADIO_EVENT_DISABLED,
64 HAL_DISABLE_FEM_PPI);
65
66 hal_gpiote_tasks_setup(gpiote_pdn.p_reg, gpiote_ch_pdn,
67 IS_ENABLED(HAL_RADIO_GPIO_NRF21540_PDN_POL_INV),
68 HAL_ENABLE_FEM_PPI, HAL_DISABLE_FEM_PPI);
69
70 hal_gpiote_tasks_setup(gpiote_csn.p_reg, gpiote_ch_csn,
71 IS_ENABLED(HAL_RADIO_GPIO_NRF21540_CSN_POL_INV),
72 HAL_ENABLE_FEM_PPI, HAL_DISABLE_FEM_PPI);
73 }
74
75 #endif /* HAL_RADIO_FEM_IS_NRF21540 */
76