Skip to content

File syn_can.c

FileList > drivers > syn_can.c

Go to the source code of this file

CAN bus driver implementation.

  • #include "../util/syn_assert.h"
  • #include "syn_can.h"
  • #include <string.h>

Public Functions

Type Name
SYN_Status syn_can_init (SYN_CAN * can, uint8_t port, uint32_t bitrate)
Initialize CAN driver.
void syn_can_on_receive (SYN_CAN * can, SYN_CAN_Callback cb, void * ctx)
Register receive callback.
void syn_can_poll (SYN_CAN * can)
Poll for received frames and dispatch callback.
bool syn_can_send (SYN_CAN * can, const SYN_CAN_Frame * frame)
Send a CAN frame.
void syn_can_set_filter (const SYN_CAN * can, uint32_t id, uint32_t mask)
Set hardware acceptance filter.

Public Functions Documentation

function syn_can_init

Initialize CAN driver.

SYN_Status syn_can_init (
    SYN_CAN * can,
    uint8_t port,
    uint32_t bitrate
) 

Parameters:

  • can CAN instance.
  • port CAN peripheral port number.
  • bitrate Bitrate in bps (e.g. 500000).

Returns:

SYN_OK on success.


function syn_can_on_receive

Register receive callback.

void syn_can_on_receive (
    SYN_CAN * can,
    SYN_CAN_Callback cb,
    void * ctx
) 

Parameters:

  • can CAN instance.
  • cb Callback function.
  • ctx User context.

function syn_can_poll

Poll for received frames and dispatch callback.

void syn_can_poll (
    SYN_CAN * can
) 

Call from your main loop.

Parameters:

  • can CAN instance.

function syn_can_send

Send a CAN frame.

bool syn_can_send (
    SYN_CAN * can,
    const SYN_CAN_Frame * frame
) 

Parameters:

  • can CAN instance.
  • frame Frame to send.

Returns:

true if frame was queued successfully.


function syn_can_set_filter

Set hardware acceptance filter.

void syn_can_set_filter (
    const SYN_CAN * can,
    uint32_t id,
    uint32_t mask
) 

Parameters:

  • can CAN instance.
  • id Filter ID.
  • mask Filter mask.


The documentation for this class was generated from the following file src/syntropic/drivers/syn_can.c