mikroC - C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
158
MikroElektronika: Development tools - Books - Compilers
page
Prototype
char
CANSPIRead(
long
*id,
char
*data,
char
*datalen,
char
*CAN_RX_MSG_FLAGS);
Returns
Message from receive buffer or zero if no message found.
Description
Function reads message from receive buffer. If at least one full receive buffer is found, it
is extracted and returned. If none found, function returns zero.
Parameters:
id
is message identifier;
data
is an array of bytes up to 8 bytes in length;
datalen
is data length, from 1–8;
CAN_RX_MSG_FLAGS
is value formed from constants
(see CAN constants).
Requires
CANSPI must be in mode in which receiving is possible.
Example
char
rcv, rx, len, data[8];
long
id;
rcv = CANSPIRead(id, data, len, 0);
CANSPIRead
Prototype
char
CANSPIWrite(
long
id,
char
*data,
char
datalen,
char
CAN_TX_MSG_FLAGS);
Returns
Returns zero if message cannot be queued (buffer full).
Description
If at least one empty transmit buffer is found, function sends message on queue for
transmission. If buffer is full, function returns 0.
Parameters:
id
is CANSPI message identifier. Only 11 or 29 bits may be used depend-
ing on message type (standard or extended);
data
is array of bytes up to 8 bytes in
length;
datalen
is data length from 1–8;
CAN_TX_MSG_FLAGS
is value formed from
constants (see CAN constants).
Requires
CANSPI must be in Normal mode.
Example
char
tx, data;
long
id;
tx = CAN_TX_PRIORITY_0 & CAN_TX_XTD_FRAME;
CANSPIWrite(id, data, 2, tx);
CANSPIWrite