Skip to content

Commit 60b37e4

Browse files
cvinayakAnas Nashif
authored andcommitted
Bluetooth: controller: Map debug pins to P3 pin head on nRF5x DK
Updated debug pin mapping so that the outputs are on P3 pin head on all nRF5x Development Kits. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent 7ee9fb5 commit 60b37e4

File tree

2 files changed

+112
-66
lines changed

2 files changed

+112
-66
lines changed

subsys/bluetooth/controller/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ config BT_CTLR_PROFILE_ISR
408408

409409
config BT_CTLR_DEBUG_PINS
410410
bool "Bluetooth Controller Debug Pins"
411+
depends on BOARD_NRF51_PCA10028 || BOARD_NRF52_PCA10040 || BOARD_NRF52840_PCA10056
411412
help
412413
Turn on debug GPIO toggling for the BLE Controller. This is useful
413414
when debugging with a logic analyzer or profiling certain sections of

subsys/bluetooth/controller/hal/nrf5/debug.h

Lines changed: 111 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -8,157 +8,202 @@
88
#ifndef _DEBUG_H_
99
#define _DEBUG_H_
1010

11+
#ifdef CONFIG_BT_CTLR_DEBUG_PINS
12+
#if defined(CONFIG_BOARD_NRF52840_PCA10056)
13+
#define DEBUG_PORT NRF_P1
14+
#define DEBUG_PIN0 BIT(1)
15+
#define DEBUG_PIN1 BIT(2)
16+
#define DEBUG_PIN2 BIT(3)
17+
#define DEBUG_PIN3 BIT(4)
18+
#define DEBUG_PIN4 BIT(5)
19+
#define DEBUG_PIN5 BIT(6)
20+
#define DEBUG_PIN6 BIT(7)
21+
#define DEBUG_PIN7 BIT(8)
22+
#define DEBUG_PIN8 BIT(10)
23+
#define DEBUG_PIN9 BIT(11)
24+
#elif defined(CONFIG_BOARD_NRF52_PCA10040)
25+
#define DEBUG_PORT NRF_GPIO
26+
#define DEBUG_PIN0 BIT(11)
27+
#define DEBUG_PIN1 BIT(12)
28+
#define DEBUG_PIN2 BIT(13)
29+
#define DEBUG_PIN3 BIT(14)
30+
#define DEBUG_PIN4 BIT(15)
31+
#define DEBUG_PIN5 BIT(16)
32+
#define DEBUG_PIN6 BIT(17)
33+
#define DEBUG_PIN7 BIT(18)
34+
#define DEBUG_PIN8 BIT(19)
35+
#define DEBUG_PIN9 BIT(20)
36+
#elif defined(CONFIG_BOARD_NRF51_PCA10028)
37+
#define DEBUG_PORT NRF_GPIO
38+
#define DEBUG_PIN0 BIT(12)
39+
#define DEBUG_PIN1 BIT(13)
40+
#define DEBUG_PIN2 BIT(14)
41+
#define DEBUG_PIN3 BIT(15)
42+
#define DEBUG_PIN4 BIT(16)
43+
#define DEBUG_PIN5 BIT(17)
44+
#define DEBUG_PIN6 BIT(18)
45+
#define DEBUG_PIN7 BIT(19)
46+
#define DEBUG_PIN8 BIT(20)
47+
#define DEBUG_PIN9 BIT(23)
48+
#else
49+
#error BT_CTLR_DEBUG_PINS not supported on this board.
50+
#endif
51+
52+
#define DEBUG_PIN_MASK (DEBUG_PIN0 | DEBUG_PIN1 | DEBUG_PIN2 | DEBUG_PIN3 | \
53+
DEBUG_PIN4 | DEBUG_PIN5 | DEBUG_PIN6 | DEBUG_PIN7 | \
54+
DEBUG_PIN8 | DEBUG_PIN9)
55+
#define DEBUG_CLOSE_MASK (DEBUG_PIN3 | DEBUG_PIN4 | DEBUG_PIN5 | DEBUG_PIN6)
56+
1157
/* below are some interesting macros referenced by controller
1258
* which can be defined to SoC's GPIO toggle to observe/debug the
1359
* controller's runtime behavior.
1460
*/
15-
#ifdef CONFIG_BT_CTLR_DEBUG_PINS
1661
#define DEBUG_INIT() do { \
17-
NRF_GPIO->DIRSET = 0x03FF0000; \
18-
NRF_GPIO->OUTCLR = 0x03FF0000; } \
62+
DEBUG_PORT->DIRSET = DEBUG_PIN_MASK; \
63+
DEBUG_PORT->OUTCLR = DEBUG_PIN_MASK; } \
1964
while (0)
2065

2166
#define DEBUG_CPU_SLEEP(flag) do { \
2267
if (flag) { \
23-
NRF_GPIO->OUTSET = BIT(16); \
24-
NRF_GPIO->OUTCLR = BIT(16); } \
68+
DEBUG_PORT->OUTSET = DEBUG_PIN0; \
69+
DEBUG_PORT->OUTCLR = DEBUG_PIN0; } \
2570
else { \
26-
NRF_GPIO->OUTCLR = BIT(16); \
27-
NRF_GPIO->OUTSET = BIT(16); } \
71+
DEBUG_PORT->OUTCLR = DEBUG_PIN0; \
72+
DEBUG_PORT->OUTSET = DEBUG_PIN0; } \
2873
} while (0)
2974

3075
#define DEBUG_TICKER_ISR(flag) do { \
3176
if (flag) { \
32-
NRF_GPIO->OUTCLR = BIT(17); \
33-
NRF_GPIO->OUTSET = BIT(17); } \
77+
DEBUG_PORT->OUTCLR = DEBUG_PIN1; \
78+
DEBUG_PORT->OUTSET = DEBUG_PIN1; } \
3479
else { \
35-
NRF_GPIO->OUTSET = BIT(17); \
36-
NRF_GPIO->OUTCLR = BIT(17); } \
80+
DEBUG_PORT->OUTSET = DEBUG_PIN1; \
81+
DEBUG_PORT->OUTCLR = DEBUG_PIN1; } \
3782
} while (0)
3883

3984
#define DEBUG_TICKER_TASK(flag) do { \
4085
if (flag) { \
41-
NRF_GPIO->OUTCLR = BIT(17); \
42-
NRF_GPIO->OUTSET = BIT(17); } \
86+
DEBUG_PORT->OUTCLR = DEBUG_PIN1; \
87+
DEBUG_PORT->OUTSET = DEBUG_PIN1; } \
4388
else { \
44-
NRF_GPIO->OUTSET = BIT(17); \
45-
NRF_GPIO->OUTCLR = BIT(17); } \
89+
DEBUG_PORT->OUTSET = DEBUG_PIN1; \
90+
DEBUG_PORT->OUTCLR = DEBUG_PIN1; } \
4691
} while (0)
4792

4893
#define DEBUG_TICKER_JOB(flag) do { \
4994
if (flag) { \
50-
NRF_GPIO->OUTCLR = BIT(18); \
51-
NRF_GPIO->OUTSET = BIT(18); } \
95+
DEBUG_PORT->OUTCLR = DEBUG_PIN2; \
96+
DEBUG_PORT->OUTSET = DEBUG_PIN2; } \
5297
else { \
53-
NRF_GPIO->OUTSET = BIT(18); \
54-
NRF_GPIO->OUTCLR = BIT(18); } \
98+
DEBUG_PORT->OUTSET = DEBUG_PIN2; \
99+
DEBUG_PORT->OUTCLR = DEBUG_PIN2; } \
55100
} while (0)
56101

57102
#define DEBUG_RADIO_ISR(flag) do { \
58103
if (flag) { \
59-
NRF_GPIO->OUTCLR = BIT(23); \
60-
NRF_GPIO->OUTSET = BIT(23); } \
104+
DEBUG_PORT->OUTCLR = DEBUG_PIN7; \
105+
DEBUG_PORT->OUTSET = DEBUG_PIN7; } \
61106
else { \
62-
NRF_GPIO->OUTSET = BIT(23); \
63-
NRF_GPIO->OUTCLR = BIT(23); } \
107+
DEBUG_PORT->OUTSET = DEBUG_PIN7; \
108+
DEBUG_PORT->OUTCLR = DEBUG_PIN7; } \
64109
} while (0)
65110

