Nut/OS  4.10.3
API Reference
vscodec.h File Reference

VLSI decoder definitions. More...

#include <cfg/audio.h>
#include <sys/device.h>
#include <stdint.h>
Include dependency graph for vscodec.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

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

Defines

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

Typedefs

typedef struct _VS_PLUGIN_INFO VS_PLUGIN_INFO
typedef struct _VSDCB VSDCB
 Internal codec control block.

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)
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.
NUTFILEVsCodecOpen (NUTDEVICE *dev, CONST char *name, int mode, int acc)
int VsCodecClose (NUTFILE *nfp)
int VsCodecWrite_P (NUTFILE *nfp, PGM_P buffer, int len)
 Write program data to decoder.
void FeederThread (void *arg)

Variables

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

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

Detailed Description

VLSI decoder definitions.

Definition in file vscodec.h.


Define Documentation

#define AUDIO0_VSAUTO

Definition at line 80 of file vscodec.h.