Skip to content

Commit 396cffd

Browse files
authored
Merge pull request #127 from runger1101001/dev
Fix for #121 - missing Sensor::init() calls and NRF52 support by Polyphe
2 parents 35ae169 + 28fb9de commit 396cffd

File tree

9 files changed

+373
-5
lines changed

9 files changed

+373
-5
lines changed

src/current_sense/hardware_specific/samd21_mcu.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ float SAMDCurrentSenseADCDMA::toVolts(uint16_t counts) {
137137

138138
void SAMDCurrentSenseADCDMA::initPins(){
139139

140-
pinMode(pinAREF, INPUT);
140+
if (pinAREF>=0)
141+
pinMode(pinAREF, INPUT);
141142
pinMode(pinA, INPUT);
142143
pinMode(pinB, INPUT);
143144

@@ -169,8 +170,10 @@ void SAMDCurrentSenseADCDMA::initADC(){
169170
//ADC->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC0_Val; // 2.2297 V Supply VDDANA
170171
ADC->INPUTCTRL.bit.GAIN = ADC_INPUTCTRL_GAIN_1X_Val; // Gain select as 1X
171172
// ADC->INPUTCTRL.bit.GAIN = ADC_INPUTCTRL_GAIN_DIV2_Val; // default
172-
ADC->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_AREFA;
173-
// ADC->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC0;
173+
if (pinAREF>=0)
174+
ADC->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_AREFA;
175+
else
176+
ADC->REFCTRL.bit.REFSEL = ADC_REFCTRL_REFSEL_INTVCC0;
174177
ADCsync(); // ref 31.6.16
175178

176179
/*

src/current_sense/hardware_specific/samd21_mcu.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#ifndef CURRENT_SENSE_SAMD21_H
44
#define CURRENT_SENSE_SAMD21_H
55

6-
// #define SIMPLEFOC_SAMD_DEBUG
6+
#define SIMPLEFOC_SAMD_DEBUG
77
#if !defined(SIMPLEFOC_SAMD_DEBUG_SERIAL)
88
#define SIMPLEFOC_SAMD_DEBUG_SERIAL Serial
99
#endif
@@ -18,6 +18,8 @@
1818
} dmacdescriptor ;
1919

2020

21+
// AREF pin is 42
22+
2123
class SAMDCurrentSenseADCDMA
2224
{
2325

@@ -64,4 +66,4 @@ class SAMDCurrentSenseADCDMA
6466

6567

6668

67-
#endif
69+
#endif

0 commit comments

Comments
 (0)