ChibiOS/HAL 9.0.0
hal_can_lld.c
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file hal_can_lld.c
19 * @brief PLATFORM CAN subsystem low level driver source.
20 *
21 * @addtogroup CAN
22 * @{
23 */
24
25#include "hal.h"
26
27#if (HAL_USE_CAN == TRUE) || defined(__DOXYGEN__)
28
29/*===========================================================================*/
30/* Driver local definitions. */
31/*===========================================================================*/
32
33/*===========================================================================*/
34/* Driver exported variables. */
35/*===========================================================================*/
36
37/**
38 * @brief CAN1 driver identifier.
39 */
40#if (PLATFORM_CAN_USE_CAN1 == TRUE) || defined(__DOXYGEN__)
42#endif
43
44/*===========================================================================*/
45/* Driver local variables and types. */
46/*===========================================================================*/
47
48/*===========================================================================*/
49/* Driver local functions. */
50/*===========================================================================*/
51
52/*===========================================================================*/
53/* Driver interrupt handlers. */
54/*===========================================================================*/
55
56/*===========================================================================*/
57/* Driver exported functions. */
58/*===========================================================================*/
59
60/**
61 * @brief Low level CAN driver initialization.
62 *
63 * @notapi
64 */
65void can_lld_init(void) {
66
67#if PLATFORM_CAN_USE_CAN1 == TRUE
68 /* Driver initialization.*/
70#endif
71}
72
73/**
74 * @brief Configures and activates the CAN peripheral.
75 *
76 * @param[in] canp pointer to the @p CANDriver object
77 *
78 * @notapi
79 */
81
82 if (canp->state == CAN_STOP) {
83 /* Enables the peripheral.*/
84#if PLATFORM_CAN_USE_CAN1 == TRUE
85 if (&CAND1 == canp) {
86
87 }
88#endif
89 }
90 /* Configures the peripheral.*/
91
92}
93
94/**
95 * @brief Deactivates the CAN peripheral.
96 *
97 * @param[in] canp pointer to the @p CANDriver object
98 *
99 * @notapi
100 */
102
103 if (canp->state == CAN_READY) {
104 /* Resets the peripheral.*/
105
106 /* Disables the peripheral.*/
107#if PLATFORM_CAN_USE_CAN1 == TRUE
108 if (&CAND1 == canp) {
109
110 }
111#endif
112 }
113}
114
115/**
116 * @brief Determines whether a frame can be transmitted.
117 *
118 * @param[in] canp pointer to the @p CANDriver object
119 * @param[in] mailbox mailbox number, @p CAN_ANY_MAILBOX for any mailbox
120 *
121 * @return The queue space availability.
122 * @retval false no space in the transmit queue.
123 * @retval true transmit slot available.
124 *
125 * @notapi
126 */
128
129 (void)canp;
130
131 switch (mailbox) {
132 case CAN_ANY_MAILBOX:
133 return false;
134 case 1:
135 return false;
136 case 2:
137 return false;
138 case 3:
139 return false;
140 default:
141 return false;
142 }
143}
144
145/**
146 * @brief Inserts a frame into the transmit queue.
147 *
148 * @param[in] canp pointer to the @p CANDriver object
149 * @param[in] ctfp pointer to the CAN frame to be transmitted
150 * @param[in] mailbox mailbox number, @p CAN_ANY_MAILBOX for any mailbox
151 *
152 * @notapi
153 */
155 canmbx_t mailbox,
156 const CANTxFrame *ctfp) {
157
158 (void)canp;
159 (void)mailbox;
160 (void)ctfp;
161
162}
163
164/**
165 * @brief Determines whether a frame has been received.
166 *
167 * @param[in] canp pointer to the @p CANDriver object
168 * @param[in] mailbox mailbox number, @p CAN_ANY_MAILBOX for any mailbox
169 *
170 * @return The queue space availability.
171 * @retval false no space in the transmit queue.
172 * @retval true transmit slot available.
173 *
174 * @notapi
175 */
177
178 (void)canp;
179 (void)mailbox;
180
181 switch (mailbox) {
182 case CAN_ANY_MAILBOX:
183 return false;
184 case 1:
185 return false;
186 case 2:
187 return false;
188 default:
189 return false;
190 }
191}
192
193/**
194 * @brief Receives a frame from the input queue.
195 *
196 * @param[in] canp pointer to the @p CANDriver object
197 * @param[in] mailbox mailbox number, @p CAN_ANY_MAILBOX for any mailbox
198 * @param[out] crfp pointer to the buffer where the CAN frame is copied
199 *
200 * @notapi
201 */
203 canmbx_t mailbox,
204 CANRxFrame *crfp) {
205
206 (void)canp;
207 (void)mailbox;
208 (void)crfp;
209
210}
211
212/**
213 * @brief Tries to abort an ongoing transmission.
214 *
215 * @param[in] canp pointer to the @p CANDriver object
216 * @param[in] mailbox mailbox number
217 *
218 * @notapi
219 */
221 canmbx_t mailbox) {
222
223 (void)canp;
224 (void)mailbox;
225}
226
227#if (CAN_USE_SLEEP_MODE == TRUE) || defined(__DOXYGEN__)
228/**
229 * @brief Enters the sleep mode.
230 *
231 * @param[in] canp pointer to the @p CANDriver object
232 *
233 * @notapi
234 */
236
237 (void)canp;
238
239}
240
241/**
242 * @brief Enforces leaving the sleep mode.
243 *
244 * @param[in] canp pointer to the @p CANDriver object
245 *
246 * @notapi
247 */
249
250 (void)canp;
251
252}
253#endif /* CAN_USE_SLEEP_MOD == TRUEE */
254
255#endif /* HAL_USE_CAN == TRUE */
256
257/** @} */
void can_lld_receive(CANDriver *canp, canmbx_t mailbox, CANRxFrame *crfp)
Receives a frame from the input queue.
uint32_t canmbx_t
Type of a transmission mailbox index.
Definition hal_can_lld.h:78
#define CAN_ANY_MAILBOX
Special mailbox identifier.
Definition hal_can.h:63
CANDriver CAND1
CAN1 driver identifier.
Definition hal_can_lld.c:41
void can_lld_transmit(CANDriver *canp, canmbx_t mailbox, const CANTxFrame *ctfp)
Inserts a frame into the transmit queue.
void can_lld_abort(CANDriver *canp, canmbx_t mailbox)
Tries to abort an ongoing transmission.
void can_lld_wakeup(CANDriver *canp)
Enforces leaving the sleep mode.
void can_lld_sleep(CANDriver *canp)
Enters the sleep mode.
void can_lld_init(void)
Low level CAN driver initialization.
Definition hal_can_lld.c:65
struct hal_can_driver CANDriver
Type of a structure representing an CAN driver.
Definition hal_can_lld.h:73
void can_lld_stop(CANDriver *canp)
Deactivates the CAN peripheral.
void canObjectInit(CANDriver *canp)
Initializes the standard part of a CANDriver structure.
Definition hal_can.c:68
bool can_lld_is_rx_nonempty(CANDriver *canp, canmbx_t mailbox)
Determines whether a frame has been received.
bool can_lld_is_tx_empty(CANDriver *canp, canmbx_t mailbox)
Determines whether a frame can be transmitted.
void can_lld_start(CANDriver *canp)
Configures and activates the CAN peripheral.
Definition hal_can_lld.c:80
@ CAN_STOP
Definition hal_can.h:104
@ CAN_READY
Definition hal_can.h:107
HAL subsystem header.
CAN received frame.
CAN transmission frame.
Definition hal_can_lld.h:96
canstate_t state
Driver state.