Loading...
Searching...
No Matches
device.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 OTA keys S.A.
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser General
5 * Public License v2.1. See the file LICENSE in the top level directory for more
6 * details.
7 */
8
20#ifndef CAN_DEVICE_H
21#define CAN_DEVICE_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include "can/candev.h"
28#include "sched.h"
29
30#ifdef MODULE_CAN_PM
31#include "ztimer.h"
32#endif
33#ifdef MODULE_CAN_TRX
34#include "can/can_trx.h"
35#endif
36
37#ifndef CAN_MAX_RATE_ERROR
42#define CAN_MAX_RATE_ERROR (50) /* 5 % */
43#endif
44
45#ifndef CAN_DLL_NUMOF
49#define CAN_DLL_NUMOF (1)
50#endif
51
55typedef struct candev_params {
56 const char *name;
57#if defined(MODULE_CAN_TRX) || defined(DOXYGEN)
59#endif
60#if defined(MODULE_CAN_PM) || defined(DOXYGEN)
63#endif
65
69typedef struct candev_dev {
71 int ifnum;
73 const char *name;
74#if defined(MODULE_CAN_TRX) || defined(DOXYGEN)
76#endif
77#if defined(MODULE_CAN_PM) || defined(DOXYGEN)
80 uint32_t last_pm_update;
81 uint32_t last_pm_value;
83#endif
85
99kernel_pid_t can_device_init(char *stack, int stacksize, char priority,
100 const char *name, candev_dev_t *params);
101
112int can_device_calc_bittiming(uint32_t clock, const struct can_bittiming_const *timing_const,
113 struct can_bittiming *bittiming);
114
115#ifdef __cplusplus
116}
117#endif
118
119#endif /* CAN_DEVICE_H */
120
CAN generic transceiver interface.
Definitions for low-level CAN driver interface.
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:139
Scheduler API definition.
CAN hardware-dependent bit-timing constant.
Definition can.h:132
CAN bit-timing parameters.
Definition can.h:116
Generic transceiver descriptor.
Definition can_trx.h:48
candev descriptor to pass to the device thread
Definition device.h:69
int ifnum
interface number
Definition device.h:71
candev_t * dev
the device
Definition device.h:70
uint32_t last_pm_update
time when the pm was updated
Definition device.h:80
const char * name
device name
Definition device.h:73
kernel_pid_t pid
pid
Definition device.h:72
uint32_t last_pm_value
last pm timer value set
Definition device.h:81
uint32_t tx_wakeup_timeout
Min timeout loaded when a frame is sent.
Definition device.h:79
ztimer_t pm_timer
timer for power management
Definition device.h:82
uint32_t rx_inactivity_timeout
Min timeout loaded when a frame is received.
Definition device.h:78
can_trx_t * trx
transceiver attached to the device
Definition device.h:75
Parameters to initialize a candev.
Definition device.h:55
uint32_t tx_wakeup_timeout
power management tx wake up value
Definition device.h:62
uint32_t rx_inactivity_timeout
power management rx timeout value
Definition device.h:61
can_trx_t * trx
transceiver to set
Definition device.h:58
const char * name
candev name to set
Definition device.h:56
Structure to hold driver state.
Definition candev.h:77
ztimer structure
Definition ztimer.h:318
kernel_pid_t can_device_init(char *stack, int stacksize, char priority, const char *name, candev_dev_t *params)
Initialize a CAN device thread.
int can_device_calc_bittiming(uint32_t clock, const struct can_bittiming_const *timing_const, struct can_bittiming *bittiming)
Fill in a bittiming structure from bittiming->bitrate and timing_const.
struct candev_params candev_params_t
Parameters to initialize a candev.
struct candev_dev candev_dev_t
candev descriptor to pass to the device thread
ztimer API