LIS3DH / STMicroelectronics / MEMS motion sensor, 3-axis accelerometer library
Diff: LIS3DH.cpp
- Revision:
- 8:0999d25ed7bc
- Parent:
- 7:50ac3372def2
--- a/LIS3DH.cpp Sat Dec 12 06:06:43 2015 +0000 +++ b/LIS3DH.cpp Wed Aug 23 09:26:06 2017 +0000 @@ -3,42 +3,40 @@ * LIS3DH MEMS motion sensor: 3-axis "nano" accelerometer, made by STMicroelectronics * http://www.st-japan.co.jp/web/jp/catalog/sense_power/FM89/SC444/PF250725 * - * Copyright (c) 2014,'15 Kenji Arai / JH1PJL + * Copyright (c) 2014,'15,'17 Kenji Arai / JH1PJL * http://www.page.sannet.ne.jp/kenjia/index.html * http://mbed.org/users/kenjiArai/ - * Created: July 14th, 2014 - * Revised: December 12th, 2015 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, - * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE - * AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * Created: July 14th, 2014 + * Revised: August 23rd, 2017 */ #include "LIS3DH.h" LIS3DH::LIS3DH (PinName p_sda, PinName p_scl, - uint8_t addr, uint8_t data_rate, uint8_t fullscale) : _i2c(p_sda, p_scl) + uint8_t addr, uint8_t data_rate, uint8_t fullscale) + : _i2c_p(new I2C(p_sda, p_scl)), _i2c(*_i2c_p) { _i2c.frequency(400000); initialize (addr, data_rate, fullscale); } -LIS3DH::LIS3DH (PinName p_sda, PinName p_scl, uint8_t addr) : _i2c(p_sda, p_scl) +LIS3DH::LIS3DH (PinName p_sda, PinName p_scl, uint8_t addr) + : _i2c_p(new I2C(p_sda, p_scl)), _i2c(*_i2c_p) { _i2c.frequency(400000); initialize (addr, LIS3DH_DR_NR_LP_50HZ, LIS3DH_FS_8G); } LIS3DH::LIS3DH (I2C& p_i2c, - uint8_t addr, uint8_t data_rate, uint8_t fullscale) : _i2c(p_i2c) + uint8_t addr, uint8_t data_rate, uint8_t fullscale) + : _i2c(p_i2c) { _i2c.frequency(400000); initialize (addr, data_rate, fullscale); } -LIS3DH::LIS3DH (I2C& p_i2c, uint8_t addr) : _i2c(p_i2c) +LIS3DH::LIS3DH (I2C& p_i2c, uint8_t addr) + : _i2c(p_i2c) { _i2c.frequency(400000); initialize (addr, LIS3DH_DR_NR_LP_50HZ, LIS3DH_FS_8G); @@ -190,3 +188,5 @@ _i2c.write(acc_addr, dt, 2, false); } } + +