📄 2460mon_otg.cpp
字号:
/**
* Project Name : S3C2460 verification project
*
* Copyright 2004 by Samsung Electronics, Inc.
* All rights reserved.
*
* Project Description :
* This software is only for verifying functions of the S3C2460.
* Anybody can use this code without our permission.
*/
/**
* File Name : 2460mon_otg.cpp
* Description : S3C2460 USB OTG monitor main code
* Author : Haksoo Kim
* Dept : Mobile solution, AP
* Created Date : 2005.06.02
* Version : 1.0
* History
* R1.0 (2005.06.02): First Release
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Option.h"
#include "Console.h"
#include "2460addr.h"
#include "2460lib.h"
#include "2460slib.h"
#include "mmu.h"
#include "profile.h"
#include "memtest.h"
#include "PLL.h"
#include "nand.h"
#include "am29f800.h"
#include "usb_otg_dev_main.h"
#include "usb_otg_dev_out.h"
#include "usb_otg_dev_lib.h"
#include "2460usb_otg_dev.h"
#include "usb_otg.h"
#include "otg_xvr_isp1301.h"
void Isr_Init(void);
void Check_SleepKey(void);
void Clear_SleepKey(void);
void Lcd_Off(void);
void Usb_On(void);
void Usb_Off(void);
void WaitDownload(void);
void Menu(void);
#define OS_START_ADDR_OFFSET (0x00200000)
#define DOWNLOAD_ADDRESS (_RAM_STARTADDRESS+OS_START_ADDR_OFFSET)
volatile unsigned int downloadAddress;
void (*restart)(void)=(void (*)(void))0x0;
void (*run)(void);
volatile unsigned char *downPt;
volatile unsigned int downloadFileSize=0;
volatile unsigned short checkSum=0;
volatile unsigned int err=0;
#if USBOTG_DMA
volatile unsigned int totalRxCountInDMA=0;
#endif
volatile int isUsbOtgSetConfiguration;
int download_run=0;
unsigned int tempDownloadAddress;
int menuUsed=0;
int first=1;
void WhichMemory( void)
{
{
#if (WHICH_PORT==1)
printf("PORT1 : ");
if (rP1BANKCFG_DDR&(1<<21)) printf("m");
if (rP1BANKCFG_DDR&(1<<22)) printf("DDR");
else printf("SDRAM_D");
#endif
printf("\tPORT2 : ");
if (rP2BANKCFG_DDR&(1<<21)) printf("m");
if (rP2BANKCFG_DDR&(1<<22)) printf("DDR\n");
else printf("SDRAM_D\n");
}
}
int main(void)
{
float mpll,armclk,hclk,pclk;
char armdiv,hdiv,pdiv;
uint32 i;
GlobalCLK();
Init_LogicalConsole();
Init_LED();
Isr_Init();
rCLKSRCCON |= (1<<5);
rCLKDIVCON = rCLKDIVCON | (1<<12); // USB 48 Div on
SetUPLL( 72, 3, 1);
//* initialize ISP1301
//ISP1301_Init_DeviceMode();
USBOTG_Port_Init();
/* emulate disconnection */
ISP1301_IIC_Write(OTG_XVR_ISP1301_ADDR,ISP1301_OTG_CTRL_CLR,0x03); //DP,DM pull-up resistor disable
for(i=0;i<0x1000;)i++;
isUsbOtgSetConfiguration=0;
#if 0
{
uint32 *otg_addr=(uint32 *)0x41944200;
printf("\n==============================================\n");
for(;otg_addr<(uint32 *)0x41944308;otg_addr++)
printf("= ADDR=0x%08x : VALUE = 0x%08x =\n",otg_addr,*otg_addr);
printf("==============================================\n");
}
#endif
//* initialize ISP1301
ISP1301_Init_DeviceMode();
#if (ONLY_ICACHE_ENABLED == TRUE)
MMU_EnableICache();
#else
MMU_Init();
#endif
UsbOtgDevMain();
#if USBOTG_DMA
if(rDSTAT2 & (1<<20))
rDMASKTRIG2 |= (1<<2);
for(i=0;i<0x1000;)
i++;
#endif
ConfigEp3IntMode();
Delay(0); //calibrate Delay()
pISR_SWI=(_ISR_STARTADDRESS+0xf0); //for pSOS
Led_Display(0x6);
mpll = (float)MPLL/1000000;
armclk = (float)ARMCLK/1000000;
hclk = (float)HCLK/1000000;
pclk = (float)PCLK/1000000;
armdiv = ARMCLKdiv+1;
hdiv = armdiv*(HCLKdiv+1);
pdiv = hdiv*(PCLKdiv+1);
printf("\n\n");
#if USBOTG_DMA
printf("+-------------------------------------------------+\n");
printf("| S3C2460A USB OTG Downloader ver R0.2 (DMA Mode) |\n");
printf("+-------------------------------------------------+\n");
#else
printf("+-------------------------------------------------------+\n");
printf("| S3C2460A USB OTG Downloader ver R0.2 (Interrupt Mode) |\n");
printf("+-------------------------------------------------------+\n");
#endif
printf("MPLL=%.2fMHz, ARMCLK=%.2fMHz (%d:%d:%d), HCLK=%.2fMHz, PCLK=%.2fMHz\n\n",mpll,armclk,armdiv,hdiv,pdiv,hclk,pclk);
printf("USB: IN_ENDPOINT:1 OUT_ENDPOINT:3\n");
printf("FORMAT: <ADDR(DATA):4>+<SIZE(n+10):4>+<DATA:n>+<CS:2>\n");
printf("NOTE: 1. Power off/on or press the reset button for 1 sec\n");
printf(" in order to get a valid USB device address.\n");
printf(" 2. For additional menu, Press any key. \n");
printf("(Bulk Max Packet Size is %3dbytes)\n",OTG_BULK_PKT_SIZE);
printf("\n");
/*******************************/
/* Cause of Boot-up */
/*******************************/
// Check_SleepKey(); // Check the cause of Boot-up(Watchdog /Soft Reset / Power on reset / Sleep wakeup.....)
download_run=1; //The default menu is the Download & Run mode.
while(1)
{
if(menuUsed==1)Menu();
WaitDownload();
}
}
unsigned char not_suspend = TRUE;
unsigned char not_resume = TRUE;
unsigned char sus_res_print = FALSE;
uint32 bank_of_nor=0;
void Menu(void)
{
int i;
int key;
menuUsed=1;
volatile uint32 saved_SROM_BW;
uint32 jumpAddress;
while(1)
{
printf("\n###### Select Menu ######\n");
printf(" [0] Download & Run\n");
printf(" [1] Download Only\n");
printf(" [2] Test SDRAM \n");
printf(" [3] Program NAND Flash Memory(K9S1208)\n");
printf(" [4] Run DSP\n");
printf(" [5] Clear SDRAM.\n");
printf(" [6] Jump to Specific Address.\n");
printf("\t(Note! Effective only when pressing a reset button without power-off.\n");
printf(" [7] USB Suspend/Resume Test\n");
#if (WHICH_PORT==1) //only 496pkg supports this
printf(" [8] Program AMD NOR Flash Memory\n");
#endif
//* temporary code for otg xvr test
printf(" [9] Read all registers of ISP1301.\n");
key=getchar();
switch(key)
{
case '0':
printf("\nDownload&Run is selected.\n\n");
download_run=1;
return;
case '1':
printf("\nDownload Only is selected.\n");
printf("Enter a new temporary download address(0x1...):");
tempDownloadAddress=GetIntNum();
download_run=0;
printf("The temporary download address is 0x%x.\n\n",tempDownloadAddress);
return;
case '2':
printf("\nMemory Test is selected.\n");
MemoryTest();
Menu();
return;
break;
case '3':
Test_K9S1208();
printf("\nProgram NAND Flash Ends.\n");
rINTMSK&=~(BIT_USB);
rINTSUBMSK&=~(BIT_SUB_USBD);
break;
case '4':
rARM2DSP_CTRL &= ~(0x8);
i=HCLK;
printf("\nSelect the frequency of DSPCLK\n");
printf("[0] HCLK (%dMHz) [1] HCLK/2 (%dMHz)\n",i/1000000,i/2000000);
if (getchar()=='1') {
rCLKDIVCON |= 0x8;
i/=2;
} else {
rCLKDIVCON &= ~(0x8);
}
printf("\nNow run the TeakDSP @%dMHz !!!\n",i);
rARM2DSP_CTRL |= 0x8;
break;
case '5':
printf("\nMemory Clear is selected.\n");
ClearMemory();
break;
case '6':
printf("\nEnter the branch address(Default:0x%08x):",(_RAM_STARTADDRESS+0x00200000));
jumpAddress=(uint32)GetIntNum();
if (jumpAddress==0xffffffff)
jumpAddress = (_RAM_STARTADDRESS+0x00200000);
run = (void (*)(void))jumpAddress;
run();
break;
case '7':
printf("\n USB Suspend/Resume test is selected.\n");
printf("\nIf you don't want to wait suspend interrupt any more, press any key\n");
apOTG_TLI_DEV_G->devIntrMask = 0;
sus_res_print = TRUE;
apOTG_TLI_DEV_G->devIntr |= OTG_DEV_SUSPEND_INTR;
apOTG_TLI_DEV_G->devIntrMask |= OTG_DEV_SUSPEND_INTR; //enable suspend interrupt
while(((apOTG_TLI_DEV_G->devStatus & (0x1<<12)) != (0x1<<12)) && (not_suspend==TRUE))
{
if(Uart_GetKey())
break;
}
if(apOTG_TLI_DEV_G->devStatus & (0x1<<12))
{
printf("\nEntered Suspend Mode\n");
}
printf("\nIf you want to end this test with resume-checking, press 'y' key\n");
while(not_resume==TRUE)
{
if(Uart_GetKey()=='y')
break;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -