diff --git a/stm-firmware/include/reflow-controller/periph-config/oven-driver-hwcfg.h b/stm-firmware/include/reflow-controller/periph-config/oven-driver-hwcfg.h index b0f6f6c..fcab29f 100644 --- a/stm-firmware/include/reflow-controller/periph-config/oven-driver-hwcfg.h +++ b/stm-firmware/include/reflow-controller/periph-config/oven-driver-hwcfg.h @@ -58,4 +58,13 @@ */ #define OVEN_CONTROLLER_PIN_ALTFUNC (2) +/** + * @brief GPIO Port for the safety enable line used by PCB versions > v1.3 + */ +#define SSR_SAFETY_EN_PORT GPIOA + +#define SSR_SAFETY_EN_PIN (3) + +#define SSR_SAFETY_EN_PORT_RCC_MASK RCC_AHB1ENR_GPIOAEN + #endif /* __OVEN_DRIVER_HWCFG_H__ */ diff --git a/stm-firmware/oven-driver.c b/stm-firmware/oven-driver.c index 6e84971..cad8c1d 100644 --- a/stm-firmware/oven-driver.c +++ b/stm-firmware/oven-driver.c @@ -26,6 +26,7 @@ #include #include #include +#include static struct pid_controller IN_SECTION(.ccm.bss) oven_pid; static bool oven_pid_running; @@ -34,6 +35,17 @@ static uint8_t IN_SECTION(.ccm.bss) oven_driver_power_level; static float IN_SECTION(.ccm.bss) target_temp; static uint64_t IN_SECTION(.ccm.bss) timestamp_last_run; +static void ssr_safety_en(bool enable) +{ + if (get_pcb_hardware_version() >= HW_REV_V1_3) { + if (enable) + SSR_SAFETY_EN_PORT->ODR |= (1<ODR &= ~(1<AHB1ENR, BITMASK_TO_BITNO(OVEN_CONTROLLER_PORT_RCC_MASK)); @@ -57,6 +69,14 @@ void oven_driver_init(void) oven_pid_aborted = false; oven_pid_running = false; + if (get_pcb_hardware_version() >= HW_REV_V1_3) { + /* Init the safety SSR enable signal */ + rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(SSR_SAFETY_EN_PORT_RCC_MASK)); + SSR_SAFETY_EN_PORT->MODER &= MODER_DELETE(SSR_SAFETY_EN_PIN); + SSR_SAFETY_EN_PORT->MODER |= OUTPUT(SSR_SAFETY_EN_PIN); + ssr_safety_en(false); + } + oven_driver_set_power(0U); oven_driver_apply_power_level(); } @@ -92,6 +112,8 @@ void oven_pid_init(struct pid_controller *controller_to_copy) oven_pid_aborted = false; safety_controller_report_timing(ERR_TIMING_PID); timestamp_last_run = systick_get_global_tick(); + ssr_safety_en(true); + } void oven_pid_set_target_temperature(float temp) @@ -124,6 +146,7 @@ void oven_pid_stop(void) oven_pid_running = false; oven_driver_set_power(0U); safety_controller_enable_timing_mon(ERR_TIMING_PID, false); + ssr_safety_en(false); } void oven_pid_abort(void)