File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ func InitADC() {
24
24
enableAltFuncClock (unsafe .Pointer (stm32 .ADC1 ))
25
25
26
26
// enable
27
- stm32 .ADC1 .CR2 .SetBits (stm32 .ADC_CR2_ADON )
27
+ stm32 .ADC1 .CR2 .SetBits (stm32 .ADC_CR2_ADON | stm32 . ADC_CR2_ALIGN )
28
28
29
29
return
30
30
}
@@ -49,7 +49,7 @@ func (a ADC) Configure(ADCConfig) {
49
49
func (a ADC ) Get () uint16 {
50
50
// set rank
51
51
ch := uint32 (a .getChannel ())
52
- stm32 .ADC1 .SQR3 . SetBits (ch )
52
+ stm32 .ADC1 .SetSQR3_SQ1 (ch )
53
53
54
54
// start conversion
55
55
stm32 .ADC1 .CR2 .SetBits (stm32 .ADC_CR2_ADON )
@@ -59,9 +59,7 @@ func (a ADC) Get() uint16 {
59
59
}
60
60
61
61
// read result as 16 bit value
62
- result := uint16 (stm32 .ADC1 .DR .Get ()) << 4
63
-
64
- return result
62
+ return uint16 (stm32 .ADC1 .DR .Get ())
65
63
}
66
64
67
65
func (a ADC ) getChannel () uint8 {
You can’t perform that action at this time.
0 commit comments