Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 9 | ||
---|---|---|---|
Line 4... | Line 4... | ||
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @brief Header file of CAN HAL module. |
5 | * @brief Header file of CAN HAL module. |
6 | ****************************************************************************** |
6 | ****************************************************************************** |
7 | * @attention |
7 | * @attention |
8 | * |
8 | * |
9 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
9 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
- | 10 | * All rights reserved.</center></h2> |
|
10 | * |
11 | * |
11 | * Redistribution and use in source and binary forms, with or without modification, |
12 | * This software component is licensed by ST under BSD 3-Clause license, |
12 | * are permitted provided that the following conditions are met: |
13 | * the "License"; You may not use this file except in compliance with the |
13 | * 1. Redistributions of source code must retain the above copyright notice, |
- | |
14 | * this list of conditions and the following disclaimer. |
- | |
15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
- | |
16 | * this list of conditions and the following disclaimer in the documentation |
- | |
17 | * and/or other materials provided with the distribution. |
14 | * License. You may obtain a copy of the License at: |
18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
- | |
19 | * may be used to endorse or promote products derived from this software |
15 | * opensource.org/licenses/BSD-3-Clause |
20 | * without specific prior written permission. |
- | |
21 | * |
- | |
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
- | |
23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
- | |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
- | |
25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
- | |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
- | |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
- | |
28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
- | |
29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
- | |
30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
- | |
31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- | |
32 | * |
16 | * |
33 | ****************************************************************************** |
17 | ****************************************************************************** |
34 | */ |
18 | */ |
35 | 19 | ||
36 | /* Define to prevent recursive inclusion -------------------------------------*/ |
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
Line 231... | Line 215... | ||
231 | __IO HAL_CAN_StateTypeDef State; /*!< CAN communication state */ |
215 | __IO HAL_CAN_StateTypeDef State; /*!< CAN communication state */ |
232 | 216 | ||
233 | __IO uint32_t ErrorCode; /*!< CAN Error code. |
217 | __IO uint32_t ErrorCode; /*!< CAN Error code. |
234 | This parameter can be a value of @ref CAN_Error_Code */ |
218 | This parameter can be a value of @ref CAN_Error_Code */ |
235 | 219 | ||
- | 220 | #if USE_HAL_CAN_REGISTER_CALLBACKS == 1 |
|
- | 221 | void (* TxMailbox0CompleteCallback)(struct __CAN_HandleTypeDef *hcan);/*!< CAN Tx Mailbox 0 complete callback */ |
|
- | 222 | void (* TxMailbox1CompleteCallback)(struct __CAN_HandleTypeDef *hcan);/*!< CAN Tx Mailbox 1 complete callback */ |
|
- | 223 | void (* TxMailbox2CompleteCallback)(struct __CAN_HandleTypeDef *hcan);/*!< CAN Tx Mailbox 2 complete callback */ |
|
- | 224 | void (* TxMailbox0AbortCallback)(struct __CAN_HandleTypeDef *hcan); /*!< CAN Tx Mailbox 0 abort callback */ |
|
- | 225 | void (* TxMailbox1AbortCallback)(struct __CAN_HandleTypeDef *hcan); /*!< CAN Tx Mailbox 1 abort callback */ |
|
- | 226 | void (* TxMailbox2AbortCallback)(struct __CAN_HandleTypeDef *hcan); /*!< CAN Tx Mailbox 2 abort callback */ |
|
- | 227 | void (* RxFifo0MsgPendingCallback)(struct __CAN_HandleTypeDef *hcan); /*!< CAN Rx FIFO 0 msg pending callback */ |
|
- | 228 | void (* RxFifo0FullCallback)(struct __CAN_HandleTypeDef *hcan); /*!< CAN Rx FIFO 0 full callback */ |
|
- | 229 | void (* RxFifo1MsgPendingCallback)(struct __CAN_HandleTypeDef *hcan); /*!< CAN Rx FIFO 1 msg pending callback */ |
|
- | 230 | void (* RxFifo1FullCallback)(struct __CAN_HandleTypeDef *hcan); /*!< CAN Rx FIFO 1 full callback */ |
|
- | 231 | void (* SleepCallback)(struct __CAN_HandleTypeDef *hcan); /*!< CAN Sleep callback */ |
|
- | 232 | void (* WakeUpFromRxMsgCallback)(struct __CAN_HandleTypeDef *hcan); /*!< CAN Wake Up from Rx msg callback */ |
|
- | 233 | void (* ErrorCallback)(struct __CAN_HandleTypeDef *hcan); /*!< CAN Error callback */ |
|
- | 234 | ||
- | 235 | void (* MspInitCallback)(struct __CAN_HandleTypeDef *hcan); /*!< CAN Msp Init callback */ |
|
- | 236 | void (* MspDeInitCallback)(struct __CAN_HandleTypeDef *hcan); /*!< CAN Msp DeInit callback */ |
|
- | 237 | ||
- | 238 | #endif /* (USE_HAL_CAN_REGISTER_CALLBACKS) */ |
|
236 | } CAN_HandleTypeDef; |
239 | } CAN_HandleTypeDef; |
237 | 240 | ||
- | 241 | #if USE_HAL_CAN_REGISTER_CALLBACKS == 1 |
|
- | 242 | /** |
|
- | 243 | * @brief HAL CAN common Callback ID enumeration definition |
|
- | 244 | */ |
|
- | 245 | typedef enum |
|
- | 246 | { |
|
- | 247 | HAL_CAN_TX_MAILBOX0_COMPLETE_CB_ID = 0x00U, /*!< CAN Tx Mailbox 0 complete callback ID */ |
|
- | 248 | HAL_CAN_TX_MAILBOX1_COMPLETE_CB_ID = 0x01U, /*!< CAN Tx Mailbox 1 complete callback ID */ |
|
- | 249 | HAL_CAN_TX_MAILBOX2_COMPLETE_CB_ID = 0x02U, /*!< CAN Tx Mailbox 2 complete callback ID */ |
|
- | 250 | HAL_CAN_TX_MAILBOX0_ABORT_CB_ID = 0x03U, /*!< CAN Tx Mailbox 0 abort callback ID */ |
|
- | 251 | HAL_CAN_TX_MAILBOX1_ABORT_CB_ID = 0x04U, /*!< CAN Tx Mailbox 1 abort callback ID */ |
|
- | 252 | HAL_CAN_TX_MAILBOX2_ABORT_CB_ID = 0x05U, /*!< CAN Tx Mailbox 2 abort callback ID */ |
|
- | 253 | HAL_CAN_RX_FIFO0_MSG_PENDING_CB_ID = 0x06U, /*!< CAN Rx FIFO 0 message pending callback ID */ |
|
- | 254 | HAL_CAN_RX_FIFO0_FULL_CB_ID = 0x07U, /*!< CAN Rx FIFO 0 full callback ID */ |
|
- | 255 | HAL_CAN_RX_FIFO1_MSG_PENDING_CB_ID = 0x08U, /*!< CAN Rx FIFO 1 message pending callback ID */ |
|
- | 256 | HAL_CAN_RX_FIFO1_FULL_CB_ID = 0x09U, /*!< CAN Rx FIFO 1 full callback ID */ |
|
- | 257 | HAL_CAN_SLEEP_CB_ID = 0x0AU, /*!< CAN Sleep callback ID */ |
|
- | 258 | HAL_CAN_WAKEUP_FROM_RX_MSG_CB_ID = 0x0BU, /*!< CAN Wake Up fropm Rx msg callback ID */ |
|
- | 259 | HAL_CAN_ERROR_CB_ID = 0x0CU, /*!< CAN Error callback ID */ |
|
- | 260 | ||
- | 261 | HAL_CAN_MSPINIT_CB_ID = 0x0DU, /*!< CAN MspInit callback ID */ |
|
- | 262 | HAL_CAN_MSPDEINIT_CB_ID = 0x0EU, /*!< CAN MspDeInit callback ID */ |
|
- | 263 | ||
- | 264 | } HAL_CAN_CallbackIDTypeDef; |
|
- | 265 | ||
- | 266 | /** |
|
- | 267 | * @brief HAL CAN Callback pointer definition |
|
- | 268 | */ |
|
- | 269 | typedef void (*pCAN_CallbackTypeDef)(CAN_HandleTypeDef *hcan); /*!< pointer to a CAN callback function */ |
|
- | 270 | ||
- | 271 | #endif /* USE_HAL_CAN_REGISTER_CALLBACKS */ |
|
238 | /** |
272 | /** |
239 | * @} |
273 | * @} |
240 | */ |
274 | */ |
241 | 275 | ||
242 | /* Exported constants --------------------------------------------------------*/ |
276 | /* Exported constants --------------------------------------------------------*/ |
Line 259... | Line 293... | ||
259 | #define HAL_CAN_ERROR_BD (0x00000080U) /*!< Bit dominant error */ |
293 | #define HAL_CAN_ERROR_BD (0x00000080U) /*!< Bit dominant error */ |
260 | #define HAL_CAN_ERROR_CRC (0x00000100U) /*!< CRC error */ |
294 | #define HAL_CAN_ERROR_CRC (0x00000100U) /*!< CRC error */ |
261 | #define HAL_CAN_ERROR_RX_FOV0 (0x00000200U) /*!< Rx FIFO0 overrun error */ |
295 | #define HAL_CAN_ERROR_RX_FOV0 (0x00000200U) /*!< Rx FIFO0 overrun error */ |
262 | #define HAL_CAN_ERROR_RX_FOV1 (0x00000400U) /*!< Rx FIFO1 overrun error */ |
296 | #define HAL_CAN_ERROR_RX_FOV1 (0x00000400U) /*!< Rx FIFO1 overrun error */ |
263 | #define HAL_CAN_ERROR_TX_ALST0 (0x00000800U) /*!< TxMailbox 0 transmit failure due to arbitration lost */ |
297 | #define HAL_CAN_ERROR_TX_ALST0 (0x00000800U) /*!< TxMailbox 0 transmit failure due to arbitration lost */ |
264 | #define HAL_CAN_ERROR_TX_TERR0 (0x00001000U) /*!< TxMailbox 1 transmit failure due to tranmit error */ |
298 | #define HAL_CAN_ERROR_TX_TERR0 (0x00001000U) /*!< TxMailbox 1 transmit failure due to transmit error */ |
265 | #define HAL_CAN_ERROR_TX_ALST1 (0x00002000U) /*!< TxMailbox 0 transmit failure due to arbitration lost */ |
299 | #define HAL_CAN_ERROR_TX_ALST1 (0x00002000U) /*!< TxMailbox 0 transmit failure due to arbitration lost */ |
266 | #define HAL_CAN_ERROR_TX_TERR1 (0x00004000U) /*!< TxMailbox 1 transmit failure due to tranmit error */ |
300 | #define HAL_CAN_ERROR_TX_TERR1 (0x00004000U) /*!< TxMailbox 1 transmit failure due to transmit error */ |
267 | #define HAL_CAN_ERROR_TX_ALST2 (0x00008000U) /*!< TxMailbox 0 transmit failure due to arbitration lost */ |
301 | #define HAL_CAN_ERROR_TX_ALST2 (0x00008000U) /*!< TxMailbox 0 transmit failure due to arbitration lost */ |
268 | #define HAL_CAN_ERROR_TX_TERR2 (0x00010000U) /*!< TxMailbox 1 transmit failure due to tranmit error */ |
302 | #define HAL_CAN_ERROR_TX_TERR2 (0x00010000U) /*!< TxMailbox 1 transmit failure due to transmit error */ |
269 | #define HAL_CAN_ERROR_TIMEOUT (0x00020000U) /*!< Timeout error */ |
303 | #define HAL_CAN_ERROR_TIMEOUT (0x00020000U) /*!< Timeout error */ |
270 | #define HAL_CAN_ERROR_NOT_INITIALIZED (0x00040000U) /*!< Peripheral not initialized */ |
304 | #define HAL_CAN_ERROR_NOT_INITIALIZED (0x00040000U) /*!< Peripheral not initialized */ |
271 | #define HAL_CAN_ERROR_NOT_READY (0x00080000U) /*!< Peripheral not ready */ |
305 | #define HAL_CAN_ERROR_NOT_READY (0x00080000U) /*!< Peripheral not ready */ |
272 | #define HAL_CAN_ERROR_NOT_STARTED (0x00100000U) /*!< Peripheral not started */ |
306 | #define HAL_CAN_ERROR_NOT_STARTED (0x00100000U) /*!< Peripheral not started */ |
273 | #define HAL_CAN_ERROR_PARAM (0x00200000U) /*!< Parameter error */ |
307 | #define HAL_CAN_ERROR_PARAM (0x00200000U) /*!< Parameter error */ |
274 | 308 | ||
- | 309 | #if USE_HAL_CAN_REGISTER_CALLBACKS == 1 |
|
- | 310 | #define HAL_CAN_ERROR_INVALID_CALLBACK (0x00400000U) /*!< Invalid Callback error */ |
|
- | 311 | #endif /* USE_HAL_CAN_REGISTER_CALLBACKS */ |
|
275 | #define HAL_CAN_ERROR_INTERNAL (0x00800000U) /*!< Internal error */ |
312 | #define HAL_CAN_ERROR_INTERNAL (0x00800000U) /*!< Internal error */ |
276 | 313 | ||
277 | /** |
314 | /** |
278 | * @} |
315 | * @} |
279 | */ |
316 | */ |
Line 505... | Line 542... | ||
505 | 542 | ||
506 | /** @brief Reset CAN handle state |
543 | /** @brief Reset CAN handle state |
507 | * @param __HANDLE__ CAN handle. |
544 | * @param __HANDLE__ CAN handle. |
508 | * @retval None |
545 | * @retval None |
509 | */ |
546 | */ |
- | 547 | #if USE_HAL_CAN_REGISTER_CALLBACKS == 1 |
|
- | 548 | #define __HAL_CAN_RESET_HANDLE_STATE(__HANDLE__) do{ \ |
|
- | 549 | (__HANDLE__)->State = HAL_CAN_STATE_RESET; \ |
|
- | 550 | (__HANDLE__)->MspInitCallback = NULL; \ |
|
- | 551 | (__HANDLE__)->MspDeInitCallback = NULL; \ |
|
- | 552 | } while(0) |
|
- | 553 | #else |
|
510 | #define __HAL_CAN_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CAN_STATE_RESET) |
554 | #define __HAL_CAN_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CAN_STATE_RESET) |
- | 555 | #endif /*USE_HAL_CAN_REGISTER_CALLBACKS */ |
|
511 | 556 | ||
512 | /** |
557 | /** |
513 | * @brief Enable the specified CAN interrupts. |
558 | * @brief Enable the specified CAN interrupts. |
514 | * @param __HANDLE__ CAN handle. |
559 | * @param __HANDLE__ CAN handle. |
515 | * @param __INTERRUPT__ CAN Interrupt sources to enable. |
560 | * @param __INTERRUPT__ CAN Interrupt sources to enable. |
Line 596... | Line 641... | ||
596 | HAL_StatusTypeDef HAL_CAN_Init(CAN_HandleTypeDef *hcan); |
641 | HAL_StatusTypeDef HAL_CAN_Init(CAN_HandleTypeDef *hcan); |
597 | HAL_StatusTypeDef HAL_CAN_DeInit(CAN_HandleTypeDef *hcan); |
642 | HAL_StatusTypeDef HAL_CAN_DeInit(CAN_HandleTypeDef *hcan); |
598 | void HAL_CAN_MspInit(CAN_HandleTypeDef *hcan); |
643 | void HAL_CAN_MspInit(CAN_HandleTypeDef *hcan); |
599 | void HAL_CAN_MspDeInit(CAN_HandleTypeDef *hcan); |
644 | void HAL_CAN_MspDeInit(CAN_HandleTypeDef *hcan); |
600 | 645 | ||
- | 646 | #if USE_HAL_CAN_REGISTER_CALLBACKS == 1 |
|
- | 647 | /* Callbacks Register/UnRegister functions ***********************************/ |
|
- | 648 | HAL_StatusTypeDef HAL_CAN_RegisterCallback(CAN_HandleTypeDef *hcan, HAL_CAN_CallbackIDTypeDef CallbackID, void (* pCallback)(CAN_HandleTypeDef *_hcan)); |
|
- | 649 | HAL_StatusTypeDef HAL_CAN_UnRegisterCallback(CAN_HandleTypeDef *hcan, HAL_CAN_CallbackIDTypeDef CallbackID); |
|
- | 650 | ||
- | 651 | #endif /* (USE_HAL_CAN_REGISTER_CALLBACKS) */ |
|
601 | /** |
652 | /** |
602 | * @} |
653 | * @} |
603 | */ |
654 | */ |
604 | 655 | ||
605 | /** @addtogroup CAN_Exported_Functions_Group2 Configuration functions |
656 | /** @addtogroup CAN_Exported_Functions_Group2 Configuration functions |