@@ -14,19 +14,17 @@ func CPUFrequency() uint32 {
14
14
15
15
// InitADC initializes the registers needed for ADC.
16
16
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 ) {
22
17
// 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.
25
19
nrf .SAADC .ENABLE .Set (nrf .SAADC_ENABLE_ENABLE_Enabled << nrf .SAADC_ENABLE_ENABLE_Pos )
20
+ }
26
21
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 ) {
30
28
31
29
var configVal uint32 = nrf .SAADC_CH_CONFIG_RESP_Bypass << nrf .SAADC_CH_CONFIG_RESP_Pos |
32
30
nrf .SAADC_CH_CONFIG_RESP_Bypass << nrf .SAADC_CH_CONFIG_RESN_Pos |
0 commit comments