[X9D] Sport driver fixed (thanks to Adela, 12 minutes without WDT reboot ...)

This commit is contained in:
bsongis
2013-03-21 07:35:11 +00:00
parent 781b3c6188
commit c6d6c7f66d
4 changed files with 39 additions and 27 deletions
+34 -9
View File
@@ -39,7 +39,32 @@
#include <inttypes.h>
#if defined(DEBUG) && !defined(SIMU)
#if defined(SIMU)
#define TRACE_DEBUG(...) { printf("-D- " __VA_ARGS__); fflush(stdout); }
#define TRACE_DEBUG_WP(...) { printf(__VA_ARGS__); fflush(stdout); }
#define TRACE_INFO(...) { printf("-I- " __VA_ARGS__); fflush(stdout); }
#define TRACE_INFO_WP(...) { printf(__VA_ARGS__); fflush(stdout); }
#define TRACE_WARNING(...) { printf("-W- " __VA_ARGS__); fflush(stdout); }
#define TRACE_WARNING_WP(...) { printf(__VA_ARGS__); fflush(stdout); }
#define TRACE_ERROR(...) { printf("-E- " __VA_ARGS__); fflush(stdout); }
inline void dump(unsigned char *data, unsigned int size)
{
printf("DUMP %d bytes ...\n\r", size);
unsigned int i = 0, j=0;
while (i*32+j < size) {
printf("%.2X ", data[i*32+j]);
j++;
if (j==32) {
i++; j=0;
printf("\n\r");
}
}
printf("\n\r");
}
#define DUMP(data, size) dump(data, size)
#elif defined(DEBUG)
#ifdef __cplusplus
extern "C" {
@@ -67,14 +92,14 @@ void debugTx(void);
#else
#define TRACE_DEBUG(...) { }
#define TRACE_DEBUG_WP(...) { }
#define TRACE_INFO(...) { }
#define TRACE_INFO_WP(...) { }
#define TRACE_WARNING(...) { }
#define TRACE_WARNING_WP(...) { }
#define TRACE_ERROR(...) { }
#define DUMP(...) { }
#define TRACE_DEBUG(...) { }
#define TRACE_DEBUG_WP(...) { }
#define TRACE_INFO(...) { }
#define TRACE_INFO_WP(...) { }
#define TRACE_WARNING(...) { }
#define TRACE_WARNING_WP(...) { }
#define TRACE_ERROR(...) { }
#define DUMP(...) { }
#endif
-3
View File
@@ -297,9 +297,6 @@ void displayTopBar()
/* The inside of the RSSI gauge */
count = min(frskyData.rssi[0].value, frskyData.rssi[1].value) / 10;
displayTopBarGauge(BAR_RSSI_X+10, count, (frskyData.rssi[0].value < getRssiAlarmValue(0)) || (frskyData.rssi[1].value < getRssiAlarmValue(1)));
// Debug - SPORTT receive counter
extern uint16_t tmp;
lcd_outdezAtt(120,2,tmp);
}
#endif
+2
View File
@@ -419,6 +419,8 @@ void power_on (void)
/* enable DMA clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA_SD, ENABLE);
#endif
(void) dummyread; // Discard value - prevents compiler warning
}
static
void power_off (void)
+3 -15
View File
@@ -36,8 +36,6 @@
#include "../open9x.h"
uint16_t tmp=0; // Debug - received bytes counter
void sportInit(void)
{
USART_InitTypeDef USART_InitStructure;
@@ -91,20 +89,10 @@ void sportPutc(const char c)
extern "C" void USART2_IRQHandler()
{
uint16_t data;
tmp++; // Debug - received bytes counter
if(USART_GetFlagStatus(SPORT, USART_FLAG_RXNE))
if (USART_GetFlagStatus(SPORT, USART_FLAG_RXNE) || USART_GetFlagStatus(SPORT, USART_FLAG_ORE)) {
data = USART_ReceiveData(SPORT);
USART_ClearFlag(SPORT,USART_FLAG_RXNE); // Just in case, should be cleared automatically by the read above, and we shouldn't enter the interrupt if no char received - doesn't help
if(SPORT->SR & USART_FLAG_ORE) // Debug - never happened once yet
{
data = (int8_t)(SPORT->SR & (uint8_t)0xFF);
tmp=0;
processSerialData((uint8_t) data);
}
processSerialData((uint8_t) data);
}
#endif