VSF Documented
i2s.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 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 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __HAL_DRIVER_${SERIES/I2S_IP}_I2S_H__
19#define __HAL_DRIVER_${SERIES/I2S_IP}_I2S_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "hal/vsf_hal_cfg.h"
24
25#if VSF_HAL_USE_I2S == ENABLED
26
27// HW/IPCore
32// HW/IPCore end
33
34#include "../../__device.h"
35
36/*\note Refer to template/README.md for usage cases.
37 * For peripheral drivers, blackbox mode is recommended but not required, reimplementation part MUST be open.
38 * For IPCore drivers, class structure, MULTI_CLASS configuration, reimplementation and class APIs should be open to user.
39 * For emulated drivers, **** No reimplementation ****.
40 */
41
42/*\note Includes CAN ONLY be put here. */
43/*\note If current header is for a peripheral driver(hw driver), and inherit from an IPCore driver, include IPCore header here. */
44
45// IPCore
46#if defined(__VSF_HAL_${I2S_IP}_I2S_CLASS_IMPLEMENT)
47# define __VSF_CLASS_IMPLEMENT__
48#elif defined(__VSF_HAL_${I2S_IP}_I2S_CLASS_INHERIT__)
49# define __VSF_CLASS_INHERIT__
50#endif
51
52#include "utilities/ooc_class.h"
53// IPCore end
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59/*============================ MACROS ========================================*/
60
61/*\note VSF_${I2S_IP}_I2S_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
62 * while VSF_HW_I2S_CFG_MULTI_CLASS should be in i2s.c.
63 */
64
65// IPCore
66#ifndef VSF_${I2S_IP}_I2S_CFG_MULTI_CLASS
67# define VSF_${I2S_IP}_I2S_CFG_MULTI_CLASS VSF_I2S_CFG_MULTI_CLASS
68#endif
69// IPCore end
70
71// HW
72/*\note hw I2S driver can reimplement following types:
73 * To enable reimplementation, please enable macro below:
74 * VSF_I2S_CFG_REIMPLEMENT_TYPE_MODE for vsf_i2s_mode_t
75 * VSF_I2S_CFG_REIMPLEMENT_TYPE_STATUS for vsf_i2s_status_t
76 * VSF_I2S_CFG_REIMPLEMENT_TYPE_IRQ_MASK for vsf_i2s_irq_mask_t
77 * VSF_I2S_CFG_REIMPLEMENT_TYPE_CTRL for vsf_i2s_ctrl_t
78 * VSF_I2S_CFG_REIMPLEMENT_TYPE_CFG for vsf_i2s_cfg_t
79 * VSF_I2S_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_i2s_capability_t
80 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
81 * *** DO NOT reimplement these in emulated drivers. ***
82 */
83
84#define VSF_I2S_CFG_REIMPLEMENT_TYPE_MODE ENABLED
85#define VSF_I2S_CFG_REIMPLEMENT_TYPE_STATUS ENABLED
86#define VSF_I2S_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
87#define VSF_I2S_CFG_REIMPLEMENT_TYPE_CTRL ENABLED
88#define VSF_I2S_CFG_REIMPLEMENT_TYPE_CFG ENABLED
89#define VSF_I2S_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
90// HW end
91
92/*============================ MACROFIED FUNCTIONS ===========================*/
93/*============================ TYPES =========================================*/
94
95// IPCore
96vsf_class(vsf_${i2s_ip}_i2s_t) {
97#if VSF_${I2S_IP}_CFG_MULTI_CLASS == ENABLED
98 public_member(
99 vsf_i2s_t vsf_i2s;
100 )
101#endif
102
103/*\note You can add more member in vsf_${i2s_ip}_i2s_t instance.
104 * For members accessible from child, put in protected_member.
105 * Else, put in private_member.
106 */
107
108 protected_member(
109 vsf_${i2s_ip}_i2s_reg_t *reg;
112};
113// IPCore end
114
115/*============================ INCLUDES ======================================*/
116
117// IPCore
118/*\note Extern APIs for ip core diriver.
119 * There is no requirement about how APIs of IPCore drivers should be implemented.
120 * Just consider the simplicity for actual peripheral drivers.
121 */
122// IPCore end
123
124#ifdef __cplusplus
125}
126#endif
127
128// IPCore
129#undef __VSF_HAL_${I2S_IP}_I2S_CLASS_IMPLEMENT
130#undef __VSF_HAL_${I2S_IP}_I2S_CLASS_INHERIT__
131// IPCore end
132
133// HW/IPCore, not for emulated drivers
134#if VSF_I2S_CFG_REIMPLEMENT_TYPE_MODE == ENABLED
135typedef enum vsf_i2s_mode_t {
136 VSF_I2S_MODE_MASTER = (0x01ul << 0),
137 VSF_I2S_MODE_SLAVE = (0x00ul << 0),
138
139 VSF_I2S_DATA_BITLEN_16 = (0x01ul << 1),
140 VSF_I2S_DATA_BITLEN_24 = (0x02ul << 1),
141 VSF_I2S_DATA_BITLEN_32 = (0x03ul << 1),
142
143 VSF_I2S_FRAME_BITLEN_16 = (0x01ul << 3),
144 VSF_I2S_FRAME_BITLEN_24 = (0x02ul << 3),
145 VSF_I2S_FRAME_BITLEN_32 = (0x03ul << 3),
146
147 VSF_I2S_STANDARD_PHILIPS = (0x01ul << 5),
148 VSF_I2S_STANDARD_MSB = (0x02ul << 5),
149 VSF_I2S_STANDARD_LSB = (0x03ul << 5),
150
151 VSF_I2S_LRCK_POL = (0x01ul << 7),
152 VSF_I2S_BCK_POL = (0x01ul << 8),
153 VSF_I2S_MCLK_OUTPUT = (0x01ul << 9),
155#endif
156
157#if VSF_I2S_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
158typedef enum vsf_i2s_irq_mask_t {
162#endif
163
164#if VSF_I2S_CFG_REIMPLEMENT_TYPE_STATUS == ENABLED
165typedef struct vsf_i2s_status_t {
166 union {
169 };
171#endif
172
173#if VSF_I2S_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
174typedef struct vsf_i2s_capability_t {
175#if VSF_I2S_CFG_INHERIT_HAL_CAPABILITY == ENABLED
177#endif
178 struct {
179 bool is_src_supported;
180 bool is_dbuffer_supported;
183#endif
184
185#if VSF_I2S_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
186typedef struct vsf_i2s_t vsf_i2s_t;
187typedef void vsf_i2s_isr_handler_t(void *target_ptr, vsf_i2s_t *i2s_ptr, vsf_i2s_irq_mask_t irq_mask);
188typedef struct vsf_i2s_isr_t {
190 void *target_ptr;
193typedef struct vsf_i2s_cfg_t {
202#endif
203// HW/IPCore end
204
205#endif // VSF_HAL_USE_I2S
206#endif // __HAL_DRIVER_${SERIES/I2S_IP}_I2S_H__
207/* EOF */
vsf_i2s_mode_t
Definition i2s.h:37
@ VSF_I2S_MCLK_OUTPUT
Definition i2s.h:63
@ VSF_I2S_STANDARD_LSB
Definition i2s.h:64
@ VSF_I2S_DATA_BITLEN_16
Definition i2s.h:54
@ VSF_I2S_FRAME_BITLEN_32
Definition i2s.h:61
@ VSF_I2S_FRAME_BITLEN_16
Definition i2s.h:59
@ VSF_I2S_STANDARD_MSB
Definition i2s.h:42
@ VSF_I2S_MODE_MASTER
Definition i2s.h:38
@ VSF_I2S_LRCK_POL
Definition i2s.h:45
@ VSF_I2S_DATA_BITLEN_32
Definition i2s.h:56
@ VSF_I2S_STANDARD_PHILIPS
Definition i2s.h:43
@ VSF_I2S_DATA_BITLEN_24
Definition i2s.h:55
@ VSF_I2S_FRAME_BITLEN_24
Definition i2s.h:60
@ VSF_I2S_MODE_SLAVE
Definition i2s.h:39
@ VSF_I2S_BCK_POL
Definition i2s.h:46
vsf_i2s_irq_mask_t
Definition i2s.h:32
@ VSF_I2S_IRQ_MASK_RX_TGL_BUFFER
Definition i2s.h:34
@ VSF_I2S_IRQ_MASK_TX_TGL_BUFFER
Definition i2s.h:33
Definition adc.h:94
vsf_arch_prio_t
Definition cortex_a_generic.h:88
#define vsf_class(__name)
Definition ooc_class.h:48
const i_spi_t vsf_spi_irq_mask_t irq_mask
Definition spi_interface.h:38
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_template_i2s.h:265
inherit(vsf_peripheral_capability_t) struct
Definition i2s.h:176
i2s_capability
Definition vsf_template_i2s.h:274
i2s configuration
Definition vsf_template_i2s.h:341
vsf_i2s_mode_t mode
Definition vsf_template_i2s.h:342
uint16_t buffer_size
Definition vsf_template_i2s.h:350
vsf_i2s_isr_t isr
Definition vsf_template_i2s.h:354
uint8_t channel_num
Definition vsf_template_i2s.h:352
uint32_t hw_sample_rate
Definition vsf_template_i2s.h:346
uint32_t data_sample_rate
Definition vsf_template_i2s.h:344
uint8_t * buffer
Definition vsf_template_i2s.h:348
i2s interrupt configuration
Definition vsf_template_i2s.h:325
vsf_arch_prio_t prio
Definition vsf_template_i2s.h:330
vsf_i2s_isr_handler_t * handler_fn
Definition vsf_template_i2s.h:326
void * target_ptr
Definition vsf_template_i2s.h:328
Definition vsf_template_i2s.h:256
Definition vsf_template_i2s.h:369
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
void vsf_i2s_isr_handler_t(void *target_ptr, vsf_i2s_t *i2s_ptr, vsf_i2s_irq_mask_t irq_mask)
Definition i2s.h:187
class vsf_$ * reg
vsf_i2s_isr_t isr
Definition i2s.h:111
vk_av_control_value_t value
Definition vsf_audio.h:171
Generated from commit: vsfteam/vsf@2b286be