Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
GyroSensor.h
00001 /** 00002 ***************************************************************************** 00003 * File Name : GyroSensor.h 00004 * 00005 * Title : Gyro Sensor Class Header File 00006 * Revision : 0.1 00007 * Notes : 00008 * Target Board : mbed NXP LPC1768 00009 * Tool Chain : ???? 00010 * 00011 * Revision History: 00012 * When Who Description of change 00013 * ----------- ----------- ----------------------- 00014 * 2012/07/10 Hiroshi M init 00015 ***************************************************************************** 00016 * 00017 * Copyright (C) 2012 Hiroshi M, MIT License 00018 * 00019 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00020 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00021 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00022 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00023 * furnished to do so, subject to the following conditions: 00024 * 00025 * The above copyright notice and this permission notice shall be included in all copies or 00026 * substantial portions of the Software. 00027 * 00028 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00029 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00030 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00031 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00032 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00033 * 00034 **/ 00035 00036 #ifndef MBED_GYRO_SENSOR_H 00037 #define MBED_GYRO_SENSOR_H 00038 00039 /* Includes ----------------------------------------------------------------- */ 00040 #include "mbed.h" 00041 00042 /* typedef ------------------------------------------------------------------ */ 00043 typedef enum {CLEAR,INI,IDLE,READY} GyroState; 00044 00045 typedef GyroState (*GYRO_CALLBACK_FUNC)(int gyv, int gyv, int offset); 00046 typedef int (*GET_DISTANCE_GAIN_FUNC)(void); 00047 typedef int (*GET_DISTANCE_FEEDBACK_FUNC)(void); 00048 00049 /* define ------------------------------------------------------------------- */ 00050 #define INI_COUNT 16 00051 #define AV_COUNT 32 00052 00053 /* macro -------------------------------------------------------------------- */ 00054 /* variables ---------------------------------------------------------------- */ 00055 00056 /* class define --------------------------------------------------------------*/ 00057 class GyroSensor 00058 { 00059 public: 00060 GyroSensor(PinName _pin_no, GYRO_CALLBACK_FUNC _p_callack, GET_DISTANCE_FEEDBACK_FUNC _p_feedback, GET_DISTANCE_GAIN_FUNC _p_disatnce_gain); 00061 ~GyroSensor(); 00062 00063 void Enable(void); 00064 void Disable(void); 00065 00066 GyroState getState(void); 00067 int getAngle(void); 00068 int getVelocity(void); 00069 int getOffset(void); 00070 00071 void setReady(void); 00072 void setIdle(void); 00073 00074 00075 private: 00076 int gya; // 00077 int gyv; // 00078 int offset; // 00079 00080 int adcav; 00081 int offset_count; 00082 int offset_ini_count; 00083 long int offset_sum; 00084 long int offset_sum_old; 00085 long int offset_sum_ini; 00086 long int offset_sum_old_ini; 00087 long int gyaa; 00088 00089 int d_fb; 00090 int d_gain; 00091 00092 GyroState state; 00093 00094 GYRO_CALLBACK_FUNC callback; 00095 GET_DISTANCE_FEEDBACK_FUNC getDistanceFeedback; 00096 GET_DISTANCE_GAIN_FUNC getDisatnceGain; 00097 00098 void getParameter(void); 00099 00100 AnalogIn gyro_adc_in; 00101 Ticker Pulse; 00102 00103 void ad_conv(void); 00104 void gyro_control(void); 00105 00106 }; 00107 00108 #endif
Generated on Thu Jul 14 2022 20:41:33 by
1.7.2