Changeset - 6f724d71c0ec
[Not reviewed]
default
0 2 0
Ethan Zonca - 10 years ago 2014-08-15 23:15:19
ez@ethanzonca.com
Stripped out some code and added USB init. May have bricked IC.
2 files changed with 7 insertions and 88 deletions:
0 comments (0 inline, 0 general)
hw_config.c
Show inline comments
 
/**
 
  ******************************************************************************
 
  * @file    hw_config.c
 
  * @author  MCD Application Team
 
  * @version V4.0.0
 
  * @date    21-January-2013
 
  * @brief   Hardware Configuration & Setup
 
  ******************************************************************************
 
  * @attention
 
  *
 
  * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>
 
  *
 
  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
 
  * You may not use this file except in compliance with the License.
 
  * You may obtain a copy of the License at:
 
  *
 
  *        http://www.st.com/software_license_agreement_liberty_v2
 
  *
 
  * Unless required by applicable law or agreed to in writing, software 
 
  * distributed under the License is distributed on an "AS IS" BASIS, 
 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  * See the License for the specific language governing permissions and
 
  * limitations under the License.
 
  *
 
  ******************************************************************************
 
  */
 
 
/* Includes ------------------------------------------------------------------*/
 
 
#include "stm32_it.h"
 
#include "usb_lib.h"
 
#include "usb_prop.h"
 
#include "usb_desc.h"
 
#include "hw_config.h"
 
#include "usb_pwr.h"
 
 
/* Private typedef -----------------------------------------------------------*/
 
/* Private define ------------------------------------------------------------*/
 
/* Private macro -------------------------------------------------------------*/
 
/* Private variables ---------------------------------------------------------*/
 
ErrorStatus HSEStartUpStatus;
 
EXTI_InitTypeDef EXTI_InitStructure;
 
extern __IO uint32_t packet_sent;
 
extern __IO uint8_t Send_Buffer[VIRTUAL_COM_PORT_DATA_SIZE] ;
 
extern __IO  uint32_t packet_receive;
 
extern __IO uint8_t Receive_length;
 
 
uint8_t Receive_Buffer[64];
 
uint32_t Send_length;
 
static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len);
 
/* Extern variables ----------------------------------------------------------*/
 
 
extern LINE_CODING linecoding;
 
 
/* Private function prototypes -----------------------------------------------*/
 
/* Private functions ---------------------------------------------------------*/
 
/*******************************************************************************
 
* Function Name  : Set_System
 
* Description    : Configures Main system clocks & power
 
* Input          : None.
 
* Return         : None.
 
*******************************************************************************/
 
void Set_System(void)
 
{
 
#if !defined(STM32L1XX_MD) && !defined(STM32L1XX_HD) && !defined(STM32L1XX_MD_PLUS)
 
  GPIO_InitTypeDef GPIO_InitStructure;
 
#endif /* STM32L1XX_MD && STM32L1XX_XD */  
 
 
#if defined(USB_USE_EXTERNAL_PULLUP)
 
  GPIO_InitTypeDef  GPIO_InitStructure;
 
#endif /* USB_USE_EXTERNAL_PULLUP */ 
 
  
 
  /*!< At this stage the microcontroller clock setting is already configured, 
 
       this is done through SystemInit() function which is called from startup
 
       file (startup_stm32f10x_xx.s) before to branch to application main.
 
       To reconfigure the default setting of SystemInit() function, refer to
 
       system_stm32f10x.c file
 
     */   
 
#if defined(STM32L1XX_MD) || defined(STM32L1XX_HD)|| defined(STM32L1XX_MD_PLUS) || defined(STM32F37X) || defined(STM32F30X)
 
  /* Enable the SYSCFG module clock */
 
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
 
#endif /* STM32L1XX_XD */ 
 
   
 
#if !defined(STM32L1XX_MD) && !defined(STM32L1XX_HD) && !defined(STM32L1XX_MD_PLUS) && !defined(STM32F37X) && !defined(STM32F30X)
 
  /* Enable USB_DISCONNECT GPIO clock */
 
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_DISCONNECT, ENABLE);
 
  //RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_DISCONNECT, ENABLE);
 
 
  /* Configure USB pull-up pin */
 
  GPIO_InitStructure.GPIO_Pin = USB_DISCONNECT_PIN;
 
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
 
  GPIO_Init(USB_DISCONNECT, &GPIO_InitStructure);
 
#endif /* STM32L1XX_MD && STM32L1XX_XD */
 
  //GPIO_InitStructure.GPIO_Pin = USB_DISCONNECT_PIN;
 
  //GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz;
 
  //GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
 
  //GPIO_Init(USB_DISCONNECT, &GPIO_InitStructure);
 
   
 
#if defined(USB_USE_EXTERNAL_PULLUP)
 
  /* Enable the USB disconnect GPIO clock */
 
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIO_DISCONNECT, ENABLE);
 
 
  /* USB_DISCONNECT used as USB pull-up */
 
  GPIO_InitStructure.GPIO_Pin = USB_DISCONNECT_PIN;
 
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
 
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
 
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
 
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
 
  GPIO_Init(USB_DISCONNECT, &GPIO_InitStructure);  
 
#endif /* USB_USE_EXTERNAL_PULLUP */ 
 
  
 
#if defined(STM32F37X) || defined(STM32F30X)
 
  
 
  /* Enable the USB disconnect GPIO clock */
 
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIO_DISCONNECT, ENABLE);
 
  
 
  /*Set PA11,12 as IN - USB_DM,DP*/ 
 
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
 
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
 
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
 
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
 
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
 
  GPIO_Init(GPIOA, &GPIO_InitStructure);
 
  
 
  /*SET PA11,12 for USB: USB_DM,DP*/
 
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource11, GPIO_AF_14);
 
  GPIO_PinAFConfig(GPIOA, GPIO_PinSource12, GPIO_AF_14);
 
  
 
  /* USB_DISCONNECT used as USB pull-up */
 
  GPIO_InitStructure.GPIO_Pin = USB_DISCONNECT_PIN;
 
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
 
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
 
  GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
 
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
 
  GPIO_Init(USB_DISCONNECT, &GPIO_InitStructure);
 
#endif /* STM32F37X  && STM32F30X)*/
 
 
 
   /* Configure the EXTI line 18 connected internally to the USB IP */
 
  EXTI_ClearITPendingBit(EXTI_Line18);
 
  EXTI_InitStructure.EXTI_Line = EXTI_Line18;
 
  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
 
  EXTI_InitStructure.EXTI_LineCmd = ENABLE;
 
  EXTI_Init(&EXTI_InitStructure); 
 
}
 
 
/*******************************************************************************
 
* Function Name  : Set_USBClock
 
* Description    : Configures USB Clock input (48MHz)
 
* Input          : None.
 
* Return         : None.
 
*******************************************************************************/
 
void Set_USBClock(void)
 
{
 
#if defined(STM32L1XX_MD) || defined(STM32L1XX_HD) || defined(STM32L1XX_MD_PLUS) 
 
  /* Enable USB clock */
 
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
 
  
 
#else 
 
  /* Select USBCLK source */
 
  RCC_USBCLKConfig(RCC_USBCLKSource_PLLCLK_1Div5);
 
  
 
  /* Enable the USB clock */
 
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USB, ENABLE);
 
#endif /* STM32L1XX_MD */
 
}
 
 
/*******************************************************************************
 
* Function Name  : Enter_LowPowerMode
 
* Description    : Power-off system clocks and power while entering suspend mode
 
* Input          : None.
 
* Return         : None.
 
*******************************************************************************/
 
void Enter_LowPowerMode(void)
 
{
 
  /* Set the device state to suspend */
 
  bDeviceState = SUSPENDED;
 
}
 
 
/*******************************************************************************
 
* Function Name  : Leave_LowPowerMode
 
* Description    : Restores system clocks and power while exiting suspend mode
 
* Input          : None.
 
* Return         : None.
 
*******************************************************************************/
 
void Leave_LowPowerMode(void)
 
{
 
  DEVICE_INFO *pInfo = &Device_Info;
 
 
  /* Set the device state to the correct state */
 
  if (pInfo->Current_Configuration != 0)
 
  {
 
    /* Device configured */
 
    bDeviceState = CONFIGURED;
 
  }
 
  else
 
  {
 
    bDeviceState = ATTACHED;
 
  }
 
    /*Enable SystemCoreClock*/
 
  SystemInit();
 
}
 
 
/*******************************************************************************
 
* Function Name  : USB_Interrupts_Config
 
* Description    : Configures the USB interrupts
 
* Input          : None.
 
* Return         : None.
 
*******************************************************************************/
 
void USB_Interrupts_Config(void)
 
{
 
NVIC_InitTypeDef NVIC_InitStructure;
 
 
  /* 2 bit for pre-emption priority, 2 bits for subpriority */
 
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
 
 
 
#if defined(STM32L1XX_MD)|| defined(STM32L1XX_HD) || defined(STM32L1XX_MD_PLUS)
 
  /* Enable the USB interrupt */
 
  NVIC_InitStructure.NVIC_IRQChannel = USB_LP_IRQn;
 
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
 
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
 
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
 
  NVIC_Init(&NVIC_InitStructure);
 
 
  /* Enable the USB Wake-up interrupt */
 
  NVIC_InitStructure.NVIC_IRQChannel = USB_FS_WKUP_IRQn;
 
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
 
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
 
  NVIC_Init(&NVIC_InitStructure);
 
 
#elif defined(STM32F37X)
 
  /* Enable the USB interrupt */
 
  NVIC_InitStructure.NVIC_IRQChannel = USB_LP_IRQn;
 
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
 
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
 
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
 
  NVIC_Init(&NVIC_InitStructure);
 
  
 
  /* Enable the USB Wake-up interrupt */
 
  NVIC_InitStructure.NVIC_IRQChannel = USBWakeUp_IRQn;
 
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
 
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
 
  NVIC_Init(&NVIC_InitStructure);
 
  
 
#else
 
  /* Enable the USB interrupt */
 
  NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn;
 
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
 
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
 
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
 
  NVIC_Init(&NVIC_InitStructure);
 
  
 
  /* Enable the USB Wake-up interrupt */
 
  NVIC_InitStructure.NVIC_IRQChannel = USBWakeUp_IRQn;
 
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
 
  NVIC_Init(&NVIC_InitStructure);   
 
#endif
 
}
 
 
/*******************************************************************************
 
* Function Name  : USB_Cable_Config
 
* Description    : Software Connection/Disconnection of USB Cable
 
* Input          : None.
 
* Return         : Status
 
*******************************************************************************/
 
void USB_Cable_Config (FunctionalState NewState)
 
{
 
#if defined(STM32L1XX_MD) || defined (STM32L1XX_HD)|| (STM32L1XX_MD_PLUS)
 
  if (NewState != DISABLE)
 
  {
 
    STM32L15_USB_CONNECT;
 
  }
 
  else
 
  {
 
    STM32L15_USB_DISCONNECT;
 
  }  
 
  
 
#else /* USE_STM3210B_EVAL or USE_STM3210E_EVAL */
 
  if (NewState != DISABLE)
 
  {
 
    GPIO_ResetBits(USB_DISCONNECT, USB_DISCONNECT_PIN);
 
  }
 
  else
 
  {
 
    GPIO_SetBits(USB_DISCONNECT, USB_DISCONNECT_PIN);
 
  }
 
#endif /* STM32L1XX_MD */
 
}
 
 
/*******************************************************************************
 
* Function Name  : Get_SerialNum.
 
* Description    : Create the serial number string descriptor.
 
* Input          : None.
 
* Output         : None.
 
* Return         : None.
 
*******************************************************************************/
 
void Get_SerialNum(void)
 
{
 
  uint32_t Device_Serial0, Device_Serial1, Device_Serial2;
 
 
  Device_Serial0 = *(uint32_t*)ID1;
 
  Device_Serial1 = *(uint32_t*)ID2;
 
  Device_Serial2 = *(uint32_t*)ID3;
 
 
 
  Device_Serial0 += Device_Serial2;
 
 
  if (Device_Serial0 != 0)
 
  {
 
    IntToUnicode (Device_Serial0, &Virtual_Com_Port_StringSerial[2] , 8);
 
    IntToUnicode (Device_Serial1, &Virtual_Com_Port_StringSerial[18], 4);
 
  }
 
}
 
 
/*******************************************************************************
 
* Function Name  : HexToChar.
 
* Description    : Convert Hex 32Bits value into char.
 
* Input          : None.
 
* Output         : None.
 
* Return         : None.
 
*******************************************************************************/
 
static void IntToUnicode (uint32_t value , uint8_t *pbuf , uint8_t len)
 
{
 
  uint8_t idx = 0;
 
  
 
  for( idx = 0 ; idx < len ; idx ++)
 
  {
 
    if( ((value >> 28)) < 0xA )
 
    {
 
      pbuf[ 2* idx] = (value >> 28) + '0';
 
    }
 
    else
 
    {
 
      pbuf[2* idx] = (value >> 28) + 'A' - 10; 
 
    }
 
    
 
    value = value << 4;
 
    
 
    pbuf[ 2* idx + 1] = 0;
 
  }
 
}
 
 
/*******************************************************************************
 
* Function Name  : Send DATA .
 
* Description    : send the data received from the STM32 to the PC through USB  
 
* Input          : None.
 
* Output         : None.
 
* Return         : None.
 
*******************************************************************************/
 
uint32_t CDC_Send_DATA (uint8_t *ptrBuffer, uint8_t Send_length)
 
{
 
  /*if max buffer is Not reached*/
 
  if(Send_length < VIRTUAL_COM_PORT_DATA_SIZE)     
 
  {
 
    /*Sent flag*/
 
    packet_sent = 0;
 
    /* send  packet to PMA*/
 
    UserToPMABufferCopy((unsigned char*)ptrBuffer, ENDP1_TXADDR, Send_length);
 
    SetEPTxCount(ENDP1, Send_length);
 
    SetEPTxValid(ENDP1);
 
  }
 
  else
 
  {
 
    return 0;
 
  } 
 
  return 1;
 
}
 
 
/*******************************************************************************
 
* Function Name  : Receive DATA .
 
* Description    : receive the data from the PC to STM32 and send it through USB
 
* Input          : None.
 
* Output         : None.
 
* Return         : None.
 
*******************************************************************************/
 
uint32_t CDC_Receive_DATA(void)
 
{ 
 
  /*Receive flag*/
 
  packet_receive = 0;
 
  SetEPRxValid(ENDP3); 
 
  return 1 ;
 
}
 
 
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
main.c
Show inline comments
 
#include "main.h"
 
#include "stm32l100c_discovery.h"
 
#include "ssd1306.h"
 
 
// USB includes
 
#include "hw_config.h"
 
#include "usb_lib.h"
 
#include "usb_desc.h"
 
#include "usb_pwr.h"
 
 
#define LED_POWER GPIOB,GPIO_Pin_9
 
#define LED_STAT  GPIOA,GPIO_Pin_15
 
 
#define MAX_CS GPIOB,GPIO_Pin_12
 
 
// TODO: Grab buttonpresses with interrupts
 
#define SW_BTN  GPIOB, GPIO_Pin_3
 
#define SW_UP   GPIOB, GPIO_Pin_7
 
#define SW_DOWN GPIOB, GPIO_Pin_6
 
#define SW_LEFT GPIOB, GPIO_Pin_5
 
#define SW_RIGHT GPIOB, GPIO_Pin_4
 
 
/* Extern variables ----------------------------------------------------------*/
 
extern __IO uint8_t Receive_Buffer[64];
 
extern __IO  uint32_t Receive_length ;
 
extern __IO  uint32_t length ;
 
uint8_t Send_Buffer[64];
 
uint32_t packet_sent=1;
 
uint32_t packet_receive=1;
 
 
static __IO uint32_t TimingDelay;
 
 
void init_gpio();
 
void init_spi();
 
void process();
 
void machine();
 
 
int main(void)
 
{
 
 
    // Init clocks
 
    SystemInit();
 
 
    init_gpio();
 
 
    Set_USBClock();
 
    USB_Interrupts_Config();
 
    USB_Init();
 
 
    GPIO_SetBits(LED_POWER);
 
    USB_Init(); // freezes here... maybe clock issue?
 
 
    RCC_ClocksTypeDef RCC_Clocks;
 
 
    // SysTick end of count event each 1ms
 
    RCC_GetClocksFreq(&RCC_Clocks);
 
    SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000);
 
 
    GPIO_ResetBits(LED_STAT);
 
    Delay(100);
 
    GPIO_SetBits(LED_POWER);
 
    Delay(500);
 
    GPIO_ResetBits(LED_POWER);
 
 
    init_spi();
 
 
    ssd1306_Init();
 
    ssd1306_DrawPoint(3,3,1);
 
    ssd1306_DrawPoint(5,5,0);
 
 
    while(1)
 
   {  
 
        ssd1306_block_write();
 
 
        // Process sensor inputs [TODO: 5hz?]
 
        process();
 
 
        // Run state machine [TODO: 50hz?]
 
        machine(); 
 
        // probably just passed the actual port
 
 
        // TODO: Grab buttonpresses with interrupts
 
        uint8_t sw_btn = GPIO_ReadInputDataBit(SW_BTN);
 
        uint8_t sw_up = GPIO_ReadInputDataBit(SW_UP);
 
        uint8_t sw_down = GPIO_ReadInputDataBit(SW_DOWN);
 
        uint8_t sw_left = GPIO_ReadInputDataBit(SW_LEFT);
 
        uint8_t sw_right = GPIO_ReadInputDataBit(SW_RIGHT);
 
 
//        SPI_I2S_SendData(SPI2,0xFA);
 
//        SPI_I2S_SendData(SPI1,0xFA);
 
 
        if(!GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_3)) {
 
            GPIO_ToggleBits(LED_STAT);
 
        }
 
 
        GPIO_SetBits(LED_POWER);
 
        Delay(50);
 
        GPIO_ResetBits(LED_POWER);
 
        Delay(50);
 
    }
 
}
 
 
int32_t temp = 0;
 
