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

📄 power.c

📁 TDA7540 收音机程序
💻 C
字号:
/***************************************************************************
Project  :  TDA7421 Jig board for Henko Autosound
Compiler : ST7 HiCross C (HiWARE)
Module   :  power.c
Version  :  V 1.0
Created  :  
Author   :  Jerry HE / ST-ShenZhen
Description
         -  System head file and data structure definition  
Modified
	  - Jan.24th,2005    
***************************************************************************/

#include "system.h"
//declare the function

/**************************init the system************************************/
/*--------------------------------------------------------------------------
Routine : Init_System
Input   : 
Output  :
Description 
        - Initial the whole syetem
--------------------------------------------------------------------------*/ 
void Init_System()
{
	SIM;
	Init_PortConfig();
	Init_RegisterConfig();
	Init_Parameter();
	SystemInit();
	Init_AD();
	LCDInit();
	Aud_Init();
	Radio_Init();
	RIM;
}

/*--------------------------------------------------------------------------
Routine : Init_PortConfig
Input   : 
Output  :
Description 
        - Initial the Port 
--------------------------------------------------------------------------*/ 

void Init_PortConfig()
{
	/*Initial Port A*/
	PA_DR.byte = y00000000;
	PA_DDR.byte = y11000000;
	PA_OR.byte = y00000011;
	
	/*Initial Port B*/
	PB_DR.byte = y00000000;
	PB_DDR.byte = y01000111;
	PB_OR.byte = y01000111;
	
	/*Initial Port C*/
	PC_DR.byte = y00000000;
	PC_DDR.byte = y11111111;
	PC_OR.byte = y11111111;
	
	/*Initial Port D*/
	PD_DR.byte = y00000000;
	PD_DDR.byte = y00000000;
	PD_OR.byte = y01100000;
	
	/*Initial Port E*/
	PE_DR.byte = y00000001;
	PE_DDR.byte = y00010001;
	PE_OR.byte = y00011001;

	
	/*Initial Port F*/
       PF_DR.byte = y00000000;
	PF_DDR.byte = y00000100;
	PF_OR.byte = y00000100;

	//P_PWRON  = 1;
}

/*--------------------------------------------------------------------------
Routine : Init_RegisterConfig
Input   : 
Output  :
Description 
        - Initial the register
--------------------------------------------------------------------------*/ 

void Init_RegisterConfig()
{
	/*--------Peripheral Registers----------*/
        MCCSR = (FOSC_DIV_16|TBC_50MS);		//if select slow mode, divide is 16
        EICR = 0x90;        // port A rising edge - others low & falling edge
                                          //Out to PB7, Neg Edge for Ext Int */
	 //ISPR0=0x00;

										  
        SPI1_CR = 0;                    /* Disable SPI */
        TIM1_CR2 = 0x08;                /* Clock divided by 8 */
        TIM1_CR1 = 0x40;                /* Output Compare Int Enable */
	    P_AMUTE = 1;
        //P_AMUTE = 0                        /* Mute Here ! */
}

/*--------------------------------------------------------------------------
Routine : Init_Parameter
Input   : 
Output  :
Description 
        - Initial the system parameter
--------------------------------------------------------------------------*/ 

void Init_Parameter()
{
	PowerOnDelay=4;
	SystemPwrMode=POWEROFF;
	F_BoardEEPEmpty =0;
	F_TunerEEPEmpty =0;
	SystemFlag.byte= 0;

	F_OnePointAlign = 0; // set to 3 point auto alignment
}

/*--------------------------------------------------------------------------
Routine : Comm_Key_Proc
Input   : 
Output  :
Description 
        - Common Key procedure
--------------------------------------------------------------------------*/ 

void Comm_Key_Proc()
{
	switch(KeyCode)
	{
		case Key_Pwr:
			if(SystemPwrMode==POWERON)
			{
				Power_Off();
			}
			if(SystemPwrMode==POWEROFF)
			{
				Power_On();
			}
			break;
	}
}

/*--------------------------------------------------------------------------
Routine : Power_main
Input   : 
Output  :
Description 
        - main routine for power on/off
--------------------------------------------------------------------------*/ 
void Power_main()
{
    switch(SystemPwrMode)
    	{
    	    case POWERON:
		     break;
	    case POWERONREQ:
		     //here power on the tuner/audioprocessor//
		     P_PWRON  = 1;
                   SystemPwrMode = POWERONWAIT;
		     PowerOnDelay=50;
		     break;
	    case POWERONWAIT:
		     if(PowerOnDelay !=0) break;
		     //Here boot the tuner...
                   TunerSettingLoad();        // Load Tuner setting first
		     Radio_PowerOn();           // Power on the radio...
      		     Audio_PowerOn();
		     DisplayMode.Request = DispMode_NORMAL;
		     SystemWorkMode.Request = SystemBackUpWorkMode;
		     SystemPwrMode = POWERON;
		     break;
	    case POWEROFF:
		     break;
	    case POWEROFFREQ:
		     P_PWRON  = 0;
		     SystemPwrMode = POWEROFFWAIT;	 
		     break;
	    case POWEROFFWAIT:
		     SystemPwrMode = POWEROFF;
		     break;
    	}
}


/*--------------------------------------------------------------------------
Routine : Power_Off
Input   : 
Output  :
Description 
        - Power off the system
--------------------------------------------------------------------------*/ 

void Power_Off()
{
     TunerSearchFlag.byte= 0;
     TunerFlag.byte =0;                      //Clear the status;
     SystemPwrMode = POWEROFFREQ;
     LCDDisplayWelcome();
}

/*--------------------------------------------------------------------------
Routine : Power_On
Input   : 
Output  :
Description 
        - Power on the system
--------------------------------------------------------------------------*/ 
void Power_On()
{
     SystemPwrMode = POWERONREQ;
}

/*** (c) 2005  STMicroelectronics ****************** END OF FILE ***/
        

⌨️ 快捷键说明

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