Macros | Functions | Variables
imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include "board.h"
#include "clock_config.h"
#include "fsl_codec_adapter.h"
#include "fsl_codec_common.h"
#include "fsl_dmamux.h"
#include "fsl_sai_edma.h"
#include "fsl_wm8960.h"
#include "picovoice.h"
Include dependency graph for imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c:

Go to the source code of this file.

Macros

#define AUDIO_IN_PCM_BUFFER_SIZE_INT16
 
#define AUDIO_IN_PCM_BUFFER_SIZE_INT8   (2 * AUDIO_IN_PCM_BUFFER_SIZE_INT16)
 
#define PV_AUDIO_REC_AUDIO_FREQUENCY   (kSAI_SampleRate16KHz)
 
#define PV_AUDIO_REC_BIT_WIDTH   (kSAI_WordWidth16bits)
 
#define PV_AUDIO_REC_CHANNEL_NUMBER   (2U)
 
#define PV_AUDIO_REC_MASTER_CLOCK   (PV_SAI_CLK_FREQ)
 
#define PV_AUDIO_REC_RECORD_BUFFER_NUMBER   (2U)
 
#define PV_AUDIO_REC_RECORD_BUFFER_SIZE   (512U)
 
#define PV_DMA   (DMA0)
 
#define PV_DMAMUX   (DMAMUX)
 
#define PV_I2C   (LPI2C1)
 
#define PV_I2C_CLK_FREQ   ((CLOCK_GetFreq(kCLOCK_Usb1PllClk) / 8) / (PV_LPI2C_CLOCK_SOURCE_DIVIDER + 1U))
 
#define PV_LPI2C_CLOCK_SOURCE_DIVIDER   (5U)
 
#define PV_LPI2C_CLOCK_SOURCE_SELECT   (0U)
 
#define PV_RX_EDMA_CHANNEL   (1U)
 
#define PV_SAI   (SAI1)
 
#define PV_SAI1_CLOCK_SOURCE_DIVIDER   (63U)
 
#define PV_SAI1_CLOCK_SOURCE_PRE_DIVIDER   (0U)
 
#define PV_SAI1_CLOCK_SOURCE_SELECT   (2U)
 
#define PV_SAI_CHANNEL   (0)
 
#define PV_SAI_CLK_FREQ
 
#define PV_SAI_IRQ   (SAI1_IRQn)
 
#define PV_SAI_MASTER_SLAVE   (kSAI_Master)
 
#define PV_SAI_MCLK_OUTPUT   (true)
 
#define PV_SAI_RX_IRQ   (SAI1_IRQn)
 
#define PV_SAI_RX_SOURCE   (kDmaRequestMuxSai1Rx)
 
#define PV_SAI_RX_SYNC_MODE   (kSAI_ModeSync)
 
#define PV_SAI_TX_IRQ   (SAI1_IRQn)
 
#define PV_SAI_TX_SOURCE   (kDmaRequestMuxSai1Tx)
 
#define PV_SAI_TX_SYNC_MODE   (kSAI_ModeAsync)
 
#define PV_SAITxIRQHandler   (SAI1_IRQHandler)
 
#define PV_TX_EDMA_CHANNEL   (0U)
 

Functions

 AT_NONCACHEABLE_SECTION_ALIGN (static int16_t ping_pong_buffer[PV_AUDIO_REC_RECORD_BUFFER_NUMBER][PV_AUDIO_REC_RECORD_BUFFER_SIZE], 4)
 
 AT_NONCACHEABLE_SECTION_ALIGN (static uint8_t record_pcm_buffer[AUDIO_IN_PCM_BUFFER_SIZE_INT8], 16)
 
 AT_NONCACHEABLE_SECTION_INIT (static sai_edma_handle_t txHandle)
 
static void BOARD_EnableSaiMclkOutput (bool enable)
 
void pv_audio_rec_deinit (void)
 
const int16_t * pv_audio_rec_get_new_buffer (void)
 
pv_status_t pv_audio_rec_init (void)
 
pv_status_t pv_audio_rec_start (void)
 
pv_status_t pv_audio_rec_stop (void)
 
static void rx_callback (I2S_Type *base, sai_edma_handle_t *handle, status_t status, void *userData)
 

Variables

static sai_transfer_t buffer_config = {0}
 
static volatile int32_t buffer_index = 0
 
