All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
can_params.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 
20 #ifndef CAN_PARAMS_H
21 #define CAN_PARAMS_H
22 
23 #include "can/device.h"
24 #include "periph/can.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
31 static const can_conf_t candev_conf[] = {
32  {
33 #if defined(CPU_FAM_STM32G4)
34  .can = FDCAN1,
35  .rcc_mask = RCC_APB1ENR1_FDCANEN,
36  .rx_pin = GPIO_PIN(PORT_A, 11),
37  .tx_pin = GPIO_PIN(PORT_A, 12),
38  .af = GPIO_AF9,
39  .it0_irqn = FDCAN1_IT0_IRQn,
40  .it1_irqn = FDCAN1_IT1_IRQn,
41 #elif defined(CPU_FAM_STM32F0)
42  .can = CAN,
43  .rcc_mask = RCC_APB1ENR_CANEN,
44  .rx_pin = GPIO_PIN(PORT_A, 11),
45  .tx_pin = GPIO_PIN(PORT_A, 12),
46  .af = GPIO_AF4,
47  .irqn = CEC_CAN_IRQn,
48 #else
49  .can = CAN1,
50 #if defined(CPU_FAM_STM32L4)
51  .rcc_mask = RCC_APB1ENR1_CAN1EN,
52 #else
53  .rcc_mask = RCC_APB1ENR_CAN1EN,
54 #if CANDEV_STM32_CHAN_NUMOF > 1
55  .can_master = CAN1,
56  .master_rcc_mask = RCC_APB1ENR_CAN1EN,
57  .first_filter = 0,
58  .nb_filters = 14,
59 #endif
60 #endif
61 #if defined(CPU_FAM_STM32F1)
62  .rx_pin = GPIO_PIN(PORT_A, 11),
63  .tx_pin = GPIO_PIN(PORT_A, 12),
64 #elif defined(CPU_FAM_STM32L4) || defined(CPU_FAM_STM32F4)
65 
66 #if defined(CPU_MODEL_STM32L432KC)
67  .rx_pin = GPIO_PIN(PORT_A, 11),
68  .tx_pin = GPIO_PIN(PORT_A, 12),
69  .af = GPIO_AF9,
70 #else
71  .rx_pin = GPIO_PIN(PORT_B, 8),
72  .tx_pin = GPIO_PIN(PORT_B, 9),
73  .af = GPIO_AF9,
74 #endif
75 #else
76  .rx_pin = GPIO_PIN(PORT_D, 0),
77  .tx_pin = GPIO_PIN(PORT_D, 1),
78  .af = GPIO_AF9,
79 #endif
80  .tx_irqn = CAN1_TX_IRQn,
81  .rx0_irqn = CAN1_RX0_IRQn,
82  .rx1_irqn = CAN1_RX1_IRQn,
83  .sce_irqn = CAN1_SCE_IRQn,
84 #endif
85  .en_deep_sleep_wake_up = true,
86  .ttcm = 0,
87  .abom = 1,
88  .awum = 1,
89  .nart = 0,
90  .rflm = 0,
91  .txfp = 0,
92  },
93 #if (CANDEV_STM32_CHAN_NUMOF >= 2) && (CAN_DLL_NUMOF >= 2)
94  {
95  .can = CAN2,
96  .rcc_mask = RCC_APB1ENR_CAN2EN,
97  .can_master = CAN1,
98  .master_rcc_mask = RCC_APB1ENR_CAN1EN,
99  .first_filter = 14,
100  .nb_filters = 14,
101  .rx_pin = GPIO_PIN(PORT_B, 5),
102  .tx_pin = GPIO_PIN(PORT_B, 6),
103 #ifndef CPU_FAM_STM32F1
104  .af = GPIO_AF9,
105 #endif
106  .en_deep_sleep_wake_up = true,
107  .tx_irqn = CAN2_TX_IRQn,
108  .rx0_irqn = CAN2_RX0_IRQn,
109  .rx1_irqn = CAN2_RX1_IRQn,
110  .sce_irqn = CAN2_SCE_IRQn,
111  .ttcm = 0,
112  .abom = 1,
113  .awum = 1,
114  .nart = 0,
115  .rflm = 0,
116  .txfp = 0,
117  },
118 #endif
119 #if (CANDEV_STM32_CHAN_NUMOF >= 3) && (CAN_DLL_NUMOF >= 3)
120  {
121  .can = CAN3,
122  .rcc_mask = RCC_APB1ENR_CAN3EN,
123  .can_master = CAN3,
124  .master_rcc_mask = RCC_APB1ENR_CAN3EN,
125  .first_filter = 0,
126  .nb_filters = 14,
127  .rx_pin = GPIO_PIN(PORT_B, 3),
128  .tx_pin = GPIO_PIN(PORT_B, 4),
129  .af = GPIO_AF11,
130  .en_deep_sleep_wake_up = true,
131  .tx_irqn = CAN3_TX_IRQn,
132  .rx0_irqn = CAN3_RX0_IRQn,
133  .rx1_irqn = CAN3_RX1_IRQn,
134  .sce_irqn = CAN3_SCE_IRQn,
135  .ttcm = 0,
136  .abom = 1,
137  .awum = 1,
138  .nart = 0,
139  .rflm = 0,
140  .txfp = 0,
141  },
142 #endif
143 };
144 
146 static const candev_params_t candev_params[] = {
147  {
148  .name = "can_stm32_0",
149  },
150 #if (CANDEV_STM32_CHAN_NUMOF >= 2) && (CAN_DLL_NUMOF >= 2)
151  {
152  .name = "can_stm32_1",
153  },
154 #endif
155 #if (CANDEV_STM32_CHAN_NUMOF >= 3) && (CAN_DLL_NUMOF >= 3)
156  {
157  .name = "can_stm32_2",
158  },
159 #endif
160 };
161 
162 #ifdef __cplusplus
163 }
164 #endif
165 
166 #endif /* CAN_PARAMS_H */
@ PORT_B
port B
Definition: periph_cpu.h:48
@ PORT_A
port A
Definition: periph_cpu.h:47
@ PORT_D
port D
Definition: periph_cpu.h:50
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:46
@ GPIO_AF4
use alternate function 4
Definition: cpu_gpio.h:106
@ GPIO_AF9
use alternate function 9
Definition: cpu_gpio.h:112
@ GPIO_AF11
use alternate function 11
Definition: cpu_gpio.h:114
Low-level CAN peripheral driver interface definitions.
ESP CAN device configuration.
Definition: can_esp.h:88
Linux candev configuration.
Definition: candev_linux.h:46
Parameters to initialize a candev.
Definition: device.h:55
const char * name
candev name to set
Definition: device.h:56
Definitions of CAN device interface.