Обновление
This commit is contained in:
parent
2519f4815f
commit
712e430fb5
272
Pwms.c
272
Pwms.c
|
|
@ -10,40 +10,274 @@
|
||||||
|
|
||||||
tPwms PWMS;
|
tPwms PWMS;
|
||||||
|
|
||||||
void Bsp_Tpu_PwmCallback(void) {
|
|
||||||
Get_Set_Tpu_PwmCallback(&PWMS.pwm);
|
//начало--------------------------PwmFront-------------------------------------------------
|
||||||
|
//начало--------------------------PwmFront-------------------------------------------------
|
||||||
|
//начало--------------------------PwmFront-------------------------------------------------
|
||||||
|
void Bsp_Tpu_PwmFrontCallback(void) {
|
||||||
|
Get_Set_Tpu_PwmCallback(&PWMS.pwmFront);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bsp_Tpu_OverflowCallBack(void) {
|
void Bsp_Tpu_PwmFrontOverflowCallBack(void) {
|
||||||
asm("nop");
|
asm("nop");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bsp_Tpu_PwmCaptureCallback(void) {
|
void Bsp_Tpu_PwmFrontCaptureCallback(void) {
|
||||||
Get_Set_Tpu_PwmCaptureCallback(&PWMS.pwmCapture);
|
Get_Set_Tpu_PwmCaptureCallback(&PWMS.pwmFrontCapture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bsp_Tpu_Capture_OverflowCallBack(void) {
|
void Bsp_Tpu_PwmFrontCapture_OverflowCallBack(void) {
|
||||||
asm("nop");
|
asm("nop");
|
||||||
}
|
}
|
||||||
|
//конец--------------------------PwmFront-------------------------------------------------
|
||||||
|
//конец--------------------------PwmFront-------------------------------------------------
|
||||||
|
//конец--------------------------PwmFront-------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
//начало--------------------------PwmRear-------------------------------------------------
|
||||||
|
//начало--------------------------PwmRear-------------------------------------------------
|
||||||
|
//начало--------------------------PwmRear-------------------------------------------------
|
||||||
|
void Bsp_Tpu_PwmRearCallback(void) {
|
||||||
|
Get_Set_Tpu_PwmCallback(&PWMS.pwmRear);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bsp_Tpu_PwmRearOverflowCallBack(void) {
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bsp_Tpu_PwmRearCaptureCallback(void) {
|
||||||
|
Get_Set_Tpu_PwmCaptureCallback(&PWMS.pwmFrontCapture);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bsp_Tpu_PwmRearCapture_OverflowCallBack(void) {
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
//конец--------------------------PwmRear-------------------------------------------------
|
||||||
|
//конец--------------------------PwmRear-------------------------------------------------
|
||||||
|
//конец--------------------------PwmRear-------------------------------------------------
|
||||||
|
|
||||||
|
//начало--------------------------PwmFrontReserve-------------------------------------------------
|
||||||
|
//начало--------------------------PwmFrontReserve-------------------------------------------------
|
||||||
|
//начало--------------------------PwmFrontReserve-------------------------------------------------
|
||||||
|
void Bsp_Tpu_PwmFrontReserveCallback(void) {
|
||||||
|
Get_Set_Tpu_PwmCallback(&PWMS.pwmFrontReserved);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bsp_Tpu_PwmFrontReserveOverflowCallBack(void) {
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bsp_Tpu_PwmFrontReserveCaptureCallback(void) {
|
||||||
|
Get_Set_Tpu_PwmCaptureCallback(&PWMS.pwmFrontReservedCapture);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bsp_Tpu_PwmFrontReserveCapture_OverflowCallBack(void) {
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
//конец--------------------------PwmFrontReserve-------------------------------------------------
|
||||||
|
//конец--------------------------PwmFrontReserve-------------------------------------------------
|
||||||
|
//конец--------------------------PwmFrontReserve-------------------------------------------------
|
||||||
|
|
||||||
|
//начало--------------------------PwmRearReserve-------------------------------------------------
|
||||||
|
//начало--------------------------PwmRearReserve-------------------------------------------------
|
||||||
|
//начало--------------------------PwmRearReserve-------------------------------------------------
|
||||||
|
void Bsp_Tpu_PwmRearReserveCallback(void) {
|
||||||
|
Get_Set_Tpu_PwmCallback(&PWMS.pwmRearReserved);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bsp_Tpu_PwmRearReserveOverflowCallBack(void) {
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bsp_Tpu_PwmRearReserveCaptureCallback(void) {
|
||||||
|
Get_Set_Tpu_PwmCaptureCallback(&PWMS.pwmRearReservedCapture);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bsp_Tpu_PwmRearReserveCapture_OverflowCallBack(void) {
|
||||||
|
asm("nop");
|
||||||
|
}
|
||||||
|
//конец--------------------------PwmRearReserve-------------------------------------------------
|
||||||
|
//конец--------------------------PwmRearReserve-------------------------------------------------
|
||||||
|
//конец--------------------------PwmRearReserve-------------------------------------------------
|
||||||
|
|
||||||
void Pwms_Init(tLoggerInterface *logger) {
|
void Pwms_Init(tLoggerInterface *logger) {
|
||||||
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
|
//начало--------------------------PwmFront-------------------------------------------------
|
||||||
tInitStruct.u32PortPins = PORT_PIN_18;
|
//начало--------------------------PwmFront-------------------------------------------------
|
||||||
|
//начало--------------------------PwmFront-------------------------------------------------
|
||||||
|
|
||||||
|
// TPU_CH4: PortD 4: ALT7
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_4;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT7_FUNC_MODE;
|
||||||
|
PORT_InitPins(PORT_D, &tInitStruct);
|
||||||
|
|
||||||
|
PWM_Initial(
|
||||||
|
&env->pwmFront,
|
||||||
|
true,
|
||||||
|
PERIOD_TICKS,
|
||||||
|
PERIOD_TICKS * 5 / 100,
|
||||||
|
4U,
|
||||||
|
0xFF,
|
||||||
|
Bsp_Tpu_PwmFrontCallback,
|
||||||
|
Bsp_Tpu_PwmFrontOverflowCallBack
|
||||||
|
);
|
||||||
|
|
||||||
|
env->pwmFrontIo = vPwmGetIo(&env->pwmFront);
|
||||||
|
|
||||||
|
|
||||||
|
// TPU_CH3: PortD 3: ALT7
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_3;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT7_FUNC_MODE;
|
||||||
|
PORT_InitPins(PORT_D, &tInitStruct);
|
||||||
|
|
||||||
|
PWM_Capture_Initial(
|
||||||
|
&env->pwmFrontCapture,
|
||||||
|
false,
|
||||||
|
3U,
|
||||||
|
0xFF,
|
||||||
|
Bsp_Tpu_PwmFrontCaptureCallback,
|
||||||
|
Bsp_Tpu_PwmFrontCapture_OverflowCallBack
|
||||||
|
);
|
||||||
|
|
||||||
|
env->pwmFrontCaptureIO = vPwmCaptureGetIo(&env->pwmFrontCapture);
|
||||||
|
//конец--------------------------PwmFront-------------------------------------------------
|
||||||
|
//конец--------------------------PwmFront-------------------------------------------------
|
||||||
|
//конец--------------------------PwmFront-------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
//начало--------------------------PwmRear-------------------------------------------------
|
||||||
|
//начало--------------------------PwmRear-------------------------------------------------
|
||||||
|
//начало--------------------------PwmRear-------------------------------------------------
|
||||||
|
|
||||||
|
// TPU_CH27: PortD 23: ALT5
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_23;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT5_FUNC_MODE;
|
||||||
|
PORT_InitPins(PORT_D, &tInitStruct);
|
||||||
|
|
||||||
|
PWM_Initial(
|
||||||
|
&env->pwmRear,
|
||||||
|
true,
|
||||||
|
PERIOD_TICKS,
|
||||||
|
PERIOD_TICKS * 5 / 100,
|
||||||
|
27U,
|
||||||
|
0xFF,
|
||||||
|
Bsp_Tpu_PwmRearCallback,
|
||||||
|
Bsp_Tpu_PwmRearOverflowCallBack
|
||||||
|
);
|
||||||
|
|
||||||
|
env->pwmFrontIo = vPwmGetIo(&env->pwmFront);
|
||||||
|
|
||||||
|
|
||||||
|
// TPU_CH17: PortD 21: ALT4
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_21;
|
||||||
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT4_FUNC_MODE;
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT4_FUNC_MODE;
|
||||||
PORT_InitPins(PORT_A, &tInitStruct);
|
PORT_InitPins(PORT_D, &tInitStruct);
|
||||||
*/
|
|
||||||
|
|
||||||
|
PWM_Capture_Initial(
|
||||||
|
&env->pwmRearCapture,
|
||||||
|
false,
|
||||||
|
17U,
|
||||||
|
0xFF,
|
||||||
|
Bsp_Tpu_PwmRearCaptureCallback,
|
||||||
|
Bsp_Tpu_PwmRearCapture_OverflowCallBack
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
env->pwmRearCaptureIO = vPwmCaptureGetIo(&env->pwmRearCapture);
|
||||||
|
//конец--------------------------PwmRear-------------------------------------------------
|
||||||
|
//конец--------------------------PwmRear-------------------------------------------------
|
||||||
|
//конец--------------------------PwmRear-------------------------------------------------
|
||||||
|
|
||||||
|
//начало--------------------------PwmFrontReserve-------------------------------------------------
|
||||||
|
//начало--------------------------PwmFrontReserve-------------------------------------------------
|
||||||
|
//начало--------------------------PwmFrontReserve-------------------------------------------------
|
||||||
|
|
||||||
|
// TPU_CH23: PortD 30: ALT6
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_31;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT6_FUNC_MODE;
|
||||||
|
PORT_InitPins(PORT_C, &tInitStruct);
|
||||||
|
|
||||||
|
PWM_Initial(
|
||||||
|
&env->pwmFrontReserved,
|
||||||
|
true,
|
||||||
|
PERIOD_TICKS,
|
||||||
|
PERIOD_TICKS * 5 / 100,
|
||||||
|
23U,
|
||||||
|
0xFF,
|
||||||
|
Bsp_Tpu_PwmFrontReserveCallback,
|
||||||
|
Bsp_Tpu_PwmFrontReserveOverflowCallBack
|
||||||
|
);
|
||||||
|
|
||||||
|
env->pwmFrontIo = vPwmGetIo(&env->pwmFrontReserved);
|
||||||
|
|
||||||
|
|
||||||
|
// TPU_CH21: PortC 29: ALT6
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_29;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT6_FUNC_MODE;
|
||||||
|
PORT_InitPins(PORT_C, &tInitStruct);
|
||||||
|
|
||||||
|
PWM_Capture_Initial(
|
||||||
|
&env->pwmFrontReservedCapture,
|
||||||
|
false,
|
||||||
|
21U,
|
||||||
|
0xFF,
|
||||||
|
Bsp_Tpu_PwmFrontReserveCaptureCallback,
|
||||||
|
Bsp_Tpu_PwmFrontReserveCapture_OverflowCallBack
|
||||||
|
);
|
||||||
|
|
||||||
|
env->pwmFrontReservedCaptureIO = vPwmCaptureGetIo(&env->pwmFrontReservedCapture);
|
||||||
|
//конец--------------------------PwmFrontReserve-------------------------------------------------
|
||||||
|
//конец--------------------------PwmFrontReserve-------------------------------------------------
|
||||||
|
//конец--------------------------PwmFrontReserve-------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
//начало--------------------------PwmRearReserve-------------------------------------------------
|
||||||
|
//начало--------------------------PwmRearReserve-------------------------------------------------
|
||||||
|
//начало--------------------------PwmRearReserve-------------------------------------------------
|
||||||
|
|
||||||
|
// TPU_CH15: PortD 30: ALT6
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_30;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT6_FUNC_MODE;
|
||||||
|
PORT_InitPins(PORT_D, &tInitStruct);
|
||||||
|
|
||||||
|
PWM_Initial(
|
||||||
|
&env->pwmRearReserved,
|
||||||
|
true,
|
||||||
|
PERIOD_TICKS,
|
||||||
|
PERIOD_TICKS * 5 / 100,
|
||||||
|
15U,
|
||||||
|
0xFF,
|
||||||
|
Bsp_Tpu_PwmRearReserveCallback,
|
||||||
|
Bsp_Tpu_PwmRearReserveOverflowCallBack
|
||||||
|
);
|
||||||
|
|
||||||
|
env->pwmFrontIo = vPwmGetIo(&env->pwmRearReserved);
|
||||||
|
|
||||||
|
|
||||||
|
// TPU_CH14: PortD 29: ALT6
|
||||||
|
tInitStruct.u32PortPins = PORT_PIN_29;
|
||||||
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT6_FUNC_MODE;
|
||||||
|
PORT_InitPins(PORT_D, &tInitStruct);
|
||||||
|
|
||||||
|
PWM_Capture_Initial(
|
||||||
|
&env->pwmRearReservedCapture,
|
||||||
|
false,
|
||||||
|
14U,
|
||||||
|
0xFF,
|
||||||
|
Bsp_Tpu_PwmRearReserveCaptureCallback,
|
||||||
|
Bsp_Tpu_PwmRearReserveCapture_OverflowCallBack
|
||||||
|
);
|
||||||
|
|
||||||
|
env->pwmRearReservedCaptureIO = vPwmCaptureGetIo(&env->pwmRearReservedCapture);
|
||||||
|
//конец--------------------------PwmRearReserve-------------------------------------------------
|
||||||
|
//конец--------------------------PwmRearReserve-------------------------------------------------
|
||||||
|
//конец--------------------------PwmRearReserve-------------------------------------------------
|
||||||
|
|
||||||
|
/*
|
||||||
// TPU_CH0: PortB 8: ALT5
|
// TPU_CH0: PortB 8: ALT5
|
||||||
tInitStruct.u32PortPins = PORT_PIN_8;
|
tInitStruct.u32PortPins = PORT_PIN_8;
|
||||||
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT5_FUNC_MODE;
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT5_FUNC_MODE;
|
||||||
|
|
@ -63,7 +297,6 @@ void Pwms_Init(tLoggerInterface *logger) {
|
||||||
env->pwmIo = vPwmGetIo(&env->pwm);
|
env->pwmIo = vPwmGetIo(&env->pwm);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TPU_CH1: PortA 0: ALT5
|
// TPU_CH1: PortA 0: ALT5
|
||||||
tInitStruct.u32PortPins = PORT_PIN_0;
|
tInitStruct.u32PortPins = PORT_PIN_0;
|
||||||
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT5_FUNC_MODE;
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT5_FUNC_MODE;
|
||||||
|
|
@ -77,9 +310,10 @@ void Pwms_Init(tLoggerInterface *logger) {
|
||||||
Bsp_Tpu_PwmCaptureCallback,
|
Bsp_Tpu_PwmCaptureCallback,
|
||||||
Bsp_Tpu_Capture_OverflowCallBack
|
Bsp_Tpu_Capture_OverflowCallBack
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
LoggerInfoStatic(LOGGER, LOG_SIGN, "Initialization PWM - OK")
|
LoggerInfoStatic(LOGGER, LOG_SIGN, "Initialization PWM - OK")
|
||||||
|
|
||||||
env->pwmCaptureIO = vPwmCaptureGetIo(&env->pwmCapture);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
24
Pwms.h
24
Pwms.h
|
|
@ -10,12 +10,32 @@
|
||||||
#include "LoggerInterface.h"
|
#include "LoggerInterface.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
tPwmFlagchip pwmFront;
|
||||||
|
tPwmIO pwmFrontIo;
|
||||||
|
tPwmCaptureFlagchip pwmFrontCapture;
|
||||||
|
tPwmCaptureIO pwmFrontCaptureIO;
|
||||||
|
|
||||||
|
tPwmFlagchip pwmRear;
|
||||||
|
tPwmIO pwmRearIo;
|
||||||
|
tPwmCaptureFlagchip pwmRearCapture;
|
||||||
|
tPwmCaptureIO pwmRearCaptureIO;
|
||||||
|
|
||||||
|
tPwmFlagchip pwmFrontReserved;
|
||||||
|
tPwmIO pwmFrontReservedIo;
|
||||||
|
tPwmCaptureFlagchip pwmFrontReservedCapture;
|
||||||
|
tPwmCaptureIO pwmFrontReservedCaptureIO;
|
||||||
|
|
||||||
|
tPwmFlagchip pwmRearReserved;
|
||||||
|
tPwmIO pwmRearReservedIo;
|
||||||
|
tPwmCaptureFlagchip pwmRearReservedCapture;
|
||||||
|
tPwmCaptureIO pwmRearReservedCaptureIO;
|
||||||
|
|
||||||
|
/*
|
||||||
tPwmFlagchip pwm;
|
tPwmFlagchip pwm;
|
||||||
tPwmIO pwmIo;
|
tPwmIO pwmIo;
|
||||||
|
|
||||||
tPwmCaptureFlagchip pwmCapture;
|
tPwmCaptureFlagchip pwmCapture;
|
||||||
tPwmCaptureIO pwmCaptureIO;
|
tPwmCaptureIO pwmCaptureIO;
|
||||||
|
*/
|
||||||
} tPwms;
|
} tPwms;
|
||||||
|
|
||||||
extern tPwms PWMS;
|
extern tPwms PWMS;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue