-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ESP32-C6: battery voltage (ADC) feature
- Loading branch information
Showing
3 changed files
with
29 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
#ifndef _BATTERY_H | ||
#define _BATTERY_H | ||
|
||
uint16_t read_voltage(void); | ||
|
||
#if defined(CONFIG_IDF_TARGET_ESP32C6) | ||
/* TBD */ | ||
typedef unsigned int adc1_channel_t; | ||
typedef unsigned int adc_atten_t; | ||
#define ADC_ATTEN_DB_11 0 | ||
void calibrate_voltage(uint8_t, adc_attenuation_t atten = ADC_11db); | ||
#else | ||
#include <driver/adc.h> | ||
#include <esp_adc_cal.h> | ||
|
||
void calibrate_voltage(adc1_channel_t, adc_atten_t atten = ADC_ATTEN_DB_11); | ||
#endif /* CONFIG_IDF_TARGET_ESP32C6 */ | ||
|
||
#define DEFAULT_VREF 1100 // tbd: use adc2_vref_to_gpio() for better estimate | ||
#define NO_OF_SAMPLES 32 // we do some multisampling to get better values | ||
|
||
uint16_t read_voltage(void); | ||
void calibrate_voltage(adc1_channel_t, adc_atten_t atten = ADC_ATTEN_DB_11); | ||
|
||
#endif | ||
#endif /* _BATTERY_H */ |