Loading...
Searching...
No Matches
candev.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
6 * more details.
7 */
8
24#ifndef CAN_CANDEV_H
25#define CAN_CANDEV_H
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#include <stdint.h>
32#include <stdlib.h>
33
34#include "can/can.h"
35#include "can/common.h"
36#include "mutex.h"
37
56
60typedef struct candev candev_t;
61
69typedef void (*candev_event_cb_t)(candev_t *dev, candev_event_t event, void *arg);
70
84
88typedef struct candev_driver {
98 int (*send)(candev_t *dev, const struct can_frame *frame);
99
109 int (*abort)(candev_t *dev, const struct can_frame *frame);
110
118 int (*init)(candev_t *dev);
119
125 void (*isr)(candev_t *dev);
126
138 int (*get)(candev_t *dev, canopt_t opt, void *value, size_t max_len);
139
151 int (*set)(candev_t *dev, canopt_t opt, void *value, size_t value_len);
152
162 int (*set_filter)(candev_t *dev, const struct can_filter *filter);
163
173 int (*remove_filter)(candev_t *dev, const struct can_filter *filter);
175
176#ifdef __cplusplus
177}
178#endif
179
180#endif /* CAN_CANDEV_H */
struct candev_driver candev_driver_t
Structure to hold driver interface -> function mapping.
void(* candev_event_cb_t)(candev_t *dev, candev_event_t event, void *arg)
Event callback for signaling event to upper layers.
Definition candev.h:69
candev_event_t
Possible event types that are sent from the device driver to the upper layer.
Definition candev.h:42
@ CANDEV_EVENT_RX_ERROR
there was an error when receiving
Definition candev.h:50
@ CANDEV_EVENT_TX_CONFIRMATION
a packet has been sent
Definition candev.h:46
@ CANDEV_EVENT_ISR
driver needs its ISR handled
Definition candev.h:44
@ CANDEV_EVENT_TX_ERROR
there was an error when transmitting
Definition candev.h:49
@ CANDEV_EVENT_WAKE_UP
driver has been woken up by bus
Definition candev.h:45
@ CANDEV_EVENT_NOEVENT
no event, used internally
Definition candev.h:43
@ CANDEV_EVENT_RX_INDICATION
a packet has been received
Definition candev.h:48
@ CANDEV_EVENT_TIMEOUT_TX_CONF
tx conf timeout received
Definition candev.h:47
@ CANDEV_EVENT_BUS_OFF
bus-off detected
Definition candev.h:51
@ CANDEV_EVENT_ERROR_PASSIVE
driver switched in error passive
Definition candev.h:52
@ CANDEV_EVENT_ERROR_WARNING
driver reached error warning
Definition candev.h:53
canopt_t
CAN options.
Definition common.h:45
can_state
CAN operational and error states.
Definition can.h:65
Mutex for thread synchronization.
CAN bit-timing parameters.
Definition can.h:116
Controller Area Network filter.
Definition can.h:101
Controller Area Network frame.
Definition can.h:88
Structure to hold driver interface -> function mapping.
Definition candev.h:88
int(* set_filter)(candev_t *dev, const struct can_filter *filter)
Set a receive filter.
Definition candev.h:162
int(* get)(candev_t *dev, canopt_t opt, void *value, size_t max_len)
Get an option value from a given CAN device.
Definition candev.h:138
int(* send)(candev_t *dev, const struct can_frame *frame)
Send packet.
Definition candev.h:98
int(* set)(candev_t *dev, canopt_t opt, void *value, size_t value_len)
Set an option value for a given CAN device.
Definition candev.h:151
int(* init)(candev_t *dev)
the driver's initialization function
Definition candev.h:118
void(* isr)(candev_t *dev)
a driver's user-space ISR handler
Definition candev.h:125
int(* remove_filter)(candev_t *dev, const struct can_filter *filter)
Remove a filter.
Definition candev.h:173
int(* abort)(candev_t *dev, const struct can_frame *frame)
Abort a packet sending.
Definition candev.h:109
Structure to hold driver state.
Definition candev.h:77
const struct candev_driver * driver
ptr to that driver's interface.
Definition candev.h:78
candev_event_cb_t event_callback
callback for device events
Definition candev.h:79
enum can_state state
device state
Definition candev.h:82
struct can_bittiming bittiming
device bittimings
Definition candev.h:81
void * isr_arg
argument to pass on isr event
Definition candev.h:80
event structure
Definition event.h:148
Definitions high-level CAN interface.
Definitions of high-level CAN interface.