giro for my students

Committer:
docent
Date:
Sat Feb 08 10:42:09 2020 +0000
Revision:
0:1eafa5c54075
for my students

Who changed what in which revision?

UserRevisionLine numberNew contents of line
docent 0:1eafa5c54075 1 #include "L3G4200D_my.h"
docent 0:1eafa5c54075 2
docent 0:1eafa5c54075 3 void GyroL3G4200D_Ini(DevI2C *gyro)
docent 0:1eafa5c54075 4 {
docent 0:1eafa5c54075 5 char data_write[2];
docent 0:1eafa5c54075 6
docent 0:1eafa5c54075 7 wait(0.02);
docent 0:1eafa5c54075 8 data_write[0]=CTRL_REG1; // DR1 DR0 BW1 BW0 PD Zen Yen Xen
docent 0:1eafa5c54075 9 data_write[1]=0x1f; // 0 0 0 1 1 1 1 1 dr=100Hz, BW=25
docent 0:1eafa5c54075 10 gyro->write(I2C_ADDR_GYRO,data_write, 2,0); // 1-no stop
docent 0:1eafa5c54075 11 }
docent 0:1eafa5c54075 12
docent 0:1eafa5c54075 13 //-----------------------------------------------
docent 0:1eafa5c54075 14 void GyroL3G4200D_GetAxis(DevI2C *gyro,int16_t* g)
docent 0:1eafa5c54075 15 {
docent 0:1eafa5c54075 16 char data_write[2];
docent 0:1eafa5c54075 17 char buffer[6];
docent 0:1eafa5c54075 18
docent 0:1eafa5c54075 19 data_write[0]=OUT_X_L|0x80;
docent 0:1eafa5c54075 20 gyro->write(I2C_ADDR_GYRO,data_write, 1,1); // 1-no stop
docent 0:1eafa5c54075 21 gyro->read(I2C_ADDR_GYRO,buffer, 6,0);
docent 0:1eafa5c54075 22 g[0]=*((int16_t*)&buffer[0]);
docent 0:1eafa5c54075 23 g[1]=*((int16_t*)&buffer[2]);
docent 0:1eafa5c54075 24 g[2]=*((int16_t*)&buffer[4]);
docent 0:1eafa5c54075 25 }
docent 0:1eafa5c54075 26