/*
* FreeModbus Libary: LPC214X Port
* Copyright (C) 2007 Tiago Prado Lone
* This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. *
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
* File: $Id: port.c,v 1.1 2007/04/24 23:15:18 wolti Exp $ */
/* ----------------------- System includes --------------------------------*/ #include
/* ----------------------- Modbus includes ----------------------------------*/
/* ----------------------- Variables ----------------------------------------*/ int VIC_Temp;
/* ----------------------- Start implementation -----------------------------*/
//本文件共两个函数,EnterCriticalSection( )和 ExitCriticalSection( ), //使用的时候必定一起先后使用、
//当进入串口中断的时候,将 VICIntEnable写入VICIntEnClr,可以关闭所有中断位置, //从而避免其他中断将串口的现成挂起
//当函数执行完成时,将 VIC_Temp写入 VICIntEnable,恢复中断位置的状态 //注意,中断位置的清除并不是串口中断的清除,中断位置只是绑定了串口中断 void
EnterCriticalSection( ) {
VIC_Temp = VICIntEnable; /* Save VICIntEnable */ // VICIntEnable, 中断使能寄存器,保存目前的值 // 共16个中断位置,bit为1时候使能
VICIntEnClr = VIC_Temp; /* Disable Interruptions */ // VICIntEnClr,中断清除寄存器 //控制16个中断位置复位,bit写入1复位
//将本身的值写入清除寄存器,就将所有的中断位置清除 } void
ExitCriticalSection( ) {
VICIntEnable = VIC_Temp; /* Restore VICIntEnable */ }
//再次恢复15个中断位置的配置
//当函数执行完成时,将 VIC_Temp写入VICIntEnable, //恢复中断位置的状态