STM32足回りプログラム

Dependencies:   mbed ros_lib_kinetic

Committer:
TanakaRobo
Date:
Mon Jun 17 13:41:24 2019 +0000
Revision:
0:a202e1bc38a1
STM32 foot;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TanakaRobo 0:a202e1bc38a1 1 #pragma once
TanakaRobo 0:a202e1bc38a1 2 #include "mbed.h"
TanakaRobo 0:a202e1bc38a1 3
TanakaRobo 0:a202e1bc38a1 4 const double GY521_LSB_MAP[4] = {131, 65.5, 32.8, 16.4};
TanakaRobo 0:a202e1bc38a1 5 enum GY521RegisterMap {
TanakaRobo 0:a202e1bc38a1 6 WHO_AM_I = 0x75,
TanakaRobo 0:a202e1bc38a1 7 PWR_MGMT_1 = 0x6B,
TanakaRobo 0:a202e1bc38a1 8 LPF = 0x1A,
TanakaRobo 0:a202e1bc38a1 9 FS_SEL = 0x1B,
TanakaRobo 0:a202e1bc38a1 10 AFS_SEL = 0x1C,
TanakaRobo 0:a202e1bc38a1 11 ACCEL_XOUT_H = 0x3B,
TanakaRobo 0:a202e1bc38a1 12 ACCEL_YOUT_H = 0x3D,
TanakaRobo 0:a202e1bc38a1 13 ACCEL_ZOUT_H = 0x3F,
TanakaRobo 0:a202e1bc38a1 14 //TEMPERATURE = 0x41,
TanakaRobo 0:a202e1bc38a1 15 //GYRO_XOUT_H = 0x43,
TanakaRobo 0:a202e1bc38a1 16 //GYRO_YOUT_H = 0x45,
TanakaRobo 0:a202e1bc38a1 17 GYRO_ZOUT_H = 0x47
TanakaRobo 0:a202e1bc38a1 18 };
TanakaRobo 0:a202e1bc38a1 19
TanakaRobo 0:a202e1bc38a1 20 class GY521{
TanakaRobo 0:a202e1bc38a1 21 public:
TanakaRobo 0:a202e1bc38a1 22 GY521(I2C &i2c,int bit = 2,int calibration = 1000,double user_reg = 1.0);
TanakaRobo 0:a202e1bc38a1 23 double yaw;
TanakaRobo 0:a202e1bc38a1 24 double diffyaw;
TanakaRobo 0:a202e1bc38a1 25 //double temp;
TanakaRobo 0:a202e1bc38a1 26 void updata();
TanakaRobo 0:a202e1bc38a1 27 void reset(int user);
TanakaRobo 0:a202e1bc38a1 28 void start(double start = 0){
TanakaRobo 0:a202e1bc38a1 29 yaw = start;
TanakaRobo 0:a202e1bc38a1 30 }
TanakaRobo 0:a202e1bc38a1 31 double checkStatus(int mode);
TanakaRobo 0:a202e1bc38a1 32 private:
TanakaRobo 0:a202e1bc38a1 33 I2C &i2c;
TanakaRobo 0:a202e1bc38a1 34 Timer time;
TanakaRobo 0:a202e1bc38a1 35 unsigned int dev_id;
TanakaRobo 0:a202e1bc38a1 36 int16_t gyroRead2(enum GY521RegisterMap reg);
TanakaRobo 0:a202e1bc38a1 37 double gyro_z_aver;
TanakaRobo 0:a202e1bc38a1 38 double gyro_z_now;
TanakaRobo 0:a202e1bc38a1 39 double gyro_z_prev;
TanakaRobo 0:a202e1bc38a1 40 double gyro_LSB;
TanakaRobo 0:a202e1bc38a1 41 int bit_;
TanakaRobo 0:a202e1bc38a1 42 int calibration;
TanakaRobo 0:a202e1bc38a1 43 bool flag;
TanakaRobo 0:a202e1bc38a1 44 };