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