📄 global.c
字号:
/******************************************************************************
Copyright (c) 2003 MStar Semiconductor, Inc.
All rights reserved.
[Module Name]: Global.c
[Date]: 27-Nov-2003
[Comment]:
Global subroutines.
[Reversion History]:
*******************************************************************************/
#define _GLOBAL_C_
// System
// Common
#include "define.h"
#include "mcu.h"
#include "common.h"
// External
#include "debug.h"
#include "uart.h"
#include "userpref.h"
#include "irfunc.h"
#include "board.h"
#include "ram.h"
#include "ir.h"
// internal
#include "global.h"
#if 1 //(!VERSION_DEBUG)
code BYTE tDummydata_Global[] =
{
0x00,
};
#endif
////////////////////////////////
// Initialize uart
////////////////////////////////
void uartInitialize(void)
{
SCON = 0x50; // mode 1, 8-bit UART, enable receive
if (_SMOD)
PCON |= 0x80;
TMOD = (TMOD & 0x0f) | 0x20; // timer1, mode 2, 8-bit reload
TH1 = TIMER1_MODE2_TH1; // set timer1(buad rate)
TR1 = 1; // timer1 run
TI = 0; // clear transfer flag
PS = 0; // set uart priority low
//ES = 1; // enable uart interrupt
ES = 1; // enable uart interrupt
// reset Uart variables
g_UartCommand.Index = 0;
g_bDebugASCIICommandFlag = _DISABLE;
g_bDebugProgStopFlag = FALSE;
}
///////////////////////////////////////////////////////////////////////////////
// <Function>: isrInitializeInterrupt
//
// <Description>: Initialize MCU interrupt
////////////////////////////////////////////////////////////////////////////////
void isrInitializeInterrupt(void)
{
// INT0 setting
IT0 = 1; // set INT0 type(falling edge)
PX0 = 0; // set INT0 priority high
EX0 = 1; // enable INT0 interrupt
// INT1 setting
#ifndef MCU_MTV_412M
#ifdef ISR_INTERRUPT1
IT1 = 1; // set INT1 type(falling edge)
PX1 = 1; // set INT1 priority high
EX1 = 1; // enable INT1 interrupt
#endif
#else
IT1 = 0; // set INT1 type(falling edge)
PX1 = 0; // set INT1 priority high
EX1 = 0; // enable INT1 interrupt
#endif
// TIMER0 setting
TMOD = (TMOD & 0xf0) | 0x01; // set TIMER0 mode 1
PT0 = 1; // set TIMER0 priority low
TR0 = 1; // TIMER0 enable
ET0 = 1; // enable TIMER0 interrupt
}
///////////////////////////////////////////////////////////////////////////////
// <Function>: InitVariable
//
// <Description>: Initialize global variable.
///////////////////////////////////////////////////////////////////////////////
void InitVariable(void)
{
g_wMilliSecond = SECOND_TICK;
// Ir control menu
g_ucIrNumKeyTimer = 0;
ucUartCheckTick = 0;
g_bEEpromInit = 0; //EEprom need init 0-No need ,1-need
g_ucEEpromAddress_x100 = 0;
g_ucEEpromAddress_x10 = 0;
g_ucEEpromAddress_x1 = 0;
g_ucEEpromData = rmReadByte(G_WEEPROMADDRESS);
g_bEEpromSave = 0;
g_bEEpromSaveDone = 0;
g_ucIrOkCounter = 0;
// 20060513
s_I2CSel = MCU_RAM;
g_uwEEStartADDR = 1;
g_uwEEDataTotal = 1;
g_ucMcuEEPType = RM_TYPE_24C16;
g_ucTvEEPType = RM_TYPE_24C16;
}
///////////////////////////////////////
void SecondTick(void)
{
if (g_bSecondTickFlag)
{
g_bSecondTickFlag = 0;
if (ucUartCheckTick)
if ((--ucUartCheckTick) == 0)
g_UartCommand.Index = 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -