diff --git a/.cproject b/.cproject
index 7fde85f..218e6d7 100644
--- a/.cproject
+++ b/.cproject
@@ -4,7 +4,13 @@
-
+
+
+
+
+
+
+
@@ -25,7 +31,7 @@
-
+
@@ -36,15 +42,17 @@
+
+
-
+
+
+
@@ -124,22 +134,24 @@
-
+
-
+
+
+
@@ -185,10 +199,11 @@
-
+
+
+
-
diff --git a/.gitmodules b/.gitmodules
index 77fac7e..a6097c2 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "Middlewares/EasyLogger"]
path = Middlewares/EasyLogger
url = https://github.com/autolaborcenter/EasyLogger.git
+[submodule "Middlewares/Lab-Project-FreeRTOS-POSIX"]
+ path = Middlewares/Lab-Project-FreeRTOS-POSIX
+ url = https://github.com/autolaborcenter/Lab-Project-FreeRTOS-POSIX.git
diff --git a/.mxproject b/.mxproject
index c6e9ea5..3623cb9 100644
--- a/.mxproject
+++ b/.mxproject
@@ -9,46 +9,46 @@ CDefines=USE_HAL_DRIVER;STM32F107xC;USE_HAL_DRIVER;USE_HAL_DRIVER;
[PreviousGenFiles]
AdvancedFolderStructure=true
HeaderFileListSize=15
-HeaderFiles#0=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Inc/gpio.h
-HeaderFiles#1=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Inc/FreeRTOSConfig.h
-HeaderFiles#2=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Inc/adc.h
-HeaderFiles#3=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Inc/dma.h
-HeaderFiles#4=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Inc/i2c.h
-HeaderFiles#5=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Inc/iwdg.h
-HeaderFiles#6=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Inc/rtc.h
-HeaderFiles#7=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Inc/usart.h
-HeaderFiles#8=E:/source/STM32CubeIDE/NaviKit_stm32/USB_DEVICE/App/usb_device.h
-HeaderFiles#9=E:/source/STM32CubeIDE/NaviKit_stm32/USB_DEVICE/Target/usbd_conf.h
-HeaderFiles#10=E:/source/STM32CubeIDE/NaviKit_stm32/USB_DEVICE/App/usbd_desc.h
-HeaderFiles#11=E:/source/STM32CubeIDE/NaviKit_stm32/USB_DEVICE/App/usbd_cdc_if.h
-HeaderFiles#12=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Inc/stm32f1xx_it.h
-HeaderFiles#13=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Inc/stm32f1xx_hal_conf.h
-HeaderFiles#14=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Inc/main.h
+HeaderFiles#0=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Inc/gpio.h
+HeaderFiles#1=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Inc/FreeRTOSConfig.h
+HeaderFiles#2=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Inc/adc.h
+HeaderFiles#3=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Inc/dma.h
+HeaderFiles#4=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Inc/i2c.h
+HeaderFiles#5=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Inc/iwdg.h
+HeaderFiles#6=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Inc/rtc.h
+HeaderFiles#7=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Inc/usart.h
+HeaderFiles#8=E:/source/STM32CubeIDE/NaviKit_EC_stm32/USB_DEVICE/App/usb_device.h
+HeaderFiles#9=E:/source/STM32CubeIDE/NaviKit_EC_stm32/USB_DEVICE/Target/usbd_conf.h
+HeaderFiles#10=E:/source/STM32CubeIDE/NaviKit_EC_stm32/USB_DEVICE/App/usbd_desc.h
+HeaderFiles#11=E:/source/STM32CubeIDE/NaviKit_EC_stm32/USB_DEVICE/App/usbd_cdc_if.h
+HeaderFiles#12=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Inc/stm32f1xx_it.h
+HeaderFiles#13=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Inc/stm32f1xx_hal_conf.h
+HeaderFiles#14=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Inc/main.h
HeaderFolderListSize=3
-HeaderPath#0=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Inc
-HeaderPath#1=E:/source/STM32CubeIDE/NaviKit_stm32/USB_DEVICE/App
-HeaderPath#2=E:/source/STM32CubeIDE/NaviKit_stm32/USB_DEVICE/Target
+HeaderPath#0=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Inc
+HeaderPath#1=E:/source/STM32CubeIDE/NaviKit_EC_stm32/USB_DEVICE/App
+HeaderPath#2=E:/source/STM32CubeIDE/NaviKit_EC_stm32/USB_DEVICE/Target
HeaderFiles=;
SourceFileListSize=16
-SourceFiles#0=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Src/gpio.c
-SourceFiles#1=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Src/freertos.c
-SourceFiles#2=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Src/adc.c
-SourceFiles#3=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Src/dma.c
-SourceFiles#4=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Src/i2c.c
-SourceFiles#5=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Src/iwdg.c
-SourceFiles#6=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Src/rtc.c
-SourceFiles#7=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Src/usart.c
-SourceFiles#8=E:/source/STM32CubeIDE/NaviKit_stm32/USB_DEVICE/App/usb_device.c
-SourceFiles#9=E:/source/STM32CubeIDE/NaviKit_stm32/USB_DEVICE/Target/usbd_conf.c
-SourceFiles#10=E:/source/STM32CubeIDE/NaviKit_stm32/USB_DEVICE/App/usbd_desc.c
-SourceFiles#11=E:/source/STM32CubeIDE/NaviKit_stm32/USB_DEVICE/App/usbd_cdc_if.c
-SourceFiles#12=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Src/stm32f1xx_it.c
-SourceFiles#13=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Src/stm32f1xx_hal_msp.c
-SourceFiles#14=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Src/stm32f1xx_hal_timebase_tim.c
-SourceFiles#15=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Src/main.c
+SourceFiles#0=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Src/gpio.c
+SourceFiles#1=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Src/freertos.c
+SourceFiles#2=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Src/adc.c
+SourceFiles#3=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Src/dma.c
+SourceFiles#4=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Src/i2c.c
+SourceFiles#5=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Src/iwdg.c
+SourceFiles#6=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Src/rtc.c
+SourceFiles#7=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Src/usart.c
+SourceFiles#8=E:/source/STM32CubeIDE/NaviKit_EC_stm32/USB_DEVICE/App/usb_device.c
+SourceFiles#9=E:/source/STM32CubeIDE/NaviKit_EC_stm32/USB_DEVICE/Target/usbd_conf.c
+SourceFiles#10=E:/source/STM32CubeIDE/NaviKit_EC_stm32/USB_DEVICE/App/usbd_desc.c
+SourceFiles#11=E:/source/STM32CubeIDE/NaviKit_EC_stm32/USB_DEVICE/App/usbd_cdc_if.c
+SourceFiles#12=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Src/stm32f1xx_it.c
+SourceFiles#13=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Src/stm32f1xx_hal_msp.c
+SourceFiles#14=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Src/stm32f1xx_hal_timebase_tim.c
+SourceFiles#15=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Src/main.c
SourceFolderListSize=3
-SourcePath#0=E:/source/STM32CubeIDE/NaviKit_stm32/Core/Src
-SourcePath#1=E:/source/STM32CubeIDE/NaviKit_stm32/USB_DEVICE/App
-SourcePath#2=E:/source/STM32CubeIDE/NaviKit_stm32/USB_DEVICE/Target
+SourcePath#0=E:/source/STM32CubeIDE/NaviKit_EC_stm32/Core/Src
+SourcePath#1=E:/source/STM32CubeIDE/NaviKit_EC_stm32/USB_DEVICE/App
+SourcePath#2=E:/source/STM32CubeIDE/NaviKit_EC_stm32/USB_DEVICE/Target
SourceFiles=;
diff --git a/.settings/stm32cubeide.project.prefs b/.settings/stm32cubeide.project.prefs
index 6d54323..336601a 100644
--- a/.settings/stm32cubeide.project.prefs
+++ b/.settings/stm32cubeide.project.prefs
@@ -1,4 +1,4 @@
-2F62501ED4689FB349E356AB974DBE57=7721402F3CE8DC8D3A6A8AE537EFAC0B
-8DF89ED150041C4CBC7CB9A9CAA90856=7721402F3CE8DC8D3A6A8AE537EFAC0B
+2F62501ED4689FB349E356AB974DBE57=8E4D1FDC05ED3D447D65E8B3A57F2283
+8DF89ED150041C4CBC7CB9A9CAA90856=8E4D1FDC05ED3D447D65E8B3A57F2283
DC22A860405A8BF2F2C095E5B6529F12=02D9A7110C849E46466CD5CF8816F30D
eclipse.preferences.version=1
diff --git a/App/Inc/th_button.h b/App/Inc/th_button.h
index 55dce98..4c4f541 100644
--- a/App/Inc/th_button.h
+++ b/App/Inc/th_button.h
@@ -11,8 +11,8 @@
#include "cmsis_os2.h"
/* Definitions for ButtonDetect */
-osThreadId_t ButtonDetectHandle;
-const osThreadAttr_t ButtonDetect_attributes;
+osThreadId_t ButtonDetectTaskHandle;
+const osThreadAttr_t ButtonDetectTask_attributes;
//Timer
osTimerId_t PwrBtnLongPressTimerHandle;
@@ -28,7 +28,7 @@ osTimerId_t CustBtnShortPressTimerHandle;
const osTimerAttr_t CustBtnShortPressTimer_attributes;
-void StartButtonDetect(void *argument);
+void StartButtonDetectTask(void *argument);
//callback
void PwrBtnLongPressTimerCallback(void *argument);
diff --git a/App/Inc/th_elog.h b/App/Inc/th_elog.h
index 737f13d..23eb358 100644
--- a/App/Inc/th_elog.h
+++ b/App/Inc/th_elog.h
@@ -3,6 +3,10 @@
#include "cmsis_os2.h"
+osMutexId_t ElogUartMutexHandle;
+const osMutexAttr_t ElogUartMutex_attributes;
+
+osMutexId_t ElogOutputMutexHandle;
const osMutexAttr_t ElogOutputMutex_attributes;
osThreadId_t ElogInitTaskHandle;
diff --git a/App/Inc/th_iwdg.h b/App/Inc/th_iwdg.h
new file mode 100644
index 0000000..a9a5f2d
--- /dev/null
+++ b/App/Inc/th_iwdg.h
@@ -0,0 +1,12 @@
+#ifndef __TH_IWDG_H__
+#define __TH_IWDG_H__
+
+#include "cmsis_os2.h"
+
+osThreadId_t IWDGTaskHandle;
+
+const osThreadAttr_t IWDGTask_attributes;
+
+void StartIWDGTask(void *argument);
+
+#endif
diff --git a/App/Src/th_button.c b/App/Src/th_button.c
index bbcea02..8bb9a52 100644
--- a/App/Src/th_button.c
+++ b/App/Src/th_button.c
@@ -12,9 +12,9 @@
#include "navikit.h"
//Thread
-const osThreadAttr_t ButtonDetect_attributes = {
- .name = "ButtonDetect",
- .priority = (osPriority_t) osPriorityLow,
+const osThreadAttr_t ButtonDetectTask_attributes = {
+ .name = "ButtonDetectTask",
+ .priority = (osPriority_t) osPriorityBelowNormal,
.stack_size = 128 * 4
};
@@ -41,7 +41,7 @@ const osTimerAttr_t CustBtnShortPressTimer_attributes = {
* @retval None
*/
/* USER CODE END Header_StartButtonDetect */
-void StartButtonDetect(void *argument)
+void StartButtonDetectTask(void *argument)
{
/* USER CODE BEGIN StartButtonDetect */
/* Infinite loop */
diff --git a/App/Src/th_coulomb.c b/App/Src/th_coulomb.c
index 9f331df..aaf8867 100644
--- a/App/Src/th_coulomb.c
+++ b/App/Src/th_coulomb.c
@@ -16,7 +16,7 @@
/* Definitions for CoulombRead */
const osThreadAttr_t CoulombRead_attributes = {
.name = "CoulombRead",
- .priority = (osPriority_t) osPriorityLow,
+ .priority = (osPriority_t) osPriorityBelowNormal,
.stack_size = 128 * 4
};
diff --git a/App/Src/th_demo.c b/App/Src/th_demo.c
index c61edb3..00f5823 100644
--- a/App/Src/th_demo.c
+++ b/App/Src/th_demo.c
@@ -1,3 +1,10 @@
+/*
+ * @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-Demo"
#include
@@ -6,20 +13,20 @@
const osThreadAttr_t DemoTask1_attributes = {
.name = "DemoTask1",
- .priority = (osPriority_t) osPriorityNormal,
- .stack_size = 128 * 4
+ .priority = (osPriority_t) osPriorityLow2,
+ .stack_size = 128 * 8
};
const osThreadAttr_t DemoTask2_attributes = {
.name = "DemoTask2",
- .priority = (osPriority_t) osPriorityBelowNormal,
- .stack_size = 128 * 4
+ .priority = (osPriority_t) osPriorityLow1,
+ .stack_size = 128 * 8
};
void StartDemoTask1(void *argument){
uint8_t i=0;
log_v("Start Demo Task1");
for(;;){
log_v("demo task 1 [%d].",i++);
- osDelay(1000);
+ osDelay(100);
}
}
void StartDemoTask2(void *argument){
@@ -27,6 +34,6 @@ void StartDemoTask2(void *argument){
log_v("Start Demo Task2");
for(;;){
log_v("demo task 2 [%d].",i++);
- osDelay(1000);
+ osDelay(100);
}
}
diff --git a/App/Src/th_elog.c b/App/Src/th_elog.c
index 24e3b72..3710f1f 100644
--- a/App/Src/th_elog.c
+++ b/App/Src/th_elog.c
@@ -2,7 +2,7 @@
* @Description:
* @Date: 2021-03-09 11:30:52
* @LastEditors: CK.Zh
- * @LastEditTime: 2021-03-10 10:59:15
+ * @LastEditTime: 2021-03-10 14:46:32
* @FilePath: \NaviKit_EC_stm32\App\Src\th_elog.c
*/
@@ -11,20 +11,23 @@
#include
#include "main.h"
+const osMutexAttr_t ElogUartMutex_attributes = {
+ .name = "ElogUartMutex"
+};
const osMutexAttr_t ElogOutputMutex_attributes = {
.name = "ElogOutputMutex"
};
const osThreadAttr_t ElogInitTask_attributes = {
.name = "ElogInitTask",
- .priority = (osPriority_t) osPriorityBelowNormal,
+ .priority = (osPriority_t) osPriorityNormal,
.stack_size = 128 * 4
};
const osThreadAttr_t ElogFlushTask_attributes = {
.name = "ElogFlushTask",
.priority = (osPriority_t) osPriorityLow,
- .stack_size = 128 * 4
+ .stack_size = 128 * 8
};
void StartElogInitTask(void *argument){
@@ -36,10 +39,11 @@ void StartElogInitTask(void *argument){
void StartElogFlushTask(void *argument){
+ uint8_t i=0;
log_v("Start Elog Flush Task");
for(;;){
elog_flush();
- osDelay(5);
+ osDelay(1);
}
}
@@ -67,6 +71,9 @@ void my_elog_init(){
/* 详细:输出除了方法名之外的所有内容 */
elog_set_fmt(ELOG_LVL_VERBOSE, ELOG_FMT_SETTING);
+ // enable text color (dynamic)
+ elog_set_text_color_enabled(true);
+
/* start EasyLogger */
elog_start();
}
diff --git a/App/Src/th_iwdg.c b/App/Src/th_iwdg.c
new file mode 100644
index 0000000..e139427
--- /dev/null
+++ b/App/Src/th_iwdg.c
@@ -0,0 +1,28 @@
+/*
+ * @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-IWDG"
+
+#include
+#include "main.h"
+#include "iwdg.h"
+
+
+const osThreadAttr_t IWDGTask_attributes = {
+ .name = "IWDGTask",
+ .priority = (osPriority_t) osPriorityHigh,
+ .stack_size = 128 * 4
+};
+
+void StartIWDGTask(void *argument){
+ log_v("Start IWDG Task");
+ for(;;){
+ HAL_IWDG_Refresh(&hiwdg);
+ osDelay(1000);
+ }
+}
+
diff --git a/App/Src/th_led.c b/App/Src/th_led.c
index f734450..07cf763 100644
--- a/App/Src/th_led.c
+++ b/App/Src/th_led.c
@@ -13,8 +13,8 @@
const osThreadAttr_t LedBlinkTask_attributes = {
.name = "LedBlinkTask",
- .priority = (osPriority_t) osPriorityLow,
- .stack_size = 128 * 4
+ .priority = (osPriority_t) osPriorityBelowNormal,
+ .stack_size = 128 * 8
};
/* USER CODE BEGIN Header_StartLedBlinkTask */
diff --git a/App/Src/th_power.c b/App/Src/th_power.c
index 034f266..a02d238 100644
--- a/App/Src/th_power.c
+++ b/App/Src/th_power.c
@@ -14,7 +14,7 @@
const osThreadAttr_t PowerMonitTask_attributes = {
.name = "PowerMonitTask",
- .priority = (osPriority_t) osPriorityLow,
+ .priority = (osPriority_t) osPriorityBelowNormal,
.stack_size = 128 * 4
};
diff --git a/Core/Inc/stm32f1xx_it.h b/Core/Inc/stm32f1xx_it.h
index 5d71e1a..c6d5a7a 100644
--- a/Core/Inc/stm32f1xx_it.h
+++ b/Core/Inc/stm32f1xx_it.h
@@ -61,6 +61,8 @@ void EXTI0_IRQHandler(void);
void EXTI3_IRQHandler(void);
void EXTI4_IRQHandler(void);
void DMA1_Channel1_IRQHandler(void);
+void DMA1_Channel4_IRQHandler(void);
+void DMA1_Channel5_IRQHandler(void);
void ADC1_2_IRQHandler(void);
void EXTI9_5_IRQHandler(void);
void TIM1_UP_IRQHandler(void);
@@ -69,6 +71,8 @@ void I2C1_ER_IRQHandler(void);
void USART1_IRQHandler(void);
void RTC_Alarm_IRQHandler(void);
void UART4_IRQHandler(void);
+void DMA2_Channel3_IRQHandler(void);
+void DMA2_Channel5_IRQHandler(void);
void OTG_FS_IRQHandler(void);
/* USER CODE BEGIN EFP */
diff --git a/Core/Inc/usart.h b/Core/Inc/usart.h
index 6b11bb4..a3e9db5 100644
--- a/Core/Inc/usart.h
+++ b/Core/Inc/usart.h
@@ -29,8 +29,6 @@ extern "C" {
/* USER CODE BEGIN Includes */
-#include
-#include
/* USER CODE END Includes */
extern UART_HandleTypeDef huart4;
@@ -45,7 +43,6 @@ void MX_USART1_UART_Init(void);
/* USER CODE BEGIN Prototypes */
-void UartPrint(char * format,...);
/* USER CODE END Prototypes */
#ifdef __cplusplus
diff --git a/Core/Src/adc.c b/Core/Src/adc.c
index 354009e..0ca5b8f 100644
--- a/Core/Src/adc.c
+++ b/Core/Src/adc.c
@@ -33,9 +33,17 @@ DMA_HandleTypeDef hdma_adc1;
/* ADC1 init function */
void MX_ADC1_Init(void)
{
+
+ /* USER CODE BEGIN ADC1_Init 0 */
+
+ /* USER CODE END ADC1_Init 0 */
+
ADC_AnalogWDGConfTypeDef AnalogWDGConfig = {0};
ADC_ChannelConfTypeDef sConfig = {0};
+ /* USER CODE BEGIN ADC1_Init 1 */
+
+ /* USER CODE END ADC1_Init 1 */
/** Common config
*/
hadc1.Instance = ADC1;
@@ -117,6 +125,9 @@ void MX_ADC1_Init(void)
{
Error_Handler();
}
+ /* USER CODE BEGIN ADC1_Init 2 */
+
+ /* USER CODE END ADC1_Init 2 */
}
diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c
index bbdafa2..b9488ee 100644
--- a/Core/Src/freertos.c
+++ b/Core/Src/freertos.c
@@ -38,6 +38,7 @@
#include
#include
#include
+#include
/* USER CODE END Includes */
@@ -70,7 +71,7 @@ const osTimerAttr_t IdleStateHoldTimer_attributes = {
osThreadId_t defaultTaskHandle;
const osThreadAttr_t defaultTask_attributes = {
.name = "defaultTask",
- .stack_size = 128 * 4,
+ .stack_size = 128 * 8,
.priority = (osPriority_t) osPriorityNormal,
};
@@ -81,6 +82,7 @@ void IdleStateHoldTimerCallback(void *argument);
bool isWakeUpFromReset() { return __HAL_PWR_GET_FLAG(PWR_FLAG_WU);}
+//__HAL_RCC_GET_FLAG(); //判断复位源
/* USER CODE END FunctionPrototypes */
@@ -167,6 +169,7 @@ void MX_FREERTOS_Init(void) {
/* USER CODE BEGIN Init */
ElogOutputMutexHandle = osMutexNew(&ElogOutputMutex_attributes);
+// ElogUartMutexHandle = osMutexNew(&ElogUartMutex_attributes);
my_elog_init();
NaviKit_var_init();
/* USER CODE END Init */
@@ -202,22 +205,23 @@ void MX_FREERTOS_Init(void) {
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
-
+ //IWDG--------------------------------------------
+ IWDGTaskHandle = osThreadNew(StartIWDGTask, NULL, &IWDGTask_attributes);
//Power--------------------------------------------
// PowerMonitTaskHandle = osThreadNew(StartPowerMonitTask, NULL, &PowerMonitTask_attributes);
//Button--------------------------------------------
-// ButtonDetectHandle = osThreadNew(StartButtonDetect, NULL, &ButtonDetect_attributes);
+ ButtonDetectTaskHandle = osThreadNew(StartButtonDetectTask, NULL, &ButtonDetectTask_attributes);
//LED--------------------------------------------
-// LedBlinkTaskHandle = osThreadNew(StartLedBlinkTask, NULL, &LedBlinkTask_attributes);
+ LedBlinkTaskHandle = osThreadNew(StartLedBlinkTask, NULL, &LedBlinkTask_attributes);
//CDC--------------------------------------------
-// cdcMonitorTaskHandle = osThreadNew(StartCdcMonitorTask, NULL, &cdcMonitorTask_attributes);
+ cdcMonitorTaskHandle = osThreadNew(StartCdcMonitorTask, NULL, &cdcMonitorTask_attributes);
//Coulomb--------------------------------------------
@@ -230,10 +234,9 @@ void MX_FREERTOS_Init(void) {
ElogFlushTaskHandle = osThreadNew(StartElogFlushTask, NULL, &ElogFlushTask_attributes);
#endif
-
//Demo--------------------------------------------
-// DemoTask1Handle = osThreadNew(StartDemoTask1, NULL, &DemoTask1_attributes);
-// DemoTask2Handle = osThreadNew(StartDemoTask2, NULL, &DemoTask2_attributes);
+ DemoTask1Handle = osThreadNew(StartDemoTask1, NULL, &DemoTask1_attributes);
+ DemoTask2Handle = osThreadNew(StartDemoTask2, NULL, &DemoTask2_attributes);
/* USER CODE END RTOS_THREADS */
@@ -290,17 +293,17 @@ osVersion_t osVersion;
// TaskBeep(50,1);
}
- log_i("----------------------------------------------");
- log_i("Copyright (c) Powered by www.autolabor.com.cn");
- #ifdef DEBUG
- log_i("EC Firmware: %s[DEBUG], build: %s, %s",APP_VERSION,__DATE__ ,__TIME__);
- #else
- log_i("EC Firmware: %s[RELEASE], build: %s, %s",APP_VERSION,__DATE__ ,__TIME__);
- #endif
- log_i("HAL Version: 0x%X ", HAL_GetHalVersion());
- log_i("Revision ID: 0x%X ", HAL_GetREVID());
- log_i("Device ID: 0x%X ", HAL_GetDEVID());
- log_i("Chip UID: 0x%X%X%X ", HAL_GetUIDw0(),HAL_GetUIDw1(),HAL_GetUIDw2());
+ log_i("----------------------------------------------");
+ log_i("Copyright (c) Powered by www.autolabor.com.cn");
+#ifdef DEBUG
+ log_i("EC Firmware: %s[DEBUG], build: %s, %s",APP_VERSION,__DATE__ ,__TIME__);
+#else
+ log_i("EC Firmware: %s[RELEASE], build: %s, %s",APP_VERSION,__DATE__ ,__TIME__);
+#endif
+ log_i("HAL Version: 0x%X ", HAL_GetHalVersion());
+ log_i("Revision ID: 0x%X ", HAL_GetREVID());
+ log_i("Device ID: 0x%X ", HAL_GetDEVID());
+ log_i("Chip UID: 0x%X%X%X ", HAL_GetUIDw0(),HAL_GetUIDw1(),HAL_GetUIDw2());
if(osOK == osKernelGetInfo(&osVersion,id_buf,id_size)){
log_i("OS Kernel Version: %u ", osVersion.kernel);
@@ -311,12 +314,10 @@ osVersion_t osVersion;
log_i("Log Library Version: V%s",ELOG_SW_VERSION);
log_i("Core initial successfully");
- log_i("----------------------------------------------");
/* Infinite loop */
for(;;)
{
-// HAL_IWDG_Refresh(&hiwdg);
osDelay(20);
if(NaviKit.sys.sta != NaviKit.sys.next_sta){
switch(NaviKit.sys.next_sta){
@@ -367,7 +368,7 @@ osVersion_t osVersion;
// }
if(!osTimerIsRunning(IdleStateHoldTimerHandle)){
- osTimerStart(IdleStateHoldTimerHandle,5000);
+// osTimerStart(IdleStateHoldTimerHandle,5000);
}
}
diff --git a/Core/Src/i2c.c b/Core/Src/i2c.c
index 7c0ac4d..5f7b5be 100644
--- a/Core/Src/i2c.c
+++ b/Core/Src/i2c.c
@@ -51,6 +51,13 @@ I2C_HandleTypeDef hi2c1;
void MX_I2C1_Init(void)
{
+ /* USER CODE BEGIN I2C1_Init 0 */
+
+ /* USER CODE END I2C1_Init 0 */
+
+ /* USER CODE BEGIN I2C1_Init 1 */
+
+ /* USER CODE END I2C1_Init 1 */
hi2c1.Instance = I2C1;
hi2c1.Init.ClockSpeed = 100000;
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
@@ -64,6 +71,9 @@ void MX_I2C1_Init(void)
{
Error_Handler();
}
+ /* USER CODE BEGIN I2C1_Init 2 */
+
+ /* USER CODE END I2C1_Init 2 */
}
diff --git a/Core/Src/iwdg.c b/Core/Src/iwdg.c
index 300a78b..fed358e 100644
--- a/Core/Src/iwdg.c
+++ b/Core/Src/iwdg.c
@@ -30,6 +30,13 @@ IWDG_HandleTypeDef hiwdg;
void MX_IWDG_Init(void)
{
+ /* USER CODE BEGIN IWDG_Init 0 */
+
+ /* USER CODE END IWDG_Init 0 */
+
+ /* USER CODE BEGIN IWDG_Init 1 */
+
+ /* USER CODE END IWDG_Init 1 */
hiwdg.Instance = IWDG;
hiwdg.Init.Prescaler = IWDG_PRESCALER_16;
hiwdg.Init.Reload = 0xfff;
@@ -37,6 +44,9 @@ void MX_IWDG_Init(void)
{
Error_Handler();
}
+ /* USER CODE BEGIN IWDG_Init 2 */
+
+ /* USER CODE END IWDG_Init 2 */
}
diff --git a/Core/Src/main.c b/Core/Src/main.c
index e2b0e1b..bc9f09a 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -96,17 +96,27 @@ int main(void)
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
-// MX_I2C1_Init();
-// MX_IWDG_Init();
-// MX_UART4_Init();
+ MX_I2C1_Init();
+ MX_IWDG_Init();
+ MX_UART4_Init();
MX_ADC1_Init();
MX_USART1_UART_Init();
-// MX_RTC_Init();
+ MX_RTC_Init();
/* Initialize interrupts */
MX_NVIC_Init();
/* USER CODE BEGIN 2 */
+ //print log before kernel start
+// uint8_t log_head[]="Autolabor EC Booting...\r\n";
+// HAL_UART_Transmit_DMA(&huart1, log_head, sizeof(log_head));
+ if( hiwdg.Instance->SR & IWDG_KEY_ENABLE){
+ uint8_t log_head[]="iwdg enable\r\n";
+ HAL_UART_Transmit_DMA(&huart1, log_head, sizeof(log_head));
+ }else{
+ uint8_t log_head[]="iwdg disable\r\n";
+ HAL_UART_Transmit_DMA(&huart1, log_head, sizeof(log_head));
+ }
/* USER CODE END 2 */
/* Init scheduler */
@@ -235,6 +245,18 @@ static void MX_NVIC_Init(void)
/* EXTI4_IRQn interrupt configuration */
HAL_NVIC_SetPriority(EXTI4_IRQn, 5, 0);
HAL_NVIC_EnableIRQ(EXTI4_IRQn);
+ /* DMA1_Channel4_IRQn interrupt configuration */
+ HAL_NVIC_SetPriority(DMA1_Channel4_IRQn, 5, 0);
+ HAL_NVIC_EnableIRQ(DMA1_Channel4_IRQn);
+ /* DMA1_Channel5_IRQn interrupt configuration */
+ HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 5, 0);
+ HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
+ /* DMA2_Channel3_IRQn interrupt configuration */
+ HAL_NVIC_SetPriority(DMA2_Channel3_IRQn, 5, 0);
+ HAL_NVIC_EnableIRQ(DMA2_Channel3_IRQn);
+ /* DMA2_Channel5_IRQn interrupt configuration */
+ HAL_NVIC_SetPriority(DMA2_Channel5_IRQn, 5, 0);
+ HAL_NVIC_EnableIRQ(DMA2_Channel5_IRQn);
}
/* USER CODE BEGIN 4 */
diff --git a/Core/Src/navikit.c b/Core/Src/navikit.c
index c3fe894..46cac33 100644
--- a/Core/Src/navikit.c
+++ b/Core/Src/navikit.c
@@ -102,6 +102,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
void enter_standby_state(){
log_i("EC enter to STANDBY Mode to save power, see you!");
+ osDelay(10);
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1);//Enable PA0 wakeup function
__HAL_RCC_RTC_DISABLE();
HAL_PWR_EnterSTANDBYMode();
diff --git a/Core/Src/rtc.c b/Core/Src/rtc.c
index b21a246..6ee003a 100644
--- a/Core/Src/rtc.c
+++ b/Core/Src/rtc.c
@@ -30,6 +30,13 @@ RTC_HandleTypeDef hrtc;
void MX_RTC_Init(void)
{
+ /* USER CODE BEGIN RTC_Init 0 */
+
+ /* USER CODE END RTC_Init 0 */
+
+ /* USER CODE BEGIN RTC_Init 1 */
+
+ /* USER CODE END RTC_Init 1 */
/** Initialize RTC Only
*/
hrtc.Instance = RTC;
@@ -39,6 +46,9 @@ void MX_RTC_Init(void)
{
Error_Handler();
}
+ /* USER CODE BEGIN RTC_Init 2 */
+
+ /* USER CODE END RTC_Init 2 */
}
diff --git a/Middlewares/Lab-Project-FreeRTOS-POSIX b/Middlewares/Lab-Project-FreeRTOS-POSIX
new file mode 160000
index 0000000..0c6cec9
--- /dev/null
+++ b/Middlewares/Lab-Project-FreeRTOS-POSIX
@@ -0,0 +1 @@
+Subproject commit 0c6cec978cd8163c8640c7c157cccba457dedabc
diff --git a/NaviKit_EC_stm32 Debug.launch b/NaviKit_EC_stm32 Debug.launch
index 9d649b7..2124351 100644
--- a/NaviKit_EC_stm32 Debug.launch
+++ b/NaviKit_EC_stm32 Debug.launch
@@ -70,4 +70,5 @@
+
diff --git a/NaviKit_EC_stm32 Release.launch b/NaviKit_EC_stm32 Release.launch
index 519b745..1dec609 100644
--- a/NaviKit_EC_stm32 Release.launch
+++ b/NaviKit_EC_stm32 Release.launch
@@ -36,6 +36,7 @@
+
@@ -67,5 +68,6 @@
+
diff --git a/NaviKit_EC_stm32.ioc b/NaviKit_EC_stm32.ioc
index 91d1368..8e24c9e 100644
--- a/NaviKit_EC_stm32.ioc
+++ b/NaviKit_EC_stm32.ioc
@@ -64,7 +64,47 @@ Dma.ADC1.0.PeriphInc=DMA_PINC_DISABLE
Dma.ADC1.0.Priority=DMA_PRIORITY_LOW
Dma.ADC1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
Dma.Request0=ADC1
-Dma.RequestsNb=1
+Dma.Request1=USART1_TX
+Dma.Request2=USART1_RX
+Dma.Request3=UART4_RX
+Dma.Request4=UART4_TX
+Dma.RequestsNb=5
+Dma.UART4_RX.3.Direction=DMA_PERIPH_TO_MEMORY
+Dma.UART4_RX.3.Instance=DMA2_Channel3
+Dma.UART4_RX.3.MemDataAlignment=DMA_MDATAALIGN_BYTE
+Dma.UART4_RX.3.MemInc=DMA_MINC_ENABLE
+Dma.UART4_RX.3.Mode=DMA_NORMAL
+Dma.UART4_RX.3.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
+Dma.UART4_RX.3.PeriphInc=DMA_PINC_DISABLE
+Dma.UART4_RX.3.Priority=DMA_PRIORITY_LOW
+Dma.UART4_RX.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
+Dma.UART4_TX.4.Direction=DMA_MEMORY_TO_PERIPH
+Dma.UART4_TX.4.Instance=DMA2_Channel5
+Dma.UART4_TX.4.MemDataAlignment=DMA_MDATAALIGN_BYTE
+Dma.UART4_TX.4.MemInc=DMA_MINC_ENABLE
+Dma.UART4_TX.4.Mode=DMA_NORMAL
+Dma.UART4_TX.4.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
+Dma.UART4_TX.4.PeriphInc=DMA_PINC_DISABLE
+Dma.UART4_TX.4.Priority=DMA_PRIORITY_LOW
+Dma.UART4_TX.4.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
+Dma.USART1_RX.2.Direction=DMA_PERIPH_TO_MEMORY
+Dma.USART1_RX.2.Instance=DMA1_Channel5
+Dma.USART1_RX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE
+Dma.USART1_RX.2.MemInc=DMA_MINC_ENABLE
+Dma.USART1_RX.2.Mode=DMA_NORMAL
+Dma.USART1_RX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
+Dma.USART1_RX.2.PeriphInc=DMA_PINC_DISABLE
+Dma.USART1_RX.2.Priority=DMA_PRIORITY_LOW
+Dma.USART1_RX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
+Dma.USART1_TX.1.Direction=DMA_MEMORY_TO_PERIPH
+Dma.USART1_TX.1.Instance=DMA1_Channel4
+Dma.USART1_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE
+Dma.USART1_TX.1.MemInc=DMA_MINC_ENABLE
+Dma.USART1_TX.1.Mode=DMA_NORMAL
+Dma.USART1_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
+Dma.USART1_TX.1.PeriphInc=DMA_PINC_DISABLE
+Dma.USART1_TX.1.Priority=DMA_PRIORITY_LOW
+Dma.USART1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
FREERTOS.FootprintOK=true
FREERTOS.HEAP_NUMBER=4
FREERTOS.INCLUDE_pcTaskGetTaskName=1
@@ -193,6 +233,10 @@ MxDb.Version=DB.6.0.20
NVIC.ADC1_2_IRQn=true\:5\:0\:false\:true\:true\:8\:true\:true\:true
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.DMA1_Channel1_IRQn=true\:5\:0\:false\:true\:true\:9\:true\:false\:true
+NVIC.DMA1_Channel4_IRQn=true\:5\:0\:false\:true\:true\:17\:true\:false\:true
+NVIC.DMA1_Channel5_IRQn=true\:5\:0\:false\:true\:true\:18\:true\:false\:true
+NVIC.DMA2_Channel3_IRQn=true\:5\:0\:false\:true\:true\:19\:true\:false\:true
+NVIC.DMA2_Channel5_IRQn=true\:5\:0\:false\:true\:true\:20\:true\:false\:true
NVIC.DebugMonitor_IRQn=true\:0\:0\:true\:false\:true\:false\:false\:false
NVIC.EXTI0_IRQn=true\:5\:0\:false\:true\:true\:11\:true\:true\:true
NVIC.EXTI3_IRQn=true\:5\:0\:false\:true\:true\:12\:true\:true\:true
@@ -652,4 +696,4 @@ VP_SYS_VS_tim1.Signal=SYS_VS_tim1
VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Mode=CDC_FS
VP_USB_DEVICE_VS_USB_DEVICE_CDC_FS.Signal=USB_DEVICE_VS_USB_DEVICE_CDC_FS
board=custom
-isbadioc=true
+isbadioc=false
diff --git a/README.md b/README.md
index d198825..ae0bcbd 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
* @Author: CK.Zh
* @Date: 2020-02-20 11:39:38
* @LastEditors: CK.Zh
- * @LastEditTime: 2021-03-10 11:40:42
+ * @LastEditTime: 2021-03-10 13:48:33
-->
# NaviKit_stm32
PM1导航套件中电源控制板源码,STM32F107VCT6,开发环境STM32CubeIDE
@@ -32,12 +32,17 @@
函数`void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd)`
代码段`HAL_PCD_SuspendCallback(hpcd); ` 务必屏蔽,否则导致枚举失败,提示获取设备描述符失败。
- > EC日志输出口波特率为56000bps
+
# 维护指南
* 为提高可移植性、可维护性、可阅读性,开发(应用层)时尽量使用`CMSIS_OS2`的抽象接口,特殊情况时再考虑使用RTOS的原生接口
-* 线程任务实例及属性、句柄的声明及定义,独立存放在`App`文件夹
+* `freertos.c`中的任务实体只保留默认任务, 其他线程任务实例、属性、句柄的声明及定义,独立存放在`App`文件夹
* 线程、定时器、事件标志、互斥锁、信号量、消息队列等功能的初始化统一在`freertos.c`文件中进行初始化(内核启动前的预装载)
-* `freertos.c`中的任务实体只保留默认任务即可
+
+# 日志接口
+
+* 串口输出口波特率为56000bps
+* 日志输出支持`CSI`颜色模式
+
# 勘误
硬件的v1.0以前版本中,SYS_RESET脚和MOD_SLEEP到单片机的实际连接与网络标号是相反的(问题发生在TXB0108PWR芯片附近),故代码中在GPIO处进行了相反的设置。
\ No newline at end of file
diff --git a/STM32F107VCTX_FLASH.ld b/STM32F107VCTX_FLASH.ld
index 37b3bc0..d99bf74 100644
--- a/STM32F107VCTX_FLASH.ld
+++ b/STM32F107VCTX_FLASH.ld
@@ -55,8 +55,8 @@ ENTRY(Reset_Handler)
/* Highest address of the user mode stack */
_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */
-_Min_Heap_Size = 0x400 ; /* required amount of heap */
-_Min_Stack_Size = 0x800 ; /* required amount of stack */
+_Min_Heap_Size = 0x1f00 ; /* required amount of heap */
+_Min_Stack_Size = 0x1f00 ; /* required amount of stack */
/* Memories definition */
MEMORY
diff --git a/USB_DEVICE/Target/usbd_conf.c b/USB_DEVICE/Target/usbd_conf.c
index 1b8c255..1a16390 100644
--- a/USB_DEVICE/Target/usbd_conf.c
+++ b/USB_DEVICE/Target/usbd_conf.c
@@ -301,6 +301,7 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)
hpcd_USB_OTG_FS.Instance = USB_OTG_FS;
hpcd_USB_OTG_FS.Init.dev_endpoints = 4;
hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL;
+ hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE;
hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE;
hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE;
diff --git a/USB_DEVICE/Target/usbd_conf.h b/USB_DEVICE/Target/usbd_conf.h
index c84489b..e6fc6f8 100644
--- a/USB_DEVICE/Target/usbd_conf.h
+++ b/USB_DEVICE/Target/usbd_conf.h
@@ -1,10 +1,3 @@
-/*
- * @Description:
- * @Date: 2020-02-20 11:58:24
- * @LastEditors: CK.Zh
- * @LastEditTime: 2021-03-09 18:32:44
- * @FilePath: \NaviKit_EC_stm32\USB_DEVICE\Target\usbd_conf.h
- */
/* USER CODE BEGIN Header */
/**
******************************************************************************
@@ -76,7 +69,7 @@
/*---------- -----------*/
#define USBD_MAX_STR_DESC_SIZ 512
/*---------- -----------*/
-#define USBD_DEBUG_LEVEL 0
+#define USBD_DEBUG_LEVEL 3
/*---------- -----------*/
#define USBD_SELF_POWERED 1
/*---------- -----------*/