mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Tue Jan 07 11:00:05 2014 +0000
Revision:
70:c1fbde68b492
Parent:
52:a51c77007319
Child:
84:f54042cbc282
Synchronized with git revision 3f438a307904431f2782db3c8fa49946b9fc1d85

Full URL: https://github.com/mbedmicro/mbed/commit/3f438a307904431f2782db3c8fa49946b9fc1d85/

[NUCLEO_F103RB] license text changed + sleep hal updated

Who changed what in which revision?

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