diff --git a/include/adc.h b/include/adc.h index a4c2538..622356a 100644 --- a/include/adc.h +++ b/include/adc.h @@ -27,7 +27,6 @@ #include #include -#include #include "esp_adc/adc_oneshot.h" #include "esp_adc/adc_cali.h" @@ -43,12 +42,17 @@ #define ADC_ATTEN ADC_ATTEN_DB_11 -//define a struct that holds the adc1 handle and calibration handles for five channels in an array + +/** + * @brief Structure representing an ADC object. + * + * This structure holds the handles and calibration data for an ADC. + */ typedef struct { - adc_oneshot_unit_handle_t adc1_handle; - adc_cali_handle_t adc1_cali_handle[5]; - bool do_calib[5]; + adc_oneshot_unit_handle_t adc1_handle; /**< Handle for ADC1 oneshot unit. */ + adc_cali_handle_t adc1_cali_handle[5]; /**< Array of calibration handles for ADC1. */ + bool do_calib[5]; /**< Array indicating whether calibration should be performed for each channel. */ } adc_obj_t; typedef adc_obj_t* adc_handle_t; @@ -60,6 +64,13 @@ typedef adc_obj_t* adc_handle_t; **/ esp_err_t enable_adc1(adc_obj_t** adc_obj); +/** + * @brief Reads the adc value from the GPIO(channel) specified. + * + * @param adc_handle_t adc_handle - pointer to adc object. + * @param int gpio - gpio pin number of the channel to be read. + * @return int - returns the adc value read from the channel. + **/ int read_adc(adc_handle_t adc_handle, int gpio); #endif diff --git a/include/sra_board.h b/include/sra_board.h index 6101a02..44a28d1 100644 --- a/include/sra_board.h +++ b/include/sra_board.h @@ -39,4 +39,4 @@ #include "oled.h" #endif -#endif +#endif \ No newline at end of file diff --git a/src/adc.c b/src/adc.c index 97f0101..00c3df6 100644 --- a/src/adc.c +++ b/src/adc.c @@ -33,7 +33,6 @@ esp_err_t config_adc1(adc_obj_t *adc_obj) .bitwidth = ADC_BITWIDTH_12, .atten = ADC_ATTEN, }; - ESP_LOGI(TAG, "ADC1 handle address: %p", adc_obj->adc1_handle); //assign channels to each io in adc_io for (int i = 0; i < sizeof(adc_io) / sizeof(adc_io[0]); i++) { @@ -116,10 +115,8 @@ esp_err_t enable_adc1(adc_obj_t** adc_obj) .unit_id = ADC_UNIT_1, }; ESP_ERROR_CHECK(adc_oneshot_new_unit(&init_config1, &ret->adc1_handle)); - ESP_LOGI(TAG, "Handle address: %p", ret->adc1_handle); config_adc1(ret); calib_init(ret); - //assign return value to adc_handle *adc_obj = ret; return ESP_OK;