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
37
38
39
48
49
50
55
56
57
58
66
67
68
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/* ... */
#ifndef __AUDIOPLAYER_APP_H
#define __AUDIOPLAYER_APP_H
#ifdef __cplusplus
extern "C" {
#endif
#include "main.h"
#define MUTE_OFF 0x00
#define MUTE_ON 0x01
#define PLAY_ACTIVE 0x00
#define PAUSE_ACTIVE 0x01
#define AUDIO_BUFFER_SIZE (1024 * 8)
5 defines Exported constants
typedef enum
{
AUDIOPLAYER_STOP = 0,
AUDIOPLAYER_START,
AUDIOPLAYER_PLAY,
AUDIOPLAYER_PAUSE,
AUDIOPLAYER_EOF,
AUDIOPLAYER_ERROR,
...}AUDIOPLAYER_StateTypdef;
typedef enum
{
BUFFER_OFFSET_NONE = 0,
BUFFER_OFFSET_HALF,
BUFFER_OFFSET_FULL,
...}
BUFFER_StateTypeDef;
typedef enum
{
AUDIOPLAYER_ERROR_NONE = 0,
AUDIOPLAYER_ERROR_IO,
AUDIOPLAYER_ERROR_HW,
AUDIOPLAYER_ERROR_MEM,
AUDIOPLAYER_ERROR_FORMAT_NOTSUPPORTED,
...}AUDIOPLAYER_ErrorTypdef;
typedef struct
{
uint8_t buffer[AUDIO_BUFFER_SIZE];
uint32_t volume;
uint32_t mute;
AUDIOPLAYER_StateTypdef state;
...}AUDIOPLAYER_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 ;
Exported types
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_Init(void);
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_Play(uint32_t frequency);
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_Stop(void);
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_Pause(void);
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_Resume(void);
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_Mute(uint8_t state);
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_GetFileInfo(char* file, WAV_InfoTypedef* info);
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_SelectFile(char* file);
AUDIOPLAYER_StateTypdef AUDIOPLAYER_GetState(void);
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_Process(void);
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_DeInit(void);
uint32_t AUDIOPLAYER_GetProgress (void);
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_SetVolume(uint32_t volume);
uint32_t AUDIOPLAYER_GetVolume(void);
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_NotifyEndOfFile(void);
AUDIOPLAYER_ErrorTypdef AUDIOPLAYER_SetPosition(uint32_t position);
#ifdef __cplusplus
}extern "C" { ... }
#endif
/* ... */
#endif