Browse Source

update

master
zhaohe 2 years ago
parent
commit
c51125a31a
  1. 2
      Core/Inc/FreeRTOSConfig.h
  2. 2
      sdk
  3. 10
      usrc/board.h
  4. 76
      usrc/main.cpp

2
Core/Inc/FreeRTOSConfig.h

@ -64,7 +64,7 @@
#define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES ( 7 )
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
#define configTOTAL_HEAP_SIZE ((size_t)15360)
#define configTOTAL_HEAP_SIZE ((size_t)55360)
#define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_16_BIT_TICKS 0
#define configUSE_MUTEXES 1

2
sdk

@ -1 +1 @@
Subproject commit baafde681f0e2f87659d06e8801f9ec9ea1c2277
Subproject commit 0242b1bfb1fd170f48e0cbf49f58090749fa1e24

10
usrc/board.h

@ -3,11 +3,11 @@
// #define TMC_DIAG1 PB0
// #define TMC_DIAG0 PB1
#define ID0_IO PC0
#define ID1_IO PC1
#define ID2_IO PC2
#define ID3_IO PC3
#define ID4_IO PC4
#define ID0_IO PE0
#define ID1_IO PE1
#define ID2_IO PE3
#define ID3_IO PE6
#define ID4_IO PB9
#define SENSOR_INT0 PD0
#define SENSOR_INT1 PD1

76
usrc/main.cpp

@ -30,13 +30,14 @@ extern DMA_HandleTypeDef hdma_usart3_tx;
/*******************************************************************************
* GET_DEVICE_ID *
*******************************************************************************/
static ZGPIO ID0;
static ZGPIO ID1;
static ZGPIO ID2;
static ZGPIO ID3;
static ZGPIO ID4;
static int32_t getDeviceId() {
static bool init = false;
static ZGPIO ID0;
static ZGPIO ID1;
static ZGPIO ID2;
static ZGPIO ID3;
static ZGPIO ID4;
static bool init = false;
if (!init) {
ID0.initAsInput(ID0_IO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
ID1.initAsInput(ID1_IO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
@ -51,9 +52,14 @@ static int32_t getDeviceId() {
/*******************************************************************************
* INIT_SUBMODULE *
*******************************************************************************/
#define GLOBAL_SCALE 32
#define DEFAULT_ENABLE true
void nvs_init_cb() {}
static void initsubmodule() {
osDelay(1000);
{
static TMC5130 g_motor;
static StepMotorCtrlModule g_stepMotorCtrlModule;
@ -66,6 +72,9 @@ static void initsubmodule() {
ZLOGI(TAG, "motora initialize 5160:%x ", g_motor.readICVersion());
g_motor.enable(true);
g_motor.setMotorShaft(false);
g_motor.setGlobalScale(GLOBAL_SCALE);
// g_motor.rotate(1*1000);
static ZGPIO input[10];
// input[0].initAsInput(MOTOR0_REFL /*REFL*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
// input[1].initAsInput(MOTOR0_REFR /*REFR*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
@ -75,9 +84,9 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_one_circle_pulse = 1000;
smcm_cfg.base_param.motor_one_circle_pulse_denominator = 1;
smcm_cfg.base_param.stepmotor_ihold = 1;
smcm_cfg.base_param.stepmotor_irun = 1;
smcm_cfg.base_param.stepmotor_irun = 20;
smcm_cfg.base_param.motor_shaft = 0;
smcm_cfg.base_param.motor_default_velocity = 1;
smcm_cfg.base_param.motor_default_velocity = 800;
smcm_cfg.base_param.motor_run_to_zero_speed = 0;
smcm_cfg.base_param.max_d = 0;
smcm_cfg.base_param.min_d = 0;
@ -89,7 +98,7 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_look_zero_edge_dec = 0;
g_stepMotorCtrlModule.initialize(initer.get_module_id(1), &g_motor, input, ZARRAY_SIZE(input), nullptr, &smcm_cfg);
g_stepMotorCtrlModule.enable(false);
g_stepMotorCtrlModule.enable(DEFAULT_ENABLE);
initer.register_module(&g_stepMotorCtrlModule);
}
@ -105,6 +114,7 @@ static void initsubmodule() {
ZLOGI(TAG, "motora initialize 5160:%x ", g_motor.readICVersion());
g_motor.enable(true);
g_motor.setMotorShaft(false);
g_motor.setGlobalScale(GLOBAL_SCALE);
static ZGPIO input[10];
// input[0].initAsInput(MOTOR0_REFL /*REFL*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
// input[1].initAsInput(MOTOR0_REFR /*REFR*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
@ -114,9 +124,9 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_one_circle_pulse = 1000;
smcm_cfg.base_param.motor_one_circle_pulse_denominator = 1;
smcm_cfg.base_param.stepmotor_ihold = 1;
smcm_cfg.base_param.stepmotor_irun = 1;
smcm_cfg.base_param.stepmotor_irun = 20;
smcm_cfg.base_param.motor_shaft = 0;
smcm_cfg.base_param.motor_default_velocity = 1;
smcm_cfg.base_param.motor_default_velocity = 800;
smcm_cfg.base_param.motor_run_to_zero_speed = 0;
smcm_cfg.base_param.max_d = 0;
smcm_cfg.base_param.min_d = 0;
@ -128,7 +138,7 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_look_zero_edge_dec = 0;
g_stepMotorCtrlModule.initialize(initer.get_module_id(2), &g_motor, input, ZARRAY_SIZE(input), nullptr, &smcm_cfg);
g_stepMotorCtrlModule.enable(false);
g_stepMotorCtrlModule.enable(DEFAULT_ENABLE);
initer.register_module(&g_stepMotorCtrlModule);
}
@ -144,6 +154,7 @@ static void initsubmodule() {
ZLOGI(TAG, "motora initialize 5160:%x ", g_motor.readICVersion());
g_motor.enable(true);
g_motor.setMotorShaft(false);
g_motor.setGlobalScale(GLOBAL_SCALE);
static ZGPIO input[10];
// input[0].initAsInput(MOTOR0_REFL /*REFL*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
// input[1].initAsInput(MOTOR0_REFR /*REFR*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
@ -153,9 +164,9 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_one_circle_pulse = 1000;
smcm_cfg.base_param.motor_one_circle_pulse_denominator = 1;
smcm_cfg.base_param.stepmotor_ihold = 1;
smcm_cfg.base_param.stepmotor_irun = 1;
smcm_cfg.base_param.stepmotor_irun = 20;
smcm_cfg.base_param.motor_shaft = 0;
smcm_cfg.base_param.motor_default_velocity = 1;
smcm_cfg.base_param.motor_default_velocity = 800;
smcm_cfg.base_param.motor_run_to_zero_speed = 0;
smcm_cfg.base_param.max_d = 0;
smcm_cfg.base_param.min_d = 0;
@ -167,7 +178,7 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_look_zero_edge_dec = 0;
g_stepMotorCtrlModule.initialize(initer.get_module_id(3), &g_motor, input, ZARRAY_SIZE(input), nullptr, &smcm_cfg);
g_stepMotorCtrlModule.enable(false);
g_stepMotorCtrlModule.enable(DEFAULT_ENABLE);
initer.register_module(&g_stepMotorCtrlModule);
}
@ -183,6 +194,7 @@ static void initsubmodule() {
ZLOGI(TAG, "motora initialize 5160:%x ", g_motor.readICVersion());
g_motor.enable(true);
g_motor.setMotorShaft(false);
g_motor.setGlobalScale(GLOBAL_SCALE);
static ZGPIO input[10];
// input[0].initAsInput(MOTOR0_REFL /*REFL*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
// input[1].initAsInput(MOTOR0_REFR /*REFR*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
@ -192,9 +204,9 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_one_circle_pulse = 1000;
smcm_cfg.base_param.motor_one_circle_pulse_denominator = 1;
smcm_cfg.base_param.stepmotor_ihold = 1;
smcm_cfg.base_param.stepmotor_irun = 1;
smcm_cfg.base_param.stepmotor_irun = 20;
smcm_cfg.base_param.motor_shaft = 0;
smcm_cfg.base_param.motor_default_velocity = 1;
smcm_cfg.base_param.motor_default_velocity = 800;
smcm_cfg.base_param.motor_run_to_zero_speed = 0;
smcm_cfg.base_param.max_d = 0;
smcm_cfg.base_param.min_d = 0;
@ -206,7 +218,7 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_look_zero_edge_dec = 0;
g_stepMotorCtrlModule.initialize(initer.get_module_id(4), &g_motor, input, ZARRAY_SIZE(input), nullptr, &smcm_cfg);
g_stepMotorCtrlModule.enable(false);
g_stepMotorCtrlModule.enable(DEFAULT_ENABLE);
initer.register_module(&g_stepMotorCtrlModule);
}
@ -223,6 +235,7 @@ static void initsubmodule() {
ZLOGI(TAG, "motora initialize 5160:%x ", g_motor.readICVersion());
g_motor.enable(true);
g_motor.setMotorShaft(false);
g_motor.setGlobalScale(GLOBAL_SCALE);
static ZGPIO input[10];
// input[0].initAsInput(MOTOR0_REFL /*REFL*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
// input[1].initAsInput(MOTOR0_REFR /*REFR*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
@ -232,9 +245,9 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_one_circle_pulse = 1000;
smcm_cfg.base_param.motor_one_circle_pulse_denominator = 1;
smcm_cfg.base_param.stepmotor_ihold = 1;
smcm_cfg.base_param.stepmotor_irun = 1;
smcm_cfg.base_param.stepmotor_irun = 20;
smcm_cfg.base_param.motor_shaft = 0;
smcm_cfg.base_param.motor_default_velocity = 1;
smcm_cfg.base_param.motor_default_velocity = 800;
smcm_cfg.base_param.motor_run_to_zero_speed = 0;
smcm_cfg.base_param.max_d = 0;
smcm_cfg.base_param.min_d = 0;
@ -246,7 +259,7 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_look_zero_edge_dec = 0;
g_stepMotorCtrlModule.initialize(initer.get_module_id(5), &g_motor, input, ZARRAY_SIZE(input), nullptr, &smcm_cfg);
g_stepMotorCtrlModule.enable(false);
g_stepMotorCtrlModule.enable(DEFAULT_ENABLE);
initer.register_module(&g_stepMotorCtrlModule);
}
@ -263,6 +276,7 @@ static void initsubmodule() {
ZLOGI(TAG, "motora initialize 5160:%x ", g_motor.readICVersion());
g_motor.enable(true);
g_motor.setMotorShaft(false);
g_motor.setGlobalScale(GLOBAL_SCALE);
static ZGPIO input[10];
// input[0].initAsInput(MOTOR0_REFL /*REFL*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
// input[1].initAsInput(MOTOR0_REFR /*REFR*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
@ -272,9 +286,9 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_one_circle_pulse = 1000;
smcm_cfg.base_param.motor_one_circle_pulse_denominator = 1;
smcm_cfg.base_param.stepmotor_ihold = 1;
smcm_cfg.base_param.stepmotor_irun = 1;
smcm_cfg.base_param.stepmotor_irun = 20;
smcm_cfg.base_param.motor_shaft = 0;
smcm_cfg.base_param.motor_default_velocity = 1;
smcm_cfg.base_param.motor_default_velocity = 800;
smcm_cfg.base_param.motor_run_to_zero_speed = 0;
smcm_cfg.base_param.max_d = 0;
smcm_cfg.base_param.min_d = 0;
@ -286,7 +300,7 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_look_zero_edge_dec = 0;
g_stepMotorCtrlModule.initialize(initer.get_module_id(6), &g_motor, input, ZARRAY_SIZE(input), nullptr, &smcm_cfg);
g_stepMotorCtrlModule.enable(false);
g_stepMotorCtrlModule.enable(DEFAULT_ENABLE);
initer.register_module(&g_stepMotorCtrlModule);
}
@ -303,6 +317,7 @@ static void initsubmodule() {
ZLOGI(TAG, "motora initialize 5160:%x ", g_motor.readICVersion());
g_motor.enable(true);
g_motor.setMotorShaft(false);
g_motor.setGlobalScale(GLOBAL_SCALE);
static ZGPIO input[10];
// input[0].initAsInput(MOTOR0_REFL /*REFL*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
// input[1].initAsInput(MOTOR0_REFR /*REFR*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
@ -312,9 +327,9 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_one_circle_pulse = 1000;
smcm_cfg.base_param.motor_one_circle_pulse_denominator = 1;
smcm_cfg.base_param.stepmotor_ihold = 1;
smcm_cfg.base_param.stepmotor_irun = 1;
smcm_cfg.base_param.stepmotor_irun = 20;
smcm_cfg.base_param.motor_shaft = 0;
smcm_cfg.base_param.motor_default_velocity = 1;
smcm_cfg.base_param.motor_default_velocity = 800;
smcm_cfg.base_param.motor_run_to_zero_speed = 0;
smcm_cfg.base_param.max_d = 0;
smcm_cfg.base_param.min_d = 0;
@ -326,7 +341,7 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_look_zero_edge_dec = 0;
g_stepMotorCtrlModule.initialize(initer.get_module_id(7), &g_motor, input, ZARRAY_SIZE(input), nullptr, &smcm_cfg);
g_stepMotorCtrlModule.enable(false);
g_stepMotorCtrlModule.enable(DEFAULT_ENABLE);
initer.register_module(&g_stepMotorCtrlModule);
}
@ -343,6 +358,7 @@ static void initsubmodule() {
ZLOGI(TAG, "motora initialize 5160:%x ", g_motor.readICVersion());
g_motor.enable(true);
g_motor.setMotorShaft(false);
g_motor.setGlobalScale(GLOBAL_SCALE);
static ZGPIO input[10];
// input[0].initAsInput(MOTOR0_REFL /*REFL*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
// input[1].initAsInput(MOTOR0_REFR /*REFR*/, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, true);
@ -352,9 +368,9 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_one_circle_pulse = 1000;
smcm_cfg.base_param.motor_one_circle_pulse_denominator = 1;
smcm_cfg.base_param.stepmotor_ihold = 1;
smcm_cfg.base_param.stepmotor_irun = 1;
smcm_cfg.base_param.stepmotor_irun = 20;
smcm_cfg.base_param.motor_shaft = 0;
smcm_cfg.base_param.motor_default_velocity = 1;
smcm_cfg.base_param.motor_default_velocity = 800;
smcm_cfg.base_param.motor_run_to_zero_speed = 0;
smcm_cfg.base_param.max_d = 0;
smcm_cfg.base_param.min_d = 0;
@ -366,7 +382,7 @@ static void initsubmodule() {
smcm_cfg.base_param.motor_look_zero_edge_dec = 0;
g_stepMotorCtrlModule.initialize(initer.get_module_id(8), &g_motor, input, ZARRAY_SIZE(input), nullptr, &smcm_cfg);
g_stepMotorCtrlModule.enable(false);
g_stepMotorCtrlModule.enable(DEFAULT_ENABLE);
initer.register_module(&g_stepMotorCtrlModule);
}
}

Loading…
Cancel
Save