代码暂存,除4G模组及日志外,其余全开,功耗50uA左右

This commit is contained in:
常正强 2025-03-27 10:16:52 +08:00
parent ebd6f63d50
commit 9381774250
6 changed files with 27 additions and 38 deletions

View File

@ -113,7 +113,7 @@
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.nostdinc.1633344562" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.nostdinc" useByScannerDiscovery="true" value="false" valueType="boolean"/> <option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.nostdinc.1633344562" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.nostdinc" useByScannerDiscovery="true" value="false" valueType="boolean"/>
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.preprocessonly.208069239" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.preprocessonly" useByScannerDiscovery="false" value="false" valueType="boolean"/> <option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.preprocessonly.208069239" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.preprocessonly" useByScannerDiscovery="false" value="false" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.177116515" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.177116515" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
<listOptionValue builtIn="false" value="CLK_OSC32K=0"/> <listOptionValue builtIn="false" value="CLK_OSC32K=1"/>
<listOptionValue builtIn="false" value="DEBUG=3"/> <listOptionValue builtIn="false" value="DEBUG=3"/>
</option> </option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.undef.1820512625" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.undef" useByScannerDiscovery="true" valueType="undefDefinedSymbols"/> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.undef.1820512625" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.undef" useByScannerDiscovery="true" valueType="undefDefinedSymbols"/>

View File

@ -104,9 +104,9 @@ int main(void)
#endif #endif
#ifdef DEBUG #ifdef DEBUG
BSP_UART3_Init(); BSP_UART3_Init();
logDebug("%s", TxBuff); logDebug("%s", TxBuff);
#endif #endif
logDebug("Start @ChipID=%02X\n", R8_CHIP_ID); logDebug("Start @ChipID=%02X\n", R8_CHIP_ID);
logDebug("%s\n", VER_LIB); logDebug("%s\n", VER_LIB);
@ -128,8 +128,8 @@ int main(void)
BSP_VBAT_Init(); BSP_VBAT_Init();
logDebug("VBAT init ok\n"); logDebug("VBAT init ok\n");
// BSP_Ml307r_Init(); // BSP_Ml307r_Init();
// logDebug("BSP_M1307r ok\n"); // logDebug("BSP_M1307r ok\n");
BSP_KEY_Init(app_task_handler); BSP_KEY_Init(app_task_handler);

View File

@ -150,7 +150,7 @@
"do_not_search_system_directories": false, "do_not_search_system_directories": false,
"preprocess_only": false, "preprocess_only": false,
"defined_symbols": [ "defined_symbols": [
"CLK_OSC32K=0", "CLK_OSC32K=1",
"DEBUG=3" "DEBUG=3"
], ],
"undefined_symbols": [] "undefined_symbols": []

View File

@ -48,7 +48,7 @@ uint16_t VBAT_ProcessEvent(uint8_t task_id, uint16_t events)
logDebug("adc_vbat =%d \n", adc_vbat); logDebug("adc_vbat =%d \n", adc_vbat);
vbat = (adc_vbat/1024.0-1)*1.05; vbat = (adc_vbat/1024.0-1)*1.05;
logDebug("vbat =%f \n", vbat); logDebug("vbat =%f \n", vbat);
tmos_start_task(vbat_task_id, VBAT_EVT_START, MS1_TO_SYSTEM_TIME(1000*10)); //1000*60 tmos_start_task(vbat_task_id, VBAT_EVT_START, MS1_TO_SYSTEM_TIME(1000*300)); //1000*60
return (events ^ VBAT_EVT_START); return (events ^ VBAT_EVT_START);
} }
return 0; return 0;

View File

