Обновление
This commit is contained in:
parent
cb48120cec
commit
1efb4f816d
40
Pwms.c
40
Pwms.c
|
|
@ -13,15 +13,29 @@ void Bsp_Tpu_PwmCallback(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bsp_Tpu_OverflowCallBack(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() {
|
void Pwms_Init() {
|
||||||
tPwms *env = &PWMS;
|
tPwms *env = &PWMS;
|
||||||
|
|
||||||
PORT_InitType tInitStruct = {0};
|
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.u32PortPins = PORT_PIN_18;
|
||||||
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT4_FUNC_MODE;
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT4_FUNC_MODE;
|
||||||
PORT_InitPins(PORT_A, &tInitStruct);
|
PORT_InitPins(PORT_A, &tInitStruct);
|
||||||
|
|
@ -29,12 +43,30 @@ void Pwms_Init() {
|
||||||
PWM_Initial(
|
PWM_Initial(
|
||||||
&env->pwm,
|
&env->pwm,
|
||||||
PERIOD_TICKS,
|
PERIOD_TICKS,
|
||||||
PERIOD_TICKS * 10 / 100,
|
PERIOD_TICKS * 20 / 100,
|
||||||
0,
|
0U,
|
||||||
0x7,
|
0xFF,
|
||||||
Bsp_Tpu_PwmCallback,
|
Bsp_Tpu_PwmCallback,
|
||||||
Bsp_Tpu_OverflowCallBack
|
Bsp_Tpu_OverflowCallBack
|
||||||
);
|
);
|
||||||
|
|
||||||
env->pwmIo = vPwmGetIo(&env->pwm);
|
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
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
Pwms.h
4
Pwms.h
|
|
@ -6,10 +6,14 @@
|
||||||
#define FLAG_PWMS_H
|
#define FLAG_PWMS_H
|
||||||
|
|
||||||
#include "PwmFlagchip.h"
|
#include "PwmFlagchip.h"
|
||||||
|
#include "PwmCaptureFlagchip.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
tPwmFlagchip pwm;
|
tPwmFlagchip pwm;
|
||||||
tPwmIO pwmIo;
|
tPwmIO pwmIo;
|
||||||
|
|
||||||
|
tPwmCaptureFlagchip pwmCapture;
|
||||||
|
|
||||||
} tPwms;
|
} tPwms;
|
||||||
|
|
||||||
extern tPwms PWMS;
|
extern tPwms PWMS;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue