5 #ifndef ___WAV_PLAYER_H 6 #define ___WAV_PLAYER_H 12 #define WAV_PLAYER_FILESYSTEM (1) 15 #define MISCCR2_DAC1SEL 0x0040 // Enable DAC1 drive output 16 #define MISCCR2_DAC0SEL 0x0020 // Enable DAC0 drive output 17 #define MISCCR2_ADCEN 0x0010 // Enable ADC 6-4 and 2-0 18 #define MISCCR2_ADC7EN 0x0008 // Enable ADC 7 19 #define MISCCR2_ADC3EN 0x0004 // Enable ADC 3 22 #define ADC_CAL_DAC1 0x0002 // Selects the source of the ADCA7 input as DAC1 output. 23 #define ADC_CAL_DAC0 0x0001 // Selects the source of the ADCA3 input as DAC0 output. 26 #define DAC_CR_RESET 0x1101 27 #define DAC_CR_FILT 0x1000 28 #define DAC_CR_WMLVL_M 0x0300 29 #define DAC_CR_WMLVL_S 8 30 #define DAC_CR_DMA 0x0080 31 #define DAC_CR_HSLS 0x0040 32 #define DAC_CR_UP 0x0020 33 #define DAC_CR_DOWN 0x0010 34 #define DAC_CR_AUTO 0x0008 35 #define DAC_CR_SYNC 0x0004 36 #define DAC_CR_FMT 0x0002 37 #define DAC_CR_PDN 0x0001 // Power down. 0 = power on, 1 = power down 41 #define DAC1_CH0 0x0000 // Source channel 0 42 #define DAC1_CH1 0x0800 // Source channel 1 43 #define DAC1_CH2 0x1000 // Source channel 2 44 #define DAC1_CH3 0x1800 // Source channel 3 46 #define DAC0_CH0 0x0000 // Source channel 0 47 #define DAC0_CH1 0x0008 // Source channel 1 48 #define DAC0_CH2 0x0010 // Source channel 2 49 #define DAC0_CH3 0x0018 // Source channel 3 52 #define DAC1_SRC_PWMA 0x0000 // PWMs 53 #define DAC1_SRC_PWMB 0x0100 54 #define DAC1_SRC_PWMX 0x0200 55 #define DAC1_SRC_PWMTRIG1 0x0300 56 #define DAC1_SRC_PWMTRIG0 0x0400 57 #define DAC1_SRC_TnOUT 0x0500 // Timers 58 #define DAC1_SRC_TnIN 0x0600 60 #define DAC0_SRC_PWMA 0x0000 // PWMs 61 #define DAC0_SRC_PWMB 0x0001 62 #define DAC0_SRC_PWMX 0x0002 63 #define DAC0_SRC_PWMTRIG1 0x0003 64 #define DAC0_SRC_PWMTRIG0 0x0004 65 #define DAC0_SRC_TnOUT 0x0005 // Timers 66 #define DAC0_SRC_TnIN 0x0006 69 #define EDMA_CH_DAC0 62 70 #define EDMA_CH_DAC1 63 71 #define EDMA_CH_DAC0_INT 0x40000000 72 #define EDMA_CH_DAC1_INT 0x80000000 74 #define TCD_POOL_SIZE 20 76 #define MAX_SAMPLE_RATE 100000 91 uint32_t SubChunkSize;
93 uint16_t ChannelCount;
97 uint16_t BitsPerSample;
103 uint32_t SubChunkSize;
158 struct channelControl {
161 uint16_t transfersRem;
162 uint16_t finalTransferSize;
164 volatile dacstruct *dac;
165 volatile edma_tcdstruct *tcd;
170 uint16_t BitsPerSample;
171 uint16_t ChannelCount;
175 struct initialPlaySettings {
177 uint16_t transfersRem;
178 uint16_t transferSize;
181 static WavPlayer *s_players[DAC_COUNT];
186 channelControl m_channel[DAC_COUNT];
187 initialPlaySettings m_initSettings[DAC_COUNT];
189 int m_playsRem[DAC_COUNT];
190 timerstruct timerSettings;
191 WAVFILE::WavFile *m_pWav;
192 WAVFILE::RIFFChunk *m_pWav_riff;
193 WAVFILE::formatChunk *m_pWav_fmt;
194 WAVFILE::dataChunk *m_pWav_data;
198 wavError PrepareData();
200 const uint8_t *FindChunk(
const char *chunkID,
const uint8_t *data, uint32_t dataLen);
201 wavError ParseHeader();
203 void PrepChunk_RIFF();
204 void PrepChunk_fmt();
205 void PrepChunk_data();
211 void ISR(
int channelNum );
217 static void RunISR( );
219 #ifdef WAV_PLAYER_FILESYSTEM 232 wavError OpenFile(
const char * fileName, uint8_t * dataBuffer, uint32_t bufferSize );
247 wavError OpenBuffer( uint8_t * data );
261 wavError SetChannelDAC(
int channel = 0,
int dacNum = 0);
272 wavError SetTimer(
int timerNum = 3 );
283 wavError Play(
OS_SEM *wavFinishedSem =
NULL);
294 wavError Loop( uint32_t playCount = 0,
OS_SEM *wavFinishedSem =
NULL );
305 wavError StopGraceful();
322 wavError ResetBuffer();
333 playState GetState();
NetBurner Real-Time Operating System API.
Semaphores are used to control access to shared resource critical section, or to communicate between ...
Definition: nbrtos.h:318
Definition: wavPlayer.h:79
#define NULL
Definition: nm_bsp.h:76