Skip to content

Commit

Permalink
stm32cube/src/stm32f4xx_hal_can.c fixed CAN_TIMEOUT_VALUE to 1000(100…
Browse files Browse the repository at this point in the history
…ms) and added Timeout exit when USER_BUTTON is pressed
  • Loading branch information
bvernoux committed Oct 2, 2016
1 parent 4d1515a commit 47a6b10
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions drv/stm32cube/src/stm32f4xx_hal_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
******************************************************************************
* @file stm32f4xx_hal_can.c
* @author MCD Application Team
* BVX fixed warnings on unused parameter
* BVX added Timeout exit when USER_BUTTON is pressed, fix warnings
* @version V1.5.1
* @date 01-July-2016
* @brief This file provides firmware functions to manage the following
Expand Down Expand Up @@ -124,7 +124,7 @@
/** @addtogroup CAN_Private_Constants
* @{
*/
#define CAN_TIMEOUT_VALUE 10U
#define CAN_TIMEOUT_VALUE 1000U
/**
* @}
*/
Expand Down Expand Up @@ -216,7 +216,7 @@ HAL_StatusTypeDef HAL_CAN_Init(CAN_HandleTypeDef* hcan)
/* Wait the acknowledge */
while((hcan->Instance->MSR & CAN_MSR_INAK) != CAN_MSR_INAK)
{
if((HAL_GetTick() - tickstart ) > CAN_TIMEOUT_VALUE)
if((USER_BUTTON) || (HAL_GetTick() - tickstart ) > CAN_TIMEOUT_VALUE)
{
hcan->State= HAL_CAN_STATE_TIMEOUT;
/* Process unlocked */
Expand Down Expand Up @@ -308,7 +308,7 @@ HAL_StatusTypeDef HAL_CAN_Init(CAN_HandleTypeDef* hcan)
/* Wait the acknowledge */
while((hcan->Instance->MSR & CAN_MSR_INAK) == CAN_MSR_INAK)
{
if((HAL_GetTick() - tickstart ) > CAN_TIMEOUT_VALUE)
if((USER_BUTTON) || (HAL_GetTick() - tickstart ) > CAN_TIMEOUT_VALUE)
{
hcan->State= HAL_CAN_STATE_TIMEOUT;
/* Process unlocked */
Expand Down Expand Up @@ -631,7 +631,7 @@ HAL_StatusTypeDef HAL_CAN_Transmit(CAN_HandleTypeDef* hcan, uint32_t Timeout)
/* Check for the Timeout */
if(Timeout != HAL_MAX_DELAY)
{
if((Timeout == 0U)||((HAL_GetTick() - tickstart ) > Timeout))
if((USER_BUTTON) || (Timeout == 0U) || ((HAL_GetTick() - tickstart ) > Timeout))
{
hcan->State = HAL_CAN_STATE_TIMEOUT;
/* Process unlocked */
Expand Down Expand Up @@ -822,7 +822,7 @@ HAL_StatusTypeDef HAL_CAN_Receive(CAN_HandleTypeDef* hcan, uint8_t FIFONumber, u
/* Check for the Timeout */
if(Timeout != HAL_MAX_DELAY)
{
if((Timeout == 0U)||((HAL_GetTick() - tickstart ) > Timeout))
if((USER_BUTTON) || (Timeout == 0U) || ((HAL_GetTick() - tickstart ) > Timeout))
{
hcan->State = HAL_CAN_STATE_TIMEOUT;
/* Process unlocked */
Expand Down Expand Up @@ -999,7 +999,7 @@ HAL_StatusTypeDef HAL_CAN_Sleep(CAN_HandleTypeDef* hcan)
/* Wait the acknowledge */
while((hcan->Instance->MSR & (CAN_MSR_SLAK|CAN_MSR_INAK)) != CAN_MSR_SLAK)
{
if((HAL_GetTick() - tickstart) > CAN_TIMEOUT_VALUE)
if((USER_BUTTON) || (HAL_GetTick() - tickstart) > CAN_TIMEOUT_VALUE)
{
hcan->State = HAL_CAN_STATE_TIMEOUT;
/* Process unlocked */
Expand Down Expand Up @@ -1044,7 +1044,7 @@ HAL_StatusTypeDef HAL_CAN_WakeUp(CAN_HandleTypeDef* hcan)
/* Sleep mode status */
while((hcan->Instance->MSR & CAN_MSR_SLAK) == CAN_MSR_SLAK)
{
if((HAL_GetTick() - tickstart) > CAN_TIMEOUT_VALUE)
if((USER_BUTTON) || (HAL_GetTick() - tickstart) > CAN_TIMEOUT_VALUE)
{
hcan->State= HAL_CAN_STATE_TIMEOUT;
/* Process unlocked */
Expand Down

0 comments on commit 47a6b10

Please sign in to comment.