Microchip® Advanced Software Framework

sam/components/audio/codec/wm8731/unit_tests/unit_tests.c File Reference

Unit tests for WM8731 module.

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

#include <stdint.h>
#include <stdbool.h>
#include <board.h>
#include <sysclk.h>
#include <string.h>
#include <unit_test/suite.h>
#include <stdio_serial.h>
#include <conf_test.h>
#include "conf_board.h"
#include "conf_clock.h"
#include "conf_wm8731.h"
#include "wm8731.h"
#include "ssc.h"
#include "dmac.h"
#include "twi_master.h"

Macros

#define BITS_BY_SLOT   (16)
 Bits per slot. More...
 
#define DMA_CH   0
 
#define SAMPLE_RATE   (48000)
 Wav feature. More...
 
#define SLOT_BY_FRAME   (2)
 Wav slot per frame. More...
 
#define WAV_LENGTH   (0xA0u)
 Bits per slot. More...
 

Functions

void DMAC_Handler (void)
 ISR for DMA interrupt. More...
 
static void init_dac (void)
 Initial the codec for audio play. More...
 
static void init_dma (void)
 DMA driver configuration. More...
 
static void init_ssc (void)
 Initial the ssc interface. More...
 
static void init_twi_wm8731 (void)
 
int main (void)
 Run WM8731 module unit tests. More...
 
static void run_wm8731_transfer_test (const struct test_case *test)
 WM8731 transfer test. More...
 
static void ssc_dma (void *p_buffer, uint16_t us_size)
 Start DMA sending data. More...
 

Variables

volatile uint32_t ul_transfer_done = 0
 Transfer done flag. More...
 
const uint8_t wav_data [WAV_LENGTH]
 wav data from the file "sample.wav" More...
 

#define BITS_BY_SLOT   (16)

Bits per slot.

Referenced by init_ssc().

#define DMA_CH   0

Referenced by DMAC_Handler(), init_dma(), and ssc_dma().

#define SAMPLE_RATE   (48000)

Wav feature.

Referenced by init_ssc().

#define SLOT_BY_FRAME   (2)

Wav slot per frame.

#define WAV_LENGTH   (0xA0u)

Bits per slot.

Referenced by run_wm8731_transfer_test().

void DMAC_Handler ( void  )
static void run_wm8731_transfer_test ( const struct test_case test)
static

WM8731 transfer test.

Parameters
testCurrent test case.

References ssc_dma(), test_assert_true, ul_transfer_done, wav_data, and WAV_LENGTH.

Referenced by main().

static void ssc_dma ( void *  p_buffer,
uint16_t  us_size 
)
static

volatile uint32_t ul_transfer_done = 0

Transfer done flag.

Referenced by DMAC_Handler(), and run_wm8731_transfer_test().

const uint8_t wav_data[WAV_LENGTH]
Initial value:
= {
0xd8, 0x01, 0x06, 0x01, 0xd4, 0x01, 0x0e, 0x01,
0xd2, 0x01, 0x18, 0x01, 0xd3, 0x01, 0x20, 0x01,
0xcd, 0x01, 0x21, 0x01, 0xca, 0x01, 0x23, 0x01,
0xc6, 0x01, 0x2a, 0x01, 0xbe, 0x01, 0x2d, 0x01,
0xb7, 0x01, 0x30, 0x01, 0xb4, 0x01, 0x38, 0x01,
0xb2, 0x01, 0x39, 0x01, 0xae, 0x01, 0x3c, 0x01,
0xae, 0x01, 0x45, 0x01, 0xaa, 0x01, 0x43, 0x01,
0xa4, 0x01, 0x3e, 0x01, 0x9d, 0x01, 0x3b, 0x01,
0x8c, 0x01, 0x30, 0x01, 0x81, 0x01, 0x29, 0x01,
0x81, 0x01, 0x27, 0x01, 0x81, 0x01, 0x23, 0x01,
0x82, 0x01, 0x1d, 0x01, 0x84, 0x01, 0x1c, 0x01,
0x80, 0x01, 0x19, 0x01, 0x7e, 0x01, 0x17, 0x01,
0x7d, 0x01, 0x12, 0x01, 0x77, 0x01, 0x0c, 0x01,
0x78, 0x01, 0x0a, 0x01, 0x7a, 0x01, 0x0b, 0x01,
0x78, 0x01, 0x04, 0x01, 0x75, 0x01, 0xff, 0x00,
0x77, 0x01, 0x04, 0x01, 0x73, 0x01, 0x09, 0x01,
0x6f, 0x01, 0x0b, 0x01, 0x6f, 0x01, 0x0c, 0x01,
0x71, 0x01, 0x08, 0x01, 0x74, 0x01, 0x10, 0x01
}

wav data from the file "sample.wav"

Referenced by run_wm8731_transfer_test().