Skip to content

Commit 9a1d055

Browse files
committed
Optimize the use of the status value
1 parent 897625c commit 9a1d055

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

targets/TARGET_STM/can_api.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ int can_frequency(can_t *obj, int f)
198198
int btr = can_speed(pclk, (unsigned int)f, 1);
199199
CAN_TypeDef *can = (CAN_TypeDef *)(obj->can);
200200
uint32_t tickstart = 0;
201-
int status = 0;
201+
int status = 1;
202202

203203
if (btr > 0) {
204204
can->MCR |= CAN_MCR_INRQ ;
@@ -211,15 +211,12 @@ int can_frequency(can_t *obj, int f)
211211
while ((can->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) {
212212
if((HAL_GetTick() - tickstart ) > 2)
213213
{
214-
status = HAL_CAN_STATE_TIMEOUT;
214+
status = 0;
215215
break;
216216
}
217217
}
218-
if (status !=0) {
218+
if (status ==0) {
219219
error("can ESR 0x%04x.%04x + timeout status %d", (can->ESR&0XFFFF0000)>>16, (can->ESR&0XFFFF), status);
220-
status=0;
221-
} else {
222-
status=1; //mbed OK value
223220
}
224221
} else {
225222
status=0;

0 commit comments

Comments
 (0)