app_i2s.h
Go to the documentation of this file.
1
52 #ifndef _APP_I2S_H_
53 #define _APP_I2S_H_
54
55 #include "gr55xx_hal.h"
56 #include "app_io.h"
57 #include "app_drv_error.h"
58 #ifdef ENV_USE_FREERTOS
59 #include "app_rtos_cfg.h"
60 #endif
61
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
65
66 #ifdef HAL_I2S_MODULE_ENABLED
67
75 typedef enum
76 {
77 APP_I2S_ID_SLAVE,
78 APP_I2S_ID_MASTER,
79 APP_I2S_ID_MAX
80 } app_i2s_id_t;
81
85 typedef enum
86 {
87 APP_I2S_TYPE_INTERRUPT,
88 APP_I2S_TYPE_POLLING,
89 APP_I2S_TYPE_DMA,
90 APP_I2S_TYPE_MAX
91 } app_i2s_type_t;
92
96 typedef enum
97 {
98 APP_I2S_EVT_ERROR,
99 APP_I2S_EVT_TX_CPLT,
100 APP_I2S_EVT_RX_DATA,
101 APP_I2S_EVT_TX_RX,
102 } app_i2s_evt_type_t;
113 typedef struct
114 {
115 app_io_type_t type;
116 app_io_mux_t mux;
117 uint32_t pin;
119 app_io_pull_t pull;
120 } app_i2s_pin_t;
121
125 typedef struct
126 {
127 app_i2s_pin_t ws;
128 app_i2s_pin_t sdo;
129 app_i2s_pin_t sdi;
130 app_i2s_pin_t sclk;
131 } app_i2s_pin_cfg_t;
132
136 typedef struct
137 {
138 app_i2s_type_t type;
139 dma_channel_t tx_dma_channel;
140 dma_channel_t rx_dma_channel;
141 } app_i2s_mode_t;
142
146 typedef struct
147 {
148 app_i2s_id_t id;
149 app_i2s_pin_cfg_t pin_cfg;
150 app_i2s_mode_t use_mode;
151 i2s_init_t init;
152 } app_i2s_params_t;
153
157 typedef struct
158 {
159 app_i2s_evt_type_t type;
160 union
161 {
162 uint32_t error_code;
163 uint16_t size;
164 } data;
165 } app_i2s_evt_t;
166
170 typedef void (*app_i2s_evt_handler_t)(app_i2s_evt_t *p_evt);
171
174 /* Exported functions --------------------------------------------------------*/
193 uint16_t app_i2s_init(app_i2s_params_t *p_params, app_i2s_evt_handler_t evt_handler);
194
204 uint16_t app_i2s_deinit(app_i2s_id_t id);
205
218 uint16_t app_i2s_receive_sync(app_i2s_id_t id, uint16_t *p_data, uint16_t size, uint32_t timeout);
219
231 uint16_t app_i2s_receive_async(app_i2s_id_t id, uint16_t *p_data, uint16_t size);
232
245 uint16_t app_i2s_transmit_sync(app_i2s_id_t id, uint16_t *p_data, uint16_t size, uint32_t timeout);
246
258 uint16_t app_i2s_transmit_async(app_i2s_id_t id, uint16_t *p_data, uint16_t size);
259
270 uint16_t app_i2s_enable(app_i2s_id_t id);
271
281 uint16_t app_i2s_disable(app_i2s_id_t id);
282
292 uint16_t app_i2s_enable_clock(app_i2s_id_t id);
293
303 uint16_t app_i2s_disable_clock(app_i2s_id_t id);
304
314 uint16_t app_i2s_flush_tx_fifo(app_i2s_id_t id);
315
325 uint16_t app_i2s_flush_rx_fifo(app_i2s_id_t id);
326
336 i2s_handle_t *app_i2s_get_handle(app_i2s_id_t id);
337
338 #ifdef ENV_RTOS_USE_SEMP
339
351 uint16_t app_i2s_receive_sem_sync(app_i2s_id_t id, uint16_t *p_data, uint16_t size);
352
364 uint16_t app_i2s_transmit_sem_sync(app_i2s_id_t id, uint16_t *p_data, uint16_t size);
365
366 #endif
367
370 #endif
371
372 #ifdef __cplusplus
373 }
374 #endif
375
376 #endif
377
app_i2s_params_t::id
app_i2s_id_t id
Definition: app_i2s.h:148
app_i2s_pin_t::mux
app_io_mux_t mux
Definition: app_i2s.h:116
app_i2s_transmit_sync
uint16_t app_i2s_transmit_sync(app_i2s_id_t id, uint16_t *p_data, uint16_t size, uint32_t timeout)
Transmits in master or slave mode an amount of data in blocking mode.
app_i2s_pin_cfg_t
I2S IO configuration Structures.
Definition: app_i2s.h:126
app_i2s_enable_clock
uint16_t app_i2s_enable_clock(app_i2s_id_t id)
Enable the master I2S clock.
app_i2s_flush_tx_fifo
uint16_t app_i2s_flush_tx_fifo(app_i2s_id_t id)
Flush the I2S transmitter FIFO.
APP_I2S_TYPE_INTERRUPT
@ APP_I2S_TYPE_INTERRUPT
Definition: app_i2s.h:87
app_i2s_params_t
I2S parameters structure definition.
Definition: app_i2s.h:147
APP_I2S_TYPE_DMA
@ APP_I2S_TYPE_DMA
Definition: app_i2s.h:89
APP_I2S_ID_MAX
@ APP_I2S_ID_MAX
Definition: app_i2s.h:79
app_i2s_evt_t::error_code
uint32_t error_code
Definition: app_i2s.h:162
APP_I2S_TYPE_POLLING
@ APP_I2S_TYPE_POLLING
Definition: app_i2s.h:88
app_i2s_pin_cfg_t::sdi
app_i2s_pin_t sdi
Definition: app_i2s.h:129
app_i2s_type_t
app_i2s_type_t
I2S operating mode Enumerations definition.
Definition: app_i2s.h:86
app_i2s_evt_type_t
app_i2s_evt_type_t
I2S event Enumerations definition.
Definition: app_i2s.h:97
app_i2s_params_t::use_mode
app_i2s_mode_t use_mode
Definition: app_i2s.h:150
app_i2s_evt_t::size
uint16_t size
Definition: app_i2s.h:163
app_io_pull_t
app_io_pull_t
GPIO pull Enumerations definition.
Definition: app_io.h:187
app_io_type_t
app_io_type_t
GPIO type Enumerations definition.
Definition: app_io.h:141
app_i2s_deinit
uint16_t app_i2s_deinit(app_i2s_id_t id)
De-initialize the APP I2S DRIVER peripheral.
app_i2s_pin_cfg_t::sdo
app_i2s_pin_t sdo
Definition: app_i2s.h:128
app_i2s_mode_t::type
app_i2s_type_t type
Definition: app_i2s.h:138
app_i2s_disable
uint16_t app_i2s_disable(app_i2s_id_t id)
Disable the I2S moudle.
app_i2s_flush_rx_fifo
uint16_t app_i2s_flush_rx_fifo(app_i2s_id_t id)
Flush the I2S receiver FIFO.
APP_I2S_ID_SLAVE
@ APP_I2S_ID_SLAVE
Definition: app_i2s.h:77
APP_I2S_ID_MASTER
@ APP_I2S_ID_MASTER
Definition: app_i2s.h:78
app_i2s_receive_sync
uint16_t app_i2s_receive_sync(app_i2s_id_t id, uint16_t *p_data, uint16_t size, uint32_t timeout)
Receive in master or slave mode an amount of data in blocking mode.
APP_I2S_EVT_RX_DATA
@ APP_I2S_EVT_RX_DATA
Definition: app_i2s.h:100
app_io.h
Header file containing functions prototypes of GPIO app library.
app_i2s_transmit_async
uint16_t app_i2s_transmit_async(app_i2s_id_t id, uint16_t *p_data, uint16_t size)
Transmits in master or slave mode an amount of data in non-blocking mode with Interrupt.
app_i2s_pin_t::pin
uint32_t pin
Definition: app_i2s.h:117
app_i2s_evt_t::type
app_i2s_evt_type_t type
Definition: app_i2s.h:159
app_i2s_id_t
app_i2s_id_t
I2S module Enumerations definition.
Definition: app_i2s.h:76
app_i2s_params_t::pin_cfg
app_i2s_pin_cfg_t pin_cfg
Definition: app_i2s.h:149
app_i2s_pin_t::pull
app_io_pull_t pull
Definition: app_i2s.h:119
app_i2s_evt_t
I2S event structure definition.
Definition: app_i2s.h:158
app_i2s_mode_t::tx_dma_channel
dma_channel_t tx_dma_channel
Definition: app_i2s.h:139
app_i2s_pin_cfg_t::ws
app_i2s_pin_t ws
Definition: app_i2s.h:127
_i2s_handle
I2S handle Structure definition.
Definition: gr55xx_hal_i2s.h:130
app_i2s_pin_t::type
app_io_type_t type
Definition: app_i2s.h:115
app_i2s_pin_t
I2S IO Structures.
Definition: app_i2s.h:114
APP_I2S_EVT_TX_CPLT
@ APP_I2S_EVT_TX_CPLT
Definition: app_i2s.h:99
app_i2s_pin_cfg_t::sclk
app_i2s_pin_t sclk
Definition: app_i2s.h:130
app_i2s_init
uint16_t app_i2s_init(app_i2s_params_t *p_params, app_i2s_evt_handler_t evt_handler)
Initialize the APP I2S DRIVER according to the specified parameters in the app_i2s_params_t and app_i...
app_i2s_params_t::init
i2s_init_t init
Definition: app_i2s.h:151
_i2s_init
I2S init Structure definition.
Definition: gr55xx_hal_i2s.h:104
app_i2s_mode_t::rx_dma_channel
dma_channel_t rx_dma_channel
Definition: app_i2s.h:140
app_i2s_mode_t
I2S operate mode Enumerations definition.
Definition: app_i2s.h:137
gr55xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
app_i2s_enable
uint16_t app_i2s_enable(app_i2s_id_t id)
Enable the I2S moudle.
app_i2s_get_handle
i2s_handle_t * app_i2s_get_handle(app_i2s_id_t id)
Return the I2S handle.
APP_I2S_EVT_TX_RX
@ APP_I2S_EVT_TX_RX
Definition: app_i2s.h:101
app_i2s_disable_clock
uint16_t app_i2s_disable_clock(app_i2s_id_t id)
Disable the master I2S clock.
app_i2s_evt_handler_t
void(* app_i2s_evt_handler_t)(app_i2s_evt_t *p_evt)
I2S event callback definition.
Definition: app_i2s.h:170
app_io_mux_t
app_io_mux_t
GPIO mux Enumerations definition.
Definition: app_io.h:198
APP_I2S_EVT_ERROR
@ APP_I2S_EVT_ERROR
Definition: app_i2s.h:98
app_rtos_cfg.h
Header file of app rtos config code.
app_drv_error.h
Header file of app driver error code.
app_i2s_receive_async
uint16_t app_i2s_receive_async(app_i2s_id_t id, uint16_t *p_data, uint16_t size)
Receive in master or slave mode an amount of data in non-blocking mode with Interrupt.
dma_channel_t
dma_channel_t
HAL DMA Channel Enumerations definition.
Definition: gr55xx_hal_dma.h:93
APP_I2S_TYPE_MAX
@ APP_I2S_TYPE_MAX
Definition: app_i2s.h:90