Changeset - 0ee0ed9a3b7d
[Not reviewed]
default
0 3 0
Ethan Zonca - 10 years ago 2014-09-25 21:34:24
ez@ethanzonca.com
Added clock startup failure check
3 files changed with 14 insertions and 7 deletions:
0 comments (0 inline, 0 general)
main.c
Show inline comments
 
@@ -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;
system_stm32l1xx.c
Show inline comments
 
@@ -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 */
system_stm32l1xx.h
Show inline comments
 
@@ -58,6 +58,8 @@
 
 
extern uint32_t SystemCoreClock;          /*!< System Clock Frequency (Core Clock) */
 
 
extern uint8_t clock_fail;
 
 
/**
 
  * @}
 
  */
0 comments (0 inline, 0 general)