📄 por.c
字号:
/* **********************************************************************
Copyright (c) 2002-2006 Beyond Innovation Technology Co., Ltd
All rights are reserved. Reproduction in whole or in parts is
prohibited without the prior written consent of the copyright owner.
----------------------------------------------------------------------
Module: POR.C - Power-On-Reset.
Purpose: Implementation of POR module.
Version: 0.01 11:26AM 2005/11/17
Compiler: Keil 8051 C Compiler v8.01
Reference:
----------------------------------------------------------------------
Modification:
R0.01 11:26AM 2005/11/17 Jeffrey Chang
Reason:
1. Original.
Solution:
********************************************************************** */
#define _POR_C_
/* ------------------------------------
Header Files
------------------------------------ */
#include "bitek.h"
#include "dispatch.h"
#include "eeprom.h"
#include "font.h"
#include "i2c.h"
#include "key.h"
#include "led.h"
#include "mcu.h"
#include "menu.h"
#include "osd.h"
#include "platform.h"
#include "por.h"
#include "timer.h"
#include "yuv.h"
#if (AUDIO_CFG != AUDIO_00_NONE)
#include "audio.h"
#endif
#if (IR_CFG != IR_00_UNUSE)
#include "ir.h"
#endif
#if (TFT_CFG == TFT_49_AUO_A025DL01) || \
(TFT_CFG == TFT_58_TOPPOLY_TD025THEB2)
#include "spi.h"
#endif
#if (PROJECT == DMO04012501)
#include "tuner.h"
#endif
/* ------------------------------------
Macro Definitions
------------------------------------ */
/* ------------------------------------
Type Definitions
------------------------------------ */
/* ------------------------------------
Variables Definitions
------------------------------------ */
/* ------------------------------------
Function Prototypes
------------------------------------ */
/* -------------------------------------------------------------------
Name: POR_Init -
Purpose: To initialize system power-on reset module.
Passed: None.
Returns: None.
Notes:
------------------------------------------------------------------- */
void POR_Init (void)
{
/* Initiate MCU */
MCU_Init();
/* Initiate TIMER */
TIMER_Init();
/* Initiate KEY */
KEY_Init();
/* Initiate I2C */
I2C_Init();
/* Initiate BITEK */
BITEK_Init();
#if (MENU_STYLE_CFG == MENU_STYLE_SCROLLING_6)
AUDIO_Init();
#endif
/* Initiate DISPATCH */
DISPATCH_Init();
/* Initiate LED */
LED_Init();
/* Initiate EEPROM */
EEPROM_Init();
#if (TFT_CFG == TFT_49_AUO_A025DL01) || \
(TFT_CFG == TFT_58_TOPPOLY_TD025THEB2)
SPI_Init();
#endif
/* [4]87 Enable all interrupts */
EA = 1;
/* ::::::::::::::::::::::::::::::::::::
To recall all data structures (EGD and EYD) from EEPROM !
:::::::::::::::::::::::::::::::::::: */
#if (PLATFORM_CFG == PLATFORM_04_DMO1611S0)
// (04)PLATFORM_04_DMO1611S0 (VID502-002-031,BIT1611BS0)
// To turn on DC POWER for EEPROM !
MCU_DC_ON;
// To ensure DC POWER is stable !
TIMER_DelayMS(100);
#endif
// To read EGD !
EEPROM_RxBurst(EGD_ADDR, sizeof(tEGD), (UB8 *)&tsEGD);
// To read EYD !
EEPROM_RxBurst(EYD_ADDR, sizeof(tEYD), (UB8 *)&tsEYD);
// To initiate EEPROM with default-values
// when
// (1) PROJECT CODE doesn't match !
// (2) Both UP and DOWN keys are pressed
if ((tsEGD.ulProjectCode != CODE_PROJECT) ||
(KEY_BufferOut() == KEY_UP_DOWN) )
{
// To initiate EEPROM with default values
EEPROM_Default();
// To read EGD !
EEPROM_RxBurst(EGD_ADDR, sizeof(tEGD), (UB8 *)&tsEGD);
// To read EYD !
EEPROM_RxBurst(EYD_ADDR, sizeof(tEYD), (UB8 *)&tsEYD);
#ifdef NOT_JUNK
tsEGD = tsEGD_Default;
tsEYD = tsEYD_Default;
#endif
LED_YELLOW_BLINK_ON;
}
#if (PLATFORM_CFG == PLATFORM_04_DMO1611S0)
// (04)PLATFORM_04_DMO1611S0 (VID502-002-031,BIT1611BS0)
// To turn off DC POWER for EEPROM !
MCU_DC_OFF;
#endif
#if (IR_HW_CFG == IR_HW_BIT1611B)
// To reset VP
VP_HardwareReset();
// To reset VD
YUV_HardwareReset();
/* Initiate VP */
VP_Init();
/* Initiate YUV */
YUV_Init();
/* Initiate IR */
IR_Init();
YUV_SetSourceMode(tsEYD.bYUV_ID);
#elif (IR_HW_CFG == IR_HW_NONE)
// Nothing !
#else
IR_Init();
#endif // IR_CFG
} /* POR_Init */
/* -------------------------------------------------------------------
Name: POR_PowerOn -
Purpose:
To turn on DC power and backlight module.
Passed: None.
Returns: None.
Notes:
1. Turn on DC.
1. Turn on Backlight.
2. Initiate VP.
------------------------------------------------------------------- */
void POR_PowerOn (void)
{
// To turn on POWER !
MCU_DC_ON;
// To turn off Backlight
MCU_BL_OFF;
// To turn off PANEL POWER
MCU_PANEL_OFF;
// LED GREEN ON !
LED_GREEN_BLINK_OFF;
LED_GREEN_ON;
#if (IR_HW_CFG == IR_HW_BIT1611B)
// Nothing !
/* Initiate VP */
VP_Init();
/* Initiate YUV */
YUV_Init();
/* Initiate IR */
IR_Init();
YUV_SetSourceMode(tsEYD.bYUV_ID);
#else
// To reset VP
VP_HardwareReset();
// To reset VD
YUV_HardwareReset();
/* Initiate VP */
VP_Init();
/* Initiate YUV */
YUV_Init();
YUV_SetSourceMode(tsEYD.bYUV_ID);
#endif
#if (TFT_CFG == TFT_49_AUO_A025DL01) || \
(TFT_CFG == TFT_58_TOPPOLY_TD025THEB2)
SPI_PowerOn();
#endif
/* Initiate OSD */
OSD_Init();
// To setup User Font !
FONT_Init();
/* Initiate MENU */
MENU_Init();
#if (PROJECT == DMO04012501)
TUNER_Init();
#endif
// To show Video Source Name !
OSD_ShowMsg(OSD_MESSAGE,
OSD_X_SOURCE,
OSD_Y_SOURCE,
apbYUV_Source[ tsEYD.bYUV_ID ]);
OSD_EnableWindow(OSD_MESSAGE, ON);
// To turn on PANEL POWER !
MCU_PANEL_ON;
// Backligh should be turned on after PWM signal is applied.
MCU_BL_ON;
// To flush KEY buffer !
KEY_BufferFlush();
// To avoid bouncing Power On/Off !
fKeyReleased = FALSE;
// To change system state !
bSystemState = SYSTEM_POWER_ON;
#if (MENU_STYLE_CFG == MENU_STYLE_SCROLLING_6)
AUDIO_FadeInVolume(tsEGD.wVolume);
#endif
} /* POR_PowerOn */
/* -------------------------------------------------------------------
Name: POR_PowerOff -
Purpose:
To turn off DC and backlight modules.
Passed: None.
Returns: None.
Notes:
1. To power off LCD panel.
------------------------------------------------------------------- */
void POR_PowerOff (void)
{
// Backlight should be turned off before DC power is turned off.
MCU_BL_OFF;
// To turn off PANEL POWER !
MCU_PANEL_OFF;
#if (MENU_STYLE_CFG == MENU_STYLE_SCROLLING_6)
AUDIO_FadeOutVolume(tsEGD.wVolume);
#endif
// LED !
LED_RED_BLINK_OFF;
LED_RED_OFF;
LED_GREEN_BLINK_ON;
#if (TFT_CFG == TFT_49_AUO_A025DL01) || \
(TFT_CFG == TFT_58_TOPPOLY_TD025THEB2)
SPI_PowerOff();
#endif
TIMER_DelayMS(60);
// To flush KEY buffer !
KEY_BufferFlush();
// To avoid bouncing Power On/Off !
fKeyReleased = FALSE;
// To change system state !
bSystemState = SYSTEM_POWER_OFF;
// To turn off DC POWER !
MCU_DC_OFF;
} /* POR_PowerOff */
/* -------------------------------------------------------------------
Name: -
Purpose: .
Passed: None.
Returns: None.
Notes:
------------------------------------------------------------------- */
/* **********************************************************************
Description:
********************************************************************** */
/* %% End Of File %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -