📄 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();
/*------------------------------------
* 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;
/*-----------------------------------------
* 0 wait state, 3 hold clock, 0 idle cycle
*----------------------------------------*/
IOCFG = IOCFG_HOLD0 | IOCFG_HOLD1;
SZCFG1 = SZCFG1_BW | SZCFG1_FRE;
/*-------------------------
* Set the Leds presentation
*-------------------------*/
/*-----------------------------------------------------
* Set IOPF port aternate function to work as GPIO port
*----------------------------------------------------*/
PFALT = 0x0;
/*----------------------------------------------
* Set the direction of the IOPF port to output
*--------------------------------------------*/
PFDIR = 0xFF;
PFDOUT = 0x80;
/*----------------------
* Turn off all the Leds
*----------------------*/
SET_ID_LEDS(0);
RESET_USB_LED();
/*-------------------------
*Set the GPIO port to 0x55
*-------------------------*/
/*-----------------------------------
* Set IOPC alternate funcion to GPIO
*----------------------------------*/
PCALT = 0;
/*--------------------------------
* Set all the IOPC port to output
*-------------------------------*/
PCDIR = 0xFF;
/*---------------------------------------
* Set the output of the IOPC port to 0x55
*--------------------------------------*/
PCDOUT = 0x0;
/*---------------
* USBN9604 init
*-------------*/
USBN9604_init();
/*---------------------
* enable usb interrupt
*-------------------*/
USB_int_enable();
/*-----------------------
* Watchdog initialization
*-----------------------*/
WATCHDOG_INIT;
/*------------------
* Enable interrupts
*-----------------*/
_spr_("psr",saved_psr);
saved_psr |= PSR_E_BIT_MASK | PSR_I_BIT_MASK;
_lpr_("psr",saved_psr);
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 + -