Description

deregReceiver() – removes an object that is derived from the base class SAMC21_CAN_RECEIVER() from the CAN bus object.

Syntax

MCAN0.deregReceiver( &pt_receiverObj );

Parameters

SAMC21_CAN_RECEIVER* pt_receiverObj – pointer to the SAMC21_CAN_RECEIVER object that should be taken of the CAN bus.

Returns

nothing

Example Code

The following example sends messages on CAN bus MCAN0.

MY_ENGINE_CLASS myEngineObj; // create an instance of our class

void setup()
{
  while(!Serial);

  // register obj. with MCAN0 listening for std.IDs 0x123 & 0x124
  MCAN0.regReceiver(&myEngineObj, 0x123, 0x124, 0); 
  // deregister the object from the CAN bus MCAN0 (freeing the slot)
  MCAN0.deregReceiver(&myEngineObj);
}
  
void loop()
{
}

An example can be found in the Arduino IDE menu:
File -> Examples -> DICE -> CAN_Bus -> ReceiverClassExample

Notes and Warnings

Each CAN bus object (MCAN0 / MCAN1) has up to 8 slot to handle SAMC21_CAN_RECEIVER() objects. Be aware that each CAN2SER and Datapool object is using one of those slots. So in an average application that uses Serial and GPS, there would be 6 slots left for the application objects. Removing an object with deregReceiver() frees up a slot and so that it can be used again by another object.

See also

regReceiver()
SAMC21_CAN_RECEIVER()
can_msg_recv_callback()
can_routine_callback()
SAMC21_CAN – Library
CAN operation background
users manual
BOOTLOADER SETTINGS – Library