diff --git a/STM32F04_FW/src/main.c b/STM32F04_FW/src/main.c
index d7efcc14d60328749fb762457930acbfa88156f2..83b90328c67d99ef2524d0476188ab15e433af92 100644
--- a/STM32F04_FW/src/main.c
+++ b/STM32F04_FW/src/main.c
@@ -46,7 +46,7 @@ SOFTWARE.
/* Private variables */
/* Private function prototypes */
/* Private functions */
-#define WAIT_FOR_FIX 1
+#define WAIT_FOR_FIX 0
/**
**===========================================================================
**
@@ -177,7 +177,11 @@ static char *safeitoa(const int x, char *buffer, const int bufferSize, const int
}
//#include <stm32f4xx_spi.h>
+#if WAIT_FOR_FIX == 1
volatile uint64_t ticks = 0;
+#else
+volatile uint64_t ticks = 1505658926;
+#endif
//must be called via GPIO-Interrupt
void EXTI1_IRQHandler(void) {
/* Make sure that interrupt flag is set */
@@ -276,6 +280,10 @@ void SPI2_IRQHandler(void)
tm[i+1] = '0';
safeitoa ( get_time(), &tm[1], 20, 16 );
+ //MAGIC do not touch - you are not meant to understand the following line :D
+// for(volatile uint16_t i=0; i < 12; ++i) asm volatile("nop"); //This line has it's puprose, due to racing conditions which caused damaged data, we artifically increased the delay of safeitoa.
+ // if safeitoa is too fast, the string of the RX-Board is not transmitted completely, thus not all characters are safed in the fifo causing that not all characters are transferred.
+
for(uint8_t i=0; i < 10; ++i){
if(tm[i] == 0) {
tm[i] = ';';
@@ -284,8 +292,9 @@ void SPI2_IRQHandler(void)
}
}
uint16_t ln = strlen(tm);
+ __disable_irq();
fifo_put(&spi2_rx_fifo, tm, ln);
-
+ __enable_irq();
// for(uint8_t i = 0; i < ln; ++i){
// cmp1[cmp1_index] = tm[i];
// cmp1_index++;
@@ -295,8 +304,9 @@ void SPI2_IRQHandler(void)
} else {
+ __disable_irq();
fifo_put(&spi2_rx_fifo, &tmp, 1);
-
+ __enable_irq();
// cmp1[cmp1_index] = tmp;
// cmp1_index++;
// if(cmp1_index >= 200)
@@ -377,7 +387,8 @@ void spi_send(void){
__enable_irq();
if(filled){
memset(tmp, 0, sizeof(tmp));
- if(filled >= 126) filled = 126;
+ if(filled >= 126)
+ filled = 126;
__disable_irq();
fifo_get(&spi2_rx_fifo, tmp, filled);
fifo_put(&spi1_tx_fifo, tmp, filled);
@@ -487,7 +498,9 @@ void SPI1_IRQHandler(void)
if(SPI_I2S_GetITStatus(SPI1, SPI_I2S_IT_TXE) == SET){
if(fifo_filled(&spi1_tx_fifo)){
char tmp;
+ __disable_irq();
fifo_get(&spi1_tx_fifo, &tmp, 1);
+ __enable_irq();
// cmp3[cmp3_index] = tmp;
// cmp3_index++;
// if(cmp3_index >= 200)
@@ -667,7 +680,8 @@ NVIC_Init(&NVIC_InitStruct);
minmea_parse_rmc(&rmc,strstr(buffer, "$GPRMC"));
uint32_t time = get_unix_tmstmp(rmc.date.year, rmc.date.month, rmc.date.day, rmc.time.hours, rmc.time.minutes, rmc.time.seconds);
- ticks = time;
+ if(time >= 0xFFFFFFFF) ticks = 0;
+ else ticks = time;
asm("nop");
}