diff --git a/src/machine/machine_nrf52840.go b/src/machine/machine_nrf52840.go index c30933ba4e..c858355fdf 100644 --- a/src/machine/machine_nrf52840.go +++ b/src/machine/machine_nrf52840.go @@ -110,3 +110,7 @@ func eraseBlockSize() int64 { } const spiMaxBufferSize = 0xffff // from the datasheet: TXD.MAXCNT and RXD.MAXCNT + +// ADC instance for the VDDH input pin. This pin is typically connected to USB +// input voltage (~5V) or directly to a battery. +var ADC_VDDH = ADC{adcVDDHPin} diff --git a/src/machine/machine_nrf52xxx.go b/src/machine/machine_nrf52xxx.go index 90a1a7fbf5..6fa267e7bf 100644 --- a/src/machine/machine_nrf52xxx.go +++ b/src/machine/machine_nrf52xxx.go @@ -12,6 +12,8 @@ func CPUFrequency() uint32 { return 64000000 } +var adcVDDHPin = Pin(254) // special pin number for VDDH on the nrf52840 + // InitADC initializes the registers needed for ADC. func InitADC() { // Enable ADC. @@ -26,7 +28,7 @@ func InitADC() { // Samples can be 1(default), 2, 4, 8, 16, 32, 64, 128, 256 samples func (a *ADC) Configure(config ADCConfig) { var configVal uint32 = nrf.SAADC_CH_CONFIG_RESP_Bypass<