Техническая Спецификация для Atmel Xplained Pro Evaluation Kit ATSAM4E-XPRO ATSAM4E-XPRO

Модели
ATSAM4E-XPRO
Скачать
Страница из 1506
SAM4E [DATASHEET]
Atmel-11157D-ATARM-SAM4E16-SAM4E8-Datasheet_12-Jun-14
658
Figure 33-3.
Message Acceptance Procedure
If a mailbox is dedicated to receiving several messages (a family of messages) with different IDs, the acceptance
mask defined in the CAN_MAMx register must mask the variable part of the ID family. Once a message is
received, the application must decode the masked bits in the CAN_MIDx. To speed up the decoding, masked bits
are grouped in the family ID register (CAN_MFIDx). 
For example, if the following message IDs are handled by the same mailbox:
ID0 101000100100010010000100 0 11 00b
ID1 101000100100010010000100 0 11 01b
ID2 101000100100010010000100 0 11 10b
ID3 101000100100010010000100 0 11 11b
ID4 101000100100010010000100 1 11 00b
ID5 101000100100010010000100 1 11 01b
ID6 101000100100010010000100 1 11 10b
ID7 101000100100010010000100 1 11 11b
The CAN_MIDx and CAN_MAMx of Mailbox x must be initialized to the corresponding values:
CAN_MIDx = 001 101000100100010010000100 x 11 xxb
CAN_MAMx = 001 111111111111111111111111 0 11 00b
If Mailbox x receives a message with ID6, then CAN_MIDx and CAN_MFIDx are set:
CAN_MIDx = 001 101000100100010010000100 1 11 10b
CAN_MFIDx = 00000000000000000000000000000110b
If the application associates a handler for each message ID, it may define an array of pointers to functions:
void (*pHandler[8])(void); 
When a message is received, the corresponding handler can be invoked using CAN_MFIDx register and there is
no need to check masked bits:
unsigned int MFID0_register;
MFID0_register = Get_CAN_MFID0_Register();
// Get_CAN_MFID0_Register() returns the value of the CAN_MFID0 register
pHandler[MFID0_register]();
33.7.2.2   Receive Mailbox
When the CAN module receives a message, it looks for the first available mailbox with the lowest number and
compares the received message ID with the mailbox ID. If such a mailbox is found, then the message is stored in
its data registers. Depending on the configuration, the mailbox is disabled as long as the message has not been
acknowledged by the application (Receive only), or, if new messages with the same ID are received, then they
overwrite the previous ones (Receive with overwrite).
CAN_MIDx
CAN_MAMx
Message Received
&
&
==
Message Accepted
Message Refused
No
Yes
CAN_MFIDx