@@ -35,37 +35,32 @@ int main(void)
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);
//ssd1306_Init();
//ssd1306_DrawPoint(3,3,1);
//ssd1306_DrawPoint(5,5,0);
Delay(500);
GPIO_ResetBits(LED_POWER);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
init_spi();
while(1)
{
// Process sensor inputs [TODO: 5hz?]
process();
@@ -112,20 +107,21 @@ void process()
uint8_t retval = SPI_I2S_ReceiveData(SPI2);
// Deassert CS
GPIO_SetBits(MAX_CS);
if((!retval || (temp & 0x2) != 0))
return; // Comms error
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
@@ -286,13 +282,13 @@ void machine()
// N/A
} break;
// Something is terribly wrong
deault:
default:
state = STATE_IDLE;
}
Status change: