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
24 extern "C" {
25 #endif
26 
27 #include "can/candev.h"
28 #include "sched.h"
29 
30 #ifdef MODULE_CAN_PM
31 #include "xtimer.h"
32 #endif
33 #ifdef MODULE_CAN_TRX
34 #include "can/can_trx.h"
35 #endif
36 
37 #ifndef CAN_MAX_RATE_ERROR
38 
42 #define CAN_MAX_RATE_ERROR (50) /* 5 % */
43 #endif
44 
45 #ifndef CAN_DLL_NUMOF
46 
49 #define CAN_DLL_NUMOF (1)
50 #endif
51 
55 typedef 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)
62  uint32_t tx_wakeup_timeout;
63 #endif
65 
69 typedef 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)
79  uint32_t tx_wakeup_timeout;
80  uint32_t last_pm_update;
81  uint32_t last_pm_value;
83 #endif
84 } candev_dev_t;
85 
99 kernel_pid_t can_device_init(char *stack, int stacksize, char priority,
100  const char *name, candev_dev_t *params);
101 
112 int 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 
kernel_pid_t
int16_t kernel_pid_t
Unique process identifier.
Definition: sched.h:125
xtimer
xtimer timer structure
Definition: xtimer.h:81
candev_dev::rx_inactivity_timeout
uint32_t rx_inactivity_timeout
Min timeout loaded when a frame is received.
Definition: device.h:78
candev
Structure to hold driver state.
Definition: candev.h:78
candev_params::name
const char * name
candev name to set
Definition: device.h:56
sched.h
Scheduler API definition.
can_bittiming_const
CAN hardware-dependent bit-timing constant.
Definition: can.h:129
candev_params_t
struct candev_params candev_params_t
Parameters to initialize a candev.
can_trx
Generic transceiver descriptor.
Definition: can_trx.h:48
can_trx.h
CAN generic transceiver interface.
candev_dev::name
const char * name
device name
Definition: device.h:73
candev_params::rx_inactivity_timeout
uint32_t rx_inactivity_timeout
power management rx timeout value
Definition: device.h:61
candev_dev::tx_wakeup_timeout
uint32_t tx_wakeup_timeout
Min timeout loaded when a frame is sent.
Definition: device.h:79
candev.h
Definitions for low-level CAN driver interface.
candev_dev::ifnum
int ifnum
interface number
Definition: device.h:71
candev_dev_t
struct candev_dev candev_dev_t
candev descriptor to pass to the device thread
candev_params::tx_wakeup_timeout
uint32_t tx_wakeup_timeout
power management tx wake up value
Definition: device.h:62
candev_dev
candev descriptor to pass to the device thread
Definition: device.h:69
candev_dev::pm_timer
xtimer_t pm_timer
timer for power management
Definition: device.h:82
can_bittiming
CAN bit-timing parameters.
Definition: can.h:113
candev_dev::last_pm_update
uint32_t last_pm_update
time when the pm was updated
Definition: device.h:80
candev_dev::trx
can_trx_t * trx
transceiver attached to the device
Definition: device.h:75
candev_dev::last_pm_value
uint32_t last_pm_value
last pm timer value set
Definition: device.h:81
can_device_calc_bittiming
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.
candev_dev::pid
kernel_pid_t pid
pid
Definition: device.h:72
candev_params::trx
can_trx_t * trx
transceiver to set
Definition: device.h:58
candev_dev::dev
candev_t * dev
the device
Definition: device.h:70
candev_params
Parameters to initialize a candev.
Definition: device.h:55
xtimer.h
xtimer interface definitions
can_device_init
kernel_pid_t can_device_init(char *stack, int stacksize, char priority, const char *name, candev_dev_t *params)
Initialize a CAN device thread.