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