📄 xgisrs.cxgate
字号:
uchar Dummy; /* used to read the SPI status register */
/* Begin Function XSPI1ISR() */
Dummy = RegBase->SPI1.SR; /* read the SPI status register */
RegBase->SPI1.DR = VFData->ScreenBuffP[VFData->BuffIndex]; /* send a byte to the display */
VFData->BuffIndex = (VFData->BuffIndex + 1) & 0x3ff; /* point to the next byte to send */
if (--VFData->ColumnByteCount == 0) /* finished with a columns worth of data? */
RegBase->SPI1.CR1 &= ~0x20; /* yes. disable SPI transmitter interrupts */
} /* end XSPI1ISR */
/*************************************************************************************/
ISR void XSPI2ISR(VFDDataType *VFData)
{
/* Variable Declarations */
uchar Dummy; /* used to read the SPI status register */
/* Begin Function XSPI2ISR() */
Dummy = RegBase->SPI2.SR; /* read the SPI status register */
RegBase->SPI2.DR = VFData->GridDataP[VFData->GridIndex]; /* send a byte to the display */
VFData->GridIndex = (VFData->GridIndex - 1) & 0x07;
if (--VFData->GridByteCount == 0) /* finished with the grid data? */
{ /* yes. rotate the 64-bit grid data to the right 1 bit */
/* assembly language routine to rotate the 64 bit data in the GridData array */
#asm
#ifdef __MWERKS__
ldl r4,%XGATE_8(GridData) ; address of GridData in r
ldh r4,%XGATE_8_H(GridData)
#else
xdef _GridData
ldw r4,#GridData ; address of GridData in r
#endif
sub r6,r6,r6 ; clear r6
ldw r5,(r4,r6) ; load first word from the array.
lsr r5,#1 ; shift to the right 1 bit.
stw r5,(r4,r6+) ; save result bump index.
ldw r5,(r4,r6) ; load second word from the array
csr r5,#1 ; rotate to the right 1 bit through carry.
stw r5,(r4,r6+) ; save result bump index.
ldw r5,(r4,r6) ; load third word from the array
csr r5,#1 ; rotate to the right 1 bit through carry.
stw r5,(r4,r6+) ; save result bump index.
ldw r5,(r4,r6) ; load fourth word from the array
csr r5,#1 ; rotate to the right 1 bit through carry.
stw r5,(r4,r6+) ; save result bump index.
bcc CarryClr ; if carry clear, a 1 did not shift out of the ls bit.
ldw r5,(r4,#0) ; load first word from the array.
addh r5,#$80 ; a 1 shifted out of the ls bit, place it in in the ms bit.
stw r5,(r4,#0) ; save the result.
CarryClr:
#endasm
//#endif
RegBase->SPI2.CR1 &= ~0x20; /* yes. disable SPI transmitter interrupts */
}
} /* end XSPI2ISR */
/*************************************************************************************/
ISR void XCAN1RxISR(void *dummy)
{
/* Variable Declarations */
uint RxID;
/* Begin Function XCAN1RxISR() */
RxID = *(uint *)&RegBase->CAN1.RxFG[0];
#asm
#ifdef __MWERKS__
ldl r1,%XGATE_8(MsgIDFilterTbl) ; address of GridData in r
ldh r1,%XGATE_8_H(MsgIDFilterTbl)
mov r2,r6 ; get the message ID
ldl r3,#0x25 ; we're going to extract the lower 3 bits of the message ID beginning at bit 5 into r4.
bfext r4,r2,r3 ;
lsr r2,#8 ; place the upper 8 bits of the message ID into the lower byte of r2.
ldb r3,(r1,r2) ; get the byte from the table.
ldl r2,#0x80 ; load bit mask into r2.
lsr r2,r4 ; shift bit mask by lower 3 bits of the message ID.
and r0,r2,r3 ; and bit mask with byte from table.
bne Accept ; if bit in table was set, accept message.
ldl r1,#0x84 ; load the address of the Receive flag register.
ldh r1,#0x1
ldl r2,#0x01 ; RXF bit mask.
stb r2,(r1,#0) ; clear the RXF bit to release the buffer.
rts ; reject message.
#else
ldw r1,#MsgIDFilterTbl ; load the address of the message ID filter array.
ldw r2,(r7,#0) ; get the message ID
ldb r3,#0x25 ; we're going to extract the lower 3 bits of the message ID beginning at bit 5 into r4.
bfext r4,r2,r3 ;
lsr r2,#8 ; place the upper 8 bits of the message ID into the lower byte of r2.
ldb r3,(r1,r2) ; get the byte from the table.
ldb r2,#0x80 ; load bit mask into r2.
lsr r2,r4 ; shift bit mask by lower 3 bits of the message ID.
and r0,r2,r3 ; and bit mask with byte from table.
bne Accept ; if bit in table was set, accept message.
ldw r1,#0x184 ; load the address of the Receive flag register.
ldb r2,#0x01 ; RXF bit mask.
stb r2,(r1) ; clear the RXF bit to release the buffer.
rts ; reject message.
#endif
Accept:
#endasm
CANMsgID = RxID;
CANDataLen = RegBase->CAN1.RxFG[0x0c];
*(uint *)(CANMsgData + 0) = *(uint *)(&RegBase->CAN1.RxFG[0x04] + 0);
*(uint *)(CANMsgData + 2) = *(uint *)(&RegBase->CAN1.RxFG[0x04] + 2);
*(uint *)(CANMsgData + 4) = *(uint *)(&RegBase->CAN1.RxFG[0x04] + 4);
*(uint *)(CANMsgData + 6) = *(uint *)(&RegBase->CAN1.RxFG[0x04] + 6);
RegBase->CAN1.RFLG = RXF;
RegBase->XGSWT = 0x0101; /* initiate XGate software trigger 0 */
} /* end XCAN1RxISR */
/*************************************************************************************/
ISR void XGSwTrig0ISR(void *dummy)
{
/* Variable Declarations */
/* Begin Function XGSwTrig0ISR() */
RegBase->XGSWT = 0x0100; /* clear XGate software trigger 0 */
if (RegBase->CAN2.TFLG != 0) /* transmit buffer available? */
{
CANMsgData[0]++;
RegBase->CAN2.TBSEL = RegBase->CAN2.TFLG;
*(uint *)(&RegBase->CAN2.TxFG[0]) = CANMsgID;
*(uint *)(&RegBase->CAN2.TxFG[0x04] + 0) = *(uint *)(CANMsgData + 0);
*(uint *)(&RegBase->CAN2.TxFG[0x04] + 2) = *(uint *)(CANMsgData + 2);
*(uint *)(&RegBase->CAN2.TxFG[0x04] + 4) = *(uint *)(CANMsgData + 4);
*(uint *)(&RegBase->CAN2.TxFG[0x04] + 6) = *(uint *)(CANMsgData + 6);
RegBase->CAN2.TxFG[0x0c] = CANDataLen;
RegBase->CAN2.TFLG = RegBase->CAN2.TBSEL;
}
} /* end XGSwTrig0ISR */ /*************************************************************************************/
static uchar XFormADSplit(uchar *AByte, uchar *DByte)
{
/* Variable Declarations */
uchar XFormByte = 0;
int x;
uchar BMask = 0x80;
/* Begin Function XFormADSplit() */
x = 7;
while (x > 0)
{
XFormByte |= (*DByte << x) & BMask;
BMask >>= 2;
DByte -= 16;
x -= 2;
}
BMask = 0x40;
for (x = 1; x <= 7; x += 2)
{
XFormByte |= (*AByte >> x) & BMask;
BMask >>= 2;
AByte -= 16;
}
return(XFormByte);
} /* end XFormADSplit */
/*************************************************************************************/
static uchar XFormBCHigh(uchar *BCByte)
{
/* Variable Declarations */
uchar XFormByte = 0;
int x;
uchar BMask = 0x30;
/* Begin Function XFormBCHigh() */
XFormByte |= (*BCByte << 1) & 0xc0;
BCByte -= 16;
for (x = 1; x <= 5; x += 2)
{
XFormByte |= (*BCByte >> x) & BMask;
BMask >>= 2;
BCByte -= 16;
}
return(XFormByte);
} /* end XFormBCHigh */
/*************************************************************************************/
static uchar XFormADMid(uchar *ADByte)
{
/* Variable Declarations */
uchar XFormByte = 0;
int x;
uchar BMask = 0x0c;
/* Begin Function XFormADMid() */
XFormByte |= (*ADByte << 3) & 0xc0;
ADByte -= 16;
XFormByte |= (*ADByte << 1) & 0x30;
ADByte -= 16;
for (x = 1; x <= 3; x += 2)
{
XFormByte |= (*ADByte >> x) & BMask;
BMask >>= 2;
ADByte -= 16;
}
return(XFormByte);
} /* end XFormADMid */
/*************************************************************************************/
static uchar XFormBCLow(uchar *BCByte)
{
/* Variable Declarations */
uchar XFormByte = 0;
int x;
uchar BMask = 0xc0;
/* Begin Function XFormBCLow() */
x = 5;
while(x > 0)
{
XFormByte |= (*BCByte << x) & BMask;
BMask >>= 2;
BCByte -= 16;
x -= 2;
}
XFormByte |= (*BCByte >> 1) & 0x03;
BCByte -= 16;
return(XFormByte);
} /* end XFormBCLow */
/*************************************************************************************/
ISR void XGSwTrig6ISR(STDataType *STData)
{
/* Variable Declarations */
int x, z;
/* Begin Function XGSwTrig7ISR() */
RegBase->XGSWT = 0x4000; /* reset XGate software trigger 6 */
if (!STData->transfering) return;
if (STData->y == 0) {
STData->y = 0; /* stuff data at the start of display buffer */
x = 1008; /* start at the last row in the graphics buffer */
while (x >= 0)
{
ScreenBuff[STData->y] = XFormADSplit(&GBuffer[x], &GBuffer[x + 15]);
STData->y++;
x -= 64;
}
} else if (STData->y <= 1024 - 64) {
z = (STData->y - 16) / 64;
switch (((STData->y / 16) - 1) & 0x03) {
case 0:
x = 1008 + z;
while (x >= z)
{
ScreenBuff[STData->y] = XFormBCHigh(&GBuffer[x]);
STData->y++;
x -= 64;
}
break;
case 1:
x = 1008 + z;
while (x >= z)
{
ScreenBuff[STData->y] = XFormADMid(&GBuffer[x]);
STData->y++;
x -= 64;
}
break;
case 2:
x = 1008 + z;
while (x >= z)
{
ScreenBuff[STData->y] = XFormBCLow(&GBuffer[x]);
STData->y++;
x -= 64;
}
break;
case 3:
x = 1008 + z;
while (x >= z)
{
ScreenBuff[STData->y] = XFormADSplit(&GBuffer[x + 1], &GBuffer[x]);
STData->y++;
x -= 64;
}
}
} else if (STData->y == 1024 - 48) {
x = 1008 + 15;
while (x >= 15)
{
ScreenBuff[STData->y] = XFormBCHigh(&GBuffer[x]);
STData->y++;
x -= 64;
}
} else if (STData->y == 1024 - 32) {
x = 1008 + 15;
while (x >= 15)
{
ScreenBuff[STData->y] = XFormADMid(&GBuffer[x]);
STData->y++;
x -= 64;
}
} else if (STData->y == 1024 - 16) {
x = 1008 + 15;
while (x >= 15)
{
ScreenBuff[STData->y] = XFormBCLow(&GBuffer[x]);
STData->y++;
x -= 64;
}
STData->transfering = 0;
}
} /* end XGSwTrig1ISR */
/*************************************************************************************/
ISR void XGSwTrig7ISR(void *dummy)
{
/* Variable Declarations */
uint dt;
/* Begin Function XGSwTrig7ISR() */
// RegBase->XGSWT = 0x8000; /* XGate software trigger 7 shall stay pending */
XGIdleCounter++;
newTime = RegBase->TCNT;
dt = newTime - oldTime;
if (dt > maxDt) {
maxDt = dt;
}
oldTime = newTime;
} /* end XGSwTrig0ISR */
/*************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -