You are viewing an older revision! See the latest version
1470101415
- include "mbed.h"
SPISlave spi(PA_7, PA_6, PA_5, PA_4); mosi, miso, sclk, ssel Serial pc(USBTX, USBRX); tx, rx
- ifndef M_PI
- define M_PI 3.14159126f
- 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); } } }