![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ライブラリ化を行った後
Dependencies: QEI accelerator bit_test cyclic_io cyclic_var cylinder event_var limit mbed mecanum motor_drive pid pid_encoder rs422_put sbdbt servo
Fork of 17robo_Practice1 by
bno055_lib.h@0:bf96e953cdb8, 2017-06-26 (annotated)
- Committer:
- echo_piyo
- Date:
- Mon Jun 26 09:59:14 2017 +0000
- Revision:
- 0:bf96e953cdb8
????????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
echo_piyo | 0:bf96e953cdb8 | 1 | #ifndef BNO055_H |
echo_piyo | 0:bf96e953cdb8 | 2 | #define BNO055_H |
echo_piyo | 0:bf96e953cdb8 | 3 | |
echo_piyo | 0:bf96e953cdb8 | 4 | //UART通信に使用するバッファの最大サイズ |
echo_piyo | 0:bf96e953cdb8 | 5 | #define BNO055_UART_BUF_MAXLEN 24 //[byte] |
echo_piyo | 0:bf96e953cdb8 | 6 | //I2Cデフォルトスレーブアドレス |
echo_piyo | 0:bf96e953cdb8 | 7 | #define BNO055_I2C_DEFADDR 0x28 |
echo_piyo | 0:bf96e953cdb8 | 8 | |
echo_piyo | 0:bf96e953cdb8 | 9 | #define BNO055_PAGE_ID 0x07 |
echo_piyo | 0:bf96e953cdb8 | 10 | |
echo_piyo | 0:bf96e953cdb8 | 11 | #define BNO055P0_CHIP_ID 0x00 |
echo_piyo | 0:bf96e953cdb8 | 12 | #define BNO055P0_ACC_ID 0x01 |
echo_piyo | 0:bf96e953cdb8 | 13 | #define BNO055P0_MAG_ID 0x02 |
echo_piyo | 0:bf96e953cdb8 | 14 | #define BNO055P0_GYR_ID 0x03 |
echo_piyo | 0:bf96e953cdb8 | 15 | #define BNO055P0_SW_REV_ID_LSB 0x04 |
echo_piyo | 0:bf96e953cdb8 | 16 | #define BNO055P0_SW_REV_ID_MSB 0x05 |
echo_piyo | 0:bf96e953cdb8 | 17 | #define BNO055P0_BL_REV_ID 0x06 |
echo_piyo | 0:bf96e953cdb8 | 18 | #define BNO055P0_ACC_DATA_X_LSB 0x08 |
echo_piyo | 0:bf96e953cdb8 | 19 | #define BNO055P0_ACC_DATA_X_MSB 0x09 |
echo_piyo | 0:bf96e953cdb8 | 20 | #define BNO055P0_ACC_DATA_Y_LSB 0x0A |
echo_piyo | 0:bf96e953cdb8 | 21 | #define BNO055P0_ACC_DATA_Y_MSB 0x0B |
echo_piyo | 0:bf96e953cdb8 | 22 | #define BNO055P0_ACC_DATA_Z_LSB 0x0C |
echo_piyo | 0:bf96e953cdb8 | 23 | #define BNO055P0_ACC_DATA_Z_MSB 0x0D |
echo_piyo | 0:bf96e953cdb8 | 24 | #define BNO055P0_MAG_DATA_X_LSB 0x0E |
echo_piyo | 0:bf96e953cdb8 | 25 | #define BNO055P0_MAG_DATA_X_MSB 0x0F |
echo_piyo | 0:bf96e953cdb8 | 26 | #define BNO055P0_MAG_DATA_Y_LSB 0x10 |
echo_piyo | 0:bf96e953cdb8 | 27 | #define BNO055P0_MAG_DATA_Y_MSB 0x11 |
echo_piyo | 0:bf96e953cdb8 | 28 | #define BNO055P0_MAG_DATA_Z_LSB 0x12 |
echo_piyo | 0:bf96e953cdb8 | 29 | #define BNO055P0_MAG_DATA_Z_MSB 0x13 |
echo_piyo | 0:bf96e953cdb8 | 30 | #define BNO055P0_GYR_DATA_X_LSB 0x14 |
echo_piyo | 0:bf96e953cdb8 | 31 | #define BNO055P0_GYR_DATA_X_MSB 0x15 |
echo_piyo | 0:bf96e953cdb8 | 32 | #define BNO055P0_GYR_DATA_Y_LSB 0x16 |
echo_piyo | 0:bf96e953cdb8 | 33 | #define BNO055P0_GYR_DATA_Y_MSB 0x17 |
echo_piyo | 0:bf96e953cdb8 | 34 | #define BNO055P0_GYR_DATA_Z_LSB 0x18 |
echo_piyo | 0:bf96e953cdb8 | 35 | #define BNO055P0_GYR_DATA_Z_MSB 0x19 |
echo_piyo | 0:bf96e953cdb8 | 36 | #define BNO055P0_EUL_HEADING_LSB 0x1A |
echo_piyo | 0:bf96e953cdb8 | 37 | #define BNO055P0_EUL_HEADING_MSB 0x1B |
echo_piyo | 0:bf96e953cdb8 | 38 | #define BNO055P0_EUL_ROLL_LSB 0x1C |
echo_piyo | 0:bf96e953cdb8 | 39 | #define BNO055P0_EUL_ROLL_MSB 0x1D |
echo_piyo | 0:bf96e953cdb8 | 40 | #define BNO055P0_EUL_PITCH_LSB 0x1E |
echo_piyo | 0:bf96e953cdb8 | 41 | #define BNO055P0_EUL_PITCH_MSB 0x1F |
echo_piyo | 0:bf96e953cdb8 | 42 | #define BNO055P0_QUA_DATA_W_LSB 0x20 |
echo_piyo | 0:bf96e953cdb8 | 43 | #define BNO055P0_QUA_DATA_W_MSB 0x21 |
echo_piyo | 0:bf96e953cdb8 | 44 | #define BNO055P0_QUA_DATA_X_LSB 0x22 |
echo_piyo | 0:bf96e953cdb8 | 45 | #define BNO055P0_QUA_DATA_X_MSB 0x23 |
echo_piyo | 0:bf96e953cdb8 | 46 | #define BNO055P0_QUA_DATA_Y_LSB 0x24 |
echo_piyo | 0:bf96e953cdb8 | 47 | #define BNO055P0_QUA_DATA_Y_MSB 0x25 |
echo_piyo | 0:bf96e953cdb8 | 48 | #define BNO055P0_QUA_DATA_Z_LSB 0x26 |
echo_piyo | 0:bf96e953cdb8 | 49 | #define BNO055P0_QUA_DATA_Z_MSB 0x27 |
echo_piyo | 0:bf96e953cdb8 | 50 | #define BNO055P0_LIA_DATA_X_LSB 0x28 |
echo_piyo | 0:bf96e953cdb8 | 51 | #define BNO055P0_LIA_DATA_X_MBS 0x29 |
echo_piyo | 0:bf96e953cdb8 | 52 | #define BNO055P0_LIA_DATA_Y_LSB 0x2A |
echo_piyo | 0:bf96e953cdb8 | 53 | #define BNO055P0_LIA_DATA_Y_MBS 0x2B |
echo_piyo | 0:bf96e953cdb8 | 54 | #define BNO055P0_LIA_DATA_Z_LSB 0x2C |
echo_piyo | 0:bf96e953cdb8 | 55 | #define BNO055P0_LIA_DATA_Z_MBS 0x2D |
echo_piyo | 0:bf96e953cdb8 | 56 | #define BNO055P0_GRV_DATA_X_LSB 0x2E |
echo_piyo | 0:bf96e953cdb8 | 57 | #define BNO055P0_GRV_DATA_X_MSB 0x2F |
echo_piyo | 0:bf96e953cdb8 | 58 | #define BNO055P0_GRV_DATA_Y_LSB 0x30 |
echo_piyo | 0:bf96e953cdb8 | 59 | #define BNO055P0_GRV_DATA_Y_MSB 0x31 |
echo_piyo | 0:bf96e953cdb8 | 60 | #define BNO055P0_GRV_DATA_Z_LSB 0x32 |
echo_piyo | 0:bf96e953cdb8 | 61 | #define BNO055P0_GRV_DATA_Z_MSB 0x33 |
echo_piyo | 0:bf96e953cdb8 | 62 | #define BNO055P0_TEMP 0x34 |
echo_piyo | 0:bf96e953cdb8 | 63 | #define BNO055P0_CALIB_STAT 0x35 |
echo_piyo | 0:bf96e953cdb8 | 64 | #define BNO055P0_ST_RESULT 0x36 |
echo_piyo | 0:bf96e953cdb8 | 65 | #define BNO055P0_INT_STA 0x37 |
echo_piyo | 0:bf96e953cdb8 | 66 | #define BNO055P0_SYS_CLK_STATUS 0x38 |
echo_piyo | 0:bf96e953cdb8 | 67 | #define BNO055P0_SYS_STATUS 0x39 |
echo_piyo | 0:bf96e953cdb8 | 68 | #define BNO055P0_SYS_ERR 0x3A |
echo_piyo | 0:bf96e953cdb8 | 69 | #define BNO055P0_UNIT_SEL 0x3B |
echo_piyo | 0:bf96e953cdb8 | 70 | #define BNO055P0_OPR_MODE 0x3D |
echo_piyo | 0:bf96e953cdb8 | 71 | #define BNO055P0_PWR_MODE 0x3E |
echo_piyo | 0:bf96e953cdb8 | 72 | #define BNO055P0_SYS_TRIGGER 0x3F |
echo_piyo | 0:bf96e953cdb8 | 73 | #define BNO055P0_TEMP_SOURCE 0x40 |
echo_piyo | 0:bf96e953cdb8 | 74 | #define BNO055P0_AXIS_MAP_CONFIG 0x41 |
echo_piyo | 0:bf96e953cdb8 | 75 | #define BNO055P0_AXIS_MAP_SIGN 0x42 |
echo_piyo | 0:bf96e953cdb8 | 76 | #define BNO055P0_ACC_OFFSET_X_LSB 0x55 |
echo_piyo | 0:bf96e953cdb8 | 77 | #define BNO055P0_ACC_OFFSET_X_MSB 0x56 |
echo_piyo | 0:bf96e953cdb8 | 78 | #define BNO055P0_ACC_OFFSET_Y_LSB 0x57 |
echo_piyo | 0:bf96e953cdb8 | 79 | #define BNO055P0_ACC_OFFSET_Y_MSB 0x58 |
echo_piyo | 0:bf96e953cdb8 | 80 | #define BNO055P0_ACC_OFFSET_Z_LSB 0x59 |
echo_piyo | 0:bf96e953cdb8 | 81 | #define BNO055P0_ACC_OFFSET_Z_MSB 0x5A |
echo_piyo | 0:bf96e953cdb8 | 82 | #define BNO055P0_MAG_OFFSET_X_LSB 0x5B |
echo_piyo | 0:bf96e953cdb8 | 83 | #define BNO055P0_MAG_OFFSET_X_MSB 0x5C |
echo_piyo | 0:bf96e953cdb8 | 84 | #define BNO055P0_MAG_OFFSET_Y_LSB 0x5D |
echo_piyo | 0:bf96e953cdb8 | 85 | #define BNO055P0_MAG_OFFSET_Y_MSB 0x5E |
echo_piyo | 0:bf96e953cdb8 | 86 | #define BNO055P0_MAG_OFFSET_Z_LSB 0x5F |
echo_piyo | 0:bf96e953cdb8 | 87 | #define BNO055P0_MAG_OFFSET_Z_MSB 0x60 |
echo_piyo | 0:bf96e953cdb8 | 88 | #define BNO055P0_GYR_OFFSET_X_LSB 0x61 |
echo_piyo | 0:bf96e953cdb8 | 89 | #define BNO055P0_GYR_OFFSET_X_MSB 0x62 |
echo_piyo | 0:bf96e953cdb8 | 90 | #define BNO055P0_GYR_OFFSET_Y_LSB 0x63 |
echo_piyo | 0:bf96e953cdb8 | 91 | #define BNO055P0_GYR_OFFSET_Y_MSB 0x64 |
echo_piyo | 0:bf96e953cdb8 | 92 | #define BNO055P0_GYR_OFFSET_Z_LSB 0x65 |
echo_piyo | 0:bf96e953cdb8 | 93 | #define BNO055P0_GYR_OFFSET_Z_MSB 0x66 |
echo_piyo | 0:bf96e953cdb8 | 94 | #define BNO055P0_ACC_RADIUS_LSB 0x67 |
echo_piyo | 0:bf96e953cdb8 | 95 | #define BNO055P0_ACC_RADIUS_MSB 0x68 |
echo_piyo | 0:bf96e953cdb8 | 96 | #define BNO055P0_MAG_RADIUS_LSB 0x69 |
echo_piyo | 0:bf96e953cdb8 | 97 | #define BNO055P0_MAG_RADIUS_MSB 0x6A |
echo_piyo | 0:bf96e953cdb8 | 98 | |
echo_piyo | 0:bf96e953cdb8 | 99 | #define BNO055P1_ACC_CONFIG 0x08 |
echo_piyo | 0:bf96e953cdb8 | 100 | #define BNO055P1_MAG_CONFIG 0x09 |
echo_piyo | 0:bf96e953cdb8 | 101 | #define BNO055P1_GYR_CONFIG_0 0x0A |
echo_piyo | 0:bf96e953cdb8 | 102 | #define BNO055P1_GYR_CONFIG_1 0x0B |
echo_piyo | 0:bf96e953cdb8 | 103 | #define BNO055P1_ACC_SLEEP_CONFIG 0x0C |
echo_piyo | 0:bf96e953cdb8 | 104 | #define BNO055P1_GYR_SLEEP_CONFIG 0x0D |
echo_piyo | 0:bf96e953cdb8 | 105 | #define BNO055P1_INT_MSK 0x0F |
echo_piyo | 0:bf96e953cdb8 | 106 | #define BNO055P1_INT_EN 0x10 |
echo_piyo | 0:bf96e953cdb8 | 107 | #define BNO055P1_ACC_AM_THRES 0x11 |
echo_piyo | 0:bf96e953cdb8 | 108 | #define BNO055P1_ACC_INT_SETTINGS 0x12 |
echo_piyo | 0:bf96e953cdb8 | 109 | #define BNO055P1_ACC_HG_DURATION 0x13 |
echo_piyo | 0:bf96e953cdb8 | 110 | #define BNO055P1_ACC_HG_THRES 0x14 |
echo_piyo | 0:bf96e953cdb8 | 111 | #define BNO055P1_ACC_NM_THRES 0x15 |
echo_piyo | 0:bf96e953cdb8 | 112 | #define BNO055P1_ACC_NM_SET 0x16 |
echo_piyo | 0:bf96e953cdb8 | 113 | #define BNO055P1_GYR_INT_SETING 0x17 |
echo_piyo | 0:bf96e953cdb8 | 114 | #define BNO055P1_GYR_HR_X_SET 0x18 |
echo_piyo | 0:bf96e953cdb8 | 115 | #define BNO055P1_GYR_DUR_X 0x19 |
echo_piyo | 0:bf96e953cdb8 | 116 | #define BNO055P1_GYR_HR_Y_SET 0x1A |
echo_piyo | 0:bf96e953cdb8 | 117 | #define BNO055P1_GYR_DUR_Y 0x1B |
echo_piyo | 0:bf96e953cdb8 | 118 | #define BNO055P1_GYR_HR_Z_SET 0x1C |
echo_piyo | 0:bf96e953cdb8 | 119 | #define BNO055P1_GYR_DUR_Z 0x1D |
echo_piyo | 0:bf96e953cdb8 | 120 | #define BNO055P1_GYR_AM_THRES 0x1E |
echo_piyo | 0:bf96e953cdb8 | 121 | #define BNO055P1_GYR_AM_SET 0x1F |
echo_piyo | 0:bf96e953cdb8 | 122 | |
echo_piyo | 0:bf96e953cdb8 | 123 | class BNO055_CTRL{ |
echo_piyo | 0:bf96e953cdb8 | 124 | public: |
echo_piyo | 0:bf96e953cdb8 | 125 | BNO055_CTRL(); |
echo_piyo | 0:bf96e953cdb8 | 126 | virtual ~BNO055_CTRL(); |
echo_piyo | 0:bf96e953cdb8 | 127 | protected: |
echo_piyo | 0:bf96e953cdb8 | 128 | bool page1; |
echo_piyo | 0:bf96e953cdb8 | 129 | char *ary; |
echo_piyo | 0:bf96e953cdb8 | 130 | char lastError; |
echo_piyo | 0:bf96e953cdb8 | 131 | char lastLength; |
echo_piyo | 0:bf96e953cdb8 | 132 | public: |
echo_piyo | 0:bf96e953cdb8 | 133 | char getNowPage(); |
echo_piyo | 0:bf96e953cdb8 | 134 | char getLastError(); |
echo_piyo | 0:bf96e953cdb8 | 135 | char getLastLength(); |
echo_piyo | 0:bf96e953cdb8 | 136 | virtual void init(); |
echo_piyo | 0:bf96e953cdb8 | 137 | virtual char rr(bool isPage1, char regAddr); |
echo_piyo | 0:bf96e953cdb8 | 138 | virtual char rrc(bool isPage1, char startRegAddr, char *receiveBytes, char length); |
echo_piyo | 0:bf96e953cdb8 | 139 | virtual char wr(bool isPage1, char regAddr, char wBytes); |
echo_piyo | 0:bf96e953cdb8 | 140 | virtual char wrc(bool isPage1, char startRegAddr, char *Bytes, char length); |
echo_piyo | 0:bf96e953cdb8 | 141 | }; |
echo_piyo | 0:bf96e953cdb8 | 142 | |
echo_piyo | 0:bf96e953cdb8 | 143 | class BNO055_UART_CTRL : public BNO055_CTRL{ |
echo_piyo | 0:bf96e953cdb8 | 144 | public: |
echo_piyo | 0:bf96e953cdb8 | 145 | BNO055_UART_CTRL(RawSerial *uart); |
echo_piyo | 0:bf96e953cdb8 | 146 | virtual ~BNO055_UART_CTRL(); |
echo_piyo | 0:bf96e953cdb8 | 147 | private: |
echo_piyo | 0:bf96e953cdb8 | 148 | RawSerial *iface; |
echo_piyo | 0:bf96e953cdb8 | 149 | short rxd; |
echo_piyo | 0:bf96e953cdb8 | 150 | bool read_mark; |
echo_piyo | 0:bf96e953cdb8 | 151 | |
echo_piyo | 0:bf96e953cdb8 | 152 | void rxInterrupt(); |
echo_piyo | 0:bf96e953cdb8 | 153 | public: |
echo_piyo | 0:bf96e953cdb8 | 154 | virtual void init(); |
echo_piyo | 0:bf96e953cdb8 | 155 | virtual char rr(bool isPage1, char regAddr); |
echo_piyo | 0:bf96e953cdb8 | 156 | virtual char rrc(bool isPage1, char startRegAddr, char *receiveBytes, char length); |
echo_piyo | 0:bf96e953cdb8 | 157 | virtual char wr(bool isPage1, char regAddr, char wBytes); |
echo_piyo | 0:bf96e953cdb8 | 158 | virtual char wrc(bool isPage1, char startRegAddr, char *Bytes, char length); |
echo_piyo | 0:bf96e953cdb8 | 159 | }; |
echo_piyo | 0:bf96e953cdb8 | 160 | |
echo_piyo | 0:bf96e953cdb8 | 161 | class BNO055_I2C_CTRL : public BNO055_CTRL{ |
echo_piyo | 0:bf96e953cdb8 | 162 | public: |
echo_piyo | 0:bf96e953cdb8 | 163 | BNO055_I2C_CTRL(I2C *iic, char addr, unsigned int freq); |
echo_piyo | 0:bf96e953cdb8 | 164 | virtual ~BNO055_I2C_CTRL(); |
echo_piyo | 0:bf96e953cdb8 | 165 | private: |
echo_piyo | 0:bf96e953cdb8 | 166 | I2C *iface; |
echo_piyo | 0:bf96e953cdb8 | 167 | char i2c_writeAddr; |
echo_piyo | 0:bf96e953cdb8 | 168 | char i2c_readAddr; |
echo_piyo | 0:bf96e953cdb8 | 169 | unsigned int i2c_freq; |
echo_piyo | 0:bf96e953cdb8 | 170 | public: |
echo_piyo | 0:bf96e953cdb8 | 171 | virtual void init(); |
echo_piyo | 0:bf96e953cdb8 | 172 | virtual char rr(bool isPage1, char regAddr); |
echo_piyo | 0:bf96e953cdb8 | 173 | virtual char rrc(bool isPage1, char startRegAddr, char *receiveBytes, char length); |
echo_piyo | 0:bf96e953cdb8 | 174 | virtual char wr(bool isPage1, char regAddr, char wBytes); |
echo_piyo | 0:bf96e953cdb8 | 175 | virtual char wrc(bool isPage1, char startRegAddr, char *Bytes, char length); |
echo_piyo | 0:bf96e953cdb8 | 176 | }; |
echo_piyo | 0:bf96e953cdb8 | 177 | |
echo_piyo | 0:bf96e953cdb8 | 178 | class BOARDC_BNO055{ |
echo_piyo | 0:bf96e953cdb8 | 179 | public: |
echo_piyo | 0:bf96e953cdb8 | 180 | BOARDC_BNO055(PinName tx, PinName rx); |
echo_piyo | 0:bf96e953cdb8 | 181 | BOARDC_BNO055(RawSerial *uart); |
echo_piyo | 0:bf96e953cdb8 | 182 | BOARDC_BNO055(PinName scl, PinName sda, char addr=BNO055_I2C_DEFADDR, unsigned int freq=100000); |
echo_piyo | 0:bf96e953cdb8 | 183 | BOARDC_BNO055(I2C *iic, char addr=BNO055_I2C_DEFADDR, unsigned int freq=100000); |
echo_piyo | 0:bf96e953cdb8 | 184 | ~BOARDC_BNO055(); |
echo_piyo | 0:bf96e953cdb8 | 185 | |
echo_piyo | 0:bf96e953cdb8 | 186 | private: |
echo_piyo | 0:bf96e953cdb8 | 187 | BNO055_CTRL *ctrl; |
echo_piyo | 0:bf96e953cdb8 | 188 | float scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 189 | float scaleMAG; //fixed |
echo_piyo | 0:bf96e953cdb8 | 190 | float scaleGYRO; |
echo_piyo | 0:bf96e953cdb8 | 191 | float scaleTEMP; |
echo_piyo | 0:bf96e953cdb8 | 192 | float scaleEuler; |
echo_piyo | 0:bf96e953cdb8 | 193 | float scaleLIA; //=scaleACC |
echo_piyo | 0:bf96e953cdb8 | 194 | float scaleGV; //=scaleACC |
echo_piyo | 0:bf96e953cdb8 | 195 | double scaleQuaternion; //fixed |
echo_piyo | 0:bf96e953cdb8 | 196 | unsigned char axisRemap; |
echo_piyo | 0:bf96e953cdb8 | 197 | unsigned char axisSign; |
echo_piyo | 0:bf96e953cdb8 | 198 | bool clkExt; |
echo_piyo | 0:bf96e953cdb8 | 199 | |
echo_piyo | 0:bf96e953cdb8 | 200 | public: |
echo_piyo | 0:bf96e953cdb8 | 201 | char initialize(bool resetIface=true); |
echo_piyo | 0:bf96e953cdb8 | 202 | char getIfaceLastError(); |
echo_piyo | 0:bf96e953cdb8 | 203 | char getIfaceLastLength(); |
echo_piyo | 0:bf96e953cdb8 | 204 | |
echo_piyo | 0:bf96e953cdb8 | 205 | char customRead(bool isPage1, char regAddr); |
echo_piyo | 0:bf96e953cdb8 | 206 | char customReadC(bool isPage1, char startRegAddr, char *receiveBytes, unsigned char length); |
echo_piyo | 0:bf96e953cdb8 | 207 | char customWrite(bool isPage1, char regAddr, char wBytes); |
echo_piyo | 0:bf96e953cdb8 | 208 | char customWriteC(bool isPage1, char startRegAddr, char *Bytes, unsigned char length); |
echo_piyo | 0:bf96e953cdb8 | 209 | |
echo_piyo | 0:bf96e953cdb8 | 210 | char getPage(); |
echo_piyo | 0:bf96e953cdb8 | 211 | void setPage(unsigned char pageNo); |
echo_piyo | 0:bf96e953cdb8 | 212 | |
echo_piyo | 0:bf96e953cdb8 | 213 | char getChipID(); |
echo_piyo | 0:bf96e953cdb8 | 214 | char getAccChipID(); |
echo_piyo | 0:bf96e953cdb8 | 215 | char getMagChipID(); |
echo_piyo | 0:bf96e953cdb8 | 216 | char getGyroChipID(); |
echo_piyo | 0:bf96e953cdb8 | 217 | |
echo_piyo | 0:bf96e953cdb8 | 218 | short getRevision(); |
echo_piyo | 0:bf96e953cdb8 | 219 | char getBootRevision(); |
echo_piyo | 0:bf96e953cdb8 | 220 | |
echo_piyo | 0:bf96e953cdb8 | 221 | float getAccScale(); |
echo_piyo | 0:bf96e953cdb8 | 222 | float getMagScale(); |
echo_piyo | 0:bf96e953cdb8 | 223 | float getGyroScale(); |
echo_piyo | 0:bf96e953cdb8 | 224 | float getTempScale(); |
echo_piyo | 0:bf96e953cdb8 | 225 | float getEulerScale(); |
echo_piyo | 0:bf96e953cdb8 | 226 | float getLinearScale(); |
echo_piyo | 0:bf96e953cdb8 | 227 | float getGVScale(); |
echo_piyo | 0:bf96e953cdb8 | 228 | double getQuaternionScale(); |
echo_piyo | 0:bf96e953cdb8 | 229 | |
echo_piyo | 0:bf96e953cdb8 | 230 | void getAccDataAll(short &accX, short &accY, short &accZ); |
echo_piyo | 0:bf96e953cdb8 | 231 | short getAccDataX(); |
echo_piyo | 0:bf96e953cdb8 | 232 | short getAccDataY(); |
echo_piyo | 0:bf96e953cdb8 | 233 | short getAccDataZ(); |
echo_piyo | 0:bf96e953cdb8 | 234 | |
echo_piyo | 0:bf96e953cdb8 | 235 | void getMagDataAll(short &magX, short &magY, short &magZ); |
echo_piyo | 0:bf96e953cdb8 | 236 | short getMagDataX(); |
echo_piyo | 0:bf96e953cdb8 | 237 | short getMagDataY(); |
echo_piyo | 0:bf96e953cdb8 | 238 | short getMagDataZ(); |
echo_piyo | 0:bf96e953cdb8 | 239 | |
echo_piyo | 0:bf96e953cdb8 | 240 | void getGyroDataAll(short &gyroX, short &gyroY, short &gyroZ); |
echo_piyo | 0:bf96e953cdb8 | 241 | short getGyroDataX(); |
echo_piyo | 0:bf96e953cdb8 | 242 | short getGyroDataY(); |
echo_piyo | 0:bf96e953cdb8 | 243 | short getGyroDataZ(); |
echo_piyo | 0:bf96e953cdb8 | 244 | |
echo_piyo | 0:bf96e953cdb8 | 245 | void getEulerDataAll(short &E_heading, short &E_roll, short &E_pitch); |
echo_piyo | 0:bf96e953cdb8 | 246 | short getEulerDataHeading(); |
echo_piyo | 0:bf96e953cdb8 | 247 | short getEulerDataYaw(); |
echo_piyo | 0:bf96e953cdb8 | 248 | short getEulerDataRoll(); |
echo_piyo | 0:bf96e953cdb8 | 249 | short getEulerDataPitch(); |
echo_piyo | 0:bf96e953cdb8 | 250 | |
echo_piyo | 0:bf96e953cdb8 | 251 | void get9Axis(short *box); |
echo_piyo | 0:bf96e953cdb8 | 252 | void get9AxisAndEUL(short *box); |
echo_piyo | 0:bf96e953cdb8 | 253 | |
echo_piyo | 0:bf96e953cdb8 | 254 | void getQuaternion(short &q1, short &q2, short &q3, short &q4); |
echo_piyo | 0:bf96e953cdb8 | 255 | |
echo_piyo | 0:bf96e953cdb8 | 256 | void getLinearAccDataAll(short &L_accX, short &L_accY, short &L_accZ); |
echo_piyo | 0:bf96e953cdb8 | 257 | short getLinearAccDataX(); |
echo_piyo | 0:bf96e953cdb8 | 258 | short getLinearAccDataY(); |
echo_piyo | 0:bf96e953cdb8 | 259 | short getLinearAccDataZ(); |
echo_piyo | 0:bf96e953cdb8 | 260 | |
echo_piyo | 0:bf96e953cdb8 | 261 | void getGVectorDataAll(short &gvX, short &gvY, short &gvZ); |
echo_piyo | 0:bf96e953cdb8 | 262 | short getGVectorDataX(); |
echo_piyo | 0:bf96e953cdb8 | 263 | short getGVectorDataY(); |
echo_piyo | 0:bf96e953cdb8 | 264 | short getGVectorDataZ(); |
echo_piyo | 0:bf96e953cdb8 | 265 | |
echo_piyo | 0:bf96e953cdb8 | 266 | char getTemperature(); |
echo_piyo | 0:bf96e953cdb8 | 267 | |
echo_piyo | 0:bf96e953cdb8 | 268 | void getCalibStatusAll(char &sys, char &acc, char &mag, char &gyro); |
echo_piyo | 0:bf96e953cdb8 | 269 | char getCalibStatusSys(); |
echo_piyo | 0:bf96e953cdb8 | 270 | char getCalibStatusAcc(); |
echo_piyo | 0:bf96e953cdb8 | 271 | char getCalibStatusMag(); |
echo_piyo | 0:bf96e953cdb8 | 272 | char getCalibStatusGyro(); |
echo_piyo | 0:bf96e953cdb8 | 273 | |
echo_piyo | 0:bf96e953cdb8 | 274 | char getSelfTestResultAll(); |
echo_piyo | 0:bf96e953cdb8 | 275 | bool getSelfTestResultMCU(); |
echo_piyo | 0:bf96e953cdb8 | 276 | bool getSelfTestResultAcc(); |
echo_piyo | 0:bf96e953cdb8 | 277 | bool getSelfTestResultMag(); |
echo_piyo | 0:bf96e953cdb8 | 278 | bool getSelfTestResultGyro(); |
echo_piyo | 0:bf96e953cdb8 | 279 | |
echo_piyo | 0:bf96e953cdb8 | 280 | char triggeredIntALL(); |
echo_piyo | 0:bf96e953cdb8 | 281 | bool triggeredACC_NM(); |
echo_piyo | 0:bf96e953cdb8 | 282 | bool triggeredACC_AM(); |
echo_piyo | 0:bf96e953cdb8 | 283 | bool triggeredACC_HIGH_G(); |
echo_piyo | 0:bf96e953cdb8 | 284 | bool triggeredGYR_HIGH_RATE(); |
echo_piyo | 0:bf96e953cdb8 | 285 | bool triggeredGYRO_AM(); |
echo_piyo | 0:bf96e953cdb8 | 286 | |
echo_piyo | 0:bf96e953cdb8 | 287 | bool isSystemClockFixed(); |
echo_piyo | 0:bf96e953cdb8 | 288 | |
echo_piyo | 0:bf96e953cdb8 | 289 | char getSystemStatus(); |
echo_piyo | 0:bf96e953cdb8 | 290 | char getSystemError(); |
echo_piyo | 0:bf96e953cdb8 | 291 | |
echo_piyo | 0:bf96e953cdb8 | 292 | char getUNIT_SEL(); |
echo_piyo | 0:bf96e953cdb8 | 293 | char setUNIT_SEL(char selectValue); |
echo_piyo | 0:bf96e953cdb8 | 294 | char setUNIT_AccUnit(bool isMeterPerSec2=true); |
echo_piyo | 0:bf96e953cdb8 | 295 | char setUNIT_GyroUnit(bool isDps=true); |
echo_piyo | 0:bf96e953cdb8 | 296 | char setUNIT_EulerUnit(bool isDegrees=true); |
echo_piyo | 0:bf96e953cdb8 | 297 | char setUNIT_Temperature(bool isCelsius=true); |
echo_piyo | 0:bf96e953cdb8 | 298 | char setUNIT_OrientationMode(bool ori_Android=true); |
echo_piyo | 0:bf96e953cdb8 | 299 | |
echo_piyo | 0:bf96e953cdb8 | 300 | char getOperationMode(); |
echo_piyo | 0:bf96e953cdb8 | 301 | char setOperationMode(char modeValue); |
echo_piyo | 0:bf96e953cdb8 | 302 | char setOperation_CONFIG(); |
echo_piyo | 0:bf96e953cdb8 | 303 | char setOperation_ACCONRY(); |
echo_piyo | 0:bf96e953cdb8 | 304 | char setOperation_MAGONRY(); |
echo_piyo | 0:bf96e953cdb8 | 305 | char setOperation_GYROONRY(); |
echo_piyo | 0:bf96e953cdb8 | 306 | char setOperation_ACCMAG(); |
echo_piyo | 0:bf96e953cdb8 | 307 | char setOperation_ACCGYRO(); |
echo_piyo | 0:bf96e953cdb8 | 308 | char setOperation_MAGGYRO(); |
echo_piyo | 0:bf96e953cdb8 | 309 | char setOperation_AMG(); |
echo_piyo | 0:bf96e953cdb8 | 310 | char setOperation_Fusion_IMU(); |
echo_piyo | 0:bf96e953cdb8 | 311 | char setOperation_Fusion_COMPASS(); |
echo_piyo | 0:bf96e953cdb8 | 312 | char setOperation_Fusion_M4G(); |
echo_piyo | 0:bf96e953cdb8 | 313 | char setOperation_Fusion_NDOF_FMC_OFF(); |
echo_piyo | 0:bf96e953cdb8 | 314 | char setOperation_Fusion_NDOF(); |
echo_piyo | 0:bf96e953cdb8 | 315 | |
echo_piyo | 0:bf96e953cdb8 | 316 | char getPowerMode(); |
echo_piyo | 0:bf96e953cdb8 | 317 | char setPowerMode(unsigned char modeValue); |
echo_piyo | 0:bf96e953cdb8 | 318 | char setPowerMode_Normal(); |
echo_piyo | 0:bf96e953cdb8 | 319 | char setPowerMode_LowPower(); |
echo_piyo | 0:bf96e953cdb8 | 320 | char setPowerMode_Suspend(); |
echo_piyo | 0:bf96e953cdb8 | 321 | |
echo_piyo | 0:bf96e953cdb8 | 322 | char setSysTrigger(char regVal); |
echo_piyo | 0:bf96e953cdb8 | 323 | char setSys_ExternalCrystal(bool isExternal=true); |
echo_piyo | 0:bf96e953cdb8 | 324 | char resetInterrupt(); |
echo_piyo | 0:bf96e953cdb8 | 325 | char soft_reset(); |
echo_piyo | 0:bf96e953cdb8 | 326 | char execSelfTest(); |
echo_piyo | 0:bf96e953cdb8 | 327 | |
echo_piyo | 0:bf96e953cdb8 | 328 | char getTempSource(); |
echo_piyo | 0:bf96e953cdb8 | 329 | char setTempSource(bool Accelerometer=true); |
echo_piyo | 0:bf96e953cdb8 | 330 | |
echo_piyo | 0:bf96e953cdb8 | 331 | char getAxisMapConfig(); |
echo_piyo | 0:bf96e953cdb8 | 332 | char setAxisMapConfig(char val); |
echo_piyo | 0:bf96e953cdb8 | 333 | char getAxisMapSign(); |
echo_piyo | 0:bf96e953cdb8 | 334 | char setAxisMapSign(char val); |
echo_piyo | 0:bf96e953cdb8 | 335 | char setAxisRemap_topview_topleft(); |
echo_piyo | 0:bf96e953cdb8 | 336 | char setAxisRemap_topview_topright(); |
echo_piyo | 0:bf96e953cdb8 | 337 | char setAxisRemap_topview_bottomleft(); |
echo_piyo | 0:bf96e953cdb8 | 338 | char setAxisRemap_topview_bottomright(); |
echo_piyo | 0:bf96e953cdb8 | 339 | char setAxisRemap_bottomview_topleft(); |
echo_piyo | 0:bf96e953cdb8 | 340 | char setAxisRemap_bottomview_topright(); |
echo_piyo | 0:bf96e953cdb8 | 341 | char setAxisRemap_bottomview_bottomleft(); |
echo_piyo | 0:bf96e953cdb8 | 342 | char setAxisRemap_bottomview_bottomright(); |
echo_piyo | 0:bf96e953cdb8 | 343 | char getAxisRemap_type(); |
echo_piyo | 0:bf96e953cdb8 | 344 | |
echo_piyo | 0:bf96e953cdb8 | 345 | void getAccOffsetAll(float &offsetX, float &offsetY, float &offsetZ); |
echo_piyo | 0:bf96e953cdb8 | 346 | float getAccOffsetX(); |
echo_piyo | 0:bf96e953cdb8 | 347 | float getAccOffsetY(); |
echo_piyo | 0:bf96e953cdb8 | 348 | float getAccOffsetZ(); |
echo_piyo | 0:bf96e953cdb8 | 349 | char setAccOffsetAll(float offsetX, float offsetY, float offsetZ); |
echo_piyo | 0:bf96e953cdb8 | 350 | char setAccOffsetX(float offset); |
echo_piyo | 0:bf96e953cdb8 | 351 | char setAccOffsetY(float offset); |
echo_piyo | 0:bf96e953cdb8 | 352 | char setAccOffsetZ(float offset); |
echo_piyo | 0:bf96e953cdb8 | 353 | |
echo_piyo | 0:bf96e953cdb8 | 354 | void getMagOffsetAll(float &offsetX, float &offsetY, float &offsetZ); |
echo_piyo | 0:bf96e953cdb8 | 355 | float getMagOffsetX(); |
echo_piyo | 0:bf96e953cdb8 | 356 | float getMagOffsetY(); |
echo_piyo | 0:bf96e953cdb8 | 357 | float getMagOffsetZ(); |
echo_piyo | 0:bf96e953cdb8 | 358 | char setMagOffsetAll(float offsetX, float offsetY, float offsetZ); |
echo_piyo | 0:bf96e953cdb8 | 359 | char setMagOffsetX(float offset); |
echo_piyo | 0:bf96e953cdb8 | 360 | char setMagOffsetY(float offset); |
echo_piyo | 0:bf96e953cdb8 | 361 | char setMagOffsetZ(float offset); |
echo_piyo | 0:bf96e953cdb8 | 362 | |
echo_piyo | 0:bf96e953cdb8 | 363 | void getGyroOffsetAll(float &offsetX, float &offsetY, float &offsetZ); |
echo_piyo | 0:bf96e953cdb8 | 364 | float getGyroOffsetX(); |
echo_piyo | 0:bf96e953cdb8 | 365 | float getGyroOffsetY(); |
echo_piyo | 0:bf96e953cdb8 | 366 | float getGyroOffsetZ(); |
echo_piyo | 0:bf96e953cdb8 | 367 | char setGyroOffsetAll(float offsetX, float offsetY, float offsetZ); |
echo_piyo | 0:bf96e953cdb8 | 368 | char setGyroOffsetX(float offset); |
echo_piyo | 0:bf96e953cdb8 | 369 | char setGyroOffsetY(float offset); |
echo_piyo | 0:bf96e953cdb8 | 370 | char setGyroOffsetZ(float offset); |
echo_piyo | 0:bf96e953cdb8 | 371 | |
echo_piyo | 0:bf96e953cdb8 | 372 | short getAccRadius(); |
echo_piyo | 0:bf96e953cdb8 | 373 | char setAccRadius(short LSB); |
echo_piyo | 0:bf96e953cdb8 | 374 | |
echo_piyo | 0:bf96e953cdb8 | 375 | short getMagRadius(); |
echo_piyo | 0:bf96e953cdb8 | 376 | char setMagRadius(short LSB); |
echo_piyo | 0:bf96e953cdb8 | 377 | |
echo_piyo | 0:bf96e953cdb8 | 378 | char getAccConfig(); |
echo_piyo | 0:bf96e953cdb8 | 379 | char setAccConfig(char regVal); |
echo_piyo | 0:bf96e953cdb8 | 380 | char setAccConfig(char gRange, char bandWidth, char powMode); |
echo_piyo | 0:bf96e953cdb8 | 381 | char setAccRange(unsigned char G); |
echo_piyo | 0:bf96e953cdb8 | 382 | |
echo_piyo | 0:bf96e953cdb8 | 383 | char getMagConfig(); |
echo_piyo | 0:bf96e953cdb8 | 384 | char setMagConfig(char regVal); |
echo_piyo | 0:bf96e953cdb8 | 385 | char setMagConfig(char rate, char oprMode, char powMode); |
echo_piyo | 0:bf96e953cdb8 | 386 | |
echo_piyo | 0:bf96e953cdb8 | 387 | char getGyroConfig_0(); |
echo_piyo | 0:bf96e953cdb8 | 388 | char setGyroConfig_0(char regVal); |
echo_piyo | 0:bf96e953cdb8 | 389 | char setGyroConfig_0(char range, char bandWidth); |
echo_piyo | 0:bf96e953cdb8 | 390 | char getGyroConfig_1(); |
echo_piyo | 0:bf96e953cdb8 | 391 | char setGyroConfig_1(char powMode); |
echo_piyo | 0:bf96e953cdb8 | 392 | char setGyroRange(unsigned short dps); |
echo_piyo | 0:bf96e953cdb8 | 393 | |
echo_piyo | 0:bf96e953cdb8 | 394 | char getAccSleepConfig(); |
echo_piyo | 0:bf96e953cdb8 | 395 | char setAccSleepConfig(char regVal); |
echo_piyo | 0:bf96e953cdb8 | 396 | char setAccSleepConfig(char duration, char mode); |
echo_piyo | 0:bf96e953cdb8 | 397 | |
echo_piyo | 0:bf96e953cdb8 | 398 | char getGyroSleepConfig(); |
echo_piyo | 0:bf96e953cdb8 | 399 | char setGyroSleepConfig(char regVal); |
echo_piyo | 0:bf96e953cdb8 | 400 | char setGyroSleepConfig(char autoSleepDuration, char duration); |
echo_piyo | 0:bf96e953cdb8 | 401 | |
echo_piyo | 0:bf96e953cdb8 | 402 | char getInterruptMask(); |
echo_piyo | 0:bf96e953cdb8 | 403 | char setInterruptMask(char mask); |
echo_piyo | 0:bf96e953cdb8 | 404 | |
echo_piyo | 0:bf96e953cdb8 | 405 | char getInterruptEnable(); |
echo_piyo | 0:bf96e953cdb8 | 406 | char setInterruptEnable(char mask); |
echo_piyo | 0:bf96e953cdb8 | 407 | |
echo_piyo | 0:bf96e953cdb8 | 408 | float getAccAnyMotionThreashold(bool ismg=true); |
echo_piyo | 0:bf96e953cdb8 | 409 | char setAccAnyMotionThreashold(bool ismg, float threashold); |
echo_piyo | 0:bf96e953cdb8 | 410 | |
echo_piyo | 0:bf96e953cdb8 | 411 | char getAccInterruptSettings(); |
echo_piyo | 0:bf96e953cdb8 | 412 | char setAccInterruptSettings(char settings); |
echo_piyo | 0:bf96e953cdb8 | 413 | |
echo_piyo | 0:bf96e953cdb8 | 414 | unsigned short getAccHighGduration(); |
echo_piyo | 0:bf96e953cdb8 | 415 | char setAccHighGduration(short ms); |
echo_piyo | 0:bf96e953cdb8 | 416 | |
echo_piyo | 0:bf96e953cdb8 | 417 | float getAccHighGThreashold(bool ismg=true); |
echo_piyo | 0:bf96e953cdb8 | 418 | char setAccHighGThreashold(bool ismg, float threashold); |
echo_piyo | 0:bf96e953cdb8 | 419 | |
echo_piyo | 0:bf96e953cdb8 | 420 | float getAccNMThreashold(bool ismg=true); |
echo_piyo | 0:bf96e953cdb8 | 421 | char setAccNMThreashold(bool ismg, float threashold); |
echo_piyo | 0:bf96e953cdb8 | 422 | |
echo_piyo | 0:bf96e953cdb8 | 423 | char getAccNMsetting(); |
echo_piyo | 0:bf96e953cdb8 | 424 | char setAccNMsetting(char setting); |
echo_piyo | 0:bf96e953cdb8 | 425 | |
echo_piyo | 0:bf96e953cdb8 | 426 | char getGyroInterruptSettings(); |
echo_piyo | 0:bf96e953cdb8 | 427 | char setGyroInterruptSettings(char settings); |
echo_piyo | 0:bf96e953cdb8 | 428 | |
echo_piyo | 0:bf96e953cdb8 | 429 | char getGyroHighRateXsetting(); |
echo_piyo | 0:bf96e953cdb8 | 430 | void getGyroHighRateXsetting_dps(float &hyst, float &thres); |
echo_piyo | 0:bf96e953cdb8 | 431 | char setGyroHighRateXsetting(char setting); |
echo_piyo | 0:bf96e953cdb8 | 432 | char setGyroHighRateXsetting_dps(float hystVal, float thresVal); |
echo_piyo | 0:bf96e953cdb8 | 433 | float getGyroHighRateXduration(); |
echo_piyo | 0:bf96e953cdb8 | 434 | char setGyroHighRateXduration(float duration); |
echo_piyo | 0:bf96e953cdb8 | 435 | |
echo_piyo | 0:bf96e953cdb8 | 436 | char getGyroHighRateYsetting(); |
echo_piyo | 0:bf96e953cdb8 | 437 | void getGyroHighRateYsetting_dps(float &hyst, float &thres); |
echo_piyo | 0:bf96e953cdb8 | 438 | char setGyroHighRateYsetting(char setting); |
echo_piyo | 0:bf96e953cdb8 | 439 | char setGyroHighRateYsetting_dps(float hystVal, float thresVal); |
echo_piyo | 0:bf96e953cdb8 | 440 | float getGyroHighRateYduration(); |
echo_piyo | 0:bf96e953cdb8 | 441 | char setGyroHighRateYduration(float duration); |
echo_piyo | 0:bf96e953cdb8 | 442 | |
echo_piyo | 0:bf96e953cdb8 | 443 | char getGyroHighRateZsetting(); |
echo_piyo | 0:bf96e953cdb8 | 444 | void getGyroHighRateZsetting_dps(float &hyst, float &thres); |
echo_piyo | 0:bf96e953cdb8 | 445 | char setGyroHighRateZsetting(char setting); |
echo_piyo | 0:bf96e953cdb8 | 446 | char setGyroHighRateZsetting_dps(float hystVal, float thresVal); |
echo_piyo | 0:bf96e953cdb8 | 447 | float getGyroHighRateZduration(); |
echo_piyo | 0:bf96e953cdb8 | 448 | char setGyroHighRateZduration(float duration); |
echo_piyo | 0:bf96e953cdb8 | 449 | |
echo_piyo | 0:bf96e953cdb8 | 450 | float getGyroAnyMotionThreashold(); |
echo_piyo | 0:bf96e953cdb8 | 451 | char setGyroAnyMotionThreashold(float threashold); |
echo_piyo | 0:bf96e953cdb8 | 452 | |
echo_piyo | 0:bf96e953cdb8 | 453 | char getAccAnyMotionSetting(); |
echo_piyo | 0:bf96e953cdb8 | 454 | char setAccAnyMotionSetting(char setting); |
echo_piyo | 0:bf96e953cdb8 | 455 | }; |
echo_piyo | 0:bf96e953cdb8 | 456 | |
echo_piyo | 0:bf96e953cdb8 | 457 | #endif |
echo_piyo | 0:bf96e953cdb8 | 458 | |
echo_piyo | 0:bf96e953cdb8 | 459 | |
echo_piyo | 0:bf96e953cdb8 | 460 | //CLASS:BNO055_CTRL////////////////////////////////////////////////// |
echo_piyo | 0:bf96e953cdb8 | 461 | /* ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 462 | * BNO055_UART_CTRLクラスとBNO055_I2C_CTRLクラスの基底クラス(インターフェース) |
echo_piyo | 0:bf96e953cdb8 | 463 | * UARTとI2Cをヘッダ書き換えなしで実現するために無理するとこうなった |
echo_piyo | 0:bf96e953cdb8 | 464 | */ |
echo_piyo | 0:bf96e953cdb8 | 465 | |
echo_piyo | 0:bf96e953cdb8 | 466 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 467 | * デフォルトコンストラクタ |
echo_piyo | 0:bf96e953cdb8 | 468 | */ |
echo_piyo | 0:bf96e953cdb8 | 469 | BNO055_CTRL::BNO055_CTRL(){ |
echo_piyo | 0:bf96e953cdb8 | 470 | lastError = 0; |
echo_piyo | 0:bf96e953cdb8 | 471 | lastLength = 0; |
echo_piyo | 0:bf96e953cdb8 | 472 | } |
echo_piyo | 0:bf96e953cdb8 | 473 | |
echo_piyo | 0:bf96e953cdb8 | 474 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 475 | * デフォルトデストラクタ |
echo_piyo | 0:bf96e953cdb8 | 476 | */ |
echo_piyo | 0:bf96e953cdb8 | 477 | BNO055_CTRL::~BNO055_CTRL(){} |
echo_piyo | 0:bf96e953cdb8 | 478 | |
echo_piyo | 0:bf96e953cdb8 | 479 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 480 | * 現在のページIDを取得する |
echo_piyo | 0:bf96e953cdb8 | 481 | */ |
echo_piyo | 0:bf96e953cdb8 | 482 | char BNO055_CTRL::getNowPage(){ |
echo_piyo | 0:bf96e953cdb8 | 483 | return page1 ? 1 : 0; |
echo_piyo | 0:bf96e953cdb8 | 484 | } |
echo_piyo | 0:bf96e953cdb8 | 485 | |
echo_piyo | 0:bf96e953cdb8 | 486 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 487 | * UARTまたはI2Cで取得した最後のエラーを取得する:通信がうまくいかないときの原因追及 |
echo_piyo | 0:bf96e953cdb8 | 488 | */ |
echo_piyo | 0:bf96e953cdb8 | 489 | char BNO055_CTRL::getLastError(){ |
echo_piyo | 0:bf96e953cdb8 | 490 | return lastError; |
echo_piyo | 0:bf96e953cdb8 | 491 | } |
echo_piyo | 0:bf96e953cdb8 | 492 | |
echo_piyo | 0:bf96e953cdb8 | 493 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 494 | * UARTまたはI2Cで通信した際の受信バイト数を取得する:通信がうまくいかないときの原因追及 |
echo_piyo | 0:bf96e953cdb8 | 495 | */ |
echo_piyo | 0:bf96e953cdb8 | 496 | char BNO055_CTRL::getLastLength(){ |
echo_piyo | 0:bf96e953cdb8 | 497 | return lastLength; |
echo_piyo | 0:bf96e953cdb8 | 498 | } |
echo_piyo | 0:bf96e953cdb8 | 499 | |
echo_piyo | 0:bf96e953cdb8 | 500 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 501 | * 未実装関数(子クラスで実装される) |
echo_piyo | 0:bf96e953cdb8 | 502 | */ |
echo_piyo | 0:bf96e953cdb8 | 503 | void BNO055_CTRL::init(){} |
echo_piyo | 0:bf96e953cdb8 | 504 | char BNO055_CTRL::rr(bool isPage1, char regAddr){return 0;} |
echo_piyo | 0:bf96e953cdb8 | 505 | char BNO055_CTRL::rrc(bool isPage1, char startRegAddr, char *receiveBytes, char length){return 0;} |
echo_piyo | 0:bf96e953cdb8 | 506 | char BNO055_CTRL::wr(bool isPage1, char regAddr, char wBytes){return 0;} |
echo_piyo | 0:bf96e953cdb8 | 507 | char BNO055_CTRL::wrc(bool isPage1, char startRegAddr, char *Bytes, char length){return 0;} |
echo_piyo | 0:bf96e953cdb8 | 508 | |
echo_piyo | 0:bf96e953cdb8 | 509 | |
echo_piyo | 0:bf96e953cdb8 | 510 | |
echo_piyo | 0:bf96e953cdb8 | 511 | |
echo_piyo | 0:bf96e953cdb8 | 512 | |
echo_piyo | 0:bf96e953cdb8 | 513 | |
echo_piyo | 0:bf96e953cdb8 | 514 | |
echo_piyo | 0:bf96e953cdb8 | 515 | |
echo_piyo | 0:bf96e953cdb8 | 516 | |
echo_piyo | 0:bf96e953cdb8 | 517 | |
echo_piyo | 0:bf96e953cdb8 | 518 | //CLASS:BNO055_UART_CTRL///////////////////////////////////////////// |
echo_piyo | 0:bf96e953cdb8 | 519 | /* ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 520 | * BNO055_CTRLクラス(インターフェース)を継承(実装)したクラス |
echo_piyo | 0:bf96e953cdb8 | 521 | * UARTで命令を送受信するためのコントロール用クラス |
echo_piyo | 0:bf96e953cdb8 | 522 | */ |
echo_piyo | 0:bf96e953cdb8 | 523 | |
echo_piyo | 0:bf96e953cdb8 | 524 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 525 | * BNO055をUARTでコントロールするためのクラス:コンストラクタ |
echo_piyo | 0:bf96e953cdb8 | 526 | */ |
echo_piyo | 0:bf96e953cdb8 | 527 | BNO055_UART_CTRL::BNO055_UART_CTRL(RawSerial *uart){ |
echo_piyo | 0:bf96e953cdb8 | 528 | iface = uart; |
echo_piyo | 0:bf96e953cdb8 | 529 | rxd = 0xFFFF; |
echo_piyo | 0:bf96e953cdb8 | 530 | read_mark = true; |
echo_piyo | 0:bf96e953cdb8 | 531 | |
echo_piyo | 0:bf96e953cdb8 | 532 | page1 = true; |
echo_piyo | 0:bf96e953cdb8 | 533 | |
echo_piyo | 0:bf96e953cdb8 | 534 | ary = new char[BNO055_UART_BUF_MAXLEN + 5]; |
echo_piyo | 0:bf96e953cdb8 | 535 | memset(ary, 0, BNO055_UART_BUF_MAXLEN + 5); |
echo_piyo | 0:bf96e953cdb8 | 536 | lastError = 0; |
echo_piyo | 0:bf96e953cdb8 | 537 | } |
echo_piyo | 0:bf96e953cdb8 | 538 | |
echo_piyo | 0:bf96e953cdb8 | 539 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 540 | * BNO055をUARTでコントロールするためのクラス:デストラクタ |
echo_piyo | 0:bf96e953cdb8 | 541 | */ |
echo_piyo | 0:bf96e953cdb8 | 542 | BNO055_UART_CTRL::~BNO055_UART_CTRL(){ |
echo_piyo | 0:bf96e953cdb8 | 543 | delete iface; |
echo_piyo | 0:bf96e953cdb8 | 544 | } |
echo_piyo | 0:bf96e953cdb8 | 545 | |
echo_piyo | 0:bf96e953cdb8 | 546 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 547 | * UART受信割り込み用関数 |
echo_piyo | 0:bf96e953cdb8 | 548 | * RX受信トリガがONになると、カウンタを加算する |
echo_piyo | 0:bf96e953cdb8 | 549 | */ |
echo_piyo | 0:bf96e953cdb8 | 550 | void BNO055_UART_CTRL::rxInterrupt(){ |
echo_piyo | 0:bf96e953cdb8 | 551 | if(read_mark){ |
echo_piyo | 0:bf96e953cdb8 | 552 | rxd = iface->getc(); |
echo_piyo | 0:bf96e953cdb8 | 553 | read_mark = false; |
echo_piyo | 0:bf96e953cdb8 | 554 | } |
echo_piyo | 0:bf96e953cdb8 | 555 | } |
echo_piyo | 0:bf96e953cdb8 | 556 | |
echo_piyo | 0:bf96e953cdb8 | 557 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 558 | * <UART> |
echo_piyo | 0:bf96e953cdb8 | 559 | * レジスタの内容を読み取り(1byteのみ) |
echo_piyo | 0:bf96e953cdb8 | 560 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 561 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 562 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 563 | * それ以外 成功した際に取得したデータ |
echo_piyo | 0:bf96e953cdb8 | 564 | */ |
echo_piyo | 0:bf96e953cdb8 | 565 | char BNO055_UART_CTRL::rr(bool isPage1, char regAddr){ |
echo_piyo | 0:bf96e953cdb8 | 566 | //ページが異なるならページ変更命令を発行 |
echo_piyo | 0:bf96e953cdb8 | 567 | if(page1 != isPage1){ |
echo_piyo | 0:bf96e953cdb8 | 568 | wr(page1, BNO055_PAGE_ID, (isPage1) ? 1 : 0); |
echo_piyo | 0:bf96e953cdb8 | 569 | page1 = isPage1; |
echo_piyo | 0:bf96e953cdb8 | 570 | } |
echo_piyo | 0:bf96e953cdb8 | 571 | |
echo_piyo | 0:bf96e953cdb8 | 572 | //送信可能になるまで待つ |
echo_piyo | 0:bf96e953cdb8 | 573 | do{wait_ms(1);}while(!iface->writeable()); |
echo_piyo | 0:bf96e953cdb8 | 574 | |
echo_piyo | 0:bf96e953cdb8 | 575 | //コマンドをセット |
echo_piyo | 0:bf96e953cdb8 | 576 | ary[0] = 0xAA; //StartByte(固定) |
echo_piyo | 0:bf96e953cdb8 | 577 | ary[1] = 0x01; //読み取り |
echo_piyo | 0:bf96e953cdb8 | 578 | ary[2] = regAddr; //レジスタアドレス |
echo_piyo | 0:bf96e953cdb8 | 579 | ary[3] = 1; //バイト長 |
echo_piyo | 0:bf96e953cdb8 | 580 | |
echo_piyo | 0:bf96e953cdb8 | 581 | //送信 |
echo_piyo | 0:bf96e953cdb8 | 582 | iface->putc(ary[0]); |
echo_piyo | 0:bf96e953cdb8 | 583 | iface->putc(ary[1]); |
echo_piyo | 0:bf96e953cdb8 | 584 | iface->putc(ary[2]); |
echo_piyo | 0:bf96e953cdb8 | 585 | iface->putc(ary[3]); |
echo_piyo | 0:bf96e953cdb8 | 586 | |
echo_piyo | 0:bf96e953cdb8 | 587 | //レスポンスを受信するまで待つ |
echo_piyo | 0:bf96e953cdb8 | 588 | while(read_mark) wait_us(100); |
echo_piyo | 0:bf96e953cdb8 | 589 | |
echo_piyo | 0:bf96e953cdb8 | 590 | lastError = 0; |
echo_piyo | 0:bf96e953cdb8 | 591 | memset(ary, 0, BNO055_UART_BUF_MAXLEN + 5); //配列ゼロクリア |
echo_piyo | 0:bf96e953cdb8 | 592 | |
echo_piyo | 0:bf96e953cdb8 | 593 | ary[0] = rxd & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 594 | |
echo_piyo | 0:bf96e953cdb8 | 595 | //残りを受信 |
echo_piyo | 0:bf96e953cdb8 | 596 | int i = 1; |
echo_piyo | 0:bf96e953cdb8 | 597 | int cnt = (ary[0] == 0xBB) ? 2 : 1; |
echo_piyo | 0:bf96e953cdb8 | 598 | while(i < cnt && iface->readable()){ |
echo_piyo | 0:bf96e953cdb8 | 599 | ary[i++] = iface->getc(); |
echo_piyo | 0:bf96e953cdb8 | 600 | } |
echo_piyo | 0:bf96e953cdb8 | 601 | |
echo_piyo | 0:bf96e953cdb8 | 602 | //レスポンスが0xBB以外:通信失敗 |
echo_piyo | 0:bf96e953cdb8 | 603 | if(ary[0] != 0xBB){ |
echo_piyo | 0:bf96e953cdb8 | 604 | lastLength = 2; |
echo_piyo | 0:bf96e953cdb8 | 605 | lastError = ary[1]; |
echo_piyo | 0:bf96e953cdb8 | 606 | //受信用割り込みマークをリセット |
echo_piyo | 0:bf96e953cdb8 | 607 | rxd = 0xFFFF; |
echo_piyo | 0:bf96e953cdb8 | 608 | read_mark = true; |
echo_piyo | 0:bf96e953cdb8 | 609 | return -1; |
echo_piyo | 0:bf96e953cdb8 | 610 | } |
echo_piyo | 0:bf96e953cdb8 | 611 | |
echo_piyo | 0:bf96e953cdb8 | 612 | lastLength = ary[1] + 2; |
echo_piyo | 0:bf96e953cdb8 | 613 | |
echo_piyo | 0:bf96e953cdb8 | 614 | //受信用割り込みマークをリセット |
echo_piyo | 0:bf96e953cdb8 | 615 | rxd = 0xFFFF; |
echo_piyo | 0:bf96e953cdb8 | 616 | read_mark = true; |
echo_piyo | 0:bf96e953cdb8 | 617 | |
echo_piyo | 0:bf96e953cdb8 | 618 | //通信成功時、取得データを返す |
echo_piyo | 0:bf96e953cdb8 | 619 | return ary[2]; |
echo_piyo | 0:bf96e953cdb8 | 620 | } |
echo_piyo | 0:bf96e953cdb8 | 621 | |
echo_piyo | 0:bf96e953cdb8 | 622 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 623 | * <UART> |
echo_piyo | 0:bf96e953cdb8 | 624 | * レジスタの内容を読み取り(複数可) |
echo_piyo | 0:bf96e953cdb8 | 625 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 626 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 627 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 628 | * -2 返答バイト不一致 |
echo_piyo | 0:bf96e953cdb8 | 629 | * -4 レスポンスエラー |
echo_piyo | 0:bf96e953cdb8 | 630 | * それ以外 成功した際の戻り値バイト数 |
echo_piyo | 0:bf96e953cdb8 | 631 | */ |
echo_piyo | 0:bf96e953cdb8 | 632 | char BNO055_UART_CTRL::rrc(bool isPage1, char startRegAddr, char *receiveBytes, char length){ |
echo_piyo | 0:bf96e953cdb8 | 633 | //読み取りバイト数が1未満またはBNO055_UART_BUF_MAXLEN以上はバッファが足りないので読み取れない |
echo_piyo | 0:bf96e953cdb8 | 634 | if(length < 1 || length > BNO055_UART_BUF_MAXLEN) return -1; |
echo_piyo | 0:bf96e953cdb8 | 635 | |
echo_piyo | 0:bf96e953cdb8 | 636 | //ページが異なるならページ変更命令を発行 |
echo_piyo | 0:bf96e953cdb8 | 637 | if(page1 != isPage1){ |
echo_piyo | 0:bf96e953cdb8 | 638 | wr(page1, BNO055_PAGE_ID, (isPage1) ? 1 : 0); |
echo_piyo | 0:bf96e953cdb8 | 639 | page1 = isPage1; |
echo_piyo | 0:bf96e953cdb8 | 640 | } |
echo_piyo | 0:bf96e953cdb8 | 641 | |
echo_piyo | 0:bf96e953cdb8 | 642 | //送信可能になるまで待つ |
echo_piyo | 0:bf96e953cdb8 | 643 | do{wait_ms(1);}while(!iface->writeable()); |
echo_piyo | 0:bf96e953cdb8 | 644 | |
echo_piyo | 0:bf96e953cdb8 | 645 | //コマンドをセット |
echo_piyo | 0:bf96e953cdb8 | 646 | ary[0] = 0xAA; //StartByte(固定) |
echo_piyo | 0:bf96e953cdb8 | 647 | ary[1] = 0x01; //読み取り |
echo_piyo | 0:bf96e953cdb8 | 648 | ary[2] = startRegAddr; //読み取り開始レジスタアドレス |
echo_piyo | 0:bf96e953cdb8 | 649 | ary[3] = length; //バイト長 |
echo_piyo | 0:bf96e953cdb8 | 650 | |
echo_piyo | 0:bf96e953cdb8 | 651 | //送信 |
echo_piyo | 0:bf96e953cdb8 | 652 | iface->putc(ary[0]); |
echo_piyo | 0:bf96e953cdb8 | 653 | iface->putc(ary[1]); |
echo_piyo | 0:bf96e953cdb8 | 654 | iface->putc(ary[2]); |
echo_piyo | 0:bf96e953cdb8 | 655 | iface->putc(ary[3]); |
echo_piyo | 0:bf96e953cdb8 | 656 | |
echo_piyo | 0:bf96e953cdb8 | 657 | //レスポンスを受信するまで待つ |
echo_piyo | 0:bf96e953cdb8 | 658 | while(read_mark) wait_us(100); |
echo_piyo | 0:bf96e953cdb8 | 659 | |
echo_piyo | 0:bf96e953cdb8 | 660 | lastError = 0; |
echo_piyo | 0:bf96e953cdb8 | 661 | memset(ary, 0, BNO055_UART_BUF_MAXLEN + 5); //配列ゼロクリア |
echo_piyo | 0:bf96e953cdb8 | 662 | |
echo_piyo | 0:bf96e953cdb8 | 663 | ary[0] = rxd & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 664 | |
echo_piyo | 0:bf96e953cdb8 | 665 | //残りを受信 |
echo_piyo | 0:bf96e953cdb8 | 666 | int i = 1; |
echo_piyo | 0:bf96e953cdb8 | 667 | int cnt = (ary[0] == 0xBB) ? 2 : 1; |
echo_piyo | 0:bf96e953cdb8 | 668 | while(i < cnt && iface->readable()){ |
echo_piyo | 0:bf96e953cdb8 | 669 | ary[i++] = iface->getc(); |
echo_piyo | 0:bf96e953cdb8 | 670 | } |
echo_piyo | 0:bf96e953cdb8 | 671 | |
echo_piyo | 0:bf96e953cdb8 | 672 | //レスポンスが0xBB以外:通信失敗 |
echo_piyo | 0:bf96e953cdb8 | 673 | if(ary[0] != 0xBB){ |
echo_piyo | 0:bf96e953cdb8 | 674 | lastLength = 2; |
echo_piyo | 0:bf96e953cdb8 | 675 | lastError = ary[1]; |
echo_piyo | 0:bf96e953cdb8 | 676 | rxd = 0xFFFF; |
echo_piyo | 0:bf96e953cdb8 | 677 | read_mark = true; |
echo_piyo | 0:bf96e953cdb8 | 678 | return -1; |
echo_piyo | 0:bf96e953cdb8 | 679 | } |
echo_piyo | 0:bf96e953cdb8 | 680 | |
echo_piyo | 0:bf96e953cdb8 | 681 | //返答バイト長がlengthと一致しない:通信失敗 |
echo_piyo | 0:bf96e953cdb8 | 682 | if(ary[1] != length){ |
echo_piyo | 0:bf96e953cdb8 | 683 | lastLength = ary[1]; |
echo_piyo | 0:bf96e953cdb8 | 684 | lastError = 0; |
echo_piyo | 0:bf96e953cdb8 | 685 | //受信用割り込みマークをリセット |
echo_piyo | 0:bf96e953cdb8 | 686 | rxd = 0xFFFF; |
echo_piyo | 0:bf96e953cdb8 | 687 | read_mark = true; |
echo_piyo | 0:bf96e953cdb8 | 688 | return -2; |
echo_piyo | 0:bf96e953cdb8 | 689 | } |
echo_piyo | 0:bf96e953cdb8 | 690 | |
echo_piyo | 0:bf96e953cdb8 | 691 | lastLength = ary[1] + 2; |
echo_piyo | 0:bf96e953cdb8 | 692 | |
echo_piyo | 0:bf96e953cdb8 | 693 | memcpy(receiveBytes, ary+2, ary[1]); |
echo_piyo | 0:bf96e953cdb8 | 694 | |
echo_piyo | 0:bf96e953cdb8 | 695 | //受信用割り込みマークをリセット |
echo_piyo | 0:bf96e953cdb8 | 696 | rxd = 0xFFFF; |
echo_piyo | 0:bf96e953cdb8 | 697 | read_mark = true; |
echo_piyo | 0:bf96e953cdb8 | 698 | |
echo_piyo | 0:bf96e953cdb8 | 699 | return ary[1]; |
echo_piyo | 0:bf96e953cdb8 | 700 | } |
echo_piyo | 0:bf96e953cdb8 | 701 | |
echo_piyo | 0:bf96e953cdb8 | 702 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 703 | * <UART> |
echo_piyo | 0:bf96e953cdb8 | 704 | * レジスタ書き込み(1byteのみ) |
echo_piyo | 0:bf96e953cdb8 | 705 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 706 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 707 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 708 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 709 | */ |
echo_piyo | 0:bf96e953cdb8 | 710 | char BNO055_UART_CTRL::wr(bool isPage1, char regAddr, char wBytes){ |
echo_piyo | 0:bf96e953cdb8 | 711 | //ページが異なるならページ変更命令を発行(再帰処理) |
echo_piyo | 0:bf96e953cdb8 | 712 | if(page1 != isPage1){ |
echo_piyo | 0:bf96e953cdb8 | 713 | wr(page1, BNO055_PAGE_ID, (isPage1) ? 1 : 0); |
echo_piyo | 0:bf96e953cdb8 | 714 | page1 = isPage1; |
echo_piyo | 0:bf96e953cdb8 | 715 | } |
echo_piyo | 0:bf96e953cdb8 | 716 | |
echo_piyo | 0:bf96e953cdb8 | 717 | //送信可能になるまで待つ |
echo_piyo | 0:bf96e953cdb8 | 718 | do{wait_ms(1);}while(!iface->writeable()); |
echo_piyo | 0:bf96e953cdb8 | 719 | |
echo_piyo | 0:bf96e953cdb8 | 720 | //コマンドをセット |
echo_piyo | 0:bf96e953cdb8 | 721 | ary[0] = 0xAA; //StartByte(固定) |
echo_piyo | 0:bf96e953cdb8 | 722 | ary[1] = 0x00; //書き込み |
echo_piyo | 0:bf96e953cdb8 | 723 | ary[2] = regAddr; //レジスタアドレス |
echo_piyo | 0:bf96e953cdb8 | 724 | ary[3] = 1; //バイト長 |
echo_piyo | 0:bf96e953cdb8 | 725 | ary[4] = wBytes; //送信データ |
echo_piyo | 0:bf96e953cdb8 | 726 | |
echo_piyo | 0:bf96e953cdb8 | 727 | //送信 |
echo_piyo | 0:bf96e953cdb8 | 728 | iface->putc(ary[0]); |
echo_piyo | 0:bf96e953cdb8 | 729 | iface->putc(ary[1]); |
echo_piyo | 0:bf96e953cdb8 | 730 | iface->putc(ary[2]); |
echo_piyo | 0:bf96e953cdb8 | 731 | iface->putc(ary[3]); |
echo_piyo | 0:bf96e953cdb8 | 732 | iface->putc(ary[4]); |
echo_piyo | 0:bf96e953cdb8 | 733 | |
echo_piyo | 0:bf96e953cdb8 | 734 | //システムリブートが発生するレジスタの場合は1200ms待つ |
echo_piyo | 0:bf96e953cdb8 | 735 | if(regAddr == 0x3F) wait_ms(1200); |
echo_piyo | 0:bf96e953cdb8 | 736 | |
echo_piyo | 0:bf96e953cdb8 | 737 | //レスポンスを受信するまで待つ |
echo_piyo | 0:bf96e953cdb8 | 738 | while(read_mark) wait_us(100); |
echo_piyo | 0:bf96e953cdb8 | 739 | |
echo_piyo | 0:bf96e953cdb8 | 740 | lastError = 0; |
echo_piyo | 0:bf96e953cdb8 | 741 | memset(ary, 0, BNO055_UART_BUF_MAXLEN + 5); //配列ゼロクリア |
echo_piyo | 0:bf96e953cdb8 | 742 | |
echo_piyo | 0:bf96e953cdb8 | 743 | ary[0] = rxd & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 744 | |
echo_piyo | 0:bf96e953cdb8 | 745 | //残りを受信 |
echo_piyo | 0:bf96e953cdb8 | 746 | while(iface->readable()){ |
echo_piyo | 0:bf96e953cdb8 | 747 | ary[1] = iface->getc(); |
echo_piyo | 0:bf96e953cdb8 | 748 | } |
echo_piyo | 0:bf96e953cdb8 | 749 | |
echo_piyo | 0:bf96e953cdb8 | 750 | //レスポンスが0xEE以外もしくはステータスが0x01以外:書き込み失敗 |
echo_piyo | 0:bf96e953cdb8 | 751 | if(ary[0] != 0xEE || ary[1] != 0x01){ |
echo_piyo | 0:bf96e953cdb8 | 752 | lastLength = 2; |
echo_piyo | 0:bf96e953cdb8 | 753 | lastError = ary[1]; |
echo_piyo | 0:bf96e953cdb8 | 754 | //受信用割り込みマークをリセット |
echo_piyo | 0:bf96e953cdb8 | 755 | rxd = 0xFFFF; |
echo_piyo | 0:bf96e953cdb8 | 756 | read_mark = true; |
echo_piyo | 0:bf96e953cdb8 | 757 | return -1; |
echo_piyo | 0:bf96e953cdb8 | 758 | } |
echo_piyo | 0:bf96e953cdb8 | 759 | |
echo_piyo | 0:bf96e953cdb8 | 760 | //受信用割り込みマークをリセット |
echo_piyo | 0:bf96e953cdb8 | 761 | rxd = 0xFFFF; |
echo_piyo | 0:bf96e953cdb8 | 762 | read_mark = true; |
echo_piyo | 0:bf96e953cdb8 | 763 | |
echo_piyo | 0:bf96e953cdb8 | 764 | return 1; |
echo_piyo | 0:bf96e953cdb8 | 765 | } |
echo_piyo | 0:bf96e953cdb8 | 766 | |
echo_piyo | 0:bf96e953cdb8 | 767 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 768 | * <UART> |
echo_piyo | 0:bf96e953cdb8 | 769 | * レジスタ書き込み(複数可) |
echo_piyo | 0:bf96e953cdb8 | 770 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 771 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 772 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 773 | * -4 レスポンスエラー |
echo_piyo | 0:bf96e953cdb8 | 774 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 775 | */ |
echo_piyo | 0:bf96e953cdb8 | 776 | char BNO055_UART_CTRL::wrc(bool isPage1, char startRegAddr, char *Bytes, char length){ |
echo_piyo | 0:bf96e953cdb8 | 777 | //書き込みバイト数が1未満またはBNO055_UART_BUF_MAXLEN以上はバッファが足りないので読み取れない |
echo_piyo | 0:bf96e953cdb8 | 778 | if(length < 1 || length > BNO055_UART_BUF_MAXLEN) return -1; |
echo_piyo | 0:bf96e953cdb8 | 779 | |
echo_piyo | 0:bf96e953cdb8 | 780 | //ページが異なるならページ変更命令を発行(再帰処理) |
echo_piyo | 0:bf96e953cdb8 | 781 | if(page1 != isPage1){ |
echo_piyo | 0:bf96e953cdb8 | 782 | wr(page1, BNO055_PAGE_ID, (isPage1) ? 1 : 0); |
echo_piyo | 0:bf96e953cdb8 | 783 | page1 = isPage1; |
echo_piyo | 0:bf96e953cdb8 | 784 | } |
echo_piyo | 0:bf96e953cdb8 | 785 | |
echo_piyo | 0:bf96e953cdb8 | 786 | //送信可能になるまで待つ |
echo_piyo | 0:bf96e953cdb8 | 787 | do{wait_ms(1);}while(!iface->writeable()); |
echo_piyo | 0:bf96e953cdb8 | 788 | |
echo_piyo | 0:bf96e953cdb8 | 789 | //コマンドをセット |
echo_piyo | 0:bf96e953cdb8 | 790 | ary[0] = 0xAA; //StartByte(固定) |
echo_piyo | 0:bf96e953cdb8 | 791 | ary[1] = 0x00; //書き込み |
echo_piyo | 0:bf96e953cdb8 | 792 | ary[2] = startRegAddr; //レジスタアドレス |
echo_piyo | 0:bf96e953cdb8 | 793 | ary[3] = length; //バイト長 |
echo_piyo | 0:bf96e953cdb8 | 794 | |
echo_piyo | 0:bf96e953cdb8 | 795 | //前部分送信 |
echo_piyo | 0:bf96e953cdb8 | 796 | iface->putc(ary[0]); |
echo_piyo | 0:bf96e953cdb8 | 797 | iface->putc(ary[1]); |
echo_piyo | 0:bf96e953cdb8 | 798 | iface->putc(ary[2]); |
echo_piyo | 0:bf96e953cdb8 | 799 | iface->putc(ary[3]); |
echo_piyo | 0:bf96e953cdb8 | 800 | |
echo_piyo | 0:bf96e953cdb8 | 801 | //データ内容送信 |
echo_piyo | 0:bf96e953cdb8 | 802 | for(int cnt=0; cnt<length; cnt++){ |
echo_piyo | 0:bf96e953cdb8 | 803 | iface->putc(Bytes[cnt]); |
echo_piyo | 0:bf96e953cdb8 | 804 | } |
echo_piyo | 0:bf96e953cdb8 | 805 | |
echo_piyo | 0:bf96e953cdb8 | 806 | //レスポンスを受信するまで待つ |
echo_piyo | 0:bf96e953cdb8 | 807 | while(read_mark) wait_us(100); |
echo_piyo | 0:bf96e953cdb8 | 808 | |
echo_piyo | 0:bf96e953cdb8 | 809 | lastError = 0; |
echo_piyo | 0:bf96e953cdb8 | 810 | memset(ary, 0, BNO055_UART_BUF_MAXLEN + 5); //配列ゼロクリア |
echo_piyo | 0:bf96e953cdb8 | 811 | |
echo_piyo | 0:bf96e953cdb8 | 812 | ary[0] = rxd & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 813 | |
echo_piyo | 0:bf96e953cdb8 | 814 | //残りを受信 |
echo_piyo | 0:bf96e953cdb8 | 815 | while(iface->readable()){ |
echo_piyo | 0:bf96e953cdb8 | 816 | ary[1] = iface->getc(); |
echo_piyo | 0:bf96e953cdb8 | 817 | } |
echo_piyo | 0:bf96e953cdb8 | 818 | |
echo_piyo | 0:bf96e953cdb8 | 819 | //レスポンスが0xEE以外もしくはステータスが0x01以外:書き込み失敗 |
echo_piyo | 0:bf96e953cdb8 | 820 | if(ary[0] != 0xEE || ary[1] != 0x01){ |
echo_piyo | 0:bf96e953cdb8 | 821 | lastLength = 2; |
echo_piyo | 0:bf96e953cdb8 | 822 | lastError = ary[1]; |
echo_piyo | 0:bf96e953cdb8 | 823 | //受信用割り込みマークをリセット |
echo_piyo | 0:bf96e953cdb8 | 824 | rxd = 0xFFFF; |
echo_piyo | 0:bf96e953cdb8 | 825 | read_mark = true; |
echo_piyo | 0:bf96e953cdb8 | 826 | return -1; |
echo_piyo | 0:bf96e953cdb8 | 827 | } |
echo_piyo | 0:bf96e953cdb8 | 828 | |
echo_piyo | 0:bf96e953cdb8 | 829 | //受信用割り込みマークをリセット |
echo_piyo | 0:bf96e953cdb8 | 830 | rxd = 0xFFFF; |
echo_piyo | 0:bf96e953cdb8 | 831 | read_mark = true; |
echo_piyo | 0:bf96e953cdb8 | 832 | |
echo_piyo | 0:bf96e953cdb8 | 833 | return 1; |
echo_piyo | 0:bf96e953cdb8 | 834 | } |
echo_piyo | 0:bf96e953cdb8 | 835 | |
echo_piyo | 0:bf96e953cdb8 | 836 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 837 | * <UART> |
echo_piyo | 0:bf96e953cdb8 | 838 | * インターフェース設定を初期化する |
echo_piyo | 0:bf96e953cdb8 | 839 | */ |
echo_piyo | 0:bf96e953cdb8 | 840 | void BNO055_UART_CTRL::init(){ |
echo_piyo | 0:bf96e953cdb8 | 841 | iface->format(); //8N1 = default |
echo_piyo | 0:bf96e953cdb8 | 842 | iface->baud(115200); |
echo_piyo | 0:bf96e953cdb8 | 843 | wait_ms(5); |
echo_piyo | 0:bf96e953cdb8 | 844 | iface->attach(this, &BNO055_UART_CTRL::rxInterrupt); |
echo_piyo | 0:bf96e953cdb8 | 845 | |
echo_piyo | 0:bf96e953cdb8 | 846 | //送信可能になるまで待つ |
echo_piyo | 0:bf96e953cdb8 | 847 | do{wait_ms(1);}while(!iface->writeable()); |
echo_piyo | 0:bf96e953cdb8 | 848 | |
echo_piyo | 0:bf96e953cdb8 | 849 | //UARTリセット時に0xFFがつく現象および前回送信時の残りがあるため同期がとれない |
echo_piyo | 0:bf96e953cdb8 | 850 | //複数回読み取りを行い、正しいレスポンス(0xBB)が返るまで送信 |
echo_piyo | 0:bf96e953cdb8 | 851 | iface->putc(0x01); //dummy |
echo_piyo | 0:bf96e953cdb8 | 852 | iface->putc(0x01); //dummy |
echo_piyo | 0:bf96e953cdb8 | 853 | iface->putc(0x01); //dummy |
echo_piyo | 0:bf96e953cdb8 | 854 | iface->putc(0x01); //dummy |
echo_piyo | 0:bf96e953cdb8 | 855 | |
echo_piyo | 0:bf96e953cdb8 | 856 | //レスポンスを受信するまで待つ |
echo_piyo | 0:bf96e953cdb8 | 857 | while(read_mark) wait_us(100); |
echo_piyo | 0:bf96e953cdb8 | 858 | |
echo_piyo | 0:bf96e953cdb8 | 859 | char rslt = rxd & 0xFF; //レスポンス |
echo_piyo | 0:bf96e953cdb8 | 860 | |
echo_piyo | 0:bf96e953cdb8 | 861 | do{ |
echo_piyo | 0:bf96e953cdb8 | 862 | //レスポンスが異常:残りの情報を無視 |
echo_piyo | 0:bf96e953cdb8 | 863 | if(rslt != 0xBB){ |
echo_piyo | 0:bf96e953cdb8 | 864 | while(iface->readable()){ |
echo_piyo | 0:bf96e953cdb8 | 865 | iface->getc(); |
echo_piyo | 0:bf96e953cdb8 | 866 | } |
echo_piyo | 0:bf96e953cdb8 | 867 | } |
echo_piyo | 0:bf96e953cdb8 | 868 | |
echo_piyo | 0:bf96e953cdb8 | 869 | //受信用割り込みマークをリセット |
echo_piyo | 0:bf96e953cdb8 | 870 | rxd = 0xFFFF; |
echo_piyo | 0:bf96e953cdb8 | 871 | read_mark = true; |
echo_piyo | 0:bf96e953cdb8 | 872 | |
echo_piyo | 0:bf96e953cdb8 | 873 | //送信可能になるまで待つ |
echo_piyo | 0:bf96e953cdb8 | 874 | do{wait_ms(5);}while(!iface->writeable()); |
echo_piyo | 0:bf96e953cdb8 | 875 | |
echo_piyo | 0:bf96e953cdb8 | 876 | iface->putc(0xAA); //START |
echo_piyo | 0:bf96e953cdb8 | 877 | iface->putc(0x01); //読み取り |
echo_piyo | 0:bf96e953cdb8 | 878 | iface->putc(0x07); //ページID |
echo_piyo | 0:bf96e953cdb8 | 879 | iface->putc(0x01); //length 1byte |
echo_piyo | 0:bf96e953cdb8 | 880 | |
echo_piyo | 0:bf96e953cdb8 | 881 | //レスポンスを受信するまで待つ |
echo_piyo | 0:bf96e953cdb8 | 882 | while(read_mark) wait_us(100); |
echo_piyo | 0:bf96e953cdb8 | 883 | |
echo_piyo | 0:bf96e953cdb8 | 884 | rslt = rxd & 0xFF; //レスポンス |
echo_piyo | 0:bf96e953cdb8 | 885 | |
echo_piyo | 0:bf96e953cdb8 | 886 | }while(rslt != 0xBB); |
echo_piyo | 0:bf96e953cdb8 | 887 | |
echo_piyo | 0:bf96e953cdb8 | 888 | //残りの情報を無視 |
echo_piyo | 0:bf96e953cdb8 | 889 | while(iface->readable()){ |
echo_piyo | 0:bf96e953cdb8 | 890 | iface->getc(); |
echo_piyo | 0:bf96e953cdb8 | 891 | } |
echo_piyo | 0:bf96e953cdb8 | 892 | |
echo_piyo | 0:bf96e953cdb8 | 893 | //受信用割り込みマークをリセット |
echo_piyo | 0:bf96e953cdb8 | 894 | rxd = 0xFFFF; |
echo_piyo | 0:bf96e953cdb8 | 895 | read_mark = true; |
echo_piyo | 0:bf96e953cdb8 | 896 | } |
echo_piyo | 0:bf96e953cdb8 | 897 | |
echo_piyo | 0:bf96e953cdb8 | 898 | |
echo_piyo | 0:bf96e953cdb8 | 899 | |
echo_piyo | 0:bf96e953cdb8 | 900 | |
echo_piyo | 0:bf96e953cdb8 | 901 | |
echo_piyo | 0:bf96e953cdb8 | 902 | |
echo_piyo | 0:bf96e953cdb8 | 903 | |
echo_piyo | 0:bf96e953cdb8 | 904 | |
echo_piyo | 0:bf96e953cdb8 | 905 | //CLASS:BNO055_I2C_CTRL////////////////////////////////////////////// |
echo_piyo | 0:bf96e953cdb8 | 906 | /* ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 907 | * BNO055_CTRLクラス(インターフェース)を継承(実装)したクラス |
echo_piyo | 0:bf96e953cdb8 | 908 | * I2Cで命令を送受信するためのコントロール用クラス |
echo_piyo | 0:bf96e953cdb8 | 909 | */ |
echo_piyo | 0:bf96e953cdb8 | 910 | |
echo_piyo | 0:bf96e953cdb8 | 911 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 912 | * BNO055をI2Cでコントロールするためのクラス:コンストラクタ |
echo_piyo | 0:bf96e953cdb8 | 913 | */ |
echo_piyo | 0:bf96e953cdb8 | 914 | BNO055_I2C_CTRL::BNO055_I2C_CTRL(I2C* iic, char addr, unsigned int freq){ |
echo_piyo | 0:bf96e953cdb8 | 915 | iface = iic; |
echo_piyo | 0:bf96e953cdb8 | 916 | i2c_writeAddr = addr << 1; |
echo_piyo | 0:bf96e953cdb8 | 917 | i2c_readAddr = i2c_writeAddr + 1; |
echo_piyo | 0:bf96e953cdb8 | 918 | i2c_freq = freq; |
echo_piyo | 0:bf96e953cdb8 | 919 | page1 = true; |
echo_piyo | 0:bf96e953cdb8 | 920 | ary = new char[2]; |
echo_piyo | 0:bf96e953cdb8 | 921 | memset(ary, 0, 2); |
echo_piyo | 0:bf96e953cdb8 | 922 | lastError = 0; |
echo_piyo | 0:bf96e953cdb8 | 923 | } |
echo_piyo | 0:bf96e953cdb8 | 924 | |
echo_piyo | 0:bf96e953cdb8 | 925 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 926 | * BNO055をI2Cでコントロールするためのクラス:デストラクタ |
echo_piyo | 0:bf96e953cdb8 | 927 | */ |
echo_piyo | 0:bf96e953cdb8 | 928 | BNO055_I2C_CTRL::~BNO055_I2C_CTRL(){ |
echo_piyo | 0:bf96e953cdb8 | 929 | delete iface; |
echo_piyo | 0:bf96e953cdb8 | 930 | delete[] ary; |
echo_piyo | 0:bf96e953cdb8 | 931 | } |
echo_piyo | 0:bf96e953cdb8 | 932 | |
echo_piyo | 0:bf96e953cdb8 | 933 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 934 | * <I2C> |
echo_piyo | 0:bf96e953cdb8 | 935 | * レジスタの内容を読み取り(1byteのみ) |
echo_piyo | 0:bf96e953cdb8 | 936 | */ |
echo_piyo | 0:bf96e953cdb8 | 937 | char BNO055_I2C_CTRL::rr(bool isPage1, char regAddr){ |
echo_piyo | 0:bf96e953cdb8 | 938 | //ページが異なるならページ変更命令を発行 |
echo_piyo | 0:bf96e953cdb8 | 939 | if(page1 != isPage1){ |
echo_piyo | 0:bf96e953cdb8 | 940 | ary[0] = BNO055_PAGE_ID; |
echo_piyo | 0:bf96e953cdb8 | 941 | ary[1] = (isPage1) ? 1 : 0; |
echo_piyo | 0:bf96e953cdb8 | 942 | page1 = isPage1; |
echo_piyo | 0:bf96e953cdb8 | 943 | iface->write(i2c_writeAddr, ary, 2); |
echo_piyo | 0:bf96e953cdb8 | 944 | } |
echo_piyo | 0:bf96e953cdb8 | 945 | |
echo_piyo | 0:bf96e953cdb8 | 946 | ary[0] = regAddr; |
echo_piyo | 0:bf96e953cdb8 | 947 | iface->write(i2c_writeAddr, ary, 1, true); |
echo_piyo | 0:bf96e953cdb8 | 948 | iface->read(i2c_readAddr, ary, 1, false); |
echo_piyo | 0:bf96e953cdb8 | 949 | |
echo_piyo | 0:bf96e953cdb8 | 950 | return ary[0]; |
echo_piyo | 0:bf96e953cdb8 | 951 | } |
echo_piyo | 0:bf96e953cdb8 | 952 | |
echo_piyo | 0:bf96e953cdb8 | 953 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 954 | * <I2C> |
echo_piyo | 0:bf96e953cdb8 | 955 | * レジスタの内容を読み取り(複数可) |
echo_piyo | 0:bf96e953cdb8 | 956 | */ |
echo_piyo | 0:bf96e953cdb8 | 957 | char BNO055_I2C_CTRL::rrc(bool isPage1, char startRegAddr, char *receiveBytes, char length){ |
echo_piyo | 0:bf96e953cdb8 | 958 | //読み取りバイト数が1未満 |
echo_piyo | 0:bf96e953cdb8 | 959 | if(length < 1) return -1; |
echo_piyo | 0:bf96e953cdb8 | 960 | |
echo_piyo | 0:bf96e953cdb8 | 961 | //ページが異なるならページ変更命令を発行 |
echo_piyo | 0:bf96e953cdb8 | 962 | if(page1 != isPage1){ |
echo_piyo | 0:bf96e953cdb8 | 963 | ary[0] = BNO055_PAGE_ID; |
echo_piyo | 0:bf96e953cdb8 | 964 | ary[1] = (isPage1) ? 1 : 0; |
echo_piyo | 0:bf96e953cdb8 | 965 | page1 = isPage1; |
echo_piyo | 0:bf96e953cdb8 | 966 | iface->write(i2c_writeAddr, ary, 2); |
echo_piyo | 0:bf96e953cdb8 | 967 | } |
echo_piyo | 0:bf96e953cdb8 | 968 | |
echo_piyo | 0:bf96e953cdb8 | 969 | ary[0] = startRegAddr; |
echo_piyo | 0:bf96e953cdb8 | 970 | iface->write(i2c_writeAddr, ary, 1, true); |
echo_piyo | 0:bf96e953cdb8 | 971 | iface->read(i2c_readAddr, receiveBytes, length, false); |
echo_piyo | 0:bf96e953cdb8 | 972 | |
echo_piyo | 0:bf96e953cdb8 | 973 | return receiveBytes[0]; |
echo_piyo | 0:bf96e953cdb8 | 974 | } |
echo_piyo | 0:bf96e953cdb8 | 975 | |
echo_piyo | 0:bf96e953cdb8 | 976 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 977 | * <I2C> |
echo_piyo | 0:bf96e953cdb8 | 978 | * レジスタ書き込み(1byteのみ) |
echo_piyo | 0:bf96e953cdb8 | 979 | */ |
echo_piyo | 0:bf96e953cdb8 | 980 | char BNO055_I2C_CTRL::wr(bool isPage1, char regAddr, char wBytes){ |
echo_piyo | 0:bf96e953cdb8 | 981 | //ページが異なるならページ変更命令を発行 |
echo_piyo | 0:bf96e953cdb8 | 982 | if(page1 != isPage1){ |
echo_piyo | 0:bf96e953cdb8 | 983 | ary[0] = BNO055_PAGE_ID; |
echo_piyo | 0:bf96e953cdb8 | 984 | ary[1] = (isPage1) ? 1 : 0; |
echo_piyo | 0:bf96e953cdb8 | 985 | page1 = isPage1; |
echo_piyo | 0:bf96e953cdb8 | 986 | iface->write(i2c_writeAddr, ary, 2); |
echo_piyo | 0:bf96e953cdb8 | 987 | } |
echo_piyo | 0:bf96e953cdb8 | 988 | |
echo_piyo | 0:bf96e953cdb8 | 989 | ary[0] = regAddr; |
echo_piyo | 0:bf96e953cdb8 | 990 | ary[1] = wBytes; |
echo_piyo | 0:bf96e953cdb8 | 991 | |
echo_piyo | 0:bf96e953cdb8 | 992 | iface->write(i2c_writeAddr, ary, 2); |
echo_piyo | 0:bf96e953cdb8 | 993 | |
echo_piyo | 0:bf96e953cdb8 | 994 | return ary[0]; |
echo_piyo | 0:bf96e953cdb8 | 995 | } |
echo_piyo | 0:bf96e953cdb8 | 996 | |
echo_piyo | 0:bf96e953cdb8 | 997 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 998 | * <I2C> |
echo_piyo | 0:bf96e953cdb8 | 999 | * レジスタ書き込み(複数可) |
echo_piyo | 0:bf96e953cdb8 | 1000 | */ |
echo_piyo | 0:bf96e953cdb8 | 1001 | char BNO055_I2C_CTRL::wrc(bool isPage1, char startRegAddr, char *Bytes, char length){ |
echo_piyo | 0:bf96e953cdb8 | 1002 | //書き込みバイト数が1未満 |
echo_piyo | 0:bf96e953cdb8 | 1003 | if(length < 1) return -1; |
echo_piyo | 0:bf96e953cdb8 | 1004 | |
echo_piyo | 0:bf96e953cdb8 | 1005 | //ページが異なるならページ変更命令を発行 |
echo_piyo | 0:bf96e953cdb8 | 1006 | if(page1 != isPage1){ |
echo_piyo | 0:bf96e953cdb8 | 1007 | ary[0] = BNO055_PAGE_ID; |
echo_piyo | 0:bf96e953cdb8 | 1008 | ary[1] = (isPage1) ? 1 : 0; |
echo_piyo | 0:bf96e953cdb8 | 1009 | page1 = isPage1; |
echo_piyo | 0:bf96e953cdb8 | 1010 | iface->write(i2c_writeAddr, ary, 2); |
echo_piyo | 0:bf96e953cdb8 | 1011 | } |
echo_piyo | 0:bf96e953cdb8 | 1012 | |
echo_piyo | 0:bf96e953cdb8 | 1013 | ary[0] = startRegAddr; |
echo_piyo | 0:bf96e953cdb8 | 1014 | iface->write(i2c_writeAddr, ary, 1, true); |
echo_piyo | 0:bf96e953cdb8 | 1015 | iface->write(i2c_writeAddr, Bytes, length, false); |
echo_piyo | 0:bf96e953cdb8 | 1016 | |
echo_piyo | 0:bf96e953cdb8 | 1017 | return Bytes[0]; |
echo_piyo | 0:bf96e953cdb8 | 1018 | } |
echo_piyo | 0:bf96e953cdb8 | 1019 | |
echo_piyo | 0:bf96e953cdb8 | 1020 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1021 | * <I2C> |
echo_piyo | 0:bf96e953cdb8 | 1022 | * インターフェース設定を初期化する |
echo_piyo | 0:bf96e953cdb8 | 1023 | */ |
echo_piyo | 0:bf96e953cdb8 | 1024 | void BNO055_I2C_CTRL::init(){ |
echo_piyo | 0:bf96e953cdb8 | 1025 | iface->frequency(i2c_freq); |
echo_piyo | 0:bf96e953cdb8 | 1026 | wait_ms(5); |
echo_piyo | 0:bf96e953cdb8 | 1027 | } |
echo_piyo | 0:bf96e953cdb8 | 1028 | |
echo_piyo | 0:bf96e953cdb8 | 1029 | |
echo_piyo | 0:bf96e953cdb8 | 1030 | |
echo_piyo | 0:bf96e953cdb8 | 1031 | |
echo_piyo | 0:bf96e953cdb8 | 1032 | |
echo_piyo | 0:bf96e953cdb8 | 1033 | |
echo_piyo | 0:bf96e953cdb8 | 1034 | |
echo_piyo | 0:bf96e953cdb8 | 1035 | |
echo_piyo | 0:bf96e953cdb8 | 1036 | |
echo_piyo | 0:bf96e953cdb8 | 1037 | //CLASS:BOARDC_BNO055//////////////////////////////////////////////// |
echo_piyo | 0:bf96e953cdb8 | 1038 | /* ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1039 | * メインクラス |
echo_piyo | 0:bf96e953cdb8 | 1040 | * BNO055をUARTまたはI2Cで使用するための命令をまとめている |
echo_piyo | 0:bf96e953cdb8 | 1041 | * 内部にBNO055_CTRLクラスのインスタンスを持ち、コンストラクタの引数によって |
echo_piyo | 0:bf96e953cdb8 | 1042 | * UARTとI2Cのどちらを使用するか決定する |
echo_piyo | 0:bf96e953cdb8 | 1043 | */ |
echo_piyo | 0:bf96e953cdb8 | 1044 | |
echo_piyo | 0:bf96e953cdb8 | 1045 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1046 | * コンストラクタ (オーバーロード+3) |
echo_piyo | 0:bf96e953cdb8 | 1047 | * UARTで使用する際のコンストラクタ:ピン別名を指定する |
echo_piyo | 0:bf96e953cdb8 | 1048 | */ |
echo_piyo | 0:bf96e953cdb8 | 1049 | BOARDC_BNO055::BOARDC_BNO055(PinName tx, PinName rx){ |
echo_piyo | 0:bf96e953cdb8 | 1050 | ctrl = new BNO055_UART_CTRL(new RawSerial(tx, rx)); |
echo_piyo | 0:bf96e953cdb8 | 1051 | |
echo_piyo | 0:bf96e953cdb8 | 1052 | scaleACC = 0.01f; // = 1 / 100 |
echo_piyo | 0:bf96e953cdb8 | 1053 | scaleMAG = 0.0625f; // = 1 / 16 |
echo_piyo | 0:bf96e953cdb8 | 1054 | scaleGYRO = 0.0625f; // = 1 / 16 |
echo_piyo | 0:bf96e953cdb8 | 1055 | scaleEuler = 0.0625f; // = 1 / 16 |
echo_piyo | 0:bf96e953cdb8 | 1056 | scaleTEMP = 1.0f; |
echo_piyo | 0:bf96e953cdb8 | 1057 | scaleLIA = scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 1058 | scaleGV = scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 1059 | scaleQuaternion = 0.00006103515; // = 1 / (2^14) |
echo_piyo | 0:bf96e953cdb8 | 1060 | |
echo_piyo | 0:bf96e953cdb8 | 1061 | clkExt = false; |
echo_piyo | 0:bf96e953cdb8 | 1062 | } |
echo_piyo | 0:bf96e953cdb8 | 1063 | |
echo_piyo | 0:bf96e953cdb8 | 1064 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1065 | * コンストラクタ (オーバーロード+3) |
echo_piyo | 0:bf96e953cdb8 | 1066 | * UARTで使用する際のコンストラクタ:RawSerialクラスのインスタンスを指定する |
echo_piyo | 0:bf96e953cdb8 | 1067 | */ |
echo_piyo | 0:bf96e953cdb8 | 1068 | BOARDC_BNO055::BOARDC_BNO055(RawSerial *uart){ |
echo_piyo | 0:bf96e953cdb8 | 1069 | ctrl = new BNO055_UART_CTRL(uart); |
echo_piyo | 0:bf96e953cdb8 | 1070 | |
echo_piyo | 0:bf96e953cdb8 | 1071 | scaleACC = 0.01f; // = 1 / 100 |
echo_piyo | 0:bf96e953cdb8 | 1072 | scaleMAG = 0.0625f; // = 1 / 16 |
echo_piyo | 0:bf96e953cdb8 | 1073 | scaleGYRO = 0.0625f; // = 1 / 16 |
echo_piyo | 0:bf96e953cdb8 | 1074 | scaleEuler = 0.0625f; // = 1 / 16 |
echo_piyo | 0:bf96e953cdb8 | 1075 | scaleTEMP = 1.0f; |
echo_piyo | 0:bf96e953cdb8 | 1076 | scaleLIA = scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 1077 | scaleGV = scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 1078 | scaleQuaternion = 0.00006103515; // = 1 / (2^14) |
echo_piyo | 0:bf96e953cdb8 | 1079 | |
echo_piyo | 0:bf96e953cdb8 | 1080 | clkExt = false; |
echo_piyo | 0:bf96e953cdb8 | 1081 | } |
echo_piyo | 0:bf96e953cdb8 | 1082 | |
echo_piyo | 0:bf96e953cdb8 | 1083 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1084 | * コンストラクタ (オーバーロード+3) |
echo_piyo | 0:bf96e953cdb8 | 1085 | * I2Cで使用する際のコンストラクタ:ピン別名を指定する |
echo_piyo | 0:bf96e953cdb8 | 1086 | */ |
echo_piyo | 0:bf96e953cdb8 | 1087 | BOARDC_BNO055::BOARDC_BNO055(PinName sda, PinName scl, char addr, unsigned int freq){ |
echo_piyo | 0:bf96e953cdb8 | 1088 | ctrl = new BNO055_I2C_CTRL(new I2C(sda, scl), addr, freq); |
echo_piyo | 0:bf96e953cdb8 | 1089 | |
echo_piyo | 0:bf96e953cdb8 | 1090 | scaleACC = 0.01f; // = 1 / 100 |
echo_piyo | 0:bf96e953cdb8 | 1091 | scaleMAG = 0.0625f; // = 1 / 16 |
echo_piyo | 0:bf96e953cdb8 | 1092 | scaleGYRO = 0.0625f; // = 1 / 16 |
echo_piyo | 0:bf96e953cdb8 | 1093 | scaleEuler = 0.0625f; // = 1 / 16 |
echo_piyo | 0:bf96e953cdb8 | 1094 | scaleTEMP = 1.0f; |
echo_piyo | 0:bf96e953cdb8 | 1095 | scaleLIA = scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 1096 | scaleGV = scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 1097 | scaleQuaternion = 0.00006103515; // = 1 / (2^14) |
echo_piyo | 0:bf96e953cdb8 | 1098 | |
echo_piyo | 0:bf96e953cdb8 | 1099 | clkExt = false; |
echo_piyo | 0:bf96e953cdb8 | 1100 | } |
echo_piyo | 0:bf96e953cdb8 | 1101 | |
echo_piyo | 0:bf96e953cdb8 | 1102 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1103 | * コンストラクタ (オーバーロード+3) |
echo_piyo | 0:bf96e953cdb8 | 1104 | * I2Cで使用する際のコンストラクタ:I2Cクラスのインスタンスを指定する |
echo_piyo | 0:bf96e953cdb8 | 1105 | */ |
echo_piyo | 0:bf96e953cdb8 | 1106 | BOARDC_BNO055::BOARDC_BNO055(I2C* iic, char addr, unsigned int freq){ |
echo_piyo | 0:bf96e953cdb8 | 1107 | ctrl = new BNO055_I2C_CTRL(iic, addr, freq); |
echo_piyo | 0:bf96e953cdb8 | 1108 | |
echo_piyo | 0:bf96e953cdb8 | 1109 | scaleACC = 0.01f; // = 1 / 100 |
echo_piyo | 0:bf96e953cdb8 | 1110 | scaleMAG = 0.0625f; // = 1 / 16 |
echo_piyo | 0:bf96e953cdb8 | 1111 | scaleGYRO = 0.0625f; // = 1 / 16 |
echo_piyo | 0:bf96e953cdb8 | 1112 | scaleEuler = 0.0625f; // = 1 / 16 |
echo_piyo | 0:bf96e953cdb8 | 1113 | scaleTEMP = 1.0f; |
echo_piyo | 0:bf96e953cdb8 | 1114 | scaleLIA = scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 1115 | scaleGV = scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 1116 | scaleQuaternion = 0.00006103515; // = 1 / (2^14) |
echo_piyo | 0:bf96e953cdb8 | 1117 | |
echo_piyo | 0:bf96e953cdb8 | 1118 | clkExt = false; |
echo_piyo | 0:bf96e953cdb8 | 1119 | } |
echo_piyo | 0:bf96e953cdb8 | 1120 | |
echo_piyo | 0:bf96e953cdb8 | 1121 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1122 | * デストラクタ |
echo_piyo | 0:bf96e953cdb8 | 1123 | */ |
echo_piyo | 0:bf96e953cdb8 | 1124 | BOARDC_BNO055::~BOARDC_BNO055(){ |
echo_piyo | 0:bf96e953cdb8 | 1125 | delete ctrl; |
echo_piyo | 0:bf96e953cdb8 | 1126 | } |
echo_piyo | 0:bf96e953cdb8 | 1127 | |
echo_piyo | 0:bf96e953cdb8 | 1128 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1129 | * デフォルト設定での初期化 |
echo_piyo | 0:bf96e953cdb8 | 1130 | */ |
echo_piyo | 0:bf96e953cdb8 | 1131 | char BOARDC_BNO055::initialize(bool resetIface){ |
echo_piyo | 0:bf96e953cdb8 | 1132 | if(resetIface) ctrl->init(); |
echo_piyo | 0:bf96e953cdb8 | 1133 | |
echo_piyo | 0:bf96e953cdb8 | 1134 | //CONFIGモードに設定 |
echo_piyo | 0:bf96e953cdb8 | 1135 | setOperation_CONFIG(); |
echo_piyo | 0:bf96e953cdb8 | 1136 | |
echo_piyo | 0:bf96e953cdb8 | 1137 | //外部発振子設定,セルフテストの実行,セルフテスト完了まで待つ |
echo_piyo | 0:bf96e953cdb8 | 1138 | setSysTrigger(0x81); |
echo_piyo | 0:bf96e953cdb8 | 1139 | |
echo_piyo | 0:bf96e953cdb8 | 1140 | //加速度センサーレンジ設定(+-8G) |
echo_piyo | 0:bf96e953cdb8 | 1141 | //地磁気や角速度センサーのレンジやバンドはFusionモードにより自動設定される |
echo_piyo | 0:bf96e953cdb8 | 1142 | if(!setAccRange(16)) return -1; |
echo_piyo | 0:bf96e953cdb8 | 1143 | |
echo_piyo | 0:bf96e953cdb8 | 1144 | //各軸リマップ設定(BNO055の1pinマークが表側右下) |
echo_piyo | 0:bf96e953cdb8 | 1145 | if(!setAxisRemap_topview_bottomright()) return -2; |
echo_piyo | 0:bf96e953cdb8 | 1146 | |
echo_piyo | 0:bf96e953cdb8 | 1147 | //単位系セット |
echo_piyo | 0:bf96e953cdb8 | 1148 | //ORI_Android_Windows : Windows |
echo_piyo | 0:bf96e953cdb8 | 1149 | //TEMP_Unit : Celcius |
echo_piyo | 0:bf96e953cdb8 | 1150 | //EUL_Unit : Degree |
echo_piyo | 0:bf96e953cdb8 | 1151 | //GYR_Unit : deg/s |
echo_piyo | 0:bf96e953cdb8 | 1152 | //ACC_Unit : m/s^2 |
echo_piyo | 0:bf96e953cdb8 | 1153 | if(!setUNIT_SEL(0x00)) return -3; |
echo_piyo | 0:bf96e953cdb8 | 1154 | |
echo_piyo | 0:bf96e953cdb8 | 1155 | //動作モード設定(9軸Fusionモード) |
echo_piyo | 0:bf96e953cdb8 | 1156 | if(!setOperation_Fusion_NDOF()) return -4; |
echo_piyo | 0:bf96e953cdb8 | 1157 | |
echo_piyo | 0:bf96e953cdb8 | 1158 | return 0; |
echo_piyo | 0:bf96e953cdb8 | 1159 | } |
echo_piyo | 0:bf96e953cdb8 | 1160 | |
echo_piyo | 0:bf96e953cdb8 | 1161 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1162 | * 通信で発生した最後のエラー番号を返す |
echo_piyo | 0:bf96e953cdb8 | 1163 | */ |
echo_piyo | 0:bf96e953cdb8 | 1164 | char BOARDC_BNO055::getIfaceLastError(){ |
echo_piyo | 0:bf96e953cdb8 | 1165 | return ctrl->getLastError(); |
echo_piyo | 0:bf96e953cdb8 | 1166 | } |
echo_piyo | 0:bf96e953cdb8 | 1167 | |
echo_piyo | 0:bf96e953cdb8 | 1168 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1169 | * 通信で発生した最後のエラーの通信バイト数を返す |
echo_piyo | 0:bf96e953cdb8 | 1170 | */ |
echo_piyo | 0:bf96e953cdb8 | 1171 | char BOARDC_BNO055::getIfaceLastLength(){ |
echo_piyo | 0:bf96e953cdb8 | 1172 | return ctrl->getLastLength(); |
echo_piyo | 0:bf96e953cdb8 | 1173 | } |
echo_piyo | 0:bf96e953cdb8 | 1174 | |
echo_piyo | 0:bf96e953cdb8 | 1175 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1176 | * ユーザー定義読み取り(1byte) |
echo_piyo | 0:bf96e953cdb8 | 1177 | * レジスタを指定して値を直接読み取る |
echo_piyo | 0:bf96e953cdb8 | 1178 | */ |
echo_piyo | 0:bf96e953cdb8 | 1179 | char BOARDC_BNO055::customRead(bool isPage1, char regAddr){ |
echo_piyo | 0:bf96e953cdb8 | 1180 | return ctrl->rr(isPage1, regAddr); |
echo_piyo | 0:bf96e953cdb8 | 1181 | } |
echo_piyo | 0:bf96e953cdb8 | 1182 | |
echo_piyo | 0:bf96e953cdb8 | 1183 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1184 | * ユーザー定義読み取り(連続) |
echo_piyo | 0:bf96e953cdb8 | 1185 | * レジスタを指定して値を直接読み取る |
echo_piyo | 0:bf96e953cdb8 | 1186 | */ |
echo_piyo | 0:bf96e953cdb8 | 1187 | char BOARDC_BNO055::customReadC(bool isPage1, char startRegAddr, char *receiveBytes, unsigned char length){ |
echo_piyo | 0:bf96e953cdb8 | 1188 | return ctrl->rrc(isPage1, startRegAddr, receiveBytes, length); |
echo_piyo | 0:bf96e953cdb8 | 1189 | } |
echo_piyo | 0:bf96e953cdb8 | 1190 | |
echo_piyo | 0:bf96e953cdb8 | 1191 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1192 | * ユーザー定義書き込み(1byte) |
echo_piyo | 0:bf96e953cdb8 | 1193 | * レジスタを指定して値を直接書き込む |
echo_piyo | 0:bf96e953cdb8 | 1194 | */ |
echo_piyo | 0:bf96e953cdb8 | 1195 | char BOARDC_BNO055::customWrite(bool isPage1, char regAddr, char wBytes){ |
echo_piyo | 0:bf96e953cdb8 | 1196 | return ctrl->wr(isPage1, regAddr, wBytes); |
echo_piyo | 0:bf96e953cdb8 | 1197 | } |
echo_piyo | 0:bf96e953cdb8 | 1198 | |
echo_piyo | 0:bf96e953cdb8 | 1199 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1200 | * ユーザー定義書き込み(連続) |
echo_piyo | 0:bf96e953cdb8 | 1201 | * レジスタを指定して値を直接書き込む |
echo_piyo | 0:bf96e953cdb8 | 1202 | */ |
echo_piyo | 0:bf96e953cdb8 | 1203 | char BOARDC_BNO055::customWriteC(bool isPage1, char startRegAddr, char *Bytes, unsigned char length){ |
echo_piyo | 0:bf96e953cdb8 | 1204 | return ctrl->wrc(isPage1, startRegAddr, Bytes, length); |
echo_piyo | 0:bf96e953cdb8 | 1205 | } |
echo_piyo | 0:bf96e953cdb8 | 1206 | |
echo_piyo | 0:bf96e953cdb8 | 1207 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1208 | * レジスタ:ページIDの現在値を読む |
echo_piyo | 0:bf96e953cdb8 | 1209 | * 実際はコントロールクラスが保持している内部変数の値を返しているだけ |
echo_piyo | 0:bf96e953cdb8 | 1210 | */ |
echo_piyo | 0:bf96e953cdb8 | 1211 | char BOARDC_BNO055::getPage(){ |
echo_piyo | 0:bf96e953cdb8 | 1212 | return ctrl->getNowPage(); |
echo_piyo | 0:bf96e953cdb8 | 1213 | } |
echo_piyo | 0:bf96e953cdb8 | 1214 | |
echo_piyo | 0:bf96e953cdb8 | 1215 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1216 | * レジスタ:ページIDを変更する |
echo_piyo | 0:bf96e953cdb8 | 1217 | * ページIDが現在値と同じであれば何もしない |
echo_piyo | 0:bf96e953cdb8 | 1218 | */ |
echo_piyo | 0:bf96e953cdb8 | 1219 | void BOARDC_BNO055::setPage(unsigned char pageNo){ |
echo_piyo | 0:bf96e953cdb8 | 1220 | pageNo = (pageNo == 0) ? 0 : 1; |
echo_piyo | 0:bf96e953cdb8 | 1221 | if(getPage() == pageNo) return; |
echo_piyo | 0:bf96e953cdb8 | 1222 | ctrl->wr((getPage() == 0) ? true : false, BNO055_PAGE_ID, pageNo); |
echo_piyo | 0:bf96e953cdb8 | 1223 | } |
echo_piyo | 0:bf96e953cdb8 | 1224 | |
echo_piyo | 0:bf96e953cdb8 | 1225 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1226 | * レジスタ:チップIDの値を取得する |
echo_piyo | 0:bf96e953cdb8 | 1227 | */ |
echo_piyo | 0:bf96e953cdb8 | 1228 | char BOARDC_BNO055::getChipID(){ |
echo_piyo | 0:bf96e953cdb8 | 1229 | return ctrl->rr(0, BNO055P0_CHIP_ID); |
echo_piyo | 0:bf96e953cdb8 | 1230 | } |
echo_piyo | 0:bf96e953cdb8 | 1231 | |
echo_piyo | 0:bf96e953cdb8 | 1232 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1233 | * レジスタ:加速度センサーIDの値を取得する |
echo_piyo | 0:bf96e953cdb8 | 1234 | */ |
echo_piyo | 0:bf96e953cdb8 | 1235 | char BOARDC_BNO055::getAccChipID(){ |
echo_piyo | 0:bf96e953cdb8 | 1236 | return ctrl->rr(0, BNO055P0_ACC_ID); |
echo_piyo | 0:bf96e953cdb8 | 1237 | } |
echo_piyo | 0:bf96e953cdb8 | 1238 | |
echo_piyo | 0:bf96e953cdb8 | 1239 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1240 | * レジスタ:地磁気センサーIDの値を取得する |
echo_piyo | 0:bf96e953cdb8 | 1241 | */ |
echo_piyo | 0:bf96e953cdb8 | 1242 | char BOARDC_BNO055::getMagChipID(){ |
echo_piyo | 0:bf96e953cdb8 | 1243 | return ctrl->rr(0, BNO055P0_MAG_ID); |
echo_piyo | 0:bf96e953cdb8 | 1244 | } |
echo_piyo | 0:bf96e953cdb8 | 1245 | |
echo_piyo | 0:bf96e953cdb8 | 1246 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1247 | * レジスタ:ジャイロセンサーIDの値を取得する |
echo_piyo | 0:bf96e953cdb8 | 1248 | */ |
echo_piyo | 0:bf96e953cdb8 | 1249 | char BOARDC_BNO055::getGyroChipID(){ |
echo_piyo | 0:bf96e953cdb8 | 1250 | return ctrl->rr(0, BNO055P0_GYR_ID); |
echo_piyo | 0:bf96e953cdb8 | 1251 | } |
echo_piyo | 0:bf96e953cdb8 | 1252 | |
echo_piyo | 0:bf96e953cdb8 | 1253 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1254 | * レジスタ:内部ソフトウェアリビジョンの値を取得する |
echo_piyo | 0:bf96e953cdb8 | 1255 | */ |
echo_piyo | 0:bf96e953cdb8 | 1256 | short BOARDC_BNO055::getRevision(){ |
echo_piyo | 0:bf96e953cdb8 | 1257 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1258 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1259 | ctrl->rrc(0, BNO055P0_SW_REV_ID_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1260 | |
echo_piyo | 0:bf96e953cdb8 | 1261 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1262 | } |
echo_piyo | 0:bf96e953cdb8 | 1263 | |
echo_piyo | 0:bf96e953cdb8 | 1264 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1265 | * レジスタ:内部ブートリビジョンの値を取得する |
echo_piyo | 0:bf96e953cdb8 | 1266 | */ |
echo_piyo | 0:bf96e953cdb8 | 1267 | char BOARDC_BNO055::getBootRevision(){ |
echo_piyo | 0:bf96e953cdb8 | 1268 | return ctrl->rr(0, BNO055P0_BL_REV_ID); |
echo_piyo | 0:bf96e953cdb8 | 1269 | } |
echo_piyo | 0:bf96e953cdb8 | 1270 | |
echo_piyo | 0:bf96e953cdb8 | 1271 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1272 | * 加速度センサーのRAW値に乗算する係数を取得する |
echo_piyo | 0:bf96e953cdb8 | 1273 | */ |
echo_piyo | 0:bf96e953cdb8 | 1274 | float BOARDC_BNO055::getAccScale(){ |
echo_piyo | 0:bf96e953cdb8 | 1275 | return scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 1276 | } |
echo_piyo | 0:bf96e953cdb8 | 1277 | |
echo_piyo | 0:bf96e953cdb8 | 1278 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1279 | * 地磁気センサーのRAW値に乗算する係数を取得する |
echo_piyo | 0:bf96e953cdb8 | 1280 | */ |
echo_piyo | 0:bf96e953cdb8 | 1281 | float BOARDC_BNO055::getMagScale(){ |
echo_piyo | 0:bf96e953cdb8 | 1282 | return scaleMAG; |
echo_piyo | 0:bf96e953cdb8 | 1283 | } |
echo_piyo | 0:bf96e953cdb8 | 1284 | |
echo_piyo | 0:bf96e953cdb8 | 1285 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1286 | * 角速度センサーのRAW値に乗算する係数を取得する |
echo_piyo | 0:bf96e953cdb8 | 1287 | */ |
echo_piyo | 0:bf96e953cdb8 | 1288 | float BOARDC_BNO055::getGyroScale(){ |
echo_piyo | 0:bf96e953cdb8 | 1289 | return scaleGYRO; |
echo_piyo | 0:bf96e953cdb8 | 1290 | } |
echo_piyo | 0:bf96e953cdb8 | 1291 | |
echo_piyo | 0:bf96e953cdb8 | 1292 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1293 | * 温度センサーのRAW値に乗算する係数を取得する |
echo_piyo | 0:bf96e953cdb8 | 1294 | */ |
echo_piyo | 0:bf96e953cdb8 | 1295 | float BOARDC_BNO055::getTempScale(){ |
echo_piyo | 0:bf96e953cdb8 | 1296 | return scaleTEMP; |
echo_piyo | 0:bf96e953cdb8 | 1297 | } |
echo_piyo | 0:bf96e953cdb8 | 1298 | |
echo_piyo | 0:bf96e953cdb8 | 1299 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1300 | * オイラー角のRAW値に乗算する係数を取得する |
echo_piyo | 0:bf96e953cdb8 | 1301 | */ |
echo_piyo | 0:bf96e953cdb8 | 1302 | float BOARDC_BNO055::getEulerScale(){ |
echo_piyo | 0:bf96e953cdb8 | 1303 | return scaleEuler; |
echo_piyo | 0:bf96e953cdb8 | 1304 | } |
echo_piyo | 0:bf96e953cdb8 | 1305 | |
echo_piyo | 0:bf96e953cdb8 | 1306 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1307 | * 加速度センサーの線形加速度のRAW値に乗算する係数を取得する |
echo_piyo | 0:bf96e953cdb8 | 1308 | */ |
echo_piyo | 0:bf96e953cdb8 | 1309 | float BOARDC_BNO055::getLinearScale(){ |
echo_piyo | 0:bf96e953cdb8 | 1310 | return scaleLIA; |
echo_piyo | 0:bf96e953cdb8 | 1311 | } |
echo_piyo | 0:bf96e953cdb8 | 1312 | |
echo_piyo | 0:bf96e953cdb8 | 1313 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1314 | * 重力ベクトルのRAW値に乗算する係数を取得する |
echo_piyo | 0:bf96e953cdb8 | 1315 | */ |
echo_piyo | 0:bf96e953cdb8 | 1316 | float BOARDC_BNO055::getGVScale(){ |
echo_piyo | 0:bf96e953cdb8 | 1317 | return scaleGV; |
echo_piyo | 0:bf96e953cdb8 | 1318 | } |
echo_piyo | 0:bf96e953cdb8 | 1319 | |
echo_piyo | 0:bf96e953cdb8 | 1320 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1321 | * 四元数のRAW値に乗算する係数を取得する |
echo_piyo | 0:bf96e953cdb8 | 1322 | */ |
echo_piyo | 0:bf96e953cdb8 | 1323 | double BOARDC_BNO055::getQuaternionScale(){ |
echo_piyo | 0:bf96e953cdb8 | 1324 | return scaleQuaternion; |
echo_piyo | 0:bf96e953cdb8 | 1325 | } |
echo_piyo | 0:bf96e953cdb8 | 1326 | |
echo_piyo | 0:bf96e953cdb8 | 1327 | |
echo_piyo | 0:bf96e953cdb8 | 1328 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1329 | * 加速度センサの値を取得する |
echo_piyo | 0:bf96e953cdb8 | 1330 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1331 | * &accX: アドレス参照引数:関数実行後、この変数にX軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1332 | * &accY: アドレス参照引数:関数実行後、この変数にY軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1333 | * &accZ: アドレス参照引数:関数実行後、この変数にZ軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1334 | */ |
echo_piyo | 0:bf96e953cdb8 | 1335 | void BOARDC_BNO055::getAccDataAll(short &accX, short &accY, short &accZ){ |
echo_piyo | 0:bf96e953cdb8 | 1336 | //連続6byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1337 | char rsv[6]; |
echo_piyo | 0:bf96e953cdb8 | 1338 | ctrl->rrc(0, BNO055P0_ACC_DATA_X_LSB, rsv, 6); |
echo_piyo | 0:bf96e953cdb8 | 1339 | |
echo_piyo | 0:bf96e953cdb8 | 1340 | accX = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1341 | accY = (rsv[3] << 8) | rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1342 | accZ = (rsv[5] << 8) | rsv[4]; |
echo_piyo | 0:bf96e953cdb8 | 1343 | } |
echo_piyo | 0:bf96e953cdb8 | 1344 | |
echo_piyo | 0:bf96e953cdb8 | 1345 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1346 | * 加速度センサの値(X軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1347 | */ |
echo_piyo | 0:bf96e953cdb8 | 1348 | short BOARDC_BNO055::getAccDataX(){ |
echo_piyo | 0:bf96e953cdb8 | 1349 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1350 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1351 | ctrl->rrc(0, BNO055P0_ACC_DATA_X_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1352 | |
echo_piyo | 0:bf96e953cdb8 | 1353 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1354 | } |
echo_piyo | 0:bf96e953cdb8 | 1355 | |
echo_piyo | 0:bf96e953cdb8 | 1356 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1357 | * 加速度センサの値(Y軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1358 | */ |
echo_piyo | 0:bf96e953cdb8 | 1359 | short BOARDC_BNO055::getAccDataY(){ |
echo_piyo | 0:bf96e953cdb8 | 1360 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1361 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1362 | ctrl->rrc(0, BNO055P0_ACC_DATA_Y_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1363 | |
echo_piyo | 0:bf96e953cdb8 | 1364 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1365 | } |
echo_piyo | 0:bf96e953cdb8 | 1366 | |
echo_piyo | 0:bf96e953cdb8 | 1367 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1368 | * 加速度センサの値(Z軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1369 | */ |
echo_piyo | 0:bf96e953cdb8 | 1370 | short BOARDC_BNO055::getAccDataZ(){ |
echo_piyo | 0:bf96e953cdb8 | 1371 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1372 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1373 | ctrl->rrc(0, BNO055P0_ACC_DATA_Z_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1374 | |
echo_piyo | 0:bf96e953cdb8 | 1375 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1376 | } |
echo_piyo | 0:bf96e953cdb8 | 1377 | |
echo_piyo | 0:bf96e953cdb8 | 1378 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1379 | * 地磁気センサの値を取得する |
echo_piyo | 0:bf96e953cdb8 | 1380 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1381 | * &magX: アドレス参照引数:関数実行後、この変数にX軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1382 | * &magY: アドレス参照引数:関数実行後、この変数にY軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1383 | * &magZ: アドレス参照引数:関数実行後、この変数にZ軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1384 | */ |
echo_piyo | 0:bf96e953cdb8 | 1385 | void BOARDC_BNO055::getMagDataAll(short &magX, short &magY, short &magZ){ |
echo_piyo | 0:bf96e953cdb8 | 1386 | //連続6byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1387 | char rsv[6]; |
echo_piyo | 0:bf96e953cdb8 | 1388 | ctrl->rrc(0, BNO055P0_MAG_DATA_X_LSB, rsv, 6); |
echo_piyo | 0:bf96e953cdb8 | 1389 | |
echo_piyo | 0:bf96e953cdb8 | 1390 | magX = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1391 | magY = (rsv[3] << 8) | rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1392 | magZ = (rsv[5] << 8) | rsv[4]; |
echo_piyo | 0:bf96e953cdb8 | 1393 | } |
echo_piyo | 0:bf96e953cdb8 | 1394 | |
echo_piyo | 0:bf96e953cdb8 | 1395 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1396 | * 地磁気センサの値(X軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1397 | */ |
echo_piyo | 0:bf96e953cdb8 | 1398 | short BOARDC_BNO055::getMagDataX(){ |
echo_piyo | 0:bf96e953cdb8 | 1399 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1400 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1401 | ctrl->rrc(0, BNO055P0_MAG_DATA_X_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1402 | |
echo_piyo | 0:bf96e953cdb8 | 1403 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1404 | } |
echo_piyo | 0:bf96e953cdb8 | 1405 | |
echo_piyo | 0:bf96e953cdb8 | 1406 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1407 | * 地磁気センサの値(Y軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1408 | */ |
echo_piyo | 0:bf96e953cdb8 | 1409 | short BOARDC_BNO055::getMagDataY(){ |
echo_piyo | 0:bf96e953cdb8 | 1410 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1411 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1412 | ctrl->rrc(0, BNO055P0_MAG_DATA_Y_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1413 | |
echo_piyo | 0:bf96e953cdb8 | 1414 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1415 | } |
echo_piyo | 0:bf96e953cdb8 | 1416 | |
echo_piyo | 0:bf96e953cdb8 | 1417 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1418 | * 地磁気センサの値(Z軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1419 | */ |
echo_piyo | 0:bf96e953cdb8 | 1420 | short BOARDC_BNO055::getMagDataZ(){ |
echo_piyo | 0:bf96e953cdb8 | 1421 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1422 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1423 | ctrl->rrc(0, BNO055P0_MAG_DATA_Z_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1424 | |
echo_piyo | 0:bf96e953cdb8 | 1425 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1426 | } |
echo_piyo | 0:bf96e953cdb8 | 1427 | |
echo_piyo | 0:bf96e953cdb8 | 1428 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1429 | * ジャイロセンサの値を取得する |
echo_piyo | 0:bf96e953cdb8 | 1430 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1431 | * &gyroX: アドレス参照引数:関数実行後、この変数にX軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1432 | * &gyroY: アドレス参照引数:関数実行後、この変数にY軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1433 | * &gyroZ: アドレス参照引数:関数実行後、この変数にZ軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1434 | */ |
echo_piyo | 0:bf96e953cdb8 | 1435 | void BOARDC_BNO055::getGyroDataAll(short &gyroX, short &gyroY, short &gyroZ){ |
echo_piyo | 0:bf96e953cdb8 | 1436 | //連続6byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1437 | char rsv[6]; |
echo_piyo | 0:bf96e953cdb8 | 1438 | ctrl->rrc(0, BNO055P0_GYR_DATA_X_LSB, rsv, 6); |
echo_piyo | 0:bf96e953cdb8 | 1439 | |
echo_piyo | 0:bf96e953cdb8 | 1440 | gyroX = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1441 | gyroY = (rsv[3] << 8) | rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1442 | gyroZ = (rsv[5] << 8) | rsv[4]; |
echo_piyo | 0:bf96e953cdb8 | 1443 | } |
echo_piyo | 0:bf96e953cdb8 | 1444 | |
echo_piyo | 0:bf96e953cdb8 | 1445 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1446 | * ジャイロセンサの値(X軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1447 | */ |
echo_piyo | 0:bf96e953cdb8 | 1448 | short BOARDC_BNO055::getGyroDataX(){ |
echo_piyo | 0:bf96e953cdb8 | 1449 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1450 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1451 | ctrl->rrc(0, BNO055P0_GYR_DATA_X_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1452 | |
echo_piyo | 0:bf96e953cdb8 | 1453 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1454 | } |
echo_piyo | 0:bf96e953cdb8 | 1455 | |
echo_piyo | 0:bf96e953cdb8 | 1456 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1457 | * ジャイロセンサの値(Y軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1458 | */ |
echo_piyo | 0:bf96e953cdb8 | 1459 | short BOARDC_BNO055::getGyroDataY(){ |
echo_piyo | 0:bf96e953cdb8 | 1460 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1461 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1462 | ctrl->rrc(0, BNO055P0_GYR_DATA_Y_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1463 | |
echo_piyo | 0:bf96e953cdb8 | 1464 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1465 | } |
echo_piyo | 0:bf96e953cdb8 | 1466 | |
echo_piyo | 0:bf96e953cdb8 | 1467 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1468 | * ジャイロセンサの値(Z軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1469 | */ |
echo_piyo | 0:bf96e953cdb8 | 1470 | short BOARDC_BNO055::getGyroDataZ(){ |
echo_piyo | 0:bf96e953cdb8 | 1471 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1472 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1473 | ctrl->rrc(0, BNO055P0_GYR_DATA_Z_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1474 | |
echo_piyo | 0:bf96e953cdb8 | 1475 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1476 | } |
echo_piyo | 0:bf96e953cdb8 | 1477 | |
echo_piyo | 0:bf96e953cdb8 | 1478 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1479 | * FusionSensing:オイラー角の値を取得する |
echo_piyo | 0:bf96e953cdb8 | 1480 | * FusionSensing機能(内部演算機能)を使用していない場合は不定の値を返す |
echo_piyo | 0:bf96e953cdb8 | 1481 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1482 | * &E_heading: アドレス参照引数:関数実行後、この変数にYaw軸(heading)の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1483 | * &E_roll: アドレス参照引数:関数実行後、この変数にroll軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1484 | * &E_pitch: アドレス参照引数:関数実行後、この変数にpitch軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1485 | */ |
echo_piyo | 0:bf96e953cdb8 | 1486 | void BOARDC_BNO055::getEulerDataAll(short &E_heading, short &E_roll, short &E_pitch){ |
echo_piyo | 0:bf96e953cdb8 | 1487 | //連続6byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1488 | char rsv[6]; |
echo_piyo | 0:bf96e953cdb8 | 1489 | ctrl->rrc(0, BNO055P0_EUL_HEADING_LSB, rsv, 6); |
echo_piyo | 0:bf96e953cdb8 | 1490 | |
echo_piyo | 0:bf96e953cdb8 | 1491 | E_heading = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1492 | E_roll = (rsv[3] << 8) | rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1493 | E_pitch = (rsv[5] << 8) | rsv[4]; |
echo_piyo | 0:bf96e953cdb8 | 1494 | } |
echo_piyo | 0:bf96e953cdb8 | 1495 | |
echo_piyo | 0:bf96e953cdb8 | 1496 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1497 | * FusionSensing:オイラー角の値(Yaw軸(heading)のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1498 | * FusionSensing機能(内部演算機能)を使用していない場合は不定の値を返す |
echo_piyo | 0:bf96e953cdb8 | 1499 | */ |
echo_piyo | 0:bf96e953cdb8 | 1500 | short BOARDC_BNO055::getEulerDataHeading(){ |
echo_piyo | 0:bf96e953cdb8 | 1501 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1502 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1503 | ctrl->rrc(0, BNO055P0_EUL_HEADING_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1504 | |
echo_piyo | 0:bf96e953cdb8 | 1505 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1506 | } |
echo_piyo | 0:bf96e953cdb8 | 1507 | |
echo_piyo | 0:bf96e953cdb8 | 1508 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1509 | * getEulerDataHeading()のエイリアス |
echo_piyo | 0:bf96e953cdb8 | 1510 | * FusionSensing:オイラー角の値(Yaw軸(heading)のみ)を返す |
echo_piyo | 0:bf96e953cdb8 | 1511 | */ |
echo_piyo | 0:bf96e953cdb8 | 1512 | short BOARDC_BNO055::getEulerDataYaw(){ |
echo_piyo | 0:bf96e953cdb8 | 1513 | return getEulerDataHeading(); |
echo_piyo | 0:bf96e953cdb8 | 1514 | } |
echo_piyo | 0:bf96e953cdb8 | 1515 | |
echo_piyo | 0:bf96e953cdb8 | 1516 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1517 | * FusionSensing:オイラー角の値(pitch軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1518 | * FusionSensing機能(内部演算機能)を使用していない場合は不定の値を返す |
echo_piyo | 0:bf96e953cdb8 | 1519 | */ |
echo_piyo | 0:bf96e953cdb8 | 1520 | short BOARDC_BNO055::getEulerDataRoll(){ |
echo_piyo | 0:bf96e953cdb8 | 1521 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1522 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1523 | ctrl->rrc(0, BNO055P0_EUL_ROLL_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1524 | |
echo_piyo | 0:bf96e953cdb8 | 1525 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1526 | } |
echo_piyo | 0:bf96e953cdb8 | 1527 | |
echo_piyo | 0:bf96e953cdb8 | 1528 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1529 | * FusionSensing:オイラー角の値(pitch軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1530 | * FusionSensing機能(内部演算機能)を使用していない場合は不定の値を返す |
echo_piyo | 0:bf96e953cdb8 | 1531 | */ |
echo_piyo | 0:bf96e953cdb8 | 1532 | short BOARDC_BNO055::getEulerDataPitch(){ |
echo_piyo | 0:bf96e953cdb8 | 1533 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1534 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1535 | ctrl->rrc(0, BNO055P0_EUL_PITCH_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1536 | |
echo_piyo | 0:bf96e953cdb8 | 1537 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1538 | } |
echo_piyo | 0:bf96e953cdb8 | 1539 | |
echo_piyo | 0:bf96e953cdb8 | 1540 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1541 | * FusionSensing:9軸センサーのすべての値の値を取得する |
echo_piyo | 0:bf96e953cdb8 | 1542 | */ |
echo_piyo | 0:bf96e953cdb8 | 1543 | void BOARDC_BNO055::get9Axis(short *box){ |
echo_piyo | 0:bf96e953cdb8 | 1544 | char rsv[18]; |
echo_piyo | 0:bf96e953cdb8 | 1545 | ctrl->rrc(0, BNO055P0_ACC_DATA_X_LSB, rsv, 18); |
echo_piyo | 0:bf96e953cdb8 | 1546 | |
echo_piyo | 0:bf96e953cdb8 | 1547 | box[0] = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1548 | box[1] = (rsv[3] << 8) | rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1549 | box[2] = (rsv[5] << 8) | rsv[4]; |
echo_piyo | 0:bf96e953cdb8 | 1550 | box[3] = (rsv[7] << 8) | rsv[6]; |
echo_piyo | 0:bf96e953cdb8 | 1551 | box[4] = (rsv[9] << 8) | rsv[8]; |
echo_piyo | 0:bf96e953cdb8 | 1552 | box[5] = (rsv[11] << 8) | rsv[10]; |
echo_piyo | 0:bf96e953cdb8 | 1553 | box[6] = (rsv[13] << 8) | rsv[12]; |
echo_piyo | 0:bf96e953cdb8 | 1554 | box[7] = (rsv[15] << 8) | rsv[14]; |
echo_piyo | 0:bf96e953cdb8 | 1555 | box[8] = (rsv[17] << 8) | rsv[16]; |
echo_piyo | 0:bf96e953cdb8 | 1556 | } |
echo_piyo | 0:bf96e953cdb8 | 1557 | |
echo_piyo | 0:bf96e953cdb8 | 1558 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1559 | * FusionSensing:9軸センサーのすべての値とオイラー角のすべての値を取得する |
echo_piyo | 0:bf96e953cdb8 | 1560 | * FusionSensing機能(内部演算機能)を使用していない場合は不定の値を返す |
echo_piyo | 0:bf96e953cdb8 | 1561 | */ |
echo_piyo | 0:bf96e953cdb8 | 1562 | void BOARDC_BNO055::get9AxisAndEUL(short *box){ |
echo_piyo | 0:bf96e953cdb8 | 1563 | char rsv[24]; |
echo_piyo | 0:bf96e953cdb8 | 1564 | ctrl->rrc(0, BNO055P0_ACC_DATA_X_LSB, rsv, 24); |
echo_piyo | 0:bf96e953cdb8 | 1565 | |
echo_piyo | 0:bf96e953cdb8 | 1566 | box[0] = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1567 | box[1] = (rsv[3] << 8) | rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1568 | box[2] = (rsv[5] << 8) | rsv[4]; |
echo_piyo | 0:bf96e953cdb8 | 1569 | box[3] = (rsv[7] << 8) | rsv[6]; |
echo_piyo | 0:bf96e953cdb8 | 1570 | box[4] = (rsv[9] << 8) | rsv[8]; |
echo_piyo | 0:bf96e953cdb8 | 1571 | box[5] = (rsv[11] << 8) | rsv[10]; |
echo_piyo | 0:bf96e953cdb8 | 1572 | box[6] = (rsv[13] << 8) | rsv[12]; |
echo_piyo | 0:bf96e953cdb8 | 1573 | box[7] = (rsv[15] << 8) | rsv[14]; |
echo_piyo | 0:bf96e953cdb8 | 1574 | box[8] = (rsv[17] << 8) | rsv[16]; |
echo_piyo | 0:bf96e953cdb8 | 1575 | box[9] = (rsv[19] << 8) | rsv[18]; |
echo_piyo | 0:bf96e953cdb8 | 1576 | box[10] = (rsv[21] << 8) | rsv[20]; |
echo_piyo | 0:bf96e953cdb8 | 1577 | box[11] = (rsv[23] << 8) | rsv[22]; |
echo_piyo | 0:bf96e953cdb8 | 1578 | } |
echo_piyo | 0:bf96e953cdb8 | 1579 | |
echo_piyo | 0:bf96e953cdb8 | 1580 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1581 | * FusionSensing:四元数(Quaternion)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1582 | * FusionSensing機能(内部演算機能)を使用していない場合は不定の値を返す |
echo_piyo | 0:bf96e953cdb8 | 1583 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1584 | * &q1, &q2, &q3, &q4:アドレス参照引数:関数実行後、この変数に四元数が格納される |
echo_piyo | 0:bf96e953cdb8 | 1585 | */ |
echo_piyo | 0:bf96e953cdb8 | 1586 | void BOARDC_BNO055::getQuaternion(short &q1, short &q2, short &q3, short &q4){ |
echo_piyo | 0:bf96e953cdb8 | 1587 | //連続8byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1588 | char rsv[8]; |
echo_piyo | 0:bf96e953cdb8 | 1589 | ctrl->rrc(0, BNO055P0_QUA_DATA_W_LSB, rsv, 8); |
echo_piyo | 0:bf96e953cdb8 | 1590 | |
echo_piyo | 0:bf96e953cdb8 | 1591 | q1 = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1592 | q2 = (rsv[3] << 8) | rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1593 | q3 = (rsv[5] << 8) | rsv[4]; |
echo_piyo | 0:bf96e953cdb8 | 1594 | q4 = (rsv[7] << 8) | rsv[6]; |
echo_piyo | 0:bf96e953cdb8 | 1595 | } |
echo_piyo | 0:bf96e953cdb8 | 1596 | |
echo_piyo | 0:bf96e953cdb8 | 1597 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1598 | * 線形加速度(LinearAcceleration)での加速度センサの値を取得する |
echo_piyo | 0:bf96e953cdb8 | 1599 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1600 | * &L_accX: アドレス参照引数:関数実行後、この変数にX軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1601 | * &L_accY: アドレス参照引数:関数実行後、この変数にY軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1602 | * &L_accZ: アドレス参照引数:関数実行後、この変数にZ軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1603 | */ |
echo_piyo | 0:bf96e953cdb8 | 1604 | void BOARDC_BNO055::getLinearAccDataAll(short &L_accX, short &L_accY, short &L_accZ){ |
echo_piyo | 0:bf96e953cdb8 | 1605 | //連続6byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1606 | char rsv[6]; |
echo_piyo | 0:bf96e953cdb8 | 1607 | ctrl->rrc(0, BNO055P0_LIA_DATA_X_LSB, rsv, 6); |
echo_piyo | 0:bf96e953cdb8 | 1608 | |
echo_piyo | 0:bf96e953cdb8 | 1609 | L_accX = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1610 | L_accY = (rsv[3] << 8) | rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1611 | L_accZ = (rsv[5] << 8) | rsv[4]; |
echo_piyo | 0:bf96e953cdb8 | 1612 | } |
echo_piyo | 0:bf96e953cdb8 | 1613 | |
echo_piyo | 0:bf96e953cdb8 | 1614 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1615 | * 線形加速度(LinearAcceleration)での加速度センサの値(X軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1616 | */ |
echo_piyo | 0:bf96e953cdb8 | 1617 | short BOARDC_BNO055::getLinearAccDataX(){ |
echo_piyo | 0:bf96e953cdb8 | 1618 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1619 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1620 | ctrl->rrc(0, BNO055P0_LIA_DATA_X_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1621 | |
echo_piyo | 0:bf96e953cdb8 | 1622 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1623 | } |
echo_piyo | 0:bf96e953cdb8 | 1624 | |
echo_piyo | 0:bf96e953cdb8 | 1625 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1626 | * 線形加速度(LinearAcceleration)での加速度センサの値(Y軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1627 | */ |
echo_piyo | 0:bf96e953cdb8 | 1628 | short BOARDC_BNO055::getLinearAccDataY(){ |
echo_piyo | 0:bf96e953cdb8 | 1629 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1630 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1631 | ctrl->rrc(0, BNO055P0_LIA_DATA_Y_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1632 | |
echo_piyo | 0:bf96e953cdb8 | 1633 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1634 | } |
echo_piyo | 0:bf96e953cdb8 | 1635 | |
echo_piyo | 0:bf96e953cdb8 | 1636 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1637 | * 線形加速度(LinearAcceleration)での加速度センサの値(Z軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1638 | */ |
echo_piyo | 0:bf96e953cdb8 | 1639 | short BOARDC_BNO055::getLinearAccDataZ(){ |
echo_piyo | 0:bf96e953cdb8 | 1640 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1641 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1642 | ctrl->rrc(0, BNO055P0_LIA_DATA_Z_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1643 | |
echo_piyo | 0:bf96e953cdb8 | 1644 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1645 | } |
echo_piyo | 0:bf96e953cdb8 | 1646 | |
echo_piyo | 0:bf96e953cdb8 | 1647 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1648 | * 重力ベクトル情報を取得する |
echo_piyo | 0:bf96e953cdb8 | 1649 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1650 | * &gvX: アドレス参照引数:関数実行後、この変数にX軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1651 | * &gvY: アドレス参照引数:関数実行後、この変数にY軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1652 | * &gvZ: アドレス参照引数:関数実行後、この変数にZ軸の値が格納される |
echo_piyo | 0:bf96e953cdb8 | 1653 | */ |
echo_piyo | 0:bf96e953cdb8 | 1654 | void BOARDC_BNO055::getGVectorDataAll(short &gvX, short &gvY, short &gvZ){ |
echo_piyo | 0:bf96e953cdb8 | 1655 | //連続6byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1656 | char rsv[6]; |
echo_piyo | 0:bf96e953cdb8 | 1657 | ctrl->rrc(0, BNO055P0_GRV_DATA_X_LSB, rsv, 6); |
echo_piyo | 0:bf96e953cdb8 | 1658 | |
echo_piyo | 0:bf96e953cdb8 | 1659 | gvX = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1660 | gvY = (rsv[3] << 8) | rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1661 | gvZ = (rsv[5] << 8) | rsv[4]; |
echo_piyo | 0:bf96e953cdb8 | 1662 | } |
echo_piyo | 0:bf96e953cdb8 | 1663 | |
echo_piyo | 0:bf96e953cdb8 | 1664 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1665 | * 重力ベクトル情報(X軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1666 | */ |
echo_piyo | 0:bf96e953cdb8 | 1667 | short BOARDC_BNO055::getGVectorDataX(){ |
echo_piyo | 0:bf96e953cdb8 | 1668 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1669 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1670 | ctrl->rrc(0, BNO055P0_GRV_DATA_X_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1671 | |
echo_piyo | 0:bf96e953cdb8 | 1672 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1673 | } |
echo_piyo | 0:bf96e953cdb8 | 1674 | |
echo_piyo | 0:bf96e953cdb8 | 1675 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1676 | * 重力ベクトル情報(Y軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1677 | */ |
echo_piyo | 0:bf96e953cdb8 | 1678 | short BOARDC_BNO055::getGVectorDataY(){ |
echo_piyo | 0:bf96e953cdb8 | 1679 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1680 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1681 | ctrl->rrc(0, BNO055P0_GRV_DATA_Y_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1682 | |
echo_piyo | 0:bf96e953cdb8 | 1683 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1684 | } |
echo_piyo | 0:bf96e953cdb8 | 1685 | |
echo_piyo | 0:bf96e953cdb8 | 1686 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1687 | * 重力ベクトル情報(Z軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1688 | */ |
echo_piyo | 0:bf96e953cdb8 | 1689 | short BOARDC_BNO055::getGVectorDataZ(){ |
echo_piyo | 0:bf96e953cdb8 | 1690 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 1691 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 1692 | ctrl->rrc(0, BNO055P0_GRV_DATA_Z_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 1693 | |
echo_piyo | 0:bf96e953cdb8 | 1694 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 1695 | } |
echo_piyo | 0:bf96e953cdb8 | 1696 | |
echo_piyo | 0:bf96e953cdb8 | 1697 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1698 | * センサー内部温度情報を取得する |
echo_piyo | 0:bf96e953cdb8 | 1699 | * 内部温度のセンサーは2つあり、どちらか一方のみの温度を返す |
echo_piyo | 0:bf96e953cdb8 | 1700 | * (設定レジスタTEMP_SOURCEにて選択可) |
echo_piyo | 0:bf96e953cdb8 | 1701 | * (setTempSource(bool)にて選択可) |
echo_piyo | 0:bf96e953cdb8 | 1702 | */ |
echo_piyo | 0:bf96e953cdb8 | 1703 | char BOARDC_BNO055::getTemperature(){ |
echo_piyo | 0:bf96e953cdb8 | 1704 | return ctrl->rr(0, BNO055P0_TEMP); |
echo_piyo | 0:bf96e953cdb8 | 1705 | } |
echo_piyo | 0:bf96e953cdb8 | 1706 | |
echo_piyo | 0:bf96e953cdb8 | 1707 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1708 | * キャリブレーション(補正)の状態を取得する |
echo_piyo | 0:bf96e953cdb8 | 1709 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1710 | * &sys: アドレス参照引数:関数実行後、この変数にsystem補正の状態が格納される |
echo_piyo | 0:bf96e953cdb8 | 1711 | * &acc: アドレス参照引数:関数実行後、この変数に加速度センサー補正の状態が格納される |
echo_piyo | 0:bf96e953cdb8 | 1712 | * &mag: アドレス参照引数:関数実行後、この変数に地磁気センサー補正の状態が格納される |
echo_piyo | 0:bf96e953cdb8 | 1713 | * &gyro: アドレス参照引数:関数実行後、この変数に角速度センサー補正の状態が格納される |
echo_piyo | 0:bf96e953cdb8 | 1714 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1715 | * 各補正情報は0 - 100[%]の百分率で返答される。それぞれ2bitであるため |
echo_piyo | 0:bf96e953cdb8 | 1716 | * 値は0[%],32[%],66[%],100[%]のいずれか |
echo_piyo | 0:bf96e953cdb8 | 1717 | */ |
echo_piyo | 0:bf96e953cdb8 | 1718 | void BOARDC_BNO055::getCalibStatusAll(char &sys, char &acc, char &mag, char &gyro){ |
echo_piyo | 0:bf96e953cdb8 | 1719 | char rv = ctrl->rr(0, BNO055P0_CALIB_STAT); |
echo_piyo | 0:bf96e953cdb8 | 1720 | sys = (((rv & 0xC0) >> 6) * 34); |
echo_piyo | 0:bf96e953cdb8 | 1721 | gyro = (((rv & 0x30) >> 4) * 34); |
echo_piyo | 0:bf96e953cdb8 | 1722 | acc = (((rv & 0x0C) >> 2) * 34); |
echo_piyo | 0:bf96e953cdb8 | 1723 | mag = ((rv & 0x03) * 34); |
echo_piyo | 0:bf96e953cdb8 | 1724 | sys -= (sys == 0) ? 0 : 2; |
echo_piyo | 0:bf96e953cdb8 | 1725 | gyro -= (gyro == 0) ? 0 : 2; |
echo_piyo | 0:bf96e953cdb8 | 1726 | acc -= (acc == 0) ? 0 : 2; |
echo_piyo | 0:bf96e953cdb8 | 1727 | mag -= (mag == 0) ? 0 : 2; |
echo_piyo | 0:bf96e953cdb8 | 1728 | } |
echo_piyo | 0:bf96e953cdb8 | 1729 | |
echo_piyo | 0:bf96e953cdb8 | 1730 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1731 | * キャリブレーション(補正)の状態(systemのみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1732 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1733 | * 各補正情報は0 - 100[%]の百分率で返答される。それぞれ2bitであるため |
echo_piyo | 0:bf96e953cdb8 | 1734 | * 値は0[%],32[%],66[%],100[%]のいずれか |
echo_piyo | 0:bf96e953cdb8 | 1735 | */ |
echo_piyo | 0:bf96e953cdb8 | 1736 | char BOARDC_BNO055::getCalibStatusSys(){ |
echo_piyo | 0:bf96e953cdb8 | 1737 | char ret = (((ctrl->rr(0, BNO055P0_CALIB_STAT) & 0xC0) >> 6) * 34) - 2; |
echo_piyo | 0:bf96e953cdb8 | 1738 | return (ret < 0) ? 0 : ret; |
echo_piyo | 0:bf96e953cdb8 | 1739 | } |
echo_piyo | 0:bf96e953cdb8 | 1740 | |
echo_piyo | 0:bf96e953cdb8 | 1741 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1742 | * キャリブレーション(補正)の状態(加速度センサーのみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1743 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1744 | * 各補正情報は0 - 100[%]の百分率で返答される。それぞれ2bitであるため |
echo_piyo | 0:bf96e953cdb8 | 1745 | * 値は0[%],32[%],66[%],100[%]のいずれか |
echo_piyo | 0:bf96e953cdb8 | 1746 | */ |
echo_piyo | 0:bf96e953cdb8 | 1747 | char BOARDC_BNO055::getCalibStatusAcc(){ |
echo_piyo | 0:bf96e953cdb8 | 1748 | char ret = (((ctrl->rr(0, BNO055P0_CALIB_STAT) & 0x0C) >> 2) * 34) - 2; |
echo_piyo | 0:bf96e953cdb8 | 1749 | return (ret < 0) ? 0 : ret; |
echo_piyo | 0:bf96e953cdb8 | 1750 | } |
echo_piyo | 0:bf96e953cdb8 | 1751 | |
echo_piyo | 0:bf96e953cdb8 | 1752 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1753 | * キャリブレーション(補正)の状態(地磁気センサーのみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1754 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1755 | * 各補正情報は0 - 100[%]の百分率で返答される。それぞれ2bitであるため |
echo_piyo | 0:bf96e953cdb8 | 1756 | * 値は0[%],32[%],66[%],100[%]のいずれか |
echo_piyo | 0:bf96e953cdb8 | 1757 | */ |
echo_piyo | 0:bf96e953cdb8 | 1758 | char BOARDC_BNO055::getCalibStatusMag(){ |
echo_piyo | 0:bf96e953cdb8 | 1759 | char ret = ((ctrl->rr(0, BNO055P0_CALIB_STAT) & 0x03) * 34) - 2; |
echo_piyo | 0:bf96e953cdb8 | 1760 | return (ret < 0) ? 0 : ret; |
echo_piyo | 0:bf96e953cdb8 | 1761 | } |
echo_piyo | 0:bf96e953cdb8 | 1762 | |
echo_piyo | 0:bf96e953cdb8 | 1763 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1764 | * キャリブレーション(補正)の状態(角速度センサーのみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1765 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1766 | * 各補正情報は0 - 100[%]の百分率で返答される。それぞれ2bitであるため |
echo_piyo | 0:bf96e953cdb8 | 1767 | * 値は0[%],32[%],66[%],100[%]のいずれか |
echo_piyo | 0:bf96e953cdb8 | 1768 | */ |
echo_piyo | 0:bf96e953cdb8 | 1769 | char BOARDC_BNO055::getCalibStatusGyro(){ |
echo_piyo | 0:bf96e953cdb8 | 1770 | char ret = (((ctrl->rr(0, BNO055P0_CALIB_STAT) & 0x30) >> 4) * 34) - 2; |
echo_piyo | 0:bf96e953cdb8 | 1771 | return (ret < 0) ? 0 : ret; |
echo_piyo | 0:bf96e953cdb8 | 1772 | } |
echo_piyo | 0:bf96e953cdb8 | 1773 | |
echo_piyo | 0:bf96e953cdb8 | 1774 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1775 | * システムおよびセンサーのセルフテストの実行結果を取得する |
echo_piyo | 0:bf96e953cdb8 | 1776 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1777 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1778 | * 1bit目:加速度センサーのセルフテストの実行結果(0:failed(異常), 1:passed(正常)) |
echo_piyo | 0:bf96e953cdb8 | 1779 | * 2bit目:地磁気センサーのセルフテストの実行結果(0:failed(異常), 1:passed(正常)) |
echo_piyo | 0:bf96e953cdb8 | 1780 | * 3bit目:角速度センサーのセルフテストの実行結果(0:failed(異常), 1:passed(正常)) |
echo_piyo | 0:bf96e953cdb8 | 1781 | * 4bit目:内部マイコンのセルフテストの実行結果(0:failed(異常), 1:passed(正常)) |
echo_piyo | 0:bf96e953cdb8 | 1782 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1783 | * 例:戻り値 0x0D (0b00001101) |
echo_piyo | 0:bf96e953cdb8 | 1784 | * >>加速度センサー:正常(1) |
echo_piyo | 0:bf96e953cdb8 | 1785 | * >>地磁気センサー:異常(0) |
echo_piyo | 0:bf96e953cdb8 | 1786 | * >>角速度センサー:正常(1) |
echo_piyo | 0:bf96e953cdb8 | 1787 | * >>内部マイコン:正常(1) |
echo_piyo | 0:bf96e953cdb8 | 1788 | */ |
echo_piyo | 0:bf96e953cdb8 | 1789 | char BOARDC_BNO055::getSelfTestResultAll(){ |
echo_piyo | 0:bf96e953cdb8 | 1790 | return ctrl->rr(0, BNO055P0_ST_RESULT); |
echo_piyo | 0:bf96e953cdb8 | 1791 | } |
echo_piyo | 0:bf96e953cdb8 | 1792 | |
echo_piyo | 0:bf96e953cdb8 | 1793 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1794 | * 内部マイコン(BNO055のMCU)のセルフテストの実行結果を取得する |
echo_piyo | 0:bf96e953cdb8 | 1795 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1796 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1797 | * false:failed(異常) |
echo_piyo | 0:bf96e953cdb8 | 1798 | * true:passed(正常) |
echo_piyo | 0:bf96e953cdb8 | 1799 | */ |
echo_piyo | 0:bf96e953cdb8 | 1800 | bool BOARDC_BNO055::getSelfTestResultMCU(){ |
echo_piyo | 0:bf96e953cdb8 | 1801 | return (((ctrl->rr(0, BNO055P0_ST_RESULT) & 0x08) >> 3) == 1); |
echo_piyo | 0:bf96e953cdb8 | 1802 | } |
echo_piyo | 0:bf96e953cdb8 | 1803 | |
echo_piyo | 0:bf96e953cdb8 | 1804 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1805 | * 加速度センサーのセルフテストの実行結果を取得する |
echo_piyo | 0:bf96e953cdb8 | 1806 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1807 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1808 | * false:failed(異常) |
echo_piyo | 0:bf96e953cdb8 | 1809 | * true:passed(正常) |
echo_piyo | 0:bf96e953cdb8 | 1810 | */ |
echo_piyo | 0:bf96e953cdb8 | 1811 | bool BOARDC_BNO055::getSelfTestResultAcc(){ |
echo_piyo | 0:bf96e953cdb8 | 1812 | return ((ctrl->rr(0, BNO055P0_ST_RESULT) & 0x01) == 1); |
echo_piyo | 0:bf96e953cdb8 | 1813 | } |
echo_piyo | 0:bf96e953cdb8 | 1814 | |
echo_piyo | 0:bf96e953cdb8 | 1815 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1816 | * 地磁気センサーのセルフテストの実行結果を取得する |
echo_piyo | 0:bf96e953cdb8 | 1817 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1818 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1819 | * false:failed(異常) |
echo_piyo | 0:bf96e953cdb8 | 1820 | * true:passed(正常) |
echo_piyo | 0:bf96e953cdb8 | 1821 | */ |
echo_piyo | 0:bf96e953cdb8 | 1822 | bool BOARDC_BNO055::getSelfTestResultMag(){ |
echo_piyo | 0:bf96e953cdb8 | 1823 | return (((ctrl->rr(0, BNO055P0_ST_RESULT) & 0x02) >> 1) == 1); |
echo_piyo | 0:bf96e953cdb8 | 1824 | } |
echo_piyo | 0:bf96e953cdb8 | 1825 | |
echo_piyo | 0:bf96e953cdb8 | 1826 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1827 | * 地磁気センサーのセルフテストの実行結果を取得する |
echo_piyo | 0:bf96e953cdb8 | 1828 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1829 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1830 | * false:failed(異常) |
echo_piyo | 0:bf96e953cdb8 | 1831 | * true:passed(正常) |
echo_piyo | 0:bf96e953cdb8 | 1832 | */ |
echo_piyo | 0:bf96e953cdb8 | 1833 | bool BOARDC_BNO055::getSelfTestResultGyro(){ |
echo_piyo | 0:bf96e953cdb8 | 1834 | return (((ctrl->rr(0, BNO055P0_ST_RESULT) & 0x04) >> 2) == 1); |
echo_piyo | 0:bf96e953cdb8 | 1835 | } |
echo_piyo | 0:bf96e953cdb8 | 1836 | |
echo_piyo | 0:bf96e953cdb8 | 1837 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1838 | * 発生している割り込みステータス情報を取得する |
echo_piyo | 0:bf96e953cdb8 | 1839 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1840 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1841 | * 3bit目:GYRO_AM(角速度AnyMotion発生)(1:発生中, 0:なし) |
echo_piyo | 0:bf96e953cdb8 | 1842 | * 4bit目:GYR_HIGH_RATE(角速度ハイレート発生)(1:発生中, 0:なし) |
echo_piyo | 0:bf96e953cdb8 | 1843 | * 6bit目:ACC_HIGH_G(加速度急加速発生)(1:発生中, 0:なし) |
echo_piyo | 0:bf96e953cdb8 | 1844 | * 7bit目:ACC_AM(角速度AnyMotion発生)(1:発生中, 0:なし) |
echo_piyo | 0:bf96e953cdb8 | 1845 | * 8bit目:ACC_NM(角速度NoMotion発生)(1:発生中, 0:なし) |
echo_piyo | 0:bf96e953cdb8 | 1846 | */ |
echo_piyo | 0:bf96e953cdb8 | 1847 | char BOARDC_BNO055::triggeredIntALL(){ |
echo_piyo | 0:bf96e953cdb8 | 1848 | return ctrl->rr(0, BNO055P0_INT_STA); |
echo_piyo | 0:bf96e953cdb8 | 1849 | } |
echo_piyo | 0:bf96e953cdb8 | 1850 | |
echo_piyo | 0:bf96e953cdb8 | 1851 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1852 | * 発生している割り込みステータス情報(ACC_NM)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1853 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1854 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1855 | * true:ACC_NMトリガー発生中 |
echo_piyo | 0:bf96e953cdb8 | 1856 | * false:ACC_NMトリガーなし |
echo_piyo | 0:bf96e953cdb8 | 1857 | */ |
echo_piyo | 0:bf96e953cdb8 | 1858 | bool BOARDC_BNO055::triggeredACC_NM(){ |
echo_piyo | 0:bf96e953cdb8 | 1859 | return (((ctrl->rr(0, BNO055P0_INT_STA) & 0x80) >> 7) == 1); |
echo_piyo | 0:bf96e953cdb8 | 1860 | } |
echo_piyo | 0:bf96e953cdb8 | 1861 | |
echo_piyo | 0:bf96e953cdb8 | 1862 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1863 | * 発生している割り込みステータス情報(ACC_AM)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1864 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1865 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1866 | * true:ACC_AMトリガー発生中 |
echo_piyo | 0:bf96e953cdb8 | 1867 | * false:ACC_AMトリガーなし |
echo_piyo | 0:bf96e953cdb8 | 1868 | */ |
echo_piyo | 0:bf96e953cdb8 | 1869 | bool BOARDC_BNO055::triggeredACC_AM(){ |
echo_piyo | 0:bf96e953cdb8 | 1870 | return (((ctrl->rr(0, BNO055P0_INT_STA) & 0x40) >> 6) == 1); |
echo_piyo | 0:bf96e953cdb8 | 1871 | } |
echo_piyo | 0:bf96e953cdb8 | 1872 | |
echo_piyo | 0:bf96e953cdb8 | 1873 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1874 | * 発生している割り込みステータス情報(ACC_HIGH_G)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1875 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1876 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1877 | * true:ACC_HIGH_Gトリガー発生中 |
echo_piyo | 0:bf96e953cdb8 | 1878 | * false:ACC_HIGH_Gトリガーなし |
echo_piyo | 0:bf96e953cdb8 | 1879 | */ |
echo_piyo | 0:bf96e953cdb8 | 1880 | bool BOARDC_BNO055::triggeredACC_HIGH_G(){ |
echo_piyo | 0:bf96e953cdb8 | 1881 | return (((ctrl->rr(0, BNO055P0_INT_STA) & 0x20) >> 5) == 1); |
echo_piyo | 0:bf96e953cdb8 | 1882 | } |
echo_piyo | 0:bf96e953cdb8 | 1883 | |
echo_piyo | 0:bf96e953cdb8 | 1884 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1885 | * 発生している割り込みステータス情報(GYR_HIGH_RATE)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1886 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1887 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1888 | * true:GYR_HIGH_RATEトリガー発生中 |
echo_piyo | 0:bf96e953cdb8 | 1889 | * false:GYR_HIGH_RATEトリガーなし |
echo_piyo | 0:bf96e953cdb8 | 1890 | */ |
echo_piyo | 0:bf96e953cdb8 | 1891 | bool BOARDC_BNO055::triggeredGYR_HIGH_RATE(){ |
echo_piyo | 0:bf96e953cdb8 | 1892 | return (((ctrl->rr(0, BNO055P0_INT_STA) & 0x08) >> 3) == 1); |
echo_piyo | 0:bf96e953cdb8 | 1893 | } |
echo_piyo | 0:bf96e953cdb8 | 1894 | |
echo_piyo | 0:bf96e953cdb8 | 1895 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1896 | * 発生している割り込みステータス情報(GYRO_AM)を取得する |
echo_piyo | 0:bf96e953cdb8 | 1897 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1898 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1899 | * true:GYRO_AMトリガー発生中 |
echo_piyo | 0:bf96e953cdb8 | 1900 | * false:GYRO_AMトリガーなし |
echo_piyo | 0:bf96e953cdb8 | 1901 | */ |
echo_piyo | 0:bf96e953cdb8 | 1902 | bool BOARDC_BNO055::triggeredGYRO_AM(){ |
echo_piyo | 0:bf96e953cdb8 | 1903 | return (((ctrl->rr(0, BNO055P0_INT_STA) & 0x04) >> 2) == 1); |
echo_piyo | 0:bf96e953cdb8 | 1904 | } |
echo_piyo | 0:bf96e953cdb8 | 1905 | |
echo_piyo | 0:bf96e953cdb8 | 1906 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1907 | * BNO055のシステムクロック固定情報を取得する |
echo_piyo | 0:bf96e953cdb8 | 1908 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1909 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1910 | * true:設定によって固定されている(SYS_TRIGGEレジスタのCLK_SEL) |
echo_piyo | 0:bf96e953cdb8 | 1911 | * false:設定されていない(内部か外部選択可) |
echo_piyo | 0:bf96e953cdb8 | 1912 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1913 | * setSys_ExternalCrystal(bool)で設定可 |
echo_piyo | 0:bf96e953cdb8 | 1914 | */ |
echo_piyo | 0:bf96e953cdb8 | 1915 | bool BOARDC_BNO055::isSystemClockFixed(){ |
echo_piyo | 0:bf96e953cdb8 | 1916 | return (ctrl->rr(0, BNO055P0_SYS_CLK_STATUS) == 1); |
echo_piyo | 0:bf96e953cdb8 | 1917 | } |
echo_piyo | 0:bf96e953cdb8 | 1918 | |
echo_piyo | 0:bf96e953cdb8 | 1919 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1920 | * BNO055のシステムステータスを取得する |
echo_piyo | 0:bf96e953cdb8 | 1921 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1922 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1923 | * 0: システム待機状態 |
echo_piyo | 0:bf96e953cdb8 | 1924 | * 1: システムエラー |
echo_piyo | 0:bf96e953cdb8 | 1925 | * 2: ペリフェラル初期化中 |
echo_piyo | 0:bf96e953cdb8 | 1926 | * 3: システム初期化中 |
echo_piyo | 0:bf96e953cdb8 | 1927 | * 4: セルフテスト実行中 |
echo_piyo | 0:bf96e953cdb8 | 1928 | * 5: 起動中(Fusionアルゴリズム起動中) |
echo_piyo | 0:bf96e953cdb8 | 1929 | * 6: 起動中(Fusionアルゴリズムなし) |
echo_piyo | 0:bf96e953cdb8 | 1930 | */ |
echo_piyo | 0:bf96e953cdb8 | 1931 | char BOARDC_BNO055::getSystemStatus(){ |
echo_piyo | 0:bf96e953cdb8 | 1932 | return ctrl->rr(0, BNO055P0_SYS_STATUS); |
echo_piyo | 0:bf96e953cdb8 | 1933 | } |
echo_piyo | 0:bf96e953cdb8 | 1934 | |
echo_piyo | 0:bf96e953cdb8 | 1935 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1936 | * BNO055のシステムエラー情報を取得する |
echo_piyo | 0:bf96e953cdb8 | 1937 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1938 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1939 | * 0: エラーなし |
echo_piyo | 0:bf96e953cdb8 | 1940 | * 1: ペリフェラル初期化エラー |
echo_piyo | 0:bf96e953cdb8 | 1941 | * 2: システム初期化エラー |
echo_piyo | 0:bf96e953cdb8 | 1942 | * 3: セルフテスト結果不調 |
echo_piyo | 0:bf96e953cdb8 | 1943 | * 4: レジスタマップエラー(値の範囲外) |
echo_piyo | 0:bf96e953cdb8 | 1944 | * 5: レジスタマップエラー(アドレスの範囲外) |
echo_piyo | 0:bf96e953cdb8 | 1945 | * 6: レジスタマップエラー(書き込み不能) |
echo_piyo | 0:bf96e953cdb8 | 1946 | * 7: BNO005LowPowerモードにつき指定モード実行不可 |
echo_piyo | 0:bf96e953cdb8 | 1947 | * 8: 加速度センサーPowerMode実行不可 |
echo_piyo | 0:bf96e953cdb8 | 1948 | * 9: Fusionアルゴリズム設定エラー |
echo_piyo | 0:bf96e953cdb8 | 1949 | * 10: 各センサー設定エラー |
echo_piyo | 0:bf96e953cdb8 | 1950 | */ |
echo_piyo | 0:bf96e953cdb8 | 1951 | char BOARDC_BNO055::getSystemError(){ |
echo_piyo | 0:bf96e953cdb8 | 1952 | return ctrl->rr(0, BNO055P0_SYS_ERR); |
echo_piyo | 0:bf96e953cdb8 | 1953 | } |
echo_piyo | 0:bf96e953cdb8 | 1954 | |
echo_piyo | 0:bf96e953cdb8 | 1955 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1956 | * システムの設定単位系を取得する |
echo_piyo | 0:bf96e953cdb8 | 1957 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1958 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1959 | * 1bit目: 加速度センサー単位系(0:m/s^2, 1:mg) |
echo_piyo | 0:bf96e953cdb8 | 1960 | * 2bit目: 角速度センサー単位系(0:deg/s, 1:rad/s) |
echo_piyo | 0:bf96e953cdb8 | 1961 | * 3bit目: オイラー角単位系(0:deg, 1:rad) |
echo_piyo | 0:bf96e953cdb8 | 1962 | * 5bit目: 温度単位系(0:摂氏, 1:華氏) |
echo_piyo | 0:bf96e953cdb8 | 1963 | * 7bit目: 出力設定(0:Windows, 1:Android) |
echo_piyo | 0:bf96e953cdb8 | 1964 | */ |
echo_piyo | 0:bf96e953cdb8 | 1965 | char BOARDC_BNO055::getUNIT_SEL(){ |
echo_piyo | 0:bf96e953cdb8 | 1966 | return ctrl->rr(0, BNO055P0_UNIT_SEL); |
echo_piyo | 0:bf96e953cdb8 | 1967 | } |
echo_piyo | 0:bf96e953cdb8 | 1968 | |
echo_piyo | 0:bf96e953cdb8 | 1969 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1970 | * システムの設定単位系を設定する |
echo_piyo | 0:bf96e953cdb8 | 1971 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1972 | * 引数selectValue: |
echo_piyo | 0:bf96e953cdb8 | 1973 | * 1bit目: 加速度センサー単位系(0:m/s^2, 1:mg) |
echo_piyo | 0:bf96e953cdb8 | 1974 | * 2bit目: 角速度センサー単位系(0:deg/s, 1:rad/s) |
echo_piyo | 0:bf96e953cdb8 | 1975 | * 3bit目: オイラー角単位系(0:deg, 1:rad) |
echo_piyo | 0:bf96e953cdb8 | 1976 | * 5bit目: 温度単位系(0:摂氏, 1:華氏) |
echo_piyo | 0:bf96e953cdb8 | 1977 | * 7bit目: 出力設定(0:Windows, 1:Android) |
echo_piyo | 0:bf96e953cdb8 | 1978 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 1979 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 1980 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 1981 | */ |
echo_piyo | 0:bf96e953cdb8 | 1982 | char BOARDC_BNO055::setUNIT_SEL(char selectValue){ |
echo_piyo | 0:bf96e953cdb8 | 1983 | if(ctrl->wr(0, BNO055P0_UNIT_SEL, selectValue) == -1) return -1; |
echo_piyo | 0:bf96e953cdb8 | 1984 | |
echo_piyo | 0:bf96e953cdb8 | 1985 | scaleACC = ((selectValue & 0x01) == 0) ? 0.01f : 1.0f; |
echo_piyo | 0:bf96e953cdb8 | 1986 | scaleGYRO = ((selectValue & 0x02) == 0) ? 0.0625f : 0.001111111111f; |
echo_piyo | 0:bf96e953cdb8 | 1987 | scaleEuler = ((selectValue & 0x04) == 0) ? 0.0625f : 0.001111111111f; |
echo_piyo | 0:bf96e953cdb8 | 1988 | scaleTEMP = ((selectValue & 0x10) == 0) ? 1.0f : 2.0f; |
echo_piyo | 0:bf96e953cdb8 | 1989 | scaleLIA = scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 1990 | scaleGV = scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 1991 | |
echo_piyo | 0:bf96e953cdb8 | 1992 | return 1; |
echo_piyo | 0:bf96e953cdb8 | 1993 | } |
echo_piyo | 0:bf96e953cdb8 | 1994 | |
echo_piyo | 0:bf96e953cdb8 | 1995 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 1996 | * システムの設定単位系(加速度センサー)を設定する |
echo_piyo | 0:bf96e953cdb8 | 1997 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 1998 | * 引数isMeterPerSec2: |
echo_piyo | 0:bf96e953cdb8 | 1999 | * true: m/s^2 |
echo_piyo | 0:bf96e953cdb8 | 2000 | * false: mg |
echo_piyo | 0:bf96e953cdb8 | 2001 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2002 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2003 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2004 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2005 | */ |
echo_piyo | 0:bf96e953cdb8 | 2006 | char BOARDC_BNO055::setUNIT_AccUnit(bool isMeterPerSec2){ |
echo_piyo | 0:bf96e953cdb8 | 2007 | char val = getUNIT_SEL() & 0xFE; |
echo_piyo | 0:bf96e953cdb8 | 2008 | if(!isMeterPerSec2) val += 1; |
echo_piyo | 0:bf96e953cdb8 | 2009 | return setUNIT_SEL(val); |
echo_piyo | 0:bf96e953cdb8 | 2010 | } |
echo_piyo | 0:bf96e953cdb8 | 2011 | |
echo_piyo | 0:bf96e953cdb8 | 2012 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2013 | * システムの設定単位系(角速度センサー)を設定する |
echo_piyo | 0:bf96e953cdb8 | 2014 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2015 | * 引数isDps: |
echo_piyo | 0:bf96e953cdb8 | 2016 | * true: dps(Degrees/s) |
echo_piyo | 0:bf96e953cdb8 | 2017 | * false: rps(Radians/s) |
echo_piyo | 0:bf96e953cdb8 | 2018 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2019 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2020 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2021 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2022 | */ |
echo_piyo | 0:bf96e953cdb8 | 2023 | char BOARDC_BNO055::setUNIT_GyroUnit(bool isDps){ |
echo_piyo | 0:bf96e953cdb8 | 2024 | char val = getUNIT_SEL() & 0xFD; |
echo_piyo | 0:bf96e953cdb8 | 2025 | if(!isDps) val += 2; |
echo_piyo | 0:bf96e953cdb8 | 2026 | return setUNIT_SEL(val); |
echo_piyo | 0:bf96e953cdb8 | 2027 | } |
echo_piyo | 0:bf96e953cdb8 | 2028 | |
echo_piyo | 0:bf96e953cdb8 | 2029 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2030 | * システムの設定単位系(オイラー角)を設定する |
echo_piyo | 0:bf96e953cdb8 | 2031 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2032 | * 引数isDegrees: |
echo_piyo | 0:bf96e953cdb8 | 2033 | * true: Degrees |
echo_piyo | 0:bf96e953cdb8 | 2034 | * false: Radians |
echo_piyo | 0:bf96e953cdb8 | 2035 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2036 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2037 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2038 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2039 | */ |
echo_piyo | 0:bf96e953cdb8 | 2040 | char BOARDC_BNO055::setUNIT_EulerUnit(bool isDegrees){ |
echo_piyo | 0:bf96e953cdb8 | 2041 | char val = getUNIT_SEL() & 0xFB; |
echo_piyo | 0:bf96e953cdb8 | 2042 | if(!isDegrees) val += 4; |
echo_piyo | 0:bf96e953cdb8 | 2043 | return setUNIT_SEL(val); |
echo_piyo | 0:bf96e953cdb8 | 2044 | } |
echo_piyo | 0:bf96e953cdb8 | 2045 | |
echo_piyo | 0:bf96e953cdb8 | 2046 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2047 | * システムの設定単位系(温度)を設定する |
echo_piyo | 0:bf96e953cdb8 | 2048 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2049 | * 引数isCelsius: |
echo_piyo | 0:bf96e953cdb8 | 2050 | * true: 摂氏(Celsius) |
echo_piyo | 0:bf96e953cdb8 | 2051 | * false: 華氏(Fahrenheit) |
echo_piyo | 0:bf96e953cdb8 | 2052 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2053 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2054 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2055 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2056 | */ |
echo_piyo | 0:bf96e953cdb8 | 2057 | char BOARDC_BNO055::setUNIT_Temperature(bool isCelsius){ |
echo_piyo | 0:bf96e953cdb8 | 2058 | char val = getUNIT_SEL() & 0xEF; |
echo_piyo | 0:bf96e953cdb8 | 2059 | if(!isCelsius) val += 16; |
echo_piyo | 0:bf96e953cdb8 | 2060 | return setUNIT_SEL(val); |
echo_piyo | 0:bf96e953cdb8 | 2061 | } |
echo_piyo | 0:bf96e953cdb8 | 2062 | |
echo_piyo | 0:bf96e953cdb8 | 2063 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2064 | * システムの設定単位系(出力設定)を設定する |
echo_piyo | 0:bf96e953cdb8 | 2065 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2066 | * 引数ori_Android: |
echo_piyo | 0:bf96e953cdb8 | 2067 | * true: Android用(Pitch角:+180 to -180 反時計回り+) |
echo_piyo | 0:bf96e953cdb8 | 2068 | * false: Windows用(Pitch角:-180 to +180 時計回り+) |
echo_piyo | 0:bf96e953cdb8 | 2069 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2070 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2071 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2072 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2073 | */ |
echo_piyo | 0:bf96e953cdb8 | 2074 | char BOARDC_BNO055::setUNIT_OrientationMode(bool ori_Android){ |
echo_piyo | 0:bf96e953cdb8 | 2075 | char val = getUNIT_SEL() & 0xBF; |
echo_piyo | 0:bf96e953cdb8 | 2076 | if(!ori_Android) val += 64; |
echo_piyo | 0:bf96e953cdb8 | 2077 | return setUNIT_SEL(val); |
echo_piyo | 0:bf96e953cdb8 | 2078 | } |
echo_piyo | 0:bf96e953cdb8 | 2079 | |
echo_piyo | 0:bf96e953cdb8 | 2080 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2081 | * システムの動作モードを取得する |
echo_piyo | 0:bf96e953cdb8 | 2082 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2083 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2084 | * 1 ACCONLY(NO FUSION)加速度のみ |
echo_piyo | 0:bf96e953cdb8 | 2085 | * 2 MAGONLY(NO FUSION)地磁気のみ |
echo_piyo | 0:bf96e953cdb8 | 2086 | * 3 GYROONLY(NO FUSION)角速度のみ |
echo_piyo | 0:bf96e953cdb8 | 2087 | * 4 ACCMAG(NO FUSION)加速度と地磁気 |
echo_piyo | 0:bf96e953cdb8 | 2088 | * 5 ACCGYRO(NO FUSION)加速度と角速度 |
echo_piyo | 0:bf96e953cdb8 | 2089 | * 6 MAGGYRO(NO FUSION)地磁気と角速度 |
echo_piyo | 0:bf96e953cdb8 | 2090 | * 7 AMG(NO FUSION)加速度、地磁気、角速度 |
echo_piyo | 0:bf96e953cdb8 | 2091 | * 8 IMU |
echo_piyo | 0:bf96e953cdb8 | 2092 | * 9 COMPASS |
echo_piyo | 0:bf96e953cdb8 | 2093 | * 10 M4G |
echo_piyo | 0:bf96e953cdb8 | 2094 | * 11 NDOF_FMC_OFF |
echo_piyo | 0:bf96e953cdb8 | 2095 | * 12 NDOF |
echo_piyo | 0:bf96e953cdb8 | 2096 | */ |
echo_piyo | 0:bf96e953cdb8 | 2097 | char BOARDC_BNO055::getOperationMode(){ |
echo_piyo | 0:bf96e953cdb8 | 2098 | return ctrl->rr(0, BNO055P0_OPR_MODE); |
echo_piyo | 0:bf96e953cdb8 | 2099 | } |
echo_piyo | 0:bf96e953cdb8 | 2100 | |
echo_piyo | 0:bf96e953cdb8 | 2101 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2102 | * システムの動作モードを設定する |
echo_piyo | 0:bf96e953cdb8 | 2103 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2104 | * 引数modeValue: |
echo_piyo | 0:bf96e953cdb8 | 2105 | * 1 ACCONLY(NO FUSION)加速度のみ |
echo_piyo | 0:bf96e953cdb8 | 2106 | * 2 MAGONLY(NO FUSION)地磁気のみ |
echo_piyo | 0:bf96e953cdb8 | 2107 | * 3 GYROONLY(NO FUSION)角速度のみ |
echo_piyo | 0:bf96e953cdb8 | 2108 | * 4 ACCMAG(NO FUSION)加速度と地磁気 |
echo_piyo | 0:bf96e953cdb8 | 2109 | * 5 ACCGYRO(NO FUSION)加速度と角速度 |
echo_piyo | 0:bf96e953cdb8 | 2110 | * 6 MAGGYRO(NO FUSION)地磁気と角速度 |
echo_piyo | 0:bf96e953cdb8 | 2111 | * 7 AMG(NO FUSION)加速度、地磁気、角速度 |
echo_piyo | 0:bf96e953cdb8 | 2112 | * 8 IMU |
echo_piyo | 0:bf96e953cdb8 | 2113 | * 9 COMPASS |
echo_piyo | 0:bf96e953cdb8 | 2114 | * 10 M4G |
echo_piyo | 0:bf96e953cdb8 | 2115 | * 11 NDOF_FMC_OFF |
echo_piyo | 0:bf96e953cdb8 | 2116 | * 12 NDOF |
echo_piyo | 0:bf96e953cdb8 | 2117 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2118 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2119 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2120 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2121 | */ |
echo_piyo | 0:bf96e953cdb8 | 2122 | char BOARDC_BNO055::setOperationMode(char modeValue){ |
echo_piyo | 0:bf96e953cdb8 | 2123 | if(modeValue < 0 || modeValue > 12) modeValue = 7; |
echo_piyo | 0:bf96e953cdb8 | 2124 | return ctrl->wr(0, BNO055P0_OPR_MODE, modeValue); |
echo_piyo | 0:bf96e953cdb8 | 2125 | } |
echo_piyo | 0:bf96e953cdb8 | 2126 | |
echo_piyo | 0:bf96e953cdb8 | 2127 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2128 | * システムの動作モードを設定モードに設定する |
echo_piyo | 0:bf96e953cdb8 | 2129 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2130 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2131 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2132 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2133 | */ |
echo_piyo | 0:bf96e953cdb8 | 2134 | char BOARDC_BNO055::setOperation_CONFIG(){ |
echo_piyo | 0:bf96e953cdb8 | 2135 | return ctrl->wr(0, BNO055P0_OPR_MODE, 0); |
echo_piyo | 0:bf96e953cdb8 | 2136 | } |
echo_piyo | 0:bf96e953cdb8 | 2137 | |
echo_piyo | 0:bf96e953cdb8 | 2138 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2139 | * システムの動作モードを加速度モードに設定する |
echo_piyo | 0:bf96e953cdb8 | 2140 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2141 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2142 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2143 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2144 | */ |
echo_piyo | 0:bf96e953cdb8 | 2145 | char BOARDC_BNO055::setOperation_ACCONRY(){ |
echo_piyo | 0:bf96e953cdb8 | 2146 | return ctrl->wr(0, BNO055P0_OPR_MODE, 1); |
echo_piyo | 0:bf96e953cdb8 | 2147 | } |
echo_piyo | 0:bf96e953cdb8 | 2148 | |
echo_piyo | 0:bf96e953cdb8 | 2149 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2150 | * システムの動作モードを地磁気モードに設定する |
echo_piyo | 0:bf96e953cdb8 | 2151 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2152 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2153 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2154 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2155 | */ |
echo_piyo | 0:bf96e953cdb8 | 2156 | char BOARDC_BNO055::setOperation_MAGONRY(){ |
echo_piyo | 0:bf96e953cdb8 | 2157 | return ctrl->wr(0, BNO055P0_OPR_MODE, 2); |
echo_piyo | 0:bf96e953cdb8 | 2158 | } |
echo_piyo | 0:bf96e953cdb8 | 2159 | |
echo_piyo | 0:bf96e953cdb8 | 2160 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2161 | * システムの動作モードを角速度モードに設定する |
echo_piyo | 0:bf96e953cdb8 | 2162 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2163 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2164 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2165 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2166 | */ |
echo_piyo | 0:bf96e953cdb8 | 2167 | char BOARDC_BNO055::setOperation_GYROONRY(){ |
echo_piyo | 0:bf96e953cdb8 | 2168 | return ctrl->wr(0, BNO055P0_OPR_MODE, 3); |
echo_piyo | 0:bf96e953cdb8 | 2169 | } |
echo_piyo | 0:bf96e953cdb8 | 2170 | |
echo_piyo | 0:bf96e953cdb8 | 2171 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2172 | * システムの動作モードを加速度地磁気モードに設定する |
echo_piyo | 0:bf96e953cdb8 | 2173 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2174 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2175 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2176 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2177 | */ |
echo_piyo | 0:bf96e953cdb8 | 2178 | char BOARDC_BNO055::setOperation_ACCMAG(){ |
echo_piyo | 0:bf96e953cdb8 | 2179 | return ctrl->wr(0, BNO055P0_OPR_MODE, 4); |
echo_piyo | 0:bf96e953cdb8 | 2180 | } |
echo_piyo | 0:bf96e953cdb8 | 2181 | |
echo_piyo | 0:bf96e953cdb8 | 2182 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2183 | * システムの動作モードを加速度角速度モードに設定する |
echo_piyo | 0:bf96e953cdb8 | 2184 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2185 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2186 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2187 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2188 | */ |
echo_piyo | 0:bf96e953cdb8 | 2189 | char BOARDC_BNO055::setOperation_ACCGYRO(){ |
echo_piyo | 0:bf96e953cdb8 | 2190 | return ctrl->wr(0, BNO055P0_OPR_MODE, 5); |
echo_piyo | 0:bf96e953cdb8 | 2191 | } |
echo_piyo | 0:bf96e953cdb8 | 2192 | |
echo_piyo | 0:bf96e953cdb8 | 2193 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2194 | * システムの動作モードを地磁気角速度モードに設定する |
echo_piyo | 0:bf96e953cdb8 | 2195 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2196 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2197 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2198 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2199 | */ |
echo_piyo | 0:bf96e953cdb8 | 2200 | char BOARDC_BNO055::setOperation_MAGGYRO(){ |
echo_piyo | 0:bf96e953cdb8 | 2201 | return ctrl->wr(0, BNO055P0_OPR_MODE, 6); |
echo_piyo | 0:bf96e953cdb8 | 2202 | } |
echo_piyo | 0:bf96e953cdb8 | 2203 | |
echo_piyo | 0:bf96e953cdb8 | 2204 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2205 | * システムの動作モードをFusionなし9軸モードに設定する |
echo_piyo | 0:bf96e953cdb8 | 2206 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2207 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2208 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2209 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2210 | */ |
echo_piyo | 0:bf96e953cdb8 | 2211 | char BOARDC_BNO055::setOperation_AMG(){ |
echo_piyo | 0:bf96e953cdb8 | 2212 | return ctrl->wr(0, BNO055P0_OPR_MODE, 7); |
echo_piyo | 0:bf96e953cdb8 | 2213 | } |
echo_piyo | 0:bf96e953cdb8 | 2214 | |
echo_piyo | 0:bf96e953cdb8 | 2215 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2216 | * システムの動作モードを6軸(加速度、角速度)Fusionモードに設定する |
echo_piyo | 0:bf96e953cdb8 | 2217 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2218 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2219 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2220 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2221 | */ |
echo_piyo | 0:bf96e953cdb8 | 2222 | char BOARDC_BNO055::setOperation_Fusion_IMU(){ |
echo_piyo | 0:bf96e953cdb8 | 2223 | return ctrl->wr(0, BNO055P0_OPR_MODE, 8); |
echo_piyo | 0:bf96e953cdb8 | 2224 | } |
echo_piyo | 0:bf96e953cdb8 | 2225 | |
echo_piyo | 0:bf96e953cdb8 | 2226 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2227 | * システムの動作モードを6軸(加速度、地磁気)Fusionモード(相対系)に設定する |
echo_piyo | 0:bf96e953cdb8 | 2228 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2229 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2230 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2231 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2232 | */ |
echo_piyo | 0:bf96e953cdb8 | 2233 | char BOARDC_BNO055::setOperation_Fusion_COMPASS(){ |
echo_piyo | 0:bf96e953cdb8 | 2234 | return ctrl->wr(0, BNO055P0_OPR_MODE, 9); |
echo_piyo | 0:bf96e953cdb8 | 2235 | } |
echo_piyo | 0:bf96e953cdb8 | 2236 | |
echo_piyo | 0:bf96e953cdb8 | 2237 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2238 | * システムの動作モードを6軸(加速度、地磁気)Fusionモード(絶対系)に設定する |
echo_piyo | 0:bf96e953cdb8 | 2239 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2240 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2241 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2242 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2243 | */ |
echo_piyo | 0:bf96e953cdb8 | 2244 | char BOARDC_BNO055::setOperation_Fusion_M4G(){ |
echo_piyo | 0:bf96e953cdb8 | 2245 | return ctrl->wr(0, BNO055P0_OPR_MODE, 10); |
echo_piyo | 0:bf96e953cdb8 | 2246 | } |
echo_piyo | 0:bf96e953cdb8 | 2247 | |
echo_piyo | 0:bf96e953cdb8 | 2248 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2249 | * システムの動作モードをNDOFモード(地磁気短時間補正OFF)に設定する |
echo_piyo | 0:bf96e953cdb8 | 2250 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2251 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2252 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2253 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2254 | */ |
echo_piyo | 0:bf96e953cdb8 | 2255 | char BOARDC_BNO055::setOperation_Fusion_NDOF_FMC_OFF(){ |
echo_piyo | 0:bf96e953cdb8 | 2256 | return ctrl->wr(0, BNO055P0_OPR_MODE, 11); |
echo_piyo | 0:bf96e953cdb8 | 2257 | } |
echo_piyo | 0:bf96e953cdb8 | 2258 | |
echo_piyo | 0:bf96e953cdb8 | 2259 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2260 | * システムの動作モードをNDOFモードに設定する |
echo_piyo | 0:bf96e953cdb8 | 2261 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2262 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2263 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2264 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2265 | */ |
echo_piyo | 0:bf96e953cdb8 | 2266 | char BOARDC_BNO055::setOperation_Fusion_NDOF(){ |
echo_piyo | 0:bf96e953cdb8 | 2267 | return ctrl->wr(0, BNO055P0_OPR_MODE, 12); |
echo_piyo | 0:bf96e953cdb8 | 2268 | } |
echo_piyo | 0:bf96e953cdb8 | 2269 | |
echo_piyo | 0:bf96e953cdb8 | 2270 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2271 | * システムの電源モードを取得する |
echo_piyo | 0:bf96e953cdb8 | 2272 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2273 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2274 | * 0: Normal |
echo_piyo | 0:bf96e953cdb8 | 2275 | * 1: LowPower |
echo_piyo | 0:bf96e953cdb8 | 2276 | * 2: Suspend |
echo_piyo | 0:bf96e953cdb8 | 2277 | */ |
echo_piyo | 0:bf96e953cdb8 | 2278 | char BOARDC_BNO055::getPowerMode(){ |
echo_piyo | 0:bf96e953cdb8 | 2279 | return ctrl->rr(0, BNO055P0_PWR_MODE); |
echo_piyo | 0:bf96e953cdb8 | 2280 | } |
echo_piyo | 0:bf96e953cdb8 | 2281 | |
echo_piyo | 0:bf96e953cdb8 | 2282 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2283 | * システムの電源モードを設定する |
echo_piyo | 0:bf96e953cdb8 | 2284 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2285 | * modeValue: |
echo_piyo | 0:bf96e953cdb8 | 2286 | * 0: Normal |
echo_piyo | 0:bf96e953cdb8 | 2287 | * 1: LowPower |
echo_piyo | 0:bf96e953cdb8 | 2288 | * 2: Suspend |
echo_piyo | 0:bf96e953cdb8 | 2289 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2290 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2291 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2292 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2293 | */ |
echo_piyo | 0:bf96e953cdb8 | 2294 | char BOARDC_BNO055::setPowerMode(unsigned char modeValue){ |
echo_piyo | 0:bf96e953cdb8 | 2295 | if(modeValue > 2) return -1; |
echo_piyo | 0:bf96e953cdb8 | 2296 | return ctrl->wr(0, BNO055P0_PWR_MODE, modeValue); |
echo_piyo | 0:bf96e953cdb8 | 2297 | } |
echo_piyo | 0:bf96e953cdb8 | 2298 | |
echo_piyo | 0:bf96e953cdb8 | 2299 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2300 | * システムの電源モードを通常モードに設定する |
echo_piyo | 0:bf96e953cdb8 | 2301 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2302 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2303 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2304 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2305 | */ |
echo_piyo | 0:bf96e953cdb8 | 2306 | char BOARDC_BNO055::setPowerMode_Normal(){ |
echo_piyo | 0:bf96e953cdb8 | 2307 | return ctrl->wr(0, BNO055P0_PWR_MODE, 0); |
echo_piyo | 0:bf96e953cdb8 | 2308 | } |
echo_piyo | 0:bf96e953cdb8 | 2309 | |
echo_piyo | 0:bf96e953cdb8 | 2310 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2311 | * システムの電源モードを低消費電力モードに設定する |
echo_piyo | 0:bf96e953cdb8 | 2312 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2313 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2314 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2315 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2316 | */ |
echo_piyo | 0:bf96e953cdb8 | 2317 | char BOARDC_BNO055::setPowerMode_LowPower(){ |
echo_piyo | 0:bf96e953cdb8 | 2318 | return ctrl->wr(0, BNO055P0_PWR_MODE, 1); |
echo_piyo | 0:bf96e953cdb8 | 2319 | } |
echo_piyo | 0:bf96e953cdb8 | 2320 | |
echo_piyo | 0:bf96e953cdb8 | 2321 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2322 | * システムの電源モードをスリープモードに設定する |
echo_piyo | 0:bf96e953cdb8 | 2323 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2324 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2325 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2326 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2327 | */ |
echo_piyo | 0:bf96e953cdb8 | 2328 | char BOARDC_BNO055::setPowerMode_Suspend(){ |
echo_piyo | 0:bf96e953cdb8 | 2329 | return ctrl->wr(0, BNO055P0_PWR_MODE, 2); |
echo_piyo | 0:bf96e953cdb8 | 2330 | } |
echo_piyo | 0:bf96e953cdb8 | 2331 | |
echo_piyo | 0:bf96e953cdb8 | 2332 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2333 | * システムのトリガー設定を変更する |
echo_piyo | 0:bf96e953cdb8 | 2334 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2335 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2336 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2337 | * 0 変更なし |
echo_piyo | 0:bf96e953cdb8 | 2338 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2339 | */ |
echo_piyo | 0:bf96e953cdb8 | 2340 | char BOARDC_BNO055::setSysTrigger(char regVal){ |
echo_piyo | 0:bf96e953cdb8 | 2341 | clkExt = regVal >> 7; |
echo_piyo | 0:bf96e953cdb8 | 2342 | return ctrl->wr(0, BNO055P0_SYS_TRIGGER, regVal & 0xE1); |
echo_piyo | 0:bf96e953cdb8 | 2343 | } |
echo_piyo | 0:bf96e953cdb8 | 2344 | |
echo_piyo | 0:bf96e953cdb8 | 2345 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2346 | * システムのクロック発振元を設定する |
echo_piyo | 0:bf96e953cdb8 | 2347 | * 外部を指定する場合は、設定前にXIN,XOUTが発振子に結線されている必要がある |
echo_piyo | 0:bf96e953cdb8 | 2348 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2349 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2350 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2351 | * 0 変更なし |
echo_piyo | 0:bf96e953cdb8 | 2352 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2353 | */ |
echo_piyo | 0:bf96e953cdb8 | 2354 | char BOARDC_BNO055::setSys_ExternalCrystal(bool isExternal){ |
echo_piyo | 0:bf96e953cdb8 | 2355 | if(clkExt == isExternal) return 0; |
echo_piyo | 0:bf96e953cdb8 | 2356 | |
echo_piyo | 0:bf96e953cdb8 | 2357 | clkExt = isExternal; |
echo_piyo | 0:bf96e953cdb8 | 2358 | return ctrl->wr(0, BNO055P0_SYS_TRIGGER, (clkExt) ? 0x80 : 0x00); |
echo_piyo | 0:bf96e953cdb8 | 2359 | } |
echo_piyo | 0:bf96e953cdb8 | 2360 | |
echo_piyo | 0:bf96e953cdb8 | 2361 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2362 | * システムの割り込み発生をすべてリセットする |
echo_piyo | 0:bf96e953cdb8 | 2363 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2364 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2365 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2366 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2367 | */ |
echo_piyo | 0:bf96e953cdb8 | 2368 | char BOARDC_BNO055::resetInterrupt(){ |
echo_piyo | 0:bf96e953cdb8 | 2369 | return ctrl->wr(0, BNO055P0_SYS_TRIGGER, ((clkExt) ? 0x80 : 0x00) | 0x40); |
echo_piyo | 0:bf96e953cdb8 | 2370 | } |
echo_piyo | 0:bf96e953cdb8 | 2371 | |
echo_piyo | 0:bf96e953cdb8 | 2372 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2373 | * システムをリセットする |
echo_piyo | 0:bf96e953cdb8 | 2374 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2375 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2376 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2377 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2378 | */ |
echo_piyo | 0:bf96e953cdb8 | 2379 | char BOARDC_BNO055::soft_reset(){ |
echo_piyo | 0:bf96e953cdb8 | 2380 | return ctrl->wr(0, BNO055P0_SYS_TRIGGER, ((clkExt) ? 0x80 : 0x00) | 0x20); |
echo_piyo | 0:bf96e953cdb8 | 2381 | } |
echo_piyo | 0:bf96e953cdb8 | 2382 | |
echo_piyo | 0:bf96e953cdb8 | 2383 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2384 | * セルフテストを実行する |
echo_piyo | 0:bf96e953cdb8 | 2385 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2386 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2387 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2388 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2389 | */ |
echo_piyo | 0:bf96e953cdb8 | 2390 | char BOARDC_BNO055::execSelfTest(){ |
echo_piyo | 0:bf96e953cdb8 | 2391 | return ctrl->wr(0, BNO055P0_SYS_TRIGGER, ((clkExt) ? 0x80 : 0x00) | 0x01); |
echo_piyo | 0:bf96e953cdb8 | 2392 | } |
echo_piyo | 0:bf96e953cdb8 | 2393 | |
echo_piyo | 0:bf96e953cdb8 | 2394 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2395 | * システムの温度計測に使用するセンサーを取得する |
echo_piyo | 0:bf96e953cdb8 | 2396 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2397 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2398 | * 0 温度計測に加速度センサーを使用している |
echo_piyo | 0:bf96e953cdb8 | 2399 | * 1 温度計測に角速度センサーを使用している |
echo_piyo | 0:bf96e953cdb8 | 2400 | */ |
echo_piyo | 0:bf96e953cdb8 | 2401 | char BOARDC_BNO055::getTempSource(){ |
echo_piyo | 0:bf96e953cdb8 | 2402 | return ctrl->rr(0, BNO055P0_TEMP_SOURCE); |
echo_piyo | 0:bf96e953cdb8 | 2403 | } |
echo_piyo | 0:bf96e953cdb8 | 2404 | |
echo_piyo | 0:bf96e953cdb8 | 2405 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2406 | * システムの温度計測に使用するセンサーを選択する |
echo_piyo | 0:bf96e953cdb8 | 2407 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2408 | * 引数Accelerometer: |
echo_piyo | 0:bf96e953cdb8 | 2409 | * true:加速度センサーを温度計測に使用する |
echo_piyo | 0:bf96e953cdb8 | 2410 | * false:角速度センサーを温度計測に使用する |
echo_piyo | 0:bf96e953cdb8 | 2411 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2412 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2413 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2414 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2415 | */ |
echo_piyo | 0:bf96e953cdb8 | 2416 | char BOARDC_BNO055::setTempSource(bool Accelerometer){ |
echo_piyo | 0:bf96e953cdb8 | 2417 | return ctrl->wr(0, BNO055P0_TEMP_SOURCE, (Accelerometer) ? 0 : 1); |
echo_piyo | 0:bf96e953cdb8 | 2418 | } |
echo_piyo | 0:bf96e953cdb8 | 2419 | |
echo_piyo | 0:bf96e953cdb8 | 2420 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2421 | * センサー出力軸交換情報の取得 |
echo_piyo | 0:bf96e953cdb8 | 2422 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2423 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2424 | * AXIS_MAP_CONFIGの設定情報:BNO055データシート [3.4 Axis remap] を参照 |
echo_piyo | 0:bf96e953cdb8 | 2425 | */ |
echo_piyo | 0:bf96e953cdb8 | 2426 | char BOARDC_BNO055::getAxisMapConfig(){ |
echo_piyo | 0:bf96e953cdb8 | 2427 | char ret = ctrl->rr(0, BNO055P0_AXIS_MAP_CONFIG); |
echo_piyo | 0:bf96e953cdb8 | 2428 | if(axisRemap != ret) axisRemap = ret; |
echo_piyo | 0:bf96e953cdb8 | 2429 | return axisRemap; |
echo_piyo | 0:bf96e953cdb8 | 2430 | } |
echo_piyo | 0:bf96e953cdb8 | 2431 | |
echo_piyo | 0:bf96e953cdb8 | 2432 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2433 | * センサー出力軸交換の設定 |
echo_piyo | 0:bf96e953cdb8 | 2434 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2435 | * 引数val: |
echo_piyo | 0:bf96e953cdb8 | 2436 | * X,Y,Zの出力交換の情報 |
echo_piyo | 0:bf96e953cdb8 | 2437 | * (BNO055データシート [3.4 Axis remap] を参照 |
echo_piyo | 0:bf96e953cdb8 | 2438 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2439 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2440 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2441 | * 0 変更なし |
echo_piyo | 0:bf96e953cdb8 | 2442 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2443 | */ |
echo_piyo | 0:bf96e953cdb8 | 2444 | char BOARDC_BNO055::setAxisMapConfig(char val){ |
echo_piyo | 0:bf96e953cdb8 | 2445 | if(axisRemap == (val & 0x3F)) return 0; |
echo_piyo | 0:bf96e953cdb8 | 2446 | else axisRemap = (val & 0x3F); |
echo_piyo | 0:bf96e953cdb8 | 2447 | return ctrl->wr(0, BNO055P0_AXIS_MAP_CONFIG, axisRemap); |
echo_piyo | 0:bf96e953cdb8 | 2448 | } |
echo_piyo | 0:bf96e953cdb8 | 2449 | |
echo_piyo | 0:bf96e953cdb8 | 2450 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2451 | * センサー出力軸符号情報の取得 |
echo_piyo | 0:bf96e953cdb8 | 2452 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2453 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2454 | * AXIS_MAP_SIGNの設定情報:BNO055データシート [3.4 Axis remap] を参照 |
echo_piyo | 0:bf96e953cdb8 | 2455 | */ |
echo_piyo | 0:bf96e953cdb8 | 2456 | char BOARDC_BNO055::getAxisMapSign(){ |
echo_piyo | 0:bf96e953cdb8 | 2457 | char ret = ctrl->rr(0, BNO055P0_AXIS_MAP_SIGN); |
echo_piyo | 0:bf96e953cdb8 | 2458 | if(axisSign != ret) axisSign = ret; |
echo_piyo | 0:bf96e953cdb8 | 2459 | return axisSign; |
echo_piyo | 0:bf96e953cdb8 | 2460 | } |
echo_piyo | 0:bf96e953cdb8 | 2461 | |
echo_piyo | 0:bf96e953cdb8 | 2462 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2463 | * センサー出力軸符号の設定 |
echo_piyo | 0:bf96e953cdb8 | 2464 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2465 | * 引数val: |
echo_piyo | 0:bf96e953cdb8 | 2466 | * X,Y,Zの出力符号の情報 |
echo_piyo | 0:bf96e953cdb8 | 2467 | * (BNO055データシート [3.4 Axis remap] を参照 |
echo_piyo | 0:bf96e953cdb8 | 2468 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2469 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2470 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2471 | * 0 変更なし |
echo_piyo | 0:bf96e953cdb8 | 2472 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2473 | */ |
echo_piyo | 0:bf96e953cdb8 | 2474 | char BOARDC_BNO055::setAxisMapSign(char val){ |
echo_piyo | 0:bf96e953cdb8 | 2475 | if(axisSign == (val & 0x07)) return 0; |
echo_piyo | 0:bf96e953cdb8 | 2476 | else axisSign = (val & 0x07); |
echo_piyo | 0:bf96e953cdb8 | 2477 | return ctrl->wr(0, BNO055P0_AXIS_MAP_SIGN, axisSign); |
echo_piyo | 0:bf96e953cdb8 | 2478 | } |
echo_piyo | 0:bf96e953cdb8 | 2479 | |
echo_piyo | 0:bf96e953cdb8 | 2480 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2481 | * センサー出力軸の符号と交換を直感的に設定する[1pinが表側左上] |
echo_piyo | 0:bf96e953cdb8 | 2482 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2483 | * (BNO055データシート [3.4 Axis remap] を参照 |
echo_piyo | 0:bf96e953cdb8 | 2484 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2485 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2486 | * -1 AXIS_MAP_CONFIG設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2487 | * -2 AXIS_MAP_SIGN設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2488 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2489 | */ |
echo_piyo | 0:bf96e953cdb8 | 2490 | char BOARDC_BNO055::setAxisRemap_topview_topleft(){ |
echo_piyo | 0:bf96e953cdb8 | 2491 | axisRemap = 0x21; |
echo_piyo | 0:bf96e953cdb8 | 2492 | axisSign = 0x04; |
echo_piyo | 0:bf96e953cdb8 | 2493 | char ret = 0; |
echo_piyo | 0:bf96e953cdb8 | 2494 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_CONFIG, axisRemap); |
echo_piyo | 0:bf96e953cdb8 | 2495 | if(ret == -1) return -1; |
echo_piyo | 0:bf96e953cdb8 | 2496 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_SIGN, axisSign); |
echo_piyo | 0:bf96e953cdb8 | 2497 | if(ret == -1) return -2; |
echo_piyo | 0:bf96e953cdb8 | 2498 | return 1; |
echo_piyo | 0:bf96e953cdb8 | 2499 | } |
echo_piyo | 0:bf96e953cdb8 | 2500 | |
echo_piyo | 0:bf96e953cdb8 | 2501 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2502 | * センサー出力軸の符号と交換を直感的に設定する[1pinが表側右上] |
echo_piyo | 0:bf96e953cdb8 | 2503 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2504 | * (BNO055データシート [3.4 Axis remap] を参照 |
echo_piyo | 0:bf96e953cdb8 | 2505 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2506 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2507 | * -1 AXIS_MAP_CONFIG設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2508 | * -2 AXIS_MAP_SIGN設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2509 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2510 | */ |
echo_piyo | 0:bf96e953cdb8 | 2511 | char BOARDC_BNO055::setAxisRemap_topview_topright(){ |
echo_piyo | 0:bf96e953cdb8 | 2512 | axisRemap = 0x24; |
echo_piyo | 0:bf96e953cdb8 | 2513 | axisSign = 0x00; |
echo_piyo | 0:bf96e953cdb8 | 2514 | char ret = 0; |
echo_piyo | 0:bf96e953cdb8 | 2515 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_CONFIG, axisRemap); |
echo_piyo | 0:bf96e953cdb8 | 2516 | if(ret == -1) return -1; |
echo_piyo | 0:bf96e953cdb8 | 2517 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_SIGN, axisSign); |
echo_piyo | 0:bf96e953cdb8 | 2518 | if(ret == -1) return -2; |
echo_piyo | 0:bf96e953cdb8 | 2519 | return 1; |
echo_piyo | 0:bf96e953cdb8 | 2520 | } |
echo_piyo | 0:bf96e953cdb8 | 2521 | |
echo_piyo | 0:bf96e953cdb8 | 2522 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2523 | * センサー出力軸の符号と交換を直感的に設定する[1pinが表側左下] |
echo_piyo | 0:bf96e953cdb8 | 2524 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2525 | * (BNO055データシート [3.4 Axis remap] を参照 |
echo_piyo | 0:bf96e953cdb8 | 2526 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2527 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2528 | * -1 AXIS_MAP_CONFIG設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2529 | * -2 AXIS_MAP_SIGN設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2530 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2531 | */ |
echo_piyo | 0:bf96e953cdb8 | 2532 | char BOARDC_BNO055::setAxisRemap_topview_bottomleft(){ |
echo_piyo | 0:bf96e953cdb8 | 2533 | axisRemap = 0x24; |
echo_piyo | 0:bf96e953cdb8 | 2534 | axisSign = 0x06; |
echo_piyo | 0:bf96e953cdb8 | 2535 | char ret = 0; |
echo_piyo | 0:bf96e953cdb8 | 2536 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_CONFIG, axisRemap); |
echo_piyo | 0:bf96e953cdb8 | 2537 | if(ret == -1) return -1; |
echo_piyo | 0:bf96e953cdb8 | 2538 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_SIGN, axisSign); |
echo_piyo | 0:bf96e953cdb8 | 2539 | if(ret == -1) return -2; |
echo_piyo | 0:bf96e953cdb8 | 2540 | return 1; |
echo_piyo | 0:bf96e953cdb8 | 2541 | } |
echo_piyo | 0:bf96e953cdb8 | 2542 | |
echo_piyo | 0:bf96e953cdb8 | 2543 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2544 | * センサー出力軸の符号と交換を直感的に設定する[1pinが表側右下] |
echo_piyo | 0:bf96e953cdb8 | 2545 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2546 | * (BNO055データシート [3.4 Axis remap] を参照 |
echo_piyo | 0:bf96e953cdb8 | 2547 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2548 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2549 | * -1 AXIS_MAP_CONFIG設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2550 | * -2 AXIS_MAP_SIGN設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2551 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2552 | */ |
echo_piyo | 0:bf96e953cdb8 | 2553 | char BOARDC_BNO055::setAxisRemap_topview_bottomright(){ |
echo_piyo | 0:bf96e953cdb8 | 2554 | axisRemap = 0x21; |
echo_piyo | 0:bf96e953cdb8 | 2555 | axisSign = 0x02; |
echo_piyo | 0:bf96e953cdb8 | 2556 | char ret = 0; |
echo_piyo | 0:bf96e953cdb8 | 2557 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_CONFIG, axisRemap); |
echo_piyo | 0:bf96e953cdb8 | 2558 | if(ret == -1) return -1; |
echo_piyo | 0:bf96e953cdb8 | 2559 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_SIGN, axisSign); |
echo_piyo | 0:bf96e953cdb8 | 2560 | if(ret == -1) return -2; |
echo_piyo | 0:bf96e953cdb8 | 2561 | return 1; |
echo_piyo | 0:bf96e953cdb8 | 2562 | } |
echo_piyo | 0:bf96e953cdb8 | 2563 | |
echo_piyo | 0:bf96e953cdb8 | 2564 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2565 | * センサー出力軸の符号と交換を直感的に設定する[1pinが表側から見たとき裏側左上] |
echo_piyo | 0:bf96e953cdb8 | 2566 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2567 | * (BNO055データシート [3.4 Axis remap] を参照 |
echo_piyo | 0:bf96e953cdb8 | 2568 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2569 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2570 | * -1 AXIS_MAP_CONFIG設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2571 | * -2 AXIS_MAP_SIGN設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2572 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2573 | */ |
echo_piyo | 0:bf96e953cdb8 | 2574 | char BOARDC_BNO055::setAxisRemap_bottomview_topleft(){ |
echo_piyo | 0:bf96e953cdb8 | 2575 | axisRemap = 0x24; |
echo_piyo | 0:bf96e953cdb8 | 2576 | axisSign = 0x03; |
echo_piyo | 0:bf96e953cdb8 | 2577 | char ret = 0; |
echo_piyo | 0:bf96e953cdb8 | 2578 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_CONFIG, axisRemap); |
echo_piyo | 0:bf96e953cdb8 | 2579 | if(ret == -1) return -1; |
echo_piyo | 0:bf96e953cdb8 | 2580 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_SIGN, axisSign); |
echo_piyo | 0:bf96e953cdb8 | 2581 | if(ret == -1) return -2; |
echo_piyo | 0:bf96e953cdb8 | 2582 | return 1; |
echo_piyo | 0:bf96e953cdb8 | 2583 | } |
echo_piyo | 0:bf96e953cdb8 | 2584 | |
echo_piyo | 0:bf96e953cdb8 | 2585 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2586 | * センサー出力軸の符号と交換を直感的に設定する[1pinが表側から見たとき裏側右上] |
echo_piyo | 0:bf96e953cdb8 | 2587 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2588 | * (BNO055データシート [3.4 Axis remap] を参照 |
echo_piyo | 0:bf96e953cdb8 | 2589 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2590 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2591 | * -1 AXIS_MAP_CONFIG設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2592 | * -2 AXIS_MAP_SIGN設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2593 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2594 | */ |
echo_piyo | 0:bf96e953cdb8 | 2595 | char BOARDC_BNO055::setAxisRemap_bottomview_topright(){ |
echo_piyo | 0:bf96e953cdb8 | 2596 | axisRemap = 0x21; |
echo_piyo | 0:bf96e953cdb8 | 2597 | axisSign = 0x01; |
echo_piyo | 0:bf96e953cdb8 | 2598 | char ret = 0; |
echo_piyo | 0:bf96e953cdb8 | 2599 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_CONFIG, axisRemap); |
echo_piyo | 0:bf96e953cdb8 | 2600 | if(ret == -1) return -1; |
echo_piyo | 0:bf96e953cdb8 | 2601 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_SIGN, axisSign); |
echo_piyo | 0:bf96e953cdb8 | 2602 | if(ret == -1) return -2; |
echo_piyo | 0:bf96e953cdb8 | 2603 | return 1; |
echo_piyo | 0:bf96e953cdb8 | 2604 | } |
echo_piyo | 0:bf96e953cdb8 | 2605 | |
echo_piyo | 0:bf96e953cdb8 | 2606 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2607 | * センサー出力軸の符号と交換を直感的に設定する[1pinが表側から見たとき裏側左下] |
echo_piyo | 0:bf96e953cdb8 | 2608 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2609 | * (BNO055データシート [3.4 Axis remap] を参照 |
echo_piyo | 0:bf96e953cdb8 | 2610 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2611 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2612 | * -1 AXIS_MAP_CONFIG設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2613 | * -2 AXIS_MAP_SIGN設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2614 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2615 | */ |
echo_piyo | 0:bf96e953cdb8 | 2616 | char BOARDC_BNO055::setAxisRemap_bottomview_bottomleft(){ |
echo_piyo | 0:bf96e953cdb8 | 2617 | axisRemap = 0x21; |
echo_piyo | 0:bf96e953cdb8 | 2618 | axisSign = 0x07; |
echo_piyo | 0:bf96e953cdb8 | 2619 | char ret = 0; |
echo_piyo | 0:bf96e953cdb8 | 2620 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_CONFIG, axisRemap); |
echo_piyo | 0:bf96e953cdb8 | 2621 | if(ret == -1) return -1; |
echo_piyo | 0:bf96e953cdb8 | 2622 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_SIGN, axisSign); |
echo_piyo | 0:bf96e953cdb8 | 2623 | if(ret == -1) return -2; |
echo_piyo | 0:bf96e953cdb8 | 2624 | return 1; |
echo_piyo | 0:bf96e953cdb8 | 2625 | } |
echo_piyo | 0:bf96e953cdb8 | 2626 | |
echo_piyo | 0:bf96e953cdb8 | 2627 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2628 | * センサー出力軸の符号と交換を直感的に設定する[1pinが表側から見たとき裏側右下] |
echo_piyo | 0:bf96e953cdb8 | 2629 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2630 | * (BNO055データシート [3.4 Axis remap] を参照 |
echo_piyo | 0:bf96e953cdb8 | 2631 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2632 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2633 | * -1 AXIS_MAP_CONFIG設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2634 | * -2 AXIS_MAP_SIGN設定の失敗 |
echo_piyo | 0:bf96e953cdb8 | 2635 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2636 | */ |
echo_piyo | 0:bf96e953cdb8 | 2637 | char BOARDC_BNO055::setAxisRemap_bottomview_bottomright(){ |
echo_piyo | 0:bf96e953cdb8 | 2638 | axisRemap = 0x24; |
echo_piyo | 0:bf96e953cdb8 | 2639 | axisSign = 0x05; |
echo_piyo | 0:bf96e953cdb8 | 2640 | char ret = 0; |
echo_piyo | 0:bf96e953cdb8 | 2641 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_CONFIG, axisRemap); |
echo_piyo | 0:bf96e953cdb8 | 2642 | if(ret == -1) return -1; |
echo_piyo | 0:bf96e953cdb8 | 2643 | ret = ctrl->wr(0, BNO055P0_AXIS_MAP_SIGN, axisSign); |
echo_piyo | 0:bf96e953cdb8 | 2644 | if(ret == -1) return -2; |
echo_piyo | 0:bf96e953cdb8 | 2645 | return 1; |
echo_piyo | 0:bf96e953cdb8 | 2646 | } |
echo_piyo | 0:bf96e953cdb8 | 2647 | |
echo_piyo | 0:bf96e953cdb8 | 2648 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2649 | * センサー出力軸の符号と交換の情報を直感的な形で取得する |
echo_piyo | 0:bf96e953cdb8 | 2650 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2651 | * (BNO055データシート [3.4 Axis remap] を参照 |
echo_piyo | 0:bf96e953cdb8 | 2652 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2653 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2654 | * 0 [P0]表側から見たとき、BNO055の1pinが表側左上にある状態 |
echo_piyo | 0:bf96e953cdb8 | 2655 | * 1 [P1]表側から見たとき、BNO055の1pinが表側右上にある状態 |
echo_piyo | 0:bf96e953cdb8 | 2656 | * 2 [P2]表側から見たとき、BNO055の1pinが表側左下にある状態 |
echo_piyo | 0:bf96e953cdb8 | 2657 | * 3 [P3]表側から見たとき、BNO055の1pinが表側右下にある状態 |
echo_piyo | 0:bf96e953cdb8 | 2658 | * 4 [P4]表側から見たとき、BNO055の1pinが裏側左上にある状態 |
echo_piyo | 0:bf96e953cdb8 | 2659 | * 5 [P5]表側から見たとき、BNO055の1pinが裏側右上にある状態 |
echo_piyo | 0:bf96e953cdb8 | 2660 | * 6 [P6]表側から見たとき、BNO055の1pinが裏側左下にある状態 |
echo_piyo | 0:bf96e953cdb8 | 2661 | * 7 [P7]表側から見たとき、BNO055の1pinが裏側右下にある状態 |
echo_piyo | 0:bf96e953cdb8 | 2662 | * -1 それ以外の設定 |
echo_piyo | 0:bf96e953cdb8 | 2663 | */ |
echo_piyo | 0:bf96e953cdb8 | 2664 | char BOARDC_BNO055::getAxisRemap_type(){ |
echo_piyo | 0:bf96e953cdb8 | 2665 | getAxisMapConfig(); //axisRemapに最新の値を格納 |
echo_piyo | 0:bf96e953cdb8 | 2666 | getAxisMapSign(); //axisSignに最新の値を格納 |
echo_piyo | 0:bf96e953cdb8 | 2667 | |
echo_piyo | 0:bf96e953cdb8 | 2668 | if(axisRemap == 0x21){ |
echo_piyo | 0:bf96e953cdb8 | 2669 | switch(axisSign){ |
echo_piyo | 0:bf96e953cdb8 | 2670 | case 0x04: |
echo_piyo | 0:bf96e953cdb8 | 2671 | return 0; |
echo_piyo | 0:bf96e953cdb8 | 2672 | case 0x02: |
echo_piyo | 0:bf96e953cdb8 | 2673 | return 3; |
echo_piyo | 0:bf96e953cdb8 | 2674 | case 0x01: |
echo_piyo | 0:bf96e953cdb8 | 2675 | return 5; |
echo_piyo | 0:bf96e953cdb8 | 2676 | case 0x07: |
echo_piyo | 0:bf96e953cdb8 | 2677 | return 6; |
echo_piyo | 0:bf96e953cdb8 | 2678 | } |
echo_piyo | 0:bf96e953cdb8 | 2679 | }else if(axisRemap == 0x24){ |
echo_piyo | 0:bf96e953cdb8 | 2680 | switch(axisSign){ |
echo_piyo | 0:bf96e953cdb8 | 2681 | case 0x00: |
echo_piyo | 0:bf96e953cdb8 | 2682 | return 1; |
echo_piyo | 0:bf96e953cdb8 | 2683 | case 0x06: |
echo_piyo | 0:bf96e953cdb8 | 2684 | return 2; |
echo_piyo | 0:bf96e953cdb8 | 2685 | case 0x03: |
echo_piyo | 0:bf96e953cdb8 | 2686 | return 4; |
echo_piyo | 0:bf96e953cdb8 | 2687 | case 0x05: |
echo_piyo | 0:bf96e953cdb8 | 2688 | return 7; |
echo_piyo | 0:bf96e953cdb8 | 2689 | } |
echo_piyo | 0:bf96e953cdb8 | 2690 | } |
echo_piyo | 0:bf96e953cdb8 | 2691 | |
echo_piyo | 0:bf96e953cdb8 | 2692 | return -1; |
echo_piyo | 0:bf96e953cdb8 | 2693 | } |
echo_piyo | 0:bf96e953cdb8 | 2694 | |
echo_piyo | 0:bf96e953cdb8 | 2695 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2696 | * 加速度センサーの補正値を取得する |
echo_piyo | 0:bf96e953cdb8 | 2697 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2698 | * &offsetX: アドレス参照引数:関数実行後、この変数にX軸補正値が格納される |
echo_piyo | 0:bf96e953cdb8 | 2699 | * &offsetY: アドレス参照引数:関数実行後、この変数にY軸補正値が格納される |
echo_piyo | 0:bf96e953cdb8 | 2700 | * &offsetZ: アドレス参照引数:関数実行後、この変数にZ軸補正値が格納される |
echo_piyo | 0:bf96e953cdb8 | 2701 | */ |
echo_piyo | 0:bf96e953cdb8 | 2702 | void BOARDC_BNO055::getAccOffsetAll(float &offsetX, float &offsetY, float &offsetZ){ |
echo_piyo | 0:bf96e953cdb8 | 2703 | //連続6byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 2704 | char rsv[6]; |
echo_piyo | 0:bf96e953cdb8 | 2705 | ctrl->rrc(0, BNO055P0_ACC_OFFSET_X_LSB, rsv, 6); |
echo_piyo | 0:bf96e953cdb8 | 2706 | |
echo_piyo | 0:bf96e953cdb8 | 2707 | short offX = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 2708 | short offY = (rsv[3] << 8) | rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 2709 | short offZ = (rsv[5] << 8) | rsv[4]; |
echo_piyo | 0:bf96e953cdb8 | 2710 | offsetX = (1.0f * offX) * scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 2711 | offsetY = (1.0f * offY) * scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 2712 | offsetZ = (1.0f * offZ) * scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 2713 | } |
echo_piyo | 0:bf96e953cdb8 | 2714 | |
echo_piyo | 0:bf96e953cdb8 | 2715 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2716 | * 加速度センサーの補正値(X軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 2717 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2718 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2719 | * X軸補正値(スケール乗算済み) |
echo_piyo | 0:bf96e953cdb8 | 2720 | */ |
echo_piyo | 0:bf96e953cdb8 | 2721 | float BOARDC_BNO055::getAccOffsetX(){ |
echo_piyo | 0:bf96e953cdb8 | 2722 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 2723 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 2724 | ctrl->rrc(0, BNO055P0_ACC_OFFSET_X_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 2725 | |
echo_piyo | 0:bf96e953cdb8 | 2726 | short offX = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 2727 | return (1.0f * offX) * scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 2728 | } |
echo_piyo | 0:bf96e953cdb8 | 2729 | |
echo_piyo | 0:bf96e953cdb8 | 2730 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2731 | * 加速度センサーの補正値(Y軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 2732 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2733 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2734 | * Y軸補正値(スケール乗算済み) |
echo_piyo | 0:bf96e953cdb8 | 2735 | */ |
echo_piyo | 0:bf96e953cdb8 | 2736 | float BOARDC_BNO055::getAccOffsetY(){ |
echo_piyo | 0:bf96e953cdb8 | 2737 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 2738 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 2739 | ctrl->rrc(0, BNO055P0_ACC_OFFSET_Y_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 2740 | |
echo_piyo | 0:bf96e953cdb8 | 2741 | short offX = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 2742 | return (1.0f * offX) * scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 2743 | } |
echo_piyo | 0:bf96e953cdb8 | 2744 | |
echo_piyo | 0:bf96e953cdb8 | 2745 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2746 | * 加速度センサーの補正値(Z軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 2747 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2748 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2749 | * Z軸補正値(スケール乗算済み) |
echo_piyo | 0:bf96e953cdb8 | 2750 | */ |
echo_piyo | 0:bf96e953cdb8 | 2751 | float BOARDC_BNO055::getAccOffsetZ(){ |
echo_piyo | 0:bf96e953cdb8 | 2752 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 2753 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 2754 | ctrl->rrc(0, BNO055P0_ACC_OFFSET_Z_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 2755 | |
echo_piyo | 0:bf96e953cdb8 | 2756 | short offX = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 2757 | return (1.0f * offX) * scaleACC; |
echo_piyo | 0:bf96e953cdb8 | 2758 | } |
echo_piyo | 0:bf96e953cdb8 | 2759 | |
echo_piyo | 0:bf96e953cdb8 | 2760 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2761 | * 加速度センサーの補正値を設定する |
echo_piyo | 0:bf96e953cdb8 | 2762 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2763 | * offsetX: スケール乗算済みのX軸の補正値 |
echo_piyo | 0:bf96e953cdb8 | 2764 | * offsetY: スケール乗算済みのY軸の補正値 |
echo_piyo | 0:bf96e953cdb8 | 2765 | * offsetZ: スケール乗算済みのZ軸の補正値 |
echo_piyo | 0:bf96e953cdb8 | 2766 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2767 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2768 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2769 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2770 | */ |
echo_piyo | 0:bf96e953cdb8 | 2771 | char BOARDC_BNO055::setAccOffsetAll(float offsetX, float offsetY, float offsetZ){ |
echo_piyo | 0:bf96e953cdb8 | 2772 | short offX = (short)((offsetX / scaleACC) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 2773 | short offY = (short)((offsetY / scaleACC) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 2774 | short offZ = (short)((offsetZ / scaleACC) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 2775 | char msg[6]; |
echo_piyo | 0:bf96e953cdb8 | 2776 | msg[0] = offX & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 2777 | msg[1] = offX >> 8; |
echo_piyo | 0:bf96e953cdb8 | 2778 | msg[2] = offY & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 2779 | msg[3] = offY >> 8; |
echo_piyo | 0:bf96e953cdb8 | 2780 | msg[4] = offZ & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 2781 | msg[5] = offZ >> 8; |
echo_piyo | 0:bf96e953cdb8 | 2782 | |
echo_piyo | 0:bf96e953cdb8 | 2783 | //連続6byte書き込み |
echo_piyo | 0:bf96e953cdb8 | 2784 | return ctrl->wrc(0, BNO055P0_ACC_OFFSET_X_LSB, msg, 6); |
echo_piyo | 0:bf96e953cdb8 | 2785 | } |
echo_piyo | 0:bf96e953cdb8 | 2786 | |
echo_piyo | 0:bf96e953cdb8 | 2787 | char BOARDC_BNO055::setAccOffsetX(float offset){ |
echo_piyo | 0:bf96e953cdb8 | 2788 | short offX = (short)((offset / scaleACC) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 2789 | char msg[2]; |
echo_piyo | 0:bf96e953cdb8 | 2790 | msg[0] = offX & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 2791 | msg[1] = offX >> 8; |
echo_piyo | 0:bf96e953cdb8 | 2792 | |
echo_piyo | 0:bf96e953cdb8 | 2793 | //連続2byte書き込み |
echo_piyo | 0:bf96e953cdb8 | 2794 | return ctrl->wrc(0, BNO055P0_ACC_OFFSET_X_LSB, msg, 2); |
echo_piyo | 0:bf96e953cdb8 | 2795 | } |
echo_piyo | 0:bf96e953cdb8 | 2796 | |
echo_piyo | 0:bf96e953cdb8 | 2797 | char BOARDC_BNO055::setAccOffsetY(float offset){ |
echo_piyo | 0:bf96e953cdb8 | 2798 | short offY = (short)((offset / scaleACC) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 2799 | char msg[2]; |
echo_piyo | 0:bf96e953cdb8 | 2800 | msg[0] = offY & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 2801 | msg[1] = offY >> 8; |
echo_piyo | 0:bf96e953cdb8 | 2802 | |
echo_piyo | 0:bf96e953cdb8 | 2803 | //連続2byte書き込み |
echo_piyo | 0:bf96e953cdb8 | 2804 | return ctrl->wrc(0, BNO055P0_ACC_OFFSET_Y_LSB, msg, 2); |
echo_piyo | 0:bf96e953cdb8 | 2805 | } |
echo_piyo | 0:bf96e953cdb8 | 2806 | |
echo_piyo | 0:bf96e953cdb8 | 2807 | char BOARDC_BNO055::setAccOffsetZ(float offset){ |
echo_piyo | 0:bf96e953cdb8 | 2808 | short offZ = (short)((offset / scaleACC) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 2809 | char msg[2]; |
echo_piyo | 0:bf96e953cdb8 | 2810 | msg[0] = offZ & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 2811 | msg[1] = offZ >> 8; |
echo_piyo | 0:bf96e953cdb8 | 2812 | |
echo_piyo | 0:bf96e953cdb8 | 2813 | //連続2byte書き込み |
echo_piyo | 0:bf96e953cdb8 | 2814 | return ctrl->wrc(0, BNO055P0_ACC_OFFSET_Z_LSB, msg, 2); |
echo_piyo | 0:bf96e953cdb8 | 2815 | } |
echo_piyo | 0:bf96e953cdb8 | 2816 | |
echo_piyo | 0:bf96e953cdb8 | 2817 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2818 | * 地磁気センサーの補正値を取得する |
echo_piyo | 0:bf96e953cdb8 | 2819 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2820 | * &offsetX: アドレス参照引数:関数実行後、この変数にX軸補正値が格納される |
echo_piyo | 0:bf96e953cdb8 | 2821 | * &offsetY: アドレス参照引数:関数実行後、この変数にY軸補正値が格納される |
echo_piyo | 0:bf96e953cdb8 | 2822 | * &offsetZ: アドレス参照引数:関数実行後、この変数にZ軸補正値が格納される |
echo_piyo | 0:bf96e953cdb8 | 2823 | */ |
echo_piyo | 0:bf96e953cdb8 | 2824 | void BOARDC_BNO055::getMagOffsetAll(float &offsetX, float &offsetY, float &offsetZ){ |
echo_piyo | 0:bf96e953cdb8 | 2825 | //連続6byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 2826 | char rsv[6]; |
echo_piyo | 0:bf96e953cdb8 | 2827 | ctrl->rrc(0, BNO055P0_MAG_OFFSET_X_LSB, rsv, 6); |
echo_piyo | 0:bf96e953cdb8 | 2828 | |
echo_piyo | 0:bf96e953cdb8 | 2829 | short offX = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 2830 | short offY = (rsv[3] << 8) | rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 2831 | short offZ = (rsv[5] << 8) | rsv[4]; |
echo_piyo | 0:bf96e953cdb8 | 2832 | offsetX = (1.0f * offX) * scaleMAG; |
echo_piyo | 0:bf96e953cdb8 | 2833 | offsetY = (1.0f * offY) * scaleMAG; |
echo_piyo | 0:bf96e953cdb8 | 2834 | offsetZ = (1.0f * offZ) * scaleMAG; |
echo_piyo | 0:bf96e953cdb8 | 2835 | } |
echo_piyo | 0:bf96e953cdb8 | 2836 | |
echo_piyo | 0:bf96e953cdb8 | 2837 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2838 | * 地磁気センサーの補正値(X軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 2839 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2840 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2841 | * X軸補正値(スケール乗算済み) |
echo_piyo | 0:bf96e953cdb8 | 2842 | */ |
echo_piyo | 0:bf96e953cdb8 | 2843 | float BOARDC_BNO055::getMagOffsetX(){ |
echo_piyo | 0:bf96e953cdb8 | 2844 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 2845 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 2846 | ctrl->rrc(0, BNO055P0_MAG_OFFSET_X_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 2847 | |
echo_piyo | 0:bf96e953cdb8 | 2848 | short offX = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 2849 | return (1.0f * offX) * scaleMAG; |
echo_piyo | 0:bf96e953cdb8 | 2850 | } |
echo_piyo | 0:bf96e953cdb8 | 2851 | |
echo_piyo | 0:bf96e953cdb8 | 2852 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2853 | * 地磁気センサーの補正値(Y軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 2854 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2855 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2856 | * Y軸補正値(スケール乗算済み) |
echo_piyo | 0:bf96e953cdb8 | 2857 | */ |
echo_piyo | 0:bf96e953cdb8 | 2858 | float BOARDC_BNO055::getMagOffsetY(){ |
echo_piyo | 0:bf96e953cdb8 | 2859 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 2860 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 2861 | ctrl->rrc(0, BNO055P0_MAG_OFFSET_Y_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 2862 | |
echo_piyo | 0:bf96e953cdb8 | 2863 | short offY = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 2864 | return (1.0f * offY) * scaleMAG; |
echo_piyo | 0:bf96e953cdb8 | 2865 | } |
echo_piyo | 0:bf96e953cdb8 | 2866 | |
echo_piyo | 0:bf96e953cdb8 | 2867 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2868 | * 地磁気センサーの補正値(Z軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 2869 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2870 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2871 | * Z軸補正値(スケール乗算済み) |
echo_piyo | 0:bf96e953cdb8 | 2872 | */ |
echo_piyo | 0:bf96e953cdb8 | 2873 | float BOARDC_BNO055::getMagOffsetZ(){ |
echo_piyo | 0:bf96e953cdb8 | 2874 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 2875 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 2876 | ctrl->rrc(0, BNO055P0_MAG_OFFSET_Z_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 2877 | |
echo_piyo | 0:bf96e953cdb8 | 2878 | short offZ = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 2879 | return (1.0f * offZ) * scaleMAG; |
echo_piyo | 0:bf96e953cdb8 | 2880 | } |
echo_piyo | 0:bf96e953cdb8 | 2881 | |
echo_piyo | 0:bf96e953cdb8 | 2882 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2883 | * 地磁気センサーの補正値を設定する |
echo_piyo | 0:bf96e953cdb8 | 2884 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2885 | * offsetX: スケール乗算済みのX軸の補正値 |
echo_piyo | 0:bf96e953cdb8 | 2886 | * offsetY: スケール乗算済みのY軸の補正値 |
echo_piyo | 0:bf96e953cdb8 | 2887 | * offsetZ: スケール乗算済みのZ軸の補正値 |
echo_piyo | 0:bf96e953cdb8 | 2888 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2889 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2890 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2891 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2892 | */ |
echo_piyo | 0:bf96e953cdb8 | 2893 | char BOARDC_BNO055::setMagOffsetAll(float offsetX, float offsetY, float offsetZ){ |
echo_piyo | 0:bf96e953cdb8 | 2894 | short offX = (short)((offsetX / scaleMAG) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 2895 | short offY = (short)((offsetY / scaleMAG) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 2896 | short offZ = (short)((offsetZ / scaleMAG) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 2897 | char msg[6]; |
echo_piyo | 0:bf96e953cdb8 | 2898 | msg[0] = offX & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 2899 | msg[1] = offX >> 8; |
echo_piyo | 0:bf96e953cdb8 | 2900 | msg[2] = offY & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 2901 | msg[3] = offY >> 8; |
echo_piyo | 0:bf96e953cdb8 | 2902 | msg[4] = offZ & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 2903 | msg[5] = offZ >> 8; |
echo_piyo | 0:bf96e953cdb8 | 2904 | |
echo_piyo | 0:bf96e953cdb8 | 2905 | //連続6byte書き込み |
echo_piyo | 0:bf96e953cdb8 | 2906 | return ctrl->wrc(0, BNO055P0_MAG_OFFSET_X_LSB, msg, 6); |
echo_piyo | 0:bf96e953cdb8 | 2907 | } |
echo_piyo | 0:bf96e953cdb8 | 2908 | |
echo_piyo | 0:bf96e953cdb8 | 2909 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2910 | * 地磁気センサーの補正値(X軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 2911 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2912 | * offset: スケール乗算済みの補正値 |
echo_piyo | 0:bf96e953cdb8 | 2913 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2914 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2915 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2916 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2917 | */ |
echo_piyo | 0:bf96e953cdb8 | 2918 | char BOARDC_BNO055::setMagOffsetX(float offset){ |
echo_piyo | 0:bf96e953cdb8 | 2919 | short offX = (short)((offset / scaleMAG) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 2920 | char msg[2]; |
echo_piyo | 0:bf96e953cdb8 | 2921 | msg[0] = offX & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 2922 | msg[1] = offX >> 8; |
echo_piyo | 0:bf96e953cdb8 | 2923 | |
echo_piyo | 0:bf96e953cdb8 | 2924 | //連続2byte書き込み |
echo_piyo | 0:bf96e953cdb8 | 2925 | return ctrl->wrc(0, BNO055P0_MAG_OFFSET_X_LSB, msg, 2); |
echo_piyo | 0:bf96e953cdb8 | 2926 | } |
echo_piyo | 0:bf96e953cdb8 | 2927 | |
echo_piyo | 0:bf96e953cdb8 | 2928 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2929 | * 地磁気センサーの補正値(Y軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 2930 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2931 | * offset: スケール乗算済みの補正値 |
echo_piyo | 0:bf96e953cdb8 | 2932 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2933 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2934 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2935 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2936 | */ |
echo_piyo | 0:bf96e953cdb8 | 2937 | char BOARDC_BNO055::setMagOffsetY(float offset){ |
echo_piyo | 0:bf96e953cdb8 | 2938 | short offY = (short)((offset / scaleMAG) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 2939 | char msg[2]; |
echo_piyo | 0:bf96e953cdb8 | 2940 | msg[0] = offY & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 2941 | msg[1] = offY >> 8; |
echo_piyo | 0:bf96e953cdb8 | 2942 | |
echo_piyo | 0:bf96e953cdb8 | 2943 | //連続2byte書き込み |
echo_piyo | 0:bf96e953cdb8 | 2944 | return ctrl->wrc(0, BNO055P0_MAG_OFFSET_Y_LSB, msg, 2); |
echo_piyo | 0:bf96e953cdb8 | 2945 | } |
echo_piyo | 0:bf96e953cdb8 | 2946 | |
echo_piyo | 0:bf96e953cdb8 | 2947 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2948 | * 地磁気センサーの補正値(Z軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 2949 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2950 | * offset: スケール乗算済みの補正値 |
echo_piyo | 0:bf96e953cdb8 | 2951 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2952 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2953 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 2954 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 2955 | */ |
echo_piyo | 0:bf96e953cdb8 | 2956 | char BOARDC_BNO055::setMagOffsetZ(float offset){ |
echo_piyo | 0:bf96e953cdb8 | 2957 | short offZ = (short)((offset / scaleMAG) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 2958 | char msg[2]; |
echo_piyo | 0:bf96e953cdb8 | 2959 | msg[0] = offZ & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 2960 | msg[1] = offZ >> 8; |
echo_piyo | 0:bf96e953cdb8 | 2961 | |
echo_piyo | 0:bf96e953cdb8 | 2962 | //連続2byte書き込み |
echo_piyo | 0:bf96e953cdb8 | 2963 | return ctrl->wrc(0, BNO055P0_MAG_OFFSET_Z_LSB, msg, 2); |
echo_piyo | 0:bf96e953cdb8 | 2964 | } |
echo_piyo | 0:bf96e953cdb8 | 2965 | |
echo_piyo | 0:bf96e953cdb8 | 2966 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2967 | * 角速度センサーの補正値を取得する |
echo_piyo | 0:bf96e953cdb8 | 2968 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2969 | * &offsetX: アドレス参照引数:関数実行後、この変数にX軸補正値が格納される |
echo_piyo | 0:bf96e953cdb8 | 2970 | * &offsetY: アドレス参照引数:関数実行後、この変数にY軸補正値が格納される |
echo_piyo | 0:bf96e953cdb8 | 2971 | * &offsetZ: アドレス参照引数:関数実行後、この変数にZ軸補正値が格納される |
echo_piyo | 0:bf96e953cdb8 | 2972 | */ |
echo_piyo | 0:bf96e953cdb8 | 2973 | void BOARDC_BNO055::getGyroOffsetAll(float &offsetX, float &offsetY, float &offsetZ){ |
echo_piyo | 0:bf96e953cdb8 | 2974 | //連続6byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 2975 | char rsv[6]; |
echo_piyo | 0:bf96e953cdb8 | 2976 | ctrl->rrc(0, BNO055P0_GYR_OFFSET_X_LSB, rsv, 6); |
echo_piyo | 0:bf96e953cdb8 | 2977 | |
echo_piyo | 0:bf96e953cdb8 | 2978 | short offX = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 2979 | short offY = (rsv[3] << 8) | rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 2980 | short offZ = (rsv[5] << 8) | rsv[4]; |
echo_piyo | 0:bf96e953cdb8 | 2981 | offsetX = (1.0f * offX) * scaleGYRO; |
echo_piyo | 0:bf96e953cdb8 | 2982 | offsetY = (1.0f * offY) * scaleGYRO; |
echo_piyo | 0:bf96e953cdb8 | 2983 | offsetZ = (1.0f * offZ) * scaleGYRO; |
echo_piyo | 0:bf96e953cdb8 | 2984 | } |
echo_piyo | 0:bf96e953cdb8 | 2985 | |
echo_piyo | 0:bf96e953cdb8 | 2986 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 2987 | * 角速度センサーの補正値(X軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 2988 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 2989 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 2990 | * X軸補正値(スケール乗算済み) |
echo_piyo | 0:bf96e953cdb8 | 2991 | */ |
echo_piyo | 0:bf96e953cdb8 | 2992 | float BOARDC_BNO055::getGyroOffsetX(){ |
echo_piyo | 0:bf96e953cdb8 | 2993 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 2994 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 2995 | ctrl->rrc(0, BNO055P0_GYR_OFFSET_X_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 2996 | |
echo_piyo | 0:bf96e953cdb8 | 2997 | short offX = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 2998 | return (1.0f * offX) * scaleGYRO; |
echo_piyo | 0:bf96e953cdb8 | 2999 | } |
echo_piyo | 0:bf96e953cdb8 | 3000 | |
echo_piyo | 0:bf96e953cdb8 | 3001 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3002 | * 角速度センサーの補正値(Y軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 3003 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3004 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3005 | * Y軸補正値(スケール乗算済み) |
echo_piyo | 0:bf96e953cdb8 | 3006 | */ |
echo_piyo | 0:bf96e953cdb8 | 3007 | float BOARDC_BNO055::getGyroOffsetY(){ |
echo_piyo | 0:bf96e953cdb8 | 3008 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 3009 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 3010 | ctrl->rrc(0, BNO055P0_GYR_OFFSET_Y_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 3011 | |
echo_piyo | 0:bf96e953cdb8 | 3012 | short offY = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 3013 | return (1.0f * offY) * scaleGYRO; |
echo_piyo | 0:bf96e953cdb8 | 3014 | } |
echo_piyo | 0:bf96e953cdb8 | 3015 | |
echo_piyo | 0:bf96e953cdb8 | 3016 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3017 | * 角速度センサーの補正値(Z軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 3018 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3019 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3020 | * Z軸補正値(スケール乗算済み) |
echo_piyo | 0:bf96e953cdb8 | 3021 | */ |
echo_piyo | 0:bf96e953cdb8 | 3022 | float BOARDC_BNO055::getGyroOffsetZ(){ |
echo_piyo | 0:bf96e953cdb8 | 3023 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 3024 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 3025 | ctrl->rrc(0, BNO055P0_GYR_OFFSET_Z_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 3026 | |
echo_piyo | 0:bf96e953cdb8 | 3027 | short offZ = (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 3028 | return (1.0f * offZ) * scaleGYRO; |
echo_piyo | 0:bf96e953cdb8 | 3029 | } |
echo_piyo | 0:bf96e953cdb8 | 3030 | |
echo_piyo | 0:bf96e953cdb8 | 3031 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3032 | * 角速度センサーの補正値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3033 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3034 | * offsetX: スケール乗算済みのX軸の補正値 |
echo_piyo | 0:bf96e953cdb8 | 3035 | * offsetY: スケール乗算済みのY軸の補正値 |
echo_piyo | 0:bf96e953cdb8 | 3036 | * offsetZ: スケール乗算済みのZ軸の補正値 |
echo_piyo | 0:bf96e953cdb8 | 3037 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3038 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3039 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3040 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3041 | */ |
echo_piyo | 0:bf96e953cdb8 | 3042 | char BOARDC_BNO055::setGyroOffsetAll(float offsetX, float offsetY, float offsetZ){ |
echo_piyo | 0:bf96e953cdb8 | 3043 | short offX = (short)((offsetX / scaleGYRO) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 3044 | short offY = (short)((offsetY / scaleGYRO) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 3045 | short offZ = (short)((offsetZ / scaleGYRO) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 3046 | char msg[6]; |
echo_piyo | 0:bf96e953cdb8 | 3047 | msg[0] = offX & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 3048 | msg[1] = offX >> 8; |
echo_piyo | 0:bf96e953cdb8 | 3049 | msg[2] = offY & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 3050 | msg[3] = offY >> 8; |
echo_piyo | 0:bf96e953cdb8 | 3051 | msg[4] = offZ & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 3052 | msg[5] = offZ >> 8; |
echo_piyo | 0:bf96e953cdb8 | 3053 | |
echo_piyo | 0:bf96e953cdb8 | 3054 | //連続6byte書き込み |
echo_piyo | 0:bf96e953cdb8 | 3055 | return ctrl->wrc(0, BNO055P0_GYR_OFFSET_X_LSB, msg, 6); |
echo_piyo | 0:bf96e953cdb8 | 3056 | } |
echo_piyo | 0:bf96e953cdb8 | 3057 | |
echo_piyo | 0:bf96e953cdb8 | 3058 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3059 | * 角速度センサーの補正値(X軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 3060 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3061 | * offset: スケール乗算済みの補正値 |
echo_piyo | 0:bf96e953cdb8 | 3062 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3063 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3064 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3065 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3066 | */ |
echo_piyo | 0:bf96e953cdb8 | 3067 | char BOARDC_BNO055::setGyroOffsetX(float offset){ |
echo_piyo | 0:bf96e953cdb8 | 3068 | short offX = (short)((offset / scaleGYRO) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 3069 | char msg[2]; |
echo_piyo | 0:bf96e953cdb8 | 3070 | msg[0] = offX & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 3071 | msg[1] = offX >> 8; |
echo_piyo | 0:bf96e953cdb8 | 3072 | |
echo_piyo | 0:bf96e953cdb8 | 3073 | //連続2byte書き込み |
echo_piyo | 0:bf96e953cdb8 | 3074 | return ctrl->wrc(0, BNO055P0_GYR_OFFSET_X_LSB, msg, 2); |
echo_piyo | 0:bf96e953cdb8 | 3075 | } |
echo_piyo | 0:bf96e953cdb8 | 3076 | |
echo_piyo | 0:bf96e953cdb8 | 3077 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3078 | * 角速度センサーの補正値(Y軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 3079 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3080 | * offset: スケール乗算済みの補正値 |
echo_piyo | 0:bf96e953cdb8 | 3081 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3082 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3083 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3084 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3085 | */ |
echo_piyo | 0:bf96e953cdb8 | 3086 | char BOARDC_BNO055::setGyroOffsetY(float offset){ |
echo_piyo | 0:bf96e953cdb8 | 3087 | short offY = (short)((offset / scaleGYRO) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 3088 | char msg[2]; |
echo_piyo | 0:bf96e953cdb8 | 3089 | msg[0] = offY & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 3090 | msg[1] = offY >> 8; |
echo_piyo | 0:bf96e953cdb8 | 3091 | |
echo_piyo | 0:bf96e953cdb8 | 3092 | //連続2byte書き込み |
echo_piyo | 0:bf96e953cdb8 | 3093 | return ctrl->wrc(0, BNO055P0_GYR_OFFSET_Y_LSB, msg, 2); |
echo_piyo | 0:bf96e953cdb8 | 3094 | } |
echo_piyo | 0:bf96e953cdb8 | 3095 | |
echo_piyo | 0:bf96e953cdb8 | 3096 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3097 | * 角速度センサーの補正値(Z軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 3098 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3099 | * offset: スケール乗算済みの補正値 |
echo_piyo | 0:bf96e953cdb8 | 3100 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3101 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3102 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3103 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3104 | */ |
echo_piyo | 0:bf96e953cdb8 | 3105 | char BOARDC_BNO055::setGyroOffsetZ(float offset){ |
echo_piyo | 0:bf96e953cdb8 | 3106 | short offZ = (short)((offset / scaleGYRO) + 0.5f); |
echo_piyo | 0:bf96e953cdb8 | 3107 | char msg[2]; |
echo_piyo | 0:bf96e953cdb8 | 3108 | msg[0] = offZ & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 3109 | msg[1] = offZ >> 8; |
echo_piyo | 0:bf96e953cdb8 | 3110 | |
echo_piyo | 0:bf96e953cdb8 | 3111 | //連続2byte書き込み |
echo_piyo | 0:bf96e953cdb8 | 3112 | return ctrl->wrc(0, BNO055P0_GYR_OFFSET_Z_LSB, msg, 2); |
echo_piyo | 0:bf96e953cdb8 | 3113 | } |
echo_piyo | 0:bf96e953cdb8 | 3114 | |
echo_piyo | 0:bf96e953cdb8 | 3115 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3116 | * 加速度センサーのデータ出力範囲[単位:LSB]を取得する |
echo_piyo | 0:bf96e953cdb8 | 3117 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3118 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3119 | * +-データ計測範囲[単位:LSB] |
echo_piyo | 0:bf96e953cdb8 | 3120 | */ |
echo_piyo | 0:bf96e953cdb8 | 3121 | short BOARDC_BNO055::getAccRadius(){ |
echo_piyo | 0:bf96e953cdb8 | 3122 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 3123 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 3124 | ctrl->rrc(0, BNO055P0_ACC_RADIUS_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 3125 | |
echo_piyo | 0:bf96e953cdb8 | 3126 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 3127 | } |
echo_piyo | 0:bf96e953cdb8 | 3128 | |
echo_piyo | 0:bf96e953cdb8 | 3129 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3130 | * 加速度センサーのデータ出力範囲[単位:LSB]を設定する |
echo_piyo | 0:bf96e953cdb8 | 3131 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3132 | * 引数r: データ計測範囲の最大値および最低値(-r から +r の範囲が計測範囲) |
echo_piyo | 0:bf96e953cdb8 | 3133 | * 最大値は1000[LSB] |
echo_piyo | 0:bf96e953cdb8 | 3134 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3135 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3136 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3137 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3138 | */ |
echo_piyo | 0:bf96e953cdb8 | 3139 | char BOARDC_BNO055::setAccRadius(short LSB){ |
echo_piyo | 0:bf96e953cdb8 | 3140 | if(LSB > 1000) LSB = 1000; |
echo_piyo | 0:bf96e953cdb8 | 3141 | |
echo_piyo | 0:bf96e953cdb8 | 3142 | char msg[2]; |
echo_piyo | 0:bf96e953cdb8 | 3143 | msg[0] = LSB & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 3144 | msg[1] = LSB >> 8; |
echo_piyo | 0:bf96e953cdb8 | 3145 | |
echo_piyo | 0:bf96e953cdb8 | 3146 | //連続2byte書き込み |
echo_piyo | 0:bf96e953cdb8 | 3147 | return ctrl->wrc(0, BNO055P0_ACC_RADIUS_LSB, msg, 2); |
echo_piyo | 0:bf96e953cdb8 | 3148 | } |
echo_piyo | 0:bf96e953cdb8 | 3149 | |
echo_piyo | 0:bf96e953cdb8 | 3150 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3151 | * 地磁気センサーのデータ出力範囲[単位:LSB]を取得する |
echo_piyo | 0:bf96e953cdb8 | 3152 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3153 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3154 | * +-データ計測範囲 |
echo_piyo | 0:bf96e953cdb8 | 3155 | */ |
echo_piyo | 0:bf96e953cdb8 | 3156 | short BOARDC_BNO055::getMagRadius(){ |
echo_piyo | 0:bf96e953cdb8 | 3157 | //連続2byte読み取り |
echo_piyo | 0:bf96e953cdb8 | 3158 | char rsv[2]; |
echo_piyo | 0:bf96e953cdb8 | 3159 | ctrl->rrc(0, BNO055P0_MAG_RADIUS_LSB, rsv, 2); |
echo_piyo | 0:bf96e953cdb8 | 3160 | |
echo_piyo | 0:bf96e953cdb8 | 3161 | return (rsv[1] << 8) | rsv[0]; |
echo_piyo | 0:bf96e953cdb8 | 3162 | } |
echo_piyo | 0:bf96e953cdb8 | 3163 | |
echo_piyo | 0:bf96e953cdb8 | 3164 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3165 | * 加速度センサーのデータ出力範囲[単位:LSB]を設定する |
echo_piyo | 0:bf96e953cdb8 | 3166 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3167 | * 引数r: データ計測範囲の最大値および最低値(-r から +r の範囲が計測範囲) |
echo_piyo | 0:bf96e953cdb8 | 3168 | * 最大値は960[LSB] |
echo_piyo | 0:bf96e953cdb8 | 3169 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3170 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3171 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3172 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3173 | */ |
echo_piyo | 0:bf96e953cdb8 | 3174 | char BOARDC_BNO055::setMagRadius(short LSB){ |
echo_piyo | 0:bf96e953cdb8 | 3175 | if(LSB > 960) LSB = 960; |
echo_piyo | 0:bf96e953cdb8 | 3176 | |
echo_piyo | 0:bf96e953cdb8 | 3177 | char msg[2]; |
echo_piyo | 0:bf96e953cdb8 | 3178 | msg[0] = LSB & 0xFF; |
echo_piyo | 0:bf96e953cdb8 | 3179 | msg[1] = LSB >> 8; |
echo_piyo | 0:bf96e953cdb8 | 3180 | |
echo_piyo | 0:bf96e953cdb8 | 3181 | //連続2byte書き込み |
echo_piyo | 0:bf96e953cdb8 | 3182 | return ctrl->wrc(0, BNO055P0_MAG_RADIUS_LSB, msg, 2); |
echo_piyo | 0:bf96e953cdb8 | 3183 | } |
echo_piyo | 0:bf96e953cdb8 | 3184 | |
echo_piyo | 0:bf96e953cdb8 | 3185 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3186 | * 加速度センサー設定のレジスタ値を取得する |
echo_piyo | 0:bf96e953cdb8 | 3187 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3188 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3189 | * 加速度センサー設定のレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3190 | */ |
echo_piyo | 0:bf96e953cdb8 | 3191 | char BOARDC_BNO055::getAccConfig(){ |
echo_piyo | 0:bf96e953cdb8 | 3192 | return ctrl->rr(1, BNO055P1_ACC_CONFIG); |
echo_piyo | 0:bf96e953cdb8 | 3193 | } |
echo_piyo | 0:bf96e953cdb8 | 3194 | |
echo_piyo | 0:bf96e953cdb8 | 3195 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3196 | * 加速度センサー設定のレジスタ値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3197 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3198 | * 引数regVal: 加速度センサー設定のレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3199 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3200 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3201 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3202 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3203 | */ |
echo_piyo | 0:bf96e953cdb8 | 3204 | char BOARDC_BNO055::setAccConfig(char regVal){ |
echo_piyo | 0:bf96e953cdb8 | 3205 | return ctrl->wr(1, BNO055P1_ACC_CONFIG, regVal); |
echo_piyo | 0:bf96e953cdb8 | 3206 | } |
echo_piyo | 0:bf96e953cdb8 | 3207 | |
echo_piyo | 0:bf96e953cdb8 | 3208 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3209 | * 加速度センサー設定のレジスタ値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3210 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3211 | * 引数gRange: 加速度センサーの計測範囲 |
echo_piyo | 0:bf96e953cdb8 | 3212 | * 引数bandWidth: 加速度センサー出力レート(Fusion時は自動設定) |
echo_piyo | 0:bf96e953cdb8 | 3213 | * 引数powMode: 加速度センサー電源設定(Fusion時は自動設定) |
echo_piyo | 0:bf96e953cdb8 | 3214 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3215 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3216 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3217 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3218 | */ |
echo_piyo | 0:bf96e953cdb8 | 3219 | char BOARDC_BNO055::setAccConfig(char gRange, char bandWidth, char powMode){ |
echo_piyo | 0:bf96e953cdb8 | 3220 | char regVal = (powMode << 5) | (bandWidth << 2) | gRange; |
echo_piyo | 0:bf96e953cdb8 | 3221 | return ctrl->wr(1, BNO055P1_ACC_CONFIG, regVal); |
echo_piyo | 0:bf96e953cdb8 | 3222 | } |
echo_piyo | 0:bf96e953cdb8 | 3223 | |
echo_piyo | 0:bf96e953cdb8 | 3224 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3225 | * 加速度センサーの計測範囲を設定する |
echo_piyo | 0:bf96e953cdb8 | 3226 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3227 | * 引数G: 加速度センサーの計測範囲(+-2, 4, 8, 16Gのいずれか) |
echo_piyo | 0:bf96e953cdb8 | 3228 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3229 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3230 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3231 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3232 | */ |
echo_piyo | 0:bf96e953cdb8 | 3233 | char BOARDC_BNO055::setAccRange(unsigned char G){ |
echo_piyo | 0:bf96e953cdb8 | 3234 | char val = 0; |
echo_piyo | 0:bf96e953cdb8 | 3235 | switch(G){ |
echo_piyo | 0:bf96e953cdb8 | 3236 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 3237 | val = 0x00; |
echo_piyo | 0:bf96e953cdb8 | 3238 | break; |
echo_piyo | 0:bf96e953cdb8 | 3239 | case 4: |
echo_piyo | 0:bf96e953cdb8 | 3240 | val = 0x01; |
echo_piyo | 0:bf96e953cdb8 | 3241 | break; |
echo_piyo | 0:bf96e953cdb8 | 3242 | case 8: |
echo_piyo | 0:bf96e953cdb8 | 3243 | val = 0x02; |
echo_piyo | 0:bf96e953cdb8 | 3244 | break; |
echo_piyo | 0:bf96e953cdb8 | 3245 | case 16: |
echo_piyo | 0:bf96e953cdb8 | 3246 | val = 0x03; |
echo_piyo | 0:bf96e953cdb8 | 3247 | break; |
echo_piyo | 0:bf96e953cdb8 | 3248 | default: |
echo_piyo | 0:bf96e953cdb8 | 3249 | val = 0x02; |
echo_piyo | 0:bf96e953cdb8 | 3250 | } |
echo_piyo | 0:bf96e953cdb8 | 3251 | |
echo_piyo | 0:bf96e953cdb8 | 3252 | char regVal = ctrl->rr(1, BNO055P1_ACC_CONFIG); |
echo_piyo | 0:bf96e953cdb8 | 3253 | regVal = (regVal & 0xFC) | val; |
echo_piyo | 0:bf96e953cdb8 | 3254 | |
echo_piyo | 0:bf96e953cdb8 | 3255 | return ctrl->wr(1, BNO055P1_ACC_CONFIG, regVal); |
echo_piyo | 0:bf96e953cdb8 | 3256 | } |
echo_piyo | 0:bf96e953cdb8 | 3257 | |
echo_piyo | 0:bf96e953cdb8 | 3258 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3259 | * 地磁気センサー設定のレジスタ値を取得する |
echo_piyo | 0:bf96e953cdb8 | 3260 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3261 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3262 | * 地磁気センサー設定のレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3263 | */ |
echo_piyo | 0:bf96e953cdb8 | 3264 | char BOARDC_BNO055::getMagConfig(){ |
echo_piyo | 0:bf96e953cdb8 | 3265 | return ctrl->rr(1, BNO055P1_MAG_CONFIG); |
echo_piyo | 0:bf96e953cdb8 | 3266 | } |
echo_piyo | 0:bf96e953cdb8 | 3267 | |
echo_piyo | 0:bf96e953cdb8 | 3268 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3269 | * 地磁気センサー設定のレジスタ値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3270 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3271 | * 引数regVal: 地磁気センサー設定のレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3272 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3273 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3274 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3275 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3276 | */ |
echo_piyo | 0:bf96e953cdb8 | 3277 | char BOARDC_BNO055::setMagConfig(char regVal){ |
echo_piyo | 0:bf96e953cdb8 | 3278 | return ctrl->wr(1, BNO055P1_MAG_CONFIG, regVal); |
echo_piyo | 0:bf96e953cdb8 | 3279 | } |
echo_piyo | 0:bf96e953cdb8 | 3280 | |
echo_piyo | 0:bf96e953cdb8 | 3281 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3282 | * 地磁気センサー設定のレジスタ値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3283 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3284 | * 引数rate: 地磁気センサー出力レート(Fusion時は自動設定) |
echo_piyo | 0:bf96e953cdb8 | 3285 | * 引数oprMode: 地磁気センサー出力モード(Fusion時は自動設定) |
echo_piyo | 0:bf96e953cdb8 | 3286 | * 引数powMode: 地磁気センサー電源設定(Fusion時は自動設定) |
echo_piyo | 0:bf96e953cdb8 | 3287 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3288 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3289 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3290 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3291 | */ |
echo_piyo | 0:bf96e953cdb8 | 3292 | char BOARDC_BNO055::setMagConfig(char rate, char oprMode, char powMode){ |
echo_piyo | 0:bf96e953cdb8 | 3293 | char regVal = powMode << 5 | oprMode << 3 | rate; |
echo_piyo | 0:bf96e953cdb8 | 3294 | return ctrl->wr(1, BNO055P1_MAG_CONFIG, regVal); |
echo_piyo | 0:bf96e953cdb8 | 3295 | } |
echo_piyo | 0:bf96e953cdb8 | 3296 | |
echo_piyo | 0:bf96e953cdb8 | 3297 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3298 | * 角速度センサー設定(0)のレジスタ値を取得する |
echo_piyo | 0:bf96e953cdb8 | 3299 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3300 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3301 | * 角速度センサー設定(0)のレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3302 | */ |
echo_piyo | 0:bf96e953cdb8 | 3303 | char BOARDC_BNO055::getGyroConfig_0(){ |
echo_piyo | 0:bf96e953cdb8 | 3304 | return ctrl->rr(1, BNO055P1_GYR_CONFIG_0); |
echo_piyo | 0:bf96e953cdb8 | 3305 | } |
echo_piyo | 0:bf96e953cdb8 | 3306 | |
echo_piyo | 0:bf96e953cdb8 | 3307 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3308 | * 角速度センサー設定(0)のレジスタ値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3309 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3310 | * 引数regVal: 角速度センサー設定(0)のレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3311 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3312 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3313 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3314 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3315 | */ |
echo_piyo | 0:bf96e953cdb8 | 3316 | char BOARDC_BNO055::setGyroConfig_0(char regVal){ |
echo_piyo | 0:bf96e953cdb8 | 3317 | return ctrl->wr(1, BNO055P1_GYR_CONFIG_0, regVal); |
echo_piyo | 0:bf96e953cdb8 | 3318 | } |
echo_piyo | 0:bf96e953cdb8 | 3319 | |
echo_piyo | 0:bf96e953cdb8 | 3320 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3321 | * 角速度センサー設定(0)のレジスタ値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3322 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3323 | * 引数range: 角速度センサーの計測範囲(Fusion時は自動設定) |
echo_piyo | 0:bf96e953cdb8 | 3324 | * 引数bandWidth: 角速度センサー出力レート(Fusion時は自動設定) |
echo_piyo | 0:bf96e953cdb8 | 3325 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3326 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3327 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3328 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3329 | */ |
echo_piyo | 0:bf96e953cdb8 | 3330 | char BOARDC_BNO055::setGyroConfig_0(char range, char bandWidth){ |
echo_piyo | 0:bf96e953cdb8 | 3331 | char regVal = bandWidth << 3 | range; |
echo_piyo | 0:bf96e953cdb8 | 3332 | return ctrl->wr(1, BNO055P1_GYR_CONFIG_0, regVal); |
echo_piyo | 0:bf96e953cdb8 | 3333 | } |
echo_piyo | 0:bf96e953cdb8 | 3334 | |
echo_piyo | 0:bf96e953cdb8 | 3335 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3336 | * 角速度センサー設定(1)のレジスタ値を取得する |
echo_piyo | 0:bf96e953cdb8 | 3337 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3338 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3339 | * 角速度センサー設定(1)のレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3340 | */ |
echo_piyo | 0:bf96e953cdb8 | 3341 | char BOARDC_BNO055::getGyroConfig_1(){ |
echo_piyo | 0:bf96e953cdb8 | 3342 | return ctrl->rr(1, BNO055P1_GYR_CONFIG_0); |
echo_piyo | 0:bf96e953cdb8 | 3343 | } |
echo_piyo | 0:bf96e953cdb8 | 3344 | |
echo_piyo | 0:bf96e953cdb8 | 3345 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3346 | * 角速度センサー設定(1)のレジスタ値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3347 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3348 | * 引数powMode: 角速度センサーの電源設定(Fusion時は自動設定) |
echo_piyo | 0:bf96e953cdb8 | 3349 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3350 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3351 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3352 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3353 | */ |
echo_piyo | 0:bf96e953cdb8 | 3354 | char BOARDC_BNO055::setGyroConfig_1(char powMode){ |
echo_piyo | 0:bf96e953cdb8 | 3355 | return ctrl->wr(1, BNO055P1_GYR_CONFIG_0, powMode & 0x07); |
echo_piyo | 0:bf96e953cdb8 | 3356 | } |
echo_piyo | 0:bf96e953cdb8 | 3357 | |
echo_piyo | 0:bf96e953cdb8 | 3358 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3359 | * 角速度センサーの計測範囲を設定する |
echo_piyo | 0:bf96e953cdb8 | 3360 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3361 | * 引数G: 角速度センサーの計測範囲(2000, 1000, 500, 250, 125dpsのいずれか) |
echo_piyo | 0:bf96e953cdb8 | 3362 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3363 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3364 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3365 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3366 | */ |
echo_piyo | 0:bf96e953cdb8 | 3367 | char BOARDC_BNO055::setGyroRange(unsigned short dps){ |
echo_piyo | 0:bf96e953cdb8 | 3368 | char val = 0; |
echo_piyo | 0:bf96e953cdb8 | 3369 | switch(dps){ |
echo_piyo | 0:bf96e953cdb8 | 3370 | case 2000: |
echo_piyo | 0:bf96e953cdb8 | 3371 | val = 0; |
echo_piyo | 0:bf96e953cdb8 | 3372 | break; |
echo_piyo | 0:bf96e953cdb8 | 3373 | case 1000: |
echo_piyo | 0:bf96e953cdb8 | 3374 | val = 1; |
echo_piyo | 0:bf96e953cdb8 | 3375 | break; |
echo_piyo | 0:bf96e953cdb8 | 3376 | case 500: |
echo_piyo | 0:bf96e953cdb8 | 3377 | val = 2; |
echo_piyo | 0:bf96e953cdb8 | 3378 | break; |
echo_piyo | 0:bf96e953cdb8 | 3379 | case 250: |
echo_piyo | 0:bf96e953cdb8 | 3380 | val = 3; |
echo_piyo | 0:bf96e953cdb8 | 3381 | break; |
echo_piyo | 0:bf96e953cdb8 | 3382 | case 125: |
echo_piyo | 0:bf96e953cdb8 | 3383 | val = 4; |
echo_piyo | 0:bf96e953cdb8 | 3384 | break; |
echo_piyo | 0:bf96e953cdb8 | 3385 | default: |
echo_piyo | 0:bf96e953cdb8 | 3386 | val = 1; |
echo_piyo | 0:bf96e953cdb8 | 3387 | } |
echo_piyo | 0:bf96e953cdb8 | 3388 | |
echo_piyo | 0:bf96e953cdb8 | 3389 | char regVal = ctrl->rr(1, BNO055P1_GYR_CONFIG_0); |
echo_piyo | 0:bf96e953cdb8 | 3390 | regVal = (regVal & 0xF8) + val; |
echo_piyo | 0:bf96e953cdb8 | 3391 | |
echo_piyo | 0:bf96e953cdb8 | 3392 | return ctrl->wr(1, BNO055P1_GYR_CONFIG_0, regVal); |
echo_piyo | 0:bf96e953cdb8 | 3393 | } |
echo_piyo | 0:bf96e953cdb8 | 3394 | |
echo_piyo | 0:bf96e953cdb8 | 3395 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3396 | * 加速度センサーのスリープモードのレジスタ値を取得する |
echo_piyo | 0:bf96e953cdb8 | 3397 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3398 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3399 | * 加速度センサーのスリープモードのレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3400 | */ |
echo_piyo | 0:bf96e953cdb8 | 3401 | char BOARDC_BNO055::getAccSleepConfig(){ |
echo_piyo | 0:bf96e953cdb8 | 3402 | return ctrl->rr(1, BNO055P1_ACC_SLEEP_CONFIG); |
echo_piyo | 0:bf96e953cdb8 | 3403 | } |
echo_piyo | 0:bf96e953cdb8 | 3404 | |
echo_piyo | 0:bf96e953cdb8 | 3405 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3406 | * 加速度センサーのスリープモードのレジスタ値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3407 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3408 | * 引数regVal: 加速度センサーのスリープモードのレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3409 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3410 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3411 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3412 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3413 | */ |
echo_piyo | 0:bf96e953cdb8 | 3414 | char BOARDC_BNO055::setAccSleepConfig(char regVal){ |
echo_piyo | 0:bf96e953cdb8 | 3415 | return ctrl->wr(1, BNO055P1_ACC_SLEEP_CONFIG, regVal); |
echo_piyo | 0:bf96e953cdb8 | 3416 | } |
echo_piyo | 0:bf96e953cdb8 | 3417 | |
echo_piyo | 0:bf96e953cdb8 | 3418 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3419 | * 加速度センサーのスリープモードのレジスタ値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3420 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3421 | * 引数duration: 加速度センサーのスリープモードの持続閾値 |
echo_piyo | 0:bf96e953cdb8 | 3422 | * 引数mode: 加速度センサーのスリープモード選択 |
echo_piyo | 0:bf96e953cdb8 | 3423 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3424 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3425 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3426 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3427 | */ |
echo_piyo | 0:bf96e953cdb8 | 3428 | char BOARDC_BNO055::setAccSleepConfig(char duration, char mode){ |
echo_piyo | 0:bf96e953cdb8 | 3429 | char regVal = duration << 1 | mode; |
echo_piyo | 0:bf96e953cdb8 | 3430 | return ctrl->wr(1, BNO055P1_ACC_SLEEP_CONFIG, regVal); |
echo_piyo | 0:bf96e953cdb8 | 3431 | } |
echo_piyo | 0:bf96e953cdb8 | 3432 | |
echo_piyo | 0:bf96e953cdb8 | 3433 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3434 | * 角速度センサーのスリープモードのレジスタ値を取得する |
echo_piyo | 0:bf96e953cdb8 | 3435 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3436 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3437 | * 角速度センサーのスリープモードのレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3438 | */ |
echo_piyo | 0:bf96e953cdb8 | 3439 | char BOARDC_BNO055::getGyroSleepConfig(){ |
echo_piyo | 0:bf96e953cdb8 | 3440 | return ctrl->rr(1, BNO055P1_GYR_SLEEP_CONFIG); |
echo_piyo | 0:bf96e953cdb8 | 3441 | } |
echo_piyo | 0:bf96e953cdb8 | 3442 | |
echo_piyo | 0:bf96e953cdb8 | 3443 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3444 | * 角速度センサーのスリープモードのレジスタ値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3445 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3446 | * 引数regVal: 角速度センサーのスリープモードのレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3447 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3448 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3449 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3450 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3451 | */ |
echo_piyo | 0:bf96e953cdb8 | 3452 | char BOARDC_BNO055::setGyroSleepConfig(char regVal){ |
echo_piyo | 0:bf96e953cdb8 | 3453 | return ctrl->wr(1, BNO055P1_GYR_SLEEP_CONFIG, regVal); |
echo_piyo | 0:bf96e953cdb8 | 3454 | } |
echo_piyo | 0:bf96e953cdb8 | 3455 | |
echo_piyo | 0:bf96e953cdb8 | 3456 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3457 | * 角速度センサーのスリープモードのレジスタ値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3458 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3459 | * 引数duration: 角速度センサーの自動スリープモードの持続閾値 |
echo_piyo | 0:bf96e953cdb8 | 3460 | * 引数mode: 角速度センサーのスリープモードの持続閾値 |
echo_piyo | 0:bf96e953cdb8 | 3461 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3462 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3463 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3464 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3465 | */ |
echo_piyo | 0:bf96e953cdb8 | 3466 | char BOARDC_BNO055::setGyroSleepConfig(char autoSleepDuration, char duration){ |
echo_piyo | 0:bf96e953cdb8 | 3467 | char regVal = autoSleepDuration << 3 | duration; |
echo_piyo | 0:bf96e953cdb8 | 3468 | return ctrl->wr(1, BNO055P1_GYR_SLEEP_CONFIG, regVal); |
echo_piyo | 0:bf96e953cdb8 | 3469 | } |
echo_piyo | 0:bf96e953cdb8 | 3470 | |
echo_piyo | 0:bf96e953cdb8 | 3471 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3472 | * 各センサーの割り込みフラグ発生のINTピン出力許可設定を取得する |
echo_piyo | 0:bf96e953cdb8 | 3473 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3474 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3475 | * 各センサーの割り込みフラグ有効無効設定のレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3476 | * 2bit目 角速度センサーAnyMotion割り込み(0:無効, 1:許可) |
echo_piyo | 0:bf96e953cdb8 | 3477 | * 3bit目 角速度センサーHighRate割り込み(0:無効, 1:許可) |
echo_piyo | 0:bf96e953cdb8 | 3478 | * 5bit目 加速度センサーHIGH_G割り込み(0:無効, 1:許可) |
echo_piyo | 0:bf96e953cdb8 | 3479 | * 6bit目 加速度センサーAnyMotion割り込み(0:無効, 1:許可) |
echo_piyo | 0:bf96e953cdb8 | 3480 | * 7bit目 加速度センサーNoMotion(SloMo)割り込み(0:無効, 1:許可) |
echo_piyo | 0:bf96e953cdb8 | 3481 | */ |
echo_piyo | 0:bf96e953cdb8 | 3482 | char BOARDC_BNO055::getInterruptMask(){ |
echo_piyo | 0:bf96e953cdb8 | 3483 | return ctrl->rr(1, BNO055P1_INT_MSK); |
echo_piyo | 0:bf96e953cdb8 | 3484 | } |
echo_piyo | 0:bf96e953cdb8 | 3485 | |
echo_piyo | 0:bf96e953cdb8 | 3486 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3487 | * 各センサーの割り込みフラグ発生のINTピン出力許可設定を設定する |
echo_piyo | 0:bf96e953cdb8 | 3488 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3489 | * 引数mask: 各センサーの割り込みフラグ有効無効設定のレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3490 | * 2bit目 角速度センサーAnyMotion割り込み(0:無効, 1:許可) |
echo_piyo | 0:bf96e953cdb8 | 3491 | * 3bit目 角速度センサーHighRate割り込み(0:無効, 1:許可) |
echo_piyo | 0:bf96e953cdb8 | 3492 | * 5bit目 加速度センサーHIGH_G割り込み(0:無効, 1:許可) |
echo_piyo | 0:bf96e953cdb8 | 3493 | * 6bit目 加速度センサーAnyMotion割り込み(0:無効, 1:許可) |
echo_piyo | 0:bf96e953cdb8 | 3494 | * 7bit目 加速度センサーNoMotion(SloMo)割り込み(0:無効, 1:許可) |
echo_piyo | 0:bf96e953cdb8 | 3495 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3496 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3497 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3498 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3499 | */ |
echo_piyo | 0:bf96e953cdb8 | 3500 | char BOARDC_BNO055::setInterruptMask(char mask){ |
echo_piyo | 0:bf96e953cdb8 | 3501 | return ctrl->wr(1, BNO055P1_INT_MSK, mask); |
echo_piyo | 0:bf96e953cdb8 | 3502 | } |
echo_piyo | 0:bf96e953cdb8 | 3503 | |
echo_piyo | 0:bf96e953cdb8 | 3504 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3505 | * 各センサーの割り込みフラグ有効無効設定を取得する |
echo_piyo | 0:bf96e953cdb8 | 3506 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3507 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3508 | * 各センサーの割り込みフラグ有効無効設定のレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3509 | * 2bit目 角速度センサーAnyMotion割り込み(0:無効, 1:有効) |
echo_piyo | 0:bf96e953cdb8 | 3510 | * 3bit目 角速度センサーHighRate割り込み(0:無効, 1:有効) |
echo_piyo | 0:bf96e953cdb8 | 3511 | * 5bit目 加速度センサーHIGH_G割り込み(0:無効, 1:有効) |
echo_piyo | 0:bf96e953cdb8 | 3512 | * 6bit目 加速度センサーAnyMotion割り込み(0:無効, 1:有効) |
echo_piyo | 0:bf96e953cdb8 | 3513 | * 7bit目 加速度センサーNoMotion(SloMo)割り込み(0:無効, 1:有効) |
echo_piyo | 0:bf96e953cdb8 | 3514 | */ |
echo_piyo | 0:bf96e953cdb8 | 3515 | char BOARDC_BNO055::getInterruptEnable(){ |
echo_piyo | 0:bf96e953cdb8 | 3516 | return ctrl->rr(1, BNO055P1_INT_EN); |
echo_piyo | 0:bf96e953cdb8 | 3517 | } |
echo_piyo | 0:bf96e953cdb8 | 3518 | |
echo_piyo | 0:bf96e953cdb8 | 3519 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3520 | * 各センサーの割り込みフラグ有効無効設定を設定する |
echo_piyo | 0:bf96e953cdb8 | 3521 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3522 | * 引数mask: 各センサーの割り込みフラグ有効無効設定のレジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3523 | * 2bit目 角速度センサーAnyMotion割り込み(0:無効, 1:有効) |
echo_piyo | 0:bf96e953cdb8 | 3524 | * 3bit目 角速度センサーHighRate割り込み(0:無効, 1:有効) |
echo_piyo | 0:bf96e953cdb8 | 3525 | * 5bit目 加速度センサーHIGH_G割り込み(0:無効, 1:有効) |
echo_piyo | 0:bf96e953cdb8 | 3526 | * 6bit目 加速度センサーAnyMotion割り込み(0:無効, 1:有効) |
echo_piyo | 0:bf96e953cdb8 | 3527 | * 7bit目 加速度センサーNoMotion(SloMo)割り込み(0:無効, 1:有効) |
echo_piyo | 0:bf96e953cdb8 | 3528 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3529 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3530 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3531 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3532 | */ |
echo_piyo | 0:bf96e953cdb8 | 3533 | char BOARDC_BNO055::setInterruptEnable(char mask){ |
echo_piyo | 0:bf96e953cdb8 | 3534 | return ctrl->wr(1, BNO055P1_INT_EN, mask); |
echo_piyo | 0:bf96e953cdb8 | 3535 | } |
echo_piyo | 0:bf96e953cdb8 | 3536 | |
echo_piyo | 0:bf96e953cdb8 | 3537 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3538 | * 加速度センサーのAnyMotion割り込み発生閾値を取得する |
echo_piyo | 0:bf96e953cdb8 | 3539 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3540 | * 引数ismg: 出力する値の単位の選択(true: mG, false: mm/s^2) |
echo_piyo | 0:bf96e953cdb8 | 3541 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3542 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3543 | * 加速度センサーのAnyMotion割り込み発生閾値 |
echo_piyo | 0:bf96e953cdb8 | 3544 | */ |
echo_piyo | 0:bf96e953cdb8 | 3545 | float BOARDC_BNO055::getAccAnyMotionThreashold(bool ismg){ |
echo_piyo | 0:bf96e953cdb8 | 3546 | char rc = getAccConfig(); |
echo_piyo | 0:bf96e953cdb8 | 3547 | float scale = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 3548 | |
echo_piyo | 0:bf96e953cdb8 | 3549 | switch(rc & 0x03){ |
echo_piyo | 0:bf96e953cdb8 | 3550 | case 0: |
echo_piyo | 0:bf96e953cdb8 | 3551 | scale = 3.91; |
echo_piyo | 0:bf96e953cdb8 | 3552 | break; |
echo_piyo | 0:bf96e953cdb8 | 3553 | case 1: |
echo_piyo | 0:bf96e953cdb8 | 3554 | scale = 7.81; |
echo_piyo | 0:bf96e953cdb8 | 3555 | break; |
echo_piyo | 0:bf96e953cdb8 | 3556 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 3557 | scale = 15.63; |
echo_piyo | 0:bf96e953cdb8 | 3558 | break; |
echo_piyo | 0:bf96e953cdb8 | 3559 | case 3: |
echo_piyo | 0:bf96e953cdb8 | 3560 | scale = 31.25; |
echo_piyo | 0:bf96e953cdb8 | 3561 | break; |
echo_piyo | 0:bf96e953cdb8 | 3562 | } |
echo_piyo | 0:bf96e953cdb8 | 3563 | |
echo_piyo | 0:bf96e953cdb8 | 3564 | scale *= (ismg) ? 1.0 : 9.80665; |
echo_piyo | 0:bf96e953cdb8 | 3565 | |
echo_piyo | 0:bf96e953cdb8 | 3566 | return (1.0 * ctrl->rr(1, BNO055P1_ACC_AM_THRES)) * scale; |
echo_piyo | 0:bf96e953cdb8 | 3567 | } |
echo_piyo | 0:bf96e953cdb8 | 3568 | |
echo_piyo | 0:bf96e953cdb8 | 3569 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3570 | * 加速度センサーのAnyMotion割り込み発生閾値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3571 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3572 | * 引数ismg: 設定する値の単位の選択(true: mG, false: mm/s^2) |
echo_piyo | 0:bf96e953cdb8 | 3573 | * 引数threashold: 単位変換済みの閾値 |
echo_piyo | 0:bf96e953cdb8 | 3574 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3575 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3576 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3577 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3578 | */ |
echo_piyo | 0:bf96e953cdb8 | 3579 | char BOARDC_BNO055::setAccAnyMotionThreashold(bool ismg, float threashold){ |
echo_piyo | 0:bf96e953cdb8 | 3580 | char rc = getAccConfig(); |
echo_piyo | 0:bf96e953cdb8 | 3581 | float scale = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 3582 | |
echo_piyo | 0:bf96e953cdb8 | 3583 | switch(rc & 0x03){ |
echo_piyo | 0:bf96e953cdb8 | 3584 | case 0: |
echo_piyo | 0:bf96e953cdb8 | 3585 | scale = 3.91; |
echo_piyo | 0:bf96e953cdb8 | 3586 | break; |
echo_piyo | 0:bf96e953cdb8 | 3587 | case 1: |
echo_piyo | 0:bf96e953cdb8 | 3588 | scale = 7.81; |
echo_piyo | 0:bf96e953cdb8 | 3589 | break; |
echo_piyo | 0:bf96e953cdb8 | 3590 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 3591 | scale = 15.63; |
echo_piyo | 0:bf96e953cdb8 | 3592 | break; |
echo_piyo | 0:bf96e953cdb8 | 3593 | case 3: |
echo_piyo | 0:bf96e953cdb8 | 3594 | scale = 31.25; |
echo_piyo | 0:bf96e953cdb8 | 3595 | break; |
echo_piyo | 0:bf96e953cdb8 | 3596 | } |
echo_piyo | 0:bf96e953cdb8 | 3597 | |
echo_piyo | 0:bf96e953cdb8 | 3598 | scale *= (ismg) ? 1.0 : 9.8; |
echo_piyo | 0:bf96e953cdb8 | 3599 | |
echo_piyo | 0:bf96e953cdb8 | 3600 | char cTh = (char)((threashold / scale) + 0.5); |
echo_piyo | 0:bf96e953cdb8 | 3601 | |
echo_piyo | 0:bf96e953cdb8 | 3602 | return ctrl->wr(1, BNO055P1_ACC_AM_THRES, cTh); |
echo_piyo | 0:bf96e953cdb8 | 3603 | } |
echo_piyo | 0:bf96e953cdb8 | 3604 | |
echo_piyo | 0:bf96e953cdb8 | 3605 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3606 | * 加速度センサーの割り込み使用設定を取得する |
echo_piyo | 0:bf96e953cdb8 | 3607 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3608 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3609 | * 0bit目,1bit目 連続発生閾値([1bit目+0bit目+1]回の発生でフラグON) |
echo_piyo | 0:bf96e953cdb8 | 3610 | * 2bit目 AM/NM_X_AXISトリガー使用(0:使用しない, 1:使用する) |
echo_piyo | 0:bf96e953cdb8 | 3611 | * 3bit目 AM/NM_Y_AXISトリガー使用(0:使用しない, 1:使用する) |
echo_piyo | 0:bf96e953cdb8 | 3612 | * 4bit目 AM/NM_Z_AXISトリガー使用(0:使用しない, 1:使用する) |
echo_piyo | 0:bf96e953cdb8 | 3613 | * 5bit目 HG_X_AXISトリガー使用(0:使用しない, 1:使用する) |
echo_piyo | 0:bf96e953cdb8 | 3614 | * 6bit目 HG_Y_AXISトリガー使用(0:使用しない, 1:使用する) |
echo_piyo | 0:bf96e953cdb8 | 3615 | * 7bit目 HG_Z_AXISトリガー使用(0:使用しない, 1:使用する) |
echo_piyo | 0:bf96e953cdb8 | 3616 | */ |
echo_piyo | 0:bf96e953cdb8 | 3617 | char BOARDC_BNO055::getAccInterruptSettings(){ |
echo_piyo | 0:bf96e953cdb8 | 3618 | return ctrl->rr(1, BNO055P1_ACC_INT_SETTINGS); |
echo_piyo | 0:bf96e953cdb8 | 3619 | } |
echo_piyo | 0:bf96e953cdb8 | 3620 | |
echo_piyo | 0:bf96e953cdb8 | 3621 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3622 | * 加速度センサーの割り込み使用設定を設定する |
echo_piyo | 0:bf96e953cdb8 | 3623 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3624 | * 引数settings: |
echo_piyo | 0:bf96e953cdb8 | 3625 | * 0bit目,1bit目 連続発生閾値([1bit目+0bit目+1]回の発生でフラグON) |
echo_piyo | 0:bf96e953cdb8 | 3626 | * 2bit目 AM/NM_X_AXISトリガー使用(0:使用しない, 1:使用する) |
echo_piyo | 0:bf96e953cdb8 | 3627 | * 3bit目 AM/NM_Y_AXISトリガー使用(0:使用しない, 1:使用する) |
echo_piyo | 0:bf96e953cdb8 | 3628 | * 4bit目 AM/NM_Z_AXISトリガー使用(0:使用しない, 1:使用する) |
echo_piyo | 0:bf96e953cdb8 | 3629 | * 5bit目 HG_X_AXISトリガー使用(0:使用しない, 1:使用する) |
echo_piyo | 0:bf96e953cdb8 | 3630 | * 6bit目 HG_Y_AXISトリガー使用(0:使用しない, 1:使用する) |
echo_piyo | 0:bf96e953cdb8 | 3631 | * 7bit目 HG_Z_AXISトリガー使用(0:使用しない, 1:使用する) |
echo_piyo | 0:bf96e953cdb8 | 3632 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3633 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3634 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3635 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3636 | */ |
echo_piyo | 0:bf96e953cdb8 | 3637 | char BOARDC_BNO055::setAccInterruptSettings(char settings){ |
echo_piyo | 0:bf96e953cdb8 | 3638 | return ctrl->wr(1, BNO055P1_ACC_INT_SETTINGS, settings); |
echo_piyo | 0:bf96e953cdb8 | 3639 | } |
echo_piyo | 0:bf96e953cdb8 | 3640 | |
echo_piyo | 0:bf96e953cdb8 | 3641 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3642 | * 加速度センサーのHighG割り込み閾値を取得する |
echo_piyo | 0:bf96e953cdb8 | 3643 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3644 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3645 | * HighG割り込み発生閾値[単位:ミリ秒](2ms - 512ms) |
echo_piyo | 0:bf96e953cdb8 | 3646 | */ |
echo_piyo | 0:bf96e953cdb8 | 3647 | unsigned short BOARDC_BNO055::getAccHighGduration(){ |
echo_piyo | 0:bf96e953cdb8 | 3648 | return (ctrl->rr(1, BNO055P1_ACC_HG_DURATION) + 1) << 1; |
echo_piyo | 0:bf96e953cdb8 | 3649 | } |
echo_piyo | 0:bf96e953cdb8 | 3650 | |
echo_piyo | 0:bf96e953cdb8 | 3651 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3652 | * 加速度センサーのHighG割り込み継続発生閾値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3653 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3654 | * 引数ms: HighG割り込み継続発生閾値[単位:ミリ秒](2ms - 512ms) |
echo_piyo | 0:bf96e953cdb8 | 3655 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3656 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3657 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3658 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3659 | */ |
echo_piyo | 0:bf96e953cdb8 | 3660 | char BOARDC_BNO055::setAccHighGduration(short ms){ |
echo_piyo | 0:bf96e953cdb8 | 3661 | if(ms > 512 || ms < 2) return -1; |
echo_piyo | 0:bf96e953cdb8 | 3662 | |
echo_piyo | 0:bf96e953cdb8 | 3663 | ms = (ms >> 1) - 1; |
echo_piyo | 0:bf96e953cdb8 | 3664 | |
echo_piyo | 0:bf96e953cdb8 | 3665 | return ctrl->wr(1, BNO055P1_ACC_HG_DURATION, ms & 0xFF); |
echo_piyo | 0:bf96e953cdb8 | 3666 | } |
echo_piyo | 0:bf96e953cdb8 | 3667 | |
echo_piyo | 0:bf96e953cdb8 | 3668 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3669 | * 加速度センサーのHighG割り込み発生閾値を取得する |
echo_piyo | 0:bf96e953cdb8 | 3670 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3671 | * 引数ismg: 出力する値の単位の選択(true: mG, false: mm/s^2) |
echo_piyo | 0:bf96e953cdb8 | 3672 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3673 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3674 | * HighG割り込み発生閾値 |
echo_piyo | 0:bf96e953cdb8 | 3675 | */ |
echo_piyo | 0:bf96e953cdb8 | 3676 | float BOARDC_BNO055::getAccHighGThreashold(bool ismg){ |
echo_piyo | 0:bf96e953cdb8 | 3677 | char rc = getAccConfig(); |
echo_piyo | 0:bf96e953cdb8 | 3678 | float scale = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 3679 | |
echo_piyo | 0:bf96e953cdb8 | 3680 | switch(rc & 0x03){ |
echo_piyo | 0:bf96e953cdb8 | 3681 | case 0: |
echo_piyo | 0:bf96e953cdb8 | 3682 | scale = 7.81; |
echo_piyo | 0:bf96e953cdb8 | 3683 | break; |
echo_piyo | 0:bf96e953cdb8 | 3684 | case 1: |
echo_piyo | 0:bf96e953cdb8 | 3685 | scale = 15.63; |
echo_piyo | 0:bf96e953cdb8 | 3686 | break; |
echo_piyo | 0:bf96e953cdb8 | 3687 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 3688 | scale = 31.25; |
echo_piyo | 0:bf96e953cdb8 | 3689 | break; |
echo_piyo | 0:bf96e953cdb8 | 3690 | case 3: |
echo_piyo | 0:bf96e953cdb8 | 3691 | scale = 62.5; |
echo_piyo | 0:bf96e953cdb8 | 3692 | break; |
echo_piyo | 0:bf96e953cdb8 | 3693 | } |
echo_piyo | 0:bf96e953cdb8 | 3694 | |
echo_piyo | 0:bf96e953cdb8 | 3695 | scale *= (ismg) ? 1.0 : 9.8; |
echo_piyo | 0:bf96e953cdb8 | 3696 | |
echo_piyo | 0:bf96e953cdb8 | 3697 | return (1.0 * ctrl->rr(1, BNO055P1_ACC_HG_THRES)) * scale; |
echo_piyo | 0:bf96e953cdb8 | 3698 | } |
echo_piyo | 0:bf96e953cdb8 | 3699 | |
echo_piyo | 0:bf96e953cdb8 | 3700 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3701 | * 加速度センサーのHighG割り込み発生閾値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3702 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3703 | * 引数ismg: 設定する値の単位の選択(true: mG, false: mm/s^2) |
echo_piyo | 0:bf96e953cdb8 | 3704 | * 引数threashold: 単位変換済みの閾値 |
echo_piyo | 0:bf96e953cdb8 | 3705 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3706 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3707 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3708 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3709 | */ |
echo_piyo | 0:bf96e953cdb8 | 3710 | char BOARDC_BNO055::setAccHighGThreashold(bool ismg, float threashold){ |
echo_piyo | 0:bf96e953cdb8 | 3711 | char rc = getAccConfig(); |
echo_piyo | 0:bf96e953cdb8 | 3712 | float scale = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 3713 | |
echo_piyo | 0:bf96e953cdb8 | 3714 | switch(rc & 0x03){ |
echo_piyo | 0:bf96e953cdb8 | 3715 | case 0: |
echo_piyo | 0:bf96e953cdb8 | 3716 | scale = 7.81; |
echo_piyo | 0:bf96e953cdb8 | 3717 | break; |
echo_piyo | 0:bf96e953cdb8 | 3718 | case 1: |
echo_piyo | 0:bf96e953cdb8 | 3719 | scale = 15.63; |
echo_piyo | 0:bf96e953cdb8 | 3720 | break; |
echo_piyo | 0:bf96e953cdb8 | 3721 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 3722 | scale = 31.25; |
echo_piyo | 0:bf96e953cdb8 | 3723 | break; |
echo_piyo | 0:bf96e953cdb8 | 3724 | case 3: |
echo_piyo | 0:bf96e953cdb8 | 3725 | scale = 62.5; |
echo_piyo | 0:bf96e953cdb8 | 3726 | break; |
echo_piyo | 0:bf96e953cdb8 | 3727 | } |
echo_piyo | 0:bf96e953cdb8 | 3728 | |
echo_piyo | 0:bf96e953cdb8 | 3729 | scale *= (ismg) ? 1.0 : 9.8; |
echo_piyo | 0:bf96e953cdb8 | 3730 | |
echo_piyo | 0:bf96e953cdb8 | 3731 | char cTh = (char)((threashold / scale) + 0.5); |
echo_piyo | 0:bf96e953cdb8 | 3732 | |
echo_piyo | 0:bf96e953cdb8 | 3733 | return ctrl->wr(1, BNO055P1_ACC_HG_THRES, cTh); |
echo_piyo | 0:bf96e953cdb8 | 3734 | } |
echo_piyo | 0:bf96e953cdb8 | 3735 | |
echo_piyo | 0:bf96e953cdb8 | 3736 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3737 | * 加速度センサーのNoMotion割り込み発生閾値を取得する |
echo_piyo | 0:bf96e953cdb8 | 3738 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3739 | * 引数ismg: 設定する値の単位の選択(true: mG, false: mm/s^2) |
echo_piyo | 0:bf96e953cdb8 | 3740 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3741 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3742 | * NoMotion割り込み発生閾値 |
echo_piyo | 0:bf96e953cdb8 | 3743 | */ |
echo_piyo | 0:bf96e953cdb8 | 3744 | float BOARDC_BNO055::getAccNMThreashold(bool ismg){ |
echo_piyo | 0:bf96e953cdb8 | 3745 | char rc = getAccConfig(); |
echo_piyo | 0:bf96e953cdb8 | 3746 | float scale = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 3747 | |
echo_piyo | 0:bf96e953cdb8 | 3748 | switch(rc & 0x03){ |
echo_piyo | 0:bf96e953cdb8 | 3749 | case 0: |
echo_piyo | 0:bf96e953cdb8 | 3750 | scale = 3.91; |
echo_piyo | 0:bf96e953cdb8 | 3751 | break; |
echo_piyo | 0:bf96e953cdb8 | 3752 | case 1: |
echo_piyo | 0:bf96e953cdb8 | 3753 | scale = 7.81; |
echo_piyo | 0:bf96e953cdb8 | 3754 | break; |
echo_piyo | 0:bf96e953cdb8 | 3755 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 3756 | scale = 15.63; |
echo_piyo | 0:bf96e953cdb8 | 3757 | break; |
echo_piyo | 0:bf96e953cdb8 | 3758 | case 3: |
echo_piyo | 0:bf96e953cdb8 | 3759 | scale = 31.25; |
echo_piyo | 0:bf96e953cdb8 | 3760 | break; |
echo_piyo | 0:bf96e953cdb8 | 3761 | } |
echo_piyo | 0:bf96e953cdb8 | 3762 | |
echo_piyo | 0:bf96e953cdb8 | 3763 | scale *= (ismg) ? 1.0 : 9.8; |
echo_piyo | 0:bf96e953cdb8 | 3764 | |
echo_piyo | 0:bf96e953cdb8 | 3765 | return (1.0 * ctrl->rr(1, BNO055P1_ACC_NM_THRES)) * scale; |
echo_piyo | 0:bf96e953cdb8 | 3766 | } |
echo_piyo | 0:bf96e953cdb8 | 3767 | |
echo_piyo | 0:bf96e953cdb8 | 3768 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3769 | * 加速度センサーのNoMotion割り込み発生閾値を設定する |
echo_piyo | 0:bf96e953cdb8 | 3770 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3771 | * 引数ismg: 設定する値の単位の選択(true: mG, false: mm/s^2) |
echo_piyo | 0:bf96e953cdb8 | 3772 | * 引数threashold: 単位変換済みの閾値 |
echo_piyo | 0:bf96e953cdb8 | 3773 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3774 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3775 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3776 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3777 | */ |
echo_piyo | 0:bf96e953cdb8 | 3778 | char BOARDC_BNO055::setAccNMThreashold(bool ismg, float threashold){ |
echo_piyo | 0:bf96e953cdb8 | 3779 | char rc = getAccConfig(); |
echo_piyo | 0:bf96e953cdb8 | 3780 | float scale = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 3781 | |
echo_piyo | 0:bf96e953cdb8 | 3782 | switch(rc & 0x03){ |
echo_piyo | 0:bf96e953cdb8 | 3783 | case 0: |
echo_piyo | 0:bf96e953cdb8 | 3784 | scale = 3.91; |
echo_piyo | 0:bf96e953cdb8 | 3785 | break; |
echo_piyo | 0:bf96e953cdb8 | 3786 | case 1: |
echo_piyo | 0:bf96e953cdb8 | 3787 | scale = 7.81; |
echo_piyo | 0:bf96e953cdb8 | 3788 | break; |
echo_piyo | 0:bf96e953cdb8 | 3789 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 3790 | scale = 15.63; |
echo_piyo | 0:bf96e953cdb8 | 3791 | break; |
echo_piyo | 0:bf96e953cdb8 | 3792 | case 3: |
echo_piyo | 0:bf96e953cdb8 | 3793 | scale = 31.25; |
echo_piyo | 0:bf96e953cdb8 | 3794 | break; |
echo_piyo | 0:bf96e953cdb8 | 3795 | } |
echo_piyo | 0:bf96e953cdb8 | 3796 | |
echo_piyo | 0:bf96e953cdb8 | 3797 | scale *= (ismg) ? 1.0 : 9.8; |
echo_piyo | 0:bf96e953cdb8 | 3798 | |
echo_piyo | 0:bf96e953cdb8 | 3799 | char cTh = (char)((threashold / scale) + 0.5); |
echo_piyo | 0:bf96e953cdb8 | 3800 | |
echo_piyo | 0:bf96e953cdb8 | 3801 | return ctrl->wr(1, BNO055P1_ACC_NM_THRES, cTh); |
echo_piyo | 0:bf96e953cdb8 | 3802 | } |
echo_piyo | 0:bf96e953cdb8 | 3803 | |
echo_piyo | 0:bf96e953cdb8 | 3804 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3805 | * 加速度センサーのNoMotion割り込み設定を取得する |
echo_piyo | 0:bf96e953cdb8 | 3806 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3807 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3808 | * NoMotion割り込み設定値 |
echo_piyo | 0:bf96e953cdb8 | 3809 | * 1bit目: スローモーション、ノーモーション選択(0:NoMotion, 1:SlowMotion) |
echo_piyo | 0:bf96e953cdb8 | 3810 | * 2 - 7bit目: slo_no_mot _dur設定値(データシート参照) |
echo_piyo | 0:bf96e953cdb8 | 3811 | */ |
echo_piyo | 0:bf96e953cdb8 | 3812 | char BOARDC_BNO055::getAccNMsetting(){ |
echo_piyo | 0:bf96e953cdb8 | 3813 | return ctrl->rr(1, BNO055P1_ACC_NM_SET); |
echo_piyo | 0:bf96e953cdb8 | 3814 | } |
echo_piyo | 0:bf96e953cdb8 | 3815 | |
echo_piyo | 0:bf96e953cdb8 | 3816 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3817 | * 加速度センサーのNoMotion割り込み設定を設定する |
echo_piyo | 0:bf96e953cdb8 | 3818 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3819 | * 引数setting: NoMotion割り込み設定値 |
echo_piyo | 0:bf96e953cdb8 | 3820 | * 1bit目: スローモーション、ノーモーション選択(0:NoMotion, 1:SlowMotion) |
echo_piyo | 0:bf96e953cdb8 | 3821 | * 2 - 7bit目: slo_no_mot _dur設定値(データシート参照) |
echo_piyo | 0:bf96e953cdb8 | 3822 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3823 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3824 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3825 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3826 | */ |
echo_piyo | 0:bf96e953cdb8 | 3827 | char BOARDC_BNO055::setAccNMsetting(char setting){ |
echo_piyo | 0:bf96e953cdb8 | 3828 | return ctrl->wr(1, BNO055P1_ACC_NM_SET, setting); |
echo_piyo | 0:bf96e953cdb8 | 3829 | } |
echo_piyo | 0:bf96e953cdb8 | 3830 | |
echo_piyo | 0:bf96e953cdb8 | 3831 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3832 | * 角速度センサーの割り込み設定を取得する |
echo_piyo | 0:bf96e953cdb8 | 3833 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3834 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3835 | * 角速度センサーの割り込み設定レジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3836 | */ |
echo_piyo | 0:bf96e953cdb8 | 3837 | char BOARDC_BNO055::getGyroInterruptSettings(){ |
echo_piyo | 0:bf96e953cdb8 | 3838 | return ctrl->rr(1, BNO055P1_GYR_INT_SETING); |
echo_piyo | 0:bf96e953cdb8 | 3839 | } |
echo_piyo | 0:bf96e953cdb8 | 3840 | |
echo_piyo | 0:bf96e953cdb8 | 3841 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3842 | * 角速度センサーの割り込み設定を設定する |
echo_piyo | 0:bf96e953cdb8 | 3843 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3844 | * 引数setting: 角速度センサーの割り込み設定レジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3845 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3846 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3847 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3848 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3849 | */ |
echo_piyo | 0:bf96e953cdb8 | 3850 | char BOARDC_BNO055::setGyroInterruptSettings(char settings){ |
echo_piyo | 0:bf96e953cdb8 | 3851 | return ctrl->wr(1, BNO055P1_GYR_INT_SETING, settings); |
echo_piyo | 0:bf96e953cdb8 | 3852 | } |
echo_piyo | 0:bf96e953cdb8 | 3853 | |
echo_piyo | 0:bf96e953cdb8 | 3854 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3855 | * 角速度センサーのHighRate割り込み設定(X軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 3856 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3857 | * 引数setting: 角速度センサーの割り込み設定レジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3858 | */ |
echo_piyo | 0:bf96e953cdb8 | 3859 | char BOARDC_BNO055::getGyroHighRateXsetting(){ |
echo_piyo | 0:bf96e953cdb8 | 3860 | return ctrl->rr(1, BNO055P1_GYR_HR_X_SET); |
echo_piyo | 0:bf96e953cdb8 | 3861 | } |
echo_piyo | 0:bf96e953cdb8 | 3862 | |
echo_piyo | 0:bf96e953cdb8 | 3863 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3864 | * 角速度センサーのHighRate割り込み設定(X軸のみ、実際の値)を取得する |
echo_piyo | 0:bf96e953cdb8 | 3865 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3866 | * 引数&hyst: アドレス参照引数:関数実行後、この変数にヒステリシスの値が格納される |
echo_piyo | 0:bf96e953cdb8 | 3867 | * 引数&thres: アドレス参照引数:関数実行後、この変数にスレッショルドの値が格納される |
echo_piyo | 0:bf96e953cdb8 | 3868 | */ |
echo_piyo | 0:bf96e953cdb8 | 3869 | void BOARDC_BNO055::getGyroHighRateXsetting_dps(float &hyst, float &thres){ |
echo_piyo | 0:bf96e953cdb8 | 3870 | char r = getGyroConfig_0(); |
echo_piyo | 0:bf96e953cdb8 | 3871 | hyst = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 3872 | thres = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 3873 | |
echo_piyo | 0:bf96e953cdb8 | 3874 | switch(r & 0x07){ |
echo_piyo | 0:bf96e953cdb8 | 3875 | case 0: |
echo_piyo | 0:bf96e953cdb8 | 3876 | hyst = 62.26; |
echo_piyo | 0:bf96e953cdb8 | 3877 | thres = 62.5; |
echo_piyo | 0:bf96e953cdb8 | 3878 | break; |
echo_piyo | 0:bf96e953cdb8 | 3879 | case 1: |
echo_piyo | 0:bf96e953cdb8 | 3880 | hyst = 31.13; |
echo_piyo | 0:bf96e953cdb8 | 3881 | thres = 31.25; |
echo_piyo | 0:bf96e953cdb8 | 3882 | break; |
echo_piyo | 0:bf96e953cdb8 | 3883 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 3884 | hyst = 15.56; |
echo_piyo | 0:bf96e953cdb8 | 3885 | thres = 15.62; |
echo_piyo | 0:bf96e953cdb8 | 3886 | break; |
echo_piyo | 0:bf96e953cdb8 | 3887 | case 3: |
echo_piyo | 0:bf96e953cdb8 | 3888 | hyst = 7.78; |
echo_piyo | 0:bf96e953cdb8 | 3889 | thres = 7.81; |
echo_piyo | 0:bf96e953cdb8 | 3890 | break; |
echo_piyo | 0:bf96e953cdb8 | 3891 | case 4: |
echo_piyo | 0:bf96e953cdb8 | 3892 | hyst = 3.89; |
echo_piyo | 0:bf96e953cdb8 | 3893 | thres = 3.90; |
echo_piyo | 0:bf96e953cdb8 | 3894 | break; |
echo_piyo | 0:bf96e953cdb8 | 3895 | } |
echo_piyo | 0:bf96e953cdb8 | 3896 | |
echo_piyo | 0:bf96e953cdb8 | 3897 | char val = ctrl->rr(1, BNO055P1_GYR_HR_X_SET); |
echo_piyo | 0:bf96e953cdb8 | 3898 | |
echo_piyo | 0:bf96e953cdb8 | 3899 | hyst *= (float)((val & 0x60) * 1.0); |
echo_piyo | 0:bf96e953cdb8 | 3900 | thres *= (float)((val & 0x1F) * 1.0); |
echo_piyo | 0:bf96e953cdb8 | 3901 | } |
echo_piyo | 0:bf96e953cdb8 | 3902 | |
echo_piyo | 0:bf96e953cdb8 | 3903 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3904 | * 角速度センサーのHighRate割り込み設定(X軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 3905 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3906 | * 引数setting: 角速度センサーのHighRate割り込み設定レジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 3907 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3908 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3909 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3910 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3911 | */ |
echo_piyo | 0:bf96e953cdb8 | 3912 | char BOARDC_BNO055::setGyroHighRateXsetting(char setting){ |
echo_piyo | 0:bf96e953cdb8 | 3913 | return ctrl->wr(1, BNO055P1_GYR_HR_X_SET, setting); |
echo_piyo | 0:bf96e953cdb8 | 3914 | } |
echo_piyo | 0:bf96e953cdb8 | 3915 | |
echo_piyo | 0:bf96e953cdb8 | 3916 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3917 | * 角速度センサーのHighRate割り込み設定(X軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 3918 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3919 | * 引数hystVal: ヒステリシス |
echo_piyo | 0:bf96e953cdb8 | 3920 | * 引数thresVal: スレッショルド |
echo_piyo | 0:bf96e953cdb8 | 3921 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3922 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3923 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3924 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3925 | */ |
echo_piyo | 0:bf96e953cdb8 | 3926 | char BOARDC_BNO055::setGyroHighRateXsetting_dps(float hystVal, float thresVal){ |
echo_piyo | 0:bf96e953cdb8 | 3927 | char r = getGyroConfig_0(); |
echo_piyo | 0:bf96e953cdb8 | 3928 | float hyst = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 3929 | float thres = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 3930 | |
echo_piyo | 0:bf96e953cdb8 | 3931 | switch(r & 0x07){ |
echo_piyo | 0:bf96e953cdb8 | 3932 | case 0: |
echo_piyo | 0:bf96e953cdb8 | 3933 | hyst = 62.26; |
echo_piyo | 0:bf96e953cdb8 | 3934 | thres = 62.5; |
echo_piyo | 0:bf96e953cdb8 | 3935 | break; |
echo_piyo | 0:bf96e953cdb8 | 3936 | case 1: |
echo_piyo | 0:bf96e953cdb8 | 3937 | hyst = 31.13; |
echo_piyo | 0:bf96e953cdb8 | 3938 | thres = 31.25; |
echo_piyo | 0:bf96e953cdb8 | 3939 | break; |
echo_piyo | 0:bf96e953cdb8 | 3940 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 3941 | hyst = 15.56; |
echo_piyo | 0:bf96e953cdb8 | 3942 | thres = 15.62; |
echo_piyo | 0:bf96e953cdb8 | 3943 | break; |
echo_piyo | 0:bf96e953cdb8 | 3944 | case 3: |
echo_piyo | 0:bf96e953cdb8 | 3945 | hyst = 7.78; |
echo_piyo | 0:bf96e953cdb8 | 3946 | thres = 7.81; |
echo_piyo | 0:bf96e953cdb8 | 3947 | break; |
echo_piyo | 0:bf96e953cdb8 | 3948 | case 4: |
echo_piyo | 0:bf96e953cdb8 | 3949 | hyst = 3.89; |
echo_piyo | 0:bf96e953cdb8 | 3950 | thres = 3.90; |
echo_piyo | 0:bf96e953cdb8 | 3951 | break; |
echo_piyo | 0:bf96e953cdb8 | 3952 | } |
echo_piyo | 0:bf96e953cdb8 | 3953 | |
echo_piyo | 0:bf96e953cdb8 | 3954 | char hystChar = (char)((hystVal / hyst) + 0.5); |
echo_piyo | 0:bf96e953cdb8 | 3955 | char thresChar = (char)((thresVal / thres) + 0.5); |
echo_piyo | 0:bf96e953cdb8 | 3956 | |
echo_piyo | 0:bf96e953cdb8 | 3957 | return ctrl->wr(1, BNO055P1_GYR_HR_X_SET, ((hystChar << 5) | thresChar)); |
echo_piyo | 0:bf96e953cdb8 | 3958 | } |
echo_piyo | 0:bf96e953cdb8 | 3959 | |
echo_piyo | 0:bf96e953cdb8 | 3960 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3961 | * 角速度センサーのHighRate割り込み継続発生閾値(X軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 3962 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3963 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3964 | * HighRate割り込み継続発生閾値[単位:ミリ秒] |
echo_piyo | 0:bf96e953cdb8 | 3965 | */ |
echo_piyo | 0:bf96e953cdb8 | 3966 | float BOARDC_BNO055::getGyroHighRateXduration(){ |
echo_piyo | 0:bf96e953cdb8 | 3967 | return (float)(1 + ctrl->rr(1, BNO055P1_GYR_DUR_X)) * 2.5; |
echo_piyo | 0:bf96e953cdb8 | 3968 | } |
echo_piyo | 0:bf96e953cdb8 | 3969 | |
echo_piyo | 0:bf96e953cdb8 | 3970 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3971 | * 角速度センサーのHighRate割り込み継続発生閾値(X軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 3972 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3973 | * 引数duration: HighRate割り込み継続発生閾値[単位:ミリ秒] |
echo_piyo | 0:bf96e953cdb8 | 3974 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3975 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3976 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 3977 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 3978 | */ |
echo_piyo | 0:bf96e953cdb8 | 3979 | char BOARDC_BNO055::setGyroHighRateXduration(float duration){ |
echo_piyo | 0:bf96e953cdb8 | 3980 | return ctrl->wr(1, BNO055P1_GYR_HR_X_SET, (char)(((duration / 2.5) - 1.0) + 0.5)); |
echo_piyo | 0:bf96e953cdb8 | 3981 | } |
echo_piyo | 0:bf96e953cdb8 | 3982 | |
echo_piyo | 0:bf96e953cdb8 | 3983 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3984 | * 角速度センサーのHighRate割り込み設定(Y軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 3985 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3986 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 3987 | * 角速度センサーのHighRate割り込み設定 |
echo_piyo | 0:bf96e953cdb8 | 3988 | */ |
echo_piyo | 0:bf96e953cdb8 | 3989 | char BOARDC_BNO055::getGyroHighRateYsetting(){ |
echo_piyo | 0:bf96e953cdb8 | 3990 | return ctrl->rr(1, BNO055P1_GYR_HR_Y_SET); |
echo_piyo | 0:bf96e953cdb8 | 3991 | } |
echo_piyo | 0:bf96e953cdb8 | 3992 | |
echo_piyo | 0:bf96e953cdb8 | 3993 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 3994 | * 角速度センサーのHighRate割り込み設定(Y軸のみ、実際の値)を取得する |
echo_piyo | 0:bf96e953cdb8 | 3995 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 3996 | * 引数&hyst: アドレス参照引数:関数実行後、この変数にヒステリシスの値が格納される |
echo_piyo | 0:bf96e953cdb8 | 3997 | * 引数&thres: アドレス参照引数:関数実行後、この変数にスレッショルドの値が格納される |
echo_piyo | 0:bf96e953cdb8 | 3998 | */ |
echo_piyo | 0:bf96e953cdb8 | 3999 | void BOARDC_BNO055::getGyroHighRateYsetting_dps(float &hyst, float &thres){ |
echo_piyo | 0:bf96e953cdb8 | 4000 | char r = getGyroConfig_0(); |
echo_piyo | 0:bf96e953cdb8 | 4001 | hyst = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 4002 | thres = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 4003 | |
echo_piyo | 0:bf96e953cdb8 | 4004 | switch(r & 0x07){ |
echo_piyo | 0:bf96e953cdb8 | 4005 | case 0: |
echo_piyo | 0:bf96e953cdb8 | 4006 | hyst = 62.26; |
echo_piyo | 0:bf96e953cdb8 | 4007 | thres = 62.5; |
echo_piyo | 0:bf96e953cdb8 | 4008 | break; |
echo_piyo | 0:bf96e953cdb8 | 4009 | case 1: |
echo_piyo | 0:bf96e953cdb8 | 4010 | hyst = 31.13; |
echo_piyo | 0:bf96e953cdb8 | 4011 | thres = 31.25; |
echo_piyo | 0:bf96e953cdb8 | 4012 | break; |
echo_piyo | 0:bf96e953cdb8 | 4013 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 4014 | hyst = 15.56; |
echo_piyo | 0:bf96e953cdb8 | 4015 | thres = 15.62; |
echo_piyo | 0:bf96e953cdb8 | 4016 | break; |
echo_piyo | 0:bf96e953cdb8 | 4017 | case 3: |
echo_piyo | 0:bf96e953cdb8 | 4018 | hyst = 7.78; |
echo_piyo | 0:bf96e953cdb8 | 4019 | thres = 7.81; |
echo_piyo | 0:bf96e953cdb8 | 4020 | break; |
echo_piyo | 0:bf96e953cdb8 | 4021 | case 4: |
echo_piyo | 0:bf96e953cdb8 | 4022 | hyst = 3.89; |
echo_piyo | 0:bf96e953cdb8 | 4023 | thres = 3.90; |
echo_piyo | 0:bf96e953cdb8 | 4024 | break; |
echo_piyo | 0:bf96e953cdb8 | 4025 | } |
echo_piyo | 0:bf96e953cdb8 | 4026 | |
echo_piyo | 0:bf96e953cdb8 | 4027 | char val = ctrl->rr(1, BNO055P1_GYR_HR_Y_SET); |
echo_piyo | 0:bf96e953cdb8 | 4028 | |
echo_piyo | 0:bf96e953cdb8 | 4029 | hyst *= (float)((val & 0x60) * 1.0); |
echo_piyo | 0:bf96e953cdb8 | 4030 | thres *= (float)((val & 0x1F) * 1.0); |
echo_piyo | 0:bf96e953cdb8 | 4031 | } |
echo_piyo | 0:bf96e953cdb8 | 4032 | |
echo_piyo | 0:bf96e953cdb8 | 4033 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 4034 | * 角速度センサーのHighRate割り込み設定(Y軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 4035 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4036 | * 引数setting: 角速度センサーのHighRate割り込み設定レジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 4037 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4038 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 4039 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 4040 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 4041 | */ |
echo_piyo | 0:bf96e953cdb8 | 4042 | char BOARDC_BNO055::setGyroHighRateYsetting(char setting){ |
echo_piyo | 0:bf96e953cdb8 | 4043 | return ctrl->wr(1, BNO055P1_GYR_HR_Y_SET, setting); |
echo_piyo | 0:bf96e953cdb8 | 4044 | } |
echo_piyo | 0:bf96e953cdb8 | 4045 | |
echo_piyo | 0:bf96e953cdb8 | 4046 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 4047 | * 角速度センサーのHighRate割り込み設定(Y軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 4048 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4049 | * 引数hystVal: ヒステリシス |
echo_piyo | 0:bf96e953cdb8 | 4050 | * 引数thresVal: スレッショルド |
echo_piyo | 0:bf96e953cdb8 | 4051 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4052 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 4053 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 4054 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 4055 | */ |
echo_piyo | 0:bf96e953cdb8 | 4056 | char BOARDC_BNO055::setGyroHighRateYsetting_dps(float hystVal, float thresVal){ |
echo_piyo | 0:bf96e953cdb8 | 4057 | char r = getGyroConfig_0(); |
echo_piyo | 0:bf96e953cdb8 | 4058 | float hyst = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 4059 | float thres = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 4060 | |
echo_piyo | 0:bf96e953cdb8 | 4061 | switch(r & 0x07){ |
echo_piyo | 0:bf96e953cdb8 | 4062 | case 0: |
echo_piyo | 0:bf96e953cdb8 | 4063 | hyst = 62.26; |
echo_piyo | 0:bf96e953cdb8 | 4064 | thres = 62.5; |
echo_piyo | 0:bf96e953cdb8 | 4065 | break; |
echo_piyo | 0:bf96e953cdb8 | 4066 | case 1: |
echo_piyo | 0:bf96e953cdb8 | 4067 | hyst = 31.13; |
echo_piyo | 0:bf96e953cdb8 | 4068 | thres = 31.25; |
echo_piyo | 0:bf96e953cdb8 | 4069 | break; |
echo_piyo | 0:bf96e953cdb8 | 4070 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 4071 | hyst = 15.56; |
echo_piyo | 0:bf96e953cdb8 | 4072 | thres = 15.62; |
echo_piyo | 0:bf96e953cdb8 | 4073 | break; |
echo_piyo | 0:bf96e953cdb8 | 4074 | case 3: |
echo_piyo | 0:bf96e953cdb8 | 4075 | hyst = 7.78; |
echo_piyo | 0:bf96e953cdb8 | 4076 | thres = 7.81; |
echo_piyo | 0:bf96e953cdb8 | 4077 | break; |
echo_piyo | 0:bf96e953cdb8 | 4078 | case 4: |
echo_piyo | 0:bf96e953cdb8 | 4079 | hyst = 3.89; |
echo_piyo | 0:bf96e953cdb8 | 4080 | thres = 3.90; |
echo_piyo | 0:bf96e953cdb8 | 4081 | break; |
echo_piyo | 0:bf96e953cdb8 | 4082 | } |
echo_piyo | 0:bf96e953cdb8 | 4083 | |
echo_piyo | 0:bf96e953cdb8 | 4084 | char hystChar = (char)((hystVal / hyst) + 0.5); |
echo_piyo | 0:bf96e953cdb8 | 4085 | char thresChar = (char)((thresVal / thres) + 0.5); |
echo_piyo | 0:bf96e953cdb8 | 4086 | |
echo_piyo | 0:bf96e953cdb8 | 4087 | return ctrl->wr(1, BNO055P1_GYR_HR_Y_SET, ((hystChar << 5) | thresChar)); |
echo_piyo | 0:bf96e953cdb8 | 4088 | } |
echo_piyo | 0:bf96e953cdb8 | 4089 | |
echo_piyo | 0:bf96e953cdb8 | 4090 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 4091 | * 角速度センサーのHighRate割り込み継続発生閾値(Y軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 4092 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4093 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 4094 | * HighRate割り込み継続発生閾値[単位:ミリ秒] |
echo_piyo | 0:bf96e953cdb8 | 4095 | */ |
echo_piyo | 0:bf96e953cdb8 | 4096 | float BOARDC_BNO055::getGyroHighRateYduration(){ |
echo_piyo | 0:bf96e953cdb8 | 4097 | return (float)(1 + ctrl->rr(1, BNO055P1_GYR_DUR_Y)) * 2.5; |
echo_piyo | 0:bf96e953cdb8 | 4098 | } |
echo_piyo | 0:bf96e953cdb8 | 4099 | |
echo_piyo | 0:bf96e953cdb8 | 4100 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 4101 | * 角速度センサーのHighRate割り込み継続発生閾値(Y軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 4102 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4103 | * 引数duration: HighRate割り込み継続発生閾値[単位:ミリ秒] |
echo_piyo | 0:bf96e953cdb8 | 4104 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4105 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 4106 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 4107 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 4108 | */ |
echo_piyo | 0:bf96e953cdb8 | 4109 | char BOARDC_BNO055::setGyroHighRateYduration(float duration){ |
echo_piyo | 0:bf96e953cdb8 | 4110 | return ctrl->wr(1, BNO055P1_GYR_HR_Y_SET, (char)(((duration / 2.5) - 1.0) + 0.5)); |
echo_piyo | 0:bf96e953cdb8 | 4111 | } |
echo_piyo | 0:bf96e953cdb8 | 4112 | |
echo_piyo | 0:bf96e953cdb8 | 4113 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 4114 | * 角速度センサーのHighRate割り込み設定(Z軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 4115 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4116 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 4117 | * 角速度センサーのHighRate割り込み設定レジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 4118 | */ |
echo_piyo | 0:bf96e953cdb8 | 4119 | char BOARDC_BNO055::getGyroHighRateZsetting(){ |
echo_piyo | 0:bf96e953cdb8 | 4120 | return ctrl->rr(1, BNO055P1_GYR_HR_Z_SET); |
echo_piyo | 0:bf96e953cdb8 | 4121 | } |
echo_piyo | 0:bf96e953cdb8 | 4122 | |
echo_piyo | 0:bf96e953cdb8 | 4123 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 4124 | * 角速度センサーのHighRate割り込み設定(Z軸のみ、実際の値)を取得する |
echo_piyo | 0:bf96e953cdb8 | 4125 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4126 | * 引数&hyst: アドレス参照引数:関数実行後、この変数にヒステリシスの値が格納される |
echo_piyo | 0:bf96e953cdb8 | 4127 | * 引数&thres: アドレス参照引数:関数実行後、この変数にスレッショルドの値が格納される |
echo_piyo | 0:bf96e953cdb8 | 4128 | */ |
echo_piyo | 0:bf96e953cdb8 | 4129 | void BOARDC_BNO055::getGyroHighRateZsetting_dps(float &hyst, float &thres){ |
echo_piyo | 0:bf96e953cdb8 | 4130 | char r = getGyroConfig_0(); |
echo_piyo | 0:bf96e953cdb8 | 4131 | hyst = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 4132 | thres = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 4133 | |
echo_piyo | 0:bf96e953cdb8 | 4134 | switch(r & 0x07){ |
echo_piyo | 0:bf96e953cdb8 | 4135 | case 0: |
echo_piyo | 0:bf96e953cdb8 | 4136 | hyst = 62.26; |
echo_piyo | 0:bf96e953cdb8 | 4137 | thres = 62.5; |
echo_piyo | 0:bf96e953cdb8 | 4138 | break; |
echo_piyo | 0:bf96e953cdb8 | 4139 | case 1: |
echo_piyo | 0:bf96e953cdb8 | 4140 | hyst = 31.13; |
echo_piyo | 0:bf96e953cdb8 | 4141 | thres = 31.25; |
echo_piyo | 0:bf96e953cdb8 | 4142 | break; |
echo_piyo | 0:bf96e953cdb8 | 4143 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 4144 | hyst = 15.56; |
echo_piyo | 0:bf96e953cdb8 | 4145 | thres = 15.62; |
echo_piyo | 0:bf96e953cdb8 | 4146 | break; |
echo_piyo | 0:bf96e953cdb8 | 4147 | case 3: |
echo_piyo | 0:bf96e953cdb8 | 4148 | hyst = 7.78; |
echo_piyo | 0:bf96e953cdb8 | 4149 | thres = 7.81; |
echo_piyo | 0:bf96e953cdb8 | 4150 | break; |
echo_piyo | 0:bf96e953cdb8 | 4151 | case 4: |
echo_piyo | 0:bf96e953cdb8 | 4152 | hyst = 3.89; |
echo_piyo | 0:bf96e953cdb8 | 4153 | thres = 3.90; |
echo_piyo | 0:bf96e953cdb8 | 4154 | break; |
echo_piyo | 0:bf96e953cdb8 | 4155 | } |
echo_piyo | 0:bf96e953cdb8 | 4156 | |
echo_piyo | 0:bf96e953cdb8 | 4157 | char val = ctrl->rr(1, BNO055P1_GYR_HR_Z_SET); |
echo_piyo | 0:bf96e953cdb8 | 4158 | |
echo_piyo | 0:bf96e953cdb8 | 4159 | hyst *= (float)((val & 0x60) * 1.0); |
echo_piyo | 0:bf96e953cdb8 | 4160 | thres *= (float)((val & 0x1F) * 1.0); |
echo_piyo | 0:bf96e953cdb8 | 4161 | } |
echo_piyo | 0:bf96e953cdb8 | 4162 | |
echo_piyo | 0:bf96e953cdb8 | 4163 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 4164 | * 角速度センサーのHighRate割り込み設定(Z軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 4165 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4166 | * 引数setting: 角速度センサーのHighRate割り込み設定レジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 4167 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4168 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 4169 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 4170 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 4171 | */ |
echo_piyo | 0:bf96e953cdb8 | 4172 | char BOARDC_BNO055::setGyroHighRateZsetting(char setting){ |
echo_piyo | 0:bf96e953cdb8 | 4173 | return ctrl->wr(1, BNO055P1_GYR_HR_Z_SET, setting); |
echo_piyo | 0:bf96e953cdb8 | 4174 | } |
echo_piyo | 0:bf96e953cdb8 | 4175 | |
echo_piyo | 0:bf96e953cdb8 | 4176 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 4177 | * 角速度センサーのHighRate割り込み設定(Z軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 4178 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4179 | * 引数hystVal: ヒステリシス |
echo_piyo | 0:bf96e953cdb8 | 4180 | * 引数thresVal: スレッショルド |
echo_piyo | 0:bf96e953cdb8 | 4181 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4182 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 4183 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 4184 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 4185 | */ |
echo_piyo | 0:bf96e953cdb8 | 4186 | char BOARDC_BNO055::setGyroHighRateZsetting_dps(float hystVal, float thresVal){ |
echo_piyo | 0:bf96e953cdb8 | 4187 | char r = getGyroConfig_0(); |
echo_piyo | 0:bf96e953cdb8 | 4188 | float hyst = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 4189 | float thres = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 4190 | |
echo_piyo | 0:bf96e953cdb8 | 4191 | switch(r & 0x07){ |
echo_piyo | 0:bf96e953cdb8 | 4192 | case 0: |
echo_piyo | 0:bf96e953cdb8 | 4193 | hyst = 62.26; |
echo_piyo | 0:bf96e953cdb8 | 4194 | thres = 62.5; |
echo_piyo | 0:bf96e953cdb8 | 4195 | break; |
echo_piyo | 0:bf96e953cdb8 | 4196 | case 1: |
echo_piyo | 0:bf96e953cdb8 | 4197 | hyst = 31.13; |
echo_piyo | 0:bf96e953cdb8 | 4198 | thres = 31.25; |
echo_piyo | 0:bf96e953cdb8 | 4199 | break; |
echo_piyo | 0:bf96e953cdb8 | 4200 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 4201 | hyst = 15.56; |
echo_piyo | 0:bf96e953cdb8 | 4202 | thres = 15.62; |
echo_piyo | 0:bf96e953cdb8 | 4203 | break; |
echo_piyo | 0:bf96e953cdb8 | 4204 | case 3: |
echo_piyo | 0:bf96e953cdb8 | 4205 | hyst = 7.78; |
echo_piyo | 0:bf96e953cdb8 | 4206 | thres = 7.81; |
echo_piyo | 0:bf96e953cdb8 | 4207 | break; |
echo_piyo | 0:bf96e953cdb8 | 4208 | case 4: |
echo_piyo | 0:bf96e953cdb8 | 4209 | hyst = 3.89; |
echo_piyo | 0:bf96e953cdb8 | 4210 | thres = 3.90; |
echo_piyo | 0:bf96e953cdb8 | 4211 | break; |
echo_piyo | 0:bf96e953cdb8 | 4212 | } |
echo_piyo | 0:bf96e953cdb8 | 4213 | |
echo_piyo | 0:bf96e953cdb8 | 4214 | char hystChar = (char)((hystVal / hyst) + 0.5); |
echo_piyo | 0:bf96e953cdb8 | 4215 | char thresChar = (char)((thresVal / thres) + 0.5); |
echo_piyo | 0:bf96e953cdb8 | 4216 | |
echo_piyo | 0:bf96e953cdb8 | 4217 | return ctrl->wr(1, BNO055P1_GYR_HR_Z_SET, ((hystChar << 5) | thresChar)); |
echo_piyo | 0:bf96e953cdb8 | 4218 | } |
echo_piyo | 0:bf96e953cdb8 | 4219 | |
echo_piyo | 0:bf96e953cdb8 | 4220 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 4221 | * 角速度センサーのHighRate割り込み継続発生閾値(Z軸のみ)を取得する |
echo_piyo | 0:bf96e953cdb8 | 4222 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4223 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 4224 | * HighRate割り込み継続発生閾値[単位:ミリ秒] |
echo_piyo | 0:bf96e953cdb8 | 4225 | */ |
echo_piyo | 0:bf96e953cdb8 | 4226 | float BOARDC_BNO055::getGyroHighRateZduration(){ |
echo_piyo | 0:bf96e953cdb8 | 4227 | return (float)(1 + ctrl->rr(1, BNO055P1_GYR_DUR_Z)) * 2.5; |
echo_piyo | 0:bf96e953cdb8 | 4228 | } |
echo_piyo | 0:bf96e953cdb8 | 4229 | |
echo_piyo | 0:bf96e953cdb8 | 4230 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 4231 | * 角速度センサーのHighRate割り込み継続発生閾値(Z軸のみ)を設定する |
echo_piyo | 0:bf96e953cdb8 | 4232 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4233 | * 引数duration: HighRate割り込み継続発生閾値[単位:ミリ秒] |
echo_piyo | 0:bf96e953cdb8 | 4234 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4235 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 4236 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 4237 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 4238 | */ |
echo_piyo | 0:bf96e953cdb8 | 4239 | char BOARDC_BNO055::setGyroHighRateZduration(float duration){ |
echo_piyo | 0:bf96e953cdb8 | 4240 | return ctrl->wr(1, BNO055P1_GYR_HR_Z_SET, (char)(((duration / 2.5) - 1.0) + 0.5)); |
echo_piyo | 0:bf96e953cdb8 | 4241 | } |
echo_piyo | 0:bf96e953cdb8 | 4242 | |
echo_piyo | 0:bf96e953cdb8 | 4243 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 4244 | * 角速度センサーのAnyMotion割り込み閾値を取得する |
echo_piyo | 0:bf96e953cdb8 | 4245 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4246 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 4247 | * AnyMotion割り込み閾値[単位:dps] |
echo_piyo | 0:bf96e953cdb8 | 4248 | */ |
echo_piyo | 0:bf96e953cdb8 | 4249 | float BOARDC_BNO055::getGyroAnyMotionThreashold(){ |
echo_piyo | 0:bf96e953cdb8 | 4250 | char r = getGyroConfig_0(); |
echo_piyo | 0:bf96e953cdb8 | 4251 | float scale = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 4252 | |
echo_piyo | 0:bf96e953cdb8 | 4253 | switch(r & 0x07){ |
echo_piyo | 0:bf96e953cdb8 | 4254 | case 0: |
echo_piyo | 0:bf96e953cdb8 | 4255 | scale = 1.0f; |
echo_piyo | 0:bf96e953cdb8 | 4256 | break; |
echo_piyo | 0:bf96e953cdb8 | 4257 | case 1: |
echo_piyo | 0:bf96e953cdb8 | 4258 | scale = 0.5; |
echo_piyo | 0:bf96e953cdb8 | 4259 | break; |
echo_piyo | 0:bf96e953cdb8 | 4260 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 4261 | scale = 0.25; |
echo_piyo | 0:bf96e953cdb8 | 4262 | break; |
echo_piyo | 0:bf96e953cdb8 | 4263 | case 3: |
echo_piyo | 0:bf96e953cdb8 | 4264 | scale = 0.125; |
echo_piyo | 0:bf96e953cdb8 | 4265 | break; |
echo_piyo | 0:bf96e953cdb8 | 4266 | case 4: |
echo_piyo | 0:bf96e953cdb8 | 4267 | scale = 0.0625; |
echo_piyo | 0:bf96e953cdb8 | 4268 | break; |
echo_piyo | 0:bf96e953cdb8 | 4269 | } |
echo_piyo | 0:bf96e953cdb8 | 4270 | |
echo_piyo | 0:bf96e953cdb8 | 4271 | return (1.0f * ctrl->rr(1, BNO055P1_GYR_AM_THRES)) * scale; |
echo_piyo | 0:bf96e953cdb8 | 4272 | } |
echo_piyo | 0:bf96e953cdb8 | 4273 | |
echo_piyo | 0:bf96e953cdb8 | 4274 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 4275 | * 角速度センサーのAnyMotion割り込み閾値を設定する |
echo_piyo | 0:bf96e953cdb8 | 4276 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4277 | * 引数threashold: AnyMotion割り込み閾値[単位:dps] |
echo_piyo | 0:bf96e953cdb8 | 4278 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4279 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 4280 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 4281 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 4282 | */ |
echo_piyo | 0:bf96e953cdb8 | 4283 | char BOARDC_BNO055::setGyroAnyMotionThreashold(float threashold){ |
echo_piyo | 0:bf96e953cdb8 | 4284 | char r = getGyroConfig_0(); |
echo_piyo | 0:bf96e953cdb8 | 4285 | float scale = 0.0f; |
echo_piyo | 0:bf96e953cdb8 | 4286 | |
echo_piyo | 0:bf96e953cdb8 | 4287 | switch(r & 0x07){ |
echo_piyo | 0:bf96e953cdb8 | 4288 | case 0: |
echo_piyo | 0:bf96e953cdb8 | 4289 | scale = 1.0f; |
echo_piyo | 0:bf96e953cdb8 | 4290 | break; |
echo_piyo | 0:bf96e953cdb8 | 4291 | case 1: |
echo_piyo | 0:bf96e953cdb8 | 4292 | scale = 0.5; |
echo_piyo | 0:bf96e953cdb8 | 4293 | break; |
echo_piyo | 0:bf96e953cdb8 | 4294 | case 2: |
echo_piyo | 0:bf96e953cdb8 | 4295 | scale = 0.25; |
echo_piyo | 0:bf96e953cdb8 | 4296 | break; |
echo_piyo | 0:bf96e953cdb8 | 4297 | case 3: |
echo_piyo | 0:bf96e953cdb8 | 4298 | scale = 0.125; |
echo_piyo | 0:bf96e953cdb8 | 4299 | break; |
echo_piyo | 0:bf96e953cdb8 | 4300 | case 4: |
echo_piyo | 0:bf96e953cdb8 | 4301 | scale = 0.0625; |
echo_piyo | 0:bf96e953cdb8 | 4302 | break; |
echo_piyo | 0:bf96e953cdb8 | 4303 | } |
echo_piyo | 0:bf96e953cdb8 | 4304 | |
echo_piyo | 0:bf96e953cdb8 | 4305 | return ctrl->wr(1, BNO055P1_GYR_AM_THRES, (char)((threashold / scale) + 0.5)); |
echo_piyo | 0:bf96e953cdb8 | 4306 | } |
echo_piyo | 0:bf96e953cdb8 | 4307 | |
echo_piyo | 0:bf96e953cdb8 | 4308 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 4309 | * 加速度センサーのAnyMotion割り込み閾値を取得する |
echo_piyo | 0:bf96e953cdb8 | 4310 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4311 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 4312 | * AnyMotion割り込み設定レジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 4313 | */ |
echo_piyo | 0:bf96e953cdb8 | 4314 | char BOARDC_BNO055::getAccAnyMotionSetting(){ |
echo_piyo | 0:bf96e953cdb8 | 4315 | return ctrl->rr(1, BNO055P1_GYR_AM_SET); |
echo_piyo | 0:bf96e953cdb8 | 4316 | } |
echo_piyo | 0:bf96e953cdb8 | 4317 | |
echo_piyo | 0:bf96e953cdb8 | 4318 | /* ================================================================== |
echo_piyo | 0:bf96e953cdb8 | 4319 | * 加速度センサーのAnyMotion割り込み閾値を設定する |
echo_piyo | 0:bf96e953cdb8 | 4320 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4321 | * 引数setting: AnyMotion割り込み設定レジスタ値 |
echo_piyo | 0:bf96e953cdb8 | 4322 | * ------------------------------------------------------------------ |
echo_piyo | 0:bf96e953cdb8 | 4323 | * returns: |
echo_piyo | 0:bf96e953cdb8 | 4324 | * -1 失敗 |
echo_piyo | 0:bf96e953cdb8 | 4325 | * 1 成功 |
echo_piyo | 0:bf96e953cdb8 | 4326 | */ |
echo_piyo | 0:bf96e953cdb8 | 4327 | char BOARDC_BNO055::setAccAnyMotionSetting(char setting){ |
echo_piyo | 0:bf96e953cdb8 | 4328 | return ctrl->wr(1, BNO055P1_GYR_AM_SET, setting); |
echo_piyo | 0:bf96e953cdb8 | 4329 | } |