66111
#define DEBUG_RADIO_XTAL(flag) do { \
67112
if (flag) { \
68-
NRF_GPIO->OUTCLR = BIT(24); \
69-
NRF_GPIO->OUTSET = BIT(24); } \
113+
DEBUG_PORT->OUTCLR = DEBUG_PIN8; \
114+
DEBUG_PORT->OUTSET = DEBUG_PIN8; } \
70115
else { \
71-
NRF_GPIO->OUTSET = BIT(24); \
72-
NRF_GPIO->OUTCLR = BIT(24); } \
116+
DEBUG_PORT->OUTSET = DEBUG_PIN8; \
117+
DEBUG_PORT->OUTCLR = DEBUG_PIN8; } \
73118
} while (0)
74119

75120
#define DEBUG_RADIO_ACTIVE(flag) do { \
76121
if (flag) { \
77-
NRF_GPIO->OUTCLR = BIT(25); \
78-
NRF_GPIO->OUTSET = BIT(25); } \
122+
DEBUG_PORT->OUTCLR = DEBUG_PIN9; \
123+
DEBUG_PORT->OUTSET = DEBUG_PIN9; } \
79124
else { \
80-
NRF_GPIO->OUTSET = BIT(25); \
81-
NRF_GPIO->OUTCLR = BIT(25); } \
125+
DEBUG_PORT->OUTSET = DEBUG_PIN9; \
126+
DEBUG_PORT->OUTCLR = DEBUG_PIN9; } \
82127
} while (0)
83128

84129
#define DEBUG_RADIO_CLOSE(flag) do { \
85130
if (flag) { \
86-
NRF_GPIO->OUTCLR = 0x00000000; \
87-
NRF_GPIO->OUTSET = 0x00000000; } \
131+
DEBUG_PORT->OUTCLR = 0x00000000; \
132+
DEBUG_PORT->OUTSET = 0x00000000; } \
88133
else { \
89-
NRF_GPIO->OUTCLR = 0x00780000; } \
134+
DEBUG_PORT->OUTCLR = DEBUG_CLOSE_MASK; } \
90135
} while (0)
91136

92137
#define DEBUG_RADIO_PREPARE_A(flag) do { \
93138
if (flag) { \
94-
NRF_GPIO->OUTCLR = BIT(19); \
95-
NRF_GPIO->OUTSET = BIT(19); } \
139+
DEBUG_PORT->OUTCLR = DEBUG_PIN3; \
140+
DEBUG_PORT->OUTSET = DEBUG_PIN3; } \
96141
else { \
97-
NRF_GPIO->OUTCLR = BIT(19); \
98-
NRF_GPIO->OUTSET = BIT(19); } \
142+
DEBUG_PORT->OUTCLR = DEBUG_PIN3; \
143+
DEBUG_PORT->OUTSET = DEBUG_PIN3; } \
99144
} while (0)
100145

101146
#define DEBUG_RADIO_START_A(flag) do { \
102147
if (flag) { \
103-
NRF_GPIO->OUTCLR = BIT(19); \
104-
NRF_GPIO->OUTSET = BIT(19); } \
148+
DEBUG_PORT->OUTCLR = DEBUG_PIN3; \
149+
DEBUG_PORT->OUTSET = DEBUG_PIN3; } \
105150
else { \
106-
NRF_GPIO->OUTCLR = BIT(19); \
107-
NRF_GPIO->OUTSET = BIT(19); } \
151+
DEBUG_PORT->OUTCLR = DEBUG_PIN3; \
152+
DEBUG_PORT->OUTSET = DEBUG_PIN3; } \
108153
} while (0)
109154

110155
#define DEBUG_RADIO_PREPARE_S(flag) do { \
111156
if (flag) { \
112-
NRF_GPIO->OUTCLR = BIT(20); \
113-
NRF_GPIO->OUTSET = BIT(20); } \
157+
DEBUG_PORT->OUTCLR = DEBUG_PIN4; \
158+
DEBUG_PORT->OUTSET = DEBUG_PIN4; } \
114159
else { \
115-
NRF_GPIO->OUTCLR = BIT(20); \
116-
NRF_GPIO->OUTSET = BIT(20); } \
160+
DEBUG_PORT->OUTCLR = DEBUG_PIN4; \
161+
DEBUG_PORT->OUTSET = DEBUG_PIN4; } \
117162
} while (0)
118163

119164
#define DEBUG_RADIO_START_S(flag) do { \
120165
if (flag) { \
121-
NRF_GPIO->OUTCLR = BIT(20); \
122-
NRF_GPIO->OUTSET = BIT(20); } \
166+
DEBUG_PORT->OUTCLR = DEBUG_PIN4; \
167+
DEBUG_PORT->OUTSET = DEBUG_PIN4; } \
123168
else { \
124-
NRF_GPIO->OUTCLR = BIT(20); \
125-
NRF_GPIO->OUTSET = BIT(20); } \
169+
DEBUG_PORT->OUTCLR = DEBUG_PIN4; \
170+
DEBUG_PORT->OUTSET = DEBUG_PIN4; } \
126171
} while (0)
127172

128173
#define DEBUG_RADIO_PREPARE_O(flag) do { \
129174
if (flag) { \
130-
NRF_GPIO->OUTCLR = BIT(21); \
131-
NRF_GPIO->OUTSET = BIT(21); } \
175+
DEBUG_PORT->OUTCLR = DEBUG_PIN5; \
176+
DEBUG_PORT->OUTSET = DEBUG_PIN5; } \
132177
else { \
133-
NRF_GPIO->OUTCLR = BIT(21); \
134-
NRF_GPIO->OUTSET = BIT(21); } \
178+
DEBUG_PORT->OUTCLR = DEBUG_PIN5; \
179+
DEBUG_PORT->OUTSET = DEBUG_PIN5; } \
135180
} while (0)
136181

137182
#define DEBUG_RADIO_START_O(flag) do { \
138183
if (flag) { \
139-
NRF_GPIO->OUTCLR = BIT(21); \
140-
NRF_GPIO->OUTSET = BIT(21); } \
184+
DEBUG_PORT->OUTCLR = DEBUG_PIN5; \
185+
DEBUG_PORT->OUTSET = DEBUG_PIN5; } \
141186
else { \
142-
NRF_GPIO->OUTCLR = BIT(21); \
143-
NRF_GPIO->OUTSET = BIT(21); } \
187+
DEBUG_PORT->OUTCLR = DEBUG_PIN5; \
188+
DEBUG_PORT->OUTSET = DEBUG_PIN5; } \
144189
} while (0)
145190

146191
#define DEBUG_RADIO_PREPARE_M(flag) do { \
147192
if (flag) { \
148-
NRF_GPIO->OUTCLR = BIT(22); \
149-
NRF_GPIO->OUTSET = BIT(22); } \
193+
DEBUG_PORT->OUTCLR = DEBUG_PIN6; \
194+
DEBUG_PORT->OUTSET = DEBUG_PIN6; } \
150195
else { \
151-
NRF_GPIO->OUTCLR = BIT(22); \
152-
NRF_GPIO->OUTSET = BIT(22); } \
196+
DEBUG_PORT->OUTCLR = DEBUG_PIN6; \
197+
DEBUG_PORT->OUTSET = DEBUG_PIN6; } \
153198
} while (0)
154199

155200
#define DEBUG_RADIO_START_M(flag) do { \
156201
if (flag) { \
157-
NRF_GPIO->OUTCLR = BIT(22); \
158-
NRF_GPIO->OUTSET = BIT(22); } \
202+
DEBUG_PORT->OUTCLR = DEBUG_PIN6; \
203+
DEBUG_PORT->OUTSET = DEBUG_PIN6; } \
159204
else { \
160-
NRF_GPIO->OUTCLR = BIT(22); \
161-
NRF_GPIO->OUTSET = BIT(22); } \
205+
DEBUG_PORT->OUTCLR = DEBUG_PIN6; \
206+
DEBUG_PORT->OUTSET = DEBUG_PIN6; } \
162207
} while (0)
163208

164209
#else

0 commit comments

Comments
 (0)