13
13
*
14
14
* This program is distributed in the hope that it will be useful,
15
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
+ * See the GNU General Public License for more details.
18
18
*
19
19
* You should have received a copy of the GNU General Public License
20
20
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
24
24
#ifndef _ADC_UTILS_H
25
25
#define _ADC_UTILS_H
26
26
27
- #if defined(__AVR__ ) && (!defined(__AVR_ATmega4809__ ))
28
27
#include <Arduino.h>
29
- #if defined(ADATE )
28
+
29
+ #if defined(__AVR__ ) && defined(ADCSRA ) && defined(ADATE ) && (!defined(__AVR_ATmega4809__ ))
30
+ #define ADC_UTILS_ARE_AVAILABLE
30
31
31
32
// PRESCALE4 => 13 * 4 = 52 microseconds per ADC conversion at 1 MHz Clock => 19,2 kHz
32
33
#define ADC_PRESCALE2 1 // 26 microseconds per ADC conversion at 1 MHz
111
112
#error "No temperature channel definitions specified for this AVR CPU"
112
113
#endif
113
114
115
+ extern float sVCCVoltage ;
116
+ extern uint16_t sVCCVoltageMillivolt ;
117
+
118
+ extern long sLastVoltageCheckMillis ;
119
+ extern uint8_t sVoltageTooLowCounter ;
120
+
114
121
uint16_t readADCChannel (uint8_t aChannelNumber );
115
122
uint16_t readADCChannelWithReference (uint8_t aChannelNumber , uint8_t aReference );
116
123
uint16_t waitAndReadADCChannelWithReference (uint8_t aChannelNumber , uint8_t aReference );
@@ -127,19 +134,30 @@ uint16_t readUntil4ConsecutiveValuesAreEqual(uint8_t aChannelNumber, uint8_t aDe
127
134
128
135
uint8_t checkAndWaitForReferenceAndChannelToSwitch (uint8_t aChannelNumber , uint8_t aReference );
129
136
130
- float getVCCVoltageSimple (void );
131
- uint16_t getVCCVoltageMillivoltSimple (void );
132
- float getTemperatureSimple (void );
133
- float getVCCVoltage (void );
134
- uint16_t getVCCVoltageMillivolt (void );
135
- uint16_t getVCCVoltageReadingFor1_1VoltReference (void );
137
+ /*
138
+ * readVCC*() functions store the result in sVCCVoltageMillivolt or sVCCVoltage
139
+ */
140
+ float getVCCVoltageSimple ();
141
+ void readVCCVoltageSimple ();
142
+ uint16_t getVCCVoltageMillivoltSimple ();
143
+ void readVCCVoltageMillivoltSimple ();
144
+ float getVCCVoltage ();
145
+ void readVCCVoltage ();
146
+ uint16_t getVCCVoltageMillivolt ();
147
+ void readVCCVoltageMillivolt ();
148
+ uint16_t getVCCVoltageReadingFor1_1VoltReference ();
136
149
uint16_t printVCCVoltageMillivolt (Print * aSerial );
137
- void printVCCVoltageMillivolt (Print * aSerial , uint16_t aVCCVoltageMillivolt );
150
+ void readAndPrintVCCVoltageMillivolt (Print * aSerial );
151
+
138
152
uint16_t getVoltageMillivolt (uint16_t aVCCVoltageMillivolt , uint8_t aADCChannelForVoltageMeasurement );
139
153
uint16_t getVoltageMillivolt (uint8_t aADCChannelForVoltageMeasurement );
140
154
uint16_t getVoltageMillivoltWith_1_1VoltReference (uint8_t aADCChannelForVoltageMeasurement );
141
- float getTemperature (void );
155
+ float getTemperatureSimple ();
156
+ float getTemperature ();
157
+
158
+ bool isVCCTooLowMultipleTimes ();
159
+ void resetVCCTooLowMultipleTimes ();
160
+ bool isVoltageTooLow ();
142
161
143
- #endif // defined(ADATE)
144
- #endif // defined(__AVR__)
162
+ #endif // defined(__AVR__) ...
145
163
#endif // _ADC_UTILS_H
0 commit comments