Add SSR safety enable to oven driver
This commit is contained in:
parent
3a07347f48
commit
bbfcd429fe
@ -58,4 +58,13 @@
|
|||||||
*/
|
*/
|
||||||
#define OVEN_CONTROLLER_PIN_ALTFUNC (2)
|
#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__ */
|
#endif /* __OVEN_DRIVER_HWCFG_H__ */
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <reflow-controller/temp-converter.h>
|
#include <reflow-controller/temp-converter.h>
|
||||||
#include <helper-macros/helper-macros.h>
|
#include <helper-macros/helper-macros.h>
|
||||||
#include <reflow-controller/safety/safety-controller.h>
|
#include <reflow-controller/safety/safety-controller.h>
|
||||||
|
#include <reflow-controller/hw-version-detect.h>
|
||||||
|
|
||||||
static struct pid_controller IN_SECTION(.ccm.bss) oven_pid;
|
static struct pid_controller IN_SECTION(.ccm.bss) oven_pid;
|
||||||
static bool oven_pid_running;
|
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 float IN_SECTION(.ccm.bss) target_temp;
|
||||||
static uint64_t IN_SECTION(.ccm.bss) timestamp_last_run;
|
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<<SSR_SAFETY_EN_PIN);
|
||||||
|
else
|
||||||
|
SSR_SAFETY_EN_PORT->ODR &= ~(1<<SSR_SAFETY_EN_PIN);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void oven_driver_init(void)
|
void oven_driver_init(void)
|
||||||
{
|
{
|
||||||
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(OVEN_CONTROLLER_PORT_RCC_MASK));
|
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(OVEN_CONTROLLER_PORT_RCC_MASK));
|
||||||
@ -57,6 +69,14 @@ void oven_driver_init(void)
|
|||||||
oven_pid_aborted = false;
|
oven_pid_aborted = false;
|
||||||
oven_pid_running = 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_set_power(0U);
|
||||||
oven_driver_apply_power_level();
|
oven_driver_apply_power_level();
|
||||||
}
|
}
|
||||||
@ -92,6 +112,8 @@ void oven_pid_init(struct pid_controller *controller_to_copy)
|
|||||||
oven_pid_aborted = false;
|
oven_pid_aborted = false;
|
||||||
safety_controller_report_timing(ERR_TIMING_PID);
|
safety_controller_report_timing(ERR_TIMING_PID);
|
||||||
timestamp_last_run = systick_get_global_tick();
|
timestamp_last_run = systick_get_global_tick();
|
||||||
|
ssr_safety_en(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void oven_pid_set_target_temperature(float temp)
|
void oven_pid_set_target_temperature(float temp)
|
||||||
@ -124,6 +146,7 @@ void oven_pid_stop(void)
|
|||||||
oven_pid_running = false;
|
oven_pid_running = false;
|
||||||
oven_driver_set_power(0U);
|
oven_driver_set_power(0U);
|
||||||
safety_controller_enable_timing_mon(ERR_TIMING_PID, false);
|
safety_controller_enable_timing_mon(ERR_TIMING_PID, false);
|
||||||
|
ssr_safety_en(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void oven_pid_abort(void)
|
void oven_pid_abort(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user