The CAN driver provides a complete software interface for operating the Synaptics CAN peripheral in Classical CAN and CAN FD modes.
The driver supports standard and extended identifiers, callback-driven transmit/receive operation, scheduled transmission, timestamp sampling, and runtime control of protocol and controller behavior.
Features:
- Classical CAN and CAN FD transfer support
- Standard (11-bit) and Extended (29-bit) identifier handling
- RX filter subscription with callback dispatch
- Blocking-style status tracking through callback completion state
- Scheduled TX support using 64-bit controller timestamps
- Timestamp capture callback support
- Runtime configuration of bitrate, sample point, loopback, and watchdog
- Interrupt mask management APIs for fine-grained event control
The driver is structured around:
- Core lifecycle APIs for initialization, configuration, and enable flow
- Transfer APIs for TX queueing and RX filter subscription
- Runtime-control APIs for protocol and timing behavior
- Interrupt/timestamp APIs for asynchronous status and timing events
- Note
- CAN APIs are divided into two categories:
- High-level APIs: Provides structured lifecycle and transfer interfaces for most application-level use cases, including configuration, frame transmission, and RX filter subscription with callback dispatch.
- Low-level APIs: Provides direct runtime control and event handling for advanced use cases, including timestamp sampling hooks and controller behavior tuning (ECC, retransmit, watchdog, and framing mode).
- Warning
- Reconfigure operating mode, bitrate, sampling, or ECC behavior only while the controller is disabled.
Configuration Considerations
To initialize and operate the CAN driver:
- Call can_init to initialize the peripheral instance and reset internal driver context.
- Fill a can_config_t, or pass NULL to use the driver defaults.
- Call can_configure to allocate driver-managed resources and apply the controller runtime state.
- Register optional timestamp callback using can_set_timestamp_sample_handler.
- Install receive filters using can_rx_subscribe.
- Call can_enable to start controller operation and bus participation.
- Submit frames using can_tx; pass a per-transfer callback when TX completion notification is required.
Using TX and RX Paths
Recommended transfer flow:
- Build a can_tx_frame_t descriptor with frame format, identifier, DLC, and payload.
- Submit the frame using can_tx (immediate or scheduled).
- Track completion through transfer callback status.
- Install one or more can_rx_filter_t entries using can_rx_subscribe to receive matching traffic.
- Remove filters when no longer needed using can_rx_unsubscribe.
can_init
Initializes the CAN peripheral and prepares hardware/software context.
can_configure
Configures driver resources and default controller runtime behavior.
.bitrate = CAN_BITRATE_500K,
.fd_mode = false,
.loopback_enable = true
};
}
can_enable
Enables CAN controller operation.
can_tx
Queues a frame for immediate or scheduled transmission.
tx_frame.header.signal_desc.fields.
id = 0x123;
tx_frame.header.signal_desc.fields.
ide = 0;
tx_frame.header.signal_desc.fields.
rtr = 0;
tx_frame.header.signal_desc.fields.
dlc = 8;
}
can_rx_subscribe
Installs an RX filter and callback subscription.
.id = 0x123,
.mask = 0x7FF,
.flags = CAN_FILTER_IDE
};
int subscription_id = -1;
}
can_disable
Disables CAN controller operation.
can_deinit
Deinitializes CAN instance resources.