Loading...
Searching...
No Matches
candev_samd5x.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024 ML!PA Consulting GmbH
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
20#ifndef CANDEV_SAMD5X_H
21#define CANDEV_SAMD5X_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#if defined(CAN_INST_NUM)
28#include "can/candev.h"
29
30#ifndef CANDEV_SAMD5X_DEFAULT_BITRATE
32#define CANDEV_SAMD5X_DEFAULT_BITRATE 500000U
33#endif
34
35#ifndef CANDEV_SAMD5X_DEFAULT_SPT
37#define CANDEV_SAMD5X_DEFAULT_SPT 875
38#endif
39
40#ifndef CANDEV_SAMD5X_DEFAULT_STD_FILTER_NUM
41#define CANDEV_SAMD5X_DEFAULT_STD_FILTER_NUM 3
42#endif
43
44#ifndef CANDEV_SAMD5X_DEFAULT_EXT_FILTER_NUM
45#define CANDEV_SAMD5X_DEFAULT_EXT_FILTER_NUM 3
46#endif
47
48#ifndef CANDEV_SAMD5X_DEFAULT_RX_FIFO_0_ELTS_NUM
49#define CANDEV_SAMD5X_DEFAULT_RX_FIFO_0_ELTS_NUM 32
50#endif
51
52#ifndef CANDEV_SAMD5X_DEFAULT_RX_FIFO_1_ELTS_NUM
53#define CANDEV_SAMD5X_DEFAULT_RX_FIFO_1_ELTS_NUM 32
54#endif
55
56#ifndef CANDEV_SAMD5X_DEFAULT_TX_EVT_FIFO_ELTS_NUM
57#define CANDEV_SAMD5X_DEFAULT_TX_EVT_FIFO_ELTS_NUM 16
58#endif
59
60#ifndef CANDEV_SAMD5X_DEFAULT_TX_BUFFER_NUM
61#define CANDEV_SAMD5X_DEFAULT_TX_BUFFER_NUM 16
62#endif
63
64#ifndef CANDEV_SAMD5X_DEFAULT_TX_BUFFER_FIFO_QUEUE_NUM
65#define CANDEV_SAMD5X_DEFAULT_TX_BUFFER_FIFO_QUEUE_NUM 16
66#endif
67
68/* unit: elements */
69#define CANDEV_SAMD5X_MAX_STD_FILTER 128
70#define CANDEV_SAMD5X_MAX_EXT_FILTER 64
71#define CANDEV_SAMD5X_MAX_RX_FIFO_0_ELTS 64
72#define CANDEV_SAMD5X_MAX_RX_FIFO_1_ELTS 64
73#define CANDEV_SAMD5X_MAX_RX_BUFFER 64
74#define CANDEV_SAMD5X_MAX_TX_EVT_FIFO_ELTS 32
75#define CANDEV_SAMD5X_MAX_TX_BUFFER 32
76#define CANDEV_SAMD5X_MSG_RAM_MAX_SIZE 448
77
81typedef struct {
83 Can *can;
85 gpio_t rx_pin;
87 gpio_t tx_pin;
89 uint8_t gclk_src;
91#define HAVE_CAN_CONF_T
92
96typedef struct {
98 CanMramSidfe std_filter[CANDEV_SAMD5X_DEFAULT_STD_FILTER_NUM];
100 CanMramXifde ext_filter[CANDEV_SAMD5X_DEFAULT_EXT_FILTER_NUM];
102 CanMramRxf0e rx_fifo_0[CANDEV_SAMD5X_DEFAULT_RX_FIFO_0_ELTS_NUM];
104 CanMramRxf1e rx_fifo_1[CANDEV_SAMD5X_DEFAULT_RX_FIFO_1_ELTS_NUM];
106 CanMramRxbe rx_buffer[CANDEV_SAMD5X_MAX_RX_BUFFER];
108 CanMramTxefe tx_event_fifo[CANDEV_SAMD5X_DEFAULT_TX_EVT_FIFO_ELTS_NUM];
110 CanMramTxbe tx_fifo_queue[CANDEV_SAMD5X_DEFAULT_TX_BUFFER_FIFO_QUEUE_NUM];
111} msg_ram_conf_t;
112
116typedef struct {
120 const can_conf_t *conf;
122 msg_ram_conf_t msg_ram_conf;
124 bool tdc_ctrl;
126 bool tx_fifo_queue_ctrl;
127} can_t;
128#define HAVE_CAN_T
129
136void candev_samd5x_tdc_control(can_t *dev);
137
144void candev_samd5x_enter_sleep_mode(candev_t *candev);
145
152void candev_samd5x_exit_sleep_mode(candev_t *candev);
153
154#endif /* CAN_INST_NUM */
155
156#ifdef __cplusplus
157}
158#endif
159
160#endif /* CANDEV_SAMD5X_H */
Definitions for low-level CAN driver interface.
struct can can_t
Low level device structure for ESP32 CAN (extension of candev_t)
ESP CAN device configuration.
Definition can_esp.h:88
Low level device structure for ESP32 CAN (extension of candev_t)
Definition can_esp.h:64
Structure to hold driver state.
Definition candev.h:77