summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/soc/i2s.h
blob: e2155a4bbe8c4a5ac53f2dd24ceff47bdfc081e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdint.h>

#include "i2s_def.h"

#define EOS_I2S_MODE_STEREO     0
#define EOS_I2S_MODE_MONO_L     1
#define EOS_I2S_MODE_MONO_R     2

typedef struct EOSABuf {
    uint16_t idx_r;
    uint16_t idx_w;
    uint16_t size;
    uint16_t *array;
} EOSABuf;

typedef void (*eos_i2s_handler_t) (unsigned char);

int eos_i2s_init(void);
int eos_i2s_start(uint32_t sample_rate, int mode);
void eos_i2s_stop(void);
int eos_i2s_running(void);
int eos_i2s_set_lsgain(int gain);

void eos_i2s_mic_set_handler(eos_i2s_handler_t handler, uint16_t wm);
void eos_i2s_mic_set_buf(uint16_t *mic_arr, uint16_t mic_arr_size);
uint16_t *eos_i2s_mic_get_buf(void);
uint16_t eos_i2s_mic_len(void);
uint16_t eos_i2s_mic_read(uint16_t *smpl_buf, uint16_t buf_size);
int eos_i2s_mic_pop(uint16_t *sample);
int eos_i2s_mic_get_vol(void);
void eos_i2s_mic_set_vol(int vol);

void eos_i2s_spk_set_handler(eos_i2s_handler_t handler, uint16_t wm);
void eos_i2s_spk_set_buf(uint16_t *spk_arr, uint16_t spk_arr_size);
uint16_t *eos_i2s_spk_get_buf(void);
uint16_t eos_i2s_spk_len(void);
uint16_t eos_i2s_spk_write(uint16_t *smpl_buf, uint16_t buf_len);
int eos_i2s_spk_push(uint16_t sample);
int eos_i2s_spk_get_vol(void);
void eos_i2s_spk_set_vol(int vol);

void eos_i2s_hp_change(int hp_det);