MP3 Decoder. More...
Data Structures | |
struct | VS_HEADERINFO |
Defines | |
#define | VS_OPCODE_READ 3 |
#define | VS_OPCODE_WRITE 2 |
#define | VS_FLUSH_BYTES 2048 |
#define | VS_STATUS_STOPPED 0 |
#define | VS_STATUS_RUNNING 1 |
#define | VS_STATUS_EOF 2 |
#define | VS_STATUS_EMPTY 4 |
#define | AUDIO_VS1001K |
#define | VS10XX_FREQ 12288000UL |
Decoder crystal frequency. | |
#define | VS10XX_HWRST_DURATION 1 |
Minimum time in milliseconds to held hardware reset low. | |
#define | VS10XX_HWRST_RECOVER 10 |
Milliseconds to wait after hardware reset. | |
#define | VS10XX_SWRST_RECOVER VS10XX_HWRST_RECOVER |
Milliseconds to wait after software reset. | |
#define | VS10XX_SCI_MODE 0 |
#define | VS10XX_SCI_RATE (VS10XX_FREQ / 4) |
#define | VS10XX_SDI_MODE 0 |
#define | VS10XX_SDI_RATE (VS10XX_FREQ / 4) |
#define | SciReset(act) |
#define | SciSetMode() (-1) |
#define | SciSetSpeed() |
#define | SciSelect() |
#define | SciDeselect() |
#define | SciByte(b) 0 |
#define | SdiSetMode() (-1) |
#define | SdiSetSpeed() |
#define | SdiSelect() |
#define | SdiDeselect() |
#define | SdiByte(b) 0 |
Functions | |
int | VsPlayerInit (void) |
Initialize the VS10XX hardware interface. | |
int | VsPlayerReset (uint16_t mode) |
Software reset the decoder. | |
int | VsPlayerSetMode (uint16_t mode) |
Set mode register of the decoder. | |
int | VsPlayerKick (void) |
Start playback. | |
int | VsPlayerStop (void) |
Stops the playback. | |
int | VsPlayerFlush (void) |
Sets up decoder internal buffer flushing. | |
ureg_t | VsPlayerInterrupts (ureg_t enable) |
Enable or disable player interrupts. | |
ureg_t | VsPlayerThrottle (ureg_t on) |
Throttle decoder activity. | |
uint16_t | VsPlayTime (void) |
Returns play time since last reset. | |
unsigned int | VsGetStatus (void) |
Returns status of the player. | |
int | VsGetHeaderInfo (VS_HEADERINFO *vshi) |
Query MP3 stream header information. | |
uint16_t | VsMemoryTest (void) |
Initialize decoder memory test and return result. | |
int | VsSetVolume (ureg_t left, ureg_t right) |
Set volume. | |
int | VsBeep (uint8_t fsin, uint8_t ms) |
Sine wave beep. | |
Mode Control Register | |
#define | VS_MODE_REG 0 |
Register index. | |
#define | VS_SM_DIFF 0x0001 |
Left channel inverted. | |
#define | VS_SM_LAYER12 0x0002 |
Allow MPEG Layers I & II. | |
#define | VS_SM_FFWD 0x0002 |
VS1001K fast forward. | |
#define | VS_SM_RESET 0x0004 |
Soft reset. | |
#define | VS_SM_MP12 0x0008 |
VS1001 MPEG Layers I & II enable. | |
#define | VS_SM_OUTOFWAV 0x0008 |
Jump out of wave decoding. | |
#define | VS_SM_PDOWN 0x0010 |
Power down. | |
#define | VS_SM_DAC 0x0020 |
VS1001K unknown function. | |
#define | VS_SM_TESTS 0x0020 |
Allow SDI tests. | |
#define | VS_SM_DACMONO 0x0040 |
VS1001K unknown function. | |
#define | VS_SM_STREAM 0x0040 |
Stream mode. | |
#define | VS_SM_BASS 0x0080 |
VS1001K bass/treble enhancer. | |
#define | VS_SM_DACT 0x0100 |
Active edge of the data clock. | |
#define | VS_SM_BYTEORD 0x0200 |
| |
#define | VS_SM_SDIORD 0x0200 |
SDI most significant bit last. | |
#define | VS_SM_IBMODE 0x0400 |
VS1001K master mode. | |
#define | VS_SM_SDISHARE 0x0400 |
Share SPI chip select. | |
#define | VS_SM_IBCLK 0x0800 |
VS1001K master mode clock speed. | |
#define | VS_SM_SDINEW 0x0800 |
VS1002 native SDI mode. | |
#define | VS_SM_ADPCM 0x1000 |
ADPCM recording. | |
#define | VS_SM_ADPCM_HP 0x2000 |
ADPCM high pass filter. | |
#define | VS_SM_LINE_IN 0x4000 |
ADPCM recording selector. | |
#define | VS_SM_CLK_RANGE 0x8000 |
Input clock range. | |
Status Register | |
#define | VS_STATUS_REG 1 |
Register index. | |
#define | VS_SS_AVOL 0x0003 |
Internal analog volume control mask. | |
#define | VS_SS_AVOL_LSB 0 |
Internal analog volume control LSB. | |
#define | VS_SS_APDOWM1 0x0004 |
Internal analog power down. | |
#define | VS_SS_APDOWN2 0x0008 |
Analog driver power down. | |
#define | VS_SS_VER 0x0070 |
Version mask. | |
#define | VS_SS_VER_LSB 4 |
Version LSB. | |
VS1001 internal frequency control register. | |
#define | VS_INT_FCTLH_REG 2 |
Register index. | |
Bass/Treble Enhancer Register | |
#define | VS_BASS_REG 2 |
Register index. | |
#define | VS_SB_FREQLIMIT 0x000F |
Bass enhancer lower limit frequency mask. | |
#define | VS_SB_FREQLIMIT_LSB 0 |
Lower limit frequency LSB. | |
#define | VS_SB_AMPLITUDE 0x00F0 |
Bass enhancement mask. | |
#define | VS_SB_AMPLITUDE_LSB 4 |
Bass enhancement LSB. | |
#define | VS_ST_FREQLIMIT 0x000F |
Treble control lower limit frequency mask. | |
#define | VS_ST_FREQLIMIT_LSB 0 |
Lower limit frequency LSB. | |
#define | VS_ST_AMPLITUDE 0x00F0 |
Treble control mask. | |
#define | VS_ST_AMPLITUDE_LSB 4 |
Bass enhancement LSB. | |
Clock Frequency and Multiplier Register | |
#define | VS_CLOCKF_REG 3 |
Register index. | |
#define | VS_SC_FREQ 0x7FFF |
Clock frequency mask. | |
#define | VS_SC_X3FREQ 0x07FF |
VS1003/VS1033 clock frequency mask. | |
#define | VS_SC_FREQ_LSB 0 |
Clock frequency LSB. | |
#define | VS_SC_ADD 0x1800 |
Allowed multiplier addition. | |
#define | VS_SC_MULT 0xE000 |
Clock multiplier. | |
#define | VS_CF_DOUBLER 0x8000 |
Clock doubler enable. | |
Decode Time Register | |
#define | VS_DECODE_TIME_REG 4 |
Register index. | |
Miscellaneous Audio Data Register | |
#define | VS_AUDATA_REG 5 |
Register index. | |
#define | VS_AD_STEREO 0x0001 |
Stereo flag. | |
#define | VS_AD_SRATE 0xFFFE |
Current sampling rate mask. | |
#define | VS_AD_SRATE_LSB 1 |
Crystal clock LSB. | |
RAM Read/Write Register | |
#define | VS_WRAM_REG 6 |
Register index. | |
RAM Read/Write Base Address Register | |
#define | VS_WRAMADDR_REG 7 |
Register index. | |
Stream Header Data Register 0 | |
#define | VS_HDAT0_REG 8 |
Register index. | |
VS1103 Input Register 0 | |
#define | VS_IN0_REG 8 |
Register index. | |
Stream Header Data Register 1 | |
#define | VS_HDAT1_REG 9 |
Register index. | |
VS1103 Input Register 1 | |
#define | VS_IN1_REG 9 |
Register index. | |
Application Start Address Register | |
#define | VS_AIADDR_REG 10 |
Register index. | |
Volume Control Register | |
#define | VS_VOL_REG 11 |
Register index. | |
#define | VS_VOL_RIGHT 0x00FF |
Right channel volume mask. | |
#define | VS_VOL_RIGHT_LSB 0 |
Right channel volume LSB. | |
#define | VS_VOL_LEFT 0xFF00 |
Right channel volume mask. | |
#define | VS_VOL_LEFT_LSB 8 |
Right channel volume LSB. | |
VS1103 Mixer Volume Register | |
#define | VS_MIXERVOL_REG 12 |
Register index. | |
#define | VS_SMV_GAIN1 0x001F |
#define | VS_SMV_GAIN2 0x03E0 |
#define | VS_SMV_GAIN3 0x7C00 |
#define | VS_SMV_ACTIVE 0x8000 |
VS1103 IMA ADPCM Record Control Register | |
#define | VS_ADPCMRECCTL_REG 13 |
Register index. | |
#define | VS_SARC_GAIN4 0x003F |
#define | VS_SARC_MANUALGAIN 0x0040 |
#define | VS_SARC_OUTOFADPCM 0x0080 |
Application Control Registers | |
#define | VS_AICTRL0_REG 12 |
Application register 0 index. | |
#define | VS_AICTRL_REG 13 |
VS1001K application register 0 index. | |
#define | VS_AICTRL1_REG 13 |
Application register 1 index. | |
#define | VS_AICTRL2_REG 14 |
Application register 2 index. | |
#define | VS_AICTRL3_REG 15 |
Application register 3 index. |
MP3 Decoder.
#define VS_OPCODE_READ 3 |
#define VS_OPCODE_WRITE 2 |
#define VS_MODE_REG 0 |
Register index.
#define VS_SM_DIFF 0x0001 |
Left channel inverted.
#define VS_SM_LAYER12 0x0002 |
Allow MPEG Layers I & II.
Determines whether it is allowed to decode MPEG 1 and 2 Layers I and II in addition to Layer III. If you enable Layer I and Layer II decoding, you are liable for any patent issues that may arise. Joint licensing of MPEG 1.0 / 2.0 Layer III does not cover all patents pertaining to Layers I and II.
#define VS_SM_FFWD 0x0002 |
VS1001K fast forward.
By setting this bit, the player starts to accept data at a high speed, and just decodes the audio headers silently without playing any audio data. This can be used to fast-forward data with safe landing. Register VS_DECODE_TIME_REG is updated during a fast-forward just as normal.
Note, that this bit is available on the VS1001K only and is used as MPEG Layer I & II enable on other members of the VS10xx family.
#define VS_SM_RESET 0x0004 |
Soft reset.
Bit is cleared automatically.
#define VS_SM_MP12 0x0008 |
VS1001 MPEG Layers I & II enable.
May not work reliable due to firmware problems.
If you enable Layer I and Layer II decoding, you are liable for any patent issues that may arise.
#define VS_SM_OUTOFWAV 0x0008 |
Jump out of wave decoding.
Set this bit to stop WAV, WMA and MIDI file playing before the end of the file has been reached. Continue sending zeros for WAV and more data for MIDI and WMA until this bit is cleared again.
Not available on the VS1001K.
#define VS_SM_PDOWN 0x0010 |
Power down.
During powerdown, no audio is played and no SDI operations are performed. It is recommended to set VS_VOL_REG to 0xFFFF before setting this bit.
For best power down efficiency, activate hardware reset.
Not available on the VS1011. Although defined, this is not implemented in the VS1001K firmware.
#define VS_SM_DAC 0x0020 |
VS1001K unknown function.
#define VS_SM_TESTS 0x0020 |
Allow SDI tests.
Not required for the VS1001K, where tests are enabled by default.
Referenced by VsCodecBeep().
#define VS_SM_DACMONO 0x0040 |
VS1001K unknown function.
#define VS_SM_STREAM 0x0040 |
Stream mode.
When stream mode is activated, data should be sent with as even intervals as possible (and preferable with data blocks of less than 512 bytes). The decoder makes every attempt to keep its input buffer half full by changing its playback speed upto 5%. For best quality sound, the average speed error should be within 0.5%, the bitrate should not exceed 160 kbit/s and VBR should not be used.
Not available on the VS1001K.
#define VS_SM_BASS 0x0080 |
VS1001K bass/treble enhancer.
#define VS_SM_DACT 0x0100 |
Active edge of the data clock.
If clear data is read at the rising edge, and if set data is read at the falling edge.
#define VS_SM_BYTEORD 0x0200 |
#define VS_SM_SDIORD 0x0200 |
SDI most significant bit last.
Bytes are, however, still sent in default order.
#define VS_SM_IBMODE 0x0400 |
VS1001K master mode.
Untested and not recommended.
#define VS_SM_SDISHARE 0x0400 |
Share SPI chip select.
#define VS_SM_IBCLK 0x0800 |
VS1001K master mode clock speed.
Untested and not recommended.
#define VS_SM_SDINEW 0x0800 |
VS1002 native SDI mode.
Default is 0 on the VS1011E and 1 on the VS1002.
Not available on the VS1001K.
#define VS_SM_ADPCM 0x1000 |
ADPCM recording.
Available on VS1033.
#define VS_SM_ADPCM_HP 0x2000 |
ADPCM high pass filter.
If set at the same time as VS_SM_ADPCM and VS_SM_RESET, ADPCM mode will start with a high-pass filter. This may help intelligibility of speech when there is lots of background noise.
Available on VS1033.
#define VS_SM_LINE_IN 0x4000 |
ADPCM recording selector.
Used to select the input for ADPCM recording. If cleared, microphone input is used. If set to 1, LINEIN is used instead.
Available on VS1033.
#define VS_SM_CLK_RANGE 0x8000 |
Input clock range.
Activates a clock divider at the XTAL input. Should be set as soon as possible after a chip reset.
Available on VS1033.
#define VS_STATUS_REG 1 |
Register index.
#define VS_SS_AVOL 0x0003 |
Internal analog volume control mask.
These bits is meant to be used by the internal firmware only.
#define VS_SS_AVOL_LSB 0 |
Internal analog volume control LSB.
#define VS_SS_APDOWM1 0x0004 |
Internal analog power down.
This bit is meant to be used by the internal firmware only.
#define VS_SS_APDOWN2 0x0008 |
Analog driver power down.
This bit is typically controlled by the internal firmware. However, if the application wants to power down the decoder with a minimum power-off transient, this bit should be set to 1 a few milliseconds before activating reset.
#define VS_SS_VER 0x0070 |
Version mask.
#define VS_SS_VER_LSB 4 |
Version LSB.
#define VS_INT_FCTLH_REG 2 |
Register index.
Use only on older chip revisions?
#define VS_BASS_REG 2 |
#define VS_SB_FREQLIMIT 0x000F |
Bass enhancer lower limit frequency mask.
Specified in 10 Hz steps.
#define VS_SB_FREQLIMIT_LSB 0 |
Lower limit frequency LSB.
Referenced by VsDecoderSetBass().
#define VS_SB_AMPLITUDE 0x00F0 |
Bass enhancement mask.
Bass enhancement in 1 dB steps, or disabled when zero.
#define VS_SB_AMPLITUDE_LSB 4 |
Bass enhancement LSB.
Referenced by VsDecoderSetBass().
#define VS_ST_FREQLIMIT 0x000F |
Treble control lower limit frequency mask.
Specified in 1 kHz steps.
#define VS_ST_FREQLIMIT_LSB 0 |
Lower limit frequency LSB.
Referenced by VsDecoderSetBass().
#define VS_ST_AMPLITUDE 0x00F0 |
Treble control mask.
Treble control in 1.5 dB steps, or disabled when zero.
#define VS_ST_AMPLITUDE_LSB 4 |
Bass enhancement LSB.
Referenced by VsDecoderSetBass().
#define VS_CLOCKF_REG 3 |
Register index.
#define VS_SC_FREQ 0x7FFF |
Clock frequency mask.
Should be set to crystal clock divided by 2000, if the clock is not 24.576 MHz.
Used for the VS1001, VS1011 and VS1002.
#define VS_SC_X3FREQ 0x07FF |
VS1003/VS1033 clock frequency mask.
Should be set to crystal clock divided by 4000, if the clock is not 12.288 MHz.
Used for the VS1003 and VS1033.
#define VS_SC_FREQ_LSB 0 |
Clock frequency LSB.
#define VS_SC_ADD 0x1800 |
Allowed multiplier addition.
Used for WMA decoding with the VS1003 and VS1033.
#define VS_SC_MULT 0xE000 |
Clock multiplier.
Used for the VS1003 and VS1033.
#define VS_CF_DOUBLER 0x8000 |
Clock doubler enable.
Used for the VS1001, VS1011 and VS1002.
#define VS_DECODE_TIME_REG 4 |
Register index.
This read-only register contains the decode time in full seconds or zero after resetting the decoder.
#define VS_AUDATA_REG 5 |
Register index.
Usage on the VS1001K differs.
#define VS_AD_STEREO 0x0001 |
Stereo flag.
Set to 1 for stereo and 0 for mono. Read-only.
#define VS_AD_SRATE 0xFFFE |
Current sampling rate mask.
Value is sample rate divided by 2. Writing to this register will change the sample rate on the run.
#define VS_AD_SRATE_LSB 1 |
Crystal clock LSB.
#define VS_WRAM_REG 6 |
Register index.
Used to upload application programs and data to instruction and data RAM.
#define VS_WRAMADDR_REG 7 |
Register index.
Used to upload application programs and data to instruction and data RAM.
#define VS_HDAT0_REG 8 |
Register index.
Not available in the VS1103.
#define VS_IN0_REG 8 |
Register index.
#define VS_HDAT1_REG 9 |
Register index.
Not available in the VS1103.
#define VS_IN1_REG 9 |
Register index.
#define VS_AIADDR_REG 10 |
Register index.
Referenced by FeederThread().
#define VS_VOL_REG 11 |
Register index.
#define VS_VOL_RIGHT 0x00FF |
Right channel volume mask.
Attenuation is given in 0.5 dB steps or 255 for mute.
#define VS_VOL_RIGHT_LSB 0 |
Right channel volume LSB.
Referenced by FeederThread(), VsDecoderSetVolume(), and VsSetVolume().
#define VS_VOL_LEFT 0xFF00 |
Right channel volume mask.
Attenuation is given in 0.5 dB steps or 255 for mute.
#define VS_VOL_LEFT_LSB 8 |
Right channel volume LSB.
Referenced by FeederThread(), VsDecoderSetVolume(), and VsSetVolume().
#define VS_MIXERVOL_REG 12 |
Register index.
#define VS_SMV_GAIN1 0x001F |
#define VS_SMV_GAIN2 0x03E0 |
#define VS_SMV_GAIN3 0x7C00 |
#define VS_SMV_ACTIVE 0x8000 |
#define VS_ADPCMRECCTL_REG 13 |
Register index.
#define VS_SARC_GAIN4 0x003F |
#define VS_SARC_MANUALGAIN 0x0040 |
#define VS_SARC_OUTOFADPCM 0x0080 |
#define VS_AICTRL0_REG 12 |
Application register 0 index.
Do not use with VS1001. Also used for mixer volume on the VS1103.
#define VS_AICTRL_REG 13 |
VS1001K application register 0 index.
A second register is available at VS_AICTRL0_REG + 1.
#define VS_AICTRL1_REG 13 |
Application register 1 index.
Register 0 on the VS1001. Also used for IMA ADPCM record control in the VS1103.
#define VS_AICTRL2_REG 14 |
Application register 2 index.
Register 1 on the VS1001.
#define VS_AICTRL3_REG 15 |
Application register 3 index.
Do not use with VS1001.
#define VS_FLUSH_BYTES 2048 |
#define VS_STATUS_STOPPED 0 |
#define VS_STATUS_RUNNING 1 |
#define VS_STATUS_EOF 2 |
#define VS_STATUS_EMPTY 4 |
#define AUDIO_VS1001K |
#define VS10XX_FREQ 12288000UL |
Decoder crystal frequency.
#define VS10XX_HWRST_DURATION 1 |
Minimum time in milliseconds to held hardware reset low.
#define VS10XX_HWRST_RECOVER 10 |
Milliseconds to wait after hardware reset.
#define VS10XX_SWRST_RECOVER VS10XX_HWRST_RECOVER |
Milliseconds to wait after software reset.
#define VS10XX_SCI_MODE 0 |
#define VS10XX_SCI_RATE (VS10XX_FREQ / 4) |
#define VS10XX_SDI_MODE 0 |
#define VS10XX_SDI_RATE (VS10XX_FREQ / 4) |
#define SciReset | ( | act | ) |
#define SciSetMode | ( | ) | (-1) |
#define SciSetSpeed | ( | ) |
#define SciSelect | ( | void | ) |
#define SciDeselect | ( | void | ) |
#define SciByte | ( | b | ) | 0 |
#define SdiSetMode | ( | ) | (-1) |
#define SdiSetSpeed | ( | ) |
#define SdiSelect | ( | ) |
Referenced by VsPlayerThrottle().
#define SdiDeselect | ( | ) |
Referenced by VsPlayerThrottle().
#define SdiByte | ( | b | ) | 0 |
int VsPlayerInit | ( | void | ) |
Initialize the VS10XX hardware interface.
int VsPlayerReset | ( | uint16_t | mode | ) |
Software reset the decoder.
This function is typically called after VsPlayerInit() and at the end of each track.
mode | Any of the following flags may be or'ed (check the data sheet)
|
int VsPlayerSetMode | ( | uint16_t | mode | ) |
Set mode register of the decoder.
mode | Any of the following flags may be or'ed (check the data sheet)
|
int VsPlayerKick | ( | void | ) |
Start playback.
This routine will send the first MP3 data bytes to the decoder, until it is completely filled. The data buffer should have been filled before calling this routine.
Decoder interrupts will be enabled.
int VsPlayerStop | ( | void | ) |
Stops the playback.
This routine will stops the MP3 playback, VsPlayerKick() may be used to resume the playback.
int VsPlayerFlush | ( | void | ) |
Sets up decoder internal buffer flushing.
This routine will set up internal VS buffer flushing, unless the buffer is already empty and starts the playback if necessary. The internal VS buffer is flushed in VsPlayerFeed() at the end of the stream.
Decoder interrupts will be enabled.
Enable or disable player interrupts.
This routine is typically used by applications when dealing with unprotected buffers.
enable | Disables interrupts when zero. Otherwise interrupts are enabled. |
References NutIrqDisable(), NutIrqEnable(), and rc.
Throttle decoder activity.
When sharing SPI with other devices, this function should be called to disable (and re-enable) the SPI interface of the VS10XX.
Decoder interrupts must have been disabled before calling this function.
#include <dev/vs10xx.h> ureg_t ief = VsPlayerInterrupts(0); ureg_t tef = VsPlayerThrottle(1); ... use other SPI devices here ... VsPlayerThrottle(tef); VsPlayerInterrupts(ief);
on | Throttles (disables) the decoder interface if not zero. Otherwise the decoder interface is enabled again. |
References rc, SdiDeselect, and SdiSelect.
uint16_t VsPlayTime | ( | void | ) |
Returns play time since last reset.
unsigned int VsGetStatus | ( | void | ) |
Returns status of the player.
int VsGetHeaderInfo | ( | VS_HEADERINFO * | vshi | ) |
Query MP3 stream header information.
vshi | Pointer to VS_HEADERINFO structure. |
uint16_t VsMemoryTest | ( | void | ) |
Initialize decoder memory test and return result.
Set volume.
left | Left channel attenuation, provided in 0.5 dB steps. Set to 255 for ananlog power down. |
right | Right channel attenuation. |
References VS_VOL_LEFT_LSB, VS_VOL_REG, VS_VOL_RIGHT_LSB, and VsPlayerInterrupts().