#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"
Go to the source code of this file.
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 |
#define AUDIO_IN_PCM_BUFFER_SIZE_INT16 |
Definition at line 53 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define AUDIO_IN_PCM_BUFFER_SIZE_INT8 (2 * AUDIO_IN_PCM_BUFFER_SIZE_INT16) |
Definition at line 55 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_AUDIO_REC_AUDIO_FREQUENCY (kSAI_SampleRate16KHz) |
Definition at line 48 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_AUDIO_REC_BIT_WIDTH (kSAI_WordWidth16bits) |
Definition at line 51 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_AUDIO_REC_CHANNEL_NUMBER (2U) |
Definition at line 49 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_AUDIO_REC_MASTER_CLOCK (PV_SAI_CLK_FREQ) |
Definition at line 52 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_AUDIO_REC_RECORD_BUFFER_NUMBER (2U) |
Definition at line 56 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_AUDIO_REC_RECORD_BUFFER_SIZE (512U) |
Definition at line 50 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_DMA (DMA0) |
Definition at line 58 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_DMAMUX (DMAMUX) |
Definition at line 59 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_I2C (LPI2C1) |
Definition at line 43 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_I2C_CLK_FREQ ((CLOCK_GetFreq(kCLOCK_Usb1PllClk) / 8) / (PV_LPI2C_CLOCK_SOURCE_DIVIDER + 1U)) |
Definition at line 46 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_LPI2C_CLOCK_SOURCE_DIVIDER (5U) |
Definition at line 45 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_LPI2C_CLOCK_SOURCE_SELECT (0U) |
Definition at line 44 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_RX_EDMA_CHANNEL (1U) |
Definition at line 61 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI (SAI1) |
Definition at line 26 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI1_CLOCK_SOURCE_DIVIDER (63U) |
Definition at line 36 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI1_CLOCK_SOURCE_PRE_DIVIDER (0U) |
Definition at line 35 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI1_CLOCK_SOURCE_SELECT (2U) |
Definition at line 34 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI_CHANNEL (0) |
Definition at line 27 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI_CLK_FREQ |
Definition at line 37 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI_IRQ (SAI1_IRQn) |
Definition at line 28 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI_MASTER_SLAVE (kSAI_Master) |
Definition at line 33 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI_MCLK_OUTPUT (true) |
Definition at line 32 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI_RX_IRQ (SAI1_IRQn) |
Definition at line 41 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI_RX_SOURCE (kDmaRequestMuxSai1Rx) |
Definition at line 63 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI_RX_SYNC_MODE (kSAI_ModeSync) |
Definition at line 31 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI_TX_IRQ (SAI1_IRQn) |
Definition at line 40 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI_TX_SOURCE (kDmaRequestMuxSai1Tx) |
Definition at line 62 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAI_TX_SYNC_MODE (kSAI_ModeAsync) |
Definition at line 30 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_SAITxIRQHandler (SAI1_IRQHandler) |
Definition at line 29 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
#define PV_TX_EDMA_CHANNEL (0U) |
Definition at line 60 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
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 |
Definition at line 113 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
void pv_audio_rec_deinit | ( | void | ) |
Definition at line 216 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
const int16_t* pv_audio_rec_get_new_buffer | ( | void | ) |
Definition at line 202 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
pv_status_t pv_audio_rec_init | ( | void | ) |
Definition at line 125 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
pv_status_t pv_audio_rec_start | ( | void | ) |
Definition at line 186 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
pv_status_t pv_audio_rec_stop | ( | void | ) |
Definition at line 197 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
|
static |
Definition at line 91 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
uint32_t audio_frequency |
Definition at line 85 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
|
static |
Definition at line 73 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
|
static |
Definition at line 81 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
uint32_t channel_number |
Definition at line 84 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
|
static |
Definition at line 72 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
|
static |
Definition at line 75 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
|
static |
Definition at line 74 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
|
static |
Definition at line 71 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
bool is_recording |
Definition at line 88 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
|
static |
Definition at line 78 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
struct { ... } pv_audio_rec |
|
static |
Definition at line 79 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
uint32_t record_buffer_size |
Definition at line 86 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
uint8_t* record_pcm_buffer |
Definition at line 87 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
|
static |
Definition at line 77 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.
|
static |
Definition at line 80 of file imxrt1050/imxrt1050-evkb/source/pv_audio_rec.c.