Nut/OS  5.0.5
API Reference
VLSI VS Driver
Collaboration diagram for VLSI VS Driver:

Data Structures

struct  _VS_PLUGIN_INFO
struct  _VS_WRAM_DATA
struct  _VS_PARAMX_INFO
struct  VS_HEADERINFO
struct  _VSDCB
 Internal codec control block. More...

Defines

#define AUDIO0_DAC_MIN_GAIN   -127
#define AUDIO0_DAC_MAX_GAIN   0
#define AUDIO_DAC_MIN_GAIN   AUDIO0_DAC_MIN_GAIN
#define AUDIO_DAC_MAX_GAIN   AUDIO0_DAC_MAX_GAIN
#define AUDIO_DAC_MAX_TREB   8
#define AUDIO_DAC_MAX_TFIN   15
#define AUDIO_DAC_MAX_BASS   15
#define AUDIO_DAC_MAX_BFIN   15
#define AUDIO_SETWRITETIMEOUT   0x010d
#define AUDIO_GETWRITETIMEOUT   0x010e
#define AUDIO_PLAY   0x3001
 Immediately start playing.
#define AUDIO_CANCEL   0x3002
 Immediately stop playing and discard buffer.
#define AUDIO_GET_STATUS   0x3003
#define AUDIO_GET_PLAYGAIN   0x3004
#define AUDIO_SET_PLAYGAIN   0x3005
#define AUDIO_GET_PBSIZE   0x3006
#define AUDIO_SET_PBSIZE   0x3007
#define AUDIO_GET_PBLEVEL   0x3008
#define AUDIO_GET_PBWLOW   0x3009
#define AUDIO_SET_PBWLOW   0x300A
#define AUDIO_GET_PBWHIGH   0x300B
#define AUDIO_SET_PBWHIGH   0x300C
#define AUDIO_BEEP   0x300F
#define AUDIO_GET_DECINFO   0x3010
 Retrieve decoder information.
#define AUDIO_GET_DECCAPS   0x3011
 Retrieve decoder capabilities.
#define AUDIO_GET_DECFMTS   0x3012
 Retrieve decoder formats.
#define AUDIO_FMT_PLUGIN   0x00000001
#define AUDIO_FMT_WAV_PCM   0x00000002
#define AUDIO_FMT_WAV_ADPCM   0x00000004
#define AUDIO_FMT_WAV_IMA_ADPCM   0x00000008
#define AUDIO_FMT_VORBIS   0x00000100
#define AUDIO_FMT_MPEG1_L1   0x00001000
#define AUDIO_FMT_MPEG1_L2   0x00002000
#define AUDIO_FMT_MPEG1_L3   0x00004000
#define AUDIO_FMT_MPEG2_AAC   0x00010000
#define AUDIO_FMT_MPEG4_AAC   0x00020000
#define AUDIO_FMT_WMA_V2   0x00100000
#define AUDIO_FMT_WMA_V7   0x00200000
#define AUDIO_FMT_WMA_V8   0x00400000
#define AUDIO_FMT_WMA_V9   0x00800000
#define AUDIO_SET_DECFMTS   0x3013
 Enable or disable specific decoder formats.
#define AUDIO_GET_CODINFO   0x3014
 Retrieve encoder information.
#define AUDIO_GET_CODCAPS   0x3015
 Retrieve encoder capabilities.
#define AUDIO_GET_CODFMTS   0x3016
 Retrieve encoder formats.
#define AUDIO_SET_CODFMTS   0x3017
 Enable or disable specific encoder formats.
#define AUDIO_GET_MIDINFO   0x3018
 Retrieve midi information.
#define AUDIO_GET_MIDCAPS   0x3019
 Retrieve midi capabilities.
#define AUDIO_FMT_GMIDI1   0x00000001
#define AUDIO_FMT_GMIDI2   0x00000002
#define AUDIO_FMT_SPMIDI0   0x00000004
#define AUDIO_SET_TREB   0x301a
 Set audio enhancement treble value.
#define AUDIO_GET_TREB   0x301b
 Get audio enhancement treble value.
#define AUDIO_SET_TFIN   0x301c
 Set audio enhancement treble frequency.
#define AUDIO_GET_TFIN   0x301d
 Get audio enhancement treble frequency.
#define AUDIO_SET_BASS   0x301e
 Set audio enhancement bass value.
#define AUDIO_GET_BASS   0x301f
 Get audio enhancement bass value.
#define AUDIO_SET_BFIN   0x3020
 Set audio enhancement bass frequency.
#define AUDIO_GET_BFIN   0x3021
 Get audio enhancement bass frequency.
#define AUDIO_PLUGIN_UPLOAD   0x3030
 Upload plug-in.
#define AUDIO_IRQ_ENABLE   0x3031
 Enable interrupts.
#define AUDIO_SET_ICLOCK   0x3032
 Set internal clock.
#define AUDIO_WRITE_CMEM   0x3038
 Upload into WRAM.
#define AUDIO_SET_PARAMX   0x3040
 Set parametric x.
#define AUDIO_GET_PARAMX   0x3041
 Get parametric x.
#define VSP4_CHIP_ID_OFF   0x00
#define VSP4_VERSION_OFF   0x02
#define VSP4_CONFIG1_OFF   0x03
#define VSP4_PLAY_SPEED_OFF   0x04
#define VSP4_BIT_RATE_PER_100_OFF   0x05
#define VSP4_END_FILL_BYTE_OFF   0x06
#define VSP4_RATE_TUNE_OFF   0x07
#define VSP4_PLAY_MODE_OFF   0x09
#define VSP4_SAMPLE_COUNTER_OFF   0x0a
#define VSP4_VU_METER_OFF   0x0c
#define VSP4_AD_MIXER_GAIN_OFF   0x0d
#define VSP4_AD_MIXER_CONFIG_OFF   0x0e
#define VSP4_PCM_MIXER_RATE_OFF   0x0f
#define VSP4_PCM_MIXER_FREE_OFF   0x10
#define VSP4_PCM_MIXER_VOL_OFF   0x11
#define VSP4_EQ5_PARAMS_OFF(i)   (0x12 + (i))
#define VSP4_EQ5_UPDATED_OFF   0x1c
#define VSP4_SPEED_SHIFTER_OFF   0x1d
#define VSP4_EAR_SPEAKER_LEVEL_OFF   0x1e
#define VSP4_SDI_FREE_OFF   0x1f
#define VSP4_AUDIO_FILL_OFF   0x20
#define VSP4_LATEST_SOF_OFF   0x25
#define VSP4_POSITION_MSEC_OFF   0x27
#define VSP4_RESYNC_OFF   0x29
#define VSP4_ENC_TX_UART_DIV_OFF   0x2a
#define VSP4_ENC_TX_UART_BYTE_SPEED_OFF   0x2b
#define VSP4_ENC_TX_PAUSE_GPIO_OFF   0x2c
#define VSP4_ENC_SEC_ADAPT_MULTIPLIER_OFF   0x2d
#define VSP4_ENC_CHANNEL_MAX_OFF   0x3c
#define VSP4_ENC_SERIAL_NUMBER_OFF   0x3e
#define VSP4_WMA_CUR_PACKET_SIZE_OFF   0x2a
#define VSP4_WMA_PACKET_SIZE_OFF   0x2c
#define VSP4_AAC_SCE_FOUND_MASK_OFF   0x2a
#define VSP4_AAC_CPE_FOUND_MASK_OFF   0x2b
#define VSP4_AAC_LFE_FOUND_MASK_OFF   0x2c
#define VSP4_AAC_PLAY_SELECT_OFF   0x2d
#define VSP4_AAC_DYN_COMPRESS_OFF   0x2e
#define VSP4_AAC_DYN_BOOST_OFF   0x2f
#define VSP4_AAC_SBR_AND_PS_STATUS_OFF   0x30
#define VSP4_AAC_SBR_PS_FLAGS_OFF   0x31
#define VSP4_VORBIS_GAIN_OFF   0x2a
#define VS_PLAYMODE_MONO_OUTPUT_ON   ox0001
#define VS_PLAYMODE_PAUSE_ON   0x0002
#define VS_PLAYMODE_VUMETER_ON   0x0004
#define VS_PLAYMODE_ADMIXER_ON   0x0008
#define VS_PLAYMODE_PCMMIXER_ON   0x0010
#define VS_PLAYMODE_EQ5_ON   0x0020
#define VS_PLAYMODE_SPEEDSHIFTER_ON   0x0040
#define VS_OPCODE_READ   3
#define VS_OPCODE_WRITE   2
#define VS_FLUSH_BYTES   2048
 Application register 0 index.
#define CODEC_STATUS_IDLE   0
#define CODEC_STATUS_PLAYING   1
#define CODEC_STATUS_RECORDING   2
#define VSCODEC_CMD_TIMEOUT   NUT_WAIT_INFINITE
 Minimum time in milliseconds to held hardware reset low.
#define VSCODEC_DATA_CHUNK_SIZE   32
 Number of data bytes we can send without checking DREQ.
#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   4
 Milliseconds to wait after hardware reset.
#define VS10XX_SWRST_RECOVER   2
 Milliseconds to wait after software reset.
#define VS10XX_SCI_MODE   0
#define VS10XX_SCI_RATE   (VS10XX_FREQ / 6)
#define VS10XX_SDI_MODE   0
#define VS10XX_SDI_RATE   (VS10XX_FREQ / 6)
#define VSREQ_PLAY   0x00000001
#define VSREQ_CANCEL   0x00000002
#define VSREQ_BEEP   0x00000004

Typedefs

typedef struct _VS_PLUGIN_INFO VS_PLUGIN_INFO
typedef struct _VS_WRAM_DATA VS_WRAM_DATA
typedef struct _VS_PARAMX_INFO VS_PARAMX_INFO
typedef struct _VSDCB VSDCB
 Internal codec control block.
typedef struct _VSDCB VSDCB

Functions

int VsCodecWaitReady (NUTDEVICE *dev, uint32_t tmo)
 Wait until codec is ready.
uint16_t VsCodecReg (NUTDEVICE *dev, uint_fast8_t op, uint_fast8_t reg, uint_fast16_t val)
uint16_t VsCodecMode (NUTDEVICE *dev, uint_fast16_t flags, uint_fast16_t mask)
 Read and modify VLSI audio codec mode flags.
int VsDecoderSetVolume (NUTDEVICE *dev, int left, int right)
 Set volume.
int VsDecoderSetBass (NUTDEVICE *dev, int treb, int tfin, int bass, int bfin)
 Set Bass.
uint16_t VsCodecBeep (NUTDEVICE *dev, uint16_t fsin)
 Start or stop sine wave beeper.
int VsDecoderBufferInit (NUTDEVICE *dev, uint32_t size)
void FeederThread (void *arg)
int VsCodecIOCtl (NUTDEVICE *dev, int req, void *conf)
 Handle I/O controls for audio codec.
int VsCodecRead (NUTFILE *nfp, void *data, int len)
 Read from the encoder.
int VsCodecWrite (NUTFILE *nfp, const void *data, int len)
 Write to decoder.
int VsCodecWrite_P (NUTFILE *nfp, PGM_P buffer, int len)
 Write program data to decoder.
NUTFILEVsCodecOpen (NUTDEVICE *dev, const char *name, int mode, int acc)
int VsCodecClose (NUTFILE *nfp)

Variables

uint8_t zero_chunk [VSCODEC_DATA_CHUNK_SIZE]
NUTDEVICE devVsCodec
 VS10XX device information structure.
NUTDEVICE devSpiVsCodec0
uint8_t zero_chunk [VSCODEC_DATA_CHUNK_SIZE]
NUTDEVICE devVsCodec
 VS10XX device information structure.

Mode Control Register

#define VS_MODE_REG   0
 Register index.
#define VS_SM_DIFF   0x0001
 Left channel inverted.
#define VS_SM_RESET   0x0004
 Allow MPEG Layers I & II.
#define VS_SM_DACT   0x0100
 VS1001 MPEG Layers I & II enable.
#define VS_SM_BITORD   0x0200
 Data bus bit order.
#define VS_SM_SDIORD   0x0200
 SDI most significant bit last.

Status Register

VS1001K master mode.

Untested and not recommended.

Note, that this bit is available on the VS1001 only and is used as a chip select mode flag on other members of the VS10xx family.

Share SPI chip select.

VS1001K master mode clock speed.

Untested and not recommended.

Note, that this bit is available on the VS1001 only and is used as an SDI mode flag on other members of the VS10xx family.

VS1002 native SDI mode.

Default is 0 on the VS1011E and 1 on the VS1002.

Not available on the VS1001K.

ADPCM recording.

Available on VS1033 and VS1053.

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.

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 and VS1053.

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 and VS1053.

#define VS_STATUS_REG   1
 Register index.
#define VS_SS_APDOWM1   0x0004
 Internal analog volume control mask.
#define VS_SS_APDOWN2   0x0008
 Analog driver power down.
#define VS_SS_VER   0x00F0
 Version mask.
#define VS_SS_VER_LSB   4
 Version LSB.
#define VS1001_SS_VER   0
#define VS1011_SS_VER   1
#define VS1011E_SS_VER   2
#define VS1002_SS_VER   2
#define VS1003_SS_VER   3
#define VS1053_SS_VER   4
#define VS1033_SS_VER   5
#define VS1063_SS_VER   6
#define VS1103_SS_VER   7

Clock Frequency and Multiplier Register

Register index.

On some earlier chips, audio interrupts may be missed when writing to this register.

For the VS1001K see VS_SM_BASS.

#define VS_CLOCKF_REG   3
 Register index.

Decode Time Register

Clock frequency mask.

Should be set to crystal clock divided by 2000, if the clock is not 24.576 MHz.

Must be set before beginning decoding MP3 data. Otherwise the sample rate will not be set correctly.

Used for the VS1001, VS1011 and VS1002.

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, VS1033 and VS1053.

Allowed multiplier addition.

Used for WMA decoding with the VS1003, VS1033 and VS1053.

Summand 0.5 is not available on the VS1053.

Clock multiplier.

Available on the VS1003, VS1033 and VS1053. However, multiplier 1.5 is not available on the VS1053.

Clock doubler enable.

Used for the VS1001, VS1011 and VS1002.

#define VS_DECODE_TIME_REG   4
 Register index.

Miscellaneous Audio Data Register

#define VS_AUDATA_REG   5
 Register index.
#define VS_AD_STEREO   0x8000
 Stereo flag.

RAM Read/Write Register

Current sampling rate mask.

Value is sample rate divided by 2. Writing to this register will change the sample rate on the run.

To reduce the digital power consumption when idle, you can set a low sample rate.

Current bit rate mask.

Current sampling rate index mask.

#define VS_WRAM_REG   6
 Register index.

RAM Read/Write Base Address Register

#define VS_WRAMADDR_REG   7
 Register index.

Application Start Address Register

Register index.

Used to activate previously uploaded application programs.

#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.
#define VS_VOL_MAX   0x0000
#define VS_VOL_MIN   0xFEFE
#define VS_VOL_OFF   0xFFFF

Internal Command Flags

#define VSREQ_PLAY   0x00000001
 Force immediate player start.
#define VSREQ_CANCEL   0x00000002
 Force immediate player stop.
#define VSREQ_VOLUPD   0x00000004
 Volume update.
#define VSREQ_AUDIOE   0x00000008
 Audio enhancement update.
#define VSREQ_BEEP   0x00000010
 Sine wave test.
#define VSREQ_RECORD   0x00000020
 Start recording.

Define Documentation

#define AUDIO0_DAC_MIN_GAIN   -127
#define AUDIO0_DAC_MAX_GAIN   0
#define AUDIO_DAC_MIN_GAIN   AUDIO0_DAC_MIN_GAIN
#define AUDIO_DAC_MAX_GAIN   AUDIO0_DAC_MAX_GAIN
#define AUDIO_DAC_MAX_TREB   8

Referenced by VsDecoderSetBass().

#define AUDIO_DAC_MAX_TFIN   15

Referenced by VsDecoderSetBass().

#define AUDIO_DAC_MAX_BASS   15

Referenced by VsDecoderSetBass().

#define AUDIO_DAC_MAX_BFIN   15

Referenced by VsDecoderSetBass().

#define AUDIO_SETWRITETIMEOUT   0x010d
#define AUDIO_GETWRITETIMEOUT   0x010e
#define AUDIO_PLAY   0x3001

