# HG changeset patch # User Ethan Zonca # Date 2014-09-25 21:34:24 # Node ID 0ee0ed9a3b7d11caf81ce305befc07aba7f84ff7 # Parent 109bc69daf498d4667c0af14fd2a8c57bba6c933 Added clock startup failure check diff --git a/main.c b/main.c --- a/main.c +++ b/main.c @@ -12,7 +12,6 @@ #include "stringhelpers.h" // TODO: Grab buttonpresses with interrupts -// TODO: Eliminate screen buffer since we aren't using it... // USB Supporting Vars extern __IO uint8_t Receive_Buffer[64]; @@ -39,7 +38,6 @@ uint32_t change_time_reset = 0; #define CHANGE_ELAPSED (ticks - change_time_reset) > CHANGE_PERIOD_MS #define CHANGE_RESET change_time_reset = ticks - int16_t setpoint_brew = 0; int16_t setpoint_steam = 0; @@ -104,9 +102,18 @@ int main(void) ssd1306_Init(); ssd1306_clearscreen(); + // Check for problems on startup + if(clock_fail) { + ssd1306_DrawString("ERROR: Check Xtal", 3, 0); + delay(2000); + } + // Startup screen ssd1306_DrawString("therm v0.1", 1, 40); ssd1306_DrawString("protofusion.org/therm", 3, 0); + + + delay(1500); ssd1306_clearscreen(); @@ -370,8 +377,6 @@ void restore_settings() void user_input(uint16_t* to_modify) { if(CHANGE_ELAPSED) { - - // TODO: Make function that takes reference to a var and increase/decreases it based on buttonpress if(!GPIO_ReadInputDataBit(SW_UP) ) { CHANGE_RESET; (*to_modify)++; @@ -380,9 +385,7 @@ void user_input(uint16_t* to_modify) CHANGE_RESET; (*to_modify)--; } - } - } void machine() @@ -755,7 +758,6 @@ void TimingDelay_Decrement(void) ticks++; } - void init_spi(void) { SPI_InitTypeDef SPI_InitStructure; diff --git a/system_stm32l1xx.c b/system_stm32l1xx.c --- a/system_stm32l1xx.c +++ b/system_stm32l1xx.c @@ -295,6 +295,8 @@ void SystemCoreClockUpdate (void) * @param None * @retval None */ +uint8_t clock_fail = 0; + static void SetSysClock(void) { __IO uint32_t StartUpCounter = 0, HSEStatus = 0; @@ -374,6 +376,7 @@ static void SetSysClock(void) } else { + clock_fail = 1; // while(1); /* If HSE fails to start-up, the application will have wrong clock configuration. User can add here some code to deal with this error */ diff --git a/system_stm32l1xx.h b/system_stm32l1xx.h --- a/system_stm32l1xx.h +++ b/system_stm32l1xx.h @@ -58,6 +58,8 @@ extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +extern uint8_t clock_fail; + /** * @} */