44 lines
912 B
C
44 lines
912 B
C
//
|
|
// Created by Cfif on 14.12.23.
|
|
//
|
|
#include <stdbool.h>
|
|
#include "fc7xxx_driver_port.h"
|
|
#include "Pwms.h"
|
|
|
|
|
|
tPwms PWMS;
|
|
|
|
void Bsp_Tpu_PwmCallback(void) {
|
|
TPU_PwmServiceReq(PWMS.pwm.TPU_PWM_CHANNEL,
|
|
PWMS.pwm.etpu_pwmconfig_tbl.u32ActiveTime,
|
|
PWMS.pwm.etpu_pwmconfig_tbl.u32PeriodTime);
|
|
}
|
|
|
|
void Bsp_Tpu_OverflowCallBack(void) {
|
|
|
|
}
|
|
|
|
|
|
void Pwms_Init(uint8_t percent) {
|
|
tPwms *env = &PWMS;
|
|
|
|
PORT_InitType tInitStruct = {0};
|
|
|
|
/* TPU_CH0: PortA 18: ALT4 */
|
|
tInitStruct.u32PortPins = PORT_PIN_18;
|
|
tInitStruct.uPortPinMux.u32PortPinMode = PORT_ALT4_FUNC_MODE;
|
|
PORT_InitPins(PORT_A, &tInitStruct);
|
|
|
|
env->pwm = PWM_Initial(
|
|
PERIOD_TICKS,
|
|
PERIOD_TICKS * percent / 100,
|
|
0,
|
|
0x7,
|
|
Bsp_Tpu_PwmCallback,
|
|
Bsp_Tpu_OverflowCallBack
|
|
|
|
);
|
|
|
|
env->pwmIo = vPwmGetIo(&env->pwm);
|
|
}
|