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