Immediately start playing.

#define AUDIO_CANCEL   0x3002

Immediately stop playing and discard buffer.

#define AUDIO_GET_STATUS   0x3003
#define AUDIO_GET_PLAYGAIN   0x3004
#define AUDIO_SET_PLAYGAIN   0x3005
#define AUDIO_GET_PBSIZE   0x3006
#define AUDIO_SET_PBSIZE   0x3007
#define AUDIO_GET_PBLEVEL   0x3008
#define AUDIO_GET_PBWLOW   0x3009
#define AUDIO_SET_PBWLOW   0x300A
#define AUDIO_GET_PBWHIGH   0x300B
#define AUDIO_SET_PBWHIGH   0x300C
#define AUDIO_BEEP   0x300F
#define AUDIO_GET_DECINFO   0x3010

Retrieve decoder information.

#define AUDIO_GET_DECCAPS   0x3011

Retrieve decoder capabilities.

#define AUDIO_GET_DECFMTS   0x3012

Retrieve decoder formats.

#define AUDIO_FMT_PLUGIN   0x00000001
#define AUDIO_FMT_WAV_PCM   0x00000002
#define AUDIO_FMT_WAV_ADPCM   0x00000004
#define AUDIO_FMT_WAV_IMA_ADPCM   0x00000008

Referenced by VsCodecOpen().

#define AUDIO_FMT_VORBIS   0x00000100

Referenced by VsCodecOpen(), and VsCodecRead().

#define AUDIO_FMT_MPEG1_L1   0x00001000
#define AUDIO_FMT_MPEG1_L2   0x00002000
#define AUDIO_FMT_MPEG1_L3   0x00004000
#define AUDIO_FMT_MPEG2_AAC   0x00010000
#define AUDIO_FMT_MPEG4_AAC   0x00020000
#define AUDIO_FMT_WMA_V2   0x00100000
#define AUDIO_FMT_WMA_V7   0x00200000
#define AUDIO_FMT_WMA_V8   0x00400000
#define AUDIO_FMT_WMA_V9   0x00800000
#define AUDIO_SET_DECFMTS   0x3013

Enable or disable specific decoder formats.

#define AUDIO_GET_CODINFO   0x3014

Retrieve encoder information.

#define AUDIO_GET_CODCAPS   0x3015

Retrieve encoder capabilities.

#define AUDIO_GET_CODFMTS   0x3016

Retrieve encoder formats.

#define AUDIO_SET_CODFMTS   0x3017

Enable or disable specific encoder formats.

#define AUDIO_GET_MIDINFO   0x3018

Retrieve midi information.

#define AUDIO_GET_MIDCAPS   0x3019

Retrieve midi capabilities.

#define AUDIO_FMT_GMIDI1   0x00000001
#define AUDIO_FMT_GMIDI2   0x00000002
#define AUDIO_FMT_SPMIDI0   0x00000004
#define AUDIO_SET_TREB   0x301a

Set audio enhancement treble value.

Referenced by VsCodecIOCtl().

#define AUDIO_GET_TREB   0x301b

Get audio enhancement treble value.

#define AUDIO_SET_TFIN   0x301c

Set audio enhancement treble frequency.

Referenced by VsCodecIOCtl().

#define AUDIO_GET_TFIN   0x301d

Get audio enhancement treble frequency.

#define AUDIO_SET_BASS   0x301e

Set audio enhancement bass value.

Referenced by VsCodecIOCtl().

#define AUDIO_GET_BASS   0x301f

Get audio enhancement bass value.

#define AUDIO_SET_BFIN   0x3020

Set audio enhancement bass frequency.

Referenced by VsCodecIOCtl().

#define AUDIO_GET_BFIN   0x3021

Get audio enhancement bass frequency.

#define AUDIO_PLUGIN_UPLOAD   0x3030

Upload plug-in.

Referenced by VsCodecIOCtl().

#define AUDIO_IRQ_ENABLE   0x3031

Enable interrupts.

Referenced by VsCodecOpen().

#define AUDIO_SET_ICLOCK   0x3032

Set internal clock.

#define AUDIO_WRITE_CMEM   0x3038

Upload into WRAM.

Referenced by VsCodecIOCtl().

#define AUDIO_SET_PARAMX   0x3040

Set parametric x.

#define AUDIO_GET_PARAMX   0x3041

Get parametric x.

