VSF Documented
vsf_es8389.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2026 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * http://www.apache.org/licenses/LICENSE-2.0 *
8 * *
9 * Unless required by applicable law or agreed to in writing, software *
10 * distributed under the License is distributed on an "AS IS" BASIS, *
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
12 * See the License for the specific language governing permissions and *
13 * limitations under the License. *
14 *****************************************************************************/
15
16#ifndef __VSF_ES8389_H__
17#define __VSF_ES8389_H__
18
19/*============================ INCLUDES ======================================*/
20
21#include "../../../vsf_av_cfg.h"
22
23#if VSF_USE_AUDIO == ENABLED && VSF_AUDIO_USE_ES8389 == ENABLED
24
25#include "component/av/vsf_av.h"
26#include "hal/vsf_hal.h"
27#include "kernel/vsf_eda.h" // vsf_sem_t for the i2c sync member
28
29#if defined(__VSF_ES8389_CLASS_IMPLEMENT)
30# undef __VSF_ES8389_CLASS_IMPLEMENT
31# define __VSF_CLASS_IMPLEMENT__
32#endif
33// re-including a class header in another mode later(e.g. the board file
34// in plain extern mode) needs the original flag back
35#if defined(__VSF_ES8389_CLASS_INHERIT__)
36# undef __VSF_ES8389_CLASS_INHERIT__
37# define __VSF_CLASS_INHERIT__
38#endif
39
40#include "utilities/ooc_class.h"
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46/*============================ MACROS ========================================*/
47/*============================ MACROFIED FUNCTIONS ===========================*/
48/*============================ TYPES =========================================*/
49
50typedef struct vk_es8389_reg_op_t {
53 uint8_t mask; // 0: write, non-zero: read-modify-write
55
57 public_member(
58 implement(vk_audio_i2s_dev_t)
59
60 // Control-bus connection and configuration; initialised by the driver.
61 vsf_i2c_t *i2c_ptr;
62 uint16_t i2c_addr; // 7-bit
63 uint32_t i2c_clock_hz;
64 vsf_arch_prio_t i2c_isr_prio;
65
66 // false: route the DAC reference into the recorded right channel;
67 // true: independent playback and capture paths.
68 bool no_dac_ref;
69
70 // Board amplifier enable pad; NULL port = none.
71 vsf_gpio_t *pa_port;
72 vsf_gpio_pin_mask_t pa_pin_mask;
73 bool pa_active_high;
74
75 // Applied on each new codec session, before later standard controls.
76 int16_t playback_volume_half_db;
77 uint8_t capture_pga_gain_steps;
78 )
79
80 private_member(
81 vsf_teda_t teda;
82 vsf_sem_t cmd_sem;
83 vsf_sem_t i2c_sem;
84 vsf_trig_t stop_trig;
85 vsf_trig_t ctrl_trig;
86 volatile vsf_i2c_irq_mask_t i2c_irq;
87
88 const vk_es8389_reg_op_t *ops;
89 vk_es8389_reg_op_t fs_ops[21];
90 vk_es8389_reg_op_t control_ops[4];
91 uint8_t op_count;
92 uint8_t op_index;
93 uint8_t xfer_phase;
94 uint8_t tx_buf[2];
95 uint8_t rx_buf[1];
96
97 uint16_t session;
98 uint16_t work_session;
99 uint16_t sample_rate[2]; // 100 Hz units, playback/capture
100 uint8_t request_mask;
101 uint8_t started_mask;
102 uint8_t enabled_mask;
103 uint8_t wait_state;
104 uint8_t work;
105 uint8_t retry;
106 bool i2c_outstanding;
107 bool i2c_timed_out;
108 bool recover_retry;
109 bool session_failed;
110 bool fs_configured;
111 bool analog_enabled;
112 bool is_opened;
113 bool is_ready;
114 vsf_err_t last_error;
115
116 bool stop_pending;
117 bool stop_completed;
118 bool stop_final;
119 vsf_err_t stop_result;
120 bool ctrl_pending;
121 bool ctrl_completed;
122 vsf_err_t ctrl_result;
123 uint8_t ctrl_dir;
124 vk_av_control_type_t ctrl_type;
125 vk_av_control_value_t ctrl_value;
126
127 int16_t playback_volume;
128 uint8_t capture_gain;
129 bool playback_muted;
130 bool capture_muted;
131 )
132};
133
134/*============================ GLOBAL VARIABLES ==============================*/
135
136extern const vk_audio_drv_t vk_es8389_drv;
137
138/*============================ PROTOTYPES ====================================*/
139
140#ifdef __cplusplus
141}
142#endif
143
144#endif // VSF_USE_AUDIO && VSF_AUDIO_USE_ES8389
145#endif // __VSF_ES8389_H__
vsf_err_t
Definition __type.h:42
Definition vsf_audio.h:74
Definition vsf_audio_i2s.h:49
Definition vsf_es8389.h:56
Base sync IPC object; sem/mutex/trig/crit are built on it.
Definition vsf_eda.h:1964
eda with timer support (can use vsf_teda_set_timer() etc.); derived classes (task/pt/thread) inherit ...
Definition vsf_eda.h:1916
vsf_arch_prio_t
Definition cortex_a_generic.h:85
vsf_i2c_irq_mask_t
Definition i2c.h:103
#define vsf_class(__name)
Definition ooc_class.h:52
short int16_t
Definition stdint.h:6
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_av.h:54
Definition vsf_es8389.h:50
uint8_t mask
Definition vsf_es8389.h:53
uint8_t reg
Definition vsf_es8389.h:51
uint8_t value
Definition vsf_es8389.h:52
Definition vsf_template_gpio.h:942
I2C instance structure for multi-class support.
Definition vsf_template_i2c.h:1056
vk_av_control_type_t
Definition vsf_av.h:38
struct vk_es8389_reg_op_t vk_es8389_reg_op_t
const vk_audio_drv_t vk_es8389_drv
uint32_t vsf_gpio_pin_mask_t
Definition vsf_template_gpio.h:351
Generated from commit: vsfteam/vsf@b7e0147