c_can.hpp
Go to the documentation of this file.
1 /*
2  * Bosch C_CAN controller API.
3  *
4  * Copyright (C) 2015 Pavel Kirienko <pavel.kirienko@gmail.com>
5  */
6 
7 #pragma once
8 
9 #include <cstdint>
10 #include <cstddef>
11 
12 namespace uavcan_lpc11c24
13 {
14 namespace c_can
15 {
16 
18 {
20 
21  union
22  {
25  } CMDMSK;
26 
29 
32 
34 
39 
40  const std::uint32_t _skip[13];
41 };
42 
43 static_assert(offsetof(MsgIfaceType, CMDMSK) == 0x04, "C_CAN offset");
44 static_assert(offsetof(MsgIfaceType, MSK1) == 0x08, "C_CAN offset");
45 static_assert(offsetof(MsgIfaceType, ARB1) == 0x10, "C_CAN offset");
46 static_assert(offsetof(MsgIfaceType, MCTRL) == 0x18, "C_CAN offset");
47 static_assert(offsetof(MsgIfaceType, DA1) == 0x1c, "C_CAN offset");
48 static_assert(offsetof(MsgIfaceType, DB2) == 0x28, "C_CAN offset");
49 
50 static_assert(sizeof(MsgIfaceType) == 96, "C_CAN size");
51 
52 
53 struct Type
54 {
62 
64 
65  MsgIfaceType IF[2]; // [0] @ 0x020, [1] @ 0x080
66 
68 
69  const std::uint32_t TXREQ[2]; // 0x100
70 
72 
73  const std::uint32_t ND[2]; // 0x120
74 
76 
77  const std::uint32_t IR[2]; // 0x140
78 
80 
81  const std::uint32_t MSGV[2]; // 0x160
82 
84 
86 };
87 
88 static_assert(offsetof(Type, CNTL) == 0x000, "C_CAN offset");
89 static_assert(offsetof(Type, STAT) == 0x004, "C_CAN offset");
90 static_assert(offsetof(Type, TEST) == 0x014, "C_CAN offset");
91 static_assert(offsetof(Type, BRPE) == 0x018, "C_CAN offset");
92 static_assert(offsetof(Type, IF[0]) == 0x020, "C_CAN offset");
93 static_assert(offsetof(Type, IF[1]) == 0x080, "C_CAN offset");
94 static_assert(offsetof(Type, TXREQ) == 0x100, "C_CAN offset");
95 static_assert(offsetof(Type, ND) == 0x120, "C_CAN offset");
96 static_assert(offsetof(Type, IR) == 0x140, "C_CAN offset");
97 static_assert(offsetof(Type, MSGV) == 0x160, "C_CAN offset");
98 static_assert(offsetof(Type, CLKDIV) == 0x180, "C_CAN offset");
99 
100 static_assert(offsetof(Type, IF[0].DB2) == 0x048, "C_CAN offset");
101 static_assert(offsetof(Type, IF[1].DB2) == 0x0A8, "C_CAN offset");
102 
103 
104 volatile Type& CAN = *reinterpret_cast<volatile Type*>(0x40050000);
105 
106 
107 /*
108  * CNTL
109  */
110 static constexpr std::uint32_t CNTL_TEST = 1 << 7;
111 static constexpr std::uint32_t CNTL_CCE = 1 << 6;
112 static constexpr std::uint32_t CNTL_DAR = 1 << 5;
113 static constexpr std::uint32_t CNTL_EIE = 1 << 3;
114 static constexpr std::uint32_t CNTL_SIE = 1 << 2;
115 static constexpr std::uint32_t CNTL_IE = 1 << 1;
116 static constexpr std::uint32_t CNTL_INIT = 1 << 0;
117 
119 
120 /*
121  * TEST
122  */
123 static constexpr std::uint32_t TEST_RX = 1 << 7;
124 static constexpr std::uint32_t TEST_LBACK = 1 << 4;
125 static constexpr std::uint32_t TEST_SILENT = 1 << 3;
126 static constexpr std::uint32_t TEST_BASIC = 1 << 2;
127 static constexpr std::uint32_t TEST_TX_SHIFT = 5;
128 
129 enum class TestTx : std::uint32_t
130 {
131  Controller = 0,
132  SamplePoint = 1,
133  LowDominant = 2,
134  HighRecessive = 3
135 };
136 
137 /*
138  * STAT
139  */
140 static constexpr std::uint32_t STAT_BOFF = 1 << 7;
141 static constexpr std::uint32_t STAT_EWARN = 1 << 6;
142 static constexpr std::uint32_t STAT_EPASS = 1 << 5;
143 static constexpr std::uint32_t STAT_RXOK = 1 << 4;
144 static constexpr std::uint32_t STAT_TXOK = 1 << 3;
145 static constexpr std::uint32_t STAT_LEC_MASK = 7;
146 static constexpr std::uint32_t STAT_LEC_SHIFT = 0;
147 
148 enum class StatLec : std::uint32_t
149 {
150  NoError = 0,
151  StuffError = 1,
152  FormError = 2,
153  AckError = 3,
154  Bit1Error = 4,
155  Bit0Error = 5,
156  CRCError = 6,
157  Unused = 7
158 };
159 
160 /*
161  * IF.CMDREQ
162  */
163 static constexpr std::uint32_t IF_CMDREQ_BUSY = 1 << 15;
164 
165 /*
166  * IF.CMDMSK
167  */
168 static constexpr std::uint32_t IF_CMDMSK_W_DATA_A = 1 << 0;
169 static constexpr std::uint32_t IF_CMDMSK_W_DATA_B = 1 << 1;
170 static constexpr std::uint32_t IF_CMDMSK_W_TXRQST = 1 << 2;
171 static constexpr std::uint32_t IF_CMDMSK_W_CTRL = 1 << 4;
172 static constexpr std::uint32_t IF_CMDMSK_W_ARB = 1 << 5;
173 static constexpr std::uint32_t IF_CMDMSK_W_MASK = 1 << 6;
174 static constexpr std::uint32_t IF_CMDMSK_W_WR_RD = 1 << 7;
175 
176 /*
177  * IF.MCTRL
178  */
179 static constexpr std::uint32_t IF_MCTRL_NEWDAT = 1 << 15;
180 static constexpr std::uint32_t IF_MCTRL_MSGLST = 1 << 14;
181 static constexpr std::uint32_t IF_MCTRL_INTPND = 1 << 13;
182 static constexpr std::uint32_t IF_MCTRL_UMASK = 1 << 12;
183 static constexpr std::uint32_t IF_MCTRL_TXIE = 1 << 11;
184 static constexpr std::uint32_t IF_MCTRL_RXIE = 1 << 10;
185 static constexpr std::uint32_t IF_MCTRL_RMTEN = 1 << 9;
186 static constexpr std::uint32_t IF_MCTRL_TXRQST = 1 << 8;
187 static constexpr std::uint32_t IF_MCTRL_EOB = 1 << 7;
188 static constexpr std::uint32_t IF_MCTRL_DLC_MASK = 15;
189 
190 }
191 }
uavcan_lpc11c24::c_can::CNTL_SIE
static constexpr std::uint32_t CNTL_SIE
Definition: c_can.hpp:114
uavcan_lpc11c24::c_can::MsgIfaceType::W
std::uint32_t W
Definition: c_can.hpp:23
uavcan_lpc11c24::c_can::CNTL_IRQ_MASK
static constexpr std::uint32_t CNTL_IRQ_MASK
Definition: c_can.hpp:118
uavcan_lpc11c24::c_can::MsgIfaceType::MCTRL
std::uint32_t MCTRL
Definition: c_can.hpp:33
TEST
TEST(DataTypeSignatureCRC, Correctness)
Definition: data_type.cpp:9
uavcan_lpc11c24::c_can::Type::IR
const std::uint32_t IR[2]
Definition: c_can.hpp:77
uavcan_lpc11c24::c_can::MsgIfaceType::ARB2
std::uint32_t ARB2
Definition: c_can.hpp:31
uavcan_lpc11c24::c_can::MsgIfaceType
Definition: c_can.hpp:17
uavcan_lpc11c24::c_can::MsgIfaceType::ARB1
std::uint32_t ARB1
Definition: c_can.hpp:30
uavcan_lpc11c24::c_can::StatLec::FormError
@ FormError
uavcan_lpc11c24::c_can::Type::STAT
std::uint32_t STAT
Definition: c_can.hpp:56
uavcan::uint32_t
std::uint32_t uint32_t
Definition: std.hpp:26
uavcan_lpc11c24::c_can::IF_MCTRL_UMASK
static constexpr std::uint32_t IF_MCTRL_UMASK
Definition: c_can.hpp:182
uavcan_lpc11c24::c_can::IF_CMDMSK_W_CTRL
static constexpr std::uint32_t IF_CMDMSK_W_CTRL
Definition: c_can.hpp:171
uavcan_lpc11c24::c_can::MsgIfaceType::MSK2
std::uint32_t MSK2
Definition: c_can.hpp:28
uavcan_lpc11c24::c_can::TEST_SILENT
static constexpr std::uint32_t TEST_SILENT
Definition: c_can.hpp:125
uavcan_lpc11c24::c_can::MsgIfaceType::CMDMSK
union uavcan_lpc11c24::c_can::MsgIfaceType::@168 CMDMSK
uavcan_lpc11c24::c_can::STAT_BOFF
static constexpr std::uint32_t STAT_BOFF
Definition: c_can.hpp:140
uavcan_lpc11c24::c_can::STAT_RXOK
static constexpr std::uint32_t STAT_RXOK
Definition: c_can.hpp:143
uavcan_lpc11c24::c_can::TestTx::HighRecessive
@ HighRecessive
IR
#define IR
Definition: sja1000_defs.h:46
uavcan_lpc11c24::c_can::Type::INT
const std::uint32_t INT
Definition: c_can.hpp:59
uavcan_lpc11c24::c_can::IF_MCTRL_RMTEN
static constexpr std::uint32_t IF_MCTRL_RMTEN
Definition: c_can.hpp:185
uavcan_lpc11c24::c_can::CNTL_CCE
static constexpr std::uint32_t CNTL_CCE
Definition: c_can.hpp:111
uavcan_lpc11c24::c_can::StatLec::Bit1Error
@ Bit1Error
uavcan_lpc11c24::c_can::CNTL_DAR
static constexpr std::uint32_t CNTL_DAR
Definition: c_can.hpp:112
uavcan_lpc11c24::c_can::IF_MCTRL_MSGLST
static constexpr std::uint32_t IF_MCTRL_MSGLST
Definition: c_can.hpp:180
uavcan_lpc11c24::c_can::TEST_RX
static constexpr std::uint32_t TEST_RX
Definition: c_can.hpp:123
uavcan_lpc11c24::c_can::MsgIfaceType::R
std::uint32_t R
Definition: c_can.hpp:24
uavcan_lpc11c24::c_can::TEST_BASIC
static constexpr std::uint32_t TEST_BASIC
Definition: c_can.hpp:126
uavcan_lpc11c24::c_can::Type::CNTL
std::uint32_t CNTL
Definition: c_can.hpp:55
uavcan_lpc11c24::c_can::STAT_EPASS
static constexpr std::uint32_t STAT_EPASS
Definition: c_can.hpp:142
uavcan_lpc11c24::c_can::IF_MCTRL_TXRQST
static constexpr std::uint32_t IF_MCTRL_TXRQST
Definition: c_can.hpp:186
uavcan_lpc11c24::c_can::Type::MSGV
const std::uint32_t MSGV[2]
Definition: c_can.hpp:81
uavcan_lpc11c24::c_can::StatLec::StuffError
@ StuffError
uavcan_lpc11c24::c_can::IF_CMDMSK_W_ARB
static constexpr std::uint32_t IF_CMDMSK_W_ARB
Definition: c_can.hpp:172
uavcan_lpc11c24::c_can::CNTL_TEST
static constexpr std::uint32_t CNTL_TEST
Definition: c_can.hpp:110
uavcan_lpc11c24::c_can::MsgIfaceType::DB1
std::uint32_t DB1
Definition: c_can.hpp:37
uavcan_lpc11c24::c_can::Type::BRPE
std::uint32_t BRPE
Definition: c_can.hpp:61
uavcan_lpc11c24::c_can::MsgIfaceType::DB2
std::uint32_t DB2
Definition: c_can.hpp:38
uavcan_lpc11c24::c_can::STAT_TXOK
static constexpr std::uint32_t STAT_TXOK
Definition: c_can.hpp:144
uavcan_lpc11c24::c_can::Type::_skip_d
const std::uint32_t _skip_d[6]
Definition: c_can.hpp:75
uavcan_lpc11c24::c_can::MsgIfaceType::DA2
std::uint32_t DA2
Definition: c_can.hpp:36
uavcan_lpc11c24::c_can::CNTL_IE
static constexpr std::uint32_t CNTL_IE
Definition: c_can.hpp:115
uavcan_lpc11c24::c_can::IF_CMDMSK_W_MASK
static constexpr std::uint32_t IF_CMDMSK_W_MASK
Definition: c_can.hpp:173
uavcan_lpc11c24::c_can::Type::TEST
std::uint32_t TEST
Definition: c_can.hpp:60
uavcan_lpc11c24::c_can::IF_MCTRL_DLC_MASK
static constexpr std::uint32_t IF_MCTRL_DLC_MASK
Definition: c_can.hpp:188
uavcan_lpc11c24::c_can::MsgIfaceType::CMDREQ
std::uint32_t CMDREQ
Definition: c_can.hpp:19
uavcan_lpc11c24::c_can::TestTx::Controller
@ Controller
uavcan_lpc11c24::c_can::IF_MCTRL_RXIE
static constexpr std::uint32_t IF_MCTRL_RXIE
Definition: c_can.hpp:184
uavcan_lpc11c24::c_can::Type::_skip_e
const std::uint32_t _skip_e[6]
Definition: c_can.hpp:79
uavcan_lpc11c24::c_can::StatLec::CRCError
@ CRCError
uavcan_lpc11c24::c_can::MsgIfaceType::DA1
std::uint32_t DA1
Definition: c_can.hpp:35
uavcan_lpc11c24::c_can::IF_MCTRL_NEWDAT
static constexpr std::uint32_t IF_MCTRL_NEWDAT
Definition: c_can.hpp:179
uavcan_lpc11c24::c_can::Type::CLKDIV
std::uint32_t CLKDIV
Definition: c_can.hpp:85
uavcan_lpc11c24::c_can::TestTx::SamplePoint
@ SamplePoint
uavcan_lpc11c24::c_can::MsgIfaceType::MSK1
std::uint32_t MSK1
Definition: c_can.hpp:27
uavcan_lpc11c24::c_can::IF_CMDMSK_W_TXRQST
static constexpr std::uint32_t IF_CMDMSK_W_TXRQST
Definition: c_can.hpp:170
uavcan_lpc11c24::c_can::IF_CMDMSK_W_WR_RD
static constexpr std::uint32_t IF_CMDMSK_W_WR_RD
Definition: c_can.hpp:174
uavcan_lpc11c24::c_can::TEST_TX_SHIFT
static constexpr std::uint32_t TEST_TX_SHIFT
Definition: c_can.hpp:127
uavcan_lpc11c24::c_can::IF_CMDMSK_W_DATA_A
static constexpr std::uint32_t IF_CMDMSK_W_DATA_A
Definition: c_can.hpp:168
uavcan_lpc11c24::c_can::IF_MCTRL_INTPND
static constexpr std::uint32_t IF_MCTRL_INTPND
Definition: c_can.hpp:181
uavcan_lpc11c24::c_can::Type::ND
const std::uint32_t ND[2]
Definition: c_can.hpp:73
uavcan_lpc11c24::c_can::Type::BT
std::uint32_t BT
Definition: c_can.hpp:58
uavcan_lpc11c24::c_can::TEST_LBACK
static constexpr std::uint32_t TEST_LBACK
Definition: c_can.hpp:124
uavcan_lpc11c24::c_can::StatLec
StatLec
Definition: c_can.hpp:148
uavcan_lpc11c24::c_can::MsgIfaceType::_skip
const std::uint32_t _skip[13]
Definition: c_can.hpp:40
uavcan_lpc11c24::c_can::Type
Definition: c_can.hpp:53
uavcan_lpc11c24::c_can::Type::_skip_b
const std::uint32_t _skip_b[8]
Definition: c_can.hpp:67
uavcan_lpc11c24::c_can::IF_CMDMSK_W_DATA_B
static constexpr std::uint32_t IF_CMDMSK_W_DATA_B
Definition: c_can.hpp:169
TXREQ
#define TXREQ
Definition: mcp2515_defs.h:272
uavcan_lpc11c24::c_can::IF_CMDREQ_BUSY
static constexpr std::uint32_t IF_CMDREQ_BUSY
Definition: c_can.hpp:163
uavcan_lpc11c24::c_can::Type::_skip_a
const std::uint32_t _skip_a[1]
Definition: c_can.hpp:63
uavcan_lpc11c24::c_can::TestTx::LowDominant
@ LowDominant
uavcan_lpc11c24::c_can::StatLec::NoError
@ NoError
uavcan_lpc11c24::c_can::Type::EC
const std::uint32_t EC
Definition: c_can.hpp:57
uavcan_lpc11c24::c_can::TestTx
TestTx
Definition: c_can.hpp:129
uavcan_lpc11c24::c_can::Type::_skip_f
const std::uint32_t _skip_f[6]
Definition: c_can.hpp:83
uavcan_lpc11c24::c_can::STAT_LEC_SHIFT
static constexpr std::uint32_t STAT_LEC_SHIFT
Definition: c_can.hpp:146
uavcan_lpc11c24::c_can::Type::_skip_c
const std::uint32_t _skip_c[6]
Definition: c_can.hpp:71
uavcan_lpc11c24::c_can::CNTL_INIT
static constexpr std::uint32_t CNTL_INIT
Definition: c_can.hpp:116
uavcan_lpc11c24
Definition: platform_specific_components/lpc11c24/libuavcan/driver/include/uavcan_lpc11c24/can.hpp:9
uavcan_lpc11c24::c_can::IF_MCTRL_EOB
static constexpr std::uint32_t IF_MCTRL_EOB
Definition: c_can.hpp:187
uavcan_lpc11c24::c_can::Type::IF
MsgIfaceType IF[2]
Definition: c_can.hpp:65
uavcan_lpc11c24::c_can::StatLec::Unused
@ Unused
uavcan_lpc11c24::c_can::IF_MCTRL_TXIE
static constexpr std::uint32_t IF_MCTRL_TXIE
Definition: c_can.hpp:183
uavcan_lpc11c24::c_can::StatLec::AckError
@ AckError
uavcan_lpc11c24::c_can::StatLec::Bit0Error
@ Bit0Error
uavcan_lpc11c24::c_can::CAN
volatile Type & CAN
Definition: c_can.hpp:104
uavcan_lpc11c24::c_can::CNTL_EIE
static constexpr std::uint32_t CNTL_EIE
Definition: c_can.hpp:113
uavcan_lpc11c24::c_can::STAT_EWARN
static constexpr std::uint32_t STAT_EWARN
Definition: c_can.hpp:141
uavcan_lpc11c24::c_can::STAT_LEC_MASK
static constexpr std::uint32_t STAT_LEC_MASK
Definition: c_can.hpp:145
uavcan_lpc11c24::c_can::Type::TXREQ
const std::uint32_t TXREQ[2]
Definition: c_can.hpp:69


uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:02