Skip to content

Commit

Permalink
repo: clean ups
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinevg committed Oct 6, 2022
1 parent 00de056 commit 93fd44d
Showing 1 changed file with 28 additions and 51 deletions.
79 changes: 28 additions & 51 deletions examples/device/wm8731.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,69 +12,46 @@ pub enum Register {
LHPOUT = 0x02,
RHPOUT = 0x03,
APANA = 0x04,
APDIGI = 0x05, // 0000_0101
APDIGI = 0x05,
PWR = 0x06,
IFACE = 0x07, // 0000_0111
SRATE = 0x08, // 0000_1000
ACTIVE = 0x09, // 0000_1001
IFACE = 0x07,
SRATE = 0x08,
ACTIVE = 0x09,
RESET = 0x0F,
}

pub const DEFAULT_CONFIG: &[(Register, u16)] = &[
(Register::PWR, 0x80),
(Register::RESET, 0x00),
(Register::ACTIVE, 0x00),
// power-on codec, reset and switch to inactive
(Register::PWR, 0b1000_0000),
(Register::RESET, 0x0),
(Register::ACTIVE, 0b0),

(Register::APANA, 0x12),
//(Register::APANA, 0b0001_0010), // MICBOOST=0 MUTEMIC=1 INSEL=0 BYPASS=0 DACSEL=1 SIDETONE=0
// configure power
(Register::PWR, 0b0001_0000), // power-down outputs

(Register::APDIGI, 0x00),
(Register::PWR, 0x00),
// select mic for adc input, dac select
(Register::APANA, 0b0_0001_0100),

(Register::IFACE, 0b0100_1110), // MS=i2s_clock_internal, IWL=32bit, FORMAT=i2s
//(Register::IFACE, 0b00001110), // MS=i2s_clock_external, IWL=32bit, FORMAT=i2s
//(Register::IFACE, 0b0000_0010), // 0x02 FORMAT=b10 IRL=b00 LRP=0 LRSWAP=0 MS=0 BCKLINV=0
//(Register::IFACE, 0b0100_0010), // 0x42 FORMAT=b10 IRL=b00 LRP=0 LRSWAP=0 MS=1 BCKLINV=0
// configure digital routing
(Register::APDIGI, 0b1_0110), // store dc-offset, de-emphasis for fs=48kHz, enable hpf

(Register::SRATE, 0b0000_0000), // MODE=0 BOSR=0 FS=48Khz CLKIDIV2=0 CLKODIV2=0
//(Register::SRATE, 0b0000_0001), // MODE=1 BOSR=0 FS=48Khz CLKIDIV2=0 CLKODIV2=0
// configure interface format
(Register::IFACE, 0b0100_1110), // i2s_clock_internal, 32bit, i2s

(Register::LINVOL, 0x17),
(Register::RINVOL, 0x17),
(Register::LHPOUT, 0x79), // 0dB
(Register::RHPOUT, 0x79), // 0dB
(Register::ACTIVE, 0x01),
];

/*
pub const DEFAULT_CONFIG: &[(Register, u16)] = &[
// reset Codec
(Register::RESET, 0x00),
// set line inputs 0dB - TODO dev board only has mic in, these are NC
(Register::LINVOL, 0x17),
(Register::RINVOL, 0x17),
// set headphone out to 0dB
(Register::LHPOUT, 0b0_0111_1001),
(Register::RHPOUT, 0b0_0111_1001),
// set analog and digital routing
(Register::APANA, 0b0_0001_0100), // select mic for adc input, dac select
(Register::APDIGI, 0b0_0000_0001), // disable hpf
// configure mode and sample-rate
(Register::SRATE, 0b0000_0000), // mode=0, fs=48kHz

// configure power management
//(Register::PWR, 0b0_0100_0000), // clkout power down
(Register::PWR, 0b0_0000_0000), // i2s_clock_internal, so don't power down clock
// set input level
(Register::LINVOL, 0b0_0001_0111), // 0dB
(Register::RINVOL, 0b0_0001_0111), // 0dB

// configure digital format
(Register::IFACE, 0b0_0100_1110), // MS=i2s_clock_internal, IWL=32bit, FORMAT=i2s
//(Register::IFACE, 0b0_0000_1110), // MS=i2s_clock_external, IWL=32bit, FORMAT=i2s
// set output level
(Register::LHPOUT, 0b0_1111_1001), // zero cross detect enable, 0dB
(Register::RHPOUT, 0b0_1111_1001), // zero cross detect enable, 0dB

// set samplerate
(Register::SRATE, 0x00), // fs=48kHz
// switch codec to active
(Register::ACTIVE, 0b1),

(Register::ACTIVE, 0x00),
(Register::ACTIVE, 0x01),
// configure power
(Register::PWR, 0b0000_0000), // power-up outputs
];
*/

0 comments on commit 93fd44d

Please sign in to comment.