libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
g4/fdcan.h
Go to the documentation of this file.
1
/** @defgroup fdcan_defines FDCAN Defines
2
3
@ingroup STM32G4xx_defines
4
5
@author @htmlonly © @endhtmlonly 2021 Eduard Drusa <ventyl86 at netkosice dot sk>
6
7
LGPL License Terms @ref lgpl_license
8
*/
9
/*
10
* This file is part of the libopencm3 project.
11
*
12
* Copyright (C) 2021 Eduard Drusa <ventyl86 at netkosice dot sk>
13
*
14
* This library is free software: you can redistribute it and/or modify
15
* it under the terms of the GNU Lesser General Public License as published by
16
* the Free Software Foundation, either version 3 of the License, or
17
* (at your option) any later version.
18
*
19
* This library is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU Lesser General Public License for more details.
23
*
24
* You should have received a copy of the GNU Lesser General Public License
25
* along with this library. If not, see <http://www.gnu.org/licenses/>.
26
*/
27
28
#pragma once
29
30
/** @{ */
31
32
/* FDCAN block base addresses. Used in functions to identify FDCAN block being manipulated. */
33
34
/** @defgroup fdcan_block FDCAN block base addresses
35
* @{
36
*/
37
#define CAN1 FDCAN1_BASE
38
#define CAN2 FDCAN2_BASE
39
#define CAN3 FDCAN3_BASE
40
/**@}*/
41
42
#define CAN_MSG_BASE FDCAN1_RAM_BASE
43
44
#define FDCAN_RXFIS_BASE 0x0090
45
#define FDCAN_RXFIA_BASE 0x0094
46
#define FDCAN_RXFI_OFFSET 0x0008
47
48
#define FDCAN_RXGFC(can_base) MMIO32(can_base + 0x0080)
49
#define FDCAN_XIDAM(can_base) MMIO32(can_base + 0x0084)
50
#define FDCAN_HPMS(can_base) MMIO32(can_base + 0x0088)
51
52
#define FDCAN_TXBRP(can_base) MMIO32(can_base + 0x00C8)
53
#define FDCAN_TXBAR(can_base) MMIO32(can_base + 0x00CC)
54
#define FDCAN_TXBCR(can_base) MMIO32(can_base + 0x00D0)
55
#define FDCAN_TXBTO(can_base) MMIO32(can_base + 0x00D4)
56
#define FDCAN_TXBCF(can_base) MMIO32(can_base + 0x00D8)
57
#define FDCAN_TXBTIE(can_base) MMIO32(can_base + 0x00DC)
58
#define FDCAN_TXBCIE(can_base) MMIO32(can_base + 0x00E0)
59
#define FDCAN_TXEFS(can_base) MMIO32(can_base + 0x00E4)
60
#define FDCAN_TXEFA(can_base) MMIO32(can_base + 0x00E8)
61
62
#define FDCAN_CKDIV(can_base) MMIO32(can_base + 0x0100)
63
64
#define FDCAN_RXGFC_RRFE (1 << 0)
65
#define FDCAN_RXGFC_RRFS (1 << 1)
66
/** ANFE[1:0]: Accept non-matching frames w/ extended ID */
67
#define FDCAN_RXGFC_ANFE_SHIFT 2
68
#define FDCAN_RXGFC_ANFE_MASK 0x3
69
70
/** ANFS[1:0]: Accept non-matching frames w/ standard ID */
71
#define FDCAN_RXGFC_ANFS_SHIFT 4
72
#define FDCAN_RXGFC_ANFS_MASK 0x3
73
74
#define FDCAN_RXGFC_F1OM (1 << 8)
75
#define FDCAN_RXGFC_F0OM (1 << 9)
76
/** LSS[4:0]: List size of standard ID filters */
77
#define FDCAN_RXGFC_LSS_SHIFT 16
78
#define FDCAN_RXGFC_LSS_MASK 0x1F
79
80
/** LSE[3:0]: List size of extended ID filters */
81
#define FDCAN_RXGFC_LSE_SHIFT 24
82
#define FDCAN_RXGFC_LSE_MASK 0xF
83
84
#define FDCAN_RXFIFO_FL_MASK 0xF
85
#define FDCAN_RXFIFO_GI_MASK 0x3
86
#define FDCAN_RXFIFO_PI_MASK 0x3
87
#define FDCAN_RXFIFO_AI_MASK 0x3
88
89
#define FDCAN_TXFQS_TFFL_MASK 0x7
90
#define FDCAN_TXFQS_TFGI_MASK 0x3
91
#define FDCAN_TXFQS_TFQPI_MASK 0x3
92
93
#define FDCAN_TXEFS_EFFL_MASK 0x7
94
#define FDCAN_TXEFS_EFGI_MASK 0x3
95
#define FDCAN_TXEFS_EFPI_MASK 0x3
96
97
/* PDIV[3:0]: Input clock divider */
98
#define FDCAN_CKDIV_PDIV_SHIFT 0
99
#define FDCAN_CKDIV_PDIV_MASK 0xF
100
101
/** Amount of standard filters allocated in Message RAM
102
* This number may vary between devices. 28 is value valid
103
* for STM32G4
104
**/
105
#define FDCAN_SFT_MAX_NR 28
106
107
/** Amount of extended filters allocated in Message RAM
108
* This number may vary between devices. 8 is value valid
109
* for STM32G4
110
**/
111
#define FDCAN_EFT_MAX_NR 8
112
113
#define FDCAN_LFSSA_OFFSET(can_base) ((FDCAN_BLOCK_ID(can_base) * 0x0350) + 0x0000)
114
#define FDCAN_LFESA_OFFSET(can_base) ((FDCAN_BLOCK_ID(can_base) * 0x0350) + 0x0070)
115
116
#define FDCAN_RXFIFOS_OFFSET(can_base) ((FDCAN_BLOCK_ID(can_base) * 0x0350) + 0x00B0)
117
118
#define FDCAN_RXFIFO_OFFSET(can_base, fifo_id) \
119
(FDCAN_RXFIFOS_OFFSET(can_base) + (0x00D8 * (fifo_id)))
120
121
#define FDCAN_TXEVT_OFFSET(can_base) ((FDCAN_BLOCK_ID(can_base) * 0x0350) + 0x0260)
122
123
#define FDCAN_TXBUF_OFFSET(can_base) ((FDCAN_BLOCK_ID(can_base) * 0x0350) + 0x0278)
124
125
BEGIN_DECLS
126
127
END_DECLS
128
129
/**@}*/
END_DECLS
#define END_DECLS
Definition:
common.h:34
BEGIN_DECLS
#define BEGIN_DECLS
Definition:
common.h:33
include
libopencm3
stm32
g4
fdcan.h
Generated on Tue Mar 7 2023 16:12:22 for libopencm3 by
1.9.4