STM32 Debug #31
tianrking
started this conversation in
Show and tell
Replies: 1 comment
-
HIDdraw a circle extern USBD_HandleTypeDef hUsbDeviceFS;
void HID_MouseDrawCircle(void) {
const int radius = 5; // 圆的半径
const int steps = 20; // 分成多少步完成一圈
uint8_t buffer[4];
for (int i = 0; i < steps; ++i) {
float angle = (float)i / steps * 2 * 3.1415926; // 计算当前角度
int xMove = cos(angle) * radius; // 计算X轴移动量
int yMove = sin(angle) * radius; // 计算Y轴移动量
memset(buffer, 0, sizeof(buffer));
buffer[1] = xMove;
buffer[2] = yMove;
// 发送报告
USBD_HID_SendReport(&hUsbDeviceFS, buffer, sizeof(buffer));
HAL_Delay(50); // 控制绘制速度
}
// 最后发送一个空报告来停止移动
memset(buffer, 0, sizeof(buffer));
USBD_HID_SendReport(&hUsbDeviceFS, buffer, sizeof(buffer));
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
can bus
loop
loop & silence
silence
normal
前三种debug模式 逻辑分析仪抓会影响总线错误 虽然 文档里面提示不会
usb
调试 usb 时候 在 stm32f103 上 usb和can不能共存
Beta Was this translation helpful? Give feedback.
All reactions