1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 #ifndef __HAL_I2S_H__ 5 #define __HAL_I2S_H__ 6 7 #ifdef __cplusplus 8 extern "C" { 9 #endif 10 11 #include "plat_types.h" 12 #include "hal_aud.h" 13 #include "hal_cmu.h" 14 15 enum HAL_I2S_MODE_T { 16 HAL_I2S_MODE_NULL, 17 HAL_I2S_MODE_MASTER, 18 HAL_I2S_MODE_SLAVE, 19 }; 20 21 struct HAL_I2S_CONFIG_T { 22 bool use_dma; 23 bool chan_sep_buf; 24 bool master_clk_wait; 25 uint8_t cycles; 26 uint8_t bits; 27 uint8_t channel_num; 28 enum AUD_CHANNEL_MAP_T channel_map; 29 uint32_t sample_rate; 30 }; 31 32 int hal_i2s_open(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream, enum HAL_I2S_MODE_T mode); 33 int hal_i2s_close(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream); 34 int hal_i2s_start_stream(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream); 35 int hal_i2s_stop_stream(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream); 36 int hal_i2s_setup_stream(enum HAL_I2S_ID_T id, enum AUD_STREAM_T stream, const struct HAL_I2S_CONFIG_T *cfg); 37 int hal_i2s_send(enum HAL_I2S_ID_T id, const uint8_t *value, uint32_t value_len); 38 uint8_t hal_i2s_recv(enum HAL_I2S_ID_T id, uint8_t *value, uint32_t value_len); 39 40 //================================================================================ 41 // I2S Packet Mode 42 //================================================================================ 43 44 int hal_i2s_packet_open(void); 45 int hal_i2s_packet_close(void); 46 int hal_i2s_start_transfer(void); 47 int hal_i2s_stop_transfer(void); 48 49 #ifdef __cplusplus 50 } 51 #endif 52 53 #endif 54