![Infineon 82C900 Скачать руководство пользователя страница 23](http://html1.mh-extra.com/html/infineon/82c900/82c900_application-note_2055171023.webp)
AP29002
Standalone TwinCAN Controller
Using special features of the 82C900
Application Note
22
V 1.0, 2004-02
The following functions send a byte/word or n bytes to the 82C900:
// sends one byte to the 82C900 at address 'startaddress'
void P_SendByte(word startaddress, unsigned char data)
{
// set Pagenumber A10-A7
P_Write((PAGE&0x00ff), (unsigned char)(startaddress>>7)&0x0E);
P_Write((startaddress&0x00FF), data)// write data into 82C900 RAM
}
// sends a word to the 82C900
void P_SendWord(word startaddress, word data)
{
P_Write((PAGE&0x00ff),(unsigned char)(startaddress>>7)&0x0E);
//
set
Pagenumber
A10-A7
P_Write(((startaddress&1),(unsigned char)(data>>8)&0x00FF);
// write data into 82C900 RAM
P_Write((startaddress&0x00FF), (unsigned char) (data&0x00FF));
// write data into 82C900 RAM
}
//sends bytecount bytes to the 82C900 starting with address startaddress
void P_SendnBytes(word startaddress, unsigned char *data, int bytecount)
{
int i;
for( i = 0; i < bytecount; i++ )
{
P_SendByte(starti,
data[i]);
}
}
These functions read bytes from the 82C900:
// read a byte from the 82C900
unsigned char P_ReadByte(word startaddress)
{
unsigned char ret;
P_Write((PAGE&0x00FF), (unsigned char)(startaddress >>7)&0x0E);
// set page of 82C900
ret = P_Read(startaddress&0xFF);
// read Byte
return ret;
}