PageRenderTime 26ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/Drivers/BSP/STM324xG_EVAL/stm324xg_eval_audio.h

https://gitlab.com/fascx/stm32f4_ex
C Header | 182 lines | 51 code | 32 blank | 99 comment | 0 complexity | 3d3f69902bc1486d5be161a137483e8a MD5 | raw file
  1. /**
  2. ******************************************************************************
  3. * @file stm324xg_eval_audio.h
  4. * @author MCD Application Team
  5. * @version V2.0.1
  6. * @date 26-February-2014
  7. * @brief This file contains the common defines and functions prototypes for
  8. * the stm324xg_eval_audio.c driver.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
  13. *
  14. * Redistribution and use in source and binary forms, with or without modification,
  15. * are permitted provided that the following conditions are met:
  16. * 1. Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. * 2. Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  22. * may be used to endorse or promote products derived from this software
  23. * without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  29. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  31. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  32. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  33. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ******************************************************************************
  37. */
  38. /* Define to prevent recursive inclusion -------------------------------------*/
  39. #ifndef __STM324xG_EVAL_AUDIO_H
  40. #define __STM324xG_EVAL_AUDIO_H
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. /* Includes ------------------------------------------------------------------*/
  45. #include "..\Components\cs43l22\cs43l22.h"
  46. #include "stm324xg_eval.h"
  47. /** @addtogroup BSP
  48. * @{
  49. */
  50. /** @addtogroup STM324xG_EVAL
  51. * @{
  52. */
  53. /** @defgroup stm324xg_eval_audio
  54. * @{
  55. */
  56. /** @defgroup stm324xg_eval_audio_Exported_Types
  57. * @{
  58. */
  59. /**
  60. * @}
  61. */
  62. /** @defgroup stm324xg_eval_audio_Exported_Constants
  63. * @{
  64. */
  65. /* Audio Reset Pin definition */
  66. #define AUDIO_RESET_PIN IO_PIN_2
  67. /* I2S peripheral configuration defines */
  68. #define AUDIO_I2Sx SPI2
  69. #define AUDIO_I2Sx_CLK_ENABLE() __SPI2_CLK_ENABLE()
  70. #define AUDIO_I2Sx_SCK_SD_WS_AF GPIO_AF5_SPI2
  71. #define AUDIO_I2Sx_SCK_SD_WS_CLK_ENABLE() __GPIOI_CLK_ENABLE()
  72. #define AUDIO_I2Sx_MCK_CLK_ENABLE() __GPIOC_CLK_ENABLE()
  73. #define AUDIO_I2Sx_WS_PIN GPIO_PIN_0
  74. #define AUDIO_I2Sx_SCK_PIN GPIO_PIN_1
  75. #define AUDIO_I2Sx_SD_PIN GPIO_PIN_3
  76. #define AUDIO_I2Sx_MCK_PIN GPIO_PIN_6
  77. #define AUDIO_I2Sx_SCK_SD_WS_GPIO_PORT GPIOI
  78. #define AUDIO_I2Sx_MCK_GPIO_PORT GPIOC
  79. /* I2S DMA Stream definitions */
  80. #define AUDIO_I2Sx_DMAx_CLK_ENABLE() __DMA1_CLK_ENABLE()
  81. #define AUDIO_I2Sx_DMAx_STREAM DMA1_Stream4
  82. #define AUDIO_I2Sx_DMAx_CHANNEL DMA_CHANNEL_0
  83. #define AUDIO_I2Sx_DMAx_IRQ DMA1_Stream4_IRQn
  84. #define AUDIO_I2Sx_DMAx_PERIPH_DATA_SIZE DMA_PDATAALIGN_HALFWORD
  85. #define AUDIO_I2Sx_DMAx_MEM_DATA_SIZE DMA_MDATAALIGN_HALFWORD
  86. #define DMA_MAX_SZE 0xFFFF
  87. #define AUDIO_I2Sx_DMAx_IRQHandler DMA1_Stream4_IRQHandler
  88. /*------------------------------------------------------------------------------
  89. CONFIGURATION: Audio Driver Configuration parameters
  90. ------------------------------------------------------------------------------*/
  91. /* Select the interrupt preemption priority for the DMA interrupt */
  92. #define AUDIO_IRQ_PREPRIO 5 /* Select the preemption priority level(0 is the highest) */
  93. #define AUDIODATA_SIZE 2 /* 16-bits audio data size */
  94. /* Audio status definition */
  95. #define AUDIO_OK 0x00
  96. #define AUDIO_ERROR 0x01
  97. #define AUDIO_TIMEOUT 0x02
  98. /*------------------------------------------------------------------------------
  99. OPTIONAL Configuration defines parameters
  100. ------------------------------------------------------------------------------*/
  101. /* Delay for the Codec to be correctly reset */
  102. #define CODEC_RESET_DELAY 5
  103. /**
  104. * @}
  105. */
  106. /** @defgroup stm324xg_eval_audio_Exported_Macros
  107. * @{
  108. */
  109. #define DMA_MAX(x) (((x) <= DMA_MAX_SZE)? (x):DMA_MAX_SZE)
  110. /**
  111. * @}
  112. */
  113. /** @defgroup stm324xg_eval_audio_Exported_Functions
  114. * @{
  115. */
  116. uint8_t BSP_AUDIO_OUT_Init(uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq);
  117. uint8_t BSP_AUDIO_OUT_Play(uint16_t* pBuffer, uint32_t Size);
  118. void BSP_AUDIO_OUT_ChangeBuffer(uint16_t *pData, uint16_t Size);
  119. uint8_t BSP_AUDIO_OUT_Pause(void);
  120. uint8_t BSP_AUDIO_OUT_Resume(void);
  121. uint8_t BSP_AUDIO_OUT_Stop(uint32_t Option);
  122. uint8_t BSP_AUDIO_OUT_SetVolume(uint8_t Volume);
  123. void BSP_AUDIO_OUT_SetFrequency(uint32_t AudioFreq);
  124. uint8_t BSP_AUDIO_OUT_SetMute(uint32_t Command);
  125. uint8_t BSP_AUDIO_OUT_SetOutputMode(uint8_t Output);
  126. /* User Callbacks: user has to implement these functions in his code if they are needed. */
  127. /* This function is called when the requested data has been completely transferred.*/
  128. void BSP_AUDIO_OUT_TransferComplete_CallBack(void);
  129. /* This function is called when half of the requested buffer has been transferred. */
  130. void BSP_AUDIO_OUT_HalfTransfer_CallBack(void);
  131. /* This function is called when an Interrupt due to transfer error on or peripheral
  132. error occurs. */
  133. void BSP_AUDIO_OUT_Error_CallBack(void);
  134. /**
  135. * @}
  136. */
  137. /**
  138. * @}
  139. */
  140. /**
  141. * @}
  142. */
  143. /**
  144. * @}
  145. */
  146. #ifdef __cplusplus
  147. }
  148. #endif
  149. #endif /* __STM324xG_EVAL_AUDIO_H */
  150. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/