📄 test.cpp
字号:
{
if ( y1 < y2 )
{
for ( i = y1; i <= y2 ; i++ )
PutPixel( x1, i, color );
}
else
{
for ( i = y2; i <= y1 ; i++ )
PutPixel( x1, i, color );
}
return;
}
if( y1 == y2 )
{
if ( x1 < x2 )
{
for ( i = x1; i <= x2 ; i++ )
PutPixel( i, y1, color );
}
else
{
for ( i = x2; i <= x1 ; i++ )
PutPixel( i, y1, color );
}
return;
}
if ( y1 < y2 )
{
ylen = y2 - y1;
ty = 1;
}
else
{
ylen = y1 - y2;
ty = -1;
}
if ( x1 < x2 )
{
xlen = x2 - x1;
tx = 1;
}
else
{
xlen = x1 - x2;
tx = -1;
}
if ( ylen <= xlen )
{
e = -xlen;
for ( i = 0; i <= xlen; i ++ )
{
PutPixel( x1, y1, color );
x1 += tx;
e += (ylen << 1);
if ( e > 0 )
{
y1 += ty;
e -= (xlen << 1);
}
}
}
else
{
e = -ylen;
for ( i = 0; i <= ylen; i ++ )
{
PutPixel( x1, y1, color );
y1 += ty;
e += (xlen << 1);
if ( e > 0 )
{
x1 += tx;
e -= (ylen << 1);
}
}
}
}
VOID FillRect( INT16 x1, INT16 y1, INT16 x2, INT16 y2, CHAR color )
{
INT16 startx, starty, endx, endy, i, j, tmpx;
UINT16 *vtmptr, *tmptr, icolor;
icolor = color;
icolor += ( icolor << 4 ) + ( icolor << 8 ) + ( icolor << 12 );
if ( x2 > x1 )
{
startx = x1;
endx = x2;
}
else
{
startx = x2;
endx = x1;
}
if ( y2 > y1 )
{
starty = y1;
endy = y2;
}
else
{
starty = y2;
endy = y1;
}
//将起点设为4的倍数
tmpx = startx % 4;
if ( tmpx != 0 )
{
while ( tmpx < 4 )
{
tmpx ++;
Line( startx + 4 - tmpx, starty, startx + 4 - tmpx, endy, color );
}
startx += 4 - ( startx % 4 );
}
//将终点设为除4余3的数
tmpx = endx % 4;
if ( tmpx != 3 )
{
while ( tmpx >= 0 )
{
Line( endx - tmpx, starty, endx - tmpx, endy, color );
tmpx --;
}
endx -= ( endx % 4 ) + 1;
}
tmptr = ( UINT16 * )( &gCharScreenRamBuf[0] + starty * SCN_WIDTH / 2 + startx / 2 );
vtmptr = ( UINT16 * )( ( UCHAR * )VPORT + starty * SCN_WIDTH / 2 + startx / 2 );
for ( i = 0; i <= endy - starty; i ++ )
{
for ( j = 0; j < ( endx + 1 - startx ) / 4; j ++ )
{
*tmptr = icolor;
*vtmptr = icolor;
tmptr ++;
vtmptr ++;
}
tmptr += SCN_WIDTH / 4 - ( endx + 1 - startx ) / 4;
vtmptr += SCN_WIDTH / 4 - ( endx + 1 - startx ) / 4;
}
}
VOID ClearWaveScreen( INT x1, INT y1, INT x2, INT y2, CHAR color )
{
INT16 startx, starty, endx, endy, i, j, xlengh;
UINT16 *vtmptr, icolor;
icolor = color;
icolor += ( icolor << 4 ) + ( icolor << 8 ) + ( icolor << 12 );
if ( x2 > x1 )
{
startx = x1;
endx = x2;
}
else
{
startx = x2;
endx = x1;
}
if ( y2 > y1 )
{
starty = y1;
endy = y2;
}
else
{
starty = y2;
endy = y1;
}
vtmptr = ( UINT16 * )( ( UCHAR * )WPORT + starty * PHYWAVESCNWIDTH / 2 + startx / 2 );
xlengh = ( endx + 1 - startx ) / 4;
for ( i = 0; i <= endy - starty; i ++ )
{
for ( j = 0; j < xlengh; j ++ )
{
*vtmptr = icolor;
vtmptr ++;
}
vtmptr += PHYWAVESCNWIDTH / 2 - xlengh;
}
}
void Test_Display( void )
{
SHORT i, j, k, color;
char *start_point_des,*start_point_source;
unsigned int *Wsa;
clrvram();
//test text screen
TextOut( 200, 200, WHITE, BLACK, "Test Text Screen");
Delay(10);
for ( color = 0; color < 16; color++ )
{
FillRect( 0, 0, 799, 599, color );
Delay( 10 );
FillRect( 0, 0, 799, 599, BLACK );
}
//test WAVE screen
TextOut( 200, 200, 3, BLACK, "Test Wave Screen");
Delay( 10 );
TextOut( 200, 200, 3, BLACK, " ");
for ( color = 0; color < 8; color++ )
{
ClearWaveScreen( 0, 0, 639, 599, color );
Delay( 10 );
ClearWaveScreen( 0, 0, 639, 599, BLACK );
}
}
//delay_time * 10 ms
void Delay( SHORT delay_time )
{
unsigned long i;
//delay 10 ms
while( delay_time > 0 )
{
for ( i = 0; i < 0x1a000; i ++ )
;
delay_time--;
}
}
void TestBuzzer(SHORT beep_time)
{
/*
asm(" PARALLEL_PORT = ($60000000 + $1c9)");
// buzzer 150 ms
asm(" MOVE.B #$FD, D2");
asm(" MOVE.B D2, (PARALLEL_PORT).L");
Delay( beep_time );
// sound off
asm(" MOVE.B #$FF, D2");
asm(" MOVE.B D2, (PARALLEL_PORT).L");
*/
UCHAR *iop;
iop = (UCHAR*)UOP3;
*iop = 0x1; // send a low level to pin /AC
Delay( beep_time );
iop = (UCHAR*)UOP2;
*iop = 0x1; // send a low level to pin /AC
}
//----------------------------CPU UART INITIALIZE------------------
UNCHAR FPGAINTTYPE, FPGATYPE;
void Serial_io_Initialize( )
{
// ============== initialize the UART1, -> RECORDER ============================
*((UNCHAR *) UCR1) = 0x10; // 00010001 reset mode regester pointer
*((UNCHAR *) UCR1) = 0x20; // 00100000 reset receiver
*((UNCHAR *) UCR1) = 0x30; // 00110000 reset transmitter
*((UNCHAR *) UCR1) = 0x40; // 01000000 reset error state
*((UNCHAR *) UCR1) = 0x50; // 01010000 reset break change interrupt
// *((UNCHAR *) UIMR1) = 0x03; // interrupt mask register.
*((UNCHAR *) UIMR1) = 0x03; // interrupt mask register.
*((UNCHAR *) UCSR1) = 0xdd; // set the clock source to 32M timer
*((UNCHAR *) UBG11) = 0; // set timer to 20.3, so the baud rate is 38400
*((UNCHAR *) UBG21) = 52; // 32MHz, the baud rate is 38400, prescalar=32:
// k = 32000000/(38400*32) = 20.3;
*((UNCHAR *) UMR11) = 0x13; // 0001 0011 13:no parity 03:even parity
// *((UNCHAR *) UMR21) = 0x07; // 00100111 normal
//set UART in local loop back mode
*((UNCHAR *) UMR21) = 0x87; // 1000111 loop back mode
*((UNCHAR *) UIVR1) = 65; // interrupt vector register
//*((UNCHAR *) ICR_UART1) = 0x90; // set UART1 interrupt to auto level 4 .
*((UNCHAR *) ICR_UART1) = 0x10; // set UART1 interrupt verctor to 65.
*((UNCHAR *) UCR1) = 0x06; // 00000001 enable receiver
// ============== initialize the UART2, -> KEYBOARD ============================
*((UNCHAR *) UCR2) = 0x10; // 00010001 reset mode regester pointer
*((UNCHAR *) UCR2) = 0x20; // 00100000 reset receiver
*((UNCHAR *) UCR2) = 0x30; // 00110000 reset transmitter
*((UNCHAR *) UCR2) = 0x40; // 01000000 reset error state
*((UNCHAR *) UCR2) = 0x50; // 01010000 reset break change interrupt
// *((UNCHAR *) UIMR2) = 0x03;
*((UNCHAR *) UIMR2) = 0x03;
*((UNCHAR *) UCSR2) = 0xdd; // set the clock source to 25M timer
*((UNCHAR *) UBG12) = 0; // set timer to 81, so the baud rate is 9600
*((UNCHAR *) UBG22) = 104; // 32MHz, the baud rate is 9600, prescalar=32:
// k = 32000000/(9600*32) = 104;
// UMR11 and UMR12 share the same address, they must be written sequentially
*((UNCHAR *) UMR12) = 0x03; // 00000011 even parity
// *((UNCHAR *) UMR22) = 0x07; // 00100111 normal
//set UART in local loop back mode
*((UNCHAR *) UMR22) = 0x87; // 00100111 normal
*((UNCHAR *) UIVR2) = 64; // interrupt vector register
// *((UNCHAR *) ICR_UART2) = 0x84; // set UART2 interrupt to auto level 1
*((UNCHAR *) ICR_UART2) = 0x04; // set UART2 interrupt to level 1
*((UNCHAR *) UCR2) = 0x06; // 00000001 enable receiver
/*
// ========== initialize the FPGA2, -> NIBP ====================================
//NIBPINTTYPE = 0x4d;
FPGAINTTYPE = 0xd0;
*((UNCHAR *)FPGAUART3A_CMD) = FPGAINTTYPE;
// ========== initialize the FPGA4, -> IBP/CO ==================================
//RECINTTYPE = 0x41;
FPGAINTTYPE = 0xd0;
*((UNCHAR *)FPGAUART2A_CMD) = FPGAINTTYPE;
//ALARMINTTYPE = 0x4d;
FPGAINTTYPE = 0xd0;
*((UNCHAR *)FPGAUART2B_CMD) = FPGAINTTYPE;
// ========== initialize the FPGA4, -> CO2 =====================================
//CO2INTTYPE = 0x41;
FPGAINTTYPE = 0xd0;
*((UNCHAR *)FPGAUART4A_CMD) = FPGAINTTYPE;
//IBPINTTYPE = 0x4d;
FPGAINTTYPE = 0xd0;
*((UNCHAR *)FPGAUART4B_CMD) = FPGAINTTYPE;
*/
//==============================================================================
// 15:- 14:- 13:UART2 12:UART1 || 11:MBUS 10:TIMER2 9:TIMER1 8:SWT
// 7 :EINT7 6:EINT6 5:EINT5 4:EINT4 || 3:EINT3: 2:EINT2 1:EINT1 0:-
// EINT6 : function and spo2 ( level 6 )
// EINT5 : display ( level 5 )
// EINT4 : Net ( level 4 )
// EINT3 : Nibp and record ( level 3 )
// EINT1 : 12887 Timer ( level 1 )
// TIMER1: Tick ( level 2 )
// UART2 : keyboard ( level 1 )
// *( (UNSHORT *) ( IMR_ADDR )) = 0xc183;
*( (UNSHORT *) ( IMR_ADDR )) = 0xffff;
}
/**************************************************************************/
void inics5()
{
asm(" MOVEA.L _Mbar,A0");
asm(" LEA.L $AA(A0),A0"); //point to CSCR5
asm(" MOVE.W #$01C3,(A0)"); //set AA bit to 1
}
/**************************************************************************/
void chacs5()
{
asm(" MOVEA.L _Mbar,A0");
asm(" LEA.L $AA(A0),A0"); //point to CSCR5
asm(" MOVE.W #$00C2,(A0)"); //reset AA bit to 0
}
/**************************************************************************/
void iniint()
{
asm(" MOVEA.L _Mbar,A0");
asm(" LEA.L $37(A0),A0"); //point to IMR
asm(" BCLR.B #3,(A0)"); //enable level 5 interrupt
asm(" BSET.B #5,(A0)"); //disable level 5 interrupt
asm(" MOVE #$3200,SR"); //mask level 2 & lower intterrupt
}
/**************************************************************************/
void InitTimerInt()
{
asm(" MOVE.W #$2700,SR"); // Lockout interrupts
asm(" MOVE.L #$84,D0"); // Pick up configuration value for ICR9
// Set up Timer 1 for a 10ms periodic tick that generates a Level 6
// autovector.
asm(" MOVE.B D0,($60000000+$1c)"); // Setup Timer 1 interrupt for lev 2, pri 0
asm(" MOVE.L #$30d4,D0"); // Pick up compare value
asm(" MOVE.W D0,($60000000+$104)"); // Load into TRR1, val = (25MHz / 16) / 100
asm(" MOVE.L #$1d,D0"); // Pick up configuration value for TMR1
asm(" MOVE.W D0,($60000000+$100)"); // Setup Timer 1
//Timer2 initialization
asm(" MOVE.L #$98,D0"); //; Pick up configuration value for ICR10
asm(" MOVE.B D0,($60000000+$1d)"); //; Setup Timer 2 interrupt for lev 3, pri 0
asm(" MOVE.L #$30d4,D0"); //; Pick up compare value
asm(" MOVE.W D0,($60000000+$124)"); //; Load into TRR2, val = (25MHz / 16) / 125
asm(" MOVE.L #$7c1d,D0"); //; Pick up configuration value for TMR2
asm(" MOVE.W D0,($60000000+$120)"); // Setup Timer 2
asm(" MOVE.W ($60000000+$36),D0"); // Get current interrupt lockout status
asm(" ANDI.L #$fdff,D0 "); // Set Timer 1 bit
asm(" MOVE.W D0,(_Mbar+$36)"); // Enable Timer 1 interrupt
}
void Time1Interupt()
{
asm(" MOVE.W #$2700,SR"); // Lockout interrupts
asm(" LEA.L -56(A7),A7");
asm(" MOVEM.L D0-D7/A0-A5,(A7)");
asm(" MOVE.L #$ff,D0"); // Pick up configuration value for TMR1
asm(" MOVE.B D0,($60000000+$111)"); // ReSet Timer 1
//Time interrupt routine
Timer1Cnt ++;
asm(" MOVEM.L (A7),D0-D7/A0-A5");
asm(" LEA.L 56(A7),A7");
asm(" RTE ");
}
void Time2Interupt()
{
asm(" MOVE.W #$2700,SR"); // Lockout interrupts
asm(" LEA.L -56(A7),A7");
asm(" MOVEM.L D0-D7/A0-A5,(A7)");
asm(" MOVE.L #$ff,D0"); // Pick up configuration value for TMR1
asm(" MOVE.B D0,($60000000+$131)"); // ReSet Timer 1
//Time interrupt routine
Timer2Cnt ++;
asm(" MOVEM.L (A7),D0-D7/A0-A5");
asm(" LEA.L 56(A7),A7");
asm(" RTE ");
}
/*****************************END OF TIME TEST***********************************/
/**
* Initialize MBUS module.
*/
VOID MBusInit(VOID)
{
UCHAR status;
// Reset MBUS.
*(UCHAR*)MBCR = 0;
// MBUS interrupt level and priority define:
// 100 011 00: autovector and level 3, priority 0
// *(UCHAR*)MBUS_ICR = 0x8c;
// SCL freqency setting: 51.6096M / 640 = 80640.
// Note: the index of prescalar value 640 is 0x38.
*(UCHAR*)MFDR = 0x38;
// The slave address of MBUS module in MCF5206 is 0x11 when it addressed
// as a slave. Can it be deleted.
*(UCHAR*)MADR = 0x11;
// enable MBUS, but interrupt was disabled
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -