Add the RTOS processing. for the Network radio streaming receiver.
Fork of VS1053b by
Diff: VS1053.h
- Revision:
- 4:cacb5e663fa9
- Parent:
- 3:88a645490529
- Child:
- 5:ead95c0f7800
--- a/VS1053.h Wed Dec 22 21:15:22 2010 +0000 +++ b/VS1053.h Fri Dec 24 23:52:55 2010 +0000 @@ -67,6 +67,8 @@ #define DEFAULT_TREBLE_AMPLITUDE 0 // -8 - 7 dB #define DEFAULT_TREBLE_FREQUENCY 15000 //1000 - 15000 Hz +#define BUFFER_SIZE (16 * 1024 + 1) + // SCI register address assignment #define SCI_MODE 0x00 #define SCI_STATUS 0x01 @@ -130,7 +132,9 @@ #define para_positionMsec_0 0x1E27 #define para_positionMsec_1 0x1E28 #define para_resync 0x1E29 - + +#define INTERRUPT_HANDLER_ENABLE _DREQ_INTERUPT_IN.rise(this, &VS1053::dataRequestHandler); timer.attach_us(this, &VS1053::dataRequestHandler, 1000) +#define INTERRUPT_HANDLER_DISABLE _DREQ_INTERUPT_IN.rise(NULL); timer.detach() /** Class for VS1053 - Ogg Vorbis / MP3 / AAC / WMA / FLAC / MIDI Audio Codec Chip. * @@ -198,7 +202,7 @@ PinName rst, PinName dreq, PinName dcs - ); + ); /** Reset the vs1053b. (hardware reset) * @@ -309,7 +313,16 @@ * @param speed * Speed 0, 1, .. 4 (0, 1 normal speed). */ - void setPlaySpeed(unsigned short speed); + void setPlaySpeed(unsigned short speed); + + bool bufferSetByte(unsigned char c); + bool bufferPutStream(const unsigned char *s, unsigned int length); + unsigned int bufferFree(void); + unsigned int bufferCount(void); + + void play(void); + void pause(void); + void stop(void); protected: unsigned short int wram_read(unsigned short int); @@ -336,28 +349,42 @@ void sine_test_deactivate(void); void changeVolume(void); + // TODO void power_down(void); -#if 0 - void putcStream(unsigned char); -#endif + void changeBass(void); - SPI _spi; - DigitalOut _CS; - DigitalOut _DCS; - DigitalIn _DREQ; - DigitalOut _RST; + unsigned char bufferGetByte(void); + void bufferReset(void); + void dataRequestHandler(void); + SPI _spi; + DigitalOut _CS; + DigitalOut _RST; + DigitalOut _DCS; + DigitalIn _DREQ; + InterruptIn _DREQ_INTERUPT_IN; + + unsigned char _buffer[BUFFER_SIZE]; + unsigned char* _bufferReadPointer; + unsigned char* _bufferWritePointer; + + bool _isIdle; + // variables to save // volume, values in db - float _balance; - float _volume; + float _balance; + float _volume; // bass enhancer settings - int _sb_amplitude; - int _sb_freqlimit; - int _st_amplitude; - int _st_freqlimit; + int _sb_amplitude; + int _sb_freqlimit; + int _st_amplitude; + int _st_freqlimit; + + Ticker timer; + }; + #endif