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() {
2424 enableAltFuncClock (unsafe .Pointer (stm32 .ADC1 ))
2525
2626 // enable
27- stm32 .ADC1 .CR2 .SetBits (stm32 .ADC_CR2_ADON )
27+ stm32 .ADC1 .CR2 .SetBits (stm32 .ADC_CR2_ADON | stm32 . ADC_CR2_ALIGN )
2828
2929 return
3030}
@@ -49,7 +49,7 @@ func (a ADC) Configure(ADCConfig) {
4949func (a ADC ) Get () uint16 {
5050 // set rank
5151 ch := uint32 (a .getChannel ())
52- stm32 .ADC1 .SQR3 . SetBits (ch )
52+ stm32 .ADC1 .SetSQR3_SQ1 (ch )
5353
5454 // start conversion
5555 stm32 .ADC1 .CR2 .SetBits (stm32 .ADC_CR2_ADON )
@@ -59,9 +59,7 @@ func (a ADC) Get() uint16 {
5959 }
6060
6161 // 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 ())
6563}
6664
6765func (a ADC ) getChannel () uint8 {
You can’t perform that action at this time.
0 commit comments