libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
codec_wm8731.h
Go to the documentation of this file.
1#pragma once
2#ifndef DSY_CODEC_WM8731_H
3#define DSY_CODEC_WM8731_H
4#include "per/i2c.h"
5
6namespace daisy
7{
33class Wm8731
34{
35 public:
37 enum class Result
38 {
39 OK,
40 ERR,
41 };
42
46 struct Config
47 {
49 enum class Format
50 {
51 MSB_FIRST_RJ = 0x00,
52 MSB_FIRST_LJ = 0x01,
53 I2S = 0x02,
54 DSP = 0x03,
55 };
56
61 enum class WordLength
62 {
63 BITS_16 = (0x00 << 2),
64 BITS_20 = (0x01 << 2),
65 BITS_24 = (0x02 << 2),
66 BITS_32 = (0x03 << 2),
67 };
68
71
73 bool lr_swap;
74
79
82
89 void Defaults()
90 {
91 mcu_is_master = true;
92 lr_swap = false;
93 csb_pin_state = false;
96 }
97 };
98
99 Wm8731() {}
101
103 Result Init(const Config &config, I2CHandle i2c);
104
105 private:
106 I2CHandle i2c_;
107 Config cfg_;
108 Result WriteControlRegister(uint8_t addr, uint16_t data);
109 uint8_t dev_addr_;
110};
111
112} // namespace daisy
113
114
115#endif
Definition i2c.h:26
Definition codec_wm8731.h:34
Wm8731()
Definition codec_wm8731.h:99
Result Init(const Config &config, I2CHandle i2c)
~Wm8731()
Definition codec_wm8731.h:100
Result
Definition codec_wm8731.h:38
Hardware defines and helpers for daisy field platform.
Definition index.h:2
Definition codec_wm8731.h:47
bool mcu_is_master
Definition codec_wm8731.h:70
void Defaults()
Definition codec_wm8731.h:89
bool csb_pin_state
Definition codec_wm8731.h:78
Format fmt
Definition codec_wm8731.h:80
bool lr_swap
Definition codec_wm8731.h:73
WordLength
Definition codec_wm8731.h:62
Format
Definition codec_wm8731.h:50
WordLength wl
Definition codec_wm8731.h:81