Bouffalo SDK  1.0
Bouffalolab Software Development Kit
bflb_i2s.h
Go to the documentation of this file.
1 #ifndef _BFLB_I2S_H
2 #define _BFLB_I2S_H
3 
4 #include "bflb_core.h"
5 
17 #define I2S_ROLE_MASTER 0
18 #define I2S_ROLE_SLAVE 1
19 
26 #define I2S_MODE_LEFT_JUSTIFIED 0 /* left-justified or Phillips standard */
27 #define I2S_MODE_RIGHT_JUSTIFIED 1 /* right-justified */
28 #define I2S_MODE_DSP_SHORT_FRAME_SYNC 2 /* dsp modeA/B short frame sync */
29 #define I2S_MODE_DSP_LONG_FRAME_SYNC 3 /* dsp modeA/B long frame sync */
30 
37 #define I2S_CHANNEL_MODE_NUM_1 0
38 #define I2S_CHANNEL_MODE_NUM_2 1
39 #define I2S_CHANNEL_MODE_NUM_3 2 /* only DSP mode, frame_size must equal data_size */
40 #define I2S_CHANNEL_MODE_NUM_4 3 /* only DSP mode, frame_size must equal data_size */
41 #define I2S_CHANNEL_MODE_NUM_6 4 /* only DSP mode, frame_size must equal data_size */
42 
49 #define I2S_SLOT_WIDTH_8 0
50 #define I2S_SLOT_WIDTH_16 1
51 #define I2S_SLOT_WIDTH_24 2
52 #define I2S_SLOT_WIDTH_32 3
53 
60 #define I2S_INTSTS_TX_FIFO (1 << 1)
61 #define I2S_INTSTS_RX_FIFO (1 << 2)
62 #define I2S_INTSTS_FIFO_ERR (1 << 3)
63 
70 #define I2S_CMD_CLEAR_TX_FIFO (0x01)
71 #define I2S_CMD_CLEAR_RX_FIFO (0x02)
72 #define I2S_CMD_RX_DEGLITCH (0x03)
73 #define I2S_CMD_DATA_ENABLE (0x04)
74 #define I2S_CMD_CHANNEL_LR_MERGE (0x05)
75 #define I2S_CMD_CHANNEL_LR_EXCHG (0x06)
76 #define I2S_CMD_MUTE (0x07)
77 #define I2S_CMD_BIT_REVERSE (0x08)
78 
85 #define I2S_CMD_DATA_ENABLE_TX (1 << 1)
86 #define I2S_CMD_DATA_ENABLE_RX (1 << 2)
87 
106  uint32_t bclk_freq_hz;
107  uint8_t role;
108  uint8_t format_mode;
109  uint8_t channel_mode;
110  uint8_t frame_width;
111  uint8_t data_width;
113 
116 };
117 
118 #ifdef __cplusplus
119 extern "C" {
120 #endif
121 
128 void bflb_i2s_init(struct bflb_device_s *dev, const struct bflb_i2s_config_s *config);
129 
135 void bflb_i2s_deinit(struct bflb_device_s *dev);
136 
143 void bflb_i2s_link_txdma(struct bflb_device_s *dev, bool enable);
144 
151 void bflb_i2s_link_rxdma(struct bflb_device_s *dev, bool enable);
152 
159 void bflb_i2s_txint_mask(struct bflb_device_s *dev, bool mask);
160 
167 void bflb_i2s_rxint_mask(struct bflb_device_s *dev, bool mask);
168 
175 void bflb_i2s_errint_mask(struct bflb_device_s *dev, bool mask);
176 
183 uint32_t bflb_i2s_get_intstatus(struct bflb_device_s *dev);
184 
193 int bflb_i2s_feature_control(struct bflb_device_s *dev, int cmd, size_t arg);
194 
195 #ifdef __cplusplus
196 }
197 #endif
198 
207 #endif
I2S configuration structure.
Definition: bflb_i2s.h:105
uint8_t fs_offset_cycle
Definition: bflb_i2s.h:112
int bflb_i2s_feature_control(struct bflb_device_s *dev, int cmd, size_t arg)
Control i2s feature.
void bflb_i2s_link_txdma(struct bflb_device_s *dev, bool enable)
Enable i2s tx dma.
uint32_t bflb_i2s_get_intstatus(struct bflb_device_s *dev)
Get i2s interrupt status.
void bflb_i2s_init(struct bflb_device_s *dev, const struct bflb_i2s_config_s *config)
Initialize i2s.
void bflb_i2s_txint_mask(struct bflb_device_s *dev, bool mask)
Enable or disable i2s rx fifo threhold interrupt.
uint8_t frame_width
Definition: bflb_i2s.h:110
uint8_t format_mode
Definition: bflb_i2s.h:108
void bflb_i2s_link_rxdma(struct bflb_device_s *dev, bool enable)
Enable i2s rx dma.
void bflb_i2s_rxint_mask(struct bflb_device_s *dev, bool mask)
Enable or disable i2s rx fifo threhold interrupt.
void bflb_i2s_deinit(struct bflb_device_s *dev)
Deinitialize i2s.
uint8_t rx_fifo_threshold
Definition: bflb_i2s.h:115
void bflb_i2s_errint_mask(struct bflb_device_s *dev, bool mask)
Enable or disable i2s error interrupt.
uint32_t bclk_freq_hz
Definition: bflb_i2s.h:106
uint8_t channel_mode
Definition: bflb_i2s.h:109
uint8_t data_width
Definition: bflb_i2s.h:111
uint8_t tx_fifo_threshold
Definition: bflb_i2s.h:114