Skip to main content
Sign in
Snippets Groups Projects
Commit 3071addc authored by Björn's avatar Björn
Browse files

* Fixed bug regarding nvm

* Added disable_irq to stm fw
parent 70899270
No related branches found
No related tags found
No related merge requests found
...@@ -46,7 +46,7 @@ SOFTWARE. ...@@ -46,7 +46,7 @@ SOFTWARE.
/* Private variables */ /* Private variables */
/* Private function prototypes */ /* Private function prototypes */
/* Private functions */ /* 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 ...@@ -177,7 +177,11 @@ static char *safeitoa(const int x, char *buffer, const int bufferSize, const int
} }
//#include <stm32f4xx_spi.h> //#include <stm32f4xx_spi.h>
#if WAIT_FOR_FIX == 1
volatile uint64_t ticks = 0; volatile uint64_t ticks = 0;
#else
volatile uint64_t ticks = 1505658926;
#endif
//must be called via GPIO-Interrupt //must be called via GPIO-Interrupt
void EXTI1_IRQHandler(void) { void EXTI1_IRQHandler(void) {
/* Make sure that interrupt flag is set */ /* Make sure that interrupt flag is set */
...@@ -276,6 +280,10 @@ void SPI2_IRQHandler(void) ...@@ -276,6 +280,10 @@ void SPI2_IRQHandler(void)
tm[i+1] = '0'; tm[i+1] = '0';
safeitoa ( get_time(), &tm[1], 20, 16 ); 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){ for(uint8_t i=0; i < 10; ++i){
if(tm[i] == 0) { if(tm[i] == 0) {
tm[i] = ';'; tm[i] = ';';
...@@ -284,8 +292,9 @@ void SPI2_IRQHandler(void) ...@@ -284,8 +292,9 @@ void SPI2_IRQHandler(void)
} }
} }
uint16_t ln = strlen(tm); uint16_t ln = strlen(tm);
__disable_irq();
fifo_put(&spi2_rx_fifo, tm, ln); fifo_put(&spi2_rx_fifo, tm, ln);
__enable_irq();
// for(uint8_t i = 0; i < ln; ++i){ // for(uint8_t i = 0; i < ln; ++i){
// cmp1[cmp1_index] = tm[i]; // cmp1[cmp1_index] = tm[i];
// cmp1_index++; // cmp1_index++;
...@@ -295,8 +304,9 @@ void SPI2_IRQHandler(void) ...@@ -295,8 +304,9 @@ void SPI2_IRQHandler(void)
} else { } else {
__disable_irq();
fifo_put(&spi2_rx_fifo, &tmp, 1); fifo_put(&spi2_rx_fifo, &tmp, 1);
__enable_irq();
// cmp1[cmp1_index] = tmp; // cmp1[cmp1_index] = tmp;
// cmp1_index++; // cmp1_index++;
// if(cmp1_index >= 200) // if(cmp1_index >= 200)
...@@ -377,7 +387,8 @@ void spi_send(void){ ...@@ -377,7 +387,8 @@ void spi_send(void){
__enable_irq(); __enable_irq();
if(filled){ if(filled){
memset(tmp, 0, sizeof(tmp)); memset(tmp, 0, sizeof(tmp));
if(filled >= 126) filled = 126; if(filled >= 126)
filled = 126;
__disable_irq(); __disable_irq();
fifo_get(&spi2_rx_fifo, tmp, filled); fifo_get(&spi2_rx_fifo, tmp, filled);
fifo_put(&spi1_tx_fifo, tmp, filled); fifo_put(&spi1_tx_fifo, tmp, filled);
...@@ -487,7 +498,9 @@ void SPI1_IRQHandler(void) ...@@ -487,7 +498,9 @@ void SPI1_IRQHandler(void)
if(SPI_I2S_GetITStatus(SPI1, SPI_I2S_IT_TXE) == SET){ if(SPI_I2S_GetITStatus(SPI1, SPI_I2S_IT_TXE) == SET){
if(fifo_filled(&spi1_tx_fifo)){ if(fifo_filled(&spi1_tx_fifo)){
char tmp; char tmp;
__disable_irq();
fifo_get(&spi1_tx_fifo, &tmp, 1); fifo_get(&spi1_tx_fifo, &tmp, 1);
__enable_irq();
// cmp3[cmp3_index] = tmp; // cmp3[cmp3_index] = tmp;
// cmp3_index++; // cmp3_index++;
// if(cmp3_index >= 200) // if(cmp3_index >= 200)
...@@ -667,7 +680,8 @@ NVIC_Init(&NVIC_InitStruct); ...@@ -667,7 +680,8 @@ NVIC_Init(&NVIC_InitStruct);
minmea_parse_rmc(&rmc,strstr(buffer, "$GPRMC")); 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); 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"); asm("nop");
} }
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment