Skip to content

Commit e60a286

Browse files
committed
updated pin mappings
1 parent 9b45e27 commit e60a286

File tree

3 files changed

+84
-161
lines changed

3 files changed

+84
-161
lines changed

README.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,6 @@ $ nrfjprog --program feather_nrf52832_bootloader.hex -f nrf52
110110
$ nrfjprog --reset -f nrf52
111111
```
112112

113-
## Particle Xenon Specific
114-
```c++
115-
// Swap between the internal antenna and external u.FL antenna
116-
switchAntenna(bool useExternal);
117-
118-
// Control RGB led / primary LED individually
119-
ledWrite(LED_RGB_RED, 255);
120-
ledWrite(LED_PRIMARY, 127);
121-
122-
// Control RGB leds in one shot
123-
rgbLedWrite(50, 100, 150);
124-
125-
```
126-
127113
## Credits
128114

129115
This core is based on [Arduino-nRF5](https://github.com/sandeepmistry/arduino-nRF5) by Sandeep Mistry,

variants/particle_xenon/variant.cpp

Lines changed: 24 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const uint32_t g_ADigitalPinMap[] =
3737
_PINNUM(1, 26), // P1.12 (PWM0)
3838
_PINNUM(1, 26), // P1.03 (UART2_RTS)
3939

40-
// D9 .. D20
40+
// D9 .. D21
4141
_PINNUM(0, 6), // P0.06 (UART1_TX)
4242
_PINNUM(0, 8), // P0.08 (UART1_RX)
4343
_PINNUM(1, 14), // P1.14 (SPI_MISO)
@@ -51,75 +51,30 @@ const uint32_t g_ADigitalPinMap[] =
5151
_PINNUM(0, 3), // P0.03 (PWM2) (ADC0)
5252
_PINNUM(0, 11), // P0.11 (MODE)
5353
_PINNUM(0, 18), // P0.18 (RESET)
54-
};
55-
56-
void initVariant()
57-
{
58-
switch_antenna(false);
59-
60-
led_pwm_init(LED_PRIMARY_IDX, LED_PRIMARY_PIN);
61-
led_pwm_init(LED_RGB_RED_IDX, LED_RGB_RED_PIN);
62-
led_pwm_init(LED_RGB_BLUE_IDX, LED_RGB_BLUE_PIN);
63-
led_pwm_init(LED_RGB_GREEN_IDX, LED_RGB_GREEN_PIN);
64-
}
6554

66-
void switch_antenna(bool useExternal) {
67-
if (useExternal) {
68-
digitalWrite(ANTENNA_SWITCH_1, LOW);
69-
digitalWrite(ANTENNA_SWITCH_2, HIGH);
70-
}
71-
else {
72-
digitalWrite(ANTENNA_SWITCH_1, HIGH);
73-
digitalWrite(ANTENNA_SWITCH_2, LOW);
74-
}
75-
}
55+
// LEDS
56+
_PINNUM(1, 12), // P1.12 (PRIMARY_LED)
57+
_PINNUM(0, 13), // P0.13 (RGB_RED)
58+
_PINNUM(0, 14), // P0.14 (RGB_GREEN)
59+
_PINNUM(0, 15), // P0.15 (RGB_BLUE)
60+
61+
// Antenna
62+
_PINNUM(0, 24), // P0.24 (ANTENNA_SWITCH_1 - PCB ANTENNA)
63+
_PINNUM(0, 25), // P0.25 (ANTENNA_SWITCH_2 - EXTERNAL u.FL)
64+
65+
// NFC
66+
_PINNUM(0, 9), // P0.09 (u.FL FOR NFC ANTENNA)
67+
_PINNUM(0, 10), // P0.10 (u.FL FOR NFC ANTENNA)
68+
69+
// Analog Pins A0 .. A5
70+
_PINNUM(0, 3), // P0.03 (A0)
71+
_PINNUM(0, 4), // P0.04 (A1)
72+
_PINNUM(0, 28), // P0.04 (A2)
73+
_PINNUM(0, 29), // P0.04 (A3)
74+
_PINNUM(0, 30), // P0.04 (A4)
75+
_PINNUM(0, 31), // P0.04 (A5)
76+
};
7677

7778
void initVariant()
7879
{
79-
switch_antenna(false);
80-
}
81-
82-
void ledWrite(uint32_t led_pin, uint8_t value) {
83-
uint32_t index = -1;
84-
switch (led_pin) {
85-
case LED_PRIMARY_PIN:
86-
index = LED_PRIMARY_IDX;
87-
break;
88-
case LED_RGB_RED_PIN:
89-
index = LED_RGB_RED_IDX;
90-
break;
91-
case LED_RGB_GREEN_PIN:
92-
index = LED_RGB_GREEN_IDX;
93-
break;
94-
case LED_RGB_BLUE_PIN:
95-
index = LED_RGB_BLUE_IDX;
96-
break;
97-
}
98-
99-
if (index != -1)
100-
led_pwm_duty_cycle(index, value);
101-
}
102-
103-
void rgbLedWrite(uint8_t red, uint8_t green, uint8_t blue) {
104-
led_pwm_duty_cycle(LED_RGB_RED_IDX, red);
105-
led_pwm_duty_cycle(LED_RGB_GREEN_IDX, green);
106-
led_pwm_duty_cycle(LED_RGB_BLUE_IDX, blue);
107-
}
108-
109-
void pwm_teardown(NRF_PWM_Type* pwm) {
110-
pwm->TASKS_SEQSTART[0] = 0;
111-
pwm->ENABLE = 0;
112-
113-
pwm->PSEL.OUT[0] = 0xFFFFFFFF;
114-
pwm->PSEL.OUT[1] = 0xFFFFFFFF;
115-
pwm->PSEL.OUT[2] = 0xFFFFFFFF;
116-
pwm->PSEL.OUT[3] = 0xFFFFFFFF;
117-
118-
pwm->MODE = 0;
119-
pwm->COUNTERTOP = 0x3FF;
120-
pwm->PRESCALER = 0;
121-
pwm->DECODER = 0;
122-
pwm->LOOP = 0;
123-
pwm->SEQ[0].PTR = 0;
124-
pwm->SEQ[0].CNT = 0;
125-
}
80+
}

variants/particle_xenon/variant.h

Lines changed: 60 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define _VARIANT_PARTICLE_XENON_
2121

2222
#define _PINNUM(port, pin) ((port)*32 + (pin))
23+
#define NRF52
2324

2425
/** Master clock frequency */
2526
#define VARIANT_MCK (64000000ul)
@@ -69,98 +70,91 @@ extern "C"
6970
#define PIN_D19 _PINNUM(0, 3)
7071
#define PIN_D20 _PINNUM(0, 11)
7172

72-
static const uint8_t D0 = PIN_D0;
73-
static const uint8_t D1 = PIN_D1;
74-
static const uint8_t D2 = PIN_D2;
75-
static const uint8_t D3 = PIN_D4;
76-
static const uint8_t D5 = PIN_D5;
77-
static const uint8_t D6 = PIN_D6;
78-
static const uint8_t D7 = PIN_D7;
79-
static const uint8_t D8 = PIN_D8;
80-
static const uint8_t D9 = PIN_D9;
81-
static const uint8_t D10 = PIN_D10;
82-
static const uint8_t D11 = PIN_D11;
83-
static const uint8_t D12 = PIN_D12;
84-
static const uint8_t D13 = PIN_D13;
85-
static const uint8_t D14 = PIN_D14;
86-
static const uint8_t D15 = PIN_D15;
87-
static const uint8_t D16 = PIN_D16;
88-
static const uint8_t D17 = PIN_D17;
89-
static const uint8_t D18 = PIN_D18;
90-
static const uint8_t D19 = PIN_D19;
91-
static const uint8_t D20 = PIN_D20;
73+
static const uint8_t D0 = (0);
74+
static const uint8_t D1 = (1);
75+
static const uint8_t D2 = (2);
76+
static const uint8_t D3 = (3);
77+
static const uint8_t D4 = (4);
78+
static const uint8_t D5 = (5);
79+
static const uint8_t D6 = (6);
80+
static const uint8_t D7 = (7);
81+
static const uint8_t D8 = (8);
82+
static const uint8_t D9 = (9);
83+
static const uint8_t D10 = (10);
84+
static const uint8_t D11 = (11);
85+
static const uint8_t D12 = (12);
86+
static const uint8_t D13 = (13);
87+
static const uint8_t D14 = (14);
88+
static const uint8_t D15 = (15);
89+
static const uint8_t D16 = (16);
90+
static const uint8_t D17 = (17);
91+
static const uint8_t D18 = (18);
92+
static const uint8_t D19 = (19);
93+
static const uint8_t D20 = (20);
9294

9395
// LEDs
9496
#define LEDS_NUMBER 1
95-
#define LED_PRIMARY_PIN _PINNUM(1, 12)
9697
#define LED_STATE_ON 1
97-
#define LED_PRIMARY_IDX 0
98-
#define LED_RGB_RED_IDX 1
99-
#define LED_RGB_GREEN_IDX 2
100-
#define LED_RGB_BLUE_IDX 3
101-
102-
#define LED_RGB_RED_PIN _PINNUM(0, 13)
103-
#define LED_RGB_GREEN_PIN _PINNUM(0, 14)
104-
#define LED_RGB_BLUE_PIN _PINNUM(0, 15)
98+
10599
#define BOARD_RGB_BRIGHTNESS 0x202020
106100

107-
static const uint8_t LED_BUILTIN = LED_PRIMARY_PIN;
108-
static const uint8_t LED_RGB_RED = LED_RGB_RED_PIN;
109-
static const uint8_t LED_RGB_GREEN = LED_RGB_GREEN_PIN;
110-
static const uint8_t LED_RGB_BLUE = LED_RGB_BLUE_PIN;
101+
static const uint8_t LED_BUILTIN = (22);
102+
static const uint8_t LED_RGB_RED = (23);
103+
static const uint8_t LED_RGB_GREEN = (24);
104+
static const uint8_t LED_RGB_BLUE = (25);
111105

112106
// Buttons
113107
#define BUTTONS_NUMBER 2
114-
#define BUTTON_DFU _PINNUM(0, 11)
115-
#define BUTTON_FRESET _PINNUM(0, 03) // A0
108+
#define BUTTON_DFU (20)
109+
#define BUTTON_FRESET (21) // A0
116110
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
117111

118-
static const uint8_t BUTTON_MODE = PIN_D20;
112+
static const uint8_t BUTTON_MODE = (20);
119113

120114
// Antenna
121-
#define ANTENNA_SWITCH_1 _PINNUM(0, 24)
122-
#define ANTENNA_SWITCH_2 _PINNUM(0, 25)
115+
#define ANTENNA_SWITCH_1 (26)
116+
#define ANTENNA_SWITCH_2 (27)
123117

124118
// NFC
125-
#define NFC1 _PINNUM(0, 9)
126-
#define NFC2 _PINNUM(0, 10)
119+
#define NFC1 (28)
120+
#define NFC2 (29)
127121

128122
/*
129123
* Analog pins
130124
*/
131-
#define PIN_A0 _PINNUM(0, 3)
132-
#define PIN_A1 _PINNUM(0, 4)
133-
#define PIN_A2 _PINNUM(0, 28)
134-
#define PIN_A3 _PINNUM(0, 29)
135-
#define PIN_A4 _PINNUM(0, 30)
136-
#define PIN_A5 _PINNUM(0, 31)
137-
138-
static const uint8_t A0 = PIN_A0 ;
139-
static const uint8_t A1 = PIN_A1 ;
140-
static const uint8_t A2 = PIN_A2 ;
141-
static const uint8_t A3 = PIN_A3 ;
142-
static const uint8_t A4 = PIN_A4 ;
143-
static const uint8_t A5 = PIN_A5 ;
125+
#define PIN_A0 (30)
126+
#define PIN_A1 (31)
127+
#define PIN_A2 (32)
128+
#define PIN_A3 (33)
129+
#define PIN_A4 (34)
130+
#define PIN_A5 (35)
131+
132+
static const uint8_t A0 = PIN_A0;
133+
static const uint8_t A1 = PIN_A1;
134+
static const uint8_t A2 = PIN_A2;
135+
static const uint8_t A3 = PIN_A3;
136+
static const uint8_t A4 = PIN_A4;
137+
static const uint8_t A5 = PIN_A5;
144138
#define ADC_RESOLUTION 14
145139

146140
/*
147141
* Serial interfaces
148142
*/
149-
#define PIN_SERIAL1_RX PIN_D9
150-
#define PIN_SERIAL1_TX PIN_D10
143+
#define PIN_SERIAL_RX PIN_D9
144+
#define PIN_SERIAL_TX PIN_D10
151145

152146
/*
153147
* SPI Interfaces
154148
*/
155149
#define SPI_INTERFACES_COUNT 2
156150

157-
#define PIN_SPI_SS PIN_A0
158-
#define PIN_SPI_MISO _PINNUM(1, 14)
159-
#define PIN_SPI_MOSI _PINNUM(1, 13)
160-
#define PIN_SPI_SCK _PINNUM(1, 15)
161-
#define PIN_SPI1_MISO _PINNUM(1, 8)
162-
#define PIN_SPI1_MOSI _PINNUM(1, 2)
163-
#define PIN_SPI1_SCK _PINNUM(1, 1)
151+
#define PIN_SPI_SS PIN_A0
152+
#define PIN_SPI_MISO _PINNUM(1, 14)
153+
#define PIN_SPI_MOSI _PINNUM(1, 13)
154+
#define PIN_SPI_SCK _PINNUM(1, 15)
155+
#define PIN_SPI1_MISO _PINNUM(1, 8)
156+
#define PIN_SPI1_MOSI _PINNUM(1, 2)
157+
#define PIN_SPI1_SCK _PINNUM(1, 1)
164158

165159
static const uint8_t SS = PIN_SPI_SS;
166160
static const uint8_t MOSI = PIN_SPI_MOSI;
@@ -175,10 +169,10 @@ static const uint8_t SCK1 = PIN_SPI1_SCK;
175169
*/
176170
#define WIRE_INTERFACES_COUNT 2
177171

178-
#define PIN_WIRE_SDA _PINNUM(0, 26)
179-
#define PIN_WIRE_SCL _PINNUM(0, 27)
180-
#define PIN_WIRE1_SDA _PINNUM(1, 1)
181-
#define PIN_WIRE1_SCL _PINNUM(1, 2)
172+
#define PIN_WIRE_SDA _PINNUM(0, 26)
173+
#define PIN_WIRE_SCL _PINNUM(0, 27)
174+
#define PIN_WIRE1_SDA _PINNUM(1, 1)
175+
#define PIN_WIRE1_SCL _PINNUM(1, 2)
182176

183177
// On-board QSPI Flash
184178
#define EXTERNAL_FLASH_DEVICES GD25Q16C
@@ -188,18 +182,6 @@ static const uint8_t SCK1 = PIN_SPI1_SCK;
188182

189183
#define EXTERNAL_FLASH_USE_QSPI
190184

191-
static void switch_antenna(bool useExternal);
192-
193-
// led pwm
194-
void led_pwm_init(uint32_t led_index, uint32_t led_pin);
195-
void led_pwm_teardown(void);
196-
void led_pwm_duty_cycle(uint32_t led_index, uint16_t duty_cycle);
197-
void pwm_teardown(NRF_PWM_Type* pwm);
198-
void ledWrite(uint32_t led_pin, uint8_t value);
199-
void rgbLedWrite(uint8_t red, uint8_t green, uint8_t blue);
200-
static uint16_t led_duty_cycles[PWM0_CH_NUM] = { 0 };
201-
202-
203185
#ifdef __cplusplus
204186
}
205187
#endif

0 commit comments

Comments
 (0)