?? power_test.c
字號:
/**************************************************************************************
*
* Project Name : S3C6400 Validation
*
* Copyright 2006 by Samsung Electronics, Inc.
* All rights reserved.
*
* Project Description :
* This software is only for validating functions of the S3C6400.
* Anybody can use this software without our permission.
*
*--------------------------------------------------------------------------------------
*
* File Name : power_test.c
*
* File Description : This file implements the test functons for the Power Mode
*
* Author : Wonjoon Jang
* Dept. : AP Development Team
* Created Date : 2007/01/10
* Version : 0.1
*
* History
* - Created(Wonjoon.jang 2007/01/10)
*
**************************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "option.h"
#include "library.h"
#include "sfr6400.h"
#include "system.h"
#include "gpio.h"
#include "intc.h"
#include "dmc.h"
#include "rtc.h"
//#include "adcts.h"
//#include "lcd.h"
#include "sysc.h"
#include "power_test.h"
#include "timer.h"
#include "keypad.h"
#include "adcts.h"
#include "dma.h"
//#include "hsi.h"
#include "uart.h"
#define DBG_PRINT FALSE
u32 g_OnTest ;//= 1;
u32 g_OnTest_DSTOP; //=1;//=1;
u32 g_OnTest_ESLP;//=1;
u32 g_TestCount, g_AlmInt;
u32 g_Inform0;
extern u32 g_DmaDone;
extern u32 g_uIntCounter0 ;
extern u32 g_uIntCounter1 ;
extern u32 g_uIntCounter2 ;
extern u32 g_uIntCounter3 ;
static DMAC oDmac0_T;
extern u32 g_iSeed;
extern void Insert_Seed(void);
//////////
// Function Name : InitData_SDRAM
// Function Description : This function initializes data in the DRAM
//
// Input : check_start - start address, check_size- data size
// Output :
//
// Version : v0.1
void InitData_SDRAM(int check_start, int check_size)
{
int i;
#if DBG_PRINT
printf("[SDRAM Initialization]\n");
printf("Fill SDRAM for self-refresh test.\n");
#endif
for(i=check_start;i<(check_start+check_size);i+=4)
*((unsigned int *)i)=i^0x55555555;
//*((unsigned int *)i)=0x55555555;
#if DBG_PRINT
printf("Filling SDRAM is completed.\n");
#endif
}
//////////
// Function Name : CheckData_SDRAM
// Function Description : This function check data in the DRAM
//
// Input : check_start - start address, check_size- data size
// Output :
//
// Version : v0.1
void CheckData_SDRAM(int check_start, int check_size)
{
int i;
int error=0;
#if DBG_PRINT
printf("Check SDRAM for self-refresh test\n");
#endif
for(i=check_start;i<(check_start+check_size);i+=4)
{
if(*((unsigned int *)i)!=(i^0x55555555))
// if(*((unsigned int *)i)!=(0x55555555))
{
printf("Mem Error:%x=%x(%x)\n",i,*((unsigned int *)i),i^0x55555555);
error++;
}
if(error>20)
break;
}
if(error)
{
printf("SDRAM self-refresh test:FAILED\n");
}
else
{
#if DBG_PRINT
printf("SDRAM self-refresh test:O.K.\n");
#endif
}
}
//////////
// Function Name : Check_AliveSFR
// Function Description :
//
// Input : uWorR = 0: Write Alive SFR
// uWorR = 1: Read Alive SFR
// Output :
//
// Version : v0.1
void Check_AliveSFR(u32 uWorR)
{
if(uWorR == 0)
{
Outp32SYSC(0x804, 0x80); //PWR_CFG -> 康氫絕瀾.
Outp32SYSC(0x808, 0x10000); //EINT_MASK
//Outp32SYSC(0x810,0xFFFFFD00); //NORMAL_CFG
Outp32SYSC(0x814,0x20120000); //STOP_CFG
Outp32SYSC(0x818,0x1); //SLEEP_CFG
Outp32SYSC(0x820, 0x2); //OSC_FREQ
Outp32SYSC(0x824, 0x2); //OSC_STABLE
Outp32SYSC(0x828, 0x2); //PWR_STABLE
Outp32SYSC(0x82C, 0x2); //FPC_STABLE
Outp32SYSC(0x830, 0xF7777777); //MTC_STABLE
//Outp32Inform(0, 0x1); // Information Register
Outp32Inform(1, 0x2); // Information Register
Outp32Inform(2, 0x3); // Information Register
Outp32Inform(3, 0x4);
Outp32Inform(4, 0x5);
Outp32Inform(5, 0x6);
Outp32Inform(6, 0x7);
//Outp32Inform(7, 0x8);
}
else
{
printf(" rPWR_CFG = 0x%x \n", Inp32SYSC(0x804)); //PWR_CFG
printf(" rEINT_MASK = 0x%x \n", Inp32SYSC(0x808));
printf(" rNORMAL_CFG = 0x%x \n", Inp32SYSC(0x810));
printf(" rSTOP_CFG = 0x%x \n", Inp32SYSC(0x814));
printf(" rSLEEP_CFG = 0x%x \n", Inp32SYSC(0x818));
printf(" rOSC_FREQ = 0x%x \n", Inp32SYSC(0x820));
printf(" rOSC_STABLE = 0x%x \n", Inp32SYSC(0x824));
printf(" rPWR_STABLE = 0x%x \n", Inp32SYSC(0x828));
printf(" rFPC_STABLE = 0x%x \n", Inp32SYSC(0x82C));
printf(" rMTC_STABLE = 0x%x \n", Inp32SYSC(0x830));
printf(" rInform0 = 0x%x \n", Inp32SYSC(0xA00));
printf(" rInform1 = 0x%x \n", Inp32SYSC(0xA04));
printf(" rInform2 = 0x%x \n", Inp32SYSC(0xA08));
printf(" rInform3 = 0x%x \n", Inp32SYSC(0xA0c));
printf(" rInform4 = 0x%x \n", Inp32SYSC(0xA10));
printf(" rInform5 = 0x%x \n", Inp32SYSC(0xA14));
printf(" rInform6 = 0x%x \n", Inp32SYSC(0xA18));
printf(" rInform7 = 0x%x \n", Inp32SYSC(0xA1c));
}
}
//////////
// Function Name : Isr_TIMER0
// Function Description : This function is Interrupt Service Routine of PWM Timer0
// Input : NONE
// Output : NONE (increment of g_uIntCounter0 value)
// Version : v0.1
void __irq Isr_TIMER0_Idle(void)
{
u32 uTmp;
uTmp = Inp32(0x7F006044);
uTmp = (uTmp & 0x1f)| (1<<5);
Outp32(0x7F006044,uTmp); // Timer0 Interrupt Clear register
// printf(".");
//printf("Timer0\n");
g_uIntCounter0++;
INTC_ClearVectAddr();
}
//////////
// Function Name : Isr_TIMER1
// Function Description : This function is Interrupt Service Routine of PWM Timer0
// Input : NONE
// Output : NONE (increment of g_uIntCounter0 value)
// Version : v0.1
void __irq Isr_TIMER1_Idle(void)
{
u32 uTmp;
uTmp = Inp32(0x7F006044);
uTmp = (uTmp & 0x1f) | (1<<6);
Outp32(0x7F006044,uTmp); // Timer1 Interrupt Clear register
// printf("+");
//printf("Timer1\n");
g_uIntCounter1++;
INTC_ClearVectAddr();
}
//////////
// Function Name : Isr_TIMER2
// Function Description : This function is Interrupt Service Routine of PWM Timer0
// Input : NONE
// Output : NONE (increment of g_uIntCounter0 value)
// Version : v0.1
void __irq Isr_TIMER2_Idle(void)
{
u32 uTmp;
uTmp = Inp32(0x7F006044);
uTmp = (uTmp & 0x1f) |(1<<7);
Outp32(0x7F006044,uTmp); // Timer2 Interrupt Clear register
// printf("-");
//printf("Timer2\n");
g_uIntCounter2++;
INTC_ClearVectAddr();
}
//////////
// Function Name : Isr_TIMER3
// Function Description : This function is Interrupt Service Routine of PWM Timer0
// Input : NONE
// Output : NONE (increment of g_uIntCounter0 value)
// Version : v0.1
void __irq Isr_TIMER3_Idle(void)
{
u32 uTmp;
uTmp = Inp32(0x7F006044);
uTmp = (uTmp & 0x1f) | (1<<8);
Outp32(0x7F006044,uTmp); // Timer3 Interrupt Clear register
// printf("&");
//printf("Timer3\n");
g_uIntCounter3++;
INTC_ClearVectAddr();
}
void __irq Dma0Done_T(void)
{
DMACH_ClearIntPending(&oDmac0_T);
//rDMAC0IntTCClear = 0xff;
printf ("DMA ISR %d\n", g_DmaDone);
g_DmaDone=1;
g_DmaDone++;
INTC_ClearVectAddr();
//Write_VECTADDR(0x0);
}
void __irq Isr_RTC_AlmWu(void)
{
RTC_ClearIntP(1);
//uCntAlarm=1;
#if DBG_PRINT
printf(" [Wu]RTC alarm test OK\n");
#endif
INTC_ClearVectAddr();
}
//////////
// Function Name : SetAlarmWakeup
// Function Description : Setting RTC Alarm Int. - after 10sec.
// Input : None
// Output : None
// Version : v0.1
void SetAlarmWakeup (void)
{
RTC_ClearIntP(1);
INTC_SetVectAddr(NUM_RTC_ALARM,Isr_RTC_AlmWu);
RTC_SetCON(0,0,0,0,0,1);
RTC_SetTime(InitYEAR,InitMONTH,InitDATE,InitDAY,InitHOUR,InitMIN,InitSEC);
RTC_SetAlmTime(AlmYear,AlmMon,AlmDate,AlmHour,AlmMin,AlmSec+3);
RTC_SetAlmEn(1,0,0,0,0,0,1);
RTC_SetCON(0,0,0,0,0,0);
#if DBG_PRINT
printf(" RTC Alarm is set for wake-up source\n");
#endif
INTC_Enable(NUM_RTC_ALARM);
}
void __irq Isr_RTC_Tick_Wu(void)
{
//GPIO_SetFunctionEach(eGPIO_F, eGPIO_14,3); //GPF14[] = 3 : CLKOUT[0]
RTC_ClearIntP(0);
printf("[WU] RTC Tick interrupt is occurred .\n");
INTC_ClearVectAddr();
}
//////////
// Function Name : SetAlarmTick
// Function Description : Setting RTC Alarm Int. - after 10sec.
// Input : None
// Output : None
// Version : v0.1
void SetAlarmTick (void)
{
INTC_SetVectAddr(NUM_RTC_TIC, Isr_RTC_Tick_Wu);
// RTC Init.
RTC_SetCON(0,0,0,0,0,1);
RTC_SetTime(InitYEAR,InitMONTH,InitDATE,InitDAY,InitHOUR,InitMIN,InitSEC);
#if 0 // 5sec, Tick Clock =128Hz
//RTC_SetTickCNT(640);
//RTC_SetCON(0,8,0,0,0,0); // Tick Clock = 128Hz?
// 1/128*1280 = 10Sec?
#endif
RTC_SetTickCNT(65500);
RTC_SetCON(0,0,0,0,0,0);
RTC_ClearIntP(0); // Clear Int. Pending
#if 0
//RTC_SetCON(1,8,0,0,0,1);
#endif
RTC_SetCON(1,0,0,0,0,1);
printf(" RTC Tick is set for wake-up source\n");
INTC_Enable(NUM_RTC_TIC);
}
//////////
// Function Name : SetEintWakeup
// Function Description : Setting EINT9,10,11 Int. - Falling Edge
// Input : None
// Output : None
// Version : v0.1
void SetEintWakeup (void)
{
GPIO_Init();
INTC_SetVectAddr(NUM_EINT1, Isr_WUEint9);
GPIO_SetPullUpDownEach(eGPIO_N, eGPIO_9, 0x0); // Pull Down Disable
GPIO_SetPullUpDownEach(eGPIO_N, eGPIO_11, 0x0); // Pull Down Disable
GPIO_SetPullUpDownEach(eGPIO_N, eGPIO_10, 0x0); // Pull Down Disable
Delay(100);
//GPIO_SetEint0(9, Low_Level, eDLYFLT, 0);
GPIO_SetEint0(9, Falling_Edge, eDLYFLT, 0); // EVT1 OK
GPIO_EINT0ClrPend(9);
GPIO_EINT0ClrPend(10);
GPIO_EINT0ClrPend(11);
GPIO_EINT0DisMask(9);
#if DBG_PRINT
printf(" EINT9 is set for wake-up source\n");
#endif
INTC_Enable(NUM_EINT1);
}
void __irq Isr_ADCTS_Wu(void)
{
printf("[WU] Touch interrupt is occurred .\n");
ADCTS_SetADCClearWKInt();
INTC_ClearVectAddr();
}
//////////
// Function Name : SetADCTSWakeup
// Function Description :
// Input : None
// Output : None
// Version : v0.1
void SetADCTSWakeup (void)
{
u32 uTemp;
ADCTS_Init();
ADC_InitADCCON();
Outp32(0x7E00B000, (Inp32(0x7E00B000)|(1<<2)));
ADCTS_SetDelay(20);
uTemp = Inp32(0x7E00B008)|(1<<16); // RTC Clock
Outp32(0x7E00B008, uTemp);
printf(" Touch Screen is set for wake-up source\n");
Outp32(0x7E00B004, 0x90);
ADCTS_SetMeasureMode(eADCTS_MEASURE_FOR_STYLUS);
Outp32(0x7E00B004, 0xd3);
#if 0
printf(" rADCCON: 0x%x\n", Inp32(0x7E00B000));
printf(" rADCTS: 0x%x\n", Inp32(0x7E00B004));
printf(" rADCDLY: 0x%x\n", Inp32(0x7E00B008));
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -