version_2.0

Dependents:   cc3000_ping_demo_try_2

Fork of mbed by mbed official

Committer:
erezi
Date:
Wed Jun 25 06:08:49 2014 +0000
Revision:
86:4f9a848d74c7
Parent:
81:7d30d6019079
version_2.0

Who changed what in which revision?

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