User manual

mikroC PRO for dsPIC
MikroElektronika
295
CANSPISetMask
Prototype
void CANSPISetMask(unsigned short CANSPI_MASK, long value, unsigned short
CANSPI_CONFIG_FLAGS);
Description Congures mask for advanced ltering of messages. The parameter value is bit-adjusted to the
appropriate mask registers.
Parameters - CANSPI_MASK: CAN module mask number. Valid values: CANSPI_MASK constants. See CANSPI_
MASK constants.
- val: mask register value. This value is bit-adjusted to appropriate buffer mask registers
- CANSPI_CONFIG_FLAGS: selects type of message to lter. Valid values:
- _CANSPI_CONFIG_ALL_VALID_MSG,
- _CANSPI_CONFIG_MATCH_MSG_TYPE & _CANSPI_CONFIG_STD_MSG,
- _CANSPI_CONFIG_MATCH_MSG_TYPE & _CANSPI_CONFIG_XTD_MSG.
See CANSPI_CONFIG_FLAGS constants.
Returns Nothing.
Requires The CANSPI module must be in Cong mode, otherwise the function will be ignored. See
CANSPISetOperationMode.
The CANSPI routines are supported only by MCUs with the SPI module.
MCU has to be properly connected to mikroElektronika’s CANSPI Extra Board or similar hardware.
See connection example at the bottom of this page.
Example
// set the appropriate lter mask and message type value
CANSPISetOperationMode(_CANSPI_MODE_CONFIG,0xFF); // set
CONFIGURATION mode (CANSPI module must be in cong mode for mask settings)
// Set all B1 mask bits to 1 (all ltered bits are relevant):
// Note that -1 is just a cheaper way to write 0xFFFFFFFF.
// Complement will do the trick and ll it up with ones.
CANSPISetMask(_CANSPI_MASK_B1, -1, _CANSPI_CONFIG_MATCH_MSG_TYPE & _CANSPI_
CONFIG_XTD_MSG);
Notes None.