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.
This commit is contained in:
Matthew Richardson committed 2024-06-14 10:48:34 -04:00
1 parent 8c8bcf292e
commit d48767476d
2 files changed
+15

No files matched your search

+8
View File
@@ -92,6 +92,14 @@ extern uint32_t analogRead( uint32_t ulPin ) ;
*/
extern uint32_t analogReadVDD( void ) ;
#ifdef SAADC_CH_PSELP_PSELP_VDDHDIV5
/*
* \brief Read the value from the vddh pin with div5.
*
* \return Read value from vddh pin with div5, if no error.
*/
extern uint32_t analogReadVDDHDIV5( void ) ;
#endif
/*
* \brief Set the resolution of analogRead return values. Default is 10 bits (range from 0 to 1023).
+7
View File
@@ -284,6 +284,13 @@ uint32_t analogReadVDD( void )
return analogRead_internal(SAADC_CH_PSELP_PSELP_VDD);
}
#ifdef SAADC_CH_PSELP_PSELP_VDDHDIV5
uint32_t analogReadVDDHDIV5( void )
{
return analogRead_internal(SAADC_CH_PSELP_PSELP_VDDHDIV5);
}
#endif
void analogCalibrateOffset( void )
{
// Enable the SAADC