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