# HG changeset patch # User Ethan Zonca # Date 2017-01-12 09:35:10 # Node ID 2ee6c8e67f3289d8963f847df81caf940de6ef8d # Parent 02d3447dac18c6ca9413d85e5aa3148c341285f6 Add error handling and vim modelines diff --git a/Include/burn.h b/Include/burn.h --- a/Include/burn.h +++ b/Include/burn.h @@ -27,3 +27,5 @@ void burn_queue(uint8_t burn_id, uint8_t void burn_process(void); #endif + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Include/config.h b/Include/config.h --- a/Include/config.h +++ b/Include/config.h @@ -73,3 +73,5 @@ #endif + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Include/error.h b/Include/error.h --- a/Include/error.h +++ b/Include/error.h @@ -6,7 +6,8 @@ // If adding errors, remember to define a message for each in error.c enum error_number { - ERR_RS485_PARSE = 0, + ERR_GPS_OFF = 0, + ERR_GPS_CHECKSUM, }; @@ -17,3 +18,5 @@ uint8_t error_occurred(void); uint8_t error_count(void); #endif + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Include/gps.h b/Include/gps.h --- a/Include/gps.h +++ b/Include/gps.h @@ -42,3 +42,5 @@ gps_data_t* gps_getdata(void); uint8_t gps_ison(void); #endif /* GPS_H_ */ + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Include/pressure.h b/Include/pressure.h --- a/Include/pressure.h +++ b/Include/pressure.h @@ -33,3 +33,4 @@ int32_t pressure_getpressure(void); I2C_HandleTypeDef* pressure_get_i2c_handle(void); #endif +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Include/system/adc.h b/Include/system/adc.h --- a/Include/system/adc.h +++ b/Include/system/adc.h @@ -8,3 +8,5 @@ uint8_t adc_get_vbatt(void); #endif /* SYSTEM_ADC_H_ */ + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Include/system/flash.h b/Include/system/flash.h --- a/Include/system/flash.h +++ b/Include/system/flash.h @@ -44,3 +44,5 @@ void flash_checksum(void); #endif // flash_h + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Include/system/gpio.h b/Include/system/gpio.h --- a/Include/system/gpio.h +++ b/Include/system/gpio.h @@ -20,3 +20,5 @@ void gpio_process_shutdown(void); #endif + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Include/system/stm32f0xx_hal_conf.h b/Include/system/stm32f0xx_hal_conf.h --- a/Include/system/stm32f0xx_hal_conf.h +++ b/Include/system/stm32f0xx_hal_conf.h @@ -262,3 +262,5 @@ #endif #endif /* __STM32F0xx_HAL_CONF_H */ + + // vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Include/system/stm32f0xx_it.h b/Include/system/stm32f0xx_it.h --- a/Include/system/stm32f0xx_it.h +++ b/Include/system/stm32f0xx_it.h @@ -12,3 +12,5 @@ void SysTick_Handler(void); #endif #endif /* __STM32F0xx_IT_H */ + + // vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Include/system/sysclk.h b/Include/system/sysclk.h --- a/Include/system/sysclk.h +++ b/Include/system/sysclk.h @@ -4,3 +4,5 @@ void sysclock_init(void); #endif + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Include/system/uart.h b/Include/system/uart.h --- a/Include/system/uart.h +++ b/Include/system/uart.h @@ -10,3 +10,5 @@ DMA_HandleTypeDef* uart_get_txdma_handle DMA_HandleTypeDef* uart_get_rxdma_handle(void); #endif + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Include/system/watchdog.h b/Include/system/watchdog.h --- a/Include/system/watchdog.h +++ b/Include/system/watchdog.h @@ -5,3 +5,5 @@ void watchdog_init(void); void watchdog_feed(void); #endif + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Source/error.c b/Source/error.c --- a/Source/error.c +++ b/Source/error.c @@ -14,7 +14,9 @@ volatile uint8_t num_errors_asserted = 0 // Moderately detailed messages corresponding to each error enum char * error_message[] = { - "RS485 parse fail", + "GPS off", + "GPS checksum", + }; // Set the passed error flag @@ -78,3 +80,5 @@ uint8_t error_count(void) { return num_errors_asserted; } + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Source/gps.c b/Source/gps.c --- a/Source/gps.c +++ b/Source/gps.c @@ -5,6 +5,7 @@ #include "stm32f0xx_hal.h" #include "config.h" +#include "error.h" #include "system/gpio.h" #include "system/uart.h" #include "gps.h" @@ -13,6 +14,7 @@ volatile gps_data_t position; uint8_t gpson = 0; + // Private methods static void gps_ubx_checksum(uint8_t* data, uint8_t len, uint8_t* cka, uint8_t* ckb); static uint8_t _gps_verify_checksum(uint8_t* data, uint8_t len); @@ -24,7 +26,7 @@ void gps_update_data(void) // Error! if(!gpson) { -// led_blink(5); + error_assert(ERR_GPS_OFF); return; } @@ -54,9 +56,10 @@ void gps_update_data(void) volatile HAL_StatusTypeDef res = HAL_UART_Receive(uart_gethandle(), buf, 100, 3000); // Check 60 bytes minus SYNC and CHECKSUM (4 bytes) -// if( !_gps_verify_checksum(&buf[2], 96) ) -// led_blink(2); - + if( !_gps_verify_checksum(&buf[2], 96) ) + { + error_assert(ERR_GPS_CHECKSUM); + } //volatile uint32_t gpstime_ms = (buf[6+0] << 24) | (buf[6+1] << 16) | buf[6+2] << 8) | (buf[6+3]); @@ -179,9 +182,6 @@ void gps_poweron(void) // HAL_Delay(100); // // - - - // Begin DMA reception //HAL_UART_Receive_DMA(uart_gethandle(), nmeaBuffer, NMEABUFFER_SIZE); diff --git a/Source/main.c b/Source/main.c --- a/Source/main.c +++ b/Source/main.c @@ -43,15 +43,11 @@ int main(void) hal_init(); sysclock_init(); gpio_init(); - adc_init(); - afsk_init(); si446x_init(); si446x_init(); - gps_poweron(); - pressure_init(); // Software timers @@ -81,7 +77,9 @@ int main(void) si446x_cw_off(); // High-frequency function calls -// watchdog_feed(); + watchdog_feed(); } } + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Source/pressure.c b/Source/pressure.c --- a/Source/pressure.c +++ b/Source/pressure.c @@ -107,3 +107,5 @@ inline I2C_HandleTypeDef* pressure_get_i return &hi2c1; } + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Source/system/_sbrk.c b/Source/system/_sbrk.c --- a/Source/system/_sbrk.c +++ b/Source/system/_sbrk.c @@ -20,3 +20,5 @@ heap_end += incr; return (caddr_t)prev_heap_end; } + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Source/system/adc.c b/Source/system/adc.c --- a/Source/system/adc.c +++ b/Source/system/adc.c @@ -95,3 +95,5 @@ DMA_HandleTypeDef* adc__hdma_gethandle(v { return &hdma_adc; } + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Source/system/flash.c b/Source/system/flash.c --- a/Source/system/flash.c +++ b/Source/system/flash.c @@ -230,3 +230,5 @@ void flash_erase(void) } */ + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Source/system/gpio.c b/Source/system/gpio.c --- a/Source/system/gpio.c +++ b/Source/system/gpio.c @@ -59,3 +59,6 @@ void gpio_init(void) // Toggle the power LED HAL_GPIO_TogglePin(LED_POWER); } + +// vim:softtabstop=4 shiftwidth=4 expandtab + diff --git a/Source/system/interrupts.c b/Source/system/interrupts.c --- a/Source/system/interrupts.c +++ b/Source/system/interrupts.c @@ -44,3 +44,5 @@ void DMA1_Channel1_IRQHandler(void) { HAL_DMA_IRQHandler(adc__hdma_gethandle()); } + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Source/system/sysclk.c b/Source/system/sysclk.c --- a/Source/system/sysclk.c +++ b/Source/system/sysclk.c @@ -82,3 +82,5 @@ void sysclock_init(void) HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); } +// vim:softtabstop=4 shiftwidth=4 expandtab + diff --git a/Source/system/uart.c b/Source/system/uart.c --- a/Source/system/uart.c +++ b/Source/system/uart.c @@ -117,3 +117,5 @@ DMA_HandleTypeDef* uart_get_rxdma_handle return &hdma_usart1_rx; } + +// vim:softtabstop=4 shiftwidth=4 expandtab diff --git a/Source/system/watchdog.c b/Source/system/watchdog.c --- a/Source/system/watchdog.c +++ b/Source/system/watchdog.c @@ -31,3 +31,5 @@ void watchdog_feed(void) HAL_IWDG_Refresh(&hiwdg); #endif } + +// vim:softtabstop=4 shiftwidth=4 expandtab