~Datasheet - IIS

Inter-IC Sound (IIS)

The S3C2440A Inter-IC Sound (IIS) bus interface can be used to implement a CODEC interface to an external stereo audio CODEC IC for mini-disc and portable applications.

The IIS bus interface supports both IIS bus data format and MSB-justified data format.

The interface provides DMA transfer mode for FIFO access instead of an interrupt. It can transmit and receive data simultaneously as well as transmit or receive data alternatively at a time. (全双工)

一般都用于dma传输音频

The IIS bus has four lines including

serial data input I2SSDI,

serial data output I2SSDO,

left/right channel select clock I2SLRCLK, //左右声道交替传输

serial bit clock I2SSCLK;

 

the device generating I2SLRCLK and I2SSCLK is the master.

 

配置代码示例:

void iis_init(void)
{
    IISCON = (1 << 5) | (1 << 1);
    IISMOD = (2 << 6) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | 1;
    IISPSR = (2 << 5) | 2;
    IISFCON = (1 << 15) | (1 << 13);
}

void iis_start(void)
{
    IISCON |= 1;
}

 

相比2416,2440在iis方面要寒酸许多。

 

 

2416模块:

DMA TRANSFER

In the DMA transfer mode, the transmitter or receiver FIFO are accessible by DMA controller. DMA service request is activated internally by the transmitter or receiver FIFO state.

The FTXEMPT, FRXEMPT, FTXFULL, and FRXFULL bits of I2SCON registerrepresent the transmitter or receiver FIFO data state.

Especially, FTXEMPT and FRXFULL bit are the ready flag for DMA service request;

the transmit DMA service request is activated when TXFIFO is not empty and the receiver DMA service request is activated when RXFIFO is not full.

The DMA transfer uses only Note that during DMA acknowledge activation, the data read or write operation should be performed.

 

* DMA request point

– TX mode : ( FIFO is not full ) & ( TXDMACTIVE is active )

– RX mode : ( FIFO is not empty ) & ( RXDMACTIVE is active )

NOTE It only supports single transfer in DMA mode.

2416有PG,给力!

 

7.1 INITIALIZATION

1.Before you use IIS bus interface, you have to configure GPIOs to IIS mode. And check signal’s direction.

I2SLRCLK, I2SSCLK and I2SCDCLK is in out-type. The each of I2SSDI and I2SSDO is input and output.

2.Now then, you choose clock source. S3C2416 has four clock sources. Those are PCLK, divided EPLL clock EPLLRefCLK and external codec. If you want to know more detail, refer Figure 23-2.

7.2 PLAY MODE (TX MODE) WITH DMA

1.TXFIFO is flushed before operation. If you don’t distinguish Master/Slave mode from TX/RX mode, you must study Master/Slave mode and TX/RX mode. Refer Master/Slave chapter.

2.To configure I2SMOD register and I2SPSR (IIS pre-scaler register) properly.

3.To operate system in stability,. First of all, DMA starts because of that reason.

4.Basically, . So, you can only check state by polling through accessing SFR.

5.If TXFIFO is full, now then you make I2SACTIVE be asserted.

 

 

 

 

====Mp3设计====

 

dma0:  arm --> iis --> 声卡

由于iis没有表示传输结束INT,所以使用dma 的INT:先传一部分,中断,触发第二次传输。

void fix(void)
{
    unsigned long *p = 0x31000000; 
    *p = (unsigned long)do_irq; // 中断函数,触发下一部分传输
}

void do_irq(void) //DMA发送完一批后自动发送中断(DMA配置)
{
    copy_music(dma_src, music_src); // 将要传输的下一部分音乐拷贝到DMA src
    SRCPND = INTPND; // 要清空中断
    INTPND = INTPND;
}

void copy_music(char *dma, char *music) // 441000*2*2转移频率
{
    static int count; 
    count = 1;
    memcpy(dma, (music + count * music_size), music_size);

    count++;
}

void _start(void)
{
    fix();

    INTMSK &= ~(1 << 17); //DMA中断enable
    __asm__ __volatile__(
      "mrs r0, cpsr\n" 
      "bic r0, r0, #0x80\n"
      "msr cpsr, r0\n"
      :::"r0"
  );


  /* 初始化声卡: gpio设置,声卡初始化 */

  iis_init();
  dma_init(dma_src, music_size); 
              //music_size 限制了一次搬运产生中断的大小

  memcpy(dma_src, music_src, music_size); //第一次要自己搬运

  //开始播放音乐
  iis_start();
  dma_start();

  printf("play now ...\n");
}

 

接下来的关键是:

DMA中断后如何触发中断函数,也就是do_irq。

在此没有使用MMU,没有内核,采用绝对物理地址,所以自定义中断向量表:

reset:
  b reset
undef:
  b undef
swi:
  b swi
pdata:
  b pdata
abort:
  b abort
.word 0x0

@irq: //这里是arm的保留位
  b irq
fiq:
  b fiq

跳到irq处理函数:

irq:
    mov sp, #0x31000000 //#首先设置栈的位置

    sub lr, lr, #4
    stmfd sp!, {r0-r14} 

    mov r0, #0x31000000 //还原中断前状态
    ldr r1, [r0] //取出do_irq函数的地址
    mov lr, pc
    mov pc, r1 //跳到中断处理函数

    ldmfd sp, {r0-r13, r15}^

 

内存中的音乐文件被分批发送到声卡播放。加上编解码,音乐文件管理,就成了古老的mp3程序,呵呵……

 

 

http://hi.baidu.com/kebey2004/item/c0f6f5c827340108c710b2a0

http://hi.baidu.com/kebey2004/item/2af70b57fecb99a8acc857a5

posted @ 2012-11-20 13:30  郝壹贰叁  阅读(390)  评论(0编辑  收藏  举报