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__ };
138LELY_CO_DEFINE_STATE(co_nmt_cfg_init_state,
148LELY_CO_DEFINE_STATE(co_nmt_cfg_abort_state,
161 co_unsigned16_t idx, co_unsigned8_t subidx, co_unsigned32_t ac);
164LELY_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;
void co_csdo_set_timeout(co_csdo_t *sdo, int timeout)
Sets the timeout of a Client-SDO.
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...
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...
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...
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.
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 co_csdo_destroy(co_csdo_t *sdo)
Destroys a CANopen Client-SDO service.
This header file is part of the CANopen library; it contains the device description declarations.
#define CO_NUM_NODES
The maximum number of nodes in a CANopen network.
This header file is part of the utilities library; it contains the native and platform-independent er...
@ ERRNUM_INVAL
Invalid argument.
@ ERRNUM_INPROGRESS
Operation in progress.
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
void set_errnum(errnum_t errnum)
Sets the current (thread-specific) platform-independent error number to errnum.
#define __unlikely(x)
Indicates to the compiler that the expression is most-likely false.
#define CO_SDO_AC_ERROR
SDO abort code: General error.
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...
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...
#define CO_NMT_CS_RESET_NODE
The NMT command specifier 'reset node'.
int co_nmt_cs_req(co_nmt_t *nmt, co_unsigned8_t cs, co_unsigned8_t id)
Submits an NMT request to a slave.
#define CO_NMT_CS_RESET_COMM
The NMT command specifier 'reset communication'.
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.
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_nmt_cfg_destroy(co_nmt_cfg_t *cfg)
Destroys a CANopen NMT 'configuration request'.
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'.
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.
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.
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'.
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_restore_on_enter(co_nmt_cfg_t *cfg)
The entry function of the 'restore configuration' state.
static co_nmt_cfg_state_t * co_nmt_cfg_init_on_enter(co_nmt_cfg_t *cfg)
The entry function of the 'initialization' state.
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'.
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...
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'.
This is the internal header file of the NMT 'configuration request' declarations.
This is the internal header file of the CANopen library.
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib....
A CANopen NMT 'configuration request' state.
void(* on_leave)(co_nmt_cfg_t *cfg)
A pointer to the function invoked when the current state is left.
co_nmt_cfg_state_t *(* on_enter)(co_nmt_cfg_t *cfg)
A pointer to the function invoked when a new state is entered.
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.
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.
A CANopen NMT 'configuration request' service.
co_nmt_t * nmt
A pointer to an NMT master service.
co_nmt_cfg_state_t * state
A pointer to the current state.
co_unsigned32_t ac
The SDO abort code.
co_dev_t * dev
A pointer to a CANopen device.
co_unsigned32_t assignment
The NMT slave assignment (object 1F81).
can_net_t * net
A pointer to a CAN network interface.
co_unsigned8_t id
The node-ID.
co_csdo_t * sdo
A pointer to the Client-SDO used to access slave objects.
A CANopen NMT master/slave service.
#define CO_DEFTYPE_UNSIGNED32
The data type (and object index) of a 32-bit unsigned integer.