Library for VS1053 chip
Revision 1:399afe8151de, committed 2012-05-24
- Comitter:
- clemente
- Date:
- Thu May 24 12:48:19 2012 +0000
- Parent:
- 0:e97876f96d4b
- Commit message:
Changed in this revision
VLSIcodec.c | Show annotated file Show diff for this revision Revisions of this file |
diff -r e97876f96d4b -r 399afe8151de VLSIcodec.c --- a/VLSIcodec.c Wed May 23 06:28:16 2012 +0000 +++ b/VLSIcodec.c Thu May 24 12:48:19 2012 +0000 @@ -1,4 +1,4 @@ -/* mbed VLSIcodec library. To access VS1053 MPEG3 codec. +/** mbed VLSIcodec library. To access VS1053 MPEG3 codec. Copyright (c) 2010 NXP 3790 @@ -127,22 +127,35 @@ */ #define cVS1053_CS_DELAY 50 +/** VS1053Codec +*/ VS1053Codec::VS1053Codec( PinName mosi, PinName miso, PinName sclk, PinName cs, PinName dreq, PinName rst, PinName xdcs) : _spi( mosi, miso, sclk), _cs( cs), _dreq( dreq), _rst( rst), _xdcs( xdcs) { // defaults params VS1053_CS_DISABLE; VS1053_XDCS_DISABLE; } +/** Wait untile the dreq is released +* @param none +* @retval none +*/ void VS1053Codec::testdreq( void){ while( !_dreq); } - + +/** Put the VS1053 in low power mode (RESET) +* +* @param none +* @retval none +*/ void VS1053Codec::lowpower( void) { VS1053_RST_ENABLE; wait_ms( 10); } +/** Initialize the VS1053 +*/ void VS1053Codec::init(void) { // @@ -313,26 +326,26 @@ #ifdef __PLUGINGA void VS1053Codec::readgavalue( unsigned char *currval, unsigned char *peak) { - writereg( VLSI_WRAMADDR, cBASE+2); - unsigned short bands = (unsigned short)readreg( VLSI_WRAM); - // - writereg( VLSI_WRAMADDR, cBASE+4); - // - for (int i=0;i<bands;i++) { - short pv = readreg( VLSI_WRAM); - /* current value in bits 5..0, normally 0..31 - peak value in bits 11..6, normally 0..31 */ - currval[i]=(unsigned char)(pv&0x003F); - peak[i]=(unsigned char)( (pv>>6)&0x003F); - } + writereg( VLSI_WRAMADDR, cBASE+2); + unsigned short bands = (unsigned short)readreg( VLSI_WRAM); + // + writereg( VLSI_WRAMADDR, cBASE+4); + // + for (int i=0;i<bands;i++) { + short pv = readreg( VLSI_WRAM); + /* current value in bits 5..0, normally 0..31 + peak value in bits 11..6, normally 0..31 */ + currval[i]=(unsigned char)(pv&0x003F); + peak[i]=(unsigned char)( (pv>>6)&0x003F); + } } unsigned short VS1053Codec::readgabands( void) { - writereg( VLSI_WRAMADDR, cBASE+2); - unsigned short bands = (unsigned short)readreg( VLSI_WRAM); - /* */ - return bands; + writereg( VLSI_WRAMADDR, cBASE+2); + unsigned short bands = (unsigned short)readreg( VLSI_WRAM); + /* */ + return bands; } #endif