Skip to content

File syn_port_can.h

FileList > port > syn_port_can.h

Go to the source code of this file

CAN bus port interface. More...

  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Public Functions

Type Name
bool syn_port_can_init (uint8_t port, uint32_t bitrate)
Initialize CAN peripheral.
bool syn_port_can_receive (uint8_t port, uint32_t * id, bool * extended, uint8_t * data, uint8_t * dlc)
Receive a CAN frame (non-blocking).
bool syn_port_can_send (uint8_t port, uint32_t id, bool extended, const uint8_t * data, uint8_t dlc)
Send a CAN frame.
void syn_port_can_set_filter (uint8_t port, uint32_t id, uint32_t mask)
Set hardware acceptance filter.

Detailed Description

Implement these functions for your CAN peripheral.

Public Functions Documentation

function syn_port_can_init

Initialize CAN peripheral.

bool syn_port_can_init (
    uint8_t port,
    uint32_t bitrate
) 

Parameters:

  • port CAN port number (0, 1, ...).
  • bitrate Bitrate in bits/sec (e.g. 500000 for 500kbps).

Returns:

true on success.


function syn_port_can_receive

Receive a CAN frame (non-blocking).

bool syn_port_can_receive (
    uint8_t port,
    uint32_t * id,
    bool * extended,
    uint8_t * data,
    uint8_t * dlc
) 

Parameters:

  • port CAN port.
  • id [out] CAN identifier.
  • extended [out] true if 29-bit ID.
  • data [out] Frame data buffer (at least 8 bytes).
  • dlc [out] Data length code.

Returns:

true if a frame was received.


function syn_port_can_send

Send a CAN frame.

bool syn_port_can_send (
    uint8_t port,
    uint32_t id,
    bool extended,
    const uint8_t * data,
    uint8_t dlc
) 

Parameters:

  • port CAN port.
  • id CAN identifier (11-bit or 29-bit).
  • extended true for 29-bit ID.
  • data Frame data (up to 8 bytes).
  • dlc Data length code (0-8).

Returns:

true if frame was queued for transmission.


function syn_port_can_set_filter

Set hardware acceptance filter.

void syn_port_can_set_filter (
    uint8_t port,
    uint32_t id,
    uint32_t mask
) 

Parameters:

  • port CAN port.
  • id Filter ID.
  • mask Filter mask (1 = must match, 0 = don't care).


The documentation for this class was generated from the following file src/syntropic/port/syn_port_can.h