Main Page Data Structures File List Data Fields Globals Related Pages

# vs1001.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Defines
#define | SDI_DMACHANNEL 0
#define | SDI_DATAREG 0x130
#define | SCI_XCSPIO 10
#define | SCI_SCLKPIO 11
#define | SCI_SIPIO 12
#define | SCI_SOPIO 9
#define | SCI_MODE 0
#define | SCI_STATUS 1
#define | SCI_CLOCKF 3
#define | SCI_DECTIME 4
#define | SCI_AUDATA 5
#define | SCI_WRAM 6
#define | SCI_WRAMADR 7
#define | SCI_HDAT0 8
#define | SCI_HDAT1 9
#define | SCI_A1ADDR 10
#define | SCI_VOL 11
#define | SCI_A1CTRL0 12
#define | SCI_A1CTRL1 13
#define | SCI_A1CTRL2 14
#define | SM_DIFF 1
#define | SM_FFWD 2
#define | SM_RESET 4
#define | SM_MP12 8
#define | SM_PDOWN 16
#define | SM_DAC 32
#define | SM_DACMONO 64
#define | SM_BASS 128
#define | SM_DACT 256
#define | SM_BYTEORD 512
#define | SM_IBMODE 1024
#define | SM_IBCLK 2048
#define | VS_OK 0
#define | VS_TIMEOUT 1
#define | VS_FIFOSIZE 2048
#define | VS_CLOCK 12288000L
## Functions
void | VS_Init ()
| Set up hardware resources for the VS1001 interface.
void | VS_Done ()
| Free all resources used by the VS1001 interface.
void | VS_Reset ()
| Initiate a software reset.
void | VS_SCITest ()
| Test SCI Interface - generate snapping sounds.
void | VS_SDITest ()
| Test SDI Interface - generate short beeps.
void | VS_SetClockFreq (long frequency)
| Set Clock frequency.
void | VS_SetVolume (int left, int right)
| Set the output volume for both channels.
void | VS_SetBassBoost (bool onoff)
| Enable bass and treble enhancement (VS1001k only).
int | VS_PlayMpegSync (char *data, unsigned len)
| Play a block of MPEG Data, and wait for completion.
void | VS_PlayMpegAsync (char *data, unsigned len, void(*function)(void *), void *param)
| Asynchronously play a block of MPEG data.
void | VS_Stop ()
| Stop playback of current stream.
bool | VS_IsPlaying ()
| Check asynchronous playback status.
void | VS_GetMPEGHeader (unsigned long *header)
| Get MPEG Header information.

## Define Documentation

#define SCI_A1ADDR 10

| Definition at line 21 of file vs1001.h. Referenced by VS_Dump().

#define SCI_A1CTRL0 12

| Definition at line 23 of file vs1001.h. Referenced by VS_Dump().

#define SCI_A1CTRL1 13

| Definition at line 24 of file vs1001.h. Referenced by VS_Dump().

#define SCI_A1CTRL2 14

| Definition at line 25 of file vs1001.h. Referenced by VS_Dump().

#define SCI_AUDATA 5

| Definition at line 16 of file vs1001.h. Referenced by VS_Dump().

#define SCI_CLOCKF 3

| Definition at line 14 of file vs1001.h. Referenced by VS_Dump(), and VS_SetClockFreq().

#define SCI_DECTIME 4

| Definition at line 15 of file vs1001.h. Referenced by VS_Dump().

#define SCI_HDAT0 8

| Definition at line 19 of file vs1001.h. Referenced by VS_Dump(), and VS_GetMPEGHeader().

#define SCI_HDAT1 9

| Definition at line 20 of file vs1001.h. Referenced by VS_Dump(), and VS_GetMPEGHeader().

#define SCI_MODE 0

| Definition at line 12 of file vs1001.h. Referenced by VS_Dump(), VS_Reset(), and VS_SetBassBoost().

#define SCI_SCLKPIO 11

| Definition at line 8 of file vs1001.h. Referenced by SCI_Read(), SCI_ReadReg(), SCI_Write(), SCI_WriteReg(), and VS_Init().

#define SCI_SIPIO 12

| Definition at line 9 of file vs1001.h. Referenced by SCI_Write(), and VS_Init().

#define SCI_SOPIO 9

| Definition at line 10 of file vs1001.h. Referenced by SCI_Read(), and VS_Init().

#define SCI_STATUS 1

| Definition at line 13 of file vs1001.h. Referenced by VS_Dump().

#define SCI_VOL 11

| Definition at line 22 of file vs1001.h. Referenced by VS_Dump(), and VS_SetVolume().

#define SCI_WRAM 6

| Definition at line 17 of file vs1001.h.

#define SCI_WRAMADR 7

| Definition at line 18 of file vs1001.h.

#define SCI_XCSPIO 10

| Definition at line 7 of file vs1001.h. Referenced by SCI_ReadReg(), SCI_WriteReg(), and VS_Init().

#define SDI_DATAREG 0x130

| Definition at line 5 of file vs1001.h. Referenced by VS_Init(), and VS_PlayMpegAsync().

#define SDI_DMACHANNEL 0

| Definition at line 4 of file vs1001.h. Referenced by SCI_ReadReg(), SCI_WriteReg(), VS_IsPlaying(), VS_PlayMpegAsync(), VS_Reset(), and VS_Stop().

#define SM_BASS 128

| Definition at line 34 of file vs1001.h. Referenced by VS_SetBassBoost().

#define SM_BYTEORD 512

| Definition at line 36 of file vs1001.h.

#define SM_DAC 32

| Definition at line 32 of file vs1001.h.

#define SM_DACMONO 64

| Definition at line 33 of file vs1001.h.

#define SM_DACT 256

| Definition at line 35 of file vs1001.h.

#define SM_DIFF 1

| Definition at line 27 of file vs1001.h.

#define SM_FFWD 2

| Definition at line 28 of file vs1001.h.

#define SM_IBCLK 2048

| Definition at line 38 of file vs1001.h.

#define SM_IBMODE 1024

| Definition at line 37 of file vs1001.h.

#define SM_MP12 8

| Definition at line 30 of file vs1001.h.

#define SM_PDOWN 16

| Definition at line 31 of file vs1001.h.

#define SM_RESET 4

| Definition at line 29 of file vs1001.h. Referenced by VS_Reset().

#define VS_CLOCK 12288000L

| Definition at line 51 of file vs1001.h. Referenced by VS_Init().

#define VS_FIFOSIZE 2048

| Definition at line 46 of file vs1001.h. Referenced by BUF_Init(), and BUF_Play().

#define VS_OK 0

| Definition at line 40 of file vs1001.h. Referenced by VS_PlayMpegSync().

#define VS_TIMEOUT 1

| Definition at line 41 of file vs1001.h.

## Function Documentation

void VS_Done | ( |  | ) |

| Free all resources used by the VS1001 interface. Definition at line 417 of file vs1001.cpp. References oldDmaHandler, and VS_Stop(). Referenced by main().

void VS_GetMPEGHeader | ( | unsigned long * | header | ) |

  | Get MPEG Header information. Returns the current header for the stream being decoded. Right after reset, 0 will be returned, indicating that no data has been found yet. Parameters:
  pointer | to MpegHeader structure to fill out
Definition at line 250 of file vs1001.cpp. References SCI_HDAT0, SCI_HDAT1, and SCI_ReadReg().

void VS_Init | ( |  | ) |

| Set up hardware resources for the VS1001 interface. Definition at line 384 of file vs1001.cpp. References DmaHandler(), lastBassBoost, lastFrequency, lastVolLeft, lastVolRight, oldDmaHandler, pfe_enable_bus(), pfe_enable_pcs(), pfe_enable_pio(), PIO_IPU, PIO_O0, PIO_O1, SCI_SCLKPIO, SCI_SIPIO, SCI_SOPIO, SCI_XCSPIO, SDI_DATAREG, VS_CLOCK, and VS_Reset(). Referenced by main().

bool VS_IsPlaying | ( |  | ) |

| Check asynchronous playback status. Returns: true if playing, false if stopped. Definition at line 122 of file vs1001.cpp. References AMD_GetDmaInfo(), DmaInfo::control, DCON_ST, and SDI_DMACHANNEL. Referenced by BUF_Play(), http_get(), and VS_PlayMpegSync().

void VS_PlayMpegAsync | ( | char * | data,
|  | unsigned | len,
|  | void(* | function)(void *),
|  | void * | param
| ) |

  | Asynchronously play a block of MPEG data. You can either specify a callback function, or poll the transfer status using VS_IsPlaying() Note: according to the VS1001 documentation, you should keep an eye on the data rate. If DREQ is either always asserted, or always inactive, the decoder most probably choked on some bad mpeg-stream. Parameters:
  data | Pointer to mpeg data
  len | Length of data block
  function | function to call after transfer has finished. May be NULL.
  param | user defined parameter that is passed to the callback function. May be NULL.
Definition at line 149 of file vs1001.cpp. References AMD_EnableDrq(), AMD_StartDma(), callbackFunction, callbackParam, DmaInfo::control, DCON_DSYNC, DCON_INT, DCON_SINC, DCON_SMIO, DCON_TC, DmaInfo::dstPort, DmaInfo::length, SDI_DATAREG, SDI_DMACHANNEL, and DmaInfo::srcMem. Referenced by BUF_Play(), http_get(), and VS_PlayMpegSync().

int VS_PlayMpegSync | ( | char * | data,
|  | unsigned | len
| ) |

  | Play a block of MPEG Data, and wait for completion. Note: you should call VS_Reset after a failed transfer. Most probably the VS1001 choked on some bad mpeg stream, and will continue to work after an reset. Parameters:
  data | Pointer to mpeg data
  len | Length of data block
Todo: (re)implement timeout checking, using RTX_Get_System_Ticks() Definition at line 184 of file vs1001.cpp. References VS_IsPlaying(), VS_OK, and VS_PlayMpegAsync(). Referenced by SDI_WriteZeros(), and VS_SDITest().

void VS_Reset | ( |  | ) |

| Initiate a software reset. All previous VS1001 settings are automatically restored by this function. Definition at line 362 of file vs1001.cpp. References AMD_EnableDrq(), lastBassBoost, lastFrequency, lastVolLeft, lastVolRight, SCI_MODE, SCI_ReadReg(), SCI_WriteReg(), SDI_DMACHANNEL, SDI_WriteZeros(), SM_RESET, usleep(), VS_SetBassBoost(), VS_SetClockFreq(), and VS_SetVolume(). Referenced by http_get(), and VS_Init().

void VS_SCITest | ( |  | ) |

| Test SCI Interface - generate snapping sounds. Definition at line 320 of file vs1001.cpp. References RTX_Sleep_Time(), and VS_SetVolume().

void VS_SDITest | ( |  | ) |

| Test SDI Interface - generate short beeps. Note: the test will be very loud. Do not keep your headphones on while conducting this test. Definition at line 299 of file vs1001.cpp. References RTX_Sleep_Time(), and VS_PlayMpegSync().

void VS_SetBassBoost | ( | bool | onoff | ) |

  | Enable bass and treble enhancement (VS1001k only). Parameters:
  onoff | enable or disable enhancements
Definition at line 284 of file vs1001.cpp. References lastBassBoost, SCI_MODE, SCI_ReadReg(), SCI_WriteReg(), and SM_BASS. Referenced by VS_Reset().

void VS_SetClockFreq | ( | long | frequency | ) |

  | Set Clock frequency. This function needs to be called if the chip is running at something else than 24.576MHz. The Clock frequency may be between 0 .. 65.534 MHz, although hardware limits the highest possible speed. Note: the clock doubler is activated for frequencies <18,432 MHz. This should be reasonable for all operation conditions. Parameters:
  frequency | Clock frequency in Hz
Definition at line 269 of file vs1001.cpp. References lastFrequency, SCI_CLOCKF, and SCI_WriteReg(). Referenced by VS_Reset().

void VS_SetVolume | ( | int | left,
|  | int | right
| ) |

  | Set the output volume for both channels. 255 is the maximum volume, 0 the minimum. Note that a volume setting of 0 will enter the analog powersave mode, and causes a slight snapping sound. If you want to avoid this, set the volume to 1 instead of 0. Parameters:
  left | left volume 0..255
  right | right volume 0..255
Definition at line 234 of file vs1001.cpp. References lastVolLeft, lastVolRight, SCI_VOL, and SCI_WriteReg(). Referenced by VS_Reset(), and VS_SCITest().

void VS_Stop | ( |  | ) |

| Stop playback of current stream. Definition at line 217 of file vs1001.cpp. References AMD_StopDma(), and SDI_DMACHANNEL. Referenced by VS_Done().