正点原子开发板 alientek_develop_board cancmder
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

137 lines
3.8 KiB

#include "main.hpp"
#include <stddef.h>
#include <stdio.h>
//
#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 {
Main gmain;
};
using namespace iflytop;
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();
}
}