26 #ifndef LELY_NO_CO_MASTER 66 co_unsigned8_t subidx, co_unsigned32_t ac,
void *data);
84 co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac);
121 co_unsigned8_t subidx, co_unsigned32_t ac);
126 #define LELY_CO_DEFINE_STATE(name, ...) \ 127 static co_nmt_cfg_state_t *const name = \ 128 &(co_nmt_cfg_state_t){ __VA_ARGS__ }; 138 LELY_CO_DEFINE_STATE(co_nmt_cfg_init_state,
148 LELY_CO_DEFINE_STATE(co_nmt_cfg_abort_state,
161 co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac);
164 LELY_CO_DEFINE_STATE(co_nmt_cfg_restore_state,
170 #undef LELY_CO_DEFINE_STATE 173 __co_nmt_cfg_alloc(
void)
182 __co_nmt_cfg_free(
void *ptr)
228 goto error_alloc_cfg;
239 __co_nmt_cfg_free(cfg);
249 __co_nmt_cfg_fini(cfg);
250 __co_nmt_cfg_free(cfg);
297 co_unsigned32_t
ac,
void *data)
324 co_unsigned8_t subidx, co_unsigned32_t
ac)
356 return co_nmt_cfg_abort_state;
370 return co_nmt_cfg_abort_state;
375 return co_nmt_cfg_abort_state;
377 return co_nmt_cfg_restore_state;
397 co_unsigned8_t subidx = co_dev_get_val_u8(cfg->
dev, 0x1f8a, cfg->
id);
401 return co_nmt_cfg_abort_state;
407 &(co_unsigned32_t){ UINT32_C(0x64616f6c) },
411 return co_nmt_cfg_abort_state;
419 co_unsigned8_t subidx, co_unsigned32_t
ac)
426 return co_nmt_cfg_abort_state;
442 return co_nmt_cfg_abort_state;
445 #endif // !LELY_NO_CO_MASTER int co_nmt_cs_req(co_nmt_t *nmt, co_unsigned8_t cs, co_unsigned8_t id)
Submits an NMT request to a slave.
void co_csdo_set_timeout(co_csdo_t *sdo, int timeout)
Sets the timeout of a Client-SDO.
static void co_nmt_cfg_emit_res(co_nmt_cfg_t *cfg, co_unsigned32_t ac)
Invokes the 'result received' transition function of the current state of a 'configuration request'...
void co_nmt_cfg_destroy(co_nmt_cfg_t *cfg)
Destroys a CANopen NMT 'configuration request'.
static void co_nmt_cfg_dn_con(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac, void *data)
The CANopen SDO download confirmation callback function for a 'configuration request'.
void set_errnum(errnum_t errnum)
Sets the current (thread-specific) platform-independent error number to errnum.
void(* on_leave)(co_nmt_cfg_t *cfg)
A pointer to the function invoked when the current state is left.
void co_nmt_cfg_ind(co_nmt_t *nmt, co_unsigned8_t id, co_csdo_t *sdo)
The CANopen NMT 'update configuration' indication function, invoked when a configuration request is r...
static co_nmt_cfg_state_t * co_nmt_cfg_restore_on_dn_con(co_nmt_cfg_t *cfg, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac)
The 'SDO download confirmation' transition function of the 'restore configuration' state...
#define CO_SDO_AC_ERROR
SDO abort code: General error.
int co_csdo_dn_val_req(co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned16_t type, const void *val, co_csdo_dn_con_t *con, void *data)
Submits a download request to a remote Server-SDO.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
co_unsigned32_t ac
The SDO abort code.
#define CO_DEFTYPE_UNSIGNED32
The data type (and object index) of a 32-bit unsigned integer.
This header file is part of the utilities library; it contains the native and platform-independent er...
static co_nmt_cfg_state_t * co_nmt_cfg_init_on_res(co_nmt_cfg_t *cfg, co_unsigned32_t ac)
The 'result received' function of the 'initialization' state.
co_nmt_cfg_state_t *(* on_enter)(co_nmt_cfg_t *cfg)
A pointer to the function invoked when a new state is entered.
This is the internal header file of the CANopen library.
#define CO_NMT_CS_RESET_NODE
The NMT command specifier 'reset node'.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function...
static void co_nmt_cfg_emit_dn_con(co_nmt_cfg_t *cfg, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac)
Invokes the 'SDO download confirmation' transition function of the current state of a 'boot slave' se...
void co_csdo_set_dn_ind(co_csdo_t *sdo, co_csdo_ind_t *ind, void *data)
Sets the indication function used to notify the user of the progress of the current SDO download requ...
A CANopen NMT master/slave service.
co_nmt_cfg_t * co_nmt_cfg_create(can_net_t *net, co_dev_t *dev, co_nmt_t *nmt)
Creates a new CANopen NMT 'configuration request'.
#define CO_NUM_NODES
The maximum number of nodes in a CANopen network.
co_dev_t * dev
A pointer to a CANopen device.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
#define __unlikely(x)
Indicates to the compiler that the expression is most-likely false.
A CANopen NMT 'configuration request' service.
void co_csdo_ind_t(const co_csdo_t *sdo, co_unsigned16_t idx, co_unsigned8_t subidx, size_t size, size_t nbyte, void *data)
The type of a CANopen Client-SDO request progress indication function, used to notify the user of the...
co_unsigned32_t assignment
The NMT slave assignment (object 1F81).
co_csdo_t * co_csdo_create(can_net_t *net, co_dev_t *dev, co_unsigned8_t num)
Creates a new CANopen Client-SDO service.
This is the internal header file of the NMT 'configuration request' declarations. ...
void co_csdo_destroy(co_csdo_t *sdo)
Destroys a CANopen Client-SDO service.
co_nmt_cfg_state_t * state
A pointer to the current state.
This header file is part of the CANopen library; it contains the device description declarations...
A CANopen NMT 'configuration request' state.
co_nmt_t * nmt
A pointer to an NMT master service.
can_net_t * net
A pointer to a CAN network interface.
co_nmt_cfg_state_t *(* on_res)(co_nmt_cfg_t *cfg, co_unsigned32_t ac)
A pointer to the transition function invoked when an NMT'update configuration' step completes...
co_csdo_t * sdo
A pointer to the Client-SDO used to access slave objects.
static co_nmt_cfg_state_t * co_nmt_cfg_restore_on_enter(co_nmt_cfg_t *cfg)
The entry function of the 'restore configuration' state.
void co_nmt_cfg_con(co_nmt_t *nmt, co_unsigned8_t id, co_unsigned32_t ac)
The CANopen NMT 'configuration request' confirmation function, invoked when a configuration request c...
co_nmt_cfg_state_t *(* on_dn_con)(co_nmt_cfg_t *cfg, co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac)
A pointer to the transition function invoked when an SDO download request completes.
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib.h> and defines any missing functionality.
static void co_nmt_cfg_enter(co_nmt_cfg_t *cfg, co_nmt_cfg_state_t *next)
Enters the specified state of a 'configuration request; and invokes the exit and entry functions...
int co_nmt_cfg_cfg_res(co_nmt_cfg_t *cfg, co_unsigned32_t ac)
Indicates the result of the 'update configuration' step of an NMT 'configuration request'.
static co_nmt_cfg_state_t * co_nmt_cfg_init_on_enter(co_nmt_cfg_t *cfg)
The entry function of the 'initialization' state.
co_unsigned8_t id
The node-ID.
#define CO_NMT_CS_RESET_COMM
The NMT command specifier 'reset communication'.
static co_nmt_cfg_state_t * co_nmt_cfg_abort_on_enter(co_nmt_cfg_t *cfg)
The entry function of the 'abort' state.
void co_csdo_set_up_ind(co_csdo_t *sdo, co_csdo_ind_t *ind, void *data)
Sets the indication function used to notify the user of the progress of the current SDO upload reques...
int co_nmt_cfg_cfg_req(co_nmt_cfg_t *cfg, co_unsigned8_t id, int timeout, co_csdo_ind_t *dn_ind, co_csdo_ind_t *up_ind, void *data)
Starts a CANopen NMT 'configuration request'.