2 ******************************************************************************
3 * @file stm32f4xx_can.h
4 * @author MCD Application Team
7 * @brief This file contains all the functions prototypes for the CAN firmware
9 ******************************************************************************
12 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
19 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
20 ******************************************************************************
23 /* Define to prevent recursive inclusion -------------------------------------*/
24 #ifndef __STM32F4xx_CAN_H
25 #define __STM32F4xx_CAN_H
31 /* Includes ------------------------------------------------------------------*/
32 #include "stm32f4xx.h"
34 /** @addtogroup STM32F4xx_StdPeriph_Driver
42 /* Exported types ------------------------------------------------------------*/
44 #define IS_CAN_ALL_PERIPH(PERIPH) (((PERIPH) == CAN1) || \
48 * @brief CAN init structure definition
52 uint16_t CAN_Prescaler; /*!< Specifies the length of a time quantum.
53 It ranges from 1 to 1024. */
55 uint8_t CAN_Mode; /*!< Specifies the CAN operating mode.
56 This parameter can be a value of @ref CAN_operating_mode */
58 uint8_t CAN_SJW; /*!< Specifies the maximum number of time quanta
59 the CAN hardware is allowed to lengthen or
60 shorten a bit to perform resynchronization.
61 This parameter can be a value of @ref CAN_synchronisation_jump_width */
63 uint8_t CAN_BS1; /*!< Specifies the number of time quanta in Bit
64 Segment 1. This parameter can be a value of
65 @ref CAN_time_quantum_in_bit_segment_1 */
67 uint8_t CAN_BS2; /*!< Specifies the number of time quanta in Bit Segment 2.
68 This parameter can be a value of @ref CAN_time_quantum_in_bit_segment_2 */
70 FunctionalState CAN_TTCM; /*!< Enable or disable the time triggered communication mode.
71 This parameter can be set either to ENABLE or DISABLE. */
73 FunctionalState CAN_ABOM; /*!< Enable or disable the automatic bus-off management.
74 This parameter can be set either to ENABLE or DISABLE. */
76 FunctionalState CAN_AWUM; /*!< Enable or disable the automatic wake-up mode.
77 This parameter can be set either to ENABLE or DISABLE. */
79 FunctionalState CAN_NART; /*!< Enable or disable the non-automatic retransmission mode.
80 This parameter can be set either to ENABLE or DISABLE. */
82 FunctionalState CAN_RFLM; /*!< Enable or disable the Receive FIFO Locked mode.
83 This parameter can be set either to ENABLE or DISABLE. */
85 FunctionalState CAN_TXFP; /*!< Enable or disable the transmit FIFO priority.
86 This parameter can be set either to ENABLE or DISABLE. */
90 * @brief CAN filter init structure definition
94 uint16_t CAN_FilterIdHigh; /*!< Specifies the filter identification number (MSBs for a 32-bit
95 configuration, first one for a 16-bit configuration).
96 This parameter can be a value between 0x0000 and 0xFFFF */
98 uint16_t CAN_FilterIdLow; /*!< Specifies the filter identification number (LSBs for a 32-bit
99 configuration, second one for a 16-bit configuration).
100 This parameter can be a value between 0x0000 and 0xFFFF */
102 uint16_t CAN_FilterMaskIdHigh; /*!< Specifies the filter mask number or identification number,
103 according to the mode (MSBs for a 32-bit configuration,
104 first one for a 16-bit configuration).
105 This parameter can be a value between 0x0000 and 0xFFFF */
107 uint16_t CAN_FilterMaskIdLow; /*!< Specifies the filter mask number or identification number,
108 according to the mode (LSBs for a 32-bit configuration,
109 second one for a 16-bit configuration).
110 This parameter can be a value between 0x0000 and 0xFFFF */
112 uint16_t CAN_FilterFIFOAssignment; /*!< Specifies the FIFO (0 or 1) which will be assigned to the filter.
113 This parameter can be a value of @ref CAN_filter_FIFO */
115 uint8_t CAN_FilterNumber; /*!< Specifies the filter which will be initialized. It ranges from 0 to 13. */
117 uint8_t CAN_FilterMode; /*!< Specifies the filter mode to be initialized.
118 This parameter can be a value of @ref CAN_filter_mode */
120 uint8_t CAN_FilterScale; /*!< Specifies the filter scale.
121 This parameter can be a value of @ref CAN_filter_scale */
123 FunctionalState CAN_FilterActivation; /*!< Enable or disable the filter.
124 This parameter can be set either to ENABLE or DISABLE. */
125 } CAN_FilterInitTypeDef;
128 * @brief CAN Tx message structure definition
132 uint32_t StdId; /*!< Specifies the standard identifier.
133 This parameter can be a value between 0 to 0x7FF. */
135 uint32_t ExtId; /*!< Specifies the extended identifier.
136 This parameter can be a value between 0 to 0x1FFFFFFF. */
138 uint8_t IDE; /*!< Specifies the type of identifier for the message that
139 will be transmitted. This parameter can be a value
140 of @ref CAN_identifier_type */
142 uint8_t RTR; /*!< Specifies the type of frame for the message that will
143 be transmitted. This parameter can be a value of
144 @ref CAN_remote_transmission_request */
146 uint8_t DLC; /*!< Specifies the length of the frame that will be
147 transmitted. This parameter can be a value between
150 uint8_t Data[8]; /*!< Contains the data to be transmitted. It ranges from 0
155 * @brief CAN Rx message structure definition
159 uint32_t StdId; /*!< Specifies the standard identifier.
160 This parameter can be a value between 0 to 0x7FF. */
162 uint32_t ExtId; /*!< Specifies the extended identifier.
163 This parameter can be a value between 0 to 0x1FFFFFFF. */
165 uint8_t IDE; /*!< Specifies the type of identifier for the message that
166 will be received. This parameter can be a value of
167 @ref CAN_identifier_type */
169 uint8_t RTR; /*!< Specifies the type of frame for the received message.
170 This parameter can be a value of
171 @ref CAN_remote_transmission_request */
173 uint8_t DLC; /*!< Specifies the length of the frame that will be received.
174 This parameter can be a value between 0 to 8 */
176 uint8_t Data[8]; /*!< Contains the data to be received. It ranges from 0 to
179 uint8_t FMI; /*!< Specifies the index of the filter the message stored in
180 the mailbox passes through. This parameter can be a
181 value between 0 to 0xFF */
184 /* Exported constants --------------------------------------------------------*/
186 /** @defgroup CAN_Exported_Constants
190 /** @defgroup CAN_InitStatus
194 #define CAN_InitStatus_Failed ((uint8_t)0x00) /*!< CAN initialization failed */
195 #define CAN_InitStatus_Success ((uint8_t)0x01) /*!< CAN initialization OK */
199 #define CANINITFAILED CAN_InitStatus_Failed
200 #define CANINITOK CAN_InitStatus_Success
205 /** @defgroup CAN_operating_mode
209 #define CAN_Mode_Normal ((uint8_t)0x00) /*!< normal mode */
210 #define CAN_Mode_LoopBack ((uint8_t)0x01) /*!< loopback mode */
211 #define CAN_Mode_Silent ((uint8_t)0x02) /*!< silent mode */
212 #define CAN_Mode_Silent_LoopBack ((uint8_t)0x03) /*!< loopback combined with silent mode */
214 #define IS_CAN_MODE(MODE) (((MODE) == CAN_Mode_Normal) || \
215 ((MODE) == CAN_Mode_LoopBack)|| \
216 ((MODE) == CAN_Mode_Silent) || \
217 ((MODE) == CAN_Mode_Silent_LoopBack))
224 * @defgroup CAN_operating_mode
227 #define CAN_OperatingMode_Initialization ((uint8_t)0x00) /*!< Initialization mode */
228 #define CAN_OperatingMode_Normal ((uint8_t)0x01) /*!< Normal mode */
229 #define CAN_OperatingMode_Sleep ((uint8_t)0x02) /*!< sleep mode */
232 #define IS_CAN_OPERATING_MODE(MODE) (((MODE) == CAN_OperatingMode_Initialization) ||\
233 ((MODE) == CAN_OperatingMode_Normal)|| \
234 ((MODE) == CAN_OperatingMode_Sleep))
240 * @defgroup CAN_operating_mode_status
244 #define CAN_ModeStatus_Failed ((uint8_t)0x00) /*!< CAN entering the specific mode failed */
245 #define CAN_ModeStatus_Success ((uint8_t)!CAN_ModeStatus_Failed) /*!< CAN entering the specific mode Succeed */
250 /** @defgroup CAN_synchronisation_jump_width
253 #define CAN_SJW_1tq ((uint8_t)0x00) /*!< 1 time quantum */
254 #define CAN_SJW_2tq ((uint8_t)0x01) /*!< 2 time quantum */
255 #define CAN_SJW_3tq ((uint8_t)0x02) /*!< 3 time quantum */
256 #define CAN_SJW_4tq ((uint8_t)0x03) /*!< 4 time quantum */
258 #define IS_CAN_SJW(SJW) (((SJW) == CAN_SJW_1tq) || ((SJW) == CAN_SJW_2tq)|| \
259 ((SJW) == CAN_SJW_3tq) || ((SJW) == CAN_SJW_4tq))
264 /** @defgroup CAN_time_quantum_in_bit_segment_1
267 #define CAN_BS1_1tq ((uint8_t)0x00) /*!< 1 time quantum */
268 #define CAN_BS1_2tq ((uint8_t)0x01) /*!< 2 time quantum */
269 #define CAN_BS1_3tq ((uint8_t)0x02) /*!< 3 time quantum */
270 #define CAN_BS1_4tq ((uint8_t)0x03) /*!< 4 time quantum */
271 #define CAN_BS1_5tq ((uint8_t)0x04) /*!< 5 time quantum */
272 #define CAN_BS1_6tq ((uint8_t)0x05) /*!< 6 time quantum */
273 #define CAN_BS1_7tq ((uint8_t)0x06) /*!< 7 time quantum */
274 #define CAN_BS1_8tq ((uint8_t)0x07) /*!< 8 time quantum */
275 #define CAN_BS1_9tq ((uint8_t)0x08) /*!< 9 time quantum */
276 #define CAN_BS1_10tq ((uint8_t)0x09) /*!< 10 time quantum */
277 #define CAN_BS1_11tq ((uint8_t)0x0A) /*!< 11 time quantum */
278 #define CAN_BS1_12tq ((uint8_t)0x0B) /*!< 12 time quantum */
279 #define CAN_BS1_13tq ((uint8_t)0x0C) /*!< 13 time quantum */
280 #define CAN_BS1_14tq ((uint8_t)0x0D) /*!< 14 time quantum */
281 #define CAN_BS1_15tq ((uint8_t)0x0E) /*!< 15 time quantum */
282 #define CAN_BS1_16tq ((uint8_t)0x0F) /*!< 16 time quantum */
284 #define IS_CAN_BS1(BS1) ((BS1) <= CAN_BS1_16tq)
289 /** @defgroup CAN_time_quantum_in_bit_segment_2
292 #define CAN_BS2_1tq ((uint8_t)0x00) /*!< 1 time quantum */
293 #define CAN_BS2_2tq ((uint8_t)0x01) /*!< 2 time quantum */
294 #define CAN_BS2_3tq ((uint8_t)0x02) /*!< 3 time quantum */
295 #define CAN_BS2_4tq ((uint8_t)0x03) /*!< 4 time quantum */
296 #define CAN_BS2_5tq ((uint8_t)0x04) /*!< 5 time quantum */
297 #define CAN_BS2_6tq ((uint8_t)0x05) /*!< 6 time quantum */
298 #define CAN_BS2_7tq ((uint8_t)0x06) /*!< 7 time quantum */
299 #define CAN_BS2_8tq ((uint8_t)0x07) /*!< 8 time quantum */
301 #define IS_CAN_BS2(BS2) ((BS2) <= CAN_BS2_8tq)
306 /** @defgroup CAN_clock_prescaler
309 #define IS_CAN_PRESCALER(PRESCALER) (((PRESCALER) >= 1) && ((PRESCALER) <= 1024))
314 /** @defgroup CAN_filter_number
317 #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 27)
322 /** @defgroup CAN_filter_mode
325 #define CAN_FilterMode_IdMask ((uint8_t)0x00) /*!< identifier/mask mode */
326 #define CAN_FilterMode_IdList ((uint8_t)0x01) /*!< identifier list mode */
328 #define IS_CAN_FILTER_MODE(MODE) (((MODE) == CAN_FilterMode_IdMask) || \
329 ((MODE) == CAN_FilterMode_IdList))
334 /** @defgroup CAN_filter_scale
337 #define CAN_FilterScale_16bit ((uint8_t)0x00) /*!< Two 16-bit filters */
338 #define CAN_FilterScale_32bit ((uint8_t)0x01) /*!< One 32-bit filter */
340 #define IS_CAN_FILTER_SCALE(SCALE) (((SCALE) == CAN_FilterScale_16bit) || \
341 ((SCALE) == CAN_FilterScale_32bit))
346 /** @defgroup CAN_filter_FIFO
349 #define CAN_Filter_FIFO0 ((uint8_t)0x00) /*!< Filter FIFO 0 assignment for filter x */
350 #define CAN_Filter_FIFO1 ((uint8_t)0x01) /*!< Filter FIFO 1 assignment for filter x */
351 #define IS_CAN_FILTER_FIFO(FIFO) (((FIFO) == CAN_FilterFIFO0) || \
352 ((FIFO) == CAN_FilterFIFO1))
355 #define CAN_FilterFIFO0 CAN_Filter_FIFO0
356 #define CAN_FilterFIFO1 CAN_Filter_FIFO1
361 /** @defgroup CAN_Start_bank_filter_for_slave_CAN
364 #define IS_CAN_BANKNUMBER(BANKNUMBER) (((BANKNUMBER) >= 1) && ((BANKNUMBER) <= 27))
372 #define IS_CAN_TRANSMITMAILBOX(TRANSMITMAILBOX) ((TRANSMITMAILBOX) <= ((uint8_t)0x02))
373 #define IS_CAN_STDID(STDID) ((STDID) <= ((uint32_t)0x7FF))
374 #define IS_CAN_EXTID(EXTID) ((EXTID) <= ((uint32_t)0x1FFFFFFF))
375 #define IS_CAN_DLC(DLC) ((DLC) <= ((uint8_t)0x08))
380 /** @defgroup CAN_identifier_type
383 #define CAN_Id_Standard ((uint32_t)0x00000000) /*!< Standard Id */
384 #define CAN_Id_Extended ((uint32_t)0x00000004) /*!< Extended Id */
385 #define IS_CAN_IDTYPE(IDTYPE) (((IDTYPE) == CAN_Id_Standard) || \
386 ((IDTYPE) == CAN_Id_Extended))
389 #define CAN_ID_STD CAN_Id_Standard
390 #define CAN_ID_EXT CAN_Id_Extended
395 /** @defgroup CAN_remote_transmission_request
398 #define CAN_RTR_Data ((uint32_t)0x00000000) /*!< Data frame */
399 #define CAN_RTR_Remote ((uint32_t)0x00000002) /*!< Remote frame */
400 #define IS_CAN_RTR(RTR) (((RTR) == CAN_RTR_Data) || ((RTR) == CAN_RTR_Remote))
403 #define CAN_RTR_DATA CAN_RTR_Data
404 #define CAN_RTR_REMOTE CAN_RTR_Remote
409 /** @defgroup CAN_transmit_constants
412 #define CAN_TxStatus_Failed ((uint8_t)0x00)/*!< CAN transmission failed */
413 #define CAN_TxStatus_Ok ((uint8_t)0x01) /*!< CAN transmission succeeded */
414 #define CAN_TxStatus_Pending ((uint8_t)0x02) /*!< CAN transmission pending */
415 #define CAN_TxStatus_NoMailBox ((uint8_t)0x04) /*!< CAN cell did not provide
418 #define CANTXFAILED CAN_TxStatus_Failed
419 #define CANTXOK CAN_TxStatus_Ok
420 #define CANTXPENDING CAN_TxStatus_Pending
421 #define CAN_NO_MB CAN_TxStatus_NoMailBox
426 /** @defgroup CAN_receive_FIFO_number_constants
429 #define CAN_FIFO0 ((uint8_t)0x00) /*!< CAN FIFO 0 used to receive */
430 #define CAN_FIFO1 ((uint8_t)0x01) /*!< CAN FIFO 1 used to receive */
432 #define IS_CAN_FIFO(FIFO) (((FIFO) == CAN_FIFO0) || ((FIFO) == CAN_FIFO1))
437 /** @defgroup CAN_sleep_constants
440 #define CAN_Sleep_Failed ((uint8_t)0x00) /*!< CAN did not enter the sleep mode */
441 #define CAN_Sleep_Ok ((uint8_t)0x01) /*!< CAN entered the sleep mode */
444 #define CANSLEEPFAILED CAN_Sleep_Failed
445 #define CANSLEEPOK CAN_Sleep_Ok
450 /** @defgroup CAN_wake_up_constants
453 #define CAN_WakeUp_Failed ((uint8_t)0x00) /*!< CAN did not leave the sleep mode */
454 #define CAN_WakeUp_Ok ((uint8_t)0x01) /*!< CAN leaved the sleep mode */
457 #define CANWAKEUPFAILED CAN_WakeUp_Failed
458 #define CANWAKEUPOK CAN_WakeUp_Ok
464 * @defgroup CAN_Error_Code_constants
467 #define CAN_ErrorCode_NoErr ((uint8_t)0x00) /*!< No Error */
468 #define CAN_ErrorCode_StuffErr ((uint8_t)0x10) /*!< Stuff Error */
469 #define CAN_ErrorCode_FormErr ((uint8_t)0x20) /*!< Form Error */
470 #define CAN_ErrorCode_ACKErr ((uint8_t)0x30) /*!< Acknowledgment Error */
471 #define CAN_ErrorCode_BitRecessiveErr ((uint8_t)0x40) /*!< Bit Recessive Error */
472 #define CAN_ErrorCode_BitDominantErr ((uint8_t)0x50) /*!< Bit Dominant Error */
473 #define CAN_ErrorCode_CRCErr ((uint8_t)0x60) /*!< CRC Error */
474 #define CAN_ErrorCode_SoftwareSetErr ((uint8_t)0x70) /*!< Software Set Error */
479 /** @defgroup CAN_flags
482 /* If the flag is 0x3XXXXXXX, it means that it can be used with CAN_GetFlagStatus()
483 and CAN_ClearFlag() functions. */
484 /* If the flag is 0x1XXXXXXX, it means that it can only be used with
485 CAN_GetFlagStatus() function. */
488 #define CAN_FLAG_RQCP0 ((uint32_t)0x38000001) /*!< Request MailBox0 Flag */
489 #define CAN_FLAG_RQCP1 ((uint32_t)0x38000100) /*!< Request MailBox1 Flag */
490 #define CAN_FLAG_RQCP2 ((uint32_t)0x38010000) /*!< Request MailBox2 Flag */
493 #define CAN_FLAG_FMP0 ((uint32_t)0x12000003) /*!< FIFO 0 Message Pending Flag */
494 #define CAN_FLAG_FF0 ((uint32_t)0x32000008) /*!< FIFO 0 Full Flag */
495 #define CAN_FLAG_FOV0 ((uint32_t)0x32000010) /*!< FIFO 0 Overrun Flag */
496 #define CAN_FLAG_FMP1 ((uint32_t)0x14000003) /*!< FIFO 1 Message Pending Flag */
497 #define CAN_FLAG_FF1 ((uint32_t)0x34000008) /*!< FIFO 1 Full Flag */
498 #define CAN_FLAG_FOV1 ((uint32_t)0x34000010) /*!< FIFO 1 Overrun Flag */
500 /* Operating Mode Flags */
501 #define CAN_FLAG_WKU ((uint32_t)0x31000008) /*!< Wake up Flag */
502 #define CAN_FLAG_SLAK ((uint32_t)0x31000012) /*!< Sleep acknowledge Flag */
503 /* @note When SLAK interrupt is disabled (SLKIE=0), no polling on SLAKI is possible.
504 In this case the SLAK bit can be polled.*/
507 #define CAN_FLAG_EWG ((uint32_t)0x10F00001) /*!< Error Warning Flag */
508 #define CAN_FLAG_EPV ((uint32_t)0x10F00002) /*!< Error Passive Flag */
509 #define CAN_FLAG_BOF ((uint32_t)0x10F00004) /*!< Bus-Off Flag */
510 #define CAN_FLAG_LEC ((uint32_t)0x30F00070) /*!< Last error code Flag */
512 #define IS_CAN_GET_FLAG(FLAG) (((FLAG) == CAN_FLAG_LEC) || ((FLAG) == CAN_FLAG_BOF) || \
513 ((FLAG) == CAN_FLAG_EPV) || ((FLAG) == CAN_FLAG_EWG) || \
514 ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_FOV0) || \
515 ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_FMP0) || \
516 ((FLAG) == CAN_FLAG_FOV1) || ((FLAG) == CAN_FLAG_FF1) || \
517 ((FLAG) == CAN_FLAG_FMP1) || ((FLAG) == CAN_FLAG_RQCP2) || \
518 ((FLAG) == CAN_FLAG_RQCP1)|| ((FLAG) == CAN_FLAG_RQCP0) || \
519 ((FLAG) == CAN_FLAG_SLAK ))
521 #define IS_CAN_CLEAR_FLAG(FLAG)(((FLAG) == CAN_FLAG_LEC) || ((FLAG) == CAN_FLAG_RQCP2) || \
522 ((FLAG) == CAN_FLAG_RQCP1) || ((FLAG) == CAN_FLAG_RQCP0) || \
523 ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_FOV0) ||\
524 ((FLAG) == CAN_FLAG_FF1) || ((FLAG) == CAN_FLAG_FOV1) || \
525 ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_SLAK))
531 /** @defgroup CAN_interrupts
534 #define CAN_IT_TME ((uint32_t)0x00000001) /*!< Transmit mailbox empty Interrupt*/
536 /* Receive Interrupts */
537 #define CAN_IT_FMP0 ((uint32_t)0x00000002) /*!< FIFO 0 message pending Interrupt*/
538 #define CAN_IT_FF0 ((uint32_t)0x00000004) /*!< FIFO 0 full Interrupt*/
539 #define CAN_IT_FOV0 ((uint32_t)0x00000008) /*!< FIFO 0 overrun Interrupt*/
540 #define CAN_IT_FMP1 ((uint32_t)0x00000010) /*!< FIFO 1 message pending Interrupt*/
541 #define CAN_IT_FF1 ((uint32_t)0x00000020) /*!< FIFO 1 full Interrupt*/
542 #define CAN_IT_FOV1 ((uint32_t)0x00000040) /*!< FIFO 1 overrun Interrupt*/
544 /* Operating Mode Interrupts */
545 #define CAN_IT_WKU ((uint32_t)0x00010000) /*!< Wake-up Interrupt*/
546 #define CAN_IT_SLK ((uint32_t)0x00020000) /*!< Sleep acknowledge Interrupt*/
548 /* Error Interrupts */
549 #define CAN_IT_EWG ((uint32_t)0x00000100) /*!< Error warning Interrupt*/
550 #define CAN_IT_EPV ((uint32_t)0x00000200) /*!< Error passive Interrupt*/
551 #define CAN_IT_BOF ((uint32_t)0x00000400) /*!< Bus-off Interrupt*/
552 #define CAN_IT_LEC ((uint32_t)0x00000800) /*!< Last error code Interrupt*/
553 #define CAN_IT_ERR ((uint32_t)0x00008000) /*!< Error Interrupt*/
555 /* Flags named as Interrupts : kept only for FW compatibility */
556 #define CAN_IT_RQCP0 CAN_IT_TME
557 #define CAN_IT_RQCP1 CAN_IT_TME
558 #define CAN_IT_RQCP2 CAN_IT_TME
561 #define IS_CAN_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FMP0) ||\
562 ((IT) == CAN_IT_FF0) || ((IT) == CAN_IT_FOV0) ||\
563 ((IT) == CAN_IT_FMP1) || ((IT) == CAN_IT_FF1) ||\
564 ((IT) == CAN_IT_FOV1) || ((IT) == CAN_IT_EWG) ||\
565 ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\
566 ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\
567 ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK))
569 #define IS_CAN_CLEAR_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FF0) ||\
570 ((IT) == CAN_IT_FOV0)|| ((IT) == CAN_IT_FF1) ||\
571 ((IT) == CAN_IT_FOV1)|| ((IT) == CAN_IT_EWG) ||\
572 ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\
573 ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\
574 ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK))
583 /* Exported macro ------------------------------------------------------------*/
584 /* Exported functions --------------------------------------------------------*/
586 /* Function used to set the CAN configuration to the default reset state *****/
587 void CAN_DeInit(CAN_TypeDef* CANx);
589 /* Initialization and Configuration functions *********************************/
590 uint8_t CAN_Init(CAN_TypeDef* CANx, CAN_InitTypeDef* CAN_InitStruct);
591 void CAN_FilterInit(CAN_FilterInitTypeDef* CAN_FilterInitStruct);
592 void CAN_StructInit(CAN_InitTypeDef* CAN_InitStruct);
593 void CAN_SlaveStartBank(uint8_t CAN_BankNumber);
594 void CAN_DBGFreeze(CAN_TypeDef* CANx, FunctionalState NewState);
595 void CAN_TTComModeCmd(CAN_TypeDef* CANx, FunctionalState NewState);
597 /* CAN Frames Transmission functions ******************************************/
598 uint8_t CAN_Transmit(CAN_TypeDef* CANx, CanTxMsg* TxMessage);
599 uint8_t CAN_TransmitStatus(CAN_TypeDef* CANx, uint8_t TransmitMailbox);
600 void CAN_CancelTransmit(CAN_TypeDef* CANx, uint8_t Mailbox);
602 /* CAN Frames Reception functions *********************************************/
603 void CAN_Receive(CAN_TypeDef* CANx, uint8_t FIFONumber, CanRxMsg* RxMessage);
604 void CAN_FIFORelease(CAN_TypeDef* CANx, uint8_t FIFONumber);
605 uint8_t CAN_MessagePending(CAN_TypeDef* CANx, uint8_t FIFONumber);
607 /* Operation modes functions **************************************************/
608 uint8_t CAN_OperatingModeRequest(CAN_TypeDef* CANx, uint8_t CAN_OperatingMode);
609 uint8_t CAN_Sleep(CAN_TypeDef* CANx);
610 uint8_t CAN_WakeUp(CAN_TypeDef* CANx);
612 /* CAN Bus Error management functions *****************************************/
613 uint8_t CAN_GetLastErrorCode(CAN_TypeDef* CANx);
614 uint8_t CAN_GetReceiveErrorCounter(CAN_TypeDef* CANx);
615 uint8_t CAN_GetLSBTransmitErrorCounter(CAN_TypeDef* CANx);
617 /* Interrupts and flags management functions **********************************/
618 void CAN_ITConfig(CAN_TypeDef* CANx, uint32_t CAN_IT, FunctionalState NewState);
619 FlagStatus CAN_GetFlagStatus(CAN_TypeDef* CANx, uint32_t CAN_FLAG);
620 void CAN_ClearFlag(CAN_TypeDef* CANx, uint32_t CAN_FLAG);
621 ITStatus CAN_GetITStatus(CAN_TypeDef* CANx, uint32_t CAN_IT);
622 void CAN_ClearITPendingBit(CAN_TypeDef* CANx, uint32_t CAN_IT);
628 #endif /* __STM32F4xx_CAN_H */
638 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/