You are viewing an older revision! See the latest version

1470101415

  1. include "mbed.h"

SPISlave spi(PA_7, PA_6, PA_5, PA_4); mosi, miso, sclk, ssel Serial pc(USBTX, USBRX); tx, rx

  1. ifndef M_PI
  2. define M_PI 3.14159126f
  3. endif

int main(){ spi.receive(); spi.format(16,3); spi.frequency (1000000); while(1){ if(spi.receive()){ unsigned short data = spi.read(); double yaw = (double)data / 10000 * 180 / M_PI; pc.printf("gyro state:%lf\n\r", yaw); } } }


All wikipages