![Infineon 82C900 Скачать руководство пользователя страница 24](http://html1.mh-extra.com/html/infineon/82c900/82c900_application-note_2055171024.webp)
AP29002
Standalone TwinCAN Controller
Using special features of the 82C900
Application Note
23
V 1.0, 2004-02
// read bytecount Bytes from the 82C900
void P_ReadnBytes(word startaddress, unsigned char *data, int bytecount)
{
int
i;
for( i = 0; i < bytecount; i++)
{
data[i]
=
P_ReadByte(starti);
}
}
Following functions can be used to configure the 82C900 easily:
// set the GLOBCTR for long read access
// copy transferfunctions in the IRAM
void Parallel_init()
{
SROM_PS(P_ACS)// define variables
// copy functions into IRAM
hmemcpy(SROM_PS_TRG(P_ACS),SROM_PS_SRC(P_ACS),SROM_PS_LEN(P_ACS));
P_SendByte(GLOBCTR,0x17);// long read access, OUT0 and OUT1 INTout
}
// init MSGOBJ obj_nr
void init_MSG(int node, int obj_nr, int dir, int by_nr, int id)
{
int
cfg=0x0000;
P_SendWord(MSG_OBJ_BASE(MSGCTRn,
0x5555);
if( 1 == node) cfg |= 0x0002; // node B(node='1')
if( 1 == dir) cfg |= 0x0008; // transmitobject(dir='1')
cfg |= by_nr<<4;
// number of bytes(by_nr)
P_SendWord(MSG_OBJ_BASE(MSGCFGn,
cfg);
// send configuration
P_SendByte(MSG_OBJ_BASE(2, id<<2);// set ID(id)
P_SendWord(MSG_OBJ_BASE(MSGCTRn, 0xFFBF);// MSG valite
}