Loading...
Searching...
No Matches
device.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2016 OTA keys S.A.
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#include "can/candev.h"
24#include "sched.h"
25
26#ifdef MODULE_CAN_PM
27#include "ztimer.h"
28#endif
29#ifdef MODULE_CAN_TRX
30#include "can/can_trx.h"
31#endif
32
33#ifndef CAN_MAX_RATE_ERROR
38#define CAN_MAX_RATE_ERROR (50) /* 5 % */
39#endif
40
41#ifndef CAN_DLL_NUMOF
45#define CAN_DLL_NUMOF (1)
46#endif
47
51typedef struct candev_params {
52 const char *name;
53#if defined(MODULE_CAN_TRX) || defined(DOXYGEN)
55#endif
56#if defined(MODULE_FDCAN)
57 uint16_t loop_delay;
58#endif
59#if defined(MODULE_CAN_PM) || defined(DOXYGEN)
62#endif
64
68typedef struct candev_dev {
70 int ifnum;
72 const char *name;
73#if defined(MODULE_CAN_TRX) || defined(DOXYGEN)
75#endif
76#if defined(MODULE_FDCAN)
77 uint16_t loop_delay;
78#endif
79#if defined(MODULE_CAN_PM) || defined(DOXYGEN)
82 uint32_t last_pm_update;
83 uint32_t last_pm_value;
85#endif
87
101kernel_pid_t can_device_init(char *stack, int stacksize, char priority,
102 const char *name, candev_dev_t *params);
103
114int can_device_calc_bittiming(uint32_t clock, const struct can_bittiming_const *timing_const,
115 struct can_bittiming *bittiming);
116
117#ifdef __cplusplus
118}
119#endif
120
CAN generic transceiver interface.
Definitions for low-level CAN driver interface.
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:134
struct can_trx can_trx_t
Generic transceiver descriptor.
struct candev candev_t
Forward declaration for candev struct.
Definition candev.h:56
CAN hardware-dependent bit-timing constant.
Definition can.h:156
CAN bit-timing parameters.
Definition can.h:140
candev descriptor to pass to the device thread
Definition device.h:68
int ifnum
interface number
Definition device.h:70
candev_t * dev
the device
Definition device.h:69
uint32_t last_pm_update
time when the pm was updated
Definition device.h:82
const char * name
device name
Definition device.h:72
kernel_pid_t pid
pid
Definition device.h:71
uint32_t last_pm_value
last pm timer value set
Definition device.h:83
uint32_t tx_wakeup_timeout
Min timeout loaded when a frame is sent.
Definition device.h:81
ztimer_t pm_timer
timer for power management
Definition device.h:84
uint32_t rx_inactivity_timeout
Min timeout loaded when a frame is received.
Definition device.h:80
can_trx_t * trx
transceiver attached to the device
Definition device.h:74
Parameters to initialize a candev.
Definition device.h:51
uint32_t tx_wakeup_timeout
power management tx wake up value
Definition device.h:61
uint32_t rx_inactivity_timeout
power management rx timeout value
Definition device.h:60
can_trx_t * trx
transceiver to set
Definition device.h:54
const char * name
candev name to set
Definition device.h:52
ztimer structure
Definition ztimer.h:316
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