Skip to content

Commit 2b58720

Browse files
committed
nimble/drivers: Add initial support for nRF54L15 PHY
1 parent 895ed28 commit 2b58720

File tree

16 files changed

+1052
-83
lines changed

16 files changed

+1052
-83
lines changed
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#ifndef H_PHY_HW_
21+
#define H_PHY_HW_
22+
23+
#include <nrf_gpio.h>
24+
#include <nrf_gpiote.h>
25+
26+
/* To disable all radio interrupts */
27+
#define NRF_RADIO_IRQ_MASK_ALL (0x34FF)
28+
29+
#define NRF_RADIO_INTENSET NRF_RADIO->INTENSET
30+
31+
#define NRF_AAR_NIRK NRF_AAR->NIRK
32+
#define NRF_AAR_IRKPTR NRF_AAR->IRKPTR
33+
#define NRF_AAR_ADDRPTR NRF_AAR->ADDRPTR
34+
#define NRF_AAR_STATUS NRF_AAR->STATUS
35+
36+
#define NRF_CCM_STATUS NRF_CCM->MICSTATUS
37+
#define NRF_CCM_EVENTS_END NRF_CCM->EVENTS_ENDCRYPT
38+
39+
#define CCM_INIT() \
40+
do { \
41+
NRF_CCM->SHORTS = CCM_SHORTS_ENDKSGEN_CRYPT_Msk; \
42+
} while (0)
43+
44+
#define CCM_SETUP_TX() \
45+
do { \
46+
NRF_CCM->SHORTS = CCM_SHORTS_ENDKSGEN_CRYPT_Msk; \
47+
NRF_CCM->INPTR = (uint32_t)&g_ble_phy_enc_buf[0]; \
48+
NRF_CCM->OUTPTR = (uint32_t)&g_ble_phy_tx_buf[0]; \
49+
NRF_CCM->SCRATCHPTR = (uint32_t)&g_nrf_encrypt_scratchpad[0]; \
50+
NRF_CCM->EVENTS_ERROR = 0; \
51+
NRF_CCM->MODE = CCM_MODE_LENGTH_Msk | ble_phy_get_ccm_datarate(); \
52+
NRF_CCM->CNFPTR = (uint32_t)&g_nrf_ccm_data; \
53+
} while (0)
54+
55+
#define CCM_SETUP_RX() \
56+
do { \
57+
NRF_CCM->INPTR = (uint32_t)&g_ble_phy_enc_buf[0]; \
58+
NRF_CCM->OUTPTR = (uint32_t)&g_ble_phy_enc_buf[3]; \
59+
NRF_CCM->SCRATCHPTR = (uint32_t)&g_nrf_encrypt_scratchpad[0]; \
60+
NRF_CCM->MODE = CCM_MODE_LENGTH_Msk | CCM_MODE_MODE_Decryption | \
61+
ble_phy_get_ccm_datarate(); \
62+
NRF_CCM->CNFPTR = (uint32_t)&g_nrf_ccm_data; \
63+
NRF_CCM->SHORTS = 0; \
64+
NRF_CCM->EVENTS_ERROR = 0; \
65+
NRF_CCM->EVENTS_ENDCRYPT = 0; \
66+
} while (0)
67+
68+
#define CCM_START() \
69+
do { \
70+
nrf_ccm_task_trigger(NRF_CCM, NRF_CCM_TASK_KSGEN); \
71+
} while (0)
72+
73+
#define RADIO_FAST_RU_SETUP() \
74+
do { \
75+
NRF_RADIO->MODECNF0 |= (RADIO_MODECNF0_RU_Fast << RADIO_MODECNF0_RU_Pos) & \
76+
RADIO_MODECNF0_RU_Msk; \
77+
} while (0)
78+
79+
#define RADIO_EVENTS_CLEAR() \
80+
do { \
81+
NRF_RADIO->EVENTS_READY = 0; \
82+
NRF_RADIO->EVENTS_END = 0; \
83+
NRF_RADIO->EVENTS_DISABLED = 0; \
84+
} while (0)
85+
86+
#define RADIO_SHORTS_SETUP_TX() \
87+
do { \
88+
NRF_RADIO->SHORTS = RADIO_SHORTS_END_DISABLE_Msk | \
89+
RADIO_SHORTS_READY_START_Msk; \
90+
} while (0)
91+
92+
93+
#define RADIO_SHORTS_SETUP_RX() \
94+
do { \
95+
NRF_RADIO->EVENTS_RSSIEND = 0; \
96+
NRF_RADIO->SHORTS = RADIO_SHORTS_END_DISABLE_Msk | \
97+
RADIO_SHORTS_READY_START_Msk | \
98+
RADIO_SHORTS_ADDRESS_BCSTART_Msk | \
99+
RADIO_SHORTS_ADDRESS_RSSISTART_Msk | \
100+
RADIO_SHORTS_DISABLED_RSSISTOP_Msk; \
101+
} while (0)
102+
103+
#define RADIO_DATAWHITE_SET(_chan) \
104+
do { \
105+
NRF_RADIO->DATAWHITEIV = (_chan); \
106+
} while (0)
107+
108+
#define RADIO_TIMER_CONFIGURE() \
109+
do { \
110+
NRF_TIMER0->PRESCALER = 4; \
111+
} while (0)
112+
113+
#define RADIO_TIMER_TASK_STOP() \
114+
do { \
115+
nrf_timer_task_trigger(NRF_TIMER0, NRF_TIMER_TASK_STOP); \
116+
NRF_TIMER0->TASKS_SHUTDOWN = 1; \
117+
} while (0)
118+
119+
#define NRF_AAR_IRK_SETUP() \
120+
do { \
121+
NRF_AAR->IRKPTR = (uint32_t)&g_nrf_irk_list[0]; \
122+
NRF_AAR->SCRATCHPTR = (uint32_t)&g_ble_phy_data.phy_aar_scratch; \
123+
} while (0)
124+
125+
#define NRF_AAR_ADDRPTR_SET(_ptr) \
126+
do { \
127+
NRF_AAR->ADDRPTR = (uint32_t)(_ptr); \
128+
} while (0)
129+
130+
static inline void
131+
phy_gpiote_configure(int idx, int pin)
132+
{
133+
nrf_gpio_cfg_output(pin);
134+
nrf_gpiote_task_configure(NRF_GPIOTE, idx, pin, NRF_GPIOTE_POLARITY_NONE,
135+
NRF_GPIOTE_INITIAL_VALUE_LOW);
136+
nrf_gpiote_task_enable(NRF_GPIOTE, idx);
137+
}
138+
139+
#endif /* H_PHY_HW_ */

