parent
efd5392f6c
commit
3726fb750a
@ -0,0 +1,5 @@ |
|||||||
|
--- |
||||||
|
BasedOnStyle: Chromium |
||||||
|
UseTab: Never |
||||||
|
|
||||||
|
... |
@ -1,5 +1,12 @@ |
|||||||
idf_component_register( |
idf_component_register(SRCS |
||||||
SRCS "gay-ipod-fw.cpp" "dac.cpp" "gpio-expander.cpp" "battery.cpp" "storage.cpp" "i2c.cpp" |
"gay-ipod-fw.cpp" |
||||||
INCLUDE_DIRS "." |
"dac.cpp" |
||||||
REQUIRES "esp_adc_cal" "fatfs" "audio_pipeline" "audio_stream" "result" |
"gpio-expander.cpp" |
||||||
) |
"battery.cpp" |
||||||
|
"storage.cpp" |
||||||
|
"i2c.cpp" INCLUDE_DIRS "." REQUIRES |
||||||
|
"esp_adc_cal" |
||||||
|
"fatfs" |
||||||
|
"audio_pipeline" |
||||||
|
"audio_stream" |
||||||
|
"result") |
||||||
|
@ -1,72 +1,72 @@ |
|||||||
#pragma once |
#pragma once |
||||||
|
|
||||||
#include "esp_err.h" |
|
||||||
#include "gpio-expander.h" |
|
||||||
#include <stdint.h> |
#include <stdint.h> |
||||||
#include <functional> |
#include <functional> |
||||||
|
#include "esp_err.h" |
||||||
|
#include "gpio-expander.h" |
||||||
|
|
||||||
namespace gay_ipod { |
namespace gay_ipod { |
||||||
|
|
||||||
static const uint8_t kPCM5122Address = 0x4C; |
static const uint8_t kPCM5122Address = 0x4C; |
||||||
static const uint8_t kPCM5122Timeout = 100 / portTICK_RATE_MS; |
static const uint8_t kPCM5122Timeout = 100 / portTICK_RATE_MS; |
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for a PCM5122PWR DAC, configured over I2C. |
* Interface for a PCM5122PWR DAC, configured over I2C. |
||||||
*/ |
*/ |
||||||
class AudioDac { |
class AudioDac { |
||||||
public: |
public: |
||||||
AudioDac(GpioExpander *gpio); |
AudioDac(GpioExpander* gpio); |
||||||
~AudioDac(); |
~AudioDac(); |
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs initial configuration of the DAC and sets it to begin expecting |
* Performs initial configuration of the DAC and sets it to begin expecting |
||||||
* I2S audio data. |
* I2S audio data. |
||||||
*/ |
*/ |
||||||
esp_err_t Start(); |
esp_err_t Start(); |
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the volume on a scale from 0 (loudest) to 254 (quietest). A value of |
* Sets the volume on a scale from 0 (loudest) to 254 (quietest). A value of |
||||||
* 255 engages the soft mute function. |
* 255 engages the soft mute function. |
||||||
*/ |
*/ |
||||||
void WriteVolume(uint8_t volume); |
void WriteVolume(uint8_t volume); |
||||||
|
|
||||||
enum PowerState { |
enum PowerState { |
||||||
POWERDOWN = 0b0, |
POWERDOWN = 0b0, |
||||||
WAIT_FOR_CP = 0b1, |
WAIT_FOR_CP = 0b1, |
||||||
CALIBRATION_1 = 0b10, |
CALIBRATION_1 = 0b10, |
||||||
CALIBRATION_2 = 0b11, |
CALIBRATION_2 = 0b11, |
||||||
RAMP_UP = 0b100, |
RAMP_UP = 0b100, |
||||||
RUN = 0b101, |
RUN = 0b101, |
||||||
SHORT = 0b110, |
SHORT = 0b110, |
||||||
RAMP_DOWN = 0b111, |
RAMP_DOWN = 0b111, |
||||||
STANDBY = 0b1000, |
STANDBY = 0b1000, |
||||||
}; |
}; |
||||||
|
|
||||||
/* Returns the current boot-up status and internal state of the DAC */ |
/* Returns the current boot-up status and internal state of the DAC */ |
||||||
std::pair<bool,PowerState> ReadPowerState(); |
std::pair<bool, PowerState> ReadPowerState(); |
||||||
|
|
||||||
// Not copyable or movable.
|
// Not copyable or movable.
|
||||||
AudioDac(const AudioDac&) = delete; |
AudioDac(const AudioDac&) = delete; |
||||||
AudioDac& operator=(const AudioDac&) = delete; |
AudioDac& operator=(const AudioDac&) = delete; |
||||||
|
|
||||||
private: |
private: |
||||||
GpioExpander *gpio_; |
GpioExpander* gpio_; |
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pools the power state for up to 10ms, waiting for the given predicate to |
* Pools the power state for up to 10ms, waiting for the given predicate to |
||||||
* be true. |
* be true. |
||||||
*/ |
*/ |
||||||
bool WaitForPowerState(std::function<bool(bool,PowerState)> predicate); |
bool WaitForPowerState(std::function<bool(bool, PowerState)> predicate); |
||||||
|
|
||||||
enum Register { |
enum Register { |
||||||
PAGE_SELECT = 0,
|
PAGE_SELECT = 0, |
||||||
DE_EMPHASIS = 7, |
DE_EMPHASIS = 7, |
||||||
DIGITAL_VOLUME_L = 61, |
DIGITAL_VOLUME_L = 61, |
||||||
DIGITAL_VOLUME_R = 62, |
DIGITAL_VOLUME_R = 62, |
||||||
DSP_BOOT_POWER_STATE = 118, |
DSP_BOOT_POWER_STATE = 118, |
||||||
}; |
}; |
||||||
|
|
||||||
void WriteRegister(Register reg, uint8_t val); |
void WriteRegister(Register reg, uint8_t val); |
||||||
}; |
}; |
||||||
|
|
||||||
} // namespace gay_ipod
|
} // namespace gay_ipod
|
||||||
|
Loading…
Reference in new issue