Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
lisa_overo_link_arch.h
Go to the documentation of this file.
1 #ifndef LISA_OVERO_LINK_ARCH_H
2 #define LISA_OVERO_LINK_ARCH_H
3 
4 #include <stm32/spi.h>
5 
6 
7 #define OveroLinkEvent(_data_received_handler, _crc_failed_handler) { \
8  if (overo_link.status == DATA_AVAILABLE) { /* set by DMA interrupt */ \
9  while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE)==RESET); \
10  while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) ==RESET); \
11  while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) ==SET); \
12  overo_link.timeout_cnt = 0; \
13  if((SPI_I2S_GetFlagStatus(SPI1, SPI_FLAG_CRCERR)) == RESET) { \
14  LED_ON(OVERO_LINK_LED_OK); \
15  LED_OFF(OVERO_LINK_LED_KO); \
16  overo_link.msg_cnt++; \
17  _data_received_handler(); \
18  overo_link_arch_prepare_next_transfert(); \
19  } \
20  else { \
21  SPI_Cmd(SPI1, DISABLE); \
22  LED_OFF(OVERO_LINK_LED_OK); \
23  LED_ON(OVERO_LINK_LED_KO); \
24  overo_link.crc_err_cnt++; \
25  overo_link.crc_error = TRUE; \
26  _crc_failed_handler(); \
27  } \
28  overo_link.status = IDLE; \
29  } \
30  if (overo_link.crc_error && /* if we've had a bad crc */ \
31  !GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_4)) { /* and we're not selected anymore */ \
32  overo_link_arch_prepare_next_transfert(); \
33  overo_link.crc_error = FALSE; \
34  } \
35  if (overo_link.timeout && /* if we've had a timeout */ \
36  !GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_4)) { /* and we're not selected anymore */ \
37  overo_link_arch_prepare_next_transfert(); \
38  overo_link.timeout = FALSE; \
39  } \
40  }
41 
42 
43 
44 
45 #endif /* LISA_OVERO_LINK_ARCH_H */