static codec_handle_t codecHandle = {0}
 
static sai_transceiver_t config = {0}
 
static edma_config_t dmaConfig = {0}
 
static edma_handle_t dmaRxHandle = {0}
 
static int32_t last_read_index = -1
 
struct {
   uint32_t   audio_frequency
 
   uint32_t   channel_number
 
   bool   is_recording
 
   uint32_t   record_buffer_size
 
   uint8_t *   record_pcm_buffer
 
pv_audio_rec
 
static volatile int32_t read_index = 1
 
static bool rx_error = false
 
static volatile int32_t write_index = 0
 

Macro Definition Documentation

◆ AUDIO_IN_PCM_BUFFER_SIZE_INT16

#define AUDIO_IN_PCM_BUFFER_SIZE_INT16

◆ AUDIO_IN_PCM_BUFFER_SIZE_INT8

#define AUDIO_IN_PCM_BUFFER_SIZE_INT8   (2 * AUDIO_IN_PCM_BUFFER_SIZE_INT16)

◆ PV_AUDIO_REC_AUDIO_FREQUENCY

#define PV_AUDIO_REC_AUDIO_FREQUENCY   (kSAI_SampleRate16KHz)

◆ PV_AUDIO_REC_BIT_WIDTH

#define PV_AUDIO_REC_BIT_WIDTH   (kSAI_WordWidth16bits)

◆ PV_AUDIO_REC_CHANNEL_NUMBER

#define PV_AUDIO_REC_CHANNEL_NUMBER   (2U)

◆ PV_AUDIO_REC_MASTER_CLOCK

#define PV_AUDIO_REC_MASTER_CLOCK   (PV_SAI_CLK_FREQ)

◆ PV_AUDIO_REC_RECORD_BUFFER_NUMBER

#define PV_AUDIO_REC_RECORD_BUFFER_NUMBER   (2U)

◆ PV_AUDIO_REC_RECORD_BUFFER_SIZE

#define PV_AUDIO_REC_RECORD_BUFFER_SIZE   (512U)

◆ PV_DMA

#define PV_DMA   (DMA0)

◆ PV_DMAMUX

#define PV_DMAMUX   (DMAMUX)

◆ PV_I2C

#define PV_I2C   (LPI2C1)

◆ PV_I2C_CLK_FREQ

#define PV_I2C_CLK_FREQ   ((CLOCK_GetFreq(kCLOCK_Usb1PllClk) / 8) / (PV_LPI2C_CLOCK_SOURCE_DIVIDER + 1U))

◆ PV_LPI2C_CLOCK_SOURCE_DIVIDER

#define PV_LPI2C_CLOCK_SOURCE_DIVIDER   (5U)

◆ PV_LPI2C_CLOCK_SOURCE_SELECT

#define PV_LPI2C_CLOCK_SOURCE_SELECT   (0U)

◆ PV_RX_EDMA_CHANNEL

#define PV_RX_EDMA_CHANNEL   (1U)

◆ PV_SAI

#define PV_SAI   (SAI1)

◆ PV_SAI1_CLOCK_SOURCE_DIVIDER

#define PV_SAI1_CLOCK_SOURCE_DIVIDER   (63U)

◆ PV_SAI1_CLOCK_SOURCE_PRE_DIVIDER

#define PV_SAI1_CLOCK_SOURCE_PRE_DIVIDER   (0U)

◆ PV_SAI1_CLOCK_SOURCE_SELECT

#define PV_SAI1_CLOCK_SOURCE_SELECT   (2U)

◆ PV_SAI_CHANNEL

#define PV_SAI_CHANNEL   (0)

◆ PV_SAI_CLK_FREQ

#define PV_SAI_CLK_FREQ

◆ PV_SAI_IRQ

#define PV_SAI_IRQ   (SAI1_IRQn)

◆ PV_SAI_MASTER_SLAVE

#define PV_SAI_MASTER_SLAVE   (kSAI_Master)

◆ PV_SAI_MCLK_OUTPUT

#define PV_SAI_MCLK_OUTPUT   (true)

◆ PV_SAI_RX_IRQ

#define PV_SAI_RX_IRQ   (SAI1_IRQn)

◆ PV_SAI_RX_SOURCE

#define PV_SAI_RX_SOURCE   (kDmaRequestMuxSai1Rx)

◆ PV_SAI_RX_SYNC_MODE

#define PV_SAI_RX_SYNC_MODE   (kSAI_ModeSync)

◆ PV_SAI_TX_IRQ

#define PV_SAI_TX_IRQ   (SAI1_IRQn)

◆ PV_SAI_TX_SOURCE

#define PV_SAI_TX_SOURCE   (kDmaRequestMuxSai1Tx)

◆ PV_SAI_TX_SYNC_MODE

#define PV_SAI_TX_SYNC_MODE   (kSAI_ModeAsync)

◆ PV_SAITxIRQHandler

#define PV_SAITxIRQHandler   (SAI1_IRQHandler)

◆ PV_TX_EDMA_CHANNEL

#define PV_TX_EDMA_CHANNEL   (0U)

Function Documentation

◆ AT_NONCACHEABLE_SECTION_ALIGN() [1/2]

AT_NONCACHEABLE_SECTION_ALIGN ( static int16_t  ping_pong_buffer[PV_AUDIO_REC_RECORD_BUFFER_NUMBER][PV_AUDIO_REC_RECORD_BUFFER_SIZE],
 
)

◆ AT_NONCACHEABLE_SECTION_ALIGN() [2/2]

AT_NONCACHEABLE_SECTION_ALIGN ( static uint8_t  record_pcm_buffer[AUDIO_IN_PCM_BUFFER_SIZE_INT8],
16   
)

◆ AT_NONCACHEABLE_SECTION_INIT()

AT_NONCACHEABLE_SECTION_INIT ( static sai_edma_handle_t  txHandle)

◆ BOARD_EnableSaiMclkOutput()

static void BOARD_EnableSaiMclkOutput ( bool  enable)
static

◆ pv_audio_rec_deinit()

void pv_audio_rec_deinit ( void  )

◆ pv_audio_rec_get_new_buffer()

const int16_t* pv_audio_rec_get_new_buffer ( void  )

◆ pv_audio_rec_init()

pv_status_t pv_audio_rec_init ( void  )

◆ pv_audio_rec_start()

pv_status_t pv_audio_rec_start ( void  )

◆ pv_audio_rec_stop()

pv_status_t pv_audio_rec_stop ( void  )

◆ rx_callback()

static void rx_callback ( I2S_Type base,
sai_edma_handle_t handle,
status_t  status,
void *  userData 
)
static

Variable Documentation

◆ audio_frequency

uint32_t audio_frequency

◆ buffer_config

sai_transfer_t buffer_config = {0}
static

◆ buffer_index

volatile int32_t buffer_index = 0
static

◆ channel_number

uint32_t channel_number

◆ codecHandle

codec_handle_t codecHandle = {0}
static

◆ config

sai_transceiver_t config = {0}
static

◆ dmaConfig

edma_config_t dmaConfig = {0}
static

◆ dmaRxHandle

edma_handle_t dmaRxHandle = {0}
static

◆ is_recording

bool is_recording

◆ last_read_index

int32_t last_read_index = -1
static

◆ pv_audio_rec

struct { ... } pv_audio_rec

◆ read_index

volatile int32_t read_index = 1
static

◆ record_buffer_size

uint32_t record_buffer_size

◆ record_pcm_buffer

uint8_t* record_pcm_buffer

◆ rx_error

bool rx_error = false
static

◆ write_index

volatile int32_t write_index = 0
static
kCLOCK_AudioPllClk
@ kCLOCK_AudioPllClk
Definition: fsl_clock.h:434
PV_AUDIO_REC_AUDIO_FREQUENCY
#define PV_AUDIO_REC_AUDIO_FREQUENCY
Definition: imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c:48
PV_SAI1_CLOCK_SOURCE_PRE_DIVIDER
#define PV_SAI1_CLOCK_SOURCE_PRE_DIVIDER
Definition: imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c:35
PV_AUDIO_REC_CHANNEL_NUMBER
#define PV_AUDIO_REC_CHANNEL_NUMBER
Definition: imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c:49
PV_SAI1_CLOCK_SOURCE_DIVIDER
#define PV_SAI1_CLOCK_SOURCE_DIVIDER
Definition: imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c:36
CLOCK_GetFreq
uint32_t CLOCK_GetFreq(clock_name_t name)
Gets the clock frequency for a specific clock name.
Definition: fsl_clock.c:310


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:15:00