diff --git a/.cproject b/.cproject
index aae7d45..201a804 100644
--- a/.cproject
+++ b/.cproject
@@ -25,6 +25,8 @@
+
+
@@ -101,6 +103,7 @@
+
@@ -197,6 +200,7 @@
+
diff --git a/Core/Inc/stm32f4xx_it.h b/Core/Inc/stm32f4xx_it.h
index ef124d1..833ede9 100644
--- a/Core/Inc/stm32f4xx_it.h
+++ b/Core/Inc/stm32f4xx_it.h
@@ -52,7 +52,10 @@ void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void DebugMon_Handler(void);
+void TIM1_UP_TIM10_IRQHandler(void);
void TIM1_TRG_COM_TIM11_IRQHandler(void);
+void TIM6_DAC_IRQHandler(void);
+void TIM7_IRQHandler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */
diff --git a/Core/Inc/tim.h b/Core/Inc/tim.h
index 1d9960e..c9fcad8 100644
--- a/Core/Inc/tim.h
+++ b/Core/Inc/tim.h
@@ -36,12 +36,15 @@ extern TIM_HandleTypeDef htim6;
extern TIM_HandleTypeDef htim7;
+extern TIM_HandleTypeDef htim10;
+
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
void MX_TIM6_Init(void);
void MX_TIM7_Init(void);
+void MX_TIM10_Init(void);
/* USER CODE BEGIN Prototypes */
diff --git a/Core/Src/freertos.c b/Core/Src/freertos.c
index 6f099c9..efa3128 100644
--- a/Core/Src/freertos.c
+++ b/Core/Src/freertos.c
@@ -102,7 +102,7 @@ void MX_FREERTOS_Init(void) {
/* Create the thread(s) */
/* definition and creation of defaultTask */
- osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
+ osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 512);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
/* USER CODE BEGIN RTOS_THREADS */
diff --git a/Core/Src/main.c b/Core/Src/main.c
index cb1e89e..32014c8 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -95,6 +95,7 @@ int main(void)
MX_TIM7_Init();
MX_USART1_UART_Init();
MX_USART2_UART_Init();
+ MX_TIM10_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
@@ -164,9 +165,9 @@ void SystemClock_Config(void)
}
/* USER CODE BEGIN 4 */
-
-/* USER CODE END 4 */
#if 0
+/* USER CODE END 4 */
+
/**
* @brief Period elapsed callback in non blocking mode
* @note This function is called when TIM11 interrupt took place, inside
diff --git a/Core/Src/stm32f4xx_it.c b/Core/Src/stm32f4xx_it.c
index 71bbb85..1ea9bf0 100644
--- a/Core/Src/stm32f4xx_it.c
+++ b/Core/Src/stm32f4xx_it.c
@@ -55,6 +55,9 @@
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
+extern TIM_HandleTypeDef htim6;
+extern TIM_HandleTypeDef htim7;
+extern TIM_HandleTypeDef htim10;
extern TIM_HandleTypeDef htim11;
/* USER CODE BEGIN EV */
@@ -160,6 +163,20 @@ void DebugMon_Handler(void)
/******************************************************************************/
/**
+ * @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
+ */
+void TIM1_UP_TIM10_IRQHandler(void)
+{
+ /* USER CODE BEGIN TIM1_UP_TIM10_IRQn 0 */
+
+ /* USER CODE END TIM1_UP_TIM10_IRQn 0 */
+ HAL_TIM_IRQHandler(&htim10);
+ /* USER CODE BEGIN TIM1_UP_TIM10_IRQn 1 */
+
+ /* USER CODE END TIM1_UP_TIM10_IRQn 1 */
+}
+
+/**
* @brief This function handles TIM1 trigger and commutation interrupts and TIM11 global interrupt.
*/
void TIM1_TRG_COM_TIM11_IRQHandler(void)
@@ -173,6 +190,34 @@ void TIM1_TRG_COM_TIM11_IRQHandler(void)
/* USER CODE END TIM1_TRG_COM_TIM11_IRQn 1 */
}
+/**
+ * @brief This function handles TIM6 global interrupt, DAC1 and DAC2 underrun error interrupts.
+ */
+void TIM6_DAC_IRQHandler(void)
+{
+ /* USER CODE BEGIN TIM6_DAC_IRQn 0 */
+
+ /* USER CODE END TIM6_DAC_IRQn 0 */
+ HAL_TIM_IRQHandler(&htim6);
+ /* USER CODE BEGIN TIM6_DAC_IRQn 1 */
+
+ /* USER CODE END TIM6_DAC_IRQn 1 */
+}
+
+/**
+ * @brief This function handles TIM7 global interrupt.
+ */
+void TIM7_IRQHandler(void)
+{
+ /* USER CODE BEGIN TIM7_IRQn 0 */
+
+ /* USER CODE END TIM7_IRQn 0 */
+ HAL_TIM_IRQHandler(&htim7);
+ /* USER CODE BEGIN TIM7_IRQn 1 */
+
+ /* USER CODE END TIM7_IRQn 1 */
+}
+
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
diff --git a/Core/Src/tim.c b/Core/Src/tim.c
index 661f577..66ae642 100644
--- a/Core/Src/tim.c
+++ b/Core/Src/tim.c
@@ -26,6 +26,7 @@
TIM_HandleTypeDef htim6;
TIM_HandleTypeDef htim7;
+TIM_HandleTypeDef htim10;
/* TIM6 init function */
void MX_TIM6_Init(void)
@@ -93,6 +94,32 @@ void MX_TIM7_Init(void)
/* USER CODE END TIM7_Init 2 */
}
+/* TIM10 init function */
+void MX_TIM10_Init(void)
+{
+
+ /* USER CODE BEGIN TIM10_Init 0 */
+
+ /* USER CODE END TIM10_Init 0 */
+
+ /* USER CODE BEGIN TIM10_Init 1 */
+
+ /* USER CODE END TIM10_Init 1 */
+ htim10.Instance = TIM10;
+ htim10.Init.Prescaler = 0;
+ htim10.Init.CounterMode = TIM_COUNTERMODE_UP;
+ htim10.Init.Period = 65535;
+ htim10.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
+ htim10.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
+ if (HAL_TIM_Base_Init(&htim10) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ /* USER CODE BEGIN TIM10_Init 2 */
+
+ /* USER CODE END TIM10_Init 2 */
+
+}
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
{
@@ -104,6 +131,10 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
/* USER CODE END TIM6_MspInit 0 */
/* TIM6 clock enable */
__HAL_RCC_TIM6_CLK_ENABLE();
+
+ /* TIM6 interrupt Init */
+ HAL_NVIC_SetPriority(TIM6_DAC_IRQn, 5, 0);
+ HAL_NVIC_EnableIRQ(TIM6_DAC_IRQn);
/* USER CODE BEGIN TIM6_MspInit 1 */
/* USER CODE END TIM6_MspInit 1 */
@@ -115,10 +146,29 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
/* USER CODE END TIM7_MspInit 0 */
/* TIM7 clock enable */
__HAL_RCC_TIM7_CLK_ENABLE();
+
+ /* TIM7 interrupt Init */
+ HAL_NVIC_SetPriority(TIM7_IRQn, 5, 0);
+ HAL_NVIC_EnableIRQ(TIM7_IRQn);
/* USER CODE BEGIN TIM7_MspInit 1 */
/* USER CODE END TIM7_MspInit 1 */
}
+ else if(tim_baseHandle->Instance==TIM10)
+ {
+ /* USER CODE BEGIN TIM10_MspInit 0 */
+
+ /* USER CODE END TIM10_MspInit 0 */
+ /* TIM10 clock enable */
+ __HAL_RCC_TIM10_CLK_ENABLE();
+
+ /* TIM10 interrupt Init */
+ HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, 5, 0);
+ HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn);
+ /* USER CODE BEGIN TIM10_MspInit 1 */
+
+ /* USER CODE END TIM10_MspInit 1 */
+ }
}
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
@@ -131,6 +181,9 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
/* USER CODE END TIM6_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM6_CLK_DISABLE();
+
+ /* TIM6 interrupt Deinit */
+ HAL_NVIC_DisableIRQ(TIM6_DAC_IRQn);
/* USER CODE BEGIN TIM6_MspDeInit 1 */
/* USER CODE END TIM6_MspDeInit 1 */
@@ -142,10 +195,27 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
/* USER CODE END TIM7_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM7_CLK_DISABLE();
+
+ /* TIM7 interrupt Deinit */
+ HAL_NVIC_DisableIRQ(TIM7_IRQn);
/* USER CODE BEGIN TIM7_MspDeInit 1 */
/* USER CODE END TIM7_MspDeInit 1 */
}
+ else if(tim_baseHandle->Instance==TIM10)
+ {
+ /* USER CODE BEGIN TIM10_MspDeInit 0 */
+
+ /* USER CODE END TIM10_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_TIM10_CLK_DISABLE();
+
+ /* TIM10 interrupt Deinit */
+ HAL_NVIC_DisableIRQ(TIM1_UP_TIM10_IRQn);
+ /* USER CODE BEGIN TIM10_MspDeInit 1 */
+
+ /* USER CODE END TIM10_MspDeInit 1 */
+ }
}
/* USER CODE BEGIN 1 */
diff --git a/Explorer STM32F4_V2.2_SCH.pdf b/Explorer STM32F4_V2.2_SCH.pdf
new file mode 100644
index 0000000..f4d29dd
Binary files /dev/null and b/Explorer STM32F4_V2.2_SCH.pdf differ
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..085e360
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+开发板资料
+http://47.111.11.73/docs/boards/stm32/zdyz_stm32f407_explorer.html
\ No newline at end of file
diff --git a/mainboard Debug.launch b/mainboard Debug.launch
new file mode 100644
index 0000000..c6d397d
--- /dev/null
+++ b/mainboard Debug.launch
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/mainboard.ioc b/mainboard.ioc
index ce2c188..7221b8a 100644
--- a/mainboard.ioc
+++ b/mainboard.ioc
@@ -8,7 +8,7 @@ CAN1.CalculateTimeQuantum=380.95238095238096
CAN1.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate
FREERTOS.FootprintOK=true
FREERTOS.IPParameters=Tasks01,FootprintOK,configUSE_RECURSIVE_MUTEXES,configUSE_NEWLIB_REENTRANT
-FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,As weak,NULL,Dynamic,NULL,NULL
+FREERTOS.Tasks01=defaultTask,0,512,StartDefaultTask,As weak,NULL,Dynamic,NULL,NULL
FREERTOS.configUSE_NEWLIB_REENTRANT=1
FREERTOS.configUSE_RECURSIVE_MUTEXES=1
File.Version=6
@@ -23,15 +23,17 @@ Mcu.IP3=RCC
Mcu.IP4=SYS
Mcu.IP5=TIM6
Mcu.IP6=TIM7
-Mcu.IP7=USART1
-Mcu.IP8=USART2
-Mcu.IPNb=9
+Mcu.IP7=TIM10
+Mcu.IP8=USART1
+Mcu.IP9=USART2
+Mcu.IPNb=10
Mcu.Name=STM32F407Z(E-G)Tx
Mcu.Package=LQFP144
Mcu.Pin0=PA2
Mcu.Pin1=PA3
Mcu.Pin10=VP_TIM6_VS_ClockSourceINT
Mcu.Pin11=VP_TIM7_VS_ClockSourceINT
+Mcu.Pin12=VP_TIM10_VS_ClockSourceINT
Mcu.Pin2=PA9
Mcu.Pin3=PA10
Mcu.Pin4=PA11
@@ -40,7 +42,7 @@ Mcu.Pin6=PA13
Mcu.Pin7=PA14
Mcu.Pin8=VP_FREERTOS_VS_CMSIS_V1
Mcu.Pin9=VP_SYS_VS_tim11
-Mcu.PinsNb=12
+Mcu.PinsNb=13
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F407ZGTx
@@ -60,6 +62,9 @@ NVIC.SavedSvcallIrqHandlerGenerated=true
NVIC.SavedSystickIrqHandlerGenerated=true
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:true\:false
NVIC.TIM1_TRG_COM_TIM11_IRQn=true\:15\:0\:true\:false\:true\:false\:false\:true\:true
+NVIC.TIM1_UP_TIM10_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
+NVIC.TIM6_DAC_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
+NVIC.TIM7_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
NVIC.TimeBase=TIM1_TRG_COM_TIM11_IRQn
NVIC.TimeBaseIP=TIM11
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
@@ -151,6 +156,8 @@ VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1
VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1
VP_SYS_VS_tim11.Mode=TIM11
VP_SYS_VS_tim11.Signal=SYS_VS_tim11
+VP_TIM10_VS_ClockSourceINT.Mode=Enable_Timer
+VP_TIM10_VS_ClockSourceINT.Signal=TIM10_VS_ClockSourceINT
VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer
VP_TIM6_VS_ClockSourceINT.Signal=TIM6_VS_ClockSourceINT
VP_TIM7_VS_ClockSourceINT.Mode=Enable_Timer
diff --git a/usrc/main.cpp b/usrc/main.cpp
index 6b67989..7badf5f 100644
--- a/usrc/main.cpp
+++ b/usrc/main.cpp
@@ -5,7 +5,8 @@
//
#include "sdk/os/zos.hpp"
-
+#include "sdk\components\step_motor_45\step_motor_45.hpp"
+#include "sdk\components\step_motor_45\step_motor_45_scheduler.hpp"
#define TAG "main"
namespace iflytop {
@@ -18,9 +19,118 @@ using namespace std;
extern "C" {
void StartDefaultTask(void const* argument) { umain(); }
}
+/*******************************************************************************
+ * 配置 *
+ *******************************************************************************/
+static chip_cfg_t chipcfg = {
+ .us_dleay_tim = &DELAY_US_TIMER,
+ .tim_irq_scheduler_tim = &TIM_IRQ_SCHEDULER_TIMER,
+ .huart = &DEBUG_UART,
+ .debuglight = DEBUG_LIGHT_GPIO,
+};
+
+static StepMotor45::cfg_t cfg1 = {
+ .max_pos = -1,
+ .enable_zero_limit = false,
+ .enable_max_pos_limit = false,
+ .mirror = false,
+
+ .zeroPin = PinNull,
+ .zeroPinMirror = false,
+
+ .driverPin = {PB15, PD11, PD12, PD13},
+ .driverPinMirror = false,
+};
+
+static StepMotor45::cfg_t cfg2 = {
+ .max_pos = -1,
+ .enable_zero_limit = false,
+ .enable_max_pos_limit = false,
+ .mirror = false,
+
+ .zeroPin = PinNull,
+ .zeroPinMirror = false,
+
+ .driverPin = {PG2, PG3, PG4, PG5},
+ .driverPinMirror = false,
+};
+
+static StepMotor45::cfg_t cfg3 = {
+ .max_pos = -1,
+ .enable_zero_limit = false,
+ .enable_max_pos_limit = false,
+ .mirror = false,
+
+ .zeroPin = PinNull,
+ .zeroPinMirror = false,
+
+ .driverPin = {PG6, PG7, PG8, PC6},
+ .driverPinMirror = false,
+};
+
+static StepMotor45::cfg_t cfg4 = {
+ .max_pos = -1,
+ .enable_zero_limit = false,
+ .enable_max_pos_limit = false,
+ .mirror = false,
+ .zeroPin = PinNull,
+ .zeroPinMirror = false,
+
+ .driverPin = {PC7, PC8, PC9, PA8},
+ .driverPinMirror = false,
+};
+
+static StepMotor45::cfg_t cfg5 = {
+ .max_pos = -1,
+ .enable_zero_limit = false,
+ .enable_max_pos_limit = false,
+ .mirror = false,
+
+ .zeroPin = PinNull,
+ .zeroPinMirror = false,
+
+ .driverPin = {PA13, PA14, PA15, PC10},
+ .driverPinMirror = false,
+};
+
+/*******************************************************************************
+ * 代码 *
+ *******************************************************************************/
+
+static StepMotor45 g_step_motor45_1;
+static StepMotor45 g_step_motor45_2;
+static StepMotor45 g_step_motor45_3;
+static StepMotor45 g_step_motor45_4;
+static StepMotor45 g_step_motor45_5;
void Main::run() {
+ /*******************************************************************************
+ * 系统初始化 *
+ *******************************************************************************/
+
+ chip_init(&chipcfg);
+
+ zos_cfg_t zoscfg;
+ zos_init(&zoscfg);
+
+ g_step_motor45_1.initialize(cfg1);
+ g_step_motor45_2.initialize(cfg2);
+ g_step_motor45_3.initialize(cfg3);
+ g_step_motor45_4.initialize(cfg4);
+ g_step_motor45_5.initialize(cfg5);
+
+ StepMotor45Scheduler step_motor45_scheduler;
+ step_motor45_scheduler.initialize(&htim10, 1000);
+ step_motor45_scheduler.addMotor(&g_step_motor45_1);
+ step_motor45_scheduler.addMotor(&g_step_motor45_2);
+ step_motor45_scheduler.addMotor(&g_step_motor45_3);
+ step_motor45_scheduler.addMotor(&g_step_motor45_4);
+ step_motor45_scheduler.addMotor(&g_step_motor45_5);
+ // g_step_motor45_1.rotate(true, 1000);
+
+ step_motor45_scheduler.start();
+
while (true) {
OSDefaultSchduler::getInstance()->loop();
}
diff --git a/usrc/project_configs.h b/usrc/project_configs.h
index 5e52b25..637fd8e 100644
--- a/usrc/project_configs.h
+++ b/usrc/project_configs.h
@@ -2,11 +2,11 @@
#define VERSION "v1.0"
#define MANUFACTURER "http://www.iflytop.com/"
-#define PROJECT_NAME "ecom_monitor"
+#define PROJECT_NAME "robot"
// 调试串口
#define DEBUG_UART huart1
// 调试指示灯
-#define DEBUG_LIGHT_GPIO PA1
+#define DEBUG_LIGHT_GPIO PF9
#define DELAY_US_TIMER htim6 // 定时器无需配置使能即可
#define TIM_IRQ_SCHEDULER_TIMER htim7 // 定时器无需配置使能即可