/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/adc/fsl_adc_hal.h substitute line 894 extern } by }
Fork of mbed by
TARGET_NUCLEO_F103RB/stm32f10x_can.h@73:1efda918f0ba, 2013-12-09 (annotated)
- Committer:
- bogdanm
- Date:
- Mon Dec 09 18:43:03 2013 +0200
- Revision:
- 73:1efda918f0ba
- Child:
- 76:824293ae5e43
Release 73 of the mbed library
Main changes:
- added support for KL46Z and NUCLEO_F103RB
- STM32 USB device support
- various bug fixes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 73:1efda918f0ba | 1 | /** |
bogdanm | 73:1efda918f0ba | 2 | ****************************************************************************** |
bogdanm | 73:1efda918f0ba | 3 | * @file stm32f10x_can.h |
bogdanm | 73:1efda918f0ba | 4 | * @author MCD Application Team |
bogdanm | 73:1efda918f0ba | 5 | * @version V3.5.0 |
bogdanm | 73:1efda918f0ba | 6 | * @date 11-March-2011 |
bogdanm | 73:1efda918f0ba | 7 | * @brief This file contains all the functions prototypes for the CAN firmware |
bogdanm | 73:1efda918f0ba | 8 | * library. |
bogdanm | 73:1efda918f0ba | 9 | ****************************************************************************** |
bogdanm | 73:1efda918f0ba | 10 | * @attention |
bogdanm | 73:1efda918f0ba | 11 | * |
bogdanm | 73:1efda918f0ba | 12 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
bogdanm | 73:1efda918f0ba | 13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE |
bogdanm | 73:1efda918f0ba | 14 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY |
bogdanm | 73:1efda918f0ba | 15 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING |
bogdanm | 73:1efda918f0ba | 16 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE |
bogdanm | 73:1efda918f0ba | 17 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
bogdanm | 73:1efda918f0ba | 18 | * |
bogdanm | 73:1efda918f0ba | 19 | * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2> |
bogdanm | 73:1efda918f0ba | 20 | ****************************************************************************** |
bogdanm | 73:1efda918f0ba | 21 | */ |
bogdanm | 73:1efda918f0ba | 22 | |
bogdanm | 73:1efda918f0ba | 23 | /* Define to prevent recursive inclusion -------------------------------------*/ |
bogdanm | 73:1efda918f0ba | 24 | #ifndef __STM32F10x_CAN_H |
bogdanm | 73:1efda918f0ba | 25 | #define __STM32F10x_CAN_H |
bogdanm | 73:1efda918f0ba | 26 | |
bogdanm | 73:1efda918f0ba | 27 | #ifdef __cplusplus |
bogdanm | 73:1efda918f0ba | 28 | extern "C" { |
bogdanm | 73:1efda918f0ba | 29 | #endif |
bogdanm | 73:1efda918f0ba | 30 | |
bogdanm | 73:1efda918f0ba | 31 | /* Includes ------------------------------------------------------------------*/ |
bogdanm | 73:1efda918f0ba | 32 | #include "stm32f10x.h" |
bogdanm | 73:1efda918f0ba | 33 | |
bogdanm | 73:1efda918f0ba | 34 | /** @addtogroup STM32F10x_StdPeriph_Driver |
bogdanm | 73:1efda918f0ba | 35 | * @{ |
bogdanm | 73:1efda918f0ba | 36 | */ |
bogdanm | 73:1efda918f0ba | 37 | |
bogdanm | 73:1efda918f0ba | 38 | /** @addtogroup CAN |
bogdanm | 73:1efda918f0ba | 39 | * @{ |
bogdanm | 73:1efda918f0ba | 40 | */ |
bogdanm | 73:1efda918f0ba | 41 | |
bogdanm | 73:1efda918f0ba | 42 | /** @defgroup CAN_Exported_Types |
bogdanm | 73:1efda918f0ba | 43 | * @{ |
bogdanm | 73:1efda918f0ba | 44 | */ |
bogdanm | 73:1efda918f0ba | 45 | |
bogdanm | 73:1efda918f0ba | 46 | #define IS_CAN_ALL_PERIPH(PERIPH) (((PERIPH) == CAN1) || \ |
bogdanm | 73:1efda918f0ba | 47 | ((PERIPH) == CAN2)) |
bogdanm | 73:1efda918f0ba | 48 | |
bogdanm | 73:1efda918f0ba | 49 | /** |
bogdanm | 73:1efda918f0ba | 50 | * @brief CAN init structure definition |
bogdanm | 73:1efda918f0ba | 51 | */ |
bogdanm | 73:1efda918f0ba | 52 | |
bogdanm | 73:1efda918f0ba | 53 | typedef struct |
bogdanm | 73:1efda918f0ba | 54 | { |
bogdanm | 73:1efda918f0ba | 55 | uint16_t CAN_Prescaler; /*!< Specifies the length of a time quantum. |
bogdanm | 73:1efda918f0ba | 56 | It ranges from 1 to 1024. */ |
bogdanm | 73:1efda918f0ba | 57 | |
bogdanm | 73:1efda918f0ba | 58 | uint8_t CAN_Mode; /*!< Specifies the CAN operating mode. |
bogdanm | 73:1efda918f0ba | 59 | This parameter can be a value of |
bogdanm | 73:1efda918f0ba | 60 | @ref CAN_operating_mode */ |
bogdanm | 73:1efda918f0ba | 61 | |
bogdanm | 73:1efda918f0ba | 62 | uint8_t CAN_SJW; /*!< Specifies the maximum number of time quanta |
bogdanm | 73:1efda918f0ba | 63 | the CAN hardware is allowed to lengthen or |
bogdanm | 73:1efda918f0ba | 64 | shorten a bit to perform resynchronization. |
bogdanm | 73:1efda918f0ba | 65 | This parameter can be a value of |
bogdanm | 73:1efda918f0ba | 66 | @ref CAN_synchronisation_jump_width */ |
bogdanm | 73:1efda918f0ba | 67 | |
bogdanm | 73:1efda918f0ba | 68 | uint8_t CAN_BS1; /*!< Specifies the number of time quanta in Bit |
bogdanm | 73:1efda918f0ba | 69 | Segment 1. This parameter can be a value of |
bogdanm | 73:1efda918f0ba | 70 | @ref CAN_time_quantum_in_bit_segment_1 */ |
bogdanm | 73:1efda918f0ba | 71 | |
bogdanm | 73:1efda918f0ba | 72 | uint8_t CAN_BS2; /*!< Specifies the number of time quanta in Bit |
bogdanm | 73:1efda918f0ba | 73 | Segment 2. |
bogdanm | 73:1efda918f0ba | 74 | This parameter can be a value of |
bogdanm | 73:1efda918f0ba | 75 | @ref CAN_time_quantum_in_bit_segment_2 */ |
bogdanm | 73:1efda918f0ba | 76 | |
bogdanm | 73:1efda918f0ba | 77 | FunctionalState CAN_TTCM; /*!< Enable or disable the time triggered |
bogdanm | 73:1efda918f0ba | 78 | communication mode. This parameter can be set |
bogdanm | 73:1efda918f0ba | 79 | either to ENABLE or DISABLE. */ |
bogdanm | 73:1efda918f0ba | 80 | |
bogdanm | 73:1efda918f0ba | 81 | FunctionalState CAN_ABOM; /*!< Enable or disable the automatic bus-off |
bogdanm | 73:1efda918f0ba | 82 | management. This parameter can be set either |
bogdanm | 73:1efda918f0ba | 83 | to ENABLE or DISABLE. */ |
bogdanm | 73:1efda918f0ba | 84 | |
bogdanm | 73:1efda918f0ba | 85 | FunctionalState CAN_AWUM; /*!< Enable or disable the automatic wake-up mode. |
bogdanm | 73:1efda918f0ba | 86 | This parameter can be set either to ENABLE or |
bogdanm | 73:1efda918f0ba | 87 | DISABLE. */ |
bogdanm | 73:1efda918f0ba | 88 | |
bogdanm | 73:1efda918f0ba | 89 | FunctionalState CAN_NART; /*!< Enable or disable the no-automatic |
bogdanm | 73:1efda918f0ba | 90 | retransmission mode. This parameter can be |
bogdanm | 73:1efda918f0ba | 91 | set either to ENABLE or DISABLE. */ |
bogdanm | 73:1efda918f0ba | 92 | |
bogdanm | 73:1efda918f0ba | 93 | FunctionalState CAN_RFLM; /*!< Enable or disable the Receive FIFO Locked mode. |
bogdanm | 73:1efda918f0ba | 94 | This parameter can be set either to ENABLE |
bogdanm | 73:1efda918f0ba | 95 | or DISABLE. */ |
bogdanm | 73:1efda918f0ba | 96 | |
bogdanm | 73:1efda918f0ba | 97 | FunctionalState CAN_TXFP; /*!< Enable or disable the transmit FIFO priority. |
bogdanm | 73:1efda918f0ba | 98 | This parameter can be set either to ENABLE |
bogdanm | 73:1efda918f0ba | 99 | or DISABLE. */ |
bogdanm | 73:1efda918f0ba | 100 | } CAN_InitTypeDef; |
bogdanm | 73:1efda918f0ba | 101 | |
bogdanm | 73:1efda918f0ba | 102 | /** |
bogdanm | 73:1efda918f0ba | 103 | * @brief CAN filter init structure definition |
bogdanm | 73:1efda918f0ba | 104 | */ |
bogdanm | 73:1efda918f0ba | 105 | |
bogdanm | 73:1efda918f0ba | 106 | typedef struct |
bogdanm | 73:1efda918f0ba | 107 | { |
bogdanm | 73:1efda918f0ba | 108 | uint16_t CAN_FilterIdHigh; /*!< Specifies the filter identification number (MSBs for a 32-bit |
bogdanm | 73:1efda918f0ba | 109 | configuration, first one for a 16-bit configuration). |
bogdanm | 73:1efda918f0ba | 110 | This parameter can be a value between 0x0000 and 0xFFFF */ |
bogdanm | 73:1efda918f0ba | 111 | |
bogdanm | 73:1efda918f0ba | 112 | uint16_t CAN_FilterIdLow; /*!< Specifies the filter identification number (LSBs for a 32-bit |
bogdanm | 73:1efda918f0ba | 113 | configuration, second one for a 16-bit configuration). |
bogdanm | 73:1efda918f0ba | 114 | This parameter can be a value between 0x0000 and 0xFFFF */ |
bogdanm | 73:1efda918f0ba | 115 | |
bogdanm | 73:1efda918f0ba | 116 | uint16_t CAN_FilterMaskIdHigh; /*!< Specifies the filter mask number or identification number, |
bogdanm | 73:1efda918f0ba | 117 | according to the mode (MSBs for a 32-bit configuration, |
bogdanm | 73:1efda918f0ba | 118 | first one for a 16-bit configuration). |
bogdanm | 73:1efda918f0ba | 119 | This parameter can be a value between 0x0000 and 0xFFFF */ |
bogdanm | 73:1efda918f0ba | 120 | |
bogdanm | 73:1efda918f0ba | 121 | uint16_t CAN_FilterMaskIdLow; /*!< Specifies the filter mask number or identification number, |
bogdanm | 73:1efda918f0ba | 122 | according to the mode (LSBs for a 32-bit configuration, |
bogdanm | 73:1efda918f0ba | 123 | second one for a 16-bit configuration). |
bogdanm | 73:1efda918f0ba | 124 | This parameter can be a value between 0x0000 and 0xFFFF */ |
bogdanm | 73:1efda918f0ba | 125 | |
bogdanm | 73:1efda918f0ba | 126 | uint16_t CAN_FilterFIFOAssignment; /*!< Specifies the FIFO (0 or 1) which will be assigned to the filter. |
bogdanm | 73:1efda918f0ba | 127 | This parameter can be a value of @ref CAN_filter_FIFO */ |
bogdanm | 73:1efda918f0ba | 128 | |
bogdanm | 73:1efda918f0ba | 129 | uint8_t CAN_FilterNumber; /*!< Specifies the filter which will be initialized. It ranges from 0 to 13. */ |
bogdanm | 73:1efda918f0ba | 130 | |
bogdanm | 73:1efda918f0ba | 131 | uint8_t CAN_FilterMode; /*!< Specifies the filter mode to be initialized. |
bogdanm | 73:1efda918f0ba | 132 | This parameter can be a value of @ref CAN_filter_mode */ |
bogdanm | 73:1efda918f0ba | 133 | |
bogdanm | 73:1efda918f0ba | 134 | uint8_t CAN_FilterScale; /*!< Specifies the filter scale. |
bogdanm | 73:1efda918f0ba | 135 | This parameter can be a value of @ref CAN_filter_scale */ |
bogdanm | 73:1efda918f0ba | 136 | |
bogdanm | 73:1efda918f0ba | 137 | FunctionalState CAN_FilterActivation; /*!< Enable or disable the filter. |
bogdanm | 73:1efda918f0ba | 138 | This parameter can be set either to ENABLE or DISABLE. */ |
bogdanm | 73:1efda918f0ba | 139 | } CAN_FilterInitTypeDef; |
bogdanm | 73:1efda918f0ba | 140 | |
bogdanm | 73:1efda918f0ba | 141 | /** |
bogdanm | 73:1efda918f0ba | 142 | * @brief CAN Tx message structure definition |
bogdanm | 73:1efda918f0ba | 143 | */ |
bogdanm | 73:1efda918f0ba | 144 | |
bogdanm | 73:1efda918f0ba | 145 | typedef struct |
bogdanm | 73:1efda918f0ba | 146 | { |
bogdanm | 73:1efda918f0ba | 147 | uint32_t StdId; /*!< Specifies the standard identifier. |
bogdanm | 73:1efda918f0ba | 148 | This parameter can be a value between 0 to 0x7FF. */ |
bogdanm | 73:1efda918f0ba | 149 | |
bogdanm | 73:1efda918f0ba | 150 | uint32_t ExtId; /*!< Specifies the extended identifier. |
bogdanm | 73:1efda918f0ba | 151 | This parameter can be a value between 0 to 0x1FFFFFFF. */ |
bogdanm | 73:1efda918f0ba | 152 | |
bogdanm | 73:1efda918f0ba | 153 | uint8_t IDE; /*!< Specifies the type of identifier for the message that |
bogdanm | 73:1efda918f0ba | 154 | will be transmitted. This parameter can be a value |
bogdanm | 73:1efda918f0ba | 155 | of @ref CAN_identifier_type */ |
bogdanm | 73:1efda918f0ba | 156 | |
bogdanm | 73:1efda918f0ba | 157 | uint8_t RTR; /*!< Specifies the type of frame for the message that will |
bogdanm | 73:1efda918f0ba | 158 | be transmitted. This parameter can be a value of |
bogdanm | 73:1efda918f0ba | 159 | @ref CAN_remote_transmission_request */ |
bogdanm | 73:1efda918f0ba | 160 | |
bogdanm | 73:1efda918f0ba | 161 | uint8_t DLC; /*!< Specifies the length of the frame that will be |
bogdanm | 73:1efda918f0ba | 162 | transmitted. This parameter can be a value between |
bogdanm | 73:1efda918f0ba | 163 | 0 to 8 */ |
bogdanm | 73:1efda918f0ba | 164 | |
bogdanm | 73:1efda918f0ba | 165 | uint8_t Data[8]; /*!< Contains the data to be transmitted. It ranges from 0 |
bogdanm | 73:1efda918f0ba | 166 | to 0xFF. */ |
bogdanm | 73:1efda918f0ba | 167 | } CanTxMsg; |
bogdanm | 73:1efda918f0ba | 168 | |
bogdanm | 73:1efda918f0ba | 169 | /** |
bogdanm | 73:1efda918f0ba | 170 | * @brief CAN Rx message structure definition |
bogdanm | 73:1efda918f0ba | 171 | */ |
bogdanm | 73:1efda918f0ba | 172 | |
bogdanm | 73:1efda918f0ba | 173 | typedef struct |
bogdanm | 73:1efda918f0ba | 174 | { |
bogdanm | 73:1efda918f0ba | 175 | uint32_t StdId; /*!< Specifies the standard identifier. |
bogdanm | 73:1efda918f0ba | 176 | This parameter can be a value between 0 to 0x7FF. */ |
bogdanm | 73:1efda918f0ba | 177 | |
bogdanm | 73:1efda918f0ba | 178 | uint32_t ExtId; /*!< Specifies the extended identifier. |
bogdanm | 73:1efda918f0ba | 179 | This parameter can be a value between 0 to 0x1FFFFFFF. */ |
bogdanm | 73:1efda918f0ba | 180 | |
bogdanm | 73:1efda918f0ba | 181 | uint8_t IDE; /*!< Specifies the type of identifier for the message that |
bogdanm | 73:1efda918f0ba | 182 | will be received. This parameter can be a value of |
bogdanm | 73:1efda918f0ba | 183 | @ref CAN_identifier_type */ |
bogdanm | 73:1efda918f0ba | 184 | |
bogdanm | 73:1efda918f0ba | 185 | uint8_t RTR; /*!< Specifies the type of frame for the received message. |
bogdanm | 73:1efda918f0ba | 186 | This parameter can be a value of |
bogdanm | 73:1efda918f0ba | 187 | @ref CAN_remote_transmission_request */ |
bogdanm | 73:1efda918f0ba | 188 | |
bogdanm | 73:1efda918f0ba | 189 | uint8_t DLC; /*!< Specifies the length of the frame that will be received. |
bogdanm | 73:1efda918f0ba | 190 | This parameter can be a value between 0 to 8 */ |
bogdanm | 73:1efda918f0ba | 191 | |
bogdanm | 73:1efda918f0ba | 192 | uint8_t Data[8]; /*!< Contains the data to be received. It ranges from 0 to |
bogdanm | 73:1efda918f0ba | 193 | 0xFF. */ |
bogdanm | 73:1efda918f0ba | 194 | |
bogdanm | 73:1efda918f0ba | 195 | uint8_t FMI; /*!< Specifies the index of the filter the message stored in |
bogdanm | 73:1efda918f0ba | 196 | the mailbox passes through. This parameter can be a |
bogdanm | 73:1efda918f0ba | 197 | value between 0 to 0xFF */ |
bogdanm | 73:1efda918f0ba | 198 | } CanRxMsg; |
bogdanm | 73:1efda918f0ba | 199 | |
bogdanm | 73:1efda918f0ba | 200 | /** |
bogdanm | 73:1efda918f0ba | 201 | * @} |
bogdanm | 73:1efda918f0ba | 202 | */ |
bogdanm | 73:1efda918f0ba | 203 | |
bogdanm | 73:1efda918f0ba | 204 | /** @defgroup CAN_Exported_Constants |
bogdanm | 73:1efda918f0ba | 205 | * @{ |
bogdanm | 73:1efda918f0ba | 206 | */ |
bogdanm | 73:1efda918f0ba | 207 | |
bogdanm | 73:1efda918f0ba | 208 | /** @defgroup CAN_sleep_constants |
bogdanm | 73:1efda918f0ba | 209 | * @{ |
bogdanm | 73:1efda918f0ba | 210 | */ |
bogdanm | 73:1efda918f0ba | 211 | |
bogdanm | 73:1efda918f0ba | 212 | #define CAN_InitStatus_Failed ((uint8_t)0x00) /*!< CAN initialization failed */ |
bogdanm | 73:1efda918f0ba | 213 | #define CAN_InitStatus_Success ((uint8_t)0x01) /*!< CAN initialization OK */ |
bogdanm | 73:1efda918f0ba | 214 | |
bogdanm | 73:1efda918f0ba | 215 | /** |
bogdanm | 73:1efda918f0ba | 216 | * @} |
bogdanm | 73:1efda918f0ba | 217 | */ |
bogdanm | 73:1efda918f0ba | 218 | |
bogdanm | 73:1efda918f0ba | 219 | /** @defgroup CAN_Mode |
bogdanm | 73:1efda918f0ba | 220 | * @{ |
bogdanm | 73:1efda918f0ba | 221 | */ |
bogdanm | 73:1efda918f0ba | 222 | |
bogdanm | 73:1efda918f0ba | 223 | #define CAN_Mode_Normal ((uint8_t)0x00) /*!< normal mode */ |
bogdanm | 73:1efda918f0ba | 224 | #define CAN_Mode_LoopBack ((uint8_t)0x01) /*!< loopback mode */ |
bogdanm | 73:1efda918f0ba | 225 | #define CAN_Mode_Silent ((uint8_t)0x02) /*!< silent mode */ |
bogdanm | 73:1efda918f0ba | 226 | #define CAN_Mode_Silent_LoopBack ((uint8_t)0x03) /*!< loopback combined with silent mode */ |
bogdanm | 73:1efda918f0ba | 227 | |
bogdanm | 73:1efda918f0ba | 228 | #define IS_CAN_MODE(MODE) (((MODE) == CAN_Mode_Normal) || \ |
bogdanm | 73:1efda918f0ba | 229 | ((MODE) == CAN_Mode_LoopBack)|| \ |
bogdanm | 73:1efda918f0ba | 230 | ((MODE) == CAN_Mode_Silent) || \ |
bogdanm | 73:1efda918f0ba | 231 | ((MODE) == CAN_Mode_Silent_LoopBack)) |
bogdanm | 73:1efda918f0ba | 232 | /** |
bogdanm | 73:1efda918f0ba | 233 | * @} |
bogdanm | 73:1efda918f0ba | 234 | */ |
bogdanm | 73:1efda918f0ba | 235 | |
bogdanm | 73:1efda918f0ba | 236 | |
bogdanm | 73:1efda918f0ba | 237 | /** |
bogdanm | 73:1efda918f0ba | 238 | * @defgroup CAN_Operating_Mode |
bogdanm | 73:1efda918f0ba | 239 | * @{ |
bogdanm | 73:1efda918f0ba | 240 | */ |
bogdanm | 73:1efda918f0ba | 241 | #define CAN_OperatingMode_Initialization ((uint8_t)0x00) /*!< Initialization mode */ |
bogdanm | 73:1efda918f0ba | 242 | #define CAN_OperatingMode_Normal ((uint8_t)0x01) /*!< Normal mode */ |
bogdanm | 73:1efda918f0ba | 243 | #define CAN_OperatingMode_Sleep ((uint8_t)0x02) /*!< sleep mode */ |
bogdanm | 73:1efda918f0ba | 244 | |
bogdanm | 73:1efda918f0ba | 245 | |
bogdanm | 73:1efda918f0ba | 246 | #define IS_CAN_OPERATING_MODE(MODE) (((MODE) == CAN_OperatingMode_Initialization) ||\ |
bogdanm | 73:1efda918f0ba | 247 | ((MODE) == CAN_OperatingMode_Normal)|| \ |
bogdanm | 73:1efda918f0ba | 248 | ((MODE) == CAN_OperatingMode_Sleep)) |
bogdanm | 73:1efda918f0ba | 249 | /** |
bogdanm | 73:1efda918f0ba | 250 | * @} |
bogdanm | 73:1efda918f0ba | 251 | */ |
bogdanm | 73:1efda918f0ba | 252 | |
bogdanm | 73:1efda918f0ba | 253 | /** |
bogdanm | 73:1efda918f0ba | 254 | * @defgroup CAN_Mode_Status |
bogdanm | 73:1efda918f0ba | 255 | * @{ |
bogdanm | 73:1efda918f0ba | 256 | */ |
bogdanm | 73:1efda918f0ba | 257 | |
bogdanm | 73:1efda918f0ba | 258 | #define CAN_ModeStatus_Failed ((uint8_t)0x00) /*!< CAN entering the specific mode failed */ |
bogdanm | 73:1efda918f0ba | 259 | #define CAN_ModeStatus_Success ((uint8_t)!CAN_ModeStatus_Failed) /*!< CAN entering the specific mode Succeed */ |
bogdanm | 73:1efda918f0ba | 260 | |
bogdanm | 73:1efda918f0ba | 261 | |
bogdanm | 73:1efda918f0ba | 262 | /** |
bogdanm | 73:1efda918f0ba | 263 | * @} |
bogdanm | 73:1efda918f0ba | 264 | */ |
bogdanm | 73:1efda918f0ba | 265 | |
bogdanm | 73:1efda918f0ba | 266 | /** @defgroup CAN_synchronisation_jump_width |
bogdanm | 73:1efda918f0ba | 267 | * @{ |
bogdanm | 73:1efda918f0ba | 268 | */ |
bogdanm | 73:1efda918f0ba | 269 | |
bogdanm | 73:1efda918f0ba | 270 | #define CAN_SJW_1tq ((uint8_t)0x00) /*!< 1 time quantum */ |
bogdanm | 73:1efda918f0ba | 271 | #define CAN_SJW_2tq ((uint8_t)0x01) /*!< 2 time quantum */ |
bogdanm | 73:1efda918f0ba | 272 | #define CAN_SJW_3tq ((uint8_t)0x02) /*!< 3 time quantum */ |
bogdanm | 73:1efda918f0ba | 273 | #define CAN_SJW_4tq ((uint8_t)0x03) /*!< 4 time quantum */ |
bogdanm | 73:1efda918f0ba | 274 | |
bogdanm | 73:1efda918f0ba | 275 | #define IS_CAN_SJW(SJW) (((SJW) == CAN_SJW_1tq) || ((SJW) == CAN_SJW_2tq)|| \ |
bogdanm | 73:1efda918f0ba | 276 | ((SJW) == CAN_SJW_3tq) || ((SJW) == CAN_SJW_4tq)) |
bogdanm | 73:1efda918f0ba | 277 | /** |
bogdanm | 73:1efda918f0ba | 278 | * @} |
bogdanm | 73:1efda918f0ba | 279 | */ |
bogdanm | 73:1efda918f0ba | 280 | |
bogdanm | 73:1efda918f0ba | 281 | /** @defgroup CAN_time_quantum_in_bit_segment_1 |
bogdanm | 73:1efda918f0ba | 282 | * @{ |
bogdanm | 73:1efda918f0ba | 283 | */ |
bogdanm | 73:1efda918f0ba | 284 | |
bogdanm | 73:1efda918f0ba | 285 | #define CAN_BS1_1tq ((uint8_t)0x00) /*!< 1 time quantum */ |
bogdanm | 73:1efda918f0ba | 286 | #define CAN_BS1_2tq ((uint8_t)0x01) /*!< 2 time quantum */ |
bogdanm | 73:1efda918f0ba | 287 | #define CAN_BS1_3tq ((uint8_t)0x02) /*!< 3 time quantum */ |
bogdanm | 73:1efda918f0ba | 288 | #define CAN_BS1_4tq ((uint8_t)0x03) /*!< 4 time quantum */ |
bogdanm | 73:1efda918f0ba | 289 | #define CAN_BS1_5tq ((uint8_t)0x04) /*!< 5 time quantum */ |
bogdanm | 73:1efda918f0ba | 290 | #define CAN_BS1_6tq ((uint8_t)0x05) /*!< 6 time quantum */ |
bogdanm | 73:1efda918f0ba | 291 | #define CAN_BS1_7tq ((uint8_t)0x06) /*!< 7 time quantum */ |
bogdanm | 73:1efda918f0ba | 292 | #define CAN_BS1_8tq ((uint8_t)0x07) /*!< 8 time quantum */ |
bogdanm | 73:1efda918f0ba | 293 | #define CAN_BS1_9tq ((uint8_t)0x08) /*!< 9 time quantum */ |
bogdanm | 73:1efda918f0ba | 294 | #define CAN_BS1_10tq ((uint8_t)0x09) /*!< 10 time quantum */ |
bogdanm | 73:1efda918f0ba | 295 | #define CAN_BS1_11tq ((uint8_t)0x0A) /*!< 11 time quantum */ |
bogdanm | 73:1efda918f0ba | 296 | #define CAN_BS1_12tq ((uint8_t)0x0B) /*!< 12 time quantum */ |
bogdanm | 73:1efda918f0ba | 297 | #define CAN_BS1_13tq ((uint8_t)0x0C) /*!< 13 time quantum */ |
bogdanm | 73:1efda918f0ba | 298 | #define CAN_BS1_14tq ((uint8_t)0x0D) /*!< 14 time quantum */ |
bogdanm | 73:1efda918f0ba | 299 | #define CAN_BS1_15tq ((uint8_t)0x0E) /*!< 15 time quantum */ |
bogdanm | 73:1efda918f0ba | 300 | #define CAN_BS1_16tq ((uint8_t)0x0F) /*!< 16 time quantum */ |
bogdanm | 73:1efda918f0ba | 301 | |
bogdanm | 73:1efda918f0ba | 302 | #define IS_CAN_BS1(BS1) ((BS1) <= CAN_BS1_16tq) |
bogdanm | 73:1efda918f0ba | 303 | /** |
bogdanm | 73:1efda918f0ba | 304 | * @} |
bogdanm | 73:1efda918f0ba | 305 | */ |
bogdanm | 73:1efda918f0ba | 306 | |
bogdanm | 73:1efda918f0ba | 307 | /** @defgroup CAN_time_quantum_in_bit_segment_2 |
bogdanm | 73:1efda918f0ba | 308 | * @{ |
bogdanm | 73:1efda918f0ba | 309 | */ |
bogdanm | 73:1efda918f0ba | 310 | |
bogdanm | 73:1efda918f0ba | 311 | #define CAN_BS2_1tq ((uint8_t)0x00) /*!< 1 time quantum */ |
bogdanm | 73:1efda918f0ba | 312 | #define CAN_BS2_2tq ((uint8_t)0x01) /*!< 2 time quantum */ |
bogdanm | 73:1efda918f0ba | 313 | #define CAN_BS2_3tq ((uint8_t)0x02) /*!< 3 time quantum */ |
bogdanm | 73:1efda918f0ba | 314 | #define CAN_BS2_4tq ((uint8_t)0x03) /*!< 4 time quantum */ |
bogdanm | 73:1efda918f0ba | 315 | #define CAN_BS2_5tq ((uint8_t)0x04) /*!< 5 time quantum */ |
bogdanm | 73:1efda918f0ba | 316 | #define CAN_BS2_6tq ((uint8_t)0x05) /*!< 6 time quantum */ |
bogdanm | 73:1efda918f0ba | 317 | #define CAN_BS2_7tq ((uint8_t)0x06) /*!< 7 time quantum */ |
bogdanm | 73:1efda918f0ba | 318 | #define CAN_BS2_8tq ((uint8_t)0x07) /*!< 8 time quantum */ |
bogdanm | 73:1efda918f0ba | 319 | |
bogdanm | 73:1efda918f0ba | 320 | #define IS_CAN_BS2(BS2) ((BS2) <= CAN_BS2_8tq) |
bogdanm | 73:1efda918f0ba | 321 | |
bogdanm | 73:1efda918f0ba | 322 | /** |
bogdanm | 73:1efda918f0ba | 323 | * @} |
bogdanm | 73:1efda918f0ba | 324 | */ |
bogdanm | 73:1efda918f0ba | 325 | |
bogdanm | 73:1efda918f0ba | 326 | /** @defgroup CAN_clock_prescaler |
bogdanm | 73:1efda918f0ba | 327 | * @{ |
bogdanm | 73:1efda918f0ba | 328 | */ |
bogdanm | 73:1efda918f0ba | 329 | |
bogdanm | 73:1efda918f0ba | 330 | #define IS_CAN_PRESCALER(PRESCALER) (((PRESCALER) >= 1) && ((PRESCALER) <= 1024)) |
bogdanm | 73:1efda918f0ba | 331 | |
bogdanm | 73:1efda918f0ba | 332 | /** |
bogdanm | 73:1efda918f0ba | 333 | * @} |
bogdanm | 73:1efda918f0ba | 334 | */ |
bogdanm | 73:1efda918f0ba | 335 | |
bogdanm | 73:1efda918f0ba | 336 | /** @defgroup CAN_filter_number |
bogdanm | 73:1efda918f0ba | 337 | * @{ |
bogdanm | 73:1efda918f0ba | 338 | */ |
bogdanm | 73:1efda918f0ba | 339 | #ifndef STM32F10X_CL |
bogdanm | 73:1efda918f0ba | 340 | #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 13) |
bogdanm | 73:1efda918f0ba | 341 | #else |
bogdanm | 73:1efda918f0ba | 342 | #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 27) |
bogdanm | 73:1efda918f0ba | 343 | #endif /* STM32F10X_CL */ |
bogdanm | 73:1efda918f0ba | 344 | /** |
bogdanm | 73:1efda918f0ba | 345 | * @} |
bogdanm | 73:1efda918f0ba | 346 | */ |
bogdanm | 73:1efda918f0ba | 347 | |
bogdanm | 73:1efda918f0ba | 348 | /** @defgroup CAN_filter_mode |
bogdanm | 73:1efda918f0ba | 349 | * @{ |
bogdanm | 73:1efda918f0ba | 350 | */ |
bogdanm | 73:1efda918f0ba | 351 | |
bogdanm | 73:1efda918f0ba | 352 | #define CAN_FilterMode_IdMask ((uint8_t)0x00) /*!< identifier/mask mode */ |
bogdanm | 73:1efda918f0ba | 353 | #define CAN_FilterMode_IdList ((uint8_t)0x01) /*!< identifier list mode */ |
bogdanm | 73:1efda918f0ba | 354 | |
bogdanm | 73:1efda918f0ba | 355 | #define IS_CAN_FILTER_MODE(MODE) (((MODE) == CAN_FilterMode_IdMask) || \ |
bogdanm | 73:1efda918f0ba | 356 | ((MODE) == CAN_FilterMode_IdList)) |
bogdanm | 73:1efda918f0ba | 357 | /** |
bogdanm | 73:1efda918f0ba | 358 | * @} |
bogdanm | 73:1efda918f0ba | 359 | */ |
bogdanm | 73:1efda918f0ba | 360 | |
bogdanm | 73:1efda918f0ba | 361 | /** @defgroup CAN_filter_scale |
bogdanm | 73:1efda918f0ba | 362 | * @{ |
bogdanm | 73:1efda918f0ba | 363 | */ |
bogdanm | 73:1efda918f0ba | 364 | |
bogdanm | 73:1efda918f0ba | 365 | #define CAN_FilterScale_16bit ((uint8_t)0x00) /*!< Two 16-bit filters */ |
bogdanm | 73:1efda918f0ba | 366 | #define CAN_FilterScale_32bit ((uint8_t)0x01) /*!< One 32-bit filter */ |
bogdanm | 73:1efda918f0ba | 367 | |
bogdanm | 73:1efda918f0ba | 368 | #define IS_CAN_FILTER_SCALE(SCALE) (((SCALE) == CAN_FilterScale_16bit) || \ |
bogdanm | 73:1efda918f0ba | 369 | ((SCALE) == CAN_FilterScale_32bit)) |
bogdanm | 73:1efda918f0ba | 370 | |
bogdanm | 73:1efda918f0ba | 371 | /** |
bogdanm | 73:1efda918f0ba | 372 | * @} |
bogdanm | 73:1efda918f0ba | 373 | */ |
bogdanm | 73:1efda918f0ba | 374 | |
bogdanm | 73:1efda918f0ba | 375 | /** @defgroup CAN_filter_FIFO |
bogdanm | 73:1efda918f0ba | 376 | * @{ |
bogdanm | 73:1efda918f0ba | 377 | */ |
bogdanm | 73:1efda918f0ba | 378 | |
bogdanm | 73:1efda918f0ba | 379 | #define CAN_Filter_FIFO0 ((uint8_t)0x00) /*!< Filter FIFO 0 assignment for filter x */ |
bogdanm | 73:1efda918f0ba | 380 | #define CAN_Filter_FIFO1 ((uint8_t)0x01) /*!< Filter FIFO 1 assignment for filter x */ |
bogdanm | 73:1efda918f0ba | 381 | #define IS_CAN_FILTER_FIFO(FIFO) (((FIFO) == CAN_FilterFIFO0) || \ |
bogdanm | 73:1efda918f0ba | 382 | ((FIFO) == CAN_FilterFIFO1)) |
bogdanm | 73:1efda918f0ba | 383 | /** |
bogdanm | 73:1efda918f0ba | 384 | * @} |
bogdanm | 73:1efda918f0ba | 385 | */ |
bogdanm | 73:1efda918f0ba | 386 | |
bogdanm | 73:1efda918f0ba | 387 | /** @defgroup Start_bank_filter_for_slave_CAN |
bogdanm | 73:1efda918f0ba | 388 | * @{ |
bogdanm | 73:1efda918f0ba | 389 | */ |
bogdanm | 73:1efda918f0ba | 390 | #define IS_CAN_BANKNUMBER(BANKNUMBER) (((BANKNUMBER) >= 1) && ((BANKNUMBER) <= 27)) |
bogdanm | 73:1efda918f0ba | 391 | /** |
bogdanm | 73:1efda918f0ba | 392 | * @} |
bogdanm | 73:1efda918f0ba | 393 | */ |
bogdanm | 73:1efda918f0ba | 394 | |
bogdanm | 73:1efda918f0ba | 395 | /** @defgroup CAN_Tx |
bogdanm | 73:1efda918f0ba | 396 | * @{ |
bogdanm | 73:1efda918f0ba | 397 | */ |
bogdanm | 73:1efda918f0ba | 398 | |
bogdanm | 73:1efda918f0ba | 399 | #define IS_CAN_TRANSMITMAILBOX(TRANSMITMAILBOX) ((TRANSMITMAILBOX) <= ((uint8_t)0x02)) |
bogdanm | 73:1efda918f0ba | 400 | #define IS_CAN_STDID(STDID) ((STDID) <= ((uint32_t)0x7FF)) |
bogdanm | 73:1efda918f0ba | 401 | #define IS_CAN_EXTID(EXTID) ((EXTID) <= ((uint32_t)0x1FFFFFFF)) |
bogdanm | 73:1efda918f0ba | 402 | #define IS_CAN_DLC(DLC) ((DLC) <= ((uint8_t)0x08)) |
bogdanm | 73:1efda918f0ba | 403 | |
bogdanm | 73:1efda918f0ba | 404 | /** |
bogdanm | 73:1efda918f0ba | 405 | * @} |
bogdanm | 73:1efda918f0ba | 406 | */ |
bogdanm | 73:1efda918f0ba | 407 | |
bogdanm | 73:1efda918f0ba | 408 | /** @defgroup CAN_identifier_type |
bogdanm | 73:1efda918f0ba | 409 | * @{ |
bogdanm | 73:1efda918f0ba | 410 | */ |
bogdanm | 73:1efda918f0ba | 411 | |
bogdanm | 73:1efda918f0ba | 412 | #define CAN_Id_Standard ((uint32_t)0x00000000) /*!< Standard Id */ |
bogdanm | 73:1efda918f0ba | 413 | #define CAN_Id_Extended ((uint32_t)0x00000004) /*!< Extended Id */ |
bogdanm | 73:1efda918f0ba | 414 | #define IS_CAN_IDTYPE(IDTYPE) (((IDTYPE) == CAN_Id_Standard) || \ |
bogdanm | 73:1efda918f0ba | 415 | ((IDTYPE) == CAN_Id_Extended)) |
bogdanm | 73:1efda918f0ba | 416 | /** |
bogdanm | 73:1efda918f0ba | 417 | * @} |
bogdanm | 73:1efda918f0ba | 418 | */ |
bogdanm | 73:1efda918f0ba | 419 | |
bogdanm | 73:1efda918f0ba | 420 | /** @defgroup CAN_remote_transmission_request |
bogdanm | 73:1efda918f0ba | 421 | * @{ |
bogdanm | 73:1efda918f0ba | 422 | */ |
bogdanm | 73:1efda918f0ba | 423 | |
bogdanm | 73:1efda918f0ba | 424 | #define CAN_RTR_Data ((uint32_t)0x00000000) /*!< Data frame */ |
bogdanm | 73:1efda918f0ba | 425 | #define CAN_RTR_Remote ((uint32_t)0x00000002) /*!< Remote frame */ |
bogdanm | 73:1efda918f0ba | 426 | #define IS_CAN_RTR(RTR) (((RTR) == CAN_RTR_Data) || ((RTR) == CAN_RTR_Remote)) |
bogdanm | 73:1efda918f0ba | 427 | |
bogdanm | 73:1efda918f0ba | 428 | /** |
bogdanm | 73:1efda918f0ba | 429 | * @} |
bogdanm | 73:1efda918f0ba | 430 | */ |
bogdanm | 73:1efda918f0ba | 431 | |
bogdanm | 73:1efda918f0ba | 432 | /** @defgroup CAN_transmit_constants |
bogdanm | 73:1efda918f0ba | 433 | * @{ |
bogdanm | 73:1efda918f0ba | 434 | */ |
bogdanm | 73:1efda918f0ba | 435 | |
bogdanm | 73:1efda918f0ba | 436 | #define CAN_TxStatus_Failed ((uint8_t)0x00)/*!< CAN transmission failed */ |
bogdanm | 73:1efda918f0ba | 437 | #define CAN_TxStatus_Ok ((uint8_t)0x01) /*!< CAN transmission succeeded */ |
bogdanm | 73:1efda918f0ba | 438 | #define CAN_TxStatus_Pending ((uint8_t)0x02) /*!< CAN transmission pending */ |
bogdanm | 73:1efda918f0ba | 439 | #define CAN_TxStatus_NoMailBox ((uint8_t)0x04) /*!< CAN cell did not provide an empty mailbox */ |
bogdanm | 73:1efda918f0ba | 440 | |
bogdanm | 73:1efda918f0ba | 441 | /** |
bogdanm | 73:1efda918f0ba | 442 | * @} |
bogdanm | 73:1efda918f0ba | 443 | */ |
bogdanm | 73:1efda918f0ba | 444 | |
bogdanm | 73:1efda918f0ba | 445 | /** @defgroup CAN_receive_FIFO_number_constants |
bogdanm | 73:1efda918f0ba | 446 | * @{ |
bogdanm | 73:1efda918f0ba | 447 | */ |
bogdanm | 73:1efda918f0ba | 448 | |
bogdanm | 73:1efda918f0ba | 449 | #define CAN_FIFO0 ((uint8_t)0x00) /*!< CAN FIFO 0 used to receive */ |
bogdanm | 73:1efda918f0ba | 450 | #define CAN_FIFO1 ((uint8_t)0x01) /*!< CAN FIFO 1 used to receive */ |
bogdanm | 73:1efda918f0ba | 451 | |
bogdanm | 73:1efda918f0ba | 452 | #define IS_CAN_FIFO(FIFO) (((FIFO) == CAN_FIFO0) || ((FIFO) == CAN_FIFO1)) |
bogdanm | 73:1efda918f0ba | 453 | |
bogdanm | 73:1efda918f0ba | 454 | /** |
bogdanm | 73:1efda918f0ba | 455 | * @} |
bogdanm | 73:1efda918f0ba | 456 | */ |
bogdanm | 73:1efda918f0ba | 457 | |
bogdanm | 73:1efda918f0ba | 458 | /** @defgroup CAN_sleep_constants |
bogdanm | 73:1efda918f0ba | 459 | * @{ |
bogdanm | 73:1efda918f0ba | 460 | */ |
bogdanm | 73:1efda918f0ba | 461 | |
bogdanm | 73:1efda918f0ba | 462 | #define CAN_Sleep_Failed ((uint8_t)0x00) /*!< CAN did not enter the sleep mode */ |
bogdanm | 73:1efda918f0ba | 463 | #define CAN_Sleep_Ok ((uint8_t)0x01) /*!< CAN entered the sleep mode */ |
bogdanm | 73:1efda918f0ba | 464 | |
bogdanm | 73:1efda918f0ba | 465 | /** |
bogdanm | 73:1efda918f0ba | 466 | * @} |
bogdanm | 73:1efda918f0ba | 467 | */ |
bogdanm | 73:1efda918f0ba | 468 | |
bogdanm | 73:1efda918f0ba | 469 | /** @defgroup CAN_wake_up_constants |
bogdanm | 73:1efda918f0ba | 470 | * @{ |
bogdanm | 73:1efda918f0ba | 471 | */ |
bogdanm | 73:1efda918f0ba | 472 | |
bogdanm | 73:1efda918f0ba | 473 | #define CAN_WakeUp_Failed ((uint8_t)0x00) /*!< CAN did not leave the sleep mode */ |
bogdanm | 73:1efda918f0ba | 474 | #define CAN_WakeUp_Ok ((uint8_t)0x01) /*!< CAN leaved the sleep mode */ |
bogdanm | 73:1efda918f0ba | 475 | |
bogdanm | 73:1efda918f0ba | 476 | /** |
bogdanm | 73:1efda918f0ba | 477 | * @} |
bogdanm | 73:1efda918f0ba | 478 | */ |
bogdanm | 73:1efda918f0ba | 479 | |
bogdanm | 73:1efda918f0ba | 480 | /** |
bogdanm | 73:1efda918f0ba | 481 | * @defgroup CAN_Error_Code_constants |
bogdanm | 73:1efda918f0ba | 482 | * @{ |
bogdanm | 73:1efda918f0ba | 483 | */ |
bogdanm | 73:1efda918f0ba | 484 | |
bogdanm | 73:1efda918f0ba | 485 | #define CAN_ErrorCode_NoErr ((uint8_t)0x00) /*!< No Error */ |
bogdanm | 73:1efda918f0ba | 486 | #define CAN_ErrorCode_StuffErr ((uint8_t)0x10) /*!< Stuff Error */ |
bogdanm | 73:1efda918f0ba | 487 | #define CAN_ErrorCode_FormErr ((uint8_t)0x20) /*!< Form Error */ |
bogdanm | 73:1efda918f0ba | 488 | #define CAN_ErrorCode_ACKErr ((uint8_t)0x30) /*!< Acknowledgment Error */ |
bogdanm | 73:1efda918f0ba | 489 | #define CAN_ErrorCode_BitRecessiveErr ((uint8_t)0x40) /*!< Bit Recessive Error */ |
bogdanm | 73:1efda918f0ba | 490 | #define CAN_ErrorCode_BitDominantErr ((uint8_t)0x50) /*!< Bit Dominant Error */ |
bogdanm | 73:1efda918f0ba | 491 | #define CAN_ErrorCode_CRCErr ((uint8_t)0x60) /*!< CRC Error */ |
bogdanm | 73:1efda918f0ba | 492 | #define CAN_ErrorCode_SoftwareSetErr ((uint8_t)0x70) /*!< Software Set Error */ |
bogdanm | 73:1efda918f0ba | 493 | |
bogdanm | 73:1efda918f0ba | 494 | |
bogdanm | 73:1efda918f0ba | 495 | /** |
bogdanm | 73:1efda918f0ba | 496 | * @} |
bogdanm | 73:1efda918f0ba | 497 | */ |
bogdanm | 73:1efda918f0ba | 498 | |
bogdanm | 73:1efda918f0ba | 499 | /** @defgroup CAN_flags |
bogdanm | 73:1efda918f0ba | 500 | * @{ |
bogdanm | 73:1efda918f0ba | 501 | */ |
bogdanm | 73:1efda918f0ba | 502 | /* If the flag is 0x3XXXXXXX, it means that it can be used with CAN_GetFlagStatus() |
bogdanm | 73:1efda918f0ba | 503 | and CAN_ClearFlag() functions. */ |
bogdanm | 73:1efda918f0ba | 504 | /* If the flag is 0x1XXXXXXX, it means that it can only be used with CAN_GetFlagStatus() function. */ |
bogdanm | 73:1efda918f0ba | 505 | |
bogdanm | 73:1efda918f0ba | 506 | /* Transmit Flags */ |
bogdanm | 73:1efda918f0ba | 507 | #define CAN_FLAG_RQCP0 ((uint32_t)0x38000001) /*!< Request MailBox0 Flag */ |
bogdanm | 73:1efda918f0ba | 508 | #define CAN_FLAG_RQCP1 ((uint32_t)0x38000100) /*!< Request MailBox1 Flag */ |
bogdanm | 73:1efda918f0ba | 509 | #define CAN_FLAG_RQCP2 ((uint32_t)0x38010000) /*!< Request MailBox2 Flag */ |
bogdanm | 73:1efda918f0ba | 510 | |
bogdanm | 73:1efda918f0ba | 511 | /* Receive Flags */ |
bogdanm | 73:1efda918f0ba | 512 | #define CAN_FLAG_FMP0 ((uint32_t)0x12000003) /*!< FIFO 0 Message Pending Flag */ |
bogdanm | 73:1efda918f0ba | 513 | #define CAN_FLAG_FF0 ((uint32_t)0x32000008) /*!< FIFO 0 Full Flag */ |
bogdanm | 73:1efda918f0ba | 514 | #define CAN_FLAG_FOV0 ((uint32_t)0x32000010) /*!< FIFO 0 Overrun Flag */ |
bogdanm | 73:1efda918f0ba | 515 | #define CAN_FLAG_FMP1 ((uint32_t)0x14000003) /*!< FIFO 1 Message Pending Flag */ |
bogdanm | 73:1efda918f0ba | 516 | #define CAN_FLAG_FF1 ((uint32_t)0x34000008) /*!< FIFO 1 Full Flag */ |
bogdanm | 73:1efda918f0ba | 517 | #define CAN_FLAG_FOV1 ((uint32_t)0x34000010) /*!< FIFO 1 Overrun Flag */ |
bogdanm | 73:1efda918f0ba | 518 | |
bogdanm | 73:1efda918f0ba | 519 | /* Operating Mode Flags */ |
bogdanm | 73:1efda918f0ba | 520 | #define CAN_FLAG_WKU ((uint32_t)0x31000008) /*!< Wake up Flag */ |
bogdanm | 73:1efda918f0ba | 521 | #define CAN_FLAG_SLAK ((uint32_t)0x31000012) /*!< Sleep acknowledge Flag */ |
bogdanm | 73:1efda918f0ba | 522 | /* Note: When SLAK intterupt is disabled (SLKIE=0), no polling on SLAKI is possible. |
bogdanm | 73:1efda918f0ba | 523 | In this case the SLAK bit can be polled.*/ |
bogdanm | 73:1efda918f0ba | 524 | |
bogdanm | 73:1efda918f0ba | 525 | /* Error Flags */ |
bogdanm | 73:1efda918f0ba | 526 | #define CAN_FLAG_EWG ((uint32_t)0x10F00001) /*!< Error Warning Flag */ |
bogdanm | 73:1efda918f0ba | 527 | #define CAN_FLAG_EPV ((uint32_t)0x10F00002) /*!< Error Passive Flag */ |
bogdanm | 73:1efda918f0ba | 528 | #define CAN_FLAG_BOF ((uint32_t)0x10F00004) /*!< Bus-Off Flag */ |
bogdanm | 73:1efda918f0ba | 529 | #define CAN_FLAG_LEC ((uint32_t)0x30F00070) /*!< Last error code Flag */ |
bogdanm | 73:1efda918f0ba | 530 | |
bogdanm | 73:1efda918f0ba | 531 | #define IS_CAN_GET_FLAG(FLAG) (((FLAG) == CAN_FLAG_LEC) || ((FLAG) == CAN_FLAG_BOF) || \ |
bogdanm | 73:1efda918f0ba | 532 | ((FLAG) == CAN_FLAG_EPV) || ((FLAG) == CAN_FLAG_EWG) || \ |
bogdanm | 73:1efda918f0ba | 533 | ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_FOV0) || \ |
bogdanm | 73:1efda918f0ba | 534 | ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_FMP0) || \ |
bogdanm | 73:1efda918f0ba | 535 | ((FLAG) == CAN_FLAG_FOV1) || ((FLAG) == CAN_FLAG_FF1) || \ |
bogdanm | 73:1efda918f0ba | 536 | ((FLAG) == CAN_FLAG_FMP1) || ((FLAG) == CAN_FLAG_RQCP2) || \ |
bogdanm | 73:1efda918f0ba | 537 | ((FLAG) == CAN_FLAG_RQCP1)|| ((FLAG) == CAN_FLAG_RQCP0) || \ |
bogdanm | 73:1efda918f0ba | 538 | ((FLAG) == CAN_FLAG_SLAK )) |
bogdanm | 73:1efda918f0ba | 539 | |
bogdanm | 73:1efda918f0ba | 540 | #define IS_CAN_CLEAR_FLAG(FLAG)(((FLAG) == CAN_FLAG_LEC) || ((FLAG) == CAN_FLAG_RQCP2) || \ |
bogdanm | 73:1efda918f0ba | 541 | ((FLAG) == CAN_FLAG_RQCP1) || ((FLAG) == CAN_FLAG_RQCP0) || \ |
bogdanm | 73:1efda918f0ba | 542 | ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_FOV0) ||\ |
bogdanm | 73:1efda918f0ba | 543 | ((FLAG) == CAN_FLAG_FF1) || ((FLAG) == CAN_FLAG_FOV1) || \ |
bogdanm | 73:1efda918f0ba | 544 | ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_SLAK)) |
bogdanm | 73:1efda918f0ba | 545 | /** |
bogdanm | 73:1efda918f0ba | 546 | * @} |
bogdanm | 73:1efda918f0ba | 547 | */ |
bogdanm | 73:1efda918f0ba | 548 | |
bogdanm | 73:1efda918f0ba | 549 | |
bogdanm | 73:1efda918f0ba | 550 | /** @defgroup CAN_interrupts |
bogdanm | 73:1efda918f0ba | 551 | * @{ |
bogdanm | 73:1efda918f0ba | 552 | */ |
bogdanm | 73:1efda918f0ba | 553 | |
bogdanm | 73:1efda918f0ba | 554 | |
bogdanm | 73:1efda918f0ba | 555 | |
bogdanm | 73:1efda918f0ba | 556 | #define CAN_IT_TME ((uint32_t)0x00000001) /*!< Transmit mailbox empty Interrupt*/ |
bogdanm | 73:1efda918f0ba | 557 | |
bogdanm | 73:1efda918f0ba | 558 | /* Receive Interrupts */ |
bogdanm | 73:1efda918f0ba | 559 | #define CAN_IT_FMP0 ((uint32_t)0x00000002) /*!< FIFO 0 message pending Interrupt*/ |
bogdanm | 73:1efda918f0ba | 560 | #define CAN_IT_FF0 ((uint32_t)0x00000004) /*!< FIFO 0 full Interrupt*/ |
bogdanm | 73:1efda918f0ba | 561 | #define CAN_IT_FOV0 ((uint32_t)0x00000008) /*!< FIFO 0 overrun Interrupt*/ |
bogdanm | 73:1efda918f0ba | 562 | #define CAN_IT_FMP1 ((uint32_t)0x00000010) /*!< FIFO 1 message pending Interrupt*/ |
bogdanm | 73:1efda918f0ba | 563 | #define CAN_IT_FF1 ((uint32_t)0x00000020) /*!< FIFO 1 full Interrupt*/ |
bogdanm | 73:1efda918f0ba | 564 | #define CAN_IT_FOV1 ((uint32_t)0x00000040) /*!< FIFO 1 overrun Interrupt*/ |
bogdanm | 73:1efda918f0ba | 565 | |
bogdanm | 73:1efda918f0ba | 566 | /* Operating Mode Interrupts */ |
bogdanm | 73:1efda918f0ba | 567 | #define CAN_IT_WKU ((uint32_t)0x00010000) /*!< Wake-up Interrupt*/ |
bogdanm | 73:1efda918f0ba | 568 | #define CAN_IT_SLK ((uint32_t)0x00020000) /*!< Sleep acknowledge Interrupt*/ |
bogdanm | 73:1efda918f0ba | 569 | |
bogdanm | 73:1efda918f0ba | 570 | /* Error Interrupts */ |
bogdanm | 73:1efda918f0ba | 571 | #define CAN_IT_EWG ((uint32_t)0x00000100) /*!< Error warning Interrupt*/ |
bogdanm | 73:1efda918f0ba | 572 | #define CAN_IT_EPV ((uint32_t)0x00000200) /*!< Error passive Interrupt*/ |
bogdanm | 73:1efda918f0ba | 573 | #define CAN_IT_BOF ((uint32_t)0x00000400) /*!< Bus-off Interrupt*/ |
bogdanm | 73:1efda918f0ba | 574 | #define CAN_IT_LEC ((uint32_t)0x00000800) /*!< Last error code Interrupt*/ |
bogdanm | 73:1efda918f0ba | 575 | #define CAN_IT_ERR ((uint32_t)0x00008000) /*!< Error Interrupt*/ |
bogdanm | 73:1efda918f0ba | 576 | |
bogdanm | 73:1efda918f0ba | 577 | /* Flags named as Interrupts : kept only for FW compatibility */ |
bogdanm | 73:1efda918f0ba | 578 | #define CAN_IT_RQCP0 CAN_IT_TME |
bogdanm | 73:1efda918f0ba | 579 | #define CAN_IT_RQCP1 CAN_IT_TME |
bogdanm | 73:1efda918f0ba | 580 | #define CAN_IT_RQCP2 CAN_IT_TME |
bogdanm | 73:1efda918f0ba | 581 | |
bogdanm | 73:1efda918f0ba | 582 | |
bogdanm | 73:1efda918f0ba | 583 | #define IS_CAN_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FMP0) ||\ |
bogdanm | 73:1efda918f0ba | 584 | ((IT) == CAN_IT_FF0) || ((IT) == CAN_IT_FOV0) ||\ |
bogdanm | 73:1efda918f0ba | 585 | ((IT) == CAN_IT_FMP1) || ((IT) == CAN_IT_FF1) ||\ |
bogdanm | 73:1efda918f0ba | 586 | ((IT) == CAN_IT_FOV1) || ((IT) == CAN_IT_EWG) ||\ |
bogdanm | 73:1efda918f0ba | 587 | ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\ |
bogdanm | 73:1efda918f0ba | 588 | ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\ |
bogdanm | 73:1efda918f0ba | 589 | ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK)) |
bogdanm | 73:1efda918f0ba | 590 | |
bogdanm | 73:1efda918f0ba | 591 | #define IS_CAN_CLEAR_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FF0) ||\ |
bogdanm | 73:1efda918f0ba | 592 | ((IT) == CAN_IT_FOV0)|| ((IT) == CAN_IT_FF1) ||\ |
bogdanm | 73:1efda918f0ba | 593 | ((IT) == CAN_IT_FOV1)|| ((IT) == CAN_IT_EWG) ||\ |
bogdanm | 73:1efda918f0ba | 594 | ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\ |
bogdanm | 73:1efda918f0ba | 595 | ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\ |
bogdanm | 73:1efda918f0ba | 596 | ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK)) |
bogdanm | 73:1efda918f0ba | 597 | |
bogdanm | 73:1efda918f0ba | 598 | /** |
bogdanm | 73:1efda918f0ba | 599 | * @} |
bogdanm | 73:1efda918f0ba | 600 | */ |
bogdanm | 73:1efda918f0ba | 601 | |
bogdanm | 73:1efda918f0ba | 602 | /** @defgroup CAN_Legacy |
bogdanm | 73:1efda918f0ba | 603 | * @{ |
bogdanm | 73:1efda918f0ba | 604 | */ |
bogdanm | 73:1efda918f0ba | 605 | #define CANINITFAILED CAN_InitStatus_Failed |
bogdanm | 73:1efda918f0ba | 606 | #define CANINITOK CAN_InitStatus_Success |
bogdanm | 73:1efda918f0ba | 607 | #define CAN_FilterFIFO0 CAN_Filter_FIFO0 |
bogdanm | 73:1efda918f0ba | 608 | #define CAN_FilterFIFO1 CAN_Filter_FIFO1 |
bogdanm | 73:1efda918f0ba | 609 | #define CAN_ID_STD CAN_Id_Standard |
bogdanm | 73:1efda918f0ba | 610 | #define CAN_ID_EXT CAN_Id_Extended |
bogdanm | 73:1efda918f0ba | 611 | #define CAN_RTR_DATA CAN_RTR_Data |
bogdanm | 73:1efda918f0ba | 612 | #define CAN_RTR_REMOTE CAN_RTR_Remote |
bogdanm | 73:1efda918f0ba | 613 | #define CANTXFAILE CAN_TxStatus_Failed |
bogdanm | 73:1efda918f0ba | 614 | #define CANTXOK CAN_TxStatus_Ok |
bogdanm | 73:1efda918f0ba | 615 | #define CANTXPENDING CAN_TxStatus_Pending |
bogdanm | 73:1efda918f0ba | 616 | #define CAN_NO_MB CAN_TxStatus_NoMailBox |
bogdanm | 73:1efda918f0ba | 617 | #define CANSLEEPFAILED CAN_Sleep_Failed |
bogdanm | 73:1efda918f0ba | 618 | #define CANSLEEPOK CAN_Sleep_Ok |
bogdanm | 73:1efda918f0ba | 619 | #define CANWAKEUPFAILED CAN_WakeUp_Failed |
bogdanm | 73:1efda918f0ba | 620 | #define CANWAKEUPOK CAN_WakeUp_Ok |
bogdanm | 73:1efda918f0ba | 621 | |
bogdanm | 73:1efda918f0ba | 622 | /** |
bogdanm | 73:1efda918f0ba | 623 | * @} |
bogdanm | 73:1efda918f0ba | 624 | */ |
bogdanm | 73:1efda918f0ba | 625 | |
bogdanm | 73:1efda918f0ba | 626 | /** |
bogdanm | 73:1efda918f0ba | 627 | * @} |
bogdanm | 73:1efda918f0ba | 628 | */ |
bogdanm | 73:1efda918f0ba | 629 | |
bogdanm | 73:1efda918f0ba | 630 | /** @defgroup CAN_Exported_Macros |
bogdanm | 73:1efda918f0ba | 631 | * @{ |
bogdanm | 73:1efda918f0ba | 632 | */ |
bogdanm | 73:1efda918f0ba | 633 | |
bogdanm | 73:1efda918f0ba | 634 | /** |
bogdanm | 73:1efda918f0ba | 635 | * @} |
bogdanm | 73:1efda918f0ba | 636 | */ |
bogdanm | 73:1efda918f0ba | 637 | |
bogdanm | 73:1efda918f0ba | 638 | /** @defgroup CAN_Exported_Functions |
bogdanm | 73:1efda918f0ba | 639 | * @{ |
bogdanm | 73:1efda918f0ba | 640 | */ |
bogdanm | 73:1efda918f0ba | 641 | /* Function used to set the CAN configuration to the default reset state *****/ |
bogdanm | 73:1efda918f0ba | 642 | void CAN_DeInit(CAN_TypeDef* CANx); |
bogdanm | 73:1efda918f0ba | 643 | |
bogdanm | 73:1efda918f0ba | 644 | /* Initialization and Configuration functions *********************************/ |
bogdanm | 73:1efda918f0ba | 645 | uint8_t CAN_Init(CAN_TypeDef* CANx, CAN_InitTypeDef* CAN_InitStruct); |
bogdanm | 73:1efda918f0ba | 646 | void CAN_FilterInit(CAN_FilterInitTypeDef* CAN_FilterInitStruct); |
bogdanm | 73:1efda918f0ba | 647 | void CAN_StructInit(CAN_InitTypeDef* CAN_InitStruct); |
bogdanm | 73:1efda918f0ba | 648 | void CAN_SlaveStartBank(uint8_t CAN_BankNumber); |
bogdanm | 73:1efda918f0ba | 649 | void CAN_DBGFreeze(CAN_TypeDef* CANx, FunctionalState NewState); |
bogdanm | 73:1efda918f0ba | 650 | void CAN_TTComModeCmd(CAN_TypeDef* CANx, FunctionalState NewState); |
bogdanm | 73:1efda918f0ba | 651 | |
bogdanm | 73:1efda918f0ba | 652 | /* Transmit functions *********************************************************/ |
bogdanm | 73:1efda918f0ba | 653 | uint8_t CAN_Transmit(CAN_TypeDef* CANx, CanTxMsg* TxMessage); |
bogdanm | 73:1efda918f0ba | 654 | uint8_t CAN_TransmitStatus(CAN_TypeDef* CANx, uint8_t TransmitMailbox); |
bogdanm | 73:1efda918f0ba | 655 | void CAN_CancelTransmit(CAN_TypeDef* CANx, uint8_t Mailbox); |
bogdanm | 73:1efda918f0ba | 656 | |
bogdanm | 73:1efda918f0ba | 657 | /* Receive functions **********************************************************/ |
bogdanm | 73:1efda918f0ba | 658 | void CAN_Receive(CAN_TypeDef* CANx, uint8_t FIFONumber, CanRxMsg* RxMessage); |
bogdanm | 73:1efda918f0ba | 659 | void CAN_FIFORelease(CAN_TypeDef* CANx, uint8_t FIFONumber); |
bogdanm | 73:1efda918f0ba | 660 | uint8_t CAN_MessagePending(CAN_TypeDef* CANx, uint8_t FIFONumber); |
bogdanm | 73:1efda918f0ba | 661 | |
bogdanm | 73:1efda918f0ba | 662 | |
bogdanm | 73:1efda918f0ba | 663 | /* Operation modes functions **************************************************/ |
bogdanm | 73:1efda918f0ba | 664 | uint8_t CAN_OperatingModeRequest(CAN_TypeDef* CANx, uint8_t CAN_OperatingMode); |
bogdanm | 73:1efda918f0ba | 665 | uint8_t CAN_Sleep(CAN_TypeDef* CANx); |
bogdanm | 73:1efda918f0ba | 666 | uint8_t CAN_WakeUp(CAN_TypeDef* CANx); |
bogdanm | 73:1efda918f0ba | 667 | |
bogdanm | 73:1efda918f0ba | 668 | /* Error management functions *************************************************/ |
bogdanm | 73:1efda918f0ba | 669 | uint8_t CAN_GetLastErrorCode(CAN_TypeDef* CANx); |
bogdanm | 73:1efda918f0ba | 670 | uint8_t CAN_GetReceiveErrorCounter(CAN_TypeDef* CANx); |
bogdanm | 73:1efda918f0ba | 671 | uint8_t CAN_GetLSBTransmitErrorCounter(CAN_TypeDef* CANx); |
bogdanm | 73:1efda918f0ba | 672 | |
bogdanm | 73:1efda918f0ba | 673 | /* Interrupts and flags management functions **********************************/ |
bogdanm | 73:1efda918f0ba | 674 | void CAN_ITConfig(CAN_TypeDef* CANx, uint32_t CAN_IT, FunctionalState NewState); |
bogdanm | 73:1efda918f0ba | 675 | FlagStatus CAN_GetFlagStatus(CAN_TypeDef* CANx, uint32_t CAN_FLAG); |
bogdanm | 73:1efda918f0ba | 676 | void CAN_ClearFlag(CAN_TypeDef* CANx, uint32_t CAN_FLAG); |
bogdanm | 73:1efda918f0ba | 677 | ITStatus CAN_GetITStatus(CAN_TypeDef* CANx, uint32_t CAN_IT); |
bogdanm | 73:1efda918f0ba | 678 | void CAN_ClearITPendingBit(CAN_TypeDef* CANx, uint32_t CAN_IT); |
bogdanm | 73:1efda918f0ba | 679 | |
bogdanm | 73:1efda918f0ba | 680 | #ifdef __cplusplus |
bogdanm | 73:1efda918f0ba | 681 | } |
bogdanm | 73:1efda918f0ba | 682 | #endif |
bogdanm | 73:1efda918f0ba | 683 | |
bogdanm | 73:1efda918f0ba | 684 | #endif /* __STM32F10x_CAN_H */ |
bogdanm | 73:1efda918f0ba | 685 | /** |
bogdanm | 73:1efda918f0ba | 686 | * @} |
bogdanm | 73:1efda918f0ba | 687 | */ |
bogdanm | 73:1efda918f0ba | 688 | |
bogdanm | 73:1efda918f0ba | 689 | /** |
bogdanm | 73:1efda918f0ba | 690 | * @} |
bogdanm | 73:1efda918f0ba | 691 | */ |
bogdanm | 73:1efda918f0ba | 692 | |
bogdanm | 73:1efda918f0ba | 693 | /** |
bogdanm | 73:1efda918f0ba | 694 | * @} |
bogdanm | 73:1efda918f0ba | 695 | */ |
bogdanm | 73:1efda918f0ba | 696 | |
bogdanm | 73:1efda918f0ba | 697 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ |