SHARE
TWEET

Untitled

a guest Mar 22nd, 2016 271 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. typedef struct CMD_CONTROL_t {
  2.     uint8_t control_mode;
  3.     uint16_t speed_roll;
  4.     uint16_t angle_roll;
  5.     uint16_t speed_pitch;
  6.     uint16_t angle_pitch;
  7.     uint16_t speed_yaw;
  8.     uint16_t angle_yaw;
  9. }CMD_CONTROL_t;
  10.  
  11. typedef struct SBGC_MSG_t{
  12.     uint8_t head;
  13.     uint8_t command_id;
  14.     uint8_t data_size;
  15.     uint8_t header_cs;
  16.     CMD_CONTROL_t data;
  17.     uint8_t body_cs;
  18. }SBGC_MSG_t;
  19.  
  20.  
  21. uint8_t body_cs(CMD_CONTROL_t cmd){
  22.     return cmd.control_mode +
  23.            cmd.angle_pitch +
  24.            cmd.angle_roll +
  25.            cmd.angle_yaw +
  26.            cmd.speed_roll +
  27.            cmd.speed_pitch +
  28.            cmd.speed_yaw;
  29. }
  30.  
  31.  
  32. int8_t app_init(void) {
  33.  
  34.     CMD_CONTROL_t cmd_msg = {0, 0, 0, 0, 0, 0, 0};
  35.     cmd_msg.control_mode = 1;
  36.     cmd_msg.speed_roll = 0x55;
  37.  
  38.     SBGC_MSG_t msg;
  39.     msg.head = '>';
  40.     msg.command_id = 67;
  41.     msg.data_size = sizeof(CMD_CONTROL_t);
  42.     msg.header_cs = msg.command_id + msg.data_size;
  43.     msg.data = cmd_msg;
  44.     msg.body_cs = body_cs(cmd_msg);
  45.  
  46.  
  47.  
  48.     while (1){
  49.         UART_write(UART_1,&msg,sizeof(msg));
  50.     }
  51.  
  52.     return 0;
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top