1 /**
2   ******************************************************************************
3   * @file    ald_can.h
4   * @brief   Header file of CAN Module driver.
5   *
6   * @version V1.0
7   * @date    16 Apr 2019
8   * @author  AE Team
9   * @note
10   *
11   * Copyright (C) Shanghai Eastsoft Microelectronics Co. Ltd. All rights reserved.
12   *
13   * SPDX-License-Identifier: Apache-2.0
14   *
15   * Licensed under the Apache License, Version 2.0 (the License); you may
16   * not use this file except in compliance with the License.
17   * You may obtain a copy of the License at
18   *
19   * www.apache.org/licenses/LICENSE-2.0
20   *
21   * Unless required by applicable law or agreed to in writing, software
22   * distributed under the License is distributed on an AS IS BASIS, WITHOUT
23   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24   * See the License for the specific language governing permissions and
25   * limitations under the License.
26   *
27   ******************************************************************************
28   */
29 
30 #ifndef __ALD_CAN_H
31 #define __ALD_CAN_H
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #include "utils.h"
38 
39 /** @addtogroup ES32FXXX_ALD
40   * @{
41   */
42 
43 /** @addtogroup CAN
44   * @{
45   */
46 
47 /** @defgroup CAN_Public_Types CAN Public Types
48   * @{
49   */
50 /**
51   * @brief  ALD State structures definition
52   */
53 typedef enum {
54 	CAN_STATE_RESET           = 0x00U,	/**< CAN not yet initialized or disabled */
55 	CAN_STATE_READY           = 0x01U,	/**< CAN initialized and ready for use */
56 	CAN_STATE_BUSY            = 0x02U,	/**< CAN process is ongoing */
57 	CAN_STATE_BUSY_TX         = 0x11U,	/**< CAN process is ongoing */
58 	CAN_STATE_BUSY_RX0        = 0x21U,	/**< CAN process is ongoing */
59 	CAN_STATE_BUSY_RX1        = 0x41U,	/**< CAN process is ongoing */
60 	CAN_STATE_BUSY_TX_RX0     = 0x31U,	/**< CAN process is ongoing */
61 	CAN_STATE_BUSY_TX_RX1     = 0x51U,	/**< CAN process is ongoing */
62 	CAN_STATE_BUSY_RX0_RX1    = 0x61U,	/**< CAN process is ongoing */
63 	CAN_STATE_BUSY_TX_RX0_RX1 = 0x71U,	/**< CAN process is ongoing */
64 	CAN_STATE_TIMEOUT         = 0x04U,	/**< CAN in Timeout state */
65 	CAN_STATE_ERROR           = 0x08U,	/**< CAN error state */
66 } can_state_t;
67 
68 /**
69   * @brief CAN Error Code
70   */
71 typedef enum {
72 	CAN_ERROR_NONE = 0x00U,		/**< No error */
73 	CAN_ERROR_EWG  = 0x01U,		/**< EWG error */
74 	CAN_ERROR_EPV  = 0x02U,		/**< EPV error */
75 	CAN_ERROR_BOF  = 0x04U,		/**< BOF error */
76 	CAN_ERROR_STF  = 0x08U,		/**< Stuff error */
77 	CAN_ERROR_FOR  = 0x10U,		/**< Form error */
78 	CAN_ERROR_ACK  = 0x20U,		/**< Acknowledgment error */
79 	CAN_ERROR_BR   = 0x40U,		/**< Bit recessive */
80 	CAN_ERROR_BD   = 0x80U,		/**< LEC dominant */
81 	CAN_ERROR_CRC  = 0x100U,	/**< LEC transfer error */
82 	CAN_ERROR_UNK  = 0x200U,	/**< Unknown error */
83 } can_error_t;
84 
85 /**
86   * @brief CAN Operating Mode
87   */
88  typedef enum {
89 	CAN_MODE_NORMAL          =  0x00U,	/**< Normal mode */
90 	CAN_MODE_LOOPBACK        =  0x01U,	/**< Loopback mode */
91 	CAN_MODE_SILENT          =  0x02U,	/**< Silent mode */
92 	CAN_MODE_SILENT_LOOPBACK =  0x03U,  	/**< Loopback combined with silent mode */
93 } can_operate_mode_t;
94 
95 /**
96   * @brief CAN Synchronization Jump Width
97   */
98 typedef enum {
99 	CAN_SJW_1 = 0x0U,	/**< 1 time quantum */
100 	CAN_SJW_2 = 0x1U,	/**< 2 time quantum */
101 	CAN_SJW_3 = 0x2U,	/**< 3 time quantum */
102 	CAN_SJW_4 = 0x3U,	/**< 4 time quantum */
103 } can_sjw_t;
104 
105 /**
106   * @brief CAN Time Quantum in Bit Segment 1
107   */
108 typedef enum {
109 	CAN_SEG1_1  = 0x0U,	/**< 1 time quantum */
110 	CAN_SEG1_2  = 0x1U,	/**< 2 time quantum */
111 	CAN_SEG1_3  = 0x2U,	/**< 3 time quantum */
112 	CAN_SEG1_4  = 0x3U,	/**< 4 time quantum */
113 	CAN_SEG1_5  = 0x4U,	/**< 5 time quantum */
114 	CAN_SEG1_6  = 0x5U,	/**< 6 time quantum */
115 	CAN_SEG1_7  = 0x6U,	/**< 7 time quantum */
116 	CAN_SEG1_8  = 0x7U,	/**< 8 time quantum */
117 	CAN_SEG1_9  = 0x8U,	/**< 9 time quantum */
118 	CAN_SEG1_10 = 0x9U,	/**< 10 time quantum */
119 	CAN_SEG1_11 = 0xAU,	/**< 11 time quantum */
120 	CAN_SEG1_12 = 0xBU,	/**< 12 time quantum */
121 	CAN_SEG1_13 = 0xCU,	/**< 13 time quantum */
122 	CAN_SEG1_14 = 0xDU,	/**< 14 time quantum */
123 	CAN_SEG1_15 = 0xEU,	/**< 15 time quantum */
124 	CAN_SEG1_16 = 0xFU,	/**< 16 time quantum */
125 } can_seg1_t;
126 
127 /**
128   * @brief CAN Time Quantum in Bit Segment 2
129   */
130 typedef enum {
131 	CAN_SEG2_1 = 0x0U,	/**< 1 time quantum */
132 	CAN_SEG2_2 = 0x1U,     	/**< 2 time quantum */
133 	CAN_SEG2_3 = 0x2U,     	/**< 3 time quantum */
134 	CAN_SEG2_4 = 0x3U,     	/**< 4 time quantum */
135 	CAN_SEG2_5 = 0x4U,     	/**< 5 time quantum */
136 	CAN_SEG2_6 = 0x5U,     	/**< 6 time quantum */
137 	CAN_SEG2_7 = 0x6U,     	/**< 7 time quantum */
138 	CAN_SEG2_8 = 0x7U,     	/**< 8 time quantum */
139 } can_seg2_t;
140 
141 /**
142   * @brief CAN Filter Mode
143   */
144 typedef enum {
145 	CAN_FILTER_MODE_MASK = 0x0U,	/**< Identifier mask mode */
146 	CAN_FILTER_MODE_LIST = 0x1U,	/**< Identifier list mode */
147 } can_filter_mode_t;
148 
149 /**
150   * @brief CAN Filter Scale
151   */
152 typedef enum {
153 	CAN_FILTER_SCALE_16 = 0x0U,	/**< Two 16-bit filters */
154 	CAN_FILTER_SCALE_32 = 0x1U,	/**< One 32-bit filter */
155 } can_filter_scale_t;
156 
157 /**
158   * @brief CAN Filter fifo
159   */
160 typedef enum {
161 	CAN_FILTER_FIFO0 = 0x0U,	/**< FIFO 0 assignment for filter */
162 	CAN_FILTER_FIFO1 = 0x1U,	/**< FIFO 1 assignment for filter */
163 } can_filter_fifo_t;
164 
165 /**
166   * @brief CAN Identifier Type
167   */
168 typedef enum {
169 	CAN_ID_STD = 0x0U,	/**< Standard Id */
170 	CAN_ID_EXT = 0x1U,	/**< Extended Id */
171 } can_id_type_t;
172 
173 /**
174   * @brief CAN Remote Transmission Request
175   */
176 typedef enum {
177 	CAN_RTR_DATA   = 0x0U,	/**< Data frame */
178 	CAN_RTR_REMOTE = 0x1U, 	/**< Remote frame */
179 } can_remote_req_t;
180 
181 /**
182   * @brief CAN Transmit Constants
183   */
184 typedef enum {
185 	CAN_TX_MAILBOX_0    = 0x0U,	/**< TX mailbox index 0 */
186 	CAN_TX_MAILBOX_1    = 0x1U,	/**< TX mailbox index 1 */
187 	CAN_TX_MAILBOX_2    = 0x2U,	/**< TX mailbox index 2 */
188 	CAN_TX_MAILBOX_NONE = 0x3U,	/**< MailBox can't be used */
189 } can_tx_mailbox_t;
190 
191 /**
192   * @brief  CAN Receive fifo Number
193   */
194 typedef enum {
195 	CAN_RX_FIFO0 = 0x0U,	/**< CAN fifo 0 used to receive */
196 	CAN_RX_FIFO1 = 0x1U,	/**< CAN fifo 1 used to receive */
197 } can_rx_fifo_t;
198 
199 /**
200   * @brief  CAN Flags
201   */
202 typedef enum {
203 	CAN_FLAG_SLPS   = (1U << 1),			/**< Sleep acknowledge flag */
204 	CAN_FLAG_ERR    = (1U << 2),			/**< Error flag*/
205 	CAN_FLAG_WK     = (1U << 3),			/**< Wake up flag */
206 	CAN_FLAG_SLP    = (1U << 4),			/**< Sleep acknowledge flag */
207 	CAN_FLAG_M0REQC = (1U << 20) | (1U << 0),	/**< Request MailBox0 flag */
208 	CAN_FLAG_M0TXC  = (1U << 20) | (1U << 1),	/**< Transmission OK MailBox0 flag */
209 	CAN_FLAG_M1REQC = (1U << 20) | (1U << 8),	/**< Request MailBox1 flag */
210 	CAN_FLAG_M1TXC  = (1U << 20) | (1U << 9),	/**< Transmission OK MailBox1 flag */
211 	CAN_FLAG_M2REQC = (1U << 20) | (1U << 16),	/**< Request MailBox2 flag */
212 	CAN_FLAG_M2TXC  = (1U << 20) | (1U << 17),	/**< Transmission OK MailBox2 flag */
213 	CAN_FLAG_TXM0   = (1U << 20) | (1U << 26),	/**< Transmit mailbox 0 empty flag */
214 	CAN_FLAG_TXM1   = (1U << 20) | (1U << 27),	/**< Transmit mailbox 1 empty flag */
215 	CAN_FLAG_TXM2   = (1U << 20) | (1U << 28),	/**< Transmit mailbox 2 empty flag */
216 	CAN_FLAG_FF0    = (2U << 20) | (1U << 3),	/**< FIFO 0 Full flag */
217 	CAN_FLAG_FOV0   = (2U << 20) | (1U << 4),	/**< FIFO 0 Overrun flag */
218 	CAN_FLAG_FF1    = (3U << 20) | (1U << 3),	/**< FIFO 1 Full flag */
219 	CAN_FLAG_FOV1   = (3U << 20) | (1U << 4),	/**< FIFO 1 Overrun flag */
220 	CAN_FLAG_WARN   = (4U << 20) | (1U << 0),	/**< Error warning flag */
221 	CAN_FLAG_PERR   = (4U << 20) | (1U << 1),	/**< Error passive flag */
222 	CAN_FLAG_BOF    = (4U << 20) | (1U << 2),	/**< Bus-Off flag */
223 } can_flag_t;
224 
225 /**
226   * @brief CAN Interrupts
227   */
228 typedef enum {
229 	CAN_IT_TXM   = (1U << 0),	/**< Transmit mailbox empty interrupt bit */
230 	CAN_IT_FP0   = (1U << 1),	/**< FIFO0 message pending interrupt bit */
231 	CAN_IT_FF0   = (1U << 2),	/**< FIFO0 full interrupt bit */
232 	CAN_IT_FOV0  = (1U << 3),	/**< FIFO0 overrun interrupt bit */
233 	CAN_IT_FP1   = (1U << 4),	/**< FIFO1 message pending interrupt bit */
234 	CAN_IT_FF1   = (1U << 5),	/**< FIFO1 full interrupt bit */
235 	CAN_IT_FOV1  = (1U << 6),	/**< FIFO1 overrun interrupt bit */
236 	CAN_IT_WARN  = (1U << 8),	/**< Error warning interrupt bit */
237 	CAN_IT_PERR  = (1U << 9),	/**< Error passive interrupt bit */
238 	CAN_IT_BOF   = (1U << 10),	/**< Bus-off interrupt bit */
239 	CAN_IT_PRERR = (1U << 11),	/**< Last error code interrupt bit */
240 	CAN_IT_ERR   = (1U << 15),	/**< Error interrupt bit */
241 	CAN_IT_WK    = (1U << 16),	/**< wake-up interrupt bit */
242 	CAN_IT_SLP   = (1U << 17),	/**< sleep interrupt bit */
243 } can_it_t;
244 
245 /**
246   * @brief CAN filter configuration structure definition
247   */
248 typedef struct {
249 	uint32_t id_high;		/**< Specifies the filter identification number */
250 	uint32_t id_low;		/**< Specifies the filter identification number */
251 	uint32_t mask_id_high;		/**< Specifies the filter mask number or identification number */
252 	uint32_t mask_id_low;		/**< Specifies the filter mask number or identification number */
253 	can_filter_fifo_t fifo;		/**< Specifies the fifo (0 or 1) which will be assigned to the filter. */
254 	uint32_t number;		/**< Specifies the filter which will be initialized. */
255 	can_filter_mode_t mode;		/**< Specifies the filter mode to be initialized. */
256 	can_filter_scale_t scale;	/**< Specifies the filter scale. */
257 	type_func_t active;		/**< Enable or disable the filter. */
258 } can_filter_t;
259 
260 /**
261   * @brief CAN init structure definition
262   */
263 typedef struct {
264 	uint32_t psc;			/**< Specifies the length of a time quantum. */
265 	can_operate_mode_t mode;	/**< Specifies the CAN operating mode. */
266 	can_sjw_t sjw;			/**< Specifies the maximum number of time quanta the CAN hardware is
267 	                                       allowed to lengthen or shorten a bit to perform resynchronization. */
268 	can_seg1_t seg1;		/**< Specifies the number of time quanta in Bit Segment 1. */
269 	can_seg2_t seg2;		/**< Specifies the number of time quanta in Bit Segment 2. */
270 	type_func_t ttcm;		/**< Enable or disable the time triggered communication mode. */
271 	type_func_t abom;		/**< Enable or disable the automatic bus-off management. */
272 	type_func_t awk;		/**< Enable or disable the automatic wake-up mode. */
273 	type_func_t artx;		/**< Enable or disable the non-automatic retransmission mode. */
274 	type_func_t rfom;		/**< Enable or disable the Receive fifo Locked mode. */
275 	type_func_t txmp;		/**< Enable or disable the transmit fifo priority. */
276 } can_init_t;
277 
278 /**
279   * @brief CAN Tx message structure definition
280   */
281 typedef struct {
282 	uint32_t std;		/**< Specifies the standard identifier. */
283 	uint32_t ext;		/**< Specifies the extended identifier. */
284 	can_id_type_t type;	/**< Specifies the type of identifier for the message that will be transmitted. */
285 	can_remote_req_t rtr;	/**< Specifies the type of frame for the message that will be transmitted. */
286 	uint32_t len;		/**< Specifies the length of the frame that will be transmitted. */
287 	uint8_t data[8];	/**< Contains the data to be transmitted. */
288 } can_tx_msg_t;
289 
290 /**
291   * @brief CAN Rx message structure definition
292   */
293 typedef struct {
294 	uint32_t std;		/**< Specifies the standard identifier. */
295 	uint32_t ext;		/**< Specifies the extended identifier. */
296 	can_id_type_t type;	/**< Specifies the type of identifier for the message that will be received. */
297 	can_remote_req_t rtr;	/**< Specifies the type of frame for the received message. */
298 	uint32_t len;		/**< Specifies the length of the frame that will be received. */
299 	uint8_t data[8];	/**< Contains the data to be received. */
300 	uint32_t fmi;		/**< Specifies the index of the filter the message stored in the mailbox passes through. */
301 	can_rx_fifo_t num;	/**< Specifies the receive fifo number. */
302 } can_rx_msg_t;
303 
304 /**
305   * @brief CAN handle Structure definition
306   */
307 typedef struct can_handle_s {
308 	CAN_TypeDef *perh;	/**< Register base address */
309 	can_init_t init;	/**< CAN required parameters */
310 	can_rx_msg_t *rx0_msg;	/**< Pointer to receive message from FIFO0 */
311 	can_rx_msg_t *rx1_msg;	/**< Pointer to receive message from FIFO1 */
312 	lock_state_t lock;	/**< CAN locking object */
313 	can_state_t state;	/**< CAN communication state */
314 	can_error_t err;	/**< CAN Error code */
315 
316 	void (*tx_cplt_cbk)(struct can_handle_s *arg);				/**< Tx completed callback */
317 	void (*rx_cplt_cbk)(struct can_handle_s *arg, can_rx_fifo_t num);	/**< Rx completed callback */
318 	void (*error_cbk)(struct can_handle_s *arg);				/**< error callback */
319 } can_handle_t;
320 /**
321   * @}
322   */
323 
324 /** @defgroup CAN_Public_Macro CAN Public Macros
325   * @{
326   */
327 #define CAN_RESET_HANDLE_STATE(x)	((x)->state = CAN_STATE_RESET)
328 #define CAN_RX_MSG_PENDING(x, y)	(((y) == CAN_RX_FIFO0) ? \
329 	(READ_BIT((x)->perh->RXF0, CAN_RXF0_PEND_MSK)) : (READ_BIT((x)->perh->RXF1, CAN_RXF1_PEND_MSK)))
330 #define CAN_DBG_FREEZE(x, y)	(MODIFY_REG((x)->perh->CON, CAN_CON_DBGSTP_MSK, (y) << CAN_CON_DBGSTP_POS))
331 #define CAN_TX_STAMP_ENABLE(x, y)	(SET_BIT((x)->perh->TxMailBox[(y)].TXFCON, CAN_TXFCON0_TXGT_MSK))
332 #define CAN_TX_STAMP_DISABLE(x, y)	(CLEAR_BIT((x)->perh->TxMailBox[(y)].TXFCON, CAN_TXFCON0_TXGT_MSK))
333 /**
334   * @}
335   */
336 
337 /** @defgroup CAN_Private_Macros CAN Private Macros
338   * @{
339   */
340 #define IS_CAN_ALL(x)	((x) == CAN0)
341 #define IS_CAN_FILTER_NUMBER(x) ((x) <= 13)
342 #define IS_CAN_MODE(x)	(((x) == CAN_MODE_NORMAL)   || \
343                          ((x) == CAN_MODE_LOOPBACK) || \
344                          ((x) == CAN_MODE_SILENT)   || \
345                          ((x) == CAN_MODE_SILENT_LOOPBACK))
346 #define IS_CAN_SJW(x)	(((x) == CAN_SJW_1) || \
347                          ((x) == CAN_SJW_2) || \
348                          ((x) == CAN_SJW_3) || \
349                          ((x) == CAN_SJW_4))
350 #define IS_CAN_BS1(x)	((x) <= CAN_SEG1_16)
351 #define IS_CAN_BS2(x)	((x) <= CAN_SEG2_8)
352 #define IS_CAN_FILTER_MODE(x)	(((x) == CAN_FILTER_MODE_MASK) || \
353                                  ((x) == CAN_FILTER_MODE_LIST))
354 #define IS_CAN_FILTER_SCALE(x)	(((x) == CAN_FILTER_SCALE_16) || \
355                                  ((x) == CAN_FILTER_SCALE_32))
356 #define IS_CAN_FILTER_FIFO(x)	(((x) == CAN_FILTER_FIFO0) || \
357                                  ((x) == CAN_FILTER_FIFO1))
358 #define IS_CAN_IDTYPE(x)	(((x) == CAN_ID_STD) || \
359                                  ((x) == CAN_ID_EXT))
360 #define IS_CAN_RTR(x)	(((x) == CAN_RTR_DATA) || ((x) == CAN_RTR_REMOTE))
361 #define IS_CAN_FIFO(x)	(((x) == CAN_RX_FIFO0) || ((x) == CAN_RX_FIFO1))
362 #define IS_CAN_TX_MAILBOX(x)	((x) <= CAN_TX_MAILBOX_NONE)
363 #define IS_CAN_STDID(x)		((x) <= ((uint32_t)0x7FF))
364 #define IS_CAN_EXTID(x)		((x) <= ((uint32_t)0x1FFFFFFF))
365 #define IS_CAN_DATA_LEN(x)	((x) <= ((uint8_t)0x08))
366 #define IS_CAN_PRESCALER(x)	(((x) >= 1) && ((x) <= 1024))
367 #define IS_CAN_GET_FLAG(x)	(((x)  == CAN_FLAG_SLPS)   || \
368                                   ((x) == CAN_FLAG_ERR)    || \
369                                   ((x) == CAN_FLAG_WK)     || \
370                                   ((x) == CAN_FLAG_SLP)    || \
371                                   ((x) == CAN_FLAG_M0REQC) || \
372                                   ((x) == CAN_FLAG_M0TXC)  || \
373                                   ((x) == CAN_FLAG_M1REQC) || \
374                                   ((x) == CAN_FLAG_M1TXC)  || \
375                                   ((x) == CAN_FLAG_M2REQC) || \
376                                   ((x) == CAN_FLAG_M2TXC)  || \
377                                   ((x) == CAN_FLAG_TXM0)   || \
378                                   ((x) == CAN_FLAG_TXM1)   || \
379                                   ((x) == CAN_FLAG_TXM2)   || \
380                                   ((x) == CAN_FLAG_FF0)    || \
381                                   ((x) == CAN_FLAG_FOV0)   || \
382                                   ((x) == CAN_FLAG_FF1)    || \
383                                   ((x) == CAN_FLAG_FOV1)   || \
384                                   ((x) == CAN_FLAG_WARN)   || \
385                                   ((x) == CAN_FLAG_PERR)   || \
386                                   ((x) == CAN_FLAG_BOF))
387 #define IS_CAN_CLEAR_FLAG(x)	(((x)  == CAN_FLAG_ERR)    || \
388                                   ((x) == CAN_FLAG_WK)     || \
389                                   ((x) == CAN_FLAG_SLP)    || \
390                                   ((x) == CAN_FLAG_M0REQC) || \
391                                   ((x) == CAN_FLAG_M1REQC) || \
392                                   ((x) == CAN_FLAG_M2REQC) || \
393                                   ((x) == CAN_FLAG_FF0)    || \
394                                   ((x) == CAN_FLAG_FOV0)   || \
395                                   ((x) == CAN_FLAG_FF1)    || \
396                                   ((x) == CAN_FLAG_FOV1))
397 #define IS_CAN_IT(x)		(((x)  == CAN_IT_TXM)   || \
398                                   ((x) == CAN_IT_FP0) || \
399                                   ((x) == CAN_IT_FF0) || \
400                                   ((x) == CAN_IT_FOV0) || \
401                                   ((x) == CAN_IT_FP1) || \
402                                   ((x) == CAN_IT_FF1)   || \
403                                   ((x) == CAN_IT_FOV1)  || \
404                                   ((x) == CAN_IT_WARN)   || \
405 				  ((x) == CAN_IT_PERR) || \
406                                   ((x) == CAN_IT_BOF) || \
407                                   ((x) == CAN_IT_PRERR) || \
408                                   ((x) == CAN_IT_ERR)   || \
409                                   ((x) == CAN_IT_WK)  || \
410                                   ((x) == CAN_IT_SLP))
411 #define CAN_TIMEOUT_VALUE	100
412 #define CAN_STATE_TX_MASK	(1U << 4)
413 #define CAN_STATE_RX0_MASK	(1U << 5)
414 #define CAN_STATE_RX1_MASK	(1U << 6)
415 
416 /**
417   * @}
418   */
419 
420 /** @addtogroup CAN_Public_Functions
421   * @{
422   */
423 
424 /** @addtogroup CAN_Public_Functions_Group1
425   *  @{
426   */
427 /* Initialization functions */
428 void ald_can_reset(can_handle_t *hperh);
429 ald_status_t ald_can_init(can_handle_t *hperh);
430 ald_status_t ald_can_filter_config(can_handle_t *hperh, can_filter_t *config);
431 /**
432   * @}
433   */
434 
435 /** @addtogroup CAN_Public_Functions_Group2
436   * @{
437   */
438 /* IO operation functions */
439 ald_status_t ald_can_send(can_handle_t *hperh, can_tx_msg_t *msg, uint32_t timeout);
440 ald_status_t ald_can_send_by_it(can_handle_t *hperh, can_tx_msg_t *msg);
441 ald_status_t ald_can_recv(can_handle_t *hperh, can_rx_fifo_t num, can_rx_msg_t *msg, uint32_t timeout);
442 ald_status_t ald_can_recv_by_it(can_handle_t *hperh, can_rx_fifo_t num, can_rx_msg_t *msg);
443 /**
444   * @}
445   */
446 
447 /** @addtogroup CAN_Public_Functions_Group3
448   * @{
449   */
450 /* Control function */
451 ald_status_t ald_can_sleep(can_handle_t *hperh);
452 ald_status_t ald_can_wake_up(can_handle_t *hperh);
453 void ald_can_cancel_send(can_handle_t *hperh, can_tx_mailbox_t box);
454 void ald_can_irq_handler(can_handle_t *hperh);
455 type_bool_t ald_can_get_tx_status(can_handle_t *hperh, can_tx_mailbox_t box);
456 void ald_can_interrupt_config(can_handle_t *hperh, can_it_t it, type_func_t state);
457 it_status_t ald_can_get_it_status(can_handle_t *hperh, can_it_t it);
458 flag_status_t ald_can_get_flag_status(can_handle_t *hperh, can_flag_t flag);
459 void ald_can_clear_flag_status(can_handle_t *hperh, can_flag_t flag);
460 /**
461   * @}
462   */
463 
464 /** @addtogroup CAN_Public_Functions_Group4
465   * @{
466   */
467 /* State and Error functions */
468 can_state_t ald_can_get_state(can_handle_t *hperh);
469 can_error_t ald_can_get_error(can_handle_t *hperh);
470 /**
471   * @}
472   */
473 
474 /**
475   * @}
476   */
477 
478 /**
479   * @}
480   */
481 
482 /**
483   * @}
484   */
485 
486 #ifdef __cplusplus
487 }
488 #endif
489 
490 #endif /* __ALD_CAN_H */
491