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