Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/machine/machine_nrf52840.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
8 changes: 8 additions & 0 deletions src/machine/machine_nrf52xxx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -136,6 +138,12 @@ func (a *ADC) Get() uint16 {
adcPin = nrf.SAADC_CH_PSELP_PSELP_AnalogInput6
case 31:
adcPin = nrf.SAADC_CH_PSELP_PSELP_AnalogInput7
case adcVDDHPin:
if Device == "nrf52840" {
adcPin = 0x0D // VDDHDIV5 on the nrf52840
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to define a constant here? Just a nit.

} else {
return 0
}
default:
return 0
}
Expand Down
Loading