a752c7ab
elopes
add first test an...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*
* Copyright (C) 2016 OTA keys S.A.
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup drivers_can_trx CAN transceiver interface
* @ingroup drivers_can
* @brief CAN generic transceiver interface
* @{
*
* @file
* @brief CAN generic transceiver interface
*
* @author Aurelien Gonce <aurelien.gonce@altran.com>
* @author Vincent Dupont <vincent@otakeys.com>
*/
#ifndef CAN_CAN_TRX_H
#define CAN_CAN_TRX_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* trx transceiver mode
*/
typedef enum {
TRX_NORMAL_MODE = 0,
TRX_SILENT_MODE,
TRX_SLEEP_MODE,
/* single wire can modes */
TRX_HIGH_SPEED_MODE,
TRX_HIGH_VOLTAGE_WAKE_UP_MODE
} can_trx_mode_t;
/**
* @brief forward declaration of trx_driver
*/
typedef struct trx_driver trx_driver_t;
/**
* @brief Generic transceiver descriptor
*/
typedef struct can_trx {
const trx_driver_t *driver; /**< driver */
can_trx_mode_t mode; /**< current mode */
} can_trx_t;
/**
* @brief Generic transceiver driver
*/
struct trx_driver {
/**
* @brief initialize the trx device
*
* @param[in] dev Transceiver to initialize
*
* @return 0 on success
* @return < 0 on error
*/
int (*init)(can_trx_t *dev);
/**
* @brief set mode interface
*
* @param[in] dev Transceiver to set
* @param[in] mode Mode to set
*
* @return 0 on success
* @return < 0 on error
*/
int (*set_mode)(can_trx_t *dev, can_trx_mode_t mode);
};
/**
* @brief initialize a transceiver
*
* @param[in] dev Transceiver to initialize
*
* @return 0 on success
* @return < 0 on error
*/
int can_trx_init(can_trx_t *dev);
/**
* @brief transceiver set mode
*
* @param[in] dev Transceiver to set
* @param[in] mode Mode to set
*
* @return 0 on success
* @return < 0 on error
*/
int can_trx_set_mode(can_trx_t *dev, can_trx_mode_t mode);
#ifdef __cplusplus
}
#endif
#endif /* CAN_CAN_TRX_H */
/** @} */
|