Photon CAN Bus [Completed]

I’m using a Teensy with FlexCan to echo the CAN messages from the Photon back to the CANBUS. The distributed version work OK for standard addressing but doesn’t work for extended addressing. I had to change the “firmware/hal/src/stm32f2xx/can_hal.cpp” as shown below. With the modified version it works for me with both standard and extended addressing filters.

bool CANDriver::addFilter(uint32_t id, uint32_t mask, HAL_CAN_Filters type)
{
if(nextFilter > hw.can_last_filter)
{
return false;
}

// Filter configuration - Register organization
// Lowest 11 bits of id are first, then next 18 bits of id, then
// sta

uint32_t filterId, filterMask;

if (type == CAN_FILTER_STANDARD) {
    
    filterId   = (id   << 21) | ((id   >> 8) & 0x1FFFF8) | (type == CAN_FILTER_EXTENDED ? 0x4 : 0);
    filterMask = (mask << 21) | ((mask >> 8) & 0x1FFFF8) | 0x6;
    
 } else {
    
    filterId   = ((id   << 3) & 0x1FFFF8) | (type == CAN_FILTER_EXTENDED ? 0x4 : 0);
    filterMask = ((mask << 3) & 0x1FFFF8) | 0x6;
    
}