📄 44btest.c
字号:
#include <string.h>
#include "..\inc\option.h"
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\def.h"
#include "..\inc\cache.h"
#include "..\inc\uart.h"
#include "..\inc\dma.h"
#include "..\inc\timer.h"
#include "..\inc\rtc.h"
#include "..\inc\etc.h"
#include "..\inc\iic.h"
#include "..\inc\stop.h"
#include "..\inc\extdma.h"
#include "..\inc\tp.h"
#include "..\inc\usb.h"
#include "..\inc\kb.h"
#include "..\inc\Pwm.h"
#include "..\inc\led.h"
#define rADCCON (*(volatile unsigned *)0x1d40000)
#define rADCPSR (*(volatile unsigned *)0x1d40004)
#define rADCDAT (*(volatile unsigned *)0x1d40008)
/* ADC 的各种指示符 */
#define ADCCON_FLAG 0x40 //转换标志
#define ADCCON_SLEEP 0x20 //休眠标志
#define ADCCON_ADIN0 (0x0<<2)//输入信道
#define ADCCON_ADIN1 (0x1<<2)
#define ADCCON_ADIN2 (0x2<<2)
#define ADCCON_ADIN3 (0x3<<2)
#define ADCCON_ADIN4 (0x4<<2)
#define ADCCON_ADIN5 (0x5<<2)
#define ADCCON_ADIN6 (0x6<<2)
#define ADCCON_ADIN7 (0x7<<2)
#define ADCCON_READ_START 0x2//读使转化标志
#define ADCCON_ENABLE_START 0x1
void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);
//****************************************************************
// * S3C44B0X developer's notes *
// ****************************************************************
void Main(void)
{
int i,aa;
rSYSCFG=SYSCFG_8KB;
#if (PLLON==1)
ChangePllValue(PLL_M,PLL_P,PLL_S);
#endif
Isr_Init();
Port_Init();
Uart_Init(0,115200);
// LcdInit(); //to avoid LCD damage.
Uart_Select(0);
Delay(0); //calibrate Delay()
i=1;
Uart_Printf("\n\n\n 欢迎使用SW3C44B0 实验程序V1.0\n\n");
Uart_Printf("\nS3C44B0X Test Program Ver 0.00 rSYSCFG=0x%x MCLK=%d\n\n",rSYSCFG,MCLK);
Uart_Printf("\n");
Uart_Printf("Input 1--3 ,Press e to exit. ");
while(i==1)
{
aa= Uart_Getch();
switch(aa)
{case '1':flash_Led();
Uart_Printf("\nInput 1--3 ,Press e to exit. ");
break;
case '2':LR_Led();
Uart_Printf("\nInput 1--3 ,Press e to exit. ");
break;
case '3':Test_Led();
Uart_Printf("\nInput 1--3 ,Press e to exit. ");
break;
case 'e':i--;break;
case 'E':i--;break;
}
}
}
void Isr_Init(void)
{
U32 i;
pISR_UNDEF=(unsigned)HaltUndef;
pISR_SWI =(unsigned)HaltSwi;
pISR_PABORT=(unsigned)HaltPabort;
pISR_DABORT=(unsigned)HaltDabort;
for(i=_RAM_STARTADDRESS;i<(_RAM_STARTADDRESS+0x20);i+=4)
{
*((volatile unsigned *)i)=0xEA000000+0x1FFE;
}
//rINTCON=0x1; // Vectored Int. IRQ enable,FIQ disable
rINTCON=0x5; // Non-vectored,IRQ enable,FIQ disable
rINTMOD=0x0; // All=IRQ mode
rINTMSK|=BIT_GLOBAL|BIT_EINT3; // All interrupt is masked.
}
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);
}
void init_ADdevice()
{
rADCPSR=20; //采样率为32
rADCCON=ADCCON_SLEEP;//进入休眠模式
}
int GetADresult(int channel) //channel 为通道数
{
rADCPSR=20;
rADCCON=(channel<<2)|ADCCON_ENABLE_START; //启动某路转换
while(!(rADCCON&ADCCON_FLAG)); //直到转换完毕
return rADCDAT; //返回转换结果
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -