update
parent
fcda752b65
commit
26ff1cf7bc
|
@ -70,6 +70,7 @@
|
||||||
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3"/>
|
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM3"/>
|
||||||
<listOptionValue builtIn="false" value="../USB_DEVICE/App"/>
|
<listOptionValue builtIn="false" value="../USB_DEVICE/App"/>
|
||||||
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/>
|
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/>
|
||||||
|
<listOptionValue builtIn="false" value="../Utils/CPU"/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1357480259" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.1357480259" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
||||||
</tool>
|
</tool>
|
||||||
|
@ -100,11 +101,12 @@
|
||||||
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.502298629.1450340378" name="elog_cfg.h" rcbsApplicability="disable" resourcePath="Middlewares/EasyLogger/easylogger/inc/elog_cfg.h" toolsToInvoke=""/>
|
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.502298629.1450340378" name="elog_cfg.h" rcbsApplicability="disable" resourcePath="Middlewares/EasyLogger/easylogger/inc/elog_cfg.h" toolsToInvoke=""/>
|
||||||
<sourceEntries>
|
<sourceEntries>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="App"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="App"/>
|
||||||
<entry excluding="Lab-Project-FreeRTOS-POSIX|EasyLogger/easylogger/plugins|EasyLogger/docs" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
|
|
||||||
<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="Drivers"/>
|
||||||
|
<entry excluding="Lab-Project-FreeRTOS-POSIX|EasyLogger/easylogger/plugins|EasyLogger/docs" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="USB_DEVICE"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="USB_DEVICE"/>
|
||||||
|
<entry excluding="CPU" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Utils"/>
|
||||||
</sourceEntries>
|
</sourceEntries>
|
||||||
</configuration>
|
</configuration>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
|
@ -171,6 +173,7 @@
|
||||||
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/>
|
<listOptionValue builtIn="false" value="../USB_DEVICE/Target"/>
|
||||||
<listOptionValue builtIn="false" value="..//CMSIS/Driver/Include"/>
|
<listOptionValue builtIn="false" value="..//CMSIS/Driver/Include"/>
|
||||||
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Class/HID/Inc"/>
|
<listOptionValue builtIn="false" value="../Middlewares/ST/STM32_USB_Device_Library/Class/HID/Inc"/>
|
||||||
|
<listOptionValue builtIn="false" value="../Utils/CPU"/>
|
||||||
</option>
|
</option>
|
||||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.77383630" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.77383630" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
||||||
</tool>
|
</tool>
|
||||||
|
@ -200,11 +203,12 @@
|
||||||
</folderInfo>
|
</folderInfo>
|
||||||
<sourceEntries>
|
<sourceEntries>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="App"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="App"/>
|
||||||
<entry excluding="Lab-Project-FreeRTOS-POSIX|EasyLogger/easylogger/plugins" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
|
|
||||||
<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="Drivers"/>
|
||||||
|
<entry excluding="Lab-Project-FreeRTOS-POSIX|EasyLogger/easylogger/plugins" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Middlewares"/>
|
||||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="USB_DEVICE"/>
|
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="USB_DEVICE"/>
|
||||||
|
<entry excluding="CPU" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="Utils"/>
|
||||||
</sourceEntries>
|
</sourceEntries>
|
||||||
</configuration>
|
</configuration>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
|
|
||||||
#include "cmsis_os2.h"
|
#include "cmsis_os2.h"
|
||||||
|
|
||||||
|
osSemaphoreId_t ElogOutputBinarySemHandle;
|
||||||
|
const osSemaphoreAttr_t ElogOutputBinarySem_attributes;
|
||||||
|
|
||||||
|
|
||||||
osMutexId_t ElogUartMutexHandle;
|
osMutexId_t ElogUartMutexHandle;
|
||||||
const osMutexAttr_t ElogUartMutex_attributes;
|
const osMutexAttr_t ElogUartMutex_attributes;
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,30 @@
|
||||||
|
|
||||||
#include "cmsis_os2.h"
|
#include "cmsis_os2.h"
|
||||||
|
|
||||||
/* Definitions for ButtonDetect */
|
//pressed time < short press time(ms)
|
||||||
osThreadId_t ButtonDetectTaskHandle;
|
#define SHORT_PRESS_TIME 500
|
||||||
const osThreadAttr_t ButtonDetectTask_attributes;
|
|
||||||
|
//pressed time > long press time(ms)
|
||||||
|
#define LONG_PRESS_TIME 1000
|
||||||
|
|
||||||
|
//define exti flag for task-notification / thread-flags
|
||||||
|
typedef enum{
|
||||||
|
SHUTDOWN_REQ_ACTIVE = 0x01<< 0,
|
||||||
|
SHUTDOWN_REQ_INACTIVE = 0x01<< 1,
|
||||||
|
MOD_SLEEP_ACTIVE = 0x01<< 2,
|
||||||
|
MOD_SLEEP_INACTIVE = 0x01<< 3,
|
||||||
|
PWR_BTN_ACTIVE = 0x01<< 4,
|
||||||
|
PWR_BTN_INACTIVE = 0x01<< 5,
|
||||||
|
CUS_BTN_ACTIVE = 0x01<< 6,
|
||||||
|
CUS_BTN_INACTIVE = 0x01<< 7,
|
||||||
|
}Exti_Flags_t;
|
||||||
|
Exti_Flags_t Exti_Flags;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Definitions for ButtonDetectTask */
|
||||||
|
osThreadId_t ExtiServiceTaskHandle;
|
||||||
|
const osThreadAttr_t ExtiServiceTask_attributes;
|
||||||
|
|
||||||
//Timer
|
//Timer
|
||||||
osTimerId_t PwrBtnLongPressTimerHandle;
|
osTimerId_t PwrBtnLongPressTimerHandle;
|
||||||
|
@ -27,8 +48,12 @@ const osTimerAttr_t PwrBtnShortPressTimer_attributes;
|
||||||
osTimerId_t CustBtnShortPressTimerHandle;
|
osTimerId_t CustBtnShortPressTimerHandle;
|
||||||
const osTimerAttr_t CustBtnShortPressTimer_attributes;
|
const osTimerAttr_t CustBtnShortPressTimer_attributes;
|
||||||
|
|
||||||
|
//Event Flag
|
||||||
|
osEventFlagsId_t ExtiEventFlags;
|
||||||
|
const osEventFlagsAttr_t ExtiEventFlags_attributes;
|
||||||
|
|
||||||
void StartButtonDetectTask(void *argument);
|
//Task
|
||||||
|
void StartExtiServiceTask(void *argument);
|
||||||
|
|
||||||
//callback
|
//callback
|
||||||
void PwrBtnLongPressTimerCallback(void *argument);
|
void PwrBtnLongPressTimerCallback(void *argument);
|
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef __TH_INFO_H__
|
||||||
|
#define __TH_INFO_H__
|
||||||
|
|
||||||
|
#include "cmsis_os2.h"
|
||||||
|
|
||||||
|
osThreadId_t InfoOutputTaskHandle;
|
||||||
|
|
||||||
|
const osThreadAttr_t InfoOutputTask_attributes;
|
||||||
|
|
||||||
|
void StartInfoOutputTask(void *argument);
|
||||||
|
#endif
|
|
@ -1,141 +0,0 @@
|
||||||
/*
|
|
||||||
* @Description:
|
|
||||||
* @Date: 2021-03-10 10:49:52
|
|
||||||
* @LastEditors: CK.Zh
|
|
||||||
* @LastEditTime: 2021-03-10 11:57:47
|
|
||||||
* @FilePath: \NaviKit_EC_stm32\App\Src\th_button.c
|
|
||||||
*/
|
|
||||||
#define LOG_TAG "TH-Button"
|
|
||||||
|
|
||||||
#include <th_button.h>
|
|
||||||
#include "main.h"
|
|
||||||
#include "navikit.h"
|
|
||||||
|
|
||||||
//Thread
|
|
||||||
const osThreadAttr_t ButtonDetectTask_attributes = {
|
|
||||||
.name = "ButtonDetectTask",
|
|
||||||
.priority = (osPriority_t) osPriorityBelowNormal,
|
|
||||||
.stack_size = 128 * 8
|
|
||||||
};
|
|
||||||
|
|
||||||
//Timer
|
|
||||||
const osTimerAttr_t PwrBtnLongPressTimer_attributes = {
|
|
||||||
.name = "PwrBtnLongPressTimer"
|
|
||||||
};
|
|
||||||
const osTimerAttr_t CustBtnLongPressTimer_attributes = {
|
|
||||||
.name = "CustBtnLongPressTimer"
|
|
||||||
};
|
|
||||||
const osTimerAttr_t PwrBtnShortPressTimer_attributes = {
|
|
||||||
.name = "PwrBtnShortPressTimer"
|
|
||||||
};
|
|
||||||
const osTimerAttr_t CustBtnShortPressTimer_attributes = {
|
|
||||||
.name = "CustBtnShortPressTimer"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* USER CODE BEGIN Header_StartButtonDetect */
|
|
||||||
/**
|
|
||||||
* @brief Function implementing the ButtonDetect thread.
|
|
||||||
* @param argument: Not used
|
|
||||||
* @retval None
|
|
||||||
*/
|
|
||||||
/* USER CODE END Header_StartButtonDetect */
|
|
||||||
void StartButtonDetectTask(void *argument)
|
|
||||||
{
|
|
||||||
/* USER CODE BEGIN StartButtonDetect */
|
|
||||||
/* Infinite loop */
|
|
||||||
log_d("Start Button Detect Task");
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
//power button
|
|
||||||
if(NaviKit.sys.power_btn && !osTimerIsRunning(PwrBtnLongPressTimerHandle)){
|
|
||||||
osTimerStart(PwrBtnLongPressTimerHandle,1500);
|
|
||||||
osTimerStart(PwrBtnShortPressTimerHandle,100);
|
|
||||||
}
|
|
||||||
osDelay(2);
|
|
||||||
if(!NaviKit.sys.power_btn && osTimerIsRunning(PwrBtnLongPressTimerHandle)){
|
|
||||||
osTimerStop(PwrBtnLongPressTimerHandle);
|
|
||||||
osTimerStop(PwrBtnShortPressTimerHandle);
|
|
||||||
}
|
|
||||||
osDelay(2);
|
|
||||||
//custom button
|
|
||||||
if(!NaviKit.sys.custom_btn && osTimerIsRunning(CustBtnLongPressTimerHandle)){
|
|
||||||
osTimerStop(CustBtnLongPressTimerHandle);
|
|
||||||
osTimerStop(CustBtnShortPressTimerHandle);
|
|
||||||
}
|
|
||||||
osDelay(2);
|
|
||||||
if(NaviKit.sys.custom_btn && !osTimerIsRunning(CustBtnLongPressTimerHandle)){
|
|
||||||
osTimerStart(CustBtnLongPressTimerHandle,1500);
|
|
||||||
osTimerStart(CustBtnShortPressTimerHandle,100);
|
|
||||||
}
|
|
||||||
osDelay(2);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
/* USER CODE END StartButtonDetect */
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PwrBtnLongPressTimerCallback(void *argument)
|
|
||||||
{
|
|
||||||
log_v("power btn long pressed.");
|
|
||||||
switch(NaviKit.sys.sta){
|
|
||||||
case run: {NaviKit.sys.next_sta = idle;log_v("change to idle"); }break;//system is run now, user request to idle
|
|
||||||
case idle: {NaviKit.sys.next_sta = run;log_v("change to run"); }break;//system is idle now , user request to power on
|
|
||||||
case dfu: {NaviKit.sys.next_sta = idle;log_v("change to idle"); }break;
|
|
||||||
case sleep:{NaviKit.sys.next_sta = run;log_v("change to run"); }break;
|
|
||||||
case isp: {NaviKit.sys.next_sta = idle;log_v("change to idle"); }break;
|
|
||||||
default : break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void CustBtnLongPressTimerCallback(void *argument)
|
|
||||||
{
|
|
||||||
log_v("custom btn long pressed.");
|
|
||||||
switch(NaviKit.sys.sta){
|
|
||||||
case run:{//system is run now, user request to reboot SOM
|
|
||||||
som_reboot(100);
|
|
||||||
}break;
|
|
||||||
case idle:{
|
|
||||||
}break;
|
|
||||||
case dfu:{
|
|
||||||
som_reboot(100);
|
|
||||||
}break;
|
|
||||||
case sleep:{
|
|
||||||
}break;
|
|
||||||
default : break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void PwrBtnShortPressTimerCallback(void *argument)
|
|
||||||
{
|
|
||||||
log_v("power btn short pressed.");
|
|
||||||
switch(NaviKit.sys.sta){
|
|
||||||
case run: {//som is running, send sleep requeset to operate system
|
|
||||||
log_v("Request operate system pop up the shutdown dialog.");
|
|
||||||
PWR_Enable(SOM_SLEEP,true,100);
|
|
||||||
PWR_Enable(SOM_SLEEP,false,0);
|
|
||||||
}break;
|
|
||||||
case idle: { }break;//system is idle now , user request to power on
|
|
||||||
case dfu: { }break;
|
|
||||||
case sleep:{ }break;
|
|
||||||
case isp: { }break;
|
|
||||||
default : break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void CustBtnShortPressTimerCallback(void *argument)
|
|
||||||
{
|
|
||||||
log_v("custom btn short pressed.");
|
|
||||||
switch(NaviKit.sys.sta){
|
|
||||||
case run:{
|
|
||||||
}break;
|
|
||||||
case idle:{
|
|
||||||
}break;
|
|
||||||
case dfu:{
|
|
||||||
}break;
|
|
||||||
case sleep:{
|
|
||||||
}break;
|
|
||||||
default : break;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,7 +16,7 @@ extern uint32_t number_restart;
|
||||||
const osThreadAttr_t cdcMonitorTask_attributes = {
|
const osThreadAttr_t cdcMonitorTask_attributes = {
|
||||||
.name = "cdcMonitorTask",
|
.name = "cdcMonitorTask",
|
||||||
.priority = (osPriority_t) osPriorityBelowNormal7,
|
.priority = (osPriority_t) osPriorityBelowNormal7,
|
||||||
.stack_size = 128 * 8
|
.stack_size = 256 * 4
|
||||||
};
|
};
|
||||||
|
|
||||||
//task instance
|
//task instance
|
||||||
|
|
|
@ -13,13 +13,13 @@
|
||||||
|
|
||||||
const osThreadAttr_t DemoTask1_attributes = {
|
const osThreadAttr_t DemoTask1_attributes = {
|
||||||
.name = "DemoTask1",
|
.name = "DemoTask1",
|
||||||
.priority = (osPriority_t) osPriorityLow2,
|
.priority = (osPriority_t) osPriorityLow1,
|
||||||
.stack_size = 128 * 8
|
.stack_size = 256 * 4
|
||||||
};
|
};
|
||||||
const osThreadAttr_t DemoTask2_attributes = {
|
const osThreadAttr_t DemoTask2_attributes = {
|
||||||
.name = "DemoTask2",
|
.name = "DemoTask2",
|
||||||
.priority = (osPriority_t) osPriorityLow1,
|
.priority = (osPriority_t) osPriorityLow1,
|
||||||
.stack_size = 128 * 8
|
.stack_size = 256 * 4
|
||||||
};
|
};
|
||||||
void StartDemoTask1(void *argument){
|
void StartDemoTask1(void *argument){
|
||||||
uint8_t i=0;
|
uint8_t i=0;
|
||||||
|
|
|
@ -11,13 +11,18 @@
|
||||||
#include <th_elog.h>
|
#include <th_elog.h>
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
//semaphore
|
||||||
|
const osSemaphoreAttr_t ElogOutputBinarySem_attributes = {
|
||||||
|
.name = "ElogOutputBinarySem"
|
||||||
|
};
|
||||||
|
//mutex
|
||||||
const osMutexAttr_t ElogUartMutex_attributes = {
|
const osMutexAttr_t ElogUartMutex_attributes = {
|
||||||
.name = "ElogUartMutex"
|
.name = "ElogUartMutex"
|
||||||
};
|
};
|
||||||
const osMutexAttr_t ElogOutputMutex_attributes = {
|
const osMutexAttr_t ElogOutputMutex_attributes = {
|
||||||
.name = "ElogOutputMutex"
|
.name = "ElogOutputMutex"
|
||||||
};
|
};
|
||||||
|
//task
|
||||||
const osThreadAttr_t ElogInitTask_attributes = {
|
const osThreadAttr_t ElogInitTask_attributes = {
|
||||||
.name = "ElogInitTask",
|
.name = "ElogInitTask",
|
||||||
.priority = (osPriority_t) osPriorityNormal,
|
.priority = (osPriority_t) osPriorityNormal,
|
||||||
|
@ -27,7 +32,7 @@ const osThreadAttr_t ElogInitTask_attributes = {
|
||||||
const osThreadAttr_t ElogFlushTask_attributes = {
|
const osThreadAttr_t ElogFlushTask_attributes = {
|
||||||
.name = "ElogFlushTask",
|
.name = "ElogFlushTask",
|
||||||
.priority = (osPriority_t) osPriorityLow,
|
.priority = (osPriority_t) osPriorityLow,
|
||||||
.stack_size = 128 * 8
|
.stack_size = 256 * 4
|
||||||
};
|
};
|
||||||
|
|
||||||
void StartElogInitTask(void *argument){
|
void StartElogInitTask(void *argument){
|
||||||
|
@ -39,8 +44,7 @@ void StartElogInitTask(void *argument){
|
||||||
|
|
||||||
void StartElogFlushTask(void *argument){
|
void StartElogFlushTask(void *argument){
|
||||||
|
|
||||||
uint8_t i=0;
|
log_d("Start log Flush Task");
|
||||||
log_d("Start Elog Flush Task");
|
|
||||||
for(;;){
|
for(;;){
|
||||||
elog_flush();
|
elog_flush();
|
||||||
osDelay(1);
|
osDelay(1);
|
||||||
|
|
|
@ -0,0 +1,221 @@
|
||||||
|
/*
|
||||||
|
* @Description:
|
||||||
|
* @Date: 2021-03-10 10:49:52
|
||||||
|
* @LastEditors: CK.Zh
|
||||||
|
* @LastEditTime: 2021-03-10 11:57:47
|
||||||
|
* @FilePath: \NaviKit_EC_stm32\App\Src\th_button.c
|
||||||
|
*/
|
||||||
|
#define LOG_TAG "TH-Exti"
|
||||||
|
|
||||||
|
#include <th_exti.h>
|
||||||
|
#include "main.h"
|
||||||
|
#include "navikit.h"
|
||||||
|
|
||||||
|
//Thread
|
||||||
|
const osThreadAttr_t ExtiServiceTask_attributes = {
|
||||||
|
.name = "ExtiServiceTask",
|
||||||
|
.priority = (osPriority_t) osPriorityBelowNormal,
|
||||||
|
.stack_size = 256 * 4
|
||||||
|
};
|
||||||
|
|
||||||
|
//Timer
|
||||||
|
const osTimerAttr_t PwrBtnLongPressTimer_attributes = {
|
||||||
|
.name = "PwrBtnLongPressTimer"
|
||||||
|
};
|
||||||
|
const osTimerAttr_t CustBtnLongPressTimer_attributes = {
|
||||||
|
.name = "CustBtnLongPressTimer"
|
||||||
|
};
|
||||||
|
const osTimerAttr_t PwrBtnShortPressTimer_attributes = {
|
||||||
|
.name = "PwrBtnShortPressTimer"
|
||||||
|
};
|
||||||
|
const osTimerAttr_t CustBtnShortPressTimer_attributes = {
|
||||||
|
.name = "CustBtnShortPressTimer"
|
||||||
|
};
|
||||||
|
|
||||||
|
//Event Flag
|
||||||
|
const osEventFlagsAttr_t ExtiEventFlags_attributes = {
|
||||||
|
.name = "ExtiEventFlags"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* USER CODE BEGIN Header_StartExtiServiceTask */
|
||||||
|
/**
|
||||||
|
* @brief Function implementing the ExtiServiceTask thread.
|
||||||
|
* @param argument: Not used
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
/* USER CODE END Header_StartExtiServiceTask */
|
||||||
|
void StartExtiServiceTask(void *argument)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN StartExtiServiceTask */
|
||||||
|
/* Infinite loop */
|
||||||
|
uint32_t thread_flag = 0;
|
||||||
|
log_d("Start EXTI Service Task");
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
|
thread_flag = osThreadFlagsGet();
|
||||||
|
|
||||||
|
if(thread_flag & SHUTDOWN_REQ){
|
||||||
|
|
||||||
|
}
|
||||||
|
if(thread_flag & MOD_SLEEP){
|
||||||
|
|
||||||
|
}
|
||||||
|
//powwer button
|
||||||
|
if((thread_flag & PWR_BTN) && !osTimerIsRunning(PwrBtnLongPressTimerHandle)){
|
||||||
|
osTimerStart(PwrBtnLongPressTimerHandle,LONG_PRESS_TIME);
|
||||||
|
osTimerStart(PwrBtnShortPressTimerHandle,SHORT_PRESS_TIME);
|
||||||
|
}else if(!(thread_flag & PWR_BTN) && osTimerIsRunning(PwrBtnLongPressTimerHandle)){
|
||||||
|
osTimerStop(PwrBtnLongPressTimerHandle);
|
||||||
|
osTimerStop(PwrBtnShortPressTimerHandle);
|
||||||
|
}
|
||||||
|
//custom button
|
||||||
|
if((thread_flag & CUS_BTN) && !osTimerIsRunning(CustBtnLongPressTimerHandle)) {
|
||||||
|
osTimerStart(CustBtnLongPressTimerHandle,LONG_PRESS_TIME);
|
||||||
|
osTimerStart(CustBtnShortPressTimerHandle,SHORT_PRESS_TIME);
|
||||||
|
}else if(!(thread_flag & CUS_BTN) && osTimerIsRunning(CustBtnLongPressTimerHandle)){
|
||||||
|
osTimerStop(CustBtnLongPressTimerHandle);
|
||||||
|
osTimerStop(CustBtnShortPressTimerHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
// //power button
|
||||||
|
// if(NaviKit.sys.power_btn && !osTimerIsRunning(PwrBtnLongPressTimerHandle)){
|
||||||
|
// osTimerStart(PwrBtnLongPressTimerHandle,LONG_PRESS_TIME);
|
||||||
|
// osTimerStart(PwrBtnShortPressTimerHandle,SHORT_PRESS_TIME);
|
||||||
|
// }
|
||||||
|
// osDelay(2);
|
||||||
|
// if(!NaviKit.sys.power_btn && osTimerIsRunning(PwrBtnLongPressTimerHandle)){
|
||||||
|
// osTimerStop(PwrBtnLongPressTimerHandle);
|
||||||
|
// osTimerStop(PwrBtnShortPressTimerHandle);
|
||||||
|
// }
|
||||||
|
// osDelay(2);
|
||||||
|
//custom button
|
||||||
|
// if(!NaviKit.sys.custom_btn && osTimerIsRunning(CustBtnLongPressTimerHandle)){
|
||||||
|
// }
|
||||||
|
// osDelay(2);
|
||||||
|
// if(NaviKit.sys.custom_btn && !osTimerIsRunning(CustBtnLongPressTimerHandle)){
|
||||||
|
// }
|
||||||
|
// osDelay(2);
|
||||||
|
osDelay(10);
|
||||||
|
|
||||||
|
}
|
||||||
|
/* USER CODE END StartExtiServiceTask */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PwrBtnLongPressTimerCallback(void *argument)
|
||||||
|
{
|
||||||
|
log_v("power button long pressed.");
|
||||||
|
switch(NaviKit.sys.sta){
|
||||||
|
case run: {NaviKit.sys.next_sta = idle;log_v("change to idle"); }break;//system is run now, user request to idle
|
||||||
|
case idle: {NaviKit.sys.next_sta = run;log_v("change to run"); }break;//system is idle now , user request to power on
|
||||||
|
case dfu: {NaviKit.sys.next_sta = idle;log_v("change to idle"); }break;
|
||||||
|
case sleep:{NaviKit.sys.next_sta = run;log_v("change to run"); }break;
|
||||||
|
case isp: {NaviKit.sys.next_sta = idle;log_v("change to idle"); }break;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CustBtnLongPressTimerCallback(void *argument)
|
||||||
|
{
|
||||||
|
log_v("custom button long pressed.");
|
||||||
|
switch(NaviKit.sys.sta){
|
||||||
|
case run:{//system is run now, user request to reboot SOM
|
||||||
|
som_reboot(100);
|
||||||
|
}break;
|
||||||
|
case idle:{
|
||||||
|
}break;
|
||||||
|
case dfu:{
|
||||||
|
som_reboot(100);
|
||||||
|
}break;
|
||||||
|
case sleep:{
|
||||||
|
}break;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void PwrBtnShortPressTimerCallback(void *argument)
|
||||||
|
{
|
||||||
|
log_v("power button short pressed.");
|
||||||
|
switch(NaviKit.sys.sta){
|
||||||
|
case run: {//som is running, send sleep requeset to operate system
|
||||||
|
log_v("Request operate system pop up the shutdown dialog.");
|
||||||
|
PWR_Enable(SOM_SLEEP,true,100);
|
||||||
|
PWR_Enable(SOM_SLEEP,false,0);
|
||||||
|
}break;
|
||||||
|
case idle: { }break;//system is idle now , user request to power on
|
||||||
|
case dfu: { }break;
|
||||||
|
case sleep:{ }break;
|
||||||
|
case isp: { }break;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void CustBtnShortPressTimerCallback(void *argument)
|
||||||
|
{
|
||||||
|
log_v("custom button short pressed.");
|
||||||
|
switch(NaviKit.sys.sta){
|
||||||
|
case run:{
|
||||||
|
}break;
|
||||||
|
case idle:{
|
||||||
|
}break;
|
||||||
|
case dfu:{
|
||||||
|
}break;
|
||||||
|
case sleep:{
|
||||||
|
}break;
|
||||||
|
default : break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
||||||
|
{
|
||||||
|
switch (GPIO_Pin){
|
||||||
|
case SOM_SHUTDOWN_REQ_Pin:{
|
||||||
|
if(HAL_GPIO_ReadPin(SOM_SHUTDOWN_REQ_GPIO_Port, SOM_SHUTDOWN_REQ_Pin)==GPIO_PIN_RESET){//falling edge trigger
|
||||||
|
if(NaviKit.sys.sta == run){//if jetson nano shutdown output low,the power_en should be set low less than 10us
|
||||||
|
PWR_Enable(SOM_PWR_EN,false,0);
|
||||||
|
NaviKit.sys.next_sta = idle;
|
||||||
|
osThreadFlagsSet(ExtiServiceTaskHandle,(Exti_Flags_t)SHUTDOWN_REQ_ACTIVE);
|
||||||
|
// log_i("SOM's shutdown_req pin falling edge, SOM request to shutdown.");
|
||||||
|
}
|
||||||
|
}else{//Rising edge trigger
|
||||||
|
osThreadFlagsSet(ExtiServiceTaskHandle,(Exti_Flags_t)SHUTDOWN_REQ_INACTIVE);
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case SOM_MOD_SLEEP_Pin:{
|
||||||
|
if(HAL_GPIO_ReadPin(SOM_MOD_SLEEP_GPIO_Port, SOM_MOD_SLEEP_Pin)==GPIO_PIN_SET){//Rising edge trigger
|
||||||
|
// log_i("SOM's sleep pin rising edge.");
|
||||||
|
osThreadFlagsSet(ExtiServiceTaskHandle,(Exti_Flags_t)MOD_SLEEP_ACTIVE);
|
||||||
|
}else{//falling edge trigger
|
||||||
|
// log_v("SOM's sleep pin falling edge.");
|
||||||
|
osThreadFlagsSet(ExtiServiceTaskHandle,(Exti_Flags_t)MOD_SLEEP_INACTIVE);
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case SYS_POWER_BTN_Pin:{
|
||||||
|
if(HAL_GPIO_ReadPin(SYS_POWER_BTN_GPIO_Port, SYS_POWER_BTN_Pin)==GPIO_PIN_SET){//Rising edge trigger
|
||||||
|
NaviKit.sys.power_btn = true;
|
||||||
|
// log_v("power_btn status: pressed.");
|
||||||
|
osThreadFlagsSet(ExtiServiceTaskHandle,(Exti_Flags_t)PWR_BTN_ACTIVE);
|
||||||
|
}else{//falling edge trigger
|
||||||
|
NaviKit.sys.power_btn = false;
|
||||||
|
// log_v("power_btn status: released.");
|
||||||
|
osThreadFlagsSet(ExtiServiceTaskHandle,(Exti_Flags_t)PWR_BTN_INACTIVE);
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
case SYS_CUSTOM_BTN_Pin:{
|
||||||
|
if(HAL_GPIO_ReadPin(SYS_CUSTOM_BTN_GPIO_Port, SYS_CUSTOM_BTN_Pin)==GPIO_PIN_RESET){//falling edge trigger
|
||||||
|
// log_v("custom_btn status: pressed.");
|
||||||
|
NaviKit.sys.custom_btn = true;
|
||||||
|
osThreadFlagsSet(ExtiServiceTaskHandle,(Exti_Flags_t)CUS_BTN_ACTIVE);
|
||||||
|
}else{//Rising edge trigger
|
||||||
|
// log_v("custom_btn status: released.");
|
||||||
|
NaviKit.sys.custom_btn = false;
|
||||||
|
osThreadFlagsSet(ExtiServiceTaskHandle,(Exti_Flags_t)CUS_BTN_INACTIVE);
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* @Description:
|
||||||
|
* @Date: 2021-03-09 18:19:26
|
||||||
|
* @LastEditors: CK.Zh
|
||||||
|
* @LastEditTime: 2021-03-10 15:07:01
|
||||||
|
* @FilePath: \NaviKit_EC_stm32\App\Src\th_demo.c
|
||||||
|
*/
|
||||||
|
#define LOG_TAG "TH-Info"
|
||||||
|
|
||||||
|
#include <th_info.h>
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
|
||||||
|
const osThreadAttr_t InfoOutputTask_attributes = {
|
||||||
|
.name = "InfoOutputTask",
|
||||||
|
.priority = (osPriority_t) osPriorityLow2,
|
||||||
|
.stack_size = 256 * 4
|
||||||
|
};
|
||||||
|
void StartInfoOutputTask(void *argument){
|
||||||
|
log_d("Start Info Output Task");
|
||||||
|
for(;;){
|
||||||
|
osThreadExit();
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,7 +15,7 @@
|
||||||
const osThreadAttr_t IWDGTask_attributes = {
|
const osThreadAttr_t IWDGTask_attributes = {
|
||||||
.name = "IWDGTask",
|
.name = "IWDGTask",
|
||||||
.priority = (osPriority_t) osPriorityHigh,
|
.priority = (osPriority_t) osPriorityHigh,
|
||||||
.stack_size = 128 * 8
|
.stack_size = 256 * 4
|
||||||
};
|
};
|
||||||
|
|
||||||
void StartIWDGTask(void *argument){
|
void StartIWDGTask(void *argument){
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
const osThreadAttr_t LedBlinkTask_attributes = {
|
const osThreadAttr_t LedBlinkTask_attributes = {
|
||||||
.name = "LedBlinkTask",
|
.name = "LedBlinkTask",
|
||||||
.priority = (osPriority_t) osPriorityLow7,
|
.priority = (osPriority_t) osPriorityLow7,
|
||||||
.stack_size = 128 * 8
|
.stack_size = 256 * 4
|
||||||
};
|
};
|
||||||
|
|
||||||
/* USER CODE BEGIN Header_StartLedBlinkTask */
|
/* USER CODE BEGIN Header_StartLedBlinkTask */
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
const osThreadAttr_t PowerMonitTask_attributes = {
|
const osThreadAttr_t PowerMonitTask_attributes = {
|
||||||
.name = "PowerMonitTask",
|
.name = "PowerMonitTask",
|
||||||
.priority = (osPriority_t) osPriorityBelowNormal,
|
.priority = (osPriority_t) osPriorityBelowNormal,
|
||||||
.stack_size = 128 * 8
|
.stack_size = 256 * 4
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,13 +64,15 @@
|
||||||
#define configTICK_RATE_HZ ((TickType_t)1000)
|
#define configTICK_RATE_HZ ((TickType_t)1000)
|
||||||
#define configMAX_PRIORITIES ( 56 )
|
#define configMAX_PRIORITIES ( 56 )
|
||||||
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
|
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
|
||||||
#define configTOTAL_HEAP_SIZE ((size_t)8192)
|
#define configTOTAL_HEAP_SIZE ((size_t)16384)
|
||||||
#define configMAX_TASK_NAME_LEN ( 32 )
|
#define configMAX_TASK_NAME_LEN ( 32 )
|
||||||
#define configGENERATE_RUN_TIME_STATS 1
|
#define configGENERATE_RUN_TIME_STATS 1
|
||||||
|
#define configUSE_TRACE_FACILITY 1
|
||||||
|
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
|
||||||
#define configUSE_16_BIT_TICKS 0
|
#define configUSE_16_BIT_TICKS 0
|
||||||
#define configUSE_MUTEXES 1
|
#define configUSE_MUTEXES 1
|
||||||
#define configQUEUE_REGISTRY_SIZE 8
|
#define configQUEUE_REGISTRY_SIZE 8
|
||||||
#define configCHECK_FOR_STACK_OVERFLOW 1
|
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||||
#define configUSE_RECURSIVE_MUTEXES 1
|
#define configUSE_RECURSIVE_MUTEXES 1
|
||||||
#define configUSE_COUNTING_SEMAPHORES 1
|
#define configUSE_COUNTING_SEMAPHORES 1
|
||||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#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
|
typedef enum
|
||||||
{
|
{
|
||||||
standby, //minimum current state
|
standby, //minimum current state
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include <th_led.h>
|
#include <th_led.h>
|
||||||
#include <th_coulomb.h>
|
#include <th_coulomb.h>
|
||||||
#include <th_power.h>
|
#include <th_power.h>
|
||||||
#include <th_button.h>
|
#include <th_exti.h>
|
||||||
#include <th_iwdg.h>
|
#include <th_iwdg.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ const osTimerAttr_t IdleStateHoldTimer_attributes = {
|
||||||
osThreadId_t defaultTaskHandle;
|
osThreadId_t defaultTaskHandle;
|
||||||
const osThreadAttr_t defaultTask_attributes = {
|
const osThreadAttr_t defaultTask_attributes = {
|
||||||
.name = "defaultTask",
|
.name = "defaultTask",
|
||||||
.stack_size = 128 * 8,
|
.stack_size = 256 * 4,
|
||||||
.priority = (osPriority_t) osPriorityNormal,
|
.priority = (osPriority_t) osPriorityNormal,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ void IdleStateHoldTimerCallback(void *argument);
|
||||||
|
|
||||||
bool isWakeUpFromReset() { return __HAL_PWR_GET_FLAG(PWR_FLAG_WU);}
|
bool isWakeUpFromReset() { return __HAL_PWR_GET_FLAG(PWR_FLAG_WU);}
|
||||||
|
|
||||||
//__HAL_RCC_GET_FLAG(); //判断复位源
|
//__HAL_RCC_GET_FLAG(); //judge reset source flag
|
||||||
|
|
||||||
/* USER CODE END FunctionPrototypes */
|
/* USER CODE END FunctionPrototypes */
|
||||||
|
|
||||||
|
@ -143,6 +143,8 @@ void vApplicationStackOverflowHook(xTaskHandle xTask, signed char *pcTaskName)
|
||||||
/* Run time stack overflow checking is performed if
|
/* Run time stack overflow checking is performed if
|
||||||
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is
|
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook function is
|
||||||
called if a stack overflow is detected. */
|
called if a stack overflow is detected. */
|
||||||
|
|
||||||
|
while(1);
|
||||||
}
|
}
|
||||||
/* USER CODE END 4 */
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
|
@ -168,7 +170,8 @@ __weak void PostSleepProcessing(uint32_t *ulExpectedIdleTime)
|
||||||
void MX_FREERTOS_Init(void) {
|
void MX_FREERTOS_Init(void) {
|
||||||
/* USER CODE BEGIN Init */
|
/* USER CODE BEGIN Init */
|
||||||
|
|
||||||
ElogOutputMutexHandle = osMutexNew(&ElogOutputMutex_attributes);
|
// ElogOutputMutexHandle = osMutexNew(&ElogOutputMutex_attributes);
|
||||||
|
ElogOutputBinarySemHandle = osSemaphoreNew(1, 1, &ElogOutputBinarySem_attributes);
|
||||||
// ElogUartMutexHandle = osMutexNew(&ElogUartMutex_attributes);
|
// ElogUartMutexHandle = osMutexNew(&ElogUartMutex_attributes);
|
||||||
my_elog_init();
|
my_elog_init();
|
||||||
NaviKit_var_init();
|
NaviKit_var_init();
|
||||||
|
@ -181,6 +184,7 @@ void MX_FREERTOS_Init(void) {
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_SEMAPHORES */
|
/* USER CODE BEGIN RTOS_SEMAPHORES */
|
||||||
/* add semaphores, ... */
|
/* add semaphores, ... */
|
||||||
|
|
||||||
/* USER CODE END RTOS_SEMAPHORES */
|
/* USER CODE END RTOS_SEMAPHORES */
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_TIMERS */
|
/* USER CODE BEGIN RTOS_TIMERS */
|
||||||
|
@ -195,7 +199,6 @@ void MX_FREERTOS_Init(void) {
|
||||||
|
|
||||||
/* USER CODE BEGIN RTOS_QUEUES */
|
/* USER CODE BEGIN RTOS_QUEUES */
|
||||||
/* add queues, ... */
|
/* add queues, ... */
|
||||||
// LogMessageQueueHandle = osMessageQueueNew (1024, sizeof(uint8_t), &LogMessageQueue_attributes);
|
|
||||||
|
|
||||||
/* USER CODE END RTOS_QUEUES */
|
/* USER CODE END RTOS_QUEUES */
|
||||||
|
|
||||||
|
@ -215,7 +218,7 @@ void MX_FREERTOS_Init(void) {
|
||||||
|
|
||||||
|
|
||||||
//Button--------------------------------------------
|
//Button--------------------------------------------
|
||||||
ButtonDetectTaskHandle = osThreadNew(StartButtonDetectTask, NULL, &ButtonDetectTask_attributes);
|
ExtiServiceTaskHandle = osThreadNew(StartExtiServiceTask, NULL, &ExtiServiceTask_attributes);
|
||||||
|
|
||||||
|
|
||||||
//LED--------------------------------------------
|
//LED--------------------------------------------
|
||||||
|
@ -223,7 +226,7 @@ void MX_FREERTOS_Init(void) {
|
||||||
|
|
||||||
|
|
||||||
//CDC--------------------------------------------
|
//CDC--------------------------------------------
|
||||||
cdcMonitorTaskHandle = osThreadNew(StartCdcMonitorTask, NULL, &cdcMonitorTask_attributes);
|
cdcMonitorTaskHandle = osThreadNew(StartCdcMonitorTask, NULL, &cdcMonitorTask_attributes);
|
||||||
|
|
||||||
|
|
||||||
//Coulomb--------------------------------------------
|
//Coulomb--------------------------------------------
|
||||||
|
@ -237,15 +240,15 @@ void MX_FREERTOS_Init(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Demo--------------------------------------------
|
//Demo--------------------------------------------
|
||||||
DemoTask1Handle = osThreadNew(StartDemoTask1, NULL, &DemoTask1_attributes);
|
DemoTask1Handle = osThreadNew(StartDemoTask1, NULL, &DemoTask1_attributes);
|
||||||
DemoTask2Handle = osThreadNew(StartDemoTask2, NULL, &DemoTask2_attributes);
|
DemoTask2Handle = osThreadNew(StartDemoTask2, NULL, &DemoTask2_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, ... */
|
||||||
|
ExtiEventFlags = osEventFlagsNew(&ExtiEventFlags_attributes);
|
||||||
/* USER CODE END RTOS_EVENTS */
|
/* USER CODE END RTOS_EVENTS */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,8 +173,8 @@ void SystemClock_Config(void)
|
||||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV4;
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV4;
|
||||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV16;
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
|
||||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV16;
|
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV4;
|
||||||
|
|
||||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
|
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
|
||||||
{
|
{
|
||||||
|
@ -189,6 +189,9 @@ void SystemClock_Config(void)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
|
/** Enables the Clock Security System
|
||||||
|
*/
|
||||||
|
HAL_RCC_EnableCSS();
|
||||||
/** Configure the Systick interrupt time
|
/** Configure the Systick interrupt time
|
||||||
*/
|
*/
|
||||||
__HAL_RCC_PLLI2S_ENABLE();
|
__HAL_RCC_PLLI2S_ENABLE();
|
||||||
|
|
|
@ -57,60 +57,17 @@ 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)
|
|
||||||
{
|
|
||||||
switch (GPIO_Pin){
|
|
||||||
case SOM_SHUTDOWN_REQ_Pin:{
|
|
||||||
if(HAL_GPIO_ReadPin(SOM_SHUTDOWN_REQ_GPIO_Port, SOM_SHUTDOWN_REQ_Pin)==GPIO_PIN_RESET){//falling edge trigger
|
|
||||||
if(NaviKit.sys.sta == run){//if jetson nano shutdown output low,the power_en should be set low less than 10us
|
|
||||||
PWR_Enable(SOM_PWR_EN,false,0);
|
|
||||||
NaviKit.sys.next_sta = idle;
|
|
||||||
log_i("SOM's shutdown_req pin falling edge, SOM request to shutdown.");
|
|
||||||
}
|
|
||||||
}else{//Rising edge trigger
|
|
||||||
}
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case SOM_MOD_SLEEP_Pin:{
|
|
||||||
if(HAL_GPIO_ReadPin(SOM_MOD_SLEEP_GPIO_Port, SOM_MOD_SLEEP_Pin)==GPIO_PIN_SET){//Rising edge trigger
|
|
||||||
log_i("SOM's sleep pin rising edge.");
|
|
||||||
}else{//falling edge trigger
|
|
||||||
log_v("SOM's sleep pin falling edge.");
|
|
||||||
}
|
|
||||||
}break;
|
|
||||||
case SYS_POWER_BTN_Pin:{
|
|
||||||
if(HAL_GPIO_ReadPin(SYS_POWER_BTN_GPIO_Port, SYS_POWER_BTN_Pin)==GPIO_PIN_SET){//Rising edge trigger
|
|
||||||
NaviKit.sys.power_btn = true;
|
|
||||||
log_v("power_btn status: pressed.");
|
|
||||||
}else{//falling edge trigger
|
|
||||||
NaviKit.sys.power_btn = false;
|
|
||||||
log_v("power_btn status: released.");
|
|
||||||
}
|
|
||||||
}break;
|
|
||||||
case SYS_CUSTOM_BTN_Pin:{
|
|
||||||
if(HAL_GPIO_ReadPin(SYS_CUSTOM_BTN_GPIO_Port, SYS_CUSTOM_BTN_Pin)==GPIO_PIN_RESET){//falling edge trigger
|
|
||||||
log_v("custom_btn status: pressed.");
|
|
||||||
NaviKit.sys.custom_btn = true;
|
|
||||||
}else{//Rising edge trigger
|
|
||||||
log_v("custom_btn status: released.");
|
|
||||||
NaviKit.sys.custom_btn = false;
|
|
||||||
}
|
|
||||||
}break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void enter_standby_state(){
|
void enter_standby_state(){
|
||||||
log_i("EC enter to STANDBY Mode to save power, see you!");
|
log_i("EC enter to STANDBY Mode to save power, see you!");
|
||||||
osDelay(10);
|
osDelay(10);
|
||||||
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);//Enable PA0 wakeup function
|
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);//Enable PA0 wakeup function
|
||||||
__HAL_RCC_RTC_DISABLE();
|
__HAL_RCC_RTC_DISABLE();
|
||||||
HAL_PWR_EnterSTANDBYMode();
|
HAL_PWR_EnterSTANDBYMode();
|
||||||
}
|
}
|
||||||
//write "bios update flag" to bkp register, and reset system
|
|
||||||
void enter_isp_state()
|
void enter_isp_state()
|
||||||
{
|
{
|
||||||
|
//write "bios update flag" to bkp register, and reset system
|
||||||
ISP_Prepare();
|
ISP_Prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,7 @@ void NMI_Handler(void)
|
||||||
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END NonMaskableInt_IRQn 0 */
|
/* USER CODE END NonMaskableInt_IRQn 0 */
|
||||||
|
HAL_RCC_NMI_IRQHandler();
|
||||||
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
|
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
|
||||||
|
|
||||||
/* USER CODE END NonMaskableInt_IRQn 1 */
|
/* USER CODE END NonMaskableInt_IRQn 1 */
|
||||||
|
|
|
@ -43,7 +43,7 @@ void MX_UART4_Init(void)
|
||||||
|
|
||||||
/* USER CODE END UART4_Init 1 */
|
/* USER CODE END UART4_Init 1 */
|
||||||
huart4.Instance = UART4;
|
huart4.Instance = UART4;
|
||||||
huart4.Init.BaudRate = 56000;
|
huart4.Init.BaudRate = 115200;
|
||||||
huart4.Init.WordLength = UART_WORDLENGTH_8B;
|
huart4.Init.WordLength = UART_WORDLENGTH_8B;
|
||||||
huart4.Init.StopBits = UART_STOPBITS_1;
|
huart4.Init.StopBits = UART_STOPBITS_1;
|
||||||
huart4.Init.Parity = UART_PARITY_NONE;
|
huart4.Init.Parity = UART_PARITY_NONE;
|
||||||
|
@ -72,7 +72,7 @@ void MX_USART1_UART_Init(void)
|
||||||
|
|
||||||
/* USER CODE END USART1_Init 1 */
|
/* USER CODE END USART1_Init 1 */
|
||||||
huart1.Instance = USART1;
|
huart1.Instance = USART1;
|
||||||
huart1.Init.BaudRate = 56000;
|
huart1.Init.BaudRate = 115200;
|
||||||
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||||
huart1.Init.StopBits = UART_STOPBITS_1;
|
huart1.Init.StopBits = UART_STOPBITS_1;
|
||||||
huart1.Init.Parity = UART_PARITY_NONE;
|
huart1.Init.Parity = UART_PARITY_NONE;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 32679ed89f7364d5f7d5281ba1b8319434ced00c
|
Subproject commit a813ff549eeec5fa41af5604770092e62ab504fc
|
|
@ -115,19 +115,19 @@ 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
|
||||||
FREERTOS.Tasks01=defaultTask,24,128,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL
|
FREERTOS.Tasks01=defaultTask,24,256,StartDefaultTask,Default,NULL,Dynamic,NULL,NULL
|
||||||
FREERTOS.configCHECK_FOR_STACK_OVERFLOW=1
|
FREERTOS.configCHECK_FOR_STACK_OVERFLOW=2
|
||||||
FREERTOS.configGENERATE_RUN_TIME_STATS=1
|
FREERTOS.configGENERATE_RUN_TIME_STATS=1
|
||||||
FREERTOS.configMAX_TASK_NAME_LEN=32
|
FREERTOS.configMAX_TASK_NAME_LEN=32
|
||||||
FREERTOS.configTOTAL_HEAP_SIZE=8192
|
FREERTOS.configTOTAL_HEAP_SIZE=16384
|
||||||
FREERTOS.configUSE_APPLICATION_TASK_TAG=0
|
FREERTOS.configUSE_APPLICATION_TASK_TAG=0
|
||||||
FREERTOS.configUSE_IDLE_HOOK=1
|
FREERTOS.configUSE_IDLE_HOOK=1
|
||||||
FREERTOS.configUSE_MALLOC_FAILED_HOOK=0
|
FREERTOS.configUSE_MALLOC_FAILED_HOOK=0
|
||||||
FREERTOS.configUSE_STATS_FORMATTING_FUNCTIONS=0
|
FREERTOS.configUSE_STATS_FORMATTING_FUNCTIONS=1
|
||||||
FREERTOS.configUSE_TASK_NOTIFICATIONS=1
|
FREERTOS.configUSE_TASK_NOTIFICATIONS=1
|
||||||
FREERTOS.configUSE_TICKLESS_IDLE=1
|
FREERTOS.configUSE_TICKLESS_IDLE=1
|
||||||
FREERTOS.configUSE_TICK_HOOK=1
|
FREERTOS.configUSE_TICK_HOOK=1
|
||||||
FREERTOS.configUSE_TRACE_FACILITY=0
|
FREERTOS.configUSE_TRACE_FACILITY=1
|
||||||
File.Version=6
|
File.Version=6
|
||||||
GPIO.groupedBy=Group By Peripherals
|
GPIO.groupedBy=Group By Peripherals
|
||||||
IWDG.IPParameters=Prescaler,Reload
|
IWDG.IPParameters=Prescaler,Reload
|
||||||
|
@ -248,7 +248,7 @@ NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
NVIC.I2C1_ER_IRQn=true\:5\:0\:true\:true\:true\:7\:false\:true\:true
|
NVIC.I2C1_ER_IRQn=true\:5\:0\:true\:true\:true\:7\:false\:true\:true
|
||||||
NVIC.I2C1_EV_IRQn=true\:5\:0\:false\:true\:true\:6\:true\:true\:true
|
NVIC.I2C1_EV_IRQn=true\:5\:0\:false\:true\:true\:6\:true\:true\:true
|
||||||
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
||||||
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
|
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
|
||||||
NVIC.OTG_FS_IRQn=true\:5\:0\:false\:true\:true\:4\:true\:false\:true
|
NVIC.OTG_FS_IRQn=true\:5\:0\:false\:true\:true\:4\:true\:false\:true
|
||||||
NVIC.PVD_IRQn=true\:5\:0\:true\:true\:true\:1\:false\:true\:true
|
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
|
||||||
|
@ -594,7 +594,7 @@ ProjectManager.DeviceId=STM32F107VCTx
|
||||||
ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.3
|
ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.3
|
||||||
ProjectManager.FreePins=false
|
ProjectManager.FreePins=false
|
||||||
ProjectManager.HalAssertFull=false
|
ProjectManager.HalAssertFull=false
|
||||||
ProjectManager.HeapSize=0x400
|
ProjectManager.HeapSize=0x1f00
|
||||||
ProjectManager.KeepUserCode=true
|
ProjectManager.KeepUserCode=true
|
||||||
ProjectManager.LastFirmware=true
|
ProjectManager.LastFirmware=true
|
||||||
ProjectManager.LibraryCopy=1
|
ProjectManager.LibraryCopy=1
|
||||||
|
@ -605,28 +605,29 @@ ProjectManager.ProjectBuild=false
|
||||||
ProjectManager.ProjectFileName=NaviKit_EC_stm32.ioc
|
ProjectManager.ProjectFileName=NaviKit_EC_stm32.ioc
|
||||||
ProjectManager.ProjectName=NaviKit_EC_stm32
|
ProjectManager.ProjectName=NaviKit_EC_stm32
|
||||||
ProjectManager.RegisterCallBack=
|
ProjectManager.RegisterCallBack=
|
||||||
ProjectManager.StackSize=0x800
|
ProjectManager.StackSize=0x1f00
|
||||||
ProjectManager.TargetToolchain=STM32CubeIDE
|
ProjectManager.TargetToolchain=STM32CubeIDE
|
||||||
ProjectManager.ToolChainLocation=
|
ProjectManager.ToolChainLocation=
|
||||||
ProjectManager.UnderRoot=true
|
ProjectManager.UnderRoot=true
|
||||||
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-true,4-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,5-MX_I2C1_Init-I2C1-false-HAL-true,6-MX_IWDG_Init-IWDG-false-HAL-true,7-MX_UART4_Init-UART4-false-HAL-true,8-MX_ADC1_Init-ADC1-false-HAL-true,9-MX_USART1_UART_Init-USART1-false-HAL-true,10-MX_RTC_Init-RTC-false-HAL-true
|
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-SystemClock_Config-RCC-false-HAL-true,4-MX_USB_DEVICE_Init-USB_DEVICE-false-HAL-false,5-MX_I2C1_Init-I2C1-false-HAL-true,6-MX_IWDG_Init-IWDG-false-HAL-true,7-MX_UART4_Init-UART4-false-HAL-true,8-MX_ADC1_Init-ADC1-false-HAL-true,9-MX_USART1_UART_Init-USART1-false-HAL-true,10-MX_RTC_Init-RTC-false-HAL-true
|
||||||
RCC.ADCFreqValue=140625
|
RCC.ADCFreqValue=562500
|
||||||
RCC.ADCPresc=RCC_ADCPCLK2_DIV8
|
RCC.ADCPresc=RCC_ADCPCLK2_DIV8
|
||||||
RCC.AHBCLKDivider=RCC_SYSCLK_DIV4
|
RCC.AHBCLKDivider=RCC_SYSCLK_DIV4
|
||||||
RCC.AHBFreq_Value=18000000
|
RCC.AHBFreq_Value=18000000
|
||||||
RCC.APB1CLKDivider=RCC_HCLK_DIV16
|
RCC.APB1CLKDivider=RCC_HCLK_DIV4
|
||||||
RCC.APB1Freq_Value=1125000
|
RCC.APB1Freq_Value=4500000
|
||||||
RCC.APB1TimFreq_Value=2250000
|
RCC.APB1TimFreq_Value=9000000
|
||||||
RCC.APB2CLKDivider=RCC_HCLK_DIV16
|
RCC.APB2CLKDivider=RCC_HCLK_DIV4
|
||||||
RCC.APB2Freq_Value=1125000
|
RCC.APB2Freq_Value=4500000
|
||||||
RCC.APB2TimFreq_Value=2250000
|
RCC.APB2TimFreq_Value=9000000
|
||||||
|
RCC.EnbaleCSS=true
|
||||||
RCC.FCLKCortexFreq_Value=18000000
|
RCC.FCLKCortexFreq_Value=18000000
|
||||||
RCC.FamilyName=M
|
RCC.FamilyName=M
|
||||||
RCC.HCLKFreq_Value=18000000
|
RCC.HCLKFreq_Value=18000000
|
||||||
RCC.HSE_VALUE=12000000
|
RCC.HSE_VALUE=12000000
|
||||||
RCC.I2S2Freq_Value=72000000
|
RCC.I2S2Freq_Value=72000000
|
||||||
RCC.I2S3Freq_Value=72000000
|
RCC.I2S3Freq_Value=72000000
|
||||||
RCC.IPParameters=ADCFreqValue,ADCPresc,AHBCLKDivider,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,I2S2Freq_Value,I2S3Freq_Value,MCOFreq_Value,PLL2CLKoutputFreqValue,PLL2VCOoutputFreqValue,PLL3CLKoutputFreqValue,PLL3VCOoutputFreqValue,PLLCLKFreq_Value,PLLMUL,Prediv2,Prediv2FreqValue,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,TimSys_Div,USBFreq_Value,VCOOutput2Freq_Value
|
RCC.IPParameters=ADCFreqValue,ADCPresc,AHBCLKDivider,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2CLKDivider,APB2Freq_Value,APB2TimFreq_Value,EnbaleCSS,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,I2S2Freq_Value,I2S3Freq_Value,MCOFreq_Value,PLL2CLKoutputFreqValue,PLL2VCOoutputFreqValue,PLL3CLKoutputFreqValue,PLL3VCOoutputFreqValue,PLLCLKFreq_Value,PLLMUL,Prediv2,Prediv2FreqValue,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,TimSys_Div,USBFreq_Value,VCOOutput2Freq_Value
|
||||||
RCC.MCOFreq_Value=72000000
|
RCC.MCOFreq_Value=72000000
|
||||||
RCC.PLL2CLKoutputFreqValue=6000000
|
RCC.PLL2CLKoutputFreqValue=6000000
|
||||||
RCC.PLL2VCOoutputFreqValue=12000000
|
RCC.PLL2VCOoutputFreqValue=12000000
|
||||||
|
@ -666,11 +667,11 @@ SH.GPXTI7.0=GPIO_EXTI7
|
||||||
SH.GPXTI7.ConfNb=1
|
SH.GPXTI7.ConfNb=1
|
||||||
SH.GPXTI8.0=GPIO_EXTI8
|
SH.GPXTI8.0=GPIO_EXTI8
|
||||||
SH.GPXTI8.ConfNb=1
|
SH.GPXTI8.ConfNb=1
|
||||||
UART4.BaudRate=56000
|
UART4.BaudRate=115200
|
||||||
UART4.IPParameters=VirtualMode,BaudRate
|
UART4.IPParameters=VirtualMode,BaudRate
|
||||||
UART4.IPParametersWithoutCheck=BaudRate
|
UART4.IPParametersWithoutCheck=BaudRate
|
||||||
UART4.VirtualMode=Asynchronous
|
UART4.VirtualMode=Asynchronous
|
||||||
USART1.BaudRate=56000
|
USART1.BaudRate=115200
|
||||||
USART1.IPParameters=VirtualMode,WordLength,BaudRate
|
USART1.IPParameters=VirtualMode,WordLength,BaudRate
|
||||||
USART1.VirtualMode=VM_ASYNC
|
USART1.VirtualMode=VM_ASYNC
|
||||||
USART1.WordLength=WORDLENGTH_8B
|
USART1.WordLength=WORDLENGTH_8B
|
||||||
|
|
|
@ -0,0 +1,197 @@
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||||
|
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="File-List" href="Library_files/filelist.xml">
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="Edit-Time-Data" href="Library_files/editdata.mso"><!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><title>Release Notes for STM32Cube CPU Utilities Driver</title><!--[if gte mso 9]><xml> <o:DocumentProperties> <o:Author>STMicroelectronics</o:Author> <o:LastAuthor>STMicroelectronics</o:LastAuthor> <o:Revision>37</o:Revision> <o:TotalTime>136</o:TotalTime> <o:Created>2009-02-27T19:26:00Z</o:Created> <o:LastSaved>2009-03-01T17:56:00Z</o:LastSaved> <o:Pages>1</o:Pages> <o:Words>522</o:Words> <o:Characters>2977</o:Characters> <o:Company>STMicroelectronics</o:Company> <o:Lines>24</o:Lines> <o:Paragraphs>6</o:Paragraphs> <o:CharactersWithSpaces>3493</o:CharactersWithSpaces> <o:Version>11.6568</o:Version> </o:DocumentProperties> </xml><![endif]--><!--[if gte mso 9]><xml> <w:WordDocument> <w:Zoom>110</w:Zoom> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
<!--
|
||||||
|
/* Style Definitions */
|
||||||
|
p.MsoNormal, li.MsoNormal, div.MsoNormal
|
||||||
|
{mso-style-parent:"";
|
||||||
|
margin:0in;
|
||||||
|
margin-bottom:.0001pt;
|
||||||
|
mso-pagination:widow-orphan;
|
||||||
|
font-size:12.0pt;
|
||||||
|
font-family:"Times New Roman";
|
||||||
|
mso-fareast-font-family:"Times New Roman";}
|
||||||
|
h2
|
||||||
|
{mso-style-next:Normal;
|
||||||
|
margin-top:12.0pt;
|
||||||
|
margin-right:0in;
|
||||||
|
margin-bottom:3.0pt;
|
||||||
|
margin-left:0in;
|
||||||
|
mso-pagination:widow-orphan;
|
||||||
|
page-break-after:avoid;
|
||||||
|
mso-outline-level:2;
|
||||||
|
font-size:14.0pt;
|
||||||
|
font-family:Arial;
|
||||||
|
font-weight:bold;
|
||||||
|
font-style:italic;}
|
||||||
|
a:link, span.MsoHyperlink
|
||||||
|
{color:blue;
|
||||||
|
text-decoration:underline;
|
||||||
|
text-underline:single;}
|
||||||
|
a:visited, span.MsoHyperlinkFollowed
|
||||||
|
{color:blue;
|
||||||
|
text-decoration:underline;
|
||||||
|
text-underline:single;}
|
||||||
|
p
|
||||||
|
{mso-margin-top-alt:auto;
|
||||||
|
margin-right:0in;
|
||||||
|
mso-margin-bottom-alt:auto;
|
||||||
|
margin-left:0in;
|
||||||
|
mso-pagination:widow-orphan;
|
||||||
|
font-size:12.0pt;
|
||||||
|
font-family:"Times New Roman";
|
||||||
|
mso-fareast-font-family:"Times New Roman";}
|
||||||
|
@page Section1
|
||||||
|
{size:8.5in 11.0in;
|
||||||
|
margin:1.0in 1.25in 1.0in 1.25in;
|
||||||
|
mso-header-margin:.5in;
|
||||||
|
mso-footer-margin:.5in;
|
||||||
|
mso-paper-source:0;}
|
||||||
|
div.Section1
|
||||||
|
{page:Section1;}
|
||||||
|
-->
|
||||||
|
</style><!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]--><!--[if gte mso 9]><xml> <o:shapedefaults v:ext="edit" spidmax="5122"/> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext="edit"> <o:idmap v:ext="edit" data="1"/> </o:shapelayout></xml><![endif]-->
|
||||||
|
<meta content="MCD Application Team" name="author"></head><body link="blue" vlink="blue">
|
||||||
|
<div class="Section1">
|
||||||
|
<p class="MsoNormal"><span style="font-family: Arial;"><o:p><br>
|
||||||
|
</o:p></span></p>
|
||||||
|
<div align="center">
|
||||||
|
<table class="MsoNormalTable" style="width: 675pt;" border="0" cellpadding="0" cellspacing="0" width="900">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="padding: 0cm;" valign="top">
|
||||||
|
<table class="MsoNormalTable" style="width: 675pt;" border="0" cellpadding="0" cellspacing="0" width="900">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td style="vertical-align: top;">
|
||||||
|
<p class="MsoNormal"><span style="font-size: 8pt; font-family: Arial; color: blue;"><a href="../../Release_Notes.html">Back to Release page</a><o:p></o:p></span></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr style="">
|
||||||
|
<td style="padding: 1.5pt;">
|
||||||
|
<h1 style="margin-bottom: 18pt; text-align: center;" align="center"><span style="font-size: 20pt; font-family: Verdana; color: rgb(51, 102, 255);">Release
|
||||||
|
Notes for STM32Cube CPU Utilities Driver</span><span style="font-size: 20pt; font-family: Verdana;"><o:p></o:p></span></h1>
|
||||||
|
<p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;">Copyright
|
||||||
|
2014 STMicroelectronics</span><span style="color: black;"><u1:p></u1:p><o:p></o:p></span></p>
|
||||||
|
<p class="MsoNormal" style="text-align: center;" align="center"><span style="font-size: 10pt; font-family: Arial; color: black;"><img alt="" id="_x0000_i1025" src="../../_htmresc/st_logo.png" style="border: 0px solid ; width: 86px; height: 65px;"></span><span style="font-size: 10pt;"><o:p></o:p></span></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<p class="MsoNormal"><span style="font-family: Arial; display: none;"><o:p> </o:p></span></p>
|
||||||
|
<table class="MsoNormalTable" style="width: 675pt;" border="0" cellpadding="0" width="900">
|
||||||
|
<tbody>
|
||||||
|
<tr style="">
|
||||||
|
<td style="padding: 0cm;" valign="top">
|
||||||
|
<span style="font-family: "Times New Roman";"></span><h2 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><a name="History"></a><span style="font-size: 12pt; color: white;">Update History</span></h2>
|
||||||
|
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V1.1.0 / 20-November-2014 <o:p></o:p></span></h3>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
|
||||||
|
Changes<o:p></o:p></span></u></b></p>
|
||||||
|
|
||||||
|
|
||||||
|
<span style="font-size: 10pt; font-family: Verdana;"></span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<span style="font-size: 10pt; font-family: Verdana;"></span>
|
||||||
|
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;"><o:p></o:p></span></u></b></p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<ul style="list-style-type: square;">
|
||||||
|
<li><span style="font-size: 10pt; font-family: Verdana;">Update some APIs to be in line with FreeRTOS V8.1.2</span></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; margin-right: 500pt; width: 180px;"><span style="font-size: 10pt; font-family: Arial; color: white;">V1.0.0 / 18-February-2014 <o:p></o:p></span></h3>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;">Main
|
||||||
|
Changes<o:p></o:p></span></u></b></p>
|
||||||
|
|
||||||
|
<span style="font-size: 10pt; font-family: Verdana;"></span>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<span style="font-size: 10pt; font-family: Verdana;"></span><p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt;"><b style=""><u><span style="font-size: 10pt; font-family: Verdana; color: black;"><o:p></o:p></span></u></b></p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<ul style="list-style-type: square;">
|
||||||
|
<li><span style="font-size: 10pt; font-family: Verdana;">First official release</span><span style="font-size: 10pt; font-family: Verdana;"><br>
|
||||||
|
</span></li>
|
||||||
|
</ul><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"><span style="font-style: italic; font-weight: bold;"></span></span><span style="font-size: 10pt; font-family: Verdana;"></span><h2 style="background: rgb(51, 102, 255) none repeat scroll 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><a name="License"></a><span style="font-size: 12pt; color: white;">License<o:p></o:p></span><br></h2>
|
||||||
|
<div style="text-align: justify;"><font size="-1"><span style="font-family: "Verdana","sans-serif";">
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:</span><br>
|
||||||
|
</font>
|
||||||
|
<ol><li><font size="-1"><span style="font-family: "Verdana","sans-serif";">Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</span><span style="font-family: "Verdana","sans-serif";"></span></font></li><li><font size="-1"><span style="font-family: "Verdana","sans-serif";">Redistributions
|
||||||
|
in binary form must reproduce the above copyright notice, this list of
|
||||||
|
conditions and the following disclaimer in </span><span style="font-family: "Verdana","sans-serif";">the documentation and/or other materials provided with the distribution.</span><span style="font-family: "Verdana","sans-serif";"></span></font></li><li><font size="-1"><span style="font-family: "Verdana","sans-serif";">Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived </span><br>
|
||||||
|
</font>
|
||||||
|
</li></ol>
|
||||||
|
<font size="-1"><span style="font-family: "Verdana","sans-serif";"> from this software without specific prior written permission.</span><br>
|
||||||
|
<span style="font-family: "Verdana","sans-serif";"></span><br>
|
||||||
|
<span style="font-family: "Verdana","sans-serif";">THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED</span><span style="font-family: "Verdana","sans-serif";"> WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A </span><span style="font-family: "Verdana","sans-serif";">PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY </span><span style="font-family: "Verdana","sans-serif";">DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, </span><span style="font-family: "Verdana","sans-serif";">PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER</span><span style="font-family: "Verdana","sans-serif";"> CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR </span><span style="font-family: "Verdana","sans-serif";">OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span></font>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<p class="MsoNormal"><span style="font-size: 10pt; font-family: "Verdana","sans-serif"; color: black;"><o:p></o:p></span></p>
|
||||||
|
<b><span style="font-size: 10pt; font-family: Verdana; color: black;"></span></b>
|
||||||
|
|
||||||
|
<div class="MsoNormal" style="text-align: center;" align="center"><span style="color: black;">
|
||||||
|
<hr align="center" size="2" width="100%"></span></div>
|
||||||
|
<p class="MsoNormal" style="margin: 4.5pt 0cm 4.5pt 18pt; text-align: center;" align="center"><span style="font-size: 10pt; font-family: Verdana; color: black;">For
|
||||||
|
complete documentation on </span><span style="font-size: 10pt; font-family: Verdana;">STM32<span style="color: black;"> Microcontrollers
|
||||||
|
visit </span><u><span style="color: blue;"><a href="http://www.st.com/internet/mcu/class/1734.jsp" target="_blank">www.st.com/STM32</a></span></u></span><span style="font-size: 10pt; font-family: Verdana;"><a target="_blank" href="http://www.st.com/internet/mcu/family/141.jsp"><u><span style="color: blue;"></span></u></a></span><span style="font-size: 10pt; font-family: Verdana;"><u><span style="color: blue;"></span></u></span><span style="color: black;"><o:p></o:p></span></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<p class="MsoNormal"><span style="font-size: 10pt;"><o:p></o:p></span></p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<p class="MsoNormal"><o:p> </o:p></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body></html>
|
|
@ -0,0 +1,144 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file cpu_utils.c
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @version V1.1.0
|
||||||
|
* @date 20-November-2014
|
||||||
|
* @brief Utilities for CPU Load calculation
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/********************** NOTES **********************************************
|
||||||
|
To use this module, the following steps should be followed :
|
||||||
|
|
||||||
|
1- in the _OS_Config.h file (ex. FreeRTOSConfig.h) enable the following macros :
|
||||||
|
- #define configUSE_IDLE_HOOK 1
|
||||||
|
- #define configUSE_TICK_HOOK 1
|
||||||
|
|
||||||
|
2- in the _OS_Config.h define the following macros :
|
||||||
|
- #define traceTASK_SWITCHED_IN() extern void StartIdleMonitor(void); \
|
||||||
|
StartIdleMonitor()
|
||||||
|
- #define traceTASK_SWITCHED_OUT() extern void EndIdleMonitor(void); \
|
||||||
|
EndIdleMonitor()
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "cpu_utils.h"
|
||||||
|
|
||||||
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
|
/* Private define ------------------------------------------------------------*/
|
||||||
|
/* Private macro -------------------------------------------------------------*/
|
||||||
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
|
/* Private variables ---------------------------------------------------------*/
|
||||||
|
|
||||||
|
xTaskHandle xIdleHandle = NULL;
|
||||||
|
__IO uint32_t osCPU_Usage = 0;
|
||||||
|
uint32_t osCPU_IdleStartTime = 0;
|
||||||
|
uint32_t osCPU_IdleSpentTime = 0;
|
||||||
|
uint32_t osCPU_TotalIdleTime = 0;
|
||||||
|
|
||||||
|
/* Private functions ---------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* @brief Application Idle Hook
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void vApplicationIdleHook(void)
|
||||||
|
{
|
||||||
|
if( xIdleHandle == NULL )
|
||||||
|
{
|
||||||
|
/* Store the handle to the idle task. */
|
||||||
|
xIdleHandle = xTaskGetCurrentTaskHandle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Application Idle Hook
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void vApplicationTickHook (void)
|
||||||
|
{
|
||||||
|
static int tick = 0;
|
||||||
|
|
||||||
|
if(tick ++ > CALCULATION_PERIOD)
|
||||||
|
{
|
||||||
|
tick = 0;
|
||||||
|
|
||||||
|
if(osCPU_TotalIdleTime > 1000)
|
||||||
|
{
|
||||||
|
osCPU_TotalIdleTime = 1000;
|
||||||
|
}
|
||||||
|
osCPU_Usage = (100 - (osCPU_TotalIdleTime * 100) / CALCULATION_PERIOD);
|
||||||
|
osCPU_TotalIdleTime = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Start Idle monitor
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void StartIdleMonitor (void)
|
||||||
|
{
|
||||||
|
if( xTaskGetCurrentTaskHandle() == xIdleHandle )
|
||||||
|
{
|
||||||
|
osCPU_IdleStartTime = xTaskGetTickCountFromISR();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Stop Idle monitor
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
void EndIdleMonitor (void)
|
||||||
|
{
|
||||||
|
if( xTaskGetCurrentTaskHandle() == xIdleHandle )
|
||||||
|
{
|
||||||
|
/* Store the handle to the idle task. */
|
||||||
|
osCPU_IdleSpentTime = xTaskGetTickCountFromISR() - osCPU_IdleStartTime;
|
||||||
|
osCPU_TotalIdleTime += osCPU_IdleSpentTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Stop Idle monitor
|
||||||
|
* @param None
|
||||||
|
* @retval None
|
||||||
|
*/
|
||||||
|
uint16_t osGetCPUUsage (void)
|
||||||
|
{
|
||||||
|
return (uint16_t)osCPU_Usage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|
@ -0,0 +1,64 @@
|
||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
* @file cpu_utils.h
|
||||||
|
* @author MCD Application Team
|
||||||
|
* @version V1.1.0
|
||||||
|
* @date 20-November-2014
|
||||||
|
* @brief Header for cpu_utils module
|
||||||
|
******************************************************************************
|
||||||
|
* @attention
|
||||||
|
*
|
||||||
|
* <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||||
|
#ifndef _CPU_UTILS_H__
|
||||||
|
#define _CPU_UTILS_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Includes ------------------------------------------------------------------*/
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
/* Exported types ------------------------------------------------------------*/
|
||||||
|
/* Exported constants --------------------------------------------------------*/
|
||||||
|
/* Exported variables --------------------------------------------------------*/
|
||||||
|
/* Exported macro ------------------------------------------------------------*/
|
||||||
|
#define CALCULATION_PERIOD 1000
|
||||||
|
|
||||||
|
/* Exported functions ------------------------------------------------------- */
|
||||||
|
uint16_t osGetCPUUsage (void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _CPU_UTILS_H__ */
|
||||||
|
|
||||||
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
Loading…
Reference in New Issue