瀏覽代碼

[HAL][CAN] Clarify pin configuration in driver header by removing open-drain info

Tasnim 2 年之前
父節點
當前提交
eb546773ea
共有 1 個文件被更改,包括 20 次插入21 次删除
  1. 20 21
      Src/stm32l4xx_hal_can.c

+ 20 - 21
Src/stm32l4xx_hal_can.c

@@ -33,7 +33,7 @@
          (++) Enable the CAN interface clock using __HAL_RCC_CANx_CLK_ENABLE()
          (++) Enable the CAN interface clock using __HAL_RCC_CANx_CLK_ENABLE()
          (++) Configure CAN pins
          (++) Configure CAN pins
              (+++) Enable the clock for the CAN GPIOs
              (+++) Enable the clock for the CAN GPIOs
-             (+++) Configure CAN pins as alternate function open-drain
+             (+++) Configure CAN pins as alternate function
          (++) In case of using interrupts (e.g. HAL_CAN_ActivateNotification())
          (++) In case of using interrupts (e.g. HAL_CAN_ActivateNotification())
              (+++) Configure the CAN interrupt priority using
              (+++) Configure the CAN interrupt priority using
                    HAL_NVIC_SetPriority()
                    HAL_NVIC_SetPriority()
@@ -235,6 +235,7 @@
   * @{
   * @{
   */
   */
 #define CAN_TIMEOUT_VALUE 10U
 #define CAN_TIMEOUT_VALUE 10U
+#define CAN_WAKEUP_TIMEOUT_COUNTER 1000000U
 /**
 /**
   * @}
   * @}
   */
   */
@@ -248,8 +249,8 @@
   */
   */
 
 
 /** @defgroup CAN_Exported_Functions_Group1 Initialization and de-initialization functions
 /** @defgroup CAN_Exported_Functions_Group1 Initialization and de-initialization functions
- *  @brief    Initialization and Configuration functions
- *
+  * @brief    Initialization and Configuration functions
+  *
 @verbatim
 @verbatim
   ==============================================================================
   ==============================================================================
               ##### Initialization and de-initialization functions #####
               ##### Initialization and de-initialization functions #####
@@ -328,7 +329,7 @@ HAL_StatusTypeDef HAL_CAN_Init(CAN_HandleTypeDef *hcan)
     /* Init the low level hardware: CLOCK, NVIC */
     /* Init the low level hardware: CLOCK, NVIC */
     HAL_CAN_MspInit(hcan);
     HAL_CAN_MspInit(hcan);
   }
   }
-#endif /* (USE_HAL_CAN_REGISTER_CALLBACKS) */
+#endif /* USE_HAL_CAN_REGISTER_CALLBACKS */
 
 
   /* Request initialisation */
   /* Request initialisation */
   SET_BIT(hcan->Instance->MCR, CAN_MCR_INRQ);
   SET_BIT(hcan->Instance->MCR, CAN_MCR_INRQ);
@@ -482,7 +483,7 @@ HAL_StatusTypeDef HAL_CAN_DeInit(CAN_HandleTypeDef *hcan)
 #else
 #else
   /* DeInit the low level hardware: CLOCK, NVIC */
   /* DeInit the low level hardware: CLOCK, NVIC */
   HAL_CAN_MspDeInit(hcan);
   HAL_CAN_MspDeInit(hcan);
-#endif /* (USE_HAL_CAN_REGISTER_CALLBACKS) */
+#endif /* USE_HAL_CAN_REGISTER_CALLBACKS */
 
 
   /* Reset the CAN peripheral */
   /* Reset the CAN peripheral */
   SET_BIT(hcan->Instance->MCR, CAN_MCR_RESET);
   SET_BIT(hcan->Instance->MCR, CAN_MCR_RESET);
