From d84b6c4fff9cbf40263140a522fca3ae6bdfd57c Mon Sep 17 00:00:00 2001 From: Avi Levkovich Date: Wed, 9 May 2018 11:44:11 +0300 Subject: update FPGA_Comm.h + Add timeout for busy SPI --- .../Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Software/Embedded_SW/Embedded/Modules') diff --git a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c index e7b75cc9d..deb5cbf75 100644 --- a/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c +++ b/Software/Embedded_SW/Embedded/Modules/Stubs_Handler/Stub_Motor.c @@ -563,7 +563,17 @@ void Stub_MotorMovRequest(MessageContainer* requestContainer) response.position = Get_Param(x_ABS_POS); response.has_position = true; - while(SSIBusy(SSI2_BASE)){}; + //while(SSIBusy(SSI2_BASE)){}; + uint32_t timeout = SSI_SPI_TIMEOUT; + + while(SSIBusy(SSI2_BASE)) + { + timeout = timeout--; + if(timeout == 0) + { + return ERROR; + } + } read_status = Get_and_Clear_Status(); -- cgit v1.3.1