[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paparazzi-commits] [5349] removed a race condition in the timeout detec
From: |
antoine drouin |
Subject: |
[paparazzi-commits] [5349] removed a race condition in the timeout detection of the overo_link |
Date: |
Thu, 12 Aug 2010 21:36:29 +0000 |
Revision: 5349
http://svn.sv.gnu.org/viewvc/?view=rev&root=paparazzi&revision=5349
Author: poine
Date: 2010-08-12 21:36:29 +0000 (Thu, 12 Aug 2010)
Log Message:
-----------
removed a race condition in the timeout detection of the overo_link
Modified Paths:
--------------
paparazzi3/trunk/sw/airborne/lisa/arch/stm32/lisa_overo_link_arch.h
paparazzi3/trunk/sw/airborne/lisa/lisa_overo_link.c
paparazzi3/trunk/sw/airborne/lisa/lisa_overo_link.h
Modified: paparazzi3/trunk/sw/airborne/lisa/arch/stm32/lisa_overo_link_arch.h
===================================================================
--- paparazzi3/trunk/sw/airborne/lisa/arch/stm32/lisa_overo_link_arch.h
2010-08-12 20:28:00 UTC (rev 5348)
+++ paparazzi3/trunk/sw/airborne/lisa/arch/stm32/lisa_overo_link_arch.h
2010-08-12 21:36:29 UTC (rev 5349)
@@ -5,11 +5,11 @@
#define OveroLinkEvent(_data_received_handler, _crc_failed_handler) { \
- if (overo_link.status == DATA_AVAILABLE) { /* set by DMA
interrupt */ \
+ if (overo_link.status == DATA_AVAILABLE) { /* set by DMA interrupt
*/ \
while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE)==RESET); \
while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) ==RESET); \
while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) ==SET); \
- overo_link.timeout = 0; \
+ overo_link.timeout_cnt = 0; \
if((SPI_I2S_GetFlagStatus(SPI1, SPI_FLAG_CRCERR)) == RESET) { \
LED_ON(OVERO_LINK_LED_OK); \
LED_OFF(OVERO_LINK_LED_KO); \
@@ -32,6 +32,11 @@
overo_link_arch_prepare_next_transfert();
\
overo_link.crc_error = FALSE; \
} \
+ if (overo_link.timeout && /* if we've had a timeout
*/ \
+ !GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_4)) { /* and we're not selected
anymore */ \
+ overo_link_arch_prepare_next_transfert();
\
+ overo_link.timeout = FALSE; \
+ } \
}
Modified: paparazzi3/trunk/sw/airborne/lisa/lisa_overo_link.c
===================================================================
--- paparazzi3/trunk/sw/airborne/lisa/lisa_overo_link.c 2010-08-12 20:28:00 UTC
(rev 5348)
+++ paparazzi3/trunk/sw/airborne/lisa/lisa_overo_link.c 2010-08-12 21:36:29 UTC
(rev 5349)
@@ -4,10 +4,11 @@
void overo_link_init(void) {
overo_link.status = IDLE;
- overo_link.timeout = OVERO_LINK_TIMEOUT-1;
+ overo_link.timeout_cnt = OVERO_LINK_TIMEOUT-1;
overo_link.msg_cnt = 0;
overo_link.crc_err_cnt = 0;
overo_link.crc_error = FALSE;
+ overo_link.timeout = FALSE;
overo_link_arch_init();
}
Modified: paparazzi3/trunk/sw/airborne/lisa/lisa_overo_link.h
===================================================================
--- paparazzi3/trunk/sw/airborne/lisa/lisa_overo_link.h 2010-08-12 20:28:00 UTC
(rev 5348)
+++ paparazzi3/trunk/sw/airborne/lisa/lisa_overo_link.h 2010-08-12 21:36:29 UTC
(rev 5349)
@@ -21,8 +21,10 @@
struct OVERO_LINK_MSG_DOWN msg;
uint8_t array[sizeof(union AutopilotMessage)];
} down;
+ uint8_t timeout_cnt;
+ /* flags used to reset hardware */
+ uint8_t crc_error;
uint8_t timeout;
- uint8_t crc_error;
};
extern struct LisaOveroLink overo_link;
@@ -36,21 +38,44 @@
#include "lisa_overo_link_arch.h"
+#if 0 /* that doesn't work yet */
#define OveroLinkPeriodic(_timeout_handler) { \
- if (overo_link.timeout < OVERO_LINK_TIMEOUT) \
- overo_link.timeout++; \
+ if (overo_link.timeout_cnt < OVERO_LINK_TIMEOUT) \
+ overo_link.timeout_cnt++;
\
else { \
if (overo_link.status != LOST && overo_link.status != DATA_AVAILABLE ) {
\
+ SPI_Cmd(SPI1, DISABLE); \
overo_link.status = LOST; \
LED_OFF(OVERO_LINK_LED_OK); \
LED_ON(OVERO_LINK_LED_KO); \
+ overo_link.timeout = TRUE; \
_timeout_handler(); \
}
\
} \
}
+#else /* this one does */
+#define OveroLinkPeriodic(_timeout_handler) { \
+ if (overo_link.timeout_cnt < OVERO_LINK_TIMEOUT) \
+ overo_link.timeout_cnt++;
\
+ else { \
+ __disable_irq(); \
+ if (overo_link.status != LOST && overo_link.status != DATA_AVAILABLE ) {
\
+ overo_link.status = LOST; \
+ __enable_irq(); \
+ LED_OFF(OVERO_LINK_LED_OK); \
+ LED_ON(OVERO_LINK_LED_KO); \
+ _timeout_handler(); \
+ }
\
+ __enable_irq(); \
+ } \
+ }
+#endif
+
+
+
/*
*
* Passing telemetry through Overo Link
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paparazzi-commits] [5349] removed a race condition in the timeout detection of the overo_link,
antoine drouin <=