代码暂存,除4G模组外,其余功能全开,日志及串口均开启,功耗90uA左右
This commit is contained in:
parent
657723ef1e
commit
ebd6f63d50
|
@ -114,7 +114,7 @@
|
|||
<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">
|
||||
<listOptionValue builtIn="false" value="CLK_OSC32K=0"/>
|
||||
<listOptionValue builtIn="false" value="DEBUG=5"/>
|
||||
<listOptionValue builtIn="false" value="DEBUG=3"/>
|
||||
</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.include.paths.1567947810" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
||||
|
|
|
@ -79,7 +79,7 @@ void Main_Circulation()
|
|||
while(1)
|
||||
{
|
||||
TMOS_SystemProcess();
|
||||
// KEY_ProcessLoop();
|
||||
KEY_ProcessLoop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ int main(void)
|
|||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
// BSP_UART3_Init();
|
||||
BSP_UART3_Init();
|
||||
|
||||
logDebug("%s", TxBuff);
|
||||
#endif
|
||||
|
@ -120,20 +120,19 @@ int main(void)
|
|||
Peripheral_Init();
|
||||
logDebug("Peripheral init ok\n");
|
||||
|
||||
// BSP_MOTOR_Init();
|
||||
//
|
||||
// VALVE_OPEN();
|
||||
//
|
||||
// BSP_LED_Init();
|
||||
//
|
||||
BSP_MOTOR_Init();
|
||||
VALVE_OPEN();
|
||||
|
||||
BSP_LED_Init();
|
||||
|
||||
BSP_VBAT_Init();
|
||||
logDebug("VBAT init ok\n");
|
||||
//
|
||||
|
||||
// BSP_Ml307r_Init();
|
||||
// logDebug("BSP_M1307r ok\n");
|
||||
//
|
||||
// BSP_KEY_Init(app_task_handler);
|
||||
//
|
||||
|
||||
BSP_KEY_Init(app_task_handler);
|
||||
|
||||
BSP_PRESS_Init();
|
||||
logDebug("BSP init ok\n");
|
||||
|
||||
|
|
|
@ -99,16 +99,16 @@
|
|||
#define HAL_LED FALSE
|
||||
#endif
|
||||
#ifndef TEM_SAMPLE
|
||||
#define TEM_SAMPLE TRUE
|
||||
#define TEM_SAMPLE FALSE //TRUE
|
||||
#endif
|
||||
#ifndef BLE_CALIBRATION_ENABLE
|
||||
#define BLE_CALIBRATION_ENABLE TRUE
|
||||
#define BLE_CALIBRATION_ENABLE FALSE //TRUE
|
||||
#endif
|
||||
#ifndef BLE_CALIBRATION_PERIOD
|
||||
#define BLE_CALIBRATION_PERIOD 120000
|
||||
#endif
|
||||
#ifndef BLE_SNV
|
||||
#define BLE_SNV TRUE
|
||||
#define BLE_SNV TRUE //TRUE
|
||||
#endif
|
||||
#ifndef BLE_SNV_ADDR
|
||||
#define BLE_SNV_ADDR 0x77E00-FLASH_ROM_MAX_SIZE
|
||||
|
|
|
@ -151,7 +151,7 @@
|
|||
"preprocess_only": false,
|
||||
"defined_symbols": [
|
||||
"CLK_OSC32K=0",
|
||||
"DEBUG=5"
|
||||
"DEBUG=3"
|
||||
],
|
||||
"undefined_symbols": []
|
||||
},
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#define LED_ALARM_PIN GPIO_Pin_9
|
||||
#define LED_VBAT_PIN GPIO_Pin_4
|
||||
|
||||
/***********************************************************************************************
|
||||
#define LED_VALVE_OPEN {GPIOA_ResetBits(LED_VALVE_R_PIN | LED_VALVE_G_PIN | LED_VALVE_Y_PIN);\
|
||||
GPIOA_SetBits(LED_VALVE_G_PIN);}
|
||||
|
||||
|
@ -35,6 +36,73 @@
|
|||
|
||||
#define LED_ALL_CLOSE {GPIOA_ResetBits(LED_VALVE_R_PIN | LED_VALVE_G_PIN | LED_VALVE_Y_PIN);\
|
||||
GPIOA_ResetBits(LED_ALARM_PIN | LED_VBAT_PIN);}
|
||||
****************************************************************************************************/
|
||||
|
||||
/**********LED_VALVE**************/
|
||||
#define LED_VALVE_OPEN \
|
||||
do \
|
||||
{ \
|
||||
GPIOA_ResetBits(LED_VALVE_R_PIN | LED_VALVE_G_PIN | LED_VALVE_Y_PIN);\
|
||||
GPIOA_SetBits(LED_VALVE_G_PIN); \
|
||||
GPIOA_ModeCfg(LED_VALVE_R_PIN | LED_VALVE_G_PIN | LED_VALVE_Y_PIN, GPIO_ModeOut_PP_5mA); \
|
||||
} while (0);
|
||||
|
||||
#define LED_VALVE_CLOSE \
|
||||
do \
|
||||
{ \
|
||||
GPIOA_ResetBits(LED_VALVE_R_PIN | LED_VALVE_G_PIN | LED_VALVE_Y_PIN);\
|
||||
GPIOA_SetBits(LED_VALVE_R_PIN); \
|
||||
GPIOA_ModeCfg(LED_VALVE_R_PIN | LED_VALVE_G_PIN | LED_VALVE_Y_PIN, GPIO_ModeOut_PP_5mA); \
|
||||
} while (0);
|
||||
|
||||
/**********LED_ALARM**************/
|
||||
#define LED_ALARM_OPEN \
|
||||
do \
|
||||
{ \
|
||||
GPIOB_SetBits(LED_ALARM_PIN); \
|
||||
GPIOB_ModeCfg(LED_ALARM_PIN, GPIO_ModeOut_PP_5mA); \
|
||||
} while (0);
|
||||
|
||||
#define LED_ALARM_CLOSE \
|
||||
do \
|
||||
{ \
|
||||
GPIOB_ResetBits(LED_ALARM_PIN); \
|
||||
GPIOB_ModeCfg(LED_ALARM_PIN, GPIO_ModeOut_PP_5mA); \
|
||||
} while (0);
|
||||
|
||||
/**********LED_VBAT**************/
|
||||
#define LED_VBAT_OPEN \
|
||||
do \
|
||||
{ \
|
||||
GPIOB_SetBits(LED_VBAT_PIN); \
|
||||
GPIOB_ModeCfg(LED_VBAT_PIN, GPIO_ModeOut_PP_5mA); \
|
||||
} while (0);
|
||||
|
||||
#define LED_VBAT_CLOSE \
|
||||
do \
|
||||
{ \
|
||||
GPIOB_ResetBits(LED_VBAT_PIN); \
|
||||
GPIOB_ModeCfg(LED_VBAT_PIN, GPIO_ModeOut_PP_5mA); \
|
||||
} while (0);
|
||||
|
||||
/**********LED_ALL**************/
|
||||
#define LED_ALL_OPEN \
|
||||
do \
|
||||
{ \
|
||||
GPIOA_SetBits(LED_VALVE_R_PIN | LED_VALVE_G_PIN | LED_VALVE_Y_PIN);\
|
||||
GPIOB_SetBits(LED_ALARM_PIN | LED_VBAT_PIN);\
|
||||
GPIOA_ModeCfg(LED_VALVE_R_PIN | LED_VALVE_G_PIN | LED_VALVE_Y_PIN, GPIO_ModeOut_PP_5mA); \
|
||||
GPIOB_ModeCfg(LED_ALARM_PIN | LED_VBAT_PIN, GPIO_ModeOut_PP_5mA); \
|
||||
} while (0);
|
||||
|
||||
#define LED_ALL_CLOSE \
|
||||
do \
|
||||
{ \
|
||||
GPIOA_ResetBits(LED_VALVE_R_PIN | LED_VALVE_G_PIN | LED_VALVE_Y_PIN);\
|
||||
GPIOB_ResetBits(LED_ALARM_PIN | LED_VBAT_PIN); \
|
||||
GPIOA_ModeCfg(LED_VALVE_R_PIN | LED_VALVE_G_PIN | LED_VALVE_Y_PIN, GPIO_ModeOut_PP_5mA); \
|
||||
GPIOB_ModeCfg(LED_ALARM_PIN | LED_VBAT_PIN, GPIO_ModeOut_PP_5mA); \
|
||||
} while (0);
|
||||
|
||||
void BSP_LED_Init(void);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ uint16_t VBAT_ProcessEvent(uint8_t task_id, uint16_t events)
|
|||
logDebug("adc_vbat =%d \n", adc_vbat);
|
||||
vbat = (adc_vbat/1024.0-1)*1.05;
|
||||
logDebug("vbat =%f \n", vbat);
|
||||
tmos_start_task(vbat_task_id, VBAT_EVT_START, MS1_TO_SYSTEM_TIME(1000*60)); //1000*60
|
||||
tmos_start_task(vbat_task_id, VBAT_EVT_START, MS1_TO_SYSTEM_TIME(1000*10)); //1000*60
|
||||
return (events ^ VBAT_EVT_START);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "bsp_bmp390.h"
|
||||
#include "bsp_motor.h"
|
||||
#include "bsp_led.h"
|
||||
#include "bsp_key.h"
|
||||
#include "CONFIG.h"
|
||||
#include "log.h"
|
||||
#include "bsp_ml307r.h"
|
||||
|
@ -354,16 +355,16 @@ void PRESS_LowerIO_Init(void)
|
|||
void Lower_IO_Deinit(void)
|
||||
{
|
||||
// LED
|
||||
GPIOA_ResetBits(GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9);
|
||||
GPIOA_ModeCfg(GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9, GPIO_ModeIN_PD);
|
||||
GPIOB_ResetBits(GPIO_Pin_4 | GPIO_Pin_9);
|
||||
GPIOB_ModeCfg(GPIO_Pin_4 | GPIO_Pin_9, GPIO_ModeIN_PD);
|
||||
GPIOA_ResetBits(LED_VALVE_R_PIN | LED_VALVE_G_PIN | LED_VALVE_Y_PIN);
|
||||
GPIOA_ModeCfg(LED_VALVE_R_PIN | LED_VALVE_G_PIN | LED_VALVE_Y_PIN, GPIO_ModeIN_PD);
|
||||
GPIOB_ResetBits(LED_VBAT_PIN | LED_ALARM_PIN);
|
||||
GPIOB_ModeCfg(LED_VBAT_PIN | LED_ALARM_PIN, GPIO_ModeIN_PD);
|
||||
|
||||
// KEY | RESET KEY | boot KEY
|
||||
GPIOB_ResetBits(GPIO_Pin_0 );
|
||||
GPIOB_ModeCfg(GPIO_Pin_0, GPIO_ModeIN_Floating);
|
||||
GPIOB_ResetBits(GPIO_Pin_23 | GPIO_Pin_22);
|
||||
GPIOB_ModeCfg(GPIO_Pin_23 | GPIO_Pin_22, GPIO_ModeIN_PD);
|
||||
GPIOB_ResetBits(KEY_B_PIN );
|
||||
GPIOB_ModeCfg(KEY_B_PIN, GPIO_ModeIN_PU);
|
||||
// GPIOB_ResetBits(GPIO_Pin_23 | GPIO_Pin_22);
|
||||
// GPIOB_ModeCfg(GPIO_Pin_23 | GPIO_Pin_22, GPIO_ModeIN_PD);
|
||||
|
||||
// ADC
|
||||
GPIOA_ResetBits(GPIO_Pin_4);
|
||||
|
@ -373,14 +374,14 @@ void Lower_IO_Deinit(void)
|
|||
// 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_ModeOut_PP_5mA);
|
||||
//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
|
||||
GPIOA_ModeCfg(GPIO_Pin_2 | GPIO_Pin_6 | GPIO_Pin_12, GPIO_ModeIN_PD);
|
||||
// spi初始化
|
||||
GPIOA_ModeCfg(GPIO_Pin_13 | GPIO_Pin_14, GPIO_ModeOut_PP_5mA);
|
||||
GPIOA_ModeCfg(GPIO_Pin_15, GPIO_ModeIN_PU);
|
||||
GPIOA_ModeCfg(GPIO_Pin_13 | GPIO_Pin_14, GPIO_ModeIN_PD); //GPIO_ModeOut_PP_5mA
|
||||
GPIOA_ModeCfg(GPIO_Pin_15, GPIO_ModeIN_PD); //GPIO_ModeIN_PU
|
||||
|
||||
//4G
|
||||
// 关闭3.8V供电
|
||||
|
@ -402,7 +403,7 @@ void Lower_IO_Deinit(void)
|
|||
GPIOB_ModeCfg(COIL_A | COIL_B, GPIO_ModeIN_PD);
|
||||
|
||||
// UART3
|
||||
/***************************************/
|
||||
/***************************************
|
||||
// 禁用UART3中断
|
||||
GPIOPinRemap(DISABLE, RB_PIN_UART3);
|
||||
UART3_INTCfg(DISABLE, RB_IER_LINE_STAT | RB_IER_RECV_RDY | RB_IER_THR_EMPTY);
|
||||
|
@ -418,7 +419,7 @@ void Lower_IO_Deinit(void)
|
|||
|
||||
// 关闭shell和日志系统
|
||||
shell.write = NULL; // 禁用shell输出
|
||||
/*************************************************/
|
||||
*************************************************/
|
||||
}
|
||||
|
||||
void PRESS_LowPower(void)
|
||||
|
@ -746,7 +747,7 @@ uint16_t Check_ProcessEvent(uint8_t task_id, uint16_t events)
|
|||
{
|
||||
VALVE_CLOSE();
|
||||
fault_state = 1;
|
||||
tmos_start_task(check_task_id, MOTOR_STOP_EVT, MS1_TO_SYSTEM_TIME(1000));
|
||||
tmos_start_task(check_task_id, MOTOR_STOP_EVT, MS1_TO_SYSTEM_TIME(1500)); //1000
|
||||
logDebug("motor high close");
|
||||
}
|
||||
//欠压检测
|
||||
|
@ -754,7 +755,7 @@ uint16_t Check_ProcessEvent(uint8_t task_id, uint16_t events)
|
|||
{
|
||||
VALVE_CLOSE();
|
||||
fault_state = 2;
|
||||
tmos_start_task(check_task_id, MOTOR_STOP_EVT, MS1_TO_SYSTEM_TIME(1000));
|
||||
tmos_start_task(check_task_id, MOTOR_STOP_EVT, MS1_TO_SYSTEM_TIME(1500)); //1000
|
||||
logDebug("motor low close");
|
||||
}
|
||||
//过流检测
|
||||
|
@ -762,7 +763,7 @@ uint16_t Check_ProcessEvent(uint8_t task_id, uint16_t events)
|
|||
{
|
||||
VALVE_CLOSE();
|
||||
fault_state = 3;
|
||||
tmos_start_task(check_task_id, MOTOR_STOP_EVT, MS1_TO_SYSTEM_TIME(1000));
|
||||
tmos_start_task(check_task_id, MOTOR_STOP_EVT, MS1_TO_SYSTEM_TIME(1500)); //1000
|
||||
logDebug("motor ver close");
|
||||
}
|
||||
}
|
||||
|
@ -773,16 +774,18 @@ uint16_t Check_ProcessEvent(uint8_t task_id, uint16_t events)
|
|||
VALVE_OPEN();
|
||||
fault_state = 0;
|
||||
tmos_start_task(check_task_id, MOTOR_STOP_EVT, MS1_TO_SYSTEM_TIME(1000));
|
||||
//LED_VALVE_OPEN;
|
||||
LED_VALVE_OPEN;
|
||||
logDebug("motor/LED open");
|
||||
}
|
||||
else if(motor_flag == 2)
|
||||
{
|
||||
motor_flag = 0;
|
||||
VALVE_CLOSE();
|
||||
tmos_start_task(check_task_id, MOTOR_STOP_EVT, MS1_TO_SYSTEM_TIME(1000));
|
||||
//LED_VALVE_CLOSE;
|
||||
LED_VALVE_CLOSE;
|
||||
logDebug("motor/LED close");
|
||||
}
|
||||
tmos_start_task(check_task_id, CHECK_EVT_START, MS1_TO_SYSTEM_TIME(1000)); //100
|
||||
tmos_start_task(check_task_id, CHECK_EVT_START, MS1_TO_SYSTEM_TIME(500)); //100
|
||||
return (events ^ CHECK_EVT_START);
|
||||
}
|
||||
if (events & MOTOR_STOP_EVT)
|
||||
|
@ -808,20 +811,20 @@ void GPIOA_IRQHandler(void)
|
|||
R16_PA_INT_IF = GPIO_Pin_6;
|
||||
flag = 1;
|
||||
tmos_set_event(press_task_id, BMP390_EVT_READ);
|
||||
//printf("interrupt1\r\n");
|
||||
logDebug("INT2 \r\n");
|
||||
}
|
||||
else if (R16_PA_INT_IF & GPIO_Pin_12)
|
||||
{
|
||||
R16_PA_INT_IF = GPIO_Pin_12;
|
||||
flag = 2;
|
||||
tmos_set_event(press_task_id, BMP390_EVT_READ);
|
||||
//printf("interrupt2\r\n");
|
||||
logDebug("INT3 \r\n");
|
||||
}
|
||||
else if (R16_PA_INT_IF & GPIO_Pin_2)
|
||||
{
|
||||
R16_PA_INT_IF = GPIO_Pin_2;
|
||||
flag = 3;
|
||||
tmos_set_event(press_task_id, BMP390_EVT_READ);
|
||||
//printf("interrupt3\r\n");
|
||||
logDebug("INT1 \r\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ void KEY_ProcessLoop(void)
|
|||
logDebug("motor close");
|
||||
}
|
||||
tmos_set_event(key_task_id, KEY_SCAN_EVT);
|
||||
logDebug("KEY_ProcessLoop");
|
||||
// logDebug("KEY_ProcessLoop");
|
||||
}
|
||||
|
||||
// if (key_wakeup_flag)
|
||||
|
|
|
@ -35,7 +35,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#ifndef LOG_ENABLE
|
||||
#define LOG_ENABLE 0 /**< 使能log */
|
||||
#define LOG_ENABLE 1 /**< 使能log */
|
||||
#endif
|
||||
|
||||
#if LOG_USING_LOCK == 1
|
||||
|
|
Loading…
Reference in New Issue