Move telemetry displayport init and cms device registering
[betaflight.git] / lib / main / STM32F3 / Drivers / STM32F30x_StdPeriph_Driver / inc / stm32f30x_can.h
blob2303f9acd8355dd2429d63bf7b88bdbe5ace6cb6
1 /**
2 ******************************************************************************
3 * @file stm32f30x_can.h
4 * @author MCD Application Team
5 * @version V1.1.1
6 * @date 04-April-2014
7 * @brief This file contains all the functions prototypes for the CAN firmware
8 * library.
9 ******************************************************************************
10 * @attention
12 * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
15 * You may not use this file except in compliance with the License.
16 * You may obtain a copy of the License at:
18 * http://www.st.com/software_license_agreement_liberty_v2
20 * Unless required by applicable law or agreed to in writing, software
21 * distributed under the License is distributed on an "AS IS" BASIS,
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 * See the License for the specific language governing permissions and
24 * limitations under the License.
26 ******************************************************************************
29 /* Define to prevent recursive inclusion -------------------------------------*/
30 #ifndef __STM32F30x_CAN_H
31 #define __STM32F30x_CAN_H
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
37 /* Includes ------------------------------------------------------------------*/
38 #include "stm32f30x.h"
40 /** @addtogroup STM32F30x_StdPeriph_Driver
41 * @{
44 /** @addtogroup CAN
45 * @{
48 /* Exported types ------------------------------------------------------------*/
50 #define IS_CAN_ALL_PERIPH(PERIPH) (((PERIPH) == CAN1))
52 /**
53 * @brief CAN init structure definition
55 typedef struct
57 uint16_t CAN_Prescaler; /*!< Specifies the length of a time quantum.
58 It ranges from 1 to 1024. */
60 uint8_t CAN_Mode; /*!< Specifies the CAN operating mode.
61 This parameter can be a value of @ref CAN_operating_mode */
63 uint8_t CAN_SJW; /*!< Specifies the maximum number of time quanta
64 the CAN hardware is allowed to lengthen or
65 shorten a bit to perform resynchronization.
66 This parameter can be a value of @ref CAN_synchronisation_jump_width */
68 uint8_t CAN_BS1; /*!< Specifies the number of time quanta in Bit
69 Segment 1. This parameter can be a value of
70 @ref CAN_time_quantum_in_bit_segment_1 */
72 uint8_t CAN_BS2; /*!< Specifies the number of time quanta in Bit Segment 2.
73 This parameter can be a value of @ref CAN_time_quantum_in_bit_segment_2 */
75 FunctionalState CAN_TTCM; /*!< Enable or disable the time triggered communication mode.
76 This parameter can be set either to ENABLE or DISABLE. */
78 FunctionalState CAN_ABOM; /*!< Enable or disable the automatic bus-off management.
79 This parameter can be set either to ENABLE or DISABLE. */
81 FunctionalState CAN_AWUM; /*!< Enable or disable the automatic wake-up mode.
82 This parameter can be set either to ENABLE or DISABLE. */
84 FunctionalState CAN_NART; /*!< Enable or disable the non-automatic retransmission mode.
85 This parameter can be set either to ENABLE or DISABLE. */
87 FunctionalState CAN_RFLM; /*!< Enable or disable the Receive FIFO Locked mode.
88 This parameter can be set either to ENABLE or DISABLE. */
90 FunctionalState CAN_TXFP; /*!< Enable or disable the transmit FIFO priority.
91 This parameter can be set either to ENABLE or DISABLE. */
92 } CAN_InitTypeDef;
94 /**
95 * @brief CAN filter init structure definition
97 typedef struct
99 uint16_t CAN_FilterIdHigh; /*!< Specifies the filter identification number (MSBs for a 32-bit
100 configuration, first one for a 16-bit configuration).
101 This parameter can be a value between 0x0000 and 0xFFFF */
103 uint16_t CAN_FilterIdLow; /*!< Specifies the filter identification number (LSBs for a 32-bit
104 configuration, second one for a 16-bit configuration).
105 This parameter can be a value between 0x0000 and 0xFFFF */
107 uint16_t CAN_FilterMaskIdHigh; /*!< Specifies the filter mask number or identification number,
108 according to the mode (MSBs for a 32-bit configuration,
109 first one for a 16-bit configuration).
110 This parameter can be a value between 0x0000 and 0xFFFF */
112 uint16_t CAN_FilterMaskIdLow; /*!< Specifies the filter mask number or identification number,
113 according to the mode (LSBs for a 32-bit configuration,
114 second one for a 16-bit configuration).
115 This parameter can be a value between 0x0000 and 0xFFFF */
117 uint16_t CAN_FilterFIFOAssignment; /*!< Specifies the FIFO (0 or 1) which will be assigned to the filter.
118 This parameter can be a value of @ref CAN_filter_FIFO */
120 uint8_t CAN_FilterNumber; /*!< Specifies the filter which will be initialized. It ranges from 0 to 13. */
122 uint8_t CAN_FilterMode; /*!< Specifies the filter mode to be initialized.
123 This parameter can be a value of @ref CAN_filter_mode */
125 uint8_t CAN_FilterScale; /*!< Specifies the filter scale.
126 This parameter can be a value of @ref CAN_filter_scale */
128 FunctionalState CAN_FilterActivation; /*!< Enable or disable the filter.
129 This parameter can be set either to ENABLE or DISABLE. */
130 } CAN_FilterInitTypeDef;
132 /**
133 * @brief CAN Tx message structure definition
135 typedef struct
137 uint32_t StdId; /*!< Specifies the standard identifier.
138 This parameter can be a value between 0 to 0x7FF. */
140 uint32_t ExtId; /*!< Specifies the extended identifier.
141 This parameter can be a value between 0 to 0x1FFFFFFF. */
143 uint8_t IDE; /*!< Specifies the type of identifier for the message that
144 will be transmitted. This parameter can be a value
145 of @ref CAN_identifier_type */
147 uint8_t RTR; /*!< Specifies the type of frame for the message that will
148 be transmitted. This parameter can be a value of
149 @ref CAN_remote_transmission_request */
151 uint8_t DLC; /*!< Specifies the length of the frame that will be
152 transmitted. This parameter can be a value between
153 0 to 8 */
155 uint8_t Data[8]; /*!< Contains the data to be transmitted. It ranges from 0
156 to 0xFF. */
157 } CanTxMsg;
159 /**
160 * @brief CAN Rx message structure definition
162 typedef struct
164 uint32_t StdId; /*!< Specifies the standard identifier.
165 This parameter can be a value between 0 to 0x7FF. */
167 uint32_t ExtId; /*!< Specifies the extended identifier.
168 This parameter can be a value between 0 to 0x1FFFFFFF. */
170 uint8_t IDE; /*!< Specifies the type of identifier for the message that
171 will be received. This parameter can be a value of
172 @ref CAN_identifier_type */
174 uint8_t RTR; /*!< Specifies the type of frame for the received message.
175 This parameter can be a value of
176 @ref CAN_remote_transmission_request */
178 uint8_t DLC; /*!< Specifies the length of the frame that will be received.
179 This parameter can be a value between 0 to 8 */
181 uint8_t Data[8]; /*!< Contains the data to be received. It ranges from 0 to
182 0xFF. */
184 uint8_t FMI; /*!< Specifies the index of the filter the message stored in
185 the mailbox passes through. This parameter can be a
186 value between 0 to 0xFF */
187 } CanRxMsg;
189 /* Exported constants --------------------------------------------------------*/
191 /** @defgroup CAN_Exported_Constants
192 * @{
195 /** @defgroup CAN_InitStatus
196 * @{
199 #define CAN_InitStatus_Failed ((uint8_t)0x00) /*!< CAN initialization failed */
200 #define CAN_InitStatus_Success ((uint8_t)0x01) /*!< CAN initialization OK */
203 /* Legacy defines */
204 #define CANINITFAILED CAN_InitStatus_Failed
205 #define CANINITOK CAN_InitStatus_Success
207 * @}
210 /** @defgroup CAN_operating_mode
211 * @{
214 #define CAN_Mode_Normal ((uint8_t)0x00) /*!< normal mode */
215 #define CAN_Mode_LoopBack ((uint8_t)0x01) /*!< loopback mode */
216 #define CAN_Mode_Silent ((uint8_t)0x02) /*!< silent mode */
217 #define CAN_Mode_Silent_LoopBack ((uint8_t)0x03) /*!< loopback combined with silent mode */
219 #define IS_CAN_MODE(MODE) (((MODE) == CAN_Mode_Normal) || \
220 ((MODE) == CAN_Mode_LoopBack)|| \
221 ((MODE) == CAN_Mode_Silent) || \
222 ((MODE) == CAN_Mode_Silent_LoopBack))
224 * @}
229 * @defgroup CAN_operating_mode
230 * @{
232 #define CAN_OperatingMode_Initialization ((uint8_t)0x00) /*!< Initialization mode */
233 #define CAN_OperatingMode_Normal ((uint8_t)0x01) /*!< Normal mode */
234 #define CAN_OperatingMode_Sleep ((uint8_t)0x02) /*!< sleep mode */
237 #define IS_CAN_OPERATING_MODE(MODE) (((MODE) == CAN_OperatingMode_Initialization) ||\
238 ((MODE) == CAN_OperatingMode_Normal)|| \
239 ((MODE) == CAN_OperatingMode_Sleep))
241 * @}
245 * @defgroup CAN_operating_mode_status
246 * @{
249 #define CAN_ModeStatus_Failed ((uint8_t)0x00) /*!< CAN entering the specific mode failed */
250 #define CAN_ModeStatus_Success ((uint8_t)!CAN_ModeStatus_Failed) /*!< CAN entering the specific mode Succeed */
252 * @}
255 /** @defgroup CAN_synchronisation_jump_width
256 * @{
258 #define CAN_SJW_1tq ((uint8_t)0x00) /*!< 1 time quantum */
259 #define CAN_SJW_2tq ((uint8_t)0x01) /*!< 2 time quantum */
260 #define CAN_SJW_3tq ((uint8_t)0x02) /*!< 3 time quantum */
261 #define CAN_SJW_4tq ((uint8_t)0x03) /*!< 4 time quantum */
263 #define IS_CAN_SJW(SJW) (((SJW) == CAN_SJW_1tq) || ((SJW) == CAN_SJW_2tq)|| \
264 ((SJW) == CAN_SJW_3tq) || ((SJW) == CAN_SJW_4tq))
266 * @}
269 /** @defgroup CAN_time_quantum_in_bit_segment_1
270 * @{
272 #define CAN_BS1_1tq ((uint8_t)0x00) /*!< 1 time quantum */
273 #define CAN_BS1_2tq ((uint8_t)0x01) /*!< 2 time quantum */
274 #define CAN_BS1_3tq ((uint8_t)0x02) /*!< 3 time quantum */
275 #define CAN_BS1_4tq ((uint8_t)0x03) /*!< 4 time quantum */
276 #define CAN_BS1_5tq ((uint8_t)0x04) /*!< 5 time quantum */
277 #define CAN_BS1_6tq ((uint8_t)0x05) /*!< 6 time quantum */
278 #define CAN_BS1_7tq ((uint8_t)0x06) /*!< 7 time quantum */
279 #define CAN_BS1_8tq ((uint8_t)0x07) /*!< 8 time quantum */
280 #define CAN_BS1_9tq ((uint8_t)0x08) /*!< 9 time quantum */
281 #define CAN_BS1_10tq ((uint8_t)0x09) /*!< 10 time quantum */
282 #define CAN_BS1_11tq ((uint8_t)0x0A) /*!< 11 time quantum */
283 #define CAN_BS1_12tq ((uint8_t)0x0B) /*!< 12 time quantum */
284 #define CAN_BS1_13tq ((uint8_t)0x0C) /*!< 13 time quantum */
285 #define CAN_BS1_14tq ((uint8_t)0x0D) /*!< 14 time quantum */
286 #define CAN_BS1_15tq ((uint8_t)0x0E) /*!< 15 time quantum */
287 #define CAN_BS1_16tq ((uint8_t)0x0F) /*!< 16 time quantum */
289 #define IS_CAN_BS1(BS1) ((BS1) <= CAN_BS1_16tq)
291 * @}
294 /** @defgroup CAN_time_quantum_in_bit_segment_2
295 * @{
297 #define CAN_BS2_1tq ((uint8_t)0x00) /*!< 1 time quantum */
298 #define CAN_BS2_2tq ((uint8_t)0x01) /*!< 2 time quantum */
299 #define CAN_BS2_3tq ((uint8_t)0x02) /*!< 3 time quantum */
300 #define CAN_BS2_4tq ((uint8_t)0x03) /*!< 4 time quantum */
301 #define CAN_BS2_5tq ((uint8_t)0x04) /*!< 5 time quantum */
302 #define CAN_BS2_6tq ((uint8_t)0x05) /*!< 6 time quantum */
303 #define CAN_BS2_7tq ((uint8_t)0x06) /*!< 7 time quantum */
304 #define CAN_BS2_8tq ((uint8_t)0x07) /*!< 8 time quantum */
306 #define IS_CAN_BS2(BS2) ((BS2) <= CAN_BS2_8tq)
308 * @}
311 /** @defgroup CAN_clock_prescaler
312 * @{
314 #define IS_CAN_PRESCALER(PRESCALER) (((PRESCALER) >= 1) && ((PRESCALER) <= 1024))
316 * @}
319 /** @defgroup CAN_filter_number
320 * @{
322 #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 27)
324 * @}
327 /** @defgroup CAN_filter_mode
328 * @{
330 #define CAN_FilterMode_IdMask ((uint8_t)0x00) /*!< identifier/mask mode */
331 #define CAN_FilterMode_IdList ((uint8_t)0x01) /*!< identifier list mode */
333 #define IS_CAN_FILTER_MODE(MODE) (((MODE) == CAN_FilterMode_IdMask) || \
334 ((MODE) == CAN_FilterMode_IdList))
336 * @}
339 /** @defgroup CAN_filter_scale
340 * @{
342 #define CAN_FilterScale_16bit ((uint8_t)0x00) /*!< Two 16-bit filters */
343 #define CAN_FilterScale_32bit ((uint8_t)0x01) /*!< One 32-bit filter */
345 #define IS_CAN_FILTER_SCALE(SCALE) (((SCALE) == CAN_FilterScale_16bit) || \
346 ((SCALE) == CAN_FilterScale_32bit))
348 * @}
351 /** @defgroup CAN_filter_FIFO
352 * @{
354 #define CAN_Filter_FIFO0 ((uint8_t)0x00) /*!< Filter FIFO 0 assignment for filter x */
355 #define CAN_Filter_FIFO1 ((uint8_t)0x01) /*!< Filter FIFO 1 assignment for filter x */
356 #define IS_CAN_FILTER_FIFO(FIFO) (((FIFO) == CAN_FilterFIFO0) || \
357 ((FIFO) == CAN_FilterFIFO1))
359 /* Legacy defines */
360 #define CAN_FilterFIFO0 CAN_Filter_FIFO0
361 #define CAN_FilterFIFO1 CAN_Filter_FIFO1
363 * @}
366 /** @defgroup CAN_Start_bank_filter_for_slave_CAN
367 * @{
369 #define IS_CAN_BANKNUMBER(BANKNUMBER) (((BANKNUMBER) >= 1) && ((BANKNUMBER) <= 27))
371 * @}
374 /** @defgroup CAN_Tx
375 * @{
377 #define IS_CAN_TRANSMITMAILBOX(TRANSMITMAILBOX) ((TRANSMITMAILBOX) <= ((uint8_t)0x02))
378 #define IS_CAN_STDID(STDID) ((STDID) <= ((uint32_t)0x7FF))
379 #define IS_CAN_EXTID(EXTID) ((EXTID) <= ((uint32_t)0x1FFFFFFF))
380 #define IS_CAN_DLC(DLC) ((DLC) <= ((uint8_t)0x08))
382 * @}
385 /** @defgroup CAN_identifier_type
386 * @{
388 #define CAN_Id_Standard ((uint32_t)0x00000000) /*!< Standard Id */
389 #define CAN_Id_Extended ((uint32_t)0x00000004) /*!< Extended Id */
390 #define IS_CAN_IDTYPE(IDTYPE) (((IDTYPE) == CAN_Id_Standard) || \
391 ((IDTYPE) == CAN_Id_Extended))
393 /* Legacy defines */
394 #define CAN_ID_STD CAN_Id_Standard
395 #define CAN_ID_EXT CAN_Id_Extended
397 * @}
400 /** @defgroup CAN_remote_transmission_request
401 * @{
403 #define CAN_RTR_Data ((uint32_t)0x00000000) /*!< Data frame */
404 #define CAN_RTR_Remote ((uint32_t)0x00000002) /*!< Remote frame */
405 #define IS_CAN_RTR(RTR) (((RTR) == CAN_RTR_Data) || ((RTR) == CAN_RTR_Remote))
407 /* Legacy defines */
408 #define CAN_RTR_DATA CAN_RTR_Data
409 #define CAN_RTR_REMOTE CAN_RTR_Remote
411 * @}
414 /** @defgroup CAN_transmit_constants
415 * @{
417 #define CAN_TxStatus_Failed ((uint8_t)0x00)/*!< CAN transmission failed */
418 #define CAN_TxStatus_Ok ((uint8_t)0x01) /*!< CAN transmission succeeded */
419 #define CAN_TxStatus_Pending ((uint8_t)0x02) /*!< CAN transmission pending */
420 #define CAN_TxStatus_NoMailBox ((uint8_t)0x04) /*!< CAN cell did not provide
421 an empty mailbox */
422 /* Legacy defines */
423 #define CANTXFAILED CAN_TxStatus_Failed
424 #define CANTXOK CAN_TxStatus_Ok
425 #define CANTXPENDING CAN_TxStatus_Pending
426 #define CAN_NO_MB CAN_TxStatus_NoMailBox
428 * @}
431 /** @defgroup CAN_receive_FIFO_number_constants
432 * @{
434 #define CAN_FIFO0 ((uint8_t)0x00) /*!< CAN FIFO 0 used to receive */
435 #define CAN_FIFO1 ((uint8_t)0x01) /*!< CAN FIFO 1 used to receive */
437 #define IS_CAN_FIFO(FIFO) (((FIFO) == CAN_FIFO0) || ((FIFO) == CAN_FIFO1))
439 * @}
442 /** @defgroup CAN_sleep_constants
443 * @{
445 #define CAN_Sleep_Failed ((uint8_t)0x00) /*!< CAN did not enter the sleep mode */
446 #define CAN_Sleep_Ok ((uint8_t)0x01) /*!< CAN entered the sleep mode */
448 /* Legacy defines */
449 #define CANSLEEPFAILED CAN_Sleep_Failed
450 #define CANSLEEPOK CAN_Sleep_Ok
452 * @}
455 /** @defgroup CAN_wake_up_constants
456 * @{
458 #define CAN_WakeUp_Failed ((uint8_t)0x00) /*!< CAN did not leave the sleep mode */
459 #define CAN_WakeUp_Ok ((uint8_t)0x01) /*!< CAN leaved the sleep mode */
461 /* Legacy defines */
462 #define CANWAKEUPFAILED CAN_WakeUp_Failed
463 #define CANWAKEUPOK CAN_WakeUp_Ok
465 * @}
469 * @defgroup CAN_Error_Code_constants
470 * @{
472 #define CAN_ErrorCode_NoErr ((uint8_t)0x00) /*!< No Error */
473 #define CAN_ErrorCode_StuffErr ((uint8_t)0x10) /*!< Stuff Error */
474 #define CAN_ErrorCode_FormErr ((uint8_t)0x20) /*!< Form Error */
475 #define CAN_ErrorCode_ACKErr ((uint8_t)0x30) /*!< Acknowledgment Error */
476 #define CAN_ErrorCode_BitRecessiveErr ((uint8_t)0x40) /*!< Bit Recessive Error */
477 #define CAN_ErrorCode_BitDominantErr ((uint8_t)0x50) /*!< Bit Dominant Error */
478 #define CAN_ErrorCode_CRCErr ((uint8_t)0x60) /*!< CRC Error */
479 #define CAN_ErrorCode_SoftwareSetErr ((uint8_t)0x70) /*!< Software Set Error */
481 * @}
484 /** @defgroup CAN_flags
485 * @{
487 /* If the flag is 0x3XXXXXXX, it means that it can be used with CAN_GetFlagStatus()
488 and CAN_ClearFlag() functions. */
489 /* If the flag is 0x1XXXXXXX, it means that it can only be used with
490 CAN_GetFlagStatus() function. */
492 /* Transmit Flags */
493 #define CAN_FLAG_RQCP0 ((uint32_t)0x38000001) /*!< Request MailBox0 Flag */
494 #define CAN_FLAG_RQCP1 ((uint32_t)0x38000100) /*!< Request MailBox1 Flag */
495 #define CAN_FLAG_RQCP2 ((uint32_t)0x38010000) /*!< Request MailBox2 Flag */
497 /* Receive Flags */
498 #define CAN_FLAG_FMP0 ((uint32_t)0x12000003) /*!< FIFO 0 Message Pending Flag */
499 #define CAN_FLAG_FF0 ((uint32_t)0x32000008) /*!< FIFO 0 Full Flag */
500 #define CAN_FLAG_FOV0 ((uint32_t)0x32000010) /*!< FIFO 0 Overrun Flag */
501 #define CAN_FLAG_FMP1 ((uint32_t)0x14000003) /*!< FIFO 1 Message Pending Flag */
502 #define CAN_FLAG_FF1 ((uint32_t)0x34000008) /*!< FIFO 1 Full Flag */
503 #define CAN_FLAG_FOV1 ((uint32_t)0x34000010) /*!< FIFO 1 Overrun Flag */
505 /* Operating Mode Flags */
506 #define CAN_FLAG_WKU ((uint32_t)0x31000008) /*!< Wake up Flag */
507 #define CAN_FLAG_SLAK ((uint32_t)0x31000012) /*!< Sleep acknowledge Flag */
508 /* @note When SLAK interrupt is disabled (SLKIE=0), no polling on SLAKI is possible.
509 In this case the SLAK bit can be polled.*/
511 /* Error Flags */
512 #define CAN_FLAG_EWG ((uint32_t)0x10F00001) /*!< Error Warning Flag */
513 #define CAN_FLAG_EPV ((uint32_t)0x10F00002) /*!< Error Passive Flag */
514 #define CAN_FLAG_BOF ((uint32_t)0x10F00004) /*!< Bus-Off Flag */
515 #define CAN_FLAG_LEC ((uint32_t)0x30F00070) /*!< Last error code Flag */
517 #define IS_CAN_GET_FLAG(FLAG) (((FLAG) == CAN_FLAG_LEC) || ((FLAG) == CAN_FLAG_BOF) || \
518 ((FLAG) == CAN_FLAG_EPV) || ((FLAG) == CAN_FLAG_EWG) || \
519 ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_FOV0) || \
520 ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_FMP0) || \
521 ((FLAG) == CAN_FLAG_FOV1) || ((FLAG) == CAN_FLAG_FF1) || \
522 ((FLAG) == CAN_FLAG_FMP1) || ((FLAG) == CAN_FLAG_RQCP2) || \
523 ((FLAG) == CAN_FLAG_RQCP1)|| ((FLAG) == CAN_FLAG_RQCP0) || \
524 ((FLAG) == CAN_FLAG_SLAK ))
526 #define IS_CAN_CLEAR_FLAG(FLAG)(((FLAG) == CAN_FLAG_LEC) || ((FLAG) == CAN_FLAG_RQCP2) || \
527 ((FLAG) == CAN_FLAG_RQCP1) || ((FLAG) == CAN_FLAG_RQCP0) || \
528 ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_FOV0) ||\
529 ((FLAG) == CAN_FLAG_FF1) || ((FLAG) == CAN_FLAG_FOV1) || \
530 ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_SLAK))
532 * @}
536 /** @defgroup CAN_interrupts
537 * @{
539 #define CAN_IT_TME ((uint32_t)0x00000001) /*!< Transmit mailbox empty Interrupt*/
541 /* Receive Interrupts */
542 #define CAN_IT_FMP0 ((uint32_t)0x00000002) /*!< FIFO 0 message pending Interrupt*/
543 #define CAN_IT_FF0 ((uint32_t)0x00000004) /*!< FIFO 0 full Interrupt*/
544 #define CAN_IT_FOV0 ((uint32_t)0x00000008) /*!< FIFO 0 overrun Interrupt*/
545 #define CAN_IT_FMP1 ((uint32_t)0x00000010) /*!< FIFO 1 message pending Interrupt*/
546 #define CAN_IT_FF1 ((uint32_t)0x00000020) /*!< FIFO 1 full Interrupt*/
547 #define CAN_IT_FOV1 ((uint32_t)0x00000040) /*!< FIFO 1 overrun Interrupt*/
549 /* Operating Mode Interrupts */
550 #define CAN_IT_WKU ((uint32_t)0x00010000) /*!< Wake-up Interrupt*/
551 #define CAN_IT_SLK ((uint32_t)0x00020000) /*!< Sleep acknowledge Interrupt*/
553 /* Error Interrupts */
554 #define CAN_IT_EWG ((uint32_t)0x00000100) /*!< Error warning Interrupt*/
555 #define CAN_IT_EPV ((uint32_t)0x00000200) /*!< Error passive Interrupt*/
556 #define CAN_IT_BOF ((uint32_t)0x00000400) /*!< Bus-off Interrupt*/
557 #define CAN_IT_LEC ((uint32_t)0x00000800) /*!< Last error code Interrupt*/
558 #define CAN_IT_ERR ((uint32_t)0x00008000) /*!< Error Interrupt*/
560 /* Flags named as Interrupts : kept only for FW compatibility */
561 #define CAN_IT_RQCP0 CAN_IT_TME
562 #define CAN_IT_RQCP1 CAN_IT_TME
563 #define CAN_IT_RQCP2 CAN_IT_TME
566 #define IS_CAN_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FMP0) ||\
567 ((IT) == CAN_IT_FF0) || ((IT) == CAN_IT_FOV0) ||\
568 ((IT) == CAN_IT_FMP1) || ((IT) == CAN_IT_FF1) ||\
569 ((IT) == CAN_IT_FOV1) || ((IT) == CAN_IT_EWG) ||\
570 ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\
571 ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\
572 ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK))
574 #define IS_CAN_CLEAR_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FF0) ||\
575 ((IT) == CAN_IT_FOV0)|| ((IT) == CAN_IT_FF1) ||\
576 ((IT) == CAN_IT_FOV1)|| ((IT) == CAN_IT_EWG) ||\
577 ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\
578 ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\
579 ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK))
581 * @}
585 * @}
588 /* Exported macro ------------------------------------------------------------*/
589 /* Exported functions --------------------------------------------------------*/
591 /* Function used to set the CAN configuration to the default reset state *****/
592 void CAN_DeInit(CAN_TypeDef* CANx);
594 /* Initialization and Configuration functions *********************************/
595 uint8_t CAN_Init(CAN_TypeDef* CANx, CAN_InitTypeDef* CAN_InitStruct);
596 void CAN_FilterInit(CAN_FilterInitTypeDef* CAN_FilterInitStruct);
597 void CAN_StructInit(CAN_InitTypeDef* CAN_InitStruct);
598 void CAN_SlaveStartBank(uint8_t CAN_BankNumber);
599 void CAN_DBGFreeze(CAN_TypeDef* CANx, FunctionalState NewState);
600 void CAN_TTComModeCmd(CAN_TypeDef* CANx, FunctionalState NewState);
602 /* CAN Frames Transmission functions ******************************************/
603 uint8_t CAN_Transmit(CAN_TypeDef* CANx, CanTxMsg* TxMessage);
604 uint8_t CAN_TransmitStatus(CAN_TypeDef* CANx, uint8_t TransmitMailbox);
605 void CAN_CancelTransmit(CAN_TypeDef* CANx, uint8_t Mailbox);
607 /* CAN Frames Reception functions *********************************************/
608 void CAN_Receive(CAN_TypeDef* CANx, uint8_t FIFONumber, CanRxMsg* RxMessage);
609 void CAN_FIFORelease(CAN_TypeDef* CANx, uint8_t FIFONumber);
610 uint8_t CAN_MessagePending(CAN_TypeDef* CANx, uint8_t FIFONumber);
612 /* Operation modes functions **************************************************/
613 uint8_t CAN_OperatingModeRequest(CAN_TypeDef* CANx, uint8_t CAN_OperatingMode);
614 uint8_t CAN_Sleep(CAN_TypeDef* CANx);
615 uint8_t CAN_WakeUp(CAN_TypeDef* CANx);
617 /* CAN Bus Error management functions *****************************************/
618 uint8_t CAN_GetLastErrorCode(CAN_TypeDef* CANx);
619 uint8_t CAN_GetReceiveErrorCounter(CAN_TypeDef* CANx);
620 uint8_t CAN_GetLSBTransmitErrorCounter(CAN_TypeDef* CANx);
622 /* Interrupts and flags management functions **********************************/
623 void CAN_ITConfig(CAN_TypeDef* CANx, uint32_t CAN_IT, FunctionalState NewState);
624 FlagStatus CAN_GetFlagStatus(CAN_TypeDef* CANx, uint32_t CAN_FLAG);
625 void CAN_ClearFlag(CAN_TypeDef* CANx, uint32_t CAN_FLAG);
626 ITStatus CAN_GetITStatus(CAN_TypeDef* CANx, uint32_t CAN_IT);
627 void CAN_ClearITPendingBit(CAN_TypeDef* CANx, uint32_t CAN_IT);
629 #ifdef __cplusplus
631 #endif
633 #endif /* __STM32F30x_CAN_H */
636 * @}
640 * @}
643 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/