38 lines
1000 B
C
38 lines
1000 B
C
#include "by_messy.h"
|
|
|
|
#include <string.h>
|
|
#include "by_stepper.h"
|
|
#include "by_can.h"
|
|
|
|
void by_messy_loop(void)
|
|
{
|
|
}
|
|
|
|
void by_messy_int(void)
|
|
{
|
|
can_rx_message_type can_rx_message_struct;
|
|
can_message_receive(CAN1, CAN_RX_FIFO0, &can_rx_message_struct);
|
|
|
|
// 接收到位置控制帧
|
|
if (0x006 == can_rx_message_struct.standard_id) {
|
|
uint8_t mode = 0;
|
|
uint8_t speed = 0;
|
|
float position_temp = 0;
|
|
|
|
memcpy(&mode, can_rx_message_struct.data, 1);
|
|
memcpy(&speed, can_rx_message_struct.data + 1, 1);
|
|
memcpy(&position_temp, can_rx_message_struct.data + 2, 4);
|
|
|
|
by_stepper_set_speed((stepper_speed_t)speed);
|
|
|
|
if (0 == mode) {
|
|
by_stepper_set_position_millimeter(position_temp);
|
|
} else if (1 == mode) {
|
|
by_stepper_add_position_millimeter(position_temp);
|
|
}
|
|
} else if (0x007 == can_rx_message_struct.standard_id) {
|
|
if (CAN_TFT_REMOTE == can_rx_message_struct.frame_type) {
|
|
by_can_send_stdd(0x007, &running_flag, 1, 0);
|
|
}
|
|
}
|
|
} |