Harurobo_CAN

Harurobo_CAN.cpp

Committer:
yuki0701
Date:
2019-01-20
Revision:
2:32640255dd8a
Parent:
1:d9c3f96a8d70

File content as of revision 2:32640255dd8a:

#ifndef HARUROBO2019_CAN_H
#include "mbed.h"
#include "PathFollowing.h"
#include "Harurobo_CAN.h"

CAN can1(p30,p29,1000000);
DigitalOut led(LED1);

CANMessage msg;



/*-----------------------1/19(土)追加-------------------------*/
void can_start(){

  while(1){
     printf("wait\n\r");
     if(can1.read(msg)){
         break;
     } 
  } 
}
/*-----------------------------------------------------------*/



void can_read(){//CAN通信受信
    
   //CANMessage msg;
    
    if(can1.read(msg)){
      
      if(msg.id == 1){
        //led = 1;
       usw_data1 = 0.1 * (short)((msg.data[0]<<8) | msg.data[1]);
       //printf("usw_data1 = %d:%d,%lf\n\r",msg.data[0],msg.data[1],usw_data1);
       // printf("%f\n\r",usw_data1);
      }
      /*if(msg.id == 2){
        //led = 1;
      //  usw_data2 = 0.01 * (short)((msg.data[0]<<8) | msg.data[1]);
        //printf("usw_data2 = %d:%d,%d\n\r",msg.data[0],msg.data[1],usw_data2);
      }*/
     // if(msg.id == 3){
        //led = 1;
        //usw_data3 = 0.1 * (short)((msg.data[0]<<8) | msg.data[1]);
        //usw_data3 = 0.1 * (short)((msg.data[0]<<8) | msg.data[1]);
        //printf("usw_data3 = %d:%d,%d\n\r",msg.data[0],msg.data[1],usw_data3);
       // printf("%f\n\r",usw_data3);
      //}
      /*if(msg.id == 4){
        led = 1;
        usw_data4 = 0.1 * (short)((msg.data[0]<<8) | msg.data[1]);
        //printf("usw_data4 = %d:%d,%d\n\r",msg.data[0],msg.data[1],usw_data4);
      }*/
          
    }
}

#endif