⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reset.c

📁 以ST公司CPU为核心的彩色电视机的完整源程序。
💻 C
字号:
/******************************** SKYWORTH *********************************
FILENAME     : RESET.H
VERSION      : V0.1
DATE         : JAN 2000
AUTHOR(s)    : Vick Zhong
PROCESSOR    : ST92196
DESCRIPTION  : This module contains the reset entry point of the software and
	       the initialization of the ST9 core and ST9 peripherals.
MODIFICATIONS:
*****************************************************************************/

#include "macro.h"
#include "st92196.h"
#include "tv_glob.h"
#include "register.h"
#include "utility.h"
#include "init.h"

#include "alarm.h"
#include "channel.h"
#include "clock.h"
#include "command.h"
#include "display.h"
#include "eeprom.h"
#include "i2c_bus.h"
#include "io.h"
#include "ir.h"
#include "power.h"
#include "reset.h"
#include "timer.h"
#include "tuning.h"
#include "video.h"
#include "autosrch.h"
#include "display.h"
#include "osddrv.h"

unsigned char power_status;

/*These variables are defined in .scr file as a label for configuring the memory*/

extern unsigned int _bss_start , _bss_end; 
extern unsigned int _stack_end , _user_stack_end;
/*****************************************************************************
Interrupt Vector Table - This table is located in the first locations of
			 the program memory. This table allows to access
			 interrupt handlers.
*Note : Not useable interrupt set to iret.
*****************************************************************************/
asm ( "
        .org    0
        .word   RESET            ;// Power On interrupt vector
        .word   DIV0VECTOR       ;// Divide by 0 interrupt vector
        .word   TOP_LEVEL_IT     ;// Top Level interrupt vector(NMI)-Not use

;// EMR2.ENCSR =0 .Interrupt can not save 'FLAG' when starting.
;// When occurring div0 interrupt ,first save 'FLAGR'.
DIV0VECTOR:
         push   R231             ;// FLAGR   
TOP_LEVEL_IT:
WDT_IT:
SPI_IT:
ADC_IT:
CC_IT:
         iret
;// External Interrupt Vectors
;// *Note: Must define EIVR = 0001xxxx
        .org    10h
        .word   WDT_IT            ;// Watchdog/Timer -Not use
        .org    12h
        .word   STD_IT            ;// Standard Time
        .org    14h
        .word   SPI_IT            ;// SPI -Not use
        .org    16h
        .word   I2C_IT            ;// I2C
        .org    18h
        .word   OSD_IT            ;// OSD
        .org    1Ah
        .word   ADC_IT       ;// A/D Converter / INT5
        .org    1Ch
        .word   CC_IT             ;// Closed Caption Slicer 1 & 2
        .org    1Eh
        .word   IR_IT             ;// IR preprocessor


;// On-Chip peripherals interrupt vector
        .org    20h               ;// Define IVR = 00100xxx for MultiFunction Timer
        .word   MFT_UO_IT         ;// MFT Overflow/Underflow              -Not use
        .org    24h
        .word   MFT_CAPTURE_IT    ;// MFT Capture event                   -Not use
        .word   MFT_COMPARE_IT    ;// MFT Compare event                   -Not use

        .org    30h               ;// Define IVR = 00110xxx for SCI0
        .word   SCI0_RX_ER_IT     ;// SCI0 receiver error                  -Not use
        .word   SCI0_BK_AM_IT     ;// SCI0 Break detected or address match -Not use
        .org    34h
        .word   SCI0_RX_DR_IT     ;// SCI0 receiver data ready or DMA end of block        -Not use
        .word   SCI0_TX_BE_IT     ;// SCI0 transmitter buffer or shift register empty, or transmitter DMA end of block -Not use

        .org    40h               ;// Define IVR = 01000xxx for SCI1
        .word   SCI1_RX_ER_IT     ;// SCI1 receiver error                  -Not use
        .word   SCI1_BK_AM_IT     ;// SCI1 Break detected or address match -Not use
        .org    44h
        .word   SCI1_RX_DR_IT     ;// SCI1 receiver data ready or DMA end of block -Not use
        .word   SCI1_TX_BE_IT     ;// SCI1 transmitter buffer or shift register empty, or transmitter DMA end of block -Not use

MFT_UO_IT:     
MFT_CAPTURE_IT:
MFT_COMPARE_IT:

SCI0_RX_ER_IT: 
SCI0_BK_AM_IT: 
SCI0_RX_DR_IT: 
SCI0_TX_BE_IT: 

SCI1_RX_ER_IT: 
SCI1_BK_AM_IT: 
SCI1_RX_DR_IT: 
SCI1_TX_BE_IT: 
               iret
 
      " );


/*****************************************************************************
INPUTS     : none
OUTPUTS    : none
DESCRIPTION: This function resets all bss section to 0
*****************************************************************************/
void Clear_BSS()
{
	unsigned char *p;

	for (p=(unsigned char *) &_bss_end; p>=(unsigned char *) &_bss_start; p--)
	{
		*p=0;
	}
}

/*****************************************************************************
INPUTS     : none
OUTPUTS    : none
DESCRIPTION: This function resets all user registers to 0
*****************************************************************************/
void Clear_Register_File(unsigned char number)
{
	asm("	ld	r4, %0
			clr     r5
	clear:
			ld              (r4),r5
			dec     r4
			jxnz    clear": :"r"(number) :"rr4");
}

/*****************************************************************************
INPUTS     : none
OUTPUTS    : ST9 system registers
DESCRIPTION: This function is executed each time the ST9 returns from the 
	     reset state. This function performs initialization of the
	     processor and other subsystems of the chassis. When complete,
	     this function transfers control to the main function.
*****************************************************************************/
void RESET(void)
{ 
    unsigned int i;     
    
    asm("di");
	
    spp(0x00);
    
    
    FLAGR = 0x01;           /* Clear flags and set data memory */
      WCR = INIT_WCR;       /* Disable Watchdog */
    MODER = INIT_MODER;     /* Set the user stack in the memory*/
                            /* and the system stack in the memory.*/
                            /* No division and prescaler set to 1 */
	CICR  = INIT_CICR;      /* Interrupt disabled, nested mode, current priority */
                            /* level 7 and top level interrupt disabled */
	
	srp(BKD0);              /* Select the current working register bank: BANK D */

    asm("
		sdm
		ldw RR238,#_stack_end         ;// Setup system stack
		ldw RR236,#_user_stack_end    ;// Setup user stack
		ldw rr12,RR236                ;// Make sure rr12 is NOT zero
	
		;spp     #21
		;and     R245, #11110000b
	");


    Clear_BSS();                    /* Clears all the bss section !!!! */
    Clear_Register_File(175);       /* Clears all the registers used */
    /* END MODIF TC */
    
    /* here in init.c file*/	
    init_IT();
    init_TCC();
    init_RCCU();
    init_SCI ();                    /* initialize sci for mouse */
    init_STDT01 ();                 /* initialize standard timer with 0.1s IT */
    init_ADC ();                    /* initialize for keyboard */

    init_IR ();                     /* initialze IR in ir.c file*/
    init_osd ();                    /* initialize osd in osddrv.c file*/

 	init_IO();                              /* Init all IOs */

	
	init_autosearch();      /* Initialize auto_search */
	init_power();           /* Initialize power management */
	init_command();         /* Initialize command processor */
	init_tuning();          /* Initialize tuning */
	init_channel();         /* Initialize channel manager */
	display_request_flags = 0;
	init_auto_demo_var();  
	init_clock();           /* Initialize the time of the day clock */

    InitI2cBus( I2C_CHANNEL_1 |I2C_050KHZ );
/* Read TV option byte in the EEPROM */
/* tv_options = read_eeprom(EEPROM_TV_OPTIONS);  */
/* Initialize EEPROM contents */

	asm("ei");

	system = tv_options & 0x03; 
	millisecond_delay(150);

	init_EEPROM();                  

	channel = read_eeprom(EEPROM_LAST_CHANNEL);
	
	i = read_eeprom(EEPROM_POWER_STATUS);
	power_status = i & 0x01;
	if(power_status == POWER_STANDBY)
	{
		tv_flags |= ON_STATE;
		tv_flags = tv_flags &~ ENABLE_POWER;
	}
	else
	{
		tv_flags |= ENABLE_POWER;
		tv_flags = tv_flags &~ ON_STATE;
		power_state = ON1;
	 }
	 
	init_alarm();           /* Initialize alarms */

	spp(VS_PG);
	VS_R = VS_R &~ 0xffff;

	VS_R = VS_R | 0x8000;


//    Clear_OSDRAM ();                /* clear osdram in osddrv.c file*/

	osd_disabled() ;  /* configurate osd */
	init_display(); /* osd */


	asm ("jp main");                                                                        /* Give control to the main function */

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -