```html
|
STM32G474xx HAL用户手册
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32g4xx_hal_fdcan.h 00004 * @author MCD Application Team 00005 * @brief Header file of FDCAN HAL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * Copyright (c) 2019 STMicroelectronics. 00010 * All rights reserved. 00011 * 00012 * This software is licensed under terms that can be found in the LICENSE file 00013 * in the root directory of this software component. 00014 * If no LICENSE file comes with this software, it is provided AS-IS. 00015 * 00016 ****************************************************************************** 00017 */ 00018 00019 /* Define to prevent recursive inclusion -------------------------------------*/ 00020 #ifndef STM32G4xx_HAL_FDCAN_H 00021 #define STM32G4xx_HAL_FDCAN_H 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 /* Includes ------------------------------------------------------------------*/ 00028 #include "stm32g4xx_hal_def.h" 00029 00030 #if defined(FDCAN1) 00031 00032 /** @addtogroup STM32G4xx_HAL_Driver 00033 * @{ 00034 */ 00035 00036 /** @addtogroup FDCAN 00037 * @{ 00038 */ 00039 00040 /* Exported types ------------------------------------------------------------*/ 00041 /** @defgroup FDCAN_Exported_Types FDCAN Exported Types 00042 * @{ 00043 */ 00044 00045 /** 00046 * @brief HAL State structures definition 00047 */ 00048 typedef enum 00049 { 00050 HAL_FDCAN_STATE_RESET = 0x00U, /*!< FDCAN not yet initialized or disabled */ 00051 HAL_FDCAN_STATE_READY = 0x01U, /*!< FDCAN initialized and ready for use */ 00052 HAL_FDCAN_STATE_BUSY = 0x02U, /*!< FDCAN process is ongoing */ 00053 HAL_FDCAN_STATE_ERROR = 0x03U /*!< FDCAN error state */ 00054 } HAL_FDCAN_StateTypeDef; 00055 00056 /** 00057 * @brief FDCAN Init structure definition 00058 */ 00059 typedef struct 00060 { 00061 uint32_t ClockDivider; /*!< Specifies the FDCAN kernel clock divider. 00062 The clock is common to all FDCAN instances. 00063 This parameter is applied only at initialisation of 00064 first FDCAN instance. 00065 This parameter can be a value of @ref FDCAN_clock_divider. */ 00066 00067 uint32_t FrameFormat; /*!< Specifies the FDCAN frame format. 00068 This parameter can be a value of @ref FDCAN_frame_format */ 00069 00070 uint32_t Mode; /*!< Specifies the FDCAN mode. 00071 This parameter can be a value of @ref FDCAN_operating_mode */ 00072 00073 FunctionalState AutoRetransmission; /*!< Enable or disable the automatic retransmission mode. 00074 This parameter can be set to ENABLE or DISABLE */ 00075 00076 FunctionalState TransmitPause; /*!< Enable or disable the Transmit Pause feature. 00077 This parameter can be set to ENABLE or DISABLE */ 00078 00079 FunctionalState ProtocolException; /*!< Enable or disable the Protocol Exception Handling. 00080 This parameter can be set to ENABLE or DISABLE */ 00081 00082 uint32_t NominalPrescaler; /*!< Specifies the value by which the oscillator frequency is 00083 divided for generating the nominal bit time quanta. 00084 This parameter must be a number between 1 and 512 */ 00085 00086 uint32_t NominalSyncJumpWidth; /*!< Specifies the maximum number of time quanta the FDCAN 00087 hardware is allowed to lengthen or shorten a bit to perform 00088 resynchronization. 00089 This parameter must be a number between 1 and 128 */ 00090 00091 uint32_t NominalTimeSeg1; /*!< Specifies the number of time quanta in Bit Segment 1. 00092 This parameter must be a number between 2 and 256 */ 00093 00094 uint32_t NominalTimeSeg2; /*!< Specifies the number of time quanta in Bit Segment 2. 00095 This parameter must be a number between 2 and 128 */ 00096 00097 uint32_t DataPrescaler; /*!< Specifies the value by which the oscillator frequency is 00098 divided for generating the data bit time quanta. 00099 This parameter must be a number between 1 and 32 */ 00100 00101 uint32_t DataSyncJumpWidth; /*!< Specifies the maximum number of time quanta the FDCAN 00102 hardware is allowed to lengthen or shorten a data bit to 00103 perform resynchronization. 00104 This parameter must be a number between 1 and 16 */ 00105 00106 uint32_t DataTimeSeg1; /*!< Specifies the number of time quanta in Data Bit Segment 1. 00107 This parameter must be a number between 1 and 32 */ 00108 00109 uint32_t DataTimeSeg2; /*!< Specifies the number of time quanta in Data Bit Segment 2. 00110 This parameter must be a number between 1 and 16 */ 00111 00112 uint32_t StdFiltersNbr; /*!< Specifies the number of standard Message ID filters. 00113 This parameter must be a number between 0 and 28 */ 00114 00115 uint32_t ExtFiltersNbr; /*!< Specifies the number of extended Message ID filters. 00116 This parameter must be a number between 0 and 8 */ 00117 00118 uint32_t TxFifoQueueMode; /*!< Tx FIFO/Queue Mode selection. 00119 This parameter can be a value of @ref FDCAN_txFifoQueue_Mode */ 00120 00121 } FDCAN_InitTypeDef; 00122 00123 /** 00124 * @brief FDCAN filter structure definition 00125 */ 00126 typedef struct 00127 { 00128 uint32_t IdType; /*!< Specifies the identifier type. 00129 This parameter can be a value of @ref FDCAN_id_type */ 00130 00131 uint32_t FilterIndex; /*!< Specifies the filter which will be initialized. 00132 This parameter must be a number between: 00133 - 0 and (SRAMCAN_FLS_NBR-1), if IdType is FDCAN_STANDARD_ID 00134 - 0 and (SRAMCAN_FLE_NBR-1), if IdType is FDCAN_EXTENDED_ID */ 00135 00136 uint32_t FilterType; /*!< Specifies the filter type. 00137 This parameter can be a value of @ref FDCAN_filter_type. 00138 The value FDCAN_FILTER_RANGE_NO_EIDM is permitted 00139 only when IdType is FDCAN_EXTENDED_ID. */ 00140 00141 uint32_t FilterConfig; /*!< Specifies the filter configuration. 00142 This parameter can be a value of @ref FDCAN_filter_config */ 00143 00144 uint32_t FilterID1; /*!< Specifies the filter identification 1. 00145 This parameter must be a number between: 00146 - 0 and 0x7FF, if IdType is FDCAN_STANDARD_ID 00147 - 0 and 0x1FFFFFFF, if IdType is FDCAN_EXTENDED_ID */ 00148 00149 uint32_t FilterID2; /*!< Specifies the filter identification 2. 00150 This parameter must be a number between: 00151 - 0 and 0x7FF, if IdType is FDCAN_STANDARD_ID 00152 - 0 and 0x1FFFFFFF, if IdType is FDCAN_EXTENDED_ID */ 00153 00154 } FDCAN_FilterTypeDef; 00155 00156 /** 00157 * @brief FDCAN Tx header structure definition 00158 */ 00159 typedef struct 00160 { 00161 uint32_t Identifier; /*!< Specifies the identifier. 00162 This parameter must be a number between: 00163 - 0 and 0x7FF, if IdType is FDCAN_STANDARD_ID 00164 - 0 and 0x1FFFFFFF, if IdType is FDCAN_EXTENDED_ID */ 00165 00166 uint32_t IdType; /*!< Specifies the identifier type for the message that will be 00167 transmitted. 00168 This parameter can be a value of @ref FDCAN_id_type */ 00169 00170 uint32_t TxFrameType; /*!< Specifies the frame type of the message that will be transmitted. 00171 This parameter can be a value of @ref FDCAN_frame_type */ 00172 00173 uint32_t DataLength; /*!< Specifies the length of the frame that will be transmitted. 00174 This parameter can be a value of @ref FDCAN_data_length_code */ 00175 00176 uint32_t ErrorStateIndicator; /*!< Specifies the error state indicator. 00177 This parameter can be a value of @ref FDCAN_error_state_indicator */