Add the RTOS processing. for the Network radio streaming receiver.
Fork of VS1053b by
Diff: VS1053.h
- Revision:
- 8:5e4a21202223
- Parent:
- 7:b6853a2c88c2
- Child:
- 9:0d76f559a151
--- a/VS1053.h Sat Jan 08 16:36:00 2011 +0000 +++ b/VS1053.h Wed Jan 12 18:30:28 2011 +0000 @@ -67,7 +67,7 @@ #define DEFAULT_TREBLE_AMPLITUDE 0 // -8 - 7 dB #define DEFAULT_TREBLE_FREQUENCY 15000 //1000 - 15000 Hz -#define BUFFER_SIZE (20 * 1024 + 1) + // SCI register address assignment #define SCI_MODE 0x00 @@ -267,6 +267,10 @@ * Pin to vs1053b data request. * @param dcs * Pin to vs1053b data chip select. + * @param buffer + * Array to cache audio data. + * @param buffer_size + * Length of the array. */ VS1053( PinName mosi, @@ -275,8 +279,10 @@ PinName cs, PinName rst, PinName dreq, - PinName dcs - ); + PinName dcs, + char* buffer, + int buffer_size + ); /** Reset the vs1053b. (hardware reset) * @@ -392,7 +398,7 @@ * @return * TRUE on success; FALSE on failure, c isn't copied in the buffer. */ - bool bufferSetByte(unsigned char c); + bool bufferSetByte(char c); /** Copy a array of bytes into the audio data buffer. * @@ -405,7 +411,7 @@ * @return * TRUE on success; FALSE on failure, s isn't copied in the buffer. */ - bool bufferPutStream(const unsigned char *s, unsigned int length); + bool bufferPutStream(const char *s, unsigned int length); /** Get the free space of the audio data buffer. * @@ -419,7 +425,14 @@ * @return * Space 0 .. BUFFER_SIZE - 1. */ - unsigned int bufferCount(void); + unsigned int bufferCount(void); + + /** Complete length of the audio buffer. + * + * @return + * Buffer length. + */ + unsigned int bufferLength(void); /** Start playing audio from buffer. * @@ -488,9 +501,10 @@ DigitalIn _DREQ; InterruptIn _DREQ_INTERUPT_IN; - unsigned char _buffer[BUFFER_SIZE]; - unsigned char* _bufferReadPointer; - unsigned char* _bufferWritePointer; + char* _buffer; + char* _bufferReadPointer; + char* _bufferWritePointer; + int BUFFER_SIZE; bool _isIdle; @@ -502,7 +516,8 @@ int _sb_amplitude; int _sb_freqlimit; int _st_amplitude; - int _st_freqlimit; + int _st_freqlimit; + Ticker timer;