nimble/drivers/nrf5x/nrf52/pkg.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
pkg.name: nimble/drivers/nrf5x/nrf52
21+
pkg.description: PHY for nRF52 and nRF53 series
22+
pkg.author: "Apache Mynewt <[email protected]>"
23+
pkg.homepage: "https://mynewt.apache.org/"
24+
pkg.keywords:
25+
- ble
26+
- bluetooth

nimble/drivers/nrf5x/src/nrf52/phy.c renamed to nimble/drivers/nrf5x/nrf52/src/phy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <stdint.h>
2121
#include <nrfx.h>
2222
#include <controller/ble_fem.h>
23-
#include "../phy_priv.h"
23+
#include "phy_ppi.h"
2424

2525
#if PHY_USE_DEBUG
2626
void
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#include "../nrf52/include/phy_hw.h"

nimble/drivers/nrf5x/nrf53/pkg.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
pkg.name: nimble/drivers/nrf5x/nrf53
21+
pkg.description: PHY for nRF52 and nRF53 series
22+
pkg.author: "Apache Mynewt <[email protected]>"
23+
pkg.homepage: "https://mynewt.apache.org/"
24+
pkg.keywords:
25+
- ble
26+
- bluetooth

nimble/drivers/nrf5x/src/nrf53/phy.c renamed to nimble/drivers/nrf5x/nrf53/src/phy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <stdint.h>
2121
#include <nrfx.h>
2222
#include <controller/ble_fem.h>
23-
#include "../phy_priv.h"
23+
#include "phy_ppi.h"
2424

2525
/*
2626
* When the radio is operated on high voltage (see VREQCTRL - Voltage request
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
#ifndef H_PHY_HW_
21+
#define H_PHY_HW_
22+
23+
#define NRF_TIMER0 NRF_TIMER10
24+
#define NRF_DPPIC NRF_DPPIC10
25+
#define NRF_RTC0 NRF_RTC10
26+
#define NRF_AAR NRF_AAR00
27+
#define NRF_CCM NRF_CCM00
28+
#define NRF_AAR NRF_AAR00
29+
#define NRF_GPIOTE NRF_GPIOTE20
30+
31+
#define RADIO_IRQn RADIO_0_IRQn
32+
#define RADIO_INTENSET_ADDRESS_Msk RADIO_INTENSET00_ADDRESS_Msk
33+
#define RADIO_INTENCLR_ADDRESS_Msk RADIO_INTENCLR00_ADDRESS_Msk
34+
#define RADIO_INTENSET_DISABLED_Msk RADIO_INTENSET00_DISABLED_Msk
35+
#define RADIO_INTENCLR_DISABLED_Msk RADIO_INTENCLR00_DISABLED_Msk
36+
37+
#define NRF_RADIO_INTENSET NRF_RADIO->INTENSET00
38+
39+
/* To disable all radio interrupts */
40+
#define NRF_RADIO_IRQ_MASK_ALL (RADIO_INTENSET00_READY_Msk | \
41+
RADIO_INTENSET00_ADDRESS_Msk | \
42+
RADIO_INTENSET00_PAYLOAD_Msk | \
43+
RADIO_INTENSET00_PHYEND_Msk | \
44+
RADIO_INTENSET00_DISABLED_Msk | \
45+
RADIO_INTENSET00_DEVMATCH_Msk | \
46+
RADIO_INTENSET00_DEVMISS_Msk | \
47+
RADIO_INTENSET00_BCMATCH_Msk | \
48+
RADIO_INTENSET00_CRCOK_Msk | \
49+
RADIO_INTENSET00_CRCERROR_Msk)
50+
51+
#define NRF_AAR_NIRK NRF_AAR->MAXRESOLVED
52+
#define NRF_AAR_IRKPTR NRF_AAR->IN.PTR
53+
#define NRF_AAR_ADDRPTR NRF_AAR->IN.PTR
54+
#define NRF_AAR_STATUS NRF_AAR->ERRORSTATUS
55+
56+
#define CCM_MODE_DATARATE_125Kbps CCM_MODE_DATARATE_125Kbit
57+
#define CCM_MODE_DATARATE_500Kbps CCM_MODE_DATARATE_500Kbit
58+
59+
#define NRF_CCM_STATUS NRF_CCM->MACSTATUS
60+
#define NRF_CCM_EVENTS_END NRF_CCM->EVENTS_END
61+
62+
#define CCM_INIT()
63+
64+
#define CCM_SETUP_TX() \
65+
do { \
66+
NRF_CCM->IN.PTR = (uint32_t)&g_ble_phy_enc_buf[0]; \
67+
NRF_CCM->OUT.PTR = (uint32_t)&g_ble_phy_tx_buf[0]; \
68+
NRF_CCM->EVENTS_ERROR = 0; \
69+
NRF_CCM->MODE = CCM_MODE_MACLEN_Pos | ble_phy_get_ccm_datarate(); \
70+
memcpy((uint8_t *)NRF_CCM->KEY.VALUE, &g_nrf_ccm_data.key, \
71+
sizeof(g_nrf_ccm_data.key)); \
72+
} while (0)
73+
74+
#define CCM_SETUP_RX() \
75+
do { \
76+
NRF_CCM->IN.PTR = (uint32_t)&g_ble_phy_enc_buf[0]; \
77+
NRF_CCM->OUT.PTR = (uint32_t)&g_ble_phy_enc_buf[3]; \
78+
NRF_CCM->MODE = CCM_MODE_MACLEN_Pos | CCM_MODE_MODE_Decryption | \
79+
ble_phy_get_ccm_datarate(); \
80+
memcpy((uint8_t *)NRF_CCM->KEY.VALUE, &g_nrf_ccm_data.key, \
81+
sizeof(g_nrf_ccm_data.key)); \
82+
NRF_CCM->EVENTS_ERROR = 0; \
83+
NRF_CCM->EVENTS_END = 0; \
84+
} while (0)
85+
86+
#define CCM_START() \
87+
do { \
88+
nrf_ccm_task_trigger(NRF_CCM, NRF_CCM_TASK_START); \
89+
} while (0)
90+
91+
#define RADIO_FAST_RU_SETUP() \
92+
do { \
93+
NRF_RADIO->TIMING = (RADIO_TIMING_RU_Fast << RADIO_TIMING_RU_Pos) & \
94+
RADIO_TIMING_RU_Msk; \
95+
} while (0)
96+
97+
#define RADIO_EVENTS_CLEAR() \
98+
do { \
99+
NRF_RADIO->EVENTS_READY = 0; \
100+
NRF_RADIO->EVENTS_PHYEND = 0; \
101+
NRF_RADIO->EVENTS_END = 0; \
102+
NRF_RADIO->EVENTS_DISABLED = 0; \
103+
} while (0)
104+
105+
#define RADIO_SHORTS_SETUP_TX() \
106+
do { \
107+
NRF_RADIO->SHORTS = RADIO_SHORTS_PHYEND_DISABLE_Msk | \
108+
RADIO_SHORTS_READY_START_Msk; \
109+
} while (0)
110+
111+
#define RADIO_SHORTS_SETUP_RX() \
112+
do { \
113+
NRF_RADIO->SHORTS = RADIO_SHORTS_PHYEND_DISABLE_Msk | \
114+
RADIO_SHORTS_READY_START_Msk | \
115+
RADIO_SHORTS_ADDRESS_BCSTART_Msk | \
116+
RADIO_SHORTS_ADDRESS_RSSISTART_Msk; \
117+
} while (0)
118+
119+
#define RADIO_DATAWHITE_SET(_chan) \
120+
do { \
121+
NRF_RADIO->DATAWHITE = RADIO_DATAWHITE_ResetValue | (_chan); \
122+
} while (0)
123+
124+
#define RADIO_TIMER_CONFIGURE() \
125+
do { \
126+
NRF_TIMER0->PRESCALER = 5; \
127+
} while (0)
128+
129+
#define RADIO_TIMER_TASK_STOP() \
130+
do { \
131+
nrf_timer_task_trigger(NRF_TIMER0, NRF_TIMER_TASK_STOP); \
132+
} while (0)
133+
134+
#define NRF_AAR_IRK_SETUP() \
135+
do { \
136+
/* TODO */ \
137+
} while (0)
138+
139+
#define NRF_AAR_ADDRPTR_SET(_ptr) \
140+
do { \
141+
/* TODO */ \
142+
} while (0)
143+
144+
#endif /* H_PHY_HW_ */

0 commit comments

Comments
 (0)