#define VSP4_CHIP_ID_OFF   0x00
#define VSP4_VERSION_OFF   0x02
#define VSP4_CONFIG1_OFF   0x03
#define VSP4_PLAY_SPEED_OFF   0x04
#define VSP4_BIT_RATE_PER_100_OFF   0x05
#define VSP4_END_FILL_BYTE_OFF   0x06
#define VSP4_RATE_TUNE_OFF   0x07
#define VSP4_PLAY_MODE_OFF   0x09
#define VSP4_SAMPLE_COUNTER_OFF   0x0a
#define VSP4_VU_METER_OFF   0x0c
#define VSP4_AD_MIXER_GAIN_OFF   0x0d
#define VSP4_AD_MIXER_CONFIG_OFF   0x0e
#define VSP4_PCM_MIXER_RATE_OFF   0x0f
#define VSP4_PCM_MIXER_FREE_OFF   0x10
#define VSP4_PCM_MIXER_VOL_OFF   0x11
#define VSP4_EQ5_PARAMS_OFF (   i)    (0x12 + (i))
#define VSP4_EQ5_UPDATED_OFF   0x1c
#define VSP4_SPEED_SHIFTER_OFF   0x1d
#define VSP4_EAR_SPEAKER_LEVEL_OFF   0x1e
#define VSP4_SDI_FREE_OFF   0x1f
#define VSP4_AUDIO_FILL_OFF   0x20
#define VSP4_LATEST_SOF_OFF   0x25
#define VSP4_POSITION_MSEC_OFF   0x27
#define VSP4_RESYNC_OFF   0x29
#define VSP4_ENC_TX_UART_DIV_OFF   0x2a
#define VSP4_ENC_TX_UART_BYTE_SPEED_OFF   0x2b
#define VSP4_ENC_TX_PAUSE_GPIO_OFF   0x2c
#define VSP4_ENC_SEC_ADAPT_MULTIPLIER_OFF   0x2d
#define VSP4_ENC_CHANNEL_MAX_OFF   0x3c
#define VSP4_ENC_SERIAL_NUMBER_OFF   0x3e
#define VSP4_WMA_CUR_PACKET_SIZE_OFF   0x2a
#define VSP4_WMA_PACKET_SIZE_OFF   0x2c
#define VSP4_AAC_SCE_FOUND_MASK_OFF   0x2a
#define VSP4_AAC_CPE_FOUND_MASK_OFF   0x2b
#define VSP4_AAC_LFE_FOUND_MASK_OFF   0x2c
#define VSP4_AAC_PLAY_SELECT_OFF   0x2d
#define VSP4_AAC_DYN_COMPRESS_OFF   0x2e
#define VSP4_AAC_DYN_BOOST_OFF   0x2f
#define VSP4_AAC_SBR_AND_PS_STATUS_OFF   0x30
#define VSP4_AAC_SBR_PS_FLAGS_OFF   0x31
#define VSP4_VORBIS_GAIN_OFF   0x2a
#define VS_PLAYMODE_MONO_OUTPUT_ON   ox0001
#define VS_PLAYMODE_PAUSE_ON   0x0002
#define VS_PLAYMODE_VUMETER_ON   0x0004
#define VS_PLAYMODE_ADMIXER_ON   0x0008
#define VS_PLAYMODE_PCMMIXER_ON   0x0010
#define VS_PLAYMODE_EQ5_ON   0x0020
#define VS_PLAYMODE_SPEEDSHIFTER_ON   0x0040
#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_RESET   0x0004

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.

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.

Soft reset.

Bit is cleared automatically.

#define VS_SM_DACT   0x0100

VS1001 MPEG Layers I & II enable.

This bit is marked unused in later VS1001 datasheet versions and may not work due to firmware problems.

Note, that this bit was available on the VS1001K only and is used as a cancel flag on other members of the VS10xx family.

If you enable Layer I and Layer II decoding, you are liable for any patent issues that may arise.

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.

Stop decoding in the middle.

Set this bit to stop decoding a in the middle, and continue sending data honouring DREQ. When this flag is detected by a codec, it will stop decoding and discard stream buffer content. The flag is cleared automatically and SCI HDAT1 will also be cleared.

Available on the VS1053.

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.

EarSpeaker spatial processing.

VS1001K DAC mode.

16-bit DAC mode if set, MP3 mode otherwise.

This bit is marked unused in later VS1001 datasheet versions and may not work due to firmware problems.

Note, that this bit was available on the VS1001 only and is used as a test mode flag on other members of the VS10xx family.

Allow SDI tests.

Not required for the VS1001K, where tests are enabled by default.

VS1001K DAC mono mode.

DAC mono mode if set, stereo mode otherwise.

This bit is marked unused in later VS1001 datasheet versions and may not work due to firmware problems.

Note, that this bit was available on the VS1001 only and is used as a streaming mode flag on other members of the VS10xx family.

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.

VS1001K bass/treble enhancer.

When set, this bit turns on the built-in bass and treble enhancer.

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_BITORD   0x0200

Data bus bit order.

When clear the most significant bit is sent first, which is the default. This register bit has no effect on the SCI bus.

#define VS_SM_SDIORD   0x0200

SDI most significant bit last.

Same as VS_SM_BITORD.

#define VS_STATUS_REG   1

Register index.

#define VS_SS_APDOWM1   0x0004

Internal analog volume control mask.

These bits is meant to be used by the internal firmware only.

  • 0 for 0 dB
  • 1 for -6 dB
  • 3 for -12 dB

Reference voltage selection.

If AVDD is at least higher than 3.3V, then this bit can be set to select 1.65V reference voltage to increase the analog output swing.

See VS_SS_AD_CLOCK for more information about using this bit with the VS1053b.

AD clock divider.

This bit can be set to divide the AD modulator frequency by 2.

Due to a firmware bug in VS1053b, volume calculation routine clears VS_SS_AD_CLOCK and VS_SS_VREF_1_65 bits. Write to VS_STATUS_REG or VS_VOL_REG as well as sample rate change with bass enhancer or treble control actived, causes the volume calculation routine to be called.

As a workaround you can write to VS_STATUS_REG through VS_WRAMADDR_REG and VS_WRAM_REG after each volume change. Write 0xC001 to VS_WRAMADDR_REG, then write the value to VS_WRAM_REG. However, the difference in performance between the modes is not significant, so it is easier to just use the default mode.

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 VS1001 and VS1011 with a minimum power-off transient, this bit should be set to 1 a few milliseconds before activating reset.

With newer chips set the volume register to 0xFFFF a few milliseconds before reset.

#define VS_SS_VER   0x00F0

