Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
uavcan.c File Reference

Interface from actuators to ChibiOS CAN driver using UAVCan. More...

#include "uavcan.h"
#include "mcu_periph/can.h"
#include "modules/core/threads.h"
+ Include dependency graph for uavcan.c:

Go to the source code of this file.

Macros

#define UAVCAN_NODE_ID   100
 
#define UAVCAN_BAUDRATE   1000000
 

Functions

static void can_frame_cb (struct pprzcan_frame *rx_msg, UNUSED struct pprzaddr_can *src_addr, void *user_data)
 
static void uavcan_tx (void *p)
 
static void onTransferReceived (CanardInstance *ins, CanardRxTransfer *transfer)
 Whenever a valid and 'accepted' transfer is received.
 
static bool shouldAcceptTransfer (const CanardInstance *ins, uint64_t *out_data_type_signature, uint16_t data_type_id, CanardTransferType transfer_type, uint8_t source_node_id)
 If we should accept this transfer.
 
static void uavcanInitIface (struct uavcan_iface_t *iface)
 Initialize uavcan interface.
 
void uavcan_init (void)
 Initialize all uavcan interfaces.
 
void uavcan_bind (uint16_t data_type_id, uint64_t data_type_signature, uavcan_event *ev, uavcan_callback cb)
 Bind to a receiving message from uavcan.
 
void uavcan_broadcast (struct uavcan_iface_t *iface, uint64_t data_type_signature, uint16_t data_type_id, uint8_t priority, const void *payload, uint16_t payload_len)
 Broadcast an uavcan message to a specific interface.
 

Variables

static uavcan_eventuavcan_event_hd = NULL
 
uint8_t msg_payload [UAVCAN_MSG_MAX_SIZE]
 

Detailed Description

Interface from actuators to ChibiOS CAN driver using UAVCan.

Definition in file uavcan.c.

Macro Definition Documentation

◆ UAVCAN_BAUDRATE

#define UAVCAN_BAUDRATE   1000000

Definition at line 36 of file uavcan.c.

◆ UAVCAN_NODE_ID

#define UAVCAN_NODE_ID   100

Definition at line 32 of file uavcan.c.

Function Documentation

◆ can_frame_cb()

static void can_frame_cb ( struct pprzcan_frame rx_msg,
UNUSED struct pprzaddr_can src_addr,
void user_data 
)
static

Definition at line 88 of file uavcan.c.

References CAN_EID_MASK, CAN_FRAME_EFF, CAN_SID_MASK, foo, pprz_mtx_lock(), and pprz_mtx_unlock().

Referenced by uavcanInitIface().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ onTransferReceived()

static void onTransferReceived ( CanardInstance ins,
CanardRxTransfer transfer 
)
static

Whenever a valid and 'accepted' transfer is received.

Definition at line 174 of file uavcan.c.

References abi_struct::cb, ev, foo, abi_struct::next, transfer(), and uavcan_event_hd.

Referenced by uavcanInitIface().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ shouldAcceptTransfer()

static bool shouldAcceptTransfer ( const CanardInstance ins,
uint64_t out_data_type_signature,
uint16_t  data_type_id,
CanardTransferType  transfer_type,
uint8_t  source_node_id 
)
static

If we should accept this transfer.

Definition at line 189 of file uavcan.c.

References ev, foo, abi_struct::next, and uavcan_event_hd.

Referenced by uavcanInitIface().

+ Here is the caller graph for this function:

◆ uavcan_bind()

void uavcan_bind ( uint16_t  data_type_id,
uint64_t  data_type_signature,
uavcan_event ev,
uavcan_callback  cb 
)

Bind to a receiving message from uavcan.

Definition at line 250 of file uavcan.c.

References abi_struct::cb, ev, abi_struct::next, and uavcan_event_hd.

Referenced by actuators_uavcan_init(), airspeed_uavcan_init(), can_fuelcell_init(), gps_uavcan_init(), mag_uavcan_init(), power_uavcan_init(), and range_sensor_uavcan_init().

+ Here is the caller graph for this function:

◆ uavcan_broadcast()

void uavcan_broadcast ( struct uavcan_iface_t iface,
uint64_t  data_type_signature,
uint16_t  data_type_id,
uint8_t  priority,
const void payload,
uint16_t  payload_len 
)

Broadcast an uavcan message to a specific interface.

Definition at line 265 of file uavcan.c.

References circular_buffer_drop(), circular_buffer_put(), foo, pprz_bsem_signal(), pprz_mtx_lock(), and pprz_mtx_unlock().

Referenced by actuators_uavcan_cmd_commit(), and actuators_uavcan_commit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uavcan_init()

void uavcan_init ( void  )

Initialize all uavcan interfaces.

uavcan interfaces

Definition at line 237 of file uavcan.c.

References foo, and uavcanInitIface().

+ Here is the call graph for this function:

◆ uavcan_tx()

static void uavcan_tx ( void p)
static

Definition at line 114 of file uavcan.c.

References CAN_FRAME_EFF, pprzcan_frame::can_id, can_transmit_frame(), circular_buffer_get(), pprzcan_frame::data, foo, pprzcan_frame::len, msg_payload, p, pprz_bsem_wait(), pprz_mtx_lock(), pprz_mtx_unlock(), and UAVCAN_MSG_MAX_SIZE.

Referenced by uavcanInitIface().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uavcanInitIface()

static void uavcanInitIface ( struct uavcan_iface_t iface)
static

Initialize uavcan interface.

Definition at line 211 of file uavcan.c.

References can_frame_cb(), can_register_callback(), circular_buffer_init(), foo, onTransferReceived(), pprz_bsem_init(), pprz_mtx_init(), pprz_thread_create(), shouldAcceptTransfer(), uavcan_tx(), and UAVCAN_TX_FIFO_SIZE.

Referenced by uavcan_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ msg_payload

Definition at line 109 of file uavcan.c.

Referenced by uavcan_tx().

◆ uavcan_event_hd

uavcan_event* uavcan_event_hd = NULL
static

Definition at line 39 of file uavcan.c.

Referenced by onTransferReceived(), shouldAcceptTransfer(), and uavcan_bind().