mbed library sources

Dependents:   bare

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Wed Mar 19 10:15:22 2014 +0000
Revision:
125:23cc3068a9e4
Synchronized with git revision ace35dfba3748c7cdc102eb38ec6b9e1067c3252

Full URL: https://github.com/mbedmicro/mbed/commit/ace35dfba3748c7cdc102eb38ec6b9e1067c3252/

[NUCLEO_F302R8] Add cmsis and hal files + change F401RE clock to 84MHz

Who changed what in which revision?

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