Version mask.

  • 0 for VS1001
  • 1 for VS1011
  • 2 for VS1002 and VS1011E, see VS_SM_SDINEW
  • 3 for VS1003
  • 4 for VS1053
  • 5 for VS1033
  • 7 for VS1103
#define VS_SS_VER_LSB   4

Version LSB.

#define VS1001_SS_VER   0
#define VS1011_SS_VER   1
#define VS1011E_SS_VER   2
#define VS1002_SS_VER   2
#define VS1003_SS_VER   3
#define VS1053_SS_VER   4
#define VS1033_SS_VER   5
#define VS1063_SS_VER   6
#define VS1103_SS_VER   7
#define VS_CLOCKF_REG   3

Register index.

#define VS_DECODE_TIME_REG   4

Register index.

This register contains the decode time in full seconds or zero after resetting the decoder.

The user may change the value of this register. However, in that case the new value should be written twice.

#define VS_AUDATA_REG   5

Register index.

Usage on the VS1001K differs.

#define VS_AD_STEREO   0x8000

Stereo flag.

1 for stereo and 0 for mono. Read-only.

On the VS1001K the most significant bit is used as a stereo indicator.

#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_AIADDR_REG   10

Register index.

#define VS_VOL_REG   11

Register index.

After hardware reset, volume is at maximum value. Software reset does not change volume settings.

Setting this register to VS_VOL_OFF will put the chip in analog power down mode.

On some earlier chips, audio interrupts may be missed when writing to this register. This will not happen on the VS1053, where volume changes are delayed until the next batch of samples are sent to the audio FIFO.

#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.

#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.

#define VS_VOL_MAX   0x0000
#define VS_VOL_MIN   0xFEFE
#define VS_VOL_OFF   0xFFFF
#define VS_FLUSH_BYTES   2048

Application register 0 index.

Do not use with VS1001. Also used for mixer volume on the VS1103.

VS1001K application register 0 index.

A second register is available at VS_AICTRL_REG + 1.

Application register 1 index.

Register 0 on the VS1001. Also used for IMA ADPCM record control in the VS1103.

Application register 2 index.

Register 1 on the VS1001.

Application register 3 index.

Do not use with VS1001.

#define CODEC_STATUS_IDLE   0
#define CODEC_STATUS_PLAYING   1
#define CODEC_STATUS_RECORDING   2

Referenced by FeederThread().

#define VSCODEC_CMD_TIMEOUT   NUT_WAIT_INFINITE

Minimum time in milliseconds to held hardware reset low.

Referenced by VsCodecReg().

#define VSCODEC_DATA_CHUNK_SIZE   32

Number of data bytes we can send without checking DREQ.

#define VSREQ_PLAY   0x00000001

Force immediate player start.

Referenced by FeederThread(), and VsCodecIOCtl().

#define VSREQ_CANCEL   0x00000002

Force immediate player stop.

Referenced by FeederThread(), and VsCodecIOCtl().

#define VSREQ_VOLUPD   0x00000004

Volume update.

Referenced by FeederThread(), and VsCodecIOCtl().

#define VSREQ_AUDIOE   0x00000008

Audio enhancement update.

Referenced by FeederThread(), and VsCodecIOCtl().

#define VSREQ_BEEP   0x00000010

Sine wave test.

Referenced by FeederThread(), and VsCodecIOCtl().

#define VSREQ_RECORD   0x00000020

Start recording.

Referenced by FeederThread(), and VsCodecRead().

#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   4

Milliseconds to wait after hardware reset.

#define VS10XX_SWRST_RECOVER   2

Milliseconds to wait after software reset.

#define VS10XX_SCI_MODE   0
#define VS10XX_SCI_RATE   (VS10XX_FREQ / 6)
#define VS10XX_SDI_MODE   0
#define VS10XX_SDI_RATE   (VS10XX_FREQ / 6)
#define VSREQ_PLAY   0x00000001

Referenced by FeederThread().

#define VSREQ_CANCEL   0x00000002

Referenced by FeederThread().

#define VSREQ_BEEP   0x00000004

Referenced by FeederThread().


Typedef Documentation

typedef struct _VS_WRAM_DATA VS_WRAM_DATA
typedef struct _VSDCB VSDCB

Internal codec control block.

typedef struct _VSDCB VSDCB

Function Documentation

int VsCodecWaitReady ( NUTDEVICE dev,
uint32_t  tmo 
)

Wait until codec is ready.

Parameters:
devSepcifies the codec device.
tmoMaximum number of milliseconds to wait.
Returns:
0 on success, -1 on time out.

References _VSDCB::dcb_feedme, _VSDCB::dcb_isready, _NUTDEVICE::dev_dcb, and NutEventWait().

Referenced by FeederThread(), and VsCodecReg().

Here is the call graph for this function:

uint16_t VsCodecReg ( NUTDEVICE dev,
uint_fast8_t  op,
uint_fast8_t  reg,
uint_fast16_t  val 
)

References _VSDCB::dcb_sendcmd, _NUTDEVICE::dev_dcb, VSCODEC_CMD_TIMEOUT, and VsCodecWaitReady().

Referenced by FeederThread(), VsCodecMode(), VsDecoderSetBass(), and VsDecoderSetVolume().

Here is the call graph for this function:

uint16_t VsCodecMode ( NUTDEVICE dev,
uint_fast16_t  flags,
uint_fast16_t  mask 
)

Read and modify VLSI audio codec mode flags.

Set both, flags and mask to zero to read the flags without change.

Parameters:
devSpecifies the audio codec device.
flagsMode flags to set. All other flags are disabled, if they appear in the mask.
maskMode flags to update. All other flags are left unchanged.
Returns:
Previous mode flags.

