Skip to content

Commit d487674

Browse files
committed
Add support for VDDHDIV5
Allow reading the VDDHDIV5 ADC source on devices that support it, such as nRF52840. For designs where the VDDH pin is connected to a battery, this is a great way to measure battery voltage without any additional external components.
1 parent 8c8bcf2 commit d487674

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

cores/nRF5/wiring_analog.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ extern uint32_t analogRead( uint32_t ulPin ) ;
9292
*/
9393
extern uint32_t analogReadVDD( void ) ;
9494

95+
#ifdef SAADC_CH_PSELP_PSELP_VDDHDIV5
96+
/*
97+
* \brief Read the value from the vddh pin with div5.
98+
*
99+
* \return Read value from vddh pin with div5, if no error.
100+
*/
101+
extern uint32_t analogReadVDDHDIV5( void ) ;
102+
#endif
95103

96104
/*
97105
* \brief Set the resolution of analogRead return values. Default is 10 bits (range from 0 to 1023).

cores/nRF5/wiring_analog_nRF52.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,13 @@ uint32_t analogReadVDD( void )
284284
return analogRead_internal(SAADC_CH_PSELP_PSELP_VDD);
285285
}
286286

287+
#ifdef SAADC_CH_PSELP_PSELP_VDDHDIV5
288+
uint32_t analogReadVDDHDIV5( void )
289+
{
290+
return analogRead_internal(SAADC_CH_PSELP_PSELP_VDDHDIV5);
291+
}
292+
#endif
293+
287294
void analogCalibrateOffset( void )
288295
{
289296
// Enable the SAADC

0 commit comments

Comments
 (0)