Обновление платы на V2
This commit is contained in:
parent
c720420517
commit
5107950ce0
|
|
@ -15,9 +15,10 @@ typedef struct {
|
||||||
TPU_InterruptCfgType etpu_Int_config_tbl;
|
TPU_InterruptCfgType etpu_Int_config_tbl;
|
||||||
TPU_PwmCfgType etpu_pwmconfig_tbl;
|
TPU_PwmCfgType etpu_pwmconfig_tbl;
|
||||||
|
|
||||||
uint8_t TPU_PWM_CHANNEL;
|
volatile uint32_t pendingActiveTime;
|
||||||
|
volatile bool updatePending;
|
||||||
|
|
||||||
osMessageQueueId_t q_u32ActiveTime;
|
uint8_t TPU_PWM_CHANNEL;
|
||||||
|
|
||||||
} tPwmFlagchip;
|
} tPwmFlagchip;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,9 @@
|
||||||
|
|
||||||
void Get_Set_Tpu_PwmCallback(tPwmFlagchip *env) {
|
void Get_Set_Tpu_PwmCallback(tPwmFlagchip *env) {
|
||||||
|
|
||||||
uint32_t data;
|
if (env->updatePending) {
|
||||||
|
env->etpu_pwmconfig_tbl.u32ActiveTime = env->pendingActiveTime;
|
||||||
osStatus_t cPeriodActiveTime = osMessageQueueGet(env->q_u32ActiveTime, &data, 0, 0);
|
env->updatePending = false;
|
||||||
|
|
||||||
if (cPeriodActiveTime == osOK) {
|
|
||||||
env->etpu_pwmconfig_tbl.u32ActiveTime = data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TPU_PwmServiceReq(env->TPU_PWM_CHANNEL, env->etpu_pwmconfig_tbl.u32ActiveTime,
|
TPU_PwmServiceReq(env->TPU_PWM_CHANNEL, env->etpu_pwmconfig_tbl.u32ActiveTime,
|
||||||
|
|
@ -29,7 +26,7 @@ void PWM_Initial(
|
||||||
TPU_EventCallbackType Bsp_Tpu_PwmCallback,
|
TPU_EventCallbackType Bsp_Tpu_PwmCallback,
|
||||||
TPU_TCR1OverflowCallbackType Bsp_Tpu_OverflowCallBack) {
|
TPU_TCR1OverflowCallbackType Bsp_Tpu_OverflowCallBack) {
|
||||||
|
|
||||||
env->q_u32ActiveTime = osMessageQueueNew(1, sizeof(uint32_t), NULL);
|
//env->q_u32ActiveTime = osMessageQueueNew(1, sizeof(uint32_t), NULL);
|
||||||
|
|
||||||
env->etpu_pwmconfig_tbl.eTBS1 = TPUE_EQUAL_ONLY_CAPBASE_TCR1_MATCHBASE_TCR1;
|
env->etpu_pwmconfig_tbl.eTBS1 = TPUE_EQUAL_ONLY_CAPBASE_TCR1_MATCHBASE_TCR1;
|
||||||
env->etpu_pwmconfig_tbl.eTBS2 = TPUE_EQUAL_ONLY_CAPBASE_TCR1_MATCHBASE_TCR1;
|
env->etpu_pwmconfig_tbl.eTBS2 = TPUE_EQUAL_ONLY_CAPBASE_TCR1_MATCHBASE_TCR1;
|
||||||
|
|
@ -83,10 +80,10 @@ static void setActivePercent(tPwmFlagchip *env, uint8_t percent) {
|
||||||
uint8_t final_percent;
|
uint8_t final_percent;
|
||||||
|
|
||||||
// Ограничения
|
// Ограничения
|
||||||
if (percent >= 100)
|
if (percent > 90)
|
||||||
percent = 99;
|
percent = 90;
|
||||||
if (percent == 0)
|
if (percent < 10)
|
||||||
percent = 1;
|
percent = 10;
|
||||||
|
|
||||||
// Для active LOW (bActiveHigh = false) нужна инверсия
|
// Для active LOW (bActiveHigh = false) нужна инверсия
|
||||||
// 10% → 90%, 20% → 80% и т.д.
|
// 10% → 90%, 20% → 80% и т.д.
|
||||||
|
|
@ -97,8 +94,10 @@ static void setActivePercent(tPwmFlagchip *env, uint8_t percent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Расчет времени активности в тактах
|
// Расчет времени активности в тактах
|
||||||
uint32_t data = env->etpu_pwmconfig_tbl.u32PeriodTime * final_percent / 100;
|
uint32_t activeTime = env->etpu_pwmconfig_tbl.u32PeriodTime * final_percent / 100;
|
||||||
osMessageQueuePut(env->q_u32ActiveTime, &data, 0, 0);
|
// Не обновляем напрямую, а ставим флаг
|
||||||
|
env->pendingActiveTime = activeTime;
|
||||||
|
env->updatePending = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue