LIS3DH / STMicroelectronics / MEMS motion sensor, 3-axis accelerometer library
Dependents: GR-PEACH_test_wo_rtos GR-PEACH_test_on_rtos_works_well Skywire_Demo_3 Skywire_Kinetis_K64_demo ... more
Revision 8:0999d25ed7bc, committed 2017-08-23
- Comitter:
- kenjiArai
- Date:
- Wed Aug 23 09:26:06 2017 +0000
- Parent:
- 7:50ac3372def2
- Commit message:
- countermeasure for NonCopyable
Changed in this revision
LIS3DH.cpp | Show annotated file Show diff for this revision Revisions of this file |
LIS3DH.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 50ac3372def2 -r 0999d25ed7bc LIS3DH.cpp --- 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); } } + +
diff -r 50ac3372def2 -r 0999d25ed7bc LIS3DH.h --- a/LIS3DH.h Sat Dec 12 06:06:43 2015 +0000 +++ b/LIS3DH.h Wed Aug 23 09:26:06 2017 +0000 @@ -3,17 +3,11 @@ * 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 */ #ifndef LIS3DH_H @@ -234,7 +228,8 @@ void initialize(uint8_t, uint8_t, uint8_t); void read_reg_data(char *data); - I2C _i2c; + I2C *_i2c_p; + I2C &_i2c; private: #if OLD_REV @@ -249,3 +244,4 @@ }; #endif // LIS3DH_H +