Adafruit VS1053 Arduino Library
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Adafruit_VS1053 Class Reference

#include <Adafruit_VS1053.h>

Inheritance diagram for Adafruit_VS1053:
Adafruit_VS1053_FilePlayer

Public Member Functions

 Adafruit_VS1053 (int8_t mosi, int8_t miso, int8_t clk, int8_t rst, int8_t cs, int8_t dcs, int8_t dreq)
 Software SPI constructor - must specify all pins. More...
 
 Adafruit_VS1053 (int8_t rst, int8_t cs, int8_t dcs, int8_t dreq)
 Hardware SPI constructor - assumes hardware SPI pins. More...
 
uint8_t begin (void)
 Initialize communication and (hard) reset the chip. More...
 
void reset (void)
 Performs a hard reset of the chip.
 
void softReset (void)
 Attempts a soft reset of the chip.
 
uint16_t sciRead (uint8_t addr)
 Reads from the specified register on the chip. More...
 
void sciWrite (uint8_t addr, uint16_t data)
 Writes to the specified register on the chip. More...
 
void sineTest (uint8_t n, uint16_t ms)
 Generate a sine-wave test signal. More...
 
uint16_t decodeTime (void)
 Reads the DECODETIME register from the chip. More...
 
void setVolume (uint8_t left, uint8_t right)
 Set the output volume for the chip. More...
 
void dumpRegs (void)
 Prints the contents of the MODE, STATUS, CLOCKF and VOLUME registers.
 
void playData (uint8_t *buffer, uint8_t buffsiz)
 Decode and play the contents of the supplied buffer. More...
 
boolean readyForData (void)
 Test if ready for more data. More...
 
void applyPatch (const uint16_t *patch, uint16_t patchsize)
 Apply a code patch. More...
 
uint16_t loadPlugin (char *fn)
 Load the specified plug-in. More...
 
void GPIO_digitalWrite (uint8_t i, uint8_t val)
 Write to a GPIO pin. More...
 
void GPIO_digitalWrite (uint8_t i)
 Write to all 8 GPIO pins at once. More...
 
uint16_t GPIO_digitalRead (void)
 Read all 8 GPIO pins at once. More...
 
boolean GPIO_digitalRead (uint8_t i)
 Read a single GPIO pin. More...
 
void GPIO_pinMode (uint8_t i, uint8_t dir)
 Set the Pin Mode (INPUT/OUTPUT) for a GPIO pin. More...
 
boolean prepareRecordOgg (char *plugin)
 Initialize chip for OGG recording. More...
 
void startRecordOgg (boolean mic)
 Start recording. More...
 
void stopRecordOgg (void)
 Stop the recording.
 
uint16_t recordedWordsWaiting (void)
 Returns the number of words recorded. More...
 
uint16_t recordedReadWord (void)
 Reads the next word from the buffer of recorded words. More...
 

Public Attributes

uint8_t mp3buffer [VS1053_DATABUFFERLEN]
 

Protected Attributes

uint8_t _dreq
 Data request pin.
 
boolean usingInterrupts = false
 True if using interrupts.
 

Detailed Description

Driver for the Adafruit VS1053

Constructor & Destructor Documentation

◆ Adafruit_VS1053() [1/2]

Adafruit_VS1053::Adafruit_VS1053 ( int8_t  mosi,
int8_t  miso,
int8_t  clk,
int8_t  rst,
int8_t  cs,
int8_t  dcs,
int8_t  dreq 
)

Software SPI constructor - must specify all pins.

Parameters
mosiMOSI (Microcontroller Out Serial In) pin
misoMISO (Microcontroller In Serial Out) pin
clkClock pin
rstReset pin
csSCI Chip Select pin
dcsSDI Chip Select pin
dreqData Request pin

◆ Adafruit_VS1053() [2/2]

Adafruit_VS1053::Adafruit_VS1053 ( int8_t  rst,
int8_t  cs,
int8_t  dcs,
int8_t  dreq 
)

Hardware SPI constructor - assumes hardware SPI pins.

Parameters
rstReset pin
csSCI Chip Select pin
dcsSDI Chip Select pin
dreqData Request pin

Member Function Documentation

◆ begin()

uint8_t Adafruit_VS1053::begin ( void  )

Initialize communication and (hard) reset the chip.

Returns
Returns true if a VS1053 is found

◆ sciRead()

uint16_t Adafruit_VS1053::sciRead ( uint8_t  addr)

Reads from the specified register on the chip.

Parameters
addrRegister address to read from
Returns
Retuns the 16-bit data corresponding to the received address

◆ sciWrite()

void Adafruit_VS1053::sciWrite ( uint8_t  addr,
uint16_t  data 
)

Writes to the specified register on the chip.

Parameters
addrRegister address to write to
dataData to write

◆ sineTest()

void Adafruit_VS1053::sineTest ( uint8_t  n,
uint16_t  ms 
)

Generate a sine-wave test signal.

Parameters
nDefines the sine test to use
msDelay (in ms)

◆ decodeTime()

uint16_t Adafruit_VS1053::decodeTime ( void  )

Reads the DECODETIME register from the chip.

Returns
Returns the decode time as an unsigned 16-bit integer

◆ setVolume()

void Adafruit_VS1053::setVolume ( uint8_t  left,
uint8_t  right 
)

Set the output volume for the chip.

Parameters
leftDesired left channel volume
rightDesired right channel volume

◆ playData()

void Adafruit_VS1053::playData ( uint8_t *  buffer,
uint8_t  buffsiz 
)

Decode and play the contents of the supplied buffer.

Parameters
bufferBuffer to decode and play
buffsizSize to decode and play

◆ readyForData()

boolean Adafruit_VS1053::readyForData ( void  )

Test if ready for more data.

Returns
Returns true if it is ready for data

◆ applyPatch()

void Adafruit_VS1053::applyPatch ( const uint16_t *  patch,
uint16_t  patchsize 
)

Apply a code patch.

Parameters
patchPatch to apply
patchsizePatch size

◆ loadPlugin()

uint16_t Adafruit_VS1053::loadPlugin ( char *  fn)

Load the specified plug-in.

Parameters
fnPlug-in to load
Returns
Either returns 0xFFFF if there is an error, or the address of the plugin that was loaded

◆ GPIO_digitalWrite() [1/2]

void Adafruit_VS1053::GPIO_digitalWrite ( uint8_t  i,
uint8_t  val 
)

Write to a GPIO pin.

Parameters
iGPIO pin to write to
valValue to write

◆ GPIO_digitalWrite() [2/2]

void Adafruit_VS1053::GPIO_digitalWrite ( uint8_t  i)

Write to all 8 GPIO pins at once.

Parameters
iValue to write

◆ GPIO_digitalRead() [1/2]

uint16_t Adafruit_VS1053::GPIO_digitalRead ( void  )

Read all 8 GPIO pins at once.

Returns
Returns a 2 byte value with the reads from the 8 pins

◆ GPIO_digitalRead() [2/2]

boolean Adafruit_VS1053::GPIO_digitalRead ( uint8_t  i)

Read a single GPIO pin.

Parameters
ipin to read
Returns
Returns the state of the specified GPIO pin

◆ GPIO_pinMode()

void Adafruit_VS1053::GPIO_pinMode ( uint8_t  i,
uint8_t  dir 
)

Set the Pin Mode (INPUT/OUTPUT) for a GPIO pin.

Parameters
iPin to set the mode for
dirMode to set

◆ prepareRecordOgg()

boolean Adafruit_VS1053::prepareRecordOgg ( char *  plugin)

Initialize chip for OGG recording.

Parameters
pluginBinary file of the plugin to use
Returns
Returns true if the device is ready to record

◆ startRecordOgg()

void Adafruit_VS1053::startRecordOgg ( boolean  mic)

Start recording.

Parameters
micmic=true for microphone input

◆ recordedWordsWaiting()

uint16_t Adafruit_VS1053::recordedWordsWaiting ( void  )

Returns the number of words recorded.

Returns
2-byte unsigned int with the number of words

◆ recordedReadWord()

uint16_t Adafruit_VS1053::recordedReadWord ( void  )

Reads the next word from the buffer of recorded words.

Returns
Returns the 16-bit data corresponding to the received address

Member Data Documentation

◆ mp3buffer

uint8_t Adafruit_VS1053::mp3buffer[VS1053_DATABUFFERLEN]

mp3 buffer that gets sent to the device


The documentation for this class was generated from the following files: