Lely core libraries 2.3.4
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
41extern "C" {
42#endif
43
52typedef void co_time_ind_t(
53 co_time_t *time, const struct timespec *tp, void *data);
54
60void co_time_of_day_get(const co_time_of_day_t *tod, struct timespec *tp);
61
67void co_time_of_day_set(co_time_of_day_t *tod, const struct timespec *tp);
68
74void co_time_diff_get(const co_time_diff_t *td, struct timespec *tp);
75
81void co_time_diff_set(co_time_diff_t *td, const struct timespec *tp);
82
83void *__co_time_alloc(void);
84void __co_time_free(void *ptr);
85struct __co_time *__co_time_init(
86 struct __co_time *time, can_net_t *net, co_dev_t *dev);
87void __co_time_fini(struct __co_time *time);
88
102
104void co_time_destroy(co_time_t *time);
105
116int co_time_start(co_time_t *time);
117
126void co_time_stop(co_time_t *time);
127
133int co_time_is_stopped(const co_time_t *time);
134
137
140
153void co_time_get_ind(const co_time_t *time, co_time_ind_t **pind, void **pdata);
154
165void co_time_set_ind(co_time_t *time, co_time_ind_t *ind, void *data);
166
183void co_time_start_prod(co_time_t *time, const struct timespec *start,
184 const struct timespec *interval);
185
187void co_time_stop_prod(co_time_t *time);
188
189#ifdef __cplusplus
190}
191#endif
192
193#endif // !LELY_CO_TIME_H_
void co_time_stop(co_time_t *time)
Stops a TIME service.
Definition time.c:300
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:240
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:355
void co_time_stop_prod(co_time_t *time)
Stops a CANopen TIME producer.
Definition time.c:374
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
int co_time_is_stopped(const co_time_t *time)
Retuns 1 if the specified TIME service is stopped, and 0 if not.
Definition time.c:320
void co_time_destroy(co_time_t *time)
Destroys a CANopen TIME producer/consumer service.
Definition time.c:267
int co_time_start(co_time_t *time)
Starts a TIME service.
Definition time.c:277
void co_time_start_prod(co_time_t *time, const struct timespec *start, const struct timespec *interval)
Starts a CANopen TIME producer.
Definition time.c:364
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:344
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:328
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:128
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:138
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:109
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
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:336
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 TIME producer/consumer service.
Definition time.c:41
void * data
A pointer to user-specified data for ind.
Definition time.c:61
can_net_t * net
A pointer to a CAN network interface.
Definition time.c:43
co_time_ind_t * ind
A pointer to the indication function.
Definition time.c:59
struct timespec start
The creation time of the service.
Definition time.c:57
co_dev_t * dev
A pointer to a CANopen device.
Definition time.c:45
A time type with nanosecond resolution.
Definition time.h:88
This header file is part of the CANopen library; it contains the CANopen type definitions.