-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/esp32_s3_korvo_1
- Loading branch information
Showing
30 changed files
with
2,599 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
#IDF version is less than IDF5.0 | ||
if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_LESS "5.0") | ||
set(SRC_VER "esp32_s3_usb_otg_idf4.c") | ||
set(REQ "") | ||
else() | ||
set(SRC_VER "esp32_s3_usb_otg_idf5.c") | ||
set(REQ esp_adc) | ||
endif() | ||
|
||
idf_component_register( | ||
SRCS "esp32_s3_usb_otg.c" | ||
SRCS "esp32_s3_usb_otg.c" ${SRC_VER} | ||
INCLUDE_DIRS "include" | ||
PRIV_INCLUDE_DIRS "priv_include" | ||
REQUIRES driver | ||
PRIV_REQUIRES fatfs esp_lcd usb esp_adc | ||
REQUIRES driver esp_lcd | ||
PRIV_REQUIRES fatfs usb spiffs ${REQ} | ||
) |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include "esp_err.h" | ||
#include "bsp/esp32_s3_usb_otg.h" | ||
#include "bsp_err_check.h" | ||
#include "driver/adc.h" | ||
#include "esp_adc_cal.h" | ||
|
||
static esp_adc_cal_characteristics_t bsp_adc_chars; | ||
|
||
esp_err_t bsp_adc_initialize(void) | ||
{ | ||
esp_err_t ret = ESP_OK; | ||
BSP_ERROR_CHECK_RETURN_ERR(esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP_FIT)); | ||
esp_adc_cal_characterize(BSP_ADC_UNIT, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_DEFAULT, 0, &bsp_adc_chars); | ||
|
||
/* ADC1 config */ | ||
BSP_ERROR_CHECK_RETURN_ERR(adc1_config_width(ADC_WIDTH_BIT_DEFAULT)); | ||
return ret; | ||
} | ||
|
||
esp_err_t bsp_voltage_init(void) | ||
{ | ||
BSP_ERROR_CHECK_RETURN_ERR(bsp_adc_initialize()); | ||
BSP_ERROR_CHECK_RETURN_ERR(adc1_config_channel_atten(ADC1_CHANNEL_0, ADC_ATTEN_DB_11)); | ||
BSP_ERROR_CHECK_RETURN_ERR(adc1_config_channel_atten(ADC1_CHANNEL_5, ADC_ATTEN_DB_11)); | ||
|
||
return ESP_OK; | ||
} | ||
|
||
int bsp_voltage_battery_get(void) | ||
{ | ||
int voltage, adc_raw; | ||
|
||
adc_raw = adc1_get_raw(ADC1_CHANNEL_5); | ||
voltage = esp_adc_cal_raw_to_voltage(adc_raw, &bsp_adc_chars); | ||
return voltage * BSP_BATTERY_VOLTAGE_DIV; | ||
} | ||
|
||
int bsp_voltage_usb_get(void) | ||
{ | ||
int voltage, adc_raw; | ||
|
||
adc_raw = adc1_get_raw(ADC_CHANNEL_0); | ||
voltage = esp_adc_cal_raw_to_voltage(adc_raw, &bsp_adc_chars); | ||
return voltage * BSP_USB_HOST_VOLTAGE_DIV; | ||
} |
Oops, something went wrong.