@@ -814,8 +815,8 @@ HAL_StatusTypeDef HAL_CAN_UnRegisterCallback(CAN_HandleTypeDef *hcan, HAL_CAN_Ca
   */
   */
 
 
 /** @defgroup CAN_Exported_Functions_Group2 Configuration functions
 /** @defgroup CAN_Exported_Functions_Group2 Configuration functions
- *  @brief    Configuration functions.
- *
+  * @brief    Configuration functions.
+  *
 @verbatim
 @verbatim
   ==============================================================================
   ==============================================================================
               ##### Configuration functions #####
               ##### Configuration functions #####
@@ -868,7 +869,7 @@ HAL_StatusTypeDef HAL_CAN_ConfigFilter(CAN_HandleTypeDef *hcan, const CAN_Filter
 
 
     /* Check the parameters */
     /* Check the parameters */
     assert_param(IS_CAN_FILTER_BANK_SINGLE(sFilterConfig->FilterBank));
     assert_param(IS_CAN_FILTER_BANK_SINGLE(sFilterConfig->FilterBank));
-#endif
+#endif /* CAN3 */
 
 
     /* Initialisation mode for the filter */
     /* Initialisation mode for the filter */
     SET_BIT(can_ip->FMR, CAN_FMR_FINIT);
     SET_BIT(can_ip->FMR, CAN_FMR_FINIT);
@@ -878,7 +879,7 @@ HAL_StatusTypeDef HAL_CAN_ConfigFilter(CAN_HandleTypeDef *hcan, const CAN_Filter
     CLEAR_BIT(can_ip->FMR, CAN_FMR_CAN2SB);
     CLEAR_BIT(can_ip->FMR, CAN_FMR_CAN2SB);
     SET_BIT(can_ip->FMR, sFilterConfig->SlaveStartFilterBank << CAN_FMR_CAN2SB_Pos);
     SET_BIT(can_ip->FMR, sFilterConfig->SlaveStartFilterBank << CAN_FMR_CAN2SB_Pos);
 
 
-#endif
+#endif /* CAN3 */
     /* Convert filter number into bit position */
     /* Convert filter number into bit position */
     filternbrbitpos = (uint32_t)1 << (sFilterConfig->FilterBank & 0x1FU);
     filternbrbitpos = (uint32_t)1 << (sFilterConfig->FilterBank & 0x1FU);
 
 
@@ -970,8 +971,8 @@ HAL_StatusTypeDef HAL_CAN_ConfigFilter(CAN_HandleTypeDef *hcan, const CAN_Filter
   */
   */
 
 
 /** @defgroup CAN_Exported_Functions_Group3 Control functions
 /** @defgroup CAN_Exported_Functions_Group3 Control functions
- *  @brief    Control functions
- *
+  * @brief    Control functions
+  *
 @verbatim
 @verbatim
   ==============================================================================
   ==============================================================================
                       ##### Control functions #####
                       ##### Control functions #####
@@ -1143,7 +1144,6 @@ HAL_StatusTypeDef HAL_CAN_RequestSleep(CAN_HandleTypeDef *hcan)
 HAL_StatusTypeDef HAL_CAN_WakeUp(CAN_HandleTypeDef *hcan)
 HAL_StatusTypeDef HAL_CAN_WakeUp(CAN_HandleTypeDef *hcan)
 {
 {
   __IO uint32_t count = 0;
   __IO uint32_t count = 0;
-  uint32_t timeout = 1000000U;
   HAL_CAN_StateTypeDef state = hcan->State;
   HAL_CAN_StateTypeDef state = hcan->State;
 
 
   if ((state == HAL_CAN_STATE_READY) ||
   if ((state == HAL_CAN_STATE_READY) ||
@@ -1159,15 +1159,14 @@ HAL_StatusTypeDef HAL_CAN_WakeUp(CAN_HandleTypeDef *hcan)
       count++;
       count++;
 
 
       /* Check if timeout is reached */
       /* Check if timeout is reached */
-      if (count > timeout)
+      if (count > CAN_WAKEUP_TIMEOUT_COUNTER)
       {
       {
         /* Update error code */
         /* Update error code */
         hcan->ErrorCode |= HAL_CAN_ERROR_TIMEOUT;
         hcan->ErrorCode |= HAL_CAN_ERROR_TIMEOUT;
 
 
         return HAL_ERROR;
         return HAL_ERROR;
       }
       }
-    }
-    while ((hcan->Instance->MSR & CAN_MSR_SLAK) != 0U);
+    } while ((hcan->Instance->MSR & CAN_MSR_SLAK) != 0U);
 
 
     /* Return function status */
     /* Return function status */
     return HAL_OK;
     return HAL_OK;
@@ -1608,8 +1607,8 @@ uint32_t HAL_CAN_GetRxFifoFillLevel(const CAN_HandleTypeDef *hcan, uint32_t RxFi
   */
   */
 
 
 /** @defgroup CAN_Exported_Functions_Group4 Interrupts management
 /** @defgroup CAN_Exported_Functions_Group4 Interrupts management
- *  @brief    Interrupts management
- *
+  * @brief    Interrupts management
+  *
 @verbatim
 @verbatim
   ==============================================================================
   ==============================================================================
                        ##### Interrupts management #####
                        ##### Interrupts management #####
@@ -2074,8 +2073,8 @@ void HAL_CAN_IRQHandler(CAN_HandleTypeDef *hcan)
   */
   */
 
 
 /** @defgroup CAN_Exported_Functions_Group5 Callback functions
 /** @defgroup CAN_Exported_Functions_Group5 Callback functions
- *  @brief   CAN Callback functions
- *
+  * @brief   CAN Callback functions
+  *
 @verbatim
 @verbatim
   ==============================================================================
   ==============================================================================
                           ##### Callback functions #####
                           ##### Callback functions #####
@@ -2324,8 +2323,8 @@ __weak void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan)
   */
   */
 
 
 /** @defgroup CAN_Exported_Functions_Group6 Peripheral State and Error functions
 /** @defgroup CAN_Exported_Functions_Group6 Peripheral State and Error functions
- *  @brief   CAN Peripheral State functions
- *
+  * @brief   CAN Peripheral State functions
+  *
 @verbatim
 @verbatim
   ==============================================================================
   ==============================================================================
             ##### Peripheral State and Error functions #####
             ##### Peripheral State and Error functions #####