ARMEBS4  revision-26.06.2015
audio_stm32.h
1 /************************************************************************//**
2  * \file heivs/AudioSTM32_stm32.h
3  * \brief ARMEBS4 audio for stm32
4  * \author marc dot pignat at hevs dot ch & Pascal Sartoretti (sap at hevs dot ch)
5  * \addtogroup libheivs_stm32_audio Audio
6  * \ingroup libheivs_stm32
7  * @{
8  ***************************************************************************/
9 
10 #ifndef HEIVS_AUDIO_STM32_H
11 #define HEIVS_AUDIO_STM32_H
12 
13 #include "heivs/error.h"
14 
15 #ifdef __cplusplus
16  extern "C" {
17 #endif
18 
19 status_e AudioSTM32_Init(uint32_t fs, uint32_t sample_size);
20 status_e AudioSTM32_Record(int16_t * dataBuf, uint32_t length);
21 
22 /************************************************************************//**
23  * \brief Play a sound (polling mode)
24  * \param dataBuf Data buffer of sound to record
25  * \param length byte length of the buffer
26  * \return NO_ERROR for no problem
27  ***************************************************************************/
28 status_e AudioSTM32_Play(const int16_t *dataBuf, uint32_t length);
29 
30 /************************************************************************//**
31  * \brief Audio stream initialization
32  * \param length byte length of each buffer
33  * \param buffer0 the first buffer to be played
34  * \param buffer1 the second buffer to be played
35  * \return NO_ERROR for no problem
36  *
37  * \warning buffer0 and buffer1 are expected to exist until \see AudioSTM32_Stream_Stop
38  *
39  * The DMA will play alternatively buffer0 and buffer1. \see AudioSTM32_Stream_Play
40  * will be used to replace the next buffer.
41  ***************************************************************************/
42 status_e AudioSTM32_Stream_Play_Init(uint32_t length, void *buffer0, void *buffer1, void (*done)(const void *));
43 
44 /************************************************************************//**
45  * \brief Audio stream play buffer
46  * \param data buffer to be played
47  * \return NO_ERROR for no problem
48  *
49  * \see AudioSTM32_Stream_Status
50  *
51  * \warning This function is blocking unless AudioSTM32_Stream_Status has returned NO_ERROR
52  ***************************************************************************/
53 status_e AudioSTM32_Stream_Play(const void *data);
54 status_e AudioSTM32_Stream_Play_Pause(void);
55 
56 /************************************************************************//**
57  * \brief Audio stream stop
58  * \return NO_ERROR for no problem
59  ***************************************************************************/
61 
62 /************************************************************************//**
63  * \brief Is AudioSTM32_Stream_Play ready for the next buffer?
64  * \return ERROR_AGAIN if not ready, NO_ERROR when ready
65  * \see AudioSTM32_DMA_Play
66  ***************************************************************************/
68 
69 status_e AudioSTM32_Stream_Record_Init(uint32_t length, void *buffer0, void *buffer1, void (*done)(const void*));
70 status_e AudioSTM32_Stream_Record_Stop(void);
71 
72 #ifdef __cplusplus
73  }
74 #endif
75 
76 /**
77  * @}
78  */
79 #endif /* HEIVS_AUDIO_STM32_H */
status_e AudioSTM32_Stream_Play_Status(void)
Is AudioSTM32_Stream_Play ready for the next buffer?
Definition: audio_stm32.c:469
status_e AudioSTM32_Stream_Play_Stop(void)
Audio stream stop.
Definition: audio_stm32.c:462
Errors definitions.
status_e AudioSTM32_Stream_Play(const void *data)
Audio stream play buffer.
Definition: audio_stm32.c:479
status_e AudioSTM32_Stream_Play_Init(uint32_t length, void *buffer0, void *buffer1, void(*done)(const void *))
Audio stream initialization.
Definition: audio_stm32.c:403
status_e
Known errors.
Definition: error.h:21
status_e AudioSTM32_Play(const int16_t *dataBuf, uint32_t length)
Play a sound (polling mode)
Definition: audio_stm32.c:523