Skip to content

Commit ac8ca36

Browse files
committed
feat(src/machine/nrf52xxx/adc): move init to init function
Signed-off-by: Paul Schroeder <milkpirate@users.noreply.github.com>
1 parent 5a1b885 commit ac8ca36

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/machine/machine_nrf52xxx.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,17 @@ func CPUFrequency() uint32 {
1414

1515
// InitADC initializes the registers needed for ADC.
1616
func InitADC() {
17-
return // no specific setup on nrf52 machine.
18-
}
19-
20-
// Configure configures an ADC pin to be able to read analog data.
21-
func (a ADC) Configure(config ADCConfig) {
2217
// Enable ADC.
23-
// The ADC does not consume a noticeable amount of current simply by being
24-
// enabled.
18+
// The ADC does not consume a noticeable amount of current by being enabled.
2519
nrf.SAADC.ENABLE.Set(nrf.SAADC_ENABLE_ENABLE_Enabled << nrf.SAADC_ENABLE_ENABLE_Pos)
20+
}
2621

27-
// Use fixed resolution of 12 bits.
28-
// TODO: is it useful for users to change this?
29-
nrf.SAADC.RESOLUTION.Set(nrf.SAADC_RESOLUTION_VAL_12bit)
22+
// Configure configures an ADC pin to be able to read analog data.
23+
// Reference voltage can be 150, 300, 600, 1200, 1800, 2400, 3000(default), 3600 mV
24+
// Resolution can be 8, 10, 12(default), 14 bits
25+
// SampleTime will be ceiled to 3(default), 5, 10, 15, 20 or 40(max) µS respectively
26+
// Samples can be 1(default), 2, 4, 8, 16, 32, 64, 128, 256 samples
27+
func (a *ADC) Configure(config ADCConfig) {
3028

3129
var configVal uint32 = nrf.SAADC_CH_CONFIG_RESP_Bypass<<nrf.SAADC_CH_CONFIG_RESP_Pos |
3230
nrf.SAADC_CH_CONFIG_RESP_Bypass<<nrf.SAADC_CH_CONFIG_RESN_Pos |

0 commit comments

Comments
 (0)