PebbleOS v4.47.0-1219-g7c542d7a9
Loading...
Searching...
No Matches
canopen.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <pbl/drivers/can.h>
#include <pbl/kernel/msgq.h>
#include <pbl/kernel/mutex.h>
#include <pbl/kernel/work.h>
#include <pbl/util/bits.h>

Data Structures

struct  pbl_canopen_od_entry
 An object dictionary entry: one sub-index of an object. More...
 
struct  pbl_canopen_od
 An object dictionary, generated by pbl_canopen_od(). More...
 
struct  pbl_canopen_callbacks
 Node callbacks, all called from the node's thread. More...
 
struct  pbl_canopen_config
 Node configuration. More...
 

Macros

Entry attributes
#define PBL_CANOPEN_ATTR_READ   PBL_BIT(0)
 Readable over the bus.
 
#define PBL_CANOPEN_ATTR_WRITE   PBL_BIT(1)
 Writable over the bus.
 
#define PBL_CANOPEN_ATTR_TPDO   PBL_BIT(2)
 Mappable to a TPDO.
 
#define PBL_CANOPEN_ATTR_RPDO   PBL_BIT(3)
 Mappable to an RPDO.
 
#define PBL_CANOPEN_ATTR_NODEID   PBL_BIT(4)
 Default value plus the node-ID.
 

Enumerations

enum  pbl_canopen_type {
  PBL_CANOPEN_TYPE_BOOLEAN = 0x01 , PBL_CANOPEN_TYPE_INTEGER8 = 0x02 , PBL_CANOPEN_TYPE_INTEGER16 = 0x03 , PBL_CANOPEN_TYPE_INTEGER32 = 0x04 ,
  PBL_CANOPEN_TYPE_UNSIGNED8 = 0x05 , PBL_CANOPEN_TYPE_UNSIGNED16 = 0x06 , PBL_CANOPEN_TYPE_UNSIGNED32 = 0x07 , PBL_CANOPEN_TYPE_REAL32 = 0x08 ,
  PBL_CANOPEN_TYPE_VISIBLE_STRING = 0x09 , PBL_CANOPEN_TYPE_OCTET_STRING = 0x0a , PBL_CANOPEN_TYPE_REAL64 = 0x11 , PBL_CANOPEN_TYPE_INTEGER64 = 0x15 ,
  PBL_CANOPEN_TYPE_UNSIGNED64 = 0x1b
}
 Data types of object dictionary entries. More...
 
enum  pbl_canopen_nmt_state { PBL_CANOPEN_NMT_INITIALIZING = 0x00 , PBL_CANOPEN_NMT_STOPPED = 0x04 , PBL_CANOPEN_NMT_OPERATIONAL = 0x05 , PBL_CANOPEN_NMT_PRE_OPERATIONAL = 0x7f }
 NMT states, with their heartbeat codes. More...
 
enum  pbl_canopen_reset { PBL_CANOPEN_RESET_COMM , PBL_CANOPEN_RESET_NODE }
 Resets, as requested by the NMT master. More...
 
enum  pbl_canopen_hb_event { PBL_CANOPEN_HB_BOOT , PBL_CANOPEN_HB_STATE , PBL_CANOPEN_HB_TIMEOUT }
 Heartbeat consumer events. More...
 

Functions

int pbl_canopen_init (struct pbl_canopen *co, const struct pbl_canopen_config *cfg)
 Initialize a node, stopped.
 
int pbl_canopen_start (struct pbl_canopen *co)
 Start the node: join the bus, restore every default and go pre-operational.
 
int pbl_canopen_stop (struct pbl_canopen *co)
 Stop the node and leave the bus.
 
enum pbl_canopen_nmt_state pbl_canopen_nmt_state (struct pbl_canopen *co)
 Get the NMT state.
 
int pbl_canopen_od_read (struct pbl_canopen *co, uint16_t index, uint8_t subindex, void *data, size_t len)
 Read an entry of the object dictionary.
 
int pbl_canopen_od_write (struct pbl_canopen *co, uint16_t index, uint8_t subindex, const void *data, size_t len)
 Write an entry of the object dictionary, whatever its access over the bus.
 
int pbl_canopen_tpdo_request (struct pbl_canopen *co, uint16_t num)
 Request the transmission of a TPDO.
 
int pbl_canopen_emcy_raise (struct pbl_canopen *co, uint16_t code, uint8_t reg, const uint8_t *msef)
 Raise an error: set its error register bits, add it to the error history and send an emergency message.
 
int pbl_canopen_emcy_clear (struct pbl_canopen *co, uint16_t code)
 Clear an error raised by pbl_canopen_emcy_raise(), and send an error reset message.