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
9#pragma once
10
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#include "can/candev.h"
27#include "sched.h"
28
29#ifdef MODULE_CAN_PM
30#include "ztimer.h"
31#endif
32#ifdef MODULE_CAN_TRX
33#include "can/can_trx.h"
34#endif
35
36#ifndef CAN_MAX_RATE_ERROR
41#define CAN_MAX_RATE_ERROR (50) /* 5 % */
42#endif
43
44#ifndef CAN_DLL_NUMOF
48#define CAN_DLL_NUMOF (1)
49#endif
50
54typedef struct candev_params {
55 const char *name;
56#if defined(MODULE_CAN_TRX) || defined(DOXYGEN)
58#endif
59#if defined(MODULE_FDCAN)
60 uint16_t loop_delay;
61#endif
62#if defined(MODULE_CAN_PM) || defined(DOXYGEN)
65#endif
67
71typedef struct candev_dev {
73 int ifnum;
75 const char *name;
76#if defined(MODULE_CAN_TRX) || defined(DOXYGEN)
78#endif
79#if defined(MODULE_FDCAN)
80 uint16_t loop_delay;
81#endif
82#if defined(MODULE_CAN_PM) || defined(DOXYGEN)
85 uint32_t last_pm_update;
86 uint32_t last_pm_value;
88#endif
90
104kernel_pid_t can_device_init(char *stack, int stacksize, char priority,
105 const char *name, candev_dev_t *params);
106
117int can_device_calc_bittiming(uint32_t clock, const struct can_bittiming_const *timing_const,
118 struct can_bittiming *bittiming);
119
120#ifdef __cplusplus
121}
122#endif
123
CAN generic transceiver interface.
Definitions for low-level CAN driver interface.
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:138
struct can_trx can_trx_t
Generic transceiver descriptor.
struct candev candev_t
Forward declaration for candev struct.
Definition candev.h:59
Scheduler API definition.
CAN hardware-dependent bit-timing constant.
Definition can.h:159
CAN bit-timing parameters.
Definition can.h:143
candev descriptor to pass to the device thread
Definition device.h:71
int ifnum
interface number
Definition device.h:73
candev_t * dev
the device
Definition device.h:72
uint32_t last_pm_update
time when the pm was updated
Definition device.h:85
const char * name
device name
Definition device.h:75
kernel_pid_t pid
pid
Definition device.h:74
uint32_t last_pm_value
last pm timer value set
Definition device.h:86
uint32_t tx_wakeup_timeout
Min timeout loaded when a frame is sent.
Definition device.h:84
ztimer_t pm_timer
timer for power management
Definition device.h:87
uint32_t rx_inactivity_timeout
Min timeout loaded when a frame is received.
Definition device.h:83
can_trx_t * trx
transceiver attached to the device
Definition device.h:77
Parameters to initialize a candev.
Definition device.h:54
uint32_t tx_wakeup_timeout
power management tx wake up value
Definition device.h:64
uint32_t rx_inactivity_timeout
power management rx timeout value
Definition device.h:63
can_trx_t * trx
transceiver to set
Definition device.h:57
const char * name
candev name to set
Definition device.h:55
ztimer structure
Definition ztimer.h:319
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