📄 eventtable.c
字号:
#ifndef _variable_c_
#define _variable_c_
#define TabLength 8
/*
********************************************************************************************************
* prio : unsigned char
* ResRdyGrp : unsigned char
* ResRdyTbl[] : unsigned char
* note:
* Every bit in ResRdyGrp is used to indicate whenever any Response in a group is ready to execute.
* When any response is ready to execute,it sets the corresponding bit in the ResRdyTbl[].
* prio : the prio is the index of the respones event .
*********************************************************************************************************
*/
//unsigned char xdata prio=0;
unsigned char xdata ResRdyGrp=0;
unsigned char xdata ResRdyTbl[TabLength]={0,0,0,0,0,0,0,0};
/*
*********************************************************************************************************
* McpRdyGrp : unsigned char
* McpRdyTbl[] : unsigned char
* note :
* Every bit in McpRdyGrp is used to indicate whenever any MCP event in a group is ready to execute.
When any MCP event is ready to execute,it sets the corresponding bit in the McpRdyTbl[].
When any MCP event has been executed,it clear the corresponding bit in the McpRdyTbl[].
if any MCP event have been executed,it also clear the corresponding bit in the McpRdyGrp.
*********************************************************************************************************
*/
unsigned char xdata McpRdyGrp=0;
unsigned char xdata McpRdyTbl[TabLength]={0,0,0,0,0,0,0,0};
/*
*********************************************************************************************************
* ExtRdyGrp : unsigned char
* ExtRdyTbl[] : unsigend char
* note :
* Every bit in ExtRdyGrp is used to indicate whenever any EXT interrupt event in a group is ready to execute.
When any EXT interrupt event is ready to execute,it sets the corresponding bit in the ExtRdyTbl[].
When any EXT interrupt event has been executed,it clear the correspoinding bit in th ExtRdytbl[].
if any EXT interrupt event have been executed,it also clear the conrresponding bit in the ExtRdyGrp.
* EXT interrupt:
Microchip INT0
Microchip INT1
Microchip Timing
********************************************************************************************************
*/
unsigned char xdata ExtRdyGrp=0;
unsigned char xdata ExtRdyTbl[TabLength]={0,0,0,0,0,0,0,0};
/*
*********************************************************************************************************
* MAPPING TABLE TO MAP BIT POSITION TO BIT MASK
*
* Note: Index into table is desired bit position, 0..7
* Indexed value corresponds to bit mask
*********************************************************************************************************
*/
unsigned char const code OSMapTbl[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
/*
*********************************************************************************************************
* PRIORITY RESOLUTION TABLE
*
* Note: Index into table is bit pattern to resolve highest priority
* Indexed value corresponds to highest priority bit position (i.e. 0..7)
*********************************************************************************************************
*/
unsigned char const code OSUnMapTbl[] = {
0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0
};
/****************************************************/
/* ScanResRdyTbl()
* Description : scan the ResRdyTbl[] and find the response readying to execute.
* Arguments : none
* return : prio is the index should be executed next.
*/
/****************************************************/
unsigned char ScanResRdyTbl() {
unsigned char xdata x = 0;
unsigned char xdata y = 0;
y=OSUnMapTbl[ResRdyGrp];
x=OSUnMapTbl[ResRdyTbl[y]];
return ((y << 3) + x);
}
/***************************************************/
/* SetResRdyTbl()
* Description : set the ResRdyTbl[] bit corresponding to prio,indicate the response event has happened.
* Arguments : prio is the index of the event that just happened.
* return : none
*/
/**************************************************/
void SetResRdyTbl(volatile unsigned char prio) large reentrant {
ResRdyGrp |= OSMapTbl[prio >> 3];
ResRdyTbl[prio >> 3] |= OSMapTbl[prio & 0x7];
}
/**************************************************/
/* ClearResRdyTbl()
* Description : clear the ResRdyTbl[] bit corresponding to prio,indicate the response event has executed.
* Arguments : prio is the index of the event that just executed.
* Return : none
*/
/**************************************************/
void ClearResRdyTbl(volatile unsigned char prio){
if((ResRdyTbl[prio >> 3] &= ~OSMapTbl[prio & 0x7]) == 0)
ResRdyGrp &= ~OSMapTbl[prio >> 3];
}
/**************************************************/
/* GetResRdyTbl()
* Description : get the state of McpResTbl[] bit corresponding to prio
* Arguments : prio is the index of the event that just executed.
* Return : true 1 ,faulse 0
*/
/**************************************************/
unsigned char GetResRdyTbl(volatile unsigned char prio) large reentrant{
unsigned char xdata temp1,temp2;
temp1 = ResRdyGrp & OSMapTbl[prio >> 3];
temp2 = ResRdyTbl[prio >> 3] & OSMapTbl[prio & 0x7];
// if ((ResRdyGrp && OSMapTbl[prio >> 3]) && (ResRdyTbl[prio >> 3] && OSMapTbl[prio & 0x7]))
if (temp1 && temp2)
return 1;
else
return 0;
}
/**************************************************/
/* ScanMcpRdyTbl()
* Description : scan the McpRdyTbl[] and find the MCP event readying to execute.
* Arguments : none
* return : prio is the index should be executed next.
*/
/****************************************************/
unsigned char ScanMcpRdyTbl() {
unsigned char xdata x = 0;
unsigned char xdata y = 0;
y=OSUnMapTbl[McpRdyGrp];
x=OSUnMapTbl[McpRdyTbl[y]];
return ((y << 3) + x);
}
/***************************************************/
/* SetMcpRdyTbl()
* Description : set the McpRdyTbl[] bit corresponding to prio,indicate the MCP event has happened.
* Arguments : prio is the index of the event that just happened.
* return : none
*/
/**************************************************/
void SetMcpRdyTbl(volatile unsigned char prio) {
McpRdyGrp |= OSMapTbl[prio >> 3];
McpRdyTbl[prio >> 3] |= OSMapTbl[prio & 0x7];
}
/**************************************************/
/* ClearMcpRdyTbl()
* Description : clear the McpRdyTbl[] bit corresponding to prio,indicate the MCP event has executed.
* Arguments : prio is the index of the event that just executed.
* Return : none
*/
/**************************************************/
void ClearMcpRdyTbl(volatile unsigned char prio){
if((McpRdyTbl[prio >> 3] &= ~OSMapTbl[prio & 0x7]) == 0)
McpRdyGrp &= ~OSMapTbl[prio >> 3];
}
/**************************************************/
/* GetMcpRdyTbl()
* Description : get the state of McpRdyTbl[] bit corresponding to prio
* Arguments : prio is the index of the event that just executed.
* Return : true 1 ,faulse 0
*/
/**************************************************/
unsigned char GetMcpRdyTbl(volatile unsigned char prio){
unsigned char xdata temp1,temp2;
temp1 = McpRdyGrp & OSMapTbl[prio >> 3];
temp2 = McpRdyTbl[prio >> 3] & OSMapTbl[prio & 0x7];
if (temp1 && temp2)
// if ((McpRdyGrp && OSMapTbl[prio >> 3]) && (McpRdyTbl[prio >> 3] && OSMapTbl[prio & 0x7]))
return 1;
else
return 0;
}
/****************************************************/
/* ScanExtRdyTbl()
* Description : scan the ExtRdyTbl[] and find the Interrupt event readying to execute.
* Arguments : none
* return : prio is the index should be executed next.
*/
/****************************************************/
unsigned char ScanExtRdyTbl() {
unsigned char xdata x = 0;
unsigned char xdata y = 0;
y=OSUnMapTbl[ExtRdyGrp];
x=OSUnMapTbl[ExtRdyTbl[y]];
return ((y << 3) + x);
}
/***************************************************/
/* SetExtRdyTbl()
* Description : set the ExtRdyTbl[] bit corresponding to prio,indicate the INT event has happened.
* Arguments : prio is the index of the event that just happened.
* return : none
*/
/**************************************************/
void SetExtRdyTbl(volatile unsigned char prio) large reentrant {
ExtRdyGrp |= OSMapTbl[prio >> 3];
ExtRdyTbl[prio >> 3] |= OSMapTbl[prio & 0x7];
}
/**************************************************/
/* ClearExtRdyTbl()
* Description : clear the ExtRdyTbl[] bit corresponding to prio,indicate the INT event has executed.
* Arguments : prio is the index of the event that just executed.
* Return : none
*/
/**************************************************/
void ClearExtRdyTbl(volatile unsigned char prio){
if((ExtRdyTbl[prio >> 3] &= ~OSMapTbl[prio & 0x7]) == 0)
ExtRdyGrp &= ~OSMapTbl[prio >> 3];
}
/**************************************************/
/* GetExtRdyTbl()
* Description : get the state of McpExtTbl[] bit corresponding to prio
* Arguments : prio is the index of the event that just executed.
* Return : true 1 ,faulse 0
*/
/**************************************************
unsigned char GetExtRdyTbl(volatile unsigned char prio){
unsigned char xdata temp1,temp2;
temp1 = ExtRdyGrp & OSMapTbl[prio >> 3];
temp2 = ExtRdyTbl[prio >> 3] & OSMapTbl[prio & 0x7];
if (temp1 && temp2)
// if ((ExtRdyGrp && OSMapTbl[prio >> 3]) && (ExtRdyTbl[prio >> 3] && OSMapTbl[prio & 0x7]))
return 1;
else
return 0;
}
*/
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -