![Infineon 82C900 Скачать руководство пользователя страница 50](http://html1.mh-extra.com/html/infineon/82c900/82c900_application-note_2055171050.webp)
AP29002
Standalone TwinCAN Controller
Using special features of the 82C900
Application Note
49
V 1.0, 2004-02
The following functions can be used to up/download data from/to the FIFO-buffer. The
load-function automatically searches for the next free object. If there is no free
message object in the buffer the function returns with zero. The read-function searches
for and reads the data from the first message object, where the NEWDAT-flag is set. If
the MSGLST-flag is set, the function returns zero.
// load the data in the first free object of the FIFO-Buffer with the
// base object base. the data can be transmitted automatically, if
// remote is '0'. else it waits for remote frames addressing the FIFO
// returns zero if their is no free object in the buffer
int load_FifoObj(int base, unsigned char* data, char remote)
{
int by_nr, next, i=0,FSIZE,obj;
unsigned char help;
by_nr = (P_ReadByte(MSG_OBJ_BASE(base)+MSGCFGn)&0xF0)>>4;
// read datasize(base)
FSIZE = P_ReadByte(MSG_OBJ_BASE(base)+MSGFGCRn)& 0x1F;
// read FSIZE(base)
next = P_ReadByte(MSG_OBJ_BASE(base)+M2);// read CANPTR(base)
for( i=0; obj = base+(next+i)%(FSIZE+1),
((help=P_ReadByte(MSG_OBJ_BASE(obj)+1+MSGCTRn))&0x22)>0; i++)
{
if((FSIZE)==i ) return 0;
}
// send data directly
if(!remote) SendData(obj, data, by_nr);
// data is send on remoteframe
else LoadRemoteData(obj, data, by_nr);
return 1;}