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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
58
59
60
61
62
71
72
77
78
82
83
88
89
90
91
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/* ... */
#ifndef __AUDIO_IF_H
#define __AUDIO_IF_H
#ifdef __cplusplus
extern "C" {
#endif
#include "main.h"
#define AUDIO_OUT_BUFFER_SIZE (24 * 1024)
#define AUDIO_IN_BUFFER_SIZE (24 * 1024)
#define AUDIO_IN_PDM_BUFFER_SIZE (256)
Exported constants
typedef enum
{
AUDIO_RECORDER_IDLE = 0,
AUDIO_RECORDER_SUSPENDED = 1,
AUDIO_RECORDER_RECORDING = 2,
AUDIO_RECORDER_PLAYING = 3,
AUDIO_RECORDER_RECORD_PAUSE = 4,
AUDIO_RECORDER_PLAY_PAUSE = 5,
AUDIO_RECORDER_RECORD_EOF = 6,
AUDIO_RECORDER_PLAY_EOF = 7,
AUDIO_RECORDER_ERROR = 0xFF,
...}IN_StateTypdef;
typedef enum
{
BUFFER_OFFSET_NONE = 0,
REC_BUFFER_OFFSET_HALF,
REC_BUFFER_OFFSET_FULL,
PLAY_BUFFER_OFFSET_HALF,
PLAY_BUFFER_OFFSET_FULL,
...}
BUFFER_StateTypeDef;
typedef enum
{
AUDIOPLAYER_STOP = 0,
AUDIOPLAYER_START,
AUDIOPLAYER_PLAY,
AUDIOPLAYER_PAUSE,
AUDIOPLAYER_EOF,
AUDIOPLAYER_ERROR,
...}OUT_StateTypdef;
typedef struct {
uint32_t volume;
uint32_t mute;
OUT_StateTypdef state;
...}OUT_Process_t;
typedef enum {
BUFFER_EMPTY = 0,
BUFFER_FULL,
...}WR_BUFFER_StateTypeDef;
typedef struct {
uint32_t volume;
uint32_t fptr;
IN_StateTypdef state;
...}IN_Process_t;
#define INTERNAL_BUFF_SIZE (128*DEFAULT_AUDIO_IN_FREQ/16000*DEFAULT_AUDIO_IN_CHANNEL_NBR)
typedef struct
{
uint8_t buff[AUDIO_OUT_BUFFER_SIZE];
uint16_t pdm[AUDIO_IN_PDM_BUFFER_SIZE];
uint32_t ppcm;
OUT_Process_t out;
IN_Process_t in;
...}AUDIO_ProcessTypdef ;
typedef struct
{
uint32_t ChunkID;
uint32_t FileSize;
uint32_t FileFormat;
uint32_t SubChunk1ID;
uint32_t SubChunk1Size;
uint16_t AudioFormat;
uint16_t NbrChannels;
uint32_t SampleRate;
uint32_t ByteRate;
uint16_t BlockAlign;
uint16_t BitPerSample;
uint32_t SubChunk2ID;
uint32_t SubChunk2Size;
...}WAV_InfoTypedef ;
typedef struct
{
void (*TransferComplete_CallBack)(void);
void (*HalfTransfer_CallBack)(void);
void (*Error_CallBack)(void);
...}AUDIO_IFTypeDef;
typedef void (*pFunc)(void);
Exported types
extern AUDIO_ProcessTypdef haudio;
void AUDIO_IF_RegisterCallbacks(pFunc tc_cb,
pFunc ht_cb,
pFunc err_cb);
#ifdef __cplusplus
}extern "C" { ... }
#endif
/* ... */
#endif