File tree Expand file tree Collapse file tree 6 files changed +10
-11
lines changed
libraries/Bluefruit52Lib/examples/Hardware/adc_vbat Expand file tree Collapse file tree 6 files changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -107,7 +107,6 @@ PIN_A6 LITERAL1
107107PIN_A7 LITERAL1
108108
109109PIN_AREF LITERAL1
110- PIN_DFU LITERAL1
111110PIN_NFC1 LITERAL1
112111PIN_NFC2 LITERAL1
113112
Original file line number Diff line number Diff line change 1+ #include < Arduino.h>
2+
3+ uint32_t vbat_pin = PIN_VBAT; // A7 for feather nRF52832, A6 for nRF52840
14
25#define VBAT_MV_PER_LSB (0 .73242188F ) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
36
47#ifdef NRF52840_XXAA // if this is for nrf52840
5- #define VBAT_PIN (A6)
6- #define VBAT_DIVIDER (0 .5F ) // 150K + 150K voltage divider on VBAT
8+ #define VBAT_DIVIDER (0 .5F ) // 150K + 150K voltage divider on VBAT
79#define VBAT_DIVIDER_COMP (2 .0F ) // Compensation factor for the VBAT divider
810#else
9- #define VBAT_PIN (A7)
1011#define VBAT_DIVIDER (0 .71275837F ) // 2M + 0.806M voltage divider on VBAT = (2M / (0.806M + 2M))
1112#define VBAT_DIVIDER_COMP (1 .403F ) // Compensation factor for the VBAT divider
1213#endif
@@ -27,7 +28,7 @@ float readVBAT(void) {
2728 delay (1 );
2829
2930 // Get the raw 12-bit, 0..3000mV ADC value
30- raw = analogRead (VBAT_PIN );
31+ raw = analogRead (vbat_pin );
3132
3233 // Set the ADC back to the default settings
3334 analogReference (AR_DEFAULT);
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ static const uint8_t A7 = PIN_A7 ;
7878
7979// Other pins
8080#define PIN_AREF (24)
81- #define PIN_DFU (20)
81+ #define PIN_VBAT PIN_A7
8282#define PIN_NFC1 (9)
8383#define PIN_NFC2 (10)
8484
Original file line number Diff line number Diff line change @@ -86,8 +86,8 @@ static const uint8_t A7 = PIN_A7 ;
8686#define ADC_RESOLUTION 14
8787
8888// Other pins
89- #define PIN_AREF ( PIN_A7)
90- #define PIN_DFU (7)
89+ #define PIN_AREF PIN_A7
90+ #define PIN_VBAT PIN_A6
9191#define PIN_NFC1 (33)
9292#define PIN_NFC2 (2)
9393
Original file line number Diff line number Diff line change @@ -86,8 +86,8 @@ static const uint8_t A7 = PIN_A7 ;
8686#define ADC_RESOLUTION 14
8787
8888// Other pins
89- #define PIN_AREF ( PIN_A7)
90- #define PIN_DFU (7)
89+ #define PIN_AREF PIN_A7
90+ #define PIN_VBAT PIN_A6
9191#define PIN_NFC1 (2)
9292#define PIN_NFC2 (51)
9393
Original file line number Diff line number Diff line change @@ -78,7 +78,6 @@ static const uint8_t A7 = PIN_A7 ;
7878
7979// Other pins
8080#define PIN_AREF (2)
81- #define PIN_DFU (11)
8281#define PIN_NFC1 (9)
8382#define PIN_NFC2 (10)
8483
You can’t perform that action at this time.
0 commit comments