refactor: streamline opa_init()
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
void SYS_Config();
|
||||
void gpio_config();
|
||||
void opa_config();
|
||||
void opa_init(void);
|
||||
void adc_init(void);
|
||||
//-------------------------------------
|
||||
void llc_pwm_config(); // LLC
|
||||
|
||||
@@ -70,7 +70,7 @@ void SYS_Config()
|
||||
// PWR_EnterDeepSleepMode(_Pre_Proc, _Post_Proc); // use WDG wake up 1 sec
|
||||
|
||||
gpio_config();
|
||||
opa_config();
|
||||
opa_init();
|
||||
adc_init();
|
||||
llc_pwm_config(); // 初始化但不輸出 EPWM_CH1
|
||||
pfc_pwm_config(); // 初始化但不輸出 TIM2_CH1
|
||||
@@ -87,22 +87,9 @@ void SYS_Config()
|
||||
//===================================================================================
|
||||
void gpio_config()
|
||||
{
|
||||
//-----------------//
|
||||
// OPA
|
||||
// IN+ = PA8
|
||||
// IN- = PA9
|
||||
// OUT = PA7
|
||||
//-----------------//
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
#if 1
|
||||
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_07 | GPIO_Pin_08; // Pin_09 is set as power_ok
|
||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_ANAL;
|
||||
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
//-----------------//
|
||||
// PWM
|
||||
@@ -146,22 +133,22 @@ void gpio_config()
|
||||
#endif
|
||||
}
|
||||
//===================================================================================
|
||||
void opa_config(void)
|
||||
void opa_init(void)
|
||||
{
|
||||
// gpio
|
||||
GPIO_InitTypeDef gpio_init = { 0 };
|
||||
gpio_init.GPIO_Pin = GPIO_Pin_07 | GPIO_Pin_08; // Pin_09 is set as power_ok
|
||||
gpio_init.GPIO_Mode = GPIO_Mode_ANAL;
|
||||
gpio_init.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||
GPIO_Init(GPIOA, &gpio_init);
|
||||
|
||||
// opa
|
||||
OPAMP_InitTypeDef opa_init = { 0 };
|
||||
|
||||
opa_init.OPAMP_VinP = OPAMP_VinP_IO;
|
||||
opa_init.OPAMP_VinM = OPAMP_VinM_GND; // 設定內部 GND ,PIN 留給 POWER_OK
|
||||
opa_init.OPAMP_Vout = OPAMP_Vout_IO; // 拉到 IO,需要外部 500 ~ 1000pF 電容
|
||||
opa_init.OPAMP_Gain = OPAMP_PGAGain_15; // 使用最大 15 倍,減少 RS 功耗
|
||||
|
||||
// 正向放大器 OK
|
||||
// 電壓隨耦器 OK
|
||||
// 反向放大器 NG
|
||||
// V+ 接 1/2 VCC,差動放大器 OK
|
||||
|
||||
opa_init.OPAMP_VinP = OPAMP_VinP_IO; // PA8
|
||||
opa_init.OPAMP_VinM = OPAMP_VinM_GND; // internal GND, PIN 留給 POWER_OK
|
||||
opa_init.OPAMP_Vout = OPAMP_Vout_IO; // PA7, 拉到 IO PA7,需要外部 500 ~ 1000pF 電容
|
||||
opa_init.OPAMP_Gain = OPAMP_PGAGain_15; // x1~x16 as needed, 使用 15 倍, 減少 RS 功耗
|
||||
OPAMP_Init(OPAMP0, &opa_init);
|
||||
|
||||
OPAMP_Enable(OPAMP0);
|
||||
}
|
||||
//===================================================================================
|
||||
|
||||
Reference in New Issue
Block a user