File syn_canopen.c¶
FileList > proto > syn_canopen.c
Go to the source code of this file
CANopen DS301 Slave Protocol Engine implementation.
#include "syntropic/proto/syn_canopen.h"#include "syntropic/util/syn_pack.h"#include <string.h>
Public Functions¶
| Type | Name |
|---|---|
| bool | syn_canopen_get_tx (SYN_CANOpenNode * node, uint32_t * out_cob_id, uint8_t * out_data, uint8_t * out_len) Retrieve pending transmit CAN frame. |
| SYN_Status | syn_canopen_init (SYN_CANOpenNode * node, const SYN_CANOpenNodeConfig * cfg, const SYN_CANOpenODEntry * od_table, size_t od_count) Initialize a CANopen DS301 Node. |
| SYN_Status | syn_canopen_od_read (SYN_CANOpenNode * node, uint16_t index, uint8_t subindex, void * buf, size_t buf_size, size_t * out_len) Directly read an entry from the Object Dictionary. |
| SYN_Status | syn_canopen_od_write (SYN_CANOpenNode * node, uint16_t index, uint8_t subindex, const void * data, size_t len) Directly write an entry to the Object Dictionary. |
| SYN_Status | syn_canopen_process_rx (SYN_CANOpenNode * node, uint32_t cob_id, const uint8_t * data, uint8_t len) Process an incoming CAN frame. |
| SYN_Status | syn_canopen_send_emcy (SYN_CANOpenNode * node, uint16_t err_code, uint8_t err_reg) Transmit an Emergency (EMCY) message. |
| SYN_Status | syn_canopen_tpdo_trigger (SYN_CANOpenNode * node, uint8_t pdo_num) Manually trigger transmission of a specific TPDO (1..4). |
| SYN_Status | syn_canopen_update (SYN_CANOpenNode * node, uint32_t dt_ms) Periodic timer update (call from tick thread or loop). |
Public Static Functions¶
| Type | Name |
|---|---|
| const SYN_CANOpenODEntry * | canopen_find_od (const SYN_CANOpenNode * node, uint16_t index, uint8_t subindex) Helper function to find an Object Dictionary entry. |
| void | canopen_queue_tx (SYN_CANOpenNode * node, uint32_t cob_id, const uint8_t * data, uint8_t len) Helper function to queue a CAN transmit frame. |
| void | canopen_send_sdo_abort (SYN_CANOpenNode * node, uint16_t index, uint8_t subindex, uint32_t abort_code) Send an SDO Abort frame. |
Public Functions Documentation¶
function syn_canopen_get_tx¶
Retrieve pending transmit CAN frame.
bool syn_canopen_get_tx (
SYN_CANOpenNode * node,
uint32_t * out_cob_id,
uint8_t * out_data,
uint8_t * out_len
)
Parameters:
nodePointer to node handle.out_cob_idOutput COB-ID pointer.out_dataOutput 8-byte buffer pointer.out_lenOutput frame length pointer.
Returns:
true if a frame was popped, false if no frame pending.
function syn_canopen_init¶
Initialize a CANopen DS301 Node.
SYN_Status syn_canopen_init (
SYN_CANOpenNode * node,
const SYN_CANOpenNodeConfig * cfg,
const SYN_CANOpenODEntry * od_table,
size_t od_count
)
Parameters:
nodePointer to node handle.cfgPointer to node configuration.od_tableArray of Object Dictionary entries.od_countNumber of entries in od_table.
Returns:
SYN_OK on success, SYN_INVALID_PARAM on invalid inputs.
function syn_canopen_od_read¶
Directly read an entry from the Object Dictionary.
SYN_Status syn_canopen_od_read (
SYN_CANOpenNode * node,
uint16_t index,
uint8_t subindex,
void * buf,
size_t buf_size,
size_t * out_len
)
Parameters:
nodePointer to node handle.index16-bit OD Index.subindex8-bit OD Subindex.bufOutput buffer pointer.buf_sizeMaximum buffer capacity.out_lenPointer to store read byte length.
Returns:
SYN_OK on success, error code if not found or unauthorized.
function syn_canopen_od_write¶
Directly write an entry to the Object Dictionary.
SYN_Status syn_canopen_od_write (
SYN_CANOpenNode * node,
uint16_t index,
uint8_t subindex,
const void * data,
size_t len
)
Parameters:
nodePointer to node handle.index16-bit OD Index.subindex8-bit OD Subindex.dataInput data pointer.lenInput data length in bytes.
Returns:
SYN_OK on success, error code if not found or unauthorized.
function syn_canopen_process_rx¶
Process an incoming CAN frame.
SYN_Status syn_canopen_process_rx (
SYN_CANOpenNode * node,
uint32_t cob_id,
const uint8_t * data,
uint8_t len
)
Parameters:
nodePointer to node handle.cob_idReceived 11-bit CAN COB-ID.dataPayload buffer (up to 8 bytes).lenPayload length.
Returns:
SYN_OK on success, error code on failure.
function syn_canopen_send_emcy¶
Transmit an Emergency (EMCY) message.
Parameters:
nodePointer to node handle.err_code16-bit CANopen Emergency Error Code.err_reg8-bit Error Register value (Index 0x1001).
Returns:
SYN_OK on success, SYN_INVALID_PARAM on invalid parameters.
function syn_canopen_tpdo_trigger¶
Manually trigger transmission of a specific TPDO (1..4).
Parameters:
nodePointer to node handle.pdo_numTPDO number (1..4).
Returns:
SYN_OK on success, SYN_INVALID_PARAM if pdo_num invalid or unmapped.
function syn_canopen_update¶
Periodic timer update (call from tick thread or loop).
Parameters:
nodePointer to node handle.dt_msElapsed time since last update in milliseconds.
Returns:
SYN_OK on success.
Public Static Functions Documentation¶
function canopen_find_od¶
Helper function to find an Object Dictionary entry.
static const SYN_CANOpenODEntry * canopen_find_od (
const SYN_CANOpenNode * node,
uint16_t index,
uint8_t subindex
)
Parameters:
nodePointer to node handle.index16-bit OD Index.subindex8-bit OD Subindex.
Returns:
Pointer to entry if found, NULL otherwise.
function canopen_queue_tx¶
Helper function to queue a CAN transmit frame.
static void canopen_queue_tx (
SYN_CANOpenNode * node,
uint32_t cob_id,
const uint8_t * data,
uint8_t len
)
Parameters:
nodePointer to node handle.cob_id11-bit CAN COB-ID.dataPayload data pointer.lenPayload length.
function canopen_send_sdo_abort¶
Send an SDO Abort frame.
static void canopen_send_sdo_abort (
SYN_CANOpenNode * node,
uint16_t index,
uint8_t subindex,
uint32_t abort_code
)
Parameters:
nodePointer to node handle.index16-bit OD Index.subindex8-bit OD Subindex.abort_code32-bit SDO Abort code.
The documentation for this class was generated from the following file src/syntropic/proto/syn_canopen.c