📄 isr.c
字号:
/******************************************************************************
Copyright (c) 2003 MStar Semiconductor, Inc.
All rights reserved.
[Module Name]: Isr.c
[Date]: 24-Dec-2003
[Comment]:
MCU interrupt service routines.
[Reversion History]:
*******************************************************************************/
#define _ISR_C_
// System
#include "board.h"
#include "bd_mst.h"
// Common
#include "define.h"
#include "mcu.h"
#include "userdef.h"
// External
#include "global.h"
#include "Userpref.h"
#include "keypad.h"
#include "uart.h"
#include "ir.h"
// Internal
#include "isr.h"
//////////////////////////////////////////////////////////////////////////////
// <Function>: isrINT1_S
//
// <Description>: MCU INT1 interrupt servicee routine
///////////////////////////////////////////////////////////////////////////////
void isrInt0_S(void) interrupt 0
{
// stop main loop for debug (Uart Command Test Command 0x51)
if (!g_bDebugProgStopFlag)
{
irInterruptProcess(IR_HEADER_CODE0, IR_HEADER_CODE1);
}
}
//////////////////////////////////////////////////////////////////////////////
// <Function>: isrTimer0_S
//
// <Description>: MCU Timer0 interrupt servicee routine
///////////////////////////////////////////////////////////////////////////////
void isrTimer0_S(void) interrupt 1
{
static BYTE count = 1;
static BYTE KeyCount = 0;
TH0 = HIBYTE(ISR_TIMER0_COUNTER);
TL0 = LOBYTE(ISR_TIMER0_COUNTER);
irDetectTimer0(); //Ir detecting
if (1)
{// Keypad dectecting
if (KeyCount == 1)
{
MADC = 0x82; //Key_AD1
}
else if (KeyCount == 7) //14
{
keyScanStatus(Key_AD1);
MADC = 0x81; //Key_AD0
}
else if (KeyCount == 14) //28
{
keyScanStatus(Key_AD0);
KeyCount = 0;
}
KeyCount++;
}
if (count < 2)
{
count++;
}
else
{// When 1ms reach..
count = 1;
// second counter
if ((--g_wMilliSecond) == 0)
{
g_bSecondTickFlag = 1;
g_wMilliSecond = SECOND_TICK;
}
if ((g_wMilliSecond & 0x0f) == 0)
{
g_b16msTickFlag = 1;
}
if (g_ucKeyReleaseCounter)
g_ucKeyReleaseCounter--;
}
}
///////////////////////////////////////
// Uart Interrupt
///////////////////////////////////////
void uartInterrupt(void) interrupt 4
{
//EA = 0; // disable all interrupt
if (!_testbit_(TI)) // check translate interrupt
{
ucUartCheckTick = 2;
RI = 0; // clear recieve interrupt
g_UartCommand.Buffer[g_UartCommand.Index] = SBUF; // recieve byte
// check command buffer index
if (UART_EXT)
{
if (g_UartCommand.Index == 0) // check 1st data
g_UartCommand.Index++; // for get UART_CMD_EXT_LENGTH
else
{
if (g_UartCommand.Index < UART_CMD_EXT_LENGTH) // still read command
g_UartCommand.Index++; // next index of command buffer
if (g_UartCommand.Index >= UART_CMD_EXT_LENGTH) // read command ok
{
g_bUartDetected = TRUE; // command buffer recieve ok
g_UartCommand.Index = 0; // reset index of command buffer
ucUartCheckTick = 0;
}
}
}
else
{
if (g_UartCommand.Index < UART_CMD_LENGTH) // still read command
g_UartCommand.Index++; // next index of command buffer
if (g_UartCommand.Index >= UART_CMD_LENGTH) // read command ok
{
g_bUartDetected = TRUE; // command buffer recieve ok
g_UartCommand.Index = 0; // reset index of command buffer
ucUartCheckTick = 0;
}
}
} // if TI
//EA = 1; // release EA bit
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -