diff --git a/.clang-format b/.clang-format index 73d1b82..1c995cf 100644 --- a/.clang-format +++ b/.clang-format @@ -2,7 +2,7 @@ # http://clang.llvm.org/docs/ClangFormatStyleOptions.html Language: Cpp BasedOnStyle: Google -ColumnLimit: 210 +ColumnLimit: 250 AlignConsecutiveMacros: true AlignConsecutiveDeclarations: true AlignConsecutiveAssignments: true diff --git a/sdk b/sdk index 967d39b..e82611f 160000 --- a/sdk +++ b/sdk @@ -1 +1 @@ -Subproject commit 967d39b1f8cac49b7a1bfd1ca491dd7cc1e4b97e +Subproject commit e82611f05a5999c543c80b7384cd2b4dd8c3a0e2 diff --git a/usrc/main.cpp b/usrc/main.cpp index 603ef3a..36c1e1b 100644 --- a/usrc/main.cpp +++ b/usrc/main.cpp @@ -50,6 +50,7 @@ void umain() { .driverIC_resetPin = PinNull, // }; motora.initialize(&cfg); + motora.setMotorShaft(false); ZLOGI(TAG, "motora initialize TMC4361A:%x DriverIC:%x", motora.readICVersion(), motora.readSubICVersion()); } @@ -64,6 +65,7 @@ void umain() { .driverIC_resetPin = PinNull, // }; motorb.initialize(&cfg); + motorb.setMotorShaft(false); ZLOGI(TAG, "motorb initialize TMC4361A:%x DriverIC:%x", motorb.readICVersion(), motorb.readSubICVersion()); } @@ -102,13 +104,36 @@ void umain() { /******************************************************************************* * zcanXYRobotCtrlModule * *******************************************************************************/ - xyRobotCtrlModule.initialize(&motora, &motorb, NULL, NULL, 1.0f); + ZGPIO input[8]; + input[0].initAsInput(ARM_SENSOR1_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false); + input[1].initAsInput(ARM_SENSOR2_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false); + input[2].initAsInput(ARM_SENSOR3_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false); + input[3].initAsInput(ARM_SENSOR4_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false); + input[4].initAsInput(ARM_SENSOR5_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false); + input[5].initAsInput(ARM_SENSOR6_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false); + input[6].initAsInput(ARM_SENSOR7_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false); + input[7].initAsInput(ARM_SENSOR8_GPIO, ZGPIO::kMode_nopull, ZGPIO::kIRQ_noIrq, false); + + xyRobotCtrlModule.initialize(&motora, &motorb, &input[6], &input[7], 1.0f); zcanXYRobotCtrlModule.initialize(&zcanCmder, 1, &xyRobotCtrlModule); + // ARM_SENSOR1_GPIO.initAsInput(STM32_GPIO::kInput_risingAndFallingIrq, true); + // ARM_SENSOR2_GPIO.initAsInput(STM32_GPIO::kInput_risingAndFallingIrq, true); + // ARM_SENSOR3_GPIO.initAsInput(); + // ARM_SENSOR4_GPIO.initAsInput(); + // ARM_SENSOR5_GPIO.initAsInput(); + // ARM_SENSOR6_GPIO.initAsInput(); + // ARM_SENSOR7_GPIO.initAsInput(STM32_GPIO::kInput_risingAndFallingIrq, true); + // ARM_SENSOR8_GPIO.initAsInput(STM32_GPIO::kInput_risingAndFallingIrq, true); + while (true) { OSDefaultSchduler::getInstance()->loop(); zcanCmder.loop(); - // zcanCmder.sendPacket(data, 4); - // osDelay(100); +// zcanCmder.sendPacket(data, 4); +#if 0 + osDelay(100); + ZLOGI(TAG, "input:%d %d %d %d %d %d %d %d", // + input[0].getState(), input[1].getState(), input[2].getState(), input[3].getState(), input[4].getState(), input[5].getState(), input[6].getState(), input[7].getState()); +#endif } } diff --git a/usrc/project_configs.h b/usrc/project_configs.h index 93b3aa7..710a222 100644 --- a/usrc/project_configs.h +++ b/usrc/project_configs.h @@ -31,4 +31,13 @@ #define TMC_MOTOR2_nFREEZE_IO PC6 #define TMC_MOTOR2_nRESET_IO PB2 #define TMC_MOTOR2_SUB_IC_ENN_IO PC7 -#define TMC_MOTOR2_ENN_IO // unused \ No newline at end of file +#define TMC_MOTOR2_ENN_IO // unused + +#define ARM_SENSOR1_GPIO PD0 +#define ARM_SENSOR2_GPIO PD1 +#define ARM_SENSOR3_GPIO PD2 +#define ARM_SENSOR4_GPIO PD3 +#define ARM_SENSOR5_GPIO PD4 +#define ARM_SENSOR6_GPIO PD5 +#define ARM_SENSOR7_GPIO PD6 +#define ARM_SENSOR8_GPIO PD7