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