master
ThinkPad-T460P 2021-01-05 14:46:47 +08:00
parent 8604bf8ead
commit 2838aee047
16 changed files with 607 additions and 526 deletions

View File

@ -43,7 +43,7 @@
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/> <listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
<listOptionValue builtIn="false" value="STM32F107xC"/> <listOptionValue builtIn="false" value="STM32F107xC"/>
<listOptionValue builtIn="false" value="DEBUG"/> <listOptionValue builtIn="false" value="DEBUG"/>
<listOptionValue builtIn="false" value="APP_VERSION=&quot;V0.9.3&quot;"/> <listOptionValue builtIn="false" value="APP_VERSION=&quot;V0.9.4&quot;"/>
</option> </option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.186388616" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.186388616" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="../Core/Inc"/> <listOptionValue builtIn="false" value="../Core/Inc"/>
@ -98,8 +98,8 @@
<sourceEntries> <sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="CMSIS"/> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="CMSIS"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Core"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Drivers"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="USB_DEVICE"/> <entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="USB_DEVICE"/>
</sourceEntries> </sourceEntries>
</configuration> </configuration>
@ -143,7 +143,7 @@
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1412817126" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.1412817126" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="USE_HAL_DRIVER"/> <listOptionValue builtIn="false" value="USE_HAL_DRIVER"/>
<listOptionValue builtIn="false" value="STM32F107xC"/> <listOptionValue builtIn="false" value="STM32F107xC"/>
<listOptionValue builtIn="false" value="APP_VERSION=&quot;V0.9.3&quot;"/> <listOptionValue builtIn="false" value="APP_VERSION=&quot;V0.9.4&quot;"/>
<listOptionValue builtIn="false" value="DEPLOY_MODE=&quot;RELEASE&quot;"/> <listOptionValue builtIn="false" value="DEPLOY_MODE=&quot;RELEASE&quot;"/>
</option> </option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.968919675" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths.968919675" name="Include paths (-I)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.includepaths" useByScannerDiscovery="false" valueType="includePath">

View File

@ -1,4 +1,4 @@
2F62501ED4689FB349E356AB974DBE57=66ECD72EB9ECEB12193E2107C4BA39FF 2F62501ED4689FB349E356AB974DBE57=7721402F3CE8DC8D3A6A8AE537EFAC0B
8DF89ED150041C4CBC7CB9A9CAA90856=66ECD72EB9ECEB12193E2107C4BA39FF 8DF89ED150041C4CBC7CB9A9CAA90856=7721402F3CE8DC8D3A6A8AE537EFAC0B
DC22A860405A8BF2F2C095E5B6529F12=F6E7387302D54A097C31AB36FAAFE226 DC22A860405A8BF2F2C095E5B6529F12=02D9A7110C849E46466CD5CF8816F30D
eclipse.preferences.version=1 eclipse.preferences.version=1

View File

@ -162,6 +162,8 @@ standard names. */
/* USER CODE BEGIN Defines */ /* USER CODE BEGIN Defines */
/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ /* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */
#define configUSE_TRACE_FACILITY 1
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
/* USER CODE END Defines */ /* USER CODE END Defines */
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) #if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)

View File

@ -184,6 +184,8 @@ void ISP_Judge();
#define IIC1_SDA_GPIO_Port GPIOB #define IIC1_SDA_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */ /* USER CODE BEGIN Private defines */
#define ISP_Address 0x1fffb000 //In-System-Program address in flash #define ISP_Address 0x1fffb000 //In-System-Program address in flash
#define ISP_BKP_DR RTC_BKP_DR1
#define BKP_DR_Jump_to_ISP 0xa5a5 //jump to isp while ISP_BKP_DR's value equal this
/* USER CODE END Private defines */ /* USER CODE END Private defines */
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,3 +1,10 @@
/*
* @Description:
* @Date: 2020-12-16 18:05:14
* @LastEditors: CK.Zh
* @LastEditTime: 2020-12-25 17:52:50
* @FilePath: \NaviKit_stm32\Core\Inc\navikit.h
*/
/* /*
* navikit.h * navikit.h
* *
@ -18,21 +25,24 @@
#define ADC_CH_COUNT 5+2 //number of adc channels (include temp sensor and vrefint adc_in17) #define ADC_CH_COUNT 5+2 //number of adc channels (include temp sensor and vrefint adc_in17)
typedef enum
{
idle, //only mcu runing
run, //all function runing
sleep, //SOCs and FANs are stop
dfu, //device firmware update for SOM
isp //in system program for EC
}state_t;
typedef struct typedef struct
{ {
struct{ struct{
enum { state_t sta,next_sta; //power state machine
shutdown, //only mcu runing bool power_btn; //power button pressed flag
running, //all function runing bool custom_btn;//custom button pressed flag
sleep, //SOCs and FANs are stop // bool pwr_led;//power led (on switch)
dfu, //device firmware update for SOM // bool run_led;//run led (on board)
isp //in system program for BIOS bool dbg_msg_out;//enable/disable debug message output
}sta,next_sta; //power state machine
bool power_btn; //power button
bool custom_btn;//custom button
bool pwr_led;//power led (on switch)
bool run_led;//run led (on board)
}sys; }sys;
struct{ struct{
bool mod_sleep; bool mod_sleep;
@ -106,24 +116,37 @@ typedef struct
// float sensor_3; // float sensor_3;
// }temp; // }temp;
}NaviKit_t; }NaviKit_t;
extern NaviKit_t NaviKit; extern NaviKit_t NaviKit;
//device on board
enum Device_t{USB2_Port1,USB2_Port2,USB2_Port3,USB2_Port4,USB2_Port5,USB2_Port6,
USB3_Port1,USB3_Port2,USB3_Port3,USB3_Port4,USB3_Port5,USB3_Port6,
SOC_USB2_HUB,SOC_USB3_HUB,SOC_USB3_HOST,SOC_USB3_GEC,SOC_GE_SW,
SYS_FAN1,SYS_FAN2,SYS_FAN3,
SYS_RUN_LED,SYS_PWR_LED,
SOM_PWR_EN,SOM_DFU,
PMB_PS_ON};
void PWR_Enable(enum Device_t device,bool en,uint16_t delay);
bool PWR_Status(enum Device_t device);
void NaviKit_var_init(); void NaviKit_var_init();
//power state machine switch function //power state machine switch function
void enter_isp_state(); void enter_isp_state();
void enter_runing_state(); void enter_run_state(uint16_t delay);
void enter_shutdown_state(); void enter_idle_state(uint16_t delay);
void enter_sleep_state(); void enter_sleep_state(uint16_t delay);
void enter_dfu_state(); void enter_dfu_state(uint16_t delay);
void Beep(uint32_t time_ms); //non-blocking beep function with os delay
void TaskBeep(uint32_t time_ms, uint8_t n);
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc); void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin);
void osEnterRuningState();
void osEnterSleepState();
#endif /* INC_NAVIKIT_H_ */ #endif /* INC_NAVIKIT_H_ */

View File

@ -66,6 +66,7 @@ void TIM1_UP_IRQHandler(void);
void I2C1_EV_IRQHandler(void); void I2C1_EV_IRQHandler(void);
void I2C1_ER_IRQHandler(void); void I2C1_ER_IRQHandler(void);
void USART1_IRQHandler(void); void USART1_IRQHandler(void);
void RTC_Alarm_IRQHandler(void);
void UART4_IRQHandler(void); void UART4_IRQHandler(void);
void OTG_FS_IRQHandler(void); void OTG_FS_IRQHandler(void);
/* USER CODE BEGIN EFP */ /* USER CODE BEGIN EFP */

View File

@ -40,7 +40,7 @@ void MX_ADC1_Init(void)
*/ */
hadc1.Instance = ADC1; hadc1.Instance = ADC1;
hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE; hadc1.Init.ScanConvMode = ADC_SCAN_ENABLE;
hadc1.Init.ContinuousConvMode = ENABLE; hadc1.Init.ContinuousConvMode = DISABLE;
hadc1.Init.DiscontinuousConvMode = DISABLE; hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START; hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT; hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;

View File

