mbed library with additional peripherals for ST F401 board

Fork of mbed-src by mbed official

This mbed LIB has additional peripherals for ST F401 board

  • UART2 : PA_3 rx, PA_2 tx
  • UART3 : PC_7 rx, PC_6 tx
  • I2C2 : PB_3 SDA, PB_10 SCL
  • I2C3 : PB_4 SDA, PA_8 SCL
Committer:
mbed_official
Date:
Wed Feb 26 09:45:12 2014 +0000
Revision:
106:ced8cbb51063
Parent:
76:aeb1df146756
Synchronized with git revision 4222735eff5868389433f0e9271976b39c8115cd

Full URL: https://github.com/mbedmicro/mbed/commit/4222735eff5868389433f0e9271976b39c8115cd/

[NUCLEO_xxx] Update STM32CubeF4 driver V1.0.0 + update license

Who changed what in which revision?

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