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_STM32F0)
34  .can = CAN,
35  .rcc_mask = RCC_APB1ENR_CANEN,
36  .rx_pin = GPIO_PIN(PORT_A, 11),
37  .tx_pin = GPIO_PIN(PORT_A, 12),
38  .af = GPIO_AF4,
39  .irqn = CEC_CAN_IRQn,
40 #else
41  .can = CAN1,
42 #if defined(CPU_FAM_STM32L4)
43  .rcc_mask = RCC_APB1ENR1_CAN1EN,
44 #else
45  .rcc_mask = RCC_APB1ENR_CAN1EN,
46  .can_master = CAN1,
47  .master_rcc_mask = RCC_APB1ENR_CAN1EN,
48  .first_filter = 0,
49  .nb_filters = 14,
50 #endif
51 #if defined(CPU_FAM_STM32F1)
52  .rx_pin = GPIO_PIN(PORT_A, 11),
53  .tx_pin = GPIO_PIN(PORT_A, 12),
54 #elif defined(CPU_FAM_STM32L4) || defined(CPU_FAM_STM32F4)
55  .rx_pin = GPIO_PIN(PORT_B, 8),
56  .tx_pin = GPIO_PIN(PORT_B, 9),
57  .af = GPIO_AF9,
58 #else
59  .rx_pin = GPIO_PIN(PORT_D, 0),
60  .tx_pin = GPIO_PIN(PORT_D, 1),
61  .af = GPIO_AF9,
62 #endif
63  .tx_irqn = CAN1_TX_IRQn,
64  .rx0_irqn = CAN1_RX0_IRQn,
65  .rx1_irqn = CAN1_RX1_IRQn,
66  .sce_irqn = CAN1_SCE_IRQn,
67 #endif
68  .ttcm = 0,
69  .abom = 1,
70  .awum = 1,
71  .nart = 0,
72  .rflm = 0,
73  .txfp = 0,
74  },
75 #if (CANDEV_STM32_CHAN_NUMOF >= 2) && (CAN_DLL_NUMOF >= 2)
76  {
77  .can = CAN2,
78  .rcc_mask = RCC_APB1ENR_CAN2EN,
79  .can_master = CAN1,
80  .master_rcc_mask = RCC_APB1ENR_CAN1EN,
81  .first_filter = 14,
82  .nb_filters = 14,
83  .rx_pin = GPIO_PIN(PORT_B, 5),
84  .tx_pin = GPIO_PIN(PORT_B, 6),
85 #ifndef CPU_FAM_STM32F1
86  .af = GPIO_AF9,
87 #endif
88  .tx_irqn = CAN2_TX_IRQn,
89  .rx0_irqn = CAN2_RX0_IRQn,
90  .rx1_irqn = CAN2_RX1_IRQn,
91  .sce_irqn = CAN2_SCE_IRQn,
92  .ttcm = 0,
93  .abom = 1,
94  .awum = 1,
95  .nart = 0,
96  .rflm = 0,
97  .txfp = 0,
98  },
99 #endif
100 #if (CANDEV_STM32_CHAN_NUMOF >= 3) && (CAN_DLL_NUMOF >= 3)
101  {
102  .can = CAN3,
103  .rcc_mask = RCC_APB1ENR_CAN3EN,
104  .can_master = CAN3,
105  .master_rcc_mask = RCC_APB1ENR_CAN3EN,
106  .first_filter = 0,
107  .nb_filters = 14,
108  .rx_pin = GPIO_PIN(PORT_B, 3),
109  .tx_pin = GPIO_PIN(PORT_B, 4),
110  .af = GPIO_AF11,
111  .tx_irqn = CAN3_TX_IRQn,
112  .rx0_irqn = CAN3_RX0_IRQn,
113  .rx1_irqn = CAN3_RX1_IRQn,
114  .sce_irqn = CAN3_SCE_IRQn,
115  .ttcm = 0,
116  .abom = 1,
117  .awum = 1,
118  .nart = 0,
119  .rflm = 0,
120  .txfp = 0,
121  },
122 #endif
123 };
124 
126 static const candev_params_t candev_params[] = {
127  {
128  .name = "can_stm32_0",
129  },
130 #if (CANDEV_STM32_CHAN_NUMOF >= 2) && (CAN_DLL_NUMOF >= 2)
131  {
132  .name = "can_stm32_1",
133  },
134 #endif
135 #if (CANDEV_STM32_CHAN_NUMOF >= 3) && (CAN_DLL_NUMOF >= 3)
136  {
137  .name = "can_stm32_2",
138  },
139 #endif
140 };
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif /* CAN_PARAMS_H */
GPIO_AF9
@ GPIO_AF9
use alternate function 9
Definition: periph_cpu_common.h:95
GPIO_AF4
@ GPIO_AF4
use alternate function 4
Definition: periph_cpu_common.h:90
GPIO_AF11
@ GPIO_AF11
use alternate function 11
Definition: periph_cpu_common.h:97
device.h
Definitions of CAN device interface.
candev_conf
Linux candev configuration.
Definition: candev_linux.h:45
PORT_A
@ PORT_A
port A
Definition: periph_cpu.h:36
PORT_D
@ PORT_D
port D
Definition: periph_cpu.h:39
can.h
Low-level CAN peripheral driver interface definitions.
candev_params::name
const char * name
candev name to set
Definition: device.h:56
can_conf_t
ESP CAN device configuration.
Definition: can_esp.h:98
GPIO_PIN
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:35
PORT_B
@ PORT_B
port B
Definition: periph_cpu.h:37
candev_params
Parameters to initialize a candev.
Definition: device.h:55