@ -1,3 +1,10 @@
/*
* @Description:
* @Date: 2020-04-02 21:44:31
* @LastEditors: CK.Zh
* @LastEditTime: 2021-01-04 17:49:58
* @FilePath: \NaviKit_stm32\Core\Src\freertos.c
*/
/* USER CODE BEGIN Header */ /* USER CODE BEGIN Header */
/** /**
****************************************************************************** ******************************************************************************
@ -26,6 +33,7 @@
/* Private includes ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
#include "timers.h"
#include "iwdg.h" #include "iwdg.h"
#include "gpio.h" #include "gpio.h"
#include "usart.h" #include "usart.h"
@ -55,6 +63,17 @@
/* Private variables ---------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN Variables */ /* USER CODE BEGIN Variables */
osEventFlagsId_t buttonEventHandle;
const osEventFlagsAttr_t buttonEvent_attributes = {
.name = "buttonEvent"
};
osThreadId_t StateSwitchTaskHandle;
const osThreadAttr_t StateSwitchTask_attributes = {
.name = "StateSwitchTask",
.priority = (osPriority_t) osPriorityNormal,
.stack_size = 128 * 4
};
/* USER CODE END Variables */ /* USER CODE END Variables */
/* Definitions for defaultTask */ /* Definitions for defaultTask */
osThreadId_t defaultTaskHandle; osThreadId_t defaultTaskHandle;
@ -70,20 +89,6 @@ const osThreadAttr_t LedBlinkTask_attributes = {
.priority = (osPriority_t) osPriorityLow, .priority = (osPriority_t) osPriorityLow,
.stack_size = 128 * 4 .stack_size = 128 * 4
}; };
/* Definitions for IWDGRefreshTask */
osThreadId_t IWDGRefreshTaskHandle;
const osThreadAttr_t IWDGRefreshTask_attributes = {
.name = "IWDGRefreshTask",
.priority = (osPriority_t) osPriorityHigh,
.stack_size = 128 * 4
};
/* Definitions for EventDetect */
osThreadId_t EventDetectHandle;
const osThreadAttr_t EventDetect_attributes = {
.name = "EventDetect",
.priority = (osPriority_t) osPriorityLow,
.stack_size = 128 * 4
};
/* Definitions for CoulombRead */ /* Definitions for CoulombRead */
osThreadId_t CoulombReadHandle; osThreadId_t CoulombReadHandle;
const osThreadAttr_t CoulombRead_attributes = { const osThreadAttr_t CoulombRead_attributes = {
@ -91,13 +96,6 @@ const osThreadAttr_t CoulombRead_attributes = {
.priority = (osPriority_t) osPriorityLow, .priority = (osPriority_t) osPriorityLow,
.stack_size = 128 * 4 .stack_size = 128 * 4
}; };
/* Definitions for StateSwitchTask */
osThreadId_t StateSwitchTaskHandle;
const osThreadAttr_t StateSwitchTask_attributes = {
.name = "StateSwitchTask",
.priority = (osPriority_t) osPriorityLow,
.stack_size = 128 * 4
};
/* Definitions for PowerMonitTask */ /* Definitions for PowerMonitTask */
osThreadId_t PowerMonitTaskHandle; osThreadId_t PowerMonitTaskHandle;
const osThreadAttr_t PowerMonitTask_attributes = { const osThreadAttr_t PowerMonitTask_attributes = {
@ -105,20 +103,41 @@ const osThreadAttr_t PowerMonitTask_attributes = {
.priority = (osPriority_t) osPriorityLow, .priority = (osPriority_t) osPriorityLow,
.stack_size = 128 * 4 .stack_size = 128 * 4
}; };
/* Definitions for EventDetect */
osThreadId_t EventDetectHandle;
const osThreadAttr_t EventDetect_attributes = {
.name = "EventDetect",
.priority = (osPriority_t) osPriorityLow,
.stack_size = 128 * 4
};
/* Definitions for PwrBtnTimer */
osTimerId_t PwrBtnTimerHandle;
const osTimerAttr_t PwrBtnTimer_attributes = {
.name = "PwrBtnTimer"
};
/* Definitions for CustBtnTimer */
osTimerId_t CustBtnTimerHandle;
const osTimerAttr_t CustBtnTimer_attributes = {
.name = "CustBtnTimer"
};
/* Private function prototypes -----------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN FunctionPrototypes */ /* USER CODE BEGIN FunctionPrototypes */
void osEnterSleepState(); //void osEnterSleepState();
void osEnterRuningState(); //void osEnterRuningState();
void StartStateSwitchTask(void *argument);
void StartChangeStateTask(state_t target_sta);
bool isWakeUpReset() { return __HAL_PWR_GET_FLAG(PWR_FLAG_WU);}
/* USER CODE END FunctionPrototypes */ /* USER CODE END FunctionPrototypes */
void StartDefaultTask(void *argument); void StartDefaultTask(void *argument);
void StartLedBlinkTask(void *argument); void StartLedBlinkTask(void *argument);
void StartIWDGRefreshTask(void *argument);
void StartEventDetect(void *argument);
void StartCoulombRead(void *argument); void StartCoulombRead(void *argument);
void StartStateSwitchTask(void *argument);
void StartPowerMonitTask(void *argument); void StartPowerMonitTask(void *argument);
void StartEventDetect(void *argument);
void PwrBtnTimerCallback(void *argument);
void CustBtnTimerCallback(void *argument);
extern void MX_USB_DEVICE_Init(void); extern void MX_USB_DEVICE_Init(void);
void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */ void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */
@ -139,7 +158,7 @@ __weak void configureTimerForRunTimeStats(void)
__weak unsigned long getRunTimeCounterValue(void) __weak unsigned long getRunTimeCounterValue(void)
{ {
return 0; return osKernelGetTickCount();
} }
/* USER CODE END 1 */ /* USER CODE END 1 */
@ -182,11 +201,13 @@ void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName)
__weak void PreSleepProcessing(uint32_t *ulExpectedIdleTime) __weak void PreSleepProcessing(uint32_t *ulExpectedIdleTime)
{ {
/* place for user code */ /* place for user code */
} }
__weak void PostSleepProcessing(uint32_t *ulExpectedIdleTime) __weak void PostSleepProcessing(uint32_t *ulExpectedIdleTime)
{ {
/* place for user code */ /* place for user code */
} }
/* USER CODE END PREPOSTSLEEP */ /* USER CODE END PREPOSTSLEEP */
@ -208,6 +229,13 @@ void MX_FREERTOS_Init(void) {
/* add semaphores, ... */ /* add semaphores, ... */
/* USER CODE END RTOS_SEMAPHORES */ /* USER CODE END RTOS_SEMAPHORES */
/* Create the timer(s) */
/* creation of PwrBtnTimer */
PwrBtnTimerHandle = osTimerNew(PwrBtnTimerCallback, osTimerOnce, NULL, &PwrBtnTimer_attributes);
/* creation of CustBtnTimer */
CustBtnTimerHandle = osTimerNew(CustBtnTimerCallback, osTimerOnce, NULL, &CustBtnTimer_attributes);
/* USER CODE BEGIN RTOS_TIMERS */ /* USER CODE BEGIN RTOS_TIMERS */
/* start timers, add new ones, ... */ /* start timers, add new ones, ... */
/* USER CODE END RTOS_TIMERS */ /* USER CODE END RTOS_TIMERS */
@ -223,28 +251,24 @@ void MX_FREERTOS_Init(void) {
/* creation of LedBlinkTask */ /* creation of LedBlinkTask */
LedBlinkTaskHandle = osThreadNew(StartLedBlinkTask, NULL, &LedBlinkTask_attributes); LedBlinkTaskHandle = osThreadNew(StartLedBlinkTask, NULL, &LedBlinkTask_attributes);
/* creation of IWDGRefreshTask */
// IWDGRefreshTaskHandle = osThreadNew(StartIWDGRefreshTask, NULL, &IWDGRefreshTask_attributes);
/* creation of EventDetect */
EventDetectHandle = osThreadNew(StartEventDetect, NULL, &EventDetect_attributes);
/* creation of CoulombRead */ /* creation of CoulombRead */
CoulombReadHandle = osThreadNew(StartCoulombRead, NULL, &CoulombRead_attributes); CoulombReadHandle = osThreadNew(StartCoulombRead, NULL, &CoulombRead_attributes);
/* creation of StateSwitchTask */
StateSwitchTaskHandle = osThreadNew(StartStateSwitchTask, NULL, &StateSwitchTask_attributes);
/* creation of PowerMonitTask */ /* creation of PowerMonitTask */
PowerMonitTaskHandle = osThreadNew(StartPowerMonitTask, NULL, &PowerMonitTask_attributes); PowerMonitTaskHandle = osThreadNew(StartPowerMonitTask, NULL, &PowerMonitTask_attributes);
/* creation of EventDetect */
EventDetectHandle = osThreadNew(StartEventDetect, NULL, &EventDetect_attributes);
/* USER CODE BEGIN RTOS_THREADS */ /* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */ /* add threads, ... */
StateSwitchTaskHandle = osThreadNew(StartStateSwitchTask, NULL, &defaultTask_attributes);
/* USER CODE END RTOS_THREADS */ /* USER CODE END RTOS_THREADS */
/* USER CODE BEGIN RTOS_EVENTS */ /* USER CODE BEGIN RTOS_EVENTS */
/* add events, ... */ /* add events, ... */
buttonEventHandle = osEventFlagsNew(&buttonEvent_attributes);
/* USER CODE END RTOS_EVENTS */ /* USER CODE END RTOS_EVENTS */
} }
@ -259,14 +283,38 @@ void MX_FREERTOS_Init(void) {
void StartDefaultTask(void *argument) void StartDefaultTask(void *argument)
{ {
/* init code for USB_DEVICE */ /* init code for USB_DEVICE */
// MX_USB_DEVICE_Init(); MX_USB_DEVICE_Init();
/* USER CODE BEGIN StartDefaultTask */ /* USER CODE BEGIN StartDefaultTask */
osVersion_t osVersion; osVersion_t osVersion;
char id_buf[20]; char id_buf[20];
unsigned char id_size=20; unsigned char id_size=20;
HAL_GPIO_WritePin(USB2_FS_ENUM_CTL_GPIO_Port,USB2_FS_ENUM_CTL_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(USB2_FS_ENUM_CTL_GPIO_Port,USB2_FS_ENUM_CTL_Pin, GPIO_PIN_SET);
Beep(50); HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);
if(isWakeUpReset()){//judge reset source form "wakeup event"
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
if(HAL_GPIO_ReadPin(SYS_POWER_BTN_GPIO_Port, SYS_POWER_BTN_Pin)==GPIO_PIN_SET){
NaviKit.sys.next_sta = run;
Log(info,"EC Reset source :Power Button WakeUP");
}else{
NaviKit.sys.next_sta = idle;
Log(info,"EC Reset source :RTC WakeUP");
// HAL_IWDG_Refresh(&hiwdg);
// HAL_PWR_EnterSTANDBYMode();
}
}else{//judge reset source "power on"
Log(info,"EC Reset source :PowerON");
if(HAL_GPIO_ReadPin(SYS_CUSTOM_BTN_GPIO_Port, SYS_CUSTOM_BTN_Pin)==GPIO_PIN_RESET){
Log(debug,"EC next state isp");
NaviKit.sys.next_sta = isp;
}else{
NaviKit.sys.next_sta = idle;
}
}
Log(info,"----------------------------------------------"); Log(info,"----------------------------------------------");
Log(info,"Copyright (c) Powered by www.autolabor.com.cn"); Log(info,"Copyright (c) Powered by www.autolabor.com.cn");
@ -281,14 +329,39 @@ void StartDefaultTask(void *argument)
Log(info,"OS Kernel Version: %u ", osVersion.kernel); Log(info,"OS Kernel Version: %u ", osVersion.kernel);
Log(info,"OS Kernel ID: %s ",id_buf); Log(info,"OS Kernel ID: %s ",id_buf);
} }
Log(info,"Core initial successfully"); Log(info,"Core initial successfully");
Log(info,"----------------------------------------------"); Log(info,"----------------------------------------------");
// osEnterSleepState();
TaskBeep(50,1);
/* Infinite loop */ /* Infinite loop */
for(;;) for(;;)
{ {
osDelay(1000); // HAL_IWDG_Refresh(&hiwdg);
osDelay(100);
if(NaviKit.sys.sta != NaviKit.sys.next_sta){
switch(NaviKit.sys.next_sta){
case idle: {
enter_idle_state(100);
NaviKit.sys.sta = NaviKit.sys.next_sta;
} break;
case run: {
enter_run_state(100);
NaviKit.sys.sta = NaviKit.sys.next_sta;
}break;
case sleep:{
enter_sleep_state(100);
NaviKit.sys.sta = NaviKit.sys.next_sta;
}break;
case dfu:{
enter_dfu_state(100);
NaviKit.sys.sta = NaviKit.sys.next_sta;
}break;
case isp:{
enter_isp_state();
NaviKit.sys.sta = NaviKit.sys.next_sta;
}break;
}
}
} }
/* USER CODE END StartDefaultTask */ /* USER CODE END StartDefaultTask */
@ -307,81 +380,52 @@ void StartLedBlinkTask(void *argument)
/* Infinite loop */ /* Infinite loop */
for(;;) for(;;)
{ {
osDelay(1000);
switch(NaviKit.sys.sta){ switch(NaviKit.sys.sta){
case running: case run: {
{ if(!PWR_Status(SYS_PWR_LED)){
if(HAL_GPIO_ReadPin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin)) PWR_Enable(SYS_PWR_LED,true,100);//turn on power led
HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin,GPIO_PIN_RESET);//turn on power led
if(HAL_GPIO_ReadPin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin) == GPIO_PIN_SET)//sys run led is off
{
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_RESET);//turn on sys run led
osDelay(50);
} }
else
{ if(!PWR_Status(SYS_RUN_LED)){//sys run led is off
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_SET);//turn off sys run led PWR_Enable(SYS_RUN_LED,true,50);//turn on sys run led
osDelay(300); PWR_Enable(SYS_RUN_LED,false,0);//turn off sys run led
} }
}break; }break;
case shutdown: case idle:{
{ if(PWR_Status(SYS_PWR_LED))
if(!HAL_GPIO_ReadPin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin)) PWR_Enable(SYS_PWR_LED,false,0);//turn on power led//turn off power led
HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin,GPIO_PIN_SET);//turn off power led
if(HAL_GPIO_ReadPin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin) == GPIO_PIN_SET)//sys run led is off if(PWR_Status(SYS_RUN_LED))//sys run led is off
{ PWR_Enable(SYS_RUN_LED,true,20);//turn on sys run led
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_RESET);//turn on sys run led
osDelay(20);
}
else else
{ PWR_Enable(SYS_RUN_LED,false,3000);//turn off sys run led
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_SET);//turn off sys run led
osDelay(2000);
}
}break; }break;
case sleep: case sleep:{//sleep mode
{//sleep mode for(uint16_t i=0;i<25;i++){//20 light level
for(uint16_t i=0;i<25;i++) for(uint16_t j=0;j<3;j++){//the time length of every light level
{//20 light level PWR_Enable(SYS_PWR_LED,false,0);
for(uint16_t j=0;j<3;j++) PWR_Enable(SYS_RUN_LED,false,0);
{//the time length of every light level
HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin,GPIO_PIN_SET);
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_SET);
osDelay(i); osDelay(i);
HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin,GPIO_PIN_RESET); PWR_Enable(SYS_PWR_LED,true,0);
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_RESET); PWR_Enable(SYS_RUN_LED,true,0);
osDelay(25-i); osDelay(25-i);
} }
} }
for(uint16_t i=0;i<25;i++) for(uint16_t i=0;i<25;i++){
{ for(uint16_t j=0;j<3;j++){
for(uint16_t j=0;j<3;j++) PWR_Enable(SYS_PWR_LED,false,0);
{ PWR_Enable(SYS_RUN_LED,false,0);
HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin,GPIO_PIN_SET);
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_SET);
osDelay(25-i); osDelay(25-i);
HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin,GPIO_PIN_RESET); PWR_Enable(SYS_PWR_LED,true,0);
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_RESET); PWR_Enable(SYS_RUN_LED,true,0);
osDelay(i); osDelay(i);
} }
} }
}break; }break;
case dfu: case dfu:{
{ PWR_Enable(SYS_PWR_LED,!PWR_Status(SYS_PWR_LED),150);
if(HAL_GPIO_ReadPin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin) == GPIO_PIN_SET)//power led is off PWR_Enable(SYS_RUN_LED,!PWR_Status(SYS_PWR_LED),150);
{
HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin,GPIO_PIN_RESET);//turn on power led
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_RESET);//turn on run led
osDelay(300);
}
else
{
HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin,GPIO_PIN_SET);//turn off sys run led
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_SET);//turn off run led
osDelay(300);
}
}break; }break;
case isp: case isp:
break; break;
@ -390,104 +434,6 @@ void StartLedBlinkTask(void *argument)
/* USER CODE END StartLedBlinkTask */ /* USER CODE END StartLedBlinkTask */
} }
/* USER CODE BEGIN Header_StartIWDGRefreshTask */
/**
* @brief Function implementing the IWDGRefreshTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartIWDGRefreshTask */
void StartIWDGRefreshTask(void *argument)
{
/* USER CODE BEGIN StartIWDGRefreshTask */
/* Infinite loop */
for(;;)
{
HAL_IWDG_Refresh(&hiwdg);
osDelay(1000);
}
/* USER CODE END StartIWDGRefreshTask */
}
/* USER CODE BEGIN Header_StartEventDetect */
/**
* @brief Function implementing the EventDetect thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartEventDetect */
void StartEventDetect(void *argument)
{
/* USER CODE BEGIN StartEventDetect */
osDelay(100);
if(HAL_GPIO_ReadPin(SYS_CUSTOM_BTN_GPIO_Port,SYS_CUSTOM_BTN_Pin) == GPIO_PIN_RESET)
{
Log(debug,"Custom button has been pushed.");
NaviKit.sys.next_sta = isp;
}
/* Infinite loop */
for(;;)
{
if(NaviKit.sys.power_btn == true)
{//power btn has been pushed
uint8_t count =0;
while(NaviKit.sys.power_btn && count<=10){
osDelay(100);
count ++;
}
if(count >10)
{//power btn has been pushed more than 1000 ms
// while(NaviKit.sys.power_btn == true);//wait to release button
switch(NaviKit.sys.sta){
case running:{//system is running now, user request to shutdown
NaviKit.sys.next_sta = shutdown;
}break;
case shutdown:{//system is shutdown now , user request to power on
NaviKit.sys.next_sta = running;
}break;
case dfu:{
NaviKit.sys.next_sta = shutdown;
}break;
case sleep:{
NaviKit.sys.next_sta = running;
}break;
}
}
else
{
//sleep mode is unused
// if(NaviKit.sys.sta == runing)
// NaviKit.sys.sta = sleep;
// else if(NaviKit.sys.sta == sleep)
// NaviKit.sys.sta = runing;
}
}
if(NaviKit.sys.custom_btn == true )
{//custom button has been pushed
uint8_t count =0;
while(NaviKit.sys.custom_btn && count<=20){
osDelay(100);
count ++;
}
if(count > 20 )
{//custom button has been pushed over 1000 ms
if((NaviKit.sys.power_btn == true) && (NaviKit.sys.sta == shutdown))//into dfu state
NaviKit.sys.next_sta = dfu;
else//TODO: force restart
NaviKit.sys.next_sta = shutdown;
// if(NaviKit.sys.sta == runing)
// NaviKit.sys.next_sta = shutdown;
// else if(NaviKit.sys.sta == shutdown)
// NaviKit.sys.next_sta = runing;
}
}
osDelay(10);
}
/* USER CODE END StartEventDetect */
}
/* USER CODE BEGIN Header_StartCoulombRead */ /* USER CODE BEGIN Header_StartCoulombRead */
/** /**
* @brief Function implementing the CoulombRead thread. * @brief Function implementing the CoulombRead thread.
@ -512,7 +458,7 @@ void StartCoulombRead(void *argument)
{ {
coulomb_read_status_and_config(); coulomb_read_status_and_config();
coulomb_read_status_raw_to_actual(); coulomb_read_status_raw_to_actual();
if(NaviKit.sys.sta == running) if(NaviKit.sys.sta == run)
osDelay(500); osDelay(500);
else else
osDelay(5000); osDelay(5000);
@ -520,56 +466,6 @@ void StartCoulombRead(void *argument)
/* USER CODE END StartCoulombRead */ /* USER CODE END StartCoulombRead */
} }
/* USER CODE BEGIN Header_StartStateSwitchTask */
/**
* @brief Function implementing the StateSwitchTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartStateSwitchTask */
void StartStateSwitchTask(void *argument)
{
/* USER CODE BEGIN StartStateSwitchTask */
/* Infinite loop */
for(;;)
{
osDelay(10);
if(NaviKit.sys.next_sta != NaviKit.sys.sta)
{
switch(NaviKit.sys.next_sta)
{
case shutdown:
{//only from running state
if((NaviKit.sys.sta == running)){// && (NaviKit.som.shutdown_req == true)
enter_shutdown_state();
// osEnterSleepState();
}
}break;
case running:
{//from sleep and shutdown state
enter_runing_state();
}break;
case sleep:
{//only form running state
if(NaviKit.sys.sta == running)
enter_sleep_state();
}break;
case dfu:
{
enter_dfu_state();
}break;
case isp:
{
enter_isp_state();
}break;
}
NaviKit.sys.sta = NaviKit.sys.next_sta;
}
}
/* USER CODE END StartStateSwitchTask */
}
/* USER CODE BEGIN Header_StartPowerMonitTask */ /* USER CODE BEGIN Header_StartPowerMonitTask */
/** /**
* @brief Function: Monit som power status and PMB status * @brief Function: Monit som power status and PMB status
@ -581,71 +477,170 @@ void StartPowerMonitTask(void *argument)
{ {
/* USER CODE BEGIN StartPowerMonitTask */ /* USER CODE BEGIN StartPowerMonitTask */
HAL_ADCEx_Calibration_Start(&hadc1); HAL_ADCEx_Calibration_Start(&hadc1);
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)&(NaviKit.pmb.rails.adc), ADC_CH_COUNT); osDelay(2000);
/* Infinite loop */ /* Infinite loop */
for(;;) for(;;)
{ {
osDelay(5000); //stat1 stat2 lead-acid
if(NaviKit.sys.sta == running){ //1 1 Not Charging
if(NaviKit.pmb.rails.out_24v > 26.4 || NaviKit.pmb.rails.out_24v < 21.6){ //1 0 Float Charge
Log(error,"24V(±10%) power rail exception:%dV",NaviKit.pmb.rails.out_24v); //0 1 Absorption Charge
} //0 0 Bulk Charge
if(NaviKit.pmb.rails.out_5v > 5.5 || NaviKit.pmb.rails.out_5v < 4.5){ NaviKit.pmb.sta.chrg_stat1 = (bool)HAL_GPIO_ReadPin(PMB_CHRG_STAT1_GPIO_Port, PMB_CHRG_STAT1_Pin);
Log(error,"5V(±10%) power rail exception:%dV",NaviKit.pmb.rails.out_5v); NaviKit.pmb.sta.chrg_stat2 = (bool)HAL_GPIO_ReadPin(PMB_CHRG_STAT2_GPIO_Port, PMB_CHRG_STAT2_Pin);
}
if(NaviKit.pmb.rails.out_12v > 13.2 || NaviKit.pmb.rails.out_12v < 10.8){ if(!NaviKit.pmb.sta.chrg_stat1 && !NaviKit.pmb.sta.chrg_stat2)
Log(error ,"12V(±10%) power rail exception:%dV",NaviKit.pmb.rails.out_12v); Log(trace,"Backup battery status:%dmV Bulk Charge(Vth=12.6V)",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000));
} if(!NaviKit.pmb.sta.chrg_stat1 && NaviKit.pmb.sta.chrg_stat2)
if(NaviKit.pmb.rails.bkp_bat < 9.5){ Log(trace,"Backup battery status:%dmV Absorption Charge(Vth=14.4V)",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000));
Log(warning,"Backup power is not online"); if(NaviKit.pmb.sta.chrg_stat1 && !NaviKit.pmb.sta.chrg_stat2)
} Log(trace,"Backup battery status:%dmV Float Charge(Vth=13.3V)",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000));
if(NaviKit.pmb.sta.chrg_stat1 && NaviKit.pmb.sta.chrg_stat2)
Log(trace,"Backup battery status:%dmV Not Charge",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000));
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)&(NaviKit.pmb.rails.adc), ADC_CH_COUNT);
if(NaviKit.sys.sta == run || NaviKit.sys.next_sta == run ){
osDelay(2000);
if(NaviKit.pmb.rails.out_24v > 26.4 || NaviKit.pmb.rails.out_24v < 21.6)
Log(fatal,"24V(±10%%) power rail exception:%dmV",(uint32_t)(NaviKit.pmb.rails.out_24v*1000));
else
Log(trace,"24V(±10%%) power rail regular:%dmV",(uint32_t)(NaviKit.pmb.rails.out_24v*1000));
if(NaviKit.pmb.rails.out_5v > 5.5 || NaviKit.pmb.rails.out_5v < 4.5)
Log(fatal,"5V(±10%%) power rail exception:%dmV",(uint32_t)(NaviKit.pmb.rails.out_5v*1000));
else
Log(trace,"5V(±10%%) power rail regular:%dmV",(uint32_t)(NaviKit.pmb.rails.out_5v*1000));
if(NaviKit.pmb.rails.out_12v > 13.2 || NaviKit.pmb.rails.out_12v < 10.8)
Log(fatal ,"12V(±10%%) power rail exception:%dmV",(uint32_t)(NaviKit.pmb.rails.out_12v*1000));
else
Log(trace,"12V(±10%%) power rail regular:%dmV",(uint32_t)(NaviKit.pmb.rails.out_12v*1000));
if(NaviKit.pmb.rails.bkp_bat < 9.5)
Log(warning,"Backup battery exception:%dmV",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000));
else
Log(trace,"Backup battery is regular:%dmV",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000));
if(NaviKit.pmb.rails.main_pwr < 19){ if(NaviKit.pmb.rails.main_pwr < 19){
Beep(200); TaskBeep(200,1);
Log(warning,"Main power has been lost, please shutdown computer as soon as possible"); Log(warning,"Main power has been lost, please shutdown computer as soon as possible:%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000));
}else
Log(trace,"Main power rail regular:%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000));
}else {//not run state
osDelay(5000);
if(NaviKit.sys.sta == idle){//idle state
if((NaviKit.pmb.sta.chrg_stat1 && NaviKit.pmb.sta.chrg_stat2) \
|| (NaviKit.pmb.sta.chrg_stat1 && !NaviKit.pmb.sta.chrg_stat2)){//Not Charge or float charge
Log(info,"EC enter STANDBY Mode to save power");
// __HAL_PWR_CLEAR_FLAG
__HAL_RCC_RTC_DISABLE();
HAL_PWR_EnterSTANDBYMode();
} }
} }
if(NaviKit.pmb.rails.bkp_bat > 15){
Log(error,"Backup power is exception:%dV",NaviKit.pmb.rails.bkp_bat);
Beep(200);
} }
if(NaviKit.pmb.rails.main_pwr > 30){ if(NaviKit.pmb.rails.main_pwr > 30){
Beep(200); TaskBeep(200,1);
Log(error,"Backup power is exception:%dV",NaviKit.pmb.rails.main_pwr); Log(fatal,"Main power is exception:%dmV",(uint32_t)(NaviKit.pmb.rails.main_pwr*1000));
} }
if(NaviKit.pmb.rails.bkp_bat > 15){
Log(fatal,"Backup battery is exception:%dmV",(uint32_t)(NaviKit.pmb.rails.bkp_bat*1000));
TaskBeep(200,1);
}
} }
/* USER CODE END StartPowerMonitTask */ /* USER CODE END StartPowerMonitTask */
} }
/* USER CODE BEGIN Header_StartEventDetect */
/**
* @brief Function implementing the EventDetect thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartEventDetect */
void StartEventDetect(void *argument)
{
/* USER CODE BEGIN StartEventDetect */
/* Infinite loop */
for(;;)
{
osDelay(10);
if(NaviKit.sys.power_btn && !osTimerIsRunning(PwrBtnTimerHandle)){
osTimerStart(PwrBtnTimerHandle,2000);
}
if(NaviKit.sys.custom_btn && !osTimerIsRunning(CustBtnTimerHandle)){
osTimerStart(PwrBtnTimerHandle,2000);
}
if(!NaviKit.sys.power_btn && osTimerIsRunning(PwrBtnTimerHandle)){
osTimerStop(PwrBtnTimerHandle);
Log(trace,"power btn short pressed");
}
if(!NaviKit.sys.custom_btn && osTimerIsRunning(CustBtnTimerHandle)){
osTimerStop(CustBtnTimerHandle);
Log(trace,"custom btn short pressed");
}
}
/* USER CODE END StartEventDetect */
}
/* PwrBtnTimerCallback function */
void PwrBtnTimerCallback(void *argument)
{
/* USER CODE BEGIN PwrBtnTimerCallback */
// Log(debug,"power btn timer callback");
Log(trace,"power btn long pressed");
switch(NaviKit.sys.sta){
case run: {NaviKit.sys.next_sta = idle;Log(trace,"change to idle"); }break;//system is run now, user request to idle
case idle: {NaviKit.sys.next_sta = run;Log(trace,"change to run"); }break;//system is idle now , user request to power on
case dfu: {NaviKit.sys.next_sta = idle;Log(trace,"change to idle"); }break;
case sleep:{NaviKit.sys.next_sta = run;Log(trace,"change to run"); }break;
case isp: {NaviKit.sys.next_sta = idle;Log(trace,"change to idle"); }break;
}
/* USER CODE END PwrBtnTimerCallback */
}
/* CustBtnTimerCallback function */
void CustBtnTimerCallback(void *argument)
{
/* USER CODE BEGIN CustBtnTimerCallback */
// Log(debug,"custom btn timer callback");
Log(trace,"custom btn long pressed");
switch(NaviKit.sys.sta){
case run:{//system is run now, user request to restart system
HAL_GPIO_WritePin(SOM_SYS_RESET_GPIO_Port,SOM_SYS_RESET_Pin,GPIO_PIN_RESET);
osDelay(10);
HAL_GPIO_WritePin(SOM_SYS_RESET_GPIO_Port,SOM_SYS_RESET_Pin,GPIO_PIN_SET);
}break;
case idle:{
}break;
case dfu:{
}break;
case sleep:{
}break;
case isp:{
}break;
}
/* USER CODE END CustBtnTimerCallback */
}
/* Private application code --------------------------------------------------*/ /* Private application code --------------------------------------------------*/
/* USER CODE BEGIN Application */ /* USER CODE BEGIN Application */
//os enter sleep state for save power void StartStateSwitchTask(void *argument)
void osEnterSleepState(){ {
Log(info,"EC Enter Sleep State");
HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin,GPIO_PIN_SET);//turn off sys run led for(;;)
vTaskSuspendAll(); {
// osKernelLock();
HAL_SuspendTick();
// MX_USB_DEVICE_DeInit();
HAL_I2C_MspDeInit(&hi2c1);
HAL_ADC_MspDeInit(&hadc1);
HAL_ADC_Stop_DMA(&hadc1);
HAL_PWR_EnableSleepOnExit();//for rtos application,enter sleep after interrupt end
HAL_PWR_EnterSLEEPMode(0,PWR_SLEEPENTRY_WFE);
} }
void osEnterRuningState(){
HAL_ResumeTick();
// MX_USB_DEVICE_Init();
HAL_I2C_MspInit(&hi2c1);
HAL_ADC_MspInit(&hadc1);
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)&(NaviKit.pmb.rails.adc), ADC_CH_COUNT);
__set_CONTROL(0);
xTaskResumeAll();
// osKernelUnlock();
NaviKit.sys.next_sta = running;
Log(info,"EC Enter Runing State");
} }
//printf redirect //printf redirect
#ifdef __GNUC__ #ifdef __GNUC__
//#define PUTCHAR_PROTOTYPE int __io_putchar(int ch) //#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)

