mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Safer PWM Init
This commit is contained in:
@@ -63,7 +63,7 @@ static bool fastPWM = false;
|
||||
static void switchToFastPWM(void);
|
||||
|
||||
volatile uint16_t PWMSafetyTimer = 0;
|
||||
volatile uint8_t pendingPWM = 200;
|
||||
volatile uint8_t pendingPWM = 0;
|
||||
volatile bool lastPeriodWasFast = false;
|
||||
|
||||
// Timer 0 is used to co-ordinate the ADC and the output PWM
|
||||
@@ -91,6 +91,8 @@ void timer0_comp2_callback(void) {
|
||||
// Leave output off
|
||||
PWM_Channel_Disable(PWM_Channel);
|
||||
}
|
||||
} else {
|
||||
PWM_Channel_Disable(PWM_Channel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ void hardware_init() {
|
||||
gpio_write(TIP_RESISTANCE_SENSE, 0);
|
||||
|
||||
MSG((char *)"Magic Starting\r\n");
|
||||
PWM_Channel_Disable(PWM_Channel);
|
||||
setup_timer_scheduler();
|
||||
setup_adc();
|
||||
setup_pwm();
|
||||
@@ -57,6 +58,7 @@ void setup_pwm(void) {
|
||||
|
||||
PWM_Channel_Init(&cfg);
|
||||
PWM_Channel_Disable(PWM_Channel);
|
||||
gpio_set_mode(PWM_Out_Pin, GPIO21_FUN_PWM_CH1);
|
||||
}
|
||||
|
||||
const ADC_Chan_Type adc_tip_pos_chans[]
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
#define POWER_LIMIT_STEPS 5 //
|
||||
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_PINECIL // Uses TS100 resistors
|
||||
#define TEMP_uV_LOOKUP_HAKKO // Use Hakko lookup table
|
||||
#define USB_PD_VMAX 28 // Maximum voltage for PD to negotiate
|
||||
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
|
||||
#define PID_TIM_HZ (10) // Tick rate of the PID loop
|
||||
#define MAX_TEMP_C 450 // Max soldering temp selectable °C
|
||||
#define MAX_TEMP_F 850 // Max soldering temp selectable °F
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
#if defined(BSP_USING_PWM_CH1)
|
||||
#ifndef PWM_CH1_CONFIG
|
||||
#define PWM_CH1_CONFIG \
|
||||
{ .ch = 1, .polarity_invert_mode = DISABLE, .period = 100, .threshold_low = 50, .threshold_high = 0, .it_pulse_count = 0, }
|
||||
{ .ch = 1, .polarity_invert_mode = DISABLE, .period = 100, .threshold_low = 0, .threshold_high = 0, .it_pulse_count = 0, }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
|
||||
// <q> GPIO21 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio21 function
|
||||
#define CONFIG_GPIO21_FUNC GPIO21_FUN_PWM_CH1
|
||||
// #define CONFIG_GPIO21_FUNC GPIO21_FUN_PWM_CH1
|
||||
|
||||
// <q> GPIO22 <2> [GPIO_FUN_UNUSED//GPIO_FUN_I2S//GPIO_FUN_SPI//GPIO_FUN_I2C//GPIO_FUN_PWM//GPIO_FUN_CAM//GPIO_FUN_USB//GPIO_FUN_UART0_RTS//GPIO_FUN_UART1_RTS//GPIO_FUN_ETHER_MAC//GPIO_FUN_QDEC]
|
||||
// <i> config gpio22 function
|
||||
|
||||
Reference in New Issue
Block a user