Обновление
This commit is contained in:
commit
497d5664c9
|
|
@ -0,0 +1,36 @@
|
|||
//
|
||||
// Created by cfif on 17.11.22.
|
||||
//
|
||||
|
||||
#ifndef PWM_CAPTURE_FLAGCHIP_H
|
||||
#define PWM_CAPTURE_FLAGCHIP_H
|
||||
|
||||
#include "PwmIO.h"
|
||||
#include "cmsis_os2.h"
|
||||
#include "fc7xxx_driver_tpu.h"
|
||||
#include "interrupt_manager.h"
|
||||
|
||||
typedef struct {
|
||||
|
||||
TPU_InterruptCfgType etpu_Int_config_tbl;
|
||||
TPU_CaptureCfgType etpu_captureconfig_tbl;
|
||||
|
||||
uint8_t TPU_CAPTURE_CHANNEL;
|
||||
|
||||
} tPwmCaptureFlagchip;
|
||||
|
||||
|
||||
void PWM_Capture_Initial(
|
||||
tPwmCaptureFlagchip *env,
|
||||
uint32_t PeriodTime,
|
||||
uint32_t ActiveTime,
|
||||
uint8_t TPU_CAPTURE_CHANNEL,
|
||||
uint8 TPU0_CH_PRIORITY,
|
||||
TPU_EventCallbackType Bsp_Tpu_PwmCallback,
|
||||
TPU_TCR1OverflowCallbackType Bsp_Tpu_OverflowCallBack);
|
||||
|
||||
tPwmIO vPwmCaptureGetIo(tPwmCaptureFlagchip *env);
|
||||
|
||||
void Get_Set_Tpu_PwmCaptureCallback(tPwmCaptureFlagchip *env);
|
||||
|
||||
#endif //PWM_CAPTURE_FLAGCHIP_H
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
//
|
||||
// Created by cfif on 07.09.22.
|
||||
//
|
||||
#include <SystemDelayInterface.h>
|
||||
#include "PwmCaptureFlagchip.h"
|
||||
|
||||
|
||||
void Get_Set_Tpu_PwmCaptureCallback(tPwmCaptureFlagchip *env) {
|
||||
if (env->etpu_captureconfig_tbl.eMeasureMode == TPU_PeriodMeasurement) {
|
||||
TPU_CaptureMeasPeriodServiceReq(env->TPU_CAPTURE_CHANNEL, &env->etpu_captureconfig_tbl);
|
||||
} else {
|
||||
TPU_CaptureMeasActivePeriodServiceReq(env->TPU_CAPTURE_CHANNEL, &env->etpu_captureconfig_tbl);
|
||||
}
|
||||
}
|
||||
|
||||
void PWM_Capture_Initial(
|
||||
tPwmCaptureFlagchip *env,
|
||||
uint32_t PeriodTime,
|
||||
uint32_t ActiveTime,
|
||||
uint8_t TPU_CAPTURE_CHANNEL,
|
||||
uint8 TPU0_CH_PRIORITY,
|
||||
TPU_EventCallbackType Bsp_Tpu_PwmCallback,
|
||||
TPU_TCR1OverflowCallbackType Bsp_Tpu_OverflowCallBack) {
|
||||
|
||||
|
||||
env->etpu_captureconfig_tbl.u32PeriodTime = 0u;
|
||||
env->etpu_captureconfig_tbl.eMeasureMode = TPU_DutyMeasurementActiveHigh;
|
||||
env->etpu_captureconfig_tbl.eInputType = TPUE_DETECT_FALLING_EDGE_ONLY;
|
||||
env->etpu_captureconfig_tbl.u32SampleTime = 80000; // Ensure sample time > period
|
||||
env->etpu_captureconfig_tbl.u32ActiveTime = 0;
|
||||
env->etpu_captureconfig_tbl.LastTime = 0;
|
||||
env->etpu_captureconfig_tbl.StartTime = 0;
|
||||
|
||||
env->etpu_Int_config_tbl.bEventIntEn = (bool) true;
|
||||
env->etpu_Int_config_tbl.bTCR1OverFlowEventIntEn = (bool) true;
|
||||
env->etpu_Int_config_tbl.bTCR2OverFlowEventIntEn = (bool) false;
|
||||
env->etpu_Int_config_tbl.pEventNotify = Bsp_Tpu_PwmCallback;
|
||||
env->etpu_Int_config_tbl.pHSANotify = NULL;
|
||||
env->etpu_Int_config_tbl.pTCR1OverflowNotify = Bsp_Tpu_OverflowCallBack;
|
||||
env->etpu_Int_config_tbl.pTCR2OverflowNotify = NULL;
|
||||
env->etpu_Int_config_tbl.eChTrigType = TPUH_TDL1_OR_TDL2_EVENT_NOT_GATED_BY_TSR;
|
||||
|
||||
env->TPU_CAPTURE_CHANNEL = TPU_CAPTURE_CHANNEL;
|
||||
|
||||
|
||||
TPU_DeInit();
|
||||
TPU_Init();
|
||||
TPU_CaptureModeInit(TPU_CAPTURE_CHANNEL, &env->etpu_captureconfig_tbl);
|
||||
TPU_InitChannelInterrupt(TPU_CAPTURE_CHANNEL, &env->etpu_Int_config_tbl);
|
||||
|
||||
if (TPU_CAPTURE_CHANNEL <= 7) {
|
||||
NVIC_EnableIRQ(TPU0_CH0_7_IRQn);
|
||||
NVIC_SetPriority(TPU0_CH0_7_IRQn, 1);
|
||||
} else if (TPU_CAPTURE_CHANNEL <= 15) {
|
||||
NVIC_EnableIRQ(TPU0_CH8_15_IRQn);
|
||||
NVIC_SetPriority(TPU0_CH8_15_IRQn, 2);
|
||||
} else if (TPU_CAPTURE_CHANNEL <= 23) {
|
||||
NVIC_EnableIRQ(TPU0_CH16_23_IRQn);
|
||||
NVIC_SetPriority(TPU0_CH16_23_IRQn, 3);
|
||||
} else if (TPU_CAPTURE_CHANNEL <= 31) {
|
||||
NVIC_EnableIRQ(TPU0_CH24_31_IRQn);
|
||||
NVIC_SetPriority(TPU0_CH24_31_IRQn, 4);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
tPwmIO vPwmCaptureGetIo(tPwmCaptureFlagchip *env) {
|
||||
tPwmIO io = {
|
||||
.env = env,
|
||||
.run = (PwmIOTransaction) vPwmRun,
|
||||
.setActivePercent = (PwmIOTransactionSetActivePercent) setActivePercent
|
||||
};
|
||||
return io;
|
||||
}
|
||||
*/
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"cmake": {
|
||||
"inc_dirs": [
|
||||
"Inc"
|
||||
],
|
||||
"srcs": [
|
||||
"Src/**.c"
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue