ESPHome 2026.12.0-dev
Loading...
Searching...
No Matches
pcm1863_const.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4
5namespace esphome::pcm1863 {
6
7// PCM1863 page 0 register addresses.
8// Names and layout follow the Texas Instruments PCM186x family register map (SLAS831D).
9static constexpr uint8_t PCM1863_REG_PAGE = 0x00; /* Page selector; writing 0xFE triggers a full reset */
10static constexpr uint8_t PCM1863_REG_PGA_VAL_CH1_L = 0x01; /* ADC1 left PGA gain, 0.5 dB/LSB, two's complement */
11static constexpr uint8_t PCM1863_REG_PGA_VAL_CH1_R = 0x02; /* ADC1 right PGA gain, 0.5 dB/LSB, two's complement */
12static constexpr uint8_t PCM1863_REG_ADC1_INPUT_SEL_L = 0x06;
13static constexpr uint8_t PCM1863_REG_ADC1_INPUT_SEL_R = 0x07;
14static constexpr uint8_t PCM1863_REG_PCM_CFG = 0x0B; /* Word length and serial audio format */
15static constexpr uint8_t PCM1863_REG_POWER_CTRL = 0x70; /* Power down, sleep and standby */
16
17// PCM1863_REG_PAGE: the register holds the page number, and the two documented
18// commands are selecting a page and resetting every register
19static constexpr uint8_t PCM1863_PAGE_0 = 0x00;
20static constexpr uint8_t PCM1863_RESET = 0xFE;
21
22// PCM1863_REG_PCM_CFG: receive word length in bits 7:6, transmit word length in bits 3:2,
23// serial audio format in bits 1:0. Bit 5 is reserved and bit 4 only applies to TDM; both
24// are zero at reset and are written as zero here.
25static constexpr uint8_t PCM1863_PCM_CFG_RX_WLEN_SHIFT = 6;
26static constexpr uint8_t PCM1863_PCM_CFG_TX_WLEN_SHIFT = 2;
27
28static constexpr uint8_t PCM1863_PCM_CFG_FMT_I2S = 0x00;
29
30// PCM1863_REG_ADC1_INPUT_SEL_L / _R
31// Bit 7 selects signal polarity, bit 6 is reserved and must always be written as 1,
32// and bits 5:0 pick the analog input. See the PCM186x datasheet, "MUX, MIX, and
33// Polarity Input Selection".
34static constexpr uint8_t PCM1863_INPUT_SEL_RSV = 0x40; // bit 6, always write 1
35// Bits 5:0 select one input: none, VIN1 to VIN4 single-ended (0x01 to 0x08), then the
36// differential pairs VIN1/VIN2 (0x10) and VIN4/VIN3 (0x20)
37
38// PCM1863_REG_POWER_CTRL
39// Bits 2:0 are power down, sleep and standby; all three are clear in the run state.
40// Bits 7:3 are reserved and the datasheet requires them to always be written as 0b01110,
41// which is also their reset value. Writing them as zero stops the analog section.
42static constexpr uint8_t PCM1863_PWR_CTRL_RSV = 0x70;
43
44// The PGA gain registers hold a two's complement value in 0.5 dB steps,
45// from -24 (-12 dB) to +80 (+40 dB)
46static constexpr float PCM1863_MIC_GAIN_MIN = -12.0f;
47static constexpr float PCM1863_MIC_GAIN_MAX = 40.0f;
48static constexpr float PCM1863_MIC_GAIN_STEP = 0.5f;
49
50} // namespace esphome::pcm1863