@ -372,16 +372,11 @@ void Lower_IO_Deinit(void)
ADC_DisablePower(); ADC_DisablePower();
// BMP390 // BMP390
//片选低电平有效,初始为输出拉高
// CSB3: PA0 | CSB2: PA3 | CSB1: PA5
//GPIOA_SetBits(GPIO_Pin_0 | GPIO_Pin_3 | GPIO_Pin_5);
// GPIOA_ModeCfg(GPIO_Pin_0 | GPIO_Pin_3 | GPIO_Pin_5, GPIO_ModeIN_PD); //GPIO_ModeOut_PP_5mA
//中断引脚推挽和高电平有效模式
// INT1: PA2 | INT2: PA6 | INT3: PA12 // INT1: PA2 | INT2: PA6 | INT3: PA12
GPIOA_ModeCfg(GPIO_Pin_2 | GPIO_Pin_6 | GPIO_Pin_12, GPIO_ModeIN_PD); GPIOA_ModeCfg(GPIO_Pin_2 | GPIO_Pin_6 | GPIO_Pin_12, GPIO_ModeIN_PD);
// spi初始化 // spi初始化
GPIOA_ModeCfg(GPIO_Pin_13 | GPIO_Pin_14, GPIO_ModeIN_PD); //GPIO_ModeOut_PP_5mA GPIOA_ModeCfg(GPIO_Pin_13 | GPIO_Pin_14, GPIO_ModeIN_PD);
GPIOA_ModeCfg(GPIO_Pin_15, GPIO_ModeIN_PD); //GPIO_ModeIN_PU GPIOA_ModeCfg(GPIO_Pin_15, GPIO_ModeIN_PD);
//4G //4G
// 关闭3.8V供电 // 关闭3.8V供电
@ -403,23 +398,16 @@ void Lower_IO_Deinit(void)
GPIOB_ModeCfg(COIL_A | COIL_B, GPIO_ModeIN_PD); GPIOB_ModeCfg(COIL_A | COIL_B, GPIO_ModeIN_PD);
// UART3 // UART3
/*************************************** // GPIOB_ModeCfg(GPIO_Pin_21 | GPIO_Pin_20, GPIO_ModeIN_PD);
// 禁用UART3中断 // // 关闭UART3时钟
GPIOPinRemap(DISABLE, RB_PIN_UART3); // sys_safe_access_enable();
UART3_INTCfg(DISABLE, RB_IER_LINE_STAT | RB_IER_RECV_RDY | RB_IER_THR_EMPTY); // R8_SLP_CLK_OFF0 |= RB_SLP_CLK_UART3;
PFIC_DisableIRQ(UART3_IRQn); // sys_safe_access_disable();
// // 关闭shell和日志系统
// 将UART3的TX和RX引脚配置为输入上拉模式以降低功耗 // shell.write = NULL; // 禁用shell输出
GPIOB_ModeCfg(GPIO_Pin_21 | GPIO_Pin_20, GPIO_ModeIN_PD);
// 关闭UART3时钟 // 关闭外部低速晶振
sys_safe_access_enable(); GPIOA_ModeCfg(GPIO_Pin_10 | GPIO_Pin_11, GPIO_ModeIN_PD);
R8_SLP_CLK_OFF0 |= RB_SLP_CLK_UART3; // 设置UART3时钟关闭标志
sys_safe_access_disable();
// 关闭shell和日志系统
shell.write = NULL; // 禁用shell输出
*************************************************/
} }
void PRESS_LowPower(void) void PRESS_LowPower(void)
@ -629,7 +617,7 @@ BMP390_ProcessEvent(uint8_t task_id, uint16_t events)
P[2] = (uint32_t)(data.pressure / 100); P[2] = (uint32_t)(data.pressure / 100);
//printf("%d, %d, %d\r\n",T[0],T[1],T[2]); //printf("%d, %d, %d\r\n",T[0],T[1],T[2]);
printf("%d, %d, %d, %d, %d, %d, %d \r\n",T[0],T[1],T[2],P[0],P[1],P[2],P[0]-P[1]); // printf("%d, %d, %d, %d, %d, %d, %d \r\n",T[0],T[1],T[2],P[0],P[1],P[2],P[0]-P[1]);
} }
tmos_start_task(press_task_id, BMP390_IN_START, MS1_TO_SYSTEM_TIME(500)); //100 tmos_start_task(press_task_id, BMP390_IN_START, MS1_TO_SYSTEM_TIME(500)); //100
//tmos_start_task(press_task_id, BMP390_ATOM_START, MS1_TO_SYSTEM_TIME(1000)); //tmos_start_task(press_task_id, BMP390_ATOM_START, MS1_TO_SYSTEM_TIME(1000));
@ -740,10 +728,11 @@ uint16_t Check_ProcessEvent(uint8_t task_id, uint16_t events)
{ {
if (events & CHECK_EVT_START) if (events & CHECK_EVT_START)
{ {
// logDebug("fault_state = %d \r\n",fault_state);
if(!fault_state) if(!fault_state)
{ {
//超压检测 //超压检测
if(P[0] - P[2] >= 8000) if(P[0] - P[2] >= 80) //8000
{ {
VALVE_CLOSE(); VALVE_CLOSE();
fault_state = 1; fault_state = 1;
@ -751,7 +740,7 @@ uint16_t Check_ProcessEvent(uint8_t task_id, uint16_t events)
logDebug("motor high close"); logDebug("motor high close");
} }
//欠压检测 //欠压检测
if(P[0] - P[2] <= 800) if(P[0] - P[2] <= 80) //800
{ {
VALVE_CLOSE(); VALVE_CLOSE();
fault_state = 2; fault_state = 2;
@ -759,7 +748,7 @@ uint16_t Check_ProcessEvent(uint8_t task_id, uint16_t events)
logDebug("motor low close"); logDebug("motor low close");
} }
//过流检测 //过流检测
if( P[0] - P[1] >= 700) if( P[0] - P[1] >= 7) //700
{ {
VALVE_CLOSE(); VALVE_CLOSE();
fault_state = 3; fault_state = 3;
@ -811,20 +800,20 @@ void GPIOA_IRQHandler(void)
R16_PA_INT_IF = GPIO_Pin_6; R16_PA_INT_IF = GPIO_Pin_6;
flag = 1; flag = 1;
tmos_set_event(press_task_id, BMP390_EVT_READ); tmos_set_event(press_task_id, BMP390_EVT_READ);
logDebug("INT2 \r\n"); // logDebug("INT2 \r\n");
} }
else if (R16_PA_INT_IF & GPIO_Pin_12) else if (R16_PA_INT_IF & GPIO_Pin_12)
{ {
R16_PA_INT_IF = GPIO_Pin_12; R16_PA_INT_IF = GPIO_Pin_12;
flag = 2; flag = 2;
tmos_set_event(press_task_id, BMP390_EVT_READ); tmos_set_event(press_task_id, BMP390_EVT_READ);
logDebug("INT3 \r\n"); // logDebug("INT3 \r\n");
} }
else if (R16_PA_INT_IF & GPIO_Pin_2) else if (R16_PA_INT_IF & GPIO_Pin_2)
{ {
R16_PA_INT_IF = GPIO_Pin_2; R16_PA_INT_IF = GPIO_Pin_2;
flag = 3; flag = 3;
tmos_set_event(press_task_id, BMP390_EVT_READ); tmos_set_event(press_task_id, BMP390_EVT_READ);
logDebug("INT1 \r\n"); // logDebug("INT1 \r\n");
} }
} }

View File

@ -35,7 +35,7 @@ extern "C" {
#endif #endif
#ifndef LOG_ENABLE #ifndef LOG_ENABLE
#define LOG_ENABLE 1 /**< 使能log */ #define LOG_ENABLE 0 /**< 使能log */
#endif #endif
#if LOG_USING_LOCK == 1 #if LOG_USING_LOCK == 1