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/*\note Refer to template/README.md for usage cases.
35 * For peripheral drivers, blackbox mode is recommended but not required, reimplementation part MUST be open.
36 * For IPCore drivers, class structure, MULTI_CLASS configuration, reimplementation and class APIs should be open to user.
37 * For emulated drivers, **** No reimplementation ****.
38 */
39
40/*\note Includes CAN ONLY be put here. */
41/*\note If current header is for a peripheral driver(hw driver), and inherit from an IPCore driver, include IPCore header here. */
42
43// IPCore
44#if defined(__VSF_HAL_${I2S_IP}_I2S_CLASS_IMPLEMENT)
45# define __VSF_CLASS_IMPLEMENT__
46#elif defined(__VSF_HAL_${I2S_IP}_I2S_CLASS_INHERIT__)
47# define __VSF_CLASS_INHERIT__
48#endif
49
50#include "utilities/ooc_class.h"
51// IPCore end
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
57/*============================ MACROS ========================================*/
58
59/*\note VSF_${I2S_IP}_I2S_CFG_MULTI_CLASS should be implemented for IP drives and open to user,
60 * while VSF_HW_I2S_CFG_MULTI_CLASS should be in i2s.c.
61 */
62
63// IPCore
64#ifndef VSF_${I2S_IP}_I2S_CFG_MULTI_CLASS
65# define VSF_${I2S_IP}_I2S_CFG_MULTI_CLASS VSF_I2S_CFG_MULTI_CLASS
66#endif
67// IPCore end
68
69// HW
70/*\note hw I2S driver can reimplement following types:
71 * To enable reimplementation, please enable macro below:
72 * VSF_I2S_CFG_REIMPLEMENT_TYPE_MODE for vsf_i2s_mode_t
73 * VSF_I2S_CFG_REIMPLEMENT_TYPE_STATUS for vsf_i2s_status_t
74 * VSF_I2S_CFG_REIMPLEMENT_TYPE_IRQ_MASK for vsf_i2s_irq_mask_t
75 * VSF_I2S_CFG_REIMPLEMENT_TYPE_CTRL for vsf_i2s_ctrl_t
76 * VSF_I2S_CFG_REIMPLEMENT_TYPE_CFG for vsf_i2s_cfg_t
77 * VSF_I2S_CFG_REIMPLEMENT_TYPE_CAPABILITY for vsf_i2s_capability_t
78 * Reimplementation is used for optimization hw/IPCore drivers, reimplement the bit mask according to hw registers.
79 * *** DO NOT reimplement these in emulated drivers. ***
80 */
81
82#define VSF_I2S_CFG_REIMPLEMENT_TYPE_MODE ENABLED
83#define VSF_I2S_CFG_REIMPLEMENT_TYPE_STATUS ENABLED
84#define VSF_I2S_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
85#define VSF_I2S_CFG_REIMPLEMENT_TYPE_CTRL ENABLED
86#define VSF_I2S_CFG_REIMPLEMENT_TYPE_CFG ENABLED
87#define VSF_I2S_CFG_REIMPLEMENT_TYPE_CAPABILITY ENABLED
88// HW end
89
90/*============================ MACROFIED FUNCTIONS ===========================*/
91/*============================ TYPES =========================================*/
92
93// IPCore
94vsf_class(vsf_${i2s_ip}_i2s_t) {
95#if VSF_${I2S_IP}_CFG_MULTI_CLASS == ENABLED
96 public_member(
97 vsf_i2s_t vsf_i2s;
98 )
99#endif
100
101/*\note You can add more member in vsf_${i2s_ip}_i2s_t instance.
102 * For members accessible from child, put in protected_member.
103 * Else, put in private_member.
104 */
105
106 protected_member(
107 vsf_${i2s_ip}_i2s_reg_t *reg;
110};
111// IPCore end
112
113/*============================ INCLUDES ======================================*/
114
115// IPCore
116/*\note Extern APIs for ip core diriver.
117 * There is no requirement about how APIs of IPCore drivers should be implemented.
118 * Just consider the simplicity for actual peripheral drivers.
119 */
120// IPCore end
121
122#ifdef __cplusplus
123}
124#endif
125
126// IPCore
127#undef __VSF_HAL_${I2S_IP}_I2S_CLASS_IMPLEMENT
128#undef __VSF_HAL_${I2S_IP}_I2S_CLASS_INHERIT__
129// IPCore end
130
131// HW/IPCore, not for emulated drivers
132#if VSF_I2S_CFG_REIMPLEMENT_TYPE_MODE == ENABLED
133typedef enum vsf_i2s_mode_t {
134 VSF_I2S_MODE_MASTER = (0x01ul << 0),
135 VSF_I2S_MODE_SLAVE = (0x00ul << 0),
136
137 VSF_I2S_DATA_BITLEN_16 = (0x01ul << 1),
138 VSF_I2S_DATA_BITLEN_24 = (0x02ul << 1),
139 VSF_I2S_DATA_BITLEN_32 = (0x03ul << 1),
140
141 VSF_I2S_FRAME_BITLEN_16 = (0x01ul << 3),
142 VSF_I2S_FRAME_BITLEN_24 = (0x02ul << 3),
143 VSF_I2S_FRAME_BITLEN_32 = (0x03ul << 3),
144
145 VSF_I2S_STANDARD_PHILIPS = (0x01ul << 5),
146 VSF_I2S_STANDARD_MSB = (0x02ul << 5),
147 VSF_I2S_STANDARD_LSB = (0x03ul << 5),
148
149 VSF_I2S_LRCK_POL = (0x01ul << 7),
150 VSF_I2S_BCK_POL = (0x01ul << 8),
151 VSF_I2S_MCLK_OUTPUT = (0x01ul << 9),
153#endif
154
155#if VSF_I2S_CFG_REIMPLEMENT_TYPE_IRQ_MASK == ENABLED
156typedef enum vsf_i2s_irq_mask_t {
160#endif
161
162#if VSF_I2S_CFG_REIMPLEMENT_TYPE_STATUS == ENABLED
163typedef struct vsf_i2s_status_t {
164 union {
167 };
169#endif
170
171#if VSF_I2S_CFG_REIMPLEMENT_TYPE_CAPABILITY == ENABLED
172typedef struct vsf_i2s_capability_t {
173#if VSF_I2S_CFG_INHERIT_HAL_CAPABILITY == ENABLED
175#endif
176 struct {
177 bool is_src_supported;
178 bool is_dbuffer_supported;
181#endif
182
183#if VSF_I2S_CFG_REIMPLEMENT_TYPE_CFG == ENABLED
184typedef struct vsf_i2s_t vsf_i2s_t;
185typedef void vsf_i2s_isr_handler_t(void *target_ptr, vsf_i2s_t *i2s_ptr, vsf_i2s_irq_mask_t irq_mask);
186typedef struct vsf_i2s_isr_t {
188 void *target_ptr;
191typedef struct vsf_i2s_cfg_t {
200#endif
201// HW/IPCore end
202
203#endif // VSF_HAL_USE_I2S
204#endif // __HAL_DRIVER_${SERIES/I2S_IP}_I2S_H__
205/* 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:92
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:268
inherit(vsf_peripheral_capability_t) struct
Definition i2s.h:174
i2s_capability
Definition vsf_template_i2s.h:277
i2s configuration
Definition vsf_template_i2s.h:344
vsf_i2s_mode_t mode
Definition vsf_template_i2s.h:345
uint16_t buffer_size
Definition vsf_template_i2s.h:353
vsf_i2s_isr_t isr
Definition vsf_template_i2s.h:357
uint8_t channel_num
Definition vsf_template_i2s.h:355
uint32_t hw_sample_rate
Definition vsf_template_i2s.h:349
uint32_t data_sample_rate
Definition vsf_template_i2s.h:347
uint8_t * buffer
Definition vsf_template_i2s.h:351
i2s interrupt configuration
Definition vsf_template_i2s.h:328
vsf_arch_prio_t prio
Definition vsf_template_i2s.h:333
vsf_i2s_isr_handler_t * handler_fn
Definition vsf_template_i2s.h:329
void * target_ptr
Definition vsf_template_i2s.h:331
Definition vsf_template_i2s.h:259
Definition vsf_template_i2s.h:372
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:185
class vsf_$ * reg
vsf_i2s_isr_t isr
Definition i2s.h:109
vk_av_control_value_t value
Definition vsf_audio.h:171
Generated from commit: vsfteam/vsf@74aa6ce