1

Dependencies:   sMotor LIS3MDL X_NUCLEO_53L0A1

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers L3G4200D_my.cpp Source File

L3G4200D_my.cpp

00001 
00002 #include "L3G4200D_my.h"
00003 
00004 void GyroL3G4200D_Ini(DevI2C *gyro)
00005 {
00006     char data_write[2];
00007 
00008     wait(0.02);
00009     data_write[0]=CTRL_REG1;  // DR1 DR0 BW1 BW0 PD Zen Yen Xen
00010     data_write[1]=0x1f;       //  0   0   0   1  1   1   1   1    dr=100Hz, BW=25
00011     gyro->write(I2C_ADDR_GYRO,data_write, 2,0); // 1-no stop
00012 }
00013 
00014 //-----------------------------------------------
00015 void GyroL3G4200D_GetAxis(DevI2C *gyro,int16_t* g)
00016 {
00017     char data_write[2];
00018     char  buffer[6];
00019     
00020     data_write[0]=OUT_X_L|0x80;
00021     gyro->write(I2C_ADDR_GYRO,data_write, 1,1); // 1-no stop
00022     gyro->read(I2C_ADDR_GYRO,buffer, 6,0);
00023     g[0]=*((int16_t*)&buffer[0]);
00024     g[1]=*((int16_t*)&buffer[2]);
00025     g[2]=*((int16_t*)&buffer[4]); 
00026 }