References NutSleep(), rc, VS_MODE_REG, VS_OPCODE_READ, VS_OPCODE_WRITE, VS_SM_RESET, and VsCodecReg().

Referenced by FeederThread(), VsCodecBeep(), and VsCodecOpen().

Here is the call graph for this function:

int VsDecoderSetVolume ( NUTDEVICE dev,
int  left,
int  right 
)

Set volume.

Parameters:
devSpecifies the audio codec device.
leftLeft channel gain in db.
rightRight channel gain in db.
Returns:
Always 0.

References AUDIO_DAC_MAX_GAIN, AUDIO_DAC_MIN_GAIN, _VSDCB::dcb_lvol, _VSDCB::dcb_rvol, _NUTDEVICE::dev_dcb, VS_OPCODE_WRITE, VS_VOL_LEFT_LSB, VS_VOL_REG, VS_VOL_RIGHT_LSB, and VsCodecReg().

Referenced by FeederThread().

Here is the call graph for this function:

int VsDecoderSetBass ( NUTDEVICE dev,
int  treb,
int  tfin,
int  bass,
int  bfin 
)

Set Bass.

Parameters:
devSpecifies the audio codec device.
trebTreble amplitude x 1.5dB.
tsetTreble frequency limit x 1000Hz
bassBass amplitude x 1dB.
bsetBass frequency limit x 10Hz
Returns:
Always 0.

References AUDIO_DAC_MAX_BASS, AUDIO_DAC_MAX_BFIN, AUDIO_DAC_MAX_TFIN, AUDIO_DAC_MAX_TREB, _VSDCB::dcb_bass, _VSDCB::dcb_bfin, _VSDCB::dcb_tfin, _VSDCB::dcb_treb, _NUTDEVICE::dev_dcb, VS_BASS_REG, VS_OPCODE_WRITE, VS_SB_AMPLITUDE_LSB, VS_SB_FREQLIMIT_LSB, VS_ST_AMPLITUDE_LSB, VS_ST_FREQLIMIT_LSB, and VsCodecReg().

Referenced by FeederThread().

Here is the call graph for this function:

uint16_t VsCodecBeep ( NUTDEVICE dev,
uint16_t  fsin 
)

Start or stop sine wave beeper.

Old, VS1001 compatible routine, which supports a limit number of frequencies only. It will try to find the best value.

Parameters:
devSpecifies the audio codec device.
fsinFrequency, or 0 to switch beeper off.
Returns:
Actual frequency set.

References _VSDCB::dcb_senddata, _NUTDEVICE::dev_dcb, rc, VS_SM_RESET, VS_SM_TESTS, and VsCodecMode().

Referenced by FeederThread().

Here is the call graph for this function:

int VsDecoderBufferInit ( NUTDEVICE dev,
uint32_t  size 
)

References CODEC_STATUS_IDLE, _VSDCB::dcb_pbstat, _VSDCB::dcb_pbwhi, _VSDCB::dcb_pbwlo, _NUTDEVICE::dev_dcb, NULL, NutSegBufAvailable(), and NutSegBufInit().

Referenced by VsCodecIOCtl().

Here is the call graph for this function:

int VsCodecIOCtl ( NUTDEVICE dev,
int  req,
void *  conf 
)

Handle I/O controls for audio codec.

Parameters:
devSpecifies the audio codec device.
  • AUDIO_PLAY Force playback start, even if the buffer level is too lower.
  • AUDIO_CANCEL Cancel playback and discard all buffered data.
  • AUDIO_GET_STATUS Sets an int to 1 if the player is running, 0 if idle.
  • AUDIO_GET_PLAYGAIN Sets an int to the current playback gain, 0..-127.
  • AUDIO_SET_PLAYGAIN Reads the requested playback gain from an int, 0..-127.
  • AUDIO_GET_PBSIZE Sets an unsigned long with the size of the playback buffer.
  • AUDIO_SET_PBSIZE Sets the size the playback buffer using an unsigned long.
  • AUDIO_GET_PBLEVEL Sets an unsigned long with the number of bytes in the playback buffer.
  • AUDIO_GET_PBWLOW Sets an unsigned long with the low watermark of the playback buffer.
  • AUDIO_SET_PBWLOW Sets the low watermark (unsigned long) of the playback buffer.
  • AUDIO_GET_PBWHIGH Sets an unsigned long with the high watermark of the playback buffer.
  • AUDIO_SET_PBWHIGH Sets the high watermark (unsigned long) of the playback buffer.
  • AUDIO_BEEP Plays a short sine wave beep.
Returns:
0 on success, -1 otherwise.

References AUDIO_BEEP, AUDIO_CANCEL, AUDIO_GET_CODCAPS, AUDIO_GET_CODINFO, AUDIO_GET_DECCAPS, AUDIO_GET_DECINFO, AUDIO_GET_MIDCAPS, AUDIO_GET_MIDINFO, AUDIO_GET_PBLEVEL, AUDIO_GET_PBSIZE, AUDIO_GET_PBWHIGH, AUDIO_GET_PBWLOW, AUDIO_GET_PLAYGAIN, AUDIO_GET_STATUS, AUDIO_GETWRITETIMEOUT, AUDIO_PLAY, AUDIO_PLUGIN_UPLOAD, AUDIO_SET_BASS, AUDIO_SET_BFIN, AUDIO_SET_PBSIZE, AUDIO_SET_PBWHIGH, AUDIO_SET_PBWLOW, AUDIO_SET_PLAYGAIN, AUDIO_SET_TFIN, AUDIO_SET_TREB, AUDIO_SETWRITETIMEOUT, AUDIO_WRITE_CMEM, CODEC_STATUS_IDLE, CODEC_STATUS_PLAYING, _VSDCB::dcb_bass, _VSDCB::dcb_bfin, _VSDCB::dcb_cod_caps, _VSDCB::dcb_control, _VSDCB::dcb_dec_caps, _VSDCB::dcb_feedme, _VSDCB::dcb_lvol, _VSDCB::dcb_midi_caps, _VSDCB::dcb_pbstat, _VSDCB::dcb_pbwhi, _VSDCB::dcb_pbwlo, _VSDCB::dcb_rvol, _VSDCB::dcb_scmd, _VSDCB::dcb_sinefreq, _VSDCB::dcb_tfin, _VSDCB::dcb_treb, _VSDCB::dcb_wtmo, _NUTDEVICE::dev_dcb, NutEventPost(), NutSegBufAvailable(), NutSegBufUsed(), rc, VsDecoderBufferInit(), VSREQ_AUDIOE, VSREQ_BEEP, VSREQ_CANCEL, VSREQ_PLAY, and VSREQ_VOLUPD.

Referenced by VsCodecOpen().

Here is the call graph for this function:

int VsCodecRead ( NUTFILE nfp,
void *  data,
int  len 
)

Read from the encoder.

Parameters:
nfpPointer to a NUTFILE structure, obtained by a previous call to VsCodecOpen().
dataPointer to the data buffer. If NULL, the buffered data will be flushed.
lenNumber of bytes to read. If 0, all buffered data will be flushed.
Returns:
Number of characters sent. If a read timeout had been set, then this may be less than the specified length.

References AUDIO_FMT_VORBIS, CODEC_STATUS_IDLE, CODEC_STATUS_PLAYING, _VSDCB::dcb_bufque, _VSDCB::dcb_cod_mode, _VSDCB::dcb_feedme, _VSDCB::dcb_pbstat, _VSDCB::dcb_rtmo, _VSDCB::dcb_scmd, _NUTDEVICE::dev_dcb, memcpy(), _NUTFILE::nf_dev, NULL, NutEventPost(), NutEventWait(), NutSegBufReadLast(), NutSegBufReadRequest(), rc, and VSREQ_RECORD.

Here is the call graph for this function:

int VsCodecWrite ( NUTFILE nfp,
const void *  data,
int  len 
)

Write to decoder.

Parameters:
nfpPointer to a NUTFILE structure, obtained by a previous call to VsCodecOpen().
dataPointer to the data buffer. If NULL, the buffered data will be flushed.
lenNumber of bytes that are available in the buffer. If 0, all buffered data will be flushed.
Returns:
Number of characters sent. If a write timeout had been set, then this may be less than the specified length.

References _VSDCB::dcb_bufque, _VSDCB::dcb_feedme, _VSDCB::dcb_wtmo, _NUTDEVICE::dev_dcb, memcpy(), _NUTFILE::nf_dev, NULL, NutEventPost(), NutEventWait(), NutSegBufWriteLast(), NutSegBufWriteRequest(), and rc.

Here is the call graph for this function:

int VsCodecWrite_P ( NUTFILE nfp,
PGM_P  buffer,
int  len 
)

Write program data to decoder.

Similar to VsCodecWrite() except that the data is expected in program memory.

This function is implemented for CPUs with Harvard Architecture only.

This function is called by the low level output routines of the C runtime library, using the _NUTDEVICE::dev_write_P entry.

Parameters:
nfpPointer to a NUTFILE structure, obtained by a previous call to VsCodecOpen().
bufferPointer to the data in program space. If zero, then the output buffer will be flushed.
lenNumber of bytes to write.
Returns:
The number of bytes written. A return value of -1 indicates an error. Currently this function is not implemented and always returns -1.
NUTFILE* VsCodecOpen ( NUTDEVICE dev,
const char *  name,
int  mode,
int  acc 
)

References _O_WRONLY, AUDIO_FMT_VORBIS, AUDIO_FMT_WAV_IMA_ADPCM, AUDIO_IRQ_ENABLE, _VSDCB::dcb_cod_mode, _NUTDEVICE::dev_dcb, malloc(), _NUTFILE::nf_dev, _NUTFILE::nf_fcb, _NUTFILE::nf_next, NULL, NutSegBufReset(), strcmp(), VS_SM_RESET, VsCodecIOCtl(), and VsCodecMode().

Here is the call graph for this function:

int VsCodecClose ( NUTFILE nfp)

References _VSDCB::dcb_wtmo, _NUTDEVICE::dev_dcb, free(), _NUTFILE::nf_dev, and rc.

Here is the call graph for this function:


Variable Documentation

uint8_t zero_chunk[VSCODEC_DATA_CHUNK_SIZE]

VS10XX device information structure.

An application must pass a pointer to this structure to NutRegisterDevice() before using this driver.

The device is named audio0.

uint8_t zero_chunk[VSCODEC_DATA_CHUNK_SIZE]
Initial value:
 {
    0,              
    {'a', 'u', 'd', 'i', 'o', '0', 0, 0, 0},    
    IFTYP_CHAR,     
    0,              
    0,              
    0,              
    &dcb,           
    VsInit,         
    VsIOCtl,        
    NULL,           
    VsWrite,        

    VsWrite_P,      

    VsOpen,         
    VsClose,        
    NULL            
}

VS10XX device information structure.

An application must pass a pointer to this structure to NutRegisterDevice() before using this driver.

The device is named audio0.