diff --git a/main.c b/main.c --- a/main.c +++ b/main.c @@ -231,20 +231,6 @@ void update_temp() { temp = temp_pre * signint; } } - - // Print temp to cdc -/* - CDC_Transmit_FS("Temp: ", 6); - char tempstr[6]; - zitoa(temp, tempstr); - CDC_Transmit_FS(tempstr, sizeof(tempstr)); - - CDC_Transmit_FS("\r\n", 2); - CDC_Transmit_FS("\r\n", 2); - CDC_Transmit_FS("\r\n", 2); - CDC_Transmit_FS("\r\n", 2); - CDC_Transmit_FS("\r\n", 2); -*/ } @@ -301,6 +287,7 @@ int16_t update_pid(uint16_t k_p, uint16_ uint32_t last_ssr_on = 0; +uint32_t last_vcp_tx = 0; uint32_t last_led = 0; int32_t setpoint = 0; int16_t ssr_output = 0; // Duty cycle of ssr, 0 to SSR_PERIOD @@ -352,6 +339,18 @@ void process() { HAL_GPIO_WritePin(SSR_PIN, 0); } + + if(ticks - last_vcp_tx > VCP_TX_FREQ) + { + // Print temp to cdc + char tempstr[6]; + itoa_fp(temp, temp_frac, tempstr); + + while(CDC_Transmit_FS(tempstr, sizeof(tempstr)) == USBD_BUSY); + while(CDC_Transmit_FS("\r\n", 2) == USBD_BUSY); + + last_vcp_tx = ticks; + } } @@ -536,7 +535,13 @@ void machine() ssd1306_clearscreen(); ssd1306_DrawString("Entering Bootloader", 1, 0); ssd1306_DrawString("(hopefully)", 2, 0); - HAL_Delay(1000); + //HAL_Delay(1000); + HAL_RCC_DeInit(); + SysTick->CTRL = 0; + SysTick->LOAD = 0; + SysTick->VAL = 0; + __set_PRIMASK(1); + __set_MSP(0x200010000); *((unsigned long *)0x200017F0) = 0xDEADBEEF; // 6KB STM32F042 NVIC_SystemReset();