Add charge-pump driver for HS load switch
This commit is contained in:
@@ -40,8 +40,9 @@ endif # I2C
|
||||
|
||||
if PWM
|
||||
|
||||
config PWM_STM32_2
|
||||
config PWM_STM32_3
|
||||
default y
|
||||
depends on PWM
|
||||
|
||||
endif # PWM
|
||||
|
||||
|
||||
@@ -57,6 +57,17 @@
|
||||
};
|
||||
};
|
||||
|
||||
pwmouts {
|
||||
compatible = "pwm-out";
|
||||
|
||||
charge_pump: charge_pump {
|
||||
pwms = <&{/soc/timers@40000400/pwm} 1 4>; /* TIM3 */
|
||||
/* originally planned TIM8 not working with current Zephyr driver */
|
||||
/* pwms = <&{/soc/timers@40013400/pwm} 1 4>; */
|
||||
label = "Charge pump for HS MOSFET drivers";
|
||||
};
|
||||
};
|
||||
|
||||
switches {
|
||||
compatible = "switch";
|
||||
load {
|
||||
@@ -70,6 +81,7 @@
|
||||
uext-uart = &usart2;
|
||||
spi-uext = &spi1;
|
||||
i2c-uext = &i2c1;
|
||||
pwm-cp = &charge_pump;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -133,3 +145,12 @@
|
||||
&adc2 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
/* for charge pump and PWM solar input */
|
||||
&timers3 {
|
||||
status = "okay";
|
||||
|
||||
pwm {
|
||||
status = "okay";
|
||||
};
|
||||
};
|
||||
@@ -12,6 +12,9 @@
|
||||
|
||||
#include <pinmux/stm32/pinmux_stm32.h>
|
||||
|
||||
#define STM32G4X_PINMUX_FUNC_PC6_PWM8_CH1 \
|
||||
(STM32_PINMUX_ALT_FUNC_4 | STM32_PUSHPULL_NOPULL)
|
||||
|
||||
static const struct pin_config pinconf[] = {
|
||||
#ifdef CONFIG_UART_1
|
||||
{STM32_PIN_PA9, STM32G4X_PINMUX_FUNC_PA9_USART1_TX},
|
||||
@@ -32,6 +35,12 @@ static const struct pin_config pinconf[] = {
|
||||
#ifdef CONFIG_PWM_STM32_2
|
||||
{STM32_PIN_PA5, STM32G4X_PINMUX_FUNC_PA5_PWM2_CH1},
|
||||
#endif /* CONFIG_PWM_STM32_2 */
|
||||
#ifdef CONFIG_PWM_STM32_3
|
||||
{STM32_PIN_PC6, STM32G4X_PINMUX_FUNC_PC6_PWM3_CH1},
|
||||
#endif /* CONFIG_PWM_STM32_3 */
|
||||
#ifdef CONFIG_PWM_STM32_8
|
||||
{STM32_PIN_PC6, STM32G4X_PINMUX_FUNC_PC6_PWM8_CH1},
|
||||
#endif /* CONFIG_PWM_STM32_8 */
|
||||
#ifdef CONFIG_SPI_1
|
||||
/* SPI1 on the Arduino connectors pins A2, D3, D11, D12 */
|
||||
#ifdef CONFIG_SPI_STM32_USE_HW_SS
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <zephyr.h>
|
||||
#include <device.h>
|
||||
#include <drivers/gpio.h>
|
||||
#include <drivers/pwm.h>
|
||||
|
||||
#if defined(CONFIG_SOC_SERIES_STM32L0X)
|
||||
#include <stm32l0xx_ll_system.h>
|
||||
@@ -231,6 +232,19 @@ void usb_out_set(bool status)
|
||||
#endif
|
||||
}
|
||||
|
||||
void load_cp_enable()
|
||||
{
|
||||
#ifdef DT_PWM_OUT_CHARGE_PUMP_PWMS_CONTROLLER
|
||||
struct device *pwm_dev;
|
||||
pwm_dev = device_get_binding(DT_PWM_OUT_CHARGE_PUMP_PWMS_CONTROLLER);
|
||||
if (!pwm_dev) {
|
||||
print_error("Cannot find %s!\n", DT_PWM_OUT_CHARGE_PUMP_PWMS_CONTROLLER);
|
||||
return;
|
||||
}
|
||||
pwm_pin_set_usec(pwm_dev, DT_PWM_OUT_CHARGE_PUMP_PWMS_CHANNEL, 200, 100, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void load_out_init()
|
||||
{
|
||||
#ifdef DT_SWITCH_LOAD_GPIOS_CONTROLLER
|
||||
@@ -239,6 +253,9 @@ void load_out_init()
|
||||
|
||||
// analog comparator to detect short circuits and trigger immediate load switch-off
|
||||
short_circuit_comp_init();
|
||||
|
||||
// enable charge pump for high-side switches (if existing)
|
||||
load_cp_enable();
|
||||
}
|
||||
|
||||
void usb_out_init()
|
||||
|
||||
@@ -12,6 +12,8 @@ CONFIG_I2C_1=y
|
||||
CONFIG_ADC=y
|
||||
CONFIG_ADC_1=y
|
||||
|
||||
CONFIG_PWM=y
|
||||
|
||||
# disable log by default to save memory for STM32F0 with little RAM
|
||||
CONFIG_LOG=y
|
||||
CONFIG_LOG_MINIMAL=y
|
||||
|
||||
Reference in New Issue
Block a user