mbed(SerialHalfDuplex入り)

Fork of mbed by mbed official

Committer:
yusuke_kyo
Date:
Wed Apr 08 08:04:18 2015 +0000
Revision:
98:01a414ca7d6d
Parent:
93:e188a91d3eaa
remove SerialHalfDuplex.h

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 93:e188a91d3eaa 1 /**
Kojto 93:e188a91d3eaa 2 ******************************************************************************
Kojto 93:e188a91d3eaa 3 * @file stm32f3xx_hal_can.h
Kojto 93:e188a91d3eaa 4 * @author MCD Application Team
Kojto 93:e188a91d3eaa 5 * @version V1.1.0
Kojto 93:e188a91d3eaa 6 * @date 12-Sept-2014
Kojto 93:e188a91d3eaa 7 * @brief Header file of CAN HAL module.
Kojto 93:e188a91d3eaa 8 ******************************************************************************
Kojto 93:e188a91d3eaa 9 * @attention
Kojto 93:e188a91d3eaa 10 *
Kojto 93:e188a91d3eaa 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
Kojto 93:e188a91d3eaa 12 *
Kojto 93:e188a91d3eaa 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 93:e188a91d3eaa 14 * are permitted provided that the following conditions are met:
Kojto 93:e188a91d3eaa 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 93:e188a91d3eaa 16 * this list of conditions and the following disclaimer.
Kojto 93:e188a91d3eaa 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 93:e188a91d3eaa 18 * this list of conditions and the following disclaimer in the documentation
Kojto 93:e188a91d3eaa 19 * and/or other materials provided with the distribution.
Kojto 93:e188a91d3eaa 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 93:e188a91d3eaa 21 * may be used to endorse or promote products derived from this software
Kojto 93:e188a91d3eaa 22 * without specific prior written permission.
Kojto 93:e188a91d3eaa 23 *
Kojto 93:e188a91d3eaa 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 93:e188a91d3eaa 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 93:e188a91d3eaa 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 93:e188a91d3eaa 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 93:e188a91d3eaa 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 93:e188a91d3eaa 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 93:e188a91d3eaa 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 93:e188a91d3eaa 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 93:e188a91d3eaa 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 93:e188a91d3eaa 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 93:e188a91d3eaa 34 *
Kojto 93:e188a91d3eaa 35 ******************************************************************************
Kojto 93:e188a91d3eaa 36 */
Kojto 93:e188a91d3eaa 37
Kojto 93:e188a91d3eaa 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 93:e188a91d3eaa 39 #ifndef __STM32F3xx_CAN_H
Kojto 93:e188a91d3eaa 40 #define __STM32F3xx_CAN_H
Kojto 93:e188a91d3eaa 41
Kojto 93:e188a91d3eaa 42 #ifdef __cplusplus
Kojto 93:e188a91d3eaa 43 extern "C" {
Kojto 93:e188a91d3eaa 44 #endif
Kojto 93:e188a91d3eaa 45
Kojto 93:e188a91d3eaa 46 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
Kojto 93:e188a91d3eaa 47 defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
Kojto 93:e188a91d3eaa 48 defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
Kojto 93:e188a91d3eaa 49 defined(STM32F302x8) || \
Kojto 93:e188a91d3eaa 50 defined(STM32F373xC) || defined(STM32F378xx)
Kojto 93:e188a91d3eaa 51
Kojto 93:e188a91d3eaa 52 /* Includes ------------------------------------------------------------------*/
Kojto 93:e188a91d3eaa 53 #include "stm32f3xx_hal_def.h"
Kojto 93:e188a91d3eaa 54
Kojto 93:e188a91d3eaa 55 /** @addtogroup STM32F3xx_HAL_Driver
Kojto 93:e188a91d3eaa 56 * @{
Kojto 93:e188a91d3eaa 57 */
Kojto 93:e188a91d3eaa 58
Kojto 93:e188a91d3eaa 59 /** @addtogroup CAN
Kojto 93:e188a91d3eaa 60 * @{
Kojto 93:e188a91d3eaa 61 */
Kojto 93:e188a91d3eaa 62
Kojto 93:e188a91d3eaa 63 /* Exported types ------------------------------------------------------------*/
Kojto 93:e188a91d3eaa 64 /** @defgroup CAN_Exported_Types CAN Exported Types
Kojto 93:e188a91d3eaa 65 * @{
Kojto 93:e188a91d3eaa 66 */
Kojto 93:e188a91d3eaa 67 /**
Kojto 93:e188a91d3eaa 68 * @brief HAL State structures definition
Kojto 93:e188a91d3eaa 69 */
Kojto 93:e188a91d3eaa 70 typedef enum
Kojto 93:e188a91d3eaa 71 {
Kojto 93:e188a91d3eaa 72 HAL_CAN_STATE_RESET = 0x00, /*!< CAN not yet initialized or disabled */
Kojto 93:e188a91d3eaa 73 HAL_CAN_STATE_READY = 0x01, /*!< CAN initialized and ready for use */
Kojto 93:e188a91d3eaa 74 HAL_CAN_STATE_BUSY = 0x02, /*!< CAN process is ongoing */
Kojto 93:e188a91d3eaa 75 HAL_CAN_STATE_BUSY_TX = 0x12, /*!< CAN process is ongoing */
Kojto 93:e188a91d3eaa 76 HAL_CAN_STATE_BUSY_RX = 0x22, /*!< CAN process is ongoing */
Kojto 93:e188a91d3eaa 77 HAL_CAN_STATE_BUSY_TX_RX = 0x32, /*!< CAN process is ongoing */
Kojto 93:e188a91d3eaa 78 HAL_CAN_STATE_TIMEOUT = 0x03, /*!< CAN in Timeout state */
Kojto 93:e188a91d3eaa 79 HAL_CAN_STATE_ERROR = 0x04 /*!< CAN error state */
Kojto 93:e188a91d3eaa 80
Kojto 93:e188a91d3eaa 81 }HAL_CAN_StateTypeDef;
Kojto 93:e188a91d3eaa 82
Kojto 93:e188a91d3eaa 83 /**
Kojto 93:e188a91d3eaa 84 * @brief HAL CAN Error Code structure definition
Kojto 93:e188a91d3eaa 85 */
Kojto 93:e188a91d3eaa 86 typedef enum
Kojto 93:e188a91d3eaa 87 {
Kojto 93:e188a91d3eaa 88 HAL_CAN_ERROR_NONE = 0x00, /*!< No error */
Kojto 93:e188a91d3eaa 89 HAL_CAN_ERROR_EWG = 0x01, /*!< EWG error */
Kojto 93:e188a91d3eaa 90 HAL_CAN_ERROR_EPV = 0x02, /*!< EPV error */
Kojto 93:e188a91d3eaa 91 HAL_CAN_ERROR_BOF = 0x04, /*!< BOF error */
Kojto 93:e188a91d3eaa 92 HAL_CAN_ERROR_STF = 0x08, /*!< Stuff error */
Kojto 93:e188a91d3eaa 93 HAL_CAN_ERROR_FOR = 0x10, /*!< Form error */
Kojto 93:e188a91d3eaa 94 HAL_CAN_ERROR_ACK = 0x20, /*!< Acknowledgment error */
Kojto 93:e188a91d3eaa 95 HAL_CAN_ERROR_BR = 0x40, /*!< Bit recessive */
Kojto 93:e188a91d3eaa 96 HAL_CAN_ERROR_BD = 0x80, /*!< LEC dominant */
Kojto 93:e188a91d3eaa 97 HAL_CAN_ERROR_CRC = 0x100 /*!< LEC transfer error */
Kojto 93:e188a91d3eaa 98 }HAL_CAN_ErrorTypeDef;
Kojto 93:e188a91d3eaa 99
Kojto 93:e188a91d3eaa 100 /**
Kojto 93:e188a91d3eaa 101 * @brief CAN init structure definition
Kojto 93:e188a91d3eaa 102 */
Kojto 93:e188a91d3eaa 103 typedef struct
Kojto 93:e188a91d3eaa 104 {
Kojto 93:e188a91d3eaa 105 uint32_t Prescaler; /*!< Specifies the length of a time quantum.
Kojto 93:e188a91d3eaa 106 This parameter must be a number between Min_Data = 1 and Max_Data = 1024. */
Kojto 93:e188a91d3eaa 107
Kojto 93:e188a91d3eaa 108 uint32_t Mode; /*!< Specifies the CAN operating mode.
Kojto 93:e188a91d3eaa 109 This parameter can be a value of @ref CAN_operating_mode */
Kojto 93:e188a91d3eaa 110
Kojto 93:e188a91d3eaa 111 uint32_t SJW; /*!< Specifies the maximum number of time quanta
Kojto 93:e188a91d3eaa 112 the CAN hardware is allowed to lengthen or
Kojto 93:e188a91d3eaa 113 shorten a bit to perform resynchronization.
Kojto 93:e188a91d3eaa 114 This parameter can be a value of @ref CAN_synchronisation_jump_width */
Kojto 93:e188a91d3eaa 115
Kojto 93:e188a91d3eaa 116 uint32_t BS1; /*!< Specifies the number of time quanta in Bit Segment 1.
Kojto 93:e188a91d3eaa 117 This parameter can be a value of @ref CAN_time_quantum_in_bit_segment_1 */
Kojto 93:e188a91d3eaa 118
Kojto 93:e188a91d3eaa 119 uint32_t BS2; /*!< Specifies the number of time quanta in Bit Segment 2.
Kojto 93:e188a91d3eaa 120 This parameter can be a value of @ref CAN_time_quantum_in_bit_segment_2 */
Kojto 93:e188a91d3eaa 121
Kojto 93:e188a91d3eaa 122 uint32_t TTCM; /*!< Enable or disable the time triggered communication mode.
Kojto 93:e188a91d3eaa 123 This parameter can be set to ENABLE or DISABLE. */
Kojto 93:e188a91d3eaa 124
Kojto 93:e188a91d3eaa 125 uint32_t ABOM; /*!< Enable or disable the automatic bus-off management.
Kojto 93:e188a91d3eaa 126 This parameter can be set to ENABLE or DISABLE. */
Kojto 93:e188a91d3eaa 127
Kojto 93:e188a91d3eaa 128 uint32_t AWUM; /*!< Enable or disable the automatic wake-up mode.
Kojto 93:e188a91d3eaa 129 This parameter can be set to ENABLE or DISABLE. */
Kojto 93:e188a91d3eaa 130
Kojto 93:e188a91d3eaa 131 uint32_t NART; /*!< Enable or disable the non-automatic retransmission mode.
Kojto 93:e188a91d3eaa 132 This parameter can be set to ENABLE or DISABLE. */
Kojto 93:e188a91d3eaa 133
Kojto 93:e188a91d3eaa 134 uint32_t RFLM; /*!< Enable or disable the Receive FIFO Locked mode.
Kojto 93:e188a91d3eaa 135 This parameter can be set to ENABLE or DISABLE. */
Kojto 93:e188a91d3eaa 136
Kojto 93:e188a91d3eaa 137 uint32_t TXFP; /*!< Enable or disable the transmit FIFO priority.
Kojto 93:e188a91d3eaa 138 This parameter can be set to ENABLE or DISABLE. */
Kojto 93:e188a91d3eaa 139 }CAN_InitTypeDef;
Kojto 93:e188a91d3eaa 140
Kojto 93:e188a91d3eaa 141 /**
Kojto 93:e188a91d3eaa 142 * @brief CAN filter configuration structure definition
Kojto 93:e188a91d3eaa 143 */
Kojto 93:e188a91d3eaa 144 typedef struct
Kojto 93:e188a91d3eaa 145 {
Kojto 93:e188a91d3eaa 146 uint32_t FilterIdHigh; /*!< Specifies the filter identification number (MSBs for a 32-bit
Kojto 93:e188a91d3eaa 147 configuration, first one for a 16-bit configuration).
Kojto 93:e188a91d3eaa 148 This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */
Kojto 93:e188a91d3eaa 149
Kojto 93:e188a91d3eaa 150 uint32_t FilterIdLow; /*!< Specifies the filter identification number (LSBs for a 32-bit
Kojto 93:e188a91d3eaa 151 configuration, second one for a 16-bit configuration).
Kojto 93:e188a91d3eaa 152 This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */
Kojto 93:e188a91d3eaa 153
Kojto 93:e188a91d3eaa 154 uint32_t FilterMaskIdHigh; /*!< Specifies the filter mask number or identification number,
Kojto 93:e188a91d3eaa 155 according to the mode (MSBs for a 32-bit configuration,
Kojto 93:e188a91d3eaa 156 first one for a 16-bit configuration).
Kojto 93:e188a91d3eaa 157 This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */
Kojto 93:e188a91d3eaa 158
Kojto 93:e188a91d3eaa 159 uint32_t FilterMaskIdLow; /*!< Specifies the filter mask number or identification number,
Kojto 93:e188a91d3eaa 160 according to the mode (LSBs for a 32-bit configuration,
Kojto 93:e188a91d3eaa 161 second one for a 16-bit configuration).
Kojto 93:e188a91d3eaa 162 This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0xFFFF. */
Kojto 93:e188a91d3eaa 163
Kojto 93:e188a91d3eaa 164 uint32_t FilterFIFOAssignment; /*!< Specifies the FIFO (0 or 1) which will be assigned to the filter.
Kojto 93:e188a91d3eaa 165 This parameter can be a value of @ref CAN_filter_FIFO */
Kojto 93:e188a91d3eaa 166
Kojto 93:e188a91d3eaa 167 uint32_t FilterNumber; /*!< Specifies the filter which will be initialized.
Kojto 93:e188a91d3eaa 168 This parameter must be a number between Min_Data = 0 and Max_Data = 27. */
Kojto 93:e188a91d3eaa 169
Kojto 93:e188a91d3eaa 170 uint32_t FilterMode; /*!< Specifies the filter mode to be initialized.
Kojto 93:e188a91d3eaa 171 This parameter can be a value of @ref CAN_filter_mode */
Kojto 93:e188a91d3eaa 172
Kojto 93:e188a91d3eaa 173 uint32_t FilterScale; /*!< Specifies the filter scale.
Kojto 93:e188a91d3eaa 174 This parameter can be a value of @ref CAN_filter_scale */
Kojto 93:e188a91d3eaa 175
Kojto 93:e188a91d3eaa 176 uint32_t FilterActivation; /*!< Enable or disable the filter.
Kojto 93:e188a91d3eaa 177 This parameter can be set to ENABLE or DISABLE. */
Kojto 93:e188a91d3eaa 178
Kojto 93:e188a91d3eaa 179 uint32_t BankNumber; /*!< Select the start slave bank filter
Kojto 93:e188a91d3eaa 180 This parameter must be a number between Min_Data = 0 and Max_Data = 28. */
Kojto 93:e188a91d3eaa 181
Kojto 93:e188a91d3eaa 182 }CAN_FilterConfTypeDef;
Kojto 93:e188a91d3eaa 183
Kojto 93:e188a91d3eaa 184 /**
Kojto 93:e188a91d3eaa 185 * @brief CAN Tx message structure definition
Kojto 93:e188a91d3eaa 186 */
Kojto 93:e188a91d3eaa 187 typedef struct
Kojto 93:e188a91d3eaa 188 {
Kojto 93:e188a91d3eaa 189 uint32_t StdId; /*!< Specifies the standard identifier.
Kojto 93:e188a91d3eaa 190 This parameter must be a number between Min_Data = 0 and Max_Data = 0x7FF. */
Kojto 93:e188a91d3eaa 191
Kojto 93:e188a91d3eaa 192 uint32_t ExtId; /*!< Specifies the extended identifier.
Kojto 93:e188a91d3eaa 193 This parameter must be a number between Min_Data = 0 and Max_Data = 0x1FFFFFFF. */
Kojto 93:e188a91d3eaa 194
Kojto 93:e188a91d3eaa 195 uint32_t IDE; /*!< Specifies the type of identifier for the message that will be transmitted.
Kojto 93:e188a91d3eaa 196 This parameter can be a value of @ref CAN_identifier_type */
Kojto 93:e188a91d3eaa 197
Kojto 93:e188a91d3eaa 198 uint32_t RTR; /*!< Specifies the type of frame for the message that will be transmitted.
Kojto 93:e188a91d3eaa 199 This parameter can be a value of @ref CAN_remote_transmission_request */
Kojto 93:e188a91d3eaa 200
Kojto 93:e188a91d3eaa 201 uint32_t DLC; /*!< Specifies the length of the frame that will be transmitted.
Kojto 93:e188a91d3eaa 202 This parameter must be a number between Min_Data = 0 and Max_Data = 8. */
Kojto 93:e188a91d3eaa 203
Kojto 93:e188a91d3eaa 204 uint32_t Data[8]; /*!< Contains the data to be transmitted.
Kojto 93:e188a91d3eaa 205 This parameter must be a number between Min_Data = 0 and Max_Data = 0xFF. */
Kojto 93:e188a91d3eaa 206
Kojto 93:e188a91d3eaa 207 }CanTxMsgTypeDef;
Kojto 93:e188a91d3eaa 208
Kojto 93:e188a91d3eaa 209 /**
Kojto 93:e188a91d3eaa 210 * @brief CAN Rx message structure definition
Kojto 93:e188a91d3eaa 211 */
Kojto 93:e188a91d3eaa 212 typedef struct
Kojto 93:e188a91d3eaa 213 {
Kojto 93:e188a91d3eaa 214 uint32_t StdId; /*!< Specifies the standard identifier.
Kojto 93:e188a91d3eaa 215 This parameter must be a number between Min_Data = 0 and Max_Data = 0x7FF. */
Kojto 93:e188a91d3eaa 216
Kojto 93:e188a91d3eaa 217 uint32_t ExtId; /*!< Specifies the extended identifier.
Kojto 93:e188a91d3eaa 218 This parameter must be a number between Min_Data = 0 and Max_Data = 0x1FFFFFFF. */
Kojto 93:e188a91d3eaa 219
Kojto 93:e188a91d3eaa 220 uint32_t IDE; /*!< Specifies the type of identifier for the message that will be received.
Kojto 93:e188a91d3eaa 221 This parameter can be a value of @ref CAN_identifier_type */
Kojto 93:e188a91d3eaa 222
Kojto 93:e188a91d3eaa 223 uint32_t RTR; /*!< Specifies the type of frame for the received message.
Kojto 93:e188a91d3eaa 224 This parameter can be a value of @ref CAN_remote_transmission_request */
Kojto 93:e188a91d3eaa 225
Kojto 93:e188a91d3eaa 226 uint32_t DLC; /*!< Specifies the length of the frame that will be received.
Kojto 93:e188a91d3eaa 227 This parameter must be a number between Min_Data = 0 and Max_Data = 8. */
Kojto 93:e188a91d3eaa 228
Kojto 93:e188a91d3eaa 229 uint32_t Data[8]; /*!< Contains the data to be received.
Kojto 93:e188a91d3eaa 230 This parameter must be a number between Min_Data = 0 and Max_Data = 0xFF. */
Kojto 93:e188a91d3eaa 231
Kojto 93:e188a91d3eaa 232 uint32_t FMI; /*!< Specifies the index of the filter the message stored in the mailbox passes through.
Kojto 93:e188a91d3eaa 233 This parameter must be a number between Min_Data = 0 and Max_Data = 0xFF. */
Kojto 93:e188a91d3eaa 234
Kojto 93:e188a91d3eaa 235 uint32_t FIFONumber; /*!< Specifies the receive FIFO number.
Kojto 93:e188a91d3eaa 236 This parameter can be CAN_FIFO0 or CAN_FIFO1 */
Kojto 93:e188a91d3eaa 237
Kojto 93:e188a91d3eaa 238 }CanRxMsgTypeDef;
Kojto 93:e188a91d3eaa 239
Kojto 93:e188a91d3eaa 240 /**
Kojto 93:e188a91d3eaa 241 * @brief CAN handle Structure definition
Kojto 93:e188a91d3eaa 242 */
Kojto 93:e188a91d3eaa 243 typedef struct
Kojto 93:e188a91d3eaa 244 {
Kojto 93:e188a91d3eaa 245 CAN_TypeDef *Instance; /*!< Register base address */
Kojto 93:e188a91d3eaa 246
Kojto 93:e188a91d3eaa 247 CAN_InitTypeDef Init; /*!< CAN required parameters */
Kojto 93:e188a91d3eaa 248
Kojto 93:e188a91d3eaa 249 CanTxMsgTypeDef* pTxMsg; /*!< Pointer to transmit structure */
Kojto 93:e188a91d3eaa 250
Kojto 93:e188a91d3eaa 251 CanRxMsgTypeDef* pRxMsg; /*!< Pointer to reception structure */
Kojto 93:e188a91d3eaa 252
Kojto 93:e188a91d3eaa 253 HAL_LockTypeDef Lock; /*!< CAN locking object */
Kojto 93:e188a91d3eaa 254
Kojto 93:e188a91d3eaa 255 __IO HAL_CAN_StateTypeDef State; /*!< CAN communication state */
Kojto 93:e188a91d3eaa 256
Kojto 93:e188a91d3eaa 257 __IO HAL_CAN_ErrorTypeDef ErrorCode; /*!< CAN Error code */
Kojto 93:e188a91d3eaa 258
Kojto 93:e188a91d3eaa 259 }CAN_HandleTypeDef;
Kojto 93:e188a91d3eaa 260 /**
Kojto 93:e188a91d3eaa 261 * @}
Kojto 93:e188a91d3eaa 262 */
Kojto 93:e188a91d3eaa 263 /* Exported constants --------------------------------------------------------*/
Kojto 93:e188a91d3eaa 264
Kojto 93:e188a91d3eaa 265 /** @defgroup CAN_Exported_Constants CAN Exported Constants
Kojto 93:e188a91d3eaa 266 * @{
Kojto 93:e188a91d3eaa 267 */
Kojto 93:e188a91d3eaa 268
Kojto 93:e188a91d3eaa 269 /** @defgroup CAN_InitStatus CAN initialization Status
Kojto 93:e188a91d3eaa 270 * @{
Kojto 93:e188a91d3eaa 271 */
Kojto 93:e188a91d3eaa 272 #define CAN_INITSTATUS_FAILED ((uint32_t)0x00000000) /*!< CAN initialization failed */
Kojto 93:e188a91d3eaa 273 #define CAN_INITSTATUS_SUCCESS ((uint32_t)0x00000001) /*!< CAN initialization OK */
Kojto 93:e188a91d3eaa 274 /**
Kojto 93:e188a91d3eaa 275 * @}
Kojto 93:e188a91d3eaa 276 */
Kojto 93:e188a91d3eaa 277
Kojto 93:e188a91d3eaa 278 /** @defgroup CAN_operating_mode CAN Operating Mode
Kojto 93:e188a91d3eaa 279 * @{
Kojto 93:e188a91d3eaa 280 */
Kojto 93:e188a91d3eaa 281 #define CAN_MODE_NORMAL ((uint32_t)0x00000000) /*!< Normal mode */
Kojto 93:e188a91d3eaa 282 #define CAN_MODE_LOOPBACK ((uint32_t)CAN_BTR_LBKM) /*!< Loopback mode */
Kojto 93:e188a91d3eaa 283 #define CAN_MODE_SILENT ((uint32_t)CAN_BTR_SILM) /*!< Silent mode */
Kojto 93:e188a91d3eaa 284 #define CAN_MODE_SILENT_LOOPBACK ((uint32_t)(CAN_BTR_LBKM | CAN_BTR_SILM)) /*!< Loopback combined with silent mode */
Kojto 93:e188a91d3eaa 285
Kojto 93:e188a91d3eaa 286 #define IS_CAN_MODE(MODE) (((MODE) == CAN_MODE_NORMAL) || \
Kojto 93:e188a91d3eaa 287 ((MODE) == CAN_MODE_LOOPBACK)|| \
Kojto 93:e188a91d3eaa 288 ((MODE) == CAN_MODE_SILENT) || \
Kojto 93:e188a91d3eaa 289 ((MODE) == CAN_MODE_SILENT_LOOPBACK))
Kojto 93:e188a91d3eaa 290 /**
Kojto 93:e188a91d3eaa 291 * @}
Kojto 93:e188a91d3eaa 292 */
Kojto 93:e188a91d3eaa 293
Kojto 93:e188a91d3eaa 294
Kojto 93:e188a91d3eaa 295 /** @defgroup CAN_synchronisation_jump_width CAN Synchronization Jump Width
Kojto 93:e188a91d3eaa 296 * @{
Kojto 93:e188a91d3eaa 297 */
Kojto 93:e188a91d3eaa 298 #define CAN_SJW_1TQ ((uint32_t)0x00000000) /*!< 1 time quantum */
Kojto 93:e188a91d3eaa 299 #define CAN_SJW_2TQ ((uint32_t)CAN_BTR_SJW_0) /*!< 2 time quantum */
Kojto 93:e188a91d3eaa 300 #define CAN_SJW_3TQ ((uint32_t)CAN_BTR_SJW_1) /*!< 3 time quantum */
Kojto 93:e188a91d3eaa 301 #define CAN_SJW_4TQ ((uint32_t)CAN_BTR_SJW) /*!< 4 time quantum */
Kojto 93:e188a91d3eaa 302
Kojto 93:e188a91d3eaa 303 #define IS_CAN_SJW(SJW) (((SJW) == CAN_SJW_1TQ) || ((SJW) == CAN_SJW_2TQ)|| \
Kojto 93:e188a91d3eaa 304 ((SJW) == CAN_SJW_3TQ) || ((SJW) == CAN_SJW_4TQ))
Kojto 93:e188a91d3eaa 305 /**
Kojto 93:e188a91d3eaa 306 * @}
Kojto 93:e188a91d3eaa 307 */
Kojto 93:e188a91d3eaa 308
Kojto 93:e188a91d3eaa 309 /** @defgroup CAN_time_quantum_in_bit_segment_1 CAN Time Quantum in Bit Segment 1
Kojto 93:e188a91d3eaa 310 * @{
Kojto 93:e188a91d3eaa 311 */
Kojto 93:e188a91d3eaa 312 #define CAN_BS1_1TQ ((uint32_t)0x00000000) /*!< 1 time quantum */
Kojto 93:e188a91d3eaa 313 #define CAN_BS1_2TQ ((uint32_t)CAN_BTR_TS1_0) /*!< 2 time quantum */
Kojto 93:e188a91d3eaa 314 #define CAN_BS1_3TQ ((uint32_t)CAN_BTR_TS1_1) /*!< 3 time quantum */
Kojto 93:e188a91d3eaa 315 #define CAN_BS1_4TQ ((uint32_t)(CAN_BTR_TS1_1 | CAN_BTR_TS1_0)) /*!< 4 time quantum */
Kojto 93:e188a91d3eaa 316 #define CAN_BS1_5TQ ((uint32_t)CAN_BTR_TS1_2) /*!< 5 time quantum */
Kojto 93:e188a91d3eaa 317 #define CAN_BS1_6TQ ((uint32_t)(CAN_BTR_TS1_2 | CAN_BTR_TS1_0)) /*!< 6 time quantum */
Kojto 93:e188a91d3eaa 318 #define CAN_BS1_7TQ ((uint32_t)(CAN_BTR_TS1_2 | CAN_BTR_TS1_1)) /*!< 7 time quantum */
Kojto 93:e188a91d3eaa 319 #define CAN_BS1_8TQ ((uint32_t)(CAN_BTR_TS1_2 | CAN_BTR_TS1_1 | CAN_BTR_TS1_0)) /*!< 8 time quantum */
Kojto 93:e188a91d3eaa 320 #define CAN_BS1_9TQ ((uint32_t)CAN_BTR_TS1_3) /*!< 9 time quantum */
Kojto 93:e188a91d3eaa 321 #define CAN_BS1_10TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_0)) /*!< 10 time quantum */
Kojto 93:e188a91d3eaa 322 #define CAN_BS1_11TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_1)) /*!< 11 time quantum */
Kojto 93:e188a91d3eaa 323 #define CAN_BS1_12TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_1 | CAN_BTR_TS1_0)) /*!< 12 time quantum */
Kojto 93:e188a91d3eaa 324 #define CAN_BS1_13TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_2)) /*!< 13 time quantum */
Kojto 93:e188a91d3eaa 325 #define CAN_BS1_14TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_2 | CAN_BTR_TS1_0)) /*!< 14 time quantum */
Kojto 93:e188a91d3eaa 326 #define CAN_BS1_15TQ ((uint32_t)(CAN_BTR_TS1_3 | CAN_BTR_TS1_2 | CAN_BTR_TS1_1)) /*!< 15 time quantum */
Kojto 93:e188a91d3eaa 327 #define CAN_BS1_16TQ ((uint32_t)CAN_BTR_TS1) /*!< 16 time quantum */
Kojto 93:e188a91d3eaa 328
Kojto 93:e188a91d3eaa 329 #define IS_CAN_BS1(BS1) ((BS1) <= CAN_BS1_16TQ)
Kojto 93:e188a91d3eaa 330 /**
Kojto 93:e188a91d3eaa 331 * @}
Kojto 93:e188a91d3eaa 332 */
Kojto 93:e188a91d3eaa 333
Kojto 93:e188a91d3eaa 334 /** @defgroup CAN_time_quantum_in_bit_segment_2 CAN Time Quantum in Bit Segment 2
Kojto 93:e188a91d3eaa 335 * @{
Kojto 93:e188a91d3eaa 336 */
Kojto 93:e188a91d3eaa 337 #define CAN_BS2_1TQ ((uint32_t)0x00000000) /*!< 1 time quantum */
Kojto 93:e188a91d3eaa 338 #define CAN_BS2_2TQ ((uint32_t)CAN_BTR_TS2_0) /*!< 2 time quantum */
Kojto 93:e188a91d3eaa 339 #define CAN_BS2_3TQ ((uint32_t)CAN_BTR_TS2_1) /*!< 3 time quantum */
Kojto 93:e188a91d3eaa 340 #define CAN_BS2_4TQ ((uint32_t)(CAN_BTR_TS2_1 | CAN_BTR_TS2_0)) /*!< 4 time quantum */
Kojto 93:e188a91d3eaa 341 #define CAN_BS2_5TQ ((uint32_t)CAN_BTR_TS2_2) /*!< 5 time quantum */
Kojto 93:e188a91d3eaa 342 #define CAN_BS2_6TQ ((uint32_t)(CAN_BTR_TS2_2 | CAN_BTR_TS2_0)) /*!< 6 time quantum */
Kojto 93:e188a91d3eaa 343 #define CAN_BS2_7TQ ((uint32_t)(CAN_BTR_TS2_2 | CAN_BTR_TS2_1)) /*!< 7 time quantum */
Kojto 93:e188a91d3eaa 344 #define CAN_BS2_8TQ ((uint32_t)CAN_BTR_TS2) /*!< 8 time quantum */
Kojto 93:e188a91d3eaa 345
Kojto 93:e188a91d3eaa 346 #define IS_CAN_BS2(BS2) ((BS2) <= CAN_BS2_8TQ)
Kojto 93:e188a91d3eaa 347 /**
Kojto 93:e188a91d3eaa 348 * @}
Kojto 93:e188a91d3eaa 349 */
Kojto 93:e188a91d3eaa 350
Kojto 93:e188a91d3eaa 351 /** @defgroup CAN_clock_prescaler CAN Clock Prescaler
Kojto 93:e188a91d3eaa 352 * @{
Kojto 93:e188a91d3eaa 353 */
Kojto 93:e188a91d3eaa 354 #define IS_CAN_PRESCALER(PRESCALER) (((PRESCALER) >= 1) && ((PRESCALER) <= 1024))
Kojto 93:e188a91d3eaa 355 /**
Kojto 93:e188a91d3eaa 356 * @}
Kojto 93:e188a91d3eaa 357 */
Kojto 93:e188a91d3eaa 358
Kojto 93:e188a91d3eaa 359 /** @defgroup CAN_filter_number CAN Filter Number
Kojto 93:e188a91d3eaa 360 * @{
Kojto 93:e188a91d3eaa 361 */
Kojto 93:e188a91d3eaa 362 #define IS_CAN_FILTER_NUMBER(NUMBER) ((NUMBER) <= 27)
Kojto 93:e188a91d3eaa 363 /**
Kojto 93:e188a91d3eaa 364 * @}
Kojto 93:e188a91d3eaa 365 */
Kojto 93:e188a91d3eaa 366
Kojto 93:e188a91d3eaa 367 /** @defgroup CAN_filter_mode CAN Filter Mode
Kojto 93:e188a91d3eaa 368 * @{
Kojto 93:e188a91d3eaa 369 */
Kojto 93:e188a91d3eaa 370 #define CAN_FILTERMODE_IDMASK ((uint8_t)0x00) /*!< Identifier mask mode */
Kojto 93:e188a91d3eaa 371 #define CAN_FILTERMODE_IDLIST ((uint8_t)0x01) /*!< Identifier list mode */
Kojto 93:e188a91d3eaa 372
Kojto 93:e188a91d3eaa 373 #define IS_CAN_FILTER_MODE(MODE) (((MODE) == CAN_FILTERMODE_IDMASK) || \
Kojto 93:e188a91d3eaa 374 ((MODE) == CAN_FILTERMODE_IDLIST))
Kojto 93:e188a91d3eaa 375 /**
Kojto 93:e188a91d3eaa 376 * @}
Kojto 93:e188a91d3eaa 377 */
Kojto 93:e188a91d3eaa 378
Kojto 93:e188a91d3eaa 379 /** @defgroup CAN_filter_scale CAN Filter Scale
Kojto 93:e188a91d3eaa 380 * @{
Kojto 93:e188a91d3eaa 381 */
Kojto 93:e188a91d3eaa 382 #define CAN_FILTERSCALE_16BIT ((uint8_t)0x00) /*!< Two 16-bit filters */
Kojto 93:e188a91d3eaa 383 #define CAN_FILTERSCALE_32BIT ((uint8_t)0x01) /*!< One 32-bit filter */
Kojto 93:e188a91d3eaa 384
Kojto 93:e188a91d3eaa 385 #define IS_CAN_FILTER_SCALE(SCALE) (((SCALE) == CAN_FILTERSCALE_16BIT) || \
Kojto 93:e188a91d3eaa 386 ((SCALE) == CAN_FILTERSCALE_32BIT))
Kojto 93:e188a91d3eaa 387 /**
Kojto 93:e188a91d3eaa 388 * @}
Kojto 93:e188a91d3eaa 389 */
Kojto 93:e188a91d3eaa 390
Kojto 93:e188a91d3eaa 391 /** @defgroup CAN_filter_FIFO CAN Filter FIFO
Kojto 93:e188a91d3eaa 392 * @{
Kojto 93:e188a91d3eaa 393 */
Kojto 93:e188a91d3eaa 394 #define CAN_FILTER_FIFO0 ((uint8_t)0x00) /*!< Filter FIFO 0 assignment for filter x */
Kojto 93:e188a91d3eaa 395 #define CAN_FILTER_FIFO1 ((uint8_t)0x01) /*!< Filter FIFO 1 assignment for filter x */
Kojto 93:e188a91d3eaa 396
Kojto 93:e188a91d3eaa 397 #define IS_CAN_FILTER_FIFO(FIFO) (((FIFO) == CAN_FILTER_FIFO0) || \
Kojto 93:e188a91d3eaa 398 ((FIFO) == CAN_FILTER_FIFO1))
Kojto 93:e188a91d3eaa 399
Kojto 93:e188a91d3eaa 400 /* Legacy defines */
Kojto 93:e188a91d3eaa 401 #define CAN_FilterFIFO0 CAN_FILTER_FIFO0
Kojto 93:e188a91d3eaa 402 #define CAN_FilterFIFO1 CAN_FILTER_FIFO1
Kojto 93:e188a91d3eaa 403 /**
Kojto 93:e188a91d3eaa 404 * @}
Kojto 93:e188a91d3eaa 405 */
Kojto 93:e188a91d3eaa 406
Kojto 93:e188a91d3eaa 407 /** @defgroup CAN_Start_bank_filter_for_slave_CAN CAN Start Bank Filter For Slave CAN
Kojto 93:e188a91d3eaa 408 * @{
Kojto 93:e188a91d3eaa 409 */
Kojto 93:e188a91d3eaa 410 #define IS_CAN_BANKNUMBER(BANKNUMBER) ((BANKNUMBER) <= 28)
Kojto 93:e188a91d3eaa 411 /**
Kojto 93:e188a91d3eaa 412 * @}
Kojto 93:e188a91d3eaa 413 */
Kojto 93:e188a91d3eaa 414
Kojto 93:e188a91d3eaa 415 /** @defgroup CAN_Tx CAN Tx
Kojto 93:e188a91d3eaa 416 * @{
Kojto 93:e188a91d3eaa 417 */
Kojto 93:e188a91d3eaa 418 #define IS_CAN_TRANSMITMAILBOX(TRANSMITMAILBOX) ((TRANSMITMAILBOX) <= ((uint8_t)0x02))
Kojto 93:e188a91d3eaa 419 #define IS_CAN_STDID(STDID) ((STDID) <= ((uint32_t)0x7FF))
Kojto 93:e188a91d3eaa 420 #define IS_CAN_EXTID(EXTID) ((EXTID) <= ((uint32_t)0x1FFFFFFF))
Kojto 93:e188a91d3eaa 421 #define IS_CAN_DLC(DLC) ((DLC) <= ((uint8_t)0x08))
Kojto 93:e188a91d3eaa 422 /**
Kojto 93:e188a91d3eaa 423 * @}
Kojto 93:e188a91d3eaa 424 */
Kojto 93:e188a91d3eaa 425
Kojto 93:e188a91d3eaa 426 /** @defgroup CAN_identifier_type CAN Identifier Type
Kojto 93:e188a91d3eaa 427 * @{
Kojto 93:e188a91d3eaa 428 */
Kojto 93:e188a91d3eaa 429 #define CAN_ID_STD ((uint32_t)0x00000000) /*!< Standard Id */
Kojto 93:e188a91d3eaa 430 #define CAN_ID_EXT ((uint32_t)0x00000004) /*!< Extended Id */
Kojto 93:e188a91d3eaa 431 #define IS_CAN_IDTYPE(IDTYPE) (((IDTYPE) == CAN_ID_STD) || \
Kojto 93:e188a91d3eaa 432 ((IDTYPE) == CAN_ID_EXT))
Kojto 93:e188a91d3eaa 433 /**
Kojto 93:e188a91d3eaa 434 * @}
Kojto 93:e188a91d3eaa 435 */
Kojto 93:e188a91d3eaa 436
Kojto 93:e188a91d3eaa 437 /** @defgroup CAN_remote_transmission_request CAN Remote Transmission Request
Kojto 93:e188a91d3eaa 438 * @{
Kojto 93:e188a91d3eaa 439 */
Kojto 93:e188a91d3eaa 440 #define CAN_RTR_DATA ((uint32_t)0x00000000) /*!< Data frame */
Kojto 93:e188a91d3eaa 441 #define CAN_RTR_REMOTE ((uint32_t)0x00000002) /*!< Remote frame */
Kojto 93:e188a91d3eaa 442 #define IS_CAN_RTR(RTR) (((RTR) == CAN_RTR_DATA) || ((RTR) == CAN_RTR_REMOTE))
Kojto 93:e188a91d3eaa 443
Kojto 93:e188a91d3eaa 444 /**
Kojto 93:e188a91d3eaa 445 * @}
Kojto 93:e188a91d3eaa 446 */
Kojto 93:e188a91d3eaa 447
Kojto 93:e188a91d3eaa 448 /** @defgroup CAN_transmit_constants CAN Transmit Constants
Kojto 93:e188a91d3eaa 449 * @{
Kojto 93:e188a91d3eaa 450 */
Kojto 93:e188a91d3eaa 451 #define CAN_TXSTATUS_FAILED ((uint8_t)0x00) /*!< CAN transmission failed */
Kojto 93:e188a91d3eaa 452 #define CAN_TXSTATUS_OK ((uint8_t)0x01) /*!< CAN transmission succeeded */
Kojto 93:e188a91d3eaa 453 #define CAN_TXSTATUS_PENDING ((uint8_t)0x02) /*!< CAN transmission pending */
Kojto 93:e188a91d3eaa 454 #define CAN_TXSTATUS_NOMAILBOX ((uint8_t)0x04) /*!< CAN cell did not provide CAN_TxStatus_NoMailBox */
Kojto 93:e188a91d3eaa 455
Kojto 93:e188a91d3eaa 456 /**
Kojto 93:e188a91d3eaa 457 * @}
Kojto 93:e188a91d3eaa 458 */
Kojto 93:e188a91d3eaa 459
Kojto 93:e188a91d3eaa 460 /** @defgroup CAN_receive_FIFO_number_constants CAN Receive FIFO Number
Kojto 93:e188a91d3eaa 461 * @{
Kojto 93:e188a91d3eaa 462 */
Kojto 93:e188a91d3eaa 463 #define CAN_FIFO0 ((uint8_t)0x00) /*!< CAN FIFO 0 used to receive */
Kojto 93:e188a91d3eaa 464 #define CAN_FIFO1 ((uint8_t)0x01) /*!< CAN FIFO 1 used to receive */
Kojto 93:e188a91d3eaa 465
Kojto 93:e188a91d3eaa 466 #define IS_CAN_FIFO(FIFO) (((FIFO) == CAN_FIFO0) || ((FIFO) == CAN_FIFO1))
Kojto 93:e188a91d3eaa 467 /**
Kojto 93:e188a91d3eaa 468 * @}
Kojto 93:e188a91d3eaa 469 */
Kojto 93:e188a91d3eaa 470
Kojto 93:e188a91d3eaa 471 /** @defgroup CAN_flags CAN Flags
Kojto 93:e188a91d3eaa 472 * @{
Kojto 93:e188a91d3eaa 473 */
Kojto 93:e188a91d3eaa 474 /* If the flag is 0x3XXXXXXX, it means that it can be used with CAN_GetFlagStatus()
Kojto 93:e188a91d3eaa 475 and CAN_ClearFlag() functions. */
Kojto 93:e188a91d3eaa 476 /* If the flag is 0x1XXXXXXX, it means that it can only be used with
Kojto 93:e188a91d3eaa 477 CAN_GetFlagStatus() function. */
Kojto 93:e188a91d3eaa 478
Kojto 93:e188a91d3eaa 479 /* Transmit Flags */
Kojto 93:e188a91d3eaa 480 #define CAN_FLAG_RQCP0 ((uint32_t)0x00000500) /*!< Request MailBox0 flag */
Kojto 93:e188a91d3eaa 481 #define CAN_FLAG_RQCP1 ((uint32_t)0x00000508) /*!< Request MailBox1 flag */
Kojto 93:e188a91d3eaa 482 #define CAN_FLAG_RQCP2 ((uint32_t)0x00000510) /*!< Request MailBox2 flag */
Kojto 93:e188a91d3eaa 483 #define CAN_FLAG_TXOK0 ((uint32_t)0x00000501) /*!< Transmission OK MailBox0 flag */
Kojto 93:e188a91d3eaa 484 #define CAN_FLAG_TXOK1 ((uint32_t)0x00000509) /*!< Transmission OK MailBox1 flag */
Kojto 93:e188a91d3eaa 485 #define CAN_FLAG_TXOK2 ((uint32_t)0x00000511) /*!< Transmission OK MailBox2 flag */
Kojto 93:e188a91d3eaa 486 #define CAN_FLAG_TME0 ((uint32_t)0x0000051A) /*!< Transmit mailbox 0 empty flag */
Kojto 93:e188a91d3eaa 487 #define CAN_FLAG_TME1 ((uint32_t)0x0000051B) /*!< Transmit mailbox 0 empty flag */
Kojto 93:e188a91d3eaa 488 #define CAN_FLAG_TME2 ((uint32_t)0x0000051C) /*!< Transmit mailbox 0 empty flag */
Kojto 93:e188a91d3eaa 489
Kojto 93:e188a91d3eaa 490 /* Receive Flags */
Kojto 93:e188a91d3eaa 491 #define CAN_FLAG_FF0 ((uint32_t)0x00000203) /*!< FIFO 0 Full flag */
Kojto 93:e188a91d3eaa 492 #define CAN_FLAG_FOV0 ((uint32_t)0x00000204) /*!< FIFO 0 Overrun flag */
Kojto 93:e188a91d3eaa 493
Kojto 93:e188a91d3eaa 494 #define CAN_FLAG_FF1 ((uint32_t)0x00000403) /*!< FIFO 1 Full flag */
Kojto 93:e188a91d3eaa 495 #define CAN_FLAG_FOV1 ((uint32_t)0x00000404) /*!< FIFO 1 Overrun flag */
Kojto 93:e188a91d3eaa 496
Kojto 93:e188a91d3eaa 497 /* Operating Mode Flags */
Kojto 93:e188a91d3eaa 498 #define CAN_FLAG_WKU ((uint32_t)0x00000103) /*!< Wake up flag */
Kojto 93:e188a91d3eaa 499 #define CAN_FLAG_SLAK ((uint32_t)0x00000101) /*!< Sleep acknowledge flag */
Kojto 93:e188a91d3eaa 500 #define CAN_FLAG_SLAKI ((uint32_t)0x00000104) /*!< Sleep acknowledge flag */
Kojto 93:e188a91d3eaa 501 /* @note When SLAK interrupt is disabled (SLKIE=0), no polling on SLAKI is possible.
Kojto 93:e188a91d3eaa 502 In this case the SLAK bit can be polled.*/
Kojto 93:e188a91d3eaa 503
Kojto 93:e188a91d3eaa 504 /* Error Flags */
Kojto 93:e188a91d3eaa 505 #define CAN_FLAG_EWG ((uint32_t)0x00000300) /*!< Error warning flag */
Kojto 93:e188a91d3eaa 506 #define CAN_FLAG_EPV ((uint32_t)0x00000301) /*!< Error passive flag */
Kojto 93:e188a91d3eaa 507 #define CAN_FLAG_BOF ((uint32_t)0x00000302) /*!< Bus-Off flag */
Kojto 93:e188a91d3eaa 508
Kojto 93:e188a91d3eaa 509 #define IS_CAN_GET_FLAG(FLAG) (((FLAG) == CAN_FLAG_RQCP2) || ((FLAG) == CAN_FLAG_BOF) || \
Kojto 93:e188a91d3eaa 510 ((FLAG) == CAN_FLAG_EPV) || ((FLAG) == CAN_FLAG_EWG) || \
Kojto 93:e188a91d3eaa 511 ((FLAG) == CAN_FLAG_WKU) || ((FLAG) == CAN_FLAG_FOV0) || \
Kojto 93:e188a91d3eaa 512 ((FLAG) == CAN_FLAG_FF0) || ((FLAG) == CAN_FLAG_SLAK) || \
Kojto 93:e188a91d3eaa 513 ((FLAG) == CAN_FLAG_FOV1) || ((FLAG) == CAN_FLAG_FF1) || \
Kojto 93:e188a91d3eaa 514 ((FLAG) == CAN_FLAG_RQCP1) || ((FLAG) == CAN_FLAG_RQCP0))
Kojto 93:e188a91d3eaa 515
Kojto 93:e188a91d3eaa 516
Kojto 93:e188a91d3eaa 517 #define IS_CAN_CLEAR_FLAG(FLAG)(((FLAG) == CAN_FLAG_RQCP2) || ((FLAG) == CAN_FLAG_RQCP1) || \
Kojto 93:e188a91d3eaa 518 ((FLAG) == CAN_FLAG_RQCP0) || ((FLAG) == CAN_FLAG_FF0) || \
Kojto 93:e188a91d3eaa 519 ((FLAG) == CAN_FLAG_FOV0) || ((FLAG) == CAN_FLAG_FF1) || \
Kojto 93:e188a91d3eaa 520 ((FLAG) == CAN_FLAG_FOV1) || ((FLAG) == CAN_FLAG_WKU))
Kojto 93:e188a91d3eaa 521 /**
Kojto 93:e188a91d3eaa 522 * @}
Kojto 93:e188a91d3eaa 523 */
Kojto 93:e188a91d3eaa 524
Kojto 93:e188a91d3eaa 525
Kojto 93:e188a91d3eaa 526 /** @defgroup CAN_interrupts CAN Interrupts
Kojto 93:e188a91d3eaa 527 * @{
Kojto 93:e188a91d3eaa 528 */
Kojto 93:e188a91d3eaa 529 #define CAN_IT_TME ((uint32_t)CAN_IER_TMEIE) /*!< Transmit mailbox empty interrupt */
Kojto 93:e188a91d3eaa 530
Kojto 93:e188a91d3eaa 531 /* Receive Interrupts */
Kojto 93:e188a91d3eaa 532 #define CAN_IT_FMP0 ((uint32_t)CAN_IER_FMPIE0) /*!< FIFO 0 message pending interrupt */
Kojto 93:e188a91d3eaa 533 #define CAN_IT_FF0 ((uint32_t)CAN_IER_FFIE0) /*!< FIFO 0 full interrupt */
Kojto 93:e188a91d3eaa 534 #define CAN_IT_FOV0 ((uint32_t)CAN_IER_FOVIE0) /*!< FIFO 0 overrun interrupt */
Kojto 93:e188a91d3eaa 535 #define CAN_IT_FMP1 ((uint32_t)CAN_IER_FMPIE1) /*!< FIFO 1 message pending interrupt */
Kojto 93:e188a91d3eaa 536 #define CAN_IT_FF1 ((uint32_t)CAN_IER_FFIE1) /*!< FIFO 1 full interrupt */
Kojto 93:e188a91d3eaa 537 #define CAN_IT_FOV1 ((uint32_t)CAN_IER_FOVIE1) /*!< FIFO 1 overrun interrupt */
Kojto 93:e188a91d3eaa 538
Kojto 93:e188a91d3eaa 539 /* Operating Mode Interrupts */
Kojto 93:e188a91d3eaa 540 #define CAN_IT_WKU ((uint32_t)CAN_IER_WKUIE) /*!< Wake-up interrupt */
Kojto 93:e188a91d3eaa 541 #define CAN_IT_SLK ((uint32_t)CAN_IER_SLKIE) /*!< Sleep acknowledge interrupt */
Kojto 93:e188a91d3eaa 542
Kojto 93:e188a91d3eaa 543 /* Error Interrupts */
Kojto 93:e188a91d3eaa 544 #define CAN_IT_EWG ((uint32_t)CAN_IER_EWGIE) /*!< Error warning interrupt */
Kojto 93:e188a91d3eaa 545 #define CAN_IT_EPV ((uint32_t)CAN_IER_EPVIE) /*!< Error passive interrupt */
Kojto 93:e188a91d3eaa 546 #define CAN_IT_BOF ((uint32_t)CAN_IER_BOFIE) /*!< Bus-off interrupt */
Kojto 93:e188a91d3eaa 547 #define CAN_IT_LEC ((uint32_t)CAN_IER_LECIE) /*!< Last error code interrupt */
Kojto 93:e188a91d3eaa 548 #define CAN_IT_ERR ((uint32_t)CAN_IER_ERRIE) /*!< Error Interrupt */
Kojto 93:e188a91d3eaa 549
Kojto 93:e188a91d3eaa 550 /* Flags named as Interrupts : kept only for FW compatibility */
Kojto 93:e188a91d3eaa 551 #define CAN_IT_RQCP0 CAN_IT_TME
Kojto 93:e188a91d3eaa 552 #define CAN_IT_RQCP1 CAN_IT_TME
Kojto 93:e188a91d3eaa 553 #define CAN_IT_RQCP2 CAN_IT_TME
Kojto 93:e188a91d3eaa 554
Kojto 93:e188a91d3eaa 555 #define IS_CAN_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FMP0) ||\
Kojto 93:e188a91d3eaa 556 ((IT) == CAN_IT_FF0) || ((IT) == CAN_IT_FOV0) ||\
Kojto 93:e188a91d3eaa 557 ((IT) == CAN_IT_FMP1) || ((IT) == CAN_IT_FF1) ||\
Kojto 93:e188a91d3eaa 558 ((IT) == CAN_IT_FOV1) || ((IT) == CAN_IT_EWG) ||\
Kojto 93:e188a91d3eaa 559 ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\
Kojto 93:e188a91d3eaa 560 ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\
Kojto 93:e188a91d3eaa 561 ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK))
Kojto 93:e188a91d3eaa 562
Kojto 93:e188a91d3eaa 563 #define IS_CAN_CLEAR_IT(IT) (((IT) == CAN_IT_TME) || ((IT) == CAN_IT_FF0) ||\
Kojto 93:e188a91d3eaa 564 ((IT) == CAN_IT_FOV0)|| ((IT) == CAN_IT_FF1) ||\
Kojto 93:e188a91d3eaa 565 ((IT) == CAN_IT_FOV1)|| ((IT) == CAN_IT_EWG) ||\
Kojto 93:e188a91d3eaa 566 ((IT) == CAN_IT_EPV) || ((IT) == CAN_IT_BOF) ||\
Kojto 93:e188a91d3eaa 567 ((IT) == CAN_IT_LEC) || ((IT) == CAN_IT_ERR) ||\
Kojto 93:e188a91d3eaa 568 ((IT) == CAN_IT_WKU) || ((IT) == CAN_IT_SLK))
Kojto 93:e188a91d3eaa 569 /**
Kojto 93:e188a91d3eaa 570 * @}
Kojto 93:e188a91d3eaa 571 */
Kojto 93:e188a91d3eaa 572
Kojto 93:e188a91d3eaa 573 /* Time out for INAK bit */
Kojto 93:e188a91d3eaa 574 #define INAK_TIMEOUT ((uint32_t)0x00FFFFFF)
Kojto 93:e188a91d3eaa 575 /* Time out for SLAK bit */
Kojto 93:e188a91d3eaa 576 #define SLAK_TIMEOUT ((uint32_t)0x00FFFFFF)
Kojto 93:e188a91d3eaa 577
Kojto 93:e188a91d3eaa 578 /* Mailboxes definition */
Kojto 93:e188a91d3eaa 579 #define CAN_TXMAILBOX_0 ((uint8_t)0x00)
Kojto 93:e188a91d3eaa 580 #define CAN_TXMAILBOX_1 ((uint8_t)0x01)
Kojto 93:e188a91d3eaa 581 #define CAN_TXMAILBOX_2 ((uint8_t)0x02)
Kojto 93:e188a91d3eaa 582
Kojto 93:e188a91d3eaa 583 /**
Kojto 93:e188a91d3eaa 584 * @}
Kojto 93:e188a91d3eaa 585 */
Kojto 93:e188a91d3eaa 586
Kojto 93:e188a91d3eaa 587 /* Exported macros -----------------------------------------------------------*/
Kojto 93:e188a91d3eaa 588 /** @defgroup CAN_Exported_Macro CAN Exported Macros
Kojto 93:e188a91d3eaa 589 * @{
Kojto 93:e188a91d3eaa 590 */
Kojto 93:e188a91d3eaa 591
Kojto 93:e188a91d3eaa 592 /** @brief Reset CAN handle state
Kojto 93:e188a91d3eaa 593 * @param __HANDLE__: CAN handle.
Kojto 93:e188a91d3eaa 594 * @retval None
Kojto 93:e188a91d3eaa 595 */
Kojto 93:e188a91d3eaa 596 #define __HAL_CAN_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CAN_STATE_RESET)
Kojto 93:e188a91d3eaa 597
Kojto 93:e188a91d3eaa 598 /**
Kojto 93:e188a91d3eaa 599 * @brief Enable the specified CAN interrupts
Kojto 93:e188a91d3eaa 600 * @param __HANDLE__: CAN handle.
Kojto 93:e188a91d3eaa 601 * @param __INTERRUPT__: CAN Interrupt.
Kojto 93:e188a91d3eaa 602 * @retval None.
Kojto 93:e188a91d3eaa 603 */
Kojto 93:e188a91d3eaa 604 #define __HAL_CAN_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IER) |= (__INTERRUPT__))
Kojto 93:e188a91d3eaa 605
Kojto 93:e188a91d3eaa 606 /**
Kojto 93:e188a91d3eaa 607 * @brief Disable the specified CAN interrupts
Kojto 93:e188a91d3eaa 608 * @param __HANDLE__: CAN handle.
Kojto 93:e188a91d3eaa 609 * @param __INTERRUPT__: CAN Interrupt.
Kojto 93:e188a91d3eaa 610 * @retval None.
Kojto 93:e188a91d3eaa 611 */
Kojto 93:e188a91d3eaa 612 #define __HAL_CAN_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IER) &= ~(__INTERRUPT__))
Kojto 93:e188a91d3eaa 613
Kojto 93:e188a91d3eaa 614 /**
Kojto 93:e188a91d3eaa 615 * @brief Return the number of pending received messages.
Kojto 93:e188a91d3eaa 616 * @param __HANDLE__: CAN handle.
Kojto 93:e188a91d3eaa 617 * @param __FIFONUMBER__: Receive FIFO number, CAN_FIFO0 or CAN_FIFO1.
Kojto 93:e188a91d3eaa 618 * @retval The number of pending message.
Kojto 93:e188a91d3eaa 619 */
Kojto 93:e188a91d3eaa 620 #define __HAL_CAN_MSG_PENDING(__HANDLE__, __FIFONUMBER__) (((__FIFONUMBER__) == CAN_FIFO0)? \
Kojto 93:e188a91d3eaa 621 ((uint8_t)((__HANDLE__)->Instance->RF0R&(uint32_t)0x03)) : ((uint8_t)((__HANDLE__)->Instance->RF1R&(uint32_t)0x03)))
Kojto 93:e188a91d3eaa 622
Kojto 93:e188a91d3eaa 623 /** @brief Check whether the specified CAN flag is set or not.
Kojto 93:e188a91d3eaa 624 * @param __HANDLE__: specifies the CAN Handle.
Kojto 93:e188a91d3eaa 625 * @param __FLAG__: specifies the flag to check.
Kojto 93:e188a91d3eaa 626 * This parameter can be one of the following values:
Kojto 93:e188a91d3eaa 627 * @arg CAN_TSR_RQCP0: Request MailBox0 Flag
Kojto 93:e188a91d3eaa 628 * @arg CAN_TSR_RQCP1: Request MailBox1 Flag
Kojto 93:e188a91d3eaa 629 * @arg CAN_TSR_RQCP2: Request MailBox2 Flag
Kojto 93:e188a91d3eaa 630 * @arg CAN_FLAG_TXOK0: Transmission OK MailBox0 Flag
Kojto 93:e188a91d3eaa 631 * @arg CAN_FLAG_TXOK1: Transmission OK MailBox1 Flag
Kojto 93:e188a91d3eaa 632 * @arg CAN_FLAG_TXOK2: Transmission OK MailBox2 Flag
Kojto 93:e188a91d3eaa 633 * @arg CAN_FLAG_TME0: Transmit mailbox 0 empty Flag
Kojto 93:e188a91d3eaa 634 * @arg CAN_FLAG_TME1: Transmit mailbox 1 empty Flag
Kojto 93:e188a91d3eaa 635 * @arg CAN_FLAG_TME2: Transmit mailbox 2 empty Flag
Kojto 93:e188a91d3eaa 636 * @arg CAN_FLAG_FMP0: FIFO 0 Message Pending Flag
Kojto 93:e188a91d3eaa 637 * @arg CAN_FLAG_FF0: FIFO 0 Full Flag
Kojto 93:e188a91d3eaa 638 * @arg CAN_FLAG_FOV0: FIFO 0 Overrun Flag
Kojto 93:e188a91d3eaa 639 * @arg CAN_FLAG_FMP1: FIFO 1 Message Pending Flag
Kojto 93:e188a91d3eaa 640 * @arg CAN_FLAG_FF1: FIFO 1 Full Flag
Kojto 93:e188a91d3eaa 641 * @arg CAN_FLAG_FOV1: FIFO 1 Overrun Flag
Kojto 93:e188a91d3eaa 642 * @arg CAN_FLAG_WKU: Wake up Flag
Kojto 93:e188a91d3eaa 643 * @arg CAN_FLAG_SLAK: Sleep acknowledge Flag
Kojto 93:e188a91d3eaa 644 * @arg CAN_FLAG_SLAKI: Sleep acknowledge Flag
Kojto 93:e188a91d3eaa 645 * @arg CAN_FLAG_EWG: Error Warning Flag
Kojto 93:e188a91d3eaa 646 * @arg CAN_FLAG_EPV: Error Passive Flag
Kojto 93:e188a91d3eaa 647 * @arg CAN_FLAG_BOF: Bus-Off Flag
Kojto 93:e188a91d3eaa 648 * @retval The new state of __FLAG__ (TRUE or FALSE).
Kojto 93:e188a91d3eaa 649 */
Kojto 93:e188a91d3eaa 650 #define CAN_FLAG_MASK ((uint32_t)0x000000FF)
Kojto 93:e188a91d3eaa 651 #define __HAL_CAN_GET_FLAG(__HANDLE__, __FLAG__) \
Kojto 93:e188a91d3eaa 652 ((((__FLAG__) >> 8) == 5)? ((((__HANDLE__)->Instance->TSR) & (1U << ((__FLAG__) & CAN_FLAG_MASK))) == (1U << ((__FLAG__) & CAN_FLAG_MASK))): \
Kojto 93:e188a91d3eaa 653 (((__FLAG__) >> 8) == 2)? ((((__HANDLE__)->Instance->RF0R) & (1U << ((__FLAG__) & CAN_FLAG_MASK))) == (1U << ((__FLAG__) & CAN_FLAG_MASK))): \
Kojto 93:e188a91d3eaa 654 (((__FLAG__) >> 8) == 4)? ((((__HANDLE__)->Instance->RF1R) & (1U << ((__FLAG__) & CAN_FLAG_MASK))) == (1U << ((__FLAG__) & CAN_FLAG_MASK))): \
Kojto 93:e188a91d3eaa 655 (((__FLAG__) >> 8) == 1)? ((((__HANDLE__)->Instance->MSR) & (1U << ((__FLAG__) & CAN_FLAG_MASK))) == (1U << ((__FLAG__) & CAN_FLAG_MASK))): \
Kojto 93:e188a91d3eaa 656 ((((__HANDLE__)->Instance->ESR) & (1U << ((__FLAG__) & CAN_FLAG_MASK))) == (1U << ((__FLAG__) & CAN_FLAG_MASK))))
Kojto 93:e188a91d3eaa 657
Kojto 93:e188a91d3eaa 658 /** @brief Clear the specified CAN pending flag.
Kojto 93:e188a91d3eaa 659 * @param __HANDLE__: specifies the CAN Handle.
Kojto 93:e188a91d3eaa 660 * @param __FLAG__: specifies the flag to check.
Kojto 93:e188a91d3eaa 661 * This parameter can be one of the following values:
Kojto 93:e188a91d3eaa 662 * @arg CAN_TSR_RQCP0: Request MailBox0 Flag
Kojto 93:e188a91d3eaa 663 * @arg CAN_TSR_RQCP1: Request MailBox1 Flag
Kojto 93:e188a91d3eaa 664 * @arg CAN_TSR_RQCP2: Request MailBox2 Flag
Kojto 93:e188a91d3eaa 665 * @arg CAN_FLAG_TXOK0: Transmission OK MailBox0 Flag
Kojto 93:e188a91d3eaa 666 * @arg CAN_FLAG_TXOK1: Transmission OK MailBox1 Flag
Kojto 93:e188a91d3eaa 667 * @arg CAN_FLAG_TXOK2: Transmission OK MailBox2 Flag
Kojto 93:e188a91d3eaa 668 * @arg CAN_FLAG_TME0: Transmit mailbox 0 empty Flag
Kojto 93:e188a91d3eaa 669 * @arg CAN_FLAG_TME1: Transmit mailbox 1 empty Flag
Kojto 93:e188a91d3eaa 670 * @arg CAN_FLAG_TME2: Transmit mailbox 2 empty Flag
Kojto 93:e188a91d3eaa 671 * @arg CAN_FLAG_FMP0: FIFO 0 Message Pending Flag
Kojto 93:e188a91d3eaa 672 * @arg CAN_FLAG_FF0: FIFO 0 Full Flag
Kojto 93:e188a91d3eaa 673 * @arg CAN_FLAG_FOV0: FIFO 0 Overrun Flag
Kojto 93:e188a91d3eaa 674 * @arg CAN_FLAG_FMP1: FIFO 1 Message Pending Flag
Kojto 93:e188a91d3eaa 675 * @arg CAN_FLAG_FF1: FIFO 1 Full Flag
Kojto 93:e188a91d3eaa 676 * @arg CAN_FLAG_FOV1: FIFO 1 Overrun Flag
Kojto 93:e188a91d3eaa 677 * @arg CAN_FLAG_WKU: Wake up Flag
Kojto 93:e188a91d3eaa 678 * @arg CAN_FLAG_SLAKI: Sleep acknowledge Flag
Kojto 93:e188a91d3eaa 679 * @retval The new state of __FLAG__ (TRUE or FALSE).
Kojto 93:e188a91d3eaa 680 */
Kojto 93:e188a91d3eaa 681 #define __HAL_CAN_CLEAR_FLAG(__HANDLE__, __FLAG__) \
Kojto 93:e188a91d3eaa 682 ((((__FLAG__) >> 8U) == 5)? (((__HANDLE__)->Instance->TSR) = (1U << ((__FLAG__) & CAN_FLAG_MASK))): \
Kojto 93:e188a91d3eaa 683 (((__FLAG__) >> 8U) == 2)? (((__HANDLE__)->Instance->RF0R) = (1U << ((__FLAG__) & CAN_FLAG_MASK))): \
Kojto 93:e188a91d3eaa 684 (((__FLAG__) >> 8U) == 4)? (((__HANDLE__)->Instance->RF1R) = (1U << ((__FLAG__) & CAN_FLAG_MASK))): \
Kojto 93:e188a91d3eaa 685 (((__FLAG__) >> 8U) == 1)? (((__HANDLE__)->Instance->MSR) = (1U << ((__FLAG__) & CAN_FLAG_MASK))): 0)
Kojto 93:e188a91d3eaa 686
Kojto 93:e188a91d3eaa 687
Kojto 93:e188a91d3eaa 688 /** @brief Check if the specified CAN interrupt source is enabled or disabled.
Kojto 93:e188a91d3eaa 689 * @param __HANDLE__: specifies the CAN Handle.
Kojto 93:e188a91d3eaa 690 * @param __INTERRUPT__: specifies the CAN interrupt source to check.
Kojto 93:e188a91d3eaa 691 * This parameter can be one of the following values:
Kojto 93:e188a91d3eaa 692 * @arg CAN_IT_TME: Transmit mailbox empty interrupt enable
Kojto 93:e188a91d3eaa 693 * @arg CAN_IT_FMP0: FIFO0 message pending interrupt enablev
Kojto 93:e188a91d3eaa 694 * @arg CAN_IT_FMP1: FIFO1 message pending interrupt enable
Kojto 93:e188a91d3eaa 695 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 93:e188a91d3eaa 696 */
Kojto 93:e188a91d3eaa 697 #define __HAL_CAN_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
Kojto 93:e188a91d3eaa 698
Kojto 93:e188a91d3eaa 699 /**
Kojto 93:e188a91d3eaa 700 * @brief Check the transmission status of a CAN Frame.
Kojto 93:e188a91d3eaa 701 * @param __HANDLE__: specifies the CAN Handle.
Kojto 93:e188a91d3eaa 702 * @param __TRANSMITMAILBOX__: the number of the mailbox that is used for transmission.
Kojto 93:e188a91d3eaa 703 * @retval The new status of transmission (TRUE or FALSE).
Kojto 93:e188a91d3eaa 704 */
Kojto 93:e188a91d3eaa 705 #define __HAL_CAN_TRANSMIT_STATUS(__HANDLE__, __TRANSMITMAILBOX__)\
Kojto 93:e188a91d3eaa 706 (((__TRANSMITMAILBOX__) == CAN_TXMAILBOX_0)? ((((__HANDLE__)->Instance->TSR) & (CAN_TSR_RQCP0 | CAN_TSR_TXOK0 | CAN_TSR_TME0)) == (CAN_TSR_RQCP0 | CAN_TSR_TXOK0 | CAN_TSR_TME0)) :\
Kojto 93:e188a91d3eaa 707 ((__TRANSMITMAILBOX__) == CAN_TXMAILBOX_1)? ((((__HANDLE__)->Instance->TSR) & (CAN_TSR_RQCP1 | CAN_TSR_TXOK1 | CAN_TSR_TME1)) == (CAN_TSR_RQCP1 | CAN_TSR_TXOK1 | CAN_TSR_TME1)) :\
Kojto 93:e188a91d3eaa 708 ((((__HANDLE__)->Instance->TSR) & (CAN_TSR_RQCP2 | CAN_TSR_TXOK2 | CAN_TSR_TME2)) == (CAN_TSR_RQCP2 | CAN_TSR_TXOK2 | CAN_TSR_TME2)))
Kojto 93:e188a91d3eaa 709
Kojto 93:e188a91d3eaa 710
Kojto 93:e188a91d3eaa 711
Kojto 93:e188a91d3eaa 712 /**
Kojto 93:e188a91d3eaa 713 * @brief Release the specified receive FIFO.
Kojto 93:e188a91d3eaa 714 * @param __HANDLE__: CAN handle.
Kojto 93:e188a91d3eaa 715 * @param __FIFONUMBER__: Receive FIFO number, CAN_FIFO0 or CAN_FIFO1.
Kojto 93:e188a91d3eaa 716 * @retval None.
Kojto 93:e188a91d3eaa 717 */
Kojto 93:e188a91d3eaa 718 #define __HAL_CAN_FIFO_RELEASE(__HANDLE__, __FIFONUMBER__) (((__FIFONUMBER__) == CAN_FIFO0)? \
Kojto 93:e188a91d3eaa 719 ((__HANDLE__)->Instance->RF0R |= CAN_RF0R_RFOM0) : ((__HANDLE__)->Instance->RF1R |= CAN_RF1R_RFOM1))
Kojto 93:e188a91d3eaa 720
Kojto 93:e188a91d3eaa 721 /**
Kojto 93:e188a91d3eaa 722 * @brief Cancel a transmit request.
Kojto 93:e188a91d3eaa 723 * @param __HANDLE__: specifies the CAN Handle.
Kojto 93:e188a91d3eaa 724 * @param __TRANSMITMAILBOX__: the number of the mailbox that is used for transmission.
Kojto 93:e188a91d3eaa 725 * @retval None.
Kojto 93:e188a91d3eaa 726 */
Kojto 93:e188a91d3eaa 727 #define __HAL_CAN_CANCEL_TRANSMIT(__HANDLE__, __TRANSMITMAILBOX__)\
Kojto 93:e188a91d3eaa 728 (((__TRANSMITMAILBOX__) == CAN_TXMAILBOX_0)? ((__HANDLE__)->Instance->TSR |= CAN_TSR_ABRQ0) :\
Kojto 93:e188a91d3eaa 729 ((__TRANSMITMAILBOX__) == CAN_TXMAILBOX_1)? ((__HANDLE__)->Instance->TSR |= CAN_TSR_ABRQ1) :\
Kojto 93:e188a91d3eaa 730 ((__HANDLE__)->Instance->TSR |= CAN_TSR_ABRQ2))
Kojto 93:e188a91d3eaa 731
Kojto 93:e188a91d3eaa 732 /**
Kojto 93:e188a91d3eaa 733 * @brief Enable or disables the DBG Freeze for CAN.
Kojto 93:e188a91d3eaa 734 * @param __HANDLE__: specifies the CAN Handle.
Kojto 93:e188a91d3eaa 735 * @param __NEWSTATE__: new state of the CAN peripheral.
Kojto 93:e188a91d3eaa 736 * This parameter can be: ENABLE (CAN reception/transmission is frozen
Kojto 93:e188a91d3eaa 737 * during debug. Reception FIFOs can still be accessed/controlled normally)
Kojto 93:e188a91d3eaa 738 * or DISABLE (CAN is working during debug).
Kojto 93:e188a91d3eaa 739 * @retval None
Kojto 93:e188a91d3eaa 740 */
Kojto 93:e188a91d3eaa 741 #define __HAL_CAN_DBG_FREEZE(__HANDLE__, __NEWSTATE__) (((__NEWSTATE__) == ENABLE)? \
Kojto 93:e188a91d3eaa 742 ((__HANDLE__)->Instance->MCR |= CAN_MCR_DBF) : ((__HANDLE__)->Instance->MCR &= ~CAN_MCR_DBF))
Kojto 93:e188a91d3eaa 743
Kojto 93:e188a91d3eaa 744 /**
Kojto 93:e188a91d3eaa 745 * @}
Kojto 93:e188a91d3eaa 746 */
Kojto 93:e188a91d3eaa 747
Kojto 93:e188a91d3eaa 748 /* Exported functions --------------------------------------------------------*/
Kojto 93:e188a91d3eaa 749 /** @addtogroup CAN_Exported_Functions CAN Exported Functions
Kojto 93:e188a91d3eaa 750 * @{
Kojto 93:e188a91d3eaa 751 */
Kojto 93:e188a91d3eaa 752
Kojto 93:e188a91d3eaa 753 /** @defgroup CAN_Exported_Functions_Group1 Initialization and de-initialization functions
Kojto 93:e188a91d3eaa 754 * @brief Initialization and Configuration functions
Kojto 93:e188a91d3eaa 755 * @{
Kojto 93:e188a91d3eaa 756 */
Kojto 93:e188a91d3eaa 757 /* addtogroup and de-initialization functions *****************************/
Kojto 93:e188a91d3eaa 758 HAL_StatusTypeDef HAL_CAN_Init(CAN_HandleTypeDef* hcan);
Kojto 93:e188a91d3eaa 759 HAL_StatusTypeDef HAL_CAN_ConfigFilter(CAN_HandleTypeDef* hcan, CAN_FilterConfTypeDef* sFilterConfig);
Kojto 93:e188a91d3eaa 760 HAL_StatusTypeDef HAL_CAN_DeInit(CAN_HandleTypeDef* hcan);
Kojto 93:e188a91d3eaa 761 void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan);
Kojto 93:e188a91d3eaa 762 void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan);
Kojto 93:e188a91d3eaa 763 /**
Kojto 93:e188a91d3eaa 764 * @}
Kojto 93:e188a91d3eaa 765 */
Kojto 93:e188a91d3eaa 766
Kojto 93:e188a91d3eaa 767 /** @addtogroup CAN_Exported_Functions_Group2 Input and Output operation functions
Kojto 93:e188a91d3eaa 768 * @brief I/O operation functions
Kojto 93:e188a91d3eaa 769 * @{
Kojto 93:e188a91d3eaa 770 */
Kojto 93:e188a91d3eaa 771 /* IO operation functions *****************************************************/
Kojto 93:e188a91d3eaa 772 HAL_StatusTypeDef HAL_CAN_Transmit(CAN_HandleTypeDef *hcan, uint32_t Timeout);
Kojto 93:e188a91d3eaa 773 HAL_StatusTypeDef HAL_CAN_Transmit_IT(CAN_HandleTypeDef *hcan);
Kojto 93:e188a91d3eaa 774 HAL_StatusTypeDef HAL_CAN_Receive(CAN_HandleTypeDef *hcan, uint8_t FIFONumber, uint32_t Timeout);
Kojto 93:e188a91d3eaa 775 HAL_StatusTypeDef HAL_CAN_Receive_IT(CAN_HandleTypeDef *hcan, uint8_t FIFONumber);
Kojto 93:e188a91d3eaa 776 HAL_StatusTypeDef HAL_CAN_Sleep(CAN_HandleTypeDef *hcan);
Kojto 93:e188a91d3eaa 777 HAL_StatusTypeDef HAL_CAN_WakeUp(CAN_HandleTypeDef *hcan);
Kojto 93:e188a91d3eaa 778 void HAL_CAN_IRQHandler(CAN_HandleTypeDef* hcan);
Kojto 93:e188a91d3eaa 779 void HAL_CAN_TxCpltCallback(CAN_HandleTypeDef* hcan);
Kojto 93:e188a91d3eaa 780 void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef* hcan);
Kojto 93:e188a91d3eaa 781 void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan);
Kojto 93:e188a91d3eaa 782 /**
Kojto 93:e188a91d3eaa 783 * @}
Kojto 93:e188a91d3eaa 784 */
Kojto 93:e188a91d3eaa 785
Kojto 93:e188a91d3eaa 786 /** @addtogroup CAN_Exported_Functions_Group3 Peripheral State and Error functions
Kojto 93:e188a91d3eaa 787 * @brief CAN Peripheral State functions
Kojto 93:e188a91d3eaa 788 * @{
Kojto 93:e188a91d3eaa 789 */
Kojto 93:e188a91d3eaa 790 /* Peripheral State and Error functions ***************************************/
Kojto 93:e188a91d3eaa 791 uint32_t HAL_CAN_GetError(CAN_HandleTypeDef *hcan);
Kojto 93:e188a91d3eaa 792 HAL_CAN_StateTypeDef HAL_CAN_GetState(CAN_HandleTypeDef* hcan);
Kojto 93:e188a91d3eaa 793 /**
Kojto 93:e188a91d3eaa 794 * @}
Kojto 93:e188a91d3eaa 795 */
Kojto 93:e188a91d3eaa 796
Kojto 93:e188a91d3eaa 797 /**
Kojto 93:e188a91d3eaa 798 * @}
Kojto 93:e188a91d3eaa 799 */
Kojto 93:e188a91d3eaa 800
Kojto 93:e188a91d3eaa 801 /**
Kojto 93:e188a91d3eaa 802 * @}
Kojto 93:e188a91d3eaa 803 */
Kojto 93:e188a91d3eaa 804
Kojto 93:e188a91d3eaa 805 /**
Kojto 93:e188a91d3eaa 806 * @}
Kojto 93:e188a91d3eaa 807 */
Kojto 93:e188a91d3eaa 808
Kojto 93:e188a91d3eaa 809 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
Kojto 93:e188a91d3eaa 810 /* STM32F302xC || STM32F303xC || STM32F358xx || */
Kojto 93:e188a91d3eaa 811 /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
Kojto 93:e188a91d3eaa 812 /* STM32F302x8 || */
Kojto 93:e188a91d3eaa 813 /* STM32F373xC || STM32F378xx */
Kojto 93:e188a91d3eaa 814
Kojto 93:e188a91d3eaa 815 #ifdef __cplusplus
Kojto 93:e188a91d3eaa 816 }
Kojto 93:e188a91d3eaa 817 #endif
Kojto 93:e188a91d3eaa 818
Kojto 93:e188a91d3eaa 819 #endif /* __STM32F3xx_CAN_H */
Kojto 93:e188a91d3eaa 820
Kojto 93:e188a91d3eaa 821
Kojto 93:e188a91d3eaa 822 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/