File syn_canopen.h¶
FileList > proto > syn_canopen.h
Go to the source code of this file
CANopen DS301 Slave Protocol Engine. More...
#include "../common/syn_defs.h"#include "../drivers/syn_can.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_CANOpenNode CANopen Node State Handle. |
| struct | SYN_CANOpenNodeConfig CANopen Node Configuration. |
| struct | SYN_CANOpenODEntry Object Dictionary Entry Definition. |
| struct | SYN_CANOpenPDOMap PDO Mapping Configuration. |
| struct | SYN_CANOpenSDOSession |
Public Types¶
| Type | Name |
|---|---|
| enum | SYN_CANOpenSDOState |
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). |
Macros¶
Detailed Description¶
Implements a lightweight, non-blocking, zero-malloc CANopen DS301 slave stack including Object Dictionary, SDO server, RPDO/TPDO engine, NMT state machine, Heartbeat producer, and Emergency (EMCY) alarms.
Public Types Documentation¶
enum SYN_CANOpenSDOState¶
enum SYN_CANOpenSDOState {
SYN_CANOPEN_SDO_IDLE = 0,
SYN_CANOPEN_SDO_SEG_DOWNLOAD,
SYN_CANOPEN_SDO_SEG_UPLOAD
};
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.
Macro Definition Documentation¶
define SYN_CANOPEN_ACCESS_RO¶
OD Access Rights.
Read-Only access
define SYN_CANOPEN_ACCESS_RW¶
Read/Write access
define SYN_CANOPEN_ACCESS_WO¶
Write-Only access
define SYN_CANOPEN_NMT_CMD_PREOP¶
Enter Pre-Operational
define SYN_CANOPEN_NMT_CMD_RESET_COMM¶
Reset Communication
define SYN_CANOPEN_NMT_CMD_RESET_NODE¶
Reset Node
define SYN_CANOPEN_NMT_CMD_START¶
CANopen NMT Command Specifiers.
Start Remote Node
define SYN_CANOPEN_NMT_CMD_STOP¶
Stop Remote Node
define SYN_CANOPEN_NMT_STATE_BOOTUP¶
CANopen NMT States.
Bootup State
define SYN_CANOPEN_NMT_STATE_OPERATIONAL¶
Operational State
define SYN_CANOPEN_NMT_STATE_PREOP¶
Pre-Operational State
define SYN_CANOPEN_NMT_STATE_STOPPED¶
Stopped State
define SYN_CANOPEN_SDO_ABORT_NONE¶
SDO Abort Codes.
No error
define SYN_CANOPEN_SDO_ABORT_NOT_EXIST¶
Object does not exist in dictionary
define SYN_CANOPEN_SDO_ABORT_READ_ONLY¶
Attempt to write a read only object
define SYN_CANOPEN_SDO_ABORT_SUBINDEX_NOT_EXIST¶
Subindex does not exist
define SYN_CANOPEN_SDO_ABORT_TOGGLE_BIT¶
Toggle bit not altered
define SYN_CANOPEN_SDO_ABORT_TYPE_MISMATCH¶
Data type mismatch, length mismatch \
define SYN_CANOPEN_SDO_ABORT_UNSUPPORTED_ACCESS¶
Unsupported access to object
define SYN_CANOPEN_SDO_ABORT_WRITE_ONLY¶
Attempt to read a write only object
define SYN_CANOPEN_TYPE_I16¶
Signed 16-bit integer
define SYN_CANOPEN_TYPE_I32¶
Signed 32-bit integer
define SYN_CANOPEN_TYPE_I8¶
OD Data Types.
Signed 8-bit integer
define SYN_CANOPEN_TYPE_U16¶
Unsigned 16-bit integer
define SYN_CANOPEN_TYPE_U32¶
Unsigned 32-bit integer
define SYN_CANOPEN_TYPE_U8¶
Unsigned 8-bit integer
The documentation for this class was generated from the following file src/syntropic/proto/syn_canopen.h