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