Datasheet
CANSPI_FILTER
The CANSPI_FILTER constants define filter codes. Functions CANSPISetFilter
expects one of these as it's argument:
const char
CANSPI_FILTER_B1_F1 = 0,
CANSPI_FILTER_B1_F2 = 1,
CANSPI_FILTER_B2_F1 = 2,
CANSPI_FILTER_B2_F2 = 3,
CANSPI_FILTER_B2_F3 = 4,
CANSPI_FILTER_B2_F4 = 5;
Library Example
This is a simple demonstration of CANSPI Library routines usage. First node initi-
ates the communication with the second node by sending some data to its address.
The second node responds by sending back the data incremented by 1. First node
then does the same and sends incremented data back to second node, etc.
Code for the first CANSPI node:
unsigned char Can_Init_Flags, Can_Send_Flags, Can_Rcv_Flags; // can
flags
unsigned char Rx_Data_Len; // received data length in bytes
char RxTx_Data[8]; // can rx/tx data buffer
char Msg_Rcvd; // reception flag
long Tx_ID, Rx_ID; // can rx and tx ID
// CANSPI module connections
sbit CanSpi_CS at PORTB.B0;
sbit CanSpi_CS_Direction at DDRB.B0;
sbit CanSpi_Rst at PORTB.B2;
sbit CanSpi_Rst_Direction at DDRB.B2;
// End CANSPI module connections
void main() {
ADCSRA.B7 = 0; // set AN pins to Digital I/O
PORTC = 0; // clear PORTC
DDRC = 255;
Can_Init_Flags = 0; //
Can_Send_Flags = 0; // clear flags
Can_Rcv_Flags = 0; //
247
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6