vs1053_avr_renesas_uno 0.1.0
Arduino Library for VS1053 shield
Loading...
Searching...
No Matches
vs1053_avr_renesas_uno.h
Go to the documentation of this file.
1
8
9#ifndef vs1053_avr_renesas_uno_h
10#define vs1053_avr_renesas_uno_h
11
12// Include libraries.
14#include "SPI.h"
15
16// Not neccessary, but just in case.
17#if (ARDUINO >= 100)
18#include <Arduino.h>
19#else
20#include <WProgram.h>
21#endif
22
23// Add the SdFat Libraries.
24#include <SdFat.h>
25//#include <SdFatUtil.h>
26
27
45
53enum flush_m {
54
61
68
75
82 }; // enum flush_m
83
84//------------------------------------------------------------------------------
89
96extern SdFat sd;
97
105extern int8_t irq;
106
110
111//------------------------------------------------------------------------------
116
126#define SCI_MODE 0x00
127
134#define SCI_STATUS 0x01
135
143#define SCI_BASS 0x02
144
150#define SCI_CLOCKF 0x03
151
164#define SCI_DECODE_TIME 0x04
165
175#define SCI_AUDATA 0x05
176
187#define SCI_WRAM 0x06
188
195#define SCI_WRAMADDR 0x07
196
208#define SCI_HDAT0 0x08
209
221#define SCI_HDAT1 0x09
222
233#define SCI_AIADDR 0x0A
234
247#define SCI_VOL 0x0B
248
255#define SCI_AICTRL0 0x0C
256
263#define SCI_AICTRL1 0x0D
264
271#define SCI_AICTRL2 0x0E
272
279#define SCI_AICTRL3 0x0F
280
284
285//------------------------------------------------------------------------------
290
297#define SM_DIFF 0x0001
298
306#define SM_LAYER12 0x0002
307
313#define SM_RESET 0x0004
314
323#define SM_CANCEL 0x0008
324
334#define SM_EARSPEAKER_LO 0x0010
335
345#define SM_TESTS 0x0020
346
352#define SM_STREAM 0x0040
353
364#define SM_EARSPEAKER_HI 0x0080
365
372#define SM_DACT 0x0100
373
383#define SM_SDIORD 0x0200
384
393#define SM_SDISHARE 0x0400
394
403#define SM_SDINEW 0x0800
404
411#define SM_ADPCM 0x1000
412
423#define SM_PAUSE 0x2000 // note: Only availble with patch. This only quickly pauses the VS's internal buffer, when canceling quickly. It won't unpause.
424
433#define SM_LINE1 0x4000
434
442#define SM_CLK_RANGE 0x8000
443
455// configure Line1 as single ended, otherwise as differential 10x gain for microphones.
456#define VS_LINE1_MODE
457
461
462//------------------------------------------------------------------------------
467
476#define SS_VU_ENABLE 0x0200
477
481
482//------------------------------------------------------------------------------
487
497#define para_chipID_0 0x1E00
498
508#define para_chipID_1 0x1E01
509
518#define para_version 0x1E02
519
530#define para_config1 0x1E03
531
540#define para_playSpeed 0x1E04
541
554#define para_byteRate 0x1E05
555
569#define para_endFillByte 0x1E06
570
583#define para_MonoOutput 0x1E09
584
596
597#define para_positionMsec_0 0x1E27
598
610#define para_positionMsec_1 0x1E28
611
622#define para_resync 0x1E29
623
627
628#define TRUE 1
629#define FALSE 0
630
631//------------------------------------------------------------------------------
636
645#define TRACK_TITLE 3
654#define TRACK_ARTIST 33
655
664#define TRACK_ALBUM 63
665
669
670//------------------------------------------------------------------------------
675class vs1053 {
676 public:
677 uint8_t begin();
678 void end();
679 uint8_t vs_init();
680 void setVolume(uint8_t, uint8_t);
681 void setVolume(uint16_t);
682 void setVolume(uint8_t);
683 uint16_t getTrebleFrequency();
684 int8_t getTrebleAmplitude();
685 uint16_t getBassFrequency();
686 int8_t getBassAmplitude();
687 void setTrebleFrequency(uint16_t);
688 void setTrebleAmplitude(int8_t);
689 void setBassFrequency(uint16_t);
690 void setBassAmplitude(uint8_t);
691 void setPlaySpeed(uint16_t);
692 uint16_t getPlaySpeed();
693 uint16_t getVolume();
694 uint8_t getEarSpeaker();
696 void setEarSpeaker(uint16_t);
697 uint16_t getMonoMode();
698 void setMonoMode(uint16_t );
699 void setDifferentialOutput(uint16_t);
700 uint8_t getDifferentialOutput();
701 uint8_t playTrack(uint8_t);
702 uint8_t playMP3(char*, uint32_t timecode = 0);
703 void trackTitle(char*);
704 void trackArtist(char*);
705 void trackAlbum(char*);
706 void stopTrack();
707 uint8_t isPlaying();
708 uint8_t skip(int32_t);
709 uint8_t skipTo(uint32_t);
710 uint32_t currentPosition();
711 void setBitRate(uint16_t);
712 void pauseDataStream();
713 void resumeDataStream();
714 void pauseMusic();
715 bool resumeMusic();
716 uint8_t resumeMusic(uint32_t);
717 static void available();
718 void getAudioInfo();
719 uint8_t enableTestSineWave(uint8_t);
720 uint8_t disableTestSineWave();
721 uint16_t memoryTest();
722 uint8_t ADMixerLoad(char*);
723 void ADMixerVol(int8_t);
724 int8_t getVUmeter();
725 int8_t setVUmeter(int8_t);
726 int16_t getVUlevel();
727 void SendSingleMIDInote();
728
729 private:
730 static SdFile track;
731 static void refill();
732 static void flush_cancel(flush_m);
733 static void spiInit();
734 static void cs_low();
735 static void cs_high();
736 static void dcs_low();
737 static void dcs_high();
738 static void Mp3WriteRegister(uint8_t, uint8_t, uint8_t);
739 static void Mp3WriteRegister(uint8_t, uint16_t);
740 static uint16_t Mp3ReadRegister (uint8_t);
741 static uint16_t Mp3ReadWRAM(uint16_t);
742 static void Mp3WriteWRAM(uint16_t, uint16_t);
743 void getTrackInfo(uint8_t, char*);
744 static void enableRefill();
745 static void disableRefill();
746 void getBitRateFromMP3File(char*);
747 uint8_t VSLoadUserCode(char*);
748
749 // Create the variables to be used by SdFat Library.
750
753
755 static uint32_t spi_Max_Rate;
756
758 static uint8_t mp3DataBuffer[32];
759
761 uint8_t bitrate;
762
765
767 uint8_t VolL;
768
770 uint8_t VolR;
771
779
785 uint16_t word;
786
792 struct {
793 uint8_t Bass_Freqlimt : 4; // 0..3
794 uint8_t Bass_Amplitude : 4; // 4..7
795 uint8_t Treble_Freqlimt : 4; // 8..11
796 int8_t Treble_Amplitude : 4; // 12..15
798 } ;
799};
800
801//------------------------------------------------------------------------------
802/*
803 * Global Functions.
804 */
805char* strip_nonalpha_inplace(char *s);
806bool isFnMusic(char*);
807
808//------------------------------------------------------------------------------
809/*
810 * Global Unions.
811 */
812
827union twobyte {
828
834 uint16_t word;
835
842 uint8_t byte[2];
843} ;
844
845#endif // vs1053_avr_renesas_uno_h
Interface Driver to the VS10xx chip on the SPI.
static void Mp3WriteWRAM(uint16_t, uint16_t)
Write a VS10xx WRAM Location.
static void spiInit()
Initialize the SPI for VS10xx use.
uint8_t getDifferentialOutput()
Get the current SM_DIFF setting from the VS10xx chip.
void resumeDataStream()
Unpause streaming data to the VSdsp.
static void dcs_low()
Select Data Channel.
uint8_t VolL
contains a local value of the VSdsp's master volume left channels
void setDifferentialOutput(uint16_t)
Set the current SM_DIFF setting of the VS10xx chip.
uint16_t getVolume()
Get the current volume from the VS10xx chip.
uint16_t memoryTest()
Perform Memory Test.
static void cs_low()
Select Control Channel.
static void dcs_high()
Deselect Data Channel.
static void Mp3WriteRegister(uint8_t, uint8_t, uint8_t)
Write a value a VSDsp's register.
uint8_t VolR
contains a local value of the VSdsp's master volume Right channels
void trackAlbum(char *)
Get Track's Album.
uint16_t getBassFrequency()
Get the current Bass Frequency limit from the VS10xx chip.
void setBassFrequency(uint16_t)
Set the current Bass Boost Frequency limit cutoff in VS10xx chip.
uint8_t disableTestSineWave()
Disable Test Sine wave.
state_m getState()
Get the current state of the device.
static state_m playing_state
Boolean flag indicating if filehandle is streaming.
void stopTrack()
Gracefully close track and cancel refill.
void setBitRate(uint16_t)
Force bit rate.
uint8_t begin()
Initialize the MP3 Player shield.
static SdFile track
Initializer for the instance of the SdCard's static member.
uint8_t skipTo(uint32_t)
Skips to a certain point in the track.
uint8_t ADMixerLoad(char *)
Initially load ADMixer patch and configure line/mic mode.
uint8_t isPlaying()
Inidicate if a song is playing?
uint8_t playMP3(char *, uint32_t timecode=0)
Begin playing a mp3 file by its filename.
uint8_t playTrack(uint8_t)
Begin playing a mp3 file, just with a number.
void setEarSpeaker(uint16_t)
Set the current Spatial EarSpeaker setting of the VS10xx chip.
void SendSingleMIDInote()
Play hardcoded MIDI file.
int8_t getBassAmplitude()
Get the current Bass boost amplitude from the VS10xx chip.
int8_t setVUmeter(int8_t)
enable VSdsp VU Meter
uint8_t bitrate
contains a local value of the beleived current bit-rate.
void getAudioInfo()
Display various Audio information from the VSdsp.
static void cs_high()
Deselect Control Channel.
int8_t getVUmeter()
get the status of the VSdsp VU Meter
void setTrebleFrequency(uint16_t)
Set the current treble frequency limit in VS10xx chip.
uint32_t currentPosition()
Current timecode in ms.
uint16_t getMonoMode()
Get the current Stereo/Mono setting of the VS10xx output.
void end()
Disables the MP3 Player shield.
static uint16_t Mp3ReadWRAM(uint16_t)
Read a VS10xx WRAM Location.
int8_t getTrebleAmplitude()
Get the current Treble Amplitude from the VS10xx chip.
static uint32_t spi_Max_Rate
Rate of the SPI to be used with communicating to the VSdsp.
void setBassAmplitude(uint8_t)
Set the current Bass Boost amplitude in VS10xx chip.
void setVolume(uint8_t, uint8_t)
Store and Push member volume to VS10xx chip.
uint16_t getTrebleFrequency()
Get the current Treble Frequency limit from the VS10xx chip.
void setTrebleAmplitude(int8_t)
Set the current Treble Amplitude in VS10xx chip.
void getBitRateFromMP3File(char *)
Read the Bit-Rate from the current track's filehandle.
static void refill()
Refill the VS10xx buffer with new data.
uint8_t VSLoadUserCode(char *)
load VS1xxx with patch or plugin from file on SDcard.
static void available()
Public interface of refill.
void pauseDataStream()
Pause streaming data to the VSdsp.
void ADMixerVol(int8_t)
Set ADMixer's attenuation of input to between -3 and -31 dB otherwise disable.
void setMonoMode(uint16_t)
Set the current Stereo/Mono setting of the VS10xx output.
uint8_t vs_init()
Initialize the VS10xx Audio Decoder Chip.
void setPlaySpeed(uint16_t)
Set the current playSpeed of the VS10xx chip.
int16_t getVUlevel()
get current measured VU Meter
uint32_t start_of_music
contains a filehandles offset to the begining of the current file.
static void disableRefill()
Disable the Interrupts for refill.
uint8_t getEarSpeaker()
Get the current Spatial EarSpeaker setting from the VS10xx chip.
void trackTitle(char *)
Get Track's Title.
bool resumeMusic()
Resume music from where it was paused.
static void enableRefill()
Enable the Interrupts for refill.
void pauseMusic()
Pause music.
static uint16_t Mp3ReadRegister(uint8_t)
Read a VS10xx register.
uint8_t enableTestSineWave(uint8_t)
Generate Test Sine wave.
uint8_t skip(int32_t)
Skips to a duration in the track.
void getTrackInfo(uint8_t, char *)
Fetch ID3 Tag information.
uint16_t getPlaySpeed()
Get the current playSpeed from the VS10xx chip.
void trackArtist(char *)
Get Track's Artist.
static void flush_cancel(flush_m)
flush the VSdsp buffer and cancel
static uint8_t mp3DataBuffer[32]
Buffer for moving data between Filehandle and VSdsp.
A handler for accessing bytes of a word.
uint16_t word
whole word value
A handler for accessing nibbles of the SCI_BASS word.
struct vs1053::sci_bass_m::@122063340134256071104100347103242272313255100340 nibble
individual Nibbles
uint16_t word
whole word value
int8_t irq
External reference to the interrupt identifier for MP3_DREQ.
SdFat sd
SdFat sd;.
state_m
State of the vs1053 device.
@ testing_sinewave
@ paused_playback
bool isFnMusic(char *)
is the filename music
char * strip_nonalpha_inplace(char *s)
chomp non printable characters out of string.
flush_m
How to flush the VSdsp's buffer.
@ pre
Flush First.
@ none
Don't Flush.
@ post
Flush After.
@ both
Flush both First and After.