?? lpc_vic.c
字號(hào):
// 定義VIC API函數(shù)
#include "LPC_Vic.h"
/******************************************************************************
* 說(shuō)明:VIC_SetProtectionMode函數(shù),根據(jù)參數(shù)決定VIC訪問(wèn)模式(特權(quán)模式或用戶(hù)模式)
* 參數(shù):LPC_Vic_ProtectionMode_t ProtectionType
* 返回值:無(wú)
*****************************************************************************/
void VIC_SetProtectionMode(LPC_Vic_ProtectionMode_t ProtectionType) {
VICProtection_bit.PROTECT = ProtectionType;
return ;
}
/******************************************************************************
* 說(shuō)明:VIC_GetProtectionMode函數(shù),獲得VIC訪問(wèn)模式(特權(quán)模式或用戶(hù)模式)
* 參數(shù):無(wú)
* 返回值:LPC_Vic_ProtectionMode_t
*****************************************************************************/
LPC_Vic_ProtectionMode_t VIC_GetProtectionMode(void) {
LPC_Vic_ProtectionMode_t ProtectionType;
if (VICProtection & 0x1)
ProtectionType = PrivilegedMode;
else
ProtectionType = UserandPrivilegedMode;
return ProtectionType;
}
/*************************************************************************
* 說(shuō)明:VIC_Init函數(shù),初始化 VIC
* 參數(shù):無(wú)
* 返回值:無(wú)
*************************************************************************/
void VIC_Init(void) {
VICIntSelect = 0; // 分配所有中斷通道給VIC
VICIntEnClear = 0xFFFFFFFF; // 禁止所有中斷
VICSoftIntClear = 0xFFFFFFFF; // 清除所有軟件中斷
VICProtection = 0; // 可通過(guò)用戶(hù)或特權(quán)模式訪問(wèn)VIC寄存器
VICVectAddr = 0; // 清除中斷
VICDefVectAddr = 0; // 清0非向量IRQ中斷服務(wù)程序地址
VICVectAddr15 = 0; // 清0向量IRQ中斷服務(wù)程序地址
VICVectCntl15 = 0; // 禁止所有向量IRQ slots
}
/***************************************************************************
* 說(shuō)明:VIC_GetIRQStatus函數(shù),獲得VIC的IRQ狀態(tài)。返回寄存器VICIRQSTATUS的值。
* 如果允許了某個(gè)IRQ中斷請(qǐng)求,則寄存器VICIRQSTATUS的相應(yīng)位置位。
* 參數(shù):無(wú)
* 返回值:unsigned int
*************************************************************************/
unsigned int VIC_GetIRQStatus(void) {
}
/***************************************************************************
* 說(shuō)明:VIC_GetFIQStatus函數(shù),獲得VIC的FIQ狀態(tài)。返回寄存器VICFIQSTATUS的值。
* 如果允許了某個(gè)FIQ中斷請(qǐng)求,則寄存器VICFIQSTATUS的相應(yīng)位置位。如果
* 分配多個(gè)中斷請(qǐng)求給FIQ,則通過(guò)調(diào)用本函數(shù)可以決定中斷源。
* 參數(shù):無(wú)
* 返回值:unsigned int
unsigned int VIC_GetFIQStatus(void) {
return (VICFIQStatus);
}
/*************************************************************************
* 說(shuō)明:VIC_EnableInt函數(shù),允許指定中斷。
* 參數(shù):lpc_uint32 IntType
* 返回值:無(wú)
*************************************************************************/
void VIC_EnableInt(unsigned int IntType) {
VICIntEnable |= IntType;
}
/*************************************************************************
* 說(shuō)明:VIC_DisableInt函數(shù),禁止指定中斷。
* 參數(shù):unsigned int IntType
* 返回值:無(wú)
*************************************************************************/
void VIC_DisableInt(unsigned int IntType) {
VICIntEnClear |= IntType;
}
/***************************************************************************
* 說(shuō)明:VIC_EnableNonVectoredIRQ函數(shù),將VICDefVectAddr設(shè)置為IRQ子程序地址。
* 參數(shù):pIRQSub - 非向量IRQ子程序地址
* 返回值:無(wú)
*************************************************************************/
void VIC_EnableNonVectoredIRQ(void(*pIRQSub)()) {
VICDefVectAddr = (unsigned int)pIRQSub;
}
/*************************************************************************
* 說(shuō)明:VIC_DisableNonVectoredIRQ函數(shù),將VICDefVectAddr設(shè)置為復(fù)位值(NULL)
* 參數(shù):無(wú)
* 返回值:無(wú)
*************************************************************************/
void VIC_DisableNonVectoredIRQ(void) {
VICDefVectAddr = NULL;
}
/*************************************************************************
* 說(shuō)明:VIC_SetVectoredIRQ函數(shù),初始化向量中斷。
* 參數(shù): void(*pIRQSub)()
* LPC_VicIrqSlots_t VicIrqSlot
* unsigned int VicIntSouce
* 返回值:無(wú)
*************************************************************************/
void VIC_SetVectoredIRQ(void(*pIRQSub)(), LPC_VicIrqSlots_t VicIrqSlot, unsigned int VicIntSource) {
unsigned long volatile *pReg;
pReg = &VICVectAddr0; // 加載向量地址寄存器的偏移地址
*(pReg+VicIrqSlot) = (unsigned long)pIRQSub; // 為相應(yīng)Slot設(shè)置回調(diào)函數(shù)地址
pReg = &VICVectCntl0; // 加載控制寄存器基地址
*(pReg+VicIrqSlot) = VicIntSource | 0x20; // 設(shè)置源通道并允許該Slot
VICIntSelect &= ~(1<<VicIntSource); // 清除FIQ選擇位
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -