📄 initio.c
字号:
// G_Battery_GroupNum = (XBYTE[0x240C] & 0x08)>>3;//select battery group
//0:1.5V or 3V alkaline battery.
//1:3.6V rechargeable battery.
DbgP15=1;//turn off DAC OP Power 20031015
DbgP14=1; //MUTE
//---- Initialize ASIC when Power on !!
L2_InitGlobal(0); // Enable SRAM and internal USB Transceiver
L2_InitCPU(); // SGJM L2_InitCPU(0);
// L2_InitUSB(0); // initial parameters , Donot care it when simulate!
Current_Dvr_Dir=1; //hxd030723 add
}
//-----------------------------------------------------------------------------
//INITIO_UsbInitialize
//-----------------------------------------------------------------------------
void INITIO_UsbInitialize(void) USING_0
/*++
Routine Description: initialize USB function
Arguments: none
Return Value: none
--*/
{
//richie@ref 0326
#if (EVBoard_OPTION==0)
//patch2.2.1@chamber@USB_WriteProtected
//XBYTE[0x2102]=XBYTE[0x2102] & 0xfd; //P11 input enable for Hold key
XBYTE[0x2038]=XBYTE[0x2038]&0xfe;
//if(DbgP11)
if(HOLDDETECT)
{
G_USBMSDC_ucCardLock = 1; // lock
_G_USB_LockTG0=TRUE;
_G_USB_LockTG1=TRUE;
}
else
{
G_USBMSDC_ucCardLock = 0; // unlock
_G_USB_LockTG0=FALSE;
_G_USB_LockTG1=FALSE;
}
G_USBMSDC_ubRefreshNeeded = 0;
#else
G_USBMSDC_ucCardLock = 0; // unlock
_G_USB_LockTG0=FALSE;
_G_USB_LockTG1=FALSE;
G_USBMSDC_ubRefreshNeeded = 0;
#endif
//end of patch2.2.1@chamber@USB_WriteProtected
#if (USBVendor_OPTION==1)
G_ucState = 0;
G_ucState2 = 0;
#endif
// _G_USB_LockTG0=FALSE;
// _G_USB_LockTG1=FALSE;
//patch4.5@richie@eject
G_USBMSDC_ucEject = 0;
//richie
G_btEP0Intr = 0;
G_btBulkIntr = 0;
//richie@g0201
//XBYTE[0x2039] &= 0xef;
G_log27c0 = 0;
G_ucPktStorIntrf = K_StorageInterface1; //current packet belongs to which storage interface
G_ucCtrlPhase = K_CommandPhase;
G_ucBulkPhase = K_CommandPhase; //cytsai@1122
G_ulStorDataLength = 0;
G_ulStorDataIndex = 0;
G_USBMSDC_usSizeProcessed = 0;
G_USBMSDC_ucSenseCodeIdx = 0x00;
G_USBMSDC_ucCSWStatus = K_USBMSDC_CommandPassed;
//richie open bulk out first
XBYTE[0x25a1] = K_USB_CLASS_OUT_OPEN;//0x02;
XBYTE[0x25d2] = K_USB_CLASS_OUT_ACK_MASK;//0x02;
//richie@1211
XBYTE[0x25a0] &= 0xfc; //reject (NAK)
// next EP0 Out packet
// next EP0 In packet
//----chamber@0103 for USB plug-in Event Detect in I/O option
//---- Caution :: Need to Modify Demo board H/W
XBYTE[0x2050]|= 0x01; // Enable GPIO0 rising edge interrupt!!
XBYTE[0x2058]|= 0x01; // Enable GPIO0 falling edge interrupt!!
// if(!(XBYTE[0x240C]&0x04)) // Check the USB Detect I/O
// _G_USBPowerOn = TRUE; // USB Power On Connect
//
//-- Polling the USB I/O pin for setting default status in initial procedure!
//if(!(XBYTE[0x2040]&0x01))
if(!USBDETECT)
_G_USBConnect = TRUE; // If USB pin is low, then USB is Connect!
else
_G_USBConnect = FALSE; // If USB pin is "High", then USB is Dis_connect!
XBYTE[0x25c0] = 0x00;
XBYTE[0x25d0] = 0x27; //enable interrupt for
// EP0 Setup packet OK
// EP0 Out packet OK
// EP0 In packet OK
// Configuration change
_G_USBSuspendPermit = FALSE; //
_G_ucSuspend=0;
}
//-----------------------------------------------------------------------------
//INITIO_CpuInitialize
//-----------------------------------------------------------------------------
void INITIO_CpuInitialize(void) USING_0
/*++
Routine Description: initialize embedded micro-controller
Arguments: none
Return Value: none
--*/
{
TCON = 0x40; //TCON: IT0=0 INT0 negative edge trigger
// IE0=0 INT0 interrupt flag
// IT1=0 INT1 negative level trigger
// IE1=0 INT1 interrupt flag
// TR0=0 TIMER0 disable
// TF0=0 TIMER0 overflow flag
// TR1=1 TIMER1 enable
// TF1=0 TIMER1 overflow flag
IP = 0x03; //IP: PX0=1 INT0 priority level
// PT0=1 TIMER0 priority level
// PX1=0 INT1 priority level
// PT1=0 TIMER1 priority level
// PS=0 Serial Port priority level
// PT2=0 Timer2 priority level
IE = 0x81; //IE: EX0=1 INT0 interrupt enable
// ET0=0 TIMER0 interrupt disable
// EX1=0 INT1 interrupt disable
// ET1=0 TIMER1 interrupt disable
// ES=0 Serial Port interrupt disable
// ET2=0 TIMER2 interrupt disable
// EA=1 All interrupts enable
TMOD = 0x21; //TMOD: Timer0 M1M0=1 (Mode1=16-bit counter)
// Timer0 C/T~=0 (Timer)
// Timer0 GATE=0
// Timer1 M1M0=2 (Mode2=8-bit counter)
// Timer1 C/T~=0 (Timer)
// Timer1 GATE=0
/*
TH1 = 0xf3;
PCON |= 0x80; //PCON: SMODE=1 double baud rate
SCON0 = 0x52; //SCON0: RI=0 interrupt flag of receiving
// TI=1 interrupt flag of transmitting
// RB8=0 stop bit (9th bit) of receiving
// TB8=0 stop bit (9th bit) of transmitting
// REN=1 receiving enable
// SM2=0
// SM1=1 8-bit UART, baud rate set by software
// SM0=0
*/
}
//-----------------------------------------------------------------------------
//INITIO_StorageInitialize
//-----------------------------------------------------------------------------
void INITIO_StorageInitialize(void) USING_0
/*++
Routine Description: initialize storage
Arguments: none
Return Value: none
--*/
{
BYTE sts;
Card_InitGlobal();
G_Card_Type = K_MEDIA_CARD;
sts = STORAGE_Detect();
if (sts == TRUE)
{
_G_Storage_Error = TRUE; // Default is Error
sts = STORAGE_Initialize(TRUE);
if (sts)
{
_G_Storage_Error = FALSE; // Storage is StandBy
}else{
// NOTE:should display to user message
// such as "Can't initialize, do format ?"
// The initialize if false may be because
// not support FAT32, unrecognized format, DOS have problem, etc.
DbgPrint("INITIO_Initialize: STORAGE_Initialize Fail %x\n", G_DOS_ErrCode);
// DbgPrint("INITIO_Initialize: STORAGE_Initialize Fail %bx\n", G_Card_Type);
//--- Chamber@0110-- DOS error Code Return !!
/*
DbgPrint("DOS error\n");
if (G_DOS_ErrCode == K_DOS_DiskFullErr)
DbgPrint("Flash card full test\n");
if ((G_DOS_ErrCode == K_DOS_UnknownFSErr) || (G_DOS_ErrCode == K_DOS_Fat32NotSupportErr) )
{
DbgPrint("INITIO_Initialize: K_DOS_UnknownFSErr, K_DOS_Fat32NotSupportErr\n", G_DOS_ErrCode);
sts = STORAGE_Format(0x41);
}
*/
// ----- Do not try to format by firmware, and show Message Only! //Chamber@1227
#if 1
//else
// LCD10_Disp_DeleteOneAll(0,Blink_FG);//disp del all
// sts = STORAGE_Format(0x41);
// NOTE:sts may be FALSE or 1, 2, 3
// if (sts != FALSE)
{
// DbgPrint("INITIO_Initialize: Try format OK\n");
sts = STORAGE_Initialize(TRUE);
// DbgPrint("INITIO_Initialize: format STORAGE_Initialize %x\n", G_DOS_ErrCode);
//@wyeo@110502, begin
if (sts)
{
_G_Storage_Error = FALSE; // Storage is StandBy
// DbgPrint("INITIO_Initialize: STORAGE_Initialize OK\n");
}else{
// DbgPrint("INITIO_Initialize: STORAGE_Initialize Fail Again\n");
}
//@wyeo@110502, end
}
//else{
//DbgPrint("INITIO_Initialize: Try format Fail\n");
//}
#endif
}
//if (sts)
// TEST_RunTest();
}
// DbgPrint("G_Card_Type=%bx\n",G_Card_Type);
// DbgPrint("G_ucStorageType=%bx\n",G_ucStorageType);
}
#if(CARD_OPTION == 1)
// WWWW0327 start
void Card_InitGlobal(void) USING_0
{
// BYTE k;
#if ( SMC_OPTION == 1 || NANDF_OPTION == 1 )
// control the G_NAND_ReservBlockTotal value to
// reserve nand block for you own purpose.
// The value must not exceed 20.
// good block 0 MUST for used by sensor bad pixel
// good block 1 MUST for used by reserve
// good block 2, 3 MUST for used by DOS
// good block 4, 5, 6, 7 for vendor used
// G_NAND_ReservBlockTotal = 20; // suggest 8 block, should not exceed 20
// G_NAND_ReservBlockMax = 20; // must 20
G_NAND_ReservBlockTotal = K_NANDF_TOTAL_RESERVE_BUFFER; // suggest 8 block, should not exceed 20
G_NAND_ReservBlockMax = K_NANDF_TOTAL_RESERVE_BUFFER; // must 20
#endif
Card_InitLibGlobal();
return;
}
// WWWW0327 end
#endif
//=============================================================================
//Y_UI_Initialize
//=============================================================================
/* SGJM TEMP DELETE void DSP_Sleep_Process(void) USING_0
{
// USHORT mwTemp;
XBYTE[0x2010] &= 0xFE;
}*/
void DSP_Wakeup_Process(void) USING_0
{
// USHORT mwTemp;
XBYTE[0x2010] |= 0x01;
}
void USER_DelayDT(USHORT DT)
{
USHORT i;
for(i=0;i<=DT;i++);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -