Lely core libraries 2.3.4
|
This file is part of the CANopen library; it contains the implementation of the time stamp (TIME) object functions. More...
#include "co.h"
#include <lely/co/dev.h>
#include <lely/co/obj.h>
#include <lely/co/sdo.h>
#include <lely/co/time.h>
#include <lely/co/val.h>
#include <lely/util/endian.h>
#include <lely/util/errnum.h>
#include <lely/util/time.h>
#include <assert.h>
#include <stdlib.h>
Go to the source code of this file.
Data Structures | |
struct | __co_time |
A CANopen TIME producer/consumer service. More... | |
Functions | |
static void | co_time_update (co_time_t *time) |
Updates and (de)activates a TIME producer/consumer service. | |
static co_unsigned32_t | co_1012_dn_ind (co_sub_t *sub, struct co_sdo_req *req, void *data) |
The download indication function for (all sub-objects of) CANopen object 1012 (COB-ID time stamp object). | |
static int | co_time_recv (const struct can_msg *msg, void *data) |
The CAN receive callback function for a TIME consumer service. | |
static int | co_time_timer (const struct timespec *tp, void *data) |
The CAN timer callback function for a TIME producer service. | |
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. | |
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. | |
void | co_time_diff_get (const co_time_diff_t *td, struct timespec *tp) |
Loads a time difference from a CANopen TIME_DIFFERENCE value. | |
void | co_time_diff_set (co_time_diff_t *td, const struct timespec *tp) |
Stores a time difference into a CANopen TIME_DIFFERENCE value. | |
co_time_t * | co_time_create (can_net_t *net, co_dev_t *dev) |
Creates a new CANopen TIME producer/consumer service. | |
void | co_time_destroy (co_time_t *time) |
Destroys a CANopen TIME producer/consumer service. | |
int | co_time_start (co_time_t *time) |
Starts a TIME service. | |
void | co_time_stop (co_time_t *time) |
Stops a TIME service. | |
int | co_time_is_stopped (const co_time_t *time) |
Retuns 1 if the specified TIME service is stopped, and 0 if not. | |
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. | |
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. | |
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. | |
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. | |
void | co_time_start_prod (co_time_t *time, const struct timespec *start, const struct timespec *interval) |
Starts a CANopen TIME producer. | |
void | co_time_stop_prod (co_time_t *time) |
Stops a CANopen TIME producer. | |
This file is part of the CANopen library; it contains the implementation of the time stamp (TIME) object functions.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file time.c.
|
static |
|
static |
The download indication function for (all sub-objects of) CANopen object 1012 (COB-ID time stamp object).
|
static |
The CAN receive callback function for a TIME consumer service.
|
static |
The CAN timer callback function for a TIME producer service.
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.
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.
void co_time_diff_get | ( | const co_time_diff_t * | td, |
struct timespec * | tp | ||
) |
Loads a time difference from a CANopen TIME_DIFFERENCE value.
void co_time_diff_set | ( | co_time_diff_t * | td, |
const struct timespec * | tp | ||
) |
Stores a time difference into a CANopen TIME_DIFFERENCE value.
Creates a new CANopen TIME producer/consumer service.
The service is started as if by co_time_start().
net | a pointer to a CAN network. |
dev | a pointer to a CANopen device. |
void co_time_destroy | ( | co_time_t * | time | ) |
Destroys a CANopen TIME producer/consumer service.
int co_time_start | ( | co_time_t * | time | ) |
Starts a TIME service.
void co_time_stop | ( | co_time_t * | time | ) |
Stops a TIME service.
This function invokes co_time_stop_prod() to stop the TIME producer, if necessary.
int co_time_is_stopped | ( | const co_time_t * | time | ) |
Retuns 1 if the specified TIME service is stopped, and 0 if not.
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.
time | a pointer to a TIME consumer service. |
pind | the address at which to store a pointer to the indication function (can be NULL). |
pdata | the address at which to store a pointer to user-specified data (can be NULL). |
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.
time | a pointer to a TIME consumer service. |
ind | a pointer to the function to be invoked. |
data | a pointer to user-specified data (can be NULL). data is passed as the last parameter to ind. |
void co_time_start_prod | ( | co_time_t * | time, |
const struct timespec * | start, | ||
const struct timespec * | interval | ||
) |
Starts a CANopen TIME producer.
This function has no effect if the TIME service is not a producer.
time | a pointer to a TIME producer service. |
start | a pointer to the absolute time when the next time stamp is to be sent. If start is NULL, this time is given by interval with respect to the current time as obtained with can_net_get_time(). If interval is also NULL, the producer is stopped. |
interval | a pointer to the interval between successive time stamps. If interval is NULL, only a single time stamp is sent, at the time given by start. |
void co_time_stop_prod | ( | co_time_t * | time | ) |