Skip to content

Commit

Permalink
Update ADC bitwidth length and fix I2C driver reconfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperChamp234 committed Feb 1, 2024
1 parent d0f41cc commit b242263
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions include/adc.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "pin_defs.h"

#define ADC_ATTEN ADC_ATTEN_DB_11

#define ADC_BITWIDTH_LEN ADC_BITWIDTH_12

/**
* @brief Structure representing an ADC object.
Expand All @@ -55,7 +55,7 @@ typedef struct
bool do_calib[5]; /**< Array indicating whether calibration should be performed for each channel. */
} adc_obj_t;

typedef adc_obj_t* adc_handle_t;
typedef adc_obj_t *adc_handle_t;

/**
* @brief call function config_adc1() and characterize_adc1().
Expand Down
8 changes: 4 additions & 4 deletions src/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ static const int adc_io[5] = {LSA_A0, LSA_A1, LSA_A2, LSA_A3, LSA_A4};
esp_err_t config_adc1(adc_obj_t *adc_obj)
{
adc_oneshot_chan_cfg_t config = {
.bitwidth = ADC_BITWIDTH_12,
.bitwidth = ADC_BITWIDTH_LEN,
.atten = ADC_ATTEN,
};
//assign channels to each io in adc_io
// Assign channels to each io in adc_io
for (int i = 0; i < sizeof(adc_io) / sizeof(adc_io[0]); i++)
{
adc_channel_t channel;
Expand All @@ -58,7 +58,7 @@ static bool adc_calibration_init(adc_unit_t unit, adc_channel_t channel, adc_att
.unit_id = unit,
.chan = channel,
.atten = atten,
.bitwidth = ADC_BITWIDTH_12,
.bitwidth = ADC_BITWIDTH_LEN,
};
ret = adc_cali_create_scheme_curve_fitting(&cali_config, &handle);
if (ret == ESP_OK) {
Expand All @@ -73,7 +73,7 @@ static bool adc_calibration_init(adc_unit_t unit, adc_channel_t channel, adc_att
adc_cali_line_fitting_config_t cali_config = {
.unit_id = unit,
.atten = atten,
.bitwidth = ADC_BITWIDTH_12,
.bitwidth = ADC_BITWIDTH_LEN,
};
ret = adc_cali_create_scheme_line_fitting(&cali_config, &handle);
if (ret == ESP_OK) {
Expand Down
2 changes: 1 addition & 1 deletion src/i2cdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static esp_err_t i2c_setup_port(const i2c_dev_t *dev)
esp_err_t res;
if (!cfg_equal(&dev->cfg, &states[dev->port].config))
{
ESP_LOGD(TAG, "Reconfiguring I2C driver on port %d", (int)dev->port);
ESP_LOGD(TAG, "Reconfiguring I2C driver on port %d", dev->port);
i2c_config_t temp;
memcpy(&temp, &dev->cfg, sizeof(i2c_config_t));
temp.mode = I2C_MODE_MASTER;
Expand Down

0 comments on commit b242263

Please sign in to comment.