Skip to content

Commit 4b609ef

Browse files
committed
Xenon board can tell when it is getting powered through the USB rather than a battery and when a battery is being charged. Added required pins inside variant files and they work as specified:
- When PIN_PWD is HIGH, Xenon is being powered through the USB - When PIN_CHG is LOW, a battery attached to Xenon is being charged Note though that prior to using these pins it is neccessary to specify pinMode(PIN_CHG, INPUT) and pinMode(PIN_PWR, INPUT) due to how they're being implemented in hardware. Using these two pins 3 states of power can be deduced: - hasUsbPower = digitalRead(PIN_PWR); - isCharging = (hasUsbPower && !digitalRead(PIN_CHG)); - onBatteryPower = !hasUsbPower; Added the missing LED1 initialisation. BUTTON_FRESET pin number assignment was fixed.
1 parent d727583 commit 4b609ef

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

variants/particle_xenon/variant.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,42 @@ const uint32_t g_ADigitalPinMap[] =
5252
_PINNUM(0, 11), // P0.11 (MODE)
5353
_PINNUM(0, 18), // P0.18 (RESET)
5454

55+
// D22 .. D24
5556
// LEDS
5657
_PINNUM(0, 13), // P0.13 (RGB_RED)
5758
_PINNUM(0, 14), // P0.14 (RGB_GREEN)
5859
_PINNUM(0, 15), // P0.15 (RGB_BLUE)
5960

61+
// D25 .. D26
6062
// Antenna
6163
_PINNUM(0, 24), // P0.24 (ANTENNA_SWITCH_1 - PCB ANTENNA)
6264
_PINNUM(0, 25), // P0.25 (ANTENNA_SWITCH_2 - EXTERNAL u.FL)
6365

66+
// D27 .. D28
6467
// NFC
6568
_PINNUM(0, 9), // P0.09 (u.FL FOR NFC ANTENNA)
6669
_PINNUM(0, 10), // P0.10 (u.FL FOR NFC ANTENNA)
6770

71+
// D29 .. 36
6872
// Analog Pins A0 .. A7
6973
_PINNUM(0, 3), // P0.03 (A0)
7074
_PINNUM(0, 4), // P0.04 (A1)
71-
_PINNUM(0, 28), // P0.04 (A2)
72-
_PINNUM(0, 29), // P0.04 (A3)
73-
_PINNUM(0, 30), // P0.04 (A4)
74-
_PINNUM(0, 31), // P0.04 (A5)
75-
_PINNUM(0, 5), // P0.04 (BAT_DET/VBAT)
75+
_PINNUM(0, 28), // P0.28 (A2)
76+
_PINNUM(0, 29), // P0.29 (A3)
77+
_PINNUM(0, 30), // P0.30 (A4)
78+
_PINNUM(0, 31), // P0.31 (A5)
79+
_PINNUM(0, 5), // P0.05 (BAT_DET/VBAT)
7680
_PINNUM(0, 2), // P0.02 (AREF)
81+
82+
// D37 .. D38
83+
// Power status
84+
_PINNUM(0, 12), // P0.12 (PWR)
85+
_PINNUM(1, 9), // P1.09 (CHG)
7786
};
7887

7988
void initVariant()
8089
{
90+
// LED1
91+
pinMode(PIN_LED1, OUTPUT);
92+
ledOff(PIN_LED1);
8193
}

variants/particle_xenon/variant.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ extern "C"
3939
#endif // __cplusplus
4040

4141
// Number of pins defined in PinDescription array
42-
#define PINS_COUNT (34)
43-
#define NUM_DIGITAL_PINS (20)
42+
#define PINS_COUNT (39)
43+
#define NUM_DIGITAL_PINS (39)
4444
#define NUM_ANALOG_INPUTS (6) // A6 is used for battery, A7 is analog reference
4545
#define NUM_ANALOG_OUTPUTS (0)
4646

@@ -111,10 +111,10 @@ static const uint8_t LED_RGB_BLUE = (24);
111111
// Buttons
112112
#define BUTTONS_NUMBER 2
113113
#define BUTTON_DFU (20)
114-
#define BUTTON_FRESET (21) // A0
114+
#define BUTTON_FRESET (19) // A0
115115
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
116116

117-
static const uint8_t BUTTON_MODE = (20);
117+
static const uint8_t BUTTON_MODE = BUTTON_DFU;
118118

119119
// Antenna
120120
#define ANTENNA_SWITCH_1 (25)
@@ -150,6 +150,8 @@ static const uint8_t A7 = PIN_A7;
150150
// Other pins
151151
#define PIN_AREF PIN_A7
152152
#define PIN_VBAT PIN_A6
153+
#define PIN_PWR (37)
154+
#define PIN_CHG (38)
153155

154156
static const uint8_t AREF = PIN_AREF;
155157

0 commit comments

Comments
 (0)