Loading...
Searching...
No Matches
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
27extern "C" {
28#endif
29
31static 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#if CANDEV_STM32_CHAN_NUMOF > 1
47 .can_master = CAN1,
48 .master_rcc_mask = RCC_APB1ENR_CAN1EN,
49 .first_filter = 0,
50 .nb_filters = 14,
51#endif
52#endif
53#if defined(CPU_FAM_STM32F1)
54 .rx_pin = GPIO_PIN(PORT_A, 11),
55 .tx_pin = GPIO_PIN(PORT_A, 12),
56#elif defined(CPU_FAM_STM32L4) || defined(CPU_FAM_STM32F4)
57
58#if defined(CPU_MODEL_STM32L432KC)
59 .rx_pin = GPIO_PIN(PORT_A, 11),
60 .tx_pin = GPIO_PIN(PORT_A, 12),
61 .af = GPIO_AF9,
62#else
63 .rx_pin = GPIO_PIN(PORT_B, 8),
64 .tx_pin = GPIO_PIN(PORT_B, 9),
65 .af = GPIO_AF9,
66#endif
67#else
68 .rx_pin = GPIO_PIN(PORT_D, 0),
69 .tx_pin = GPIO_PIN(PORT_D, 1),
70 .af = GPIO_AF9,
71#endif
72 .tx_irqn = CAN1_TX_IRQn,
73 .rx0_irqn = CAN1_RX0_IRQn,
74 .rx1_irqn = CAN1_RX1_IRQn,
75 .sce_irqn = CAN1_SCE_IRQn,
76#endif
77 .en_deep_sleep_wake_up = true,
78 .ttcm = 0,
79 .abom = 1,
80 .awum = 1,
81 .nart = 0,
82 .rflm = 0,
83 .txfp = 0,
84 },
85#if (CANDEV_STM32_CHAN_NUMOF >= 2) && (CAN_DLL_NUMOF >= 2)
86 {
87 .can = CAN2,
88 .rcc_mask = RCC_APB1ENR_CAN2EN,
89 .can_master = CAN1,
90 .master_rcc_mask = RCC_APB1ENR_CAN1EN,
91 .first_filter = 14,
92 .nb_filters = 14,
93 .rx_pin = GPIO_PIN(PORT_B, 5),
94 .tx_pin = GPIO_PIN(PORT_B, 6),
95#ifndef CPU_FAM_STM32F1
96 .af = GPIO_AF9,
97#endif
98 .en_deep_sleep_wake_up = true,
99 .tx_irqn = CAN2_TX_IRQn,
100 .rx0_irqn = CAN2_RX0_IRQn,
101 .rx1_irqn = CAN2_RX1_IRQn,
102 .sce_irqn = CAN2_SCE_IRQn,
103 .ttcm = 0,
104 .abom = 1,
105 .awum = 1,
106 .nart = 0,
107 .rflm = 0,
108 .txfp = 0,
109 },
110#endif
111#if (CANDEV_STM32_CHAN_NUMOF >= 3) && (CAN_DLL_NUMOF >= 3)
112 {
113 .can = CAN3,
114 .rcc_mask = RCC_APB1ENR_CAN3EN,
115 .can_master = CAN3,
116 .master_rcc_mask = RCC_APB1ENR_CAN3EN,
117 .first_filter = 0,
118 .nb_filters = 14,
119 .rx_pin = GPIO_PIN(PORT_B, 3),
120 .tx_pin = GPIO_PIN(PORT_B, 4),
121 .af = GPIO_AF11,
122 .en_deep_sleep_wake_up = true,
123 .tx_irqn = CAN3_TX_IRQn,
124 .rx0_irqn = CAN3_RX0_IRQn,
125 .rx1_irqn = CAN3_RX1_IRQn,
126 .sce_irqn = CAN3_SCE_IRQn,
127 .ttcm = 0,
128 .abom = 1,
129 .awum = 1,
130 .nart = 0,
131 .rflm = 0,
132 .txfp = 0,
133 },
134#endif
135};
136
139 {
140 .name = "can_stm32_0",
141 },
142#if (CANDEV_STM32_CHAN_NUMOF >= 2) && (CAN_DLL_NUMOF >= 2)
143 {
144 .name = "can_stm32_1",
145 },
146#endif
147#if (CANDEV_STM32_CHAN_NUMOF >= 3) && (CAN_DLL_NUMOF >= 3)
148 {
149 .name = "can_stm32_2",
150 },
151#endif
152};
153
154#ifdef __cplusplus
155}
156#endif
157
158#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.
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.