stm32f10x_can.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f10x_can.h
00004   * @author  MCD Application Team
00005   * @version V3.4.0
00006   * @date    10/15/2010
00007   * @brief   This file contains all the functions prototypes for the CAN firmware 
00008   *          library.
00009   ******************************************************************************
00010   * @copy
00011   *
00012   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00013   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00014   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00015   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00016   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00017   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00018   *
00019   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
00020   */ 
00021 
00022 /* Define to prevent recursive inclusion -------------------------------------*/
00023 #ifndef __STM32F10x_CAN_H
00024 #define __STM32F10x_CAN_H
00025 
00026 #ifdef __cplusplus
00027  extern "C" {
00028 #endif
00029 
00030 /* Includes ------------------------------------------------------------------*/
00031 #include "stm32f10x.h"
00032 
00033 /** @addtogroup STM32F10x_StdPeriph_Driver
00034   * @{
00035   */
00036 
00037 /** @addtogroup CAN
00038   * @{
00039   */
00040 
00041 /** @defgroup CAN_Exported_Types
00042   * @{
00043   */
00044 
00045 #define IS_CAN_ALL_PERIPH(PERIPH) (((PERIPH) == CAN1) || \
00046                                    ((PERIPH) == CAN2))
00047 
00048 /** 
00049   * @brief  CAN init structure definition
00050   */
00051 
00052 typedef struct
00053 {
00054   uint16_t CAN_Prescaler;   /*!< Specifies the length of a time quantum. It ranges from 1 to 1024. */
00055   
00056   uint8_t CAN_Mode;         /*!< Specifies the CAN operating mode.
00057                                  This parameter can be a value of @ref CAN_operating_mode */
00058 
00059   uint8_t CAN_SJW;          /*!< Specifies the maximum number of time quanta the CAN hardware
00060                                  is allowed to lengthen or shorten a bit to perform resynchronization.
00061                                  This parameter can be a value of @ref CAN_synchronisation_jump_width */
00062 
00063   uint8_t CAN_BS1;          /*!< Specifies the number of time quanta in Bit Segment 1.
00064                                  This parameter can be a value of @ref CAN_time_quantum_in_bit_segment_1 */
00065 
00066   uint8_t CAN_BS2;          /*!< Specifies the number of time quanta in Bit Segment 2.
00067                                  This parameter can be a value of @ref CAN_time_quantum_in_bit_segment_2 */
00068   
00069   FunctionalState CAN_TTCM; /*!< Enable or disable the time triggered communication mode.
00070                                  This parameter can be set either to ENABLE or DISABLE. */
00071   
00072   FunctionalState CAN_ABOM;  /*!< Enable or disable the automatic bus-off management.
00073                                  This parameter can be set either to ENABLE or DISABLE. */
00074 
00075   FunctionalState CAN_AWUM;  /*!< Enable or disable the automatic wake-up mode. 
00076                                  This parameter can be set either to ENABLE or DISABLE. */
00077 
00078   FunctionalState CAN_NART;  /*!< Enable or disable the no-automatic retransmission mode.
00079                                  This parameter can be set either to ENABLE or DISABLE. */
00080 
00081   FunctionalState CAN_RFLM;  /*!< Enable or disable the Receive FIFO Locked mode.
00082                                  This parameter can be set either to ENABLE or DISABLE. */
00083 
00084   FunctionalState CAN_TXFP;  /*!< Enable or disable the transmit FIFO priority.
00085                                  This parameter can be set either to ENABLE or DISABLE. */
00086 } CAN_InitTypeDef;
00087 
00088 /** 
00089   * @brief  CAN filter init structure definition
00090   */
00091 
00092 typedef struct
00093 {
00094   uint16_t CAN_FilterIdHigh;             /*!< Specifies the filter identification number (MSBs for a 32-bit
00095                                               configuration, first one for a 16-bit configuration).
00096                                               This parameter can be a value between 0x0000 and 0xFFFF */
00097 
00098   uint16_t CAN_FilterIdLow;              /*!< Specifies the filter identification number (LSBs for a 32-bit
00099                                               configuration, second one for a 16-bit configuration).
00100                                               This parameter can be a value between 0x0000 and 0xFFFF */
00101 
00102   uint16_t CAN_FilterMaskIdHigh;         /*!< Specifies the filter mask number or identification number,
00103                                               according to the mode (MSBs for a 32-bit configuration,
00104                                               first one for a 16-bit configuration).
00105                                               This parameter can be a value between 0x0000 and 0xFFFF */
00106 
00107   uint16_t CAN_FilterMaskIdLow;          /*!< Specifies the filter mask number or identification number,
00108                                               according to the mode (LSBs for a 32-bit configuration,
00109                                               second one for a 16-bit configuration).
00110                                               This parameter can be a value between 0x0000 and 0xFFFF */
00111 
00112   uint16_t CAN_FilterFIFOAssignment;     /*!< Specifies the FIFO (0 or 1) which will be assigned to the filter.
00113                                               This parameter can be a value of @ref CAN_filter_FIFO */
00114   
00115   uint8_t CAN_FilterNumber;              /*!< Specifies the filter which will be initialized. It ranges from 0 to 13. */
00116 
00117   uint8_t CAN_FilterMode;                /*!< Specifies the filter mode to be initialized.
00118                                               This parameter can be a value of @ref CAN_filter_mode */
00119 
00120   uint8_t CAN_FilterScale;               /*!< Specifies the filter scale.
00121                                               This parameter can be a value of @ref CAN_filter_scale */
00122 
00123   FunctionalState CAN_FilterActivation;  /*!< Enable or disable the filter.
00124                                               This parameter can be set either to ENABLE or DISABLE. */
00125 } CAN_FilterInitTypeDef;
00126 
00127 /** 
00128   * @brief  CAN Tx message structure definition  
00129   */
00130 
00131 typedef struct
00132 {
00133   uint32_t StdId;  /*!< Specifies the standard identifier.
00134                         This parameter can be a value between 0 to 0x7FF. */
00135 
00136   uint32_t ExtId;  /*!< Specifies the extended identifier.
00137                         This parameter can be a value between 0 to 0x1FFFFFFF. */
00138 
00139   uint8_t IDE;     /*!< Specifies the type of identifier for the message that will be transmitted.
00140                         This parameter can be a value of @ref CAN_identifier_type */
00141 
00142   uint8_t RTR;     /*!< Specifies the type of frame for the message that will be transmitted.
00143                         This parameter can be a value of @ref CAN_remote_transmission_request */
00144 
00145   uint8_t DLC;     /*!< Specifies the length of the frame that will be transmitted.
00146                         This parameter can be a value between 0 to 8 */
00147 
00148   uint8_t Data[8]; /*!< Contains the data to be transmitted. It ranges from 0 to 0xFF. */
00149 } CanTxMsg;
00150 
00151 /** 
00152   * @brief  CAN Rx message structure definition  
00153   */
00154 
00155 typedef struct
00156 {
00157   uint32_t StdId;  /*!< Specifies the standard identifier.
00158                         This parameter can be a value between 0 to 0x7FF. */
00159 
00160   uint32_t ExtId;  /*!< Specifies the extended identifier.
00161                         This parameter can be a value between 0 to 0x1FFFFFFF. */
00162 
00163   uint8_t IDE;     /*!< Specifies the type of identifier for the message that will be received.
00164                         This parameter can be a value of @ref CAN_identifier_type */
00165 
00166   uint8_t RTR;     /*!< Specifies the type of frame for the received message.
00167                         This parameter can be a value of @ref CAN_remote_transmission_request */
00168 
00169   uint8_t DLC;     /*!< Specifies the length of the frame that will be received.
00170                         This parameter can be a value between 0 to 8 */
00171 
00172   uint8_t Data[8]; /*!< Contains the data to be received. It ranges from 0 to 0xFF. */
00173 
00174   uint8_t FMI;     /*!< Specifies the index of the filter the message stored in the mailbox passes through.
00175                         This parameter can be a value between 0 to 0xFF */
00176 } CanRxMsg;
00177 
00178 /**
00179   * @}
00180   */
00181 
00182 /** @defgroup CAN_Exported_Constants
00183   * @{
00184   */
00185 
00186 /** @defgroup CAN_sleep_constants 
00187   * @{
00188   */
00189 
00190 #define CANINITFAILED              ((uint8_t)0x00) /*!< CAN initialization failed */
00191 #define CANINITOK                  ((uint8_t)0x01) /*!< CAN initialization failed */
00192 
00193 /**
00194   * @}
00195   */
00196 
00197 /** @defgroup CAN_operating_mode 
00198   * @{
00199   */
00200 
00201 #define CAN_Mode_Normal             ((uint8_t)0x00)  /*!< normal mode */
00202 #define CAN_Mode_LoopBack           ((uint8_t)0x01)  /*!< loopback mode */
00203 #define CAN_Mode_Silent             ((uint8_t)0x02)  /*!< silent mode */
00204 #define CAN_Mode_Silent_LoopBack    ((uint8_t)0x03)  /*!< loopback combined with silent mode */
00205 
00206 #define IS_CAN_MODE(MODE) (((MODE) == CAN_Mode_Normal) || ((MODE) == CAN_Mode_LoopBack)|| \
00207                            ((MODE) == CAN_Mode_Silent) || ((MODE) == CAN_Mode_Silent_LoopBack))
00208 /**
00209   * @}
00210   */
00211 
00212 /** @defgroup CAN_synchronisation_jump_width 
00213   * @{
00214   */
00215 
00216 #define CAN_SJW_1tq                 ((uint8_t)0x00)  /*!< 1 time quantum */
00217 #define CAN_SJW_2tq                 ((uint8_t)0x01)  /*!< 2 time quantum */
00218 #define CAN_SJW_3tq                 ((uint8_t)0x02)  /*!< 3 time quantum */
00219 #define CAN_SJW_4tq                 ((uint8_t)0x03)  /*!< 4 time quantum */
00220 
00221 #define IS_CAN_SJW(SJW) (((SJW) == CAN_SJW_1tq) || ((SJW) == CAN_SJW_2tq)|| \
00222                          ((SJW) == CAN_SJW_3tq) || ((SJW) == CAN_SJW_4tq))
00223 /**
00224   * @}
00225   */
00226 
00227 /** @defgroup CAN_time_quantum_in_bit_segment_1 
00228   * @{
00229   */
00230 
00231 #define CAN_BS1_1tq                 ((uint8_t)0x00)  /*!< 1 time quantum */
00232 #define CAN_BS1_2tq                 ((uint8_t)0x01)  /*!< 2 time quantum */
00233 #define CAN_BS1_3tq                 ((uint8_t)0x02)  /*!< 3 time quantum */
00234 #define CAN_BS1_4tq                 ((uint8_t)0x03)  /*!< 4 time quantum */
00235 #define CAN_BS1_5tq                 ((uint8_t)0x04)  /*!< 5 time quantum */
00236 #define CAN_BS1_6tq                 ((uint8_t)0x05)  /*!< 6 time quantum */
00237 #define CAN_BS1_7tq                 ((uint8_t)0x06)  /*!< 7 time quantum */
00238 #define CAN_BS1_8tq                 ((uint8_t)0x07)  /*!< 8 time quantum */
00239 #define CAN_BS1_9tq                 ((uint8_t)0x08)  /*!< 9 time quantum */
00240 #define CAN_BS1_10tq                ((uint8_t)0x09)  /*!< 10 time quantum */
00241 #define CAN_BS1_11tq                ((uint8_t)0x0A)  /*!< 11 time quantum */
00242 #define CAN_BS1_12tq                ((uint8_t)0x0B)  /*!< 12 time quantum */
00243 #define CAN_BS1_13tq                ((uint8_t)0x0C)  /*!< 13 time quantum */
00244 #define CAN_BS1_14tq                ((uint8_t)0x0D)  /*!< 14 time quantum */
00245 #define CAN_BS1_15tq                ((uint8_t)0x0E)  /*!< 15 time quantum */
00246 #define CAN_BS1_16tq                ((uint8_t)0x0F)  /*!< 16 time quantum */
00247 
00248 #define IS_CAN_BS1(BS1) ((BS1) <= CAN_BS1_16tq)
00249 /**
00250   * @}
00251   */
00252 
00253 /** @defgroup CAN_time_quantum_in_bit_segment_2 
00254   * @{
00255   */
00256 
00257 #define CAN_BS2_1tq                 ((uint8_t)0x00)  /*!< 1 time quantum */
00258 #define CAN_BS2_2tq                 ((uint8_t)0x01)  /*!< 2 time quantum */
00259 #define CAN_BS2_3tq                 ((uint8_t)0x02)  /*!< 3 time quantum */
00260 #define CAN_BS2_4tq                 ((uint8_t)0x03)  /*!< 4 time quantum */
00261 #define CAN_BS2_5tq                 ((uint8_t)0x04)  /*!< 5 time quantum */
00262 #define CAN_BS2_6tq                 ((uint8_t)0x05)  /*!< 6 time quantum */
00263 #define CAN_BS2_7tq                 ((uint8_t)0x06)  /*!< 7 time quantum */
00264 #define CAN_BS2_8tq                 ((uint8_t)0x07)  /*!< 8 time quantum */
00265 
00266 #define IS_CAN_BS2(BS2) ((BS2) <= CAN_BS2_8tq)
00267 
00268 /**
00269   * @}
00270   */
00271 
00272 /** @defgroup CAN_clock_prescaler 
00273   * @{
00274   */
00275 
00276 #define IS_CAN_PRESCALER(PRESCALER) (((PRESCALER) >= 1) && ((PRESCALER) <= 1024))
00277 
00278 /**
00279   * @}
00280   */
00281 
00282 /** @defgroup CAN_filter_number 
00283   * @{
00284   */
00285 #ifndef STM32F10X_CL
00286   #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 13)
00287 #else
00288   #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 27)
00289 #endif /* STM32F10X_CL */ 
00290 /**
00291   * @}
00292   */
00293 
00294 /** @defgroup CAN_filter_mode 
00295   * @{
00296   */
00297 
00298 #define CAN_FilterMode_IdMask       ((uint8_t)0x00)  /*!< id/mask mode */
00299 #define CAN_FilterMode_IdList       ((uint8_t)0x01)  /*!< identifier list mode */
00300 
00301 #define IS_CAN_FILTER_MODE(MODE) (((MODE) == CAN_FilterMode_IdMask) || \
00302                                   ((MODE) == CAN_FilterMode_IdList))
00303 /**
00304   * @}
00305   */
00306 
00307 /** @defgroup CAN_filter_scale 
00308   * @{
00309   */
00310 
00311 #define CAN_FilterScale_16bit       ((uint8_t)0x00) /*!< Two 16-bit filters */
00312 #define CAN_FilterScale_32bit       ((uint8_t)0x01) /*!< One 32-bit filter */
00313 
00314 #define IS_CAN_FILTER_SCALE(SCALE) (((SCALE) == CAN_FilterScale_16bit) || \
00315                                     ((SCALE) == CAN_FilterScale_32bit))
00316 
00317 /**
00318   * @}
00319   */
00320 
00321 /** @defgroup CAN_filter_FIFO
00322   * @{
00323   */
00324 
00325 #define CAN_FilterFIFO0             ((uint8_t)0x00)  /*!< Filter FIFO 0 assignment for filter x */
00326 #define CAN_FilterFIFO1             ((uint8_t)0x01)  /*!< Filter FIFO 1 assignment for filter x */
00327 #define IS_CAN_FILTER_FIFO(FIFO) (((FIFO) == CAN_FilterFIFO0) || \
00328                                   ((FIFO) == CAN_FilterFIFO1))
00329 
00330 /**
00331   * @}
00332   */
00333 
00334 /** @defgroup Start_bank_filter_for_slave_CAN 
00335   * @{
00336   */
00337 #define IS_CAN_BANKNUMBER(BANKNUMBER) (((BANKNUMBER) >= 1) && ((BANKNUMBER) <= 27))
00338 /**
00339   * @}
00340   */
00341 
00342 /** @defgroup CAN_Tx 
00343   * @{
00344   */
00345 
00346 #define IS_CAN_TRANSMITMAILBOX(TRANSMITMAILBOX) ((TRANSMITMAILBOX) <= ((uint8_t)0x02))
00347 #define IS_CAN_STDID(STDID)   ((STDID) <= ((uint32_t)0x7FF))
00348 #define IS_CAN_EXTID(EXTID)   ((EXTID) <= ((uint32_t)0x1FFFFFFF))
00349 #define IS_CAN_DLC(DLC)       ((DLC) <= ((uint8_t)0x08))
00350 
00351 /**
00352   * @}
00353   */
00354 
00355 /** @defgroup CAN_identifier_type 
00356   * @{
00357   */
00358 
00359 #define CAN_ID_STD                 ((uint32_t)0x00000000)  /*!< Standard Id */
00360 #define CAN_ID_EXT                 ((uint32_t)0x00000004)  /*!< Extended Id */
00361 #define IS_CAN_IDTYPE(IDTYPE) (((IDTYPE) == CAN_ID_STD) || ((IDTYPE) == CAN_ID_EXT))
00362 
00363 /**
00364   * @}
00365   */
00366 
00367 /** @defgroup CAN_remote_transmission_request 
00368   * @{
00369   */
00370 
00371 #define CAN_RTR_DATA                ((uint32_t)0x00000000)  /*!< Data frame */
00372 #define CAN_RTR_REMOTE              ((uint32_t)0x00000002)  /*!< Remote frame */
00373 #define IS_CAN_RTR(RTR) (((RTR) == CAN_RTR_DATA) || ((RTR) == CAN_RTR_REMOTE))
00374 
00375 /**
00376   * @}
00377   */
00378 
00379 /** @defgroup CAN_transmit_constants 
00380   * @{
00381   */
00382 
00383 #define CANTXFAILED                 ((uint8_t)0x00) /*!< CAN transmission failed */
00384 #define CANTXOK                     ((uint8_t)0x01) /*!< CAN transmission succeeded */
00385 #define CANTXPENDING                ((uint8_t)0x02) /*!< CAN transmission pending */
00386 #define CAN_NO_MB                   ((uint8_t)0x04) /*!< CAN cell did not provide an empty mailbox */
00387 
00388 /**
00389   * @}
00390   */
00391 
00392 /** @defgroup CAN_receive_FIFO_number_constants 
00393   * @{
00394   */
00395 
00396 #define CAN_FIFO0                 ((uint8_t)0x00) /*!< CAN FIFO0 used to receive */
00397 #define CAN_FIFO1                 ((uint8_t)0x01) /*!< CAN FIFO1 used to receive */
00398 
00399 #define IS_CAN_FIFO(FIFO) (((FIFO) == CAN_FIFO0) || ((FIFO) == CAN_FIFO1))
00400 
00401 /**
00402   * @}
00403   */
00404 
00405 /** @defgroup CAN_sleep_constants 
00406   * @{
00407   */
00408 
00409 #define CANSLEEPFAILED              ((uint8_t)0x00) /*!< CAN did not enter the sleep mode */
00410 #define CANSLEEPOK                  ((uint8_t)0x01) /*!< CAN entered the sleep mode */
00411 
00412 /**
00413   * @}
00414   */
00415 
00416 /** @defgroup CAN_wake_up_constants 
00417   * @{
00418   */
00419 
00420 #define CANWAKEUPFAILED             ((uint8_t)0x00) /*!< CAN did not leave the sleep mode */
00421 #define CANWAKEUPOK                 ((uint8_t)0x01) /*!< CAN leaved the sleep mode */
00422 
00423 /**
00424   * @}
00425   */
00426 
00427 /** @defgroup CAN_flags 
00428   * @{
00429   */
00430 /* If the flag is 0x3XXXXXXX, it means that it can be used with CAN_GetFlagStatus()
00431    and CAN_ClearFlag() functions. */
00432 /* If the flag is 0x1XXXXXXX, it means that it can only be used with CAN_GetFlagStatus() function.  */
00433 
00434 /* Transmit Flags */
00435 #define CAN_FLAG_RQCP0             ((uint32_t)0x38000001) /*!< Request MailBox0 Flag */
00436 #define CAN_FLAG_RQCP1             ((uint32_t)0x38000100) /*!< Request MailBox1 Flag */
00437 #define CAN_FLAG_RQCP2             ((uint32_t)0x38010000) /*!< Request MailBox2 Flag */
00438 
00439 /* Receive Flags */
00440 #define CAN_FLAG_FMP0              ((uint32_t)0x12000003) /*!< FIFO 0 Message Pending Flag */
00441 #define CAN_FLAG_FF0               ((uint32_t)0x32000008) /*!< FIFO 0 Full Flag            */
00442 #define CAN_FLAG_FOV0              ((uint32_t)0x32000010) /*!< FIFO 0 Overrun Flag         */
00443 #define CAN_FLAG_FMP1              ((uint32_t)0x14000003) /*!< FIFO 1 Message Pending Flag */
00444 #define CAN_FLAG_FF1               ((uint32_t)0x34000008) /*!< FIFO 1 Full Flag            */
00445 #define CAN_FLAG_FOV1              ((uint32_t)0x34000010) /*!< FIFO 1 Overrun Flag         */
00446 
00447 /* Operating Mode Flags */
00448 #define CAN_FLAG_WKU               ((uint32_t)0x31000008) /*!< Wake up Flag */
00449 #define CAN_FLAG_SLAK              ((uint32_t)0x31000012) /*!< Sleep acknowledge Flag */
00450 /* Note: When SLAK intterupt is disabled (SLKIE=0), no polling on SLAKI is possible. 
00451          In this case the SLAK bit can be polled.*/
00452 
00453 /* Error Flags */
00454 #define CAN_FLAG_EWG               ((uint32_t)0x10F00001) /*!< Error Warning Flag   */
00455 #define CAN_FLAG_EPV               ((uint32_t)0x10F00002) /*!< Error Passive Flag   */
00456 #define CAN_FLAG_BOF               ((uint32_t)0x10F00004) /*!< Bus-Off Flag         */
00457 #define CAN_FLAG_LEC               ((uint32_t)0x30F00070) /*!< Last error code Flag */
00458 
00459 #define IS_CAN_GET_FLAG(FLAG) (((FLAG) == CAN_FLAG_LEC)  || ((FLAG) == CAN_FLAG_BOF)   || \
00460                                ((FLAG) == CAN_FLAG_EPV)  || ((FLAG) == CAN_FLAG_EWG)   || \
00461                                ((FLAG) == CAN_FLAG_WKU)  || ((FLAG) == CAN_FLAG_FOV0)  || \
00462                                ((FLAG) == CAN_FLAG_FF0)  || ((FLAG) == CAN_FLAG_FMP0)  || \
00463                                ((FLAG) == CAN_FLAG_FOV1) || ((FLAG) == CAN_FLAG_FF1)   || \
00464                                ((FLAG) == CAN_FLAG_FMP1) || ((FLAG) == CAN_FLAG_RQCP2) || \
00465                                ((FLAG) == CAN_FLAG_RQCP1)|| ((FLAG) == CAN_FLAG_RQCP0) || \
00466                                ((FLAG) == CAN_FLAG_SLAK ))
00467 
00468 #define IS_CAN_CLEAR_FLAG(FLAG)(((FLAG) == CAN_FLAG_LEC) || ((FLAG) == CAN_FLAG_RQCP2) || \
00469                                 ((FLAG) == CAN_FLAG_RQCP1)  || ((FLAG) == CAN_FLAG_RQCP0) || \
00470                                 ((FLAG) == CAN_FLAG_FF0)  || ((FLAG) == CAN_FLAG_FOV0) ||\
00471                                 ((FLAG) == CAN_FLAG_FF1) || ((FLAG) == CAN_FLAG_FOV1) || \
00472                                 ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_SLAK))
00473 /**
00474   * @}
00475   */
00476 
00477   
00478 /** @defgroup CAN_interrupts 
00479   * @{
00480   */
00481 
00482 
00483   
00484 #define CAN_IT_TME                  ((uint32_t)0x00000001) /*!< Transmit mailbox empty Interrupt*/
00485 
00486 /* Receive Interrupts */
00487 #define CAN_IT_FMP0                 ((uint32_t)0x00000002) /*!< FIFO 0 message pending Interrupt*/
00488 #define CAN_IT_FF0                  ((uint32_t)0x00000004) /*!< FIFO 0 full Interrupt*/
00489 #define CAN_IT_FOV0                 ((uint32_t)0x00000008) /*!< FIFO 0 overrun Interrupt*/
00490 #define CAN_IT_FMP1                 ((uint32_t)0x00000010) /*!< FIFO 1 message pending Interrupt*/
00491 #define CAN_IT_FF1                  ((uint32_t)0x00000020) /*!< FIFO 1 full Interrupt*/
00492 #define CAN_IT_FOV1                 ((uint32_t)0x00000040) /*!< FIFO 1 overrun Interrupt*/
00493 
00494 /* Operating Mode Interrupts */
00495 #define CAN_IT_WKU                  ((uint32_t)0x00010000) /*!< Wake-up Interrupt*/
00496 #define CAN_IT_SLK                  ((uint32_t)0x00020000) /*!< Sleep acknowledge Interrupt*/
00497 
00498 /* Error Interrupts */
00499 #define CAN_IT_EWG                  ((uint32_t)0x00000100) /*!< Error warning Interrupt*/
00500 #define CAN_IT_EPV                  ((uint32_t)0x00000200) /*!< Error passive Interrupt*/
00501 #define CAN_IT_BOF                  ((uint32_t)0x00000400) /*!< Bus-off Interrupt*/
00502 #define CAN_IT_LEC                  ((uint32_t)0x00000800) /*!< Last error code Interrupt*/
00503 #define CAN_IT_ERR                  ((uint32_t)0x00008000) /*!< Error Interrupt*/
00504 
00505 /* Flags named as Interrupts : kept only for FW compatibility */
00506 #define CAN_IT_RQCP0   CAN_IT_TME
00507 #define CAN_IT_RQCP1   CAN_IT_TME
00508 #define CAN_IT_RQCP2   CAN_IT_TME
00509 
00510 
00511 #define IS_CAN_IT(IT)        (((IT) == CAN_IT_TME)   || ((IT) == CAN_IT_FMP0)  ||\
00512                              ((IT) == CAN_IT_FF0)   || ((IT) == CAN_IT_FOV0)  ||\
00513                              ((IT) == CAN_IT_FMP1)  || ((IT) == CAN_IT_FF1)   ||\
00514                              ((IT) == CAN_IT_FOV1)  || ((IT) == CAN_IT_EWG)   ||\
00515                              ((IT) == CAN_IT_EPV)   || ((IT) == CAN_IT_BOF)   ||\
00516                              ((IT) == CAN_IT_LEC)   || ((IT) == CAN_IT_ERR)   ||\
00517                              ((IT) == CAN_IT_WKU)   || ((IT) == CAN_IT_SLK))
00518 
00519 #define IS_CAN_CLEAR_IT(IT) (((IT) == CAN_IT_TME)    || ((IT) == CAN_IT_FF0)    ||\
00520                              ((IT) == CAN_IT_FOV0)   || ((IT) == CAN_IT_FF1)    ||\
00521                              ((IT) == CAN_IT_FOV1)   || ((IT) == CAN_IT_EWG)    ||\
00522                              ((IT) == CAN_IT_EPV)    || ((IT) == CAN_IT_BOF)    ||\
00523                              ((IT) == CAN_IT_LEC)    || ((IT) == CAN_IT_ERR)    ||\
00524                              ((IT) == CAN_IT_WKU)    || ((IT) == CAN_IT_SLK))
00525 
00526 /**
00527   * @}
00528   */
00529 
00530 /**
00531   * @}
00532   */
00533 
00534 /** @defgroup CAN_Exported_Macros
00535   * @{
00536   */
00537 
00538 /**
00539   * @}
00540   */
00541 
00542 /** @defgroup CAN_Exported_Functions
00543   * @{
00544   */
00545 
00546 void CAN_DeInit(CAN_TypeDef* CANx);
00547 uint8_t CAN_Init(CAN_TypeDef* CANx, CAN_InitTypeDef* CAN_InitStruct);
00548 void CAN_FilterInit(CAN_FilterInitTypeDef* CAN_FilterInitStruct);
00549 void CAN_StructInit(CAN_InitTypeDef* CAN_InitStruct);
00550 void CAN_SlaveStartBank(uint8_t CAN_BankNumber); 
00551 void CAN_ITConfig(CAN_TypeDef* CANx, uint32_t CAN_IT, FunctionalState NewState);
00552 uint8_t CAN_Transmit(CAN_TypeDef* CANx, CanTxMsg* TxMessage);
00553 uint8_t CAN_TransmitStatus(CAN_TypeDef* CANx, uint8_t TransmitMailbox);
00554 void CAN_CancelTransmit(CAN_TypeDef* CANx, uint8_t Mailbox);
00555 void CAN_FIFORelease(CAN_TypeDef* CANx, uint8_t FIFONumber);
00556 uint8_t CAN_MessagePending(CAN_TypeDef* CANx, uint8_t FIFONumber);
00557 void CAN_Receive(CAN_TypeDef* CANx, uint8_t FIFONumber, CanRxMsg* RxMessage);
00558 void CAN_DBGFreeze(CAN_TypeDef* CANx, FunctionalState NewState);
00559 uint8_t CAN_Sleep(CAN_TypeDef* CANx);
00560 uint8_t CAN_WakeUp(CAN_TypeDef* CANx);
00561 FlagStatus CAN_GetFlagStatus(CAN_TypeDef* CANx, uint32_t CAN_FLAG);
00562 void CAN_ClearFlag(CAN_TypeDef* CANx, uint32_t CAN_FLAG);
00563 ITStatus CAN_GetITStatus(CAN_TypeDef* CANx, uint32_t CAN_IT);
00564 void CAN_ClearITPendingBit(CAN_TypeDef* CANx, uint32_t CAN_IT);
00565 
00566 #ifdef __cplusplus
00567 }
00568 #endif
00569 
00570 #endif /* __STM32F10x_CAN_H */
00571 /**
00572   * @}
00573   */
00574 
00575 /**
00576   * @}
00577   */
00578 
00579 /**
00580   * @}
00581   */
00582 
00583 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32