/********************** 头文件 *************************/ #include "bsp_interface.h" /********************** 变量区 *************************/ //extern int16_t gyro[3]; //extern int16_t accel[3]; //extern uint16_t press; extern int16_t accel[3]; extern int16_t gyro[3]; extern uint16_t h_press; extern int16_t s_gyro[3]; extern int16_t s_accel[3]; extern uint16_t s_press; /********************** 函数声明区 *************************/ //enum _CMD_UPDATE{ // UPDATE_NONE = 0, // UPDATE_RUN, // NUMBERS_OF_UPDATE, // }; void sen_step_to_host(uint8_t step,uint16_t distance) { uint8_t buf[32]; uint8_t L=0; buf[L++] = UPDATE_RUN; buf[L++] = (uint8_t)(step>>0); buf[L++] = (uint8_t)(distance>>8); buf[L++] = (uint8_t)(distance>>0); send_protocol(DEX_NUM,CMD_UPDATE,buf,L); } void sen_data_to_host(void) { // uint8_t buf[256]; // uint8_t L=0; // // buf[L++] = (uint8_t)(h_press>>8); // buf[L++] = (uint8_t)(h_press>>0); // // buf[L++] = (uint8_t)(s_press>>8); // buf[L++] = (uint8_t)(s_press>>0); // // buf[L++] = (uint8_t)(accel[0]>>8); // buf[L++] = (uint8_t)(accel[0]>>0); // // buf[L++] = (uint8_t)(accel[1]>>8); // buf[L++] = (uint8_t)(accel[1]>>0); // // buf[L++] = (uint8_t)(accel[2]>>8); // buf[L++] = (uint8_t)(accel[2]>>0); // // buf[L++] = (uint8_t)(s_accel[0]>>8); // buf[L++] = (uint8_t)(s_accel[0]>>0); // // buf[L++] = (uint8_t)(s_accel[1]>>8); // buf[L++] = (uint8_t)(s_accel[1]>>0); // // buf[L++] = (uint8_t)(s_accel[2]>>8); // buf[L++] = (uint8_t)(s_accel[2]>>0); // // buf[L++] = (uint8_t)(gyro[0]>>8); // buf[L++] = (uint8_t)(gyro[0]>>0); // // buf[L++] = (uint8_t)(gyro[1]>>8); // buf[L++] = (uint8_t)(gyro[1]>>0); // // buf[L++] = (uint8_t)(gyro[2]>>8); // buf[L++] = (uint8_t)(gyro[2]>>0); // // buf[L++] = (uint8_t)(s_gyro[0]>>8); // buf[L++] = (uint8_t)(s_gyro[0]>>0); // // buf[L++] = (uint8_t)(s_gyro[1]>>8); // buf[L++] = (uint8_t)(s_gyro[1]>>0); // // buf[L++] = (uint8_t)(s_gyro[2]>>8); // buf[L++] = (uint8_t)(s_gyro[2]>>0); // // send_protocol(DEX_NUM,CMD_HEART,buf,L); } static uint8_t send_motion = 0; static uint8_t send_ts = 0; static uint8_t send_times = 0; void send_motion_to_phone(uint8_t motion,uint16_t ts) { send_motion = motion; send_ts = ts; send_times = 10; // uint8_t buf[16]; // uint8_t L=0; // buf[L++] = motion; // // buf[L++] = (uint8_t)(ts>>8); // buf[L++] = (uint8_t)(ts>>0); // // for(int i = 0; i <5; i++) // send_protocol(DEX_NUM,CMD_MOTION,buf,L); } void send_to_phone_process(void) { uint8_t buf[16]; uint8_t L=0; if(send_times>0){ send_times--; buf[L++] = send_motion; buf[L++] = (uint8_t)(send_ts>>8); buf[L++] = (uint8_t)(send_ts>>0); send_protocol(DEX_NUM,CMD_MOTION,buf,L); } }