mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
arch/arm/stm32h5: STM32H5 PWM Driver (STM32H7 port)
Build Documentation / build-html (push) Has been cancelled
Build Documentation / build-html (push) Has been cancelled
Adding the stm32h5 pwm driver. This is almost an exact copy of the stm32h7 pwm driver. I confirmed the timers for the h5 are version v2 and added the preprocessor definition. This commit was tested on a stm32h5 nucleo-h563zi development board. Necessary board files and a pwm config have been added. Added pin mappings for all timer outputs. Signed-off-by: kywwilson11 <kwilson@2g-eng.com> Added documentation regarding nucleo-h563zi:pwm config. Removed CONFIG_STM32H5_PWM guard at the top. Fixed IRQs for tim1 and tim8. Added H5 to list of Timer IP v2 timers. Conditionally compile stm32_serial.c. Add stm32_pwm.c to CMakeLists.txt
This commit is contained in:
@@ -140,6 +140,14 @@ This configuration configures ADC1_IN3 and ADC1_IN10, which can be
|
|||||||
accessed at the CN9 A0 and A1 pins respectively. Modify
|
accessed at the CN9 A0 and A1 pins respectively. Modify
|
||||||
nucleo-h563zi/src/stm32_adc.c to enable more channels.
|
nucleo-h563zi/src/stm32_adc.c to enable more channels.
|
||||||
|
|
||||||
|
pwm:
|
||||||
|
--------
|
||||||
|
|
||||||
|
This configuration configures TIM1_CH1OUT, which can be
|
||||||
|
accessed at pin D6 on the CN10 A0 connector. TIM1_CH1 is configured
|
||||||
|
as a pwm output at /dev/pwm0, and can be tested with the example pwm
|
||||||
|
application.
|
||||||
|
|
||||||
adc_watchdog:
|
adc_watchdog:
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,10 @@ if(CONFIG_STM32H5_DTS)
|
|||||||
list(APPEND SRCS stm32_dts.c)
|
list(APPEND SRCS stm32_dts.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(CONFIG_STM32H5_PWM)
|
||||||
|
list(APPEND SRCS stm32_pwm.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Required chip type specific files
|
# Required chip type specific files
|
||||||
|
|
||||||
if(CONFIG_STM32H5_STM32H5XXXX)
|
if(CONFIG_STM32H5_STM32H5XXXX)
|
||||||
|
|||||||
@@ -323,6 +323,11 @@ config STM32H5_FDCAN
|
|||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
config STM32H5_PWM
|
||||||
|
bool
|
||||||
|
default n
|
||||||
|
select ARCH_HAVE_PWM_PULSECOUNT
|
||||||
|
|
||||||
config STM32H5_SPI
|
config STM32H5_SPI
|
||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ endif
|
|||||||
# Required STM32H5 files
|
# Required STM32H5 files
|
||||||
|
|
||||||
CHIP_CSRCS += stm32_gpio.c stm32_irq.c stm32_lowputc.c stm32_rcc.c
|
CHIP_CSRCS += stm32_gpio.c stm32_irq.c stm32_lowputc.c stm32_rcc.c
|
||||||
CHIP_CSRCS += stm32_serial.c stm32_start.c stm32_pwr.c stm32_timerisr.c
|
CHIP_CSRCS += stm32_start.c stm32_pwr.c stm32_timerisr.c
|
||||||
CHIP_CSRCS += stm32_lse.c stm32_lsi.c
|
CHIP_CSRCS += stm32_lse.c stm32_lsi.c
|
||||||
CHIP_CSRCS += stm32_uid.c
|
CHIP_CSRCS += stm32_uid.c
|
||||||
|
|
||||||
@@ -44,6 +44,10 @@ ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y)
|
|||||||
CHIP_CSRCS += stm32_idle.c
|
CHIP_CSRCS += stm32_idle.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_STM32H5_USART),y)
|
||||||
|
CHIP_CSRCS += stm32_serial.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_TIMER),y)
|
ifeq ($(CONFIG_TIMER),y)
|
||||||
CHIP_CSRCS += stm32_tim_lowerhalf.c
|
CHIP_CSRCS += stm32_tim_lowerhalf.c
|
||||||
endif
|
endif
|
||||||
@@ -96,6 +100,10 @@ ifeq ($(CONFIG_STM32H5_DTS),y)
|
|||||||
CHIP_CSRCS += stm32_dts.c
|
CHIP_CSRCS += stm32_dts.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_STM32H5_PWM),y)
|
||||||
|
CHIP_CSRCS += stm32_pwm.c
|
||||||
|
endif
|
||||||
|
|
||||||
# Required chip type specific files
|
# Required chip type specific files
|
||||||
|
|
||||||
ifeq ($(CONFIG_STM32H5_STM32H5XXXX),y)
|
ifeq ($(CONFIG_STM32H5_STM32H5XXXX),y)
|
||||||
|
|||||||
@@ -34,6 +34,10 @@
|
|||||||
* Pre-porcessor Definitions
|
* Pre-porcessor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* The STM32H5 family uses STM32 TIMER IP version 2 */
|
||||||
|
|
||||||
|
#define HAVE_IP_TIMERS_V2 1
|
||||||
|
|
||||||
/* Register Offsets *********************************************************/
|
/* Register Offsets *********************************************************/
|
||||||
|
|
||||||
/* Basic Timers - TIM6 and TIM7 */
|
/* Basic Timers - TIM6 and TIM7 */
|
||||||
|
|||||||
@@ -352,6 +352,165 @@
|
|||||||
#define GPIO_TRACED3_0 (GPIO_ALT|GPIO_AF0|GPIO_PORTC|GPIO_PIN12)
|
#define GPIO_TRACED3_0 (GPIO_ALT|GPIO_AF0|GPIO_PORTC|GPIO_PIN12)
|
||||||
#define GPIO_TRACED3_1 (GPIO_ALT|GPIO_AF0|GPIO_PORTE|GPIO_PIN6)
|
#define GPIO_TRACED3_1 (GPIO_ALT|GPIO_AF0|GPIO_PORTE|GPIO_PIN6)
|
||||||
|
|
||||||
|
/* Timers */
|
||||||
|
|
||||||
|
/* TIM1 (AF1) */
|
||||||
|
|
||||||
|
#define GPIO_TIM1_CH1OUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN8) /* PA8 */
|
||||||
|
#define GPIO_TIM1_CH1OUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTE|GPIO_PIN9) /* PE9 */
|
||||||
|
#define GPIO_TIM1_CH1OUT_3 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTH|GPIO_PIN11) /* PH11 */
|
||||||
|
|
||||||
|
#define GPIO_TIM1_CH1NOUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PORTA|GPIO_PIN7) /* PA7 */
|
||||||
|
#define GPIO_TIM1_CH1NOUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PORTB|GPIO_PIN13) /* PB13 */
|
||||||
|
#define GPIO_TIM1_CH1NOUT_3 (GPIO_ALT|GPIO_AF1|GPIO_PORTE|GPIO_PIN8) /* PE8 */
|
||||||
|
#define GPIO_TIM1_CH1NOUT_4 (GPIO_ALT|GPIO_AF1|GPIO_PORTH|GPIO_PIN10) /* PH10 */
|
||||||
|
|
||||||
|
#define GPIO_TIM1_CH2OUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN9) /* PA9 */
|
||||||
|
#define GPIO_TIM1_CH2OUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTE|GPIO_PIN11) /* PE11 */
|
||||||
|
#define GPIO_TIM1_CH2OUT_3 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTH|GPIO_PIN9) /* PH9 */
|
||||||
|
|
||||||
|
#define GPIO_TIM1_CH2NOUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PORTB|GPIO_PIN0) /* PB0 */
|
||||||
|
#define GPIO_TIM1_CH2NOUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PORTB|GPIO_PIN14) /* PB14 */
|
||||||
|
#define GPIO_TIM1_CH2NOUT_3 (GPIO_ALT|GPIO_AF1|GPIO_PORTE|GPIO_PIN10) /* PE10 */
|
||||||
|
#define GPIO_TIM1_CH2NOUT_4 (GPIO_ALT|GPIO_AF1|GPIO_PORTH|GPIO_PIN8) /* PH8 */
|
||||||
|
|
||||||
|
#define GPIO_TIM1_CH3OUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN10) /* PA10 */
|
||||||
|
#define GPIO_TIM1_CH3OUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTE|GPIO_PIN13) /* PE13 */
|
||||||
|
#define GPIO_TIM1_CH3OUT_3 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTH|GPIO_PIN7) /* PH7 */
|
||||||
|
|
||||||
|
#define GPIO_TIM1_CH3NOUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PORTB|GPIO_PIN1) /* PB1 */
|
||||||
|
#define GPIO_TIM1_CH3NOUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PORTB|GPIO_PIN15) /* PB15 */
|
||||||
|
#define GPIO_TIM1_CH3NOUT_3 (GPIO_ALT|GPIO_AF1|GPIO_PORTE|GPIO_PIN12) /* PE12 */
|
||||||
|
#define GPIO_TIM1_CH3NOUT_4 (GPIO_ALT|GPIO_AF1|GPIO_PORTH|GPIO_PIN6) /* PH6 */
|
||||||
|
|
||||||
|
#define GPIO_TIM1_CH4OUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN11) /* PA11 */
|
||||||
|
#define GPIO_TIM1_CH4OUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTE|GPIO_PIN14) /* PE14 */
|
||||||
|
|
||||||
|
#define GPIO_TIM1_CH4NOUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PORTE|GPIO_PIN15) /* PE15 */
|
||||||
|
#define GPIO_TIM1_CH4NOUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PORTC|GPIO_PIN5) /* PC5 */
|
||||||
|
|
||||||
|
/* TIM2 (AF1) */
|
||||||
|
|
||||||
|
#define GPIO_TIM2_CH1OUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN0) /* PA0 */
|
||||||
|
#define GPIO_TIM2_CH1OUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN5) /* PA5 */
|
||||||
|
#define GPIO_TIM2_CH1OUT_3 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN15) /* PA15 */
|
||||||
|
|
||||||
|
#define GPIO_TIM2_CH2OUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN1) /* PA1 */
|
||||||
|
#define GPIO_TIM2_CH2OUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN3) /* PB3 */
|
||||||
|
|
||||||
|
#define GPIO_TIM2_CH3OUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN2) /* PA2 */
|
||||||
|
#define GPIO_TIM2_CH3OUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN10) /* PB10 */
|
||||||
|
|
||||||
|
#define GPIO_TIM2_CH4OUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN3) /* PA3 */
|
||||||
|
#define GPIO_TIM2_CH4OUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN11) /* PB11 */
|
||||||
|
#define GPIO_TIM2_CH4OUT_3 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN4) /* PC4 */
|
||||||
|
|
||||||
|
/* TIM3 (AF2) */
|
||||||
|
|
||||||
|
#define GPIO_TIM3_CH1OUT_1 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN6) /* PA6 */
|
||||||
|
#define GPIO_TIM3_CH1OUT_2 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN4) /* PB4 */
|
||||||
|
#define GPIO_TIM3_CH1OUT_3 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN6) /* PC6 */
|
||||||
|
|
||||||
|
#define GPIO_TIM3_CH2OUT_1 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN7) /* PA7 */
|
||||||
|
#define GPIO_TIM3_CH2OUT_2 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN5) /* PB5 */
|
||||||
|
#define GPIO_TIM3_CH2OUT_3 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN7) /* PC7 */
|
||||||
|
|
||||||
|
#define GPIO_TIM3_CH3OUT_1 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN0) /* PB0 */
|
||||||
|
#define GPIO_TIM3_CH3OUT_2 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN8) /* PC8 */
|
||||||
|
|
||||||
|
#define GPIO_TIM3_CH4OUT_1 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN1) /* PB1 */
|
||||||
|
#define GPIO_TIM3_CH4OUT_2 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN9) /* PC9 */
|
||||||
|
|
||||||
|
/* TIM4 (AF2) */
|
||||||
|
|
||||||
|
#define GPIO_TIM4_CH1OUT_1 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN6) /* PB6 */
|
||||||
|
#define GPIO_TIM4_CH2OUT_1 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN7) /* PB7 */
|
||||||
|
#define GPIO_TIM4_CH3OUT_1 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN8) /* PB8 */
|
||||||
|
#define GPIO_TIM4_CH4OUT_1 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN9) /* PB9 */
|
||||||
|
#define GPIO_TIM4_CH4OUT_2 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN2) /* PC2 */
|
||||||
|
|
||||||
|
/* TIM5 (AF2) */
|
||||||
|
|
||||||
|
#define GPIO_TIM5_CH1OUT_1 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN0) /* PA0 */
|
||||||
|
#define GPIO_TIM5_CH1OUT_2 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTH|GPIO_PIN10) /* PH10 */
|
||||||
|
|
||||||
|
#define GPIO_TIM5_CH2OUT_1 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN1) /* PA1 */
|
||||||
|
#define GPIO_TIM5_CH2OUT_2 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTH|GPIO_PIN11) /* PH11 */
|
||||||
|
|
||||||
|
#define GPIO_TIM5_CH3OUT_1 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN2) /* PA2 */
|
||||||
|
#define GPIO_TIM5_CH3OUT_2 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTH|GPIO_PIN12) /* PH12 */
|
||||||
|
|
||||||
|
#define GPIO_TIM5_CH4OUT_1 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN3) /* PA3 */
|
||||||
|
#define GPIO_TIM5_CH4OUT_2 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTI|GPIO_PIN0) /* PI0 */
|
||||||
|
|
||||||
|
/* TIM8 (AF3) */
|
||||||
|
|
||||||
|
#define GPIO_TIM8_CH1OUT_1 (GPIO_ALT|GPIO_AF3|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN6) /* PC6 */
|
||||||
|
#define GPIO_TIM8_CH1OUT_2 (GPIO_ALT|GPIO_AF3|GPIO_PUSHPULL|GPIO_PORTI|GPIO_PIN5) /* PI5 */
|
||||||
|
#define GPIO_TIM8_CH1OUT_3 (GPIO_ALT|GPIO_AF3|GPIO_PUSHPULL|GPIO_PORTH|GPIO_PIN6) /* PH6 */
|
||||||
|
|
||||||
|
#define GPIO_TIM8_CH1NOUT_1 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN5) /* PA5 */
|
||||||
|
#define GPIO_TIM8_CH1NOUT_2 (GPIO_ALT|GPIO_AF3|GPIO_PORTA|GPIO_PIN7) /* PA7 */
|
||||||
|
#define GPIO_TIM8_CH1NOUT_3 (GPIO_ALT|GPIO_AF3|GPIO_PORTH|GPIO_PIN7) /* PH7 */
|
||||||
|
#define GPIO_TIM8_CH1NOUT_4 (GPIO_ALT|GPIO_AF3|GPIO_PORTH|GPIO_PIN13) /* PH13 */
|
||||||
|
|
||||||
|
#define GPIO_TIM8_CH2OUT_1 (GPIO_ALT|GPIO_AF3|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN7) /* PC7 */
|
||||||
|
#define GPIO_TIM8_CH2OUT_2 (GPIO_ALT|GPIO_AF3|GPIO_PUSHPULL|GPIO_PORTI|GPIO_PIN6) /* PI6 */
|
||||||
|
#define GPIO_TIM8_CH2OUT_3 (GPIO_ALT|GPIO_AF3|GPIO_PUSHPULL|GPIO_PORTH|GPIO_PIN8) /* PH8 */
|
||||||
|
|
||||||
|
#define GPIO_TIM8_CH2NOUT_1 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN0) /* PB0 */
|
||||||
|
#define GPIO_TIM8_CH2NOUT_2 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN14) /* PB14 */
|
||||||
|
#define GPIO_TIM8_CH2NOUT_3 (GPIO_ALT|GPIO_AF3|GPIO_PORTH|GPIO_PIN9) /* PH9 */
|
||||||
|
#define GPIO_TIM8_CH2NOUT_4 (GPIO_ALT|GPIO_AF3|GPIO_PORTH|GPIO_PIN14) /* PH14 */
|
||||||
|
|
||||||
|
#define GPIO_TIM8_CH3OUT_1 (GPIO_ALT|GPIO_AF3|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN8) /* PC8 */
|
||||||
|
#define GPIO_TIM8_CH3OUT_2 (GPIO_ALT|GPIO_AF3|GPIO_PUSHPULL|GPIO_PORTH|GPIO_PIN10) /* PH10 */
|
||||||
|
#define GPIO_TIM8_CH3OUT_3 (GPIO_ALT|GPIO_AF3|GPIO_PUSHPULL|GPIO_PORTI|GPIO_PIN7) /* PI7 */
|
||||||
|
|
||||||
|
#define GPIO_TIM8_CH3NOUT_1 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN1) /* PB1 */
|
||||||
|
#define GPIO_TIM8_CH3NOUT_2 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN15) /* PB15 */
|
||||||
|
#define GPIO_TIM8_CH3NOUT_3 (GPIO_ALT|GPIO_AF3|GPIO_PORTH|GPIO_PIN11) /* PH11 */
|
||||||
|
#define GPIO_TIM8_CH3NOUT_4 (GPIO_ALT|GPIO_AF3|GPIO_PORTH|GPIO_PIN15) /* PH15 */
|
||||||
|
|
||||||
|
#define GPIO_TIM8_CH4OUT_1 (GPIO_ALT|GPIO_AF3|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN9) /* PC9 */
|
||||||
|
#define GPIO_TIM8_CH4OUT_2 (GPIO_ALT|GPIO_AF3|GPIO_PUSHPULL|GPIO_PORTI|GPIO_PIN2) /* PI2 */
|
||||||
|
|
||||||
|
#define GPIO_TIM8_CH4NOUT_1 (GPIO_ALT|GPIO_AF3|GPIO_PORTB|GPIO_PIN2) /* PB2 */
|
||||||
|
|
||||||
|
/* TIM12 (AF2) */
|
||||||
|
|
||||||
|
#define GPIO_TIM12_CH1OUT_1 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN14) /* PB14 */
|
||||||
|
#define GPIO_TIM12_CH1OUT_2 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTH|GPIO_PIN6) /* PH6 */
|
||||||
|
|
||||||
|
#define GPIO_TIM12_CH2OUT_1 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN15) /* PB15 */
|
||||||
|
#define GPIO_TIM12_CH2OUT_2 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTH|GPIO_PIN9) /* PH9 */
|
||||||
|
|
||||||
|
/* TIM15 (AF2/AF4, per pin) */
|
||||||
|
|
||||||
|
#define GPIO_TIM15_CH1OUT_1 (GPIO_ALT|GPIO_AF4|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN2) /* PA2 */
|
||||||
|
#define GPIO_TIM15_CH1OUT_2 (GPIO_ALT|GPIO_AF4|GPIO_PUSHPULL|GPIO_PORTE|GPIO_PIN5) /* PE5 */
|
||||||
|
#define GPIO_TIM15_CH1OUT_3 (GPIO_ALT|GPIO_AF2|GPIO_PUSHPULL|GPIO_PORTC|GPIO_PIN12) /* PC12 */
|
||||||
|
|
||||||
|
#define GPIO_TIM15_CH1NOUT_1 (GPIO_ALT|GPIO_AF4|GPIO_PORTA|GPIO_PIN1) /* PA1 */
|
||||||
|
#define GPIO_TIM15_CH1NOUT_2 (GPIO_ALT|GPIO_AF4|GPIO_PORTE|GPIO_PIN4) /* PE4 */
|
||||||
|
|
||||||
|
#define GPIO_TIM15_CH2OUT_1 (GPIO_ALT|GPIO_AF4|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN3) /* PA3 */
|
||||||
|
#define GPIO_TIM15_CH2OUT_2 (GPIO_ALT|GPIO_AF4|GPIO_PUSHPULL|GPIO_PORTE|GPIO_PIN6) /* PE6 */
|
||||||
|
|
||||||
|
/* TIM16 (AF1) */
|
||||||
|
|
||||||
|
#define GPIO_TIM16_CH1OUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN8) /* PB8 */
|
||||||
|
#define GPIO_TIM16_CH1OUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTF|GPIO_PIN6) /* PF6 */
|
||||||
|
#define GPIO_TIM16_CH1NOUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PORTB|GPIO_PIN6) /* PB6 */
|
||||||
|
#define GPIO_TIM16_CH1NOUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PORTF|GPIO_PIN8) /* PF8 */
|
||||||
|
|
||||||
|
/* TIM17 (AF1) */
|
||||||
|
|
||||||
|
#define GPIO_TIM17_CH1OUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTB|GPIO_PIN9) /* PB9 */
|
||||||
|
#define GPIO_TIM17_CH1OUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PUSHPULL|GPIO_PORTF|GPIO_PIN7) /* PF7 */
|
||||||
|
#define GPIO_TIM17_CH1NOUT_1 (GPIO_ALT|GPIO_AF1|GPIO_PORTB|GPIO_PIN7) /* PB7 */
|
||||||
|
#define GPIO_TIM17_CH1NOUT_2 (GPIO_ALT|GPIO_AF1|GPIO_PORTF|GPIO_PIN9) /* PF9 */
|
||||||
|
|
||||||
/* UARTs/USARTs */
|
/* UARTs/USARTs */
|
||||||
|
|
||||||
/* UART4 */
|
/* UART4 */
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,56 @@
|
|||||||
|
#
|
||||||
|
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||||
|
#
|
||||||
|
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||||
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
|
# modifications.
|
||||||
|
#
|
||||||
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
|
# CONFIG_STANDARD_SERIAL is not set
|
||||||
|
CONFIG_ARCH="arm"
|
||||||
|
CONFIG_ARCH_BOARD="nucleo-h563zi"
|
||||||
|
CONFIG_ARCH_BOARD_NUCLEO_H563ZI=y
|
||||||
|
CONFIG_ARCH_BUTTONS=y
|
||||||
|
CONFIG_ARCH_CHIP="stm32h5"
|
||||||
|
CONFIG_ARCH_CHIP_STM32H563ZI=y
|
||||||
|
CONFIG_ARCH_CHIP_STM32H5=y
|
||||||
|
CONFIG_ARCH_INTERRUPTSTACK=2048
|
||||||
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
|
CONFIG_ARMV8M_STACKCHECK=y
|
||||||
|
CONFIG_BOARD_LOOPSPERMSEC=9251
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
|
CONFIG_DEBUG_ASSERTIONS=y
|
||||||
|
CONFIG_DEBUG_FEATURES=y
|
||||||
|
CONFIG_DEBUG_SYMBOLS=y
|
||||||
|
CONFIG_EXAMPLES_PWM=y
|
||||||
|
CONFIG_EXAMPLES_PWM_DURATION=60
|
||||||
|
CONFIG_FS_PROCFS=y
|
||||||
|
CONFIG_FS_PROCFS_REGISTER=y
|
||||||
|
CONFIG_HAVE_CXX=y
|
||||||
|
CONFIG_HAVE_CXXINITIALIZE=y
|
||||||
|
CONFIG_IDLETHREAD_STACKSIZE=2048
|
||||||
|
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||||
|
CONFIG_LINE_MAX=64
|
||||||
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
CONFIG_NSH_DISABLE_IFUPDOWN=y
|
||||||
|
CONFIG_NSH_FILEIOSIZE=512
|
||||||
|
CONFIG_NSH_READLINE=y
|
||||||
|
CONFIG_PREALLOC_TIMERS=4
|
||||||
|
CONFIG_PWM=y
|
||||||
|
CONFIG_RAM_SIZE=655360
|
||||||
|
CONFIG_RAM_START=0x20000000
|
||||||
|
CONFIG_RAW_BINARY=y
|
||||||
|
CONFIG_READLINE_CMD_HISTORY=y
|
||||||
|
CONFIG_READLINE_TABCOMPLETION=y
|
||||||
|
CONFIG_RR_INTERVAL=200
|
||||||
|
CONFIG_SCHED_WAITPID=y
|
||||||
|
CONFIG_STACK_COLORATION=y
|
||||||
|
CONFIG_STM32H5_TIM1=y
|
||||||
|
CONFIG_STM32H5_TIM1_CH1OUT=y
|
||||||
|
CONFIG_STM32H5_TIM1_PWM=y
|
||||||
|
CONFIG_STM32H5_USART3=y
|
||||||
|
CONFIG_SYSTEM_NSH=y
|
||||||
|
CONFIG_TASK_NAME_SIZE=0
|
||||||
|
CONFIG_TIMER=y
|
||||||
|
CONFIG_USART3_SERIAL_CONSOLE=y
|
||||||
@@ -322,6 +322,10 @@
|
|||||||
#define GPIO_ADC1_INP3 (GPIO_ADC1_INP3_0)
|
#define GPIO_ADC1_INP3 (GPIO_ADC1_INP3_0)
|
||||||
#define GPIO_ADC1_INP10 (GPIO_ADC1_INP10_0)
|
#define GPIO_ADC1_INP10 (GPIO_ADC1_INP10_0)
|
||||||
|
|
||||||
|
/* Timers / PWM */
|
||||||
|
|
||||||
|
#define GPIO_TIM1_CH1OUT GPIO_TIM1_CH1OUT_2 /* PE9 */
|
||||||
|
|
||||||
/* USART3 GPIOs *************************************************************/
|
/* USART3 GPIOs *************************************************************/
|
||||||
|
|
||||||
/* USART3 (Nucleo Virtual Console): Default board solder bridge configuration
|
/* USART3 (Nucleo Virtual Console): Default board solder bridge configuration
|
||||||
|
|||||||
@@ -51,4 +51,8 @@ ifeq ($(CONFIG_STM32H5_FDCAN),y)
|
|||||||
CSRCS += stm32_can.c
|
CSRCS += stm32_can.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_STM32H5_PWM),y)
|
||||||
|
CSRCS += stm32_pwm.c
|
||||||
|
endif
|
||||||
|
|
||||||
include $(TOPDIR)/boards/Board.mk
|
include $(TOPDIR)/boards/Board.mk
|
||||||
|
|||||||
@@ -145,5 +145,17 @@ int stm32_dts_setup(int devno);
|
|||||||
int stm32_can_setup(uint8_t port);
|
int stm32_can_setup(uint8_t port);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stm32_pwm_setup
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize PWM and register the PWM device.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_PWM
|
||||||
|
int stm32_pwm_setup(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __ASSEMBLY__ */
|
#endif /* __ASSEMBLY__ */
|
||||||
#endif /* __BOARDS_ARM_STM32H5_NUCLEO_H563ZI_SRC_NUCLEO_H563ZI_H */
|
#endif /* __BOARDS_ARM_STM32H5_NUCLEO_H563ZI_SRC_NUCLEO_H563ZI_H */
|
||||||
|
|||||||
@@ -139,6 +139,16 @@ int stm32_bringup(void)
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_PWM
|
||||||
|
/* Initialize PWM and register the PWM device. */
|
||||||
|
|
||||||
|
ret = stm32_pwm_setup();
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "ERROR: stm32_pwm_setup() failed: %d\n", ret);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
UNUSED(ret);
|
UNUSED(ret);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/arm/stm32h5/nucleo-h563zi/src/stm32_pwm.c
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the
|
||||||
|
* License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <nuttx/timers/pwm.h>
|
||||||
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
#include "chip.h"
|
||||||
|
#include "arm_internal.h"
|
||||||
|
#include "stm32_pwm.h"
|
||||||
|
#include "nucleo-h563zi.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Configuration ************************************************************/
|
||||||
|
|
||||||
|
#define HAVE_PWM 1
|
||||||
|
|
||||||
|
#ifndef CONFIG_PWM
|
||||||
|
# undef HAVE_PWM
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_STM32H5_TIM1
|
||||||
|
# undef HAVE_PWM
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CONFIG_STM32H5_TIM1_PWM
|
||||||
|
# undef HAVE_PWM
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: stm32_pwm_setup
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize PWM and register the PWM device.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int stm32_pwm_setup(void)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_PWM
|
||||||
|
static bool initialized = false;
|
||||||
|
struct pwm_lowerhalf_s *pwm;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Have we already initialized? */
|
||||||
|
|
||||||
|
if (!initialized)
|
||||||
|
{
|
||||||
|
/* Get an instance of the PWM interface */
|
||||||
|
|
||||||
|
pwm = stm32_pwminitialize(1);
|
||||||
|
if (!pwm)
|
||||||
|
{
|
||||||
|
tmrerr("ERROR: Failed to get the STM32 PWM lower half\n");
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Register the PWM driver at "/dev/pwm0" */
|
||||||
|
|
||||||
|
ret = pwm_register("/dev/pwm0", pwm);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
tmrerr("ERROR: pwm_register failed: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now we are initialized */
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
#else
|
||||||
|
return -ENODEV;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user