![Infineon 82C900 Скачать руководство пользователя страница 26](http://html1.mh-extra.com/html/infineon/82c900/82c900_application-note_2055171026.webp)
AP29002
Standalone TwinCAN Controller
Using special features of the 82C900
Application Note
25
V 1.0, 2004-02
Functions to transmit data via CAN-Bus or to read received data from the 82C900:
// load wd_nr bytes into the MSGOBJ and transmit them via CAN-BUS
void SendData(int msg_obj, unsigned char *data, int bt_nr)
{
int msg_dat=MSG_OBJ_BASE(mMSGDRn0;
// address of the MSGOBJ-data
P_SendWord(MSG_OBJ_BASE(mMSGCTRn,
0xFB7F);
// inhibit transmission.
P_SendnBytes(msg_dat,data,bt_nr);
// transmit new data to the MSGOBJ
P_SendWord(MSG_OBJ_BASE(mMSGCTRn,
0xE6BD);
// Reads bt_nr Bytes from the MSGOBJ into the datafield
void ReadData(int msg_obj, unsigned char *data, int bt_nr)
{
int
msg_dat=MSG_OBJ_BASE(mMSGDRn0;
// address of the MSGOBJ-data
P_SendWord(MSG_OBJ_BASE(mMSGCTRn,
0xFD7F);
// reset MSGVAL,NEWDAT
P_ReadnBytes(msg_dat,data,bt_nr);
// read bt_nr bytes
P_SendWord(MSG_OBJ_BASE(mMSGCTRn,
0xFDBF);
// set MSGVAL, no data lost
}