TB2026-YDS Firmware
Loading...
Searching...
No Matches
adc.c File Reference
#include "adc.h"
#include "board_pins.h"
#include "esp_adc/adc_cali.h"
#include "esp_adc/adc_cali_scheme.h"
#include <math.h>

Macros

#define POT_MV_MIN   (147)
#define POT_MV_MAX   (2518)
#define POT_INVERTED   (0)
#define POT_SAMPLES   (16)
#define POT_ATTEN   ADC_ATTEN_DB_12
#define POT_BITWIDTH   ADC_BITWIDTH_DEFAULT
#define DAC_REG0_DB   (24.0f)
#define DAC_DB_PER_STEP   (0.5f)
#define DAC_MAX_DB   (0.0f)
#define POT_FLOOR_DB   (-60.0f)

Functions

esp_err_t adc_pot_init (adc_oneshot_unit_handle_t *out_handle)
 Bring up ADC1 for the volume potentiometer (GPIO36) with line-fitting calibration.
esp_err_t adc_pot_read (adc_oneshot_unit_handle_t handle, int *out_mv)
 Read the averaged, calibrated wiper voltage.
uint8_t adc_pot_to_volume (int mv)
 Map a wiper voltage to a PCM5242 digital-volume register byte.
uint8_t adc_pot_to_avrcp_volume (int mv)
 Map a wiper voltage to an AVRCP absolute-volume value (0..0x7F) for a Bluetooth sink.
uint8_t adc_frac_to_volume (float frac)
 Map a 0..1 volume fraction directly to a PCM5242 register byte, bypassing the pot.
uint8_t adc_frac_to_avrcp_volume (float frac)
 Map a 0..1 volume fraction directly to an AVRCP absolute-volume value, bypassing the pot.

Detailed Description

Note
Développé avec l'assistance de Claude Opus 4.8 (Anthropic), sous la direction de Y. Dos Santos : spécification, revue et validation sur cible par l'auteur.

Macro Definition Documentation

◆ DAC_DB_PER_STEP

#define DAC_DB_PER_STEP   (0.5f)

◆ DAC_MAX_DB

#define DAC_MAX_DB   (0.0f)

◆ DAC_REG0_DB

#define DAC_REG0_DB   (24.0f)

◆ POT_ATTEN

#define POT_ATTEN   ADC_ATTEN_DB_12

◆ POT_BITWIDTH

#define POT_BITWIDTH   ADC_BITWIDTH_DEFAULT

◆ POT_FLOOR_DB

#define POT_FLOOR_DB   (-60.0f)

◆ POT_INVERTED

#define POT_INVERTED   (0)

◆ POT_MV_MAX

#define POT_MV_MAX   (2518)

◆ POT_MV_MIN

#define POT_MV_MIN   (147)

◆ POT_SAMPLES

#define POT_SAMPLES   (16)