int32_t setpoint = 0;
 
int32_t p = 1;
 
int32_t i = 1;
 
int32_t d = 1;
 
 
// Process things
 
void process()
 
{
 
    // Read MAX temp sensor
 
    GPIO_ResetBits(MAX_CS);
 
 
    // Assert CS
 
    // This may not clock at all... might need to send 16 bits first
 
    uint8_t retval = 0;//SPI_I2S_ReceiveData(SPI2);
 
 
    // Deassert CS
 
    GPIO_SetBits(MAX_CS);
 
 
    if((!retval || (temp & 0x2) != 0))
 
        return; // Comms error - this is happening right now
 
 
    if((temp & 0x4)!= 0)
 
        return; // Open thermocouple
 
 
 
    temp = (temp & 0x7FF8) >> 5;
 
 
 
    // TODO: Add calibration offset (linear)
 
 
 
    // Perform PID calculations
 
 
    // Write output to SSR
 
}
 
 
 
 
enum state {
 
    STATE_IDLE = 0,
 
    STATE_SETP,
 
    STATE_SETI,
 
    STATE_SETD,
 
 
    STATE_PREHEAT_BREW,
 
    STATE_MAINTAIN_BREW,
 
    STATE_PREHEAT_STEAM,
 
    STATE_MAINTAIN_STEAM,
 
};
 
 
 
uint8_t state = STATE_IDLE;
 
 
// State machine
 
void machine()
 
{
 
    
 
    switch(state)
 
    {
 
        // Idle state
 
        case STATE_IDLE:
 
        {
 
            // Write text to OLED
 
            // [ therm :: idle ]
 
 
            // Button handler
 
            if(GPIO_ReadInputDataBit(SW_BTN)) {
 
                state = STATE_SETP;
 
            }
 
 
            // Event Handler
 
            // N/A
 
 
        } break;
 
 
        case STATE_SETP:
 
        {
 
            // Write text to OLED
 
            // [ therm :: set p ]
 
            // [ p = 12         ]
 
 
            // Button handler
 
            if(GPIO_ReadInputDataBit(SW_BTN)) {
 
                state = STATE_IDLE;
 
            }
 
 
            // Event Handler
 
            // N/A
 
 
 
        } break;
 
 
        case STATE_SETI:
 
        {
 
            // Write text to OLED
 
            // [ therm :: set i ]
 
            // [ i = 12         ]
 
 
            // Button handler
 
            if(GPIO_ReadInputDataBit(SW_BTN)) {
 
                state = STATE_IDLE;
 
            }
 
 
            // Event Handler
 
            // N/A
 
 
 
        } break;
 
 
        case STATE_SETD:
 
        {
 
            // Write text to OLED
 
            // [ therm :: set d ]
 
            // [ d = 12         ]
 
 
            // Button handler
 
            if(GPIO_ReadInputDataBit(SW_BTN)) {
 
                state = STATE_IDLE;
 
            }
 
 
            // Event Handler
 
            // N/A
 
 
 
        } break;
 
 
        case STATE_PREHEAT_BREW:
 
        {
 
            // Write text to OLED
 
            // [ therm : preheating brew ]
 
            // [ 30 => 120 C             ]
 
 
            // Button handler
 
            if(GPIO_ReadInputDataBit(SW_BTN)) {
 
                state = STATE_IDLE;
 
            }
 
 
            // Event Handler
 
            if(temp >= setpoint) {
 
                state = STATE_MAINTAIN_BREW;
 
            }
0 comments (0 inline, 0 general)