Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
CANSPISetMask
192
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6
Prototype
procedure CANSPISetMask(CAN_MASK: byte; val: longint; CAN_CON-
FIG_FLAGS: byte);
Returns
Nothing.
Description
Configures mask for advanced filtering of messages. The parameter value is
bit-adjusted to the appropriate mask registers.
Parameters:
CAN_MASK
: CANSPI module mask number. Valid values: 
CANSPI_MASK
constants (see CANSPI constants) 
val
: mask register value 
CAN_CONFIG_FLAGS
: selects type of message to filter. Valid values:    
CANSPI_CONFIG_ALL_VALID_MSG, 
CANSPI_CONFIG_MATCH_MSG_TYPE 
and CANSPI_CONFIG_STD_MSG,
CANSPI_CONFIG_MATCH_MSG_TYPE 
and CANSPI_CONFIG_XTD_MSG. 
(see CANSPI constants) 
Requires
The CANSPI module must be in Config 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 filter mask and message type value
CANSPISetOperationMode(CANSPI_MODE_CONFIG,0xFF);              //
set CONFIGURATION mode (CANSPI module must be in config mode for
mask settings)
// Set all B1 mask bits to 1 (all filtered bits are relevant):
// Note that -1 is just a cheaper way to write 0xFFFFFFFF.
// Complement will do the trick and fill it up with ones.
CANSPISetMask(CANSPI_MASK_B1, -1, CANSPI_CONFIG_MATCH_MSG_TYPE
and CANSPI_CONFIG_XTD_MSG);