Lely core libraries  2.2.5
time.h
Go to the documentation of this file.
1 
22 #ifndef LELY_CO_TIME_H_
23 #define LELY_CO_TIME_H_
24 
25 #include <lely/can/net.h>
26 #include <lely/co/type.h>
27 
29 #define CO_TIME_COBID_CONSUMER UINT32_C(0x80000000)
30 
32 #define CO_TIME_COBID_PRODUCER UINT32_C(0x40000000)
33 
38 #define CO_TIME_COBID_FRAME UINT32_C(0x20000000)
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
52 typedef void co_time_ind_t(
53  co_time_t *time, const struct timespec *tp, void *data);
54 
60 void co_time_of_day_get(const co_time_of_day_t *tod, struct timespec *tp);
61 
67 void co_time_of_day_set(co_time_of_day_t *tod, const struct timespec *tp);
68 
74 void co_time_diff_get(const co_time_diff_t *td, struct timespec *tp);
75 
81 void co_time_diff_set(co_time_diff_t *td, const struct timespec *tp);
82 
83 void *__co_time_alloc(void);
84 void __co_time_free(void *ptr);
85 struct __co_time *__co_time_init(
86  struct __co_time *time, can_net_t *net, co_dev_t *dev);
87 void __co_time_fini(struct __co_time *time);
88 
101 
103 void co_time_destroy(co_time_t *time);
104 
106 can_net_t *co_time_get_net(const co_time_t *time);
107 
109 co_dev_t *co_time_get_dev(const co_time_t *time);
110 
123 void co_time_get_ind(const co_time_t *time, co_time_ind_t **pind, void **pdata);
124 
135 void co_time_set_ind(co_time_t *time, co_time_ind_t *ind, void *data);
136 
153 void co_time_start(co_time_t *time, const struct timespec *start,
154  const struct timespec *interval);
155 
157 void co_time_stop(co_time_t *time);
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif // !LELY_CO_TIME_H_
void co_time_of_day_get(const co_time_of_day_t *tod, struct timespec *tp)
Loads the absolute time from a CANopen TIME_OF_DAY value.
Definition: time.c:95
void co_time_destroy(co_time_t *time)
Destroys a CANopen TIME producer/consumer service.
Definition: time.c:250
A CAN network interface.
Definition: net.c:37
This header file is part of the CAN library; it contains the CAN network interface declarations...
co_dev_t * co_time_get_dev(const co_time_t *time)
Returns a pointer to the CANopen device of a TIME producer/consumer service.
Definition: time.c:268
co_time_t * co_time_create(can_net_t *net, co_dev_t *dev)
Creates a new CANopen TIME producer/consumer service.
Definition: time.c:223
co_time_ind_t * ind
A pointer to the indication function.
Definition: time.c:57
void co_time_of_day_set(co_time_of_day_t *tod, const struct timespec *tp)
Stores the absolute time into a CANopen TIME_OF_DAY value.
Definition: time.c:108
void co_time_diff_get(const co_time_diff_t *td, struct timespec *tp)
Loads a time difference from a CANopen TIME_DIFFERENCE value.
Definition: time.c:124
can_net_t * co_time_get_net(const co_time_t *time)
Returns a pointer to the CAN network of a TIME producer/consumer service.
Definition: time.c:260
A CANopen TIME producer/consumer service.
Definition: time.c:41
A CANopen device.
Definition: dev.c:41
void co_time_diff_set(co_time_diff_t *td, const struct timespec *tp)
Stores a time difference into a CANopen TIME_DIFFERENCE value.
Definition: time.c:134
void co_time_ind_t(co_time_t *time, const struct timespec *tp, void *data)
The type of a CANopen TIME indication function, invoked when a time stamp is received.
Definition: time.h:52
struct timespec start
The creation time of the service.
Definition: time.c:55
void co_time_start(co_time_t *time, const struct timespec *start, const struct timespec *interval)
Starts a CANopen TIME producer.
Definition: time.c:296
void co_time_set_ind(co_time_t *time, co_time_ind_t *ind, void *data)
Sets the indication function invoked when a CANopen time stamp is received.
Definition: time.c:287
void co_time_get_ind(const co_time_t *time, co_time_ind_t **pind, void **pdata)
Retrieves the indication function invoked when a CANopen time stamp is received.
Definition: time.c:276
can_net_t * net
A pointer to a CAN network interface.
Definition: time.c:43
void * data
A pointer to user-specified data for ind.
Definition: time.c:59
void co_time_stop(co_time_t *time)
Stops a CANopen TIME producer.
Definition: time.c:306
co_dev_t * dev
A pointer to a CANopen device.
Definition: time.c:45
This header file is part of the CANopen library; it contains the CANopen type definitions.