From 1efb4f816d7be879da2ce8e3ecb379d37ad638d9 Mon Sep 17 00:00:00 2001 From: cfif Date: Mon, 22 Dec 2025 13:52:09 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Pwms.c | 40 ++++++++++++++++++++++++++++++++++++---- Pwms.h | 4 ++++ 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/Pwms.c b/Pwms.c index 19023d9..7b9dd52 100644 --- a/Pwms.c +++ b/Pwms.c @@ -13,15 +13,29 @@ void Bsp_Tpu_PwmCallback(void) { } void Bsp_Tpu_OverflowCallBack(void) { + asm("nop"); +} +void Bsp_Tpu_PwmCaptureCallback(void) { + Get_Set_Tpu_PwmCaptureCallback(&PWMS.pwmCapture); +} + +void Bsp_Tpu_Capture_OverflowCallBack(void) { + asm("nop"); } void Pwms_Init() { tPwms *env = &PWMS; PORT_InitType tInitStruct = {0}; +/* + // TPU_CH0: PortB 10: ALT6 + tInitStruct.u32PortPins = PORT_PIN_10; + tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT6_FUNC_MODE; + PORT_InitPins(PORT_B, &tInitStruct); +*/ - /* TPU_CH0: PortA 18: ALT4 */ + // TPU_CH0: PortA 18: ALT4 tInitStruct.u32PortPins = PORT_PIN_18; tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT4_FUNC_MODE; PORT_InitPins(PORT_A, &tInitStruct); @@ -29,12 +43,30 @@ void Pwms_Init() { PWM_Initial( &env->pwm, PERIOD_TICKS, - PERIOD_TICKS * 10 / 100, - 0, - 0x7, + PERIOD_TICKS * 20 / 100, + 0U, + 0xFF, Bsp_Tpu_PwmCallback, Bsp_Tpu_OverflowCallBack ); env->pwmIo = vPwmGetIo(&env->pwm); + + + + // TPU_CH8: PortA 31: ALT6 + tInitStruct.u32PortPins = PORT_PIN_31; + tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT6_FUNC_MODE; + PORT_InitPins(PORT_A, &tInitStruct); + + PWM_Capture_Initial( + &env->pwmCapture, + 0, + 0, + 8U, + 0xFF, + Bsp_Tpu_PwmCaptureCallback, + Bsp_Tpu_Capture_OverflowCallBack + ); + } diff --git a/Pwms.h b/Pwms.h index ab4d136..4a6d0d6 100644 --- a/Pwms.h +++ b/Pwms.h @@ -6,10 +6,14 @@ #define FLAG_PWMS_H #include "PwmFlagchip.h" +#include "PwmCaptureFlagchip.h" typedef struct { tPwmFlagchip pwm; tPwmIO pwmIo; + + tPwmCaptureFlagchip pwmCapture; + } tPwms; extern tPwms PWMS;