Microchip® Advanced Software Framework

unit_tests.c File Reference

Unit tests for I2S driver.

Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include <conf_test.h>
#include <string.h>

Macros

#define CMP_BLOCK   32
 
#define DMA_CH_FLAG_IN_L   (XDMAC_GS_ST0 << CONF_DMA_CH_IN_L)
 
#define DMA_CH_FLAG_IN_R   (XDMAC_GS_ST0 << CONF_DMA_CH_IN_R)
 
#define DMA_CH_FLAG_OUT_L   (XDMAC_GS_ST0 << CONF_DMA_CH_OUT_L)
 
#define DMA_CH_FLAG_OUT_R   (XDMAC_GS_ST0 << CONF_DMA_CH_OUT_R)
 
#define DMA_CH_FLAGS
 
#define DMA_DWIDTH   XDMAC_CC_DWIDTH_HALFWORD
 
#define SOUND_SAMPLES   0x100
 
#define TEST_OUT_LOOP   10
 

Functions

static bool check_samples (bool right)
 Return true if samples check is good. More...
 
static void config_dma_channel_xfr (uint8_t ch)
 
int main (void)
 Run I2SC driver unit tests. More...
 
static void prepare_dma_channel (uint8_t ch)
 
static void run_i2s_test (const struct test_case *test)
 Test audio data transfer and receive. More...
 
static void start_transfer (struct i2s_dev_inst *dev_inst)
 Start transfer for test. More...
 
static void stop_transfer (struct i2s_dev_inst *dev_inst)
 Stop transfer for test. More...
 
static void wait_transfer (struct i2s_dev_inst *dev_inst)
 Wait transfer done for test. More...
 

Variables

static const uint32_t g_dma_dst [4]
 
static const uint32_t g_dma_perid [4]
 
static const uint32_t g_dma_src [4]
 
int16_t input_samples_left [SOUND_SAMPLES *2]
 
int16_t input_samples_right [SOUND_SAMPLES *2]
 
int16_t off_cmp_left [SOUND_SAMPLES/CMP_BLOCK]
 
int16_t off_cmp_right [SOUND_SAMPLES/CMP_BLOCK]
 
int16_t output_samples_left [SOUND_SAMPLES *2]
 
int16_t output_samples_right [SOUND_SAMPLES *2]
 
static xdmac_channel_config_t xdmac_channel_cfg
 XDMA channel configuration. More...
 

#define CMP_BLOCK   32
#define DMA_CH_FLAG_IN_L   (XDMAC_GS_ST0 << CONF_DMA_CH_IN_L)
#define DMA_CH_FLAG_IN_R   (XDMAC_GS_ST0 << CONF_DMA_CH_IN_R)
#define DMA_CH_FLAG_OUT_L   (XDMAC_GS_ST0 << CONF_DMA_CH_OUT_L)
#define DMA_CH_FLAG_OUT_R   (XDMAC_GS_ST0 << CONF_DMA_CH_OUT_R)
#define DMA_CH_FLAGS
Value:
( 0\
)
#define DMA_CH_FLAG_IN_L
Definition: unit_tests.c:423
#define DMA_CH_FLAG_IN_R
Definition: unit_tests.c:425
#define DMA_CH_FLAG_OUT_R
Definition: unit_tests.c:424
#define DMA_CH_FLAG_OUT_L
Definition: unit_tests.c:422

Referenced by start_transfer(), stop_transfer(), and wait_transfer().

#define DMA_DWIDTH   XDMAC_CC_DWIDTH_HALFWORD

Referenced by config_dma_channel_xfr().

#define SOUND_SAMPLES   0x100
#define TEST_OUT_LOOP   10

static bool check_samples ( bool  right)
static
static void start_transfer ( struct i2s_dev_inst dev_inst)
static
static void stop_transfer ( struct i2s_dev_inst dev_inst)
static

Stop transfer for test.

References CONF_DMA, and DMA_CH_FLAGS.

Referenced by run_i2s_test().

static void wait_transfer ( struct i2s_dev_inst dev_inst)
static

Wait transfer done for test.

References DMA_CH_FLAGS.

Referenced by run_i2s_test().

const uint32_t g_dma_dst[4]
static
Initial value:
= {
(uint32_t)&CONF_I2SC->I2SC_THR,
(uint32_t)input_samples_left,
(uint32_t)&CONF_I2SC->I2SC_THR,
}
#define CONF_I2SC
Definition: conf_test.h:41
int16_t input_samples_left[SOUND_SAMPLES *2]
Definition: unit_tests.c:216
int16_t input_samples_right[SOUND_SAMPLES *2]
Definition: unit_tests.c:218
const uint32_t g_dma_perid[4]
static
Initial value:
= {
}
#define CONF_DMA_PERID_RX_L
Definition: conf_test.h:56
#define CONF_DMA_PERID_TX_L
Definition: conf_test.h:55
#define CONF_DMA_PERID_TX_R
Definition: conf_test.h:57
#define CONF_DMA_PERID_RX_R
Definition: conf_test.h:58
const uint32_t g_dma_src[4]
static
Initial value:
= {
(uint32_t)&CONF_I2SC->I2SC_RHR,
(uint32_t)&CONF_I2SC->I2SC_RHR
}
int16_t output_samples_left[SOUND_SAMPLES *2]
Definition: unit_tests.c:79
#define CONF_I2SC
Definition: conf_test.h:41
int16_t output_samples_right[SOUND_SAMPLES *2]
Definition: unit_tests.c:148
int16_t input_samples_left[SOUND_SAMPLES *2]

Referenced by check_samples().

int16_t input_samples_right[SOUND_SAMPLES *2]

Referenced by check_samples().

int16_t off_cmp_left[SOUND_SAMPLES/CMP_BLOCK]

Referenced by check_samples().

int16_t off_cmp_right[SOUND_SAMPLES/CMP_BLOCK]

Referenced by check_samples().

int16_t output_samples_left[SOUND_SAMPLES *2]

Referenced by check_samples().

int16_t output_samples_right[SOUND_SAMPLES *2]

Referenced by check_samples().

xdmac_channel_config_t xdmac_channel_cfg
static

XDMA channel configuration.