initial
BMG160.h@0:4f5c0b7acaa8, 2018-04-27 (annotated)
- Committer:
- johnathanlyu
- Date:
- Fri Apr 27 09:55:36 2018 +0000
- Revision:
- 0:4f5c0b7acaa8
update library flow
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
johnathanlyu | 0:4f5c0b7acaa8 | 1 | /* Copyright (c) 2016 MtM Technology Corporation, MIT License |
johnathanlyu | 0:4f5c0b7acaa8 | 2 | * |
johnathanlyu | 0:4f5c0b7acaa8 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
johnathanlyu | 0:4f5c0b7acaa8 | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
johnathanlyu | 0:4f5c0b7acaa8 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
johnathanlyu | 0:4f5c0b7acaa8 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
johnathanlyu | 0:4f5c0b7acaa8 | 7 | * furnished to do so, subject to the following conditions: |
johnathanlyu | 0:4f5c0b7acaa8 | 8 | * |
johnathanlyu | 0:4f5c0b7acaa8 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
johnathanlyu | 0:4f5c0b7acaa8 | 10 | * substantial portions of the Software. |
johnathanlyu | 0:4f5c0b7acaa8 | 11 | * |
johnathanlyu | 0:4f5c0b7acaa8 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
johnathanlyu | 0:4f5c0b7acaa8 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
johnathanlyu | 0:4f5c0b7acaa8 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
johnathanlyu | 0:4f5c0b7acaa8 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
johnathanlyu | 0:4f5c0b7acaa8 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
johnathanlyu | 0:4f5c0b7acaa8 | 17 | */ |
johnathanlyu | 0:4f5c0b7acaa8 | 18 | #ifndef BMG160_h |
johnathanlyu | 0:4f5c0b7acaa8 | 19 | #define BMG160_h |
johnathanlyu | 0:4f5c0b7acaa8 | 20 | |
johnathanlyu | 0:4f5c0b7acaa8 | 21 | #include "mbed.h" |
johnathanlyu | 0:4f5c0b7acaa8 | 22 | |
johnathanlyu | 0:4f5c0b7acaa8 | 23 | #define BMG160_SLAVE_ADDR 0xd0 |
johnathanlyu | 0:4f5c0b7acaa8 | 24 | |
johnathanlyu | 0:4f5c0b7acaa8 | 25 | class BMG160 { |
johnathanlyu | 0:4f5c0b7acaa8 | 26 | public: |
johnathanlyu | 0:4f5c0b7acaa8 | 27 | BMG160(PinName i2c_sda, PinName i2c_scl, PinName int1 = NC, PinName int2 = NC, uint8_t range = 0x00, uint8_t bandwith = 0x00); |
johnathanlyu | 0:4f5c0b7acaa8 | 28 | void ReadXYZ(int16_t *xyz); |
johnathanlyu | 0:4f5c0b7acaa8 | 29 | |
johnathanlyu | 0:4f5c0b7acaa8 | 30 | private: |
johnathanlyu | 0:4f5c0b7acaa8 | 31 | I2C i2c_; |
johnathanlyu | 0:4f5c0b7acaa8 | 32 | PinName interrupt1_pinname_; |
johnathanlyu | 0:4f5c0b7acaa8 | 33 | InterruptIn interrupt1_; |
johnathanlyu | 0:4f5c0b7acaa8 | 34 | PinName interrupt2_pinname_; |
johnathanlyu | 0:4f5c0b7acaa8 | 35 | InterruptIn interrupt2_; |
johnathanlyu | 0:4f5c0b7acaa8 | 36 | uint8_t range_; |
johnathanlyu | 0:4f5c0b7acaa8 | 37 | uint8_t bandwith_; |
johnathanlyu | 0:4f5c0b7acaa8 | 38 | |
johnathanlyu | 0:4f5c0b7acaa8 | 39 | void RegWrite(char reg, char val); |
johnathanlyu | 0:4f5c0b7acaa8 | 40 | void RegRead (char reg, char *val, int len); |
johnathanlyu | 0:4f5c0b7acaa8 | 41 | }; |
johnathanlyu | 0:4f5c0b7acaa8 | 42 | |
johnathanlyu | 0:4f5c0b7acaa8 | 43 | #endif |