The official mbed C/C SDK provides the software platform and libraries to build your applications.

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Feb 03 15:31:20 2015 +0000
Revision:
93:e188a91d3eaa
Release 93 of the mbed library

Main changes:

- Renesas RZ_A1H bugfixes - i2c, ticker
- new targets - Nucleo F303RE, Nucleo F070RB, BLE SMURFS,
Dragonfly 411RE,
- BusXXX - is connected method, plus operators addition
- LPC8xx - I2c fixes
- timestamp_t reverted to uint32_t
- RTX - fixes regarding stack (alignment, magic word)

Who changed what in which revision?

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