micCapture_saiPdm.c
Go to the documentation of this file.
1 /*
2 * This software component is licensed by ST under Ultimate Liberty license
3 * SLA0044, the "License"; You may not use this file except in compliance with
4 * the License. You may obtain a copy of the License at:
5 * www.st.com/SLA0044
6 *
7 */
8 
9 #include "micCapture_saiPdm.h"
10 #include "pdm2pcm.h"
11 #include "micCapture_task.h"
12 #include "stdio.h"
13 #define MIC_CAPTURE_PDM_BUFF_SIZE_BYTES (MIC_CAPTURE_IT_MS * 2 * 2048 / 8) /* 256 kHz frequency expected on SAI ; 2x for pingPong */
14 #define MIC_CAPTURE_PCM_BUFF_SIZE_SAMPLES (MIC_CAPTURE_IT_MS * 16) /* ms @16kHz */
15 #define MIC_CAPTURE_MEMORY_SECTION_HW_BUFFERS ".NOCACHE_Section"
16 
17 
18 
19 #if defined ( __ICCARM__ )
20  #pragma data_alignment=4
21  #ifdef MIC_CAPTURE_MEMORY_SECTION_HW_BUFFERS
23  #else
24  __ALIGN_BEGIN uint8_t PDM_Buffer[MIC_CAPTURE_PDM_BUFF_SIZE_BYTES] __ALIGN_END;
25  #endif
26 
27 
28 #else /* keil & (__GNUC__)*/
30  __ALIGN_BEGIN uint8_t PDM_Buffer[MIC_CAPTURE_PDM_BUFF_SIZE_BYTES] __ALIGN_END;
31 #endif
32 
34 
35 
36 
37 int mic_capture_start(void)
38 {
41 }
42 
43 
51 {
52  /* Call the record update function to get the second half */
53  /* Invalidate Data Cache to get the updated content of the SRAM*/
55  MX_PDM2PCM_Process((uint16_t *)PDM_Buffer, (uint16_t *)PCM_Buffer);
57 }
58 
59 
61 {
62  /* Call the record update function to get the second half */
63  /* Invalidate Data Cache to get the updated content of the SRAM*/
65  MX_PDM2PCM_Process((uint16_t *)(&PDM_Buffer[MIC_CAPTURE_PDM_BUFF_SIZE_BYTES / 2]), (uint16_t *)PCM_Buffer);
67 }
68 
69 
71 {
72  /* Prevent unused argument(s) compilation warning */
73  UNUSED(hsai);
74  while (1);
75  /* NOTE : This function should not be modified, when the callback is needed,
76  the HAL_SAI_ErrorCallback could be implemented in the user file
77  */
78 }
micCapture_saiPdm.h
MX_PDM2PCM_Process
uint8_t MX_PDM2PCM_Process(uint16_t *PDMBuf, uint16_t *PCMBuf)
Definition: pdm2pcm.c:63
pdm2pcm.h
HAL_SAI_RxHalfCpltCallback
void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai)
Re targets the C library printf function to the USART.
Definition: micCapture_saiPdm.c:50
__ALIGN_END
#define __ALIGN_END
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:131
hsai_BlockA4
SAI_HandleTypeDef hsai_BlockA4
Definition: stm32h735/stm32h735g-dk/Src/pv_audio_rec.c:39
HAL_SAI_ErrorCallback
void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai)
SAI error callbacks.
Definition: micCapture_saiPdm.c:70
PCM_Buffer
int16_t PCM_Buffer[]
mic_capture_createTask
void mic_capture_createTask(void)
creates task for AudioIn capture
Definition: micCapture_task.c:86
UNUSED
#define UNUSED(x)
Definition: porcupine/demo/c/dr_libs/old/dr.h:92
__attribute__
__attribute__((__section__(MIC_CAPTURE_MEMORY_SECTION_HW_BUFFERS)))
Definition: micCapture_saiPdm.c:29
__SAI_HandleTypeDef
Definition: stm32f7xx_hal_sai.h:191
MIC_CAPTURE_PDM_BUFF_SIZE_BYTES
#define MIC_CAPTURE_PDM_BUFF_SIZE_BYTES
Definition: micCapture_saiPdm.c:13
MIC_CAPTURE_PCM_BUFF_SIZE_SAMPLES
#define MIC_CAPTURE_PCM_BUFF_SIZE_SAMPLES
Definition: micCapture_saiPdm.c:14
mic_capture_processTask
void mic_capture_processTask(void)
sends AudioIn Pushed message
Definition: micCapture_task.c:63
HAL_SAI_RxCpltCallback
void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai)
Reception complete callback.
Definition: micCapture_saiPdm.c:60
HAL_SAI_Receive_DMA
HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size)
micCapture_task.h
SCB_InvalidateDCache_by_Addr
__STATIC_FORCEINLINE void SCB_InvalidateDCache_by_Addr(void *addr, int32_t dsize)
D-Cache Invalidate by address.
Definition: imxrt1050/imxrt1050-evkb/CMSIS/core_cm7.h:2512
mic_capture_start
int mic_capture_start(void)
MIC_CAPTURE_MEMORY_SECTION_HW_BUFFERS
#define MIC_CAPTURE_MEMORY_SECTION_HW_BUFFERS
Definition: micCapture_saiPdm.c:15


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:13:56