Lely core libraries 2.3.4
emcy.h
Go to the documentation of this file.
1
22#ifndef LELY_CO_EMCY_H_
23#define LELY_CO_EMCY_H_
24
25#include <lely/can/net.h>
26#include <lely/co/type.h>
27
29#define CO_EMCY_COBID_VALID UINT32_C(0x80000000)
30
35#define CO_EMCY_COBID_FRAME UINT32_C(0x20000000)
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
52typedef void co_emcy_ind_t(co_emcy_t *emcy, co_unsigned8_t id,
53 co_unsigned16_t eec, co_unsigned8_t er, co_unsigned8_t msef[5],
54 void *data);
55
56void *__co_emcy_alloc(void);
57void __co_emcy_free(void *ptr);
58struct __co_emcy *__co_emcy_init(
59 struct __co_emcy *emcy, can_net_t *net, co_dev_t *dev);
60void __co_emcy_fini(struct __co_emcy *emcy);
61
75
77void co_emcy_destroy(co_emcy_t *emcy);
78
89int co_emcy_start(co_emcy_t *emcy);
90
98void co_emcy_stop(co_emcy_t *emcy);
99
105int co_emcy_is_stopped(const co_emcy_t *emcy);
106
109
114
129int co_emcy_push(co_emcy_t *emcy, co_unsigned16_t eec, co_unsigned8_t er,
130 const co_unsigned8_t msef[5]);
131
146int co_emcy_pop(co_emcy_t *emcy, co_unsigned16_t *peec, co_unsigned8_t *per);
147
159void co_emcy_peek(const co_emcy_t *emcy, co_unsigned16_t *peec,
160 co_unsigned8_t *per);
161
176int co_emcy_remove(co_emcy_t *emcy, size_t n);
177
189ssize_t co_emcy_find(const co_emcy_t *emcy, co_unsigned16_t eec);
190
200int co_emcy_clear(co_emcy_t *emcy);
201
214void co_emcy_get_ind(const co_emcy_t *emcy, co_emcy_ind_t **pind, void **pdata);
215
226void co_emcy_set_ind(co_emcy_t *emcy, co_emcy_ind_t *ind, void *data);
227
228#ifdef __cplusplus
229}
230#endif
231
232#endif // !LELY_CO_EMCY_H_
void co_emcy_destroy(co_emcy_t *emcy)
Destroys a CANopen EMCY producer/consumer service.
Definition: emcy.c:360
void co_emcy_get_ind(const co_emcy_t *emcy, co_emcy_ind_t **pind, void **pdata)
Retrieves the indication function invoked when a CANopen EMCY message is received.
Definition: emcy.c:614
int co_emcy_is_stopped(const co_emcy_t *emcy)
Retuns 1 if the specified EMCY service is stopped, and 0 if not.
Definition: emcy.c:446
int co_emcy_remove(co_emcy_t *emcy, size_t n)
Pops a CANopen EMCY message from the stack, even if it is not the most recent message,...
Definition: emcy.c:551
int co_emcy_push(co_emcy_t *emcy, co_unsigned16_t eec, co_unsigned8_t er, const co_unsigned8_t msef[5])
Pushes a CANopen EMCY message to the stack and broadcasts it if the EMCY producer service is active.
Definition: emcy.c:470
co_emcy_t * co_emcy_create(can_net_t *net, co_dev_t *dev)
Creates a new CANopen EMCY producer/consumer service.
Definition: emcy.c:333
void co_emcy_ind_t(co_emcy_t *emcy, co_unsigned8_t id, co_unsigned16_t eec, co_unsigned8_t er, co_unsigned8_t msef[5], void *data)
The type of a CANopen EMCY indication function, invoked when an EMCY message is received.
Definition: emcy.h:52
int co_emcy_start(co_emcy_t *emcy)
Starts an EMCY service.
Definition: emcy.c:370
int co_emcy_clear(co_emcy_t *emcy)
Clears the CANopen EMCY message stack and broadcasts the 'error reset/no error' message if the EMCY p...
Definition: emcy.c:595
can_net_t * co_emcy_get_net(const co_emcy_t *emcy)
Returns a pointer to the CAN network of an EMCY producer/consumer service.
Definition: emcy.c:454
int co_emcy_pop(co_emcy_t *emcy, co_unsigned16_t *peec, co_unsigned8_t *per)
Pops the most recent CANopen EMCY message from the stack and broadcasts an 'error reset' message if t...
Definition: emcy.c:526
void co_emcy_peek(const co_emcy_t *emcy, co_unsigned16_t *peec, co_unsigned8_t *per)
Retrieves, but does not pop, the most recent CANopen EMCY message from the stack.
Definition: emcy.c:536
ssize_t co_emcy_find(const co_emcy_t *emcy, co_unsigned16_t eec)
Finds a CANopen EMCY message in the stack.
Definition: emcy.c:582
co_dev_t * co_emcy_get_dev(const co_emcy_t *emcy)
Returns a pointer to the CANopen device of an EMCY producer/consumer service.
Definition: emcy.c:462
void co_emcy_stop(co_emcy_t *emcy)
Stops an EMCY service.
Definition: emcy.c:410
void co_emcy_set_ind(co_emcy_t *emcy, co_emcy_ind_t *ind, void *data)
Sets the indication function invoked when a CANopen EMCY message is received.
Definition: emcy.c:625
This header file is part of the CAN library; it contains the CAN network interface declarations.
A CAN network interface.
Definition: net.c:37
A CANopen device.
Definition: dev.h:30
A CANopen EMCY producer/consumer service.
Definition: emcy.c:85
co_dev_t * dev
A pointer to a CANopen device.
Definition: emcy.c:89
void * data
A pointer to user-specified data for ind.
Definition: emcy.c:122
co_emcy_ind_t * ind
A pointer to the indication function.
Definition: emcy.c:120
can_net_t * net
A pointer to a CAN network interface.
Definition: emcy.c:87
This header file is part of the CANopen library; it contains the CANopen type definitions.