📄 reset.c
字号:
/*----------------------------------------------------------------------------
* Copyright (c) 200 by National Semiconductor Corporation
* National Semiconductor Corporation
*
* All rights reserved
*
*<<<-------------------------------------------------------------------------
* File Contents:
* Reset routines
*
* Project: USB Demo firmware
* Author : Yan Nosovitsky
* Date : Oct 2001
*----------------------------------------------------------------------->>>*/
#include "..\include\all.h"
/*<<<-------------------------------------------------------------------------
*
* The software reset routine. Initializes the main system blocks (like
* stacks, wait-states, dispach table) before we can start working.
*
*--------------------------------------------------------------------------*/
void c_reset(void)
{
u_int saved_psr;
WORD i;
// delay to make cristal stable
for(i=0 ;i< 0xFFFF ;i++);
ICU_init();
/*First set the environment clock*/
/* This way you set the clock 8MHz max performence */
//HFCGP = 0x04;
//HFCGCTRL1 |= HFCGCTRL1_LOAD96;
// if (GET_DIP_SW1() & 0x80){
// /* This way you set the clock 8MHz max performence */
// HFCGN = 0x0B;
// HFCGML = 0x7C;
// HFCGMH = 0x0A;
// }
// else {
/* This way you set the clock 20MHz max performence */
HFCGN = 0x0A;
HFCGML = 0xD6;
HFCGMH = 0x17;
// }
HFCGCTRL1 |= HFCGCTRL1_LOAD;
/*Set the memory to work with late write, and enable the BIU unit*/
BCFG = 0;
MCFG = MCFG_ENEIO;
MCFGSH = MCFG_ENEIO;
IOCFG = IOCFG_HOLD0 | IOCFG_HOLD1; /* 0 wait state, 3 hold clock, 0 idle cycle*/
SZCFG1 = SZCFG1_BW | SZCFG1_FRE;
/*Set the Leds presentation */
PFALT = 0x0; /*Set IOPF port aternate function to work as GPIO port*/
PFDIR = 0xFF; /*Set the direction of the IOPF port to output*/
SET_ID_LEDS(0); /*Turn off all the Leds*/
RESET_USB_LED();
/*Set the GPIO port to 0x55*/
PCALT = 0; /*Set IOPC alternate funcion to GPIO*/
PCDIR = 0xFF; /*Set all the IOPC port to output*/
PCDOUT = 0x0; /*Set the output of the IOPC port to 0x55*/
/* USBN9604 init */
USBN9604_init();
/*enable usb interrupt*/
//ICU_unmask_int(USB_NODE_INT);
/* SCANPSC100F init */
// SCANPSC100F_init();
/*enable usb interrupt*/
USB_int_enable();
//Watchdog initialization
WATCHDOG_INIT;
//USB_Init();
/* Enable interrupts */
_spr_("psr",saved_psr);
saved_psr |= PSR_E_BIT_MASK | PSR_I_BIT_MASK;
_lpr_("psr",saved_psr);
dprintf(("write done\n"));
main();
}
/*----------------------------------------------------------------------------
* void panic(msg)
*
* This function is a hook for catching anomalous/catastrophic events.
* It can be replacable by the user (since it resides in a library)
* simply by defining it somewhere else.
*
* It assumes the 'msg' contains some information about the problem,
* (although you don't HAVE to pass it anything).
* Examining the context (active routines on the current stack, 'where'
* from within the debugger) may further direct you to the problem.
*
* This is here only for debugging - if you get here - it is a real problem
* that should never happen in a final product.
* In the 'production' we do a cold-reset from here, just in case...
* In principle, 'panic' should be never called in a real product.
*--------------------------------------------------------------------------*/
public int panic(char *str)
{
#ifdef DEBUG
printf(str);
ROM_BPT;
#else
WATCHDOG_RESET;
#endif
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -