42 int8_t l3g4200d_init(
void) {
46 while (l3g4200d_read8bit(L3G4000D_WHO_I_AM_REG) != 0xD3) {
52 l3g4200d_write8bit(L3G4000D_CTRL_REG1, 0x0F);
56 angle_data_t l3g4200d_get_angle(
void) {
57 angle_data_t this_angle;
59 this_angle.angle_x_value = l3g4200d_get_x_angle();
60 this_angle.angle_y_value = l3g4200d_get_y_angle();
61 this_angle.angle_z_value = l3g4200d_get_z_angle();
65 uint16_t l3g4200d_get_x_angle(
void) {
66 return l3g4200d_read16bit(L3G4000D_OUT_X_L);
69 uint16_t l3g4200d_get_y_angle(
void) {
70 return l3g4200d_read16bit(L3G4000D_OUT_Y_L);
73 uint16_t l3g4200d_get_z_angle(
void) {
74 return l3g4200d_read16bit(L3G4000D_OUT_Z_L);
77 int8_t l3g4200d_get_temp(
void){
78 return 45-(int8_t)l3g4200d_read8bit(L3G4000D_OUT_TEMP);
81 uint8_t l3g4200d_read8bit(uint8_t addr) {
83 i2c_start(L3G4200D_DEV_ADDR_W);
85 i2c_rep_start(L3G4200D_DEV_ADDR_R);
91 uint16_t l3g4200d_read16bit(uint8_t addr) {
92 uint8_t lsb = 0, msb = 0;
93 i2c_start(L3G4200D_DEV_ADDR_W);
94 i2c_write((addr | 0x80));
95 i2c_rep_start(L3G4200D_DEV_ADDR_R);
99 return (uint16_t) ((msb << 8) + lsb);
102 void l3g4200d_write8bit(uint8_t addr, uint8_t data){
103 i2c_start(L3G4200D_DEV_ADDR_W);