View File

@ -84,7 +84,6 @@ int main(void)
/* USER CODE BEGIN Init */ /* USER CODE BEGIN Init */
NaviKit_var_init();
/* USER CODE END Init */ /* USER CODE END Init */
/* Configure the system clock */ /* Configure the system clock */
@ -102,13 +101,13 @@ int main(void)
MX_UART4_Init(); MX_UART4_Init();
MX_ADC1_Init(); MX_ADC1_Init();
MX_USART1_UART_Init(); MX_USART1_UART_Init();
MX_RTC_Init(); // MX_RTC_Init();
/* Initialize interrupts */ /* Initialize interrupts */
MX_NVIC_Init(); MX_NVIC_Init();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1); NaviKit_var_init();
/* USER CODE END 2 */ /* USER CODE END 2 */
/* Init scheduler */ /* Init scheduler */
@ -226,7 +225,7 @@ void ISP_Judge()
{//Judge that if need jump to ISP area {//Judge that if need jump to ISP area
RTC_HandleTypeDef hrtc; RTC_HandleTypeDef hrtc;
hrtc.Instance = RTC; hrtc.Instance = RTC;
if(HAL_RTCEx_BKUPRead(&hrtc,RTC_BKP_DR1) == 0x32f2) if(HAL_RTCEx_BKUPRead(&hrtc,ISP_BKP_DR) == BKP_DR_Jump_to_ISP)
{ {
__HAL_RCC_PWR_CLK_ENABLE(); __HAL_RCC_PWR_CLK_ENABLE();
__HAL_RCC_BKP_CLK_ENABLE(); __HAL_RCC_BKP_CLK_ENABLE();
@ -234,7 +233,7 @@ void ISP_Judge()
__HAL_RCC_RTC_ENABLE(); __HAL_RCC_RTC_ENABLE();
HAL_PWR_EnableBkUpAccess(); HAL_PWR_EnableBkUpAccess();
HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR1,0x0000); HAL_RTCEx_BKUPWrite(&hrtc,ISP_BKP_DR,0x0000);
__HAL_RCC_RTC_DISABLE(); __HAL_RCC_RTC_DISABLE();
__HAL_RCC_PWR_CLK_DISABLE(); __HAL_RCC_PWR_CLK_DISABLE();

View File

@ -2,7 +2,7 @@
* @Description: * @Description:
* @Date: 2020-04-17 13:16:16 * @Date: 2020-04-17 13:16:16
* @LastEditors: CK.Zh * @LastEditors: CK.Zh
* @LastEditTime: 2020-12-17 17:29:07 * @LastEditTime: 2020-12-30 14:19:14
* @FilePath: \NaviKit_stm32\Core\Src\navikit.c * @FilePath: \NaviKit_stm32\Core\Src\navikit.c
*/ */
/* /*
@ -15,18 +15,22 @@
#include "navikit.h" #include "navikit.h"
NaviKit_t NaviKit; NaviKit_t NaviKit;
void NaviKit_var_init() void NaviKit_var_init()
{ {
NaviKit.sys.sta = shutdown; NaviKit.sys.sta = idle;
NaviKit.sys.next_sta = shutdown; NaviKit.sys.next_sta = idle;
} }
void Beep(uint32_t time_ms) void TaskBeep(uint32_t time_ms , uint8_t n)
{ {
for(uint8_t i=0;i<n;i++){
HAL_GPIO_WritePin(SYS_BUZZ_CTL_GPIO_Port,SYS_BUZZ_CTL_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(SYS_BUZZ_CTL_GPIO_Port,SYS_BUZZ_CTL_Pin, GPIO_PIN_RESET);
HAL_Delay(time_ms>>1); osDelay(time_ms>>1);
HAL_GPIO_WritePin(SYS_BUZZ_CTL_GPIO_Port,SYS_BUZZ_CTL_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(SYS_BUZZ_CTL_GPIO_Port,SYS_BUZZ_CTL_Pin, GPIO_PIN_SET);
HAL_Delay(time_ms>>1); osDelay(time_ms>>1);
}
} }
@ -34,7 +38,9 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{ {
if(hadc->Instance == ADC1) if(hadc->Instance == ADC1)
{ {
float adc_17_voltage = 1.2 / NaviKit.pmb.rails.adc[1];//reference voltage // ADC_CHANNEL_TEMPSENSOR ADC_CHANNEL_16 /* ADC internal channel (no connection on device pin) */
// ADC_CHANNEL_VREFINT ADC_CHANNEL_17 /* ADC internal channel (no connection on device pin) */
float adc_17_voltage = (float)1.2 / NaviKit.pmb.rails.adc[1];//reference voltage
NaviKit.pmb.rails.out_24v = (float)(adc_17_voltage * NaviKit.pmb.rails.adc[2] * 16); NaviKit.pmb.rails.out_24v = (float)(adc_17_voltage * NaviKit.pmb.rails.adc[2] * 16);
NaviKit.pmb.rails.out_5v = (float)(adc_17_voltage * NaviKit.pmb.rails.adc[3] * 8); NaviKit.pmb.rails.out_5v = (float)(adc_17_voltage * NaviKit.pmb.rails.adc[3] * 8);
@ -48,58 +54,41 @@ void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc)
{ {
HAL_ADCEx_Calibration_Start(&hadc1); HAL_ADCEx_Calibration_Start(&hadc1);
} }
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{ {
if(GPIO_Pin == SOM_SHUTDOWN_REQ_Pin) if(GPIO_Pin == SOM_SHUTDOWN_REQ_Pin){
{ if(HAL_GPIO_ReadPin(SOM_SHUTDOWN_REQ_GPIO_Port, SOM_SHUTDOWN_REQ_Pin)==GPIO_PIN_RESET){//falling edge trigger
if(HAL_GPIO_ReadPin(SOM_SHUTDOWN_REQ_GPIO_Port, SOM_SHUTDOWN_REQ_Pin)==GPIO_PIN_RESET) if(NaviKit.sys.sta == run){//if jetson nano shutdown output low,the power_en should be set low less than 10us
{//falling edge trigger
if(NaviKit.sys.sta == running)
{//if jetson nano shutdown output low,the power_en should be set low less than 10us
HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port ,SOM_POWER_EN_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port ,SOM_POWER_EN_Pin, GPIO_PIN_RESET);
NaviKit.sys.next_sta = shutdown; NaviKit.sys.next_sta = idle;
Log(info,"som request to shutdown"); Log(info,"SOM request to shutdown");
} }
NaviKit.som.shutdown_req = true;
} }
else{//Rising edge trigger else{//Rising edge trigger
NaviKit.som.shutdown_req = false;
} }
} }
else if(GPIO_Pin == SYS_POWER_BTN_Pin) else if(GPIO_Pin == SYS_POWER_BTN_Pin){
{ if(HAL_GPIO_ReadPin(SYS_POWER_BTN_GPIO_Port, SYS_POWER_BTN_Pin)==GPIO_PIN_SET){//Rising edge trigger
if(HAL_GPIO_ReadPin(SYS_POWER_BTN_GPIO_Port, SYS_POWER_BTN_Pin)==GPIO_PIN_SET)
{//Rising edge trigger
NaviKit.sys.power_btn = true; NaviKit.sys.power_btn = true;
Log(debug,"power_btn pushed"); Log(debug,"power_btn status: pressed.");
if(NaviKit.sys.sta==shutdown){
// osEnterRuningState();
} }
} if(HAL_GPIO_ReadPin(SYS_POWER_BTN_GPIO_Port, SYS_POWER_BTN_Pin)==GPIO_PIN_RESET){//falling edge trigger
if(HAL_GPIO_ReadPin(SYS_POWER_BTN_GPIO_Port, SYS_POWER_BTN_Pin)==GPIO_PIN_RESET)
{//falling edge trigger
NaviKit.sys.power_btn = false; NaviKit.sys.power_btn = false;
Log(debug,"power_btn released"); Log(debug,"power_btn status: released.");
} }
} }
else if(GPIO_Pin == SYS_CUSTOM_BTN_Pin) else if(GPIO_Pin == SYS_CUSTOM_BTN_Pin){
{ if(HAL_GPIO_ReadPin(SYS_CUSTOM_BTN_GPIO_Port, SYS_CUSTOM_BTN_Pin)==GPIO_PIN_RESET){//falling edge trigger
if(HAL_GPIO_ReadPin(SYS_CUSTOM_BTN_GPIO_Port, SYS_CUSTOM_BTN_Pin)==GPIO_PIN_SET) Log(debug,"custom_btn status: pressed.");
{//Rising edge trigger
NaviKit.sys.custom_btn = false;
Log(debug,"custom_btn released");
}
if(HAL_GPIO_ReadPin(SYS_CUSTOM_BTN_GPIO_Port, SYS_CUSTOM_BTN_Pin)==GPIO_PIN_RESET)
{//falling edge trigger
NaviKit.sys.custom_btn = true; NaviKit.sys.custom_btn = true;
Log(debug,"custom_btn pushed"); }
if(HAL_GPIO_ReadPin(SYS_CUSTOM_BTN_GPIO_Port, SYS_CUSTOM_BTN_Pin)==GPIO_PIN_SET){//Rising edge trigger
Log(debug,"custom_btn status: released.");
NaviKit.sys.custom_btn = false;
} }
} }
} }
__weak void osEnterRuningState(){}
__weak void osEnterSleepState(){}
//write "bios update flag" to bkp register, and reset system //write "bios update flag" to bkp register, and reset system
void enter_isp_state() void enter_isp_state()
@ -114,16 +103,12 @@ void enter_isp_state()
__HAL_RCC_RTC_ENABLE(); __HAL_RCC_RTC_ENABLE();
HAL_PWR_EnableBkUpAccess(); HAL_PWR_EnableBkUpAccess();
HAL_RTCEx_BKUPWrite(&hrtc,RTC_BKP_DR1,0x32f2); HAL_RTCEx_BKUPWrite(&hrtc,ISP_BKP_DR,BKP_DR_Jump_to_ISP);
HAL_Delay(10); osDelay(10);
if(HAL_RTCEx_BKUPRead(&hrtc,RTC_BKP_DR1) == 0x32f2) if(HAL_RTCEx_BKUPRead(&hrtc,ISP_BKP_DR) == BKP_DR_Jump_to_ISP)
{//write successful {//write successful
Beep(500); TaskBeep(500,5);
Beep(500);
Beep(500);
Beep(500);
Beep(500);
Log(info,"Enter to EC update state."); Log(info,"Enter to EC update state.");
Log(info,"System will reboot ,then run ISP automatic."); Log(info,"System will reboot ,then run ISP automatic.");
HAL_NVIC_SystemReset(); HAL_NVIC_SystemReset();
@ -134,149 +119,120 @@ void enter_isp_state()
} }
//timeout:the time of wait //timeout:the time of wait
void enter_shutdown_state() void enter_idle_state(uint16_t delay)
{ {
Log(info,"Enter to shutdown state"); Log(info,"Enter to idle state");
Beep(50); TaskBeep(50,1);
HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port ,SOM_POWER_EN_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(SOM_PWR_EN ,false, delay);
HAL_GPIO_WritePin(SOC_U3_HUB_PWR_CTL_GPIO_Port,SOC_U3_HUB_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(SOC_USB3_HUB ,false, delay);
HAL_GPIO_WritePin(SOC_U2_HUB_PWR_CTL_GPIO_Port,SOC_U2_HUB_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(SOC_USB2_HUB ,false, delay);
HAL_GPIO_WritePin(SOC_U3_HOST_PWR_CTL_GPIO_Port,SOC_U3_HOST_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(SOC_USB3_HOST,false, delay);
HAL_GPIO_WritePin(SOC_GE_SW_PWR_CTL_GPIO_Port,SOC_GE_SW_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(SOC_USB3_GEC ,false, delay);
HAL_GPIO_WritePin(SOC_U3_GEC_PWR_CTL_GPIO_Port,SOC_U3_GEC_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(SOC_GE_SW ,false, delay);
HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(USB3_Port4,false, delay);
HAL_GPIO_WritePin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(USB3_Port3,false, delay);
HAL_GPIO_WritePin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(USB3_Port2,false, delay);
HAL_GPIO_WritePin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(USB3_Port1,false, delay);
HAL_GPIO_WritePin(USB3_VBUS_CTL_6_GPIO_Port,USB3_VBUS_CTL_6_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(USB3_Port6,false, delay);
HAL_GPIO_WritePin(USB3_VBUS_CTL_5_GPIO_Port,USB3_VBUS_CTL_5_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(USB3_Port5,false, delay);
HAL_GPIO_WritePin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(USB2_Port6,false, delay);
HAL_GPIO_WritePin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(USB2_Port5,false, delay);
HAL_GPIO_WritePin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(USB2_Port4,false, delay);
HAL_GPIO_WritePin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(USB2_Port3,false, delay);
HAL_GPIO_WritePin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(USB2_Port2,false, delay);
HAL_GPIO_WritePin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(USB2_Port1,false, delay);
HAL_GPIO_WritePin(SYS_FAN_CTL_1_GPIO_Port,SYS_FAN_CTL_1_Pin,GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(SYS_FAN1 ,false , delay);
HAL_GPIO_WritePin(SYS_FAN_CTL_2_GPIO_Port,SYS_FAN_CTL_2_Pin,GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(SYS_FAN2 ,false , delay);
HAL_GPIO_WritePin(SYS_FAN_CTL_3_GPIO_Port,SYS_FAN_CTL_3_Pin,GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(SYS_FAN3 ,false , delay);
HAL_GPIO_WritePin(PMB_PS_ON_GPIO_Port ,PMB_PS_ON_Pin, GPIO_PIN_RESET); HAL_Delay(100); PWR_Enable(PMB_PS_ON ,false , delay);
MX_USB_DEVICE_DeInit();
} }
void enter_sleep_state()
void enter_run_state(uint16_t delay)
{
Log(info,"Enter to run state");
TaskBeep(200,1);
PWR_Enable(SOM_DFU ,false, delay);
PWR_Enable(PMB_PS_ON ,true, delay);
PWR_Enable(SYS_FAN1 ,true , delay);
PWR_Enable(SYS_FAN2 ,true , delay);
PWR_Enable(SYS_FAN3 ,true , delay);
PWR_Enable(SOC_USB3_HUB ,true , delay);
PWR_Enable(SOC_USB2_HUB ,true , delay);
PWR_Enable(SOC_USB3_HOST,true , delay);
PWR_Enable(SOC_USB3_GEC ,true , delay);
PWR_Enable(SOC_GE_SW ,true , delay);
PWR_Enable(USB2_Port1,true , delay);
PWR_Enable(USB2_Port2,true , delay);
PWR_Enable(USB2_Port3,true , delay);
PWR_Enable(USB2_Port4,true , delay);
PWR_Enable(USB2_Port5,true , delay);
PWR_Enable(USB2_Port6,true , delay);
PWR_Enable(USB3_Port5,true , delay);
PWR_Enable(USB3_Port6,true , delay);
PWR_Enable(USB3_Port1,true , delay);
PWR_Enable(USB3_Port2,true , delay);
PWR_Enable(USB3_Port3,true , delay);
PWR_Enable(USB3_Port4,true , delay);
PWR_Enable(SOM_PWR_EN , true , delay);
}
void enter_sleep_state(uint16_t delay)
{ {
Log(info,"Enter to sleep state"); Log(info,"Enter to sleep state");
Beep(50); TaskBeep(50,1);
// HAL_GPIO_WritePin(SOC_U3_HUB_PWR_CTL_GPIO_Port,SOC_U3_HUB_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(SOC_U2_HUB_PWR_CTL_GPIO_Port,SOC_U2_HUB_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
// HAL_GPIO_WritePin(SOC_U3_HOST_PWR_CTL_GPIO_Port,SOC_U3_HOST_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(SOC_GE_SW_PWR_CTL_GPIO_Port,SOC_GE_SW_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
// HAL_GPIO_WritePin(SOC_U3_GEC_PWR_CTL_GPIO_Port,SOC_U3_GEC_PWR_CTL_Pin, GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin, GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin, GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin, GPIO_PIN_RESET); HAL_Delay(100);
// HAL_GPIO_WritePin(USB3_VBUS_CTL_6_GPIO_Port,USB3_VBUS_CTL_6_Pin, GPIO_PIN_RESET); HAL_Delay(100);
// HAL_GPIO_WritePin(USB3_VBUS_CTL_5_GPIO_Port,USB3_VBUS_CTL_5_Pin, GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin, GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin, GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin, GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin, GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin, GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin, GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_1_GPIO_Port,SYS_FAN_CTL_1_Pin,GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_2_GPIO_Port,SYS_FAN_CTL_2_Pin,GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_3_GPIO_Port,SYS_FAN_CTL_3_Pin,GPIO_PIN_RESET); HAL_Delay(100);
} }
void enter_dfu_state(uint16_t delay)
void enter_runing_state()
{ {
Log(info,"Enter to runing state"); Log(info,"Enter to DFU state");
Beep(200); TaskBeep(500,3);
HAL_GPIO_WritePin(SOM_FORCE_RECOVERY_GPIO_Port ,SOM_FORCE_RECOVERY_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(SOM_DFU , true , delay);
HAL_GPIO_WritePin(PMB_PS_ON_GPIO_Port ,PMB_PS_ON_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_1_GPIO_Port,SYS_FAN_CTL_1_Pin,GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(PMB_PS_ON , true , delay);
HAL_GPIO_WritePin(SYS_FAN_CTL_2_GPIO_Port,SYS_FAN_CTL_2_Pin,GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_3_GPIO_Port,SYS_FAN_CTL_3_Pin,GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(SOC_U3_HUB_PWR_CTL_GPIO_Port,SOC_U3_HUB_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(SYS_FAN1 , true , delay);
HAL_GPIO_WritePin(SOC_U2_HUB_PWR_CTL_GPIO_Port,SOC_U2_HUB_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(SYS_FAN2 , true , delay);
HAL_GPIO_WritePin(SOC_U3_HOST_PWR_CTL_GPIO_Port,SOC_U3_HOST_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(SYS_FAN3 , true , delay);
HAL_GPIO_WritePin(SOC_GE_SW_PWR_CTL_GPIO_Port,SOC_GE_SW_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(SOC_U3_GEC_PWR_CTL_GPIO_Port,SOC_U3_GEC_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(SOC_USB3_HUB , true , delay);
HAL_GPIO_WritePin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(SOC_USB2_HUB , true , delay);
HAL_GPIO_WritePin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(SOC_USB3_HOST , true , delay);
HAL_GPIO_WritePin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(SOC_USB3_GEC , true , delay);
HAL_GPIO_WritePin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(SOC_GE_SW , true , delay);
HAL_GPIO_WritePin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_5_GPIO_Port,USB3_VBUS_CTL_5_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(USB2_Port1 , true , delay);
HAL_GPIO_WritePin(USB3_VBUS_CTL_6_GPIO_Port,USB3_VBUS_CTL_6_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(USB2_Port2 , true , delay);
HAL_GPIO_WritePin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(USB2_Port3 , true , delay);
HAL_GPIO_WritePin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(USB2_Port4 , true , delay);
HAL_GPIO_WritePin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(USB2_Port5 , true , delay);
HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(USB2_Port6 , true , delay);
PWR_Enable(USB2_Port1 , true , delay);
PWR_Enable(USB2_Port1 , true , delay);
HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port ,SOM_POWER_EN_Pin, GPIO_PIN_SET); HAL_Delay(100); PWR_Enable(USB3_Port5,true , delay);
PWR_Enable(USB3_Port6,true , delay);
MX_USB_DEVICE_Init(); PWR_Enable(USB3_Port1,true , delay);
} PWR_Enable(USB3_Port2,true , delay);
PWR_Enable(USB3_Port3,true , delay);
void enter_dfu_state() PWR_Enable(USB3_Port4,true , delay);
{
Log(info,"Enter to dfu state");
Beep(500);
Beep(500);
Beep(500);
HAL_GPIO_WritePin(SOM_FORCE_RECOVERY_GPIO_Port ,SOM_FORCE_RECOVERY_Pin, GPIO_PIN_RESET); HAL_Delay(100);
HAL_GPIO_WritePin(PMB_PS_ON_GPIO_Port ,PMB_PS_ON_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port ,SOM_POWER_EN_Pin, GPIO_PIN_SET); HAL_Delay(1000);
HAL_GPIO_WritePin(SYS_FAN_CTL_1_GPIO_Port,SYS_FAN_CTL_1_Pin,GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_2_GPIO_Port,SYS_FAN_CTL_2_Pin,GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(SYS_FAN_CTL_3_GPIO_Port,SYS_FAN_CTL_3_Pin,GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(SOC_U3_HUB_PWR_CTL_GPIO_Port,SOC_U3_HUB_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(SOC_U2_HUB_PWR_CTL_GPIO_Port,SOC_U2_HUB_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(SOC_U3_HOST_PWR_CTL_GPIO_Port,SOC_U3_HOST_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(SOC_GE_SW_PWR_CTL_GPIO_Port,SOC_GE_SW_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(SOC_U3_GEC_PWR_CTL_GPIO_Port,SOC_U3_GEC_PWR_CTL_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_5_GPIO_Port,USB3_VBUS_CTL_5_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_6_GPIO_Port,USB3_VBUS_CTL_6_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin, GPIO_PIN_SET); HAL_Delay(100);
HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, GPIO_PIN_SET); HAL_Delay(100);
PWR_Enable(SOM_PWR_EN , true , delay);
// //
// HAL_GPIO_WritePin(SOM_FORCE_RECOVERY_GPIO_Port ,SOM_FORCE_RECOVERY_Pin, GPIO_PIN_RESET); HAL_Delay(100); // HAL_GPIO_WritePin(SOM_FORCE_RECOVERY_GPIO_Port ,SOM_FORCE_RECOVERY_Pin, GPIO_PIN_RESET); HAL_Delay(100);
@ -285,6 +241,74 @@ void enter_dfu_state()
// HAL_Delay(5000); // HAL_Delay(5000);
// HAL_GPIO_WritePin(SOM_SYS_RESET_GPIO_Port ,SOM_SYS_RESET_Pin, GPIO_PIN_SET); HAL_Delay(100); // HAL_GPIO_WritePin(SOM_SYS_RESET_GPIO_Port ,SOM_SYS_RESET_Pin, GPIO_PIN_SET); HAL_Delay(100);
// HAL_GPIO_WritePin(SOM_FORCE_RECOVERY_GPIO_Port ,SOM_FORCE_RECOVERY_Pin, GPIO_PIN_SET); HAL_Delay(100); // HAL_GPIO_WritePin(SOM_FORCE_RECOVERY_GPIO_Port ,SOM_FORCE_RECOVERY_Pin, GPIO_PIN_SET); HAL_Delay(100);
}
//device power enable or disable
//delay: After executing the operation delay (ms)
void PWR_Enable(enum Device_t device,bool en,uint16_t delay){
switch (device){
case USB2_Port1: {HAL_GPIO_WritePin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin, en); }break;
case USB2_Port2: {HAL_GPIO_WritePin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin, en); }break;
case USB2_Port3: {HAL_GPIO_WritePin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin, en); }break;
case USB2_Port4: {HAL_GPIO_WritePin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin, en); }break;
case USB2_Port5: {HAL_GPIO_WritePin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin, en); }break;
case USB2_Port6: {HAL_GPIO_WritePin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin, en); }break;
case USB3_Port1: {HAL_GPIO_WritePin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin, en); }break;
case USB3_Port2: {HAL_GPIO_WritePin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin, en); }break;
case USB3_Port3: {HAL_GPIO_WritePin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin, en); }break;
case USB3_Port4: {HAL_GPIO_WritePin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin, en); }break;
case USB3_Port5: {HAL_GPIO_WritePin(USB3_VBUS_CTL_5_GPIO_Port,USB3_VBUS_CTL_5_Pin, en); }break;
case USB3_Port6: {HAL_GPIO_WritePin(USB3_VBUS_CTL_6_GPIO_Port,USB3_VBUS_CTL_6_Pin, en); }break;
case SOC_USB2_HUB: {HAL_GPIO_WritePin(SOC_U2_HUB_PWR_CTL_GPIO_Port,SOC_U2_HUB_PWR_CTL_Pin, en); }break;
case SOC_USB3_HUB: {HAL_GPIO_WritePin(SOC_U3_HUB_PWR_CTL_GPIO_Port,SOC_U3_HUB_PWR_CTL_Pin, en); }break;
case SOC_USB3_HOST: {HAL_GPIO_WritePin(SOC_U3_HOST_PWR_CTL_GPIO_Port,SOC_U3_HOST_PWR_CTL_Pin, en); }break;
case SOC_USB3_GEC: {HAL_GPIO_WritePin(SOC_U3_GEC_PWR_CTL_GPIO_Port,SOC_U3_GEC_PWR_CTL_Pin, en); }break;
case SOC_GE_SW: {HAL_GPIO_WritePin(SOC_GE_SW_PWR_CTL_GPIO_Port,SOC_GE_SW_PWR_CTL_Pin, en); }break;
case SYS_FAN1: {HAL_GPIO_WritePin(SYS_FAN_CTL_1_GPIO_Port,SYS_FAN_CTL_1_Pin, en); }break;
case SYS_FAN2: {HAL_GPIO_WritePin(SYS_FAN_CTL_2_GPIO_Port,SYS_FAN_CTL_2_Pin, en); }break;
case SYS_FAN3: {HAL_GPIO_WritePin(SYS_FAN_CTL_3_GPIO_Port,SYS_FAN_CTL_3_Pin, en); }break;
case SYS_RUN_LED: {HAL_GPIO_WritePin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin, !en); }break;
case SYS_PWR_LED: {HAL_GPIO_WritePin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin, !en); }break;
case SOM_PWR_EN: {HAL_GPIO_WritePin(SOM_POWER_EN_GPIO_Port,SOM_POWER_EN_Pin, en); }break;
case SOM_DFU: {HAL_GPIO_WritePin(SOM_FORCE_RECOVERY_GPIO_Port,SOM_FORCE_RECOVERY_Pin, !en); }break;
case PMB_PS_ON: {HAL_GPIO_WritePin(PMB_PS_ON_GPIO_Port,PMB_PS_ON_Pin, en); }break;
default: {Log(error,"PWR_Enable device parameter is invalid."); }break;
}
osDelay(delay);
}
//check device on board power status
bool PWR_Status(enum Device_t device){
bool sta = false;
switch (device){
case USB2_Port1: {sta = HAL_GPIO_ReadPin(USB2_VBUS_CTL_1_GPIO_Port,USB2_VBUS_CTL_1_Pin); }break;
case USB2_Port2: {sta = HAL_GPIO_ReadPin(USB2_VBUS_CTL_2_GPIO_Port,USB2_VBUS_CTL_2_Pin); }break;
case USB2_Port3: {sta = HAL_GPIO_ReadPin(USB2_VBUS_CTL_3_GPIO_Port,USB2_VBUS_CTL_3_Pin); }break;
case USB2_Port4: {sta = HAL_GPIO_ReadPin(USB2_VBUS_CTL_4_GPIO_Port,USB2_VBUS_CTL_4_Pin); }break;
case USB2_Port5: {sta = HAL_GPIO_ReadPin(USB2_VBUS_CTL_5_GPIO_Port,USB2_VBUS_CTL_5_Pin); }break;
case USB2_Port6: {sta = HAL_GPIO_ReadPin(USB2_VBUS_CTL_6_GPIO_Port,USB2_VBUS_CTL_6_Pin); }break;
case USB3_Port1: {sta = HAL_GPIO_ReadPin(USB3_VBUS_CTL_1_GPIO_Port,USB3_VBUS_CTL_1_Pin); }break;
case USB3_Port2: {sta = HAL_GPIO_ReadPin(USB3_VBUS_CTL_2_GPIO_Port,USB3_VBUS_CTL_2_Pin); }break;
case USB3_Port3: {sta = HAL_GPIO_ReadPin(USB3_VBUS_CTL_3_GPIO_Port,USB3_VBUS_CTL_3_Pin); }break;
case USB3_Port4: {sta = HAL_GPIO_ReadPin(USB3_VBUS_CTL_4_GPIO_Port,USB3_VBUS_CTL_4_Pin); }break;
case USB3_Port5: {sta = HAL_GPIO_ReadPin(USB3_VBUS_CTL_5_GPIO_Port,USB3_VBUS_CTL_5_Pin); }break;
case USB3_Port6: {sta = HAL_GPIO_ReadPin(USB3_VBUS_CTL_6_GPIO_Port,USB3_VBUS_CTL_6_Pin); }break;
case SOC_USB2_HUB: {sta = HAL_GPIO_ReadPin(SOC_U2_HUB_PWR_CTL_GPIO_Port,SOC_U2_HUB_PWR_CTL_Pin); }break;
case SOC_USB3_HUB: {sta = HAL_GPIO_ReadPin(SOC_U3_HUB_PWR_CTL_GPIO_Port,SOC_U3_HUB_PWR_CTL_Pin); }break;
case SOC_USB3_HOST: {sta = HAL_GPIO_ReadPin(SOC_U3_HOST_PWR_CTL_GPIO_Port,SOC_U3_HOST_PWR_CTL_Pin); }break;
case SOC_USB3_GEC: {sta = HAL_GPIO_ReadPin(SOC_U3_GEC_PWR_CTL_GPIO_Port,SOC_U3_GEC_PWR_CTL_Pin); }break;
case SOC_GE_SW: {sta = HAL_GPIO_ReadPin(SOC_GE_SW_PWR_CTL_GPIO_Port,SOC_GE_SW_PWR_CTL_Pin); }break;
case SYS_FAN1: {sta = HAL_GPIO_ReadPin(SYS_FAN_CTL_1_GPIO_Port,SYS_FAN_CTL_1_Pin); }break;
case SYS_FAN2: {sta = HAL_GPIO_ReadPin(SYS_FAN_CTL_2_GPIO_Port,SYS_FAN_CTL_2_Pin); }break;
case SYS_FAN3: {sta = HAL_GPIO_ReadPin(SYS_FAN_CTL_3_GPIO_Port,SYS_FAN_CTL_3_Pin); }break;
case SYS_RUN_LED: {sta = !HAL_GPIO_ReadPin(SYS_RUN_LED_CTL_GPIO_Port,SYS_RUN_LED_CTL_Pin); }break;
case SYS_PWR_LED: {sta = !HAL_GPIO_ReadPin(SYS_POWER_LED_CTL_GPIO_Port,SYS_POWER_LED_CTL_Pin); }break;
case SOM_PWR_EN: {sta = HAL_GPIO_ReadPin(SOM_POWER_EN_GPIO_Port,SOM_POWER_EN_Pin); }break;
case SOM_DFU: {sta = !HAL_GPIO_ReadPin(SOM_FORCE_RECOVERY_GPIO_Port,SOM_FORCE_RECOVERY_Pin); }break;
case PMB_PS_ON: {sta = HAL_GPIO_ReadPin(PMB_PS_ON_GPIO_Port,PMB_PS_ON_Pin); }break;
default: {Log(error,"PWR_Status device parameter is invalid."); }break;
}
return sta;
} }

View File

@ -59,6 +59,8 @@ void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle)
/* RTC interrupt Init */ /* RTC interrupt Init */
HAL_NVIC_SetPriority(RTC_IRQn, 5, 0); HAL_NVIC_SetPriority(RTC_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(RTC_IRQn); HAL_NVIC_EnableIRQ(RTC_IRQn);
HAL_NVIC_SetPriority(RTC_Alarm_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn);
/* USER CODE BEGIN RTC_MspInit 1 */ /* USER CODE BEGIN RTC_MspInit 1 */
/* USER CODE END RTC_MspInit 1 */ /* USER CODE END RTC_MspInit 1 */
@ -78,6 +80,7 @@ void HAL_RTC_MspDeInit(RTC_HandleTypeDef* rtcHandle)
/* RTC interrupt Deinit */ /* RTC interrupt Deinit */
HAL_NVIC_DisableIRQ(RTC_IRQn); HAL_NVIC_DisableIRQ(RTC_IRQn);
HAL_NVIC_DisableIRQ(RTC_Alarm_IRQn);
/* USER CODE BEGIN RTC_MspDeInit 1 */ /* USER CODE BEGIN RTC_MspDeInit 1 */
/* USER CODE END RTC_MspDeInit 1 */ /* USER CODE END RTC_MspDeInit 1 */

View File

@ -349,6 +349,20 @@ void USART1_IRQHandler(void)
/* USER CODE END USART1_IRQn 1 */ /* USER CODE END USART1_IRQn 1 */
} }
/**
* @brief This function handles RTC alarm interrupt through EXTI line 17.
*/
void RTC_Alarm_IRQHandler(void)
{
/* USER CODE BEGIN RTC_Alarm_IRQn 0 */
/* USER CODE END RTC_Alarm_IRQn 0 */
HAL_RTC_AlarmIRQHandler(&hrtc);
/* USER CODE BEGIN RTC_Alarm_IRQn 1 */
/* USER CODE END RTC_Alarm_IRQn 1 */
}
/** /**
* @brief This function handles UART4 global interrupt. * @brief This function handles UART4 global interrupt.
*/ */

View File

@ -1,3 +1,10 @@
/*
* @Description:
* @Date: 2020-04-10 17:35:38
* @LastEditors: CK.Zh
* @LastEditTime: 2021-01-04 17:51:16
* @FilePath: \NaviKit_stm32\Drivers\STM32F1xx_HAL_Driver\Inc\stm32f1xx_hal_pwr.h
*/
/** /**
****************************************************************************** ******************************************************************************
* @file stm32f1xx_hal_pwr.h * @file stm32f1xx_hal_pwr.h

View File

@ -10,6 +10,9 @@
void Log(LogLevel_t loglevel,char *format,...) void Log(LogLevel_t loglevel,char *format,...)
{ {
switch(loglevel){ switch(loglevel){
case trace:{
printf("[Trace ] ") ;
}break;
case debug:{ case debug:{
printf("[Debug ] ") ; printf("[Debug ] ") ;
}break; }break;
@ -22,6 +25,9 @@ void Log(LogLevel_t loglevel,char *format,...)
case error:{ case error:{
printf("[Error ] ") ; printf("[Error ] ") ;
}break; }break;
case fatal:{
printf("[Fatal ] ") ;
}break;
} }
printf("%u | ",osKernelGetTickCount()); printf("%u | ",osKernelGetTickCount());
va_list args; va_list args;

View File

@ -11,10 +11,12 @@
#include <stdarg.h> #include <stdarg.h>
typedef enum { typedef enum {
debug = 0, trace = 0,
info = 1, debug = 1,
warning = 2, info = 2,
error = 3 warning = 3,
error = 4,
fatal =5
}LogLevel_t; }LogLevel_t;
void Log(LogLevel_t loglevel,char *format, ...); void Log(LogLevel_t loglevel,char *format, ...);

View File

@ -9,7 +9,7 @@ ADC1.Channel-3\#ChannelRegularConversion=ADC_CHANNEL_4
ADC1.Channel-4\#ChannelRegularConversion=ADC_CHANNEL_5 ADC1.Channel-4\#ChannelRegularConversion=ADC_CHANNEL_5
ADC1.Channel-5\#ChannelRegularConversion=ADC_CHANNEL_6 ADC1.Channel-5\#ChannelRegularConversion=ADC_CHANNEL_6
ADC1.Channel-6\#ChannelRegularConversion=ADC_CHANNEL_7 ADC1.Channel-6\#ChannelRegularConversion=ADC_CHANNEL_7
ADC1.ContinuousConvMode=ENABLE ADC1.ContinuousConvMode=DISABLE
ADC1.EnableAnalogWatchDog=true ADC1.EnableAnalogWatchDog=true
ADC1.ExternalTrigConv=ADC_SOFTWARE_START ADC1.ExternalTrigConv=ADC_SOFTWARE_START
ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,ContinuousConvMode,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,NbrOfConversion,Rank-4\#ChannelRegularConversion,Channel-4\#ChannelRegularConversion,SamplingTime-4\#ChannelRegularConversion,Rank-5\#ChannelRegularConversion,Channel-5\#ChannelRegularConversion,SamplingTime-5\#ChannelRegularConversion,ExternalTrigConv,master,EnableAnalogWatchDog,Rank-6\#ChannelRegularConversion,Channel-6\#ChannelRegularConversion,SamplingTime-6\#ChannelRegularConversion,WatchdogMode,AWD1ITMode,WatchdogChannel,AWD1HighThreshold,AWD1LowThreshold ADC1.IPParameters=Rank-0\#ChannelRegularConversion,Channel-0\#ChannelRegularConversion,SamplingTime-0\#ChannelRegularConversion,NbrOfConversionFlag,ContinuousConvMode,Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,Rank-2\#ChannelRegularConversion,Channel-2\#ChannelRegularConversion,SamplingTime-2\#ChannelRegularConversion,Rank-3\#ChannelRegularConversion,Channel-3\#ChannelRegularConversion,SamplingTime-3\#ChannelRegularConversion,NbrOfConversion,Rank-4\#ChannelRegularConversion,Channel-4\#ChannelRegularConversion,SamplingTime-4\#ChannelRegularConversion,Rank-5\#ChannelRegularConversion,Channel-5\#ChannelRegularConversion,SamplingTime-5\#ChannelRegularConversion,ExternalTrigConv,master,EnableAnalogWatchDog,Rank-6\#ChannelRegularConversion,Channel-6\#ChannelRegularConversion,SamplingTime-6\#ChannelRegularConversion,WatchdogMode,AWD1ITMode,WatchdogChannel,AWD1HighThreshold,AWD1LowThreshold
@ -65,6 +65,7 @@ Dma.ADC1.0.Priority=DMA_PRIORITY_LOW
Dma.ADC1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority Dma.ADC1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
Dma.Request0=ADC1 Dma.Request0=ADC1
Dma.RequestsNb=1 Dma.RequestsNb=1
FREERTOS.Events01=
FREERTOS.FootprintOK=true FREERTOS.FootprintOK=true
FREERTOS.HEAP_NUMBER=4 FREERTOS.HEAP_NUMBER=4
FREERTOS.INCLUDE_pcTaskGetTaskName=1 FREERTOS.INCLUDE_pcTaskGetTaskName=1
@ -74,8 +75,9 @@ FREERTOS.INCLUDE_xSemaphoreGetMutexHolder=1
FREERTOS.INCLUDE_xTaskAbortDelay=1 FREERTOS.INCLUDE_xTaskAbortDelay=1
FREERTOS.INCLUDE_xTaskGetCurrentTaskHandle=1 FREERTOS.INCLUDE_xTaskGetCurrentTaskHandle=1
FREERTOS.INCLUDE_xTaskGetHandle=1 FREERTOS.INCLUDE_xTaskGetHandle=1
FREERTOS.IPParameters=Tasks01,configMAX_TASK_NAME_LEN,configUSE_TICKLESS_IDLE,INCLUDE_xTaskGetCurrentTaskHandle,INCLUDE_xTaskGetHandle,configUSE_APPLICATION_TASK_TAG,FootprintOK,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,configGENERATE_RUN_TIME_STATS,configUSE_STATS_FORMATTING_FUNCTIONS,configUSE_TRACE_FACILITY,HEAP_NUMBER,configTOTAL_HEAP_SIZE,configCHECK_FOR_STACK_OVERFLOW,configUSE_TASK_NOTIFICATIONS,INCLUDE_xTaskAbortDelay,INCLUDE_xEventGroupSetBitFromISR,INCLUDE_xSemaphoreGetMutexHolder,INCLUDE_pcTaskGetTaskName,INCLUDE_vTaskCleanUpResources FREERTOS.IPParameters=Tasks01,configMAX_TASK_NAME_LEN,configUSE_TICKLESS_IDLE,INCLUDE_xTaskGetCurrentTaskHandle,INCLUDE_xTaskGetHandle,configUSE_APPLICATION_TASK_TAG,FootprintOK,configUSE_IDLE_HOOK,configUSE_TICK_HOOK,configUSE_MALLOC_FAILED_HOOK,configGENERATE_RUN_TIME_STATS,configUSE_STATS_FORMATTING_FUNCTIONS,configUSE_TRACE_FACILITY,HEAP_NUMBER,configTOTAL_HEAP_SIZE,configCHECK_FOR_STACK_OVERFLOW,configUSE_TASK_NOTIFICATIONS,INCLUDE_xTaskAbortDelay,INCLUDE_xEventGroupSetBitFromISR,INCLUDE_xSemaphoreGetMutexHolder,INCLUDE_pcTaskGetTaskName,INCLUDE_vTaskCleanUpResources,Events01,Timers01
FREERTOS.Tasks01=defaultTask,24,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL;LedBlinkTask,8,128,StartLedBlinkTask,Default,NULL,Dynamic,NULL,NULL;IWDGRefreshTask,40,128,StartIWDGRefreshTask,Default,NULL,Dynamic,NULL,NULL;EventDetect,8,128,StartEventDetect,Default,NULL,Dynamic,NULL,NULL;CoulombRead,8,128,StartCoulombRead,Default,NULL,Dynamic,NULL,NULL;StateSwitchTask,8,128,StartStateSwitchTask,Default,NULL,Dynamic,NULL,NULL;PowerMonitTask,8,128,StartPowerMonitTask,Default,NULL,Dynamic,NULL,NULL FREERTOS.Tasks01=defaultTask,24,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL;LedBlinkTask,8,128,StartLedBlinkTask,Default,NULL,Dynamic,NULL,NULL;CoulombRead,8,128,StartCoulombRead,Default,NULL,Dynamic,NULL,NULL;PowerMonitTask,8,128,StartPowerMonitTask,Default,NULL,Dynamic,NULL,NULL;EventDetect,8,128,StartEventDetect,Default,NULL,Dynamic,NULL,NULL
FREERTOS.Timers01=PwrBtnTimer,PwrBtnTimerCallback,osTimerOnce,Default,NULL,Dynamic,NULL;CustBtnTimer,CustBtnTimerCallback,osTimerOnce,Default,NULL,Dynamic,NULL
FREERTOS.configCHECK_FOR_STACK_OVERFLOW=1 FREERTOS.configCHECK_FOR_STACK_OVERFLOW=1
FREERTOS.configGENERATE_RUN_TIME_STATS=1 FREERTOS.configGENERATE_RUN_TIME_STATS=1
FREERTOS.configMAX_TASK_NAME_LEN=32 FREERTOS.configMAX_TASK_NAME_LEN=32
@ -209,7 +211,8 @@ NVIC.PVD_IRQn=true\:5\:0\:true\:true\:true\:1\:false\:true\:true
NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.RCC_IRQn=true\:5\:0\:false\:true\:true\:3\:true\:true\:false NVIC.RCC_IRQn=true\:5\:0\:false\:true\:true\:3\:true\:true\:false
NVIC.RTC_IRQn=true\:5\:0\:true\:false\:true\:false\:true\:true NVIC.RTC_Alarm_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true
NVIC.RTC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false
NVIC.SavedPendsvIrqHandlerGenerated=true NVIC.SavedPendsvIrqHandlerGenerated=true
NVIC.SavedSvcallIrqHandlerGenerated=true NVIC.SavedSvcallIrqHandlerGenerated=true
@ -520,7 +523,7 @@ PE5.GPIO_PuPd=GPIO_PULLUP
PE5.Locked=true PE5.Locked=true
PE5.Signal=GPIO_Input PE5.Signal=GPIO_Input
PE6.GPIOParameters=GPIO_PuPd,GPIO_Label PE6.GPIOParameters=GPIO_PuPd,GPIO_Label
PE6.GPIO_Label=PMG_CHRG_STAT1 PE6.GPIO_Label=PMB_CHRG_STAT1
PE6.GPIO_PuPd=GPIO_PULLUP PE6.GPIO_PuPd=GPIO_PULLUP
PE6.Locked=true PE6.Locked=true
PE6.Signal=GPIO_Input PE6.Signal=GPIO_Input