實驗目的:
1.瞭解觸IIS基本概念與原理。
2.瞭解觸DMA基本概念與原理。。
3.編程實現對IIS的控制。
本次實驗編寫對IIS進行控制的程式,我們可以進行錄音,放音。
#include <stdlib.h>
#include <string.h>
//Shin, On Pil
#include "def.h"
#include "option.h"
#include "2410addr.h"
#include "2410lib.h"
#include "2410slib.h"
#include "2410iis.h"
#include "mmu.h"
void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);
void * function[][2]=
{
//IIS
(void *)Record_Iis, "Reco IIS UDA1341 ",
(void *)Test_Iis, "Play IIS UDA1341 ",
0,0
};
//===================================================================
void Main(void)
{
int i;
Led_Display(15);
MMU_Init();
#if ADS10
__rt_lib_init(); //for ADS 1.0
#endif
// ChangeClockDivider(0,0); // 1:1:1
// ChangeClockDivider(1,0); // 1:2:2
ChangeClockDivider(1,1); // 1:2:4
// ChangeMPllValue(0x92,0x4,0x2); // FCLK=50MHz
// ChangeMPllValue(0x96,0x5,0x1); // FCLK=135428571Hz
// ChangeMPllValue(0x2a,0x1,0x0); // FCLK=200MHz
// ChangeMPllValue(0x5c,0x1,0x1); // FCLK=200MHz
// ChangeMPllValue(0x5c,0x4,0x0); // FCLK=200MHz
// ChangeMPllValue(0x8e,0x7,0x0); // FCLK=200MHz
ChangeMPllValue(0xa1,0x3,0x1); // FCLK=202.8MHz
// ChangeMPllValue(0x66,0x1,0x1); // FCLK=220MHz
// ChangeMPllValue(0x69,0x1,0x1); // FCLK=226MHz
// ChangeMPllValue(0x96,0x2,0x1); // FCLK=237MHz
Port_Init();
Isr_Init();
// Rtc_Init();
Uart_Init(0,115200);
Uart_Select(0);
//Check whether or not the POWER_OFF wake-up.
Delay(0); //calibrate Delay()
rIISPSR=(2<<5)|(2<<0); //IIS_LRCK=44.1Khz @384fs,PCLK=50Mhz.
rGPHCON = rGPHCON & ~(0xf<<18)|(0x5<<18); //CLKOUT 0,1=OUTPUT to reduce the power consumption.
while(1)
{
i = 0;
Uart_Printf("\n\nSMDK2410 Board (MCU S3C2410) Test Program Ver 1.1(20020801) FCLK = %d Hz\n\n", FCLK);
while(1)
{ //display menu
Uart_Printf("%2d:%s",i,function[i][1]);
i++;
if((int)(function[i][0])==0)
{
Uart_Printf("\n");
break;
}
if((i%4)==0)
Uart_Printf("\n");
}
Uart_Printf("\nSelect the function to test : ");
i = Uart_GetIntNum();
Uart_Printf("\n");
//GPG4 Output Port [9:8] 01 -> LCD power On
rGPGCON = (rGPGCON & 0xfffffcff) | (1<<8);
rGPGDAT = (rGPGDAT & 0xffef) | (1<<4);
if(i>=0 && (i<(sizeof(function)/8)) )
( (void (*)(void)) (function[i][0]) )();
}
}
//===================================================================
void Isr_Init(void)
{
pISR_UNDEF = (unsigned)HaltUndef;
pISR_SWI = (unsigned)HaltSwi;
pISR_PABORT = (unsigned)HaltPabort;
pISR_DABORT = (unsigned)HaltDabort;
rINTMOD = 0x0; //All=IRQ mode
// rINTCON=0x5; //Non-vectored,IRQ enable,FIQ disable
rINTMSK = BIT_ALLMSK; //All interrupt is masked.
rINTSUBMSK = BIT_SUB_ALLMSK; //All sub-interrupt is masked. <- April 01, 2002 SOP
// rINTSUBMSK = ~(BIT_SUB_RXD0); //Enable Rx0 Default value=0x7ff
// rINTMSK = ~(BIT_UART0); //Enable UART0 Default value=0xffffffff
// pISR_UART0=(unsigned)RxInt; //pISR_FIQ,pISR_IRQ must be initialized
}
//===================================================================
void HaltUndef(void)
{
Uart_Printf("Undefined instruction exception.\n");
while(1);
}
//===================================================================
void HaltSwi(void)
{
Uart_Printf("SWI exception.\n");
while(1);
}
//===================================================================
void HaltPabort(void)
{
Uart_Printf("Pabort exception.\n");
while(1);
}
//===================================================================
void HaltDabort(void)
{
Uart_Printf("Dabort exception.\n");
while(1);
}
/*
//=========================
while(1)
{
Led_Display(3);
}
//=========================
*/
/*
//=========================
while(1)
{
Led_Display(1);
Delay(1500);
Led_Display(2);
Delay(1500);
Led_Display(4);
Delay(1500);
Led_Display(8);
Delay(1500);
}
//=========================