?? main.c
字號:
/************************* Filename: mpi_main.c ****************************/
/* ========================================================================= */
/* */
/* 0000 000 000 00000 0 000 0 0 0 0000 */
/* 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 */
/* 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Einsteinstra遝 6 */
/* 0000 000 0 0 000 0 0 00000 0 0000 91074 Herzogenaurach */
/* 0 00 0 0 0 0 0 0 0 0 0 */
/* 0 0 0 0 0 0 0 0 0 0 0 0 0 Tel: ++49-9132-744-200 */
/* 0 0 0 000 0 0 000 0 0 0 0 GmbH Fax: ++49-9132-744-204 */
/* */
/* ========================================================================= */
/* */
/* Function: Demo for PROFICHIP Evaluation Board AT89C5132 with VPC3+ */
/* */
/* Order Number: PA 006300 */
/* */
/* ------------------------------------------------------------------------- */
/* */
/* history */
/* ========================================================================= */
/* 08.09.2005 [V1.00] Urversion */
/* */
/* ------------------------------------------------------------------------- */
/* */
/* Hardware requirements: ProfiChip Evaluation Board AT89C5132 (PA006101) */
/* ProfiChip Evaluation Board VPC3+/C (PA006103) */
/* */
/* ------------------------------------------------------------------------- */
/* memory: 0000H ... 7FFFH: RAM */
/* 8000H ... 8FFFH: VPC3+ */
/* 9000H ... 9FFFH: Reserved */
/* A000H ... AFFFH: FPGA */
/* B000H ... BFFFH: RTC */
/* C000H ... CFFFH: LCD */
/* D000H ... DFFFH: I/O Port 0 */
/* E000H ... EFFFH: I/O Port 1 */
/* F000H ... FFFFH: I/O Port 2 */
/* */
/* ------------------------------------------------------------------------- */
/* */
/* Technical support: P. Fredehorst */
/* Tel. : ++49-9132/744-214 */
/* Fax. : -204 */
/* eMail: pfredehorst@profichip.com */
/* */
/*****************************************************************************/
/*****************************************************************************/
/* contents:
- function prototypes
- data structures
- internal functions
*/
/*****************************************************************************/
/* include hierarchy */
#include "..\..\dp_inc\platform.h"
#include "..\..\dp_inc\dp_inc.h"
/*---------------------------------------------------------------------------*/
/* function prototypes */
/*---------------------------------------------------------------------------*/
DP_ERROR_CODE check_external_ram ( void );
void init_hardware ( void );
void print_hello ( void );
void main ( void );
extern ROMCONST__ UBYTE NAME[8];
/*---------------------------------------------------------------------------*/
/* global user data definitions */
/*---------------------------------------------------------------------------*/
UWORD wTimerCount;
/*---------------------------------------------------------------------------*/
/* function: main */
/*---------------------------------------------------------------------------*/
void main( void )
{
#ifdef EvaBoard_AT89C5132
//necessary for VPC3+/C, because address 10 is input
CLR_VPC3_ADR10__;
#endif//#ifdef EvaBoard_AT89C5132
// init system - adapt it to your special requirements !
init_hardware();
print_hello();
// call the example user application
user_main();
}//void main( void )
/*---------------------------------------------------------------------------*/
/* init hardware */
/*---------------------------------------------------------------------------*/
void print_hello( void )
{
sDP_VERSION pVersion;
DP_GetVersion( &pVersion );
#ifdef RS232_SERIO
print_string( "\r\n\r\nprofichip GmbH VPC3-Demo Version: V5.00 09.09.2005\r\n" );
print_string( "\r\nSoftwareversion: V" );
print_hexbyte( pVersion.bMainInterface );
print_string( "." );
print_hexbyte( pVersion.bFunction );
print_hexbyte( pVersion.bBugfix );
print_string( "\r\nInstalled Components: " );
print_hexword( pVersion.wComponentsInstalled );
print_help();
#endif//#ifdef RS232_SERIO
#ifdef EvaBoard_AT89C5132
#ifdef LCD
LCDUpdateProfichip( pVersion.bMainInterface, pVersion.bFunction, pVersion.bBugfix );
LCDUpdate( &NAME[0] );
#endif//#ifdef LCD
#endif//#ifdef EvaBoard_AT89C5132
}//void print_hello( void )
/*---------------------------------------------------------------------------*/
/* init hardware */
/*---------------------------------------------------------------------------*/
void init_hardware( void )
{
CLR_LED_YLW__;
CLR_LED_RED__;
#ifdef EvaBoard_AT89C5132
#ifdef AT89C5132_MODE_X2
Set_x2_mode();
#endif//#ifdef AT89C5132_MODE_X2
AUXR = 0x02; //set ERAM, enable ALE
*WRITE_PORT0 = 0x00;
*WRITE_PORT1 = 0x00;
*WRITE_PORT2 = 0x00;
#endif//#ifdef EvaBoard_AT89C5132
// check sram
if( DP_OK != check_external_ram() )
{
#ifdef EvaBoard_AT89C5132
*WRITE_PORT0 = DP_SRAM_ERROR;
#endif//#ifdef EvaBoard_AT89C5132
SET_LED_RED__;
while(1)
{
}//while(1)
}//if( DP_OK != check_external_ram() )
// only used for fibre optic interface
DISABLE_LWL_INTERFACE_B__;
SET_DIR_AB__;
// todo: perform VPC3 reset for at least 300ns time
VPC3_RESET__; // set reset hardware pin
//VPC3_CLEAR_RESET__; // clear reset hardware pin
#ifdef RS232_SERIO
// initialize serial port
//init_serio( 57600 );
init_serio( 38400 );
#endif//#ifdef RS232_SERIO
#ifdef EvaBoard_AT89C5132
#ifdef LCD
//init LCD-Display
LCDInitDisplay();
#endif//#ifdef LCD
#endif//#ifdef EvaBoard_AT89C5132
#ifdef ISOCHRON_MODE
//clear pending interrupt
KBSTA = KBSTA;
//detect 1 to 0 transition
KBCON = KB_STD;
//0 on all columns
P_KBD &= MSK_STD;
//enable keyboard interrupt
Kbd_enable_int();
#endif//#ifdef ISOCHRON_MODE
// enable interrupts
ENABLE_ALL_INTERRUPT_BIT__;
// todo: do other hardware-initialisation
}//void init_hardware( void )
/*---------------------------------------------------------------------------*/
/* function: check_external_ram */
/*---------------------------------------------------------------------------*/
DP_ERROR_CODE check_external_ram( void )
{
data DP_ERROR_CODE bError;
data UWORD i;
data UWORD j;
bError = DP_OK;
j = 5432;
for(i=0x4000;i<0x8000;)
{
*((UWORD xdata*)i)=j;
i+=2;
j++;
}
j = 5432;
for(i=0x4000;i<0x8000;)
{
if(*((UWORD xdata*)i)!=j)
{
bError = DP_SRAM_ERROR; // ERROR
}
i+=2;
j++;
}
j = 0;
for(i=0x4000;i<0x8000;)
{
*((UWORD xdata*)i)=j;
i+=2;
}
return bError;
}//DP_ERROR_CODE check_sram( void )
/*---------------------------------------------------------------------------*/
/* function: external interrupt 0 */
/*---------------------------------------------------------------------------*/
#ifdef EvaBoard_AT89C5132
void ex0_ISR (void) interrupt IRQ_INT0
{
vpc3_isr();
}
#endif//#ifdef EvaBoard_AT89C5132
/*---------------------------------------------------------------------------*/
/* function: external interrupt 0 */
/*---------------------------------------------------------------------------*/
#ifdef EvaBoard_AT89C5132
#ifdef ISOCHRON_MODE
void kbd_ISR (void) interrupt IRQ_KBD
{
vpc3_isochron_isr();
}
#endif//#ifdef ISOCHRON_MODE
#endif//#ifdef EvaBoard_AT89C5132
/*****************************************************************************/
/* Copyright (C) profichip GmbH 2005. Confidential. */
/*****************************************************************************/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -