📄 6410_otgmon.c
字号:
//////////
// Function Name : Select_OpMode
// Function Description : This function selects an operation mode of USB OTG of CPU or DMA mode.
// Input : NONE
// Output : NONE
// Version :
void Select_OpMode(void)
{
int iSel;
Disp(" Current Op Mode : ");
if(eOpMode == USB_CPU)
{
Disp("CPU mode\n");
}
else if(eOpMode== USB_DMA)
{
Disp("DMA mode\n");
}
Disp(" Enter the op. mode (0: CPU_MODE, 1: DMA_MODE) : ");
iSel = GetIntNum();
if (iSel != -1)
{
if (iSel == 0)
eOpMode = USB_CPU;
else if (iSel == 1)
eOpMode = USB_DMA;
else
Disp("Invalid selection\n");
}
}
//////////
// Function Name : Program_AM29F800
// Function Description : This function implements AMD Nor Flash Write function.
// Input : NONE
// Output : NONE
// Version :
void Program_AM29F800(void)
{
Disp("Caution : You must put BINARY file into 0x%08x before programming\n",(_DRAM_BaseAddress+0x01000000));
//rb1004...SROMC CS0 memory bus width setting: 16bit
*(u32 *)0x7e00f120 |= (1<<12);
Disp("\n[Check AM29LVxxx]\n");
switch(AM29F800_CheckId())
{
case 1 :
printf("This device is AM29LV200B!\n");
break;
case 2 :
printf("This device is AM29LV400B!\n");
break;
case 3 :
printf("This device is AM29LV800B!\n");
break;
case 4 :
printf("This device is AM29LV160B!\n");
break;
case 5 :
printf("This device is AM29LV320B!\n");
break;
default:
printf("ID Check Error!!!\n");
return;
}
ProgramAM29F800();
Disp("\nProgram AMD NOR Flash Ends.\n");
}
//////////
// Function Name : Program_NAND
// Function Description : This function implements AMD Nor Flash Write function.
// Input : NONE
// Output : NONE
// Version :
#if (USE_SCATTER_LOAD==0)
extern u32 g_NandContNum;
extern NAND_oInform NAND_Inform[NAND_CONNUM];
extern void NANDT_ProgramBinary(void);
void Program_NAND(void)
{
g_NandContNum = 0;
NAND_Inform[g_NandContNum].uNandType = NAND_Normal8bit;
NAND_Inform[g_NandContNum].uAddrCycle = 4;
NAND_Inform[g_NandContNum].uBlockNum = 4096;
NAND_Inform[g_NandContNum].uPageNum = 32;
NAND_Inform[g_NandContNum].uPageSize = NAND_PAGE_512;
NAND_Inform[g_NandContNum].uSpareSize = NAND_SPARE_16;
NAND_Inform[g_NandContNum].uECCtest = 0;
NAND_Inform[g_NandContNum].uSpareECCtest = 0;
NAND_Inform[g_NandContNum].uAllBitEccCheck = 0;
NAND_Inform[g_NandContNum].uPerformanceCheck = 0;
NAND_Inform[g_NandContNum].uTacls = 0;
NAND_Inform[g_NandContNum].uTwrph0 = 35+10; //Pad delay : about 10ns
NAND_Inform[g_NandContNum].uTwrph1 = 15;
NAND_Init(g_NandContNum);
NANDT_ProgramBinary();
}
#endif
//////////
// Function Name : Suspend_Resume
// Function Description : This function enables or disables Suspend & Resume option.
// Input : NONE
// Output : NONE
// Version :
void Suspend_Resume(void)
{
s32 sSel;
Disp("Suspend & Resume On/Off\n");
Disp(" 0 : off 1 : on\n");
sSel = GetIntNum();
if(sSel==0)
{
g_bSuspendResume = false;
}
else if(sSel==1)
{
g_bSuspendResume = true;
}
else
{
Disp("You entered wrong number\n");
}
return;
}
//////////
// Function Name : Check_SuspendCurrent
// Function Description :
// Input : NONE
// Output : NONE
// Version :
void Check_SuspendCurrent(void)
{
u8 ucKey=0;
USB_SPEED eUsbSpeed;
u32 i=0;
Disp("OTG PHY will enter suspend mode(48MHz clock is available).\n");
Disp("After entering suspend mode, OTG will not work\n");
////
OTGDEV_SetSoftDisconnect();
Outp32(0x7c100004, Inp32(0x7c100004)|(0x1<<4));
Outp32(0x7c100000, 0x17); //enable force_suspend
////
Disp("\nMeasure current through Vdd_otgi & Vdd_otg\n");
Disp("If you want to power down analog block of OTG PHT, press 'x' key\n");
while(ucKey!='x')
{
ucKey = UART_GetKey();
}
ucKey = 0;
////
Outp32(0x7c100000, 0x1f); //analog block power down
Outp32SYSC(0x900,Inp32SYSC(0x900)&~(1<<16)); //mask usb signal
Outp32SYSC(0x804,Inp32SYSC(0x804)|(1<<17)); //disable OTG clock pad
////
Disp("\nMeasure current through Vdd_otgi & Vdd_otg\n");
Disp("If you want to have OTG exited from suspend mode, press 'x' key\n");
while(ucKey!='x')
{
ucKey = UART_GetKey();
}
////
OTGDEV_InitOtg(eSpeed);
////
Disp("USB host is not connected yet.\n");
Disp("Waiting for USB host connection.\n");
while(1)
{
if(OTGDEV_IsUsbOtgSetConfiguration()==true)
{
Disp("\n!!! USB host is connected !!!\n");
Disp(" - Bulk In EP : %d\n",BULK_IN_EP);
Disp(" - Bulk Out EP : %d\n",BULK_OUT_EP);
OTGDEV_CheckEnumeratedSpeed(&eUsbSpeed);
Disp(" - Speed : ");
if(eUsbSpeed == USB_HIGH)
{
Disp("High\n");
DisplayLED(0xf);
}
else if(eUsbSpeed == USB_FULL)
{
Disp("Full\n");
DisplayLED(0x6);
}
Disp(" - Op Mode : ");
if(eOpMode== USB_DMA)
{
Disp("DMA mode\n");
}
else if(eOpMode == USB_CPU)
{
Disp("CPU mode\n");
}
break;
}
if(i%0x800000==0)
DisplayLED(0x8);
if(i%0x800000==0x200000)
DisplayLED(0x4);
if(i%0x800000==0x400000)
DisplayLED(0x2);
if(i%0x800000==0x600000)
DisplayLED(0x1);
i++;
}
return;
}
//////////
// Function Name : DisplayMenu
// Function Description : This function displays the menus of the monitor pgm
// and then executes the selected item.
// Input : NONE
// Output : NONE
// Version :
void DisplayMenu(void)
{
int iSel, i;
const testFuncMenu menu[]=
{
Download_Run, "Download & Run",
Download_Only, "Donwload Only",
Upload_Only, "Upload Only",
Select_OpMode, "Select Op Mode",
Program_AM29F800, "Program AMD NOR Flash",
#if (USE_SCATTER_LOAD==0)
Program_NAND, "Program K9F1208 NAND Flash",
#endif
Suspend_Resume, "Suspend & Resume On/Off",
Check_SuspendCurrent, "Check Suspend Current",
0, 0
};
Disp("\n");
for (i=0; (int)(menu[i].desc)!=0; i++)
Disp("%2d: %s\n", i, menu[i].desc);
Disp("\nSelect the function to test : ");
iSel = GetIntNum();
Disp("\n");
if ((iSel>=0) && (iSel<sizeof(menu)/8-1))
(menu[iSel].func)();
}
//////////
// Function Name : main
// Function Desctiption : main function of the monitor pgm.
// Input : NONE
// Output : NONE
// Version :
extern u8 aDescStr2[];
int main(void)
{
u32 i=0;
USB_SPEED eUsbSpeed;
SYSTEM_InitException();
#if (ONLY_ICACHE_ENABLED == TRUE)
SYSTEM_EnableICache();
#else
SYSTEM_InitMmu();
#endif
//SYSC_ChangeMode(eASYNC_MODE);
//SYSC_ChangeSYSCLK_1(eAPLL400M, eAPLL200M, 0, 0, 3);
SYSC_ReadSystemID();
SYSC_GetClkInform();
GPIO_Init();
OpenConsole();
Disp("\n\n");
PM_Check();
DisplayLED(0x0);
CalibrateDelay();
Disp("VCO=%.3fGHz",(float)(g_APLL<<(Inp32SYSC(0x00c)&0x3))/1.0e9);
Disp("\n\n");
Disp("+-----------------------------------------------+\n");
if (g_System_ID == 0x364101)
{
Disp("| S3C6410 USB OTG Downloader v0.2 (2008.07.04) +\n");
aDescStr2[20] = '1';
}
else
{
Disp("| S3C6400 USB OTG Downloader v0.2 (2008.07.04) +\n");
aDescStr2[20] = '0';
}
Disp("| System ID : Revision [%2d], Pass [%2d] +\n", g_System_Revision, g_System_Pass);
Disp("+-----------------------------------------------+\n");
Disp("ARMCLK: %.2fMHz HCLKx2: %.2fMHz HCLK: %.2fMHz PCLK: %.2fMHz\n",(float)g_ARMCLK/1.0e6, (float)g_HCLKx2/1.0e6, (float)g_HCLK/1.0e6, (float)g_PCLK/1.0e6);
#if (VIC_MODE == 1)
Disp("VIC mode / ");
#else
Disp("non-VIC mode / ");
#endif
if(g_SYNCACK==eSYNC_MODE)
Disp("Sync Mode\n\n");
else
Disp("Async Mode\n\n");
Disp("USB host is not connected yet.\n");
Disp("Waiting for USB host connection.\n");
INTC_SetVectAddr(NUM_OTG, Isr_UsbOtg);
INTC_Enable(NUM_OTG);
OTGDEV_InitOtg(eSpeed);
while(1)
{
if(OTGDEV_IsUsbOtgSetConfiguration()==true)
{
Disp("\n!!! USB host is connected !!!\n");
Disp(" - Bulk In EP : %d\n",BULK_IN_EP);
Disp(" - Bulk Out EP : %d\n",BULK_OUT_EP);
OTGDEV_CheckEnumeratedSpeed(&eUsbSpeed);
Disp(" - Speed : ");
if(eUsbSpeed == USB_HIGH)
{
Disp("High\n");
DisplayLED(0xf);
}
else if(eUsbSpeed == USB_FULL)
{
Disp("Full\n");
DisplayLED(0x6);
}
Disp(" - Op Mode : ");
if(eOpMode== USB_DMA)
{
Disp("DMA mode\n");
}
else if(eOpMode == USB_CPU)
{
Disp("CPU mode\n");
}
break;
}
if(i%0x800000==0)
DisplayLED(0x8);
if(i%0x800000==0x200000)
DisplayLED(0x4);
if(i%0x800000==0x400000)
DisplayLED(0x2);
if(i%0x800000==0x600000)
DisplayLED(0x1);
i++;
}
Disp("\nDownload & Run is selected\n\n");
Download_Run();
while(1)
{
download_run = false;
bStop_Download_Run = false;
DisplayMenu();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -