SDK4.0
This document shows Ameba SDK 4.0 APIs
Enumerator

i2s functions More...

Ameba Common

enum  {
  SR_8KHZ = I2S_SR_8KHZ, SR_16KHZ = I2S_SR_16KHZ, SR_24KHZ = I2S_SR_24KHZ, SR_32KHZ = I2S_SR_32KHZ,
  SR_48KHZ = I2S_SR_48KHZ, SR_96KHZ = I2S_SR_96KHZ, SR_7p35KHZ = I2S_SR_7p35KHZ, SR_14p7KHZ = I2S_SR_14p7KHZ,
  SR_22p05KHZ = I2S_SR_22p05KHZ, SR_29p4KHZ = I2S_SR_29p4KHZ, SR_44p1KHZ = I2S_SR_44p1KHZ, SR_88p2KHZ = I2S_SR_88p2KHZ
}
 
enum  { CH_STEREO = I2S_CH_STEREO, CH_MONO = I2S_CH_MONO }
 
enum  { WL_16b = I2S_WL_16, WL_24b = I2S_WL_24 }
 
enum  { I2S_DIR_RX = I2S_ONLY_RX, I2S_DIR_TX = I2S_ONLY_TX, I2S_DIR_TXRX = I2S_TXRX }
 
typedef void(* i2s_irq_handler) (uint32_t id, char *pbuf)
 
typedef struct i2s_s i2s_t
 
void i2s_deinit (i2s_t *obj)
 Deinitializes the I2S device, include function/interrupt/I2S registers. More...
 
void i2s_set_dma_buffer (i2s_t *obj, char *tx_buf, char *rx_buf, uint32_t page_num, uint32_t page_size)
 Sets page number, page size, page address. More...
 
void i2s_tx_irq_handler (i2s_t *obj, i2s_irq_handler handler, uint32_t id)
 Sets TX interrupt handler. More...
 
void i2s_rx_irq_handler (i2s_t *obj, i2s_irq_handler handler, uint32_t id)
 Sets RX interrupt handler. More...
 
void i2s_set_direction (i2s_t *obj, int trx_type)
 Sets i2s data transfer direction. More...
 
void i2s_set_param (i2s_t *obj, int channel_num, int rate, int word_len)
 Sets i2s channel number, sample rate, word length. More...
 
int * i2s_get_tx_page (i2s_t *obj)
 Gets current tx page address. More...
 
void i2s_send_page (i2s_t *obj, uint32_t *pbuf)
 Sets current tx page own by i2s. More...
 
void i2s_recv_page (i2s_t *obj)
 Sets current rx page own by i2s. More...
 
void i2s_enable (i2s_t *obj)
 Enable i2s interrupt and function. More...
 
void i2s_disable (i2s_t *obj)
 Disable i2s interrupt and function. More...
 

Ameba1 Only

void i2s_init (i2s_t *obj, PinName sck, PinName ws, PinName sd)
 Initializes the I2S device, include clock/function/interrupt/I2S registers. More...
 

AmebaZ Only

void i2s_init (i2s_t *obj, PinName sck, PinName ws, PinName sd_tx, PinName sd_rx, PinName mck)
 Initializes the I2S device, include clock/function/interrupt/I2S registers. More...
 

Detailed Description

i2s functions

Function Documentation

void i2s_deinit ( i2s_t *  obj)

Deinitializes the I2S device, include function/interrupt/I2S registers.

Parameters
obji2s object define in application software.
Return values
none
void i2s_disable ( i2s_t *  obj)

Disable i2s interrupt and function.

Parameters
obji2s object define in application software.
Return values
none
void i2s_enable ( i2s_t *  obj)

Enable i2s interrupt and function.

Parameters
obji2s object define in application software.
Return values
none
int* i2s_get_tx_page ( i2s_t *  obj)

Gets current tx page address.

Parameters
obji2s object define in application software.
Return values
address of current tx page or NULL
Note
current page own by cpu, return address of current tx page
current page own by i2s, return NULL
void i2s_init ( i2s_t *  obj,
PinName  sck,
PinName  ws,
PinName  sd 
)

Initializes the I2S device, include clock/function/interrupt/I2S registers.

Parameters
obji2s object define in application software.
sckSerial clock PinName according to pinmux spec.
wsWord select PinName according to pinmux spec.
sdPinName according to pinmux spec.
Return values
none
void i2s_init ( i2s_t *  obj,
PinName  sck,
PinName  ws,
PinName  sd_tx,
PinName  sd_rx,
PinName  mck 
)

Initializes the I2S device, include clock/function/interrupt/I2S registers.

Parameters
obji2s object define in application software.
sckSerial clock PinName according to pinmux spec.
wsWord select PinName according to pinmux spec.
sd_txTx PinName according to pinmux spec.
sd_rxRx PinName according to pinmux spec.
mckMaster clock PinName according to pinmux spec.
Return values
none
void i2s_recv_page ( i2s_t *  obj)

Sets current rx page own by i2s.

Parameters
obji2s object define in application software.
Return values
none
void i2s_rx_irq_handler ( i2s_t *  obj,
i2s_irq_handler  handler,
uint32_t  id 
)

Sets RX interrupt handler.

Parameters
obji2s object define in application software.
handlerRX interrupt callback function.
idRX interrupt callback function parameter.
Return values
none
void i2s_send_page ( i2s_t *  obj,
uint32_t *  pbuf 
)

Sets current tx page own by i2s.

Parameters
obji2s object define in application software.
pbuftx buffer adderss.
Return values
none
void i2s_set_direction ( i2s_t *  obj,
int  trx_type 
)

Sets i2s data transfer direction.

Parameters
obji2s object define in application software.
trx_typetransfer direction. This parameter can be one of the following values:
  • I2S_DIR_RX: Rx receive direction
  • I2S_DIR_TX: Tx transmission direction
  • I2S_DIR_TXRX: Tx & Rx bi-direction
Return values
none
void i2s_set_dma_buffer ( i2s_t *  obj,
char *  tx_buf,
char *  rx_buf,
uint32_t  page_num,
uint32_t  page_size 
)

Sets page number, page size, page address.

Parameters
obji2s object define in application software.
tx_bufpointer to the start address of Tx page.
rx_bufpointer to the start address of Rx page.
page_numpage number. This parameter must be set to a value in the 2~4 range
page_sizepage size. This parameter must be set to a value in the 4~16384 bytes range
Return values
none
void i2s_set_param ( i2s_t *  obj,
int  channel_num,
int  rate,
int  word_len 
)

Sets i2s channel number, sample rate, word length.

Parameters
obji2s object define in application software.
channel_numthis parameter can be one of the following values:
  • CH_STEREO: stereo channel
  • CH_MONO: mono channel
ratethis parameter can be one of the following values:
  • SR_8KHZ: sample rate is 8kHz
  • SR_16KHZ: sample rate is 16kHz
  • SR_24KHZ: sample rate is 24kHz
  • SR_32KHZ: sample rate is 32kHz
  • SR_48KHZ: sample rate is 48kHz
  • SR_96KHZ: sample rate is 96kHz
  • SR_7p35KHZ: sample rate is 7.35kHz
  • SR_14p7KHZ: sample rate is 14.7kHz
  • SR_22p05KHZ: sample rate is 22.05kHz
  • SR_29p4KHZ: sample rate is 29.4kHz
  • SR_44p1KHZ: sample rate is 44.1kHz
  • SR_88p2KHZ: sample rate is 88.2kHz
word_lenthis parameter can be one of the following values:
  • WL_16b: sample bit is 16 bit
  • WL_24b: sample bit is 24 bit
Return values
none
void i2s_tx_irq_handler ( i2s_t *  obj,
i2s_irq_handler  handler,
uint32_t  id 
)

Sets TX interrupt handler.

Parameters
obji2s object define in application software.
handlerTX interrupt callback function.
idTX interrupt callback function parameter.
Return values
none