summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammed Habibulla <moch@google.com>2016-07-15 20:44:52 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-07-15 20:44:52 +0000
commit94b0add192f544ef43d3a9b1c3e7f223dd8f35fd (patch)
treed1c9bce90c2dd04239da9a4f45b96088fd2c0f46
parentcb9e0b2f53f8150f8a9786ffe6ffe7d622e247fe (diff)
parentc5138e9c8d776e9c7a12d67945cebc674377297d (diff)
downloadintel-94b0add192f544ef43d3a9b1c3e7f223dd8f35fd.tar.gz
Revert \"libupm: sync with upstream (SHA1: 1849e22)\"
am: c5138e9c8d Change-Id: I9a580048d451c0186886026a89d44abee9771c08
-rw-r--r--peripheral/libupm/.travis.yml47
-rw-r--r--peripheral/libupm/Android.mk21
-rw-r--r--peripheral/libupm/CMakeLists.txt81
-rw-r--r--peripheral/libupm/README.md47
-rw-r--r--peripheral/libupm/cmake/modules/FindNode.cmake70
-rw-r--r--peripheral/libupm/docs/apichanges.md15
-rw-r--r--peripheral/libupm/docs/changelog.md55
-rw-r--r--peripheral/libupm/docs/images/apa102.jpgbin73623 -> 0 bytes
-rw-r--r--peripheral/libupm/docs/max31855.md6
-rw-r--r--peripheral/libupm/docs/porting.md6
-rw-r--r--peripheral/libupm/doxy/Doxyfile.in5
-rw-r--r--peripheral/libupm/doxy/samples.mapping.txt2
-rw-r--r--peripheral/libupm/examples/c++/CMakeLists.txt45
-rw-r--r--peripheral/libupm/examples/c++/a110x-intr.cxx2
-rw-r--r--peripheral/libupm/examples/c++/a110x.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ad8232.cxx2
-rw-r--r--peripheral/libupm/examples/c++/adafruitms1438-stepper.cxx2
-rw-r--r--peripheral/libupm/examples/c++/adafruitms1438.cxx2
-rw-r--r--peripheral/libupm/examples/c++/adafruitss.cxx2
-rw-r--r--peripheral/libupm/examples/c++/adc-sensor.cxx80
-rw-r--r--peripheral/libupm/examples/c++/adc121c021.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ads1x15.cxx8
-rw-r--r--peripheral/libupm/examples/c++/adxl335.cxx2
-rw-r--r--peripheral/libupm/examples/c++/adxl345.cxx2
-rw-r--r--peripheral/libupm/examples/c++/adxrs610.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ak8975.cxx2
-rw-r--r--peripheral/libupm/examples/c++/am2315.cxx2
-rw-r--r--peripheral/libupm/examples/c++/apa102.cxx51
-rw-r--r--peripheral/libupm/examples/c++/apds9002.cxx2
-rw-r--r--peripheral/libupm/examples/c++/apds9930.cxx2
-rw-r--r--peripheral/libupm/examples/c++/at42qt1070.cxx2
-rw-r--r--peripheral/libupm/examples/c++/biss0001.cxx2
-rw-r--r--peripheral/libupm/examples/c++/bma220.cxx2
-rw-r--r--peripheral/libupm/examples/c++/bma250e.cxx83
-rw-r--r--peripheral/libupm/examples/c++/bmc150.cxx82
-rw-r--r--peripheral/libupm/examples/c++/bme280.cxx78
-rw-r--r--peripheral/libupm/examples/c++/bmg160.cxx83
-rw-r--r--peripheral/libupm/examples/c++/bmi055.cxx82
-rw-r--r--peripheral/libupm/examples/c++/bmi160.cxx82
-rw-r--r--peripheral/libupm/examples/c++/bmm150.cxx78
-rw-r--r--peripheral/libupm/examples/c++/bmp280.cxx77
-rw-r--r--peripheral/libupm/examples/c++/bmpx8x.cxx2
-rw-r--r--peripheral/libupm/examples/c++/bmx055.cxx89
-rw-r--r--peripheral/libupm/examples/c++/bno055.cxx129
-rw-r--r--peripheral/libupm/examples/c++/buzzer-sound.cxx2
-rw-r--r--peripheral/libupm/examples/c++/cjq4435.cxx2
-rw-r--r--peripheral/libupm/examples/c++/co2-sensor.cxx71
-rw-r--r--peripheral/libupm/examples/c++/curieimu.cxx81
-rw-r--r--peripheral/libupm/examples/c++/cwlsxxa.cxx82
-rw-r--r--peripheral/libupm/examples/c++/dfrph.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ds1307.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ds1808lc.cxx51
-rw-r--r--peripheral/libupm/examples/c++/ds18b20.cxx81
-rw-r--r--peripheral/libupm/examples/c++/ds2413.cxx59
-rw-r--r--peripheral/libupm/examples/c++/e50hx.cxx112
-rw-r--r--peripheral/libupm/examples/c++/eboled.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ecs1030.cxx2
-rw-r--r--peripheral/libupm/examples/c++/enc03r.cxx2
-rw-r--r--peripheral/libupm/examples/c++/es08a.cxx2
-rw-r--r--peripheral/libupm/examples/c++/flex.cxx2
-rw-r--r--peripheral/libupm/examples/c++/gp2y0a.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovebutton.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovecircularled.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovecollision.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveehr.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveeldriver.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveelectromagnet.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveemg.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovegprs.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovegsr.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveled-multi.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveled.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveledbar.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovelight.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovelinefinder.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovemd-stepper.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovemd.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovemoisture.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveo2.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groverelay.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groverotary.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovescam.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveslide.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovespeaker.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovetemp.cxx2
-rw-r--r--peripheral/libupm/examples/c++/groveultrasonic.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovevdiv.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovewater.cxx2
-rw-r--r--peripheral/libupm/examples/c++/grovewfs.cxx2
-rw-r--r--peripheral/libupm/examples/c++/guvas12d.cxx2
-rw-r--r--peripheral/libupm/examples/c++/h3lis331dl.cxx2
-rw-r--r--peripheral/libupm/examples/c++/h803x.cxx149
-rw-r--r--peripheral/libupm/examples/c++/hcsr04.cxx2
-rw-r--r--peripheral/libupm/examples/c++/hdxxvxta.cxx2
-rw-r--r--peripheral/libupm/examples/c++/hlg150h.cxx51
-rw-r--r--peripheral/libupm/examples/c++/hm11.cxx2
-rw-r--r--peripheral/libupm/examples/c++/hmc5883l.cxx2
-rw-r--r--peripheral/libupm/examples/c++/hmtrp.cxx4
-rw-r--r--peripheral/libupm/examples/c++/hp20x.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ht9170.cxx2
-rw-r--r--peripheral/libupm/examples/c++/htu21d.cxx2
-rw-r--r--peripheral/libupm/examples/c++/humidity-sensor.cxx83
-rw-r--r--peripheral/libupm/examples/c++/hwxpxx.cxx2
-rw-r--r--peripheral/libupm/examples/c++/hx711.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ili9341.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ina132.cxx2
-rw-r--r--peripheral/libupm/examples/c++/isd1820.cxx2
-rw-r--r--peripheral/libupm/examples/c++/itg3200.cxx2
-rw-r--r--peripheral/libupm/examples/c++/jhd1313m1-lcd.cxx2
-rw-r--r--peripheral/libupm/examples/c++/joystick12.cxx2
-rw-r--r--peripheral/libupm/examples/c++/kxcjk1013.cxx14
-rw-r--r--peripheral/libupm/examples/c++/l298-stepper.cxx2
-rw-r--r--peripheral/libupm/examples/c++/l298.cxx2
-rw-r--r--peripheral/libupm/examples/c++/l3gd20.cxx79
-rw-r--r--peripheral/libupm/examples/c++/lcm1602-i2c.cxx2
-rw-r--r--peripheral/libupm/examples/c++/lcm1602-parallel.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ldt0028.cxx2
-rw-r--r--peripheral/libupm/examples/c++/light-controller.cxx98
-rw-r--r--peripheral/libupm/examples/c++/light-sensor.cxx78
-rw-r--r--peripheral/libupm/examples/c++/lm35.cxx2
-rw-r--r--peripheral/libupm/examples/c++/lol.cxx2
-rw-r--r--peripheral/libupm/examples/c++/loudness.cxx2
-rw-r--r--peripheral/libupm/examples/c++/lp8860.cxx52
-rw-r--r--peripheral/libupm/examples/c++/lpd8806.cxx2
-rw-r--r--peripheral/libupm/examples/c++/lsm303.cxx2
-rw-r--r--peripheral/libupm/examples/c++/lsm9ds0.cxx2
-rw-r--r--peripheral/libupm/examples/c++/m24lr64e.cxx2
-rw-r--r--peripheral/libupm/examples/c++/max31723.cxx2
-rw-r--r--peripheral/libupm/examples/c++/max31855.cxx2
-rw-r--r--peripheral/libupm/examples/c++/max44000.cxx2
-rw-r--r--peripheral/libupm/examples/c++/max44009.cxx46
-rw-r--r--peripheral/libupm/examples/c++/max5487.cxx2
-rw-r--r--peripheral/libupm/examples/c++/maxds3231m.cxx2
-rw-r--r--peripheral/libupm/examples/c++/maxsonarez.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mcp9808.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mg811.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mhz16.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mic.cxx2
-rw-r--r--peripheral/libupm/examples/c++/micsv89.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mlx90614.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mma7455.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mma7660.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mpl3115a2.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mpr121.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mpu60x0.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mpu9150.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mpu9250.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq2.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq3.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq303a.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq4.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq5.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq6.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq7.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq8.cxx2
-rw-r--r--peripheral/libupm/examples/c++/mq9.cxx2
-rw-r--r--peripheral/libupm/examples/c++/nlgpio16.cxx2
-rw-r--r--peripheral/libupm/examples/c++/nrf24l01-broadcast.cxx2
-rw-r--r--peripheral/libupm/examples/c++/nrf24l01-receiver.cxx2
-rw-r--r--peripheral/libupm/examples/c++/nrf24l01-transmitter.cxx2
-rw-r--r--peripheral/libupm/examples/c++/nrf8001-broadcast.cxx4
-rw-r--r--peripheral/libupm/examples/c++/nrf8001-broadcast.h (renamed from peripheral/libupm/examples/c++/nrf8001-broadcast.hpp)0
-rw-r--r--peripheral/libupm/examples/c++/nrf8001-helloworld.cxx4
-rw-r--r--peripheral/libupm/examples/c++/nrf8001-helloworld.h (renamed from peripheral/libupm/examples/c++/nrf8001-helloworld.hpp)0
-rw-r--r--peripheral/libupm/examples/c++/nunchuck.cxx2
-rw-r--r--peripheral/libupm/examples/c++/otp538u.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ozw.cxx2
-rw-r--r--peripheral/libupm/examples/c++/pca9685.cxx2
-rw-r--r--peripheral/libupm/examples/c++/pn532-writeurl.cxx2
-rw-r--r--peripheral/libupm/examples/c++/pn532.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ppd42ns.cxx2
-rw-r--r--peripheral/libupm/examples/c++/pressure-sensor.cxx81
-rw-r--r--peripheral/libupm/examples/c++/pulsensor.cxx2
-rw-r--r--peripheral/libupm/examples/c++/rfr359f.cxx2
-rw-r--r--peripheral/libupm/examples/c++/rgbringcoder.cxx2
-rw-r--r--peripheral/libupm/examples/c++/rhusb.cxx2
-rw-r--r--peripheral/libupm/examples/c++/rotaryencoder.cxx2
-rw-r--r--peripheral/libupm/examples/c++/rpr220-intr.cxx2
-rw-r--r--peripheral/libupm/examples/c++/rpr220.cxx2
-rw-r--r--peripheral/libupm/examples/c++/sainsmartks.cxx2
-rw-r--r--peripheral/libupm/examples/c++/si1132.cxx46
-rw-r--r--peripheral/libupm/examples/c++/si114x.cxx2
-rw-r--r--peripheral/libupm/examples/c++/si7005.cxx51
-rw-r--r--peripheral/libupm/examples/c++/sm130.cxx2
-rw-r--r--peripheral/libupm/examples/c++/smartdrive.cxx75
-rw-r--r--peripheral/libupm/examples/c++/ssd1306-oled.cxx4
-rw-r--r--peripheral/libupm/examples/c++/ssd1308-oled.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ssd1327-oled.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ssd1351.cxx2
-rw-r--r--peripheral/libupm/examples/c++/st7735.cxx2
-rw-r--r--peripheral/libupm/examples/c++/stepmotor.cxx2
-rw-r--r--peripheral/libupm/examples/c++/sx1276-fsk.cxx2
-rw-r--r--peripheral/libupm/examples/c++/sx1276-lora.cxx2
-rw-r--r--peripheral/libupm/examples/c++/sx6119.cxx2
-rw-r--r--peripheral/libupm/examples/c++/t3311.cxx2
-rw-r--r--peripheral/libupm/examples/c++/t6713.cxx48
-rw-r--r--peripheral/libupm/examples/c++/t8100.cxx117
-rw-r--r--peripheral/libupm/examples/c++/ta12200.cxx2
-rw-r--r--peripheral/libupm/examples/c++/tb7300.cxx124
-rw-r--r--peripheral/libupm/examples/c++/tcs3414cs.cxx2
-rw-r--r--peripheral/libupm/examples/c++/teams.cxx84
-rw-r--r--peripheral/libupm/examples/c++/temperature-sensor.cxx90
-rw-r--r--peripheral/libupm/examples/c++/tex00.cxx91
-rw-r--r--peripheral/libupm/examples/c++/th02.cxx2
-rw-r--r--peripheral/libupm/examples/c++/tm1637.cxx2
-rw-r--r--peripheral/libupm/examples/c++/tp401.cxx2
-rw-r--r--peripheral/libupm/examples/c++/tsl2561.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ttp223.cxx2
-rw-r--r--peripheral/libupm/examples/c++/ublox6.cxx4
-rw-r--r--peripheral/libupm/examples/c++/uln200xa.cxx2
-rw-r--r--peripheral/libupm/examples/c++/urm37-uart.cxx2
-rw-r--r--peripheral/libupm/examples/c++/urm37.cxx2
-rw-r--r--peripheral/libupm/examples/c++/vcap.cxx70
-rw-r--r--peripheral/libupm/examples/c++/waterlevel.cxx2
-rw-r--r--peripheral/libupm/examples/c++/wheelencoder.cxx2
-rw-r--r--peripheral/libupm/examples/c++/wt5001.cxx2
-rw-r--r--peripheral/libupm/examples/c++/xbee.cxx2
-rw-r--r--peripheral/libupm/examples/c++/yg1006.cxx2
-rw-r--r--peripheral/libupm/examples/c++/zfm20-register.cxx2
-rw-r--r--peripheral/libupm/examples/c++/zfm20.cxx2
-rw-r--r--peripheral/libupm/examples/java/AM2315Example.java66
-rw-r--r--peripheral/libupm/examples/java/APA102Sample.java44
-rw-r--r--peripheral/libupm/examples/java/Ad8232Example.java14
-rw-r--r--peripheral/libupm/examples/java/Apds9002.java2
-rw-r--r--peripheral/libupm/examples/java/BMA250E_Example.java64
-rw-r--r--peripheral/libupm/examples/java/BMC150_Example.java61
-rw-r--r--peripheral/libupm/examples/java/BME280_Example.java69
-rw-r--r--peripheral/libupm/examples/java/BMG160_Example.java64
-rw-r--r--peripheral/libupm/examples/java/BMI055_Example.java61
-rw-r--r--peripheral/libupm/examples/java/BMI160_Example.java78
-rw-r--r--peripheral/libupm/examples/java/BMM150_Example.java58
-rw-r--r--peripheral/libupm/examples/java/BMP280_Example.java65
-rw-r--r--peripheral/libupm/examples/java/BMX055_Example.java69
-rw-r--r--peripheral/libupm/examples/java/BNO055_Example.java99
-rw-r--r--peripheral/libupm/examples/java/CMakeLists.txt49
-rw-r--r--peripheral/libupm/examples/java/CWLSXXA_Example.java62
-rw-r--r--peripheral/libupm/examples/java/E50HX_Example.java91
-rw-r--r--peripheral/libupm/examples/java/ECS1030Example.java52
-rw-r--r--peripheral/libupm/examples/java/Gp2y0aExample.java2
-rw-r--r--peripheral/libupm/examples/java/GroveEmg.java2
-rw-r--r--peripheral/libupm/examples/java/GroveGsr.java2
-rw-r--r--peripheral/libupm/examples/java/GroveO2Example.java2
-rw-r--r--peripheral/libupm/examples/java/H803X_Example.java123
-rw-r--r--peripheral/libupm/examples/java/HP20xExample.java2
-rw-r--r--peripheral/libupm/examples/java/MAX31855Example.java56
-rw-r--r--peripheral/libupm/examples/java/MAX5487Example.java71
-rw-r--r--peripheral/libupm/examples/java/MAXds3231mExample.java79
-rw-r--r--peripheral/libupm/examples/java/SM130Example.java69
-rw-r--r--peripheral/libupm/examples/java/T8100_Example.java97
-rw-r--r--peripheral/libupm/examples/java/TB7300_Example.java99
-rw-r--r--peripheral/libupm/examples/java/TEAMS_Example.java64
-rw-r--r--peripheral/libupm/examples/java/TEX00_Example.java71
-rw-r--r--peripheral/libupm/examples/java/Th02Example.java14
-rw-r--r--peripheral/libupm/examples/java/Tsl2561.java61
-rw-r--r--peripheral/libupm/examples/java/VCAP_Example.java60
-rw-r--r--peripheral/libupm/examples/java/WaterLevelSensor.java2
-rw-r--r--peripheral/libupm/examples/javascript/apa102.js44
-rw-r--r--peripheral/libupm/examples/javascript/bma250e.js72
-rw-r--r--peripheral/libupm/examples/javascript/bmc150.js69
-rw-r--r--peripheral/libupm/examples/javascript/bme280.js71
-rw-r--r--peripheral/libupm/examples/javascript/bmg160.js72
-rw-r--r--peripheral/libupm/examples/javascript/bmi055.js69
-rw-r--r--peripheral/libupm/examples/javascript/bmi160.js71
-rw-r--r--peripheral/libupm/examples/javascript/bmm150.js65
-rw-r--r--peripheral/libupm/examples/javascript/bmp280.js67
-rw-r--r--peripheral/libupm/examples/javascript/bmx055.js76
-rw-r--r--peripheral/libupm/examples/javascript/bno055.js117
-rw-r--r--peripheral/libupm/examples/javascript/curieimu.js52
-rw-r--r--peripheral/libupm/examples/javascript/cwlsxxa.js66
-rw-r--r--peripheral/libupm/examples/javascript/ds18b20.js70
-rw-r--r--peripheral/libupm/examples/javascript/ds2413.js55
-rw-r--r--peripheral/libupm/examples/javascript/e50hx.js101
-rw-r--r--peripheral/libupm/examples/javascript/h803x.js115
-rw-r--r--peripheral/libupm/examples/javascript/hmtrp.js2
-rw-r--r--peripheral/libupm/examples/javascript/oled_ssd1306.js2
-rw-r--r--peripheral/libupm/examples/javascript/t8100.js98
-rw-r--r--peripheral/libupm/examples/javascript/tb7300.js102
-rw-r--r--peripheral/libupm/examples/javascript/teams.js70
-rw-r--r--peripheral/libupm/examples/javascript/tex00.js77
-rw-r--r--peripheral/libupm/examples/javascript/ublox6.js2
-rw-r--r--peripheral/libupm/examples/javascript/vcap.js69
-rw-r--r--peripheral/libupm/examples/python/apa102.py48
-rw-r--r--peripheral/libupm/examples/python/bma250e.py66
-rw-r--r--peripheral/libupm/examples/python/bmc150.py65
-rw-r--r--peripheral/libupm/examples/python/bme280.py60
-rw-r--r--peripheral/libupm/examples/python/bmg160.py66
-rw-r--r--peripheral/libupm/examples/python/bmi055.py65
-rw-r--r--peripheral/libupm/examples/python/bmi160.py66
-rw-r--r--peripheral/libupm/examples/python/bmm150.py62
-rw-r--r--peripheral/libupm/examples/python/bmp280.py58
-rw-r--r--peripheral/libupm/examples/python/bmx055.py71
-rw-r--r--peripheral/libupm/examples/python/bno055.py105
-rw-r--r--peripheral/libupm/examples/python/curieimu.py56
-rw-r--r--peripheral/libupm/examples/python/cwlsxxa.py61
-rw-r--r--peripheral/libupm/examples/python/ds18b20.py64
-rw-r--r--peripheral/libupm/examples/python/ds2413.py57
-rw-r--r--peripheral/libupm/examples/python/e50hx.py95
-rw-r--r--peripheral/libupm/examples/python/h803x.py106
-rw-r--r--peripheral/libupm/examples/python/hmtrp.py2
-rw-r--r--peripheral/libupm/examples/python/t8100.py97
-rw-r--r--peripheral/libupm/examples/python/tb7300.py96
-rw-r--r--peripheral/libupm/examples/python/teams.py65
-rw-r--r--peripheral/libupm/examples/python/tex00.py65
-rw-r--r--peripheral/libupm/examples/python/ublox6.py2
-rw-r--r--peripheral/libupm/examples/python/vcap.py67
-rw-r--r--peripheral/libupm/src/CMakeLists.txt109
-rw-r--r--peripheral/libupm/src/a110x/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/a110x/a110x.cxx2
-rw-r--r--peripheral/libupm/src/a110x/a110x.h (renamed from peripheral/libupm/src/a110x/a110x.hpp)0
-rw-r--r--peripheral/libupm/src/a110x/javaupm_a110x.i4
-rw-r--r--peripheral/libupm/src/a110x/jsupm_a110x.i4
-rw-r--r--peripheral/libupm/src/a110x/pyupm_a110x.i4
-rw-r--r--peripheral/libupm/src/ad8232/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/ad8232/ad8232.cxx2
-rw-r--r--peripheral/libupm/src/ad8232/ad8232.h (renamed from peripheral/libupm/src/ad8232/ad8232.hpp)0
-rw-r--r--peripheral/libupm/src/ad8232/javaupm_ad8232.i4
-rw-r--r--peripheral/libupm/src/ad8232/jsupm_ad8232.i4
-rw-r--r--peripheral/libupm/src/ad8232/pyupm_ad8232.i4
-rw-r--r--peripheral/libupm/src/adafruitms1438/CMakeLists.txt6
-rw-r--r--peripheral/libupm/src/adafruitms1438/adafruitms1438.cxx2
-rw-r--r--peripheral/libupm/src/adafruitms1438/adafruitms1438.h (renamed from peripheral/libupm/src/adafruitms1438/adafruitms1438.hpp)2
-rw-r--r--peripheral/libupm/src/adafruitms1438/javaupm_adafruitms1438.i4
-rw-r--r--peripheral/libupm/src/adafruitms1438/jsupm_adafruitms1438.i4
-rw-r--r--peripheral/libupm/src/adafruitms1438/pyupm_adafruitms1438.i4
-rw-r--r--peripheral/libupm/src/adafruitss/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/adafruitss/adafruitss.cxx2
-rw-r--r--peripheral/libupm/src/adafruitss/adafruitss.h (renamed from peripheral/libupm/src/adafruitss/adafruitss.hpp)0
-rw-r--r--peripheral/libupm/src/adafruitss/javaupm_adafruitss.i4
-rw-r--r--peripheral/libupm/src/adafruitss/jsupm_adafruitss.i4
-rw-r--r--peripheral/libupm/src/adafruitss/pyupm_adafruitss.i4
-rw-r--r--peripheral/libupm/src/adc121c021/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/adc121c021/adc121c021.cxx14
-rw-r--r--peripheral/libupm/src/adc121c021/adc121c021.h (renamed from peripheral/libupm/src/adc121c021/adc121c021.hpp)0
-rw-r--r--peripheral/libupm/src/adc121c021/javaupm_adc121c021.i4
-rw-r--r--peripheral/libupm/src/adc121c021/jsupm_adc121c021.i4
-rw-r--r--peripheral/libupm/src/adc121c021/pyupm_adc121c021.i4
-rw-r--r--peripheral/libupm/src/adis16448/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/adis16448/adis16448.cxx2
-rw-r--r--peripheral/libupm/src/adis16448/adis16448.h (renamed from peripheral/libupm/src/adis16448/adis16448.hpp)2
-rw-r--r--peripheral/libupm/src/adis16448/javaupm_adis16448.i4
-rw-r--r--peripheral/libupm/src/adis16448/jsupm_adis16448.i4
-rw-r--r--peripheral/libupm/src/adis16448/pyupm_adis16448.i4
-rw-r--r--peripheral/libupm/src/ads1x15/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/ads1x15/ads1015.cxx68
-rw-r--r--peripheral/libupm/src/ads1x15/ads1015.h (renamed from peripheral/libupm/src/ads1x15/ads1015.hpp)56
-rw-r--r--peripheral/libupm/src/ads1x15/ads1115.cxx2
-rw-r--r--peripheral/libupm/src/ads1x15/ads1115.h (renamed from peripheral/libupm/src/ads1x15/ads1115.hpp)2
-rw-r--r--peripheral/libupm/src/ads1x15/ads1x15.cxx2
-rw-r--r--peripheral/libupm/src/ads1x15/ads1x15.h (renamed from peripheral/libupm/src/ads1x15/ads1x15.hpp)0
-rw-r--r--peripheral/libupm/src/ads1x15/javaupm_ads1x15.i12
-rw-r--r--peripheral/libupm/src/ads1x15/jsupm_ads1x15.i12
-rw-r--r--peripheral/libupm/src/ads1x15/pyupm_ads1x15.i12
-rw-r--r--peripheral/libupm/src/adxl335/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/adxl335/adxl335.cxx2
-rw-r--r--peripheral/libupm/src/adxl335/adxl335.h (renamed from peripheral/libupm/src/adxl335/adxl335.hpp)0
-rw-r--r--peripheral/libupm/src/adxl335/javaupm_adxl335.i4
-rw-r--r--peripheral/libupm/src/adxl335/jsupm_adxl335.i4
-rw-r--r--peripheral/libupm/src/adxl335/pyupm_adxl335.i4
-rw-r--r--peripheral/libupm/src/adxl345/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/adxl345/adxl345.cxx2
-rw-r--r--peripheral/libupm/src/adxl345/adxl345.h (renamed from peripheral/libupm/src/adxl345/adxl345.hpp)0
-rw-r--r--peripheral/libupm/src/adxl345/javaupm_adxl345.i4
-rw-r--r--peripheral/libupm/src/adxl345/jsupm_adxl345.i4
-rw-r--r--peripheral/libupm/src/adxl345/pyupm_adxl345.i4
-rw-r--r--peripheral/libupm/src/adxrs610/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/adxrs610/adxrs610.cxx2
-rw-r--r--peripheral/libupm/src/adxrs610/adxrs610.h (renamed from peripheral/libupm/src/adxrs610/adxrs610.hpp)2
-rw-r--r--peripheral/libupm/src/adxrs610/javaupm_adxrs610.i4
-rw-r--r--peripheral/libupm/src/adxrs610/jsupm_adxrs610.i4
-rw-r--r--peripheral/libupm/src/adxrs610/pyupm_adxrs610.i4
-rw-r--r--peripheral/libupm/src/am2315/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/am2315/am2315.cpp5
-rw-r--r--peripheral/libupm/src/am2315/am2315.h (renamed from peripheral/libupm/src/am2315/am2315.hpp)0
-rw-r--r--peripheral/libupm/src/am2315/javaupm_am2315.i4
-rw-r--r--peripheral/libupm/src/am2315/jsupm_am2315.i4
-rw-r--r--peripheral/libupm/src/am2315/pyupm_am2315.i4
-rw-r--r--peripheral/libupm/src/apa102/CMakeLists.txt5
-rw-r--r--peripheral/libupm/src/apa102/apa102.cxx166
-rw-r--r--peripheral/libupm/src/apa102/apa102.hpp143
-rw-r--r--peripheral/libupm/src/apa102/javaupm_apa102.i30
-rw-r--r--peripheral/libupm/src/apa102/jsupm_apa102.i19
-rw-r--r--peripheral/libupm/src/apa102/pyupm_apa102.i25
-rw-r--r--peripheral/libupm/src/apds9002/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/apds9002/apds9002.cxx2
-rw-r--r--peripheral/libupm/src/apds9002/apds9002.h (renamed from peripheral/libupm/src/apds9002/apds9002.hpp)0
-rw-r--r--peripheral/libupm/src/apds9002/javaupm_apds9002.i4
-rw-r--r--peripheral/libupm/src/apds9002/jsupm_apds9002.i4
-rw-r--r--peripheral/libupm/src/apds9002/pyupm_apds9002.i4
-rw-r--r--peripheral/libupm/src/apds9930/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/apds9930/apds9930.cxx5
-rw-r--r--peripheral/libupm/src/apds9930/apds9930.h (renamed from peripheral/libupm/src/apds9930/apds9930.hpp)0
-rw-r--r--peripheral/libupm/src/apds9930/javaupm_apds9930.i4
-rw-r--r--peripheral/libupm/src/apds9930/jsupm_apds9930.i4
-rw-r--r--peripheral/libupm/src/apds9930/pyupm_apds9930.i4
-rw-r--r--peripheral/libupm/src/at42qt1070/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/at42qt1070/at42qt1070.cxx14
-rw-r--r--peripheral/libupm/src/at42qt1070/at42qt1070.h (renamed from peripheral/libupm/src/at42qt1070/at42qt1070.hpp)0
-rw-r--r--peripheral/libupm/src/at42qt1070/javaupm_at42qt1070.i4
-rw-r--r--peripheral/libupm/src/at42qt1070/jsupm_at42qt1070.i4
-rw-r--r--peripheral/libupm/src/at42qt1070/pyupm_at42qt1070.i4
-rw-r--r--peripheral/libupm/src/bacnetmstp/CMakeLists.txt24
-rw-r--r--peripheral/libupm/src/bacnetmstp/bacnetmstp.cxx936
-rw-r--r--peripheral/libupm/src/bacnetmstp/bacnetmstp.hpp754
-rw-r--r--peripheral/libupm/src/bacnetmstp/bacnetutil.cxx925
-rw-r--r--peripheral/libupm/src/bacnetmstp/bacnetutil.hpp559
-rw-r--r--peripheral/libupm/src/bacnetmstp/device-client.c1026
-rw-r--r--peripheral/libupm/src/bacnetmstp/device.h465
-rw-r--r--peripheral/libupm/src/bacnetmstp/javaupm_bacnetmstp.i23
-rw-r--r--peripheral/libupm/src/bacnetmstp/jsupm_bacnetmstp.i11
-rw-r--r--peripheral/libupm/src/bacnetmstp/pyupm_bacnetmstp.i15
-rw-r--r--peripheral/libupm/src/bacnetmstp/timer.h65
-rw-r--r--peripheral/libupm/src/biss0001/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/biss0001/biss0001.cxx2
-rw-r--r--peripheral/libupm/src/biss0001/biss0001.h (renamed from peripheral/libupm/src/biss0001/biss0001.hpp)0
-rw-r--r--peripheral/libupm/src/biss0001/javaupm_biss0001.i4
-rw-r--r--peripheral/libupm/src/biss0001/jsupm_biss0001.i4
-rw-r--r--peripheral/libupm/src/biss0001/pyupm_biss0001.i4
-rw-r--r--peripheral/libupm/src/bma220/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/bma220/bma220.cxx2
-rw-r--r--peripheral/libupm/src/bma220/bma220.h (renamed from peripheral/libupm/src/bma220/bma220.hpp)0
-rw-r--r--peripheral/libupm/src/bma220/javaupm_bma220.i4
-rw-r--r--peripheral/libupm/src/bma220/jsupm_bma220.i4
-rw-r--r--peripheral/libupm/src/bma220/pyupm_bma220.i4
-rw-r--r--peripheral/libupm/src/bmi160/CMakeLists.txt5
-rw-r--r--peripheral/libupm/src/bmi160/bmi160.cxx433
-rw-r--r--peripheral/libupm/src/bmi160/bmi160.hpp251
-rw-r--r--peripheral/libupm/src/bmi160/bosch_bmi160.c20467
-rw-r--r--peripheral/libupm/src/bmi160/bosch_bmi160.h12045
-rw-r--r--peripheral/libupm/src/bmi160/javaupm_bmi160.i41
-rw-r--r--peripheral/libupm/src/bmi160/jsupm_bmi160.i10
-rw-r--r--peripheral/libupm/src/bmi160/license.txt55
-rw-r--r--peripheral/libupm/src/bmi160/pyupm_bmi160.i16
-rw-r--r--peripheral/libupm/src/bmp280/CMakeLists.txt5
-rw-r--r--peripheral/libupm/src/bmp280/bme280.cxx174
-rw-r--r--peripheral/libupm/src/bmp280/bme280.hpp215
-rw-r--r--peripheral/libupm/src/bmp280/bmp280.cxx576
-rw-r--r--peripheral/libupm/src/bmp280/bmp280.hpp490
-rw-r--r--peripheral/libupm/src/bmp280/javaupm_bmp280.i28
-rw-r--r--peripheral/libupm/src/bmp280/jsupm_bmp280.i13
-rw-r--r--peripheral/libupm/src/bmp280/pyupm_bmp280.i23
-rw-r--r--peripheral/libupm/src/bmpx8x/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/bmpx8x/bmpx8x.cxx21
-rw-r--r--peripheral/libupm/src/bmpx8x/bmpx8x.h (renamed from peripheral/libupm/src/bmpx8x/bmpx8x.hpp)24
-rw-r--r--peripheral/libupm/src/bmpx8x/javaupm_bmpx8x.i4
-rw-r--r--peripheral/libupm/src/bmpx8x/jsupm_bmpx8x.i4
-rw-r--r--peripheral/libupm/src/bmpx8x/pyupm_bmpx8x.i4
-rw-r--r--peripheral/libupm/src/bmx055/CMakeLists.txt5
-rw-r--r--peripheral/libupm/src/bmx055/bma250e.cxx735
-rw-r--r--peripheral/libupm/src/bmx055/bma250e.hpp1461
-rw-r--r--peripheral/libupm/src/bmx055/bmc150.cxx120
-rw-r--r--peripheral/libupm/src/bmx055/bmc150.hpp196
-rw-r--r--peripheral/libupm/src/bmx055/bmg160.cxx581
-rw-r--r--peripheral/libupm/src/bmx055/bmg160.hpp1223
-rw-r--r--peripheral/libupm/src/bmx055/bmi055.cxx122
-rw-r--r--peripheral/libupm/src/bmx055/bmi055.hpp193
-rw-r--r--peripheral/libupm/src/bmx055/bmm150.cxx675
-rw-r--r--peripheral/libupm/src/bmx055/bmm150.hpp614
-rw-r--r--peripheral/libupm/src/bmx055/bmx055.cxx158
-rw-r--r--peripheral/libupm/src/bmx055/bmx055.hpp248
-rw-r--r--peripheral/libupm/src/bmx055/javaupm_bmx055.i77
-rw-r--r--peripheral/libupm/src/bmx055/jsupm_bmx055.i37
-rw-r--r--peripheral/libupm/src/bmx055/pyupm_bmx055.i47
-rw-r--r--peripheral/libupm/src/bno055/CMakeLists.txt5
-rw-r--r--peripheral/libupm/src/bno055/bno055.cxx809
-rw-r--r--peripheral/libupm/src/bno055/bno055.hpp1508
-rw-r--r--peripheral/libupm/src/bno055/javaupm_bno055.i93
-rw-r--r--peripheral/libupm/src/bno055/jsupm_bno055.i12
-rw-r--r--peripheral/libupm/src/bno055/pyupm_bno055.i22
-rw-r--r--peripheral/libupm/src/buzzer/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/buzzer/buzzer.cxx2
-rw-r--r--peripheral/libupm/src/buzzer/buzzer.h (renamed from peripheral/libupm/src/buzzer/buzzer.hpp)16
-rw-r--r--peripheral/libupm/src/buzzer/javaupm_buzzer.i4
-rw-r--r--peripheral/libupm/src/buzzer/jsupm_buzzer.i4
-rw-r--r--peripheral/libupm/src/buzzer/pyupm_buzzer.i4
-rw-r--r--peripheral/libupm/src/cjq4435/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/cjq4435/cjq4435.cxx2
-rw-r--r--peripheral/libupm/src/cjq4435/cjq4435.h (renamed from peripheral/libupm/src/cjq4435/cjq4435.hpp)0
-rw-r--r--peripheral/libupm/src/cjq4435/javaupm_cjq4435.i4
-rw-r--r--peripheral/libupm/src/cjq4435/jsupm_cjq4435.i4
-rw-r--r--peripheral/libupm/src/cjq4435/pyupm_cjq4435.i4
-rw-r--r--peripheral/libupm/src/curieimu/CMakeLists.txt11
-rw-r--r--peripheral/libupm/src/curieimu/curieimu.cpp458
-rw-r--r--peripheral/libupm/src/curieimu/curieimu.hpp307
-rw-r--r--peripheral/libupm/src/curieimu/javaupm_curieimu.i42
-rw-r--r--peripheral/libupm/src/curieimu/jsupm_curieimu.i15
-rw-r--r--peripheral/libupm/src/curieimu/pyupm_curieimu.i21
-rw-r--r--peripheral/libupm/src/cwlsxxa/CMakeLists.txt5
-rw-r--r--peripheral/libupm/src/cwlsxxa/cwlsxxa.cxx183
-rw-r--r--peripheral/libupm/src/cwlsxxa/cwlsxxa.hpp189
-rw-r--r--peripheral/libupm/src/cwlsxxa/javaupm_cwlsxxa.i19
-rw-r--r--peripheral/libupm/src/cwlsxxa/jsupm_cwlsxxa.i10
-rw-r--r--peripheral/libupm/src/cwlsxxa/pyupm_cwlsxxa.i13
-rw-r--r--peripheral/libupm/src/dfrph/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/dfrph/dfrph.cxx2
-rw-r--r--peripheral/libupm/src/dfrph/dfrph.h (renamed from peripheral/libupm/src/dfrph/dfrph.hpp)0
-rw-r--r--peripheral/libupm/src/dfrph/javaupm_dfrph.i4
-rw-r--r--peripheral/libupm/src/dfrph/jsupm_dfrph.i4
-rw-r--r--peripheral/libupm/src/dfrph/pyupm_dfrph.i4
-rw-r--r--peripheral/libupm/src/ds1307/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/ds1307/ds1307.cxx2
-rw-r--r--peripheral/libupm/src/ds1307/ds1307.h (renamed from peripheral/libupm/src/ds1307/ds1307.hpp)0
-rw-r--r--peripheral/libupm/src/ds1307/javaupm_ds1307.i4
-rw-r--r--peripheral/libupm/src/ds1307/jsupm_ds1307.i4
-rw-r--r--peripheral/libupm/src/ds1307/pyupm_ds1307.i4
-rw-r--r--peripheral/libupm/src/ds1808lc/CMakeLists.txt6
-rw-r--r--peripheral/libupm/src/ds1808lc/ds1808lc.cxx134
-rw-r--r--peripheral/libupm/src/ds1808lc/ds1808lc.hpp80
-rw-r--r--peripheral/libupm/src/ds1808lc/javaupm_ds1808lc.i23
-rw-r--r--peripheral/libupm/src/ds1808lc/jsupm_ds1808lc.i8
-rw-r--r--peripheral/libupm/src/ds1808lc/mraa-utils.cxx73
-rw-r--r--peripheral/libupm/src/ds1808lc/mraa-utils.hpp37
-rw-r--r--peripheral/libupm/src/ds1808lc/pyupm_ds1808lc.i9
-rw-r--r--peripheral/libupm/src/ds18b20/CMakeLists.txt5
-rw-r--r--peripheral/libupm/src/ds18b20/ds18b20.cxx298
-rw-r--r--peripheral/libupm/src/ds18b20/ds18b20.hpp242
-rw-r--r--peripheral/libupm/src/ds18b20/javaupm_ds18b20.i22
-rw-r--r--peripheral/libupm/src/ds18b20/jsupm_ds18b20.i11
-rw-r--r--peripheral/libupm/src/ds18b20/pyupm_ds18b20.i12
-rw-r--r--peripheral/libupm/src/ds2413/CMakeLists.txt5
-rw-r--r--peripheral/libupm/src/ds2413/ds2413.cxx165
-rw-r--r--peripheral/libupm/src/ds2413/ds2413.hpp175
-rw-r--r--peripheral/libupm/src/ds2413/javaupm_ds2413.i22
-rw-r--r--peripheral/libupm/src/ds2413/jsupm_ds2413.i11
-rw-r--r--peripheral/libupm/src/ds2413/pyupm_ds2413.i12
-rw-r--r--peripheral/libupm/src/e50hx/CMakeLists.txt28
-rw-r--r--peripheral/libupm/src/e50hx/e50hx.cxx129
-rw-r--r--peripheral/libupm/src/e50hx/e50hx.hpp321
-rw-r--r--peripheral/libupm/src/e50hx/javaupm_e50hx.i34
-rw-r--r--peripheral/libupm/src/e50hx/jsupm_e50hx.i10
-rw-r--r--peripheral/libupm/src/e50hx/pyupm_e50hx.i14
-rw-r--r--peripheral/libupm/src/ecs1030/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/ecs1030/ecs1030.cxx6
-rw-r--r--peripheral/libupm/src/ecs1030/ecs1030.h (renamed from peripheral/libupm/src/ecs1030/ecs1030.hpp)0
-rw-r--r--peripheral/libupm/src/ecs1030/javaupm_ecs1030.i4
-rw-r--r--peripheral/libupm/src/ecs1030/jsupm_ecs1030.i4
-rw-r--r--peripheral/libupm/src/ecs1030/pyupm_ecs1030.i4
-rw-r--r--peripheral/libupm/src/enc03r/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/enc03r/enc03r.cxx9
-rw-r--r--peripheral/libupm/src/enc03r/enc03r.h (renamed from peripheral/libupm/src/enc03r/enc03r.hpp)0
-rw-r--r--peripheral/libupm/src/enc03r/javaupm_enc03r.i4
-rw-r--r--peripheral/libupm/src/enc03r/jsupm_enc03r.i4
-rw-r--r--peripheral/libupm/src/enc03r/pyupm_enc03r.i4
-rw-r--r--peripheral/libupm/src/flex/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/flex/flex.cxx2
-rw-r--r--peripheral/libupm/src/flex/flex.h (renamed from peripheral/libupm/src/flex/flex.hpp)0
-rw-r--r--peripheral/libupm/src/flex/javaupm_flex.i4
-rw-r--r--peripheral/libupm/src/flex/jsupm_flex.i4
-rw-r--r--peripheral/libupm/src/flex/pyupm_flex.i4
-rw-r--r--peripheral/libupm/src/gas/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/gas/gas.cxx2
-rw-r--r--peripheral/libupm/src/gas/gas.h (renamed from peripheral/libupm/src/gas/gas.hpp)0
-rw-r--r--peripheral/libupm/src/gas/javaupm_gas.i40
-rw-r--r--peripheral/libupm/src/gas/jsupm_gas.i40
-rw-r--r--peripheral/libupm/src/gas/mq2.cxx2
-rw-r--r--peripheral/libupm/src/gas/mq2.h (renamed from peripheral/libupm/src/gas/mq2.hpp)2
-rw-r--r--peripheral/libupm/src/gas/mq3.cxx2
-rw-r--r--peripheral/libupm/src/gas/mq3.h (renamed from peripheral/libupm/src/gas/mq3.hpp)2
-rw-r--r--peripheral/libupm/src/gas/mq4.cxx2
-rw-r--r--peripheral/libupm/src/gas/mq4.h (renamed from peripheral/libupm/src/gas/mq4.hpp)2
-rw-r--r--peripheral/libupm/src/gas/mq5.cxx2
-rw-r--r--peripheral/libupm/src/gas/mq5.h (renamed from peripheral/libupm/src/gas/mq5.hpp)2
-rw-r--r--peripheral/libupm/src/gas/mq6.cxx2
-rw-r--r--peripheral/libupm/src/gas/mq6.h (renamed from peripheral/libupm/src/gas/mq6.hpp)2
-rw-r--r--peripheral/libupm/src/gas/mq7.cxx2
-rw-r--r--peripheral/libupm/src/gas/mq7.h (renamed from peripheral/libupm/src/gas/mq7.hpp)2
-rw-r--r--peripheral/libupm/src/gas/mq8.cxx2
-rw-r--r--peripheral/libupm/src/gas/mq8.h (renamed from peripheral/libupm/src/gas/mq8.hpp)2
-rw-r--r--peripheral/libupm/src/gas/mq9.cxx2
-rw-r--r--peripheral/libupm/src/gas/mq9.h (renamed from peripheral/libupm/src/gas/mq9.hpp)2
-rw-r--r--peripheral/libupm/src/gas/pyupm_gas.i40
-rw-r--r--peripheral/libupm/src/gas/tp401.cxx2
-rw-r--r--peripheral/libupm/src/gas/tp401.h (renamed from peripheral/libupm/src/gas/tp401.hpp)2
-rw-r--r--peripheral/libupm/src/gp2y0a/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/gp2y0a/gp2y0a.cxx4
-rw-r--r--peripheral/libupm/src/gp2y0a/gp2y0a.h (renamed from peripheral/libupm/src/gp2y0a/gp2y0a.hpp)0
-rw-r--r--peripheral/libupm/src/gp2y0a/javaupm_gp2y0a.i4
-rw-r--r--peripheral/libupm/src/gp2y0a/jsupm_gp2y0a.i4
-rw-r--r--peripheral/libupm/src/gp2y0a/pyupm_gp2y0a.i4
-rw-r--r--peripheral/libupm/src/grove/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/grove/grove.cxx11
-rw-r--r--peripheral/libupm/src/grove/grove.h (renamed from peripheral/libupm/src/grove/grove.hpp)5
-rw-r--r--peripheral/libupm/src/grove/grovebutton.h (renamed from peripheral/libupm/src/grove/grovebutton.hpp)0
-rw-r--r--peripheral/libupm/src/grove/groveled.h (renamed from peripheral/libupm/src/grove/groveled.hpp)0
-rw-r--r--peripheral/libupm/src/grove/grovelight.h (renamed from peripheral/libupm/src/grove/grovelight.hpp)0
-rw-r--r--peripheral/libupm/src/grove/groverelay.h (renamed from peripheral/libupm/src/grove/groverelay.hpp)0
-rw-r--r--peripheral/libupm/src/grove/groverotary.h (renamed from peripheral/libupm/src/grove/groverotary.hpp)0
-rw-r--r--peripheral/libupm/src/grove/groveslide.h (renamed from peripheral/libupm/src/grove/groveslide.hpp)0
-rw-r--r--peripheral/libupm/src/grove/grovetemp.h (renamed from peripheral/libupm/src/grove/grovetemp.hpp)0
-rw-r--r--peripheral/libupm/src/grove/javaupm_grove.i4
-rw-r--r--peripheral/libupm/src/grove/jsupm_grove.i4
-rw-r--r--peripheral/libupm/src/grove/pyupm_grove.i4
-rw-r--r--peripheral/libupm/src/grovecollision/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/grovecollision/grovecollision.cxx2
-rw-r--r--peripheral/libupm/src/grovecollision/grovecollision.h (renamed from peripheral/libupm/src/grovecollision/grovecollision.hpp)0
-rw-r--r--peripheral/libupm/src/grovecollision/javaupm_grovecollision.i4
-rw-r--r--peripheral/libupm/src/grovecollision/jsupm_grovecollision.i4
-rw-r--r--peripheral/libupm/src/grovecollision/pyupm_grovecollision.i4
-rw-r--r--peripheral/libupm/src/groveehr/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/groveehr/groveehr.cxx2
-rw-r--r--peripheral/libupm/src/groveehr/groveehr.h (renamed from peripheral/libupm/src/groveehr/groveehr.hpp)0
-rw-r--r--peripheral/libupm/src/groveehr/javaupm_groveehr.i4
-rw-r--r--peripheral/libupm/src/groveehr/jsupm_groveehr.i4
-rw-r--r--peripheral/libupm/src/groveehr/pyupm_groveehr.i4
-rw-r--r--peripheral/libupm/src/groveeldriver/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/groveeldriver/groveeldriver.cxx2
-rw-r--r--peripheral/libupm/src/groveeldriver/groveeldriver.h (renamed from peripheral/libupm/src/groveeldriver/groveeldriver.hpp)0
-rw-r--r--peripheral/libupm/src/groveeldriver/javaupm_groveeldriver.i4
-rw-r--r--peripheral/libupm/src/groveeldriver/jsupm_groveeldriver.i4
-rw-r--r--peripheral/libupm/src/groveeldriver/pyupm_groveeldriver.i4
-rw-r--r--peripheral/libupm/src/groveelectromagnet/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/groveelectromagnet/groveelectromagnet.cxx2
-rw-r--r--peripheral/libupm/src/groveelectromagnet/groveelectromagnet.h (renamed from peripheral/libupm/src/groveelectromagnet/groveelectromagnet.hpp)0
-rw-r--r--peripheral/libupm/src/groveelectromagnet/javaupm_groveelectromagnet.i4
-rw-r--r--peripheral/libupm/src/groveelectromagnet/jsupm_groveelectromagnet.i4
-rw-r--r--peripheral/libupm/src/groveelectromagnet/pyupm_groveelectromagnet.i4
-rw-r--r--peripheral/libupm/src/groveemg/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/groveemg/groveemg.cxx4
-rw-r--r--peripheral/libupm/src/groveemg/groveemg.h (renamed from peripheral/libupm/src/groveemg/groveemg.hpp)0
-rw-r--r--peripheral/libupm/src/groveemg/javaupm_groveemg.i4
-rw-r--r--peripheral/libupm/src/groveemg/jsupm_groveemg.i4
-rw-r--r--peripheral/libupm/src/groveemg/pyupm_groveemg.i4
-rw-r--r--peripheral/libupm/src/grovegprs/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/grovegprs/grovegprs.cxx2
-rw-r--r--peripheral/libupm/src/grovegprs/grovegprs.h (renamed from peripheral/libupm/src/grovegprs/grovegprs.hpp)0
-rw-r--r--peripheral/libupm/src/grovegprs/javaupm_grovegprs.i4
-rw-r--r--peripheral/libupm/src/grovegprs/jsupm_grovegprs.i4
-rw-r--r--peripheral/libupm/src/grovegprs/pyupm_grovegprs.i4
-rw-r--r--peripheral/libupm/src/grovegsr/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/grovegsr/grovegsr.cxx4
-rw-r--r--peripheral/libupm/src/grovegsr/grovegsr.h (renamed from peripheral/libupm/src/grovegsr/grovegsr.hpp)0
-rw-r--r--peripheral/libupm/src/grovegsr/javaupm_grovegsr.i4
-rw-r--r--peripheral/libupm/src/grovegsr/jsupm_grovegsr.i4
-rw-r--r--peripheral/libupm/src/grovegsr/pyupm_grovegsr.i4
-rw-r--r--peripheral/libupm/src/grovelinefinder/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/grovelinefinder/grovelinefinder.cxx2
-rw-r--r--peripheral/libupm/src/grovelinefinder/grovelinefinder.h (renamed from peripheral/libupm/src/grovelinefinder/grovelinefinder.hpp)0
-rw-r--r--peripheral/libupm/src/grovelinefinder/javaupm_grovelinefinder.i4
-rw-r--r--peripheral/libupm/src/grovelinefinder/jsupm_grovelinefinder.i4
-rw-r--r--peripheral/libupm/src/grovelinefinder/pyupm_grovelinefinder.i4
-rw-r--r--peripheral/libupm/src/groveloudness/groveloudness.cxx2
-rw-r--r--peripheral/libupm/src/grovemd/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/grovemd/grovemd.cxx2
-rw-r--r--peripheral/libupm/src/grovemd/grovemd.h (renamed from peripheral/libupm/src/grovemd/grovemd.hpp)0
-rw-r--r--peripheral/libupm/src/grovemd/javaupm_grovemd.i4
-rw-r--r--peripheral/libupm/src/grovemd/jsupm_grovemd.i4
-rw-r--r--peripheral/libupm/src/grovemd/pyupm_grovemd.i4
-rw-r--r--peripheral/libupm/src/grovemoisture/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/grovemoisture/grovemoisture.cxx2
-rw-r--r--peripheral/libupm/src/grovemoisture/grovemoisture.h (renamed from peripheral/libupm/src/grovemoisture/grovemoisture.hpp)0
-rw-r--r--peripheral/libupm/src/grovemoisture/javaupm_grovemoisture.i4
-rw-r--r--peripheral/libupm/src/grovemoisture/jsupm_grovemoisture.i4
-rw-r--r--peripheral/libupm/src/grovemoisture/pyupm_grovemoisture.i4
-rw-r--r--peripheral/libupm/src/groveo2/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/groveo2/groveo2.cxx3
-rw-r--r--peripheral/libupm/src/groveo2/groveo2.h (renamed from peripheral/libupm/src/groveo2/groveo2.hpp)0
-rw-r--r--peripheral/libupm/src/groveo2/javaupm_groveo2.i4
-rw-r--r--peripheral/libupm/src/groveo2/jsupm_groveo2.i4
-rw-r--r--peripheral/libupm/src/groveo2/pyupm_groveo2.i4
-rw-r--r--peripheral/libupm/src/grovescam/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/grovescam/grovescam.cxx83
-rw-r--r--peripheral/libupm/src/grovescam/grovescam.h (renamed from peripheral/libupm/src/grovescam/grovescam.hpp)0
-rw-r--r--peripheral/libupm/src/grovescam/javaupm_grovescam.i4
-rw-r--r--peripheral/libupm/src/grovescam/jsupm_grovescam.i4
-rw-r--r--peripheral/libupm/src/grovescam/pyupm_grovescam.i4
-rw-r--r--peripheral/libupm/src/grovespeaker/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/grovespeaker/grovespeaker.cxx2
-rw-r--r--peripheral/libupm/src/grovespeaker/grovespeaker.h (renamed from peripheral/libupm/src/grovespeaker/grovespeaker.hpp)0
-rw-r--r--peripheral/libupm/src/grovespeaker/javaupm_grovespeaker.i4
-rw-r--r--peripheral/libupm/src/grovespeaker/jsupm_grovespeaker.i4
-rw-r--r--peripheral/libupm/src/grovespeaker/pyupm_grovespeaker.i4
-rw-r--r--peripheral/libupm/src/groveultrasonic/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/groveultrasonic/groveultrasonic.cxx2
-rw-r--r--peripheral/libupm/src/groveultrasonic/groveultrasonic.h (renamed from peripheral/libupm/src/groveultrasonic/groveultrasonic.hpp)0
-rw-r--r--peripheral/libupm/src/groveultrasonic/javaupm_groveultrasonic.i4
-rw-r--r--peripheral/libupm/src/groveultrasonic/jsupm_groveultrasonic.i4
-rw-r--r--peripheral/libupm/src/groveultrasonic/pyupm_groveultrasonic.i4
-rw-r--r--peripheral/libupm/src/grovevdiv/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/grovevdiv/grovevdiv.cxx3
-rw-r--r--peripheral/libupm/src/grovevdiv/grovevdiv.h (renamed from peripheral/libupm/src/grovevdiv/grovevdiv.hpp)0
-rw-r--r--peripheral/libupm/src/grovevdiv/javaupm_grovevdiv.i4
-rw-r--r--peripheral/libupm/src/grovevdiv/jsupm_grovevdiv.i4
-rw-r--r--peripheral/libupm/src/grovevdiv/pyupm_grovevdiv.i4
-rw-r--r--peripheral/libupm/src/grovewater/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/grovewater/grovewater.cxx2
-rw-r--r--peripheral/libupm/src/grovewater/grovewater.h (renamed from peripheral/libupm/src/grovewater/grovewater.hpp)0
-rw-r--r--peripheral/libupm/src/grovewater/javaupm_grovewater.i4
-rw-r--r--peripheral/libupm/src/grovewater/jsupm_grovewater.i4
-rw-r--r--peripheral/libupm/src/grovewater/pyupm_grovewater.i4
-rw-r--r--peripheral/libupm/src/grovewfs/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/grovewfs/grovewfs.cxx2
-rw-r--r--peripheral/libupm/src/grovewfs/grovewfs.h (renamed from peripheral/libupm/src/grovewfs/grovewfs.hpp)0
-rw-r--r--peripheral/libupm/src/grovewfs/javaupm_grovewfs.i4
-rw-r--r--peripheral/libupm/src/grovewfs/jsupm_grovewfs.i4
-rw-r--r--peripheral/libupm/src/grovewfs/pyupm_grovewfs.i4
-rw-r--r--peripheral/libupm/src/guvas12d/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/guvas12d/guvas12d.cxx3
-rw-r--r--peripheral/libupm/src/guvas12d/guvas12d.h (renamed from peripheral/libupm/src/guvas12d/guvas12d.hpp)0
-rw-r--r--peripheral/libupm/src/guvas12d/javaupm_guvas12d.i4
-rw-r--r--peripheral/libupm/src/guvas12d/jsupm_guvas12d.i4
-rw-r--r--peripheral/libupm/src/guvas12d/pyupm_guvas12d.i4
-rw-r--r--peripheral/libupm/src/h3lis331dl/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/h3lis331dl/h3lis331dl.cxx2
-rw-r--r--peripheral/libupm/src/h3lis331dl/h3lis331dl.h (renamed from peripheral/libupm/src/h3lis331dl/h3lis331dl.hpp)4
-rw-r--r--peripheral/libupm/src/h3lis331dl/javaupm_h3lis331dl.i4
-rw-r--r--peripheral/libupm/src/h3lis331dl/jsupm_h3lis331dl.i4
-rw-r--r--peripheral/libupm/src/h3lis331dl/pyupm_h3lis331dl.i4
-rw-r--r--peripheral/libupm/src/h803x/CMakeLists.txt23
-rw-r--r--peripheral/libupm/src/h803x/h803x.cxx356
-rw-r--r--peripheral/libupm/src/h803x/h803x.hpp547
-rw-r--r--peripheral/libupm/src/h803x/jsupm_h803x.i8
-rw-r--r--peripheral/libupm/src/h803x/pyupm_h803x.i12
-rw-r--r--peripheral/libupm/src/hcsr04/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/hcsr04/hcsr04.cxx2
-rw-r--r--peripheral/libupm/src/hcsr04/hcsr04.h (renamed from peripheral/libupm/src/hcsr04/hcsr04.hpp)0
-rw-r--r--peripheral/libupm/src/hcsr04/javaupm_hcsr04.i4
-rw-r--r--peripheral/libupm/src/hcsr04/jsupm_hcsr04.i4
-rw-r--r--peripheral/libupm/src/hcsr04/pyupm_hcsr04.i4
-rw-r--r--peripheral/libupm/src/hdxxvxta/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/hdxxvxta/hdxxvxta.cxx2
-rw-r--r--peripheral/libupm/src/hdxxvxta/hdxxvxta.h (renamed from peripheral/libupm/src/hdxxvxta/hdxxvxta.hpp)0
-rw-r--r--peripheral/libupm/src/hdxxvxta/javaupm_hdxxvxta.i4
-rw-r--r--peripheral/libupm/src/hdxxvxta/jsupm_hdxxvxta.i4
-rw-r--r--peripheral/libupm/src/hdxxvxta/pyupm_hdxxvxta.i4
-rw-r--r--peripheral/libupm/src/hlg150h/CMakeLists.txt6
-rw-r--r--peripheral/libupm/src/hlg150h/hlg150h.cxx80
-rw-r--r--peripheral/libupm/src/hlg150h/hlg150h.hpp78
-rw-r--r--peripheral/libupm/src/hlg150h/javaupm_hlg150h.i23
-rw-r--r--peripheral/libupm/src/hlg150h/jsupm_hlg150h.i8
-rw-r--r--peripheral/libupm/src/hlg150h/mraa-utils.cxx47
-rw-r--r--peripheral/libupm/src/hlg150h/mraa-utils.hpp37
-rw-r--r--peripheral/libupm/src/hlg150h/pyupm_hlg150h.i9
-rw-r--r--peripheral/libupm/src/hm11/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/hm11/hm11.cxx2
-rw-r--r--peripheral/libupm/src/hm11/hm11.h (renamed from peripheral/libupm/src/hm11/hm11.hpp)0
-rw-r--r--peripheral/libupm/src/hm11/javaupm_hm11.i4
-rw-r--r--peripheral/libupm/src/hm11/jsupm_hm11.i4
-rw-r--r--peripheral/libupm/src/hm11/pyupm_hm11.i4
-rw-r--r--peripheral/libupm/src/hmc5883l/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/hmc5883l/hmc5883l.cxx2
-rw-r--r--peripheral/libupm/src/hmc5883l/hmc5883l.h (renamed from peripheral/libupm/src/hmc5883l/hmc5883l.hpp)0
-rw-r--r--peripheral/libupm/src/hmc5883l/javaupm_hmc5883l.i4
-rw-r--r--peripheral/libupm/src/hmc5883l/jsupm_hmc5883l.i4
-rw-r--r--peripheral/libupm/src/hmc5883l/pyupm_hmc5883l.i4
-rw-r--r--peripheral/libupm/src/hmtrp/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/hmtrp/hmtrp.cxx2
-rw-r--r--peripheral/libupm/src/hmtrp/hmtrp.h (renamed from peripheral/libupm/src/hmtrp/hmtrp.hpp)0
-rw-r--r--peripheral/libupm/src/hmtrp/javaupm_hmtrp.i4
-rw-r--r--peripheral/libupm/src/hmtrp/jsupm_hmtrp.i4
-rw-r--r--peripheral/libupm/src/hmtrp/pyupm_hmtrp.i4
-rw-r--r--peripheral/libupm/src/hp20x/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/hp20x/hp20x.cxx2
-rw-r--r--peripheral/libupm/src/hp20x/hp20x.h (renamed from peripheral/libupm/src/hp20x/hp20x.hpp)0
-rw-r--r--peripheral/libupm/src/hp20x/javaupm_hp20x.i4
-rw-r--r--peripheral/libupm/src/hp20x/jsupm_hp20x.i4
-rw-r--r--peripheral/libupm/src/hp20x/pyupm_hp20x.i4
-rw-r--r--peripheral/libupm/src/ht9170/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/ht9170/ht9170.cxx2
-rw-r--r--peripheral/libupm/src/ht9170/ht9170.h (renamed from peripheral/libupm/src/ht9170/ht9170.hpp)0
-rw-r--r--peripheral/libupm/src/ht9170/javaupm_ht9170.i4
-rw-r--r--peripheral/libupm/src/ht9170/jsupm_ht9170.i4
-rw-r--r--peripheral/libupm/src/ht9170/pyupm_ht9170.i4
-rw-r--r--peripheral/libupm/src/htu21d/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/htu21d/htu21d.cpp2
-rw-r--r--peripheral/libupm/src/htu21d/htu21d.h (renamed from peripheral/libupm/src/htu21d/htu21d.hpp)0
-rw-r--r--peripheral/libupm/src/htu21d/javaupm_htu21d.i4
-rw-r--r--peripheral/libupm/src/htu21d/jsupm_htu21d.i4
-rw-r--r--peripheral/libupm/src/htu21d/pyupm_htu21d.i4
-rw-r--r--peripheral/libupm/src/hwxpxx/CMakeLists.txt9
-rw-r--r--peripheral/libupm/src/hwxpxx/hwxpxx.cxx2
-rw-r--r--peripheral/libupm/src/hwxpxx/hwxpxx.h (renamed from peripheral/libupm/src/hwxpxx/hwxpxx.hpp)0
-rw-r--r--peripheral/libupm/src/hwxpxx/javaupm_hwxpxx.i4
-rw-r--r--peripheral/libupm/src/hwxpxx/jsupm_hwxpxx.i4
-rw-r--r--peripheral/libupm/src/hwxpxx/pyupm_hwxpxx.i4
-rw-r--r--peripheral/libupm/src/hx711/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/hx711/hx711.cxx2
-rw-r--r--peripheral/libupm/src/hx711/hx711.h (renamed from peripheral/libupm/src/hx711/hx711.hpp)0
-rw-r--r--peripheral/libupm/src/hx711/javaupm_hx711.i4
-rw-r--r--peripheral/libupm/src/hx711/jsupm_hx711.i4
-rw-r--r--peripheral/libupm/src/hx711/pyupm_hx711.i4
-rw-r--r--peripheral/libupm/src/ili9341/CMakeLists.txt4
-rw-r--r--peripheral/libupm/src/ili9341/gfx.cxx (renamed from peripheral/libupm/src/ili9341/ili9341_gfx.cxx)2
-rw-r--r--peripheral/libupm/src/ili9341/gfx.h (renamed from peripheral/libupm/src/ili9341/ili9341_gfx.hpp)0
-rw-r--r--peripheral/libupm/src/ili9341/ili9341.cxx2
-rw-r--r--peripheral/libupm/src/ili9341/ili9341.h (renamed from peripheral/libupm/src/ili9341/ili9341.hpp)2
-rw-r--r--peripheral/libupm/src/ili9341/javaupm_ili9341.i8
-rw-r--r--peripheral/libupm/src/ili9341/jsupm_ili9341.i8
-rw-r--r--peripheral/libupm/src/ili9341/pyupm_ili9341.i8
-rw-r--r--peripheral/libupm/src/ina132/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/ina132/ina132.cxx3
-rw-r--r--peripheral/libupm/src/ina132/ina132.h (renamed from peripheral/libupm/src/ina132/ina132.hpp)0
-rw-r--r--peripheral/libupm/src/ina132/javaupm_ina132.i4
-rw-r--r--peripheral/libupm/src/ina132/jsupm_ina132.i4
-rw-r--r--peripheral/libupm/src/ina132/pyupm_ina132.i4
-rw-r--r--peripheral/libupm/src/isd1820/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/isd1820/isd1820.cxx2
-rw-r--r--peripheral/libupm/src/isd1820/isd1820.h (renamed from peripheral/libupm/src/isd1820/isd1820.hpp)0
-rw-r--r--peripheral/libupm/src/isd1820/javaupm_isd1820.i4
-rw-r--r--peripheral/libupm/src/isd1820/jsupm_isd1820.i4
-rw-r--r--peripheral/libupm/src/isd1820/pyupm_isd1820.i4
-rw-r--r--peripheral/libupm/src/itg3200/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/itg3200/itg3200.cxx2
-rw-r--r--peripheral/libupm/src/itg3200/itg3200.h (renamed from peripheral/libupm/src/itg3200/itg3200.hpp)0
-rw-r--r--peripheral/libupm/src/itg3200/javaupm_itg3200.i4
-rw-r--r--peripheral/libupm/src/itg3200/jsupm_itg3200.i4
-rw-r--r--peripheral/libupm/src/itg3200/pyupm_itg3200.i4
-rw-r--r--peripheral/libupm/src/javaswig_blacklist2
-rw-r--r--peripheral/libupm/src/joystick12/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/joystick12/javaupm_joystick12.i4
-rw-r--r--peripheral/libupm/src/joystick12/joystick12.cxx4
-rw-r--r--peripheral/libupm/src/joystick12/joystick12.h (renamed from peripheral/libupm/src/joystick12/joystick12.hpp)0
-rw-r--r--peripheral/libupm/src/joystick12/jsupm_joystick12.i4
-rw-r--r--peripheral/libupm/src/joystick12/pyupm_joystick12.i4
-rw-r--r--peripheral/libupm/src/kxcjk1013/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/kxcjk1013/javaupm_kxcjk1013.i (renamed from peripheral/libupm/src/h803x/javaupm_h803x.i)10
-rw-r--r--peripheral/libupm/src/kxcjk1013/jsupm_kxcjk1013.i4
-rw-r--r--[-rwxr-xr-x]peripheral/libupm/src/kxcjk1013/kxcjk1013.cxx26
-rw-r--r--peripheral/libupm/src/kxcjk1013/kxcjk1013.h (renamed from peripheral/libupm/src/kxcjk1013/kxcjk1013.hpp)32
-rw-r--r--peripheral/libupm/src/kxcjk1013/pyupm_kxcjk1013.i4
-rw-r--r--peripheral/libupm/src/l298/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/l298/javaupm_l298.i4
-rw-r--r--peripheral/libupm/src/l298/jsupm_l298.i4
-rw-r--r--peripheral/libupm/src/l298/l298.cxx2
-rw-r--r--peripheral/libupm/src/l298/l298.h (renamed from peripheral/libupm/src/l298/l298.hpp)0
-rw-r--r--peripheral/libupm/src/l298/pyupm_l298.i4
-rw-r--r--peripheral/libupm/src/l3gd20/CMakeLists.txt5
-rw-r--r--peripheral/libupm/src/l3gd20/jsupm_l3gd20.i8
-rwxr-xr-xperipheral/libupm/src/l3gd20/l3gd20.cxx458
-rw-r--r--peripheral/libupm/src/l3gd20/l3gd20.hpp214
-rw-r--r--peripheral/libupm/src/l3gd20/pyupm_l3gd20.i9
-rwxr-xr-xperipheral/libupm/src/lcd/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/lcd/eboled.cxx4
-rw-r--r--peripheral/libupm/src/lcd/eboled.h (renamed from peripheral/libupm/src/lcd/eboled.hpp)4
-rw-r--r--peripheral/libupm/src/lcd/hd44780_bits.h (renamed from peripheral/libupm/src/lcd/hd44780_bits.hpp)0
-rw-r--r--peripheral/libupm/src/lcd/javaupm_i2clcd.i36
-rw-r--r--peripheral/libupm/src/lcd/jhd1313m1.cxx26
-rw-r--r--peripheral/libupm/src/lcd/jhd1313m1.h (renamed from peripheral/libupm/src/lcd/jhd1313m1.hpp)2
-rwxr-xr-xperipheral/libupm/src/lcd/jsupm_i2clcd.i34
-rw-r--r--peripheral/libupm/src/lcd/lcd.cxx2
-rw-r--r--peripheral/libupm/src/lcd/lcd.h (renamed from peripheral/libupm/src/lcd/lcd.hpp)0
-rw-r--r--peripheral/libupm/src/lcd/lcd_private.h (renamed from peripheral/libupm/src/lcd/lcd_private.hpp)0
-rw-r--r--peripheral/libupm/src/lcd/lcm1602.cxx22
-rw-r--r--peripheral/libupm/src/lcd/lcm1602.h (renamed from peripheral/libupm/src/lcd/lcm1602.hpp)33
-rwxr-xr-xperipheral/libupm/src/lcd/pyupm_i2clcd.i34
-rw-r--r--peripheral/libupm/src/lcd/sainsmartks.cxx2
-rw-r--r--peripheral/libupm/src/lcd/sainsmartks.h (renamed from peripheral/libupm/src/lcd/sainsmartks.hpp)2
-rw-r--r--peripheral/libupm/src/lcd/ssd.h (renamed from peripheral/libupm/src/lcd/ssd.hpp)0
-rw-r--r--peripheral/libupm/src/lcd/ssd1306.cxx4
-rw-r--r--peripheral/libupm/src/lcd/ssd1306.h (renamed from peripheral/libupm/src/lcd/ssd1306.hpp)4
-rw-r--r--peripheral/libupm/src/lcd/ssd1308.cxx4
-rw-r--r--peripheral/libupm/src/lcd/ssd1308.h (renamed from peripheral/libupm/src/lcd/ssd1308.hpp)4
-rw-r--r--peripheral/libupm/src/lcd/ssd1327.cxx4
-rw-r--r--peripheral/libupm/src/lcd/ssd1327.h (renamed from peripheral/libupm/src/lcd/ssd1327.hpp)4
-rw-r--r--peripheral/libupm/src/ldt0028/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/ldt0028/javaupm_ldt0028.i4
-rw-r--r--peripheral/libupm/src/ldt0028/jsupm_ldt0028.i4
-rw-r--r--peripheral/libupm/src/ldt0028/ldt0028.cxx2
-rw-r--r--peripheral/libupm/src/ldt0028/ldt0028.h (renamed from peripheral/libupm/src/ldt0028/ldt0028.hpp)0
-rw-r--r--peripheral/libupm/src/ldt0028/pyupm_ldt0028.i4
-rw-r--r--peripheral/libupm/src/lm35/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/lm35/javaupm_lm35.i4
-rw-r--r--peripheral/libupm/src/lm35/jsupm_lm35.i4
-rw-r--r--peripheral/libupm/src/lm35/lm35.cxx2
-rw-r--r--peripheral/libupm/src/lm35/lm35.h (renamed from peripheral/libupm/src/lm35/lm35.hpp)0
-rw-r--r--peripheral/libupm/src/lm35/pyupm_lm35.i4
-rw-r--r--peripheral/libupm/src/lol/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/lol/javaupm_lol.i4
-rw-r--r--peripheral/libupm/src/lol/jsupm_lol.i4
-rw-r--r--peripheral/libupm/src/lol/lol.cxx2
-rw-r--r--peripheral/libupm/src/lol/lol.h (renamed from peripheral/libupm/src/lol/lol.hpp)0
-rw-r--r--peripheral/libupm/src/lol/pyupm_lol.i4
-rw-r--r--peripheral/libupm/src/loudness/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/loudness/javaupm_loudness.i4
-rw-r--r--peripheral/libupm/src/loudness/jsupm_loudness.i4
-rw-r--r--peripheral/libupm/src/loudness/loudness.cxx2
-rw-r--r--peripheral/libupm/src/loudness/loudness.h (renamed from peripheral/libupm/src/loudness/loudness.hpp)0
-rw-r--r--peripheral/libupm/src/loudness/pyupm_loudness.i4
-rw-r--r--peripheral/libupm/src/lp8860/CMakeLists.txt6
-rw-r--r--peripheral/libupm/src/lp8860/javaupm_lp8860.i8
-rw-r--r--peripheral/libupm/src/lp8860/jsupm_lp8860.i8
-rw-r--r--peripheral/libupm/src/lp8860/lp8860.cxx284
-rw-r--r--peripheral/libupm/src/lp8860/lp8860.hpp81
-rw-r--r--peripheral/libupm/src/lp8860/mraa-utils.cxx73
-rw-r--r--peripheral/libupm/src/lp8860/mraa-utils.hpp37
-rw-r--r--peripheral/libupm/src/lp8860/pyupm_lp8860.i9
-rw-r--r--peripheral/libupm/src/lpd8806/.DS_Storebin0 -> 6148 bytes
-rw-r--r--peripheral/libupm/src/lpd8806/._.DS_Storebin0 -> 4096 bytes
-rw-r--r--peripheral/libupm/src/lpd8806/._CMakeLists.txtbin0 -> 4096 bytes
-rw-r--r--peripheral/libupm/src/lpd8806/._jsupm_lpd8806.ibin0 -> 4096 bytes
-rw-r--r--peripheral/libupm/src/lpd8806/._pyupm_lpd8806.ibin0 -> 4096 bytes
-rw-r--r--peripheral/libupm/src/lpd8806/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/lpd8806/javaupm_lpd8806.i4
-rw-r--r--peripheral/libupm/src/lpd8806/jsupm_lpd8806.i4
-rw-r--r--peripheral/libupm/src/lpd8806/lpd8806.cxx2
-rw-r--r--peripheral/libupm/src/lpd8806/lpd8806.h (renamed from peripheral/libupm/src/lpd8806/lpd8806.hpp)0
-rw-r--r--peripheral/libupm/src/lpd8806/pyupm_lpd8806.i4
-rw-r--r--peripheral/libupm/src/lsm303/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/lsm303/javaupm_lsm303.i4
-rw-r--r--peripheral/libupm/src/lsm303/jsupm_lsm303.i4
-rw-r--r--peripheral/libupm/src/lsm303/lsm303.cxx2
-rw-r--r--peripheral/libupm/src/lsm303/lsm303.h (renamed from peripheral/libupm/src/lsm303/lsm303.hpp)0
-rw-r--r--peripheral/libupm/src/lsm303/pyupm_lsm303.i4
-rw-r--r--peripheral/libupm/src/lsm9ds0/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/lsm9ds0/javaupm_lsm9ds0.i4
-rw-r--r--peripheral/libupm/src/lsm9ds0/jsupm_lsm9ds0.i4
-rw-r--r--peripheral/libupm/src/lsm9ds0/lsm9ds0.cxx6
-rw-r--r--peripheral/libupm/src/lsm9ds0/lsm9ds0.h (renamed from peripheral/libupm/src/lsm9ds0/lsm9ds0.hpp)5
-rw-r--r--peripheral/libupm/src/lsm9ds0/pyupm_lsm9ds0.i4
-rw-r--r--peripheral/libupm/src/m24lr64e/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/m24lr64e/javaupm_m24lr64e.i4
-rw-r--r--peripheral/libupm/src/m24lr64e/jsupm_m24lr64e.i4
-rw-r--r--peripheral/libupm/src/m24lr64e/m24lr64e.cxx2
-rw-r--r--peripheral/libupm/src/m24lr64e/m24lr64e.h (renamed from peripheral/libupm/src/m24lr64e/m24lr64e.hpp)0
-rw-r--r--peripheral/libupm/src/m24lr64e/pyupm_m24lr64e.i4
-rw-r--r--peripheral/libupm/src/max31723/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/max31723/javaupm_max31723.i4
-rw-r--r--peripheral/libupm/src/max31723/jsupm_max31723.i4
-rw-r--r--peripheral/libupm/src/max31723/max31723.cxx2
-rw-r--r--peripheral/libupm/src/max31723/max31723.h (renamed from peripheral/libupm/src/max31723/max31723.hpp)0
-rw-r--r--peripheral/libupm/src/max31723/pyupm_max31723.i4
-rw-r--r--peripheral/libupm/src/max31855/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/max31855/javaupm_max31855.i4
-rw-r--r--peripheral/libupm/src/max31855/jsupm_max31855.i4
-rw-r--r--peripheral/libupm/src/max31855/max31855.cxx2
-rw-r--r--peripheral/libupm/src/max31855/max31855.h (renamed from peripheral/libupm/src/max31855/max31855.hpp)0
-rw-r--r--peripheral/libupm/src/max31855/pyupm_max31855.i4
-rw-r--r--peripheral/libupm/src/max44000/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/max44000/javaupm_max44000.i4
-rw-r--r--peripheral/libupm/src/max44000/jsupm_max44000.i4
-rw-r--r--peripheral/libupm/src/max44000/max44000.cxx2
-rw-r--r--peripheral/libupm/src/max44000/max44000.h (renamed from peripheral/libupm/src/max44000/max44000.hpp)0
-rw-r--r--peripheral/libupm/src/max44000/pyupm_max44000.i4
-rw-r--r--peripheral/libupm/src/max44009/CMakeLists.txt6
-rw-r--r--peripheral/libupm/src/max44009/javaupm_max44009.i23
-rw-r--r--peripheral/libupm/src/max44009/jsupm_max44009.i8
-rw-r--r--peripheral/libupm/src/max44009/max44009.cxx94
-rw-r--r--peripheral/libupm/src/max44009/max44009.hpp143
-rw-r--r--peripheral/libupm/src/max44009/pyupm_max44009.i11
-rw-r--r--peripheral/libupm/src/max5487/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/max5487/javaupm_max5487.i4
-rw-r--r--peripheral/libupm/src/max5487/jsupm_max5487.i4
-rw-r--r--peripheral/libupm/src/max5487/max5487.cxx2
-rw-r--r--peripheral/libupm/src/max5487/max5487.h (renamed from peripheral/libupm/src/max5487/max5487.hpp)0
-rw-r--r--peripheral/libupm/src/max5487/pyupm_max5487.i4
-rw-r--r--peripheral/libupm/src/maxds3231m/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/maxds3231m/javaupm_maxds3231m.i4
-rw-r--r--peripheral/libupm/src/maxds3231m/jsupm_maxds3231m.i4
-rw-r--r--peripheral/libupm/src/maxds3231m/maxds3231m.cxx2
-rw-r--r--peripheral/libupm/src/maxds3231m/maxds3231m.h (renamed from peripheral/libupm/src/maxds3231m/maxds3231m.hpp)0
-rw-r--r--peripheral/libupm/src/maxds3231m/pyupm_maxds3231m.i4
-rw-r--r--peripheral/libupm/src/maxsonarez/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/maxsonarez/javaupm_maxsonarez.i4
-rw-r--r--peripheral/libupm/src/maxsonarez/jsupm_maxsonarez.i4
-rw-r--r--peripheral/libupm/src/maxsonarez/maxsonarez.cxx5
-rw-r--r--peripheral/libupm/src/maxsonarez/maxsonarez.h (renamed from peripheral/libupm/src/maxsonarez/maxsonarez.hpp)0
-rw-r--r--peripheral/libupm/src/maxsonarez/pyupm_maxsonarez.i4
-rw-r--r--peripheral/libupm/src/mcp9808/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/mcp9808/javaupm_mcp9808.i4
-rw-r--r--peripheral/libupm/src/mcp9808/jsupm_mcp9808.i4
-rw-r--r--peripheral/libupm/src/mcp9808/mcp9808.cxx2
-rw-r--r--peripheral/libupm/src/mcp9808/mcp9808.h (renamed from peripheral/libupm/src/mcp9808/mcp9808.hpp)0
-rw-r--r--peripheral/libupm/src/mcp9808/pyupm_mcp9808.i4
-rw-r--r--peripheral/libupm/src/mg811/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/mg811/javaupm_mg811.i4
-rw-r--r--peripheral/libupm/src/mg811/jsupm_mg811.i4
-rw-r--r--peripheral/libupm/src/mg811/mg811.cxx2
-rw-r--r--peripheral/libupm/src/mg811/mg811.h (renamed from peripheral/libupm/src/mg811/mg811.hpp)0
-rw-r--r--peripheral/libupm/src/mg811/pyupm_mg811.i4
-rw-r--r--peripheral/libupm/src/mhz16/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/mhz16/javaupm_mhz16.i4
-rw-r--r--peripheral/libupm/src/mhz16/jsupm_mhz16.i4
-rw-r--r--peripheral/libupm/src/mhz16/mhz16.cxx2
-rw-r--r--peripheral/libupm/src/mhz16/mhz16.h (renamed from peripheral/libupm/src/mhz16/mhz16.hpp)0
-rw-r--r--peripheral/libupm/src/mhz16/pyupm_mhz16.i4
-rw-r--r--peripheral/libupm/src/mic/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/mic/javaupm_mic.i4
-rw-r--r--peripheral/libupm/src/mic/jsupm_mic.i4
-rw-r--r--peripheral/libupm/src/mic/mic.cxx8
-rw-r--r--peripheral/libupm/src/mic/mic.h (renamed from peripheral/libupm/src/mic/mic.hpp)2
-rw-r--r--peripheral/libupm/src/mic/pyupm_mic.i4
-rw-r--r--peripheral/libupm/src/micsv89/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/micsv89/javaupm_micsv89.i4
-rw-r--r--peripheral/libupm/src/micsv89/jsupm_micsv89.i4
-rw-r--r--peripheral/libupm/src/micsv89/micsv89.cxx2
-rw-r--r--peripheral/libupm/src/micsv89/micsv89.h (renamed from peripheral/libupm/src/micsv89/micsv89.hpp)0
-rw-r--r--peripheral/libupm/src/micsv89/pyupm_micsv89.i4
-rw-r--r--peripheral/libupm/src/mlx90614/.DS_Storebin0 -> 6148 bytes
-rw-r--r--peripheral/libupm/src/mlx90614/._.DS_Storebin0 -> 4096 bytes
-rw-r--r--peripheral/libupm/src/mlx90614/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/mlx90614/javaupm_mlx90614.i4
-rw-r--r--peripheral/libupm/src/mlx90614/jsupm_mlx90614.i4
-rw-r--r--peripheral/libupm/src/mlx90614/mlx90614.cxx2
-rw-r--r--peripheral/libupm/src/mlx90614/mlx90614.h (renamed from peripheral/libupm/src/mlx90614/mlx90614.hpp)0
-rw-r--r--peripheral/libupm/src/mlx90614/pyupm_mlx90614.i4
-rw-r--r--peripheral/libupm/src/mma7455/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/mma7455/javaupm_mma7455.i4
-rw-r--r--peripheral/libupm/src/mma7455/jsupm_mma7455.i4
-rw-r--r--peripheral/libupm/src/mma7455/mma7455.cxx2
-rw-r--r--peripheral/libupm/src/mma7455/mma7455.h (renamed from peripheral/libupm/src/mma7455/mma7455.hpp)0
-rw-r--r--peripheral/libupm/src/mma7455/pyupm_mma7455.i4
-rw-r--r--peripheral/libupm/src/mma7660/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/mma7660/javaupm_mma7660.i4
-rw-r--r--peripheral/libupm/src/mma7660/jsupm_mma7660.i4
-rw-r--r--peripheral/libupm/src/mma7660/mma7660.cxx8
-rw-r--r--peripheral/libupm/src/mma7660/mma7660.cxx.orig275
-rw-r--r--peripheral/libupm/src/mma7660/mma7660.h (renamed from peripheral/libupm/src/mma7660/mma7660.hpp)0
-rw-r--r--peripheral/libupm/src/mma7660/pyupm_mma7660.i4
-rw-r--r--peripheral/libupm/src/mpl3115a2/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/mpl3115a2/javaupm_mpl3115a2.i4
-rw-r--r--peripheral/libupm/src/mpl3115a2/jsupm_mpl3115a2.i4
-rw-r--r--peripheral/libupm/src/mpl3115a2/mpl3115a2.cpp2
-rw-r--r--peripheral/libupm/src/mpl3115a2/mpl3115a2.h (renamed from peripheral/libupm/src/mpl3115a2/mpl3115a2.hpp)0
-rw-r--r--peripheral/libupm/src/mpl3115a2/pyupm_mpl3115a2.i4
-rw-r--r--peripheral/libupm/src/mpr121/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/mpr121/javaupm_mpr121.i4
-rw-r--r--peripheral/libupm/src/mpr121/jsupm_mpr121.i4
-rw-r--r--peripheral/libupm/src/mpr121/mpr121.cxx2
-rw-r--r--peripheral/libupm/src/mpr121/mpr121.h (renamed from peripheral/libupm/src/mpr121/mpr121.hpp)0
-rw-r--r--peripheral/libupm/src/mpr121/pyupm_mpr121.i4
-rw-r--r--peripheral/libupm/src/mpu9150/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/mpu9150/ak8975.cxx2
-rw-r--r--peripheral/libupm/src/mpu9150/ak8975.h (renamed from peripheral/libupm/src/mpu9150/ak8975.hpp)0
-rw-r--r--peripheral/libupm/src/mpu9150/javaupm_mpu9150.i8
-rw-r--r--peripheral/libupm/src/mpu9150/jsupm_mpu9150.i18
-rw-r--r--peripheral/libupm/src/mpu9150/mpu60x0.cxx2
-rw-r--r--peripheral/libupm/src/mpu9150/mpu60x0.h (renamed from peripheral/libupm/src/mpu9150/mpu60x0.hpp)2
-rw-r--r--peripheral/libupm/src/mpu9150/mpu9150.cxx2
-rw-r--r--peripheral/libupm/src/mpu9150/mpu9150.h (renamed from peripheral/libupm/src/mpu9150/mpu9150.hpp)8
-rw-r--r--peripheral/libupm/src/mpu9150/mpu9250.cxx2
-rw-r--r--peripheral/libupm/src/mpu9150/mpu9250.h (renamed from peripheral/libupm/src/mpu9150/mpu9250.hpp)2
-rw-r--r--peripheral/libupm/src/mpu9150/pyupm_mpu9150.i16
-rw-r--r--peripheral/libupm/src/mq303a/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/mq303a/javaupm_mq303a.i4
-rw-r--r--peripheral/libupm/src/mq303a/jsupm_mq303a.i4
-rw-r--r--peripheral/libupm/src/mq303a/mq303a.cxx2
-rw-r--r--peripheral/libupm/src/mq303a/mq303a.h (renamed from peripheral/libupm/src/mq303a/mq303a.hpp)0
-rw-r--r--peripheral/libupm/src/mq303a/pyupm_mq303a.i4
-rw-r--r--peripheral/libupm/src/my9221/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/my9221/grovecircularled.cxx2
-rw-r--r--peripheral/libupm/src/my9221/grovecircularled.h (renamed from peripheral/libupm/src/my9221/grovecircularled.hpp)2
-rw-r--r--peripheral/libupm/src/my9221/groveledbar.cxx2
-rw-r--r--peripheral/libupm/src/my9221/groveledbar.h (renamed from peripheral/libupm/src/my9221/groveledbar.hpp)2
-rw-r--r--peripheral/libupm/src/my9221/javaupm_my9221.i12
-rw-r--r--peripheral/libupm/src/my9221/jsupm_my9221.i12
-rw-r--r--peripheral/libupm/src/my9221/my9221.cxx2
-rw-r--r--peripheral/libupm/src/my9221/my9221.h (renamed from peripheral/libupm/src/my9221/my9221.hpp)0
-rw-r--r--peripheral/libupm/src/my9221/pyupm_my9221.i12
-rw-r--r--peripheral/libupm/src/nlgpio16/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/nlgpio16/javaupm_nlgpio16.i4
-rw-r--r--peripheral/libupm/src/nlgpio16/jsupm_nlgpio16.i4
-rw-r--r--peripheral/libupm/src/nlgpio16/nlgpio16.cxx2
-rw-r--r--peripheral/libupm/src/nlgpio16/nlgpio16.h (renamed from peripheral/libupm/src/nlgpio16/nlgpio16.hpp)6
-rw-r--r--peripheral/libupm/src/nlgpio16/pyupm_nlgpio16.i4
-rw-r--r--peripheral/libupm/src/nrf24l01/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/nrf24l01/Callback.h (renamed from peripheral/libupm/src/nrf24l01/Callback.hpp)0
-rw-r--r--peripheral/libupm/src/nrf24l01/javaupm_nrf24l01.i6
-rw-r--r--peripheral/libupm/src/nrf24l01/jsupm_nrf24l01.i5
-rw-r--r--peripheral/libupm/src/nrf24l01/nrf24l01.cxx2
-rw-r--r--peripheral/libupm/src/nrf24l01/nrf24l01.h (renamed from peripheral/libupm/src/nrf24l01/nrf24l01.hpp)2
-rw-r--r--peripheral/libupm/src/nrf24l01/pyupm_nrf24l01.i5
-rw-r--r--peripheral/libupm/src/nrf8001/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/nrf8001/javaupm_nrf8001.i (renamed from peripheral/libupm/src/vcap/javaupm_vcap.i)12
-rw-r--r--peripheral/libupm/src/nrf8001/jsupm_nrf8001.i4
-rw-r--r--peripheral/libupm/src/nrf8001/nrf8001.cxx2
-rw-r--r--peripheral/libupm/src/nrf8001/nrf8001.h (renamed from peripheral/libupm/src/nrf8001/nrf8001.hpp)0
-rw-r--r--peripheral/libupm/src/nrf8001/pyupm_nrf8001.i4
-rw-r--r--peripheral/libupm/src/nunchuck/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/nunchuck/javaupm_nunchuck.i4
-rw-r--r--peripheral/libupm/src/nunchuck/jsupm_nunchuck.i4
-rw-r--r--peripheral/libupm/src/nunchuck/nunchuck.cxx2
-rw-r--r--peripheral/libupm/src/nunchuck/nunchuck.h (renamed from peripheral/libupm/src/nunchuck/nunchuck.hpp)0
-rw-r--r--peripheral/libupm/src/nunchuck/pyupm_nunchuck.i4
-rw-r--r--peripheral/libupm/src/otp538u/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/otp538u/javaupm_otp538u.i4
-rw-r--r--peripheral/libupm/src/otp538u/jsupm_otp538u.i4
-rw-r--r--peripheral/libupm/src/otp538u/otp538u.cxx15
-rw-r--r--peripheral/libupm/src/otp538u/otp538u.h (renamed from peripheral/libupm/src/otp538u/otp538u.hpp)0
-rw-r--r--peripheral/libupm/src/otp538u/pyupm_otp538u.i4
-rw-r--r--peripheral/libupm/src/otp538u/thermister_rt_table.h (renamed from peripheral/libupm/src/otp538u/thermister_rt_table.hpp)0
-rw-r--r--peripheral/libupm/src/otp538u/thermopile_vt_table.h (renamed from peripheral/libupm/src/otp538u/thermopile_vt_table.hpp)0
-rw-r--r--peripheral/libupm/src/ozw/CMakeLists.txt9
-rw-r--r--peripheral/libupm/src/ozw/javaupm_ozw.i4
-rw-r--r--peripheral/libupm/src/ozw/jsupm_ozw.i4
-rw-r--r--peripheral/libupm/src/ozw/ozw.cxx4
-rw-r--r--peripheral/libupm/src/ozw/ozw.h (renamed from peripheral/libupm/src/ozw/ozw.hpp)2
-rw-r--r--peripheral/libupm/src/ozw/pyupm_ozw.i4
-rw-r--r--peripheral/libupm/src/ozw/zwNode.cxx2
-rw-r--r--peripheral/libupm/src/ozw/zwNode.h (renamed from peripheral/libupm/src/ozw/zwNode.hpp)0
-rw-r--r--peripheral/libupm/src/package.json.in2
-rw-r--r--peripheral/libupm/src/pca9685/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/pca9685/javaupm_pca9685.i4
-rw-r--r--peripheral/libupm/src/pca9685/jsupm_pca9685.i4
-rw-r--r--peripheral/libupm/src/pca9685/pca9685.cxx14
-rw-r--r--peripheral/libupm/src/pca9685/pca9685.h (renamed from peripheral/libupm/src/pca9685/pca9685.hpp)0
-rw-r--r--peripheral/libupm/src/pca9685/pyupm_pca9685.i4
-rw-r--r--peripheral/libupm/src/pn532/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/pn532/javaupm_pn532.i4
-rw-r--r--peripheral/libupm/src/pn532/jsupm_pn532.i4
-rw-r--r--peripheral/libupm/src/pn532/pn532.cxx336
-rw-r--r--peripheral/libupm/src/pn532/pn532.h (renamed from peripheral/libupm/src/pn532/pn532.hpp)4
-rw-r--r--peripheral/libupm/src/pn532/pyupm_pn532.i4
-rw-r--r--peripheral/libupm/src/ppd42ns/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/ppd42ns/javaupm_ppd42ns.i4
-rw-r--r--peripheral/libupm/src/ppd42ns/jsupm_ppd42ns.i4
-rw-r--r--peripheral/libupm/src/ppd42ns/ppd42ns.cxx2
-rw-r--r--peripheral/libupm/src/ppd42ns/ppd42ns.h (renamed from peripheral/libupm/src/ppd42ns/ppd42ns.hpp)0
-rw-r--r--peripheral/libupm/src/ppd42ns/pyupm_ppd42ns.i4
-rw-r--r--peripheral/libupm/src/pulsensor/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/pulsensor/Callback.h (renamed from peripheral/libupm/src/pulsensor/Callback.hpp)0
-rw-r--r--peripheral/libupm/src/pulsensor/javaupm_pulsensor.i6
-rw-r--r--peripheral/libupm/src/pulsensor/jsupm_pulsensor.i4
-rw-r--r--peripheral/libupm/src/pulsensor/pulsensor.cxx2
-rw-r--r--peripheral/libupm/src/pulsensor/pulsensor.h (renamed from peripheral/libupm/src/pulsensor/pulsensor.hpp)2
-rw-r--r--peripheral/libupm/src/pulsensor/pyupm_pulsensor.i4
-rw-r--r--peripheral/libupm/src/rfr359f/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/rfr359f/javaupm_rfr359f.i4
-rw-r--r--peripheral/libupm/src/rfr359f/jsupm_rfr359f.i4
-rw-r--r--peripheral/libupm/src/rfr359f/pyupm_rfr359f.i4
-rw-r--r--peripheral/libupm/src/rfr359f/rfr359f.cxx2
-rw-r--r--peripheral/libupm/src/rfr359f/rfr359f.h (renamed from peripheral/libupm/src/rfr359f/rfr359f.hpp)0
-rw-r--r--peripheral/libupm/src/rgbringcoder/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/rgbringcoder/javaupm_rgbringcoder.i4
-rw-r--r--peripheral/libupm/src/rgbringcoder/jsupm_rgbringcoder.i4
-rw-r--r--peripheral/libupm/src/rgbringcoder/pyupm_rgbringcoder.i4
-rw-r--r--peripheral/libupm/src/rgbringcoder/rgbringcoder.cxx2
-rw-r--r--peripheral/libupm/src/rgbringcoder/rgbringcoder.h (renamed from peripheral/libupm/src/rgbringcoder/rgbringcoder.hpp)0
-rw-r--r--peripheral/libupm/src/rhusb/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/rhusb/javaupm_rhusb.i4
-rw-r--r--peripheral/libupm/src/rhusb/jsupm_rhusb.i4
-rw-r--r--peripheral/libupm/src/rhusb/pyupm_rhusb.i4
-rw-r--r--peripheral/libupm/src/rhusb/rhusb.cxx2
-rw-r--r--peripheral/libupm/src/rhusb/rhusb.h (renamed from peripheral/libupm/src/rhusb/rhusb.hpp)0
-rw-r--r--peripheral/libupm/src/rotaryencoder/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/rotaryencoder/javaupm_rotaryencoder.i4
-rw-r--r--peripheral/libupm/src/rotaryencoder/jsupm_rotaryencoder.i4
-rw-r--r--peripheral/libupm/src/rotaryencoder/pyupm_rotaryencoder.i4
-rw-r--r--peripheral/libupm/src/rotaryencoder/rotaryencoder.cxx2
-rw-r--r--peripheral/libupm/src/rotaryencoder/rotaryencoder.h (renamed from peripheral/libupm/src/rotaryencoder/rotaryencoder.hpp)0
-rw-r--r--peripheral/libupm/src/rpr220/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/rpr220/javaupm_rpr220.i4
-rw-r--r--peripheral/libupm/src/rpr220/jsupm_rpr220.i4
-rw-r--r--peripheral/libupm/src/rpr220/pyupm_rpr220.i4
-rw-r--r--peripheral/libupm/src/rpr220/rpr220.cxx2
-rw-r--r--peripheral/libupm/src/rpr220/rpr220.h (renamed from peripheral/libupm/src/rpr220/rpr220.hpp)0
-rw-r--r--peripheral/libupm/src/servo/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/servo/es08a.cxx2
-rw-r--r--peripheral/libupm/src/servo/es08a.h (renamed from peripheral/libupm/src/servo/es08a.hpp)2
-rw-r--r--peripheral/libupm/src/servo/es9257.cxx2
-rw-r--r--peripheral/libupm/src/servo/es9257.h (renamed from peripheral/libupm/src/servo/es9257.hpp)2
-rw-r--r--peripheral/libupm/src/servo/javaupm_servo.i12
-rw-r--r--peripheral/libupm/src/servo/jsupm_servo.i12
-rw-r--r--peripheral/libupm/src/servo/pyupm_servo.i12
-rw-r--r--peripheral/libupm/src/servo/servo.cxx2
-rw-r--r--peripheral/libupm/src/servo/servo.h (renamed from peripheral/libupm/src/servo/servo.hpp)0
-rw-r--r--peripheral/libupm/src/si1132/CMakeLists.txt6
-rw-r--r--peripheral/libupm/src/si1132/javaupm_si1132.i17
-rw-r--r--peripheral/libupm/src/si1132/jsupm_si1132.i8
-rw-r--r--peripheral/libupm/src/si1132/pyupm_si1132.i11
-rw-r--r--peripheral/libupm/src/si1132/si1132.cxx227
-rw-r--r--peripheral/libupm/src/si1132/si1132.hpp96
-rw-r--r--peripheral/libupm/src/si114x/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/si114x/javaupm_si114x.i4
-rw-r--r--peripheral/libupm/src/si114x/jsupm_si114x.i4
-rw-r--r--peripheral/libupm/src/si114x/pyupm_si114x.i4
-rw-r--r--peripheral/libupm/src/si114x/si114x.cxx14
-rw-r--r--peripheral/libupm/src/si114x/si114x.h (renamed from peripheral/libupm/src/si114x/si114x.hpp)0
-rw-r--r--peripheral/libupm/src/si7005/CMakeLists.txt6
-rw-r--r--peripheral/libupm/src/si7005/javaupm_si7005.i23
-rw-r--r--peripheral/libupm/src/si7005/jsupm_si7005.i8
-rw-r--r--peripheral/libupm/src/si7005/mraa-utils.cxx73
-rw-r--r--peripheral/libupm/src/si7005/mraa-utils.hpp37
-rw-r--r--peripheral/libupm/src/si7005/pyupm_si7005.i11
-rw-r--r--peripheral/libupm/src/si7005/si7005.cxx203
-rw-r--r--peripheral/libupm/src/si7005/si7005.hpp139
-rw-r--r--peripheral/libupm/src/sm130/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/sm130/javaupm_sm130.i4
-rw-r--r--peripheral/libupm/src/sm130/jsupm_sm130.i4
-rw-r--r--peripheral/libupm/src/sm130/pyupm_sm130.i4
-rw-r--r--peripheral/libupm/src/sm130/sm130.cxx2
-rw-r--r--peripheral/libupm/src/sm130/sm130.h (renamed from peripheral/libupm/src/sm130/sm130.hpp)0
-rw-r--r--peripheral/libupm/src/smartdrive/CMakeLists.txt5
-rw-r--r--peripheral/libupm/src/smartdrive/javaupm_smartdrive.i8
-rw-r--r--peripheral/libupm/src/smartdrive/jsupm_smartdrive.i8
-rw-r--r--peripheral/libupm/src/smartdrive/pyupm_smartdrive.i9
-rw-r--r--peripheral/libupm/src/smartdrive/smartdrive.cxx430
-rw-r--r--peripheral/libupm/src/smartdrive/smartdrive.hpp302
-rw-r--r--peripheral/libupm/src/ssd1351/CMakeLists.txt4
-rw-r--r--peripheral/libupm/src/ssd1351/gfx.cxx (renamed from peripheral/libupm/src/ssd1351/ssd1351_gfx.cxx)2
-rw-r--r--peripheral/libupm/src/ssd1351/gfx.h (renamed from peripheral/libupm/src/ssd1351/ssd1351_gfx.hpp)0
-rw-r--r--peripheral/libupm/src/ssd1351/javaupm_ssd1351.i8
-rw-r--r--peripheral/libupm/src/ssd1351/jsupm_ssd1351.i8
-rw-r--r--peripheral/libupm/src/ssd1351/pyupm_ssd1351.i8
-rw-r--r--peripheral/libupm/src/ssd1351/ssd1351.cxx4
-rw-r--r--peripheral/libupm/src/ssd1351/ssd1351.h (renamed from peripheral/libupm/src/ssd1351/ssd1351.hpp)10
-rw-r--r--peripheral/libupm/src/st7735/CMakeLists.txt4
-rw-r--r--peripheral/libupm/src/st7735/gfx.cxx (renamed from peripheral/libupm/src/st7735/st7735_gfx.cxx)2
-rw-r--r--peripheral/libupm/src/st7735/gfx.h (renamed from peripheral/libupm/src/st7735/st7735_gfx.hpp)0
-rw-r--r--peripheral/libupm/src/st7735/javaupm_st7735.i8
-rw-r--r--peripheral/libupm/src/st7735/jsupm_st7735.i8
-rw-r--r--peripheral/libupm/src/st7735/pyupm_st7735.i8
-rw-r--r--peripheral/libupm/src/st7735/st7735.cxx8
-rw-r--r--peripheral/libupm/src/st7735/st7735.h (renamed from peripheral/libupm/src/st7735/st7735.hpp)2
-rw-r--r--peripheral/libupm/src/stepmotor/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/stepmotor/javaupm_stepmotor.i4
-rw-r--r--peripheral/libupm/src/stepmotor/jsupm_stepmotor.i4
-rw-r--r--peripheral/libupm/src/stepmotor/pyupm_stepmotor.i4
-rw-r--r--peripheral/libupm/src/stepmotor/stepmotor.cxx2
-rw-r--r--peripheral/libupm/src/stepmotor/stepmotor.h (renamed from peripheral/libupm/src/stepmotor/stepmotor.hpp)0
-rw-r--r--peripheral/libupm/src/sx1276/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/sx1276/javaupm_sx1276.i4
-rw-r--r--peripheral/libupm/src/sx1276/jsupm_sx1276.i4
-rw-r--r--peripheral/libupm/src/sx1276/pyupm_sx1276.i4
-rw-r--r--peripheral/libupm/src/sx1276/sx1276.cxx6
-rw-r--r--peripheral/libupm/src/sx1276/sx1276.h (renamed from peripheral/libupm/src/sx1276/sx1276.hpp)2
-rw-r--r--peripheral/libupm/src/sx6119/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/sx6119/javaupm_sx6119.i4
-rw-r--r--peripheral/libupm/src/sx6119/jsupm_sx6119.i4
-rw-r--r--peripheral/libupm/src/sx6119/pyupm_sx6119.i4
-rw-r--r--peripheral/libupm/src/sx6119/sx6119.cxx2
-rw-r--r--peripheral/libupm/src/sx6119/sx6119.h (renamed from peripheral/libupm/src/sx6119/sx6119.hpp)0
-rw-r--r--peripheral/libupm/src/t3311/CMakeLists.txt11
-rw-r--r--peripheral/libupm/src/t3311/javaupm_t3311.i4
-rw-r--r--peripheral/libupm/src/t3311/jsupm_t3311.i4
-rw-r--r--peripheral/libupm/src/t3311/pyupm_t3311.i4
-rw-r--r--peripheral/libupm/src/t3311/t3311.cxx2
-rw-r--r--peripheral/libupm/src/t3311/t3311.h (renamed from peripheral/libupm/src/t3311/t3311.hpp)0
-rw-r--r--peripheral/libupm/src/t6713/CMakeLists.txt5
-rw-r--r--peripheral/libupm/src/t6713/javaupm_t6713.i23
-rw-r--r--peripheral/libupm/src/t6713/jsupm_t6713.i9
-rw-r--r--peripheral/libupm/src/t6713/pyupm_t6713.i10
-rw-r--r--peripheral/libupm/src/t6713/t6713.cxx278
-rw-r--r--peripheral/libupm/src/t6713/t6713.hpp148
-rw-r--r--peripheral/libupm/src/t8100/CMakeLists.txt28
-rw-r--r--peripheral/libupm/src/t8100/javaupm_t8100.i22
-rw-r--r--peripheral/libupm/src/t8100/jsupm_t8100.i10
-rw-r--r--peripheral/libupm/src/t8100/pyupm_t8100.i14
-rw-r--r--peripheral/libupm/src/t8100/t8100.cxx254
-rw-r--r--peripheral/libupm/src/t8100/t8100.hpp379
-rw-r--r--peripheral/libupm/src/ta12200/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/ta12200/javaupm_ta12200.i4
-rw-r--r--peripheral/libupm/src/ta12200/jsupm_ta12200.i4
-rw-r--r--peripheral/libupm/src/ta12200/pyupm_ta12200.i4
-rw-r--r--peripheral/libupm/src/ta12200/ta12200.cxx14
-rw-r--r--peripheral/libupm/src/ta12200/ta12200.h (renamed from peripheral/libupm/src/ta12200/ta12200.hpp)4
-rw-r--r--peripheral/libupm/src/tb7300/CMakeLists.txt28
-rw-r--r--peripheral/libupm/src/tb7300/javaupm_tb7300.i32
-rw-r--r--peripheral/libupm/src/tb7300/jsupm_tb7300.i10
-rw-r--r--peripheral/libupm/src/tb7300/pyupm_tb7300.i14
-rw-r--r--peripheral/libupm/src/tb7300/tb7300.cxx108
-rw-r--r--peripheral/libupm/src/tb7300/tb7300.hpp258
-rw-r--r--peripheral/libupm/src/tcs3414cs/.DS_Storebin0 -> 6148 bytes
-rw-r--r--peripheral/libupm/src/tcs3414cs/._.DS_Storebin0 -> 4096 bytes
-rw-r--r--peripheral/libupm/src/tcs3414cs/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/tcs3414cs/javaupm_tcs3414cs.i4
-rw-r--r--peripheral/libupm/src/tcs3414cs/jsupm_tcs3414cs.i4
-rw-r--r--peripheral/libupm/src/tcs3414cs/pyupm_tcs3414cs.i4
-rw-r--r--peripheral/libupm/src/tcs3414cs/tcs3414cs.cxx2
-rw-r--r--peripheral/libupm/src/tcs3414cs/tcs3414cs.h (renamed from peripheral/libupm/src/tcs3414cs/tcs3414cs.hpp)0
-rw-r--r--peripheral/libupm/src/teams/CMakeLists.txt5
-rw-r--r--peripheral/libupm/src/teams/javaupm_teams.i19
-rw-r--r--peripheral/libupm/src/teams/jsupm_teams.i10
-rw-r--r--peripheral/libupm/src/teams/pyupm_teams.i13
-rw-r--r--peripheral/libupm/src/teams/teams.cxx125
-rw-r--r--peripheral/libupm/src/teams/teams.hpp174
-rw-r--r--peripheral/libupm/src/tex00/CMakeLists.txt5
-rw-r--r--peripheral/libupm/src/tex00/javaupm_tex00.i19
-rw-r--r--peripheral/libupm/src/tex00/jsupm_tex00.i10
-rw-r--r--peripheral/libupm/src/tex00/pyupm_tex00.i13
-rw-r--r--peripheral/libupm/src/tex00/tex00.cxx692
-rw-r--r--peripheral/libupm/src/tex00/tex00.hpp216
-rw-r--r--peripheral/libupm/src/th02/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/th02/javaupm_th02.i4
-rw-r--r--peripheral/libupm/src/th02/jsupm_th02.i4
-rw-r--r--peripheral/libupm/src/th02/pyupm_th02.i4
-rw-r--r--peripheral/libupm/src/th02/th02.cxx2
-rw-r--r--peripheral/libupm/src/th02/th02.h (renamed from peripheral/libupm/src/th02/th02.hpp)0
-rw-r--r--peripheral/libupm/src/tm1637/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/tm1637/javaupm_tm1637.i4
-rw-r--r--peripheral/libupm/src/tm1637/jsupm_tm1637.i4
-rw-r--r--peripheral/libupm/src/tm1637/pyupm_tm1637.i4
-rw-r--r--peripheral/libupm/src/tm1637/tm1637.cxx2
-rw-r--r--peripheral/libupm/src/tm1637/tm1637.h (renamed from peripheral/libupm/src/tm1637/tm1637.hpp)0
-rw-r--r--peripheral/libupm/src/tsl2561/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/tsl2561/javaupm_tsl2561.i4
-rw-r--r--peripheral/libupm/src/tsl2561/jsupm_tsl2561.i4
-rw-r--r--peripheral/libupm/src/tsl2561/pyupm_tsl2561.i4
-rw-r--r--peripheral/libupm/src/tsl2561/tsl2561.cxx2
-rw-r--r--peripheral/libupm/src/tsl2561/tsl2561.h (renamed from peripheral/libupm/src/tsl2561/tsl2561.hpp)0
-rw-r--r--peripheral/libupm/src/ttp223/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/ttp223/javaupm_ttp223.i4
-rw-r--r--peripheral/libupm/src/ttp223/jsupm_ttp223.i4
-rw-r--r--peripheral/libupm/src/ttp223/pyupm_ttp223.i4
-rw-r--r--peripheral/libupm/src/ttp223/ttp223.cxx2
-rw-r--r--peripheral/libupm/src/ttp223/ttp223.h (renamed from peripheral/libupm/src/ttp223/ttp223.hpp)0
-rw-r--r--peripheral/libupm/src/ublox6/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/ublox6/javaupm_ublox6.i4
-rw-r--r--peripheral/libupm/src/ublox6/jsupm_ublox6.i4
-rw-r--r--peripheral/libupm/src/ublox6/pyupm_ublox6.i4
-rw-r--r--peripheral/libupm/src/ublox6/ublox6.cxx2
-rw-r--r--peripheral/libupm/src/ublox6/ublox6.h (renamed from peripheral/libupm/src/ublox6/ublox6.hpp)0
-rw-r--r--peripheral/libupm/src/uln200xa/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/uln200xa/javaupm_uln200xa.i4
-rw-r--r--peripheral/libupm/src/uln200xa/jsupm_uln200xa.i4
-rw-r--r--peripheral/libupm/src/uln200xa/pyupm_uln200xa.i4
-rw-r--r--peripheral/libupm/src/uln200xa/uln200xa.cxx2
-rw-r--r--peripheral/libupm/src/uln200xa/uln200xa.h (renamed from peripheral/libupm/src/uln200xa/uln200xa.hpp)0
-rw-r--r--peripheral/libupm/src/upm.h82
-rw-r--r--peripheral/libupm/src/upm/CMakeLists.txt8
-rw-r--r--peripheral/libupm/src/upm/iADC.hpp49
-rw-r--r--peripheral/libupm/src/upm/iCO2Sensor.hpp44
-rw-r--r--peripheral/libupm/src/upm/iHumiditySensor.hpp42
-rw-r--r--peripheral/libupm/src/upm/iLightController.hpp94
-rw-r--r--peripheral/libupm/src/upm/iLightSensor.hpp61
-rw-r--r--peripheral/libupm/src/upm/iModuleStatus.hpp53
-rw-r--r--peripheral/libupm/src/upm/iPressureSensor.hpp46
-rw-r--r--peripheral/libupm/src/upm/iTemperatureSensor.hpp42
-rw-r--r--peripheral/libupm/src/upm/interfaces.cxx1
-rw-r--r--peripheral/libupm/src/upm/javaupm_interfaces.i15
-rw-r--r--peripheral/libupm/src/upm/javaupm_light_sensor.i15
-rw-r--r--peripheral/libupm/src/upm/jsupm_interfaces.i11
-rw-r--r--peripheral/libupm/src/upm/pyupm_interfaces.i13
-rw-r--r--peripheral/libupm/src/urm37/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/urm37/javaupm_urm37.i4
-rw-r--r--peripheral/libupm/src/urm37/jsupm_urm37.i4
-rw-r--r--peripheral/libupm/src/urm37/pyupm_urm37.i4
-rw-r--r--peripheral/libupm/src/urm37/urm37.cxx2
-rw-r--r--peripheral/libupm/src/urm37/urm37.h (renamed from peripheral/libupm/src/urm37/urm37.hpp)0
-rw-r--r--peripheral/libupm/src/vcap/CMakeLists.txt22
-rw-r--r--peripheral/libupm/src/vcap/jsupm_vcap.i10
-rw-r--r--peripheral/libupm/src/vcap/pyupm_vcap.i14
-rw-r--r--peripheral/libupm/src/vcap/vcap.cxx524
-rw-r--r--peripheral/libupm/src/vcap/vcap.hpp214
-rw-r--r--peripheral/libupm/src/waterlevel/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/waterlevel/javaupm_waterlevel.i4
-rw-r--r--peripheral/libupm/src/waterlevel/jsupm_waterlevel.i4
-rw-r--r--peripheral/libupm/src/waterlevel/pyupm_waterlevel.i4
-rw-r--r--peripheral/libupm/src/waterlevel/waterlevel.cxx2
-rw-r--r--peripheral/libupm/src/waterlevel/waterlevel.h (renamed from peripheral/libupm/src/waterlevel/waterlevel.hpp)0
-rw-r--r--peripheral/libupm/src/wheelencoder/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/wheelencoder/javaupm_wheelencoder.i4
-rw-r--r--peripheral/libupm/src/wheelencoder/jsupm_wheelencoder.i4
-rw-r--r--peripheral/libupm/src/wheelencoder/pyupm_wheelencoder.i4
-rw-r--r--peripheral/libupm/src/wheelencoder/wheelencoder.cxx2
-rw-r--r--peripheral/libupm/src/wheelencoder/wheelencoder.h (renamed from peripheral/libupm/src/wheelencoder/wheelencoder.hpp)0
-rw-r--r--peripheral/libupm/src/wt5001/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/wt5001/javaupm_wt5001.i4
-rw-r--r--peripheral/libupm/src/wt5001/jsupm_wt5001.i4
-rw-r--r--peripheral/libupm/src/wt5001/pyupm_wt5001.i4
-rw-r--r--peripheral/libupm/src/wt5001/wt5001.cxx2
-rw-r--r--peripheral/libupm/src/wt5001/wt5001.h (renamed from peripheral/libupm/src/wt5001/wt5001.hpp)0
-rw-r--r--peripheral/libupm/src/xbee/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/xbee/javaupm_xbee.i4
-rw-r--r--peripheral/libupm/src/xbee/jsupm_xbee.i4
-rw-r--r--peripheral/libupm/src/xbee/pyupm_xbee.i4
-rw-r--r--peripheral/libupm/src/xbee/xbee.cxx2
-rw-r--r--peripheral/libupm/src/xbee/xbee.h (renamed from peripheral/libupm/src/xbee/xbee.hpp)0
-rw-r--r--peripheral/libupm/src/yg1006/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/yg1006/javaupm_yg1006.i4
-rw-r--r--peripheral/libupm/src/yg1006/jsupm_yg1006.i4
-rw-r--r--peripheral/libupm/src/yg1006/pyupm_yg1006.i4
-rw-r--r--peripheral/libupm/src/yg1006/yg1006.cxx2
-rw-r--r--peripheral/libupm/src/yg1006/yg1006.h (renamed from peripheral/libupm/src/yg1006/yg1006.hpp)0
-rw-r--r--peripheral/libupm/src/zfm20/CMakeLists.txt2
-rw-r--r--peripheral/libupm/src/zfm20/javaupm_zfm20.i4
-rw-r--r--peripheral/libupm/src/zfm20/jsupm_zfm20.i5
-rw-r--r--peripheral/libupm/src/zfm20/pyupm_zfm20.i5
-rw-r--r--peripheral/libupm/src/zfm20/zfm20.cxx2
-rw-r--r--peripheral/libupm/src/zfm20/zfm20.h (renamed from peripheral/libupm/src/zfm20/zfm20.hpp)0
-rw-r--r--peripheral/sensors/mraa/sensors/GroveLight.hpp2
-rw-r--r--peripheral/sensors/mraa/sensors/GroveTemperature.hpp2
-rw-r--r--peripheral/sensors/mraa/sensors/LSM9DS0Accelerometer.hpp2
-rw-r--r--peripheral/sensors/mraa/sensors/MMA7660Accelerometer.hpp2
-rw-r--r--peripheral/sensors/mraa/sensors/MPU9150Accelerometer.hpp2
-rw-r--r--peripheral/sensors/mraa/sensors/ProximityGPIO.hpp2
1373 files changed, 2229 insertions, 71467 deletions
diff --git a/peripheral/libupm/.travis.yml b/peripheral/libupm/.travis.yml
index 364e612..6075524 100644
--- a/peripheral/libupm/.travis.yml
+++ b/peripheral/libupm/.travis.yml
@@ -1,46 +1,21 @@
language: cpp
-env:
- global:
- - MRAA_ROOT=/tmp/mraa
- - MRAA_BUILD=$MRAA_ROOT/build
- - MRAA_INSTALL=$MRAA_ROOT/install
- - UPM_ROOT=$TRAVIS_BUILD_DIR
- - UPM_BUILD=$UPM_ROOT/build
- - UPM_INSTALL=$UPM_ROOT/install
- - JAVA_HOME=/usr/lib/jvm/java-8-oracle
- matrix:
- - NODE010=true
- - NODE012=true
- - NODE4=true
- - NODE5=true
compiler:
- - clang
- gcc
+ - clang
install:
+ - sudo add-apt-repository --yes ppa:kalakris/cmake
- sudo add-apt-repository --yes ppa:fenics-packages/fenics-exp/swig
- sudo apt-get update -qq
- - sudo apt-get install -y -qq swig3.0 git
+ - sudo apt-get install -y -qq swig3.0 python git cmake
- sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
- sudo update-java-alternatives -s java-8-oracle
before_script:
- # Turn off JAVA SWIG for clang++, use 4.8 for all g++ builds
- - if [ "$CC" == "gcc" ]; then export BUILDJAVA=ON; export CC=gcc-4.8; export CXX=g++-4.8; else export BUILDJAVA=OFF; fi
- - if [ "${NODE012}" ]; then nvm install 0.12; fi
- - if [ "${NODE4}" ]; then nvm install 4.1; fi
- - if [ "${NODE5}" ]; then nvm install 5; fi
- # Handle 0.10 NODE_ROOT_DIR differently than other versions
- - if [ -z ${NODE010} ]; then export NODE_ROOT_DIR="/home/travis/.nvm/versions/node/`nvm version`"; else export NODE_ROOT_DIR=/home/travis/.nvm/v0.10.36; fi
+ - if [ "$CC" = "gcc" ]; then export BUILDJAVA=ON; else export BUILDJAVA=OFF; fi
+ - export JAVA_HOME=/usr/lib/jvm/java-8-oracle
script:
- - echo "CC=$CC BUILDJAVA=$BUILDJAVA NODE010=$NODE010 NODE012=$NODE012 NODE4=$NODE4 NODE5=$NODE5 NODE_ROOT_DIR=$NODE_ROOT_DIR"
- - git clone https://github.com/intel-iot-devkit/mraa.git $MRAA_ROOT
- - mkdir -p $MRAA_BUILD && cd $_ && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDSWIGNODE=OFF -DBUILDSWIGPYTHON=OFF -DFIRMATA=ON -DENABLEEXAMPLES=OFF -DCMAKE_INSTALL_PREFIX:PATH=$MRAA_INSTALL $MRAA_ROOT && make install
- - cd $UPM_ROOT && mkdir $UPM_BUILD && cd $_ && PKG_CONFIG_PATH=$MRAA_INSTALL/lib/pkgconfig cmake -DNODE_ROOT_DIR:PATH="${NODE_ROOT_DIR}" -DBUILDSWIGJAVA=$BUILDJAVA -DBUILDEXAMPLES=ON -DBUILDJAVAEXAMPLES=$BUILDJAVA -DCMAKE_INSTALL_PREFIX:PATH=$UPM_INSTALL .. && make install
-addons:
- apt:
- sources:
- - ubuntu-toolchain-r-test
- - george-edison55-precise-backports
- packages:
- - cmake
- - cmake-data
- - g++-4.8
+ - git clone --branch=master https://github.com/intel-iot-devkit/mraa.git
+ - cd mraa && mkdir build && cd build && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DENABLEEXAMPLES=OFF -DCMAKE_INSTALL_PREFIX:PATH=. -DNODE_ROOT_DIR:PATH=/home/travis/.nvm/v0.10.36/include .. && make && make install
+ - export PKG_CONFIG_PATH=$PWD/lib/pkgconfig:$PWD/lib/x86_64-linux-gnu/pkgconfig
+ - export CPLUS_INCLUDE_PATH=$PWD/include
+ - export LIBRARY_PATH=$PWD/lib:$PWD/lib/x86_64-linux-gnu
+ - cd ../.. && mkdir build && cd build && cmake -DBUILDSWIGJAVA=$BUILDJAVA -DNODE_ROOT_DIR:PATH=/home/travis/.nvm/v0.10.36/include -DBUILDEXAMPLES=ON -DBUILDJAVAEXAMPLES=$BUILDJAVA .. && make
diff --git a/peripheral/libupm/Android.mk b/peripheral/libupm/Android.mk
index 2c6ed1e..2e73037 100644
--- a/peripheral/libupm/Android.mk
+++ b/peripheral/libupm/Android.mk
@@ -40,30 +40,9 @@ LIBUPM_CXX_FILE_LIST := $(filter-out %ssd1351.cxx, $(LIBUPM_CXX_FILE_LIST))
LIBUPM_CXX_FILE_LIST := $(filter-out %st7735.cxx, $(LIBUPM_CXX_FILE_LIST))
LIBUPM_CXX_FILE_LIST := $(filter-out %ili9341.cxx, $(LIBUPM_CXX_FILE_LIST))
LIBUPM_CXX_FILE_LIST := $(filter-out %gfx.cxx, $(LIBUPM_CXX_FILE_LIST))
-
-# drivers dependent on the BACnet stack
-LIBUPM_CXX_FILE_LIST := $(filter-out %bacnetmstp.cxx, $(LIBUPM_CXX_FILE_LIST))
-LIBUPM_CXX_FILE_LIST := $(filter-out %e50hx.cxx, $(LIBUPM_CXX_FILE_LIST))
-LIBUPM_CXX_FILE_LIST := $(filter-out %bacnetutil.cxx, $(LIBUPM_CXX_FILE_LIST))
-LIBUPM_CXX_FILE_LIST := $(filter-out %tb7300.cxx, $(LIBUPM_CXX_FILE_LIST))
-LIBUPM_CXX_FILE_LIST := $(filter-out %t8100.cxx, $(LIBUPM_CXX_FILE_LIST))
-
-# drivers dependent on the modbus library
-LIBUPM_CXX_FILE_LIST := $(filter-out %h803x.cxx, $(LIBUPM_CXX_FILE_LIST))
-
-# drivers dependent on the jpeg library
-LIBUPM_CXX_FILE_LIST := $(filter-out %vcap.cxx, $(LIBUPM_CXX_FILE_LIST))
-
-# keep a single implementation of MraaUtils class
-LIBUPM_CXX_FILE_LIST := $(filter-out %ds1808lc/mraa-utils.cxx, $(LIBUPM_CXX_FILE_LIST))
-LIBUPM_CXX_FILE_LIST := $(filter-out %si7005/mraa-utils.cxx, $(LIBUPM_CXX_FILE_LIST))
-LIBUPM_CXX_FILE_LIST := $(filter-out %hlg150h/mraa-utils.cxx, $(LIBUPM_CXX_FILE_LIST))
-
LOCAL_SRC_FILES := $(LIBUPM_CXX_FILE_LIST)
-LOCAL_SRC_FILES += src/bmi160/bosch_bmi160.c
LOCAL_C_INCLUDES := $(sort $(dir $(wildcard $(LOCAL_PATH)/src/*/)))
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/src/
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_C_INCLUDES)
diff --git a/peripheral/libupm/CMakeLists.txt b/peripheral/libupm/CMakeLists.txt
index fbab828..0a6f4fc 100644
--- a/peripheral/libupm/CMakeLists.txt
+++ b/peripheral/libupm/CMakeLists.txt
@@ -10,22 +10,22 @@ find_package (PkgConfig REQUIRED)
# Force a libmraa search and minimum required version every time a config is generated
unset(MRAA_FOUND CACHE)
-pkg_check_modules (MRAA REQUIRED mraa>=1.1.1)
+pkg_check_modules (MRAA REQUIRED mraa>=0.9.1)
message (INFO " found mraa version: ${MRAA_VERSION}")
# Appends the cmake/modules path to MAKE_MODULE_PATH variable.
set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
+set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation path for libraries")
-# Set CMAKE_INSTALL_LIBDIR if not defined
+# Set CMAKE_LIB_INSTALL_DIR if not defined
include(GNUInstallDirs)
-set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation path for libraries")
# Make a version file containing the current version from git.
include (GetGitRevisionDescription)
git_describe (VERSION "--tags")
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_-128-NOTFOUND")
message (WARNING " - Install git to compile a production UPM!")
- set (VERSION "v0.7.2-dirty")
+ set (VERSION "v0.5.1-dirty")
endif ()
message (INFO " - UPM Version ${VERSION}")
@@ -51,15 +51,13 @@ set (CMAKE_SWIG_FLAGS "")
option (BUILDDOC "Build all doc." OFF)
option (BUILDSWIG "Build swig modules." ON)
option (BUILDSWIGPYTHON "Build swig python modules." ON)
-option (BUILDPYTHON3 "Use python3 for building/installing/testing" OFF)
option (BUILDSWIGNODE "Build swig node modules." ON)
option (BUILDEXAMPLES "Build C++ example binaries" OFF)
option (BUILDJAVAEXAMPLES "Build java example jars" OFF)
option (BUILDSWIGJAVA "Build swig java modules" OFF)
option (IPK "Generate IPK using CPack" OFF)
option (RPM "Generate RPM using CPack" OFF)
-option (BUILDTESTS "Generate check-ups for upm" ON)
-option (ENABLECXX11 "Enable C++11 standards support" ON)
+option (BUILDTESTS "Generate check-ups for upm" OFF)
# Find swig
if (BUILDSWIG)
@@ -78,32 +76,6 @@ include (TargetArch)
target_architecture (DETECTED_ARCH)
message( INFO " - Target arch is ${DETECTED_ARCH}")
-#-march=native for ARM when not defined/forced
-if (DETECTED_ARCH MATCHES "arm.*" AND NOT CMAKE_CXX_FLAGS MATCHES "-march")
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
-endif()
-
-# enable c++11 standards support
-if (ENABLECXX11)
- include(CheckCXXCompilerFlag)
- if (CMAKE_VERSION VERSION_LESS "3.1")
- CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
- CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
- if (COMPILER_SUPPORTS_CXX11)
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
- elseif (COMPILER_SUPPORTS_CXX0X)
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
- else()
- message(WARNING "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please update your C++ compiler.")
- endif()
- else()
- # 3.1+ uses this generic method to enable c++11
- set (CMAKE_CXX_STANDARD 11)
- endif()
-else()
- message(WARNING "Some modules require C++11 support, and may not build without it.")
-endif()
-
if (BUILDDOC)
# Add a target to generate API documentation with Doxygen
find_package (Doxygen)
@@ -127,10 +99,11 @@ if (BUILDDOC)
find_package (Sphinx)
if(SPHINX_FOUND AND BUILDSWIG AND BUILDSWIGPYTHON)
# Python required for Sphinx build
- find_package (PythonLibs ${PYTHONBUILD_VERSION} REQUIRED)
+ find_package (PythonLibs)
string (REPLACE "." ";" PYTHON_VERSION_LIST ${PYTHONLIBS_VERSION_STRING})
list (GET PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR)
list (GET PYTHON_VERSION_LIST 1 PYTHON_VERSION_MINOR)
+ set (SITE_PACKAGES ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/pydoc/conf.py @ONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/index.rst ${CMAKE_CURRENT_BINARY_DIR}/pydoc/index.rst COPYONLY)
add_custom_target (pydoc ALL
@@ -157,9 +130,9 @@ if (BUILDDOC)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxy/node/${JSDOC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${JSDOC_FILE} COPYONLY)
endforeach()
add_custom_target(jsdoc ALL
- COMMAND ${NODEJS_EXECUTABLE} docgen -m upm -i xml -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../
+ COMMAND ${NODE_EXECUTABLE} docgen -m upm -i xml -t ${CMAKE_CURRENT_SOURCE_DIR}/src -g ../../
COMMAND ${YUIDOC_EXECUTABLE} -C --no-sort --helpers generators/yuidoc/helper.js --themedir generators/yuidoc/tmpl -o html/node jsdoc/yuidoc/upm
- COMMAND ${NODEJS_EXECUTABLE} tolower -i html/node
+ COMMAND ${NODE_EXECUTABLE} tolower -i html/node
DEPENDS doc
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Yuidoc" VERBATIM
@@ -183,7 +156,7 @@ if (IPK)
endif ()
message (INFO " - Package arch is ${TARGET_ARCH}")
- set(CPACK_GENERATOR "DEB")
+ set(CPACK_GENERATOR "DEB" "TGZ")
set(OPKG_ARCH ${TARGET_ARCH})
set(CPACK_BINARY_DIR ${CMAKE_BINARY_DIR})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Intel IoT-Devkit") #required
@@ -209,28 +182,26 @@ if (RPM)
message (INFO " - RPM packaging enabled for ${DETECTED_ARCH}")
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_GENERATOR "RPM")
- set(CPACK_PACKAGE_NAME "upm")
- set(upm_PACKAGE_ON_TAG ".")
- if ("${VERSION_COMMIT}" STREQUAL "")
- set(upm_PACKAGE_ON_TAG "")
- endif()
+ set(CPACK_PACKAGE_NAME "libupm${upm_VERSION_MAJOR}")
+ set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_PACKAGE_VERSION
- "${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
+ "${upm_VERSION_MAJOR}.${upm_VERSION_MINOR}.${upm_VERSION_PATCH}-${upm_PACKAGE_ON_TAG}${VERSION_COMMIT}")
set(CPACK_PACKAGE_CONTACT "Intel IoT-Devkit")
set(CPACK_PACKAGE_VENDOR "Intel IoT-Devkit")
set(CPACK_RPM_PACKAGE_REQUIRES "mraa >= ${MRAA_VERSION}")
set(CPACK_RPM_PACKAGE_PROVIDES "${CPACK_PACKAGE_NAME}-devel")
- set(CPACK_RPM_PACKAGE_LICENSE "MIT")
EXECUTE_PROCESS(COMMAND rpm --showrc
COMMAND grep -E "dist[[:space:]]*\\."
COMMAND sed -e "s/^.*dist\\s*\\.//"
COMMAND tr \\n \\t
COMMAND sed -e s/\\t//
OUTPUT_VARIABLE DIST_TAG)
- set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${DIST_TAG}.${DETECTED_ARCH}")
+ set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${DIST_TAG}.${DETECTED_ARCH}")
include(CPack)
endif()
+add_subdirectory (src)
+
if(BUILDEXAMPLES)
add_subdirectory (examples/c++)
endif()
@@ -239,18 +210,10 @@ if(BUILDJAVAEXAMPLES)
add_subdirectory (examples/java)
endif()
-if (BUILDSWIGPYTHON OR BUILDTESTS)
- if (BUILDPYTHON3)
- set (PYTHONBUILD_VERSION 3)
- else ()
- set (PYTHONBUILD_VERSION 2.7)
- endif ()
-endif ()
-
-add_subdirectory (src)
-
-if (BUILDTESTS)
- find_package (PythonInterp ${PYTHONBUILD_VERSION} REQUIRED)
- enable_testing ()
- add_subdirectory (tests)
+if(BUILDTESTS)
+ find_package (PythonInterp REQUIRED)
+ if (${PYTHONINTERP_FOUND})
+ enable_testing ()
+ add_subdirectory (tests)
+ endif ()
endif()
diff --git a/peripheral/libupm/README.md b/peripheral/libupm/README.md
index f462d1b..e7ccd02 100644
--- a/peripheral/libupm/README.md
+++ b/peripheral/libupm/README.md
@@ -1,29 +1,16 @@
UPM (Useful Packages & Modules) Sensor/Actuator repository for MRAA
==============
-The UPM repository provides software drivers for a wide variety of commonly
-used sensors and actuators. These software drivers interact with the
-underlying hardware platform (or microcontroller), as well as with the attached
-sensors, through calls to [MRAA](https://github.com/intel-iot-devkit/mraa) APIs.
-
-Programmers can access the interfaces for each sensor by including the sensor’s
-corresponding header file and instantiating the associated sensor class. In the
-typical use case, a constructor initializes the sensor based on parameters that
-identify the sensor, the I/O protocol used and the pin location of the sensor.
-
-C++ interfaces have been defined for the following sensor/actuator types, but
-they are subject to change:
-
-* Light controller
-* Light sensor
-* Temperature sensor
-* Humidity sensor
-* Pressure sensor
-* Gas sensor
-* Analog to digital converter
-
-The developer community is encouraged to help expand the list of supported
-sensors and actuators and provide feedback on interface design.
+UPM is a high level repository for sensors that use MRAA. Each sensor links
+to MRAA and are not meant to be interlinked although some groups of sensors
+may be. Each sensor contains a header which allows to interface with it.
+Typically a sensor is represented as a class and instantiated.
+
+The constructor is expected to initialise the sensor and parameters may be used
+to provide identification/pin location on the board.
+
+Typically an update() function will be called in order to get new data from the
+sensor in order to reduce load when doing multiple reads to sensor data.
### Example
@@ -64,6 +51,10 @@ A sensor/actuator is expected to work as such (here is the MMA7660 accelerometer
}
```
+However implementation and API design is completely up to the developer, some
+enumerable sensors for example may provide much clever instantiation. Displays
+may also create more complex structures in order to interface with them.
+
Browse through the list of all [examples](https://github.com/intel-iot-devkit/upm/tree/master/examples).
Multi-sensor samples for the starter and specialized kits can be found in the
@@ -90,7 +81,7 @@ See building documentation [here](docs/building.md).
Porting [link](docs/porting.md) has more information on making new UPM modules.
-There is also an example available gfor max31855 [sensor](docs/max31855.md).
+There is also an example available for max31855 [sensor](docs/max31855.md).
Guide on creating Java [bindings](docs/creating_java_bindings.md).
@@ -114,14 +105,6 @@ API Documentation
<a href="http://iotdk.intel.com/docs/master/upm/python"><img src="docs/icons/python.png"/></a>
<a href="http://iotdk.intel.com/docs/master/upm/node"><img src="docs/icons/node.png"/></a>
-### API Compatibility
-Even if we try our best not to, every once in a while we are forced to modify
-our API in a way that will break backwards compatibility. If you find yourself
-unable to compile code that was working fine before a library update, make sure
-you check the [API changes](docs/apichanges.md) section first.
-
-**NOTE** - Our **C++ header files** changed extension from *.h* to *.hpp*!
-
### Changelog
Version changelog [here](docs/changelog.md).
diff --git a/peripheral/libupm/cmake/modules/FindNode.cmake b/peripheral/libupm/cmake/modules/FindNode.cmake
index c59cbed..7501a16 100644
--- a/peripheral/libupm/cmake/modules/FindNode.cmake
+++ b/peripheral/libupm/cmake/modules/FindNode.cmake
@@ -1,12 +1,4 @@
- # Macro to add directory to NODEJS_INCLUDE_DIRS if it exists and is not /usr/include
- macro(add_include_dir dir)
- if (IS_DIRECTORY ${dir} AND NOT ${dir} STREQUAL "/usr/include")
- set(NODEJS_INCLUDE_DIRS ${NODEJS_INCLUDE_DIRS} ${dir})
- endif()
-endmacro()
-
-
-find_program (NODEJS_EXECUTABLE NAMES node nodejs
+find_program (NODE_EXECUTABLE NAMES node
HINTS
$ENV{NODE_DIR}
PATH_SUFFIXES bin
@@ -15,50 +7,26 @@ find_program (NODEJS_EXECUTABLE NAMES node nodejs
include (FindPackageHandleStandardArgs)
-# If compat-libuv package exists, it must be at start of include path
-find_path (UV_ROOT_DIR "uv.h" PATHS /usr/include/compat-libuv010 NO_DEFAULT_PATH)
-if (UV_ROOT_DIR)
- # set (NODEJS_INCLUDE_DIRS ${UV_ROOT_DIR})
- add_include_dir(${UV_ROOT_DIR})
-endif()
-
-# Now look for node. Flag an error if not found
-find_path (NODE_ROOT_DIR "include/node/node.h" "include/src/node.h"
- PATHS /usr/include/nodejs /usr/local/include/nodejs /usr/local/include)
-if (NODE_ROOT_DIR)
- add_include_dir(${NODE_ROOT_DIR}/include/src)
- add_include_dir(${NODE_ROOT_DIR}/include/node)
- add_include_dir(${NODE_ROOT_DIR}/include/deps/v8/include)
- add_include_dir(${NODE_ROOT_DIR}/include/deps/uv/include)
-else()
- unset(NODEJS_INCLUDE_DIRS)
- message(ERROR " - node.h not found")
-endif()
+find_path (NODE_ROOT_DIR "node/node.h" "src/node.h"
+ PATHS /usr/include/nodejs /usr/local/include/nodejs)
-# Check that v8.h is in NODEJS_INCLUDE_DIRS
-find_path (V8_ROOT_DIR "v8.h" PATHS ${NODEJS_INCLUDE_DIRS})
-if (NOT V8_ROOT_DIR)
- unset(NODEJS_INCLUDE_DIRS)
- message(ERROR " - v8.h not found")
-endif()
-
-# Check that uv.h is in NODEJS_INCLUDE_DIRS
-find_path (UV_ROOT_DIR "uv.h" PATHS ${NODEJS_INCLUDE_DIRS})
-if (NOT UV_ROOT_DIR)
- unset(NODEJS_INCLUDE_DIRS)
- message(ERROR " - uv.h not found")
-endif()
+set (NODE_INCLUDE_DIRS
+ ${NODE_ROOT_DIR}/src
+ ${NODE_ROOT_DIR}/node
+ ${NODE_ROOT_DIR}/deps/v8/include
+ ${NODE_ROOT_DIR}/deps/uv/include
+)
-find_package_handle_standard_args (Nodejs DEFAULT_MSG
- NODEJS_EXECUTABLE
- NODEJS_INCLUDE_DIRS
+find_package_handle_standard_args (Node DEFAULT_MSG
+ NODE_EXECUTABLE
+ NODE_INCLUDE_DIRS
)
-if (NODEJS_EXECUTABLE)
- execute_process(COMMAND ${NODEJS_EXECUTABLE} --version
+if (NODE_EXECUTABLE)
+ execute_process(COMMAND ${NODE_EXECUTABLE} --version
OUTPUT_VARIABLE _VERSION
RESULT_VARIABLE _NODE_VERSION_RESULT)
- execute_process(COMMAND ${NODEJS_EXECUTABLE} -e "console.log(process.versions.v8)"
+ execute_process(COMMAND ${NODE_EXECUTABLE} -e "console.log(process.versions.v8)"
OUTPUT_VARIABLE _V8_VERSION
RESULT_VARIABLE _V8_RESULT)
if (NOT _NODE_VERSION_RESULT AND NOT _V8_RESULT)
@@ -87,11 +55,7 @@ if (NODEJS_EXECUTABLE)
set (V8_VERSION_STRING "3.28.72")
message ("defaulted to node 0.10.30")
endif ()
- string (REGEX REPLACE "\n" "" NODE_VERSION_STRING ${NODE_VERSION_STRING})
- string (REGEX REPLACE "\n" "" V8_VERSION_STRING ${V8_VERSION_STRING})
- message ("INFO - Node version is " ${NODE_VERSION_STRING})
- message ("INFO - Node using v8 " ${V8_VERSION_STRING})
- mark_as_advanced (NODEJS_EXECUTABLE)
+ message ("INFO - Node version is " ${NODE_VERSION_STRING} "INFO - Node using v8 " ${V8_VERSION_STRING})
endif ()
-mark_as_advanced (NODEJS_EXECUTABLE)
+mark_as_advanced (NODE_EXECUTABLE)
diff --git a/peripheral/libupm/docs/apichanges.md b/peripheral/libupm/docs/apichanges.md
deleted file mode 100644
index fe23e29..0000000
--- a/peripheral/libupm/docs/apichanges.md
+++ /dev/null
@@ -1,15 +0,0 @@
-API Changes {#apichanges}
-===============
-
-Here's a list of other API changes made to the library that break source/binary
-compatibility between releases:
-
- * Our **C++ header files** changed their extension from *.h* to *.hpp* in
- version 0.7.0, Intel provided examples and code samples also reflect this
- change but you will need to modify your `#include` directives in existing code
- * **my9221**, **groveledbar** and **grovecircularled** are now all part of the
- same library (my9221) and new functionality was added going to v.0.5.1
- * **stepmotor** driver API was changed significantly from v.0.4.1 to v.0.5.0
- * **eboled** library was greatly improved in version 0.4.0 and the `draw()`
- function was removed in favor of a more complete GFX library implementation
- \ No newline at end of file
diff --git a/peripheral/libupm/docs/changelog.md b/peripheral/libupm/docs/changelog.md
index 244f7ca..40630a6 100644
--- a/peripheral/libupm/docs/changelog.md
+++ b/peripheral/libupm/docs/changelog.md
@@ -4,61 +4,6 @@ Changelog {#changelog}
Here's a list summarizing some of the key undergoing changes to our library
from earlier versions:
-### v0.7.2
-
- * Mraa 1.1.1 required changes to UPM drivers and examples for IIO core
- kernel support
- * Rev'ed libmraa requirement to 1.1.1
-
-### v0.7.1
-
- * Fix for building python2 vs python3 bindings
- * Fixes for jhd1313m1 row/font size and reset
- * Added bacnet utility class
- * New sensors: bmx055, bmi055, bmc160, bma250e, bmg150, bmm150, t8100, tb7300
-
-### v0.7.0
-
- * C++ header files have been renamed from *.h to *.hpp along with all Intel
- provided examples and code samples to allow for native C drivers
- * Updated driver compatibility to new MRAA 1.0 API
- * First sensor implementations for our newly added Dallas One Wire support
- * Several fixes based on issues reported on Github
- * Changed SWIG linking strategy, more robust Travis CI build checks
- * New sensors: ds2413, ds18b20, bmp280, bno055, l3gd20
-
-### v0.6.2
-
- * Added a generic driver for taking snapshots from an USB camera device
- * New API changes section in documentation to let users know when the UPM API
- gets modified
- * Fixed some spelling errors and improved JavaScript documentation builds with
- newer versions of YUI and Node
- * Enhanced Cmake scripts and the build process
- * New sensors: vcap, e50hx
-
-### v0.6.1
-
- * Fixed library build process for different configurations across multiple
- environments reported by users.
- * Fixed multiple GFX library header clash and improved SSD1351 compatibility
- by changing SPI mode
- * Added Node and Python array typemaps for nrf24l01
- * Added 2 new JAVA examples
-
-### v0.6.0
-
- * Introduced C++ Interfaces for several sensor categories that will help
- consolidate the sensor APIs with uniform function names upon implementation
- * Greatly improved Node.js detection and handling during build and install,
- and should be now compatible with all major versions
- * Added a driver for the Curie IMU (accelerometer + gyroscope) that works with
- the new Firmata support implemented by MRAA
- * Continued to provide several JAVA fixes and examples
- * Many new industrial and maker sensors: cwlsxxa, teams, tex00, h803x, apa102,
- smartdrive, bmi160, bme280, ds1808lc, hlg150, lp8860, max44009, si1132, t6713,
- si7005, ssd1351
-
### v0.5.1
* Updated the API and added new functionality for the MY9221 class and derived
diff --git a/peripheral/libupm/docs/images/apa102.jpg b/peripheral/libupm/docs/images/apa102.jpg
deleted file mode 100644
index 43395e3..0000000
--- a/peripheral/libupm/docs/images/apa102.jpg
+++ /dev/null
Binary files differ
diff --git a/peripheral/libupm/docs/max31855.md b/peripheral/libupm/docs/max31855.md
index 7a6a22b..7405989 100644
--- a/peripheral/libupm/docs/max31855.md
+++ b/peripheral/libupm/docs/max31855.md
@@ -13,7 +13,7 @@ This is a spi module so we will use the mraa spi functions to build our module.
First thing to do is to create a tree structure like this in upm/src/max31855:
* max31855.cxx
-* max31855.hpp
+* max31855.h
* jsupm_max31855.i
* pyupm_max31855.i
* CMakeLists.txt
@@ -36,11 +36,11 @@ used swig wrappers for UPM sensors, it's not obligatory but recommended.
### API
-Then we create the header (max31855.hpp) , a very simple header in our case we
+Then we create the header (max31855.h) , a very simple header in our case we
will have only a very basic api. We provide a getTemp() function which will
return the same type as in the arduino library, a double.
-@snippet max31855.hpp Interesting
+@snippet max31855.h Interesting
Note that the header contains both the io that we will use, the gpio is in this
case used as the chip select pin.
diff --git a/peripheral/libupm/docs/porting.md b/peripheral/libupm/docs/porting.md
index e7ecd16..a75041a 100644
--- a/peripheral/libupm/docs/porting.md
+++ b/peripheral/libupm/docs/porting.md
@@ -14,16 +14,16 @@ example is explained in detail on @ref max31855
### CmakeLists.txt
-By default you need a header called modulename.hpp and a C++ file called
+By default you need a header called modulename.h and a C++ file called
modulename.cxx. You can have multiple headers and source files. Only public
-headers need to be added to module_hpp and all source files need to be in
+headers need to be added to module_h and all source files need to be in
module_src.
~~~~~~~~~~~
set (libname "modulename")
set (libdescription "Module Description")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
~~~~~~~~~~~
diff --git a/peripheral/libupm/doxy/Doxyfile.in b/peripheral/libupm/doxy/Doxyfile.in
index 6db46fe..83db5af 100644
--- a/peripheral/libupm/doxy/Doxyfile.in
+++ b/peripheral/libupm/doxy/Doxyfile.in
@@ -859,10 +859,7 @@ EXCLUDE_SYMLINKS = NO
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/*
-# bmi160 driver contains code provided by bosch. This source contains
-# tags which are picked up by doxygen (namely \mainpage) and
-# incorrectly get added to docs.
-EXCLUDE_PATTERNS = bosch_*
+EXCLUDE_PATTERNS =
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
diff --git a/peripheral/libupm/doxy/samples.mapping.txt b/peripheral/libupm/doxy/samples.mapping.txt
index 78e5773..db7c4c7 100644
--- a/peripheral/libupm/doxy/samples.mapping.txt
+++ b/peripheral/libupm/doxy/samples.mapping.txt
@@ -48,7 +48,7 @@ mpu9150.cxx MPU9150Sample.java
mq2.cxx MQ2Sample.java
mq303a.cxx MQ303ASample.java
mq5.cxx MQ5Sample.java
-groveledbar GroveLEDBar
+my9221-ledbar.cxx MY9221_ledbarSample.java
nrf24l01-receiver.cxx NRF24L01_receiverSample.java
nrf24l01-transmitter.cxx NRF24L01_transmitterSample.java
nunchuck.cxx NUNCHUCKSample.java
diff --git a/peripheral/libupm/examples/c++/CMakeLists.txt b/peripheral/libupm/examples/c++/CMakeLists.txt
index ed367b3..b227703 100644
--- a/peripheral/libupm/examples/c++/CMakeLists.txt
+++ b/peripheral/libupm/examples/c++/CMakeLists.txt
@@ -234,44 +234,12 @@ if (MODBUS_FOUND)
include_directories(${MODBUS_INCLUDE_DIRS})
add_example (t3311)
add_example (hwxpxx)
- add_example (h803x)
endif()
add_example (hdxxvxta)
add_example (rhusb)
add_example (apds9930)
add_example (kxcjk1013)
add_example (ssd1351)
-add_example (ds1808lc)
-add_example (hlg150h)
-add_example (lp8860)
-add_example (max44009)
-add_example (si1132)
-add_example (si7005)
-add_example (t6713)
-add_example (cwlsxxa)
-add_example (teams)
-add_example (apa102)
-add_example (tex00)
-add_example (bmi160)
-add_example (smartdrive)
-if (HAVE_FIRMATA)
- add_example (curieimu)
-endif ()
-if (BACNET_FOUND)
- include_directories(${BACNET_INCLUDE_DIRS})
- # we need access to bacnetmstp headers too
- include_directories(${PROJECT_SOURCE_DIR}/src/bacnetmstp)
- add_example (e50hx)
- add_example (t8100)
- add_example (tb7300)
-endif()
-add_example (vcap)
-add_example (ds2413)
-add_example (ds18b20)
-add_example (bmp280)
-add_example (bno055)
-add_example (l3gd20)
-add_example (bmx055)
# These are special cases where you specify example binary, source file and module(s)
include_directories (${PROJECT_SOURCE_DIR}/src)
@@ -290,16 +258,3 @@ add_custom_example (ak8975-example ak8975.cxx mpu9150)
add_custom_example (mpu9250-example mpu9250.cxx mpu9150)
add_custom_example (groveledbar-example groveledbar.cxx my9221)
add_custom_example (grovecircularled-example grovecircularled.cxx my9221)
-add_custom_example (temperature-sensor-example temperature-sensor.cxx "si7005;bmpx8x;bme280")
-add_custom_example (humidity-sensor-example humidity-sensor.cxx "si7005;bme280")
-add_custom_example (pressure-sensor-example pressure-sensor.cxx "bmpx8x;bme280")
-add_custom_example (co2-sensor-example co2-sensor.cxx "t6713")
-add_custom_example (adc-example adc-sensor.cxx "ads1x15")
-add_custom_example (light-sensor-example light-sensor.cxx "si1132;max44009")
-add_custom_example (light-controller-example light-controller.cxx "lp8860;ds1808lc;hlg150h")
-add_custom_example (bme280-example bme280.cxx bmp280)
-add_custom_example (bma250e-example bma250e.cxx bmx055)
-add_custom_example (bmg160-example bmg160.cxx bmx055)
-add_custom_example (bmm150-example bmm150.cxx bmx055)
-add_custom_example (bmc150-example bmc150.cxx bmx055)
-add_custom_example (bmi055-example bmi055.cxx bmx055)
diff --git a/peripheral/libupm/examples/c++/a110x-intr.cxx b/peripheral/libupm/examples/c++/a110x-intr.cxx
index 93b2a49..187c2ed 100644
--- a/peripheral/libupm/examples/c++/a110x-intr.cxx
+++ b/peripheral/libupm/examples/c++/a110x-intr.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "a110x.hpp"
+#include "a110x.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/a110x.cxx b/peripheral/libupm/examples/c++/a110x.cxx
index 0344ac3..30c355d 100644
--- a/peripheral/libupm/examples/c++/a110x.cxx
+++ b/peripheral/libupm/examples/c++/a110x.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "a110x.hpp"
+#include "a110x.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ad8232.cxx b/peripheral/libupm/examples/c++/ad8232.cxx
index c07094b..5d03527 100644
--- a/peripheral/libupm/examples/c++/ad8232.cxx
+++ b/peripheral/libupm/examples/c++/ad8232.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "ad8232.hpp"
+#include "ad8232.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/adafruitms1438-stepper.cxx b/peripheral/libupm/examples/c++/adafruitms1438-stepper.cxx
index 41a5f88..1bcf75b 100644
--- a/peripheral/libupm/examples/c++/adafruitms1438-stepper.cxx
+++ b/peripheral/libupm/examples/c++/adafruitms1438-stepper.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "adafruitms1438.hpp"
+#include "adafruitms1438.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/adafruitms1438.cxx b/peripheral/libupm/examples/c++/adafruitms1438.cxx
index 1a94e17..8ca184c 100644
--- a/peripheral/libupm/examples/c++/adafruitms1438.cxx
+++ b/peripheral/libupm/examples/c++/adafruitms1438.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "adafruitms1438.hpp"
+#include "adafruitms1438.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/adafruitss.cxx b/peripheral/libupm/examples/c++/adafruitss.cxx
index 7e9f68d..f2a7ebf 100644
--- a/peripheral/libupm/examples/c++/adafruitss.cxx
+++ b/peripheral/libupm/examples/c++/adafruitss.cxx
@@ -33,7 +33,7 @@
*/
#include <iostream>
-#include "adafruitss.hpp"
+#include "adafruitss.h"
#include <unistd.h>
using namespace std;
diff --git a/peripheral/libupm/examples/c++/adc-sensor.cxx b/peripheral/libupm/examples/c++/adc-sensor.cxx
deleted file mode 100644
index b367086..0000000
--- a/peripheral/libupm/examples/c++/adc-sensor.cxx
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include "ads1015.hpp"
-#include "mraa/gpio.hpp"
-
-#define EDISON_I2C_BUS 1
-#define FT4222_I2C_BUS 0
-#define EDISON_GPIO_SI7005_CS 20
-
-
-//! [Interesting]
-// Simple example of using IADC to determine
-// which sensor is present and return its name.
-// IADC is then used to get readings from sensor
-
-
-upm::IADC* getADC()
-{
- upm::IADC* adc = NULL;
- try {
- adc = new upm::ADS1015(EDISON_I2C_BUS);
- mraa::Gpio gpio(EDISON_GPIO_SI7005_CS);
- gpio.dir(mraa::DIR_OUT_HIGH);
- return adc;
- } catch (std::exception& e) {
- std::cerr << "ADS1015: " << e.what() << std::endl;
- }
- return adc;
-}
-
-int main ()
-{
- upm::IADC* adc = getADC();
- if (adc == NULL) {
- std::cout << "ADC not detected" << std::endl;
- return 1;
- }
- std::cout << "ADC " << adc->getModuleName() << " detected. " ;
- std::cout << adc->getNumInputs() << " inputs available" << std::endl;
- while (true) {
- for (unsigned int i=0; i<adc->getNumInputs(); ++i) {
- std::cout << "Input " << i;
- try {
- float voltage = adc->getVoltage(i);
- std::cout << ": Voltage = " << voltage << "V" << std::endl;
- } catch (std::exception& e) {
- std::cerr << e.what() << std::endl;
- }
- }
- sleep(1);
- }
- delete adc;
- return 0;
-}
-
-//! [Interesting]
diff --git a/peripheral/libupm/examples/c++/adc121c021.cxx b/peripheral/libupm/examples/c++/adc121c021.cxx
index 7a86c18..18288ad 100644
--- a/peripheral/libupm/examples/c++/adc121c021.cxx
+++ b/peripheral/libupm/examples/c++/adc121c021.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "adc121c021.hpp"
+#include "adc121c021.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ads1x15.cxx b/peripheral/libupm/examples/c++/ads1x15.cxx
index d4196cd..3c5da65 100644
--- a/peripheral/libupm/examples/c++/ads1x15.cxx
+++ b/peripheral/libupm/examples/c++/ads1x15.cxx
@@ -26,8 +26,8 @@
#include <iostream>
#include <unistd.h>
-#include "ads1015.hpp"
-#include "ads1115.hpp"
+#include "ads1015.h"
+#include "ads1115.h"
@@ -286,7 +286,7 @@ int main()
else ads->setCompMode();
break;
case 18:
- cout << ads->getCompLatch() << endl;
+ cout << ads->getCompLatch() << cout;
break;
case 19:
cout << "select one of the following:" << endl;
@@ -296,7 +296,7 @@ int main()
else ads->setCompLatch();
break;
case 20:
- cout << ads->getContinuous() << endl;
+ cout << ads->getContinuous() << cout;
break;
case 21:
cout << "select one of the following:" << endl;
diff --git a/peripheral/libupm/examples/c++/adxl335.cxx b/peripheral/libupm/examples/c++/adxl335.cxx
index 8152012..471695d 100644
--- a/peripheral/libupm/examples/c++/adxl335.cxx
+++ b/peripheral/libupm/examples/c++/adxl335.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "adxl335.hpp"
+#include "adxl335.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/adxl345.cxx b/peripheral/libupm/examples/c++/adxl345.cxx
index 851bc77..a5bc2cc 100644
--- a/peripheral/libupm/examples/c++/adxl345.cxx
+++ b/peripheral/libupm/examples/c++/adxl345.cxx
@@ -23,7 +23,7 @@
*/
#include <unistd.h>
-#include "adxl345.hpp"
+#include "adxl345.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/adxrs610.cxx b/peripheral/libupm/examples/c++/adxrs610.cxx
index f24ccd5..4ec53ef 100644
--- a/peripheral/libupm/examples/c++/adxrs610.cxx
+++ b/peripheral/libupm/examples/c++/adxrs610.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "adxrs610.hpp"
+#include "adxrs610.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ak8975.cxx b/peripheral/libupm/examples/c++/ak8975.cxx
index c2f8607..1b95ead 100644
--- a/peripheral/libupm/examples/c++/ak8975.cxx
+++ b/peripheral/libupm/examples/c++/ak8975.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "mpu9150.hpp"
+#include "mpu9150.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/am2315.cxx b/peripheral/libupm/examples/c++/am2315.cxx
index 56f27cc..4b95e1c 100644
--- a/peripheral/libupm/examples/c++/am2315.cxx
+++ b/peripheral/libupm/examples/c++/am2315.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "am2315.hpp"
+#include "am2315.h"
volatile int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/apa102.cxx b/peripheral/libupm/examples/c++/apa102.cxx
deleted file mode 100644
index 01aa963..0000000
--- a/peripheral/libupm/examples/c++/apa102.cxx
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Author: Yannick Adam <yannick.adam@gmail.com>
- * Copyright (c) 2016 Yannick Adam
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include "apa102.hpp"
-#include <iostream>
-#include <signal.h>
-#include <unistd.h>
-
-using namespace std;
-
-int
-main(int argc, char** argv)
-{
- //! [Interesting]
- // Instantiate a strip of 30 LEDs on SPI bus 0
- upm::APA102* ledStrip = new upm::APA102(800, 0);
-
- // Set all LEDs to Red
- ledStrip->setAllLeds(31, 255, 0, 0);
-
- // Set a section (10 to 20) to blue
- ledStrip->setLeds(10, 20, 31, 0, 0, 255);
-
- // Set a single LED to green
- ledStrip->setLed(15, 31, 0, 255, 0);
-
- delete ledStrip;
- //! [Interesting]
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/apds9002.cxx b/peripheral/libupm/examples/c++/apds9002.cxx
index 345f53a..87b5070 100644
--- a/peripheral/libupm/examples/c++/apds9002.cxx
+++ b/peripheral/libupm/examples/c++/apds9002.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "apds9002.hpp"
+#include "apds9002.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/apds9930.cxx b/peripheral/libupm/examples/c++/apds9930.cxx
index 6da24a9..8d461c9 100644
--- a/peripheral/libupm/examples/c++/apds9930.cxx
+++ b/peripheral/libupm/examples/c++/apds9930.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "apds9930.hpp"
+#include "apds9930.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/at42qt1070.cxx b/peripheral/libupm/examples/c++/at42qt1070.cxx
index b198649..c22a998 100644
--- a/peripheral/libupm/examples/c++/at42qt1070.cxx
+++ b/peripheral/libupm/examples/c++/at42qt1070.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "at42qt1070.hpp"
+#include "at42qt1070.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/biss0001.cxx b/peripheral/libupm/examples/c++/biss0001.cxx
index 2468804..1574c2f 100644
--- a/peripheral/libupm/examples/c++/biss0001.cxx
+++ b/peripheral/libupm/examples/c++/biss0001.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "biss0001.hpp"
+#include "biss0001.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/bma220.cxx b/peripheral/libupm/examples/c++/bma220.cxx
index 9701510..a41b81a 100644
--- a/peripheral/libupm/examples/c++/bma220.cxx
+++ b/peripheral/libupm/examples/c++/bma220.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "bma220.hpp"
+#include "bma220.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/bma250e.cxx b/peripheral/libupm/examples/c++/bma250e.cxx
deleted file mode 100644
index 0391617..0000000
--- a/peripheral/libupm/examples/c++/bma250e.cxx
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-#include "bma250e.hpp"
-
-using namespace std;
-
-int shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-//! [Interesting]
-
- // Instantiate an BMA250E using default I2C parameters
- upm::BMA250E *sensor = new upm::BMA250E();
-
- // For SPI, bus 0, you would pass -1 as the address, and a valid pin
- // for CS: BMA250E(0, -1, 10);
-
- // now output data every 250 milliseconds
- while (shouldRun)
- {
- float x, y, z;
-
- sensor->update();
-
- sensor->getAccelerometer(&x, &y, &z);
- cout << "Accelerometer x: " << x
- << " y: " << y
- << " z: " << z
- << " g"
- << endl;
-
- // we show both C and F for temperature
- cout << "Compensation Temperature: " << sensor->getTemperature()
- << " C / " << sensor->getTemperature(true) << " F"
- << endl;
-
- cout << endl;
-
- usleep(250000);
- }
-
-//! [Interesting]
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/bmc150.cxx b/peripheral/libupm/examples/c++/bmc150.cxx
deleted file mode 100644
index 4600643..0000000
--- a/peripheral/libupm/examples/c++/bmc150.cxx
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-#include "bmc150.hpp"
-
-using namespace std;
-
-int shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-//! [Interesting]
-
- // Instantiate an BMC150 using default I2C parameters
- upm::BMC150 *sensor = new upm::BMC150();
-
- // now output data every 250 milliseconds
- while (shouldRun)
- {
- float x, y, z;
-
- sensor->update();
-
- sensor->getAccelerometer(&x, &y, &z);
- cout << "Accelerometer x: " << x
- << " y: " << y
- << " z: " << z
- << " g"
- << endl;
-
- sensor->getMagnetometer(&x, &y, &z);
- cout << "Magnetometer x: " << x
- << " y: " << y
- << " z: " << z
- << " uT"
- << endl;
-
- cout << endl;
-
- usleep(250000);
- }
-
-//! [Interesting]
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/bme280.cxx b/peripheral/libupm/examples/c++/bme280.cxx
deleted file mode 100644
index 12df7a9..0000000
--- a/peripheral/libupm/examples/c++/bme280.cxx
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-
-#include "bme280.hpp"
-
-using namespace std;
-using namespace upm;
-
-int shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-//! [Interesting]
-
- // Instantiate a BME280 instance using default i2c bus and address
- upm::BME280 *sensor = new upm::BME280();
-
- // For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
- // BME280(0, -1, 10);
-
- while (shouldRun)
- {
- // update our values from the sensor
- sensor->update();
-
- // we show both C and F for temperature
- cout << "Compensation Temperature: " << sensor->getTemperature()
- << " C / " << sensor->getTemperature(true) << " F"
- << endl;
- cout << "Pressure: " << sensor->getPressure() << " Pa" << endl;
- cout << "Computed Altitude: " << sensor->getAltitude() << " m" << endl;
- cout << "Humidity: " << sensor->getHumidity() << " %RH" << endl;
-
- cout << endl;
-
- sleep(1);
- }
-//! [Interesting]
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/bmg160.cxx b/peripheral/libupm/examples/c++/bmg160.cxx
deleted file mode 100644
index c305b27..0000000
--- a/peripheral/libupm/examples/c++/bmg160.cxx
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-#include "bmg160.hpp"
-
-using namespace std;
-
-int shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-//! [Interesting]
-
- // Instantiate an BMG160 using default I2C parameters
- upm::BMG160 *sensor = new upm::BMG160();
-
- // For SPI, bus 0, you would pass -1 as the address, and a valid pin
- // for CS: BMG160(0, -1, 10);
-
- // now output data every 250 milliseconds
- while (shouldRun)
- {
- float x, y, z;
-
- sensor->update();
-
- sensor->getGyroscope(&x, &y, &z);
- cout << "Gyroscope x: " << x
- << " y: " << y
- << " z: " << z
- << " degrees/s"
- << endl;
-
- // we show both C and F for temperature
- cout << "Compensation Temperature: " << sensor->getTemperature()
- << " C / " << sensor->getTemperature(true) << " F"
- << endl;
-
- cout << endl;
-
- usleep(250000);
- }
-
-//! [Interesting]
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/bmi055.cxx b/peripheral/libupm/examples/c++/bmi055.cxx
deleted file mode 100644
index e88fe16..0000000
--- a/peripheral/libupm/examples/c++/bmi055.cxx
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-#include "bmi055.hpp"
-
-using namespace std;
-
-int shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-//! [Interesting]
-
- // Instantiate an BMI055 using default I2C parameters
- upm::BMI055 *sensor = new upm::BMI055();
-
- // now output data every 250 milliseconds
- while (shouldRun)
- {
- float x, y, z;
-
- sensor->update();
-
- sensor->getAccelerometer(&x, &y, &z);
- cout << "Accelerometer x: " << x
- << " y: " << y
- << " z: " << z
- << " g"
- << endl;
-
- sensor->getGyroscope(&x, &y, &z);
- cout << "Gyroscope x: " << x
- << " y: " << y
- << " z: " << z
- << " degrees/s"
- << endl;
-
- cout << endl;
-
- usleep(250000);
- }
-
-//! [Interesting]
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/bmi160.cxx b/peripheral/libupm/examples/c++/bmi160.cxx
deleted file mode 100644
index 6f98556..0000000
--- a/peripheral/libupm/examples/c++/bmi160.cxx
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-#include "bmi160.hpp"
-
-using namespace std;
-
-int shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-//! [Interesting]
-
- // Instantiate a BMI160 instance using default i2c bus and address
- upm::BMI160 *sensor = new upm::BMI160();
-
- while (shouldRun)
- {
- // update our values from the sensor
- sensor->update();
-
- float dataX, dataY, dataZ;
-
- sensor->getAccelerometer(&dataX, &dataY, &dataZ);
- cout << "Accelerometer: ";
- cout << "AX: " << dataX << " AY: " << dataY << " AZ: "
- << dataZ << endl;
-
- sensor->getGyroscope(&dataX, &dataY, &dataZ);
- cout << "Gryoscope: ";
- cout << "GX: " << dataX << " GY: " << dataY << " GZ: "
- << dataZ << endl;
-
- sensor->getMagnetometer(&dataX, &dataY, &dataZ);
- cout << "Magnetometer: ";
- cout << "MX: " << dataX << " MY: " << dataY << " MZ: "
- << dataZ << endl;
-
- cout << endl;
-
- usleep(500000);
- }
-//! [Interesting]
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/bmm150.cxx b/peripheral/libupm/examples/c++/bmm150.cxx
deleted file mode 100644
index 400f1a9..0000000
--- a/peripheral/libupm/examples/c++/bmm150.cxx
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-#include "bmm150.hpp"
-
-using namespace std;
-
-int shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-//! [Interesting]
-
- // Instantiate an BMM150 using default I2C parameters
- upm::BMM150 *sensor = new upm::BMM150();
-
- // For SPI, bus 0, you would pass -1 as the address, and a valid pin
- // for CS: BMM150(0, -1, 10);
-
- // now output data every 250 milliseconds
- while (shouldRun)
- {
- float x, y, z;
-
- sensor->update();
-
- sensor->getMagnetometer(&x, &y, &z);
- cout << "Magnetometer x: " << x
- << " y: " << y
- << " z: " << z
- << " uT"
- << endl;
-
- cout << endl;
-
- usleep(250000);
- }
-
-//! [Interesting]
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/bmp280.cxx b/peripheral/libupm/examples/c++/bmp280.cxx
deleted file mode 100644
index 101159e..0000000
--- a/peripheral/libupm/examples/c++/bmp280.cxx
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-
-#include "bmp280.hpp"
-
-using namespace std;
-using namespace upm;
-
-int shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-//! [Interesting]
-
- // Instantiate a BMP280 instance using default i2c bus and address
- upm::BMP280 *sensor = new upm::BMP280();
-
- // For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
- // BMP280(0, -1, 10);
-
- while (shouldRun)
- {
- // update our values from the sensor
- sensor->update();
-
- // we show both C and F for temperature
- cout << "Compensation Temperature: " << sensor->getTemperature()
- << " C / " << sensor->getTemperature(true) << " F"
- << endl;
- cout << "Pressure: " << sensor->getPressure() << " Pa" << endl;
- cout << "Computed Altitude: " << sensor->getAltitude() << " m" << endl;
-
- cout << endl;
-
- sleep(1);
- }
-//! [Interesting]
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/bmpx8x.cxx b/peripheral/libupm/examples/c++/bmpx8x.cxx
index f4ebf7d..28e5be8 100644
--- a/peripheral/libupm/examples/c++/bmpx8x.cxx
+++ b/peripheral/libupm/examples/c++/bmpx8x.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "bmpx8x.hpp"
+#include "bmpx8x.h"
#include <signal.h>
int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/bmx055.cxx b/peripheral/libupm/examples/c++/bmx055.cxx
deleted file mode 100644
index 31626f4..0000000
--- a/peripheral/libupm/examples/c++/bmx055.cxx
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-#include "bmx055.hpp"
-
-using namespace std;
-
-int shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-//! [Interesting]
-
- // Instantiate an BMX055 using default I2C parameters
- upm::BMX055 *sensor = new upm::BMX055();
-
- // now output data every 250 milliseconds
- while (shouldRun)
- {
- float x, y, z;
-
- sensor->update();
-
- sensor->getAccelerometer(&x, &y, &z);
- cout << "Accelerometer x: " << x
- << " y: " << y
- << " z: " << z
- << " g"
- << endl;
-
- sensor->getGyroscope(&x, &y, &z);
- cout << "Gyroscope x: " << x
- << " y: " << y
- << " z: " << z
- << " degrees/s"
- << endl;
-
- sensor->getMagnetometer(&x, &y, &z);
- cout << "Magnetometer x: " << x
- << " y: " << y
- << " z: " << z
- << " uT"
- << endl;
-
- cout << endl;
-
- usleep(250000);
- }
-
-//! [Interesting]
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/bno055.cxx b/peripheral/libupm/examples/c++/bno055.cxx
deleted file mode 100644
index b46999e..0000000
--- a/peripheral/libupm/examples/c++/bno055.cxx
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-#include "bno055.hpp"
-
-using namespace std;
-
-int shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-//! [Interesting]
-
- // Instantiate an BNO055 using default parameters (bus 0, addr
- // 0x28). The default running mode is NDOF absolute orientation
- // mode.
- upm::BNO055 *sensor = new upm::BNO055();
-
- // First we need to calibrate....
- cout << "First we need to calibrate. 4 numbers will be output every"
- << endl;
- cout << "second for each sensor. 0 means uncalibrated, and 3 means"
- << endl;
- cout << "fully calibrated."
- << endl;
- cout << "See the UPM documentation on this sensor for instructions on"
- << endl;
- cout << "what actions are required to calibrate."
- << endl;
- cout << endl;
-
- // do the calibration...
- while (shouldRun && !sensor->isFullyCalibrated())
- {
- int mag, acc, gyr, sys;
- sensor->getCalibrationStatus(&mag, &acc, &gyr, &sys);
-
- cout << "Magnetometer: " << mag
- << " Accelerometer: " << acc
- << " Gyroscope: " << gyr
- << " System: " << sys
- << endl;
-
- sleep(1);
- }
-
- cout << endl;
- cout << "Calibration complete." << endl;
- cout << endl;
-
- // now output various fusion data every 250 milliseconds
- while (shouldRun)
- {
- float w, x, y, z;
-
- sensor->update();
-
- sensor->getEulerAngles(&x, &y, &z);
- cout << "Euler: Heading: " << x
- << " Roll: " << y
- << " Pitch: " << z
- << " degrees"
- << endl;
-
- sensor->getQuaternions(&w, &x, &y, &z);
- cout << "Quaternion: W: " << w
- << " X: " << x
- << " Y: " << y
- << " Z: " << z
- << endl;
-
- sensor->getLinearAcceleration(&x, &y, &z);
- cout << "Linear Acceleration: X: " << x
- << " Y: " << y
- << " Z: " << z
- << " m/s^2"
- << endl;
-
- sensor->getGravityVectors(&x, &y, &z);
- cout << "Gravity Vector: X: " << x
- << " Y: " << y
- << " Z: " << z
- << " m/s^2"
- << endl;
-
- cout << endl;
- usleep(250000);
- }
-
-//! [Interesting]
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/buzzer-sound.cxx b/peripheral/libupm/examples/c++/buzzer-sound.cxx
index 604904a..1d377ba 100644
--- a/peripheral/libupm/examples/c++/buzzer-sound.cxx
+++ b/peripheral/libupm/examples/c++/buzzer-sound.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "buzzer.hpp"
+#include "buzzer.h"
int
diff --git a/peripheral/libupm/examples/c++/cjq4435.cxx b/peripheral/libupm/examples/c++/cjq4435.cxx
index 79d3495..f9d84d4 100644
--- a/peripheral/libupm/examples/c++/cjq4435.cxx
+++ b/peripheral/libupm/examples/c++/cjq4435.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "cjq4435.hpp"
+#include "cjq4435.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/co2-sensor.cxx b/peripheral/libupm/examples/c++/co2-sensor.cxx
deleted file mode 100644
index da978ad..0000000
--- a/peripheral/libupm/examples/c++/co2-sensor.cxx
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include "t6713.hpp"
-
-#define EDISON_I2C_BUS 1
-#define FT4222_I2C_BUS 0
-
-//! [Interesting]
-// Simple example of using ICO2Sensor to determine
-// which sensor is present and return its name.
-// ICO2Sensor is then used to get readings from sensor
-
-
-upm::ICO2Sensor* getCO2Sensor()
-{
- upm::ICO2Sensor* cO2Sensor = NULL;
- try {
- cO2Sensor = new upm::T6713(mraa_get_sub_platform_id(FT4222_I2C_BUS));
- return cO2Sensor;
- } catch (std::exception& e) {
- std::cerr << "T6713: " << e.what() << std::endl;
- }
- return cO2Sensor;
-}
-
-int main ()
-{
- upm::ICO2Sensor* cO2Sensor = getCO2Sensor();
- if (cO2Sensor == NULL) {
- std::cout << "CO2 sensor not detected" << std::endl;
- return 1;
- }
- std::cout << "CO2 sensor " << cO2Sensor->getModuleName() << " detected" << std::endl;
- while (true) {
- try {
- uint16_t value = cO2Sensor->getPpm();
- std::cout << "CO2 level = " << value << " ppm" << std::endl;
- } catch (std::exception& e) {
- std::cerr << e.what() << std::endl;
- }
- sleep(1);
- }
- delete cO2Sensor;
- return 0;
-}
-
-//! [Interesting]
diff --git a/peripheral/libupm/examples/c++/curieimu.cxx b/peripheral/libupm/examples/c++/curieimu.cxx
deleted file mode 100644
index c9ff3e6..0000000
--- a/peripheral/libupm/examples/c++/curieimu.cxx
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Author: Brendan Le Foll <brendan.le.foll@intel.com>
- * Author: Ron Evans (@deadprogram)
- * Author: Justin Zemlyansky (@JustInDevelopment)
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include "curieimu.hpp"
-#include "mraa.h"
-#include "mraa/firmata.h"
-#include <math.h>
-
-int
-main(int argc, char **argv)
-{
- //! [Interesting]
- mraa_init();
- mraa_add_subplatform(MRAA_GENERIC_FIRMATA, "/dev/ttyACM0");
-
- upm::CurieImu* sensor = new upm::CurieImu();
-
- std::cout << "temperature is: " << (sensor->getTemperature() * pow(0.5, 9) + 23) << std::endl;
-
- sensor->updateAccel();
- int x = sensor->getAccelX(),
- y = sensor->getAccelY(),
- z = sensor->getAccelZ();
- printf("accelerometer is: %d, %d, %d\n", x, y, z);
-
- sensor->updateGyro();
- int a = sensor->getGyroX(),
- b = sensor->getGyroY(),
- c = sensor->getGyroZ();
- printf("gyroscope is: %d, %d, %d\n", a, b, c);
-
- int axis, direction;
- sensor->enableShockDetection(true);
- for(int i=0; i<300; i++) {
- if (sensor->isShockDetected()) {
- sensor->getNextShock();
- axis = sensor->getAxis();
- direction = sensor->getDirection();
- printf("shock data is: %d, %d\n", axis, direction);
- }
- usleep(10000);
- }
-
- sensor->updateMotion();
- int m = sensor->getAccelX(),
- n = sensor->getAccelY(),
- o = sensor->getAccelZ(),
- p = sensor->getGyroX(),
- q = sensor->getGyroY(),
- r = sensor->getGyroZ();
- printf("motion is: %d, %d, %d, %d, %d, %d\n", m, n, o, p, q, r);
-
- delete sensor;
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/cwlsxxa.cxx b/peripheral/libupm/examples/c++/cwlsxxa.cxx
deleted file mode 100644
index b96c85e..0000000
--- a/peripheral/libupm/examples/c++/cwlsxxa.cxx
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-
-#include "cwlsxxa.hpp"
-
-using namespace std;
-
-bool shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-
-//! [Interesting]
-
- cout << "Initializing..." << endl;
-
- // Instantiate an CWLSXXA instance, using A0 for CO2, A1 for
- // humidity and A2 for temperature
- upm::CWLSXXA *sensor = new upm::CWLSXXA(0, 1, 2);
-
- // update and print available values every second
- while (shouldRun)
- {
- // update our values from the sensor
- sensor->update();
-
- // we show both C and F for temperature
- cout << "Temperature: " << sensor->getTemperature()
- << " C / " << sensor->getTemperature(true) << " F"
- << endl;
-
- cout << "Humidity: " << sensor->getHumidity()
- << " %" << endl;
-
- cout << "CO2: " << sensor->getCO2()
- << " ppm" << endl;
-
- cout << endl;
-
- sleep(1);
- }
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
-//! [Interesting]
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/dfrph.cxx b/peripheral/libupm/examples/c++/dfrph.cxx
index 22d3db5..601fdbf 100644
--- a/peripheral/libupm/examples/c++/dfrph.cxx
+++ b/peripheral/libupm/examples/c++/dfrph.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "dfrph.hpp"
+#include "dfrph.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ds1307.cxx b/peripheral/libupm/examples/c++/ds1307.cxx
index 0cb0793..44a0b08 100644
--- a/peripheral/libupm/examples/c++/ds1307.cxx
+++ b/peripheral/libupm/examples/c++/ds1307.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "ds1307.hpp"
+#include "ds1307.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ds1808lc.cxx b/peripheral/libupm/examples/c++/ds1808lc.cxx
deleted file mode 100644
index 33e655e..0000000
--- a/peripheral/libupm/examples/c++/ds1808lc.cxx
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <iostream>
-#include <string>
-#include "ds1808lc.hpp"
-
-#define EDISON_I2C_BUS 1 // Edison I2C-1
-#define DS1808_GPIO_PWR 15 // Edison GP165
-
-void printState(upm::ILightController *lightController)
-{
- if (lightController->isPowered())
- {
- std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
- }
- else
- {
- std::cout << "Light is not powered." << std::endl;
- }
-}
-
-int main( int argc, char **argv )
-{
- int status = 0;
- upm::ILightController* lightController;
-
- try {
- lightController = new upm::DS1808LC(DS1808_GPIO_PWR, EDISON_I2C_BUS);
- std::cout << "Existing state: "; printState(lightController);
- if (argc == 2)
- {
- std::string arg = argv[1];
- int brightness = ::atoi(argv[1]);
- if (brightness > 0) {
- lightController->setPowerOn();
- lightController->setBrightness(brightness);
- } else
- lightController->setPowerOff();
- }
- std::cout << "Now: ";printState(lightController);
- } catch (std::exception& e) {
- std::cout << "Error: " << e.what() << std::endl;
- status = 1;
- }
-
- delete lightController;
- return status;
-}
-
-
diff --git a/peripheral/libupm/examples/c++/ds18b20.cxx b/peripheral/libupm/examples/c++/ds18b20.cxx
deleted file mode 100644
index f1eaa8c..0000000
--- a/peripheral/libupm/examples/c++/ds18b20.cxx
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-
-#include "ds18b20.hpp"
-
-using namespace std;
-
-bool shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-
-//! [Interesting]
-
- cout << "Initializing..." << endl;
-
- // Instantiate an DS18B20 instance using the default values (uart 0)
- upm::DS18B20 sensor;
-
- // locate and setup our devices
- sensor.init();
-
- cout << "Found " << sensor.devicesFound() << " device(s)" << endl;
- cout << endl;
-
- // bail if we didn't find anything
- if (!sensor.devicesFound())
- return 1;
-
- // update and print available values every second
- while (shouldRun)
- {
- // update our values for the first sensor
- sensor.update(0);
-
- // we show both C and F for temperature for the first sensor
- cout << "Temperature: " << sensor.getTemperature(0)
- << " C / " << sensor.getTemperature(0, true) << " F"
- << endl;
-
- sleep(1);
- }
-
- cout << "Exiting..." << endl;
-
-//! [Interesting]
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/ds2413.cxx b/peripheral/libupm/examples/c++/ds2413.cxx
deleted file mode 100644
index 04fdcb6..0000000
--- a/peripheral/libupm/examples/c++/ds2413.cxx
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <stdio.h>
-#include "ds2413.hpp"
-
-using namespace std;
-using namespace upm;
-
-int main(int argc, char **argv)
-{
-//! [Interesting]
- // Instantiate a DS2413 Module on a Dallas 1-wire bus connected to UART 0
- upm::DS2413* sensor = new upm::DS2413(0);
-
- // find all of the DS2413 devices present on the bus
- sensor->init();
-
- // how many devices were found?
- cout << "Found "<< sensor->devicesFound() << " device(s)" << endl;
-
- // read the gpio and latch values from the first device
- // the lower 4 bits are of the form:
- // <gpioB latch> <gpioB value> <gpioA latch> <gpioA value>
- cout << "GPIO device 0 values: " << sensor->readGpios(0) << endl;
-
- // set the gpio latch values of the first device
- cout << "Setting GPIO latches to on" << endl;
- sensor->writeGpios(0, 0x03);
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-//! [Interesting]
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/e50hx.cxx b/peripheral/libupm/examples/c++/e50hx.cxx
deleted file mode 100644
index 253e089..0000000
--- a/peripheral/libupm/examples/c++/e50hx.cxx
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-
-#include "e50hx.hpp"
-
-using namespace std;
-using namespace upm;
-
-bool shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-
-//! [Interesting]
- // You will need to edit this example to conform to your site and your
- // devices, specifically the Device Object Instance ID passed to the
- // constructor, and the arguments to initMaster() that are
- // appropriate for your BACnet network.
-
- string defaultDev = "/dev/ttyUSB0";
-
- // if an argument was specified, use it as the device instead
- if (argc > 1)
- defaultDev = string(argv[1]);
-
- cout << "Using device " << defaultDev << endl;
- cout << "Initializing..." << endl;
-
- // Instantiate an E50HX object for an E50HX device that has 1075425
- // as it's unique Device Object Instance ID. NOTE: You will
- // certainly want to change this to the correct value for your
- // device(s).
- E50HX *sensor = new E50HX(1075425);
-
- // Initialize our BACnet master, if it has not already been
- // initialized, with the device and baudrate, choosing 1000001 as
- // our unique Device Object Instance ID, 2 as our MAC address and
- // using default values for maxMaster and maxInfoFrames
- sensor->initMaster(defaultDev, 38400, 1000001, 2);
-
- // Uncomment to enable debugging output
- // sensor->setDebug(true);
-
- cout << endl;
- cout << "Device Description: " << sensor->getDeviceDescription() << endl;
- cout << "Device Location: " << sensor->getDeviceLocation() << endl;
- cout << endl;
-
- // update and print a few values every 5 seconds
- while (shouldRun)
- {
- cout << "System Voltage: "
- << sensor->getAnalogValue(E50HX::AV_System_Voltage)
- << " " << sensor->getAnalogValueUnits(E50HX::AV_System_Voltage)
- << endl;
-
- cout << "System Type: "
- << sensor->getAnalogValue(E50HX::AV_System_Type)
- << endl;
-
- cout << "Energy Consumption: " << sensor->getAnalogInput(E50HX::AI_Energy)
- << " " << sensor->getAnalogInputUnits(E50HX::AI_Energy)
- << endl;
-
- cout << "Power Up Counter: "
- << sensor->getAnalogInput(E50HX::AI_Power_Up_Count)
- << endl;
-
- cout << endl;
- sleep(5);
- }
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
-//! [Interesting]
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/eboled.cxx b/peripheral/libupm/examples/c++/eboled.cxx
index 0832537..c1c281c 100644
--- a/peripheral/libupm/examples/c++/eboled.cxx
+++ b/peripheral/libupm/examples/c++/eboled.cxx
@@ -23,7 +23,7 @@
*/
#include <iostream>
-#include "eboled.hpp"
+#include "eboled.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ecs1030.cxx b/peripheral/libupm/examples/c++/ecs1030.cxx
index ff87279..40a7dc5 100644
--- a/peripheral/libupm/examples/c++/ecs1030.cxx
+++ b/peripheral/libupm/examples/c++/ecs1030.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
#include <stdlib.h>
-#include "ecs1030.hpp"
+#include "ecs1030.h"
int is_running = 0;
upm::ECS1030 *sensor = NULL;
diff --git a/peripheral/libupm/examples/c++/enc03r.cxx b/peripheral/libupm/examples/c++/enc03r.cxx
index 298d7cd..da0db9b 100644
--- a/peripheral/libupm/examples/c++/enc03r.cxx
+++ b/peripheral/libupm/examples/c++/enc03r.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "enc03r.hpp"
+#include "enc03r.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/es08a.cxx b/peripheral/libupm/examples/c++/es08a.cxx
index c480012..3f7e5c4 100644
--- a/peripheral/libupm/examples/c++/es08a.cxx
+++ b/peripheral/libupm/examples/c++/es08a.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "es08a.hpp"
+#include "es08a.h"
#include <signal.h>
#include <stdlib.h>
diff --git a/peripheral/libupm/examples/c++/flex.cxx b/peripheral/libupm/examples/c++/flex.cxx
index 26cdcdd..5477338 100644
--- a/peripheral/libupm/examples/c++/flex.cxx
+++ b/peripheral/libupm/examples/c++/flex.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "flex.hpp"
+#include "flex.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/gp2y0a.cxx b/peripheral/libupm/examples/c++/gp2y0a.cxx
index 1a6114b..0111b17 100644
--- a/peripheral/libupm/examples/c++/gp2y0a.cxx
+++ b/peripheral/libupm/examples/c++/gp2y0a.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "gp2y0a.hpp"
+#include "gp2y0a.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovebutton.cxx b/peripheral/libupm/examples/c++/grovebutton.cxx
index 3534d16..7d2d69a 100644
--- a/peripheral/libupm/examples/c++/grovebutton.cxx
+++ b/peripheral/libupm/examples/c++/grovebutton.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "grove.hpp"
+#include "grove.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/grovecircularled.cxx b/peripheral/libupm/examples/c++/grovecircularled.cxx
index 54af0cf..066e017 100644
--- a/peripheral/libupm/examples/c++/grovecircularled.cxx
+++ b/peripheral/libupm/examples/c++/grovecircularled.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovecircularled.hpp"
+#include "grovecircularled.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovecollision.cxx b/peripheral/libupm/examples/c++/grovecollision.cxx
index e7ad0f8..2de7609 100644
--- a/peripheral/libupm/examples/c++/grovecollision.cxx
+++ b/peripheral/libupm/examples/c++/grovecollision.cxx
@@ -24,7 +24,7 @@
#include <iostream>
#include <unistd.h>
#include <signal.h>
-#include "grovecollision.hpp"
+#include "grovecollision.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groveehr.cxx b/peripheral/libupm/examples/c++/groveehr.cxx
index 7377560..b056a15 100644
--- a/peripheral/libupm/examples/c++/groveehr.cxx
+++ b/peripheral/libupm/examples/c++/groveehr.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "groveehr.hpp"
+#include "groveehr.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groveeldriver.cxx b/peripheral/libupm/examples/c++/groveeldriver.cxx
index 9c1d561..126eaaf 100644
--- a/peripheral/libupm/examples/c++/groveeldriver.cxx
+++ b/peripheral/libupm/examples/c++/groveeldriver.cxx
@@ -24,7 +24,7 @@
#include <iostream>
#include <unistd.h>
#include <signal.h>
-#include "groveeldriver.hpp"
+#include "groveeldriver.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groveelectromagnet.cxx b/peripheral/libupm/examples/c++/groveelectromagnet.cxx
index bbd4d33..386f4de 100644
--- a/peripheral/libupm/examples/c++/groveelectromagnet.cxx
+++ b/peripheral/libupm/examples/c++/groveelectromagnet.cxx
@@ -24,7 +24,7 @@
#include <iostream>
#include <time.h>
#include <signal.h>
-#include "groveelectromagnet.hpp"
+#include "groveelectromagnet.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groveemg.cxx b/peripheral/libupm/examples/c++/groveemg.cxx
index 3a049dd..d06295a 100644
--- a/peripheral/libupm/examples/c++/groveemg.cxx
+++ b/peripheral/libupm/examples/c++/groveemg.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "groveemg.hpp"
+#include "groveemg.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovegprs.cxx b/peripheral/libupm/examples/c++/grovegprs.cxx
index f882cba..bc0e3d9 100644
--- a/peripheral/libupm/examples/c++/grovegprs.cxx
+++ b/peripheral/libupm/examples/c++/grovegprs.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
#include <stdio.h>
-#include "grovegprs.hpp"
+#include "grovegprs.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/grovegsr.cxx b/peripheral/libupm/examples/c++/grovegsr.cxx
index 6068e79..549e775 100644
--- a/peripheral/libupm/examples/c++/grovegsr.cxx
+++ b/peripheral/libupm/examples/c++/grovegsr.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovegsr.hpp"
+#include "grovegsr.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groveled-multi.cxx b/peripheral/libupm/examples/c++/groveled-multi.cxx
index 1a6f8eb..16a6eba 100644
--- a/peripheral/libupm/examples/c++/groveled-multi.cxx
+++ b/peripheral/libupm/examples/c++/groveled-multi.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grove.hpp"
+#include "grove.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groveled.cxx b/peripheral/libupm/examples/c++/groveled.cxx
index 8f7e752..52d5e84 100644
--- a/peripheral/libupm/examples/c++/groveled.cxx
+++ b/peripheral/libupm/examples/c++/groveled.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
-#include "grove.hpp"
+#include "grove.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/groveledbar.cxx b/peripheral/libupm/examples/c++/groveledbar.cxx
index bc51183..d86110c 100644
--- a/peripheral/libupm/examples/c++/groveledbar.cxx
+++ b/peripheral/libupm/examples/c++/groveledbar.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "groveledbar.hpp"
+#include "groveledbar.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovelight.cxx b/peripheral/libupm/examples/c++/grovelight.cxx
index 18f8f6c..64760c9 100644
--- a/peripheral/libupm/examples/c++/grovelight.cxx
+++ b/peripheral/libupm/examples/c++/grovelight.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
-#include "grove.hpp"
+#include "grove.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/grovelinefinder.cxx b/peripheral/libupm/examples/c++/grovelinefinder.cxx
index 53b1e6e..a8290c5 100644
--- a/peripheral/libupm/examples/c++/grovelinefinder.cxx
+++ b/peripheral/libupm/examples/c++/grovelinefinder.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovelinefinder.hpp"
+#include "grovelinefinder.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovemd-stepper.cxx b/peripheral/libupm/examples/c++/grovemd-stepper.cxx
index ce189d2..f65c5e4 100644
--- a/peripheral/libupm/examples/c++/grovemd-stepper.cxx
+++ b/peripheral/libupm/examples/c++/grovemd-stepper.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "grovemd.hpp"
+#include "grovemd.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovemd.cxx b/peripheral/libupm/examples/c++/grovemd.cxx
index 87c3616..a5c1015 100644
--- a/peripheral/libupm/examples/c++/grovemd.cxx
+++ b/peripheral/libupm/examples/c++/grovemd.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "grovemd.hpp"
+#include "grovemd.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovemoisture.cxx b/peripheral/libupm/examples/c++/grovemoisture.cxx
index f63a088..1fee54c 100644
--- a/peripheral/libupm/examples/c++/grovemoisture.cxx
+++ b/peripheral/libupm/examples/c++/grovemoisture.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovemoisture.hpp"
+#include "grovemoisture.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groveo2.cxx b/peripheral/libupm/examples/c++/groveo2.cxx
index 79741b5..cc1b240 100644
--- a/peripheral/libupm/examples/c++/groveo2.cxx
+++ b/peripheral/libupm/examples/c++/groveo2.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "groveo2.hpp"
+#include "groveo2.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/groverelay.cxx b/peripheral/libupm/examples/c++/groverelay.cxx
index 9297139..4366dd6 100644
--- a/peripheral/libupm/examples/c++/groverelay.cxx
+++ b/peripheral/libupm/examples/c++/groverelay.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "grove.hpp"
+#include "grove.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/groverotary.cxx b/peripheral/libupm/examples/c++/groverotary.cxx
index aa2ee57..4139242 100644
--- a/peripheral/libupm/examples/c++/groverotary.cxx
+++ b/peripheral/libupm/examples/c++/groverotary.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <iomanip>
-#include "grove.hpp"
+#include "grove.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovescam.cxx b/peripheral/libupm/examples/c++/grovescam.cxx
index 6592b33..6edd85d 100644
--- a/peripheral/libupm/examples/c++/grovescam.cxx
+++ b/peripheral/libupm/examples/c++/grovescam.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
#include <stdio.h>
-#include "grovescam.hpp"
+#include "grovescam.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/groveslide.cxx b/peripheral/libupm/examples/c++/groveslide.cxx
index 04b8bb4..42e975a 100644
--- a/peripheral/libupm/examples/c++/groveslide.cxx
+++ b/peripheral/libupm/examples/c++/groveslide.cxx
@@ -26,7 +26,7 @@
#include <unistd.h>
#include <iostream>
#include <iomanip>
-#include "grove.hpp"
+#include "grove.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovespeaker.cxx b/peripheral/libupm/examples/c++/grovespeaker.cxx
index 4e139e5..97d6518 100644
--- a/peripheral/libupm/examples/c++/grovespeaker.cxx
+++ b/peripheral/libupm/examples/c++/grovespeaker.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovespeaker.hpp"
+#include "grovespeaker.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovetemp.cxx b/peripheral/libupm/examples/c++/grovetemp.cxx
index 2a21bc1..73de9c7 100644
--- a/peripheral/libupm/examples/c++/grovetemp.cxx
+++ b/peripheral/libupm/examples/c++/grovetemp.cxx
@@ -26,7 +26,7 @@
#include <unistd.h>
#include <iostream>
#include <iomanip>
-#include "grove.hpp"
+#include "grove.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/groveultrasonic.cxx b/peripheral/libupm/examples/c++/groveultrasonic.cxx
index f23e8f4..e054c4c 100644
--- a/peripheral/libupm/examples/c++/groveultrasonic.cxx
+++ b/peripheral/libupm/examples/c++/groveultrasonic.cxx
@@ -26,7 +26,7 @@
#include <unistd.h>
#include <iostream>
-#include "groveultrasonic.hpp"
+#include "groveultrasonic.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/grovevdiv.cxx b/peripheral/libupm/examples/c++/grovevdiv.cxx
index 0f90333..40be66c 100644
--- a/peripheral/libupm/examples/c++/grovevdiv.cxx
+++ b/peripheral/libupm/examples/c++/grovevdiv.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovevdiv.hpp"
+#include "grovevdiv.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovewater.cxx b/peripheral/libupm/examples/c++/grovewater.cxx
index e13f8e7..51bfacb 100644
--- a/peripheral/libupm/examples/c++/grovewater.cxx
+++ b/peripheral/libupm/examples/c++/grovewater.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovewater.hpp"
+#include "grovewater.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/grovewfs.cxx b/peripheral/libupm/examples/c++/grovewfs.cxx
index b92ff17..ea819ae 100644
--- a/peripheral/libupm/examples/c++/grovewfs.cxx
+++ b/peripheral/libupm/examples/c++/grovewfs.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "grovewfs.hpp"
+#include "grovewfs.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/guvas12d.cxx b/peripheral/libupm/examples/c++/guvas12d.cxx
index a0aa740..3351741 100644
--- a/peripheral/libupm/examples/c++/guvas12d.cxx
+++ b/peripheral/libupm/examples/c++/guvas12d.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "guvas12d.hpp"
+#include "guvas12d.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/h3lis331dl.cxx b/peripheral/libupm/examples/c++/h3lis331dl.cxx
index 714d29b..d4a04ca 100644
--- a/peripheral/libupm/examples/c++/h3lis331dl.cxx
+++ b/peripheral/libupm/examples/c++/h3lis331dl.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "h3lis331dl.hpp"
+#include "h3lis331dl.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/h803x.cxx b/peripheral/libupm/examples/c++/h803x.cxx
deleted file mode 100644
index 4416439..0000000
--- a/peripheral/libupm/examples/c++/h803x.cxx
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-
-#include "h803x.hpp"
-
-using namespace std;
-
-bool shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-
-//! [Interesting]
-
- string defaultDev = "/dev/ttyUSB0";
-
- // if an argument was specified, use it as the device instead
- if (argc > 1)
- defaultDev = string(argv[1]);
-
- cout << "Using device " << defaultDev << endl;
- cout << "Initializing..." << endl;
-
- // Instantiate an H803X instance, using MODBUS slave address 1, and
- // default comm parameters (9600, 8, N, 2)
- upm::H803X *sensor = new upm::H803X(defaultDev, 1);
-
- // output the Slave ID string
- cout << "Slave ID: " << sensor->getSlaveID() << endl;
- cout << endl;
-
- // update and print available values every second
- while (shouldRun)
- {
- // update our values from the sensor
- sensor->update();
-
- // H8035 / H8036
- cout << "Consumption (kWh): " << sensor->getConsumption() << endl;
- cout << "Real Power (kW): " << sensor->getRealPower() << endl;
-
- if (sensor->isH8036())
- {
- // The H8036 has much more data available...
-
- cout << "Reactive Power (kVAR): " << sensor->getReactivePower()
- << endl;
- cout << "Apparent Power (kVA): " << sensor->getApparentPower()
- << endl;
- cout << "Power Factor: " << sensor->getPowerFactor()
- << endl;
- cout << "Volts Line to Line: " << sensor->getVoltsLineToLine()
- << endl;
- cout << "Volts Line to Neutral: " << sensor->getVoltsLineToNeutral()
- << endl;
-
- cout << "Current: " << sensor->getCurrent()
- << endl;
-
- cout << "Real Power Phase A (kW): " << sensor->getRealPowerPhaseA()
- << endl;
- cout << "Real Power Phase B (kW): " << sensor->getRealPowerPhaseB()
- << endl;
- cout << "Real Power Phase C (kW): " << sensor->getRealPowerPhaseC()
- << endl;
-
- cout << "Power Factor Phase A: " << sensor->getPowerFactorPhaseA()
- << endl;
- cout << "Power Factor Phase B: " << sensor->getPowerFactorPhaseB()
- << endl;
- cout << "Power Factor Phase C: " << sensor->getPowerFactorPhaseC()
- << endl;
-
- cout << "Volts Phase A to B: " << sensor->getVoltsPhaseAToB()
- << endl;
- cout << "Volts Phase B to C: " << sensor->getVoltsPhaseBToC()
- << endl;
- cout << "Volts Phase A to C: " << sensor->getVoltsPhaseAToC()
- << endl;
- cout << "Volts Phase A to Neutral: "
- << sensor->getVoltsPhaseAToNeutral()
- << endl;
- cout << "Volts Phase B to Neutral: "
- << sensor->getVoltsPhaseBToNeutral()
- << endl;
- cout << "Volts Phase C to Neutral: "
- << sensor->getVoltsPhaseCToNeutral()
- << endl;
-
- cout << "Current Phase A: " << sensor->getCurrentPhaseA()
- << endl;
- cout << "Current Phase B: " << sensor->getCurrentPhaseB()
- << endl;
- cout << "Current Phase C: " << sensor->getCurrentPhaseC()
- << endl;
-
- cout << "Avg Real Power (kW): " << sensor->getAvgRealPower()
- << endl;
- cout << "Min Real Power (kW): " << sensor->getMinRealPower()
- << endl;
- cout << "Max Real Power (kW): " << sensor->getMaxRealPower()
- << endl;
- }
-
- cout << endl;
-
- sleep(2);
- }
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
-//! [Interesting]
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/hcsr04.cxx b/peripheral/libupm/examples/c++/hcsr04.cxx
index 472c293..c0a2725 100644
--- a/peripheral/libupm/examples/c++/hcsr04.cxx
+++ b/peripheral/libupm/examples/c++/hcsr04.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "hcsr04.hpp"
+#include "hcsr04.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/hdxxvxta.cxx b/peripheral/libupm/examples/c++/hdxxvxta.cxx
index c258355..2a555f3 100644
--- a/peripheral/libupm/examples/c++/hdxxvxta.cxx
+++ b/peripheral/libupm/examples/c++/hdxxvxta.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "hdxxvxta.hpp"
+#include "hdxxvxta.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/hlg150h.cxx b/peripheral/libupm/examples/c++/hlg150h.cxx
deleted file mode 100644
index b4efe33..0000000
--- a/peripheral/libupm/examples/c++/hlg150h.cxx
+++ /dev/null
@@ -1,51 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <iostream>
-#include <string>
-#include "hlg150h.hpp"
-
-#define HLG150H_GPIO_RELAY 21
-#define HLG150H_GPIO_PWM 22
-
-void printState(upm::ILightController *lightController)
-{
- if (lightController->isPowered())
- {
- std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
- }
- else
- {
- std::cout << "Light is not powered." << std::endl;
- }
-}
-
-int main( int argc, char **argv )
-{
- int status = 0;
- upm::ILightController* lightController;
-
- try {
- lightController = new upm::HLG150H(HLG150H_GPIO_RELAY, HLG150H_GPIO_PWM);
- std::cout << "Existing state: "; printState(lightController);
- if (argc == 2)
- {
- std::string arg = argv[1];
- int brightness = ::atoi(argv[1]);
- if (brightness > 0) {
- lightController->setPowerOn();
- lightController->setBrightness(brightness);
- } else
- lightController->setPowerOff();
- }
- std::cout << "Now: ";printState(lightController);
- delete lightController;
- } catch (std::exception& e) {
- std::cout << "Error: " << e.what() << std::endl;
- status = 1;
- }
-
- return status;
-}
-
-
diff --git a/peripheral/libupm/examples/c++/hm11.cxx b/peripheral/libupm/examples/c++/hm11.cxx
index 61b25e5..e759804 100644
--- a/peripheral/libupm/examples/c++/hm11.cxx
+++ b/peripheral/libupm/examples/c++/hm11.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
#include <stdio.h>
-#include "hm11.hpp"
+#include "hm11.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/hmc5883l.cxx b/peripheral/libupm/examples/c++/hmc5883l.cxx
index 7dbf700..dec08ce 100644
--- a/peripheral/libupm/examples/c++/hmc5883l.cxx
+++ b/peripheral/libupm/examples/c++/hmc5883l.cxx
@@ -24,7 +24,7 @@
*/
#include <unistd.h>
-#include "hmc5883l.hpp"
+#include "hmc5883l.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/hmtrp.cxx b/peripheral/libupm/examples/c++/hmtrp.cxx
index f711dd5..3d58ba9 100644
--- a/peripheral/libupm/examples/c++/hmtrp.cxx
+++ b/peripheral/libupm/examples/c++/hmtrp.cxx
@@ -26,7 +26,7 @@
#include <string.h>
#include <iostream>
#include <signal.h>
-#include "hmtrp.hpp"
+#include "hmtrp.h"
using namespace std;
@@ -135,7 +135,7 @@ int main (int argc, char **argv)
if (rv > 0)
cout << "Received: " << radioBuffer << endl;
- if (rv < 0) // some sort of read error occurred
+ if (rv < 0) // some sort of read error occured
{
cerr << "Port read error." << endl;
break;
diff --git a/peripheral/libupm/examples/c++/hp20x.cxx b/peripheral/libupm/examples/c++/hp20x.cxx
index ff7dd27..119a449 100644
--- a/peripheral/libupm/examples/c++/hp20x.cxx
+++ b/peripheral/libupm/examples/c++/hp20x.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "hp20x.hpp"
+#include "hp20x.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/ht9170.cxx b/peripheral/libupm/examples/c++/ht9170.cxx
index 299c82c..1be72b6 100644
--- a/peripheral/libupm/examples/c++/ht9170.cxx
+++ b/peripheral/libupm/examples/c++/ht9170.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "ht9170.hpp"
+#include "ht9170.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/htu21d.cxx b/peripheral/libupm/examples/c++/htu21d.cxx
index 31cec0f..63d6fdf 100644
--- a/peripheral/libupm/examples/c++/htu21d.cxx
+++ b/peripheral/libupm/examples/c++/htu21d.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "htu21d.hpp"
+#include "htu21d.h"
volatile int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/humidity-sensor.cxx b/peripheral/libupm/examples/c++/humidity-sensor.cxx
deleted file mode 100644
index 8bb7eb4..0000000
--- a/peripheral/libupm/examples/c++/humidity-sensor.cxx
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include "si7005.hpp"
-#include "bme280.hpp"
-
-#define EDISON_I2C_BUS 1
-#define FT4222_I2C_BUS 0
-
- #define EDISON_GPIO_SI7005_CS 20
-
-//! [Interesting]
-// Simple example of using ILightSensor to determine
-// which sensor is present and return its name.
-// ILightSensor is then used to get readings from sensor
-
-
-upm::IHumiditySensor* getHumiditySensor()
-{
- upm::IHumiditySensor* humiditySensor = NULL;
-
- try {
- humiditySensor = new upm::BME280 (mraa_get_sub_platform_id(FT4222_I2C_BUS));
- return humiditySensor ;
- } catch (std::exception& e)
- {
- std::cerr <<"BME280: "<<e.what() << std::endl;
- }
-
- try {
- humiditySensor = new upm::SI7005(EDISON_I2C_BUS, EDISON_GPIO_SI7005_CS);
- return humiditySensor;
- } catch (std::exception& e) {
- std::cerr << "SI7005: " << e.what() << std::endl;
- }
- return humiditySensor;
-}
-
-int main ()
-{
- upm::IHumiditySensor* humiditySensor = getHumiditySensor();
- if (humiditySensor == NULL) {
- std::cout << "Humidity sensor not detected" << std::endl;
- return 1;
- }
- std::cout << "Humidity sensor " << humiditySensor->getModuleName() << " detected" << std::endl;
- while (true) {
- try {
- int value = humiditySensor->getHumidityRelative();
- std::cout << "Humidity = " << value << "%" << std::endl;
- } catch (std::exception& e) {
- std::cerr << e.what() << std::endl;
- }
- sleep(1);
- }
- delete humiditySensor;
- return 0;
-}
-
-//! [Interesting]
diff --git a/peripheral/libupm/examples/c++/hwxpxx.cxx b/peripheral/libupm/examples/c++/hwxpxx.cxx
index c9d92bf..1cfdf54 100644
--- a/peripheral/libupm/examples/c++/hwxpxx.cxx
+++ b/peripheral/libupm/examples/c++/hwxpxx.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "hwxpxx.hpp"
+#include "hwxpxx.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/hx711.cxx b/peripheral/libupm/examples/c++/hx711.cxx
index e894ad8..531734b 100644
--- a/peripheral/libupm/examples/c++/hx711.cxx
+++ b/peripheral/libupm/examples/c++/hx711.cxx
@@ -26,7 +26,7 @@
#include <signal.h>
//! [Interesting]
-#include "hx711.hpp"
+#include "hx711.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/ili9341.cxx b/peripheral/libupm/examples/c++/ili9341.cxx
index 139615c..8fe397a 100644
--- a/peripheral/libupm/examples/c++/ili9341.cxx
+++ b/peripheral/libupm/examples/c++/ili9341.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
-#include "ili9341.hpp"
+#include "ili9341.h"
int main(int argc, char **argv) {
//! [Interesting]
diff --git a/peripheral/libupm/examples/c++/ina132.cxx b/peripheral/libupm/examples/c++/ina132.cxx
index 7bc6457..0c78630 100644
--- a/peripheral/libupm/examples/c++/ina132.cxx
+++ b/peripheral/libupm/examples/c++/ina132.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "ina132.hpp"
+#include "ina132.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/isd1820.cxx b/peripheral/libupm/examples/c++/isd1820.cxx
index 75d7798..3246808 100644
--- a/peripheral/libupm/examples/c++/isd1820.cxx
+++ b/peripheral/libupm/examples/c++/isd1820.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "isd1820.hpp"
+#include "isd1820.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/itg3200.cxx b/peripheral/libupm/examples/c++/itg3200.cxx
index a313cb6..a1bf8af 100644
--- a/peripheral/libupm/examples/c++/itg3200.cxx
+++ b/peripheral/libupm/examples/c++/itg3200.cxx
@@ -23,7 +23,7 @@
*/
#include <unistd.h>
-#include "itg3200.hpp"
+#include "itg3200.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/jhd1313m1-lcd.cxx b/peripheral/libupm/examples/c++/jhd1313m1-lcd.cxx
index 8e7ea03..ca2f155 100644
--- a/peripheral/libupm/examples/c++/jhd1313m1-lcd.cxx
+++ b/peripheral/libupm/examples/c++/jhd1313m1-lcd.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "jhd1313m1.hpp"
+#include "jhd1313m1.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/joystick12.cxx b/peripheral/libupm/examples/c++/joystick12.cxx
index 9e9013b..408ca2a 100644
--- a/peripheral/libupm/examples/c++/joystick12.cxx
+++ b/peripheral/libupm/examples/c++/joystick12.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "joystick12.hpp"
+#include "joystick12.h"
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/kxcjk1013.cxx b/peripheral/libupm/examples/c++/kxcjk1013.cxx
index 7676785..3732dbd 100644
--- a/peripheral/libupm/examples/c++/kxcjk1013.cxx
+++ b/peripheral/libupm/examples/c++/kxcjk1013.cxx
@@ -1,6 +1,6 @@
/*
* Author: Lay, Kuan Loon <kuan.loon.lay@intel.com>
- * Copyright (c) 2016 Intel Corporation.
+ * Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -22,11 +22,10 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include <iostream>
-#include <iomanip>
#include <unistd.h>
+#include <iostream>
#include <signal.h>
-#include "kxcjk1013.hpp"
+#include "kxcjk1013.h"
using namespace std;
@@ -45,8 +44,8 @@ data_callback(char* data)
{
float x, y, z;
accelerometer->extract3Axis(data, &x, &y, &z);
- cout << fixed << setprecision(1);
- cout << x << '\t' << y << '\t' << z << "[m/s^2]" << endl;
+ printf("%.1f %.1f %.1f\n", x, y, z);
+ // usleep(100);
}
int
@@ -56,10 +55,7 @@ main()
//! [Interesting]
// Instantiate a KXCJK1013 Accelerometer Sensor on iio device 0
accelerometer = new upm::KXCJK1013(0);
- // Available scales are 0.009582(2g), 0.019163(4g), and 0.038326(8g)
accelerometer->setScale(0.019163);
- // Available sampling frequency are 0.781000, 1.563000, 3.125000, 6.250000, 12.500000, 25, 50,
- // 100, 200, 400, 800, and 1600
accelerometer->setSamplingFrequency(25.0);
accelerometer->enable3AxisChannel();
accelerometer->installISR(data_callback, NULL);
diff --git a/peripheral/libupm/examples/c++/l298-stepper.cxx b/peripheral/libupm/examples/c++/l298-stepper.cxx
index 8436175..8fe2b91 100644
--- a/peripheral/libupm/examples/c++/l298-stepper.cxx
+++ b/peripheral/libupm/examples/c++/l298-stepper.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "l298.hpp"
+#include "l298.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/l298.cxx b/peripheral/libupm/examples/c++/l298.cxx
index ff972ee..8e360b2 100644
--- a/peripheral/libupm/examples/c++/l298.cxx
+++ b/peripheral/libupm/examples/c++/l298.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "l298.hpp"
+#include "l298.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/l3gd20.cxx b/peripheral/libupm/examples/c++/l3gd20.cxx
deleted file mode 100644
index 2795686..0000000
--- a/peripheral/libupm/examples/c++/l3gd20.cxx
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Author: Lay, Kuan Loon <kuan.loon.lay@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-#include <iomanip>
-#include <unistd.h>
-#include <signal.h>
-#include "l3gd20.hpp"
-
-using namespace std;
-
-int shouldRun = true;
-upm::L3GD20* gyroscope;
-
-void
-sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-void
-data_callback(char* data)
-{
- float x, y, z;
- if (gyroscope->extract3Axis(data, &x, &y, &z)) {
- cout << fixed << setprecision(1);
- cout << x << '\t' << y << '\t' << z << "[rad/sec]" << endl;
- }
-}
-
-int
-main()
-{
- signal(SIGINT, sig_handler);
- //! [Interesting]
- // Instantiate a L3GD20 Gyroscope Sensor on iio device 3
- gyroscope = new upm::L3GD20(3);
- // Available scales are 0.000153(250dps), 0.000305(500dps), and 0.001222(2000dps)
- gyroscope->setScale(0.001222);
- // Available sampling frequency are 95, 190, 380, and 760
- gyroscope->setSamplingFrequency(95.0);
- gyroscope->enable3AxisChannel();
- gyroscope->installISR(data_callback, NULL);
- gyroscope->enableBuffer(16);
-
- while (shouldRun) {
- sleep(1);
- }
- gyroscope->disableBuffer();
-
- //! [Interesting]
- cout << "Exiting" << endl;
-
- delete gyroscope;
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/lcm1602-i2c.cxx b/peripheral/libupm/examples/c++/lcm1602-i2c.cxx
index 66ae8f2..f405f96 100644
--- a/peripheral/libupm/examples/c++/lcm1602-i2c.cxx
+++ b/peripheral/libupm/examples/c++/lcm1602-i2c.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "lcm1602.hpp"
+#include "lcm1602.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/lcm1602-parallel.cxx b/peripheral/libupm/examples/c++/lcm1602-parallel.cxx
index d85ab06..642c6af 100644
--- a/peripheral/libupm/examples/c++/lcm1602-parallel.cxx
+++ b/peripheral/libupm/examples/c++/lcm1602-parallel.cxx
@@ -23,7 +23,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include <lcm1602.hpp>
+#include <lcm1602.h>
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/ldt0028.cxx b/peripheral/libupm/examples/c++/ldt0028.cxx
index baaac11..8d9c8b7 100644
--- a/peripheral/libupm/examples/c++/ldt0028.cxx
+++ b/peripheral/libupm/examples/c++/ldt0028.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <iomanip>
#include <cmath>
-#include "ldt0028.hpp"
+#include "ldt0028.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/light-controller.cxx b/peripheral/libupm/examples/c++/light-controller.cxx
deleted file mode 100644
index 5c734d6..0000000
--- a/peripheral/libupm/examples/c++/light-controller.cxx
+++ /dev/null
@@ -1,98 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <iostream>
-#include <string>
-#include "lp8860.hpp"
-#include "ds1808lc.hpp"
-#include "hlg150h.hpp"
-
-#define EDISON_I2C_BUS 1 // Edison I2C-1
-#define GPIO_SI7005_CS 20 // Edison GP12
-#define HLG150H_GPIO_RELAY 21
-#define HLG150H_GPIO_PWM 22
-#define LP8860_GPIO_PWR 45 // Edison GP45
-#define DS1808_GPIO_PWR 15 // Edison GP165
-#define DS1808_GPIO_EDISON_LIVE 36 // Edison GP14
-
-//! [Interesting]
-// Simple example of using ILightController to determine
-// which controller is present and return its name.
-// ILightController is then used to get readings from sensor
-
-upm::ILightController* getLightController()
-{
- upm::ILightController* lightController = NULL;
- try {
- lightController = new upm::LP8860(LP8860_GPIO_PWR, EDISON_I2C_BUS);
- return lightController;
- } catch (std::exception& e) {
- std::cerr << "LP8860: " << e.what() << std::endl;
- }
- try {
- lightController = new upm::DS1808LC(DS1808_GPIO_PWR, EDISON_I2C_BUS);
- return lightController;
- } catch (std::exception& e) {
- std::cerr << "DS1808LC: " << e.what() << std::endl;
- }
- try {
- lightController = new upm::HLG150H(HLG150H_GPIO_RELAY, HLG150H_GPIO_PWM);
- return lightController;
- } catch (std::exception& e) {
- std::cerr << "HLG150H: " << e.what() << std::endl;
- }
- return lightController;
-}
-
-
-void printState(upm::ILightController *lightController)
-{
- if (lightController->isPowered())
- {
- std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
- }
- else
- {
- std::cout << "Light is not powered." << std::endl;
- }
-}
-
-int main( int argc, char **argv )
-{
- int status = 0;
- // MraaUtils::setGpio(GPIO_SI7005_CS, 1);
-
- upm::ILightController *lightController = getLightController();
- if (lightController != NULL)
- {
- std::cout << "Detected light controller " << lightController->getModuleName() << std::endl;
- }
- else
- {
- std::cerr << "Error. Unsupported platform." << std::endl;
- return 1;
- }
-
- try {
- std::cout << "Existing state: "; printState(lightController);
- if (argc == 2)
- {
- std::string arg = argv[1];
- int brightness = ::atoi(argv[1]);
- if (brightness > 0) {
- lightController->setPowerOn();
- lightController->setBrightness(brightness);
- } else
- lightController->setPowerOff();
- }
- std::cout << "Now: ";printState(lightController);
- } catch (std::exception& e) {
- std::cout << "Error: " << e.what() << std::endl;
- status = 1;
- }
-
- delete lightController;
- return status;
-}
-
-
diff --git a/peripheral/libupm/examples/c++/light-sensor.cxx b/peripheral/libupm/examples/c++/light-sensor.cxx
deleted file mode 100644
index c4b87ea..0000000
--- a/peripheral/libupm/examples/c++/light-sensor.cxx
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include "max44009.hpp"
-#include "si1132.hpp"
-
-#define EDISON_I2C_BUS 1
-#define FT4222_I2C_BUS 0
-
-//! [Interesting]
-// Simple example of using ILightSensor to determine
-// which sensor is present and return its name.
-// ILightSensor is then used to get readings from sensor
-
-
-upm::ILightSensor* getLightSensor()
-{
- upm::ILightSensor* lightSensor = NULL;
- try {
- lightSensor = new upm::SI1132(mraa_get_sub_platform_id(FT4222_I2C_BUS));
- return lightSensor;
- } catch (std::exception& e) {
- std::cerr << "SI1132: " << e.what() << std::endl;
- }
- try {
- lightSensor = new upm::MAX44009(EDISON_I2C_BUS);
- return lightSensor;
- } catch (std::exception& e) {
- std::cerr << "MAX44009: " << e.what() << std::endl;
- }
- return lightSensor;
-}
-
-int main ()
-{
- upm::ILightSensor* lightSensor = getLightSensor();
- if (lightSensor == NULL) {
- std::cout << "Light sensor not detected" << std::endl;
- return 1;
- }
- std::cout << "Light sensor " << lightSensor->getModuleName() << " detected" << std::endl;
- while (true) {
- try {
- float value = lightSensor->getVisibleLux();
- std::cout << "Light level = " << value << " lux" << std::endl;
- } catch (std::exception& e) {
- std::cerr << e.what() << std::endl;
- }
- sleep(1);
- }
- delete lightSensor;
- return 0;
-}
-
-//! [Interesting] \ No newline at end of file
diff --git a/peripheral/libupm/examples/c++/lm35.cxx b/peripheral/libupm/examples/c++/lm35.cxx
index abdfd91..8930940 100644
--- a/peripheral/libupm/examples/c++/lm35.cxx
+++ b/peripheral/libupm/examples/c++/lm35.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "lm35.hpp"
+#include "lm35.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/lol.cxx b/peripheral/libupm/examples/c++/lol.cxx
index 9cf71bd..9f2943d 100644
--- a/peripheral/libupm/examples/c++/lol.cxx
+++ b/peripheral/libupm/examples/c++/lol.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "lol.hpp"
+#include "lol.h"
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/loudness.cxx b/peripheral/libupm/examples/c++/loudness.cxx
index 9eaa59b..44e62b0 100644
--- a/peripheral/libupm/examples/c++/loudness.cxx
+++ b/peripheral/libupm/examples/c++/loudness.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "loudness.hpp"
+#include "loudness.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/lp8860.cxx b/peripheral/libupm/examples/c++/lp8860.cxx
deleted file mode 100644
index 81d8629..0000000
--- a/peripheral/libupm/examples/c++/lp8860.cxx
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <iostream>
-#include <string>
-#include "lp8860.hpp"
-
-#define EDISON_I2C_BUS 1 // Edison I2C-1
-#define LP8860_GPIO_PWR 45 // Edison GP45
-
-
-void printState(upm::ILightController *lightController)
-{
- if (lightController->isPowered())
- {
- std::cout << "Light is powered, brightness = " << lightController->getBrightness() << std::endl;
- }
- else
- {
- std::cout << "Light is not powered." << std::endl;
- }
-}
-
-int main( int argc, char **argv )
-{
- int status = 0;
- upm::LP8860* lightController;
-
- try {
- lightController = new upm::LP8860(LP8860_GPIO_PWR, EDISON_I2C_BUS);
- std::cout << "Existing state: "; printState(lightController);
- if (argc == 2)
- {
- std::string arg = argv[1];
- int brightness = ::atoi(argv[1]);
- if (brightness > 0) {
- lightController->setPowerOn();
- lightController->setBrightness(brightness);
- } else
- lightController->setPowerOff();
- }
- std::cout << "Now: ";printState(lightController);
- delete lightController;
- } catch (std::exception& e) {
- std::cout << "Error: " << e.what() << std::endl;
- status = 1;
- }
-
- return status;
-}
-
-
diff --git a/peripheral/libupm/examples/c++/lpd8806.cxx b/peripheral/libupm/examples/c++/lpd8806.cxx
index bc1e17f..8828f07 100644
--- a/peripheral/libupm/examples/c++/lpd8806.cxx
+++ b/peripheral/libupm/examples/c++/lpd8806.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "lpd8806.hpp"
+#include "lpd8806.h"
#include <signal.h>
void scanner(uint8_t r, uint8_t g, uint8_t b, uint8_t wait);
diff --git a/peripheral/libupm/examples/c++/lsm303.cxx b/peripheral/libupm/examples/c++/lsm303.cxx
index 94e9b7b..f75fd5b 100644
--- a/peripheral/libupm/examples/c++/lsm303.cxx
+++ b/peripheral/libupm/examples/c++/lsm303.cxx
@@ -25,7 +25,7 @@
#include <iostream>
//! [Interesting]
-#include "lsm303.hpp"
+#include "lsm303.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/lsm9ds0.cxx b/peripheral/libupm/examples/c++/lsm9ds0.cxx
index 655e02c..66644a0 100644
--- a/peripheral/libupm/examples/c++/lsm9ds0.cxx
+++ b/peripheral/libupm/examples/c++/lsm9ds0.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "lsm9ds0.hpp"
+#include "lsm9ds0.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/m24lr64e.cxx b/peripheral/libupm/examples/c++/m24lr64e.cxx
index 63b186f..6c3aae0 100644
--- a/peripheral/libupm/examples/c++/m24lr64e.cxx
+++ b/peripheral/libupm/examples/c++/m24lr64e.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "m24lr64e.hpp"
+#include "m24lr64e.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/max31723.cxx b/peripheral/libupm/examples/c++/max31723.cxx
index 4b98310..96082af 100644
--- a/peripheral/libupm/examples/c++/max31723.cxx
+++ b/peripheral/libupm/examples/c++/max31723.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "max31723.hpp"
+#include "max31723.h"
#include <signal.h>
int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/max31855.cxx b/peripheral/libupm/examples/c++/max31855.cxx
index 6e72998..2390d93 100644
--- a/peripheral/libupm/examples/c++/max31855.cxx
+++ b/peripheral/libupm/examples/c++/max31855.cxx
@@ -27,7 +27,7 @@
#include <signal.h>
//! [Interesting]
-#include "max31855.hpp"
+#include "max31855.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/max44000.cxx b/peripheral/libupm/examples/c++/max44000.cxx
index c344bdf..404f544 100644
--- a/peripheral/libupm/examples/c++/max44000.cxx
+++ b/peripheral/libupm/examples/c++/max44000.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "max44000.hpp"
+#include "max44000.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/max44009.cxx b/peripheral/libupm/examples/c++/max44009.cxx
deleted file mode 100644
index bf911cb..0000000
--- a/peripheral/libupm/examples/c++/max44009.cxx
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include "max44009.hpp"
-
-#define EDISON_I2C_BUS 1
-
-int main ()
-{
- try {
- upm::MAX44009* lightSensor = new upm::MAX44009(EDISON_I2C_BUS);
- while (true) {
- float value = lightSensor->getVisibleLux();
- std::cout << "Light level = " << value << " lux" << std::endl;
- sleep(1);
- }
- delete lightSensor;
- } catch (std::exception& e) {
- std::cerr << e.what() << std::endl;
- return 1;
- }
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/max5487.cxx b/peripheral/libupm/examples/c++/max5487.cxx
index a13223a..661be05 100644
--- a/peripheral/libupm/examples/c++/max5487.cxx
+++ b/peripheral/libupm/examples/c++/max5487.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "max5487.hpp"
+#include "max5487.h"
#include <signal.h>
upm::MAX5487 *sensor = NULL;
diff --git a/peripheral/libupm/examples/c++/maxds3231m.cxx b/peripheral/libupm/examples/c++/maxds3231m.cxx
index ef5f95f..e5a6fc1 100644
--- a/peripheral/libupm/examples/c++/maxds3231m.cxx
+++ b/peripheral/libupm/examples/c++/maxds3231m.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "maxds3231m.hpp"
+#include "maxds3231m.h"
#include <signal.h>
int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/maxsonarez.cxx b/peripheral/libupm/examples/c++/maxsonarez.cxx
index 5ffb5c1..3c3d300 100644
--- a/peripheral/libupm/examples/c++/maxsonarez.cxx
+++ b/peripheral/libupm/examples/c++/maxsonarez.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "maxsonarez.hpp"
+#include "maxsonarez.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mcp9808.cxx b/peripheral/libupm/examples/c++/mcp9808.cxx
index 32076da..ba4e5e4 100644
--- a/peripheral/libupm/examples/c++/mcp9808.cxx
+++ b/peripheral/libupm/examples/c++/mcp9808.cxx
@@ -1,6 +1,6 @@
#include <iostream>
#include <unistd.h>
-#include "mcp9808.hpp"
+#include "mcp9808.h"
#include "mraa.hpp"
diff --git a/peripheral/libupm/examples/c++/mg811.cxx b/peripheral/libupm/examples/c++/mg811.cxx
index 3d334c1..b17423c 100644
--- a/peripheral/libupm/examples/c++/mg811.cxx
+++ b/peripheral/libupm/examples/c++/mg811.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "mg811.hpp"
+#include "mg811.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mhz16.cxx b/peripheral/libupm/examples/c++/mhz16.cxx
index dae109d..542dc5f 100644
--- a/peripheral/libupm/examples/c++/mhz16.cxx
+++ b/peripheral/libupm/examples/c++/mhz16.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "mhz16.hpp"
+#include "mhz16.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mic.cxx b/peripheral/libupm/examples/c++/mic.cxx
index bb7ae22..8773d71 100644
--- a/peripheral/libupm/examples/c++/mic.cxx
+++ b/peripheral/libupm/examples/c++/mic.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mic.hpp"
+#include "mic.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/micsv89.cxx b/peripheral/libupm/examples/c++/micsv89.cxx
index b2e4274..cf1530b 100644
--- a/peripheral/libupm/examples/c++/micsv89.cxx
+++ b/peripheral/libupm/examples/c++/micsv89.cxx
@@ -25,7 +25,7 @@
#include <iostream>
#include <unistd.h>
#include <signal.h>
-#include "micsv89.hpp"
+#include "micsv89.h"
/*
* An example for using the MICSV89 sensor library.
diff --git a/peripheral/libupm/examples/c++/mlx90614.cxx b/peripheral/libupm/examples/c++/mlx90614.cxx
index c7f2a3f..dbd00f4 100644
--- a/peripheral/libupm/examples/c++/mlx90614.cxx
+++ b/peripheral/libupm/examples/c++/mlx90614.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mlx90614.hpp"
+#include "mlx90614.h"
#include <signal.h>
int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/mma7455.cxx b/peripheral/libupm/examples/c++/mma7455.cxx
index 0e73233..052919f 100644
--- a/peripheral/libupm/examples/c++/mma7455.cxx
+++ b/peripheral/libupm/examples/c++/mma7455.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mma7455.hpp"
+#include "mma7455.h"
#include <signal.h>
#include <pthread.h>
diff --git a/peripheral/libupm/examples/c++/mma7660.cxx b/peripheral/libupm/examples/c++/mma7660.cxx
index 19e3e02..c426db5 100644
--- a/peripheral/libupm/examples/c++/mma7660.cxx
+++ b/peripheral/libupm/examples/c++/mma7660.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "mma7660.hpp"
+#include "mma7660.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mpl3115a2.cxx b/peripheral/libupm/examples/c++/mpl3115a2.cxx
index 77890f1..f9499d1 100644
--- a/peripheral/libupm/examples/c++/mpl3115a2.cxx
+++ b/peripheral/libupm/examples/c++/mpl3115a2.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "mpl3115a2.hpp"
+#include "mpl3115a2.h"
volatile int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/mpr121.cxx b/peripheral/libupm/examples/c++/mpr121.cxx
index e8aa4b7..7998965 100644
--- a/peripheral/libupm/examples/c++/mpr121.cxx
+++ b/peripheral/libupm/examples/c++/mpr121.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "mpr121.hpp"
+#include "mpr121.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mpu60x0.cxx b/peripheral/libupm/examples/c++/mpu60x0.cxx
index 63882cd..d90a017 100644
--- a/peripheral/libupm/examples/c++/mpu60x0.cxx
+++ b/peripheral/libupm/examples/c++/mpu60x0.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "mpu9150.hpp"
+#include "mpu9150.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mpu9150.cxx b/peripheral/libupm/examples/c++/mpu9150.cxx
index df75057..d6f5da5 100644
--- a/peripheral/libupm/examples/c++/mpu9150.cxx
+++ b/peripheral/libupm/examples/c++/mpu9150.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "mpu9150.hpp"
+#include "mpu9150.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mpu9250.cxx b/peripheral/libupm/examples/c++/mpu9250.cxx
index ecd8877..fd093f9 100644
--- a/peripheral/libupm/examples/c++/mpu9250.cxx
+++ b/peripheral/libupm/examples/c++/mpu9250.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "mpu9250.hpp"
+#include "mpu9250.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mq2.cxx b/peripheral/libupm/examples/c++/mq2.cxx
index 040706e..f3bd9ca 100644
--- a/peripheral/libupm/examples/c++/mq2.cxx
+++ b/peripheral/libupm/examples/c++/mq2.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq2.hpp"
+#include "mq2.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/mq3.cxx b/peripheral/libupm/examples/c++/mq3.cxx
index 13e7586..9fd3cce 100644
--- a/peripheral/libupm/examples/c++/mq3.cxx
+++ b/peripheral/libupm/examples/c++/mq3.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq3.hpp"
+#include "mq3.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/mq303a.cxx b/peripheral/libupm/examples/c++/mq303a.cxx
index 8a8764d..4557de0 100644
--- a/peripheral/libupm/examples/c++/mq303a.cxx
+++ b/peripheral/libupm/examples/c++/mq303a.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "mq303a.hpp"
+#include "mq303a.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/mq4.cxx b/peripheral/libupm/examples/c++/mq4.cxx
index 87d5daf..686970b 100644
--- a/peripheral/libupm/examples/c++/mq4.cxx
+++ b/peripheral/libupm/examples/c++/mq4.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq4.hpp"
+#include "mq4.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/mq5.cxx b/peripheral/libupm/examples/c++/mq5.cxx
index 89c0a52..541bb26 100644
--- a/peripheral/libupm/examples/c++/mq5.cxx
+++ b/peripheral/libupm/examples/c++/mq5.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq5.hpp"
+#include "mq5.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/mq6.cxx b/peripheral/libupm/examples/c++/mq6.cxx
index be25f14..0a73af1 100644
--- a/peripheral/libupm/examples/c++/mq6.cxx
+++ b/peripheral/libupm/examples/c++/mq6.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq6.hpp"
+#include "mq6.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/mq7.cxx b/peripheral/libupm/examples/c++/mq7.cxx
index 561fde0..a6279f1 100644
--- a/peripheral/libupm/examples/c++/mq7.cxx
+++ b/peripheral/libupm/examples/c++/mq7.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq7.hpp"
+#include "mq7.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/mq8.cxx b/peripheral/libupm/examples/c++/mq8.cxx
index 5f9fb28..eae583f 100644
--- a/peripheral/libupm/examples/c++/mq8.cxx
+++ b/peripheral/libupm/examples/c++/mq8.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq8.hpp"
+#include "mq8.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/mq9.cxx b/peripheral/libupm/examples/c++/mq9.cxx
index f1a8cd3..b62dad3 100644
--- a/peripheral/libupm/examples/c++/mq9.cxx
+++ b/peripheral/libupm/examples/c++/mq9.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "mq9.hpp"
+#include "mq9.h"
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/peripheral/libupm/examples/c++/nlgpio16.cxx b/peripheral/libupm/examples/c++/nlgpio16.cxx
index ecd9f02..44c901e 100644
--- a/peripheral/libupm/examples/c++/nlgpio16.cxx
+++ b/peripheral/libupm/examples/c++/nlgpio16.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
#include <stdio.h>
-#include "nlgpio16.hpp"
+#include "nlgpio16.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/nrf24l01-broadcast.cxx b/peripheral/libupm/examples/c++/nrf24l01-broadcast.cxx
index 81c70e0..f4a1d21 100644
--- a/peripheral/libupm/examples/c++/nrf24l01-broadcast.cxx
+++ b/peripheral/libupm/examples/c++/nrf24l01-broadcast.cxx
@@ -25,7 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <iostream>
-#include "nrf24l01.hpp"
+#include "nrf24l01.h"
#include <signal.h>
#include <stdio.h>
#include <vector>
diff --git a/peripheral/libupm/examples/c++/nrf24l01-receiver.cxx b/peripheral/libupm/examples/c++/nrf24l01-receiver.cxx
index a2430af..344cb0c 100644
--- a/peripheral/libupm/examples/c++/nrf24l01-receiver.cxx
+++ b/peripheral/libupm/examples/c++/nrf24l01-receiver.cxx
@@ -25,7 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <iostream>
-#include "nrf24l01.hpp"
+#include "nrf24l01.h"
#include <signal.h>
int running = 0;
diff --git a/peripheral/libupm/examples/c++/nrf24l01-transmitter.cxx b/peripheral/libupm/examples/c++/nrf24l01-transmitter.cxx
index d64cf2e..5d9f7cc 100644
--- a/peripheral/libupm/examples/c++/nrf24l01-transmitter.cxx
+++ b/peripheral/libupm/examples/c++/nrf24l01-transmitter.cxx
@@ -25,7 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <iostream>
-#include "nrf24l01.hpp"
+#include "nrf24l01.h"
#include <signal.h>
int running = 0;
diff --git a/peripheral/libupm/examples/c++/nrf8001-broadcast.cxx b/peripheral/libupm/examples/c++/nrf8001-broadcast.cxx
index a30e15d..534e32b 100644
--- a/peripheral/libupm/examples/c++/nrf8001-broadcast.cxx
+++ b/peripheral/libupm/examples/c++/nrf8001-broadcast.cxx
@@ -24,8 +24,8 @@
#include <unistd.h>
#include <iostream>
-#include "nrf8001.hpp"
-#include "nrf8001-broadcast.hpp"
+#include "nrf8001.h"
+#include "nrf8001-broadcast.h"
#include <lib_aci.h>
#include <aci_setup.h>
#include <signal.h>
diff --git a/peripheral/libupm/examples/c++/nrf8001-broadcast.hpp b/peripheral/libupm/examples/c++/nrf8001-broadcast.h
index b6f8cb5..b6f8cb5 100644
--- a/peripheral/libupm/examples/c++/nrf8001-broadcast.hpp
+++ b/peripheral/libupm/examples/c++/nrf8001-broadcast.h
diff --git a/peripheral/libupm/examples/c++/nrf8001-helloworld.cxx b/peripheral/libupm/examples/c++/nrf8001-helloworld.cxx
index 9da070f..5866a0f 100644
--- a/peripheral/libupm/examples/c++/nrf8001-helloworld.cxx
+++ b/peripheral/libupm/examples/c++/nrf8001-helloworld.cxx
@@ -24,8 +24,8 @@
#include <unistd.h>
#include <iostream>
-#include "nrf8001.hpp"
-#include "nrf8001-helloworld.hpp"
+#include "nrf8001.h"
+#include "nrf8001-helloworld.h"
#include <lib_aci.h>
#include <aci_setup.h>
#include <signal.h>
diff --git a/peripheral/libupm/examples/c++/nrf8001-helloworld.hpp b/peripheral/libupm/examples/c++/nrf8001-helloworld.h
index ec566b5..ec566b5 100644
--- a/peripheral/libupm/examples/c++/nrf8001-helloworld.hpp
+++ b/peripheral/libupm/examples/c++/nrf8001-helloworld.h
diff --git a/peripheral/libupm/examples/c++/nunchuck.cxx b/peripheral/libupm/examples/c++/nunchuck.cxx
index 03d2cbb..4b9d617 100644
--- a/peripheral/libupm/examples/c++/nunchuck.cxx
+++ b/peripheral/libupm/examples/c++/nunchuck.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "nunchuck.hpp"
+#include "nunchuck.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/otp538u.cxx b/peripheral/libupm/examples/c++/otp538u.cxx
index 914350f..ea6e3b3 100644
--- a/peripheral/libupm/examples/c++/otp538u.cxx
+++ b/peripheral/libupm/examples/c++/otp538u.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <iomanip>
#include <signal.h>
-#include "otp538u.hpp"
+#include "otp538u.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ozw.cxx b/peripheral/libupm/examples/c++/ozw.cxx
index ab9521a..40c30f4 100644
--- a/peripheral/libupm/examples/c++/ozw.cxx
+++ b/peripheral/libupm/examples/c++/ozw.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
-#include "ozw.hpp"
+#include "ozw.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/pca9685.cxx b/peripheral/libupm/examples/c++/pca9685.cxx
index 82f3986..0806e40 100644
--- a/peripheral/libupm/examples/c++/pca9685.cxx
+++ b/peripheral/libupm/examples/c++/pca9685.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "pca9685.hpp"
+#include "pca9685.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/pn532-writeurl.cxx b/peripheral/libupm/examples/c++/pn532-writeurl.cxx
index 8e63f54..f7fc956 100644
--- a/peripheral/libupm/examples/c++/pn532-writeurl.cxx
+++ b/peripheral/libupm/examples/c++/pn532-writeurl.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "pn532.hpp"
+#include "pn532.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/pn532.cxx b/peripheral/libupm/examples/c++/pn532.cxx
index ea66a02..d1b7ba0 100644
--- a/peripheral/libupm/examples/c++/pn532.cxx
+++ b/peripheral/libupm/examples/c++/pn532.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <signal.h>
#include <iostream>
-#include "pn532.hpp"
+#include "pn532.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/ppd42ns.cxx b/peripheral/libupm/examples/c++/ppd42ns.cxx
index 8a2a302..38a64e5 100644
--- a/peripheral/libupm/examples/c++/ppd42ns.cxx
+++ b/peripheral/libupm/examples/c++/ppd42ns.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "ppd42ns.hpp"
+#include "ppd42ns.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/pressure-sensor.cxx b/peripheral/libupm/examples/c++/pressure-sensor.cxx
deleted file mode 100644
index 891f6a6..0000000
--- a/peripheral/libupm/examples/c++/pressure-sensor.cxx
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include "bmpx8x.hpp"
-#include "bme280.hpp"
-
-
-#define EDISON_I2C_BUS 1
-#define FT4222_I2C_BUS 0
-
-//! [Interesting]
-// Simple example of using ILightSensor to determine
-// which sensor is present and return its name.
-// ILightSensor is then used to get readings from sensor
-
-
-upm::IPressureSensor* getPressureSensor()
-{
- upm::IPressureSensor* pressureSensor = NULL;
- try {
- pressureSensor = new upm::BME280 (mraa_get_sub_platform_id(FT4222_I2C_BUS));
- return pressureSensor ;
- } catch (std::exception& e)
- {
- std::cerr <<"BME280: "<<e.what() << std::endl;
- }
-
- try {
- pressureSensor = new upm::BMPX8X(EDISON_I2C_BUS);
- return pressureSensor;
- } catch (std::exception& e) {
- std::cerr << "BMPX8X: " << e.what() << std::endl;
- }
- return pressureSensor;
-}
-
-int main ()
-{
- upm::IPressureSensor* pressureSensor = getPressureSensor();
- if (pressureSensor == NULL) {
- std::cout << "Pressure sensor not detected" << std::endl;
- return 1;
- }
- std::cout << "Pressure sensor " << pressureSensor->getModuleName() << " detected" << std::endl;
- while (true) {
- try {
- int value = pressureSensor->getPressurePa();
- std::cout << "Pressure = " << value << " Pa" << std::endl;
- } catch (std::exception& e) {
- std::cerr << e.what() << std::endl;
- }
- sleep(1);
- }
- delete pressureSensor;
- return 0;
-}
-
-//! [Interesting]
diff --git a/peripheral/libupm/examples/c++/pulsensor.cxx b/peripheral/libupm/examples/c++/pulsensor.cxx
index a2919e9..dcb9cba 100644
--- a/peripheral/libupm/examples/c++/pulsensor.cxx
+++ b/peripheral/libupm/examples/c++/pulsensor.cxx
@@ -24,7 +24,7 @@
#include <string.h>
#include <unistd.h>
-#include "pulsensor.hpp"
+#include "pulsensor.h"
#include <signal.h>
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/rfr359f.cxx b/peripheral/libupm/examples/c++/rfr359f.cxx
index 81b2d48..b7a8c21 100644
--- a/peripheral/libupm/examples/c++/rfr359f.cxx
+++ b/peripheral/libupm/examples/c++/rfr359f.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "rfr359f.hpp"
+#include "rfr359f.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/rgbringcoder.cxx b/peripheral/libupm/examples/c++/rgbringcoder.cxx
index c648bba..52644cd 100644
--- a/peripheral/libupm/examples/c++/rgbringcoder.cxx
+++ b/peripheral/libupm/examples/c++/rgbringcoder.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "rgbringcoder.hpp"
+#include "rgbringcoder.h"
#include <signal.h>
using namespace std;
diff --git a/peripheral/libupm/examples/c++/rhusb.cxx b/peripheral/libupm/examples/c++/rhusb.cxx
index 0b14aaa..20f12ed 100644
--- a/peripheral/libupm/examples/c++/rhusb.cxx
+++ b/peripheral/libupm/examples/c++/rhusb.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "rhusb.hpp"
+#include "rhusb.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/rotaryencoder.cxx b/peripheral/libupm/examples/c++/rotaryencoder.cxx
index e211f03..f6c505e 100644
--- a/peripheral/libupm/examples/c++/rotaryencoder.cxx
+++ b/peripheral/libupm/examples/c++/rotaryencoder.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "rotaryencoder.hpp"
+#include "rotaryencoder.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/rpr220-intr.cxx b/peripheral/libupm/examples/c++/rpr220-intr.cxx
index 401640c..05a8381 100644
--- a/peripheral/libupm/examples/c++/rpr220-intr.cxx
+++ b/peripheral/libupm/examples/c++/rpr220-intr.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "rpr220.hpp"
+#include "rpr220.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/rpr220.cxx b/peripheral/libupm/examples/c++/rpr220.cxx
index dffffc8..c9bdf1d 100644
--- a/peripheral/libupm/examples/c++/rpr220.cxx
+++ b/peripheral/libupm/examples/c++/rpr220.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "rpr220.hpp"
+#include "rpr220.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/sainsmartks.cxx b/peripheral/libupm/examples/c++/sainsmartks.cxx
index 8f17033..19c8704 100644
--- a/peripheral/libupm/examples/c++/sainsmartks.cxx
+++ b/peripheral/libupm/examples/c++/sainsmartks.cxx
@@ -26,7 +26,7 @@
#include <signal.h>
#include <iostream>
-#include "sainsmartks.hpp"
+#include "sainsmartks.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/si1132.cxx b/peripheral/libupm/examples/c++/si1132.cxx
deleted file mode 100644
index 31d5bde..0000000
--- a/peripheral/libupm/examples/c++/si1132.cxx
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include "si1132.hpp"
-
-#define FT4222_I2C_BUS 1
-
-int main ()
-{
- try {
- upm::SI1132* lightSensor = new upm::SI1132(mraa_get_sub_platform_id(FT4222_I2C_BUS));
- while (true) {
- float value = lightSensor->getVisibleLux();
- std::cout << "Light level = " << value << " lux" << std::endl;
- sleep(1);
- }
- delete lightSensor;
- } catch (std::exception& e) {
- std::cerr << e.what() << std::endl;
- return 1;
- }
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/si114x.cxx b/peripheral/libupm/examples/c++/si114x.cxx
index cf9d168..4c069c9 100644
--- a/peripheral/libupm/examples/c++/si114x.cxx
+++ b/peripheral/libupm/examples/c++/si114x.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "si114x.hpp"
+#include "si114x.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/si7005.cxx b/peripheral/libupm/examples/c++/si7005.cxx
deleted file mode 100644
index 97e013d..0000000
--- a/peripheral/libupm/examples/c++/si7005.cxx
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include "si7005.hpp"
-
-#define EDISON_I2C_BUS 1
-#define EDISON_GPIO_SI7005_CS 20
-
-
-int main ()
-{
- try {
- upm::SI7005* sensor = new upm::SI7005(EDISON_I2C_BUS, EDISON_GPIO_SI7005_CS);
- while (true) {
- int temperature = sensor->getTemperatureCelcius();
- int humidity = sensor->getHumidityRelative();
- std::cout << "Temperature = " << temperature << "C" << std::endl;
- std::cout << "Humidity = " << humidity << "%" << std::endl;
- sleep(1);
- }
- delete sensor;
- } catch (std::exception& e) {
- std::cerr << e.what() << std::endl;
- }
- return 0;
-}
-
-//! [Interesting]
diff --git a/peripheral/libupm/examples/c++/sm130.cxx b/peripheral/libupm/examples/c++/sm130.cxx
index 2712790..3d1e3bd 100644
--- a/peripheral/libupm/examples/c++/sm130.cxx
+++ b/peripheral/libupm/examples/c++/sm130.cxx
@@ -27,7 +27,7 @@
#include <string>
#include <signal.h>
#include <stdio.h>
-#include "sm130.hpp"
+#include "sm130.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/smartdrive.cxx b/peripheral/libupm/examples/c++/smartdrive.cxx
deleted file mode 100644
index ab943fd..0000000
--- a/peripheral/libupm/examples/c++/smartdrive.cxx
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Author: Oussema Harbi <oussema.elharbi@gmail.com>
- * Copyright (c) <2016> <Oussema Harbi>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include "smartdrive.hpp"
-#include <signal.h>
-
-upm::SmartDrive *drive = NULL;
-
-void
-sig_handler(int signo)
-{
- printf("got signal\n");
- if (signo == SIGINT) {
- printf("exiting application\n");
- if (drive != NULL)
- delete drive;
- exit (0);
- }
-}
-
-int
-main(int argc, char **argv)
-{
- float voltage = 0;
-
- std::cout << "SmartDrive demo is starting. Please make sure drive is connected to board" << std::endl;
- sleep(2); //Wait for 2 seconds in case you want to fix your h/w setup
-
- //! [Interesting]
- // Instantiate a SmartDrive connected to /dev/i2c-0 bus, using DefaultAddress
- drive = new upm::SmartDrive(0);
-
- std::cout << "Battery Voltage before motor run : " << drive->GetBattVoltage() << std::endl;
- //Set motor M1 to run for 120 seconds, with speed of 15RPM, waith for it to finish and then Brake It
- drive->Run_Seconds(SmartDrive_Motor_ID_1, SmartDrive_Dir_Forward, 15, 120, true, SmartDrive_Action_Brake);
- std::cout << "Battery Voltage after motor run : " << drive->GetBattVoltage() << std::endl;
- //Rotate motor M2 2270 degrees, in reverse sense, with speed of 10RPM, return immediately from function call
- drive->Run_Degrees(SmartDrive_Motor_ID_2, SmartDrive_Dir_Reverse, 10, 2270, false, SmartDrive_Action_Float);
- //While motor is running, Display its status
- drive->PrintMotorStatus(SmartDrive_Motor_ID_2);
- sleep(2); //Sleep for 2 seconds
- //Stop motor M2 and then finish program
- drive->StopMotor(SmartDrive_Motor_ID_2, SmartDrive_Action_BrakeHold);
- //! [Interesting]
-
- std::cout << "Demo complete. GoodBye" << std::endl;
-
- delete drive;
- drive = NULL;
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/ssd1306-oled.cxx b/peripheral/libupm/examples/c++/ssd1306-oled.cxx
index c0eef15..07421e3 100644
--- a/peripheral/libupm/examples/c++/ssd1306-oled.cxx
+++ b/peripheral/libupm/examples/c++/ssd1306-oled.cxx
@@ -26,10 +26,10 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "ssd1306.hpp"
+#include "ssd1306.h"
#define DEVICE_ADDRESS 0x3C
-#define BUS_NUMBER 0x0
+#define BUS_NUMBER 0x6
static uint8_t intel_logo[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
diff --git a/peripheral/libupm/examples/c++/ssd1308-oled.cxx b/peripheral/libupm/examples/c++/ssd1308-oled.cxx
index c78e8b8..f54169e 100644
--- a/peripheral/libupm/examples/c++/ssd1308-oled.cxx
+++ b/peripheral/libupm/examples/c++/ssd1308-oled.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "ssd1308.hpp"
+#include "ssd1308.h"
#define DEVICE_ADDRESS 0x3C
#define BUS_NUMBER 0x0
diff --git a/peripheral/libupm/examples/c++/ssd1327-oled.cxx b/peripheral/libupm/examples/c++/ssd1327-oled.cxx
index d087f70..73323ec 100644
--- a/peripheral/libupm/examples/c++/ssd1327-oled.cxx
+++ b/peripheral/libupm/examples/c++/ssd1327-oled.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "ssd1327.hpp"
+#include "ssd1327.h"
#define DEVICE_ADDRESS 0x3C
#define BUS_NUMBER 0x0
diff --git a/peripheral/libupm/examples/c++/ssd1351.cxx b/peripheral/libupm/examples/c++/ssd1351.cxx
index dec565d..c0de509 100644
--- a/peripheral/libupm/examples/c++/ssd1351.cxx
+++ b/peripheral/libupm/examples/c++/ssd1351.cxx
@@ -2,7 +2,7 @@
#include <iostream>
#include <unistd.h>
-#include "ssd1351.hpp"
+#include "ssd1351.h"
#define BLACK 0x0000
#define WHITE 0xFFFF
diff --git a/peripheral/libupm/examples/c++/st7735.cxx b/peripheral/libupm/examples/c++/st7735.cxx
index 5dedd8b..2c14d49 100644
--- a/peripheral/libupm/examples/c++/st7735.cxx
+++ b/peripheral/libupm/examples/c++/st7735.cxx
@@ -25,7 +25,7 @@
#include <string.h>
#include <unistd.h>
#include <iostream>
-#include "st7735.hpp"
+#include "st7735.h"
#include <signal.h>
int
diff --git a/peripheral/libupm/examples/c++/stepmotor.cxx b/peripheral/libupm/examples/c++/stepmotor.cxx
index 8f4194c..9357d5d 100644
--- a/peripheral/libupm/examples/c++/stepmotor.cxx
+++ b/peripheral/libupm/examples/c++/stepmotor.cxx
@@ -26,7 +26,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "stepmotor.hpp"
+#include "stepmotor.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/sx1276-fsk.cxx b/peripheral/libupm/examples/c++/sx1276-fsk.cxx
index c6bf3ad..f63d1bf 100644
--- a/peripheral/libupm/examples/c++/sx1276-fsk.cxx
+++ b/peripheral/libupm/examples/c++/sx1276-fsk.cxx
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <iostream>
#include <signal.h>
-#include "sx1276.hpp"
+#include "sx1276.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/sx1276-lora.cxx b/peripheral/libupm/examples/c++/sx1276-lora.cxx
index 6ac3706..7c45597 100644
--- a/peripheral/libupm/examples/c++/sx1276-lora.cxx
+++ b/peripheral/libupm/examples/c++/sx1276-lora.cxx
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <iostream>
#include <signal.h>
-#include "sx1276.hpp"
+#include "sx1276.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/sx6119.cxx b/peripheral/libupm/examples/c++/sx6119.cxx
index 0d1178f..2608387 100644
--- a/peripheral/libupm/examples/c++/sx6119.cxx
+++ b/peripheral/libupm/examples/c++/sx6119.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "sx6119.hpp"
+#include "sx6119.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/t3311.cxx b/peripheral/libupm/examples/c++/t3311.cxx
index 4401a1b..1859dc6 100644
--- a/peripheral/libupm/examples/c++/t3311.cxx
+++ b/peripheral/libupm/examples/c++/t3311.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
-#include "t3311.hpp"
+#include "t3311.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/t6713.cxx b/peripheral/libupm/examples/c++/t6713.cxx
deleted file mode 100644
index c07871a..0000000
--- a/peripheral/libupm/examples/c++/t6713.cxx
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include "t6713.hpp"
-
-#define FT4222_I2C_BUS 0
-
-int main ()
-{
-
- try {
- upm::T6713* cO2Sensor = new upm::T6713(mraa_get_sub_platform_id(FT4222_I2C_BUS));
- while (true) {
- uint16_t value = cO2Sensor->getPpm();
- std::cout << "CO2 level = " << value << " ppm" << std::endl;
- sleep(1);
- }
- delete cO2Sensor;
- } catch (std::exception& e) {
- std::cerr << e.what() << std::endl;
- return 1;
- }
- return 0;
-}
-
diff --git a/peripheral/libupm/examples/c++/t8100.cxx b/peripheral/libupm/examples/c++/t8100.cxx
deleted file mode 100644
index 3cecbac..0000000
--- a/peripheral/libupm/examples/c++/t8100.cxx
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-
-#include "t8100.hpp"
-
-using namespace std;
-using namespace upm;
-
-bool shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-
-//! [Interesting]
- // You will need to edit this example to conform to your site and your
- // devices, specifically the Device Object Instance ID passed to the
- // constructor, and the arguments to initMaster() that are
- // appropriate for your BACnet network.
-
- string defaultDev = "/dev/ttyUSB0";
-
- // if an argument was specified, use it as the device instead
- if (argc > 1)
- defaultDev = string(argv[1]);
-
- cout << "Using device " << defaultDev << endl;
- cout << "Initializing..." << endl;
-
- // Instantiate an T8100 object for an T8100 device that has 568000
- // as it's unique Device Object Instance ID. NOTE: You will
- // certainly want to change this to the correct value for your
- // device(s).
- T8100 *sensor = new T8100(568000);
-
- // Initialize our BACnet master, if it has not already been
- // initialized, with the device and baudrate, choosing 1000001 as
- // our unique Device Object Instance ID, 2 as our MAC address and
- // using default values for maxMaster and maxInfoFrames
- sensor->initMaster(defaultDev, 38400, 1000001, 2);
-
- // Uncomment to enable debugging output
- // sensor->setDebug(true);
-
- cout << endl;
- cout << "Device Description: " << sensor->getDeviceDescription() << endl;
- cout << "Device Location: " << sensor->getDeviceLocation() << endl;
- cout << endl;
-
- // update and print a few values every 5 seconds
- while (shouldRun)
- {
- // update our values
- sensor->update();
-
- cout << "CO2 Concentration: "
- << sensor->getCO2()
- << " ppm"
- << endl;
-
- // we show both C and F for temperature
- cout << "Temperature: " << sensor->getTemperature()
- << " C / "
- << sensor->getTemperature(true)
- << " F"
- << endl;
-
- cout << "Humidity: " << sensor->getHumidity()
- << " %RH"
- << endl;
-
- cout << "Relay State: " << sensor->getRelayState()
- << endl;
-
- cout << endl;
- sleep(5);
- }
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
-//! [Interesting]
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/ta12200.cxx b/peripheral/libupm/examples/c++/ta12200.cxx
index 8fdffd8..5f949a1 100644
--- a/peripheral/libupm/examples/c++/ta12200.cxx
+++ b/peripheral/libupm/examples/c++/ta12200.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "ta12200.hpp"
+#include "ta12200.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/tb7300.cxx b/peripheral/libupm/examples/c++/tb7300.cxx
deleted file mode 100644
index 0aab8ac..0000000
--- a/peripheral/libupm/examples/c++/tb7300.cxx
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-
-#include "tb7300.hpp"
-
-using namespace std;
-using namespace upm;
-
-bool shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-
-//! [Interesting]
- // You will need to edit this example to conform to your site and your
- // devices, specifically the Device Object Instance ID passed to the
- // constructor, and the arguments to initMaster() that are
- // appropriate for your BACnet network.
-
- string defaultDev = "/dev/ttyUSB0";
-
- // if an argument was specified, use it as the device instead
- if (argc > 1)
- defaultDev = string(argv[1]);
-
- cout << "Using device " << defaultDev << endl;
- cout << "Initializing..." << endl;
-
- // Instantiate an TB7300 object for an TB7300 device that has 73001
- // as it's unique Device Object Instance ID. NOTE: You will
- // certainly want to change this to the correct value for your
- // device(s).
- TB7300 *sensor = new TB7300(73001);
-
- // Initialize our BACnet master, if it has not already been
- // initialized, with the device and baudrate, choosing 1000001 as
- // our unique Device Object Instance ID, 2 as our MAC address and
- // using default values for maxMaster and maxInfoFrames
- sensor->initMaster(defaultDev, 38400, 1000001, 2);
-
- // Uncomment to enable debugging output
- // sensor->setDebug(true);
-
- cout << endl;
- cout << "Device Name: " << sensor->getDeviceName() << endl;
- cout << "Device Description: " << sensor->getDeviceDescription() << endl;
- cout << "Device Location: " << sensor->getDeviceLocation() << endl;
- cout << endl;
-
- cout << "Fan Mode: "
- << sensor->getMultiStateValueText(TB7300::MV_Fan_Mode)
- << endl;
-
- cout << "Fan Status: "
- << sensor->getMultiStateValueText(TB7300::MV_Fan_Status)
- << endl;
-
- cout << "System Mode: "
- << sensor->getMultiStateValueText(TB7300::MV_System_Mode)
- << endl;
-
- cout << "Service Alarm: "
- << sensor->getBinaryInputText(TB7300::BI_Service_Alarm)
- << endl;
-
- cout << endl;
-
- // update and print the room temperature every 5 seconds
- while (shouldRun)
- {
- // update our values
- sensor->update();
-
- // we show both C and F for temperature
- cout << "Temperature: " << sensor->getTemperature()
- << " C / "
- << sensor->getTemperature(true)
- << " F"
- << endl;
-
- cout << endl;
- sleep(5);
- }
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
-//! [Interesting]
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/tcs3414cs.cxx b/peripheral/libupm/examples/c++/tcs3414cs.cxx
index 7efcebd..5e6376e 100644
--- a/peripheral/libupm/examples/c++/tcs3414cs.cxx
+++ b/peripheral/libupm/examples/c++/tcs3414cs.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "tcs3414cs.hpp"
+#include "tcs3414cs.h"
#include <signal.h>
int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/teams.cxx b/peripheral/libupm/examples/c++/teams.cxx
deleted file mode 100644
index 40570ad..0000000
--- a/peripheral/libupm/examples/c++/teams.cxx
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-
-#include "teams.hpp"
-
-using namespace std;
-
-bool shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-
-//! [Interesting]
-
- cout << "Initializing..." << endl;
-
- // Instantiate an TEAMS instance, using A0 for temperature, and
- // 165.0 ohms for the rResistor value (for the libelium 4-20ma
- // interface)
- upm::TEAMS *sensor = new upm::TEAMS(0, 165.0);
-
- // update and print available values every second
- while (shouldRun)
- {
- // update our values from the sensor
- sensor->update();
-
- // is the sensor connected? (current >= 4ma)
- cout << "Is Connected: " << sensor->isConnected() << endl;
-
- // print computed current on the loop. This includes the offset,
- // if one was set by setOffsetMilliamps().
- cout << "Milliamps: " << sensor->getRawMilliamps() << endl;
-
- // we show both C and F for temperature
- cout << "Temperature: " << sensor->getTemperature()
- << " C / " << sensor->getTemperature(true) << " F"
- << endl;
-
- cout << endl;
-
- sleep(1);
- }
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
-//! [Interesting]
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/temperature-sensor.cxx b/peripheral/libupm/examples/c++/temperature-sensor.cxx
deleted file mode 100644
index d613461..0000000
--- a/peripheral/libupm/examples/c++/temperature-sensor.cxx
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include "si7005.hpp"
-#include "bmpx8x.hpp"
-#include "bme280.hpp"
-
-#define EDISON_I2C_BUS 1
-#define FT4222_I2C_BUS 0
-
- #define EDISON_GPIO_SI7005_CS 20
-
-//! [Interesting]
-// Simple example of using ITemperatureSensor to determine
-// which sensor is present and return its name.
-// ITemperatureSensor is then used to get readings from sensor
-
-
-upm::ITemperatureSensor* getTemperatureSensor()
-{
- upm::ITemperatureSensor* temperatureSensor = NULL;
-
- try {
- temperatureSensor = new upm::BME280 (mraa_get_sub_platform_id(FT4222_I2C_BUS));
- return temperatureSensor;
- } catch (std::exception& e)
- {
- std::cerr <<"BME280: "<<e.what() << std::endl;
- }
-
- try {
- temperatureSensor = new upm::SI7005(EDISON_I2C_BUS, EDISON_GPIO_SI7005_CS);
- return temperatureSensor;
- } catch (std::exception& e) {
- std::cerr << "SI7005: " << e.what() << std::endl;
- }
- try {
- temperatureSensor = new upm::BMPX8X(EDISON_I2C_BUS);
- return temperatureSensor;
- } catch (std::exception& e) {
- std::cerr << "BMPX8X: " << e.what() << std::endl;
- }
- return temperatureSensor;
-}
-
-int main ()
-{
- upm::ITemperatureSensor* temperatureSensor = getTemperatureSensor();
- if (temperatureSensor == NULL) {
- std::cout << "Temperature sensor not detected" << std::endl;
- return 1;
- }
- std::cout << "Temperature sensor " << temperatureSensor->getModuleName() << " detected" << std::endl;
- while (true) {
- try {
- int value = temperatureSensor->getTemperatureCelcius();
- std::cout << "Temperature = " << value << "C" << std::endl;
- } catch (std::exception& e) {
- std::cerr << e.what() << std::endl;
- }
- sleep(1);
- }
- delete temperatureSensor;
- return 0;
-}
-
-//! [Interesting]
diff --git a/peripheral/libupm/examples/c++/tex00.cxx b/peripheral/libupm/examples/c++/tex00.cxx
deleted file mode 100644
index 8fdb9cb..0000000
--- a/peripheral/libupm/examples/c++/tex00.cxx
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <signal.h>
-
-#include "tex00.hpp"
-
-using namespace std;
-
-bool shouldRun = true;
-
-void sig_handler(int signo)
-{
- if (signo == SIGINT)
- shouldRun = false;
-}
-
-int main(int argc, char **argv)
-{
- signal(SIGINT, sig_handler);
-
-//! [Interesting]
-
- cout << "Initializing..." << endl;
-
- // Instantiate an TEX00 instance, using A0 for the analog input. In
- // this example, we are using a 10K Ohm balance resistor and a TED
- // (10k type 2) thermistor.
- upm::TEX00 *sensor = new upm::TEX00(0, 10000,
- upm::TEX00::STYPE_THERMISTOR_TED);
-
- cout << "Minimum temperature: " << sensor->getTemperatureRangeMin()
- << " C" << endl;
- cout << "Maximum temperature: " << sensor->getTemperatureRangeMax()
- << " C" << endl;
- cout << endl;
-
- // update and print available values every second
- while (shouldRun)
- {
- // update our values from the sensor
- sensor->update();
-
- if (sensor->isOutOfRange())
- {
- cout << "Temperature out of range" << endl;
- }
- else
- {
- // we show both C and F for temperature
- cout << "Temperature: " << sensor->getTemperature()
- << " C / " << sensor->getTemperature(true) << " F"
- << endl;
- }
-
- cout << endl;
-
- sleep(1);
- }
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
-//! [Interesting]
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/th02.cxx b/peripheral/libupm/examples/c++/th02.cxx
index 3079d8d..cce0367 100644
--- a/peripheral/libupm/examples/c++/th02.cxx
+++ b/peripheral/libupm/examples/c++/th02.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "th02.hpp"
+#include "th02.h"
#include <signal.h>
int doWork = 0;
diff --git a/peripheral/libupm/examples/c++/tm1637.cxx b/peripheral/libupm/examples/c++/tm1637.cxx
index 14ec3a2..235ae50 100644
--- a/peripheral/libupm/examples/c++/tm1637.cxx
+++ b/peripheral/libupm/examples/c++/tm1637.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "tm1637.hpp"
+#include "tm1637.h"
#include <signal.h>
#include <unistd.h>
#include <sstream>
diff --git a/peripheral/libupm/examples/c++/tp401.cxx b/peripheral/libupm/examples/c++/tp401.cxx
index 4749ea5..255d3f0 100644
--- a/peripheral/libupm/examples/c++/tp401.cxx
+++ b/peripheral/libupm/examples/c++/tp401.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
-#include "tp401.hpp"
+#include "tp401.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/tsl2561.cxx b/peripheral/libupm/examples/c++/tsl2561.cxx
index 87f8339..14ddb8a 100644
--- a/peripheral/libupm/examples/c++/tsl2561.cxx
+++ b/peripheral/libupm/examples/c++/tsl2561.cxx
@@ -26,7 +26,7 @@
#include <unistd.h>
-#include "tsl2561.hpp"
+#include "tsl2561.h"
int main (int argc, char **argv)
{
diff --git a/peripheral/libupm/examples/c++/ttp223.cxx b/peripheral/libupm/examples/c++/ttp223.cxx
index 88cbcf0..1d15585 100644
--- a/peripheral/libupm/examples/c++/ttp223.cxx
+++ b/peripheral/libupm/examples/c++/ttp223.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "ttp223.hpp"
+#include "ttp223.h"
int
main(int argc, char **argv)
diff --git a/peripheral/libupm/examples/c++/ublox6.cxx b/peripheral/libupm/examples/c++/ublox6.cxx
index 2d3d34b..a0cd5f2 100644
--- a/peripheral/libupm/examples/c++/ublox6.cxx
+++ b/peripheral/libupm/examples/c++/ublox6.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "ublox6.hpp"
+#include "ublox6.h"
using namespace std;
@@ -77,7 +77,7 @@ int main (int argc, char **argv)
if (rv > 0)
write(1, nmeaBuffer, rv);
- if (rv < 0) // some sort of read error occurred
+ if (rv < 0) // some sort of read error occured
{
cerr << "Port read error." << endl;
break;
diff --git a/peripheral/libupm/examples/c++/uln200xa.cxx b/peripheral/libupm/examples/c++/uln200xa.cxx
index 6a95328..53a6958 100644
--- a/peripheral/libupm/examples/c++/uln200xa.cxx
+++ b/peripheral/libupm/examples/c++/uln200xa.cxx
@@ -24,7 +24,7 @@
#include <unistd.h>
#include <iostream>
-#include "uln200xa.hpp"
+#include "uln200xa.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/urm37-uart.cxx b/peripheral/libupm/examples/c++/urm37-uart.cxx
index 0a0ff9c..7a94a1f 100644
--- a/peripheral/libupm/examples/c++/urm37-uart.cxx
+++ b/peripheral/libupm/examples/c++/urm37-uart.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "urm37.hpp"
+#include "urm37.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/urm37.cxx b/peripheral/libupm/examples/c++/urm37.cxx
index a7a7e24..820b2a1 100644
--- a/peripheral/libupm/examples/c++/urm37.cxx
+++ b/peripheral/libupm/examples/c++/urm37.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "urm37.hpp"
+#include "urm37.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/vcap.cxx b/peripheral/libupm/examples/c++/vcap.cxx
deleted file mode 100644
index fe0d8a7..0000000
--- a/peripheral/libupm/examples/c++/vcap.cxx
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-
-#include "vcap.hpp"
-
-using namespace std;
-
-int main(int argc, char **argv)
-{
-//! [Interesting]
-
- string defaultDev = "/dev/video0";
-
- // if an argument was specified, use it as the device instead
- if (argc > 1)
- defaultDev = string(argv[1]);
-
- cout << "Using device " << defaultDev << endl;
- cout << "Initializing..." << endl;
-
- // Instantiate an VCAP instance, using the specified video device
- upm::VCAP *sensor = new upm::VCAP(defaultDev);
-
- // enable some debug/verbose output
- sensor->setDebug(true);
-
- // This is just a hint. The kernel can change this to a lower
- // resolution that the hardware supports. Use getWidth() and
- // getHeight() methods to see what the kernel actually chose if you
- // care.
- sensor->setResolution(1920, 1080);
-
- // capture an image
- sensor->captureImage();
-
- // convert and save it as a jpeg
- sensor->saveImage("video-img1.jpg");
-
- cout << "Exiting..." << endl;
-
- delete sensor;
-
-//! [Interesting]
-
- return 0;
-}
diff --git a/peripheral/libupm/examples/c++/waterlevel.cxx b/peripheral/libupm/examples/c++/waterlevel.cxx
index 301e489..d3a069f 100644
--- a/peripheral/libupm/examples/c++/waterlevel.cxx
+++ b/peripheral/libupm/examples/c++/waterlevel.cxx
@@ -24,7 +24,7 @@
#include <iostream>
#include <unistd.h>
#include <signal.h>
-#include "waterlevel.hpp"
+#include "waterlevel.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/wheelencoder.cxx b/peripheral/libupm/examples/c++/wheelencoder.cxx
index 1741b97..08a7825 100644
--- a/peripheral/libupm/examples/c++/wheelencoder.cxx
+++ b/peripheral/libupm/examples/c++/wheelencoder.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "wheelencoder.hpp"
+#include "wheelencoder.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/wt5001.cxx b/peripheral/libupm/examples/c++/wt5001.cxx
index 92a6581..317e877 100644
--- a/peripheral/libupm/examples/c++/wt5001.cxx
+++ b/peripheral/libupm/examples/c++/wt5001.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "wt5001.hpp"
+#include "wt5001.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/xbee.cxx b/peripheral/libupm/examples/c++/xbee.cxx
index d56052e..834d8bc 100644
--- a/peripheral/libupm/examples/c++/xbee.cxx
+++ b/peripheral/libupm/examples/c++/xbee.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <signal.h>
#include <stdio.h>
-#include "xbee.hpp"
+#include "xbee.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/yg1006.cxx b/peripheral/libupm/examples/c++/yg1006.cxx
index 6b94421..07dbfb5 100644
--- a/peripheral/libupm/examples/c++/yg1006.cxx
+++ b/peripheral/libupm/examples/c++/yg1006.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "yg1006.hpp"
+#include "yg1006.h"
using namespace std;
diff --git a/peripheral/libupm/examples/c++/zfm20-register.cxx b/peripheral/libupm/examples/c++/zfm20-register.cxx
index c1f68d7..fb1292c 100644
--- a/peripheral/libupm/examples/c++/zfm20-register.cxx
+++ b/peripheral/libupm/examples/c++/zfm20-register.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "zfm20.hpp"
+#include "zfm20.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/c++/zfm20.cxx b/peripheral/libupm/examples/c++/zfm20.cxx
index 1ce6aaf..a7323b0 100644
--- a/peripheral/libupm/examples/c++/zfm20.cxx
+++ b/peripheral/libupm/examples/c++/zfm20.cxx
@@ -25,7 +25,7 @@
#include <unistd.h>
#include <iostream>
#include <signal.h>
-#include "zfm20.hpp"
+#include "zfm20.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/examples/java/AM2315Example.java b/peripheral/libupm/examples/java/AM2315Example.java
deleted file mode 100644
index 3da2ff5..0000000
--- a/peripheral/libupm/examples/java/AM2315Example.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Author: Abhishek Malik <abhishek.malik@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-import upm_am2315.AM2315;
-
-public class AM2315Example {
-
- static {
- try {
- System.loadLibrary("javaupm_am2315");
- System.loadLibrary("mraajava");
- } catch (UnsatisfiedLinkError e) {
- System.err.println(
- "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
- e);
- System.exit(1);
- }
- }
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- //! [Interesting]
- float humidity = 0;
- float temperature = 0;
-
- // Instantiate the sensor
- AM2315 sensor = new AM2315(0, upm_am2315.javaupm_am2315Constants.AM2315_I2C_ADDRESS);
- sensor.testSensor();
-
- while(true){
- // retrieving the humidity and temperature values
- humidity = sensor.getHumidity();
- temperature = sensor.getTemperature();
-
- System.out.println("Temperature : "+temperature+" Humidity: "+humidity);
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- System.out.println("The following exception occurred: "+e.getMessage());
- }
- }
- //! [Interesting]
- }
-
-}
diff --git a/peripheral/libupm/examples/java/APA102Sample.java b/peripheral/libupm/examples/java/APA102Sample.java
deleted file mode 100644
index 4ebbdbf..0000000
--- a/peripheral/libupm/examples/java/APA102Sample.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Author: Yannick Adam <yannick.adam@gmail.com>
- * Copyright (c) 2016 Yannick Adam
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-public class APA102Sample {
-
- public static void main(String[] args) throws InterruptedException {
- // ! [Interesting]
- // Instantiate a strip of 30 LEDs on SPI bus 0
- upm_apa102.APA102 ledStrip =
- new upm_apa102.APA102(30, (short)0, false, (byte)-1);
-
- System.out.println("Set all LEDs to blue");
- ledStrip.setAllLeds((short)31, (short)0, (short)0, (short)255);
-
- System.out.println("Set LEDs between 10 and 20 to green");
- ledStrip.setLeds(10, 20, (short)31, (short)0, (short)255, (short)0);
-
- System.out.println("Set a single LED to red at index 15");
- ledStrip.setLed(15, (short)31, (short)255, (short)0, (short)0);
-
- // ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/Ad8232Example.java b/peripheral/libupm/examples/java/Ad8232Example.java
index 0ee0f2c..3b6102b 100644
--- a/peripheral/libupm/examples/java/Ad8232Example.java
+++ b/peripheral/libupm/examples/java/Ad8232Example.java
@@ -25,6 +25,18 @@ import upm_ad8232.AD8232;
public class Ad8232Example {
+ static {
+ try {
+ System.loadLibrary("javaupm_ad8232");
+ System.loadLibrary("mraajava");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println(
+ "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
+ e);
+ System.exit(1);
+ }
+ }
+
public static void main(String[] args) {
// TODO Auto-generated method stub
//! [Interesting]
@@ -42,7 +54,7 @@ public class Ad8232Example {
Thread.sleep(1);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following error has occurred: "+e.getMessage());
+ System.out.println("The following error has occured: "+e.getMessage());
}
}
}
diff --git a/peripheral/libupm/examples/java/Apds9002.java b/peripheral/libupm/examples/java/Apds9002.java
index 0c6b7cb..4bb5de8 100644
--- a/peripheral/libupm/examples/java/Apds9002.java
+++ b/peripheral/libupm/examples/java/Apds9002.java
@@ -38,7 +38,7 @@ public class Apds9002 {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception occurred: "+e.getMessage());
+ System.out.println("The following exception occured: "+e.getMessage());
}
}
//! [Interesting]
diff --git a/peripheral/libupm/examples/java/BMA250E_Example.java b/peripheral/libupm/examples/java/BMA250E_Example.java
deleted file mode 100644
index dd138ad..0000000
--- a/peripheral/libupm/examples/java/BMA250E_Example.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_bmx055.BMA250E;
-
-public class BMA250E_Example
-{
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
-
- // Instantiate a BMA250E instance using default i2c bus and address
- BMA250E sensor = new BMA250E();
-
- // For SPI, bus 0, you would pass -1 as the address, and a
- // valid pin for CS:
- // BMA250E(0, -1, 10);
-
- while (true)
- {
- // update our values from the sensor
- sensor.update();
-
- float dataA[] = sensor.getAccelerometer();
-
- System.out.println("Accelerometer x: " + dataA[0]
- + " y: " + dataA[1]
- + " z: " + dataA[2]
- + " g");
-
- System.out.println("Compensation Temperature: "
- + sensor.getTemperature()
- + " C / "
- + sensor.getTemperature(true)
- + " F");
-
- System.out.println();
- Thread.sleep(250);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/BMC150_Example.java b/peripheral/libupm/examples/java/BMC150_Example.java
deleted file mode 100644
index bcd37af..0000000
--- a/peripheral/libupm/examples/java/BMC150_Example.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_bmx055.BMC150;
-
-public class BMC150_Example
-{
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
-
- // Instantiate a BMC150 instance using default i2c bus and address
- BMC150 sensor = new BMC150();
-
- while (true)
- {
- // update our values from the sensor
- sensor.update();
-
- float data[] = sensor.getAccelerometer();
-
- System.out.println("Accelerometer x: " + data[0]
- + " y: " + data[1]
- + " z: " + data[2]
- + " g");
-
- data = sensor.getMagnetometer();
-
- System.out.println("Magnetometer x: " + data[0]
- + " y: " + data[1]
- + " z: " + data[2]
- + " uT");
-
- System.out.println();
- Thread.sleep(250);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/BME280_Example.java b/peripheral/libupm/examples/java/BME280_Example.java
deleted file mode 100644
index 0a627e5..0000000
--- a/peripheral/libupm/examples/java/BME280_Example.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_bmp280.BME280;
-
-public class BME280_Example
-{
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
-
- // Instantiate a BME280 instance using default i2c bus and address
- BME280 sensor = new BME280();
-
- // For SPI, bus 0, you would pass -1 as the address, and a
- // valid pin for CS:
- // BME280(0, -1, 10);
-
- while (true)
- {
- // update our values from the sensor
- sensor.update();
-
- System.out.println("Compensation Temperature: "
- + sensor.getTemperature()
- + " C / "
- + sensor.getTemperature(true)
- + " F");
-
- System.out.println("Pressure: "
- + sensor.getPressure()
- + " Pa");
-
- System.out.println("Computed Altitude: "
- + sensor.getAltitude()
- + " m");
-
- System.out.println("Humidity: "
- + sensor.getHumidity()
- + " %RH");
-
- System.out.println();
- Thread.sleep(1000);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/BMG160_Example.java b/peripheral/libupm/examples/java/BMG160_Example.java
deleted file mode 100644
index 09667b9..0000000
--- a/peripheral/libupm/examples/java/BMG160_Example.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_bmx055.BMG160;
-
-public class BMG160_Example
-{
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
-
- // Instantiate a BMG160 instance using default i2c bus and address
- BMG160 sensor = new BMG160();
-
- // For SPI, bus 0, you would pass -1 as the address, and a
- // valid pin for CS:
- // BMG160(0, -1, 10);
-
- while (true)
- {
- // update our values from the sensor
- sensor.update();
-
- float dataA[] = sensor.getGyroscope();
-
- System.out.println("Gyroscope x: " + dataA[0]
- + " y: " + dataA[1]
- + " z: " + dataA[2]
- + " degrees/s");
-
- System.out.println("Compensation Temperature: "
- + sensor.getTemperature()
- + " C / "
- + sensor.getTemperature(true)
- + " F");
-
- System.out.println();
- Thread.sleep(250);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/BMI055_Example.java b/peripheral/libupm/examples/java/BMI055_Example.java
deleted file mode 100644
index fc11696..0000000
--- a/peripheral/libupm/examples/java/BMI055_Example.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_bmx055.BMI055;
-
-public class BMI055_Example
-{
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
-
- // Instantiate a BMI055 instance using default i2c bus and address
- BMI055 sensor = new BMI055();
-
- while (true)
- {
- // update our values from the sensor
- sensor.update();
-
- float data[] = sensor.getAccelerometer();
-
- System.out.println("Accelerometer x: " + data[0]
- + " y: " + data[1]
- + " z: " + data[2]
- + " g");
-
- data = sensor.getGyroscope();
-
- System.out.println("Gyroscope x: " + data[0]
- + " y: " + data[1]
- + " z: " + data[2]
- + " degrees/s");
-
- System.out.println();
- Thread.sleep(250);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/BMI160_Example.java b/peripheral/libupm/examples/java/BMI160_Example.java
deleted file mode 100644
index 6d83e2e..0000000
--- a/peripheral/libupm/examples/java/BMI160_Example.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_bmi160.BMI160;
-
-public class BMI160_Example
-{
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
- System.out.println("Initializing...");
-
- // Instantiate a BMI160 instance using default i2c bus and address
- BMI160 sensor = new BMI160();
-
- while (true)
- {
- // update our values from the sensor
- sensor.update();
-
- float dataA[] = sensor.getAccelerometer();
-
- System.out.println("Accelerometer: "
- + "AX: "
- + dataA[0]
- + " AY: "
- + dataA[1]
- + " AZ: "
- + dataA[2]);
-
- float dataG[] = sensor.getGyroscope();
-
- System.out.println("Gryoscope: "
- + "GX: "
- + dataG[0]
- + " GY: "
- + dataG[1]
- + " GZ: "
- + dataG[2]);
-
- float dataM[] = sensor.getMagnetometer();
-
- System.out.println("Magnetometer: "
- + "MX: "
- + dataM[0]
- + " MY: "
- + dataM[1]
- + " MZ: "
- + dataM[2]);
-
- System.out.println();
- Thread.sleep(500);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/BMM150_Example.java b/peripheral/libupm/examples/java/BMM150_Example.java
deleted file mode 100644
index fc34ac7..0000000
--- a/peripheral/libupm/examples/java/BMM150_Example.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_bmx055.BMM150;
-
-public class BMM150_Example
-{
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
-
- // Instantiate a BMM150 instance using default i2c bus and address
- BMM150 sensor = new BMM150();
-
- // For SPI, bus 0, you would pass -1 as the address, and a
- // valid pin for CS:
- // BMM150(0, -1, 10);
-
- while (true)
- {
- // update our values from the sensor
- sensor.update();
-
- float dataA[] = sensor.getMagnetometer();
-
- System.out.println("Magnetometer x: " + dataA[0]
- + " y: " + dataA[1]
- + " z: " + dataA[2]
- + " uT");
-
- System.out.println();
- Thread.sleep(250);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/BMP280_Example.java b/peripheral/libupm/examples/java/BMP280_Example.java
deleted file mode 100644
index 6bd600b..0000000
--- a/peripheral/libupm/examples/java/BMP280_Example.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_bmp280.BMP280;
-
-public class BMP280_Example
-{
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
-
- // Instantiate a BMP280 instance using default i2c bus and address
- BMP280 sensor = new BMP280();
-
- // For SPI, bus 0, you would pass -1 as the address, and a
- // valid pin for CS:
- // BMP280(0, -1, 10);
-
- while (true)
- {
- // update our values from the sensor
- sensor.update();
-
- System.out.println("Compensation Temperature: "
- + sensor.getTemperature()
- + " C / "
- + sensor.getTemperature(true)
- + " F");
-
- System.out.println("Pressure: "
- + sensor.getPressure()
- + " Pa");
-
- System.out.println("Computed Altitude: "
- + sensor.getAltitude()
- + " m");
-
- System.out.println();
- Thread.sleep(1000);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/BMX055_Example.java b/peripheral/libupm/examples/java/BMX055_Example.java
deleted file mode 100644
index 2abb0da..0000000
--- a/peripheral/libupm/examples/java/BMX055_Example.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_bmx055.BMX055;
-
-public class BMX055_Example
-{
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
-
- // Instantiate a BMX055 instance using default i2c bus and address
- BMX055 sensor = new BMX055();
-
- while (true)
- {
- // update our values from the sensor
- sensor.update();
-
- float data[] = sensor.getAccelerometer();
-
- System.out.println("Accelerometer x: " + data[0]
- + " y: " + data[1]
- + " z: " + data[2]
- + " g");
-
- data = sensor.getGyroscope();
-
- System.out.println("Gyroscope x: " + data[0]
- + " y: " + data[1]
- + " z: " + data[2]
- + " degrees/s");
-
-
- data = sensor.getMagnetometer();
-
- System.out.println("Magnetometer x: " + data[0]
- + " y: " + data[1]
- + " z: " + data[2]
- + " uT");
-
- System.out.println();
- Thread.sleep(250);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/BNO055_Example.java b/peripheral/libupm/examples/java/BNO055_Example.java
deleted file mode 100644
index 808dbd3..0000000
--- a/peripheral/libupm/examples/java/BNO055_Example.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_bno055.BNO055;
-
-public class BNO055_Example
-{
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
- System.out.println("Initializing...");
-
- // Instantiate an BNO055 using default parameters (bus 0, addr
- // 0x28). The default running mode is NDOF absolute orientation
- // mode.
- BNO055 sensor = new BNO055();
-
- System.out.println("First we need to calibrate. 4 numbers will be output every");
- System.out.println("second for each sensor. 0 means uncalibrated, and 3 means");
- System.out.println("fully calibrated.");
- System.out.println("See the UPM documentation on this sensor for instructions on");
- System.out.println("what actions are required to calibrate.");
- System.out.println("");
-
- while (!sensor.isFullyCalibrated())
- {
- int calData[] = sensor.getCalibrationStatus();
-
- System.out.println("Magnetometer: " + calData[0]
- + " Accelerometer: " + calData[1]
- + " Gyroscope: " + calData[2]
- + " System: " + calData[3]);
-
- Thread.sleep(1000);
-
- }
-
- System.out.println("");
- System.out.println("Calibration complete.");
- System.out.println("");
-
- while (true)
- {
- // update our values from the sensor
- sensor.update();
-
- float dataE[] = sensor.getEulerAngles();
- System.out.println("Euler: Heading: " + dataE[0] +
- " Roll: " + dataE[1] +
- " Pitch: " + dataE[2] +
- " degrees");
-
- float dataQ[] = sensor.getQuaternions();
- System.out.println("Quaternion: W: " + dataQ[0] +
- " X:" + dataQ[1] +
- " Y: " + dataQ[2] +
- " Z: " + dataQ[3]);
-
- float dataL[] = sensor.getLinearAcceleration();
- System.out.println("Linear Acceleration: X: " + dataL[0] +
- " Y: " + dataL[1] +
- " Z: " + dataL[2] +
- " m/s^2");
-
- float dataG[] = sensor.getGravityVectors();
- System.out.println("Gravity Vector: X: " + dataG[0] +
- " Y: " + dataG[1] +
- " Z: " + dataG[2] +
- " m/s^2");
-
-
- System.out.println();
- Thread.sleep(250);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/CMakeLists.txt b/peripheral/libupm/examples/java/CMakeLists.txt
index 130cc4f..95d187a 100644
--- a/peripheral/libupm/examples/java/CMakeLists.txt
+++ b/peripheral/libupm/examples/java/CMakeLists.txt
@@ -6,15 +6,13 @@ macro(add_example example_name jar_name)
set(example_jar "${CMAKE_CURRENT_BINARY_DIR}/../../src/${jar_name}/upm_${jar_name}.jar")
add_jar(${example_name} SOURCES ${example_src} INCLUDE_JARS ${example_jar})
- add_dependencies(${example_name} javaupm_${jar_name})
endmacro()
-macro(add_example_with_path example_name jar_path jar_name)
+macro(add_example_with_path example_name jar_path)
set(example_src "${example_name}.java")
- set(example_jar "${CMAKE_CURRENT_BINARY_DIR}/../../src/${jar_path}/upm_${jar_name}.jar")
+ set(example_jar "${CMAKE_CURRENT_BINARY_DIR}/../../src/${jar_path}")
add_jar(${example_name} SOURCES ${example_src} INCLUDE_JARS ${example_jar})
- add_dependencies(${example_name} javaupm_${jar_name})
endmacro()
add_example(A110X_intrSample a110x)
@@ -107,41 +105,12 @@ add_example(Ad8232Example ad8232)
add_example(Gp2y0aExample gp2y0a)
add_example(Th02Example th02)
add_example(FlexSensorExample flex)
-add_example(CWLSXXA_Example cwlsxxa)
-add_example(TEAMS_Example teams)
-add_example(APA102Sample apa102)
-add_example(TEX00_Example tex00)
-add_example(BMI160_Example bmi160)
-add_example(Tsl2561 tsl2561)
-add_example(AM2315Example am2315)
-add_example(MAX31855Example max31855)
-add_example(MAX5487Example max5487)
-add_example(MAXds3231mExample maxds3231m)
-add_example(ECS1030Example ecs1030)
-add_example(SM130Example sm130)
-if (MODBUS_FOUND)
- add_example(H803X_Example h803x)
-endif()
-if (BACNET_FOUND)
- add_example(E50HX_Example e50hx)
- add_example(T8100_Example t8100)
- add_example(TB7300_Example tb7300)
-endif()
-add_example(VCAP_Example vcap)
-add_example(BMP280_Example bmp280)
-add_example(BNO055_Example bno055)
-add_example(BMX055_Example bmx055)
-add_example_with_path(Jhd1313m1_lcdSample lcd i2clcd)
-add_example_with_path(Jhd1313m1Sample lcd i2clcd)
-add_example_with_path(Lcm1602_i2cSample lcd i2clcd)
-add_example_with_path(Lcm1602_parallelSample lcd i2clcd)
-add_example_with_path(SSD1308_oledSample lcd i2clcd)
-add_example_with_path(SSD1327_oledSample lcd i2clcd)
-add_example_with_path(BME280_Example bmp280 bmp280)
-add_example_with_path(BMA250E_Example bmx055 bmx055)
-add_example_with_path(BMG160_Example bmx055 bmx055)
-add_example_with_path(BMM150_Example bmx055 bmx055)
-add_example_with_path(BMC150_Example bmx055 bmx055)
-add_example_with_path(BMI055_Example bmx055 bmx055)
+
+add_example_with_path(Jhd1313m1_lcdSample lcd/upm_i2clcd.jar)
+add_example_with_path(Jhd1313m1Sample lcd/upm_i2clcd.jar)
+add_example_with_path(Lcm1602_i2cSample lcd/upm_i2clcd.jar)
+add_example_with_path(Lcm1602_parallelSample lcd/upm_i2clcd.jar)
+add_example_with_path(SSD1308_oledSample lcd/upm_i2clcd.jar)
+add_example_with_path(SSD1327_oledSample lcd/upm_i2clcd.jar)
diff --git a/peripheral/libupm/examples/java/CWLSXXA_Example.java b/peripheral/libupm/examples/java/CWLSXXA_Example.java
deleted file mode 100644
index e0f3052..0000000
--- a/peripheral/libupm/examples/java/CWLSXXA_Example.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_cwlsxxa.CWLSXXA;
-
-public class CWLSXXA_Example
-{
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
-
- // Instantiate an CWLSXXA instance, using A0 for CO2, A1 for
- // humidity and A2 for temperature
- CWLSXXA sensor = new CWLSXXA(0, 1, 2);
-
- while (true)
- {
- // update our values from the sensor
- sensor.update();
-
- // we show both C and F for temperature
- System.out.println("Temperature: "
- + sensor.getTemperature()
- + " C / "
- + sensor.getTemperature(true)
- + " F");
-
- System.out.println("Humidity: "
- + sensor.getHumidity()
- + " %");
-
- System.out.println("CO2: "
- + sensor.getCO2()
- + " ppm");
-
- Thread.sleep(1000);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/E50HX_Example.java b/peripheral/libupm/examples/java/E50HX_Example.java
deleted file mode 100644
index 24b6e3a..0000000
--- a/peripheral/libupm/examples/java/E50HX_Example.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_e50hx.E50HX;
-
-public class E50HX_Example
-{
- private static String defaultDev = "/dev/ttyUSB0";
-
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
-
- // You will need to edit this example to conform to your site
- // and your devices, specifically the Device Object Instance
- // ID passed to the constructor, and the arguments to
- // initMaster() that are appropriate for your BACnet network.
-
- if (args.length > 0)
- defaultDev = args[0];
- System.out.println("Using device " + defaultDev);
- System.out.println("Initializing...");
-
- // Instantiate an E50HX object for an E50HX device that has
- // 1075425 as it's unique Device Object Instance ID. NOTE:
- // You will certainly want to change this to the correct value
- // for your device(s).
- E50HX sensor = new E50HX(1075425);
-
- // Initialize our BACnet master, if it has not already been
- // initialized, with the device and baudrate, choosing 1000001 as
- // our unique Device Object Instance ID, 2 as our MAC address and
- // using default values for maxMaster and maxInfoFrames
- sensor.initMaster(defaultDev, 38400, 1000001, 2);
-
- // Uncomment to enable debugging output
- // sensor.setDebug(true);
-
- System.out.println();
- System.out.println("Device Description: "
- + sensor.getDeviceDescription());
- System.out.println("Device Location: "
- + sensor.getDeviceLocation());
- System.out.println();
-
- // update and print a few values every 5 seconds
- while (true)
- {
- System.out.println("System Voltage: "
- + sensor.getAnalogValue(E50HX.ANALOG_VALUES_T.AV_System_Voltage)
- + " "
- + sensor.getAnalogValueUnits(E50HX.ANALOG_VALUES_T.AV_System_Voltage));
-
- System.out.println("System Type: "
- + sensor.getAnalogValue(E50HX.ANALOG_VALUES_T.AV_System_Type));
-
- System.out.println("Energy Consumption: "
- + sensor.getAnalogInput(E50HX.ANALOG_INPUTS_T.AI_Energy)
- + " "
- + sensor.getAnalogInputUnits(E50HX.ANALOG_INPUTS_T.AI_Energy));
-
- System.out.println("Power Up Counter: "
- + sensor.getAnalogInput(E50HX.ANALOG_INPUTS_T.AI_Power_Up_Count));
-
- System.out.println();
- Thread.sleep(5000);
- }
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/ECS1030Example.java b/peripheral/libupm/examples/java/ECS1030Example.java
deleted file mode 100644
index b922349..0000000
--- a/peripheral/libupm/examples/java/ECS1030Example.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Author: Abhishek Malik <abhishek.malik@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-import upm_ecs1030.ECS1030;
-
-public class ECS1030Example {
-
- static {
- try {
- System.loadLibrary("javaupm_ecs1030");
- System.loadLibrary("mraajava");
- } catch (UnsatisfiedLinkError e) {
- System.err.println(
- "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
- e);
- System.exit(1);
- }
- }
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- //! [Interesting]
- ECS1030 sensor = new ECS1030((short)0);
-
- while(true){
- System.out.println("I = "+sensor.getCurrency_A()+", Power = "+sensor.getPower_A());
- System.out.println("I = "+sensor.getCurrency_B()+", Power = "+sensor.getPower_B());
- }
- //! [Interesting]
- }
-
-} \ No newline at end of file
diff --git a/peripheral/libupm/examples/java/Gp2y0aExample.java b/peripheral/libupm/examples/java/Gp2y0aExample.java
index 1501b87..0837f55 100644
--- a/peripheral/libupm/examples/java/Gp2y0aExample.java
+++ b/peripheral/libupm/examples/java/Gp2y0aExample.java
@@ -59,7 +59,7 @@ public class Gp2y0aExample {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception occurred: "+e.getMessage());
+ System.out.println("The following exception occured: "+e.getMessage());
}
}
//! [Interesting]
diff --git a/peripheral/libupm/examples/java/GroveEmg.java b/peripheral/libupm/examples/java/GroveEmg.java
index 9827701..eaa8ba0 100644
--- a/peripheral/libupm/examples/java/GroveEmg.java
+++ b/peripheral/libupm/examples/java/GroveEmg.java
@@ -39,7 +39,7 @@ public class GroveEmg {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception occurred: "+e.getMessage());
+ System.out.println("The following exception occured: "+e.getMessage());
}
}
}
diff --git a/peripheral/libupm/examples/java/GroveGsr.java b/peripheral/libupm/examples/java/GroveGsr.java
index d7e9a69..08a04b9 100644
--- a/peripheral/libupm/examples/java/GroveGsr.java
+++ b/peripheral/libupm/examples/java/GroveGsr.java
@@ -41,7 +41,7 @@ public class GroveGsr {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception occurred: "+e.getMessage());
+ System.out.println("The following exception occured: "+e.getMessage());
}
}
//! [Interesting]
diff --git a/peripheral/libupm/examples/java/GroveO2Example.java b/peripheral/libupm/examples/java/GroveO2Example.java
index 6ef0e61..fe22b80 100644
--- a/peripheral/libupm/examples/java/GroveO2Example.java
+++ b/peripheral/libupm/examples/java/GroveO2Example.java
@@ -38,7 +38,7 @@ public class GroveO2Example {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception has occurred: "+e.getMessage());
+ System.out.println("The following exception has occured: "+e.getMessage());
}
}
//! [Interesting]
diff --git a/peripheral/libupm/examples/java/H803X_Example.java b/peripheral/libupm/examples/java/H803X_Example.java
deleted file mode 100644
index 5d4828e..0000000
--- a/peripheral/libupm/examples/java/H803X_Example.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_h803x.H803X;
-
-public class H803X_Example
-{
- private static String defaultDev = "/dev/ttyUSB0";
-
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
- if (args.length > 0)
- defaultDev = args[0];
- System.out.println("Using device " + defaultDev);
- System.out.println("Initializing...");
-
- // Instantiate an H803X instance, using MODBUS slave address 1, and
- // default comm parameters (9600, 8, N, 2)
- H803X sensor = new H803X(defaultDev, 1);
-
- // output the Slave ID (manufacturer, model, serno)
- System.out.println("Slave ID: " + sensor.getSlaveID());
- System.out.println();
-
- while (true)
- {
- // update our values from the sensor
- sensor.update();
-
- // H8035 / H8036
- System.out.println("Consumption (kWh): "
- + sensor.getConsumption());
- System.out.println("Real Power (kW): "
- + sensor.getRealPower());
-
- if (sensor.isH8036())
- {
- // The H8036 has much more data available...
-
- System.out.println("Reactive Power (kVAR): "
- + sensor.getReactivePower());
- System.out.println("Apparent Power (kVA): "
- + sensor.getApparentPower());
- System.out.println("Power Factor: "
- + sensor.getPowerFactor());
- System.out.println("Volts Line to Line: "
- + sensor.getVoltsLineToLine());
- System.out.println("Volts Line to Neutral: "
- + sensor.getVoltsLineToNeutral());
-
- System.out.println("Current: " + sensor.getCurrent());
-
- System.out.println("Real Power Phase A (kW): "
- + sensor.getRealPowerPhaseA());
- System.out.println("Real Power Phase B (kW): "
- + sensor.getRealPowerPhaseB());
- System.out.println("Real Power Phase C (kW): "
- + sensor.getRealPowerPhaseC());
-
- System.out.println("Power Factor Phase A: "
- + sensor.getPowerFactorPhaseA());
- System.out.println("Power Factor Phase B: "
- + sensor.getPowerFactorPhaseB());
- System.out.println("Power Factor Phase C: "
- + sensor.getPowerFactorPhaseC());
-
- System.out.println("Volts Phase A to B: "
- + sensor.getVoltsPhaseAToB());
- System.out.println("Volts Phase B to C: "
- + sensor.getVoltsPhaseBToC());
- System.out.println("Volts Phase A to C: "
- + sensor.getVoltsPhaseAToC());
- System.out.println("Volts Phase A to Neutral: "
- + sensor.getVoltsPhaseAToNeutral());
- System.out.println("Volts Phase B to Neutral: "
- + sensor.getVoltsPhaseBToNeutral());
- System.out.println("Volts Phase C to Neutral: "
- + sensor.getVoltsPhaseCToNeutral());
-
- System.out.println("Current Phase A: "
- + sensor.getCurrentPhaseA());
- System.out.println("Current Phase B: "
- + sensor.getCurrentPhaseB());
- System.out.println("Current Phase C: "
- + sensor.getCurrentPhaseC());
-
- System.out.println("Avg Real Power (kW): "
- + sensor.getAvgRealPower());
- System.out.println("Min Real Power (kW): "
- + sensor.getMinRealPower());
- System.out.println("Max Real Power (kW): "
- + sensor.getMaxRealPower());
- }
-
- System.out.println();
- Thread.sleep(2000);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/HP20xExample.java b/peripheral/libupm/examples/java/HP20xExample.java
index 17e9441..8082031 100644
--- a/peripheral/libupm/examples/java/HP20xExample.java
+++ b/peripheral/libupm/examples/java/HP20xExample.java
@@ -42,7 +42,7 @@ public class HP20xExample {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception occurred: "+e.getMessage());
+ System.out.println("The following exception occured: "+e.getMessage());
}
}
//! [Interesting]
diff --git a/peripheral/libupm/examples/java/MAX31855Example.java b/peripheral/libupm/examples/java/MAX31855Example.java
deleted file mode 100644
index 1b1127e..0000000
--- a/peripheral/libupm/examples/java/MAX31855Example.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Author: Abhishek Malik <abhishek.malik@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-import upm_max31855.MAX31855;
-
-public class MAX31855Example {
-
- static {
- try {
- System.loadLibrary("javaupm_max31855");
- System.loadLibrary("mraajava");
- } catch (UnsatisfiedLinkError e) {
- System.err.println(
- "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
- e);
- System.exit(1);
- }
- }
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- //! [Interesting]
- MAX31855 sensor = new MAX31855(0, 8);
- while(true){
- System.out.println("Temperature: "+sensor.getTemp());
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- System.out.println("The following exception occured: "+e.getMessage());
- }
- }
- //! [Interesting]
- }
-
-} \ No newline at end of file
diff --git a/peripheral/libupm/examples/java/MAX5487Example.java b/peripheral/libupm/examples/java/MAX5487Example.java
deleted file mode 100644
index 92b5331..0000000
--- a/peripheral/libupm/examples/java/MAX5487Example.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Author: Abhishek Malik <abhishek.malik@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-import upm_max5487.MAX5487;
-
-public class MAX5487Example {
-
- static {
- try {
- System.loadLibrary("javaupm_max5487");
- System.loadLibrary("mraajava");
- } catch (UnsatisfiedLinkError e) {
- System.err.println(
- "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
- e);
- System.exit(1);
- }
- }
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- //! [Interesting]
- MAX5487 sensor = new MAX5487(7);
-
- // Power LED UP
- for(int i=0; i<255; i++){
- sensor.setWiperA((short)i);
- try {
- Thread.sleep(5);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- System.out.println("The following Exception occured: "+e.getMessage());
- }
- }
-
- // Power LED DOWN
- for(int i=0; i<255; i++){
- sensor.setWiperA((short)(255 - i));
- try {
- Thread.sleep(5);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- System.out.println("The following exception occured: "+e.getMessage());
- }
- }
-
- System.out.println("Exiting...");
- //! [Interesting]
- }
-
-} \ No newline at end of file
diff --git a/peripheral/libupm/examples/java/MAXds3231mExample.java b/peripheral/libupm/examples/java/MAXds3231mExample.java
deleted file mode 100644
index 12e6dba..0000000
--- a/peripheral/libupm/examples/java/MAXds3231mExample.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Author: Abhishek Malik <abhishek.malik@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-import upm_maxds3231m.MAXDS3231M;
-import upm_maxds3231m.Time3231;
-
-public class MAXds3231mExample {
-
- static {
- try {
- System.loadLibrary("javaupm_maxds3231m");
- System.loadLibrary("mraajava");
- } catch (UnsatisfiedLinkError e) {
- System.err.println(
- "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
- e);
- System.exit(1);
- }
- }
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- //! [Interesting]
- MAXDS3231M sensor = new MAXDS3231M(upm_maxds3231m.javaupm_maxds3231mConstants.ADDR);
- Time3231 t = new Time3231();
-
- t.setSecond((short)1);
- t.setMinute((short)3);
- t.setHour((short)3);
- t.setDay((short)3);
- t.setMonth((short)3);
- t.setYear((short)3);
- t.setWeekDay((short)3);
-
- sensor.setDate(t);
-
- try {
- Thread.sleep(500);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- System.out.println("The following exception occured: "+e.getMessage());
- }
-
- while(true){
- if(sensor.getDate(t)){
- System.out.println(t.getHour()+":"+t.getMinute()+":"+t.getSecond());
- }
- System.out.println("Temperature: "+sensor.getTemperature());
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- System.out.println("The following exception occcured: "+e.getMessage());
- }
- }
- //! [Interesting]
- }
-
-} \ No newline at end of file
diff --git a/peripheral/libupm/examples/java/SM130Example.java b/peripheral/libupm/examples/java/SM130Example.java
deleted file mode 100644
index 16f056d..0000000
--- a/peripheral/libupm/examples/java/SM130Example.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Author: Abhishek Malik <abhishek.malik@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-import upm_sm130.SM130;
-
-public class SM130Example {
-
- static {
- try {
- System.loadLibrary("javaupm_sm130");
- System.loadLibrary("mraajava");
- } catch (UnsatisfiedLinkError e) {
- System.err.println(
- "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
- e);
- System.exit(1);
- }
- }
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- //! [Interesting]
- // Instantiate a UART based SM130 RFID Module using defaults
- SM130 sensor = new SM130();
-
- // set the baud rate. 19200 baud is the default.
- if(sensor.setBaudRate(19200) == 1){
- System.out.println("Failed to set baud rate");
- return;
- }
-
- System.out.println("Resetting...");
- sensor.reset();
-
- System.out.println("Firmware revision: "+sensor.getFirmwareVersion());
- System.out.println("Waiting up to 5 seconds for a tag...");
-
- if(sensor.waitForTag(5000)){
- System.out.println("Found tag, UID: "+sensor.string2HexString(sensor.getUID()));
- System.out.println("Tag Type: "+sensor.tag2String(sensor.getTagType()));
- }
- else{
- // error
- System.out.println("waitForTag failed: "+sensor.getLastErrorString());
- }
- //! [Interesting]
- }
-
-} \ No newline at end of file
diff --git a/peripheral/libupm/examples/java/T8100_Example.java b/peripheral/libupm/examples/java/T8100_Example.java
deleted file mode 100644
index 162c23f..0000000
--- a/peripheral/libupm/examples/java/T8100_Example.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_t8100.T8100;
-
-public class T8100_Example
-{
- private static String defaultDev = "/dev/ttyUSB0";
-
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
-
- // You will need to edit this example to conform to your site
- // and your devices, specifically the Device Object Instance
- // ID passed to the constructor, and the arguments to
- // initMaster() that are appropriate for your BACnet network.
-
- if (args.length > 0)
- defaultDev = args[0];
- System.out.println("Using device " + defaultDev);
- System.out.println("Initializing...");
-
- // Instantiate an T8100 object for an T8100 device that has
- // 568000 as it's unique Device Object Instance ID. NOTE: You
- // will certainly want to change this to the correct value for
- // your device(s).
- T8100 sensor = new T8100(568000);
-
- // Initialize our BACnet master, if it has not already been
- // initialized, with the device and baudrate, choosing 1000001
- // as our unique Device Object Instance ID, 2 as our MAC
- // address and using default values for maxMaster and
- // maxInfoFrames
- sensor.initMaster(defaultDev, 38400, 1000001, 2);
-
- // Uncomment to enable debugging output
- // sensor.setDebug(true);
-
- System.out.println();
- System.out.println("Device Description: "
- + sensor.getDeviceDescription());
- System.out.println("Device Location: " + sensor.getDeviceLocation());
- System.out.println();
-
- // update and print a few values every 5 seconds
- while (true)
- {
- // update our values
- sensor.update();
-
- System.out.println("CO2 Concentration: "
- + sensor.getCO2()
- + " ppm");
-
- // we show both C and F for temperature
- System.out.println("Temperature: "
- + sensor.getTemperature()
- + " C / "
- + sensor.getTemperature(true)
- + " F");
-
- System.out.println("Humidity: "
- + sensor.getHumidity()
- + " %RH");
-
- System.out.println("Relay State: "
- + sensor.getRelayState());
-
- System.out.println();
- Thread.sleep(5000);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/TB7300_Example.java b/peripheral/libupm/examples/java/TB7300_Example.java
deleted file mode 100644
index 250dcdf..0000000
--- a/peripheral/libupm/examples/java/TB7300_Example.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_tb7300.TB7300;
-
-public class TB7300_Example
-{
- private static String defaultDev = "/dev/ttyUSB0";
-
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
-
- // You will need to edit this example to conform to your site
- // and your devices, specifically the Device Object Instance
- // ID passed to the constructor, and the arguments to
- // initMaster() that are appropriate for your BACnet network.
-
- if (args.length > 0)
- defaultDev = args[0];
- System.out.println("Using device " + defaultDev);
- System.out.println("Initializing...");
-
- // Instantiate an TB7300 object for an TB7300 device that has
- // 73001 as it's unique Device Object Instance ID. NOTE: You
- // will certainly want to change this to the correct value for
- // your device(s).
- TB7300 sensor = new TB7300(73001);
-
- // Initialize our BACnet master, if it has not already been
- // initialized, with the device and baudrate, choosing 1000001
- // as our unique Device Object Instance ID, 2 as our MAC
- // address and using default values for maxMaster and
- // maxInfoFrames
- sensor.initMaster(defaultDev, 38400, 1000001, 2);
-
- // Uncomment to enable debugging output
- // sensor.setDebug(true);
-
- System.out.println();
- System.out.println("Device Name: "
- + sensor.getDeviceName());
- System.out.println("Device Description: "
- + sensor.getDeviceDescription());
- System.out.println("Device Location: " + sensor.getDeviceLocation());
- System.out.println();
-
- System.out.println("Fan Mode: "
- + sensor.getMultiStateValueText(TB7300.MULTISTATE_VALUES_T.MV_Fan_Mode));
- System.out.println("Fan Status: "
- + sensor.getMultiStateValueText(TB7300.MULTISTATE_VALUES_T.MV_Fan_Status));
- System.out.println("System Mode: "
- + sensor.getMultiStateValueText(TB7300.MULTISTATE_VALUES_T.MV_System_Mode));
- System.out.println("Service Alarm:"
- + sensor.getBinaryInputText(TB7300.BINARY_INPUTS_T.BI_Service_Alarm));
-
- System.out.println();
-
- // update and print the room temperature every 5 seconds
- while (true)
- {
- // update our values
- sensor.update();
-
- // we show both C and F for temperature
- System.out.println("Temperature: "
- + sensor.getTemperature()
- + " C / "
- + sensor.getTemperature(true)
- + " F");
-
- System.out.println();
- Thread.sleep(5000);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/TEAMS_Example.java b/peripheral/libupm/examples/java/TEAMS_Example.java
deleted file mode 100644
index caeda6f..0000000
--- a/peripheral/libupm/examples/java/TEAMS_Example.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_teams.TEAMS;
-
-public class TEAMS_Example
-{
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
- System.out.println("Initializing...");
-
- // Instantiate an TEAMS instance, using A0 for temperature, and
- // 165.0 ohms for the rResistor value (for the libelium 4-20ma
- // interface)
- TEAMS sensor = new TEAMS(0, 165.0f);
-
- while (true)
- {
- // update our values from the sensor
- sensor.update();
-
- // is the sensor connected? (current >= 4ma)
- System.out.println("Is Connected: " + sensor.isConnected());
-
- // print computed current on the loop. This includes
- // the offset, if one was set by setOffsetMilliamps().
- System.out.println("Milliamps: " + sensor.getRawMilliamps());
-
- // we show both C and F for temperature
- System.out.println("Temperature: "
- + sensor.getTemperature()
- + " C / "
- + sensor.getTemperature(true)
- + " F");
-
- System.out.println();
- Thread.sleep(1000);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/TEX00_Example.java b/peripheral/libupm/examples/java/TEX00_Example.java
deleted file mode 100644
index b2e307b..0000000
--- a/peripheral/libupm/examples/java/TEX00_Example.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_tex00.TEX00;
-
-public class TEX00_Example
-{
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
- System.out.println("Initializing...");
-
- // Instantiate an TEX00 instance, using A0 for the analog input. In
- // this example, we are using a 10K Ohm balance resistor and a TED
- // (10k type 2) thermistor.
- TEX00 sensor = new TEX00(0, 10000.0f,
- TEX00.SENSOR_TYPES_T.STYPE_THERMISTOR_TED);
-
- System.out.println("Minimum temperature: "
- + sensor.getTemperatureRangeMin());
- System.out.println("Maximum temperature: "
- + sensor.getTemperatureRangeMax());
- System.out.println();
-
- while (true)
- {
- // update our values from the sensor
- sensor.update();
-
- if (sensor.isOutOfRange())
- {
- System.out.println("Temperature out of range");
- }
- else
- {
- // we show both C and F for temperature
- System.out.println("Temperature: "
- + sensor.getTemperature()
- + " C / "
- + sensor.getTemperature(true)
- + " F");
- }
-
- System.out.println();
- Thread.sleep(1000);
- }
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/Th02Example.java b/peripheral/libupm/examples/java/Th02Example.java
index 206f89e..f2a97c4 100644
--- a/peripheral/libupm/examples/java/Th02Example.java
+++ b/peripheral/libupm/examples/java/Th02Example.java
@@ -25,6 +25,18 @@ import upm_th02.TH02;
public class Th02Example {
+ static {
+ try {
+ System.loadLibrary("javaupm_th02");
+ System.loadLibrary("mraajava");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println(
+ "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
+ e);
+ System.exit(1);
+ }
+ }
+
public static void main(String[] args) {
// TODO Auto-generated method stub
float temperature = 0;
@@ -39,7 +51,7 @@ public class Th02Example {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception has occurred: "+e.getMessage());
+ System.out.println("The following exception has occured: "+e.getMessage());
}
}
}
diff --git a/peripheral/libupm/examples/java/Tsl2561.java b/peripheral/libupm/examples/java/Tsl2561.java
deleted file mode 100644
index 895b2e5..0000000
--- a/peripheral/libupm/examples/java/Tsl2561.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Author: Abhishek Malik <abhishek.malik@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-import upm_tsl2561.TSL2561;
-
-public class Tsl2561 {
-
- static {
- try {
- System.loadLibrary("javaupm_tsl2561");
- System.loadLibrary("mraajava");
- } catch (UnsatisfiedLinkError e) {
- System.err.println(
- "Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" +
- e);
- System.exit(1);
- }
- }
-
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- //! [Interesting]
- TSL2561 sensor = null;
- int loopCount = 100;
- // Instantiate the sensor object
- sensor = new TSL2561();
-
- for (int i=0; i<loopCount; i++){
- // retrieving and displaying the Lux value
- System.out.println("Lux: "+sensor.getLux());
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- System.out.println("The following exception occurred: "+e.getMessage());
- }
- }
- //! [Interesting]
- }
-
-}
diff --git a/peripheral/libupm/examples/java/VCAP_Example.java b/peripheral/libupm/examples/java/VCAP_Example.java
deleted file mode 100644
index 73d06ad..0000000
--- a/peripheral/libupm/examples/java/VCAP_Example.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-import upm_vcap.VCAP;
-
-public class VCAP_Example
-{
- private static String defaultDev = "/dev/video0";
-
- public static void main(String[] args) throws InterruptedException
- {
-// ! [Interesting]
- if (args.length > 0)
- defaultDev = args[0];
-
- System.out.println("Using device " + defaultDev);
- System.out.println("Initializing...");
-
- // Instantiate an VCAP instance, using the specified video device
- VCAP sensor = new VCAP(defaultDev);
-
- // enable some debug/verbose output
- sensor.setDebug(true);
-
- // This is just a hint. The kernel can change this to a lower
- // resolution that the hardware supports. Use getWidth() and
- // getHeight() methods to see what the kernel actually chose if you
- // care.
- sensor.setResolution(1920, 1080);
-
- // capture an image
- sensor.captureImage();
-
- // convert and save it as a jpeg
- sensor.saveImage("video-img1.jpg");
-
-// ! [Interesting]
- }
-}
diff --git a/peripheral/libupm/examples/java/WaterLevelSensor.java b/peripheral/libupm/examples/java/WaterLevelSensor.java
index c13ec5b..d08aaee 100644
--- a/peripheral/libupm/examples/java/WaterLevelSensor.java
+++ b/peripheral/libupm/examples/java/WaterLevelSensor.java
@@ -43,7 +43,7 @@ public class WaterLevelSensor {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
- System.out.println("The following exception occurred: "+e.getMessage());
+ System.out.println("The following exception occured: "+e.getMessage());
}
}
//! [Interesting]
diff --git a/peripheral/libupm/examples/javascript/apa102.js b/peripheral/libupm/examples/javascript/apa102.js
deleted file mode 100644
index c8b841f..0000000
--- a/peripheral/libupm/examples/javascript/apa102.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-/*
-* Author: Yannick Adam <yannick.adam@gmail.com>
-* Copyright (c) 2016 Yannick Adam
-*
-* Permission is hereby granted, free of charge, to any person obtaining
-* a copy of this software and associated documentation files (the
-* "Software"), to deal in the Software without restriction, including
-* without limitation the rights to use, copy, modify, merge, publish,
-* distribute, sublicense, and/or sell copies of the Software, and to
-* permit persons to whom the Software is furnished to do so, subject to
-* the following conditions:
-*
-* The above copyright notice and this permission notice shall be
-* included in all copies or substantial portions of the Software.
-*
-* 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.
-*/
-
-var lib = require('jsupm_apa102');
-
-// Instantiate a strip of 30 LEDs on SPI Bus 0
-var ledStrip = new lib.APA102(30, 0);
-
-// Set all LEDs to blue
-ledStrip.setAllLeds(31, 0, 0, 255);
-
-// Set a mid-section to red
-ledStrip.setLeds(10,20, 31, 255, 0, 0);
-
-// Set a single led to green
-ledStrip.setLed(15, 31, 0, 255, 0);
-
-
-// Exit
-ledStrip = null;
-process.exit(0);
diff --git a/peripheral/libupm/examples/javascript/bma250e.js b/peripheral/libupm/examples/javascript/bma250e.js
deleted file mode 100644
index 55780d7..0000000
--- a/peripheral/libupm/examples/javascript/bma250e.js
+++ /dev/null
@@ -1,72 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-var sensorObj = require('jsupm_bmx055');
-
-// Instantiate a BMA250E instance using default i2c bus and address
-var sensor = new sensorObj.BMA250E();
-
-// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
-// BMA250E(0, -1, 10);
-
-var x = new sensorObj.new_floatp();
-var y = new sensorObj.new_floatp();
-var z = new sensorObj.new_floatp();
-
-// now output data every 250 milliseconds
-setInterval(function()
-{
- // update our values from the sensor
- sensor.update();
-
- sensor.getAccelerometer(x, y, z);
- console.log("Accelerometer x: "
- + sensorObj.floatp_value(x)
- + " y: " + sensorObj.floatp_value(y)
- + " z: " + sensorObj.floatp_value(z)
- + " g");
-
- // we show both C and F for temperature
- console.log("Compensation Temperature: "
- + sensor.getTemperature()
- + " C / "
- + sensor.getTemperature(true)
- + " F");
-
- console.log();
-
-}, 250);
-
-// exit on ^C
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting.");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/bmc150.js b/peripheral/libupm/examples/javascript/bmc150.js
deleted file mode 100644
index a3e2900..0000000
--- a/peripheral/libupm/examples/javascript/bmc150.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-var sensorObj = require('jsupm_bmx055');
-
-// Instantiate a BMC150 instance using default i2c bus and address
-var sensor = new sensorObj.BMC150();
-
-var x = new sensorObj.new_floatp();
-var y = new sensorObj.new_floatp();
-var z = new sensorObj.new_floatp();
-
-// now output data every 250 milliseconds
-setInterval(function()
-{
- // update our values from the sensor
- sensor.update();
-
- sensor.getAccelerometer(x, y, z);
- console.log("Accelerometer x: "
- + sensorObj.floatp_value(x)
- + " y: " + sensorObj.floatp_value(y)
- + " z: " + sensorObj.floatp_value(z)
- + " g");
-
- sensor.getMagnetometer(x, y, z);
- console.log("Magnetometer x: "
- + sensorObj.floatp_value(x)
- + " y: " + sensorObj.floatp_value(y)
- + " z: " + sensorObj.floatp_value(z)
- + " uT");
-
- console.log();
-
-}, 250);
-
-// exit on ^C
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting.");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/bme280.js b/peripheral/libupm/examples/javascript/bme280.js
deleted file mode 100644
index a183c3f..0000000
--- a/peripheral/libupm/examples/javascript/bme280.js
+++ /dev/null
@@ -1,71 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-var sensorObj = require('jsupm_bmp280');
-
-// Instantiate a BME280 instance using default i2c bus and address
-var sensor = new sensorObj.BME280();
-
-// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
-// BME280(0, -1, 10);
-
-setInterval(function()
-{
- // update our values from the sensor
- sensor.update();
-
- console.log("Compensation Temperature: "
- + sensor.getTemperature()
- + " C / "
- + sensor.getTemperature(true)
- + " F");
-
- console.log("Pressure: "
- + sensor.getPressure()
- + " Pa");
-
- console.log("Computed Altitude: "
- + sensor.getAltitude()
- + " m");
-
- console.log("Humidity: "
- + sensor.getHumidity()
- + " %RH");
-
- console.log();
-
-}, 1000);
-
-// exit on ^C
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting.");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/bmg160.js b/peripheral/libupm/examples/javascript/bmg160.js
deleted file mode 100644
index 96f46a1..0000000
--- a/peripheral/libupm/examples/javascript/bmg160.js
+++ /dev/null
@@ -1,72 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-var sensorObj = require('jsupm_bmx055');
-
-// Instantiate a BMG160 instance using default i2c bus and address
-var sensor = new sensorObj.BMG160();
-
-// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
-// BMG160(0, -1, 10);
-
-var x = new sensorObj.new_floatp();
-var y = new sensorObj.new_floatp();
-var z = new sensorObj.new_floatp();
-
-// now output data every 250 milliseconds
-setInterval(function()
-{
- // update our values from the sensor
- sensor.update();
-
- sensor.getGyroscope(x, y, z);
- console.log("Gyroscope x: "
- + sensorObj.floatp_value(x)
- + " y: " + sensorObj.floatp_value(y)
- + " z: " + sensorObj.floatp_value(z)
- + " degrees/s");
-
- // we show both C and F for temperature
- console.log("Compensation Temperature: "
- + sensor.getTemperature()
- + " C / "
- + sensor.getTemperature(true)
- + " F");
-
- console.log();
-
-}, 250);
-
-// exit on ^C
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting.");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/bmi055.js b/peripheral/libupm/examples/javascript/bmi055.js
deleted file mode 100644
index 4711071..0000000
--- a/peripheral/libupm/examples/javascript/bmi055.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-var sensorObj = require('jsupm_bmx055');
-
-// Instantiate a BMI055 instance using default i2c bus and address
-var sensor = new sensorObj.BMI055();
-
-var x = new sensorObj.new_floatp();
-var y = new sensorObj.new_floatp();
-var z = new sensorObj.new_floatp();
-
-// now output data every 250 milliseconds
-setInterval(function()
-{
- // update our values from the sensor
- sensor.update();
-
- sensor.getAccelerometer(x, y, z);
- console.log("Accelerometer x: "
- + sensorObj.floatp_value(x)
- + " y: " + sensorObj.floatp_value(y)
- + " z: " + sensorObj.floatp_value(z)
- + " g");
-
- sensor.getGyroscope(x, y, z);
- console.log("Gyroscope x: "
- + sensorObj.floatp_value(x)
- + " y: " + sensorObj.floatp_value(y)
- + " z: " + sensorObj.floatp_value(z)
- + " degrees/s");
-
- console.log();
-
-}, 250);
-
-// exit on ^C
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting.");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/bmi160.js b/peripheral/libupm/examples/javascript/bmi160.js
deleted file mode 100644
index 4df790e..0000000
--- a/peripheral/libupm/examples/javascript/bmi160.js
+++ /dev/null
@@ -1,71 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-var sensorObj = require('jsupm_bmi160');
-
-// Instantiate a BMI160 instance using default i2c bus and address
-var sensor = new sensorObj.BMI160();
-
-var x = new sensorObj.new_floatp();
-var y = new sensorObj.new_floatp();
-var z = new sensorObj.new_floatp();
-
-// Output data every half second until interrupted
-setInterval(function()
-{
- // update our values from the sensor
- sensor.update();
-
- sensor.getAccelerometer(x, y, z);
- console.log("Accelerometer: AX: " + sensorObj.floatp_value(x) +
- " AY: " + sensorObj.floatp_value(y) +
- " AZ: " + sensorObj.floatp_value(z));
-
- sensor.getGyroscope(x, y, z);
- console.log("Gyroscope: GX: " + sensorObj.floatp_value(x) +
- " AY: " + sensorObj.floatp_value(y) +
- " AZ: " + sensorObj.floatp_value(z));
-
- sensor.getMagnetometer(x, y, z);
- console.log("Magnetometer: MX: " + sensorObj.floatp_value(x) +
- " MY: " + sensorObj.floatp_value(y) +
- " MZ: " + sensorObj.floatp_value(z));
-
- console.log();
-
-}, 500);
-
-// exit on ^C
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting.");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/bmm150.js b/peripheral/libupm/examples/javascript/bmm150.js
deleted file mode 100644
index 8274aa9..0000000
--- a/peripheral/libupm/examples/javascript/bmm150.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-var sensorObj = require('jsupm_bmx055');
-
-// Instantiate a BMM150 instance using default i2c bus and address
-var sensor = new sensorObj.BMM150();
-
-// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
-// BMM150(0, -1, 10);
-
-var x = new sensorObj.new_floatp();
-var y = new sensorObj.new_floatp();
-var z = new sensorObj.new_floatp();
-
-// now output data every 250 milliseconds
-setInterval(function()
-{
- // update our values from the sensor
- sensor.update();
-
- sensor.getMagnetometer(x, y, z);
- console.log("Magnetometer x: "
- + sensorObj.floatp_value(x)
- + " y: " + sensorObj.floatp_value(y)
- + " z: " + sensorObj.floatp_value(z)
- + " uT");
-
- console.log();
-
-}, 250);
-
-// exit on ^C
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting.");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/bmp280.js b/peripheral/libupm/examples/javascript/bmp280.js
deleted file mode 100644
index 57a9a70..0000000
--- a/peripheral/libupm/examples/javascript/bmp280.js
+++ /dev/null
@@ -1,67 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-var sensorObj = require('jsupm_bmp280');
-
-// Instantiate a BMP280 instance using default i2c bus and address
-var sensor = new sensorObj.BMP280();
-
-// For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
-// BMP280(0, -1, 10);
-
-setInterval(function()
-{
- // update our values from the sensor
- sensor.update();
-
- console.log("Compensation Temperature: "
- + sensor.getTemperature()
- + " C / "
- + sensor.getTemperature(true)
- + " F");
-
- console.log("Pressure: "
- + sensor.getPressure()
- + " Pa");
-
- console.log("Computed Altitude: "
- + sensor.getAltitude()
- + " m");
-
- console.log();
-
-}, 1000);
-
-// exit on ^C
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting.");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/bmx055.js b/peripheral/libupm/examples/javascript/bmx055.js
deleted file mode 100644
index 7b0e9b9..0000000
--- a/peripheral/libupm/examples/javascript/bmx055.js
+++ /dev/null
@@ -1,76 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-var sensorObj = require('jsupm_bmx055');
-
-// Instantiate a BMX055 instance using default i2c bus and address
-var sensor = new sensorObj.BMX055();
-
-var x = new sensorObj.new_floatp();
-var y = new sensorObj.new_floatp();
-var z = new sensorObj.new_floatp();
-
-// now output data every 250 milliseconds
-setInterval(function()
-{
- // update our values from the sensor
- sensor.update();
-
- sensor.getAccelerometer(x, y, z);
- console.log("Accelerometer x: "
- + sensorObj.floatp_value(x)
- + " y: " + sensorObj.floatp_value(y)
- + " z: " + sensorObj.floatp_value(z)
- + " g");
-
- sensor.getGyroscope(x, y, z);
- console.log("Gyroscope x: "
- + sensorObj.floatp_value(x)
- + " y: " + sensorObj.floatp_value(y)
- + " z: " + sensorObj.floatp_value(z)
- + " degrees/s");
-
- sensor.getMagnetometer(x, y, z);
- console.log("Magnetometer x: "
- + sensorObj.floatp_value(x)
- + " y: " + sensorObj.floatp_value(y)
- + " z: " + sensorObj.floatp_value(z)
- + " uT");
-
- console.log();
-
-}, 250);
-
-// exit on ^C
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting.");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/bno055.js b/peripheral/libupm/examples/javascript/bno055.js
deleted file mode 100644
index b9a9f32..0000000
--- a/peripheral/libupm/examples/javascript/bno055.js
+++ /dev/null
@@ -1,117 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-var sensorObj = require('jsupm_bno055');
-
-// Instantiate an BNO055 using default parameters (bus 0, addr
-// 0x28). The default running mode is NDOF absolute orientation
-// mode.
-var sensor = new sensorObj.BNO055();
-
-var mag = new sensorObj.new_intp();
-var acc = new sensorObj.new_intp();
-var gyr = new sensorObj.new_intp();
-var syst = new sensorObj.new_intp();
-
-var w = new sensorObj.new_floatp();
-var x = new sensorObj.new_floatp();
-var y = new sensorObj.new_floatp();
-var z = new sensorObj.new_floatp();
-
-console.log("First we need to calibrate. 4 numbers will be output every");
-console.log("second for each sensor. 0 means uncalibrated, and 3 means");
-console.log("fully calibrated.");
-console.log("See the UPM documentation on this sensor for instructions on");
-console.log("what actions are required to calibrate.");
-console.log("");
-
-// do the calibration...
-var calInterval = setInterval(function()
-{
- if (sensor.isFullyCalibrated())
- {
- clearInterval(calInterval);
- console.log("");
- console.log("Calibration complete.");
- console.log("");
-
- setInterval(outputData, 250)
- }
- else
- {
- sensor.getCalibrationStatus(mag, acc, gyr, syst);
- console.log("Magnetometer: " + sensorObj.intp_value(mag) +
- " Accelerometer: " + sensorObj.intp_value(acc) +
- " Gyroscope: " + sensorObj.intp_value(gyr) +
- " System: " + sensorObj.intp_value(syst));
- }
-
-}, 1000);
-
-
-// now output various fusion data every 250 milliseconds
-function outputData()
-{
- sensor.update();
-
- sensor.getEulerAngles(x, y, z);
- console.log("Euler: Heading: " + sensorObj.floatp_value(x) +
- " Roll: " + sensorObj.floatp_value(y) +
- " Pitch: " + sensorObj.floatp_value(z) +
- " degrees");
-
- sensor.getQuaternions(w, x, y, z);
- console.log("Quaternion: W: " + sensorObj.floatp_value(w) +
- " X:" + sensorObj.floatp_value(x) +
- " Y: " + sensorObj.floatp_value(y) +
- " Z: " + sensorObj.floatp_value(z));
-
- sensor.getLinearAcceleration(x, y, z);
- console.log("Linear Acceleration: X: " + sensorObj.floatp_value(x) +
- " Y: " + sensorObj.floatp_value(y) +
- " Z: " + sensorObj.floatp_value(z) +
- " m/s^2");
-
- sensor.getGravityVectors(x, y, z);
- console.log("Gravity Vector: X: " + sensorObj.floatp_value(x) +
- " Y: " + sensorObj.floatp_value(y) +
- " Z: " + sensorObj.floatp_value(z) +
- " m/s^2");
-
- console.log("");
-};
-
-// exit on ^C
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting.");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/curieimu.js b/peripheral/libupm/examples/javascript/curieimu.js
deleted file mode 100644
index 72bfea0..0000000
--- a/peripheral/libupm/examples/javascript/curieimu.js
+++ /dev/null
@@ -1,52 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-/*
-* Author: Ron Evans (@deadprogram)
-* Copyright (c) 2016 Intel Corporation.
-*
-* Permission is hereby granted, free of charge, to any person obtaining
-* a copy of this software and associated documentation files (the
-* "Software"), to deal in the Software without restriction, including
-* without limitation the rights to use, copy, modify, merge, publish,
-* distribute, sublicense, and/or sell copies of the Software, and to
-* permit persons to whom the Software is furnished to do so, subject to
-* the following conditions:
-*
-* The above copyright notice and this permission notice shall be
-* included in all copies or substantial portions of the Software.
-*
-* 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.
-*/
-
-var mraa = require('mraa');
-console.log('MRAA Version: ' + mraa.getVersion());
-
-// open connection to Firmata
-mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0");
-
-var curieImu = require('jsupm_curieimu');
-var myCurie = new curieImu.CurieImu();
-
-var outputStr;
-var myInterval = setInterval(function()
-{
- myCurie.updateAccel();
- outputStr = "accel: x " + myCurie.getAccelX()
- + " - y " + myCurie.getAccelY()
- + " - z " + myCurie.getAccelZ();
- console.log(outputStr);
-}, 500);
-
-// Print message when exiting
-process.on('SIGINT', function()
-{
- clearInterval(myInterval);
- console.log("Exiting");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/cwlsxxa.js b/peripheral/libupm/examples/javascript/cwlsxxa.js
deleted file mode 100644
index 46d9fe7..0000000
--- a/peripheral/libupm/examples/javascript/cwlsxxa.js
+++ /dev/null
@@ -1,66 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-var sensorObj = require('jsupm_cwlsxxa');
-
-
-/************** Main code **************/
-
-console.log("Initializing...");
-
-// Instantiate an CWLSXXA instance, using A0 for CO2, A1 for
-// humidity and A2 for temperature
-var sensor = new sensorObj.CWLSXXA(0, 1, 2);
-
-// update and print available values every second
-setInterval(function()
-{
- // update our values from the sensor
- sensor.update();
-
- // we show both C and F for temperature
- console.log("Temperature:", sensor.getTemperature(),
- "C /", sensor.getTemperature(true), "F");
-
- console.log("Humidity:", sensor.getHumidity(), "%");
-
- console.log("CO2:", sensor.getCO2(), "ppm");
-
- console.log("");
-
-}, 1000);
-
-
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting...");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/ds18b20.js b/peripheral/libupm/examples/javascript/ds18b20.js
deleted file mode 100644
index 3c2835f..0000000
--- a/peripheral/libupm/examples/javascript/ds18b20.js
+++ /dev/null
@@ -1,70 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-var sensorObj = require('jsupm_ds18b20');
-
-
-/************** Main code **************/
-
-console.log("Initializing...");
-
-// Instantiate an DS18B20 instance using the default values (uart 0)
-var sensor = new sensorObj.DS18B20(0);
-
-// locate and setup our devices
-sensor.init();
-
-console.log("Found", sensor.devicesFound(), "device(s)");
-console.log("");
-
-if (!sensor.devicesFound())
-{
- process.exit(1);
-}
-
-// update and print available values every second
-setInterval(function()
-{
- // update our values for the first sensor
- sensor.update(0);
-
- // we show both C and F for temperature for the first sensor
- console.log("Temperature:", sensor.getTemperature(0),
- "C /", sensor.getTemperature(0, true), "F");
-
-}, 1000);
-
-
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting...");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/ds2413.js b/peripheral/libupm/examples/javascript/ds2413.js
deleted file mode 100644
index 069be3a..0000000
--- a/peripheral/libupm/examples/javascript/ds2413.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-var sensorObj = require('jsupm_ds2413');
-
-
-/************** Main code **************/
-// Instantiate a DS2413 Module on a Dallas 1-wire bus connected to UART 0
-var sensor = new sensorObj.DS2413(0);
-
-// find all of the DS2413 devices present on the bus
-sensor.init();
-
-// how many devices were found?
-console.log("Found", sensor.devicesFound(), "device(s)");
-
-// read the gpio and latch values from the first device
-// the lower 4 bits are of the form:
-// <gpioB latch> <gpioB value> <gpioA latch> <gpioA value>
-console.log("GPIO device 0 values:", sensor.readGpios(0));
-
-// set the gpio latch values of the first device
-console.log("Setting GPIO latches to on");;
-sensor.writeGpios(0, 0x03);
-
-sensor = null;
-sensorObj.cleanUp();
-sensorObj = null;
-console.log("Exiting...");
-process.exit(0);
diff --git a/peripheral/libupm/examples/javascript/e50hx.js b/peripheral/libupm/examples/javascript/e50hx.js
deleted file mode 100644
index 692d9f5..0000000
--- a/peripheral/libupm/examples/javascript/e50hx.js
+++ /dev/null
@@ -1,101 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-var sensorObj = require('jsupm_e50hx');
-
-
-/************** Main code **************/
-
-// You will need to edit this example to conform to your site and your
-// devices, specifically the Device Object Instance ID passed to the
-// constructor, and the arguments to initMaster() that are
-// appropriate for your BACnet network.
-
-var defaultDev = "/dev/ttyUSB0";
-
-// if an argument was specified, use it as the device instead
-if (process.argv.length > 2)
-{
- defaultDev = process.argv[2];
-}
-
-console.log("Using device " + defaultDev);
-console.log("Initializing...");
-
-// Instantiate an E50HX object for an E50HX device that has 1075425
-// as it's unique Device Object Instance ID. NOTE: You will
-// certainly want to change this to the correct value for your
-// device(s).
-var sensor = new sensorObj.E50HX(1075425);
-
-// Initialize our BACnet master, if it has not already been
-// initialized, with the device and baudrate, choosing 1000001 as
-// our unique Device Object Instance ID, 2 as our MAC address and
-// using default values for maxMaster and maxInfoFrames
-sensor.initMaster(defaultDev, 38400, 1000001, 2);
-
-// Uncomment to enable debugging output
-// sensor.setDebug(true);
-
-console.log("");
-console.log("Device Description:", sensor.getDeviceDescription());
-console.log("Device Location:", sensor.getDeviceLocation());
-console.log("");
-
-// update and print a few values every 5 seconds
-setInterval(function()
-{
- console.log("System Voltage:",
- sensor.getAnalogValue(sensorObj.E50HX.AV_System_Voltage),
- " ",
- sensor.getAnalogValueUnits(sensorObj.E50HX.AV_System_Voltage));
-
- console.log("System Type:",
- sensor.getAnalogValue(sensorObj.E50HX.AV_System_Type));
-
- console.log("Energy Consumption:",
- sensor.getAnalogInput(sensorObj.E50HX.AI_Energy),
- " ",
- sensor.getAnalogInputUnits(sensorObj.E50HX.AI_Energy));
-
- console.log("Power Up Counter:",
- sensor.getAnalogInput(sensorObj.E50HX.AI_Power_Up_Count));
-
- console.log("");
-
-}, 5000);
-
-
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting...");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/h803x.js b/peripheral/libupm/examples/javascript/h803x.js
deleted file mode 100644
index 23fe5d8..0000000
--- a/peripheral/libupm/examples/javascript/h803x.js
+++ /dev/null
@@ -1,115 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-var sensorObj = require('jsupm_h803x');
-
-
-/************** Main code **************/
-
-var defaultDev = "/dev/ttyUSB0";
-
-// if an argument was specified, use it as the device instead
-if (process.argv.length > 2)
-{
- defaultDev = process.argv[2];
-}
-
-console.log("Using device " + defaultDev);
-console.log("Initializing...");
-
-// Instantiate an H803X instance, using MODBUS slave address 1, and
-// default comm parameters (9600, 8, N, 2)
-var sensor = new sensorObj.H803X(defaultDev, 1);
-
-// output the Slave ID (manufacturer, model, serno)
-console.log("Slave ID:", sensor.getSlaveID());
-
-console.log("");
-
-// update and print available values every second
-setInterval(function()
-{
- // update our values from the sensor
- sensor.update();
-
- // H8035 / H8036
- console.log("Consumption (kWh):", sensor.getConsumption());
- console.log("Real Power (kW):", sensor.getRealPower());
-
- if (sensor.isH8036())
- {
- // The H8036 has much more data available...
-
- console.log("Reactive Power (kVAR):", sensor.getReactivePower());
- console.log("Apparent Power (kVA):", sensor.getApparentPower());
- console.log("Power Factor:", sensor.getPowerFactor());
- console.log("Volts Line to Line:", sensor.getVoltsLineToLine());
- console.log("Volts Line to Neutral:", sensor.getVoltsLineToNeutral());
-
- console.log("Current:", sensor.getCurrent());
-
- console.log("Real Power Phase A (kW):", sensor.getRealPowerPhaseA());
- console.log("Real Power Phase B (kW):", sensor.getRealPowerPhaseB());
- console.log("Real Power Phase C (kW):", sensor.getRealPowerPhaseC());
-
- console.log("Power Factor Phase A:", sensor.getPowerFactorPhaseA());
- console.log("Power Factor Phase B:", sensor.getPowerFactorPhaseB());
- console.log("Power Factor Phase C:", sensor.getPowerFactorPhaseC());
-
- console.log("Volts Phase A to B:", sensor.getVoltsPhaseAToB());
- console.log("Volts Phase B to C:", sensor.getVoltsPhaseBToC());
- console.log("Volts Phase A to C:", sensor.getVoltsPhaseAToC());
- console.log("Volts Phase A to Neutral: ",
- sensor.getVoltsPhaseAToNeutral());
- console.log("Volts Phase B to Neutral: ",
- sensor.getVoltsPhaseBToNeutral());
- console.log("Volts Phase C to Neutral: ",
- sensor.getVoltsPhaseCToNeutral());
-
- console.log("Current Phase A:", sensor.getCurrentPhaseA());
- console.log("Current Phase B:", sensor.getCurrentPhaseB());
- console.log("Current Phase C:", sensor.getCurrentPhaseC());
-
- console.log("Avg Real Power (kW):", sensor.getAvgRealPower());
- console.log("Min Real Power (kW):", sensor.getMinRealPower());
- console.log("Max Real Power (kW):", sensor.getMaxRealPower());
- }
-
- console.log("");
-
-}, 2000);
-
-
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting...");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/hmtrp.js b/peripheral/libupm/examples/javascript/hmtrp.js
index 94a803d..3bdd0f2 100644
--- a/peripheral/libupm/examples/javascript/hmtrp.js
+++ b/peripheral/libupm/examples/javascript/hmtrp.js
@@ -128,7 +128,7 @@ function runRadio()
console.log("Received: " + resultStr);
}
- if (rv < 0) // some sort of read error occurred
+ if (rv < 0) // some sort of read error occured
{
console.log("Port read error.");
return;
diff --git a/peripheral/libupm/examples/javascript/oled_ssd1306.js b/peripheral/libupm/examples/javascript/oled_ssd1306.js
index 95cc9d8..b3ceac7 100644
--- a/peripheral/libupm/examples/javascript/oled_ssd1306.js
+++ b/peripheral/libupm/examples/javascript/oled_ssd1306.js
@@ -90,7 +90,7 @@ function exit()
// Load i2clcd module
var lcdObj = require('jsupm_i2clcd');
-var lcd = new lcdObj.SSD1306(0, 0x3C);
+var lcd = new lcdObj.SSD1306(6, 0x3c);
var next = 0;
lcd.clear();
diff --git a/peripheral/libupm/examples/javascript/t8100.js b/peripheral/libupm/examples/javascript/t8100.js
deleted file mode 100644
index 7be2fad..0000000
--- a/peripheral/libupm/examples/javascript/t8100.js
+++ /dev/null
@@ -1,98 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-var sensorObj = require('jsupm_t8100');
-
-
-/************** Main code **************/
-
-// You will need to edit this example to conform to your site and your
-// devices, specifically the Device Object Instance ID passed to the
-// constructor, and the arguments to initMaster() that are
-// appropriate for your BACnet network.
-
-var defaultDev = "/dev/ttyUSB0";
-
-// if an argument was specified, use it as the device instead
-if (process.argv.length > 2)
-{
- defaultDev = process.argv[2];
-}
-
-console.log("Using device " + defaultDev);
-console.log("Initializing...");
-
-// Instantiate an T8100 object for an T8100 device that has 568000
-// as it's unique Device Object Instance ID. NOTE: You will
-// certainly want to change this to the correct value for your
-// device(s).
-var sensor = new sensorObj.T8100(568000);
-
-// Initialize our BACnet master, if it has not already been
-// initialized, with the device and baudrate, choosing 1000001 as
-// our unique Device Object Instance ID, 2 as our MAC address and
-// using default values for maxMaster and maxInfoFrames
-sensor.initMaster(defaultDev, 38400, 1000001, 2);
-
-// Uncomment to enable debugging output
-// sensor.setDebug(true);
-
-console.log("");
-console.log("Device Description:", sensor.getDeviceDescription());
-console.log("Device Location:", sensor.getDeviceLocation());
-console.log("");
-
-// update and print a few values every 5 seconds
-setInterval(function()
-{
- // update our values
- sensor.update();
-
- console.log("CO2 Concentration:", sensor.getCO2(), "ppm");
-
- // we show both C and F for temperature
- console.log("Temperature:", sensor.getTemperature(),
- "C /", sensor.getTemperature(true), "F");
-
- console.log("Humidity:", sensor.getHumidity(), "%RH");
-
- console.log("Relay State:", sensor.getRelayState());
-
- console.log("");
-
-}, 5000);
-
-
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting...");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/tb7300.js b/peripheral/libupm/examples/javascript/tb7300.js
deleted file mode 100644
index 8188a86..0000000
--- a/peripheral/libupm/examples/javascript/tb7300.js
+++ /dev/null
@@ -1,102 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-var sensorObj = require('jsupm_tb7300');
-
-
-/************** Main code **************/
-
-// You will need to edit this example to conform to your site and your
-// devices, specifically the Device Object Instance ID passed to the
-// constructor, and the arguments to initMaster() that are
-// appropriate for your BACnet network.
-
-var defaultDev = "/dev/ttyUSB0";
-
-// if an argument was specified, use it as the device instead
-if (process.argv.length > 2)
-{
- defaultDev = process.argv[2];
-}
-
-console.log("Using device " + defaultDev);
-console.log("Initializing...");
-
-// Instantiate an TB7300 object for an TB7300 device that has 73001
-// as it's unique Device Object Instance ID. NOTE: You will
-// certainly want to change this to the correct value for your
-// device(s).
-var sensor = new sensorObj.TB7300(73001);
-
-// Initialize our BACnet master, if it has not already been
-// initialized, with the device and baudrate, choosing 1000001 as
-// our unique Device Object Instance ID, 2 as our MAC address and
-// using default values for maxMaster and maxInfoFrames
-sensor.initMaster(defaultDev, 38400, 1000001, 2);
-
-// Uncomment to enable debugging output
-// sensor.setDebug(true);
-
-console.log("");
-console.log("Device Name:", sensor.getDeviceName());
-console.log("Device Description:", sensor.getDeviceDescription());
-console.log("Device Location:", sensor.getDeviceLocation());
-console.log("");
-
-console.log("Fan Mode:",
- sensor.getMultiStateValueText(sensorObj.TB7300.MV_Fan_Mode));
-console.log("Fan Status:",
- sensor.getMultiStateValueText(sensorObj.TB7300.MV_Fan_Status));
-console.log("System Mode:",
- sensor.getMultiStateValueText(sensorObj.TB7300.MV_System_Mode));
-console.log("Service Alarm:",
- sensor.getBinaryInputText(sensorObj.TB7300.BI_Service_Alarm));
-console.log("");
-
-// update and print the room temperature every 5 seconds
-setInterval(function()
-{
- // update our values
- sensor.update();
-
- // we show both C and F for temperature
- console.log("Temperature:", sensor.getTemperature(),
- "C /", sensor.getTemperature(true), "F");
- console.log("");
-
-}, 5000);
-
-
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting...");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/teams.js b/peripheral/libupm/examples/javascript/teams.js
deleted file mode 100644
index 5c5b883..0000000
--- a/peripheral/libupm/examples/javascript/teams.js
+++ /dev/null
@@ -1,70 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-var sensorObj = require('jsupm_teams');
-
-
-/************** Main code **************/
-
-console.log("Initializing...");
-
-// Instantiate an TEAMS instance, using A0 for temperature, and
-// 165.0 ohms for the rResistor value (for the libelium 4-20ma
-// interface)
-var sensor = new sensorObj.TEAMS(0, 165.0);
-
-// update and print available values every second
-setInterval(function()
-{
- // update our values from the sensor
- sensor.update();
-
- // is the sensor connected? (current >= 4ma)
- console.log("Is Connected:", sensor.isConnected());
-
- // print computed current on the loop. This includes the offset,
- // if one was set by setOffsetMilliamps().
- console.log("Milliamps:", sensor.getRawMilliamps());
-
- // we show both C and F for temperature
- console.log("Temperature:", sensor.getTemperature(),
- "C /", sensor.getTemperature(true), "F");
-
- console.log("");
-
-}, 1000);
-
-
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting...");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/tex00.js b/peripheral/libupm/examples/javascript/tex00.js
deleted file mode 100644
index 38b2b30..0000000
--- a/peripheral/libupm/examples/javascript/tex00.js
+++ /dev/null
@@ -1,77 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-var sensorObj = require('jsupm_tex00');
-
-
-/************** Main code **************/
-
-console.log("Initializing...");
-
-// Instantiate an TEX00 instance, using A0 for the analog input. In
-// this example, we are using a 10K Ohm balance resistor and a TED
-// (10k type 2) thermistor.
-var sensor = new sensorObj.TEX00(0, 10000,
- sensorObj.TEX00.STYPE_THERMISTOR_TED);
-
-console.log("Minimum temperature:", sensor.getTemperatureRangeMin(),
- "C");
-console.log("Maximum temperature:", sensor.getTemperatureRangeMax(),
- "C");
-console.log("");
-
-// update and print available values every second
-setInterval(function()
-{
- // update our values from the sensor
- sensor.update();
-
- if (sensor.isOutOfRange())
- {
- console.log("Temperature out of range");
- }
- else
- {
- // we show both C and F for temperature
- console.log("Temperature:", sensor.getTemperature(),
- "C /", sensor.getTemperature(true), "F");
- }
-
- console.log("");
-
-}, 1000);
-
-
-process.on('SIGINT', function()
-{
- sensor = null;
- sensorObj.cleanUp();
- sensorObj = null;
- console.log("Exiting...");
- process.exit(0);
-});
diff --git a/peripheral/libupm/examples/javascript/ublox6.js b/peripheral/libupm/examples/javascript/ublox6.js
index 50bad1a..d68640a 100644
--- a/peripheral/libupm/examples/javascript/ublox6.js
+++ b/peripheral/libupm/examples/javascript/ublox6.js
@@ -66,7 +66,7 @@ function getGPSInfo()
process.stdout.write(GPSData)
}
- if (rv < 0) // some sort of read error occurred
+ if (rv < 0) // some sort of read error occured
{
console.log("Port read error.");
process.exit(0);
diff --git a/peripheral/libupm/examples/javascript/vcap.js b/peripheral/libupm/examples/javascript/vcap.js
deleted file mode 100644
index d198b53..0000000
--- a/peripheral/libupm/examples/javascript/vcap.js
+++ /dev/null
@@ -1,69 +0,0 @@
-/*jslint node:true, vars:true, bitwise:true, unparam:true */
-/*jshint unused:true */
-
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-var sensorObj = require('jsupm_vcap');
-
-
-/************** Main code **************/
-
-var defaultDev = "/dev/video0";
-
-// if an argument was specified, use it as the device instead
-if (process.argv.length > 2)
-{
- defaultDev = process.argv[2];
-}
-
-console.log("Using device " + defaultDev);
-console.log("Initializing...");
-
-// Instantiate an VCAP instance, using the specified video device
-var sensor = new sensorObj.VCAP(defaultDev);
-
-// enable some debug/verbose output
-sensor.setDebug(true);
-
-// This is just a hint. The kernel can change this to a lower
-// resolution that the hardware supports. Use getWidth() and
-// getHeight() methods to see what the kernel actually chose if you
-// care.
-sensor.setResolution(1920, 1080);
-
-// capture an image
-sensor.captureImage();
-
-// convert and save it as a jpeg
-sensor.saveImage("video-img1.jpg");
-
-// make sure we clean up
-sensor = null;
-sensorObj.cleanUp();
-sensorObj = null;
-console.log("Exiting...");
-process.exit(0);
-
diff --git a/peripheral/libupm/examples/python/apa102.py b/peripheral/libupm/examples/python/apa102.py
deleted file mode 100644
index 721d4d4..0000000
--- a/peripheral/libupm/examples/python/apa102.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/python
-# Author: Yannick Adam <yannick.adam@gmail.com>
-# Copyright (c) 2016 Yannick Adam
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-
-import time, sys, signal, atexit
-import pyupm_apa102 as mylib
-
-# Instantiate a strip of 30 LEDs on SPI bus 0
-ledStrip = mylib.APA102(30, 0, False)
-
-## Exit handlers ##
-# This stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# Register exit handlers
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-print "Setting all LEDs to Green"
-ledStrip.setAllLeds(31, 0, 255, 0)
-
-print "Setting LEDs between 10 and 20 to Red"
-ledStrip.setLeds(10, 20, 31, 255, 0, 0)
-
-print "Setting LED 15 to Blue"
-ledStrip.setLed(15, 31, 0, 0, 255)
-
-
diff --git a/peripheral/libupm/examples/python/bma250e.py b/peripheral/libupm/examples/python/bma250e.py
deleted file mode 100644
index 051273c..0000000
--- a/peripheral/libupm/examples/python/bma250e.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_bmx055 as sensorObj
-
-# Instantiate a BMP250E instance using default i2c bus and address
-sensor = sensorObj.BMA250E()
-
-# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
-# BMA250E(0, -1, 10);
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting"
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-x = sensorObj.new_floatp()
-y = sensorObj.new_floatp()
-z = sensorObj.new_floatp()
-
-# now output data every 250 milliseconds
-while (1):
- sensor.update()
-
- sensor.getAccelerometer(x, y, z)
- print "Accelerometer x:", sensorObj.floatp_value(x),
- print " y:", sensorObj.floatp_value(y),
- print " z:", sensorObj.floatp_value(z),
- print " g"
-
- # we show both C and F for temperature
- print "Compensation Temperature:", sensor.getTemperature(), "C /",
- print sensor.getTemperature(True), "F"
-
- print
- time.sleep(.250)
diff --git a/peripheral/libupm/examples/python/bmc150.py b/peripheral/libupm/examples/python/bmc150.py
deleted file mode 100644
index efb1d99..0000000
--- a/peripheral/libupm/examples/python/bmc150.py
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_bmx055 as sensorObj
-
-# Instantiate a BMC150 instance using default i2c bus and address
-sensor = sensorObj.BMC150()
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting"
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-x = sensorObj.new_floatp()
-y = sensorObj.new_floatp()
-z = sensorObj.new_floatp()
-
-# now output data every 250 milliseconds
-while (1):
- sensor.update()
-
- sensor.getAccelerometer(x, y, z)
- print "Accelerometer x:", sensorObj.floatp_value(x),
- print " y:", sensorObj.floatp_value(y),
- print " z:", sensorObj.floatp_value(z),
- print " g"
-
- sensor.getMagnetometer(x, y, z)
- print "Magnetometer x:", sensorObj.floatp_value(x),
- print " y:", sensorObj.floatp_value(y),
- print " z:", sensorObj.floatp_value(z),
- print " uT"
-
- print
- time.sleep(.250)
diff --git a/peripheral/libupm/examples/python/bme280.py b/peripheral/libupm/examples/python/bme280.py
deleted file mode 100644
index 160a95a..0000000
--- a/peripheral/libupm/examples/python/bme280.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_bmp280 as sensorObj
-
-# Instantiate a BME280 instance using default i2c bus and address
-sensor = sensorObj.BME280()
-
-# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
-# BME280(0, -1, 10);
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting"
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-while (1):
- sensor.update()
-
- print "Compensation Temperature:", sensor.getTemperature(), "C /",
- print sensor.getTemperature(True), "F"
-
- print "Pressure: ", sensor.getPressure(), "Pa"
-
- print "Computed Altitude:", sensor.getAltitude(), "m"
-
- print "Humidity:", sensor.getHumidity(), "%RH"
-
- print
- time.sleep(1)
diff --git a/peripheral/libupm/examples/python/bmg160.py b/peripheral/libupm/examples/python/bmg160.py
deleted file mode 100644
index 112e3d6..0000000
--- a/peripheral/libupm/examples/python/bmg160.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_bmx055 as sensorObj
-
-# Instantiate a BMP250E instance using default i2c bus and address
-sensor = sensorObj.BMG160()
-
-# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
-# BMG160(0, -1, 10);
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting"
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-x = sensorObj.new_floatp()
-y = sensorObj.new_floatp()
-z = sensorObj.new_floatp()
-
-# now output data every 250 milliseconds
-while (1):
- sensor.update()
-
- sensor.getGyroscope(x, y, z)
- print "Gyroscope x:", sensorObj.floatp_value(x),
- print " y:", sensorObj.floatp_value(y),
- print " z:", sensorObj.floatp_value(z),
- print " degrees/s"
-
- # we show both C and F for temperature
- print "Compensation Temperature:", sensor.getTemperature(), "C /",
- print sensor.getTemperature(True), "F"
-
- print
- time.sleep(.250)
diff --git a/peripheral/libupm/examples/python/bmi055.py b/peripheral/libupm/examples/python/bmi055.py
deleted file mode 100644
index 96ddac2..0000000
--- a/peripheral/libupm/examples/python/bmi055.py
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_bmx055 as sensorObj
-
-# Instantiate a BMI055 instance using default i2c bus and address
-sensor = sensorObj.BMI055()
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting"
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-x = sensorObj.new_floatp()
-y = sensorObj.new_floatp()
-z = sensorObj.new_floatp()
-
-# now output data every 250 milliseconds
-while (1):
- sensor.update()
-
- sensor.getAccelerometer(x, y, z)
- print "Accelerometer x:", sensorObj.floatp_value(x),
- print " y:", sensorObj.floatp_value(y),
- print " z:", sensorObj.floatp_value(z),
- print " g"
-
- sensor.getGyroscope(x, y, z)
- print "Gyroscope x:", sensorObj.floatp_value(x),
- print " y:", sensorObj.floatp_value(y),
- print " z:", sensorObj.floatp_value(z),
- print " degrees/s"
-
- print
- time.sleep(.250)
diff --git a/peripheral/libupm/examples/python/bmi160.py b/peripheral/libupm/examples/python/bmi160.py
deleted file mode 100644
index f7e7aa1..0000000
--- a/peripheral/libupm/examples/python/bmi160.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_bmi160 as sensorObj
-
-# Instantiate a BMI160 instance using default i2c bus and address
-sensor = sensorObj.BMI160()
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting"
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-x = sensorObj.new_floatp()
-y = sensorObj.new_floatp()
-z = sensorObj.new_floatp()
-
-while (1):
- sensor.update()
- sensor.getAccelerometer(x, y, z)
- print "Accelerometer: AX: ", sensorObj.floatp_value(x),
- print " AY: ", sensorObj.floatp_value(y),
- print " AZ: ", sensorObj.floatp_value(z)
-
- sensor.getGyroscope(x, y, z)
- print "Gyroscope: GX: ", sensorObj.floatp_value(x),
- print " GY: ", sensorObj.floatp_value(y),
- print " GZ: ", sensorObj.floatp_value(z)
-
- sensor.getMagnetometer(x, y, z)
- print "Magnetometer: MX: ", sensorObj.floatp_value(x),
- print " MY: ", sensorObj.floatp_value(y),
- print " MZ: ", sensorObj.floatp_value(z)
-
- print
- time.sleep(.5)
diff --git a/peripheral/libupm/examples/python/bmm150.py b/peripheral/libupm/examples/python/bmm150.py
deleted file mode 100644
index 69f36bf..0000000
--- a/peripheral/libupm/examples/python/bmm150.py
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_bmx055 as sensorObj
-
-# Instantiate a BMP250E instance using default i2c bus and address
-sensor = sensorObj.BMM150()
-
-# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
-# BMM150(0, -1, 10);
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting"
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-x = sensorObj.new_floatp()
-y = sensorObj.new_floatp()
-z = sensorObj.new_floatp()
-
-# now output data every 250 milliseconds
-while (1):
- sensor.update()
-
- sensor.getMagnetometer(x, y, z)
- print "Magnetometer x:", sensorObj.floatp_value(x),
- print " y:", sensorObj.floatp_value(y),
- print " z:", sensorObj.floatp_value(z),
- print " uT"
-
- print
- time.sleep(.250)
diff --git a/peripheral/libupm/examples/python/bmp280.py b/peripheral/libupm/examples/python/bmp280.py
deleted file mode 100644
index 899e0a8..0000000
--- a/peripheral/libupm/examples/python/bmp280.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_bmp280 as sensorObj
-
-# Instantiate a BMP280 instance using default i2c bus and address
-sensor = sensorObj.BMP280()
-
-# For SPI, bus 0, you would pass -1 as the address, and a valid pin for CS:
-# BMP280(0, -1, 10);
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting"
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-while (1):
- sensor.update()
-
- print "Compensation Temperature:", sensor.getTemperature(), "C /",
- print sensor.getTemperature(True), "F"
-
- print "Pressure: ", sensor.getPressure(), "Pa"
-
- print "Computed Altitude:", sensor.getAltitude(), "m"
-
- print
- time.sleep(1)
diff --git a/peripheral/libupm/examples/python/bmx055.py b/peripheral/libupm/examples/python/bmx055.py
deleted file mode 100644
index 45012cf..0000000
--- a/peripheral/libupm/examples/python/bmx055.py
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_bmx055 as sensorObj
-
-# Instantiate a BMX055 instance using default i2c bus and address
-sensor = sensorObj.BMX055()
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting"
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-x = sensorObj.new_floatp()
-y = sensorObj.new_floatp()
-z = sensorObj.new_floatp()
-
-# now output data every 250 milliseconds
-while (1):
- sensor.update()
-
- sensor.getAccelerometer(x, y, z)
- print "Accelerometer x:", sensorObj.floatp_value(x),
- print " y:", sensorObj.floatp_value(y),
- print " z:", sensorObj.floatp_value(z),
- print " g"
-
- sensor.getGyroscope(x, y, z)
- print "Gyroscope x:", sensorObj.floatp_value(x),
- print " y:", sensorObj.floatp_value(y),
- print " z:", sensorObj.floatp_value(z),
- print " degrees/s"
-
- sensor.getMagnetometer(x, y, z)
- print "Magnetometer x:", sensorObj.floatp_value(x),
- print " y:", sensorObj.floatp_value(y),
- print " z:", sensorObj.floatp_value(z),
- print " uT"
-
- print
- time.sleep(.250)
diff --git a/peripheral/libupm/examples/python/bno055.py b/peripheral/libupm/examples/python/bno055.py
deleted file mode 100644
index 6e5a500..0000000
--- a/peripheral/libupm/examples/python/bno055.py
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_bno055 as sensorObj
-
-# Instantiate an BNO055 using default parameters (bus 0, addr
-# 0x28). The default running mode is NDOF absolute orientation
-# mode.
-sensor = sensorObj.BNO055()
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting..."
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-mag = sensorObj.new_intp()
-acc = sensorObj.new_intp()
-gyr = sensorObj.new_intp()
-syst = sensorObj.new_intp()
-
-w = sensorObj.new_floatp()
-x = sensorObj.new_floatp()
-y = sensorObj.new_floatp()
-z = sensorObj.new_floatp()
-
-print "First we need to calibrate. 4 numbers will be output every"
-print "second for each sensor. 0 means uncalibrated, and 3 means"
-print "fully calibrated."
-print "See the UPM documentation on this sensor for instructions on"
-print "what actions are required to calibrate."
-print
-
-while (not sensor.isFullyCalibrated()):
- sensor.getCalibrationStatus(mag, acc, gyr, syst)
- print "Magnetometer:", sensorObj.intp_value(mag),
- print " Accelerometer:", sensorObj.intp_value(acc),
- print " Gyroscope:", sensorObj.intp_value(gyr),
- print " System:", sensorObj.intp_value(syst),
- time.sleep(1)
-
-print
-print "Calibration complete."
-print
-
-# now output various fusion data every 250 milliseconds
-
-while (True):
- sensor.update()
-
- sensor.getEulerAngles(x, y, z)
- print "Euler: Heading:", sensorObj.floatp_value(x),
- print " Roll:", sensorObj.floatp_value(y),
- print " Pitch:", sensorObj.floatp_value(z),
- print " degrees"
-
- sensor.getQuaternions(w, x, y, z)
- print "Quaternion: W:", sensorObj.floatp_value(w),
- print " X:", sensorObj.floatp_value(x),
- print " Y:", sensorObj.floatp_value(y),
- print " Z:", sensorObj.floatp_value(z)
-
- sensor.getLinearAcceleration(x, y, z)
- print "Linear Acceleration: X:", sensorObj.floatp_value(x),
- print " Y:", sensorObj.floatp_value(y),
- print " Z:", sensorObj.floatp_value(z),
- print " m/s^2"
-
- sensor.getGravityVectors(x, y, z)
- print "Gravity Vector: X:", sensorObj.floatp_value(x),
- print " Y:", sensorObj.floatp_value(y),
- print " Z:", sensorObj.floatp_value(z),
- print " m/s^2"
-
- print
- time.sleep(.25);
diff --git a/peripheral/libupm/examples/python/curieimu.py b/peripheral/libupm/examples/python/curieimu.py
deleted file mode 100644
index 8596fef..0000000
--- a/peripheral/libupm/examples/python/curieimu.py
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/python
-
-# Author: Ron Evans (@deadprogram)
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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
-
-import mraa
-print (mraa.getVersion())
-
-# open connection to Firmata
-mraa.addSubplatform(mraa.GENERIC_FIRMATA, "/dev/ttyACM0")
-
-import time, sys, signal, atexit
-import pyupm_curieimu as curieimu
-sensor = curieimu.CurieImu()
-
-## Exit handlers ##
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-def exitHandler():
- print "Exiting"
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-
-while(1):
- sensor.updateAccel();
-
- outputStr = "acc: gX {0} - gY {1} - gZ {2}".format(
- sensor.getAccelX(), sensor.getAccelY(),
- sensor.getAccelZ())
- print outputStr
-
- time.sleep(1)
diff --git a/peripheral/libupm/examples/python/cwlsxxa.py b/peripheral/libupm/examples/python/cwlsxxa.py
deleted file mode 100644
index da73416..0000000
--- a/peripheral/libupm/examples/python/cwlsxxa.py
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_cwlsxxa as sensorObj
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting"
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-print "Initializing..."
-
-# Instantiate an CWLSXXA instance, using A0 for CO2, A1 for
-# humidity and A2 for temperature
-sensor = sensorObj.CWLSXXA(0, 1, 2)
-
-# update and print available values every second
-while (1):
- # update our values from the sensor
- sensor.update()
-
- # we show both C and F for temperature
- print "Temperature:", sensor.getTemperature(), "C /",
- print sensor.getTemperature(True), "F"
-
- print "Humidity:", sensor.getHumidity(), "%"
-
- print "CO2:", sensor.getCO2(), "ppm"
-
- print
- time.sleep(1)
diff --git a/peripheral/libupm/examples/python/ds18b20.py b/peripheral/libupm/examples/python/ds18b20.py
deleted file mode 100644
index d91d33c..0000000
--- a/peripheral/libupm/examples/python/ds18b20.py
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_ds18b20 as sensorObj
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting..."
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-print "Initializing..."
-
-# Instantiate an DS18B20 instance using the default values (uart 0)
-sensor = sensorObj.DS18B20(0)
-
-# locate and setup our devices
-sensor.init()
-
-print "Found", sensor.devicesFound(), "device(s)"
-print
-
-if (not sensor.devicesFound()):
- sys.exit(1);
-
-# update and print available values every second
-while (1):
- # update our values for the first sensor
- sensor.update(0)
-
- # we show both C and F for temperature for the first sensor
- print "Temperature:", sensor.getTemperature(0), "C /",
- print sensor.getTemperature(0, True), "F"
-
- time.sleep(1)
diff --git a/peripheral/libupm/examples/python/ds2413.py b/peripheral/libupm/examples/python/ds2413.py
deleted file mode 100644
index 2dc95d8..0000000
--- a/peripheral/libupm/examples/python/ds2413.py
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2015 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_ds2413 as sensorObj
-
-# Instantiate a DS2413 Module on a Dallas 1-wire bus connected to UART 0
-sensor = sensorObj.DS2413(0)
-
-## Exit handlers ##
-# This stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting..."
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-# find all of the DS2413 devices present on the bus
-sensor.init();
-
-# how many devices were found?
-print "Found", sensor.devicesFound(), "device(s)"
-
-# read the gpio and latch values from the first device
-# the lower 4 bits are of the form:
-# <gpioB latch> <gpioB value> <gpioA latch> <gpioA value>
-print "GPIO device 0 values:", sensor.readGpios(0)
-
-# set the gpio latch values of the first device
-print "Setting GPIO latches to on"
-sensor.writeGpios(0, 0x03);
diff --git a/peripheral/libupm/examples/python/e50hx.py b/peripheral/libupm/examples/python/e50hx.py
deleted file mode 100644
index a291001..0000000
--- a/peripheral/libupm/examples/python/e50hx.py
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_e50hx as sensorObj
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting..."
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-# You will need to edit this example to conform to your site and your
-# devices, specifically the Device Object Instance ID passed to the
-# constructor, and the arguments to initMaster() that are
-# appropriate for your BACnet network.
-
-defaultDev = "/dev/ttyUSB0"
-
-# if an argument was specified, use it as the device instead
-if (len(sys.argv) > 1):
- defaultDev = sys.argv[1]
-
-print "Using device", defaultDev
-print "Initializing..."
-
-# Instantiate an E50HX object for an E50HX device that has 1075425
-# as it's unique Device Object Instance ID. NOTE: You will
-# certainly want to change this to the correct value for your
-# device(s).
-sensor = sensorObj.E50HX(1075425)
-
-# Initialize our BACnet master, if it has not already been
-# initialized, with the device and baudrate, choosing 1000001 as
-# our unique Device Object Instance ID, 2 as our MAC address and
-# using default values for maxMaster and maxInfoFrames
-sensor.initMaster(defaultDev, 38400, 1000001, 2)
-
-# Uncomment to enable debugging output
-# sensor.setDebug(True);
-
-# output the serial number and firmware revision
-print
-print "Device Description:", sensor.getDeviceDescription()
-print "Device Location:", sensor.getDeviceLocation()
-print
-
-# update and print available values every second
-while (1):
- print "System Voltage:",
- print sensor.getAnalogValue(sensorObj.E50HX.AV_System_Voltage),
- print " ",
- print sensor.getAnalogValueUnits(sensorObj.E50HX.AV_System_Voltage)
-
- print "System Type:",
- print sensor.getAnalogValue(sensorObj.E50HX.AV_System_Type)
-
- print "Energy Consumption:",
- print sensor.getAnalogInput(sensorObj.E50HX.AI_Energy),
- print " ",
- print sensor.getAnalogInputUnits(sensorObj.E50HX.AI_Energy)
-
- print "Power Up Counter:",
- print sensor.getAnalogInput(sensorObj.E50HX.AI_Power_Up_Count)
-
- print
- time.sleep(5)
diff --git a/peripheral/libupm/examples/python/h803x.py b/peripheral/libupm/examples/python/h803x.py
deleted file mode 100644
index 4e950e0..0000000
--- a/peripheral/libupm/examples/python/h803x.py
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_h803x as sensorObj
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting..."
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-defaultDev = "/dev/ttyUSB0"
-
-# if an argument was specified, use it as the device instead
-if (len(sys.argv) > 1):
- defaultDev = sys.argv[1]
-
-print "Using device", defaultDev
-print "Initializing..."
-
-# Instantiate an H803X instance, using MODBUS slave address 1, and
-# default comm parameters (9600, 8, N, 2)
-sensor = sensorObj.H803X(defaultDev, 1)
-
-# output the serial number and firmware revision
-print "Slave ID:", sensor.getSlaveID()
-
-print
-
-# update and print available values every second
-while (1):
- # update our values from the sensor
- sensor.update()
-
- # H8035 / H8036
- print "Consumption (kWh):", sensor.getConsumption()
- print "Real Power (kW):", sensor.getRealPower()
-
- if (sensor.isH8036()):
- # The H8036 has much more data available...
-
- print "Reactive Power (kVAR):", sensor.getReactivePower()
- print "Apparent Power (kVA):", sensor.getApparentPower()
- print "Power Factor:", sensor.getPowerFactor()
- print "Volts Line to Line:", sensor.getVoltsLineToLine()
- print "Volts Line to Neutral:", sensor.getVoltsLineToNeutral()
-
- print "Current:", sensor.getCurrent()
-
- print "Real Power Phase A (kW):", sensor.getRealPowerPhaseA()
- print "Real Power Phase B (kW):", sensor.getRealPowerPhaseB()
- print "Real Power Phase C (kW):", sensor.getRealPowerPhaseC()
-
- print "Power Factor Phase A:", sensor.getPowerFactorPhaseA()
- print "Power Factor Phase B:", sensor.getPowerFactorPhaseB()
- print "Power Factor Phase C:", sensor.getPowerFactorPhaseC()
-
- print "Volts Phase A to B:", sensor.getVoltsPhaseAToB()
- print "Volts Phase B to C:", sensor.getVoltsPhaseBToC()
- print "Volts Phase A to C:", sensor.getVoltsPhaseAToC()
- print "Volts Phase A to Neutral: ",
- print sensor.getVoltsPhaseAToNeutral()
- print "Volts Phase B to Neutral: ",
- print sensor.getVoltsPhaseBToNeutral()
- print "Volts Phase C to Neutral: ",
- print sensor.getVoltsPhaseCToNeutral()
-
- print "Current Phase A:", sensor.getCurrentPhaseA()
- print "Current Phase B:", sensor.getCurrentPhaseB()
- print "Current Phase C:", sensor.getCurrentPhaseC()
-
- print "Avg Real Power (kW):", sensor.getAvgRealPower()
- print "Min Real Power (kW):", sensor.getMinRealPower()
- print "Max Real Power (kW):", sensor.getMaxRealPower()
-
- print
- time.sleep(2)
diff --git a/peripheral/libupm/examples/python/hmtrp.py b/peripheral/libupm/examples/python/hmtrp.py
index 9b8fe19..dd2298f 100644
--- a/peripheral/libupm/examples/python/hmtrp.py
+++ b/peripheral/libupm/examples/python/hmtrp.py
@@ -123,7 +123,7 @@ else:
resultStr += radioBuffer.__getitem__(x)
print "Received:", resultStr
- if (rv < 0): # some sort of read error occurred
+ if (rv < 0): # some sort of read error occured
print "Port read error."
sys.exit(0)
myCounter += 1
diff --git a/peripheral/libupm/examples/python/t8100.py b/peripheral/libupm/examples/python/t8100.py
deleted file mode 100644
index 2f14651..0000000
--- a/peripheral/libupm/examples/python/t8100.py
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_t8100 as sensorObj
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting..."
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-# You will need to edit this example to conform to your site and your
-# devices, specifically the Device Object Instance ID passed to the
-# constructor, and the arguments to initMaster() that are
-# appropriate for your BACnet network.
-
-defaultDev = "/dev/ttyUSB0"
-
-# if an argument was specified, use it as the device instead
-if (len(sys.argv) > 1):
- defaultDev = sys.argv[1]
-
-print "Using device", defaultDev
-print "Initializing..."
-
-# Instantiate an T8100 object for an T8100 device that has 568000
-# as it's unique Device Object Instance ID. NOTE: You will
-# certainly want to change this to the correct value for your
-# device(s).
-sensor = sensorObj.T8100(568000)
-
-# Initialize our BACnet master, if it has not already been
-# initialized, with the device and baudrate, choosing 1000001 as
-# our unique Device Object Instance ID, 2 as our MAC address and
-# using default values for maxMaster and maxInfoFrames
-sensor.initMaster(defaultDev, 38400, 1000001, 2)
-
-# Uncomment to enable debugging output
-# sensor.setDebug(True);
-
-# output the serial number and firmware revision
-print
-print "Device Description:", sensor.getDeviceDescription()
-print "Device Location:", sensor.getDeviceLocation()
-print
-
-# update and print available values every 5 seconds
-while (1):
- # update our values
- sensor.update();
-
- print "CO2 Concentration:",
- print sensor.getCO2(),
- print "ppm"
-
- # we show both C and F for temperature
- print "Temperature:", sensor.getTemperature(),
- print "C /", sensor.getTemperature(True), "F"
-
- print "Humidity:",
- print sensor.getHumidity(),
- print "%RH"
-
- print "Relay State:",
- print sensor.getRelayState()
-
- print
- time.sleep(5)
diff --git a/peripheral/libupm/examples/python/tb7300.py b/peripheral/libupm/examples/python/tb7300.py
deleted file mode 100644
index 93e879d..0000000
--- a/peripheral/libupm/examples/python/tb7300.py
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_tb7300 as sensorObj
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting..."
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-# You will need to edit this example to conform to your site and your
-# devices, specifically the Device Object Instance ID passed to the
-# constructor, and the arguments to initMaster() that are
-# appropriate for your BACnet network.
-
-defaultDev = "/dev/ttyUSB0"
-
-# if an argument was specified, use it as the device instead
-if (len(sys.argv) > 1):
- defaultDev = sys.argv[1]
-
-print "Using device", defaultDev
-print "Initializing..."
-
-# Instantiate an TB7300 object for an TB7300 device that has 73001
-# as it's unique Device Object Instance ID. NOTE: You will
-# certainly want to change this to the correct value for your
-# device(s).
-sensor = sensorObj.TB7300(73001)
-
-# Initialize our BACnet master, if it has not already been
-# initialized, with the device and baudrate, choosing 1000001 as
-# our unique Device Object Instance ID, 2 as our MAC address and
-# using default values for maxMaster and maxInfoFrames
-sensor.initMaster(defaultDev, 38400, 1000001, 2)
-
-# Uncomment to enable debugging output
-# sensor.setDebug(True);
-
-# output the serial number and firmware revision
-print
-print "Device Name:", sensor.getDeviceName()
-print "Device Description:", sensor.getDeviceDescription()
-print "Device Location:", sensor.getDeviceLocation()
-print
-
-print "Fan Mode:", sensor.getMultiStateValueText(sensorObj.TB7300.MV_Fan_Mode)
-print "Fan Status:",
-print sensor.getMultiStateValueText(sensorObj.TB7300.MV_Fan_Status)
-print "System Mode:",
-print sensor.getMultiStateValueText(sensorObj.TB7300.MV_System_Mode)
-print "Service Alarm:",
-print sensor.getBinaryInputText(sensorObj.TB7300.BI_Service_Alarm)
-print
-
-# update and print the room temperature every 5 seconds
-while (1):
- # update our values
- sensor.update();
-
- # we show both C and F for temperature
- print "Temperature:", sensor.getTemperature(),
- print "C /", sensor.getTemperature(True), "F"
-
- print
- time.sleep(5)
diff --git a/peripheral/libupm/examples/python/teams.py b/peripheral/libupm/examples/python/teams.py
deleted file mode 100644
index 8acfa09..0000000
--- a/peripheral/libupm/examples/python/teams.py
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_teams as sensorObj
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting"
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-print "Initializing..."
-
-# Instantiate an TEAMS instance, using A0 for temperature, and
-# 165.0 ohms for the rResistor value (for the libelium 4-20ma
-# interface)
-sensor = sensorObj.TEAMS(0, 165.0)
-
-# update and print available values every second
-while (1):
- # update our values from the sensor
- sensor.update()
-
- # is the sensor connected? (current >= 4ma)
- print "Is Connected:", sensor.isConnected()
-
- # print computed current on the loop. This includes the offset,
- # if one was set by setOffsetMilliamps().
- print "Milliamps:", sensor.getRawMilliamps()
-
- # we show both C and F for temperature
- print "Temperature:", sensor.getTemperature(), "C /",
- print sensor.getTemperature(True), "F"
-
- print
- time.sleep(1)
diff --git a/peripheral/libupm/examples/python/tex00.py b/peripheral/libupm/examples/python/tex00.py
deleted file mode 100644
index da42796..0000000
--- a/peripheral/libupm/examples/python/tex00.py
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_tex00 as sensorObj
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting"
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-print "Initializing..."
-
-# Instantiate an TEX00 instance, using A0 for the analog input. In
-# this example, we are using a 10K Ohm balance resistor and a TED
-# (10k type 2) thermistor.
-sensor = sensorObj.TEX00(0, 10000, sensorObj.TEX00.STYPE_THERMISTOR_TED)
-
-print "Minimum temperature:", sensor.getTemperatureRangeMin(), "C"
-print "Maximum temperature:", sensor.getTemperatureRangeMax(), "C"
-print
-
-# update and print available values every second
-while (1):
- # update our values from the sensor
- sensor.update()
-
- if (sensor.isOutOfRange()):
- print "Temperature out of range"
- else:
- # we show both C and F for temperature
- print "Temperature:", sensor.getTemperature(), "C /",
- print sensor.getTemperature(True), "F"
-
- print
- time.sleep(1)
diff --git a/peripheral/libupm/examples/python/ublox6.py b/peripheral/libupm/examples/python/ublox6.py
index c2e0322..bb98d2b 100644
--- a/peripheral/libupm/examples/python/ublox6.py
+++ b/peripheral/libupm/examples/python/ublox6.py
@@ -73,7 +73,7 @@ def getGPSInfo():
GPSData += nmeaBuffer.__getitem__(x)
sys.stdout.write(GPSData)
- if (rv < 0): # some sort of read error occurred
+ if (rv < 0): # some sort of read error occured
print "Port read error."
sys.exit(0)
diff --git a/peripheral/libupm/examples/python/vcap.py b/peripheral/libupm/examples/python/vcap.py
deleted file mode 100644
index dfd23a4..0000000
--- a/peripheral/libupm/examples/python/vcap.py
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/python
-# Author: Jon Trulson <jtrulson@ics.com>
-# Copyright (c) 2016 Intel Corporation.
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be
-# included in all copies or substantial portions of the Software.
-#
-# 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.
-
-import time, sys, signal, atexit
-import pyupm_vcap as sensorObj
-
-## Exit handlers ##
-# This function stops python from printing a stacktrace when you hit control-C
-def SIGINTHandler(signum, frame):
- raise SystemExit
-
-# This function lets you run code on exit
-def exitHandler():
- print "Exiting..."
- sys.exit(0)
-
-# Register exit handlers
-atexit.register(exitHandler)
-signal.signal(signal.SIGINT, SIGINTHandler)
-
-defaultDev = "/dev/video0"
-
-# if an argument was specified, use it as the device instead
-if (len(sys.argv) > 1):
- defaultDev = sys.argv[1]
-
-print "Using device", defaultDev
-print "Initializing..."
-
-# Instantiate an VCAP instance, using the specified video device
-sensor = sensorObj.VCAP(defaultDev)
-
-# enable some debug/verbose output
-sensor.setDebug(True);
-
-# This is just a hint. The kernel can change this to a lower
-# resolution that the hardware supports. Use getWidth() and
-# getHeight() methods to see what the kernel actually chose if you
-# care.
-sensor.setResolution(1920, 1080);
-
-# capture an image
-sensor.captureImage();
-
-# convert and save it as a jpeg
-sensor.saveImage("video-img1.jpg");
-
diff --git a/peripheral/libupm/src/CMakeLists.txt b/peripheral/libupm/src/CMakeLists.txt
index b9a85a0..5c0fa85 100644
--- a/peripheral/libupm/src/CMakeLists.txt
+++ b/peripheral/libupm/src/CMakeLists.txt
@@ -28,11 +28,6 @@ endmacro (upm_CREATE_INSTALL_PKGCONFIG)
macro(upm_SWIG_PYTHON)
if (BUILDSWIGPYTHON AND BUILDSWIG)
-
- include_directories (
- ${CMAKE_CURRENT_SOURCE_DIR}/..
- )
-
set_source_files_properties (pyupm_${libname}.i PROPERTIES CPLUSPLUS ON)
set_source_files_properties (pyupm_${libname}.i PROPERTIES SWIG_FLAGS "-I${CMAKE_CURRENT_BINARY_DIR}/..")
swig_add_module (pyupm_${libname} python pyupm_${libname}.i ${module_src})
@@ -44,39 +39,23 @@ macro(upm_SWIG_PYTHON)
)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/_pyupm_${libname}.so
${CMAKE_CURRENT_BINARY_DIR}/pyupm_${libname}.py
- DESTINATION ${LIB_INSTALL_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/
COMPONENT ${libname})
endif()
endmacro()
macro(upm_SWIG_NODE)
if (BUILDSWIGNODE AND BUILDSWIG)
- # SWIG treats SWIG_FLAGS as a list and not a string so semicolon seperation is
- # required. This hardcodes V8_VERSION to be <10 but I assume that's not going
- # to be a problem for a little while! SWIG uses a padded SWIG_V8 version which
- # we hack together from our findnode module.
- set (V8_VERSION_HEX 0x0${V8_VERSION_MAJOR}${V8_VERSION_MINOR}${V8_VERSION_PATCH})
- string (LENGTH "${V8_VERSION_HEX}" V8_VERSION_HEX_length)
- while (V8_VERSION_HEX_length LESS 8)
- set (V8_VERSION_HEX "${V8_VERSION_HEX}0")
- string (LENGTH "${V8_VERSION_HEX}" V8_VERSION_HEX_length)
- endwhile ()
-
- include_directories (
- ${CMAKE_CURRENT_SOURCE_DIR}/..
- )
-
- set_property (SOURCE jsupm_${libname}.i PROPERTY SWIG_FLAGS "-node" "-DV8_VERSION=${V8_VERSION_HEX}")
set_source_files_properties (jsupm_${libname}.i PROPERTIES CPLUSPLUS ON)
+ set_source_files_properties (jsupm_${libname}.i PROPERTIES SWIG_FLAGS "-node")
swig_add_module (jsupm_${libname} javascript jsupm_${libname}.i ${module_src})
swig_link_libraries (jsupm_${libname} ${MRAA_LIBRARIES} ${NODE_LIBRARIES})
target_include_directories ( ${SWIG_MODULE_jsupm_${libname}_REAL_NAME}
PUBLIC
"${NODE_INCLUDE_DIRS}"
- )
-
+ )
set_target_properties (jsupm_${libname} PROPERTIES
- COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -DBUILDING_NODE_EXTENSION -DSWIG_V8_VERSION=${V8_VERSION_HEX}"
+ COMPILE_FLAGS "${CMAKE_CXX_FLAGS} -DBUILDING_NODE_EXTENSION -DSWIG_V8_VERSION=0x0${V8_DEFINE_STRING}"
PREFIX ""
SUFFIX ".node"
)
@@ -86,28 +65,12 @@ macro(upm_SWIG_NODE)
message(FATAL_ERROR " **ERROR** GCC 4.7 or above is required to compile jsupm_${libname} ")
endif()
endif()
-
- if (NOT ENABLECXX11)
- set_property (TARGET jsupm_${libname} PROPERTY CXX_STANDARD 11)
- set_property (TARGET jsupm_${libname} PROPERTY CXX_STANDARD_REQUIRED ON)
-
- if (CMAKE_VERSION VERSION_LESS "3.1")
- if (CMAKE_COMPILER_IS_GNUCXX)
- if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
- message (FATAL_ERROR " FATAL ERROR: GNU gcc compiler is also too old (need 4.7+, but ${CMAKE_CXX_COMPILER_VERSION}) and does not support C++11 standard.")
- endif ()
- set (UPM_CXX11_WORKAROUND_OPTION "-std=gnu++11")
- else ()
- set (UPM_CXX11_WORKAROUND_OPTION "-std=c++11")
- endif ()
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${UPM_CXX11_WORKAROUND_OPTION} ")
- endif ()
- endif ()
-
+ set_property (TARGET jsupm_${libname} PROPERTY CXX_STANDARD 11)
+ set_property (TARGET jsupm_${libname} PROPERTY CXX_STANDARD_REQUIRED ON)
endif()
createpackagejson(${libname})
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/jsupm_${libname}.node
- DESTINATION ${NODE_MODULE_INSTALL_PATH} COMPONENT ${libname})
+ DESTINATION lib/node_modules/jsupm_${libname} COMPONENT ${libname})
endif()
endmacro()
@@ -126,7 +89,7 @@ macro(upm_SWIG_JAVA)
set_source_files_properties (javaupm_${libname}.i PROPERTIES CPLUSPLUS ON)
set_source_files_properties (javaupm_${libname}.i PROPERTIES SWIG_FLAGS ";-package;upm_${libname};-I${CMAKE_BINARY_DIR}/src")
swig_add_module (javaupm_${libname} java javaupm_${libname}.i ${module_src})
- swig_link_libraries (javaupm_${libname} ${MRAAJAVA_LIBRARIES} ${MRAA_LIBRARIES} ${JAVA_LIBRARIES})
+ swig_link_libraries (javaupm_${libname} ${MRAAJAVA_LDFLAGS} ${JAVA_LDFLAGS})
target_include_directories ( ${SWIG_MODULE_javaupm_${libname}_REAL_NAME}
PUBLIC
"${JAVA_INCLUDE_DIRS}"
@@ -137,8 +100,8 @@ macro(upm_SWIG_JAVA)
PREFIX "lib"
SUFFIX ".so"
)
- install (TARGETS javaupm_${libname} LIBRARY DESTINATION ${LIB_INSTALL_DIR})
- install (FILES ${CMAKE_CURRENT_BINARY_DIR}/upm_${libname}.jar DESTINATION ${LIB_INSTALL_DIR}/../lib/java)
+ install (TARGETS javaupm_${libname} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install (FILES ${CMAKE_CURRENT_BINARY_DIR}/upm_${libname}.jar DESTINATION ${CMAKE_INSTALL_LIBDIR}/../lib/java)
if (NOT DEFINED $ENV{JAVA_HOME_NATIVE})
set (JAVAC $ENV{JAVA_HOME}/bin/javac)
@@ -166,7 +129,7 @@ macro(upm_doxygen)
set (classname ${libname})
endif()
set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
- if (BUILDSWIGPYTHON AND BUILDSWIG)
+ if (BUILDSWIG)
add_dependencies (_pyupm_${libname} pyupm_doxy2swig)
add_dependencies (pydoc _pyupm_${libname})
else ()
@@ -176,44 +139,34 @@ macro(upm_doxygen)
endmacro()
if (SWIG_FOUND)
- if (BUILDSWIGPYTHON)
- if(NOT PYTHONLIBS_FOUND)
- find_package (PythonInterp ${PYTHONBUILD_VERSION} REQUIRED)
- find_package (PythonLibs ${PYTHONBUILD_VERSION} REQUIRED)
- string (REPLACE "." ";" PYTHON_VERSION_LIST ${PYTHONLIBS_VERSION_STRING})
- list (GET PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR)
- list (GET PYTHON_VERSION_LIST 1 PYTHON_VERSION_MINOR)
- endif()
+ if(BUILDSWIGPYTHON)
+ find_package (PythonLibs)
+ string (REPLACE "." ";" PYTHON_VERSION_LIST ${PYTHONLIBS_VERSION_STRING})
+ list (GET PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR)
+ list (GET PYTHON_VERSION_LIST 1 PYTHON_VERSION_MINOR)
endif(BUILDSWIGPYTHON)
- if (BUILDSWIGNODE)
+ if(BUILDSWIGNODE)
if(NOT NODE_FOUND)
find_package(Node)
endif()
if(SWIG_VERSION VERSION_LESS 3.0.5 AND NODE_VERSION_STRING VERSION_GREATER 0.12)
message("WARNING - SWIG 3.0.5+ required for building with nodejs 0.12. Current version is ${SWIG_VERSION}")
endif()
- find_path (NODE_ROOT_DIR "include/node/node.h")
+ find_path (NODE_ROOT_DIR "node/node.h")
set (NODE_INCLUDE_DIRS
- ${NODE_ROOT_DIR}/include/src
- ${NODE_ROOT_DIR}/include/node
- ${NODE_ROOT_DIR}/include/deps/v8/include
- ${NODE_ROOT_DIR}/include/deps/uv/include
+ ${NODE_ROOT_DIR}/src
+ ${NODE_ROOT_DIR}/node
+ ${NODE_ROOT_DIR}/deps/v8/include
+ ${NODE_ROOT_DIR}/deps/uv/include
)
macro(createpackagejson)
- configure_file (${PROJECT_SOURCE_DIR}/src/package.json.in ${CMAKE_CURRENT_BINARY_DIR}/package.json @ONLY)
- # If a CMAKE_INSTALL_PREFIX has NOT been provided, set NODE_MODULE_INSTALL_PATH
- # base on the NODE_ROOT_DIR.
- if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
- set (NODE_MODULE_INSTALL_PATH ${NODE_ROOT_DIR}/lib/node_modules/jsupm_${libname}/)
- # If a CMAKE_INSTALL_PREFIX has been provided, set NODE_MODULE_INSTALL_PATH
- # relative to the provided install directory.
- else ()
- set (NODE_MODULE_INSTALL_PATH ${CMAKE_INSTALL_PREFIX}/lib/node_modules/jsupm_${libname}/)
- endif ()
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/package.json
- DESTINATION ${NODE_MODULE_INSTALL_PATH} COMPONENT ${libname})
+ configure_file (${PROJECT_SOURCE_DIR}/src/package.json.in ${CMAKE_CURRENT_BINARY_DIR}/package.json @ONLY)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/package.json
+ DESTINATION lib/node_modules/jsupm_${libname} COMPONENT ${libname})
endmacro()
+
endif(BUILDSWIGNODE)
+
endif()
macro(upm_module_init)
@@ -222,7 +175,7 @@ macro(upm_module_init)
foreach (linkflag ${ARGN})
target_link_libraries (${libname} ${linkflag})
endforeach ()
- include_directories (${MRAA_INCLUDE_DIRS} . ..)
+ include_directories (${MRAA_INCLUDE_DIRS} .)
target_link_libraries (${libname} ${MRAA_LIBRARIES})
set_target_properties(
${libname}
@@ -230,7 +183,7 @@ macro(upm_module_init)
SOVERSION ${upm_VERSION_MAJOR}
VERSION ${upm_VERSION_STRING}
)
- upm_create_install_pkgconfig (upm-${libname}.pc ${LIB_INSTALL_DIR}/pkgconfig)
+ upm_create_install_pkgconfig (upm-${libname}.pc ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
if (SWIG_FOUND)
if (NOT ";${PYTHONSWIG_BLACKLIST};" MATCHES ";${libname};")
upm_swig_python()
@@ -245,8 +198,8 @@ macro(upm_module_init)
if (BUILDDOC)
upm_doxygen()
endif()
- install(TARGETS ${libname} DESTINATION ${LIB_INSTALL_DIR})
- install (FILES ${module_hpp} DESTINATION include/upm COMPONENT ${libname})
+ install(TARGETS ${libname} DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install (FILES ${module_h} DESTINATION include/upm COMPONENT ${libname})
if (IPK)
cpack_add_component (${libname} DISPLAY_NAME ${libname} REQUIRED INSTALL_TYPES all)
diff --git a/peripheral/libupm/src/a110x/CMakeLists.txt b/peripheral/libupm/src/a110x/CMakeLists.txt
index 844846f..f649239 100644
--- a/peripheral/libupm/src/a110x/CMakeLists.txt
+++ b/peripheral/libupm/src/a110x/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "a110x")
set (libdescription "upm a110x sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/a110x/a110x.cxx b/peripheral/libupm/src/a110x/a110x.cxx
index f605865..9023091 100644
--- a/peripheral/libupm/src/a110x/a110x.cxx
+++ b/peripheral/libupm/src/a110x/a110x.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "a110x.hpp"
+#include "a110x.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/a110x/a110x.hpp b/peripheral/libupm/src/a110x/a110x.h
index d833a37..d833a37 100644
--- a/peripheral/libupm/src/a110x/a110x.hpp
+++ b/peripheral/libupm/src/a110x/a110x.h
diff --git a/peripheral/libupm/src/a110x/javaupm_a110x.i b/peripheral/libupm/src/a110x/javaupm_a110x.i
index 4e55872..ca9cb37 100644
--- a/peripheral/libupm/src/a110x/javaupm_a110x.i
+++ b/peripheral/libupm/src/a110x/javaupm_a110x.i
@@ -4,9 +4,9 @@
%include "typemaps.i"
%{
- #include "a110x.hpp"
+ #include "a110x.h"
%}
-%include "a110x.hpp"
+%include "a110x.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/a110x/jsupm_a110x.i b/peripheral/libupm/src/a110x/jsupm_a110x.i
index f6a5305..1aa7916 100644
--- a/peripheral/libupm/src/a110x/jsupm_a110x.i
+++ b/peripheral/libupm/src/a110x/jsupm_a110x.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "a110x.hpp"
+ #include "a110x.h"
%}
-%include "a110x.hpp"
+%include "a110x.h"
diff --git a/peripheral/libupm/src/a110x/pyupm_a110x.i b/peripheral/libupm/src/a110x/pyupm_a110x.i
index dd90cef..9eeabdb 100644
--- a/peripheral/libupm/src/a110x/pyupm_a110x.i
+++ b/peripheral/libupm/src/a110x/pyupm_a110x.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "a110x.hpp"
+%include "a110x.h"
%{
- #include "a110x.hpp"
+ #include "a110x.h"
%}
diff --git a/peripheral/libupm/src/ad8232/CMakeLists.txt b/peripheral/libupm/src/ad8232/CMakeLists.txt
index 8c04807..0a57240 100644
--- a/peripheral/libupm/src/ad8232/CMakeLists.txt
+++ b/peripheral/libupm/src/ad8232/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "ad8232")
set (libdescription "upm ad8232 heart rate monitor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/ad8232/ad8232.cxx b/peripheral/libupm/src/ad8232/ad8232.cxx
index de8d650..35612ae 100644
--- a/peripheral/libupm/src/ad8232/ad8232.cxx
+++ b/peripheral/libupm/src/ad8232/ad8232.cxx
@@ -24,7 +24,7 @@
#include <iostream>
-#include "ad8232.hpp"
+#include "ad8232.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/ad8232/ad8232.hpp b/peripheral/libupm/src/ad8232/ad8232.h
index f4eaf7e..f4eaf7e 100644
--- a/peripheral/libupm/src/ad8232/ad8232.hpp
+++ b/peripheral/libupm/src/ad8232/ad8232.h
diff --git a/peripheral/libupm/src/ad8232/javaupm_ad8232.i b/peripheral/libupm/src/ad8232/javaupm_ad8232.i
index 5b90bbe..391f1cf 100644
--- a/peripheral/libupm/src/ad8232/javaupm_ad8232.i
+++ b/peripheral/libupm/src/ad8232/javaupm_ad8232.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "ad8232.hpp"
+ #include "ad8232.h"
%}
-%include "ad8232.hpp"
+%include "ad8232.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/ad8232/jsupm_ad8232.i b/peripheral/libupm/src/ad8232/jsupm_ad8232.i
index 63490da..e2fe8d8 100644
--- a/peripheral/libupm/src/ad8232/jsupm_ad8232.i
+++ b/peripheral/libupm/src/ad8232/jsupm_ad8232.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "ad8232.hpp"
+ #include "ad8232.h"
%}
-%include "ad8232.hpp"
+%include "ad8232.h"
diff --git a/peripheral/libupm/src/ad8232/pyupm_ad8232.i b/peripheral/libupm/src/ad8232/pyupm_ad8232.i
index db748c6..46abb7d 100644
--- a/peripheral/libupm/src/ad8232/pyupm_ad8232.i
+++ b/peripheral/libupm/src/ad8232/pyupm_ad8232.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "ad8232.hpp"
+%include "ad8232.h"
%{
- #include "ad8232.hpp"
+ #include "ad8232.h"
%}
diff --git a/peripheral/libupm/src/adafruitms1438/CMakeLists.txt b/peripheral/libupm/src/adafruitms1438/CMakeLists.txt
index 34433e2..d3da7e7 100644
--- a/peripheral/libupm/src/adafruitms1438/CMakeLists.txt
+++ b/peripheral/libupm/src/adafruitms1438/CMakeLists.txt
@@ -1,7 +1,7 @@
set (libname "adafruitms1438")
set (libdescription "upm module for the Adafruit Motor Shield 1438")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
set (reqlibname "upm-pca9685")
include_directories("../pca9685")
upm_module_init()
@@ -10,10 +10,10 @@ target_link_libraries(${libname} pca9685)
if (BUILDSWIG)
if (BUILDSWIGNODE)
set_target_properties(${SWIG_MODULE_jsupm_${libname}_REAL_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE)
- swig_link_libraries (jsupm_${libname} pca9685)
+ swig_link_libraries (jsupm_${libname} pca9685 ${MRAA_LIBRARIES} ${NODE_LIBRARIES})
endif()
if (BUILDSWIGPYTHON)
set_target_properties(${SWIG_MODULE_pyupm_${libname}_REAL_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE)
- swig_link_libraries (pyupm_${libname} pca9685)
+ swig_link_libraries (pyupm_${libname} pca9685 ${PYTHON_LIBRARIES} ${MRAA_LIBRARIES})
endif()
endif()
diff --git a/peripheral/libupm/src/adafruitms1438/adafruitms1438.cxx b/peripheral/libupm/src/adafruitms1438/adafruitms1438.cxx
index 5435219..f1475d4 100644
--- a/peripheral/libupm/src/adafruitms1438/adafruitms1438.cxx
+++ b/peripheral/libupm/src/adafruitms1438/adafruitms1438.cxx
@@ -27,7 +27,7 @@
#include <iostream>
#include <string>
-#include "adafruitms1438.hpp"
+#include "adafruitms1438.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/adafruitms1438/adafruitms1438.hpp b/peripheral/libupm/src/adafruitms1438/adafruitms1438.h
index 05c4326..1f00ac9 100644
--- a/peripheral/libupm/src/adafruitms1438/adafruitms1438.hpp
+++ b/peripheral/libupm/src/adafruitms1438/adafruitms1438.h
@@ -30,7 +30,7 @@
#include <mraa/i2c.h>
#include <mraa/gpio.h>
-#include "pca9685.hpp"
+#include "pca9685.h"
#define ADAFRUITMS1438_I2C_BUS 0
#define ADAFRUITMS1438_DEFAULT_I2C_ADDR 0x60
diff --git a/peripheral/libupm/src/adafruitms1438/javaupm_adafruitms1438.i b/peripheral/libupm/src/adafruitms1438/javaupm_adafruitms1438.i
index b29b20c..a02306c 100644
--- a/peripheral/libupm/src/adafruitms1438/javaupm_adafruitms1438.i
+++ b/peripheral/libupm/src/adafruitms1438/javaupm_adafruitms1438.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "adafruitms1438.hpp"
+ #include "adafruitms1438.h"
%}
-%include "adafruitms1438.hpp"
+%include "adafruitms1438.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/adafruitms1438/jsupm_adafruitms1438.i b/peripheral/libupm/src/adafruitms1438/jsupm_adafruitms1438.i
index f06f2b5..69060e5 100644
--- a/peripheral/libupm/src/adafruitms1438/jsupm_adafruitms1438.i
+++ b/peripheral/libupm/src/adafruitms1438/jsupm_adafruitms1438.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "adafruitms1438.hpp"
+ #include "adafruitms1438.h"
%}
-%include "adafruitms1438.hpp"
+%include "adafruitms1438.h"
diff --git a/peripheral/libupm/src/adafruitms1438/pyupm_adafruitms1438.i b/peripheral/libupm/src/adafruitms1438/pyupm_adafruitms1438.i
index 42fc140..812311a 100644
--- a/peripheral/libupm/src/adafruitms1438/pyupm_adafruitms1438.i
+++ b/peripheral/libupm/src/adafruitms1438/pyupm_adafruitms1438.i
@@ -9,7 +9,7 @@
%include "adafruitms1438_doc.i"
#endif
-%include "adafruitms1438.hpp"
+%include "adafruitms1438.h"
%{
- #include "adafruitms1438.hpp"
+ #include "adafruitms1438.h"
%}
diff --git a/peripheral/libupm/src/adafruitss/CMakeLists.txt b/peripheral/libupm/src/adafruitss/CMakeLists.txt
index 8d5dd48..40214ce 100644
--- a/peripheral/libupm/src/adafruitss/CMakeLists.txt
+++ b/peripheral/libupm/src/adafruitss/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "adafruitss")
set (libdescription "upm Adafruit pca9685 based 16-channel servo shield")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/adafruitss/adafruitss.cxx b/peripheral/libupm/src/adafruitss/adafruitss.cxx
index a43e7b0..1bd967a 100644
--- a/peripheral/libupm/src/adafruitss/adafruitss.cxx
+++ b/peripheral/libupm/src/adafruitss/adafruitss.cxx
@@ -25,7 +25,7 @@
#include <string>
#include <stdexcept>
-#include "adafruitss.hpp"
+#include "adafruitss.h"
#include <unistd.h>
#include <math.h>
diff --git a/peripheral/libupm/src/adafruitss/adafruitss.hpp b/peripheral/libupm/src/adafruitss/adafruitss.h
index e9dbb75..e9dbb75 100644
--- a/peripheral/libupm/src/adafruitss/adafruitss.hpp
+++ b/peripheral/libupm/src/adafruitss/adafruitss.h
diff --git a/peripheral/libupm/src/adafruitss/javaupm_adafruitss.i b/peripheral/libupm/src/adafruitss/javaupm_adafruitss.i
index 1bbccd7..4e64220 100644
--- a/peripheral/libupm/src/adafruitss/javaupm_adafruitss.i
+++ b/peripheral/libupm/src/adafruitss/javaupm_adafruitss.i
@@ -1,9 +1,9 @@
%module javaupm_adafruitss
%include "../upm.i"
-%include "adafruitss.hpp"
+%include "adafruitss.h"
%{
- #include "adafruitss.hpp"
+ #include "adafruitss.h"
%}
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/adafruitss/jsupm_adafruitss.i b/peripheral/libupm/src/adafruitss/jsupm_adafruitss.i
index 4117543..cb15aaa 100644
--- a/peripheral/libupm/src/adafruitss/jsupm_adafruitss.i
+++ b/peripheral/libupm/src/adafruitss/jsupm_adafruitss.i
@@ -1,7 +1,7 @@
%module jsupm_adafruitss
%include "../upm.i"
-%include "adafruitss.hpp"
+%include "adafruitss.h"
%{
- #include "adafruitss.hpp"
+ #include "adafruitss.h"
%}
diff --git a/peripheral/libupm/src/adafruitss/pyupm_adafruitss.i b/peripheral/libupm/src/adafruitss/pyupm_adafruitss.i
index 364123e..8f8131f 100644
--- a/peripheral/libupm/src/adafruitss/pyupm_adafruitss.i
+++ b/peripheral/libupm/src/adafruitss/pyupm_adafruitss.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "adafruitss.hpp"
+%include "adafruitss.h"
%{
- #include "adafruitss.hpp"
+ #include "adafruitss.h"
%}
diff --git a/peripheral/libupm/src/adc121c021/CMakeLists.txt b/peripheral/libupm/src/adc121c021/CMakeLists.txt
index bc00f59..1c198fd 100644
--- a/peripheral/libupm/src/adc121c021/CMakeLists.txt
+++ b/peripheral/libupm/src/adc121c021/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "adc121c021")
set (libdescription "upm adc121c021 I2C ADC converter module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/adc121c021/adc121c021.cxx b/peripheral/libupm/src/adc121c021/adc121c021.cxx
index 41808b9..7bdb8a3 100644
--- a/peripheral/libupm/src/adc121c021/adc121c021.cxx
+++ b/peripheral/libupm/src/adc121c021/adc121c021.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "adc121c021.hpp"
+#include "adc121c021.h"
using namespace upm;
using namespace std;
@@ -79,20 +79,12 @@ mraa_result_t ADC121C021::writeWord(uint8_t reg, uint16_t word)
uint8_t ADC121C021::readByte(uint8_t reg)
{
- int val = mraa_i2c_read_byte_data(m_i2c, reg);
- if (val != -1) {
- return (uint8_t) val;
- }
- return 0;
+ return mraa_i2c_read_byte_data(m_i2c, reg);
}
uint16_t ADC121C021::readWord(uint8_t reg)
{
- int x = mraa_i2c_read_word_data(m_i2c, reg);
- if (x == -1) {
- return 0;
- }
- uint16_t val = (uint16_t) x;
+ uint16_t val = mraa_i2c_read_word_data(m_i2c, reg);
uint8_t b1;
// The value returned is in the wrong byte order, so we need to swap them
diff --git a/peripheral/libupm/src/adc121c021/adc121c021.hpp b/peripheral/libupm/src/adc121c021/adc121c021.h
index 8a2519d..8a2519d 100644
--- a/peripheral/libupm/src/adc121c021/adc121c021.hpp
+++ b/peripheral/libupm/src/adc121c021/adc121c021.h
diff --git a/peripheral/libupm/src/adc121c021/javaupm_adc121c021.i b/peripheral/libupm/src/adc121c021/javaupm_adc121c021.i
index 4509600..33e4d2e 100644
--- a/peripheral/libupm/src/adc121c021/javaupm_adc121c021.i
+++ b/peripheral/libupm/src/adc121c021/javaupm_adc121c021.i
@@ -3,10 +3,10 @@
/*%include "../carrays_uint16_t.i"
*/
%{
- #include "adc121c021.hpp"
+ #include "adc121c021.h"
%}
-%include "adc121c021.hpp"
+%include "adc121c021.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/adc121c021/jsupm_adc121c021.i b/peripheral/libupm/src/adc121c021/jsupm_adc121c021.i
index 2a81ccb..83c2893 100644
--- a/peripheral/libupm/src/adc121c021/jsupm_adc121c021.i
+++ b/peripheral/libupm/src/adc121c021/jsupm_adc121c021.i
@@ -3,7 +3,7 @@
%include "../carrays_uint16_t.i"
%{
- #include "adc121c021.hpp"
+ #include "adc121c021.h"
%}
-%include "adc121c021.hpp"
+%include "adc121c021.h"
diff --git a/peripheral/libupm/src/adc121c021/pyupm_adc121c021.i b/peripheral/libupm/src/adc121c021/pyupm_adc121c021.i
index 33668de..9fd2a83 100644
--- a/peripheral/libupm/src/adc121c021/pyupm_adc121c021.i
+++ b/peripheral/libupm/src/adc121c021/pyupm_adc121c021.i
@@ -9,7 +9,7 @@
%include "adc121c021_doc.i"
#endif
-%include "adc121c021.hpp"
+%include "adc121c021.h"
%{
- #include "adc121c021.hpp"
+ #include "adc121c021.h"
%}
diff --git a/peripheral/libupm/src/adis16448/CMakeLists.txt b/peripheral/libupm/src/adis16448/CMakeLists.txt
index d6ac44c..d7b4972 100644
--- a/peripheral/libupm/src/adis16448/CMakeLists.txt
+++ b/peripheral/libupm/src/adis16448/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "adis16448")
set (libdescription "libupm High-Precision IMU")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/adis16448/adis16448.cxx b/peripheral/libupm/src/adis16448/adis16448.cxx
index eb6f4a8..b95d3fa 100644
--- a/peripheral/libupm/src/adis16448/adis16448.cxx
+++ b/peripheral/libupm/src/adis16448/adis16448.cxx
@@ -44,7 +44,7 @@
#include <functional>
#include <string.h>
-#include "adis16448.hpp"
+#include "adis16448.h"
using namespace upm;
diff --git a/peripheral/libupm/src/adis16448/adis16448.hpp b/peripheral/libupm/src/adis16448/adis16448.h
index 3227ee5..0159e48 100644
--- a/peripheral/libupm/src/adis16448/adis16448.hpp
+++ b/peripheral/libupm/src/adis16448/adis16448.h
@@ -6,7 +6,7 @@
// Copyright (c) 2015 Juan Jose Chong
//
//////////////////////////////////////////////////////////////////////////////////////
-// adis16448.hpp
+// adis16448.h
//////////////////////////////////////////////////////////////////////////////////////
//
// This library runs on an Intel Edison and uses mraa to acquire data
diff --git a/peripheral/libupm/src/adis16448/javaupm_adis16448.i b/peripheral/libupm/src/adis16448/javaupm_adis16448.i
index 46dbd84..b4cc0b1 100644
--- a/peripheral/libupm/src/adis16448/javaupm_adis16448.i
+++ b/peripheral/libupm/src/adis16448/javaupm_adis16448.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "adis16448.hpp"
+ #include "adis16448.h"
%}
-%include "adis16448.hpp"
+%include "adis16448.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/adis16448/jsupm_adis16448.i b/peripheral/libupm/src/adis16448/jsupm_adis16448.i
index 95b88f6..64882d0 100644
--- a/peripheral/libupm/src/adis16448/jsupm_adis16448.i
+++ b/peripheral/libupm/src/adis16448/jsupm_adis16448.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "adis16448.hpp"
+ #include "adis16448.h"
%}
-%include "adis16448.hpp"
+%include "adis16448.h"
diff --git a/peripheral/libupm/src/adis16448/pyupm_adis16448.i b/peripheral/libupm/src/adis16448/pyupm_adis16448.i
index 5edec48..62ef918 100644
--- a/peripheral/libupm/src/adis16448/pyupm_adis16448.i
+++ b/peripheral/libupm/src/adis16448/pyupm_adis16448.i
@@ -4,7 +4,7 @@
%include "../upm.i"
%{
- #include "adis16448.hpp"
+ #include "adis16448.h"
%}
-%include "adis16448.hpp"
+%include "adis16448.h"
diff --git a/peripheral/libupm/src/ads1x15/CMakeLists.txt b/peripheral/libupm/src/ads1x15/CMakeLists.txt
index 7d93acd..67c2e85 100644
--- a/peripheral/libupm/src/ads1x15/CMakeLists.txt
+++ b/peripheral/libupm/src/ads1x15/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "ads1x15")
set (libdescription "analog to digital converter")
set (module_src ${libname}.cxx ads1115.cxx ads1015.cxx)
-set (module_hpp ${libname}.hpp ads1115.hpp ads1015.hpp)
+set (module_h ${libname}.h ads1115.h ads1015.h)
upm_module_init() \ No newline at end of file
diff --git a/peripheral/libupm/src/ads1x15/ads1015.cxx b/peripheral/libupm/src/ads1x15/ads1015.cxx
index d49b83d..1beef3d 100644
--- a/peripheral/libupm/src/ads1x15/ads1015.cxx
+++ b/peripheral/libupm/src/ads1x15/ads1015.cxx
@@ -21,7 +21,7 @@
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "ads1015.hpp"
+#include "ads1015.h"
using namespace upm;
@@ -30,63 +30,15 @@ ADS1015::setSPS(ADSSAMPLERATE rate){
updateConfigRegister((m_config_reg & ~ADS1X15_DR_MASK) | rate);
}
-ADS1015::ADS1015(int bus, uint8_t address, float vref) : ADS1X15(bus, address) {
+ADS1015::ADS1015(int bus, uint8_t address) : ADS1X15(bus, address) {
m_name = "ADS1015";
m_conversionDelay = ADS1015_CONVERSIONDELAY;
m_bitShift = 4;
ADS1X15::getCurrentConfig();
- if (vref < 0.0 || vref > 6.144)
- UPM_THROW("vref out of range");
- else if (vref > 4.096)
- setGain(GAIN_TWOTHIRDS);
- else if (vref > 2.048)
- setGain(GAIN_ONE);
- else if (vref > 1.024)
- setGain(GAIN_TWO);
- else if (vref > 0.512)
- setGain(GAIN_FOUR);
- else if (vref > 0.256)
- setGain(GAIN_EIGHT);
- else
- setGain(GAIN_SIXTEEN);
}
ADS1015::~ADS1015(){};
-const char*
-ADS1015::getModuleName() {
- return m_name.c_str();
-}
-
-
-unsigned int
-ADS1015::getNumInputs() {
- return 4;
-}
-
-unsigned int
-ADS1015::getResolutionInBits() {
- return 12;
-}
-
-uint16_t
-ADS1015::getRawValue(unsigned int input) {
- ADS1X15::ADSMUXMODE mode = getMuxMode(input);
- updateConfigRegister((m_config_reg & ~ADS1X15_MUX_MASK) | mode, true);
- usleep(m_conversionDelay);
- uint16_t value = i2c->readWordReg(ADS1X15_REG_POINTER_CONVERT);
- value = value >> m_bitShift;
- return swapWord(value);
-}
-
-float
-ADS1015::getVoltage(unsigned int input) {
- ADSMUXMODE mode = getMuxMode(input);
- return getSample(mode);
-}
-
-
-
//Private functions
float
ADS1015::getMultiplier(void){
@@ -147,20 +99,4 @@ ADS1015::setDelay(){
}
}
-ADS1X15::ADSMUXMODE
-ADS1015::getMuxMode(unsigned int input) {
- ADS1X15::ADSMUXMODE mode;
- switch (input) {
- case 0:
- return SINGLE_0;
- case 1:
- return SINGLE_1;
- case 2:
- return SINGLE_2;
- case 3:
- return SINGLE_3;
- default:
- UPM_THROW("Invalid input");
- }
-}
diff --git a/peripheral/libupm/src/ads1x15/ads1015.hpp b/peripheral/libupm/src/ads1x15/ads1015.h
index c51a455..6d0fd9f 100644
--- a/peripheral/libupm/src/ads1x15/ads1015.hpp
+++ b/peripheral/libupm/src/ads1x15/ads1015.h
@@ -25,10 +25,9 @@
#pragma once
-#include "ads1x15.hpp"
-#include "upm/iADC.hpp"
+#include "ads1x15.h"
+
-#define ADS1015_VREF 2.048
/*=========================================================================
CONVERSION DELAY (in microS)
@@ -83,7 +82,7 @@ namespace upm {
* @image html ads1015.jpg
* @snippet ads1x15.cxx Interesting
*/
- class ADS1015 : public ADS1X15, public IADC {
+ class ADS1015 : public ADS1X15 {
public:
@@ -112,16 +111,12 @@ namespace upm {
/**
- * ADS1015 constructor
- *
- * This constructor includes a vref parameter that can be used
- * to set gain so it matches full scale value of input
+ * ADS1X15 constructor
*
* @param bus i2c bus the sensor is attached to.
- * @param address. Optional device address. Default is 0x48.
- * @param vref. Optional reference (i.e. half full swing) voltage. Default is 2.048V
+ * @param address. Device address. Default is 0x48.
*/
- ADS1015 (int bus, uint8_t address = 0x48, float vref = ADS1015_VREF);
+ ADS1015 (int bus, uint8_t address = 0x48);
/**
* ADS1X15 destructor
@@ -137,48 +132,9 @@ namespace upm {
*/
void setSPS(ADSSAMPLERATE rate = SPS_1600);
- /**
- * Get number of inputs
- *
- * @return number of inputs
- */
- unsigned int getNumInputs();
-
- /**
- * Read current value for current single ended analogue input
- *
- * @return current conversion value
- */
- uint16_t getRawValue(unsigned int input);
-
- /**
- * Read current voltage for current single ended analogue input
- *
- * @return current voltage
- */
- float getVoltage(unsigned int input);
-
- /**
- * Read current voltage for current single ended analogue input
- *
- * @return current voltage
- */
- unsigned int getResolutionInBits();
-
- /**
- * Returns module name
- *
- * @return modulename as const char*
- */
- const char* getModuleName();
-
-
protected:
float getMultiplier(void);
void setDelay(void);
- private:
- ADS1X15::ADSMUXMODE getMuxMode(unsigned int input);
-
};
}
diff --git a/peripheral/libupm/src/ads1x15/ads1115.cxx b/peripheral/libupm/src/ads1x15/ads1115.cxx
index a26aba4..ee0dfda 100644
--- a/peripheral/libupm/src/ads1x15/ads1115.cxx
+++ b/peripheral/libupm/src/ads1x15/ads1115.cxx
@@ -21,7 +21,7 @@
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "ads1115.hpp"
+#include "ads1115.h"
using namespace upm;
diff --git a/peripheral/libupm/src/ads1x15/ads1115.hpp b/peripheral/libupm/src/ads1x15/ads1115.h
index ffe44ab..32c4b93 100644
--- a/peripheral/libupm/src/ads1x15/ads1115.hpp
+++ b/peripheral/libupm/src/ads1x15/ads1115.h
@@ -25,7 +25,7 @@
#pragma once
-#include "ads1x15.hpp"
+#include "ads1x15.h"
diff --git a/peripheral/libupm/src/ads1x15/ads1x15.cxx b/peripheral/libupm/src/ads1x15/ads1x15.cxx
index a9a7ff2..4a1ea9d 100644
--- a/peripheral/libupm/src/ads1x15/ads1x15.cxx
+++ b/peripheral/libupm/src/ads1x15/ads1x15.cxx
@@ -23,7 +23,7 @@
*/
-#include "ads1x15.hpp"
+#include "ads1x15.h"
#include <unistd.h>
diff --git a/peripheral/libupm/src/ads1x15/ads1x15.hpp b/peripheral/libupm/src/ads1x15/ads1x15.h
index 8ff4fa3..8ff4fa3 100644
--- a/peripheral/libupm/src/ads1x15/ads1x15.hpp
+++ b/peripheral/libupm/src/ads1x15/ads1x15.h
diff --git a/peripheral/libupm/src/ads1x15/javaupm_ads1x15.i b/peripheral/libupm/src/ads1x15/javaupm_ads1x15.i
index e16dc4e..88522e3 100644
--- a/peripheral/libupm/src/ads1x15/javaupm_ads1x15.i
+++ b/peripheral/libupm/src/ads1x15/javaupm_ads1x15.i
@@ -3,14 +3,14 @@
%include "typemaps.i"
%{
- #include "ads1x15.hpp"
- #include "ads1015.hpp"
- #include "ads1115.hpp"
+ #include "ads1x15.h"
+ #include "ads1015.h"
+ #include "ads1115.h"
%}
-%include "ads1x15.hpp"
-%include "ads1015.hpp"
-%include "ads1115.hpp"
+%include "ads1x15.h"
+%include "ads1015.h"
+%include "ads1115.h"
diff --git a/peripheral/libupm/src/ads1x15/jsupm_ads1x15.i b/peripheral/libupm/src/ads1x15/jsupm_ads1x15.i
index 8a10beb..11a00e7 100644
--- a/peripheral/libupm/src/ads1x15/jsupm_ads1x15.i
+++ b/peripheral/libupm/src/ads1x15/jsupm_ads1x15.i
@@ -1,17 +1,17 @@
%module jsupm_ads1x15
%include "../upm.i"
-%include "ads1x15.hpp"
+%include "ads1x15.h"
%{
- #include "ads1x15.hpp"
+ #include "ads1x15.h"
%}
-%include "ads1015.hpp"
+%include "ads1015.h"
%{
- #include "ads1015.hpp"
+ #include "ads1015.h"
%}
-%include "ads1115.hpp"
+%include "ads1115.h"
%{
- #include "ads1115.hpp"
+ #include "ads1115.h"
%} \ No newline at end of file
diff --git a/peripheral/libupm/src/ads1x15/pyupm_ads1x15.i b/peripheral/libupm/src/ads1x15/pyupm_ads1x15.i
index e257313..dc17d1a 100644
--- a/peripheral/libupm/src/ads1x15/pyupm_ads1x15.i
+++ b/peripheral/libupm/src/ads1x15/pyupm_ads1x15.i
@@ -5,17 +5,17 @@
%feature("autodoc", "3");
-%include "ads1x15.hpp"
+%include "ads1x15.h"
%{
- #include "ads1x15.hpp"
+ #include "ads1x15.h"
%}
-%include "ads1015.hpp"
+%include "ads1015.h"
%{
- #include "ads1015.hpp"
+ #include "ads1015.h"
%}
-%include "ads1115.hpp"
+%include "ads1115.h"
%{
- #include "ads1115.hpp"
+ #include "ads1115.h"
%} \ No newline at end of file
diff --git a/peripheral/libupm/src/adxl335/CMakeLists.txt b/peripheral/libupm/src/adxl335/CMakeLists.txt
index fe12852..0260767 100644
--- a/peripheral/libupm/src/adxl335/CMakeLists.txt
+++ b/peripheral/libupm/src/adxl335/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "adxl335")
set (libdescription "upm adxl335 grove 3-axis anaolog accelerometer")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/adxl335/adxl335.cxx b/peripheral/libupm/src/adxl335/adxl335.cxx
index 261f66b..de6f1b9 100644
--- a/peripheral/libupm/src/adxl335/adxl335.cxx
+++ b/peripheral/libupm/src/adxl335/adxl335.cxx
@@ -29,7 +29,7 @@
#include <string>
#include <stdexcept>
-#include "adxl335.hpp"
+#include "adxl335.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/src/adxl335/adxl335.hpp b/peripheral/libupm/src/adxl335/adxl335.h
index e7671da..e7671da 100644
--- a/peripheral/libupm/src/adxl335/adxl335.hpp
+++ b/peripheral/libupm/src/adxl335/adxl335.h
diff --git a/peripheral/libupm/src/adxl335/javaupm_adxl335.i b/peripheral/libupm/src/adxl335/javaupm_adxl335.i
index 99e021e..2624571 100644
--- a/peripheral/libupm/src/adxl335/javaupm_adxl335.i
+++ b/peripheral/libupm/src/adxl335/javaupm_adxl335.i
@@ -7,7 +7,7 @@
%apply float *OUTPUT { float *xAccel, float *yAccel, float *zAccel };
%{
- #include "adxl335.hpp"
+ #include "adxl335.h"
%}
%typemap(jni) float* "jfloatArray"
@@ -40,7 +40,7 @@
%ignore values(int *, int *, int *);
%ignore acceleration(float *, float *, float *);
-%include "adxl335.hpp"
+%include "adxl335.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/adxl335/jsupm_adxl335.i b/peripheral/libupm/src/adxl335/jsupm_adxl335.i
index 4c48eed..452204c 100644
--- a/peripheral/libupm/src/adxl335/jsupm_adxl335.i
+++ b/peripheral/libupm/src/adxl335/jsupm_adxl335.i
@@ -6,7 +6,7 @@
%pointer_functions(float, floatPointer);
%{
- #include "adxl335.hpp"
+ #include "adxl335.h"
%}
-%include "adxl335.hpp"
+%include "adxl335.h"
diff --git a/peripheral/libupm/src/adxl335/pyupm_adxl335.i b/peripheral/libupm/src/adxl335/pyupm_adxl335.i
index 4618c92..ea4f240 100644
--- a/peripheral/libupm/src/adxl335/pyupm_adxl335.i
+++ b/peripheral/libupm/src/adxl335/pyupm_adxl335.i
@@ -9,7 +9,7 @@
%feature("autodoc", "3");
-%include "adxl335.hpp"
+%include "adxl335.h"
%{
- #include "adxl335.hpp"
+ #include "adxl335.h"
%}
diff --git a/peripheral/libupm/src/adxl345/CMakeLists.txt b/peripheral/libupm/src/adxl345/CMakeLists.txt
index 74c03ab..9f19228 100644
--- a/peripheral/libupm/src/adxl345/CMakeLists.txt
+++ b/peripheral/libupm/src/adxl345/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "adxl345")
set (libdescription "libupm Digital Accelerometer")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/adxl345/adxl345.cxx b/peripheral/libupm/src/adxl345/adxl345.cxx
index cf2dcc6..3503d64 100644
--- a/peripheral/libupm/src/adxl345/adxl345.cxx
+++ b/peripheral/libupm/src/adxl345/adxl345.cxx
@@ -27,7 +27,7 @@
#include <stdexcept>
#include <unistd.h>
#include "math.h"
-#include "adxl345.hpp"
+#include "adxl345.h"
#define READ_BUFFER_LENGTH 6
diff --git a/peripheral/libupm/src/adxl345/adxl345.hpp b/peripheral/libupm/src/adxl345/adxl345.h
index 7d35f23..7d35f23 100644
--- a/peripheral/libupm/src/adxl345/adxl345.hpp
+++ b/peripheral/libupm/src/adxl345/adxl345.h
diff --git a/peripheral/libupm/src/adxl345/javaupm_adxl345.i b/peripheral/libupm/src/adxl345/javaupm_adxl345.i
index 8087a36..9b759b4 100644
--- a/peripheral/libupm/src/adxl345/javaupm_adxl345.i
+++ b/peripheral/libupm/src/adxl345/javaupm_adxl345.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "adxl345.hpp"
+ #include "adxl345.h"
%}
%typemap(jni) float* "jfloatArray"
@@ -33,7 +33,7 @@
delete [] $1;
}
-%include "adxl345.hpp"
+%include "adxl345.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/adxl345/jsupm_adxl345.i b/peripheral/libupm/src/adxl345/jsupm_adxl345.i
index 9957887..6f72b79 100644
--- a/peripheral/libupm/src/adxl345/jsupm_adxl345.i
+++ b/peripheral/libupm/src/adxl345/jsupm_adxl345.i
@@ -4,7 +4,7 @@
%include "../carrays_float.i"
%{
- #include "adxl345.hpp"
+ #include "adxl345.h"
%}
%typemap(out) int16_t * {
@@ -15,6 +15,6 @@
$result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_floatArray, 0 | 0 );
}
-%include "adxl345.hpp"
+%include "adxl345.h"
%include <carrays.i>
diff --git a/peripheral/libupm/src/adxl345/pyupm_adxl345.i b/peripheral/libupm/src/adxl345/pyupm_adxl345.i
index b8df689..b3c5300 100644
--- a/peripheral/libupm/src/adxl345/pyupm_adxl345.i
+++ b/peripheral/libupm/src/adxl345/pyupm_adxl345.i
@@ -19,7 +19,7 @@
%include "adxl345_doc.i"
#endif
-%include "adxl345.hpp"
+%include "adxl345.h"
%{
- #include "adxl345.hpp"
+ #include "adxl345.h"
%}
diff --git a/peripheral/libupm/src/adxrs610/CMakeLists.txt b/peripheral/libupm/src/adxrs610/CMakeLists.txt
index 8cc5696..eb349f8 100644
--- a/peripheral/libupm/src/adxrs610/CMakeLists.txt
+++ b/peripheral/libupm/src/adxrs610/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "adxrs610")
set (libdescription "upm ADXRS610 gyroscope")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/adxrs610/adxrs610.cxx b/peripheral/libupm/src/adxrs610/adxrs610.cxx
index 30662bb..8d48928 100644
--- a/peripheral/libupm/src/adxrs610/adxrs610.cxx
+++ b/peripheral/libupm/src/adxrs610/adxrs610.cxx
@@ -24,7 +24,7 @@
#include <iostream>
-#include "adxrs610.hpp"
+#include "adxrs610.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/src/adxrs610/adxrs610.hpp b/peripheral/libupm/src/adxrs610/adxrs610.h
index ac8cdb0..07bc389 100644
--- a/peripheral/libupm/src/adxrs610/adxrs610.hpp
+++ b/peripheral/libupm/src/adxrs610/adxrs610.h
@@ -113,7 +113,7 @@ namespace upm {
/**
* Set the zero point. This is the point measured and averaged
* when the sensor is not moving. It is set at construction time
- * (averaged over a number of samples), but can be overridden here.
+ * (averaged over a number of samples), but can be overriden here.
*
* @param zeroPoint The averaged zero point of the sensor at rest
*/
diff --git a/peripheral/libupm/src/adxrs610/javaupm_adxrs610.i b/peripheral/libupm/src/adxrs610/javaupm_adxrs610.i
index 32ca600..0c89c14 100644
--- a/peripheral/libupm/src/adxrs610/javaupm_adxrs610.i
+++ b/peripheral/libupm/src/adxrs610/javaupm_adxrs610.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "adxrs610.hpp"
+ #include "adxrs610.h"
%}
-%include "adxrs610.hpp"
+%include "adxrs610.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/adxrs610/jsupm_adxrs610.i b/peripheral/libupm/src/adxrs610/jsupm_adxrs610.i
index 35ce559..841fa60 100644
--- a/peripheral/libupm/src/adxrs610/jsupm_adxrs610.i
+++ b/peripheral/libupm/src/adxrs610/jsupm_adxrs610.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "adxrs610.hpp"
+ #include "adxrs610.h"
%}
-%include "adxrs610.hpp"
+%include "adxrs610.h"
diff --git a/peripheral/libupm/src/adxrs610/pyupm_adxrs610.i b/peripheral/libupm/src/adxrs610/pyupm_adxrs610.i
index 979750f..fd597ff 100644
--- a/peripheral/libupm/src/adxrs610/pyupm_adxrs610.i
+++ b/peripheral/libupm/src/adxrs610/pyupm_adxrs610.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "adxrs610.hpp"
+%include "adxrs610.h"
%{
- #include "adxrs610.hpp"
+ #include "adxrs610.h"
%}
diff --git a/peripheral/libupm/src/am2315/CMakeLists.txt b/peripheral/libupm/src/am2315/CMakeLists.txt
index d7afff6..5931421 100644
--- a/peripheral/libupm/src/am2315/CMakeLists.txt
+++ b/peripheral/libupm/src/am2315/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "am2315")
set (libdescription "libupm Humidity Sensor")
set (module_src ${libname}.cpp)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/am2315/am2315.cpp b/peripheral/libupm/src/am2315/am2315.cpp
index f1e7186..c687cc7 100644
--- a/peripheral/libupm/src/am2315/am2315.cpp
+++ b/peripheral/libupm/src/am2315/am2315.cpp
@@ -30,7 +30,7 @@
#include <sched.h>
#include <time.h>
-#include "am2315.hpp"
+#include "am2315.h"
using namespace upm;
@@ -233,8 +233,7 @@ AM2315::i2cWriteReg(uint8_t reg, uint8_t* data, uint8_t ilen)
uint8_t
AM2315::i2cReadReg(int reg, uint8_t* data, int ilen)
{
- uint8_t tdata[16] = { AM2315_READ, static_cast<uint8_t>(reg),
- static_cast<uint8_t>(ilen) };
+ uint8_t tdata[16] = { AM2315_READ, reg, ilen };
mraa_result_t ret = mraa_i2c_address(m_i2ControlCtx, m_controlAddr);
int iLoops = 5;
diff --git a/peripheral/libupm/src/am2315/am2315.hpp b/peripheral/libupm/src/am2315/am2315.h
index 5d69882..5d69882 100644
--- a/peripheral/libupm/src/am2315/am2315.hpp
+++ b/peripheral/libupm/src/am2315/am2315.h
diff --git a/peripheral/libupm/src/am2315/javaupm_am2315.i b/peripheral/libupm/src/am2315/javaupm_am2315.i
index 8bdd047..5d2a0ad 100644
--- a/peripheral/libupm/src/am2315/javaupm_am2315.i
+++ b/peripheral/libupm/src/am2315/javaupm_am2315.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "am2315.hpp"
+ #include "am2315.h"
%}
-%include "am2315.hpp"
+%include "am2315.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/am2315/jsupm_am2315.i b/peripheral/libupm/src/am2315/jsupm_am2315.i
index ddf4cac..f6baf25 100644
--- a/peripheral/libupm/src/am2315/jsupm_am2315.i
+++ b/peripheral/libupm/src/am2315/jsupm_am2315.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "am2315.hpp"
+ #include "am2315.h"
%}
-%include "am2315.hpp"
+%include "am2315.h"
diff --git a/peripheral/libupm/src/am2315/pyupm_am2315.i b/peripheral/libupm/src/am2315/pyupm_am2315.i
index 829ab9c..7e9acf1 100644
--- a/peripheral/libupm/src/am2315/pyupm_am2315.i
+++ b/peripheral/libupm/src/am2315/pyupm_am2315.i
@@ -9,7 +9,7 @@
%include "am2315_doc.i"
#endif
-%include "am2315.hpp"
+%include "am2315.h"
%{
- #include "am2315.hpp"
+ #include "am2315.h"
%}
diff --git a/peripheral/libupm/src/apa102/CMakeLists.txt b/peripheral/libupm/src/apa102/CMakeLists.txt
deleted file mode 100644
index 27335be..0000000
--- a/peripheral/libupm/src/apa102/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set (libname "apa102")
-set (libdescription "upm apa102 led strip spi output module")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/apa102/apa102.cxx b/peripheral/libupm/src/apa102/apa102.cxx
deleted file mode 100644
index a43004a..0000000
--- a/peripheral/libupm/src/apa102/apa102.cxx
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Author: Yannick Adam <yannick.adam@gmail.com>
- * Copyright (c) 2016 Yannick Adam
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <cstring>
-#include <iostream>
-#include <stdexcept>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "apa102.hpp"
-
-using namespace upm;
-
-APA102::APA102(uint16_t ledCount, uint8_t spiBus, bool batchMode, int8_t csn)
- : m_ledCount(ledCount), m_batchMode(batchMode)
-{
- mraa::Result res = mraa::SUCCESS;
- m_leds = NULL;
-
- // Optional chip select pin
- m_csnPinCtx = NULL;
- if (csn > -1) {
- m_csnPinCtx = new mraa::Gpio(csn);
- res = m_csnPinCtx->dir(mraa::DIR_OUT);
- if (res != mraa::SUCCESS) {
- throw std::invalid_argument(std::string(__FUNCTION__) +
- ": GPIO failed to set direction");
- }
- }
-
- CSOff();
- // Initialize SPI
- m_spi = new mraa::Spi(spiBus);
-
- // Initialize LED array
- uint16_t endFrameLength = (m_ledCount + 15) / 16; // End frame should be (leds/2) bits
- m_frameLength = endFrameLength + (m_ledCount + 1) * 4;
- if ((m_leds = (uint8_t*) malloc(m_frameLength))) {
- memset(m_leds, 0x00, m_frameLength - 4); // Clear state
- memset(&m_leds[m_frameLength - endFrameLength], 0xFF, endFrameLength); // Frame End
-
- // Need to set the brightness to "0" for each Led
- for (int i = 1; i <= m_ledCount; i++) {
- m_leds[i * 4] = 224;
- }
-
- } else {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": Failed to allocate memory for LED Strip");
- }
-}
-
-APA102::~APA102()
-{
- // Clear leds
- if (m_leds) {
- free(m_leds);
- }
-
- // Clear SPI
- if (m_spi) {
- delete m_spi;
- }
-
- // Clear GPIO
- if (m_csnPinCtx) {
- delete m_csnPinCtx;
- }
-}
-
-
-void
-APA102::setLed(uint16_t ledIdx, uint8_t brightness, uint8_t r, uint8_t g, uint8_t b)
-{
- setLeds(ledIdx, ledIdx, brightness, r, g, b);
-}
-
-void
-APA102::setAllLeds(uint8_t brightness, uint8_t r, uint8_t g, uint8_t b)
-{
- setLeds(0, m_ledCount - 1, brightness, r, g, b);
-}
-
-void
-APA102::setLeds(uint16_t startIdx, uint16_t endIdx, uint8_t brightness, uint8_t r, uint8_t g, uint8_t b)
-{
- uint16_t s_idx = (startIdx + 1) * 4;
- uint16_t e_idx = (endIdx + 1) * 4;
-
- for (uint16_t i = s_idx; i <= e_idx; i += 4) {
- m_leds[i] = brightness | 224;
- m_leds[i + 1] = b;
- m_leds[i + 2] = g;
- m_leds[i + 3] = r;
- }
-
- if (!m_batchMode) {
- pushState();
- }
-}
-
-void
-APA102::setLeds(uint16_t startIdx, uint16_t endIdx, uint8_t* colors)
-{
- uint16_t s_idx = (startIdx + 1) * 4;
- memcpy(&m_leds[s_idx], colors, (endIdx - startIdx + 1) * 4);
-
- if (!m_batchMode) {
- pushState();
- }
-}
-
-void
-APA102::pushState(void)
-{
- CSOn();
- m_spi->write(m_leds, m_frameLength);
- CSOff();
-}
-
-/*
- * **************
- * private area
- * **************
- */
-
-mraa::Result
-APA102::CSOn()
-{
- if (m_csnPinCtx) {
- return m_csnPinCtx->write(HIGH);
- }
-
- return mraa::ERROR_FEATURE_NOT_SUPPORTED;
-}
-
-mraa::Result
-APA102::CSOff()
-{
- if (m_csnPinCtx) {
- return m_csnPinCtx->write(LOW);
- }
-
- return mraa::ERROR_FEATURE_NOT_SUPPORTED;
-}
diff --git a/peripheral/libupm/src/apa102/apa102.hpp b/peripheral/libupm/src/apa102/apa102.hpp
deleted file mode 100644
index 34033e8..0000000
--- a/peripheral/libupm/src/apa102/apa102.hpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Author: Yannick Adam <yannick.adam@gmail.com>
- * Copyright (c) 2016 Yannick Adam
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <mraa/gpio.hpp>
-#include <mraa/spi.hpp>
-#include <string>
-
-#define HIGH 1
-#define LOW 0
-
-namespace upm
-{
-/**
- * @brief APA102 RGB LED Strip driver library
- * @defgroup apa102 libupm-apa102
- * @ingroup spi led
- */
-
-/**
- * @library apa102
- * @sensor apa102
- * @comname APA102/DotStar LED Strip
- * @type led
- * @man adafruit
- * @con spi
- *
- * @brief API for controlling APA102/DotStar RGB LED Strips
- *
- * APA102 LED Strips provide individually controllable LEDs through a SPI interface.
- * For each LED, brightness (0-31) and RGB (0-255) values can be set.
- *
- * @image html apa102.jpg
- * @snippet apa102.cxx Interesting
- */
-class APA102
-{
- public:
- /**
- * Instantiates a new APA102 LED Strip
- *
- * @param ledCount Number of APA102 leds in the strip
- * @param spiBus SPI Bus number
- * @param batchMode (optional) Immediately write to SPI (false, default) or wait for a pushState
- * call (true)
- * @param csn (optional) Chip Select Pin
- */
- APA102(uint16_t ledCount, uint8_t spiBus, bool batchMode = false, int8_t csn = -1);
-
- /**
- * APA102 destructor
- */
- ~APA102();
-
- /**
- * Change the color for a single led
- *
- * @param ledIdx Index of the LED in the strip (0 based)
- * @param brightness Brightness value (0-31)
- * @param r Red component (0-255)
- * @param g Green component (0-255)
- * @param b Blue component (0-255)
- */
- void setLed(uint16_t ledIdx, uint8_t brightness, uint8_t r, uint8_t g, uint8_t b);
-
- /**
- * Change the color for all leds
- *
- * @param brightness Brightness value (0-31)
- * @param r Red component (0-255)
- * @param g Green component (0-255)
- * @param b Blue component (0-255)
- */
- void setAllLeds(uint8_t brightness, uint8_t r, uint8_t g, uint8_t b);
-
- /**
- * Change the color for a range of leds
- *
- * @param startIdx Start index of the range of LEDs in the strip (0 based)
- * @param endIdx End index of the range of LEDs in the strip (0 based)
- * @param brightness Brightness value (0-31)
- * @param r Red component (0-255)
- * @param g Green component (0-255)
- * @param b Blue component (0-255)
- */
- void
- setLeds(uint16_t startIdx, uint16_t endIdx, uint8_t brightness, uint8_t r, uint8_t g, uint8_t b);
-
- /**
- * (Advanced) Manually control the colors of a range of LEDS
- * Best used to maximize performance
- *
- * @param startIdx Start index of the range of LEDs to update (0 based)
- * @param endIdx End index of the range of LEDs to update (0 based)
- * @param colors Pointer to an array of bytes. Each color is described as the following:
- * B1: Brightness (224-255) B2: Blue (0-255) B3: Green (0-255) B4: Red
- *(0-255)
- * No check done on the boundaries
- */
- void setLeds(uint16_t startIdx, uint16_t endIdx, uint8_t* colors);
-
- /**
- * Outputs the current LED data to the SPI bus
- * Note: Only required if batch mode is set to TRUE
- *
- */
- void pushState();
-
- private:
- mraa::Spi* m_spi;
- mraa::Gpio* m_csnPinCtx;
-
- uint16_t m_ledCount;
- uint8_t* m_leds;
- uint16_t m_frameLength;
-
- bool m_batchMode;
-
- mraa::Result CSOn();
- mraa::Result CSOff();
-};
-}
diff --git a/peripheral/libupm/src/apa102/javaupm_apa102.i b/peripheral/libupm/src/apa102/javaupm_apa102.i
deleted file mode 100644
index 372a228..0000000
--- a/peripheral/libupm/src/apa102/javaupm_apa102.i
+++ /dev/null
@@ -1,30 +0,0 @@
-%module javaupm_apa102
-
-%include "../upm.i"
-%include "typemaps.i"
-
-%typemap(jtype) (uint8_t *colors) "byte[]"
-%typemap(jstype) (uint8_t *colors) "byte[]"
-%typemap(jni) (uint8_t *colors) "jbyteArray"
-%typemap(javain) (uint8_t *colors) "$javainput"
-
-%typemap(in) (uint8_t *colors) {
- $1 = (uint8_t*)JCALL2(GetByteArrayElements, jenv, $input, NULL);
-}
-
-%{
- #include "apa102.hpp"
-%}
-
-%include "apa102.hpp"
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_apa102");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/apa102/jsupm_apa102.i b/peripheral/libupm/src/apa102/jsupm_apa102.i
deleted file mode 100644
index ae40e2f..0000000
--- a/peripheral/libupm/src/apa102/jsupm_apa102.i
+++ /dev/null
@@ -1,19 +0,0 @@
-%module jsupm_apa102
-
-%include "../upm.i"
-%inline %{
- #include <node_buffer.h>
-%}
-
-%typemap(in) (uint8_t *colors) {
- if (!node::Buffer::HasInstance($input)) {
- SWIG_exception_fail(SWIG_ERROR, "Expected a node Buffer");
- }
- $1 = (uint8_t*) node::Buffer::Data($input);
-}
-
-%include "apa102.hpp"
-
-%{
- #include "apa102.hpp"
-%}
diff --git a/peripheral/libupm/src/apa102/pyupm_apa102.i b/peripheral/libupm/src/apa102/pyupm_apa102.i
deleted file mode 100644
index c6fe5ac..0000000
--- a/peripheral/libupm/src/apa102/pyupm_apa102.i
+++ /dev/null
@@ -1,25 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-
-%module pyupm_apa102
-
-%include "../upm.i"
-
-%feature("autodoc", "3");
-
-// setLeds
-%typemap(in) (uint8_t *colors) {
- if (PyByteArray_Check($input)) {
- $1 = (uint8_t*) PyByteArray_AsString($input);
- } else {
- PyErr_SetString(PyExc_ValueError, "bytearray expected");
- return NULL;
- }
-}
-
-%include "apa102.hpp"
-
-%{
-
- #include "apa102.hpp"
-%}
diff --git a/peripheral/libupm/src/apds9002/CMakeLists.txt b/peripheral/libupm/src/apds9002/CMakeLists.txt
index 24d9e70..e006f8f 100644
--- a/peripheral/libupm/src/apds9002/CMakeLists.txt
+++ b/peripheral/libupm/src/apds9002/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "apds9002")
set (libdescription "upm apds9002 luminance module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/apds9002/apds9002.cxx b/peripheral/libupm/src/apds9002/apds9002.cxx
index b417d1b..cd3138e 100644
--- a/peripheral/libupm/src/apds9002/apds9002.cxx
+++ b/peripheral/libupm/src/apds9002/apds9002.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "apds9002.hpp"
+#include "apds9002.h"
using namespace upm;
diff --git a/peripheral/libupm/src/apds9002/apds9002.hpp b/peripheral/libupm/src/apds9002/apds9002.h
index 0c3a3d5..0c3a3d5 100644
--- a/peripheral/libupm/src/apds9002/apds9002.hpp
+++ b/peripheral/libupm/src/apds9002/apds9002.h
diff --git a/peripheral/libupm/src/apds9002/javaupm_apds9002.i b/peripheral/libupm/src/apds9002/javaupm_apds9002.i
index e994e0c..645e8f9 100644
--- a/peripheral/libupm/src/apds9002/javaupm_apds9002.i
+++ b/peripheral/libupm/src/apds9002/javaupm_apds9002.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "apds9002.hpp"
+ #include "apds9002.h"
%}
-%include "apds9002.hpp"
+%include "apds9002.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/apds9002/jsupm_apds9002.i b/peripheral/libupm/src/apds9002/jsupm_apds9002.i
index 0968aba..383f568 100644
--- a/peripheral/libupm/src/apds9002/jsupm_apds9002.i
+++ b/peripheral/libupm/src/apds9002/jsupm_apds9002.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "apds9002.hpp"
+ #include "apds9002.h"
%}
-%include "apds9002.hpp"
+%include "apds9002.h"
diff --git a/peripheral/libupm/src/apds9002/pyupm_apds9002.i b/peripheral/libupm/src/apds9002/pyupm_apds9002.i
index a4f7919..516f112 100644
--- a/peripheral/libupm/src/apds9002/pyupm_apds9002.i
+++ b/peripheral/libupm/src/apds9002/pyupm_apds9002.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "apds9002.hpp"
+%include "apds9002.h"
%{
- #include "apds9002.hpp"
+ #include "apds9002.h"
%}
diff --git a/peripheral/libupm/src/apds9930/CMakeLists.txt b/peripheral/libupm/src/apds9930/CMakeLists.txt
index 182a125..d534a79 100644
--- a/peripheral/libupm/src/apds9930/CMakeLists.txt
+++ b/peripheral/libupm/src/apds9930/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "apds9930")
set (libdescription "upm apds9930 sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/apds9930/apds9930.cxx b/peripheral/libupm/src/apds9930/apds9930.cxx
index 4b1084d..e365d4c 100644
--- a/peripheral/libupm/src/apds9930/apds9930.cxx
+++ b/peripheral/libupm/src/apds9930/apds9930.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "apds9930.hpp"
+#include "apds9930.h"
using namespace upm;
@@ -41,8 +41,7 @@ APDS9930::APDS9930(int device)
APDS9930::~APDS9930()
{
- if(m_iio)
- mraa_iio_close(m_iio);
+ // mraa_iio_stop(m_iio);
}
int
diff --git a/peripheral/libupm/src/apds9930/apds9930.hpp b/peripheral/libupm/src/apds9930/apds9930.h
index a5c3a81..a5c3a81 100644
--- a/peripheral/libupm/src/apds9930/apds9930.hpp
+++ b/peripheral/libupm/src/apds9930/apds9930.h
diff --git a/peripheral/libupm/src/apds9930/javaupm_apds9930.i b/peripheral/libupm/src/apds9930/javaupm_apds9930.i
index 2a7afb3..ca8aa53 100644
--- a/peripheral/libupm/src/apds9930/javaupm_apds9930.i
+++ b/peripheral/libupm/src/apds9930/javaupm_apds9930.i
@@ -2,9 +2,9 @@
%include "../upm.i"
%{
- #include "apds9930.hpp"
+ #include "apds9930.h"
%}
-%include "apds9930.hpp"
+%include "apds9930.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/apds9930/jsupm_apds9930.i b/peripheral/libupm/src/apds9930/jsupm_apds9930.i
index 8a22c0d..80e77af 100644
--- a/peripheral/libupm/src/apds9930/jsupm_apds9930.i
+++ b/peripheral/libupm/src/apds9930/jsupm_apds9930.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "apds9930.hpp"
+ #include "apds9930.h"
%}
-%include "apds9930.hpp"
+%include "apds9930.h"
diff --git a/peripheral/libupm/src/apds9930/pyupm_apds9930.i b/peripheral/libupm/src/apds9930/pyupm_apds9930.i
index e54fb2e..fb1f6c5 100644
--- a/peripheral/libupm/src/apds9930/pyupm_apds9930.i
+++ b/peripheral/libupm/src/apds9930/pyupm_apds9930.i
@@ -3,7 +3,7 @@
%feature("autodoc", "3");
-%include "apds9930.hpp"
+%include "apds9930.h"
%{
- #include "apds9930.hpp"
+ #include "apds9930.h"
%}
diff --git a/peripheral/libupm/src/at42qt1070/CMakeLists.txt b/peripheral/libupm/src/at42qt1070/CMakeLists.txt
index 6046158..8b48db8 100644
--- a/peripheral/libupm/src/at42qt1070/CMakeLists.txt
+++ b/peripheral/libupm/src/at42qt1070/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "at42qt1070")
set (libdescription "upm module for the Atmel AT42QT1070 QTouch sensor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/at42qt1070/at42qt1070.cxx b/peripheral/libupm/src/at42qt1070/at42qt1070.cxx
index fed9f38..f9207d2 100644
--- a/peripheral/libupm/src/at42qt1070/at42qt1070.cxx
+++ b/peripheral/libupm/src/at42qt1070/at42qt1070.cxx
@@ -28,7 +28,7 @@
#include <string>
#include <stdexcept>
-#include "at42qt1070.hpp"
+#include "at42qt1070.h"
using namespace upm;
using namespace std;
@@ -98,21 +98,13 @@ AT42QT1070::writeWord(uint8_t reg, uint16_t word)
uint8_t
AT42QT1070::readByte(uint8_t reg)
{
- int x = mraa_i2c_read_byte_data(m_i2c, reg);
- if (x != -1) {
- return (uint8_t) x;
- }
- return 0;
+ return mraa_i2c_read_byte_data(m_i2c, reg);
}
uint16_t
AT42QT1070::readWord(uint8_t reg)
{
- int x = mraa_i2c_read_word_data(m_i2c, reg);
- if (x != -1) {
- return (uint16_t) x;
- }
- return 0;
+ return mraa_i2c_read_word_data(m_i2c, reg);
}
uint8_t
diff --git a/peripheral/libupm/src/at42qt1070/at42qt1070.hpp b/peripheral/libupm/src/at42qt1070/at42qt1070.h
index 935a4bd..935a4bd 100644
--- a/peripheral/libupm/src/at42qt1070/at42qt1070.hpp
+++ b/peripheral/libupm/src/at42qt1070/at42qt1070.h
diff --git a/peripheral/libupm/src/at42qt1070/javaupm_at42qt1070.i b/peripheral/libupm/src/at42qt1070/javaupm_at42qt1070.i
index f387c4a..8aceab0 100644
--- a/peripheral/libupm/src/at42qt1070/javaupm_at42qt1070.i
+++ b/peripheral/libupm/src/at42qt1070/javaupm_at42qt1070.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "at42qt1070.hpp"
+ #include "at42qt1070.h"
%}
-%include "at42qt1070.hpp"
+%include "at42qt1070.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/at42qt1070/jsupm_at42qt1070.i b/peripheral/libupm/src/at42qt1070/jsupm_at42qt1070.i
index ac72d2d..9c47e46 100644
--- a/peripheral/libupm/src/at42qt1070/jsupm_at42qt1070.i
+++ b/peripheral/libupm/src/at42qt1070/jsupm_at42qt1070.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "at42qt1070.hpp"
+ #include "at42qt1070.h"
%}
-%include "at42qt1070.hpp"
+%include "at42qt1070.h"
diff --git a/peripheral/libupm/src/at42qt1070/pyupm_at42qt1070.i b/peripheral/libupm/src/at42qt1070/pyupm_at42qt1070.i
index d3446b5..21897ed 100644
--- a/peripheral/libupm/src/at42qt1070/pyupm_at42qt1070.i
+++ b/peripheral/libupm/src/at42qt1070/pyupm_at42qt1070.i
@@ -9,7 +9,7 @@
%include "at42qt1070_doc.i"
#endif
-%include "at42qt1070.hpp"
+%include "at42qt1070.h"
%{
- #include "at42qt1070.hpp"
+ #include "at42qt1070.h"
%}
diff --git a/peripheral/libupm/src/bacnetmstp/CMakeLists.txt b/peripheral/libupm/src/bacnetmstp/CMakeLists.txt
deleted file mode 100644
index 8f23f7e..0000000
--- a/peripheral/libupm/src/bacnetmstp/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-set (libname "bacnetmstp")
-set (libdescription "upm driver module for BACnet MS/TP devices")
-set (module_src ${libname}.cxx device-client.c bacnetutil.cxx)
-set (module_hpp ${libname}.hpp bacnetutil.hpp)
-
-pkg_check_modules(BACNET libbacnet)
-if (BACNET_FOUND)
- set (reqlibname "libbacnet")
- include_directories(${BACNET_INCLUDE_DIRS})
- upm_module_init()
- add_dependencies(${libname} ${BACNET_LIBRARIES})
- target_link_libraries(${libname} ${BACNET_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
- if (BUILDSWIG)
- if (BUILDSWIGNODE)
- swig_link_libraries (jsupm_${libname} ${BACNET_LIBRARIES})
- endif()
- if (BUILDSWIGPYTHON)
- swig_link_libraries (pyupm_${libname} ${BACNET_LIBRARIES})
- endif()
- if (BUILDSWIGJAVA)
- swig_link_libraries (javaupm_${libname} ${BACNET_LIBRARIES})
- endif()
- endif()
-endif ()
diff --git a/peripheral/libupm/src/bacnetmstp/bacnetmstp.cxx b/peripheral/libupm/src/bacnetmstp/bacnetmstp.cxx
deleted file mode 100644
index 3e6f6e5..0000000
--- a/peripheral/libupm/src/bacnetmstp/bacnetmstp.cxx
+++ /dev/null
@@ -1,936 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-#include <sstream>
-
-#include "bacnetmstp.hpp"
-#include "handlers.h"
-#include "client.h"
-#include "txbuf.h"
-#include "mstpdef.h"
-
-using namespace upm;
-using namespace std;
-
-// our singleton instance
-BACNETMSTP* BACNETMSTP::m_instance = 0;
-
-BACNETMSTP::BACNETMSTP()
-{
- // set defaults here
- m_maxInfoFrames = DEFAULT_MAX_INFO_FRAMES;
- m_maxMaster = DEFAULT_MAX_MASTER;
- m_baudRate = 38400;
- m_macAddr = DEFAULT_MAX_MASTER;
-
- m_initialized = false;
-
- // 60 sec, for MS/TP
- m_adpuTimeoutMS = 60000;
-
- m_deviceInstanceID = BACNET_MAX_INSTANCE;
-
- memset(m_rxBuffer, 0, MAX_MPDU);
-
- m_returnedValue.clear();
- m_targetAddress = {0};
- m_invokeID = 0;
- m_errorDetected = false;
-
- setDebug(false);
-}
-
-BACNETMSTP::~BACNETMSTP()
-{
- if (m_initialized)
- datalink_cleanup();
-}
-
-void BACNETMSTP::setDebug(bool enable)
-{
- m_debugging = enable;
-}
-
-void BACNETMSTP::clearErrors()
-{
- m_errorType = BACERR_TYPE_NONE;
-
- // empty out all of our error/reject/abort info
- m_rejectReason = REJECT_REASON_OTHER;
- m_rejectString.clear();
-
- m_abortReason = ABORT_REASON_OTHER;
- m_abortString.clear();
-
- m_errorClass = ERROR_CLASS_DEVICE;
- m_errorCode = ERROR_CODE_OTHER;
- m_errorString.clear();
-
- m_upmErrorString.clear();
-}
-
-void BACNETMSTP::handlerError(BACNET_ADDRESS* src,
- uint8_t invoke_id,
- BACNET_ERROR_CLASS error_class,
- BACNET_ERROR_CODE error_code)
-{
- if (instance()->m_debugging)
- cerr << __FUNCTION__ << ": entered" << endl;
-
- if (address_match(&(instance()->m_targetAddress), src) &&
- (invoke_id == instance()->m_invokeID))
- {
- instance()->m_errorType = BACERR_TYPE_ERROR;
- instance()->m_errorClass = error_class;
- instance()->m_errorCode = error_code;
- instance()->m_errorString =
- bactext_error_class_name((int)error_class)
- + string(": ") + bactext_error_code_name((int)error_code);
-
- instance()->m_errorDetected = true;
- }
-}
-
-void BACNETMSTP::handlerAbort(BACNET_ADDRESS* src,
- uint8_t invoke_id,
- uint8_t abort_reason,
- bool server)
-{
- (void)server; // not used
-
- if (instance()->m_debugging)
- cerr << __FUNCTION__ << ": entered" << endl;
-
- if (address_match(&(instance()->m_targetAddress), src) &&
- (invoke_id == instance()->m_invokeID))
- {
- instance()->m_errorType = BACERR_TYPE_ABORT;
- instance()->m_abortReason = abort_reason;
- instance()->m_abortString =
- bactext_abort_reason_name((int)abort_reason);
-
- instance()->m_errorDetected = true;
- }
-}
-
-void BACNETMSTP::handlerReject(BACNET_ADDRESS* src,
- uint8_t invoke_id,
- uint8_t reject_reason)
-{
- if (instance()->m_debugging)
- cerr << __FUNCTION__ << ": entered" << endl;
-
- if (address_match(&(instance()->m_targetAddress), src) &&
- (invoke_id == instance()->m_invokeID))
- {
- instance()->m_errorType = BACERR_TYPE_REJECT;
- instance()->m_rejectReason = reject_reason;
- instance()->m_rejectString =
- bactext_reject_reason_name((int)reject_reason);
-
- instance()->m_errorDetected = true;
- }
-}
-
-void BACNETMSTP::handlerReadPropertyAck(uint8_t* service_request,
- uint16_t service_len,
- BACNET_ADDRESS* src,
- BACNET_CONFIRMED_SERVICE_ACK_DATA* service_data)
-{
- int len = 0;
- BACNET_READ_PROPERTY_DATA data;
-
- // clear our stored data
- instance()->m_returnedValue.clear();
-
- BACNET_APPLICATION_DATA_VALUE value;
- memset((void *)&value, 0, sizeof(value));
-
- uint8_t *application_data = 0;
- int application_data_len = 0;
-
- if (address_match(&(instance()->m_targetAddress), src) &&
- (service_data->invoke_id == instance()->m_invokeID))
- {
- if (instance()->m_debugging)
- cerr << __FUNCTION__ << ": got readProp ack" << endl;
-
- len = rp_ack_decode_service_request(service_request, service_len,
- &data);
-
- // store any delivered data elements
- if (len > 0)
- {
- application_data_len = data.application_data_len;
- application_data = data.application_data;
-
- while (true)
- {
- len = bacapp_decode_application_data(application_data,
- application_data_len,
- &value);
- if (len > 0)
- {
- // store a copy
- instance()->m_returnedValue.push_back(value);
-
- if (len < application_data_len)
- {
- // there is more data
- application_data += len;
- application_data_len -= len;
- }
- else
- {
- // we are done
- break;
- }
- }
- else
- {
- // shouldn't happen?
- cerr << __FUNCTION__ << ": decode app data failed" << endl;
- break;
- }
- }
- }
- }
-
- if (instance()->m_debugging)
- cerr << __FUNCTION__ << ": STORED "
- << instance()->m_returnedValue.size()
- << " data elements." << endl;
-}
-
-void BACNETMSTP::handlerWritePropertyAck(BACNET_ADDRESS* src,
- uint8_t invoke_id)
-{
- if (address_match(&(instance()->m_targetAddress), src) &&
- (invoke_id == instance()->m_invokeID))
- {
- if (instance()->m_debugging)
- cerr << __FUNCTION__ << ": got writeProp ack" << endl;
- }
-}
-
-void BACNETMSTP::initServiceHandlers()
-{
- // this is in device-client.c
- Device_Init(NULL);
-
- // These are service requests we must handle from other masters
-
- // we need to handle who-is to support dynamic device binding to us
- apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_WHO_IS, handler_who_is);
-
- // handle i-am to support binding to other devices
- apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_I_AM, handler_i_am_bind);
-
- // set the handler for all the services we don't implement
-
- // It is required to send the proper reject message...
- apdu_set_unrecognized_service_handler_handler(handler_unrecognized_service);
-
- // we must implement read property (it's required)
- apdu_set_confirmed_handler(SERVICE_CONFIRMED_READ_PROPERTY,
- handler_read_property);
-
- // These are related to requests we make
-
- // handle the data coming back from confirmed readProp requests
- apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROPERTY,
- handlerReadPropertyAck);
-
- // handle the simple ack for confirmed writeProp requests
- apdu_set_confirmed_simple_ack_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
- handlerWritePropertyAck);
-
- // handle any errors coming back
- apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROPERTY, handlerError);
- apdu_set_abort_handler(handlerAbort);
- apdu_set_reject_handler(handlerReject);
-}
-
-BACNETMSTP* BACNETMSTP::instance()
-{
- if (!m_instance)
- m_instance = new BACNETMSTP;
-
- return m_instance;
-}
-
-void BACNETMSTP::initMaster(std::string port, int baudRate,
- int deviceInstanceID, int macAddr, int maxMaster,
- int maxInfoFrames)
-{
- // first some checking
-
- // if we are already initialized, then it's too late to change things now
- if (m_initialized)
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": Instance is already initialized, ignored."
- << endl;
- return;
- }
-
- // baudrate
- // The standard allows (as of at least 2010) the following baud rates
- if ( !(baudRate == 9600 || baudRate == 19200 || baudRate == 38400
- || baudRate == 57600 || baudRate == 76800 || baudRate == 115200) )
- {
- throw std::invalid_argument(std::string(__FUNCTION__)
- + ": baudRate must be 9600, 19200, 38400, "
- + " 57600, 76800, or 115200");
- }
-
- // maxMaster
- // maxMaster must be less than or equal to 127
- if (maxMaster < 0 || maxMaster > DEFAULT_MAX_MASTER)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": maxMaster must be between 0 and "
- + std::to_string(DEFAULT_MAX_MASTER));
- }
-
- // As a master ourselves, we must have a MAC address also within the
- // constraints of maxMaster
- if (macAddr < 0 || macAddr > DEFAULT_MAX_MASTER)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": macAddr must be between 0 and "
- + std::to_string(DEFAULT_MAX_MASTER));
- }
-
- // this should be unique on the network
- if (deviceInstanceID >= BACNET_MAX_INSTANCE)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": deviceInstanceID must be less than "
- + std::to_string(BACNET_MAX_INSTANCE)
- + ", and must be unique on the network");
- }
-
- m_port = port;
- m_baudRate = baudRate;
- m_maxInfoFrames = maxInfoFrames;
- m_macAddr = macAddr;
- m_maxMaster = maxMaster;
- m_deviceInstanceID = deviceInstanceID;
-
- // Let the fun begin...
-
- // setup our info
- Device_Set_Object_Instance_Number(m_deviceInstanceID);
- address_init();
-
- initServiceHandlers();
-
- dlmstp_set_max_info_frames(m_maxInfoFrames);
- dlmstp_set_max_master(m_maxMaster);
- dlmstp_set_baud_rate(m_baudRate);
- dlmstp_set_mac_address(m_macAddr);
-
- // FIXME - allow to change?
- apdu_timeout_set(m_adpuTimeoutMS);
-
- // Ordinarily, I'd like to check the return value of this function,
- // but even in the face of errors, it always returns true :( This
- // function starts the ball rolling, and initializes the Master FSM
- // thread. Unfortunately, it doesn't appear this can be turned back
- // off without exiting the application.
- datalink_init((char *)port.c_str());
-
- m_initialized = true;
-}
-
-bool BACNETMSTP::dispatchRequest()
-{
- uint16_t pdu_len = 0;
- unsigned timeout = 100; // milliseconds
- unsigned max_apdu = 0;
- time_t elapsed_seconds = 0;
- time_t last_seconds = 0;
- time_t current_seconds = 0;
- time_t timeout_seconds = 0;
- bool found = false;
-
- // address where message came from
- BACNET_ADDRESS src = {0};
-
- clearErrors();
- m_errorDetected = false;
-
- uint32_t targetDeviceInstanceID = BACNET_MAX_INSTANCE;
-
- switch (m_command.cmd)
- {
- case BACCMD_READ_PROPERTY:
- targetDeviceInstanceID = m_command.readPropArgs.targetDeviceInstanceID;
- break;
-
- case BACCMD_WRITE_PROPERTY:
- targetDeviceInstanceID = m_command.writePropArgs.targetDeviceInstanceID;
- break;
-
- case BACCMD_NONE:
- {
- m_errorType = BACERR_TYPE_UPM;
- m_upmErrorString = string(__FUNCTION__) +
- ": called with BACCMD_NONE, ignoring";
-
- return true; // error
- }
-
- break;
-
- default:
- {
- // should this throw?
- m_errorType = BACERR_TYPE_UPM;
- m_upmErrorString = string(__FUNCTION__) +
- ": internal error, called with unknown command, ignoring";
-
- return true; // error
- }
-
- break;
- }
-
- // timeouts
- last_seconds = time(NULL);
- timeout_seconds = (apdu_timeout() / 1000) * apdu_retries();
-
- // we use 0 to indicate that request hasn't been made yet, so that
- // it will be made once the address is bound.
- m_invokeID = 0;
-
- // bind to the device first.
- found = address_bind_request(targetDeviceInstanceID, &max_apdu,
- &(instance()->m_targetAddress));
-
- if (!found)
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": Address not found, Sending WhoIs..." << endl;
-
- Send_WhoIs(targetDeviceInstanceID, targetDeviceInstanceID);
- }
- else
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": Address was found" << endl;
- }
-
- // loop until either we get our data, an error occurs, or we timeout
- while (true)
- {
- current_seconds = time(NULL);
-
- // at least one second has passed
- if (current_seconds != last_seconds)
- tsm_timer_milliseconds((uint16_t) ((current_seconds -
- last_seconds) * 1000));
- if (m_errorDetected)
- break;
-
- // we have to wait until the address is bound before proceeding
- if (!found)
- {
- found =
- address_bind_request(targetDeviceInstanceID, &max_apdu,
- &(instance()->m_targetAddress));
- }
-
- if (found)
- {
- // address is bound, and we have not sent our request yet. Make it so.
- if (m_invokeID == 0)
- {
- switch (m_command.cmd)
- {
- case BACCMD_READ_PROPERTY:
- m_invokeID =
- Send_Read_Property_Request(targetDeviceInstanceID,
- m_command.readPropArgs.objType,
- m_command.readPropArgs.objInstance,
- m_command.readPropArgs.objProperty,
- m_command.readPropArgs.arrayIndex);
- if (m_debugging)
- cerr << __FUNCTION__
- << ": Called Send_Read_Property_Request(), m_invokeID = "
- << (int)m_invokeID << endl;
-
- break;
-
- case BACCMD_WRITE_PROPERTY:
- m_invokeID =
- Send_Write_Property_Request(targetDeviceInstanceID,
- m_command.writePropArgs.objType,
- m_command.writePropArgs.objInstance,
- m_command.writePropArgs.objProperty,
- m_command.writePropArgs.propValue,
- m_command.writePropArgs.propPriority,
- m_command.writePropArgs.arrayIndex);
- if (m_debugging)
- cerr << __FUNCTION__
- << ": Called Send_Write_Property_Request(), m_invokeID = "
- << (int)m_invokeID << endl;
-
- break;
- }
-
- }
- else if (tsm_invoke_id_free(m_invokeID))
- {
- // transaction completed successfully
-
- if (m_debugging)
- cerr << __FUNCTION__ << ": Success, m_invokeID = "
- << (int)m_invokeID << endl;
-
- break;
- }
- else if (tsm_invoke_id_failed(m_invokeID))
- {
- // transaction state machine failed, most likely timeout
- tsm_free_invoke_id(m_invokeID);
-
- m_errorType = BACERR_TYPE_UPM;
- m_upmErrorString = string(__FUNCTION__) +
- ": TSM Timed Out.";
-
- if (m_debugging)
- cerr << m_upmErrorString << endl;
-
- m_errorDetected = true;
-
- break;
- }
- }
- else
- {
- // still waiting to bind. timeout if we've waited too long.
- elapsed_seconds += (current_seconds - last_seconds);
- if (elapsed_seconds > timeout_seconds)
- {
- m_errorType = BACERR_TYPE_UPM;
- m_upmErrorString = string(__FUNCTION__) +
- ": Timed out waiting to bind address.";
-
- // We output this error unconditionally as this is an
- // error you will get if you supply a non-existant
- // Device Obeject Instance ID.
-
- cerr << m_upmErrorString << endl;
- cerr << __FUNCTION__
- << ": Did you supply the correct Device Object Instance ID "
- << "for your device?"
- << endl;
-
- m_errorDetected = true;
- break;
- }
- }
-
- // returns 0 bytes on timeout
- pdu_len = datalink_receive(&src, m_rxBuffer, MAX_MPDU, timeout);
-
- // process the packet if valid. This will call our handlers as needed.
- if (pdu_len)
- npdu_handler(&src, m_rxBuffer, pdu_len);
-
- // keep track of time for next check
- last_seconds = current_seconds;
- }
-
- return m_errorDetected;
-}
-
-bool BACNETMSTP::readProperty(uint32_t targetDeviceInstanceID,
- BACNET_OBJECT_TYPE objType,
- uint32_t objInstance,
- BACNET_PROPERTY_ID objProperty,
- uint32_t arrayIndex)
-{
- // some sanity checking...
- if (objInstance >= BACNET_MAX_INSTANCE)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": objInstance must be less than "
- + std::to_string(BACNET_MAX_INSTANCE));
- }
-
- // fill in the command structure and dispatch
- m_command.cmd = BACCMD_READ_PROPERTY;
- m_command.readPropArgs.targetDeviceInstanceID = targetDeviceInstanceID;
- m_command.readPropArgs.objType = objType;
- m_command.readPropArgs.objInstance = objInstance;
- m_command.readPropArgs.objProperty = objProperty;
- m_command.readPropArgs.arrayIndex = arrayIndex;
-
- if (m_debugging)
- cerr << __FUNCTION__ << ": calling dispatchRequest()..." << endl;
-
- // send it off
- bool error = dispatchRequest();
-
- // clear the command to avoid accidental re-calls
- m_command.cmd = BACCMD_NONE;
-
- return error;
-}
-
-bool BACNETMSTP::writeProperty(uint32_t targetDeviceInstanceID,
- BACNET_OBJECT_TYPE objType,
- uint32_t objInstance,
- BACNET_PROPERTY_ID objProperty,
- BACNET_APPLICATION_DATA_VALUE* propValue,
- uint8_t propPriority,
- int32_t arrayIndex)
-{
- // some sanity checking...
- if (objInstance >= BACNET_MAX_INSTANCE)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": objInstance must be less than "
- + std::to_string(BACNET_MAX_INSTANCE));
- }
-
- // fill in the command structure and dispatch
- m_command.cmd = BACCMD_WRITE_PROPERTY;
- m_command.writePropArgs.targetDeviceInstanceID = targetDeviceInstanceID;
- m_command.writePropArgs.objType = objType;
- m_command.writePropArgs.objInstance = objInstance;
- m_command.writePropArgs.objProperty = objProperty;
- m_command.writePropArgs.propValue = propValue;
- m_command.writePropArgs.propPriority = propPriority;
- m_command.writePropArgs.arrayIndex = arrayIndex;
-
- if (m_debugging)
- cerr << __FUNCTION__ << ": calling dispatchRequest()..." << endl;
-
- // send it off
- bool error = dispatchRequest();
-
- // clear the command to avoid accidental re-calls
- m_command.cmd = BACCMD_NONE;
-
- return error;
-}
-
-BACNET_APPLICATION_DATA_VALUE BACNETMSTP::getData(int index)
-{
- return m_returnedValue.at(index);
-}
-
-int BACNETMSTP::getDataNumElements()
-{
- return m_returnedValue.size();
-}
-
-uint8_t BACNETMSTP::getDataType(int index)
-{
- return m_returnedValue.at(index).tag;
-}
-
-float BACNETMSTP::getDataTypeReal(int index)
-{
- if (getDataType(index) == BACNET_APPLICATION_TAG_REAL)
- return m_returnedValue.at(index).type.Real;
- else
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": Not of Real type, trying to convert..." << endl;
-
- // try to convert or throw
- switch (getDataType(index))
- {
- case BACNET_APPLICATION_TAG_BOOLEAN:
- return (getDataTypeBoolean(index) ? 1.0 : 0.0);
- case BACNET_APPLICATION_TAG_UNSIGNED_INT:
- return float(getDataTypeUnsignedInt(index));
- case BACNET_APPLICATION_TAG_SIGNED_INT:
- return float(getDataTypeSignedInt(index));
- default:
- throw std::invalid_argument(std::string(__FUNCTION__)
- + ": data type ("
- + std::to_string(int(getDataType(index)))
- + ") is not convertible to Real");
- }
- }
-}
-
-bool BACNETMSTP::getDataTypeBoolean(int index)
-{
- if (getDataType(index) == BACNET_APPLICATION_TAG_BOOLEAN)
- return ((m_returnedValue.at(index).type.Boolean) ? true : false);
- else
- throw std::invalid_argument(std::string(__FUNCTION__)
- + ": data type ("
- + std::to_string(int(getDataType(index)))
- + ") is not convertible to Bool");
-}
-
-unsigned int BACNETMSTP::getDataTypeUnsignedInt(int index)
-{
- if (getDataType(index) == BACNET_APPLICATION_TAG_UNSIGNED_INT)
- return m_returnedValue.at(index).type.Unsigned_Int;
- else
- throw std::invalid_argument(std::string(__FUNCTION__)
- + ": data type ("
- + std::to_string(int(getDataType(index)))
- + ") is not convertible to UnsignedInt");
-}
-
-int BACNETMSTP::getDataTypeSignedInt(int index)
-{
- if (getDataType(index) == BACNET_APPLICATION_TAG_SIGNED_INT)
- return m_returnedValue.at(index).type.Signed_Int;
- else
- throw std::invalid_argument(std::string(__FUNCTION__)
- + ": data type ("
- + std::to_string(int(getDataType(index)))
- + ") is not convertible to SignedInt");
-}
-
-#if defined(BACAPP_DOUBLE)
-double BACNETMSTP::getDataTypeDouble(int index)
-{
- if (getDataType() == BACNET_APPLICATION_TAG_DOUBLE)
- return m_returnedValue.at(index).type.Double;
- else
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": Not of Double type, trying to convert..." << endl;
-
- // try to convert or throw
- switch (getDataType(index))
- {
- case BACNET_APPLICATION_TAG_REAL:
- return double(getDataTypeReal(index));
- case BACNET_APPLICATION_TAG_BOOLEAN:
- return (getDataTypeBoolean(index) ? 1.0 : 0.0);
- case BACNET_APPLICATION_TAG_UNSIGNED_INT:
- return double(getDataTypeUnsignedInt(index));
- case BACNET_APPLICATION_TAG_SIGNED_INT:
- return double(getDataTypeSignedInt(index));
- default:
- throw std::invalid_argument(std::string(__FUNCTION__)
- + ": data type ("
- + std::to_string(int(getDataType(index)))
- + ") is not convertible to Double");
- }
- }
-}
-#endif // BACAPP_DOUBLE
-
-unsigned int BACNETMSTP::getDataTypeEnum(int index)
-{
- if (getDataType(index) == BACNET_APPLICATION_TAG_ENUMERATED)
- return m_returnedValue.at(index).type.Enumerated;
- else
- throw std::invalid_argument(std::string(__FUNCTION__)
- + ": data type ("
- + std::to_string(int(getDataType(index)))
- + ") is not convertible to Enum");
-}
-
-std::string BACNETMSTP::getDataTypeString(int index)
-{
- string retval;
-
- // Here, we can try to accomodate all the types
- switch(getDataType(index))
- {
- case BACNET_APPLICATION_TAG_REAL:
- retval = std::to_string(getDataTypeReal(index));
- break;
-
-#if defined(BACAPP_DOUBLE)
- case BACNET_APPLICATION_TAG_DOUBLE:
- retval = std::to_string(getDataTypeDouble(index));
- break;
-#endif // BACAPP_DOUBLE
-
- case BACNET_APPLICATION_TAG_UNSIGNED_INT:
- retval = std::to_string(getDataTypeUnsignedInt(index));
- break;
-
- case BACNET_APPLICATION_TAG_SIGNED_INT:
- retval = std::to_string(getDataTypeSignedInt(index));
- break;
-
- case BACNET_APPLICATION_TAG_BOOLEAN:
- retval = (getDataTypeBoolean(index) ? string("true") : string("false"));
- break;
-
- case BACNET_APPLICATION_TAG_CHARACTER_STRING:
- retval = string(characterstring_value(&m_returnedValue.at(index).type.Character_String),
-
- characterstring_length(&m_returnedValue.at(index).type.Character_String));
- break;
-
- case BACNET_APPLICATION_TAG_OCTET_STRING:
- {
- string tmpstr((char *)octetstring_value(&m_returnedValue.at(index).type.Octet_String),
-
- octetstring_length(&m_returnedValue.at(index).type.Octet_String));
- retval = string2HexString(tmpstr);
- }
-
- break;
-
- case BACNET_APPLICATION_TAG_BIT_STRING:
- {
- int len = bitstring_bits_used(&m_returnedValue.at(index).type.Bit_String);
-
- for (int i=0; i<len; i++)
- {
- if (bitstring_bit(&m_returnedValue.at(index).type.Bit_String,
- uint8_t(i)))
- retval += "1";
- else
- retval += "0";
-
- if (i != 0 && ((i % 8) == 0))
- retval += " ";
- }
- }
-
- break;
-
- default:
- throw std::invalid_argument(std::string(__FUNCTION__)
- + ": data type ("
- + std::to_string(int(getDataType(index)))
- + ") is not convertible to String");
- break;
- }
-
- return retval;
-}
-
-BACNET_APPLICATION_DATA_VALUE BACNETMSTP::createDataReal(float value)
-{
- BACNET_APPLICATION_DATA_VALUE data;
-
- memset(&data, 0, sizeof(BACNET_APPLICATION_DATA_VALUE));
-
- data.tag = BACNET_APPLICATION_TAG_REAL;
- data.type.Real = value;
-
- return data;
-}
-
-BACNET_APPLICATION_DATA_VALUE BACNETMSTP::createDataBool(bool value)
-{
- BACNET_APPLICATION_DATA_VALUE data;
-
- memset(&data, 0, sizeof(BACNET_APPLICATION_DATA_VALUE));
-
- data.tag = BACNET_APPLICATION_TAG_BOOLEAN;
- data.type.Boolean = value;
-
- return data;
-}
-
-BACNET_APPLICATION_DATA_VALUE BACNETMSTP::createDataSignedInt(int value)
-{
- BACNET_APPLICATION_DATA_VALUE data;
-
- memset(&data, 0, sizeof(BACNET_APPLICATION_DATA_VALUE));
-
- data.tag = BACNET_APPLICATION_TAG_SIGNED_INT;
- data.type.Signed_Int = value;
-
- return data;
-}
-
-BACNET_APPLICATION_DATA_VALUE BACNETMSTP::createDataUnsignedInt(unsigned int value)
-{
- BACNET_APPLICATION_DATA_VALUE data;
-
- memset(&data, 0, sizeof(BACNET_APPLICATION_DATA_VALUE));
-
- data.tag = BACNET_APPLICATION_TAG_UNSIGNED_INT;
- data.type.Unsigned_Int = value;
-
- return data;
-}
-
-BACNET_APPLICATION_DATA_VALUE BACNETMSTP::createDataString(string value)
-{
- if (value.size() > (MAX_CHARACTER_STRING_BYTES - 1))
- {
- throw std::invalid_argument(std::string(__FUNCTION__)
- + ": value must be less than or equal to "
- + std::to_string(MAX_CHARACTER_STRING_BYTES - 1)
- + " characters long");
- }
-
- BACNET_APPLICATION_DATA_VALUE data;
-
- memset(&data, 0, sizeof(BACNET_APPLICATION_DATA_VALUE));
-
- data.tag = BACNET_APPLICATION_TAG_CHARACTER_STRING;
-
- characterstring_init_ansi(&data.type.Character_String, value.c_str());
-
- return data;
-}
-
-BACNET_APPLICATION_DATA_VALUE BACNETMSTP::createDataEnum(uint32_t value)
-{
- BACNET_APPLICATION_DATA_VALUE data;
-
- memset(&data, 0, sizeof(BACNET_APPLICATION_DATA_VALUE));
-
- data.tag = BACNET_APPLICATION_TAG_ENUMERATED;
- data.type.Enumerated = value;
-
- return data;
-}
-
-string BACNETMSTP::string2HexString(string input)
-{
- static const char* const lut = "0123456789abcdef";
- size_t len = input.size();
-
- string output;
- output.reserve(3 * len);
- for (size_t i = 0; i < len; ++i)
- {
- const unsigned char c = input[i];
- output.push_back(lut[c >> 4]);
- output.push_back(lut[c & 15]);
- output.push_back(' ');
- }
-
- return output;
-}
diff --git a/peripheral/libupm/src/bacnetmstp/bacnetmstp.hpp b/peripheral/libupm/src/bacnetmstp/bacnetmstp.hpp
deleted file mode 100644
index 8001dba..0000000
--- a/peripheral/libupm/src/bacnetmstp/bacnetmstp.hpp
+++ /dev/null
@@ -1,754 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <vector>
-
-// we only support a BACnet RS-485 MS/TP datalink
-#define BACDL_MSTP 1
-#undef BACDL_ALL
-
-// get a variety of bacnet-stack includes...
-#include "bacdef.h"
-#include "config.h"
-#include "bactext.h"
-#include "bacerror.h"
-#include "iam.h"
-#include "arf.h"
-#include "tsm.h"
-#include "address.h"
-#include "npdu.h"
-#include "apdu.h"
-#include "device.h"
-#include "datalink.h"
-#include "whois.h"
-#include "mstpdef.h"
-#include "dlmstp.h"
-
-
-namespace upm {
-
- /**
- * @brief BACNETMSTP base class
- * @defgroup bacnetmstp libupm-bacnetmstp
- * @ingroup uart
- */
-
- /**
- * @library bacnetmstp
- * @sensor bacnetmstp
- * @comname UPM API for BACNET MS/TP communications
- * @con uart
- * @web http://bacnet.sourceforge.net/
- * @brief UPM API for BACNETMSTP
- *
- * This is a singleton class that provides services to UPM BACnet
- * drivers (like E50HX) based on the bacnet-stack at
- * http://bacnet.sourceforge.net . This class is implemented as a
- * singleton due to the fact that the bacnet-stack implementation
- * does not currently allow multiple simultaneous datalinks. We are
- * using 0.8.3 of bacnet-stack. In the future this restriction may
- * be lifted depending on bacnet-stack, but for now, you are
- * stuck with only a single BACnet MS/TP datalink.
- *
- * This driver is not intended to be used by end users. It is
- * intended for use with other UPM drivers that require access to a
- * BACnet MS/TP (Master Slave/Token Passing) network over RS-485.
- *
- * For this reason, no examples are provided. If you wish to
- * implement your own BACnet MS/TP driver, please look at the E50HX
- * driver to see how this class can be used.
- *
- * Currently, only readProperty and writeProperty BACnet requests
- * are supported. In the future, any other BACnet requests could be
- * supported as well. readProperty and writeProperty should provide
- * most of what you will need when communicating with BACnet
- * devices. Since the source code is open, feel free to add other
- * services as you see fit :)
- *
- * In order to make requests over an MS/TP network, you must be a
- * BACnet master. initMaster() is responsible for configuring your
- * underlying RS-485 network and starting a Master FSM (finite state
- * machine) thread that will be responsible for identifying other
- * Masters on the network and negotiating token passing. Your
- * master can only transmit when it has the token.
- *
- * Fortunately, all of these messy details are handled for you by
- * this class, or the underlying bacnet-stack library this class
- * relies on.
-
- */
-
- class BACNETMSTP {
- // Constructor and destructor are protected
-
- public:
-
- // error types
- typedef enum {
- BACERR_TYPE_NONE = 0,
- BACERR_TYPE_REJECT,
- BACERR_TYPE_ABORT,
- BACERR_TYPE_ERROR,
- BACERR_TYPE_UPM
- } BACERR_TYPE_T;
-
- // command types we currently support
- typedef enum {
- BACCMD_NONE = 0,
- BACCMD_READ_PROPERTY,
- BACCMD_WRITE_PROPERTY
- } BACCMD_TYPE_T;
-
- /**
- * Get our singleton instance, initializing it if neccessary. All
- * requests to this class should be done through this instance
- * accessor.
- *
- * @return static pointer to our class instance
- */
- static BACNETMSTP* instance();
-
- /**
- * This function initializes the underlying BACNETMSTP Master
- * singleton in the event it has not already been initialized. If
- * the BACNETMSTP Master singleton has already been initialized,
- * then this call will be ignored. There can be only one.
- *
- * @param port The serial port that the RS-485 interface is
- * connected to.
- * @param baudRate The baudrate of the RS-485 interface. All
- * devices on a BACnet RS-485 bus must run at the same baudrate.
- * Valid values are 9600, 19200, 38400, 57600, 76800, and 115200.
- * @param deviceInstanceNumber This is the unique Device Object
- * Instance number that will be used for our BACnet Master in
- * order to communicate over the BACnet interface. This number
- * must be between 1-4194302 and must be unique on the BACnet
- * network.
- * @param macAddr This is the MAC address of our BACnet Master.
- * It must be unique on the BACnet segment, and must be between
- * 1-127.
- * @param maxMaster This specifies to our Master the maximum MAC
- * address used by any other Masters on the BACnet network. This
- * must be between 1-127, the default is 127. Do not change this
- * unless you know what you are doing or you could introduce
- * token passing errors on the BACnet network.
- * @param maxInfoFrames This number specifies the maximum number
- * of transmissions (like requests for data) our Master is allowed
- * to make before passing the token to the next Master. The
- * default is 1.
- */
- void initMaster(std::string port, int baudRate, int deviceInstanceNumber,
- int macAddr, int maxMaster=DEFAULT_MAX_MASTER,
- int maxInfoFrames=1);
-
-
- /**
- * Perform a BACnet readProperty transaction. This function will
- * return when either the transaction has completed, or an error
- * has occurred. It requests the value of a property, belonging
- * to a specific object instance on a specific device.
- *
- * @param targetDeviceInstanceID This is the Device Object
- * Instance ID of the device to send the request to. This number
- * will be unique for every device on the network. An address
- * lookup will be performed the first time a request is made to a
- * device using the WhoHas BACnet service. The result will be
- * cached for further use.
- * @param objType This is the BACnet object type of the object you
- * wish to query. It should be one of the BACNET_OBJECT_TYPE
- * values.
- * @param objInstance This is the instance number of the Object
- * you wish to access. It is an integer starting from 1.
- * @param objProperty This is the property of the Object and
- * instance you wish to access. It should be one of the
- * BACNET_PROPERTY_ID values.
- * @param arrayIndex This specifies the index number of an array
- * property. The default is BACNET_ARRAY_ALL.
- * @return true if an error occurred, false otherwise.
- */
- bool readProperty(uint32_t targetDeviceInstanceID,
- BACNET_OBJECT_TYPE objType,
- uint32_t objInstance,
- BACNET_PROPERTY_ID objProperty,
- uint32_t arrayIndex=BACNET_ARRAY_ALL);
-
- /**
- * Perform a BACnet writeProperty transaction. This function will
- * return when either the transaction has completed, or an error
- * has occurred. It writes the supplied value to a property,
- * belonging to a specific object instance on a specific device.
- *
- * @param targetDeviceInstanceID This is the Device Object
- * Instance ID of the device to send the request to. This number
- * will be unique for every device on the network. An address
- * lookup will be performed the first time a request is made to a
- * device using the WhoHas BACnet service. The result will be
- * cached for further use.
- * @param objType This is the BACnet object type of the object you
- * wish to query. It should be one of the BACNET_OBJECT_TYPE
- * values.
- * @param objInstance This is the instance number of the Object
- * you wish to access. It is an integer starting from 1.
- * @param objProperty This is the property of the Object and
- * instance you wish to access. It should be one of the
- * BACNET_PROPERTY_ID values.
- * @param propValue This is a pointer to a
- * BACNET_APPLICATION_DATA_VALUE structure containg the data value
- * to write to the property. Use the createData*() methods to
- * properly create these structures.
- * @param propPriority This specifies the priority of a
- * commandable property. Leave it at the default unless you know
- * what you are doing. In addition, there is conflicting
- * information in the bacnet-stack documentation as to whether
- * this is even supported.
- * @param arrayIndex This specifies the index number of an array
- * property. The default is BACNET_ARRAY_ALL.
- * @return true if an error occurred, false otherwise.
- */
- bool writeProperty(uint32_t targetDeviceInstanceID,
- BACNET_OBJECT_TYPE objType,
- uint32_t objInstance,
- BACNET_PROPERTY_ID objProperty,
- BACNET_APPLICATION_DATA_VALUE* propValue,
- uint8_t propPriority=BACNET_NO_PRIORITY,
- int32_t arrayIndex=BACNET_ARRAY_ALL);
-
- /**
- * After a successful readProperty request, this method can be used
- * to return a BACNET_APPLICATION_DATA_VALUE structure containing
- * the returned data.
- *
- * @param index into the list of returned data. 0 (first) is the
- * default.
- * @return a BACNET_APPLICATION_DATA_VALUE structure containing
- * the returned data.
- */
- BACNET_APPLICATION_DATA_VALUE getData(int index=0);
-
- /**
- * After a successful readProperty request, this method can be
- * used to return the number of data elements returned. This will
- * usually be 1, unless reading an array.
- *
- * @return The number of data elements received.
- */
- int getDataNumElements();
-
- /**
- * After a successful readProperty request, this method can be
- * used to return the BACnet data type of the returned data. It
- * will be one of the BACNET_APPLICATION_TAG_* values.
- *
- * @param index into the list of returned data. 0 (first) is the
- * default.
- * @return A BACNET_APPLICATION_TAG_* value
- */
- uint8_t getDataType(int index=0);
-
- /**
- * After a successful readProperty request, this method can be
- * used to return the BACnet dataype of the returned data as a
- * Real. If the data type (getDataType()) is not a
- * BACNET_APPLICATION_TAG_REAL, and the value returned cannot be
- * safely converted, an exception is thrown.
- *
- * @param index into the list of returned data. 0 (first) is the
- * default.
- * @return A floating point value representing the returned data
- */
- float getDataTypeReal(int index=0);
-
- /**
- * After a successful readProperty request, this method can be
- * used to return the BACnet dataype of the returned data as a
- * Boolean. If the data type (getDataType()) is not a
- * BACNET_APPLICATION_TAG_BOOLEAN, and the value returned cannot
- * be safely converted, an exception is thrown.
- *
- * @param index into the list of returned data. 0 (first) is the
- * default.
- * @return A boolean value representing the returned data
- */
- bool getDataTypeBoolean(int index=0);
-
- /**
- * After a successful readProperty request, this method can be
- * used to return the BACnet dataype of the returned data as a
- * unsigned int. If the data type (getDataType()) is not a
- * BACNET_APPLICATION_TAG_UNSIGNED_INT, and the value returned
- * cannot be safely converted, an exception is thrown.
- *
- * @param index into the list of returned data. 0 (first) is the
- * default.
- * @return An unsigned int value representing the returned data
- */
- unsigned int getDataTypeUnsignedInt(int index=0);
-
- /**
- * After a successful readProperty request, this method can be
- * used to return the BACnet dataype of the returned data as a
- * signed int. If the data type (getDataType()) is not a
- * BACNET_APPLICATION_TAG_SIGNED_INT, and the value returned
- * cannot be safely converted, an exception is thrown.
- *
- * @param index into the list of returned data. 0 (first) is the
- * default.
- * @return A signed int value representing the returned data
- */
- int getDataTypeSignedInt(int index=0);
-
- /**
- * After a successful readProperty request, this method can be
- * used to return the BACnet dataype of the returned data as a
- * string. Most of the data types except Enum can be converted to
- * a string. If the data type (getDataType()) is not a
- * BACNET_APPLICATION_TAG_CHARACTER_STRING, and the value returned
- * cannot be safely converted, an exception is thrown.
- *
- * @param index into the list of returned data. 0 (first) is the
- * default.
- * @return A string value representing the returned data
- */
- std::string getDataTypeString(int index=0);
-
- /**
- * After a successful readProperty request, this method can be
- * used to return the BACnet dataype of the returned data as an
- * enumeration. If the data type (getDataType()) is not a
- * BACNET_APPLICATION_TAG_ENUMERATED an exception is thrown.
- *
- * @param index into the list of returned data. 0 (first) is the
- * default.
- * @return An unsigned int representing a BACnet enumerant
- */
- unsigned int getDataTypeEnum(int index=0);
-
-#if defined(BACAPP_DOUBLE)
- /**
- * After a successful readProperty request, this method can be
- * used to return the BACnet dataype of the returned data as a
- * double. If the data type (getDataType()) is not a
- * BACNET_APPLICATION_TAG_DOUBLE, and the value returned cannot be
- * safely converted, an exception is thrown.
- *
- * @param index into the list of returned data. 0 (first) is the
- * default.
- * @return A double floating point value representing the returned data
- */
- double getDataTypeDouble(int index=0);
-#endif // BACAPP_DOUBLE
-
- /**
- * This method is used to create and return an initialized
- * BACNET_APPLICATION_DATA_VALUE containing a real (floating point
- * value). A pointer to this returned structure can then be used
- * with writeProperty().
- *
- * @param value The floating point value to initialize the structure to.
- * @return An initialized structure containing the value
- */
- BACNET_APPLICATION_DATA_VALUE createDataReal(float Real);
-
- /**
- * This method is used to create and return an initialized
- * BACNET_APPLICATION_DATA_VALUE containing a boolean. A pointer
- * to this returned structure can then be used with
- * writeProperty().
- *
- * @param value The boolean value to initialize the structure to.
- * @return An initialized structure containing the value
- */
- BACNET_APPLICATION_DATA_VALUE createDataBool(bool value);
-
- /**
- * This method is used to create and return an initialized
- * BACNET_APPLICATION_DATA_VALUE containing a signed integer. A
- * pointer to this returned structure can then be used with
- * writeProperty().
- *
- * @param value The signed integer value to initialize the structure to.
- * @return An initialized structure containing the value
- */
- BACNET_APPLICATION_DATA_VALUE createDataSignedInt(int value);
-
- /**
- * This method is used to create and return an initialized
- * BACNET_APPLICATION_DATA_VALUE containing a unsigned integer. A
- * pointer to this returned structure can then be used with
- * writeProperty().
- *
- * @param value The unsigned integer value to initialize the
- * structure to.
- * @return An initialized structure containing the value
- */
- BACNET_APPLICATION_DATA_VALUE createDataUnsignedInt(unsigned int value);
-
- /**
- * This method is used to create and return an initialized
- * BACNET_APPLICATION_DATA_VALUE containing a character string. A
- * pointer to this returned structure can then be used with
- * writeProperty(). Strings are typically limited to 63 characters.
- *
- * @param value The character string value to initialize the
- * structure to.
- * @return An initialized structure containing the value
- */
- BACNET_APPLICATION_DATA_VALUE createDataString(std::string value);
-
- /**
- * This method is used to create and return an initialized
- * BACNET_APPLICATION_DATA_VALUE containing an enumeration. A
- * pointer to this returned structure can then be used with
- * writeProperty().
- *
- * @param value The BACnet enumeration to initialize the
- * structure to.
- * @return An initialized structure containing the value
- */
- BACNET_APPLICATION_DATA_VALUE createDataEnum(uint32_t value);
-
- /**
- * Return an enumration of the last error type to occur. The
- * value returned will be one of the BACERR_TYPE_T values.
- *
- * @return The last error type to occur, one of the BACERR_TYPE_T
- * values.
- */
- BACERR_TYPE_T getErrorType()
- {
- return m_errorType;
- };
-
- /**
- * In the event of a BACnet Reject error, return the error code.
- *
- * @return The Reject error code.
- */
- uint8_t getRejectReason()
- {
- return m_rejectReason;
- };
-
- /**
- * In the event of a BACnet Reject error, return the error string.
- *
- * @return The Reject error string.
- */
- std::string getRejectString()
- {
- return m_rejectString;
- };
-
- /**
- * In the event of a BACnet Abort error, return the Abort reason code.
- *
- * @return The Abort reason code.
- */
- uint8_t getAbortReason()
- {
- return m_abortReason;
- };
-
- /**
- * In the event of a BACnet Abort error, return the Abort string.
- *
- * @return The Abort error string.
- */
- std::string getAbortString()
- {
- return m_abortString;
- };
-
- /**
- * In the event of a general BACnet error, return the BACnet error class.
- *
- * @return One of the BACNET_ERROR_CLASS error class codes
- */
- BACNET_ERROR_CLASS getErrorClass()
- {
- return m_errorClass;
- };
-
- /**
- * In the event of a general BACnet error, return the BACnet error code.
- *
- * @return One of the BACNET_ERROR_CODE error codes
- */
- BACNET_ERROR_CODE getErrorCode()
- {
- return m_errorCode;
- };
-
- /**
- * In the event of a general BACnet error, return the BACnet error
- * string.
- *
- * @return A string representing the BACnet error class and code.
- */
- std::string getErrorString()
- {
- return m_errorString;
- };
-
- /**
- * In the event of a non-BACnet UPM error, return a string
- * describing the error.
- *
- * @return A string representing the UPM error.
- */
- std::string getUPMErrorString()
- {
- return m_upmErrorString;
- };
-
- /**
- * Check to see if initMaster) has already been called, and out
- * master is initialized.
- *
- * @return true if the master is initialized, false otherwise
- */
- bool isInitialized()
- {
- return m_initialized;
- };
-
- /**
- * Return the port that was specified to initMaster().
- *
- * @return The port specified to initMaster().
- */
- std::string getPort()
- {
- return m_port;
- };
-
- /**
- * Return the Object Device Instance ID for our Master was
- * specified to initMaster().
- *
- * @return The Object Device Instance ID for our Master.
- */
- uint32_t getDeviceInstanceID()
- {
- return m_deviceInstanceID;
- };
-
- /**
- * Return the maxInfoFrames parameter that was specified to initMaster().
- *
- * @return The maxInfoFrames parameter specified to initMaster().
- */
- int getMaxInfoFrames()
- {
- return m_maxInfoFrames;
- };
-
- /**
- * Return the maxMaster parameter that was specified to initMaster().
- *
- * @return The maxMaster parameter specified to initMaster().
- */
- int getMaxMaster()
- {
- return m_maxMaster;
- };
-
- /**
- * Return the baud rate parameter that was specified to initMaster().
- *
- * @return The baud rate parameter specified to initMaster().
- */
- int getBaudRate()
- {
- return m_baudRate;
- };
-
- /**
- * Return the MAC address parameter that was specified to initMaster().
- *
- * @return The MAC address parameter specified to initMaster().
- */
- int getMACAddress()
- {
- return m_macAddr;
- };
-
- /**
- * Enable or disable debugging output.
- *
- * @param enable true to enable debugging, false otherwise
- */
- void setDebug(bool enable);
-
- protected:
- /**
- * BACNETMSTP constructor
- */
- BACNETMSTP();
-
- /**
- * BACNETMSTP Destructor
- */
- ~BACNETMSTP();
-
- // clear/reset error states
- void clearErrors();
-
- // error handler
- static void handlerError(BACNET_ADDRESS * src,
- uint8_t invoke_id,
- BACNET_ERROR_CLASS error_class,
- BACNET_ERROR_CODE error_code);
-
- // abort handler
- static void handlerAbort(BACNET_ADDRESS * src,
- uint8_t invoke_id,
- uint8_t abort_reason,
- bool server);
-
- // reject handler
- static void handlerReject(BACNET_ADDRESS * src,
- uint8_t invoke_id,
- uint8_t reject_reason);
-
-
- // our handler for dealing with return data from a ReadProperty call
- static void handlerReadPropertyAck(uint8_t* service_request,
- uint16_t service_len,
- BACNET_ADDRESS* src,
- BACNET_CONFIRMED_SERVICE_ACK_DATA* service_data);
-
- // our handler for writeProp acks
- static void handlerWritePropertyAck(BACNET_ADDRESS* src,
- uint8_t invoke_id);
-
- // initialize our service handlers
- void initServiceHandlers();
-
- // utility function
- std::string string2HexString(std::string input);
-
- // responsible for dispatching a request to the BACnet network
- bool dispatchRequest();
-
- private:
- // prevent copying and assignment
- BACNETMSTP(BACNETMSTP const &) {};
- BACNETMSTP& operator=(BACNETMSTP const&) {};
-
- // our class instance
- static BACNETMSTP* m_instance;
-
- // has the class been created yet?
- bool m_initialized;
-
- // Some items we can set for our master
- std::string m_port;
- int m_maxInfoFrames;
- int m_maxMaster;
- int m_baudRate;
- int m_macAddr;
-
- // the unique Instance Number of our Master Device Object
- uint32_t m_deviceInstanceID;
-
- // adpu timeout in milliseconds
- uint16_t m_adpuTimeoutMS;
-
- // buffer used for receiving data
- uint8_t m_rxBuffer[MAX_MPDU];
-
- // our error classfication
- BACERR_TYPE_T m_errorType;
-
- // BACnet reject info
- uint8_t m_rejectReason;
- std::string m_rejectString;
-
- // BACnet abort info
- uint8_t m_abortReason;
- std::string m_abortString;
-
- // BACnet error info
- BACNET_ERROR_CLASS m_errorClass;
- BACNET_ERROR_CODE m_errorCode;
- std::string m_errorString;
-
- // generic UPM related errors - we just set the error text to
- // something informative.
- std::string m_upmErrorString;
-
- // our returned data from readProperty()
- std::vector<BACNET_APPLICATION_DATA_VALUE> m_returnedValue;
-
- // current bound target address of dispatched service request
- // (read/write prop, etc)
- BACNET_ADDRESS m_targetAddress;
-
- // current invokeID (for transaction handling)
- uint8_t m_invokeID;
-
- // error detected flag
- bool m_errorDetected;
-
- // Commands - we create a struct to hold the arguments for each
- // command type we support. Then, we create a command struct
- // which contains the command type and a union containing the
- // relevant arguments. This is used by dispatchRequest() to issue
- // the correct request.
-
- // these may generate SWIG warnings, but they can be ignored as we
- // do not expose these outside the class
- typedef struct {
- uint32_t targetDeviceInstanceID;
- BACNET_OBJECT_TYPE objType;
- uint32_t objInstance;
- BACNET_PROPERTY_ID objProperty;
- uint32_t arrayIndex;
- } READ_PROPERTY_ARGS_T;
-
- typedef struct {
- uint32_t targetDeviceInstanceID;
- BACNET_OBJECT_TYPE objType;
- uint32_t objInstance;
- BACNET_PROPERTY_ID objProperty;
- BACNET_APPLICATION_DATA_VALUE* propValue;
- uint8_t propPriority;
- int32_t arrayIndex;
- } WRITE_PROPERTY_ARGS_T;
-
- struct {
- BACCMD_TYPE_T cmd;
-
- union {
- READ_PROPERTY_ARGS_T readPropArgs;
- WRITE_PROPERTY_ARGS_T writePropArgs;
- };
- } m_command;
-
- bool m_debugging;
- };
-}
diff --git a/peripheral/libupm/src/bacnetmstp/bacnetutil.cxx b/peripheral/libupm/src/bacnetmstp/bacnetutil.cxx
deleted file mode 100644
index 17d555a..0000000
--- a/peripheral/libupm/src/bacnetmstp/bacnetutil.cxx
+++ /dev/null
@@ -1,925 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <assert.h>
-#include <errno.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-
-#include "bacnetutil.hpp"
-
-using namespace upm;
-using namespace std;
-
-
-BACNETUTIL::BACNETUTIL(uint32_t targetDeviceObjectID) :
- m_instance(0)
-{
- // Save our device's ID
- m_targetDeviceObjectID = targetDeviceObjectID;
-
- // create the BACNETMSTP instance here if it does not already exist,
- // and store the pointer in our class to save on some typing.
-
- m_instance = BACNETMSTP::instance();
-
- // now see if it has been initialized yet for init()
- m_initialized = m_instance->isInitialized();
-
- setDebug(false);
-
- // we disable this by default for performance reasons
- checkReliability(false);
-
- // empty our unit caches
- m_avUnitCache.clear();
- m_aiUnitCache.clear();
-
- // empty our msv info store
- m_msvInfo.clear();
-
- // empty our binary info stores
- m_bvInfo.clear();
- m_biInfo.clear();
-}
-
-BACNETUTIL::~BACNETUTIL()
-{
-}
-
-void BACNETUTIL::initMaster(std::string port, int baudRate,
- int deviceInstanceID, int macAddr, int maxMaster,
- int maxInfoFrames)
-{
- // first we check to see if the bacnetmstp instance has already been
- // initialized (determined in the ctor). If not, we will do so here
- // with the arguments specified. If it has already been
- // initialized, then we do not bother calling bacnetmstp's init
- // again as it will just be ignored.
-
- if (!m_initialized)
- m_instance->initMaster(port, baudRate, deviceInstanceID,
- macAddr, maxMaster, maxInfoFrames);
-
- // either it threw an exception, was already initialized or it's
- // initialized now...
- m_initialized = true;
-}
-
-void BACNETUTIL::setDebug(bool enable)
-{
- m_debugging = enable;
-
- // we also enable/disable debugging in BACNETMSTP
- m_instance->setDebug(enable);
-}
-
-float BACNETUTIL::getAnalogValue(uint32_t objInstance)
-{
- // check reliability first, if enabled
- if (m_checkReliability)
- {
- if (m_instance->readProperty(m_targetDeviceObjectID, OBJECT_ANALOG_VALUE,
- objInstance, PROP_RELIABILITY))
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": (reliability): " << getAllErrorString()
- << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + getAllErrorString());
- }
-
- BACNET_RELIABILITY reliable =
- static_cast<BACNET_RELIABILITY>(m_instance->getDataTypeEnum());
-
- if (reliable != RELIABILITY_NO_FAULT_DETECTED)
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": Reliability check failed" << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": Reliability check failed");
- }
- }
-
- // now get the value
- if (m_instance->readProperty(m_targetDeviceObjectID, OBJECT_ANALOG_VALUE,
- objInstance, PROP_PRESENT_VALUE))
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": (value): " << getAllErrorString()
- << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": "
- + getAllErrorString());
- }
-
- return m_instance->getDataTypeReal();
-}
-
-void BACNETUTIL::setAnalogValue(uint32_t objInstance,
- float value)
-{
- // Write the value
- BACNET_APPLICATION_DATA_VALUE myData =
- m_instance->createDataReal(value);
-
- // write it
- if (m_instance->writeProperty(m_targetDeviceObjectID, OBJECT_ANALOG_VALUE,
- objInstance, PROP_PRESENT_VALUE,
- &myData))
- {
- // error occurred
- if (m_debugging)
- cerr << __FUNCTION__ << ": " << getAllErrorString() << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": "
- + getAllErrorString());
- }
-}
-
-string BACNETUTIL::getAnalogValueUnits(uint32_t objInstance)
-{
- // see if it exists
- if (m_avUnitCache.count(objInstance) == 0)
- {
- // then we need to fetch it
- if (m_instance->readProperty(m_targetDeviceObjectID, OBJECT_ANALOG_VALUE,
- objInstance, PROP_UNITS))
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": " << getAllErrorString() << endl;
- // set to empty string
- m_avUnitCache[objInstance] = string("");
- }
- else
- {
- // cache it for future calls
- m_avUnitCache[objInstance] =
- string(bactext_engineering_unit_name(m_instance->getDataTypeEnum()));
- }
- }
-
- return m_avUnitCache[objInstance];
-}
-
-float BACNETUTIL::getAnalogInput(uint32_t objInstance)
-{
- // check reliability first, if enabled
- if (m_checkReliability)
- {
- if (m_instance->readProperty(m_targetDeviceObjectID, OBJECT_ANALOG_INPUT,
- objInstance, PROP_RELIABILITY))
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": (reliability): "
- << getAllErrorString() << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + getAllErrorString());
- }
-
- BACNET_RELIABILITY reliable =
- static_cast<BACNET_RELIABILITY>(m_instance->getDataTypeEnum());
-
- if (reliable != RELIABILITY_NO_FAULT_DETECTED)
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": Reliability check failed" << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": Reliability check failed");
- }
- }
-
- // now get the value
- if (m_instance->readProperty(m_targetDeviceObjectID, OBJECT_ANALOG_INPUT,
- objInstance, PROP_PRESENT_VALUE))
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": (value): " << getAllErrorString() << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": "
- + getAllErrorString());
- }
-
- return m_instance->getDataTypeReal();
-}
-
-bool BACNETUTIL::getBinaryInput(uint32_t objInstance)
-{
- // check the BV info, and update/cache the data if needed
- updateBinaryInputInfo(objInstance);
-
- // check reliability first, if enabled
- if (m_checkReliability)
- {
- if (m_instance->readProperty(m_targetDeviceObjectID, OBJECT_BINARY_INPUT,
- objInstance, PROP_RELIABILITY))
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": (reliability): "
- << getAllErrorString() << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + getAllErrorString());
- }
-
- BACNET_RELIABILITY reliable =
- static_cast<BACNET_RELIABILITY>(m_instance->getDataTypeEnum());
-
- if (reliable != RELIABILITY_NO_FAULT_DETECTED)
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": Reliability check failed" << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": Reliability check failed");
- }
- }
-
- // now get the value
- if (m_instance->readProperty(m_targetDeviceObjectID, OBJECT_BINARY_INPUT,
- objInstance, PROP_PRESENT_VALUE))
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": (value): " << getAllErrorString() << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": "
- + getAllErrorString());
- }
-
- BACNET_BINARY_PV bpv =
- static_cast<BACNET_BINARY_PV>(m_instance->getDataTypeEnum());
-
- return (bpv == BINARY_INACTIVE) ? false : true;
-}
-
-bool BACNETUTIL::getBinaryValue(uint32_t objInstance)
-{
- // check the BV info, and update/cache the data if needed
- updateBinaryValueInfo(objInstance);
-
- // check reliability first, if enabled
- if (m_checkReliability)
- {
- if (m_instance->readProperty(m_targetDeviceObjectID, OBJECT_BINARY_VALUE,
- objInstance, PROP_RELIABILITY))
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": (reliability): "
- << getAllErrorString() << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + getAllErrorString());
- }
-
- BACNET_RELIABILITY reliable =
- static_cast<BACNET_RELIABILITY>(m_instance->getDataTypeEnum());
-
- if (reliable != RELIABILITY_NO_FAULT_DETECTED)
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": Reliability check failed" << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": Reliability check failed");
- }
- }
-
- // now get the value
- if (m_instance->readProperty(m_targetDeviceObjectID, OBJECT_BINARY_VALUE,
- objInstance, PROP_PRESENT_VALUE))
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": (value): " << getAllErrorString() << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": "
- + getAllErrorString());
- }
-
- BACNET_BINARY_PV bpv =
- static_cast<BACNET_BINARY_PV>(m_instance->getDataTypeEnum());
-
- return (bpv == BINARY_INACTIVE) ? false : true;
-}
-
-void BACNETUTIL::setBinaryValue(uint32_t objInstance,
- bool value)
-{
- BACNET_BINARY_PV bpv = (value) ? BINARY_ACTIVE : BINARY_INACTIVE;
-
- // Write the value
- BACNET_APPLICATION_DATA_VALUE myData =
- m_instance->createDataEnum(bpv);
-
- // write it
- if (m_instance->writeProperty(m_targetDeviceObjectID, OBJECT_BINARY_VALUE,
- objInstance, PROP_PRESENT_VALUE,
- &myData))
- {
- // error occurred
- if (m_debugging)
- cerr << __FUNCTION__ << ": " << getAllErrorString() << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": "
- + getAllErrorString());
- }
-}
-
-string BACNETUTIL::getAnalogInputUnits(uint32_t objInstance)
-{
- // see if it exists
- if (m_aiUnitCache.count(objInstance) == 0)
- {
- // then we need to fetch it
- if (m_instance->readProperty(m_targetDeviceObjectID, OBJECT_ANALOG_INPUT,
- objInstance, PROP_UNITS))
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": " << getAllErrorString() << endl;
- // set to empty string
- m_aiUnitCache[objInstance] = string("");
- }
- else
- {
- // cache it for future calls
- m_aiUnitCache[objInstance] =
- string(bactext_engineering_unit_name(m_instance->getDataTypeEnum()));
- }
- }
-
- return m_aiUnitCache[objInstance];
-}
-
-unsigned int BACNETUTIL::getMultiStateValue(uint32_t objInstance)
-{
- // check the MSV info, and update/cache the data if needed
- updateMultiStateValueInfo(objInstance);
-
- // check reliability first, if enabled
- if (m_checkReliability)
- {
- if (m_instance->readProperty(m_targetDeviceObjectID,
- OBJECT_MULTI_STATE_VALUE,
- objInstance, PROP_RELIABILITY))
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": (reliability): "
- << getAllErrorString() << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + getAllErrorString());
- }
-
- BACNET_RELIABILITY reliable =
- static_cast<BACNET_RELIABILITY>(m_instance->getDataTypeEnum());
-
- if (reliable != RELIABILITY_NO_FAULT_DETECTED)
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": Reliability check failed" << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": Reliability check failed");
- }
- }
-
- // now get the value
- if (m_instance->readProperty(m_targetDeviceObjectID,
- OBJECT_MULTI_STATE_VALUE,
- objInstance, PROP_PRESENT_VALUE))
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": (value): " << getAllErrorString() << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": "
- + getAllErrorString());
- }
-
- return m_instance->getDataTypeUnsignedInt();
-}
-
-void BACNETUTIL::updateMultiStateValueInfo(uint32_t objInstance)
-{
- // bail if we already have information on this msv
- if (m_msvInfo.count(objInstance) != 0)
- return;
-
- // we need to fetch information on MSV's - number of states, and
- // possibly the state-text, if present
-
- // get the number of values possible (required)
- if (m_instance->readProperty(m_targetDeviceObjectID,
- OBJECT_MULTI_STATE_VALUE,
- objInstance, PROP_NUMBER_OF_STATES))
- {
- if (m_debugging)
- cerr << __FUNCTION__
- << ": (number of states): "
- << getAllErrorString()
- << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": "
- + getAllErrorString());
- }
-
- // Add the entry...
- m_msvInfo[objInstance].numStates = m_instance->getDataTypeUnsignedInt();
-
- if (m_debugging)
- cerr << __FUNCTION__
- << ": number of states: "
- << m_msvInfo[objInstance].numStates
- << endl;
-
- // now get the state-text. This is optional, so we will not throw
- // here.
- if (m_instance->readProperty(m_targetDeviceObjectID,
- OBJECT_MULTI_STATE_VALUE,
- objInstance, PROP_STATE_TEXT))
- {
- if (m_debugging)
- cerr << __FUNCTION__
- << ": (state-text): "
- << getAllErrorString()
- << endl;
- }
-
- // store them
- int numElements = m_instance->getDataNumElements();
-
- if (m_debugging)
- cerr << __FUNCTION__ << ": numElements: " << numElements << endl;
-
- if (numElements > 0)
- {
- for (int i=0; i<numElements; i++)
- {
- m_msvInfo[objInstance].stateList.push_back(m_instance->getDataTypeString(i));
-
- if (m_debugging)
- cerr << __FUNCTION__ << ": " << int(objInstance) << ", "
- << i << ": "
- << "added state text string: "
- << m_msvInfo[objInstance].stateList.at(i)
- << endl;
- }
- }
-
- return;
-}
-
-void BACNETUTIL::deleteMultiStateValueInfo(uint32_t objInstance)
-{
- // if there is no data stored for this objInstance yet, then we do
- // not need to do anything.
- if (m_msvInfo.count(objInstance) == 0)
- return;
-
- // Now, we just erase the entry, and it will be updated the next
- // time the MSV is accessed.
- m_msvInfo.erase(objInstance);
-
- return;
-}
-
-string BACNETUTIL::lookupMultiStateValueText(uint32_t objInstance,
- unsigned int value)
-{
- // verify that we have the relevant object data cached. If not, go
- // get it.
- updateMultiStateValueInfo(objInstance);
-
- // verify that value is valid for this object
- if (value == 0 || value > m_msvInfo[objInstance].numStates)
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": value supplied is invalid. Maximum "
- + "allowed values are 1 to "
- + std::to_string(m_msvInfo[objInstance].numStates)
- + " for this object");
-
-
- // at this point either it failed or suceeded. If it suceeded, then
- // we will see if any state text was retrieved. If no text is
- // available (it is an optional property), then we will simply
- // return the value itself as a string.
-
- if (m_msvInfo[objInstance].stateList.size() > 0)
- {
- // we have state-text and a usable value.
-
- // value should never be 0 at this point, so compensate for
- // indexing into stateList which is 0-based.
- value--;
-
- return m_msvInfo[objInstance].stateList.at(value);
- }
-
- // no stateList text available, so just return value as a string
- return std::to_string(value);
-}
-
-unsigned int BACNETUTIL::getMultiStateValueMaxStates(uint32_t objInstance)
-{
- // check the MSV info, and update/cache the data if needed
- updateMultiStateValueInfo(objInstance);
-
- return m_msvInfo[objInstance].numStates;
-}
-
-string BACNETUTIL::getMultiStateValueText(uint32_t objInstance)
-{
- unsigned int value = getMultiStateValue(objInstance);
-
- return lookupMultiStateValueText(objInstance, value);
-}
-
-void BACNETUTIL::setMultiStateValue(uint32_t objInstance,
- unsigned int value)
-{
- // check the MSV info, and update/cache the data if needed
- updateMultiStateValueInfo(objInstance);
-
- // Check value against the valid limits
-
- if (value == 0 || value > m_msvInfo[objInstance].numStates)
- throw std::invalid_argument(std::string(__FUNCTION__)
- + ": value supplied is invalid. Maximum "
- + "allowed values are 1 to "
- + std::to_string(m_msvInfo[objInstance].numStates)
- + " for this object");
-
- // Write the value
- BACNET_APPLICATION_DATA_VALUE myData =
- m_instance->createDataUnsignedInt(value);
-
- // write it
- if (m_instance->writeProperty(m_targetDeviceObjectID,
- OBJECT_MULTI_STATE_VALUE,
- objInstance, PROP_PRESENT_VALUE,
- &myData))
- {
- // error occurred
- if (m_debugging)
- cerr << __FUNCTION__ << ": " << getAllErrorString() << endl;
-
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": "
- + getAllErrorString());
- }
-}
-
-void BACNETUTIL::updateBinaryValueInfo(uint32_t objInstance)
-{
- // bail if we already have information on this object
- if (m_bvInfo.count(objInstance) != 0)
- return;
-
- // fetch inactive/active text. These are optional accordingto the
- // spec, so we will not throw if they do not exist.
-
- // get inactive text
- if (m_instance->readProperty(m_targetDeviceObjectID,
- OBJECT_BINARY_VALUE,
- objInstance, PROP_INACTIVE_TEXT))
- {
- if (m_debugging)
- cerr << __FUNCTION__
- << ": (inactive text): "
- << getAllErrorString()
- << endl;
-
- m_bvInfo[objInstance].inactiveText = "inactive";
- }
- else
- {
- m_bvInfo[objInstance].inactiveText = m_instance->getDataTypeString();
- }
-
- // get active text
- if (m_instance->readProperty(m_targetDeviceObjectID,
- OBJECT_BINARY_VALUE,
- objInstance, PROP_ACTIVE_TEXT))
- {
- if (m_debugging)
- cerr << __FUNCTION__
- << ": (active text): "
- << getAllErrorString()
- << endl;
-
- m_bvInfo[objInstance].activeText = "active";
- }
- else
- {
- m_bvInfo[objInstance].activeText = m_instance->getDataTypeString();
- }
-
- return;
-}
-
-void BACNETUTIL::deleteBinaryValueInfo(uint32_t objInstance)
-{
- // if there is no data stored for this objInstance yet, then we do
- // not need to do anything.
- if (m_bvInfo.count(objInstance) == 0)
- return;
-
- // Now, we just erase the entry, and it will be updated the next
- // time it is accessed.
- m_bvInfo.erase(objInstance);
-
- return;
-}
-
-void BACNETUTIL::updateBinaryInputInfo(uint32_t objInstance)
-{
- // bail if we already have information on this object
- if (m_biInfo.count(objInstance) != 0)
- return;
-
- // fetch inactive/active text. These are optional accordingto the
- // spec, so we will not throw if they do not exist.
-
- // get inactive text
- if (m_instance->readProperty(m_targetDeviceObjectID,
- OBJECT_BINARY_INPUT,
- objInstance, PROP_INACTIVE_TEXT))
- {
- if (m_debugging)
- cerr << __FUNCTION__
- << ": (inactive text): "
- << getAllErrorString()
- << endl;
-
- m_biInfo[objInstance].inactiveText = "inactive";
- }
- else
- {
- m_biInfo[objInstance].inactiveText = m_instance->getDataTypeString();
- }
-
- // get active text
- if (m_instance->readProperty(m_targetDeviceObjectID,
- OBJECT_BINARY_INPUT,
- objInstance, PROP_ACTIVE_TEXT))
- {
- if (m_debugging)
- cerr << __FUNCTION__
- << ": (active text): "
- << getAllErrorString()
- << endl;
-
- m_biInfo[objInstance].activeText = "active";
- }
- else
- {
- m_biInfo[objInstance].activeText = m_instance->getDataTypeString();
- }
-
- return;
-}
-
-void BACNETUTIL::deleteBinaryInputInfo(uint32_t objInstance)
-{
- // if there is no data stored for this objInstance yet, then we do
- // not need to do anything.
- if (m_biInfo.count(objInstance) == 0)
- return;
-
- // Now, we just erase the entry, and it will be updated the next
- // time it is accessed.
- m_biInfo.erase(objInstance);
-
- return;
-}
-
-string BACNETUTIL::lookupBinaryInputText(uint32_t objInstance, bool value)
-{
- // cache relevant data if necessary
- updateBinaryInputInfo(objInstance);
-
- if (value)
- return m_biInfo[objInstance].activeText;
- else
- return m_biInfo[objInstance].inactiveText;
-}
-
-string BACNETUTIL::getBinaryInputText(uint32_t objInstance)
-{
- bool value = getBinaryInput(objInstance);
-
- return lookupBinaryInputText(objInstance, value);
-}
-
-string BACNETUTIL::lookupBinaryValueText(uint32_t objInstance, bool value)
-{
- // cache relevant data if necessary
- updateBinaryValueInfo(objInstance);
-
- if (value)
- return m_bvInfo[objInstance].activeText;
- else
- return m_bvInfo[objInstance].inactiveText;
-}
-
-string BACNETUTIL::getBinaryValueText(uint32_t objInstance)
-{
- bool value = getBinaryValue(objInstance);
-
- return lookupBinaryValueText(objInstance, value);
-}
-
-BACNETMSTP::BACERR_TYPE_T BACNETUTIL::getErrorType()
-{
- return m_instance->getErrorType();
-}
-
-uint8_t BACNETUTIL::getRejectReason()
-{
- return m_instance->getRejectReason();
-}
-
-std::string BACNETUTIL::getRejectString()
-{
- return m_instance->getRejectString();
-}
-
-uint8_t BACNETUTIL::getAbortReason()
-{
- return m_instance->getAbortReason();
-}
-
-std::string BACNETUTIL::getAbortString()
-{
- return m_instance->getAbortString();
-}
-
-BACNET_ERROR_CLASS BACNETUTIL::getErrorClass()
-{
- return m_instance->getErrorClass();
-}
-
-BACNET_ERROR_CODE BACNETUTIL::getErrorCode()
-{
- return m_instance->getErrorCode();
-}
-
-std::string BACNETUTIL::getUPMErrorString()
-{
- return m_instance->getUPMErrorString();
-}
-
-std::string BACNETUTIL::getErrorString()
-{
- return m_instance->getErrorString();
-};
-
-string BACNETUTIL::getAllErrorString()
-{
- switch (m_instance->getErrorType())
- {
- case BACNETMSTP::BACERR_TYPE_NONE:
- return string("No Error");
- break;
-
- case BACNETMSTP::BACERR_TYPE_REJECT:
- return string("Reject: ") + getRejectString();
- break;
-
- case BACNETMSTP::BACERR_TYPE_ABORT:
- return string("Abort: ") + getAbortString();
- break;
-
- case BACNETMSTP::BACERR_TYPE_ERROR:
- return string("Error: ") + getErrorString();
- break;
-
- case BACNETMSTP::BACERR_TYPE_UPM:
- return string("UPM Error: ") + getUPMErrorString();
- break;
- }
-}
-
-string BACNETUTIL::getDeviceDescription()
-{
- if (m_instance->readProperty(m_targetDeviceObjectID, OBJECT_DEVICE,
- m_targetDeviceObjectID, PROP_DESCRIPTION))
- {
- // error occurred
- if (m_debugging)
- cerr << __FUNCTION__ << ": " << getAllErrorString() << endl;
-
- return "";
- }
-
- return m_instance->getDataTypeString();
-}
-
-string BACNETUTIL::getDeviceLocation()
-{
- if (m_instance->readProperty(m_targetDeviceObjectID, OBJECT_DEVICE,
- m_targetDeviceObjectID, PROP_LOCATION))
- {
- // error occurred
- if (m_debugging)
- cerr << __FUNCTION__ << ": " << getAllErrorString() << endl;
-
- return "";
- }
-
- return m_instance->getDataTypeString();
-}
-
-bool BACNETUTIL::setDeviceLocation(string location)
-{
- BACNET_APPLICATION_DATA_VALUE myLocation =
- m_instance->createDataString(location);
-
- // write the Device Object Location
- if (m_instance->writeProperty(m_targetDeviceObjectID, OBJECT_DEVICE,
- m_targetDeviceObjectID, PROP_LOCATION,
- &myLocation))
- {
- // error occurred
- if (m_debugging)
- cerr << __FUNCTION__ << ": " << getAllErrorString() << endl;
-
- return false;
- }
-
- return true;
-}
-
-string BACNETUTIL::getDeviceName()
-{
- if (m_instance->readProperty(m_targetDeviceObjectID, OBJECT_DEVICE,
- m_targetDeviceObjectID, PROP_OBJECT_NAME))
- {
- // error occurred
- if (m_debugging)
- cerr << __FUNCTION__ << ": " << getAllErrorString() << endl;
-
- return "";
- }
-
- return m_instance->getDataTypeString();
-}
-
-bool BACNETUTIL::setDeviceName(string name)
-{
- if (name.size() < 1)
- {
- throw std::invalid_argument(std::string(__FUNCTION__)
- + ": name must have at least one character");
- }
-
- BACNET_APPLICATION_DATA_VALUE myName =
- m_instance->createDataString(name);
-
- // write the Device Object Location
- if (m_instance->writeProperty(m_targetDeviceObjectID, OBJECT_DEVICE,
- m_targetDeviceObjectID, PROP_OBJECT_NAME,
- &myName))
- {
- // error occurred
- if (m_debugging)
- cerr << __FUNCTION__ << ": " << getAllErrorString() << endl;
-
- return false;
- }
-
- return true;
-}
diff --git a/peripheral/libupm/src/bacnetmstp/bacnetutil.hpp b/peripheral/libupm/src/bacnetmstp/bacnetutil.hpp
deleted file mode 100644
index 463d1d8..0000000
--- a/peripheral/libupm/src/bacnetmstp/bacnetutil.hpp
+++ /dev/null
@@ -1,559 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <map>
-#include <vector>
-
-#include "bacnetmstp.hpp"
-
-namespace upm {
-
- /**
- * @library bacnetmstp
- * @comname UPM Utility API for BACnet
- * @con uart
- *
- * @brief UPM Utility API for BACnet
- *
- * This class implements some common access functions that are
- * useful to any driver making use of the bacnetmstp driver.
- *
- * It provides some basic functionality for reading and writing a
- * proprty (with and without relability checking) as well as access
- * to error conditions. It is intended to be inherited by your
- * driver class.
- */
-
- class BACNETUTIL {
- public:
-
- /**
- * BACNETUTIL constructor
- *
- */
- BACNETUTIL(uint32_t targetDeviceObjectID);
-
- /**
- * BACNETUTIL Destructor
- */
- virtual ~BACNETUTIL();
-
- /**
- * This function initializes the underlying BACNETMSTP Master
- * singleton in the event it has not already been initialized. If
- * the BACNETMSTP Master singleton has already been initialized,
- * then this call will be ignored.
- *
- * @param port The serial port that the RS-485 interface is
- * connected to.
- * @param baudRate The baudrate of the RS-485 interface. All
- * devices on a BACnet RS-485 bus must run at the same baudrate.
- * Valid values are 9600, 19200, 38400, 57600, 76800, and 115200.
- * @param deviceInstanceNumber This is the unique Device Object
- * Instance number that will be used for our BACnet Master in
- * order to communicate over the BACnet interface. This number
- * must be between 1-4194302 and must be unique on the BACnet
- * network.
- * @param macAddr This is the MAC address of our BACnet Master.
- * It must be unique on the BACnet segment, and must be between
- * 1-127.
- * @param maxMaster This specifies to our Master the maximum MAC
- * address used by any other Masters on the BACnet network. This
- * must be between 1-127, the default is 127. Do not change this
- * unless you know what you are doing or you could introduce
- * token passing errors on the BACnet network.
- * @param maxInfoFrames This number specifies the maximum number
- * of transmissions (like requests for data) our Master is allowed
- * to make before passing the token to the next Master. The
- * default is 1.
- */
- virtual void initMaster(std::string port, int baudRate,
- int deviceInstanceNumber,
- int macAddr, int maxMaster=DEFAULT_MAX_MASTER,
- int maxInfoFrames=1);
-
- /**
- * Enable some debugging output in this module as well as the
- * BACNETMSTP module. Debugging is disabled by default.
- *
- * @param enable true to enable, false to disable.
- */
- virtual void setDebug(bool enable);
-
- /**
- * Retrieve the Present_Value property of an Analog Value object.
- * If checkReliability() has been enabled, then the Reliability
- * property of the object will be retrieved first. If the
- * Reliability property is anything other than
- * RELIABILITY_NO_FAULT_DETECTED, then the method will throw.
- * Reliability checking is disabled by default for performance
- * reasons.
- *
- * @param objInstance The Analog Value Object instance.
- * @return The floating point value requested.
- */
- virtual float getAnalogValue(uint32_t objInstance);
-
- /**
- * Set the Present_Value property of an Analog Value object. This
- * method will throw on an error.
- *
- * @param objInstance The Analog Value Object instance.
- * @param value The data value to write.
- */
- virtual void setAnalogValue(uint32_t objInstance,
- float value);
-
- /**
- * Retrieve the Present_Value property of an Analog Input object.
- * If checkReliability() has been enabled, then the Reliability
- * property of the object will be retrieved first. If the
- * Reliability property is anything other than
- * RELIABILITY_NO_FAULT_DETECTED, then the method will throw.
- * Reliability checking is disabled by default for performance
- * reasons.
- *
- * @param objInstance The Analog Input Object instance.
- * @return the floating point value requested.
- */
- virtual float getAnalogInput(uint32_t objInstance);
-
- /**
- * Query an Analog Value object for the unit code, translate it
- * into a string and cache the result for future use. Return the
- * BACnet text for the Unit enumeration. Unit enumerations are
- * things like 'kilowatt-hours', 'volts', etc. For Objects which
- * do not have a Units property defined for them, or for which
- * Units has no meaning, 'no-units' will typically be returned and
- * cached for the object.
- *
- * @param objInstance The Analog Value Object instance.
- * @return A string representing the Object's Unit property.
- */
- virtual std::string getAnalogValueUnits(uint32_t objInstance);
-
- /**
- * Query an Analog Input object for the unit code, translate it
- * into a string and cache the result for future use. Return the
- * BACnet text for the Unit enumeration. Unit enumerations are
- * things like 'kilowatt-hours', 'volts', etc. For Objects which
- * do not have a Units property defined for them, or for which
- * Units has no meaning, 'no-units' will typically be returned and
- * cached for the object.
- *
- * @param objInstance The Analog Input Object instance.
- * @return A string representing the Object's Unit property.
- */
- virtual std::string getAnalogInputUnits(uint32_t objInstance);
-
- /**
- * Retrieve the Present_Value property of a Binary Input object.
- * If checkReliability() has been enabled, then the Reliability
- * property of the object will be retrieved first. If the
- * Reliability property is anything other than
- * RELIABILITY_NO_FAULT_DETECTED, then the method will throw.
- * Reliability checking is disabled by default for performance
- * reasons.
- *
- * @param objInstance The Object Instance number to query
- * @return the boolean point value requested
- */
- virtual bool getBinaryInput(uint32_t objInstance);
-
- /**
- * Lookup (retrieve if necessary) the Inactive_Text and
- * Active_Text properties of a Binary Input object. These text
- * properties are optional and can provide a string representing a
- * given state (true/false) that can be more informational than
- * just the boolean value the object represents. This is useful
- * in applications that display this data to a user for example.
- * If this text is not present in the object (as it is not
- * required), then a string representation of the value will be
- * returned instead ("active" and "inactive").
- *
- * @param objInstance The Object Instance number of the object
- * @param value The value you want to lookup the text
- * representation for.
- * @return The string representing the value.
- */
- virtual std::string lookupBinaryInputText(uint32_t objInstance, bool value);
-
- /**
- * Return a string representation of the Present_Value property of
- * a BinaryInput object. This method just calls getBinaryInput()
- * on the object, uses lookupBinaryInputText() to lookup the
- * corresponding text value, and returns the result.
- *
- * @param objInstance The Object Instance number of the object.
- * @return The string representing the value.
- */
- virtual std::string getBinaryInputText(uint32_t objInstance);
-
- /**
- * Retrieve the Present_Value property of a Binary Value object.
- * If checkReliability() has been enabled, then the Reliability
- * property of the object will be retrieved first. If the
- * Reliability property is anything other than
- * RELIABILITY_NO_FAULT_DETECTED, then the method will throw.
- * Reliability checking is disabled by default for performance
- * reasons.
- *
- * @param objInstance The Object Instance number to query
- * @return the boolean point value requested
- */
- virtual bool getBinaryValue(uint32_t objInstance);
-
- /**
- * Set the Present_Value property of a Binary Value object. This
- * method will throw on an error.
- *
- * @param objInstance The Analog Value Object instance.
- * @param value The data value to write
- */
- virtual void setBinaryValue(uint32_t objInstance,
- bool value);
-
- /**
- * Lookup (retrieve if necessary) the Inactive_Text and
- * Active_Text properties of a Binary Value object. These text
- * properties are optional and can provide a string representing a
- * given state (true/false) that can be more informational than
- * just the boolean value the object represents. This is useful
- * in applications that display this data to a user for example.
- * If this text is not present in the object (as it is not
- * required), then a string representation of the value will be
- * returned instead ("active" and "inactive").
- *
- * @param objInstance The Object Instance number of the object.
- * @param value The value you want to lookup the text
- * representation for.
- * @return The string representing the value.
- */
- virtual std::string lookupBinaryValueText(uint32_t objInstance, bool value);
-
- /**
- * Return a string representation of the Present_Value property of
- * a Binary Value object. This method just calls getBinaryValue()
- * on the object, uses lookupBinaryValueText() to lookup the
- * corresponding text value, and returns the result.
- *
- * @param objInstance The Object Instance number of the object.
- * @return The string representing the value.
- */
- virtual std::string getBinaryValueText(uint32_t objInstance);
-
- /**
- * Retrieve the Present_Value property of a Multi State Value
- * object. If checkReliability() has been enabled, then the
- * Reliability property of the object will be retrieved first. If
- * the Reliability property is anything other than
- * RELIABILITY_NO_FAULT_DETECTED, then the method will throw.
- * Reliability checking is disabled by default for performance
- * reasons.
- *
- * @param objInstance The Object Instance number to query.
- * @return The Present_Value property of the object.
- */
- virtual unsigned int getMultiStateValue(uint32_t objInstance);
-
- /**
- * Lookup (retrieve if necessary) the State_Text strings
- * corresponding to the supplied value of a MultiStateValue
- * object. State_Text is an optional property that can provide
- * strings representing a given state that can be more
- * informational than just the unsigned integer the object
- * represents. This is useful in applications that display this
- * data to a user for example. If this text is not present in the
- * object (as it is not required), then a string representation of
- * the integer value will be returned instead.
- *
- * @param objInstance The Object Instance number of the object.
- * @param value The value you want to lookup the text
- * representation for.
- * @return The string representing the value.
- */
- virtual std::string lookupMultiStateValueText(uint32_t objInstance,
- unsigned int value);
-
- /**
- * Return a string representation of the Present_Value property of
- * a MultiStateValue object. This method just calls
- * getMultiStateValue() on the object, uses
- * lookupMultiStateValueText() to lookup the corresponding
- * State_Text value, and returns the result.
- *
- * @param objInstance The Object Instance number of the object.
- * @return The string representing the value.
- */
- virtual std::string getMultiStateValueText(uint32_t objInstance);
-
- /**
- * Return the maximum legal value of a Multi State Value Object.
- * The value represents the highest value the Present_Value
- * porperty of the object will allow.
- *
- * @param objInstance The Object Instance number of the object.
- * @return The highest Present_Value the object supports.
- */
- virtual unsigned int getMultiStateValueMaxStates(uint32_t objInstance);
-
- /**
- * Set the Present_Value property of a Multi State Value object.
- * The value provided must not be 0, and must not exceed the
- * object's Number_Of_States property. Use
- * getMultiStateValueMaxStates() to determine the maximum value
- * the object supports. This method will throw on an error.
- *
- * @param objInstance The MultiStateValue Object instance.
- * @param value The data value to write.
- */
- virtual void setMultiStateValue(uint32_t objInstance,
- unsigned int value);
-
- /**
- * Enable or disable reliability checking. When retrieving data,
- * the Present_Value property is returned. There is also an
- * optional property called Reliability that can be checked to
- * ensure that the Present_Value property is currently valid.
- *
- * Enabling Reliability Checking has the data retrieval functions
- * check for a RELIABILITY_NO_FAULT_DETECTED value for the
- * Reliability property before querying the Present_Value
- * property. If anything other than RELIABILITY_NO_FAULT_DETECTED
- * is set, then the method will throw.
- *
- * This checking is disabled by default since it will double the
- * number of queries needed to retrieve a given value. In
- * addition, since it is an optional property, calling it for an
- * object that does not support it will also throw. However, if
- * you need to ensure that the values returned are always
- * completely valid as determined by the device firmware, and the
- * objects you are querying support the reliability property, you
- * can enable this.
- *
- * @param enable true to check Reliability before returning a
- * value, false otherwise.
- */
- virtual void checkReliability(bool enable)
- {
- m_checkReliability = enable;
- };
-
- /**
- * Query the Device Object of the device and return it's
- * Description property. This typically contains information like
- * the Vendor, model and serial number of a device.
- *
- * @return A string containing the Device Object's Description property.
- */
- virtual std::string getDeviceDescription();
-
- /**
- * Query the Device Object of the device and return it's Location
- * property. This typically contains a string indication of a
- * customer specific value. Use setLocation() to change.
- *
- * @return A string containing the Device Object's Location property.
- */
- virtual std::string getDeviceLocation();
-
- /**
- * Set the Device Object's Location property. This must be a
- * string containing no more than 63 characters. Not all devices
- * allow setting the location.
- *
- * @param location The new location to set, if supported.
- * @return true if the operation succeeded, otherwise false.
- */
- virtual bool setDeviceLocation(std::string location);
-
- /**
- * Query the Device Object of the device and return it's Name
- * property. This should contain a unique string value. Use
- * setName() to change. Note, according to the spec, the Device
- * Object Name must be unique within a given BACnet network.
- *
- * @return A string containing the Object's Name property.
- */
- virtual std::string getDeviceName();
-
- /**
- * Set the Device Object's Name property. This must be a string
- * containing at least one character and no more than 63
- * characters. Note, according to the spec, the Device Object
- * Name must be unique within a given BACnet network.
- *
- * @param name The name to set.
- * @return true if the operation succeeded, false otherwise
- */
- virtual bool setDeviceName(std::string name);
-
- /**
- * This is a utility function that will return a string reporting
- * on the various types of errors that can occur in BACnet
- * operation.
- *
- * @return A string containing the last error message.
- */
- virtual std::string getAllErrorString();
-
- /**
- * Return an enumration of the last error type to occur. The
- * value returned will be one of the BACNETMSTP::BACERR_TYPE_T
- * values.
- *
- * @return The last error type to occur, one of the
- * BACNETMSTP::BACERR_TYPE_T values.
- */
- virtual BACNETMSTP::BACERR_TYPE_T getErrorType();
-
- /**
- * In the event of a BACnet Reject error, return the error code.
- *
- * @return The Reject error code.
- */
- virtual uint8_t getRejectReason();
-
- /**
- * In the event of a BACnet Reject error, return the error string.
- *
- * @return The Reject error string.
- */
- virtual std::string getRejectString();
-
- /**
- * In the event of a BACnet Abort error, return the Abort reason code.
- *
- * @return The Abort reason code.
- */
- virtual uint8_t getAbortReason();
-
- /**
- * In the event of a BACnet Abort error, return the Abort string.
- *
- * @return The Abort error string.
- */
- virtual std::string getAbortString();
-
- /**
- * In the event of a general BACnet error, return the BACnet error class.
- *
- * @return One of the BACNET_ERROR_CLASS error class codes
- */
- virtual BACNET_ERROR_CLASS getErrorClass();
-
- /**
- * In the event of a general BACnet error, return the BACnet error code.
- *
- * @return One of the BACNET_ERROR_CODE error codes
- */
- virtual BACNET_ERROR_CODE getErrorCode();
-
- /**
- * In the event of a general BACnet error, return the BACnet error
- * string.
- *
- * @return A string representing the BACnet error class and code.
- */
- virtual std::string getErrorString();
-
- /**
- * In the event of a non-BACnet UPM error, return a string
- * describing the error.
- *
- * @return A string representing the UPM error.
- */
- virtual std::string getUPMErrorString();
-
- protected:
- // update our stored info for an MSV
- virtual void updateMultiStateValueInfo(uint32_t objInstance);
- // delete our stored info for an MSV
- virtual void deleteMultiStateValueInfo(uint32_t objInstance);
-
- // update our stored info for a BV
- virtual void updateBinaryValueInfo(uint32_t objInstance);
- // delete our stored info for a BV
- virtual void deleteBinaryValueInfo(uint32_t objInstance);
-
- // update our stored info for a BI
- virtual void updateBinaryInputInfo(uint32_t objInstance);
- // delete our stored info for a BI
- virtual void deleteBinaryInputInfo(uint32_t objInstance);
-
- // also enable mstp debugging in BACNETMSTP
- bool m_debugging;
-
- // whether or not to verify reliability before reading a value.
- bool m_checkReliability;
-
- // our target Device Object ID
- uint32_t m_targetDeviceObjectID;
-
- // a copy of the BACNETMSTP singleton instance pointer
- BACNETMSTP* m_instance;
-
- // are we initialized?
- bool m_initialized;
-
- // storage for Binary Input and Binary Value Data. This will
- // generate SWIG warnings which can be ignored as we do not expose
- // this struct outside the class.
- typedef struct {
- std::string inactiveText;
- std::string activeText;
- } binaryData_t;
-
- typedef std::map<uint32_t, binaryData_t> binaryInfo_t;
-
- // storage for binary input/value information
- binaryInfo_t m_bvInfo;
- binaryInfo_t m_biInfo;
-
- // storage for multi-state data. This will generate SWIG
- // warnings which can be ignored as we do not expose this struct
- // outside the class.
- typedef struct {
- unsigned int numStates;
- std::vector<std::string>stateList;
- } multiStateData_t;
-
- // our information storage for MSV's
- typedef std::map<uint32_t, multiStateData_t> multiStateInfo_t;
-
- multiStateInfo_t m_msvInfo;
-
- // Unit cache for AV
- typedef std::map<uint32_t, std::string> avCacheMap_t;
- avCacheMap_t m_avUnitCache;
-
- // Unit cache for AI
- typedef std::map<uint32_t, std::string> aiCacheMap_t;
- aiCacheMap_t m_aiUnitCache;
-
- private:
- };
-}
diff --git a/peripheral/libupm/src/bacnetmstp/device-client.c b/peripheral/libupm/src/bacnetmstp/device-client.c
deleted file mode 100644
index cb25dd9..0000000
--- a/peripheral/libupm/src/bacnetmstp/device-client.c
+++ /dev/null
@@ -1,1026 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-/**************************************************************************
-*
-* Copyright (C) 2011 Steve Karg <skarg@users.sourceforge.net>
-*
-* Permission is hereby granted, free of charge, to any person obtaining
-* a copy of this software and associated documentation files (the
-* "Software"), to deal in the Software without restriction, including
-* without limitation the rights to use, copy, modify, merge, publish,
-* distribute, sublicense, and/or sell copies of the Software, and to
-* permit persons to whom the Software is furnished to do so, subject to
-* the following conditions:
-*
-* The above copyright notice and this permission notice shall be included
-* in all copies or substantial portions of the Software.
-*
-* 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.
-*
-*********************************************************************/
-
-/** @file device-client.c Lightweight base "class" for handling all
- * BACnet objects belonging to a BACnet device, as well as
- * Device-specific properties. This Device instance is designed to
- * meet minimal functionality for simple clients. */
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <string.h> /* for memmove */
-#include <time.h> /* for timezone, localtime */
-
-#define BACDL_MSTP 1
-#undef BACDL_ALL
-
-
-/* OS specific include*/
-//#include "net.h"
-#include "timer.h"
-/* BACnet includes */
-#include "bacdef.h"
-#include "bacdcode.h"
-#include "bacenum.h"
-#include "bacapp.h"
-#include "config.h" /* the custom stuff */
-#include "apdu.h"
-#include "rp.h" /* ReadProperty handling */
-#include "version.h"
-#include "handlers.h"
-#include "datalink.h"
-#include "address.h"
-/* include the device object */
-#include "device.h" /* me */
-
-#if defined(__BORLANDC__) || defined(_WIN32)
-/* seems to not be defined in time.h as specified by The Open Group */
-/* difference from UTC and local standard time */
-long int timezone;
-#endif
-
-/* note: you really only need to define variables for
- properties that are writable or that may change.
- The properties that are constant can be hard coded
- into the read-property encoding. */
-
-static uint32_t Object_Instance_Number = 260001;
-static BACNET_CHARACTER_STRING My_Object_Name;
-static BACNET_DEVICE_STATUS System_Status = STATUS_OPERATIONAL;
-static char *Vendor_Name = BACNET_VENDOR_NAME;
-static uint16_t Vendor_Identifier = BACNET_VENDOR_ID;
-static char *Model_Name = "UPM Bacnet-o-matic MS/TP";
-static char *Application_Software_Version = "1.0";
-static char *Location = "Unknown";
-static char *Description = "UPM BACNET MS/TP driver";
-/* static uint8_t Protocol_Version = 1; - constant, not settable */
-/* static uint8_t Protocol_Revision = 4; - constant, not settable */
-/* Protocol_Services_Supported - dynamically generated */
-/* Protocol_Object_Types_Supported - in RP encoding */
-/* Object_List - dynamically generated */
-/* static BACNET_SEGMENTATION Segmentation_Supported = SEGMENTATION_NONE; */
-/* static uint8_t Max_Segments_Accepted = 0; */
-/* VT_Classes_Supported */
-/* Active_VT_Sessions */
-static BACNET_TIME Local_Time; /* rely on OS, if there is one */
-static BACNET_DATE Local_Date; /* rely on OS, if there is one */
-/* NOTE: BACnet UTC Offset is inverse of common practice.
- If your UTC offset is -5hours of GMT,
- then BACnet UTC offset is +5hours.
- BACnet UTC offset is expressed in minutes. */
-static int32_t UTC_Offset = 5 * 60;
-static bool Daylight_Savings_Status = false; /* rely on OS */
-/* List_Of_Session_Keys */
-/* Time_Synchronization_Recipients */
-/* Max_Master - rely on MS/TP subsystem, if there is one */
-/* Max_Info_Frames - rely on MS/TP subsystem, if there is one */
-/* Device_Address_Binding - required, but relies on binding cache */
-static uint32_t Database_Revision = 0;
-/* Configuration_Files */
-/* Last_Restore_Time */
-/* Backup_Failure_Timeout */
-/* Active_COV_Subscriptions */
-/* Slave_Proxy_Enable */
-/* Manual_Slave_Address_Binding */
-/* Auto_Slave_Discovery */
-/* Slave_Address_Binding */
-/* Profile_Name */
-
-/* local forward (semi-private) and external prototypes */
-int Device_Read_Property_Local(
- BACNET_READ_PROPERTY_DATA * rpdata);
-extern int Routed_Device_Read_Property_Local(
- BACNET_READ_PROPERTY_DATA * rpdata);
-extern bool Routed_Device_Write_Property_Local(
- BACNET_WRITE_PROPERTY_DATA * wp_data);
-
-/* All included BACnet objects */
-static object_functions_t Object_Table[] = {
- {OBJECT_DEVICE,
- NULL /* Init - don't init Device or it will recourse! */ ,
- Device_Count,
- Device_Index_To_Instance,
- Device_Valid_Object_Instance_Number,
- Device_Object_Name,
- Device_Read_Property_Local,
- NULL /* Write_Property */ ,
- NULL /* Property_Lists */ ,
- NULL /* ReadRangeInfo */ ,
- NULL /* Iterator */ ,
- NULL /* Value_Lists */ ,
- NULL /* COV */ ,
- NULL /* COV Clear */ ,
- NULL /* Intrinsic Reporting */ },
- {MAX_BACNET_OBJECT_TYPE,
- NULL /* Init */ ,
- NULL /* Count */ ,
- NULL /* Index_To_Instance */ ,
- NULL /* Valid_Instance */ ,
- NULL /* Object_Name */ ,
- NULL /* Read_Property */ ,
- NULL /* Write_Property */ ,
- NULL /* Property_Lists */ ,
- NULL /* ReadRangeInfo */ ,
- NULL /* Iterator */ ,
- NULL /* Value_Lists */ ,
- NULL /* COV */ ,
- NULL /* COV Clear */ ,
- NULL /* Intrinsic Reporting */ }
-};
-
-/** Glue function to let the Device object, when called by a handler,
- * lookup which Object type needs to be invoked.
- * @ingroup ObjHelpers
- * @param Object_Type [in] The type of BACnet Object the handler wants to access.
- * @return Pointer to the group of object helper functions that implement this
- * type of Object.
- */
-static struct object_functions *Device_Objects_Find_Functions(
- BACNET_OBJECT_TYPE Object_Type)
-{
- struct object_functions *pObject = NULL;
-
- pObject = &Object_Table[0];
- while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
- /* handle each object type */
- if (pObject->Object_Type == Object_Type) {
- return (pObject);
- }
-
- pObject++;
- }
-
- return (NULL);
-}
-
-unsigned Device_Count(
- void)
-{
- return 1;
-}
-
-uint32_t Device_Index_To_Instance(
- unsigned index)
-{
- index = index;
- return Object_Instance_Number;
-}
-
-/* methods to manipulate the data */
-
-/** Return the Object Instance number for our (single) Device Object.
- * This is a key function, widely invoked by the handler code, since
- * it provides "our" (ie, local) address.
- * @ingroup ObjIntf
- * @return The Instance number used in the BACNET_OBJECT_ID for the Device.
- */
-uint32_t Device_Object_Instance_Number(
- void)
-{
-#ifdef BAC_ROUTING
- return Routed_Device_Object_Instance_Number();
-#else
- return Object_Instance_Number;
-#endif
-}
-
-bool Device_Set_Object_Instance_Number(
- uint32_t object_id)
-{
- bool status = true; /* return value */
-
- if (object_id <= BACNET_MAX_INSTANCE) {
- /* Make the change and update the database revision */
- Object_Instance_Number = object_id;
- Device_Inc_Database_Revision();
- } else
- status = false;
-
- return status;
-}
-
-bool Device_Valid_Object_Instance_Number(
- uint32_t object_id)
-{
- return (Object_Instance_Number == object_id);
-}
-
-bool Device_Object_Name(
- uint32_t object_instance,
- BACNET_CHARACTER_STRING * object_name)
-{
- bool status = false;
-
- if (object_instance == Object_Instance_Number) {
- status = characterstring_copy(object_name, &My_Object_Name);
- }
-
- return status;
-}
-
-bool Device_Set_Object_Name(
- BACNET_CHARACTER_STRING * object_name)
-{
- bool status = false; /*return value */
-
- if (!characterstring_same(&My_Object_Name, object_name)) {
- /* Make the change and update the database revision */
- status = characterstring_copy(&My_Object_Name, object_name);
- Device_Inc_Database_Revision();
- }
-
- return status;
-}
-
-BACNET_DEVICE_STATUS Device_System_Status(
- void)
-{
- return System_Status;
-}
-
-int Device_Set_System_Status(
- BACNET_DEVICE_STATUS status,
- bool local)
-{
- int result = 0; /*return value - 0 = ok, -1 = bad value, -2 = not allowed */
-
- /* We limit the options available depending on whether the source is
- * internal or external. */
- if (local) {
- switch (status) {
- case STATUS_OPERATIONAL:
- case STATUS_OPERATIONAL_READ_ONLY:
- case STATUS_DOWNLOAD_REQUIRED:
- case STATUS_DOWNLOAD_IN_PROGRESS:
- case STATUS_NON_OPERATIONAL:
- System_Status = status;
- break;
-
- /* Don't support backup at present so don't allow setting */
- case STATUS_BACKUP_IN_PROGRESS:
- result = -2;
- break;
-
- default:
- result = -1;
- break;
- }
- } else {
- switch (status) {
- /* Allow these for the moment as a way to easily alter
- * overall device operation. The lack of password protection
- * or other authentication makes allowing writes to this
- * property a risky facility to provide.
- */
- case STATUS_OPERATIONAL:
- case STATUS_OPERATIONAL_READ_ONLY:
- case STATUS_NON_OPERATIONAL:
- System_Status = status;
- break;
-
- /* Don't allow outsider set this - it should probably
- * be set if the device config is incomplete or
- * corrupted or perhaps after some sort of operator
- * wipe operation.
- */
- case STATUS_DOWNLOAD_REQUIRED:
- /* Don't allow outsider set this - it should be set
- * internally at the start of a multi packet download
- * perhaps indirectly via PT or WF to a config file.
- */
- case STATUS_DOWNLOAD_IN_PROGRESS:
- /* Don't support backup at present so don't allow setting */
- case STATUS_BACKUP_IN_PROGRESS:
- result = -2;
- break;
-
- default:
- result = -1;
- break;
- }
- }
-
- return (result);
-}
-
-const char *Device_Vendor_Name(
- void)
-{
- return Vendor_Name;
-}
-
-/** Returns the Vendor ID for this Device.
- * See the assignments at http://www.bacnet.org/VendorID/BACnet%20Vendor%20IDs.htm
- * @return The Vendor ID of this Device.
- */
-uint16_t Device_Vendor_Identifier(
- void)
-{
- return Vendor_Identifier;
-}
-
-void Device_Set_Vendor_Identifier(
- uint16_t vendor_id)
-{
- Vendor_Identifier = vendor_id;
-}
-
-const char *Device_Model_Name(
- void)
-{
- return Model_Name;
-}
-
-bool Device_Set_Model_Name(
- const char *name,
- size_t length)
-{
- bool status = false; /*return value */
-
- if (length < sizeof(Model_Name)) {
- memmove(Model_Name, name, length);
- Model_Name[length] = 0;
- status = true;
- }
-
- return status;
-}
-
-const char *Device_Firmware_Revision(
- void)
-{
- return BACnet_Version;
-}
-
-const char *Device_Application_Software_Version(
- void)
-{
- return Application_Software_Version;
-}
-
-bool Device_Set_Application_Software_Version(
- const char *name,
- size_t length)
-{
- bool status = false; /*return value */
-
- if (length < sizeof(Application_Software_Version)) {
- memmove(Application_Software_Version, name, length);
- Application_Software_Version[length] = 0;
- status = true;
- }
-
- return status;
-}
-
-const char *Device_Description(
- void)
-{
- return Description;
-}
-
-bool Device_Set_Description(
- const char *name,
- size_t length)
-{
- bool status = false; /*return value */
-
- if (length < sizeof(Description)) {
- memmove(Description, name, length);
- Description[length] = 0;
- status = true;
- }
-
- return status;
-}
-
-const char *Device_Location(
- void)
-{
- return Location;
-}
-
-bool Device_Set_Location(
- const char *name,
- size_t length)
-{
- bool status = false; /*return value */
-
- if (length < sizeof(Location)) {
- memmove(Location, name, length);
- Location[length] = 0;
- status = true;
- }
-
- return status;
-}
-
-uint8_t Device_Protocol_Version(
- void)
-{
- return BACNET_PROTOCOL_VERSION;
-}
-
-uint8_t Device_Protocol_Revision(
- void)
-{
- return BACNET_PROTOCOL_REVISION;
-}
-
-BACNET_SEGMENTATION Device_Segmentation_Supported(
- void)
-{
- return SEGMENTATION_NONE;
-}
-
-uint32_t Device_Database_Revision(
- void)
-{
- return Database_Revision;
-}
-
-void Device_Set_Database_Revision(
- uint32_t revision)
-{
- Database_Revision = revision;
-}
-
-/*
- * Shortcut for incrementing database revision as this is potentially
- * the most common operation if changing object names and ids is
- * implemented.
- */
-void Device_Inc_Database_Revision(
- void)
-{
- Database_Revision++;
-}
-
-/** Get the total count of objects supported by this Device Object.
- * @note Since many network clients depend on the object list
- * for discovery, it must be consistent!
- * @return The count of objects, for all supported Object types.
- */
-unsigned Device_Object_List_Count(
- void)
-{
- unsigned count = 0; /* number of objects */
- struct object_functions *pObject = NULL;
-
- /* initialize the default return values */
- pObject = &Object_Table[0];
- while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
- if (pObject->Object_Count) {
- count += pObject->Object_Count();
- }
- pObject++;
- }
-
- return count;
-}
-
-/** Lookup the Object at the given array index in the Device's Object List.
- * Even though we don't keep a single linear array of objects in the Device,
- * this method acts as though we do and works through a virtual, concatenated
- * array of all of our object type arrays.
- *
- * @param array_index [in] The desired array index (1 to N)
- * @param object_type [out] The object's type, if found.
- * @param instance [out] The object's instance number, if found.
- * @return True if found, else false.
- */
-bool Device_Object_List_Identifier(
- unsigned array_index,
- int *object_type,
- uint32_t * instance)
-{
- bool status = false;
- unsigned count = 0;
- unsigned object_index = 0;
- unsigned temp_index = 0;
- struct object_functions *pObject = NULL;
-
- /* array index zero is length - so invalid */
- if (array_index == 0) {
- return status;
- }
- object_index = array_index - 1;
- /* initialize the default return values */
- pObject = &Object_Table[0];
- while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
- if (pObject->Object_Count) {
- object_index -= count;
- count = pObject->Object_Count();
- if (object_index < count) {
- /* Use the iterator function if available otherwise
- * look for the index to instance to get the ID */
- if (pObject->Object_Iterator) {
- /* First find the first object */
- temp_index = pObject->Object_Iterator(~(unsigned) 0);
- /* Then step through the objects to find the nth */
- while (object_index != 0) {
- temp_index = pObject->Object_Iterator(temp_index);
- object_index--;
- }
- /* set the object_index up before falling through to next bit */
- object_index = temp_index;
- }
- if (pObject->Object_Index_To_Instance) {
- *object_type = pObject->Object_Type;
- *instance =
- pObject->Object_Index_To_Instance(object_index);
- status = true;
- break;
- }
- }
- }
- pObject++;
- }
-
- return status;
-}
-
-/** Determine if we have an object with the given object_name.
- * If the object_type and object_instance pointers are not null,
- * and the lookup succeeds, they will be given the resulting values.
- * @param object_name [in] The desired Object Name to look for.
- * @param object_type [out] The BACNET_OBJECT_TYPE of the matching Object.
- * @param object_instance [out] The object instance number of the matching Object.
- * @return True on success or else False if not found.
- */
-bool Device_Valid_Object_Name(
- BACNET_CHARACTER_STRING * object_name1,
- int *object_type,
- uint32_t * object_instance)
-{
- bool found = false;
- int type = 0;
- uint32_t instance;
- unsigned max_objects = 0, i = 0;
- bool check_id = false;
- BACNET_CHARACTER_STRING object_name2;
- struct object_functions *pObject = NULL;
-
- max_objects = Device_Object_List_Count();
- for (i = 1; i <= max_objects; i++) {
- check_id = Device_Object_List_Identifier(i, &type, &instance);
- if (check_id) {
- pObject = Device_Objects_Find_Functions(type);
- if ((pObject != NULL) && (pObject->Object_Name != NULL) &&
- (pObject->Object_Name(instance, &object_name2) &&
- characterstring_same(object_name1, &object_name2))) {
- found = true;
- if (object_type) {
- *object_type = type;
- }
- if (object_instance) {
- *object_instance = instance;
- }
- break;
- }
- }
- }
-
- return found;
-}
-
-/** Determine if we have an object of this type and instance number.
- * @param object_type [in] The desired BACNET_OBJECT_TYPE
- * @param object_instance [in] The object instance number to be looked up.
- * @return True if found, else False if no such Object in this device.
- */
-bool Device_Valid_Object_Id(
- int object_type,
- uint32_t object_instance)
-{
- bool status = false; /* return value */
- struct object_functions *pObject = NULL;
-
- pObject = Device_Objects_Find_Functions(object_type);
- if ((pObject != NULL) && (pObject->Object_Valid_Instance != NULL)) {
- status = pObject->Object_Valid_Instance(object_instance);
- }
-
- return status;
-}
-
-/** Copy a child object's object_name value, given its ID.
- * @param object_type [in] The BACNET_OBJECT_TYPE of the child Object.
- * @param object_instance [in] The object instance number of the child Object.
- * @param object_name [out] The Object Name found for this child Object.
- * @return True on success or else False if not found.
- */
-bool Device_Object_Name_Copy(
- BACNET_OBJECT_TYPE object_type,
- uint32_t object_instance,
- BACNET_CHARACTER_STRING * object_name)
-{
- struct object_functions *pObject = NULL;
- bool found = false;
-
- pObject = Device_Objects_Find_Functions(object_type);
- if ((pObject != NULL) && (pObject->Object_Name != NULL)) {
- found = pObject->Object_Name(object_instance, object_name);
- }
-
- return found;
-}
-
-static void Update_Current_Time(
- void)
-{
- struct tm *tblock = NULL;
-#if defined(_MSC_VER)
- time_t tTemp;
-#else
- struct timeval tv;
-#endif
-/*
-struct tm
-
-int tm_sec Seconds [0,60].
-int tm_min Minutes [0,59].
-int tm_hour Hour [0,23].
-int tm_mday Day of month [1,31].
-int tm_mon Month of year [0,11].
-int tm_year Years since 1900.
-int tm_wday Day of week [0,6] (Sunday =0).
-int tm_yday Day of year [0,365].
-int tm_isdst Daylight Savings flag.
-*/
-#if defined(_MSC_VER)
- time(&tTemp);
- tblock = (struct tm *)localtime(&tTemp);
-#else
- if (gettimeofday(&tv, NULL) == 0) {
- tblock = (struct tm *)localtime((const time_t *)&tv.tv_sec);
- }
-#endif
-
- if (tblock) {
- datetime_set_date(&Local_Date, (uint16_t) tblock->tm_year + 1900,
- (uint8_t) tblock->tm_mon + 1, (uint8_t) tblock->tm_mday);
-#if !defined(_MSC_VER)
- datetime_set_time(&Local_Time, (uint8_t) tblock->tm_hour,
- (uint8_t) tblock->tm_min, (uint8_t) tblock->tm_sec,
- (uint8_t) (tv.tv_usec / 10000));
-#else
- datetime_set_time(&Local_Time, (uint8_t) tblock->tm_hour,
- (uint8_t) tblock->tm_min, (uint8_t) tblock->tm_sec, 0);
-#endif
- if (tblock->tm_isdst) {
- Daylight_Savings_Status = true;
- } else {
- Daylight_Savings_Status = false;
- }
- /* note: timezone is declared in <time.h> stdlib. */
- UTC_Offset = timezone / 60;
- } else {
- datetime_date_wildcard_set(&Local_Date);
- datetime_time_wildcard_set(&Local_Time);
- Daylight_Savings_Status = false;
- }
-}
-
-void Device_getCurrentDateTime(
- BACNET_DATE_TIME * DateTime)
-{
- Update_Current_Time();
-
- DateTime->date = Local_Date;
- DateTime->time = Local_Time;
-}
-
-int32_t Device_UTC_Offset(void)
-{
- Update_Current_Time();
-
- return UTC_Offset;
-}
-
-bool Device_Daylight_Savings_Status(void)
-{
- return Daylight_Savings_Status;
-}
-
-/* return the length of the apdu encoded or BACNET_STATUS_ERROR for error or
- BACNET_STATUS_ABORT for abort message */
-int Device_Read_Property_Local(
- BACNET_READ_PROPERTY_DATA * rpdata)
-{
- int apdu_len = 0; /* return value */
- int len = 0; /* apdu len intermediate value */
- BACNET_BIT_STRING bit_string;
- BACNET_CHARACTER_STRING char_string;
- unsigned i = 0;
- int object_type = 0;
- uint32_t instance = 0;
- unsigned count = 0;
- uint8_t *apdu = NULL;
- struct object_functions *pObject = NULL;
- bool found = false;
-
- if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
- (rpdata->application_data_len == 0)) {
- return 0;
- }
- apdu = rpdata->application_data;
- switch (rpdata->object_property) {
- case PROP_OBJECT_IDENTIFIER:
- apdu_len =
- encode_application_object_id(&apdu[0], OBJECT_DEVICE,
- Object_Instance_Number);
- break;
- case PROP_OBJECT_NAME:
- apdu_len =
- encode_application_character_string(&apdu[0], &My_Object_Name);
- break;
- case PROP_OBJECT_TYPE:
- apdu_len = encode_application_enumerated(&apdu[0], OBJECT_DEVICE);
- break;
- case PROP_DESCRIPTION:
- characterstring_init_ansi(&char_string, Description);
- apdu_len =
- encode_application_character_string(&apdu[0], &char_string);
- break;
- case PROP_SYSTEM_STATUS:
- apdu_len = encode_application_enumerated(&apdu[0], System_Status);
- break;
- case PROP_VENDOR_NAME:
- characterstring_init_ansi(&char_string, Vendor_Name);
- apdu_len =
- encode_application_character_string(&apdu[0], &char_string);
- break;
- case PROP_VENDOR_IDENTIFIER:
- apdu_len =
- encode_application_unsigned(&apdu[0], Vendor_Identifier);
- break;
- case PROP_MODEL_NAME:
- characterstring_init_ansi(&char_string, Model_Name);
- apdu_len =
- encode_application_character_string(&apdu[0], &char_string);
- break;
- case PROP_FIRMWARE_REVISION:
- characterstring_init_ansi(&char_string, BACnet_Version);
- apdu_len =
- encode_application_character_string(&apdu[0], &char_string);
- break;
- case PROP_APPLICATION_SOFTWARE_VERSION:
- characterstring_init_ansi(&char_string,
- Application_Software_Version);
- apdu_len =
- encode_application_character_string(&apdu[0], &char_string);
- break;
- case PROP_LOCATION:
- characterstring_init_ansi(&char_string, Location);
- apdu_len =
- encode_application_character_string(&apdu[0], &char_string);
- break;
- case PROP_PROTOCOL_VERSION:
- apdu_len =
- encode_application_unsigned(&apdu[0],
- Device_Protocol_Version());
- break;
- case PROP_PROTOCOL_REVISION:
- apdu_len =
- encode_application_unsigned(&apdu[0],
- Device_Protocol_Revision());
- break;
- case PROP_PROTOCOL_SERVICES_SUPPORTED:
- /* Note: list of services that are executed, not initiated. */
- bitstring_init(&bit_string);
- for (i = 0; i < MAX_BACNET_SERVICES_SUPPORTED; i++) {
- /* automatic lookup based on handlers set */
- bitstring_set_bit(&bit_string, (uint8_t) i,
- apdu_service_supported((BACNET_SERVICES_SUPPORTED) i));
- }
- apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
- break;
- case PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED:
- /* Note: this is the list of objects that can be in this device,
- not a list of objects that this device can access */
- bitstring_init(&bit_string);
- for (i = 0; i < MAX_ASHRAE_OBJECT_TYPE; i++) {
- /* initialize all the object types to not-supported */
- bitstring_set_bit(&bit_string, (uint8_t) i, false);
- }
- /* set the object types with objects to supported */
-
- pObject = &Object_Table[0];
- while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
- if ((pObject->Object_Count) && (pObject->Object_Count() > 0)) {
- bitstring_set_bit(&bit_string, pObject->Object_Type, true);
- }
- pObject++;
- }
- apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
- break;
- case PROP_OBJECT_LIST:
- count = Device_Object_List_Count();
- /* Array element zero is the number of objects in the list */
- if (rpdata->array_index == 0)
- apdu_len = encode_application_unsigned(&apdu[0], count);
- /* if no index was specified, then try to encode the entire list */
- /* into one packet. Note that more than likely you will have */
- /* to return an error if the number of encoded objects exceeds */
- /* your maximum APDU size. */
- else if (rpdata->array_index == BACNET_ARRAY_ALL) {
- for (i = 1; i <= count; i++) {
- found =
- Device_Object_List_Identifier(i, &object_type,
- &instance);
- if (found) {
- len =
- encode_application_object_id(&apdu[apdu_len],
- object_type, instance);
- apdu_len += len;
- /* assume next one is the same size as this one */
- /* can we all fit into the APDU? Don't check for last entry */
- if ((i != count) && (apdu_len + len) >= MAX_APDU) {
- /* Abort response */
- rpdata->error_code =
- ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
- apdu_len = BACNET_STATUS_ABORT;
- break;
- }
- } else {
- /* error: internal error? */
- rpdata->error_class = ERROR_CLASS_SERVICES;
- rpdata->error_code = ERROR_CODE_OTHER;
- apdu_len = BACNET_STATUS_ERROR;
- break;
- }
- }
- } else {
- found =
- Device_Object_List_Identifier(rpdata->array_index,
- &object_type, &instance);
- if (found) {
- apdu_len =
- encode_application_object_id(&apdu[0], object_type,
- instance);
- } else {
- rpdata->error_class = ERROR_CLASS_PROPERTY;
- rpdata->error_code = ERROR_CODE_INVALID_ARRAY_INDEX;
- apdu_len = BACNET_STATUS_ERROR;
- }
- }
- break;
- case PROP_MAX_APDU_LENGTH_ACCEPTED:
- apdu_len = encode_application_unsigned(&apdu[0], MAX_APDU);
- break;
- case PROP_SEGMENTATION_SUPPORTED:
- apdu_len =
- encode_application_enumerated(&apdu[0],
- Device_Segmentation_Supported());
- break;
- case PROP_APDU_TIMEOUT:
- apdu_len = encode_application_unsigned(&apdu[0], apdu_timeout());
- break;
- case PROP_NUMBER_OF_APDU_RETRIES:
- apdu_len = encode_application_unsigned(&apdu[0], apdu_retries());
- break;
- case PROP_DEVICE_ADDRESS_BINDING:
- /* FIXME: the real max apdu remaining should be passed into function */
- apdu_len = address_list_encode(&apdu[0], MAX_APDU);
- break;
- case PROP_DATABASE_REVISION:
- apdu_len =
- encode_application_unsigned(&apdu[0], Database_Revision);
- break;
-#if defined(BACDL_MSTP)
- case PROP_MAX_INFO_FRAMES:
- apdu_len =
- encode_application_unsigned(&apdu[0],
- dlmstp_max_info_frames());
- break;
- case PROP_MAX_MASTER:
- apdu_len =
- encode_application_unsigned(&apdu[0], dlmstp_max_master());
- break;
-#endif
- case PROP_ACTIVE_COV_SUBSCRIPTIONS:
- break;
- default:
- rpdata->error_class = ERROR_CLASS_PROPERTY;
- rpdata->error_code = ERROR_CODE_UNKNOWN_PROPERTY;
- apdu_len = BACNET_STATUS_ERROR;
- break;
- }
- /* only array properties can have array options */
- if ((apdu_len >= 0) && (rpdata->object_property != PROP_OBJECT_LIST) &&
- (rpdata->array_index != BACNET_ARRAY_ALL)) {
- rpdata->error_class = ERROR_CLASS_PROPERTY;
- rpdata->error_code = ERROR_CODE_PROPERTY_IS_NOT_AN_ARRAY;
- apdu_len = BACNET_STATUS_ERROR;
- }
-
- return apdu_len;
-}
-
-/** Looks up the requested Object and Property, and encodes its Value in an APDU.
- * @ingroup ObjIntf
- * If the Object or Property can't be found, sets the error class and code.
- *
- * @param rpdata [in,out] Structure with the desired Object and Property info
- * on entry, and APDU message on return.
- * @return The length of the APDU on success, else BACNET_STATUS_ERROR
- */
-int Device_Read_Property(
- BACNET_READ_PROPERTY_DATA * rpdata)
-{
- int apdu_len = BACNET_STATUS_ERROR;
- struct object_functions *pObject = NULL;
-
- /* initialize the default return values */
- rpdata->error_class = ERROR_CLASS_OBJECT;
- rpdata->error_code = ERROR_CODE_UNKNOWN_OBJECT;
- pObject = Device_Objects_Find_Functions(rpdata->object_type);
- if (pObject != NULL) {
- if (pObject->Object_Valid_Instance &&
- pObject->Object_Valid_Instance(rpdata->object_instance)) {
- if (pObject->Object_Read_Property) {
- apdu_len = pObject->Object_Read_Property(rpdata);
- }
- } else {
- rpdata->error_class = ERROR_CLASS_OBJECT;
- rpdata->error_code = ERROR_CODE_UNKNOWN_OBJECT;
- }
- } else {
- rpdata->error_class = ERROR_CLASS_OBJECT;
- rpdata->error_code = ERROR_CODE_UNKNOWN_OBJECT;
- }
-
- return apdu_len;
-}
-
-/** Initialize the Device Object.
- Initialize the group of object helper functions for any supported Object.
- Initialize each of the Device Object child Object instances.
- * @ingroup ObjIntf
- * @param object_table [in,out] array of structure with object functions.
- * Each Child Object must provide some implementation of each of these
- * functions in order to properly support the default handlers.
- */
-void Device_Init(
- object_functions_t * object_table)
-{
- struct object_functions *pObject = NULL;
-
- characterstring_init_ansi(&My_Object_Name, "SimpleClient");
- /* we don't use the object table passed in */
- (void) object_table;
- pObject = &Object_Table[0];
- while (pObject->Object_Type < MAX_BACNET_OBJECT_TYPE) {
- if (pObject->Object_Init) {
- pObject->Object_Init();
- }
- pObject++;
- }
-}
diff --git a/peripheral/libupm/src/bacnetmstp/device.h b/peripheral/libupm/src/bacnetmstp/device.h
deleted file mode 100644
index b9c54db..0000000
--- a/peripheral/libupm/src/bacnetmstp/device.h
+++ /dev/null
@@ -1,465 +0,0 @@
-/**************************************************************************
-*
-* Copyright (C) 2005 Steve Karg <skarg@users.sourceforge.net>
-*
-* Permission is hereby granted, free of charge, to any person obtaining
-* a copy of this software and associated documentation files (the
-* "Software"), to deal in the Software without restriction, including
-* without limitation the rights to use, copy, modify, merge, publish,
-* distribute, sublicense, and/or sell copies of the Software, and to
-* permit persons to whom the Software is furnished to do so, subject to
-* the following conditions:
-*
-* The above copyright notice and this permission notice shall be included
-* in all copies or substantial portions of the Software.
-*
-* 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.
-*
-*********************************************************************/
-
-/** @file device.h Defines functions for handling all BACnet objects belonging
- * to a BACnet device, as well as Device-specific properties. */
-
-#ifndef DEVICE_H
-#define DEVICE_H
-
-#include <stdbool.h>
-#include <stdint.h>
-#include "bacdef.h"
-#include "bacenum.h"
-#include "wp.h"
-#include "rd.h"
-#include "rp.h"
-#include "rpm.h"
-#include "readrange.h"
-
-/** Called so a BACnet object can perform any necessary initialization.
- * @ingroup ObjHelpers
- */
-typedef void (
- *object_init_function) (
- void);
-
-/** Counts the number of objects of this type.
- * @ingroup ObjHelpers
- * @return Count of implemented objects of this type.
- */
-typedef unsigned (
- *object_count_function) (
- void);
-
-/** Maps an object index position to its corresponding BACnet object instance number.
- * @ingroup ObjHelpers
- * @param index [in] The index of the object, in the array of objects of its type.
- * @return The BACnet object instance number to be used in a BACNET_OBJECT_ID.
- */
-typedef uint32_t(
- *object_index_to_instance_function)
- (
- unsigned index);
-
-/** Provides the BACnet Object_Name for a given object instance of this type.
- * @ingroup ObjHelpers
- * @param object_instance [in] The object instance number to be looked up.
- * @param object_name [in,out] Pointer to a character_string structure that
- * will hold a copy of the object name if this is a valid object_instance.
- * @return True if the object_instance is valid and object_name has been
- * filled with a copy of the Object's name.
- */
-typedef bool(
- *object_name_function)
- (
- uint32_t object_instance,
- BACNET_CHARACTER_STRING * object_name);
-
-/** Look in the table of objects of this type, and see if this is a valid
- * instance number.
- * @ingroup ObjHelpers
- * @param [in] The object instance number to be looked up.
- * @return True if the object instance refers to a valid object of this type.
- */
-typedef bool(
- *object_valid_instance_function) (
- uint32_t object_instance);
-
-/** Helper function to step through an array of objects and find either the
- * first one or the next one of a given type. Used to step through an array
- * of objects which is not necessarily contiguious for each type i.e. the
- * index for the 'n'th object of a given type is not necessarily 'n'.
- * @ingroup ObjHelpers
- * @param [in] The index of the current object or a value of ~0 to indicate
- * start at the beginning.
- * @return The index of the next object of the required type or ~0 (all bits
- * == 1) to indicate no more objects found.
- */
-typedef unsigned (
- *object_iterate_function) (
- unsigned current_index);
-
-/** Look in the table of objects of this type, and get the COV Value List.
- * @ingroup ObjHelpers
- * @param [in] The object instance number to be looked up.
- * @param [out] The value list
- * @return True if the object instance supports this feature, and has changed.
- */
-typedef bool(
- *object_value_list_function) (
- uint32_t object_instance,
- BACNET_PROPERTY_VALUE * value_list);
-
-/** Look in the table of objects for this instance to see if value changed.
- * @ingroup ObjHelpers
- * @param [in] The object instance number to be looked up.
- * @return True if the object instance has changed.
- */
-typedef bool(
- *object_cov_function) (
- uint32_t object_instance);
-
-/** Look in the table of objects for this instance to clear the changed flag.
- * @ingroup ObjHelpers
- * @param [in] The object instance number to be looked up.
- */
-typedef void (
- *object_cov_clear_function) (
- uint32_t object_instance);
-
-/** Intrinsic Reporting funcionality.
- * @ingroup ObjHelpers
- * @param [in] Object instance.
- */
-typedef void (
- *object_intrinsic_reporting_function) (
- uint32_t object_instance);
-
-
-/** Defines the group of object helper functions for any supported Object.
- * @ingroup ObjHelpers
- * Each Object must provide some implementation of each of these helpers
- * in order to properly support the handlers. Eg, the ReadProperty handler
- * handler_read_property() relies on the instance of Object_Read_Property
- * for each Object type, or configure the function as NULL.
- * In both appearance and operation, this group of functions acts like
- * they are member functions of a C++ Object base class.
- */
-typedef struct object_functions {
- BACNET_OBJECT_TYPE Object_Type;
- object_init_function Object_Init;
- object_count_function Object_Count;
- object_index_to_instance_function Object_Index_To_Instance;
- object_valid_instance_function Object_Valid_Instance;
- object_name_function Object_Name;
- read_property_function Object_Read_Property;
- write_property_function Object_Write_Property;
- rpm_property_lists_function Object_RPM_List;
- rr_info_function Object_RR_Info;
- object_iterate_function Object_Iterator;
- object_value_list_function Object_Value_List;
- object_cov_function Object_COV;
- object_cov_clear_function Object_COV_Clear;
- object_intrinsic_reporting_function Object_Intrinsic_Reporting;
-} object_functions_t;
-
-/* String Lengths - excluding any nul terminator */
-#define MAX_DEV_NAME_LEN 32
-#define MAX_DEV_LOC_LEN 64
-#define MAX_DEV_MOD_LEN 32
-#define MAX_DEV_VER_LEN 16
-#define MAX_DEV_DESC_LEN 64
-
-/** Structure to define the Object Properties common to all Objects. */
-typedef struct commonBacObj_s {
-
- /** The BACnet type of this object (ie, what class is this object from?).
- * This property, of type BACnetObjectType, indicates membership in a
- * particular object type class. Each inherited class will be of one type.
- */
- BACNET_OBJECT_TYPE mObject_Type;
-
- /** The instance number for this class instance. */
- uint32_t Object_Instance_Number;
-
- /** Object Name; must be unique.
- * This property, of type CharacterString, shall represent a name for
- * the object that is unique within the BACnet Device that maintains it.
- */
- char Object_Name[MAX_DEV_NAME_LEN];
-
-} COMMON_BAC_OBJECT;
-
-
-/** Structure to define the Properties of Device Objects which distinguish
- * one instance from another.
- * This structure only defines fields for properties that are unique to
- * a given Device object. The rest may be fixed in device.c or hard-coded
- * into the read-property encoding.
- * This may be useful for implementations which manage multiple Devices,
- * eg, a Gateway.
- */
-typedef struct devObj_s {
- /** The BACnet Device Address for this device; ->len depends on DLL type. */
- BACNET_ADDRESS bacDevAddr;
-
- /** Structure for the Object Properties common to all Objects. */
- COMMON_BAC_OBJECT bacObj;
-
- /** Device Description. */
- char Description[MAX_DEV_DESC_LEN];
-
- /** The upcounter that shows if the Device ID or object structure has changed. */
- uint32_t Database_Revision;
-} DEVICE_OBJECT_DATA;
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
- void Device_Init(
- object_functions_t * object_table);
-
- bool Device_Reinitialize(
- BACNET_REINITIALIZE_DEVICE_DATA * rd_data);
-
- BACNET_REINITIALIZED_STATE Device_Reinitialized_State(
- void);
-
- rr_info_function Device_Objects_RR_Info(
- BACNET_OBJECT_TYPE object_type);
-
- void Device_getCurrentDateTime(
- BACNET_DATE_TIME * DateTime);
- int32_t Device_UTC_Offset(void);
- bool Device_Daylight_Savings_Status(void);
-
- void Device_Property_Lists(
- const int **pRequired,
- const int **pOptional,
- const int **pProprietary);
- void Device_Objects_Property_List(
- BACNET_OBJECT_TYPE object_type,
- struct special_property_list_t *pPropertyList);
- /* functions to support COV */
- bool Device_Encode_Value_List(
- BACNET_OBJECT_TYPE object_type,
- uint32_t object_instance,
- BACNET_PROPERTY_VALUE * value_list);
- bool Device_Value_List_Supported(
- BACNET_OBJECT_TYPE object_type);
- bool Device_COV(
- BACNET_OBJECT_TYPE object_type,
- uint32_t object_instance);
- void Device_COV_Clear(
- BACNET_OBJECT_TYPE object_type,
- uint32_t object_instance);
-
- uint32_t Device_Object_Instance_Number(
- void);
- bool Device_Set_Object_Instance_Number(
- uint32_t object_id);
- bool Device_Valid_Object_Instance_Number(
- uint32_t object_id);
- unsigned Device_Object_List_Count(
- void);
- bool Device_Object_List_Identifier(
- unsigned array_index,
- int *object_type,
- uint32_t * instance);
-
- unsigned Device_Count(
- void);
- uint32_t Device_Index_To_Instance(
- unsigned index);
-
- bool Device_Object_Name(
- uint32_t object_instance,
- BACNET_CHARACTER_STRING * object_name);
- bool Device_Set_Object_Name(
- BACNET_CHARACTER_STRING * object_name);
- /* Copy a child object name, given its ID. */
- bool Device_Object_Name_Copy(
- BACNET_OBJECT_TYPE object_type,
- uint32_t object_instance,
- BACNET_CHARACTER_STRING * object_name);
- bool Device_Object_Name_ANSI_Init(const char * value);
-
- BACNET_DEVICE_STATUS Device_System_Status(
- void);
- int Device_Set_System_Status(
- BACNET_DEVICE_STATUS status,
- bool local);
-
- const char *Device_Vendor_Name(
- void);
-
- uint16_t Device_Vendor_Identifier(
- void);
- void Device_Set_Vendor_Identifier(
- uint16_t vendor_id);
-
- const char *Device_Model_Name(
- void);
- bool Device_Set_Model_Name(
- const char *name,
- size_t length);
-
- const char *Device_Firmware_Revision(
- void);
-
- const char *Device_Application_Software_Version(
- void);
- bool Device_Set_Application_Software_Version(
- const char *name,
- size_t length);
-
- const char *Device_Description(
- void);
- bool Device_Set_Description(
- const char *name,
- size_t length);
-
- const char *Device_Location(
- void);
- bool Device_Set_Location(
- const char *name,
- size_t length);
-
- /* some stack-centric constant values - no set methods */
- uint8_t Device_Protocol_Version(
- void);
- uint8_t Device_Protocol_Revision(
- void);
- BACNET_SEGMENTATION Device_Segmentation_Supported(
- void);
-
- uint32_t Device_Database_Revision(
- void);
- void Device_Set_Database_Revision(
- uint32_t revision);
- void Device_Inc_Database_Revision(
- void);
-
- bool Device_Valid_Object_Name(
- BACNET_CHARACTER_STRING * object_name,
- int *object_type,
- uint32_t * object_instance);
- bool Device_Valid_Object_Id(
- int object_type,
- uint32_t object_instance);
-
- int Device_Read_Property(
- BACNET_READ_PROPERTY_DATA * rpdata);
- bool Device_Write_Property(
- BACNET_WRITE_PROPERTY_DATA * wp_data);
-
- bool DeviceGetRRInfo(
- BACNET_READ_RANGE_DATA * pRequest, /* Info on the request */
- RR_PROP_INFO * pInfo); /* Where to put the information */
-
- int Device_Read_Property_Local(
- BACNET_READ_PROPERTY_DATA * rpdata);
- bool Device_Write_Property_Local(
- BACNET_WRITE_PROPERTY_DATA * wp_data);
-
-#if defined(INTRINSIC_REPORTING)
- void Device_local_reporting(
- void);
-#endif
-
-/* Prototypes for Routing functionality in the Device Object.
- * Enable by defining BAC_ROUTING in config.h and including gw_device.c
- * in the build (lib/Makefile).
- */
- void Routing_Device_Init(
- uint32_t first_object_instance);
-
- uint16_t Add_Routed_Device(
- uint32_t Object_Instance,
- BACNET_CHARACTER_STRING * Object_Name,
- const char *Description);
- DEVICE_OBJECT_DATA *Get_Routed_Device_Object(
- int idx);
- BACNET_ADDRESS *Get_Routed_Device_Address(
- int idx);
-
- void routed_get_my_address(
- BACNET_ADDRESS * my_address);
-
- bool Routed_Device_Address_Lookup(
- int idx,
- uint8_t address_len,
- uint8_t * mac_adress);
- bool Routed_Device_GetNext(
- BACNET_ADDRESS * dest,
- int *DNET_list,
- int *cursor);
- bool Routed_Device_Is_Valid_Network(
- uint16_t dest_net,
- int *DNET_list);
-
- uint32_t Routed_Device_Index_To_Instance(
- unsigned index);
- bool Routed_Device_Valid_Object_Instance_Number(
- uint32_t object_id);
- bool Routed_Device_Name(
- uint32_t object_instance,
- BACNET_CHARACTER_STRING * object_name);
- uint32_t Routed_Device_Object_Instance_Number(
- void);
- bool Routed_Device_Set_Object_Instance_Number(
- uint32_t object_id);
- bool Routed_Device_Set_Object_Name(
- uint8_t encoding,
- const char *value,
- size_t length);
- bool Routed_Device_Set_Description(
- const char *name,
- size_t length);
- void Routed_Device_Inc_Database_Revision(
- void);
- int Routed_Device_Service_Approval(
- BACNET_CONFIRMED_SERVICE service,
- int service_argument,
- uint8_t * apdu_buff,
- uint8_t invoke_id);
-
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-/** @defgroup ObjFrmwk Object Framework
- * The modules in this section describe the BACnet-stack's framework for
- * BACnet-defined Objects (Device, Analog Input, etc). There are two submodules
- * to describe this arrangement:
- * - The "object helper functions" which provide C++-like common functionality
- * to all supported object types.
- * - The interface between the implemented Objects and the BAC-stack services,
- * specifically the handlers, which are mediated through function calls to
- * the Device object.
- *//** @defgroup ObjHelpers Object Helper Functions
- * @ingroup ObjFrmwk
- * This section describes the function templates for the helper functions that
- * provide common object support.
- *//** @defgroup ObjIntf Handler-to-Object Interface Functions
- * @ingroup ObjFrmwk
- * This section describes the fairly limited set of functions that link the
- * BAC-stack handlers to the BACnet Object instances. All of these calls are
- * situated in the Device Object, which "knows" how to reach its child Objects.
- *
- * Most of these calls have a common operation:
- * -# Call Device_Objects_Find_Functions( for the desired Object_Type )
- * - Gets a pointer to the object_functions for this Type of Object.
- * -# Call the Object's Object_Valid_Instance( for the desired object_instance )
- * to make sure there is such an instance.
- * -# Call the Object helper function needed by the handler,
- * eg Object_Read_Property() for the RP handler.
- *
- */
-#endif
diff --git a/peripheral/libupm/src/bacnetmstp/javaupm_bacnetmstp.i b/peripheral/libupm/src/bacnetmstp/javaupm_bacnetmstp.i
deleted file mode 100644
index 4902e73..0000000
--- a/peripheral/libupm/src/bacnetmstp/javaupm_bacnetmstp.i
+++ /dev/null
@@ -1,23 +0,0 @@
-%module javaupm_bacnetmstp
-%include "../upm.i"
-%include "typemaps.i"
-%include "carrays_uint32_t.i"
-
-%{
- #include "bacnetmstp.hpp"
- #include "bacnetutil.hpp"
-%}
-
-%include "bacnetmstp.hpp"
-%include "bacnetutil.hpp"
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_bacnetmstp");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/bacnetmstp/jsupm_bacnetmstp.i b/peripheral/libupm/src/bacnetmstp/jsupm_bacnetmstp.i
deleted file mode 100644
index 1ee6dee..0000000
--- a/peripheral/libupm/src/bacnetmstp/jsupm_bacnetmstp.i
+++ /dev/null
@@ -1,11 +0,0 @@
-%module jsupm_bacnetmstp
-%include "../upm.i"
-%include "stdint.i"
-%include "cpointer.i"
-
-%pointer_functions(float, floatp);
-
-%include "bacnetmstp.hpp"
-%{
- #include "bacnetmstp.hpp"
-%}
diff --git a/peripheral/libupm/src/bacnetmstp/pyupm_bacnetmstp.i b/peripheral/libupm/src/bacnetmstp/pyupm_bacnetmstp.i
deleted file mode 100644
index 2fb74e1..0000000
--- a/peripheral/libupm/src/bacnetmstp/pyupm_bacnetmstp.i
+++ /dev/null
@@ -1,15 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_bacnetmstp
-%include "../upm.i"
-%include "stdint.i"
-%include "cpointer.i"
-
-%feature("autodoc", "3");
-
-%pointer_functions(float, floatp);
-
-%include "bacnetmstp.hpp"
-%{
- #include "bacnetmstp.hpp"
-%}
diff --git a/peripheral/libupm/src/bacnetmstp/timer.h b/peripheral/libupm/src/bacnetmstp/timer.h
deleted file mode 100644
index a2fff78..0000000
--- a/peripheral/libupm/src/bacnetmstp/timer.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**************************************************************************
-*
-* Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
-*
-* Permission is hereby granted, free of charge, to any person obtaining
-* a copy of this software and associated documentation files (the
-* "Software"), to deal in the Software without restriction, including
-* without limitation the rights to use, copy, modify, merge, publish,
-* distribute, sublicense, and/or sell copies of the Software, and to
-* permit persons to whom the Software is furnished to do so, subject to
-* the following conditions:
-*
-* The above copyright notice and this permission notice shall be included
-* in all copies or substantial portions of the Software.
-*
-* 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.
-*********************************************************************/
-#ifndef TIMER_H
-#define TIMER_H
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <sys/time.h> /* for timeval */
-
-/* Timer Module */
-#ifndef MAX_MILLISECOND_TIMERS
-#define TIMER_SILENCE 0
-#define MAX_MILLISECOND_TIMERS 1
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
- uint32_t timeGetTime(
- void);
-
- void timer_init(
- void);
- uint32_t timer_milliseconds(
- unsigned index);
- bool timer_elapsed_milliseconds(
- unsigned index,
- uint32_t value);
- bool timer_elapsed_seconds(
- unsigned index,
- uint32_t value);
- bool timer_elapsed_minutes(
- unsigned index,
- uint32_t seconds);
- uint32_t timer_milliseconds_set(
- unsigned index,
- uint32_t value);
- uint32_t timer_reset(
- unsigned index);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif
diff --git a/peripheral/libupm/src/biss0001/CMakeLists.txt b/peripheral/libupm/src/biss0001/CMakeLists.txt
index e4d418f..1e1223a 100644
--- a/peripheral/libupm/src/biss0001/CMakeLists.txt
+++ b/peripheral/libupm/src/biss0001/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "biss0001")
set (libdescription "upm biss0001 motion module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/biss0001/biss0001.cxx b/peripheral/libupm/src/biss0001/biss0001.cxx
index d19b324..7f366a7 100644
--- a/peripheral/libupm/src/biss0001/biss0001.cxx
+++ b/peripheral/libupm/src/biss0001/biss0001.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "biss0001.hpp"
+#include "biss0001.h"
using namespace upm;
diff --git a/peripheral/libupm/src/biss0001/biss0001.hpp b/peripheral/libupm/src/biss0001/biss0001.h
index 470f27b..470f27b 100644
--- a/peripheral/libupm/src/biss0001/biss0001.hpp
+++ b/peripheral/libupm/src/biss0001/biss0001.h
diff --git a/peripheral/libupm/src/biss0001/javaupm_biss0001.i b/peripheral/libupm/src/biss0001/javaupm_biss0001.i
index 0d7fae8..c841230 100644
--- a/peripheral/libupm/src/biss0001/javaupm_biss0001.i
+++ b/peripheral/libupm/src/biss0001/javaupm_biss0001.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "biss0001.hpp"
+ #include "biss0001.h"
%}
-%include "biss0001.hpp"
+%include "biss0001.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/biss0001/jsupm_biss0001.i b/peripheral/libupm/src/biss0001/jsupm_biss0001.i
index ce8fac6..bff6ccf 100644
--- a/peripheral/libupm/src/biss0001/jsupm_biss0001.i
+++ b/peripheral/libupm/src/biss0001/jsupm_biss0001.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "biss0001.hpp"
+ #include "biss0001.h"
%}
-%include "biss0001.hpp"
+%include "biss0001.h"
diff --git a/peripheral/libupm/src/biss0001/pyupm_biss0001.i b/peripheral/libupm/src/biss0001/pyupm_biss0001.i
index 15b92f7..c485f58 100644
--- a/peripheral/libupm/src/biss0001/pyupm_biss0001.i
+++ b/peripheral/libupm/src/biss0001/pyupm_biss0001.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "biss0001.hpp"
+%include "biss0001.h"
%{
- #include "biss0001.hpp"
+ #include "biss0001.h"
%}
diff --git a/peripheral/libupm/src/bma220/CMakeLists.txt b/peripheral/libupm/src/bma220/CMakeLists.txt
index 3cc8980..fcea4bb 100644
--- a/peripheral/libupm/src/bma220/CMakeLists.txt
+++ b/peripheral/libupm/src/bma220/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "bma220")
set (libdescription "accelerometer sensor based on bma220")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/bma220/bma220.cxx b/peripheral/libupm/src/bma220/bma220.cxx
index 4f540be..4148b93 100644
--- a/peripheral/libupm/src/bma220/bma220.cxx
+++ b/peripheral/libupm/src/bma220/bma220.cxx
@@ -28,7 +28,7 @@
#include <string>
#include <string.h>
-#include "bma220.hpp"
+#include "bma220.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/bma220/bma220.hpp b/peripheral/libupm/src/bma220/bma220.h
index e361d48..e361d48 100644
--- a/peripheral/libupm/src/bma220/bma220.hpp
+++ b/peripheral/libupm/src/bma220/bma220.h
diff --git a/peripheral/libupm/src/bma220/javaupm_bma220.i b/peripheral/libupm/src/bma220/javaupm_bma220.i
index c2363c0..82e1f56 100644
--- a/peripheral/libupm/src/bma220/javaupm_bma220.i
+++ b/peripheral/libupm/src/bma220/javaupm_bma220.i
@@ -25,10 +25,10 @@
%ignore getAccelerometer(float *, float *, float *);
%{
- #include "bma220.hpp"
+ #include "bma220.h"
%}
-%include "bma220.hpp"
+%include "bma220.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/bma220/jsupm_bma220.i b/peripheral/libupm/src/bma220/jsupm_bma220.i
index 2816e08..fa25b7f 100644
--- a/peripheral/libupm/src/bma220/jsupm_bma220.i
+++ b/peripheral/libupm/src/bma220/jsupm_bma220.i
@@ -4,8 +4,8 @@
%pointer_functions(float, floatp);
-%include "bma220.hpp"
+%include "bma220.h"
%{
- #include "bma220.hpp"
+ #include "bma220.h"
%}
diff --git a/peripheral/libupm/src/bma220/pyupm_bma220.i b/peripheral/libupm/src/bma220/pyupm_bma220.i
index c4f82bf..30f16b7 100644
--- a/peripheral/libupm/src/bma220/pyupm_bma220.i
+++ b/peripheral/libupm/src/bma220/pyupm_bma220.i
@@ -10,8 +10,8 @@
%pointer_functions(float, floatp);
-%include "bma220.hpp"
+%include "bma220.h"
%{
- #include "bma220.hpp"
+ #include "bma220.h"
%}
diff --git a/peripheral/libupm/src/bmi160/CMakeLists.txt b/peripheral/libupm/src/bmi160/CMakeLists.txt
deleted file mode 100644
index 4286851..0000000
--- a/peripheral/libupm/src/bmi160/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set (libname "bmi160")
-set (libdescription "Bosch BMI160 Accelerometer, Gyroscope and BMM150 Magnetometer")
-set (module_src ${libname}.cxx bosch_bmi160.c)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/bmi160/bmi160.cxx b/peripheral/libupm/src/bmi160/bmi160.cxx
deleted file mode 100644
index d9f35b7..0000000
--- a/peripheral/libupm/src/bmi160/bmi160.cxx
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-
-// we have to do it the old skool way
-#include <mraa/i2c.h>
-
-#include "bmi160.hpp"
-
-extern "C" {
-#include "bosch_bmi160.h"
-}
-
-// We do not need this define anyway. It conflicts with mraa::SUCCESS.
-#undef SUCCESS
-
-using namespace upm;
-using namespace std;
-
-static mraa_i2c_context i2cContext = NULL;
-
-// Our bmi160 info structure
-struct bmi160_t s_bmi160;
-
-// bus read and write functions for use with the bmi driver code
-s8 bmi160_i2c_bus_read(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
-{
- if (!i2cContext)
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": i2c context is NULL");
- }
-
- int retries = 10;
-
- // There seems to be some occasional flakyness with reads when
- // moving the sensor around
- while (retries >= 0)
- {
- int rv = mraa_i2c_read_bytes_data(i2cContext, reg_addr, reg_data, cnt);
-
- if (rv < 0)
- {
- usleep(100000);
- retries--;
- }
- else
- return 0;
- }
-
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": mraa_i2c_read_bytes_data() failed");
-
- return 0;
-}
-
-s8 bmi160_i2c_bus_write(u8 dev_addr, u8 reg_addr, u8 *reg_data, u8 cnt)
-{
- if (!i2cContext)
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": i2c context is NULL");
- }
-
- // FIXME fprintf(stderr, "%s: %02x: cnt %d\n", __FUNCTION__, reg_addr, cnt);
- uint8_t buffer[cnt + 1];
-
- buffer[0] = reg_addr;
- for (int i=0; i<cnt; i++)
- buffer[i+1] = reg_data[i];
-
- mraa_result_t rv = mraa_i2c_write(i2cContext, buffer, cnt+1);
-
- if (rv != MRAA_SUCCESS)
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": mraa_i2c_write() failed");
- }
-
- return 0;
-}
-
-// delay for some milliseconds
-void bmi160_delay_ms(u32 msek)
-{
- usleep(msek * 1000);
-}
-
-
-BMI160::BMI160(int bus, uint8_t address)
-{
- m_addr = address;
-
- // We need to use the C MRAA interface to avoid issue with C++ <-> C
- // calling convention issues, also we need a global
- // mraa_i2c_context
-
- if (!(i2cContext = mraa_i2c_init(bus)))
- {
- throw std::invalid_argument(std::string(__FUNCTION__) +
- ": mraa_i2c_init() failed");
- }
-
- if (mraa_i2c_address(i2cContext, m_addr) != MRAA_SUCCESS)
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": mraa_i2c_address() failed");
- return;
- }
-
- // init the driver interface functions
- s_bmi160.bus_write = bmi160_i2c_bus_write;
- s_bmi160.bus_read = bmi160_i2c_bus_read;
- s_bmi160.delay_msec = bmi160_delay_ms;
- s_bmi160.dev_addr = m_addr;
-
- // Init our driver interface pointers
- bmi160_init(&s_bmi160);
-
- m_accelX = 0.0;
- m_accelY = 0.0;
- m_accelZ = 0.0;
-
- m_gyroX = 0.0;
- m_gyroY = 0.0;
- m_gyroZ = 0.0;
-
- m_magX = 0.0;
- m_magY = 0.0;
- m_magZ = 0.0;
-
- m_accelScale = 1.0;
- m_gyroScale = 1.0;
-
- m_magEnabled = false;
-
- if (!init())
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": init() failed");
- }
-}
-
-BMI160::~BMI160()
-{
- mraa_i2c_stop(i2cContext);
- i2cContext = NULL;
-}
-
-bool BMI160::init()
-{
- // This should be interesting...
- const u32 C_BMI160_THIRTY_U8X = 30;
-
- enableMagnetometer(true);
-
- /*Set the accel mode as Normal write in the register 0x7E*/
- bmi160_set_command_register(ACCEL_MODE_NORMAL);
-
- /* bmi160_delay_ms in ms*/
- bmi160_delay_ms(C_BMI160_THIRTY_U8X);
-
- /*Set the gyro mode as Normal write in the register 0x7E*/
- bmi160_set_command_register(GYRO_MODE_NORMAL);
-
- /* bmi160_delay_ms in ms*/
- bmi160_delay_ms(C_BMI160_THIRTY_U8X);
-
- /* Set the accel bandwidth as OSRS4 */
- bmi160_set_accel_bw(BMI160_ACCEL_OSR4_AVG1);
- bmi160_delay_ms(BMI160_GEN_READ_WRITE_DELAY);
-
- /* Set the gryo bandwidth as Normal */
- bmi160_set_gyro_bw(BMI160_GYRO_NORMAL_MODE);
- bmi160_delay_ms(BMI160_GEN_READ_WRITE_DELAY);
-
- /* set gyro data rate as 200Hz*/
- bmi160_set_gyro_output_data_rate(BMI160_GYRO_OUTPUT_DATA_RATE_200HZ);
- bmi160_delay_ms(BMI160_GEN_READ_WRITE_DELAY);
-
- /* set accel data rate as 200Hz*/
- bmi160_set_accel_output_data_rate(BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ,
- BMI160_ACCEL_OSR4_AVG1);
- bmi160_delay_ms(BMI160_GEN_READ_WRITE_DELAY);
-
- setAccelerometerScale(ACCEL_RANGE_2G);
- setGyroscopeScale(GYRO_RANGE_125);
-
- return true;
-}
-
-
-void BMI160::update()
-{
- struct bmi160_gyro_t gyroxyz;
- struct bmi160_accel_t accelxyz;
- struct bmi160_mag_xyz_s32_t magxyz;
-
- // read gyro data
- bmi160_read_gyro_xyz(&gyroxyz);
-
- // read accel data
- bmi160_read_accel_xyz(&accelxyz);
-
- // read mag data
- if (m_magEnabled)
- bmi160_bmm150_mag_compensate_xyz(&magxyz);
-
- // read the sensor time
- u32 v_sensor_time;
- bmi160_get_sensor_time(&v_sensor_time);
- m_sensorTime = (unsigned int)v_sensor_time;
-
- m_accelX = float(accelxyz.x);
- m_accelY = float(accelxyz.y);
- m_accelZ = float(accelxyz.z);
-
- m_gyroX = float(gyroxyz.x);
- m_gyroY = float(gyroxyz.y);
- m_gyroZ = float(gyroxyz.z);
-
- if (m_magEnabled)
- {
- m_magX = float(magxyz.x);
- m_magY = float(magxyz.y);
- m_magZ = float(magxyz.z);
- }
-}
-
-void BMI160::setAccelerometerScale(ACCEL_RANGE_T scale)
-{
- s8 v_range = BMI160_ACCEL_RANGE_2G;
- // store scaling factor
-
- switch (scale)
- {
- case ACCEL_RANGE_2G:
- v_range = BMI160_ACCEL_RANGE_2G;
- m_accelScale = 16384.0;
- break;
-
- case ACCEL_RANGE_4G:
- v_range = BMI160_ACCEL_RANGE_4G;
- m_accelScale = 8192.0;
- break;
-
- case ACCEL_RANGE_8G:
- v_range = BMI160_ACCEL_RANGE_8G;
- m_accelScale = 4096.0;
- break;
-
- case ACCEL_RANGE_16G:
- v_range = BMI160_ACCEL_RANGE_16G;
- m_accelScale = 2048.0;
- break;
-
- default: // should never occur, but...
- m_accelScale = 1.0; // set a safe, though incorrect value
- throw std::logic_error(string(__FUNCTION__) +
- ": internal error, unsupported scale");
- break;
- }
-
- bmi160_set_accel_range(v_range);
-
- return;
-}
-
-void BMI160::setGyroscopeScale(GYRO_RANGE_T scale)
-{
- u8 v_range = BMI160_GYRO_RANGE_2000_DEG_SEC;
-
- // store scaling factor
-
- switch (scale)
- {
- case GYRO_RANGE_125:
- v_range = BMI160_GYRO_RANGE_125_DEG_SEC;
- m_gyroScale = 262.4;
- break;
-
- case GYRO_RANGE_250:
- v_range = BMI160_GYRO_RANGE_250_DEG_SEC;
- m_gyroScale = 131.2;
- break;
-
- case GYRO_RANGE_500:
- v_range = BMI160_GYRO_RANGE_500_DEG_SEC;
- m_gyroScale = 65.6;
- break;
-
- case GYRO_RANGE_1000:
- v_range = BMI160_GYRO_RANGE_1000_DEG_SEC;
- m_gyroScale = 32.8;
- break;
-
- case GYRO_RANGE_2000:
- v_range = BMI160_GYRO_RANGE_2000_DEG_SEC;
- m_gyroScale = 16.4;
- break;
-
- default: // should never occur, but...
- m_gyroScale = 1.0; // set a safe, though incorrect value
- throw std::logic_error(string(__FUNCTION__) +
- ": internal error, unsupported scale");
- break;
- }
-
- bmi160_set_gyro_range(v_range);
-
- return;
-}
-
-void BMI160::getAccelerometer(float *x, float *y, float *z)
-{
- if (x)
- *x = m_accelX / m_accelScale;
-
- if (y)
- *y = m_accelY / m_accelScale;
-
- if (z)
- *z = m_accelZ / m_accelScale;
-}
-
-void BMI160::getGyroscope(float *x, float *y, float *z)
-{
- if (x)
- *x = m_gyroX / m_gyroScale;
-
- if (y)
- *y = m_gyroY / m_gyroScale;
-
- if (z)
- *z = m_gyroZ / m_gyroScale;
-}
-
-void BMI160::getMagnetometer(float *x, float *y, float *z)
-{
- if (x)
- *x = m_magX;
-
- if (y)
- *y = m_magY;
-
- if (z)
- *z = m_magZ;
-}
-
-float *BMI160::getAccelerometer()
-{
- float *values = new float[3]; // x, y, and then z
-
- getAccelerometer(&values[0], &values[1], &values[2]);
-
- return values;
-}
-
-float *BMI160::getGyroscope()
-{
- float *values = new float[3]; // x, y, and then z
-
- getGyroscope(&values[0], &values[1], &values[2]);
-
- return values;
-}
-
-float *BMI160::getMagnetometer()
-{
- float *values = new float[3]; // x, y, and then z
-
- getMagnetometer(&values[0], &values[1], &values[2]);
-
- return values;
-}
-
-void BMI160::enableMagnetometer(bool enable)
-{
- // butchered from support example
- if (!enable)
- {
- bmi160_set_bmm150_mag_and_secondary_if_power_mode(MAG_SUSPEND_MODE);
- bmi160_delay_ms(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_set_if_mode(0x00);
- bmi160_delay_ms(BMI160_GEN_READ_WRITE_DELAY);
-
- m_magEnabled = false;
- m_magX = 0;
- m_magY = 0;
- m_magZ = 0;
- }
- else
- {
- u8 v_bmm_chip_id_u8 = BMI160_INIT_VALUE;
- /* Init the magnetometer */
- bmi160_bmm150_mag_interface_init(&v_bmm_chip_id_u8);
-
- /* bmi160_delay_ms in ms*/
- bmi160_delay_ms(BMI160_GEN_READ_WRITE_DELAY);
-
- m_magEnabled = true;
- }
-}
-
-unsigned int BMI160::getSensorTime()
-{
- return m_sensorTime;
-}
diff --git a/peripheral/libupm/src/bmi160/bmi160.hpp b/peripheral/libupm/src/bmi160/bmi160.hpp
deleted file mode 100644
index 84448c0..0000000
--- a/peripheral/libupm/src/bmi160/bmi160.hpp
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <stdint.h>
-
-#define BMI160_I2C_BUS 0
-#define BMI160_DEFAULT_I2C_ADDR 0x69
-
-namespace upm {
-
- /**
- * @brief BMI160 3-axis Accelerometer, Gyroscope and Magnetometer
- * @defgroup bmi160 libupm-bmi160
- * @ingroup i2c accelerometer compass
- */
-
-
- /**
- * @library bmi160
- * @sensor bmi160
- * @comname UPM API for the BMI160 3-axis Accelerometer, Gyroscope
- * and Magnetometer
- * @type accelerometer compass
- * @man mouser
- * @con i2c
- * @web http://www.mouser.com/ProductDetail/Bosch-Sensortec/0330SB2187/?qs=sGAEpiMZZMvi6wO7nhr1L9JELKA6cYRX60mAGNTn0fQ%3d
- *
- * @brief UPM API for the BMI160 3-axis Accelerometer, Gyroscope and
- * Magnetometer
- *
- * The Bosch BMI160 is a 3-axis Accelerometer and Gyroscope.
- * Additionally it supports an external Magnetometer, accessed
- * through the BMI160's register interface. This driver was
- * developed with a BMI160 "Shuttle" board, which included a BMM150
- * Magnetometer.
- *
- * The device is driven by either 1.8v or 3.3vdc. This driver
- * incorporates the Bosch BMI160 driver code at
- * https://github.com/BoschSensortec/BMI160_driver .
- *
- * While not all of the functionality of this device is supported
- * initially, the inclusion of the Bosch driver in the source code
- * makes it possible to support whatever features are required that
- * the driver can support.
- *
- * @snippet bmi160.cxx Interesting
- */
- class BMI160 {
- public:
-
- typedef enum {
- ACCEL_RANGE_2G = 0, // 2 Gravities
- ACCEL_RANGE_4G,
- ACCEL_RANGE_8G,
- ACCEL_RANGE_16G
- } ACCEL_RANGE_T;
-
- typedef enum {
- GYRO_RANGE_125 = 0, // 125 degrees/sec
- GYRO_RANGE_250,
- GYRO_RANGE_500,
- GYRO_RANGE_1000,
- GYRO_RANGE_2000
- } GYRO_RANGE_T;
-
- /**
- * bmi160 constructor
- *
- * @param bus i2c bus to use
- * @param address the address for this device
- */
- BMI160(int bus=BMI160_I2C_BUS, uint8_t address=BMI160_DEFAULT_I2C_ADDR);
-
- /**
- * BMI160 Destructor
- */
- ~BMI160();
-
- /**
- * Take a measurement and store the current sensor values
- * internally. This function must be called prior to retrieving
- * any sensor values, for example getAccelerometer().
- *
- */
- void update();
-
- /**
- * set the scaling mode of the accelerometer
- *
- * @param scale one of the ACCEL_RANGE_T values
- */
- void setAccelerometerScale(ACCEL_RANGE_T scale);
-
- /**
- * set the scaling mode of the gyroscope
- *
- * @param scale one of the GYRO_RANGE_T values
- */
- void setGyroscopeScale(GYRO_RANGE_T scale);
-
- /**
- * Get the Accelerometer values. This function returns a pointer
- * to 3 floating point values: X, Y, and Z, in that order. The
- * values returned are in gravities. update() must have been
- * called prior to calling this method.
- *
- * The caller is reponsible for freeing the returned pointer.
- *
- * @return Pointer to 3 floating point values: X, Y, and Z in
- * gravities.
- */
- float *getAccelerometer();
-
- /**
- * Get the Accelerometer values. The values returned are in
- * gravities. update() must have been called prior to calling
- * this method.
- *
- * @param x A pointer into which the X value will be returned
- * @param y A pointer into which the Y value will be returned
- * @param z A pointer into which the Z value will be returned
- */
- void getAccelerometer(float *x, float *y, float *z);
-
- /**
- * Get the Gyroscope values. This function returns a pointer to 3
- * floating point values: X, Y, and Z, in that order. The values
- * values returned are in degrees per second. update() must have
- * been called prior to calling this method.
- *
- * The caller is reponsible for freeing the returned pointer.
- *
- * @return Pointer to 3 floating point values: X, Y, and Z in
- * degrees per second.
- */
- float *getGyroscope();
-
- /**
- * Get the Gyroscope values. The values returned are in degrees
- * per second. update() must have been called prior to calling
- * this method.
- *
- * @param x A pointer into which the X value will be returned
- * @param y A pointer into which the Y value will be returned
- * @param z A pointer into which the Z value will be returned
- */
- void getGyroscope(float *x, float *y, float *z);
-
- /**
- * Get the Magnetometer values. This function returns a pointer
- * to 3 floating point values: X, Y, and Z, in that order. The
- * values values returned are in micro Teslas. update() must have
- * been called prior to calling this method. If the Magnetometer
- * has been disabled, the return values will always be 0, 0, and
- * 0.
- *
- * The caller is reponsible for freeing the returned pointer.
- *
- * @return Pointer to 3 floating point values: X, Y, and Z in
- * micro Teslas.
- */
- float *getMagnetometer();
-
- /**
- * Get the Magnetometer values. The values returned are in micro
- * Teslas. update() must have been called prior to calling this
- * method.
- *
- * @param x A pointer into which the X value will be returned
- * @param y A pointer into which the Y value will be returned
- * @param z A pointer into which the Z value will be returned
- */
- void getMagnetometer(float *x, float *y, float *z);
-
- /**
- * Enable or disable the Magnetometer. By default, the
- * magnetometer is enabled.
- *
- * @param enable true to enable the magnetometer, false to disable.
- */
- void enableMagnetometer(bool enable);
-
- /**
- * Return the sensor time. This is a 24bit value that increments
- * every 39us. It will wrap around once the 24b resolution is
- * exceeded.
- *
- * @return The current sensor time.
- */
- unsigned int getSensorTime();
-
- protected:
- // uncompensated accelerometer and gyroscope values
- float m_accelX;
- float m_accelY;
- float m_accelZ;
-
- float m_gyroX;
- float m_gyroY;
- float m_gyroZ;
-
- float m_magX;
- float m_magY;
- float m_magZ;
-
- unsigned int m_sensorTime;
-
- // accelerometer and gyro scaling factors, depending on their Full
- // Scale (Range) settings.
- float m_accelScale;
- float m_gyroScale;
-
- // is the magnetometer enabled?
- bool m_magEnabled;
-
- /**
- * set up initial values and start operation
- *
- * @return true if successful
- */
- virtual bool init();
-
- private:
- // due to the way we need to 'hook' into the bmi driver, the i2c
- // context is a static variable defined in the .cxx implmentation.
-
- uint8_t m_addr;
- };
-}
diff --git a/peripheral/libupm/src/bmi160/bosch_bmi160.c b/peripheral/libupm/src/bmi160/bosch_bmi160.c
deleted file mode 100644
index 52c834a..0000000
--- a/peripheral/libupm/src/bmi160/bosch_bmi160.c
+++ /dev/null
@@ -1,20467 +0,0 @@
-/*
-****************************************************************************
-* Copyright (C) 2015 Bosch Sensortec GmbH
-*
-* bosch_bmi160.c
-* Date: 2014/10/27
-* Revision: 2.0.6 $
-*
-* Usage: Sensor Driver for BMI160 sensor
-*
-****************************************************************************
-* License:
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-*
-* Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-*
-* Neither the name of the copyright holder nor the names of the
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
-* OR CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-* OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
-* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-* ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
-*
-* The information provided is believed to be accurate and reliable.
-* The copyright holder assumes no responsibility
-* for the consequences of use
-* of such information nor for any infringement of patents or
-* other rights of third parties which may result from its use.
-* No license is granted by implication or otherwise under any patent or
-* patent rights of the copyright holder.
-**************************************************************************/
-/*! file <BMI160 >
- brief <Sensor driver for BMI160> */
-#include "bosch_bmi160.h"
-/* user defined code to be added here ... */
-struct bmi160_t *p_bmi160;
-/* used for reading the mag trim values for compensation*/
-struct trim_data_t mag_trim;
-/* the following variable used for avoiding the selecting of auto mode
-when it is running in the manual mode of BMM150 mag interface*/
-u8 V_bmm150_maual_auto_condition_u8 = BMI160_INIT_VALUE;
-/* used for reading the AKM compensating data */
-struct bst_akm_sensitivity_data_t akm_asa_data;
-/* FIFO data read for 1024 bytes of data */
-u8 v_fifo_data_u8[FIFO_FRAME] = {BMI160_INIT_VALUE,};
-/* YAMAHA-YAS532*/
-/* value of coeff*/
-static const int yas532_version_ac_coef[] = {YAS532_VERSION_AC_COEF_X,
-YAS532_VERSION_AC_COEF_Y1, YAS532_VERSION_AC_COEF_Y2};
-/* used for reading the yas532 calibration data*/
-struct yas532_t yas532_data;
-/* used for reading the yas537 calibration data*/
-struct yas537_t yas537_data;
-struct bmi160_mag_fifo_data_t mag_data;
-struct bmi160_mag_xyz_s32_t processed_data;
-struct yas532_vector fifo_xyz_data;
-struct yas_vector fifo_vector_xyz;
-
-
-
-/*!
- * @brief
- * This function is used for initialize
- * bus read and bus write functions
- * assign the chip id and device address
- * chip id is read in the register 0x00 bit from 0 to 7
- *
- * @param bmi160 : structure pointer
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- * @note
- * While changing the parameter of the bmi160_t
- * consider the following point:
- * Changing the reference value of the parameter
- * will changes the local copy or local reference
- * make sure your changes will not
- * affect the reference value of the parameter
- * (Better case don't change the reference value of the parameter)
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_init(struct bmi160_t *bmi160)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- u8 v_pmu_data_u8 = BMI160_INIT_VALUE;
- /* assign bmi160 ptr */
- p_bmi160 = bmi160;
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_CHIP_ID__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* read Chip Id */
- p_bmi160->chip_id = v_data_u8;
- /* To avoid gyro wakeup it is required to write 0x00 to 0x6C*/
- com_rslt += bmi160_write_reg(BMI160_USER_PMU_TRIGGER_ADDR,
- &v_pmu_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- return com_rslt;
-}
-/*!
- * @brief
- * This API write the data to
- * the given register
- *
- *
- * @param v_addr_u8 -> Address of the register
- * @param v_data_u8 -> The data from the register
- * @param v_len_u8 -> no of bytes to read
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_write_reg(u8 v_addr_u8,
-u8 *v_data_u8, u8 v_len_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write data from register*/
- com_rslt =
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
- v_addr_u8, v_data_u8, v_len_u8);
- }
- return com_rslt;
-}
-/*!
- * @brief
- * This API reads the data from
- * the given register
- *
- *
- * @param v_addr_u8 -> Address of the register
- * @param v_data_u8 -> The data from the register
- * @param v_len_u8 -> no of bytes to read
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_reg(u8 v_addr_u8,
-u8 *v_data_u8, u8 v_len_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* Read data from register*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- v_addr_u8, v_data_u8, v_len_u8);
- }
- return com_rslt;
-}
-/*!
- * @brief This API used to reads the fatal error
- * from the Register 0x02 bit 0
- * This flag will be reset only by power-on-reset and soft reset
- *
- *
- * @param v_fatal_err_u8 : The status of fatal error
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fatal_err(u8
-*v_fatal_err_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* reading the fatal error status*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FATAL_ERR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_fatal_err_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FATAL_ERR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API used to read the error code
- * from register 0x02 bit 1 to 4
- *
- *
- * @param v_err_code_u8 : The status of error codes
- * error_code | description
- * ------------|---------------
- * 0x00 |no error
- * 0x01 |ACC_CONF error (accel ODR and bandwidth not compatible)
- * 0x02 |GYR_CONF error (Gyroscope ODR and bandwidth not compatible)
- * 0x03 |Under sampling mode and interrupt uses pre filtered data
- * 0x04 |reserved
- * 0x05 |Selected trigger-readout offset in
- * - |MAG_IF greater than selected ODR
- * 0x06 |FIFO configuration error for header less mode
- * 0x07 |Under sampling mode and pre filtered data as FIFO source
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_err_code(u8
-*v_err_code_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_ERR_CODE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_err_code_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_ERR_CODE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API Reads the i2c error code from the
- * Register 0x02 bit 5.
- * This error occurred in I2C master detected
- *
- * @param v_i2c_err_code_u8 : The status of i2c fail error
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_fail_err(u8
-*v_i2c_err_code_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_I2C_FAIL_ERR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_i2c_err_code_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_I2C_FAIL_ERR);
- }
- return com_rslt;
-}
- /*!
- * @brief This API Reads the dropped command error
- * from the register 0x02 bit 6
- *
- *
- * @param v_drop_cmd_err_u8 : The status of drop command error
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_drop_cmd_err(u8
-*v_drop_cmd_err_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_DROP_CMD_ERR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_drop_cmd_err_u8 = BMI160_GET_BITSLICE(
- v_data_u8,
- BMI160_USER_DROP_CMD_ERR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the magnetometer data ready
- * interrupt not active.
- * It reads from the error register 0x0x2 bit 7
- *
- *
- *
- *
- * @param v_mag_data_rdy_err_u8 : The status of mag data ready interrupt
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_dada_rdy_err(
-u8 *v_mag_data_rdy_err_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_MAG_DADA_RDY_ERR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_mag_data_rdy_err_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_MAG_DADA_RDY_ERR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the error status
- * from the error register 0x02 bit 0 to 7
- *
- * @param v_mag_data_rdy_err_u8 : The status of mag data ready interrupt
- * @param v_fatal_er_u8r : The status of fatal error
- * @param v_err_code_u8 : The status of error code
- * @param v_i2c_fail_err_u8 : The status of I2C fail error
- * @param v_drop_cmd_err_u8 : The status of drop command error
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_error_status(u8 *v_fatal_er_u8r,
-u8 *v_err_code_u8, u8 *v_i2c_fail_err_u8,
-u8 *v_drop_cmd_err_u8, u8 *v_mag_data_rdy_err_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the error codes*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_ERR_STAT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* fatal error*/
- *v_fatal_er_u8r =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FATAL_ERR);
- /* user error*/
- *v_err_code_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_ERR_CODE);
- /* i2c fail error*/
- *v_i2c_fail_err_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_I2C_FAIL_ERR);
- /* drop command error*/
- *v_drop_cmd_err_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_DROP_CMD_ERR);
- /* mag data ready error*/
- *v_mag_data_rdy_err_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_MAG_DADA_RDY_ERR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the magnetometer power mode from
- * PMU status register 0x03 bit 0 and 1
- *
- * @param v_mag_power_mode_stat_u8 : The value of mag power mode
- * mag_powermode | value
- * ------------------|----------
- * SUSPEND | 0x00
- * NORMAL | 0x01
- * LOW POWER | 0x02
- *
- *
- * @note The power mode of mag set by the 0x7E command register
- * @note using the function "bmi160_set_command_register()"
- * value | mode
- * ---------|----------------
- * 0x18 | MAG_MODE_SUSPEND
- * 0x19 | MAG_MODE_NORMAL
- * 0x1A | MAG_MODE_LOWPOWER
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_power_mode_stat(u8
-*v_mag_power_mode_stat_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_MAG_POWER_MODE_STAT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_mag_power_mode_stat_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_MAG_POWER_MODE_STAT);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the gyroscope power mode from
- * PMU status register 0x03 bit 2 and 3
- *
- * @param v_gyro_power_mode_stat_u8 : The value of gyro power mode
- * gyro_powermode | value
- * ------------------|----------
- * SUSPEND | 0x00
- * NORMAL | 0x01
- * FAST POWER UP | 0x03
- *
- * @note The power mode of gyro set by the 0x7E command register
- * @note using the function "bmi160_set_command_register()"
- * value | mode
- * ---------|----------------
- * 0x14 | GYRO_MODE_SUSPEND
- * 0x15 | GYRO_MODE_NORMAL
- * 0x17 | GYRO_MODE_FASTSTARTUP
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_power_mode_stat(u8
-*v_gyro_power_mode_stat_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_GYRO_POWER_MODE_STAT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_gyro_power_mode_stat_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_GYRO_POWER_MODE_STAT);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the accelerometer power mode from
- * PMU status register 0x03 bit 4 and 5
- *
- *
- * @param v_accel_power_mode_stat_u8 : The value of accel power mode
- * accel_powermode | value
- * ------------------|----------
- * SUSPEND | 0x00
- * NORMAL | 0x01
- * LOW POWER | 0x02
- *
- * @note The power mode of accel set by the 0x7E command register
- * @note using the function "bmi160_set_command_register()"
- * value | mode
- * ---------|----------------
- * 0x11 | ACCEL_MODE_NORMAL
- * 0x12 | ACCEL_LOWPOWER
- * 0x10 | ACCEL_SUSPEND
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_power_mode_stat(u8
-*v_accel_power_mode_stat_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_ACCEL_POWER_MODE_STAT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_accel_power_mode_stat_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_ACCEL_POWER_MODE_STAT);
- }
- return com_rslt;
-}
-/*!
- * @brief This API switch mag interface to normal mode
- * and confirm whether the mode switching done successfully or not
-*
- * @return results of bus communication function and current MAG_PMU result
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_interface_normal(void)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
- /* aim to check the result of switching mag normal */
- u8 v_try_times_u8 = BMI160_MAG_NOAMRL_SWITCH_TIMES;
- u8 v_mag_pum_status_u8 = BMI160_INIT_VALUE;
-
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt = bmi160_set_command_register(MAG_MODE_NORMAL);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- while (v_try_times_u8) {
- com_rslt = bmi160_get_mag_power_mode_stat(&v_mag_pum_status_u8);
- if (v_mag_pum_status_u8 == MAG_INTERFACE_PMU_ENABLE)
- break;
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- v_try_times_u8--;
- }
- if (v_mag_pum_status_u8 == MAG_INTERFACE_PMU_ENABLE)
- com_rslt += SUCCESS;
- else
- com_rslt += E_BMI160_COMM_RES;
-
- return com_rslt;
-}
-/*!
- * @brief This API reads magnetometer data X values
- * from the register 0x04 and 0x05
- * @brief The mag sensor data read form auxiliary mag
- *
- * @param v_mag_x_s16 : The value of mag x
- * @param v_sensor_select_u8 : Mag selection value
- * value | sensor
- * ---------|----------------
- * 0 | BMM150
- * 1 | AKM09911 or AKM09912
- *
- * @note For mag data output rate configuration use the following function
- * @note bmi160_set_mag_output_data_rate()
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_x(s16 *v_mag_x_s16,
-u8 v_sensor_select_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the mag X lSB and MSB data
- v_data_u8[0] - LSB
- v_data_u8[1] - MSB*/
- u8 v_data_u8[BMI160_MAG_X_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_sensor_select_u8) {
- case BST_BMM:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_DATA_MAG_X_LSB__REG,
- v_data_u8, BMI160_MAG_X_DATA_LENGTH);
- /* X axis*/
- v_data_u8[BMI160_MAG_X_LSB_BYTE] =
- BMI160_GET_BITSLICE(v_data_u8[BMI160_MAG_X_LSB_BYTE],
- BMI160_USER_DATA_MAG_X_LSB);
- *v_mag_x_s16 = (s16)
- ((((s32)((s8)v_data_u8[BMI160_MAG_X_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_05_BITS) |
- (v_data_u8[BMI160_MAG_X_LSB_BYTE]));
- break;
- case BST_AKM:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_DATA_0_MAG_X_LSB__REG,
- v_data_u8, BMI160_MAG_X_DATA_LENGTH);
- *v_mag_x_s16 = (s16)
- ((((s32)((s8)v_data_u8[BMI160_MAG_X_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
- (v_data_u8[BMI160_MAG_X_LSB_BYTE]));
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads magnetometer data Y values
- * from the register 0x06 and 0x07
- * @brief The mag sensor data read form auxiliary mag
- *
- * @param v_mag_y_s16 : The value of mag y
- * @param v_sensor_select_u8 : Mag selection value
- * value | sensor
- * ---------|----------------
- * 0 | BMM150
- * 1 | AKM09911 or AKM09912
- *
- * @note For mag data output rate configuration use the following function
- * @note bmi160_set_mag_output_data_rate()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_y(s16 *v_mag_y_s16,
-u8 v_sensor_select_u8)
-{
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_OUT_OF_RANGE;
- /* Array contains the mag Y lSB and MSB data
- v_data_u8[0] - LSB
- v_data_u8[1] - MSB*/
- u8 v_data_u8[BMI160_MAG_Y_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_sensor_select_u8) {
- case BST_BMM:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_DATA_MAG_Y_LSB__REG,
- v_data_u8, BMI160_MAG_Y_DATA_LENGTH);
- /*Y-axis lsb value shifting*/
- v_data_u8[BMI160_MAG_Y_LSB_BYTE] =
- BMI160_GET_BITSLICE(v_data_u8[BMI160_MAG_Y_LSB_BYTE],
- BMI160_USER_DATA_MAG_Y_LSB);
- *v_mag_y_s16 = (s16)
- ((((s32)((s8)v_data_u8[BMI160_MAG_Y_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_05_BITS) |
- (v_data_u8[BMI160_MAG_Y_LSB_BYTE]));
- break;
- case BST_AKM:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_DATA_2_MAG_Y_LSB__REG,
- v_data_u8, BMI160_MAG_Y_DATA_LENGTH);
- *v_mag_y_s16 = (s16)
- ((((s32)((s8)v_data_u8[BMI160_MAG_Y_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
- (v_data_u8[BMI160_MAG_Y_LSB_BYTE]));
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads magnetometer data Z values
- * from the register 0x08 and 0x09
- * @brief The mag sensor data read form auxiliary mag
- *
- * @param v_mag_z_s16 : The value of mag z
- * @param v_sensor_select_u8 : Mag selection value
- * value | sensor
- * ---------|----------------
- * 0 | BMM150
- * 1 | AKM09911 or AKM09912
- *
- * @note For mag data output rate configuration use the following function
- * @note bmi160_set_mag_output_data_rate()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_z(s16 *v_mag_z_s16,
-u8 v_sensor_select_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the mag Z lSB and MSB data
- v_data_u8[0] - LSB
- v_data_u8[1] - MSB*/
- u8 v_data_u8[BMI160_MAG_Z_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_sensor_select_u8) {
- case BST_BMM:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_DATA_MAG_Z_LSB__REG,
- v_data_u8, BMI160_MAG_Z_DATA_LENGTH);
- /*Z-axis lsb value shifting*/
- v_data_u8[BMI160_MAG_Z_LSB_BYTE] =
- BMI160_GET_BITSLICE(v_data_u8[BMI160_MAG_Z_LSB_BYTE],
- BMI160_USER_DATA_MAG_Z_LSB);
- *v_mag_z_s16 = (s16)
- ((((s32)((s8)v_data_u8[BMI160_MAG_Z_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_07_BITS) |
- (v_data_u8[BMI160_MAG_Z_LSB_BYTE]));
- break;
- case BST_AKM:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_DATA_4_MAG_Z_LSB__REG,
- v_data_u8, BMI160_MAG_Z_DATA_LENGTH);
- *v_mag_z_s16 = (s16)
- ((((s32)((s8)v_data_u8[BMI160_MAG_Z_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (
- v_data_u8[BMI160_MAG_Z_LSB_BYTE]));
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads magnetometer data RHALL values
- * from the register 0x0A and 0x0B
- *
- *
- * @param v_mag_r_s16 : The value of BMM150 r data
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_r(s16 *v_mag_r_s16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the mag R lSB and MSB data
- v_data_u8[0] - LSB
- v_data_u8[1] - MSB*/
- u8 v_data_u8[BMI160_MAG_R_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_DATA_6_RHALL_LSB__REG,
- v_data_u8, BMI160_MAG_R_DATA_LENGTH);
- /*R-axis lsb value shifting*/
- v_data_u8[BMI160_MAG_R_LSB_BYTE] =
- BMI160_GET_BITSLICE(v_data_u8[BMI160_MAG_R_LSB_BYTE],
- BMI160_USER_DATA_MAG_R_LSB);
- *v_mag_r_s16 = (s16)
- ((((s32)((s8)v_data_u8[BMI160_MAG_R_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_06_BITS) |
- (v_data_u8[BMI160_MAG_R_LSB_BYTE]));
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads magnetometer data X,Y,Z values
- * from the register 0x04 to 0x09
- *
- * @brief The mag sensor data read form auxiliary mag
- *
- * @param mag : The value of mag xyz data
- * @param v_sensor_select_u8 : Mag selection value
- * value | sensor
- * ---------|----------------
- * 0 | BMM150
- * 1 | AKM09911 or AKM09912
- *
- * @note For mag data output rate configuration use the following function
- * @note bmi160_set_mag_output_data_rate()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_xyz(
-struct bmi160_mag_t *mag, u8 v_sensor_select_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the mag XYZ lSB and MSB data
- v_data_u8[0] - X-LSB
- v_data_u8[1] - X-MSB
- v_data_u8[0] - Y-LSB
- v_data_u8[1] - Y-MSB
- v_data_u8[0] - Z-LSB
- v_data_u8[1] - Z-MSB
- */
- u8 v_data_u8[BMI160_MAG_XYZ_DATA_SIZE] = {
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_sensor_select_u8) {
- case BST_BMM:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_DATA_MAG_X_LSB__REG,
- v_data_u8, BMI160_MAG_XYZ_DATA_LENGTH);
- /*X-axis lsb value shifting*/
- v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE] =
- BMI160_GET_BITSLICE(
- v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE],
- BMI160_USER_DATA_MAG_X_LSB);
- /* Data X */
- mag->x = (s16)
- ((((s32)((s8)v_data_u8[
- BMI160_DATA_FRAME_MAG_X_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_05_BITS) |
- (v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE]));
- /* Data Y */
- /*Y-axis lsb value shifting*/
- v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE] =
- BMI160_GET_BITSLICE(
- v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE],
- BMI160_USER_DATA_MAG_Y_LSB);
- mag->y = (s16)
- ((((s32)((s8)v_data_u8[
- BMI160_DATA_FRAME_MAG_Y_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_05_BITS) |
- (v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE]));
-
- /* Data Z */
- /*Z-axis lsb value shifting*/
- v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]
- = BMI160_GET_BITSLICE(
- v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE],
- BMI160_USER_DATA_MAG_Z_LSB);
- mag->z = (s16)
- ((((s32)((s8)v_data_u8[
- BMI160_DATA_FRAME_MAG_Z_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_07_BITS) |
- (v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]));
- break;
- case BST_AKM:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_DATA_0_MAG_X_LSB__REG,
- v_data_u8, BMI160_MAG_XYZ_DATA_LENGTH);
- /* Data X */
- mag->x = (s16)
- ((((s32)((s8)v_data_u8[
- BMI160_DATA_FRAME_MAG_X_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
- (v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE]));
- /* Data Y */
- mag->y = ((((s32)((s8)v_data_u8[
- BMI160_DATA_FRAME_MAG_Y_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
- (v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE]));
- /* Data Z */
- mag->z = (s16)
- ((((s32)((s8)v_data_u8[
- BMI160_DATA_FRAME_MAG_Z_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
- (v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]));
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
- /*!*
- * @brief This API reads magnetometer data X,Y,Z,r
- * values from the register 0x04 to 0x0B
- *
- * @brief The mag sensor data read form auxiliary mag
- *
- * @param mag : The value of mag-BMM150 xyzr data
- *
- * @note For mag data output rate configuration use the following function
- * @note bmi160_set_mag_output_data_rate()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_xyzr(
-struct bmi160_mag_xyzr_t *mag)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8[BMI160_MAG_XYZR_DATA_SIZE] = {
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_DATA_MAG_X_LSB__REG,
- v_data_u8, BMI160_MAG_XYZR_DATA_LENGTH);
-
- /* Data X */
- /*X-axis lsb value shifting*/
- v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE]
- = BMI160_GET_BITSLICE(
- v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE],
- BMI160_USER_DATA_MAG_X_LSB);
- mag->x = (s16)
- ((((s32)((s8)v_data_u8[
- BMI160_DATA_FRAME_MAG_X_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_05_BITS)
- | (v_data_u8[BMI160_DATA_FRAME_MAG_X_LSB_BYTE]));
- /* Data Y */
- /*Y-axis lsb value shifting*/
- v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE]
- = BMI160_GET_BITSLICE(
- v_data_u8[BMI160_DATA_FRAME_MAG_Y_LSB_BYTE],
- BMI160_USER_DATA_MAG_Y_LSB);
- mag->y = (s16)
- ((((s32)((s8)v_data_u8[
- BMI160_DATA_FRAME_MAG_Y_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_05_BITS)
- | (v_data_u8[
- BMI160_DATA_FRAME_MAG_Y_LSB_BYTE]));
-
- /* Data Z */
- /*Z-axis lsb value shifting*/
- v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]
- = BMI160_GET_BITSLICE(
- v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE],
- BMI160_USER_DATA_MAG_Z_LSB);
- mag->z = (s16)
- ((((s32)((s8)v_data_u8[
- BMI160_DATA_FRAME_MAG_Z_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_07_BITS)
- | (v_data_u8[BMI160_DATA_FRAME_MAG_Z_LSB_BYTE]));
-
- /* RHall */
- /*R-axis lsb value shifting*/
- v_data_u8[BMI160_DATA_FRAME_MAG_R_LSB_BYTE]
- = BMI160_GET_BITSLICE(
- v_data_u8[BMI160_DATA_FRAME_MAG_R_LSB_BYTE],
- BMI160_USER_DATA_MAG_R_LSB);
- mag->r = (s16)
- ((((s32)((s8)v_data_u8[
- BMI160_DATA_FRAME_MAG_R_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
- | (v_data_u8[BMI160_DATA_FRAME_MAG_R_LSB_BYTE]));
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads gyro data X values
- * form the register 0x0C and 0x0D
- *
- *
- *
- *
- * @param v_gyro_x_s16 : The value of gyro x data
- *
- * @note Gyro Configuration use the following function
- * @note bmi160_set_gyro_output_data_rate()
- * @note bmi160_set_gyro_bw()
- * @note bmi160_set_gyro_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_x(s16 *v_gyro_x_s16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the gyro X lSB and MSB data
- v_data_u8[0] - LSB
- v_data_u8[MSB_ONE] - MSB*/
- u8 v_data_u8[BMI160_GYRO_X_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_DATA_8_GYRO_X_LSB__REG,
- v_data_u8, BMI160_GYRO_DATA_LENGTH);
-
- *v_gyro_x_s16 = (s16)
- ((((s32)((s8)v_data_u8[BMI160_GYRO_X_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (v_data_u8[BMI160_GYRO_X_LSB_BYTE]));
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads gyro data Y values
- * form the register 0x0E and 0x0F
- *
- *
- *
- *
- * @param v_gyro_y_s16 : The value of gyro y data
- *
- * @note Gyro Configuration use the following function
- * @note bmi160_set_gyro_output_data_rate()
- * @note bmi160_set_gyro_bw()
- * @note bmi160_set_gyro_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error result of communication routines
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_y(s16 *v_gyro_y_s16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the gyro Y lSB and MSB data
- v_data_u8[LSB_ZERO] - LSB
- v_data_u8[MSB_ONE] - MSB*/
- u8 v_data_u8[BMI160_GYRO_Y_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read gyro y data*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_DATA_10_GYRO_Y_LSB__REG,
- v_data_u8, BMI160_GYRO_DATA_LENGTH);
-
- *v_gyro_y_s16 = (s16)
- ((((s32)((s8)v_data_u8[BMI160_GYRO_Y_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (v_data_u8[BMI160_GYRO_Y_LSB_BYTE]));
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads gyro data Z values
- * form the register 0x10 and 0x11
- *
- *
- *
- *
- * @param v_gyro_z_s16 : The value of gyro z data
- *
- * @note Gyro Configuration use the following function
- * @note bmi160_set_gyro_output_data_rate()
- * @note bmi160_set_gyro_bw()
- * @note bmi160_set_gyro_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_z(s16 *v_gyro_z_s16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the gyro Z lSB and MSB data
- v_data_u8[LSB_ZERO] - LSB
- v_data_u8[MSB_ONE] - MSB*/
- u8 v_data_u8[BMI160_GYRO_Z_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read gyro z data */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_DATA_12_GYRO_Z_LSB__REG,
- v_data_u8, BMI160_GYRO_DATA_LENGTH);
-
- *v_gyro_z_s16 = (s16)
- ((((s32)((s8)v_data_u8[BMI160_GYRO_Z_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (v_data_u8[BMI160_GYRO_Z_LSB_BYTE]));
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads gyro data X,Y,Z values
- * from the register 0x0C to 0x11
- *
- *
- *
- *
- * @param gyro : The value of gyro xyz
- *
- * @note Gyro Configuration use the following function
- * @note bmi160_set_gyro_output_data_rate()
- * @note bmi160_set_gyro_bw()
- * @note bmi160_set_gyro_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_xyz(struct bmi160_gyro_t *gyro)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the mag XYZ lSB and MSB data
- v_data_u8[0] - X-LSB
- v_data_u8[1] - X-MSB
- v_data_u8[0] - Y-LSB
- v_data_u8[1] - Y-MSB
- v_data_u8[0] - Z-LSB
- v_data_u8[1] - Z-MSB
- */
- u8 v_data_u8[BMI160_GYRO_XYZ_DATA_SIZE] = {
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the gyro xyz data*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_DATA_8_GYRO_X_LSB__REG,
- v_data_u8, BMI160_GYRO_XYZ_DATA_LENGTH);
-
- /* Data X */
- gyro->x = (s16)
- ((((s32)((s8)v_data_u8[
- BMI160_DATA_FRAME_GYRO_X_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (v_data_u8[BMI160_DATA_FRAME_GYRO_X_LSB_BYTE]));
- /* Data Y */
- gyro->y = (s16)
- ((((s32)((s8)v_data_u8[
- BMI160_DATA_FRAME_GYRO_Y_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (v_data_u8[BMI160_DATA_FRAME_GYRO_Y_LSB_BYTE]));
-
- /* Data Z */
- gyro->z = (s16)
- ((((s32)((s8)v_data_u8[
- BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (v_data_u8[BMI160_DATA_FRAME_GYRO_Z_LSB_BYTE]));
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads accelerometer data X values
- * form the register 0x12 and 0x13
- *
- *
- *
- *
- * @param v_accel_x_s16 : The value of accel x
- *
- * @note For accel configuration use the following functions
- * @note bmi160_set_accel_output_data_rate()
- * @note bmi160_set_accel_bw()
- * @note bmi160_set_accel_under_sampling_parameter()
- * @note bmi160_set_accel_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_x(s16 *v_accel_x_s16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the accel X lSB and MSB data
- v_data_u8[0] - LSB
- v_data_u8[1] - MSB*/
- u8 v_data_u8[BMI160_ACCEL_X_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_DATA_14_ACCEL_X_LSB__REG,
- v_data_u8, BMI160_ACCEL_DATA_LENGTH);
-
- *v_accel_x_s16 = (s16)
- ((((s32)((s8)v_data_u8[BMI160_ACCEL_X_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (v_data_u8[BMI160_ACCEL_X_LSB_BYTE]));
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads accelerometer data Y values
- * form the register 0x14 and 0x15
- *
- *
- *
- *
- * @param v_accel_y_s16 : The value of accel y
- *
- * @note For accel configuration use the following functions
- * @note bmi160_set_accel_output_data_rate()
- * @note bmi160_set_accel_bw()
- * @note bmi160_set_accel_under_sampling_parameter()
- * @note bmi160_set_accel_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_y(s16 *v_accel_y_s16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the accel Y lSB and MSB data
- v_data_u8[0] - LSB
- v_data_u8[1] - MSB*/
- u8 v_data_u8[BMI160_ACCEL_Y_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_DATA_16_ACCEL_Y_LSB__REG,
- v_data_u8, BMI160_ACCEL_DATA_LENGTH);
-
- *v_accel_y_s16 = (s16)
- ((((s32)((s8)v_data_u8[BMI160_ACCEL_Y_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (v_data_u8[BMI160_ACCEL_Y_LSB_BYTE]));
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads accelerometer data Z values
- * form the register 0x16 and 0x17
- *
- *
- *
- *
- * @param v_accel_z_s16 : The value of accel z
- *
- * @note For accel configuration use the following functions
- * @note bmi160_set_accel_output_data_rate()
- * @note bmi160_set_accel_bw()
- * @note bmi160_set_accel_under_sampling_parameter()
- * @note bmi160_set_accel_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_z(s16 *v_accel_z_s16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the accel Z lSB and MSB data
- a_data_u8r[LSB_ZERO] - LSB
- a_data_u8r[MSB_ONE] - MSB*/
- u8 a_data_u8r[BMI160_ACCEL_Z_DATA_SIZE] = {
- BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_DATA_18_ACCEL_Z_LSB__REG,
- a_data_u8r, BMI160_ACCEL_DATA_LENGTH);
-
- *v_accel_z_s16 = (s16)
- ((((s32)((s8)a_data_u8r[BMI160_ACCEL_Z_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (a_data_u8r[BMI160_ACCEL_Z_LSB_BYTE]));
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads accelerometer data X,Y,Z values
- * from the register 0x12 to 0x17
- *
- *
- *
- *
- * @param accel :The value of accel xyz
- *
- * @note For accel configuration use the following functions
- * @note bmi160_set_accel_output_data_rate()
- * @note bmi160_set_accel_bw()
- * @note bmi160_set_accel_under_sampling_parameter()
- * @note bmi160_set_accel_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_xyz(
-struct bmi160_accel_t *accel)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the accel XYZ lSB and MSB data
- a_data_u8r[0] - X-LSB
- a_data_u8r[1] - X-MSB
- a_data_u8r[0] - Y-LSB
- a_data_u8r[1] - Y-MSB
- a_data_u8r[0] - Z-LSB
- a_data_u8r[1] - Z-MSB
- */
- u8 a_data_u8r[BMI160_ACCEL_XYZ_DATA_SIZE] = {
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_DATA_14_ACCEL_X_LSB__REG,
- a_data_u8r, BMI160_ACCEL_XYZ_DATA_LENGTH);
-
- /* Data X */
- accel->x = (s16)
- ((((s32)((s8)a_data_u8r[
- BMI160_DATA_FRAME_ACCEL_X_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (a_data_u8r[BMI160_DATA_FRAME_ACCEL_X_LSB_BYTE]));
- /* Data Y */
- accel->y = (s16)
- ((((s32)((s8)a_data_u8r[
- BMI160_DATA_FRAME_ACCEL_Y_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (a_data_u8r[BMI160_DATA_FRAME_ACCEL_Y_LSB_BYTE]));
-
- /* Data Z */
- accel->z = (s16)
- ((((s32)((s8)a_data_u8r[
- BMI160_DATA_FRAME_ACCEL_Z_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (a_data_u8r[BMI160_DATA_FRAME_ACCEL_Z_LSB_BYTE]));
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads sensor_time from the register
- * 0x18 to 0x1A
- *
- *
- * @param v_sensor_time_u32 : The value of sensor time
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_sensor_time(u32 *v_sensor_time_u32)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the sensor time it is 32 bit data
- a_data_u8r[0] - sensor time
- a_data_u8r[1] - sensor time
- a_data_u8r[0] - sensor time
- */
- u8 a_data_u8r[BMI160_SENSOR_TIME_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__REG,
- a_data_u8r, BMI160_SENSOR_TIME_LENGTH);
-
- *v_sensor_time_u32 = (u32)
- ((((u32)a_data_u8r[BMI160_SENSOR_TIME_MSB_BYTE])
- << BMI160_SHIFT_BIT_POSITION_BY_16_BITS)
- |(((u32)a_data_u8r[BMI160_SENSOR_TIME_XLSB_BYTE])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (a_data_u8r[BMI160_SENSOR_TIME_LSB_BYTE]));
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the Gyroscope self test
- * status from the register 0x1B bit 1
- *
- *
- * @param v_gyro_selftest_u8 : The value of gyro self test status
- * value | status
- * ---------|----------------
- * 0 | Gyroscope self test is running or failed
- * 1 | Gyroscope self test completed successfully
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_selftest(u8
-*v_gyro_selftest_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_STAT_GYRO_SELFTEST_OK__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_gyro_selftest_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_STAT_GYRO_SELFTEST_OK);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the status of
- * mag manual interface operation form the register 0x1B bit 2
- *
- *
- *
- * @param v_mag_manual_stat_u8 : The value of mag manual operation status
- * value | status
- * ---------|----------------
- * 0 | Indicates no manual magnetometer
- * - | interface operation is ongoing
- * 1 | Indicates manual magnetometer
- * - | interface operation is ongoing
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_manual_operation_stat(u8
-*v_mag_manual_stat_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read manual operation*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_STAT_MAG_MANUAL_OPERATION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_mag_manual_stat_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_STAT_MAG_MANUAL_OPERATION);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the fast offset compensation
- * status form the register 0x1B bit 3
- *
- *
- * @param v_foc_rdy_u8 : The status of fast compensation
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_rdy(u8
-*v_foc_rdy_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the FOC status*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_STAT_FOC_RDY__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_foc_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_STAT_FOC_RDY);
- }
- return com_rslt;
-}
-/*!
- * @brief This API Reads the nvm_rdy status from the
- * resister 0x1B bit 4
- *
- *
- * @param v_nvm_rdy_u8 : The value of NVM ready status
- * value | status
- * ---------|----------------
- * 0 | NVM write operation in progress
- * 1 | NVM is ready to accept a new write trigger
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_nvm_rdy(u8
-*v_nvm_rdy_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the nvm ready status*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_STAT_NVM_RDY__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_nvm_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_STAT_NVM_RDY);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the status of mag data ready
- * from the register 0x1B bit 5
- * The status get reset when one mag data register is read out
- *
- * @param v_data_rdy_u8 : The value of mag data ready status
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_data_rdy_mag(u8
-*v_data_rdy_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_STAT_DATA_RDY_MAG__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_STAT_DATA_RDY_MAG);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the status of gyro data ready form the
- * register 0x1B bit 6
- * The status get reset when gyro data register read out
- *
- *
- * @param v_data_rdy_u8 : The value of gyro data ready
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_data_rdy(u8
-*v_data_rdy_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_STAT_DATA_RDY_GYRO__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_STAT_DATA_RDY_GYRO);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the status of accel data ready form the
- * register 0x1B bit 7
- * The status get reset when accel data register read out
- *
- *
- * @param v_data_rdy_u8 : The value of accel data ready status
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_data_rdy(u8
-*v_data_rdy_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /*reads the status of accel data ready*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_STAT_DATA_RDY_ACCEL__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_STAT_DATA_RDY_ACCEL);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the step detector interrupt status
- * from the register 0x1C bit 0
- * flag is associated with a specific interrupt function.
- * It is set when the single tab interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt
- * signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_step_intr_u8 : The status of step detector interrupt
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_step_intr(u8
-*v_step_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_0_STEP_INTR__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_step_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_0_STEP_INTR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the
- * significant motion interrupt status
- * from the register 0x1C bit 1
- * flag is associated with a specific interrupt function.
- * It is set when the single tab interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt
- * signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- *
- * @param v_significant_intr_u8 : The status of step
- * motion interrupt
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_significant_intr(u8
-*v_significant_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_significant_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR);
- }
- return com_rslt;
-}
- /*!
- * @brief This API reads the any motion interrupt status
- * from the register 0x1C bit 2
- * flag is associated with a specific interrupt function.
- * It is set when the single tab interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt
- * signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- * @param v_any_motion_intr_u8 : The status of any-motion interrupt
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_any_motion_intr(u8
-*v_any_motion_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_0_ANY_MOTION__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_any_motion_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_0_ANY_MOTION);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the power mode trigger interrupt status
- * from the register 0x1C bit 3
- * flag is associated with a specific interrupt function.
- * It is set when the single tab interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt
- * signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- *
- * @param v_pmu_trigger_intr_u8 : The status of power mode trigger interrupt
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_pmu_trigger_intr(u8
-*v_pmu_trigger_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_0_PMU_TRIGGER__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_pmu_trigger_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_0_PMU_TRIGGER);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the double tab status
- * from the register 0x1C bit 4
- * flag is associated with a specific interrupt function.
- * It is set when the single tab interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt
- * signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_double_tap_intr_u8 :The status of double tab interrupt
- *
- * @note Double tap interrupt can be configured by the following functions
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_double_tap()
- * @note AXIS MAPPING
- * @note bmi160_get_stat2_tap_first_x()
- * @note bmi160_get_stat2_tap_first_y()
- * @note bmi160_get_stat2_tap_first_z()
- * @note DURATION
- * @note bmi160_set_intr_tap_durn()
- * @note THRESHOLD
- * @note bmi160_set_intr_tap_thres()
- * @note TAP QUIET
- * @note bmi160_set_intr_tap_quiet()
- * @note TAP SHOCK
- * @note bmi160_set_intr_tap_shock()
- * @note TAP SOURCE
- * @note bmi160_set_intr_tap_source()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_double_tap_intr(u8
-*v_double_tap_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_double_tap_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the single tab status
- * from the register 0x1C bit 5
- * flag is associated with a specific interrupt function.
- * It is set when the single tab interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt
- * signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_single_tap_intr_u8 :The status of single tap interrupt
- *
- * @note Single tap interrupt can be configured by the following functions
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_single_tap()
- * @note AXIS MAPPING
- * @note bmi160_get_stat2_tap_first_x()
- * @note bmi160_get_stat2_tap_first_y()
- * @note bmi160_get_stat2_tap_first_z()
- * @note DURATION
- * @note bmi160_set_intr_tap_durn()
- * @note THRESHOLD
- * @note bmi160_set_intr_tap_thres()
- * @note TAP QUIET
- * @note bmi160_set_intr_tap_quiet()
- * @note TAP SHOCK
- * @note bmi160_set_intr_tap_shock()
- * @note TAP SOURCE
- * @note bmi160_set_intr_tap_source()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_single_tap_intr(u8
-*v_single_tap_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_single_tap_intr_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the orient status
- * from the register 0x1C bit 6
- * flag is associated with a specific interrupt function.
- * It is set when the orient interrupt triggers. The
- * setting of INT_LATCH controls if the
- * interrupt signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_orient_intr_u8 : The status of orient interrupt
- *
- * @note For orient interrupt configuration use the following functions
- * @note STATUS
- * @note bmi160_get_stat0_orient_intr()
- * @note AXIS MAPPING
- * @note bmi160_get_stat3_orient_xy()
- * @note bmi160_get_stat3_orient_z()
- * @note bmi160_set_intr_orient_axes_enable()
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_orient()
- * @note INTERRUPT OUTPUT
- * @note bmi160_set_intr_orient_ud_enable()
- * @note THETA
- * @note bmi160_set_intr_orient_theta()
- * @note HYSTERESIS
- * @note bmi160_set_intr_orient_hyst()
- * @note BLOCKING
- * @note bmi160_set_intr_orient_blocking()
- * @note MODE
- * @note bmi160_set_intr_orient_mode()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_orient_intr(u8
-*v_orient_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_0_ORIENT__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_orient_intr_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_0_ORIENT);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the flat interrupt status
- * from the register 0x1C bit 7
- * flag is associated with a specific interrupt function.
- * It is set when the flat interrupt triggers. The
- * setting of INT_LATCH controls if the
- * interrupt signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_flat_intr_u8 : The status of flat interrupt
- *
- * @note For flat configuration use the following functions
- * @note STATS
- * @note bmi160_get_stat0_flat_intr()
- * @note bmi160_get_stat3_flat()
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_flat()
- * @note THETA
- * @note bmi160_set_intr_flat_theta()
- * @note HOLD TIME
- * @note bmi160_set_intr_flat_hold()
- * @note HYSTERESIS
- * @note bmi160_set_intr_flat_hyst()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_flat_intr(u8
-*v_flat_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_0_FLAT__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_flat_intr_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_0_FLAT);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the high_g interrupt status
- * from the register 0x1D bit 2
- * flag is associated with a specific interrupt function.
- * It is set when the high g interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt signal and hence the
- * respective interrupt flag will be permanently
- * latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_high_g_intr_u8 : The status of high_g interrupt
- *
- * @note High_g interrupt configured by following functions
- * @note STATUS
- * @note bmi160_get_stat1_high_g_intr()
- * @note AXIS MAPPING
- * @note bmi160_get_stat3_high_g_first_x()
- * @note bmi160_get_stat3_high_g_first_y()
- * @note bmi160_get_stat3_high_g_first_z()
- * @note SIGN MAPPING
- * @note bmi160_get_stat3_high_g_first_sign()
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_high_g()
- * @note HYSTERESIS
- * @note bmi160_set_intr_high_g_hyst()
- * @note DURATION
- * @note bmi160_set_intr_high_g_durn()
- * @note THRESHOLD
- * @note bmi160_set_intr_high_g_thres()
- * @note SOURCE
- * @note bmi160_set_intr_low_high_source()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_high_g_intr(u8
-*v_high_g_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_1_HIGH_G_INTR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_high_g_intr_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_1_HIGH_G_INTR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the low g interrupt status
- * from the register 0x1D bit 3
- * flag is associated with a specific interrupt function.
- * It is set when the low g interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_low_g_intr_u8 : The status of low_g interrupt
- *
- * @note Low_g interrupt configured by following functions
- * @note STATUS
- * @note bmi160_get_stat1_low_g_intr()
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_low_g()
- * @note SOURCE
- * @note bmi160_set_intr_low_high_source()
- * @note DURATION
- * @note bmi160_set_intr_low_g_durn()
- * @note THRESHOLD
- * @note bmi160_set_intr_low_g_thres()
- * @note HYSTERESIS
- * @note bmi160_set_intr_low_g_hyst()
- * @note MODE
- * @note bmi160_set_intr_low_g_mode()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_low_g_intr(u8
-*v_low_g_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_1_LOW_G_INTR__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_low_g_intr_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_1_LOW_G_INTR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads data ready interrupt status
- * from the register 0x1D bit 4
- * flag is associated with a specific interrupt function.
- * It is set when the data ready interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_data_rdy_intr_u8 : The status of data ready interrupt
- *
- * @note Data ready interrupt configured by following functions
- * @note STATUS
- * @note bmi160_get_stat1_data_rdy_intr()
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_data_rdy()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_data_rdy_intr(u8
-*v_data_rdy_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_data_rdy_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_1_DATA_RDY_INTR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads data ready FIFO full interrupt status
- * from the register 0x1D bit 5
- * flag is associated with a specific interrupt function.
- * It is set when the FIFO full interrupt triggers. The
- * setting of INT_LATCH controls if the
- * interrupt signal and hence the
- * respective interrupt flag will
- * be permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_fifo_full_intr_u8 : The status of fifo full interrupt
- *
- * @note FIFO full interrupt can be configured by following functions
- * @note bmi160_set_intr_fifo_full()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_fifo_full_intr(u8
-*v_fifo_full_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_fifo_full_intr_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads data
- * ready FIFO watermark interrupt status
- * from the register 0x1D bit 6
- * flag is associated with a specific interrupt function.
- * It is set when the FIFO watermark interrupt triggers. The
- * setting of INT_LATCH controls if the
- * interrupt signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_fifo_wm_intr_u8 : The status of fifo water mark interrupt
- *
- * @note FIFO full interrupt can be configured by following functions
- * @note bmi160_set_intr_fifo_wm()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_fifo_wm_intr(u8
-*v_fifo_wm_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_fifo_wm_intr_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_1_FIFO_WM_INTR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads data ready no motion interrupt status
- * from the register 0x1D bit 7
- * flag is associated with a specific interrupt function.
- * It is set when the no motion interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt signal and hence the
- * respective interrupt flag will be permanently
- * latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_nomotion_intr_u8 : The status of no motion interrupt
- *
- * @note No motion interrupt can be configured by following function
- * @note STATUS
- * @note bmi160_get_stat1_nomotion_intr()
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_nomotion()
- * @note DURATION
- * @note bmi160_set_intr_slow_no_motion_durn()
- * @note THRESHOLD
- * @note bmi160_set_intr_slow_no_motion_thres()
- * @note SLOW/NO MOTION SELECT
- * @note bmi160_set_intr_slow_no_motion_select()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_nomotion_intr(u8
-*v_nomotion_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the no motion interrupt*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_1_NOMOTION_INTR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_nomotion_intr_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_1_NOMOTION_INTR);
- }
- return com_rslt;
-}
-/*!
- *@brief This API reads the status of any motion first x
- * from the register 0x1E bit 0
- *
- *
- *@param v_anymotion_first_x_u8 : The status of any motion first x interrupt
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by x axis
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_x(u8
-*v_anymotion_first_x_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the any motion first x interrupt*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_anymotion_first_x_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the status of any motion first y interrupt
- * from the register 0x1E bit 1
- *
- *
- *
- *@param v_any_motion_first_y_u8 : The status of any motion first y interrupt
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_y(u8
-*v_any_motion_first_y_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the any motion first y interrupt*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_any_motion_first_y_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the status of any motion first z interrupt
- * from the register 0x1E bit 2
- *
- *
- *
- *
- *@param v_any_motion_first_z_u8 : The status of any motion first z interrupt
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_z(u8
-*v_any_motion_first_z_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the any motion first z interrupt*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_any_motion_first_z_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the any motion sign status from the
- * register 0x1E bit 3
- *
- *
- *
- *
- * @param v_anymotion_sign_u8 : The status of any motion sign
- * value | sign
- * -----------|-------------
- * 0 | positive
- * 1 | negative
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_sign(u8
-*v_anymotion_sign_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read any motion sign interrupt status */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_anymotion_sign_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the any motion tap first x status from the
- * register 0x1E bit 4
- *
- *
- *
- *
- * @param v_tap_first_x_u8 :The status of any motion tap first x
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by x axis
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_x(u8
-*v_tap_first_x_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read tap first x interrupt status */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_2_TAP_FIRST_X__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_tap_first_x_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_2_TAP_FIRST_X);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the tap first y interrupt status from the
- * register 0x1E bit 5
- *
- *
- *
- *
- * @param v_tap_first_y_u8 :The status of tap first y interrupt
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_y(u8
-*v_tap_first_y_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read tap first y interrupt status */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_tap_first_y_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_2_TAP_FIRST_Y);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the tap first z interrupt status from the
- * register 0x1E bit 6
- *
- *
- *
- *
- * @param v_tap_first_z_u8 :The status of tap first z interrupt
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by z axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_z(u8
-*v_tap_first_z_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read tap first z interrupt status */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_tap_first_z_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_2_TAP_FIRST_Z);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the tap sign status from the
- * register 0x1E bit 7
- *
- *
- *
- *
- * @param v_tap_sign_u8 : The status of tap sign
- * value | sign
- * -----------|-------------
- * 0 | positive
- * 1 | negative
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_sign(u8
-*v_tap_sign_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read tap_sign interrupt status */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_2_TAP_SIGN__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_tap_sign_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_2_TAP_SIGN);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the high_g first x status from the
- * register 0x1F bit 0
- *
- *
- *
- *
- * @param v_high_g_first_x_u8 :The status of high_g first x
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by x axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_x(u8
-*v_high_g_first_x_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read highg_x interrupt status */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_high_g_first_x_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the high_g first y status from the
- * register 0x1F bit 1
- *
- *
- *
- *
- * @param v_high_g_first_y_u8 : The status of high_g first y
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_y(u8
-*v_high_g_first_y_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read highg_y interrupt status */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_high_g_first_y_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the high_g first z status from the
- * register 0x1F bit 3
- *
- *
- *
- *
- * @param v_high_g_first_z_u8 : The status of high_g first z
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by z axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_z(u8
-*v_high_g_first_z_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read highg_z interrupt status */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_high_g_first_z_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the high sign status from the
- * register 0x1F bit 3
- *
- *
- *
- *
- * @param v_high_g_sign_u8 :The status of high sign
- * value | sign
- * -----------|-------------
- * 0 | positive
- * 1 | negative
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_sign(u8
-*v_high_g_sign_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read highg_sign interrupt status */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_high_g_sign_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_3_HIGH_G_SIGN);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the status of orient_xy plane
- * from the register 0x1F bit 4 and 5
- *
- *
- * @param v_orient_xy_u8 :The status of orient_xy plane
- * value | status
- * -----------|-------------
- * 0x00 | portrait upright
- * 0x01 | portrait upside down
- * 0x02 | landscape left
- * 0x03 | landscape right
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_orient_xy(u8
-*v_orient_xy_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read orient plane xy interrupt status */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_3_ORIENT_XY__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_orient_xy_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_3_ORIENT_XY);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the status of orient z plane
- * from the register 0x1F bit 6
- *
- *
- * @param v_orient_z_u8 :The status of orient z
- * value | status
- * -----------|-------------
- * 0x00 | upward looking
- * 0x01 | downward looking
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_orient_z(u8
-*v_orient_z_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read orient z plane interrupt status */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_3_ORIENT_Z__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_orient_z_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_3_ORIENT_Z);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the flat status from the register
- * 0x1F bit 7
- *
- *
- * @param v_flat_u8 : The status of flat interrupt
- * value | status
- * -----------|-------------
- * 0x00 | non flat
- * 0x01 | flat position
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_flat(u8
-*v_flat_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read flat interrupt status */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_INTR_STAT_3_FLAT__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_flat_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_STAT_3_FLAT);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the temperature of the sensor
- * from the register 0x21 bit 0 to 7
- *
- *
- *
- * @param v_temp_s16 : The value of temperature
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_temp(s16
-*v_temp_s16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the temperature lSB and MSB data
- v_data_u8[0] - LSB
- v_data_u8[1] - MSB*/
- u8 v_data_u8[BMI160_TEMP_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read temperature data */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_TEMP_LSB_VALUE__REG, v_data_u8,
- BMI160_TEMP_DATA_LENGTH);
- *v_temp_s16 =
- (s16)(((s32)((s8) (v_data_u8[BMI160_TEMP_MSB_BYTE]) <<
- BMI160_SHIFT_BIT_POSITION_BY_08_BITS))
- | v_data_u8[BMI160_TEMP_LSB_BYTE]);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the of the sensor
- * form the register 0x23 and 0x24 bit 0 to 7 and 0 to 2
- * @brief this byte counter is updated each time a complete frame
- * was read or writtern
- *
- *
- * @param v_fifo_length_u32 : The value of fifo byte counter
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_fifo_length(u32 *v_fifo_length_u32)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array contains the fifo length data
- v_data_u8[0] - fifo length
- v_data_u8[1] - fifo length*/
- u8 a_data_u8r[BMI160_FIFO_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read fifo length*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_BYTE_COUNTER_LSB__REG, a_data_u8r,
- BMI160_FIFO_DATA_LENGTH);
-
- a_data_u8r[BMI160_FIFO_LENGTH_MSB_BYTE] =
- BMI160_GET_BITSLICE(
- a_data_u8r[BMI160_FIFO_LENGTH_MSB_BYTE],
- BMI160_USER_FIFO_BYTE_COUNTER_MSB);
-
- *v_fifo_length_u32 =
- (u32)(((u32)((u8) (
- a_data_u8r[BMI160_FIFO_LENGTH_MSB_BYTE]) <<
- BMI160_SHIFT_BIT_POSITION_BY_08_BITS))
- | a_data_u8r[BMI160_FIFO_LENGTH_LSB_BYTE]);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the fifo data of the sensor
- * from the register 0x24
- * @brief Data format depends on the setting of register FIFO_CONFIG
- *
- *
- *
- * @param v_fifodata_u8 : Pointer holding the fifo data
- * @param fifo_length_u16 : The value of fifo length maximum
- * 1024
- *
- * @note For reading FIFO data use the following functions
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_fifo_data(
-u8 *v_fifodata_u8, u16 v_fifo_length_u16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read fifo data*/
- com_rslt =
- p_bmi160->BMI160_BURST_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_DATA__REG,
- v_fifodata_u8, v_fifo_length_u16);
-
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to get the
- * accel output date rate form the register 0x40 bit 0 to 3
- *
- *
- * @param v_output_data_rate_u8 :The value of accel output date rate
- * value | output data rate
- * -------|--------------------------
- * 0 | BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED
- * 1 | BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
- * 2 | BMI160_ACCEL_OUTPUT_DATA_RATE_1_56HZ
- * 3 | BMI160_ACCEL_OUTPUT_DATA_RATE_3_12HZ
- * 4 | BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ
- * 5 | BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ
- * 6 | BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ
- * 7 | BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ
- * 8 | BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ
- * 9 | BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ
- * 10 | BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ
- * 11 | BMI160_ACCEL_OUTPUT_DATA_RATE_800HZ
- * 12 | BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_output_data_rate(
-u8 *v_output_data_rate_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the accel output data rate*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_output_data_rate_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set the
- * accel output date rate form the register 0x40 bit 0 to 3
- *
- *
- * @param v_output_data_rate_u8 :The value of accel output date rate
- * value | output data rate
- * -------|--------------------------
- * 0 | BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED
- * 1 | BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
- * 2 | BMI160_ACCEL_OUTPUT_DATA_RATE_1_56HZ
- * 3 | BMI160_ACCEL_OUTPUT_DATA_RATE_3_12HZ
- * 4 | BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ
- * 5 | BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ
- * 6 | BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ
- * 7 | BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ
- * 8 | BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ
- * 9 | BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ
- * 10 | BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ
- * 11 | BMI160_ACCEL_OUTPUT_DATA_RATE_800HZ
- * 12 | BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ
- *
- * @param v_accel_bw_u8 :The value of accel selected accel bandwidth
- * value | output data rate
- * -------|--------------------------
- * 0 | BMI160_ACCEL_OSR4_AVG1
- * 1 | BMI160_ACCEL_OSR2_AVG2
- * 2 | BMI160_ACCEL_NORMAL_AVG4
- * 3 | BMI160_ACCEL_CIC_AVG8
- * 4 | BMI160_ACCEL_RES_AVG2
- * 5 | BMI160_ACCEL_RES_AVG4
- * 6 | BMI160_ACCEL_RES_AVG8
- * 7 | BMI160_ACCEL_RES_AVG16
- * 8 | BMI160_ACCEL_RES_AVG32
- * 9 | BMI160_ACCEL_RES_AVG64
- * 10 | BMI160_ACCEL_RES_AVG128
- *
- *
- *
- *
- *
- * @note Verify the accel bandwidth before setting the
- * output data rate
- * bandwidth | output data rate | under sampling
- *-------------|------------------|----------------
- * OSR4 | 12.5 TO 1600 | 0
- * OSR2 | 12.5 TO 1600 | 0
- * NORMAL | 12.5 TO 1600 | 0
- * CIC | 12.5 TO 1600 | 0
- * AVG2 | 0.78 TO 400 | 1
- * AVG4 | 0.78 TO 200 | 1
- * AVG8 | 0.78 TO 100 | 1
- * AVG16 | 0.78 TO 50 | 1
- * AVG32 | 0.78 TO 25 | 1
- * AVG64 | 0.78 TO 12.5 | 1
- * AVG128 | 0.78 TO 6.25 | 1
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_output_data_rate(
-u8 v_output_data_rate_u8, u8 v_accel_bw_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- u8 v_odr_u8 = BMI160_INIT_VALUE;
- u8 v_assign_bw = BMI160_ASSIGN_DATA;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if ((v_accel_bw_u8 >= BMI160_ACCEL_RES_AVG2) &&
- (v_accel_bw_u8 <= BMI160_ACCEL_RES_AVG128)) {
- /* enable the under sampling*/
- com_rslt = bmi160_set_accel_under_sampling_parameter(
- BMI160_US_ENABLE);
- } else if (((v_accel_bw_u8 > BMI160_ACCEL_OSR4_AVG1) &&
- (v_accel_bw_u8 <= BMI160_ACCEL_CIC_AVG8))
- || (v_accel_bw_u8 == BMI160_ACCEL_OSR4_AVG1)) {
- /* disable the under sampling*/
- com_rslt = bmi160_set_accel_under_sampling_parameter(
- BMI160_US_DISABLE);
- }
- /* assign the output data rate*/
- switch (v_accel_bw_u8) {
- case BMI160_ACCEL_RES_AVG2:
- if (v_output_data_rate_u8
- >= BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
- && v_output_data_rate_u8
- <= BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ) {
- v_odr_u8 = v_output_data_rate_u8;
- v_assign_bw = SUCCESS;
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- break;
- case BMI160_ACCEL_RES_AVG4:
- if (v_output_data_rate_u8
- >= BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
- && v_output_data_rate_u8
- <= BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ) {
- v_odr_u8 = v_output_data_rate_u8;
- v_assign_bw = SUCCESS;
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- break;
- case BMI160_ACCEL_RES_AVG8:
- if (v_output_data_rate_u8
- >= BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
- && v_output_data_rate_u8
- <= BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ) {
- v_odr_u8 = v_output_data_rate_u8;
- v_assign_bw = SUCCESS;
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- break;
- case BMI160_ACCEL_RES_AVG16:
- if (v_output_data_rate_u8
- >= BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
- && v_output_data_rate_u8
- <= BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ) {
- v_odr_u8 = v_output_data_rate_u8;
- v_assign_bw = SUCCESS;
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- break;
- case BMI160_ACCEL_RES_AVG32:
- if (v_output_data_rate_u8
- >= BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
- && v_output_data_rate_u8
- <= BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ) {
- v_odr_u8 = v_output_data_rate_u8;
- v_assign_bw = SUCCESS;
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- break;
- case BMI160_ACCEL_RES_AVG64:
- if (v_output_data_rate_u8
- >= BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
- && v_output_data_rate_u8
- <= BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ) {
- v_odr_u8 = v_output_data_rate_u8;
- v_assign_bw = SUCCESS;
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- break;
- case BMI160_ACCEL_RES_AVG128:
- if (v_output_data_rate_u8
- >= BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
- && v_output_data_rate_u8
- <= BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ) {
- v_odr_u8 = v_output_data_rate_u8;
- v_assign_bw = SUCCESS;
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- break;
- case BMI160_ACCEL_OSR4_AVG1:
- if ((v_output_data_rate_u8
- >= BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ)
- && (v_output_data_rate_u8
- <= BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ)) {
- v_odr_u8 = v_output_data_rate_u8;
- v_assign_bw = SUCCESS;
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- break;
- case BMI160_ACCEL_OSR2_AVG2:
- if ((v_output_data_rate_u8
- >= BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ)
- && (v_output_data_rate_u8
- <= BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ)) {
- v_odr_u8 = v_output_data_rate_u8;
- v_assign_bw = SUCCESS;
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- break;
- case BMI160_ACCEL_NORMAL_AVG4:
- if ((v_output_data_rate_u8
- >= BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ)
- && (v_output_data_rate_u8
- <= BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ)) {
- v_odr_u8 = v_output_data_rate_u8;
- v_assign_bw = SUCCESS;
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- break;
- case BMI160_ACCEL_CIC_AVG8:
- if ((v_output_data_rate_u8
- >= BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ)
- && (v_output_data_rate_u8
- <= BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ)) {
- v_odr_u8 = v_output_data_rate_u8;
- v_assign_bw = SUCCESS;
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- if (v_assign_bw == SUCCESS) {
- /* write accel output data rate */
- com_rslt +=
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE,
- v_odr_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to get the
- * accel bandwidth from the register 0x40 bit 4 to 6
- * @brief bandwidth parameter determines filter configuration(acc_us=0)
- * and averaging for under sampling mode(acc_us=1)
- *
- *
- * @param v_bw_u8 : The value of accel bandwidth
- *
- * @note accel bandwidth depends on under sampling parameter
- * @note under sampling parameter cab be set by the function
- * "BMI160_SET_ACCEL_UNDER_SAMPLING_PARAMETER"
- *
- * @note Filter configuration
- * accel_us | Filter configuration
- * -----------|---------------------
- * 0x00 | OSR4 mode
- * 0x01 | OSR2 mode
- * 0x02 | normal mode
- * 0x03 | CIC mode
- * 0x04 | Reserved
- * 0x05 | Reserved
- * 0x06 | Reserved
- * 0x07 | Reserved
- *
- * @note accel under sampling mode
- * accel_us | Under sampling mode
- * -----------|---------------------
- * 0x00 | no averaging
- * 0x01 | average 2 samples
- * 0x02 | average 4 samples
- * 0x03 | average 8 samples
- * 0x04 | average 16 samples
- * 0x05 | average 32 samples
- * 0x06 | average 64 samples
- * 0x07 | average 128 samples
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_bw(u8 *v_bw_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the accel bandwidth */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_ACCEL_CONFIG_ACCEL_BW__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_bw_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_ACCEL_CONFIG_ACCEL_BW);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set the
- * accel bandwidth from the register 0x40 bit 4 to 6
- * @brief bandwidth parameter determines filter configuration(acc_us=0)
- * and averaging for under sampling mode(acc_us=1)
- *
- *
- * @param v_bw_u8 : The value of accel bandwidth
- *
- * @note accel bandwidth depends on under sampling parameter
- * @note under sampling parameter cab be set by the function
- * "BMI160_SET_ACCEL_UNDER_SAMPLING_PARAMETER"
- *
- * @note Filter configuration
- * accel_us | Filter configuration
- * -----------|---------------------
- * 0x00 | OSR4 mode
- * 0x01 | OSR2 mode
- * 0x02 | normal mode
- * 0x03 | CIC mode
- * 0x04 | Reserved
- * 0x05 | Reserved
- * 0x06 | Reserved
- * 0x07 | Reserved
- *
- * @note accel under sampling mode
- * accel_us | Under sampling mode
- * -----------|---------------------
- * 0x00 | no averaging
- * 0x01 | average 2 samples
- * 0x02 | average 4 samples
- * 0x03 | average 8 samples
- * 0x04 | average 16 samples
- * 0x05 | average 32 samples
- * 0x06 | average 64 samples
- * 0x07 | average 128 samples
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_bw(u8 v_bw_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* select accel bandwidth*/
- if (v_bw_u8 <= BMI160_MAX_ACCEL_BW) {
- /* write accel bandwidth*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_ACCEL_CONFIG_ACCEL_BW__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_ACCEL_CONFIG_ACCEL_BW,
- v_bw_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_ACCEL_CONFIG_ACCEL_BW__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to get the accel
- * under sampling parameter form the register 0x40 bit 7
- *
- *
- *
- *
- * @param v_accel_under_sampling_u8 : The value of accel under sampling
- * value | under_sampling
- * ----------|---------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_under_sampling_parameter(
-u8 *v_accel_under_sampling_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the accel under sampling parameter */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_accel_under_sampling_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set the accel
- * under sampling parameter form the register 0x40 bit 7
- *
- *
- *
- *
- * @param v_accel_under_sampling_u8 : The value of accel under sampling
- * value | under_sampling
- * ----------|---------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_under_sampling_parameter(
-u8 v_accel_under_sampling_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_accel_under_sampling_u8 <= BMI160_MAX_UNDER_SAMPLING) {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- /* write the accel under sampling parameter */
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING,
- v_accel_under_sampling_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
-}
-return com_rslt;
-}
-/*!
- * @brief This API is used to get the ranges
- * (g values) of the accel from the register 0x41 bit 0 to 3
- *
- *
- *
- *
- * @param v_range_u8 : The value of accel g range
- * value | g_range
- * ----------|-----------
- * 0x03 | BMI160_ACCEL_RANGE_2G
- * 0x05 | BMI160_ACCEL_RANGE_4G
- * 0x08 | BMI160_ACCEL_RANGE_8G
- * 0x0C | BMI160_ACCEL_RANGE_16G
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_range(
-u8 *v_range_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the accel range*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_ACCEL_RANGE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_range_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_ACCEL_RANGE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set the ranges
- * (g values) of the accel from the register 0x41 bit 0 to 3
- *
- *
- *
- *
- * @param v_range_u8 : The value of accel g range
- * value | g_range
- * ----------|-----------
- * 0x03 | BMI160_ACCEL_RANGE_2G
- * 0x05 | BMI160_ACCEL_RANGE_4G
- * 0x08 | BMI160_ACCEL_RANGE_8G
- * 0x0C | BMI160_ACCEL_RANGE_16G
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_range(u8 v_range_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if ((v_range_u8 == BMI160_ACCEL_RANGE0) ||
- (v_range_u8 == BMI160_ACCEL_RANGE1) ||
- (v_range_u8 == BMI160_ACCEL_RANGE3) ||
- (v_range_u8 == BMI160_ACCEL_RANGE4)) {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_ACCEL_RANGE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(
- v_data_u8, BMI160_USER_ACCEL_RANGE,
- v_range_u8);
- /* write the accel range*/
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_ACCEL_RANGE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to get the
- * gyroscope output data rate from the register 0x42 bit 0 to 3
- *
- *
- *
- *
- * @param v_output_data_rate_u8 :The value of gyro output data rate
- * value | gyro output data rate
- * -----------|-----------------------------
- * 0x00 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x01 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x02 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x03 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x04 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x05 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x06 | BMI160_GYRO_OUTPUT_DATA_RATE_25HZ
- * 0x07 | BMI160_GYRO_OUTPUT_DATA_RATE_50HZ
- * 0x08 | BMI160_GYRO_OUTPUT_DATA_RATE_100HZ
- * 0x09 | BMI160_GYRO_OUTPUT_DATA_RATE_200HZ
- * 0x0A | BMI160_GYRO_OUTPUT_DATA_RATE_400HZ
- * 0x0B | BMI160_GYRO_OUTPUT_DATA_RATE_800HZ
- * 0x0C | BMI160_GYRO_OUTPUT_DATA_RATE_1600HZ
- * 0x0D | BMI160_GYRO_OUTPUT_DATA_RATE_3200HZ
- * 0x0E | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x0F | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_output_data_rate(
-u8 *v_output_data_rate_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the gyro output data rate*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_output_data_rate_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set the
- * gyroscope output data rate from the register 0x42 bit 0 to 3
- *
- *
- *
- *
- * @param v_output_data_rate_u8 :The value of gyro output data rate
- * value | gyro output data rate
- * -----------|-----------------------------
- * 0x00 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x01 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x02 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x03 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x04 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x05 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x06 | BMI160_GYRO_OUTPUT_DATA_RATE_25HZ
- * 0x07 | BMI160_GYRO_OUTPUT_DATA_RATE_50HZ
- * 0x08 | BMI160_GYRO_OUTPUT_DATA_RATE_100HZ
- * 0x09 | BMI160_GYRO_OUTPUT_DATA_RATE_200HZ
- * 0x0A | BMI160_GYRO_OUTPUT_DATA_RATE_400HZ
- * 0x0B | BMI160_GYRO_OUTPUT_DATA_RATE_800HZ
- * 0x0C | BMI160_GYRO_OUTPUT_DATA_RATE_1600HZ
- * 0x0D | BMI160_GYRO_OUTPUT_DATA_RATE_3200HZ
- * 0x0E | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x0F | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_output_data_rate(
-u8 v_output_data_rate_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* select the gyro output data rate*/
- if ((v_output_data_rate_u8 < BMI160_OUTPUT_DATA_RATE6) &&
- (v_output_data_rate_u8 != BMI160_INIT_VALUE)
- && (v_output_data_rate_u8 != BMI160_OUTPUT_DATA_RATE1)
- && (v_output_data_rate_u8 != BMI160_OUTPUT_DATA_RATE2)
- && (v_output_data_rate_u8 != BMI160_OUTPUT_DATA_RATE3)
- && (v_output_data_rate_u8 != BMI160_OUTPUT_DATA_RATE4)
- && (v_output_data_rate_u8 != BMI160_OUTPUT_DATA_RATE5)
- && (v_output_data_rate_u8 != BMI160_OUTPUT_DATA_RATE6)
- && (v_output_data_rate_u8 != BMI160_OUTPUT_DATA_RATE7)) {
- /* write the gyro output data rate */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE,
- v_output_data_rate_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to get the
- * data of gyro from the register 0x42 bit 4 to 5
- *
- *
- *
- *
- * @param v_bw_u8 : The value of gyro bandwidth
- * value | gyro bandwidth
- * ----------|----------------
- * 0x00 | BMI160_GYRO_OSR4_MODE
- * 0x01 | BMI160_GYRO_OSR2_MODE
- * 0x02 | BMI160_GYRO_NORMAL_MODE
- * 0x03 | BMI160_GYRO_CIC_MODE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_bw(u8 *v_bw_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read gyro bandwidth*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_GYRO_CONFIG_BW__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_bw_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_GYRO_CONFIG_BW);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set the
- * data of gyro from the register 0x42 bit 4 to 5
- *
- *
- *
- *
- * @param v_bw_u8 : The value of gyro bandwidth
- * value | gyro bandwidth
- * ----------|----------------
- * 0x00 | BMI160_GYRO_OSR4_MODE
- * 0x01 | BMI160_GYRO_OSR2_MODE
- * 0x02 | BMI160_GYRO_NORMAL_MODE
- * 0x03 | BMI160_GYRO_CIC_MODE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_bw(u8 v_bw_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_bw_u8 <= BMI160_MAX_GYRO_BW) {
- /* write the gyro bandwidth*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_GYRO_CONFIG_BW__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_GYRO_CONFIG_BW, v_bw_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_CONFIG_BW__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads the range
- * of gyro from the register 0x43 bit 0 to 2
- *
- * @param v_range_u8 : The value of gyro range
- * value | range
- * ----------|-------------------------------
- * 0x00 | BMI160_GYRO_RANGE_2000_DEG_SEC
- * 0x01 | BMI160_GYRO_RANGE_1000_DEG_SEC
- * 0x02 | BMI160_GYRO_RANGE_500_DEG_SEC
- * 0x03 | BMI160_GYRO_RANGE_250_DEG_SEC
- * 0x04 | BMI160_GYRO_RANGE_125_DEG_SEC
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_range(u8 *v_range_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the gyro range */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_GYRO_RANGE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_range_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_GYRO_RANGE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API set the range
- * of gyro from the register 0x43 bit 0 to 2
- *
- * @param v_range_u8 : The value of gyro range
- * value | range
- * ----------|-------------------------------
- * 0x00 | BMI160_GYRO_RANGE_2000_DEG_SEC
- * 0x01 | BMI160_GYRO_RANGE_1000_DEG_SEC
- * 0x02 | BMI160_GYRO_RANGE_500_DEG_SEC
- * 0x03 | BMI160_GYRO_RANGE_250_DEG_SEC
- * 0x04 | BMI160_GYRO_RANGE_125_DEG_SEC
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_range(u8 v_range_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_range_u8 <= BMI160_MAX_GYRO_RANGE) {
- /* write the gyro range value */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_GYRO_RANGE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_GYRO_RANGE,
- v_range_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_GYRO_RANGE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to get the
- * output data rate of magnetometer from the register 0x44 bit 0 to 3
- *
- *
- *
- *
- * @param v_output_data_rat_u8e : The value of mag output data rate
- * value | mag output data rate
- * ---------|---------------------------
- * 0x00 |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED
- * 0x01 |BMI160_MAG_OUTPUT_DATA_RATE_0_78HZ
- * 0x02 |BMI160_MAG_OUTPUT_DATA_RATE_1_56HZ
- * 0x03 |BMI160_MAG_OUTPUT_DATA_RATE_3_12HZ
- * 0x04 |BMI160_MAG_OUTPUT_DATA_RATE_6_25HZ
- * 0x05 |BMI160_MAG_OUTPUT_DATA_RATE_12_5HZ
- * 0x06 |BMI160_MAG_OUTPUT_DATA_RATE_25HZ
- * 0x07 |BMI160_MAG_OUTPUT_DATA_RATE_50HZ
- * 0x08 |BMI160_MAG_OUTPUT_DATA_RATE_100HZ
- * 0x09 |BMI160_MAG_OUTPUT_DATA_RATE_200HZ
- * 0x0A |BMI160_MAG_OUTPUT_DATA_RATE_400HZ
- * 0x0B |BMI160_MAG_OUTPUT_DATA_RATE_800HZ
- * 0x0C |BMI160_MAG_OUTPUT_DATA_RATE_1600HZ
- * 0x0D |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED0
- * 0x0E |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED1
- * 0x0F |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED2
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_output_data_rate(
-u8 *v_output_data_rat_u8e)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the mag data output rate*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_output_data_rat_u8e = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set the
- * output data rate of magnetometer from the register 0x44 bit 0 to 3
- *
- *
- *
- *
- * @param v_output_data_rat_u8e : The value of mag output data rate
- * value | mag output data rate
- * ---------|---------------------------
- * 0x00 |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED
- * 0x01 |BMI160_MAG_OUTPUT_DATA_RATE_0_78HZ
- * 0x02 |BMI160_MAG_OUTPUT_DATA_RATE_1_56HZ
- * 0x03 |BMI160_MAG_OUTPUT_DATA_RATE_3_12HZ
- * 0x04 |BMI160_MAG_OUTPUT_DATA_RATE_6_25HZ
- * 0x05 |BMI160_MAG_OUTPUT_DATA_RATE_12_5HZ
- * 0x06 |BMI160_MAG_OUTPUT_DATA_RATE_25HZ
- * 0x07 |BMI160_MAG_OUTPUT_DATA_RATE_50HZ
- * 0x08 |BMI160_MAG_OUTPUT_DATA_RATE_100HZ
- * 0x09 |BMI160_MAG_OUTPUT_DATA_RATE_200HZ
- * 0x0A |BMI160_MAG_OUTPUT_DATA_RATE_400HZ
- * 0x0B |BMI160_MAG_OUTPUT_DATA_RATE_800HZ
- * 0x0C |BMI160_MAG_OUTPUT_DATA_RATE_1600HZ
- * 0x0D |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED0
- * 0x0E |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED1
- * 0x0F |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED2
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_output_data_rate(
-u8 v_output_data_rat_u8e)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* select the mag data output rate*/
- if ((v_output_data_rat_u8e
- <= BMI160_MAX_ACCEL_OUTPUT_DATA_RATE)
- && (v_output_data_rat_u8e
- != BMI160_OUTPUT_DATA_RATE0)
- && (v_output_data_rat_u8e
- != BMI160_OUTPUT_DATA_RATE6)
- && (v_output_data_rat_u8e
- != BMI160_OUTPUT_DATA_RATE7)) {
- /* write the mag data output rate*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE,
- v_output_data_rat_u8e);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API is used to read Down sampling
- * for gyro (2**downs_gyro) in the register 0x45 bit 0 to 2
- *
- *
- *
- *
- * @param v_fifo_down_gyro_u8 :The value of gyro fifo down
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_down_gyro(
-u8 *v_fifo_down_gyro_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the gyro fifo down*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_DOWN_GYRO__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_fifo_down_gyro_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_DOWN_GYRO);
- }
- return com_rslt;
-}
- /*!
- * @brief This API is used to set Down sampling
- * for gyro (2**downs_gyro) in the register 0x45 bit 0 to 2
- *
- *
- *
- *
- * @param v_fifo_down_gyro_u8 :The value of gyro fifo down
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_down_gyro(
-u8 v_fifo_down_gyro_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write the gyro fifo down*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_DOWN_GYRO__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(
- v_data_u8,
- BMI160_USER_FIFO_DOWN_GYRO,
- v_fifo_down_gyro_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FIFO_DOWN_GYRO__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read gyro fifo filter data
- * from the register 0x45 bit 3
- *
- *
- *
- * @param v_gyro_fifo_filter_data_u8 :The value of gyro filter data
- * value | gyro_fifo_filter_data
- * ------------|-------------------------
- * 0x00 | Unfiltered data
- * 0x01 | Filtered data
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_fifo_filter_data(
-u8 *v_gyro_fifo_filter_data_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the gyro fifo filter data */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_FILTER_GYRO__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_gyro_fifo_filter_data_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_FILTER_GYRO);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set gyro fifo filter data
- * from the register 0x45 bit 3
- *
- *
- *
- * @param v_gyro_fifo_filter_data_u8 :The value of gyro filter data
- * value | gyro_fifo_filter_data
- * ------------|-------------------------
- * 0x00 | Unfiltered data
- * 0x01 | Filtered data
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_fifo_filter_data(
-u8 v_gyro_fifo_filter_data_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_gyro_fifo_filter_data_u8
- <= BMI160_MAX_VALUE_FIFO_FILTER) {
- /* write the gyro fifo filter data */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_FILTER_GYRO__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(
- v_data_u8,
- BMI160_USER_FIFO_FILTER_GYRO,
- v_gyro_fifo_filter_data_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FIFO_FILTER_GYRO__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read Down sampling
- * for accel (2*downs_accel) from the register 0x45 bit 4 to 6
- *
- *
- *
- *
- * @param v_fifo_down_u8 :The value of accel fifo down
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_down_accel(
-u8 *v_fifo_down_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the accel fifo down data */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_DOWN_ACCEL__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_fifo_down_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_DOWN_ACCEL);
- }
- return com_rslt;
-}
- /*!
- * @brief This API is used to set Down sampling
- * for accel (2*downs_accel) from the register 0x45 bit 4 to 6
- *
- *
- *
- *
- * @param v_fifo_down_u8 :The value of accel fifo down
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_down_accel(
-u8 v_fifo_down_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write the accel fifo down data */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_DOWN_ACCEL__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_DOWN_ACCEL, v_fifo_down_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FIFO_DOWN_ACCEL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read accel fifo filter data
- * from the register 0x45 bit 7
- *
- *
- *
- * @param accel_fifo_filter_u8 :The value of accel filter data
- * value | accel_fifo_filter_u8
- * ------------|-------------------------
- * 0x00 | Unfiltered data
- * 0x01 | Filtered data
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_fifo_filter_data(
-u8 *accel_fifo_filter_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the accel fifo filter data */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_FILTER_ACCEL__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *accel_fifo_filter_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_FILTER_ACCEL);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set accel fifo filter data
- * from the register 0x45 bit 7
- *
- *
- *
- * @param v_accel_fifo_filter_u8 :The value of accel filter data
- * value | accel_fifo_filter_data
- * ------------|-------------------------
- * 0x00 | Unfiltered data
- * 0x01 | Filtered data
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_fifo_filter_data(
-u8 v_accel_fifo_filter_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_accel_fifo_filter_u8 <= BMI160_MAX_VALUE_FIFO_FILTER) {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_FILTER_ACCEL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- /* write accel fifo filter data */
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_FILTER_ACCEL,
- v_accel_fifo_filter_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FIFO_FILTER_ACCEL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to Trigger an interrupt
- * when FIFO contains water mark level from the register 0x46 bit 0 to 7
- *
- *
- *
- * @param v_fifo_wm_u8 : The value of fifo water mark level
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_wm(
-u8 *v_fifo_wm_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the fifo water mark level*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_WM__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_fifo_wm_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_WM);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to Trigger an interrupt
- * when FIFO contains water mark level from the register 0x46 bit 0 to 7
- *
- *
- *
- * @param v_fifo_wm_u8 : The value of fifo water mark level
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_wm(
-u8 v_fifo_wm_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write the fifo water mark level*/
- com_rslt =
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_WM__REG,
- &v_fifo_wm_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads fifo sensor time
- * frame after the last valid data frame form the register 0x47 bit 1
- *
- *
- *
- *
- * @param v_fifo_time_enable_u8 : The value of sensor time
- * value | fifo sensor time
- * ------------|-------------------------
- * 0x00 | do not return sensortime frame
- * 0x01 | return sensortime frame
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_time_enable(
-u8 *v_fifo_time_enable_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the fifo sensor time*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_TIME_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_fifo_time_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_TIME_ENABLE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API set fifo sensor time
- * frame after the last valid data frame form the register 0x47 bit 1
- *
- *
- *
- *
- * @param v_fifo_time_enable_u8 : The value of sensor time
- * value | fifo sensor time
- * ------------|-------------------------
- * 0x00 | do not return sensortime frame
- * 0x01 | return sensortime frame
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_time_enable(
-u8 v_fifo_time_enable_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_fifo_time_enable_u8 <= BMI160_MAX_VALUE_FIFO_TIME) {
- /* write the fifo sensor time*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_TIME_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_TIME_ENABLE,
- v_fifo_time_enable_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FIFO_TIME_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads FIFO tag interrupt2 enable status
- * from the resister 0x47 bit 2
- *
- * @param v_fifo_tag_intr2_u8 : The value of fifo tag interrupt
- * value | fifo tag interrupt
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_tag_intr2_enable(
-u8 *v_fifo_tag_intr2_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the fifo tag interrupt2*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_TAG_INTR2_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_fifo_tag_intr2_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_TAG_INTR2_ENABLE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API set FIFO tag interrupt2 enable status
- * from the resister 0x47 bit 2
- *
- * @param v_fifo_tag_intr2_u8 : The value of fifo tag interrupt
- * value | fifo tag interrupt
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_tag_intr2_enable(
-u8 v_fifo_tag_intr2_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_fifo_tag_intr2_u8 <= BMI160_MAX_VALUE_FIFO_INTR) {
- /* write the fifo tag interrupt2*/
- com_rslt = bmi160_set_input_enable(1,
- v_fifo_tag_intr2_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_TAG_INTR2_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_TAG_INTR2_ENABLE,
- v_fifo_tag_intr2_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FIFO_TAG_INTR2_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API get FIFO tag interrupt1 enable status
- * from the resister 0x47 bit 3
- *
- * @param v_fifo_tag_intr1_u8 :The value of fifo tag interrupt1
- * value | fifo tag interrupt
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_tag_intr1_enable(
-u8 *v_fifo_tag_intr1_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read fifo tag interrupt*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_TAG_INTR1_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_fifo_tag_intr1_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_TAG_INTR1_ENABLE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API set FIFO tag interrupt1 enable status
- * from the resister 0x47 bit 3
- *
- * @param v_fifo_tag_intr1_u8 :The value of fifo tag interrupt1
- * value | fifo tag interrupt
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_tag_intr1_enable(
-u8 v_fifo_tag_intr1_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_fifo_tag_intr1_u8 <= BMI160_MAX_VALUE_FIFO_INTR) {
- /* write the fifo tag interrupt*/
- com_rslt = bmi160_set_input_enable(BMI160_INIT_VALUE,
- v_fifo_tag_intr1_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_TAG_INTR1_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_TAG_INTR1_ENABLE,
- v_fifo_tag_intr1_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FIFO_TAG_INTR1_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads FIFO frame
- * header enable from the register 0x47 bit 4
- *
- * @param v_fifo_header_u8 :The value of fifo header
- * value | fifo header
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_header_enable(
-u8 *v_fifo_header_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read fifo header */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_HEADER_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_fifo_header_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_HEADER_ENABLE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API set FIFO frame
- * header enable from the register 0x47 bit 4
- *
- * @param v_fifo_header_u8 :The value of fifo header
- * value | fifo header
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_header_enable(
-u8 v_fifo_header_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_fifo_header_u8 <= BMI160_MAX_VALUE_FIFO_HEADER) {
- /* write the fifo header */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_HEADER_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_HEADER_ENABLE,
- v_fifo_header_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FIFO_HEADER_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read stored
- * magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
- *
- * @param v_fifo_mag_u8 : The value of fifo mag enble
- * value | fifo mag
- * ----------|-------------------
- * 0x00 | no magnetometer data is stored
- * 0x01 | magnetometer data is stored
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_mag_enable(
-u8 *v_fifo_mag_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the fifo mag enable*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_MAG_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_fifo_mag_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_MAG_ENABLE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set stored
- * magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
- *
- * @param v_fifo_mag_u8 : The value of fifo mag enble
- * value | fifo mag
- * ----------|-------------------
- * 0x00 | no magnetometer data is stored
- * 0x01 | magnetometer data is stored
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_mag_enable(
-u8 v_fifo_mag_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_fifo_mag_u8 <= BMI160_MAX_VALUE_FIFO_MAG) {
- /* write the fifo mag enable*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_FIFO_MAG_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_MAG_ENABLE,
- v_fifo_mag_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_FIFO_MAG_ENABLE__REG,
- &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read stored
- * accel data in FIFO (all 3 axes) from the register 0x47 bit 6
- *
- * @param v_fifo_accel_u8 : The value of fifo accel enble
- * value | fifo accel
- * ----------|-------------------
- * 0x00 | no accel data is stored
- * 0x01 | accel data is stored
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_accel_enable(
-u8 *v_fifo_accel_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the accel fifo enable*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_ACCEL_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_fifo_accel_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_ACCEL_ENABLE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set stored
- * accel data in FIFO (all 3 axes) from the register 0x47 bit 6
- *
- * @param v_fifo_accel_u8 : The value of fifo accel enble
- * value | fifo accel
- * ----------|-------------------
- * 0x00 | no accel data is stored
- * 0x01 | accel data is stored
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_accel_enable(
-u8 v_fifo_accel_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_fifo_accel_u8 <= BMI160_MAX_VALUE_FIFO_ACCEL) {
- /* write the fifo mag enables*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_ACCEL_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_ACCEL_ENABLE, v_fifo_accel_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FIFO_ACCEL_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read stored
- * gyro data in FIFO (all 3 axes) from the resister 0x47 bit 7
- *
- *
- * @param v_fifo_gyro_u8 : The value of fifo gyro enble
- * value | fifo gyro
- * ----------|-------------------
- * 0x00 | no gyro data is stored
- * 0x01 | gyro data is stored
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_gyro_enable(
-u8 *v_fifo_gyro_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read fifo gyro enable */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_GYRO_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_fifo_gyro_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_GYRO_ENABLE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set stored
- * gyro data in FIFO (all 3 axes) from the resister 0x47 bit 7
- *
- *
- * @param v_fifo_gyro_u8 : The value of fifo gyro enble
- * value | fifo gyro
- * ----------|-------------------
- * 0x00 | no gyro data is stored
- * 0x01 | gyro data is stored
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_gyro_enable(
-u8 v_fifo_gyro_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_fifo_gyro_u8 <= BMI160_MAX_VALUE_FIFO_GYRO) {
- /* write fifo gyro enable*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_FIFO_GYRO_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FIFO_GYRO_ENABLE, v_fifo_gyro_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FIFO_GYRO_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read
- * I2C device address of auxiliary mag from the register 0x4B bit 1 to 7
- *
- *
- *
- *
- * @param v_i2c_device_addr_u8 : The value of mag I2C device address
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_device_addr(
-u8 *v_i2c_device_addr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the mag I2C device address*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_I2C_DEVICE_ADDR__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_i2c_device_addr_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_I2C_DEVICE_ADDR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set
- * I2C device address of auxiliary mag from the register 0x4B bit 1 to 7
- *
- *
- *
- *
- * @param v_i2c_device_addr_u8 : The value of mag I2C device address
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_i2c_device_addr(
-u8 v_i2c_device_addr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write the mag I2C device address*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_I2C_DEVICE_ADDR__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_I2C_DEVICE_ADDR,
- v_i2c_device_addr_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_I2C_DEVICE_ADDR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read
- * Burst data length (1,2,6,8 byte) from the register 0x4C bit 0 to 1
- *
- *
- *
- *
- * @param v_mag_burst_u8 : The data of mag burst read lenth
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_burst(
-u8 *v_mag_burst_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read mag burst mode length*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_MAG_BURST__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_mag_burst_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_MAG_BURST);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set
- * Burst data length (1,2,6,8 byte) from the register 0x4C bit 0 to 1
- *
- *
- *
- *
- * @param v_mag_burst_u8 : The data of mag burst read lenth
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_burst(
-u8 v_mag_burst_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write mag burst mode length*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_MAG_BURST__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_MAG_BURST, v_mag_burst_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_MAG_BURST__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read
- * trigger-readout offset in units of 2.5 ms. If set to zero,
- * the offset is maximum, i.e. after readout a trigger
- * is issued immediately. from the register 0x4C bit 2 to 5
- *
- *
- *
- *
- * @param v_mag_offset_u8 : The value of mag offset
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_offset(
-u8 *v_mag_offset_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_MAG_OFFSET__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_mag_offset_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_MAG_OFFSET);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set
- * trigger-readout offset in units of 2.5 ms. If set to zero,
- * the offset is maximum, i.e. after readout a trigger
- * is issued immediately. from the register 0x4C bit 2 to 5
- *
- *
- *
- *
- * @param v_mag_offset_u8 : The value of mag offset
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_offset(
-u8 v_mag_offset_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_MAG_OFFSET__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_MAG_OFFSET, v_mag_offset_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
- BMI160_USER_MAG_OFFSET__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
-return com_rslt;
-}
-/*!
- * @brief This API is used to read
- * Enable register access on MAG_IF[2] or MAG_IF[3] writes.
- * This implies that the DATA registers are not updated with
- * magnetometer values. Accessing magnetometer requires
- * the magnetometer in normal mode in PMU_STATUS.
- * from the register 0x4C bit 7
- *
- *
- *
- * @param v_mag_manual_u8 : The value of mag manual enable
- * value | mag manual
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_manual_enable(
-u8 *v_mag_manual_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read mag manual */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_MAG_MANUAL_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_mag_manual_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_MAG_MANUAL_ENABLE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set
- * Enable register access on MAG_IF[2] or MAG_IF[3] writes.
- * This implies that the DATA registers are not updated with
- * magnetometer values. Accessing magnetometer requires
- * the magnetometer in normal mode in PMU_STATUS.
- * from the register 0x4C bit 7
- *
- *
- *
- * @param v_mag_manual_u8 : The value of mag manual enable
- * value | mag manual
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_manual_enable(
-u8 v_mag_manual_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write the mag manual*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_MAG_MANUAL_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- if (com_rslt == SUCCESS) {
- /* set the bit of mag manual enable*/
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_MAG_MANUAL_ENABLE, v_mag_manual_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
- BMI160_USER_MAG_MANUAL_ENABLE__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- if (com_rslt == SUCCESS)
- p_bmi160->mag_manual_enable = v_mag_manual_u8;
- else
- p_bmi160->mag_manual_enable = E_BMI160_COMM_RES;
- }
-return com_rslt;
-}
-/*!
- * @brief This API is used to read data
- * magnetometer address to read from the register 0x4D bit 0 to 7
- * @brief It used to provide mag read address of auxiliary mag
- *
- *
- *
- *
- * @param v_mag_read_addr_u8 : The value of address need to be read
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_read_addr(
-u8 *v_mag_read_addr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the written address*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_READ_ADDR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_mag_read_addr_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_READ_ADDR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set
- * magnetometer write address from the register 0x4D bit 0 to 7
- * @brief mag write address writes the address of auxiliary mag to write
- *
- *
- *
- * @param v_mag_read_addr_u8:
- * The data of auxiliary mag address to write data
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_read_addr(
-u8 v_mag_read_addr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write the mag read address*/
- com_rslt =
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
- BMI160_USER_READ_ADDR__REG, &v_mag_read_addr_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read
- * magnetometer write address from the register 0x4E bit 0 to 7
- * @brief mag write address writes the address of auxiliary mag to write
- *
- *
- *
- * @param v_mag_write_addr_u8:
- * The data of auxiliary mag address to write data
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_write_addr(
-u8 *v_mag_write_addr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the address of last written */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_WRITE_ADDR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_mag_write_addr_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_WRITE_ADDR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set
- * magnetometer write address from the register 0x4E bit 0 to 7
- * @brief mag write address writes the address of auxiliary mag to write
- *
- *
- *
- * @param v_mag_write_addr_u8:
- * The data of auxiliary mag address to write data
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_write_addr(
-u8 v_mag_write_addr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write the data of mag address to write data */
- com_rslt =
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
- BMI160_USER_WRITE_ADDR__REG, &v_mag_write_addr_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read magnetometer write data
- * form the resister 0x4F bit 0 to 7
- * @brief This writes the data will be wrote to mag
- *
- *
- *
- * @param v_mag_write_data_u8: The value of mag data
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_write_data(
-u8 *v_mag_write_data_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_WRITE_DATA__REG, &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_mag_write_data_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_WRITE_DATA);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set magnetometer write data
- * form the resister 0x4F bit 0 to 7
- * @brief This writes the data will be wrote to mag
- *
- *
- *
- * @param v_mag_write_data_u8: The value of mag data
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_write_data(
-u8 v_mag_write_data_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt =
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->dev_addr,
- BMI160_USER_WRITE_DATA__REG, &v_mag_write_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read
- * interrupt enable from the register 0x50 bit 0 to 7
- *
- *
- *
- *
- * @param v_enable_u8 : Value to decided to select interrupt
- * v_enable_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_ANY_MOTION_X_ENABLE
- * 1 | BMI160_ANY_MOTION_Y_ENABLE
- * 2 | BMI160_ANY_MOTION_Z_ENABLE
- * 3 | BMI160_DOUBLE_TAP_ENABLE
- * 4 | BMI160_SINGLE_TAP_ENABLE
- * 5 | BMI160_ORIENT_ENABLE
- * 6 | BMI160_FLAT_ENABLE
- *
- * @param v_intr_enable_zero_u8 : The interrupt enable value
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_0(
-u8 v_enable_u8, u8 *v_intr_enable_zero_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* select interrupt to read*/
- switch (v_enable_u8) {
- case BMI160_ANY_MOTION_X_ENABLE:
- /* read the any motion interrupt x data */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_zero_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE);
- break;
- case BMI160_ANY_MOTION_Y_ENABLE:
- /* read the any motion interrupt y data */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_zero_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE);
- break;
- case BMI160_ANY_MOTION_Z_ENABLE:
- /* read the any motion interrupt z data */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_zero_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE);
- break;
- case BMI160_DOUBLE_TAP_ENABLE:
- /* read the double tap interrupt data */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_zero_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE);
- break;
- case BMI160_SINGLE_TAP_ENABLE:
- /* read the single tap interrupt data */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_zero_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE);
- break;
- case BMI160_ORIENT_ENABLE:
- /* read the orient interrupt data */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_zero_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE);
- break;
- case BMI160_FLAT_ENABLE:
- /* read the flat interrupt data */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_zero_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set
- * interrupt enable from the register 0x50 bit 0 to 7
- *
- *
- *
- *
- * @param v_enable_u8 : Value to decided to select interrupt
- * v_enable_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_ANY_MOTION_X_ENABLE
- * 1 | BMI160_ANY_MOTION_Y_ENABLE
- * 2 | BMI160_ANY_MOTION_Z_ENABLE
- * 3 | BMI160_DOUBLE_TAP_ENABLE
- * 4 | BMI160_SINGLE_TAP_ENABLE
- * 5 | BMI160_ORIENT_ENABLE
- * 6 | BMI160_FLAT_ENABLE
- *
- * @param v_intr_enable_zero_u8 : The interrupt enable value
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_enable_0(
-u8 v_enable_u8, u8 v_intr_enable_zero_u8)
-{
-/* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_enable_u8) {
- case BMI160_ANY_MOTION_X_ENABLE:
- /* write any motion x*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE,
- v_intr_enable_zero_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_ANY_MOTION_Y_ENABLE:
- /* write any motion y*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE,
- v_intr_enable_zero_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_ANY_MOTION_Z_ENABLE:
- /* write any motion z*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE,
- v_intr_enable_zero_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_DOUBLE_TAP_ENABLE:
- /* write double tap*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE,
- v_intr_enable_zero_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_SINGLE_TAP_ENABLE:
- /* write single tap */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE,
- v_intr_enable_zero_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_ORIENT_ENABLE:
- /* write orient interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE,
- v_intr_enable_zero_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_FLAT_ENABLE:
- /* write flat interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE,
- v_intr_enable_zero_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
-}
-return com_rslt;
-}
-/*!
- * @brief This API is used to read
- * interrupt enable byte1 from the register 0x51 bit 0 to 6
- * @brief It read the high_g_x,high_g_y,high_g_z,low_g_enable
- * data ready, fifo full and fifo water mark.
- *
- *
- *
- * @param v_enable_u8 : The value of interrupt enable
- * @param v_enable_u8 : Value to decided to select interrupt
- * v_enable_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_HIGH_G_X_ENABLE
- * 1 | BMI160_HIGH_G_Y_ENABLE
- * 2 | BMI160_HIGH_G_Z_ENABLE
- * 3 | BMI160_LOW_G_ENABLE
- * 4 | BMI160_DATA_RDY_ENABLE
- * 5 | BMI160_FIFO_FULL_ENABLE
- * 6 | BMI160_FIFO_WM_ENABLE
- *
- * @param v_intr_enable_1_u8 : The interrupt enable value
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_1(
-u8 v_enable_u8, u8 *v_intr_enable_1_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_enable_u8) {
- case BMI160_HIGH_G_X_ENABLE:
- /* read high_g_x interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE);
- break;
- case BMI160_HIGH_G_Y_ENABLE:
- /* read high_g_y interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE);
- break;
- case BMI160_HIGH_G_Z_ENABLE:
- /* read high_g_z interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE);
- break;
- case BMI160_LOW_G_ENABLE:
- /* read low_g interrupt */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE);
- break;
- case BMI160_DATA_RDY_ENABLE:
- /* read data ready interrupt */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE);
- break;
- case BMI160_FIFO_FULL_ENABLE:
- /* read fifo full interrupt */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE);
- break;
- case BMI160_FIFO_WM_ENABLE:
- /* read fifo water mark interrupt */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_1_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set
- * interrupt enable byte1 from the register 0x51 bit 0 to 6
- * @brief It read the high_g_x,high_g_y,high_g_z,low_g_enable
- * data ready, fifo full and fifo water mark.
- *
- *
- *
- * @param v_enable_u8 : The value of interrupt enable
- * @param v_enable_u8 : Value to decided to select interrupt
- * v_enable_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_HIGH_G_X_ENABLE
- * 1 | BMI160_HIGH_G_Y_ENABLE
- * 2 | BMI160_HIGH_G_Z_ENABLE
- * 3 | BMI160_LOW_G_ENABLE
- * 4 | BMI160_DATA_RDY_ENABLE
- * 5 | BMI160_FIFO_FULL_ENABLE
- * 6 | BMI160_FIFO_WM_ENABLE
- *
- * @param v_intr_enable_1_u8 : The interrupt enable value
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_enable_1(
-u8 v_enable_u8, u8 v_intr_enable_1_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_enable_u8) {
- case BMI160_HIGH_G_X_ENABLE:
- /* write high_g_x interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE,
- v_intr_enable_1_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_HIGH_G_Y_ENABLE:
- /* write high_g_y interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE,
- v_intr_enable_1_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_HIGH_G_Z_ENABLE:
- /* write high_g_z interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE,
- v_intr_enable_1_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_LOW_G_ENABLE:
- /* write low_g interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE,
- v_intr_enable_1_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_DATA_RDY_ENABLE:
- /* write data ready interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE,
- v_intr_enable_1_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_FIFO_FULL_ENABLE:
- /* write fifo full interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE,
- v_intr_enable_1_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_FIFO_WM_ENABLE:
- /* write fifo water mark interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE,
- v_intr_enable_1_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read
- * interrupt enable byte2 from the register bit 0x52 bit 0 to 3
- * @brief It reads no motion x,y and z
- *
- *
- *
- * @param v_enable_u8: The value of interrupt enable
- * v_enable_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_NOMOTION_X_ENABLE
- * 1 | BMI160_NOMOTION_Y_ENABLE
- * 2 | BMI160_NOMOTION_Z_ENABLE
- *
- * @param v_intr_enable_2_u8 : The interrupt enable value
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_2(
-u8 v_enable_u8, u8 *v_intr_enable_2_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_enable_u8) {
- case BMI160_NOMOTION_X_ENABLE:
- /* read no motion x */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_2_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE);
- break;
- case BMI160_NOMOTION_Y_ENABLE:
- /* read no motion y */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_2_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE);
- break;
- case BMI160_NOMOTION_Z_ENABLE:
- /* read no motion z */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_enable_2_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to set
- * interrupt enable byte2 from the register bit 0x52 bit 0 to 3
- * @brief It reads no motion x,y and z
- *
- *
- *
- * @param v_enable_u8: The value of interrupt enable
- * v_enable_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_NOMOTION_X_ENABLE
- * 1 | BMI160_NOMOTION_Y_ENABLE
- * 2 | BMI160_NOMOTION_Z_ENABLE
- *
- * @param v_intr_enable_2_u8 : The interrupt enable value
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_enable_2(
-u8 v_enable_u8, u8 v_intr_enable_2_u8)
-{
-/* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_enable_u8) {
- case BMI160_NOMOTION_X_ENABLE:
- /* write no motion x */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE,
- v_intr_enable_2_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_NOMOTION_Y_ENABLE:
- /* write no motion y */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE,
- v_intr_enable_2_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_NOMOTION_Z_ENABLE:
- /* write no motion z */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE,
- v_intr_enable_2_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
-}
-return com_rslt;
-}
- /*!
- * @brief This API is used to read
- * interrupt enable step detector interrupt from
- * the register bit 0x52 bit 3
- *
- *
- *
- *
- * @param v_step_intr_u8 : The value of step detector interrupt enable
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_detector_enable(
-u8 *v_step_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the step detector interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_step_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE);
- }
- return com_rslt;
-}
- /*!
- * @brief This API is used to set
- * interrupt enable step detector interrupt from
- * the register bit 0x52 bit 3
- *
- *
- *
- *
- * @param v_step_intr_u8 : The value of step detector interrupt enable
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_detector_enable(
-u8 v_step_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE,
- v_step_intr_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Configure trigger condition of interrupt1
- * and interrupt2 pin from the register 0x53
- * @brief interrupt1 - bit 0
- * @brief interrupt2 - bit 4
- *
- * @param v_channel_u8: The value of edge trigger selection
- * v_channel_u8 | Edge trigger
- * ---------------|---------------
- * 0 | BMI160_INTR1_EDGE_CTRL
- * 1 | BMI160_INTR2_EDGE_CTRL
- *
- * @param v_intr_edge_ctrl_u8 : The value of edge trigger enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_EDGE
- * 0x00 | BMI160_LEVEL
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_edge_ctrl(
-u8 v_channel_u8, u8 *v_intr_edge_ctrl_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- case BMI160_INTR1_EDGE_CTRL:
- /* read the edge trigger interrupt1*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_EDGE_CTRL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_edge_ctrl_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR1_EDGE_CTRL);
- break;
- case BMI160_INTR2_EDGE_CTRL:
- /* read the edge trigger interrupt2*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_EDGE_CTRL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_edge_ctrl_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR2_EDGE_CTRL);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Configure trigger condition of interrupt1
- * and interrupt2 pin from the register 0x53
- * @brief interrupt1 - bit 0
- * @brief interrupt2 - bit 4
- *
- * @param v_channel_u8: The value of edge trigger selection
- * v_channel_u8 | Edge trigger
- * ---------------|---------------
- * 0 | BMI160_INTR1_EDGE_CTRL
- * 1 | BMI160_INTR2_EDGE_CTRL
- *
- * @param v_intr_edge_ctrl_u8 : The value of edge trigger enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_EDGE
- * 0x00 | BMI160_LEVEL
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_edge_ctrl(
-u8 v_channel_u8, u8 v_intr_edge_ctrl_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- case BMI160_INTR1_EDGE_CTRL:
- /* write the edge trigger interrupt1*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_EDGE_CTRL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR1_EDGE_CTRL,
- v_intr_edge_ctrl_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_EDGE_CTRL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_EDGE_CTRL:
- /* write the edge trigger interrupt2*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_EDGE_CTRL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR2_EDGE_CTRL,
- v_intr_edge_ctrl_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_EDGE_CTRL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief API used for get the Configure level condition of interrupt1
- * and interrupt2 pin form the register 0x53
- * @brief interrupt1 - bit 1
- * @brief interrupt2 - bit 5
- *
- * @param v_channel_u8: The value of level condition selection
- * v_channel_u8 | level selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_LEVEL
- * 1 | BMI160_INTR2_LEVEL
- *
- * @param v_intr_level_u8 : The value of level of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_LEVEL_HIGH
- * 0x00 | BMI160_LEVEL_LOW
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_level(
-u8 v_channel_u8, u8 *v_intr_level_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- case BMI160_INTR1_LEVEL:
- /* read the interrupt1 level*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_LEVEL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_level_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR1_LEVEL);
- break;
- case BMI160_INTR2_LEVEL:
- /* read the interrupt2 level*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_LEVEL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_level_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR2_LEVEL);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief API used for set the Configure level condition of interrupt1
- * and interrupt2 pin form the register 0x53
- * @brief interrupt1 - bit 1
- * @brief interrupt2 - bit 5
- *
- * @param v_channel_u8: The value of level condition selection
- * v_channel_u8 | level selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_LEVEL
- * 1 | BMI160_INTR2_LEVEL
- *
- * @param v_intr_level_u8 : The value of level of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_LEVEL_HIGH
- * 0x00 | BMI160_LEVEL_LOW
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_level(
-u8 v_channel_u8, u8 v_intr_level_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- case BMI160_INTR1_LEVEL:
- /* write the interrupt1 level*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_LEVEL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR1_LEVEL, v_intr_level_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_LEVEL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_LEVEL:
- /* write the interrupt2 level*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_LEVEL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR2_LEVEL, v_intr_level_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_LEVEL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief API used to get configured output enable of interrupt1
- * and interrupt2 from the register 0x53
- * @brief interrupt1 - bit 2
- * @brief interrupt2 - bit 6
- *
- *
- * @param v_channel_u8: The value of output type enable selection
- * v_channel_u8 | level selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_OUTPUT_TYPE
- * 1 | BMI160_INTR2_OUTPUT_TYPE
- *
- * @param v_intr_output_type_u8 :
- * The value of output type of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_OPEN_DRAIN
- * 0x00 | BMI160_PUSH_PULL
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_output_type(
-u8 v_channel_u8, u8 *v_intr_output_type_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- case BMI160_INTR1_OUTPUT_TYPE:
- /* read the output type of interrupt1*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_OUTPUT_TYPE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_output_type_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR1_OUTPUT_TYPE);
- break;
- case BMI160_INTR2_OUTPUT_TYPE:
- /* read the output type of interrupt2*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_OUTPUT_TYPE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_output_type_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR2_OUTPUT_TYPE);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief API used to set output enable of interrupt1
- * and interrupt2 from the register 0x53
- * @brief interrupt1 - bit 2
- * @brief interrupt2 - bit 6
- *
- *
- * @param v_channel_u8: The value of output type enable selection
- * v_channel_u8 | level selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_OUTPUT_TYPE
- * 1 | BMI160_INTR2_OUTPUT_TYPE
- *
- * @param v_intr_output_type_u8 :
- * The value of output type of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_OPEN_DRAIN
- * 0x00 | BMI160_PUSH_PULL
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_output_type(
-u8 v_channel_u8, u8 v_intr_output_type_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- case BMI160_INTR1_OUTPUT_TYPE:
- /* write the output type of interrupt1*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_OUTPUT_TYPE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR1_OUTPUT_TYPE,
- v_intr_output_type_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_OUTPUT_TYPE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_OUTPUT_TYPE:
- /* write the output type of interrupt2*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_OUTPUT_TYPE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR2_OUTPUT_TYPE,
- v_intr_output_type_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_OUTPUT_TYPE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief API used to get the Output enable for interrupt1
- * and interrupt1 pin from the register 0x53
- * @brief interrupt1 - bit 3
- * @brief interrupt2 - bit 7
- *
- * @param v_channel_u8: The value of output enable selection
- * v_channel_u8 | level selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_OUTPUT_TYPE
- * 1 | BMI160_INTR2_OUTPUT_TYPE
- *
- * @param v_output_enable_u8 :
- * The value of output enable of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_INPUT
- * 0x00 | BMI160_OUTPUT
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_output_enable(
-u8 v_channel_u8, u8 *v_output_enable_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- case BMI160_INTR1_OUTPUT_ENABLE:
- /* read the output enable of interrupt1*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_OUTPUT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_output_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR1_OUTPUT_ENABLE);
- break;
- case BMI160_INTR2_OUTPUT_ENABLE:
- /* read the output enable of interrupt2*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_OUTPUT_EN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_output_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR2_OUTPUT_EN);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief API used to set the Output enable for interrupt1
- * and interrupt1 pin from the register 0x53
- * @brief interrupt1 - bit 3
- * @brief interrupt2 - bit 7
- *
- * @param v_channel_u8: The value of output enable selection
- * v_channel_u8 | level selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_OUTPUT_TYPE
- * 1 | BMI160_INTR2_OUTPUT_TYPE
- *
- * @param v_output_enable_u8 :
- * The value of output enable of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_INPUT
- * 0x00 | BMI160_OUTPUT
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_output_enable(
-u8 v_channel_u8, u8 v_output_enable_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- case BMI160_INTR1_OUTPUT_ENABLE:
- /* write the output enable of interrupt1*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_OUTPUT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR1_OUTPUT_ENABLE,
- v_output_enable_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_OUTPUT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_OUTPUT_ENABLE:
- /* write the output enable of interrupt2*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_OUTPUT_EN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR2_OUTPUT_EN,
- v_output_enable_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_OUTPUT_EN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
-* @brief This API is used to get the latch duration
-* from the register 0x54 bit 0 to 3
-* @brief This latch selection is not applicable for data ready,
-* orientation and flat interrupts.
-*
-*
-*
-* @param v_latch_intr_u8 : The value of latch duration
-* Latch Duration | value
-* --------------------------------------|------------------
-* BMI160_LATCH_DUR_NONE | 0x00
-* BMI160_LATCH_DUR_312_5_MICRO_SEC | 0x01
-* BMI160_LATCH_DUR_625_MICRO_SEC | 0x02
-* BMI160_LATCH_DUR_1_25_MILLI_SEC | 0x03
-* BMI160_LATCH_DUR_2_5_MILLI_SEC | 0x04
-* BMI160_LATCH_DUR_5_MILLI_SEC | 0x05
-* BMI160_LATCH_DUR_10_MILLI_SEC | 0x06
-* BMI160_LATCH_DUR_20_MILLI_SEC | 0x07
-* BMI160_LATCH_DUR_40_MILLI_SEC | 0x08
-* BMI160_LATCH_DUR_80_MILLI_SEC | 0x09
-* BMI160_LATCH_DUR_160_MILLI_SEC | 0x0A
-* BMI160_LATCH_DUR_320_MILLI_SEC | 0x0B
-* BMI160_LATCH_DUR_640_MILLI_SEC | 0x0C
-* BMI160_LATCH_DUR_1_28_SEC | 0x0D
-* BMI160_LATCH_DUR_2_56_SEC | 0x0E
-* BMI160_LATCHED | 0x0F
-*
-*
-*
-* @return results of bus communication function
-* @retval 0 -> Success
-* @retval -1 -> Error
-*
-*
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_latch_intr(
-u8 *v_latch_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the latch duration value */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_LATCH__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_latch_intr_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_LATCH);
- }
- return com_rslt;
-}
-/*!
-* @brief This API is used to set the latch duration
-* from the register 0x54 bit 0 to 3
-* @brief This latch selection is not applicable for data ready,
-* orientation and flat interrupts.
-*
-*
-*
-* @param v_latch_intr_u8 : The value of latch duration
-* Latch Duration | value
-* --------------------------------------|------------------
-* BMI160_LATCH_DUR_NONE | 0x00
-* BMI160_LATCH_DUR_312_5_MICRO_SEC | 0x01
-* BMI160_LATCH_DUR_625_MICRO_SEC | 0x02
-* BMI160_LATCH_DUR_1_25_MILLI_SEC | 0x03
-* BMI160_LATCH_DUR_2_5_MILLI_SEC | 0x04
-* BMI160_LATCH_DUR_5_MILLI_SEC | 0x05
-* BMI160_LATCH_DUR_10_MILLI_SEC | 0x06
-* BMI160_LATCH_DUR_20_MILLI_SEC | 0x07
-* BMI160_LATCH_DUR_40_MILLI_SEC | 0x08
-* BMI160_LATCH_DUR_80_MILLI_SEC | 0x09
-* BMI160_LATCH_DUR_160_MILLI_SEC | 0x0A
-* BMI160_LATCH_DUR_320_MILLI_SEC | 0x0B
-* BMI160_LATCH_DUR_640_MILLI_SEC | 0x0C
-* BMI160_LATCH_DUR_1_28_SEC | 0x0D
-* BMI160_LATCH_DUR_2_56_SEC | 0x0E
-* BMI160_LATCHED | 0x0F
-*
-*
-*
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
-*
-*
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_latch_intr(u8 v_latch_intr_u8)
-{
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_latch_intr_u8 <= BMI160_MAX_LATCH_INTR) {
- /* write the latch duration value */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_LATCH__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_LATCH, v_latch_intr_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_LATCH__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief API used to get input enable for interrupt1
- * and interrupt2 pin from the register 0x54
- * @brief interrupt1 - bit 4
- * @brief interrupt2 - bit 5
- *
- * @param v_channel_u8: The value of input enable selection
- * v_channel_u8 | input selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_INPUT_ENABLE
- * 1 | BMI160_INTR2_INPUT_ENABLE
- *
- * @param v_input_en_u8 :
- * The value of input enable of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_INPUT
- * 0x00 | BMI160_OUTPUT
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_input_enable(
-u8 v_channel_u8, u8 *v_input_en_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* read input enable of interrup1 and interrupt2*/
- case BMI160_INTR1_INPUT_ENABLE:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_INPUT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_input_en_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR1_INPUT_ENABLE);
- break;
- case BMI160_INTR2_INPUT_ENABLE:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_INPUT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_input_en_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR2_INPUT_ENABLE);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief API used to set input enable for interrupt1
- * and interrupt2 pin from the register 0x54
- * @brief interrupt1 - bit 4
- * @brief interrupt2 - bit 5
- *
- * @param v_channel_u8: The value of input enable selection
- * v_channel_u8 | input selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_INPUT_ENABLE
- * 1 | BMI160_INTR2_INPUT_ENABLE
- *
- * @param v_input_en_u8 :
- * The value of input enable of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_INPUT
- * 0x00 | BMI160_OUTPUT
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_input_enable(
-u8 v_channel_u8, u8 v_input_en_u8)
-{
-/* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* write input enable of interrup1 and interrupt2*/
- case BMI160_INTR1_INPUT_ENABLE:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_INPUT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR1_INPUT_ENABLE, v_input_en_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR1_INPUT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_INPUT_ENABLE:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_INPUT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR2_INPUT_ENABLE, v_input_en_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR2_INPUT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
-}
-return com_rslt;
-}
- /*!
- * @brief reads the Low g interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 0 in the register 0x55
- * @brief interrupt2 bit 0 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of low_g selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_LOW_G
- * 1 | BMI160_INTR2_MAP_LOW_G
- *
- * @param v_intr_low_g_u8 : The value of low_g enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g(
-u8 v_channel_u8, u8 *v_intr_low_g_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* read the low_g interrupt */
- case BMI160_INTR1_MAP_LOW_G:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_low_g_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_LOW_G);
- break;
- case BMI160_INTR2_MAP_LOW_G:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_low_g_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_LOW_G);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief set the Low g interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 0 in the register 0x55
- * @brief interrupt2 bit 0 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of low_g selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_LOW_G
- * 1 | BMI160_INTR2_MAP_LOW_G
- *
- * @param v_intr_low_g_u8 : The value of low_g enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g(
-u8 v_channel_u8, u8 v_intr_low_g_u8)
-{
-/* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-u8 v_step_cnt_stat_u8 = BMI160_INIT_VALUE;
-u8 v_step_det_stat_u8 = BMI160_INIT_VALUE;
-
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* check the step detector interrupt enable status*/
- com_rslt = bmi160_get_step_detector_enable(&v_step_det_stat_u8);
- /* disable the step detector interrupt */
- if (v_step_det_stat_u8 != BMI160_INIT_VALUE)
- com_rslt += bmi160_set_step_detector_enable(BMI160_INIT_VALUE);
- /* check the step counter interrupt enable status*/
- com_rslt += bmi160_get_step_counter_enable(&v_step_cnt_stat_u8);
- /* disable the step counter interrupt */
- if (v_step_cnt_stat_u8 != BMI160_INIT_VALUE)
- com_rslt += bmi160_set_step_counter_enable(
- BMI160_INIT_VALUE);
- switch (v_channel_u8) {
- /* write the low_g interrupt*/
- case BMI160_INTR1_MAP_LOW_G:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_LOW_G, v_intr_low_g_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_MAP_LOW_G:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_LOW_G, v_intr_low_g_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
-}
-return com_rslt;
-}
-/*!
- * @brief Reads the HIGH g interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 1 in the register 0x55
- * @brief interrupt2 bit 1 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of high_g selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_HIGH_G
- * 1 | BMI160_INTR2_MAP_HIGH_G
- *
- * @param v_intr_high_g_u8 : The value of high_g enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g(
-u8 v_channel_u8, u8 *v_intr_high_g_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the high_g interrupt*/
- switch (v_channel_u8) {
- case BMI160_INTR1_MAP_HIGH_G:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_high_g_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_HIGH_G);
- break;
- case BMI160_INTR2_MAP_HIGH_G:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_high_g_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_HIGH_G);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Write the HIGH g interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 1 in the register 0x55
- * @brief interrupt2 bit 1 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of high_g selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_HIGH_G
- * 1 | BMI160_INTR2_MAP_HIGH_G
- *
- * @param v_intr_high_g_u8 : The value of high_g enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g(
-u8 v_channel_u8, u8 v_intr_high_g_u8)
-{
-/* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* write the high_g interrupt*/
- case BMI160_INTR1_MAP_HIGH_G:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_HIGH_G, v_intr_high_g_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_MAP_HIGH_G:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_HIGH_G, v_intr_high_g_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
-}
-return com_rslt;
-}
-/*!
- * @brief Reads the Any motion interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 2 in the register 0x55
- * @brief interrupt2 bit 2 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of any motion selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_ANY_MOTION
- * 1 | BMI160_INTR2_MAP_ANY_MOTION
- *
- * @param v_intr_any_motion_u8 : The value of any motion enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion(
-u8 v_channel_u8, u8 *v_intr_any_motion_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* read the any motion interrupt */
- case BMI160_INTR1_MAP_ANY_MOTION:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_any_motion_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION);
- break;
- case BMI160_INTR2_MAP_ANY_MOTION:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_any_motion_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Write the Any motion interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 2 in the register 0x55
- * @brief interrupt2 bit 2 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of any motion selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_ANY_MOTION
- * 1 | BMI160_INTR2_MAP_ANY_MOTION
- *
- * @param v_intr_any_motion_u8 : The value of any motion enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion(
-u8 v_channel_u8, u8 v_intr_any_motion_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-u8 sig_mot_stat = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the status of significant motion interrupt */
- com_rslt = bmi160_get_intr_significant_motion_select(&sig_mot_stat);
- /* disable the significant motion interrupt */
- if (sig_mot_stat != BMI160_INIT_VALUE)
- com_rslt += bmi160_set_intr_significant_motion_select(
- BMI160_INIT_VALUE);
- switch (v_channel_u8) {
- /* write the any motion interrupt */
- case BMI160_INTR1_MAP_ANY_MOTION:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION,
- v_intr_any_motion_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_MAP_ANY_MOTION:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION,
- v_intr_any_motion_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
-}
-return com_rslt;
-}
-/*!
- * @brief Reads the No motion interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 3 in the register 0x55
- * @brief interrupt2 bit 3 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of no motion selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_NOMO
- * 1 | BMI160_INTR2_MAP_NOMO
- *
- * @param v_intr_nomotion_u8 : The value of no motion enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_nomotion(
-u8 v_channel_u8, u8 *v_intr_nomotion_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* read the no motion interrupt*/
- case BMI160_INTR1_MAP_NOMO:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_nomotion_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_NOMOTION);
- break;
- case BMI160_INTR2_MAP_NOMO:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_nomotion_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_NOMOTION);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Write the No motion interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 3 in the register 0x55
- * @brief interrupt2 bit 3 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of no motion selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_NOMO
- * 1 | BMI160_INTR2_MAP_NOMO
- *
- * @param v_intr_nomotion_u8 : The value of no motion enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_nomotion(
-u8 v_channel_u8, u8 v_intr_nomotion_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* write the no motion interrupt*/
- case BMI160_INTR1_MAP_NOMO:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_NOMOTION,
- v_intr_nomotion_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_MAP_NOMO:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_NOMOTION,
- v_intr_nomotion_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
-}
-return com_rslt;
-}
-/*!
- * @brief Reads the Double Tap interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 4 in the register 0x55
- * @brief interrupt2 bit 4 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of double tap interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_DOUBLE_TAP
- * 1 | BMI160_INTR2_MAP_DOUBLE_TAP
- *
- * @param v_intr_double_tap_u8 : The value of double tap enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_double_tap(
-u8 v_channel_u8, u8 *v_intr_double_tap_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- case BMI160_INTR1_MAP_DOUBLE_TAP:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_double_tap_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP);
- break;
- case BMI160_INTR2_MAP_DOUBLE_TAP:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_double_tap_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Write the Double Tap interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 4 in the register 0x55
- * @brief interrupt2 bit 4 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of double tap interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_DOUBLE_TAP
- * 1 | BMI160_INTR2_MAP_DOUBLE_TAP
- *
- * @param v_intr_double_tap_u8 : The value of double tap enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_double_tap(
-u8 v_channel_u8, u8 v_intr_double_tap_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* set the double tap interrupt */
- case BMI160_INTR1_MAP_DOUBLE_TAP:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP,
- v_intr_double_tap_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_MAP_DOUBLE_TAP:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP,
- v_intr_double_tap_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
-}
-return com_rslt;
-}
-/*!
- * @brief Reads the Single Tap interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 5 in the register 0x55
- * @brief interrupt2 bit 5 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of single tap interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_SINGLE_TAP
- * 1 | BMI160_INTR2_MAP_SINGLE_TAP
- *
- * @param v_intr_single_tap_u8 : The value of single tap enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_single_tap(
-u8 v_channel_u8, u8 *v_intr_single_tap_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* reads the single tap interrupt*/
- case BMI160_INTR1_MAP_SINGLE_TAP:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_single_tap_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP);
- break;
- case BMI160_INTR2_MAP_SINGLE_TAP:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_single_tap_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Write the Single Tap interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 5 in the register 0x55
- * @brief interrupt2 bit 5 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of single tap interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_SINGLE_TAP
- * 1 | BMI160_INTR2_MAP_SINGLE_TAP
- *
- * @param v_intr_single_tap_u8 : The value of single tap enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_single_tap(
-u8 v_channel_u8, u8 v_intr_single_tap_u8)
-{
-/* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* write the single tap interrupt */
- case BMI160_INTR1_MAP_SINGLE_TAP:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP,
- v_intr_single_tap_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_MAP_SINGLE_TAP:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP,
- v_intr_single_tap_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
-}
-return com_rslt;
-}
-/*!
- * @brief Reads the Orient interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 6 in the register 0x55
- * @brief interrupt2 bit 6 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of orient interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_ORIENT
- * 1 | BMI160_INTR2_MAP_ORIENT
- *
- * @param v_intr_orient_u8 : The value of orient enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient(
-u8 v_channel_u8, u8 *v_intr_orient_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* read the orientation interrupt*/
- case BMI160_INTR1_MAP_ORIENT:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ORIENT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_orient_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_ORIENT);
- break;
- case BMI160_INTR2_MAP_ORIENT:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ORIENT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_orient_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_ORIENT);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Write the Orient interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 6 in the register 0x55
- * @brief interrupt2 bit 6 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of orient interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_ORIENT
- * 1 | BMI160_INTR2_MAP_ORIENT
- *
- * @param v_intr_orient_u8 : The value of orient enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient(
-u8 v_channel_u8, u8 v_intr_orient_u8)
-{
-/* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* write the orientation interrupt*/
- case BMI160_INTR1_MAP_ORIENT:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ORIENT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_ORIENT, v_intr_orient_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_ORIENT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_MAP_ORIENT:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ORIENT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_ORIENT, v_intr_orient_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_ORIENT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
-}
-return com_rslt;
-}
- /*!
- * @brief Reads the Flat interrupt
- * mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 7 in the register 0x55
- * @brief interrupt2 bit 7 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of flat interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_FLAT
- * 1 | BMI160_INTR2_MAP_FLAT
- *
- * @param v_intr_flat_u8 : The value of flat enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat(
-u8 v_channel_u8, u8 *v_intr_flat_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* read the flat interrupt*/
- case BMI160_INTR1_MAP_FLAT:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_FLAT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_flat_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_FLAT);
- break;
- case BMI160_INTR2_MAP_FLAT:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_FLAT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_flat_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_FLAT);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief Write the Flat interrupt
- * mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 7 in the register 0x55
- * @brief interrupt2 bit 7 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of flat interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_FLAT
- * 1 | BMI160_INTR2_MAP_FLAT
- *
- * @param v_intr_flat_u8 : The value of flat enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat(
-u8 v_channel_u8, u8 v_intr_flat_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* write the flat interrupt */
- case BMI160_INTR1_MAP_FLAT:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_0_INTR1_FLAT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_0_INTR1_FLAT,
- v_intr_flat_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_MAP_0_INTR1_FLAT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_MAP_FLAT:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_2_INTR2_FLAT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_2_INTR2_FLAT,
- v_intr_flat_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_MAP_2_INTR2_FLAT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Reads PMU trigger interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56 bit 0 and 4
- * @brief interrupt1 bit 0 in the register 0x56
- * @brief interrupt2 bit 4 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of pmu trigger selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_PMUTRIG
- * 1 | BMI160_INTR2_MAP_PMUTRIG
- *
- * @param v_intr_pmu_trig_u8 : The value of pmu trigger enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_pmu_trig(
-u8 v_channel_u8, u8 *v_intr_pmu_trig_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* read the pmu trigger interrupt*/
- case BMI160_INTR1_MAP_PMUTRIG:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_pmu_trig_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG);
- break;
- case BMI160_INTR2_MAP_PMUTRIG:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_pmu_trig_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Write PMU trigger interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56 bit 0 and 4
- * @brief interrupt1 bit 0 in the register 0x56
- * @brief interrupt2 bit 4 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of pmu trigger selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_PMUTRIG
- * 1 | BMI160_INTR2_MAP_PMUTRIG
- *
- * @param v_intr_pmu_trig_u8 : The value of pmu trigger enable
- * value | trigger enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_pmu_trig(
-u8 v_channel_u8, u8 v_intr_pmu_trig_u8)
-{
-/* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* write the pmu trigger interrupt */
- case BMI160_INTR1_MAP_PMUTRIG:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG,
- v_intr_pmu_trig_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_MAP_PMUTRIG:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG,
- v_intr_pmu_trig_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
-}
-return com_rslt;
-}
-/*!
- * @brief Reads FIFO Full interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56 bit 5 and 1
- * @brief interrupt1 bit 5 in the register 0x56
- * @brief interrupt2 bit 1 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of fifo full interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_FIFO_FULL
- * 1 | BMI160_INTR2_MAP_FIFO_FULL
- *
- * @param v_intr_fifo_full_u8 : The value of fifo full interrupt enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_fifo_full(
-u8 v_channel_u8, u8 *v_intr_fifo_full_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* read the fifo full interrupt */
- case BMI160_INTR1_MAP_FIFO_FULL:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_fifo_full_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL);
- break;
- case BMI160_INTR2_MAP_FIFO_FULL:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_fifo_full_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Write FIFO Full interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56 bit 5 and 1
- * @brief interrupt1 bit 5 in the register 0x56
- * @brief interrupt2 bit 1 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of fifo full interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_FIFO_FULL
- * 1 | BMI160_INTR2_MAP_FIFO_FULL
- *
- * @param v_intr_fifo_full_u8 : The value of fifo full interrupt enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_fifo_full(
-u8 v_channel_u8, u8 v_intr_fifo_full_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* write the fifo full interrupt */
- case BMI160_INTR1_MAP_FIFO_FULL:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL,
- v_intr_fifo_full_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_MAP_FIFO_FULL:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL,
- v_intr_fifo_full_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Reads FIFO Watermark interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56 bit 6 and 2
- * @brief interrupt1 bit 6 in the register 0x56
- * @brief interrupt2 bit 2 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of fifo Watermark interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_FIFO_WM
- * 1 | BMI160_INTR2_MAP_FIFO_WM
- *
- * @param v_intr_fifo_wm_u8 : The value of fifo Watermark interrupt enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_fifo_wm(
-u8 v_channel_u8, u8 *v_intr_fifo_wm_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* read the fifo water mark interrupt */
- case BMI160_INTR1_MAP_FIFO_WM:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_fifo_wm_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM);
- break;
- case BMI160_INTR2_MAP_FIFO_WM:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_fifo_wm_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Write FIFO Watermark interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56 bit 6 and 2
- * @brief interrupt1 bit 6 in the register 0x56
- * @brief interrupt2 bit 2 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of fifo Watermark interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_FIFO_WM
- * 1 | BMI160_INTR2_MAP_FIFO_WM
- *
- * @param v_intr_fifo_wm_u8 : The value of fifo Watermark interrupt enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_fifo_wm(
-u8 v_channel_u8, u8 v_intr_fifo_wm_u8)
-{
-/* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /* write the fifo water mark interrupt */
- case BMI160_INTR1_MAP_FIFO_WM:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM,
- v_intr_fifo_wm_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_MAP_FIFO_WM:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM,
- v_intr_fifo_wm_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr,
- BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Reads Data Ready interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56
- * @brief interrupt1 bit 7 in the register 0x56
- * @brief interrupt2 bit 3 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of data ready interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_DATA_RDY
- * 1 | BMI160_INTR2_MAP_DATA_RDY
- *
- * @param v_intr_data_rdy_u8 : The value of data ready interrupt enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_data_rdy(
-u8 v_channel_u8, u8 *v_intr_data_rdy_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /*Read Data Ready interrupt*/
- case BMI160_INTR1_MAP_DATA_RDY:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY);
- break;
- case BMI160_INTR2_MAP_DATA_RDY:
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_data_rdy_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief Write Data Ready interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56
- * @brief interrupt1 bit 7 in the register 0x56
- * @brief interrupt2 bit 3 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of data ready interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_DATA_RDY
- * 1 | BMI160_INTR2_MAP_DATA_RDY
- *
- * @param v_intr_data_rdy_u8 : The value of data ready interrupt enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_data_rdy(
-u8 v_channel_u8, u8 v_intr_data_rdy_u8)
-{
-/* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- switch (v_channel_u8) {
- /*Write Data Ready interrupt*/
- case BMI160_INTR1_MAP_DATA_RDY:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY,
- v_intr_data_rdy_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- case BMI160_INTR2_MAP_DATA_RDY:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY,
- v_intr_data_rdy_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(p_bmi160->
- dev_addr, BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
-}
-return com_rslt;
-}
- /*!
- * @brief This API reads data source for the interrupt
- * engine for the single and double tap interrupts from the register
- * 0x58 bit 3
- *
- *
- * @param v_tap_source_u8 : The value of the tap source
- * value | Description
- * ----------|-------------------
- * 0x01 | UNFILTER_DATA
- * 0x00 | FILTER_DATA
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_source(u8 *v_tap_source_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the tap source interrupt */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_tap_source_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write data source for the interrupt
- * engine for the single and double tap interrupts from the register
- * 0x58 bit 3
- *
- *
- * @param v_tap_source_u8 : The value of the tap source
- * value | Description
- * ----------|-------------------
- * 0x01 | UNFILTER_DATA
- * 0x00 | FILTER_DATA
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_source(
-u8 v_tap_source_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_tap_source_u8 <= BMI160_MAX_VALUE_SOURCE_INTR) {
- /* write the tap source interrupt */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE,
- v_tap_source_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API Reads Data source for the
- * interrupt engine for the low and high g interrupts
- * from the register 0x58 bit 7
- *
- * @param v_low_high_source_u8 : The value of the tap source
- * value | Description
- * ----------|-------------------
- * 0x01 | UNFILTER_DATA
- * 0x00 | FILTER_DATA
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_high_source(
-u8 *v_low_high_source_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the high_low_g source interrupt */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_low_high_source_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write Data source for the
- * interrupt engine for the low and high g interrupts
- * from the register 0x58 bit 7
- *
- * @param v_low_high_source_u8 : The value of the tap source
- * value | Description
- * ----------|-------------------
- * 0x01 | UNFILTER_DATA
- * 0x00 | FILTER_DATA
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_high_source(
-u8 v_low_high_source_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_low_high_source_u8 <= BMI160_MAX_VALUE_SOURCE_INTR) {
- /* write the high_low_g source interrupt */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE,
- v_low_high_source_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
-}
-return com_rslt;
-}
- /*!
- * @brief This API reads Data source for the
- * interrupt engine for the nomotion and anymotion interrupts
- * from the register 0x59 bit 7
- *
- * @param v_motion_source_u8 :
- * The value of the any/no motion interrupt source
- * value | Description
- * ----------|-------------------
- * 0x01 | UNFILTER_DATA
- * 0x00 | FILTER_DATA
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_motion_source(
-u8 *v_motion_source_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the any/no motion interrupt */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_motion_source_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write Data source for the
- * interrupt engine for the nomotion and anymotion interrupts
- * from the register 0x59 bit 7
- *
- * @param v_motion_source_u8 :
- * The value of the any/no motion interrupt source
- * value | Description
- * ----------|-------------------
- * 0x01 | UNFILTER_DATA
- * 0x00 | FILTER_DATA
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_motion_source(
-u8 v_motion_source_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_motion_source_u8 <= BMI160_MAX_VALUE_SOURCE_INTR) {
- /* write the any/no motion interrupt */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE,
- v_motion_source_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API is used to read the low_g duration from register
- * 0x5A bit 0 to 7
- *
- *
- *
- *
- * @param v_low_g_durn_u8 : The value of low_g duration
- *
- * @note Low_g duration trigger trigger delay according to
- * "(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
- * the default corresponds delay is 20ms
- * @note When low_g data source of interrupt is unfiltered
- * the sensor must not be in low power mode
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_durn(
-u8 *v_low_g_durn_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the low_g interrupt */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_low_g_durn_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN);
- }
- return com_rslt;
-}
- /*!
- * @brief This API is used to write the low_g duration from register
- * 0x5A bit 0 to 7
- *
- *
- *
- *
- * @param v_low_g_durn_u8 : The value of low_g duration
- *
- * @note Low_g duration trigger trigger delay according to
- * "(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
- * the default corresponds delay is 20ms
- * @note When low_g data source of interrupt is unfiltered
- * the sensor must not be in low power mode
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_durn(u8 v_low_g_durn_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write the low_g interrupt */
- com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__REG,
- &v_low_g_durn_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read Threshold
- * definition for the low-g interrupt from the register 0x5B bit 0 to 7
- *
- *
- *
- *
- * @param v_low_g_thres_u8 : The value of low_g threshold
- *
- * @note Low_g interrupt trigger threshold according to
- * (v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
- * 3.91 mg for v_low_g_thres_u8 = 0
- * The threshold range is form 3.91mg to 2.000mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_thres(
-u8 *v_low_g_thres_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read low_g threshold */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_low_g_thres_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to write Threshold
- * definition for the low-g interrupt from the register 0x5B bit 0 to 7
- *
- *
- *
- *
- * @param v_low_g_thres_u8 : The value of low_g threshold
- *
- * @note Low_g interrupt trigger threshold according to
- * (v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
- * 3.91 mg for v_low_g_thres_u8 = 0
- * The threshold range is form 3.91mg to 2.000mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_thres(
-u8 v_low_g_thres_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write low_g threshold */
- com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__REG,
- &v_low_g_thres_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- return com_rslt;
-}
- /*!
- * @brief This API Reads Low-g interrupt hysteresis
- * from the register 0x5C bit 0 to 1
- *
- * @param v_low_hyst_u8 :The value of low_g hysteresis
- *
- * @note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_hyst(
-u8 *v_low_hyst_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read low_g hysteresis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_low_hyst_u8 = BMI160_GET_BITSLICE(
- v_data_u8,
- BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write Low-g interrupt hysteresis
- * from the register 0x5C bit 0 to 1
- *
- * @param v_low_hyst_u8 :The value of low_g hysteresis
- *
- * @note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_hyst(
-u8 v_low_hyst_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write low_g hysteresis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST,
- v_low_hyst_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads Low-g interrupt mode
- * from the register 0x5C bit 2
- *
- * @param v_low_g_mode_u8 : The value of low_g mode
- * Value | Description
- * ----------|-----------------
- * 0 | single-axis
- * 1 | axis-summing
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_mode(u8 *v_low_g_mode_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /*read Low-g interrupt mode*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_low_g_mode_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write Low-g interrupt mode
- * from the register 0x5C bit 2
- *
- * @param v_low_g_mode_u8 : The value of low_g mode
- * Value | Description
- * ----------|-----------------
- * 0 | single-axis
- * 1 | axis-summing
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_mode(
-u8 v_low_g_mode_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_low_g_mode_u8 <= BMI160_MAX_VALUE_LOW_G_MODE) {
- /*write Low-g interrupt mode*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE,
- v_low_g_mode_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads High-g interrupt hysteresis
- * from the register 0x5C bit 6 and 7
- *
- * @param v_high_g_hyst_u8 : The value of high hysteresis
- *
- * @note High_g hysteresis changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | high_g hysteresis
- * ----------------|---------------------
- * 2g | high_hy*125 mg
- * 4g | high_hy*250 mg
- * 8g | high_hy*500 mg
- * 16g | high_hy*1000 mg
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_hyst(
-u8 *v_high_g_hyst_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read high_g hysteresis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_high_g_hyst_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write High-g interrupt hysteresis
- * from the register 0x5C bit 6 and 7
- *
- * @param v_high_g_hyst_u8 : The value of high hysteresis
- *
- * @note High_g hysteresis changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | high_g hysteresis
- * ----------------|---------------------
- * 2g | high_hy*125 mg
- * 4g | high_hy*250 mg
- * 8g | high_hy*500 mg
- * 16g | high_hy*1000 mg
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_hyst(
-u8 v_high_g_hyst_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write high_g hysteresis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST,
- v_high_g_hyst_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
-return com_rslt;
-}
-/*!
- * @brief This API is used to read Delay
- * time definition for the high-g interrupt from the register
- * 0x5D bit 0 to 7
- *
- *
- *
- * @param v_high_g_durn_u8 : The value of high duration
- *
- * @note High_g interrupt delay triggered according to
- * v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_durn(
-u8 *v_high_g_durn_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read high_g duration*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_high_g_durn_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to write Delay
- * time definition for the high-g interrupt from the register
- * 0x5D bit 0 to 7
- *
- *
- *
- * @param v_high_g_durn_u8 : The value of high duration
- *
- * @note High_g interrupt delay triggered according to
- * v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_durn(
-u8 v_high_g_durn_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write high_g duration*/
- com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__REG,
- &v_high_g_durn_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to read Threshold
- * definition for the high-g interrupt from the register 0x5E 0 to 7
- *
- *
- *
- *
- * @param v_high_g_thres_u8 : Pointer holding the value of Threshold
- * @note High_g threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | high_g threshold
- * ----------------|---------------------
- * 2g | v_high_g_thres_u8*7.81 mg
- * 4g | v_high_g_thres_u8*15.63 mg
- * 8g | v_high_g_thres_u8*31.25 mg
- * 16g | v_high_g_thres_u8*62.5 mg
- * @note when v_high_g_thres_u8 = 0
- * accel_range | high_g threshold
- * ----------------|---------------------
- * 2g | 3.91 mg
- * 4g | 7.81 mg
- * 8g | 15.63 mg
- * 16g | 31.25 mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_thres(
-u8 *v_high_g_thres_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_high_g_thres_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to write Threshold
- * definition for the high-g interrupt from the register 0x5E 0 to 7
- *
- *
- *
- *
- * @param v_high_g_thres_u8 : Pointer holding the value of Threshold
- * @note High_g threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | high_g threshold
- * ----------------|---------------------
- * 2g | v_high_g_thres_u8*7.81 mg
- * 4g | v_high_g_thres_u8*15.63 mg
- * 8g | v_high_g_thres_u8*31.25 mg
- * 16g | v_high_g_thres_u8*62.5 mg
- * @note when v_high_g_thres_u8 = 0
- * accel_range | high_g threshold
- * ----------------|---------------------
- * 2g | 3.91 mg
- * 4g | 7.81 mg
- * 8g | 15.63 mg
- * 16g | 31.25 mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_thres(
-u8 v_high_g_thres_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__REG,
- &v_high_g_thres_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads any motion duration
- * from the register 0x5F bit 0 and 1
- *
- * @param v_any_motion_durn_u8 : The value of any motion duration
- *
- * @note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion_durn(
-u8 *v_any_motion_durn_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read any motion duration*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_any_motion_durn_u8 = BMI160_GET_BITSLICE
- (v_data_u8,
- BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write any motion duration
- * from the register 0x5F bit 0 and 1
- *
- * @param v_any_motion_durn_u8 : The value of any motion duration
- *
- * @note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion_durn(
-u8 v_any_motion_durn_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write any motion duration*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN,
- v_any_motion_durn_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API read Slow/no-motion
- * interrupt trigger delay duration from the register 0x5F bit 2 to 7
- *
- * @param v_slow_no_motion_u8 :The value of slow no motion duration
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- * @note
- * @note v_slow_no_motion_u8(5:4)=0b00 ->
- * [v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
- * @note v_slow_no_motion_u8(5:4)=1 ->
- * [v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
- * @note v_slow_no_motion_u8(5)='1' ->
- * [(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_durn(
-u8 *v_slow_no_motion_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read slow no motion duration*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_slow_no_motion_u8 = BMI160_GET_BITSLICE
- (v_data_u8,
- BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN);
- }
-return com_rslt;
-}
- /*!
- * @brief This API write Slow/no-motion
- * interrupt trigger delay duration from the register 0x5F bit 2 to 7
- *
- * @param v_slow_no_motion_u8 :The value of slow no motion duration
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- * @note
- * @note v_slow_no_motion_u8(5:4)=0b00 ->
- * [v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
- * @note v_slow_no_motion_u8(5:4)=1 ->
- * [v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
- * @note v_slow_no_motion_u8(5)='1' ->
- * [(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_durn(
-u8 v_slow_no_motion_u8)
-{
-/* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write slow no motion duration*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE
- (v_data_u8,
- BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN,
- v_slow_no_motion_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
-}
-return com_rslt;
-}
-/*!
- * @brief This API is used to read threshold
- * definition for the any-motion interrupt
- * from the register 0x60 bit 0 to 7
- *
- *
- * @param v_any_motion_thres_u8 : The value of any motion threshold
- *
- * @note any motion threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | any motion threshold
- * ----------------|---------------------
- * 2g | v_any_motion_thres_u8*3.91 mg
- * 4g | v_any_motion_thres_u8*7.81 mg
- * 8g | v_any_motion_thres_u8*15.63 mg
- * 16g | v_any_motion_thres_u8*31.25 mg
- * @note when v_any_motion_thres_u8 = 0
- * accel_range | any motion threshold
- * ----------------|---------------------
- * 2g | 1.95 mg
- * 4g | 3.91 mg
- * 8g | 7.81 mg
- * 16g | 15.63 mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion_thres(
-u8 *v_any_motion_thres_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read any motion threshold*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_any_motion_thres_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to write threshold
- * definition for the any-motion interrupt
- * from the register 0x60 bit 0 to 7
- *
- *
- * @param v_any_motion_thres_u8 : The value of any motion threshold
- *
- * @note any motion threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | any motion threshold
- * ----------------|---------------------
- * 2g | v_any_motion_thres_u8*3.91 mg
- * 4g | v_any_motion_thres_u8*7.81 mg
- * 8g | v_any_motion_thres_u8*15.63 mg
- * 16g | v_any_motion_thres_u8*31.25 mg
- * @note when v_any_motion_thres_u8 = 0
- * accel_range | any motion threshold
- * ----------------|---------------------
- * 2g | 1.95 mg
- * 4g | 3.91 mg
- * 8g | 7.81 mg
- * 16g | 15.63 mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion_thres(
-u8 v_any_motion_thres_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write any motion threshold*/
- com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__REG,
- &v_any_motion_thres_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- return com_rslt;
-}
- /*!
- * @brief This API is used to read threshold
- * for the slow/no-motion interrupt
- * from the register 0x61 bit 0 to 7
- *
- *
- *
- *
- * @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
- * @note slow no motion threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | slow no motion threshold
- * ----------------|---------------------
- * 2g | v_slow_no_motion_thres_u8*3.91 mg
- * 4g | v_slow_no_motion_thres_u8*7.81 mg
- * 8g | v_slow_no_motion_thres_u8*15.63 mg
- * 16g | v_slow_no_motion_thres_u8*31.25 mg
- * @note when v_slow_no_motion_thres_u8 = 0
- * accel_range | slow no motion threshold
- * ----------------|---------------------
- * 2g | 1.95 mg
- * 4g | 3.91 mg
- * 8g | 7.81 mg
- * 16g | 15.63 mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_thres(
-u8 *v_slow_no_motion_thres_u8)
-{
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read slow no motion threshold*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_slow_no_motion_thres_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES);
- }
-return com_rslt;
-}
- /*!
- * @brief This API is used to write threshold
- * for the slow/no-motion interrupt
- * from the register 0x61 bit 0 to 7
- *
- *
- *
- *
- * @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
- * @note slow no motion threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | slow no motion threshold
- * ----------------|---------------------
- * 2g | v_slow_no_motion_thres_u8*3.91 mg
- * 4g | v_slow_no_motion_thres_u8*7.81 mg
- * 8g | v_slow_no_motion_thres_u8*15.63 mg
- * 16g | v_slow_no_motion_thres_u8*31.25 mg
- * @note when v_slow_no_motion_thres_u8 = 0
- * accel_range | slow no motion threshold
- * ----------------|---------------------
- * 2g | 1.95 mg
- * 4g | 3.91 mg
- * 8g | 7.81 mg
- * 16g | 15.63 mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_thres(
-u8 v_slow_no_motion_thres_u8)
-{
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write slow no motion threshold*/
- com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__REG,
- &v_slow_no_motion_thres_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
-return com_rslt;
-}
- /*!
- * @brief This API is used to read
- * the slow/no-motion selection from the register 0x62 bit 0
- *
- *
- *
- *
- * @param v_intr_slow_no_motion_select_u8 :
- * The value of slow/no-motion select
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | SLOW_MOTION
- * 0x01 | NO_MOTION
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_select(
-u8 *v_intr_slow_no_motion_select_u8)
-{
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read slow no motion select*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_slow_no_motion_select_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT);
- }
-return com_rslt;
-}
- /*!
- * @brief This API is used to write
- * the slow/no-motion selection from the register 0x62 bit 0
- *
- *
- *
- *
- * @param v_intr_slow_no_motion_select_u8 :
- * The value of slow/no-motion select
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | SLOW_MOTION
- * 0x01 | NO_MOTION
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_select(
-u8 v_intr_slow_no_motion_select_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
-} else {
-if (v_intr_slow_no_motion_select_u8 <= BMI160_MAX_VALUE_NO_MOTION) {
- /* write slow no motion select*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT,
- v_intr_slow_no_motion_select_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
-} else {
-com_rslt = E_BMI160_OUT_OF_RANGE;
-}
-}
-return com_rslt;
-}
- /*!
- * @brief This API is used to select
- * the significant or any motion interrupt from the register 0x62 bit 1
- *
- *
- *
- *
- * @param v_intr_significant_motion_select_u8 :
- * the value of significant or any motion interrupt selection
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | ANY_MOTION
- * 0x01 | SIGNIFICANT_MOTION
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_select(
-u8 *v_intr_significant_motion_select_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the significant or any motion interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_intr_significant_motion_select_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT);
- }
- return com_rslt;
-}
- /*!
- * @brief This API is used to write, select
- * the significant or any motion interrupt from the register 0x62 bit 1
- *
- *
- *
- *
- * @param v_intr_significant_motion_select_u8 :
- * the value of significant or any motion interrupt selection
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | ANY_MOTION
- * 0x01 | SIGNIFICANT_MOTION
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_select(
-u8 v_intr_significant_motion_select_u8)
-{
-/* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_intr_significant_motion_select_u8 <=
- BMI160_MAX_VALUE_SIGNIFICANT_MOTION) {
- /* write the significant or any motion interrupt*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT,
- v_intr_significant_motion_select_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
-}
-return com_rslt;
-}
- /*!
- * @brief This API is used to read
- * the significant skip time from the register 0x62 bit 2 and 3
- *
- *
- *
- *
- * @param v_int_sig_mot_skip_u8 : the value of significant skip time
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | skip time 1.5 seconds
- * 0x01 | skip time 3 seconds
- * 0x02 | skip time 6 seconds
- * 0x03 | skip time 12 seconds
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_skip(
-u8 *v_int_sig_mot_skip_u8)
-{
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read significant skip time*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_int_sig_mot_skip_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP);
- }
- return com_rslt;
-}
- /*!
- * @brief This API is used to write
- * the significant skip time from the register 0x62 bit 2 and 3
- *
- *
- *
- *
- * @param v_int_sig_mot_skip_u8 : the value of significant skip time
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | skip time 1.5 seconds
- * 0x01 | skip time 3 seconds
- * 0x02 | skip time 6 seconds
- * 0x03 | skip time 12 seconds
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_skip(
-u8 v_int_sig_mot_skip_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_int_sig_mot_skip_u8 <= BMI160_MAX_UNDER_SIG_MOTION) {
- /* write significant skip time*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP,
- v_int_sig_mot_skip_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API is used to read
- * the significant proof time from the register 0x62 bit 4 and 5
- *
- *
- *
- *
- * @param v_significant_motion_proof_u8 :
- * the value of significant proof time
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | proof time 0.25 seconds
- * 0x01 | proof time 0.5 seconds
- * 0x02 | proof time 1 seconds
- * 0x03 | proof time 2 seconds
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_proof(
-u8 *v_significant_motion_proof_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read significant proof time */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_significant_motion_proof_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF);
- }
- return com_rslt;
-}
- /*!
- * @brief This API is used to write
- * the significant proof time from the register 0x62 bit 4 and 5
- *
- *
- *
- *
- * @param v_significant_motion_proof_u8 :
- * the value of significant proof time
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | proof time 0.25 seconds
- * 0x01 | proof time 0.5 seconds
- * 0x02 | proof time 1 seconds
- * 0x03 | proof time 2 seconds
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_proof(
-u8 v_significant_motion_proof_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_significant_motion_proof_u8
- <= BMI160_MAX_UNDER_SIG_MOTION) {
- /* write significant proof time */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF,
- v_significant_motion_proof_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to get the tap duration
- * from the register 0x63 bit 0 to 2
- *
- *
- *
- * @param v_tap_durn_u8 : The value of tap duration
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | BMI160_TAP_DURN_50MS
- * 0x01 | BMI160_TAP_DURN_100MS
- * 0x03 | BMI160_TAP_DURN_150MS
- * 0x04 | BMI160_TAP_DURN_200MS
- * 0x05 | BMI160_TAP_DURN_250MS
- * 0x06 | BMI160_TAP_DURN_375MS
- * 0x07 | BMI160_TAP_DURN_700MS
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_durn(
-u8 *v_tap_durn_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read tap duration*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_tap_durn_u8 = BMI160_GET_BITSLICE(
- v_data_u8,
- BMI160_USER_INTR_TAP_0_INTR_TAP_DURN);
- }
- return com_rslt;
-}
-/*!
- * @brief This API is used to write the tap duration
- * from the register 0x63 bit 0 to 2
- *
- *
- *
- * @param v_tap_durn_u8 : The value of tap duration
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | BMI160_TAP_DURN_50MS
- * 0x01 | BMI160_TAP_DURN_100MS
- * 0x03 | BMI160_TAP_DURN_150MS
- * 0x04 | BMI160_TAP_DURN_200MS
- * 0x05 | BMI160_TAP_DURN_250MS
- * 0x06 | BMI160_TAP_DURN_375MS
- * 0x07 | BMI160_TAP_DURN_700MS
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_durn(
-u8 v_tap_durn_u8)
-{
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_tap_durn_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_tap_durn_u8 <= BMI160_MAX_TAP_TURN) {
- switch (v_tap_durn_u8) {
- case BMI160_TAP_DURN_50MS:
- v_data_tap_durn_u8 = BMI160_TAP_DURN_50MS;
- break;
- case BMI160_TAP_DURN_100MS:
- v_data_tap_durn_u8 = BMI160_TAP_DURN_100MS;
- break;
- case BMI160_TAP_DURN_150MS:
- v_data_tap_durn_u8 = BMI160_TAP_DURN_150MS;
- break;
- case BMI160_TAP_DURN_200MS:
- v_data_tap_durn_u8 = BMI160_TAP_DURN_200MS;
- break;
- case BMI160_TAP_DURN_250MS:
- v_data_tap_durn_u8 = BMI160_TAP_DURN_250MS;
- break;
- case BMI160_TAP_DURN_375MS:
- v_data_tap_durn_u8 = BMI160_TAP_DURN_375MS;
- break;
- case BMI160_TAP_DURN_500MS:
- v_data_tap_durn_u8 = BMI160_TAP_DURN_500MS;
- break;
- case BMI160_TAP_DURN_700MS:
- v_data_tap_durn_u8 = BMI160_TAP_DURN_700MS;
- break;
- default:
- break;
- }
- /* write tap duration*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_TAP_0_INTR_TAP_DURN,
- v_data_tap_durn_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API read the
- * tap shock duration from the register 0x63 bit 2
- *
- * @param v_tap_shock_u8 :The value of tap shock
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | BMI160_TAP_SHOCK_50MS
- * 0x01 | BMI160_TAP_SHOCK_75MS
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_shock(
-u8 *v_tap_shock_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read tap shock duration*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_tap_shock_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write the
- * tap shock duration from the register 0x63 bit 2
- *
- * @param v_tap_shock_u8 :The value of tap shock
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | BMI160_TAP_SHOCK_50MS
- * 0x01 | BMI160_TAP_SHOCK_75MS
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_shock(u8 v_tap_shock_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_tap_shock_u8 <= BMI160_MAX_VALUE_TAP_SHOCK) {
- /* write tap shock duration*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK,
- v_tap_shock_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read
- * tap quiet duration from the register 0x63 bit 7
- *
- *
- * @param v_tap_quiet_u8 : The value of tap quiet
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | BMI160_TAP_QUIET_30MS
- * 0x01 | BMI160_TAP_QUIET_20MS
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_quiet(
-u8 *v_tap_quiet_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read tap quiet duration*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_tap_quiet_u8 = BMI160_GET_BITSLICE(
- v_data_u8,
- BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write
- * tap quiet duration from the register 0x63 bit 7
- *
- *
- * @param v_tap_quiet_u8 : The value of tap quiet
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | BMI160_TAP_QUIET_30MS
- * 0x01 | BMI160_TAP_QUIET_20MS
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_quiet(u8 v_tap_quiet_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_tap_quiet_u8 <= BMI160_MAX_VALUE_TAP_QUIET) {
- /* write tap quiet duration*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET,
- v_tap_quiet_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API read Threshold of the
- * single/double tap interrupt from the register 0x64 bit 0 to 4
- *
- *
- * @param v_tap_thres_u8 : The value of single/double tap threshold
- *
- * @note single/double tap threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | single/double tap threshold
- * ----------------|---------------------
- * 2g | ((v_tap_thres_u8 + 1) * 62.5)mg
- * 4g | ((v_tap_thres_u8 + 1) * 125)mg
- * 8g | ((v_tap_thres_u8 + 1) * 250)mg
- * 16g | ((v_tap_thres_u8 + 1) * 500)mg
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_thres(
-u8 *v_tap_thres_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read tap threshold*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_tap_thres_u8 = BMI160_GET_BITSLICE
- (v_data_u8,
- BMI160_USER_INTR_TAP_1_INTR_TAP_THRES);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write Threshold of the
- * single/double tap interrupt from the register 0x64 bit 0 to 4
- *
- *
- * @param v_tap_thres_u8 : The value of single/double tap threshold
- *
- * @note single/double tap threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | single/double tap threshold
- * ----------------|---------------------
- * 2g | ((v_tap_thres_u8 + 1) * 62.5)mg
- * 4g | ((v_tap_thres_u8 + 1) * 125)mg
- * 8g | ((v_tap_thres_u8 + 1) * 250)mg
- * 16g | ((v_tap_thres_u8 + 1) * 500)mg
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_thres(
-u8 v_tap_thres_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write tap threshold*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_TAP_1_INTR_TAP_THRES,
- v_tap_thres_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API read the threshold for orientation interrupt
- * from the register 0x65 bit 0 and 1
- *
- * @param v_orient_mode_u8 : The value of threshold for orientation
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | symmetrical
- * 0x01 | high-asymmetrical
- * 0x02 | low-asymmetrical
- * 0x03 | symmetrical
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_mode(
-u8 *v_orient_mode_u8)
-{
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read orientation threshold*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_orient_mode_u8 = BMI160_GET_BITSLICE
- (v_data_u8,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write the threshold for orientation interrupt
- * from the register 0x65 bit 0 and 1
- *
- * @param v_orient_mode_u8 : The value of threshold for orientation
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | symmetrical
- * 0x01 | high-asymmetrical
- * 0x02 | low-asymmetrical
- * 0x03 | symmetrical
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_mode(
-u8 v_orient_mode_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_orient_mode_u8 <= BMI160_MAX_ORIENT_MODE) {
- /* write orientation threshold*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE,
- v_orient_mode_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read the orient blocking mode
- * that is used for the generation of the orientation interrupt.
- * from the register 0x65 bit 2 and 3
- *
- * @param v_orient_blocking_u8 : The value of orient blocking mode
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | No blocking
- * 0x01 | Theta blocking or acceleration in any axis > 1.5g
- * 0x02 | Theta blocking or acceleration slope in any axis >
- * - | 0.2g or acceleration in any axis > 1.5g
- * 0x03 | Theta blocking or acceleration slope in any axis >
- * - | 0.4g or acceleration in any axis >
- * - | 1.5g and value of orient is not stable
- * - | for at least 100 ms
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_blocking(
-u8 *v_orient_blocking_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read orient blocking mode*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_orient_blocking_u8 = BMI160_GET_BITSLICE
- (v_data_u8,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write the orient blocking mode
- * that is used for the generation of the orientation interrupt.
- * from the register 0x65 bit 2 and 3
- *
- * @param v_orient_blocking_u8 : The value of orient blocking mode
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | No blocking
- * 0x01 | Theta blocking or acceleration in any axis > 1.5g
- * 0x02 | Theta blocking or acceleration slope in any axis >
- * - | 0.2g or acceleration in any axis > 1.5g
- * 0x03 | Theta blocking or acceleration slope in any axis >
- * - | 0.4g or acceleration in any axis >
- * - | 1.5g and value of orient is not stable
- * - | for at least 100 ms
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_blocking(
-u8 v_orient_blocking_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_orient_blocking_u8 <= BMI160_MAX_ORIENT_BLOCKING) {
- /* write orient blocking mode*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING,
- v_orient_blocking_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
-}
-return com_rslt;
-}
-/*!
- * @brief This API read Orient interrupt
- * hysteresis, from the register 0x64 bit 4 to 7
- *
- *
- *
- * @param v_orient_hyst_u8 : The value of orient hysteresis
- *
- * @note 1 LSB corresponds to 62.5 mg,
- * irrespective of the selected accel range
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_hyst(
-u8 *v_orient_hyst_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read orient hysteresis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_orient_hyst_u8 = BMI160_GET_BITSLICE
- (v_data_u8,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write Orient interrupt
- * hysteresis, from the register 0x64 bit 4 to 7
- *
- *
- *
- * @param v_orient_hyst_u8 : The value of orient hysteresis
- *
- * @note 1 LSB corresponds to 62.5 mg,
- * irrespective of the selected accel range
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_hyst(
-u8 v_orient_hyst_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write orient hysteresis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST,
- v_orient_hyst_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API read Orient
- * blocking angle (0 to 44.8) from the register 0x66 bit 0 to 5
- *
- * @param v_orient_theta_u8 : The value of Orient blocking angle
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_theta(
-u8 *v_orient_theta_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read Orient blocking angle*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_orient_theta_u8 = BMI160_GET_BITSLICE
- (v_data_u8,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write Orient
- * blocking angle (0 to 44.8) from the register 0x66 bit 0 to 5
- *
- * @param v_orient_theta_u8 : The value of Orient blocking angle
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_theta(
-u8 v_orient_theta_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_orient_theta_u8 <= BMI160_MAX_ORIENT_THETA) {
- /* write Orient blocking angle*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA,
- v_orient_theta_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
-}
-return com_rslt;
-}
-/*!
- * @brief This API read orient change
- * of up/down bit from the register 0x66 bit 6
- *
- * @param v_orient_ud_u8 : The value of orient change of up/down
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | Is ignored
- * 0x01 | Generates orientation interrupt
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_ud_enable(
-u8 *v_orient_ud_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read orient up/down enable*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_orient_ud_u8 = BMI160_GET_BITSLICE
- (v_data_u8,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write orient change
- * of up/down bit from the register 0x66 bit 6
- *
- * @param v_orient_ud_u8 : The value of orient change of up/down
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | Is ignored
- * 0x01 | Generates orientation interrupt
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_ud_enable(
-u8 v_orient_ud_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_orient_ud_u8 <= BMI160_MAX_VALUE_ORIENT_UD) {
- /* write orient up/down enable */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE,
- v_orient_ud_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
-}
-return com_rslt;
-}
- /*!
- * @brief This API read orientation axes changes
- * from the register 0x66 bit 7
- *
- * @param v_orient_axes_u8 : The value of orient axes assignment
- * value | Behaviour | Name
- * ----------|--------------------|------
- * 0x00 | x = x, y = y, z = z|orient_ax_noex
- * 0x01 | x = y, y = z, z = x|orient_ax_ex
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_axes_enable(
-u8 *v_orient_axes_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read orientation axes changes */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_orient_axes_u8 = BMI160_GET_BITSLICE
- (v_data_u8,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write orientation axes changes
- * from the register 0x66 bit 7
- *
- * @param v_orient_axes_u8 : The value of orient axes assignment
- * value | Behaviour | Name
- * ----------|--------------------|------
- * 0x00 | x = x, y = y, z = z|orient_ax_noex
- * 0x01 | x = y, y = z, z = x|orient_ax_ex
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_axes_enable(
-u8 v_orient_axes_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_orient_axes_u8 <= BMI160_MAX_VALUE_ORIENT_AXES) {
- /*write orientation axes changes */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX,
- v_orient_axes_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
-}
-return com_rslt;
-}
- /*!
- * @brief This API read Flat angle (0 to 44.8) for flat interrupt
- * from the register 0x67 bit 0 to 5
- *
- * @param v_flat_theta_u8 : The value of flat angle
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_theta(
-u8 *v_flat_theta_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read Flat angle*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_flat_theta_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write Flat angle (0 to 44.8) for flat interrupt
- * from the register 0x67 bit 0 to 5
- *
- * @param v_flat_theta_u8 : The value of flat angle
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_theta(
-u8 v_flat_theta_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_flat_theta_u8 <= BMI160_MAX_FLAT_THETA) {
- /* write Flat angle */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA,
- v_flat_theta_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read Flat interrupt hold time;
- * from the register 0x68 bit 4 and 5
- *
- * @param v_flat_hold_u8 : The value of flat hold time
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | 0ms
- * 0x01 | 512ms
- * 0x01 | 1024ms
- * 0x01 | 2048ms
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_hold(
-u8 *v_flat_hold_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read flat hold time*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_flat_hold_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write Flat interrupt hold time;
- * from the register 0x68 bit 4 and 5
- *
- * @param v_flat_hold_u8 : The value of flat hold time
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | 0ms
- * 0x01 | 512ms
- * 0x01 | 1024ms
- * 0x01 | 2048ms
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_hold(
-u8 v_flat_hold_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_flat_hold_u8 <= BMI160_MAX_FLAT_HOLD) {
- /* write flat hold time*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD,
- v_flat_hold_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read flat interrupt hysteresis
- * from the register 0x68 bit 0 to 3
- *
- * @param v_flat_hyst_u8 : The value of flat hysteresis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_hyst(
-u8 *v_flat_hyst_u8)
-{
- /* variable used to return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the flat hysteresis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_flat_hyst_u8 = BMI160_GET_BITSLICE(
- v_data_u8,
- BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write flat interrupt hysteresis
- * from the register 0x68 bit 0 to 3
- *
- * @param v_flat_hyst_u8 : The value of flat hysteresis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_hyst(
-u8 v_flat_hyst_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_flat_hyst_u8 <= BMI160_MAX_FLAT_HYST) {
- /* read the flat hysteresis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST,
- v_flat_hyst_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API read accel offset compensation
- * target value for z-axis from the register 0x69 bit 0 and 1
- *
- * @param v_foc_accel_z_u8 : the value of accel offset compensation z axis
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_z(u8 *v_foc_accel_z_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the accel offset compensation for z axis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_Z__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_foc_accel_z_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FOC_ACCEL_Z);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write accel offset compensation
- * target value for z-axis from the register 0x69 bit 0 and 1
- *
- * @param v_foc_accel_z_u8 : the value of accel offset compensation z axis
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_z(
-u8 v_foc_accel_z_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write the accel offset compensation for z axis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_Z__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FOC_ACCEL_Z,
- v_foc_accel_z_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_Z__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read accel offset compensation
- * target value for y-axis
- * from the register 0x69 bit 2 and 3
- *
- * @param v_foc_accel_y_u8 : the value of accel offset compensation y axis
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_y(u8 *v_foc_accel_y_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the accel offset compensation for y axis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_Y__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_foc_accel_y_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FOC_ACCEL_Y);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write accel offset compensation
- * target value for y-axis
- * from the register 0x69 bit 2 and 3
- *
- * @param v_foc_accel_y_u8 : the value of accel offset compensation y axis
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x02 | -1g
- * 0x03 | 0g
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_y(u8 v_foc_accel_y_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_foc_accel_y_u8 <= BMI160_MAX_ACCEL_FOC) {
- /* write the accel offset compensation for y axis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_Y__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FOC_ACCEL_Y,
- v_foc_accel_y_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_Y__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read accel offset compensation
- * target value for x-axis is
- * from the register 0x69 bit 4 and 5
- *
- * @param v_foc_accel_x_u8 : the value of accel offset compensation x axis
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x02 | -1g
- * 0x03 | 0g
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_x(u8 *v_foc_accel_x_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the accel offset compensation for x axis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_X__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_foc_accel_x_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FOC_ACCEL_X);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write accel offset compensation
- * target value for x-axis is
- * from the register 0x69 bit 4 and 5
- *
- * @param v_foc_accel_x_u8 : the value of accel offset compensation x axis
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_x(u8 v_foc_accel_x_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_foc_accel_x_u8 <= BMI160_MAX_ACCEL_FOC) {
- /* write the accel offset compensation for x axis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_X__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FOC_ACCEL_X,
- v_foc_accel_x_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_X__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API writes accel fast offset compensation
- * from the register 0x69 bit 0 to 5
- * @brief This API writes each axis individually
- * FOC_X_AXIS - bit 4 and 5
- * FOC_Y_AXIS - bit 2 and 3
- * FOC_Z_AXIS - bit 0 and 1
- *
- * @param v_foc_accel_u8: The value of accel offset compensation
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- * @param v_axis_u8: The value of accel offset axis selection
- * value | axis
- * ----------|-------------------
- * 0 | FOC_X_AXIS
- * 1 | FOC_Y_AXIS
- * 2 | FOC_Z_AXIS
- *
- * @param v_accel_offset_s8: The accel offset value
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_foc_trigger(u8 v_axis_u8,
-u8 v_foc_accel_u8, s8 *v_accel_offset_s8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-s8 v_status_s8 = SUCCESS;
-u8 v_timeout_u8 = BMI160_INIT_VALUE;
-s8 v_foc_accel_offset_x_s8 = BMI160_INIT_VALUE;
-s8 v_foc_accel_offset_y_s8 = BMI160_INIT_VALUE;
-s8 v_foc_accel_offset_z_s8 = BMI160_INIT_VALUE;
-u8 focstatus = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
-} else {
- v_status_s8 = bmi160_set_accel_offset_enable(
- ACCEL_OFFSET_ENABLE);
- if (v_status_s8 == SUCCESS) {
- switch (v_axis_u8) {
- case FOC_X_AXIS:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_X__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FOC_ACCEL_X,
- v_foc_accel_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_X__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
-
- /* trigger the
- FOC need to write
- 0x03 in the register 0x7e*/
- com_rslt +=
- bmi160_set_command_register(
- START_FOC_ACCEL_GYRO);
-
- com_rslt +=
- bmi160_get_foc_rdy(&focstatus);
- if ((com_rslt != SUCCESS) ||
- (focstatus != BMI160_FOC_STAT_HIGH)) {
- while ((com_rslt != SUCCESS) ||
- (focstatus != BMI160_FOC_STAT_HIGH
- && v_timeout_u8 <
- BMI160_MAXIMUM_TIMEOUT)) {
- p_bmi160->delay_msec(
- BMI160_DELAY_SETTLING_TIME);
- com_rslt = bmi160_get_foc_rdy(
- &focstatus);
- v_timeout_u8++;
- }
- }
- if ((com_rslt == SUCCESS) &&
- (focstatus == BMI160_FOC_STAT_HIGH)) {
- com_rslt +=
- bmi160_get_accel_offset_compensation_xaxis(
- &v_foc_accel_offset_x_s8);
- *v_accel_offset_s8 =
- v_foc_accel_offset_x_s8;
- }
- break;
- case FOC_Y_AXIS:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_Y__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FOC_ACCEL_Y,
- v_foc_accel_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_Y__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
-
- /* trigger the FOC
- need to write 0x03
- in the register 0x7e*/
- com_rslt +=
- bmi160_set_command_register(
- START_FOC_ACCEL_GYRO);
-
- com_rslt +=
- bmi160_get_foc_rdy(&focstatus);
- if ((com_rslt != SUCCESS) ||
- (focstatus != BMI160_FOC_STAT_HIGH)) {
- while ((com_rslt != SUCCESS) ||
- (focstatus != BMI160_FOC_STAT_HIGH
- && v_timeout_u8 <
- BMI160_MAXIMUM_TIMEOUT)) {
- p_bmi160->delay_msec(
- BMI160_DELAY_SETTLING_TIME);
- com_rslt = bmi160_get_foc_rdy(
- &focstatus);
- v_timeout_u8++;
- }
- }
- if ((com_rslt == SUCCESS) &&
- (focstatus == BMI160_FOC_STAT_HIGH)) {
- com_rslt +=
- bmi160_get_accel_offset_compensation_yaxis(
- &v_foc_accel_offset_y_s8);
- *v_accel_offset_s8 =
- v_foc_accel_offset_y_s8;
- }
- break;
- case FOC_Z_AXIS:
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_Z__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FOC_ACCEL_Z,
- v_foc_accel_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_Z__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
-
- /* trigger the FOC need to write
- 0x03 in the register 0x7e*/
- com_rslt +=
- bmi160_set_command_register(
- START_FOC_ACCEL_GYRO);
-
- com_rslt +=
- bmi160_get_foc_rdy(&focstatus);
- if ((com_rslt != SUCCESS) ||
- (focstatus != BMI160_FOC_STAT_HIGH)) {
- while ((com_rslt != SUCCESS) ||
- (focstatus != BMI160_FOC_STAT_HIGH
- && v_timeout_u8 <
- BMI160_MAXIMUM_TIMEOUT)) {
- p_bmi160->delay_msec(
- BMI160_DELAY_SETTLING_TIME);
- com_rslt = bmi160_get_foc_rdy(
- &focstatus);
- v_timeout_u8++;
- }
- }
- if ((com_rslt == SUCCESS) &&
- (focstatus == BMI160_FOC_STAT_HIGH)) {
- com_rslt +=
- bmi160_get_accel_offset_compensation_zaxis(
- &v_foc_accel_offset_z_s8);
- *v_accel_offset_s8 =
- v_foc_accel_offset_z_s8;
- }
- break;
- default:
- break;
- }
- } else {
- com_rslt = ERROR;
- }
-}
-return com_rslt;
-}
-/*!
- * @brief This API write fast accel offset compensation
- * it writes all axis together.To the register 0x69 bit 0 to 5
- * FOC_X_AXIS - bit 4 and 5
- * FOC_Y_AXIS - bit 2 and 3
- * FOC_Z_AXIS - bit 0 and 1
- *
- * @param v_foc_accel_x_u8: The value of accel offset x compensation
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- * @param v_foc_accel_y_u8: The value of accel offset y compensation
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- * @param v_foc_accel_z_u8: The value of accel offset z compensation
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- * @param v_accel_off_x_s8: The value of accel offset x axis
- * @param v_accel_off_y_s8: The value of accel offset y axis
- * @param v_accel_off_z_s8: The value of accel offset z axis
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_accel_foc_trigger_xyz(u8 v_foc_accel_x_u8,
-u8 v_foc_accel_y_u8, u8 v_foc_accel_z_u8, s8 *v_accel_off_x_s8,
-s8 *v_accel_off_y_s8, s8 *v_accel_off_z_s8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 focx = BMI160_INIT_VALUE;
-u8 focy = BMI160_INIT_VALUE;
-u8 focz = BMI160_INIT_VALUE;
-s8 v_foc_accel_offset_x_s8 = BMI160_INIT_VALUE;
-s8 v_foc_accel_offset_y_s8 = BMI160_INIT_VALUE;
-s8 v_foc_accel_offset_z_s8 = BMI160_INIT_VALUE;
-u8 v_status_s8 = SUCCESS;
-u8 v_timeout_u8 = BMI160_INIT_VALUE;
-u8 focstatus = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- v_status_s8 = bmi160_set_accel_offset_enable(
- ACCEL_OFFSET_ENABLE);
- if (v_status_s8 == SUCCESS) {
- /* foc x axis*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_X__REG,
- &focx, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- focx = BMI160_SET_BITSLICE(focx,
- BMI160_USER_FOC_ACCEL_X,
- v_foc_accel_x_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_X__REG,
- &focx, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
-
- /* foc y axis*/
- com_rslt +=
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_Y__REG,
- &focy, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- focy = BMI160_SET_BITSLICE(focy,
- BMI160_USER_FOC_ACCEL_Y,
- v_foc_accel_y_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_Y__REG,
- &focy, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
-
- /* foc z axis*/
- com_rslt +=
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_Z__REG,
- &focz, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- focz = BMI160_SET_BITSLICE(focz,
- BMI160_USER_FOC_ACCEL_Z,
- v_foc_accel_z_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_ACCEL_Z__REG,
- &focz, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
-
- /* trigger the FOC need to
- write 0x03 in the register 0x7e*/
- com_rslt += bmi160_set_command_register(
- START_FOC_ACCEL_GYRO);
-
- com_rslt += bmi160_get_foc_rdy(
- &focstatus);
- if ((com_rslt != SUCCESS) ||
- (focstatus != BMI160_FOC_STAT_HIGH)) {
- while ((com_rslt != SUCCESS) ||
- (focstatus != BMI160_FOC_STAT_HIGH
- && v_timeout_u8 <
- BMI160_MAXIMUM_TIMEOUT)) {
- p_bmi160->delay_msec(
- BMI160_DELAY_SETTLING_TIME);
- com_rslt = bmi160_get_foc_rdy(
- &focstatus);
- v_timeout_u8++;
- }
- }
- if ((com_rslt == SUCCESS) &&
- (focstatus == BMI160_GEN_READ_WRITE_DATA_LENGTH)) {
- com_rslt +=
- bmi160_get_accel_offset_compensation_xaxis(
- &v_foc_accel_offset_x_s8);
- *v_accel_off_x_s8 =
- v_foc_accel_offset_x_s8;
- com_rslt +=
- bmi160_get_accel_offset_compensation_yaxis(
- &v_foc_accel_offset_y_s8);
- *v_accel_off_y_s8 =
- v_foc_accel_offset_y_s8;
- com_rslt +=
- bmi160_get_accel_offset_compensation_zaxis(
- &v_foc_accel_offset_z_s8);
- *v_accel_off_z_s8 =
- v_foc_accel_offset_z_s8;
- }
- } else {
- com_rslt = ERROR;
- }
- }
-return com_rslt;
-}
-/*!
- * @brief This API read gyro fast offset enable
- * from the register 0x69 bit 6
- *
- * @param v_foc_gyro_u8 : The value of gyro fast offset enable
- * value | Description
- * ----------|-------------
- * 0 | fast offset compensation disabled
- * 1 | fast offset compensation enabled
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_gyro_enable(
-u8 *v_foc_gyro_u8)
-{
- /* used for return the status of bus communication */
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the gyro fast offset enable*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_FOC_GYRO_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_foc_gyro_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_FOC_GYRO_ENABLE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write gyro fast offset enable
- * from the register 0x69 bit 6
- *
- * @param v_foc_gyro_u8 : The value of gyro fast offset enable
- * value | Description
- * ----------|-------------
- * 0 | fast offset compensation disabled
- * 1 | fast offset compensation enabled
- *
- * @param v_gyro_off_x_s16 : The value of gyro fast offset x axis data
- * @param v_gyro_off_y_s16 : The value of gyro fast offset y axis data
- * @param v_gyro_off_z_s16 : The value of gyro fast offset z axis data
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_gyro_enable(
-u8 v_foc_gyro_u8, s16 *v_gyro_off_x_s16,
-s16 *v_gyro_off_y_s16, s16 *v_gyro_off_z_s16)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-u8 v_status_s8 = SUCCESS;
-u8 v_timeout_u8 = BMI160_INIT_VALUE;
-s16 offsetx = BMI160_INIT_VALUE;
-s16 offsety = BMI160_INIT_VALUE;
-s16 offsetz = BMI160_INIT_VALUE;
-u8 focstatus = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- v_status_s8 = bmi160_set_gyro_offset_enable(
- GYRO_OFFSET_ENABLE);
- if (v_status_s8 == SUCCESS) {
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_FOC_GYRO_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_FOC_GYRO_ENABLE,
- v_foc_gyro_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_FOC_GYRO_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
-
- /* trigger the FOC need to write 0x03
- in the register 0x7e*/
- com_rslt += bmi160_set_command_register
- (START_FOC_ACCEL_GYRO);
-
- com_rslt += bmi160_get_foc_rdy(&focstatus);
- if ((com_rslt != SUCCESS) ||
- (focstatus != BMI160_FOC_STAT_HIGH)) {
- while ((com_rslt != SUCCESS) ||
- (focstatus != BMI160_FOC_STAT_HIGH
- && v_timeout_u8 <
- BMI160_MAXIMUM_TIMEOUT)) {
- p_bmi160->delay_msec(
- BMI160_DELAY_SETTLING_TIME);
- com_rslt = bmi160_get_foc_rdy(
- &focstatus);
- v_timeout_u8++;
- }
- }
- if ((com_rslt == SUCCESS) &&
- (focstatus == BMI160_FOC_STAT_HIGH)) {
- com_rslt +=
- bmi160_get_gyro_offset_compensation_xaxis
- (&offsetx);
- *v_gyro_off_x_s16 = offsetx;
-
- com_rslt +=
- bmi160_get_gyro_offset_compensation_yaxis
- (&offsety);
- *v_gyro_off_y_s16 = offsety;
-
- com_rslt +=
- bmi160_get_gyro_offset_compensation_zaxis(
- &offsetz);
- *v_gyro_off_z_s16 = offsetz;
- }
- } else {
- com_rslt = ERROR;
- }
- }
-return com_rslt;
-}
- /*!
- * @brief This API read NVM program enable
- * from the register 0x6A bit 1
- *
- * @param v_nvm_prog_u8 : The value of NVM program enable
- * Value | Description
- * --------|-------------
- * 0 | DISABLE
- * 1 | ENABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_nvm_prog_enable(
-u8 *v_nvm_prog_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read NVM program*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_CONFIG_NVM_PROG_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_nvm_prog_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_CONFIG_NVM_PROG_ENABLE);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write NVM program enable
- * from the register 0x6A bit 1
- *
- * @param v_nvm_prog_u8 : The value of NVM program enable
- * Value | Description
- * --------|-------------
- * 0 | DISABLE
- * 1 | ENABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_nvm_prog_enable(
-u8 v_nvm_prog_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_nvm_prog_u8 <= BMI160_MAX_VALUE_NVM_PROG) {
- /* write the NVM program*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_CONFIG_NVM_PROG_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_CONFIG_NVM_PROG_ENABLE,
- v_nvm_prog_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_CONFIG_NVM_PROG_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read to configure SPI
- * Interface Mode for primary and OIS interface
- * from the register 0x6B bit 0
- *
- * @param v_spi3_u8 : The value of SPI mode selection
- * Value | Description
- * --------|-------------
- * 0 | SPI 4-wire mode
- * 1 | SPI 3-wire mode
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_spi3(
-u8 *v_spi3_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read SPI mode*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_IF_CONFIG_SPI3__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_spi3_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_IF_CONFIG_SPI3);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write to configure SPI
- * Interface Mode for primary and OIS interface
- * from the register 0x6B bit 0
- *
- * @param v_spi3_u8 : The value of SPI mode selection
- * Value | Description
- * --------|-------------
- * 0 | SPI 4-wire mode
- * 1 | SPI 3-wire mode
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_spi3(
-u8 v_spi3_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_spi3_u8 <= BMI160_MAX_VALUE_SPI3) {
- /* write SPI mode*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_IF_CONFIG_SPI3__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_IF_CONFIG_SPI3,
- v_spi3_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_IF_CONFIG_SPI3__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read I2C Watchdog timer
- * from the register 0x70 bit 1
- *
- * @param v_i2c_wdt_u8 : The value of I2C watch dog timer
- * Value | Description
- * --------|-------------
- * 0 | I2C watchdog v_timeout_u8 after 1 ms
- * 1 | I2C watchdog v_timeout_u8 after 50 ms
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_wdt_select(
-u8 *v_i2c_wdt_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read I2C watch dog timer */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_i2c_wdt_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_IF_CONFIG_I2C_WDT_SELECT);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write I2C Watchdog timer
- * from the register 0x70 bit 1
- *
- * @param v_i2c_wdt_u8 : The value of I2C watch dog timer
- * Value | Description
- * --------|-------------
- * 0 | I2C watchdog v_timeout_u8 after 1 ms
- * 1 | I2C watchdog v_timeout_u8 after 50 ms
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_i2c_wdt_select(
-u8 v_i2c_wdt_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_i2c_wdt_u8 <= BMI160_MAX_VALUE_I2C_WDT) {
- /* write I2C watch dog timer */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_IF_CONFIG_I2C_WDT_SELECT,
- v_i2c_wdt_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read I2C watchdog enable
- * from the register 0x70 bit 2
- *
- * @param v_i2c_wdt_u8 : The value of I2C watchdog enable
- * Value | Description
- * --------|-------------
- * 0 | DISABLE
- * 1 | ENABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_wdt_enable(
-u8 *v_i2c_wdt_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read i2c watch dog eneble */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_i2c_wdt_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write I2C watchdog enable
- * from the register 0x70 bit 2
- *
- * @param v_i2c_wdt_u8 : The value of I2C watchdog enable
- * Value | Description
- * --------|-------------
- * 0 | DISABLE
- * 1 | ENABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_i2c_wdt_enable(
-u8 v_i2c_wdt_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_i2c_wdt_u8 <= BMI160_MAX_VALUE_I2C_WDT) {
- /* write i2c watch dog eneble */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE,
- v_i2c_wdt_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read I2C interface configuration(if) moe
- * from the register 0x6B bit 4 and 5
- *
- * @param v_if_mode_u8 : The value of interface configuration mode
- * Value | Description
- * --------|-------------
- * 0x00 | Primary interface:autoconfig / secondary interface:off
- * 0x01 | Primary interface:I2C / secondary interface:OIS
- * 0x02 | Primary interface:autoconfig/secondary interface:Magnetometer
- * 0x03 | Reserved
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_if_mode(
-u8 *v_if_mode_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read if mode*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_IF_CONFIG_IF_MODE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_if_mode_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_IF_CONFIG_IF_MODE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write I2C interface configuration(if) moe
- * from the register 0x6B bit 4 and 5
- *
- * @param v_if_mode_u8 : The value of interface configuration mode
- * Value | Description
- * --------|-------------
- * 0x00 | Primary interface:autoconfig / secondary interface:off
- * 0x01 | Primary interface:I2C / secondary interface:OIS
- * 0x02 | Primary interface:autoconfig/secondary interface:Magnetometer
- * 0x03 | Reserved
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_if_mode(
-u8 v_if_mode_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_if_mode_u8 <= BMI160_MAX_IF_MODE) {
- /* write if mode*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_IF_CONFIG_IF_MODE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_IF_CONFIG_IF_MODE,
- v_if_mode_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_IF_CONFIG_IF_MODE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read gyro sleep trigger
- * from the register 0x6C bit 0 to 2
- *
- * @param v_gyro_sleep_trigger_u8 : The value of gyro sleep trigger
- * Value | Description
- * --------|-------------
- * 0x00 | nomotion: no / Not INT1 pin: no / INT2 pin: no
- * 0x01 | nomotion: no / Not INT1 pin: no / INT2 pin: yes
- * 0x02 | nomotion: no / Not INT1 pin: yes / INT2 pin: no
- * 0x03 | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
- * 0x04 | nomotion: yes / Not INT1 pin: no / INT2 pin: no
- * 0x05 | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
- * 0x06 | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
- * 0x07 | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_sleep_trigger(
-u8 *v_gyro_sleep_trigger_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read gyro sleep trigger */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_SLEEP_TRIGGER__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_gyro_sleep_trigger_u8 =
- BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_GYRO_SLEEP_TRIGGER);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write gyro sleep trigger
- * from the register 0x6C bit 0 to 2
- *
- * @param v_gyro_sleep_trigger_u8 : The value of gyro sleep trigger
- * Value | Description
- * --------|-------------
- * 0x00 | nomotion: no / Not INT1 pin: no / INT2 pin: no
- * 0x01 | nomotion: no / Not INT1 pin: no / INT2 pin: yes
- * 0x02 | nomotion: no / Not INT1 pin: yes / INT2 pin: no
- * 0x03 | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
- * 0x04 | nomotion: yes / Not INT1 pin: no / INT2 pin: no
- * 0x05 | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
- * 0x06 | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
- * 0x07 | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_sleep_trigger(
-u8 v_gyro_sleep_trigger_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_gyro_sleep_trigger_u8 <= BMI160_MAX_GYRO_SLEEP_TIGGER) {
- /* write gyro sleep trigger */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_SLEEP_TRIGGER__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_GYRO_SLEEP_TRIGGER,
- v_gyro_sleep_trigger_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_SLEEP_TRIGGER__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read gyro wakeup trigger
- * from the register 0x6C bit 3 and 4
- *
- * @param v_gyro_wakeup_trigger_u8 : The value of gyro wakeup trigger
- * Value | Description
- * --------|-------------
- * 0x00 | anymotion: no / INT1 pin: no
- * 0x01 | anymotion: no / INT1 pin: yes
- * 0x02 | anymotion: yes / INT1 pin: no
- * 0x03 | anymotion: yes / INT1 pin: yes
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_wakeup_trigger(
-u8 *v_gyro_wakeup_trigger_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read gyro wakeup trigger */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_WAKEUP_TRIGGER__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_gyro_wakeup_trigger_u8 = BMI160_GET_BITSLICE(
- v_data_u8,
- BMI160_USER_GYRO_WAKEUP_TRIGGER);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write gyro wakeup trigger
- * from the register 0x6C bit 3 and 4
- *
- * @param v_gyro_wakeup_trigger_u8 : The value of gyro wakeup trigger
- * Value | Description
- * --------|-------------
- * 0x00 | anymotion: no / INT1 pin: no
- * 0x01 | anymotion: no / INT1 pin: yes
- * 0x02 | anymotion: yes / INT1 pin: no
- * 0x03 | anymotion: yes / INT1 pin: yes
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_wakeup_trigger(
-u8 v_gyro_wakeup_trigger_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_gyro_wakeup_trigger_u8
- <= BMI160_MAX_GYRO_WAKEUP_TRIGGER) {
- /* write gyro wakeup trigger */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_WAKEUP_TRIGGER__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_GYRO_WAKEUP_TRIGGER,
- v_gyro_wakeup_trigger_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_WAKEUP_TRIGGER__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read Target state for gyro sleep mode
- * from the register 0x6C bit 5
- *
- * @param v_gyro_sleep_state_u8 : The value of gyro sleep mode
- * Value | Description
- * --------|-------------
- * 0x00 | Sleep transition to fast wake up state
- * 0x01 | Sleep transition to suspend state
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_sleep_state(
-u8 *v_gyro_sleep_state_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read gyro sleep state*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_SLEEP_STATE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_gyro_sleep_state_u8 = BMI160_GET_BITSLICE(
- v_data_u8,
- BMI160_USER_GYRO_SLEEP_STATE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write Target state for gyro sleep mode
- * from the register 0x6C bit 5
- *
- * @param v_gyro_sleep_state_u8 : The value of gyro sleep mode
- * Value | Description
- * --------|-------------
- * 0x00 | Sleep transition to fast wake up state
- * 0x01 | Sleep transition to suspend state
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_sleep_state(
-u8 v_gyro_sleep_state_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_gyro_sleep_state_u8 <= BMI160_MAX_VALUE_SLEEP_STATE) {
- /* write gyro sleep state*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_SLEEP_STATE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_GYRO_SLEEP_STATE,
- v_gyro_sleep_state_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_SLEEP_STATE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read gyro wakeup interrupt
- * from the register 0x6C bit 6
- *
- * @param v_gyro_wakeup_intr_u8 : The valeu of gyro wakeup interrupt
- * Value | Description
- * --------|-------------
- * 0x00 | DISABLE
- * 0x01 | ENABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_wakeup_intr(
-u8 *v_gyro_wakeup_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read gyro wakeup interrupt */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_WAKEUP_INTR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_gyro_wakeup_intr_u8 = BMI160_GET_BITSLICE(
- v_data_u8,
- BMI160_USER_GYRO_WAKEUP_INTR);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write gyro wakeup interrupt
- * from the register 0x6C bit 6
- *
- * @param v_gyro_wakeup_intr_u8 : The valeu of gyro wakeup interrupt
- * Value | Description
- * --------|-------------
- * 0x00 | DISABLE
- * 0x01 | ENABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_wakeup_intr(
-u8 v_gyro_wakeup_intr_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_gyro_wakeup_intr_u8 <= BMI160_MAX_VALUE_WAKEUP_INTR) {
- /* write gyro wakeup interrupt */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_WAKEUP_INTR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_GYRO_WAKEUP_INTR,
- v_gyro_wakeup_intr_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_WAKEUP_INTR__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read accel select axis to be self-test
- *
- * @param v_accel_selftest_axis_u8 :
- * The value of accel self test axis selection
- * Value | Description
- * --------|-------------
- * 0x00 | disabled
- * 0x01 | x-axis
- * 0x02 | y-axis
- * 0x03 | z-axis
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_axis(
-u8 *v_accel_selftest_axis_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read accel self test axis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_ACCEL_SELFTEST_AXIS__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_accel_selftest_axis_u8 = BMI160_GET_BITSLICE(
- v_data_u8,
- BMI160_USER_ACCEL_SELFTEST_AXIS);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write accel select axis to be self-test
- *
- * @param v_accel_selftest_axis_u8 :
- * The value of accel self test axis selection
- * Value | Description
- * --------|-------------
- * 0x00 | disabled
- * 0x01 | x-axis
- * 0x02 | y-axis
- * 0x03 | z-axis
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_axis(
-u8 v_accel_selftest_axis_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_accel_selftest_axis_u8
- <= BMI160_MAX_ACCEL_SELFTEST_AXIS) {
- /* write accel self test axis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_ACCEL_SELFTEST_AXIS__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_ACCEL_SELFTEST_AXIS,
- v_accel_selftest_axis_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_ACCEL_SELFTEST_AXIS__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read accel self test axis sign
- * from the register 0x6D bit 2
- *
- * @param v_accel_selftest_sign_u8: The value of accel self test axis sign
- * Value | Description
- * --------|-------------
- * 0x00 | negative
- * 0x01 | positive
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_sign(
-u8 *v_accel_selftest_sign_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read accel self test axis sign*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_ACCEL_SELFTEST_SIGN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_accel_selftest_sign_u8 = BMI160_GET_BITSLICE(
- v_data_u8,
- BMI160_USER_ACCEL_SELFTEST_SIGN);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write accel self test axis sign
- * from the register 0x6D bit 2
- *
- * @param v_accel_selftest_sign_u8: The value of accel self test axis sign
- * Value | Description
- * --------|-------------
- * 0x00 | negative
- * 0x01 | positive
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_sign(
-u8 v_accel_selftest_sign_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_accel_selftest_sign_u8 <=
- BMI160_MAX_VALUE_SELFTEST_SIGN) {
- /* write accel self test axis sign*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_ACCEL_SELFTEST_SIGN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_ACCEL_SELFTEST_SIGN,
- v_accel_selftest_sign_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_ACCEL_SELFTEST_SIGN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read accel self test amplitude
- * from the register 0x6D bit 3
- * select amplitude of the selftest deflection:
- *
- * @param v_accel_selftest_amp_u8 : The value of accel self test amplitude
- * Value | Description
- * --------|-------------
- * 0x00 | LOW
- * 0x01 | HIGH
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_amp(
-u8 *v_accel_selftest_amp_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read self test amplitude*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_SELFTEST_AMP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_accel_selftest_amp_u8 = BMI160_GET_BITSLICE(
- v_data_u8,
- BMI160_USER_SELFTEST_AMP);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write accel self test amplitude
- * from the register 0x6D bit 3
- * select amplitude of the selftest deflection:
- *
- * @param v_accel_selftest_amp_u8 : The value of accel self test amplitude
- * Value | Description
- * --------|-------------
- * 0x00 | LOW
- * 0x01 | HIGH
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_amp(
-u8 v_accel_selftest_amp_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_accel_selftest_amp_u8 <=
- BMI160_MAX_VALUE_SELFTEST_AMP) {
- /* write self test amplitude*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_SELFTEST_AMP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_SELFTEST_AMP,
- v_accel_selftest_amp_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_SELFTEST_AMP__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read gyro self test trigger
- *
- * @param v_gyro_selftest_start_u8: The value of gyro self test start
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_selftest_start(
-u8 *v_gyro_selftest_start_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read gyro self test start */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_SELFTEST_START__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_gyro_selftest_start_u8 = BMI160_GET_BITSLICE(
- v_data_u8,
- BMI160_USER_GYRO_SELFTEST_START);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write gyro self test trigger
- *
- * @param v_gyro_selftest_start_u8: The value of gyro self test start
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_selftest_start(
-u8 v_gyro_selftest_start_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_gyro_selftest_start_u8 <=
- BMI160_MAX_VALUE_SELFTEST_START) {
- /* write gyro self test start */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_SELFTEST_START__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_GYRO_SELFTEST_START,
- v_gyro_selftest_start_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_GYRO_SELFTEST_START__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API read primary interface selection I2C or SPI
- * from the register 0x70 bit 0
- *
- * @param v_spi_enable_u8: The value of Interface selection
- * Value | Description
- * --------|-------------
- * 0x00 | I2C Enable
- * 0x01 | I2C DISBALE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_spi_enable(u8 *v_spi_enable_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read interface section*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_NV_CONFIG_SPI_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_spi_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_NV_CONFIG_SPI_ENABLE);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write primary interface selection I2C or SPI
- * from the register 0x70 bit 0
- *
- * @param v_spi_enable_u8: The value of Interface selection
- * Value | Description
- * --------|-------------
- * 0x00 | I2C Enable
- * 0x01 | I2C DISBALE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_spi_enable(u8 v_spi_enable_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write interface section*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_NV_CONFIG_SPI_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_NV_CONFIG_SPI_ENABLE,
- v_spi_enable_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_NV_CONFIG_SPI_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API read the spare zero
- * form register 0x70 bit 3
- *
- *
- * @param v_spare0_trim_u8: The value of spare zero
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_spare0_trim(u8 *v_spare0_trim_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read spare zero*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_NV_CONFIG_SPARE0__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_spare0_trim_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_NV_CONFIG_SPARE0);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write the spare zero
- * form register 0x70 bit 3
- *
- *
- * @param v_spare0_trim_u8: The value of spare zero
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_spare0_trim(u8 v_spare0_trim_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write spare zero*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_NV_CONFIG_SPARE0__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_NV_CONFIG_SPARE0,
- v_spare0_trim_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_NV_CONFIG_SPARE0__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API read the NVM counter
- * form register 0x70 bit 4 to 7
- *
- *
- * @param v_nvm_counter_u8: The value of NVM counter
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_nvm_counter(u8 *v_nvm_counter_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read NVM counter*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_NV_CONFIG_NVM_COUNTER__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_nvm_counter_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_NV_CONFIG_NVM_COUNTER);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write the NVM counter
- * form register 0x70 bit 4 to 7
- *
- *
- * @param v_nvm_counter_u8: The value of NVM counter
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_nvm_counter(
-u8 v_nvm_counter_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write NVM counter*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_NV_CONFIG_NVM_COUNTER__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_NV_CONFIG_NVM_COUNTER,
- v_nvm_counter_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_NV_CONFIG_NVM_COUNTER__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read accel manual offset compensation of x axis
- * from the register 0x71 bit 0 to 7
- *
- *
- *
- * @param v_accel_off_x_s8:
- * The value of accel manual offset compensation of x axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_xaxis(
-s8 *v_accel_off_x_s8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read accel manual offset compensation of x axis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_0_ACCEL_OFF_X__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_accel_off_x_s8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_OFFSET_0_ACCEL_OFF_X);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write accel manual offset compensation of x axis
- * from the register 0x71 bit 0 to 7
- *
- *
- *
- * @param v_accel_off_x_s8:
- * The value of accel manual offset compensation of x axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_xaxis(
-s8 v_accel_off_x_s8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-u8 v_status_s8 = SUCCESS;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* enable accel offset */
- v_status_s8 = bmi160_set_accel_offset_enable(
- ACCEL_OFFSET_ENABLE);
- if (v_status_s8 == SUCCESS) {
- /* write accel manual offset compensation of x axis*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_0_ACCEL_OFF_X__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(
- v_data_u8,
- BMI160_USER_OFFSET_0_ACCEL_OFF_X,
- v_accel_off_x_s8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_0_ACCEL_OFF_X__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = ERROR;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read accel manual offset compensation of y axis
- * from the register 0x72 bit 0 to 7
- *
- *
- *
- * @param v_accel_off_y_s8:
- * The value of accel manual offset compensation of y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_yaxis(
-s8 *v_accel_off_y_s8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read accel manual offset compensation of y axis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_1_ACCEL_OFF_Y__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_accel_off_y_s8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_OFFSET_1_ACCEL_OFF_Y);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write accel manual offset compensation of y axis
- * from the register 0x72 bit 0 to 7
- *
- *
- *
- * @param v_accel_off_y_s8:
- * The value of accel manual offset compensation of y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_yaxis(
-s8 v_accel_off_y_s8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-u8 v_status_s8 = SUCCESS;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* enable accel offset */
- v_status_s8 = bmi160_set_accel_offset_enable(
- ACCEL_OFFSET_ENABLE);
- if (v_status_s8 == SUCCESS) {
- /* write accel manual offset compensation of y axis*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_1_ACCEL_OFF_Y__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(
- v_data_u8,
- BMI160_USER_OFFSET_1_ACCEL_OFF_Y,
- v_accel_off_y_s8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_1_ACCEL_OFF_Y__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = ERROR;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read accel manual offset compensation of z axis
- * from the register 0x73 bit 0 to 7
- *
- *
- *
- * @param v_accel_off_z_s8:
- * The value of accel manual offset compensation of z axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_zaxis(
-s8 *v_accel_off_z_s8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read accel manual offset compensation of z axis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_2_ACCEL_OFF_Z__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_accel_off_z_s8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_OFFSET_2_ACCEL_OFF_Z);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write accel manual offset compensation of z axis
- * from the register 0x73 bit 0 to 7
- *
- *
- *
- * @param v_accel_off_z_s8:
- * The value of accel manual offset compensation of z axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_zaxis(
-s8 v_accel_off_z_s8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- u8 v_status_s8 = SUCCESS;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* enable accel offset */
- v_status_s8 = bmi160_set_accel_offset_enable(
- ACCEL_OFFSET_ENABLE);
- if (v_status_s8 == SUCCESS) {
- /* write accel manual offset
- compensation of z axis*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_2_ACCEL_OFF_Z__REG,
- &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_OFFSET_2_ACCEL_OFF_Z,
- v_accel_off_z_s8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_2_ACCEL_OFF_Z__REG,
- &v_data_u8,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = ERROR;
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read gyro manual offset compensation of x axis
- * from the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
- *
- *
- *
- * @param v_gyro_off_x_s16:
- * The value of gyro manual offset compensation of x axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_xaxis(
-s16 *v_gyro_off_x_s16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data1_u8r = BMI160_INIT_VALUE;
- u8 v_data2_u8r = BMI160_INIT_VALUE;
- s16 v_data3_u8r, v_data4_u8r = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read gyro offset x*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_3_GYRO_OFF_X__REG,
- &v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data1_u8r = BMI160_GET_BITSLICE(v_data1_u8r,
- BMI160_USER_OFFSET_3_GYRO_OFF_X);
- com_rslt += p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_GYRO_OFF_X__REG,
- &v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data2_u8r = BMI160_GET_BITSLICE(v_data2_u8r,
- BMI160_USER_OFFSET_6_GYRO_OFF_X);
- v_data3_u8r = v_data2_u8r
- << BMI160_SHIFT_BIT_POSITION_BY_14_BITS;
- v_data4_u8r = v_data1_u8r
- << BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
- v_data3_u8r = v_data3_u8r | v_data4_u8r;
- *v_gyro_off_x_s16 = v_data3_u8r
- >> BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
- }
- return com_rslt;
-}
-/*!
- * @brief This API write gyro manual offset compensation of x axis
- * from the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
- *
- *
- *
- * @param v_gyro_off_x_s16:
- * The value of gyro manual offset compensation of x axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_xaxis(
-s16 v_gyro_off_x_s16)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data1_u8r, v_data2_u8r = BMI160_INIT_VALUE;
-u16 v_data3_u8r = BMI160_INIT_VALUE;
-u8 v_status_s8 = SUCCESS;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write gyro offset x*/
- v_status_s8 = bmi160_set_gyro_offset_enable(
- GYRO_OFFSET_ENABLE);
- if (v_status_s8 == SUCCESS) {
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_3_GYRO_OFF_X__REG,
- &v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data1_u8r =
- ((s8) (v_gyro_off_x_s16 &
- BMI160_GYRO_MANUAL_OFFSET_0_7));
- v_data2_u8r = BMI160_SET_BITSLICE(
- v_data2_u8r,
- BMI160_USER_OFFSET_3_GYRO_OFF_X,
- v_data1_u8r);
- /* write 0x74 bit 0 to 7*/
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_3_GYRO_OFF_X__REG,
- &v_data2_u8r,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
-
- com_rslt += p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_GYRO_OFF_X__REG,
- &v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data3_u8r =
- (u16) (v_gyro_off_x_s16 &
- BMI160_GYRO_MANUAL_OFFSET_8_9);
- v_data1_u8r = (u8)(v_data3_u8r
- >> BMI160_SHIFT_BIT_POSITION_BY_08_BITS);
- v_data2_u8r = BMI160_SET_BITSLICE(
- v_data2_u8r,
- BMI160_USER_OFFSET_6_GYRO_OFF_X,
- v_data1_u8r);
- /* write 0x77 bit 0 and 1*/
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_GYRO_OFF_X__REG,
- &v_data2_u8r,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- return ERROR;
- }
- }
-return com_rslt;
-}
-/*!
- * @brief This API read gyro manual offset compensation of y axis
- * from the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
- *
- *
- *
- * @param v_gyro_off_y_s16:
- * The value of gyro manual offset compensation of y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_yaxis(
-s16 *v_gyro_off_y_s16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data1_u8r = BMI160_INIT_VALUE;
- u8 v_data2_u8r = BMI160_INIT_VALUE;
- s16 v_data3_u8r, v_data4_u8r = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read gyro offset y*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_4_GYRO_OFF_Y__REG,
- &v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data1_u8r = BMI160_GET_BITSLICE(v_data1_u8r,
- BMI160_USER_OFFSET_4_GYRO_OFF_Y);
- com_rslt += p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_GYRO_OFF_Y__REG,
- &v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data2_u8r = BMI160_GET_BITSLICE(v_data2_u8r,
- BMI160_USER_OFFSET_6_GYRO_OFF_Y);
- v_data3_u8r = v_data2_u8r
- << BMI160_SHIFT_BIT_POSITION_BY_14_BITS;
- v_data4_u8r = v_data1_u8r
- << BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
- v_data3_u8r = v_data3_u8r | v_data4_u8r;
- *v_gyro_off_y_s16 = v_data3_u8r
- >> BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
- }
- return com_rslt;
-}
-/*!
- * @brief This API write gyro manual offset compensation of y axis
- * from the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
- *
- *
- *
- * @param v_gyro_off_y_s16:
- * The value of gyro manual offset compensation of y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_yaxis(
-s16 v_gyro_off_y_s16)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data1_u8r, v_data2_u8r = BMI160_INIT_VALUE;
-u16 v_data3_u8r = BMI160_INIT_VALUE;
-u8 v_status_s8 = SUCCESS;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* enable gyro offset bit */
- v_status_s8 = bmi160_set_gyro_offset_enable(
- GYRO_OFFSET_ENABLE);
- /* write gyro offset y*/
- if (v_status_s8 == SUCCESS) {
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_OFFSET_4_GYRO_OFF_Y__REG,
- &v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data1_u8r =
- ((s8) (v_gyro_off_y_s16 &
- BMI160_GYRO_MANUAL_OFFSET_0_7));
- v_data2_u8r = BMI160_SET_BITSLICE(
- v_data2_u8r,
- BMI160_USER_OFFSET_4_GYRO_OFF_Y,
- v_data1_u8r);
- /* write 0x75 bit 0 to 7*/
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_OFFSET_4_GYRO_OFF_Y__REG,
- &v_data2_u8r,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
-
- com_rslt += p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_GYRO_OFF_Y__REG,
- &v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data3_u8r =
- (u16) (v_gyro_off_y_s16 &
- BMI160_GYRO_MANUAL_OFFSET_8_9);
- v_data1_u8r = (u8)(v_data3_u8r
- >> BMI160_SHIFT_BIT_POSITION_BY_08_BITS);
- v_data2_u8r = BMI160_SET_BITSLICE(
- v_data2_u8r,
- BMI160_USER_OFFSET_6_GYRO_OFF_Y,
- v_data1_u8r);
- /* write 0x77 bit 2 and 3*/
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_GYRO_OFF_Y__REG,
- &v_data2_u8r,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- return ERROR;
- }
- }
-return com_rslt;
-}
-/*!
- * @brief This API read gyro manual offset compensation of z axis
- * from the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
- *
- *
- *
- * @param v_gyro_off_z_s16:
- * The value of gyro manual offset compensation of z axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_zaxis(
-s16 *v_gyro_off_z_s16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data1_u8r = BMI160_INIT_VALUE;
- u8 v_data2_u8r = BMI160_INIT_VALUE;
- s16 v_data3_u8r, v_data4_u8r = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read gyro manual offset z axis*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_OFFSET_5_GYRO_OFF_Z__REG,
- &v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data1_u8r = BMI160_GET_BITSLICE
- (v_data1_u8r,
- BMI160_USER_OFFSET_5_GYRO_OFF_Z);
- com_rslt +=
- p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_GYRO_OFF_Z__REG,
- &v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data2_u8r = BMI160_GET_BITSLICE(
- v_data2_u8r,
- BMI160_USER_OFFSET_6_GYRO_OFF_Z);
- v_data3_u8r = v_data2_u8r
- << BMI160_SHIFT_BIT_POSITION_BY_14_BITS;
- v_data4_u8r = v_data1_u8r
- << BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
- v_data3_u8r = v_data3_u8r | v_data4_u8r;
- *v_gyro_off_z_s16 = v_data3_u8r
- >> BMI160_SHIFT_BIT_POSITION_BY_06_BITS;
- }
- return com_rslt;
-}
-/*!
- * @brief This API write gyro manual offset compensation of z axis
- * from the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
- *
- *
- *
- * @param v_gyro_off_z_s16:
- * The value of gyro manual offset compensation of z axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_zaxis(
-s16 v_gyro_off_z_s16)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data1_u8r, v_data2_u8r = BMI160_INIT_VALUE;
-u16 v_data3_u8r = BMI160_INIT_VALUE;
-u8 v_status_s8 = SUCCESS;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* enable gyro offset*/
- v_status_s8 = bmi160_set_gyro_offset_enable(
- GYRO_OFFSET_ENABLE);
- /* write gyro manual offset z axis*/
- if (v_status_s8 == SUCCESS) {
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_OFFSET_5_GYRO_OFF_Z__REG,
- &v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data1_u8r =
- ((u8) (v_gyro_off_z_s16 &
- BMI160_GYRO_MANUAL_OFFSET_0_7));
- v_data2_u8r = BMI160_SET_BITSLICE(
- v_data2_u8r,
- BMI160_USER_OFFSET_5_GYRO_OFF_Z,
- v_data1_u8r);
- /* write 0x76 bit 0 to 7*/
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_OFFSET_5_GYRO_OFF_Z__REG,
- &v_data2_u8r,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
-
- com_rslt += p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_GYRO_OFF_Z__REG,
- &v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data3_u8r =
- (u16) (v_gyro_off_z_s16 &
- BMI160_GYRO_MANUAL_OFFSET_8_9);
- v_data1_u8r = (u8)(v_data3_u8r
- >> BMI160_SHIFT_BIT_POSITION_BY_08_BITS);
- v_data2_u8r = BMI160_SET_BITSLICE(
- v_data2_u8r,
- BMI160_USER_OFFSET_6_GYRO_OFF_Z,
- v_data1_u8r);
- /* write 0x77 bit 4 and 5*/
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_GYRO_OFF_Z__REG,
- &v_data2_u8r,
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- return ERROR;
- }
- }
-return com_rslt;
-}
-/*!
- * @brief This API read the accel offset enable bit
- * from the register 0x77 bit 6
- *
- *
- *
- * @param v_accel_off_enable_u8: The value of accel offset enable
- * value | Description
- * ----------|--------------
- * 0x01 | ENABLE
- * 0x00 | DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_enable(
-u8 *v_accel_off_enable_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read accel offset enable */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_accel_off_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write the accel offset enable bit
- * from the register 0x77 bit 6
- *
- *
- *
- * @param v_accel_off_enable_u8: The value of accel offset enable
- * value | Description
- * ----------|--------------
- * 0x01 | ENABLE
- * 0x00 | DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_enable(
-u8 v_accel_off_enable_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write accel offset enable */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE,
- v_accel_off_enable_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API read the accel offset enable bit
- * from the register 0x77 bit 7
- *
- *
- *
- * @param v_gyro_off_enable_u8: The value of gyro offset enable
- * value | Description
- * ----------|--------------
- * 0x01 | ENABLE
- * 0x00 | DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_enable(
-u8 *v_gyro_off_enable_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read gyro offset*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_GYRO_OFF_EN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_gyro_off_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_OFFSET_6_GYRO_OFF_EN);
- }
- return com_rslt;
-}
-/*!
- * @brief This API write the accel offset enable bit
- * from the register 0x77 bit 7
- *
- *
- *
- * @param v_gyro_off_enable_u8: The value of gyro offset enable
- * value | Description
- * ----------|--------------
- * 0x01 | ENABLE
- * 0x00 | DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_enable(
-u8 v_gyro_off_enable_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write gyro offset*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_GYRO_OFF_EN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 = BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_OFFSET_6_GYRO_OFF_EN,
- v_gyro_off_enable_u8);
- com_rslt += p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_OFFSET_6_GYRO_OFF_EN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This API reads step counter value
- * form the register 0x78 and 0x79
- *
- *
- *
- *
- * @param v_step_cnt_s16 : The value of step counter
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_step_count(s16 *v_step_cnt_s16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* array having the step counter LSB and MSB data
- v_data_u8[0] - LSB
- v_data_u8[1] - MSB*/
- u8 a_data_u8r[BMI160_STEP_COUNT_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE};
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read step counter */
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_STEP_COUNT_LSB__REG,
- a_data_u8r, BMI160_STEP_COUNTER_LENGTH);
-
- *v_step_cnt_s16 = (s16)
- ((((s32)((s8)a_data_u8r[BMI160_STEP_COUNT_MSB_BYTE]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (a_data_u8r[BMI160_STEP_COUNT_LSB_BYTE]));
- }
- return com_rslt;
-}
- /*!
- * @brief This API Reads
- * step counter configuration
- * from the register 0x7A bit 0 to 7
- * and from the register 0x7B bit 0 to 2 and 4 to 7
- *
- *
- * @param v_step_config_u16 : The value of step configuration
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_config(
-u16 *v_step_config_u16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data1_u8r = BMI160_INIT_VALUE;
- u8 v_data2_u8r = BMI160_INIT_VALUE;
- u16 v_data3_u8r = BMI160_INIT_VALUE;
- /* Read the 0 to 7 bit*/
- com_rslt =
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_STEP_CONFIG_ZERO__REG,
- &v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* Read the 8 to 10 bit*/
- com_rslt +=
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_STEP_CONFIG_ONE_CNF1__REG,
- &v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data2_u8r = BMI160_GET_BITSLICE(v_data2_u8r,
- BMI160_USER_STEP_CONFIG_ONE_CNF1);
- v_data3_u8r = ((u16)((((u32)
- ((u8)v_data2_u8r))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (v_data1_u8r)));
- /* Read the 11 to 14 bit*/
- com_rslt +=
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_STEP_CONFIG_ONE_CNF2__REG,
- &v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data1_u8r = BMI160_GET_BITSLICE(v_data1_u8r,
- BMI160_USER_STEP_CONFIG_ONE_CNF2);
- *v_step_config_u16 = ((u16)((((u32)
- ((u8)v_data1_u8r))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | (v_data3_u8r)));
-
- return com_rslt;
-}
- /*!
- * @brief This API write
- * step counter configuration
- * from the register 0x7A bit 0 to 7
- * and from the register 0x7B bit 0 to 2 and 4 to 7
- *
- *
- * @param v_step_config_u16 :
- * the value of Enable step configuration
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_config(
-u16 v_step_config_u16)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data1_u8r = BMI160_INIT_VALUE;
- u8 v_data2_u8r = BMI160_INIT_VALUE;
- u16 v_data3_u16 = BMI160_INIT_VALUE;
-
- /* write the 0 to 7 bit*/
- v_data1_u8r = (u8)(v_step_config_u16 &
- BMI160_STEP_CONFIG_0_7);
- p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_STEP_CONFIG_ZERO__REG,
- &v_data1_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* write the 8 to 10 bit*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_STEP_CONFIG_ONE_CNF1__REG,
- &v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data3_u16 = (u16) (v_step_config_u16 &
- BMI160_STEP_CONFIG_8_10);
- v_data1_u8r = (u8)(v_data3_u16
- >> BMI160_SHIFT_BIT_POSITION_BY_08_BITS);
- v_data2_u8r = BMI160_SET_BITSLICE(v_data2_u8r,
- BMI160_USER_STEP_CONFIG_ONE_CNF1, v_data1_u8r);
- p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_STEP_CONFIG_ONE_CNF1__REG,
- &v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- /* write the 11 to 14 bit*/
- com_rslt += p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_STEP_CONFIG_ONE_CNF2__REG,
- &v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data3_u16 = (u16) (v_step_config_u16 &
- BMI160_STEP_CONFIG_11_14);
- v_data1_u8r = (u8)(v_data3_u16
- >> BMI160_SHIFT_BIT_POSITION_BY_12_BITS);
- v_data2_u8r = BMI160_SET_BITSLICE(v_data2_u8r,
- BMI160_USER_STEP_CONFIG_ONE_CNF2, v_data1_u8r);
- p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_STEP_CONFIG_ONE_CNF2__REG,
- &v_data2_u8r, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
-
- return com_rslt;
-}
- /*!
- * @brief This API read enable step counter
- * from the register 0x7B bit 3
- *
- *
- * @param v_step_counter_u8 : The value of step counter enable
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_counter_enable(
-u8 *v_step_counter_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the step counter */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_step_counter_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write enable step counter
- * from the register 0x7B bit 3
- *
- *
- * @param v_step_counter_u8 : The value of step counter enable
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_counter_enable(u8 v_step_counter_u8)
-{
-/* variable used for return the status of communication result*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-/* check the p_bmi160 structure as NULL*/
-if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
-} else {
- if (v_step_counter_u8 <= BMI160_MAX_GYRO_STEP_COUNTER) {
- /* write the step counter */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE,
- v_step_counter_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
-}
- return com_rslt;
-}
- /*!
- * @brief This API set Step counter modes
- *
- *
- * @param v_step_mode_u8 : The value of step counter mode
- * value | mode
- * ----------|-----------
- * 0 | BMI160_STEP_NORMAL_MODE
- * 1 | BMI160_STEP_SENSITIVE_MODE
- * 2 | BMI160_STEP_ROBUST_MODE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_mode(u8 v_step_mode_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-
- switch (v_step_mode_u8) {
- case BMI160_STEP_NORMAL_MODE:
- com_rslt = bmi160_set_step_config(
- STEP_CONFIG_NORMAL);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- break;
- case BMI160_STEP_SENSITIVE_MODE:
- com_rslt = bmi160_set_step_config(
- STEP_CONFIG_SENSITIVE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- break;
- case BMI160_STEP_ROBUST_MODE:
- com_rslt = bmi160_set_step_config(
- STEP_CONFIG_ROBUST);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
-
- return com_rslt;
-}
-/*!
- * @brief This API used to trigger the signification motion
- * interrupt
- *
- *
- * @param v_significant_u8 : The value of interrupt selection
- * value | interrupt
- * ----------|-----------
- * 0 | BMI160_MAP_INTR1
- * 1 | BMI160_MAP_INTR2
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_map_significant_motion_intr(
-u8 v_significant_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_sig_motion_u8 = BMI160_INIT_VALUE;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- u8 v_any_motion_intr1_stat_u8 = BMI160_ENABLE_ANY_MOTION_INTR1;
- u8 v_any_motion_intr2_stat_u8 = BMI160_ENABLE_ANY_MOTION_INTR2;
- u8 v_any_motion_axis_stat_u8 = BMI160_ENABLE_ANY_MOTION_AXIS;
- /* enable the significant motion interrupt */
- com_rslt = bmi160_get_intr_significant_motion_select(&v_sig_motion_u8);
- if (v_sig_motion_u8 != BMI160_SIG_MOTION_STAT_HIGH)
- com_rslt += bmi160_set_intr_significant_motion_select(
- BMI160_SIG_MOTION_INTR_ENABLE);
- switch (v_significant_u8) {
- case BMI160_MAP_INTR1:
- /* interrupt */
- com_rslt += bmi160_read_reg(
- BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data_u8 |= v_any_motion_intr1_stat_u8;
- /* map the signification interrupt to any-motion interrupt1*/
- com_rslt += bmi160_write_reg(
- BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* axis*/
- com_rslt = bmi160_read_reg(BMI160_USER_INTR_ENABLE_0_ADDR,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data_u8 |= v_any_motion_axis_stat_u8;
- com_rslt += bmi160_write_reg(
- BMI160_USER_INTR_ENABLE_0_ADDR,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- break;
-
- case BMI160_MAP_INTR2:
- /* map the signification interrupt to any-motion interrupt2*/
- com_rslt += bmi160_read_reg(
- BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data_u8 |= v_any_motion_intr2_stat_u8;
- com_rslt += bmi160_write_reg(
- BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* axis*/
- com_rslt = bmi160_read_reg(BMI160_USER_INTR_ENABLE_0_ADDR,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data_u8 |= v_any_motion_axis_stat_u8;
- com_rslt += bmi160_write_reg(
- BMI160_USER_INTR_ENABLE_0_ADDR,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- break;
-
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
-
- }
- return com_rslt;
-}
-/*!
- * @brief This API used to trigger the step detector
- * interrupt
- *
- *
- * @param v_step_detector_u8 : The value of interrupt selection
- * value | interrupt
- * ----------|-----------
- * 0 | BMI160_MAP_INTR1
- * 1 | BMI160_MAP_INTR2
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_map_step_detector_intr(
-u8 v_step_detector_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_step_det_u8 = BMI160_INIT_VALUE;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- u8 v_low_g_intr_u81_stat_u8 = BMI160_LOW_G_INTR_STAT;
- u8 v_low_g_intr_u82_stat_u8 = BMI160_LOW_G_INTR_STAT;
- u8 v_low_g_enable_u8 = BMI160_ENABLE_LOW_G;
- /* read the v_status_s8 of step detector interrupt*/
- com_rslt = bmi160_get_step_detector_enable(&v_step_det_u8);
- if (v_step_det_u8 != BMI160_STEP_DET_STAT_HIGH)
- com_rslt += bmi160_set_step_detector_enable(
- BMI160_STEP_DETECT_INTR_ENABLE);
- switch (v_step_detector_u8) {
- case BMI160_MAP_INTR1:
- com_rslt += bmi160_read_reg(
- BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data_u8 |= v_low_g_intr_u81_stat_u8;
- /* map the step detector interrupt
- to Low-g interrupt 1*/
- com_rslt += bmi160_write_reg(
- BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* Enable the Low-g interrupt*/
- com_rslt = bmi160_read_reg(
- BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data_u8 |= v_low_g_enable_u8;
- com_rslt += bmi160_write_reg(
- BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- break;
- case BMI160_MAP_INTR2:
- /* map the step detector interrupt
- to Low-g interrupt 1*/
- com_rslt += bmi160_read_reg(
- BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data_u8 |= v_low_g_intr_u82_stat_u8;
-
- com_rslt += bmi160_write_reg(
- BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* Enable the Low-g interrupt*/
- com_rslt = bmi160_read_reg(
- BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_data_u8 |= v_low_g_enable_u8;
- com_rslt += bmi160_write_reg(
- BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- return com_rslt;
-}
- /*!
- * @brief This API used to clear the step counter interrupt
- * interrupt
- *
- *
- * @param : None
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_clear_step_counter(void)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* clear the step counter*/
- com_rslt = bmi160_set_command_register(RESET_STEP_COUNTER);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-
- return com_rslt;
-
-}
- /*!
- * @brief This API writes value to the register 0x7E bit 0 to 7
- *
- *
- * @param v_command_reg_u8 : The value to write command register
- * value | Description
- * ---------|--------------------------------------------------------
- * 0x00 | Reserved
- * 0x03 | Starts fast offset calibration for the accel and gyro
- * 0x10 | Sets the PMU mode for the Accelerometer to suspend
- * 0x11 | Sets the PMU mode for the Accelerometer to normal
- * 0x12 | Sets the PMU mode for the Accelerometer Lowpower
- * 0x14 | Sets the PMU mode for the Gyroscope to suspend
- * 0x15 | Sets the PMU mode for the Gyroscope to normal
- * 0x16 | Reserved
- * 0x17 | Sets the PMU mode for the Gyroscope to fast start-up
- * 0x18 | Sets the PMU mode for the Magnetometer to suspend
- * 0x19 | Sets the PMU mode for the Magnetometer to normal
- * 0x1A | Sets the PMU mode for the Magnetometer to Lowpower
- * 0xB0 | Clears all data in the FIFO
- * 0xB1 | Resets the interrupt engine
- * 0xB2 | step_cnt_clr Clears the step counter
- * 0xB6 | Triggers a reset
- * 0x37 | See extmode_en_last
- * 0x9A | See extmode_en_last
- * 0xC0 | Enable the extended mode
- * 0xC4 | Erase NVM cell
- * 0xC8 | Load NVM cell
- * 0xF0 | Reset acceleration data path
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_command_register(u8 v_command_reg_u8)
-{
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write command register */
- com_rslt = p_bmi160->BMI160_BUS_WRITE_FUNC(
- p_bmi160->dev_addr,
- BMI160_CMD_COMMANDS__REG,
- &v_command_reg_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- return com_rslt;
-}
- /*!
- * @brief This API read target page from the register 0x7F bit 4 and 5
- *
- * @param v_target_page_u8: The value of target page
- * value | page
- * ---------|-----------
- * 0 | User data/configure page
- * 1 | Chip level trim/test page
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_target_page(u8 *v_target_page_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the page*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_CMD_TARGET_PAGE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_target_page_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_CMD_TARGET_PAGE);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write target page from the register 0x7F bit 4 and 5
- *
- * @param v_target_page_u8: The value of target page
- * value | page
- * ---------|-----------
- * 0 | User data/configure page
- * 1 | Chip level trim/test page
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_target_page(u8 v_target_page_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_target_page_u8 <= BMI160_MAX_TARGET_PAGE) {
- /* write the page*/
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_CMD_TARGET_PAGE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_CMD_TARGET_PAGE,
- v_target_page_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_CMD_TARGET_PAGE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API read page enable from the register 0x7F bit 7
- *
- *
- *
- * @param v_page_enable_u8: The value of page enable
- * value | page
- * ---------|-----------
- * 0 | DISABLE
- * 1 | ENABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_paging_enable(u8 *v_page_enable_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the page enable */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_CMD_PAGING_EN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_page_enable_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_CMD_PAGING_EN);
- }
- return com_rslt;
-}
- /*!
- * @brief This API write page enable from the register 0x7F bit 7
- *
- *
- *
- * @param v_page_enable_u8: The value of page enable
- * value | page
- * ---------|-----------
- * 0 | DISABLE
- * 1 | ENABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_paging_enable(
-u8 v_page_enable_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- if (v_page_enable_u8 <= BMI160_MAX_VALUE_PAGE) {
- /* write the page enable */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_CMD_PAGING_EN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_CMD_PAGING_EN,
- v_page_enable_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_CMD_PAGING_EN__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- } else {
- com_rslt = E_BMI160_OUT_OF_RANGE;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This API read
- * pull up configuration from the register 0X85 bit 4 an 5
- *
- *
- *
- * @param v_control_pullup_u8: The value of pull up register
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_pullup_configuration(
-u8 *v_control_pullup_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read pull up value */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC(
- p_bmi160->dev_addr,
- BMI160_COM_C_TRIM_FIVE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_control_pullup_u8 = BMI160_GET_BITSLICE(v_data_u8,
- BMI160_COM_C_TRIM_FIVE);
- }
- return com_rslt;
-
-}
- /*!
- * @brief This API write
- * pull up configuration from the register 0X85 bit 4 an 5
- *
- *
- *
- * @param v_control_pullup_u8: The value of pull up register
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_pullup_configuration(
-u8 v_control_pullup_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* write pull up value */
- com_rslt = p_bmi160->BMI160_BUS_READ_FUNC
- (p_bmi160->dev_addr,
- BMI160_COM_C_TRIM_FIVE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- if (com_rslt == SUCCESS) {
- v_data_u8 =
- BMI160_SET_BITSLICE(v_data_u8,
- BMI160_COM_C_TRIM_FIVE,
- v_control_pullup_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_WRITE_FUNC
- (p_bmi160->dev_addr,
- BMI160_COM_C_TRIM_FIVE__REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This function used for reading the compensated data of
- * mag secondary interface xyz data
- * @param v_mag_x_s16: The value of mag x data
- * @param v_mag_y_s16: The value of mag y data
- * @param v_mag_z_s16: The value of mag z data
- * @param v_mag_r_s16: The value of mag r data
- * @param v_mag_second_if_u8: The value of mag selection
- *
- * value | v_mag_second_if_u8
- * ---------|----------------------
- * 0 | BMM150
- * 1 | AKM09911
- * 2 | AKM09912
- * 3 | YAS532
- * 4 | YAS537
- * @param mag_fifo_data: The value of compensated mag xyz data
- *
- *
- * @return
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_second_if_mag_compensate_xyz(
-struct bmi160_mag_fifo_data_t mag_fifo_data,
-u8 v_mag_second_if_u8)
-{
-s8 com_rslt = BMI160_INIT_VALUE;
-s16 v_mag_x_s16 = BMI160_INIT_VALUE;
-s16 v_mag_y_s16 = BMI160_INIT_VALUE;
-s16 v_mag_z_s16 = BMI160_INIT_VALUE;
-u16 v_mag_r_u16 = BMI160_INIT_VALUE;
-u8 i = BMI160_INIT_VALUE;
-u8 v_ouflow_u8 = BMI160_INIT_VALUE;
-u8 v_busy_u8 = BMI160_INIT_VALUE;
-u8 v_coil_stat_u8 = BMI160_INIT_VALUE;
-u16 v_temperature_u16 = BMI160_INIT_VALUE;
-s32 a_h_s32[BMI160_YAS_H_DATA_SIZE] = {
-BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-s32 a_s_s32[BMI160_YAS_S_DATA_SIZE] = {
-BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-u16 xy1y2[3] = {
-BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-u16 v_xy1y2_u16[3] = {
-BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-u8 v_busy_yas532_u8 = BMI160_INIT_VALUE;
-u16 v_temp_yas532_u16 = BMI160_INIT_VALUE;
-u8 v_overflow_yas532_u8 = BMI160_INIT_VALUE;
-
-switch (v_mag_second_if_u8) {
-case BMI160_SEC_IF_BMM150:
- /* x data*/
- v_mag_x_s16 = (s16)((mag_fifo_data.mag_x_msb
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (mag_fifo_data.mag_x_lsb));
- v_mag_x_s16 = (s16)
- (v_mag_x_s16 >> BMI160_SHIFT_BIT_POSITION_BY_03_BITS);
- /* y data*/
- v_mag_y_s16 = (s16)((mag_fifo_data.mag_y_msb
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (mag_fifo_data.mag_y_lsb));
- v_mag_y_s16 = (s16)
- (v_mag_y_s16 >> BMI160_SHIFT_BIT_POSITION_BY_03_BITS);
- /* z data*/
- v_mag_z_s16 = (s16)((mag_fifo_data.mag_z_msb
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (mag_fifo_data.mag_z_lsb));
- v_mag_z_s16 = (s16)
- (v_mag_z_s16 >> BMI160_SHIFT_BIT_POSITION_BY_01_BIT);
- /* r data*/
- v_mag_r_u16 = (u16)((mag_fifo_data.mag_r_y2_msb
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (mag_fifo_data.mag_r_y2_lsb));
- v_mag_r_u16 = (u16)
- (v_mag_r_u16 >> BMI160_SHIFT_BIT_POSITION_BY_02_BITS);
- /* Compensated mag x data */
- processed_data.x =
- bmi160_bmm150_mag_compensate_X(v_mag_x_s16,
- v_mag_r_u16);
- /* Compensated mag y data */
- processed_data.y =
- bmi160_bmm150_mag_compensate_Y(v_mag_y_s16,
- v_mag_r_u16);
- /* Compensated mag z data */
- processed_data.z =
- bmi160_bmm150_mag_compensate_Z(v_mag_z_s16,
- v_mag_r_u16);
-break;
-case BMI160_SEC_IF_AKM09911:
- /* x data*/
- v_mag_x_s16 = (s16)((mag_fifo_data.mag_x_msb
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (mag_fifo_data.mag_x_lsb));
- /* y data*/
- v_mag_y_s16 = (s16)((mag_fifo_data.mag_y_msb
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (mag_fifo_data.mag_y_lsb));
- /* z data*/
- v_mag_z_s16 = (s16)((mag_fifo_data.mag_z_msb
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (mag_fifo_data.mag_z_lsb));
- /* Compensated for X data */
- processed_data.x =
- bmi160_bst_akm09911_compensate_X(v_mag_x_s16);
- /* Compensated for Y data */
- processed_data.y =
- bmi160_bst_akm09911_compensate_Y(v_mag_y_s16);
- /* Compensated for Z data */
- processed_data.z =
- bmi160_bst_akm09911_compensate_Z(v_mag_z_s16);
-break;
-case BMI160_SEC_IF_AKM09912:
- /* x data*/
- v_mag_x_s16 = (s16)((mag_fifo_data.mag_x_msb
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (mag_fifo_data.mag_x_lsb));
- /* y data*/
- v_mag_y_s16 = (s16)((mag_fifo_data.mag_y_msb
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (mag_fifo_data.mag_y_lsb));
- /* z data*/
- v_mag_z_s16 = (s16)((mag_fifo_data.mag_z_msb
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (mag_fifo_data.mag_z_lsb));
- /* Compensated for X data */
- processed_data.x =
- bmi160_bst_akm09912_compensate_X(v_mag_x_s16);
- /* Compensated for Y data */
- processed_data.y =
- bmi160_bst_akm09912_compensate_Y(v_mag_y_s16);
- /* Compensated for Z data */
- processed_data.z =
- bmi160_bst_akm09912_compensate_Z(v_mag_z_s16);
-break;
-case BMI160_SEC_IF_YAS532:
- /* read the xyy1 data*/
- v_busy_yas532_u8 =
- ((mag_fifo_data.mag_x_lsb
- >> BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01);
- v_temp_yas532_u16 =
- (u16)((((s32)mag_fifo_data.mag_x_lsb
- << BMI160_SHIFT_BIT_POSITION_BY_03_BITS)
- & 0x3F8) | ((mag_fifo_data.mag_x_msb
- >> BMI160_SHIFT_BIT_POSITION_BY_05_BITS) & 0x07));
-
- v_xy1y2_u16[0] =
- (u16)((((s32)mag_fifo_data.mag_y_lsb
- << BMI160_SHIFT_BIT_POSITION_BY_06_BITS) & 0x1FC0)
- | ((mag_fifo_data.mag_y_msb >>
- BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
- v_xy1y2_u16[1] =
- (u16)((((s32)mag_fifo_data.mag_z_lsb
- << BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
- & 0x1FC0)
- | ((mag_fifo_data.mag_z_msb
- >> BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
- v_xy1y2_u16[2] =
- (u16)((((s32)mag_fifo_data.mag_r_y2_lsb
- << BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
- & 0x1FC0)
- | ((mag_fifo_data.mag_r_y2_msb
- >> BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
- v_overflow_yas532_u8 = 0;
- for (i = 0; i < 3; i++) {
- if (v_xy1y2_u16[i] == YAS532_DATA_OVERFLOW)
- v_overflow_yas532_u8 |= (1 << (i * 2));
- if (v_xy1y2_u16[i] == YAS532_DATA_UNDERFLOW)
- v_overflow_yas532_u8 |= (1 << (i * 2 + 1));
- }
- /* assign the data*/
- com_rslt = bmi160_bst_yas532_fifo_xyz_data(
- v_xy1y2_u16, 1, v_overflow_yas532_u8,
- v_temp_yas532_u16, v_busy_yas532_u8);
- processed_data.x =
- fifo_xyz_data.yas532_vector_xyz[0];
- processed_data.y =
- fifo_xyz_data.yas532_vector_xyz[1];
- processed_data.z =
- fifo_xyz_data.yas532_vector_xyz[2];
-break;
-case BMI160_SEC_IF_YAS537:
- /* read the busy flag*/
- v_busy_u8 = mag_fifo_data.mag_y_lsb
- >> BMI160_SHIFT_BIT_POSITION_BY_07_BITS;
- /* read the coil status*/
- v_coil_stat_u8 =
- ((mag_fifo_data.mag_y_lsb >>
- BMI160_SHIFT_BIT_POSITION_BY_06_BITS) & 0X01);
- /* read temperature data*/
- v_temperature_u16 = (u16)((mag_fifo_data.mag_x_lsb
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | mag_fifo_data.mag_x_msb);
- /* read x data*/
- xy1y2[0] = (u16)(((mag_fifo_data.mag_y_lsb &
- 0x3F)
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (mag_fifo_data.mag_y_msb));
- /* read y1 data*/
- xy1y2[1] = (u16)((mag_fifo_data.mag_z_lsb
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | mag_fifo_data.mag_z_msb);
- /* read y2 data*/
- xy1y2[2] = (u16)((mag_fifo_data.mag_r_y2_lsb
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | mag_fifo_data.mag_r_y2_msb);
- for (i = 0; i < 3; i++)
- yas537_data.last_raw[i] = xy1y2[i];
- yas537_data.last_raw[i] = v_temperature_u16;
- if (yas537_data.calib_yas537.ver == 1) {
- for (i = 0; i < 3; i++)
- a_s_s32[i] = xy1y2[i] - 8192;
- /* read hx*/
- a_h_s32[0] = ((yas537_data.calib_yas537.k * (
- (128 * a_s_s32[0]) +
- (yas537_data.calib_yas537.a2 * a_s_s32[1]) +
- (yas537_data.calib_yas537.a3 * a_s_s32[2])))
- / (8192));
- /* read hy1*/
- a_h_s32[1] = ((yas537_data.calib_yas537.k * (
- (yas537_data.calib_yas537.a4 * a_s_s32[0]) +
- (yas537_data.calib_yas537.a5 * a_s_s32[1]) +
- (yas537_data.calib_yas537.a6 * a_s_s32[2])))
- / (8192));
- /* read hy2*/
- a_h_s32[2] = ((yas537_data.calib_yas537.k * (
- (yas537_data.calib_yas537.a7 * a_s_s32[0]) +
- (yas537_data.calib_yas537.a8 * a_s_s32[1]) +
- (yas537_data.calib_yas537.a9 * a_s_s32[2])))
- / (8192));
-
- for (i = 0; i < 3; i++) {
- if (a_h_s32[i] < -8192)
- a_h_s32[i] = -8192;
-
- if (8192 < a_h_s32[i])
- a_h_s32[i] = 8192;
-
- xy1y2[i] = a_h_s32[i] + 8192;
-
- }
- }
- v_ouflow_u8 = 0;
- for (i = 0; i < 3; i++) {
- if (YAS537_DATA_OVERFLOW
- <= xy1y2[i])
- v_ouflow_u8 |=
- (1 << (i * 2));
- if (xy1y2[i] ==
- YAS537_DATA_UNDERFLOW)
- v_ouflow_u8
- |= (1 << (i * 2 + 1));
- }
- com_rslt = bmi160_bst_yamaha_yas537_fifo_xyz_data(
- xy1y2, v_ouflow_u8, v_coil_stat_u8, v_busy_u8);
- processed_data.x =
- fifo_vector_xyz.yas537_vector_xyz[0];
- processed_data.y =
- fifo_vector_xyz.yas537_vector_xyz[1];
- processed_data.z =
- fifo_vector_xyz.yas537_vector_xyz[2];
-break;
-default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
-break;
-}
- return com_rslt;
-}
-/*!
- * @brief This function used for reading the
- * fifo data of header mode
- *
- *
- * @note Configure the below functions for FIFO header mode
- * @note 1. bmi160_set_fifo_down_gyro()
- * @note 2. bmi160_set_gyro_fifo_filter_data()
- * @note 3. bmi160_set_fifo_down_accel()
- * @note 4. bmi160_set_accel_fifo_filter_dat()
- * @note 5. bmi160_set_fifo_mag_enable()
- * @note 6. bmi160_set_fifo_accel_enable()
- * @note 7. bmi160_set_fifo_gyro_enable()
- * @note 8. bmi160_set_fifo_header_enable()
- * @note For interrupt configuration
- * @note 1. bmi160_set_intr_fifo_full()
- * @note 2. bmi160_set_intr_fifo_wm()
- * @note 3. bmi160_set_fifo_tag_intr2_enable()
- * @note 4. bmi160_set_fifo_tag_intr1_enable()
- *
- * @note The fifo reads the whole 1024 bytes
- * and processing the data
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_header_data(u8 v_mag_if_u8)
-{
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- struct bmi160_fifo_data_header_t header_data;
- /* read the whole fifo data*/
- com_rslt =
- bmi160_read_fifo_header_data_user_defined_length(
- FIFO_FRAME, v_mag_if_u8, &header_data);
- return com_rslt;
-}
-/*!
- * @brief This function used for reading the
- * fifo data of header mode for using user defined length
- *
- *
- * @note Configure the below functions for FIFO header mode
- * @note 1. bmi160_set_fifo_down_gyro()
- * @note 2. bmi160_set_gyro_fifo_filter_data()
- * @note 3. bmi160_set_fifo_down_accel()
- * @note 4. bmi160_set_accel_fifo_filter_dat()
- * @note 5. bmi160_set_fifo_mag_enable()
- * @note 6. bmi160_set_fifo_accel_enable()
- * @note 7. bmi160_set_fifo_gyro_enable()
- * @note 8. bmi160_set_fifo_header_enable()
- * @note For interrupt configuration
- * @note 1. bmi160_set_intr_fifo_full()
- * @note 2. bmi160_set_intr_fifo_wm()
- * @note 3. bmi160_set_fifo_tag_intr2_enable()
- * @note 4. bmi160_set_fifo_tag_intr1_enable()
- *
- * @note The fifo reads the whole 1024 bytes
- * and processing the data
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_header_data_user_defined_length(
-u16 v_fifo_user_length_u16, u8 v_mag_if_mag_u8,
-struct bmi160_fifo_data_header_t *fifo_header_data)
-{
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_accel_index_u8 = BMI160_INIT_VALUE;
- u8 v_gyro_index_u8 = BMI160_INIT_VALUE;
- u8 v_mag_index_u8 = BMI160_INIT_VALUE;
- s8 v_last_return_stat_s8 = BMI160_INIT_VALUE;
- u16 v_fifo_index_u16 = BMI160_INIT_VALUE;
- u8 v_frame_head_u8 = BMI160_INIT_VALUE;
- u8 v_frame_index_u8 = BMI160_INIT_VALUE;
-
- u16 v_fifo_length_u16 = BMI160_INIT_VALUE;
-
- fifo_header_data->accel_frame_count = BMI160_INIT_VALUE;
- fifo_header_data->mag_frame_count = BMI160_INIT_VALUE;
- fifo_header_data->gyro_frame_count = BMI160_INIT_VALUE;
- /* read fifo v_data_u8*/
- com_rslt = bmi160_fifo_data(&v_fifo_data_u8[BMI160_INIT_VALUE],
- v_fifo_user_length_u16);
- v_fifo_length_u16 = v_fifo_user_length_u16;
- for (v_fifo_index_u16 = BMI160_INIT_VALUE;
- v_fifo_index_u16 < v_fifo_length_u16;) {
- fifo_header_data->fifo_header[v_frame_index_u8]
- = v_fifo_data_u8[v_fifo_index_u16];
- v_frame_head_u8 =
- fifo_header_data->fifo_header[v_frame_index_u8]
- & BMI160_FIFO_TAG_INTR_MASK;
- v_frame_index_u8++;
- switch (v_frame_head_u8) {
- /* Header frame of accel */
- case FIFO_HEAD_A:
- { /*fifo v_data_u8 frame index + 1*/
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_INDEX_LENGTH;
-
- if ((v_fifo_index_u16 + BMI160_FIFO_A_LENGTH)
- > v_fifo_length_u16) {
- v_last_return_stat_s8 = FIFO_A_OVER_LEN;
- break;
- }
- /* Accel raw x v_data_u8 */
- fifo_header_data->accel_fifo[v_accel_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_MSB_DATA])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_LSB_DATA]));
- /* Accel raw y v_data_u8 */
- fifo_header_data->accel_fifo[v_accel_index_u8].y =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_MSB_DATA])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_LSB_DATA]));
- /* Accel raw z v_data_u8 */
- fifo_header_data->accel_fifo[v_accel_index_u8].z =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_MSB_DATA])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_LSB_DATA]));
- /* check for accel frame count*/
- fifo_header_data->accel_frame_count =
- fifo_header_data->accel_frame_count
- + BMI160_FRAME_COUNT;
- /* index adde to 6 accel alone*/
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_A_LENGTH;
- v_accel_index_u8++;
-
- break;
- }
- /* Header frame of gyro */
- case FIFO_HEAD_G:
- { /*fifo v_data_u8 frame index + 1*/
- v_fifo_index_u16 = v_fifo_index_u16
- + BMI160_FIFO_INDEX_LENGTH;
-
- if ((v_fifo_index_u16 + BMI160_FIFO_G_LENGTH) >
- v_fifo_length_u16) {
- v_last_return_stat_s8 = FIFO_G_OVER_LEN;
- break;
- }
- /* Gyro raw x v_data_u8 */
- fifo_header_data->gyro_fifo[v_gyro_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_MSB_DATA])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_LSB_DATA]));
- /* Gyro raw y v_data_u8 */
- fifo_header_data->gyro_fifo[v_gyro_index_u8].y =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_MSB_DATA])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_LSB_DATA]));
- /* Gyro raw z v_data_u8 */
- fifo_header_data->gyro_fifo[v_gyro_index_u8].z =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_MSB_DATA])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_LSB_DATA]));
- /* check for gyro frame count*/
- fifo_header_data->gyro_frame_count =
- fifo_header_data->gyro_frame_count + BMI160_FRAME_COUNT;
- /*fifo G v_data_u8 frame index + 6*/
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_G_LENGTH;
- v_gyro_index_u8++;
-
- break;
- }
- /* Header frame of mag */
- case FIFO_HEAD_M:
- { /*fifo v_data_u8 frame index + 1*/
- v_fifo_index_u16 = v_fifo_index_u16
- + BMI160_FIFO_INDEX_LENGTH;
-
- if ((v_fifo_index_u16 + BMI160_FIFO_M_LENGTH) >
- (v_fifo_length_u16)) {
- v_last_return_stat_s8 = FIFO_M_OVER_LEN;
- break;
- }
- /* Mag x data*/
- mag_data.mag_x_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_LSB_DATA]);
- mag_data.mag_x_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_MSB_DATA]);
- /* Mag y data*/
- mag_data.mag_y_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_LSB_DATA]);
- mag_data.mag_y_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_MSB_DATA]);
- mag_data.mag_z_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_LSB_DATA]);
- mag_data.mag_z_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_MSB_DATA]);
- /* Mag r data*/
- mag_data.mag_r_y2_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_LSB_DATA]);
- mag_data.mag_r_y2_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_MSB_DATA]);
-
- com_rslt = bmi160_second_if_mag_compensate_xyz(mag_data,
- v_mag_if_mag_u8);
- /* compensated mag x */
- fifo_header_data->mag_fifo[v_gyro_index_u8].x
- = processed_data.x;
- /* compensated mag y */
- fifo_header_data->mag_fifo[v_gyro_index_u8].y
- = processed_data.y;
- /* compensated mag z */
- fifo_header_data->mag_fifo[v_gyro_index_u8].z
- = processed_data.z;
-
- /* check for mag frame count*/
- fifo_header_data->mag_frame_count =
- fifo_header_data->mag_frame_count
- + BMI160_FRAME_COUNT;
-
- v_mag_index_u8++;
- /*fifo M v_data_u8 frame index + 8*/
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_M_LENGTH;
- break;
- }
- /* Header frame of gyro and accel */
- case FIFO_HEAD_G_A:
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_INDEX_LENGTH;
- if ((v_fifo_index_u16 + BMI160_FIFO_AG_LENGTH)
- > v_fifo_length_u16) {
- v_last_return_stat_s8 = FIFO_G_A_OVER_LEN;
- break;
- }
- /* Raw gyro x */
- fifo_header_data->gyro_fifo[v_gyro_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_G_X_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_G_X_LSB]));
- /* Raw gyro y */
- fifo_header_data->gyro_fifo[v_gyro_index_u8].y =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_G_Y_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_G_Y_LSB]));
- /* Raw gyro z */
- fifo_header_data->gyro_fifo[v_gyro_index_u8].z =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_G_Z_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_G_Z_LSB]));
- /* check for gyro frame count*/
- fifo_header_data->gyro_frame_count =
- fifo_header_data->gyro_frame_count + BMI160_FRAME_COUNT;
- /* Raw accel x */
- fifo_header_data->accel_fifo[v_accel_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_A_X_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_A_X_LSB]));
- /* Raw accel y */
- fifo_header_data->accel_fifo[v_accel_index_u8].y =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_A_Y_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_A_Y_LSB]));
- /* Raw accel z */
- fifo_header_data->accel_fifo[v_accel_index_u8].z =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_A_Z_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16
- + BMI160_GA_FIFO_A_Z_LSB]));
- /* check for accel frame count*/
- fifo_header_data->accel_frame_count =
- fifo_header_data->accel_frame_count
- + BMI160_FRAME_COUNT;
- /* Index added to 12 for gyro and accel*/
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_AG_LENGTH;
- v_gyro_index_u8++;
- v_accel_index_u8++;
- break;
- /* Header frame of mag, gyro and accel */
- case FIFO_HEAD_M_G_A:
- { /*fifo v_data_u8 frame index + 1*/
- v_fifo_index_u16 = v_fifo_index_u16
- + BMI160_FIFO_INDEX_LENGTH;
-
- if ((v_fifo_index_u16 + BMI160_FIFO_AMG_LENGTH)
- > (v_fifo_length_u16)) {
- v_last_return_stat_s8 = FIFO_M_G_A_OVER_LEN;
- break;
- }
- /* Mag x data*/
- mag_data.mag_x_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_LSB_DATA]);
- mag_data.mag_x_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_MSB_DATA]);
- /* Mag y data*/
- mag_data.mag_y_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_LSB_DATA]);
- mag_data.mag_y_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_MSB_DATA]);
- mag_data.mag_z_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_LSB_DATA]);
- mag_data.mag_z_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_MSB_DATA]);
- /* Mag r data*/
- mag_data.mag_r_y2_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_LSB_DATA]);
- mag_data.mag_r_y2_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_MSB_DATA]);
- /* Processing the compensation data*/
- com_rslt = bmi160_second_if_mag_compensate_xyz(mag_data,
- v_mag_if_mag_u8);
- /* compensated mag x */
- fifo_header_data->mag_fifo[v_mag_index_u8].x =
- processed_data.x;
- /* compensated mag y */
- fifo_header_data->mag_fifo[v_mag_index_u8].y =
- processed_data.y;
- /* compensated mag z */
- fifo_header_data->mag_fifo[v_mag_index_u8].z =
- processed_data.z;
- /* check for mag frame count*/
- fifo_header_data->mag_frame_count =
- fifo_header_data->mag_frame_count + BMI160_FRAME_COUNT;
- /* Gyro raw x v_data_u8 */
- fifo_header_data->gyro_fifo[v_gyro_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_G_X_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_G_X_LSB]));
- /* Gyro raw y v_data_u8 */
- fifo_header_data->gyro_fifo[v_gyro_index_u8].y =
- (s16)(((v_fifo_data_u8[
- v_fifo_index_u16 + BMI160_MGA_FIFO_G_Y_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_G_Y_LSB]));
- /* Gyro raw z v_data_u8 */
- fifo_header_data->gyro_fifo[v_gyro_index_u8].z =
- (s16)(((v_fifo_data_u8[
- v_fifo_index_u16 + BMI160_MGA_FIFO_G_Z_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[
- v_fifo_index_u16 + BMI160_MGA_FIFO_G_Z_LSB]));
- /* check for gyro frame count*/
- fifo_header_data->gyro_frame_count =
- fifo_header_data->gyro_frame_count + BMI160_FRAME_COUNT;
- /* Accel raw x v_data_u8 */
- fifo_header_data->accel_fifo[v_accel_index_u8].x =
- (s16)(((v_fifo_data_u8[
- v_fifo_index_u16 + BMI160_MGA_FIFO_A_X_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_A_X_LSB]));
- /* Accel raw y v_data_u8 */
- fifo_header_data->accel_fifo[v_accel_index_u8].y =
- (s16)(((v_fifo_data_u8[
- v_fifo_index_u16 + BMI160_MGA_FIFO_A_Y_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_A_Y_LSB]));
- /* Accel raw z v_data_u8 */
- fifo_header_data->accel_fifo[v_accel_index_u8].z =
- (s16)(((v_fifo_data_u8[
- v_fifo_index_u16 + BMI160_MGA_FIFO_A_Z_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_A_Z_LSB]));
- /* check for accel frame count*/
- fifo_header_data->accel_frame_count =
- fifo_header_data->accel_frame_count
- + BMI160_FRAME_COUNT;
- /* Index added to 20 for mag, gyro and accel*/
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_AMG_LENGTH;
- v_accel_index_u8++;
- v_mag_index_u8++;
- v_gyro_index_u8++;
- break;
- }
- /* Header frame of mag and accel */
- case FIFO_HEAD_M_A:
- { /*fifo v_data_u8 frame index + 1*/
- v_fifo_index_u16 = v_fifo_index_u16
- + BMI160_GEN_READ_WRITE_DATA_LENGTH;
-
- if ((v_fifo_index_u16 + BMI160_FIFO_MA_OR_MG_LENGTH)
- > (v_fifo_length_u16)) {
- v_last_return_stat_s8 = FIFO_M_A_OVER_LEN;
- break;
- }
- /* Mag x data*/
- mag_data.mag_x_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_LSB_DATA]);
- mag_data.mag_x_msb = (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_MSB_DATA]);
- /* Mag y data*/
- mag_data.mag_y_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_LSB_DATA]);
- mag_data.mag_y_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_MSB_DATA]);
- mag_data.mag_z_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_LSB_DATA]);
- mag_data.mag_z_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_MSB_DATA]);
- /* Mag r data*/
- mag_data.mag_r_y2_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_LSB_DATA]);
- mag_data.mag_r_y2_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_MSB_DATA]);
- com_rslt =
- bmi160_second_if_mag_compensate_xyz(mag_data,
- v_mag_if_mag_u8);
- /* compensated mag x */
- fifo_header_data->mag_fifo[v_mag_index_u8].x =
- processed_data.x;
- /* compensated mag y */
- fifo_header_data->mag_fifo[v_mag_index_u8].y =
- processed_data.y;
- /* compensated mag z */
- fifo_header_data->mag_fifo[v_mag_index_u8].z =
- processed_data.z;
- /* check for mag frame count*/
- fifo_header_data->mag_frame_count =
- fifo_header_data->mag_frame_count
- + BMI160_FRAME_COUNT;
- /* Accel raw x v_data_u8 */
- fifo_header_data->accel_fifo[v_accel_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MA_FIFO_A_X_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MA_FIFO_A_X_LSB]));
- /* Accel raw y v_data_u8 */
- fifo_header_data->accel_fifo[v_accel_index_u8].y =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MA_FIFO_A_Y_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MA_FIFO_A_Y_LSB]));
- /* Accel raw z v_data_u8 */
- fifo_header_data->accel_fifo[v_accel_index_u8].z =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MA_FIFO_A_Z_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MA_FIFO_A_Z_LSB]));
- /* check for accel frame count*/
- fifo_header_data->accel_frame_count =
- fifo_header_data->accel_frame_count
- + BMI160_FRAME_COUNT;
- /*fifo AM v_data_u8 frame index + 14(8+6)*/
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_MA_OR_MG_LENGTH;
- v_accel_index_u8++;
- v_mag_index_u8++;
- break;
- }
- /* Header frame of mag and gyro */
- case FIFO_HEAD_M_G:
- {
- /*fifo v_data_u8 frame index + 1*/
- v_fifo_index_u16 = v_fifo_index_u16
- + BMI160_GEN_READ_WRITE_DATA_LENGTH;
-
- if ((v_fifo_index_u16 + BMI160_FIFO_MA_OR_MG_LENGTH)
- > v_fifo_length_u16) {
- v_last_return_stat_s8 = FIFO_M_G_OVER_LEN;
- break;
- }
- /* Mag x data*/
- mag_data.mag_x_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_LSB_DATA]);
- mag_data.mag_x_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_MSB_DATA]);
- /* Mag y data*/
- mag_data.mag_y_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_LSB_DATA]);
- mag_data.mag_y_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_MSB_DATA]);
- mag_data.mag_z_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_LSB_DATA]);
- mag_data.mag_z_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_MSB_DATA]);
- /* Mag r data*/
- mag_data.mag_r_y2_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_LSB_DATA]);
- mag_data.mag_r_y2_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_MSB_DATA]);
- com_rslt =
- bmi160_second_if_mag_compensate_xyz(mag_data,
- v_mag_if_mag_u8);
- /* compensated mag x */
- fifo_header_data->mag_fifo[v_mag_index_u8].x =
- processed_data.x;
- /* compensated mag y */
- fifo_header_data->mag_fifo[v_mag_index_u8].y =
- processed_data.y;
- /* compensated mag z */
- fifo_header_data->mag_fifo[v_mag_index_u8].z =
- processed_data.z;
- /* check for mag frame count*/
- fifo_header_data->mag_frame_count =
- fifo_header_data->mag_frame_count + BMI160_FRAME_COUNT;
- /* Gyro raw x v_data_u8 */
- fifo_header_data->gyro_fifo[v_gyro_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MG_FIFO_G_X_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MG_FIFO_G_X_LSB]));
- /* Gyro raw y v_data_u8 */
- fifo_header_data->gyro_fifo[v_gyro_index_u8].y =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MG_FIFO_G_Y_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MG_FIFO_G_Y_LSB]));
- /* Gyro raw z v_data_u8 */
- fifo_header_data->gyro_fifo[v_gyro_index_u8].z =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MG_FIFO_G_Z_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MG_FIFO_G_Z_LSB]));
- /* check for gyro frame count*/
- fifo_header_data->gyro_frame_count =
- fifo_header_data->gyro_frame_count
- + BMI160_FRAME_COUNT;
- /*fifo GM v_data_u8 frame index + 14(8+6)*/
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_MA_OR_MG_LENGTH;
- v_mag_index_u8++;
- v_gyro_index_u8++;
- break;
- }
- /* Header frame of sensor time */
- case FIFO_HEAD_SENSOR_TIME:
- {
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_GEN_READ_WRITE_DATA_LENGTH;
-
- if ((v_fifo_index_u16
- + BMI160_FIFO_SENSOR_TIME_LENGTH) >
- (v_fifo_length_u16)) {
- v_last_return_stat_s8
- = FIFO_SENSORTIME_RETURN;
- break;
- }
- /* Sensor time */
- fifo_header_data->fifo_time = (u32)
- ((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_SENSOR_TIME_MSB]
- << BMI160_SHIFT_BIT_POSITION_BY_16_BITS) |
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_SENSOR_TIME_XLSB]
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_SENSOR_TIME_LSB]));
-
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_SENSOR_TIME_LENGTH;
- break;
- }
- /* Header frame of skip frame */
- case FIFO_HEAD_SKIP_FRAME:
- {
- /*fifo v_data_u8 frame index + 1*/
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_INDEX_LENGTH;
- if (v_fifo_index_u16
- + BMI160_FIFO_INDEX_LENGTH
- > v_fifo_length_u16) {
- v_last_return_stat_s8 =
- FIFO_SKIP_OVER_LEN;
- break;
- }
- fifo_header_data->skip_frame =
- v_fifo_data_u8[v_fifo_index_u16];
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_INDEX_LENGTH;
- break;
- }
- case FIFO_HEAD_INPUT_CONFIG:
- {
- /*fifo v_data_u8 frame index + 1*/
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_INDEX_LENGTH;
- if (v_fifo_index_u16
- + BMI160_FIFO_INDEX_LENGTH
- > v_fifo_length_u16) {
- v_last_return_stat_s8 =
- FIFO_INPUT_CONFIG_OVER_LEN;
- break;
- }
- fifo_header_data->fifo_input_config_info
- = v_fifo_data_u8[v_fifo_index_u16];
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_INDEX_LENGTH;
- break;
- }
- /* Header frame of over read fifo v_data_u8 */
- case FIFO_HEAD_OVER_READ_LSB:
- {
- /*fifo v_data_u8 frame index + 1*/
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_INDEX_LENGTH;
-
- if ((v_fifo_index_u16 + BMI160_FIFO_INDEX_LENGTH)
- > (v_fifo_length_u16)) {
- v_last_return_stat_s8 = FIFO_OVER_READ_RETURN;
- break;
- }
- if (v_fifo_data_u8[v_fifo_index_u16] ==
- FIFO_HEAD_OVER_READ_MSB) {
- /*fifo over read frame index + 1*/
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_INDEX_LENGTH;
- break;
- } else {
- v_last_return_stat_s8 = FIFO_OVER_READ_RETURN;
- break;
- }
- }
-
- default:
- v_last_return_stat_s8 = BMI160_FIFO_INDEX_LENGTH;
- break;
- }
- if (v_last_return_stat_s8)
- break;
- }
-return com_rslt;
-}
-/*!
- * @brief This function used for reading the
- * fifo data of header less mode
- *
- *
- *
- * @note Configure the below functions for FIFO header less mode
- * @note 1. bmi160_set_fifo_down_gyro
- * @note 2. bmi160_set_gyro_fifo_filter_data
- * @note 3. bmi160_set_fifo_down_accel
- * @note 4. bmi160_set_accel_fifo_filter_dat
- * @note 5. bmi160_set_fifo_mag_enable
- * @note 6. bmi160_set_fifo_accel_enable
- * @note 7. bmi160_set_fifo_gyro_enable
- * @note For interrupt configuration
- * @note 1. bmi160_set_intr_fifo_full
- * @note 2. bmi160_set_intr_fifo_wm
- * @note 3. bmi160_set_fifo_tag_intr2_enable
- * @note 4. bmi160_set_fifo_tag_intr1_enable
- *
- * @note The fifo reads the whole 1024 bytes
- * and processing the data
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_headerless_mode(
-u8 v_mag_if_u8) {
-
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- struct bmi160_fifo_data_header_less_t headerless_data;
- /* read the whole FIFO data*/
- com_rslt =
- bmi160_read_fifo_headerless_mode_user_defined_length(
- FIFO_FRAME, &headerless_data, v_mag_if_u8);
- return com_rslt;
-}
-/*!
- * @brief This function used for reading the
- * fifo data of header less mode for using user defined length
- *
- *
- * @param v_fifo_user_length_u16: The value of length of fifo read data
- *
- * @note Configure the below functions for FIFO header less mode
- * @note 1. bmi160_set_fifo_down_gyro
- * @note 2. bmi160_set_gyro_fifo_filter_data
- * @note 3. bmi160_set_fifo_down_accel
- * @note 4. bmi160_set_accel_fifo_filter_dat
- * @note 5. bmi160_set_fifo_mag_enable
- * @note 6. bmi160_set_fifo_accel_enable
- * @note 7. bmi160_set_fifo_gyro_enable
- * @note For interrupt configuration
- * @note 1. bmi160_set_intr_fifo_full
- * @note 2. bmi160_set_intr_fifo_wm
- * @note 3. bmi160_set_fifo_tag_intr2_enable
- * @note 4. bmi160_set_fifo_tag_intr1_enable
- *
- * @note The fifo reads the whole 1024 bytes
- * and processing the data
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE
-bmi160_read_fifo_headerless_mode_user_defined_length(
-u16 v_fifo_user_length_u16,
-struct bmi160_fifo_data_header_less_t *fifo_data,
-u8 v_mag_if_mag_u8)
-{
-u8 v_data_u8 = BMI160_INIT_VALUE;
-u32 v_fifo_index_u16 = BMI160_INIT_VALUE;
-u32 v_fifo_length_u16 = BMI160_INIT_VALUE;
-u8 v_accel_index_u8 = BMI160_INIT_VALUE;
-u8 v_gyro_index_u8 = BMI160_INIT_VALUE;
-u8 v_mag_index_u8 = BMI160_INIT_VALUE;
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-fifo_data->accel_frame_count = BMI160_INIT_VALUE;
-fifo_data->mag_frame_count = BMI160_INIT_VALUE;
-fifo_data->gyro_frame_count = BMI160_INIT_VALUE;
-/* disable the header data */
-com_rslt = bmi160_set_fifo_header_enable(BMI160_INIT_VALUE);
-/* read mag, accel and gyro enable status*/
-com_rslt += bmi160_read_reg(BMI160_USER_FIFO_CONFIG_1_ADDR,
-&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-v_data_u8 = v_data_u8 & BMI160_FIFO_M_G_A_ENABLE;
-/* read the fifo data of 1024 bytes*/
-com_rslt += bmi160_fifo_data(&v_fifo_data_u8[BMI160_INIT_VALUE],
-v_fifo_user_length_u16);
-v_fifo_length_u16 = v_fifo_user_length_u16;
-/* loop for executing the different conditions */
-for (v_fifo_index_u16 = BMI160_INIT_VALUE;
-v_fifo_index_u16 < v_fifo_length_u16;) {
- /* condition for mag, gyro and accel enable*/
- if (v_data_u8 == BMI160_FIFO_M_G_A_ENABLE) {
- /* Raw mag x*/
- mag_data.mag_x_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_LSB_DATA]);
- mag_data.mag_x_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_MSB_DATA]);
- /* Mag y data*/
- mag_data.mag_y_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_LSB_DATA]);
- mag_data.mag_y_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_MSB_DATA]);
- /* Mag z data*/
- mag_data.mag_z_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_LSB_DATA]);
- mag_data.mag_z_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_MSB_DATA]);
- /* Mag r data*/
- mag_data.mag_r_y2_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_LSB_DATA]);
- mag_data.mag_r_y2_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_MSB_DATA]);
- com_rslt =
- bmi160_second_if_mag_compensate_xyz(mag_data,
- v_mag_if_mag_u8);
- /* compensated mag x */
- fifo_data->mag_fifo[v_mag_index_u8].x =
- processed_data.x;
- /* compensated mag y */
- fifo_data->mag_fifo[v_mag_index_u8].y =
- processed_data.y;
- /* compensated mag z */
- fifo_data->mag_fifo[v_mag_index_u8].z =
- processed_data.z;
- /* check for mag frame count*/
- fifo_data->mag_frame_count =
- fifo_data->mag_frame_count + BMI160_FRAME_COUNT;
- /* Gyro raw x v_data_u8 */
- fifo_data->gyro_fifo[v_gyro_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_G_X_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_G_X_LSB]));
- /* Gyro raw y v_data_u8 */
- fifo_data->gyro_fifo[v_gyro_index_u8].y =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_G_Y_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_G_Y_LSB]));
- /* Gyro raw z v_data_u8 */
- fifo_data->gyro_fifo[v_gyro_index_u8].z =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_G_Z_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_G_Z_LSB]));
- /* check for gyro frame count*/
- fifo_data->gyro_frame_count =
- fifo_data->gyro_frame_count + BMI160_FRAME_COUNT;
- /* Accel raw x v_data_u8 */
- fifo_data->accel_fifo[v_accel_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_A_X_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_A_X_LSB]));
- /* Accel raw y v_data_u8 */
- fifo_data->accel_fifo[v_accel_index_u8].y =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_A_Y_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_A_Y_LSB]));
- /* Accel raw z v_data_u8 */
- fifo_data->accel_fifo[v_accel_index_u8].z =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_A_Z_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MGA_FIFO_A_Z_LSB]));
- /* check for accel frame count*/
- fifo_data->accel_frame_count =
- fifo_data->accel_frame_count + BMI160_FRAME_COUNT;
- v_accel_index_u8++;
- v_mag_index_u8++;
- v_gyro_index_u8++;
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_AMG_LENGTH;
- }
- /* condition for mag and gyro enable*/
- else if (v_data_u8 == BMI160_FIFO_M_G_ENABLE) {
- /* Raw mag x*/
- mag_data.mag_x_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_LSB_DATA]);
- mag_data.mag_x_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_MSB_DATA]);
- /* Mag y data*/
- mag_data.mag_y_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_LSB_DATA]);
- mag_data.mag_y_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_MSB_DATA]);
- /* Mag z data*/
- mag_data.mag_z_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_LSB_DATA]);
- mag_data.mag_z_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_MSB_DATA]);
- /* Mag r data*/
- mag_data.mag_r_y2_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_LSB_DATA]);
- mag_data.mag_r_y2_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_MSB_DATA]);
- com_rslt = bmi160_second_if_mag_compensate_xyz(mag_data,
- v_mag_if_mag_u8);
- /* compensated mag x */
- fifo_data->mag_fifo[v_mag_index_u8].x =
- processed_data.x;
- /* compensated mag y */
- fifo_data->mag_fifo[v_mag_index_u8].y =
- processed_data.y;
- /* compensated mag z */
- fifo_data->mag_fifo[v_mag_index_u8].z =
- processed_data.z;
- /* check for mag frame count*/
- fifo_data->mag_frame_count =
- fifo_data->mag_frame_count + BMI160_FRAME_COUNT;
- /* Gyro raw x v_data_u8 */
- fifo_data->gyro_fifo[v_gyro_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MG_FIFO_G_X_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MG_FIFO_G_X_LSB]));
- /* Gyro raw y v_data_u8 */
- fifo_data->gyro_fifo[v_gyro_index_u8].y =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MG_FIFO_G_Y_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MG_FIFO_G_Y_LSB]));
- /* Gyro raw z v_data_u8 */
- fifo_data->gyro_fifo[v_gyro_index_u8].z =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MG_FIFO_G_Z_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MG_FIFO_G_Z_LSB]));
- /* check for gyro frame count*/
- fifo_data->gyro_frame_count =
- fifo_data->gyro_frame_count + BMI160_FRAME_COUNT;
- v_gyro_index_u8++;
- v_mag_index_u8++;
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_MA_OR_MG_LENGTH;
- }
- /* condition for mag and accel enable*/
- else if (v_data_u8 == BMI160_FIFO_M_A_ENABLE) {
- /* Raw mag x*/
- mag_data.mag_x_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_LSB_DATA]);
- mag_data.mag_x_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_MSB_DATA]);
- /* Mag y data*/
- mag_data.mag_y_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_LSB_DATA]);
- mag_data.mag_y_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_MSB_DATA]);
- /* Mag z data*/
- mag_data.mag_z_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_LSB_DATA]);
- mag_data.mag_z_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_MSB_DATA]);
- /* Mag r data*/
- mag_data.mag_r_y2_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_LSB_DATA]);
- mag_data.mag_r_y2_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_MSB_DATA]);
- com_rslt = bmi160_second_if_mag_compensate_xyz(mag_data,
- v_mag_if_mag_u8);
- /* compensated mag x */
- fifo_data->mag_fifo[v_mag_index_u8].x =
- processed_data.x;
- /* compensated mag y */
- fifo_data->mag_fifo[v_mag_index_u8].y =
- processed_data.y;
- /* compensated mag z */
- fifo_data->mag_fifo[v_mag_index_u8].z =
- processed_data.z;
- /* check for mag frame count*/
- fifo_data->mag_frame_count =
- fifo_data->mag_frame_count + BMI160_FRAME_COUNT;
- /* Accel raw x v_data_u8 */
- fifo_data->accel_fifo[v_accel_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MA_FIFO_A_X_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MA_FIFO_A_X_LSB]));
- /* Accel raw y v_data_u8 */
- fifo_data->accel_fifo[v_accel_index_u8].y =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MA_FIFO_A_Y_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MA_FIFO_A_Y_LSB]));
- /* Accel raw z v_data_u8 */
- fifo_data->accel_fifo[v_accel_index_u8].z =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MA_FIFO_A_Z_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_MA_FIFO_A_Z_LSB]));
- /* check for accel frame count*/
- fifo_data->accel_frame_count =
- fifo_data->accel_frame_count + BMI160_FRAME_COUNT;
- v_accel_index_u8++;
- v_mag_index_u8++;
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_MA_OR_MG_LENGTH;
- }
- /* condition for gyro and accel enable*/
- else if (v_data_u8 == BMI160_FIFO_G_A_ENABLE) {
- /* Gyro raw x v_data_u8 */
- fifo_data->gyro_fifo[v_gyro_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_G_X_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_G_X_LSB]));
- /* Gyro raw y v_data_u8 */
- fifo_data->gyro_fifo[v_gyro_index_u8].y =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_G_Y_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_G_Y_LSB]));
- /* Gyro raw z v_data_u8 */
- fifo_data->gyro_fifo[v_gyro_index_u8].z =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_G_Z_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_G_Z_LSB]));
- /* check for gyro frame count*/
- fifo_data->gyro_frame_count =
- fifo_data->gyro_frame_count + BMI160_FRAME_COUNT;
- /* Accel raw x v_data_u8 */
- fifo_data->accel_fifo[v_accel_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_A_X_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_A_X_LSB]));
- /* Accel raw y v_data_u8 */
- fifo_data->accel_fifo[v_accel_index_u8].y =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_A_Y_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_A_Y_LSB]));
- /* Accel raw z v_data_u8 */
- fifo_data->accel_fifo[v_accel_index_u8].z =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_A_Z_MSB])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_GA_FIFO_A_Z_LSB]));
- /* check for accel frame count*/
- fifo_data->accel_frame_count =
- fifo_data->accel_frame_count + BMI160_FRAME_COUNT;
- v_accel_index_u8++;
- v_gyro_index_u8++;
- v_fifo_index_u16 = v_fifo_index_u16 +
- BMI160_FIFO_AG_LENGTH;
- }
- /* condition for gyro enable*/
- else if (v_data_u8 == BMI160_FIFO_GYRO_ENABLE) {
- /* Gyro raw x v_data_u8 */
- fifo_data->gyro_fifo[v_gyro_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16
- + BMI160_FIFO_X_MSB_DATA])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16
- + BMI160_FIFO_X_LSB_DATA]));
- /* Gyro raw y v_data_u8 */
- fifo_data->gyro_fifo[v_gyro_index_u8].y =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16
- + BMI160_FIFO_Y_MSB_DATA])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16
- + BMI160_FIFO_Y_LSB_DATA]));
- /* Gyro raw z v_data_u8 */
- fifo_data->gyro_fifo[v_gyro_index_u8].z =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16
- + BMI160_FIFO_Z_MSB_DATA])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16
- + BMI160_FIFO_Z_LSB_DATA]));
- /* check for gyro frame count*/
- fifo_data->gyro_frame_count =
- fifo_data->gyro_frame_count + BMI160_FRAME_COUNT;
- v_fifo_index_u16 = v_fifo_index_u16 + BMI160_FIFO_G_LENGTH;
- v_gyro_index_u8++;
- }
- /* condition for accel enable*/
- else if (v_data_u8 == BMI160_FIFO_A_ENABLE) {
- /* Accel raw x v_data_u8 */
- fifo_data->accel_fifo[v_accel_index_u8].x =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16
- + BMI160_FIFO_X_MSB_DATA])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 + BMI160_FIFO_X_LSB_DATA]));
- /* Accel raw y v_data_u8 */
- fifo_data->accel_fifo[v_accel_index_u8].y =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16
- + BMI160_FIFO_Y_MSB_DATA])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 + BMI160_FIFO_Y_LSB_DATA]));
- /* Accel raw z v_data_u8 */
- fifo_data->accel_fifo[v_accel_index_u8].z =
- (s16)(((v_fifo_data_u8[v_fifo_index_u16
- + BMI160_FIFO_Z_MSB_DATA])
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- |(v_fifo_data_u8[v_fifo_index_u16 + BMI160_FIFO_Z_LSB_DATA]));
- /* check for accel frame count*/
- fifo_data->accel_frame_count =
- fifo_data->accel_frame_count + BMI160_FRAME_COUNT;
- v_fifo_index_u16 = v_fifo_index_u16 + BMI160_FIFO_A_LENGTH;
- v_accel_index_u8++;
- }
- /* condition for mag enable*/
- else if (v_data_u8 == BMI160_FIFO_M_ENABLE) {
- /* Raw mag x*/
- mag_data.mag_x_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_LSB_DATA]);
- mag_data.mag_x_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_X_MSB_DATA]);
- /* Mag y data*/
- mag_data.mag_y_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_LSB_DATA]);
- mag_data.mag_y_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Y_MSB_DATA]);
- /* Mag z data*/
- mag_data.mag_z_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_LSB_DATA]);
- mag_data.mag_z_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_Z_MSB_DATA]);
- /* Mag r data*/
- mag_data.mag_r_y2_lsb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_LSB_DATA]);
- mag_data.mag_r_y2_msb =
- (v_fifo_data_u8[v_fifo_index_u16 +
- BMI160_FIFO_R_MSB_DATA]);
- com_rslt = bmi160_second_if_mag_compensate_xyz(mag_data,
- v_mag_if_mag_u8);
- /* compensated mag x */
- fifo_data->mag_fifo[v_mag_index_u8].x =
- processed_data.x;
- /* compensated mag y */
- fifo_data->mag_fifo[v_mag_index_u8].y =
- processed_data.y;
- /* compensated mag z */
- fifo_data->mag_fifo[v_mag_index_u8].z =
- processed_data.z;
- /* check for mag frame count*/
- fifo_data->mag_frame_count =
- fifo_data->mag_frame_count + BMI160_FRAME_COUNT;
- v_fifo_index_u16 = v_fifo_index_u16
- + BMI160_FIFO_M_LENGTH;
- v_mag_index_u8++;
- }
- /* condition for fifo over read enable*/
- if (v_fifo_data_u8[v_fifo_index_u16] == FIFO_CONFIG_CHECK1 &&
- v_fifo_data_u8[v_fifo_index_u16 + BMI160_FIFO_INDEX_LENGTH] ==
- FIFO_CONFIG_CHECK2) {
- break;
- }
- }
- return com_rslt;
-}
- /*!
- * @brief This function used for read the compensated value of mag
- * Before start reading the mag compensated data's
- * make sure the following two points are addressed
- * @note
- * 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note
- * 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_compensate_xyz(
-struct bmi160_mag_xyz_s32_t *mag_comp_xyz)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- struct bmi160_mag_xyzr_t mag_xyzr;
-
- com_rslt = bmi160_read_mag_xyzr(&mag_xyzr);
- if (com_rslt)
- return com_rslt;
- /* Compensation for X axis */
- mag_comp_xyz->x = bmi160_bmm150_mag_compensate_X(
- mag_xyzr.x, mag_xyzr.r);
-
- /* Compensation for Y axis */
- mag_comp_xyz->y = bmi160_bmm150_mag_compensate_Y(
- mag_xyzr.y, mag_xyzr.r);
-
- /* Compensation for Z axis */
- mag_comp_xyz->z = bmi160_bmm150_mag_compensate_Z(
- mag_xyzr.z, mag_xyzr.r);
-
- return com_rslt;
-}
-/*!
- * @brief This API used to get the compensated BMM150-X data
- * the out put of X as s32
- * Before start reading the mag compensated X data
- * make sure the following two points are addressed
- * @note
- * 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note
- * 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- *
- * @param v_mag_data_x_s16 : The value of mag raw X data
- * @param v_data_r_u16 : The value of mag R data
- *
- * @return results of compensated X data value output as s32
- *
- */
-s32 bmi160_bmm150_mag_compensate_X(s16 v_mag_data_x_s16, u16 v_data_r_u16)
-{
-s32 inter_retval = BMI160_INIT_VALUE;
-/* no overflow */
-if (v_mag_data_x_s16 != BMI160_MAG_FLIP_OVERFLOW_ADCVAL) {
- if ((v_data_r_u16 != 0)
- || (mag_trim.dig_xyz1 != 0)) {
- inter_retval = ((s32)(((u16)
- ((((s32)mag_trim.dig_xyz1)
- << BMI160_SHIFT_BIT_POSITION_BY_14_BITS)/
- (v_data_r_u16 != 0 ?
- v_data_r_u16 : mag_trim.dig_xyz1))) -
- ((u16)0x4000)));
- } else {
- inter_retval = BMI160_MAG_OVERFLOW_OUTPUT;
- return inter_retval;
- }
- inter_retval = ((s32)((((s32)v_mag_data_x_s16) *
- ((((((((s32)mag_trim.dig_xy2) *
- ((((s32)inter_retval) *
- ((s32)inter_retval))
- >> BMI160_SHIFT_BIT_POSITION_BY_07_BITS)) +
- (((s32)inter_retval) *
- ((s32)(((s16)mag_trim.dig_xy1)
- << BMI160_SHIFT_BIT_POSITION_BY_07_BITS))))
- >> BMI160_SHIFT_BIT_POSITION_BY_09_BITS) +
- ((s32)0x100000)) *
- ((s32)(((s16)mag_trim.dig_x2) +
- ((s16)0xA0))))
- >> BMI160_SHIFT_BIT_POSITION_BY_12_BITS))
- >> BMI160_SHIFT_BIT_POSITION_BY_13_BITS)) +
- (((s16)mag_trim.dig_x1)
- << BMI160_SHIFT_BIT_POSITION_BY_03_BITS);
- /* check the overflow output */
- if (inter_retval == (s32)BMI160_MAG_OVERFLOW_OUTPUT)
- inter_retval = BMI160_MAG_OVERFLOW_OUTPUT_S32;
-} else {
- /* overflow */
- inter_retval = BMI160_MAG_OVERFLOW_OUTPUT;
-}
-return inter_retval;
-}
-/*!
- * @brief This API used to get the compensated BMM150-Y data
- * the out put of Y as s32
- * Before start reading the mag compensated Y data
- * make sure the following two points are addressed
- * @note
- * 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note
- * 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- *
- * @param v_mag_data_y_s16 : The value of mag raw Y data
- * @param v_data_r_u16 : The value of mag R data
- *
- * @return results of compensated Y data value output as s32
- */
-s32 bmi160_bmm150_mag_compensate_Y(s16 v_mag_data_y_s16, u16 v_data_r_u16)
-{
-s32 inter_retval = BMI160_INIT_VALUE;
-/* no overflow */
-if (v_mag_data_y_s16 != BMI160_MAG_FLIP_OVERFLOW_ADCVAL) {
- if ((v_data_r_u16 != 0)
- || (mag_trim.dig_xyz1 != 0)) {
- inter_retval = ((s32)(((u16)(((
- (s32)mag_trim.dig_xyz1)
- << BMI160_SHIFT_BIT_POSITION_BY_14_BITS) /
- (v_data_r_u16 != 0 ?
- v_data_r_u16 : mag_trim.dig_xyz1))) -
- ((u16)0x4000)));
- } else {
- inter_retval = BMI160_MAG_OVERFLOW_OUTPUT;
- return inter_retval;
- }
- inter_retval = ((s32)((((s32)v_mag_data_y_s16) * ((((((((s32)
- mag_trim.dig_xy2) * ((((s32) inter_retval) *
- ((s32)inter_retval)) >> BMI160_SHIFT_BIT_POSITION_BY_07_BITS))
- + (((s32)inter_retval) *
- ((s32)(((s16)mag_trim.dig_xy1)
- << BMI160_SHIFT_BIT_POSITION_BY_07_BITS))))
- >> BMI160_SHIFT_BIT_POSITION_BY_09_BITS) +
- ((s32)0x100000))
- * ((s32)(((s16)mag_trim.dig_y2)
- + ((s16)0xA0))))
- >> BMI160_SHIFT_BIT_POSITION_BY_12_BITS))
- >> BMI160_SHIFT_BIT_POSITION_BY_13_BITS)) +
- (((s16)mag_trim.dig_y1)
- << BMI160_SHIFT_BIT_POSITION_BY_03_BITS);
- /* check the overflow output */
- if (inter_retval == (s32)BMI160_MAG_OVERFLOW_OUTPUT)
- inter_retval = BMI160_MAG_OVERFLOW_OUTPUT_S32;
-} else {
- /* overflow */
- inter_retval = BMI160_MAG_OVERFLOW_OUTPUT;
-}
-return inter_retval;
-}
-/*!
- * @brief This API used to get the compensated BMM150-Z data
- * the out put of Z as s32
- * Before start reading the mag compensated Z data
- * make sure the following two points are addressed
- * @note
- * 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note
- * 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- *
- * @param v_mag_data_z_s16 : The value of mag raw Z data
- * @param v_data_r_u16 : The value of mag R data
- *
- * @return results of compensated Z data value output as s32
- */
-s32 bmi160_bmm150_mag_compensate_Z(s16 v_mag_data_z_s16, u16 v_data_r_u16)
-{
- s32 retval = BMI160_INIT_VALUE;
-
- if (v_mag_data_z_s16 != BMI160_MAG_HALL_OVERFLOW_ADCVAL) {
- if ((v_data_r_u16 != 0)
- && (mag_trim.dig_z2 != 0)
- && (mag_trim.dig_z1 != 0)) {
- retval = (((((s32)(v_mag_data_z_s16 - mag_trim.dig_z4))
- << BMI160_SHIFT_BIT_POSITION_BY_15_BITS) -
- ((((s32)mag_trim.dig_z3) *
- ((s32)(((s16)v_data_r_u16) -
- ((s16)mag_trim.dig_xyz1))))
- >> BMI160_SHIFT_BIT_POSITION_BY_02_BITS))/
- (mag_trim.dig_z2 +
- ((s16)(((((s32)mag_trim.dig_z1) *
- ((((s16)v_data_r_u16)
- << BMI160_SHIFT_BIT_POSITION_BY_01_BIT))) +
- (1 << BMI160_SHIFT_BIT_POSITION_BY_15_BITS))
- >> BMI160_SHIFT_BIT_POSITION_BY_16_BITS))));
- }
- } else {
- retval = BMI160_MAG_OVERFLOW_OUTPUT;
- }
- return retval;
-}
- /*!
- * @brief This function used for initialize the bmm150 sensor
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_interface_init(u8 *v_chip_id_u8)
-{
- /* This variable used for provide the communication
- results*/
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
- u8 v_pull_value_u8 = BMI160_INIT_VALUE;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- /* accel operation mode to normal*/
- com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* write the mag power mode as NORMAL*/
- com_rslt += bmi160_set_mag_interface_normal();
- /* register 0x7E write the 0x37, 0x9A and 0x30*/
- com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_ONE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_TWO);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_THREE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /*switch the page1*/
- com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE1);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_target_page(&v_data_u8);
- com_rslt += bmi160_set_paging_enable(BMI160_WRITE_ENABLE_PAGE1);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_paging_enable(&v_data_u8);
- /* enable the pullup configuration from
- the register 0x05 bit 4 and 5 as 10*/
- bmi160_get_pullup_configuration(&v_pull_value_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- v_pull_value_u8 = v_pull_value_u8 | BMI160_PULL_UP_DATA;
- com_rslt += bmi160_set_pullup_configuration(v_pull_value_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /*switch the page0*/
- com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE0);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_target_page(&v_data_u8);
- /* Write the BMM150 i2c address*/
- com_rslt += bmi160_set_i2c_device_addr(BMI160_AUX_BMM150_I2C_ADDRESS);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* enable the mag interface to manual mode*/
- com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_mag_manual_enable(&v_data_u8);
- /*Enable the MAG interface */
- com_rslt += bmi160_set_if_mode(BMI160_ENABLE_MAG_IF_MODE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_if_mode(&v_data_u8);
- /* Mag normal mode*/
- com_rslt += bmi160_bmm150_mag_wakeup();
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* Read the BMM150 device id is 0x32*/
- com_rslt += bmi160_set_mag_read_addr(BMI160_BMM150_CHIP_ID);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- *v_chip_id_u8 = v_data_u8;
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* write the power mode register*/
- com_rslt += bmi160_set_mag_write_data(BMI160_BMM_POWER_MODE_REG);
- /*write 0x4C register to write set power mode to normal*/
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_POWE_MODE_REG);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* read the mag trim values*/
- com_rslt += bmi160_read_bmm150_mag_trim();
- /* To avoid the auto mode enable when manual mode operation running*/
- V_bmm150_maual_auto_condition_u8 = BMI160_MANUAL_ENABLE;
- /* write the XY and Z repetitions*/
- com_rslt += bmi160_set_bmm150_mag_presetmode(
- BMI160_MAG_PRESETMODE_REGULAR);
- /* To avoid the auto mode enable when manual mode operation running*/
- V_bmm150_maual_auto_condition_u8 = BMI160_MANUAL_DISABLE;
- /* Set the power mode of mag as force mode*/
- /* The data have to write for the register
- It write the value in the register 0x4F */
- com_rslt += bmi160_set_mag_write_data(BMI160_BMM150_FORCE_MODE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* write into power mode register*/
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_POWE_MODE_REG);
- /* write the mag v_data_bw_u8 as 25Hz*/
- com_rslt += bmi160_set_mag_output_data_rate(
- BMI160_MAG_OUTPUT_DATA_RATE_25HZ);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
- /* When mag interface is auto mode - The mag read address
- starts the register 0x42*/
- com_rslt += bmi160_set_mag_read_addr(
- BMI160_BMM150_DATA_REG);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* enable mag interface to auto mode*/
- com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_DISABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_mag_manual_enable(&v_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
- return com_rslt;
-}
- /*!
- * @brief This function used for set the mag power control
- * bit enable
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_wakeup(void)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
- u8 v_try_times_u8 = BMI160_BMM150_MAX_RETRY_WAKEUP;
- u8 v_power_control_bit_u8 = BMI160_INIT_VALUE;
- u8 i = BMI160_INIT_VALUE;
-
- for (i = BMI160_INIT_VALUE; i < v_try_times_u8; i++) {
- com_rslt = bmi160_set_mag_write_data(BMI160_BMM150_POWER_ON);
- p_bmi160->delay_msec(BMI160_BMM150_WAKEUP_DELAY1);
- /*write 0x4B register to enable power control bit*/
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_POWE_CONTROL_REG);
- p_bmi160->delay_msec(BMI160_BMM150_WAKEUP_DELAY2);
- com_rslt += bmi160_set_mag_read_addr(
- BMI160_BMM150_POWE_CONTROL_REG);
- /* 0x04 is secondary read mag x lsb register */
- p_bmi160->delay_msec(BMI160_BMM150_WAKEUP_DELAY3);
- com_rslt += bmi160_read_reg(BMI160_USER_DATA_0_ADDR,
- &v_power_control_bit_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- v_power_control_bit_u8 = BMI160_BMM150_SET_POWER_CONTROL
- & v_power_control_bit_u8;
- if (v_power_control_bit_u8 == BMI160_BMM150_POWER_ON)
- break;
- }
- com_rslt = (i >= v_try_times_u8) ?
- BMI160_BMM150_POWER_ON_FAIL : BMI160_BMM150_POWER_ON_SUCCESS;
- return com_rslt;
-}
- /*!
- * @brief This function used for set the magnetometer
- * power mode.
- * @note
- * Before set the mag power mode
- * make sure the following two point is addressed
- * Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- *
- * @param v_mag_sec_if_pow_mode_u8 : The value of mag power mode
- * value | mode
- * ----------|------------
- * 0 | BMI160_MAG_FORCE_MODE
- * 1 | BMI160_MAG_SUSPEND_MODE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_bmm150_mag_and_secondary_if_power_mode(
-u8 v_mag_sec_if_pow_mode_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = BMI160_INIT_VALUE;
- /* set the accel power mode to NORMAL*/
- com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* set mag interface manual mode*/
- if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE) {
- com_rslt += bmi160_set_mag_manual_enable(
- BMI160_MANUAL_ENABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- }
- switch (v_mag_sec_if_pow_mode_u8) {
- case BMI160_MAG_FORCE_MODE:
- /* set the secondary mag power mode as NORMAL*/
- com_rslt += bmi160_set_mag_interface_normal();
- /* set the mag power mode as FORCE mode*/
- com_rslt += bmi160_bmm150_mag_set_power_mode(FORCE_MODE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- break;
- case BMI160_MAG_SUSPEND_MODE:
- /* set the mag power mode as SUSPEND mode*/
- com_rslt += bmi160_bmm150_mag_set_power_mode(SUSPEND_MODE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* set the secondary mag power mode as SUSPEND*/
- com_rslt += bmi160_set_command_register(MAG_MODE_SUSPEND);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE) {
- /* set mag interface auto mode*/
- com_rslt += bmi160_set_mag_manual_enable(
- BMI160_MANUAL_DISABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- }
- return com_rslt;
-}
-/*!
- * @brief This function used for set the magnetometer
- * power mode.
- * @note
- * Before set the mag power mode
- * make sure the following two points are addressed
- * @note
- * 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note
- * 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- * @param v_mag_pow_mode_u8 : The value of mag power mode
- * value | mode
- * ----------|------------
- * 0 | FORCE_MODE
- * 1 | SUSPEND_MODE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_set_power_mode(
-u8 v_mag_pow_mode_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* set mag interface manual mode*/
- if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE) {
- com_rslt = bmi160_set_mag_manual_enable(
- BMI160_MANUAL_ENABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- if (com_rslt != SUCCESS)
- return com_rslt;
-
- }
- switch (v_mag_pow_mode_u8) {
- case FORCE_MODE:
- /* Set the power control bit enabled */
- com_rslt = bmi160_bmm150_mag_wakeup();
- /* write the mag power mode as FORCE mode*/
- com_rslt += bmi160_set_mag_write_data(
- BMI160_BMM150_FORCE_MODE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_POWE_MODE_REG);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /* To avoid the auto mode enable when manual
- mode operation running*/
- V_bmm150_maual_auto_condition_u8 = BMI160_MANUAL_ENABLE;
- /* set the preset mode */
- com_rslt += bmi160_set_bmm150_mag_presetmode(
- BMI160_MAG_PRESETMODE_REGULAR);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* To avoid the auto mode enable when manual
- mode operation running*/
- V_bmm150_maual_auto_condition_u8 = BMI160_MANUAL_DISABLE;
- /* set the mag read address to data registers*/
- com_rslt += bmi160_set_mag_read_addr(
- BMI160_BMM150_DATA_REG);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- break;
- case SUSPEND_MODE:
- /* Set the power mode of mag as suspend mode*/
- com_rslt = bmi160_set_mag_write_data(
- BMI160_BMM150_POWER_OFF);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_POWE_CONTROL_REG);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- /* set mag interface auto mode*/
- if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE) {
- com_rslt += bmi160_set_mag_manual_enable(
- BMI160_MANUAL_DISABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- }
- return com_rslt;
-}
-/*!
- * @brief This API used to set the pre-set modes of bmm150
- * The pre-set mode setting is depend on data rate and xy and z repetitions
- *
- * @note
- * Before set the mag preset mode
- * make sure the following two points are addressed
- * @note
- * 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note
- * 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- * @param v_mode_u8: The value of pre-set mode selection value
- * value | pre_set mode
- * ----------|------------
- * 1 | BMI160_MAG_PRESETMODE_LOWPOWER
- * 2 | BMI160_MAG_PRESETMODE_REGULAR
- * 3 | BMI160_MAG_PRESETMODE_HIGHACCURACY
- * 4 | BMI160_MAG_PRESETMODE_ENHANCED
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_bmm150_mag_presetmode(u8 v_mode_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* set mag interface manual mode*/
- if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
- com_rslt = bmi160_set_mag_manual_enable(
- BMI160_MANUAL_ENABLE);
- switch (v_mode_u8) {
- case BMI160_MAG_PRESETMODE_LOWPOWER:
- /* write the XY and Z repetitions*/
- /* The v_data_u8 have to write for the register
- It write the value in the register 0x4F*/
- com_rslt = bmi160_set_mag_write_data(
- BMI160_MAG_LOWPOWER_REPXY);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_XY_REP);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* write the Z repetitions*/
- /* The v_data_u8 have to write for the register
- It write the value in the register 0x4F*/
- com_rslt += bmi160_set_mag_write_data(
- BMI160_MAG_LOWPOWER_REPZ);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_Z_REP);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* set the mag v_data_u8 rate as 10 to the register 0x4C*/
- com_rslt += bmi160_set_mag_write_data(
- BMI160_MAG_LOWPOWER_DR);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_POWE_MODE_REG);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- break;
- case BMI160_MAG_PRESETMODE_REGULAR:
- /* write the XY and Z repetitions*/
- /* The v_data_u8 have to write for the register
- It write the value in the register 0x4F*/
- com_rslt = bmi160_set_mag_write_data(
- BMI160_MAG_REGULAR_REPXY);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_XY_REP);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* write the Z repetitions*/
- /* The v_data_u8 have to write for the register
- It write the value in the register 0x4F*/
- com_rslt += bmi160_set_mag_write_data(
- BMI160_MAG_REGULAR_REPZ);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_Z_REP);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* set the mag v_data_u8 rate as 10 to the register 0x4C*/
- com_rslt += bmi160_set_mag_write_data(
- BMI160_MAG_REGULAR_DR);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_POWE_MODE_REG);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- break;
- case BMI160_MAG_PRESETMODE_HIGHACCURACY:
- /* write the XY and Z repetitions*/
- /* The v_data_u8 have to write for the register
- It write the value in the register 0x4F*/
- com_rslt = bmi160_set_mag_write_data(
- BMI160_MAG_HIGHACCURACY_REPXY);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_XY_REP);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* write the Z repetitions*/
- /* The v_data_u8 have to write for the register
- It write the value in the register 0x4F*/
- com_rslt += bmi160_set_mag_write_data(
- BMI160_MAG_HIGHACCURACY_REPZ);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_Z_REP);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* set the mag v_data_u8 rate as 20 to the register 0x4C*/
- com_rslt += bmi160_set_mag_write_data(
- BMI160_MAG_HIGHACCURACY_DR);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_POWE_MODE_REG);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- break;
- case BMI160_MAG_PRESETMODE_ENHANCED:
- /* write the XY and Z repetitions*/
- /* The v_data_u8 have to write for the register
- It write the value in the register 0x4F*/
- com_rslt = bmi160_set_mag_write_data(
- BMI160_MAG_ENHANCED_REPXY);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_XY_REP);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* write the Z repetitions*/
- /* The v_data_u8 have to write for the register
- It write the value in the register 0x4F*/
- com_rslt += bmi160_set_mag_write_data(
- BMI160_MAG_ENHANCED_REPZ);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_Z_REP);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* set the mag v_data_u8 rate as 10 to the register 0x4C*/
- com_rslt += bmi160_set_mag_write_data(
- BMI160_MAG_ENHANCED_DR);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_POWE_MODE_REG);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- if (V_bmm150_maual_auto_condition_u8 == BMI160_MANUAL_DISABLE) {
- com_rslt += bmi160_set_mag_write_data(
- BMI160_BMM150_FORCE_MODE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_BMM150_POWE_MODE_REG);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_read_addr(BMI160_BMM150_DATA_REG);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* set mag interface auto mode*/
- if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
- com_rslt = bmi160_set_mag_manual_enable(
- BMI160_MANUAL_DISABLE);
- }
- return com_rslt;
-}
- /*!
- * @brief This function used for read the trim values of magnetometer
- *
- * @note
- * Before reading the mag trimming values
- * make sure the following two points are addressed
- * @note
- * 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note
- * 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_bmm150_mag_trim(void)
-{
- /* This variable used for provide the communication
- results*/
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array holding the bmm150 trim data
- */
- u8 v_data_u8[BMI160_MAG_TRIM_DATA_SIZE] = {
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE};
- /* read dig_x1 value */
- com_rslt = bmi160_set_mag_read_addr(
- BMI160_MAG_DIG_X1);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_X1],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- mag_trim.dig_x1 = v_data_u8[BMI160_BMM150_DIG_X1];
- /* read dig_y1 value */
- com_rslt += bmi160_set_mag_read_addr(
- BMI160_MAG_DIG_Y1);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_Y1],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- mag_trim.dig_y1 = v_data_u8[BMI160_BMM150_DIG_Y1];
-
- /* read dig_x2 value */
- com_rslt += bmi160_set_mag_read_addr(
- BMI160_MAG_DIG_X2);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_X2],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- mag_trim.dig_x2 = v_data_u8[BMI160_BMM150_DIG_X2];
- /* read dig_y2 value */
- com_rslt += bmi160_set_mag_read_addr(
- BMI160_MAG_DIG_Y2);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_Y3],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- mag_trim.dig_y2 = v_data_u8[BMI160_BMM150_DIG_Y3];
-
- /* read dig_xy1 value */
- com_rslt += bmi160_set_mag_read_addr(
- BMI160_MAG_DIG_XY1);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_XY1],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- mag_trim.dig_xy1 = v_data_u8[BMI160_BMM150_DIG_XY1];
- /* read dig_xy2 value */
- com_rslt += bmi160_set_mag_read_addr(
- BMI160_MAG_DIG_XY2);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is v_mag_x_s16 ls register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_XY2],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- mag_trim.dig_xy2 = v_data_u8[BMI160_BMM150_DIG_XY2];
-
- /* read dig_z1 lsb value */
- com_rslt += bmi160_set_mag_read_addr(
- BMI160_MAG_DIG_Z1_LSB);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_Z1_LSB],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* read dig_z1 msb value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z1_MSB);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is v_mag_x_s16 msb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_Z1_MSB],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- mag_trim.dig_z1 =
- (u16)((((u32)((u8)v_data_u8[BMI160_BMM150_DIG_Z1_MSB]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
- (v_data_u8[BMI160_BMM150_DIG_Z1_LSB]));
-
- /* read dig_z2 lsb value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z2_LSB);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_Z2_LSB],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* read dig_z2 msb value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z2_MSB);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is v_mag_x_s16 msb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_Z2_MSB],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- mag_trim.dig_z2 =
- (s16)((((s32)((s8)v_data_u8[BMI160_BMM150_DIG_Z2_MSB]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
- (v_data_u8[BMI160_BMM150_DIG_Z2_LSB]));
-
- /* read dig_z3 lsb value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z3_LSB);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_DIG_Z3_LSB],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* read dig_z3 msb value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z3_MSB);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is v_mag_x_s16 msb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_DIG_Z3_MSB],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- mag_trim.dig_z3 =
- (s16)((((s32)((s8)v_data_u8[BMI160_BMM150_DIG_DIG_Z3_MSB]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
- (v_data_u8[BMI160_BMM150_DIG_DIG_Z3_LSB]));
- /* read dig_z4 lsb value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z4_LSB);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_DIG_Z4_LSB],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* read dig_z4 msb value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_Z4_MSB);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is v_mag_x_s16 msb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_DIG_Z4_MSB],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- mag_trim.dig_z4 =
- (s16)((((s32)((s8)v_data_u8[BMI160_BMM150_DIG_DIG_Z4_MSB]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
- (v_data_u8[BMI160_BMM150_DIG_DIG_Z4_LSB]));
-
- /* read dig_xyz1 lsb value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_XYZ1_LSB);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_DIG_XYZ1_LSB],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* read dig_xyz1 msb value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_MAG_DIG_XYZ1_MSB);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is v_mag_x_s16 msb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[BMI160_BMM150_DIG_DIG_XYZ1_MSB],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- mag_trim.dig_xyz1 =
- (u16)((((u32)((u8)v_data_u8[BMI160_BMM150_DIG_DIG_XYZ1_MSB]))
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) |
- (v_data_u8[BMI160_BMM150_DIG_DIG_XYZ1_LSB]));
-
- return com_rslt;
-}
- /*!
- * @brief This function used for initialize
- * the AKM09911 and AKM09912 sensor
- *
- *
- * @param v_akm_i2c_address_u8: The value of device address
- * AKM sensor | Slave address
- * --------------|---------------------
- * AKM09911 | AKM09911_I2C_ADDR_1
- * - | and AKM09911_I2C_ADDR_2
- * AKM09912 | AKM09912_I2C_ADDR_1
- * - | AKM09912_I2C_ADDR_2
- * - | AKM09912_I2C_ADDR_3
- * - | AKM09912_I2C_ADDR_4
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm_mag_interface_init(
-u8 v_akm_i2c_address_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_pull_value_u8 = BMI160_INIT_VALUE;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- u8 v_akm_chip_id_u8 = BMI160_INIT_VALUE;
- /* accel operation mode to normal*/
- com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_command_register(MAG_MODE_NORMAL);
- p_bmi160->delay_msec(BMI160_AKM_INIT_DELAY);
- bmi160_get_mag_power_mode_stat(&v_data_u8);
- /* register 0x7E write the 0x37, 0x9A and 0x30*/
- com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_ONE);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_TWO);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_THREE);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /*switch the page1*/
- com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE1);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_target_page(&v_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_paging_enable(BMI160_WRITE_ENABLE_PAGE1);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_paging_enable(&v_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* enable the pullup configuration from
- the register 0x05 bit 4 and 5 to 10*/
- bmi160_get_pullup_configuration(&v_pull_value_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- v_pull_value_u8 = v_pull_value_u8 | BMI160_PULL_UP_DATA;
- com_rslt += bmi160_set_pullup_configuration(v_pull_value_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
- /*switch the page0*/
- com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE0);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_target_page(&v_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* Write the AKM09911 0r AKM09912 i2c address*/
- com_rslt += bmi160_set_i2c_device_addr(v_akm_i2c_address_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* enable the mag interface to manual mode*/
- com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_mag_manual_enable(&v_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /*Enable the MAG interface */
- com_rslt += bmi160_set_if_mode(BMI160_ENABLE_MAG_IF_MODE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_if_mode(&v_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
- /* Set the AKM Fuse ROM mode */
- /* Set value for fuse ROM mode*/
- com_rslt += bmi160_set_mag_write_data(AKM_FUSE_ROM_MODE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* AKM mode address is 0x31*/
- com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /* Read the Fuse ROM v_data_u8 from registers
- 0x60,0x61 and 0x62*/
- /* ASAX v_data_u8 */
- com_rslt += bmi160_read_bst_akm_sensitivity_data();
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /* read the device id of the AKM sensor
- if device id is 0x05 - AKM09911
- if device id is 0x04 - AKM09912*/
- com_rslt += bmi160_set_mag_read_addr(AKM_CHIP_ID_REG);
- /* 0x04 is mag_x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_akm_chip_id_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* Set value power down mode mode*/
- com_rslt += bmi160_set_mag_write_data(AKM_POWER_DOWN_MODE_DATA);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* AKM mode address is 0x31*/
- com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /* Set AKM Force mode*/
- com_rslt += bmi160_set_mag_write_data(
- AKM_SINGLE_MEASUREMENT_MODE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* AKM mode address is 0x31*/
- com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /* Set the AKM read xyz v_data_u8 address*/
- com_rslt += bmi160_set_mag_read_addr(AKM_DATA_REGISTER);
- /* write the mag v_data_bw_u8 as 25Hz*/
- com_rslt += bmi160_set_mag_output_data_rate(
- BMI160_MAG_OUTPUT_DATA_RATE_25HZ);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* Enable mag interface to auto mode*/
- com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_DISABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_mag_manual_enable(&v_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
- return com_rslt;
-}
- /*!
- * @brief This function used for read the sensitivity data of
- * AKM09911 and AKM09912
- *
- * @note Before reading the mag sensitivity values
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_bst_akm_sensitivity_data(void)
-{
- /* This variable used for provide the communication
- results*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array holding the sensitivity ax,ay and az data*/
- u8 v_data_u8[BMI160_AKM_SENSITIVITY_DATA_SIZE] = {
- BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- /* read asax value */
- com_rslt = bmi160_set_mag_read_addr(BMI160_BST_AKM_ASAX);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[AKM_ASAX],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- akm_asa_data.asax = v_data_u8[AKM_ASAX];
- /* read asay value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_BST_AKM_ASAY);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[AKM_ASAY],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- akm_asa_data.asay = v_data_u8[AKM_ASAY];
- /* read asaz value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_BST_AKM_ASAZ);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[AKM_ASAZ],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- akm_asa_data.asaz = v_data_u8[AKM_ASAZ];
-
- return com_rslt;
-}
-/*!
- * @brief This API used to get the compensated X data
- * of AKM09911 the out put of X as s32
- * @note Before start reading the mag compensated X data
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- * @param v_bst_akm_x_s16 : The value of X data
- *
- * @return results of compensated X data value output as s32
- *
- */
-s32 bmi160_bst_akm09911_compensate_X(s16 v_bst_akm_x_s16)
-{
- /*Return value of AKM x compensated v_data_u8*/
- s32 retval = BMI160_INIT_VALUE;
- /* Convert raw v_data_u8 into compensated v_data_u8*/
- retval = (v_bst_akm_x_s16 *
- ((akm_asa_data.asax/AKM09911_SENSITIVITY_DIV) +
- BMI160_GEN_READ_WRITE_DATA_LENGTH));
- return retval;
-}
-/*!
- * @brief This API used to get the compensated Y data
- * of AKM09911 the out put of Y as s32
- * @note Before start reading the mag compensated Y data
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- * @param v_bst_akm_y_s16 : The value of Y data
- *
- * @return results of compensated Y data value output as s32
- *
- */
-s32 bmi160_bst_akm09911_compensate_Y(s16 v_bst_akm_y_s16)
-{
- /*Return value of AKM y compensated v_data_u8*/
- s32 retval = BMI160_INIT_VALUE;
- /* Convert raw v_data_u8 into compensated v_data_u8*/
- retval = (v_bst_akm_y_s16 *
- ((akm_asa_data.asay/AKM09911_SENSITIVITY_DIV) +
- BMI160_GEN_READ_WRITE_DATA_LENGTH));
- return retval;
-}
-/*!
- * @brief This API used to get the compensated Z data
- * of AKM09911 the out put of Z as s32
- * @note Before start reading the mag compensated Z data
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- * @param v_bst_akm_z_s16 : The value of Z data
- *
- * @return results of compensated Z data value output as s32
- *
- */
-s32 bmi160_bst_akm09911_compensate_Z(s16 v_bst_akm_z_s16)
-{
- /*Return value of AKM z compensated v_data_u8*/
- s32 retval = BMI160_INIT_VALUE;
- /* Convert raw v_data_u8 into compensated v_data_u8*/
- retval = (v_bst_akm_z_s16 *
- ((akm_asa_data.asaz/AKM09911_SENSITIVITY_DIV) +
- BMI160_GEN_READ_WRITE_DATA_LENGTH));
- return retval;
-}
-/*!
- * @brief This API used to get the compensated X data
- * of AKM09912 the out put of X as s32
- * @note Before start reading the mag compensated X data
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- * @param v_bst_akm_x_s16 : The value of X data
- *
- * @return results of compensated X data value output as s32
- *
- */
-s32 bmi160_bst_akm09912_compensate_X(s16 v_bst_akm_x_s16)
-{
- /*Return value of AKM x compensated data*/
- s32 retval = BMI160_INIT_VALUE;
- /* Convert raw data into compensated data*/
- retval = v_bst_akm_x_s16 *
- (akm_asa_data.asax + AKM09912_SENSITIVITY)
- / AKM09912_SENSITIVITY_DIV;
- return retval;
-}
-/*!
- * @brief This API used to get the compensated Y data
- * of AKM09912 the out put of Y as s32
- * @note Before start reading the mag compensated Y data
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- * @param v_bst_akm_y_s16 : The value of Y data
- *
- * @return results of compensated Y data value output as s32
- *
- */
-s32 bmi160_bst_akm09912_compensate_Y(s16 v_bst_akm_y_s16)
-{
- /*Return value of AKM y compensated data*/
- s32 retval = BMI160_INIT_VALUE;
- /* Convert raw data into compensated data*/
- retval = v_bst_akm_y_s16 *
- (akm_asa_data.asax + AKM09912_SENSITIVITY)
- / AKM09912_SENSITIVITY_DIV;
- return retval;
-}
-/*!
- * @brief This API used to get the compensated Z data
- * of AKM09912 the out put of Z as s32
- * @note Before start reading the mag compensated Z data
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- * @param v_bst_akm_z_s16 : The value of Z data
- *
- * @return results of compensated Z data value output as s32
- *
- */
-s32 bmi160_bst_akm09912_compensate_Z(s16 v_bst_akm_z_s16)
-{
- /*Return value of AKM z compensated data*/
- s32 retval = BMI160_INIT_VALUE;
- /* Convert raw data into compensated data*/
- retval = v_bst_akm_z_s16 *
- (akm_asa_data.asax + AKM09912_SENSITIVITY)
- / AKM09912_SENSITIVITY_DIV;
- return retval;
-}
- /*!
- * @brief This function used for read the compensated value of
- * AKM09911
- * @note Before start reading the mag compensated data's
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
-
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm09911_compensate_xyz(
-struct bmi160_bst_akm_xyz_t *bst_akm_xyz)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- struct bmi160_mag_t mag_xyz;
-
- com_rslt = bmi160_read_mag_xyz(&mag_xyz, BST_AKM);
- /* Compensation for X axis */
- bst_akm_xyz->x = bmi160_bst_akm09911_compensate_X(mag_xyz.x);
-
- /* Compensation for Y axis */
- bst_akm_xyz->y = bmi160_bst_akm09911_compensate_Y(mag_xyz.y);
-
- /* Compensation for Z axis */
- bst_akm_xyz->z = bmi160_bst_akm09911_compensate_Z(mag_xyz.z);
-
- return com_rslt;
-}
- /*!
- * @brief This function used for read the compensated value of
- * AKM09912
- * @note Before start reading the mag compensated data's
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
-
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm09912_compensate_xyz(
-struct bmi160_bst_akm_xyz_t *bst_akm_xyz)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- struct bmi160_mag_t mag_xyz;
-
- com_rslt = bmi160_read_mag_xyz(&mag_xyz, BST_AKM);
- /* Compensation for X axis */
- bst_akm_xyz->x = bmi160_bst_akm09912_compensate_X(mag_xyz.x);
-
- /* Compensation for Y axis */
- bst_akm_xyz->y = bmi160_bst_akm09912_compensate_Y(mag_xyz.y);
-
- /* Compensation for Z axis */
- bst_akm_xyz->z = bmi160_bst_akm09912_compensate_Z(mag_xyz.z);
-
- return com_rslt;
-}
-/*!
- * @brief This function used for set the AKM09911 and AKM09912
- * power mode.
- * @note Before set the AKM power mode
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- * @param v_akm_pow_mode_u8 : The value of akm power mode
- * value | Description
- * ---------|--------------------
- * 0 | AKM_POWER_DOWN_MODE
- * 1 | AKM_SINGLE_MEAS_MODE
- * 2 | FUSE_ROM_MODE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm_set_powermode(
-u8 v_akm_pow_mode_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* set mag interface manual mode*/
- if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE) {
- com_rslt = bmi160_set_mag_manual_enable(
- BMI160_MANUAL_ENABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- }
- switch (v_akm_pow_mode_u8) {
- case AKM_POWER_DOWN_MODE:
- /* Set the power mode of AKM as power down mode*/
- com_rslt += bmi160_set_mag_write_data(AKM_POWER_DOWN_MODE_DATA);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- break;
- case AKM_SINGLE_MEAS_MODE:
- /* Set the power mode of AKM as
- single measurement mode*/
- com_rslt += bmi160_set_mag_write_data
- (AKM_SINGLE_MEASUREMENT_MODE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_read_addr(AKM_DATA_REGISTER);
- break;
- case FUSE_ROM_MODE:
- /* Set the power mode of AKM as
- Fuse ROM mode*/
- com_rslt += bmi160_set_mag_write_data(AKM_FUSE_ROM_MODE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /* Sensitivity v_data_u8 */
- com_rslt += bmi160_read_bst_akm_sensitivity_data();
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /* power down mode*/
- com_rslt += bmi160_set_mag_write_data(AKM_POWER_DOWN_MODE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(AKM_POWER_MODE_REG);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- /* set mag interface auto mode*/
- if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE) {
- com_rslt += bmi160_set_mag_manual_enable(
- BMI160_MANUAL_DISABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- }
- return com_rslt;
-}
- /*!
- * @brief This function used for set the magnetometer
- * power mode of AKM09911 and AKM09912
- * @note Before set the mag power mode
- * make sure the following two point is addressed
- * Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- *
- * @param v_mag_sec_if_pow_mode_u8 : The value of secondary if power mode
- * value | Description
- * ---------|--------------------
- * 0 | BMI160_MAG_FORCE_MODE
- * 1 | BMI160_MAG_SUSPEND_MODE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_bst_akm_and_secondary_if_powermode(
-u8 v_mag_sec_if_pow_mode_u8)
-{
- /* variable used for return the status of communication result*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* accel operation mode to normal*/
- com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* set mag interface manual mode*/
- if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE) {
- com_rslt = bmi160_set_mag_manual_enable(
- BMI160_MANUAL_ENABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- }
- switch (v_mag_sec_if_pow_mode_u8) {
- case BMI160_MAG_FORCE_MODE:
- /* set the secondary mag power mode as NORMAL*/
- com_rslt += bmi160_set_mag_interface_normal();
- /* set the akm power mode as single measurement mode*/
- com_rslt += bmi160_bst_akm_set_powermode(AKM_SINGLE_MEAS_MODE);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_read_addr(AKM_DATA_REGISTER);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- break;
- case BMI160_MAG_SUSPEND_MODE:
- /* set the akm power mode as power down mode*/
- com_rslt += bmi160_bst_akm_set_powermode(AKM_POWER_DOWN_MODE);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /* set the secondary mag power mode as SUSPEND*/
- com_rslt += bmi160_set_command_register(MAG_MODE_SUSPEND);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- break;
- default:
- com_rslt = E_BMI160_OUT_OF_RANGE;
- break;
- }
- /* set mag interface auto mode*/
- if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
- com_rslt += bmi160_set_mag_manual_enable(
- BMI160_MANUAL_DISABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- return com_rslt;
-}
-/*!
- * @brief This function used for read the YAMAH-YAS532 init
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas532_mag_interface_init(
-void)
-{
- /* This variable used for provide the communication
- results*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- u8 v_pull_value_u8 = BMI160_INIT_VALUE;
- u8 v_data_u8 = BMI160_INIT_VALUE;
- u8 i = BMI160_INIT_VALUE;
- /* accel operation mode to normal*/
- com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* write mag power mode as NORMAL*/
- com_rslt += bmi160_set_mag_interface_normal();
- /* register 0x7E write the 0x37, 0x9A and 0x30*/
- com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_ONE);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_TWO);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_THREE);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /*switch the page1*/
- com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE1);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_target_page(&v_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_paging_enable(BMI160_WRITE_ENABLE_PAGE1);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_paging_enable(&v_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* enable the pullup configuration from
- the register 0x05 bit 4 and 5 as 10*/
- bmi160_get_pullup_configuration(&v_pull_value_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- v_pull_value_u8 = v_pull_value_u8 | BMI160_PULL_UP_DATA;
- com_rslt += bmi160_set_pullup_configuration(v_pull_value_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /*switch the page0*/
- com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE0);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_target_page(&v_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* Write the YAS532 i2c address*/
- com_rslt += bmi160_set_i2c_device_addr(BMI160_AUX_YAS532_I2C_ADDRESS);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* enable the mag interface to manual mode*/
- com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_mag_manual_enable(&v_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /*Enable the MAG interface */
- com_rslt += bmi160_set_if_mode(BMI160_ENABLE_MAG_IF_MODE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_if_mode(&v_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- v_data_u8 = BMI160_MANUAL_DISABLE;
- /* Read the YAS532 device id is 0x02*/
- com_rslt += bmi160_set_mag_read_addr(BMI160_YAS_DEVICE_ID_REG);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* Read the YAS532 calibration data*/
- com_rslt += bmi160_bst_yamaha_yas532_calib_values();
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /* Assign the data acquisition mode*/
- yas532_data.measure_state = YAS532_MAG_STATE_INIT_COIL;
- /* Set the default offset as invalid offset*/
- set_vector(yas532_data.v_hard_offset_s8, INVALID_OFFSET);
- /* set the transform to zero */
-
- yas532_data.transform = BMI160_NULL;
- /* Assign overflow as zero*/
- yas532_data.overflow = 0;
- #if 1 < YAS532_MAG_TEMPERATURE_LOG
- yas532_data.temp_data.num =
- yas532_data.temp_data.idx = 0;
- #endif
- /* Assign the coef value*/
- for (i = 0; i < 3; i++) {
- yas532_data.coef[i] = yas532_version_ac_coef[i];
- yas532_data.last_raw[i] = 0;
- }
- yas532_data.last_raw[3] = 0;
- /* Set the initial values of yas532*/
- com_rslt += bmi160_bst_yas532_set_initial_values();
- /* write the mag v_data_bw_u8 as 25Hz*/
- com_rslt += bmi160_set_mag_output_data_rate(
- BMI160_MAG_OUTPUT_DATA_RATE_25HZ);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* Enable mag interface to auto mode*/
- com_rslt += bmi160_set_mag_manual_enable(
- BMI160_MANUAL_DISABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- bmi160_get_mag_manual_enable(&v_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
- return com_rslt;
-}
-/*!
- * @brief This function used to set the YAS532 initial values
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_set_initial_values(void)
-{
-/* This variable used for provide the communication
- results*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* write testr1 as 0x00*/
- com_rslt = bmi160_set_mag_write_data(
- BMI160_YAS532_WRITE_TESTR1);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_TESTR1);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /* write testr2 as 0x00*/
- com_rslt += bmi160_set_mag_write_data(
- BMI160_YAS532_WRITE_TESTR2);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_TESTR2);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /* write Rcoil as 0x00*/
- com_rslt += bmi160_set_mag_write_data(
- BMI160_YAS532_WRITE_RCOIL);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_RCOIL);
- p_bmi160->delay_msec(BMI160_YAS532_SET_INITIAL_VALUE_DELAY);
- /* check the valid offset*/
- if (is_valid_offset(yas532_data.v_hard_offset_s8)) {
- com_rslt += bmi160_bst_yas532_set_offset(
- yas532_data.v_hard_offset_s8);
- yas532_data.measure_state = YAS532_MAG_STATE_NORMAL;
- } else {
- /* set the default offset as invalid offset*/
- set_vector(yas532_data.v_hard_offset_s8, INVALID_OFFSET);
- /*Set the default measure state for offset correction*/
- yas532_data.measure_state = YAS532_MAG_STATE_MEASURE_OFFSET;
- }
- return com_rslt;
-}
-/*!
- * @brief This function used for YAS532 offset correction
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_magnetic_measure_set_offset(
-void)
-{
- /* This variable used for provide the communication
- results*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* used for offset value set to the offset register*/
- s8 v_hard_offset_s8[BMI160_HARD_OFFSET_DATA_SIZE] = {
- BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- /* offset correction factors*/
- static const u8 v_correct_u8[BMI160_YAS_CORRECT_DATA_SIZE] = {
- 16, 8, 4, 2, 1};
- /* used for the temperature */
- u16 v_temp_u16 = BMI160_INIT_VALUE;
- /* used for the xy1y2 read*/
- u16 v_xy1y2_u16[BMI160_YAS_XY1Y2_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- /* local flag for assign the values*/
- s32 v_flag_s32[BMI160_YAS_FLAG_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- u8 i, j, v_busy_u8, v_overflow_u8 = BMI160_INIT_VALUE;
-
- for (i = 0; i < 5; i++) {
- /* set the offset values*/
- com_rslt = bmi160_bst_yas532_set_offset(v_hard_offset_s8);
- /* read the sensor data*/
- com_rslt += bmi160_bst_yas532_normal_measurement_data(
- BMI160_YAS532_ACQ_START, &v_busy_u8, &v_temp_u16,
- v_xy1y2_u16, &v_overflow_u8);
- /* check the sensor busy status*/
- if (v_busy_u8)
- return E_BMI160_BUSY;
- /* calculate the magnetic correction with
- offset and assign the values
- to the offset register */
- for (j = 0; j < 3; j++) {
- if (YAS532_DATA_CENTER == v_xy1y2_u16[j])
- v_flag_s32[j] = 0;
- if (YAS532_DATA_CENTER < v_xy1y2_u16[j])
- v_flag_s32[j] = 1;
- if (v_xy1y2_u16[j] < YAS532_DATA_CENTER)
- v_flag_s32[j] = -1;
- }
- for (j = 0; j < 3; j++) {
- if (v_flag_s32[j])
- v_hard_offset_s8[j] = (s8)(v_hard_offset_s8[j]
- + v_flag_s32[j] * v_correct_u8[i]);
- }
- }
- /* set the offset */
- com_rslt += bmi160_bst_yas532_set_offset(v_hard_offset_s8);
- return com_rslt;
-}
-/*!
- * @brief This function used for read the
- * YAMAHA YAS532 calibration data
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas532_calib_values(void)
-{
- /* This variable used for provide the communication
- results*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array holding the YAS532 calibration values */
- u8 v_data_u8[BMI160_YAS532_CALIB_DATA_SIZE] = {
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- /* Read the DX value */
- com_rslt = bmi160_set_mag_read_addr(BMI160_YAS532_CALIB_CX);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[0], BMI160_GEN_READ_WRITE_DATA_LENGTH);
- yas532_data.calib_yas532.cx = (s32)((v_data_u8[0]
- * 10) - 1280);
- /* Read the DY1 value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB_CY1);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[1], BMI160_GEN_READ_WRITE_DATA_LENGTH);
- yas532_data.calib_yas532.cy1 =
- (s32)((v_data_u8[1] * 10) - 1280);
- /* Read the DY2 value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB_CY2);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[2], BMI160_GEN_READ_WRITE_DATA_LENGTH);
- yas532_data.calib_yas532.cy2 =
- (s32)((v_data_u8[2] * 10) - 1280);
- /* Read the D2 and D3 value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB1);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[3], BMI160_GEN_READ_WRITE_DATA_LENGTH);
- yas532_data.calib_yas532.a2 =
- (s32)(((v_data_u8[3] >>
- BMI160_SHIFT_BIT_POSITION_BY_02_BITS)
- & 0x03F) - 32);
- /* Read the D3 and D4 value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB2);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[4], BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* calculate a3*/
- yas532_data.calib_yas532.a3 = (s32)((((v_data_u8[3] <<
- BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x0C) |
- ((v_data_u8[4]
- >> BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
- & 0x03)) - 8);
- /* calculate a4*/
- yas532_data.calib_yas532.a4 = (s32)((v_data_u8[4]
- & 0x3F) - 32);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* Read the D5 and D6 value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB3);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[5], BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* calculate a5*/
- yas532_data.calib_yas532.a5 =
- (s32)(((v_data_u8[5]
- >> BMI160_SHIFT_BIT_POSITION_BY_02_BITS)
- & 0x3F) + 38);
- /* Read the D6 and D7 value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB4);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[6], BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* calculate a6*/
- yas532_data.calib_yas532.a6 =
- (s32)((((v_data_u8[5]
- << BMI160_SHIFT_BIT_POSITION_BY_04_BITS)
- & 0x30) | ((v_data_u8[6] >>
- BMI160_SHIFT_BIT_POSITION_BY_04_BITS)
- & 0x0F)) - 32);
- /* Read the D7 and D8 value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB5);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[7], BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* calculate a7*/
- yas532_data.calib_yas532.a7 = (s32)((((v_data_u8[6]
- << BMI160_SHIFT_BIT_POSITION_BY_03_BITS)
- & 0x78) |
- ((v_data_u8[7]
- >> BMI160_SHIFT_BIT_POSITION_BY_05_BITS) &
- 0x07)) - 64);
- /* Read the D8 and D9 value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CLAIB6);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[8], BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* calculate a8*/
- yas532_data.calib_yas532.a8 = (s32)((((v_data_u8[7] <<
- BMI160_GEN_READ_WRITE_DATA_LENGTH) & 0x3E) |
- ((v_data_u8[8] >>
- BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01)) -
- 32);
-
- /* Read the D8 and D9 value */
- com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB7);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[9], BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* calculate a9*/
- yas532_data.calib_yas532.a9 = (s32)(((v_data_u8[8] <<
- BMI160_GEN_READ_WRITE_DATA_LENGTH) & 0xFE) |
- ((v_data_u8[9] >>
- BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
- /* calculate k*/
- yas532_data.calib_yas532.k = (s32)((v_data_u8[9] >>
- BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x1F);
- /* Read the value from register 0x9A*/
- com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB8);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[10],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* Read the value from register 0x9B*/
- com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIIB9);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[11],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* Read the value from register 0x9C*/
- com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB10);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[12],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* Read the value from register 0x9D*/
- com_rslt += bmi160_set_mag_read_addr(BMI160_YAS532_CALIB11);
- /* 0x04 is secondary read mag x lsb register */
- com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
- &v_data_u8[13],
- BMI160_GEN_READ_WRITE_DATA_LENGTH);
- /* Calculate the fxy1y2 and rxy1y1*/
- yas532_data.calib_yas532.fxy1y2[0] =
- (u8)(((v_data_u8[10]
- & 0x01)
- << BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
- | ((v_data_u8[11] >>
- BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
- yas532_data.calib_yas532.rxy1y2[0] =
- ((s8)(((v_data_u8[10]
- >> BMI160_SHIFT_BIT_POSITION_BY_01_BIT) & 0x3F)
- << BMI160_SHIFT_BIT_POSITION_BY_02_BITS))
- >> BMI160_SHIFT_BIT_POSITION_BY_02_BITS;
- yas532_data.calib_yas532.fxy1y2[1] =
- (u8)(((v_data_u8[11] & 0x01)
- << BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
- | ((v_data_u8[12] >>
- BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
- yas532_data.calib_yas532.rxy1y2[1] =
- ((s8)(((v_data_u8[11]
- >> BMI160_SHIFT_BIT_POSITION_BY_01_BIT) & 0x3F)
- << BMI160_SHIFT_BIT_POSITION_BY_02_BITS))
- >> BMI160_SHIFT_BIT_POSITION_BY_02_BITS;
- yas532_data.calib_yas532.fxy1y2[2] =
- (u8)(((v_data_u8[12] & 0x01)
- << BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
- | ((v_data_u8[13]
- >> BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01));
- yas532_data.calib_yas532.rxy1y2[2] =
- ((s8)(((v_data_u8[12]
- >> BMI160_SHIFT_BIT_POSITION_BY_01_BIT) & 0x3F)
- << BMI160_SHIFT_BIT_POSITION_BY_02_BITS))
- >> BMI160_SHIFT_BIT_POSITION_BY_02_BITS;
-
- return com_rslt;
-}
-/*!
- * @brief This function used for calculate the
- * YAS532 read the linear data
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_xy1y2_to_linear(
-u16 *v_xy1y2_u16, s32 *xy1y2_linear)
-{
- /* This variable used for provide the communication
- results*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = SUCCESS;
- static const u16 v_calib_data[] = {
- 3721, 3971, 4221, 4471};
- u8 i = BMI160_INIT_VALUE;
-
- for (i = 0; i < 3; i++)
- xy1y2_linear[i] = v_xy1y2_u16[i] -
- v_calib_data[yas532_data.calib_yas532.fxy1y2[i]]
- + (yas532_data.v_hard_offset_s8[i] -
- yas532_data.calib_yas532.rxy1y2[i])
- * yas532_data.coef[i];
- return com_rslt;
-}
-/*!
- * @brief This function used for read the YAS532 sensor data
- * @param v_acquisition_command_u8: used to set the data acquisition
- * acquisition_command | operation
- * ---------------------|-------------------------
- * 0x17 | turn on the acquisition coil
- * - | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Deferred acquisition mode
- * 0x07 | turn on the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Normal acquisition mode
- * 0x11 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Deferred acquisition mode
- * 0x01 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Normal acquisition mode
- *
- * @param v_busy_u8 : used to get the busy flay for sensor data read
- * @param v_temp_u16 : used to get the temperature data
- * @param v_xy1y2_u16 : used to get the sensor xy1y2 data
- * @param v_overflow_u8 : used to get the overflow data
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_normal_measurement_data(
-u8 v_acquisition_command_u8, u8 *v_busy_u8,
-u16 *v_temp_u16, u16 *v_xy1y2_u16, u8 *v_overflow_u8)
-{
- /* This variable used for provide the communication
- results*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array holding the YAS532 xyy1 data*/
- u8 v_data_u8[BMI160_YAS_XY1Y2T_DATA_SIZE] = {
- BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- u8 i = BMI160_INIT_VALUE;
- /* check the p_bmi160 structure as NULL*/
- if (p_bmi160 == BMI160_NULL) {
- return E_BMI160_NULL_PTR;
- } else {
- /* read the sensor data */
- com_rslt = bmi160_bst_yas532_acquisition_command_register(
- v_acquisition_command_u8);
- com_rslt +=
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_DATA_MAG_X_LSB__REG,
- v_data_u8, BMI160_MAG_YAS_DATA_LENGTH);
- v_data_u8[0] = 0x31;
- v_data_u8[1] = 0xF8;
- v_data_u8[2] = 0x49;
- v_data_u8[3] = 0x3B;
- v_data_u8[4] = 0x45;
- v_data_u8[5] = 0x8F;
- v_data_u8[6] = 0x31;
- v_data_u8[7] = 0x90;
- /* read the xyy1 data*/
- *v_busy_u8 =
- ((v_data_u8[0]
- >> BMI160_SHIFT_BIT_POSITION_BY_07_BITS) & 0x01);
- *v_temp_u16 =
- (u16)((((s32)v_data_u8[0]
- << BMI160_SHIFT_BIT_POSITION_BY_03_BITS)
- & 0x3F8) | ((v_data_u8[1]
- >> BMI160_SHIFT_BIT_POSITION_BY_05_BITS) & 0x07));
- v_xy1y2_u16[0] =
- (u16)((((s32)v_data_u8[2]
- << BMI160_SHIFT_BIT_POSITION_BY_06_BITS) & 0x1FC0)
- | ((v_data_u8[3] >>
- BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
- v_xy1y2_u16[1] =
- (u16)((((s32)v_data_u8[4]
- << BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
- & 0x1FC0)
- | ((v_data_u8[5]
- >> BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
- v_xy1y2_u16[2] =
- (u16)((((s32)v_data_u8[6]
- << BMI160_SHIFT_BIT_POSITION_BY_06_BITS)
- & 0x1FC0)
- | ((v_data_u8[7]
- >> BMI160_SHIFT_BIT_POSITION_BY_02_BITS) & 0x3F));
- *v_overflow_u8 = 0;
- for (i = 0; i < 3; i++) {
- if (v_xy1y2_u16[i] == YAS532_DATA_OVERFLOW)
- *v_overflow_u8 |= (1 << (i * 2));
- if (v_xy1y2_u16[i] == YAS532_DATA_UNDERFLOW)
- *v_overflow_u8 |= (1 << (i * 2 + 1));
- }
- }
- return com_rslt;
-}
-/*!
- * @brief This function used for YAS532 sensor data
- * @param v_acquisition_command_u8 : the value of CMDR
- * acquisition_command | operation
- * ---------------------|-------------------------
- * 0x17 | turn on the acquisition coil
- * - | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Deferred acquisition mode
- * 0x07 | turn on the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Normal acquisition mode
- * 0x11 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Deferred acquisition mode
- * 0x01 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Normal acquisition mode
- *
- * @param xyz_data : the vector xyz output
- * @param v_overflow_s8 : the value of overflow
- * @param v_temp_correction_u8 : the value of temperate correction enable
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_measurement_xyz_data(
-struct yas532_vector *xyz_data, u8 *v_overflow_s8, u8 v_temp_correction_u8,
-u8 v_acquisition_command_u8)
-{
- /* This variable used for provide the communication
- results*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array holding the linear calculation output*/
- s32 v_xy1y2_linear_s32[BMI160_YAS_XY1Y2_DATA_SIZE] = {
- BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- /* Array holding the temperature data */
- s32 v_xyz_tmp_s32[BMI160_YAS_TEMP_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- s32 tmp = BMI160_INIT_VALUE;
- s32 sx, sy1, sy2, sy, sz = BMI160_INIT_VALUE;
- u8 i, v_busy_u8 = BMI160_INIT_VALUE;
- u16 v_temp_u16 = BMI160_INIT_VALUE;
- /* Array holding the xyy1 sensor raw data*/
- u16 v_xy1y2_u16[BMI160_YAS_XY1Y2_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- #if 1 < YAS532_MAG_TEMPERATURE_LOG
- s32 sum = BMI160_INIT_VALUE;
- #endif
- *v_overflow_s8 = BMI160_INIT_VALUE;
- switch (yas532_data.measure_state) {
- case YAS532_MAG_STATE_INIT_COIL:
- if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
- com_rslt = bmi160_set_mag_manual_enable(
- BMI160_MANUAL_ENABLE);
- /* write Rcoil*/
- com_rslt += bmi160_set_mag_write_data(
- BMI160_YAS_DISABLE_RCOIL);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_RCOIL);
- p_bmi160->delay_msec(BMI160_YAS532_MEASUREMENT_DELAY);
- if (!yas532_data.overflow && is_valid_offset(
- yas532_data.v_hard_offset_s8))
- yas532_data.measure_state = 0;
- break;
- case YAS532_MAG_STATE_MEASURE_OFFSET:
- com_rslt = bmi160_bst_yas532_magnetic_measure_set_offset();
- yas532_data.measure_state = 0;
- break;
- default:
- break;
- }
- /* Read sensor data*/
- com_rslt += bmi160_bst_yas532_normal_measurement_data(
- v_acquisition_command_u8, &v_busy_u8, &v_temp_u16,
- v_xy1y2_u16, v_overflow_s8);
- /* Calculate the linear data*/
- com_rslt += bmi160_bst_yas532_xy1y2_to_linear(v_xy1y2_u16,
- v_xy1y2_linear_s32);
- /* Calculate temperature correction */
- #if 1 < YAS532_MAG_TEMPERATURE_LOG
- yas532_data.temp_data.log[yas532_data.temp_data.idx++] =
- v_temp_u16;
- if (YAS532_MAG_TEMPERATURE_LOG <= yas532_data.temp_data.idx)
- yas532_data.temp_data.idx = 0;
- yas532_data.temp_data.num++;
- if (YAS532_MAG_TEMPERATURE_LOG <= yas532_data.temp_data.num)
- yas532_data.temp_data.num = YAS532_MAG_TEMPERATURE_LOG;
- for (i = 0; i < yas532_data.temp_data.num; i++)
- sum += yas532_data.temp_data.log[i];
- tmp = sum * 10 / yas532_data.temp_data.num
- - YAS532_TEMP20DEGREE_TYPICAL * 10;
- #else
- tmp = (v_temp_u16 - YAS532_TEMP20DEGREE_TYPICAL)
- * 10;
- #endif
- sx = v_xy1y2_linear_s32[0];
- sy1 = v_xy1y2_linear_s32[1];
- sy2 = v_xy1y2_linear_s32[2];
- /* Temperature correction */
- if (v_temp_correction_u8) {
- sx -= (yas532_data.calib_yas532.cx * tmp)
- / 1000;
- sy1 -= (yas532_data.calib_yas532.cy1 * tmp)
- / 1000;
- sy2 -= (yas532_data.calib_yas532.cy2 * tmp)
- / 1000;
- }
- sy = sy1 - sy2;
- sz = -sy1 - sy2;
- #if 1
- xyz_data->yas532_vector_xyz[0] = yas532_data.calib_yas532.k *
- ((100 * sx + yas532_data.calib_yas532.a2 * sy +
- yas532_data.calib_yas532.a3 * sz) / 10);
- xyz_data->yas532_vector_xyz[1] = yas532_data.calib_yas532.k *
- ((yas532_data.calib_yas532.a4 * sx + yas532_data.calib_yas532.a5 * sy +
- yas532_data.calib_yas532.a6 * sz) / 10);
- xyz_data->yas532_vector_xyz[2] = yas532_data.calib_yas532.k *
- ((yas532_data.calib_yas532.a7 * sx + yas532_data.calib_yas532.a8 * sy +
- yas532_data.calib_yas532.a9 * sz) / 10);
- if (yas532_data.transform != BMI160_NULL) {
- for (i = 0; i < 3; i++) {
- v_xyz_tmp_s32[i] = yas532_data.transform[i
- * 3] *
- xyz_data->yas532_vector_xyz[0]
- + yas532_data.transform[i * 3 + 1] *
- xyz_data->yas532_vector_xyz[1]
- + yas532_data.transform[i * 3 + 2] *
- xyz_data->yas532_vector_xyz[2];
- }
- set_vector(xyz_data->yas532_vector_xyz, v_xyz_tmp_s32);
- }
- for (i = 0; i < 3; i++) {
- xyz_data->yas532_vector_xyz[i] -=
- xyz_data->yas532_vector_xyz[i] % 10;
- if (*v_overflow_s8 & (1
- << (i * 2)))
- xyz_data->yas532_vector_xyz[i] +=
- 1; /* set overflow */
- if (*v_overflow_s8 & (1 <<
- (i * 2 + 1)))
- xyz_data->yas532_vector_xyz[i] += 2; /* set underflow */
- }
-#else
- xyz_data->yas532_vector_xyz[0] = sx;
- xyz_data->yas532_vector_xyz[1] = sy;
- xyz_data->yas532_vector_xyz[2] = sz;
-#endif
-if (v_busy_u8)
- return com_rslt;
- if (0 < *v_overflow_s8) {
- if (!yas532_data.overflow)
- yas532_data.overflow = 1;
- yas532_data.measure_state = YAS532_MAG_STATE_INIT_COIL;
- } else
- yas532_data.overflow = 0;
- for (i = 0; i < 3; i++)
- yas532_data.last_raw[i] = v_xy1y2_u16[i];
- yas532_data.last_raw[i] = v_temp_u16;
- return com_rslt;
-}
-/*!
- * @brief This function used for YAS532 sensor data
- * @param v_acquisition_command_u8 : the value of CMDR
- *
- * @param v_xy1y2_u16 : the vector xyz output
- * @param v_overflow_s8 : the value of overflow
- * @param v_temp_correction_u8 : the value of temperate correction enable
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_fifo_xyz_data(
-u16 *v_xy1y2_u16, u8 v_temp_correction_u8,
-s8 v_overflow_s8, u16 v_temp_u16, u8 v_busy_u8)
-{
- /* This variable used for provide the communication
- results*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array holding the linear calculation output*/
- s32 v_xy1y2_linear_s32[BMI160_YAS_XY1Y2_DATA_SIZE] = {
- BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- /* Array holding the temperature data */
- s32 v_xyz_tmp_s32[BMI160_YAS_TEMP_DATA_SIZE] = {BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- s32 tmp = BMI160_INIT_VALUE;
- s32 sx, sy1, sy2, sy, sz = BMI160_INIT_VALUE;
- u8 i = BMI160_INIT_VALUE;
- #if 1 < YAS532_MAG_TEMPERATURE_LOG
- s32 sum = BMI160_INIT_VALUE;
- #endif
- v_overflow_s8 = BMI160_INIT_VALUE;
- /* Calculate the linear data*/
- com_rslt = bmi160_bst_yas532_xy1y2_to_linear(v_xy1y2_u16,
- v_xy1y2_linear_s32);
- /* Calculate temperature correction */
- #if 1 < YAS532_MAG_TEMPERATURE_LOG
- yas532_data.temp_data.log[yas532_data.temp_data.idx++] =
- v_temp_u16;
- if (YAS532_MAG_TEMPERATURE_LOG <= yas532_data.temp_data.idx)
- yas532_data.temp_data.idx = 0;
- yas532_data.temp_data.num++;
- if (YAS532_MAG_TEMPERATURE_LOG <= yas532_data.temp_data.num)
- yas532_data.temp_data.num = YAS532_MAG_TEMPERATURE_LOG;
- for (i = 0; i < yas532_data.temp_data.num; i++)
- sum += yas532_data.temp_data.log[i];
- tmp = sum * 10 / yas532_data.temp_data.num
- - YAS532_TEMP20DEGREE_TYPICAL * 10;
- #else
- tmp = (v_temp_u16 - YAS532_TEMP20DEGREE_TYPICAL)
- * 10;
- #endif
- sx = v_xy1y2_linear_s32[0];
- sy1 = v_xy1y2_linear_s32[1];
- sy2 = v_xy1y2_linear_s32[2];
- /* Temperature correction */
- if (v_temp_correction_u8) {
- sx -= (yas532_data.calib_yas532.cx * tmp)
- / 1000;
- sy1 -= (yas532_data.calib_yas532.cy1 * tmp)
- / 1000;
- sy2 -= (yas532_data.calib_yas532.cy2 * tmp)
- / 1000;
- }
- sy = sy1 - sy2;
- sz = -sy1 - sy2;
- #if 1
- fifo_xyz_data.yas532_vector_xyz[0] = yas532_data.calib_yas532.k *
- ((100 * sx + yas532_data.calib_yas532.a2 * sy +
- yas532_data.calib_yas532.a3 * sz) / 10);
- fifo_xyz_data.yas532_vector_xyz[1] = yas532_data.calib_yas532.k *
- ((yas532_data.calib_yas532.a4 * sx + yas532_data.calib_yas532.a5 * sy +
- yas532_data.calib_yas532.a6 * sz) / 10);
- fifo_xyz_data.yas532_vector_xyz[2] = yas532_data.calib_yas532.k *
- ((yas532_data.calib_yas532.a7 * sx + yas532_data.calib_yas532.a8 * sy +
- yas532_data.calib_yas532.a9 * sz) / 10);
- if (yas532_data.transform != BMI160_NULL) {
- for (i = 0; i < 3; i++) {
- v_xyz_tmp_s32[i] = yas532_data.transform[i
- * 3] *
- fifo_xyz_data.yas532_vector_xyz[0]
- + yas532_data.transform[i * 3 + 1] *
- fifo_xyz_data.yas532_vector_xyz[1]
- + yas532_data.transform[i * 3 + 2] *
- fifo_xyz_data.yas532_vector_xyz[2];
- }
- set_vector(fifo_xyz_data.yas532_vector_xyz, v_xyz_tmp_s32);
- }
- for (i = 0; i < 3; i++) {
- fifo_xyz_data.yas532_vector_xyz[i] -=
- fifo_xyz_data.yas532_vector_xyz[i] % 10;
- if (v_overflow_s8 & (1
- << (i * 2)))
- fifo_xyz_data.yas532_vector_xyz[i] +=
- 1; /* set overflow */
- if (v_overflow_s8 & (1 <<
- (i * 2 + 1)))
- fifo_xyz_data.yas532_vector_xyz[i] += 2;
- }
-#else
- fifo_xyz_data.yas532_vector_xyz[0] = sx;
- fifo_xyz_data.yas532_vector_xyz[1] = sy;
- fifo_xyz_data.yas532_vector_xyz[2] = sz;
-#endif
-if (v_busy_u8)
- return com_rslt;
- if (0 < v_overflow_s8) {
- if (!yas532_data.overflow)
- yas532_data.overflow = 1;
- yas532_data.measure_state = YAS532_MAG_STATE_INIT_COIL;
- } else
- yas532_data.overflow = 0;
- for (i = 0; i < 3; i++)
- yas532_data.last_raw[i] = v_xy1y2_u16[i];
- yas532_data.last_raw[i] = v_temp_u16;
- return com_rslt;
-}
-/*!
- * @brief This function used for YAS532 write data acquisition
- * @param
- */
-/*!
- * @brief This function used for YAS532 write data acquisition
- * command register write
- * @param v_command_reg_data_u8 : the value of data acquisition
- * acquisition_command | operation
- * ---------------------|-------------------------
- * 0x17 | turn on the acquisition coil
- * - | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Deferred acquisition mode
- * 0x07 | turn on the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Normal acquisition mode
- * 0x11 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Deferred acquisition mode
- * 0x01 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Normal acquisition mode
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_acquisition_command_register(
-u8 v_command_reg_data_u8)
-{
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-
- if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
- com_rslt = bmi160_set_mag_manual_enable(
- BMI160_MANUAL_ENABLE);
-
- com_rslt = bmi160_set_mag_write_data(v_command_reg_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* YAMAHA YAS532-0x82*/
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_YAS532_COMMAND_REGISTER);
- p_bmi160->delay_msec(BMI160_YAS_ACQ_COMMAND_DELAY);
- com_rslt += bmi160_set_mag_read_addr(
- BMI160_YAS532_DATA_REGISTER);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
- if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
- com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_DISABLE);
-
- return com_rslt;
-
-}
-/*!
- * @brief This function used write offset of YAS532
- *
- * @param p_offset_s8 : The value of offset to write
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_set_offset(
-const s8 *p_offset_s8)
-{
- /* This variable used for provide the communication
- results*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-
- if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
- com_rslt = bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
- p_bmi160->delay_msec(BMI160_YAS532_OFFSET_DELAY);
-
- /* Write offset X data*/
- com_rslt = bmi160_set_mag_write_data(p_offset_s8[0]);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* YAS532 offset x write*/
- com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_OFFSET_X);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
- /* Write offset Y data*/
- com_rslt = bmi160_set_mag_write_data(p_offset_s8[1]);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* YAS532 offset y write*/
- com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_OFFSET_Y);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
- /* Write offset Z data*/
- com_rslt = bmi160_set_mag_write_data(p_offset_s8[2]);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* YAS532 offset z write*/
- com_rslt += bmi160_set_mag_write_addr(BMI160_YAS532_OFFSET_Z);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- set_vector(yas532_data.v_hard_offset_s8, p_offset_s8);
-
- if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
- com_rslt = bmi160_set_mag_manual_enable(BMI160_MANUAL_DISABLE);
- return com_rslt;
-}
-/*!
- * @brief This function used to init the YAMAH-YAS537
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_mag_interface_init(
-void)
-{
-/* This variable used for provide the communication
-results*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-u8 v_pull_value_u8 = BMI160_INIT_VALUE;
-u8 v_data_u8 = BMI160_INIT_VALUE;
-u8 i = BMI160_INIT_VALUE;
-/* accel operation mode to normal*/
-com_rslt = bmi160_set_command_register(ACCEL_MODE_NORMAL);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* write mag power mode as NORMAL*/
-com_rslt += bmi160_set_mag_interface_normal();
-/* register 0x7E write the 0x37, 0x9A and 0x30*/
-com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_ONE);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_TWO);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_set_command_register(BMI160_COMMAND_REG_THREE);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-/*switch the page1*/
-com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE1);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-bmi160_get_target_page(&v_data_u8);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_set_paging_enable(BMI160_WRITE_ENABLE_PAGE1);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-bmi160_get_paging_enable(&v_data_u8);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* enable the pullup configuration from
-the register 0x05 bit 4 and 5 as 10*/
-bmi160_get_pullup_configuration(&v_pull_value_u8);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-v_pull_value_u8 = v_pull_value_u8 | BMI160_PULL_UP_DATA;
-com_rslt += bmi160_set_pullup_configuration(v_pull_value_u8);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/*switch the page0*/
-com_rslt += bmi160_set_target_page(BMI160_WRITE_TARGET_PAGE0);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-bmi160_get_target_page(&v_data_u8);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* Write the YAS532 i2c address*/
-com_rslt += bmi160_set_i2c_device_addr(BMI160_YAS537_I2C_ADDRESS);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* enable the mag interface to manual mode*/
-com_rslt += bmi160_set_mag_manual_enable(BMI160_MANUAL_ENABLE);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-bmi160_get_mag_manual_enable(&v_data_u8);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/*Enable the MAG interface */
-com_rslt += bmi160_set_if_mode(BMI160_ENABLE_MAG_IF_MODE);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-bmi160_get_if_mode(&v_data_u8);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-v_data_u8 = BMI160_MANUAL_DISABLE;
-/* Read the YAS537 device id 0x07*/
-com_rslt += bmi160_set_mag_read_addr(BMI160_YAS_DEVICE_ID_REG);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&v_data_u8, BMI160_GEN_READ_WRITE_DATA_LENGTH);
-yas537_data.dev_id = v_data_u8;
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* Read the YAS532 calibration data*/
-
-com_rslt +=
-bmi160_bst_yamaha_yas537_calib_values(
-BMI160_GEN_READ_WRITE_DATA_LENGTH);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-/* set the mode to NORMAL*/
-yas537_data.measure_state = YAS537_MAG_STATE_NORMAL;
-/* set the transform to zero */
-yas537_data.transform = BMI160_NULL;
-yas537_data.average = 32;
-for (i = 0; i < 3; i++) {
- yas537_data.hard_offset[i] = -128;
- yas537_data.last_after_rcoil[i] = 0;
-}
-for (i = 0; i < 4; i++)
- yas537_data.last_raw[i] = 0;
-/* write the mag bandwidth as 25Hz*/
-com_rslt += bmi160_set_mag_output_data_rate(
-BMI160_MAG_OUTPUT_DATA_RATE_25HZ);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* Enable mag interface to auto mode*/
-com_rslt += bmi160_set_mag_manual_enable(
-BMI160_MANUAL_DISABLE);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-bmi160_get_mag_manual_enable(&v_data_u8);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-return com_rslt;
-}
-/*!
-* @brief This function used for read the
-* YAMAHA YAS537 calibration data
-*
-*
-* @param v_rcoil_u8 : The value of r coil
-*
-*
-* @return results of bus communication function
-* @retval 0 -> Success
-* @retval -1 -> Error
-*
-*
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_calib_values(
-u8 v_rcoil_u8)
-{
-/* This variable used for provide the communication
-results*/
-BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-/* Array holding the YAS532 calibration values */
-u8 a_data_u8[BMI160_YAS537_CALIB_DATA_SIZE] = {
-BMI160_INIT_VALUE, BMI160_INIT_VALUE,
-BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
-BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
-BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
-BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
-BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
-};
-static const u8 v_avrr_u8[] = {0x50, 0x60, 0x70};
-u8 v_cal_valid_u8 = BMI160_INIT_VALUE, i;
-/* write soft reset as 0x02*/
-com_rslt = bmi160_set_mag_write_data(
-YAS537_SRSTR_DATA);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_set_mag_write_addr(YAS537_REG_SRSTR);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-/* Read the DX value */
-com_rslt = bmi160_set_mag_read_addr(YAS537_REG_CALR_C0);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[0], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the DY1 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C1);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[1], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the DY2 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C2);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[2], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D2 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C3);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[3], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D3 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C4);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[4], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D4 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C5);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[5], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D5 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C6);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[6], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D6 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C7);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[7], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D7 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C8);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[8], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D8 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_C9);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[9], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the D9 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CA);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[10], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the RX value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CB);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[11], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the RY1 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CC);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[12], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the RY2 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CD);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[13], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the RY2 value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CE);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[14], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the CHF value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_CF);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[15], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* Read the VER value */
-com_rslt += bmi160_set_mag_read_addr(YAS537_REG_CALR_DO);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-/* 0x04 is secondary read mag x lsb register */
-com_rslt += bmi160_read_reg(BMI160_MAG_DATA_READ_REG,
-&a_data_u8[16], BMI160_GEN_READ_WRITE_DATA_LENGTH);
-/* get the calib ver*/
-yas537_data.calib_yas537.ver =
-(a_data_u8[16] >> BMI160_SHIFT_BIT_POSITION_BY_06_BITS);
-for (i = 0; i < 17; i++) {
- if (((i < 16 && a_data_u8[i]) != 0))
- v_cal_valid_u8 = 1;
- if ((i < 16 &&
- (a_data_u8[i] & 0x3F)) != 0)
- v_cal_valid_u8 = 1;
-}
-if (!v_cal_valid_u8)
- return ERROR;
-if (yas537_data.calib_yas537.ver == 0) {
- for (i = 0; i < 17; i++) {
- if (i < 12) {
- /* write offset*/
- com_rslt += bmi160_set_mag_write_data(
- a_data_u8[i]);
- p_bmi160->delay_msec(
- BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- YAS537_REG_MTCR + i);
- p_bmi160->delay_msec(
- BMI160_GEN_READ_WRITE_DELAY);
- } else if (i < 15) {
- /* write offset correction*/
- com_rslt += bmi160_set_mag_write_data(
- a_data_u8[i]);
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr((
- (YAS537_REG_OXR + i) - 12));
- p_bmi160->delay_msec(
- BMI160_GEN_READ_WRITE_DELAY);
- yas537_data.hard_offset[i - 12]
- = a_data_u8[i];
- } else {
- /* write offset correction*/
- com_rslt += bmi160_set_mag_write_data(
- a_data_u8[i]);
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr((
- (YAS537_REG_OXR + i) - 11));
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- }
-
-}
-} else if (yas537_data.calib_yas537.ver == 1) {
- for (i = 0; i < 3; i++) {
- /* write offset*/
- com_rslt += bmi160_set_mag_write_data(
- a_data_u8[i]);
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- YAS537_REG_MTCR + i);
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- if (com_rslt == SUCCESS) {
- /* write offset*/
- com_rslt += bmi160_set_mag_write_data(
- a_data_u8[i + 12]);
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- YAS537_REG_OXR + i);
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- yas537_data.hard_offset[i] =
- a_data_u8[i + 12];
- } else {
- com_rslt = ERROR;
- }
- }
- /* write offset*/
- com_rslt += bmi160_set_mag_write_data(
- ((a_data_u8[i] & 0xE0) | 0x10));
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(
- YAS537_REG_MTCR + i);
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /* write offset*/
- com_rslt += bmi160_set_mag_write_data(
- ((a_data_u8[15]
- >> BMI160_SHIFT_BIT_POSITION_BY_03_BITS)
- & 0x1E));
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(YAS537_REG_HCKR);
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /* write offset*/
- com_rslt += bmi160_set_mag_write_data(
- ((a_data_u8[15] << 1) & 0x1E));
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(YAS537_REG_LCKR);
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- /* write offset*/
- com_rslt += bmi160_set_mag_write_data(
- (a_data_u8[16] & 0x3F));
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(YAS537_REG_OCR);
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-
- /* Assign the calibration values*/
- /* a2 */
- yas537_data.calib_yas537.a2 =
- ((((a_data_u8[3]
- << BMI160_SHIFT_BIT_POSITION_BY_02_BITS)
- & 0x7C)
- | (a_data_u8[4]
- >> BMI160_SHIFT_BIT_POSITION_BY_06_BITS)) - 64);
- /* a3 */
- yas537_data.calib_yas537.a3 =
- ((((a_data_u8[4] << BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
- & 0x7E)
- | (a_data_u8[5]
- >> BMI160_SHIFT_BIT_POSITION_BY_07_BITS)) - 64);
- /* a4 */
- yas537_data.calib_yas537.a4 =
- ((((a_data_u8[5]
- << BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
- & 0xFE)
- | (a_data_u8[6]
- >> BMI160_SHIFT_BIT_POSITION_BY_07_BITS))
- - 128);
- /* a5 */
- yas537_data.calib_yas537.a5 =
- ((((a_data_u8[6]
- << BMI160_SHIFT_BIT_POSITION_BY_02_BITS)
- & 0x1FC)
- | (a_data_u8[7]
- >> BMI160_SHIFT_BIT_POSITION_BY_06_BITS))
- - 112);
- /* a6 */
- yas537_data.calib_yas537.a6 =
- ((((a_data_u8[7]
- << BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
- & 0x7E)
- | (a_data_u8[8]
- >> BMI160_SHIFT_BIT_POSITION_BY_07_BITS)) - 64);
- /* a7 */
- yas537_data.calib_yas537.a7 =
- ((((a_data_u8[8]
- << BMI160_SHIFT_BIT_POSITION_BY_01_BIT)
- & 0xFE)
- | (a_data_u8[9]
- >> BMI160_SHIFT_BIT_POSITION_BY_07_BITS))
- - 128);
- /* a8 */
- yas537_data.calib_yas537.a8 = ((a_data_u8[9] &
- 0x7F) - 64);
- /* a9 */
- yas537_data.calib_yas537.a9 = ((((a_data_u8[10]
- << BMI160_SHIFT_BIT_POSITION_BY_01_BIT) & 0x1FE)
- | (a_data_u8[11]
- >> BMI160_SHIFT_BIT_POSITION_BY_07_BITS))
- - 112);
- /* k */
- yas537_data.calib_yas537.k = (
- a_data_u8[11] & 0x7F);
- } else {
- return ERROR;
- }
-/* write A/D converter*/
-com_rslt += bmi160_set_mag_write_data(
-YAS537_WRITE_A_D_CONVERTER);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_set_mag_write_addr(YAS537_REG_ADCCALR);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-/* write A/D converter second register*/
-com_rslt += bmi160_set_mag_write_data(
-YAS537_WRITE_A_D_CONVERTER2);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_set_mag_write_addr(YAS537_REG_ADCCALR_ONE);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-/* write temperature calibration register*/
-com_rslt += bmi160_set_mag_write_data(YAS537_WRITE_TEMP_CALIB);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_set_mag_write_addr(YAS537_REG_TRMR);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-/* write average filter register*/
-com_rslt += bmi160_set_mag_write_data(
-v_avrr_u8[yas537_data.average]);
-p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-com_rslt += bmi160_set_mag_write_addr(YAS537_REG_AVRR);
-p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-if (v_rcoil_u8) {
- /* write average; filter register*/
- com_rslt += bmi160_set_mag_write_data(
- YAS537_WRITE_FILTER);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(YAS537_REG_CONFR);
- p_bmi160->delay_msec(
- BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
-}
-
-return com_rslt;
-
-}
-/*!
- * @brief This function used for YAS537 write data acquisition
- * command register write
- * @param v_command_reg_data_u8 : the value of data acquisition
- * acquisition_command | operation
- * ---------------------|-------------------------
- * 0x17 | turn on the acquisition coil
- * - | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Deferred acquisition mode
- * 0x07 | turn on the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Normal acquisition mode
- * 0x11 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Deferred acquisition mode
- * 0x01 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Normal acquisition mode
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas537_acquisition_command_register(
-u8 v_command_reg_data_u8)
-{
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
-
- if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
- com_rslt = bmi160_set_mag_manual_enable(
- BMI160_MANUAL_ENABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
- com_rslt = bmi160_set_mag_write_data(v_command_reg_data_u8);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- /* YAMAHA YAS532-0x82*/
- com_rslt += bmi160_set_mag_write_addr(
- BMI160_REG_YAS537_CMDR);
- /* set the mode to RECORD*/
- yas537_data.measure_state = YAS537_MAG_STATE_RECORD_DATA;
- p_bmi160->delay_msec(BMI160_YAS_ACQ_COMMAND_DELAY);
- com_rslt += bmi160_set_mag_read_addr(
- YAS537_REG_TEMPERATURE_0);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
- if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
- com_rslt += bmi160_set_mag_manual_enable(
- BMI160_MANUAL_DISABLE);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
-
- return com_rslt;
-
-}
-/*!
- * @brief This function used for read the
- * YAMAHA YAS537 xy1y2 data
- *
- * @param xy1y2: The value of raw xy1y2 data
- * @param xyz: The value of xyz data
- *
- *
- * @return None
- *
- *
- */
-static void xy1y2_to_xyz(u16 *xy1y2, s32 *xyz)
-{
- xyz[0] = ((xy1y2[0] - 8192)
- * 300);
- xyz[1] = (((xy1y2[1] - xy1y2[2])
- * 1732) / 10);
- xyz[2] = (((-xy1y2[2] - xy1y2[2])
- + 16384) * 300);
-}
-/*!
- * @brief This function used for read the
- * YAMAHA YAS537 xy1y2 data
- *
- * @param v_coil_stat_u8: The value of R coil status
- * @param v_busy_u8: The value of busy status
- * @param v_temperature_u16: The value of temperature
- * @param xy1y2: The value of raw xy1y2 data
- * @param v_ouflow_u8: The value of overflow
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_read_xy1y2_data(
-u8 *v_coil_stat_u8, u8 *v_busy_u8,
-u16 *v_temperature_u16, u16 *xy1y2, u8 *v_ouflow_u8)
-{
- /* This variable used for provide the communication
- results*/
- BMI160_RETURN_FUNCTION_TYPE com_rslt = E_BMI160_COMM_RES;
- /* Array holding the YAS532 calibration values */
- u8 a_data_u8[BMI160_YAS_XY1Y2T_DATA_SIZE] = {
- BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE,
- };
- u8 i = BMI160_INIT_VALUE;
- s32 a_h_s32[BMI160_YAS_H_DATA_SIZE] = {
- BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- s32 a_s_s32[BMI160_YAS_S_DATA_SIZE] = {
- BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- /* set command register*/
- com_rslt = bmi160_bst_yas537_acquisition_command_register(
- YAS537_SET_COMMAND_REGISTER);
- /* read the yas537 sensor data of xy1y2*/
- com_rslt +=
- p_bmi160->BMI160_BUS_READ_FUNC(p_bmi160->dev_addr,
- BMI160_USER_DATA_MAG_X_LSB__REG,
- a_data_u8, BMI160_MAG_YAS_DATA_LENGTH);
- /* read the busy flag*/
- *v_busy_u8 = a_data_u8[2]
- >> BMI160_SHIFT_BIT_POSITION_BY_07_BITS;
- /* read the coil status*/
- *v_coil_stat_u8 =
- ((a_data_u8[2] >>
- BMI160_SHIFT_BIT_POSITION_BY_06_BITS) & 0X01);
- /* read temperature data*/
- *v_temperature_u16 = (u16)((a_data_u8[0]
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS) | a_data_u8[1]);
- /* read x data*/
- xy1y2[0] = (u16)(((a_data_u8[2] &
- 0x3F)
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | (a_data_u8[3]));
- /* read y1 data*/
- xy1y2[1] = (u16)((a_data_u8[4]
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | a_data_u8[5]);
- /* read y2 data*/
- xy1y2[2] = (u16)((a_data_u8[6]
- << BMI160_SHIFT_BIT_POSITION_BY_08_BITS)
- | a_data_u8[7]);
- for (i = 0; i < 3; i++)
- yas537_data.last_raw[i] = xy1y2[i];
- yas537_data.last_raw[i] = *v_temperature_u16;
- if (yas537_data.calib_yas537.ver == 1) {
- for (i = 0; i < 3; i++)
- a_s_s32[i] = xy1y2[i] - 8192;
- /* read hx*/
- a_h_s32[0] = ((yas537_data.calib_yas537.k * (
- (128 * a_s_s32[0]) +
- (yas537_data.calib_yas537.a2 * a_s_s32[1]) +
- (yas537_data.calib_yas537.a3 * a_s_s32[2])))
- / (8192));
- /* read hy1*/
- a_h_s32[1] = ((yas537_data.calib_yas537.k * (
- (yas537_data.calib_yas537.a4 * a_s_s32[0]) +
- (yas537_data.calib_yas537.a5 * a_s_s32[1]) +
- (yas537_data.calib_yas537.a6 * a_s_s32[2])))
- / (8192));
- /* read hy2*/
- a_h_s32[2] = ((yas537_data.calib_yas537.k * (
- (yas537_data.calib_yas537.a7 * a_s_s32[0]) +
- (yas537_data.calib_yas537.a8 * a_s_s32[1]) +
- (yas537_data.calib_yas537.a9 * a_s_s32[2])))
- / (8192));
-
- for (i = 0; i < 3; i++) {
- if (a_h_s32[i] < -8192)
- a_h_s32[i] = -8192;
-
- if (8192 < a_h_s32[i])
- a_h_s32[i] = 8192;
-
- xy1y2[i] = a_h_s32[i] + 8192;
-
- }
- }
- *v_ouflow_u8 = 0;
- for (i = 0; i < 3; i++) {
- if (YAS537_DATA_OVERFLOW <= xy1y2[i])
- *v_ouflow_u8 |= (1 << (i * 2));
- if (xy1y2[i] == YAS537_DATA_UNDERFLOW)
- *v_ouflow_u8 |= (1 << (i * 2 + 1));
- }
-
- return com_rslt;
-
-}
-/*!
- * @brief This function used for read the
- * YAMAHA YAS537 xy1y2 data
- *
- * @param v_ouflow_u8: The value of overflow
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-static BMI160_RETURN_FUNCTION_TYPE invalid_magnetic_field(
-u16 *v_cur_u16, u16 *v_last_u16)
-{
- s16 invalid_thresh[] = {1500, 1500, 1500};
- u8 i = BMI160_INIT_VALUE;
-
- for (i = 0; i < 3; i++)
- if (invalid_thresh[i] < ABS(v_cur_u16[i] - v_last_u16[i]))
- return 1;
- return 0;
-}
-/*!
- * @brief This function used for read the
- * YAMAHA YAS537 xy1y2 data
- *
- * @param v_ouflow_u8: The value of overflow
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_measure_xyz_data(
-u8 *v_ouflow_u8, struct yas_vector *vector_xyz)
-{
- s32 a_xyz_tmp_s32[BMI160_YAS_TEMP_DATA_SIZE] = {
- BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- u8 i = BMI160_INIT_VALUE;
- s8 com_rslt = BMI160_INIT_VALUE;
- u8 v_busy_u8 = BMI160_INIT_VALUE;
- u8 v_rcoil_u8 = BMI160_INIT_VALUE;
- u16 v_temperature_u16 = BMI160_INIT_VALUE;
- u16 a_xy1y2_u16[BMI160_YAS_XY1Y2_DATA_SIZE] = {
- BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
- *v_ouflow_u8 = 0;
- /* read the yas537 xy1y2 data*/
- com_rslt = bmi160_bst_yamaha_yas537_read_xy1y2_data(
- &v_rcoil_u8, &v_busy_u8,
- &v_temperature_u16, a_xy1y2_u16, v_ouflow_u8);
- /* linear calculation*/
- xy1y2_to_xyz(a_xy1y2_u16, vector_xyz->yas537_vector_xyz);
- if (yas537_data.transform != BMI160_NULL) {
- for (i = 0; i < 3; i++) {
- a_xyz_tmp_s32[i] = ((
- yas537_data.transform[i + 3]
- * vector_xyz->yas537_vector_xyz[0])
- + (yas537_data.transform[
- i * 3 + 1]
- * vector_xyz->yas537_vector_xyz[1])
- + (yas537_data.transform[
- i * 3 + 2]
- * vector_xyz->yas537_vector_xyz[2]));
- }
- yas537_set_vector(
- vector_xyz->yas537_vector_xyz, a_xyz_tmp_s32);
- }
- for (i = 0; i < 3; i++) {
- vector_xyz->yas537_vector_xyz[i] -=
- vector_xyz->yas537_vector_xyz[i] % 10;
- if (*v_ouflow_u8 & (1 <<
- (i * 2)))
- vector_xyz->yas537_vector_xyz[i] +=
- 1; /* set overflow */
- if (*v_ouflow_u8 & (1 << (i * 2 + 1)))
- /* set underflow */
- vector_xyz->yas537_vector_xyz[i] += 2;
- }
- if (v_busy_u8)
- return ERROR;
- switch (yas537_data.measure_state) {
- case YAS537_MAG_STATE_INIT_COIL:
- if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
- com_rslt = bmi160_set_mag_manual_enable(
- BMI160_MANUAL_ENABLE);
- com_rslt += bmi160_set_mag_write_data(YAS537_WRITE_CONFR);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(YAS537_REG_CONFR);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- yas537_data.measure_state = YAS537_MAG_STATE_RECORD_DATA;
- if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
- com_rslt = bmi160_set_mag_manual_enable(
- BMI160_MANUAL_DISABLE);
- break;
- case YAS537_MAG_STATE_RECORD_DATA:
- if (v_rcoil_u8)
- break;
- yas537_set_vector(yas537_data.last_after_rcoil, a_xy1y2_u16);
- yas537_data.measure_state = YAS537_MAG_STATE_NORMAL;
- break;
- case YAS537_MAG_STATE_NORMAL:
- if (BMI160_INIT_VALUE < v_ouflow_u8
- || invalid_magnetic_field(a_xy1y2_u16,
- yas537_data.last_after_rcoil)) {
- yas537_data.measure_state = YAS537_MAG_STATE_INIT_COIL;
- for (i = 0; i < 3; i++) {
- if (!*v_ouflow_u8)
- vector_xyz->yas537_vector_xyz[i] += 3;
- }
- }
- break;
- }
-
- return com_rslt;
-}
-/*!
- * @brief This function used for read the
- * YAMAHA YAS537 xy1y2 data of fifo
- *
- * @param a_xy1y2_u16: The value of xyy1 data
- * @param v_over_flow_u8: The value of overflow
- * @param v_rcoil_u8: The value of rcoil
- * @param v_busy_u8: The value of busy flag
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_fifo_xyz_data(
-u16 *a_xy1y2_u16, u8 v_over_flow_u8, u8 v_rcoil_u8, u8 v_busy_u8)
-{
-
-s32 a_xyz_tmp_s32[BMI160_YAS_TEMP_DATA_SIZE] = {
-BMI160_INIT_VALUE, BMI160_INIT_VALUE, BMI160_INIT_VALUE};
-u8 i = BMI160_INIT_VALUE;
-s8 com_rslt = BMI160_INIT_VALUE;
-/* linear calculation*/
-xy1y2_to_xyz(a_xy1y2_u16, fifo_vector_xyz.yas537_vector_xyz);
-if (yas537_data.transform != BMI160_NULL) {
- for (i = 0; i < 3; i++) {
- a_xyz_tmp_s32[i] = ((
- yas537_data.transform[i + 3]
- * fifo_vector_xyz.yas537_vector_xyz[0])
- + (yas537_data.transform[
- i * 3 + 1]
- * fifo_vector_xyz.yas537_vector_xyz[1])
- + (yas537_data.transform[
- i * 3 + 2]
- * fifo_vector_xyz.yas537_vector_xyz[2]));
- }
- yas537_set_vector(
- fifo_vector_xyz.yas537_vector_xyz, a_xyz_tmp_s32);
-}
-for (i = 0; i < 3; i++) {
- fifo_vector_xyz.yas537_vector_xyz[i] -=
- fifo_vector_xyz.yas537_vector_xyz[i] % 10;
- if (v_over_flow_u8 & (1 <<
- (i * 2)))
- fifo_vector_xyz.yas537_vector_xyz[i] +=
- 1; /* set overflow */
- if (v_over_flow_u8 & (1 << (i * 2 + 1)))
- /* set underflow */
- fifo_vector_xyz.yas537_vector_xyz[i] += 2;
-}
-if (v_busy_u8)
- return ERROR;
-switch (yas537_data.measure_state) {
-case YAS537_MAG_STATE_INIT_COIL:
- if (p_bmi160->mag_manual_enable != BMI160_MANUAL_ENABLE)
- com_rslt = bmi160_set_mag_manual_enable(
- BMI160_MANUAL_ENABLE);
- com_rslt += bmi160_set_mag_write_data(YAS537_WRITE_CONFR);
- p_bmi160->delay_msec(BMI160_GEN_READ_WRITE_DELAY);
- com_rslt += bmi160_set_mag_write_addr(YAS537_REG_CONFR);
- p_bmi160->delay_msec(BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY);
- yas537_data.measure_state = YAS537_MAG_STATE_RECORD_DATA;
- if (p_bmi160->mag_manual_enable == BMI160_MANUAL_ENABLE)
- com_rslt = bmi160_set_mag_manual_enable(
- BMI160_MANUAL_DISABLE);
-break;
-case YAS537_MAG_STATE_RECORD_DATA:
- if (v_rcoil_u8)
- break;
- yas537_set_vector(yas537_data.last_after_rcoil, a_xy1y2_u16);
- yas537_data.measure_state = YAS537_MAG_STATE_NORMAL;
-break;
-case YAS537_MAG_STATE_NORMAL:
- if (BMI160_INIT_VALUE < v_over_flow_u8
- || invalid_magnetic_field(a_xy1y2_u16,
- yas537_data.last_after_rcoil)) {
- yas537_data.measure_state = YAS537_MAG_STATE_INIT_COIL;
- for (i = 0; i < 3; i++) {
- if (!v_over_flow_u8)
- fifo_vector_xyz.yas537_vector_xyz[i]
- += 3;
- }
- }
-break;
-}
-
-return com_rslt;
-
-}
-/*!
- * @brief This function used for reading
- * bmi160_t structure
- *
- * @return the reference and values of bmi160_t
- *
- *
-*/
-struct bmi160_t *bmi160_get_ptr(void)
-{
- return p_bmi160;
-}
diff --git a/peripheral/libupm/src/bmi160/bosch_bmi160.h b/peripheral/libupm/src/bmi160/bosch_bmi160.h
deleted file mode 100644
index 96f79da..0000000
--- a/peripheral/libupm/src/bmi160/bosch_bmi160.h
+++ /dev/null
@@ -1,12045 +0,0 @@
-/** \mainpage
-*
-****************************************************************************
-* Copyright (C) 2014 Bosch Sensortec GmbH
-*
-* File : bosch_bmi160.h
-*
-* Date : 2014/10/27
-*
-* Revision : 2.0.6 $
-*
-* Usage: Sensor Driver for BMI160 sensor
-*
-****************************************************************************
-*
-* \section License
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-*
-* Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-*
-* Neither the name of the copyright holder nor the names of the
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
-* OR CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-* OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
-* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-* ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
-*
-* The information provided is believed to be accurate and reliable.
-* The copyright holder assumes no responsibility
-* for the consequences of use
-* of such information nor for any infringement of patents or
-* other rights of third parties which may result from its use.
-* No license is granted by implication or otherwise under any patent or
-* patent rights of the copyright holder.
-**************************************************************************/
-
-/*! \file bmi160.hpp
- \brief BMI160 Sensor Driver Support Header File */
-/* user defined code to be added here ... */
-#ifndef __BMI160_H__
-#define __BMI160_H__
-
-/*!
-* @brief The following definition uses for define the data types
-*
-* @note While porting the API please consider the following
-* @note Please check the version of C standard
-* @note Are you using Linux platform
-*/
-
-/*!
-* @brief For the Linux platform support
-* Please use the types.h for your data types definitions
-*/
-#ifdef __KERNEL__
-
-#include <linux/types.h>
-/* singed integer type*/
-typedef int8_t s8;/**< used for signed 8bit */
-typedef int16_t s16;/**< used for signed 16bit */
-typedef int32_t s32;/**< used for signed 32bit */
-typedef int64_t s64;/**< used for signed 64bit */
-
-typedef u_int8_t u8;/**< used for unsigned 8bit */
-typedef u_int16_t u16;/**< used for unsigned 16bit */
-typedef u_int32_t u32;/**< used for unsigned 32bit */
-typedef u_int64_t u64;/**< used for unsigned 64bit */
-
-
-
-#else /* ! __KERNEL__ */
-/**********************************************************
-* These definition uses for define the C
-* standard version data types
-***********************************************************/
-# if !defined(__STDC_VERSION__)
-
-/************************************************
- * compiler is C11 C standard
-************************************************/
-#if (__STDC_VERSION__ == 201112L)
-
-/************************************************/
-#include <stdint.h>
-/************************************************/
-
-/*unsigned integer types*/
-typedef uint8_t u8;/**< used for unsigned 8bit */
-typedef uint16_t u16;/**< used for unsigned 16bit */
-typedef uint32_t u32;/**< used for unsigned 32bit */
-typedef uint64_t u64;/**< used for unsigned 64bit */
-
-/*signed integer types*/
-typedef int8_t s8;/**< used for signed 8bit */
-typedef int16_t s16;/**< used for signed 16bit */
-typedef int32_t s32;/**< used for signed 32bit */
-typedef int64_t s64;/**< used for signed 64bit */
-/************************************************
- * compiler is C99 C standard
-************************************************/
-
-#elif (__STDC_VERSION__ == 199901L)
-
-/* stdint.h is a C99 supported c library.
-which is used to fixed the integer size*/
-/************************************************/
-#include <stdint.h>
-/************************************************/
-
-/*unsigned integer types*/
-typedef uint8_t u8;/**< used for unsigned 8bit */
-typedef uint16_t u16;/**< used for unsigned 16bit */
-typedef uint32_t u32;/**< used for unsigned 32bit */
-typedef uint64_t u64;/**< used for unsigned 64bit */
-
-/*signed integer types*/
-typedef int8_t s8;/**< used for signed 8bit */
-typedef int16_t s16;/**< used for signed 16bit */
-typedef int32_t s32;/**< used for signed 32bit */
-typedef int64_t s64;/**< used for signed 64bit */
-/************************************************
- * compiler is C89 or other C standard
-************************************************/
-
-#else /* !defined(__STDC_VERSION__) */
-/*!
-* @brief By default it is defined as 32 bit machine configuration
-* define your data types based on your
-* machine/compiler/controller configuration
-*/
-#define MACHINE_32_BIT
-
-/*! @brief
- * If your machine support 16 bit
- * define the MACHINE_16_BIT
- */
-#ifdef MACHINE_16_BIT
-#include <limits.h>
-/*signed integer types*/
-typedef signed char s8;/**< used for signed 8bit */
-typedef signed short int s16;/**< used for signed 16bit */
-typedef signed long int s32;/**< used for signed 32bit */
-
-#if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
-typedef long int s64;/**< used for signed 64bit */
-typedef unsigned long int u64;/**< used for unsigned 64bit */
-#elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
-typedef long long int s64;/**< used for signed 64bit */
-typedef unsigned long long int u64;/**< used for unsigned 64bit */
-#else
-#warning Either the correct data type for signed 64 bit integer \
-could not be found, or 64 bit integers are not supported in your environment.
-#warning If 64 bit integers are supported on your platform, \
-please set s64 manually.
-#endif
-
-/*unsigned integer types*/
-typedef unsigned char u8;/**< used for unsigned 8bit */
-typedef unsigned short int u16;/**< used for unsigned 16bit */
-typedef unsigned long int u32;/**< used for unsigned 32bit */
-
-/* If your machine support 32 bit
-define the MACHINE_32_BIT*/
-#elif defined MACHINE_32_BIT
-/*signed integer types*/
-typedef signed char s8;/**< used for signed 8bit */
-typedef signed short int s16;/**< used for signed 16bit */
-typedef signed int s32;/**< used for signed 32bit */
-typedef signed long long int s64;/**< used for signed 64bit */
-
-/*unsigned integer types*/
-typedef unsigned char u8;/**< used for unsigned 8bit */
-typedef unsigned short int u16;/**< used for unsigned 16bit */
-typedef unsigned int u32;/**< used for unsigned 32bit */
-typedef unsigned long long int u64;/**< used for unsigned 64bit */
-
-/* If your machine support 64 bit
-define the MACHINE_64_BIT*/
-#elif defined MACHINE_64_BIT
-/*signed integer types*/
-typedef signed char s8;/**< used for signed 8bit */
-typedef signed short int s16;/**< used for signed 16bit */
-typedef signed int s32;/**< used for signed 32bit */
-typedef signed long int s64;/**< used for signed 64bit */
-
-/*unsigned integer types*/
-typedef unsigned char u8;/**< used for unsigned 8bit */
-typedef unsigned short int u16;/**< used for unsigned 16bit */
-typedef unsigned int u32;/**< used for unsigned 32bit */
-typedef unsigned long int u64;/**< used for unsigned 64bit */
-
-#else
-#warning The data types defined above which not supported \
-define the data types manually
-#endif
-#endif
-
-/*** This else will execute for the compilers
- * which are not supported the C standards
- * Like C89/C99/C11***/
-#else
-/*!
-* @brief By default it is defined as 32 bit machine configuration
-* define your data types based on your
-* machine/compiler/controller configuration
-*/
-#define MACHINE_32_BIT
-
-/* If your machine support 16 bit
-define the MACHINE_16_BIT*/
-#ifdef MACHINE_16_BIT
-#include <limits.h>
-/*signed integer types*/
-typedef signed char s8;/**< used for signed 8bit */
-typedef signed short int s16;/**< used for signed 16bit */
-typedef signed long int s32;/**< used for signed 32bit */
-
-#if defined(LONG_MAX) && LONG_MAX == 0x7fffffffffffffffL
-typedef long int s64;/**< used for signed 64bit */
-typedef unsigned long int u64;/**< used for unsigned 64bit */
-#elif defined(LLONG_MAX) && (LLONG_MAX == 0x7fffffffffffffffLL)
-typedef long long int s64;/**< used for signed 64bit */
-typedef unsigned long long int u64;/**< used for unsigned 64bit */
-#else
-#warning Either the correct data type for signed 64 bit integer \
-could not be found, or 64 bit integers are not supported in your environment.
-#warning If 64 bit integers are supported on your platform, \
-please set s64 manually.
-#endif
-
-/*unsigned integer types*/
-typedef unsigned char u8;/**< used for unsigned 8bit */
-typedef unsigned short int u16;/**< used for unsigned 16bit */
-typedef unsigned long int u32;/**< used for unsigned 32bit */
-
-/*! @brief If your machine support 32 bit
-define the MACHINE_32_BIT*/
-#elif defined MACHINE_32_BIT
-/*signed integer types*/
-typedef signed char s8;/**< used for signed 8bit */
-typedef signed short int s16;/**< used for signed 16bit */
-typedef signed int s32;/**< used for signed 32bit */
-typedef signed long long int s64;/**< used for signed 64bit */
-
-/*unsigned integer types*/
-typedef unsigned char u8;/**< used for unsigned 8bit */
-typedef unsigned short int u16;/**< used for unsigned 16bit */
-typedef unsigned int u32;/**< used for unsigned 32bit */
-typedef unsigned long long int u64;/**< used for unsigned 64bit */
-
-/* If your machine support 64 bit
-define the MACHINE_64_BIT*/
-#elif defined MACHINE_64_BIT
-/*signed integer types*/
-typedef signed char s8;/**< used for signed 8bit */
-typedef signed short int s16;/**< used for signed 16bit */
-typedef signed int s32;/**< used for signed 32bit */
-typedef signed long int s64;/**< used for signed 64bit */
-
-/*unsigned integer types*/
-typedef unsigned char u8;/**< used for unsigned 8bit */
-typedef unsigned short int u16;/**< used for unsigned 16bit */
-typedef unsigned int u32;/**< used for unsigned 32bit */
-typedef unsigned long int u64;/**< used for unsigned 64bit */
-
-#else
-#warning The data types defined above which not supported \
-define the data types manually
-#endif
-#endif
-#endif
-/***************************************************************/
-/**\name BUS READ AND WRITE FUNCTION POINTERS */
-/***************************************************************/
-/*!
- @brief Define the calling convention of YOUR bus communication routine.
- @note This includes types of parameters. This example shows the
- configuration for an SPI bus link.
-
- If your communication function looks like this:
-
- write_my_bus_xy(u8 device_addr, u8 register_addr,
- u8 * data, u8 length);
-
- The BMI160_WR_FUNC_PTR would equal:
-
- BMI160_WR_FUNC_PTR s8 (* bus_write)(u8,
- u8, u8 *, u8)
-
- Parameters can be mixed as needed refer to the
- @ref BMI160_BUS_WRITE_FUNC macro.
-
-
-*/
-#define BMI160_WR_FUNC_PTR s8 (*bus_write)(u8, u8,\
-u8 *, u8)
-/**< link macro between API function calls and bus write function
- @note The bus write function can change since this is a
- system dependant issue.
-
- If the bus_write parameter calling order is like: reg_addr,
- reg_data, wr_len it would be as it is here.
-
- If the parameters are differently ordered or your communication
- function like I2C need to know the device address,
- you can change this macro accordingly.
-
-
- BMI160_BUS_WRITE_FUNC(dev_addr, reg_addr, reg_data, wr_len)\
- bus_write(dev_addr, reg_addr, reg_data, wr_len)
-
- This macro lets all API functions call YOUR communication routine in a
- way that equals your definition in the
- @ref BMI160_WR_FUNC_PTR definition.
-
-*/
-#define BMI160_BUS_WRITE_FUNC(dev_addr, reg_addr, reg_data, wr_len)\
- bus_write(dev_addr, reg_addr, reg_data, wr_len)
-
-/**< Define the calling convention of YOUR bus communication routine.
- @note This includes types of parameters. This example shows the
- configuration for an SPI bus link.
-
- If your communication function looks like this:
-
- read_my_bus_xy(u8 device_addr, u8 register_addr,
- u8 * data, u8 length);
-
- The BMI160_RD_FUNC_PTR would equal:
-
- BMI160_RD_FUNC_PTR s8 (* bus_read)(u8,
- u8, u8 *, u8)
-
- Parameters can be mixed as needed refer to the
- refer BMI160_BUS_READ_FUNC macro.
-
-*/
-#define BMI160_SPI_RD_MASK (0x80) /* for spi read transactions on SPI the
- MSB has to be set */
-#define BMI160_RD_FUNC_PTR s8 (*bus_read)(u8,\
- u8, u8 *, u8)
-
-#define BMI160_BRD_FUNC_PTR s8 \
-(*burst_read)(u8, u8, u8 *, u32)
-
-/**< link macro between API function calls and bus read function
- @note The bus write function can change since this is a
- system dependant issue.
-
- If the bus_read parameter calling order is like: reg_addr,
- reg_data, wr_len it would be as it is here.
-
- If the parameters are differently ordered or your communication
- function like I2C need to know the device address,
- you can change this macro accordingly.
-
-
- BMI160_BUS_READ_FUNC(dev_addr, reg_addr, reg_data, wr_len)\
- bus_read(dev_addr, reg_addr, reg_data, wr_len)
-
- This macro lets all API functions call YOUR communication routine in a
- way that equals your definition in the
- refer BMI160_WR_FUNC_PTR definition.
-
- @note: this macro also includes the "MSB='1'
- for reading BMI160 addresses.
-
-*/
-#define BMI160_BUS_READ_FUNC(dev_addr, reg_addr, reg_data, r_len)\
- bus_read(dev_addr, reg_addr, reg_data, r_len)
-
-#define BMI160_BURST_READ_FUNC(device_addr, \
-register_addr, register_data, rd_len)\
-burst_read(device_addr, register_addr, register_data, rd_len)
-
-
-#define BMI160_MDELAY_DATA_TYPE u32
-
-/***************************************************************/
-/**\name BUS READ AND WRITE FUNCTION POINTERS */
-/***************************************************************/
-#define BMI160_I2C_ADDR1 (0x68)
-/**< I2C Address needs to be changed */
-#define BMI160_I2C_ADDR2 (0x69)
- /**< I2C Address needs to be changed */
-#define BMI160_AUX_BMM150_I2C_ADDRESS (0x10)
-/**< I2C address of BMM150*/
-#define BMI160_AUX_YAS532_I2C_ADDRESS (0x2E)
-/**< I2C address of YAS532*/
-#define BMI160_AUX_AKM09911_I2C_ADDR_1 (0x0C)
-/**< I2C address of AKM09911*/
-#define BMI160_AUX_AKM09911_I2C_ADDR_2 (0x0D)
-/**< I2C address of AKM09911*/
-#define BMI160_AUX_AKM09912_I2C_ADDR_1 (0x0C)
-/**< I2C address of AKM09912*/
-#define BMI160_AUX_AKM09912_I2C_ADDR_2 (0x0D)
-/**< I2C address of AKM09912*/
-#define BMI160_AUX_AKM09912_I2C_ADDR_3 (0x0E)
-/**< I2C address of AKM09912*/
-#define BMI160_AUX_AKM09912_I2C_ADDR_4 (0x0F)
-/**< I2C address of AKM09912*/
-/*******************************************/
-/**\name CONSTANTS */
-/******************************************/
-#define BMI160_INIT_VALUE (0)
-#define BMI160_ASSIGN_DATA (1)
-#define BMI160_GEN_READ_WRITE_DATA_LENGTH (1)
-#define BMI160_MAXIMUM_TIMEOUT (10)
-
-/* output data rate condition check*/
-#define BMI160_OUTPUT_DATA_RATE0 (0)
-#define BMI160_OUTPUT_DATA_RATE1 (1)
-#define BMI160_OUTPUT_DATA_RATE2 (2)
-#define BMI160_OUTPUT_DATA_RATE3 (3)
-#define BMI160_OUTPUT_DATA_RATE4 (4)
-#define BMI160_OUTPUT_DATA_RATE5 (5)
-#define BMI160_OUTPUT_DATA_RATE6 (14)
-#define BMI160_OUTPUT_DATA_RATE7 (15)
-
-/* accel range check*/
-#define BMI160_ACCEL_RANGE0 (3)
-#define BMI160_ACCEL_RANGE1 (5)
-#define BMI160_ACCEL_RANGE3 (8)
-#define BMI160_ACCEL_RANGE4 (12)
-
-/* check the status of registers*/
-#define BMI160_FOC_STAT_HIGH (1)
-#define BMI160_SIG_MOTION_STAT_HIGH (1)
-#define BMI160_STEP_DET_STAT_HIGH (1)
-
-/*condition check for reading and writing data*/
-#define BMI160_MAX_VALUE_SIGNIFICANT_MOTION (1)
-#define BMI160_MAX_VALUE_FIFO_FILTER (1)
-#define BMI160_MAX_VALUE_FIFO_TIME (1)
-#define BMI160_MAX_VALUE_FIFO_INTR (1)
-#define BMI160_MAX_VALUE_FIFO_HEADER (1)
-#define BMI160_MAX_VALUE_FIFO_MAG (1)
-#define BMI160_MAX_VALUE_FIFO_ACCEL (1)
-#define BMI160_MAX_VALUE_FIFO_GYRO (1)
-#define BMI160_MAX_VALUE_SOURCE_INTR (1)
-#define BMI160_MAX_VALUE_LOW_G_MODE (1)
-#define BMI160_MAX_VALUE_NO_MOTION (1)
-#define BMI160_MAX_VALUE_TAP_SHOCK (1)
-#define BMI160_MAX_VALUE_TAP_QUIET (1)
-#define BMI160_MAX_VALUE_ORIENT_UD (1)
-#define BMI160_MAX_VALUE_ORIENT_AXES (1)
-#define BMI160_MAX_VALUE_NVM_PROG (1)
-#define BMI160_MAX_VALUE_SPI3 (1)
-#define BMI160_MAX_VALUE_PAGE (1)
-#define BMI160_MAX_VALUE_I2C_WDT (1)
-#define BMI160_MAX_VALUE_SLEEP_STATE (1)
-#define BMI160_MAX_VALUE_WAKEUP_INTR (1)
-#define BMI160_MAX_VALUE_SELFTEST_SIGN (1)
-#define BMI160_MAX_VALUE_SELFTEST_AMP (1)
-#define BMI160_MAX_VALUE_SELFTEST_START (1)
-
-#define BMI160_MAX_GYRO_WAKEUP_TRIGGER (3)
-#define BMI160_MAX_ACCEL_SELFTEST_AXIS (3)
-#define BMI160_MAX_GYRO_STEP_COUNTER (1)
-#define BMI160_MAX_GYRO_BW (3)
-#define BMI160_MAX_ACCEL_BW (7)
-#define BMI160_MAX_ORIENT_MODE (3)
-#define BMI160_MAX_ORIENT_BLOCKING (3)
-#define BMI160_MAX_FLAT_HOLD (3)
-#define BMI160_MAX_ACCEL_FOC (3)
-#define BMI160_MAX_IF_MODE (3)
-#define BMI160_MAX_TARGET_PAGE (3)
-#define BMI160_MAX_GYRO_RANGE (4)
-#define BMI160_MAX_GYRO_SLEEP_TIGGER (7)
-#define BMI160_MAX_TAP_TURN (7)
-#define BMI160_MAX_UNDER_SAMPLING (1)
-#define BMI160_MAX_UNDER_SIG_MOTION (3)
-#define BMI160_MAX_ACCEL_OUTPUT_DATA_RATE (12)
-#define BMI160_MAX_LATCH_INTR (15)
-#define BMI160_MAX_FLAT_HYST (15)
-#define BMI160_MAX_ORIENT_THETA (63)
-#define BMI160_MAX_FLAT_THETA (63)
-
-/* FIFO index definitions*/
-#define BMI160_FIFO_X_LSB_DATA (0)
-#define BMI160_FIFO_X_MSB_DATA (1)
-#define BMI160_FIFO_Y_LSB_DATA (2)
-#define BMI160_FIFO_Y_MSB_DATA (3)
-#define BMI160_FIFO_Z_LSB_DATA (4)
-#define BMI160_FIFO_Z_MSB_DATA (5)
-#define BMI160_FIFO_R_LSB_DATA (6)
-#define BMI160_FIFO_R_MSB_DATA (7)
-/* FIFO gyro definition*/
-#define BMI160_GA_FIFO_G_X_LSB (0)
-#define BMI160_GA_FIFO_G_X_MSB (1)
-#define BMI160_GA_FIFO_G_Y_LSB (2)
-#define BMI160_GA_FIFO_G_Y_MSB (3)
-#define BMI160_GA_FIFO_G_Z_LSB (4)
-#define BMI160_GA_FIFO_G_Z_MSB (5)
-#define BMI160_GA_FIFO_A_X_LSB (6)
-#define BMI160_GA_FIFO_A_X_MSB (7)
-#define BMI160_GA_FIFO_A_Y_LSB (8)
-#define BMI160_GA_FIFO_A_Y_MSB (9)
-#define BMI160_GA_FIFO_A_Z_LSB (10)
-#define BMI160_GA_FIFO_A_Z_MSB (11)
-/* FIFO mag/gyro/accel definition*/
-#define BMI160_MGA_FIFO_M_X_LSB (0)
-#define BMI160_MGA_FIFO_M_X_MSB (1)
-#define BMI160_MGA_FIFO_M_Y_LSB (2)
-#define BMI160_MGA_FIFO_M_Y_MSB (3)
-#define BMI160_MGA_FIFO_M_Z_LSB (4)
-#define BMI160_MGA_FIFO_M_Z_MSB (5)
-#define BMI160_MGA_FIFO_M_R_LSB (6)
-#define BMI160_MGA_FIFO_M_R_MSB (7)
-#define BMI160_MGA_FIFO_G_X_LSB (8)
-#define BMI160_MGA_FIFO_G_X_MSB (9)
-#define BMI160_MGA_FIFO_G_Y_LSB (10)
-#define BMI160_MGA_FIFO_G_Y_MSB (11)
-#define BMI160_MGA_FIFO_G_Z_LSB (12)
-#define BMI160_MGA_FIFO_G_Z_MSB (13)
-#define BMI160_MGA_FIFO_A_X_LSB (14)
-#define BMI160_MGA_FIFO_A_X_MSB (15)
-#define BMI160_MGA_FIFO_A_Y_LSB (16)
-#define BMI160_MGA_FIFO_A_Y_MSB (17)
-#define BMI160_MGA_FIFO_A_Z_LSB (18)
-#define BMI160_MGA_FIFO_A_Z_MSB (19)
-/* FIFO mag definition*/
-#define BMI160_MA_FIFO_M_X_LSB (0)
-#define BMI160_MA_FIFO_M_X_MSB (1)
-#define BMI160_MA_FIFO_M_Y_LSB (2)
-#define BMI160_MA_FIFO_M_Y_MSB (3)
-#define BMI160_MA_FIFO_M_Z_LSB (4)
-#define BMI160_MA_FIFO_M_Z_MSB (5)
-#define BMI160_MA_FIFO_M_R_LSB (6)
-#define BMI160_MA_FIFO_M_R_MSB (7)
-#define BMI160_MA_FIFO_A_X_LSB (8)
-#define BMI160_MA_FIFO_A_X_MSB (9)
-#define BMI160_MA_FIFO_A_Y_LSB (10)
-#define BMI160_MA_FIFO_A_Y_MSB (11)
-#define BMI160_MA_FIFO_A_Z_LSB (12)
-#define BMI160_MA_FIFO_A_Z_MSB (13)
-/* FIFO mag/gyro definition*/
-#define BMI160_MG_FIFO_M_X_LSB (0)
-#define BMI160_MG_FIFO_M_X_MSB (1)
-#define BMI160_MG_FIFO_M_Y_LSB (2)
-#define BMI160_MG_FIFO_M_Y_MSB (3)
-#define BMI160_MG_FIFO_M_Z_LSB (4)
-#define BMI160_MG_FIFO_M_Z_MSB (5)
-#define BMI160_MG_FIFO_M_R_LSB (6)
-#define BMI160_MG_FIFO_M_R_MSB (7)
-#define BMI160_MG_FIFO_G_X_LSB (8)
-#define BMI160_MG_FIFO_G_X_MSB (9)
-#define BMI160_MG_FIFO_G_Y_LSB (10)
-#define BMI160_MG_FIFO_G_Y_MSB (11)
-#define BMI160_MG_FIFO_G_Z_LSB (12)
-#define BMI160_MG_FIFO_G_Z_MSB (13)
-/* FIFO length definitions*/
-#define BMI160_FIFO_SENSOR_TIME_LSB (0)
-#define BMI160_FIFO_SENSOR_TIME_XLSB (1)
-#define BMI160_FIFO_SENSOR_TIME_MSB (2)
-#define BMI160_FIFO_SENSOR_TIME_LENGTH (3)
-#define BMI160_FIFO_A_LENGTH (6)
-#define BMI160_FIFO_G_LENGTH (6)
-#define BMI160_FIFO_M_LENGTH (8)
-#define BMI160_FIFO_AG_LENGTH (12)
-#define BMI160_FIFO_AMG_LENGTH (20)
-#define BMI160_FIFO_MA_OR_MG_LENGTH (14)
-
-/* bus read and write length for mag, accel and gyro*/
-#define BMI160_MAG_X_DATA_LENGTH (2)
-#define BMI160_MAG_Y_DATA_LENGTH (2)
-#define BMI160_MAG_Z_DATA_LENGTH (2)
-#define BMI160_MAG_R_DATA_LENGTH (2)
-#define BMI160_MAG_XYZ_DATA_LENGTH (6)
-#define BMI160_MAG_XYZR_DATA_LENGTH (8)
-#define BMI160_MAG_YAS_DATA_LENGTH (8)
-#define BMI160_GYRO_DATA_LENGTH (2)
-#define BMI160_GYRO_XYZ_DATA_LENGTH (6)
-#define BMI160_ACCEL_DATA_LENGTH (2)
-#define BMI160_ACCEL_XYZ_DATA_LENGTH (6)
-#define BMI160_TEMP_DATA_LENGTH (2)
-#define BMI160_FIFO_DATA_LENGTH (2)
-#define BMI160_STEP_COUNTER_LENGTH (2)
-#define BMI160_SENSOR_TIME_LENGTH (3)
-
-/* Delay definitions*/
-#define BMI160_SEC_INTERFACE_GEN_READ_WRITE_DELAY (5)
-#define BMI160_BMM150_WAKEUP_DELAY1 (2)
-#define BMI160_BMM150_WAKEUP_DELAY2 (3)
-#define BMI160_BMM150_WAKEUP_DELAY3 (1)
-#define BMI160_YAS532_OFFSET_DELAY (2)
-#define BMI160_GEN_READ_WRITE_DELAY (1)
-#define BMI160_YAS532_MEASUREMENT_DELAY (25)
-#define BMI160_YAS_ACQ_COMMAND_DELAY (50)
-#define BMI160_YAS532_SET_INITIAL_VALUE_DELAY (200)
-#define BMI160_AKM_INIT_DELAY (60)
-/****************************************************/
-/**\name ARRAY SIZE DEFINITIONS */
-/***************************************************/
-#define BMI160_ACCEL_X_DATA_SIZE (2)
-#define BMI160_ACCEL_Y_DATA_SIZE (2)
-#define BMI160_ACCEL_Z_DATA_SIZE (2)
-#define BMI160_ACCEL_XYZ_DATA_SIZE (6)
-
-#define BMI160_GYRO_X_DATA_SIZE (2)
-#define BMI160_GYRO_Y_DATA_SIZE (2)
-#define BMI160_GYRO_Z_DATA_SIZE (2)
-#define BMI160_GYRO_XYZ_DATA_SIZE (6)
-
-#define BMI160_MAG_X_DATA_SIZE (2)
-#define BMI160_MAG_Y_DATA_SIZE (2)
-#define BMI160_MAG_Z_DATA_SIZE (2)
-#define BMI160_MAG_R_DATA_SIZE (2)
-#define BMI160_MAG_XYZ_DATA_SIZE (6)
-#define BMI160_MAG_XYZR_DATA_SIZE (8)
-#define BMI160_MAG_TRIM_DATA_SIZE (16)
-
-
-#define BMI160_TEMP_DATA_SIZE (2)
-#define BMI160_FIFO_DATA_SIZE (2)
-#define BMI160_STEP_COUNT_DATA_SIZE (2)
-
-#define BMI160_SENSOR_TIME_DATA_SIZE (3)
-#define BMI160_AKM_SENSITIVITY_DATA_SIZE (3)
-#define BMI160_HARD_OFFSET_DATA_SIZE (3)
-#define BMI160_YAS_XY1Y2_DATA_SIZE (3)
-#define BMI160_YAS_FLAG_DATA_SIZE (3)
-#define BMI160_YAS_TEMP_DATA_SIZE (3)
-#define BMI160_YAS_H_DATA_SIZE (3)
-#define BMI160_YAS_S_DATA_SIZE (3)
-#define BMI160_YAS_CORRECT_DATA_SIZE (5)
-#define BMI160_YAS_XY1Y2T_DATA_SIZE (8)
-#define BMI160_YAS537_CALIB_DATA_SIZE (17)
-#define BMI160_YAS532_CALIB_DATA_SIZE (14)
-
-/****************************************************/
-/**\name ARRAY PARAMETER DEFINITIONS */
-/***************************************************/
-#define BMI160_SENSOR_TIME_MSB_BYTE (2)
-#define BMI160_SENSOR_TIME_XLSB_BYTE (1)
-#define BMI160_SENSOR_TIME_LSB_BYTE (0)
-
-#define BMI160_MAG_X_LSB_BYTE (0)
-#define BMI160_MAG_X_MSB_BYTE (1)
-#define BMI160_MAG_Y_LSB_BYTE (0)
-#define BMI160_MAG_Y_MSB_BYTE (1)
-#define BMI160_MAG_Z_LSB_BYTE (0)
-#define BMI160_MAG_Z_MSB_BYTE (1)
-#define BMI160_MAG_R_LSB_BYTE (0)
-#define BMI160_MAG_R_MSB_BYTE (1)
-#define BMI160_DATA_FRAME_MAG_X_LSB_BYTE (0)
-#define BMI160_DATA_FRAME_MAG_X_MSB_BYTE (1)
-#define BMI160_DATA_FRAME_MAG_Y_LSB_BYTE (2)
-#define BMI160_DATA_FRAME_MAG_Y_MSB_BYTE (3)
-#define BMI160_DATA_FRAME_MAG_Z_LSB_BYTE (4)
-#define BMI160_DATA_FRAME_MAG_Z_MSB_BYTE (5)
-#define BMI160_DATA_FRAME_MAG_R_LSB_BYTE (6)
-#define BMI160_DATA_FRAME_MAG_R_MSB_BYTE (7)
-
-#define BMI160_GYRO_X_LSB_BYTE (0)
-#define BMI160_GYRO_X_MSB_BYTE (1)
-#define BMI160_GYRO_Y_LSB_BYTE (0)
-#define BMI160_GYRO_Y_MSB_BYTE (1)
-#define BMI160_GYRO_Z_LSB_BYTE (0)
-#define BMI160_GYRO_Z_MSB_BYTE (1)
-#define BMI160_DATA_FRAME_GYRO_X_LSB_BYTE (0)
-#define BMI160_DATA_FRAME_GYRO_X_MSB_BYTE (1)
-#define BMI160_DATA_FRAME_GYRO_Y_LSB_BYTE (2)
-#define BMI160_DATA_FRAME_GYRO_Y_MSB_BYTE (3)
-#define BMI160_DATA_FRAME_GYRO_Z_LSB_BYTE (4)
-#define BMI160_DATA_FRAME_GYRO_Z_MSB_BYTE (5)
-
-#define BMI160_ACCEL_X_LSB_BYTE (0)
-#define BMI160_ACCEL_X_MSB_BYTE (1)
-#define BMI160_ACCEL_Y_LSB_BYTE (0)
-#define BMI160_ACCEL_Y_MSB_BYTE (1)
-#define BMI160_ACCEL_Z_LSB_BYTE (0)
-#define BMI160_ACCEL_Z_MSB_BYTE (1)
-#define BMI160_DATA_FRAME_ACCEL_X_LSB_BYTE (0)
-#define BMI160_DATA_FRAME_ACCEL_X_MSB_BYTE (1)
-#define BMI160_DATA_FRAME_ACCEL_Y_LSB_BYTE (2)
-#define BMI160_DATA_FRAME_ACCEL_Y_MSB_BYTE (3)
-#define BMI160_DATA_FRAME_ACCEL_Z_LSB_BYTE (4)
-#define BMI160_DATA_FRAME_ACCEL_Z_MSB_BYTE (5)
-
-#define BMI160_TEMP_LSB_BYTE (0)
-#define BMI160_TEMP_MSB_BYTE (1)
-
-#define BMI160_FIFO_LENGTH_LSB_BYTE (0)
-#define BMI160_FIFO_LENGTH_MSB_BYTE (1)
-
-#define BMI160_STEP_COUNT_LSB_BYTE (0)
-#define BMI160_STEP_COUNT_MSB_BYTE (1)
-/****************************************************/
-/**\name ERROR CODES */
-/***************************************************/
-
-#define E_BMI160_NULL_PTR ((s8)-127)
-#define E_BMI160_COMM_RES ((s8)-1)
-#define E_BMI160_OUT_OF_RANGE ((s8)-2)
-#define E_BMI160_BUSY ((s8)-3)
-#define SUCCESS ((u8)0)
-#define ERROR ((s8)-1)
-
-/* Constants */
-#define BMI160_NULL (0)
-#define BMI160_DELAY_SETTLING_TIME (5)
-/*This refers BMI160 return type as s8 */
-#define BMI160_RETURN_FUNCTION_TYPE s8
-/****************************************************/
-/**\name REGISTER DEFINITIONS */
-/***************************************************/
-/*******************/
-/**\name CHIP ID */
-/*******************/
-#define BMI160_USER_CHIP_ID_ADDR (0x00)
-/*******************/
-/**\name ERROR STATUS */
-/*******************/
-#define BMI160_USER_ERROR_ADDR (0X02)
-/*******************/
-/**\name POWER MODE STATUS */
-/*******************/
-#define BMI160_USER_PMU_STAT_ADDR (0X03)
-/*******************/
-/**\name MAG DATA REGISTERS */
-/*******************/
-#define BMI160_USER_DATA_0_ADDR (0X04)
-#define BMI160_USER_DATA_1_ADDR (0X05)
-#define BMI160_USER_DATA_2_ADDR (0X06)
-#define BMI160_USER_DATA_3_ADDR (0X07)
-#define BMI160_USER_DATA_4_ADDR (0X08)
-#define BMI160_USER_DATA_5_ADDR (0X09)
-#define BMI160_USER_DATA_6_ADDR (0X0A)
-#define BMI160_USER_DATA_7_ADDR (0X0B)
-/*******************/
-/**\name GYRO DATA REGISTERS */
-/*******************/
-#define BMI160_USER_DATA_8_ADDR (0X0C)
-#define BMI160_USER_DATA_9_ADDR (0X0D)
-#define BMI160_USER_DATA_10_ADDR (0X0E)
-#define BMI160_USER_DATA_11_ADDR (0X0F)
-#define BMI160_USER_DATA_12_ADDR (0X10)
-#define BMI160_USER_DATA_13_ADDR (0X11)
-#define BMI160_USER_DATA_14_ADDR (0X12)
-#define BMI160_USER_DATA_15_ADDR (0X13)
-/*******************/
-/**\name ACCEL DATA REGISTERS */
-/*******************/
-#define BMI160_USER_DATA_16_ADDR (0X14)
-#define BMI160_USER_DATA_17_ADDR (0X15)
-#define BMI160_USER_DATA_18_ADDR (0X16)
-#define BMI160_USER_DATA_19_ADDR (0X17)
-/*******************/
-/**\name SENSOR TIME REGISTERS */
-/*******************/
-#define BMI160_USER_SENSORTIME_0_ADDR (0X18)
-#define BMI160_USER_SENSORTIME_1_ADDR (0X19)
-#define BMI160_USER_SENSORTIME_2_ADDR (0X1A)
-/*******************/
-/**\name STATUS REGISTER FOR SENSOR STATUS FLAG */
-/*******************/
-#define BMI160_USER_STAT_ADDR (0X1B)
-/*******************/
-/**\name INTERRUPY STATUS REGISTERS */
-/*******************/
-#define BMI160_USER_INTR_STAT_0_ADDR (0X1C)
-#define BMI160_USER_INTR_STAT_1_ADDR (0X1D)
-#define BMI160_USER_INTR_STAT_2_ADDR (0X1E)
-#define BMI160_USER_INTR_STAT_3_ADDR (0X1F)
-/*******************/
-/**\name TEMPERATURE REGISTERS */
-/*******************/
-#define BMI160_USER_TEMPERATURE_0_ADDR (0X20)
-#define BMI160_USER_TEMPERATURE_1_ADDR (0X21)
-/*******************/
-/**\name FIFO REGISTERS */
-/*******************/
-#define BMI160_USER_FIFO_LENGTH_0_ADDR (0X22)
-#define BMI160_USER_FIFO_LENGTH_1_ADDR (0X23)
-#define BMI160_USER_FIFO_DATA_ADDR (0X24)
-/***************************************************/
-/**\name ACCEL CONFIG REGISTERS FOR ODR, BANDWIDTH AND UNDERSAMPLING*/
-/******************************************************/
-#define BMI160_USER_ACCEL_CONFIG_ADDR (0X40)
-/*******************/
-/**\name ACCEL RANGE */
-/*******************/
-#define BMI160_USER_ACCEL_RANGE_ADDR (0X41)
-/***************************************************/
-/**\name GYRO CONFIG REGISTERS FOR ODR AND BANDWIDTH */
-/******************************************************/
-#define BMI160_USER_GYRO_CONFIG_ADDR (0X42)
-/*******************/
-/**\name GYRO RANGE */
-/*******************/
-#define BMI160_USER_GYRO_RANGE_ADDR (0X43)
-/***************************************************/
-/**\name MAG CONFIG REGISTERS FOR ODR*/
-/******************************************************/
-#define BMI160_USER_MAG_CONFIG_ADDR (0X44)
-/***************************************************/
-/**\name REGISTER FOR GYRO AND ACCEL DOWNSAMPLING RATES FOR FIFO*/
-/******************************************************/
-#define BMI160_USER_FIFO_DOWN_ADDR (0X45)
-/***************************************************/
-/**\name FIFO CONFIG REGISTERS*/
-/******************************************************/
-#define BMI160_USER_FIFO_CONFIG_0_ADDR (0X46)
-#define BMI160_USER_FIFO_CONFIG_1_ADDR (0X47)
-/***************************************************/
-/**\name MAG INTERFACE REGISTERS*/
-/******************************************************/
-#define BMI160_USER_MAG_IF_0_ADDR (0X4B)
-#define BMI160_USER_MAG_IF_1_ADDR (0X4C)
-#define BMI160_USER_MAG_IF_2_ADDR (0X4D)
-#define BMI160_USER_MAG_IF_3_ADDR (0X4E)
-#define BMI160_USER_MAG_IF_4_ADDR (0X4F)
-/***************************************************/
-/**\name INTERRUPT ENABLE REGISTERS*/
-/******************************************************/
-#define BMI160_USER_INTR_ENABLE_0_ADDR (0X50)
-#define BMI160_USER_INTR_ENABLE_1_ADDR (0X51)
-#define BMI160_USER_INTR_ENABLE_2_ADDR (0X52)
-#define BMI160_USER_INTR_OUT_CTRL_ADDR (0X53)
-/***************************************************/
-/**\name LATCH DURATION REGISTERS*/
-/******************************************************/
-#define BMI160_USER_INTR_LATCH_ADDR (0X54)
-/***************************************************/
-/**\name MAP INTERRUPT 1 and 2 REGISTERS*/
-/******************************************************/
-#define BMI160_USER_INTR_MAP_0_ADDR (0X55)
-#define BMI160_USER_INTR_MAP_1_ADDR (0X56)
-#define BMI160_USER_INTR_MAP_2_ADDR (0X57)
-/***************************************************/
-/**\name DATA SOURCE REGISTERS*/
-/******************************************************/
-#define BMI160_USER_INTR_DATA_0_ADDR (0X58)
-#define BMI160_USER_INTR_DATA_1_ADDR (0X59)
-/***************************************************/
-/**\name
-INTERRUPT THRESHOLD, HYSTERESIS, DURATION, MODE CONFIGURATION REGISTERS*/
-/******************************************************/
-#define BMI160_USER_INTR_LOWHIGH_0_ADDR (0X5A)
-#define BMI160_USER_INTR_LOWHIGH_1_ADDR (0X5B)
-#define BMI160_USER_INTR_LOWHIGH_2_ADDR (0X5C)
-#define BMI160_USER_INTR_LOWHIGH_3_ADDR (0X5D)
-#define BMI160_USER_INTR_LOWHIGH_4_ADDR (0X5E)
-#define BMI160_USER_INTR_MOTION_0_ADDR (0X5F)
-#define BMI160_USER_INTR_MOTION_1_ADDR (0X60)
-#define BMI160_USER_INTR_MOTION_2_ADDR (0X61)
-#define BMI160_USER_INTR_MOTION_3_ADDR (0X62)
-#define BMI160_USER_INTR_TAP_0_ADDR (0X63)
-#define BMI160_USER_INTR_TAP_1_ADDR (0X64)
-#define BMI160_USER_INTR_ORIENT_0_ADDR (0X65)
-#define BMI160_USER_INTR_ORIENT_1_ADDR (0X66)
-#define BMI160_USER_INTR_FLAT_0_ADDR (0X67)
-#define BMI160_USER_INTR_FLAT_1_ADDR (0X68)
-/***************************************************/
-/**\name FAST OFFSET CONFIGURATION REGISTER*/
-/******************************************************/
-#define BMI160_USER_FOC_CONFIG_ADDR (0X69)
-/***************************************************/
-/**\name MISCELLANEOUS CONFIGURATION REGISTER*/
-/******************************************************/
-#define BMI160_USER_CONFIG_ADDR (0X6A)
-/***************************************************/
-/**\name SERIAL INTERFACE SETTINGS REGISTER*/
-/******************************************************/
-#define BMI160_USER_IF_CONFIG_ADDR (0X6B)
-/***************************************************/
-/**\name GYRO POWER MODE TRIGGER REGISTER */
-/******************************************************/
-#define BMI160_USER_PMU_TRIGGER_ADDR (0X6C)
-/***************************************************/
-/**\name SELF_TEST REGISTER*/
-/******************************************************/
-#define BMI160_USER_SELF_TEST_ADDR (0X6D)
-/***************************************************/
-/**\name SPI,I2C SELECTION REGISTER*/
-/******************************************************/
-#define BMI160_USER_NV_CONFIG_ADDR (0x70)
-/***************************************************/
-/**\name ACCEL AND GYRO OFFSET REGISTERS*/
-/******************************************************/
-#define BMI160_USER_OFFSET_0_ADDR (0X71)
-#define BMI160_USER_OFFSET_1_ADDR (0X72)
-#define BMI160_USER_OFFSET_2_ADDR (0X73)
-#define BMI160_USER_OFFSET_3_ADDR (0X74)
-#define BMI160_USER_OFFSET_4_ADDR (0X75)
-#define BMI160_USER_OFFSET_5_ADDR (0X76)
-#define BMI160_USER_OFFSET_6_ADDR (0X77)
-/***************************************************/
-/**\name STEP COUNTER INTERRUPT REGISTERS*/
-/******************************************************/
-#define BMI160_USER_STEP_COUNT_0_ADDR (0X78)
-#define BMI160_USER_STEP_COUNT_1_ADDR (0X79)
-/***************************************************/
-/**\name STEP COUNTER CONFIGURATION REGISTERS*/
-/******************************************************/
-#define BMI160_USER_STEP_CONFIG_0_ADDR (0X7A)
-#define BMI160_USER_STEP_CONFIG_1_ADDR (0X7B)
-/***************************************************/
-/**\name COMMAND REGISTER*/
-/******************************************************/
-#define BMI160_CMD_COMMANDS_ADDR (0X7E)
-/***************************************************/
-/**\name PAGE REGISTERS*/
-/******************************************************/
-#define BMI160_CMD_EXT_MODE_ADDR (0X7F)
-#define BMI160_COM_C_TRIM_FIVE_ADDR (0X05)
-
-/****************************************************/
-/**\name SHIFT VALUE DEFINITION */
-/***************************************************/
-#define BMI160_SHIFT_BIT_POSITION_BY_01_BIT (1)
-#define BMI160_SHIFT_BIT_POSITION_BY_02_BITS (2)
-#define BMI160_SHIFT_BIT_POSITION_BY_03_BITS (3)
-#define BMI160_SHIFT_BIT_POSITION_BY_04_BITS (4)
-#define BMI160_SHIFT_BIT_POSITION_BY_05_BITS (5)
-#define BMI160_SHIFT_BIT_POSITION_BY_06_BITS (6)
-#define BMI160_SHIFT_BIT_POSITION_BY_07_BITS (7)
-#define BMI160_SHIFT_BIT_POSITION_BY_08_BITS (8)
-#define BMI160_SHIFT_BIT_POSITION_BY_09_BITS (9)
-#define BMI160_SHIFT_BIT_POSITION_BY_12_BITS (12)
-#define BMI160_SHIFT_BIT_POSITION_BY_13_BITS (13)
-#define BMI160_SHIFT_BIT_POSITION_BY_14_BITS (14)
-#define BMI160_SHIFT_BIT_POSITION_BY_15_BITS (15)
-#define BMI160_SHIFT_BIT_POSITION_BY_16_BITS (16)
-
-/****************************************************/
-/**\name DEFINITIONS USED FOR YAMAHA-YAS532 */
-/***************************************************/
-#define YAS532_MAG_STATE_NORMAL (0)
-#define YAS532_MAG_STATE_INIT_COIL (1)
-#define YAS532_MAG_STATE_MEASURE_OFFSET (2)
-#define YAS532_MAG_INITCOIL_TIMEOUT (1000)
-#define YAS532_MAG_NOTRANS_POSITION (3)
-#define YAS532_DEFAULT_SENSOR_DELAY (50)
-#define YAS532_DATA_OVERFLOW (8190)
-#define YAS532_DATA_UNDERFLOW (0)
-#define YAS532_MAG_TEMPERATURE_LOG (10)
-#define YAS532_TEMP20DEGREE_TYPICAL (390)
-#define YAS532_VERSION_AC_COEF_X (850)
-#define YAS532_VERSION_AC_COEF_Y1 (750)
-#define YAS532_VERSION_AC_COEF_Y2 (750)
-#define YAS532_DATA_CENTER (4096)
-/****************************************************/
-/**\name YAMAHA-YAS532 OFFSET DEFINITION */
-/***************************************************/
-static const s8 INVALID_OFFSET[] = {0x7f, 0x7f, 0x7f};
-#define set_vector(to, from) \
- {int _l; for (_l = 0; _l < 3; _l++) (to)[_l] = (from)[_l]; }
-#define is_valid_offset(a) \
- (((a)[0] <= 31) && ((a)[1] <= 31) && ((a)[2] <= 31) \
- && (-31 <= (a)[0]) && (-31 <= (a)[1]) && (-31 <= (a)[2]))
-
-/**************************************************/
-/**\name YAS532 CALIB DATA DEFINITIONS */
-/*************************************************/
-
-
-/* register address of YAS532*/
-#define BMI160_YAS532_TESTR1 (0x88)
-#define BMI160_YAS532_TESTR2 (0x89)
-#define BMI160_YAS532_RCOIL (0x81)
-#define BMI160_YAS532_COMMAND_REGISTER (0x82)
-#define BMI160_YAS532_DATA_REGISTER (0xB0)
-/* calib data register definition*/
-#define BMI160_YAS532_CALIB_CX (0x90)
-#define BMI160_YAS532_CALIB_CY1 (0x91)
-#define BMI160_YAS532_CALIB_CY2 (0x92)
-#define BMI160_YAS532_CALIB1 (0x93)
-#define BMI160_YAS532_CALIB2 (0x94)
-#define BMI160_YAS532_CALIB3 (0x95)
-#define BMI160_YAS532_CALIB4 (0x96)
-#define BMI160_YAS532_CALIB5 (0x97)
-#define BMI160_YAS532_CLAIB6 (0x98)
-#define BMI160_YAS532_CALIB7 (0x99)
-#define BMI160_YAS532_CALIB8 (0x9A)
-#define BMI160_YAS532_CALIIB9 (0x9B)
-#define BMI160_YAS532_CALIB10 (0x9C)
-#define BMI160_YAS532_CALIB11 (0x9D)
-/* offset definition */
-#define BMI160_YAS532_OFFSET_X (0x85)
-#define BMI160_YAS532_OFFSET_Y (0x86)
-#define BMI160_YAS532_OFFSET_Z (0x87)
-/* data to write register for yas532*/
-#define BMI160_YAS532_WRITE_TESTR1 (0x00)
-#define BMI160_YAS532_WRITE_TESTR2 (0x00)
-#define BMI160_YAS532_WRITE_RCOIL (0x00)
-/**************************************************/
-/**\name YAS537 DEFINITION */
-/*************************************************/
-
-#define YAS537_SRSTR_DATA (0x02)
-#define YAS537_WRITE_A_D_CONVERTER (0x03)
-#define YAS537_WRITE_A_D_CONVERTER2 (0xF8)
-#define YAS537_WRITE_FILTER (0x08)
-#define YAS537_WRITE_CONFR (0x08)
-#define YAS537_WRITE_TEMP_CALIB (0xFF)
-#define YAS537_SET_COMMAND_REGISTER (0x01)
-
-/**************************************************/
-/**\name YAS537 REGISTER DEFINITION */
-/*************************************************/
-#define YAS537_REG_SRSTR (0x90)
-#define YAS537_REG_CALR_C0 (0xC0)
-#define YAS537_REG_CALR_C1 (0xC1)
-#define YAS537_REG_CALR_C2 (0xC2)
-#define YAS537_REG_CALR_C3 (0xC3)
-#define YAS537_REG_CALR_C4 (0xC4)
-#define YAS537_REG_CALR_C5 (0xC5)
-#define YAS537_REG_CALR_C6 (0xC6)
-#define YAS537_REG_CALR_C7 (0xC7)
-#define YAS537_REG_CALR_C8 (0xC8)
-#define YAS537_REG_CALR_C9 (0xC9)
-#define YAS537_REG_CALR_CA (0xCA)
-#define YAS537_REG_CALR_CB (0xCB)
-#define YAS537_REG_CALR_CC (0xCC)
-#define YAS537_REG_CALR_CD (0xCD)
-#define YAS537_REG_CALR_CE (0xCE)
-#define YAS537_REG_CALR_CF (0xCF)
-#define YAS537_REG_CALR_DO (0xD0)
-#define YAS537_REG_MTCR (0x93)
-#define YAS537_REG_CONFR (0x82)
-#define BMI160_REG_YAS537_CMDR (0x81)
-#define YAS537_REG_OXR (0x84)
-#define YAS537_REG_AVRR (0x87)
-#define YAS537_REG_HCKR (0x88)
-#define YAS537_REG_LCKR (0x89)
-#define YAS537_REG_ADCCALR (0x91)
-#define YAS537_REG_ADCCALR_ONE (0x92)
-#define YAS537_REG_OCR (0x9E)
-#define YAS537_REG_TRMR (0x9F)
-#define YAS537_REG_TEMPERATURE_0 (0xB0)
-#define YAS537_REG_TEMPERATURE_1 (0xB1)
-#define YAS537_REG_DATA_X_0 (0xB2)
-#define YAS537_REG_DATA_X_1 (0xB3)
-#define YAS537_REG_DATA_Y1_0 (0xB4)
-#define YAS537_REG_DATA_Y1_1 (0xB5)
-#define YAS537_REG_DATA_Y2_0 (0xB6)
-#define YAS537_REG_DATA_Y2_1 (0xB7)
-#define YAS537_MAG_STATE_NORMAL (0)
-#define YAS537_MAG_STATE_INIT_COIL (1)
-#define YAS537_MAG_STATE_RECORD_DATA (2)
-#define YAS537_DATA_UNDERFLOW (0)
-#define YAS537_DATA_OVERFLOW (16383)
-/****************************************************/
-/**\name YAS537_set vector */
-/***************************************************/
-#define yas537_set_vector(to, from) \
- {int _l; for (_l = 0; _l < 3; _l++) (to)[_l] = (from)[_l]; }
-
-#ifndef ABS
-#define ABS(a) ((a) > 0 ? (a) : -(a)) /*!< Absolute value */
-#endif
-/****************************************************/
-/**\name AKM09911 AND AKM09912 DEFINITION */
-/***************************************************/
-#define AKM09912_SENSITIVITY_DIV (256)
-#define AKM09912_SENSITIVITY (128)
-#define AKM09911_SENSITIVITY_DIV (128)
-#define AKM_ASAX (0)
-#define AKM_ASAY (1)
-#define AKM_ASAZ (2)
-#define AKM_POWER_DOWN_MODE_DATA (0x00)
-#define AKM_FUSE_ROM_MODE (0x1F)
-#define AKM_POWER_MODE_REG (0x31)
-#define AKM_SINGLE_MEASUREMENT_MODE (0x01)
-#define AKM_DATA_REGISTER (0x11)
-/*! AKM09912 Register definition */
-#define AKM_CHIP_ID_REG (0x01)
-/****************************************************/
-/**\name BMM150 DEFINITION */
-/***************************************************/
-#define BMI160_BMM150_SET_POWER_CONTROL (0x01)
-#define BMI160_BMM150_MAX_RETRY_WAKEUP (5)
-#define BMI160_BMM150_POWER_ON (0x01)
-#define BMI160_BMM150_POWER_OFF (0x00)
-#define BMI160_BMM150_FORCE_MODE (0x02)
-#define BMI160_BMM150_POWER_ON_SUCCESS (0)
-#define BMI160_BMM150_POWER_ON_FAIL ((s8)-1)
-
-#define BMI160_BMM150_DIG_X1 (0)
-#define BMI160_BMM150_DIG_Y1 (1)
-#define BMI160_BMM150_DIG_X2 (2)
-#define BMI160_BMM150_DIG_Y3 (3)
-#define BMI160_BMM150_DIG_XY1 (4)
-#define BMI160_BMM150_DIG_XY2 (5)
-#define BMI160_BMM150_DIG_Z1_LSB (6)
-#define BMI160_BMM150_DIG_Z1_MSB (7)
-#define BMI160_BMM150_DIG_Z2_LSB (8)
-#define BMI160_BMM150_DIG_Z2_MSB (9)
-#define BMI160_BMM150_DIG_DIG_Z3_LSB (10)
-#define BMI160_BMM150_DIG_DIG_Z3_MSB (11)
-#define BMI160_BMM150_DIG_DIG_Z4_LSB (12)
-#define BMI160_BMM150_DIG_DIG_Z4_MSB (13)
-#define BMI160_BMM150_DIG_DIG_XYZ1_LSB (14)
-#define BMI160_BMM150_DIG_DIG_XYZ1_MSB (15)
-#define BMI160_FIFO_FRAME_CNT (146)
-#define BMI160_FRAME_COUNT (1)
-
-/**************************************************************/
-/**\name STRUCTURE DEFINITIONS */
-/**************************************************************/
-/*!
-* @brief bmi160 structure
-* This structure holds all relevant information about bmi160
-*/
-struct bmi160_t {
-u8 chip_id;/**< chip id of BMI160 */
-u8 dev_addr;/**< device address of BMI160 */
-s8 mag_manual_enable;/**< used for check the mag manual/auto mode status */
-BMI160_WR_FUNC_PTR;/**< bus write function pointer */
-BMI160_RD_FUNC_PTR;/**< bus read function pointer */
-BMI160_BRD_FUNC_PTR;/**< burst write function pointer */
-void (*delay_msec)(BMI160_MDELAY_DATA_TYPE);/**< delay function pointer */
-};
-/*!
- * @brief Structure containing bmm150 and akm09911
- * magnetometer values for x,y and
- * z-axis in s16
- */
-struct bmi160_mag_t {
-s32 x;/**< BMM150 and AKM09911 and AKM09912 X raw data*/
-s32 y;/**< BMM150 and AKM09911 and AKM09912 Y raw data*/
-s32 z;/**< BMM150 and AKM09911 and AKM09912 Z raw data*/
-};
-/*!
- * @brief Structure containing bmm150 xyz data and temperature
- */
-struct bmi160_mag_xyzr_t {
-s16 x;/**< BMM150 X raw data*/
-s16 y;/**< BMM150 Y raw data*/
-s16 z;/**<BMM150 Z raw data*/
-u16 r;/**<BMM150 R raw data*/
-};
-/*!
- * @brief Structure containing gyro xyz data
- */
-struct bmi160_gyro_t {
-s16 x;/**<gyro X data*/
-s16 y;/**<gyro Y data*/
-s16 z;/**<gyro Z data*/
-};
-/*!
- * @brief Structure containing accel xyz data
- */
-struct bmi160_accel_t {
-s16 x;/**<accel X data*/
-s16 y;/**<accel Y data*/
-s16 z;/**<accel Z data*/
-};
-/*!
- * @brief Structure bmm150 mag compensated data with s32 output
- */
-struct bmi160_mag_xyz_s32_t {
-s32 x;/**<BMM150 X compensated data*/
-s32 y;/**<BMM150 Y compensated data*/
-s32 z;/**<BMM150 Z compensated data*/
-};
-/*!
- * @brief Structure bmm150 mag trim data
- */
-struct trim_data_t {
-s8 dig_x1;/**<BMM150 trim x1 data*/
-s8 dig_y1;/**<BMM150 trim y1 data*/
-
-s8 dig_x2;/**<BMM150 trim x2 data*/
-s8 dig_y2;/**<BMM150 trim y2 data*/
-
-u16 dig_z1;/**<BMM150 trim z1 data*/
-s16 dig_z2;/**<BMM150 trim z2 data*/
-s16 dig_z3;/**<BMM150 trim z3 data*/
-s16 dig_z4;/**<BMM150 trim z4 data*/
-
-u8 dig_xy1;/**<BMM150 trim xy1 data*/
-s8 dig_xy2;/**<BMM150 trim xy2 data*/
-
-u16 dig_xyz1;/**<BMM150 trim xyz1 data*/
-};
-/*!
- * @brief Used to read the akm compensated values
-*/
-struct bmi160_bst_akm_xyz_t {
-s32 x;/**<AKM09911 and AKM09912 X compensated data*/
-s32 y;/**<AKM09911 and AKM09912 Y compensated data*/
-s32 z;/**<AKM09911 and AKM09912 Z compensated data*/
-};
-/*!
-* @brief Structure for reading AKM compensating data
-*/
-struct bst_akm_sensitivity_data_t {
-u8 asax;/**<AKM09911 and AKM09912 X sensitivity data*/
-u8 asay;/**<AKM09911 and AKM09912 Y sensitivity data*/
-u8 asaz;/**<AKM09911 and AKM09912 Z sensitivity data*/
-};
-/*!
-* @brief YAMAHA-YAS532 struct
-* Calibration YAS532 data struct
-*/
-struct bst_yas532_calib_data_t {
-s32 cx;/**<YAS532 calib cx data */
-s32 cy1;/**<YAS532 calib cy1 data */
-s32 cy2;/**<YAS532 calib cy2 data */
-s32 a2;/**<YAS532 calib a2 data */
-s32 a3;/**<YAS532 calib a3 data */
-s32 a4;/**<YAS532 calib a4 data */
-s32 a5;/**<YAS532 calib a5 data */
-s32 a6;/**<YAS532 calib a6 data */
-s32 a7;/**<YAS532 calib a7 data */
-s32 a8;/**<YAS532 calib a8 data */
-s32 a9;/**<YAS532 calib a9 data */
-s32 k;/**<YAS532 calib k data */
-s8 rxy1y2[3];/**<YAS532 calib rxy1y2 data */
-u8 fxy1y2[3];/**<YAS532 calib fxy1y2 data */
-};
-/*!
-* @brief YAS532 Temperature structure
-*/
-#if 1 < YAS532_MAG_TEMPERATURE_LOG
-struct yas_temp_filter_t {
-u16 log[YAS532_MAG_TEMPERATURE_LOG];/**<YAS532 temp log array */
-u8 num;/**< used for increment the index */
-u8 idx;/**< used for increment the index */
-};
-#endif
-/*!
-* @brief YAS532 sensor initialization
-*/
-struct yas532_t {
-struct bst_yas532_calib_data_t calib_yas532;/**< calib data */
-s8 measure_state;/**< update measure state */
-s8 v_hard_offset_s8[3];/**< offset write array*/
-s32 coef[3];/**< co efficient data */
-s8 overflow;/**< over flow condition check */
-u8 dev_id;/**< device id information */
-const s8 *transform;/**< transform condition check */
-#if 1 < YAS532_MAG_TEMPERATURE_LOG
-struct yas_temp_filter_t temp_data;/**< temp data */
-#endif
-u16 last_raw[4];/**< raw data */
-};
-/*!
-* @brief Used for reading the YAS532 XYZ data
-*/
-struct yas532_vector {
-s32 yas532_vector_xyz[3];/**< YAS532 compensated xyz data*/
-};
-/*!
-* @brief Used for reading the YAS532 XYZ data
-*/
-struct yas532_data {
-s32 x;
-s32 y;
-s32 z;
-};
-/**
- * @struct yas_vector
- * @brief Stores the sensor data
- */
-struct yas_vector {
- s32 yas537_vector_xyz[3]; /*!< vector data */
-};
-/*!
-* @brief YAMAHA-YAS532 struct
-* Calibration YAS532 data struct
-*/
-struct bst_yas537_calib_data_t {
-s8 a2;/**<YAS532 calib a2 data */
-s8 a3;/**<YAS532 calib a3 data */
-s8 a4;/**<YAS532 calib a4 data */
-s16 a5;/**<YAS532 calib a5 data */
-s8 a6;/**<YAS532 calib a6 data */
-s8 a7;/**<YAS532 calib a7 data */
-s8 a8;/**<YAS532 calib a8 data */
-s16 a9;/**<YAS532 calib a9 data */
-u8 k;/**<YAS532 calib k data */
-u8 ver;/**<YAS532 calib ver data*/
-};
-/*!
-* @brief YAS537 sensor initialization
-*/
-struct yas537_t {
-struct bst_yas537_calib_data_t calib_yas537;/**< calib data */
-s8 measure_state;/**< update measure state */
-s8 hard_offset[3];/**< offset write array*/
-u16 last_after_rcoil[3];/**< rcoil write array*/
-s32 coef[3];/**< co efficient data */
-s8 overflow;/**< over flow condition check */
-u8 dev_id;/**< device id information */
-u8 average;/**<average selection for offset configuration*/
-const s8 *transform;/**< transform condition check */
-u16 last_raw[4];/**< raw data */
-struct yas_vector xyz; /*!< X, Y, Z measurement data of the sensor */
-};
-/*!
-* @brief FIFO used to store the FIFO header less data
-*/
-struct bmi160_fifo_data_header_less_t {
-
-struct bmi160_accel_t accel_fifo[BMI160_FIFO_FRAME_CNT];/**<
-Accel data of XYZ */
-struct bmi160_mag_t mag_fifo[BMI160_FIFO_FRAME_CNT];/**<
-Mag data of XYZ */
-struct bmi160_gyro_t gyro_fifo[BMI160_FIFO_FRAME_CNT];/**<
-Gyro data of XYZ */
-u8 accel_frame_count;/**< The total number of accel frame stored
-in the FIFO*/
-u8 gyro_frame_count;/**< The total number of gyro frame stored
-in the FIFO*/
-u8 mag_frame_count;/**< The total number of mag frame stored
-in the FIFO*/
-};
-/*!
-* @brief Struct used to store the FIFO header data
-*/
-struct bmi160_fifo_data_header_t {
-struct bmi160_accel_t accel_fifo[BMI160_FIFO_FRAME_CNT];/**<
-Accel data of XYZ */
-struct bmi160_mag_t mag_fifo[BMI160_FIFO_FRAME_CNT];/**<
-Mag data of XYZ */
-struct bmi160_gyro_t gyro_fifo[BMI160_FIFO_FRAME_CNT];/**<
-Gyro data of XYZ */
-u32 fifo_time;/**< Value of fifo time*/
-u8 skip_frame;/**< The value of skip frame information */
-u8 fifo_input_config_info; /**< FIFO input config info*/
-u8 accel_frame_count; /**< The total number of accel frame stored
-in the FIFO*/
-u8 gyro_frame_count; /**< The total number of gyro frame stored
-in the FIFO*/
-u8 mag_frame_count; /**< The total number of mag frame stored
-in the FIFO*/
-u8 fifo_header[BMI160_FIFO_FRAME_CNT]; /**< FIFO header info*/
-};
-/*!
-* @brief Struct used to store the FIFO mag data
-*/
-struct bmi160_mag_fifo_data_t {
-u8 mag_x_lsb;/**< The value of mag x LSB data*/
-u8 mag_x_msb;/**< The value of mag x MSB data*/
-u8 mag_y_lsb;/**< The value of mag y LSB data*/
-u8 mag_y_msb;/**< The value of mag y MSB data*/
-u8 mag_z_lsb;/**< The value of mag z LSB data*/
-u8 mag_z_msb;/**< The value of mag z MSB data*/
-u8 mag_r_y2_lsb;
-/**< The value of mag r for BMM150 Y2 for YAMAHA LSB data*/
-u8 mag_r_y2_msb;
-/**< The value of mag r for BMM150 Y2 for YAMAHA MSB data*/
-};
-
-/**************************************************************/
-/**\name USER DATA REGISTERS DEFINITION START */
-/**************************************************************/
-
-/**************************************************************/
-/**\name CHIP ID LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* Chip ID Description - Reg Addr --> (0x00), Bit --> 0...7 */
-#define BMI160_USER_CHIP_ID__POS (0)
-#define BMI160_USER_CHIP_ID__MSK (0xFF)
-#define BMI160_USER_CHIP_ID__LEN (8)
-#define BMI160_USER_CHIP_ID__REG (BMI160_USER_CHIP_ID_ADDR)
-/**************************************************************/
-/**\name ERROR STATUS LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* Error Description - Reg Addr --> (0x02), Bit --> 0 */
-#define BMI160_USER_ERR_STAT__POS (0)
-#define BMI160_USER_ERR_STAT__LEN (8)
-#define BMI160_USER_ERR_STAT__MSK (0xFF)
-#define BMI160_USER_ERR_STAT__REG (BMI160_USER_ERROR_ADDR)
-
-#define BMI160_USER_FATAL_ERR__POS (0)
-#define BMI160_USER_FATAL_ERR__LEN (1)
-#define BMI160_USER_FATAL_ERR__MSK (0x01)
-#define BMI160_USER_FATAL_ERR__REG (BMI160_USER_ERROR_ADDR)
-
-/* Error Description - Reg Addr --> (0x02), Bit --> 1...4 */
-#define BMI160_USER_ERR_CODE__POS (1)
-#define BMI160_USER_ERR_CODE__LEN (4)
-#define BMI160_USER_ERR_CODE__MSK (0x1E)
-#define BMI160_USER_ERR_CODE__REG (BMI160_USER_ERROR_ADDR)
-
-/* Error Description - Reg Addr --> (0x02), Bit --> 5 */
-#define BMI160_USER_I2C_FAIL_ERR__POS (5)
-#define BMI160_USER_I2C_FAIL_ERR__LEN (1)
-#define BMI160_USER_I2C_FAIL_ERR__MSK (0x20)
-#define BMI160_USER_I2C_FAIL_ERR__REG (BMI160_USER_ERROR_ADDR)
-
-/* Error Description - Reg Addr --> (0x02), Bit --> 6 */
-#define BMI160_USER_DROP_CMD_ERR__POS (6)
-#define BMI160_USER_DROP_CMD_ERR__LEN (1)
-#define BMI160_USER_DROP_CMD_ERR__MSK (0x40)
-#define BMI160_USER_DROP_CMD_ERR__REG (BMI160_USER_ERROR_ADDR)
-/**************************************************************/
-/**\name MAG DATA READY LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* Error Description - Reg Addr --> (0x02), Bit --> 7 */
-#define BMI160_USER_MAG_DADA_RDY_ERR__POS (7)
-#define BMI160_USER_MAG_DADA_RDY_ERR__LEN (1)
-#define BMI160_USER_MAG_DADA_RDY_ERR__MSK (0x80)
-#define BMI160_USER_MAG_DADA_RDY_ERR__REG (BMI160_USER_ERROR_ADDR)
-/**************************************************************/
-/**\name MAG POWER MODE LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* PMU_Status Description of MAG - Reg Addr --> (0x03), Bit --> 1..0 */
-#define BMI160_USER_MAG_POWER_MODE_STAT__POS (0)
-#define BMI160_USER_MAG_POWER_MODE_STAT__LEN (2)
-#define BMI160_USER_MAG_POWER_MODE_STAT__MSK (0x03)
-#define BMI160_USER_MAG_POWER_MODE_STAT__REG \
-(BMI160_USER_PMU_STAT_ADDR)
-/**************************************************************/
-/**\name GYRO POWER MODE LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* PMU_Status Description of GYRO - Reg Addr --> (0x03), Bit --> 3...2 */
-#define BMI160_USER_GYRO_POWER_MODE_STAT__POS (2)
-#define BMI160_USER_GYRO_POWER_MODE_STAT__LEN (2)
-#define BMI160_USER_GYRO_POWER_MODE_STAT__MSK (0x0C)
-#define BMI160_USER_GYRO_POWER_MODE_STAT__REG \
-(BMI160_USER_PMU_STAT_ADDR)
-/**************************************************************/
-/**\name ACCEL POWER MODE LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* PMU_Status Description of ACCEL - Reg Addr --> (0x03), Bit --> 5...4 */
-#define BMI160_USER_ACCEL_POWER_MODE_STAT__POS (4)
-#define BMI160_USER_ACCEL_POWER_MODE_STAT__LEN (2)
-#define BMI160_USER_ACCEL_POWER_MODE_STAT__MSK (0x30)
-#define BMI160_USER_ACCEL_POWER_MODE_STAT__REG \
-(BMI160_USER_PMU_STAT_ADDR)
-/**************************************************************/
-/**\name MAG DATA XYZ LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* Mag_X(LSB) Description - Reg Addr --> (0x04), Bit --> 0...7 */
-#define BMI160_USER_DATA_0_MAG_X_LSB__POS (0)
-#define BMI160_USER_DATA_0_MAG_X_LSB__LEN (8)
-#define BMI160_USER_DATA_0_MAG_X_LSB__MSK (0xFF)
-#define BMI160_USER_DATA_0_MAG_X_LSB__REG (BMI160_USER_DATA_0_ADDR)
-
-/* Mag_X(LSB) Description - Reg Addr --> (0x04), Bit --> 3...7 */
-#define BMI160_USER_DATA_MAG_X_LSB__POS (3)
-#define BMI160_USER_DATA_MAG_X_LSB__LEN (5)
-#define BMI160_USER_DATA_MAG_X_LSB__MSK (0xF8)
-#define BMI160_USER_DATA_MAG_X_LSB__REG (BMI160_USER_DATA_0_ADDR)
-
-/* Mag_X(MSB) Description - Reg Addr --> (0x05), Bit --> 0...7 */
-#define BMI160_USER_DATA_1_MAG_X_MSB__POS (0)
-#define BMI160_USER_DATA_1_MAG_X_MSB__LEN (8)
-#define BMI160_USER_DATA_1_MAG_X_MSB__MSK (0xFF)
-#define BMI160_USER_DATA_1_MAG_X_MSB__REG (BMI160_USER_DATA_1_ADDR)
-
-/* Mag_Y(LSB) Description - Reg Addr --> (0x06), Bit --> 0...7 */
-#define BMI160_USER_DATA_2_MAG_Y_LSB__POS (0)
-#define BMI160_USER_DATA_2_MAG_Y_LSB__LEN (8)
-#define BMI160_USER_DATA_2_MAG_Y_LSB__MSK (0xFF)
-#define BMI160_USER_DATA_2_MAG_Y_LSB__REG (BMI160_USER_DATA_2_ADDR)
-
-/* Mag_Y(LSB) Description - Reg Addr --> (0x06), Bit --> 3...7 */
-#define BMI160_USER_DATA_MAG_Y_LSB__POS (3)
-#define BMI160_USER_DATA_MAG_Y_LSB__LEN (5)
-#define BMI160_USER_DATA_MAG_Y_LSB__MSK (0xF8)
-#define BMI160_USER_DATA_MAG_Y_LSB__REG (BMI160_USER_DATA_2_ADDR)
-
-/* Mag_Y(MSB) Description - Reg Addr --> (0x07), Bit --> 0...7 */
-#define BMI160_USER_DATA_3_MAG_Y_MSB__POS (0)
-#define BMI160_USER_DATA_3_MAG_Y_MSB__LEN (8)
-#define BMI160_USER_DATA_3_MAG_Y_MSB__MSK (0xFF)
-#define BMI160_USER_DATA_3_MAG_Y_MSB__REG (BMI160_USER_DATA_3_ADDR)
-
-/* Mag_Z(LSB) Description - Reg Addr --> (0x08), Bit --> 0...7 */
-#define BMI160_USER_DATA_4_MAG_Z_LSB__POS (0)
-#define BMI160_USER_DATA_4_MAG_Z_LSB__LEN (8)
-#define BMI160_USER_DATA_4_MAG_Z_LSB__MSK (0xFF)
-#define BMI160_USER_DATA_4_MAG_Z_LSB__REG (BMI160_USER_DATA_4_ADDR)
-
-/* Mag_X(LSB) Description - Reg Addr --> (0x08), Bit --> 3...7 */
-#define BMI160_USER_DATA_MAG_Z_LSB__POS (1)
-#define BMI160_USER_DATA_MAG_Z_LSB__LEN (7)
-#define BMI160_USER_DATA_MAG_Z_LSB__MSK (0xFE)
-#define BMI160_USER_DATA_MAG_Z_LSB__REG (BMI160_USER_DATA_4_ADDR)
-
-/* Mag_Z(MSB) Description - Reg Addr --> (0x09), Bit --> 0...7 */
-#define BMI160_USER_DATA_5_MAG_Z_MSB__POS (0)
-#define BMI160_USER_DATA_5_MAG_Z_MSB__LEN (8)
-#define BMI160_USER_DATA_5_MAG_Z_MSB__MSK (0xFF)
-#define BMI160_USER_DATA_5_MAG_Z_MSB__REG (BMI160_USER_DATA_5_ADDR)
-
-/* RHALL(LSB) Description - Reg Addr --> (0x0A), Bit --> 0...7 */
-#define BMI160_USER_DATA_6_RHALL_LSB__POS (0)
-#define BMI160_USER_DATA_6_RHALL_LSB__LEN (8)
-#define BMI160_USER_DATA_6_RHALL_LSB__MSK (0xFF)
-#define BMI160_USER_DATA_6_RHALL_LSB__REG (BMI160_USER_DATA_6_ADDR)
-
-/* Mag_R(LSB) Description - Reg Addr --> (0x0A), Bit --> 3...7 */
-#define BMI160_USER_DATA_MAG_R_LSB__POS (2)
-#define BMI160_USER_DATA_MAG_R_LSB__LEN (6)
-#define BMI160_USER_DATA_MAG_R_LSB__MSK (0xFC)
-#define BMI160_USER_DATA_MAG_R_LSB__REG (BMI160_USER_DATA_6_ADDR)
-
-/* RHALL(MSB) Description - Reg Addr --> (0x0B), Bit --> 0...7 */
-#define BMI160_USER_DATA_7_RHALL_MSB__POS (0)
-#define BMI160_USER_DATA_7_RHALL_MSB__LEN (8)
-#define BMI160_USER_DATA_7_RHALL_MSB__MSK (0xFF)
-#define BMI160_USER_DATA_7_RHALL_MSB__REG (BMI160_USER_DATA_7_ADDR)
-/**************************************************************/
-/**\name GYRO DATA XYZ LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* GYR_X (LSB) Description - Reg Addr --> (0x0C), Bit --> 0...7 */
-#define BMI160_USER_DATA_8_GYRO_X_LSB__POS (0)
-#define BMI160_USER_DATA_8_GYRO_X_LSB__LEN (8)
-#define BMI160_USER_DATA_8_GYRO_X_LSB__MSK (0xFF)
-#define BMI160_USER_DATA_8_GYRO_X_LSB__REG (BMI160_USER_DATA_8_ADDR)
-
-/* GYR_X (MSB) Description - Reg Addr --> (0x0D), Bit --> 0...7 */
-#define BMI160_USER_DATA_9_GYRO_X_MSB__POS (0)
-#define BMI160_USER_DATA_9_GYRO_X_MSB__LEN (8)
-#define BMI160_USER_DATA_9_GYRO_X_MSB__MSK (0xFF)
-#define BMI160_USER_DATA_9_GYRO_X_MSB__REG (BMI160_USER_DATA_9_ADDR)
-
-/* GYR_Y (LSB) Description - Reg Addr --> 0x0E, Bit --> 0...7 */
-#define BMI160_USER_DATA_10_GYRO_Y_LSB__POS (0)
-#define BMI160_USER_DATA_10_GYRO_Y_LSB__LEN (8)
-#define BMI160_USER_DATA_10_GYRO_Y_LSB__MSK (0xFF)
-#define BMI160_USER_DATA_10_GYRO_Y_LSB__REG (BMI160_USER_DATA_10_ADDR)
-
-/* GYR_Y (MSB) Description - Reg Addr --> (0x0F), Bit --> 0...7 */
-#define BMI160_USER_DATA_11_GYRO_Y_MSB__POS (0)
-#define BMI160_USER_DATA_11_GYRO_Y_MSB__LEN (8)
-#define BMI160_USER_DATA_11_GYRO_Y_MSB__MSK (0xFF)
-#define BMI160_USER_DATA_11_GYRO_Y_MSB__REG (BMI160_USER_DATA_11_ADDR)
-
-/* GYR_Z (LSB) Description - Reg Addr --> (0x10), Bit --> 0...7 */
-#define BMI160_USER_DATA_12_GYRO_Z_LSB__POS (0)
-#define BMI160_USER_DATA_12_GYRO_Z_LSB__LEN (8)
-#define BMI160_USER_DATA_12_GYRO_Z_LSB__MSK (0xFF)
-#define BMI160_USER_DATA_12_GYRO_Z_LSB__REG (BMI160_USER_DATA_12_ADDR)
-
-/* GYR_Z (MSB) Description - Reg Addr --> (0x11), Bit --> 0...7 */
-#define BMI160_USER_DATA_13_GYRO_Z_MSB__POS (0)
-#define BMI160_USER_DATA_13_GYRO_Z_MSB__LEN (8)
-#define BMI160_USER_DATA_13_GYRO_Z_MSB__MSK (0xFF)
-#define BMI160_USER_DATA_13_GYRO_Z_MSB__REG (BMI160_USER_DATA_13_ADDR)
-/**************************************************************/
-/**\name ACCEL DATA XYZ LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* ACC_X (LSB) Description - Reg Addr --> (0x12), Bit --> 0...7 */
-#define BMI160_USER_DATA_14_ACCEL_X_LSB__POS (0)
-#define BMI160_USER_DATA_14_ACCEL_X_LSB__LEN (8)
-#define BMI160_USER_DATA_14_ACCEL_X_LSB__MSK (0xFF)
-#define BMI160_USER_DATA_14_ACCEL_X_LSB__REG (BMI160_USER_DATA_14_ADDR)
-
-/* ACC_X (MSB) Description - Reg Addr --> 0x13, Bit --> 0...7 */
-#define BMI160_USER_DATA_15_ACCEL_X_MSB__POS (0)
-#define BMI160_USER_DATA_15_ACCEL_X_MSB__LEN (8)
-#define BMI160_USER_DATA_15_ACCEL_X_MSB__MSK (0xFF)
-#define BMI160_USER_DATA_15_ACCEL_X_MSB__REG (BMI160_USER_DATA_15_ADDR)
-
-/* ACC_Y (LSB) Description - Reg Addr --> (0x14), Bit --> 0...7 */
-#define BMI160_USER_DATA_16_ACCEL_Y_LSB__POS (0)
-#define BMI160_USER_DATA_16_ACCEL_Y_LSB__LEN (8)
-#define BMI160_USER_DATA_16_ACCEL_Y_LSB__MSK (0xFF)
-#define BMI160_USER_DATA_16_ACCEL_Y_LSB__REG (BMI160_USER_DATA_16_ADDR)
-
-/* ACC_Y (MSB) Description - Reg Addr --> (0x15), Bit --> 0...7 */
-#define BMI160_USER_DATA_17_ACCEL_Y_MSB__POS (0)
-#define BMI160_USER_DATA_17_ACCEL_Y_MSB__LEN (8)
-#define BMI160_USER_DATA_17_ACCEL_Y_MSB__MSK (0xFF)
-#define BMI160_USER_DATA_17_ACCEL_Y_MSB__REG (BMI160_USER_DATA_17_ADDR)
-
-/* ACC_Z (LSB) Description - Reg Addr --> 0x16, Bit --> 0...7 */
-#define BMI160_USER_DATA_18_ACCEL_Z_LSB__POS (0)
-#define BMI160_USER_DATA_18_ACCEL_Z_LSB__LEN (8)
-#define BMI160_USER_DATA_18_ACCEL_Z_LSB__MSK (0xFF)
-#define BMI160_USER_DATA_18_ACCEL_Z_LSB__REG (BMI160_USER_DATA_18_ADDR)
-
-/* ACC_Z (MSB) Description - Reg Addr --> (0x17), Bit --> 0...7 */
-#define BMI160_USER_DATA_19_ACCEL_Z_MSB__POS (0)
-#define BMI160_USER_DATA_19_ACCEL_Z_MSB__LEN (8)
-#define BMI160_USER_DATA_19_ACCEL_Z_MSB__MSK (0xFF)
-#define BMI160_USER_DATA_19_ACCEL_Z_MSB__REG (BMI160_USER_DATA_19_ADDR)
-/**************************************************************/
-/**\name SENSOR TIME LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* SENSORTIME_0 (LSB) Description - Reg Addr --> (0x18), Bit --> 0...7 */
-#define BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__POS (0)
-#define BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__LEN (8)
-#define BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__MSK (0xFF)
-#define BMI160_USER_SENSORTIME_0_SENSOR_TIME_LSB__REG \
- (BMI160_USER_SENSORTIME_0_ADDR)
-
-/* SENSORTIME_1 (MSB) Description - Reg Addr --> (0x19), Bit --> 0...7 */
-#define BMI160_USER_SENSORTIME_1_SENSOR_TIME_MSB__POS (0)
-#define BMI160_USER_SENSORTIME_1_SENSOR_TIME_MSB__LEN (8)
-#define BMI160_USER_SENSORTIME_1_SENSOR_TIME_MSB__MSK (0xFF)
-#define BMI160_USER_SENSORTIME_1_SENSOR_TIME_MSB__REG \
- (BMI160_USER_SENSORTIME_1_ADDR)
-
-/* SENSORTIME_2 (MSB) Description - Reg Addr --> (0x1A), Bit --> 0...7 */
-#define BMI160_USER_SENSORTIME_2_SENSOR_TIME_MSB__POS (0)
-#define BMI160_USER_SENSORTIME_2_SENSOR_TIME_MSB__LEN (8)
-#define BMI160_USER_SENSORTIME_2_SENSOR_TIME_MSB__MSK (0xFF)
-#define BMI160_USER_SENSORTIME_2_SENSOR_TIME_MSB__REG \
- (BMI160_USER_SENSORTIME_2_ADDR)
-/**************************************************************/
-/**\name GYRO SELF TEST LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* Status Description - Reg Addr --> 0x1B, Bit --> 1 */
-#define BMI160_USER_STAT_GYRO_SELFTEST_OK__POS (1)
-#define BMI160_USER_STAT_GYRO_SELFTEST_OK__LEN (1)
-#define BMI160_USER_STAT_GYRO_SELFTEST_OK__MSK (0x02)
-#define BMI160_USER_STAT_GYRO_SELFTEST_OK__REG \
- (BMI160_USER_STAT_ADDR)
-/**************************************************************/
-/**\name MAG MANUAL OPERATION LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* Status Description - Reg Addr --> 0x1B, Bit --> 2 */
-#define BMI160_USER_STAT_MAG_MANUAL_OPERATION__POS (2)
-#define BMI160_USER_STAT_MAG_MANUAL_OPERATION__LEN (1)
-#define BMI160_USER_STAT_MAG_MANUAL_OPERATION__MSK (0x04)
-#define BMI160_USER_STAT_MAG_MANUAL_OPERATION__REG \
- (BMI160_USER_STAT_ADDR)
-/**************************************************************/
-/**\name FOC STATUS LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* Status Description - Reg Addr --> 0x1B, Bit --> 3 */
-#define BMI160_USER_STAT_FOC_RDY__POS (3)
-#define BMI160_USER_STAT_FOC_RDY__LEN (1)
-#define BMI160_USER_STAT_FOC_RDY__MSK (0x08)
-#define BMI160_USER_STAT_FOC_RDY__REG (BMI160_USER_STAT_ADDR)
-/**************************************************************/
-/**\name NVM READY LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* Status Description - Reg Addr --> 0x1B, Bit --> 4 */
-#define BMI160_USER_STAT_NVM_RDY__POS (4)
-#define BMI160_USER_STAT_NVM_RDY__LEN (1)
-#define BMI160_USER_STAT_NVM_RDY__MSK (0x10)
-#define BMI160_USER_STAT_NVM_RDY__REG (BMI160_USER_STAT_ADDR)
-/**************************************************************/
-/**\name DATA READY LENGTH, POSITION AND MASK FOR ACCEL, MAG AND GYRO*/
-/**************************************************************/
-/* Status Description - Reg Addr --> 0x1B, Bit --> 5 */
-#define BMI160_USER_STAT_DATA_RDY_MAG__POS (5)
-#define BMI160_USER_STAT_DATA_RDY_MAG__LEN (1)
-#define BMI160_USER_STAT_DATA_RDY_MAG__MSK (0x20)
-#define BMI160_USER_STAT_DATA_RDY_MAG__REG (BMI160_USER_STAT_ADDR)
-
-/* Status Description - Reg Addr --> 0x1B, Bit --> 6 */
-#define BMI160_USER_STAT_DATA_RDY_GYRO__POS (6)
-#define BMI160_USER_STAT_DATA_RDY_GYRO__LEN (1)
-#define BMI160_USER_STAT_DATA_RDY_GYRO__MSK (0x40)
-#define BMI160_USER_STAT_DATA_RDY_GYRO__REG (BMI160_USER_STAT_ADDR)
-
-/* Status Description - Reg Addr --> 0x1B, Bit --> 7 */
-#define BMI160_USER_STAT_DATA_RDY_ACCEL__POS (7)
-#define BMI160_USER_STAT_DATA_RDY_ACCEL__LEN (1)
-#define BMI160_USER_STAT_DATA_RDY_ACCEL__MSK (0x80)
-#define BMI160_USER_STAT_DATA_RDY_ACCEL__REG (BMI160_USER_STAT_ADDR)
-/**************************************************************/
-/**\name INTERRUPT STATUS LENGTH, POSITION AND MASK */
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 0 */
-#define BMI160_USER_INTR_STAT_0_STEP_INTR__POS (0)
-#define BMI160_USER_INTR_STAT_0_STEP_INTR__LEN (1)
-#define BMI160_USER_INTR_STAT_0_STEP_INTR__MSK (0x01)
-#define BMI160_USER_INTR_STAT_0_STEP_INTR__REG \
- (BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name SIGNIFICANT INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 1 */
-#define BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__POS (1)
-#define BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__LEN (1)
-#define BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__MSK (0x02)
-#define BMI160_USER_INTR_STAT_0_SIGNIFICANT_INTR__REG \
- (BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name ANY_MOTION INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 2 */
-#define BMI160_USER_INTR_STAT_0_ANY_MOTION__POS (2)
-#define BMI160_USER_INTR_STAT_0_ANY_MOTION__LEN (1)
-#define BMI160_USER_INTR_STAT_0_ANY_MOTION__MSK (0x04)
-#define BMI160_USER_INTR_STAT_0_ANY_MOTION__REG \
- (BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name PMU TRIGGER INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 3 */
-#define BMI160_USER_INTR_STAT_0_PMU_TRIGGER__POS 3
-#define BMI160_USER_INTR_STAT_0_PMU_TRIGGER__LEN (1)
-#define BMI160_USER_INTR_STAT_0_PMU_TRIGGER__MSK (0x08)
-#define BMI160_USER_INTR_STAT_0_PMU_TRIGGER__REG \
- (BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name DOUBLE TAP INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 4 */
-#define BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__POS 4
-#define BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__LEN (1)
-#define BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__MSK (0x10)
-#define BMI160_USER_INTR_STAT_0_DOUBLE_TAP_INTR__REG \
- (BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name SINGLE TAP INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 5 */
-#define BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__POS 5
-#define BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__LEN (1)
-#define BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__MSK (0x20)
-#define BMI160_USER_INTR_STAT_0_SINGLE_TAP_INTR__REG \
- (BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name ORIENT INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 6 */
-#define BMI160_USER_INTR_STAT_0_ORIENT__POS (6)
-#define BMI160_USER_INTR_STAT_0_ORIENT__LEN (1)
-#define BMI160_USER_INTR_STAT_0_ORIENT__MSK (0x40)
-#define BMI160_USER_INTR_STAT_0_ORIENT__REG \
- (BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name FLAT INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_0 Description - Reg Addr --> 0x1C, Bit --> 7 */
-#define BMI160_USER_INTR_STAT_0_FLAT__POS (7)
-#define BMI160_USER_INTR_STAT_0_FLAT__LEN (1)
-#define BMI160_USER_INTR_STAT_0_FLAT__MSK (0x80)
-#define BMI160_USER_INTR_STAT_0_FLAT__REG \
- (BMI160_USER_INTR_STAT_0_ADDR)
-/**************************************************************/
-/**\name HIGH_G INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 2 */
-#define BMI160_USER_INTR_STAT_1_HIGH_G_INTR__POS (2)
-#define BMI160_USER_INTR_STAT_1_HIGH_G_INTR__LEN (1)
-#define BMI160_USER_INTR_STAT_1_HIGH_G_INTR__MSK (0x04)
-#define BMI160_USER_INTR_STAT_1_HIGH_G_INTR__REG \
- (BMI160_USER_INTR_STAT_1_ADDR)
-/**************************************************************/
-/**\name LOW_G INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 3 */
-#define BMI160_USER_INTR_STAT_1_LOW_G_INTR__POS (3)
-#define BMI160_USER_INTR_STAT_1_LOW_G_INTR__LEN (1)
-#define BMI160_USER_INTR_STAT_1_LOW_G_INTR__MSK (0x08)
-#define BMI160_USER_INTR_STAT_1_LOW_G_INTR__REG \
- (BMI160_USER_INTR_STAT_1_ADDR)
-/**************************************************************/
-/**\name DATA READY INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 4 */
-#define BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__POS (4)
-#define BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__LEN (1)
-#define BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__MSK (0x10)
-#define BMI160_USER_INTR_STAT_1_DATA_RDY_INTR__REG \
- (BMI160_USER_INTR_STAT_1_ADDR)
-/**************************************************************/
-/**\name FIFO FULL INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 5 */
-#define BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__POS (5)
-#define BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__LEN (1)
-#define BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__MSK (0x20)
-#define BMI160_USER_INTR_STAT_1_FIFO_FULL_INTR__REG \
- (BMI160_USER_INTR_STAT_1_ADDR)
-/**************************************************************/
-/**\name FIFO WATERMARK INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 6 */
-#define BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__POS (6)
-#define BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__LEN (1)
-#define BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__MSK (0x40)
-#define BMI160_USER_INTR_STAT_1_FIFO_WM_INTR__REG \
- (BMI160_USER_INTR_STAT_1_ADDR)
-/**************************************************************/
-/**\name NO MOTION INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_1 Description - Reg Addr --> 0x1D, Bit --> 7 */
-#define BMI160_USER_INTR_STAT_1_NOMOTION_INTR__POS (7)
-#define BMI160_USER_INTR_STAT_1_NOMOTION_INTR__LEN (1)
-#define BMI160_USER_INTR_STAT_1_NOMOTION_INTR__MSK (0x80)
-#define BMI160_USER_INTR_STAT_1_NOMOTION_INTR__REG \
- (BMI160_USER_INTR_STAT_1_ADDR)
-/**************************************************************/
-/**\name ANY MOTION-XYZ AXIS INTERRUPT STATUS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 0 */
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__POS (0)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__LEN (1)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__MSK (0x01)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_X__REG \
- (BMI160_USER_INTR_STAT_2_ADDR)
-
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 1 */
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__POS (1)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__LEN (1)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__MSK (0x02)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Y__REG \
- (BMI160_USER_INTR_STAT_2_ADDR)
-
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 2 */
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__POS (2)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__LEN (1)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__MSK (0x04)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_FIRST_Z__REG \
- (BMI160_USER_INTR_STAT_2_ADDR)
-/**************************************************************/
-/**\name ANY MOTION SIGN LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 3 */
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__POS (3)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__LEN (1)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__MSK (0x08)
-#define BMI160_USER_INTR_STAT_2_ANY_MOTION_SIGN__REG \
- (BMI160_USER_INTR_STAT_2_ADDR)
-/**************************************************************/
-/**\name TAP_XYZ AND SIGN LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 4 */
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_X__POS (4)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_X__LEN (1)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_X__MSK (0x10)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_X__REG \
- (BMI160_USER_INTR_STAT_2_ADDR)
-
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 5 */
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__POS (5)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__LEN (1)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__MSK (0x20)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Y__REG \
- (BMI160_USER_INTR_STAT_2_ADDR)
-
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 6 */
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__POS (6)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__LEN (1)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__MSK (0x40)
-#define BMI160_USER_INTR_STAT_2_TAP_FIRST_Z__REG \
- (BMI160_USER_INTR_STAT_2_ADDR)
-
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 7 */
-#define BMI160_USER_INTR_STAT_2_TAP_SIGN__POS (7)
-#define BMI160_USER_INTR_STAT_2_TAP_SIGN__LEN (1)
-#define BMI160_USER_INTR_STAT_2_TAP_SIGN__MSK (0x80)
-#define BMI160_USER_INTR_STAT_2_TAP_SIGN__REG \
- (BMI160_USER_INTR_STAT_2_ADDR)
-/**************************************************************/
-/**\name INTERRUPT SATAUS FOR WHOLE 0x1E LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_2 Description - Reg Addr --> 0x1E, Bit --> 0...7 */
-#define BMI160_USER_INTR_STAT_2__POS (0)
-#define BMI160_USER_INTR_STAT_2__LEN (8)
-#define BMI160_USER_INTR_STAT_2__MSK (0xFF)
-#define BMI160_USER_INTR_STAT_2__REG \
- (BMI160_USER_INTR_STAT_2_ADDR)
-/**************************************************************/
-/**\name HIGH_G-XYZ AND SIGN LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 0 */
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__POS (0)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__LEN (1)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__MSK (0x01)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_X__REG \
- (BMI160_USER_INTR_STAT_3_ADDR)
-
-/* Int_Status_3 Description - Reg Addr --> 0x1E, Bit --> 1 */
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__POS (1)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__LEN (1)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__MSK (0x02)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Y__REG \
- (BMI160_USER_INTR_STAT_3_ADDR)
-
-/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 2 */
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__POS (2)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__LEN (1)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__MSK (0x04)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_FIRST_Z__REG \
- (BMI160_USER_INTR_STAT_3_ADDR)
-
-/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 3 */
-#define BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__POS (3)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__LEN (1)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__MSK (0x08)
-#define BMI160_USER_INTR_STAT_3_HIGH_G_SIGN__REG \
- (BMI160_USER_INTR_STAT_3_ADDR)
-/**************************************************************/
-/**\name ORIENT XY and Z AXIS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 4...5 */
-#define BMI160_USER_INTR_STAT_3_ORIENT_XY__POS (4)
-#define BMI160_USER_INTR_STAT_3_ORIENT_XY__LEN (2)
-#define BMI160_USER_INTR_STAT_3_ORIENT_XY__MSK (0x30)
-#define BMI160_USER_INTR_STAT_3_ORIENT_XY__REG \
- (BMI160_USER_INTR_STAT_3_ADDR)
-
-/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 6 */
-#define BMI160_USER_INTR_STAT_3_ORIENT_Z__POS (6)
-#define BMI160_USER_INTR_STAT_3_ORIENT_Z__LEN (1)
-#define BMI160_USER_INTR_STAT_3_ORIENT_Z__MSK (0x40)
-#define BMI160_USER_INTR_STAT_3_ORIENT_Z__REG \
- (BMI160_USER_INTR_STAT_3_ADDR)
-/**************************************************************/
-/**\name FLAT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 7 */
-#define BMI160_USER_INTR_STAT_3_FLAT__POS (7)
-#define BMI160_USER_INTR_STAT_3_FLAT__LEN (1)
-#define BMI160_USER_INTR_STAT_3_FLAT__MSK (0x80)
-#define BMI160_USER_INTR_STAT_3_FLAT__REG \
- (BMI160_USER_INTR_STAT_3_ADDR)
-/**************************************************************/
-/**\name (0x1F) LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Status_3 Description - Reg Addr --> (0x1F), Bit --> 0...7 */
-#define BMI160_USER_INTR_STAT_3__POS (0)
-#define BMI160_USER_INTR_STAT_3__LEN (8)
-#define BMI160_USER_INTR_STAT_3__MSK (0xFF)
-#define BMI160_USER_INTR_STAT_3__REG \
- (BMI160_USER_INTR_STAT_3_ADDR)
-/**************************************************************/
-/**\name TEMPERATURE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Temperature Description - LSB Reg Addr --> (0x20), Bit --> 0...7 */
-#define BMI160_USER_TEMP_LSB_VALUE__POS (0)
-#define BMI160_USER_TEMP_LSB_VALUE__LEN (8)
-#define BMI160_USER_TEMP_LSB_VALUE__MSK (0xFF)
-#define BMI160_USER_TEMP_LSB_VALUE__REG \
- (BMI160_USER_TEMPERATURE_0_ADDR)
-
-/* Temperature Description - LSB Reg Addr --> 0x21, Bit --> 0...7 */
-#define BMI160_USER_TEMP_MSB_VALUE__POS (0)
-#define BMI160_USER_TEMP_MSB_VALUE__LEN (8)
-#define BMI160_USER_TEMP_MSB_VALUE__MSK (0xFF)
-#define BMI160_USER_TEMP_MSB_VALUE__REG \
- (BMI160_USER_TEMPERATURE_1_ADDR)
-/**************************************************************/
-/**\name FIFO BYTE COUNTER LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Length0 Description - Reg Addr --> 0x22, Bit --> 0...7 */
-#define BMI160_USER_FIFO_BYTE_COUNTER_LSB__POS (0)
-#define BMI160_USER_FIFO_BYTE_COUNTER_LSB__LEN (8)
-#define BMI160_USER_FIFO_BYTE_COUNTER_LSB__MSK (0xFF)
-#define BMI160_USER_FIFO_BYTE_COUNTER_LSB__REG \
- (BMI160_USER_FIFO_LENGTH_0_ADDR)
-
-/*Fifo_Length1 Description - Reg Addr --> 0x23, Bit --> 0...2 */
-#define BMI160_USER_FIFO_BYTE_COUNTER_MSB__POS (0)
-#define BMI160_USER_FIFO_BYTE_COUNTER_MSB__LEN 3
-#define BMI160_USER_FIFO_BYTE_COUNTER_MSB__MSK (0x07)
-#define BMI160_USER_FIFO_BYTE_COUNTER_MSB__REG \
- (BMI160_USER_FIFO_LENGTH_1_ADDR)
-
-/**************************************************************/
-/**\name FIFO DATA LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Data Description - Reg Addr --> 0x24, Bit --> 0...7 */
-#define BMI160_USER_FIFO_DATA__POS (0)
-#define BMI160_USER_FIFO_DATA__LEN (8)
-#define BMI160_USER_FIFO_DATA__MSK (0xFF)
-#define BMI160_USER_FIFO_DATA__REG (BMI160_USER_FIFO_DATA_ADDR)
-
-/**************************************************************/
-/**\name ACCEL CONFIGURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Acc_Conf Description - Reg Addr --> (0x40), Bit --> 0...3 */
-#define BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__POS (0)
-#define BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__LEN (4)
-#define BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__MSK (0x0F)
-#define BMI160_USER_ACCEL_CONFIG_OUTPUT_DATA_RATE__REG \
-(BMI160_USER_ACCEL_CONFIG_ADDR)
-
-/* Acc_Conf Description - Reg Addr --> (0x40), Bit --> 4...6 */
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_BW__POS (4)
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_BW__LEN (3)
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_BW__MSK (0x70)
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_BW__REG (BMI160_USER_ACCEL_CONFIG_ADDR)
-
-/* Acc_Conf Description - Reg Addr --> (0x40), Bit --> 7 */
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__POS (7)
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__LEN (1)
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__MSK (0x80)
-#define BMI160_USER_ACCEL_CONFIG_ACCEL_UNDER_SAMPLING__REG \
-(BMI160_USER_ACCEL_CONFIG_ADDR)
-
-/* Acc_Range Description - Reg Addr --> 0x41, Bit --> 0...3 */
-#define BMI160_USER_ACCEL_RANGE__POS (0)
-#define BMI160_USER_ACCEL_RANGE__LEN (4)
-#define BMI160_USER_ACCEL_RANGE__MSK (0x0F)
-#define BMI160_USER_ACCEL_RANGE__REG \
-(BMI160_USER_ACCEL_RANGE_ADDR)
-/**************************************************************/
-/**\name GYRO CONFIGURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Gyro_Conf Description - Reg Addr --> (0x42), Bit --> 0...3 */
-#define BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__POS (0)
-#define BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__LEN (4)
-#define BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__MSK (0x0F)
-#define BMI160_USER_GYRO_CONFIG_OUTPUT_DATA_RATE__REG \
-(BMI160_USER_GYRO_CONFIG_ADDR)
-
-/* Gyro_Conf Description - Reg Addr --> (0x42), Bit --> 4...5 */
-#define BMI160_USER_GYRO_CONFIG_BW__POS (4)
-#define BMI160_USER_GYRO_CONFIG_BW__LEN (2)
-#define BMI160_USER_GYRO_CONFIG_BW__MSK (0x30)
-#define BMI160_USER_GYRO_CONFIG_BW__REG \
-(BMI160_USER_GYRO_CONFIG_ADDR)
-
-/* Gyr_Range Description - Reg Addr --> 0x43, Bit --> 0...2 */
-#define BMI160_USER_GYRO_RANGE__POS (0)
-#define BMI160_USER_GYRO_RANGE__LEN (3)
-#define BMI160_USER_GYRO_RANGE__MSK (0x07)
-#define BMI160_USER_GYRO_RANGE__REG (BMI160_USER_GYRO_RANGE_ADDR)
-/**************************************************************/
-/**\name MAG CONFIGURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Mag_Conf Description - Reg Addr --> (0x44), Bit --> 0...3 */
-#define BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__POS (0)
-#define BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__LEN (4)
-#define BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__MSK (0x0F)
-#define BMI160_USER_MAG_CONFIG_OUTPUT_DATA_RATE__REG \
-(BMI160_USER_MAG_CONFIG_ADDR)
-/**************************************************************/
-/**\name FIFO DOWNS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Downs Description - Reg Addr --> 0x45, Bit --> 0...2 */
-#define BMI160_USER_FIFO_DOWN_GYRO__POS (0)
-#define BMI160_USER_FIFO_DOWN_GYRO__LEN (3)
-#define BMI160_USER_FIFO_DOWN_GYRO__MSK (0x07)
-#define BMI160_USER_FIFO_DOWN_GYRO__REG (BMI160_USER_FIFO_DOWN_ADDR)
-/**************************************************************/
-/**\name FIFO FILTER FOR ACCEL AND GYRO LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_filt Description - Reg Addr --> 0x45, Bit --> 3 */
-#define BMI160_USER_FIFO_FILTER_GYRO__POS (3)
-#define BMI160_USER_FIFO_FILTER_GYRO__LEN (1)
-#define BMI160_USER_FIFO_FILTER_GYRO__MSK (0x08)
-#define BMI160_USER_FIFO_FILTER_GYRO__REG (BMI160_USER_FIFO_DOWN_ADDR)
-
-/* Fifo_Downs Description - Reg Addr --> 0x45, Bit --> 4...6 */
-#define BMI160_USER_FIFO_DOWN_ACCEL__POS (4)
-#define BMI160_USER_FIFO_DOWN_ACCEL__LEN (3)
-#define BMI160_USER_FIFO_DOWN_ACCEL__MSK (0x70)
-#define BMI160_USER_FIFO_DOWN_ACCEL__REG (BMI160_USER_FIFO_DOWN_ADDR)
-
-/* Fifo_FILT Description - Reg Addr --> 0x45, Bit --> 7 */
-#define BMI160_USER_FIFO_FILTER_ACCEL__POS (7)
-#define BMI160_USER_FIFO_FILTER_ACCEL__LEN (1)
-#define BMI160_USER_FIFO_FILTER_ACCEL__MSK (0x80)
-#define BMI160_USER_FIFO_FILTER_ACCEL__REG (BMI160_USER_FIFO_DOWN_ADDR)
-/**************************************************************/
-/**\name FIFO WATER MARK LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Config_0 Description - Reg Addr --> 0x46, Bit --> 0...7 */
-#define BMI160_USER_FIFO_WM__POS (0)
-#define BMI160_USER_FIFO_WM__LEN (8)
-#define BMI160_USER_FIFO_WM__MSK (0xFF)
-#define BMI160_USER_FIFO_WM__REG (BMI160_USER_FIFO_CONFIG_0_ADDR)
-/**************************************************************/
-/**\name FIFO TIME LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 1 */
-#define BMI160_USER_FIFO_TIME_ENABLE__POS (1)
-#define BMI160_USER_FIFO_TIME_ENABLE__LEN (1)
-#define BMI160_USER_FIFO_TIME_ENABLE__MSK (0x02)
-#define BMI160_USER_FIFO_TIME_ENABLE__REG (BMI160_USER_FIFO_CONFIG_1_ADDR)
-/**************************************************************/
-/**\name FIFO TAG INTERRUPT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 2 */
-#define BMI160_USER_FIFO_TAG_INTR2_ENABLE__POS (2)
-#define BMI160_USER_FIFO_TAG_INTR2_ENABLE__LEN (1)
-#define BMI160_USER_FIFO_TAG_INTR2_ENABLE__MSK (0x04)
-#define BMI160_USER_FIFO_TAG_INTR2_ENABLE__REG (BMI160_USER_FIFO_CONFIG_1_ADDR)
-
-/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 3 */
-#define BMI160_USER_FIFO_TAG_INTR1_ENABLE__POS (3)
-#define BMI160_USER_FIFO_TAG_INTR1_ENABLE__LEN (1)
-#define BMI160_USER_FIFO_TAG_INTR1_ENABLE__MSK (0x08)
-#define BMI160_USER_FIFO_TAG_INTR1_ENABLE__REG (BMI160_USER_FIFO_CONFIG_1_ADDR)
-/**************************************************************/
-/**\name FIFO HEADER LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 4 */
-#define BMI160_USER_FIFO_HEADER_ENABLE__POS (4)
-#define BMI160_USER_FIFO_HEADER_ENABLE__LEN (1)
-#define BMI160_USER_FIFO_HEADER_ENABLE__MSK (0x10)
-#define BMI160_USER_FIFO_HEADER_ENABLE__REG \
-(BMI160_USER_FIFO_CONFIG_1_ADDR)
-/**************************************************************/
-/**\name FIFO MAG ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 5 */
-#define BMI160_USER_FIFO_MAG_ENABLE__POS (5)
-#define BMI160_USER_FIFO_MAG_ENABLE__LEN (1)
-#define BMI160_USER_FIFO_MAG_ENABLE__MSK (0x20)
-#define BMI160_USER_FIFO_MAG_ENABLE__REG \
-(BMI160_USER_FIFO_CONFIG_1_ADDR)
-/**************************************************************/
-/**\name FIFO ACCEL ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 6 */
-#define BMI160_USER_FIFO_ACCEL_ENABLE__POS (6)
-#define BMI160_USER_FIFO_ACCEL_ENABLE__LEN (1)
-#define BMI160_USER_FIFO_ACCEL_ENABLE__MSK (0x40)
-#define BMI160_USER_FIFO_ACCEL_ENABLE__REG \
-(BMI160_USER_FIFO_CONFIG_1_ADDR)
-/**************************************************************/
-/**\name FIFO GYRO ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Fifo_Config_1 Description - Reg Addr --> 0x47, Bit --> 7 */
-#define BMI160_USER_FIFO_GYRO_ENABLE__POS (7)
-#define BMI160_USER_FIFO_GYRO_ENABLE__LEN (1)
-#define BMI160_USER_FIFO_GYRO_ENABLE__MSK (0x80)
-#define BMI160_USER_FIFO_GYRO_ENABLE__REG \
-(BMI160_USER_FIFO_CONFIG_1_ADDR)
-
-/**************************************************************/
-/**\name MAG I2C ADDRESS SELECTION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-
-/* Mag_IF_0 Description - Reg Addr --> 0x4b, Bit --> 1...7 */
-#define BMI160_USER_I2C_DEVICE_ADDR__POS (1)
-#define BMI160_USER_I2C_DEVICE_ADDR__LEN (7)
-#define BMI160_USER_I2C_DEVICE_ADDR__MSK (0xFE)
-#define BMI160_USER_I2C_DEVICE_ADDR__REG (BMI160_USER_MAG_IF_0_ADDR)
-/**************************************************************/
-/**\name MAG CONFIGURATION FOR SECONDARY
- INTERFACE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Mag_IF_1 Description - Reg Addr --> 0x4c, Bit --> 0...1 */
-#define BMI160_USER_MAG_BURST__POS (0)
-#define BMI160_USER_MAG_BURST__LEN (2)
-#define BMI160_USER_MAG_BURST__MSK (0x03)
-#define BMI160_USER_MAG_BURST__REG (BMI160_USER_MAG_IF_1_ADDR)
-
-/* Mag_IF_1 Description - Reg Addr --> 0x4c, Bit --> 2...5 */
-#define BMI160_USER_MAG_OFFSET__POS (2)
-#define BMI160_USER_MAG_OFFSET__LEN (4)
-#define BMI160_USER_MAG_OFFSET__MSK (0x3C)
-#define BMI160_USER_MAG_OFFSET__REG (BMI160_USER_MAG_IF_1_ADDR)
-
-/* Mag_IF_1 Description - Reg Addr --> 0x4c, Bit --> 7 */
-#define BMI160_USER_MAG_MANUAL_ENABLE__POS (7)
-#define BMI160_USER_MAG_MANUAL_ENABLE__LEN (1)
-#define BMI160_USER_MAG_MANUAL_ENABLE__MSK (0x80)
-#define BMI160_USER_MAG_MANUAL_ENABLE__REG \
-(BMI160_USER_MAG_IF_1_ADDR)
-
-/* Mag_IF_2 Description - Reg Addr --> 0x4d, Bit -->0... 7 */
-#define BMI160_USER_READ_ADDR__POS (0)
-#define BMI160_USER_READ_ADDR__LEN (8)
-#define BMI160_USER_READ_ADDR__MSK (0xFF)
-#define BMI160_USER_READ_ADDR__REG (BMI160_USER_MAG_IF_2_ADDR)
-
-/* Mag_IF_3 Description - Reg Addr --> 0x4e, Bit -->0... 7 */
-#define BMI160_USER_WRITE_ADDR__POS (0)
-#define BMI160_USER_WRITE_ADDR__LEN (8)
-#define BMI160_USER_WRITE_ADDR__MSK (0xFF)
-#define BMI160_USER_WRITE_ADDR__REG (BMI160_USER_MAG_IF_3_ADDR)
-
-/* Mag_IF_4 Description - Reg Addr --> 0x4f, Bit -->0... 7 */
-#define BMI160_USER_WRITE_DATA__POS (0)
-#define BMI160_USER_WRITE_DATA__LEN (8)
-#define BMI160_USER_WRITE_DATA__MSK (0xFF)
-#define BMI160_USER_WRITE_DATA__REG (BMI160_USER_MAG_IF_4_ADDR)
-/**************************************************************/
-/**\name ANY MOTION XYZ AXIS ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->0 */
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__POS (0)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__MSK (0x01)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_X_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_0_ADDR)
-
-/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->1 */
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__POS (1)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__MSK (0x02)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Y_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_0_ADDR)
-
-/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->2 */
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__POS (2)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__MSK (0x04)
-#define BMI160_USER_INTR_ENABLE_0_ANY_MOTION_Z_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_0_ADDR)
-/**************************************************************/
-/**\name DOUBLE TAP ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->4 */
-#define BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__POS (4)
-#define BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__MSK (0x10)
-#define BMI160_USER_INTR_ENABLE_0_DOUBLE_TAP_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_0_ADDR)
-/**************************************************************/
-/**\name SINGLE TAP ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->5 */
-#define BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__POS (5)
-#define BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__MSK (0x20)
-#define BMI160_USER_INTR_ENABLE_0_SINGLE_TAP_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_0_ADDR)
-/**************************************************************/
-/**\name ORIENT ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->6 */
-#define BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__POS (6)
-#define BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__MSK (0x40)
-#define BMI160_USER_INTR_ENABLE_0_ORIENT_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_0_ADDR)
-/**************************************************************/
-/**\name FLAT ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_0 Description - Reg Addr --> 0x50, Bit -->7 */
-#define BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__POS (7)
-#define BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__MSK (0x80)
-#define BMI160_USER_INTR_ENABLE_0_FLAT_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_0_ADDR)
-/**************************************************************/
-/**\name HIGH_G XYZ ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->0 */
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__POS (0)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__MSK (0x01)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_X_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_1_ADDR)
-
-/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->1 */
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__POS (1)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__MSK (0x02)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Y_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_1_ADDR)
-
-/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->2 */
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__POS (2)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__MSK (0x04)
-#define BMI160_USER_INTR_ENABLE_1_HIGH_G_Z_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_1_ADDR)
-/**************************************************************/
-/**\name LOW_G ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->3 */
-#define BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__POS (3)
-#define BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__MSK (0x08)
-#define BMI160_USER_INTR_ENABLE_1_LOW_G_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_1_ADDR)
-/**************************************************************/
-/**\name DATA READY ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->4 */
-#define BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__POS (4)
-#define BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__MSK (0x10)
-#define BMI160_USER_INTR_ENABLE_1_DATA_RDY_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_1_ADDR)
-/**************************************************************/
-/**\name FIFO FULL AND WATER MARK ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->5 */
-#define BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__POS (5)
-#define BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__MSK (0x20)
-#define BMI160_USER_INTR_ENABLE_1_FIFO_FULL_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_1_ADDR)
-
-/* Int_En_1 Description - Reg Addr --> (0x51), Bit -->6 */
-#define BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__POS (6)
-#define BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__MSK (0x40)
-#define BMI160_USER_INTR_ENABLE_1_FIFO_WM_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_1_ADDR)
-/**************************************************************/
-/**\name NO MOTION XYZ ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->0 */
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__POS (0)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__MSK (0x01)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_X_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_2_ADDR)
-
-/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->1 */
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__POS (1)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__MSK (0x02)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Y_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_2_ADDR)
-
-/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->2 */
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__POS (2)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__MSK (0x04)
-#define BMI160_USER_INTR_ENABLE_2_NOMOTION_Z_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_2_ADDR)
-/**************************************************************/
-/**\name STEP DETECTOR ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_En_2 Description - Reg Addr --> (0x52), Bit -->3 */
-#define BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__POS (3)
-#define BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__MSK (0x08)
-#define BMI160_USER_INTR_ENABLE_2_STEP_DETECTOR_ENABLE__REG \
-(BMI160_USER_INTR_ENABLE_2_ADDR)
-/**************************************************************/
-/**\name EDGE CONTROL ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->0 */
-#define BMI160_USER_INTR1_EDGE_CTRL__POS (0)
-#define BMI160_USER_INTR1_EDGE_CTRL__LEN (1)
-#define BMI160_USER_INTR1_EDGE_CTRL__MSK (0x01)
-#define BMI160_USER_INTR1_EDGE_CTRL__REG \
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-/**************************************************************/
-/**\name LEVEL CONTROL ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->1 */
-#define BMI160_USER_INTR1_LEVEL__POS (1)
-#define BMI160_USER_INTR1_LEVEL__LEN (1)
-#define BMI160_USER_INTR1_LEVEL__MSK (0x02)
-#define BMI160_USER_INTR1_LEVEL__REG \
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-/**************************************************************/
-/**\name OUTPUT TYPE ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->2 */
-#define BMI160_USER_INTR1_OUTPUT_TYPE__POS (2)
-#define BMI160_USER_INTR1_OUTPUT_TYPE__LEN (1)
-#define BMI160_USER_INTR1_OUTPUT_TYPE__MSK (0x04)
-#define BMI160_USER_INTR1_OUTPUT_TYPE__REG \
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-/**************************************************************/
-/**\name OUTPUT TYPE ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->3 */
-#define BMI160_USER_INTR1_OUTPUT_ENABLE__POS (3)
-#define BMI160_USER_INTR1_OUTPUT_ENABLE__LEN (1)
-#define BMI160_USER_INTR1_OUTPUT_ENABLE__MSK (0x08)
-#define BMI160_USER_INTR1_OUTPUT_ENABLE__REG \
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-/**************************************************************/
-/**\name EDGE CONTROL ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->4 */
-#define BMI160_USER_INTR2_EDGE_CTRL__POS (4)
-#define BMI160_USER_INTR2_EDGE_CTRL__LEN (1)
-#define BMI160_USER_INTR2_EDGE_CTRL__MSK (0x10)
-#define BMI160_USER_INTR2_EDGE_CTRL__REG \
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-/**************************************************************/
-/**\name LEVEL CONTROL ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->5 */
-#define BMI160_USER_INTR2_LEVEL__POS (5)
-#define BMI160_USER_INTR2_LEVEL__LEN (1)
-#define BMI160_USER_INTR2_LEVEL__MSK (0x20)
-#define BMI160_USER_INTR2_LEVEL__REG \
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-/**************************************************************/
-/**\name OUTPUT TYPE ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->6 */
-#define BMI160_USER_INTR2_OUTPUT_TYPE__POS (6)
-#define BMI160_USER_INTR2_OUTPUT_TYPE__LEN (1)
-#define BMI160_USER_INTR2_OUTPUT_TYPE__MSK (0x40)
-#define BMI160_USER_INTR2_OUTPUT_TYPE__REG \
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-
-/* Int_Out_Ctrl Description - Reg Addr --> 0x53, Bit -->7 */
-#define BMI160_USER_INTR2_OUTPUT_EN__POS (7)
-#define BMI160_USER_INTR2_OUTPUT_EN__LEN (1)
-#define BMI160_USER_INTR2_OUTPUT_EN__MSK (0x80)
-#define BMI160_USER_INTR2_OUTPUT_EN__REG \
-(BMI160_USER_INTR_OUT_CTRL_ADDR)
-/**************************************************************/
-/**\name LATCH INTERRUPT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Latch Description - Reg Addr --> 0x54, Bit -->0...3 */
-#define BMI160_USER_INTR_LATCH__POS (0)
-#define BMI160_USER_INTR_LATCH__LEN (4)
-#define BMI160_USER_INTR_LATCH__MSK (0x0F)
-#define BMI160_USER_INTR_LATCH__REG (BMI160_USER_INTR_LATCH_ADDR)
-/**************************************************************/
-/**\name INPUT ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Latch Description - Reg Addr --> 0x54, Bit -->4 */
-#define BMI160_USER_INTR1_INPUT_ENABLE__POS (4)
-#define BMI160_USER_INTR1_INPUT_ENABLE__LEN (1)
-#define BMI160_USER_INTR1_INPUT_ENABLE__MSK (0x10)
-#define BMI160_USER_INTR1_INPUT_ENABLE__REG \
-(BMI160_USER_INTR_LATCH_ADDR)
-
-/* Int_Latch Description - Reg Addr --> 0x54, Bit -->5*/
-#define BMI160_USER_INTR2_INPUT_ENABLE__POS (5)
-#define BMI160_USER_INTR2_INPUT_ENABLE__LEN (1)
-#define BMI160_USER_INTR2_INPUT_ENABLE__MSK (0x20)
-#define BMI160_USER_INTR2_INPUT_ENABLE__REG \
-(BMI160_USER_INTR_LATCH_ADDR)
-/**************************************************************/
-/**\name INTERRUPT1 MAPPIONG OF LOW_G LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->0 */
-#define BMI160_USER_INTR_MAP_0_INTR1_LOW_G__POS (0)
-#define BMI160_USER_INTR_MAP_0_INTR1_LOW_G__LEN (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_LOW_G__MSK (0x01)
-#define BMI160_USER_INTR_MAP_0_INTR1_LOW_G__REG (BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name INTERRUPT1 MAPPIONG OF HIGH_G LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->1 */
-#define BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__POS (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__LEN (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__MSK (0x02)
-#define BMI160_USER_INTR_MAP_0_INTR1_HIGH_G__REG \
-(BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name INTERRUPT MAPPIONG OF ANY MOTION_G LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->2 */
-#define BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__POS (2)
-#define BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__LEN (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__MSK (0x04)
-#define BMI160_USER_INTR_MAP_0_INTR1_ANY_MOTION__REG \
-(BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name INTERRUPT1 MAPPIONG OF NO MOTION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->3 */
-#define BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__POS (3)
-#define BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__LEN (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__MSK (0x08)
-#define BMI160_USER_INTR_MAP_0_INTR1_NOMOTION__REG (BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name INTERRUPT1 MAPPIONG OF DOUBLE TAP LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->4 */
-#define BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__POS (4)
-#define BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__LEN (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__MSK (0x10)
-#define BMI160_USER_INTR_MAP_0_INTR1_DOUBLE_TAP__REG \
-(BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name INTERRUPT1 MAPPIONG OF SINGLE TAP LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->5 */
-#define BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__POS (5)
-#define BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__LEN (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__MSK (0x20)
-#define BMI160_USER_INTR_MAP_0_INTR1_SINGLE_TAP__REG \
-(BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name INTERRUPT1 MAPPIONG OF ORIENT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x55, Bit -->6 */
-#define BMI160_USER_INTR_MAP_0_INTR1_ORIENT__POS (6)
-#define BMI160_USER_INTR_MAP_0_INTR1_ORIENT__LEN (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_ORIENT__MSK (0x40)
-#define BMI160_USER_INTR_MAP_0_INTR1_ORIENT__REG \
-(BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name INTERRUPT MAPPIONG OF FLAT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_0 Description - Reg Addr --> 0x56, Bit -->7 */
-#define BMI160_USER_INTR_MAP_0_INTR1_FLAT__POS (7)
-#define BMI160_USER_INTR_MAP_0_INTR1_FLAT__LEN (1)
-#define BMI160_USER_INTR_MAP_0_INTR1_FLAT__MSK (0x80)
-#define BMI160_USER_INTR_MAP_0_INTR1_FLAT__REG (BMI160_USER_INTR_MAP_0_ADDR)
-/**************************************************************/
-/**\name INTERRUPT1 MAPPIONG OF PMU TRIGGER LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->0 */
-#define BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__POS (0)
-#define BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__LEN (1)
-#define BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__MSK (0x01)
-#define BMI160_USER_INTR_MAP_1_INTR2_PMU_TRIG__REG (BMI160_USER_INTR_MAP_1_ADDR)
-/**************************************************************/
-/**\name INTERRUPT1 MAPPIONG OF FIFO FULL AND
- WATER MARK LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->1 */
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__POS (1)
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__LEN (1)
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__MSK (0x02)
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_FULL__REG \
-(BMI160_USER_INTR_MAP_1_ADDR)
-
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->2 */
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__POS (2)
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__LEN (1)
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__MSK (0x04)
-#define BMI160_USER_INTR_MAP_1_INTR2_FIFO_WM__REG \
-(BMI160_USER_INTR_MAP_1_ADDR)
-/**************************************************************/
-/**\name INTERRUPT1 MAPPIONG OF DATA READY LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->3 */
-#define BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__POS (3)
-#define BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__LEN (1)
-#define BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__MSK (0x08)
-#define BMI160_USER_INTR_MAP_1_INTR2_DATA_RDY__REG \
-(BMI160_USER_INTR_MAP_1_ADDR)
-/**************************************************************/
-/**\name INTERRUPT1 MAPPIONG OF PMU TRIGGER LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->4 */
-#define BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__POS (4)
-#define BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__LEN (1)
-#define BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__MSK (0x10)
-#define BMI160_USER_INTR_MAP_1_INTR1_PMU_TRIG__REG (BMI160_USER_INTR_MAP_1_ADDR)
-/**************************************************************/
-/**\name INTERRUPT1 MAPPIONG OF FIFO FULL AND
- WATER MARK LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->5 */
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__POS (5)
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__LEN (1)
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__MSK (0x20)
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_FULL__REG \
-(BMI160_USER_INTR_MAP_1_ADDR)
-
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->6 */
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__POS (6)
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__LEN (1)
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__MSK (0x40)
-#define BMI160_USER_INTR_MAP_1_INTR1_FIFO_WM__REG \
-(BMI160_USER_INTR_MAP_1_ADDR)
-/**************************************************************/
-/**\name INTERRUPT1 MAPPIONG OF DATA READY LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_1 Description - Reg Addr --> 0x56, Bit -->7 */
-#define BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__POS (7)
-#define BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__LEN (1)
-#define BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__MSK (0x80)
-#define BMI160_USER_INTR_MAP_1_INTR1_DATA_RDY__REG \
-(BMI160_USER_INTR_MAP_1_ADDR)
-/**************************************************************/
-/**\name INTERRUPT2 MAPPIONG OF LOW_G LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->0 */
-#define BMI160_USER_INTR_MAP_2_INTR2_LOW_G__POS (0)
-#define BMI160_USER_INTR_MAP_2_INTR2_LOW_G__LEN (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_LOW_G__MSK (0x01)
-#define BMI160_USER_INTR_MAP_2_INTR2_LOW_G__REG (BMI160_USER_INTR_MAP_2_ADDR)
-/**************************************************************/
-/**\name INTERRUPT2 MAPPIONG OF HIGH_G LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->1 */
-#define BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__POS (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__LEN (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__MSK (0x02)
-#define BMI160_USER_INTR_MAP_2_INTR2_HIGH_G__REG \
-(BMI160_USER_INTR_MAP_2_ADDR)
-/**************************************************************/
-/**\name INTERRUPT2 MAPPIONG OF ANY MOTION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->2 */
-#define BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__POS (2)
-#define BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__LEN (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__MSK (0x04)
-#define BMI160_USER_INTR_MAP_2_INTR2_ANY_MOTION__REG \
-(BMI160_USER_INTR_MAP_2_ADDR)
-/**************************************************************/
-/**\name INTERRUPT2 MAPPIONG OF NO MOTION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->3 */
-#define BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__POS (3)
-#define BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__LEN (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__MSK (0x08)
-#define BMI160_USER_INTR_MAP_2_INTR2_NOMOTION__REG (BMI160_USER_INTR_MAP_2_ADDR)
-/**************************************************************/
-/**\name INTERRUPT2 MAPPIONG OF DOUBLE TAP LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->4 */
-#define BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__POS (4)
-#define BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__LEN (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__MSK (0x10)
-#define BMI160_USER_INTR_MAP_2_INTR2_DOUBLE_TAP__REG \
-(BMI160_USER_INTR_MAP_2_ADDR)
-/**************************************************************/
-/**\name INTERRUPT2 MAPPIONG OF SINGLE TAP LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->5 */
-#define BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__POS (5)
-#define BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__LEN (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__MSK (0x20)
-#define BMI160_USER_INTR_MAP_2_INTR2_SINGLE_TAP__REG \
-(BMI160_USER_INTR_MAP_2_ADDR)
-/**************************************************************/
-/**\name INTERRUPT2 MAPPIONG OF ORIENT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->6 */
-#define BMI160_USER_INTR_MAP_2_INTR2_ORIENT__POS (6)
-#define BMI160_USER_INTR_MAP_2_INTR2_ORIENT__LEN (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_ORIENT__MSK (0x40)
-#define BMI160_USER_INTR_MAP_2_INTR2_ORIENT__REG \
-(BMI160_USER_INTR_MAP_2_ADDR)
-/**************************************************************/
-/**\name INTERRUPT2 MAPPIONG OF FLAT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Map_2 Description - Reg Addr --> 0x57, Bit -->7 */
-#define BMI160_USER_INTR_MAP_2_INTR2_FLAT__POS (7)
-#define BMI160_USER_INTR_MAP_2_INTR2_FLAT__LEN (1)
-#define BMI160_USER_INTR_MAP_2_INTR2_FLAT__MSK (0x80)
-#define BMI160_USER_INTR_MAP_2_INTR2_FLAT__REG (BMI160_USER_INTR_MAP_2_ADDR)
-
-/**************************************************************/
-/**\name TAP SOURCE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Data_0 Description - Reg Addr --> 0x58, Bit --> 3 */
-#define BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__POS (3)
-#define BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__LEN (1)
-#define BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__MSK (0x08)
-#define BMI160_USER_INTR_DATA_0_INTR_TAP_SOURCE__REG \
-(BMI160_USER_INTR_DATA_0_ADDR)
-
-/**************************************************************/
-/**\name HIGH SOURCE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Data_0 Description - Reg Addr --> 0x58, Bit --> 7 */
-#define BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__POS (7)
-#define BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__LEN (1)
-#define BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__MSK (0x80)
-#define BMI160_USER_INTR_DATA_0_INTR_LOW_HIGH_SOURCE__REG \
-(BMI160_USER_INTR_DATA_0_ADDR)
-
-/**************************************************************/
-/**\name MOTION SOURCE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Data_1 Description - Reg Addr --> 0x59, Bit --> 7 */
-#define BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__POS (7)
-#define BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__LEN (1)
-#define BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__MSK (0x80)
-#define BMI160_USER_INTR_DATA_1_INTR_MOTION_SOURCE__REG \
- (BMI160_USER_INTR_DATA_1_ADDR)
-/**************************************************************/
-/**\name LOW HIGH DURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_LowHigh_0 Description - Reg Addr --> 0x5a, Bit --> 0...7 */
-#define BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__POS (0)
-#define BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__LEN (8)
-#define BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__MSK (0xFF)
-#define BMI160_USER_INTR_LOWHIGH_0_INTR_LOW_DURN__REG \
- (BMI160_USER_INTR_LOWHIGH_0_ADDR)
-/**************************************************************/
-/**\name LOW THRESHOLD LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_LowHigh_1 Description - Reg Addr --> 0x5b, Bit --> 0...7 */
-#define BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__POS (0)
-#define BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__LEN (8)
-#define BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__MSK (0xFF)
-#define BMI160_USER_INTR_LOWHIGH_1_INTR_LOW_THRES__REG \
- (BMI160_USER_INTR_LOWHIGH_1_ADDR)
-/**************************************************************/
-/**\name LOW HYSTERESIS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_LowHigh_2 Description - Reg Addr --> 0x5c, Bit --> 0...1 */
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__POS (0)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__LEN (2)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__MSK (0x03)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_HYST__REG \
- (BMI160_USER_INTR_LOWHIGH_2_ADDR)
-/**************************************************************/
-/**\name LOW MODE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_LowHigh_2 Description - Reg Addr --> 0x5c, Bit --> 2 */
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__POS (2)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__LEN (1)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__MSK (0x04)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_LOW_G_MODE__REG \
- (BMI160_USER_INTR_LOWHIGH_2_ADDR)
-/**************************************************************/
-/**\name HIGH_G HYSTERESIS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_LowHigh_2 Description - Reg Addr --> 0x5c, Bit --> 6...7 */
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__POS (6)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__LEN (2)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__MSK (0xC0)
-#define BMI160_USER_INTR_LOWHIGH_2_INTR_HIGH_G_HYST__REG \
- (BMI160_USER_INTR_LOWHIGH_2_ADDR)
-/**************************************************************/
-/**\name HIGH_G DURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_LowHigh_3 Description - Reg Addr --> 0x5d, Bit --> 0...7 */
-#define BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__POS (0)
-#define BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__LEN (8)
-#define BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__MSK (0xFF)
-#define BMI160_USER_INTR_LOWHIGH_3_INTR_HIGH_G_DURN__REG \
- (BMI160_USER_INTR_LOWHIGH_3_ADDR)
-/**************************************************************/
-/**\name HIGH_G THRESHOLD LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_LowHigh_4 Description - Reg Addr --> 0x5e, Bit --> 0...7 */
-#define BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__POS (0)
-#define BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__LEN (8)
-#define BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__MSK (0xFF)
-#define BMI160_USER_INTR_LOWHIGH_4_INTR_HIGH_THRES__REG \
- (BMI160_USER_INTR_LOWHIGH_4_ADDR)
-/**************************************************************/
-/**\name ANY MOTION DURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Motion_0 Description - Reg Addr --> 0x5f, Bit --> 0...1 */
-#define BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__POS (0)
-#define BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__LEN (2)
-#define BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__MSK (0x03)
-#define BMI160_USER_INTR_MOTION_0_INTR_ANY_MOTION_DURN__REG \
- (BMI160_USER_INTR_MOTION_0_ADDR)
-/**************************************************************/
-/**\name SLOW/NO MOTION DURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
- /* Int_Motion_0 Description - Reg Addr --> 0x5f, Bit --> 2...7 */
-#define BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__POS (2)
-#define BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__LEN (6)
-#define BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__MSK (0xFC)
-#define BMI160_USER_INTR_MOTION_0_INTR_SLOW_NO_MOTION_DURN__REG \
- (BMI160_USER_INTR_MOTION_0_ADDR)
-/**************************************************************/
-/**\name ANY MOTION THRESHOLD LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Motion_1 Description - Reg Addr --> (0x60), Bit --> 0...7 */
-#define BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__POS (0)
-#define BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__LEN (8)
-#define BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__MSK (0xFF)
-#define BMI160_USER_INTR_MOTION_1_INTR_ANY_MOTION_THRES__REG \
- (BMI160_USER_INTR_MOTION_1_ADDR)
-/**************************************************************/
-/**\name SLOW/NO MOTION THRESHOLD LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Motion_2 Description - Reg Addr --> 0x61, Bit --> 0...7 */
-#define BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__POS (0)
-#define BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__LEN (8)
-#define BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__MSK (0xFF)
-#define BMI160_USER_INTR_MOTION_2_INTR_SLOW_NO_MOTION_THRES__REG \
- (BMI160_USER_INTR_MOTION_2_ADDR)
-/**************************************************************/
-/**\name SLOW/NO MOTION SELECT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 0 */
-#define BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__POS (0)
-#define BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__LEN (1)
-#define BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__MSK (0x01)
-#define BMI160_USER_INTR_MOTION_3_INTR_SLOW_NO_MOTION_SELECT__REG \
-(BMI160_USER_INTR_MOTION_3_ADDR)
-/**************************************************************/
-/**\name SIGNIFICANT MOTION SELECT LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 1 */
-#define BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__POS (1)
-#define BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__LEN (1)
-#define BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__MSK (0x02)
-#define BMI160_USER_INTR_SIGNIFICATION_MOTION_SELECT__REG \
- (BMI160_USER_INTR_MOTION_3_ADDR)
-
-/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 3..2 */
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__POS (2)
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__LEN (2)
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__MSK (0x0C)
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_SKIP__REG \
- (BMI160_USER_INTR_MOTION_3_ADDR)
-
-/* Int_Motion_3 Description - Reg Addr --> (0x62), Bit --> 5..4 */
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__POS (4)
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__LEN (2)
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__MSK (0x30)
-#define BMI160_USER_INTR_SIGNIFICANT_MOTION_PROOF__REG \
- (BMI160_USER_INTR_MOTION_3_ADDR)
-/**************************************************************/
-/**\name TAP DURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* INT_TAP_0 Description - Reg Addr --> (0x63), Bit --> 0..2*/
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__POS (0)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__LEN (3)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__MSK (0x07)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_DURN__REG \
-(BMI160_USER_INTR_TAP_0_ADDR)
-/**************************************************************/
-/**\name TAP SHOCK LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Tap_0 Description - Reg Addr --> (0x63), Bit --> 6 */
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__POS (6)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__LEN (1)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__MSK (0x40)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_SHOCK__REG (BMI160_USER_INTR_TAP_0_ADDR)
-/**************************************************************/
-/**\name TAP QUIET LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Tap_0 Description - Reg Addr --> (0x63), Bit --> 7 */
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__POS (7)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__LEN (1)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__MSK (0x80)
-#define BMI160_USER_INTR_TAP_0_INTR_TAP_QUIET__REG (BMI160_USER_INTR_TAP_0_ADDR)
-/**************************************************************/
-/**\name TAP THRESHOLD LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Tap_1 Description - Reg Addr --> (0x64), Bit --> 0...4 */
-#define BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__POS (0)
-#define BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__LEN (5)
-#define BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__MSK (0x1F)
-#define BMI160_USER_INTR_TAP_1_INTR_TAP_THRES__REG (BMI160_USER_INTR_TAP_1_ADDR)
-/**************************************************************/
-/**\name ORIENT MODE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Orient_0 Description - Reg Addr --> (0x65), Bit --> 0...1 */
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__POS (0)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__LEN (2)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__MSK (0x03)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_MODE__REG \
- (BMI160_USER_INTR_ORIENT_0_ADDR)
-/**************************************************************/
-/**\name ORIENT BLOCKING LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Orient_0 Description - Reg Addr --> (0x65), Bit --> 2...3 */
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__POS (2)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__LEN (2)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__MSK (0x0C)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_BLOCKING__REG \
- (BMI160_USER_INTR_ORIENT_0_ADDR)
-/**************************************************************/
-/**\name ORIENT HYSTERESIS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Orient_0 Description - Reg Addr --> (0x65), Bit --> 4...7 */
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__POS (4)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__LEN (4)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__MSK (0xF0)
-#define BMI160_USER_INTR_ORIENT_0_INTR_ORIENT_HYST__REG \
- (BMI160_USER_INTR_ORIENT_0_ADDR)
-/**************************************************************/
-/**\name ORIENT THETA LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Orient_1 Description - Reg Addr --> 0x66, Bit --> 0...5 */
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__POS (0)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__LEN (6)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__MSK (0x3F)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_THETA__REG \
- (BMI160_USER_INTR_ORIENT_1_ADDR)
-/**************************************************************/
-/**\name ORIENT UD LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Orient_1 Description - Reg Addr --> 0x66, Bit --> 6 */
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__POS (6)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__LEN (1)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__MSK (0x40)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_UD_ENABLE__REG \
- (BMI160_USER_INTR_ORIENT_1_ADDR)
-/**************************************************************/
-/**\name ORIENT AXIS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Orient_1 Description - Reg Addr --> 0x66, Bit --> 7 */
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__POS (7)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__LEN (1)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__MSK (0x80)
-#define BMI160_USER_INTR_ORIENT_1_INTR_ORIENT_AXES_EX__REG \
- (BMI160_USER_INTR_ORIENT_1_ADDR)
-/**************************************************************/
-/**\name FLAT THETA LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Flat_0 Description - Reg Addr --> 0x67, Bit --> 0...5 */
-#define BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__POS (0)
-#define BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__LEN (6)
-#define BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__MSK (0x3F)
-#define BMI160_USER_INTR_FLAT_0_INTR_FLAT_THETA__REG \
- (BMI160_USER_INTR_FLAT_0_ADDR)
-/**************************************************************/
-/**\name FLAT HYSTERESIS LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Flat_1 Description - Reg Addr --> (0x68), Bit --> 0...3 */
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__POS (0)
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__LEN (4)
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__MSK (0x0F)
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HYST__REG \
-(BMI160_USER_INTR_FLAT_1_ADDR)
-/**************************************************************/
-/**\name FLAT HOLD LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Int_Flat_1 Description - Reg Addr --> (0x68), Bit --> 4...5 */
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__POS (4)
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__LEN (2)
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__MSK (0x30)
-#define BMI160_USER_INTR_FLAT_1_INTR_FLAT_HOLD__REG \
-(BMI160_USER_INTR_FLAT_1_ADDR)
-/**************************************************************/
-/**\name FOC ACCEL XYZ LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 0...1 */
-#define BMI160_USER_FOC_ACCEL_Z__POS (0)
-#define BMI160_USER_FOC_ACCEL_Z__LEN (2)
-#define BMI160_USER_FOC_ACCEL_Z__MSK (0x03)
-#define BMI160_USER_FOC_ACCEL_Z__REG (BMI160_USER_FOC_CONFIG_ADDR)
-
-/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 2...3 */
-#define BMI160_USER_FOC_ACCEL_Y__POS (2)
-#define BMI160_USER_FOC_ACCEL_Y__LEN (2)
-#define BMI160_USER_FOC_ACCEL_Y__MSK (0x0C)
-#define BMI160_USER_FOC_ACCEL_Y__REG (BMI160_USER_FOC_CONFIG_ADDR)
-
-/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 4...5 */
-#define BMI160_USER_FOC_ACCEL_X__POS (4)
-#define BMI160_USER_FOC_ACCEL_X__LEN (2)
-#define BMI160_USER_FOC_ACCEL_X__MSK (0x30)
-#define BMI160_USER_FOC_ACCEL_X__REG (BMI160_USER_FOC_CONFIG_ADDR)
-/**************************************************************/
-/**\name FOC GYRO LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Foc_Conf Description - Reg Addr --> (0x69), Bit --> 6 */
-#define BMI160_USER_FOC_GYRO_ENABLE__POS (6)
-#define BMI160_USER_FOC_GYRO_ENABLE__LEN (1)
-#define BMI160_USER_FOC_GYRO_ENABLE__MSK (0x40)
-#define BMI160_USER_FOC_GYRO_ENABLE__REG \
-(BMI160_USER_FOC_CONFIG_ADDR)
-/**************************************************************/
-/**\name NVM PROGRAM LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* CONF Description - Reg Addr --> (0x6A), Bit --> 1 */
-#define BMI160_USER_CONFIG_NVM_PROG_ENABLE__POS (1)
-#define BMI160_USER_CONFIG_NVM_PROG_ENABLE__LEN (1)
-#define BMI160_USER_CONFIG_NVM_PROG_ENABLE__MSK (0x02)
-#define BMI160_USER_CONFIG_NVM_PROG_ENABLE__REG \
-(BMI160_USER_CONFIG_ADDR)
-
-/*IF_CONF Description - Reg Addr --> (0x6B), Bit --> 0 */
-
-#define BMI160_USER_IF_CONFIG_SPI3__POS (0)
-#define BMI160_USER_IF_CONFIG_SPI3__LEN (1)
-#define BMI160_USER_IF_CONFIG_SPI3__MSK (0x01)
-#define BMI160_USER_IF_CONFIG_SPI3__REG \
-(BMI160_USER_IF_CONFIG_ADDR)
-
-/*IF_CONF Description - Reg Addr --> (0x6B), Bit --> 5..4 */
-#define BMI160_USER_IF_CONFIG_IF_MODE__POS (4)
-#define BMI160_USER_IF_CONFIG_IF_MODE__LEN (2)
-#define BMI160_USER_IF_CONFIG_IF_MODE__MSK (0x30)
-#define BMI160_USER_IF_CONFIG_IF_MODE__REG \
-(BMI160_USER_IF_CONFIG_ADDR)
-/**************************************************************/
-/**\name GYRO SLEEP CONFIGURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 0...2 */
-#define BMI160_USER_GYRO_SLEEP_TRIGGER__POS (0)
-#define BMI160_USER_GYRO_SLEEP_TRIGGER__LEN (3)
-#define BMI160_USER_GYRO_SLEEP_TRIGGER__MSK (0x07)
-#define BMI160_USER_GYRO_SLEEP_TRIGGER__REG (BMI160_USER_PMU_TRIGGER_ADDR)
-
-/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 3...4 */
-#define BMI160_USER_GYRO_WAKEUP_TRIGGER__POS (3)
-#define BMI160_USER_GYRO_WAKEUP_TRIGGER__LEN (2)
-#define BMI160_USER_GYRO_WAKEUP_TRIGGER__MSK (0x18)
-#define BMI160_USER_GYRO_WAKEUP_TRIGGER__REG (BMI160_USER_PMU_TRIGGER_ADDR)
-
-/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 5 */
-#define BMI160_USER_GYRO_SLEEP_STATE__POS (5)
-#define BMI160_USER_GYRO_SLEEP_STATE__LEN (1)
-#define BMI160_USER_GYRO_SLEEP_STATE__MSK (0x20)
-#define BMI160_USER_GYRO_SLEEP_STATE__REG (BMI160_USER_PMU_TRIGGER_ADDR)
-
-/* Pmu_Trigger Description - Reg Addr --> 0x6c, Bit --> 6 */
-#define BMI160_USER_GYRO_WAKEUP_INTR__POS (6)
-#define BMI160_USER_GYRO_WAKEUP_INTR__LEN (1)
-#define BMI160_USER_GYRO_WAKEUP_INTR__MSK (0x40)
-#define BMI160_USER_GYRO_WAKEUP_INTR__REG (BMI160_USER_PMU_TRIGGER_ADDR)
-/**************************************************************/
-/**\name ACCEL SELF TEST LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 0...1 */
-#define BMI160_USER_ACCEL_SELFTEST_AXIS__POS (0)
-#define BMI160_USER_ACCEL_SELFTEST_AXIS__LEN (2)
-#define BMI160_USER_ACCEL_SELFTEST_AXIS__MSK (0x03)
-#define BMI160_USER_ACCEL_SELFTEST_AXIS__REG (BMI160_USER_SELF_TEST_ADDR)
-
-/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 2 */
-#define BMI160_USER_ACCEL_SELFTEST_SIGN__POS (2)
-#define BMI160_USER_ACCEL_SELFTEST_SIGN__LEN (1)
-#define BMI160_USER_ACCEL_SELFTEST_SIGN__MSK (0x04)
-#define BMI160_USER_ACCEL_SELFTEST_SIGN__REG (BMI160_USER_SELF_TEST_ADDR)
-
-/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 3 */
-#define BMI160_USER_SELFTEST_AMP__POS (3)
-#define BMI160_USER_SELFTEST_AMP__LEN (1)
-#define BMI160_USER_SELFTEST_AMP__MSK (0x08)
-#define BMI160_USER_SELFTEST_AMP__REG (BMI160_USER_SELF_TEST_ADDR)
-/**************************************************************/
-/**\name GYRO SELF TEST LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Self_Test Description - Reg Addr --> 0x6d, Bit --> 4 */
-#define BMI160_USER_GYRO_SELFTEST_START__POS (4)
-#define BMI160_USER_GYRO_SELFTEST_START__LEN (1)
-#define BMI160_USER_GYRO_SELFTEST_START__MSK (0x10)
-#define BMI160_USER_GYRO_SELFTEST_START__REG \
-(BMI160_USER_SELF_TEST_ADDR)
-/**************************************************************/
-/**\name NV_CONFIG LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* NV_CONF Description - Reg Addr --> (0x70), Bit --> 0 */
-#define BMI160_USER_NV_CONFIG_SPI_ENABLE__POS (0)
-#define BMI160_USER_NV_CONFIG_SPI_ENABLE__LEN (1)
-#define BMI160_USER_NV_CONFIG_SPI_ENABLE__MSK (0x01)
-#define BMI160_USER_NV_CONFIG_SPI_ENABLE__REG (BMI160_USER_NV_CONFIG_ADDR)
-
-/*IF_CONF Description - Reg Addr --> (0x70), Bit --> 1 */
-#define BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__POS (1)
-#define BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__LEN (1)
-#define BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__MSK (0x02)
-#define BMI160_USER_IF_CONFIG_I2C_WDT_SELECT__REG \
-(BMI160_USER_NV_CONFIG_ADDR)
-
-/*IF_CONF Description - Reg Addr --> (0x70), Bit --> 2 */
-#define BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__POS (2)
-#define BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__LEN (1)
-#define BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__MSK (0x04)
-#define BMI160_USER_IF_CONFIG_I2C_WDT_ENABLE__REG \
-(BMI160_USER_NV_CONFIG_ADDR)
-
-/* NV_CONF Description - Reg Addr --> (0x70), Bit --> 3 */
-#define BMI160_USER_NV_CONFIG_SPARE0__POS (3)
-#define BMI160_USER_NV_CONFIG_SPARE0__LEN (1)
-#define BMI160_USER_NV_CONFIG_SPARE0__MSK (0x08)
-#define BMI160_USER_NV_CONFIG_SPARE0__REG (BMI160_USER_NV_CONFIG_ADDR)
-
-/* NV_CONF Description - Reg Addr --> (0x70), Bit --> 4...7 */
-#define BMI160_USER_NV_CONFIG_NVM_COUNTER__POS (4)
-#define BMI160_USER_NV_CONFIG_NVM_COUNTER__LEN (4)
-#define BMI160_USER_NV_CONFIG_NVM_COUNTER__MSK (0xF0)
-#define BMI160_USER_NV_CONFIG_NVM_COUNTER__REG (BMI160_USER_NV_CONFIG_ADDR)
-/**************************************************************/
-/**\name ACCEL MANUAL OFFSET LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Offset_0 Description - Reg Addr --> (0x71), Bit --> 0...7 */
-#define BMI160_USER_OFFSET_0_ACCEL_OFF_X__POS (0)
-#define BMI160_USER_OFFSET_0_ACCEL_OFF_X__LEN (8)
-#define BMI160_USER_OFFSET_0_ACCEL_OFF_X__MSK (0xFF)
-#define BMI160_USER_OFFSET_0_ACCEL_OFF_X__REG (BMI160_USER_OFFSET_0_ADDR)
-
-/* Offset_1 Description - Reg Addr --> 0x72, Bit --> 0...7 */
-#define BMI160_USER_OFFSET_1_ACCEL_OFF_Y__POS (0)
-#define BMI160_USER_OFFSET_1_ACCEL_OFF_Y__LEN (8)
-#define BMI160_USER_OFFSET_1_ACCEL_OFF_Y__MSK (0xFF)
-#define BMI160_USER_OFFSET_1_ACCEL_OFF_Y__REG (BMI160_USER_OFFSET_1_ADDR)
-
-/* Offset_2 Description - Reg Addr --> 0x73, Bit --> 0...7 */
-#define BMI160_USER_OFFSET_2_ACCEL_OFF_Z__POS (0)
-#define BMI160_USER_OFFSET_2_ACCEL_OFF_Z__LEN (8)
-#define BMI160_USER_OFFSET_2_ACCEL_OFF_Z__MSK (0xFF)
-#define BMI160_USER_OFFSET_2_ACCEL_OFF_Z__REG (BMI160_USER_OFFSET_2_ADDR)
-/**************************************************************/
-/**\name GYRO MANUAL OFFSET LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Offset_3 Description - Reg Addr --> 0x74, Bit --> 0...7 */
-#define BMI160_USER_OFFSET_3_GYRO_OFF_X__POS (0)
-#define BMI160_USER_OFFSET_3_GYRO_OFF_X__LEN (8)
-#define BMI160_USER_OFFSET_3_GYRO_OFF_X__MSK (0xFF)
-#define BMI160_USER_OFFSET_3_GYRO_OFF_X__REG (BMI160_USER_OFFSET_3_ADDR)
-
-/* Offset_4 Description - Reg Addr --> 0x75, Bit --> 0...7 */
-#define BMI160_USER_OFFSET_4_GYRO_OFF_Y__POS (0)
-#define BMI160_USER_OFFSET_4_GYRO_OFF_Y__LEN (8)
-#define BMI160_USER_OFFSET_4_GYRO_OFF_Y__MSK (0xFF)
-#define BMI160_USER_OFFSET_4_GYRO_OFF_Y__REG (BMI160_USER_OFFSET_4_ADDR)
-
-/* Offset_5 Description - Reg Addr --> 0x76, Bit --> 0...7 */
-#define BMI160_USER_OFFSET_5_GYRO_OFF_Z__POS (0)
-#define BMI160_USER_OFFSET_5_GYRO_OFF_Z__LEN (8)
-#define BMI160_USER_OFFSET_5_GYRO_OFF_Z__MSK (0xFF)
-#define BMI160_USER_OFFSET_5_GYRO_OFF_Z__REG (BMI160_USER_OFFSET_5_ADDR)
-
-
-/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 0..1 */
-#define BMI160_USER_OFFSET_6_GYRO_OFF_X__POS (0)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_X__LEN (2)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_X__MSK (0x03)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_X__REG (BMI160_USER_OFFSET_6_ADDR)
-
-/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 2...3 */
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Y__POS (2)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Y__LEN (2)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Y__MSK (0x0C)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Y__REG (BMI160_USER_OFFSET_6_ADDR)
-
-/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 4...5 */
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Z__POS (4)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Z__LEN (2)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Z__MSK (0x30)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_Z__REG (BMI160_USER_OFFSET_6_ADDR)
-/**************************************************************/
-/**\name ACCEL OFFSET ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 6 */
-#define BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__POS (6)
-#define BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__LEN (1)
-#define BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__MSK (0x40)
-#define BMI160_USER_OFFSET_6_ACCEL_OFF_ENABLE__REG \
-(BMI160_USER_OFFSET_6_ADDR)
-/**************************************************************/
-/**\name GYRO OFFSET ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Offset_6 Description - Reg Addr --> 0x77, Bit --> 7 */
-#define BMI160_USER_OFFSET_6_GYRO_OFF_EN__POS (7)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_EN__LEN (1)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_EN__MSK (0x80)
-#define BMI160_USER_OFFSET_6_GYRO_OFF_EN__REG (BMI160_USER_OFFSET_6_ADDR)
-/**************************************************************/
-/**\name STEP COUNTER LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* STEP_CNT_0 Description - Reg Addr --> 0x78, Bit --> 0 to 7 */
-#define BMI160_USER_STEP_COUNT_LSB__POS (0)
-#define BMI160_USER_STEP_COUNT_LSB__LEN (7)
-#define BMI160_USER_STEP_COUNT_LSB__MSK (0xFF)
-#define BMI160_USER_STEP_COUNT_LSB__REG (BMI160_USER_STEP_COUNT_0_ADDR)
-
-/* STEP_CNT_1 Description - Reg Addr --> 0x79, Bit --> 0 to 7 */
-#define BMI160_USER_STEP_COUNT_MSB__POS (0)
-#define BMI160_USER_STEP_COUNT_MSB__LEN (7)
-#define BMI160_USER_STEP_COUNT_MSB__MSK (0xFF)
-#define BMI160_USER_STEP_COUNT_MSB__REG (BMI160_USER_STEP_COUNT_1_ADDR)
-/**************************************************************/
-/**\name STEP COUNTER CONFIGURATION LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* STEP_CONFIG_0 Description - Reg Addr --> 0x7A, Bit --> 0 to 7 */
-#define BMI160_USER_STEP_CONFIG_ZERO__POS (0)
-#define BMI160_USER_STEP_CONFIG_ZERO__LEN (7)
-#define BMI160_USER_STEP_CONFIG_ZERO__MSK (0xFF)
-#define BMI160_USER_STEP_CONFIG_ZERO__REG \
-(BMI160_USER_STEP_CONFIG_0_ADDR)
-
-
-/* STEP_CONFIG_1 Description - Reg Addr --> 0x7B, Bit --> 0 to 2 and
-4 to 7 */
-#define BMI160_USER_STEP_CONFIG_ONE_CNF1__POS (0)
-#define BMI160_USER_STEP_CONFIG_ONE_CNF1__LEN (3)
-#define BMI160_USER_STEP_CONFIG_ONE_CNF1__MSK (0x07)
-#define BMI160_USER_STEP_CONFIG_ONE_CNF1__REG \
-(BMI160_USER_STEP_CONFIG_1_ADDR)
-
-#define BMI160_USER_STEP_CONFIG_ONE_CNF2__POS (4)
-#define BMI160_USER_STEP_CONFIG_ONE_CNF2__LEN (4)
-#define BMI160_USER_STEP_CONFIG_ONE_CNF2__MSK (0xF0)
-#define BMI160_USER_STEP_CONFIG_ONE_CNF2__REG \
-(BMI160_USER_STEP_CONFIG_1_ADDR)
-/**************************************************************/
-/**\name STEP COUNTER ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* STEP_CONFIG_1 Description - Reg Addr --> 0x7B, Bit --> 0 to 2 */
-#define BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__POS (3)
-#define BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__LEN (1)
-#define BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__MSK (0x08)
-#define BMI160_USER_STEP_CONFIG_1_STEP_COUNT_ENABLE__REG \
-(BMI160_USER_STEP_CONFIG_1_ADDR)
-
-/* USER REGISTERS DEFINITION END */
-/**************************************************************************/
-/* CMD REGISTERS DEFINITION START */
-/**************************************************************/
-/**\name COMMAND REGISTER LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Command description address - Reg Addr --> 0x7E, Bit --> 0....7 */
-#define BMI160_CMD_COMMANDS__POS (0)
-#define BMI160_CMD_COMMANDS__LEN (8)
-#define BMI160_CMD_COMMANDS__MSK (0xFF)
-#define BMI160_CMD_COMMANDS__REG (BMI160_CMD_COMMANDS_ADDR)
-/**************************************************************/
-/**\name PAGE ENABLE LENGTH, POSITION AND MASK*/
-/**************************************************************/
-/* Target page address - Reg Addr --> 0x7F, Bit --> 4....5 */
-#define BMI160_CMD_TARGET_PAGE__POS (4)
-#define BMI160_CMD_TARGET_PAGE__LEN (2)
-#define BMI160_CMD_TARGET_PAGE__MSK (0x30)
-#define BMI160_CMD_TARGET_PAGE__REG (BMI160_CMD_EXT_MODE_ADDR)
-
-/* Target page address - Reg Addr --> 0x7F, Bit --> 4....5 */
-#define BMI160_CMD_PAGING_EN__POS (7)
-#define BMI160_CMD_PAGING_EN__LEN (1)
-#define BMI160_CMD_PAGING_EN__MSK (0x80)
-#define BMI160_CMD_PAGING_EN__REG (BMI160_CMD_EXT_MODE_ADDR)
-
-/* Target page address - Reg Addr --> 0x7F, Bit --> 4....5 */
-#define BMI160_COM_C_TRIM_FIVE__POS (0)
-#define BMI160_COM_C_TRIM_FIVE__LEN (8)
-#define BMI160_COM_C_TRIM_FIVE__MSK (0xFF)
-#define BMI160_COM_C_TRIM_FIVE__REG (BMI160_COM_C_TRIM_FIVE_ADDR)
-
-/**************************************************************************/
-/* CMD REGISTERS DEFINITION END */
-
-/**************************************************/
-/**\name FIFO FRAME COUNT DEFINITION */
-/*************************************************/
-#define FIFO_FRAME (1024)
-#define FIFO_CONFIG_CHECK1 (0x00)
-#define FIFO_CONFIG_CHECK2 (0x80)
-/**************************************************/
-/**\name MAG SENSOR SELECT */
-/*************************************************/
-#define BST_BMM (0)
-#define BST_AKM (1)
-#define BMI160_YAS537_I2C_ADDRESS (0x2E)
-/**************************************************/
-/**\name ACCEL RANGE */
-/*************************************************/
-#define BMI160_ACCEL_RANGE_2G (0X03)
-#define BMI160_ACCEL_RANGE_4G (0X05)
-#define BMI160_ACCEL_RANGE_8G (0X08)
-#define BMI160_ACCEL_RANGE_16G (0X0C)
-/**************************************************/
-/**\name ACCEL ODR */
-/*************************************************/
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED (0x00)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ (0x01)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_1_56HZ (0x02)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_3_12HZ (0x03)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ (0x04)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ (0x05)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ (0x06)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ (0x07)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ (0x08)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ (0x09)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ (0x0A)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_800HZ (0x0B)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ (0x0C)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED0 (0x0D)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED1 (0x0E)
-#define BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED2 (0x0F)
-/**************************************************/
-/**\name ACCEL BANDWIDTH PARAMETER */
-/*************************************************/
-#define BMI160_ACCEL_OSR4_AVG1 (0)
-#define BMI160_ACCEL_OSR2_AVG2 (1)
-#define BMI160_ACCEL_NORMAL_AVG4 (2)
-#define BMI160_ACCEL_CIC_AVG8 (3)
-#define BMI160_ACCEL_RES_AVG2 (4)
-#define BMI160_ACCEL_RES_AVG4 (5)
-#define BMI160_ACCEL_RES_AVG8 (6)
-#define BMI160_ACCEL_RES_AVG16 (7)
-#define BMI160_ACCEL_RES_AVG32 (8)
-#define BMI160_ACCEL_RES_AVG64 (9)
-#define BMI160_ACCEL_RES_AVG128 (10)
-
-#define BMI160_US_DISABLE (0)
-#define BMI160_US_ENABLE (1)
-/**************************************************/
-/**\name GYRO ODR */
-/*************************************************/
-#define BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED (0x00)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_25HZ (0x06)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_50HZ (0x07)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_100HZ (0x08)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_200HZ (0x09)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_400HZ (0x0A)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_800HZ (0x0B)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_1600HZ (0x0C)
-#define BMI160_GYRO_OUTPUT_DATA_RATE_3200HZ (0x0D)
-/**************************************************/
-/**\name GYRO BANDWIDTH PARAMETER */
-/*************************************************/
-#define BMI160_GYRO_OSR4_MODE (0x00)
-#define BMI160_GYRO_OSR2_MODE (0x01)
-#define BMI160_GYRO_NORMAL_MODE (0x02)
-#define BMI160_GYRO_CIC_MODE (0x03)
-/**************************************************/
-/**\name GYROSCOPE RANGE PARAMETER */
-/*************************************************/
-#define BMI160_GYRO_RANGE_2000_DEG_SEC (0x00)
-#define BMI160_GYRO_RANGE_1000_DEG_SEC (0x01)
-#define BMI160_GYRO_RANGE_500_DEG_SEC (0x02)
-#define BMI160_GYRO_RANGE_250_DEG_SEC (0x03)
-#define BMI160_GYRO_RANGE_125_DEG_SEC (0x04)
-/**************************************************/
-/**\name MAG ODR */
-/*************************************************/
-#define BMI160_MAG_OUTPUT_DATA_RATE_RESERVED (0x00)
-#define BMI160_MAG_OUTPUT_DATA_RATE_0_78HZ (0x01)
-#define BMI160_MAG_OUTPUT_DATA_RATE_1_56HZ (0x02)
-#define BMI160_MAG_OUTPUT_DATA_RATE_3_12HZ (0x03)
-#define BMI160_MAG_OUTPUT_DATA_RATE_6_25HZ (0x04)
-#define BMI160_MAG_OUTPUT_DATA_RATE_12_5HZ (0x05)
-#define BMI160_MAG_OUTPUT_DATA_RATE_25HZ (0x06)
-#define BMI160_MAG_OUTPUT_DATA_RATE_50HZ (0x07)
-#define BMI160_MAG_OUTPUT_DATA_RATE_100HZ (0x08)
-#define BMI160_MAG_OUTPUT_DATA_RATE_200HZ (0x09)
-#define BMI160_MAG_OUTPUT_DATA_RATE_400HZ (0x0A)
-#define BMI160_MAG_OUTPUT_DATA_RATE_800HZ (0x0B)
-#define BMI160_MAG_OUTPUT_DATA_RATE_1600HZ (0x0C)
-#define BMI160_MAG_OUTPUT_DATA_RATE_RESERVED0 (0x0D)
-#define BMI160_MAG_OUTPUT_DATA_RATE_RESERVED1 (0x0E)
-#define BMI160_MAG_OUTPUT_DATA_RATE_RESERVED2 (0x0F)
-
-/**************************************************/
-/**\name ENABLE/DISABLE SELECTIONS */
-/*************************************************/
-
-/* Enable accel and gyro offset */
-#define ACCEL_OFFSET_ENABLE (0x01)
-#define GYRO_OFFSET_ENABLE (0x01)
-
-/* command register definition */
-#define START_FOC_ACCEL_GYRO (0X03)
-
- /* INT ENABLE 1 */
-#define BMI160_ANY_MOTION_X_ENABLE (0)
-#define BMI160_ANY_MOTION_Y_ENABLE (1)
-#define BMI160_ANY_MOTION_Z_ENABLE (2)
-#define BMI160_DOUBLE_TAP_ENABLE (4)
-#define BMI160_SINGLE_TAP_ENABLE (5)
-#define BMI160_ORIENT_ENABLE (6)
-#define BMI160_FLAT_ENABLE (7)
-
-/* INT ENABLE 1 */
-#define BMI160_HIGH_G_X_ENABLE (0)
-#define BMI160_HIGH_G_Y_ENABLE (1)
-#define BMI160_HIGH_G_Z_ENABLE (2)
-#define BMI160_LOW_G_ENABLE (3)
-#define BMI160_DATA_RDY_ENABLE (4)
-#define BMI160_FIFO_FULL_ENABLE (5)
-#define BMI160_FIFO_WM_ENABLE (6)
-
-/* INT ENABLE 2 */
-#define BMI160_NOMOTION_X_ENABLE (0)
-#define BMI160_NOMOTION_Y_ENABLE (1)
-#define BMI160_NOMOTION_Z_ENABLE (2)
-
-/* FOC axis selection for accel*/
-#define FOC_X_AXIS (0)
-#define FOC_Y_AXIS (1)
-#define FOC_Z_AXIS (2)
-
-/* IN OUT CONTROL */
-#define BMI160_INTR1_EDGE_CTRL (0)
-#define BMI160_INTR2_EDGE_CTRL (1)
-#define BMI160_INTR1_LEVEL (0)
-#define BMI160_INTR2_LEVEL (1)
-#define BMI160_INTR1_OUTPUT_TYPE (0)
-#define BMI160_INTR2_OUTPUT_TYPE (1)
-#define BMI160_INTR1_OUTPUT_ENABLE (0)
-#define BMI160_INTR2_OUTPUT_ENABLE (1)
-
-#define BMI160_INTR1_INPUT_ENABLE (0)
-#define BMI160_INTR2_INPUT_ENABLE (1)
-
-/* INTERRUPT MAPS */
-#define BMI160_INTR1_MAP_LOW_G (0)
-#define BMI160_INTR2_MAP_LOW_G (1)
-#define BMI160_INTR1_MAP_HIGH_G (0)
-#define BMI160_INTR2_MAP_HIGH_G (1)
-#define BMI160_INTR1_MAP_ANY_MOTION (0)
-#define BMI160_INTR2_MAP_ANY_MOTION (1)
-#define BMI160_INTR1_MAP_NOMO (0)
-#define BMI160_INTR2_MAP_NOMO (1)
-#define BMI160_INTR1_MAP_DOUBLE_TAP (0)
-#define BMI160_INTR2_MAP_DOUBLE_TAP (1)
-#define BMI160_INTR1_MAP_SINGLE_TAP (0)
-#define BMI160_INTR2_MAP_SINGLE_TAP (1)
-#define BMI160_INTR1_MAP_ORIENT (0)
-#define BMI160_INTR2_MAP_ORIENT (1)
-#define BMI160_INTR1_MAP_FLAT (0)
-#define BMI160_INTR2_MAP_FLAT (1)
-#define BMI160_INTR1_MAP_DATA_RDY (0)
-#define BMI160_INTR2_MAP_DATA_RDY (1)
-#define BMI160_INTR1_MAP_FIFO_WM (0)
-#define BMI160_INTR2_MAP_FIFO_WM (1)
-#define BMI160_INTR1_MAP_FIFO_FULL (0)
-#define BMI160_INTR2_MAP_FIFO_FULL (1)
-#define BMI160_INTR1_MAP_PMUTRIG (0)
-#define BMI160_INTR2_MAP_PMUTRIG (1)
-
-/* Interrupt mapping*/
-#define BMI160_MAP_INTR1 (0)
-#define BMI160_MAP_INTR2 (1)
-/**************************************************/
-/**\name TAP DURATION */
-/*************************************************/
-#define BMI160_TAP_DURN_50MS (0x00)
-#define BMI160_TAP_DURN_100MS (0x01)
-#define BMI160_TAP_DURN_150MS (0x02)
-#define BMI160_TAP_DURN_200MS (0x03)
-#define BMI160_TAP_DURN_250MS (0x04)
-#define BMI160_TAP_DURN_375MS (0x05)
-#define BMI160_TAP_DURN_500MS (0x06)
-#define BMI160_TAP_DURN_700MS (0x07)
-/**************************************************/
-/**\name TAP SHOCK */
-/*************************************************/
-#define BMI160_TAP_SHOCK_50MS (0x00)
-#define BMI160_TAP_SHOCK_75MS (0x01)
-/**************************************************/
-/**\name TAP QUIET */
-/*************************************************/
-#define BMI160_TAP_QUIET_30MS (0x00)
-#define BMI160_TAP_QUIET_20MS (0x01)
-/**************************************************/
-/**\name STEP DETECTION SELECTION MODES */
-/*************************************************/
-#define BMI160_STEP_NORMAL_MODE (0)
-#define BMI160_STEP_SENSITIVE_MODE (1)
-#define BMI160_STEP_ROBUST_MODE (2)
-/**************************************************/
-/**\name STEP CONFIGURATION SELECT MODE */
-/*************************************************/
-#define STEP_CONFIG_NORMAL (0X315)
-#define STEP_CONFIG_SENSITIVE (0X2D)
-#define STEP_CONFIG_ROBUST (0X71D)
-/**************************************************/
-/**\name BMM150 TRIM DATA DEFINITIONS */
-/*************************************************/
-#define BMI160_MAG_DIG_X1 (0x5D)
-#define BMI160_MAG_DIG_Y1 (0x5E)
-#define BMI160_MAG_DIG_Z4_LSB (0x62)
-#define BMI160_MAG_DIG_Z4_MSB (0x63)
-#define BMI160_MAG_DIG_X2 (0x64)
-#define BMI160_MAG_DIG_Y2 (0x65)
-#define BMI160_MAG_DIG_Z2_LSB (0x68)
-#define BMI160_MAG_DIG_Z2_MSB (0x69)
-#define BMI160_MAG_DIG_Z1_LSB (0x6A)
-#define BMI160_MAG_DIG_Z1_MSB (0x6B)
-#define BMI160_MAG_DIG_XYZ1_LSB (0x6C)
-#define BMI160_MAG_DIG_XYZ1_MSB (0x6D)
-#define BMI160_MAG_DIG_Z3_LSB (0x6E)
-#define BMI160_MAG_DIG_Z3_MSB (0x6F)
-#define BMI160_MAG_DIG_XY2 (0x70)
-#define BMI160_MAG_DIG_XY1 (0x71)
-/**************************************************/
-/**\name BMM150 PRE-SET MODE DEFINITIONS */
-/*************************************************/
-#define BMI160_MAG_PRESETMODE_LOWPOWER (1)
-#define BMI160_MAG_PRESETMODE_REGULAR (2)
-#define BMI160_MAG_PRESETMODE_HIGHACCURACY (3)
-#define BMI160_MAG_PRESETMODE_ENHANCED (4)
-/**************************************************/
-/**\name BMM150 PRESET MODES - DATA RATES */
-/*************************************************/
-#define BMI160_MAG_LOWPOWER_DR (0x02)
-#define BMI160_MAG_REGULAR_DR (0x02)
-#define BMI160_MAG_HIGHACCURACY_DR (0x2A)
-#define BMI160_MAG_ENHANCED_DR (0x02)
-/**************************************************/
-/**\name BMM150 PRESET MODES - REPETITIONS-XY RATES */
-/*************************************************/
-#define BMI160_MAG_LOWPOWER_REPXY (1)
-#define BMI160_MAG_REGULAR_REPXY (4)
-#define BMI160_MAG_HIGHACCURACY_REPXY (23)
-#define BMI160_MAG_ENHANCED_REPXY (7)
-/**************************************************/
-/**\name BMM150 PRESET MODES - REPETITIONS-Z RATES */
-/*************************************************/
-#define BMI160_MAG_LOWPOWER_REPZ (2)
-#define BMI160_MAG_REGULAR_REPZ (14)
-#define BMI160_MAG_HIGHACCURACY_REPZ (82)
-#define BMI160_MAG_ENHANCED_REPZ (26)
-#define BMI160_MAG_NOAMRL_SWITCH_TIMES (5)
-#define MAG_INTERFACE_PMU_ENABLE (1)
-#define MAG_INTERFACE_PMU_DISABLE (0)
-/**************************************************/
-/**\name USED FOR MAG OVERFLOW CHECK FOR BMM150 */
-/*************************************************/
-#define BMI160_MAG_OVERFLOW_OUTPUT ((s16)-32768)
-#define BMI160_MAG_OVERFLOW_OUTPUT_S32 ((s32)(-2147483647-1))
-#define BMI160_MAG_NEGATIVE_SATURATION_Z ((s16)-32767)
-#define BMI160_MAG_POSITIVE_SATURATION_Z ((u16)32767)
-#define BMI160_MAG_FLIP_OVERFLOW_ADCVAL ((s16)-4096)
-#define BMI160_MAG_HALL_OVERFLOW_ADCVAL ((s16)-16384)
-/**************************************************/
-/**\name BMM150 REGISTER DEFINITION */
-/*************************************************/
-#define BMI160_BMM150_CHIP_ID (0x40)
-#define BMI160_BMM150_POWE_CONTROL_REG (0x4B)
-#define BMI160_BMM150_POWE_MODE_REG (0x4C)
-#define BMI160_BMM150_DATA_REG (0x42)
-#define BMI160_BMM150_XY_REP (0x51)
-#define BMI160_BMM150_Z_REP (0x52)
-/**************************************************/
-/**\name AKM COMPENSATING DATA REGISTERS */
-/*************************************************/
-#define BMI160_BST_AKM_ASAX (0x60)
-#define BMI160_BST_AKM_ASAY (0x61)
-#define BMI160_BST_AKM_ASAZ (0x62)
-/**************************************************/
-/**\name AKM POWER MODE SELECTION */
-/*************************************************/
-#define AKM_POWER_DOWN_MODE (0)
-#define AKM_SINGLE_MEAS_MODE (1)
-#define FUSE_ROM_MODE (2)
-/**************************************************/
-/**\name SECONDARY_MAG POWER MODE SELECTION */
-/*************************************************/
-#define BMI160_MAG_FORCE_MODE (0)
-#define BMI160_MAG_SUSPEND_MODE (1)
-/**************************************************/
-/**\name MAG POWER MODE SELECTION */
-/*************************************************/
-#define FORCE_MODE (0)
-#define SUSPEND_MODE (1)
-#define NORMAL_MODE (2)
-#define MAG_SUSPEND_MODE (1)
-/**************************************************/
-/**\name FIFO CONFIGURATIONS */
-/*************************************************/
-#define FIFO_HEADER_ENABLE (0x01)
-#define FIFO_MAG_ENABLE (0x01)
-#define FIFO_ACCEL_ENABLE (0x01)
-#define FIFO_GYRO_ENABLE (0x01)
-#define FIFO_TIME_ENABLE (0x01)
-#define FIFO_STOPONFULL_ENABLE (0x01)
-#define FIFO_WM_INTERRUPT_ENABLE (0x01)
-#define BMI160_FIFO_INDEX_LENGTH (1)
-#define BMI160_FIFO_TAG_INTR_MASK (0xFC)
-
-/* FIFO definitions*/
-#define FIFO_HEAD_A (0x84)
-#define FIFO_HEAD_G (0x88)
-#define FIFO_HEAD_M (0x90)
-
-#define FIFO_HEAD_G_A (0x8C)
-#define FIFO_HEAD_M_A (0x94)
-#define FIFO_HEAD_M_G (0x98)
-
-#define FIFO_HEAD_M_G_A (0x9C)
-
-#define FIFO_HEAD_SENSOR_TIME (0x44)
-#define FIFO_HEAD_INPUT_CONFIG (0x48)
-#define FIFO_HEAD_SKIP_FRAME (0x40)
-#define FIFO_HEAD_OVER_READ_LSB (0x80)
-#define FIFO_HEAD_OVER_READ_MSB (0x00)
-
-
-/* FIFO 1024 byte, max fifo frame count not over 150 */
-
-#define FIFO_INPUT_CONFIG_OVER_LEN ((s8)-11)
-#define FIFO_OVER_READ_RETURN ((s8)-10)
-#define FIFO_SENSORTIME_RETURN ((s8)-9)
-#define FIFO_SKIP_OVER_LEN ((s8)-8)
-#define FIFO_M_G_A_OVER_LEN ((s8)-7)
-#define FIFO_M_G_OVER_LEN ((s8)-6)
-#define FIFO_M_A_OVER_LEN ((s8)-5)
-#define FIFO_G_A_OVER_LEN ((s8)-4)
-#define FIFO_M_OVER_LEN ((s8)-3)
-#define FIFO_G_OVER_LEN ((s8)-2)
-#define FIFO_A_OVER_LEN ((s8)-1)
-/**************************************************/
-/**\name ACCEL POWER MODE */
-/*************************************************/
-#define ACCEL_MODE_NORMAL (0x11)
-#define ACCEL_LOWPOWER (0X12)
-#define ACCEL_SUSPEND (0X10)
-/**************************************************/
-/**\name GYRO POWER MODE */
-/*************************************************/
-#define GYRO_MODE_SUSPEND (0x14)
-#define GYRO_MODE_NORMAL (0x15)
-#define GYRO_MODE_FASTSTARTUP (0x17)
-/**************************************************/
-/**\name MAG POWER MODE */
-/*************************************************/
-#define MAG_MODE_SUSPEND (0x18)
-#define MAG_MODE_NORMAL (0x19)
-#define MAG_MODE_LOWPOWER (0x1A)
-/**************************************************/
-/**\name ENABLE/DISABLE BIT VALUES */
-/*************************************************/
-#define BMI160_ENABLE (0x01)
-#define BMI160_DISABLE (0x00)
-/**************************************************/
-/**\name INTERRUPT EDGE TRIGGER ENABLE */
-/*************************************************/
-#define BMI160_EDGE (0x01)
-#define BMI160_LEVEL (0x00)
-/**************************************************/
-/**\name INTERRUPT LEVEL ENABLE */
-/*************************************************/
-#define BMI160_LEVEL_LOW (0x00)
-#define BMI160_LEVEL_HIGH (0x01)
-/**************************************************/
-/**\name INTERRUPT OUTPUT ENABLE */
-/*************************************************/
-#define BMI160_OPEN_DRAIN (0x01)
-#define BMI160_PUSH_PULL (0x00)
-
-/* interrupt output enable*/
-#define BMI160_INPUT (0x01)
-#define BMI160_OUTPUT (0x00)
-
-/**************************************************/
-/**\name INTERRUPT TAP SOURCE ENABLE */
-/*************************************************/
-#define FILTER_DATA (0x00)
-#define UNFILTER_DATA (0x01)
-/**************************************************/
-/**\name SLOW MOTION/ NO MOTION SELECT */
-/*************************************************/
-#define SLOW_MOTION (0x00)
-#define NO_MOTION (0x01)
-/**************************************************/
-/**\name SIGNIFICANT MOTION SELECTION */
-/*************************************************/
-#define ANY_MOTION (0x00)
-#define SIGNIFICANT_MOTION (0x01)
-/**************************************************/
-/**\name LATCH DURATION */
-/*************************************************/
-#define BMI160_LATCH_DUR_NONE (0x00)
-#define BMI160_LATCH_DUR_312_5_MICRO_SEC (0x01)
-#define BMI160_LATCH_DUR_625_MICRO_SEC (0x02)
-#define BMI160_LATCH_DUR_1_25_MILLI_SEC (0x03)
-#define BMI160_LATCH_DUR_2_5_MILLI_SEC (0x04)
-#define BMI160_LATCH_DUR_5_MILLI_SEC (0x05)
-#define BMI160_LATCH_DUR_10_MILLI_SEC (0x06)
-#define BMI160_LATCH_DUR_20_MILLI_SEC (0x07)
-#define BMI160_LATCH_DUR_40_MILLI_SEC (0x08)
-#define BMI160_LATCH_DUR_80_MILLI_SEC (0x09)
-#define BMI160_LATCH_DUR_160_MILLI_SEC (0x0A)
-#define BMI160_LATCH_DUR_320_MILLI_SEC (0x0B)
-#define BMI160_LATCH_DUR_640_MILLI_SEC (0x0C)
-#define BMI160_LATCH_DUR_1_28_SEC (0x0D)
-#define BMI160_LATCH_DUR_2_56_SEC (0x0E)
-#define BMI160_LATCHED (0x0F)
-/**************************************************/
-/**\name GYRO OFFSET MASK DEFINITION */
-/*************************************************/
-#define BMI160_GYRO_MANUAL_OFFSET_0_7 (0x00FF)
-#define BMI160_GYRO_MANUAL_OFFSET_8_9 (0x0300)
-/**************************************************/
-/**\name STEP CONFIGURATION MASK DEFINITION */
-/*************************************************/
-#define BMI160_STEP_CONFIG_0_7 (0x00FF)
-#define BMI160_STEP_CONFIG_8_10 (0x0700)
-#define BMI160_STEP_CONFIG_11_14 (0xF000)
-/**************************************************/
-/**\name DEFINITION USED FOR DIFFERENT WRITE */
-/*************************************************/
-#define BMI160_WRITE_TARGET_PAGE0 (0x00)
-#define BMI160_WRITE_TARGET_PAGE1 (0x01)
-#define BMI160_WRITE_ENABLE_PAGE1 (0x01)
-#define BMI160_MANUAL_DISABLE (0x00)
-#define BMI160_MANUAL_ENABLE (0x01)
-#define BMI160_YAS_DISABLE_RCOIL (0x00)
-#define BMI160_ENABLE_MAG_IF_MODE (0x02)
-#define BMI160_ENABLE_ANY_MOTION_INTR1 (0x04)
-#define BMI160_ENABLE_ANY_MOTION_INTR2 (0x04)
-#define BMI160_MAG_DATA_READ_REG (0x04)
-#define BMI160_BMM_POWER_MODE_REG (0x06)
-#define BMI160_ENABLE_ANY_MOTION_AXIS (0x07)
-#define BMI160_ENABLE_LOW_G (0x08)
-#define BMI160_YAS532_ACQ_START (0x11)
-#define BMI160_YAS_DEVICE_ID_REG (0x80)
-#define BMI160_FIFO_GYRO_ENABLE (0x80)
-#define BMI160_SIG_MOTION_INTR_ENABLE (0x01)
-#define BMI160_STEP_DETECT_INTR_ENABLE (0x01)
-#define BMI160_LOW_G_INTR_STAT (0x01)
-#define BMI160_PULL_UP_DATA (0x30)
-#define BMI160_FIFO_M_G_A_ENABLE (0xE0)
-#define BMI160_FIFO_M_G_ENABLE (0xA0)
-#define BMI160_FIFO_M_A_ENABLE (0x60)
-#define BMI160_FIFO_G_A_ENABLE (0xC0)
-#define BMI160_FIFO_A_ENABLE (0x40)
-#define BMI160_FIFO_M_ENABLE (0x20)
-
-#define BMI160_SEC_IF_BMM150 (0)
-#define BMI160_SEC_IF_AKM09911 (1)
-#define BMI160_SEC_IF_AKM09912 (2)
-#define BMI160_SEC_IF_YAS532 (3)
-#define BMI160_SEC_IF_YAS537 (4)
-/**************************************************/
-/**\name MAG INIT DEFINITION */
-/*************************************************/
-#define BMI160_COMMAND_REG_ONE (0x37)
-#define BMI160_COMMAND_REG_TWO (0x9A)
-#define BMI160_COMMAND_REG_THREE (0xC0)
-#define RESET_STEP_COUNTER (0xB2)
-/**************************************************/
-/**\name BIT SLICE GET AND SET FUNCTIONS */
-/*************************************************/
-#define BMI160_GET_BITSLICE(regvar, bitname)\
- ((regvar & bitname##__MSK) >> bitname##__POS)
-
-
-#define BMI160_SET_BITSLICE(regvar, bitname, val)\
- ((regvar & ~bitname##__MSK) | \
- ((val<<bitname##__POS)&bitname##__MSK))
-
-/**************************************************/
-/**\name FUNCTION DECLARATIONS */
-/*************************************************/
-/**************************************************/
-/**\name FUNCTION FOR BMI160 INITIALIZE */
-/*************************************************/
-/*!
- * @brief
- * This function is used for initialize
- * bus read and bus write functions
- * assign the chip id and device address
- * chip id is read in the register 0x00 bit from 0 to 7
- *
- * @param bmi160 : structure pointer
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- * @note
- * While changing the parameter of the bmi160_t
- * consider the following point:
- * Changing the reference value of the parameter
- * will changes the local copy or local reference
- * make sure your changes will not
- * affect the reference value of the parameter
- * (Better case don't change the reference value of the parameter)
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_init(struct bmi160_t *bmi160);
-/**************************************************/
-/**\name FUNCTION FOR READ AND WRITE REGISTERS */
-/*************************************************/
-/*!
- * @brief
- * This API write the data to
- * the given register
- *
- *
- * @param v_addr_u8 -> Address of the register
- * @param v_data_u8 -> The data from the register
- * @param v_len_u8 -> no of bytes to read
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_write_reg(u8 v_addr_u8,
-u8 *v_data_u8, u8 v_len_u8);
-/*!
- * @brief
- * This API reads the data from
- * the given register
- *
- *
- * @param v_addr_u8 -> Address of the register
- * @param v_data_u8 -> The data from the register
- * @param v_len_u8 -> no of bytes to read
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_reg(u8 v_addr_u8,
-u8 *v_data_u8, u8 v_len_u8);
-/**************************************************/
-/**\name FUNCTION FOR ERROR CODES */
-/*************************************************/
-/*!
- * @brief This API used to reads the fatal error
- * from the Register 0x02 bit 0
- * This flag will be reset only by power-on-reset and soft reset
- *
- *
- * @param v_fatal_err_u8 : The status of fatal error
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fatal_err(u8
-*v_fatal_err_u8);
-/*!
- * @brief This API used to read the error code
- * from register 0x02 bit 1 to 4
- *
- *
- * @param v_err_code_u8 : The status of error codes
- * error_code | description
- * ------------|---------------
- * 0x00 |no error
- * 0x01 |ACC_CONF error (accel ODR and bandwidth not compatible)
- * 0x02 |GYR_CONF error (Gyroscope ODR and bandwidth not compatible)
- * 0x03 |Under sampling mode and interrupt uses pre filtered data
- * 0x04 |reserved
- * 0x05 |Selected trigger-readout offset in
- * - |MAG_IF greater than selected ODR
- * 0x06 |FIFO configuration error for header less mode
- * 0x07 |Under sampling mode and pre filtered data as FIFO source
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_err_code(u8
-*v_error_code_u8);
-/*!
- * @brief This API Reads the i2c error code from the
- * Register 0x02 bit 5.
- * This error occurred in I2C master detected
- *
- * @param v_i2c_err_code_u8 : The status of i2c fail error
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_fail_err(u8
-*v_i2c_error_code_u8);
- /*!
- * @brief This API Reads the dropped command error
- * from the register 0x02 bit 6
- *
- *
- * @param v_drop_cmd_err_u8 : The status of drop command error
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_drop_cmd_err(u8
-*v_drop_cmd_err_u8);
-/*!
- * @brief This API reads the magnetometer data ready
- * interrupt not active.
- * It reads from the error register 0x0x2 bit 7
- *
- *
- *
- *
- * @param v_mag_data_rdy_err_u8 : The status of mag data ready interrupt
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_dada_rdy_err(u8
-*v_mag_data_rdy_err_u8);
-/*!
- * @brief This API reads the error status
- * from the error register 0x02 bit 0 to 7
- *
- * @param v_mag_data_rdy_err_u8 : The status of mag data ready interrupt
- * @param v_fatal_er_u8r : The status of fatal error
- * @param v_err_code_u8 : The status of error code
- * @param v_i2c_fail_err_u8 : The status of I2C fail error
- * @param v_drop_cmd_err_u8 : The status of drop command error
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_error_status(u8 *v_fatal_er_u8r,
-u8 *v_err_code_u8, u8 *v_i2c_fail_err_u8,
-u8 *v_drop_cmd_err_u8, u8 *v_mag_data_rdy_err_u8);
-/******************************************************************/
-/**\name FUNCTIONS FOR MAG,ACCEL AND GYRO POWER MODE STATUS */
-/*****************************************************************/
-/*!
- * @brief This API reads the magnetometer power mode from
- * PMU status register 0x03 bit 0 and 1
- *
- * @param v_mag_power_mode_stat_u8 : The value of mag power mode
- * mag_powermode | value
- * ------------------|----------
- * SUSPEND | 0x00
- * NORMAL | 0x01
- * LOW POWER | 0x02
- *
- *
- * @note The power mode of mag set by the 0x7E command register
- * @note using the function "bmi160_set_command_register()"
- * value | mode
- * ---------|----------------
- * 0x18 | MAG_MODE_SUSPEND
- * 0x19 | MAG_MODE_NORMAL
- * 0x1A | MAG_MODE_LOWPOWER
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_power_mode_stat(u8
-*v_mag_power_mode_stat_u8);
-/*!
- * @brief This API reads the gyroscope power mode from
- * PMU status register 0x03 bit 2 and 3
- *
- * @param v_gyro_power_mode_stat_u8 : The value of gyro power mode
- * gyro_powermode | value
- * ------------------|----------
- * SUSPEND | 0x00
- * NORMAL | 0x01
- * FAST POWER UP | 0x03
- *
- * @note The power mode of gyro set by the 0x7E command register
- * @note using the function "bmi160_set_command_register()"
- * value | mode
- * ---------|----------------
- * 0x14 | GYRO_MODE_SUSPEND
- * 0x15 | GYRO_MODE_NORMAL
- * 0x17 | GYRO_MODE_FASTSTARTUP
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_power_mode_stat(u8
-*v_gyro_power_mode_stat_u8);
-/*!
- * @brief This API reads the accelerometer power mode from
- * PMU status register 0x03 bit 4 and 5
- *
- *
- * @param v_accel_power_mode_stat_u8 : The value of accel power mode
- * accel_powermode | value
- * ------------------|----------
- * SUSPEND | 0x00
- * NORMAL | 0x01
- * LOW POWER | 0x03
- *
- * @note The power mode of accel set by the 0x7E command register
- * @note using the function "bmi160_set_command_register()"
- * value | mode
- * ---------|----------------
- * 0x11 | ACCEL_MODE_NORMAL
- * 0x12 | ACCEL_LOWPOWER
- * 0x10 | ACCEL_SUSPEND
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_power_mode_stat(u8
-*v_accel_power_mode_stat_u8);
-/*!
- * @brief This API switch mag interface to normal mode
- * and confirm whether the mode switching done successfully or not
-*
- * @return results of bus communication function and current MAG_PMU result
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_interface_normal(void);
-/**************************************************/
-/**\name FUNCTION FOR Mag XYZ data read */
-/*************************************************/
-/*!
- * @brief This API reads magnetometer data X values
- * from the register 0x04 and 0x05
- * @brief The mag sensor data read form auxiliary mag
- *
- * @param v_mag_x_s16 : The value of mag x
- * @param v_sensor_select_u8 : Mag selection value
- * value | sensor
- * ---------|----------------
- * 0 | BMM150
- * 1 | AKM09911 or AKM09912
- *
- * @note For mag data output rate configuration use the following function
- * @note bmi160_set_mag_output_data_rate()
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_x(s16 *v_mag_x_s16,
-u8 v_sensor_select_u8);
-/*!
- * @brief This API reads magnetometer data Y values
- * from the register 0x06 and 0x07
- * @brief The mag sensor data read form auxiliary mag
- *
- * @param v_mag_y_s16 : The value of mag y
- * @param v_sensor_select_u8 : Mag selection value
- * value | sensor
- * ---------|----------------
- * 0 | BMM150
- * 1 | AKM09911 or AKM09912
- *
- * @note For mag data output rate configuration use the following function
- * @note bmi160_set_mag_output_data_rate()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_y(s16 *v_mag_y_s16,
-u8 v_sensor_select_u8);
-/*!
- * @brief This API reads magnetometer data Z values
- * from the register 0x08 and 0x09
- * @brief The mag sensor data read form auxiliary mag
- *
- * @param v_mag_z_s16 : The value of mag z
- * @param v_sensor_select_u8 : Mag selection value
- * value | sensor
- * ---------|----------------
- * 0 | BMM150
- * 1 | AKM09911 or AKM09912
- *
- * @note For mag data output rate configuration use the following function
- * @note bmi160_set_mag_output_data_rate()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_z(s16 *v_mag_z_s16,
-u8 v_sensor_select_u8);
-/*!
- * @brief This API reads magnetometer data RHALL values
- * from the register 0x0A and 0x0B
- *
- *
- * @param v_mag_r_s16 : The value of BMM150 r data
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_r(
-s16 *v_mag_r_s16);
-/*!
- * @brief This API reads magnetometer data X,Y,Z values
- * from the register 0x04 to 0x09
- *
- * @brief The mag sensor data read form auxiliary mag
- *
- * @param mag : The value of mag xyz data
- * @param v_sensor_select_u8 : Mag selection value
- * value | sensor
- * ---------|----------------
- * 0 | BMM150
- * 1 | AKM09911 or AKM09912
- *
- * @note For mag data output rate configuration use the following function
- * @note bmi160_set_mag_output_data_rate()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_xyz(
-struct bmi160_mag_t *mag, u8 v_sensor_select_u8);
- /*!*
- * @brief This API reads magnetometer data X,Y,Z,r
- * values from the register 0x04 to 0x0B
- *
- * @brief The mag sensor data read form auxiliary mag
- *
- * @param mag : The value of mag-BMM150 xyzr data
- *
- * @note For mag data output rate configuration use the following function
- * @note bmi160_set_mag_output_data_rate()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_mag_xyzr(
-struct bmi160_mag_xyzr_t *mag);
-/**************************************************/
-/**\name FUNCTION FOR GYRO XYZ DATA READ */
-/*************************************************/
-/*!
- * @brief This API reads gyro data X values
- * form the register 0x0C and 0x0D
- *
- *
- *
- *
- * @param v_gyro_x_s16 : The value of gyro x data
- *
- * @note Gyro Configuration use the following function
- * @note bmi160_set_gyro_output_data_rate()
- * @note bmi160_set_gyro_bw()
- * @note bmi160_set_gyro_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_x(
-s16 *v_gyro_x_s16);
-/*!
- * @brief This API reads gyro data Y values
- * form the register 0x0E and 0x0F
- *
- *
- *
- *
- * @param v_gyro_y_s16 : The value of gyro y data
- *
- * @note Gyro Configuration use the following function
- * @note bmi160_set_gyro_output_data_rate()
- * @note bmi160_set_gyro_bw()
- * @note bmi160_set_gyro_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error result of communication routines
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_y(
-s16 *v_gyro_y_s16);
-/*!
- * @brief This API reads gyro data Z values
- * form the register 0x10 and 0x11
- *
- *
- *
- *
- * @param v_gyro_z_s16 : The value of gyro z data
- *
- * @note Gyro Configuration use the following function
- * @note bmi160_set_gyro_output_data_rate()
- * @note bmi160_set_gyro_bw()
- * @note bmi160_set_gyro_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_z(
-s16 *v_gyro_z_s16);
-/*!
- * @brief This API reads gyro data X,Y,Z values
- * from the register 0x0C to 0x11
- *
- *
- *
- *
- * @param gyro : The value of gyro xyz
- *
- * @note Gyro Configuration use the following function
- * @note bmi160_set_gyro_output_data_rate()
- * @note bmi160_set_gyro_bw()
- * @note bmi160_set_gyro_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_gyro_xyz(
-struct bmi160_gyro_t *gyro);
-/**************************************************/
-/**\name FUNCTION FOR ACCEL XYZ DATA READ */
-/*************************************************/
-/*!
- * @brief This API reads accelerometer data X values
- * form the register 0x12 and 0x13
- *
- *
- *
- *
- * @param v_accel_x_s16 : The value of accel x
- *
- * @note For accel configuration use the following functions
- * @note bmi160_set_accel_output_data_rate()
- * @note bmi160_set_accel_bw()
- * @note bmi160_set_accel_under_sampling_parameter()
- * @note bmi160_set_accel_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_x(
-s16 *v_accel_x_s16);
-/*!
- * @brief This API reads accelerometer data Y values
- * form the register 0x14 and 0x15
- *
- *
- *
- *
- * @param v_accel_y_s16 : The value of accel y
- *
- * @note For accel configuration use the following functions
- * @note bmi160_set_accel_output_data_rate()
- * @note bmi160_set_accel_bw()
- * @note bmi160_set_accel_under_sampling_parameter()
- * @note bmi160_set_accel_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_y(
-s16 *v_accel_y_s16);
-/*!
- * @brief This API reads accelerometer data Z values
- * form the register 0x16 and 0x17
- *
- *
- *
- *
- * @param v_accel_z_s16 : The value of accel z
- *
- * @note For accel configuration use the following functions
- * @note bmi160_set_accel_output_data_rate()
- * @note bmi160_set_accel_bw()
- * @note bmi160_set_accel_under_sampling_parameter()
- * @note bmi160_set_accel_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_z(
-s16 *v_accel_z_s16);
-/*!
- * @brief This API reads accelerometer data X,Y,Z values
- * from the register 0x12 to 0x17
- *
- *
- *
- *
- * @param accel :The value of accel xyz
- *
- * @note For accel configuration use the following functions
- * @note bmi160_set_accel_output_data_rate()
- * @note bmi160_set_accel_bw()
- * @note bmi160_set_accel_under_sampling_parameter()
- * @note bmi160_set_accel_range()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_accel_xyz(
-struct bmi160_accel_t *accel);
-/**************************************************/
-/**\name FUNCTION FOR SENSOR TIME */
-/*************************************************/
-/*!
- * @brief This API reads sensor_time from the register
- * 0x18 to 0x1A
- *
- *
- * @param v_sensor_time_u32 : The value of sensor time
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_sensor_time(
-u32 *v_sensor_time_u32);
-/**************************************************/
-/**\name FUNCTION FOR GYRO SLEF TEST */
-/*************************************************/
-/*!
- * @brief This API reads the Gyroscope self test
- * status from the register 0x1B bit 1
- *
- *
- * @param v_gyro_selftest_u8 : The value of gyro self test status
- * value | status
- * ---------|----------------
- * 0 | Gyroscope self test is running or failed
- * 1 | Gyroscope self test completed successfully
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_selftest(u8
-*v_gyro_selftest_u8);
-/**************************************************/
-/**\name FUNCTION FOR MANUAL INTERFACE */
-/*************************************************/
-/*!
- * @brief This API reads the status of
- * mag manual interface operation form the register 0x1B bit 2
- *
- *
- *
- * @param v_mag_manual_stat_u8 : The value of mag manual operation status
- * value | status
- * ---------|----------------
- * 0 | Indicates no manual magnetometer
- * - | interface operation is ongoing
- * 1 | Indicates manual magnetometer
- * - | interface operation is ongoing
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_manual_operation_stat(u8
-*v_mag_manual_stat_u8);
-/**************************************************/
-/**\name FUNCTION FOR FAST OFFSET READY */
-/*************************************************/
-/*!
- * @brief This API reads the fast offset compensation
- * status form the register 0x1B bit 3
- *
- *
- * @param v_foc_rdy_u8 : The status of fast compensation
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_rdy(u8
-*v_foc_rdy_u8);
-/**************************************************/
-/**\name FUNCTION FOR NVM READY */
-/*************************************************/
-/*!
- * @brief This API Reads the nvm_rdy status from the
- * resister 0x1B bit 4
- *
- *
- * @param v_nvm_rdy_u8 : The value of NVM ready status
- * value | status
- * ---------|----------------
- * 0 | NVM write operation in progress
- * 1 | NVM is ready to accept a new write trigger
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_nvm_rdy(u8
-*v_nvm_rdy_u8);
-/**************************************************/
-/**\name FUNCTION FOR DATA READY FOR MAG, GYRO, AND ACCEL */
-/*************************************************/
-/*!
- * @brief This API reads the status of mag data ready
- * from the register 0x1B bit 5
- * The status get reset when one mag data register is read out
- *
- * @param v_data_rdy_u8 : The value of mag data ready status
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_data_rdy_mag(u8
-*v_data_rdy_u8);
-/*!
- * @brief This API reads the status of gyro data ready form the
- * register 0x1B bit 6
- * The status get reset when gyro data register read out
- *
- *
- * @param v_data_rdy_u8 : The value of gyro data ready
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_data_rdy(u8
-*v_data_rdy_u8);
-/*!
- * @brief This API reads the status of accel data ready form the
- * register 0x1B bit 7
- * The status get reset when accel data register read out
- *
- *
- * @param v_data_rdy_u8 : The value of accel data ready status
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_data_rdy(u8
-*drdy_acc);
-/**************************************************/
-/**\name FUNCTION FOR STEP INTERRUPT STATUS */
-/*************************************************/
-/*!
- * @brief This API reads the step detector interrupt status
- * from the register 0x1C bit 0
- * flag is associated with a specific interrupt function.
- * It is set when the single tab interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt
- * signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_step_intr_u8 : The status of step detector interrupt
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_step_intr(u8
-*v_step_intr_u8);
-/**************************************************/
-/**\name FUNCTION FOR SIGNIFICANT INTERRUPT STATUS */
-/*************************************************/
-/*!
- * @brief This API reads the
- * significant motion interrupt status
- * from the register 0x1C bit 1
- * flag is associated with a specific interrupt function.
- * It is set when the single tab interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt
- * signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- *
- * @param v_significant_intr_u8 : The status of step
- * motion interrupt
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_significant_intr(u8
-*sigmot_intr);
-/**************************************************/
-/**\name FUNCTION FOR ANY MOTION INTERRUPT STATUS */
-/*************************************************/
- /*!
- * @brief This API reads the any motion interrupt status
- * from the register 0x1C bit 2
- * flag is associated with a specific interrupt function.
- * It is set when the single tab interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt
- * signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- * @param v_any_motion_intr_u8 : The status of any-motion interrupt
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_any_motion_intr(u8
-*v_any_motion_intr_u8);
-/**************************************************/
-/**\name FUNCTION FOR PMU TRIGGER INTERRUPT STATUS */
-/*************************************************/
-/*!
- * @brief This API reads the power mode trigger interrupt status
- * from the register 0x1C bit 3
- * flag is associated with a specific interrupt function.
- * It is set when the single tab interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt
- * signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- *
- * @param v_pmu_trigger_intr_u8 : The status of power mode trigger interrupt
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_pmu_trigger_intr(u8
-*v_pmu_trigger_intr_u8);
-/**************************************************/
-/**\name FUNCTION FOR DOUBLE TAB STATUS */
-/*************************************************/
-/*!
- * @brief This API reads the double tab status
- * from the register 0x1C bit 4
- * flag is associated with a specific interrupt function.
- * It is set when the single tab interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt
- * signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_double_tap_intr_u8 :The status of double tab interrupt
- *
- * @note Double tap interrupt can be configured by the following functions
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_double_tap()
- * @note AXIS MAPPING
- * @note bmi160_get_stat2_tap_first_x()
- * @note bmi160_get_stat2_tap_first_y()
- * @note bmi160_get_stat2_tap_first_z()
- * @note DURATION
- * @note bmi160_set_intr_tap_durn()
- * @note THRESHOLD
- * @note bmi160_set_intr_tap_thres()
- * @note TAP QUIET
- * @note bmi160_set_intr_tap_quiet()
- * @note TAP SHOCK
- * @note bmi160_set_intr_tap_shock()
- * @note TAP SOURCE
- * @note bmi160_set_intr_tap_source()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_double_tap_intr(u8
-*v_double_tap_intr_u8);
-/**************************************************/
-/**\name FUNCTION FOR SINGLE TAB STATUS */
-/*************************************************/
-/*!
- * @brief This API reads the single tab status
- * from the register 0x1C bit 5
- * flag is associated with a specific interrupt function.
- * It is set when the single tab interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt
- * signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_single_tap_intr_u8 :The status of single tap interrupt
- *
- * @note Single tap interrupt can be configured by the following functions
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_single_tap()
- * @note AXIS MAPPING
- * @note bmi160_get_stat2_tap_first_x()
- * @note bmi160_get_stat2_tap_first_y()
- * @note bmi160_get_stat2_tap_first_z()
- * @note DURATION
- * @note bmi160_set_intr_tap_durn()
- * @note THRESHOLD
- * @note bmi160_set_intr_tap_thres()
- * @note TAP QUIET
- * @note bmi160_set_intr_tap_quiet()
- * @note TAP SHOCK
- * @note bmi160_set_intr_tap_shock()
- * @note TAP SOURCE
- * @note bmi160_set_intr_tap_source()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_single_tap_intr(u8
-*v_single_tap_intr_u8);
-/**************************************************/
-/**\name FUNCTION FOR ORIENT INTERRUPT STATUS */
-/*************************************************/
-/*!
- * @brief This API reads the orient status
- * from the register 0x1C bit 6
- * flag is associated with a specific interrupt function.
- * It is set when the orient interrupt triggers. The
- * setting of INT_LATCH controls if the
- * interrupt signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_orient_intr_u8 : The status of orient interrupt
- *
- * @note For orient interrupt configuration use the following functions
- * @note STATUS
- * @note bmi160_get_stat0_orient_intr()
- * @note AXIS MAPPING
- * @note bmi160_get_stat3_orient_xy()
- * @note bmi160_get_stat3_orient_z()
- * @note bmi160_set_intr_orient_axes_enable()
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_orient()
- * @note INTERRUPT OUTPUT
- * @note bmi160_set_intr_orient_ud_enable()
- * @note THETA
- * @note bmi160_set_intr_orient_theta()
- * @note HYSTERESIS
- * @note bmi160_set_intr_orient_hyst()
- * @note BLOCKING
- * @note bmi160_set_intr_orient_blocking()
- * @note MODE
- * @note bmi160_set_intr_orient_mode()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_orient_intr(u8
-*v_orient_intr_u8);
-/**************************************************/
-/**\name FUNCTION FOR FLAT INTERRUPT STATUS */
-/*************************************************/
-/*!
- * @brief This API reads the flat interrupt status
- * from the register 0x1C bit 7
- * flag is associated with a specific interrupt function.
- * It is set when the flat interrupt triggers. The
- * setting of INT_LATCH controls if the
- * interrupt signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_flat_intr_u8 : The status of flat interrupt
- *
- * @note For flat configuration use the following functions
- * @note STATS
- * @note bmi160_get_stat0_flat_intr()
- * @note bmi160_get_stat3_flat()
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_flat()
- * @note THETA
- * @note bmi160_set_intr_flat_theta()
- * @note HOLD TIME
- * @note bmi160_set_intr_flat_hold()
- * @note HYSTERESIS
- * @note bmi160_set_intr_flat_hyst()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat0_flat_intr(u8
-*v_flat_intr_u8);
-/**************************************************/
-/**\name FUNCTION FOR HIGH_G INTERRUPT STATUS */
-/*************************************************/
-/*!
- * @brief This API reads the high_g interrupt status
- * from the register 0x1D bit 2
- * flag is associated with a specific interrupt function.
- * It is set when the high g interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt signal and hence the
- * respective interrupt flag will be permanently
- * latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_high_g_intr_u8 : The status of high_g interrupt
- *
- * @note High_g interrupt configured by following functions
- * @note STATUS
- * @note bmi160_get_stat1_high_g_intr()
- * @note AXIS MAPPING
- * @note bmi160_get_stat3_high_g_first_x()
- * @note bmi160_get_stat3_high_g_first_y()
- * @note bmi160_get_stat3_high_g_first_z()
- * @note SIGN MAPPING
- * @note bmi160_get_stat3_high_g_first_sign()
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_high_g()
- * @note HYSTERESIS
- * @note bmi160_set_intr_high_g_hyst()
- * @note DURATION
- * @note bmi160_set_intr_high_g_durn()
- * @note THRESHOLD
- * @note bmi160_set_intr_high_g_thres()
- * @note SOURCE
- * @note bmi160_set_intr_low_high_source()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_high_g_intr(u8
-*v_high_g_intr_u8);
-/**************************************************/
-/**\name FUNCTION FOR LOW_G INTERRUPT STATUS */
-/*************************************************/
-/*!
- * @brief This API reads the low g interrupt status
- * from the register 0x1D bit 3
- * flag is associated with a specific interrupt function.
- * It is set when the low g interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_low_g_intr_u8 : The status of low_g interrupt
- *
- * @note Low_g interrupt configured by following functions
- * @note STATUS
- * @note bmi160_get_stat1_low_g_intr()
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_low_g()
- * @note SOURCE
- * @note bmi160_set_intr_low_high_source()
- * @note DURATION
- * @note bmi160_set_intr_low_g_durn()
- * @note THRESHOLD
- * @note bmi160_set_intr_low_g_thres()
- * @note HYSTERESIS
- * @note bmi160_set_intr_low_g_hyst()
- * @note MODE
- * @note bmi160_set_intr_low_g_mode()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_low_g_intr(u8
-*v_low_g_intr_u8);
-/**************************************************/
-/**\name FUNCTION FOR DATA READY INTERRUPT STATUS */
-/*************************************************/
-/*!
- * @brief This API reads data ready interrupt status
- * from the register 0x1D bit 4
- * flag is associated with a specific interrupt function.
- * It is set when the data ready interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_data_rdy_intr_u8 : The status of data ready interrupt
- *
- * @note Data ready interrupt configured by following functions
- * @note STATUS
- * @note bmi160_get_stat1_data_rdy_intr()
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_data_rdy()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_data_rdy_intr(u8
-*v_data_rdy_intr_u8);
-/**************************************************/
-/**\name FUNCTIONS FOR FIFO FULL AND WATER MARK INTERRUPT STATUS*/
-/*************************************************/
-/*!
- * @brief This API reads data ready FIFO full interrupt status
- * from the register 0x1D bit 5
- * flag is associated with a specific interrupt function.
- * It is set when the FIFO full interrupt triggers. The
- * setting of INT_LATCH controls if the
- * interrupt signal and hence the
- * respective interrupt flag will
- * be permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_fifo_full_intr_u8 : The status of fifo full interrupt
- *
- * @note FIFO full interrupt can be configured by following functions
- * @note bmi160_set_intr_fifo_full()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_fifo_full_intr(u8
-*v_fifo_full_intr_u8);
-/*!
- * @brief This API reads data
- * ready FIFO watermark interrupt status
- * from the register 0x1D bit 6
- * flag is associated with a specific interrupt function.
- * It is set when the FIFO watermark interrupt triggers. The
- * setting of INT_LATCH controls if the
- * interrupt signal and hence the
- * respective interrupt flag will be
- * permanently latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_fifo_wm_intr_u8 : The status of fifo water mark interrupt
- *
- * @note FIFO full interrupt can be configured by following functions
- * @note bmi160_set_intr_fifo_wm()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_fifo_wm_intr(u8
-*v_fifo_wm_intr_u8);
-/**************************************************/
-/**\name FUNCTIONS FOR NO MOTION INTERRUPT STATUS*/
-/*************************************************/
-/*!
- * @brief This API reads data ready no motion interrupt status
- * from the register 0x1D bit 7
- * flag is associated with a specific interrupt function.
- * It is set when the no motion interrupt triggers. The
- * setting of INT_LATCH controls if the interrupt signal and hence the
- * respective interrupt flag will be permanently
- * latched, temporarily latched
- * or not latched.
- *
- *
- *
- *
- * @param v_nomotion_intr_u8 : The status of no motion interrupt
- *
- * @note No motion interrupt can be configured by following function
- * @note STATUS
- * @note bmi160_get_stat1_nomotion_intr()
- * @note INTERRUPT MAPPING
- * @note bmi160_set_intr_nomotion()
- * @note DURATION
- * @note bmi160_set_intr_slow_no_motion_durn()
- * @note THRESHOLD
- * @note bmi160_set_intr_slow_no_motion_thres()
- * @note SLOW/NO MOTION SELECT
- * @note bmi160_set_intr_slow_no_motion_select()
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat1_nomotion_intr(u8
-*nomo_intr);
-/**************************************************/
-/**\name FUNCTIONS FOR ANY MOTION FIRST XYZ AND SIGN INTERRUPT STATUS*/
-/*************************************************/
-/*!
- * @brief This API reads the status of any motion first x
- * from the register 0x1E bit 0
- *
- *
- * @param v_anymotion_first_x_u8 : The status of any motion first x interrupt
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by x axis
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_x(u8
-*v_anymotion_first_x_u8);
-/*!
- * @brief This API reads the status of any motion first y interrupt
- * from the register 0x1E bit 1
- *
- *
- *
- *@param v_any_motion_first_y_u8 : The status of any motion first y interrupt
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_y(u8
-*v_any_motion_first_y_u8);
-/*!
- * @brief This API reads the status of any motion first z interrupt
- * from the register 0x1E bit 2
- *
- *
- *
- *
- *@param v_any_motion_first_z_u8 : The status of any motion first z interrupt
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_first_z(u8
-*v_any_motion_first_z_u8);
-/*!
- * @brief This API reads the any motion sign status from the
- * register 0x1E bit 3
- *
- *
- *
- *
- * @param v_anymotion_sign_u8 : The status of any motion sign
- * value | sign
- * -----------|-------------
- * 0 | positive
- * 1 | negative
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_any_motion_sign(u8
-*v_anymotion_sign_u8);
-/**************************************************/
-/**\name FUNCTIONS FOR TAP FIRST XYZ AND SIGN INTERRUPT STATUS*/
-/*************************************************/
-/*!
- * @brief This API reads the any motion tap first x status from the
- * register 0x1E bit 4
- *
- *
- *
- *
- * @param v_tap_first_x_u8 :The status of any motion tap first x
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by x axis
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_x(u8
-*v_tap_first_x_u8);
-/*!
- * @brief This API reads the tap first y interrupt status from the
- * register 0x1E bit 5
- *
- *
- *
- *
- * @param v_tap_first_y_u8 :The status of tap first y interrupt
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_y(u8
-*v_tap_first_y_u8);
-/*!
- * @brief This API reads the tap first z interrupt status from the
- * register 0x1E bit 6
- *
- *
- *
- *
- * @param v_tap_first_z_u8 :The status of tap first z interrupt
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by z axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_first_z(u8
-*v_tap_first_z_u8);
-/*!
- * @brief This API reads the tap sign status from the
- * register 0x1E bit 7
- *
- *
- *
- *
- * @param v_tap_sign_u8 : The status of tap sign
- * value | sign
- * -----------|-------------
- * 0 | positive
- * 1 | negative
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat2_tap_sign(u8
-*tap_sign);
-/**************************************************/
-/**\name FUNCTIONS FOR HIGH_G FIRST XYZ AND SIGN INTERRUPT STATUS*/
-/*************************************************/
-/*!
- * @brief This API reads the high_g first x status from the
- * register 0x1F bit 0
- *
- *
- *
- *
- * @param v_high_g_first_x_u8 :The status of high_g first x
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by x axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_x(u8
-*v_high_g_first_x_u8);
-/*!
- * @brief This API reads the high_g first y status from the
- * register 0x1F bit 1
- *
- *
- *
- *
- * @param v_high_g_first_y_u8 : The status of high_g first y
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_y(u8
-*v_high_g_first_y_u8);
-/*!
- * @brief This API reads the high_g first z status from the
- * register 0x1F bit 3
- *
- *
- *
- *
- * @param v_high_g_first_z_u8 : The status of high_g first z
- * value | status
- * -----------|-------------
- * 0 | not triggered
- * 1 | triggered by z axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_first_z(u8
-*v_high_g_first_z_u8);
-/*!
- * @brief This API reads the high sign status from the
- * register 0x1F bit 3
- *
- *
- *
- *
- * @param v_high_g_sign_u8 :The status of high sign
- * value | sign
- * -----------|-------------
- * 0 | positive
- * 1 | negative
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_high_g_sign(u8
-*v_high_g_sign_u8);
-/**************************************************/
-/**\name FUNCTIONS FOR ORIENT XY AND Z INTERRUPT STATUS*/
-/*************************************************/
-/*!
- * @brief This API reads the status of orient_xy plane
- * from the register 0x1F bit 4 and 5
- *
- *
- * @param v_orient_xy_u8 :The status of orient_xy plane
- * value | status
- * -----------|-------------
- * 0x00 | portrait upright
- * 0x01 | portrait upside down
- * 0x02 | landscape left
- * 0x03 | landscape right
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_orient_xy(u8
-*v_orient_xy_u8);
-/*!
- * @brief This API reads the status of orient z plane
- * from the register 0x1F bit 6
- *
- *
- * @param v_orient_z_u8 :The status of orient z
- * value | status
- * -----------|-------------
- * 0x00 | upward looking
- * 0x01 | downward looking
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_orient_z(u8
-*v_orient_z_u8);
-/**************************************************/
-/**\name FUNCTIONS FOR FLAT INTERRUPT STATUS*/
-/*************************************************/
-/*!
- * @brief This API reads the flat status from the register
- * 0x1F bit 7
- *
- *
- * @param v_flat_u8 : The status of flat interrupt
- * value | status
- * -----------|-------------
- * 0x00 | non flat
- * 0x01 | flat position
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_stat3_flat(u8
-*flat);
-/**************************************************/
-/**\name FUNCTION FOR TEMPERATUE READ */
-/*************************************************/
-/*!
- * @brief This API reads the temperature of the sensor
- * from the register 0x21 bit 0 to 7
- *
- *
- *
- * @param v_temp_s16 : The value of temperature
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_temp(s16
-*v_temp_s16);
-/**************************************************/
-/**\name FUNCTION FOR FIFO LENGTH AND FIFO DATA READ */
-/*************************************************/
-/*!
- * @brief This API reads the of the sensor
- * form the register 0x23 and 0x24 bit 0 to 7 and 0 to 2
- * @brief this byte counter is updated each time a complete frame
- * was read or writtern
- *
- *
- * @param v_fifo_length_u32 : The value of fifo byte counter
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_fifo_length(
-u32 *v_fifo_length_u32);
-/*!
- * @brief This API reads the fifo data of the sensor
- * from the register 0x24
- * @brief Data format depends on the setting of register FIFO_CONFIG
- *
- *
- *
- * @param v_fifodata_u8 : Pointer holding the fifo data
- * @param v_fifo_length_u16 : The value of fifo length maximum
- * 1024
- *
- * @note For reading FIFO data use the following functions
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_fifo_data(
-u8 *v_fifodata_u8, u16 v_fifo_length_u16);
-/**************************************************/
-/**\name FUNCTION FOR ACCEL CONFIGURATIONS */
-/*************************************************/
-/*!
- * @brief This API is used to get the
- * accel output date rate form the register 0x40 bit 0 to 3
- *
- *
- * @param v_output_data_rate_u8 :The value of accel output date rate
- * value | output data rate
- * -------|--------------------------
- * 0 | BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED
- * 1 | BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
- * 2 | BMI160_ACCEL_OUTPUT_DATA_RATE_1_56HZ
- * 3 | BMI160_ACCEL_OUTPUT_DATA_RATE_3_12HZ
- * 4 | BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ
- * 5 | BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ
- * 6 | BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ
- * 7 | BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ
- * 8 | BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ
- * 9 | BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ
- * 10 | BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ
- * 11 | BMI160_ACCEL_OUTPUT_DATA_RATE_800HZ
- * 12 | BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_output_data_rate(
-u8 *v_output_data_rate_u8);
-/*!
- * @brief This API is used to set the
- * accel output date rate form the register 0x40 bit 0 to 3
- *
- *
- * @param v_output_data_rate_u8 :The value of accel output date rate
- * value | output data rate
- * -------|--------------------------
- * 0 | BMI160_ACCEL_OUTPUT_DATA_RATE_RESERVED
- * 1 | BMI160_ACCEL_OUTPUT_DATA_RATE_0_78HZ
- * 2 | BMI160_ACCEL_OUTPUT_DATA_RATE_1_56HZ
- * 3 | BMI160_ACCEL_OUTPUT_DATA_RATE_3_12HZ
- * 4 | BMI160_ACCEL_OUTPUT_DATA_RATE_6_25HZ
- * 5 | BMI160_ACCEL_OUTPUT_DATA_RATE_12_5HZ
- * 6 | BMI160_ACCEL_OUTPUT_DATA_RATE_25HZ
- * 7 | BMI160_ACCEL_OUTPUT_DATA_RATE_50HZ
- * 8 | BMI160_ACCEL_OUTPUT_DATA_RATE_100HZ
- * 9 | BMI160_ACCEL_OUTPUT_DATA_RATE_200HZ
- * 10 | BMI160_ACCEL_OUTPUT_DATA_RATE_400HZ
- * 11 | BMI160_ACCEL_OUTPUT_DATA_RATE_800HZ
- * 12 | BMI160_ACCEL_OUTPUT_DATA_RATE_1600HZ
- *
- * @param v_accel_bw_u8 :The value of accel selected accel bandwidth
- * value | output data rate
- * -------|--------------------------
- * 0 | BMI160_ACCEL_OSR4_AVG1
- * 1 | BMI160_ACCEL_OSR2_AVG2
- * 2 | BMI160_ACCEL_NORMAL_AVG4
- * 3 | BMI160_ACCEL_CIC_AVG8
- * 4 | BMI160_ACCEL_RES_AVG2
- * 5 | BMI160_ACCEL_RES_AVG4
- * 6 | BMI160_ACCEL_RES_AVG8
- * 7 | BMI160_ACCEL_RES_AVG16
- * 8 | BMI160_ACCEL_RES_AVG32
- * 9 | BMI160_ACCEL_RES_AVG64
- * 10 | BMI160_ACCEL_RES_AVG128
- *
- *
- *
- * @note Verify the accel bandwidth before seting the
- * output data rate
- * bandwidth | output data rate | under sampling
- *-------------|------------------|----------------
- * OSR4 | 12.5 TO 1600 | 0
- * OSR2 | 12.5 TO 1600 | 0
- * NORMAL | 12.5 TO 1600 | 0
- * CIC | 12.5 TO 1600 | 0
- * AVG2 | 0.78 TO 400 | 1
- * AVG4 | 0.78 TO 200 | 1
- * AVG8 | 0.78 TO 100 | 1
- * AVG16 | 0.78 TO 50 | 1
- * AVG32 | 0.78 TO 25 | 1
- * AVG64 | 0.78 TO 12.5 | 1
- * AVG128 | 0.78 TO 6.25 | 1
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_output_data_rate(
-u8 v_output_data_rate_u8, u8 v_accel_bw_u8);
-/*!
- * @brief This API is used to get the
- * accel bandwidth from the register 0x40 bit 4 to 6
- * @brief bandwidth parameter determines filter configuration(acc_us=0)
- * and averaging for under sampling mode(acc_us=1)
- *
- *
- * @param v_bw_u8 : The value of accel bandwidth
- *
- * @note accel bandwidth depends on under sampling parameter
- * @note under sampling parameter cab be set by the function
- * "BMI160_SET_ACCEL_UNDER_SAMPLING_PARAMETER"
- *
- * @note Filter configuration
- * accel_us | Filter configuration
- * -----------|---------------------
- * 0x00 | OSR4 mode
- * 0x01 | OSR2 mode
- * 0x02 | normal mode
- * 0x03 | CIC mode
- * 0x04 | Reserved
- * 0x05 | Reserved
- * 0x06 | Reserved
- * 0x07 | Reserved
- *
- * @note accel under sampling mode
- * accel_us | Under sampling mode
- * -----------|---------------------
- * 0x00 | no averaging
- * 0x01 | average 2 samples
- * 0x02 | average 4 samples
- * 0x03 | average 8 samples
- * 0x04 | average 16 samples
- * 0x05 | average 32 samples
- * 0x06 | average 64 samples
- * 0x07 | average 128 samples
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_bw(u8 *v_bw_u8);
-/*!
- * @brief This API is used to set the
- * accel bandwidth from the register 0x40 bit 4 to 6
- * @brief bandwidth parameter determines filter configuration(acc_us=0)
- * and averaging for under sampling mode(acc_us=1)
- *
- *
- * @param v_bw_u8 : The value of accel bandwidth
- *
- * @note accel bandwidth depends on under sampling parameter
- * @note under sampling parameter cab be set by the function
- * "BMI160_SET_ACCEL_UNDER_SAMPLING_PARAMETER"
- *
- * @note Filter configuration
- * accel_us | Filter configuration
- * -----------|---------------------
- * 0x00 | OSR4 mode
- * 0x01 | OSR2 mode
- * 0x02 | normal mode
- * 0x03 | CIC mode
- * 0x04 | Reserved
- * 0x05 | Reserved
- * 0x06 | Reserved
- * 0x07 | Reserved
- *
- * @note accel under sampling mode
- * accel_us | Under sampling mode
- * -----------|---------------------
- * 0x00 | no averaging
- * 0x01 | average 2 samples
- * 0x02 | average 4 samples
- * 0x03 | average 8 samples
- * 0x04 | average 16 samples
- * 0x05 | average 32 samples
- * 0x06 | average 64 samples
- * 0x07 | average 128 samples
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_bw(u8 v_bw_u8);
-/*!
- * @brief This API is used to get the accel
- * under sampling parameter form the register 0x40 bit 7
- *
- *
- *
- *
- * @param v_accel_under_sampling_u8 : The value of accel under sampling
- * value | under_sampling
- * ----------|---------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_under_sampling_parameter(
-u8 *v_accel_under_sampling_u8);
-/*!
- * @brief This API is used to set the accel
- * under sampling parameter form the register 0x40 bit 7
- *
- *
- *
- *
- * @param v_accel_under_sampling_u8 : The value of accel under sampling
- * value | under_sampling
- * ----------|---------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_under_sampling_parameter(
-u8 v_accel_under_sampling_u8);
-/*!
- * @brief This API is used to get the ranges
- * (g values) of the accel from the register 0x41 bit 0 to 3
- *
- *
- *
- *
- * @param v_range_u8 : The value of accel g range
- * value | g_range
- * ----------|-----------
- * 0x03 | BMI160_ACCEL_RANGE_2G
- * 0x05 | BMI160_ACCEL_RANGE_4G
- * 0x08 | BMI160_ACCEL_RANGE_8G
- * 0x0C | BMI160_ACCEL_RANGE_16G
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_range(
-u8 *v_range_u8);
-/*!
- * @brief This API is used to set the ranges
- * (g values) of the accel from the register 0x41 bit 0 to 3
- *
- *
- *
- *
- * @param v_range_u8 : The value of accel g range
- * value | g_range
- * ----------|-----------
- * 0x03 | BMI160_ACCEL_RANGE_2G
- * 0x05 | BMI160_ACCEL_RANGE_4G
- * 0x08 | BMI160_ACCEL_RANGE_8G
- * 0x0C | BMI160_ACCEL_RANGE_16G
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_range(
-u8 v_range_u8);
-/**************************************************/
-/**\name FUNCTION FOR GYRO CONFIGURATIONS */
-/*************************************************/
-/*!
- * @brief This API is used to get the
- * gyroscope output data rate from the register 0x42 bit 0 to 3
- *
- *
- *
- *
- * @param v_output_data_rate_u8 :The value of gyro output data rate
- * value | gyro output data rate
- * -----------|-----------------------------
- * 0x00 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x01 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x02 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x03 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x04 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x05 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x06 | BMI160_GYRO_OUTPUT_DATA_RATE_25HZ
- * 0x07 | BMI160_GYRO_OUTPUT_DATA_RATE_50HZ
- * 0x08 | BMI160_GYRO_OUTPUT_DATA_RATE_100HZ
- * 0x09 | BMI160_GYRO_OUTPUT_DATA_RATE_200HZ
- * 0x0A | BMI160_GYRO_OUTPUT_DATA_RATE_400HZ
- * 0x0B | BMI160_GYRO_OUTPUT_DATA_RATE_800HZ
- * 0x0C | BMI160_GYRO_OUTPUT_DATA_RATE_1600HZ
- * 0x0D | BMI160_GYRO_OUTPUT_DATA_RATE_3200HZ
- * 0x0E | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x0F | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_output_data_rate(
-u8 *gyro_output_typer);
-/*!
- * @brief This API is used to set the
- * gyroscope output data rate from the register 0x42 bit 0 to 3
- *
- *
- *
- *
- * @param v_output_data_rate_u8 :The value of gyro output data rate
- * value | gyro output data rate
- * -----------|-----------------------------
- * 0x00 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x01 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x02 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x03 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x04 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x05 | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x06 | BMI160_GYRO_OUTPUT_DATA_RATE_25HZ
- * 0x07 | BMI160_GYRO_OUTPUT_DATA_RATE_50HZ
- * 0x08 | BMI160_GYRO_OUTPUT_DATA_RATE_100HZ
- * 0x09 | BMI160_GYRO_OUTPUT_DATA_RATE_200HZ
- * 0x0A | BMI160_GYRO_OUTPUT_DATA_RATE_400HZ
- * 0x0B | BMI160_GYRO_OUTPUT_DATA_RATE_800HZ
- * 0x0C | BMI160_GYRO_OUTPUT_DATA_RATE_1600HZ
- * 0x0D | BMI160_GYRO_OUTPUT_DATA_RATE_3200HZ
- * 0x0E | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- * 0x0F | BMI160_GYRO_OUTPUT_DATA_RATE_RESERVED
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_output_data_rate(
-u8 gyro_output_typer);
-/*!
- * @brief This API is used to get the
- * data of gyro from the register 0x42 bit 4 to 5
- *
- *
- *
- *
- * @param v_bw_u8 : The value of gyro bandwidth
- * value | gyro bandwidth
- * ----------|----------------
- * 0x00 | BMI160_GYRO_OSR4_MODE
- * 0x01 | BMI160_GYRO_OSR2_MODE
- * 0x02 | BMI160_GYRO_NORMAL_MODE
- * 0x03 | BMI160_GYRO_CIC_MODE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_bw(u8 *v_bw_u8);
-/*!
- * @brief This API is used to set the
- * data of gyro from the register 0x42 bit 4 to 5
- *
- *
- *
- *
- * @param v_bw_u8 : The value of gyro bandwidth
- * value | gyro bandwidth
- * ----------|----------------
- * 0x00 | BMI160_GYRO_OSR4_MODE
- * 0x01 | BMI160_GYRO_OSR2_MODE
- * 0x02 | BMI160_GYRO_NORMAL_MODE
- * 0x03 | BMI160_GYRO_CIC_MODE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_bw(u8 v_bw_u8);
-/*!
- * @brief This API reads the range
- * of gyro from the register 0x43 bit 0 to 2
- *
- * @param v_range_u8 : The value of gyro range
- * value | range
- * ----------|-------------------------------
- * 0x00 | BMI160_GYRO_RANGE_2000_DEG_SEC
- * 0x01 | BMI160_GYRO_RANGE_1000_DEG_SEC
- * 0x02 | BMI160_GYRO_RANGE_500_DEG_SEC
- * 0x03 | BMI160_GYRO_RANGE_250_DEG_SEC
- * 0x04 | BMI160_GYRO_RANGE_125_DEG_SEC
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_range(
-u8 *v_range_u8);
-/*!
- * @brief This API set the range
- * of gyro from the register 0x43 bit 0 to 2
- *
- * @param v_range_u8 : The value of gyro range
- * value | range
- * ----------|-------------------------------
- * 0x00 | BMI160_GYRO_RANGE_2000_DEG_SEC
- * 0x01 | BMI160_GYRO_RANGE_1000_DEG_SEC
- * 0x02 | BMI160_GYRO_RANGE_500_DEG_SEC
- * 0x03 | BMI160_GYRO_RANGE_250_DEG_SEC
- * 0x04 | BMI160_GYRO_RANGE_125_DEG_SEC
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_range(
-u8 v_range_u8);
-/**************************************************/
-/**\name FUNCTION FOR MAG CONFIGURATIONS */
-/*************************************************/
-/*!
- * @brief This API is used to get the
- * output data rate of magnetometer from the register 0x44 bit 0 to 3
- *
- *
- *
- *
- * @param v_output_data_rat_u8e : The value of mag output data rate
- * value | mag output data rate
- * ---------|---------------------------
- * 0x00 |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED
- * 0x01 |BMI160_MAG_OUTPUT_DATA_RATE_0_78HZ
- * 0x02 |BMI160_MAG_OUTPUT_DATA_RATE_1_56HZ
- * 0x03 |BMI160_MAG_OUTPUT_DATA_RATE_3_12HZ
- * 0x04 |BMI160_MAG_OUTPUT_DATA_RATE_6_25HZ
- * 0x05 |BMI160_MAG_OUTPUT_DATA_RATE_12_5HZ
- * 0x06 |BMI160_MAG_OUTPUT_DATA_RATE_25HZ
- * 0x07 |BMI160_MAG_OUTPUT_DATA_RATE_50HZ
- * 0x08 |BMI160_MAG_OUTPUT_DATA_RATE_100HZ
- * 0x09 |BMI160_MAG_OUTPUT_DATA_RATE_200HZ
- * 0x0A |BMI160_MAG_OUTPUT_DATA_RATE_400HZ
- * 0x0B |BMI160_MAG_OUTPUT_DATA_RATE_800HZ
- * 0x0C |BMI160_MAG_OUTPUT_DATA_RATE_1600HZ
- * 0x0D |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED0
- * 0x0E |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED1
- * 0x0F |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED2
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_output_data_rate(u8 *odr);
-/*!
- * @brief This API is used to set the
- * output data rate of magnetometer from the register 0x44 bit 0 to 3
- *
- *
- *
- *
- * @param v_output_data_rat_u8e : The value of mag output data rate
- * value | mag output data rate
- * ---------|---------------------------
- * 0x00 |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED
- * 0x01 |BMI160_MAG_OUTPUT_DATA_RATE_0_78HZ
- * 0x02 |BMI160_MAG_OUTPUT_DATA_RATE_1_56HZ
- * 0x03 |BMI160_MAG_OUTPUT_DATA_RATE_3_12HZ
- * 0x04 |BMI160_MAG_OUTPUT_DATA_RATE_6_25HZ
- * 0x05 |BMI160_MAG_OUTPUT_DATA_RATE_12_5HZ
- * 0x06 |BMI160_MAG_OUTPUT_DATA_RATE_25HZ
- * 0x07 |BMI160_MAG_OUTPUT_DATA_RATE_50HZ
- * 0x08 |BMI160_MAG_OUTPUT_DATA_RATE_100HZ
- * 0x09 |BMI160_MAG_OUTPUT_DATA_RATE_200HZ
- * 0x0A |BMI160_MAG_OUTPUT_DATA_RATE_400HZ
- * 0x0B |BMI160_MAG_OUTPUT_DATA_RATE_800HZ
- * 0x0C |BMI160_MAG_OUTPUT_DATA_RATE_1600HZ
- * 0x0D |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED0
- * 0x0E |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED1
- * 0x0F |BMI160_MAG_OUTPUT_DATA_RATE_RESERVED2
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_output_data_rate(u8 odr);
-/**************************************************/
-/**\name FUNCTION FOR FIFO CONFIGURATIONS */
-/*************************************************/
- /*!
- * @brief This API is used to read Down sampling
- * for gyro (2**downs_gyro) in the register 0x45 bit 0 to 2
- *
- *
- *
- *
- * @param v_fifo_down_gyro_u8 :The value of gyro fifo down
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_down_gyro(
-u8 *v_fifo_down_gyro_u8);
- /*!
- * @brief This API is used to set Down sampling
- * for gyro (2**downs_gyro) in the register 0x45 bit 0 to 2
- *
- *
- *
- *
- * @param v_fifo_down_gyro_u8 :The value of gyro fifo down
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_down_gyro(
-u8 v_fifo_down_gyro_u8);
-/*!
- * @brief This API is used to read gyro fifo filter data
- * from the register 0x45 bit 3
- *
- *
- *
- * @param v_gyro_fifo_filter_data_u8 :The value of gyro filter data
- * value | gyro_fifo_filter_data
- * ------------|-------------------------
- * 0x00 | Unfiltered data
- * 0x01 | Filtered data
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_fifo_filter_data(
-u8 *v_gyro_fifo_filter_data_u8);
-/*!
- * @brief This API is used to set gyro fifo filter data
- * from the register 0x45 bit 3
- *
- *
- *
- * @param v_gyro_fifo_filter_data_u8 :The value of gyro filter data
- * value | gyro_fifo_filter_data
- * ------------|-------------------------
- * 0x00 | Unfiltered data
- * 0x01 | Filtered data
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_fifo_filter_data(
-u8 v_gyro_fifo_filter_data_u8);
-/*!
- * @brief This API is used to read Down sampling
- * for accel (2*downs_accel) from the register 0x45 bit 4 to 6
- *
- *
- *
- *
- * @param v_fifo_down_u8 :The value of accel fifo down
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_down_accel(
-u8 *v_fifo_down_u8);
- /*!
- * @brief This API is used to set Down sampling
- * for accel (2*downs_accel) from the register 0x45 bit 4 to 6
- *
- *
- *
- *
- * @param v_fifo_down_u8 :The value of accel fifo down
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_down_accel(
-u8 v_fifo_down_u8);
-/*!
- * @brief This API is used to read accel fifo filter data
- * from the register 0x45 bit 7
- *
- *
- *
- * @param v_accel_fifo_filter_u8 :The value of accel filter data
- * value | accel_fifo_filter_data
- * ------------|-------------------------
- * 0x00 | Unfiltered data
- * 0x01 | Filtered data
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_fifo_filter_data(
-u8 *v_accel_fifo_filter_u8);
-/*!
- * @brief This API is used to set accel fifo filter data
- * from the register 0x45 bit 7
- *
- *
- *
- * @param v_accel_fifo_filter_u8 :The value of accel filter data
- * value | accel_fifo_filter_data
- * ------------|-------------------------
- * 0x00 | Unfiltered data
- * 0x01 | Filtered data
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_fifo_filter_data(
-u8 v_accel_fifo_filter_u8);
-/**************************************************/
-/**\name FUNCTION FOR FIFO WATER MARK ENABLE */
-/*************************************************/
-/*!
- * @brief This API is used to Trigger an interrupt
- * when FIFO contains water mark level from the register 0x46 bit 0 to 7
- *
- *
- *
- * @param v_fifo_wm_u8 : The value of fifo water mark level
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_wm(
-u8 *v_fifo_wm_u8);
-/*!
- * @brief This API is used to Trigger an interrupt
- * when FIFO contains water mark level from the register 0x46 bit 0 to 7
- *
- *
- *
- * @param v_fifo_wm_u8 : The value of fifo water mark level
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_wm(
-u8 v_fifo_wm_u8);
-/**************************************************/
-/**\name FUNCTION FOR FIFO CONFIGURATIONS */
-/*************************************************/
-/*!
- * @brief This API reads fifo sensor time
- * frame after the last valid data frame form the register 0x47 bit 1
- *
- *
- *
- *
- * @param v_fifo_time_enable_u8 : The value of sensor time
- * value | fifo sensor time
- * ------------|-------------------------
- * 0x00 | do not return sensortime frame
- * 0x01 | return sensortime frame
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_time_enable(
-u8 *v_fifo_time_enable_u8);
-/*!
- * @brief This API set fifo sensor time
- * frame after the last valid data frame form the register 0x47 bit 1
- *
- *
- *
- *
- * @param v_fifo_time_enable_u8 : The value of sensor time
- * value | fifo sensor time
- * ------------|-------------------------
- * 0x00 | do not return sensortime frame
- * 0x01 | return sensortime frame
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_time_enable(
-u8 v_fifo_time_enable_u8);
-/*!
- * @brief This API reads FIFO tag interrupt2 enable status
- * from the resister 0x47 bit 2
- *
- * @param v_fifo_tag_intr2_u8 : The value of fifo tag interrupt
- * value | fifo tag interrupt
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_tag_intr2_enable(
-u8 *v_fifo_tag_intr2_u8);
-/*!
- * @brief This API set FIFO tag interrupt2 enable status
- * from the resister 0x47 bit 2
- *
- * @param v_fifo_tag_intr2_u8 : The value of fifo tag interrupt
- * value | fifo tag interrupt
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_tag_intr2_enable(
-u8 v_fifo_tag_intr2_u8);
-/*!
- * @brief This API get FIFO tag interrupt1 enable status
- * from the resister 0x47 bit 3
- *
- * @param v_fifo_tag_intr1_u8 :The value of fifo tag interrupt1
- * value | fifo tag interrupt
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_tag_intr1_enable(
-u8 *v_fifo_tag_intr1_u8);
-/*!
- * @brief This API set FIFO tag interrupt1 enable status
- * from the resister 0x47 bit 3
- *
- * @param v_fifo_tag_intr1_u8 :The value of fifo tag interrupt1
- * value | fifo tag interrupt
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_tag_intr1_enable(
-u8 v_fifo_tag_intr1_u8);
-/*!
- * @brief This API reads FIFO frame
- * header enable from the register 0x47 bit 4
- *
- * @param v_fifo_header_u8 :The value of fifo header
- * value | fifo header
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_header_enable(
-u8 *v_fifo_header_u8);
-/*!
- * @brief This API set FIFO frame
- * header enable from the register 0x47 bit 4
- *
- * @param v_fifo_header_u8 :The value of fifo header
- * value | fifo header
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_header_enable(
-u8 v_fifo_header_u8);
-/*!
- * @brief This API is used to read stored
- * magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
- *
- * @param v_fifo_mag_u8 : The value of fifo mag enble
- * value | fifo mag
- * ----------|-------------------
- * 0x00 | no magnetometer data is stored
- * 0x01 | magnetometer data is stored
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_mag_enable(
-u8 *v_fifo_mag_u8);
-/*!
- * @brief This API is used to set stored
- * magnetometer data in FIFO (all 3 axes) from the register 0x47 bit 5
- *
- * @param v_fifo_mag_u8 : The value of fifo mag enble
- * value | fifo mag
- * ----------|-------------------
- * 0x00 | no magnetometer data is stored
- * 0x01 | magnetometer data is stored
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_mag_enable(
-u8 v_fifo_mag_u8);
-/*!
- * @brief This API is used to read stored
- * accel data in FIFO (all 3 axes) from the register 0x47 bit 6
- *
- * @param v_fifo_accel_u8 : The value of fifo accel enble
- * value | fifo accel
- * ----------|-------------------
- * 0x00 | no accel data is stored
- * 0x01 | accel data is stored
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_accel_enable(
-u8 *v_fifo_accel_u8);
-/*!
- * @brief This API is used to set stored
- * accel data in FIFO (all 3 axes) from the register 0x47 bit 6
- *
- * @param v_fifo_accel_u8 : The value of fifo accel enble
- * value | fifo accel
- * ----------|-------------------
- * 0x00 | no accel data is stored
- * 0x01 | accel data is stored
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_accel_enable(
-u8 v_fifo_accel_u8);
-/*!
- * @brief This API is used to read stored
- * gyro data in FIFO (all 3 axes) from the resister 0x47 bit 7
- *
- *
- * @param v_fifo_gyro_u8 : The value of fifo gyro enble
- * value | fifo gyro
- * ----------|-------------------
- * 0x00 | no gyro data is stored
- * 0x01 | gyro data is stored
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_fifo_gyro_enable(
-u8 *v_fifo_gyro_u8);
-/*!
- * @brief This API is used to set stored
- * gyro data in FIFO (all 3 axes) from the resister 0x47 bit 7
- *
- *
- * @param v_fifo_gyro_u8 : The value of fifo gyro enble
- * value | fifo gyro
- * ----------|-------------------
- * 0x00 | no gyro data is stored
- * 0x01 | gyro data is stored
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_fifo_gyro_enable(
-u8 v_fifo_gyro_u8);
-/***************************************************************/
-/**\name FUNCTION FOR MAG I2C ADDRESS SELECTION */
-/***************************************************************/
-/*!
- * @brief This API is used to read
- * I2C device address of auxiliary mag from the register 0x4B bit 1 to 7
- *
- *
- *
- *
- * @param v_i2c_device_addr_u8 : The value of mag I2C device address
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_device_addr(
-u8 *v_i2c_device_addr_u8);
-/*!
- * @brief This API is used to set
- * I2C device address of auxiliary mag from the register 0x4B bit 1 to 7
- *
- *
- *
- *
- * @param v_i2c_device_addr_u8 : The value of mag I2C device address
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_i2c_device_addr(
-u8 v_i2c_device_addr_u8);
-/*!
- * @brief This API is used to read
- * Burst data length (1,2,6,8 byte) from the register 0x4C bit 0 to 1
- *
- *
- *
- *
- * @param v_mag_burst_u8 : The data of mag burst read lenth
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_burst(
-u8 *v_mag_burst_u8);
-/*!
- * @brief This API is used to set
- * Burst data length (1,2,6,8 byte) from the register 0x4C bit 0 to 1
- *
- *
- *
- *
- * @param v_mag_burst_u8 : The data of mag burst read lenth
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_burst(
-u8 v_mag_burst_u8);
-/***************************************************************/
-/**\name FUNCTION FOR MAG OFFSET */
-/***************************************************************/
-/*!
- * @brief This API is used to read
- * trigger-readout offset in units of 2.5 ms. If set to zero,
- * the offset is maximum, i.e. after readout a trigger
- * is issued immediately. from the register 0x4C bit 2 to 5
- *
- *
- *
- *
- * @param v_mag_offset_u8 : The value of mag offset
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_offset(
-u8 *v_mag_offset_u8);
-/*!
- * @brief This API is used to set
- * trigger-readout offset in units of 2.5 ms. If set to zero,
- * the offset is maximum, i.e. after readout a trigger
- * is issued immediately. from the register 0x4C bit 2 to 5
- *
- *
- *
- *
- * @param v_mag_offset_u8 : The value of mag offset
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_offset(
-u8 v_mag_offset_u8);
-/***************************************************************/
-/**\name FUNCTION FOR MAG MANUAL/AUTO MODE SELECTION */
-/***************************************************************/
-/*!
- * @brief This API is used to read
- * Enable register access on MAG_IF[2] or MAG_IF[3] writes.
- * This implies that the DATA registers are not updated with
- * magnetometer values. Accessing magnetometer requires
- * the magnetometer in normal mode in PMU_STATUS.
- * from the register 0x4C bit 7
- *
- *
- *
- * @param v_mag_manual_u8 : The value of mag manual enable
- * value | mag manual
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_manual_enable(
-u8 *v_mag_manual_u8);
-/*!
- * @brief This API is used to set
- * Enable register access on MAG_IF[2] or MAG_IF[3] writes.
- * This implies that the DATA registers are not updated with
- * magnetometer values. Accessing magnetometer requires
- * the magnetometer in normal mode in PMU_STATUS.
- * from the register 0x4C bit 7
- *
- *
- *
- * @param v_mag_manual_u8 : The value of mag manual enable
- * value | mag manual
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_manual_enable(
-u8 v_mag_manual_u8);
-/***************************************************************/
-/**\name FUNCTIONS FOR MAG READ, WRITE AND WRITE DATA ADDRESS */
-/***************************************************************/
-/*!
- * @brief This API is used to read data
- * magnetometer address to read from the register 0x4D bit 0 to 7
- * @brief It used to provide mag read address of auxiliary mag
- *
- *
- *
- *
- * @param v_mag_read_addr_u8 : The value of address need to be read
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_read_addr(
-u8 *v_mag_read_addr_u8);
-/*!
- * @brief This API is used to set
- * magnetometer write address from the register 0x4D bit 0 to 7
- * @brief mag write address writes the address of auxiliary mag to write
- *
- *
- *
- * @param v_mag_read_addr_u8:
- * The data of auxiliary mag address to write data
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_read_addr(
-u8 v_mag_read_addr_u8);
-/*!
- * @brief This API is used to read
- * magnetometer write address from the register 0x4E bit 0 to 7
- * @brief mag write address writes the address of auxiliary mag to write
- *
- *
- *
- * @param v_mag_write_addr_u8:
- * The data of auxiliary mag address to write data
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_write_addr(
-u8 *v_mag_write_addr_u8);
-/*!
- * @brief This API is used to set
- * magnetometer write address from the register 0x4E bit 0 to 7
- * @brief mag write address writes the address of auxiliary mag to write
- *
- *
- *
- * @param v_mag_write_addr_u8:
- * The data of auxiliary mag address to write data
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_write_addr(
-u8 v_mag_write_addr_u8);
-/*!
- * @brief This API is used to read magnetometer write data
- * form the resister 0x4F bit 0 to 7
- * @brief This writes the data will be wrote to mag
- *
- *
- *
- * @param v_mag_write_data_u8: The value of mag data
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_mag_write_data(
-u8 *v_mag_write_data_u8);
-/*!
- * @brief This API is used to set magnetometer write data
- * form the resister 0x4F bit 0 to 7
- * @brief This writes the data will be wrote to mag
- *
- *
- *
- * @param v_mag_write_data_u8: The value of mag data
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_mag_write_data(
-u8 v_mag_write_data_u8);
-/***************************************************************/
-/**\name FUNCTION FOR INTERRUPT ENABLE OF
-ANY-MOTION XYZ, DOUBLE AND SINGLE TAP, ORIENT AND FLAT */
-/***************************************************************/
-/*!
- * @brief This API is used to read
- * interrupt enable from the register 0x50 bit 0 to 7
- *
- *
- *
- *
- * @param v_enable_u8 : Value to decided to select interrupt
- * v_enable_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_ANY_MOTION_X_ENABLE
- * 1 | BMI160_ANY_MOTION_Y_ENABLE
- * 2 | BMI160_ANY_MOTION_Z_ENABLE
- * 3 | BMI160_DOUBLE_TAP_ENABLE
- * 4 | BMI160_SINGLE_TAP_ENABLE
- * 5 | BMI160_ORIENT_ENABLE
- * 6 | BMI160_FLAT_ENABLE
- *
- * @param v_intr_enable_zero_u8 : The interrupt enable value
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_0(
-u8 enable, u8 *v_intr_enable_zero_u8);
-/*!
- * @brief This API is used to set
- * interrupt enable from the register 0x50 bit 0 to 7
- *
- *
- *
- *
- * @param v_enable_u8 : Value to decided to select interrupt
- * v_enable_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_ANY_MOTION_X_ENABLE
- * 1 | BMI160_ANY_MOTION_Y_ENABLE
- * 2 | BMI160_ANY_MOTION_Z_ENABLE
- * 3 | BMI160_DOUBLE_TAP_ENABLE
- * 4 | BMI160_SINGLE_TAP_ENABLE
- * 5 | BMI160_ORIENT_ENABLE
- * 6 | BMI160_FLAT_ENABLE
- *
- * @param v_intr_enable_zero_u8 : The interrupt enable value
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_enable_0(
-u8 enable, u8 v_intr_enable_zero_u8);
-/***************************************************************/
-/**\name FUNCTION FOR INTERRUPT ENABLE OF
-HIGH_G XYZ, LOW_G, DATA READY, FIFO FULL AND FIFO WATER MARK */
-/***************************************************************/
-/*!
- * @brief This API is used to read
- * interrupt enable byte1 from the register 0x51 bit 0 to 6
- * @brief It read the high_g_x,high_g_y,high_g_z,low_g_enable
- * data ready, fifo full and fifo water mark.
- *
- *
- *
- * @param v_enable_u8 : The value of interrupt enable
- * @param v_enable_u8 : Value to decided to select interrupt
- * v_enable_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_HIGH_G_X_ENABLE
- * 1 | BMI160_HIGH_G_Y_ENABLE
- * 2 | BMI160_HIGH_G_Z_ENABLE
- * 3 | BMI160_LOW_G_ENABLE
- * 4 | BMI160_DATA_RDY_ENABLE
- * 5 | BMI160_FIFO_FULL_ENABLE
- * 6 | BMI160_FIFO_WM_ENABLE
- *
- * @param v_intr_enable_1_u8 : The interrupt enable value
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_1(
-u8 enable, u8 *v_intr_enable_1_u8);
-/*!
- * @brief This API is used to set
- * interrupt enable byte1 from the register 0x51 bit 0 to 6
- * @brief It read the high_g_x,high_g_y,high_g_z,low_g_enable
- * data ready, fifo full and fifo water mark.
- *
- *
- *
- * @param v_enable_u8 : The value of interrupt enable
- * @param v_enable_u8 : Value to decided to select interrupt
- * v_enable_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_HIGH_G_X_ENABLE
- * 1 | BMI160_HIGH_G_Y_ENABLE
- * 2 | BMI160_HIGH_G_Z_ENABLE
- * 3 | BMI160_LOW_G_ENABLE
- * 4 | BMI160_DATA_RDY_ENABLE
- * 5 | BMI160_FIFO_FULL_ENABLE
- * 6 | BMI160_FIFO_WM_ENABLE
- *
- * @param v_intr_enable_1_u8 : The interrupt enable value
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_enable_1(
-u8 enable, u8 v_intr_enable_1_u8);
-/***************************************************************/
-/**\name FUNCTION FOR INTERRUPT ENABLE OF
-NO MOTION XYZ */
-/***************************************************************/
-/*!
- * @brief This API is used to read
- * interrupt enable byte2 from the register bit 0x52 bit 0 to 3
- * @brief It reads no motion x,y and z
- *
- *
- *
- * @param v_enable_u8: The value of interrupt enable
- * v_enable_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_NOMOTION_X_ENABLE
- * 1 | BMI160_NOMOTION_Y_ENABLE
- * 2 | BMI160_NOMOTION_Z_ENABLE
- *
- * @param v_intr_enable_2_u8 : The interrupt enable value
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_enable_2(
-u8 enable, u8 *v_intr_enable_2_u8);
-/*!
- * @brief This API is used to set
- * interrupt enable byte2 from the register bit 0x52 bit 0 to 3
- * @brief It reads no motion x,y and z
- *
- *
- *
- * @param v_enable_u8: The value of interrupt enable
- * v_enable_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_NOMOTION_X_ENABLE
- * 1 | BMI160_NOMOTION_Y_ENABLE
- * 2 | BMI160_NOMOTION_Z_ENABLE
- *
- * @param v_intr_enable_2_u8 : The interrupt enable value
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_enable_2(
-u8 enable, u8 v_intr_enable_2_u8);
-/***************************************************************/
-/**\name FUNCTION FOR INTERRUPT ENABLE OF
- STEP DETECTOR */
-/***************************************************************/
- /*!
- * @brief This API is used to read
- * interrupt enable step detector interrupt from
- * the register bit 0x52 bit 3
- *
- *
- *
- *
- * @param v_step_intr_u8 : The value of step detector interrupt enable
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_detector_enable(
-u8 *v_step_intr_u8);
- /*!
- * @brief This API is used to set
- * interrupt enable step detector interrupt from
- * the register bit 0x52 bit 3
- *
- *
- *
- *
- * @param v_step_intr_u8 : The value of step detector interrupt enable
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_detector_enable(
-u8 v_step_intr_u8);
-/***************************************************************/
-/**\name FUNCTION FOR INTERRUPT CONTROL */
-/***************************************************************/
-/*!
- * @brief Configure trigger condition of interrupt1
- * and interrupt2 pin from the register 0x53
- * @brief interrupt1 - bit 0
- * @brief interrupt2 - bit 4
- *
- * @param v_channel_u8: The value of edge trigger selection
- * v_channel_u8 | Edge trigger
- * ---------------|---------------
- * 0 | BMI160_INTR1_EDGE_CTRL
- * 1 | BMI160_INTR2_EDGE_CTRL
- *
- * @param v_intr_edge_ctrl_u8 : The value of edge trigger enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_EDGE
- * 0x00 | BMI160_LEVEL
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_edge_ctrl(
-u8 v_channel_u8, u8 *v_intr_edge_ctrl_u8);
-/*!
- * @brief Configure trigger condition of interrupt1
- * and interrupt2 pin from the register 0x53
- * @brief interrupt1 - bit 0
- * @brief interrupt2 - bit 4
- *
- * @param v_channel_u8: The value of edge trigger selection
- * v_channel_u8 | Edge trigger
- * ---------------|---------------
- * 0 | BMI160_INTR1_EDGE_CTRL
- * 1 | BMI160_INTR2_EDGE_CTRL
- *
- * @param v_intr_edge_ctrl_u8 : The value of edge trigger enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_EDGE
- * 0x00 | BMI160_LEVEL
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_edge_ctrl(
-u8 v_channel_u8, u8 v_intr_edge_ctrl_u8);
-/*!
- * @brief API used for get the Configure level condition of interrupt1
- * and interrupt2 pin form the register 0x53
- * @brief interrupt1 - bit 1
- * @brief interrupt2 - bit 5
- *
- * @param v_channel_u8: The value of level condition selection
- * v_channel_u8 | level selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_LEVEL
- * 1 | BMI160_INTR2_LEVEL
- *
- * @param v_intr_level_u8 : The value of level of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_LEVEL_HIGH
- * 0x00 | BMI160_LEVEL_LOW
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_level(
-u8 v_channel_u8, u8 *v_intr_level_u8);
-/*!
- * @brief API used for set the Configure level condition of interrupt1
- * and interrupt2 pin form the register 0x53
- * @brief interrupt1 - bit 1
- * @brief interrupt2 - bit 5
- *
- * @param v_channel_u8: The value of level condition selection
- * v_channel_u8 | level selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_LEVEL
- * 1 | BMI160_INTR2_LEVEL
- *
- * @param v_intr_level_u8 : The value of level of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_LEVEL_HIGH
- * 0x00 | BMI160_LEVEL_LOW
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_level(
-u8 v_channel_u8, u8 v_intr_level_u8);
-/*!
- * @brief API used to get configured output enable of interrupt1
- * and interrupt2 from the register 0x53
- * @brief interrupt1 - bit 2
- * @brief interrupt2 - bit 6
- *
- *
- * @param v_channel_u8: The value of output type enable selection
- * v_channel_u8 | level selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_OUTPUT_TYPE
- * 1 | BMI160_INTR2_OUTPUT_TYPE
- *
- * @param v_intr_output_type_u8 :
- * The value of output type of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_OPEN_DRAIN
- * 0x00 | BMI160_PUSH_PULL
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_output_type(
-u8 v_channel_u8, u8 *v_intr_output_type_u8);
-/*!
- * @brief API used to set output enable of interrupt1
- * and interrupt2 from the register 0x53
- * @brief interrupt1 - bit 2
- * @brief interrupt2 - bit 6
- *
- *
- * @param v_channel_u8: The value of output type enable selection
- * v_channel_u8 | level selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_OUTPUT_TYPE
- * 1 | BMI160_INTR2_OUTPUT_TYPE
- *
- * @param v_intr_output_type_u8 :
- * The value of output type of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_OPEN_DRAIN
- * 0x00 | BMI160_PUSH_PULL
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_output_type(
-u8 v_channel_u8, u8 v_intr_output_type_u8);
- /*!
- * @brief API used to get the Output enable for interrupt1
- * and interrupt1 pin from the register 0x53
- * @brief interrupt1 - bit 3
- * @brief interrupt2 - bit 7
- *
- * @param v_channel_u8: The value of output enable selection
- * v_channel_u8 | level selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_OUTPUT_TYPE
- * 1 | BMI160_INTR2_OUTPUT_TYPE
- *
- * @param v_output_enable_u8 :
- * The value of output enable of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_INPUT
- * 0x00 | BMI160_OUTPUT
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_output_enable(
-u8 v_channel_u8, u8 *v_output_enable_u8);
- /*!
- * @brief API used to set the Output enable for interrupt1
- * and interrupt1 pin from the register 0x53
- * @brief interrupt1 - bit 3
- * @brief interrupt2 - bit 7
- *
- * @param v_channel_u8: The value of output enable selection
- * v_channel_u8 | level selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_OUTPUT_TYPE
- * 1 | BMI160_INTR2_OUTPUT_TYPE
- *
- * @param v_output_enable_u8 :
- * The value of output enable of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_INPUT
- * 0x00 | BMI160_OUTPUT
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_output_enable(
-u8 v_channel_u8, u8 v_output_enable_u8);
-/***************************************************************/
-/**\name FUNCTION FOR INTERRUPT LATCH INTERRUPT */
-/***************************************************************/
-/*!
-* @brief This API is used to get the latch duration
-* from the register 0x54 bit 0 to 3
-* @brief This latch selection is not applicable for data ready,
-* orientation and flat interrupts.
-*
-*
-*
-* @param v_latch_intr_u8 : The value of latch duration
-* Latch Duration | value
-* --------------------------------------|------------------
-* BMI160_LATCH_DUR_NONE | 0x00
-* BMI160_LATCH_DUR_312_5_MICRO_SEC | 0x01
-* BMI160_LATCH_DUR_625_MICRO_SEC | 0x02
-* BMI160_LATCH_DUR_1_25_MILLI_SEC | 0x03
-* BMI160_LATCH_DUR_2_5_MILLI_SEC | 0x04
-* BMI160_LATCH_DUR_5_MILLI_SEC | 0x05
-* BMI160_LATCH_DUR_10_MILLI_SEC | 0x06
-* BMI160_LATCH_DUR_20_MILLI_SEC | 0x07
-* BMI160_LATCH_DUR_40_MILLI_SEC | 0x08
-* BMI160_LATCH_DUR_80_MILLI_SEC | 0x09
-* BMI160_LATCH_DUR_160_MILLI_SEC | 0x0A
-* BMI160_LATCH_DUR_320_MILLI_SEC | 0x0B
-* BMI160_LATCH_DUR_640_MILLI_SEC | 0x0C
-* BMI160_LATCH_DUR_1_28_SEC | 0x0D
-* BMI160_LATCH_DUR_2_56_SEC | 0x0E
-* BMI160_LATCHED | 0x0F
-*
-*
-*
-* @return results of bus communication function
-* @retval 0 -> Success
-* @retval -1 -> Error
-*
-*
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_latch_intr(
-u8 *v_latch_intr_u8);
-/*!
-* @brief This API is used to set the latch duration
-* from the register 0x54 bit 0 to 3
-* @brief This latch selection is not applicable for data ready,
-* orientation and flat interrupts.
-*
-*
-*
-* @param v_latch_intr_u8 : The value of latch duration
-* Latch Duration | value
-* --------------------------------------|------------------
-* BMI160_LATCH_DUR_NONE | 0x00
-* BMI160_LATCH_DUR_312_5_MICRO_SEC | 0x01
-* BMI160_LATCH_DUR_625_MICRO_SEC | 0x02
-* BMI160_LATCH_DUR_1_25_MILLI_SEC | 0x03
-* BMI160_LATCH_DUR_2_5_MILLI_SEC | 0x04
-* BMI160_LATCH_DUR_5_MILLI_SEC | 0x05
-* BMI160_LATCH_DUR_10_MILLI_SEC | 0x06
-* BMI160_LATCH_DUR_20_MILLI_SEC | 0x07
-* BMI160_LATCH_DUR_40_MILLI_SEC | 0x08
-* BMI160_LATCH_DUR_80_MILLI_SEC | 0x09
-* BMI160_LATCH_DUR_160_MILLI_SEC | 0x0A
-* BMI160_LATCH_DUR_320_MILLI_SEC | 0x0B
-* BMI160_LATCH_DUR_640_MILLI_SEC | 0x0C
-* BMI160_LATCH_DUR_1_28_SEC | 0x0D
-* BMI160_LATCH_DUR_2_56_SEC | 0x0E
-* BMI160_LATCHED | 0x0F
-*
-*
-*
-* @return results of bus communication function
-* @retval 0 -> Success
-* @retval -1 -> Error
-*
-*
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_latch_intr(
-u8 v_latch_intr_u8);
-/*!
- * @brief API used to get input enable for interrupt1
- * and interrupt2 pin from the register 0x54
- * @brief interrupt1 - bit 4
- * @brief interrupt2 - bit 5
- *
- * @param v_channel_u8: The value of input enable selection
- * v_channel_u8 | input selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_INPUT_ENABLE
- * 1 | BMI160_INTR2_INPUT_ENABLE
- *
- * @param v_input_en_u8 :
- * The value of input enable of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_INPUT
- * 0x00 | BMI160_OUTPUT
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_input_enable(
-u8 v_channel_u8, u8 *v_input_en_u8);
-/*!
- * @brief API used to set input enable for interrupt1
- * and interrupt2 pin from the register 0x54
- * @brief interrupt1 - bit 4
- * @brief interrupt2 - bit 5
- *
- * @param v_channel_u8: The value of input enable selection
- * v_channel_u8 | input selection
- * ---------------|---------------
- * 0 | BMI160_INTR1_INPUT_ENABLE
- * 1 | BMI160_INTR2_INPUT_ENABLE
- *
- * @param v_input_en_u8 :
- * The value of input enable of interrupt enable
- * value | Behaviour
- * ----------|-------------------
- * 0x01 | BMI160_INPUT
- * 0x00 | BMI160_OUTPUT
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_input_enable(
-u8 v_channel_u8, u8 v_input_en_u8);
-/***************************************************************/
-/**\name FUNCTION FOR INTERRUPT1 AND INTERRUPT2 MAPPING */
-/***************************************************************/
- /*!
- * @brief reads the Low g interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 0 in the register 0x55
- * @brief interrupt2 bit 0 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of low_g selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_LOW_G
- * 1 | BMI160_INTR2_MAP_LOW_G
- *
- * @param v_intr_low_g_u8 : The value of low_g enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g(
-u8 v_channel_u8, u8 *v_intr_low_g_u8);
- /*!
- * @brief set the Low g interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 0 in the register 0x55
- * @brief interrupt2 bit 0 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of low_g selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_LOW_G
- * 1 | BMI160_INTR2_MAP_LOW_G
- *
- * @param v_intr_low_g_u8 : The value of low_g enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g(
-u8 v_channel_u8, u8 v_intr_low_g_u8);
-/*!
- * @brief Reads the HIGH g interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 1 in the register 0x55
- * @brief interrupt2 bit 1 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of high_g selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_HIGH_G
- * 1 | BMI160_INTR2_MAP_HIGH_G
- *
- * @param v_intr_high_g_u8 : The value of high_g enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g(
-u8 v_channel_u8, u8 *v_intr_high_g_u8);
-/*!
- * @brief Write the HIGH g interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 1 in the register 0x55
- * @brief interrupt2 bit 1 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of high_g selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_HIGH_G
- * 1 | BMI160_INTR2_MAP_HIGH_G
- *
- * @param v_intr_high_g_u8 : The value of high_g enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g(
-u8 v_channel_u8, u8 v_intr_high_g_u8);
-/*!
- * @brief Reads the Any motion interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 2 in the register 0x55
- * @brief interrupt2 bit 2 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of any motion selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_ANY_MOTION
- * 1 | BMI160_INTR2_MAP_ANY_MOTION
- *
- * @param v_intr_any_motion_u8 : The value of any motion enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion(
-u8 v_channel_u8, u8 *v_intr_any_motion_u8);
-/*!
- * @brief Write the Any motion interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 2 in the register 0x55
- * @brief interrupt2 bit 2 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of any motion selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_ANY_MOTION
- * 1 | BMI160_INTR2_MAP_ANY_MOTION
- *
- * @param v_intr_any_motion_u8 : The value of any motion enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion(
-u8 v_channel_u8, u8 v_intr_any_motion_u8);
-/*!
- * @brief Reads the No motion interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 3 in the register 0x55
- * @brief interrupt2 bit 3 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of no motion selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_NOMO
- * 1 | BMI160_INTR2_MAP_NOMO
- *
- * @param v_intr_nomotion_u8 : The value of no motion enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_nomotion(
-u8 v_channel_u8, u8 *v_intr_nomotion_u8);
-/*!
- * @brief Write the No motion interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 3 in the register 0x55
- * @brief interrupt2 bit 3 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of no motion selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_NOMO
- * 1 | BMI160_INTR2_MAP_NOMO
- *
- * @param v_intr_nomotion_u8 : The value of no motion enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_nomotion(
-u8 v_channel_u8, u8 v_intr_nomotion_u8);
-/*!
- * @brief Reads the Double Tap interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 4 in the register 0x55
- * @brief interrupt2 bit 4 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of double tap interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_DOUBLE_TAP
- * 1 | BMI160_INTR2_MAP_DOUBLE_TAP
- *
- * @param v_intr_double_tap_u8 : The value of double tap enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_double_tap(
-u8 v_channel_u8, u8 *v_intr_double_tap_u8);
-/*!
- * @brief Write the Double Tap interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 4 in the register 0x55
- * @brief interrupt2 bit 4 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of double tap interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_DOUBLE_TAP
- * 1 | BMI160_INTR2_MAP_DOUBLE_TAP
- *
- * @param v_intr_double_tap_u8 : The value of double tap enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_double_tap(
-u8 v_channel_u8, u8 v_intr_double_tap_u8);
-/*!
- * @brief Reads the Single Tap interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 5 in the register 0x55
- * @brief interrupt2 bit 5 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of single tap interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_SINGLE_TAP
- * 1 | BMI160_INTR2_MAP_SINGLE_TAP
- *
- * @param v_intr_single_tap_u8 : The value of single tap enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_single_tap(
-u8 v_channel_u8, u8 *v_intr_single_tap_u8);
-/*!
- * @brief Write the Single Tap interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 5 in the register 0x55
- * @brief interrupt2 bit 5 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of single tap interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_SINGLE_TAP
- * 1 | BMI160_INTR2_MAP_SINGLE_TAP
- *
- * @param v_intr_single_tap_u8 : The value of single tap enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_single_tap(
-u8 v_channel_u8, u8 v_intr_single_tap_u8);
-/*!
- * @brief Reads the Orient interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 6 in the register 0x55
- * @brief interrupt2 bit 6 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of orient interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_ORIENT
- * 1 | BMI160_INTR2_MAP_ORIENT
- *
- * @param v_intr_orient_u8 : The value of orient enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient(
-u8 v_channel_u8, u8 *v_intr_orient_u8);
-/*!
- * @brief Write the Orient interrupt
- * interrupt mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 6 in the register 0x55
- * @brief interrupt2 bit 6 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of orient interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_ORIENT
- * 1 | BMI160_INTR2_MAP_ORIENT
- *
- * @param v_intr_orient_u8 : The value of orient enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient(
-u8 v_channel_u8, u8 v_intr_orient_u8);
- /*!
- * @brief Reads the Flat interrupt
- * mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 7 in the register 0x55
- * @brief interrupt2 bit 7 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of flat interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_FLAT
- * 1 | BMI160_INTR2_MAP_FLAT
- *
- * @param v_intr_flat_u8 : The value of flat enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat(
-u8 v_channel_u8, u8 *v_intr_flat_u8);
- /*!
- * @brief Write the Flat interrupt
- * mapped to interrupt1
- * and interrupt2 from the register 0x55 and 0x57
- * @brief interrupt1 bit 7 in the register 0x55
- * @brief interrupt2 bit 7 in the register 0x57
- *
- *
- * @param v_channel_u8: The value of flat interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_FLAT
- * 1 | BMI160_INTR2_MAP_FLAT
- *
- * @param v_intr_flat_u8 : The value of flat enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat(
-u8 v_channel_u8, u8 v_intr_flat_u8);
-/*!
- * @brief Reads PMU trigger interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56 bit 0 and 4
- * @brief interrupt1 bit 0 in the register 0x56
- * @brief interrupt2 bit 4 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of pmu trigger selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_PMUTRIG
- * 1 | BMI160_INTR2_MAP_PMUTRIG
- *
- * @param v_intr_pmu_trig_u8 : The value of pmu trigger enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_pmu_trig(
-u8 v_channel_u8, u8 *v_intr_pmu_trig_u8);
-/*!
- * @brief Write PMU trigger interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56 bit 0 and 4
- * @brief interrupt1 bit 0 in the register 0x56
- * @brief interrupt2 bit 4 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of pmu trigger selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_PMUTRIG
- * 1 | BMI160_INTR2_MAP_PMUTRIG
- *
- * @param v_intr_pmu_trig_u8 : The value of pmu trigger enable
- * value | trigger enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_pmu_trig(
-u8 v_channel_u8, u8 v_intr_pmu_trig_u8);
-/*!
- * @brief Reads FIFO Full interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56 bit 5 and 1
- * @brief interrupt1 bit 5 in the register 0x56
- * @brief interrupt2 bit 1 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of fifo full interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_FIFO_FULL
- * 1 | BMI160_INTR2_MAP_FIFO_FULL
- *
- * @param v_intr_fifo_full_u8 : The value of fifo full interrupt enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_fifo_full(
-u8 v_channel_u8, u8 *v_intr_fifo_full_u8);
-/*!
- * @brief Write FIFO Full interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56 bit 5 and 1
- * @brief interrupt1 bit 5 in the register 0x56
- * @brief interrupt2 bit 1 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of fifo full interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_FIFO_FULL
- * 1 | BMI160_INTR2_MAP_FIFO_FULL
- *
- * @param v_intr_fifo_full_u8 : The value of fifo full interrupt enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_fifo_full(
-u8 v_channel_u8, u8 v_intr_fifo_full_u8);
-/*!
- * @brief Reads FIFO Watermark interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56 bit 6 and 2
- * @brief interrupt1 bit 6 in the register 0x56
- * @brief interrupt2 bit 2 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of fifo Watermark interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_FIFO_WM
- * 1 | BMI160_INTR2_MAP_FIFO_WM
- *
- * @param v_intr_fifo_wm_u8 : The value of fifo Watermark interrupt enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_fifo_wm(
-u8 v_channel_u8, u8 *v_intr_fifo_wm_u8);
-/*!
- * @brief Write FIFO Watermark interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56 bit 6 and 2
- * @brief interrupt1 bit 6 in the register 0x56
- * @brief interrupt2 bit 2 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of fifo Watermark interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_FIFO_WM
- * 1 | BMI160_INTR2_MAP_FIFO_WM
- *
- * @param v_intr_fifo_wm_u8 : The value of fifo Watermark interrupt enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_fifo_wm(
-u8 v_channel_u8, u8 v_intr_fifo_wm_u8);
-/*!
- * @brief Reads Data Ready interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56
- * @brief interrupt1 bit 7 in the register 0x56
- * @brief interrupt2 bit 3 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of data ready interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_DATA_RDY
- * 1 | BMI160_INTR2_MAP_DATA_RDY
- *
- * @param v_intr_data_rdy_u8 : The value of data ready interrupt enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_data_rdy(
-u8 v_channel_u8, u8 *v_intr_data_rdy_u8);
-/*!
- * @brief Write Data Ready interrupt mapped to interrupt1
- * and interrupt2 form the register 0x56
- * @brief interrupt1 bit 7 in the register 0x56
- * @brief interrupt2 bit 3 in the register 0x56
- *
- *
- * @param v_channel_u8: The value of data ready interrupt selection
- * v_channel_u8 | interrupt
- * ---------------|---------------
- * 0 | BMI160_INTR1_MAP_DATA_RDY
- * 1 | BMI160_INTR2_MAP_DATA_RDY
- *
- * @param v_intr_data_rdy_u8 : The value of data ready interrupt enable
- * value | interrupt enable
- * ----------|-------------------
- * 0x01 | BMI160_ENABLE
- * 0x00 | BMI160_DISABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_data_rdy(
-u8 v_channel_u8, u8 v_intr_data_rdy_u8);
-/***************************************************************/
-/**\name FUNCTION FOR TAP SOURCE CONFIGURATION */
-/***************************************************************/
- /*!
- * @brief This API reads data source for the interrupt
- * engine for the single and double tap interrupts from the register
- * 0x58 bit 3
- *
- *
- * @param v_tap_source_u8 : The value of the tap source
- * value | Description
- * ----------|-------------------
- * 0x01 | UNFILTER_DATA
- * 0x00 | FILTER_DATA
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_source(
-u8 *v_tap_source_u8);
- /*!
- * @brief This API write data source for the interrupt
- * engine for the single and double tap interrupts from the register
- * 0x58 bit 3
- *
- *
- * @param v_tap_source_u8 : The value of the tap source
- * value | Description
- * ----------|-------------------
- * 0x01 | UNFILTER_DATA
- * 0x00 | FILTER_DATA
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_source(
-u8 v_tap_source_u8);
-/***************************************************************/
-/**\name FUNCTION FOR LOW_G AND HIGH_G SOURCE CONFIGURATION */
-/***************************************************************/
- /*!
- * @brief This API Reads Data source for the
- * interrupt engine for the low and high g interrupts
- * from the register 0x58 bit 7
- *
- * @param v_low_high_source_u8 : The value of the tap source
- * value | Description
- * ----------|-------------------
- * 0x01 | UNFILTER_DATA
- * 0x00 | FILTER_DATA
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_high_source(
-u8 *v_low_high_source_u8);
- /*!
- * @brief This API write Data source for the
- * interrupt engine for the low and high g interrupts
- * from the register 0x58 bit 7
- *
- * @param v_low_high_source_u8 : The value of the tap source
- * value | Description
- * ----------|-------------------
- * 0x01 | UNFILTER_DATA
- * 0x00 | FILTER_DATA
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_high_source(
-u8 v_low_high_source_u8);
-/***************************************************************/
-/**\name FUNCTION FOR MOTION SOURCE CONFIGURATION */
-/***************************************************************/
- /*!
- * @brief This API reads Data source for the
- * interrupt engine for the nomotion and anymotion interrupts
- * from the register 0x59 bit 7
- *
- * @param v_motion_source_u8 :
- * The value of the any/no motion interrupt source
- * value | Description
- * ----------|-------------------
- * 0x01 | UNFILTER_DATA
- * 0x00 | FILTER_DATA
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_motion_source(
-u8 *v_motion_source_u8);
- /*!
- * @brief This API write Data source for the
- * interrupt engine for the nomotion and anymotion interrupts
- * from the register 0x59 bit 7
- *
- * @param v_motion_source_u8 :
- * The value of the any/no motion interrupt source
- * value | Description
- * ----------|-------------------
- * 0x01 | UNFILTER_DATA
- * 0x00 | FILTER_DATA
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_motion_source(
-u8 v_motion_source_u8);
-/***************************************************************/
-/**\name FUNCTION FOR LOW_G DURATION CONFIGURATION */
-/***************************************************************/
-/*!
- * @brief This API is used to read the low_g duration from register
- * 0x5A bit 0 to 7
- *
- *
- *
- *
- * @param v_low_g_durn_u8 : The value of low_g duration
- *
- * @note Low_g duration trigger trigger delay according to
- * "(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
- * the default corresponds delay is 20ms
- * @note When low_g data source of interrupt is unfiltered
- * the sensor must not be in low power mode
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_durn(
-u8 *v_low_durn_u8);
- /*!
- * @brief This API is used to write the low_g duration from register
- * 0x5A bit 0 to 7
- *
- *
- *
- *
- * @param v_low_g_durn_u8 : The value of low_g duration
- *
- * @note Low_g duration trigger trigger delay according to
- * "(v_low_g_durn_u8 * 2.5)ms" in a range from 2.5ms to 640ms.
- * the default corresponds delay is 20ms
- * @note When low_g data source of interrupt is unfiltered
- * the sensor must not be in low power mode
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_durn(
-u8 v_low_durn_u8);
-/***************************************************************/
-/**\name FUNCTION FOR LOW_G THRESH CONFIGURATION */
-/***************************************************************/
-/*!
- * @brief This API is used to read Threshold
- * definition for the low-g interrupt from the register 0x5B bit 0 to 7
- *
- *
- *
- *
- * @param v_low_g_thres_u8 : The value of low_g threshold
- *
- * @note Low_g interrupt trigger threshold according to
- * (v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
- * 3.91 mg for v_low_g_thres_u8 = 0
- * The threshold range is form 3.91mg to 2.000mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_thres(
-u8 *v_low_g_thres_u8);
-/*!
- * @brief This API is used to write Threshold
- * definition for the low-g interrupt from the register 0x5B bit 0 to 7
- *
- *
- *
- *
- * @param v_low_g_thres_u8 : The value of low_g threshold
- *
- * @note Low_g interrupt trigger threshold according to
- * (v_low_g_thres_u8 * 7.81)mg for v_low_g_thres_u8 > 0
- * 3.91 mg for v_low_g_thres_u8 = 0
- * The threshold range is form 3.91mg to 2.000mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_thres(
-u8 v_low_g_thres_u8);
-/***************************************************************/
-/**\name FUNCTION FOR LOW_G HYSTERESIS CONFIGURATION */
-/***************************************************************/
- /*!
- * @brief This API Reads Low-g interrupt hysteresis
- * from the register 0x5C bit 0 to 1
- *
- * @param v_low_hyst_u8 :The value of low_g hysteresis
- *
- * @note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_hyst(
-u8 *v_low_hyst_u8);
- /*!
- * @brief This API write Low-g interrupt hysteresis
- * from the register 0x5C bit 0 to 1
- *
- * @param v_low_hyst_u8 :The value of low_g hysteresis
- *
- * @note Low_g hysteresis calculated by v_low_hyst_u8*125 mg
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_hyst(
-u8 v_low_hyst_u8);
-/***************************************************************/
-/**\name FUNCTION FOR LOW_G MODE CONFIGURATION */
-/***************************************************************/
-/*!
- * @brief This API reads Low-g interrupt mode
- * from the register 0x5C bit 2
- *
- * @param v_low_g_mode_u8 : The value of low_g mode
- * Value | Description
- * ----------|-----------------
- * 0 | single-axis
- * 1 | axis-summing
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_low_g_mode(
-u8 *v_low_g_mode_u8);
-/*!
- * @brief This API write Low-g interrupt mode
- * from the register 0x5C bit 2
- *
- * @param v_low_g_mode_u8 : The value of low_g mode
- * Value | Description
- * ----------|-----------------
- * 0 | single-axis
- * 1 | axis-summing
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_low_g_mode(
-u8 v_low_g_mode_u8);
-/***************************************************************/
-/**\name FUNCTION FOR HIGH_G HYST CONFIGURATION */
-/***************************************************************/
-/*!
- * @brief This API reads High-g interrupt hysteresis
- * from the register 0x5C bit 6 and 7
- *
- * @param v_high_g_hyst_u8 : The value of high hysteresis
- *
- * @note High_g hysteresis changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | high_g hysteresis
- * ----------------|---------------------
- * 2g | high_hy*125 mg
- * 4g | high_hy*250 mg
- * 8g | high_hy*500 mg
- * 16g | high_hy*1000 mg
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_hyst(
-u8 *v_high_g_hyst_u8);
-/*!
- * @brief This API write High-g interrupt hysteresis
- * from the register 0x5C bit 6 and 7
- *
- * @param v_high_g_hyst_u8 : The value of high hysteresis
- *
- * @note High_g hysteresis changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | high_g hysteresis
- * ----------------|---------------------
- * 2g | high_hy*125 mg
- * 4g | high_hy*250 mg
- * 8g | high_hy*500 mg
- * 16g | high_hy*1000 mg
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_hyst(
-u8 v_high_g_hyst_u8);
-/***************************************************************/
-/**\name FUNCTION FOR HIGH_G DURATION CONFIGURATION */
-/***************************************************************/
-/*!
- * @brief This API is used to read Delay
- * time definition for the high-g interrupt from the register
- * 0x5D bit 0 to 7
- *
- *
- *
- * @param v_high_g_durn_u8 : The value of high duration
- *
- * @note High_g interrupt delay triggered according to
- * v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_durn(
-u8 *v_high_g_durn_u8);
-/*!
- * @brief This API is used to write Delay
- * time definition for the high-g interrupt from the register
- * 0x5D bit 0 to 7
- *
- *
- *
- * @param v_high_g_durn_u8 : The value of high duration
- *
- * @note High_g interrupt delay triggered according to
- * v_high_g_durn_u8 * 2.5ms in a range from 2.5ms to 640ms
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_durn(
-u8 v_high_g_durn_u8);
-/***************************************************************/
-/**\name FUNCTION FOR HIGH_G THRESHOLD CONFIGURATION */
-/***************************************************************/
-/*!
- * @brief This API is used to read Threshold
- * definition for the high-g interrupt from the register 0x5E 0 to 7
- *
- *
- *
- *
- * @param v_high_g_thres_u8 : Pointer holding the value of Threshold
- * @note High_g threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | high_g threshold
- * ----------------|---------------------
- * 2g | v_high_g_thres_u8*7.81 mg
- * 4g | v_high_g_thres_u8*15.63 mg
- * 8g | v_high_g_thres_u8*31.25 mg
- * 16g | v_high_g_thres_u8*62.5 mg
- * @note when v_high_g_thres_u8 = 0
- * accel_range | high_g threshold
- * ----------------|---------------------
- * 2g | 3.91 mg
- * 4g | 7.81 mg
- * 8g | 15.63 mg
- * 16g | 31.25 mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_high_g_thres(
-u8 *v_high_g_thres_u8);
-/*!
- * @brief This API is used to write Threshold
- * definition for the high-g interrupt from the register 0x5E 0 to 7
- *
- *
- *
- *
- * @param v_high_g_thres_u8 : Pointer holding the value of Threshold
- * @note High_g threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | high_g threshold
- * ----------------|---------------------
- * 2g | v_high_g_thres_u8*7.81 mg
- * 4g | v_high_g_thres_u8*15.63 mg
- * 8g | v_high_g_thres_u8*31.25 mg
- * 16g | v_high_g_thres_u8*62.5 mg
- * @note when v_high_g_thres_u8 = 0
- * accel_range | high_g threshold
- * ----------------|---------------------
- * 2g | 3.91 mg
- * 4g | 7.81 mg
- * 8g | 15.63 mg
- * 16g | 31.25 mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_high_g_thres(
-u8 v_high_g_thres_u8);
-/***************************************************************/
-/**\name FUNCTION FOR ANY MOTION DURATION CONFIGURATION */
-/***************************************************************/
-/*!
- * @brief This API reads any motion duration
- * from the register 0x5F bit 0 and 1
- *
- * @param v_any_motion_durn_u8 : The value of any motion duration
- *
- * @note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion_durn(
-u8 *v_any_motion_durn_u8);
-/*!
- * @brief This API write any motion duration
- * from the register 0x5F bit 0 and 1
- *
- * @param v_any_motion_durn_u8 : The value of any motion duration
- *
- * @note Any motion duration can be calculated by "v_any_motion_durn_u8 + 1"
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion_durn(
-u8 nomotion);
-/***************************************************************/
-/**\name FUNCTION FOR SLOW NO MOTION DURATION CONFIGURATION */
-/***************************************************************/
- /*!
- * @brief This API read Slow/no-motion
- * interrupt trigger delay duration from the register 0x5F bit 2 to 7
- *
- * @param v_slow_no_motion_u8 :The value of slow no motion duration
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- * @note
- * @note v_slow_no_motion_u8(5:4)=0b00 ->
- * [v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
- * @note v_slow_no_motion_u8(5:4)=1 ->
- * [v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
- * @note v_slow_no_motion_u8(5)='1' ->
- * [(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_durn(
-u8 *v_slow_no_motion_u8);
- /*!
- * @brief This API write Slow/no-motion
- * interrupt trigger delay duration from the register 0x5F bit 2 to 7
- *
- * @param v_slow_no_motion_u8 :The value of slow no motion duration
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- * @note
- * @note v_slow_no_motion_u8(5:4)=0b00 ->
- * [v_slow_no_motion_u8(3:0) + 1] * 1.28s (1.28s-20.48s)
- * @note v_slow_no_motion_u8(5:4)=1 ->
- * [v_slow_no_motion_u8(3:0)+5] * 5.12s (25.6s-102.4s)
- * @note v_slow_no_motion_u8(5)='1' ->
- * [(v_slow_no_motion_u8:0)+11] * 10.24s (112.64s-430.08s);
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_durn(
-u8 v_slow_no_motion_u8);
-/***************************************************************/
-/**\name FUNCTION FOR ANY MOTION THRESHOLD CONFIGURATION */
-/***************************************************************/
-/*!
- * @brief This API is used to read threshold
- * definition for the any-motion interrupt
- * from the register 0x60 bit 0 to 7
- *
- *
- * @param v_any_motion_thres_u8 : The value of any motion threshold
- *
- * @note any motion threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | any motion threshold
- * ----------------|---------------------
- * 2g | v_any_motion_thres_u8*3.91 mg
- * 4g | v_any_motion_thres_u8*7.81 mg
- * 8g | v_any_motion_thres_u8*15.63 mg
- * 16g | v_any_motion_thres_u8*31.25 mg
- * @note when v_any_motion_thres_u8 = 0
- * accel_range | any motion threshold
- * ----------------|---------------------
- * 2g | 1.95 mg
- * 4g | 3.91 mg
- * 8g | 7.81 mg
- * 16g | 15.63 mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_any_motion_thres(
-u8 *v_any_motion_thres_u8);
-/*!
- * @brief This API is used to write threshold
- * definition for the any-motion interrupt
- * from the register 0x60 bit 0 to 7
- *
- *
- * @param v_any_motion_thres_u8 : The value of any motion threshold
- *
- * @note any motion threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | any motion threshold
- * ----------------|---------------------
- * 2g | v_any_motion_thres_u8*3.91 mg
- * 4g | v_any_motion_thres_u8*7.81 mg
- * 8g | v_any_motion_thres_u8*15.63 mg
- * 16g | v_any_motion_thres_u8*31.25 mg
- * @note when v_any_motion_thres_u8 = 0
- * accel_range | any motion threshold
- * ----------------|---------------------
- * 2g | 1.95 mg
- * 4g | 3.91 mg
- * 8g | 7.81 mg
- * 16g | 15.63 mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_any_motion_thres(
-u8 v_any_motion_thres_u8);
-/***************************************************************/
-/**\name FUNCTION FOR SLO/NO MOTION THRESHOLD CONFIGURATION */
-/***************************************************************/
- /*!
- * @brief This API is used to read threshold
- * for the slow/no-motion interrupt
- * from the register 0x61 bit 0 to 7
- *
- *
- *
- *
- * @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
- * @note slow no motion threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | slow no motion threshold
- * ----------------|---------------------
- * 2g | v_slow_no_motion_thres_u8*3.91 mg
- * 4g | v_slow_no_motion_thres_u8*7.81 mg
- * 8g | v_slow_no_motion_thres_u8*15.63 mg
- * 16g | v_slow_no_motion_thres_u8*31.25 mg
- * @note when v_slow_no_motion_thres_u8 = 0
- * accel_range | slow no motion threshold
- * ----------------|---------------------
- * 2g | 1.95 mg
- * 4g | 3.91 mg
- * 8g | 7.81 mg
- * 16g | 15.63 mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_thres(
-u8 *v_slow_no_motion_thres_u8);
- /*!
- * @brief This API is used to write threshold
- * for the slow/no-motion interrupt
- * from the register 0x61 bit 0 to 7
- *
- *
- *
- *
- * @param v_slow_no_motion_thres_u8 : The value of slow no motion threshold
- * @note slow no motion threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | slow no motion threshold
- * ----------------|---------------------
- * 2g | v_slow_no_motion_thres_u8*3.91 mg
- * 4g | v_slow_no_motion_thres_u8*7.81 mg
- * 8g | v_slow_no_motion_thres_u8*15.63 mg
- * 16g | v_slow_no_motion_thres_u8*31.25 mg
- * @note when v_slow_no_motion_thres_u8 = 0
- * accel_range | slow no motion threshold
- * ----------------|---------------------
- * 2g | 1.95 mg
- * 4g | 3.91 mg
- * 8g | 7.81 mg
- * 16g | 15.63 mg
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_thres(
-u8 v_slow_no_motion_thres_u8);
-/***************************************************************/
-/**\name FUNCTION FOR SLO/NO MOTION SELECT CONFIGURATION */
-/***************************************************************/
- /*!
- * @brief This API is used to read
- * the slow/no-motion selection from the register 0x62 bit 0
- *
- *
- *
- *
- * @param v_intr_slow_no_motion_select_u8 :
- * The value of slow/no-motion select
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | SLOW_MOTION
- * 0x01 | NO_MOTION
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_slow_no_motion_select(
-u8 *v_intr_slow_no_motion_select_u8);
- /*!
- * @brief This API is used to write
- * the slow/no-motion selection from the register 0x62 bit 0
- *
- *
- *
- *
- * @param v_intr_slow_no_motion_select_u8 :
- * The value of slow/no-motion select
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | SLOW_MOTION
- * 0x01 | NO_MOTION
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_slow_no_motion_select(
-u8 v_intr_slow_no_motion_select_u8);
-/***************************************************************/
-/**\name FUNCTION FOR SIGNIFICANT MOTION SELECT CONFIGURATION*/
-/***************************************************************/
- /*!
- * @brief This API is used to select
- * the significant or any motion interrupt from the register 0x62 bit 1
- *
- *
- *
- *
- * @param v_intr_significant_motion_select_u8 :
- * the value of significant or any motion interrupt selection
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | ANY_MOTION
- * 0x01 | SIGNIFICANT_MOTION
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_select(
-u8 *int_sig_mot_sel);
- /*!
- * @brief This API is used to write, select
- * the significant or any motion interrupt from the register 0x62 bit 1
- *
- *
- *
- *
- * @param v_intr_significant_motion_select_u8 :
- * the value of significant or any motion interrupt selection
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | ANY_MOTION
- * 0x01 | SIGNIFICANT_MOTION
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_select(
-u8 int_sig_mot_sel);
- /*!
- * @brief This API is used to read
- * the significant skip time from the register 0x62 bit 2 and 3
- *
- *
- *
- *
- * @param v_int_sig_mot_skip_u8 : the value of significant skip time
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | skip time 1.5 seconds
- * 0x01 | skip time 3 seconds
- * 0x02 | skip time 6 seconds
- * 0x03 | skip time 12 seconds
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_skip(
-u8 *v_int_sig_mot_skip_u8);
- /*!
- * @brief This API is used to write
- * the significant skip time from the register 0x62 bit 2 and 3
- *
- *
- *
- *
- * @param v_int_sig_mot_skip_u8 : the value of significant skip time
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | skip time 1.5 seconds
- * 0x01 | skip time 3 seconds
- * 0x02 | skip time 6 seconds
- * 0x03 | skip time 12 seconds
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_skip(
-u8 v_int_sig_mot_skip_u8);
- /*!
- * @brief This API is used to read
- * the significant proof time from the register 0x62 bit 4 and 5
- *
- *
- *
- *
- * @param v_significant_motion_proof_u8 :
- * the value of significant proof time
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | proof time 0.25 seconds
- * 0x01 | proof time 0.5 seconds
- * 0x02 | proof time 1 seconds
- * 0x03 | proof time 2 seconds
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_significant_motion_proof(
-u8 *int_sig_mot_proof);
- /*!
- * @brief This API is used to write
- * the significant proof time from the register 0x62 bit 4 and 5
- *
- *
- *
- *
- * @param v_significant_motion_proof_u8 :
- * the value of significant proof time
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | proof time 0.25 seconds
- * 0x01 | proof time 0.5 seconds
- * 0x02 | proof time 1 seconds
- * 0x03 | proof time 2 seconds
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_significant_motion_proof(
-u8 int_sig_mot_proof);
-/***************************************************************/
-/**\name FUNCTION FOR TAP DURATION CONFIGURATION*/
-/***************************************************************/
-/*!
- * @brief This API is used to get the tap duration
- * from the register 0x63 bit 0 to 2
- *
- *
- *
- * @param v_tap_durn_u8 : The value of tap duration
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | BMI160_TAP_DURN_50MS
- * 0x01 | BMI160_TAP_DURN_100MS
- * 0x03 | BMI160_TAP_DURN_150MS
- * 0x04 | BMI160_TAP_DURN_200MS
- * 0x05 | BMI160_TAP_DURN_250MS
- * 0x06 | BMI160_TAP_DURN_375MS
- * 0x07 | BMI160_TAP_DURN_700MS
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_durn(
-u8 *v_tap_durn_u8);
-/*!
- * @brief This API is used to write the tap duration
- * from the register 0x63 bit 0 to 2
- *
- *
- *
- * @param v_tap_durn_u8 : The value of tap duration
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | BMI160_TAP_DURN_50MS
- * 0x01 | BMI160_TAP_DURN_100MS
- * 0x03 | BMI160_TAP_DURN_150MS
- * 0x04 | BMI160_TAP_DURN_200MS
- * 0x05 | BMI160_TAP_DURN_250MS
- * 0x06 | BMI160_TAP_DURN_375MS
- * 0x07 | BMI160_TAP_DURN_700MS
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_durn(
-u8 v_tap_durn_u8);
-/***************************************************************/
-/**\name FUNCTION FOR TAP SHOCK CONFIGURATION*/
-/***************************************************************/
- /*!
- * @brief This API read the
- * tap shock duration from the register 0x63 bit 2
- *
- * @param v_tap_shock_u8 :The value of tap shock
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | BMI160_TAP_SHOCK_50MS
- * 0x01 | BMI160_TAP_SHOCK_75MS
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_shock(
-u8 *v_tap_shock_u8);
- /*!
- * @brief This API write the
- * tap shock duration from the register 0x63 bit 2
- *
- * @param v_tap_shock_u8 :The value of tap shock
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | BMI160_TAP_SHOCK_50MS
- * 0x01 | BMI160_TAP_SHOCK_75MS
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_shock(
-u8 v_tap_shock_u8);
-/***************************************************************/
-/**\name FUNCTION FOR TAP QUIET CONFIGURATION*/
-/***************************************************************/
-/*!
- * @brief This API read
- * tap quiet duration from the register 0x63 bit 7
- *
- *
- * @param v_tap_quiet_u8 : The value of tap quiet
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | BMI160_TAP_QUIET_30MS
- * 0x01 | BMI160_TAP_QUIET_20MS
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_quiet(
-u8 *v_tap_quiet_u8);
-/*!
- * @brief This API write
- * tap quiet duration from the register 0x63 bit 7
- *
- *
- * @param v_tap_quiet_u8 : The value of tap quiet
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | BMI160_TAP_QUIET_30MS
- * 0x01 | BMI160_TAP_QUIET_20MS
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_quiet(
-u8 v_tap_quiet_u8);
-/***************************************************************/
-/**\name FUNCTION FOR TAP THRESHOLD CONFIGURATION*/
-/***************************************************************/
- /*!
- * @brief This API read Threshold of the
- * single/double tap interrupt from the register 0x64 bit 0 to 4
- *
- *
- * @param v_tap_thres_u8 : The value of single/double tap threshold
- *
- * @note single/double tap threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | single/double tap threshold
- * ----------------|---------------------
- * 2g | ((v_tap_thres_u8 + 1) * 62.5)mg
- * 4g | ((v_tap_thres_u8 + 1) * 125)mg
- * 8g | ((v_tap_thres_u8 + 1) * 250)mg
- * 16g | ((v_tap_thres_u8 + 1) * 500)mg
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_tap_thres(
-u8 *v_tap_thres_u8);
- /*!
- * @brief This API write Threshold of the
- * single/double tap interrupt from the register 0x64 bit 0 to 4
- *
- *
- * @param v_tap_thres_u8 : The value of single/double tap threshold
- *
- * @note single/double tap threshold changes according to accel g range
- * accel g range can be set by the function ""
- * accel_range | single/double tap threshold
- * ----------------|---------------------
- * 2g | ((v_tap_thres_u8 + 1) * 62.5)mg
- * 4g | ((v_tap_thres_u8 + 1) * 125)mg
- * 8g | ((v_tap_thres_u8 + 1) * 250)mg
- * 16g | ((v_tap_thres_u8 + 1) * 500)mg
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_tap_thres(
-u8 v_tap_thres_u8);
-/***************************************************************/
-/**\name FUNCTION FOR ORIENT MODE CONFIGURATION*/
-/***************************************************************/
- /*!
- * @brief This API read the threshold for orientation interrupt
- * from the register 0x65 bit 0 and 1
- *
- * @param v_orient_mode_u8 : The value of threshold for orientation
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | symmetrical
- * 0x01 | high-asymmetrical
- * 0x02 | low-asymmetrical
- * 0x03 | symmetrical
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_mode(
-u8 *v_orient_mode_u8);
- /*!
- * @brief This API write the threshold for orientation interrupt
- * from the register 0x65 bit 0 and 1
- *
- * @param v_orient_mode_u8 : The value of threshold for orientation
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | symmetrical
- * 0x01 | high-asymmetrical
- * 0x02 | low-asymmetrical
- * 0x03 | symmetrical
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_mode(
-u8 v_orient_mode_u8);
-/***************************************************************/
-/**\name FUNCTION FOR ORIENT BLOCKING CONFIGURATION*/
-/***************************************************************/
-/*!
- * @brief This API read the orient blocking mode
- * that is used for the generation of the orientation interrupt.
- * from the register 0x65 bit 2 and 3
- *
- * @param v_orient_blocking_u8 : The value of orient blocking mode
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | No blocking
- * 0x01 | Theta blocking or acceleration in any axis > 1.5g
- * 0x02 | Theta blocking or acceleration slope in any axis >
- * - | 0.2g or acceleration in any axis > 1.5g
- * 0x03 | Theta blocking or acceleration slope in any axis >
- * - | 0.4g or acceleration in any axis >
- * - | 1.5g and value of orient is not stable
- * - | for at least 100 ms
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_blocking(
-u8 *v_orient_blocking_u8);
-/*!
- * @brief This API write the orient blocking mode
- * that is used for the generation of the orientation interrupt.
- * from the register 0x65 bit 2 and 3
- *
- * @param v_orient_blocking_u8 : The value of orient blocking mode
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | No blocking
- * 0x01 | Theta blocking or acceleration in any axis > 1.5g
- * 0x02 | Theta blocking or acceleration slope in any axis >
- * - | 0.2g or acceleration in any axis > 1.5g
- * 0x03 | Theta blocking or acceleration slope in any axis >
- * - | 0.4g or acceleration in any axis >
- * - | 1.5g and value of orient is not stable
- * - | for at least 100 ms
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_blocking(
-u8 v_orient_blocking_u8);
-/***************************************************************/
-/**\name FUNCTION FOR ORIENT HYSTERESIS CONFIGURATION*/
-/***************************************************************/
-/*!
- * @brief This API read Orient interrupt
- * hysteresis, from the register 0x64 bit 4 to 7
- *
- *
- *
- * @param v_orient_hyst_u8 : The value of orient hysteresis
- *
- * @note 1 LSB corresponds to 62.5 mg,
- * irrespective of the selected accel range
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_hyst(
-u8 *v_orient_hyst_u8);
-/*!
- * @brief This API write Orient interrupt
- * hysteresis, from the register 0x64 bit 4 to 7
- *
- *
- *
- * @param v_orient_hyst_u8 : The value of orient hysteresis
- *
- * @note 1 LSB corresponds to 62.5 mg,
- * irrespective of the selected accel range
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_hyst(
-u8 v_orient_hyst_u8);
-/***************************************************************/
-/**\name FUNCTION FOR ORIENT THETA CONFIGURATION*/
-/***************************************************************/
- /*!
- * @brief This API read Orient
- * blocking angle (0 to 44.8) from the register 0x66 bit 0 to 5
- *
- * @param v_orient_theta_u8 : The value of Orient blocking angle
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_theta(
-u8 *v_orient_theta_u8);
- /*!
- * @brief This API write Orient
- * blocking angle (0 to 44.8) from the register 0x66 bit 0 to 5
- *
- * @param v_orient_theta_u8 : The value of Orient blocking angle
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_theta(
-u8 v_orient_theta_u8);
-/***************************************************************/
-/**\name FUNCTION FOR ORIENT OUTPUT ENABLE CONFIGURATION*/
-/***************************************************************/
-/*!
- * @brief This API read orient change
- * of up/down bit from the register 0x66 bit 6
- *
- * @param v_orient_ud_u8 : The value of orient change of up/down
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | Is ignored
- * 0x01 | Generates orientation interrupt
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_ud_enable(
-u8 *v_orient_ud_u8);
-/*!
- * @brief This API write orient change
- * of up/down bit from the register 0x66 bit 6
- *
- * @param v_orient_ud_u8 : The value of orient change of up/down
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | Is ignored
- * 0x01 | Generates orientation interrupt
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_ud_enable(
-u8 v_orient_ud_u8);
-/***************************************************************/
-/**\name FUNCTION FOR ORIENT AXIS ENABLE CONFIGURATION*/
-/***************************************************************/
- /*!
- * @brief This API read orientation axes changes
- * from the register 0x66 bit 7
- *
- * @param v_orient_axes_u8 : The value of orient axes assignment
- * value | Behaviour | Name
- * ----------|--------------------|------
- * 0x00 | x = x, y = y, z = z|orient_ax_noex
- * 0x01 | x = y, y = z, z = x|orient_ax_ex
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_orient_axes_enable(
-u8 *v_orient_axes_u8);
- /*!
- * @brief This API write orientation axes changes
- * from the register 0x66 bit 7
- *
- * @param v_orient_axes_u8 : The value of orient axes assignment
- * value | Behaviour | Name
- * ----------|--------------------|------
- * 0x00 | x = x, y = y, z = z|orient_ax_noex
- * 0x01 | x = y, y = z, z = x|orient_ax_ex
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_orient_axes_enable(
-u8 v_orient_axes_u8);
-/***************************************************************/
-/**\name FUNCTION FOR FLAT THETA CONFIGURATION*/
-/***************************************************************/
- /*!
- * @brief This API read Flat angle (0 to 44.8) for flat interrupt
- * from the register 0x67 bit 0 to 5
- *
- * @param v_flat_theta_u8 : The value of flat angle
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_theta(
-u8 *v_flat_theta_u8);
- /*!
- * @brief This API write Flat angle (0 to 44.8) for flat interrupt
- * from the register 0x67 bit 0 to 5
- *
- * @param v_flat_theta_u8 : The value of flat angle
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_theta(
-u8 v_flat_theta_u8);
-/***************************************************************/
-/**\name FUNCTION FOR FLAT HOLD CONFIGURATION*/
-/***************************************************************/
-/*!
- * @brief This API read Flat interrupt hold time;
- * from the register 0x68 bit 4 and 5
- *
- * @param v_flat_hold_u8 : The value of flat hold time
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | 0ms
- * 0x01 | 512ms
- * 0x01 | 1024ms
- * 0x01 | 2048ms
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_hold(
-u8 *v_flat_hold_u8);
-/*!
- * @brief This API write Flat interrupt hold time;
- * from the register 0x68 bit 4 and 5
- *
- * @param v_flat_hold_u8 : The value of flat hold time
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | 0ms
- * 0x01 | 512ms
- * 0x01 | 1024ms
- * 0x01 | 2048ms
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_hold(
-u8 v_flat_hold_u8);
-/***************************************************************/
-/**\name FUNCTION FOR FLAT HYSTERESIS CONFIGURATION*/
-/***************************************************************/
-/*!
- * @brief This API read flat interrupt hysteresis
- * from the register 0x68 bit 0 to 3
- *
- * @param v_flat_hyst_u8 : The value of flat hysteresis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_intr_flat_hyst(
-u8 *v_flat_hyst_u8);
-/*!
- * @brief This API write flat interrupt hysteresis
- * from the register 0x68 bit 0 to 3
- *
- * @param v_flat_hyst_u8 : The value of flat hysteresis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_intr_flat_hyst(
-u8 v_flat_hyst_u8);
-/***************************************************************/
-/**\name FUNCTION FAST OFFSET COMPENSATION FOR ACCEL */
-/***************************************************************/
- /*!
- * @brief This API read accel offset compensation
- * target value for z-axis from the register 0x69 bit 0 and 1
- *
- * @param v_foc_accel_z_u8 : the value of accel offset compensation z axis
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_z(
-u8 *v_foc_accel_z_u8);
- /*!
- * @brief This API write accel offset compensation
- * target value for z-axis from the register 0x69 bit 0 and 1
- *
- * @param v_foc_accel_z_u8 : the value of accel offset compensation z axis
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_z(
-u8 v_foc_accel_z_u8);
-/*!
- * @brief This API read accel offset compensation
- * target value for y-axis
- * from the register 0x69 bit 2 and 3
- *
- * @param v_foc_accel_y_u8 : the value of accel offset compensation y axis
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_y(
-u8 *v_foc_accel_y_u8);
-/*!
- * @brief This API write accel offset compensation
- * target value for y-axis
- * from the register 0x69 bit 2 and 3
- *
- * @param v_foc_accel_y_u8 : the value of accel offset compensation y axis
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_y(
-u8 v_foc_accel_y_u8);
-/*!
- * @brief This API read accel offset compensation
- * target value for x-axis is
- * from the register 0x69 bit 4 and 5
- *
- * @param v_foc_accel_x_u8 : the value of accel offset compensation x axis
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_accel_x(
-u8 *v_foc_accel_x_u8);
-/*!
- * @brief This API write accel offset compensation
- * target value for x-axis is
- * from the register 0x69 bit 4 and 5
- *
- * @param v_foc_accel_x_u8 : the value of accel offset compensation x axis
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_accel_x(
-u8 v_foc_accel_x_u8);
-/***************************************************************/
-/**\name FUNCTION FAST OFFSET COMPENSATION FOR GYRO */
-/***************************************************************/
-/*!
- * @brief This API write gyro fast offset enable
- * from the register 0x69 bit 6
- *
- * @param v_foc_gyro_u8 : The value of gyro fast offset enable
- * value | Description
- * ----------|-------------
- * 0 | fast offset compensation disabled
- * 1 | fast offset compensation enabled
- *
- * @param v_gyro_off_x_s16 : The value of gyro fast offset x axis data
- * @param v_gyro_off_y_s16 : The value of gyro fast offset y axis data
- * @param v_gyro_off_z_s16 : The value of gyro fast offset z axis data
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_foc_gyro_enable(
-u8 v_foc_gyro_u8, s16 *v_gyro_off_x_s16,
-s16 *v_gyro_off_y_s16, s16 *v_gyro_off_z_s16);
-/***************************************************/
-/**\name FUNCTION FOR NVM*/
-/***************************************************/
- /*!
- * @brief This API read NVM program enable
- * from the register 0x6A bit 1
- *
- * @param v_nvm_prog_u8 : The value of NVM program enable
- * Value | Description
- * --------|-------------
- * 0 | DISABLE
- * 1 | ENABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_nvm_prog_enable(
-u8 *v_nvm_prog_u8);
- /*!
- * @brief This API write NVM program enable
- * from the register 0x6A bit 1
- *
- * @param v_nvm_prog_u8 : The value of NVM program enable
- * Value | Description
- * --------|-------------
- * 0 | DISABLE
- * 1 | ENABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_nvm_prog_enable(
-u8 v_nvm_prog_u8);
-/***************************************************/
-/**\name FUNCTION FOR SPI MODE*/
-/***************************************************/
-/*!
- * @brief This API read to configure SPI
- * Interface Mode for primary and OIS interface
- * from the register 0x6B bit 0
- *
- * @param v_spi3_u8 : The value of SPI mode selection
- * Value | Description
- * --------|-------------
- * 0 | SPI 4-wire mode
- * 1 | SPI 3-wire mode
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_spi3(
-u8 *v_spi3_u8);
-/*!
- * @brief This API write to configure SPI
- * Interface Mode for primary and OIS interface
- * from the register 0x6B bit 0
- *
- * @param v_spi3_u8 : The value of SPI mode selection
- * Value | Description
- * --------|-------------
- * 0 | SPI 4-wire mode
- * 1 | SPI 3-wire mode
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_spi3(
-u8 v_spi3_u8);
-/***************************************************/
-/**\name FUNCTION FOR FOC GYRO */
-/***************************************************/
-/*!
- * @brief This API read gyro fast offset enable
- * from the register 0x69 bit 6
- *
- * @param v_foc_gyro_u8 : The value of gyro fast offset enable
- * value | Description
- * ----------|-------------
- * 0 | fast offset compensation disabled
- * 1 | fast offset compensation enabled
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_foc_gyro_enable(
-u8 *v_foc_gyro_u8);
-/***************************************************/
-/**\name FUNCTION FOR I2C WATCHDOG TIMBER */
-/***************************************************/
-/*!
- * @brief This API read I2C Watchdog timer
- * from the register 0x70 bit 1
- *
- * @param v_i2c_wdt_u8 : The value of I2C watch dog timer
- * Value | Description
- * --------|-------------
- * 0 | I2C watchdog v_timeout_u8 after 1 ms
- * 1 | I2C watchdog v_timeout_u8 after 50 ms
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_wdt_select(
-u8 *v_i2c_wdt_u8);
-/*!
- * @brief This API write I2C Watchdog timer
- * from the register 0x70 bit 1
- *
- * @param v_i2c_wdt_u8 : The value of I2C watch dog timer
- * Value | Description
- * --------|-------------
- * 0 | I2C watchdog v_timeout_u8 after 1 ms
- * 1 | I2C watchdog v_timeout_u8 after 50 ms
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE
-bmi160_set_i2c_wdt_select(u8 v_i2c_wdt_u8);
-/*!
- * @brief This API read I2C watchdog enable
- * from the register 0x70 bit 2
- *
- * @param v_i2c_wdt_u8 : The value of I2C watchdog enable
- * Value | Description
- * --------|-------------
- * 0 | DISABLE
- * 1 | ENABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_i2c_wdt_enable(
-u8 *v_i2c_wdt_u8);
-/*!
- * @brief This API write I2C watchdog enable
- * from the register 0x70 bit 2
- *
- * @param v_i2c_wdt_u8 : The value of I2C watchdog enable
- * Value | Description
- * --------|-------------
- * 0 | DISABLE
- * 1 | ENABLE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_i2c_wdt_enable(
-u8 v_i2c_wdt_u8);
-/***************************************************/
-/**\name FUNCTION FOR IF MODE*/
-/***************************************************/
-/*!
- * @brief This API read I2C interface configuration(if) moe
- * from the register 0x6B bit 4 and 5
- *
- * @param v_if_mode_u8 : The value of interface configuration mode
- * Value | Description
- * --------|-------------
- * 0x00 | Primary interface:autoconfig / secondary interface:off
- * 0x01 | Primary interface:I2C / secondary interface:OIS
- * 0x02 | Primary interface:autoconfig/secondary interface:Magnetometer
- * 0x03 | Reserved
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_if_mode(
-u8 *v_if_mode_u8);
-/*!
- * @brief This API write I2C interface configuration(if) moe
- * from the register 0x6B bit 4 and 5
- *
- * @param v_if_mode_u8 : The value of interface configuration mode
- * Value | Description
- * --------|-------------
- * 0x00 | Primary interface:autoconfig / secondary interface:off
- * 0x01 | Primary interface:I2C / secondary interface:OIS
- * 0x02 | Primary interface:autoconfig/secondary interface:Magnetometer
- * 0x03 | Reserved
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_if_mode(
-u8 v_if_mode_u8);
-/***************************************************/
-/**\name FUNCTION FOR GYRO SLEEP TRIGGER INTERRUPT CONFIGURATION*/
-/***************************************************/
-/*!
- * @brief This API read gyro sleep trigger
- * from the register 0x6C bit 0 to 2
- *
- * @param v_gyro_sleep_trigger_u8 : The value of gyro sleep trigger
- * Value | Description
- * --------|-------------
- * 0x00 | nomotion: no / Not INT1 pin: no / INT2 pin: no
- * 0x01 | nomotion: no / Not INT1 pin: no / INT2 pin: yes
- * 0x02 | nomotion: no / Not INT1 pin: yes / INT2 pin: no
- * 0x03 | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
- * 0x04 | nomotion: yes / Not INT1 pin: no / INT2 pin: no
- * 0x05 | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
- * 0x06 | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
- * 0x07 | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_sleep_trigger(
-u8 *v_gyro_sleep_trigger_u8);
-/*!
- * @brief This API write gyro sleep trigger
- * from the register 0x6C bit 0 to 2
- *
- * @param v_gyro_sleep_trigger_u8 : The value of gyro sleep trigger
- * Value | Description
- * --------|-------------
- * 0x00 | nomotion: no / Not INT1 pin: no / INT2 pin: no
- * 0x01 | nomotion: no / Not INT1 pin: no / INT2 pin: yes
- * 0x02 | nomotion: no / Not INT1 pin: yes / INT2 pin: no
- * 0x03 | nomotion: no / Not INT1 pin: yes / INT2 pin: yes
- * 0x04 | nomotion: yes / Not INT1 pin: no / INT2 pin: no
- * 0x05 | anymotion: yes / Not INT1 pin: no / INT2 pin: yes
- * 0x06 | anymotion: yes / Not INT1 pin: yes / INT2 pin: no
- * 0x07 | anymotion: yes / Not INT1 pin: yes / INT2 pin: yes
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_sleep_trigger(
-u8 v_gyro_sleep_trigger_u8);
-/*!
- * @brief This API read gyro wakeup trigger
- * from the register 0x6C bit 3 and 4
- *
- * @param v_gyro_wakeup_trigger_u8 : The value of gyro wakeup trigger
- * Value | Description
- * --------|-------------
- * 0x00 | anymotion: no / INT1 pin: no
- * 0x01 | anymotion: no / INT1 pin: yes
- * 0x02 | anymotion: yes / INT1 pin: no
- * 0x03 | anymotion: yes / INT1 pin: yes
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_wakeup_trigger(
-u8 *v_gyro_wakeup_trigger_u8);
-/*!
- * @brief This API write gyro wakeup trigger
- * from the register 0x6C bit 3 and 4
- *
- * @param v_gyro_wakeup_trigger_u8 : The value of gyro wakeup trigger
- * Value | Description
- * --------|-------------
- * 0x00 | anymotion: no / INT1 pin: no
- * 0x01 | anymotion: no / INT1 pin: yes
- * 0x02 | anymotion: yes / INT1 pin: no
- * 0x03 | anymotion: yes / INT1 pin: yes
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_wakeup_trigger(
-u8 v_gyro_wakeup_trigger_u8);
-/*!
- * @brief This API read Target state for gyro sleep mode
- * from the register 0x6C bit 5
- *
- * @param v_gyro_sleep_state_u8 : The value of gyro sleep mode
- * Value | Description
- * --------|-------------
- * 0x00 | Sleep transition to fast wake up state
- * 0x01 | Sleep transition to suspend state
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_sleep_state(
-u8 *v_gyro_sleep_state_u8);
-/*!
- * @brief This API write Target state for gyro sleep mode
- * from the register 0x6C bit 5
- *
- * @param v_gyro_sleep_state_u8 : The value of gyro sleep mode
- * Value | Description
- * --------|-------------
- * 0x00 | Sleep transition to fast wake up state
- * 0x01 | Sleep transition to suspend state
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_sleep_state(
-u8 v_gyro_sleep_state_u8);
-/*!
- * @brief This API read gyro wakeup interrupt
- * from the register 0x6C bit 6
- *
- * @param v_gyro_wakeup_intr_u8 : The valeu of gyro wakeup interrupt
- * Value | Description
- * --------|-------------
- * 0x00 | DISABLE
- * 0x01 | ENABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_wakeup_intr(
-u8 *v_gyro_wakeup_intr_u8);
-/*!
- * @brief This API write gyro wakeup interrupt
- * from the register 0x6C bit 6
- *
- * @param v_gyro_wakeup_intr_u8 : The valeu of gyro wakeup interrupt
- * Value | Description
- * --------|-------------
- * 0x00 | DISABLE
- * 0x01 | ENABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_wakeup_intr(
-u8 v_gyro_wakeup_intr_u8);
-/***************************************************/
-/**\name FUNCTION FOR ACCEL SELF TEST */
-/***************************************************/
-/*!
- * @brief This API read accel select axis to be self-test
- *
- * @param v_accel_selftest_axis_u8 :
- * The value of accel self test axis selection
- * Value | Description
- * --------|-------------
- * 0x00 | disabled
- * 0x01 | x-axis
- * 0x02 | y-axis
- * 0x03 | z-axis
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_axis(
-u8 *acc_selftest_axis);
-/*!
- * @brief This API write accel select axis to be self-test
- *
- * @param v_accel_selftest_axis_u8 :
- * The value of accel self test axis selection
- * Value | Description
- * --------|-------------
- * 0x00 | disabled
- * 0x01 | x-axis
- * 0x02 | y-axis
- * 0x03 | z-axis
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_axis(
-u8 acc_selftest_axis);
-/*!
- * @brief This API read accel self test axis sign
- * from the register 0x6D bit 2
- *
- * @param v_accel_selftest_sign_u8: The value of accel self test axis sign
- * Value | Description
- * --------|-------------
- * 0x00 | negative
- * 0x01 | positive
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_sign(
-u8 *acc_selftest_sign);
-/*!
- * @brief This API write accel self test axis sign
- * from the register 0x6D bit 2
- *
- * @param v_accel_selftest_sign_u8: The value of accel self test axis sign
- * Value | Description
- * --------|-------------
- * 0x00 | negative
- * 0x01 | positive
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_sign(
-u8 acc_selftest_sign);
-/*!
- * @brief This API read accel self test amplitude
- * from the register 0x6D bit 3
- * select amplitude of the selftest deflection:
- *
- * @param v_accel_selftest_amp_u8 : The value of accel self test amplitude
- * Value | Description
- * --------|-------------
- * 0x00 | LOW
- * 0x01 | HIGH
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_selftest_amp(
-u8 *acc_selftest_amp);
-/*!
- * @brief This API write accel self test amplitude
- * from the register 0x6D bit 3
- * select amplitude of the selftest deflection:
- *
- * @param v_accel_selftest_amp_u8 : The value of accel self test amplitude
- * Value | Description
- * --------|-------------
- * 0x00 | LOW
- * 0x01 | HIGH
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_selftest_amp(
-u8 acc_selftest_amp);
-/***************************************************/
-/**\name FUNCTION FOR GYRO SELF TEST */
-/***************************************************/
-/*!
- * @brief This API read gyro self test trigger
- *
- * @param v_gyro_selftest_start_u8: The value of gyro self test start
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_selftest_start(
-u8 *v_gyro_selftest_start_u8);
-/*!
- * @brief This API write gyro self test trigger
- *
- * @param v_gyro_selftest_start_u8: The value of gyro self test start
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_selftest_start(
-u8 v_gyro_selftest_start_u8);
-/***************************************************/
-/**\name FUNCTION FOR SPI/I2C ENABLE */
-/***************************************************/
- /*!
- * @brief This API read primary interface selection I2C or SPI
- * from the register 0x70 bit 0
- *
- * @param v_spi_enable_u8: The value of Interface selection
- * Value | Description
- * --------|-------------
- * 0x00 | I2C Enable
- * 0x01 | I2C DISBALE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_spi_enable(
-u8 *v_spi_enable_u8);
- /*!
- * @brief This API write primary interface selection I2C or SPI
- * from the register 0x70 bit 0
- *
- * @param v_spi_enable_u8: The value of Interface selection
- * Value | Description
- * --------|-------------
- * 0x00 | I2C Enable
- * 0x01 | I2C DISBALE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_spi_enable(
-u8 v_spi_enable_u8);
- /*!
- * @brief This API read the spare zero
- * form register 0x70 bit 3
- *
- *
- * @param v_spare0_trim_u8: The value of spare zero
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_spare0_trim
-(u8 *v_spare0_trim_u8);
- /*!
- * @brief This API write the spare zero
- * form register 0x70 bit 3
- *
- *
- * @param v_spare0_trim_u8: The value of spare zero
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_spare0_trim
-(u8 v_spare0_trim_u8);
-/***************************************************/
-/**\name FUNCTION FOR NVM COUNTER */
-/***************************************************/
- /*!
- * @brief This API read the NVM counter
- * form register 0x70 bit 4 to 7
- *
- *
- * @param v_nvm_counter_u8: The value of NVM counter
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_nvm_counter(
-u8 *v_nvm_counter_u8);
- /*!
- * @brief This API write the NVM counter
- * form register 0x70 bit 4 to 7
- *
- *
- * @param v_nvm_counter_u8: The value of NVM counter
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_nvm_counter(
-u8 v_nvm_counter_u8);
-/***************************************************/
-/**\name FUNCTION FOR ACCEL MANUAL OFFSET COMPENSATION */
-/***************************************************/
-/*!
- * @brief This API read accel manual offset compensation of x axis
- * from the register 0x71 bit 0 to 7
- *
- *
- *
- * @param v_accel_off_x_s8:
- * The value of accel manual offset compensation of x axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_xaxis(
-s8 *v_accel_off_x_s8);
-/*!
- * @brief This API write accel manual offset compensation of x axis
- * from the register 0x71 bit 0 to 7
- *
- *
- *
- * @param v_accel_off_x_s8:
- * The value of accel manual offset compensation of x axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_xaxis(
-s8 v_accel_off_x_s8);
-/*!
- * @brief This API read accel manual offset compensation of y axis
- * from the register 0x72 bit 0 to 7
- *
- *
- *
- * @param v_accel_off_y_s8:
- * The value of accel manual offset compensation of y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_yaxis(
-s8 *v_accel_off_y_s8);
-/*!
- * @brief This API write accel manual offset compensation of y axis
- * from the register 0x72 bit 0 to 7
- *
- *
- *
- * @param v_accel_off_y_s8:
- * The value of accel manual offset compensation of y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_yaxis(
-s8 v_accel_off_y_s8);
-/*!
- * @brief This API read accel manual offset compensation of z axis
- * from the register 0x73 bit 0 to 7
- *
- *
- *
- * @param v_accel_off_z_s8:
- * The value of accel manual offset compensation of z axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_compensation_zaxis(
-s8 *v_accel_off_z_s8);
-/*!
- * @brief This API write accel manual offset compensation of z axis
- * from the register 0x73 bit 0 to 7
- *
- *
- *
- * @param v_accel_off_z_s8:
- * The value of accel manual offset compensation of z axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_compensation_zaxis(
-s8 v_accel_off_z_s8);
-/***************************************************/
-/**\name FUNCTION FOR GYRO MANUAL OFFSET COMPENSATION */
-/***************************************************/
-/*!
- * @brief This API read gyro manual offset compensation of x axis
- * from the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
- *
- *
- *
- * @param v_gyro_off_x_s16:
- * The value of gyro manual offset compensation of x axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_xaxis(
-s16 *v_gyro_off_x_s16);
-/*!
- * @brief This API write gyro manual offset compensation of x axis
- * from the register 0x74 bit 0 to 7 and 0x77 bit 0 and 1
- *
- *
- *
- * @param v_gyro_off_x_s16:
- * The value of gyro manual offset compensation of x axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_xaxis(
-s16 v_gyro_off_x_s16);
-/*!
- * @brief This API read gyro manual offset compensation of y axis
- * from the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
- *
- *
- *
- * @param v_gyro_off_y_s16:
- * The value of gyro manual offset compensation of y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_yaxis(
-s16 *v_gyro_off_y_s16);
-/*!
- * @brief This API write gyro manual offset compensation of y axis
- * from the register 0x75 bit 0 to 7 and 0x77 bit 2 and 3
- *
- *
- *
- * @param v_gyro_off_y_s16:
- * The value of gyro manual offset compensation of y axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_yaxis(
-s16 v_gyro_off_y_s16);
-/*!
- * @brief This API read gyro manual offset compensation of z axis
- * from the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
- *
- *
- *
- * @param v_gyro_off_z_s16:
- * The value of gyro manual offset compensation of z axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_compensation_zaxis(
-s16 *v_gyro_off_z_s16);
-/*!
- * @brief This API write gyro manual offset compensation of z axis
- * from the register 0x76 bit 0 to 7 and 0x77 bit 4 and 5
- *
- *
- *
- * @param v_gyro_off_z_s16:
- * The value of gyro manual offset compensation of z axis
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_compensation_zaxis(
-s16 v_gyro_off_z_s16);
-/*!
- * @brief This API writes accel fast offset compensation
- * from the register 0x69 bit 0 to 5
- * @brief This API writes each axis individually
- * FOC_X_AXIS - bit 4 and 5
- * FOC_Y_AXIS - bit 2 and 3
- * FOC_Z_AXIS - bit 0 and 1
- *
- * @param v_foc_accel_u8: The value of accel offset compensation
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- * @param v_axis_u8: The value of accel offset axis selection
- * value | axis
- * ----------|-------------------
- * 0 | FOC_X_AXIS
- * 1 | FOC_Y_AXIS
- * 2 | FOC_Z_AXIS
- *
- * @param v_accel_offset_s8: The accel offset value
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_foc_trigger(u8 axis,
-u8 foc_acc, s8 *accel_offset);
-/*!
- * @brief This API write fast accel offset compensation
- * it writes all axis together.To the register 0x69 bit 0 to 5
- * FOC_X_AXIS - bit 4 and 5
- * FOC_Y_AXIS - bit 2 and 3
- * FOC_Z_AXIS - bit 0 and 1
- *
- * @param v_foc_accel_x_u8: The value of accel offset x compensation
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- * @param v_foc_accel_y_u8: The value of accel offset y compensation
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- * @param v_foc_accel_z_u8: The value of accel offset z compensation
- * value | Behaviour
- * ----------|-------------------
- * 0x00 | disable
- * 0x01 | +1g
- * 0x01 | -1g
- * 0x01 | 0g
- *
- * @param v_accel_off_x_s8: The value of accel offset x axis
- * @param v_accel_off_y_s8: The value of accel offset y axis
- * @param v_accel_off_z_s8: The value of accel offset z axis
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_accel_foc_trigger_xyz(u8 v_foc_accel_x_u8,
-u8 v_foc_accel_y_u8, u8 v_foc_accel_z_u8,
-s8 *acc_off_x, s8 *acc_off_y, s8 *acc_off_z);
-/***************************************************/
-/**\name FUNCTION FOR ACEL AND GYRO OFFSET ENABLE */
-/***************************************************/
-/*!
- * @brief This API read the accel offset enable bit
- * from the register 0x77 bit 6
- *
- *
- *
- * @param v_accel_off_enable_u8: The value of accel offset enable
- * value | Description
- * ----------|--------------
- * 0x01 | ENABLE
- * 0x00 | DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_accel_offset_enable(
-u8 *acc_off_en);
-/*!
- * @brief This API write the accel offset enable bit
- * from the register 0x77 bit 6
- *
- *
- *
- * @param v_accel_off_enable_u8: The value of accel offset enable
- * value | Description
- * ----------|--------------
- * 0x01 | ENABLE
- * 0x00 | DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_accel_offset_enable(
-u8 acc_off_en);
-/*!
- * @brief This API read the accel offset enable bit
- * from the register 0x77 bit 7
- *
- *
- *
- * @param v_gyro_off_enable_u8: The value of gyro offset enable
- * value | Description
- * ----------|--------------
- * 0x01 | ENABLE
- * 0x00 | DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_gyro_offset_enable(
-u8 *v_gyro_off_enable_u8);
-/*!
- * @brief This API write the accel offset enable bit
- * from the register 0x77 bit 7
- *
- *
- *
- * @param v_gyro_off_enable_u8: The value of gyro offset enable
- * value | Description
- * ----------|--------------
- * 0x01 | ENABLE
- * 0x00 | DISABLE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_gyro_offset_enable(
-u8 v_gyro_off_enable_u8);
-/***************************************************/
-/**\name FUNCTION FOR STEP COUNTER INTERRUPT */
-/***************************************************/
-/*!
- * @brief This API reads step counter value
- * form the register 0x78 and 0x79
- *
- *
- *
- *
- * @param v_step_cnt_s16 : The value of step counter
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_step_count(s16 *v_step_cnt_s16);
- /*!
- * @brief This API Reads
- * step counter configuration
- * from the register 0x7A bit 0 to 7
- * and from the register 0x7B bit 0 to 2 and 4 to 7
- *
- *
- * @param v_step_config_u16 : The value of step configuration
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_config(
-u16 *v_step_config_u16);
- /*!
- * @brief This API write
- * step counter configuration
- * from the register 0x7A bit 0 to 7
- * and from the register 0x7B bit 0 to 2 and 4 to 7
- *
- *
- * @param v_step_config_u16 :
- * the value of Enable step configuration
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_config(
-u16 v_step_config_u16);
- /*!
- * @brief This API read enable step counter
- * from the register 0x7B bit 3
- *
- *
- * @param v_step_counter_u8 : The value of step counter enable
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_step_counter_enable(
-u8 *v_step_counter_u8);
- /*!
- * @brief This API write enable step counter
- * from the register 0x7B bit 3
- *
- *
- * @param v_step_counter_u8 : The value of step counter enable
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_counter_enable(
-u8 v_step_counter_u8);
- /*!
- * @brief This API set Step counter modes
- *
- *
- * @param v_step_mode_u8 : The value of step counter mode
- * value | mode
- * ----------|-----------
- * 0 | BMI160_STEP_NORMAL_MODE
- * 1 | BMI160_STEP_SENSITIVE_MODE
- * 2 | BMI160_STEP_ROBUST_MODE
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_step_mode(u8 v_step_mode_u8);
-/*!
- * @brief This API used to trigger the signification motion
- * interrupt
- *
- *
- * @param v_significant_u8 : The value of interrupt selection
- * value | interrupt
- * ----------|-----------
- * 0 | BMI160_MAP_INTR1
- * 1 | BMI160_MAP_INTR2
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_map_significant_motion_intr(
-u8 v_significant_u8);
-/*!
- * @brief This API used to trigger the step detector
- * interrupt
- *
- *
- * @param v_step_detector_u8 : The value of interrupt selection
- * value | interrupt
- * ----------|-----------
- * 0 | BMI160_MAP_INTR1
- * 1 | BMI160_MAP_INTR2
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_map_step_detector_intr(
-u8 v_step_detector_u8);
- /*!
- * @brief This API used to clear the step counter interrupt
- * interrupt
- *
- *
- * @param : None
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_clear_step_counter(void);
-/***************************************************/
-/**\name FUNCTION FOR STEP COMMAND REGISTER WRITE */
-/***************************************************/
- /*!
- * @brief This API writes value to the register 0x7E bit 0 to 7
- *
- *
- * @param v_command_reg_u8 : The value to write command register
- * value | Description
- * ---------|--------------------------------------------------------
- * 0x00 | Reserved
- * 0x03 | Starts fast offset calibration for the accel and gyro
- * 0x10 | Sets the PMU mode for the Accelerometer to suspend
- * 0x11 | Sets the PMU mode for the Accelerometer to normal
- * 0x12 | Sets the PMU mode for the Accelerometer Lowpower
- * 0x14 | Sets the PMU mode for the Gyroscope to suspend
- * 0x15 | Sets the PMU mode for the Gyroscope to normal
- * 0x16 | Reserved
- * 0x17 | Sets the PMU mode for the Gyroscope to fast start-up
- * 0x18 | Sets the PMU mode for the Magnetometer to suspend
- * 0x19 | Sets the PMU mode for the Magnetometer to normal
- * 0x1A | Sets the PMU mode for the Magnetometer to Lowpower
- * 0xB0 | Clears all data in the FIFO
- * 0xB1 | Resets the interrupt engine
- * 0xB2 | step_cnt_clr Clears the step counter
- * 0xB6 | Triggers a reset
- * 0x37 | See extmode_en_last
- * 0x9A | See extmode_en_last
- * 0xC0 | Enable the extended mode
- * 0xC4 | Erase NVM cell
- * 0xC8 | Load NVM cell
- * 0xF0 | Reset acceleration data path
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_command_register(
-u8 v_command_reg_u8);
-/***************************************************/
-/**\name FUNCTION FOR PAGE ENABLE */
-/***************************************************/
- /*!
- * @brief This API read target page from the register 0x7F bit 4 and 5
- *
- * @param v_target_page_u8: The value of target page
- * value | page
- * ---------|-----------
- * 0 | User data/configure page
- * 1 | Chip level trim/test page
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_target_page(
-u8 *v_target_page_u8);
- /*!
- * @brief This API write target page from the register 0x7F bit 4 and 5
- *
- * @param v_target_page_u8: The value of target page
- * value | page
- * ---------|-----------
- * 0 | User data/configure page
- * 1 | Chip level trim/test page
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_target_page(
-u8 v_target_page_u8);
- /*!
- * @brief This API read page enable from the register 0x7F bit 7
- *
- *
- *
- * @param v_page_enable_u8: The value of page enable
- * value | page
- * ---------|-----------
- * 0 | DISABLE
- * 1 | ENABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_paging_enable(
-u8 *v_page_enable_u8);
- /*!
- * @brief This API write page enable from the register 0x7F bit 7
- *
- *
- *
- * @param v_page_enable_u8: The value of page enable
- * value | page
- * ---------|-----------
- * 0 | DISABLE
- * 1 | ENABLE
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_paging_enable(
-u8 v_page_enable_u8);
- /*!
- * @brief This API read
- * pull up configuration from the register 0X85 bit 4 an 5
- *
- *
- *
- * @param v_control_pullup_u8: The value of pull up register
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_get_pullup_configuration(
-u8 *v_control_pullup_u8);
- /*!
- * @brief This API write
- * pull up configuration from the register 0X85 bit 4 an 5
- *
- *
- *
- * @param v_control_pullup_u8: The value of pull up register
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_pullup_configuration(
-u8 v_control_pullup_u8);
-/***************************************************/
-/**\name FUNCTION FOR BMM150 */
-/***************************************************/
- /*!
- * @brief This function used for initialize the bmm150 sensor
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_interface_init(u8 *v_chip_id_u8);
- /*!
- * @brief This function used for set the mag power control
- * bit enable
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_wakeup(void);
- /*!
- * @brief This function used for read the trim values of magnetometer
- *
- * @note
- * Before reading the mag trimming values
- * make sure the following two points are addressed
- * @note
- * 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note
- * 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_bmm150_mag_trim(void);
- /*!
- * @brief This function used for read the compensated value of mag
- * Before start reading the mag compensated data's
- * make sure the following two points are addressed
- * @note
- * 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note
- * 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_compensate_xyz(
-struct bmi160_mag_xyz_s32_t *mag_comp_xyz);
-/*!
- * @brief This API used to get the compensated BMM150-X data
- * the out put of X as s32
- * Before start reading the mag compensated X data
- * make sure the following two points are addressed
- * @note
- * 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note
- * 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- *
- * @param v_mag_data_x_s16 : The value of mag raw X data
- * @param v_data_r_u16 : The value of mag R data
- *
- * @return results of compensated X data value output as s32
- *
- */
-s32 bmi160_bmm150_mag_compensate_X(s16 v_mag_data_x_s16, u16 v_data_r_u16);
-/*!
- * @brief This API used to get the compensated BMM150-Y data
- * the out put of Y as s32
- * Before start reading the mag compensated Y data
- * make sure the following two points are addressed
- * @note
- * 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note
- * 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- *
- * @param v_mag_data_y_s16 : The value of mag raw Y data
- * @param v_data_r_u16 : The value of mag R data
- *
- * @return results of compensated Y data value output as s32
- */
-s32 bmi160_bmm150_mag_compensate_Y(s16 v_mag_data_y_s16, u16 v_data_r_u16);
-/*!
- * @brief This API used to get the compensated BMM150-Z data
- * the out put of Z as s32
- * Before start reading the mag compensated Z data
- * make sure the following two points are addressed
- * @note
- * 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note
- * 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- *
- * @param v_mag_data_z_s16 : The value of mag raw Z data
- * @param v_data_r_u16 : The value of mag R data
- *
- * @return results of compensated Z data value output as s32
- */
-s32 bmi160_bmm150_mag_compensate_Z(s16 v_mag_data_z_s16, u16 v_data_r_u16);
-/*!
- * @brief This API used to set the pre-set modes of bmm150
- * The pre-set mode setting is depend on data rate and xy and z repetitions
- *
- * @note
- * Before set the mag preset mode
- * make sure the following two points are addressed
- * @note
- * 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note
- * 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- * @param v_mode_u8: The value of pre-set mode selection value
- * value | pre_set mode
- * ----------|------------
- * 1 | BMI160_MAG_PRESETMODE_LOWPOWER
- * 2 | BMI160_MAG_PRESETMODE_REGULAR
- * 3 | BMI160_MAG_PRESETMODE_HIGHACCURACY
- * 4 | BMI160_MAG_PRESETMODE_ENHANCED
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_bmm150_mag_presetmode(u8 mode);
-/*!
- * @brief This function used for set the magnetometer
- * power mode.
- * @note
- * Before set the mag power mode
- * make sure the following two points are addressed
- * @note
- * 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note
- * 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- * @param v_mag_pow_mode_u8 : The value of mag power mode
- * value | mode
- * ----------|------------
- * 0 | FORCE_MODE
- * 1 | SUSPEND_MODE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bmm150_mag_set_power_mode(u8 mag_pow_mode);
- /*!
- * @brief This function used for set the magnetometer
- * power mode.
- * @note
- * Before set the mag power mode
- * make sure the following two point is addressed
- * Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- *
- * @param v_mag_sec_if_pow_mode_u8 : The value of mag power mode
- * value | mode
- * ----------|------------
- * 0 | BMI160_MAG_FORCE_MODE
- * 1 | BMI160_MAG_SUSPEND_MODE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_bmm150_mag_and_secondary_if_power_mode(
-u8 v_mag_sec_if_pow_mode_u8);
-/***************************************************/
-/**\name FUNCTIONS FOR AKM09911 AND AKM09912*/
-/***************************************************/
- /*!
- * @brief This function used for initialize
- * the AKM09911 and AKM09912 sensor
- *
- *
- * @param v_akm_i2c_address_u8: The value of device address
- * AKM sensor | Slave address
- * --------------|---------------------
- * AKM09911 | AKM09911_I2C_ADDR_1
- * - | and AKM09911_I2C_ADDR_2
- * AKM09912 | AKM09912_I2C_ADDR_1
- * - | AKM09912_I2C_ADDR_2
- * - | AKM09912_I2C_ADDR_3
- * - | AKM09912_I2C_ADDR_4
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm_mag_interface_init(
-u8 v_akm_i2c_address_u8);
- /*!
- * @brief This function used for read the sensitivity data of
- * AKM09911 and AKM09912
- *
- * @note Before reading the mag sensitivity values
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_bst_akm_sensitivity_data(void);
-/*!
- * @brief This API used to get the compensated X data
- * of AKM09911 the out put of X as s32
- * @note Before start reading the mag compensated X data
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- * @param v_bst_akm_x_s16 : The value of X data
- *
- * @return results of compensated X data value output as s32
- *
- */
-s32 bmi160_bst_akm09911_compensate_X(s16 v_bst_akm_x_s16);
-/*!
- * @brief This API used to get the compensated Y data
- * of AKM09911 the out put of Y as s32
- * @note Before start reading the mag compensated Y data
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- * @param v_bst_akm_y_s16 : The value of Y data
- *
- * @return results of compensated Y data value output as s32
- *
- */
-s32 bmi160_bst_akm09911_compensate_Y(s16 v_bst_akm_y_s16);
-/*!
- * @brief This API used to get the compensated Z data
- * of AKM09911 the out put of Z as s32
- * @note Before start reading the mag compensated Z data
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- * @param v_bst_akm_z_s16 : The value of Z data
- *
- * @return results of compensated Z data value output as s32
- *
- */
-s32 bmi160_bst_akm09911_compensate_Z(s16 v_bst_akm_z_s16);
-/*!
- * @brief This API used to get the compensated X data
- * of AKM09912 the out put of X as s32
- * @note Before start reading the mag compensated X data
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- * @param v_bst_akm_x_s16 : The value of X data
- *
- * @return results of compensated X data value output as s32
- *
- */
-s32 bmi160_bst_akm09912_compensate_X(s16 v_bst_akm_x_s16);
-/*!
- * @brief This API used to get the compensated Y data
- * of AKM09912 the out put of Y as s32
- * @note Before start reading the mag compensated Y data
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- * @param v_bst_akm_y_s16 : The value of Y data
- *
- * @return results of compensated Y data value output as s32
- *
- */
-s32 bmi160_bst_akm09912_compensate_Y(s16 v_bst_akm_y_s16);
-/*!
- * @brief This API used to get the compensated Z data
- * of AKM09912 the out put of Z as s32
- * @note Before start reading the mag compensated Z data
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- *
- * @param v_bst_akm_z_s16 : The value of Z data
- *
- * @return results of compensated Z data value output as s32
- *
- */
-s32 bmi160_bst_akm09912_compensate_Z(s16 v_bst_akm_z_s16);
- /*!
- * @brief This function used for read the compensated value of
- * AKM09911
- * @note Before start reading the mag compensated data's
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
-
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm09911_compensate_xyz(
-struct bmi160_bst_akm_xyz_t *bst_akm_xyz);
- /*!
- * @brief This function used for read the compensated value of
- * AKM09912
- * @note Before start reading the mag compensated data's
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
-
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm09912_compensate_xyz(
-struct bmi160_bst_akm_xyz_t *bst_akm_xyz);
-/*!
- * @brief This function used for set the AKM09911 and AKM09912
- * power mode.
- * @note Before set the AKM power mode
- * make sure the following two points are addressed
- * @note 1. Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- * @note 2. And also confirm the secondary-interface power mode
- * is not in the SUSPEND mode.
- * by using the function bmi160_get_mag_pmu_status().
- * If the secondary-interface power mode is in SUSPEND mode
- * set the value of 0x19(NORMAL mode)by using the
- * bmi160_set_command_register(0x19) function.
- *
- * @param v_akm_pow_mode_u8 : The value of akm power mode
- * value | Description
- * ---------|--------------------
- * 0 | AKM_POWER_DOWN_MODE
- * 1 | AKM_SINGLE_MEAS_MODE
- * 2 | FUSE_ROM_MODE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_akm_set_powermode(u8 v_akm_pow_mode_u8);
- /*!
- * @brief This function used for set the magnetometer
- * power mode of AKM09911 and AKM09912
- * @note Before set the mag power mode
- * make sure the following two point is addressed
- * Make sure the mag interface is enabled or not,
- * by using the bmi160_get_if_mode() function.
- * If mag interface is not enabled set the value of 0x02
- * to the function bmi160_get_if_mode(0x02)
- *
- * @param v_mag_sec_if_pow_mode_u8 : The value of secondary if power mode
- * value | Description
- * ---------|--------------------
- * 0 | BMI160_MAG_FORCE_MODE
- * 1 | BMI160_MAG_SUSPEND_MODE
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_set_bst_akm_and_secondary_if_powermode(
-u8 v_mag_sec_if_pow_mode_u8);
-/***************************************************/
-/**\name FUNCTIONS FOR YAMAH-YAS532 */
-/***************************************************/
-/*!
- * @brief This function used for read the YAMAH-YAS532 init
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas532_mag_interface_init(
-void);
-/*!
- * @brief This function used to set the YAS532 initial values
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_set_initial_values(void);
-/*!
- * @brief This function used for YAS532 offset correction
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_magnetic_measure_set_offset(
-void);
-/*!
- * @brief This function used for read the
- * YAMAHA YAS532 calibration data
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas532_calib_values(void);
-/*!
- * @brief This function used for calculate the
- * YAS532 read the linear data
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_xy1y2_to_linear(
-u16 *v_xy1y2_u16, s32 *xy1y2_linear);
-/*!
- * @brief This function used for read the YAS532 sensor data
- * @param v_acquisition_command_u8: used to set the data acquisition
- * acquisition_command | operation
- * ---------------------|-------------------------
- * 0x17 | turn on the acquisition coil
- * - | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Deferred acquisition mode
- * 0x07 | turn on the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Normal acquisition mode
- * 0x11 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Deferred acquisition mode
- * 0x01 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Normal acquisition mode
- *
- * @param v_busy_u8 : used to get the busy flay for sensor data read
- * @param v_temp_u16 : used to get the temperature data
- * @param v_xy1y2_u16 : used to get the sensor xy1y2 data
- * @param v_overflow_u8 : used to get the overflow data
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_normal_measurement_data(
-u8 v_acquisition_command_u8, u8 *v_busy_u8,
-u16 *v_temp_u16, u16 *v_xy1y2_u16, u8 *v_overflow_u8);
-/*!
- * @brief This function used for YAS532 sensor data
- * @param v_acquisition_command_u8 : the value of CMDR
- * acquisition_command | operation
- * ---------------------|-------------------------
- * 0x17 | turn on the acquisition coil
- * - | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Deferred acquisition mode
- * 0x07 | turn on the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Normal acquisition mode
- * 0x11 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Deferred acquisition mode
- * 0x01 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Normal acquisition mode
- *
- * @param xyz_data : the vector xyz output
- * @param v_overflow_s8 : the value of overflow
- * @param v_temp_correction_u8 : the value of temperate correction enable
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_measurement_xyz_data(
-struct yas532_vector *xyz_data, u8 *v_overflow_s8, u8 v_temp_correction_u8,
-u8 v_acquisition_command_u8);
-/*!
- * @brief This function used for YAS532 write data acquisition
- * command register write
- * @param v_command_reg_data_u8 : the value of data acquisition
- * acquisition_command | operation
- * ---------------------|-------------------------
- * 0x17 | turn on the acquisition coil
- * - | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Deferred acquisition mode
- * 0x07 | turn on the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Normal acquisition mode
- * 0x11 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Deferred acquisition mode
- * 0x01 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Normal acquisition mode
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_acquisition_command_register(
-u8 v_command_reg_data_u8);
-/*!
- * @brief This function used write offset of YAS532
- *
- * @param p_offset_s8 : The value of offset to write
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_set_offset(
-const s8 *p_offset_s8);
-/*!
- * @brief This function used to init the YAMAH-YAS537
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_mag_interface_init(
-void);
-/*!
- * @brief This function used for read the
- * YAMAHA YAS537 calibration data
- *
- *
- * @param v_rcoil_u8 : The value of r coil
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_calib_values(
-u8 v_rcoil_u8);
-/*!
- * @brief This function used for YAS537 write data acquisition
- * command register write
- * @param v_command_reg_data_u8 : the value of data acquisition
- * acquisition_command | operation
- * ---------------------|-------------------------
- * 0x17 | turn on the acquisition coil
- * - | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Deferred acquisition mode
- * 0x07 | turn on the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as minus(-))
- * _ | Normal acquisition mode
- * 0x11 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Deferred acquisition mode
- * 0x01 | turn OFF the acquisition coil
- * _ | set direction of the coil
- * _ | (x and y as plus(+))
- * _ | Normal acquisition mode
- *
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas537_acquisition_command_register(
-u8 v_command_reg_data_u8);
-/*!
- * @brief This function used for read the
- * YAMAHA YAS537 xy1y2 data
- *
- * @param xy1y2: The value of raw xy1y2 data
- * @param xyz: The value of xyz data
- *
- *
- * @return None
- *
- *
- */
-static void xy1y2_to_xyz(u16 *xy1y2, s32 *xyz);
-/*!
- * @brief This function used for read the
- * YAMAHA YAS537 xy1y2 data
- *
- * @param v_coil_stat_u8: The value of R coil status
- * @param v_busy_u8: The value of busy status
- * @param v_temperature_u16: The value of temperature
- * @param xy1y2: The value of raw xy1y2 data
- * @param v_ouflow_u8: The value of overflow
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_read_xy1y2_data(
-u8 *v_coil_stat_u8, u8 *v_busy_u8,
-u16 *v_temperature_u16, u16 *xy1y2, u8 *v_ouflow_u8);
-/*!
- * @brief This function used for read the
- * YAMAHA YAS537 xy1y2 data
- *
- * @param v_ouflow_u8: The value of overflow
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_measure_xyz_data(
-u8 *v_ouflow_u8, struct yas_vector *vector_xyz);
-/*!
- * @brief This function used for read the
- * YAMAHA YAS537 xy1y2 data
- *
- * @param v_ouflow_u8: The value of overflow
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-static BMI160_RETURN_FUNCTION_TYPE invalid_magnetic_field(
-u16 *v_cur_u16, u16 *v_last_u16);
-/***************************************************/
-/**\name FUNCTIONS FOR FIFO DATA READ */
-/***************************************************/
-/*!
- * @brief This function used for reading the
- * fifo data of header less mode
- *
- *
- *
- * @note Configure the below functions for FIFO header less mode
- * @note 1. bmi160_set_fifo_down_gyro
- * @note 2. bmi160_set_gyro_fifo_filter_data
- * @note 3. bmi160_set_fifo_down_accel
- * @note 4. bmi160_set_accel_fifo_filter_dat
- * @note 5. bmi160_set_fifo_mag_enable
- * @note 6. bmi160_set_fifo_accel_enable
- * @note 7. bmi160_set_fifo_gyro_enable
- * @note For interrupt configuration
- * @note 1. bmi160_set_intr_fifo_full
- * @note 2. bmi160_set_intr_fifo_wm
- * @note 3. bmi160_set_fifo_tag_intr2_enable
- * @note 4. bmi160_set_fifo_tag_intr1_enable
- *
- * @note The fifo reads the whole 1024 bytes
- * and processing the data
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_headerless_mode(
-u8 v_mag_if_u8);
-/*!
- * @brief This function used for reading the
- * fifo data of header less mode for using user defined length
- *
- *
- * @param v_fifo_user_length_u16: The value of length of fifo read data
- *
- * @note Configure the below functions for FIFO header less mode
- * @note 1. bmi160_set_fifo_down_gyro
- * @note 2. bmi160_set_gyro_fifo_filter_data
- * @note 3. bmi160_set_fifo_down_accel
- * @note 4. bmi160_set_accel_fifo_filter_dat
- * @note 5. bmi160_set_fifo_mag_enable
- * @note 6. bmi160_set_fifo_accel_enable
- * @note 7. bmi160_set_fifo_gyro_enable
- * @note For interrupt configuration
- * @note 1. bmi160_set_intr_fifo_full
- * @note 2. bmi160_set_intr_fifo_wm
- * @note 3. bmi160_set_fifo_tag_intr2_enable
- * @note 4. bmi160_set_fifo_tag_intr1_enable
- *
- * @note The fifo reads the whole 1024 bytes
- * and processing the data
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE
-bmi160_read_fifo_headerless_mode_user_defined_length(
-u16 v_fifo_user_length_u16,
-struct bmi160_fifo_data_header_less_t *fifo_data, u8 v_mag_if_mag_u8);
-/*!
- * @brief This function used for reading the
- * fifo data of header mode
- *
- *
- * @note Configure the below functions for FIFO header mode
- * @note 1. bmi160_set_fifo_down_gyro()
- * @note 2. bmi160_set_gyro_fifo_filter_data()
- * @note 3. bmi160_set_fifo_down_accel()
- * @note 4. bmi160_set_accel_fifo_filter_dat()
- * @note 5. bmi160_set_fifo_mag_enable()
- * @note 6. bmi160_set_fifo_accel_enable()
- * @note 7. bmi160_set_fifo_gyro_enable()
- * @note 8. bmi160_set_fifo_header_enable()
- * @note For interrupt configuration
- * @note 1. bmi160_set_intr_fifo_full()
- * @note 2. bmi160_set_intr_fifo_wm()
- * @note 3. bmi160_set_fifo_tag_intr2_enable()
- * @note 4. bmi160_set_fifo_tag_intr1_enable()
- *
- * @note The fifo reads the whole 1024 bytes
- * and processing the data
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_header_data(
-u8 v_mag_if_u8);
-/*!
- * @brief This function used for reading the
- * fifo data of header mode for using user defined length
- *
- *
- * @note Configure the below functions for FIFO header mode
- * @note 1. bmi160_set_fifo_down_gyro()
- * @note 2. bmi160_set_gyro_fifo_filter_data()
- * @note 3. bmi160_set_fifo_down_accel()
- * @note 4. bmi160_set_accel_fifo_filter_dat()
- * @note 5. bmi160_set_fifo_mag_enable()
- * @note 6. bmi160_set_fifo_accel_enable()
- * @note 7. bmi160_set_fifo_gyro_enable()
- * @note 8. bmi160_set_fifo_header_enable()
- * @note For interrupt configuration
- * @note 1. bmi160_set_intr_fifo_full()
- * @note 2. bmi160_set_intr_fifo_wm()
- * @note 3. bmi160_set_fifo_tag_intr2_enable()
- * @note 4. bmi160_set_fifo_tag_intr1_enable()
- *
- * @note The fifo reads the whole 1024 bytes
- * and processing the data
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_read_fifo_header_data_user_defined_length(
-u16 v_fifo_user_length_u16, u8 v_mag_if_mag_u8,
-struct bmi160_fifo_data_header_t *fifo_header_data);
-/*!
- * @brief This function used for reading
- * bmi160_t structure
- *
- * @return the reference and values of bmi160_t
- *
- *
-*/
-struct bmi160_t *bmi160_get_ptr(void);
-/*!
- * @brief This function used for reading the compensated data of
- * mag secondary interface xyz data
- * @param v_mag_x_s16: The value of mag x data
- * @param v_mag_y_s16: The value of mag y data
- * @param v_mag_z_s16: The value of mag z data
- * @param v_mag_r_s16: The value of mag r data
- * @param v_mag_second_if_u8: The value of mag selection
- *
- * value | v_mag_second_if_u8
- * ---------|----------------------
- * 0 | BMM150
- * 1 | AKM09911
- * 2 | AKM09912
- * 3 | YAS532
- * 4 | YAS537
- * @param mag_fifo_data: The value of compensated mag xyz data
- *
- *
- * @return
- *
- *
-*/
-BMI160_RETURN_FUNCTION_TYPE bmi160_second_if_mag_compensate_xyz(
-struct bmi160_mag_fifo_data_t mag_fifo_data,
-u8 v_mag_second_if_u8);
-/*!
- * @brief This function used for read the
- * YAMAHA YAS537 xy1y2 data of fifo
- *
- * @param a_xy1y2_u16: The value of xyy1 data
- * @param v_over_flow_u8: The value of overflow
- * @param v_rcoil_u8: The value of rcoil
- * @param v_busy_u8: The value of busy flag
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yamaha_yas537_fifo_xyz_data(
-u16 *a_xy1y2_u16, u8 v_over_flow_u8, u8 v_rcoil_u8, u8 v_busy_u8);
-/*!
- * @brief This function used for YAS532 sensor data
- * @param v_acquisition_command_u8 : the value of CMDR
- *
- * @param v_xy1y2_u16 : the vector xyz output
- * @param v_overflow_s8 : the value of overflow
- * @param v_temp_correction_u8 : the value of temperate correction enable
- *
- *
- * @return results of bus communication function
- * @retval 0 -> Success
- * @retval -1 -> Error
- *
- *
- */
-BMI160_RETURN_FUNCTION_TYPE bmi160_bst_yas532_fifo_xyz_data(
-u16 *v_xy1y2_u16, u8 v_temp_correction_u8,
-s8 v_overflow_s8, u16 v_temp_u16, u8 v_busy_u8);
-
-#endif
diff --git a/peripheral/libupm/src/bmi160/javaupm_bmi160.i b/peripheral/libupm/src/bmi160/javaupm_bmi160.i
deleted file mode 100644
index 478b58f..0000000
--- a/peripheral/libupm/src/bmi160/javaupm_bmi160.i
+++ /dev/null
@@ -1,41 +0,0 @@
-%module javaupm_bmi160
-%include "../upm.i"
-%include "typemaps.i"
-%include "arrays_java.i"
-%include "../java_buffer.i"
-
-%{
- #include "bmi160.hpp"
-%}
-
-
-%typemap(jni) float * "jfloatArray"
-%typemap(jstype) float * "float[]"
-%typemap(jtype) float * "float[]"
-
-%typemap(javaout) float * {
- return $jnicall;
-}
-
-%typemap(out) float * {
- $result = JCALL1(NewFloatArray, jenv, 3);
- JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
- delete [] $1;
-}
-
-%ignore getAccelerometer(float *, float *, float *);
-%ignore getGyroscope(float *, float *, float *);
-%ignore getMagnetometer(float *, float *, float *);
-
-%include "bmi160.hpp"
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_bmi160");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/bmi160/jsupm_bmi160.i b/peripheral/libupm/src/bmi160/jsupm_bmi160.i
deleted file mode 100644
index d728716..0000000
--- a/peripheral/libupm/src/bmi160/jsupm_bmi160.i
+++ /dev/null
@@ -1,10 +0,0 @@
-%module jsupm_bmi160
-%include "../upm.i"
-%include "cpointer.i"
-
-%pointer_functions(float, floatp);
-
-%include "bmi160.hpp"
-%{
- #include "bmi160.hpp"
-%}
diff --git a/peripheral/libupm/src/bmi160/license.txt b/peripheral/libupm/src/bmi160/license.txt
deleted file mode 100644
index f9e8cd4..0000000
--- a/peripheral/libupm/src/bmi160/license.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-/** \mainpage
-*
-****************************************************************************
-* Copyright (C) 2014 Bosch Sensortec GmbH
-*
-* File : bmi160.hpp
-*
-* Date : 2014/10/27
-*
-* Revision : 2.0.6 $
-*
-* Usage: Sensor Driver for BMI160 sensor
-*
-****************************************************************************
-*
-* \section License
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-*
-* Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-*
-* Neither the name of the copyright holder nor the names of the
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
-* OR CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-* OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
-* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-* ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
-*
-* The information provided is believed to be accurate and reliable.
-* The copyright holder assumes no responsibility
-* for the consequences of use
-* of such information nor for any infringement of patents or
-* other rights of third parties which may result from its use.
-* No license is granted by implication or otherwise under any patent or
-* patent rights of the copyright holder.
-**************************************************************************/
diff --git a/peripheral/libupm/src/bmi160/pyupm_bmi160.i b/peripheral/libupm/src/bmi160/pyupm_bmi160.i
deleted file mode 100644
index e5cd91e..0000000
--- a/peripheral/libupm/src/bmi160/pyupm_bmi160.i
+++ /dev/null
@@ -1,16 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_bmi160
-%include "../upm.i"
-%include "cpointer.i"
-
-%include "stdint.i"
-
-%feature("autodoc", "3");
-
-%pointer_functions(float, floatp);
-
-%include "bmi160.hpp"
-%{
- #include "bmi160.hpp"
-%}
diff --git a/peripheral/libupm/src/bmp280/CMakeLists.txt b/peripheral/libupm/src/bmp280/CMakeLists.txt
deleted file mode 100644
index c722782..0000000
--- a/peripheral/libupm/src/bmp280/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set (libname "bmp280")
-set (libdescription "Bosch bmp280 Pressure sensor and bme280 humidity sensor")
-set (module_src ${libname}.cxx bme280.cxx)
-set (module_hpp ${libname}.hpp bme280.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/bmp280/bme280.cxx b/peripheral/libupm/src/bmp280/bme280.cxx
deleted file mode 100644
index e78b8af..0000000
--- a/peripheral/libupm/src/bmp280/bme280.cxx
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-#include <math.h>
-#include <string.h>
-
-#include "bme280.hpp"
-
-using namespace upm;
-using namespace std;
-
-BME280::BME280(int bus, int addr, int cs, uint8_t theChipID) :
- BMP280(bus, addr, cs, theChipID)
-{
-
- m_humidity = 0;
-
- m_dig_H1 = 0;
- m_dig_H2 = 0;
- m_dig_H3 = 0;
- m_dig_H4 = 0;
- m_dig_H5 = 0;
- m_dig_H6 = 0;
-
- // set sleep mode for now
- setMeasureMode(MODE_SLEEP);
-
- // read calibration data
- readCalibrationData();
-
- // set the default mode to the highest resolution mode
- setUsageMode(USAGE_MODE_INDOOR_NAV);
-}
-
-BME280::~BME280()
-{
-}
-
-void BME280::update()
-{
- // call the base class method first. This will handle the details
- // WRT forced mode so that we can always be sure to read valid data
- // regardless of the underlying measurement mode.
-
- BMP280::update();
-
- int32_t hum = 0;
-
- const int dataLen = 2;
- uint8_t data[dataLen];
- memset(data, 0, dataLen);
-
- int rv;
- if ((rv = readRegs(REG_HUMIDITY_MSB, data, dataLen)) != dataLen)
- {
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": readRegs() failed, returned "
- + std::to_string(rv));
- }
-
- // 20 bits unsigned stored in a 32bit signed quanty
-
- hum = ( (data[0] << 8) | data[1] );
-
- m_humidity = float(bme280_compensate_H_int32(hum));
- m_humidity /= 1024.0;
-}
-
-void BME280::readCalibrationData()
-{
- m_dig_H1 = readReg(REG_CALIB_DIG_H1);
-
- const int calibLen = 7;
- uint8_t calibData[calibLen];
- readRegs(REG_CALIB_DIG_H2_LSB, calibData, calibLen);
-
- m_dig_H2 = int16_t((calibData[1] << 8) | calibData[0]);
-
- m_dig_H3 = calibData[2];
-
- m_dig_H4 = int16_t( (calibData[3] << 4) |
- (calibData[4] & 0x0f) );
-
- m_dig_H5 = int16_t( ((calibData[4] & 0xf0) >> 4) |
- (calibData[5] << 4) );
-
- m_dig_H6 = int8_t(calibData[6]);
-
-# if 0
- cerr << std::dec
- << "H1: " << (int)m_dig_H1
- << " H2: " << (int)m_dig_H2
- << " H3: " << (int)m_dig_H3
- << " H4: " << (int)m_dig_H4
- << " H5: " << (int)m_dig_H5
- << " H6: " << (int)m_dig_H5
- << endl;
-# endif // 0
-
- // The BMP280 ctor will call it's version of readCalibrationData
-}
-
-float BME280::getHumidity()
-{
- return m_humidity;
-}
-
-void BME280::setOversampleRateHumidity(OSRS_H_T rate)
-{
- uint8_t reg = readReg(REG_CTRL_HUM);
-
- reg &= ~(_CTRL_HUM_OSRS_H_MASK << _CTRL_HUM_OSRS_H_SHIFT);
- reg |= (rate << _CTRL_HUM_OSRS_H_SHIFT);
-
- writeReg(REG_CTRL_HUM, reg);
-}
-
-
-void BME280::setUsageMode(USAGE_MODE_T mode)
-{
- // Here, we just set the default humidity oversample to 1 and then
- // call the base method.
-
- m_humidity = 0;
-
- // set sleep mode first
- setMeasureMode(MODE_SLEEP);
-
- setOversampleRateHumidity(OSRS_H_OVERSAMPLING_1);
- BMP280::setUsageMode(mode);
-}
-
-// This function comes from the BMP180 datasheet, section 4.2.3
-
-// Returns humidity in %RH as unsigned 32 bit integer in Q22.10 format
-// (22 integer and 10 fractional bits). Output value of “47445”
-// represents 47445/1024 = 46.333 %RH
-uint32_t BME280::bme280_compensate_H_int32(int32_t adc_H)
-{
- int32_t v_x1_u32r;
- v_x1_u32r = (m_t_fine - ((int32_t)76800));
- v_x1_u32r = (((((adc_H << 14) - (((int32_t)m_dig_H4) << 20) - (((int32_t)m_dig_H5) * v_x1_u32r)) +
- ((int32_t)16384)) >> 15) * (((((((v_x1_u32r * ((int32_t)m_dig_H6)) >> 10) * (((v_x1_u32r * ((int32_t)m_dig_H3)) >> 11) + ((int32_t)32768))) >> 10) + ((int32_t)2097152)) * ((int32_t)m_dig_H2) + 8192) >> 14));
- v_x1_u32r = (v_x1_u32r - (((((v_x1_u32r >> 15) * (v_x1_u32r >> 15)) >> 7) * ((int32_t)m_dig_H1)) >> 4));
- v_x1_u32r = (v_x1_u32r < 0 ? 0 : v_x1_u32r);
- v_x1_u32r = (v_x1_u32r > 419430400 ? 419430400 : v_x1_u32r);
- return (int32_t)(v_x1_u32r>>12);
-}
-
diff --git a/peripheral/libupm/src/bmp280/bme280.hpp b/peripheral/libupm/src/bmp280/bme280.hpp
deleted file mode 100644
index e6d84e5..0000000
--- a/peripheral/libupm/src/bmp280/bme280.hpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <mraa/i2c.hpp>
-#include <mraa/spi.hpp>
-#include <mraa/gpio.hpp>
-
-#include "upm/iHumiditySensor.hpp"
-
-#include "bmp280.hpp"
-
-#define BME280_DEFAULT_I2C_BUS 0
-#define BME280_DEFAULT_SPI_BUS 0
-#define BME280_DEFAULT_ADDR 0x77
-#define BME280_DEFAULT_CHIPID 0x60
-
-namespace upm {
-
- /**
- * @library bmp280
- * @sensor bme280
- * @comname BME280 Digital Humidity, Pressure, and Temperature Sensor
- * @type pressure humidity
- * @man adafruit
- * @con i2c spi gpio
- * @web https://www.adafruit.com/products/2652
- *
- * @brief API for the BME280 Digital Humidity, Pressure, and
- * Temperature Sensor
- *
- * The BME280 is as combined digital humidity, pressure and
- * temperature sensor based on proven sensing principles. The sensor
- * module is housed in an extremely compact metal-lid LGA package
- * with a footprint of only 2.5 × 2.5 mm2 with a height of 0.93
- * mm. Its small dimensions and its low power consumption allow the
- * implementation in battery driven devices such as handsets, GPS
- * modules or watches. The BME280 is register and performance
- * compatible to the Bosch Sensortec BMP280 digital pressure sensor
- *
- * @snippet bme280.cxx Interesting
- */
-
- class BME280 : public BMP280, public IHumiditySensor {
- public:
-
- /**
- * BMP280 registers
- */
- typedef enum : uint8_t {
- // Do not write into reserved bits.
-
- // We only specify those registers specific to the BME280. The
- // rest of them can be found in the BMP280 header file.
-
- // read-only factory calibration data for humidity
-
- REG_CALIB_DIG_H1 = 0xa1,
-
- REG_CALIB_DIG_H2_LSB = 0xe1,
- REG_CALIB_DIG_H2_MSB = 0xe2,
-
- REG_CALIB_DIG_H3 = 0xe3,
-
- REG_CALIB_DIG_H4_0 = 0xe4, // bits 8 -> 11:4
- REG_CALIB_DIG_H4_1 = 0xe5, // bits 3:0 -> 3:0
-
- REG_CALIB_DIG_H5_0 = 0xe5, // bits 7:4 -> 3:0
- REG_CALIB_DIG_H5_1 = 0xe6, // bits 8 -> 11:4
-
- REG_CALIB_DIG_H6 = 0xe7,
-
- REG_CTRL_HUM = 0xf2,
-
- REG_HUMIDITY_MSB = 0xfd,
- REG_HUMIDITY_LSB = 0xfe
- } BME280_REGS_T;
-
- /**
- * REG_CTRL_HUM bits
- */
- typedef enum {
- CTRL_HUM_OSRS_H0 = 0x01,
- CTRL_HUM_OSRS_H1 = 0x02,
- CTRL_HUM_OSRS_H2 = 0x04,
- _CTRL_HUM_OSRS_H_MASK = 3,
- _CTRL_HUM_OSRS_H_SHIFT = 0
-
- // 0x08-0x80 reserved
- } CTRL_HUM_T;
-
- /**
- * CTRL_HUM_OSRS_H values
- */
- typedef enum {
- OSRS_H_SKIPPED = 0,
- OSRS_H_OVERSAMPLING_1 = 1, // x1
- OSRS_H_OVERSAMPLING_2 = 2, // x2
- OSRS_H_OVERSAMPLING_4 = 3,
- OSRS_H_OVERSAMPLING_8 = 4,
- OSRS_H_OVERSAMPLING_16 = 5
- } OSRS_H_T;
-
-
- /**
- * BME280 constructor.
- *
- * This device can support both I2C and SPI. For SPI, set the addr
- * to -1, and specify a positive integer representing the Chip
- * Select (CS) pin for the cs argument. If you are using a
- * hardware CS pin, then you can connect the proper pin to the
- * hardware CS pin on your MCU and supply -1 for cs. The default
- * operating mode is I2C.
- *
- * @param bus I2C or SPI bus to use.
- * @param address The address for this device. -1 for SPI.
- * @param cs The gpio pin to use for the SPI Chip Select. -1 for
- * I2C or for SPI with a hardware controlled pin.
- * @param theChipID The chip ID used for validation
- */
- BME280(int bus=BME280_DEFAULT_I2C_BUS, int addr=BME280_DEFAULT_ADDR,
- int cs=-1, uint8_t theChipID=BME280_DEFAULT_CHIPID);
-
- /**
- * BME280 Destructor.
- */
- virtual ~BME280();
-
- /**
- * Update the internal stored values from sensor data.
- */
- virtual void update();
-
- /**
- * Return the current measured relative humidity. update() must
- * have been called prior to calling this method.
- *
- * @return The relative humidity in percent..
- */
- float getHumidity();
-
- /**
- * Set a general usage mode. This function can be used to
- * configure the filters and oversampling for a particular use
- * case. These settings are documented in the BMP280 and BME280
- * datasheets.
- *
- * @param mode One of the USAGE_MODE_T values.
- */
- virtual void setUsageMode(USAGE_MODE_T mode);
-
- /**
- * Set the humidity sensor oversampling parameter. See the data
- * sheet for details. This value can be automatically set to a
- * suitable value by using one of the predefined modes for
- * setUsageMode().
- *
- * @param mode One of the OSRS_H_T values.
- */
- void setOversampleRateHumidity(OSRS_H_T rate);
-
- // Interface support
- const char *getModuleName()
- {
- return "BME280";
- };
-
- int getHumidityRelative()
- {
- return int(getHumidity());
- };
-
- protected:
- // relative humidity
- float m_humidity;
-
- // read the calibration data
- virtual void readCalibrationData();
-
- private:
- // calibration data humidity
- uint8_t m_dig_H1;
- int16_t m_dig_H2;
- uint8_t m_dig_H3;
- int16_t m_dig_H4;
- int16_t m_dig_H5;
- int8_t m_dig_H6;
-
- // Bosch supplied conversion/compensation functions from the
- // datasheet.
- uint32_t bme280_compensate_H_int32(int32_t adc_H);
- };
-}
diff --git a/peripheral/libupm/src/bmp280/bmp280.cxx b/peripheral/libupm/src/bmp280/bmp280.cxx
deleted file mode 100644
index 4e59975..0000000
--- a/peripheral/libupm/src/bmp280/bmp280.cxx
+++ /dev/null
@@ -1,576 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-#include <math.h>
-#include <string.h>
-
-#include "bmp280.hpp"
-
-using namespace upm;
-using namespace std;
-
-// Uncomment the following to use test data as specified in the
-// datasheet, section 3.12. This really only tests the compensation
-// algorithm.
-
-// #define BMP280_USE_TEST_DATA
-
-// conversion from fahrenheit to celcius and back
-
-static float f2c(float f)
-{
- return ((f - 32.0) / (9.0 / 5.0));
-}
-
-static float c2f(float c)
-{
- return (c * (9.0 / 5.0) + 32.0);
-}
-
-BMP280::BMP280(int bus, int addr, int cs, uint8_t theChipID) :
- m_i2c(0), m_spi(0), m_gpioCS(0)
-{
-
- m_addr = addr;
-
- m_temperature = 0;
- m_pressure = 0;
- m_isSPI = false;
-
- clearData();
-
- if (addr < 0)
- m_isSPI = true;
-
- mraa::Result rv;
-
- if (m_isSPI)
- {
- m_spi = new mraa::Spi(bus);
-
- // Only create cs context if we are actually using a valid pin.
- // A hardware controlled pin should specify cs as -1.
- if (cs >= 0)
- {
- m_gpioCS = new mraa::Gpio(cs);
- m_gpioCS->dir(mraa::DIR_OUT);
- }
-
- m_spi->mode(mraa::SPI_MODE0);
- m_spi->frequency(5000000);
-
- // toggle it on/off so chip switches into SPI mode. For a hw CS
- // pin, the first SPI transaction should accomplish this.
- csOn();
- usleep(10000);
- csOff();
- }
- else
- {
- // I2C
- m_i2c = new mraa::I2c(bus);
-
- if ((rv = m_i2c->address(m_addr)) != mraa::SUCCESS)
- {
- throw std::runtime_error(string(__FUNCTION__) +
- ": I2c.address() failed");
- }
- }
-
- // check the chip id
-
- uint8_t chipID = readReg(REG_CHIPID);
- if (chipID != theChipID)
- {
- throw std::runtime_error(string(__FUNCTION__)
- + ": invalid chip ID. Expected "
- + std::to_string(int(theChipID))
- + ", got "
- + std::to_string(int(chipID)));
- }
-
- // set sleep mode for now
- setMeasureMode(MODE_SLEEP);
-
- // read calibration data
- readCalibrationData();
-
- // set the default mode to the highest resolution mode
- setUsageMode(USAGE_MODE_INDOOR_NAV);
-}
-
-BMP280::~BMP280()
-{
- if (m_i2c)
- delete m_i2c;
-
- if (m_spi)
- delete m_spi;
-
- if (m_gpioCS)
- delete m_gpioCS;
-}
-
-void BMP280::update()
-{
- int32_t temp = 0;
- int32_t pres = 0;
-
- const int dataLen = 6;
- uint8_t data[dataLen];
- memset(data, 0, dataLen);
-
- // If we are using a forced mode, then we need to manually trigger
- // the measurement, and wait for it to complete.
-
- if (m_mode == MODE_FORCED)
- {
- // bmp280 measure mode will return to sleep after completion...
- setMeasureMode(MODE_FORCED);
-
- uint8_t stat;
- do
- {
- usleep(10000); // 10ms
- stat = readReg(REG_STATUS);
- } while (stat & STATUS_MEASURING);
- }
-
- int rv;
- if ((rv = readRegs(REG_PRESSURE_MSB, data, dataLen)) != dataLen)
- {
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": readRegs() failed, returned "
- + std::to_string(rv));
- }
-
- // 20 bits unsigned stored in a 32bit signed quanty
-
-#if defined(BMP280_USE_TEST_DATA)
- // taken from datasheet, section 3.12
- temp = 519888;
- pres = 415148;
-#else
- temp = ( (data[5] >> 4) | (data[4] << 4) | (data[3] << 12) );
- pres = ( (data[2] >> 4) | (data[1] << 4) | (data[0] << 12) );
-#endif
-
- m_temperature = float(bmp280_compensate_T_int32(temp));
- m_temperature /= 100.0;
-
- m_pressure = float(bmp280_compensate_P_int64(pres));
- m_pressure /= 256.0;
-}
-
-float BMP280::getAltitude(float sealLevelhPA)
-{
- // adapted from the NOAA pdf: pressureAltitude.pdf
- return 44307.69 * (1.0 - pow((m_pressure/100.0) / sealLevelhPA, 0.190284));
-}
-
-uint8_t BMP280::readReg(uint8_t reg)
-{
- if (m_isSPI)
- {
- reg |= 0x80; // needed for read
- uint8_t pkt[2] = {reg, 0};
-
- csOn();
- if (m_spi->transfer(pkt, pkt, 2))
- {
- csOff();
- throw std::runtime_error(string(__FUNCTION__)
- + ": Spi.transfer() failed");
- }
- csOff();
-
-#if 0
- cerr << "readReg: " << std::hex << "p0: " << (int)pkt[0] << " p1: "
- << (int)pkt[1] << endl;
-#endif // 0
-
- return pkt[1];
- }
- else
- return m_i2c->readReg(reg);
-}
-
-int BMP280::readRegs(uint8_t reg, uint8_t *buffer, int len)
-{
- if (m_isSPI)
- {
- reg |= 0x80; // needed for read
-
- uint8_t sbuf[len + 1];
- memset((char *)sbuf, 0, len + 1);
- sbuf[0] = reg;
-
- // We need to do it this way for edison - ie: use a single
- // transfer rather than breaking it up into two like we used to.
- // This means a buffer copy is now required, but that's the way
- // it goes.
-
- csOn();
- if (m_spi->transfer(sbuf, sbuf, len + 1))
- {
- csOff();
- throw std::runtime_error(string(__FUNCTION__)
- + ": Spi.transfer(buf) failed");
- }
- csOff();
-
- // now copy it into user buffer
- for (int i=0; i<len; i++)
- buffer[i] = sbuf[i + 1];
-
- // so... did this work on edison????
-
-#if 0
- cerr << "readRegs(): " << std::hex;
- for (int i=0; i<len; i++)
- cerr << (int)buffer[i] << " ";
- cerr << endl;
-#endif // 0
-
- return len;
- }
- else
- return m_i2c->readBytesReg(reg, buffer, len);
-}
-
-void BMP280::writeReg(uint8_t reg, uint8_t val)
-{
- if (m_isSPI)
- {
- reg &= 0x7f; // mask off 0x80 for writing
- uint8_t pkt[2] = {reg, val};
-
- csOn();
- if (m_spi->transfer(pkt, NULL, 2))
- {
- csOff();
- throw std::runtime_error(string(__FUNCTION__)
- + ": Spi.transfer() failed");
- }
- csOff();
- }
- else
- {
-
- mraa::Result rv;
- if ((rv = m_i2c->writeReg(reg, val)) != mraa::SUCCESS)
- {
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": I2c.writeReg() failed");
- }
- }
-}
-
-void BMP280::clearData()
-{
- m_t_fine = 0;
-
- m_dig_T1 = 0;
- m_dig_T2 = 0;
- m_dig_T3 = 0;
-
- m_dig_P1 = 0;
- m_dig_P2 = 0;
- m_dig_P3 = 0;
- m_dig_P4 = 0;
- m_dig_P5 = 0;
- m_dig_P6 = 0;
- m_dig_P7 = 0;
- m_dig_P8 = 0;
- m_dig_P9 = 0;
-}
-
-uint8_t BMP280::getChipID()
-{
-
- return readReg(REG_CHIPID);
-}
-
-void BMP280::reset()
-{
- writeReg(REG_RESET, BMP280_RESET_BYTE);
- sleep(1);
-}
-
-
-void BMP280::readCalibrationData()
-{
-#if defined(BMP280_USE_TEST_DATA)
- cerr << "WARNING: Test data is being used" << endl;
- // This data is taken from the datasheet, section 3.12
- m_dig_T1 = 27504;
- m_dig_T2 = 26435;
- m_dig_T3 = -1000;
-
- m_dig_P1 = 36477;
- m_dig_P2 = -10685;
- m_dig_P3 = 3024;
- m_dig_P4 = 2855;
- m_dig_P5 = 140;
- m_dig_P6 = -7;
- m_dig_P7 = 15500;
- m_dig_P8 = -14600;
- m_dig_P9 = 6000;
-
-#else
-
- uint8_t calibData[CALIBRATION_BYTES];
- readRegs(REG_CALIB00, calibData, CALIBRATION_BYTES);
-
- m_dig_T1 = uint16_t((calibData[1] << 8) | calibData[0]);
- m_dig_T2 = int16_t((calibData[3] << 8) | calibData[2]);
- m_dig_T3 = int16_t((calibData[5] << 8) | calibData[4]);
-
-# if 0
- cerr << std::dec << "T1: " << (int)m_dig_T1
- << " T2: " << (int)m_dig_T2
- << " T3: " << (int)m_dig_T3
- << endl;
-# endif // 0
-
- m_dig_P1 = uint16_t((calibData[7] << 8) | calibData[6]);
- m_dig_P2 = int16_t((calibData[9] << 8) | calibData[8]);
- m_dig_P3 = int16_t((calibData[11] << 8) | calibData[10]);
- m_dig_P4 = int16_t((calibData[13] << 8) | calibData[12]);
- m_dig_P5 = int16_t((calibData[15] << 8) | calibData[14]);
- m_dig_P6 = int16_t((calibData[17] << 8) | calibData[16]);
- m_dig_P7 = int16_t((calibData[19] << 8) | calibData[18]);
- m_dig_P8 = int16_t((calibData[21] << 8) | calibData[20]);
- m_dig_P9 = int16_t((calibData[23] << 8) | calibData[22]);
-
-# if 0
- cerr << std::dec << "P1: " << (int)m_dig_P1
- << " P2: " << (int)m_dig_P2
- << " P3: " << (int)m_dig_P3
- << " P4: " << (int)m_dig_P4
- << " P5: " << (int)m_dig_P5
- << endl;
- cerr << std::dec << "P6: " << (int)m_dig_P6
- << " P7: " << (int)m_dig_P7
- << " P8: " << (int)m_dig_P8
- << " P9: " << (int)m_dig_P9
- << endl;
-# endif // 0
-
-
-#endif
-}
-
-float BMP280::getTemperature(bool fahrenheit)
-{
- if (fahrenheit)
- return c2f(m_temperature);
- else
- return m_temperature;
-}
-
-float BMP280::getPressure()
-{
- return m_pressure;
-}
-
-void BMP280::setFilter(FILTER_T filter)
-{
- uint8_t reg = readReg(REG_CONFIG);
-
- reg &= ~(_CONFIG_FILTER_MASK << _CONFIG_FILTER_SHIFT);
- reg |= (filter << _CONFIG_FILTER_SHIFT);
-
- writeReg(REG_CONFIG, reg);
-}
-
-void BMP280::setTimerStandby(T_SB_T tsb)
-{
- uint8_t reg = readReg(REG_CONFIG);
-
- reg &= ~(_CONFIG_T_SB_MASK << _CONFIG_T_SB_SHIFT);
- reg |= (tsb << _CONFIG_T_SB_SHIFT);
-
- writeReg(REG_CONFIG, reg);
-}
-
-void BMP280::setMeasureMode(MODES_T mode)
-{
- uint8_t reg = readReg(REG_CTRL_MEAS);
-
- reg &= ~(_CTRL_MEAS_MODE_MASK << _CTRL_MEAS_MODE_SHIFT);
- reg |= (mode << _CTRL_MEAS_MODE_SHIFT);
-
- writeReg(REG_CTRL_MEAS, reg);
- m_mode = mode;
-}
-
-void BMP280::setOversampleRatePressure(OSRS_P_T rate)
-{
- uint8_t reg = readReg(REG_CTRL_MEAS);
-
- reg &= ~(_CTRL_MEAS_OSRS_P_MASK << _CTRL_MEAS_OSRS_P_SHIFT);
- reg |= (rate << _CTRL_MEAS_OSRS_P_SHIFT);
-
- writeReg(REG_CTRL_MEAS, reg);
-}
-
-void BMP280::setOversampleRateTemperature(OSRS_T_T rate)
-{
- uint8_t reg = readReg(REG_CTRL_MEAS);
-
- reg &= ~(_CTRL_MEAS_OSRS_T_MASK << _CTRL_MEAS_OSRS_T_SHIFT);
- reg |= (rate << _CTRL_MEAS_OSRS_T_SHIFT);
-
- writeReg(REG_CTRL_MEAS, reg);
-}
-
-uint8_t BMP280::getStatus()
-{
- return readReg(REG_STATUS);
-}
-
-void BMP280::setUsageMode(USAGE_MODE_T mode)
-{
- // set up the regs for the given usage mode. These settings come
- // from the recomendations in the BMP280 datasheet, section 3.4
- // Filter Selection.
-
- m_temperature = 0;
- m_pressure = 0;
-
- // set sleep mode first
- setMeasureMode(MODE_SLEEP);
-
- switch (mode)
- {
- case USAGE_MODE_HANDHELD_LOW_POWER:
- setOversampleRatePressure(OSRS_P_OVERSAMPLING_16);
- setOversampleRateTemperature(OSRS_T_OVERSAMPLING_2);
- setFilter(FILTER_4);
- setMeasureMode(MODE_NORMAL);
-
- break;
-
- case USAGE_MODE_HANDHELD_DYNAMIC:
- setOversampleRatePressure(OSRS_P_OVERSAMPLING_4);
- setOversampleRateTemperature(OSRS_T_OVERSAMPLING_1);
- setFilter(FILTER_16);
- setMeasureMode(MODE_NORMAL);
-
- break;
-
- case USAGE_MODE_WEATHER_MONITOR:
- setOversampleRatePressure(OSRS_P_OVERSAMPLING_1);
- setOversampleRateTemperature(OSRS_T_OVERSAMPLING_1);
- setFilter(FILTER_OFF);
- setMeasureMode(MODE_FORCED);
-
- break;
-
- case USAGE_MODE_FLOOR_CHG_DETECT:
- setOversampleRatePressure(OSRS_P_OVERSAMPLING_4);
- setOversampleRateTemperature(OSRS_T_OVERSAMPLING_1);
- setFilter(FILTER_4);
- setMeasureMode(MODE_NORMAL);
-
- break;
-
- case USAGE_MODE_DROP_DETECT:
- setOversampleRatePressure(OSRS_P_OVERSAMPLING_2);
- setOversampleRateTemperature(OSRS_T_OVERSAMPLING_1);
- setFilter(FILTER_OFF);
- setMeasureMode(MODE_NORMAL);
-
- break;
-
- case USAGE_MODE_INDOOR_NAV:
- setOversampleRatePressure(OSRS_P_OVERSAMPLING_16);
- setOversampleRateTemperature(OSRS_T_OVERSAMPLING_2);
- setFilter(FILTER_16);
- setMeasureMode(MODE_NORMAL);
-
- break;
-
- default:
- throw std::logic_error(string(__FUNCTION__)
- + ": invalid mode specified");
- }
-}
-
-void BMP280::csOn()
-{
- if (m_gpioCS)
- m_gpioCS->write(0);
-}
-
-void BMP280::csOff()
-{
- if (m_gpioCS)
- m_gpioCS->write(1);
-}
-
-// These functions come from the BMP280 datasheet, section 3.11.3
-
-// Returns temperature in DegC, resolution is 0.01 DegC. Output value
-// of “5123” equals 51.23 DegC. t_fine carries fine temperature as
-// global value
-int32_t BMP280::bmp280_compensate_T_int32(int32_t adc_T)
-{
- int32_t var1, var2, T;
- var1 = ((((adc_T>>3) - ((int32_t)m_dig_T1<<1))) * ((int32_t)m_dig_T2)) >> 11;
- var2 = (((((adc_T>>4) - ((int32_t)m_dig_T1)) * ((adc_T>>4) - ((int32_t)m_dig_T1))) >> 12) *
- ((int32_t)m_dig_T3)) >> 14;
- m_t_fine = var1 + var2;
- T = (m_t_fine * 5 + 128) >> 8;
- return T;
-}
-
-// Returns pressure in Pa as unsigned 32 bit integer in Q24.8 format
-// (24 integer bits and 8 fractional bits). Output value of
-// “24674867” represents 24674867/256 = 96386.2 Pa = 963.862 hPa
-uint32_t BMP280::bmp280_compensate_P_int64(int32_t adc_P)
-{
- int64_t var1, var2, p;
- var1 = ((int64_t)m_t_fine) - 128000;
- var2 = var1 * var1 * (int64_t)m_dig_P6;
- var2 = var2 + ((var1*(int64_t)m_dig_P5)<<17);
- var2 = var2 + (((int64_t)m_dig_P4)<<35);
- var1 = ((var1 * var1 * (int64_t)m_dig_P3)>>8) + ((var1 * (int64_t)m_dig_P2)<<12);
- var1 = (((((int64_t)1)<<47)+var1))*((int64_t)m_dig_P1)>>33;
- if (var1 == 0)
- {
- return 0; // avoid exception caused by division by zero
- }
- p = 1048576-adc_P;
- p = (((p<<31)-var2)*3125)/var1;
- var1 = (((int64_t)m_dig_P9) * (p>>13) * (p>>13)) >> 25;
- var2 = (((int64_t)m_dig_P8) * p) >> 19;
- p = ((p + var1 + var2) >> 8) + (((int64_t)m_dig_P7)<<4);
- return (uint32_t)p;
-}
diff --git a/peripheral/libupm/src/bmp280/bmp280.hpp b/peripheral/libupm/src/bmp280/bmp280.hpp
deleted file mode 100644
index 447ac61..0000000
--- a/peripheral/libupm/src/bmp280/bmp280.hpp
+++ /dev/null
@@ -1,490 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <mraa/i2c.hpp>
-#include <mraa/spi.hpp>
-#include <mraa/gpio.hpp>
-
-#include "upm/iPressureSensor.hpp"
-#include "upm/iTemperatureSensor.hpp"
-
-#define BMP280_DEFAULT_I2C_BUS 0
-#define BMP280_DEFAULT_SPI_BUS 0
-#define BMP280_DEFAULT_ADDR 0x77
-#define BMP280_DEFAULT_CHIPID 0x58
-
-namespace upm {
-
- /**
- * @brief BMP280 Digital Pressure Sensor
- * @defgroup bmp280 libupm-bmp280
- * @ingroup i2c spi gpio pressure
- */
-
- /**
- * @library bmp280
- * @sensor bmp280
- * @comname BMP280 Digital Pressure Sensor
- * @type pressure
- * @man adafruit
- * @con i2c spi gpio
- * @web https://www.adafruit.com/products/2651
- *
- * @brief API for the BMP280 Digital Pressure Sensor
- *
- * The BMP280 is an absolute barometric pressure sensor especially
- * designed for mobile applications. The sensor module is housed in
- * an extremely compact 8-pin metal-lid LGA package with a footprint
- * of only 2.0 × 2.5 mm2 and 0.95 mm package height. Its small
- * dimensions and its low power consumption of 2.7 μA @1Hz allow the
- * implementation in battery driven devices such as mobile phones,
- * GPS modules or watches.
- *
- * As the successor to the widely adopted BMP180, the BMP280
- * delivers high performance in all applications that require
- * precise pressure measurement. The BMP280 operates at lower noise,
- * supports new filter modes and an SPI interface within a footprint
- * 63% smaller than the BMP180.
- *
- * @snippet bmp280.cxx Interesting
- */
-
- class BMP280 : public ITemperatureSensor, public IPressureSensor {
- public:
- // special reset byte
- const uint8_t BMP280_RESET_BYTE = 0xb6;
-
- // number of bytes of stored calibration data
- const int CALIBRATION_BYTES = 26;
-
- /**
- * BMP280 registers
- */
- typedef enum : uint8_t {
- // Do not write into reserved bits.
-
- // read-only factory calibration data
- REG_CALIB00 = 0x88,
- REG_CALIB01 = 0x89,
- REG_CALIB02 = 0x8a,
- REG_CALIB03 = 0x8b,
- REG_CALIB04 = 0x8c,
- REG_CALIB05 = 0x8d,
- REG_CALIB06 = 0x8e,
- REG_CALIB07 = 0x8f,
- REG_CALIB08 = 0x90,
- REG_CALIB09 = 0x91,
- REG_CALIB10 = 0x92,
- REG_CALIB11 = 0x93,
- REG_CALIB12 = 0x94,
- REG_CALIB13 = 0x95,
- REG_CALIB14 = 0x96,
- REG_CALIB15 = 0x97,
- REG_CALIB16 = 0x98,
- REG_CALIB17 = 0x99,
- REG_CALIB18 = 0x9a,
- REG_CALIB19 = 0x9b,
- REG_CALIB20 = 0x9c,
- REG_CALIB21 = 0x9d,
- REG_CALIB22 = 0x9e,
- REG_CALIB23 = 0x9f,
- REG_CALIB24 = 0xa0,
- REG_CALIB25 = 0xa1,
-
- REG_CHIPID = 0xd0,
- REG_RESET = 0xe0,
- REG_STATUS = 0xf3,
- REG_CTRL_MEAS = 0xf4,
- REG_CONFIG = 0xf5,
-
- REG_PRESSURE_MSB = 0xf7,
- REG_PRESSURE_LSB = 0xf8,
- REG_PRESSURE_XLSB = 0xf9,
-
- REG_TEMPERATURE_MSB = 0xfa,
- REG_TEMPERATURE_LSB = 0xfb,
- REG_TEMPERATURE_XLSB = 0xfc
- } BMP280_REGS_T;
-
- /**
- * REG_CONFIG bits
- */
- typedef enum {
- CONFIG_SPI3W_EN = 0x01,
-
- // 0x02 reserved
-
- CONFIG_FILTER0 = 0x04,
- CONFIG_FILTER1 = 0x08,
- CONFIG_FILTER2 = 0x10,
- _CONFIG_FILTER_MASK = 7,
- _CONFIG_FILTER_SHIFT = 2,
-
- CONFIG_T_SB0 = 0x20,
- CONFIG_T_SB1 = 0x40,
- CONFIG_T_SB2 = 0x80,
- _CONFIG_T_SB_MASK = 7,
- _CONFIG_T_SB_SHIFT = 5
- } CONFIG_BITS_T;
-
- /**
- * FILTER values (samples to reach >= 75% of step response)
- */
- typedef enum {
- FILTER_OFF = 0, // 1 samples
- FILTER_2 = 1, // 2
- FILTER_4 = 2, // 5
- FILTER_8 = 3, // 11
- FILTER_16 = 4 // 22
- } FILTER_T;
-
- /**
- * T_SB values (timer standby)
- */
- typedef enum {
- T_SB_0_5 = 0, // 0.5ms
- T_SB_62_5 = 1, // 62.5ms
- T_SB_125 = 2, // 125ms
- T_SB_250 = 3,
- T_SB_500 = 4,
- T_SB_1000 = 5,
- T_SB_2000 = 6, // bme280 - 10ms
- T_SB_4000 = 7 // bme280 - 20ms
- } T_SB_T;
-
-
- /**
- * REG_CTRL_MEAS bits
- */
- typedef enum {
- CTRL_MEAS_MODE0 = 0x01,
- CTRL_MEAS_MODE1 = 0x02,
- _CTRL_MEAS_MODE_MASK = 3,
- _CTRL_MEAS_MODE_SHIFT = 0,
-
- CTRL_MEAS_OSRS_P0 = 0x04,
- CTRL_MEAS_OSRS_P1 = 0x08,
- CTRL_MEAS_OSRS_P2 = 0x10,
- _CTRL_MEAS_OSRS_P_MASK = 7,
- _CTRL_MEAS_OSRS_P_SHIFT = 2,
-
- CTRL_MEAS_OSRS_T0 = 0x04,
- CTRL_MEAS_OSRS_T1 = 0x08,
- CTRL_MEAS_OSRS_T2 = 0x10,
- _CTRL_MEAS_OSRS_T_MASK = 7,
- _CTRL_MEAS_OSRS_T_SHIFT = 5
- } CTRL_MEAS_T;
-
- /**
- * CTRL_MEAS_MODE values
- */
- typedef enum {
- MODE_SLEEP = 0,
- MODE_FORCED = 1,
- // 2 is also FORCED mode
- MODE_NORMAL = 3
- } MODES_T;
-
- /**
- * CTRL_MEAS_OSRS_P values
- */
- typedef enum {
- OSRS_P_SKIPPED = 0,
- OSRS_P_OVERSAMPLING_1 = 1, // x1
- OSRS_P_OVERSAMPLING_2 = 2, // x2
- OSRS_P_OVERSAMPLING_4 = 3,
- OSRS_P_OVERSAMPLING_8 = 4,
- OSRS_P_OVERSAMPLING_16 = 5
- } OSRS_P_T;
-
- /**
- * CTRL_MEAS_OSRS_T values
- */
- typedef enum {
- OSRS_T_SKIPPED = 0,
- OSRS_T_OVERSAMPLING_1 = 1, // x1
- OSRS_T_OVERSAMPLING_2 = 2, // x2
- OSRS_T_OVERSAMPLING_4 = 3,
- OSRS_T_OVERSAMPLING_8 = 4,
- OSRS_T_OVERSAMPLING_16 = 5
- } OSRS_T_T;
-
- /**
- * REG_STATUS bits
- */
- typedef enum {
- STATUS_IM_UPDATE = 0x01,
- // 0x02-0x04 reserved
- STATUS_MEASURING = 0x08
- // 0x10-0x80 reserved
- } STATUS_T;
-
- /**
- * USAGE_MODE values. This is a fake specification to configure
- * the various knobs based on their typical use modes, as
- * recommended by Bosch.
- */
- typedef enum {
- USAGE_MODE_HANDHELD_LOW_POWER = 0,
- USAGE_MODE_HANDHELD_DYNAMIC = 1,
- USAGE_MODE_WEATHER_MONITOR = 2, // lowest power consumption
- USAGE_MODE_FLOOR_CHG_DETECT = 3,
- USAGE_MODE_DROP_DETECT = 4,
- USAGE_MODE_INDOOR_NAV = 5 // highest resolution
- } USAGE_MODE_T;
-
- /**
- * BMP280 constructor.
- *
- * This device can support both I2C and SPI. For SPI, set the addr
- * to -1, and specify a positive integer representing the Chip
- * Select (CS) pin for the cs argument. If you are using a
- * hardware CS pin, then you can connect the proper pin to the
- * hardware CS pin on your MCU and supply -1 for cs. The default
- * operating mode is I2C.
- *
- * @param bus I2C or SPI bus to use.
- * @param address The address for this device. -1 for SPI.
- * @param cs The gpio pin to use for the SPI Chip Select. -1 for
- * I2C or for SPI with a hardware controlled pin.
- * @param theChipID The chip ID to use for validation
- */
- BMP280(int bus=BMP280_DEFAULT_I2C_BUS, int addr=BMP280_DEFAULT_ADDR,
- int cs=-1, uint8_t theChipID=BMP280_DEFAULT_CHIPID);
-
- /**
- * BMP280 Destructor.
- */
- virtual ~BMP280();
-
- /**
- * Update the internal stored values from sensor data.
- */
- virtual void update();
-
- /**
- * Return the chip ID.
- *
- * @return The chip ID (BMP280_CHIPID).
- */
- uint8_t getChipID();
-
- /**
- * Reset the sensor, as if by a power-on-reset.
- */
- void reset();
-
- /**
- * Return the current measured temperature. Note, this is not
- * ambient temperature - this is the temperature used to fine tune
- * the pressure measurement. update() must have been called prior
- * to calling this method.
- *
- * @param fahrenheit true to return data in Fahrenheit, false for
- * Celicus. Celcius is the default.
- * @return The temperature in degrees Celcius or Fahrenheit.
- */
- float getTemperature(bool fahrenheit=false);
-
- /**
- * Return the current measured pressure in Pascals (Pa). update()
- * must have been called prior to calling this method.
- *
- * @return The pressure in Pascals (Pa).
- */
- float getPressure();
-
- /**
- * Return the current computed altitude in meters. update()
- * must have been called prior to calling this method.
- *
- * @param seaLevelhPA The pressure at sea level in hectoPascals
- * (hPa). The default is 1013.25 hPA, (101325 Pa).
- * @return The computed altitude in meters.
- */
- float getAltitude(float seaLevelhPA=1013.25);
-
- /**
- * Set a general usage mode. This function can be used to
- * configure the filters and oversampling for a particular use
- * case. These setting are documented in the BMP280 datasheet.
- * The default mode set in the contructor is
- * USAGE_MODE_INDOOR_NAV, the highest resolution mode.
- *
- * @param mode One of the USAGE_MODE_T values.
- */
- virtual void setUsageMode(USAGE_MODE_T mode);
-
- /**
- * Set the temperature sensor oversampling parameter. See the
- * data sheet for details. This value can be automatically set to
- * a suitable value by using one of the predefined modes for
- * setUsageMode().
- *
- * @param mode One of the OSRS_T_T values.
- */
- void setOversampleRateTemperature(OSRS_T_T rate);
-
- /**
- * Set the pressure sensor oversampling parameter. See the
- * data sheet for details. This value can be automatically set to
- * a suitable value by using one of the predefined modes for
- * setUsageMode().
- *
- * @param mode One of the OSRS_P_T values.
- */
- void setOversampleRatePressure(OSRS_P_T rate);
-
- /**
- * Set the timer standby value. When in NORMAL operating mode,
- * this timer governs how long the chip will wait before
- * performing a measurement. See the data sheet for details.
- *
- * @param mode One of the T_SB_T values.
- */
- void setTimerStandby(T_SB_T tsb);
-
- /**
- * Set the IIR filtering parameter. See the data sheet for
- * details. This value can be automatically set to a suitable
- * value by using one of the predefined modes for setUsageMode().
- *
- * @param mode One of the FILTER_T values.
- */
- void setFilter(FILTER_T filter);
-
- /**
- * Set the default measuring mode. Basic values are forced,
- * sleep, and normal. See the data sheet for details. This value
- * can be automatically set to a suitable value by using one of
- * the predefined modes for setUsageMode().
- *
- * @param mode One of the MODES_T values.
- */
- void setMeasureMode(MODES_T mode);
-
-
- // Interface support
- const char *getModuleName()
- {
- return "BMP280";
- };
-
- int getTemperatureCelcius()
- {
- return int(getTemperature(false));
- };
-
- int getPressurePa()
- {
- return int(getPressure());
- };
-
- protected:
- mraa::I2c *m_i2c;
- mraa::Spi *m_spi;
- mraa::Gpio *m_gpioCS;
-
- uint8_t m_addr;
-
- // always stored in C
- float m_temperature;
-
- // pressure in Pa
- float m_pressure;
-
- // shared calibration data - set in temp conversion, used in
- // pressure conversion.
- int32_t m_t_fine;
-
- // current operating mode. MODE_FORCED requires special attention
- // in update()
- MODES_T m_mode;
-
- // return the status register
- uint8_t getStatus();
-
- /**
- * Read a register.
- *
- * @param reg The register to read
- * @return The value of the register
- */
- uint8_t readReg(uint8_t reg);
-
- /**
- * Read contiguous registers into a buffer.
- *
- * @param buffer The buffer to store the results
- * @param len The number of registers to read
- * @return The number of bytes read, or -1 on error
- */
- int readRegs(uint8_t reg, uint8_t *buffer, int len);
-
- /**
- * Write to a register
- *
- * @param reg The register to write to
- * @param val The value to write
- */
- void writeReg(uint8_t reg, uint8_t val);
-
- // clear member data...
- void clearData();
-
- // read the calibration data
- virtual void readCalibrationData();
-
- // SPI chip select
- void csOn();
- void csOff();
-
- private:
- // are we doing SPI?
- bool m_isSPI;
-
- // calibration data temperature
- uint16_t m_dig_T1;
- int16_t m_dig_T2;
- int16_t m_dig_T3;
-
- // calibration data pressure
- uint16_t m_dig_P1;
- int16_t m_dig_P2;
- int16_t m_dig_P3;
- int16_t m_dig_P4;
- int16_t m_dig_P5;
- int16_t m_dig_P6;
- int16_t m_dig_P7;
- int16_t m_dig_P8;
- int16_t m_dig_P9;
-
- // Bosch supplied conversion/compensation functions from the
- // datasheet.
- int32_t bmp280_compensate_T_int32(int32_t adc_T);
- uint32_t bmp280_compensate_P_int64(int32_t adc_P);
- };
-}
diff --git a/peripheral/libupm/src/bmp280/javaupm_bmp280.i b/peripheral/libupm/src/bmp280/javaupm_bmp280.i
deleted file mode 100644
index f91403f..0000000
--- a/peripheral/libupm/src/bmp280/javaupm_bmp280.i
+++ /dev/null
@@ -1,28 +0,0 @@
-%module javaupm_bmp280
-%include "../upm.i"
-%include "cpointer.i"
-%include "typemaps.i"
-%include "arrays_java.i";
-%include "../java_buffer.i"
-
-%include "bmp280.hpp"
-%{
- #include "bmp280.hpp"
-%}
-
-%include "bme280.hpp"
-%{
- #include "bme280.hpp"
-%}
-
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_bmp280");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/bmp280/jsupm_bmp280.i b/peripheral/libupm/src/bmp280/jsupm_bmp280.i
deleted file mode 100644
index 1d7d75f..0000000
--- a/peripheral/libupm/src/bmp280/jsupm_bmp280.i
+++ /dev/null
@@ -1,13 +0,0 @@
-%module jsupm_bmp280
-%include "../upm.i"
-%include "cpointer.i"
-
-%include "bmp280.hpp"
-%{
- #include "bmp280.hpp"
-%}
-
-%include "bme280.hpp"
-%{
- #include "bme280.hpp"
-%}
diff --git a/peripheral/libupm/src/bmp280/pyupm_bmp280.i b/peripheral/libupm/src/bmp280/pyupm_bmp280.i
deleted file mode 100644
index d6d1f7b..0000000
--- a/peripheral/libupm/src/bmp280/pyupm_bmp280.i
+++ /dev/null
@@ -1,23 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_bmp280
-%include "../upm.i"
-%include "cpointer.i"
-
-%include "stdint.i"
-
-%feature("autodoc", "3");
-
-#ifdef DOXYGEN
-%include "bmp280_doc.i"
-#endif
-
-%include "bmp280.hpp"
-%{
- #include "bmp280.hpp"
-%}
-
-%include "bme280.hpp"
-%{
- #include "bme280.hpp"
-%}
diff --git a/peripheral/libupm/src/bmpx8x/CMakeLists.txt b/peripheral/libupm/src/bmpx8x/CMakeLists.txt
index 172e432..5960e12 100644
--- a/peripheral/libupm/src/bmpx8x/CMakeLists.txt
+++ b/peripheral/libupm/src/bmpx8x/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "bmpx8x")
set (libdescription "upm BMPX8X")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/bmpx8x/bmpx8x.cxx b/peripheral/libupm/src/bmpx8x/bmpx8x.cxx
index 5bf7f57..058e265 100644
--- a/peripheral/libupm/src/bmpx8x/bmpx8x.cxx
+++ b/peripheral/libupm/src/bmpx8x/bmpx8x.cxx
@@ -28,14 +28,14 @@
#include <unistd.h>
#include <stdlib.h>
-#include "bmpx8x.hpp"
+#include "bmpx8x.h"
using namespace upm;
BMPX8X::BMPX8X (int bus, int devAddr, uint8_t mode) : m_controlAddr(devAddr), m_i2ControlCtx(bus) {
-
+
m_name = "BMPX8X";
-
+
mraa::Result ret = m_i2ControlCtx.address(m_controlAddr);
if (ret != mraa::SUCCESS) {
throw std::invalid_argument(std::string(__FUNCTION__) +
@@ -93,8 +93,7 @@ BMPX8X::getPressure () {
B7 = ((uint32_t)UP - B3) * (uint32_t)( 50000UL >> oversampling );
if (B7 < 0x80000000) {
- p = (B7 * 2) / B4
-;
+ p = (B7 * 2) / B4;
} else {
p = (B7 / B4) * 2;
}
@@ -170,18 +169,6 @@ BMPX8X::getAltitude (float sealevelPressure) {
return altitude;
}
-
-int
-BMPX8X::getTemperatureCelcius() {
- return static_cast<int>(getTemperature() + 0.5);
-}
-
-const char*
-BMPX8X::getModuleName() {
- return m_name.c_str();
-}
-
-
int32_t
BMPX8X::computeB5(int32_t UT) {
int32_t X1 = (UT - (int32_t)ac6) * ((int32_t)ac5) >> 15;
diff --git a/peripheral/libupm/src/bmpx8x/bmpx8x.hpp b/peripheral/libupm/src/bmpx8x/bmpx8x.h
index 40033fe..a58ef08 100644
--- a/peripheral/libupm/src/bmpx8x/bmpx8x.hpp
+++ b/peripheral/libupm/src/bmpx8x/bmpx8x.h
@@ -30,8 +30,6 @@
#include <string>
#include <mraa/i2c.hpp>
#include <math.h>
-#include "upm/iPressureSensor.hpp"
-#include "upm/iTemperatureSensor.hpp"
#define ADDR 0x77 // device address
@@ -90,7 +88,7 @@ namespace upm {
* @snippet bmpx8x.cxx Interesting
*/
-class BMPX8X : public IPressureSensor, public ITemperatureSensor {
+class BMPX8X {
public:
/**
* Instantiates a BMPX8X object
@@ -144,26 +142,6 @@ class BMPX8X : public IPressureSensor, public ITemperatureSensor {
float getAltitude (float sealevelPressure = 101325);
/**
- * Return latest calculated temperature value in Celcius
- * See ITemperatureSensor
- */
- int getTemperatureCelcius();
-
- /**
- * Return latest calculated pressure value in Pascals
- * See IPressureSensor
- */
- int getPressurePa() { return getPressure(); };
-
- /**
- * Returns name of module. This is the string in library name
- * after libupm_
-
- * @return name of module
- */
- const char* getModuleName();
-
- /**
* Calculates B5 (check the spec for more information)
*
* @param UT
diff --git a/peripheral/libupm/src/bmpx8x/javaupm_bmpx8x.i b/peripheral/libupm/src/bmpx8x/javaupm_bmpx8x.i
index d50c74d..227056b 100644
--- a/peripheral/libupm/src/bmpx8x/javaupm_bmpx8x.i
+++ b/peripheral/libupm/src/bmpx8x/javaupm_bmpx8x.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "bmpx8x.hpp"
+ #include "bmpx8x.h"
%}
-%include "bmpx8x.hpp"
+%include "bmpx8x.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/bmpx8x/jsupm_bmpx8x.i b/peripheral/libupm/src/bmpx8x/jsupm_bmpx8x.i
index de9c949..419f75c 100644
--- a/peripheral/libupm/src/bmpx8x/jsupm_bmpx8x.i
+++ b/peripheral/libupm/src/bmpx8x/jsupm_bmpx8x.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "bmpx8x.hpp"
+ #include "bmpx8x.h"
%}
-%include "bmpx8x.hpp"
+%include "bmpx8x.h"
diff --git a/peripheral/libupm/src/bmpx8x/pyupm_bmpx8x.i b/peripheral/libupm/src/bmpx8x/pyupm_bmpx8x.i
index c514e0f..22f3fe2 100644
--- a/peripheral/libupm/src/bmpx8x/pyupm_bmpx8x.i
+++ b/peripheral/libupm/src/bmpx8x/pyupm_bmpx8x.i
@@ -5,8 +5,8 @@
%include "stdint.i"
-%include "bmpx8x.hpp"
+%include "bmpx8x.h"
%{
- #include "bmpx8x.hpp"
+ #include "bmpx8x.h"
%}
diff --git a/peripheral/libupm/src/bmx055/CMakeLists.txt b/peripheral/libupm/src/bmx055/CMakeLists.txt
deleted file mode 100644
index 5e968a5..0000000
--- a/peripheral/libupm/src/bmx055/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set (libname "bmx055")
-set (libdescription "Bosch bmx055, bmi055, bma250e, bmc150, bmg160, bmm150")
-set (module_src ${libname}.cxx bma250e.cxx bmg160.cxx bmm150.cxx bmc150.cxx bmi055.cxx)
-set (module_hpp ${libname}.hpp bma250e.hpp bmg160.hpp bmm150.hpp bmc150.cxx bmi055.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/bmx055/bma250e.cxx b/peripheral/libupm/src/bmx055/bma250e.cxx
deleted file mode 100644
index bdf41ca..0000000
--- a/peripheral/libupm/src/bmx055/bma250e.cxx
+++ /dev/null
@@ -1,735 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-#include <string.h>
-
-#include "bma250e.hpp"
-
-using namespace upm;
-using namespace std;
-
-// conversion from celcius to fahrenheit
-
-static float c2f(float c)
-{
- return (c * (9.0 / 5.0) + 32.0);
-}
-
-BMA250E::BMA250E(int bus, uint8_t addr, int cs) :
- m_i2c(0), m_spi(0), m_gpioIntr1(0), m_gpioIntr2(0), m_gpioCS(0)
-{
- m_addr = addr;
- m_isSPI = false;
-
- m_accX = 0;
- m_accY = 0;
- m_accZ = 0;
- m_accScale = 0;
- m_temperature = 0.0;
-
- if (addr < 0)
- m_isSPI = true;
-
- if (m_isSPI)
- {
- m_spi = new mraa::Spi(bus);
-
- // Only create cs context if we are actually using a valid pin.
- // A hardware controlled pin should specify cs as -1.
- if (cs >= 0)
- {
- m_gpioCS = new mraa::Gpio(cs);
- m_gpioCS->dir(mraa::DIR_OUT);
- }
-
- m_spi->mode(mraa::SPI_MODE0);
- m_spi->frequency(5000000);
- }
- else
- {
- // I2C
- m_i2c = new mraa::I2c(bus);
-
- mraa::Result rv;
- if ((rv = m_i2c->address(m_addr)) != mraa::SUCCESS)
- {
- throw std::runtime_error(string(__FUNCTION__) +
- ": I2c.address() failed");
- }
- }
-
- // check the chip id
-
- uint8_t chipID = getChipID();
-
- m_useFIFO = false;
-
- // check the various chips id's and set appropriate capabilities.
- // Bail if the chip id is unknown.
- switch (chipID)
- {
- case 0xf9: // standalone bma250e
- m_resolution = RESOLUTION_10BITS;
- m_fifoAvailable = true;
-
- break;
-
- case 0xfa: // bmx055, bmi055 variants, 12b resolution
- m_resolution = RESOLUTION_12BITS;
- m_fifoAvailable = true;
-
- break;
-
- case 0x03: // bmc050 variant, no FIFO, 12b resolution
- m_resolution = RESOLUTION_12BITS;
- m_fifoAvailable = false;
-
- break;
-
- default:
- throw std::runtime_error(string(__FUNCTION__)
- + ": invalid chip ID. Expected "
- + "3, 249, or 250 "
- + ", got "
- + std::to_string(int(chipID)));
- }
-
- // call init with default options
- init();
-}
-
-BMA250E::~BMA250E()
-{
- uninstallISR(INTERRUPT_INT1);
- uninstallISR(INTERRUPT_INT2);
-}
-
-void BMA250E::init(POWER_MODE_T pwr, RANGE_T range, BW_T bw)
-{
- setPowerMode(pwr);
- usleep(50000); // 50ms, in case we are waking up
-
- // set our range and bandwidth
- setRange(range);
- setBandwidth(bw);
-
- // make sure register shadowing is enabled
- enableRegisterShadowing(true);
-
- // enable output filtering
- enableOutputFiltering(true);
-
- // use the FIFO by default, if we have one
- fifoConfig(FIFO_MODE_BYPASS, FIFO_DATA_SEL_XYZ);
- enableFIFO(true);
-
- // make sure low power mode LPM2 is enabled in case we go to low
- // power or suspend mode. LPM1 mode (the default) requires register
- // writes to be drastically slowed down when enabled, which we
- // cannot handle.
- setLowPowerMode2();
-
- // settle
- usleep(50000);
-}
-
-void BMA250E::update()
-{
- int bufLen = 0;
- uint8_t startReg = 0;
-
- if (m_useFIFO)
- {
- bufLen = 6;
- startReg = REG_FIFO_DATA;
- }
- else
- {
- // non FIFO, read acc regs directly (including temp)
- bufLen = 7;
- startReg = REG_ACCD_X_LSB;
- }
-
- uint8_t buf[bufLen];
-
- if (readRegs(startReg, buf, bufLen) != bufLen)
- {
- throw std::runtime_error(string(__FUNCTION__)
- + ": readRegs() failed to read "
- + std::to_string(bufLen)
- + " bytes");
- }
-
- uint8_t mask, shift;
- float divisor;
-
- switch (m_resolution)
- {
- case RESOLUTION_10BITS:
- mask = _ACCD10_LSB_MASK;
- shift = _ACCD10_LSB_SHIFT;
- divisor = 64.0;
-
- break;
-
- case RESOLUTION_12BITS:
- mask = _ACCD12_LSB_MASK;
- shift = _ACCD12_LSB_SHIFT;
- divisor = 16.0;
-
- break;
-
- default:
- throw std::logic_error(string(__FUNCTION__)
- + ": internal error: invalid resolution "
- + std::to_string(int(m_resolution)));
- }
-
- int16_t val;
-
- // x
- val = int16_t(buf[1] << 8 | (buf[0] & (mask << shift)));
- m_accX = float(val / divisor);
-
- // y
- val = int16_t(buf[3] << 8 | (buf[2] & (mask << shift)));
- m_accY = float(val / divisor);
-
- // z
- val = int16_t(buf[5] << 8 | (buf[4] & (mask << shift)));
- m_accZ = float(val / divisor);
-
- // get the temperature...
-
- uint8_t temp = 0;
- if (m_useFIFO)
- {
- // we have to read temperature separately...
- temp = readReg(REG_TEMP);
- }
- else
- {
- // we've already got it
- temp = buf[6];
- }
-
- // .5K/LSB, 23C center point
- m_temperature = (float(temp) / 2.0) + 23.0;
-}
-
-void BMA250E::enableFIFO(bool useFIFO)
-{
- if (m_fifoAvailable)
- m_useFIFO = useFIFO;
-}
-
-uint8_t BMA250E::readReg(uint8_t reg)
-{
- if (m_isSPI)
- {
- reg |= 0x80; // needed for read
- uint8_t pkt[2] = {reg, 0};
-
- csOn();
- if (m_spi->transfer(pkt, pkt, 2))
- {
- csOff();
- throw std::runtime_error(string(__FUNCTION__)
- + ": Spi.transfer() failed");
- }
- csOff();
-
- return pkt[1];
- }
- else
- return m_i2c->readReg(reg);
-}
-
-int BMA250E::readRegs(uint8_t reg, uint8_t *buffer, int len)
-{
- if (m_isSPI)
- {
- reg |= 0x80; // needed for read
-
- uint8_t sbuf[len + 1];
- memset((char *)sbuf, 0, len + 1);
- sbuf[0] = reg;
-
- // We need to do it this way for edison - ie: use a single
- // transfer rather than breaking it up into two like we used to.
- // This means a buffer copy is now required, but that's the way
- // it goes.
-
- csOn();
- if (m_spi->transfer(sbuf, sbuf, len + 1))
- {
- csOff();
- throw std::runtime_error(string(__FUNCTION__)
- + ": Spi.transfer(buf) failed");
- }
- csOff();
-
- // now copy it into user buffer
- for (int i=0; i<len; i++)
- buffer[i] = sbuf[i + 1];
-
- return len;
- }
- else
- return m_i2c->readBytesReg(reg, buffer, len);
-}
-
-void BMA250E::writeReg(uint8_t reg, uint8_t val)
-{
- if (m_isSPI)
- {
- reg &= 0x7f; // mask off 0x80 for writing
- uint8_t pkt[2] = {reg, val};
-
- csOn();
- if (m_spi->transfer(pkt, NULL, 2))
- {
- csOff();
- throw std::runtime_error(string(__FUNCTION__)
- + ": Spi.transfer() failed");
- }
- csOff();
- }
- else
- {
- if (m_i2c->writeReg(reg, val) != mraa::SUCCESS)
- {
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": I2c.writeReg() failed");
- }
- }
-}
-
-void BMA250E::csOn()
-{
- if (m_gpioCS)
- m_gpioCS->write(0);
-}
-
-void BMA250E::csOff()
-{
- if (m_gpioCS)
- m_gpioCS->write(1);
-}
-
-uint8_t BMA250E::getChipID()
-{
- return readReg(REG_CHIP_ID);
-}
-
-void BMA250E::getAccelerometer(float *x, float *y, float *z)
-{
- if (x)
- *x = (m_accX * m_accScale) / 1000.0;
-
- if (y)
- *y = (m_accY * m_accScale) / 1000.0;
-
- if (z)
- *z = (m_accZ * m_accScale) / 1000.0;
-}
-
-float *BMA250E::getAccelerometer()
-{
- static float v[3];
-
- getAccelerometer(&v[0], &v[1], &v[2]);
- return v;
-}
-
-float BMA250E::getTemperature(bool fahrenheit)
-{
- if (fahrenheit)
- return c2f(m_temperature);
- else
- return m_temperature;
-}
-
-void BMA250E::reset()
-{
- writeReg(REG_SOFTRESET, BMA250E_RESET_BYTE);
- sleep(1);
-}
-
-void BMA250E::setRange(RANGE_T range)
-{
- switch (m_resolution)
- {
- case RESOLUTION_10BITS:
- switch(range)
- {
- case RANGE_2G:
- m_accScale = 3.91; // milli-gravities
- break;
-
- case RANGE_4G:
- m_accScale = 7.81;
- break;
-
- case RANGE_8G:
- m_accScale = 15.63;
- break;
-
- case RANGE_16G:
- m_accScale = 31.25;
- break;
- }
-
- break;
-
- case RESOLUTION_12BITS:
- switch(range)
- {
- case RANGE_2G:
- m_accScale = 0.98; // milli-gravities
- break;
-
- case RANGE_4G:
- m_accScale = 1.95;
- break;
-
- case RANGE_8G:
- m_accScale = 3.91;
- break;
-
- case RANGE_16G:
- m_accScale = 7.81;
- break;
- }
-
- break;
- }
-
- writeReg(REG_PMU_RANGE, range);
-}
-
-void BMA250E::setBandwidth(BW_T bw)
-{
- writeReg(REG_PMU_BW, bw);
-}
-
-void BMA250E::setPowerMode(POWER_MODE_T power)
-{
- // mask off reserved bits
- uint8_t reg = readReg(REG_PMU_LPW) & ~_PMU_LPW_RESERVED_MASK;
-
- reg &= ~(_PMU_LPW_POWER_MODE_MASK << _PMU_LPW_POWER_MODE_SHIFT);
- reg |= (power << _PMU_LPW_POWER_MODE_SHIFT);
-
- writeReg(REG_PMU_LPW, power);
-}
-
-void BMA250E::fifoSetWatermark(int wm)
-{
- // do nothing if we don't have a FIFO
- if (!m_fifoAvailable)
- return;
-
- // mask off illegal values
- uint8_t reg = uint8_t(wm) & _FIFO_CONFIG_0_WATER_MARK_MASK;
-
- writeReg(REG_FIFO_CONFIG_0, reg);
-}
-
-void BMA250E::fifoConfig(FIFO_MODE_T mode, FIFO_DATA_SEL_T axes)
-{
- // do nothing if we don't have a FIFO
- if (!m_fifoAvailable)
- return;
-
- uint8_t reg = ( (mode << _FIFO_CONFIG_1_FIFO_MODE_SHIFT) |
- (axes << _FIFO_CONFIG_1_FIFO_DATA_SHIFT) );
-
- writeReg(REG_FIFO_CONFIG_1, reg);
-}
-
-void BMA250E::setSelfTest(bool sign, bool amp, SELFTTEST_AXIS_T axis)
-{
- uint8_t reg = (axis << _PMU_SELFTTEST_AXIS_SHIFT);
-
- if (amp)
- reg |= PMU_SELFTTEST_AMP;
-
- if (sign)
- reg |= PMU_SELFTTEST_SIGN;
-
- writeReg(REG_PMU_SELFTEST, reg);
-}
-
-uint8_t BMA250E::getInterruptEnable0()
-{
- return readReg(REG_INT_EN_0) & ~_INT_EN_0_RESERVED_BITS;
-}
-
-void BMA250E::setInterruptEnable0(uint8_t bits)
-{
- uint8_t reg = bits & ~_INT_EN_0_RESERVED_BITS;
-
- writeReg(REG_INT_EN_0, reg);
-}
-
-uint8_t BMA250E::getInterruptEnable1()
-{
- return readReg(REG_INT_EN_1) & ~_INT_EN_1_RESERVED_BITS;
-}
-
-void BMA250E::setInterruptEnable1(uint8_t bits)
-{
- uint8_t reg = bits & ~_INT_EN_1_RESERVED_BITS;
-
- writeReg(REG_INT_EN_1, reg);
-}
-
-uint8_t BMA250E::getInterruptEnable2()
-{
- return readReg(REG_INT_EN_2) & ~_INT_EN_2_RESERVED_BITS;
-}
-
-void BMA250E::setInterruptEnable2(uint8_t bits)
-{
- uint8_t reg = bits & ~_INT_EN_2_RESERVED_BITS;
-
- writeReg(REG_INT_EN_2, reg);
-}
-
-uint8_t BMA250E::getInterruptMap0()
-{
- return readReg(REG_INT_MAP_0);
-}
-
-void BMA250E::setInterruptMap0(uint8_t bits)
-{
- writeReg(REG_INT_MAP_0, bits);
-}
-
-uint8_t BMA250E::getInterruptMap1()
-{
- return readReg(REG_INT_MAP_1) & ~_INT_MAP_1_INT1_RESERVED_BITS;
-}
-
-void BMA250E::setInterruptMap1(uint8_t bits)
-{
- uint8_t reg = bits & ~_INT_MAP_1_INT1_RESERVED_BITS;
-
- writeReg(REG_INT_MAP_1, reg);
-}
-
-uint8_t BMA250E::getInterruptMap2()
-{
- return readReg(REG_INT_MAP_2);
-}
-
-void BMA250E::setInterruptMap2(uint8_t bits)
-{
- writeReg(REG_INT_MAP_2, bits);
-}
-
-uint8_t BMA250E::getInterruptSrc()
-{
- return readReg(REG_INT_SRC) & ~_INT_SRC_RESERVED_BITS;
-}
-
-void BMA250E::setInterruptSrc(uint8_t bits)
-{
- uint8_t reg = bits & ~_INT_SRC_RESERVED_BITS;
-
- writeReg(REG_INT_SRC, reg);
-}
-
-uint8_t BMA250E::getInterruptOutputControl()
-{
- return readReg(REG_INT_OUT_CTRL) & ~_INT_OUT_CTRL_INT1_RESERVED_BITS;
-}
-
-void BMA250E::setInterruptOutputControl(uint8_t bits)
-{
- uint8_t reg = bits & ~_INT_OUT_CTRL_INT1_RESERVED_BITS;
-
- writeReg(REG_INT_OUT_CTRL, reg);
-}
-
-void BMA250E::clearInterruptLatches()
-{
- uint8_t reg = readReg(REG_INT_RST_LATCH) & ~_INT_RST_LATCH_RESERVED_BITS;
-
- reg |= INT_RST_LATCH_RESET_INT;
-
- writeReg(REG_INT_RST_LATCH, reg);
-}
-
-BMA250E::RST_LATCH_T BMA250E::getInterruptLatchBehavior()
-{
- uint8_t reg = readReg(REG_INT_RST_LATCH) & ~_INT_RST_LATCH_RESERVED_BITS;
-
- reg &= (_INT_RST_LATCH_MASK << _INT_RST_LATCH_SHIFT);
-
- return static_cast<RST_LATCH_T>(reg);
-}
-
-void BMA250E::setInterruptLatchBehavior(RST_LATCH_T latch)
-{
- uint8_t reg = readReg(REG_INT_RST_LATCH) & ~_INT_RST_LATCH_RESERVED_BITS;
-
- reg &= ~(_INT_RST_LATCH_MASK << _INT_RST_LATCH_SHIFT);
- reg |= (latch << _INT_RST_LATCH_SHIFT);
-
- writeReg(REG_INT_RST_LATCH, reg);
-}
-
-void BMA250E::enableRegisterShadowing(bool shadow)
-{
- uint8_t reg = readReg(REG_ACC_HBW) & ~_ACC_HBW_RESERVED_BITS;
-
- if (shadow)
- reg &= ~ACC_HBW_SHADOW_DIS;
- else
- reg |= ACC_HBW_SHADOW_DIS;
-
- writeReg(REG_ACC_HBW, reg);
-}
-
-void BMA250E::enableOutputFiltering(bool filter)
-{
- uint8_t reg = readReg(REG_ACC_HBW) & ~_ACC_HBW_RESERVED_BITS;
-
- if (filter)
- reg &= ~ACC_HBW_DATA_HIGH_BW;
- else
- reg |= ACC_HBW_DATA_HIGH_BW;
-
- writeReg(REG_ACC_HBW, reg);
-}
-
-uint8_t BMA250E::getInterruptStatus0()
-{
- return readReg(REG_INT_STATUS_0);
-}
-
-uint8_t BMA250E::getInterruptStatus1()
-{
- return readReg(REG_INT_STATUS_1) & ~_INT_STATUS_1_RESERVED_BITS;
-}
-
-uint8_t BMA250E::getInterruptStatus2()
-{
- return readReg(REG_INT_STATUS_2);
-}
-
-uint8_t BMA250E::getInterruptStatus3Bits()
-{
- // filter out the orientation bitfield..
- return readReg(REG_INT_STATUS_3) &
- ~(_INT_STATUS_3_ORIENT_MASK << _INT_STATUS_3_ORIENT_SHIFT);
-}
-
-BMA250E::ORIENT_T BMA250E::getInterruptStatus3Orientation()
-{
- // grab just the orientation bitfield
- uint8_t reg = readReg(REG_INT_STATUS_3) &
- (_INT_STATUS_3_ORIENT_MASK << _INT_STATUS_3_ORIENT_SHIFT);
-
- reg >>= _INT_STATUS_3_ORIENT_SHIFT;
-
- return static_cast<ORIENT_T>(reg);
-}
-
-void BMA250E::setLowPowerMode2()
-{
- uint8_t reg = readReg(REG_PMU_LOW_POWER) & ~_LOW_POWER_RESERVED_BITS;
-
- // we simply set the low power mode to 2. Low power mode 1 slows
- // down register write accesses, and we can't handle that. In the
- // words of the late Admiral Akbar: "We cannot handle firepower of
- // that magnitude!" :(
-
- reg |= LOW_POWER_LOWPOWER_MODE;
-
- writeReg(REG_PMU_LOW_POWER, reg);
-}
-
-#if defined(SWIGJAVA) || (JAVACALLBACK)
-void BMA250E::installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- jobject runnable)
-{
- // delete any existing ISR and GPIO context
- uninstallISR(intr);
-
- // create gpio context
- getPin(intr) = new mraa::Gpio(gpio);
-
- getPin(intr)->dir(mraa::DIR_IN);
- getPin(intr)->isr(level, runnable);
-}
-#else
-void BMA250E::installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- void (*isr)(void *), void *arg)
-{
- // delete any existing ISR and GPIO context
- uninstallISR(intr);
-
- // create gpio context
- getPin(intr) = new mraa::Gpio(gpio);
-
- getPin(intr)->dir(mraa::DIR_IN);
- getPin(intr)->isr(level, isr, arg);
-}
-#endif
-
-void BMA250E::uninstallISR(INTERRUPT_PINS_T intr)
-{
- if (getPin(intr))
- {
- getPin(intr)->isrExit();
- delete getPin(intr);
-
- getPin(intr) = 0;
- }
-}
-
-mraa::Gpio*& BMA250E::getPin(INTERRUPT_PINS_T intr)
-{
- switch(intr)
- {
- case INTERRUPT_INT1:
- return m_gpioIntr1;
- break;
-
- case INTERRUPT_INT2:
- return m_gpioIntr2;
- break;
-
- default:
- throw std::out_of_range(string(__FUNCTION__) +
- ": Invalid interrupt enum passed");
- }
-}
diff --git a/peripheral/libupm/src/bmx055/bma250e.hpp b/peripheral/libupm/src/bmx055/bma250e.hpp
deleted file mode 100644
index 46ae471..0000000
--- a/peripheral/libupm/src/bmx055/bma250e.hpp
+++ /dev/null
@@ -1,1461 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <mraa/i2c.hpp>
-#include <mraa/spi.hpp>
-#include <mraa/gpio.hpp>
-
-#define BMA250E_I2C_BUS 0
-#define BMA250E_SPI_BUS 0
-#define BMA250E_DEFAULT_ADDR 0x18
-
-
-namespace upm {
-
- /**
- * @library bmx050
- * @sensor bma250e
- * @comname BMA250E 10 bit Trixial Accelerometer
- * @type accelerometer
- * @man bosch
- * @con i2c spi gpio
- *
- * @brief API for the BMA250E 10 bit Trixial Accelerometer
- *
- * The BMA250E is a triaxial, low-g acceleration sensor with digital
- * output for consumer applications. It allows measurements of
- * acceleration in three perpendicular axes. An evaluation circuitry
- * (ASIC) converts the output of a micromechanical
- * acceleration-sensing structure (MEMS) that works according to the
- * differential capacitance principle.
- *
- * Not all functionality of this chip has been implemented in this
- * driver, however all the pieces are present to add any desired
- * functionality. This driver supports both I2C (default) and SPI
- * operation.
- *
- * This driver attempts to support verious flavors of this chip,
- * such as the version on the BMX050, BMI050 (chipid 0xfa) and the
- * version on the bmc050 (chipid 0x03). Not all functionality is
- * appropriate, or even present on all chips. Consult the relevant
- * datasheets.
- *
- * This device requires 3.3v operation.
- *
- * @snippet bma250e.cxx Interesting
- */
-
- class BMA250E {
- public:
- // special reset byte
- static const uint8_t BMA250E_RESET_BYTE = 0xb6;
-
- // NOTE: Reserved registers must not be written into. Reading
- // from them may return indeterminate values. Registers
- // containing reserved bitfields must be written as 0. Reading
- // reserved bitfields may return indeterminate values.
-
- /**
- * BMA250E registers
- */
- typedef enum : uint8_t {
- REG_CHIP_ID = 0x00,
-
- // 0x01 reserved
-
- REG_ACCD_X_LSB = 0x02,
- REG_ACCD_X_MSB = 0x03,
- REG_ACCD_Y_LSB = 0x04,
- REG_ACCD_Y_MSB = 0x05,
- REG_ACCD_Z_LSB = 0x06,
- REG_ACCD_Z_MSB = 0x07,
-
- REG_TEMP = 0x08,
-
- REG_INT_STATUS_0 = 0x09,
- REG_INT_STATUS_1 = 0x0a,
- REG_INT_STATUS_2 = 0x0b,
- REG_INT_STATUS_3 = 0x0c,
-
- // 0x0d reserved
-
- REG_FIFO_STATUS = 0x0e,
-
- REG_PMU_RANGE = 0x0f,
- REG_PMU_BW = 0x10,
- REG_PMU_LPW = 0x11,
- REG_PMU_LOW_POWER = 0x12,
-
- REG_ACC_HBW = 0x13,
-
- REG_SOFTRESET = 0x14,
-
- // 0x15 reserved
-
- REG_INT_EN_0 = 0x16,
- REG_INT_EN_1 = 0x17,
- REG_INT_EN_2 = 0x18,
-
- REG_INT_MAP_0 = 0x19,
- REG_INT_MAP_1 = 0x1a,
- REG_INT_MAP_2 = 0x1b,
-
- // 0x1c-0x1d reserved
-
- REG_INT_SRC = 0x1e,
-
- // 0x1f reserved
-
- REG_INT_OUT_CTRL = 0x20,
- REG_INT_RST_LATCH = 0x21,
-
- REG_INT_0 = 0x22,
- REG_INT_1 = 0x23,
- REG_INT_2 = 0x24,
- REG_INT_3 = 0x25,
- REG_INT_4 = 0x26,
- REG_INT_5 = 0x27,
- REG_INT_6 = 0x28,
- REG_INT_7 = 0x29,
- REG_INT_8 = 0x2a,
- REG_INT_9 = 0x2b,
- REG_INT_A = 0x2c,
- REG_INT_B = 0x2d,
- REG_INT_C = 0x2e,
- REG_INT_D = 0x2f,
-
- REG_FIFO_CONFIG_0 = 0x30,
-
- // 0x31 reserved
-
- REG_PMU_SELFTEST = 0x32,
-
- REG_TRIM_NVM_CTRL = 0x33,
-
- REG_SPI3_WDT = 0x34,
-
- // 0x35 reserved
-
- REG_OFC_CTRL = 0x36,
- REG_OFC_SETTING = 0x37,
-
- REG_OFC_OFFSET_X = 0x38,
- REG_OFC_OFFSET_Y = 0x39,
- REG_OFC_OFFSET_Z = 0x3a,
-
- REG_TRIM_GP0 = 0x3b,
- REG_TRIM_GP1 = 0x3c,
-
- // 0x3d reserved
-
- REG_FIFO_CONFIG_1 = 0x3e,
- REG_FIFO_DATA = 0x3f
-
- } BMA250E_REGS_T;
-
- /**
- * REG_ACCD_*_LSB bits - handle X, Y, and Z LSB regs, for 10 bit
- * resolution
- */
- typedef enum {
- ACCD10_LSB_NEW_DATA = 0x01, // data updated since last read
-
- // 0x02-0x20 reserved
-
- ACCD10_LSB0 = 0x40, // lower 2 bits of LSB data
- ACCD10_LSB1 = 0x80,
- _ACCD10_LSB_MASK = 3,
- _ACCD10_LSB_SHIFT = 6
- } ACCD10_LSB_BITS_T;
-
- /**
- * REG_ACCD_*_LSB bits - handle X, Y, and Z LSB regs, for 12 bit
- * resolution
- */
- typedef enum {
- ACCD12_LSB_NEW_DATA = 0x01, // data updated since last read
-
- // 0x02-0x08 reserved
-
- ACCD12_LSB0 = 0x10, // lower 4 bits of LSB data
- ACCD12_LSB1 = 0x20,
- ACCD12_LSB2 = 0x40,
- ACCD12_LSB3 = 0x80,
- _ACCD12_LSB_MASK = 15,
- _ACCD12_LSB_SHIFT = 4
- } ACCD12_LSB_BITS_T;
-
- /**
- * REG_INT_STATUS_0 bits
- */
- typedef enum {
- INT_STATUS_0_LOW = 0x01,
- INT_STATUS_0_HIGH = 0x02,
- INT_STATUS_0_SLOPE = 0x04,
- INT_STATUS_0_SLO_NOT_MOT = 0x08,
- INT_STATUS_0_D_TAP = 0x10,
- INT_STATUS_0_S_TAP = 0x20,
- INT_STATUS_0_ORIENT = 0x40,
- INT_STATUS_0_FLAT = 0x80
- } INT_STATUS_0_BITS_T;
-
- /**
- * REG_INT_STATUS_1 bits
- */
- typedef enum {
- _INT_STATUS_1_RESERVED_BITS = 0x0f | 0x10,
- // 0x01-0x10 reserved
- INT_STATUS_1_FIFO_FULL = 0x20,
- INT_STATUS_1_FIFO_WM = 0x40,
- INT_STATUS_1_DATA = 0x80 // data ready int
- } INT_STATUS_1_BITS_T;
-
- /**
- * REG_INT_STATUS_2 bits
- */
- typedef enum {
- INT_STATUS_2_SLOPE_FIRST_X = 0x01,
- INT_STATUS_2_SLOPE_FIRST_Y = 0x02,
- INT_STATUS_2_SLOPE_FIRST_Z = 0x04,
- INT_STATUS_2_SLOPE_SIGN = 0x08,
- INT_STATUS_2_TAP_FIRST_X = 0x10,
- INT_STATUS_2_TAP_FIRST_Y = 0x20,
- INT_STATUS_2_TAP_FIRST_Z = 0x40,
- INT_STATUS_2_TAP_SIGN = 0x80
- } INT_STATUS_2_BITS_T;
-
- /**
- * REG_INT_STATUS_3 bits
- */
- typedef enum {
- INT_STATUS_3_HIGH_FIRST_X = 0x01,
- INT_STATUS_3_HIGH_FIRST_Y = 0x02,
- INT_STATUS_3_HIGH_FIRST_Z = 0x04,
- INT_STATUS_3_HIGH_SIGN = 0x08,
-
- INT_STATUS_3_ORIENT0 = 0x10,
- INT_STATUS_3_ORIENT1 = 0x20,
- INT_STATUS_3_ORIENT2 = 0x40,
- _INT_STATUS_3_ORIENT_MASK = 7,
- _INT_STATUS_3_ORIENT_SHIFT = 4,
-
- INT_STATUS_3_FLAT = 0x80
- } INT_STATUS_3_BITS_T;
-
- /**
- * INT_STATUS_3_ORIENT values
- */
- typedef enum {
- ORIENT_POTRAIT_UPRIGHT = 0,
- ORIENT_POTRAIT_UPSIDE_DOWN = 1,
- ORIENT_LANDSCAPE_LEFT = 2,
- ORIENT_LANDSCAPE_RIGHT = 3,
- } ORIENT_T;
-
- /**
- * REG_FIFO_STATUS bits
- */
- typedef enum {
- FIFO_STATUS_FRAME_COUNTER0 = 0x01,
- FIFO_STATUS_FRAME_COUNTER1 = 0x02,
- FIFO_STATUS_FRAME_COUNTER2 = 0x04,
- FIFO_STATUS_FRAME_COUNTER3 = 0x08,
- FIFO_STATUS_FRAME_COUNTER4 = 0x10,
- FIFO_STATUS_FRAME_COUNTER5 = 0x20,
- FIFO_STATUS_FRAME_COUNTER6 = 0x40,
- _FIFO_STATUS_FRAME_COUNTER_MASK = 127,
- _FIFO_STATUS_FRAME_COUNTER_SHIFT = 0,
-
- FIFO_STATUS_FIFO_OVERRUN = 0x80
- } FIFO_STATUS_BITS_T;
-
- /**
- * REG_PMU_RANGE bits
- */
- typedef enum {
- PMU_RANGE0 = 0x01,
- PMU_RANGE1 = 0x02,
- PMU_RANGE2 = 0x04,
- PMU_RANGE3 = 0x08,
- _PMU_RANGE_MASK = 15,
- _PMU_RANGE_SHIFT = 0
-
- // 0x10-0x80 reserved
- } PMU_RANGE_BITS_T;
-
- /**
- * PMU_RANGE (accelerometer g-range) values
- */
- typedef enum {
- RANGE_2G = 3,
- RANGE_4G = 5,
- RANGE_8G = 8,
- RANGE_16G = 12
- } RANGE_T;
-
- /**
- * REG_PMU_BW bits
- */
- typedef enum {
- PMU_BW0 = 0x01,
- PMU_BW1 = 0x02,
- PMU_BW2 = 0x04,
- PMU_BW3 = 0x08,
- PMU_BW4 = 0x10,
- _PMU_BW_MASK = 31,
- _PMU_BW_SHIFT = 0
-
- // 0x20-0x80 reserved
- } PMU_BW_BITS_T;
-
- /**
- * PMU_BW (accelerometer filter bandwidth) values
- */
- typedef enum {
- BW_7_81 = 8, // 7.81 Hz
- BW_15_63 = 9,
- BW_31_25 = 10,
- BW_62_5 = 11,
- BW_125 = 12,
- BW_250 = 13,
- BW_500 = 14,
- BW_1000 = 15
- } BW_T;
-
- /**
- * REG_PMU_LPW bits
- */
- typedef enum {
- // 0x01 reserved
- _PMU_LPW_RESERVED_MASK = 0x01,
-
- PMU_LPW_SLEEP_DUR0 = 0x02, // sleep dur in low power mode
- PMU_LPW_SLEEP_DUR1 = 0x04,
- PMU_LPW_SLEEP_DUR2 = 0x08,
- PMU_LPW_SLEEP_DUR3 = 0x10,
- _PMU_LPW_SLEEP_MASK = 15,
- _PMU_LPW_SLEEP_SHIFT = 1,
-
- // These are separate bits, deep_suspend, lowpower_en and
- // suspend (and if all 0, normal). Since only specific
- // combinations are allowed, we will treat this as a 3 bit
- // bitfield called POWER_MODE.
- PMU_LPW_POWER_MODE0 = 0x20, // deep_suspend
- PMU_LPW_POWER_MODE1 = 0x40, // lowpower_en
- PMU_LPW_POWER_MODE2 = 0x80, // suspend
- _PMU_LPW_POWER_MODE_MASK = 7,
- _PMU_LPW_POWER_MODE_SHIFT = 5
- } PMU_LPW_BITS_T;
-
- /**
- * SLEEP_DUR values
- */
- typedef enum {
- SLEEP_DUR_0_5 = 0, // 0.5ms
- SLEEP_DUR_1 = 6,
- SLEEP_DUR_2 = 7,
- SLEEP_DUR_4 = 8,
- SLEEP_DUR_6 = 9,
- SLEEP_DUR_10 = 10,
- SLEEP_DUR_25 = 11,
- SLEEP_DUR_50 = 12,
- SLEEP_DUR_100 = 13,
- SLEEP_DUR_500 = 14,
- SLEEP_DUR_1000 = 15
- } SLEEP_DUR_T;
-
- /**
- * POWER_MODE values
- */
- typedef enum {
- POWER_MODE_NORMAL = 0,
- POWER_MODE_DEEP_SUSPEND = 1,
- POWER_MODE_LOW_POWER = 2,
- POWER_MODE_SUSPEND = 4
- } POWER_MODE_T;
-
- /**
- * REG_PMU_LOW_POWER bits
- */
- typedef enum {
- _LOW_POWER_RESERVED_BITS = 0x0f | 0x10 | 0x80,
-
- // 0x01-0x10 reserved
- LOW_POWER_SLEEPTIMER_MODE = 0x20,
- LOW_POWER_LOWPOWER_MODE = 0x40 // LPM1 or LPM2 mode. see DS.
- // 0x80 reserved
- } LOW_POWER_BITS_T;
-
- /**
- * REG_ACC_HBW bits
- */
- typedef enum {
- _ACC_HBW_RESERVED_BITS = 0x0f | 0x10 | 0x20,
-
- // 0x01-0x20 reserved
- ACC_HBW_SHADOW_DIS = 0x40,
- ACC_HBW_DATA_HIGH_BW = 0x80
- } ACC_HBW_BITS_T;
-
- /**
- * REG_INT_EN_0 bits
- */
- typedef enum {
- _INT_EN_0_RESERVED_BITS = 0x08,
-
- INT_EN_0_SLOPE_EN_X = 0x01,
- INT_EN_0_SLOPE_EN_Y = 0x02,
- INT_EN_0_SLOPE_EN_Z = 0x04,
-
- // 0x08 reserved
-
- INT_EN_0_D_TAP_EN = 0x10,
- INT_EN_0_S_TAP_EN = 0x20,
- INT_EN_0_ORIENT_EN = 0x40,
- INT_EN_0_FLAT_EN = 0x80
- } INT_EN_0_BITS_T;
-
- /**
- * REG_INT_EN_1 bits
- */
- typedef enum {
- _INT_EN_1_RESERVED_BITS = 0x80,
-
- INT_EN_1_HIGH_EN_X = 0x01,
- INT_EN_1_HIGH_EN_Y = 0x02,
- INT_EN_1_HIGH_EN_Z = 0x04,
- INT_EN_1_LOW_EN = 0x08,
- INT_EN_1_DATA_EN = 0x10,
- INT_EN_1_INT_FFULL_EN = 0x20, // fifo full
- INT_EN_1_INT_FWM_EN = 0x40 // fifo watermark
-
- // 0x80 reserved
- } INT_EN_1_BITS_T;
-
- /**
- * REG_INT_EN_2 bits
- */
- typedef enum {
- _INT_EN_2_RESERVED_BITS = 0xf0,
-
- INT_EN_2_SLO_NO_MOT_EN_X = 0x01,
- INT_EN_2_SLO_NO_MOT_EN_Y = 0x02,
- INT_EN_2_SLO_NO_MOT_EN_Z = 0x04,
- INT_EN_2_SLO_NO_MOT_SEL = 0x08
-
- // 0x10-0x80 reserved
- } INT_EN_2_BITS_T;
-
- /**
- * REG_INT_MAP_0 bits
- */
- typedef enum {
- INT_MAP_0_INT1_LOW = 0x01,
- INT_MAP_0_INT1_HIGH = 0x02,
- INT_MAP_0_INT1_SLOPE = 0x04,
- INT_MAP_0_INT1_SLO_NO_MOT = 0x08,
- INT_MAP_0_INT1_D_TAP = 0x10,
- INT_MAP_0_INT1_S_TAP = 0x20,
- INT_MAP_0_INT1_ORIENT = 0x40,
- INT_MAP_0_INT1_FLAT = 0x80
- } INT_MAP_0_BITS_T;
-
- /**
- * REG_INT_MAP_1 bits
- */
- typedef enum {
- _INT_MAP_1_INT1_RESERVED_BITS = 0x08 | 0x10,
-
- INT_MAP_1_INT1_DATA = 0x01,
- INT_MAP_1_INT1_FWM = 0x02,
- INT_MAP_1_INT1_FFULL = 0x04,
-
- // 0x08-0x10 reserved
-
- INT_MAP_1_INT2_FFULL = 0x20,
- INT_MAP_1_INT2_FWM = 0x40,
- INT_MAP_1_INT2_DATA = 0x80
- } INT_MAP_1_BITS_T;
-
- /**
- * REG_INT_MAP_2 bits
- */
- typedef enum {
- INT_MAP_2_INT2_LOW = 0x01,
- INT_MAP_2_INT2_HIGH = 0x02,
- INT_MAP_2_INT2_SLOPE = 0x04,
- INT_MAP_2_INT2_SLO_NO_MOT = 0x08,
- INT_MAP_2_INT2_D_TAP = 0x10,
- INT_MAP_2_INT2_S_TAP = 0x20,
- INT_MAP_2_INT2_ORIENT = 0x40,
- INT_MAP_2_INT2_FLAT = 0x80
- } INT_MAP_2_BITS_T;
-
- /**
- * REG_INT_SRC bits
- */
- typedef enum {
- _INT_SRC_RESERVED_BITS = 0x40 | 0x80,
-
- INT_SRC_LOW = 0x01,
- INT_SRC_HIGH = 0x02,
- INT_SRC_SLO_NO_MOT = 0x04,
- INT_SRC_SLOPE = 0x08,
- INT_SRC_TAP = 0x10,
- INT_SRC_DATA = 0x20
-
- // 0x40-0x80 reserved
- } INT_SRC_BITS_T;
-
- /**
- * REG_INT_OUT_CTRL bits
- */
- typedef enum {
- _INT_OUT_CTRL_INT1_RESERVED_BITS = 0xf0,
-
- INT_OUT_CTRL_INT1_LVL = 0x01, // level or edge
- INT_OUT_CTRL_INT1_OD = 0x02, // push-pull or open drain
- INT_OUT_CTRL_INT2_LVL = 0x04,
- INT_OUT_CTRL_INT2_OD = 0x08
-
- // 0x10-0x80 reserved
- } INT_OUT_CTRL_BITS_T;
-
- /**
- * REG_INT_RST_LATCH bits
- */
- typedef enum {
- _INT_RST_LATCH_RESERVED_BITS = 0x10 | 0x20 | 0x40,
-
- INT_RST_LATCH0 = 0x01,
- INT_RST_LATCH1 = 0x02,
- INT_RST_LATCH2 = 0x04,
- INT_RST_LATCH3 = 0x08,
- _INT_RST_LATCH_MASK = 15,
- _INT_RST_LATCH_SHIFT = 0,
-
- // 0x10-0x40 reserved
-
- INT_RST_LATCH_RESET_INT = 0x80
- } INT_RST_LATCH_BITS_T;
-
- /**
- * RST_LATCH values
- */
- typedef enum {
- RST_LATCH_NON_LATCHED = 0,
- RST_LATCH_TEMPORARY_250MS = 1,
- RST_LATCH_TEMPORARY_500MS = 2,
- RST_LATCH_TEMPORARY_1S = 3,
- RST_LATCH_TEMPORARY_2S = 4,
- RST_LATCH_TEMPORARY_4S = 5,
- RST_LATCH_TEMPORARY_8S = 6,
- RST_LATCH_LATCHED = 7,
-
- // 8 == non latched
-
- RST_LATCH_TEMPORARY_250US = 9,
- RST_LATCH_TEMPORARY_500US = 10,
- RST_LATCH_TEMPORARY_1MS = 11,
- RST_LATCH_TEMPORARY_12_5MS = 12,
- RST_LATCH_TEMPORARY_25MS = 13,
- RST_LATCH_TEMPORARY_50MS = 14
-
- // 15 == latched
- } RST_LATCH_T;
-
- /**
- * REG_INT_2 bits
- */
- typedef enum {
- INT_2_LOW_HY0 = 0x01,
- INT_2_LOW_HY1 = 0x02,
- _INT_2_LOW_HY_MASK = 3,
- _INT_2_LOW_HY_SHIFT = 0,
-
- INT_2_LOW_MODE = 0x04,
-
- // 0x08-0x20 reserved
-
- INT_2_HIGH_HY0 = 0x40,
- INT_2_HIGH_HY1 = 0x80,
- _INT_2_HIGH_HY_MASK = 3,
- _INT_2_HIGH_HY_SHIFT = 6
- } INT_2_BITS_T;
-
- /**
- * REG_INT_5 bits
- */
- typedef enum {
- INT_5_SLOPE_DUR0 = 0x01,
- INT_5_SLOPE_DUR1 = 0x02,
- _INT_5_SLOPE_DUR_MASK = 3,
- _INT_5_SLOPE_DUR_SHIFT = 0,
-
- INT_5_SLO_NO_MOT_DUR0 = 0x04,
- INT_5_SLO_NO_MOT_DUR1 = 0x08,
- INT_5_SLO_NO_MOT_DUR2 = 0x10,
- INT_5_SLO_NO_MOT_DUR3 = 0x20,
- INT_5_SLO_NO_MOT_DUR4 = 0x40,
- INT_5_SLO_NO_MOT_DUR5 = 0x80,
- _INT_5_SLO_NO_MOT_DUR_MASK = 63,
- _INT_5_SLO_NO_MOT_DUR_SHIFT = 2
- } INT_5_BITS_T;
-
- /**
- * REG_INT_8 bits
- */
- typedef enum {
- INT_8_TAP_DUR0 = 0x01,
- INT_8_TAP_DUR1 = 0x02,
- INT_8_TAP_DUR2 = 0x04,
- _INT_8_TAP_DUR_MASK = 7,
- _INT_8_TAP_DUR_SHIFT = 0,
-
- // 0x08-0x20 reserved
-
- INT_8_TAP_SHOCK = 0x40,
- INT_8_TAP_QUIET = 0x80
- } INT_8_BITS_T;
-
- /**
- * REG_INT_9 bits
- */
- typedef enum {
- INT_9_TAP_TH0 = 0x01,
- INT_9_TAP_TH1 = 0x02,
- INT_9_TAP_TH2 = 0x04,
- INT_9_TAP_TH3 = 0x08,
- INT_9_TAP_TH4 = 0x10,
- _INT_5_TAP_TH_MASK = 31,
- _INT_5_TAP_TH_SHIFT = 0,
-
- // 0x20 reserved
-
- INT_9_TAP_SAMP0 = 0x40,
- INT_9_TAP_SAMP1 = 0x80,
- INT_9_TAP_SAMP1_MASK = 3,
- INT_9_TAP_SAMP1_SHIFT = 6
- } INT_9_BITS_T;
-
- /**
- * REG_INT_A bits
- */
- typedef enum {
- INT_A_ORIENT_MODE0 = 0x01,
- INT_A_ORIENT_MODE1 = 0x02,
- _INT_A_ORIENT_MODE_MASK = 3,
- _INT_A_ORIENT_MODE_SHIFT = 0,
-
- INT_A_ORIENT_BLOCKING0 = 0x04,
- INT_A_ORIENT_BLOCKING1 = 0x08,
- _INT_A_ORIENT_BLOCKING_MASK = 3,
- _INT_A_ORIENT_BLOCKING_SHIFT = 2,
-
- INT_A_ORIENT_HYST0 = 0x10,
- INT_A_ORIENT_HYST1 = 0x20,
- INT_A_ORIENT_HYST2 = 0x40,
- _INT_A_ORIENT_HYST_MASK = 7,
- _INT_A_ORIENT_HYST_SHIFT = 4
-
- // 0x80 reserved
- } INT_A_BITS_T;
-
- /**
- * INT_A_ORIENT_MODE values
- */
- typedef enum {
- ORIENT_MODE_SYMETRICAL = 0,
- ORIENT_MODE_HIGH_ASYMETRICAL = 1,
- ORIENT_MODE_LOW_ASYMETRICAL = 2
- } ORIENT_MODE_T;
-
- /**
- * INT_A_ORIENT_BLOCKING values
- */
- typedef enum {
- ORIENT_BLOCKING_NONE = 0,
- ORIENT_BLOCKING_THETA_ACC_1_5G = 1,
- ORIENT_BLOCKING_THETA_ACC_0_2G_1_5G = 2,
- ORIENT_BLOCKING_THETA_ACC_0_4G_1_5G = 3
- } ORIENT_BLOCKING_T;
-
- /**
- * REG_INT_B bits
- */
- typedef enum {
- INT_B_ORIENT_THETA0 = 0x01,
- INT_B_ORIENT_THETA1 = 0x02,
- INT_B_ORIENT_THETA2 = 0x04,
- INT_B_ORIENT_THETA3 = 0x08,
- INT_B_ORIENT_THETA4 = 0x10,
- INT_B_ORIENT_THETA5 = 0x20,
- _INT_B_ORIENT_THETA_MASK = 63,
- _INT_B_ORIENT_THETA_SHIFT = 0,
-
- INT_B_ORIENT_UD_EN = 0x40
- // 0x80 reserved
- } INT_B_BITS_T;
-
- /**
- * REG_INT_C bits
- */
- typedef enum {
- INT_B_FLAT_THETA0 = 0x01,
- INT_B_FLAT_THETA1 = 0x02,
- INT_B_FLAT_THETA2 = 0x04,
- INT_B_FLAT_THETA3 = 0x08,
- INT_B_FLAT_THETA4 = 0x10,
- INT_B_FLAT_THETA5 = 0x20,
- _INT_B_FLAT_THETA_MASK = 63,
- _INT_B_FLAT_THETA_SHIFT = 0,
-
- // 0x40-0x80 reserved
- } INT_C_BITS_T;
-
- /**
- * REG_INT_D bits
- */
- typedef enum {
- INT_D_FLAT_HY0 = 0x01,
- INT_D_FLAT_HY1 = 0x02,
- INT_D_FLAT_HY2 = 0x04,
- _INT_B_FLAT_HY_MASK = 7,
- _INT_B_FLAT_HY_SHIFT = 0,
-
- // 0x08 reserved
-
- INT_D_FLAT_HOLD_TIME0 = 0x10,
- INT_D_FLAT_HOLD_TIME1 = 0x20,
- _INT_B_FLAT_HOLD_TIME_MASK = 3,
- _INT_B_FLAT_HOLD_TIME_SHIFT = 4
-
- // 0x40-0x80 reserved
- } INT_D_BITS_T;
-
- /**
- * REG_FIFO_CONFIG_0 bits
- */
- typedef enum {
- _FIFO_CONFIG_0_RESERVED_BITS = 0x80 | 0x40,
-
- FIFO_CONFIG_0_WATER_MARK0 = 0x01,
- FIFO_CONFIG_0_WATER_MARK1 = 0x02,
- FIFO_CONFIG_0_WATER_MARK2 = 0x04,
- FIFO_CONFIG_0_WATER_MARK3 = 0x08,
- FIFO_CONFIG_0_WATER_MARK4 = 0x10,
- FIFO_CONFIG_0_WATER_MARK5 = 0x20,
- _FIFO_CONFIG_0_WATER_MARK_MASK = 63,
- _FIFO_CONFIG_0_WATER_MARK_SHIFT = 0
- } FIFO_CONFIG_0_BITS_T;
-
- /**
- * REG_PMU_SELFTTEST bits
- */
- typedef enum {
- PMU_SELFTTEST_AXIS0 = 0x01,
- PMU_SELFTTEST_AXIS1 = 0x02,
- _PMU_SELFTTEST_AXIS_MASK = 3,
- _PMU_SELFTTEST_AXIS_SHIFT = 0,
-
- PMU_SELFTTEST_SIGN = 0x04,
-
- // 0x08 reserved
-
- PMU_SELFTTEST_AMP = 0x10,
-
- // 0x20-0x80 reserved
- } PMU_SELFTTEST_BITS_T;
-
- /**
- * PMU_SELFTTEST_AXIS values
- */
- typedef enum {
- SELFTTEST_AXIS_NONE = 0,
- SELFTTEST_AXIS_X = 1,
- SELFTTEST_AXIS_Y = 2,
- SELFTTEST_AXIS_Z = 3,
- } SELFTTEST_AXIS_T;
-
- /**
- * REG_TRIM_NVM_CTRL bits
- */
- typedef enum {
- TRIM_NVM_CTRL_NVM_PROG_MODE = 0x01,
- TRIM_NVM_CTRL_NVM_PROG_TRIG = 0x02,
- TRIM_NVM_CTRL_NVM_PROG_RDY = 0x04,
- TRIM_NVM_CTRL_NVM_PROG_LOAD = 0x08,
-
- TRIM_NVM_CTRL_NVM_REMAIN0 = 0x10,
- TRIM_NVM_CTRL_NVM_REMAIN1 = 0x20,
- TRIM_NVM_CTRL_NVM_REMAIN2 = 0x40,
- TRIM_NVM_CTRL_NVM_REMAIN3 = 0x80,
- _TRIM_NVM_CTRL_NVM_REMAIN_MASK = 15,
- _TRIM_NVM_CTRL_NVM_REMAIN_SHIFT = 4
- } TRIM_NVM_CTRL_BITS_T;
-
- /**
- * REG_SPI3_WDT bits
- */
- typedef enum {
- _SPI3_WDT_RESERVED_BITS = 0xf0 | 0x08,
-
- SPI3_WDT_SPI3 = 0x01, // 3-wire SPI - NOT SUPPORTED
-
- SPI3_WDT_I2C_WDT_SEL = 0x02,
- SPI3_WDT_I2C_WDT_EN = 0x04
-
- // 0x08-0x80 reserved
- } SPI3_WDT_BITS_T;
-
- /**
- * REG_OFC_CTRL bits
- */
- typedef enum {
- OFC_CTRL_HP_X_EN = 0x01,
- OFC_CTRL_HP_Y_EN = 0x02,
- OFC_CTRL_HP_Z_EN = 0x04,
-
- // 0x08 reserved
-
- OFC_CTRL_CAL_RDY = 0x10,
-
- OFC_CTRL_CAL_TRIGGER0 = 0x20,
- OFC_CTRL_CAL_TRIGGER1 = 0x40,
- _OFC_CTRL_CAL_TRIGGER_MASK = 3,
- _OFC_CTRL_CAL_TRIGGER_SHIFT = 5,
-
- OFC_CTRL_OFFSET_RESET = 0x80
-
- } OFC_CTRL_BITS_T;
-
- /**
- * OFC_CTRL_CAL_TRIGGER values
- */
- typedef enum {
- CAL_TRIGGER_NONE = 0,
- CAL_TRIGGER_X = 1,
- CAL_TRIGGER_Y = 2,
- CAL_TRIGGER_Z = 3
- } CAL_TRIGGER_T;
-
- /**
- * REG_OFC_SETTING bits
- */
- typedef enum {
- OFC_SETTING_CUT_OFF = 0x01,
-
- OFC_SETTING_OFFSET_TARGET_X0 = 0x02,
- OFC_SETTING_OFFSET_TARGET_X1 = 0x04,
- _OFC_SETTING_OFFSET_TARGET_X_MASK = 3,
- _OFC_SETTING_OFFSET_TARGET_X_SHIFT = 1,
-
- OFC_SETTING_OFFSET_TARGET_Y0 = 0x08,
- OFC_SETTING_OFFSET_TARGET_Y1 = 0x10,
- _OFC_SETTING_OFFSET_TARGET_Y_MASK = 3,
- _OFC_SETTING_OFFSET_TARGET_Y_SHIFT = 3,
-
- OFC_SETTING_OFFSET_TARGET_Z0 = 0x20,
- OFC_SETTING_OFFSET_TARGET_Z1 = 0x40,
- _OFC_SETTING_OFFSET_TARGET_Z_MASK = 3,
- _OFC_SETTING_OFFSET_TARGET_Z_SHIFT = 5
-
- // 0x80 reserved
- } OFC_SETTING_BITS_T;
-
- /**
- * OFC_SETTING_OFFSET_TARGET (for X, Y and Z axis) values
- */
- typedef enum {
- OFFSET_TARGET_0G = 0,
- OFFSET_TARGET_PLUS_1G = 1,
- OFFSET_TARGET_MINUS_1G = 2,
- // 3 == 0G
- } OFFSET_TARGET_T;
-
- /**
- * REG_FIFO_CONFIG_1 bits
- */
- typedef enum {
- FIFO_CONFIG_1_FIFO_DATA_SEL0 = 0x01,
- FIFO_CONFIG_1_FIFO_DATA_SEL1 = 0x02,
- _FIFO_CONFIG_1_FIFO_DATA_SEL = 3,
- _FIFO_CONFIG_1_FIFO_DATA_SHIFT = 0,
-
- // 0x04-0x20 reserved
-
- FIFO_CONFIG_1_FIFO_MODE0 = 0x40,
- FIFO_CONFIG_1_FIFO_MODE1 = 0x80,
- _FIFO_CONFIG_1_FIFO_MODE_MASK = 3,
- _FIFO_CONFIG_1_FIFO_MODE_SHIFT = 5
- } FIFO_CONFIG_1_BITS_T;
-
- /**
- * FIFO_DATA_SEL values
- */
- typedef enum {
- FIFO_DATA_SEL_XYZ = 0,
- FIFO_DATA_SEL_X = 1,
- FIFO_DATA_SEL_Y = 2,
- FIFO_DATA_SEL_Z = 3
- } FIFO_DATA_SEL_T;
-
- /**
- * FIFO_MODE values
- */
- typedef enum {
- FIFO_MODE_BYPASS = 0,
- FIFO_MODE_FIFO = 1,
- FIFO_MODE_STREAM = 2
-
- // 3 == reserved (execute self-destruct :)
- } FIFO_MODE_T;
-
- // interrupt selection for installISR() and uninstallISR()
- typedef enum {
- INTERRUPT_INT1,
- INTERRUPT_INT2
- } INTERRUPT_PINS_T;
-
- // Different variants of this chip support different resolutions.
- // The 0xf9 variant supports 10b, while the 0xfa variant (bmx050)
- // supports 12 bits.
- typedef enum {
- RESOLUTION_10BITS,
- RESOLUTION_12BITS
- } RESOLUTION_T;
-
-
- /**
- * BMA250E constructor.
- *
- * This device can support both I2C and SPI. For SPI, set the addr
- * to -1, and specify a positive integer representing the Chip
- * Select (CS) pin for the cs argument. If you are using a
- * hardware CS pin (like edison with arduino breakout), then you
- * can connect the proper pin to the hardware CS pin on your MCU
- * and supply -1 for cs. The default operating mode is I2C.
- *
- * @param bus I2C or SPI bus to use.
- * @param addr The address for this device. -1 for SPI.
- * @param cs The gpio pin to use for the SPI Chip Select. -1 for
- * I2C or for SPI with a hardware controlled pin.
- */
- BMA250E(int bus=BMA250E_I2C_BUS, uint8_t addr=BMA250E_DEFAULT_ADDR,
- int cs=-1);
-
- /**
- * BMA250E Destructor.
- */
- ~BMA250E();
-
- /**
- * Update the internal stored values from sensor data.
- */
- void update();
-
- /**
- * Return the chip ID.
- *
- * @return The chip ID (BMA250E_CHIPID).
- */
- uint8_t getChipID();
-
- /**
- * Return accelerometer data in gravities. update() must have
- * been called prior to calling this method.
- *
- * @param x Pointer to a floating point value that will have the
- * current x component placed into it.
- * @param y Pointer to a floating point value that will have the
- * current y component placed into it.
- * @param z Pointer to a floating point value that will have the
- * current z component placed into it.
- */
- void getAccelerometer(float *x, float *y, float *z);
-
- /**
- * Return accelerometer data in gravities in the form of a
- * floating point array. The pointer returned by this function is
- * statically allocated and will be rewritten on each call.
- * update() must have been called prior to calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getAccelerometer();
-
- /**
- * Return the current measured temperature. Note, this is not
- * ambient temperature. update() must have been called prior to
- * calling this method.
- *
- * @param fahrenheit true to return data in Fahrenheit, false for
- * Celicus. Celcius is the default.
- * @return The temperature in degrees Celcius or Fahrenheit.
- */
- float getTemperature(bool fahrenheit=false);
-
- /**
- * Initialize the device and start operation. This function is
- * called from the constructor so will not typically need to be
- * called by a user unless the device is reset.
- *
- * @param pwr One of the POWER_MODE_T values. The default is
- * POWER_MODE_NORMAL.
- * @param range One of the RANGE_T values. The default is
- * RANGE_2G.
- * @param bw One of the filtering BW_T values. The default is
- * BW_250.
- */
- void init(POWER_MODE_T pwr=POWER_MODE_NORMAL,
- RANGE_T range=RANGE_2G, BW_T bw=BW_250);
-
- /**
- * Reset the device as if during a power on reset. All configured
- * values are lost when this happens. You should call init()
- * afterwards, or at least perform the same initialization init()
- * does before continuing.
- */
- void reset();
-
- /**
- * Set the acceleration scaling range. This device supports 2, 4,
- * 8, and 16g ranges.
- *
- * @param range One of the RANGE_T values.
- */
- void setRange(RANGE_T range);
-
- /**
- * Set the output filtering bandwidth of the device.
- *
- * @param bw One of the BW_T values.
- */
- void setBandwidth(BW_T bw);
-
- /**
- * Set the power mode of the device. Care must be taken when
- * setting a low power or suspend mode. By default init() calls
- * setLowPowerMode2() to ensure that if any of these modes are
- * entered we can still talk to the device. The default low power
- * mode is LPM1, which requires slowing down register writes,
- * which we cannot support. setLowPowerMode2() enables LPM2 which
- * keeps the digital interface operational in low power or suspend
- * modes. See the datasheet for details.
- *
- * So if you reset your device and don't call init() or
- * setLowPowerMode2(), you could lose control of the device by
- * calling this function with anything other than
- * POWER_MODE_NORMAL. You've been warned :)
- *
- * @param power One of the POWER_MODE_T values.
- */
- void setPowerMode(POWER_MODE_T power);
-
- /**
- * Enable update() to read from the FIFO rather than the
- * acceleration axis registers directly. init() enables this mode
- * by default if the chip variant supports a FIFO. An advantage
- * to this mode that all axis data is sampled from the same
- * timeslice. When reading directly from the acceleration output
- * registers, it's possible for one axis to be updated while
- * another is being read, causing a temporal anomaly that even
- * Captain Picard can't resolve. If there is no FIFO present,
- * this call is ignored.
- *
- * Using the FIFO removes this problem.
- *
- * @param useFIFO true to enable update() to read from the FIFO.
- * When false, update will read from the acceleration output
- * registers directly.
- */
- void enableFIFO(bool useFIFO);
-
- /**
- * Set the FIFO watermark. When the watermark is reached an
- * interrupt (if enabled) will be generated. If there is no FIFO
- * present, this call is ignored.
- *
- * @param wm The FIFO watermark to use. The maximum value is 63.
- */
- void fifoSetWatermark(int wm);
-
- /**
- * Set the FIFO configuration. init() uses the FIFO_MODE_BYPASS
- * mode with axes set to FIFO_DATA_SEL_XYZ by default. If there
- * is no FIFO present, this call is ignored.
- *
- * @param mode One of the FIFO_MODE_T values.
- * @param axes One of the FIFO_DATA_SEL_T values.
- */
- void fifoConfig(FIFO_MODE_T mode, FIFO_DATA_SEL_T axes);
-
- /**
- * Enable, disable, and configure the built in self test on a per
- * axis basis. See the datasheet for details.
- *
- * @param sign true for a positive deflection, false for negative
- * @param amp true for a high deflection, false for a low deflection
- * @param axis One of the SELFTTEST_AXIS_T values. Note, only one
- * axis at a time can be tested. Accelerometer output for other
- * axes should be ignored.
- */
- void setSelfTest(bool sign, bool amp, SELFTTEST_AXIS_T axis);
-
- /**
- * Return the Interrupt Enables 0 register. These resgisters
- * allow you to enable various interrupt conditions. See the
- * datasheet for details.
- *
- * @return A bitmask of INT_EN_0_BITS_T bits.
- */
- uint8_t getInterruptEnable0();
-
- /**
- * Set the Interrupt Enables 0 register. See the datasheet for
- * details.
- *
- * @param bits A bitmask of INT_EN_0_BITS_T bits.
- */
- void setInterruptEnable0(uint8_t bits);
-
- /**
- * Return the Interrupt Enables 1 register. See the datasheet for
- * details.
- *
- * @return A bitmask of INT_EN_1_BITS_T bits.
- */
- uint8_t getInterruptEnable1();
-
- /**
- * Set the Interrupt Enables 1 register. See the datasheet for
- * details.
- *
- * @param bits A bitmask of INT_EN_1_BITS_T bits.
- */
- void setInterruptEnable1(uint8_t bits);
-
- /**
- * Return the Interrupt Enables 2 register. See the datasheet for
- * details.
- *
- * @return A bitmask of INT_EN_2_BITS_T bits.
- */
- uint8_t getInterruptEnable2();
-
- /**
- * Set the Interrupt Enables 2 register. See the datasheet for
- * details.
- *
- * @param bits A bitmask of INT_EN_2_BITS_T bits.
- */
- void setInterruptEnable2(uint8_t bits);
-
- /**
- * Return the Interrupt Map 0 register. These registers allow you
- * to map specific interrupts to the interrupt 1 or interrupt 2
- * pin. See the datasheet for details.
- *
- * @return A bitmask of INT_MAP_0_BITS_T bits.
- */
- uint8_t getInterruptMap0();
-
- /**
- * Set the Interrupt Map 0 register. These registers allow you
- * to map specific interrupts to the interrupt 1 or interrupt 2
- * pin. See the datasheet for details.
- *
- * @param A bitmask of INT_MAP_0_BITS_T bits.
- */
- void setInterruptMap0(uint8_t bits);
-
- /**
- * Return the Interrupt Map 1 register. See the datasheet for
- * details.
- *
- * @return A bitmask of INT_MAP_1_BITS_T bits.
- */
- uint8_t getInterruptMap1();
-
- /**
- * Set the Interrupt Map 1 register. See the datasheet for
- * details.
- *
- * @param A bitmask of INT_MAP_1_BITS_T bits.
- */
- void setInterruptMap1(uint8_t bits);
-
- /**
- * Return the Interrupt Map 2 register. See the datasheet for
- * details.
- *
- * @return A bitmask of INT_MAP_2_BITS_T bits.
- */
- uint8_t getInterruptMap2();
-
- /**
- * Set the Interrupt Map 2 register. See the datasheet for
- * details.
- *
- * @param A bitmask of INT_MAP_2_BITS_T bits.
- */
- void setInterruptMap2(uint8_t bits);
-
- /**
- * Return the Interrupt source register. This register allows
- * determining where data comes from (filtered/unfiltered) for
- * those interrupt sources where this is selectable. See the
- * datasheet for details.
- *
- * @return A bitmask of INT_SRC_BITS_T bits.
- */
- uint8_t getInterruptSrc();
-
- /**
- * Set the Interrupt source register. This register allows
- * determining where data comes from (filtered/unfiltered) for
- * those interrupt sources where this is selectable. See the
- * datasheet for details.
- *
- * @param bits A bitmask of INT_SRC_BITS_T bits.
- */
- void setInterruptSrc(uint8_t bits);
-
- /**
- * Return the Interrupt output control register. This register
- * allows determining the electrical characteristics of the 2
- * interrupt pins (open-drain/push-pull and level/edge
- * triggering). See the datasheet for details.
- *
- * @return A bitmask of INT_OUT_CTRL_BITS_T bits.
- */
- uint8_t getInterruptOutputControl();
-
- /**
- * Set the Interrupt output control register. This register
- * allows determining the electrical characteristics of the 2
- * interrupt pins (open-drain/push-pull and level/edge
- * triggering). See the datasheet for details.
- *
- * @param bits A bitmask of INT_OUT_CTRL_BITS_T bits.
- */
- void setInterruptOutputControl(uint8_t bits);
-
- /**
- * Clear all latched interrupts. See the datasheet for details.
- */
- void clearInterruptLatches();
-
- /**
- * Return the current interrupt latching behavior. See the
- * datasheet for details.
- *
- * @return One of the RST_LATCH_T values.
- */
- RST_LATCH_T getInterruptLatchBehavior();
-
- /**
- * Set the current interrupt latching behavior. See the datasheet
- * for details.
- *
- * @param latch One of the RST_LATCH_T values.
- */
- void setInterruptLatchBehavior(RST_LATCH_T latch);
-
- /**
- * Return the interrupt status 0 register. These registers
- * indicate which interrupts have been triggered. See the
- * datasheet for details.
- *
- * @return a bitmask of INT_STATUS_0_BITS_T bits.
- */
- uint8_t getInterruptStatus0();
-
- /**
- * Return the interrupt status 1 register. See the datasheet for
- * details.
- *
- * @return a bitmask of INT_STATUS_1_BITS_T bits.
- */
- uint8_t getInterruptStatus1();
-
- /**
- * Return the interrupt status 2 register. See the datasheet for
- * details.
- *
- * @return a bitmask of INT_STATUS_2_BITS_T bits.
- */
- uint8_t getInterruptStatus2();
-
- /**
- * Return the interrupt status 3 register bitfields. See the
- * datasheet for details. The Orientation value is not returned by
- * this function, see getInterruptStatus3Orientation() for that
- * information.
- *
- * @return a bitmask of INT_STATUS_3_BITS_T bits ONLY.
- */
- uint8_t getInterruptStatus3Bits();
-
- /**
- * Return the interrupt status 3 register Orientation value. See the
- * datasheet for details.
- *
- * @return one of the ORIENT_T values.
- */
- ORIENT_T getInterruptStatus3Orientation();
-
- /**
- * Enable shadowing of the accelerometer output registers. When
- * enabled, a read of an axis LSB register automatically locks the
- * MSB register of that axis until it has been read. This is
- * usually a good thing to have enabled. init() enables this by
- * default. If disabled, then it becomes possible for part of an
- * axis value to change while another part is being read, causing
- * inconsistent data.
- *
- * @param shadow true to enable axis register shadowing, false otherwise.
- */
- void enableRegisterShadowing(bool shadow);
-
- /**
- * Enable filtering of the accelerometer axis data. init()
- * enables this by default. If disabled, then accelerometer data
- * that is read will be raw and unfiltered (rated R). See the
- * datasheet for details.
- *
- * @param filter true to enable filtering, false to disable.
- */
- void enableOutputFiltering(bool filter);
-
- /**
- * Make sure low power mode config (LPM2) is set in case we later
- * go into the low power or suspend power modes. LPM1 mode (the
- * default) requires drastically slowed register writes which we
- * cannot handle.
- */
- void setLowPowerMode2();
-
-
-#if defined(SWIGJAVA) || defined(JAVACALLBACK)
- void installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- jobject runnable);
-#else
- /**
- * install an interrupt handler.
- *
- * @param intr one of the INTERRUPT_PINS_T values specifying which
- * interrupt pin you are installing.
- * @param gpio gpio pin to use as interrupt pin
- * @param level the interrupt trigger level (one of mraa::Edge
- * values). Make sure that you have configured the interrupt pin
- * properly for whatever level you choose.
- * @param isr the interrupt handler, accepting a void * argument
- * @param arg the argument to pass the the interrupt handler
- */
- void installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- void (*isr)(void *), void *arg);
-#endif
-
- /**
- * uninstall a previously installed interrupt handler
- *
- * @param intr one of the INTERRUPT_PINS_T values specifying which
- * interrupt pin you are removing.
- */
- void uninstallISR(INTERRUPT_PINS_T intr);
-
- /**
- * Read a register.
- *
- * @param reg The register to read.
- * @return The value of the register.
- */
- uint8_t readReg(uint8_t reg);
-
- /**
- * Read contiguous registers into a buffer.
- *
- * @param buffer The buffer to store the results.
- * @param len The number of registers to read.
- * @return The number of bytes read.
- */
- int readRegs(uint8_t reg, uint8_t *buffer, int len);
-
- /**
- * Write to a register
- *
- * @param reg The register to write to.
- * @param val The value to write.
- */
- void writeReg(uint8_t reg, uint8_t val);
-
- protected:
- mraa::I2c *m_i2c;
- mraa::Spi *m_spi;
-
- // spi chip select
- mraa::Gpio *m_gpioCS;
-
- mraa::Gpio *m_gpioIntr1;
- mraa::Gpio *m_gpioIntr2;
-
- uint8_t m_addr;
- RESOLUTION_T m_resolution;
-
- // does this chip support the fifo?
- bool m_fifoAvailable;
-
- // SPI chip select
- void csOn();
- void csOff();
-
- // acc data
- float m_accX;
- float m_accY;
- float m_accZ;
-
- float m_accScale;
-
- float m_temperature;
-
- private:
- bool m_isSPI;
-
- // use the FIFO by default?
- bool m_useFIFO;
-
- // return a reference to a gpio pin pointer depending on intr
- mraa::Gpio*& getPin(INTERRUPT_PINS_T intr);
-
- // Adding a private function definition for java bindings
-#if defined(SWIGJAVA) || defined(JAVACALLBACK)
- void installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- void (*isr)(void *), void *arg);
-#endif
- };
-}
diff --git a/peripheral/libupm/src/bmx055/bmc150.cxx b/peripheral/libupm/src/bmx055/bmc150.cxx
deleted file mode 100644
index 26d3f62..0000000
--- a/peripheral/libupm/src/bmx055/bmc150.cxx
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-
-#include "bmc150.hpp"
-
-using namespace upm;
-using namespace std;
-
-BMC150::BMC150(int accelBus, uint8_t accelAddr, int accelCS,
- int magBus, uint8_t magAddr, int magCS) :
- m_accel(0), m_mag(0)
-{
- // if -1 is supplied as a bus for any of these, we will not
- // instantiate them
-
- if (accelBus >= 0)
- m_accel = new BMA250E(accelBus, accelAddr, accelCS);
-
- if (magBus >= 0)
- m_mag = new BMM150(magBus, magAddr, magCS);
-
- // now initialize them...
- if (m_accel)
- m_accel->init();
-
- if (m_mag)
- m_mag->init();
-}
-
-BMC150::~BMC150()
-{
- if (m_accel)
- delete m_accel;
-
- if (m_mag)
- delete m_mag;
-}
-
-void BMC150::initAccelerometer(BMA250E::POWER_MODE_T pwr,
- BMA250E::RANGE_T range,
- BMA250E::BW_T bw)
-{
- if (m_accel)
- m_accel->init(pwr, range, bw);
-}
-
-void BMC150::initMagnetometer(BMM150::USAGE_PRESETS_T usage)
-{
- if (m_mag)
- m_mag->init(usage);
-}
-
-void BMC150::update()
-{
- if (m_accel)
- m_accel->update();
-
- if (m_mag)
- m_mag->update();
-}
-
-void BMC150::getAccelerometer(float *x, float *y, float *z)
-{
- if (m_accel)
- m_accel->getAccelerometer(x, y, z);
-}
-
-float *BMC150::getAccelerometer()
-{
- if (m_accel)
- return m_accel->getAccelerometer();
- else
- {
- static float v[3] = {0.0f, 0.0f, 0.0f};
- return v;
- }
-}
-
-void BMC150::getMagnetometer(float *x, float *y, float *z)
-{
- if (m_mag)
- m_mag->getMagnetometer(x, y, z);
-}
-
-float *BMC150::getMagnetometer()
-{
- if (m_mag)
- return m_mag->getMagnetometer();
- else
- {
- static float v[3] = {0.0f, 0.0f, 0.0f};
- return v;
- }
-}
diff --git a/peripheral/libupm/src/bmx055/bmc150.hpp b/peripheral/libupm/src/bmx055/bmc150.hpp
deleted file mode 100644
index c570af0..0000000
--- a/peripheral/libupm/src/bmx055/bmc150.hpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-
-#include "bma250e.hpp"
-#include "bmm150.hpp"
-
-#define BMC150_DEFAULT_BUS 0
-#define BMC150_DEFAULT_ACC_ADDR 0x10
-#define BMC150_DEFAULT_MAG_ADDR 0x12
-
-namespace upm {
-
- /**
- * @library bmx055
- * @sensor bmc150
- * @comname BMC150 6-axis eCompass
- * @type accelerometer compass
- * @man mouser
- * @con i2c gpio spi
- * @web http://www.mouser.com/ProductDetail/Bosch-Sensortec/0330SB0156/?qs=sGAEpiMZZMsrChSOYEGTCd8nwjostN1SWavW0HYOOXw%3d
- *
- * @brief API for the BMC150 6-axis eCompass
- *
- *
- * The BMC150 is an integrated electronic compass solution for
- * consumer market applications. It comprises a 12bit leading edge
- * triaxial, low-g acceleration sensor and an ultra-low power, high
- * precision triaxial magnetic field sensor. It allows measurements
- * of acceleration and magnetic field in three perpendicular
- * axes. Performance and features of both sensing technologies are
- * carefully tuned and perfectly match the demanding requirements of
- * all 6-axis mobile applications such as electronic compass,
- * navigation or augmented reality.
-
- * The BMC150 is essentially 2 separate devices in one: the BMA250E
- * Accelerometer and the BMM150 Magnetometer. They are completely
- * independant of each other.
- *
- * This driver provides a very simple interface to these 2 devices.
- * If finer control is desired, you should just use the separate
- * BMA25E and BMM150 device classes directly. This driver simply
- * initializes both devices, and provides a mechanism to read
- * accelerometer and magnetometer data from them.
- *
- * @snippet bmc150.cxx Interesting
- */
-
- class BMC150 {
- public:
- /**
- * BMC150 constructor.
- *
- * This device can support both I2C and SPI. For SPI, set the addr
- * to -1, and specify a positive integer representing the Chip
- * Select (CS) pin for the cs argument. If you are using a
- * hardware CS pin (like edison with arduino breakout), then you
- * can connect the proper pin to the hardware CS pin on your MCU
- * and supply -1 for cs. The default operating mode is I2C.
- *
- * @param accelBus I2C or SPI bus to use. -1 to skip initializing
- * this device.
- * @param accelAddr The address for this device. -1 for SPI.
- * @param accelCS The gpio pin to use for the SPI Chip Select. -1 for
- * I2C or for SPI with a hardware controlled pin.
- * @param magBus I2C or SPI bus to use. -1 to skip initializing
- * this device.
- * @param magAddr The address for this device. -1 for SPI.
- * @param magCS The gpio pin to use for the SPI Chip Select. -1 for
- * I2C or for SPI with a hardware controlled pin.
- */
- BMC150(int accelBus=BMC150_DEFAULT_BUS,
- uint8_t accelAddr=BMC150_DEFAULT_ACC_ADDR,
- int accelCS=-1,
- int magBus=BMC150_DEFAULT_BUS,
- uint8_t magAddr=BMC150_DEFAULT_MAG_ADDR,
- int magCS=-1);
-
- /**
- * BMC150 Destructor.
- */
- ~BMC150();
-
- /**
- * Update the internal stored values from sensor data.
- */
- void update();
-
- /**
- * Initialize the accelerometer and start operation. This
- * function is called from the constructor so will not typically
- * need to be called by a user unless the device is reset or you
- * want to change these values.
- *
- * @param pwr One of the BMA250E::POWER_MODE_T values. The default is
- * BMA250E::POWER_MODE_NORMAL.
- * @param range One of the BMA250E::RANGE_T values. The default is
- * BMA250E::RANGE_2G.
- * @param bw One of the filtering BMA250E::BW_T values. The default is
- * BMA250E::BW_250.
- */
- void initAccelerometer(BMA250E::POWER_MODE_T pwr=BMA250E::POWER_MODE_NORMAL,
- BMA250E::RANGE_T range=BMA250E::RANGE_2G,
- BMA250E::BW_T bw=BMA250E::BW_250);
-
- /**
- * Initialize the magnetometer and start operation. This function
- * is called from the constructor so will not typically need to be
- * called by a user unless the device is reset or you want to
- * change these values. This method will call
- * BMM150::setPresetMode() with the passed parameter.
- *
- * @param usage One of the BMM150::USAGE_PRESETS_T values. The default is
- * BMM150::USAGE_HIGH_ACCURACY.
- */
- void initMagnetometer(BMM150::USAGE_PRESETS_T usage=BMM150::USAGE_HIGH_ACCURACY);
-
- /**
- * Return accelerometer data in gravities. update() must have
- * been called prior to calling this method.
- *
- * @param x Pointer to a floating point value that will have the
- * current x component placed into it.
- * @param y Pointer to a floating point value that will have the
- * current y component placed into it.
- * @param z Pointer to a floating point value that will have the
- * current z component placed into it.
- */
- void getAccelerometer(float *x, float *y, float *z);
-
- /**
- * Return accelerometer data in gravities in the form of a
- * floating point array. The pointer returned by this function is
- * statically allocated and will be rewritten on each call.
- * update() must have been called prior to calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getAccelerometer();
-
- /**
- * Return magnetometer data in micro-Teslas (uT). update() must
- * have been called prior to calling this method.
- *
- * @param x Pointer to a floating point value that will have the
- * current x component placed into it.
- * @param y Pointer to a floating point value that will have the
- * current y component placed into it.
- * @param z Pointer to a floating point value that will have the
- * current z component placed into it.
- */
- void getMagnetometer(float *x, float *y, float *z);
-
- /**
- * Return magnetometer data in micro-Teslas (uT) in the form of a
- * floating point array. The pointer returned by this function is
- * statically allocated and will be rewritten on each call.
- * update() must have been called prior to calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getMagnetometer();
-
-
- protected:
- BMA250E *m_accel;
- BMM150 *m_mag;
-
- private:
- };
-}
diff --git a/peripheral/libupm/src/bmx055/bmg160.cxx b/peripheral/libupm/src/bmx055/bmg160.cxx
deleted file mode 100644
index 45593b6..0000000
--- a/peripheral/libupm/src/bmx055/bmg160.cxx
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-#include <string.h>
-
-#include "bmg160.hpp"
-
-using namespace upm;
-using namespace std;
-
-#define BMG160_DEFAULT_CHIPID 0x0f
-
-// conversion from celcius to fahrenheit
-
-static float c2f(float c)
-{
- return (c * (9.0 / 5.0) + 32.0);
-}
-
-BMG160::BMG160(int bus, uint8_t addr, int cs) :
- m_i2c(0), m_spi(0), m_gpioIntr1(0), m_gpioIntr2(0), m_gpioCS(0)
-{
- m_addr = addr;
- m_isSPI = false;
-
- m_gyrX = 0;
- m_gyrY = 0;
- m_gyrZ = 0;
- m_gyrScale = 0;
- m_temperature = 0.0;
-
- if (addr < 0)
- m_isSPI = true;
-
- if (m_isSPI)
- {
- m_spi = new mraa::Spi(bus);
-
- // Only create cs context if we are actually using a valid pin.
- // A hardware controlled pin should specify cs as -1.
- if (cs >= 0)
- {
- m_gpioCS = new mraa::Gpio(cs);
- m_gpioCS->dir(mraa::DIR_OUT);
- }
-
- m_spi->mode(mraa::SPI_MODE0);
- m_spi->frequency(5000000);
- }
- else
- {
- // I2C
- m_i2c = new mraa::I2c(bus);
-
- mraa::Result rv;
- if ((rv = m_i2c->address(m_addr)) != mraa::SUCCESS)
- {
- throw std::runtime_error(string(__FUNCTION__) +
- ": I2c.address() failed");
- }
- }
-
- // check the chip id
-
- uint8_t chipID = getChipID();
- if (chipID != BMG160_DEFAULT_CHIPID)
- {
- throw std::runtime_error(string(__FUNCTION__)
- + ": invalid chip ID. Expected "
- + std::to_string(int(BMG160_DEFAULT_CHIPID))
- + ", got "
- + std::to_string(int(chipID)));
- }
-
- // call init with default options
- init();
-}
-
-BMG160::~BMG160()
-{
- uninstallISR(INTERRUPT_INT1);
- uninstallISR(INTERRUPT_INT2);
-}
-
-void BMG160::init(POWER_MODE_T pwr, RANGE_T range, BW_T bw)
-{
- setPowerMode(pwr);
- usleep(50000); // 50ms, in case we are waking up
-
- // set our range and bandwidth
- setRange(range);
- setBandwidth(bw);
-
- // make sure register shadowing is enabled
- enableRegisterShadowing(true);
-
- // enable output filtering
- enableOutputFiltering(true);
-
- // use the FIFO by default
- fifoConfig(FIFO_MODE_BYPASS, FIFO_DATA_SEL_XYZ);
- enableFIFO(true);
-
- // settle
- usleep(50000);
-}
-
-void BMG160::update()
-{
- int bufLen = 0;
- uint8_t startReg = 0;
-
- if (m_useFIFO)
- {
- bufLen = 6;
- startReg = REG_FIFO_DATA;
- }
- else
- {
- // non FIFO, read acc regs directly (including temp)
- bufLen = 7;
- startReg = REG_RATE_X_LSB;
- }
-
- uint8_t buf[bufLen];
-
- if (readRegs(startReg, buf, bufLen) != bufLen)
- {
- throw std::runtime_error(string(__FUNCTION__)
- + ": readRegs() failed to read "
- + std::to_string(bufLen)
- + " bytes");
- }
-
- int16_t val;
-
- // x
- val = int16_t(buf[1] << 8 | buf[0]);
- m_gyrX = float(val);
-
- // y
- val = int16_t(buf[3] << 8 | buf[2]);
- m_gyrY = float(val);
-
- // z
- val = int16_t(buf[5] << 8 | buf[4]);
- m_gyrZ = float(val);
-
- // get the temperature...
-
- uint8_t temp = 0;
- if (m_useFIFO)
- {
- // we have to read temperature separately...
- temp = readReg(REG_TEMP);
- }
- else
- {
- // we already got it
- temp = buf[6];
- }
-
- // .5K/LSB, 23C center point
- m_temperature = (float(temp) / 2.0) + 23.0;
-}
-
-void BMG160::enableFIFO(bool useFIFO)
-{
- m_useFIFO = useFIFO;
-}
-
-uint8_t BMG160::readReg(uint8_t reg)
-{
- if (m_isSPI)
- {
- reg |= 0x80; // needed for read
- uint8_t pkt[2] = {reg, 0};
-
- csOn();
- if (m_spi->transfer(pkt, pkt, 2))
- {
- csOff();
- throw std::runtime_error(string(__FUNCTION__)
- + ": Spi.transfer() failed");
- }
- csOff();
-
- return pkt[1];
- }
- else
- return m_i2c->readReg(reg);
-}
-
-int BMG160::readRegs(uint8_t reg, uint8_t *buffer, int len)
-{
- if (m_isSPI)
- {
- reg |= 0x80; // needed for read
-
- uint8_t sbuf[len + 1];
- memset((char *)sbuf, 0, len + 1);
- sbuf[0] = reg;
-
- // We need to do it this way for edison - ie: use a single
- // transfer rather than breaking it up into two like we used to.
- // This means a buffer copy is now required, but that's the way
- // it goes.
-
- csOn();
- if (m_spi->transfer(sbuf, sbuf, len + 1))
- {
- csOff();
- throw std::runtime_error(string(__FUNCTION__)
- + ": Spi.transfer(buf) failed");
- }
- csOff();
-
- // now copy it into user buffer
- for (int i=0; i<len; i++)
- buffer[i] = sbuf[i + 1];
-
- return len;
- }
- else
- return m_i2c->readBytesReg(reg, buffer, len);
-}
-
-void BMG160::writeReg(uint8_t reg, uint8_t val)
-{
- if (m_isSPI)
- {
- reg &= 0x7f; // mask off 0x80 for writing
- uint8_t pkt[2] = {reg, val};
-
- csOn();
- if (m_spi->transfer(pkt, NULL, 2))
- {
- csOff();
- throw std::runtime_error(string(__FUNCTION__)
- + ": Spi.transfer() failed");
- }
- csOff();
- }
- else
- {
-
- mraa::Result rv;
- if ((rv = m_i2c->writeReg(reg, val)) != mraa::SUCCESS)
- {
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": I2c.writeReg() failed");
- }
- }
-}
-
-void BMG160::csOn()
-{
- if (m_gpioCS)
- m_gpioCS->write(0);
-}
-
-void BMG160::csOff()
-{
- if (m_gpioCS)
- m_gpioCS->write(1);
-}
-
-uint8_t BMG160::getChipID()
-{
- return readReg(REG_CHIP_ID);
-}
-
-void BMG160::getGyroscope(float *x, float *y, float *z)
-{
- if (x)
- *x = (m_gyrX * m_gyrScale) / 1000.0;
-
- if (y)
- *y = (m_gyrY * m_gyrScale) / 1000.0;
-
- if (z)
- *z = (m_gyrZ * m_gyrScale) / 1000.0;
-}
-
-float *BMG160::getGyroscope()
-{
- static float v[3];
-
- getGyroscope(&v[0], &v[1], &v[2]);
- return v;
-}
-
-float BMG160::getTemperature(bool fahrenheit)
-{
- if (fahrenheit)
- return c2f(m_temperature);
- else
- return m_temperature;
-}
-
-void BMG160::reset()
-{
- writeReg(REG_SOFTRESET, BMG160_RESET_BYTE);
- sleep(1);
-}
-
-void BMG160::setRange(RANGE_T range)
-{
- switch(range)
- {
- case RANGE_125:
- m_gyrScale = 3.8; // milli-degrees
- break;
-
- case RANGE_250:
- m_gyrScale = 7.6;
- break;
-
- case RANGE_500:
- m_gyrScale = 15.3;
- break;
-
- case RANGE_1000:
- m_gyrScale = 30.5;
- break;
-
- case RANGE_2000:
- m_gyrScale = 61.0;
- break;
- }
-
- // we also have to write a fixed '0x10' to the high-order bits for
- // some reason (according to datasheet)
- uint8_t reg = range | (_GYR_RANGE_FIXED_VALUE << _GYR_RANGE_FIXED_SHIFT);
- writeReg(REG_GYR_RANGE, reg);
-}
-
-void BMG160::setBandwidth(BW_T bw)
-{
- writeReg(REG_GYR_BW, bw);
-}
-
-void BMG160::setPowerMode(POWER_MODE_T power)
-{
- // mask off reserved bits
- uint8_t reg = readReg(REG_LPM1) & ~_LPM1_RESERVED_MASK;
-
- reg &= ~(_LPM1_POWER_MODE_MASK << _LPM1_POWER_MODE_SHIFT);
- reg |= (power << _LPM1_POWER_MODE_SHIFT);
-
- writeReg(REG_LPM1, power);
-}
-
-void BMG160::fifoSetWatermark(int wm)
-{
- // mask off illegal values
- uint8_t reg = uint8_t(wm) & _FIFO_CONFIG_0_WATER_MARK_MASK;
-
- writeReg(REG_FIFO_CONFIG_0, reg);
-}
-
-void BMG160::fifoConfig(FIFO_MODE_T mode, FIFO_DATA_SEL_T axes)
-{
- uint8_t reg = ( (mode << _FIFO_CONFIG_1_FIFO_MODE_SHIFT) |
- (axes << _FIFO_CONFIG_1_FIFO_DATA_SHIFT) );
-
- writeReg(REG_FIFO_CONFIG_1, reg);
-}
-
-uint8_t BMG160::getInterruptEnable0()
-{
- return readReg(REG_INT_EN_0) & ~_INT_EN_0_RESERVED_BITS;
-}
-
-void BMG160::setInterruptEnable0(uint8_t bits)
-{
- uint8_t reg = bits & ~_INT_EN_0_RESERVED_BITS;
-
- writeReg(REG_INT_EN_0, reg);
-}
-
-uint8_t BMG160::getInterruptMap0()
-{
- return readReg(REG_INT_MAP_0) & ~_INT_MAP_0_RESERVED_BITS;
-}
-
-void BMG160::setInterruptMap0(uint8_t bits)
-{
- uint8_t reg = bits & ~_INT_MAP_0_RESERVED_BITS;
-
- writeReg(REG_INT_MAP_0, reg);
-}
-
-uint8_t BMG160::getInterruptMap1()
-{
- return readReg(REG_INT_MAP_1);
-}
-
-void BMG160::setInterruptMap1(uint8_t bits)
-{
- writeReg(REG_INT_MAP_1, bits);
-}
-
-// REG_INT_EN1, for some strange reason
-uint8_t BMG160::getInterruptSrc()
-{
- return readReg(REG_INT_EN_1) & ~_INT_EN_1_INT1_RESERVED_BITS;
-}
-
-void BMG160::setInterruptSrc(uint8_t bits)
-{
- uint8_t reg = bits & ~_INT_EN_1_INT1_RESERVED_BITS;
-
- writeReg(REG_INT_EN_1, reg);
-}
-
-uint8_t BMG160::getInterruptOutputControl()
-{
- return readReg(REG_INT_EN_1) & ~_INT_EN_1_INT1_RESERVED_BITS;
-}
-
-void BMG160::setInterruptOutputControl(uint8_t bits)
-{
- uint8_t reg = bits & ~_INT_EN_1_INT1_RESERVED_BITS;
-
- writeReg(REG_INT_EN_1, reg);
-}
-
-void BMG160::clearInterruptLatches()
-{
- uint8_t reg = readReg(REG_INT_RST_LATCH) & ~_INT_RST_LATCH_RESERVED_BITS;
-
- reg |= INT_RST_LATCH_RESET_INT;
-
- writeReg(REG_INT_RST_LATCH, reg);
-}
-
-BMG160::RST_LATCH_T BMG160::getInterruptLatchBehavior()
-{
- uint8_t reg = readReg(REG_INT_RST_LATCH) & ~_INT_RST_LATCH_RESERVED_BITS;
-
- reg &= (_INT_RST_LATCH_MASK << _INT_RST_LATCH_SHIFT);
-
- return static_cast<RST_LATCH_T>(reg);
-}
-
-void BMG160::setInterruptLatchBehavior(RST_LATCH_T latch)
-{
- uint8_t reg = readReg(REG_INT_RST_LATCH) & ~_INT_RST_LATCH_RESERVED_BITS;
-
- reg &= ~(_INT_RST_LATCH_MASK << _INT_RST_LATCH_SHIFT);
- reg |= (latch << _INT_RST_LATCH_SHIFT);
-
- writeReg(REG_INT_RST_LATCH, reg);
-}
-
-void BMG160::enableRegisterShadowing(bool shadow)
-{
- uint8_t reg = readReg(REG_RATE_HBW) & ~_RATE_HBW_RESERVED_BITS;
-
- if (shadow)
- reg &= ~RATE_HBW_SHADOW_DIS;
- else
- reg |= RATE_HBW_SHADOW_DIS;
-
- writeReg(REG_RATE_HBW, reg);
-}
-
-void BMG160::enableOutputFiltering(bool filter)
-{
- uint8_t reg = readReg(REG_RATE_HBW) & ~_RATE_HBW_RESERVED_BITS;
-
- if (filter)
- reg &= ~RATE_HBW_DATA_HIGH_BW;
- else
- reg |= RATE_HBW_DATA_HIGH_BW;
-
- writeReg(REG_RATE_HBW, reg);
-}
-
-uint8_t BMG160::getInterruptStatus0()
-{
- return readReg(REG_INT_STATUS_0) & ~_INT_STATUS_0_RESERVED_BITS;
-}
-
-uint8_t BMG160::getInterruptStatus1()
-{
- return readReg(REG_INT_STATUS_1) & ~_INT_STATUS_1_RESERVED_BITS;
-}
-
-uint8_t BMG160::getInterruptStatus2()
-{
- return readReg(REG_INT_STATUS_2) & ~_INT_STATUS_2_RESERVED_BITS;
-}
-
-uint8_t BMG160::getInterruptStatus3()
-{
- return readReg(REG_INT_STATUS_3) & ~_INT_STATUS_3_RESERVED_BITS;
-}
-
-#if defined(SWIGJAVA) || (JAVACALLBACK)
-void BMG160::installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- jobject runnable)
-{
- // delete any existing ISR and GPIO context
- uninstallISR(intr);
-
- // create gpio context
- getPin(intr) = new mraa::Gpio(gpio);
-
- getPin(intr)->dir(mraa::DIR_IN);
- getPin(intr)->isr(level, runnable);
-}
-#else
-void BMG160::installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- void (*isr)(void *), void *arg)
-{
- // delete any existing ISR and GPIO context
- uninstallISR(intr);
-
- // create gpio context
- getPin(intr) = new mraa::Gpio(gpio);
-
- getPin(intr)->dir(mraa::DIR_IN);
- getPin(intr)->isr(level, isr, arg);
-}
-#endif
-
-void BMG160::uninstallISR(INTERRUPT_PINS_T intr)
-{
- if (getPin(intr))
- {
- getPin(intr)->isrExit();
- delete getPin(intr);
-
- getPin(intr) = 0;
- }
-}
-
-mraa::Gpio*& BMG160::getPin(INTERRUPT_PINS_T intr)
-{
- switch(intr)
- {
- case INTERRUPT_INT1:
- return m_gpioIntr1;
- break;
-
- case INTERRUPT_INT2:
- return m_gpioIntr2;
- break;
-
- default:
- throw std::out_of_range(string(__FUNCTION__) +
- ": Invalid interrupt enum passed");
- }
-}
diff --git a/peripheral/libupm/src/bmx055/bmg160.hpp b/peripheral/libupm/src/bmx055/bmg160.hpp
deleted file mode 100644
index 9b7b389..0000000
--- a/peripheral/libupm/src/bmx055/bmg160.hpp
+++ /dev/null
@@ -1,1223 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <mraa/i2c.hpp>
-#include <mraa/spi.hpp>
-#include <mraa/gpio.hpp>
-
-#define BMG160_I2C_BUS 0
-#define BMG160_SPI_BUS 0
-#define BMG160_DEFAULT_ADDR 0x68
-
-
-namespace upm {
-
- /**
- * @library bmx050
- * @sensor bmg160
- * @comname BMG160 16 bit Trixial Gyroscope
- * @type gyro
- * @man bosch
- * @con i2c spi gpio
- *
- * @brief API for the BMG160 16 bit Trixial Gyroscope
- *
- * The BMG160 is a 3-axis angular rate sensor that is made of a
- * surface micro machined sensing element and an evaluation ASIC.
- * Both parts are packed into one single LGA 3.0mm x 3.0mm x 0.95mm
- * housing. The BMG160 is designed to meet requirements for
- * consumer applications such as image stabilization (DSC and
- * camera-phone), gaming and pointing devices. It is capable to
- * measure angular rates in three perpendicular room dimensions, the
- * x-, y- and z-axis, and to provide the corresponding output
- * signals. The BMG160 is fitted with digital bi-directional SPI and
- * I2C interfaces for optimum system integration.
- *
- * Not all functionality of this chip has been implemented in this
- * driver, however all the pieces are present to add any desired
- * functionality. This driver supports both I2C (default) and SPI
- * operation.
- *
- * This device requires 3.3v operation.
- *
- * @snippet bmg160.cxx Interesting
- */
-
- class BMG160 {
- public:
- // special reset byte
- static const uint8_t BMG160_RESET_BYTE = 0xb6;
-
- // NOTE: Reserved registers must not be written into. Reading
- // from them may return indeterminate values. Registers
- // containing reserved bitfields must be written as 0. Reading
- // reserved bitfields may return indeterminate values.
-
- /**
- * BMG160 registers
- */
- typedef enum : uint8_t {
- REG_CHIP_ID = 0x00,
-
- // 0x01 reserved
-
- REG_RATE_X_LSB = 0x02,
- REG_RATE_X_MSB = 0x03,
- REG_RATE_Y_LSB = 0x04,
- REG_RATE_Y_MSB = 0x05,
- REG_RATE_Z_LSB = 0x06,
- REG_RATE_Z_MSB = 0x07,
-
- REG_TEMP = 0x08,
-
- REG_INT_STATUS_0 = 0x09,
- REG_INT_STATUS_1 = 0x0a,
- REG_INT_STATUS_2 = 0x0b,
- REG_INT_STATUS_3 = 0x0c,
-
- // 0x0d reserved
-
- REG_FIFO_STATUS = 0x0e,
-
- REG_GYR_RANGE = 0x0f,
- REG_GYR_BW = 0x10,
- REG_LPM1 = 0x11,
- REG_LPM2 = 0x12,
-
- REG_RATE_HBW = 0x13,
-
- REG_SOFTRESET = 0x14,
-
- REG_INT_EN_0 = 0x15,
- REG_INT_EN_1 = 0x16,
-
- REG_INT_MAP_0 = 0x17,
- REG_INT_MAP_1 = 0x18,
- REG_INT_MAP_2 = 0x19,
-
- REG_INT_1A = 0x1a,
- REG_INT_1B = 0x1b,
- REG_INT_1C = 0x1c,
-
- // 0x1d reserved
-
- REG_INT_1E = 0x1e,
-
- // 0x1f-0x20 reserved
-
- REG_INT_RST_LATCH = 0x21,
-
- REG_HIGH_TH_X = 0x22,
- REG_HIGH_DUR_X = 0x23,
- REG_HIGH_TH_Y = 0x24,
- REG_HIGH_DUR_Y = 0x25,
- REG_HIGH_TH_Z = 0x26,
- REG_HIGH_DUR_Z = 0x27,
-
- // 0x28-0x30 reserved
-
- REG_SOC = 0x31,
- REG_A_FOC = 0x32,
-
- REG_TRIM_NVM_CTRL = 0x33,
-
- REG_SPI3_WDT = 0x34,
-
- // 0x35 reserved
-
- REG_OFC1 = 0x36,
- REG_OFC2 = 0x37,
- REG_OFC3 = 0x38,
- REG_OFC4 = 0x39,
-
- REG_TRIM_GP0 = 0x3a,
- REG_TRIM_GP1 = 0x3b,
-
- REG_BIST = 0x3c,
-
- REG_FIFO_CONFIG_0 = 0x3d,
- REG_FIFO_CONFIG_1 = 0x3e,
-
- REG_FIFO_DATA = 0x3f
-
- } BMG160_REGS_T;
-
- /**
- * REG_INT_STATUS_0 bits
- */
- typedef enum {
- _INT_STATUS_0_RESERVED_BITS = 0xf0 | 0x08 | 0x01,
-
- INT_STATUS_0_HIGH_INT = 0x02,
- INT_STATUS_0_ANY_INT = 0x04
- } INT_STATUS_0_BITS_T;
-
- /**
- * REG_INT_STATUS_1 bits
- */
- typedef enum {
- _INT_STATUS_1_RESERVED_BITS = 0x0f,
-
- INT_STATUS_1_FIFO_INT = 0x10,
- INT_STATUS_1_FAST_OFFSET_INT = 0x20,
- INT_STATUS_1_AUTO_OFFSET_INT = 0x40,
- INT_STATUS_1_DATA_INT = 0x80
- } INT_STATUS_1_BITS_T;
-
- /**
- * REG_INT_STATUS_2 bits
- */
- typedef enum {
- _INT_STATUS_2_RESERVED_BITS = 0xf0,
-
- INT_STATUS_2_ANY_FIRST_X = 0x01,
- INT_STATUS_2_ANY_FIRST_Y = 0x02,
- INT_STATUS_2_ANY_FIRST_Z = 0x04,
- INT_STATUS_2_ANY_SIGN = 0x08
- } INT_STATUS_2_BITS_T;
-
- /**
- * REG_INT_STATUS_3 bits
- */
- typedef enum {
- _INT_STATUS_3_RESERVED_BITS = 0xf0,
-
- INT_STATUS_3_HIGH_FIRST_X = 0x01,
- INT_STATUS_3_HIGH_FIRST_Y = 0x02,
- INT_STATUS_3_HIGH_FIRST_Z = 0x04,
- INT_STATUS_3_HIGH_SIGN = 0x08
- } INT_STATUS_3_BITS_T;
-
- /**
- * REG_FIFO_STATUS bits
- */
- typedef enum {
- FIFO_STATUS_FRAME_COUNTER0 = 0x01,
- FIFO_STATUS_FRAME_COUNTER1 = 0x02,
- FIFO_STATUS_FRAME_COUNTER2 = 0x04,
- FIFO_STATUS_FRAME_COUNTER3 = 0x08,
- FIFO_STATUS_FRAME_COUNTER4 = 0x10,
- FIFO_STATUS_FRAME_COUNTER5 = 0x20,
- FIFO_STATUS_FRAME_COUNTER6 = 0x40,
- _FIFO_STATUS_FRAME_COUNTER_MASK = 127,
- _FIFO_STATUS_FRAME_COUNTER_SHIFT = 0,
-
- FIFO_STATUS_FIFO_OVERRUN = 0x80
- } FIFO_STATUS_BITS_T;
-
- /**
- * REG_GYR_RANGE bits
- */
- typedef enum {
- _GYR_RANGE_RESERVED_BITS = 0x20 | 0x10 | 0x08,
-
- GYR_RANGE0 = 0x01,
- GYR_RANGE1 = 0x02,
- GYR_RANGE2 = 0x04,
- _GYR_RANGE_MASK = 7,
- _GYR_RANGE_SHIFT = 0,
-
- GYR_RANGE_FIXED0 = 0x40, // bits need hardcoding to 0b10
- GYR_RANGE_FIXED1 = 0x80, // for some odd reason...
- _GYR_RANGE_FIXED_MASK = 3,
- _GYR_RANGE_FIXED_SHIFT = 6,
- _GYR_RANGE_FIXED_VALUE = 2 // 0b10
- } GYR_RANGE_BITS_T;
-
- /**
- * GYR_RANGE (gyroscope deg/s range) values
- */
- typedef enum {
- RANGE_2000 = 0, // degrees/sec
- RANGE_1000 = 1,
- RANGE_500 = 2,
- RANGE_250 = 3,
- RANGE_125 = 4
- } RANGE_T;
-
- /**
- * REG_GYR_BW bits
- */
- typedef enum {
- _GYR_BW_RESERVED_BITS = 0xf0,
-
- GYR_BW0 = 0x01,
- GYR_BW1 = 0x02,
- GYR_BW2 = 0x04,
- GYR_BW3 = 0x08,
- _GYR_BW_MASK = 15,
- _GYR_BW_SHIFT = 0
- } GYR_BW_BITS_T;
-
- /**
- * GYR_BW (gyroscope filter bandwidth) values
- */
- typedef enum {
- BW_2000_UNFILTERED = 0, // ODR/Filter BW
- BW_2000_230 = 1, // ODR 2000Hz, Filter BW 230Hz
- BW_1000_116 = 2,
- BW_400_47 = 3,
- BW_200_23 = 4,
- BW_100_12 = 5,
- BW_200_64 = 6,
- BW_100_32 = 7
- } BW_T;
-
- /**
- * REG_LPM1 bits
- */
- typedef enum {
- // 0x01 reserved
- _LPM1_RESERVED_MASK = 0x40 | 0x10 | 0x01,
-
- LPM1_SLEEP_DUR0 = 0x02, // sleep dur in low power mode
- LPM1_SLEEP_DUR1 = 0x04,
- LPM1_SLEEP_DUR2 = 0x08,
- _LPM1_SLEEP_MASK = 7,
- _LPM1_SLEEP_SHIFT = 1,
-
- // These are separate bits, deep_suspend and suspend (and if all
- // 0, normal). Since only specific combinations are allowed, we
- // will treat this as a 3 bit bitfield called POWER_MODE.
- LPM1_POWER_MODE0 = 0x20, // deep_suspend
- LPM1_POWER_MODE1 = 0x40, // must always be 0!
- LPM1_POWER_MODE2 = 0x80, // suspend
- _LPM1_POWER_MODE_MASK = 7,
- _LPM1_POWER_MODE_SHIFT = 5
- } LPM1_BITS_T;
-
- /**
- * SLEEP_DUR values
- */
- typedef enum {
- SLEEP_DUR_2 = 0, // 2ms
- SLEEP_DUR_4 = 1,
- SLEEP_DUR_5 = 2,
- SLEEP_DUR_8 = 3,
- SLEEP_DUR_10 = 4,
- SLEEP_DUR_15 = 5,
- SLEEP_DUR_18 = 6,
- SLEEP_DUR_20 = 7
- } SLEEP_DUR_T;
-
- /**
- * POWER_MODE values
- */
- typedef enum {
- POWER_MODE_NORMAL = 0,
- POWER_MODE_DEEP_SUSPEND = 1,
- POWER_MODE_SUSPEND = 4
- } POWER_MODE_T;
-
- /**
- * REG_LPM2 bits
- */
- typedef enum {
- _LPM2_RESERVED_BITS = 0x08,
-
- LPM2_AUTOSLEEP_DUR0 = 0x01,
- LPM2_AUTOSLEEP_DUR1 = 0x02,
- LPM2_AUTOSLEEP_DUR2 = 0x04,
- _LPM2_AUTOSLEEP_DUR_MASK = 7,
- _LPM2_AUTOSLEEP_DUR_SHIFT = 0,
-
- LPM2_EXT_TRIG_SEL0 = 0x10,
- LPM2_EXT_TRIG_SEL1 = 0x20,
- _LPM2_EXT_TRIG_SEL_MASK = 3,
- _LPM2_EXT_TRIG_SEL_SHIFT = 4,
-
- LPM2_POWER_SAVE_MODE = 0x40,
- LPM2_FAST_POWERUP = 0x80
- } LPM2_BITS_T;
-
-
- /**
- * LPM2_AUTOSLEEP_DUR values
- */
- typedef enum {
- AUTOSLEEP_DUR_NONE = 0,
- AUTOSLEEP_DUR_4MS = 1,
- AUTOSLEEP_DUR_5MS = 2,
- AUTOSLEEP_DUR_8MS = 3,
- AUTOSLEEP_DUR_10MS = 4,
- AUTOSLEEP_DUR_15MS = 5,
- AUTOSLEEP_DUR_20MS = 6,
- AUTOSLEEP_DUR_40MS = 7
- } AUTOSLEEP_DUR_T;
-
- /**
- * LPM2_EXT_TRIG_SEL values
- */
- typedef enum {
- EXT_TRIG_SEL_NONE = 0,
- EXT_TRIG_SEL_INT1 = 1,
- EXT_TRIG_SEL_INT2 = 2,
- EXT_TRIG_SEL_SDO = 3 // if SPI3 mode (unsupported)
- } EXT_TRIG_SEL_T;
-
- /**
- * REG_RATE_HBW bits
- */
- typedef enum {
- _RATE_HBW_RESERVED_BITS = 0x0f | 0x10 | 0x20,
-
- RATE_HBW_SHADOW_DIS = 0x40,
- RATE_HBW_DATA_HIGH_BW = 0x80
- } RATE_HBW_BITS_T;
-
- /**
- * REG_INT_EN_0 bits
- */
- typedef enum {
- _INT_EN_0_RESERVED_BITS = 0x20 | 0x10 | 0x08 | 0x02 | 0x01,
-
- INT_EN_0_AUTO_OFFSET_EN = 0x04,
-
- INT_EN_0_FIFO_EN = 0x40,
- INT_EN_0_DATA_EN = 0x80
- } INT_EN_0_BITS_T;
-
- /**
- * REG_INT_EN_1 bits
- */
- typedef enum {
- _INT_EN_1_INT1_RESERVED_BITS = 0xf0,
-
- INT_EN_1_INT1_LVL = 0x01, // level or edge
- INT_EN_1_INT1_OD = 0x02, // push-pull or open drain
- INT_EN_1_INT2_LVL = 0x04,
- INT_EN_1_INT2_OD = 0x08
- } INT_EN_1_BITS_T;
-
- /**
- * REG_INT_MAP_0 bits
- */
- typedef enum {
- _INT_MAP_0_RESERVED_BITS = 0xf0 | 0x04 | 0x01,
-
- INT_MAP_0_INT1_ANY = 0x02,
- INT_MAP_0_INT1_HIGH = 0x08
- } INT_MAP_0_BITS_T;
-
- /**
- * REG_INT_MAP_1 bits
- */
- typedef enum {
- INT_MAP_1_INT1_DATA = 0x01,
- INT_MAP_1_INT1_FAST_OFFSET = 0x02,
- INT_MAP_1_INT1_FIFO = 0x04,
- INT_MAP_1_INT1_AUTO_OFFSET = 0x08,
- INT_MAP_1_INT2_AUTO_OFFSET = 0x10,
- INT_MAP_1_INT2_FIFO = 0x20,
- INT_MAP_1_INT2_FAST_OFFSET = 0x40,
- INT_MAP_1_INT2_DATA = 0x80
- } INT_MAP_1_BITS_T;
-
- /**
- * REG_INT_1A bits
- */
- typedef enum {
- _INT_1A_RESERVED_BITS = 0xd5,
-
- INT_1A_ANY_UNFILT_DATA = 0x02,
- INT_1A_HIGH_UNFILT_DATA = 0x08,
- INT_1A_SLOW_OFFSET_UNFILT = 0x20
- } INT_1A_BITS_T;
-
- /**
- * REG_INT_1B bits
- */
- typedef enum {
- INT_1B_ANY_TH0 = 0x01,
- INT_1B_ANY_TH1 = 0x02,
- INT_1B_ANY_TH2 = 0x04,
- INT_1B_ANY_TH3 = 0x08,
- INT_1B_ANY_TH4 = 0x10,
- INT_1B_ANY_TH5 = 0x20,
- INT_1B_ANY_TH6 = 0x40,
- _INT_1B_ANY_TH_MASK = 127,
- _INT_1B_ANY_TH_SHIFT = 0,
-
- INT_1B_FAST_OFFSET_UNFILT = 0x80
- } INT_1B_BITS_T;
-
- /**
- * REG_INT_1C bits
- */
- typedef enum {
- _INT_1C_RESERVED_BITS = 0x08,
-
- INT_1C_ANY_EN_X = 0x01,
- INT_1C_ANY_EN_Y = 0x02,
- INT_1C_ANY_EN_Z = 0x04,
-
- INT_1C_ANY_DUR_SAMPLE0 = 0x10,
- INT_1C_ANY_DUR_SAMPLE1 = 0x20,
- INT_1C_ANY_DUR_SAMPLE_MASK = 3,
- INT_1C_ANY_DUR_SAMPLE_SHIFT = 4,
-
- INT_1C_AWAKE_DUR0 = 0x40,
- INT_1C_AWAKE_DUR1 = 0x80,
- INT_1C_AWAKE_DUR_MASK = 3,
- INT_1C_AWAKE_DUR_SHIFT = 6
- } INT_1C_BITS_T;
-
- /**
- * INT_1C_ANY_DUR_SAMPLE values
- */
- typedef enum {
- ANY_DUR_SAMPLE_4 = 0, // samples
- ANY_DUR_SAMPLE_8 = 1,
- ANY_DUR_SAMPLE_12 = 2,
- ANY_DUR_SAMPLE_16 = 3
- } ANY_DUR_SAMPLE_T;
-
- /**
- * INT_1C_AWAKE_DUR values
- */
- typedef enum {
- AWAKE_DUR_SAMPLE_8 = 0, // samples
- AWAKE_DUR_SAMPLE_16 = 1,
- AWAKE_DUR_SAMPLE_32 = 2,
- AWAKE_DUR_SAMPLE_64 = 3
- } AWAKE_DUR_SAMPLE_T;
-
- /**
- * REG_INT_1E bits
- */
- typedef enum {
- _INT_1E_RESERVED_BITS = 0x7f,
-
- INT_1E_FIFO_WM_EN = 0x80
- } INT_1E_BITS_T;
-
- /**
- * REG_INT_RST_LATCH bits
- */
- typedef enum {
- _INT_RST_LATCH_RESERVED_BITS = 0x20,
-
- INT_RST_LATCH0 = 0x01,
- INT_RST_LATCH1 = 0x02,
- INT_RST_LATCH2 = 0x04,
- INT_RST_LATCH3 = 0x08,
- _INT_RST_LATCH_MASK = 15,
- _INT_RST_LATCH_SHIFT = 0,
-
- INT_RST_LATCH_STATUS_BIT = 0x10,
-
- INT_RST_LATCH_OFFSET_RESET = 0x40,
- INT_RST_LATCH_RESET_INT = 0x80
- } INT_RST_LATCH_BITS_T;
-
- /**
- * RST_LATCH values
- */
- typedef enum {
- RST_LATCH_NON_LATCHED = 0,
- RST_LATCH_TEMPORARY_250MS = 1,
- RST_LATCH_TEMPORARY_500MS = 2,
- RST_LATCH_TEMPORARY_1S = 3,
- RST_LATCH_TEMPORARY_2S = 4,
- RST_LATCH_TEMPORARY_4S = 5,
- RST_LATCH_TEMPORARY_8S = 6,
- RST_LATCH_LATCHED = 7,
-
- // 8 == non latched
-
- RST_LATCH_TEMPORARY_250US = 9,
- RST_LATCH_TEMPORARY_500US = 10,
- RST_LATCH_TEMPORARY_1MS = 11,
- RST_LATCH_TEMPORARY_12_5MS = 12,
- RST_LATCH_TEMPORARY_25MS = 13,
- RST_LATCH_TEMPORARY_50MS = 14
-
- // 15 == latched
- } RST_LATCH_T;
-
- /**
- * REG_HIGH_TH_* (X, Y, and Z) register bits
- */
- typedef enum {
- HIGH_TH_EN = 0x01,
-
- HIGH_TH_TH0 = 0x02,
- HIGH_TH_TH1 = 0x04,
- HIGH_TH_TH2 = 0x08,
- HIGH_TH_TH3 = 0x10,
- HIGH_TH_TH4 = 0x20,
- _HIGH_TH_TH_MASK = 31,
- _HIGH_TH_TH_SHIFT = 1,
-
- HIGH_TH_HY0 = 0x40,
- HIGH_TH_HY1 = 0x80,
- _HIGH_TH_HY_MASK = 3,
- _HIGH_TH_HY_SHIFT = 6
- } HIGH_TH_BITS_T;
-
- /**
- * REG_SOC bits
- */
- typedef enum {
- SOC_SLOW_OFFSET_EN_X = 0x01,
- SOC_SLOW_OFFSET_EN_Y = 0x02,
- SOC_SLOW_OFFSET_EN_Z = 0x04,
-
- SOC_SLOW_OFFSET_DUR0 = 0x08,
- SOC_SLOW_OFFSET_DUR1 = 0x10,
- SOC_SLOW_OFFSET_DUR2 = 0x20,
- _SOC_SLOW_OFFSET_DUR_MASK = 7,
- _SOC_SLOW_OFFSET_DUR_SHIFT = 3,
-
- SOC_SLOW_OFFSET_TH0 = 0x40,
- SOC_SLOW_OFFSET_TH1 = 0x80,
- _SOC_SLOW_OFFSET_TH_MASK = 3,
- _SOC_SLOW_OFFSET_TH_SHIFT = 6
- } SOC_BITS_T;
-
- /**
- * SOC_SLOW_OFFSET_DUR values
- */
- typedef enum {
- SLOW_OFFSET_DUR_40MS = 0, // 40ms
- SLOW_OFFSET_DUR_80MS = 1,
- SLOW_OFFSET_DUR_160MS = 2,
- SLOW_OFFSET_DUR_320MS = 3,
- SLOW_OFFSET_DUR_640MS = 4,
- SLOW_OFFSET_DUR_1280MS = 5
- } SLOW_OFFSET_DUR_T;
-
- /**
- * SOC_SLOW_OFFSET_TH values
- */
- typedef enum {
- SLOW_OFFSET_TH_0_1 = 0, // 0.1 degree/s
- SLOW_OFFSET_TH_0_2 = 1,
- SLOW_OFFSET_TH_0_5 = 2,
- SLOW_OFFSET_TH_1 = 3
- } SLOW_OFFSET_TH_T;
-
- /**
- * REG_A_FOC bits
- */
- typedef enum {
- A_FOC_FAST_OFFSET_EN_X = 0x01,
- A_FOC_FAST_OFFSET_EN_Y = 0x02,
- A_FOC_FAST_OFFSET_EN_Z = 0x04,
-
- A_FOC_FAST_OFFSET_EN = 0x08,
-
- A_FOC_FAST_OFFSET_WORDLENGTH0 = 0x10,
- A_FOC_FAST_OFFSET_WORDLENGTH1 = 0x20,
- _A_FOC_FAST_OFFSET_WORDLENGTH_MASK = 3,
- _A_FOC_FAST_OFFSET_WORDLENGTH_SHIFT = 4,
-
- A_FOC_AUTO_OFFSET_WORDLENGTH0 = 0x40,
- A_FOC_AUTO_OFFSET_WORDLENGTH1 = 0x80,
- _A_FOC_AUTO_OFFSET_WORDLENGTH_MASK = 3,
- _A_FOC_AUTO_OFFSET_WORDLENGTH_SHIFT = 6
- } A_FOC_BITS_T;
-
- /**
- * FAST_OFFSET_WORDLENGTH values
- */
- typedef enum {
- FAST_OFFSET_WORDLENGTH_32 = 0, // samples
- FAST_OFFSET_WORDLENGTH_64 = 1,
- FAST_OFFSET_WORDLENGTH_128 = 2,
- FAST_OFFSET_WORDLENGTH_256 = 3
- } FAST_OFFSET_WORDLENGTH_T;
-
- /**
- * AUTO_OFFSET_WORDLENGTH values
- */
- typedef enum {
- AUTO_OFFSET_WORDLENGTH_32 = 0, // samples
- AUTO_OFFSET_WORDLENGTH_64 = 1,
- AUTO_OFFSET_WORDLENGTH_128 = 2,
- AUTO_OFFSET_WORDLENGTH_256 = 3
- } AUTO_OFFSET_WORDLENGTH_T;
-
- /**
- * REG_TRIM_NVM_CTRL bits
- */
- typedef enum {
- TRIM_NVM_CTRL_NVM_PROG_MODE = 0x01,
- TRIM_NVM_CTRL_NVM_PROG_TRIG = 0x02,
- TRIM_NVM_CTRL_NVM_PROG_RDY = 0x04,
- TRIM_NVM_CTRL_NVM_PROG_LOAD = 0x08,
-
- TRIM_NVM_CTRL_NVM_REMAIN0 = 0x10,
- TRIM_NVM_CTRL_NVM_REMAIN1 = 0x20,
- TRIM_NVM_CTRL_NVM_REMAIN2 = 0x40,
- TRIM_NVM_CTRL_NVM_REMAIN3 = 0x80,
- _TRIM_NVM_CTRL_NVM_REMAIN_MASK = 15,
- _TRIM_NVM_CTRL_NVM_REMAIN_SHIFT = 4
- } TRIM_NVM_CTRL_BITS_T;
-
- /**
- * REG_SPI3_WDT bits
- */
- typedef enum {
- _SPI3_WDT_RESERVED_BITS = 0xf0 | 0x08,
-
- SPI3_WDT_SPI3 = 0x01, // 3-wire SPI - NOT SUPPORTED
-
- SPI3_WDT_I2C_WDT_SEL = 0x02,
- SPI3_WDT_I2C_WDT_EN = 0x04
-
- // 0x08-0x80 reserved
- } SPI3_WDT_BITS_T;
-
- /**
- * REG_OFC1 bits, the missing x, y, and z llsb bits are in GP0
- */
- typedef enum {
- OFC1_OFFSET_Z0 = 0x01, // Z lsb (3:1)
- OFC1_OFFSET_Z1 = 0x02,
- OFC1_OFFSET_Z2 = 0x04,
- _OFC1_OFFSET_Z_MASK = 7,
- _OFC1_OFFSET_Z_SHIFT = 0,
-
- OFC1_OFFSET_Y0 = 0x08, // Y lsb (3:1)
- OFC1_OFFSET_Y1 = 0x10,
- OFC1_OFFSET_Y2 = 0x20,
- _OFC1_OFFSET_Y_MASK = 7,
- _OFC1_OFFSET_Y_SHIFT = 3,
-
- OFC1_OFFSET_X0 = 0x08, // bits 3:2 of X lsb. geez
- OFC1_OFFSET_X1 = 0x10,
- _OFC1_OFFSET_X_MASK = 3,
- _OFC1_OFFSET_X_SHIFT = 6
- } OFC1_OFFSET_BITS_T;
-
- /**
- * REG_GP0 bits
- */
- typedef enum {
- GP0_OFFSET_Z = 0x01, // Z llsb (bit 0)
- GP0_OFFSET_Y = 0x02, // Y llsb (bit 0)
-
- GP0_OFFSET_X0 = 0x04, // X llsbs (bits 1:0)
- GP0_OFFSET_X1 = 0x08,
- _GP0_OFFSET_X_MASK = 3,
- _GP0_OFFSET_X_SHIFT = 2,
-
- GP0_GP00 = 0x10,
- GP0_GP01 = 0x20,
- GP0_GP02 = 0x40,
- GP0_GP03 = 0x80,
- _GP0_GP0_MASK = 15,
- _GP0_GP0_SHIFT = 4
- } GP0_BITS_T;
-
- /**
- * REG_BIST bits
- */
- typedef enum {
- _BIST_RESERVED_BITS = 0x80 | 0x40 | 0x20 | 0x08,
-
- BIST_TRIG_BIST = 0x01,
- BIST_BIST_RDY = 0x02,
- BIST_BIST_FAIL = 0x04,
-
- BIST_RATE_OK = 0x10
- } BIST_BITS_T;
-
- /**
- * REG_FIFO_CONFIG_0 bits
- */
- typedef enum {
- FIFO_CONFIG_0_WATER_MARK0 = 0x01,
- FIFO_CONFIG_0_WATER_MARK1 = 0x02,
- FIFO_CONFIG_0_WATER_MARK2 = 0x04,
- FIFO_CONFIG_0_WATER_MARK3 = 0x08,
- FIFO_CONFIG_0_WATER_MARK4 = 0x10,
- FIFO_CONFIG_0_WATER_MARK5 = 0x20,
- FIFO_CONFIG_0_WATER_MARK6 = 0x40,
- _FIFO_CONFIG_0_WATER_MARK_MASK = 127,
- _FIFO_CONFIG_0_WATER_MARK_SHIFT = 0,
-
- FIFO_CONFIG_0_TAG = 0x80
- } FIFO_CONFIG_0_BITS_T;
-
- /**
- * REG_FIFO_CONFIG_1 bits
- */
- typedef enum {
- _FIFO_CONFIG_1_RESERVED_BITS = 0x20 | 0x10 |0x08 | 0x04,
-
- FIFO_CONFIG_1_FIFO_DATA_SEL0 = 0x01,
- FIFO_CONFIG_1_FIFO_DATA_SEL1 = 0x02,
- _FIFO_CONFIG_1_FIFO_DATA_SEL = 3,
- _FIFO_CONFIG_1_FIFO_DATA_SHIFT = 0,
-
- FIFO_CONFIG_1_FIFO_MODE0 = 0x40,
- FIFO_CONFIG_1_FIFO_MODE1 = 0x80,
- _FIFO_CONFIG_1_FIFO_MODE_MASK = 3,
- _FIFO_CONFIG_1_FIFO_MODE_SHIFT = 6
- } FIFO_CONFIG_1_BITS_T;
-
- /**
- * FIFO_DATA_SEL values
- */
- typedef enum {
- FIFO_DATA_SEL_XYZ = 0,
- FIFO_DATA_SEL_X = 1,
- FIFO_DATA_SEL_Y = 2,
- FIFO_DATA_SEL_Z = 3
- } FIFO_DATA_SEL_T;
-
- /**
- * FIFO_MODE values
- */
- typedef enum {
- FIFO_MODE_BYPASS = 0,
- FIFO_MODE_FIFO = 1,
- FIFO_MODE_STREAM = 2
- } FIFO_MODE_T;
-
- // interrupt selection for installISR() and uninstallISR()
- typedef enum {
- INTERRUPT_INT1,
- INTERRUPT_INT2
- } INTERRUPT_PINS_T;
-
-
- /**
- * BMG160 constructor.
- *
- * This device can support both I2C and SPI. For SPI, set the addr
- * to -1, and specify a positive integer representing the Chip
- * Select (CS) pin for the cs argument. If you are using a
- * hardware CS pin (like edison with arduino breakout), then you
- * can connect the proper pin to the hardware CS pin on your MCU
- * and supply -1 for cs. The default operating mode is I2C.
- *
- * @param bus I2C or SPI bus to use.
- * @param addr The address for this device. -1 for SPI.
- * @param cs The gpio pin to use for the SPI Chip Select. -1 for
- * I2C or for SPI with a hardware controlled pin.
- * @param theChipID The chip ID to use for validation
- */
- BMG160(int bus=BMG160_I2C_BUS, uint8_t addr=BMG160_DEFAULT_ADDR,
- int cs=-1);
-
- /**
- * BMG160 Destructor.
- */
- ~BMG160();
-
- /**
- * Update the internal stored values from sensor data.
- */
- void update();
-
- /**
- * Return the chip ID.
- *
- * @return The chip ID (BMG160_CHIPID).
- */
- uint8_t getChipID();
-
- /**
- * Return gyroscope data in degrees per second. update() must
- * have been called prior to calling this method.
- *
- * @param x Pointer to a floating point value that will have the
- * current x component placed into it.
- * @param y Pointer to a floating point value that will have the
- * current y component placed into it.
- * @param z Pointer to a floating point value that will have the
- * current z component placed into it.
- */
- void getGyroscope(float *x, float *y, float *z);
-
- /**
- * Return gyroscope data in degrees per second in the form of a
- * floating point array. The pointer returned by this function is
- * statically allocated and will be rewritten on each call.
- * update() must have been called prior to calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getGyroscope();
-
- /**
- * Return the current measured temperature. Note, this is not
- * ambient temperature. update() must have been called prior to
- * calling this method.
- *
- * @param fahrenheit true to return data in Fahrenheit, false for
- * Celicus. Celcius is the default.
- * @return The temperature in degrees Celcius or Fahrenheit.
- */
- float getTemperature(bool fahrenheit=false);
-
- /**
- * Initialize the device and start operation. This function is
- * called from the constructor so will not typically need to be
- * called by a user unless the device is reset.
- *
- * @param pwr One of the POWER_MODE_T values. The default is
- * POWER_MODE_NORMAL.
- * @param range One of the RANGE_T values. The default is
- * RANGE_250.
- * @param bw One of the filtering BW_T values. The default is
- * BW_400_47.
- */
- void init(POWER_MODE_T pwr=POWER_MODE_NORMAL,
- RANGE_T range=RANGE_250, BW_T bw=BW_400_47);
-
- /**
- * Reset the device as if during a power on reset. All configured
- * values are lost when this happens. You should call init()
- * afterwards, or at least perform the same initialization init()
- * does before continuing.
- */
- void reset();
-
- /**
- * Set the gyroscope detection scaling range. This device
- * supports 125, 250, 500, 100, and 2000 degree/s ranges.
- *
- * @param range One of the RANGE_T values.
- */
- void setRange(RANGE_T range);
-
- /**
- * Set the output filtering bandwidth of the device.
- *
- * @param bw One of the BW_T values.
- */
- void setBandwidth(BW_T bw);
-
- /**
- * Set the power mode of the device. Care must be taken when
- * setting a low power or suspend mode. See the datasheet for
- * details. I ncertain power modes, register write must be
- * drastically slowed down. which we cannot support.
- *
- * @param power One of the POWER_MODE_T values.
- */
- void setPowerMode(POWER_MODE_T power);
-
- /**
- * Enable update() to read from the FIFO rather than the gyroscope
- * axis registers directly. init() enables this mode by default.
- * An advantage to this mode that all axis data is sampled from
- * the same timeslice. When reading directly from the gyroscope
- * output registers, it's possible for one axis to be updated
- * while another is being read, causing a temporal
- * inconsistancy..
- *
- * Using the FIFO removes this problem.
- *
- * @param useFIFO true to enable update() to read from the FIFO.
- * When false, update will read from the gyroscope output
- * registers directly.
- */
- void enableFIFO(bool useFIFO);
-
- /**
- * Set the FIFO watermark. When the watermark is reached an
- * interrupt (if enabled) will be generated.
- *
- * @param wm The FIFO watermark to use. The maximum value is 63.
- */
- void fifoSetWatermark(int wm);
-
- /**
- * Set the FIFO configuration. init() uses the FIFO_MODE_BYPASS
- * mode with axes set to FIFO_DATA_SEL_XYZ by default.
- *
- * @param mode One of the FIFO_MODE_T values.
- * @param axes One of the FIFO_DATA_SEL_T values.
- */
- void fifoConfig(FIFO_MODE_T mode, FIFO_DATA_SEL_T axes);
-
- /**
- * Return the Interrupt Enables 0 register. These resgisters
- * allow you to enable various interrupt conditions. See the
- * datasheet for details.
- *
- * @return A bitmask of INT_EN_0_BITS_T bits.
- */
- uint8_t getInterruptEnable0();
-
- /**
- * Set the Interrupt Enables 0 register. See the datasheet for
- * details.
- *
- * @param bits A bitmask of INT_EN_0_BITS_T bits.
- */
- void setInterruptEnable0(uint8_t bits);
-
- /**
- * Return the Interrupt Map 0 register. These registers allow you
- * to map specific interrupts to the interrupt 1 or interrupt 2
- * pin. See the datasheet for details.
- *
- * @return A bitmask of INT_MAP_0_BITS_T bits.
- */
- uint8_t getInterruptMap0();
-
- /**
- * Set the Interrupt Map 0 register. These registers allow you
- * to map specific interrupts to the interrupt 1 or interrupt 2
- * pin. See the datasheet for details.
- *
- * @param A bitmask of INT_MAP_0_BITS_T bits.
- */
- void setInterruptMap0(uint8_t bits);
-
- /**
- * Return the Interrupt Map 1 register. See the datasheet for
- * details.
- *
- * @return A bitmask of INT_MAP_1_BITS_T bits.
- */
- uint8_t getInterruptMap1();
-
- /**
- * Set the Interrupt Map 1 register. See the datasheet for
- * details.
- *
- * @param A bitmask of INT_MAP_1_BITS_T bits.
- */
- void setInterruptMap1(uint8_t bits);
-
- /**
- * Return the Interrupt source register. This register allows
- * determining where data comes from (filtered/unfiltered) for
- * those interrupt sources where this is selectable. See the
- * datasheet for details.
- *
- * @return A bitmask of INT_1A_BITS_T bits.
- */
- uint8_t getInterruptSrc();
-
- /**
- * Set the Interrupt source register. This register allows
- * determining where data comes from (filtered/unfiltered) for
- * those interrupt sources where this is selectable. See the
- * datasheet for details.
- *
- * @param bits A bitmask of INT_1A_BITS_T bits.
- */
- void setInterruptSrc(uint8_t bits);
-
- /**
- * Return the Interrupt output control register. This register
- * allows determining the electrical characteristics of the 2
- * interrupt pins (open-drain/push-pull and level/edge
- * triggering). See the datasheet for details.
- *
- * @return A bitmask of INT_EN_1_BITS_T bits.
- */
- uint8_t getInterruptOutputControl();
-
- /**
- * Set the Interrupt output control register. This register
- * allows determining the electrical characteristics of the 2
- * interrupt pins (open-drain/push-pull and level/edge
- * triggering). See the datasheet for details.
- *
- * @param bits A bitmask of INT_EN_1_BITS_T bits.
- */
- void setInterruptOutputControl(uint8_t bits);
-
- /**
- * Clear all latched interrupts. See the datasheet for details.
- */
- void clearInterruptLatches();
-
- /**
- * Return the current interrupt latching behavior. See the
- * datasheet for details.
- *
- * @return One of the RST_LATCH_T values.
- */
- RST_LATCH_T getInterruptLatchBehavior();
-
- /**
- * Set the current interrupt latching behavior. See the datasheet
- * for details.
- *
- * @param latch One of the RST_LATCH_T values.
- */
- void setInterruptLatchBehavior(RST_LATCH_T latch);
-
- /**
- * Return the interrupt status 0 register. These registers
- * indicate which interrupts have been triggered. See the
- * datasheet for details.
- *
- * @return a bitmask of INT_STATUS_0_BITS_T bits.
- */
- uint8_t getInterruptStatus0();
-
- /**
- * Return the interrupt status 1 register. See the datasheet for
- * details.
- *
- * @return a bitmask of INT_STATUS_1_BITS_T bits.
- */
- uint8_t getInterruptStatus1();
-
- /**
- * Return the interrupt status 2 register. See the datasheet for
- * details.
- *
- * @return a bitmask of INT_STATUS_2_BITS_T bits.
- */
- uint8_t getInterruptStatus2();
-
- /**
- * Return the interrupt status 3 register. See the datasheet for
- * details.
- *
- * @return a bitmask of INT_STATUS_3_BITS_T bits.
- */
- uint8_t getInterruptStatus3();
-
- /**
- * Enable shadowing of the gyroscope output registers. When
- * enabled, a read of an axis LSB register automatically locks the
- * MSB register of that axis until it has been read. This is
- * usually a good thing to have enabled. init() enables this by
- * default. If disabled, then it becomes possible for part of an
- * axis value to change while another part is being read, causing
- * inconsistent data.
- *
- * @param shadow true to enable axis register shadowing, false otherwise.
- */
- void enableRegisterShadowing(bool shadow);
-
- /**
- * Enable filtering of the gyroscope axis data. init()
- * enables this by default. If disabled, then gyroscope data
- * that is read will be raw and unfiltered (rated R). See the
- * datasheet for details.
- *
- * @param filter true to enable filtering, false to disable.
- */
- void enableOutputFiltering(bool filter);
-
-#if defined(SWIGJAVA) || defined(JAVACALLBACK)
- void installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- jobject runnable);
-#else
- /**
- * install an interrupt handler.
- *
- * @param intr one of the INTERRUPT_PINS_T values specifying which
- * interrupt pin you are installing.
- * @param gpio gpio pin to use as interrupt pin
- * @param level the interrupt trigger level (one of mraa::Edge
- * values). Make sure that you have configured the interrupt pin
- * properly for whatever level you choose.
- * @param isr the interrupt handler, accepting a void * argument
- * @param arg the argument to pass the the interrupt handler
- */
- void installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- void (*isr)(void *), void *arg);
-#endif
-
- /**
- * uninstall a previously installed interrupt handler
- *
- * @param intr one of the INTERRUPT_PINS_T values specifying which
- * interrupt pin you are removing.
- */
- void uninstallISR(INTERRUPT_PINS_T intr);
-
- /**
- * Read a register.
- *
- * @param reg The register to read.
- * @return The value of the register.
- */
- uint8_t readReg(uint8_t reg);
-
- /**
- * Read contiguous registers into a buffer.
- *
- * @param buffer The buffer to store the results.
- * @param len The number of registers to read.
- * @return The number of bytes read.
- */
- int readRegs(uint8_t reg, uint8_t *buffer, int len);
-
- /**
- * Write to a register
- *
- * @param reg The register to write to.
- * @param val The value to write.
- */
- void writeReg(uint8_t reg, uint8_t val);
-
- protected:
- mraa::I2c *m_i2c;
- mraa::Spi *m_spi;
-
- // spi chip select
- mraa::Gpio *m_gpioCS;
-
- mraa::Gpio *m_gpioIntr1;
- mraa::Gpio *m_gpioIntr2;
-
- uint8_t m_addr;
-
- // SPI chip select
- void csOn();
- void csOff();
-
- // acc data
- float m_gyrX;
- float m_gyrY;
- float m_gyrZ;
-
- float m_gyrScale;
-
- float m_temperature;
-
- private:
- bool m_isSPI;
- // use the FIFO by default?
- bool m_useFIFO;
-
- // return a reference to a gpio pin pointer depending on intr
- mraa::Gpio*& getPin(INTERRUPT_PINS_T intr);
-
- // Adding a private function definition for java bindings
-#if defined(SWIGJAVA) || defined(JAVACALLBACK)
- void installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- void (*isr)(void *), void *arg);
-#endif
- };
-}
diff --git a/peripheral/libupm/src/bmx055/bmi055.cxx b/peripheral/libupm/src/bmx055/bmi055.cxx
deleted file mode 100644
index 0b348f7..0000000
--- a/peripheral/libupm/src/bmx055/bmi055.cxx
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-
-#include "bmi055.hpp"
-
-using namespace upm;
-using namespace std;
-
-BMI055::BMI055(int accelBus, uint8_t accelAddr, int accelCS,
- int gyroBus, uint8_t gyroAddr, int gyroCS) :
- m_accel(0), m_gyro(0)
-{
- // if -1 is supplied as a bus for any of these, we will not
- // instantiate them
-
- if (accelBus >= 0)
- m_accel = new BMA250E(accelBus, accelAddr, accelCS);
-
- if (gyroBus >= 0)
- m_gyro = new BMG160(gyroBus, gyroAddr, gyroCS);
-
- // now initialize them...
- if (m_accel)
- m_accel->init();
-
- if (m_gyro)
- m_gyro->init();
-}
-
-BMI055::~BMI055()
-{
- if (m_accel)
- delete m_accel;
-
- if (m_gyro)
- delete m_gyro;
-}
-
-void BMI055::initAccelerometer(BMA250E::POWER_MODE_T pwr,
- BMA250E::RANGE_T range,
- BMA250E::BW_T bw)
-{
- if (m_accel)
- m_accel->init(pwr, range, bw);
-}
-
-void BMI055::initGyroscope(BMG160::POWER_MODE_T pwr,
- BMG160::RANGE_T range,
- BMG160::BW_T bw)
-{
- if (m_gyro)
- m_gyro->init(pwr, range, bw);
-}
-
-void BMI055::update()
-{
- if (m_accel)
- m_accel->update();
-
- if (m_gyro)
- m_gyro->update();
-}
-
-void BMI055::getAccelerometer(float *x, float *y, float *z)
-{
- if (m_accel)
- m_accel->getAccelerometer(x, y, z);
-}
-
-float *BMI055::getAccelerometer()
-{
- if (m_accel)
- return m_accel->getAccelerometer();
- else
- {
- static float v[3] = {0.0f, 0.0f, 0.0f};
- return v;
- }
-}
-
-void BMI055::getGyroscope(float *x, float *y, float *z)
-{
- if (m_gyro)
- m_gyro->getGyroscope(x, y, z);
-}
-
-float *BMI055::getGyroscope()
-{
- if (m_gyro)
- return m_gyro->getGyroscope();
- else
- {
- static float v[3] = {0.0f, 0.0f, 0.0f};
- return v;
- }
-}
diff --git a/peripheral/libupm/src/bmx055/bmi055.hpp b/peripheral/libupm/src/bmx055/bmi055.hpp
deleted file mode 100644
index 4212643..0000000
--- a/peripheral/libupm/src/bmx055/bmi055.hpp
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-
-#include "bma250e.hpp"
-#include "bmg160.hpp"
-
-namespace upm {
-
- /**
- * @library bmx055
- * @sensor bmi055
- * @comname BMI055 6-axis Sensor Module
- * @type accelerometer compass
- * @man mouser
- * @con i2c gpio spi
- * @web http://www.mouser.com/ProductDetail/Bosch-Sensortec/0330SB0134/?qs=sGAEpiMZZMsrChSOYEGTCVIRbo47L7ys6GxSnxRPEhU%3d
- *
- * @brief API for the BMI055 6-axis Sensor Module
- *
- * The BMI055 is an inertial measurement unit (IMU) for the
- * detection of movements and rotations in 6 degrees of freedom
- * (6DoF). It reflects the full functionality of a triaxial, low-g
- * acceleration sensor and at the same time it is capable to measure
- * angular rates. Both – acceleration and angular rate – in three
- * perpendicular room dimensions, the x-, y- and z-axis.
- *
- * The BMI055 is essentially 2 separate devices in one: the BMA250E
- * Accelerometer and the BMG160 Gyroscope. They are completely
- * independant of each other.
- *
- * This driver provides a very simple interface to these two devices.
- * If finer control is desired, you should just use the separate
- * BMA25E and BMG160 device classes directly. This driver
- * simply initializes both devices, and provides a mechanism to
- * read accelerometer and gyroscope data from them.
- *
- * @snippet bmi055.cxx Interesting
- */
-
- class BMI055 {
- public:
- /**
- * BMI055 constructor.
- *
- * This device can support both I2C and SPI. For SPI, set the addr
- * to -1, and specify a positive integer representing the Chip
- * Select (CS) pin for the cs argument. If you are using a
- * hardware CS pin (like edison with arduino breakout), then you
- * can connect the proper pin to the hardware CS pin on your MCU
- * and supply -1 for cs. The default operating mode is I2C.
- *
- * @param accelBus I2C or SPI bus to use. -1 to skip initializing
- * this device.
- * @param accelAddr The address for this device. -1 for SPI.
- * @param accelCS The gpio pin to use for the SPI Chip Select. -1 for
- * I2C or for SPI with a hardware controlled pin.
- * @param gyroBus I2C or SPI bus to use. -1 to skip initializing
- * this device.
- * @param gyroAddr The address for this device. -1 for SPI.
- * @param gyroCS The gpio pin to use for the SPI Chip Select. -1 for
- * I2C or for SPI with a hardware controlled pin.
- */
- BMI055(int accelBus=BMA250E_I2C_BUS,
- uint8_t accelAddr=BMA250E_DEFAULT_ADDR,
- int accelCS=-1,
- int gyroBus=BMG160_I2C_BUS,
- uint8_t gyroAddr=BMG160_DEFAULT_ADDR,
- int gyroCS=-1);
-
- /**
- * BMI055 Destructor.
- */
- ~BMI055();
-
- /**
- * Update the internal stored values from sensor data.
- */
- void update();
-
- /**
- * Initialize the accelerometer and start operation. This
- * function is called from the constructor so will not typically
- * need to be called by a user unless the device is reset or you
- * want to change these values.
- *
- * @param pwr One of the BMA250E::POWER_MODE_T values. The default is
- * BMA250E::POWER_MODE_NORMAL.
- * @param range One of the BMA250E::RANGE_T values. The default is
- * BMA250E::RANGE_2G.
- * @param bw One of the filtering BMA250E::BW_T values. The default is
- * BMA250E::BW_250.
- */
- void initAccelerometer(BMA250E::POWER_MODE_T pwr=BMA250E::POWER_MODE_NORMAL,
- BMA250E::RANGE_T range=BMA250E::RANGE_2G,
- BMA250E::BW_T bw=BMA250E::BW_250);
-
- /**
- * Initialize the gyroscope and start operation. This function is
- * called from the constructor so will not typically need to be
- * called by a user unless the device is reset or you want to
- * change these values.
- *
- * @param pwr One of the BMG160::POWER_MODE_T values. The default is
- * BMG160::POWER_MODE_NORMAL.
- * @param range One of the BMG160::RANGE_T values. The default is
- * BMG160::RANGE_250.
- * @param bw One of the filtering BMG160::BW_T values. The default is
- * BMG160::BW_400_47.
- */
- void initGyroscope(BMG160::POWER_MODE_T pwr=BMG160::POWER_MODE_NORMAL,
- BMG160::RANGE_T range=BMG160::RANGE_250,
- BMG160::BW_T bw=BMG160::BW_400_47);
-
- /**
- * Return accelerometer data in gravities. update() must have
- * been called prior to calling this method.
- *
- * @param x Pointer to a floating point value that will have the
- * current x component placed into it.
- * @param y Pointer to a floating point value that will have the
- * current y component placed into it.
- * @param z Pointer to a floating point value that will have the
- * current z component placed into it.
- */
- void getAccelerometer(float *x, float *y, float *z);
-
- /**
- * Return accelerometer data in gravities in the form of a
- * floating point array. The pointer returned by this function is
- * statically allocated and will be rewritten on each call.
- * update() must have been called prior to calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getAccelerometer();
-
- /**
- * Return gyroscope data in degrees per second. update() must
- * have been called prior to calling this method.
- *
- * @param x Pointer to a floating point value that will have the
- * current x component placed into it.
- * @param y Pointer to a floating point value that will have the
- * current y component placed into it.
- * @param z Pointer to a floating point value that will have the
- * current z component placed into it.
- */
- void getGyroscope(float *x, float *y, float *z);
-
- /**
- * Return gyroscope data in degrees per second in the form of a
- * floating point array. The pointer returned by this function is
- * statically allocated and will be rewritten on each call.
- * update() must have been called prior to calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getGyroscope();
-
-
- protected:
- BMA250E *m_accel;
- BMG160 *m_gyro;
-
- private:
- };
-}
diff --git a/peripheral/libupm/src/bmx055/bmm150.cxx b/peripheral/libupm/src/bmx055/bmm150.cxx
deleted file mode 100644
index 2e98ab2..0000000
--- a/peripheral/libupm/src/bmx055/bmm150.cxx
+++ /dev/null
@@ -1,675 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-// The trimming algorithms are taken from the Bosch BMM050 driver code
-
-/****************************************************************************
-* Copyright (C) 2015 - 2016 Bosch Sensortec GmbH
-*
-* File : bmm050.h
-*
-* Date : 2016/03/17
-*
-* Revision : 2.0.5 $
-*
-* Usage: Sensor Driver for BMM050 and BMM150 sensor
-*
-****************************************************************************
-*
-* section License
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-*
-* Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-*
-* Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-*
-* Neither the name of the copyright holder nor the names of the
-* contributors may be used to endorse or promote products derived from
-* this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
-* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
-* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
-* OR CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
-* OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO,
-* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-* ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
-*
-* The information provided is believed to be accurate and reliable.
-* The copyright holder assumes no responsibility
-* for the consequences of use
-* of such information nor for any infringement of patents or
-* other rights of third parties which may result from its use.
-* No license is granted by implication or otherwise under any patent or
-* patent rights of the copyright holder.
-**************************************************************************/
-
-
-#include <unistd.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-#include <string.h>
-
-#include "bmm150.hpp"
-
-#define BMM150_DEFAULT_CHIPID 0x32
-
-using namespace upm;
-using namespace std;
-
-BMM150::BMM150(int bus, uint8_t addr, int cs) :
- m_i2c(0), m_spi(0), m_gpioIntr(0), m_gpioDR(0), m_gpioCS(0)
-{
- m_addr = addr;
- m_isSPI = false;
-
- m_magX = 0;
- m_magY = 0;
- m_magZ = 0;
-
- m_hall = 0;
-
- m_dig_x1 = 0;
- m_dig_y1 = 0;
-
- m_dig_z4 = 0;
- m_dig_x2 = 0;
- m_dig_y2 = 0;
-
- m_dig_z2 = 0;
- m_dig_z1 = 0;
- m_dig_xyz1 = 0;
- m_dig_z3 = 0;
- m_dig_xy2 = 0;
- m_dig_xy1 = 0;
-
- if (addr < 0)
- m_isSPI = true;
-
- if (m_isSPI)
- {
- m_spi = new mraa::Spi(bus);
-
- // Only create cs context if we are actually using a valid pin.
- // A hardware controlled pin should specify cs as -1.
- if (cs >= 0)
- {
- m_gpioCS = new mraa::Gpio(cs);
- m_gpioCS->dir(mraa::DIR_OUT);
- }
-
- m_spi->mode(mraa::SPI_MODE0);
- m_spi->frequency(5000000);
- }
- else
- {
- // I2C
- m_i2c = new mraa::I2c(bus);
-
- mraa::Result rv;
- if ((rv = m_i2c->address(m_addr)) != mraa::SUCCESS)
- {
- throw std::runtime_error(string(__FUNCTION__) +
- ": I2c.address() failed");
- }
- }
-
- // power bit must be on for chip ID to be accessable
- setPowerBit(true);
- m_opmode = OPERATION_MODE_SLEEP;
-
- usleep(50000);
-
- // check the chip id
- uint8_t chipID = getChipID();
- if (chipID != BMM150_DEFAULT_CHIPID)
- {
- throw std::runtime_error(string(__FUNCTION__)
- + ": invalid chip ID. Expected "
- + std::to_string(int(BMM150_DEFAULT_CHIPID))
- + ", got "
- + std::to_string(int(chipID)));
- }
-
- // get trim data
- readTrimData();
-
- // call init with default options
- init();
-}
-
-BMM150::~BMM150()
-{
- uninstallISR(INTERRUPT_INT);
- uninstallISR(INTERRUPT_DR);
-}
-
-void BMM150::init(USAGE_PRESETS_T usage)
-{
- setPowerBit(true);
- setOpmode(OPERATION_MODE_NORMAL);
-
- usleep(50000); // 50ms, in case we are waking up
-
- setPresetMode(usage);
-
- // settle
- usleep(50000);
-}
-
-void BMM150::update()
-{
- // special care when in a forced mode - need to trigger a
- // measurement, and wait for the opmode to return to OPMODE_SLEEP,
- // then we can read the values.
-
- if (m_opmode == OPERATION_MODE_FORCED)
- {
- // trigger measurement
- setOpmode(OPERATION_MODE_FORCED);
-
- // opmode will return to sleep after measurement is complete
- do {
- usleep(5000);
- } while (getOpmode() == OPERATION_MODE_FORCED);
- }
-
- const int bufLen = 8;
- uint8_t buf[bufLen];
-
- if (readRegs(REG_MAG_X_LSB, buf, bufLen) != bufLen)
- {
- throw std::runtime_error(string(__FUNCTION__)
- + ": readRegs() failed to read "
- + std::to_string(bufLen)
- + " bytes");
- }
-
- // we need to get the hall data first, since it's needed for the
- // bosch compensation functions for each of the xyz axes
-
- m_hall = uint16_t(buf[7] << 8 | (buf[6] &
- (_MAG_RHALL_LSB_LSB_MASK <<
- _MAG_RHALL_LSB_LSB_SHIFT)));
- m_hall /= 4;
-
- int16_t val;
-
- // x
- val = int16_t(buf[1] << 8 | (buf[0] & (_MAG_XY_LSB_LSB_MASK <<
- _MAG_XY_LSB_LSB_SHIFT)));
- val /= 8;
- m_magX = bmm050_compensate_X_float(val, m_hall);
-
- // y
- val = int16_t(buf[3] << 8 | (buf[2] & (_MAG_XY_LSB_LSB_MASK <<
- _MAG_XY_LSB_LSB_SHIFT)));
- val /= 8;
- m_magY = bmm050_compensate_Y_float(val, m_hall);
-
- // z
- val = int16_t(buf[5] << 8 | (buf[4] & (_MAG_Z_LSB_LSB_MASK <<
- _MAG_Z_LSB_LSB_SHIFT)));
- val /= 2;
- m_magZ = bmm050_compensate_Z_float(val, m_hall);
-}
-
-uint8_t BMM150::readReg(uint8_t reg)
-{
- if (m_isSPI)
- {
- reg |= 0x80; // needed for read
- uint8_t pkt[2] = {reg, 0};
-
- csOn();
- if (m_spi->transfer(pkt, pkt, 2))
- {
- csOff();
- throw std::runtime_error(string(__FUNCTION__)
- + ": Spi.transfer() failed");
- }
- csOff();
-
- return pkt[1];
- }
- else
- return m_i2c->readReg(reg);
-}
-
-int BMM150::readRegs(uint8_t reg, uint8_t *buffer, int len)
-{
- if (m_isSPI)
- {
- reg |= 0x80; // needed for read
-
- uint8_t sbuf[len + 1];
- memset((char *)sbuf, 0, len + 1);
- sbuf[0] = reg;
-
- // We need to do it this way for edison - ie: use a single
- // transfer rather than breaking it up into two like we used to.
- // This means a buffer copy is now required, but that's the way
- // it goes.
-
- csOn();
- if (m_spi->transfer(sbuf, sbuf, len + 1))
- {
- csOff();
- throw std::runtime_error(string(__FUNCTION__)
- + ": Spi.transfer(buf) failed");
- }
- csOff();
-
- // now copy it into user buffer
- for (int i=0; i<len; i++)
- buffer[i] = sbuf[i + 1];
-
- return len;
- }
- else
- return m_i2c->readBytesReg(reg, buffer, len);
-}
-
-void BMM150::writeReg(uint8_t reg, uint8_t val)
-{
- if (m_isSPI)
- {
- reg &= 0x7f; // mask off 0x80 for writing
- uint8_t pkt[2] = {reg, val};
-
- csOn();
- if (m_spi->transfer(pkt, NULL, 2))
- {
- csOff();
- throw std::runtime_error(string(__FUNCTION__)
- + ": Spi.transfer() failed");
- }
- csOff();
- }
- else
- {
-
- mraa::Result rv;
- if ((rv = m_i2c->writeReg(reg, val)) != mraa::SUCCESS)
- {
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": I2c.writeReg() failed");
- }
- }
-}
-
-void BMM150::csOn()
-{
- if (m_gpioCS)
- m_gpioCS->write(0);
-}
-
-void BMM150::csOff()
-{
- if (m_gpioCS)
- m_gpioCS->write(1);
-}
-
-uint8_t BMM150::getChipID()
-{
- return readReg(REG_CHIP_ID);
-}
-
-void BMM150::getMagnetometer(float *x, float *y, float *z)
-{
- if (x)
- *x = m_magX;
-
- if (y)
- *y = m_magY;
-
- if (z)
- *z = m_magZ;
-}
-
-float *BMM150::getMagnetometer()
-{
- static float v[3];
-
- getMagnetometer(&v[0], &v[1], &v[2]);
- return v;
-}
-
-void BMM150::reset()
-{
- // mask off reserved bits
- uint8_t reg = readReg(REG_POWER_CTRL) & ~_POWER_CTRL_RESERVED_BITS;
-
- reg |= POWER_CTRL_SOFT_RESET0 | POWER_CTRL_SOFT_RESET1;
-
- writeReg(REG_POWER_CTRL, reg);
- sleep(1);
- // device will return to SLEEP mode...
-}
-
-void BMM150::setOutputDataRate(DATA_RATE_T odr)
-{
- uint8_t reg = readReg(REG_OPMODE);
-
- reg &= ~(_OPMODE_DATA_RATE_MASK << _OPMODE_DATA_RATE_SHIFT);
- reg |= (odr << _OPMODE_DATA_RATE_SHIFT);
-
- writeReg(REG_OPMODE, reg);
-}
-
-void BMM150::setPowerBit(bool power)
-{
- // mask off reserved bits
- uint8_t reg = readReg(REG_POWER_CTRL) & ~_POWER_CTRL_RESERVED_BITS;
-
- if (power)
- reg |= POWER_CTRL_POWER_CTRL_BIT;
- else
- reg &= ~POWER_CTRL_POWER_CTRL_BIT;
-
- writeReg(REG_POWER_CTRL, reg);
-}
-
-void BMM150::setOpmode(OPERATION_MODE_T opmode)
-{
- uint8_t reg = readReg(REG_OPMODE);
-
- reg &= ~(_OPMODE_OPERATION_MODE_MASK << _OPMODE_OPERATION_MODE_SHIFT);
- reg |= (opmode << _OPMODE_OPERATION_MODE_SHIFT);
-
- writeReg(REG_OPMODE, reg);
- m_opmode = opmode;
-}
-
-BMM150::OPERATION_MODE_T BMM150::getOpmode()
-{
- uint8_t reg = readReg(REG_OPMODE);
-
- reg &= (_OPMODE_OPERATION_MODE_MASK << _OPMODE_OPERATION_MODE_SHIFT);
- reg >>= _OPMODE_OPERATION_MODE_SHIFT;
-
- return static_cast<OPERATION_MODE_T>(reg);
-}
-
-uint8_t BMM150::getInterruptEnable()
-{
- return readReg(REG_INT_EN);
-}
-
-void BMM150::setInterruptEnable(uint8_t bits)
-{
- writeReg(REG_INT_EN, bits);
-}
-
-uint8_t BMM150::getInterruptConfig()
-{
- return readReg(REG_INT_CONFIG);
-}
-
-void BMM150::setInterruptConfig(uint8_t bits)
-{
- writeReg(REG_INT_CONFIG, bits);
-}
-
-uint8_t BMM150::getInterruptStatus()
-{
- return readReg(REG_INT_STATUS);
-}
-
-void BMM150::readTrimData()
-{
- int bufLen = 10;
- uint8_t calibData[bufLen];
-
- // 2 bytes first
- readRegs(REG_TRIM_DIG_X1, calibData, 2);
-
- m_dig_x1 = int8_t(calibData[0]);
- m_dig_y1 = int8_t(calibData[1]);
-
- // next block of 4 bytes
- readRegs(REG_TRIM_DIG_Z4_LSB, calibData, 4);
-
- m_dig_z4 = int16_t((calibData[1] << 8) | calibData[0]);
- m_dig_x2 = int8_t(calibData[2]);
- m_dig_y2 = int8_t(calibData[3]);
-
- // final block of 10 bytes
- readRegs(REG_TRIM_DIG_Z2_LSB, calibData, 10);
-
- m_dig_z2 = int16_t((calibData[1] << 8) | calibData[0]);
- m_dig_z1 = uint16_t((calibData[3] << 8) | calibData[2]);
- m_dig_xyz1 = uint16_t((calibData[5] << 8) | calibData[4]);
- m_dig_z3 = int16_t((calibData[7] << 8) | calibData[6]);
- m_dig_xy2 = int8_t(calibData[8]);
- m_dig_xy1 = calibData[9];
-}
-
-void BMM150::setRepetitionsXY(uint8_t reps)
-{
- writeReg(REG_REP_XY, reps);
-}
-
-void BMM150::setRepetitionsZ(uint8_t reps)
-{
- writeReg(REG_REP_Z, reps);
-}
-
-void BMM150::setPresetMode(USAGE_PRESETS_T usage)
-{
- // these recommended presets come from the datasheet, Table 3,
- // Section 4.2
- switch (usage)
- {
- case USAGE_LOW_POWER:
- setRepetitionsXY(3);
- setRepetitionsZ(3);
- setOutputDataRate(DATA_RATE_10HZ);
-
- break;
-
- case USAGE_REGULAR:
- setRepetitionsXY(9);
- setRepetitionsZ(15);
- setOutputDataRate(DATA_RATE_10HZ);
-
- break;
-
- case USAGE_ENHANCED_REGULAR:
- setRepetitionsXY(15);
- setRepetitionsZ(27);
- setOutputDataRate(DATA_RATE_10HZ);
-
- break;
-
- case USAGE_HIGH_ACCURACY:
- setRepetitionsXY(47);
- setRepetitionsZ(83);
- setOutputDataRate(DATA_RATE_20HZ);
-
- break;
-
- default:
- throw std::out_of_range(string(__FUNCTION__) +
- ": Invalid usage enum passed");
- }
-}
-
-#if defined(SWIGJAVA) || (JAVACALLBACK)
-void BMM150::installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- jobject runnable)
-{
- // delete any existing ISR and GPIO context
- uninstallISR(intr);
-
- // create gpio context
- getPin(intr) = new mraa::Gpio(gpio);
-
- getPin(intr)->dir(mraa::DIR_IN);
- getPin(intr)->isr(level, runnable);
-}
-#else
-void BMM150::installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- void (*isr)(void *), void *arg)
-{
- // delete any existing ISR and GPIO context
- uninstallISR(intr);
-
- // create gpio context
- getPin(intr) = new mraa::Gpio(gpio);
-
- getPin(intr)->dir(mraa::DIR_IN);
- getPin(intr)->isr(level, isr, arg);
-}
-#endif
-
-void BMM150::uninstallISR(INTERRUPT_PINS_T intr)
-{
- if (getPin(intr))
- {
- getPin(intr)->isrExit();
- delete getPin(intr);
-
- getPin(intr) = 0;
- }
-}
-
-mraa::Gpio*& BMM150::getPin(INTERRUPT_PINS_T intr)
-{
- switch(intr)
- {
- case INTERRUPT_INT:
- return m_gpioIntr;
- break;
-
- case INTERRUPT_DR:
- return m_gpioDR;
- break;
-
- default:
- throw std::out_of_range(string(__FUNCTION__) +
- ": Invalid interrupt enum passed");
- }
-}
-
-// Bosch compensation functions
-
-float BMM150::bmm050_compensate_X_float(int16_t mag_data_x, uint16_t data_r)
-{
- float inter_retval = 0;
-
- if (mag_data_x != -4096 /* no overflow */
- ) {
- if ((data_r != 0)
- && (m_dig_xyz1 != 0)) {
- inter_retval = ((((float)m_dig_xyz1)
- * 16384.0 / data_r) - 16384.0);
- } else {
- inter_retval = 0.0f;
- return inter_retval;
- }
- inter_retval = (((mag_data_x * ((((((float)m_dig_xy2) *
- (inter_retval*inter_retval /
- 268435456.0) +
- inter_retval * ((float)m_dig_xy1)
- / 16384.0)) + 256.0) *
- (((float)m_dig_x2) + 160.0)))
- / 8192.0)
- + (((float)m_dig_x1) *
- 8.0)) / 16.0;
- } else {
- inter_retval = 0.0f;
- }
- return inter_retval;
-}
-
-float BMM150::bmm050_compensate_Y_float(int16_t mag_data_y, uint16_t data_r)
-{
- float inter_retval = 0;
-
- if (mag_data_y != -4096 /* no overflow */
- ) {
- if ((data_r != 0)
- && (m_dig_xyz1 != 0)) {
- inter_retval = ((((float)m_dig_xyz1)
- * 16384.0
- /data_r) - 16384.0);
- } else {
- inter_retval = 0.0f;
- return inter_retval;
- }
- inter_retval = (((mag_data_y * ((((((float)m_dig_xy2) *
- (inter_retval*inter_retval
- / 268435456.0) +
- inter_retval * ((float)m_dig_xy1)
- / 16384.0)) +
- 256.0) *
- (((float)m_dig_y2) + 160.0)))
- / 8192.0) +
- (((float)m_dig_y1) * 8.0))
- / 16.0;
- } else {
- /* overflow, set output to 0.0f */
- inter_retval = 0.0f;
- }
- return inter_retval;
-}
-
-float BMM150::bmm050_compensate_Z_float(int16_t mag_data_z, uint16_t data_r)
-{
- float inter_retval = 0;
- /* no overflow */
- if (mag_data_z != -16384) {
- if ((m_dig_z2 != 0)
- && (m_dig_z1 != 0)
- && (m_dig_xyz1 != 0)
- && (data_r != 0)) {
- inter_retval = ((((((float)mag_data_z)-
- ((float)m_dig_z4)) * 131072.0)-
- (((float)m_dig_z3)*(((float)data_r)
- -((float)m_dig_xyz1))))
- /((((float)m_dig_z2)+
- ((float)m_dig_z1)*((float)data_r) /
- 32768.0) * 4.0)) / 16.0;
- }
- } else {
- /* overflow, set output to 0.0f */
- inter_retval = 0.0f;
- }
- return inter_retval;
-}
diff --git a/peripheral/libupm/src/bmx055/bmm150.hpp b/peripheral/libupm/src/bmx055/bmm150.hpp
deleted file mode 100644
index ab20e8c..0000000
--- a/peripheral/libupm/src/bmx055/bmm150.hpp
+++ /dev/null
@@ -1,614 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <mraa/i2c.hpp>
-#include <mraa/spi.hpp>
-#include <mraa/gpio.hpp>
-
-#define BMM150_I2C_BUS 0
-#define BMM150_SPI_BUS 0
-#define BMM150_DEFAULT_ADDR 0x10
-
-
-namespace upm {
-
- /**
- * @library bmx050
- * @sensor bmm150
- * @comname BMM150 3-Axis Geomagnetic Sensor
- * @altname bmm050
- * @type compass
- * @man bosch
- * @con i2c spi gpio
- *
- * @brief API for the BMM150 3-Axis Geomagnetic Sensor
- *
- * The BMM150 is a standalone geomagnetic sensor for consumer market
- * applications. It allows measurements of the magnetic field in
- * three perpendicular axes. Based on Bosch’s proprietary FlipCore
- * technology, performance and features of BMM150 are carefully
- * tuned and perfectly match the demanding requirements of all
- * 3-axis mobile applications such as electronic compass, navigation
- * or augmented reality.
- *
- * An evaluation circuitry (ASIC) converts the output of the
- * geomagnetic sensor to digital results which can be read out over
- * the industry standard digital interfaces (SPI and I2C).
- *
- * Not all functionality of this chip has been implemented in this
- * driver, however all the pieces are present to add any desired
- * functionality. This driver supports both I2C (default) and SPI
- * operation.
- *
- * This device requires 3.3v operation.
- *
- * @snippet bmm150.cxx Interesting
- */
-
- class BMM150 {
- public:
-
- // NOTE: Reserved registers must not be written into. Reading
- // from them may return indeterminate values. Registers
- // containing reserved bitfields must be written as 0. Reading
- // reserved bitfields may return indeterminate values.
-
- /**
- * BMM150 registers
- */
- typedef enum : uint8_t {
- REG_CHIP_ID = 0x40,
-
- // 0x41 reserved
-
- REG_MAG_X_LSB = 0x42,
- REG_MAG_X_MSB = 0x43,
- REG_MAG_Y_LSB = 0x44,
- REG_MAG_Y_MSB = 0x45,
- REG_MAG_Z_LSB = 0x46,
- REG_MAG_Z_MSB = 0x47,
-
- REG_RHALL_LSB = 0x48,
- REG_RHALL_MSB = 0x49,
-
- REG_INT_STATUS = 0x4a,
-
- REG_POWER_CTRL = 0x4b,
-
- REG_OPMODE = 0x4c,
-
- REG_INT_EN = 0x4d,
- REG_INT_CONFIG = 0x4e,
-
- REG_LOW_THRES = 0x4f,
- REG_HIGH_THRES = 0x50,
-
- REG_REP_XY = 0x51,
- REG_REP_Z = 0x52,
-
- // 0x53-0x71 reserved (mostly)
-
- // TRIM registers from Bosch BMM050 driver
- REG_TRIM_DIG_X1 = 0x5d,
- REG_TRIM_DIG_Y1 = 0x5e,
-
- REG_TRIM_DIG_Z4_LSB = 0x62,
- REG_TRIM_DIG_Z4_MSB = 0x63,
- REG_TRIM_DIG_X2 = 0x64,
- REG_TRIM_DIG_Y2 = 0x65,
-
- REG_TRIM_DIG_Z2_LSB = 0x68,
- REG_TRIM_DIG_Z2_MSB = 0x69,
- REG_TRIM_DIG_Z1_LSB = 0x6a,
- REG_TRIM_DIG_Z1_MSB = 0x6b,
- REG_TRIM_DIG_XYZ1_LSB = 0x6c,
- REG_TRIM_DIG_XYZ1_MSB = 0x6d,
- REG_TRIM_DIG_Z3_LSB = 0x6e,
- REG_TRIM_DIG_Z3_MSB = 0x6f,
- REG_TRIM_DIG_XY2 = 0x70,
- REG_TRIM_DIG_XY1 = 0x71
-
- } BMM150_REGS_T;
-
- /**
- * REG_MAG_XY_LSB bits (for X and Y mag data LSB's only)
- */
- typedef enum {
- _MAG_XY_LSB_RESERVED_BITS = 0x02 | 0x04,
-
- MAG_XY_LSB_SELFTEST_XY = 0x01,
-
- MAG_XY_LSB_LSB0 = 0x08,
- MAG_XY_LSB_LSB1 = 0x10,
- MAG_XY_LSB_LSB2 = 0x20,
- MAG_XY_LSB_LSB3 = 0x40,
- MAG_XY_LSB_LSB4 = 0x80,
- _MAG_XY_LSB_LSB_MASK = 31,
- _MAG_XY_LSB_LSB_SHIFT = 3
- } MAG_XY_LSB_BITS_T;
-
- /**
- * REG_MAG_Z_LSB bits (for Z LSB only)
- */
- typedef enum {
- MAG_Z_LSB_SELFTEST_Z = 0x01,
-
- MAG_Z_LSB_LSB0 = 0x02,
- MAG_Z_LSB_LSB1 = 0x04,
- MAG_Z_LSB_LSB2 = 0x08,
- MAG_Z_LSB_LSB3 = 0x10,
- MAG_Z_LSB_LSB4 = 0x20,
- MAG_Z_LSB_LSB5 = 0x40,
- MAG_Z_LSB_LSB6 = 0x80,
- _MAG_Z_LSB_LSB_MASK = 127,
- _MAG_Z_LSB_LSB_SHIFT = 1
- } MAG_Z_LSB_BITS_T;
-
- /**
- * REG_MAG_RHALL_LSB bits (for RHALL LSB only)
- */
- typedef enum {
- _MAG_RHALL_LSB_RESERVED_BITS = 0x02,
-
- MAG_RHALL_LSB_DATA_READY_STATUS = 0x01,
-
- MAG_RHALL_LSB_LSB0 = 0x04,
- MAG_RHALL_LSB_LSB1 = 0x08,
- MAG_RHALL_LSB_LSB2 = 0x10,
- MAG_RHALL_LSB_LSB3 = 0x20,
- MAG_RHALL_LSB_LSB4 = 0x40,
- MAG_RHALL_LSB_LSB5 = 0x80,
- _MAG_RHALL_LSB_LSB_MASK = 63,
- _MAG_RHALL_LSB_LSB_SHIFT = 2
- } MAG_RHALL_LSB_BITS_T;
-
- /**
- * REG_INT_STATUS bits
- */
- typedef enum {
- INT_STATUS_LOW_INT_X = 0x01,
- INT_STATUS_LOW_INT_Y = 0x02,
- INT_STATUS_LOW_INT_Z = 0x04,
- INT_STATUS_HIGH_INT_X = 0x08,
- INT_STATUS_HIGH_INT_Y = 0x10,
- INT_STATUS_HIGH_INT_Z = 0x20,
- INT_STATUS_OVERFLOW = 0x40,
- INT_STATUS_DATA_OVERRUN = 0x80
- } INT_STATUS_BITS_T;
-
- /**
- * REG_POWER_CTRL bits
- */
- typedef enum {
- _POWER_CTRL_RESERVED_BITS = 0x40 | 0x20 | 0x10 | 0x08,
-
- POWER_CTRL_POWER_CTRL_BIT = 0x01,
- POWER_CTRL_SOFT_RESET0 = 0x02,
- POWER_CTRL_SPI3EN = 0x04, // not supported
-
- POWER_CTRL_SOFT_RESET1 = 0x80
- } POWER_CTRL_BITS_T;
-
- /**
- * REG_OPMODE bits
- */
- typedef enum {
- OPMODE_SELFTTEST = 0x01,
-
- OPMODE_OPERATION_MODE0 = 0x02,
- OPMODE_OPERATION_MODE1 = 0x04,
- _OPMODE_OPERATION_MODE_MASK = 3,
- _OPMODE_OPERATION_MODE_SHIFT = 1,
-
- OPMODE_DATA_RATE0 = 0x08,
- OPMODE_DATA_RATE1 = 0x10,
- OPMODE_DATA_RATE2 = 0x20,
- _OPMODE_DATA_RATE_MASK = 7,
- _OPMODE_DATA_RATE_SHIFT = 3,
-
- OPMODE_ADV_SELFTEST0 = 0x40,
- OPMODE_ADV_SELFTEST1 = 0x80,
- _OPMODE_ADV_SELFTEST_MASK = 3,
- _OPMODE_ADV_SELFTEST_SHIFT = 6
- } OPMODE_BITS_T;
-
- /**
- * OPMODE_OPERATION_MODE values
- */
- typedef enum {
- OPERATION_MODE_NORMAL = 0,
- OPERATION_MODE_FORCED = 1,
- OPERATION_MODE_SLEEP = 3
- } OPERATION_MODE_T;
-
- /**
- * OPMODE_DATA_RATE values
- */
- typedef enum {
- DATA_RATE_10HZ = 0,
- DATA_RATE_2HZ = 1,
- DATA_RATE_6HZ = 2,
- DATA_RATE_8HZ = 3,
- DATA_RATE_15HZ = 4,
- DATA_RATE_20HZ = 5,
- DATA_RATE_25HZ = 6,
- DATA_RATE_30HZ = 7
- } DATA_RATE_T;
-
- /**
- * REG_INT_EN bits
- */
- typedef enum {
- INT_EN_LOW_INT_X_EN = 0x01,
- INT_EN_LOW_INT_Y_EN = 0x02,
- INT_EN_LOW_INT_Z_EN = 0x04,
- INT_EN_HIGH_INT_X_EN = 0x08,
- INT_EN_HIGH_INT_Y_EN = 0x10,
- INT_EN_HIGH_INT_Z_EN = 0x20,
- INT_EN_OVERFLOW_INT_EN = 0x40,
- INT_EN_DATA_OVERRUN_INT_EN = 0x80
- } INT_EN_T;
-
- /**
- * REG_INT_CONFIG bits
- */
- typedef enum {
- INT_CONFIG_INT_POLARITY = 0x01,
- INT_CONFIG_INT_LATCH = 0x02,
- INT_CONFIG_DR_POLARITY = 0x04,
- INT_CONFIG_CHANNEL_X = 0x08,
- INT_CONFIG_CHANNEL_Y = 0x10,
- INT_CONFIG_CHANNEL_Z = 0x20,
- INT_CONFIG_INT_PIN_EN = 0x40,
- INT_CONFIG_DR_PIN_EN = 0x80
- } INT_CONFIG_T;
-
- /**
- * Interrupt selection for installISR() and uninstallISR()
- */
- typedef enum {
- INTERRUPT_INT,
- INTERRUPT_DR
- } INTERRUPT_PINS_T;
-
- /**
- * Bosch recommended usage preset modes
- */
- typedef enum {
- USAGE_LOW_POWER,
- USAGE_REGULAR,
- USAGE_ENHANCED_REGULAR,
- USAGE_HIGH_ACCURACY
- } USAGE_PRESETS_T;
-
- /**
- * BMM150 constructor.
- *
- * This device can support both I2C and SPI. For SPI, set the addr
- * to -1, and specify a positive integer representing the Chip
- * Select (CS) pin for the cs argument. If you are using a
- * hardware CS pin (like edison with arduino breakout), then you
- * can connect the proper pin to the hardware CS pin on your MCU
- * and supply -1 for cs. The default operating mode is I2C.
- *
- * @param bus I2C or SPI bus to use.
- * @param addr The address for this device. -1 for SPI.
- * @param cs The gpio pin to use for the SPI Chip Select. -1 for
- * I2C or for SPI with a hardware controlled pin.
- * @param theChipID The chip ID to use for validation
- */
- BMM150(int bus=BMM150_I2C_BUS, uint8_t addr=BMM150_DEFAULT_ADDR,
- int cs=-1);
-
- /**
- * BMM150 Destructor.
- */
- ~BMM150();
-
- /**
- * Update the internal stored values from sensor data.
- */
- void update();
-
- /**
- * Return the chip ID.
- *
- * @return The chip ID (BMM150_CHIPID).
- */
- uint8_t getChipID();
-
- /**
- * Return magnetometer data in micro-Teslas (uT). update() must
- * have been called prior to calling this method.
- *
- * @param x Pointer to a floating point value that will have the
- * current x component placed into it.
- * @param y Pointer to a floating point value that will have the
- * current y component placed into it.
- * @param z Pointer to a floating point value that will have the
- * current z component placed into it.
- */
- void getMagnetometer(float *x, float *y, float *z);
-
- /**
- * Return magnetometer data in micro-Teslas (uT) in the form of a
- * floating point array. The pointer returned by this function is
- * statically allocated and will be rewritten on each call.
- * update() must have been called prior to calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getMagnetometer();
-
- /**
- * Initialize the device and start operation. This function is
- * called from the constructor so will not typically need to be
- * called by a user unless the device is reset. This method will
- * call setPresetMode() with the passed parameter.
- *
- * @param usage One of the USAGE_PRESETS_T values. The default is
- * USAGE_HIGH_ACCURACY.
- */
- void init(USAGE_PRESETS_T usage=USAGE_HIGH_ACCURACY);
-
- /**
- * Set one of the Bosch recommended preset modes. These modes
- * configure the sensor for varying use cases.
- *
- * @param usage One of the USAGE_PRESETS_T values. The default is
- * USAGE_HIGH_ACCURACY.
- */
- void setPresetMode(USAGE_PRESETS_T usage);
-
- /**
- * Perform a device soft-reset. The device will be placed in
- * SUSPEND mode afterward with all configured setting lost, so
- * some re-initialization will be required to get data from the
- * sensor. Calling init() will get everything running again.
- */
- void reset();
-
- /**
- * Set the magnetometer Output Data Rate. See the datasheet for
- * details.
- *
- * @param odr One of the DATA_RATE_T values.
- */
- void setOutputDataRate(DATA_RATE_T odr);
-
- /**
- * Set or clear the Power bit. When the power bit is cleared, the
- * device enters a deep suspend mode where only the REG_POWER_CTRL
- * register can be accessed. This bit needs to be enabled for the
- * device to operate. See the datasheet for details. The
- * constructor enables this by default. After a deep suspend mode
- * has been entered, all configured data is lost and the device
- * must be reconfigured (as via init()).
- *
- * @param power true to enable the bit, false otherwise.
- */
- void setPowerBit(bool power);
-
- /**
- * Set the operating mode of the device. See the datasheet for
- * details.
- *
- * @param power One of the POWER_MODE_T values.
- */
- void setOpmode(OPERATION_MODE_T opmode);
-
- /**
- * Get the current operating mode of the device. See the datasheet for
- * details. The power bit must be one for this method to succeed.
- *
- * @return One of the OPERATION_MODE_T values.
- */
- OPERATION_MODE_T getOpmode();
-
- /**
- * Return the Interrupt Enables register. This resgister
- * allows you to enable various interrupt conditions. See the
- * datasheet for details.
- *
- * @return A bitmask of INT_EN_BITS_T bits.
- */
- uint8_t getInterruptEnable();
-
- /**
- * Set the Interrupt Enables register. See the datasheet for
- * details.
- *
- * @param bits A bitmask of INT_EN_BITS_T bits.
- */
- void setInterruptEnable(uint8_t bits);
-
- /**
- * Return the Interrupt Config register. This register allows
- * determining the electrical characteristics of the 2 interrupt
- * pins (open-drain/push-pull and level/edge triggering) as well
- * as other options. See the datasheet for details.
- *
- * @return A bitmask of INT_CONFIG_BITS_T bits.
- */
- uint8_t getInterruptConfig();
-
- /**
- * Set the Interrupt Config register. This register
- * allows determining the electrical characteristics of the 2
- * interrupt pins (open-drain/push-pull and level/edge
- * triggering). See the datasheet for details.
- *
- * @param bits A bitmask of INT_CONFIG_BITS_T bits.
- */
- void setInterruptConfig(uint8_t bits);
-
- /**
- * Return the interrupt status register. This register
- * indicates which interrupts have been triggered. See the
- * datasheet for details.
- *
- * @return a bitmask of INT_STATUS_BITS_T bits.
- */
- uint8_t getInterruptStatus();
-
- /**
- * Set the repetion counter for the X and Y axes. This allows the
- * device to average a number of measurements for a more stable
- * output. See the datasheet for details.
- *
- * @param reps A coefficient for specifying the number of
- * repititions to perform. (1 + 2(reps))
- */
- void setRepetitionsXY(uint8_t reps);
-
- /**
- * Set the repetion counter for the Z axis. This allows the
- * device to average a number of measurements for a more stable
- * output. See the datasheet for details.
- *
- * @param reps A coefficient for specifying the number of
- * repititions to perform. (1 + (reps))
- */
- void setRepetitionsZ(uint8_t reps);
-
-#if defined(SWIGJAVA) || defined(JAVACALLBACK)
- void installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- jobject runnable);
-#else
- /**
- * install an interrupt handler.
- *
- * @param intr one of the INTERRUPT_PINS_T values specifying which
- * interrupt pin you are installing.
- * @param gpio gpio pin to use as interrupt pin
- * @param level the interrupt trigger level (one of mraa::Edge
- * values). Make sure that you have configured the interrupt pin
- * properly for whatever level you choose.
- * @param isr the interrupt handler, accepting a void * argument
- * @param arg the argument to pass the the interrupt handler
- */
- void installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- void (*isr)(void *), void *arg);
-#endif
-
- /**
- * uninstall a previously installed interrupt handler
- *
- * @param intr one of the INTERRUPT_PINS_T values specifying which
- * interrupt pin you are removing.
- */
- void uninstallISR(INTERRUPT_PINS_T intr);
-
- /**
- * Read a register.
- *
- * @param reg The register to read.
- * @return The value of the register.
- */
- uint8_t readReg(uint8_t reg);
-
- /**
- * Read contiguous registers into a buffer.
- *
- * @param buffer The buffer to store the results.
- * @param len The number of registers to read.
- * @return The number of bytes read.
- */
- int readRegs(uint8_t reg, uint8_t *buffer, int len);
-
- /**
- * Write to a register
- *
- * @param reg The register to write to.
- * @param val The value to write.
- */
- void writeReg(uint8_t reg, uint8_t val);
-
- protected:
- mraa::I2c *m_i2c;
- mraa::Spi *m_spi;
-
- // spi chip select
- mraa::Gpio *m_gpioCS;
-
- mraa::Gpio *m_gpioIntr;
- mraa::Gpio *m_gpioDR;
-
- uint8_t m_addr;
-
- OPERATION_MODE_T m_opmode;
-
- // SPI chip select
- void csOn();
- void csOff();
-
- // acc data
- float m_magX;
- float m_magY;
- float m_magZ;
-
- // hall resistance
- uint16_t m_hall;
-
- // trimming data
- int8_t m_dig_x1;
- int8_t m_dig_y1;
-
- int16_t m_dig_z4;
- int8_t m_dig_x2;
- int8_t m_dig_y2;
-
- int16_t m_dig_z2;
- uint16_t m_dig_z1;
- uint16_t m_dig_xyz1;
- int16_t m_dig_z3;
- int8_t m_dig_xy2;
- uint8_t m_dig_xy1;
-
- // read trim data for compensation
- void readTrimData();
-
- private:
- bool m_isSPI;
- // use the FIFO by default?
- bool m_useFIFO;
-
- // return a reference to a gpio pin pointer depending on intr
- mraa::Gpio*& getPin(INTERRUPT_PINS_T intr);
-
- // Adding a private function definition for java bindings
-#if defined(SWIGJAVA) || defined(JAVACALLBACK)
- void installISR(INTERRUPT_PINS_T intr, int gpio, mraa::Edge level,
- void (*isr)(void *), void *arg);
-#endif
-
- // bosch compensation algorithms
- float bmm050_compensate_X_float(int16_t mag_data_x, uint16_t data_r);
- float bmm050_compensate_Y_float(int16_t mag_data_y, uint16_t data_r);
- float bmm050_compensate_Z_float(int16_t mag_data_z, uint16_t data_r);
- };
-}
diff --git a/peripheral/libupm/src/bmx055/bmx055.cxx b/peripheral/libupm/src/bmx055/bmx055.cxx
deleted file mode 100644
index 9d36a5b..0000000
--- a/peripheral/libupm/src/bmx055/bmx055.cxx
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-
-#include "bmx055.hpp"
-
-using namespace upm;
-using namespace std;
-
-BMX055::BMX055(int accelBus, uint8_t accelAddr, int accelCS,
- int gyroBus, uint8_t gyroAddr, int gyroCS,
- int magBus, uint8_t magAddr, int magCS) :
- m_accel(0), m_gyro(0), m_mag(0)
-{
- // if -1 is supplied as a bus for any of these, we will not
- // instantiate them
-
- if (accelBus >= 0)
- m_accel = new BMA250E(accelBus, accelAddr, accelCS);
-
- if (gyroBus >= 0)
- m_gyro = new BMG160(gyroBus, gyroAddr, gyroCS);
-
- if (magBus >= 0)
- m_mag = new BMM150(magBus, magAddr, magCS);
-
- // now initialize them...
- if (m_accel)
- m_accel->init();
-
- if (m_gyro)
- m_gyro->init();
-
- if (m_mag)
- m_mag->init();
-}
-
-BMX055::~BMX055()
-{
- if (m_accel)
- delete m_accel;
-
- if (m_gyro)
- delete m_gyro;
-
- if (m_mag)
- delete m_mag;
-}
-
-void BMX055::initAccelerometer(BMA250E::POWER_MODE_T pwr,
- BMA250E::RANGE_T range,
- BMA250E::BW_T bw)
-{
- if (m_accel)
- m_accel->init(pwr, range, bw);
-}
-
-void BMX055::initGyroscope(BMG160::POWER_MODE_T pwr,
- BMG160::RANGE_T range,
- BMG160::BW_T bw)
-{
- if (m_gyro)
- m_gyro->init(pwr, range, bw);
-}
-
-void BMX055::initMagnetometer(BMM150::USAGE_PRESETS_T usage)
-{
- if (m_mag)
- m_mag->init(usage);
-}
-
-void BMX055::update()
-{
- if (m_accel)
- m_accel->update();
-
- if (m_gyro)
- m_gyro->update();
-
- if (m_mag)
- m_mag->update();
-}
-
-void BMX055::getAccelerometer(float *x, float *y, float *z)
-{
- if (m_accel)
- m_accel->getAccelerometer(x, y, z);
-}
-
-float *BMX055::getAccelerometer()
-{
- if (m_accel)
- return m_accel->getAccelerometer();
- else
- {
- static float v[3] = {0.0f, 0.0f, 0.0f};
- return v;
- }
-}
-
-void BMX055::getGyroscope(float *x, float *y, float *z)
-{
- if (m_gyro)
- m_gyro->getGyroscope(x, y, z);
-}
-
-float *BMX055::getGyroscope()
-{
- if (m_gyro)
- return m_gyro->getGyroscope();
- else
- {
- static float v[3] = {0.0f, 0.0f, 0.0f};
- return v;
- }
-}
-
-void BMX055::getMagnetometer(float *x, float *y, float *z)
-{
- if (m_mag)
- m_mag->getMagnetometer(x, y, z);
-}
-
-float *BMX055::getMagnetometer()
-{
- if (m_mag)
- return m_mag->getMagnetometer();
- else
- {
- static float v[3] = {0.0f, 0.0f, 0.0f};
- return v;
- }
-}
diff --git a/peripheral/libupm/src/bmx055/bmx055.hpp b/peripheral/libupm/src/bmx055/bmx055.hpp
deleted file mode 100644
index 3f03d60..0000000
--- a/peripheral/libupm/src/bmx055/bmx055.hpp
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-
-#include "bma250e.hpp"
-#include "bmg160.hpp"
-#include "bmm150.hpp"
-
-namespace upm {
-
- /**
- * @brief BMX055 9-axis Sensor Module
- * @defgroup bmx055 libupm-bmx055
- * @ingroup i2c spi accelerometer compass
- */
-
- /**
- * @library bmx055
- * @sensor bmx055
- * @comname BMX055 9-axis Sensor Module
- * @type accelerometer compass
- * @man mouser
- * @con i2c gpio spi
- * @web http://www.mouser.com/ProductDetail/Bosch-Sensortec/0330SB0179/?qs=sGAEpiMZZMsrChSOYEGTCZo8d3KRE6KPUk8gVuWS2Ho%3d
- *
- * @brief API for the BMX055 9-axis Sensor Module
- *
- * The BMX055 is an integrated 9-axis sensor for the detection of
- * movements and rotations and magnetic heading. It comprises the
- * full functionality of a triaxial, low-g acceleration sensor, a
- * triaxial angular rate sensor and a triaxial geomagnetic sensor.
- *
- * The BMX055 senses orientation, tilt, motion, acceleration,
- * rotation, shock, vibration and heading in cell phones, handhelds,
- * computer peripherals, man-machine interfaces, virtual reality
- * features and game controllers.
- *
- * The BMX055 is essentially 3 separate devices in one: the BMA250E
- * Accelerometer, the BMG160 Gyroscope, and the BMM150 Magnetometer.
- * They are completely independant of each other.
- *
- * This driver provides a very simple interface to these 3 devices.
- * If finer control is desired, you should just use the separate
- * BMA25E, BMG160, and BMM150 device classes directly. This driver
- * simply initializes all three devices, and provides a mechanism to
- * read accelerometer, gyroscope and magnetometer data from them.
- *
- * @snippet bmx055.cxx Interesting
- */
-
- class BMX055 {
- public:
- /**
- * BMX055 constructor.
- *
- * This device can support both I2C and SPI. For SPI, set the addr
- * to -1, and specify a positive integer representing the Chip
- * Select (CS) pin for the cs argument. If you are using a
- * hardware CS pin (like edison with arduino breakout), then you
- * can connect the proper pin to the hardware CS pin on your MCU
- * and supply -1 for cs. The default operating mode is I2C.
- *
- * @param accelBus I2C or SPI bus to use. -1 to skip initializing
- * this device.
- * @param accelAddr The address for this device. -1 for SPI.
- * @param accelCS The gpio pin to use for the SPI Chip Select. -1 for
- * I2C or for SPI with a hardware controlled pin.
- * @param gyroBus I2C or SPI bus to use. -1 to skip initializing
- * this device.
- * @param gyroAddr The address for this device. -1 for SPI.
- * @param gyroCS The gpio pin to use for the SPI Chip Select. -1 for
- * I2C or for SPI with a hardware controlled pin.
- * @param magBus I2C or SPI bus to use. -1 to skip initializing
- * this device.
- * @param magAddr The address for this device. -1 for SPI.
- * @param magCS The gpio pin to use for the SPI Chip Select. -1 for
- * I2C or for SPI with a hardware controlled pin.
- */
- BMX055(int accelBus=BMA250E_I2C_BUS,
- uint8_t accelAddr=BMA250E_DEFAULT_ADDR,
- int accelCS=-1,
- int gyroBus=BMG160_I2C_BUS,
- uint8_t gyroAddr=BMG160_DEFAULT_ADDR,
- int gyroCS=-1,
- int magBus=BMM150_I2C_BUS,
- uint8_t magAddr=BMM150_DEFAULT_ADDR,
- int magCS=-1);
-
- /**
- * BMX055 Destructor.
- */
- ~BMX055();
-
- /**
- * Update the internal stored values from sensor data.
- */
- void update();
-
- /**
- * Initialize the accelerometer and start operation. This
- * function is called from the constructor so will not typically
- * need to be called by a user unless the device is reset or you
- * want to change these values.
- *
- * @param pwr One of the BMA250E::POWER_MODE_T values. The default is
- * BMA250E::POWER_MODE_NORMAL.
- * @param range One of the BMA250E::RANGE_T values. The default is
- * BMA250E::RANGE_2G.
- * @param bw One of the filtering BMA250E::BW_T values. The default is
- * BMA250E::BW_250.
- */
- void initAccelerometer(BMA250E::POWER_MODE_T pwr=BMA250E::POWER_MODE_NORMAL,
- BMA250E::RANGE_T range=BMA250E::RANGE_2G,
- BMA250E::BW_T bw=BMA250E::BW_250);
-
- /**
- * Initialize the gyroscope and start operation. This function is
- * called from the constructor so will not typically need to be
- * called by a user unless the device is reset or you want to
- * change these values.
- *
- * @param pwr One of the BMG160::POWER_MODE_T values. The default is
- * BMG160::POWER_MODE_NORMAL.
- * @param range One of the BMG160::RANGE_T values. The default is
- * BMG160::RANGE_250.
- * @param bw One of the filtering BMG160::BW_T values. The default is
- * BMG160::BW_400_47.
- */
- void initGyroscope(BMG160::POWER_MODE_T pwr=BMG160::POWER_MODE_NORMAL,
- BMG160::RANGE_T range=BMG160::RANGE_250,
- BMG160::BW_T bw=BMG160::BW_400_47);
-
- /**
- * Initialize the magnetometer and start operation. This function
- * is called from the constructor so will not typically need to be
- * called by a user unless the device is reset or you want to
- * change these values. This method will call
- * BMM150::setPresetMode() with the passed parameter.
- *
- * @param usage One of the BMM150::USAGE_PRESETS_T values. The default is
- * BMM150::USAGE_HIGH_ACCURACY.
- */
- void initMagnetometer(BMM150::USAGE_PRESETS_T usage=BMM150::USAGE_HIGH_ACCURACY);
-
- /**
- * Return accelerometer data in gravities. update() must have
- * been called prior to calling this method.
- *
- * @param x Pointer to a floating point value that will have the
- * current x component placed into it.
- * @param y Pointer to a floating point value that will have the
- * current y component placed into it.
- * @param z Pointer to a floating point value that will have the
- * current z component placed into it.
- */
- void getAccelerometer(float *x, float *y, float *z);
-
- /**
- * Return accelerometer data in gravities in the form of a
- * floating point array. The pointer returned by this function is
- * statically allocated and will be rewritten on each call.
- * update() must have been called prior to calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getAccelerometer();
-
- /**
- * Return gyroscope data in degrees per second. update() must
- * have been called prior to calling this method.
- *
- * @param x Pointer to a floating point value that will have the
- * current x component placed into it.
- * @param y Pointer to a floating point value that will have the
- * current y component placed into it.
- * @param z Pointer to a floating point value that will have the
- * current z component placed into it.
- */
- void getGyroscope(float *x, float *y, float *z);
-
- /**
- * Return gyroscope data in degrees per second in the form of a
- * floating point array. The pointer returned by this function is
- * statically allocated and will be rewritten on each call.
- * update() must have been called prior to calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getGyroscope();
-
- /**
- * Return magnetometer data in micro-Teslas (uT). update() must
- * have been called prior to calling this method.
- *
- * @param x Pointer to a floating point value that will have the
- * current x component placed into it.
- * @param y Pointer to a floating point value that will have the
- * current y component placed into it.
- * @param z Pointer to a floating point value that will have the
- * current z component placed into it.
- */
- void getMagnetometer(float *x, float *y, float *z);
-
- /**
- * Return magnetometer data in micro-Teslas (uT) in the form of a
- * floating point array. The pointer returned by this function is
- * statically allocated and will be rewritten on each call.
- * update() must have been called prior to calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getMagnetometer();
-
-
- protected:
- BMA250E *m_accel;
- BMG160 *m_gyro;
- BMM150 *m_mag;
-
- private:
- };
-}
diff --git a/peripheral/libupm/src/bmx055/javaupm_bmx055.i b/peripheral/libupm/src/bmx055/javaupm_bmx055.i
deleted file mode 100644
index 4a160cc..0000000
--- a/peripheral/libupm/src/bmx055/javaupm_bmx055.i
+++ /dev/null
@@ -1,77 +0,0 @@
-%module javaupm_bmx055
-%include "../upm.i"
-%include "cpointer.i"
-%include "typemaps.i"
-%include "arrays_java.i";
-%include "../java_buffer.i"
-
-%apply int {mraa::Edge};
-%apply float *INOUT { float *x, float *y, float *z };
-
-%typemap(jni) float* "jfloatArray"
-%typemap(jstype) float* "float[]"
-%typemap(jtype) float* "float[]"
-
-%typemap(javaout) float* {
- return $jnicall;
-}
-
-%typemap(out) float *getAccelerometer {
- $result = JCALL1(NewFloatArray, jenv, 3);
- JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
-}
-
-%typemap(out) float *getGyroscope {
- $result = JCALL1(NewFloatArray, jenv, 3);
- JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
-}
-
-%typemap(out) float *getMagnetometer {
- $result = JCALL1(NewFloatArray, jenv, 3);
- JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
-}
-
-%ignore getAccelerometer(float *, float *, float *);
-%ignore getGyroscope(float *, float *, float *);
-%ignore getMagnetometer(float *, float *, float *);
-
-%include "bma250e.hpp"
-%{
- #include "bma250e.hpp"
-%}
-
-%include "bmg160.hpp"
-%{
- #include "bmg160.hpp"
-%}
-
-%include "bmm150.hpp"
-%{
- #include "bmm150.hpp"
-%}
-
-%include "bmx055.hpp"
-%{
- #include "bmx055.hpp"
-%}
-
-%include "bmc150.hpp"
-%{
- #include "bmc150.hpp"
-%}
-
-%include "bmi055.hpp"
-%{
- #include "bmi055.hpp"
-%}
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_bmx055");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/bmx055/jsupm_bmx055.i b/peripheral/libupm/src/bmx055/jsupm_bmx055.i
deleted file mode 100644
index b59ccd6..0000000
--- a/peripheral/libupm/src/bmx055/jsupm_bmx055.i
+++ /dev/null
@@ -1,37 +0,0 @@
-%module jsupm_bmx055
-%include "../upm.i"
-%include "cpointer.i"
-
-/* Send "int *" and "float *" to JavaScript as intp and floatp */
-%pointer_functions(int, intp);
-%pointer_functions(float, floatp);
-
-%include "bma250e.hpp"
-%{
- #include "bma250e.hpp"
-%}
-
-%include "bmg160.hpp"
-%{
- #include "bmg160.hpp"
-%}
-
-%include "bmm150.hpp"
-%{
- #include "bmm150.hpp"
-%}
-
-%include "bmx055.hpp"
-%{
- #include "bmx055.hpp"
-%}
-
-%include "bmc150.hpp"
-%{
- #include "bmc150.hpp"
-%}
-
-%include "bmi055.hpp"
-%{
- #include "bmi055.hpp"
-%}
diff --git a/peripheral/libupm/src/bmx055/pyupm_bmx055.i b/peripheral/libupm/src/bmx055/pyupm_bmx055.i
deleted file mode 100644
index 8250a66..0000000
--- a/peripheral/libupm/src/bmx055/pyupm_bmx055.i
+++ /dev/null
@@ -1,47 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_bmx055
-%include "../upm.i"
-%include "cpointer.i"
-
-%include "stdint.i"
-
-/* Send "int *" and "float *" to python as intp and floatp */
-%pointer_functions(int, intp);
-%pointer_functions(float, floatp);
-
-%feature("autodoc", "3");
-
-#ifdef DOXYGEN
-%include "bmx055_doc.i"
-#endif
-
-%include "bma250e.hpp"
-%{
- #include "bma250e.hpp"
-%}
-
-%include "bmg160.hpp"
-%{
- #include "bmg160.hpp"
-%}
-
-%include "bmm150.hpp"
-%{
- #include "bmm150.hpp"
-%}
-
-%include "bmx055.hpp"
-%{
- #include "bmx055.hpp"
-%}
-
-%include "bmc150.hpp"
-%{
- #include "bmc150.hpp"
-%}
-
-%include "bmi055.hpp"
-%{
- #include "bmi055.hpp"
-%}
diff --git a/peripheral/libupm/src/bno055/CMakeLists.txt b/peripheral/libupm/src/bno055/CMakeLists.txt
deleted file mode 100644
index b62eac9..0000000
--- a/peripheral/libupm/src/bno055/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set (libname "bno055")
-set (libdescription "Bosch bno055 intelligent orientation sensor 9dof fusion")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/bno055/bno055.cxx b/peripheral/libupm/src/bno055/bno055.cxx
deleted file mode 100644
index f59f271..0000000
--- a/peripheral/libupm/src/bno055/bno055.cxx
+++ /dev/null
@@ -1,809 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-#include <string.h>
-
-#include "bno055.hpp"
-
-using namespace upm;
-using namespace std;
-
-// conversion from fahrenheit to celcius and back
-
-static float f2c(float f)
-{
- return ((f - 32.0) / (9.0 / 5.0));
-}
-
-static float c2f(float c)
-{
- return (c * (9.0 / 5.0) + 32.0);
-}
-
-BNO055::BNO055(int bus, uint8_t addr) :
- m_i2c(bus), m_gpioIntr(0)
-{
-
- m_addr = addr;
-
- clearData();
-
- mraa::Result rv;
- if ( (rv = m_i2c.address(m_addr)) != mraa::SUCCESS)
- {
- throw std::runtime_error(string(__FUNCTION__) +
- ": I2c.address() failed");
- return;
- }
-
- // forcibly set page 0, so we are synced
- setPage(0, true);
-
- // set config mode
- setOperationMode(OPERATION_MODE_CONFIGMODE);
-
- // default to internal clock
- setClockExternal(false);
-
- // we specifically avoid doing a reset so that if the device is
- // already calibrated, it will remain so.
-
- // check the chip id
-
- uint8_t chipID = readReg(REG_CHIP_ID);
- if (chipID != BNO055_CHIPID)
- {
- throw std::runtime_error(string(__FUNCTION__)
- + ": invalid chip ID. Expected "
- + std::to_string(int(BNO055_CHIPID))
- + ", got "
- + std::to_string(int(chipID)));
- return;
- }
-
- // default to temperature C
- setTemperatureUnits(true);
-
- // default to accelerometer temp
- setTemperatureSource(TEMP_SOURCE_ACC);
-
- // set accel units to m/s^2
- setAccelerometerUnits(false);
-
- // set gyro units to degrees
- setGyroscopeUnits(false);
-
- // set Euler units to degrees
- setEulerUnits(false);
-
- // by default, we set the operating mode to the NDOF fusion mode
- setOperationMode(OPERATION_MODE_NDOF);
-}
-
-BNO055::~BNO055()
-{
- uninstallISR();
-}
-
-void BNO055::update()
-{
- setPage(0);
-
- // temperature first, we always store as C
- float tmpF = float((int8_t)readReg(REG_TEMPERATURE));
- if (m_tempIsC)
- m_temperature = tmpF;
- else
- m_temperature = f2c(tmpF * 2.0);
-
- updateFusionData();
- updateNonFusionData();
-}
-
-uint8_t BNO055::readReg(uint8_t reg)
-{
- return m_i2c.readReg(reg);
-}
-
-void BNO055::readRegs(uint8_t reg, uint8_t *buffer, int len)
-{
- m_i2c.readBytesReg(reg, buffer, len);
-}
-
-bool BNO055::writeReg(uint8_t reg, uint8_t val)
-{
- mraa::Result rv;
- if ((rv = m_i2c.writeReg(reg, val)) != mraa::SUCCESS)
- {
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": I2c.writeReg() failed");
- }
-
- return true;
-}
-
-bool BNO055::writeRegs(uint8_t reg, uint8_t *buffer, int len)
-{
- uint8_t buf[len + 1];
-
- buf[0] = reg;
- for (int i=0; i<len; i++)
- buf[i+1] = buffer[i];
-
- mraa::Result rv;
- if ((rv = m_i2c.write(buf, len+1)) != mraa::SUCCESS)
- {
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": I2c.write() failed");
- }
-
- return true;
-}
-
-uint8_t BNO055::getChipID()
-{
- setPage(0);
- return readReg(REG_CHIP_ID);
-}
-
-uint8_t BNO055::getACCID()
-{
- setPage(0);
- return readReg(REG_ACC_ID);
-}
-
-uint8_t BNO055::getMAGID()
-{
- setPage(0);
- return readReg(REG_MAG_ID);
-}
-
-uint8_t BNO055::getGYRID()
-{
- setPage(0);
- return readReg(REG_GYR_ID);
-}
-
-uint16_t BNO055::getSWRevID()
-{
- setPage(0);
-
- uint16_t vers = uint16_t( readReg(REG_SW_REV_ID_LSB) |
- (readReg(REG_SW_REV_ID_MSB) << 8) );
-
- return vers;
-}
-
-uint8_t BNO055::getBootLoaderID()
-{
- setPage(0);
- return readReg(REG_BL_REV_ID);
-}
-
-void BNO055::setPage(uint8_t page, bool force)
-{
- // page can only be 0 or 1
- if (!(page == 0 || page == 1))
- throw std::out_of_range(string(__FUNCTION__) +
- ": page can only be 0 or 1");
-
- if (force || page != m_currentPage)
- writeReg(REG_PAGE_ID, page);
-
- m_currentPage = page;
-}
-
-void BNO055::setClockExternal(bool extClock)
-{
- setPage(0);
-
- // first we need to be in config mode
- OPERATION_MODES_T currentMode = m_currentMode;
- setOperationMode(OPERATION_MODE_CONFIGMODE);
-
- uint8_t reg = readReg(REG_SYS_TRIGGER);
-
- if (extClock)
- reg |= SYS_TRIGGER_CLK_SEL;
- else
- reg &= ~SYS_TRIGGER_CLK_SEL;
-
- writeReg(REG_SYS_TRIGGER, reg);
-
- // now reset our operating mode
- setOperationMode(currentMode);
-}
-
-void BNO055::setTemperatureSource(TEMP_SOURCES_T src)
-{
- setPage(0);
- writeReg(REG_TEMP_SOURCE, src);
-}
-
-void BNO055::setTemperatureUnits(bool celcius)
-{
- setPage(0);
-
- uint8_t reg = readReg(REG_UNIT_SEL);
-
- if (celcius)
- reg &= ~UNIT_SEL_TEMP_UNIT;
- else
- reg |= UNIT_SEL_TEMP_UNIT;
-
- writeReg(REG_UNIT_SEL, reg);
-
- m_tempIsC = celcius;
-}
-
-void BNO055::setAccelerometerUnits(bool mg)
-{
- setPage(0);
-
- uint8_t reg = readReg(REG_UNIT_SEL);
-
- if (mg)
- {
- reg |= UNIT_SEL_ACC_UNIT;
- m_accUnitScale = 1.0;
- }
- else
- {
- reg &= ~UNIT_SEL_ACC_UNIT;
- m_accUnitScale = 100.0;
- }
-
- writeReg(REG_UNIT_SEL, reg);
-}
-
-void BNO055::setGyroscopeUnits(bool radians)
-{
- setPage(0);
-
- uint8_t reg = readReg(REG_UNIT_SEL);
-
- if (radians)
- {
- reg |= UNIT_SEL_GYR_UNIT;
- m_gyrUnitScale = 900.0;
- }
- else
- {
- reg &= ~UNIT_SEL_GYR_UNIT;
- m_gyrUnitScale = 16.0;
- }
-
- writeReg(REG_UNIT_SEL, reg);
-}
-
-void BNO055::setEulerUnits(bool radians)
-{
- setPage(0);
-
- uint8_t reg = readReg(REG_UNIT_SEL);
-
- if (radians)
- {
- reg |= UNIT_SEL_EUL_UNIT;
- m_eulUnitScale = 900.0;
- }
- else
- {
- reg &= ~UNIT_SEL_EUL_UNIT;
- m_eulUnitScale = 16.0;
- }
-
- writeReg(REG_UNIT_SEL, reg);
-}
-
-void BNO055::setOperationMode(OPERATION_MODES_T mode)
-{
- setPage(0);
-
- // we clear all of our loaded data on mode changes
- clearData();
-
- uint8_t reg = readReg(REG_OPER_MODE);
-
- reg &= ~(_OPR_MODE_OPERATION_MODE_MASK << _OPR_MODE_OPERATION_MODE_SHIFT);
-
- reg |= (mode << _OPR_MODE_OPERATION_MODE_SHIFT);
-
- writeReg(REG_OPER_MODE, reg);
- m_currentMode = mode;
-
- usleep(30);
-}
-
-void BNO055::getCalibrationStatus(int *mag, int *acc, int *gyr, int *sys)
-{
- setPage(0);
-
- uint8_t reg = readReg(REG_CALIB_STAT);
-
- if (mag)
- *mag = (reg >> _CALIB_STAT_MAG_SHIFT) & _CALIB_STAT_MAG_MASK;
-
- if (acc)
- *acc = (reg >> _CALIB_STAT_ACC_SHIFT) & _CALIB_STAT_ACC_MASK;
-
- if (gyr)
- *gyr = (reg >> _CALIB_STAT_GYR_SHIFT) & _CALIB_STAT_GYR_MASK;
-
- if (sys)
- *sys = (reg >> _CALIB_STAT_SYS_SHIFT) & _CALIB_STAT_SYS_MASK;
-}
-
-int *BNO055::getCalibrationStatus()
-{
- static int v[4]; // mag, acc, gyr, sys;
-
- getCalibrationStatus(&v[0], &v[1], &v[2], &v[3]);
- return v;
-}
-
-bool BNO055::isFullyCalibrated()
-{
- int mag, acc, gyr, sys;
-
- getCalibrationStatus(&mag, &acc, &gyr, &sys);
-
- // all of them equal to 3 means fully calibrated
- if (mag == 3 && acc == 3 && gyr == 3 && sys == 3)
- return true;
- else
- return false;
-}
-
-void BNO055::resetSystem()
-{
- setPage(0);
-
- uint8_t reg = readReg(REG_SYS_TRIGGER);
-
- reg |= SYS_TRIGGER_RST_SYS;
-
- writeReg(REG_SYS_TRIGGER, reg);
- sleep(1);
-}
-
-void BNO055::resetInterruptStatus()
-{
- setPage(0);
-
- uint8_t reg = readReg(REG_SYS_TRIGGER);
-
- reg |= SYS_TRIGGER_RST_INT;
-
- writeReg(REG_SYS_TRIGGER, reg);
-}
-
-uint8_t BNO055::getInterruptStatus()
-{
- setPage(0);
-
- return readReg(REG_INT_STA);
-}
-
-uint8_t BNO055::getInterruptEnable()
-{
- setPage(1);
-
- return readReg(REG_INT_EN);
-}
-
-void BNO055::setInterruptEnable(uint8_t enables)
-{
- setPage(1);
-
- writeReg(REG_INT_EN, enables);
-}
-
-uint8_t BNO055::getInterruptMask()
-{
- setPage(1);
-
- return readReg(REG_INT_MSK);
-}
-
-void BNO055::setInterruptMask(uint8_t mask)
-{
- setPage(1);
-
- writeReg(REG_INT_MSK, mask);
-}
-
-BNO055::SYS_STATUS_T BNO055::getSystemStatus()
-{
- setPage(0);
-
- return static_cast<BNO055::SYS_STATUS_T>(readReg(REG_SYS_STATUS));
-}
-
-BNO055::SYS_ERR_T BNO055::getSystemError()
-{
- setPage(0);
-
- return static_cast<BNO055::SYS_ERR_T>(readReg(REG_SYS_ERROR));
-}
-
-string BNO055::readCalibrationData()
-{
- if (!isFullyCalibrated())
- {
- cerr << __FUNCTION__ << ": Sensor must be fully calibrated first."
- << endl;
- return "";
- }
-
- // should be at page 0, but lets make sure
- setPage(0);
-
- // first we need to go back into config mode
- OPERATION_MODES_T currentMode = m_currentMode;
- setOperationMode(OPERATION_MODE_CONFIGMODE);
-
- uint8_t calibData[calibrationDataNumBytes];
- readRegs(REG_ACC_OFFSET_X_LSB, calibData, calibrationDataNumBytes);
-
- string rv((char *)calibData, calibrationDataNumBytes);
-
- // now reset our operating mode
- setOperationMode(currentMode);
-
- return rv;
-}
-
-void BNO055::writeCalibrationData(string calibData)
-{
- if (calibData.size() != calibrationDataNumBytes)
- {
- throw std::invalid_argument(std::string(__FUNCTION__)
- + ": calibData string must be exactly "
- + std::to_string(calibrationDataNumBytes)
- + " bytes long");
- }
-
- // should be at page 0, but lets make sure
- setPage(0);
-
- // first we need to go back into config mode
- OPERATION_MODES_T currentMode = m_currentMode;
- setOperationMode(OPERATION_MODE_CONFIGMODE);
-
- // write the data
- writeRegs(REG_ACC_OFFSET_X_LSB, (uint8_t *)calibData.c_str(),
- calibData.size());
-
- // now reset our operating mode
- setOperationMode(currentMode);
-}
-
-float BNO055::getTemperature(bool fahrenheit)
-{
- if (fahrenheit)
- return c2f(m_temperature);
- else
- return m_temperature;
-}
-
-void BNO055::clearData()
-{
- m_magX = m_magY = m_magZ = 0;
- m_accX = m_accY = m_accZ = 0;
- m_gyrX = m_gyrY = m_gyrZ = 0;
- m_eulHeading = m_eulRoll = m_eulPitch = 0;
- m_quaW = m_quaX = m_quaY = m_quaZ = 0;
- m_liaX = m_liaY = m_liaZ = 0;
- m_grvX = m_grvY = m_grvZ = 0;
-}
-
-bool BNO055::updateFusionData()
-{
- // bail if we are in config mode, or aren't in a fusion mode...
- if (m_currentMode == OPERATION_MODE_CONFIGMODE ||
- m_currentMode < OPERATION_MODE_IMU)
- return false;
-
- setPage(0);
-
- // FIXME/MAYBE? - abort early if SYS calibration is == 0?
-
- const int fusionBytes = 26;
- uint8_t buf[fusionBytes];
-
- readRegs(REG_EUL_HEADING_LSB, buf, fusionBytes);
-
- m_eulHeading = float(int16_t(buf[0] | (buf[1] << 8)));
- m_eulRoll = float(int16_t(buf[2] | (buf[3] << 8)));
- m_eulPitch = float(int16_t(buf[4] | (buf[5] << 8)));
-
- m_quaW = float(int16_t(buf[6] | (buf[7] << 8)));
- m_quaX = float(int16_t(buf[8] | (buf[9] << 8)));
- m_quaY = float(int16_t(buf[10] | (buf[11] << 8)));
- m_quaZ = float(int16_t(buf[12] | (buf[13] << 8)));
-
- m_liaX = float(int16_t(buf[14] | (buf[15] << 8)));
- m_liaY = float(int16_t(buf[16] | (buf[17] << 8)));
- m_liaZ = float(int16_t(buf[18] | (buf[19] << 8)));
-
- m_grvX = float(int16_t(buf[20] | (buf[21] << 8)));
- m_grvY = float(int16_t(buf[22] | (buf[23] << 8)));
- m_grvZ = float(int16_t(buf[24] | (buf[25] << 8)));
-
- return true;
-}
-
-bool BNO055::updateNonFusionData()
-{
- // bail if we are in config mode...
- if (m_currentMode == OPERATION_MODE_CONFIGMODE)
- return false;
-
- setPage(0);
-
- const int nonFusionBytes = 18;
- uint8_t buf[nonFusionBytes];
-
- readRegs(REG_ACC_DATA_X_LSB, buf, nonFusionBytes);
-
- m_accX = float(int16_t(buf[0] | (buf[1] << 8)));
- m_accY = float(int16_t(buf[2] | (buf[3] << 8)));
- m_accZ = float(int16_t(buf[4] | (buf[5] << 8)));
-
- m_magX = float(int16_t(buf[6] | (buf[7] << 8)));
- m_magY = float(int16_t(buf[8] | (buf[9] << 8)));
- m_magZ = float(int16_t(buf[10] | (buf[11] << 8)));
-
- m_gyrX = float(int16_t(buf[12] | (buf[13] << 8)));
- m_gyrY = float(int16_t(buf[14] | (buf[15] << 8)));
- m_gyrZ = float(int16_t(buf[16] | (buf[17] << 8)));
-
- return true;
-}
-
-void BNO055::getEulerAngles(float *heading, float *roll, float *pitch)
-{
- if (heading)
- *heading = m_eulHeading / m_eulUnitScale;
-
- if (roll)
- *roll = m_eulRoll / m_eulUnitScale;
-
- if (pitch)
- *pitch = m_eulPitch / m_eulUnitScale;
-}
-
-float *BNO055::getEulerAngles()
-{
- static float v[3];
- getEulerAngles(&v[0], &v[1], &v[2]);
- return v;
-}
-
-void BNO055::getQuaternions(float *w, float *x, float *y, float *z)
-{
- // from the datasheet
- const float scale = float(1.0 / (1 << 14));
-
- if (w)
- *w = m_quaW * scale;
-
- if (x)
- *x = m_quaX * scale;
-
- if (y)
- *y = m_quaY * scale;
-
- if (z)
- *z = m_quaZ * scale;
-}
-
-float *BNO055::getQuaternions()
-{
- static float v[4];
- getQuaternions(&v[0], &v[1], &v[2], &v[3]);
- return v;
-}
-
-void BNO055::getLinearAcceleration(float *x, float *y, float *z)
-{
- if (x)
- *x = m_liaX / m_accUnitScale;
-
- if (y)
- *y = m_liaY / m_accUnitScale;
-
- if (z)
- *z = m_liaZ / m_accUnitScale;
-}
-
-float *BNO055::getLinearAcceleration()
-{
- static float v[3];
- getLinearAcceleration(&v[0], &v[1], &v[2]);
- return v;
-}
-
-void BNO055::getGravityVectors(float *x, float *y, float *z)
-{
- if (x)
- *x = m_grvX / m_accUnitScale;
-
- if (y)
- *y = m_grvY / m_accUnitScale;
-
- if (z)
- *z = m_grvZ / m_accUnitScale;
-}
-
-float *BNO055::getGravityVectors()
-{
- static float v[3];
- getGravityVectors(&v[0], &v[1], &v[2]);
- return v;
-}
-
-void BNO055::getAccelerometer(float *x, float *y, float *z)
-{
- if (x)
- *x = m_accX / m_accUnitScale;
-
- if (y)
- *y = m_accY / m_accUnitScale;
-
- if (z)
- *z = m_accZ / m_accUnitScale;
-}
-
-float *BNO055::getAccelerometer()
-{
- static float v[3];
- getAccelerometer(&v[0], &v[1], &v[2]);
- return v;
-}
-
-void BNO055::getMagnetometer(float *x, float *y, float *z)
-{
- // from the datasheet - 16 uT's per LSB
- const float scale = 16.0;
-
- if (x)
- *x = m_magX / scale;
-
- if (y)
- *y = m_magY / scale;
-
- if (z)
- *z = m_magZ / scale;
-}
-
-float *BNO055::getMagnetometer()
-{
- static float v[3];
- getMagnetometer(&v[0], &v[1], &v[2]);
- return v;
-}
-
-void BNO055::getGyroscope(float *x, float *y, float *z)
-{
- if (x)
- *x = m_gyrX / m_gyrUnitScale;
-
- if (y)
- *y = m_gyrY / m_gyrUnitScale;
-
- if (z)
- *z = m_gyrZ / m_gyrUnitScale;
-}
-
-float *BNO055::getGyroscope()
-{
- static float v[3];
- getGyroscope(&v[0], &v[1], &v[2]);
- return v;
-}
-
-void BNO055::setAccelerationConfig(ACC_RANGE_T range, ACC_BW_T bw,
- ACC_PWR_MODE_T pwr)
-{
- setPage(1);
-
- uint8_t reg = ((range << _ACC_CONFIG_ACC_RANGE_SHIFT) |
- (bw << _ACC_CONFIG_ACC_BW_SHIFT) |
- (pwr << _ACC_CONFIG_ACC_PWR_MODE_SHIFT));
-
- writeReg(REG_ACC_CONFIG, reg);
-}
-
-void BNO055::setMagnetometerConfig(MAG_ODR_T odr, MAG_OPR_T opr,
- MAG_POWER_T pwr)
-{
- setPage(1);
-
- uint8_t reg = ((odr << _MAG_CONFIG_MAG_ODR_SHIFT) |
- (opr << _MAG_CONFIG_MAG_OPR_MODE_SHIFT) |
- (pwr << _MAG_CONFIG_MAG_POWER_MODE_SHIFT));
-
- writeReg(REG_MAG_CONFIG, reg);
-}
-
-void BNO055::setGyroscopeConfig(GYR_RANGE_T range, GYR_BW_T bw,
- GYR_POWER_MODE_T pwr)
-{
- setPage(1);
-
- uint8_t reg = ((range << _GYR_CONFIG0_GYR_RANGE_SHIFT) |
- (bw << _GYR_CONFIG0_GYR_BW_SHIFT));
-
- writeReg(REG_GYR_CONFIG0, reg);
-
- reg = (pwr << _GYR_CONFIG1_GYR_POWER_MODE_SHIFT);
-
- writeReg(REG_GYR_CONFIG1, reg);
-}
-
-#if defined(SWIGJAVA) || (JAVACALLBACK)
-void BNO055::installISR(int gpio, mraa::Edge level,
- jobject runnable)
-{
- // delete any existing ISR and GPIO context
- uninstallISR();
-
- // create gpio context
- m_gpioIntr = new mraa::Gpio(gpio);
-
- m_gpioIntr->dir(mraa::DIR_IN);
- m_gpioIntr->isr(level, runnable);
-
-}
-#else
-void BNO055::installISR(int gpio, mraa::Edge level,
- void (*isr)(void *), void *arg)
-{
- // delete any existing ISR and GPIO context
- uninstallISR();
-
- // create gpio context
- m_gpioIntr = new mraa::Gpio(gpio);
-
- m_gpioIntr->dir(mraa::DIR_IN);
- m_gpioIntr->isr(level, isr, arg);
-}
-#endif
-
-void BNO055::uninstallISR()
-{
- if (m_gpioIntr)
- {
- m_gpioIntr->isrExit();
- delete m_gpioIntr;
-
- m_gpioIntr = 0;
- }
-}
diff --git a/peripheral/libupm/src/bno055/bno055.hpp b/peripheral/libupm/src/bno055/bno055.hpp
deleted file mode 100644
index bc9fcbc..0000000
--- a/peripheral/libupm/src/bno055/bno055.hpp
+++ /dev/null
@@ -1,1508 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <mraa/i2c.hpp>
-#include <mraa/gpio.hpp>
-
-#define BNO055_I2C_BUS 0
-#define BNO055_DEFAULT_ADDR 0x28
-
-namespace upm {
-
- /**
- * @brief BNO055 Absolute Orientation 9DOF Fusion Hub
- * @defgroup bno055 libupm-bno055
- * @ingroup i2c gpio accelerometer compass
- */
-
- /**
- * @library bno055
- * @sensor bno055
- * @comname BNO055 Absolute Orientation 9DOF Fusion Hub
- * @type accelerometer compass
- * @man adafruit
- * @con i2c gpio
- * @web https://www.adafruit.com/products/2472
- *
- * @brief API for the BNO055 Absolute Orientation 9DOF Fusion Hub
- *
- * The BNO055 is a System in Package (SiP), integrating a triaxial
- * 14-bit accelerometer, a triaxial 16-bit gyroscope with a range of
- * ±2000 degrees per second, a triaxial geomagnetic sensor and a
- * 32-bit cortex M0+ microcontroller running Bosch Sensortec sensor
- * fusion software, in a single package.
- *
- * This sensor handles the hard problem of combining various sensor
- * information into a reliable measurement of sensor orientation
- * (refered to as 'sensor fusion'). The onboard MCU runs this
- * software and can provide fusion output in the form of Euler
- * Angles, Quaternions, Linear Acceleration, and Gravity Vectors in
- * 3 axes.
- *
- * The focus on this driver has been on supporting the fusion
- * components. Less support is available for use of this device as
- * a generic accelerometer, gyroscope and magnetometer, however
- * enough infrastructure is available to add any missing
- * functionality.
- *
- * This device requires calibration in order to operate accurately.
- * Methods are provided to retrieve calibration data (once
- * calibrated) to be stored somewhere else, like in a file. A
- * method is provided to load this data as well. Calibration data
- * is lost on a power cycle. See one of the examples for a
- * description of how to calibrate the device, but in essence:
- *
- * There is a calibration status register available
- * (getCalibrationStatus()) that returns the calibration status of
- * the accelerometer (ACC), magnetometer (MAG), gyroscope (GYR), and
- * overall system (SYS). Each of these values range from 0
- * (uncalibrated) to 3 (fully calibrated). Calibration involves
- * certain motions to get all 4 values at 3. The motions are as
- * follows (though see the datasheet for more information):
- *
- * GYR: Simply let the sensor sit flat for a few seconds.
- *
- * ACC: Move the sensor in various positions. Start flat, then
- * rotate slowly by 45 degrees, hold for a few seconds, then
- * continue rotating another 45 degrees and hold, etc. 6 or more
- * movements of this type may be required. You can move through any
- * axis you desire, but make sure that the device is lying at least
- * once perpendicular to the x, y, and z axis.
- *
- * MAG: Move slowly in a figure 8 pattern in the air, until the
- * calibration values reaches 3.
- *
- * SYS: This will usually reach 3 when the other items have also
- * reached 3. If not, continue slowly moving the device though
- * various axes until it does.
- *
- * @snippet bno055.cxx Interesting
- */
-
- class BNO055 {
- public:
- // The chip ID, for verification in the ctor.
- const uint8_t BNO055_CHIPID = 0xa0;
-
- // number of bytes of stored calibration data
- const int calibrationDataNumBytes = 22;
-
- // NOTE: Reserved registers should not be written into. Reading
- // from them will return indeterminate values.
- //
- // The register map is divided into two pages - page 1 contains
- // sensor specific configuration registers, and page 0 contains all
- // other configuration data and sensor output registers.
-
- /**
- * BNO055 registers
- */
- typedef enum : uint8_t {
- // The first register listed here is the page ID register. It
- // is the same on both pages, and selects or indicates the
- // currently active register page.
-
- REG_PAGE_ID = 0x07,
-
- // Page 0
- REG_CHIP_ID = 0x00,
- REG_ACC_ID = 0x01, // accel id
- REG_MAG_ID = 0x02, // mag id
- REG_GYR_ID = 0x03, // gyro id
- REG_SW_REV_ID_LSB = 0x04,
- REG_SW_REV_ID_MSB = 0x05,
- REG_BL_REV_ID = 0x06, // bootloader rev
-
- // REG_PAGE_ID = 0x07
-
- REG_ACC_DATA_X_LSB = 0x08,
- REG_ACC_DATA_X_MSB = 0x09,
- REG_ACC_DATA_Y_LSB = 0x0a,
- REG_ACC_DATA_Y_MSB = 0x0b,
- REG_ACC_DATA_Z_LSB = 0x0c,
- REG_ACC_DATA_Z_MSB = 0x0d,
-
- REG_MAG_DATA_X_LSB = 0x0e,
- REG_MAG_DATA_X_MSB = 0x0f,
- REG_MAG_DATA_Y_LSB = 0x10,
- REG_MAG_DATA_Y_MSB = 0x11,
- REG_MAG_DATA_Z_LSB = 0x12,
- REG_MAG_DATA_Z_MSB = 0x13,
-
- REG_GYR_DATA_X_LSB = 0x14,
- REG_GYR_DATA_X_MSB = 0x15,
- REG_GYR_DATA_Y_LSB = 0x16,
- REG_GYR_DATA_Y_MSB = 0x17,
- REG_GYR_DATA_Z_LSB = 0x18,
- REG_GYR_DATA_Z_MSB = 0x19,
-
- // euler angles
- REG_EUL_HEADING_LSB = 0x1a,
- REG_EUL_HEADING_MSB = 0x1b,
- REG_EUL_ROLL_LSB = 0x1c,
- REG_EUL_ROLL_MSB = 0x1d,
- REG_EUL_PITCH_LSB = 0x1e,
- REG_EUL_PITCH_MSB = 0x1f,
-
- // Quaternions
- REG_QUA_DATA_W_LSB = 0x20,
- REG_QUA_DATA_W_MSB = 0x21,
- REG_QUA_DATA_X_LSB = 0x22,
- REG_QUA_DATA_X_MSB = 0x23,
- REG_QUA_DATA_Y_LSB = 0x24,
- REG_QUA_DATA_Y_MSB = 0x25,
- REG_QUA_DATA_Z_LSB = 0x26,
- REG_QUA_DATA_Z_MSB = 0x27,
-
- // linear accel data
- REG_LIA_DATA_X_LSB = 0x28,
- REG_LIA_DATA_X_MSB = 0x29,
- REG_LIA_DATA_Y_LSB = 0x2a,
- REG_LIA_DATA_Y_MSB = 0x2b,
- REG_LIA_DATA_Z_LSB = 0x2c,
- REG_LIA_DATA_Z_MSB = 0x2d,
-
- // gravity vector
- REG_GRV_DATA_X_LSB = 0x2e,
- REG_GRV_DATA_X_MSB = 0x2f,
- REG_GRV_DATA_Y_LSB = 0x30,
- REG_GRV_DATA_Y_MSB = 0x31,
- REG_GRV_DATA_Z_LSB = 0x32,
- REG_GRV_DATA_Z_MSB = 0x33,
-
- REG_TEMPERATURE = 0x34,
-
- REG_CALIB_STAT = 0x35, // calibration status
- REG_ST_RESULT = 0x36, // selftest result
-
- REG_INT_STA = 0x37, // interrupt status
-
- REG_SYS_CLK_STATUS = 0x38,
-
- REG_SYS_STATUS = 0x39,
- REG_SYS_ERROR = 0x3a,
-
- REG_UNIT_SEL = 0x3b,
-
- // 0x3c reserved
-
- REG_OPER_MODE = 0x3d, // operating mode
- REG_POWER_MODE = 0x3e,
-
- REG_SYS_TRIGGER = 0x3f,
- REG_TEMP_SOURCE = 0x40, // temperature src
-
- REG_AXIS_MAP_CONFIG = 0x41,
- REG_AXIS_MAP_SIGN = 0x42,
-
- // 0x43-0x54 reserved
-
- // stored configuration data
- REG_ACC_OFFSET_X_LSB = 0x55,
- REG_ACC_OFFSET_X_MSB = 0x56,
- REG_ACC_OFFSET_Y_LSB = 0x57,
- REG_ACC_OFFSET_Y_MSB = 0x58,
- REG_ACC_OFFSET_Z_LSB = 0x59,
- REG_ACC_OFFSET_Z_MSB = 0x5a,
-
- REG_MAG_OFFSET_X_LSB = 0x5b,
- REG_MAG_OFFSET_X_MSB = 0x5c,
- REG_MAG_OFFSET_Y_LSB = 0x5d,
- REG_MAG_OFFSET_Y_MSB = 0x5e,
- REG_MAG_OFFSET_Z_LSB = 0x5f,
- REG_MAG_OFFSET_Z_MSB = 0x60,
-
- REG_GYR_OFFSET_X_LSB = 0x61,
- REG_GYR_OFFSET_X_MSB = 0x62,
- REG_GYR_OFFSET_Y_LSB = 0x63,
- REG_GYR_OFFSET_Y_MSB = 0x64,
- REG_GYR_OFFSET_Z_LSB = 0x65,
- REG_GYR_OFFSET_Z_MSB = 0x66,
-
- REG_ACC_RADIUS_LSB = 0x67,
- REG_ACC_RADIUS_MSB = 0x68,
-
- REG_MAG_RADIUS_LSB = 0x69,
- REG_MAG_RADIUS_MSB = 0x6a,
-
- // 0x6b-0x7f reserved
- // end of page 0
-
- // Page 1
-
- // 0x00-0x06 reserved
- // 0x07 - page id
-
- REG_ACC_CONFIG = 0x08,
- REG_MAG_CONFIG = 0x09,
- REG_GYR_CONFIG0 = 0x0a,
- REG_GYR_CONFIG1 = 0x0b,
- REG_ACC_SLEEP_CONFIG = 0x0c,
- REG_GYR_SLEEP_CONFIG = 0x0d,
-
- // 0x0e reserved
- REG_INT_MSK = 0x0f,
- REG_INT_EN = 0x10,
-
- REG_ACC_AM_THRES = 0x11,
- REG_ACC_INT_SETTINGS = 0x12,
- REG_ACC_HG_DURATION = 0x13,
- REG_ACC_HG_THRES = 0x14,
- REG_ACC_NM_THRES = 0x15,
- REG_ACC_NM_SET = 0x16,
-
- REG_GYR_INT_SETTING = 0x17,
- REG_GYR_HR_X_SET = 0x18,
- REG_GYR_DUR_X = 0x19,
- REG_GYR_HR_Y_SET = 0x1a,
- REG_GYR_DUR_Y = 0x1b,
- REG_GYR_HR_Z_SET = 0x1c,
- REG_GYR_DUR_Z = 0x1d,
- REG_GYR_AM_THRES = 0x1e,
- REG_GYR_AM_SET = 0x1f,
-
- // 0x20-0x4f reserved
-
- // 16 byte (0x50-0x5f) unique ID
- REG_BNO_UNIQUE_ID = 0x50
-
- // 0x60-0x7f reserved
- } REGS_T;
-
- // Page 0 register enumerants
-
- /**
- * REG_CALIB_STAT bits
- */
- typedef enum {
- CALIB_STAT_MAG0 = 0x01,
- CALIB_STAT_MAG1 = 0x02,
- _CALIB_STAT_MAG_MASK = 3,
- _CALIB_STAT_MAG_SHIFT = 0,
-
- CALIB_STAT_ACC0 = 0x04,
- CALIB_STAT_ACC1 = 0x08,
- _CALIB_STAT_ACC_MASK = 3,
- _CALIB_STAT_ACC_SHIFT = 2,
-
- CALIB_STAT_GYR0 = 0x10,
- CALIB_STAT_GYR1 = 0x20,
- _CALIB_STAT_GYR_MASK = 3,
- _CALIB_STAT_GYR_SHIFT = 4,
-
- CALIB_STAT_SYS0 = 0x40,
- CALIB_STAT_SYS1 = 0x80,
- _CALIB_STAT_SYS_MASK = 3,
- _CALIB_STAT_SYS_SHIFT = 6
- } CALIB_STAT_BITS_T;
-
- /**
- * REG_ST_RESULT bits
- */
- typedef enum {
- ST_RESULT_ACC = 0x01,
- ST_RESULT_MAG = 0x02,
- ST_RESULT_GYR = 0x04,
- ST_RESULT_MCU = 0x08
- // 0x10-0x80 reserved
- } ST_RESULT_BITS_T;
-
- /**
- * REG_INT_STA bits
- */
- typedef enum {
- // 0x01-0x02 reserved
- INT_STA_GYRO_AM = 0x04, // gyro any-motion
- INT_STA_GYR_HIGH_RATE = 0x08,
- // 0x010 reserved
- INT_STA_ACC_HIGH_G = 0x20,
- INT_STA_ACC_AM = 0x40, // accel any-motion
- INT_STA_ACC_NM = 0x80 // accel no-motion
- } INT_STA_BITS_T;
-
- /**
- * REG_SYS_CLK_STATUS bits
- */
- typedef enum {
- SYS_CLK_STATUS_ST_MAIN_CLK = 0x01
- // 0x02-0x80 reserved
- } SYS_CLK_STATUS_BITS_T;
-
- /**
- * REG_SYS_STATUS values
- */
- typedef enum {
- SYS_STATUS_IDLE = 0,
- SYS_STATUS_SYS_ERR = 1,
- SYS_STATUS_INIT_PERIPHERALS = 2,
- SYS_STATUS_SYSTEM_INIT = 3,
- SYS_STATUS_EXECUTING_SELFTEST = 4,
- SYS_STATUS_FUSION_RUNNING = 5,
- SYS_STATUS_NO_FUSION_RUNNING = 6
- } SYS_STATUS_T;
-
- /**
- * REG_SYS_ERR values
- */
- typedef enum {
- SYS_ERR_NOERROR = 0,
- SYS_ERR_PERIPH_INIT_ERROR = 1,
- SYS_ERR_SYS_INIT_ERROR = 2,
- SYS_ERR_SELFTEST_FAIL_ERROR = 3,
- SYS_ERR_REG_VAL_OUTOFRANGE_ERROR = 4,
- SYS_ERR_REG_ADDR_OUTOFRANGE_ERROR = 5,
- SYS_ERR_REG_WRITE_ERROR = 6,
- SYS_ERR_LP_MODE_NOT_AVAIL_ERROR = 7,
- SYS_ERR_ACC_PWR_MODE_NOT_AVAIL_ERROR = 8,
- SYS_ERR_FUSION_CONFIG_ERROR = 9,
- SYS_ERR_SENSOR_CONFIG_ERROR = 10
- } SYS_ERR_T;
-
-
- /**
- * REG_UNIT_SEL bits
- */
- typedef enum {
- UNIT_SEL_ACC_UNIT = 0x01, // 0=m/s^2, 1=mg
- UNIT_SEL_GYR_UNIT = 0x02, // 0=dps, 1=rps
- UNIT_SEL_EUL_UNIT = 0x04, // 0=degrees, 1=radians
- // 0x08 reserved
- UNIT_SEL_TEMP_UNIT = 0x10, // 0=C, 1=F
- // 0x20-0x40 reserved
- UNIT_SEL_ORI_ANDROID_WINDOWS = 0x80 // 0=windows orient, 1=android
- } UNIT_SEL_BITS_T;
-
- /**
- * REG_OPR_MODE bits
- */
- typedef enum {
- OPR_MODE_OPERATION_MODE0 = 0x01,
- OPR_MODE_OPERATION_MODE1 = 0x02,
- OPR_MODE_OPERATION_MODE2 = 0x04,
- OPR_MODE_OPERATION_MODE3 = 0x08,
- _OPR_MODE_OPERATION_MODE_MASK = 15,
- _OPR_MODE_OPERATION_MODE_SHIFT = 0
- // 0x10-0x80 reserved
- } OPR_MODE_BITS_T;
-
- /**
- * OPR_MODE_OPERATION values
- */
- typedef enum {
- OPERATION_MODE_CONFIGMODE = 0,
- OPERATION_MODE_ACCONLY = 1,
- OPERATION_MODE_MAGONLY = 2,
- OPERATION_MODE_GYROONLY = 3,
- OPERATION_MODE_ACCMAG = 4,
- OPERATION_MODE_ACCGYRO = 5,
- OPERATION_MODE_MAGGYRO = 6,
- OPERATION_MODE_AMG = 7,
- // fusion modes
- OPERATION_MODE_IMU = 8,
- OPERATION_MODE_COMPASS = 9,
- OPERATION_MODE_M4G = 10,
- OPERATION_MODE_NDOF_FMC_OFF = 11,
- OPERATION_MODE_NDOF = 12
- } OPERATION_MODES_T;
-
- /**
- * REG_PWR_MODE bits
- */
- typedef enum {
- PWR_MODE_POWER_MODE0 = 0x01,
- PWR_MODE_POWER_MODE1 = 0x02,
- _PWR_MODE_POWER_MODE_MASK = 3,
- _PWR_MODE_POWER_MODE_SHIFT = 0
- // 0x04-0x80 reserved
- } PWR_MODE_BITS_T;
-
- /**
- * POWER_MODE values
- */
- typedef enum {
- POWER_MODE_NORMAL = 0,
- POWER_MODE_LOW = 1,
- POWER_MODE_SUSPEND = 2
- } POWER_MODES_T;
-
- /**
- * REG_SYS_TRIGGER bits
- */
- typedef enum {
- SYS_TRIGGER_SELF_TEST = 0x01,
- // 0x02-0x10 reserved
- SYS_TRIGGER_RST_SYS = 0x20,
- SYS_TRIGGER_RST_INT = 0x40,
- SYS_TRIGGER_CLK_SEL = 0x80
- } SYS_TRIGGER_BITS_T;
-
- /**
- * REG_TEMP_SOURCE bits
- */
- typedef enum {
- TEMP_SOURCE_TEMP_SOURCE0 = 0x01,
- TEMP_SOURCE_TEMP_SOURCE1 = 0x02,
- _TEMP_SOURCE_TEMP_SOURCE_MASK = 3,
- _TEMP_SOURCE_TEMP_SOURCE_SHIFT = 0
- // 0x04-0x80 reserved
- } TEMP_SOURCE_BITS_T;
-
- /**
- * TEMP_SOURCE values
- */
- typedef enum {
- TEMP_SOURCE_ACC = 0,
- TEMP_SOURCE_GYR = 1
- } TEMP_SOURCES_T;
-
- /**
- * REG_AXIS_MAP_CONFIG bits
- */
- typedef enum {
- AXIS_MAP_CONFIG_REMAPPED_X_VAL0 = 0x01,
- AXIS_MAP_CONFIG_REMAPPED_X_VAL1 = 0x02,
- _AXIS_MAP_CONFIG_REMAPPED_X_VAL_MASK = 3,
- _AXIS_MAP_CONFIG_REMAPPED_X_VAL_SHIFT = 0,
-
- AXIS_MAP_CONFIG_REMAPPED_Y_VAL0 = 0x04,
- AXIS_MAP_CONFIG_REMAPPED_Y_VAL1 = 0x08,
- _AXIS_MAP_CONFIG_REMAPPED_Y_VAL_MASK = 3,
- _AXIS_MAP_CONFIG_REMAPPED_Y_VAL_SHIFT = 2,
-
- AXIS_MAP_CONFIG_REMAPPED_Z_VAL0 = 0x10,
- AXIS_MAP_CONFIG_REMAPPED_Z_VAL1 = 0x20,
- _AXIS_MAP_CONFIG_REMAPPED_Z_VAL_MASK = 3,
- _AXIS_MAP_CONFIG_REMAPPED_Z_VAL_SHIFT = 4
- // 0x40-0x80 reserved
- } AXIS_MAP_CONFIG_BITS_T;
-
- /**
- * REMAPPED_AXIS values, applied to X, Y, and Z axes
- * (REG_AXIS_MAP_CONFIG)
- */
- typedef enum {
- REMAPPED_AXIS_X = 0,
- REMAPPED_AXIS_Y = 1,
- REMAPPED_AXIS_Z = 2
- } REMAPPED_AXIS_T;
-
-
- /**
- * REG_AXIS_MAP_SIGN bits
- */
- typedef enum {
- AXIS_MAP_SIGN_REMAPPED_Z_SIGN = 0x01,
- AXIS_MAP_SIGN_REMAPPED_Y_SIGN = 0x02,
- AXIS_MAP_SIGN_REMAPPED_X_SIGN = 0x04
- // 0x08-0x80 reserved
- } AXIS_MAP_SIGN_BITS_T;
-
- // Page 1 register enumerants
-
- /**
- * REG_ACC_CONFIG bits
- */
- typedef enum {
- ACC_CONFIG_ACC_RANGE0 = 0x01,
- ACC_CONFIG_ACC_RANGE1 = 0x02,
- _ACC_CONFIG_ACC_RANGE_MASK = 3,
- _ACC_CONFIG_ACC_RANGE_SHIFT = 0,
-
- ACC_CONFIG_ACC_BW0 = 0x04,
- ACC_CONFIG_ACC_BW1 = 0x08,
- ACC_CONFIG_ACC_BW2 = 0x10,
- _ACC_CONFIG_ACC_BW_MASK = 7,
- _ACC_CONFIG_ACC_BW_SHIFT = 2,
-
- ACC_CONFIG_ACC_PWR_MODE0 = 0x20,
- ACC_CONFIG_ACC_PWR_MODE1 = 0x40,
- ACC_CONFIG_ACC_PWR_MODE2 = 0x80,
- _ACC_CONFIG_ACC_PWR_MODE_MASK = 7,
- _ACC_CONFIG_ACC_PWR_MODE_SHIFT = 5
- } ACC_CONFIG_BITS_T;
-
- /**
- * ACC_CONFIG_ACC_RANGE values
- */
- typedef enum {
- ACC_RANGE_2G = 0,
- ACC_RANGE_4G = 1,
- ACC_RANGE_8G = 2,
- ACC_RANGE_16G = 3
- } ACC_RANGE_T;
-
- /**
- * ACC_CONFIG_ACC_BW values
- */
- typedef enum {
- ACC_BW_7_81 = 0, // 7.81 Hz
- ACC_BW_15_53 = 1,
- ACC_BW_31_25 = 2,
- ACC_BW_62_5 = 3,
- ACC_BW_125 = 4, // 125 Hz
- ACC_BW_250 = 5,
- ACC_BW_500 = 6,
- ACC_BW_1000 = 7
- } ACC_BW_T;
-
- /**
- * ACC_PWR_MODE values
- */
- typedef enum {
- ACC_PWR_MODE_NORMAL = 0,
- ACC_PWR_MODE_SUSPEND = 1,
- ACC_PWR_MODE_LOWPOWER1 = 2,
- ACC_PWR_MODE_STANDBY = 3,
- ACC_PWR_MODE_LOWPOWER2 = 4,
- ACC_PWR_MODE_DEEPSUSPEND = 5
- } ACC_PWR_MODE_T;
-
- /**
- * REG_MAG_CONFIG bits
- */
- typedef enum {
- MAG_CONFIG_MAG_ODR0 = 0x01,
- MAG_CONFIG_MAG_ODR1 = 0x02,
- MAG_CONFIG_MAG_ODR2 = 0x04,
- _MAG_CONFIG_MAG_ODR_MASK = 7,
- _MAG_CONFIG_MAG_ODR_SHIFT = 0,
-
- MAG_CONFIG_MAG_OPR_MODE0 = 0x08,
- MAG_CONFIG_MAG_OPR_MODE1 = 0x10,
- _MAG_CONFIG_MAG_OPR_MODE_MASK = 3,
- _MAG_CONFIG_MAG_OPR_MODE_SHIFT = 3,
-
- MAG_CONFIG_MAG_POWER_MODE0 = 0x20,
- MAG_CONFIG_MAG_POWER_MODE1 = 0x40,
- _MAG_CONFIG_MAG_POWER_MODE_MASK = 3,
- _MAG_CONFIG_MAG_POWER_MODE_SHIFT = 5
- // 0x80 reserved
- } MAG_CONFIG_BITS_T;
-
- /**
- * MAG_ODR values
- */
- typedef enum {
- MAG_ODR_2 = 0, // 2Hz
- MAG_ODR_6 = 1,
- MAG_ODR_8 = 2,
- MAG_ODR_10 = 3,
- MAG_ODR_15 = 4,
- MAG_ODR_20 = 5,
- MAG_ODR_25 = 6,
- MAG_ODR_30 = 7
- } MAG_ODR_T;
-
- /**
- * MAG_OPR values
- */
- typedef enum {
- MAG_OPR_LOW = 0, // low power
- MAG_OPR_REGULAR = 1,
- MAG_OPR_ENHANCED_REGULAR = 2,
- MAG_OPR_HIGH_ACCURACY = 3
- } MAG_OPR_T;
-
- /**
- * MAG_POWER values
- */
- typedef enum {
- MAG_POWER_NORMAL = 0,
- MAG_POWER_SLEEP = 1,
- MAG_POWER_SUSPEND = 2,
- MAG_POWER_FORCE_MODE = 3
- } MAG_POWER_T;
-
- /**
- * REG_GYR_CONFIG0 bits
- */
- typedef enum {
- GYR_CONFIG0_GYR_RANGE0 = 0x01,
- GYR_CONFIG0_GYR_RANGE1 = 0x02,
- GYR_CONFIG0_GYR_RANGE2 = 0x04,
- _GYR_CONFIG0_GYR_RANGE_MASK = 7,
- _GYR_CONFIG0_GYR_RANGE_SHIFT = 0,
-
- GYR_CONFIG0_GYR_BW0 = 0x08,
- GYR_CONFIG0_GYR_BW1 = 0x10,
- GYR_CONFIG0_GYR_BW2 = 0x20,
- _GYR_CONFIG0_GYR_BW_MASK = 7,
- _GYR_CONFIG0_GYR_BW_SHIFT = 3
- // 0x40-0x80 reserved
- } GYR_CONFIG0_BITS_T;
-
- /**
- * GYR_RANGE values
- */
- typedef enum {
- GYR_RANGE_2000 = 0, // degrees/sec
- GYR_RANGE_1000 = 1,
- GYR_RANGE_500 = 2,
- GYR_RANGE_250 = 3,
- GYR_RANGE_125 = 4
- } GYR_RANGE_T;
-
- /**
- * GYR_BW values
- */
- typedef enum {
- GYR_BW_523 = 0, // Hz
- GYR_BW_230 = 1,
- GYR_BW_116 = 2,
- GYR_BW_47 = 3,
- GYR_BW_23 = 4,
- GYR_BW_12 = 5,
- GYR_BW_64 = 6,
- GYR_BW_32 = 7
- } GYR_BW_T;
-
- /**
- * REG_GYR_CONFIG1 bits
- */
- typedef enum {
- GYR_CONFIG1_GYR_POWER_MODE0 = 0x01,
- GYR_CONFIG1_GYR_POWER_MODE1 = 0x02,
- GYR_CONFIG1_GYR_POWER_MODE2 = 0x04,
- _GYR_CONFIG1_GYR_POWER_MODE_MASK = 7,
- _GYR_CONFIG1_GYR_POWER_MODE_SHIFT = 0
- // 0x08-0x80 reserved
- } GYR_CONFIG1_BITS_T;
-
- /**
- * GYR_POWER_MODE values
- */
- typedef enum {
- GYR_POWER_MODE_NORMAL = 0,
- GYR_POWER_MODE_FAST_POWERUP = 1,
- GYR_POWER_MODE_DEEP_SUSPEND = 2,
- GYR_POWER_MODE_SUSPEND = 3,
- GYR_POWER_MODE_ADVANCED_POWERSAVE= 4
- } GYR_POWER_MODE_T;
-
- /**
- * REG_ACC_SLEEP_CONFIG bits
- */
- typedef enum {
- ACC_SLEEP_CONFIG_SLP_MODE = 0x01, // 0=event, 1=equidistant sample
-
- ACC_SLEEP_CONFIG_ACC_SLP_DUR0 = 0x02,
- ACC_SLEEP_CONFIG_ACC_SLP_DUR1 = 0x04,
- ACC_SLEEP_CONFIG_ACC_SLP_DUR2 = 0x08,
- ACC_SLEEP_CONFIG_ACC_SLP_DUR3 = 0x10,
- _ACC_SLEEP_CONFIG_ACC_SLP_DUR_MASK = 15,
- _ACC_SLEEP_CONFIG_ACC_SLP_DUR_SHIFT = 1
- // 0x20-0x80 reserved
- } ACC_SLEEP_CONFIG_BITS_T;
-
- /**
- * ACC_SLP_DUR values
- */
- typedef enum {
- ACC_SLP_DUR_0_5 = 0, // 0.5ms
- // same for 1-5
-
- ACC_SLP_DUR_1 = 6, // 1ms
- ACC_SLP_DUR_2 = 7,
- ACC_SLP_DUR_4 = 8,
- ACC_SLP_DUR_6 = 9,
- ACC_SLP_DUR_10 = 10,
- ACC_SLP_DUR_25 = 11,
- ACC_SLP_DUR_50 = 12,
- ACC_SLP_DUR_100 = 13,
- ACC_SLP_DUR_500 = 14
- // 15 = 1ms
- } ACC_SLP_DUR_T;
-
- /**
- * REG_GYR_SLEEP_CONFIG bits
- */
- typedef enum {
- GYR_SLEEP_CONFIG_GYR_SLEEP_DUR0 = 0x01,
- GYR_SLEEP_CONFIG_GYR_SLEEP_DUR1 = 0x02,
- GYR_SLEEP_CONFIG_GYR_SLEEP_DUR2 = 0x04,
- _GYR_SLEEP_CONFIG_GYR_SLEEP_DUR_MASK = 7,
- _GYR_SLEEP_CONFIG_GYR_SLEEP_DUR_SHIFT = 0,
-
- GYR_SLEEP_CONFIG_GYR_AUTO_SLP_DUR0 = 0x08,
- GYR_SLEEP_CONFIG_GYR_AUTO_SLP_DUR1 = 0x10,
- GYR_SLEEP_CONFIG_GYR_AUTO_SLP_DUR2 = 0x20,
- _GYR_SLEEP_CONFIG_GYR_AUTO_SLP_DUR_MASK = 7,
- _GYR_SLEEP_CONFIG_GYR_AUTO_SLP_DUR_SHIFT = 3
- // 0x40-0x80 reserved
- } GYR_SLEEP_CONFIG_BITS_T;
-
- /**
- * GYR_SLEEP_DUR values
- */
- typedef enum {
- GYR_SLEEP_DUR_2 = 0, // 2ms
- GYR_SLEEP_DUR_4 = 1,
- GYR_SLEEP_DUR_5 = 2,
- GYR_SLEEP_DUR_8 = 3,
- GYR_SLEEP_DUR_10 = 4,
- GYR_SLEEP_DUR_15 = 5,
- GYR_SLEEP_DUR_18 = 6,
- GYR_SLEEP_DUR_20 = 7
- } GYR_SLEEP_DUR_T;
-
- /**
- * GYR_AUTO_SLP_DUR values
- */
- typedef enum {
- // 0 = illegal
- GYR_AUTO_SLP_DUR_4 = 1, // ms
- GYR_AUTO_SLP_DUR_5 = 2,
- GYR_AUTO_SLP_DUR_8 = 3,
- GYR_AUTO_SLP_DUR_10 = 4,
- GYR_AUTO_SLP_DUR_15 = 5,
- GYR_AUTO_SLP_DUR_20 = 6,
- GYR_AUTO_SLP_DUR_40 = 7
- } GYR_AUTO_SLP_DUR_T;
-
- /**
- * REG_INT_MSK and REG_INT_EN bits
- */
- typedef enum {
- // 0x00-0x02 reserved
- INT_GYRO_AM = 0x04, // gyro any-motion
- INT_GYRO_HIGH_RATE = 0x08,
- // 0x10 reserved
- INT_ACC_HIGH_G = 0x20,
- INT_ACC_AM = 0x40, // acc any-motion
- INT_ACC_NM = 0x80, // acc no-motion
- } INT_BITS_T;
-
- /**
- * REG_ACC_INT_SETTINGS bits
- */
- typedef enum {
- ACC_INT_SETTINGS_AM_DUR0 = 0x01,
- ACC_INT_SETTINGS_AM_DUR1 = 0x02,
- _ACC_INT_SETTINGS_AM_DUR_MASK = 3,
- _ACC_INT_SETTINGS_AM_DUR_SHIFT = 0,
-
- ACC_INT_SETTINGS_AM_NM_X_AXIS = 0x04,
- ACC_INT_SETTINGS_AM_NM_Y_AXIS = 0x08,
- ACC_INT_SETTINGS_AM_NM_Z_AXIS = 0x10,
-
- ACC_INT_SETTINGS_HG_X_AXIS = 0x20,
- ACC_INT_SETTINGS_HG_Y_AXIS = 0x40,
- ACC_INT_SETTINGS_HG_Z_AXIS = 0x80
- } ACC_INT_SETTINGS_BITS_T;
-
- /**
- * REG_ACC_NM_SET bits
- */
- typedef enum {
- ACC_NM_SET_SM_NM = 0x01, // 0=slowmotion, 1=nomotion
-
- ACC_NM_SET_SM_NM_DUR0 = 0x02,
- ACC_NM_SET_SM_NM_DUR1 = 0x04,
- ACC_NM_SET_SM_NM_DUR2 = 0x08,
- ACC_NM_SET_SM_NM_DUR3 = 0x10,
- ACC_NM_SET_SM_NM_DUR4 = 0x20,
- ACC_NM_SET_SM_NM_DUR5 = 0x40,
- _ACC_NM_SET_SM_NM_DUR_MASK = 63,
- _ACC_NM_SET_SM_NM_DUR_SHIFT = 1
- // 0x80 reserved
- } ACC_NM_SET_BITS_T;
-
- /**
- * REG_GYR_INT_SETTING bits
- */
- typedef enum {
- GYR_INT_SETTING_AM_X_AXIS = 0x01,
- GYR_INT_SETTING_AM_Y_AXIS = 0x02,
- GYR_INT_SETTING_AM_Z_AXIS = 0x04,
-
- GYR_INT_SETTING_HR_X_AXIS = 0x08,
- GYR_INT_SETTING_HR_Y_AXIS = 0x10,
- GYR_INT_SETTING_HR_Z_AXIS = 0x20,
-
- GYR_INT_SETTING_AM_FILT = 0x40,
- GYR_INT_SETTING_HR_FILT = 0x80
- } GYR_INT_SETTING_BITS_T;
-
- /**
- * REG_GYR_HR_X_SET, REG_GYR_HR_Y_SET, and REG_GYR_HR_Z_SET bits
- */
- typedef enum {
- GYR_HR_XYZ_SET_HR_THRESH0 = 0x01,
- GYR_HR_XYZ_SET_HR_THRESH1 = 0x02,
- GYR_HR_XYZ_SET_HR_THRESH2 = 0x04,
- GYR_HR_XYZ_SET_HR_THRESH3 = 0x08,
- GYR_HR_XYZ_SET_HR_THRESH4 = 0x10,
- _GYR_HR_XYZ_SET_HR_THRESH_MASK = 31,
- _GYR_HR_XYZ_SET_HR_THRESH_SHIFT = 0,
-
- GYR_HR_XYZ_SET_HR_THRESH_HYST0 = 0x20,
- GYR_HR_XYZ_SET_HR_THRESH_HYST1 = 0x40,
- _GYR_HR_XYZ_SET_HR_THRESH_HYST_MASK = 3,
- _GYR_HR_XYZ_SET_HR_THRESH_HYST_SHIFT = 5
- } GYR_HR_XYZ_SET_BITS_T;
-
- /**
- * REG_GYR_AM_SET bits
- */
- typedef enum {
- GYR_AM_SET_SLOPE_SAMPLES0 = 0x01,
- GYR_AM_SET_SLOPE_SAMPLES1 = 0x02,
- _GYR_AM_SET_SLOPE_SAMPLES_MASK = 3,
- _GYR_AM_SET_SLOPE_SAMPLES_SHIFT = 0,
-
- GYR_AM_SET_AWAKE_DUR0 = 0x04,
- GYR_AM_SET_AWAKE_DUR1 = 0x08,
- _GYR_AM_SET_AWAKE_DUR_MASK = 3,
- _GYR_AM_SET_AWAKE_DUR_SHIFT = 2
-
- // 0x10-0x80 reserved
- } GYR_AM_SET_BITS_T;
-
- /**
- * GYR_AM_SET_SLOPE_SAMPLES values
- */
- typedef enum {
- SLOPE_SAMPLES_8 = 0, // 8 samples
- SLOPE_SAMPLES_16 = 1,
- SLOPE_SAMPLES_32 = 2,
- SLOPE_SAMPLES_64 = 3
- } SLOPE_SAMPLES_T;
-
- /**
- * BNO055 constructor.
- *
- * By default, the constructor sets the acceleration units to
- * m/s^2, gyro and Euler units to degrees, and temperature to
- * celcius. It then enters the NDOF fusion mode.
- *
- * In addition, the internal clock is used so that compatibility
- * with other implementations is assured. If you are using a
- * device with an external clock, call setClockExternal(true) to
- * enable it.
- *
- * @param bus I2C bus to use.
- * @param address The address for this device.
- */
- BNO055(int bus=BNO055_I2C_BUS, uint8_t addr=BNO055_DEFAULT_ADDR);
-
- /**
- * BNO055 Destructor.
- */
- ~BNO055();
-
- /**
- * Update the internal stored values from sensor data.
- */
- void update();
-
- /**
- * Return the chip ID.
- *
- * @return The chip ID (BNO055_CHIPID).
- */
- uint8_t getChipID();
-
- /**
- * Return the accelerometer chip ID.
- *
- * @return The chip ID.
- */
- uint8_t getACCID();
-
- /**
- * Return the magnetometer chip ID.
- *
- * @return The chip ID.
- */
- uint8_t getMAGID();
-
- /**
- * Return the gyroscope chip ID.
- *
- * @return The chip ID.
- */
- uint8_t getGYRID();
-
- /**
- * Return the fusion firmware revison.
- *
- * @return The firmware revison.
- */
- uint16_t getSWRevID();
-
- /**
- * Return the bootloader ID.
- *
- * @return The bootloader ID.
- */
- uint8_t getBootLoaderID();
-
- /**
- * Enable or disables the use of the external clock. The Adafriut
- * device does contain an external clock which might be more
- * stable. By default, the internal clock is used.
- *
- * @param extClock true to use external clock, false otherwise.
- */
- void setClockExternal(bool extClock);
-
- /**
- * Select the temperature source. This can be the accelerometer
- * or the gyroscope. By default, the accelerometer temperature is
- * used as the source.
- *
- * @param src One of the TEMP_SOURCES_T values.
- */
- void setTemperatureSource(TEMP_SOURCES_T src);
-
- /**
- * Select the temperature units. This can be the Fahrenheit or
- * Celcius.
- *
- * @param celcius true for Celius, false for Fahrenheit.
- */
- void setTemperatureUnits(bool celcius);
-
- /**
- * Set the operating mode for the device. This places the device
- * into a config mode, one of 7 non-fusion modes, or one of 5
- * fusion modes. All stored sensor data is cleared when switching
- * modes. The device must be in config mode for most
- * configuration operations. See the datasheet for details.
- *
- * @param mode One of the OPERATION_MODES_T values.
- */
- void setOperationMode(OPERATION_MODES_T mode);
-
- /**
- * Reboot the sensor. This is equivalent to a power on reset.
- * All calibration data will be lost, and the device must be
- * recalibrated.
- */
- void resetSystem();
-
- /**
- * Read the calibration status registers and return them. The
- * values range from 0 (uncalibrated) to 3 (fully calibrated).
- *
- * @param mag The calibration status of the magnetometer.
- * @param acc The calibration status of the accelerometer.
- * @param mag The calibration status of the gyroscope.
- * @param mag The calibration status of the overall system.
- */
- void getCalibrationStatus(int *mag, int *acc, int *gyr, int *sys);
-
- /**
- * Read the calibration status registers and return them as an
- * integer array. The values range from 0 (uncalibrated) to 3
- * (fully calibrated).
- *
- * @return An integer array containing the values in the order:
- * mag, acc, gyr, and sys.
- */
- int *getCalibrationStatus();
-
- /**
- * Read the calibration status registers and return true or false,
- * indicating whether all of the calibration parameters are fully
- * calibrated.
- *
- * @return true if all 4 calibration parameters are fully
- * calibrated, else false.
- */
- bool isFullyCalibrated();
-
- /**
- * Read the calibration data and return it as a string. This data
- * can then be saved for later reuse by writeCalibrationData() to
- * restore calibration data after a reset.
- *
- * @return string representing calibration data.
- */
- std::string readCalibrationData();
-
- /**
- * Write previously saved calibration data to the calibration
- * registers.
- *
- * @param string representing calibration data, as returned by
- * readCalibrationData().
- */
- void writeCalibrationData(std::string calibData);
-
- /**
- * Return the current measured temperature. Note, this is not
- * ambient temperature - this is the temperature of the selected
- * source on the chip. update() must have been called prior to
- * calling this method.
- *
- * @param fahrenheit true to return data in Fahrenheit, false for
- * Celicus. Celcius is the default.
- * @return The temperature in degrees Celcius or Fahrenheit.
- */
- float getTemperature(bool fahrenheit=false);
-
- /**
- * Return current orientation fusion data in the form of Euler
- * Angles. By default, the returned values are in degrees.
- * update() must have been called prior to calling this method.
- *
- * @param heading Pointer to a floating point value that will have
- * the current heading angle placed into it.
- * @param roll Pointer to a floating point value that will have
- * the current roll angle placed into it.
- * @param pitch Pointer to a floating point value that will have
- * the current pitch angle placed into it.
- */
- void getEulerAngles(float *heading, float *roll, float *pitch);
-
- /**
- * Return current orientation fusion data in the form of Euler
- * Angles as a floating point array. By default, the returned
- * values are in degrees. update() must have been called prior to
- * calling this method.
- *
- * @return A floating point array containing heading, roll, and
- * pitch, in that order.
- */
- float *getEulerAngles();
-
- /**
- * Return current orientation fusion data in the form of
- * Quaternions. update() must have been called prior to calling
- * this method.
- *
- * @param w Pointer to a floating point value that will have
- * the current w component placed into it.
- * @param x Pointer to a floating point value that will have
- * the current x component placed into it.
- * @param y Pointer to a floating point value that will have
- * the current y component placed into it.
- * @param z Pointer to a floating point value that will have
- * the current z component placed into it.
- */
- void getQuaternions(float *w, float *x, float *y, float *z);
-
- /**
- * Return current orientation fusion data in the form of
- * Quaternions, as a floating point array. update() must have
- * been called prior to calling this method.
- *
- * @return A floating point array containing w, x, y, and z in
- * that order.
- */
- float *getQuaternions();
-
- /**
- * Return current orientation fusion data in the form of Linear
- * Acceleration. By default the returned values are in meters
- * per-second squared (m/s^2). update() must have been called
- * prior to calling this method.
- *
- * @param x Pointer to a floating point value that will have
- * the current x component placed into it.
- * @param y Pointer to a floating point value that will have
- * the current y component placed into it.
- * @param z Pointer to a floating point value that will have
- * the current z component placed into it.
- */
- void getLinearAcceleration(float *x, float *y, float *z);
-
- /**
- * Return current orientation fusion data in the form of Linear
- * Acceleration, as a floating point array. update() must have
- * been called prior to calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getLinearAcceleration();
-
- /**
- * Return current orientation fusion data in the form of a Gravity
- * Vector per-axis. By default the returned values are in meters
- * per-second squared (m/s^2). update() must have been called
- * prior to calling this method.
- *
- * @param x Pointer to a floating point value that will have
- * the current x component placed into it.
- * @param y Pointer to a floating point value that will have
- * the current y component placed into it.
- * @param z Pointer to a floating point value that will have
- * the current z component placed into it.
- */
- void getGravityVectors(float *x, float *y, float *z);
-
- /**
- * Return current orientation fusion data in the form of a Gravity
- * Vector per-axis as a floating point array. update() must have
- * been called prior to calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getGravityVectors();
-
- /**
- * Return uncompensated accelerometer data (non-fusion). In
- * fusion modes, this data will be of little value. By default
- * the returned values are in meters per-second squared (m/s^2).
- * update() must have been called prior to calling this method.
- *
- * @param x Pointer to a floating point value that will have
- * the current x component placed into it.
- * @param y Pointer to a floating point value that will have
- * the current y component placed into it.
- * @param z Pointer to a floating point value that will have
- * the current z component placed into it.
- */
- void getAccelerometer(float *x, float *y, float *z);
-
- /**
- * Return current uncompensated accelerometer (non-fusion) data in
- * the form of a floating point array. By default the returned
- * values are in meters per-second squared (m/s^2). update() must
- * have been called prior to calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getAccelerometer();
-
- /**
- * Return uncompensated magnetometer data (non-fusion). In fusion
- * modes, this data will be of little value. The returned values
- * are in micro-teslas (uT). update() must have been called prior
- * to calling this method.
- *
- * @param x Pointer to a floating point value that will have
- * the current x component placed into it.
- * @param y Pointer to a floating point value that will have
- * the current y component placed into it.
- * @param z Pointer to a floating point value that will have
- * the current z component placed into it.
- */
- void getMagnetometer(float *x, float *y, float *z);
-
- /**
- * Return current uncompensated magnetometer (non-fusion) data in
- * the form of a floating point array. The returned values are in
- * micro-teslas (uT). update() must have been called prior to
- * calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getMagnetometer();
-
- /**
- * Return uncompensated gyroscope data (non-fusion). In fusion
- * modes, this data will be of little value. By default the
- * returned values are in meters per-second squared (m/s^2).
- * update() must have been called prior to calling this method.
- *
- * @param x Pointer to a floating point value that will have
- * the current x component placed into it.
- * @param y Pointer to a floating point value that will have
- * the current y component placed into it.
- * @param z Pointer to a floating point value that will have
- * the current z component placed into it.
- */
- void getGyroscope(float *x, float *y, float *z);
-
- /**
- * Return current uncompensated gyroscope (non-fusion) data in the
- * form of a floating point array. By default the returned values
- * are in meters per-second squared (m/s^2). update() must have
- * been called prior to calling this method.
- *
- * @return A floating point array containing x, y, and z in
- * that order.
- */
- float *getGyroscope();
-
- /**
- * Set the bandwidth, range, and power modes of the accelerometer.
- * In fusion modes, these values will be ignored.
- *
- * @param range One of the ACC_RANGE_T values.
- * @param bw One of the ACC_BW_T values.
- * @param pwr One of the ACC_PWR_MODE_T values.
- */
- void setAccelerationConfig(ACC_RANGE_T range, ACC_BW_T bw,
- ACC_PWR_MODE_T pwr);
-
- /**
- * Set the output data rate, operating mode and power mode of the
- * magnetometer. In fusion modes, these values will be ignored.
- *
- * @param odr One of the MAG_ODR_T values.
- * @param opr One of the MAG_OPR_T values.
- * @param pwr One of the MAG_POWER_T values.
- */
- void setMagnetometerConfig(MAG_ODR_T odr, MAG_OPR_T opr,
- MAG_POWER_T pwr);
-
- /**
- * Set the range, bandwidth and power modes of the gyroscope. In
- * fusion modes, these values will be ignored.
- *
- * @param range One of the GYR_RANGE_T values.
- * @param bw One of the GYR_BW_T values.
- * @param pwr One of the GYR_POWER_MODE_T values.
- */
- void setGyroscopeConfig(GYR_RANGE_T range, GYR_BW_T bw,
- GYR_POWER_MODE_T pwr);
-
- /**
- * Set the unit of measurement for the accelerometer related
- * sensor values. The choices are mg (milligrams) or meters
- * per-second squared (m/s^2). The default is m/s^2.
- *
- * @param mg true for mg, false for m/s^2.
- */
- void setAccelerometerUnits(bool mg=false);
-
- /**
- * Set the unit of measurement for the gyroscope related sensor
- * values. The choices are degrees and radians. The default is
- * degrees.
- *
- * @param radians true for radians, false for degrees.
- */
- void setGyroscopeUnits(bool radians=false);
-
- /**
- * Set the unit of measurement for the Euler Angle related sensor
- * values. The choices are degrees and radians. The default is
- * degrees.
- *
- * @param radians true for radians, false for degrees.
- */
- void setEulerUnits(bool radians=false);
-
- /**
- * Reset all interrupt status bits and interrupt output.
- */
- void resetInterruptStatus();
-
- /**
- * Return the interrupt status register. This is a bitmask of the
- * INT_STA_BITS_T bits.
- *
- * @return a bitmask of INT_STA_BITS_T bits.
- */
- uint8_t getInterruptStatus();
-
- /**
- * Return the interrupt enables register. This is a bitmask of the
- * INT_STA_BITS_T bits.
- *
- * @return a bitmask of INT_STA_BITS_T bits currently set in the
- * enable register.
- */
- uint8_t getInterruptEnable();
-
- /**
- * Set the interrupt enable register. This is composed of a
- * bitmask of the INT_STA_BITS_T bits.
- *
- * @param enables a bitmask of INT_STA_BITS_T bits to enable
- */
- void setInterruptEnable(uint8_t enables);
-
- /**
- * Return the interrupt mask register. This is a bitmask of the
- * INT_STA_BITS_T bits. The interrupt mask is used to mask off
- * enabled interrupts from generating a hardware interrupt. The
- * interrupt status register can still be used to detect masked
- * interrupts if they are enabled.
- *
- * @return a bitmask of INT_STA_BITS_T bits currently set in the
- * interrupt mask register.
- */
- uint8_t getInterruptMask();
-
- /**
- * Set the interrupt mask register. This is a bitmask of the
- * INT_STA_BITS_T bits. The interrupt mask is used to mask off
- * enabled interrupts from generating a hardware interrupt. The
- * interrupt status register can still be used to detect masked
- * interrupts if they are enabled.
- *
- * @param a bitmask of INT_STA_BITS_T bits to set in the interrupt
- * mask register.
- */
- void setInterruptMask(uint8_t mask);
-
- /**
- * Return the value of the system status register. This method
- * can be used to determine the overall status of the device.
- *
- * @return One of the SYS_STATUS_T values.
- */
- SYS_STATUS_T getSystemStatus();
-
- /**
- * Return the value of the system error register. This mathod can
- * be used to determine a variety of system related error
- * conditions.
- *
- * @return One of the SYS_ERR_T values.
- */
- SYS_ERR_T getSystemError();
-
-
-#if defined(SWIGJAVA) || defined(JAVACALLBACK)
- void installISR(int gpio, mraa::Edge level, jobject runnable);
-#else
- /**
- * install an interrupt handler.
- *
- * @param gpio gpio pin to use as interrupt pin
- * @param level the interrupt trigger level (one of mraa::Edge
- * values). Make sure that you have configured the interrupt pin
- * properly for whatever level you choose.
- * @param isr the interrupt handler, accepting a void * argument
- * @param arg the argument to pass the the interrupt handler
- */
- void installISR(int gpio, mraa::Edge level,
- void (*isr)(void *), void *arg);
-#endif
-
- /**
- * uninstall a previously installed interrupt handler
- *
- */
- void uninstallISR();
-
- protected:
- mraa::I2c m_i2c;
- mraa::Gpio *m_gpioIntr;
- uint8_t m_addr;
-
- // always stored in C
- float m_temperature;
-
- // uncompensated data
-
- // mag data
- float m_magX;
- float m_magY;
- float m_magZ;
-
- // acc data
- float m_accX;
- float m_accY;
- float m_accZ;
-
- // acc units
- float m_accUnitScale;
-
- // gyr data
- float m_gyrX;
- float m_gyrY;
- float m_gyrZ;
-
- // gyr units
- float m_gyrUnitScale;
-
- // eul (euler angle) data
- float m_eulHeading;
- float m_eulRoll;
- float m_eulPitch;
-
- // eul units
- float m_eulUnitScale;
-
- // qua (quaternion) data
- float m_quaW;
- float m_quaX;
- float m_quaY;
- float m_quaZ;
-
- // lia (linear acceleration) data
- float m_liaX;
- float m_liaY;
- float m_liaZ;
-
- // grv (gravity vector) data
- float m_grvX;
- float m_grvY;
- float m_grvZ;
-
- void clearData();
- bool updateFusionData();
- bool updateNonFusionData();
- void setPage(uint8_t page, bool force=false);
-
- /**
- * Read a register.
- *
- * @param reg The register to read
- * @return The value of the register
- */
- uint8_t readReg(uint8_t reg);
-
- /**
- * Read contiguous registers into a buffer.
- *
- * @param buffer The buffer to store the results
- * @param len The number of registers to read
- */
- void readRegs(uint8_t reg, uint8_t *buffer, int len);
-
- /**
- * Write to a register
- *
- * @param reg The register to write to
- * @param val The value to write
- * @return true if successful, false otherwise
- */
- bool writeReg(uint8_t reg, uint8_t val);
-
- /**
- * Write data to contiguous registers
- *
- * @param reg The starting register to write to
- * @param buffer The buffer containing the data to write
- * @param len The number of bytes to write
- * @return true if successful, false otherwise
- */
- bool writeRegs(uint8_t reg, uint8_t *buffer, int len);
-
- private:
- int m_currentPage;
- OPERATION_MODES_T m_currentMode;
- bool m_tempIsC;
-
- // Adding a private function definition for java bindings
-#if defined(SWIGJAVA) || defined(JAVACALLBACK)
- void installISR(int gpio, mraa::Edge level,
- void (*isr)(void *), void *arg);
-#endif
- };
-}
diff --git a/peripheral/libupm/src/bno055/javaupm_bno055.i b/peripheral/libupm/src/bno055/javaupm_bno055.i
deleted file mode 100644
index 455374a..0000000
--- a/peripheral/libupm/src/bno055/javaupm_bno055.i
+++ /dev/null
@@ -1,93 +0,0 @@
-%module javaupm_bno055
-%include "../upm.i"
-%include "cpointer.i"
-%include "typemaps.i"
-%include "arrays_java.i";
-%include "../java_buffer.i"
-
-%apply int {mraa::Edge};
-%apply float *INOUT { float *x, float *y, float *z };
-%apply float *INOUT { float *heading, float *roll, float *pitch };
-
-%typemap(jni) float* "jfloatArray"
-%typemap(jstype) float* "float[]"
-%typemap(jtype) float* "float[]"
-
-%typemap(javaout) float* {
- return $jnicall;
-}
-
-%typemap(jni) int* "jintArray"
-%typemap(jstype) int* "int[]"
-%typemap(jtype) int* "int[]"
-
-%typemap(javaout) int* {
- return $jnicall;
-}
-
-
-%typemap(out) float *getAccelerometer {
- $result = JCALL1(NewFloatArray, jenv, 3);
- JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
-}
-
-%typemap(out) float *getMagnetometer {
- $result = JCALL1(NewFloatArray, jenv, 3);
- JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
-}
-
-%typemap(out) float *getGyroscope {
- $result = JCALL1(NewFloatArray, jenv, 3);
- JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
-}
-
-%typemap(out) float *getEulerAngles {
- $result = JCALL1(NewFloatArray, jenv, 3);
- JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
-}
-
-%typemap(out) float *getQuaternions {
- $result = JCALL1(NewFloatArray, jenv, 4);
- JCALL4(SetFloatArrayRegion, jenv, $result, 0, 4, $1);
-}
-
-%typemap(out) float *getLinearAcceleration {
- $result = JCALL1(NewFloatArray, jenv, 3);
- JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
-}
-
-%typemap(out) float *getGravityVectors {
- $result = JCALL1(NewFloatArray, jenv, 3);
- JCALL4(SetFloatArrayRegion, jenv, $result, 0, 3, $1);
-}
-
-%typemap(out) int *getCalibrationStatus {
- $result = JCALL1(NewIntArray, jenv, 4);
- JCALL4(SetIntArrayRegion, jenv, $result, 0, 4, (const int*)$1);
-}
-
-%ignore getCalibrationStatus(int *, int *, int *, int *);
-%ignore getAccelerometer(float *, float *, float *);
-%ignore getMagnetometer(float *, float *, float *);
-%ignore getGyroscope(float *, float *, float *);
-%ignore getEulerAngles(float *, float *, float *);
-%ignore getQuaternions(float *, float *, float *, float *);
-%ignore getLinearAcceleration(float *, float *, float *);
-%ignore getGravityVectors(float *, float *, float *);
-
-%{
- #include "bno055.hpp"
-%}
-
-%include "bno055.hpp"
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_bno055");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/bno055/jsupm_bno055.i b/peripheral/libupm/src/bno055/jsupm_bno055.i
deleted file mode 100644
index 7fa679b..0000000
--- a/peripheral/libupm/src/bno055/jsupm_bno055.i
+++ /dev/null
@@ -1,12 +0,0 @@
-%module jsupm_bno055
-%include "../upm.i"
-%include "cpointer.i"
-
-/* Send "int *" and "float *" to JavaScript as intp and floatp */
-%pointer_functions(int, intp);
-%pointer_functions(float, floatp);
-
-%include "bno055.hpp"
-%{
- #include "bno055.hpp"
-%}
diff --git a/peripheral/libupm/src/bno055/pyupm_bno055.i b/peripheral/libupm/src/bno055/pyupm_bno055.i
deleted file mode 100644
index 23eead2..0000000
--- a/peripheral/libupm/src/bno055/pyupm_bno055.i
+++ /dev/null
@@ -1,22 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_bno055
-%include "../upm.i"
-%include "cpointer.i"
-
-%include "stdint.i"
-
-/* Send "int *" and "float *" to python as intp and floatp */
-%pointer_functions(int, intp);
-%pointer_functions(float, floatp);
-
-%feature("autodoc", "3");
-
-#ifdef DOXYGEN
-%include "bno055_doc.i"
-#endif
-
-%include "bno055.hpp"
-%{
- #include "bno055.hpp"
-%}
diff --git a/peripheral/libupm/src/buzzer/CMakeLists.txt b/peripheral/libupm/src/buzzer/CMakeLists.txt
index 49f5cce..02749c0 100644
--- a/peripheral/libupm/src/buzzer/CMakeLists.txt
+++ b/peripheral/libupm/src/buzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "buzzer")
set (libdescription "upm buzzer")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/buzzer/buzzer.cxx b/peripheral/libupm/src/buzzer/buzzer.cxx
index 4150f63..8ef8922 100644
--- a/peripheral/libupm/src/buzzer/buzzer.cxx
+++ b/peripheral/libupm/src/buzzer/buzzer.cxx
@@ -27,7 +27,7 @@
#include <stdexcept>
#include <unistd.h>
-#include "buzzer.hpp"
+#include "buzzer.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/buzzer/buzzer.hpp b/peripheral/libupm/src/buzzer/buzzer.h
index ca3c808..dfeb47d 100644
--- a/peripheral/libupm/src/buzzer/buzzer.hpp
+++ b/peripheral/libupm/src/buzzer/buzzer.h
@@ -26,13 +26,13 @@
#include <string>
#include <mraa/pwm.h>
-#define DO 3800 // 262 Hz - C4
-#define RE 3400 // 294 Hz - D
-#define MI 3000 // 330 Hz - E
-#define FA 2900 // 349 Hz - F
-#define SOL 2550 // 392 Hz - G
-#define LA 2270 // 440 Hz - A
-#define SI 2000 // 494 Hz - B
+#define DO 3300 // 261 Hz 3830
+#define RE 2930 // 294 Hz
+#define MI 2600 // 329 Hz
+#define FA 2460 // 349 Hz
+#define SOL 2190 // 392 Hz
+#define LA 1960 // 440 Hz
+#define SI 1750 // 493 Hz
namespace upm {
@@ -80,7 +80,7 @@ class Buzzer {
* Plays a tone for a certain amount of time or indefinitely. When delay
* is not used, the sound can be stopped by calling stopSound().
*
- * @param note Note to play (DO, RE, MI, etc.) or frequency
+ * @param note Note to play (C, D, E, etc.) or frequency
* @param delay Time in microseconds for which to play the sound; if the value is
* 0, the sound is played indefinitely
*
diff --git a/peripheral/libupm/src/buzzer/javaupm_buzzer.i b/peripheral/libupm/src/buzzer/javaupm_buzzer.i
index ce8ed60..e647831 100644
--- a/peripheral/libupm/src/buzzer/javaupm_buzzer.i
+++ b/peripheral/libupm/src/buzzer/javaupm_buzzer.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "buzzer.hpp"
+ #include "buzzer.h"
%}
-%include "buzzer.hpp"
+%include "buzzer.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/buzzer/jsupm_buzzer.i b/peripheral/libupm/src/buzzer/jsupm_buzzer.i
index 4b7c452..d957892 100644
--- a/peripheral/libupm/src/buzzer/jsupm_buzzer.i
+++ b/peripheral/libupm/src/buzzer/jsupm_buzzer.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "buzzer.hpp"
+ #include "buzzer.h"
%}
-%include "buzzer.hpp"
+%include "buzzer.h"
diff --git a/peripheral/libupm/src/buzzer/pyupm_buzzer.i b/peripheral/libupm/src/buzzer/pyupm_buzzer.i
index 56de121..a58d139 100644
--- a/peripheral/libupm/src/buzzer/pyupm_buzzer.i
+++ b/peripheral/libupm/src/buzzer/pyupm_buzzer.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "buzzer.hpp"
+%include "buzzer.h"
%{
- #include "buzzer.hpp"
+ #include "buzzer.h"
%}
diff --git a/peripheral/libupm/src/cjq4435/CMakeLists.txt b/peripheral/libupm/src/cjq4435/CMakeLists.txt
index a5c4b8f..b9c954b 100644
--- a/peripheral/libupm/src/cjq4435/CMakeLists.txt
+++ b/peripheral/libupm/src/cjq4435/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "cjq4435")
set (libdescription "upm cjq4435 MOSFET module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/cjq4435/cjq4435.cxx b/peripheral/libupm/src/cjq4435/cjq4435.cxx
index d730624..43c2a56 100644
--- a/peripheral/libupm/src/cjq4435/cjq4435.cxx
+++ b/peripheral/libupm/src/cjq4435/cjq4435.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "cjq4435.hpp"
+#include "cjq4435.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/cjq4435/cjq4435.hpp b/peripheral/libupm/src/cjq4435/cjq4435.h
index 025cafc..025cafc 100644
--- a/peripheral/libupm/src/cjq4435/cjq4435.hpp
+++ b/peripheral/libupm/src/cjq4435/cjq4435.h
diff --git a/peripheral/libupm/src/cjq4435/javaupm_cjq4435.i b/peripheral/libupm/src/cjq4435/javaupm_cjq4435.i
index 414863d..a67fb5b 100644
--- a/peripheral/libupm/src/cjq4435/javaupm_cjq4435.i
+++ b/peripheral/libupm/src/cjq4435/javaupm_cjq4435.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "cjq4435.hpp"
+ #include "cjq4435.h"
%}
-%include "cjq4435.hpp"
+%include "cjq4435.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/cjq4435/jsupm_cjq4435.i b/peripheral/libupm/src/cjq4435/jsupm_cjq4435.i
index fa7be73..3fe19ee 100644
--- a/peripheral/libupm/src/cjq4435/jsupm_cjq4435.i
+++ b/peripheral/libupm/src/cjq4435/jsupm_cjq4435.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "cjq4435.hpp"
+ #include "cjq4435.h"
%}
-%include "cjq4435.hpp"
+%include "cjq4435.h"
diff --git a/peripheral/libupm/src/cjq4435/pyupm_cjq4435.i b/peripheral/libupm/src/cjq4435/pyupm_cjq4435.i
index c2f7354..706cd28 100644
--- a/peripheral/libupm/src/cjq4435/pyupm_cjq4435.i
+++ b/peripheral/libupm/src/cjq4435/pyupm_cjq4435.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "cjq4435.hpp"
+%include "cjq4435.h"
%{
- #include "cjq4435.hpp"
+ #include "cjq4435.h"
%}
diff --git a/peripheral/libupm/src/curieimu/CMakeLists.txt b/peripheral/libupm/src/curieimu/CMakeLists.txt
deleted file mode 100644
index a3230ff..0000000
--- a/peripheral/libupm/src/curieimu/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-include (CheckFunctionExists)
-include (CheckLibraryExists)
-include (CheckIncludeFiles)
-check_library_exists (${MRAA_LIBRARIES} mraa_firmata_init "" HAVE_FIRMATA)
-if (HAVE_FIRMATA)
- set (libname "curieimu")
- set (libdescription "upm Curie IMU via Firmata")
- set (module_src ${libname}.cpp)
- set (module_hpp ${libname}.hpp)
- upm_module_init ()
-endif ()
diff --git a/peripheral/libupm/src/curieimu/curieimu.cpp b/peripheral/libupm/src/curieimu/curieimu.cpp
deleted file mode 100644
index 00df7a3..0000000
--- a/peripheral/libupm/src/curieimu/curieimu.cpp
+++ /dev/null
@@ -1,458 +0,0 @@
-/*
- * Author: Brendan Le Foll <brendan.le.foll@intel.com>
- * Author: Ron Evans (@deadprogram)
- * Author: Justin Zemlyansky (@JustInDevelopment)
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-#include <string>
-#include <string.h>
-#include <stdexcept>
-#include <unistd.h>
-#include <stdlib.h>
-#include <pthread.h>
-
-#include "curieimu.hpp"
-
-using namespace upm;
-
-static CurieImu* awaitingReponse;
-
-CurieImu::CurieImu (int subplatformoffset)
-{
- m_firmata = mraa_firmata_init(FIRMATA_CURIE_IMU);
- if (m_firmata == NULL) {
- throw std::invalid_argument(std::string(__FUNCTION__) +
- ": mraa_firmata_init() failed");
- return;
- }
-
- if (pthread_mutex_init(&m_responseLock, NULL)) {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": pthread_mutex_init(m_responseLock) failed");
- return;
- }
-
- if (pthread_cond_init(&m_responseCond, NULL)) {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": pthread_cond_init(m_responseCond) failed");
- return;
- }
-}
-
-CurieImu::~CurieImu()
-{
- pthread_mutex_destroy(&m_responseLock);
- pthread_cond_destroy(&m_responseCond);
-}
-
-void
-CurieImu::lock()
-{
- pthread_mutex_lock(&m_responseLock);
-}
-
-void
-CurieImu::unlock()
-{
- pthread_mutex_unlock(&m_responseLock);
-}
-
-void
-CurieImu::waitForResponse()
-{
- awaitingReponse = this;
- pthread_cond_wait(&m_responseCond, &m_responseLock);
-}
-
-void
-CurieImu::proceed()
-{
- pthread_cond_broadcast(&m_responseCond);
-}
-
-void
-CurieImu::setResults(uint8_t* buf, int length)
-{
- m_results = new char(length);
- memcpy((void*)m_results, (void*)buf, length);
-}
-
-/*
-* Handles a single syncronous response being returned from Firmata
-*
-* @param buffer the data beinig returned from Firmata
-* @param length length of results buffer
-*/
-static void
-handleSyncResponse(uint8_t* buf, int length)
-{
- awaitingReponse->setResults(buf, length);
- awaitingReponse->proceed();
-}
-
-/*
-* Handles asyncronous responses being returned from Firmata
-*
-* @param buffer the data beinig returned from Firmata
-* @param length length of results buffer
-*/
-static void
-handleAsyncResponses(uint8_t* buf, int length)
-{
- awaitingReponse->setResults(buf, length);
- awaitingReponse->processResponse();
-}
-
-void
-CurieImu::processResponse()
-{
- switch(m_results[2]) {
- case FIRMATA_CURIE_IMU_SHOCK_DETECT:
- {
- IMUDataItem* item = new IMUDataItem();
- item->axis = m_results[3];
- item->direction = m_results[4];
- m_shockData.push(item);
- break;
- }
- case FIRMATA_CURIE_IMU_STEP_COUNTER:
- {
- int count = ((m_results[3] & 0x7f) | ((m_results[4] & 0x7f) << 7));
- m_stepData.push(count);
- break;
- }
- case FIRMATA_CURIE_IMU_TAP_DETECT:
- {
- IMUDataItem* item = new IMUDataItem();
- item->axis = m_results[3];
- item->direction = m_results[4];
- m_tapData.push(item);
- break;
- }
- }
-
- return;
-}
-
-int16_t*
-CurieImu::getAccel()
-{
- return &m_accel[0];
-}
-
-int16_t
-CurieImu::getAccelX()
-{
- return m_accel[X];
-}
-
-int16_t
-CurieImu::getAccelY()
-{
- return m_accel[Y];
-}
-
-int16_t
-CurieImu::getAccelZ()
-{
- return m_accel[Z];
-}
-
-int16_t*
-CurieImu::getGyro()
-{
- return &m_gyro[0];
-}
-
-int16_t
-CurieImu::getGyroX()
-{
- return m_gyro[X];
-}
-
-int16_t
-CurieImu::getGyroY()
-{
- return m_gyro[Y];
-}
-
-int16_t
-CurieImu::getGyroZ()
-{
- return m_gyro[Z];
-}
-
-int16_t*
-CurieImu::getMotion()
-{
- return &m_motion[0];
-}
-
-void
-CurieImu::updateAccel()
-{
- char message[4];
- message[0] = FIRMATA_START_SYSEX;
- message[1] = FIRMATA_CURIE_IMU;
- message[2] = FIRMATA_CURIE_IMU_READ_ACCEL;
- message[3] = FIRMATA_END_SYSEX;
-
- lock();
-
- mraa_firmata_response_stop(m_firmata);
- mraa_firmata_response(m_firmata, handleSyncResponse);
- mraa_firmata_write_sysex(m_firmata, &message[0], 4);
-
- waitForResponse();
-
- m_accel[0] = ((m_results[3] & 0x7f) | ((m_results[4] & 0x7f) << 7));
- m_accel[1] = ((m_results[5] & 0x7f) | ((m_results[6] & 0x7f) << 7));
- m_accel[2] = ((m_results[7] & 0x7f) | ((m_results[8] & 0x7f) << 7));
-
- delete m_results;
- unlock();
-
- return;
-}
-
-void
-CurieImu::updateGyro()
-{
- char message[4];
- message[0] = FIRMATA_START_SYSEX;
- message[1] = FIRMATA_CURIE_IMU;
- message[2] = FIRMATA_CURIE_IMU_READ_GYRO;
- message[3] = FIRMATA_END_SYSEX;
-
- lock();
-
- mraa_firmata_response_stop(m_firmata);
- mraa_firmata_response(m_firmata, handleSyncResponse);
- mraa_firmata_write_sysex(m_firmata, &message[0], 4);
-
- waitForResponse();
-
- m_gyro[0] = ((m_results[3] & 0x7f) | ((m_results[4] & 0x7f) << 7));
- m_gyro[1] = ((m_results[5] & 0x7f) | ((m_results[6] & 0x7f) << 7));
- m_gyro[2] = ((m_results[7] & 0x7f) | ((m_results[8] & 0x7f) << 7));
-
- delete m_results;
- unlock();
-
- return;
-}
-
-void
-CurieImu::updateMotion()
-{
- char message[4];
- message[0] = FIRMATA_START_SYSEX;
- message[1] = FIRMATA_CURIE_IMU;
- message[2] = FIRMATA_CURIE_IMU_READ_MOTION;
- message[3] = FIRMATA_END_SYSEX;
-
- lock();
-
- mraa_firmata_response_stop(m_firmata);
- mraa_firmata_response(m_firmata, handleSyncResponse);
- mraa_firmata_write_sysex(m_firmata, &message[0], 4);
-
- waitForResponse();
-
- m_motion[0] = ((m_results[3] & 0x7f) | ((m_results[4] & 0x7f) << 7));
- m_motion[1] = ((m_results[5] & 0x7f) | ((m_results[6] & 0x7f) << 7));
- m_motion[2] = ((m_results[7] & 0x7f) | ((m_results[8] & 0x7f) << 7));
- m_motion[3] = ((m_results[9] & 0x7f) | ((m_results[10] & 0x7f) << 7));
- m_motion[4] = ((m_results[11] & 0x7f) | ((m_results[12] & 0x7f) << 7));
- m_motion[5] = ((m_results[13] & 0x7f) | ((m_results[13] & 0x7f) << 7));
-
- for (int i=0; i<3; i++)
- m_accel[i] = m_motion[i];
-
- for (int i=0; i<3; i++)
- m_gyro[i] = m_motion[i+3];
-
- delete m_results;
- unlock();
-
- return;
-}
-
-int16_t
-CurieImu::getTemperature()
-{
- char message[4];
- message[0] = FIRMATA_START_SYSEX;
- message[1] = FIRMATA_CURIE_IMU;
- message[2] = FIRMATA_CURIE_IMU_READ_TEMP;
- message[3] = FIRMATA_END_SYSEX;
-
- lock();
-
- mraa_firmata_response_stop(m_firmata);
- mraa_firmata_response(m_firmata, handleSyncResponse);
- mraa_firmata_write_sysex(m_firmata, &message[0], 4);
-
- waitForResponse();
-
- int16_t result;
- result = ((m_results[3] & 0x7f) | ((m_results[4] & 0x7f) << 7));
- result += ((m_results[5] & 0x7f) | ((m_results[6] & 0x7f) << 7)) << 8;
-
- delete m_results;
- unlock();
-
- return result;
-}
-
-int16_t
-CurieImu::getAxis()
-{
- return m_axis;
-}
-
-int16_t
-CurieImu::getDirection()
-{
- return m_direction;
-}
-
-void
-CurieImu::enableShockDetection(bool enable)
-{
- char message[5];
- message[0] = FIRMATA_START_SYSEX;
- message[1] = FIRMATA_CURIE_IMU;
- message[2] = FIRMATA_CURIE_IMU_SHOCK_DETECT;
- message[3] = enable;
- message[4] = FIRMATA_END_SYSEX;
-
- lock();
-
- mraa_firmata_response_stop(m_firmata);
- mraa_firmata_response(m_firmata, handleAsyncResponses);
- mraa_firmata_write_sysex(m_firmata, &message[0], 5);
-
- awaitingReponse = this;
- unlock();
-
- return;
-}
-
-bool
-CurieImu::isShockDetected()
-{
- return (m_shockData.size() > 0);
-}
-
-void
-CurieImu::getNextShock()
-{
- if (m_shockData.size() > 0) {
- IMUDataItem* item = m_shockData.front();
- m_axis = item->axis;
- m_direction = item->direction;
- m_shockData.pop();
- delete item;
- }
-}
-
-void
-CurieImu::enableStepCounter(bool enable)
-{
- char message[5];
- message[0] = FIRMATA_START_SYSEX;
- message[1] = FIRMATA_CURIE_IMU;
- message[2] = FIRMATA_CURIE_IMU_STEP_COUNTER;
- message[3] = enable;
- message[4] = FIRMATA_END_SYSEX;
-
- lock();
-
- mraa_firmata_response_stop(m_firmata);
- mraa_firmata_response(m_firmata, handleAsyncResponses);
- mraa_firmata_write_sysex(m_firmata, &message[0], 5);
-
- awaitingReponse = this;
- unlock();
-
- return;
-}
-
-bool
-CurieImu::isStepDetected()
-{
- return (m_stepData.size() > 0);
-}
-
-int16_t
-CurieImu::getStepCount()
-{
- int16_t count = 0;
- if (m_stepData.size() > 0) {
- count = m_stepData.front();
- m_stepData.pop();
- }
- return count;
-}
-
-void
-CurieImu::enableTapDetection(bool enable)
-{
- char message[5];
- message[0] = FIRMATA_START_SYSEX;
- message[1] = FIRMATA_CURIE_IMU;
- message[2] = FIRMATA_CURIE_IMU_TAP_DETECT;
- message[3] = enable;
- message[4] = FIRMATA_END_SYSEX;
-
- lock();
-
- mraa_firmata_response_stop(m_firmata);
- mraa_firmata_response(m_firmata, handleAsyncResponses);
- mraa_firmata_write_sysex(m_firmata, &message[0], 5);
-
- awaitingReponse = this;
- unlock();
-
- return;
-}
-
-bool
-CurieImu::isTapDetected()
-{
- return (m_tapData.size() > 0);
-}
-
-void
-CurieImu::getNextTap()
-{
- if (m_tapData.size() > 0) {
- IMUDataItem* item = m_tapData.front();
- m_axis = item->axis;
- m_direction = item->direction;
- m_tapData.pop();
- delete item;
- }
-}
diff --git a/peripheral/libupm/src/curieimu/curieimu.hpp b/peripheral/libupm/src/curieimu/curieimu.hpp
deleted file mode 100644
index 61186cc..0000000
--- a/peripheral/libupm/src/curieimu/curieimu.hpp
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * Author: Brendan Le Foll <brendan.le.foll@intel.com>
- * Author: Ron Evans (@deadprogram)
- * Author: Justin Zemlyansky (@JustInDevelopment)
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <mraa/firmata.h>
-#include <queue>
-
-namespace upm {
-
-/**
- * @brief CurieIMU sensor for Genuino 101 running Firmata
- * @defgroup curieimu libupm-curieimu
- * @ingroup firmata
- */
-
-/**
- * @library curieimu
- * @sensor curieimu
- * @comname Curie IMU sensor over Genuino 101 running Firmata
- * @altname Curie Firmata IMU
- * @type firmata
- * @man firmata imu genuino
- * @con firmata
- *
- * @brief API for the Curie IMU via Firmata
- *
- * Curie IMU is a 6-axxis acclerometer
- *
- * This module has been tested on an Genuino 101 running ConfigurableFirmata with CurieIMU
- *
- * @snippet curieimu.cxx Interesting
- */
-
-#define FIRMATA_START_SYSEX 0xF0
-#define FIRMATA_END_SYSEX 0xF7
-#define FIRMATA_CURIE_IMU 0x11
-#define FIRMATA_CURIE_IMU_READ_ACCEL 0x00
-#define FIRMATA_CURIE_IMU_READ_GYRO 0x01
-#define FIRMATA_CURIE_IMU_READ_TEMP 0x02
-#define FIRMATA_CURIE_IMU_SHOCK_DETECT 0x03
-#define FIRMATA_CURIE_IMU_STEP_COUNTER 0x04
-#define FIRMATA_CURIE_IMU_TAP_DETECT 0x05
-#define FIRMATA_CURIE_IMU_READ_MOTION 0x06
-
-#define X 0
-#define Y 1
-#define Z 2
-
-struct IMUDataItem {
- int axis;
- int direction;
-};
-
-class CurieImu {
- public:
-
- /**
- * Instantiates a CurieImu object
- *
- * @param subplatformoffset Subplatform offset
- */
- CurieImu (int subplatform_offset=512);
-
- /**
- * Destructor for CurieImu object
- */
- ~CurieImu();
-
- /**
- * Updates the latest accelerometer readings by calling Firmata
- */
- void updateAccel();
-
- /**
- * Updates the latest gyroscope readings by calling Firmata
- */
- void updateGyro();
-
- /**
- * Updates the both the latest accelerometer & gyroscope readings
- * by calling Firmata
- */
- void updateMotion();
-
- /**
- * Returns last accelerometer reading X, Y, and Z axis
- *
- * @return pointer to array with X-axis, Y-axis & Z-axis value
- */
- int16_t* getAccel();
-
- /**
- * Returns last accelerometer reading X axis
- *
- * @return X-axis value
- */
- int16_t getAccelX();
-
- /**
- * Returns last accelerometer reading Y axis
- *
- * @return Y-axis value
- */
- int16_t getAccelY();
-
- /**
- * Returns last accelerometer reading Z axis
- *
- * @return Z-axis value
- */
- int16_t getAccelZ();
-
- /**
- * Read gyroscope X, Y, and Z axis
- *
- * @return pointer to array with X-axis, Y-axis & Z-axis value
- */
- int16_t* getGyro();
-
- /**
- * Returns last gyroscope reading X axis
- *
- * @return X-axis value
- */
- int16_t getGyroX();
-
- /**
- * Returns last gyroscope reading Y axis
- *
- * @return Y-axis value
- */
- int16_t getGyroY();
-
- /**
- * Returns last gyroscope reading Z axis
- *
- * @return Z-axis value
- */
- int16_t getGyroZ();
-
- /**
- * Reads the internal temperature
- *
- * @return 16-bit integer containing the scaled temperature reading
- */
- int16_t getTemperature();
-
- /**
- * Reads the X, Y, and Z axis of both gyroscope and accelerometer
- *
- * @return pointer to array with X-axis, Y-axis & Z-axis values for
- * accelerometer, and then X-axis, Y-axis & Z-axis values for
- * gyroscope
- */
- int16_t* getMotion();
-
- /**
- * Returns last shock or tap axis reading
- *
- * @return axis value
- */
- int16_t getAxis();
-
- /**
- * Returns last shock or tap direction reading
- *
- * @return direction value
- */
- int16_t getDirection();
-
- /**
- * Turns shock detection notifications on/off
- *
- * @param enable enables/disables notifications
- */
- void enableShockDetection(bool enable);
-
- /**
- * Has there been a shock detected?
- *
- * @return true if any unprocessed shock notifications are in the queue
- */
- bool isShockDetected();
-
- /**
- * Gets shock detect data from queue. Then m_axis gets axis data, and
- * m_direction gets direction data
- */
- void getNextShock();
-
- /**
- * Turns step counter notifications on/off
- *
- * @param enable enables/disables notifications
- */
- void enableStepCounter(bool enable);
-
- /**
- * Has there been a step detected?
- *
- * @return true if any unprocessed step notifications are in the queue
- */
- bool isStepDetected();
-
- /**
- * Gets step count data from queue
- *
- * @return the total number of steps taken
- */
- int16_t getStepCount();
-
- /**
- * Turns tap detection notifications on/off
- *
- * @param enable enables/disables notifications
- */
- void enableTapDetection(bool enable);
-
- /**
- * Has there been a tap detected?
- *
- * @return true if any unprocessed tap notifications are in the queue
- */
- bool isTapDetected();
-
- /**
- * Gets tap detect data from queue. Then m_axis gets axis data, and
- * m_direction gets direction data
- */
- void getNextTap();
-
- /**
- * Locks responses from Firmata
- */
- void lock();
-
- /**
- * Unlocks responses from Firmata
- */
- void unlock();
-
- /**
- * Wait for a response from Firmata before proceeding
- */
- void waitForResponse();
-
- /**
- * Proceed with original function call now that response
- * from Firmata has been received
- */
- void proceed();
-
- /**
- * Set results being returned from Firmata for processing
- *
- * @param buf is the buffer
- * @param length is the length of results buffer
- */
- void setResults(uint8_t* buf, int length);
-
- /**
- * Processes asyncronous responses returned from Firmata
- */
- void processResponse();
-
- private:
- mraa_firmata_context m_firmata;
- pthread_mutex_t m_responseLock;
- pthread_cond_t m_responseCond;
- char* m_results;
-
- std::queue<IMUDataItem*> m_shockData;
- std::queue<int> m_stepData;
- std::queue<IMUDataItem*> m_tapData;
-
- int16_t m_accel[3];
- int16_t m_gyro[3];
- int16_t m_motion[6];
-
- int16_t m_axis;
- int16_t m_direction;
-};
-
-}
diff --git a/peripheral/libupm/src/curieimu/javaupm_curieimu.i b/peripheral/libupm/src/curieimu/javaupm_curieimu.i
deleted file mode 100644
index 726f8c2..0000000
--- a/peripheral/libupm/src/curieimu/javaupm_curieimu.i
+++ /dev/null
@@ -1,42 +0,0 @@
-%module javaupm_curieimu
-%include "../upm.i"
-
-%{
- #include "curieimu.hpp"
-%}
-
-%typemap(jni) int16_t* "jshortArray"
-%typemap(jstype) int16_t* "short[]"
-%typemap(jtype) int16_t* "short[]"
-
-%typemap(javaout) int16_t* {
- return $jnicall;
-}
-
-%typemap(out) int16_t *getAccel {
- $result = JCALL1(NewShortArray, jenv, 3);
- JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1);
-}
-
-%typemap(out) int16_t *getGyro {
- $result = JCALL1(NewShortArray, jenv, 3);
- JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1);
-}
-
-%typemap(out) int16_t *getMotion {
- $result = JCALL1(NewShortArray, jenv, 6);
- JCALL4(SetShortArrayRegion, jenv, $result, 0, 6, (jshort*)$1);
-}
-
-%include "curieimu.hpp"
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_curieimu");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/curieimu/jsupm_curieimu.i b/peripheral/libupm/src/curieimu/jsupm_curieimu.i
deleted file mode 100644
index cf2955a..0000000
--- a/peripheral/libupm/src/curieimu/jsupm_curieimu.i
+++ /dev/null
@@ -1,15 +0,0 @@
-%module jsupm_curieimu
-%include "../upm.i"
-%include "../carrays_int16_t.i"
-
-// Adding this typemap because SWIG is converting int16 into a short by default
-// This forces SWIG to convert it correctly
-%typemap(out) int16_t* {
- jsresult = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 );
-}
-
-%{
- #include "curieimu.hpp"
-%}
-
-%include "curieimu.hpp"
diff --git a/peripheral/libupm/src/curieimu/pyupm_curieimu.i b/peripheral/libupm/src/curieimu/pyupm_curieimu.i
deleted file mode 100644
index d5a1f6d..0000000
--- a/peripheral/libupm/src/curieimu/pyupm_curieimu.i
+++ /dev/null
@@ -1,21 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_curieimu
-%include "../upm.i"
-%include "../carrays_int16_t.i"
-%include "stdint.i"
-
-%feature("autodoc", "3");
-
-#ifdef DOXYGEN
-%include "curieupm_doc.i"
-#endif
-
-%typemap(out) int16_t* {
- $result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 );
-}
-
-%include "curieimu.hpp"
-%{
- #include "curieimu.hpp"
-%}
diff --git a/peripheral/libupm/src/cwlsxxa/CMakeLists.txt b/peripheral/libupm/src/cwlsxxa/CMakeLists.txt
deleted file mode 100644
index 87755d0..0000000
--- a/peripheral/libupm/src/cwlsxxa/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set (libname "cwlsxxa")
-set (libdescription "upm Veris CWLSXXA CO2/Temperature/Humidity transmitter")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/cwlsxxa/cwlsxxa.cxx b/peripheral/libupm/src/cwlsxxa/cwlsxxa.cxx
deleted file mode 100644
index 8101698..0000000
--- a/peripheral/libupm/src/cwlsxxa/cwlsxxa.cxx
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-
-#include "cwlsxxa.hpp"
-
-using namespace upm;
-using namespace std;
-
-// for current loop reads that seems a little noisy, we average over
-// several aio reads.
-static const int maxSamples = 50;
-
-// conversion from celcius to fahrenheit
-
-static float c2f(float c)
-{
- return (c * (9.0 / 5.0) + 32.0);
-}
-
-
-CWLSXXA::CWLSXXA(int gPin, int hPin, int tPin, float rResistor, float aref) :
- m_aioCO2(gPin), m_aioHum(0), m_aioTemp(0)
-{
- m_hasHum = (hPin >= 0) ? true : false;
- m_hasTemp = (tPin >= 0) ? true : false;
-
- if (m_hasTemp)
- {
- m_aioTemp = new mraa::Aio(tPin);
- m_aResTemp = (1 << m_aioTemp->getBit());
- }
- else
- m_aResTemp = 0;
-
- if (m_hasHum)
- {
- m_aioHum = new mraa::Aio(hPin);
- m_aResHum = (1 << m_aioHum->getBit());
- }
- else
- m_aResHum = 0;
-
- m_aResCO2 = (1 << m_aioCO2.getBit());
-
- m_temperature = 0.0;
- m_humidity = 0.0;
- m_co2 = 0.0;
-
- m_aref = aref;
- m_rResistor = rResistor;
-}
-
-CWLSXXA::~CWLSXXA()
-{
- if (m_aioHum)
- delete m_aioHum;
- if (m_aioTemp)
- delete m_aioTemp;
-}
-
-void CWLSXXA::update()
-{
- // temperature
- int val;
- float volts;
- float milliamps = 0.0;
-
- int samples;
- if (m_rResistor)
- samples = maxSamples;
- else
- samples = 1;
-
-
- // temperature
- if (m_hasTemp)
- {
- // fortunately, this sensor always reports temperatures in C,
- // regardless of the configuration of the LCD display (for
- // models that have an LCD display)
-
- val = average(m_aioTemp, samples);
-
- volts = (float(val) * (m_aref / m_aResTemp));
-
- // valid range is 10-35C, current loop range is 16ma (20ma - 4ma)
- if (!m_rResistor)
- m_temperature = ((volts / m_aref) * 25.0) + 10.0;
- else
- {
- milliamps = ((volts / m_rResistor * 1000.0) - 4.0);
- if (milliamps < 0.0) // not connected
- milliamps = 0.0;
- m_temperature = (milliamps * (25.0 / 16.0)) + 10.0;
- }
- }
-
- // humidity
- if (m_hasHum)
- {
- val = average(m_aioHum, samples);
- volts = (float(val) * (m_aref / m_aResHum));
-
- // range is 0-100
- if (!m_rResistor)
- m_humidity = ((volts / m_aref) * 100.0);
- else
- {
- milliamps = ((volts / m_rResistor * 1000.0) - 4.0);
- if (milliamps < 0.0) // not connected
- milliamps = 0.0;
- m_humidity = milliamps * (100.0 / 16.0);
- }
- }
-
- // CO2
- val = average(&m_aioCO2, samples);
- volts = (float(val) * (m_aref / m_aResCO2));
-
- // CO2 range is 0-2000ppm
- if (!m_rResistor)
- m_co2 = ((volts / m_aref) * 2000.0);
- else
- {
- milliamps = ((volts / m_rResistor * 1000.0) - 4.0);
- if (milliamps < 0.0) // not connected
- milliamps = 0.0;
- m_co2 = milliamps * (2000.0 / 16.0);
- }
-}
-
-float CWLSXXA::getTemperature(bool fahrenheit)
-{
- if (fahrenheit)
- return c2f(m_temperature);
- else
- return m_temperature;
-}
-
-float CWLSXXA::getHumidity()
-{
- return m_humidity;
-}
-
-float CWLSXXA::getCO2()
-{
- return m_co2;
-}
-
-int CWLSXXA::average(mraa::Aio *aio, int samples)
-{
- if (samples <= 0)
- samples = 1;
-
- int avg = 0;
- for (int i=0; i<samples; i++)
- avg += aio->read();
-
- return (avg / samples);
-}
diff --git a/peripheral/libupm/src/cwlsxxa/cwlsxxa.hpp b/peripheral/libupm/src/cwlsxxa/cwlsxxa.hpp
deleted file mode 100644
index 184eaad..0000000
--- a/peripheral/libupm/src/cwlsxxa/cwlsxxa.hpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <iostream>
-
-#include <mraa/aio.hpp>
-
-// Unlikey to be changable without external circuitry (voltage divider)
-#define CWLSXXA_DEFAULT_AREF 5.0
-
-namespace upm {
- /**
- * @brief Veris CWLSXXA CO2 Sensor
- * @defgroup cwlsxxa libupm-cwlsxxa
- * @ingroup veris ainput temp gaseous
- */
-
- /**
- * @library cwlsxxa
- * @sensor cwlsxxa
- * @comname Veris CWLSXXA CO2 Sensor Family
- * @type temp gaseous
- * @man veris
- * @con ainput
- * @web http://www.veris.com/Item/CWLSHTA.aspx
- *
- * @brief API for the Veris CWLSXXA CO2 Sensor Family
- *
- * The driver was developed using the CWLSHTA CO2 Gas sensor. The
- * 'T' variant supports a temperature transmitter, and the 'H'
- * variant supports a humidity sensor. All 3 signals are provided
- * by the device as analog 0-5Vdc, 0-10Vdc, or 4-20ma loop current
- * outputs. For devices supporting temperature, the valid
- * temperature range is 10C to 50C. The humidity ranges from 0%
- * to 100% (non-condensing). The CO2 sensor ranges from 0 to 2000
- * ppm.
- *
- * This driver was developed using the 5Vdc outputs and the 4-20ma
- * outputs. For voltage outputs, your MCU must be configured for
- * 5V operation. In addition, you must configure the sensor (via
- * it's configuration switches) to output 0-5VDC only. Using any
- * other analog reference voltage will require the appropriate
- * external circuitry (such as a voltage divider) in order to
- * interface safely with your MCU.
- *
- * In addition, the sensor can be configured for 4-20ma usage, by
- * specifying the correct receiver resistance (in ohms) in the
- * constructor. This sensor was tested with a Cooking Hacks
- * (Libelium) 4-channel 4-20ma Arduino interface shield. For this
- * interface, the receiver resistance was specified as 165.0 ohms.
- *
- * For devices which do not support temperature, use '-1' as the
- * temperature pin number in the object constructor. If
- * temperature measurement is disabled, getTemperature() will always
- * return 0C/32F.
- *
- * For devices which do not support humidity, use '-1' as the
- * temperature pin number in the object constructor. If
- * humidity measurement is disabled, getHumidity() will always
- * return 0.
- *
- * @snippet cwlsxxa.cxx Interesting
- */
-
- class CWLSXXA {
- public:
-
- /**
- * CWLSXXA object constructor
- *
- * @param gPin Analog pin to use for the CO2 measurement
- * @param hPin Analog pin to use for the humidity measurement. If
- * your device does not support humidity, use -1 as the value so
- * that humidity will not be queried and an analog pin won't be
- * wasted.
- * @param tPin Analog pin to use for temperature. If your device
- * does not support temperature, use -1 as the value so that
- * temperature will not be queried and an analog pin won't be
- * wasted.
- * @param rResistor The receiver resistance in ohms, when using a
- * 4-20ma current loop interface. When specified, this value will
- * be used in computing the current based on the voltage read when
- * scaling the return values. Default is 0.0, for standard
- * scaling based on voltage output rather than current (4-20ma
- * mode).
- * @param aref The analog reference voltage, default 5.0
- */
- CWLSXXA(int gPin, int hPin, int tPin, float rResistor=0.0,
- float aref=CWLSXXA_DEFAULT_AREF);
-
- /**
- * CWLSXXA object destructor
- */
- ~CWLSXXA();
-
- /**
- * Read current values from the sensor and update internal stored
- * values. This method must be called prior to querying any
- * values, such as CO2, temperature, or humidity.
- */
- void update();
-
- /**
- * Get the current temperature. update() must have been called
- * prior to calling this method. If temperature measurement was
- * disabled (by passing -1 as the temperature pin in the
- * constructor) then this function will always return 0C/32F.
- *
- * @param fahrenheit true to return the temperature in degrees
- * fahrenheit, false to return the temperature in degrees celcius.
- * The default is false (degrees Celcius).
- * @return The last temperature reading in Celcius or Fahrenheit
- */
- float getTemperature(bool fahrenheit=false);
-
- /**
- * Get the current relative humidity. update() must have been called
- * prior to calling this method. If humidity measurement was
- * disabled (by passing -1 as the te pin in the
- * constructor) then this function will always return 0.
- *
- * @return The last humidity reading
- */
- float getHumidity();
-
- /**
- * Get the current CO2 concentration in Parts Per Million (PPM).
- * update() must have been called prior to calling this method.
- *
- * @return The last CO2 reading
- */
- float getCO2();
-
-
- protected:
- // temperature and humidity are optional features of this transmitter
- mraa::Aio *m_aioTemp;
- mraa::Aio *m_aioHum;
-
- // CO2 reporting is always supported
- mraa::Aio m_aioCO2;
-
- private:
- float m_aref;
- float m_rResistor;
- int m_aResTemp;
- int m_aResHum;
- int m_aResCO2;
-
- // does this sensor support temperature and/or humidity reporting?
- bool m_hasTemp;
- bool m_hasHum;
-
- // in Celcius
- float m_temperature;
-
- float m_humidity;
-
- // in PPM
- float m_co2;
-
- int average(mraa::Aio *aio, int samples);
- };
-}
-
-
diff --git a/peripheral/libupm/src/cwlsxxa/javaupm_cwlsxxa.i b/peripheral/libupm/src/cwlsxxa/javaupm_cwlsxxa.i
deleted file mode 100644
index 8a25f33..0000000
--- a/peripheral/libupm/src/cwlsxxa/javaupm_cwlsxxa.i
+++ /dev/null
@@ -1,19 +0,0 @@
-%module javaupm_cwlsxxa
-%include "../upm.i"
-%include "std_string.i"
-
-%include "cwlsxxa.hpp"
-%{
- #include "cwlsxxa.hpp"
-%}
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_cwlsxxa");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/cwlsxxa/jsupm_cwlsxxa.i b/peripheral/libupm/src/cwlsxxa/jsupm_cwlsxxa.i
deleted file mode 100644
index cae0224..0000000
--- a/peripheral/libupm/src/cwlsxxa/jsupm_cwlsxxa.i
+++ /dev/null
@@ -1,10 +0,0 @@
-%module jsupm_cwlsxxa
-%include "../upm.i"
-%include "std_string.i"
-
-%{
- #include "cwlsxxa.hpp"
-%}
-
-%include "cwlsxxa.hpp"
-
diff --git a/peripheral/libupm/src/cwlsxxa/pyupm_cwlsxxa.i b/peripheral/libupm/src/cwlsxxa/pyupm_cwlsxxa.i
deleted file mode 100644
index 0393e39..0000000
--- a/peripheral/libupm/src/cwlsxxa/pyupm_cwlsxxa.i
+++ /dev/null
@@ -1,13 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_cwlsxxa
-%include "../upm.i"
-%include "std_string.i"
-
-%feature("autodoc", "3");
-
-%{
- #include "cwlsxxa.hpp"
-%}
-%include "cwlsxxa.hpp"
-
diff --git a/peripheral/libupm/src/dfrph/CMakeLists.txt b/peripheral/libupm/src/dfrph/CMakeLists.txt
index 6de74f5..1f08e95 100644
--- a/peripheral/libupm/src/dfrph/CMakeLists.txt
+++ b/peripheral/libupm/src/dfrph/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "dfrph")
set (libdescription "upm dfrobot pH sensors")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/dfrph/dfrph.cxx b/peripheral/libupm/src/dfrph/dfrph.cxx
index 000d64d..a984af7 100644
--- a/peripheral/libupm/src/dfrph/dfrph.cxx
+++ b/peripheral/libupm/src/dfrph/dfrph.cxx
@@ -24,7 +24,7 @@
#include <iostream>
-#include "dfrph.hpp"
+#include "dfrph.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/src/dfrph/dfrph.hpp b/peripheral/libupm/src/dfrph/dfrph.h
index 68c2557..68c2557 100644
--- a/peripheral/libupm/src/dfrph/dfrph.hpp
+++ b/peripheral/libupm/src/dfrph/dfrph.h
diff --git a/peripheral/libupm/src/dfrph/javaupm_dfrph.i b/peripheral/libupm/src/dfrph/javaupm_dfrph.i
index 975520b..68fe193 100644
--- a/peripheral/libupm/src/dfrph/javaupm_dfrph.i
+++ b/peripheral/libupm/src/dfrph/javaupm_dfrph.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "dfrph.hpp"
+ #include "dfrph.h"
%}
-%include "dfrph.hpp"
+%include "dfrph.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/dfrph/jsupm_dfrph.i b/peripheral/libupm/src/dfrph/jsupm_dfrph.i
index 764fc77..ca3a249 100644
--- a/peripheral/libupm/src/dfrph/jsupm_dfrph.i
+++ b/peripheral/libupm/src/dfrph/jsupm_dfrph.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "dfrph.hpp"
+ #include "dfrph.h"
%}
-%include "dfrph.hpp"
+%include "dfrph.h"
diff --git a/peripheral/libupm/src/dfrph/pyupm_dfrph.i b/peripheral/libupm/src/dfrph/pyupm_dfrph.i
index 6231c7e..f22183e 100644
--- a/peripheral/libupm/src/dfrph/pyupm_dfrph.i
+++ b/peripheral/libupm/src/dfrph/pyupm_dfrph.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "dfrph.hpp"
+%include "dfrph.h"
%{
- #include "dfrph.hpp"
+ #include "dfrph.h"
%}
diff --git a/peripheral/libupm/src/ds1307/CMakeLists.txt b/peripheral/libupm/src/ds1307/CMakeLists.txt
index b9054d6..3ee7e08 100644
--- a/peripheral/libupm/src/ds1307/CMakeLists.txt
+++ b/peripheral/libupm/src/ds1307/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "ds1307")
set (libdescription "upm ds1307 RTC module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/ds1307/ds1307.cxx b/peripheral/libupm/src/ds1307/ds1307.cxx
index 1b3dbc0..8681cea 100644
--- a/peripheral/libupm/src/ds1307/ds1307.cxx
+++ b/peripheral/libupm/src/ds1307/ds1307.cxx
@@ -29,7 +29,7 @@
#include <string>
#include <stdexcept>
-#include "ds1307.hpp"
+#include "ds1307.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/ds1307/ds1307.hpp b/peripheral/libupm/src/ds1307/ds1307.h
index 4061866..4061866 100644
--- a/peripheral/libupm/src/ds1307/ds1307.hpp
+++ b/peripheral/libupm/src/ds1307/ds1307.h
diff --git a/peripheral/libupm/src/ds1307/javaupm_ds1307.i b/peripheral/libupm/src/ds1307/javaupm_ds1307.i
index 6bb3b71..ba7de15 100644
--- a/peripheral/libupm/src/ds1307/javaupm_ds1307.i
+++ b/peripheral/libupm/src/ds1307/javaupm_ds1307.i
@@ -4,10 +4,10 @@
%include "../java_buffer.i"
%{
- #include "ds1307.hpp"
+ #include "ds1307.h"
%}
-%include "ds1307.hpp"
+%include "ds1307.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/ds1307/jsupm_ds1307.i b/peripheral/libupm/src/ds1307/jsupm_ds1307.i
index f2e689c..f102ea0 100644
--- a/peripheral/libupm/src/ds1307/jsupm_ds1307.i
+++ b/peripheral/libupm/src/ds1307/jsupm_ds1307.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "ds1307.hpp"
+ #include "ds1307.h"
%}
-%include "ds1307.hpp"
+%include "ds1307.h"
diff --git a/peripheral/libupm/src/ds1307/pyupm_ds1307.i b/peripheral/libupm/src/ds1307/pyupm_ds1307.i
index 5d4c0b2..33e65eb 100644
--- a/peripheral/libupm/src/ds1307/pyupm_ds1307.i
+++ b/peripheral/libupm/src/ds1307/pyupm_ds1307.i
@@ -9,7 +9,7 @@
%include "ds1307_doc.i"
#endif
-%include "ds1307.hpp"
+%include "ds1307.h"
%{
- #include "ds1307.hpp"
+ #include "ds1307.h"
%}
diff --git a/peripheral/libupm/src/ds1808lc/CMakeLists.txt b/peripheral/libupm/src/ds1808lc/CMakeLists.txt
deleted file mode 100644
index 6a46ccb..0000000
--- a/peripheral/libupm/src/ds1808lc/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-include_directories(..)
-set (libname "ds1808lc")
-set (libdescription “DS1808 lighting controller”)
-set (module_src ${libname}.cxx mraa-utils.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/ds1808lc/ds1808lc.cxx b/peripheral/libupm/src/ds1808lc/ds1808lc.cxx
deleted file mode 100644
index ff98980..0000000
--- a/peripheral/libupm/src/ds1808lc/ds1808lc.cxx
+++ /dev/null
@@ -1,134 +0,0 @@
-#include <iostream>
-#include <unistd.h>
-#include <string.h>
-#include <cmath>
-#include "ds1808lc.hpp"
-#include "mraa-utils.hpp"
-
-#define DS1808_I2C_ADDR 0x28
-#define DS1808_POT2_OFFSET 0x40
-#define DS1808_MAX_POT_VALUE 0x20
-#define DS1808_LOW_VALUE 32 // Lowest pot value that the eye can differentiate from 0
-#define DS1808_HIGH_VALUE 51 // Highest pot value that the eye can differentiate from full
-
-
-namespace upm {
-DS1808LC::DS1808LC(int gpioPower, int i2cBus)
-{
- mraa_set_log_level(7);
- pinPower = gpioPower;
- i2c = new mraa::I2c(i2cBus);
- status = i2c->address(DS1808_I2C_ADDR);
- getBrightness();
-}
-
-DS1808LC::~DS1808LC()
-{
-}
-
-
-bool DS1808LC::isPowered()
-{
- return static_cast<bool>(MraaUtils::getGpio(pinPower));
-}
-
-void DS1808LC::setPowerOn()
-{
- if (!isPowered())
- {
- MraaUtils::setGpio(pinPower, 1);
- setBrightness(0);
- }
-}
-
-void DS1808LC::setPowerOff()
-{
- MraaUtils::setGpio(pinPower, 0);
-}
-
-
-int DS1808LC::getBrightness()
-{
- uint8_t values[2];
-
- if (i2c->read(values, 2) == 2) {
- return getPercentBrightness(values[0], values[1]);
- }
- else
- UPM_THROW("i2c read error");
-}
-
-
-void DS1808LC::setBrightness(int dutyPercent)
-{
- uint8_t values[2];
- values[0] = getPot1Value(dutyPercent);
- values[1] = getPot2Value(dutyPercent);
- status = i2c->write(values, 2);
- if (status != mraa::SUCCESS)
- UPM_THROW("i2c write error");
-}
-
-//
-// Helper Function
-//
-
-uint8_t DS1808LC::getPot1Value(int dutyPercent) {
- uint8_t result = 0;
- int scaledResistance = getScaledResistance(dutyPercent);
-
- if (scaledResistance > DS1808_MAX_POT_VALUE)
- result = DS1808_MAX_POT_VALUE;
- else {
- result = scaledResistance;
- }
-
- return result;
-}
-
-uint8_t DS1808LC::getPot2Value(int dutyPercent) {
- uint8_t result = 0;
- int scaledResistance = getScaledResistance(dutyPercent);
-
- if (scaledResistance <= DS1808_MAX_POT_VALUE)
- result = 0;
- else {
- result = scaledResistance - DS1808_MAX_POT_VALUE;
- }
-
- if (result > DS1808_MAX_POT_VALUE)
- result = DS1808_MAX_POT_VALUE;
-
- return result | DS1808_POT2_OFFSET;
-}
-
-int DS1808LC::getPercentBrightness(uint8_t val1, uint8_t val2) {
- val2 = val2 & (~DS1808_POT2_OFFSET);
- int scaledResistance = val1 + val2;
- int percent;
-
- if (scaledResistance < DS1808_LOW_VALUE)
- percent = 100;
- else if (scaledResistance > DS1808_HIGH_VALUE)
- percent = 0;
- else
- percent = 100 - (((scaledResistance - DS1808_LOW_VALUE) * 100) / (DS1808_HIGH_VALUE - DS1808_LOW_VALUE));
- return percent;
-}
-
-int DS1808LC::getScaledResistance(int dutyPercent) {
- int scaledResistance;
-
- if (dutyPercent == 0)
- scaledResistance = 2 * DS1808_MAX_POT_VALUE;
- else if (dutyPercent == 100)
- scaledResistance = 0;
- else
- scaledResistance = (((100 - dutyPercent) * (DS1808_HIGH_VALUE - DS1808_LOW_VALUE)) / 100) + DS1808_LOW_VALUE;
- return scaledResistance;
-}
-
-}
-
-
-
diff --git a/peripheral/libupm/src/ds1808lc/ds1808lc.hpp b/peripheral/libupm/src/ds1808lc/ds1808lc.hpp
deleted file mode 100644
index 9b87192..0000000
--- a/peripheral/libupm/src/ds1808lc/ds1808lc.hpp
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include "upm/iLightController.hpp"
-#include "mraa/i2c.hpp"
-
-namespace upm
-{
-/**
- * @brief DS1808LC lighting controller library
- * @defgroup DS1808LC libupm-ds1808lc
- * @ingroup ds1808lc i2c maxim light ilightcontroller
- */
-
-/**
- * @brief API for DS1808 Dual Log Digital Potentiometer as a Light Controller
- *
- * The Maxim Integrated
- * [DS1808](http://www.maximintegrated.com/en/products/analog/data-converters/digital-potentiometers/DS1808.html)
- * Dual Log Digital Potentiometer
- *
- *
- * @library ds1808lc
- * @sensor ds1808lc
- * @comname Maxim DS1808 as lighting controller
- * @altname DS1808LC
- * @type light
- * @man maxim
- * @con i2c
- * @if ilightcontroller
- */
-class DS1808LC : public upm::ILightController
-{
-public:
- DS1808LC(int gpioPower, int i2cBus);
- ~DS1808LC();
-
-protected:
- const char* getModuleName() { return "ds1808lc"; }
- bool isPowered();
- void setPowerOn();
- void setPowerOff();
- int getBrightness();
- void setBrightness(int dutyPercent);
-
-private:
- int getPercentBrightness(uint8_t val1, uint8_t val2);
- uint8_t getPot1Value(int dutyPercent);
- uint8_t getPot2Value(int dutyPercent);
- int getScaledResistance(int dutyPercent);
-
- mraa::Result status;
- mraa::I2c* i2c;
- int pinPower;
-};
-
-
-}
-
diff --git a/peripheral/libupm/src/ds1808lc/javaupm_ds1808lc.i b/peripheral/libupm/src/ds1808lc/javaupm_ds1808lc.i
deleted file mode 100644
index 988bb1d..0000000
--- a/peripheral/libupm/src/ds1808lc/javaupm_ds1808lc.i
+++ /dev/null
@@ -1,23 +0,0 @@
-%module javaupm_ds1808lc
-%include "../upm.i"
-%include "arrays_java.i";
-%include "../java_buffer.i"
-%include "cpointer.i"
-%include "typemaps.i"
-
-%{
- #include "ds1808lc.hpp"
-%}
-
-%include "ds1808lc.hpp"
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_ds1808lc");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/ds1808lc/jsupm_ds1808lc.i b/peripheral/libupm/src/ds1808lc/jsupm_ds1808lc.i
deleted file mode 100644
index 5f8fa16..0000000
--- a/peripheral/libupm/src/ds1808lc/jsupm_ds1808lc.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module jsupm_ds1808lc
-%include "../upm.i"
-
-%{
- #include "ds1808lc.hpp"
-%}
-
-%include "ds1808lc.hpp"
diff --git a/peripheral/libupm/src/ds1808lc/mraa-utils.cxx b/peripheral/libupm/src/ds1808lc/mraa-utils.cxx
deleted file mode 100644
index 528a79b..0000000
--- a/peripheral/libupm/src/ds1808lc/mraa-utils.cxx
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <string>
-#include "mraa-utils.hpp"
-#include "mraa/gpio.hpp"
-
- #define UPM_THROW(msg) throw std::runtime_error(std::string(__FUNCTION__) + ": " + (msg))
-
-void MraaUtils::setGpio(int pin, int level)
-{
-/*
- mraa_result_t status = MRAA_ERROR_NO_RESOURCES;
- mraa_gpio_context gpio = mraa_gpio_init(pin);
- if (gpio != NULL)
- {
- mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
- status = mraa_gpio_write(gpio, level);
- mraa_gpio_close(gpio);
- }
- return status;
-*/
- mraa::Gpio gpio(pin);
- gpio.dir(mraa::DIR_OUT);
- if (gpio.write(level) != mraa::SUCCESS)
- UPM_THROW("gpio write failed");
-}
-
-
-int MraaUtils::getGpio(int pin)
-{
-/*
- mraa_result_t status = MRAA_ERROR_NO_RESOURCES;
- mraa_gpio_context gpio = mraa_gpio_init(pin);
- if (gpio != NULL)
- {
- status = mraa_gpio_dir(gpio, MRAA_GPIO_IN);
- int value = mraa_gpio_read(gpio);
- if (value != -1)
- *level = value;
- else
- status = MRAA_ERROR_NO_RESOURCES;
- mraa_gpio_close(gpio);
- }
- return status;
-*/
- mraa::Gpio gpio(pin);
- gpio.dir(mraa::DIR_IN);
- return gpio.read();
-}
-
-
diff --git a/peripheral/libupm/src/ds1808lc/mraa-utils.hpp b/peripheral/libupm/src/ds1808lc/mraa-utils.hpp
deleted file mode 100644
index f9e6acc..0000000
--- a/peripheral/libupm/src/ds1808lc/mraa-utils.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#pragma once
-
-#include "mraa/types.h"
-
-class __attribute__ ((visibility("hidden"))) MraaUtils
-{
-public:
- static void setGpio(int pin, int level);
- static int getGpio(int pin);
-};
-
-
-
diff --git a/peripheral/libupm/src/ds1808lc/pyupm_ds1808lc.i b/peripheral/libupm/src/ds1808lc/pyupm_ds1808lc.i
deleted file mode 100644
index 4c2b34a..0000000
--- a/peripheral/libupm/src/ds1808lc/pyupm_ds1808lc.i
+++ /dev/null
@@ -1,9 +0,0 @@
-%module pyupm_ds1808lc
-%include "../upm.i"
-
-%feature("autodoc", "3");
-
-%include "ds1808lc.hpp"
-%{
- #include "ds1808lc.hpp"
-%}
diff --git a/peripheral/libupm/src/ds18b20/CMakeLists.txt b/peripheral/libupm/src/ds18b20/CMakeLists.txt
deleted file mode 100644
index 988d278..0000000
--- a/peripheral/libupm/src/ds18b20/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set (libname "ds18b20")
-set (libdescription "upm DS18B20 1-wire Temperature sensor")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/ds18b20/ds18b20.cxx b/peripheral/libupm/src/ds18b20/ds18b20.cxx
deleted file mode 100644
index 0848fe3..0000000
--- a/peripheral/libupm/src/ds18b20/ds18b20.cxx
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-#include <time.h>
-#include <stdexcept>
-
-#include "ds18b20.hpp"
-
-using namespace upm;
-using namespace std;
-
-// conversion from celcius to fahrenheit
-static float c2f(float c)
-{
- return (c * (9.0 / 5.0) + 32.0);
-}
-
-DS18B20::DS18B20(int uart) :
- m_uart(uart)
-{
- m_devicesFound = 0;
-
- // check basic access to the 1-wire bus (presence detect)
- mraa::Result rv;
-
- if ((rv = m_uart.reset()) != mraa::SUCCESS)
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": reset() failed, no devices on bus?");
- }
-}
-
-DS18B20::~DS18B20()
-{
-}
-
-void DS18B20::init()
-{
- // iterate through the bus and build up a list of detected DS18B20
- // devices (only)
-
- // empty the map, in case this method has already been run once
- // before
- m_devicesFound = 0;
- m_deviceMap.clear();
-
- sensor_info_t sinfo;
-
- // defaults
- sinfo.temperature = 0.0;
- sinfo.resolution = RESOLUTION_12BITS;
-
- // start the search from scratch
- string id = m_uart.search(true);
- if (id.empty())
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": no devices detected on bus");
- }
-
- while (!id.empty())
- {
- // The first byte (id[0]]) is the device type (family) code. We
- // are only interested in the family code for these devices.
-
- if ((uint8_t)id[0] == DS18B20_FAMILY_CODE)
- {
- // we have a winner, add it to our map and continue searching
-
- sinfo.id = id;
- m_deviceMap[m_devicesFound] = sinfo;
-
- m_devicesFound++;
- }
-
- // continue search
- id = m_uart.search(false);
- }
-
- if (!m_devicesFound)
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": no DS18B20 devices found on bus");
- }
-
- // iterate through the found devices and query their resolutions
- for (int i=0; i<m_devicesFound; i++)
- {
- // read only the first 5 bytes of the scratchpad
- static const int numScratch = 5;
- uint8_t scratch[numScratch];
-
- m_uart.command(CMD_READ_SCRATCHPAD, m_deviceMap[i].id);
- for (int j=0; j<numScratch; j++)
- scratch[j] = m_uart.readByte();
-
- // config byte, shift the resolution to bit 0
- scratch[4] >>= _CFG_RESOLUTION_SHIFT;
-
- switch (scratch[4] & _CFG_RESOLUTION_MASK)
- {
- case 0: m_deviceMap[i].resolution = RESOLUTION_9BITS; break;
- case 1: m_deviceMap[i].resolution = RESOLUTION_10BITS; break;
- case 2: m_deviceMap[i].resolution = RESOLUTION_11BITS; break;
- case 3: m_deviceMap[i].resolution = RESOLUTION_12BITS; break;
- }
-
- // reset the bus
- m_uart.reset();
- }
-}
-
-void DS18B20::update(int index)
-{
- if (index >= m_devicesFound)
- {
- throw std::out_of_range(std::string(__FUNCTION__) +
- ": device index out of range");
- }
-
- // should we update all of them?
- bool doAll = (index < 0) ? true : false;
-
- if (doAll)
- {
- // if we want to update all of them, we will first send the
- // convert command to all of them, then wait. This will be
- // faster, timey-wimey wise, then converting, sleeping, and
- // reading each individual sensor.
-
- for (int i=0; i<m_devicesFound; i++)
- m_uart.command(CMD_CONVERT, m_deviceMap[i].id);
- }
- else
- m_uart.command(CMD_CONVERT, m_deviceMap[index].id);
-
- // wait for conversion(s) to finish
- usleep(750000); // 750ms max
-
- if (doAll)
- {
- for (int i=0; i<m_devicesFound; i++)
- m_deviceMap[i].temperature = readSingleTemp(i);
- }
- else
- m_deviceMap[index].temperature = readSingleTemp(index);
-}
-
-// utility function to read temp data from a single sensor
-float DS18B20::readSingleTemp(int index)
-{
- if (index < 0 || index >= m_devicesFound)
- {
- throw std::out_of_range(std::string(__FUNCTION__) +
- ": device index out of range");
- }
-
- static const int numScratch = 9;
- uint8_t scratch[numScratch];
-
- // read the 9-byte scratchpad
- m_uart.command(CMD_READ_SCRATCHPAD, m_deviceMap[index].id);
- for (int i=0; i<numScratch; i++)
- scratch[i] = m_uart.readByte();
-
- // validate cksum -- if we get an error, we will warn and simply
- // return the current (previously read) temperature
- uint8_t crc = m_uart.crc8(scratch, 8);
-
- if (crc != scratch[8])
- {
- cerr << __FUNCTION__ << ": crc check failed for device "
- << index << ", returning previously measured temperature" << endl;
- return m_deviceMap[index].temperature;
- }
-
- // check the sign bit(s)
- bool negative = (scratch[1] & 0x80) ? true : false;
-
- // shift everything into position
- int16_t temp = (scratch[1] << 8) | scratch[0];
-
- // grab the fractional
- uint8_t frac = temp & 0x0f;
-
- // depending on the resolution, some frac bits should be ignored, so
- // we mask them off. For 12bits, all bits are valid so we leve them
- // alone.
-
- switch (m_deviceMap[index].resolution)
- {
- case RESOLUTION_9BITS: frac &= 0x08; break;
- case RESOLUTION_10BITS: frac &= 0x0c; break;
- case RESOLUTION_11BITS: frac &= 0x0e; break;
- }
-
- // remove the fractional with extreme prejudice
- temp >>= 4;
-
- // compensate for sign
- if (negative)
- temp -= 65536; // 2^^16
-
- // convert
- return ( float(temp) + (float(frac) * 0.0625) );
-}
-
-float DS18B20::getTemperature(int index, bool fahrenheit)
-{
- if (index < 0 || index >= m_devicesFound)
- {
- throw std::out_of_range(std::string(__FUNCTION__) +
- ": device index out of range");
- }
-
- if (fahrenheit)
- return c2f(m_deviceMap[index].temperature);
- else
- return m_deviceMap[index].temperature;
-}
-
-void DS18B20::setResolution(int index, RESOLUTIONS_T res)
-{
- if (index < 0 || index >= m_devicesFound)
- {
- throw std::out_of_range(std::string(__FUNCTION__) +
- ": device index out of range");
- }
-
- static const int numScratch = 9;
- uint8_t scratch[numScratch];
-
- // read the 9-byte scratchpad
- m_uart.command(CMD_READ_SCRATCHPAD, m_deviceMap[index].id);
- for (int i=0; i<numScratch; i++)
- scratch[i] = m_uart.readByte();
-
- // resolution is stored in byte 4
- scratch[4] = ((scratch[4] & ~(_CFG_RESOLUTION_MASK << _CFG_RESOLUTION_SHIFT))
- | (res << _CFG_RESOLUTION_SHIFT));
-
- // now, write back, we only write 3 bytes (2-4), no cksum.
- m_uart.command(CMD_WRITE_SCRATCHPAD, m_deviceMap[index].id);
- for (int i=0; i<3; i++)
- m_uart.writeByte(scratch[i+2]);
-}
-
-void DS18B20::copyScratchPad(int index)
-{
- if (index < 0 || index >= m_devicesFound)
- {
- throw std::out_of_range(std::string(__FUNCTION__) +
- ": device index out of range");
- }
-
- // issue the command
- m_uart.command(CMD_COPY_SCRATCHPAD, m_deviceMap[index].id);
-
- sleep(1); // to be safe...
-}
-
-void DS18B20::recallEEPROM(int index)
-{
- if (index < 0 || index >= m_devicesFound)
- {
- throw std::out_of_range(std::string(__FUNCTION__) +
- ": device index out of range");
- }
-
- // issue the command
- m_uart.command(CMD_RECALL_EEPROM, m_deviceMap[index].id);
-
- // issue read timeslots until a '1' is read back, indicating completion
- while (!m_uart.writeBit(1))
- usleep(100);
-}
diff --git a/peripheral/libupm/src/ds18b20/ds18b20.hpp b/peripheral/libupm/src/ds18b20/ds18b20.hpp
deleted file mode 100644
index 46d7abb..0000000
--- a/peripheral/libupm/src/ds18b20/ds18b20.hpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <iostream>
-#include <map>
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <mraa/common.hpp>
-#include <mraa/uart_ow.hpp>
-
-#define DS18B20_DEFAULT_UART 0
-
-namespace upm {
- /**
- * @brief DS18B20 1-Wire Temperature Sensor
- * @defgroup ds18b20 libupm-ds18b20
- * @ingroup maxim uart
- */
-
- /**
- * @library ds18b20
- * @sensor ds18b20
- * @comname DS18B20 1-Wire Temperature Sensor
- * @type uart
- * @man maxim
- * @con uart
- * @web https://www.sparkfun.com/products/11050
- *
- * @brief API for the DS18B20 1-Wire Temperature Sensor
- *
- * This driver supports, and was tested with, a DS18B20 with
- * external power.
- *
- * Multiple DS18B20 devices can be connected to this bus. This
- * module will identify all such devices connected, and allow you
- * to access them using an index starting at 0.
- *
- * Parasitic power is not currently supported due
- * to the very tight 10us limit on switching a GPIO properly to
- * supply power during certain operations. For this reason, you
- * should use external power for your sensors.
- *
- * Setting the alarm values (Tl, Th) is also not supported, since
- * this is only useful when doing a 1-wire device search looking
- * for devices in an alarm state, a capability not yet supported
- * in MRAA. In reality, this is trivial to handle yourself in
- * your application.
- *
- * This device requires the use of a UART to provide access to a
- * Dallas 1-wire bus, via a new facility supported by MRAA (once
- * the relevant PR is accepted), using the UartOW access class.
- * It is important to realize that the UART is only being used to
- * access and control a Dallas 1-wire compliant bus, it is not
- * actually a UART device.
- *
- * @snippet ds18b20.cxx Interesting
- */
-
- class DS18B20 {
- public:
-
- // The family code for these devices. We handle all of them that
- // are found on the bus.
- static const uint8_t DS18B20_FAMILY_CODE = 0x28;
-
- // commands
- typedef enum {
- CMD_CONVERT = 0x44, // start a temp conversion
- CMD_WRITE_SCRATCHPAD = 0x4e,
- CMD_READ_SCRATCHPAD = 0xbe,
- CMD_COPY_SCRATCHPAD = 0x48, // copy scratchpad to EEPROM
- CMD_RECALL_EEPROM = 0xb8, // copy EEPROM to scratchpad
- CMD_READ_POWER_SUPPLY = 0xb4 // parasitically powered?
- } CMD_T;
-
- // config register (scratchpad[4])
- typedef enum {
- CFG_RESOLUTION_R0 = 0x20,
- CFG_RESOLUTION_R1 = 0x40,
- _CFG_RESOLUTION_MASK = 3,
- _CFG_RESOLUTION_SHIFT = 5
-
- // all other bits reserved and non-writable
- } CFG_BITS_T;
-
- typedef enum {
- RESOLUTION_9BITS = 0, // 93.75ms (tconv/8)
- RESOLUTION_10BITS = 1, // 187.5 (tconv/4)
- RESOLUTION_11BITS = 2, // 375ms (tconv/2)
- RESOLUTION_12BITS = 3 // 750ms (tconv)
- } RESOLUTIONS_T;
-
- /**
- * DS18B20 object constructor
- *
- * @param uart Default UART to use (0 or 1). Default is 0.
- */
- DS18B20(int uart=DS18B20_DEFAULT_UART);
-
- /**
- * DS18B20 object destructor
- */
- ~DS18B20();
-
- /**
- * This method will search the 1-wire bus and store information on
- * each device detected on the bus. If no devices are found, an
- * exception is thrown. Once this function completes
- * successfully, you can use devicesFound() to determine how many
- * devices were detected. This method must be executed first
- * before any others below.
- */
- void init();
-
- /**
- * Update our stored temperature for a device. This method must
- * be called prior to getTemperature().
- *
- * @param index The device index to access (starts at 0). Specify
- * -1 to query all detected devices. Default: -1
- */
- void update(int index=-1);
-
- /**
- * Get the current temperature. update() must have been called
- * prior to calling this method.
- *
- * @param index The device index to access (starts at 0).
- * @param fahrenheit true to return the temperature in degrees
- * fahrenheit, false to return the temperature in degrees celcius.
- * The default is false (degrees Celcius).
- * @return The last temperature reading in Celcius or Fahrenheit
- */
- float getTemperature(int index, bool fahrenheit=false);
-
- /**
- * Set the device resolution for a device. These devices support
- * 9, 10, 11, and 12 bits of resolution, with the default from the
- * factory at 12 bits.
- *
- * @param index The device index to access (starts at 0).
- * @param res One of the RESOLUTIONS_T values
- */
- void setResolution(int index, RESOLUTIONS_T res);
-
- /**
- * Copy the device's scratchpad memory to the EEPROM. This
- * includes the configuration byte (resolution).
- *
- * @param index The device index to access (starts at 0).
- */
- void copyScratchPad(int index);
-
- /**
- * Copy the device's EEPROM memory to the scratchpad. This method
- * will return when the copy completes. This operation is
- * performed by the device automatically on power up, so it is
- * rarely needed.
- *
- * @param index The device index to access (starts at 0).
- */
- void recallEEPROM(int index);
-
- /**
- * This method will return the number of DS18B20 devices that were
- * found on the bus by init().
- *
- * @return number of DS18B20's that were found on the bus
- */
- int devicesFound()
- {
- return m_devicesFound;
- }
-
- /**
- * Return an 8 byte string representing the unique device ID
- * (1-wire romcode) for a given device index.
- *
- * @param index The device index to access (starts at 0).
- * @return 8 byte string representing the 1-wire device's unique
- * romcode.
- */
- std::string getId(int index)
- {
- if (index < 0 || index >= m_devicesFound)
- {
- throw std::out_of_range(std::string(__FUNCTION__) +
- ": device index out of range");
- }
- return m_deviceMap[index].id;
- }
-
- protected:
- mraa::UartOW m_uart;
-
- // the total number of devices found
- int m_devicesFound;
-
- // this struct will generate SWIG warnings on build, but as it's not
- // exposed outside the class, they can be safely ignored
-
- // data we need to store for each sensor we are dealing with
- typedef struct {
- std::string id; // 8-byte romcode id
- float temperature;
- RESOLUTIONS_T resolution;
- } sensor_info_t;
-
- std::map<int, sensor_info_t> m_deviceMap;
-
- private:
- // internal utility function to read temperature from a single
- // device
- float readSingleTemp(int index);
- };
-}
diff --git a/peripheral/libupm/src/ds18b20/javaupm_ds18b20.i b/peripheral/libupm/src/ds18b20/javaupm_ds18b20.i
deleted file mode 100644
index 918f613..0000000
--- a/peripheral/libupm/src/ds18b20/javaupm_ds18b20.i
+++ /dev/null
@@ -1,22 +0,0 @@
-%module javaupm_ds18b20
-%include "../upm.i"
-%include "carrays.i"
-%include "std_string.i"
-
-%{
- #include "ds18b20.hpp"
-%}
-
-%include "ds18b20.hpp"
-%array_class(char, charArray);
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_ds18b20");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/ds18b20/jsupm_ds18b20.i b/peripheral/libupm/src/ds18b20/jsupm_ds18b20.i
deleted file mode 100644
index 8f882b6..0000000
--- a/peripheral/libupm/src/ds18b20/jsupm_ds18b20.i
+++ /dev/null
@@ -1,11 +0,0 @@
-%module jsupm_ds18b20
-%include "../upm.i"
-%include "carrays.i"
-%include "std_string.i"
-
-%{
- #include "ds18b20.hpp"
-%}
-
-%include "ds18b20.hpp"
-%array_class(char, charArray);
diff --git a/peripheral/libupm/src/ds18b20/pyupm_ds18b20.i b/peripheral/libupm/src/ds18b20/pyupm_ds18b20.i
deleted file mode 100644
index 3a4ac70..0000000
--- a/peripheral/libupm/src/ds18b20/pyupm_ds18b20.i
+++ /dev/null
@@ -1,12 +0,0 @@
-%module pyupm_ds18b20
-%include "../upm.i"
-%include "carrays.i"
-%include "std_string.i"
-
-%feature("autodoc", "3");
-
-%{
- #include "ds18b20.hpp"
-%}
-%include "ds18b20.hpp"
-%array_class(char, charArray);
diff --git a/peripheral/libupm/src/ds2413/CMakeLists.txt b/peripheral/libupm/src/ds2413/CMakeLists.txt
deleted file mode 100644
index b176d03..0000000
--- a/peripheral/libupm/src/ds2413/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set (libname "ds2413")
-set (libdescription "upm DS2413 1-wire Dual Channel Addressable Switch module")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/ds2413/ds2413.cxx b/peripheral/libupm/src/ds2413/ds2413.cxx
deleted file mode 100644
index 24f2795..0000000
--- a/peripheral/libupm/src/ds2413/ds2413.cxx
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-#include <time.h>
-#include <stdexcept>
-
-#include "ds2413.hpp"
-
-using namespace upm;
-using namespace std;
-
-
-DS2413::DS2413(int uart) :
- m_uart(uart)
-{
- m_devicesFound = 0;
-
- // check basic access to the 1-wire bus (presence detect)
- mraa::Result rv;
-
- if ((rv = m_uart.reset()) != mraa::SUCCESS)
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": reset() failed, no devices on bus?");
- return;
- }
-}
-
-DS2413::~DS2413()
-{
-}
-
-void DS2413::init()
-{
- // iterate through the bus and build up a list of detected DS2413
- // devices (only)
-
- // empty the map, in case this method has already been run once
- // before
- m_devicesFound = 0;
- m_deviceMap.clear();
-
- // start the search from scratch
- string id = m_uart.search(true);
-
- if (id.empty())
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": no devices detected on bus");
- return;
- }
-
- while (!id.empty())
- {
- // The first byte (id[0]]) is the device type (family) code. We
- // are only interested in the family code for this device (0x3a).
-
- if ((uint8_t)id[0] == DS2413_FAMILY_CODE)
- {
- // we have a winner, add it to our map and continue searching
-
- m_deviceMap[m_devicesFound] = id;
- m_devicesFound++;
- }
-
- // continue search
- id = m_uart.search(false);
- }
-
- if (!m_devicesFound)
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": no DS2413 devices found on bus");
- return;
- }
-}
-
-int DS2413::readGpios(int index)
-{
- if (index < 0 || index >= m_devicesFound)
- {
- throw std::out_of_range(std::string(__FUNCTION__) +
- ": device index out of range");
- return 0;
- }
-
- m_uart.command(ACCESS_READ, m_deviceMap[index]);
-
- uint8_t value = m_uart.readByte();
-
- // Validity is performed by taking the high nibble, inverting it, and
- // copmpating it to the low nibble. If they are equal, then the
- // data is good.
-
- if ( (value & 0x0f) != ((~value >> 4) & 0x0f) )
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": returned value failed integrity check");
- return 0;
- }
-
- m_uart.reset();
-
- // Only the 4 lsb's are relevant
- return (value & 0x0f);
-}
-
-void DS2413::writeGpios(int index, int value)
-{
- if (index < 0 || index >= m_devicesFound)
- {
- throw std::out_of_range(std::string(__FUNCTION__) +
- ": device index out of range");
- return;
- }
-
- // mask out everything but the first 2 bits
- uint8_t val = (uint8_t)value & 0x03;
-
- // the value must have the upper 8 bits written set to 1's
- val |= 0xfc;
-
- m_uart.command(ACCESS_WRITE, m_deviceMap[index]);
-
- // first we write the new value, then the inverted value
- m_uart.writeByte(val);
- m_uart.writeByte(~val);
-
- // now we read back a response indicating success or failure
- uint8_t resp = m_uart.readByte();
-
- if (resp != ACK_SUCCESS)
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": failed response validation");
- return;
- }
-
- m_uart.reset();
-
- return;
-
-}
diff --git a/peripheral/libupm/src/ds2413/ds2413.hpp b/peripheral/libupm/src/ds2413/ds2413.hpp
deleted file mode 100644
index 1e9e238..0000000
--- a/peripheral/libupm/src/ds2413/ds2413.hpp
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <iostream>
-#include <map>
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <mraa/common.hpp>
-#include <mraa/uart_ow.hpp>
-
-#define DS2413_DEFAULT_UART 0
-
-namespace upm {
- /**
- * @brief DS2413 modules
- * @defgroup ds2413 libupm-ds2413
- * @ingroup maxim uart gpio
- */
-
- /**
- * @library ds2413
- * @sensor ds2413
- * @comname DS2413 1-Wire Dual Channel Addressable Switch
- * @type gpio
- * @man maxim
- * @con uart
- * @web https://learn.adafruit.com/adafruit-1-wire-gpio-breakout-ds2413/overview
- *
- * @brief API for the DS2413 1-Wire Dual Channel Addressable Switch
- *
- * The DS2413 is a dual-channel programmable I/O 1-Wire® chip. The
- * PIO outputs are configured as open-drain and provide up to 20mA
- * continuous sink capability and off-state operating voltage up
- * to 28V. Control and sensing of the PIO pins is performed with
- * a dedicated device-level command protocol.
- *
- * This device requires the use of a UART to provide access to a
- * Dallas 1-wire bus, via a new facility supported by MRAA (once
- * the relevant PR is accepted), using the UartOW access class.
- * It is important to realize that the UART is only being used to
- * access and control a Dallas 1-wire compliant bus, it is not
- * actually a UART device.
- *
- * Multiple DS2413 devices can be connected to this bus. This
- * module will identify all such devices connected, and allow you
- * to access them using an index starting at 0.
- *
- * @snippet ds2413.cxx Interesting
- */
-
- class DS2413 {
- public:
-
- // The family code for these devices. We handle all of them that
- // are found on the bus.
- static const uint8_t DS2413_FAMILY_CODE = 0x3a;
-
- // commands
- typedef enum {
- ACCESS_READ = 0xf5,
- ACCESS_WRITE = 0x5a
- } DS2413_CMD_T;
-
- // possible ack responses for gpio writes
- typedef enum {
- ACK_SUCCESS = 0xaa,
- ACK_FAILURE = 0xff
- } DS2413_ACK_T;
-
- /**
- * DS2413 object constructor
- *
- * @param uart Default UART to use (0 or 1). Default is 0.
- */
- DS2413(int uart=DS2413_DEFAULT_UART);
-
- /**
- * DS2413 object destructor
- */
- ~DS2413();
-
- /**
- * This method will search the 1-wire bus and store information on
- * each device detected on the bus. If no devices are found, an
- * exception is thrown. Once this function completes
- * successfully, you can use devicesFound() to determine how many
- * devices were detected.
- */
- void init();
-
- /**
- * This method will return the number of DS2413 devices that were
- * found on the bus.
- *
- * @return number of DS2413's that were found on the bus
- */
- int devicesFound()
- {
- return m_devicesFound;
- }
-
- /**
- * Read the GPIO latches and values for a given device. Only the
- * lower 4 bits of the return value have any meaning. The bits
- * are formatted as follows (from msb to lsb):
- * <gpioB latch> <gpioB value> <gpioA latch> <gpioA value>
- *
- * @param index The device index to access (starts at 0). Default
- * is the first device (index = 0)
- * @return the 4 bit status of the 2 gpios
- */
- int readGpios(int index=0);
-
- /**
- * Write the given values to the gpio latches for a given device.
- * Only the lower 2 bits of the value have any meaning. The lsb
- * is gor gpioA and the next lsb is for gpioB:
- * <gpioB latch> <gpioA latch>
- *
- * @param index The device index to access (starts at 0).
- * @param value the value to write to the gpio latches
- */
- void writeGpios(int index, int value);
-
- /**
- * Return an 8 byte string representing the unique device ID for a
- * given device index. If the index is invalid, an empty strig
- * will be returned.
- *
- * @param index The device index to access (starts at 0).
- * @return 8 byte string representing the 1-wire device's unique
- * rom code.
- */
- std::string getId(int index)
- {
- return m_deviceMap[index];
- }
-
- protected:
- mraa::UartOW m_uart;
-
- // the total number of devices found
- int m_devicesFound;
-
- std::map<int, std::string> m_deviceMap;
-
- private:
- };
-}
diff --git a/peripheral/libupm/src/ds2413/javaupm_ds2413.i b/peripheral/libupm/src/ds2413/javaupm_ds2413.i
deleted file mode 100644
index c846950..0000000
--- a/peripheral/libupm/src/ds2413/javaupm_ds2413.i
+++ /dev/null
@@ -1,22 +0,0 @@
-%module javaupm_ds2413
-%include "../upm.i"
-%include "carrays.i"
-%include "std_string.i"
-
-%{
- #include "ds2413.hpp"
-%}
-
-%include "ds2413.hpp"
-%array_class(char, charArray);
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_ds2413");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/ds2413/jsupm_ds2413.i b/peripheral/libupm/src/ds2413/jsupm_ds2413.i
deleted file mode 100644
index af9ffaf..0000000
--- a/peripheral/libupm/src/ds2413/jsupm_ds2413.i
+++ /dev/null
@@ -1,11 +0,0 @@
-%module jsupm_ds2413
-%include "../upm.i"
-%include "carrays.i"
-%include "std_string.i"
-
-%{
- #include "ds2413.hpp"
-%}
-
-%include "ds2413.hpp"
-%array_class(char, charArray);
diff --git a/peripheral/libupm/src/ds2413/pyupm_ds2413.i b/peripheral/libupm/src/ds2413/pyupm_ds2413.i
deleted file mode 100644
index 819f71c..0000000
--- a/peripheral/libupm/src/ds2413/pyupm_ds2413.i
+++ /dev/null
@@ -1,12 +0,0 @@
-%module pyupm_ds2413
-%include "../upm.i"
-%include "carrays.i"
-%include "std_string.i"
-
-%feature("autodoc", "3");
-
-%{
- #include "ds2413.hpp"
-%}
-%include "ds2413.hpp"
-%array_class(char, charArray);
diff --git a/peripheral/libupm/src/e50hx/CMakeLists.txt b/peripheral/libupm/src/e50hx/CMakeLists.txt
deleted file mode 100644
index 609d586..0000000
--- a/peripheral/libupm/src/e50hx/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-set (libname "e50hx")
-set (libdescription "upm module for the Veris E50HX (E50H2/E50H5)Energy Meters")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-
-pkg_check_modules(BACNET libbacnet)
-if (BACNET_FOUND)
- # upm-libbacnetmstp will bring in libbacnet, I hope
- set (reqlibname "upm-bacnetmstp")
- include_directories(${BACNET_INCLUDE_DIRS})
- include_directories("../bacnetmstp")
- upm_module_init()
- target_link_libraries(${libname} bacnetmstp)
- if (BUILDSWIG)
- if (BUILDSWIGNODE)
- set_target_properties(${SWIG_MODULE_jsupm_${libname}_REAL_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE)
- swig_link_libraries (jsupm_${libname} bacnetmstp)
- endif()
- if (BUILDSWIGPYTHON)
- set_target_properties(${SWIG_MODULE_pyupm_${libname}_REAL_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE)
- swig_link_libraries (pyupm_${libname} bacnetmstp)
- endif()
- if (BUILDSWIGJAVA)
- set_target_properties(${SWIG_MODULE_javaupm_${libname}_REAL_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE)
- swig_link_libraries (javaupm_${libname} bacnetmstp)
- endif()
- endif()
-endif ()
diff --git a/peripheral/libupm/src/e50hx/e50hx.cxx b/peripheral/libupm/src/e50hx/e50hx.cxx
deleted file mode 100644
index f382b72..0000000
--- a/peripheral/libupm/src/e50hx/e50hx.cxx
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <assert.h>
-#include <errno.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-
-#include "e50hx.hpp"
-
-using namespace upm;
-using namespace std;
-
-
-E50HX::E50HX(uint32_t targetDeviceObjectID) :
- BACNETUTIL(targetDeviceObjectID)
-{
- setDebug(false);
-
- // we disable this by default for performance reasons
- checkReliability(false);
-}
-
-E50HX::~E50HX()
-{
-}
-
-uint16_t E50HX::getAlarmBits()
-{
- return uint16_t(getAnalogInput(AI_Alarm_Bitmap));
-}
-
-void E50HX::writeConfig(CFG_VALUES_T config)
-{
- setAnalogValue(AV_Config, float(config));
-}
-
-void E50HX::writeSystemType(SYSTEM_TYPES_T systype)
-{
- setAnalogValue(AV_System_Type, float(systype));
-}
-
-void E50HX::writeCTRatioPrimary(float ctRatio)
-{
- if (ctRatio < 5 || ctRatio > 32000)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": ctRatio must be between 5-32000");
- }
-
- setAnalogValue(AV_CT_Ratio_Primary, ctRatio);
-}
-
-void E50HX::writeCTRatioSecondary(CT_SECONDARY_T ctRatio)
-{
- setAnalogValue(AV_CT_Ratio_Secondary, ctRatio);
-}
-
-void E50HX::writePTRatio(float ptRatio)
-{
- if (ptRatio < 0.01 || ptRatio > 320.0)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": ptRatio must be between 0.01-320.0");
- }
-
- setAnalogValue(AV_PT_Ratio, ptRatio);
-}
-
-void E50HX::writeSystemVoltage(float sysVolts)
-{
- if (sysVolts < 82.0 || sysVolts > 32000.0)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": sysVolts must be between 82.0-32000.0");
- }
-
- setAnalogValue(AV_System_Voltage, sysVolts);
-}
-
-void E50HX::writeDisplayUnits(DISP_UNITS_T dispUnits)
-{
- setAnalogValue(AV_Display_Units, dispUnits);
-}
-
-void E50HX::writePhaseLossVT(float phaseLoss)
-{
- if (phaseLoss < 1.0 || phaseLoss > 99.0)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": phaseLoss must be between 1.0-99.0");
- }
-
- setAnalogValue(AV_Phase_Loss_Voltage_Threshold, phaseLoss);
-}
-
-void E50HX::writePhaseLossIT(float phaseLoss)
-{
- if (phaseLoss < 1.0 || phaseLoss > 99.0)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": phaseLoss must be between 1.0-99.0");
- }
-
- setAnalogValue(AV_Phase_Loss_Imbalance_Threshold, phaseLoss);
-}
diff --git a/peripheral/libupm/src/e50hx/e50hx.hpp b/peripheral/libupm/src/e50hx/e50hx.hpp
deleted file mode 100644
index c2f4b51..0000000
--- a/peripheral/libupm/src/e50hx/e50hx.hpp
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <map>
-
-#include "bacnetmstp.hpp"
-#include "bacnetutil.hpp"
-
-namespace upm {
-
- /**
- * @brief E50HX Energy Meter
- * @defgroup e50hx libupm-e50hx
- * @ingroup uart electric
- */
-
- /**
- * @library e50hx
- * @sensor e50hx
- * @comname UPM API for the Veris E50HX Energy Meters
- * @type electic
- * @man veris
- * @con uart
- * @web http://www.veris.com/Item/E50H5.aspx
- *
- * @brief UPM API for the Veris E50HX Energy Meter
- *
- * This module implements support for the Veris E50H2 and E50H5
- * BACnet Energy Meters.
- *
- * From the datasheet: The E50H5 BACnet MS/TP DIN Rail Meter with
- * Data Logging combines exceptional performance and easy
- * installation to deliver a cost-effective solution for power
- * monitoring applications. Native serial communication via BACnet
- * MS/TP provides complete accessibility of all measurements to your
- * Building Automation System The data logging capability protects
- * data in the event of a power failure. The E50H5 can be easily
- * installed on standard DIN rail, surface mounted or contained in
- * an optional NEMA 4 enclosure, as needed. The front-panel LCD
- * display makes device installation and setup easy and provides
- * local access to the full set of detailed measurements.
- *
- * This module was developed using the upm::BACNETMSTP module, based
- * on libbacnet-stack 0.8.3. Both libbacnet 0.8.3 and the
- * upm::BACNETMSTP libraries must be present in order to build this
- * module. This driver was developed on the E50H5. The Trend Log
- * functionality is not currently supported.
- *
- * The Binary Input Objects are also not supported as these are only
- * used for the Alarm bits which are already available from Analog
- * Input Object 52 as an alarm bitfield incorporating all of the
- * supported alarm indicators.
- *
- * It was connected using an RS232->RS485 interface. You cannot use
- * the built in MCU TTL UART pins for accessing this device -- you
- * must use a full Serial RS232->RS485 or USB-RS485 interface
- * connected via USB.
- *
- * @snippet e50hx.cxx Interesting
- */
-
- class E50HX : public BACNETUTIL {
- public:
-
- // Supported Analog Value Objects. These are readable and writable.
- typedef enum : uint32_t {
- AV_Config = 1, // always returns 0 on read
- AV_System_Type = 2,
- AV_CT_Ratio_Primary = 3,
- AV_CT_Ratio_Secondary = 4,
- AV_PT_Ratio = 5,
- AV_System_Voltage = 6,
- AV_Display_Units = 7,
- AV_Phase_Loss_Voltage_Threshold = 8,
- AV_Phase_Loss_Imbalance_Threshold = 9,
- AV_Subintervals = 10,
- AV_Subinterval_Length = 11
- } ANALOG_VALUES_T;
-
- // Supported Analog Input Objects. These are read only.
- typedef enum : uint32_t {
- AI_Energy = 1,
- AI_kW_Total = 2,
- AI_kVAR_Total = 3,
- AI_kVA_Total = 4,
- AI_PF_Total = 5,
- AI_Volts_LL_Avg = 6,
- AI_Volts_LN_Avg = 7,
- AI_Current_Avg = 8,
- AI_kW_A = 9,
- AI_kW_B = 10,
- AI_kW_C = 11,
- AI_PF_A = 12,
- AI_PF_B = 13,
- AI_PF_C = 14,
- AI_Volts_AB = 15,
- AI_Volts_BC = 16,
- AI_Volts_AC = 17,
- AI_Volts_AN = 18,
- AI_Volts_BN = 19,
- AI_Volts_CN = 20,
- AI_Current_A = 21,
- AI_Current_B = 22,
- AI_Current_C = 23,
- // AI24 is reserved
- AI_Frequency = 25,
- AI_kVAh = 26, // units = kVAh, not kWH
- AI_kVARh = 27, // units = kVAh, not kWH
- AI_kVA_A = 28,
- AI_kVA_B = 29,
- AI_kVA_C = 30,
- AI_kVAR_A = 31,
- AI_kVAR_B = 32,
- AI_kVAR_C = 33,
- AI_KW_Present_Demand = 34,
- AI_KVAR_Present_Demand = 35,
- AI_KWA_Present_Demand = 36,
- AI_KW_Max_Demand = 37,
- AI_KVAR_Max_Demand = 38,
- AI_KVA_Max_Demand = 39,
- AI_Pulse_Count_1 = 40, // H2 & H5
- // AI41 is reserved on H2 variant
- AI_Pulse_Count_2 = 41, // only on H5 variant
- AI_KWH_A = 42,
- AI_KWH_B = 43,
- AI_KWH_C = 44,
- AI_Max_Power = 45, // theoretical max power
- // AI46 reserved
- AI_Energy_Resets = 47,
- // AI48 and AI49 reserved
- AI_Power_Up_Count = 50,
- AI_Output_Config = 51, // H2 = 11, H5 = 10
- AI_Alarm_Bitmap = 52
- } ANALOG_INPUTS_T;
-
- // Alarm bits (AI52)
- typedef enum : uint16_t {
- ALARM_Volts_Error_A = 0x0001,
- ALARM_Volts_Error_B = 0x0002,
- ALARM_Volts_Error_C = 0x0004,
-
- ALARM_Current_Error_A = 0x0008,
- ALARM_Current_Error_B = 0x0010,
- ALARM_Current_Error_C = 0x0020,
-
- ALARM_Frequency_Error = 0x0040,
-
- ALARM_Reserved_0 = 0x0080, // reserved
-
- ALARM_Phase_Loss_A = 0x0100,
- ALARM_Phase_Loss_B = 0x0200,
- ALARM_Phase_Loss_C = 0x0400,
-
- ALARM_Power_Factor_A = 0x0800,
- ALARM_Power_Factor_B = 0x1000,
- ALARM_Power_Factor_C = 0x2000,
-
- ALARM_RTC_RESET = 0x4000 // H5 only
- } ALARM_BITS_T;
-
- // valid config values to write to AV1
- typedef enum {
- CFG_CLR_ENERGY_ACCUM = 30078, // clear energy accumulators
- CFG_NEW_DSI = 21211, // begin new demand subinterval
- CFG_RESET_MAX_TO_PRESENT = 21212, // reset max vals to present vals
- CFG_CLEAR_PULSE_COUNTERS = 16498 // clear the pulse counters
- } CFG_VALUES_T;
-
- // system type configuration
- typedef enum {
- SYSTYPE_SINGLE_PHASE_AN = 10,
- SYSTYPE_SINGLE_PHASE_AB = 11,
- SYSTYPE_SPLIT_PHASE_ABN = 12,
- SYSTYPE_3PHASE_ABC = 31,
- SYSTYPE_3PHASE_ABCN = 40
- } SYSTEM_TYPES_T;
-
- // CT input ratio
- typedef enum {
- CT_RATIO_SECONDARY_1 = 1, // CT's w/ 1v outputs
- CT_RATIO_SECONDARY_3 = 3 // CT's w/ 0.3v outputs
- } CT_SECONDARY_T;
-
- // LCD display units
- typedef enum {
- DISP_UNITS_IEC = 0, // IEC display units
- DISP_UNITS_IEEE = 1 // IEEE display units
- } DISP_UNITS_T;
-
- /**
- * E50HX constructor
- *
- * @param targetDeviceObjectID the unique Instance ID of the
- * Device Object. This number is used to uniquely identify
- * devices on the BACnet network, and ranges from 1 to 4194302.
- * This is not the device's MAC address, though on some devices,
- * the MAC address may be used as part of this number. On the
- * E50HX, this number is randomly generated per device, and you
- * can see this number (or change it) on the BACnet config screens
- * on the LCD.
- */
- E50HX(uint32_t targetDeviceObjectID);
-
- /**
- * E50HX Destructor
- */
- ~E50HX();
-
- /**
- * Write one of several 'magic' numbers to the configuration
- * object (AV1). This is used to clear certain counters, reset
- * the accumulated Energy consumption values, etc. This method
- * will throw on error.
- *
- * @param config One of the CFG_VALUES_T values
- */
- void writeConfig(CFG_VALUES_T config);
-
- /**
- * Set the System Type of the device. This defines the voltage
- * lines you have connected. This method will throw on error.
- *
- * @param systype One of the SYSTEM_TYPES_T values.
- */
- void writeSystemType(SYSTEM_TYPES_T systype);
-
- /**
- * Set the Primary CT ratio. See the datasheet for details. This
- * method will throw on error.
- *
- * @param ctRatio A floating point value between 5-32000
- */
- void writeCTRatioPrimary(float ctRatio);
-
- /**
- * Set the Secondary CT ratio. See the datasheet for details.
- * This method will throw on error.
- *
- * @param ctRatio One of the CT_SECONDARY_T values.
- */
- void writeCTRatioSecondary(CT_SECONDARY_T ctRatio);
-
- /**
- * Set the PT ratio. See the datasheet for details. This method
- * will throw on error.
- *
- * @param ptRatio A floating point value between 0.01-320.0
- */
- void writePTRatio(float ptRatio);
-
- /**
- * Set the System Voltage parmeter. See the datasheet for
- * details. This method will throw on error.
- *
- * @param sysVolts A floating point value between 82.0-32000.0
- */
- void writeSystemVoltage(float sysVolts);
-
- /**
- * Set the LCD Display Units in IEC or IEEE format. This method
- * will throw on error.
- *
- * @param dispUnits One of the DISP_UNITS_T values.
- */
- void writeDisplayUnits(DISP_UNITS_T dispUnits);
-
- /**
- * Set the Phase Loss Voltage Threshold. See the datasheet for
- * details. This method will throw on error.
- *
- * @param dispUnits A floating point value between 1.0-99.0
- */
- void writePhaseLossVT(float phaseLoss);
-
- /**
- * Set the Phase Loss Imbalance Threshold. See the datasheet for
- * details. This method will throw on error.
- *
- * @param dispUnits A floating point value between 1.0-99.0
- */
- void writePhaseLossIT(float phaseLoss);
-
- /**
- * Query the AI52 Object and return a bitmask of current Alarms.
- * Compare against ALARM_BITS_T to determine what conditions are
- * signaling an alarm. Alarm conditions will clear on their own
- * as soon as the cause is rectified. This method will throw on
- * error.
- *
- * @return A bitmask of values from ALARM_BITS_T indicating
- * current alarm conditions.
- */
- uint16_t getAlarmBits();
-
- protected:
- private:
- };
-}
diff --git a/peripheral/libupm/src/e50hx/javaupm_e50hx.i b/peripheral/libupm/src/e50hx/javaupm_e50hx.i
deleted file mode 100644
index 26244a7..0000000
--- a/peripheral/libupm/src/e50hx/javaupm_e50hx.i
+++ /dev/null
@@ -1,34 +0,0 @@
-%module javaupm_e50hx
-%include "../upm.i"
-%include "typemaps.i"
-%include "carrays_uint32_t.i"
-
-// We need to use this method for enum wrapping since the enum typedefs used
-// by the derived classes (like ANALOG_VALUES_T) are passed to methods
-// in the base class which expect a uint32_t. This is fine, and
-// works everywhere except Java. It's type safety is a little too
-// stringent in these cases. %javaconst(1) is generally recommended
-// as it avoids JNI calls to determine the enumerant values at
-// runtime.
-%include "enumtypeunsafe.swg"
-%javaconst(1);
-
-%include "bacnetmstp.hpp"
-%include "bacnetutil.hpp"
-%include "e50hx.hpp"
-%{
- #include "bacnetutil.hpp"
- #include "e50hx.hpp"
-%}
-
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_e50hx");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/e50hx/jsupm_e50hx.i b/peripheral/libupm/src/e50hx/jsupm_e50hx.i
deleted file mode 100644
index a8d9170..0000000
--- a/peripheral/libupm/src/e50hx/jsupm_e50hx.i
+++ /dev/null
@@ -1,10 +0,0 @@
-%module jsupm_e50hx
-%include "../upm.i"
-%include "stdint.i"
-
-%include "bacnetmstp.hpp"
-%include "bacnetutil.hpp"
-%include "e50hx.hpp"
-%{
- #include "e50hx.hpp"
-%}
diff --git a/peripheral/libupm/src/e50hx/pyupm_e50hx.i b/peripheral/libupm/src/e50hx/pyupm_e50hx.i
deleted file mode 100644
index 6786732..0000000
--- a/peripheral/libupm/src/e50hx/pyupm_e50hx.i
+++ /dev/null
@@ -1,14 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_e50hx
-%include "../upm.i"
-%include "stdint.i"
-
-%feature("autodoc", "3");
-
-%include "bacnetmstp.hpp"
-%include "bacnetutil.hpp"
-%include "e50hx.hpp"
-%{
- #include "e50hx.hpp"
-%}
diff --git a/peripheral/libupm/src/ecs1030/CMakeLists.txt b/peripheral/libupm/src/ecs1030/CMakeLists.txt
index caaf58e..ccbe8dc 100644
--- a/peripheral/libupm/src/ecs1030/CMakeLists.txt
+++ b/peripheral/libupm/src/ecs1030/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "ecs1030")
set (libdescription "Non-invasive current sensor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/ecs1030/ecs1030.cxx b/peripheral/libupm/src/ecs1030/ecs1030.cxx
index 90dd60a..aa1c73a 100644
--- a/peripheral/libupm/src/ecs1030/ecs1030.cxx
+++ b/peripheral/libupm/src/ecs1030/ecs1030.cxx
@@ -28,7 +28,7 @@
#include <string>
#include <stdexcept>
-#include "ecs1030.hpp"
+#include "ecs1030.h"
using namespace upm;
@@ -59,8 +59,6 @@ ECS1030::getCurrency_A () {
for (int i = 0; i < NUMBER_OF_SAMPLES; i++) {
sensorValue = mraa_aio_read (m_dataPinCtx);
- if (sensorValue == -1) throw std::runtime_error(std::string(__FUNCTION__) +
- ": Failed to do an aio read.");
volt = (VOLT_M * sensorValue) - 2.5;
volt = volt * volt;
rms = rms + volt;
@@ -79,8 +77,6 @@ ECS1030::getCurrency_B () {
for (int i = 0; i < NUMBER_OF_SAMPLES; i++) {
m_lastSample = m_sample;
m_sample = mraa_aio_read (m_dataPinCtx);
- if (m_sample == -1) throw std::runtime_error(std::string(__FUNCTION__) +
- ": Failed to do an aio read.");
m_lastFilter = m_filteredSample;
m_filteredSample = 0.996 * (m_lastFilter + m_sample - m_lastSample);
sumCurrency += (m_filteredSample * m_filteredSample);
diff --git a/peripheral/libupm/src/ecs1030/ecs1030.hpp b/peripheral/libupm/src/ecs1030/ecs1030.h
index 29deb4a..29deb4a 100644
--- a/peripheral/libupm/src/ecs1030/ecs1030.hpp
+++ b/peripheral/libupm/src/ecs1030/ecs1030.h
diff --git a/peripheral/libupm/src/ecs1030/javaupm_ecs1030.i b/peripheral/libupm/src/ecs1030/javaupm_ecs1030.i
index 54ac2bb..93f5c5e 100644
--- a/peripheral/libupm/src/ecs1030/javaupm_ecs1030.i
+++ b/peripheral/libupm/src/ecs1030/javaupm_ecs1030.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "ecs1030.hpp"
+ #include "ecs1030.h"
%}
-%include "ecs1030.hpp"
+%include "ecs1030.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/ecs1030/jsupm_ecs1030.i b/peripheral/libupm/src/ecs1030/jsupm_ecs1030.i
index ce30b75..12abd2c 100644
--- a/peripheral/libupm/src/ecs1030/jsupm_ecs1030.i
+++ b/peripheral/libupm/src/ecs1030/jsupm_ecs1030.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "ecs1030.hpp"
+ #include "ecs1030.h"
%}
-%include "ecs1030.hpp"
+%include "ecs1030.h"
diff --git a/peripheral/libupm/src/ecs1030/pyupm_ecs1030.i b/peripheral/libupm/src/ecs1030/pyupm_ecs1030.i
index baf82d1..82c4d95 100644
--- a/peripheral/libupm/src/ecs1030/pyupm_ecs1030.i
+++ b/peripheral/libupm/src/ecs1030/pyupm_ecs1030.i
@@ -7,7 +7,7 @@
%feature("autodoc", "3");
-%include "ecs1030.hpp"
+%include "ecs1030.h"
%{
- #include "ecs1030.hpp"
+ #include "ecs1030.h"
%}
diff --git a/peripheral/libupm/src/enc03r/CMakeLists.txt b/peripheral/libupm/src/enc03r/CMakeLists.txt
index 25bc77a..3fc0420 100644
--- a/peripheral/libupm/src/enc03r/CMakeLists.txt
+++ b/peripheral/libupm/src/enc03r/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "enc03r")
set (libdescription "upm enc03r single axis analog gyro module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/enc03r/enc03r.cxx b/peripheral/libupm/src/enc03r/enc03r.cxx
index 7dc4f65..6b1faa8 100644
--- a/peripheral/libupm/src/enc03r/enc03r.cxx
+++ b/peripheral/libupm/src/enc03r/enc03r.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "enc03r.hpp"
+#include "enc03r.h"
using namespace upm;
using namespace std;
@@ -51,10 +51,7 @@ ENC03R::~ENC03R()
unsigned int ENC03R::value()
{
- int x = mraa_aio_read(m_aio);
- if (x == -1) throw std::out_of_range(std::string(__FUNCTION__) +
- ": Failed to do an aio read.");
- return (unsigned int) x;
+ return mraa_aio_read(m_aio);
}
void ENC03R::calibrate(unsigned int samples)
@@ -65,8 +62,6 @@ void ENC03R::calibrate(unsigned int samples)
for (int i=0; i<samples; i++)
{
val = mraa_aio_read(m_aio);
- if (val == -1) throw std::out_of_range(std::string(__FUNCTION__) +
- ": Failed to do an aio read.");
total += (float)val;
usleep(2000);
}
diff --git a/peripheral/libupm/src/enc03r/enc03r.hpp b/peripheral/libupm/src/enc03r/enc03r.h
index 8587ea0..8587ea0 100644
--- a/peripheral/libupm/src/enc03r/enc03r.hpp
+++ b/peripheral/libupm/src/enc03r/enc03r.h
diff --git a/peripheral/libupm/src/enc03r/javaupm_enc03r.i b/peripheral/libupm/src/enc03r/javaupm_enc03r.i
index 5f901eb..2557969 100644
--- a/peripheral/libupm/src/enc03r/javaupm_enc03r.i
+++ b/peripheral/libupm/src/enc03r/javaupm_enc03r.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "enc03r.hpp"
+ #include "enc03r.h"
%}
-%include "enc03r.hpp"
+%include "enc03r.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/enc03r/jsupm_enc03r.i b/peripheral/libupm/src/enc03r/jsupm_enc03r.i
index 5e15060..b47cdd4 100644
--- a/peripheral/libupm/src/enc03r/jsupm_enc03r.i
+++ b/peripheral/libupm/src/enc03r/jsupm_enc03r.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "enc03r.hpp"
+ #include "enc03r.h"
%}
-%include "enc03r.hpp"
+%include "enc03r.h"
diff --git a/peripheral/libupm/src/enc03r/pyupm_enc03r.i b/peripheral/libupm/src/enc03r/pyupm_enc03r.i
index c76cd03..c50e66a 100644
--- a/peripheral/libupm/src/enc03r/pyupm_enc03r.i
+++ b/peripheral/libupm/src/enc03r/pyupm_enc03r.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "enc03r.hpp"
+%include "enc03r.h"
%{
- #include "enc03r.hpp"
+ #include "enc03r.h"
%}
diff --git a/peripheral/libupm/src/flex/CMakeLists.txt b/peripheral/libupm/src/flex/CMakeLists.txt
index e141053..5769281 100644
--- a/peripheral/libupm/src/flex/CMakeLists.txt
+++ b/peripheral/libupm/src/flex/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "flex")
set (libdescription "upm flex sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/flex/flex.cxx b/peripheral/libupm/src/flex/flex.cxx
index 0ab1d73..4e63362 100644
--- a/peripheral/libupm/src/flex/flex.cxx
+++ b/peripheral/libupm/src/flex/flex.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "flex.hpp"
+#include "flex.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/flex/flex.hpp b/peripheral/libupm/src/flex/flex.h
index 7ac4ad1..7ac4ad1 100644
--- a/peripheral/libupm/src/flex/flex.hpp
+++ b/peripheral/libupm/src/flex/flex.h
diff --git a/peripheral/libupm/src/flex/javaupm_flex.i b/peripheral/libupm/src/flex/javaupm_flex.i
index b4017c5..fc28dcf 100644
--- a/peripheral/libupm/src/flex/javaupm_flex.i
+++ b/peripheral/libupm/src/flex/javaupm_flex.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "flex.hpp"
+ #include "flex.h"
%}
-%include "flex.hpp"
+%include "flex.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/flex/jsupm_flex.i b/peripheral/libupm/src/flex/jsupm_flex.i
index eba2fd8..12c45f3 100644
--- a/peripheral/libupm/src/flex/jsupm_flex.i
+++ b/peripheral/libupm/src/flex/jsupm_flex.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "flex.hpp"
+ #include "flex.h"
%}
-%include "flex.hpp"
+%include "flex.h"
diff --git a/peripheral/libupm/src/flex/pyupm_flex.i b/peripheral/libupm/src/flex/pyupm_flex.i
index 9036994..e964689 100644
--- a/peripheral/libupm/src/flex/pyupm_flex.i
+++ b/peripheral/libupm/src/flex/pyupm_flex.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "flex.hpp"
+%include "flex.h"
%{
- #include "flex.hpp"
+ #include "flex.h"
%}
diff --git a/peripheral/libupm/src/gas/CMakeLists.txt b/peripheral/libupm/src/gas/CMakeLists.txt
index 76b36ca..9d50cc2 100644
--- a/peripheral/libupm/src/gas/CMakeLists.txt
+++ b/peripheral/libupm/src/gas/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "gas")
set (libdescription "Gas sensors")
set (module_src ${libname}.cxx mq2.cxx mq3.cxx mq4.cxx mq5.cxx mq6.cxx mq7.cxx mq8.cxx mq9.cxx tp401.cxx)
-set (module_hpp ${libname}.hpp mq2.hpp mq3.hpp mq4.hpp mq5.hpp mq6.hpp mq7.hpp mq8.hpp mq9.hpp tp401.hpp)
+set (module_h ${libname}.h mq2.h mq3.h mq4.h mq5.h mq6.h mq7.h mq8.h mq9.h tp401.h)
upm_module_init()
diff --git a/peripheral/libupm/src/gas/gas.cxx b/peripheral/libupm/src/gas/gas.cxx
index 1fd0a49..a43b82c 100644
--- a/peripheral/libupm/src/gas/gas.cxx
+++ b/peripheral/libupm/src/gas/gas.cxx
@@ -28,7 +28,7 @@
#include <functional>
#include <string.h>
#include <stdexcept>
-#include "gas.hpp"
+#include "gas.h"
using namespace upm;
diff --git a/peripheral/libupm/src/gas/gas.hpp b/peripheral/libupm/src/gas/gas.h
index 19bd781..19bd781 100644
--- a/peripheral/libupm/src/gas/gas.hpp
+++ b/peripheral/libupm/src/gas/gas.h
diff --git a/peripheral/libupm/src/gas/javaupm_gas.i b/peripheral/libupm/src/gas/javaupm_gas.i
index 6e87530..fc3b016 100644
--- a/peripheral/libupm/src/gas/javaupm_gas.i
+++ b/peripheral/libupm/src/gas/javaupm_gas.i
@@ -3,16 +3,16 @@
%include "typemaps.i"
%{
- #include "gas.hpp"
- #include "mq2.hpp"
- #include "mq3.hpp"
- #include "mq4.hpp"
- #include "mq5.hpp"
- #include "mq6.hpp"
- #include "mq7.hpp"
- #include "mq8.hpp"
- #include "mq9.hpp"
- #include "tp401.hpp"
+ #include "gas.h"
+ #include "mq2.h"
+ #include "mq3.h"
+ #include "mq4.h"
+ #include "mq5.h"
+ #include "mq6.h"
+ #include "mq7.h"
+ #include "mq8.h"
+ #include "mq9.h"
+ #include "tp401.h"
%}
%typemap(jni) (uint16_t *buffer, int len) "jshortArray";
@@ -45,16 +45,16 @@
JCALL3(ReleaseShortArrayElements, jenv, $input, (jshort *)$2, 0);
}
-%include "gas.hpp"
-%include "mq2.hpp"
-%include "mq3.hpp"
-%include "mq4.hpp"
-%include "mq5.hpp"
-%include "mq6.hpp"
-%include "mq7.hpp"
-%include "mq8.hpp"
-%include "mq9.hpp"
-%include "tp401.hpp"
+%include "gas.h"
+%include "mq2.h"
+%include "mq3.h"
+%include "mq4.h"
+%include "mq5.h"
+%include "mq6.h"
+%include "mq7.h"
+%include "mq8.h"
+%include "mq9.h"
+%include "tp401.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/gas/jsupm_gas.i b/peripheral/libupm/src/gas/jsupm_gas.i
index add44b1..25a5097 100644
--- a/peripheral/libupm/src/gas/jsupm_gas.i
+++ b/peripheral/libupm/src/gas/jsupm_gas.i
@@ -2,52 +2,52 @@
%include "../upm.i"
%include "../carrays_uint16_t.i"
-%include "gas.hpp"
+%include "gas.h"
%{
- #include "gas.hpp"
+ #include "gas.h"
%}
-%include "mq2.hpp"
+%include "mq2.h"
%{
- #include "mq2.hpp"
+ #include "mq2.h"
%}
-%include "mq3.hpp"
+%include "mq3.h"
%{
- #include "mq3.hpp"
+ #include "mq3.h"
%}
-%include "mq4.hpp"
+%include "mq4.h"
%{
- #include "mq4.hpp"
+ #include "mq4.h"
%}
-%include "mq5.hpp"
+%include "mq5.h"
%{
- #include "mq5.hpp"
+ #include "mq5.h"
%}
-%include "mq6.hpp"
+%include "mq6.h"
%{
- #include "mq6.hpp"
+ #include "mq6.h"
%}
-%include "mq7.hpp"
+%include "mq7.h"
%{
- #include "mq7.hpp"
+ #include "mq7.h"
%}
-%include "mq8.hpp"
+%include "mq8.h"
%{
- #include "mq8.hpp"
+ #include "mq8.h"
%}
-%include "mq9.hpp"
+%include "mq9.h"
%{
- #include "mq9.hpp"
+ #include "mq9.h"
%}
-%include "tp401.hpp"
+%include "tp401.h"
%{
- #include "tp401.hpp"
+ #include "tp401.h"
%}
diff --git a/peripheral/libupm/src/gas/mq2.cxx b/peripheral/libupm/src/gas/mq2.cxx
index 913c66a..d91dc35 100644
--- a/peripheral/libupm/src/gas/mq2.cxx
+++ b/peripheral/libupm/src/gas/mq2.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "mq2.hpp"
+#include "mq2.h"
using namespace upm;
diff --git a/peripheral/libupm/src/gas/mq2.hpp b/peripheral/libupm/src/gas/mq2.h
index 6126bde..a30d737 100644
--- a/peripheral/libupm/src/gas/mq2.hpp
+++ b/peripheral/libupm/src/gas/mq2.h
@@ -25,7 +25,7 @@
#include <iostream>
#include <string>
-#include "gas.hpp"
+#include "gas.h"
namespace upm {
/**
diff --git a/peripheral/libupm/src/gas/mq3.cxx b/peripheral/libupm/src/gas/mq3.cxx
index 609c885..f000a70 100644
--- a/peripheral/libupm/src/gas/mq3.cxx
+++ b/peripheral/libupm/src/gas/mq3.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "mq3.hpp"
+#include "mq3.h"
using namespace upm;
diff --git a/peripheral/libupm/src/gas/mq3.hpp b/peripheral/libupm/src/gas/mq3.h
index fb0af32..295e2aa 100644
--- a/peripheral/libupm/src/gas/mq3.hpp
+++ b/peripheral/libupm/src/gas/mq3.h
@@ -25,7 +25,7 @@
#include <iostream>
#include <string>
-#include "gas.hpp"
+#include "gas.h"
namespace upm {
/**
diff --git a/peripheral/libupm/src/gas/mq4.cxx b/peripheral/libupm/src/gas/mq4.cxx
index be07eb4..ac136ce 100644
--- a/peripheral/libupm/src/gas/mq4.cxx
+++ b/peripheral/libupm/src/gas/mq4.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "mq4.hpp"
+#include "mq4.h"
using namespace upm;
diff --git a/peripheral/libupm/src/gas/mq4.hpp b/peripheral/libupm/src/gas/mq4.h
index f06a229..581c908 100644
--- a/peripheral/libupm/src/gas/mq4.hpp
+++ b/peripheral/libupm/src/gas/mq4.h
@@ -25,7 +25,7 @@
#include <iostream>
#include <string>
-#include "gas.hpp"
+#include "gas.h"
namespace upm {
/**
diff --git a/peripheral/libupm/src/gas/mq5.cxx b/peripheral/libupm/src/gas/mq5.cxx
index ae0fcde..8d1536f 100644
--- a/peripheral/libupm/src/gas/mq5.cxx
+++ b/peripheral/libupm/src/gas/mq5.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "mq5.hpp"
+#include "mq5.h"
using namespace upm;
diff --git a/peripheral/libupm/src/gas/mq5.hpp b/peripheral/libupm/src/gas/mq5.h
index 2218b09..ec176f7 100644
--- a/peripheral/libupm/src/gas/mq5.hpp
+++ b/peripheral/libupm/src/gas/mq5.h
@@ -25,7 +25,7 @@
#include <iostream>
#include <string>
-#include "gas.hpp"
+#include "gas.h"
namespace upm {
/**
diff --git a/peripheral/libupm/src/gas/mq6.cxx b/peripheral/libupm/src/gas/mq6.cxx
index 023ade2..90fae15 100644
--- a/peripheral/libupm/src/gas/mq6.cxx
+++ b/peripheral/libupm/src/gas/mq6.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "mq6.hpp"
+#include "mq6.h"
using namespace upm;
diff --git a/peripheral/libupm/src/gas/mq6.hpp b/peripheral/libupm/src/gas/mq6.h
index 7a77b09..fafa7fd 100644
--- a/peripheral/libupm/src/gas/mq6.hpp
+++ b/peripheral/libupm/src/gas/mq6.h
@@ -25,7 +25,7 @@
#include <iostream>
#include <string>
-#include "gas.hpp"
+#include "gas.h"
namespace upm {
/**
diff --git a/peripheral/libupm/src/gas/mq7.cxx b/peripheral/libupm/src/gas/mq7.cxx
index c6a3463..76201a4 100644
--- a/peripheral/libupm/src/gas/mq7.cxx
+++ b/peripheral/libupm/src/gas/mq7.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "mq7.hpp"
+#include "mq7.h"
using namespace upm;
diff --git a/peripheral/libupm/src/gas/mq7.hpp b/peripheral/libupm/src/gas/mq7.h
index 4707c5b..1550a3e 100644
--- a/peripheral/libupm/src/gas/mq7.hpp
+++ b/peripheral/libupm/src/gas/mq7.h
@@ -25,7 +25,7 @@
#include <iostream>
#include <string>
-#include "gas.hpp"
+#include "gas.h"
namespace upm {
/**
diff --git a/peripheral/libupm/src/gas/mq8.cxx b/peripheral/libupm/src/gas/mq8.cxx
index bc6e0a9..667eab5 100644
--- a/peripheral/libupm/src/gas/mq8.cxx
+++ b/peripheral/libupm/src/gas/mq8.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "mq8.hpp"
+#include "mq8.h"
using namespace upm;
diff --git a/peripheral/libupm/src/gas/mq8.hpp b/peripheral/libupm/src/gas/mq8.h
index 3f7f780..10bc7a4 100644
--- a/peripheral/libupm/src/gas/mq8.hpp
+++ b/peripheral/libupm/src/gas/mq8.h
@@ -25,7 +25,7 @@
#include <iostream>
#include <string>
-#include "gas.hpp"
+#include "gas.h"
namespace upm {
/**
diff --git a/peripheral/libupm/src/gas/mq9.cxx b/peripheral/libupm/src/gas/mq9.cxx
index bd7aa74..f9ee171 100644
--- a/peripheral/libupm/src/gas/mq9.cxx
+++ b/peripheral/libupm/src/gas/mq9.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "mq9.hpp"
+#include "mq9.h"
using namespace upm;
diff --git a/peripheral/libupm/src/gas/mq9.hpp b/peripheral/libupm/src/gas/mq9.h
index 41d8791..dada03a 100644
--- a/peripheral/libupm/src/gas/mq9.hpp
+++ b/peripheral/libupm/src/gas/mq9.h
@@ -25,7 +25,7 @@
#include <iostream>
#include <string>
-#include "gas.hpp"
+#include "gas.h"
namespace upm {
/**
diff --git a/peripheral/libupm/src/gas/pyupm_gas.i b/peripheral/libupm/src/gas/pyupm_gas.i
index 7029ccf..1af489d 100644
--- a/peripheral/libupm/src/gas/pyupm_gas.i
+++ b/peripheral/libupm/src/gas/pyupm_gas.i
@@ -6,52 +6,52 @@
%feature("autodoc", "3");
-%include "gas.hpp"
+%include "gas.h"
%{
- #include "gas.hpp"
+ #include "gas.h"
%}
-%include "mq2.hpp"
+%include "mq2.h"
%{
- #include "mq2.hpp"
+ #include "mq2.h"
%}
-%include "mq3.hpp"
+%include "mq3.h"
%{
- #include "mq3.hpp"
+ #include "mq3.h"
%}
-%include "mq4.hpp"
+%include "mq4.h"
%{
- #include "mq4.hpp"
+ #include "mq4.h"
%}
-%include "mq5.hpp"
+%include "mq5.h"
%{
- #include "mq5.hpp"
+ #include "mq5.h"
%}
-%include "mq6.hpp"
+%include "mq6.h"
%{
- #include "mq6.hpp"
+ #include "mq6.h"
%}
-%include "mq7.hpp"
+%include "mq7.h"
%{
- #include "mq7.hpp"
+ #include "mq7.h"
%}
-%include "mq8.hpp"
+%include "mq8.h"
%{
- #include "mq8.hpp"
+ #include "mq8.h"
%}
-%include "mq9.hpp"
+%include "mq9.h"
%{
- #include "mq9.hpp"
+ #include "mq9.h"
%}
-%include "tp401.hpp"
+%include "tp401.h"
%{
- #include "tp401.hpp"
+ #include "tp401.h"
%}
diff --git a/peripheral/libupm/src/gas/tp401.cxx b/peripheral/libupm/src/gas/tp401.cxx
index 6df491c..9426355 100644
--- a/peripheral/libupm/src/gas/tp401.cxx
+++ b/peripheral/libupm/src/gas/tp401.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "tp401.hpp"
+#include "tp401.h"
using namespace upm;
diff --git a/peripheral/libupm/src/gas/tp401.hpp b/peripheral/libupm/src/gas/tp401.h
index 14b15c0..494cbb5 100644
--- a/peripheral/libupm/src/gas/tp401.hpp
+++ b/peripheral/libupm/src/gas/tp401.h
@@ -25,7 +25,7 @@
#include <iostream>
#include <string>
-#include "gas.hpp"
+#include "gas.h"
namespace upm {
/**
diff --git a/peripheral/libupm/src/gp2y0a/CMakeLists.txt b/peripheral/libupm/src/gp2y0a/CMakeLists.txt
index e6b56ec..ddb50a5 100644
--- a/peripheral/libupm/src/gp2y0a/CMakeLists.txt
+++ b/peripheral/libupm/src/gp2y0a/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "gp2y0a")
set (libdescription "upm gp2y0a family of IR distance detectors")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/gp2y0a/gp2y0a.cxx b/peripheral/libupm/src/gp2y0a/gp2y0a.cxx
index 0b375a9..07abc7d 100644
--- a/peripheral/libupm/src/gp2y0a/gp2y0a.cxx
+++ b/peripheral/libupm/src/gp2y0a/gp2y0a.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "gp2y0a.hpp"
+#include "gp2y0a.h"
using namespace std;
using namespace upm;
@@ -57,8 +57,6 @@ float GP2Y0A::value(float aref, uint8_t samples)
for (int i=0; i<samples; i++)
{
val = mraa_aio_read(m_aio);
- if (val != -1) throw std::runtime_error(std::string(__FUNCTION__) +
- ": Failed to do an aio read.");
sum += val;
}
diff --git a/peripheral/libupm/src/gp2y0a/gp2y0a.hpp b/peripheral/libupm/src/gp2y0a/gp2y0a.h
index d3d4213..d3d4213 100644
--- a/peripheral/libupm/src/gp2y0a/gp2y0a.hpp
+++ b/peripheral/libupm/src/gp2y0a/gp2y0a.h
diff --git a/peripheral/libupm/src/gp2y0a/javaupm_gp2y0a.i b/peripheral/libupm/src/gp2y0a/javaupm_gp2y0a.i
index 7edfcea..8b2f761 100644
--- a/peripheral/libupm/src/gp2y0a/javaupm_gp2y0a.i
+++ b/peripheral/libupm/src/gp2y0a/javaupm_gp2y0a.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "gp2y0a.hpp"
+ #include "gp2y0a.h"
%}
-%include "gp2y0a.hpp"
+%include "gp2y0a.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/gp2y0a/jsupm_gp2y0a.i b/peripheral/libupm/src/gp2y0a/jsupm_gp2y0a.i
index 81f731f..95eaad2 100644
--- a/peripheral/libupm/src/gp2y0a/jsupm_gp2y0a.i
+++ b/peripheral/libupm/src/gp2y0a/jsupm_gp2y0a.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "gp2y0a.hpp"
+ #include "gp2y0a.h"
%}
-%include "gp2y0a.hpp"
+%include "gp2y0a.h"
diff --git a/peripheral/libupm/src/gp2y0a/pyupm_gp2y0a.i b/peripheral/libupm/src/gp2y0a/pyupm_gp2y0a.i
index dab897a..dba38d3 100644
--- a/peripheral/libupm/src/gp2y0a/pyupm_gp2y0a.i
+++ b/peripheral/libupm/src/gp2y0a/pyupm_gp2y0a.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "gp2y0a.hpp"
+%include "gp2y0a.h"
%{
- #include "gp2y0a.hpp"
+ #include "gp2y0a.h"
%}
diff --git a/peripheral/libupm/src/grove/CMakeLists.txt b/peripheral/libupm/src/grove/CMakeLists.txt
index e76ac5d..c102c2e 100644
--- a/peripheral/libupm/src/grove/CMakeLists.txt
+++ b/peripheral/libupm/src/grove/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "grove")
set (libdescription "upm grove module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/grove/grove.cxx b/peripheral/libupm/src/grove/grove.cxx
index b0be12d..4be1f3e 100644
--- a/peripheral/libupm/src/grove/grove.cxx
+++ b/peripheral/libupm/src/grove/grove.cxx
@@ -28,7 +28,7 @@
#include <string>
#include <stdexcept>
-#include "grove.hpp"
+#include "grove.h"
#include "math.h"
using namespace upm;
@@ -109,7 +109,7 @@ bool GroveRelay::isOff()
//// GroveTemp ////
-GroveTemp::GroveTemp(unsigned int pin, float scale)
+GroveTemp::GroveTemp(unsigned int pin)
{
if ( !(m_aio = mraa_aio_init(pin)) ) {
throw std::invalid_argument(std::string(__FUNCTION__) +
@@ -117,7 +117,6 @@ GroveTemp::GroveTemp(unsigned int pin, float scale)
return;
}
m_name = "Temperature Sensor";
- m_scale = scale;
}
GroveTemp::~GroveTemp()
@@ -127,10 +126,7 @@ GroveTemp::~GroveTemp()
int GroveTemp::value ()
{
- float a = (float) mraa_aio_read(m_aio);
- if (a == -1.0) return -1;
- // Apply scale factor after error check
- a *= m_scale;
+ int a = mraa_aio_read(m_aio);
float r = (float)(1023.0-a)*10000.0/a;
float t = 1.0/(log(r/10000.0)/3975.0 + 1.0/298.15)-273.15;
return (int) round(t);
@@ -162,7 +158,6 @@ int GroveLight::value()
{
// rough conversion to lux, using formula from Grove Starter Kit booklet
float a = (float) mraa_aio_read(m_aio);
- if (a == -1.0) return -1;
a = 10000.0/pow(((1023.0-a)*10.0/a)*15.0,4.0/3.0);
return (int) round(a);
}
diff --git a/peripheral/libupm/src/grove/grove.hpp b/peripheral/libupm/src/grove/grove.h
index a3e13c6..1ef60e9 100644
--- a/peripheral/libupm/src/grove/grove.hpp
+++ b/peripheral/libupm/src/grove/grove.h
@@ -171,10 +171,8 @@ class GroveTemp: public Grove {
* Grove analog temperature sensor constructor
*
* @param pin Analog pin to use
- * @param scale Scaling factor for raw analog value from the ADC,
- * useful for mixed 3.3V/5V boards
*/
- GroveTemp(unsigned int pin, float scale = 1.0);
+ GroveTemp(unsigned int pin);
/**
* GroveTemp destructor
*/
@@ -193,7 +191,6 @@ class GroveTemp: public Grove {
int value();
private:
mraa_aio_context m_aio;
- float m_scale;
};
/**
diff --git a/peripheral/libupm/src/grove/grovebutton.hpp b/peripheral/libupm/src/grove/grovebutton.h
index 6f746cc..6f746cc 100644
--- a/peripheral/libupm/src/grove/grovebutton.hpp
+++ b/peripheral/libupm/src/grove/grovebutton.h
diff --git a/peripheral/libupm/src/grove/groveled.hpp b/peripheral/libupm/src/grove/groveled.h
index c35c653..c35c653 100644
--- a/peripheral/libupm/src/grove/groveled.hpp
+++ b/peripheral/libupm/src/grove/groveled.h
diff --git a/peripheral/libupm/src/grove/grovelight.hpp b/peripheral/libupm/src/grove/grovelight.h
index b71d8ad..b71d8ad 100644
--- a/peripheral/libupm/src/grove/grovelight.hpp
+++ b/peripheral/libupm/src/grove/grovelight.h
diff --git a/peripheral/libupm/src/grove/groverelay.hpp b/peripheral/libupm/src/grove/groverelay.h
index 6edc77d..6edc77d 100644
--- a/peripheral/libupm/src/grove/groverelay.hpp
+++ b/peripheral/libupm/src/grove/groverelay.h
diff --git a/peripheral/libupm/src/grove/groverotary.hpp b/peripheral/libupm/src/grove/groverotary.h
index ee98978..ee98978 100644
--- a/peripheral/libupm/src/grove/groverotary.hpp
+++ b/peripheral/libupm/src/grove/groverotary.h
diff --git a/peripheral/libupm/src/grove/groveslide.hpp b/peripheral/libupm/src/grove/groveslide.h
index e3cbba1..e3cbba1 100644
--- a/peripheral/libupm/src/grove/groveslide.hpp
+++ b/peripheral/libupm/src/grove/groveslide.h
diff --git a/peripheral/libupm/src/grove/grovetemp.hpp b/peripheral/libupm/src/grove/grovetemp.h
index d85ac3e..d85ac3e 100644
--- a/peripheral/libupm/src/grove/grovetemp.hpp
+++ b/peripheral/libupm/src/grove/grovetemp.h
diff --git a/peripheral/libupm/src/grove/javaupm_grove.i b/peripheral/libupm/src/grove/javaupm_grove.i
index 72cc8ad..ab9636b 100644
--- a/peripheral/libupm/src/grove/javaupm_grove.i
+++ b/peripheral/libupm/src/grove/javaupm_grove.i
@@ -5,10 +5,10 @@
%apply int {mraa::Edge}
%{
- #include "grove.hpp"
+ #include "grove.h"
%}
-%include "grove.hpp"
+%include "grove.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/grove/jsupm_grove.i b/peripheral/libupm/src/grove/jsupm_grove.i
index 59269d9..b1f9e7d 100644
--- a/peripheral/libupm/src/grove/jsupm_grove.i
+++ b/peripheral/libupm/src/grove/jsupm_grove.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "grove.hpp"
+ #include "grove.h"
%}
-%include "grove.hpp"
+%include "grove.h"
diff --git a/peripheral/libupm/src/grove/pyupm_grove.i b/peripheral/libupm/src/grove/pyupm_grove.i
index 1edd802..b61c155 100644
--- a/peripheral/libupm/src/grove/pyupm_grove.i
+++ b/peripheral/libupm/src/grove/pyupm_grove.i
@@ -9,7 +9,7 @@
%include "grove_doc.i"
#endif
-%include "grove.hpp"
+%include "grove.h"
%{
- #include "grove.hpp"
+ #include "grove.h"
%}
diff --git a/peripheral/libupm/src/grovecollision/CMakeLists.txt b/peripheral/libupm/src/grovecollision/CMakeLists.txt
index 38a5b34..0bdce67 100644
--- a/peripheral/libupm/src/grovecollision/CMakeLists.txt
+++ b/peripheral/libupm/src/grovecollision/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "grovecollision")
set (libdescription "upm grovecollision sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init("-lrt")
diff --git a/peripheral/libupm/src/grovecollision/grovecollision.cxx b/peripheral/libupm/src/grovecollision/grovecollision.cxx
index d83e02e..fd8aa9b 100644
--- a/peripheral/libupm/src/grovecollision/grovecollision.cxx
+++ b/peripheral/libupm/src/grovecollision/grovecollision.cxx
@@ -25,7 +25,7 @@
#include <string>
#include <stdexcept>
-#include "grovecollision.hpp"
+#include "grovecollision.h"
using namespace upm;
diff --git a/peripheral/libupm/src/grovecollision/grovecollision.hpp b/peripheral/libupm/src/grovecollision/grovecollision.h
index 57b93f6..57b93f6 100644
--- a/peripheral/libupm/src/grovecollision/grovecollision.hpp
+++ b/peripheral/libupm/src/grovecollision/grovecollision.h
diff --git a/peripheral/libupm/src/grovecollision/javaupm_grovecollision.i b/peripheral/libupm/src/grovecollision/javaupm_grovecollision.i
index 39b5025..7cb1049 100644
--- a/peripheral/libupm/src/grovecollision/javaupm_grovecollision.i
+++ b/peripheral/libupm/src/grovecollision/javaupm_grovecollision.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "grovecollision.hpp"
+ #include "grovecollision.h"
%}
-%include "grovecollision.hpp"
+%include "grovecollision.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/grovecollision/jsupm_grovecollision.i b/peripheral/libupm/src/grovecollision/jsupm_grovecollision.i
index 7cd1ca0..5164b3e 100644
--- a/peripheral/libupm/src/grovecollision/jsupm_grovecollision.i
+++ b/peripheral/libupm/src/grovecollision/jsupm_grovecollision.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "grovecollision.hpp"
+ #include "grovecollision.h"
%}
-%include "grovecollision.hpp"
+%include "grovecollision.h"
diff --git a/peripheral/libupm/src/grovecollision/pyupm_grovecollision.i b/peripheral/libupm/src/grovecollision/pyupm_grovecollision.i
index 7ce2d3f..3d128a0 100644
--- a/peripheral/libupm/src/grovecollision/pyupm_grovecollision.i
+++ b/peripheral/libupm/src/grovecollision/pyupm_grovecollision.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "grovecollision.hpp"
+%include "grovecollision.h"
%{
- #include "grovecollision.hpp"
+ #include "grovecollision.h"
%}
diff --git a/peripheral/libupm/src/groveehr/CMakeLists.txt b/peripheral/libupm/src/groveehr/CMakeLists.txt
index f53d9c2..32efe5a 100644
--- a/peripheral/libupm/src/groveehr/CMakeLists.txt
+++ b/peripheral/libupm/src/groveehr/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "groveehr")
set (libdescription "upm grove ear-clip heart rate sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/groveehr/groveehr.cxx b/peripheral/libupm/src/groveehr/groveehr.cxx
index 953e5f5..d2b0cd9 100644
--- a/peripheral/libupm/src/groveehr/groveehr.cxx
+++ b/peripheral/libupm/src/groveehr/groveehr.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "groveehr.hpp"
+#include "groveehr.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/groveehr/groveehr.hpp b/peripheral/libupm/src/groveehr/groveehr.h
index 371fe83..371fe83 100644
--- a/peripheral/libupm/src/groveehr/groveehr.hpp
+++ b/peripheral/libupm/src/groveehr/groveehr.h
diff --git a/peripheral/libupm/src/groveehr/javaupm_groveehr.i b/peripheral/libupm/src/groveehr/javaupm_groveehr.i
index 2ac1d9c..2b5d110 100644
--- a/peripheral/libupm/src/groveehr/javaupm_groveehr.i
+++ b/peripheral/libupm/src/groveehr/javaupm_groveehr.i
@@ -4,10 +4,10 @@
%ignore beatISR;
%{
- #include "groveehr.hpp"
+ #include "groveehr.h"
%}
-%include "groveehr.hpp"
+%include "groveehr.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/groveehr/jsupm_groveehr.i b/peripheral/libupm/src/groveehr/jsupm_groveehr.i
index 3005cc9..9c324ba 100644
--- a/peripheral/libupm/src/groveehr/jsupm_groveehr.i
+++ b/peripheral/libupm/src/groveehr/jsupm_groveehr.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "groveehr.hpp"
+ #include "groveehr.h"
%}
-%include "groveehr.hpp"
+%include "groveehr.h"
diff --git a/peripheral/libupm/src/groveehr/pyupm_groveehr.i b/peripheral/libupm/src/groveehr/pyupm_groveehr.i
index 002a85e..0568df4 100644
--- a/peripheral/libupm/src/groveehr/pyupm_groveehr.i
+++ b/peripheral/libupm/src/groveehr/pyupm_groveehr.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "groveehr.hpp"
+%include "groveehr.h"
%{
- #include "groveehr.hpp"
+ #include "groveehr.h"
%}
diff --git a/peripheral/libupm/src/groveeldriver/CMakeLists.txt b/peripheral/libupm/src/groveeldriver/CMakeLists.txt
index 2ed1979..9ce5b02 100644
--- a/peripheral/libupm/src/groveeldriver/CMakeLists.txt
+++ b/peripheral/libupm/src/groveeldriver/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "groveeldriver")
set (libdescription "upm groveeldriver sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init("-lrt")
diff --git a/peripheral/libupm/src/groveeldriver/groveeldriver.cxx b/peripheral/libupm/src/groveeldriver/groveeldriver.cxx
index 322d666..c8755d6 100644
--- a/peripheral/libupm/src/groveeldriver/groveeldriver.cxx
+++ b/peripheral/libupm/src/groveeldriver/groveeldriver.cxx
@@ -25,7 +25,7 @@
#include <string>
#include <stdexcept>
-#include "groveeldriver.hpp"
+#include "groveeldriver.h"
using namespace upm;
diff --git a/peripheral/libupm/src/groveeldriver/groveeldriver.hpp b/peripheral/libupm/src/groveeldriver/groveeldriver.h
index 7ed7963..7ed7963 100644
--- a/peripheral/libupm/src/groveeldriver/groveeldriver.hpp
+++ b/peripheral/libupm/src/groveeldriver/groveeldriver.h
diff --git a/peripheral/libupm/src/groveeldriver/javaupm_groveeldriver.i b/peripheral/libupm/src/groveeldriver/javaupm_groveeldriver.i
index f6e6787..061329c 100644
--- a/peripheral/libupm/src/groveeldriver/javaupm_groveeldriver.i
+++ b/peripheral/libupm/src/groveeldriver/javaupm_groveeldriver.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "groveeldriver.hpp"
+ #include "groveeldriver.h"
%}
-%include "groveeldriver.hpp"
+%include "groveeldriver.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/groveeldriver/jsupm_groveeldriver.i b/peripheral/libupm/src/groveeldriver/jsupm_groveeldriver.i
index bfd05ac..28964e8 100644
--- a/peripheral/libupm/src/groveeldriver/jsupm_groveeldriver.i
+++ b/peripheral/libupm/src/groveeldriver/jsupm_groveeldriver.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "groveeldriver.hpp"
+ #include "groveeldriver.h"
%}
-%include "groveeldriver.hpp"
+%include "groveeldriver.h"
diff --git a/peripheral/libupm/src/groveeldriver/pyupm_groveeldriver.i b/peripheral/libupm/src/groveeldriver/pyupm_groveeldriver.i
index 002797d..057367b 100644
--- a/peripheral/libupm/src/groveeldriver/pyupm_groveeldriver.i
+++ b/peripheral/libupm/src/groveeldriver/pyupm_groveeldriver.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "groveeldriver.hpp"
+%include "groveeldriver.h"
%{
- #include "groveeldriver.hpp"
+ #include "groveeldriver.h"
%}
diff --git a/peripheral/libupm/src/groveelectromagnet/CMakeLists.txt b/peripheral/libupm/src/groveelectromagnet/CMakeLists.txt
index a12d371..69b1d88 100644
--- a/peripheral/libupm/src/groveelectromagnet/CMakeLists.txt
+++ b/peripheral/libupm/src/groveelectromagnet/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "groveelectromagnet")
set (libdescription "upm groveelectromagnet sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init("-lrt")
diff --git a/peripheral/libupm/src/groveelectromagnet/groveelectromagnet.cxx b/peripheral/libupm/src/groveelectromagnet/groveelectromagnet.cxx
index e7206f7..d3e118d 100644
--- a/peripheral/libupm/src/groveelectromagnet/groveelectromagnet.cxx
+++ b/peripheral/libupm/src/groveelectromagnet/groveelectromagnet.cxx
@@ -25,7 +25,7 @@
#include <string>
#include <stdexcept>
-#include "groveelectromagnet.hpp"
+#include "groveelectromagnet.h"
using namespace upm;
diff --git a/peripheral/libupm/src/groveelectromagnet/groveelectromagnet.hpp b/peripheral/libupm/src/groveelectromagnet/groveelectromagnet.h
index c39ae4c..c39ae4c 100644
--- a/peripheral/libupm/src/groveelectromagnet/groveelectromagnet.hpp
+++ b/peripheral/libupm/src/groveelectromagnet/groveelectromagnet.h
diff --git a/peripheral/libupm/src/groveelectromagnet/javaupm_groveelectromagnet.i b/peripheral/libupm/src/groveelectromagnet/javaupm_groveelectromagnet.i
index ecfffde..5def283 100644
--- a/peripheral/libupm/src/groveelectromagnet/javaupm_groveelectromagnet.i
+++ b/peripheral/libupm/src/groveelectromagnet/javaupm_groveelectromagnet.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "groveelectromagnet.hpp"
+ #include "groveelectromagnet.h"
%}
-%include "groveelectromagnet.hpp"
+%include "groveelectromagnet.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/groveelectromagnet/jsupm_groveelectromagnet.i b/peripheral/libupm/src/groveelectromagnet/jsupm_groveelectromagnet.i
index 62d5ac9..323a8fb 100644
--- a/peripheral/libupm/src/groveelectromagnet/jsupm_groveelectromagnet.i
+++ b/peripheral/libupm/src/groveelectromagnet/jsupm_groveelectromagnet.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "groveelectromagnet.hpp"
+ #include "groveelectromagnet.h"
%}
-%include "groveelectromagnet.hpp"
+%include "groveelectromagnet.h"
diff --git a/peripheral/libupm/src/groveelectromagnet/pyupm_groveelectromagnet.i b/peripheral/libupm/src/groveelectromagnet/pyupm_groveelectromagnet.i
index 82492c3..8102266 100644
--- a/peripheral/libupm/src/groveelectromagnet/pyupm_groveelectromagnet.i
+++ b/peripheral/libupm/src/groveelectromagnet/pyupm_groveelectromagnet.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "groveelectromagnet.hpp"
+%include "groveelectromagnet.h"
%{
- #include "groveelectromagnet.hpp"
+ #include "groveelectromagnet.h"
%}
diff --git a/peripheral/libupm/src/groveemg/CMakeLists.txt b/peripheral/libupm/src/groveemg/CMakeLists.txt
index a65dec3..7e2388d 100644
--- a/peripheral/libupm/src/groveemg/CMakeLists.txt
+++ b/peripheral/libupm/src/groveemg/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "groveemg")
set (libdescription "upm groveemg muscle signal reader sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/groveemg/groveemg.cxx b/peripheral/libupm/src/groveemg/groveemg.cxx
index 538c6b5..17f3d25 100644
--- a/peripheral/libupm/src/groveemg/groveemg.cxx
+++ b/peripheral/libupm/src/groveemg/groveemg.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "groveemg.hpp"
+#include "groveemg.h"
using namespace upm;
using namespace std;
@@ -53,8 +53,6 @@ void GroveEMG::calibrate()
for (int i=0; i<1100; i++)
{
val = mraa_aio_read(m_aio);
- if (val != -1) throw std::runtime_error(std::string(__FUNCTION__) +
- ": Failed to do an aio read.");
sum += val;
usleep(1000);
}
diff --git a/peripheral/libupm/src/groveemg/groveemg.hpp b/peripheral/libupm/src/groveemg/groveemg.h
index eef5fa3..eef5fa3 100644
--- a/peripheral/libupm/src/groveemg/groveemg.hpp
+++ b/peripheral/libupm/src/groveemg/groveemg.h
diff --git a/peripheral/libupm/src/groveemg/javaupm_groveemg.i b/peripheral/libupm/src/groveemg/javaupm_groveemg.i
index 9c66328..c829829 100644
--- a/peripheral/libupm/src/groveemg/javaupm_groveemg.i
+++ b/peripheral/libupm/src/groveemg/javaupm_groveemg.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "groveemg.hpp"
+ #include "groveemg.h"
%}
-%include "groveemg.hpp"
+%include "groveemg.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/groveemg/jsupm_groveemg.i b/peripheral/libupm/src/groveemg/jsupm_groveemg.i
index 9904172..7cac045 100644
--- a/peripheral/libupm/src/groveemg/jsupm_groveemg.i
+++ b/peripheral/libupm/src/groveemg/jsupm_groveemg.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "groveemg.hpp"
+ #include "groveemg.h"
%}
-%include "groveemg.hpp"
+%include "groveemg.h"
diff --git a/peripheral/libupm/src/groveemg/pyupm_groveemg.i b/peripheral/libupm/src/groveemg/pyupm_groveemg.i
index 09ce0c9..8bccef2 100644
--- a/peripheral/libupm/src/groveemg/pyupm_groveemg.i
+++ b/peripheral/libupm/src/groveemg/pyupm_groveemg.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "groveemg.hpp"
+%include "groveemg.h"
%{
- #include "groveemg.hpp"
+ #include "groveemg.h"
%}
diff --git a/peripheral/libupm/src/grovegprs/CMakeLists.txt b/peripheral/libupm/src/grovegprs/CMakeLists.txt
index 85a8397..524cb36 100644
--- a/peripheral/libupm/src/grovegprs/CMakeLists.txt
+++ b/peripheral/libupm/src/grovegprs/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "grovegprs")
set (libdescription "upm grove GPRS module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/grovegprs/grovegprs.cxx b/peripheral/libupm/src/grovegprs/grovegprs.cxx
index 8634cd4..4f83bc8 100644
--- a/peripheral/libupm/src/grovegprs/grovegprs.cxx
+++ b/peripheral/libupm/src/grovegprs/grovegprs.cxx
@@ -24,7 +24,7 @@
#include <iostream>
-#include "grovegprs.hpp"
+#include "grovegprs.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/grovegprs/grovegprs.hpp b/peripheral/libupm/src/grovegprs/grovegprs.h
index 1aa774f..1aa774f 100644
--- a/peripheral/libupm/src/grovegprs/grovegprs.hpp
+++ b/peripheral/libupm/src/grovegprs/grovegprs.h
diff --git a/peripheral/libupm/src/grovegprs/javaupm_grovegprs.i b/peripheral/libupm/src/grovegprs/javaupm_grovegprs.i
index 2997236..e048626 100644
--- a/peripheral/libupm/src/grovegprs/javaupm_grovegprs.i
+++ b/peripheral/libupm/src/grovegprs/javaupm_grovegprs.i
@@ -4,10 +4,10 @@
%include "std_string.i"
%{
- #include "grovegprs.hpp"
+ #include "grovegprs.h"
%}
-%include "grovegprs.hpp"
+%include "grovegprs.h"
%array_class(char, charArray);
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/grovegprs/jsupm_grovegprs.i b/peripheral/libupm/src/grovegprs/jsupm_grovegprs.i
index bd14764..a4f0556 100644
--- a/peripheral/libupm/src/grovegprs/jsupm_grovegprs.i
+++ b/peripheral/libupm/src/grovegprs/jsupm_grovegprs.i
@@ -4,8 +4,8 @@
%include "std_string.i"
%{
- #include "grovegprs.hpp"
+ #include "grovegprs.h"
%}
-%include "grovegprs.hpp"
+%include "grovegprs.h"
%array_class(char, charArray);
diff --git a/peripheral/libupm/src/grovegprs/pyupm_grovegprs.i b/peripheral/libupm/src/grovegprs/pyupm_grovegprs.i
index 04e1178..46567e9 100644
--- a/peripheral/libupm/src/grovegprs/pyupm_grovegprs.i
+++ b/peripheral/libupm/src/grovegprs/pyupm_grovegprs.i
@@ -8,7 +8,7 @@
%feature("autodoc", "3");
%{
- #include "grovegprs.hpp"
+ #include "grovegprs.h"
%}
-%include "grovegprs.hpp"
+%include "grovegprs.h"
%array_class(char, charArray);
diff --git a/peripheral/libupm/src/grovegsr/CMakeLists.txt b/peripheral/libupm/src/grovegsr/CMakeLists.txt
index d352cdd..051ad08 100644
--- a/peripheral/libupm/src/grovegsr/CMakeLists.txt
+++ b/peripheral/libupm/src/grovegsr/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "grovegsr")
set (libdescription "upm grovegsr galvanic skin response sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/grovegsr/grovegsr.cxx b/peripheral/libupm/src/grovegsr/grovegsr.cxx
index 17b19c5..0d7669d 100644
--- a/peripheral/libupm/src/grovegsr/grovegsr.cxx
+++ b/peripheral/libupm/src/grovegsr/grovegsr.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "grovegsr.hpp"
+#include "grovegsr.h"
using namespace upm;
using namespace std;
@@ -54,8 +54,6 @@ void GroveGSR::calibrate()
for(int i=0; i<500; i++)
{
val = mraa_aio_read(m_aio);
- if (val != -1) throw std::runtime_error(std::string(__FUNCTION__) +
- ": Failed to do an aio read.");
sum += val;
usleep(5000);
}
diff --git a/peripheral/libupm/src/grovegsr/grovegsr.hpp b/peripheral/libupm/src/grovegsr/grovegsr.h
index 32666ab..32666ab 100644
--- a/peripheral/libupm/src/grovegsr/grovegsr.hpp
+++ b/peripheral/libupm/src/grovegsr/grovegsr.h
diff --git a/peripheral/libupm/src/grovegsr/javaupm_grovegsr.i b/peripheral/libupm/src/grovegsr/javaupm_grovegsr.i
index 22e27b0..658146d 100644
--- a/peripheral/libupm/src/grovegsr/javaupm_grovegsr.i
+++ b/peripheral/libupm/src/grovegsr/javaupm_grovegsr.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "grovegsr.hpp"
+ #include "grovegsr.h"
%}
-%include "grovegsr.hpp"
+%include "grovegsr.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/grovegsr/jsupm_grovegsr.i b/peripheral/libupm/src/grovegsr/jsupm_grovegsr.i
index 5ee875b..d1ec016 100644
--- a/peripheral/libupm/src/grovegsr/jsupm_grovegsr.i
+++ b/peripheral/libupm/src/grovegsr/jsupm_grovegsr.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "grovegsr.hpp"
+ #include "grovegsr.h"
%}
-%include "grovegsr.hpp"
+%include "grovegsr.h"
diff --git a/peripheral/libupm/src/grovegsr/pyupm_grovegsr.i b/peripheral/libupm/src/grovegsr/pyupm_grovegsr.i
index 92a30c2..6e1a7ce 100644
--- a/peripheral/libupm/src/grovegsr/pyupm_grovegsr.i
+++ b/peripheral/libupm/src/grovegsr/pyupm_grovegsr.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "grovegsr.hpp"
+%include "grovegsr.h"
%{
- #include "grovegsr.hpp"
+ #include "grovegsr.h"
%}
diff --git a/peripheral/libupm/src/grovelinefinder/CMakeLists.txt b/peripheral/libupm/src/grovelinefinder/CMakeLists.txt
index 04ee8b4..46d22e9 100644
--- a/peripheral/libupm/src/grovelinefinder/CMakeLists.txt
+++ b/peripheral/libupm/src/grovelinefinder/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "grovelinefinder")
set (libdescription "upm grove line finder sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/grovelinefinder/grovelinefinder.cxx b/peripheral/libupm/src/grovelinefinder/grovelinefinder.cxx
index 3f4f55c..297f526 100644
--- a/peripheral/libupm/src/grovelinefinder/grovelinefinder.cxx
+++ b/peripheral/libupm/src/grovelinefinder/grovelinefinder.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "grovelinefinder.hpp"
+#include "grovelinefinder.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/grovelinefinder/grovelinefinder.hpp b/peripheral/libupm/src/grovelinefinder/grovelinefinder.h
index 5e662a2..5e662a2 100644
--- a/peripheral/libupm/src/grovelinefinder/grovelinefinder.hpp
+++ b/peripheral/libupm/src/grovelinefinder/grovelinefinder.h
diff --git a/peripheral/libupm/src/grovelinefinder/javaupm_grovelinefinder.i b/peripheral/libupm/src/grovelinefinder/javaupm_grovelinefinder.i
index ebad50a..bee2ffd 100644
--- a/peripheral/libupm/src/grovelinefinder/javaupm_grovelinefinder.i
+++ b/peripheral/libupm/src/grovelinefinder/javaupm_grovelinefinder.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "grovelinefinder.hpp"
+ #include "grovelinefinder.h"
%}
-%include "grovelinefinder.hpp"
+%include "grovelinefinder.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/grovelinefinder/jsupm_grovelinefinder.i b/peripheral/libupm/src/grovelinefinder/jsupm_grovelinefinder.i
index 174f4b4..e379f37 100644
--- a/peripheral/libupm/src/grovelinefinder/jsupm_grovelinefinder.i
+++ b/peripheral/libupm/src/grovelinefinder/jsupm_grovelinefinder.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "grovelinefinder.hpp"
+ #include "grovelinefinder.h"
%}
-%include "grovelinefinder.hpp"
+%include "grovelinefinder.h"
diff --git a/peripheral/libupm/src/grovelinefinder/pyupm_grovelinefinder.i b/peripheral/libupm/src/grovelinefinder/pyupm_grovelinefinder.i
index 99832eb..3e58d21 100644
--- a/peripheral/libupm/src/grovelinefinder/pyupm_grovelinefinder.i
+++ b/peripheral/libupm/src/grovelinefinder/pyupm_grovelinefinder.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "grovelinefinder.hpp"
+%include "grovelinefinder.h"
%{
- #include "grovelinefinder.hpp"
+ #include "grovelinefinder.h"
%}
diff --git a/peripheral/libupm/src/groveloudness/groveloudness.cxx b/peripheral/libupm/src/groveloudness/groveloudness.cxx
index d9df9e0..6a6a284 100644
--- a/peripheral/libupm/src/groveloudness/groveloudness.cxx
+++ b/peripheral/libupm/src/groveloudness/groveloudness.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "groveloudness.hpp"
+#include "groveloudness.h"
using namespace upm;
diff --git a/peripheral/libupm/src/grovemd/CMakeLists.txt b/peripheral/libupm/src/grovemd/CMakeLists.txt
index 627632c..6f30715 100644
--- a/peripheral/libupm/src/grovemd/CMakeLists.txt
+++ b/peripheral/libupm/src/grovemd/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "grovemd")
set (libdescription "upm grove i2c motor driver module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/grovemd/grovemd.cxx b/peripheral/libupm/src/grovemd/grovemd.cxx
index fcf83ac..2e588a4 100644
--- a/peripheral/libupm/src/grovemd/grovemd.cxx
+++ b/peripheral/libupm/src/grovemd/grovemd.cxx
@@ -27,7 +27,7 @@
#include <string>
#include <stdexcept>
-#include "grovemd.hpp"
+#include "grovemd.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/grovemd/grovemd.hpp b/peripheral/libupm/src/grovemd/grovemd.h
index 9483475..9483475 100644
--- a/peripheral/libupm/src/grovemd/grovemd.hpp
+++ b/peripheral/libupm/src/grovemd/grovemd.h
diff --git a/peripheral/libupm/src/grovemd/javaupm_grovemd.i b/peripheral/libupm/src/grovemd/javaupm_grovemd.i
index 4fa1da7..341297c 100644
--- a/peripheral/libupm/src/grovemd/javaupm_grovemd.i
+++ b/peripheral/libupm/src/grovemd/javaupm_grovemd.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "grovemd.hpp"
+ #include "grovemd.h"
%}
-%include "grovemd.hpp"
+%include "grovemd.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/grovemd/jsupm_grovemd.i b/peripheral/libupm/src/grovemd/jsupm_grovemd.i
index b15aa49..a907c05 100644
--- a/peripheral/libupm/src/grovemd/jsupm_grovemd.i
+++ b/peripheral/libupm/src/grovemd/jsupm_grovemd.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "grovemd.hpp"
+ #include "grovemd.h"
%}
-%include "grovemd.hpp"
+%include "grovemd.h"
diff --git a/peripheral/libupm/src/grovemd/pyupm_grovemd.i b/peripheral/libupm/src/grovemd/pyupm_grovemd.i
index eb9996d..4de7fbe 100644
--- a/peripheral/libupm/src/grovemd/pyupm_grovemd.i
+++ b/peripheral/libupm/src/grovemd/pyupm_grovemd.i
@@ -9,7 +9,7 @@
%include "grovemd_doc.i"
#endif
-%include "grovemd.hpp"
+%include "grovemd.h"
%{
- #include "grovemd.hpp"
+ #include "grovemd.h"
%}
diff --git a/peripheral/libupm/src/grovemoisture/CMakeLists.txt b/peripheral/libupm/src/grovemoisture/CMakeLists.txt
index c7fbf14..a50d11e 100644
--- a/peripheral/libupm/src/grovemoisture/CMakeLists.txt
+++ b/peripheral/libupm/src/grovemoisture/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "grovemoisture")
set (libdescription "upm grove moisture module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/grovemoisture/grovemoisture.cxx b/peripheral/libupm/src/grovemoisture/grovemoisture.cxx
index aa44e78..2145b44 100644
--- a/peripheral/libupm/src/grovemoisture/grovemoisture.cxx
+++ b/peripheral/libupm/src/grovemoisture/grovemoisture.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "grovemoisture.hpp"
+#include "grovemoisture.h"
using namespace upm;
diff --git a/peripheral/libupm/src/grovemoisture/grovemoisture.hpp b/peripheral/libupm/src/grovemoisture/grovemoisture.h
index 2b08170..2b08170 100644
--- a/peripheral/libupm/src/grovemoisture/grovemoisture.hpp
+++ b/peripheral/libupm/src/grovemoisture/grovemoisture.h
diff --git a/peripheral/libupm/src/grovemoisture/javaupm_grovemoisture.i b/peripheral/libupm/src/grovemoisture/javaupm_grovemoisture.i
index 1cf217c..886991a 100644
--- a/peripheral/libupm/src/grovemoisture/javaupm_grovemoisture.i
+++ b/peripheral/libupm/src/grovemoisture/javaupm_grovemoisture.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "grovemoisture.hpp"
+ #include "grovemoisture.h"
%}
-%include "grovemoisture.hpp"
+%include "grovemoisture.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/grovemoisture/jsupm_grovemoisture.i b/peripheral/libupm/src/grovemoisture/jsupm_grovemoisture.i
index 40a877e..e77e94b 100644
--- a/peripheral/libupm/src/grovemoisture/jsupm_grovemoisture.i
+++ b/peripheral/libupm/src/grovemoisture/jsupm_grovemoisture.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "grovemoisture.hpp"
+ #include "grovemoisture.h"
%}
-%include "grovemoisture.hpp"
+%include "grovemoisture.h"
diff --git a/peripheral/libupm/src/grovemoisture/pyupm_grovemoisture.i b/peripheral/libupm/src/grovemoisture/pyupm_grovemoisture.i
index e661aad..cc1e015 100644
--- a/peripheral/libupm/src/grovemoisture/pyupm_grovemoisture.i
+++ b/peripheral/libupm/src/grovemoisture/pyupm_grovemoisture.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "grovemoisture.hpp"
+%include "grovemoisture.h"
%{
- #include "grovemoisture.hpp"
+ #include "grovemoisture.h"
%}
diff --git a/peripheral/libupm/src/groveo2/CMakeLists.txt b/peripheral/libupm/src/groveo2/CMakeLists.txt
index d0be353..a9edadb 100644
--- a/peripheral/libupm/src/groveo2/CMakeLists.txt
+++ b/peripheral/libupm/src/groveo2/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "groveo2")
set (libdescription "upm groveO2 oxygen concentration sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/groveo2/groveo2.cxx b/peripheral/libupm/src/groveo2/groveo2.cxx
index b982d3f..61b95eb 100644
--- a/peripheral/libupm/src/groveo2/groveo2.cxx
+++ b/peripheral/libupm/src/groveo2/groveo2.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "groveo2.hpp"
+#include "groveo2.h"
using namespace upm;
using namespace std;
@@ -49,7 +49,6 @@ GroveO2::~GroveO2()
float GroveO2::voltageValue()
{
int val = mraa_aio_read(m_aio);
- if (val == -1) return -1.0f;
float sensorVoltage = (val/1024.0) * 5.0;
sensorVoltage = (sensorVoltage/201.0) * 10000.0;
return sensorVoltage;
diff --git a/peripheral/libupm/src/groveo2/groveo2.hpp b/peripheral/libupm/src/groveo2/groveo2.h
index 16081d2..16081d2 100644
--- a/peripheral/libupm/src/groveo2/groveo2.hpp
+++ b/peripheral/libupm/src/groveo2/groveo2.h
diff --git a/peripheral/libupm/src/groveo2/javaupm_groveo2.i b/peripheral/libupm/src/groveo2/javaupm_groveo2.i
index a761108..8ae0399 100644
--- a/peripheral/libupm/src/groveo2/javaupm_groveo2.i
+++ b/peripheral/libupm/src/groveo2/javaupm_groveo2.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "groveo2.hpp"
+ #include "groveo2.h"
%}
-%include "groveo2.hpp"
+%include "groveo2.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/groveo2/jsupm_groveo2.i b/peripheral/libupm/src/groveo2/jsupm_groveo2.i
index 11d849e..8e3482e 100644
--- a/peripheral/libupm/src/groveo2/jsupm_groveo2.i
+++ b/peripheral/libupm/src/groveo2/jsupm_groveo2.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "groveo2.hpp"
+ #include "groveo2.h"
%}
-%include "groveo2.hpp"
+%include "groveo2.h"
diff --git a/peripheral/libupm/src/groveo2/pyupm_groveo2.i b/peripheral/libupm/src/groveo2/pyupm_groveo2.i
index 79bf206..f468b52 100644
--- a/peripheral/libupm/src/groveo2/pyupm_groveo2.i
+++ b/peripheral/libupm/src/groveo2/pyupm_groveo2.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "groveo2.hpp"
+%include "groveo2.h"
%{
- #include "groveo2.hpp"
+ #include "groveo2.h"
%}
diff --git a/peripheral/libupm/src/grovescam/CMakeLists.txt b/peripheral/libupm/src/grovescam/CMakeLists.txt
index 7154d3c..509a664 100644
--- a/peripheral/libupm/src/grovescam/CMakeLists.txt
+++ b/peripheral/libupm/src/grovescam/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "grovescam")
set (libdescription "upm grove serial camera module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/grovescam/grovescam.cxx b/peripheral/libupm/src/grovescam/grovescam.cxx
index 1a78a3a..1bc6235 100644
--- a/peripheral/libupm/src/grovescam/grovescam.cxx
+++ b/peripheral/libupm/src/grovescam/grovescam.cxx
@@ -29,7 +29,7 @@
#include <stdexcept>
#include <errno.h>
-#include "grovescam.hpp"
+#include "grovescam.h"
using namespace upm;
using namespace std;
@@ -66,7 +66,7 @@ GROVESCAM::GROVESCAM(int uart, uint8_t camAddr)
if ( (m_ttyFd = open(devPath, O_RDWR)) == -1)
{
throw std::runtime_error(std::string(__FUNCTION__) +
- ": open of " +
+ ": open of " +
string(devPath) + " failed:" +
string(strerror(errno)));
return;
@@ -86,25 +86,25 @@ bool GROVESCAM::dataAvailable(unsigned int millis)
struct timeval timeout;
- if (millis == 0)
+ if (millis == 0)
{
// no waiting
timeout.tv_sec = 0;
timeout.tv_usec = 0;
}
- else
+ else
{
timeout.tv_sec = millis / 1000;
timeout.tv_usec = (millis % 1000) * 1000;
}
- int nfds;
+ int nfds;
fd_set readfds;
FD_ZERO(&readfds);
FD_SET(m_ttyFd, &readfds);
-
+
if (select(m_ttyFd + 1, &readfds, NULL, NULL, &timeout) > 0)
return true; // data is ready
else
@@ -157,7 +157,7 @@ bool GROVESCAM::setupTty(speed_t baud)
{
if (m_ttyFd == -1)
return(false);
-
+
struct termios termio;
// get current modes
@@ -216,22 +216,22 @@ bool GROVESCAM::init()
if (readData(resp, pktLen) != pktLen)
continue;
- if (resp[0] == 0xaa
- && resp[1] == (0x0e | m_camAddr)
- && resp[2] == 0x0d
- && resp[4] == 0
+ if (resp[0] == 0xaa
+ && resp[1] == (0x0e | m_camAddr)
+ && resp[2] == 0x0d
+ && resp[4] == 0
&& resp[5] == 0)
{
if (readData(resp, pktLen) != pktLen)
continue;
else
{
- if (resp[0] == 0xaa
- && resp[1] == (0x0d | m_camAddr)
- && resp[2] == 0
- && resp[3] == 0
- && resp[4] == 0
- && resp[5] == 0)
+ if (resp[0] == 0xaa
+ && resp[1] == (0x0d | m_camAddr)
+ && resp[2] == 0
+ && resp[3] == 0
+ && resp[4] == 0
+ && resp[5] == 0)
break;
}
}
@@ -271,10 +271,10 @@ bool GROVESCAM::preCapture(PIC_FORMATS_T fmt)
if (readData(resp, pktLen) != pktLen)
continue;
- if (resp[0] == 0xaa
- && resp[1] == (0x0e | m_camAddr)
- && resp[2] == 0x01
- && resp[4] == 0
+ if (resp[0] == 0xaa
+ && resp[1] == (0x0e | m_camAddr)
+ && resp[2] == 0x01
+ && resp[4] == 0
&& resp[5] == 0) break;
}
@@ -285,11 +285,10 @@ bool GROVESCAM::doCapture()
{
const unsigned int pktLen = 6;
uint8_t cmd[pktLen] = { 0xaa, static_cast<uint8_t>(0x06 | m_camAddr), 0x08,
- static_cast<uint8_t>(MAX_PKT_LEN & 0xff),
- static_cast<uint8_t>((MAX_PKT_LEN >> 8)) & 0xff, 0};
+ MAX_PKT_LEN & 0xff, (MAX_PKT_LEN >> 8) & 0xff, 0};
uint8_t resp[pktLen];
int retries = 0;
-
+
m_picTotalLen = 0;
while (true)
@@ -311,10 +310,10 @@ bool GROVESCAM::doCapture()
if (readData(resp, pktLen) != pktLen)
continue;
- if (resp[0] == 0xaa
- && resp[1] == (0x0e | m_camAddr)
- && resp[2] == 0x06
- && resp[4] == 0
+ if (resp[0] == 0xaa
+ && resp[1] == (0x0e | m_camAddr)
+ && resp[2] == 0x06
+ && resp[4] == 0
&& resp[5] == 0)
break;
}
@@ -340,10 +339,10 @@ bool GROVESCAM::doCapture()
if (readData(resp, pktLen) != pktLen)
continue;
- if (resp[0] == 0xaa
- && resp[1] == (0x0e | m_camAddr)
- && resp[2] == 0x05
- && resp[4] == 0
+ if (resp[0] == 0xaa
+ && resp[1] == (0x0e | m_camAddr)
+ && resp[2] == 0x05
+ && resp[4] == 0
&& resp[5] == 0)
break;
}
@@ -367,10 +366,10 @@ bool GROVESCAM::doCapture()
if (readData(resp, pktLen) != pktLen)
continue;
- if (resp[0] == 0xaa
- && resp[1] == (0x0e | m_camAddr)
- && resp[2] == 0x04
- && resp[4] == 0
+ if (resp[0] == 0xaa
+ && resp[1] == (0x0e | m_camAddr)
+ && resp[2] == 0x04
+ && resp[4] == 0
&& resp[5] == 0)
{
if (!dataAvailable(1000))
@@ -418,23 +417,23 @@ bool GROVESCAM::storeImage(const char *fname)
string(strerror(errno)));
return false;
}
-
+
/// let the games begin...
const unsigned int pktLen = 6;
unsigned int pktCnt = (m_picTotalLen) / (MAX_PKT_LEN - 6);
- if ((m_picTotalLen % (MAX_PKT_LEN-6)) != 0)
+ if ((m_picTotalLen % (MAX_PKT_LEN-6)) != 0)
pktCnt += 1;
-
+
uint8_t cmd[pktLen] = { 0xaa, static_cast<uint8_t>(0x0e | m_camAddr), 0x00,
0x00, 0x00, 0x00 };
uint8_t pkt[MAX_PKT_LEN];
int retries = 0;
-
+
for (unsigned int i = 0; i < pktCnt; i++)
{
cmd[4] = i & 0xff;
cmd[5] = (i >> 8) & 0xff;
-
+
retries = 0;
retry:
@@ -456,7 +455,7 @@ bool GROVESCAM::storeImage(const char *fname)
}
uint16_t cnt = readData(pkt, MAX_PKT_LEN);
-
+
unsigned char sum = 0;
for (int y = 0; y < cnt - 2; y++)
{
diff --git a/peripheral/libupm/src/grovescam/grovescam.hpp b/peripheral/libupm/src/grovescam/grovescam.h
index 82fff7d..82fff7d 100644
--- a/peripheral/libupm/src/grovescam/grovescam.hpp
+++ b/peripheral/libupm/src/grovescam/grovescam.h
diff --git a/peripheral/libupm/src/grovescam/javaupm_grovescam.i b/peripheral/libupm/src/grovescam/javaupm_grovescam.i
index c22bf9c..8e55cdf 100644
--- a/peripheral/libupm/src/grovescam/javaupm_grovescam.i
+++ b/peripheral/libupm/src/grovescam/javaupm_grovescam.i
@@ -3,10 +3,10 @@
%include "../java_buffer.i"
%{
- #include "grovescam.hpp"
+ #include "grovescam.h"
%}
-%include "grovescam.hpp"
+%include "grovescam.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/grovescam/jsupm_grovescam.i b/peripheral/libupm/src/grovescam/jsupm_grovescam.i
index 18cf474..d8e12ec 100644
--- a/peripheral/libupm/src/grovescam/jsupm_grovescam.i
+++ b/peripheral/libupm/src/grovescam/jsupm_grovescam.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "grovescam.hpp"
+ #include "grovescam.h"
%}
-%include "grovescam.hpp"
+%include "grovescam.h"
diff --git a/peripheral/libupm/src/grovescam/pyupm_grovescam.i b/peripheral/libupm/src/grovescam/pyupm_grovescam.i
index 0f8c416..6bb7163 100644
--- a/peripheral/libupm/src/grovescam/pyupm_grovescam.i
+++ b/peripheral/libupm/src/grovescam/pyupm_grovescam.i
@@ -6,6 +6,6 @@
%feature("autodoc", "3");
%{
- #include "grovescam.hpp"
+ #include "grovescam.h"
%}
-%include "grovescam.hpp"
+%include "grovescam.h"
diff --git a/peripheral/libupm/src/grovespeaker/CMakeLists.txt b/peripheral/libupm/src/grovespeaker/CMakeLists.txt
index 171bfd6..ab3b511 100644
--- a/peripheral/libupm/src/grovespeaker/CMakeLists.txt
+++ b/peripheral/libupm/src/grovespeaker/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "grovespeaker")
set (libdescription "upm grovespeaker speaker module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/grovespeaker/grovespeaker.cxx b/peripheral/libupm/src/grovespeaker/grovespeaker.cxx
index 61d2548..0b34e48 100644
--- a/peripheral/libupm/src/grovespeaker/grovespeaker.cxx
+++ b/peripheral/libupm/src/grovespeaker/grovespeaker.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "grovespeaker.hpp"
+#include "grovespeaker.h"
using namespace upm;
diff --git a/peripheral/libupm/src/grovespeaker/grovespeaker.hpp b/peripheral/libupm/src/grovespeaker/grovespeaker.h
index 535dc48..535dc48 100644
--- a/peripheral/libupm/src/grovespeaker/grovespeaker.hpp
+++ b/peripheral/libupm/src/grovespeaker/grovespeaker.h
diff --git a/peripheral/libupm/src/grovespeaker/javaupm_grovespeaker.i b/peripheral/libupm/src/grovespeaker/javaupm_grovespeaker.i
index 4af4564..c3f98a7 100644
--- a/peripheral/libupm/src/grovespeaker/javaupm_grovespeaker.i
+++ b/peripheral/libupm/src/grovespeaker/javaupm_grovespeaker.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "grovespeaker.hpp"
+ #include "grovespeaker.h"
%}
-%include "grovespeaker.hpp"
+%include "grovespeaker.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/grovespeaker/jsupm_grovespeaker.i b/peripheral/libupm/src/grovespeaker/jsupm_grovespeaker.i
index ef71438..cf0f1e6 100644
--- a/peripheral/libupm/src/grovespeaker/jsupm_grovespeaker.i
+++ b/peripheral/libupm/src/grovespeaker/jsupm_grovespeaker.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "grovespeaker.hpp"
+ #include "grovespeaker.h"
%}
-%include "grovespeaker.hpp"
+%include "grovespeaker.h"
diff --git a/peripheral/libupm/src/grovespeaker/pyupm_grovespeaker.i b/peripheral/libupm/src/grovespeaker/pyupm_grovespeaker.i
index 667c872..16d54db 100644
--- a/peripheral/libupm/src/grovespeaker/pyupm_grovespeaker.i
+++ b/peripheral/libupm/src/grovespeaker/pyupm_grovespeaker.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "grovespeaker.hpp"
+%include "grovespeaker.h"
%{
- #include "grovespeaker.hpp"
+ #include "grovespeaker.h"
%}
diff --git a/peripheral/libupm/src/groveultrasonic/CMakeLists.txt b/peripheral/libupm/src/groveultrasonic/CMakeLists.txt
index 0a05ad2..3144f43 100644
--- a/peripheral/libupm/src/groveultrasonic/CMakeLists.txt
+++ b/peripheral/libupm/src/groveultrasonic/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "groveultrasonic")
set (libdescription "upm grove ultrasonic proximity sensor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/groveultrasonic/groveultrasonic.cxx b/peripheral/libupm/src/groveultrasonic/groveultrasonic.cxx
index 87ec1f6..2a695f7 100644
--- a/peripheral/libupm/src/groveultrasonic/groveultrasonic.cxx
+++ b/peripheral/libupm/src/groveultrasonic/groveultrasonic.cxx
@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <functional>
-#include "groveultrasonic.hpp"
+#include "groveultrasonic.h"
using namespace upm;
diff --git a/peripheral/libupm/src/groveultrasonic/groveultrasonic.hpp b/peripheral/libupm/src/groveultrasonic/groveultrasonic.h
index d1fd340..d1fd340 100644
--- a/peripheral/libupm/src/groveultrasonic/groveultrasonic.hpp
+++ b/peripheral/libupm/src/groveultrasonic/groveultrasonic.h
diff --git a/peripheral/libupm/src/groveultrasonic/javaupm_groveultrasonic.i b/peripheral/libupm/src/groveultrasonic/javaupm_groveultrasonic.i
index f890706..a0680e9 100644
--- a/peripheral/libupm/src/groveultrasonic/javaupm_groveultrasonic.i
+++ b/peripheral/libupm/src/groveultrasonic/javaupm_groveultrasonic.i
@@ -4,10 +4,10 @@
%ignore signalISR;
%{
- #include "groveultrasonic.hpp"
+ #include "groveultrasonic.h"
%}
-%include "groveultrasonic.hpp"
+%include "groveultrasonic.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/groveultrasonic/jsupm_groveultrasonic.i b/peripheral/libupm/src/groveultrasonic/jsupm_groveultrasonic.i
index 6cfae0a..6993b01 100644
--- a/peripheral/libupm/src/groveultrasonic/jsupm_groveultrasonic.i
+++ b/peripheral/libupm/src/groveultrasonic/jsupm_groveultrasonic.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "groveultrasonic.hpp"
+ #include "groveultrasonic.h"
%}
-%include "groveultrasonic.hpp"
+%include "groveultrasonic.h"
diff --git a/peripheral/libupm/src/groveultrasonic/pyupm_groveultrasonic.i b/peripheral/libupm/src/groveultrasonic/pyupm_groveultrasonic.i
index 8f7eb3f..188dd40 100644
--- a/peripheral/libupm/src/groveultrasonic/pyupm_groveultrasonic.i
+++ b/peripheral/libupm/src/groveultrasonic/pyupm_groveultrasonic.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "groveultrasonic.hpp"
+%include "groveultrasonic.h"
%{
- #include "groveultrasonic.hpp"
+ #include "groveultrasonic.h"
%}
diff --git a/peripheral/libupm/src/grovevdiv/CMakeLists.txt b/peripheral/libupm/src/grovevdiv/CMakeLists.txt
index 66d925b..ec612c0 100644
--- a/peripheral/libupm/src/grovevdiv/CMakeLists.txt
+++ b/peripheral/libupm/src/grovevdiv/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "grovevdiv")
set (libdescription "upm grove voltage divider module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/grovevdiv/grovevdiv.cxx b/peripheral/libupm/src/grovevdiv/grovevdiv.cxx
index b1ebe15..722956e 100644
--- a/peripheral/libupm/src/grovevdiv/grovevdiv.cxx
+++ b/peripheral/libupm/src/grovevdiv/grovevdiv.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "grovevdiv.hpp"
+#include "grovevdiv.h"
using namespace upm;
using namespace std;
@@ -53,7 +53,6 @@ unsigned int GroveVDiv::value(unsigned int samples)
for (int i=0; i<samples; i++)
{
sum += mraa_aio_read(m_aio);
- if (sum == -1) return 0;
usleep(2000);
}
diff --git a/peripheral/libupm/src/grovevdiv/grovevdiv.hpp b/peripheral/libupm/src/grovevdiv/grovevdiv.h
index 9e93879..9e93879 100644
--- a/peripheral/libupm/src/grovevdiv/grovevdiv.hpp
+++ b/peripheral/libupm/src/grovevdiv/grovevdiv.h
diff --git a/peripheral/libupm/src/grovevdiv/javaupm_grovevdiv.i b/peripheral/libupm/src/grovevdiv/javaupm_grovevdiv.i
index b3c5e02..1fb23bd 100644
--- a/peripheral/libupm/src/grovevdiv/javaupm_grovevdiv.i
+++ b/peripheral/libupm/src/grovevdiv/javaupm_grovevdiv.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "grovevdiv.hpp"
+ #include "grovevdiv.h"
%}
-%include "grovevdiv.hpp"
+%include "grovevdiv.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/grovevdiv/jsupm_grovevdiv.i b/peripheral/libupm/src/grovevdiv/jsupm_grovevdiv.i
index ab9bedf..35c3bd4 100644
--- a/peripheral/libupm/src/grovevdiv/jsupm_grovevdiv.i
+++ b/peripheral/libupm/src/grovevdiv/jsupm_grovevdiv.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "grovevdiv.hpp"
+ #include "grovevdiv.h"
%}
-%include "grovevdiv.hpp"
+%include "grovevdiv.h"
diff --git a/peripheral/libupm/src/grovevdiv/pyupm_grovevdiv.i b/peripheral/libupm/src/grovevdiv/pyupm_grovevdiv.i
index 5ad7aaf..1267a8f 100644
--- a/peripheral/libupm/src/grovevdiv/pyupm_grovevdiv.i
+++ b/peripheral/libupm/src/grovevdiv/pyupm_grovevdiv.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "grovevdiv.hpp"
+%include "grovevdiv.h"
%{
- #include "grovevdiv.hpp"
+ #include "grovevdiv.h"
%}
diff --git a/peripheral/libupm/src/grovewater/CMakeLists.txt b/peripheral/libupm/src/grovewater/CMakeLists.txt
index 6561276..2fa64b1 100644
--- a/peripheral/libupm/src/grovewater/CMakeLists.txt
+++ b/peripheral/libupm/src/grovewater/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "grovewater")
set (libdescription "upm grove water module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/grovewater/grovewater.cxx b/peripheral/libupm/src/grovewater/grovewater.cxx
index 9220adc..7456df2 100644
--- a/peripheral/libupm/src/grovewater/grovewater.cxx
+++ b/peripheral/libupm/src/grovewater/grovewater.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "grovewater.hpp"
+#include "grovewater.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/grovewater/grovewater.hpp b/peripheral/libupm/src/grovewater/grovewater.h
index 50e74b4..50e74b4 100644
--- a/peripheral/libupm/src/grovewater/grovewater.hpp
+++ b/peripheral/libupm/src/grovewater/grovewater.h
diff --git a/peripheral/libupm/src/grovewater/javaupm_grovewater.i b/peripheral/libupm/src/grovewater/javaupm_grovewater.i
index 0c07417..d679c2e 100644
--- a/peripheral/libupm/src/grovewater/javaupm_grovewater.i
+++ b/peripheral/libupm/src/grovewater/javaupm_grovewater.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "grovewater.hpp"
+ #include "grovewater.h"
%}
-%include "grovewater.hpp"
+%include "grovewater.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/grovewater/jsupm_grovewater.i b/peripheral/libupm/src/grovewater/jsupm_grovewater.i
index 48c5dee..b1407af 100644
--- a/peripheral/libupm/src/grovewater/jsupm_grovewater.i
+++ b/peripheral/libupm/src/grovewater/jsupm_grovewater.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "grovewater.hpp"
+ #include "grovewater.h"
%}
-%include "grovewater.hpp"
+%include "grovewater.h"
diff --git a/peripheral/libupm/src/grovewater/pyupm_grovewater.i b/peripheral/libupm/src/grovewater/pyupm_grovewater.i
index 0af321c..f4218a1 100644
--- a/peripheral/libupm/src/grovewater/pyupm_grovewater.i
+++ b/peripheral/libupm/src/grovewater/pyupm_grovewater.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "grovewater.hpp"
+%include "grovewater.h"
%{
- #include "grovewater.hpp"
+ #include "grovewater.h"
%}
diff --git a/peripheral/libupm/src/grovewfs/CMakeLists.txt b/peripheral/libupm/src/grovewfs/CMakeLists.txt
index df87cf8..826a32e 100644
--- a/peripheral/libupm/src/grovewfs/CMakeLists.txt
+++ b/peripheral/libupm/src/grovewfs/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "grovewfs")
set (libdescription "upm grove water flow sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/grovewfs/grovewfs.cxx b/peripheral/libupm/src/grovewfs/grovewfs.cxx
index 2b6f4ba..2eb70ac 100644
--- a/peripheral/libupm/src/grovewfs/grovewfs.cxx
+++ b/peripheral/libupm/src/grovewfs/grovewfs.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "grovewfs.hpp"
+#include "grovewfs.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/grovewfs/grovewfs.hpp b/peripheral/libupm/src/grovewfs/grovewfs.h
index bec30dc..bec30dc 100644
--- a/peripheral/libupm/src/grovewfs/grovewfs.hpp
+++ b/peripheral/libupm/src/grovewfs/grovewfs.h
diff --git a/peripheral/libupm/src/grovewfs/javaupm_grovewfs.i b/peripheral/libupm/src/grovewfs/javaupm_grovewfs.i
index f4e5f04..7e650ac 100644
--- a/peripheral/libupm/src/grovewfs/javaupm_grovewfs.i
+++ b/peripheral/libupm/src/grovewfs/javaupm_grovewfs.i
@@ -4,10 +4,10 @@
%ignore flowISR;
%{
- #include "grovewfs.hpp"
+ #include "grovewfs.h"
%}
-%include "grovewfs.hpp"
+%include "grovewfs.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/grovewfs/jsupm_grovewfs.i b/peripheral/libupm/src/grovewfs/jsupm_grovewfs.i
index 1b837c2..d85d64d 100644
--- a/peripheral/libupm/src/grovewfs/jsupm_grovewfs.i
+++ b/peripheral/libupm/src/grovewfs/jsupm_grovewfs.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "grovewfs.hpp"
+ #include "grovewfs.h"
%}
-%include "grovewfs.hpp"
+%include "grovewfs.h"
diff --git a/peripheral/libupm/src/grovewfs/pyupm_grovewfs.i b/peripheral/libupm/src/grovewfs/pyupm_grovewfs.i
index 735b130..7dd71ff 100644
--- a/peripheral/libupm/src/grovewfs/pyupm_grovewfs.i
+++ b/peripheral/libupm/src/grovewfs/pyupm_grovewfs.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "grovewfs.hpp"
+%include "grovewfs.h"
%{
- #include "grovewfs.hpp"
+ #include "grovewfs.h"
%}
diff --git a/peripheral/libupm/src/guvas12d/CMakeLists.txt b/peripheral/libupm/src/guvas12d/CMakeLists.txt
index 24faa19..3485e0e 100644
--- a/peripheral/libupm/src/guvas12d/CMakeLists.txt
+++ b/peripheral/libupm/src/guvas12d/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "guvas12d")
set (libdescription "upm guvas12d UV sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/guvas12d/guvas12d.cxx b/peripheral/libupm/src/guvas12d/guvas12d.cxx
index 063e42d..7b30e1f 100644
--- a/peripheral/libupm/src/guvas12d/guvas12d.cxx
+++ b/peripheral/libupm/src/guvas12d/guvas12d.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "guvas12d.hpp"
+#include "guvas12d.h"
using namespace upm;
using namespace std;
@@ -54,7 +54,6 @@ float GUVAS12D::value(float aref, unsigned int samples)
for (int i=0; i<samples; i++)
{
val = mraa_aio_read(m_aio);
- if (val == -1) return -1;
sum += val;
usleep(2000);
}
diff --git a/peripheral/libupm/src/guvas12d/guvas12d.hpp b/peripheral/libupm/src/guvas12d/guvas12d.h
index 9ca2f5c..9ca2f5c 100644
--- a/peripheral/libupm/src/guvas12d/guvas12d.hpp
+++ b/peripheral/libupm/src/guvas12d/guvas12d.h
diff --git a/peripheral/libupm/src/guvas12d/javaupm_guvas12d.i b/peripheral/libupm/src/guvas12d/javaupm_guvas12d.i
index 0cf0599..1b7af28 100644
--- a/peripheral/libupm/src/guvas12d/javaupm_guvas12d.i
+++ b/peripheral/libupm/src/guvas12d/javaupm_guvas12d.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "guvas12d.hpp"
+ #include "guvas12d.h"
%}
-%include "guvas12d.hpp"
+%include "guvas12d.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/guvas12d/jsupm_guvas12d.i b/peripheral/libupm/src/guvas12d/jsupm_guvas12d.i
index db1e6c4..9660754 100644
--- a/peripheral/libupm/src/guvas12d/jsupm_guvas12d.i
+++ b/peripheral/libupm/src/guvas12d/jsupm_guvas12d.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "guvas12d.hpp"
+ #include "guvas12d.h"
%}
-%include "guvas12d.hpp"
+%include "guvas12d.h"
diff --git a/peripheral/libupm/src/guvas12d/pyupm_guvas12d.i b/peripheral/libupm/src/guvas12d/pyupm_guvas12d.i
index 7d63013..715b533 100644
--- a/peripheral/libupm/src/guvas12d/pyupm_guvas12d.i
+++ b/peripheral/libupm/src/guvas12d/pyupm_guvas12d.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "guvas12d.hpp"
+%include "guvas12d.h"
%{
- #include "guvas12d.hpp"
+ #include "guvas12d.h"
%}
diff --git a/peripheral/libupm/src/h3lis331dl/CMakeLists.txt b/peripheral/libupm/src/h3lis331dl/CMakeLists.txt
index df4294b..cec9f55 100644
--- a/peripheral/libupm/src/h3lis331dl/CMakeLists.txt
+++ b/peripheral/libupm/src/h3lis331dl/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "h3lis331dl")
set (libdescription "upm h3lis331dl I2c Accelerometer (400g)")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/h3lis331dl/h3lis331dl.cxx b/peripheral/libupm/src/h3lis331dl/h3lis331dl.cxx
index 86daeda..e726f2a 100644
--- a/peripheral/libupm/src/h3lis331dl/h3lis331dl.cxx
+++ b/peripheral/libupm/src/h3lis331dl/h3lis331dl.cxx
@@ -28,7 +28,7 @@
#include <stdexcept>
#include <string>
-#include "h3lis331dl.hpp"
+#include "h3lis331dl.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/h3lis331dl/h3lis331dl.hpp b/peripheral/libupm/src/h3lis331dl/h3lis331dl.h
index 775ec02..90b8a02 100644
--- a/peripheral/libupm/src/h3lis331dl/h3lis331dl.hpp
+++ b/peripheral/libupm/src/h3lis331dl/h3lis331dl.h
@@ -522,7 +522,7 @@ namespace upm {
/**
* Sets up the interrupt 1 threshold register
*
- * @param val Threshold to set
+ * @param val Threshhold to set
* @return True if successful
*/
bool setInterrupt1Threshold(uint8_t val);
@@ -530,7 +530,7 @@ namespace upm {
/**
* Sets up the interrupt 2 threshold register
*
- * @param val Threshold to set
+ * @param val Threshhold to set
* @return True if successful
*/
bool setInterrupt2Threshold(uint8_t val);
diff --git a/peripheral/libupm/src/h3lis331dl/javaupm_h3lis331dl.i b/peripheral/libupm/src/h3lis331dl/javaupm_h3lis331dl.i
index 9a8d1e0..812a53d 100644
--- a/peripheral/libupm/src/h3lis331dl/javaupm_h3lis331dl.i
+++ b/peripheral/libupm/src/h3lis331dl/javaupm_h3lis331dl.i
@@ -9,7 +9,7 @@
%ignore i2cContext;
%{
- #include "h3lis331dl.hpp"
+ #include "h3lis331dl.h"
%}
%typemap(jni) float* "jfloatArray"
@@ -48,7 +48,7 @@
%ignore getXYZ(int *, int *, int *);
%ignore getAcceleration(float *, float *, float *);
-%include "h3lis331dl.hpp"
+%include "h3lis331dl.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/h3lis331dl/jsupm_h3lis331dl.i b/peripheral/libupm/src/h3lis331dl/jsupm_h3lis331dl.i
index 052cc5b..f459bf3 100644
--- a/peripheral/libupm/src/h3lis331dl/jsupm_h3lis331dl.i
+++ b/peripheral/libupm/src/h3lis331dl/jsupm_h3lis331dl.i
@@ -7,7 +7,7 @@
%pointer_functions(float, floatp);
%{
- #include "h3lis331dl.hpp"
+ #include "h3lis331dl.h"
%}
-%include "h3lis331dl.hpp"
+%include "h3lis331dl.h"
diff --git a/peripheral/libupm/src/h3lis331dl/pyupm_h3lis331dl.i b/peripheral/libupm/src/h3lis331dl/pyupm_h3lis331dl.i
index b9d76d5..553081e 100644
--- a/peripheral/libupm/src/h3lis331dl/pyupm_h3lis331dl.i
+++ b/peripheral/libupm/src/h3lis331dl/pyupm_h3lis331dl.i
@@ -14,7 +14,7 @@
%include "h3lis331dl_doc.i"
#endif
-%include "h3lis331dl.hpp"
+%include "h3lis331dl.h"
%{
- #include "h3lis331dl.hpp"
+ #include "h3lis331dl.h"
%}
diff --git a/peripheral/libupm/src/h803x/CMakeLists.txt b/peripheral/libupm/src/h803x/CMakeLists.txt
deleted file mode 100644
index 3c723b0..0000000
--- a/peripheral/libupm/src/h803x/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-set (libname "h803x")
-set (libdescription "upm module for the Veris H803X (H8035/H8036)")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-
-pkg_check_modules(MODBUS libmodbus)
-if (MODBUS_FOUND)
- set (reqlibname "libmodbus")
- include_directories(${MODBUS_INCLUDE_DIRS})
- upm_module_init()
- target_link_libraries(${libname} ${MODBUS_LIBRARIES})
- if (BUILDSWIG)
- if (BUILDSWIGNODE)
- swig_link_libraries (jsupm_${libname} ${MODBUS_LIBRARIES})
- endif()
- if (BUILDSWIGPYTHON)
- swig_link_libraries (pyupm_${libname} ${MODBUS_LIBRARIES})
- endif()
- if (BUILDSWIGJAVA)
- swig_link_libraries (javaupm_${libname} ${MODBUS_LIBRARIES})
- endif()
- endif()
-endif ()
diff --git a/peripheral/libupm/src/h803x/h803x.cxx b/peripheral/libupm/src/h803x/h803x.cxx
deleted file mode 100644
index 03e7f58..0000000
--- a/peripheral/libupm/src/h803x/h803x.cxx
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <assert.h>
-#include <errno.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-
-#include "h803x.hpp"
-
-using namespace upm;
-using namespace std;
-
-// We can't use the modbus float conversion functions since they
-// assume the first word is the LSW. On this device, the first word
-// is MSW. In addition, the data is already IEEE 754 formatted, which
-// won't work with just the bit shuffling modbus_get_float*() does.
-static float regs2float(uint16_t h, uint16_t l)
-{
- // this function will fail horribly if the following isn't true
- assert(sizeof(float) == sizeof(uint32_t));
-
- // we can't use a cast here, since the data is already IEEE 754
- // formatted, so use a union instead.
- union {
- uint32_t i;
- float f;
- } converter;
-
- converter.i = ((uint32_t)h << 16) | l;
- return converter.f;
-}
-
-
-H803X::H803X(std::string device, int address, int baud, int bits, char parity,
- int stopBits) :
- m_mbContext(0)
-{
- // check some of the parameters
- if (!(bits == 7 || bits == 8))
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": bits must be 7 or 8");
- }
-
- if (!(parity == 'N' || parity == 'E' || parity == 'O'))
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": parity must be 'N', 'O', or 'E'");
- }
-
- if (!(stopBits == 1 || stopBits == 2))
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": stopBits must be 1 or 2");
- }
-
- // now, open/init the device and modbus context
-
- if (!(m_mbContext = modbus_new_rtu(device.c_str(), baud, parity, bits,
- stopBits)))
- {
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": modbus_new_rtu() failed");
- }
-
- // set the slave address of the device we want to talk to
-
- // addresses are only 8bits wide
- address &= 0xff;
- if (modbus_set_slave(m_mbContext, address))
- {
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": modbus_set_slave() failed");
- }
-
- // set the serial mode
- modbus_rtu_set_serial_mode(m_mbContext, MODBUS_RTU_RS232);
-
- // now connect..
- if (modbus_connect(m_mbContext))
- {
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": modbus_connect() failed");
- }
-
- // will set m_isH8036 appropriately
- testH8036();
-
- clearData();
-
- // turn off debugging
- setDebug(false);
-}
-
-H803X::~H803X()
-{
- if (m_mbContext)
- {
- modbus_close(m_mbContext);
- modbus_free(m_mbContext);
- }
-}
-
-int H803X::readHoldingRegs(HOLDING_REGS_T reg, int len, uint16_t *buf)
-{
- int rv;
- int retries = 5;
-
- // Sometimes it seems the device goes to sleep, and therefore a read
- // will timeout, so we will retry up to 5 times.
-
- while (retries >= 0)
- {
- if ((rv = modbus_read_registers(m_mbContext, reg, len, buf)) < 0)
- {
- if (errno == ETIMEDOUT)
- {
- // timeout
- retries--;
- sleep(1);
- }
- else if (errno == EMBXILADD)
- {
- // invalid registers will return a EMBXILADD (modbus)
- // error. We want to detect these as a way to determine
- // whether we are dealing with an H8035 or H8036.
- return -1;
- }
- else
- {
- // anything else is a failure.
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": modbus_read_registers() failed: "
- + modbus_strerror(errno));
- }
- }
- else
- return rv; // success
- }
-
- // if we're here, then all the retries were exhausted
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": modbus_read_registers() timed out after "
- + "5 retries");
-}
-
-void H803X::writeHoldingReg(HOLDING_REGS_T reg, int value)
-{
- if (modbus_write_register(m_mbContext, reg, value) != 1)
- {
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": modbus_write_register() failed: "
- + modbus_strerror(errno));
- }
-}
-
-void H803X::update()
-{
- static const int h8035NumRegs = 4; // 2 regs * 2
- static const int h8036NumRegs = 52; // 26 regs * 2
-
- int numRegs = (isH8036() ? h8036NumRegs : h8035NumRegs);
-
- uint16_t buf[numRegs];
-
- // This should only fail (return -1) if we got isH8036() wrong
- if (readHoldingRegs(HOLDING_CONSUMPTION_KWH, numRegs, buf) < 0)
- {
- throw std::out_of_range(std::string(__FUNCTION__) +
- ": readHoldingRegs() failed: "
- + modbus_strerror(errno));
- }
-
- // And so it begins...
-
- // H8035 / H8036
- m_consumptionkWh = regs2float(buf[0], buf[1]);
- m_realPowerkW = regs2float(buf[2], buf[3]);
-
- // H8036 only
- if (isH8036())
- {
- m_reactivePowerkVAR = regs2float(buf[4], buf[5]);
- m_apparentPowerkVA = regs2float(buf[6], buf[7]);
- m_powerFactor = regs2float(buf[8], buf[9]);
-
- m_voltsLineToLine = regs2float(buf[10], buf[11]);
- m_voltsLineToNeutral = regs2float(buf[12], buf[13]);
-
- m_current = regs2float(buf[14], buf[15]);
-
- m_realPowerPhaseAkW = regs2float(buf[16], buf[17]);
- m_realPowerPhaseBkW = regs2float(buf[18], buf[19]);
- m_realPowerPhaseCkW = regs2float(buf[20], buf[21]);
-
- m_powerFactorPhaseA = regs2float(buf[22], buf[23]);
- m_powerFactorPhaseB = regs2float(buf[24], buf[25]);
- m_powerFactorPhaseC = regs2float(buf[26], buf[27]);
-
- m_voltsPhaseAB = regs2float(buf[28], buf[29]);
- m_voltsPhaseBC = regs2float(buf[30], buf[31]);
- m_voltsPhaseAC = regs2float(buf[32], buf[33]);
- m_voltsPhaseAN = regs2float(buf[34], buf[35]);
- m_voltsPhaseBN = regs2float(buf[36], buf[37]);
- m_voltsPhaseCN = regs2float(buf[38], buf[39]);
-
- m_currentPhaseA = regs2float(buf[40], buf[41]);
- m_currentPhaseB = regs2float(buf[42], buf[43]);
- m_currentPhaseC = regs2float(buf[44], buf[45]);
-
- m_avgRealPowerkW = regs2float(buf[46], buf[47]);
- m_minRealPowerkW = regs2float(buf[48], buf[49]);
- m_maxRealPowerkW = regs2float(buf[50], buf[51]);
- }
-}
-
-string H803X::getSlaveID()
-{
- uint8_t id[MODBUS_MAX_PDU_LENGTH];
- int rv;
-
- if ((rv = modbus_report_slave_id(m_mbContext, MODBUS_MAX_PDU_LENGTH, id)) < 0)
- {
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": modbus_report_slave_id() failed: "
- + modbus_strerror(errno));
-
- }
-
- // the first byte is the number of bytes in the response, the second
- // byte is the active indicator (00 = off, ff = on), and the rest
- // are ascii identification (company, model, and serial number) data.
-
- if (rv > 2)
- {
- string retID((char *)&id[2], rv - 2);
- return retID;
- }
- else
- return "";
-}
-
-void H803X::setSlaveAddress(int addr)
-{
- // addresses are only 8bits wide
- addr &= 0xff;
-
- if (modbus_set_slave(m_mbContext, addr))
- {
- throw std::runtime_error(std::string(__FUNCTION__)
- + ": modbus_set_slave() failed: "
- + modbus_strerror(errno));
- }
-
- // retest H8036
- testH8036();
-
- // clear out any previously stored data
- clearData();
-}
-
-void H803X::setDebug(bool enable)
-{
- m_debugging = enable;
-
- if (enable)
- modbus_set_debug(m_mbContext, 1);
- else
- modbus_set_debug(m_mbContext, 0);
-}
-
-void H803X::clearData()
-{
- // H8035
- m_consumptionkWh = 0.0;
- m_realPowerkW = 0.0;
-
- // H8036
- m_reactivePowerkVAR = 0.0;
- m_apparentPowerkVA = 0.0;
- m_powerFactor = 0.0;
- m_voltsLineToLine = 0.0;
- m_voltsLineToNeutral = 0.0;
- m_current = 0.0;
- m_realPowerPhaseAkW = 0.0;
- m_realPowerPhaseBkW = 0.0;
- m_realPowerPhaseCkW = 0.0;
- m_powerFactorPhaseA = 0.0;
- m_powerFactorPhaseB = 0.0;
- m_powerFactorPhaseC = 0.0;
- m_voltsPhaseAB = 0.0;
- m_voltsPhaseBC = 0.0;
- m_voltsPhaseAC = 0.0;
- m_voltsPhaseAN = 0.0;
- m_voltsPhaseBN = 0.0;
- m_voltsPhaseCN = 0.0;
- m_currentPhaseA = 0.0;
- m_currentPhaseB = 0.0;
- m_currentPhaseC = 0.0;
- m_avgRealPowerkW = 0.0;
- m_minRealPowerkW = 0.0;
- m_maxRealPowerkW = 0.0;
-}
-
-void H803X::testH8036()
-{
- // here we test a register read to see if we are on an H8036 device,
- // which can provide much more information.
-
- uint16_t regs[2];
-
- // here, we'll read 2 registers that only exist on the H8036. Any
- // failure other than a illegal data access will generate an
- // exception. A valid request will return >0, and an illegal
- // register read will return -1.
- if (readHoldingRegs(HOLDING_REACTIVE_POWER_KVAR, 2, regs) == -1)
- m_isH8036 = false;
- else
- m_isH8036 = true;
-}
-
-void H803X::presetConsumption(float value, MULTIPLIERS_T multiplier)
-{
- uint32_t i = uint32_t(value * float(multiplier));
-
- uint16_t h = uint16_t(i >> 16);
- uint16_t l = uint16_t(i & 0xffff);
-
- // always write the LSW first
- writeHoldingReg(HOLDING_CONSUMPTION_KWH_INT_L, l);
- writeHoldingReg(HOLDING_CONSUMPTION_KWH_INT_H, h);
-}
diff --git a/peripheral/libupm/src/h803x/h803x.hpp b/peripheral/libupm/src/h803x/h803x.hpp
deleted file mode 100644
index 472f5e1..0000000
--- a/peripheral/libupm/src/h803x/h803x.hpp
+++ /dev/null
@@ -1,547 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-
-#include <modbus/modbus.h>
-
-namespace upm {
-
- /**
- * @brief H803X Energy Meter
- * @defgroup h803x libupm-h803x
- * @ingroup uart electric
- */
-
- /**
- * @library h803x
- * @sensor h803x
- * @comname UPM API for the Veris H803X Energy Meter
- * @type electic
- * @man veris
- * @con uart
- * @web http://www.veris.com/Item/H8035-0100-2.aspx
- *
- * @brief UPM API for the Veris H803X Energy Meter
- *
- * This module implements support for the Veris H8035 and H8036
- * Energy Meters.
- *
- * The H8036 is similar to the H8035, but provides much more data.
- *
- * The Enercept H8035/H8036 is an innovative three-phase networked
- * (Modbus RTU) power transducer that combines electronics and high
- * accuracy industrial grade CTs in a single package. The need for
- * external electrical enclosures is eliminated, greatly reducing
- * installation time and cost. Color-coordination between voltage
- * leads and CTs makes phase matching easy. Additionally, these
- * transducers automatically detect and compensate for phase
- * reversal, eliminating the concern of CT load orientation. Up to
- * 63 Transducers can be daisy-chained on a single RS-485 network.
- *
- * This module was developed using libmodbus 3.1.2, and the H8035.
- * The H8036 has not been tested. libmodbus 3.1.2 must be present
- * for this module to build.
- *
- * It was developed using an RS232->RS485 interface. You cannot use
- * the built in MCU TTL UART pins for accessing this device -- you
- * must use a full Serial RS232->RS485 or USB-RS485 interface
- * connected via USB.
- *
- * @snippet h803x.cxx Interesting
- */
-
- class H803X {
- public:
-
- // MODBUS holding registers. These offsets are for the MSW only.
- // The LSW always follows, though they are not enumerated here.
- // These are all 2 register (32-bit total (16b HSW + 16b LSW))
- // quantities, in IEEE 754 floating point format.
- typedef enum {
- // these two registers are used only for presetConsumption()
- HOLDING_CONSUMPTION_KWH_INT_L = 0, // preset use only
- HOLDING_CONSUMPTION_KWH_INT_H = 1, // preset use only
-
- // H8035/H8036
- HOLDING_CONSUMPTION_KWH = 258, // floating point data
-
- HOLDING_REAL_POWER_KW = 260,
-
- // H8036 only
- HOLDING_REACTIVE_POWER_KVAR = 262,
- HOLDING_APPARENT_POWER_KVA = 264,
- HOLDING_POWER_FACTOR = 266,
- HOLDING_VOLTS_LINE_TO_LINE = 268,
- HOLDING_VOLTS_LINE_TO_NEUTRAL = 270,
- HOLDING_CURRENT = 272,
- HOLDING_REAL_POWER_PHASE_A_KWH = 274,
- HOLDING_REAL_POWER_PHASE_B_KWH = 276,
- HOLDING_REAL_POWER_PHASE_C_KWH = 278,
- HOLDING_POWER_FACTOR_PHASE_A = 280,
- HOLDING_POWER_FACTOR_PHASE_B = 282,
- HOLDING_POWER_FACTOR_PHASE_C = 284,
- HOLDING_VOLTS_PHASE_AB = 286,
- HOLDING_VOLTS_PHASE_BC = 288,
- HOLDING_VOLTS_PHASE_AC = 290,
- HOLDING_VOLTS_PHASE_AN = 292,
- HOLDING_VOLTS_PHASE_BN = 294,
- HOLDING_VOLTS_PHASE_CN = 296,
- HOLDING_CURRENT_PHASE_A = 298,
- HOLDING_CURRENT_PHASE_B = 300,
- HOLDING_CURRENT_PHASE_C = 302,
- HOLDING_AVG_REAL_POWER_KW = 304,
- HOLDING_MIN_REAL_POWER_KW = 306,
- HOLDING_MAX_REAL_POWER_KW = 308
- } HOLDING_REGS_T;
-
- // these enums are used by presetConsumption() to scale the value
- // properly depending on the devices' current capacity.
- typedef enum {
- MULT_100A = 128, // 100A devices
- MULT_300A_400A = 32,
- MULT_800A = 16,
- MULT_1600A = 8,
- MULT_2400A = 4
- } MULTIPLIERS_T;
-
- /**
- * H803X constructor
- *
- * @param device Path to the serial device
- * @param address The MODBUS slave address
- * @param baud The baudrate of the device. Default: 9600
- * @param bits The number of bits per byte. Default: 8
- * @param parity The parity of the connection, 'N' for None, 'E'
- * for Even, 'O' for Odd. Default: 'N'
- * @param stopBits The number of stop bits. Default: 2
- */
- H803X(std::string device, int address, int baud=9600, int bits=8,
- char parity='N', int stopBits=2);
-
- /**
- * H803X Destructor
- */
- ~H803X();
-
- /**
- * Read current values from the sensor and update internal stored
- * values. This method must be called prior to querying any
- * values.
- */
- void update();
-
- /**
- * Return a string corresponding the the device's MODBUS slave ID.
- *
- * @return string represnting the MODBUS slave ID
- */
- std::string getSlaveID();
-
- /**
- * Set a new MODBUS slave address. This is useful if you have
- * multiple H803X devices on a single bus. When this method is
- * called, the current stored data is cleared, and a new attempt
- * is made to determine whether the target device is an H8035 or
- * H8036.
- *
- * @param addr The new slave address to set
- */
- void setSlaveAddress(int addr);
-
- /**
- * Preset the kWh accumulated Consumption registers to a
- * predefined value. This is generally not advised, but is
- * provided for those installations that might require it. The
- * multiplier depends on the current range of your device. Be
- * sure to select the right multiplier for your devices'
- * supported current capacity.
- *
- * @param value The desired value for the consumption accumulator
- * registers in kWh.
- * @param multiplier The correct MULTIPLIERS_T value for your device.
- */
- void presetConsumption(float value, MULTIPLIERS_T multiplier);
-
- /**
- * Return the accumulated consumption value, in kWh. update() must
- * have been called prior to calling this method.
- *
- * @return The accumulated consumption.
- */
- float getConsumption()
- {
- return m_consumptionkWh;
- };
-
- /**
- * Return the real power value in kW. update() must have been
- * called prior to calling this method.
- *
- * @return The real power value in kW.
- */
- float getRealPower()
- {
- return m_realPowerkW;
- };
-
- /**
- * Return the reactive power value in kVAR (kilo-volt Amperes
- * Reactive). update() must have been called prior to calling this
- * method.
- *
- * @return The reactive power value in kVAR.
- */
- float getReactivePower()
- {
- return m_reactivePowerkVAR;
- };
-
- /**
- * Return the apparent power value in kVA. update() must have been
- * called prior to calling this method.
- *
- * @return The apparent power value in kVA.
- */
- float getApparentPower()
- {
- return m_apparentPowerkVA;
- };
-
- /**
- * Return the power factor value. update() must have been called
- * prior to calling this method.
- *
- * @return The power factor.
- */
- float getPowerFactor()
- {
- return m_powerFactor;
- };
-
- /**
- * Return the voltage line to line value. update() must have been
- * called prior to calling this method.
- *
- * @return The voltage, line to line.
- */
- float getVoltsLineToLine()
- {
- return m_voltsLineToLine;
- };
-
- /**
- * Return the voltage line to neutral. update() must have been
- * called prior to calling this method.
- *
- * @return The voltage, line to neutral.
- */
- float getVoltsLineToNeutral()
- {
- return m_voltsLineToNeutral;
- };
-
- /**
- * Return the current value in amps. update() must have been
- * called prior to calling this method.
- *
- * @return The current value in amps.
- */
- float getCurrent()
- {
- return m_current;
- };
-
- /**
- * Return the real power for phase A. update() must have been
- * called prior to calling this method.
- *
- * @return The real power for phase A.
- */
- float getRealPowerPhaseA()
- {
- return m_realPowerPhaseAkW;
- };
-
- /**
- * Return the real power for phase B. update() must have been
- * called prior to calling this method.
- *
- * @return The real power for phase B.
- */
- float getRealPowerPhaseB()
- {
- return m_realPowerPhaseBkW;
- };
-
- /**
- * Return the real power for phase C. update() must have been
- * called prior to calling this method.
- *
- * @return The real power for phase C.
- */
- float getRealPowerPhaseC()
- {
- return m_realPowerPhaseCkW;
- };
-
- /**
- * Return the power factor for phase A. update() must have been
- * called prior to calling this method.
- *
- * @return The power factor for phase A.
- */
- float getPowerFactorPhaseA()
- {
- return m_powerFactorPhaseA;
- };
-
- /**
- * Return the power factor for phase B. update() must have been
- * called prior to calling this method.
- *
- * @return The power factor for phase B.
- */
- float getPowerFactorPhaseB()
- {
- return m_powerFactorPhaseB;
- };
-
- /**
- * Return the power factor for phase C. update() must have been
- * called prior to calling this method.
- *
- * @return The power factor for phase C.
- */
- float getPowerFactorPhaseC()
- {
- return m_powerFactorPhaseC;
- };
-
- /**
- * Return the voltage for phase A to B. update() must have been
- * called prior to calling this method.
- *
- * @return The voltage for phase A to B.
- */
- float getVoltsPhaseAToB()
- {
- return m_voltsPhaseAB;
- };
-
- /**
- * Return the voltage for phase B to C. update() must have been
- * called prior to calling this method.
- *
- * @return The voltage for phase B to C.
- */
- float getVoltsPhaseBToC()
- {
- return m_voltsPhaseBC;
- };
-
- /**
- * Return the voltage for phase A to B. update() must have been
- * called prior to calling this method.
- *
- * @return The voltage for phase A to B.
- */
- float getVoltsPhaseAToC()
- {
- return m_voltsPhaseAC;
- };
-
- /**
- * Return the voltage for phase A to neutral. update() must have
- * been called prior to calling this method.
- *
- * @return The voltage for phase A to neutral.
- */
- float getVoltsPhaseAToNeutral()
- {
- return m_voltsPhaseAN;
- };
-
- /**
- * Return the voltage for phase B to neutral. update() must have
- * been called prior to calling this method.
- *
- * @return The voltage for phase B to neutral.
- */
- float getVoltsPhaseBToNeutral()
- {
- return m_voltsPhaseBN;
- };
-
- /**
- * Return the voltage for phase C to neutral. update() must have
- * been called prior to calling this method.
- *
- * @return The voltage for phase C to neutral.
- */
- float getVoltsPhaseCToNeutral()
- {
- return m_voltsPhaseCN;
- };
-
- /**
- * Return the current for phase A. update() must have been called
- * prior to calling this method.
- *
- * @return The current for phase A.
- */
- float getCurrentPhaseA()
- {
- return m_currentPhaseA;
- };
-
- /**
- * Return the current for phase B. update() must have been called
- * prior to calling this method.
- *
- * @return The current for phase B.
- */
- float getCurrentPhaseB()
- {
- return m_currentPhaseB;
- };
-
- /**
- * Return the current for phase C. update() must have been called
- * prior to calling this method.
- *
- * @return The current for phase C.
- */
- float getCurrentPhaseC()
- {
- return m_currentPhaseC;
- };
-
- /**
- * Return the average real power. update() must have been called
- * prior to calling this method.
- *
- * @return The average real power.
- */
- float getAvgRealPower()
- {
- return m_avgRealPowerkW;
- };
-
- /**
- * Return the minimum real power. update() must have been called
- * prior to calling this method.
- *
- * @return The minimum real power.
- */
- float getMinRealPower()
- {
- return m_minRealPowerkW;
- };
-
- /**
- * Return the maximum real power. update() must have been called
- * prior to calling this method.
- *
- * @return The maximum real power.
- */
- float getMaxRealPower()
- {
- return m_maxRealPowerkW;
- };
-
- /**
- * Enable or disable debugging output. This primarily enables and
- * disables libmodbus debugging output.
- *
- * @param enable true to enable debugging, false otherwise
- */
- void setDebug(bool enable);
-
- /**
- * Indicate whether the connected device is an H8035 or an H8036.
- * The H8036 provides many more data registers.
- *
- * @return true if we are using an H8036, false otherwise.
- */
- bool isH8036()
- {
- return m_isH8036;
- };
-
- protected:
- // holding registers
- int readHoldingRegs(HOLDING_REGS_T reg, int len, uint16_t *buf);
- void writeHoldingReg(HOLDING_REGS_T reg, int value);
-
- // clear out all stored data
- void clearData();
-
- // MODBUS context
- modbus_t *m_mbContext;
-
- // test to see if the connected device is an H8036, and set
- // m_isH8036 appropriately
- void testH8036();
-
- // Is this an H8036 (has extended registers)
- bool m_isH8036;
-
- private:
- bool m_debugging;
-
- // data
-
- // H8035 / H8036
- float m_consumptionkWh;
- float m_realPowerkW;
-
- // H8036 only
- float m_reactivePowerkVAR;
- float m_apparentPowerkVA;
- float m_powerFactor;
- float m_voltsLineToLine;
- float m_voltsLineToNeutral;
- float m_current; // in amps
- float m_realPowerPhaseAkW;
- float m_realPowerPhaseBkW;
- float m_realPowerPhaseCkW;
- float m_powerFactorPhaseA;
- float m_powerFactorPhaseB;
- float m_powerFactorPhaseC;
- float m_voltsPhaseAB;
- float m_voltsPhaseBC;
- float m_voltsPhaseAC;
- float m_voltsPhaseAN;
- float m_voltsPhaseBN;
- float m_voltsPhaseCN;
- float m_currentPhaseA;
- float m_currentPhaseB;
- float m_currentPhaseC;
- float m_avgRealPowerkW;
- float m_minRealPowerkW;
- float m_maxRealPowerkW;
- };
-}
diff --git a/peripheral/libupm/src/h803x/jsupm_h803x.i b/peripheral/libupm/src/h803x/jsupm_h803x.i
deleted file mode 100644
index 4938fe6..0000000
--- a/peripheral/libupm/src/h803x/jsupm_h803x.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module jsupm_h803x
-%include "../upm.i"
-%include "stdint.i"
-
-%include "h803x.hpp"
-%{
- #include "h803x.hpp"
-%}
diff --git a/peripheral/libupm/src/h803x/pyupm_h803x.i b/peripheral/libupm/src/h803x/pyupm_h803x.i
deleted file mode 100644
index 134bbaf..0000000
--- a/peripheral/libupm/src/h803x/pyupm_h803x.i
+++ /dev/null
@@ -1,12 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_h803x
-%include "../upm.i"
-%include "stdint.i"
-
-%feature("autodoc", "3");
-
-%include "h803x.hpp"
-%{
- #include "h803x.hpp"
-%}
diff --git a/peripheral/libupm/src/hcsr04/CMakeLists.txt b/peripheral/libupm/src/hcsr04/CMakeLists.txt
index 5aec195..81e692d 100644
--- a/peripheral/libupm/src/hcsr04/CMakeLists.txt
+++ b/peripheral/libupm/src/hcsr04/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "hcsr04")
set (libdescription "upm proximity sensor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/hcsr04/hcsr04.cxx b/peripheral/libupm/src/hcsr04/hcsr04.cxx
index a05b9d5..1a6a49e 100644
--- a/peripheral/libupm/src/hcsr04/hcsr04.cxx
+++ b/peripheral/libupm/src/hcsr04/hcsr04.cxx
@@ -34,7 +34,7 @@
#undef JAVACALLBACK
#endif
-#include "hcsr04.hpp"
+#include "hcsr04.h"
using namespace upm;
diff --git a/peripheral/libupm/src/hcsr04/hcsr04.hpp b/peripheral/libupm/src/hcsr04/hcsr04.h
index 95721df..95721df 100644
--- a/peripheral/libupm/src/hcsr04/hcsr04.hpp
+++ b/peripheral/libupm/src/hcsr04/hcsr04.h
diff --git a/peripheral/libupm/src/hcsr04/javaupm_hcsr04.i b/peripheral/libupm/src/hcsr04/javaupm_hcsr04.i
index a92d6f0..046646b 100644
--- a/peripheral/libupm/src/hcsr04/javaupm_hcsr04.i
+++ b/peripheral/libupm/src/hcsr04/javaupm_hcsr04.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "hcsr04.hpp"
+ #include "hcsr04.h"
%}
-%include "hcsr04.hpp"
+%include "hcsr04.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/hcsr04/jsupm_hcsr04.i b/peripheral/libupm/src/hcsr04/jsupm_hcsr04.i
index 0b5aa52..f86bd1b 100644
--- a/peripheral/libupm/src/hcsr04/jsupm_hcsr04.i
+++ b/peripheral/libupm/src/hcsr04/jsupm_hcsr04.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "hcsr04.hpp"
+ #include "hcsr04.h"
%}
-%include "hcsr04.hpp"
+%include "hcsr04.h"
diff --git a/peripheral/libupm/src/hcsr04/pyupm_hcsr04.i b/peripheral/libupm/src/hcsr04/pyupm_hcsr04.i
index 87c4e9d..56e435b 100644
--- a/peripheral/libupm/src/hcsr04/pyupm_hcsr04.i
+++ b/peripheral/libupm/src/hcsr04/pyupm_hcsr04.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "hcsr04.hpp"
+%include "hcsr04.h"
%{
- #include "hcsr04.hpp"
+ #include "hcsr04.h"
%}
diff --git a/peripheral/libupm/src/hdxxvxta/CMakeLists.txt b/peripheral/libupm/src/hdxxvxta/CMakeLists.txt
index ec6ac67..9f8244d 100644
--- a/peripheral/libupm/src/hdxxvxta/CMakeLists.txt
+++ b/peripheral/libupm/src/hdxxvxta/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "hdxxvxta")
set (libdescription "upm Veris HDXXVXTA Temperature/Humidity transmitter")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/hdxxvxta/hdxxvxta.cxx b/peripheral/libupm/src/hdxxvxta/hdxxvxta.cxx
index 0d73492..6c25d1b 100644
--- a/peripheral/libupm/src/hdxxvxta/hdxxvxta.cxx
+++ b/peripheral/libupm/src/hdxxvxta/hdxxvxta.cxx
@@ -24,7 +24,7 @@
#include <iostream>
-#include "hdxxvxta.hpp"
+#include "hdxxvxta.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/hdxxvxta/hdxxvxta.hpp b/peripheral/libupm/src/hdxxvxta/hdxxvxta.h
index a0f5f7a..a0f5f7a 100644
--- a/peripheral/libupm/src/hdxxvxta/hdxxvxta.hpp
+++ b/peripheral/libupm/src/hdxxvxta/hdxxvxta.h
diff --git a/peripheral/libupm/src/hdxxvxta/javaupm_hdxxvxta.i b/peripheral/libupm/src/hdxxvxta/javaupm_hdxxvxta.i
index 3a0d6a2..95c78bf 100644
--- a/peripheral/libupm/src/hdxxvxta/javaupm_hdxxvxta.i
+++ b/peripheral/libupm/src/hdxxvxta/javaupm_hdxxvxta.i
@@ -3,10 +3,10 @@
%include "std_string.i"
%{
- #include "hdxxvxta.hpp"
+ #include "hdxxvxta.h"
%}
-%include "hdxxvxta.hpp"
+%include "hdxxvxta.h"
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/hdxxvxta/jsupm_hdxxvxta.i b/peripheral/libupm/src/hdxxvxta/jsupm_hdxxvxta.i
index b3b25e3..8fa283d 100644
--- a/peripheral/libupm/src/hdxxvxta/jsupm_hdxxvxta.i
+++ b/peripheral/libupm/src/hdxxvxta/jsupm_hdxxvxta.i
@@ -3,8 +3,8 @@
%include "std_string.i"
%{
- #include "hdxxvxta.hpp"
+ #include "hdxxvxta.h"
%}
-%include "hdxxvxta.hpp"
+%include "hdxxvxta.h"
diff --git a/peripheral/libupm/src/hdxxvxta/pyupm_hdxxvxta.i b/peripheral/libupm/src/hdxxvxta/pyupm_hdxxvxta.i
index b792647..377deab 100644
--- a/peripheral/libupm/src/hdxxvxta/pyupm_hdxxvxta.i
+++ b/peripheral/libupm/src/hdxxvxta/pyupm_hdxxvxta.i
@@ -7,7 +7,7 @@
%feature("autodoc", "3");
%{
- #include "hdxxvxta.hpp"
+ #include "hdxxvxta.h"
%}
-%include "hdxxvxta.hpp"
+%include "hdxxvxta.h"
diff --git a/peripheral/libupm/src/hlg150h/CMakeLists.txt b/peripheral/libupm/src/hlg150h/CMakeLists.txt
deleted file mode 100644
index 6650f8b..0000000
--- a/peripheral/libupm/src/hlg150h/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-include_directories(..)
-set (libname "hlg150h")
-set (libdescription “Lighting power supply”)
-set (module_src ${libname}.cxx mraa-utils.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/hlg150h/hlg150h.cxx b/peripheral/libupm/src/hlg150h/hlg150h.cxx
deleted file mode 100644
index bfc8cd6..0000000
--- a/peripheral/libupm/src/hlg150h/hlg150h.cxx
+++ /dev/null
@@ -1,80 +0,0 @@
-#include <iostream>
-#include <stdexcept>
-#include <unistd.h>
-#include "hlg150h.hpp"
-#include "mraa-utils.hpp"
-
-#define PWM_PERIOD 3333
-
-using namespace upm;
-
-HLG150H::HLG150H(int pinRelay, int pinPWM)
-{
- int dutyPercent = 0;
- status = mraa::SUCCESS;
- this->pinRelay = pinRelay;
- isPoweredShadow = false;
- pwmBrightness = new mraa::Pwm(pinPWM);
- status = pwmBrightness->enable(true);
- status = pwmBrightness->period_us(PWM_PERIOD);
- if (status != mraa::SUCCESS)
- UPM_THROW("pwm config failed.");
- dutyPercent = getBrightness();
- isPoweredShadow = dutyPercent > 10;
-}
-
-HLG150H::~HLG150H()
-{
- delete pwmBrightness;
-}
-
-void HLG150H::setPowerOn()
-{
- isPoweredShadow = true;
- MraaUtils::setGpio(pinRelay, 0);
-}
-
-void HLG150H::setPowerOff()
-{
- isPoweredShadow = false;
- MraaUtils::setGpio(pinRelay, 1);
-}
-
-bool HLG150H::isPowered()
-{
- // Can't read GPIO state as setting in to input mode turns off relay
- // Instead we return a shadow variable
- /*
- int level;
- if (MraaUtils::getGpio(pinRelay, &level) == MRAA_SUCCESS)
- return level == 1;
- else
- return false;
- */
- return isPoweredShadow;
-}
-
-
-// If duty is less than 10% light will flicker
-void HLG150H::setBrightness(int dutyPercent)
-{
- if (dutyPercent < 10)
- dutyPercent = 10;
- int dutyUs = (PWM_PERIOD * dutyPercent) / 100;
- dutyUs = PWM_PERIOD - dutyUs;
- status = pwmBrightness->pulsewidth_us(dutyUs);
- // std::cout << "Brightness = " << dutyPercent << "%, duty = " << dutyUs << "us" << std::endl;
- if (status != mraa::SUCCESS)
- UPM_THROW("setBrightness failed");
-
-}
-
-
-int HLG150H::getBrightness()
-{
- float duty = pwmBrightness->read();
- int dutyPercent = static_cast<int>(100.0 * (1.0 - duty) + 0.5);
- return dutyPercent;
-}
-
-
diff --git a/peripheral/libupm/src/hlg150h/hlg150h.hpp b/peripheral/libupm/src/hlg150h/hlg150h.hpp
deleted file mode 100644
index a92a8be..0000000
--- a/peripheral/libupm/src/hlg150h/hlg150h.hpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include "upm/iLightController.hpp"
-// #include "mraa/gpio.hpp"
-#include "mraa/pwm.hpp"
-
-namespace upm
-{
-
-/**
- * @brief Meanwell HLG150H Lighting power supply controller library
- * @defgroup hlg150h libupm-hlg150h
- * @ingroup pwm light ilightcontroller
- */
-
-/**
- * @brief API for HLG-150H Lighting Power Supply Controller
- *
- * The Mean Well
- * [HLG-150H](http://www.meanwell.com/webapp/product/search.aspx?prod=HLG-150H)
- * 150W Single Output Switching Power Supply
- *
- * @library hlg150h
- * @sensor hlg150h
- * @comname HLG150H lighting controller
- * @altname HLG150H
- * @type light
- * @con pwm
- * @if ilightcontroller
- */
-
-class HLG150H : public upm::ILightController
-{
-public:
- HLG150H(int pinRelay, int pinPWM);
- ~HLG150H();
-
-protected:
- const char* getModuleName() { return "hlg150h"; }
- void setPowerOn();
- void setPowerOff();
- bool isPowered();
- void setBrightness(int dutyPercent);
- int getBrightness();
-
-private:
- mraa::Result status;
- bool isPoweredShadow;
- int pinRelay;
- mraa::Pwm* pwmBrightness;
-};
-
-}
-
-
-
diff --git a/peripheral/libupm/src/hlg150h/javaupm_hlg150h.i b/peripheral/libupm/src/hlg150h/javaupm_hlg150h.i
deleted file mode 100644
index ffe620b..0000000
--- a/peripheral/libupm/src/hlg150h/javaupm_hlg150h.i
+++ /dev/null
@@ -1,23 +0,0 @@
-%module javaupm_hlg150h
-%include "../upm.i"
-%include "arrays_java.i";
-%include "../java_buffer.i"
-%include "cpointer.i"
-%include "typemaps.i"
-
-%{
- #include "hlg150h.hpp"
-%}
-
-%include "hlg150h.hpp"
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_hlg150h");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/hlg150h/jsupm_hlg150h.i b/peripheral/libupm/src/hlg150h/jsupm_hlg150h.i
deleted file mode 100644
index 18cb2e0..0000000
--- a/peripheral/libupm/src/hlg150h/jsupm_hlg150h.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module jsupm_hlg150h
-%include "../upm.i"
-
-%{
- #include "hlg150h.hpp"
-%}
-
-%include "hlg150h.hpp"
diff --git a/peripheral/libupm/src/hlg150h/mraa-utils.cxx b/peripheral/libupm/src/hlg150h/mraa-utils.cxx
deleted file mode 100644
index c1261a6..0000000
--- a/peripheral/libupm/src/hlg150h/mraa-utils.cxx
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <string>
-#include "mraa-utils.hpp"
-#include "mraa/gpio.hpp"
-
- #define UPM_THROW(msg) throw std::runtime_error(std::string(__FUNCTION__) + ": " + (msg))
-
-void MraaUtils::setGpio(int pin, int level)
-{
- mraa::Gpio gpio(pin);
- gpio.dir(mraa::DIR_OUT);
- if (gpio.write(level) != mraa::SUCCESS)
- UPM_THROW("gpio write failed");
-}
-
-
-int MraaUtils::getGpio(int pin)
-{
- mraa::Gpio gpio(pin);
- gpio.dir(mraa::DIR_IN);
- return gpio.read();
-}
-
-
diff --git a/peripheral/libupm/src/hlg150h/mraa-utils.hpp b/peripheral/libupm/src/hlg150h/mraa-utils.hpp
deleted file mode 100644
index f9e6acc..0000000
--- a/peripheral/libupm/src/hlg150h/mraa-utils.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#pragma once
-
-#include "mraa/types.h"
-
-class __attribute__ ((visibility("hidden"))) MraaUtils
-{
-public:
- static void setGpio(int pin, int level);
- static int getGpio(int pin);
-};
-
-
-
diff --git a/peripheral/libupm/src/hlg150h/pyupm_hlg150h.i b/peripheral/libupm/src/hlg150h/pyupm_hlg150h.i
deleted file mode 100644
index 29c6697..0000000
--- a/peripheral/libupm/src/hlg150h/pyupm_hlg150h.i
+++ /dev/null
@@ -1,9 +0,0 @@
-%module pyupm_hlg150h
-%include "../upm.i"
-
-%feature("autodoc", "3");
-
-%include "hlg150h.hpp"
-%{
- #include "hlg150h.hpp"
-%}
diff --git a/peripheral/libupm/src/hm11/CMakeLists.txt b/peripheral/libupm/src/hm11/CMakeLists.txt
index d586b5c..6e9fb87 100644
--- a/peripheral/libupm/src/hm11/CMakeLists.txt
+++ b/peripheral/libupm/src/hm11/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "hm11")
set (libdescription "upm grove hm11 bluetooth low energy module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/hm11/hm11.cxx b/peripheral/libupm/src/hm11/hm11.cxx
index bc0c3ba..0c6cebc 100644
--- a/peripheral/libupm/src/hm11/hm11.cxx
+++ b/peripheral/libupm/src/hm11/hm11.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "hm11.hpp"
+#include "hm11.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/hm11/hm11.hpp b/peripheral/libupm/src/hm11/hm11.h
index 29e4319..29e4319 100644
--- a/peripheral/libupm/src/hm11/hm11.hpp
+++ b/peripheral/libupm/src/hm11/hm11.h
diff --git a/peripheral/libupm/src/hm11/javaupm_hm11.i b/peripheral/libupm/src/hm11/javaupm_hm11.i
index a5fee07..df71082 100644
--- a/peripheral/libupm/src/hm11/javaupm_hm11.i
+++ b/peripheral/libupm/src/hm11/javaupm_hm11.i
@@ -4,11 +4,11 @@
%include "../java_buffer.i"
%{
- #include "hm11.hpp"
+ #include "hm11.h"
speed_t int_B9600 = B9600;
%}
-%include "hm11.hpp"
+%include "hm11.h"
speed_t int_B9600 = B9600;
%array_class(char, charArray);
diff --git a/peripheral/libupm/src/hm11/jsupm_hm11.i b/peripheral/libupm/src/hm11/jsupm_hm11.i
index bf2f605..4f02b7a 100644
--- a/peripheral/libupm/src/hm11/jsupm_hm11.i
+++ b/peripheral/libupm/src/hm11/jsupm_hm11.i
@@ -3,10 +3,10 @@
%include "carrays.i"
%{
- #include "hm11.hpp"
+ #include "hm11.h"
speed_t int_B9600 = B9600;
%}
-%include "hm11.hpp"
+%include "hm11.h"
speed_t int_B9600 = B9600;
%array_class(char, charArray);
diff --git a/peripheral/libupm/src/hm11/pyupm_hm11.i b/peripheral/libupm/src/hm11/pyupm_hm11.i
index 453cdb0..345d106 100644
--- a/peripheral/libupm/src/hm11/pyupm_hm11.i
+++ b/peripheral/libupm/src/hm11/pyupm_hm11.i
@@ -7,9 +7,9 @@
%feature("autodoc", "3");
%{
- #include "hm11.hpp"
+ #include "hm11.h"
speed_t int_B9600 = B9600;
%}
-%include "hm11.hpp"
+%include "hm11.h"
speed_t int_B9600 = B9600;
%array_class(char, charArray);
diff --git a/peripheral/libupm/src/hmc5883l/CMakeLists.txt b/peripheral/libupm/src/hmc5883l/CMakeLists.txt
index 9f83850..f97d75f 100644
--- a/peripheral/libupm/src/hmc5883l/CMakeLists.txt
+++ b/peripheral/libupm/src/hmc5883l/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "hmc5883l")
set (libdescription "libupm Digital Compass")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/hmc5883l/hmc5883l.cxx b/peripheral/libupm/src/hmc5883l/hmc5883l.cxx
index fc8f690..bcada4b 100644
--- a/peripheral/libupm/src/hmc5883l/hmc5883l.cxx
+++ b/peripheral/libupm/src/hmc5883l/hmc5883l.cxx
@@ -27,7 +27,7 @@
#include <stdexcept>
#include "math.h"
-#include "hmc5883l.hpp"
+#include "hmc5883l.h"
#define MAX_BUFFER_LENGTH 6
#define HMC5883L_I2C_ADDR 0x1E
diff --git a/peripheral/libupm/src/hmc5883l/hmc5883l.hpp b/peripheral/libupm/src/hmc5883l/hmc5883l.h
index 3bd8b76..3bd8b76 100644
--- a/peripheral/libupm/src/hmc5883l/hmc5883l.hpp
+++ b/peripheral/libupm/src/hmc5883l/hmc5883l.h
diff --git a/peripheral/libupm/src/hmc5883l/javaupm_hmc5883l.i b/peripheral/libupm/src/hmc5883l/javaupm_hmc5883l.i
index db43d6d..cc80059 100644
--- a/peripheral/libupm/src/hmc5883l/javaupm_hmc5883l.i
+++ b/peripheral/libupm/src/hmc5883l/javaupm_hmc5883l.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "hmc5883l.hpp"
+ #include "hmc5883l.h"
%}
%typemap(jni) int16_t* "jshortArray"
@@ -18,7 +18,7 @@
JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1);
}
-%include "hmc5883l.hpp"
+%include "hmc5883l.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/hmc5883l/jsupm_hmc5883l.i b/peripheral/libupm/src/hmc5883l/jsupm_hmc5883l.i
index f5b7192..b04b3e9 100644
--- a/peripheral/libupm/src/hmc5883l/jsupm_hmc5883l.i
+++ b/peripheral/libupm/src/hmc5883l/jsupm_hmc5883l.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%include "../carrays_int16_t.i"
%{
- #include "hmc5883l.hpp"
+ #include "hmc5883l.h"
%}
// Adding this typemap because SWIG is converting int16 into a short by default
@@ -11,4 +11,4 @@
$result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 );
}
-%include "hmc5883l.hpp"
+%include "hmc5883l.h"
diff --git a/peripheral/libupm/src/hmc5883l/pyupm_hmc5883l.i b/peripheral/libupm/src/hmc5883l/pyupm_hmc5883l.i
index c79a43b..c14f949 100644
--- a/peripheral/libupm/src/hmc5883l/pyupm_hmc5883l.i
+++ b/peripheral/libupm/src/hmc5883l/pyupm_hmc5883l.i
@@ -14,7 +14,7 @@
$result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 );
}
-%include "hmc5883l.hpp"
+%include "hmc5883l.h"
%{
- #include "hmc5883l.hpp"
+ #include "hmc5883l.h"
%}
diff --git a/peripheral/libupm/src/hmtrp/CMakeLists.txt b/peripheral/libupm/src/hmtrp/CMakeLists.txt
index f48a1f6..6a43ba3 100644
--- a/peripheral/libupm/src/hmtrp/CMakeLists.txt
+++ b/peripheral/libupm/src/hmtrp/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "hmtrp")
set (libdescription "upm grove serial rf pro (hmtrp) module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/hmtrp/hmtrp.cxx b/peripheral/libupm/src/hmtrp/hmtrp.cxx
index 60e52d3..ca71c31 100644
--- a/peripheral/libupm/src/hmtrp/hmtrp.cxx
+++ b/peripheral/libupm/src/hmtrp/hmtrp.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "hmtrp.hpp"
+#include "hmtrp.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/hmtrp/hmtrp.hpp b/peripheral/libupm/src/hmtrp/hmtrp.h
index c091a8f..c091a8f 100644
--- a/peripheral/libupm/src/hmtrp/hmtrp.hpp
+++ b/peripheral/libupm/src/hmtrp/hmtrp.h
diff --git a/peripheral/libupm/src/hmtrp/javaupm_hmtrp.i b/peripheral/libupm/src/hmtrp/javaupm_hmtrp.i
index 6d4c4de..2f38e06 100644
--- a/peripheral/libupm/src/hmtrp/javaupm_hmtrp.i
+++ b/peripheral/libupm/src/hmtrp/javaupm_hmtrp.i
@@ -12,7 +12,7 @@
%apply uint8_t *OUTPUT { uint8_t *strength };
%{
- #include "hmtrp.hpp"
+ #include "hmtrp.h"
speed_t int_B9600 = B9600;
%}
@@ -22,7 +22,7 @@ READDATA_EXCEPTION(getRFSignalStrength())
%ignore getModSignalStrength(uint8_t *strength);
READDATA_EXCEPTION(getModSignalStrength())
-%include "hmtrp.hpp"
+%include "hmtrp.h"
speed_t int_B9600 = B9600;
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/hmtrp/jsupm_hmtrp.i b/peripheral/libupm/src/hmtrp/jsupm_hmtrp.i
index 3c2bfbe..2853677 100644
--- a/peripheral/libupm/src/hmtrp/jsupm_hmtrp.i
+++ b/peripheral/libupm/src/hmtrp/jsupm_hmtrp.i
@@ -5,10 +5,10 @@
%include "../carrays_uint32_t.i"
%{
- #include "hmtrp.hpp"
+ #include "hmtrp.h"
speed_t int_B9600 = B9600;
%}
-%include "hmtrp.hpp"
+%include "hmtrp.h"
speed_t int_B9600 = B9600;
%array_class(char, charArray);
diff --git a/peripheral/libupm/src/hmtrp/pyupm_hmtrp.i b/peripheral/libupm/src/hmtrp/pyupm_hmtrp.i
index 8cb96e3..3898382 100644
--- a/peripheral/libupm/src/hmtrp/pyupm_hmtrp.i
+++ b/peripheral/libupm/src/hmtrp/pyupm_hmtrp.i
@@ -11,9 +11,9 @@
%feature("autodoc", "3");
-%include "hmtrp.hpp"
+%include "hmtrp.h"
%{
- #include "hmtrp.hpp"
+ #include "hmtrp.h"
speed_t int_B9600 = B9600;
%}
speed_t int_B9600 = B9600;
diff --git a/peripheral/libupm/src/hp20x/CMakeLists.txt b/peripheral/libupm/src/hp20x/CMakeLists.txt
index 169d2da..63c0b82 100644
--- a/peripheral/libupm/src/hp20x/CMakeLists.txt
+++ b/peripheral/libupm/src/hp20x/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "hp20x")
set (libdescription "upm grove barometer (high efficiency)")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/hp20x/hp20x.cxx b/peripheral/libupm/src/hp20x/hp20x.cxx
index 3cbe0fe..73ae3e2 100644
--- a/peripheral/libupm/src/hp20x/hp20x.cxx
+++ b/peripheral/libupm/src/hp20x/hp20x.cxx
@@ -28,7 +28,7 @@
#include <string>
#include <stdexcept>
-#include "hp20x.hpp"
+#include "hp20x.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/hp20x/hp20x.hpp b/peripheral/libupm/src/hp20x/hp20x.h
index 9831341..9831341 100644
--- a/peripheral/libupm/src/hp20x/hp20x.hpp
+++ b/peripheral/libupm/src/hp20x/hp20x.h
diff --git a/peripheral/libupm/src/hp20x/javaupm_hp20x.i b/peripheral/libupm/src/hp20x/javaupm_hp20x.i
index 8602c46..54d7c33 100644
--- a/peripheral/libupm/src/hp20x/javaupm_hp20x.i
+++ b/peripheral/libupm/src/hp20x/javaupm_hp20x.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "hp20x.hpp"
+ #include "hp20x.h"
%}
-%include "hp20x.hpp"
+%include "hp20x.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/hp20x/jsupm_hp20x.i b/peripheral/libupm/src/hp20x/jsupm_hp20x.i
index e83a6b2..cf9a645 100644
--- a/peripheral/libupm/src/hp20x/jsupm_hp20x.i
+++ b/peripheral/libupm/src/hp20x/jsupm_hp20x.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "hp20x.hpp"
+ #include "hp20x.h"
%}
-%include "hp20x.hpp"
+%include "hp20x.h"
diff --git a/peripheral/libupm/src/hp20x/pyupm_hp20x.i b/peripheral/libupm/src/hp20x/pyupm_hp20x.i
index 20aea4d..39c0b07 100644
--- a/peripheral/libupm/src/hp20x/pyupm_hp20x.i
+++ b/peripheral/libupm/src/hp20x/pyupm_hp20x.i
@@ -9,7 +9,7 @@
%include "hp20x_doc.i"
#endif
-%include "hp20x.hpp"
+%include "hp20x.h"
%{
- #include "hp20x.hpp"
+ #include "hp20x.h"
%}
diff --git a/peripheral/libupm/src/ht9170/CMakeLists.txt b/peripheral/libupm/src/ht9170/CMakeLists.txt
index 889038d..b00f1eb 100644
--- a/peripheral/libupm/src/ht9170/CMakeLists.txt
+++ b/peripheral/libupm/src/ht9170/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "ht9170")
set (libdescription "upm ht9170 DTMF decoder")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/ht9170/ht9170.cxx b/peripheral/libupm/src/ht9170/ht9170.cxx
index 109e104..d34987b 100644
--- a/peripheral/libupm/src/ht9170/ht9170.cxx
+++ b/peripheral/libupm/src/ht9170/ht9170.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "ht9170.hpp"
+#include "ht9170.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/ht9170/ht9170.hpp b/peripheral/libupm/src/ht9170/ht9170.h
index a16f6ea..a16f6ea 100644
--- a/peripheral/libupm/src/ht9170/ht9170.hpp
+++ b/peripheral/libupm/src/ht9170/ht9170.h
diff --git a/peripheral/libupm/src/ht9170/javaupm_ht9170.i b/peripheral/libupm/src/ht9170/javaupm_ht9170.i
index 25fd713..4bc6b1d 100644
--- a/peripheral/libupm/src/ht9170/javaupm_ht9170.i
+++ b/peripheral/libupm/src/ht9170/javaupm_ht9170.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "ht9170.hpp"
+ #include "ht9170.h"
%}
-%include "ht9170.hpp"
+%include "ht9170.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/ht9170/jsupm_ht9170.i b/peripheral/libupm/src/ht9170/jsupm_ht9170.i
index 1c7c789..f4d14b3 100644
--- a/peripheral/libupm/src/ht9170/jsupm_ht9170.i
+++ b/peripheral/libupm/src/ht9170/jsupm_ht9170.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "ht9170.hpp"
+ #include "ht9170.h"
%}
-%include "ht9170.hpp"
+%include "ht9170.h"
diff --git a/peripheral/libupm/src/ht9170/pyupm_ht9170.i b/peripheral/libupm/src/ht9170/pyupm_ht9170.i
index 9b6ccac..bb5d3d2 100644
--- a/peripheral/libupm/src/ht9170/pyupm_ht9170.i
+++ b/peripheral/libupm/src/ht9170/pyupm_ht9170.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "ht9170.hpp"
+%include "ht9170.h"
%{
- #include "ht9170.hpp"
+ #include "ht9170.h"
%}
diff --git a/peripheral/libupm/src/htu21d/CMakeLists.txt b/peripheral/libupm/src/htu21d/CMakeLists.txt
index aa8aece..4385a1f 100644
--- a/peripheral/libupm/src/htu21d/CMakeLists.txt
+++ b/peripheral/libupm/src/htu21d/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "htu21d")
set (libdescription "libupm Humidity Sensor")
set (module_src ${libname}.cpp)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/htu21d/htu21d.cpp b/peripheral/libupm/src/htu21d/htu21d.cpp
index 540d381..0ff097c 100644
--- a/peripheral/libupm/src/htu21d/htu21d.cpp
+++ b/peripheral/libupm/src/htu21d/htu21d.cpp
@@ -28,7 +28,7 @@
#include <unistd.h>
#include <stdlib.h>
-#include "htu21d.hpp"
+#include "htu21d.h"
using namespace upm;
diff --git a/peripheral/libupm/src/htu21d/htu21d.hpp b/peripheral/libupm/src/htu21d/htu21d.h
index 910d351..910d351 100644
--- a/peripheral/libupm/src/htu21d/htu21d.hpp
+++ b/peripheral/libupm/src/htu21d/htu21d.h
diff --git a/peripheral/libupm/src/htu21d/javaupm_htu21d.i b/peripheral/libupm/src/htu21d/javaupm_htu21d.i
index 25c44b4..7c6b1ef 100644
--- a/peripheral/libupm/src/htu21d/javaupm_htu21d.i
+++ b/peripheral/libupm/src/htu21d/javaupm_htu21d.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "htu21d.hpp"
+ #include "htu21d.h"
%}
-%include "htu21d.hpp"
+%include "htu21d.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/htu21d/jsupm_htu21d.i b/peripheral/libupm/src/htu21d/jsupm_htu21d.i
index 66dcdb4..e6d9c9d 100644
--- a/peripheral/libupm/src/htu21d/jsupm_htu21d.i
+++ b/peripheral/libupm/src/htu21d/jsupm_htu21d.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "htu21d.hpp"
+ #include "htu21d.h"
%}
-%include "htu21d.hpp"
+%include "htu21d.h"
diff --git a/peripheral/libupm/src/htu21d/pyupm_htu21d.i b/peripheral/libupm/src/htu21d/pyupm_htu21d.i
index b68f5ee..6f87b98 100644
--- a/peripheral/libupm/src/htu21d/pyupm_htu21d.i
+++ b/peripheral/libupm/src/htu21d/pyupm_htu21d.i
@@ -9,7 +9,7 @@
%include "htu21d_doc.i"
#endif
-%include "htu21d.hpp"
+%include "htu21d.h"
%{
- #include "htu21d.hpp"
+ #include "htu21d.h"
%}
diff --git a/peripheral/libupm/src/hwxpxx/CMakeLists.txt b/peripheral/libupm/src/hwxpxx/CMakeLists.txt
index a23b6c5..47bee1a 100644
--- a/peripheral/libupm/src/hwxpxx/CMakeLists.txt
+++ b/peripheral/libupm/src/hwxpxx/CMakeLists.txt
@@ -1,20 +1,21 @@
set (libname "hwxpxx")
set (libdescription "upm module for the Veris HWXPXX (HWXPHTX)")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
-pkg_check_modules(MODBUS libmodbus)
+pkg_search_module(MODBUS libmodbus)
if (MODBUS_FOUND)
set (reqlibname "libmodbus")
include_directories(${MODBUS_INCLUDE_DIRS})
upm_module_init()
+ add_dependencies(${libname} ${MODBUS_LIBRARIES})
target_link_libraries(${libname} ${MODBUS_LIBRARIES})
if (BUILDSWIG)
if (BUILDSWIGNODE)
- swig_link_libraries (jsupm_${libname} ${MODBUS_LIBRARIES})
+ swig_link_libraries (jsupm_${libname} ${MODBUS_LIBRARIES} ${MRAA_LIBRARIES} ${NODE_LIBRARIES})
endif()
if (BUILDSWIGPYTHON)
- swig_link_libraries (pyupm_${libname} ${MODBUS_LIBRARIES})
+ swig_link_libraries (pyupm_${libname} ${MODBUS_LIBRARIES} ${PYTHON_LIBRARIES} ${MRAA_LIBRARIES})
endif()
endif()
endif ()
diff --git a/peripheral/libupm/src/hwxpxx/hwxpxx.cxx b/peripheral/libupm/src/hwxpxx/hwxpxx.cxx
index 51deae9..78753ce 100644
--- a/peripheral/libupm/src/hwxpxx/hwxpxx.cxx
+++ b/peripheral/libupm/src/hwxpxx/hwxpxx.cxx
@@ -27,7 +27,7 @@
#include <stdexcept>
#include <string>
-#include "hwxpxx.hpp"
+#include "hwxpxx.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/hwxpxx/hwxpxx.hpp b/peripheral/libupm/src/hwxpxx/hwxpxx.h
index 1d2da73..1d2da73 100644
--- a/peripheral/libupm/src/hwxpxx/hwxpxx.hpp
+++ b/peripheral/libupm/src/hwxpxx/hwxpxx.h
diff --git a/peripheral/libupm/src/hwxpxx/javaupm_hwxpxx.i b/peripheral/libupm/src/hwxpxx/javaupm_hwxpxx.i
index b431137..f6f849b 100644
--- a/peripheral/libupm/src/hwxpxx/javaupm_hwxpxx.i
+++ b/peripheral/libupm/src/hwxpxx/javaupm_hwxpxx.i
@@ -3,10 +3,10 @@
%include "typemaps.i"
%{
- #include "hwxpxx.hpp"
+ #include "hwxpxx.h"
%}
-%include "hwxpxx.hpp"
+%include "hwxpxx.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/hwxpxx/jsupm_hwxpxx.i b/peripheral/libupm/src/hwxpxx/jsupm_hwxpxx.i
index b58732a..2620000 100644
--- a/peripheral/libupm/src/hwxpxx/jsupm_hwxpxx.i
+++ b/peripheral/libupm/src/hwxpxx/jsupm_hwxpxx.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%include "stdint.i"
-%include "hwxpxx.hpp"
+%include "hwxpxx.h"
%{
- #include "hwxpxx.hpp"
+ #include "hwxpxx.h"
%}
diff --git a/peripheral/libupm/src/hwxpxx/pyupm_hwxpxx.i b/peripheral/libupm/src/hwxpxx/pyupm_hwxpxx.i
index e37e387..fcfec09 100644
--- a/peripheral/libupm/src/hwxpxx/pyupm_hwxpxx.i
+++ b/peripheral/libupm/src/hwxpxx/pyupm_hwxpxx.i
@@ -6,7 +6,7 @@
%feature("autodoc", "3");
-%include "hwxpxx.hpp"
+%include "hwxpxx.h"
%{
- #include "hwxpxx.hpp"
+ #include "hwxpxx.h"
%}
diff --git a/peripheral/libupm/src/hx711/CMakeLists.txt b/peripheral/libupm/src/hx711/CMakeLists.txt
index 29c42c9..8cdf95e 100644
--- a/peripheral/libupm/src/hx711/CMakeLists.txt
+++ b/peripheral/libupm/src/hx711/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "hx711")
set (libdescription "HX711 24bit ADC")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/hx711/hx711.cxx b/peripheral/libupm/src/hx711/hx711.cxx
index cf6c987..28e60bf 100644
--- a/peripheral/libupm/src/hx711/hx711.cxx
+++ b/peripheral/libupm/src/hx711/hx711.cxx
@@ -25,7 +25,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdexcept>
-#include "hx711.hpp"
+#include "hx711.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/hx711/hx711.hpp b/peripheral/libupm/src/hx711/hx711.h
index 4047fbc..4047fbc 100644
--- a/peripheral/libupm/src/hx711/hx711.hpp
+++ b/peripheral/libupm/src/hx711/hx711.h
diff --git a/peripheral/libupm/src/hx711/javaupm_hx711.i b/peripheral/libupm/src/hx711/javaupm_hx711.i
index 1d3e9ef..2d8fdf5 100644
--- a/peripheral/libupm/src/hx711/javaupm_hx711.i
+++ b/peripheral/libupm/src/hx711/javaupm_hx711.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "hx711.hpp"
+ #include "hx711.h"
%}
-%include "hx711.hpp"
+%include "hx711.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/hx711/jsupm_hx711.i b/peripheral/libupm/src/hx711/jsupm_hx711.i
index a3a79f3..ddaabe9 100644
--- a/peripheral/libupm/src/hx711/jsupm_hx711.i
+++ b/peripheral/libupm/src/hx711/jsupm_hx711.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "hx711.hpp"
+ #include "hx711.h"
%}
-%include "hx711.hpp"
+%include "hx711.h"
diff --git a/peripheral/libupm/src/hx711/pyupm_hx711.i b/peripheral/libupm/src/hx711/pyupm_hx711.i
index 3811e27..8d313f0 100644
--- a/peripheral/libupm/src/hx711/pyupm_hx711.i
+++ b/peripheral/libupm/src/hx711/pyupm_hx711.i
@@ -6,7 +6,7 @@
%feature("autodoc", "3");
-%include "hx711.hpp"
+%include "hx711.h"
%{
- #include "hx711.hpp"
+ #include "hx711.h"
%}
diff --git a/peripheral/libupm/src/ili9341/CMakeLists.txt b/peripheral/libupm/src/ili9341/CMakeLists.txt
index 43489be..6998826 100644
--- a/peripheral/libupm/src/ili9341/CMakeLists.txt
+++ b/peripheral/libupm/src/ili9341/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "ili9341")
set (libdescription "libupm ILI9341 SPI LCD")
-set (module_src ili9341_gfx.cxx ili9341.cxx)
-set (module_hpp ili9341_gfx.hpp ili9341.hpp)
+set (module_src gfx.cxx ili9341.cxx)
+set (module_h gfx.h ili9341.h)
upm_module_init()
diff --git a/peripheral/libupm/src/ili9341/ili9341_gfx.cxx b/peripheral/libupm/src/ili9341/gfx.cxx
index 9888265..90f83de 100644
--- a/peripheral/libupm/src/ili9341/ili9341_gfx.cxx
+++ b/peripheral/libupm/src/ili9341/gfx.cxx
@@ -24,7 +24,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "ili9341_gfx.hpp"
+#include "gfx.h"
using namespace upm;
diff --git a/peripheral/libupm/src/ili9341/ili9341_gfx.hpp b/peripheral/libupm/src/ili9341/gfx.h
index c62e81e..c62e81e 100644
--- a/peripheral/libupm/src/ili9341/ili9341_gfx.hpp
+++ b/peripheral/libupm/src/ili9341/gfx.h
diff --git a/peripheral/libupm/src/ili9341/ili9341.cxx b/peripheral/libupm/src/ili9341/ili9341.cxx
index 22e2350..b0a4e57 100644
--- a/peripheral/libupm/src/ili9341/ili9341.cxx
+++ b/peripheral/libupm/src/ili9341/ili9341.cxx
@@ -33,7 +33,7 @@
#include <stdio.h>
#include <string.h>
-#include "ili9341.hpp"
+#include "ili9341.h"
using namespace upm;
diff --git a/peripheral/libupm/src/ili9341/ili9341.hpp b/peripheral/libupm/src/ili9341/ili9341.h
index 23eb3f4..fbf8a20 100644
--- a/peripheral/libupm/src/ili9341/ili9341.hpp
+++ b/peripheral/libupm/src/ili9341/ili9341.h
@@ -32,7 +32,7 @@
#include <mraa/common.hpp>
#include <mraa/gpio.hpp>
#include <mraa/spi.hpp>
-#include "ili9341_gfx.hpp"
+#include "gfx.h"
// Defines
#define ILI9341_TFTWIDTH 240
diff --git a/peripheral/libupm/src/ili9341/javaupm_ili9341.i b/peripheral/libupm/src/ili9341/javaupm_ili9341.i
index 6a7071b..d725498 100644
--- a/peripheral/libupm/src/ili9341/javaupm_ili9341.i
+++ b/peripheral/libupm/src/ili9341/javaupm_ili9341.i
@@ -5,16 +5,16 @@
%apply uint8_t *INPUT { uint8_t *addr }
-%include "ili9341_gfx.hpp"
+%include "gfx.h"
%{
- #include "ili9341_gfx.hpp"
+ #include "gfx.h"
%}
%{
- #include "ili9341.hpp"
+ #include "ili9341.h"
%}
-%include "ili9341.hpp"
+%include "ili9341.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/ili9341/jsupm_ili9341.i b/peripheral/libupm/src/ili9341/jsupm_ili9341.i
index fd47fb6..db58074 100644
--- a/peripheral/libupm/src/ili9341/jsupm_ili9341.i
+++ b/peripheral/libupm/src/ili9341/jsupm_ili9341.i
@@ -1,12 +1,12 @@
%module jsupm_ili9341
%include "../upm.i"
-%include "ili9341_gfx.hpp"
+%include "gfx.h"
%{
- #include "ili9341_gfx.hpp"
+ #include "gfx.h"
%}
-%include "ili9341.hpp"
+%include "ili9341.h"
%{
- #include "ili9341.hpp"
+ #include "ili9341.h"
%}
diff --git a/peripheral/libupm/src/ili9341/pyupm_ili9341.i b/peripheral/libupm/src/ili9341/pyupm_ili9341.i
index 2d36cc0..c772853 100644
--- a/peripheral/libupm/src/ili9341/pyupm_ili9341.i
+++ b/peripheral/libupm/src/ili9341/pyupm_ili9341.i
@@ -6,12 +6,12 @@
%feature("autodoc", "3");
%rename("printString") print(std::string msg);
-%include "ili9341_gfx.hpp"
+%include "gfx.h"
%{
- #include "ili9341_gfx.hpp"
+ #include "gfx.h"
%}
-%include "ili9341.hpp"
+%include "ili9341.h"
%{
- #include "ili9341.hpp"
+ #include "ili9341.h"
%}
diff --git a/peripheral/libupm/src/ina132/CMakeLists.txt b/peripheral/libupm/src/ina132/CMakeLists.txt
index 31471e6..d1dd9fd 100644
--- a/peripheral/libupm/src/ina132/CMakeLists.txt
+++ b/peripheral/libupm/src/ina132/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "ina132")
set (libdescription "upm ina132 differential amplifier sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/ina132/ina132.cxx b/peripheral/libupm/src/ina132/ina132.cxx
index 11ed525..ffba007 100644
--- a/peripheral/libupm/src/ina132/ina132.cxx
+++ b/peripheral/libupm/src/ina132/ina132.cxx
@@ -27,7 +27,7 @@
#include <stdexcept>
#include <unistd.h>
-#include "ina132.hpp"
+#include "ina132.h"
using namespace upm;
using namespace std;
@@ -55,7 +55,6 @@ float INA132::value()
for(i=0;i<10;i++)
{
val = mraa_aio_read(m_aio);
- if (val == -1) return -1;
v = val*5.00/1023;
sum += v;
usleep(10000);
diff --git a/peripheral/libupm/src/ina132/ina132.hpp b/peripheral/libupm/src/ina132/ina132.h
index 56d32d3..56d32d3 100644
--- a/peripheral/libupm/src/ina132/ina132.hpp
+++ b/peripheral/libupm/src/ina132/ina132.h
diff --git a/peripheral/libupm/src/ina132/javaupm_ina132.i b/peripheral/libupm/src/ina132/javaupm_ina132.i
index affc72f..b49ed20 100644
--- a/peripheral/libupm/src/ina132/javaupm_ina132.i
+++ b/peripheral/libupm/src/ina132/javaupm_ina132.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "ina132.hpp"
+ #include "ina132.h"
%}
-%include "ina132.hpp"
+%include "ina132.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/ina132/jsupm_ina132.i b/peripheral/libupm/src/ina132/jsupm_ina132.i
index 2780b89..28be9ba 100644
--- a/peripheral/libupm/src/ina132/jsupm_ina132.i
+++ b/peripheral/libupm/src/ina132/jsupm_ina132.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "ina132.hpp"
+ #include "ina132.h"
%}
-%include "ina132.hpp"
+%include "ina132.h"
diff --git a/peripheral/libupm/src/ina132/pyupm_ina132.i b/peripheral/libupm/src/ina132/pyupm_ina132.i
index 44a7f9d..01f6a60 100644
--- a/peripheral/libupm/src/ina132/pyupm_ina132.i
+++ b/peripheral/libupm/src/ina132/pyupm_ina132.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "ina132.hpp"
+%include "ina132.h"
%{
- #include "ina132.hpp"
+ #include "ina132.h"
%}
diff --git a/peripheral/libupm/src/isd1820/CMakeLists.txt b/peripheral/libupm/src/isd1820/CMakeLists.txt
index 329781c..57ee9c1 100644
--- a/peripheral/libupm/src/isd1820/CMakeLists.txt
+++ b/peripheral/libupm/src/isd1820/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "isd1820")
set (libdescription "upm grove recorder")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/isd1820/isd1820.cxx b/peripheral/libupm/src/isd1820/isd1820.cxx
index 9cfbfad..29aed20 100644
--- a/peripheral/libupm/src/isd1820/isd1820.cxx
+++ b/peripheral/libupm/src/isd1820/isd1820.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "isd1820.hpp"
+#include "isd1820.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/isd1820/isd1820.hpp b/peripheral/libupm/src/isd1820/isd1820.h
index 8e89511..8e89511 100644
--- a/peripheral/libupm/src/isd1820/isd1820.hpp
+++ b/peripheral/libupm/src/isd1820/isd1820.h
diff --git a/peripheral/libupm/src/isd1820/javaupm_isd1820.i b/peripheral/libupm/src/isd1820/javaupm_isd1820.i
index 235c9d9..ac5f341 100644
--- a/peripheral/libupm/src/isd1820/javaupm_isd1820.i
+++ b/peripheral/libupm/src/isd1820/javaupm_isd1820.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "isd1820.hpp"
+ #include "isd1820.h"
%}
-%include "isd1820.hpp"
+%include "isd1820.h"
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/isd1820/jsupm_isd1820.i b/peripheral/libupm/src/isd1820/jsupm_isd1820.i
index 00be649..30d7e03 100644
--- a/peripheral/libupm/src/isd1820/jsupm_isd1820.i
+++ b/peripheral/libupm/src/isd1820/jsupm_isd1820.i
@@ -2,8 +2,8 @@
%include "../upm.i"
%{
- #include "isd1820.hpp"
+ #include "isd1820.h"
%}
-%include "isd1820.hpp"
+%include "isd1820.h"
diff --git a/peripheral/libupm/src/isd1820/pyupm_isd1820.i b/peripheral/libupm/src/isd1820/pyupm_isd1820.i
index 1a9f138..ec916f4 100644
--- a/peripheral/libupm/src/isd1820/pyupm_isd1820.i
+++ b/peripheral/libupm/src/isd1820/pyupm_isd1820.i
@@ -6,8 +6,8 @@
%feature("autodoc", "3");
%{
- #include "isd1820.hpp"
+ #include "isd1820.h"
%}
-%include "isd1820.hpp"
+%include "isd1820.h"
diff --git a/peripheral/libupm/src/itg3200/CMakeLists.txt b/peripheral/libupm/src/itg3200/CMakeLists.txt
index d26844d..5be008b 100644
--- a/peripheral/libupm/src/itg3200/CMakeLists.txt
+++ b/peripheral/libupm/src/itg3200/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "itg3200")
set (libdescription "libupm Digital Gyro")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/itg3200/itg3200.cxx b/peripheral/libupm/src/itg3200/itg3200.cxx
index 8f2fb29..1f2f2ff 100644
--- a/peripheral/libupm/src/itg3200/itg3200.cxx
+++ b/peripheral/libupm/src/itg3200/itg3200.cxx
@@ -27,7 +27,7 @@
#include <stdexcept>
#include <unistd.h>
#include "math.h"
-#include "itg3200.hpp"
+#include "itg3200.h"
#define READ_BUFFER_LENGTH 8
diff --git a/peripheral/libupm/src/itg3200/itg3200.hpp b/peripheral/libupm/src/itg3200/itg3200.h
index 32ec1f6..32ec1f6 100644
--- a/peripheral/libupm/src/itg3200/itg3200.hpp
+++ b/peripheral/libupm/src/itg3200/itg3200.h
diff --git a/peripheral/libupm/src/itg3200/javaupm_itg3200.i b/peripheral/libupm/src/itg3200/javaupm_itg3200.i
index b11cce9..012c6a0 100644
--- a/peripheral/libupm/src/itg3200/javaupm_itg3200.i
+++ b/peripheral/libupm/src/itg3200/javaupm_itg3200.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "itg3200.hpp"
+ #include "itg3200.h"
%}
%typemap(jni) float* "jfloatArray"
@@ -32,7 +32,7 @@
JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1);
}
-%include "itg3200.hpp"
+%include "itg3200.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/itg3200/jsupm_itg3200.i b/peripheral/libupm/src/itg3200/jsupm_itg3200.i
index 0dda5ce..011ffc6 100644
--- a/peripheral/libupm/src/itg3200/jsupm_itg3200.i
+++ b/peripheral/libupm/src/itg3200/jsupm_itg3200.i
@@ -4,7 +4,7 @@
%include "../carrays_float.i"
%{
- #include "itg3200.hpp"
+ #include "itg3200.h"
%}
%typemap(out) int16_t * {
@@ -15,6 +15,6 @@
$result = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_floatArray, 0 | 0 );
}
-%include "itg3200.hpp"
+%include "itg3200.h"
%include <carrays.i>
diff --git a/peripheral/libupm/src/itg3200/pyupm_itg3200.i b/peripheral/libupm/src/itg3200/pyupm_itg3200.i
index 96fa74c..7faae41 100644
--- a/peripheral/libupm/src/itg3200/pyupm_itg3200.i
+++ b/peripheral/libupm/src/itg3200/pyupm_itg3200.i
@@ -19,7 +19,7 @@
%include "itg3200_doc.i"
#endif
-%include "itg3200.hpp"
+%include "itg3200.h"
%{
- #include "itg3200.hpp"
+ #include "itg3200.h"
%}
diff --git a/peripheral/libupm/src/javaswig_blacklist b/peripheral/libupm/src/javaswig_blacklist
index 18cf785..f38ff79 100644
--- a/peripheral/libupm/src/javaswig_blacklist
+++ b/peripheral/libupm/src/javaswig_blacklist
@@ -1,3 +1 @@
nrf8001
-kxcjk1013
-l3gd20
diff --git a/peripheral/libupm/src/joystick12/CMakeLists.txt b/peripheral/libupm/src/joystick12/CMakeLists.txt
index 0d0afc2..750e62e 100644
--- a/peripheral/libupm/src/joystick12/CMakeLists.txt
+++ b/peripheral/libupm/src/joystick12/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "joystick12")
set (libdescription "ElecFreaks Joystick 1.2")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/joystick12/javaupm_joystick12.i b/peripheral/libupm/src/joystick12/javaupm_joystick12.i
index c4ecf63..8ebe78f 100644
--- a/peripheral/libupm/src/joystick12/javaupm_joystick12.i
+++ b/peripheral/libupm/src/joystick12/javaupm_joystick12.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "joystick12.hpp"
+ #include "joystick12.h"
%}
-%include "joystick12.hpp"
+%include "joystick12.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/joystick12/joystick12.cxx b/peripheral/libupm/src/joystick12/joystick12.cxx
index 4f7245b..b70557c 100644
--- a/peripheral/libupm/src/joystick12/joystick12.cxx
+++ b/peripheral/libupm/src/joystick12/joystick12.cxx
@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <functional>
#include <string.h>
-#include "joystick12.hpp"
+#include "joystick12.h"
using namespace upm;
@@ -75,7 +75,6 @@ Joystick12::~Joystick12() {
float Joystick12::getXInput() {
float in = mraa_aio_read (m_joystickCtxX);
- if (in == -1.0) return -1;
if (in < X_left) return -1;
if (in < X_center) return -(X_center - in) / (X_center - X_left);
if (in == X_center) return 0;
@@ -87,7 +86,6 @@ float Joystick12::getXInput() {
float Joystick12::getYInput() {
float in = mraa_aio_read (m_joystickCtxY);
- if (in == -1.0) return -1;
if (in < Y_left) return -1;
if (in < Y_center) return -(Y_center - in) / (Y_center - Y_left);
if (in == Y_center) return 0;
diff --git a/peripheral/libupm/src/joystick12/joystick12.hpp b/peripheral/libupm/src/joystick12/joystick12.h
index 2157fa6..2157fa6 100644
--- a/peripheral/libupm/src/joystick12/joystick12.hpp
+++ b/peripheral/libupm/src/joystick12/joystick12.h
diff --git a/peripheral/libupm/src/joystick12/jsupm_joystick12.i b/peripheral/libupm/src/joystick12/jsupm_joystick12.i
index 2945918..640273f 100644
--- a/peripheral/libupm/src/joystick12/jsupm_joystick12.i
+++ b/peripheral/libupm/src/joystick12/jsupm_joystick12.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "joystick12.hpp"
+ #include "joystick12.h"
%}
-%include "joystick12.hpp"
+%include "joystick12.h"
diff --git a/peripheral/libupm/src/joystick12/pyupm_joystick12.i b/peripheral/libupm/src/joystick12/pyupm_joystick12.i
index 9fb2aa9..fa7637c 100644
--- a/peripheral/libupm/src/joystick12/pyupm_joystick12.i
+++ b/peripheral/libupm/src/joystick12/pyupm_joystick12.i
@@ -7,7 +7,7 @@
%feature("autodoc", "3");
-%include "joystick12.hpp"
+%include "joystick12.h"
%{
- #include "joystick12.hpp"
+ #include "joystick12.h"
%}
diff --git a/peripheral/libupm/src/kxcjk1013/CMakeLists.txt b/peripheral/libupm/src/kxcjk1013/CMakeLists.txt
index d957a00..679dc4a 100644
--- a/peripheral/libupm/src/kxcjk1013/CMakeLists.txt
+++ b/peripheral/libupm/src/kxcjk1013/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "kxcjk1013")
set (libdescription "upm kxcjk1013 sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/h803x/javaupm_h803x.i b/peripheral/libupm/src/kxcjk1013/javaupm_kxcjk1013.i
index 7c98031..1c5e88f 100644
--- a/peripheral/libupm/src/h803x/javaupm_h803x.i
+++ b/peripheral/libupm/src/kxcjk1013/javaupm_kxcjk1013.i
@@ -1,17 +1,17 @@
-%module javaupm_h803x
+%module javaupm_kxcjk1013
%include "../upm.i"
-%include "typemaps.i"
%{
- #include "h803x.hpp"
+ #include "kxcjk1013.h"
%}
+%include "kxcjk1013.h"
-%include "h803x.hpp"
+%ignore installISR(void (*isr)(char*), void* arg);
%pragma(java) jniclasscode=%{
static {
try {
- System.loadLibrary("javaupm_h803x");
+ System.loadLibrary("javaupm_kxcjk1013");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. \n" + e);
System.exit(1);
diff --git a/peripheral/libupm/src/kxcjk1013/jsupm_kxcjk1013.i b/peripheral/libupm/src/kxcjk1013/jsupm_kxcjk1013.i
index 7671462..e457563 100644
--- a/peripheral/libupm/src/kxcjk1013/jsupm_kxcjk1013.i
+++ b/peripheral/libupm/src/kxcjk1013/jsupm_kxcjk1013.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "kxcjk1013.hpp"
+ #include "kxcjk1013.h"
%}
-%include "kxcjk1013.hpp"
+%include "kxcjk1013.h"
diff --git a/peripheral/libupm/src/kxcjk1013/kxcjk1013.cxx b/peripheral/libupm/src/kxcjk1013/kxcjk1013.cxx
index bf1021a..0eafbb7 100755..100644
--- a/peripheral/libupm/src/kxcjk1013/kxcjk1013.cxx
+++ b/peripheral/libupm/src/kxcjk1013/kxcjk1013.cxx
@@ -1,6 +1,6 @@
/*
* Author: Lay, Kuan Loon <kuan.loon.lay@intel.com>
- * Copyright (c) 2016 Intel Corporation.
+ * Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -26,9 +26,7 @@
#include <string>
#include <stdexcept>
#include <string.h>
-#include "kxcjk1013.hpp"
-
-#define NUMBER_OF_BITS_IN_BYTE 8
+#include "kxcjk1013.h"
using namespace upm;
@@ -47,9 +45,9 @@ KXCJK1013::KXCJK1013(int device)
sprintf(trigger, "hrtimer-kxcjk1013-hr-dev%d", device);
if (mraa_iio_create_trigger(m_iio, trigger) != MRAA_SUCCESS)
- fprintf(stderr, "Create trigger %s failed\n", trigger);
+ fprintf(stderr, "Create trigger failed\n");
- if (mraa_iio_get_mount_matrix(m_iio, "in_mount_matrix", m_mount_matrix) == MRAA_SUCCESS)
+ if (mraa_iio_get_mounting_matrix(m_iio, m_mount_matrix) == MRAA_SUCCESS)
m_mount_matrix_exist = true;
else
m_mount_matrix_exist = false;
@@ -60,8 +58,7 @@ KXCJK1013::KXCJK1013(int device)
KXCJK1013::~KXCJK1013()
{
- if (m_iio)
- mraa_iio_close(m_iio);
+ // mraa_iio_stop(m_iio);
}
void
@@ -73,20 +70,21 @@ KXCJK1013::installISR(void (*isr)(char*), void* arg)
int64_t
KXCJK1013::getChannelValue(unsigned char* input, mraa_iio_channel* chan)
{
- uint64_t u64 = 0;
+ uint64_t u64;
int i;
- int storagebits = chan->bytes * NUMBER_OF_BITS_IN_BYTE;
+ int storagebits = chan->bytes * 8;
int realbits = chan->bits_used;
int zeroed_bits = storagebits - realbits;
uint64_t sign_mask;
uint64_t value_mask;
+ u64 = 0;
if (!chan->lendian)
- for (i = 0; i < storagebits / NUMBER_OF_BITS_IN_BYTE; i++)
- u64 = (u64 << NUMBER_OF_BITS_IN_BYTE) | input[i];
+ for (i = 0; i < storagebits / 8; i++)
+ u64 = (u64 << 8) | input[i];
else
- for (i = storagebits / NUMBER_OF_BITS_IN_BYTE - 1; i >= 0; i--)
+ for (i = storagebits / 8 - 1; i >= 0; i--)
u64 = (u64 << 8) | input[i];
u64 = (u64 >> chan->shift) & (~0ULL >> zeroed_bits);
@@ -144,7 +142,6 @@ KXCJK1013::disableBuffer()
bool
KXCJK1013::setScale(float scale)
{
- m_scale = scale;
mraa_iio_write_float(m_iio, "in_accel_scale", scale);
return true;
@@ -186,7 +183,6 @@ KXCJK1013::extract3Axis(char* data, float* x, float* y, float* z)
iio_y = getChannelValue((unsigned char*) (data + channels[1].location), &channels[1]);
iio_z = getChannelValue((unsigned char*) (data + channels[2].location), &channels[2]);
- // Raw data is acceleration in direction. Units after application of scale are m/s^2
*x = (iio_x * m_scale);
*y = (iio_y * m_scale);
*z = (iio_z * m_scale);
diff --git a/peripheral/libupm/src/kxcjk1013/kxcjk1013.hpp b/peripheral/libupm/src/kxcjk1013/kxcjk1013.h
index 29be647..0a2f2ab 100644
--- a/peripheral/libupm/src/kxcjk1013/kxcjk1013.hpp
+++ b/peripheral/libupm/src/kxcjk1013/kxcjk1013.h
@@ -1,6 +1,6 @@
/*
* Author: Lay, Kuan Loon <kuan.loon.lay@intel.com>
- * Copyright (c) 2016 Intel Corporation.
+ * Copyright (c) 2015 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -59,12 +59,10 @@ class KXCJK1013
* @param iio device number
*/
KXCJK1013(int device);
-
/**
* KXCJK1013 destructor
*/
~KXCJK1013();
-
/**
* Installs an interrupt service routine (ISR) to be called when
* an interrupt occurs
@@ -75,17 +73,16 @@ class KXCJK1013
* argument to the ISR.
*/
void installISR(void (*isr)(char*), void* arg);
-
/**
* Extract the channel value based on channel type
- * @param input Channel data
- * @param chan MRAA iio-layer channel info
+ * @param input Channel data
+ * @param chan MRAA iio-layer channel info
*/
int64_t getChannelValue(unsigned char* input, mraa_iio_channel* chan);
/**
* Enable trigger buffer
- * @param trigger buffer length in integer
+ * @param trigger buffer length in string
*/
bool enableBuffer(int length);
@@ -96,18 +93,13 @@ class KXCJK1013
/**
* Set scale
- * @param scale in float
- * Available scales are 0.009582(2g), 0.019163(4g), and 0.038326(8g)
- * Default scale is 0.019163
+ * @param scale in string
*/
bool setScale(const float scale);
/**
* Set sampling frequency
- * @param sampling frequency in float
- * Available sampling frequency are 0.781000, 1.563000, 3.125000, 6.250000, 12.500000, 25, 50,
- * 100, 200, 400, 800, and 1600
- * Default sampling frequency is 25
+ * @param sampling frequency in string
*/
bool setSamplingFrequency(const float sampling_frequency);
@@ -118,10 +110,10 @@ class KXCJK1013
/**
* Process enabled channel buffer and return x, y, z axis
- * @param data Enabled channel data, 6 bytes, each axis 2 bytes
- * @param x X-Axis
- * @param y Y-Axis
- * @param z Z-Axis
+ * @param data Enabled channel data, 6 bytes, each axis 2 bytes
+ * @param x X-Axis
+ * @param y Y-Axis
+ * @param z Z-Axis
*/
void extract3Axis(char* data, float* x, float* y, float* z);
@@ -129,7 +121,7 @@ class KXCJK1013
mraa_iio_context m_iio;
int m_iio_device_num;
bool m_mount_matrix_exist; // is mount matrix exist
- float m_mount_matrix[9]; // mount matrix
- float m_scale; // accelerometer data scale
+ float m_mount_matrix[9]; // mount matrix
+ float m_scale; // accelerometer data scale
};
}
diff --git a/peripheral/libupm/src/kxcjk1013/pyupm_kxcjk1013.i b/peripheral/libupm/src/kxcjk1013/pyupm_kxcjk1013.i
index 05b03e6..87b8d77 100644
--- a/peripheral/libupm/src/kxcjk1013/pyupm_kxcjk1013.i
+++ b/peripheral/libupm/src/kxcjk1013/pyupm_kxcjk1013.i
@@ -3,7 +3,7 @@
%feature("autodoc", "3");
-%include "kxcjk1013.hpp"
+%include "kxcjk1013.h"
%{
- #include "kxcjk1013.hpp"
+ #include "kxcjk1013.h"
%}
diff --git a/peripheral/libupm/src/l298/CMakeLists.txt b/peripheral/libupm/src/l298/CMakeLists.txt
index 21e27bf..e42e3b5 100644
--- a/peripheral/libupm/src/l298/CMakeLists.txt
+++ b/peripheral/libupm/src/l298/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "l298")
set (libdescription "upm l298 dual h-bridge")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/l298/javaupm_l298.i b/peripheral/libupm/src/l298/javaupm_l298.i
index af7fc45..8a9355e 100644
--- a/peripheral/libupm/src/l298/javaupm_l298.i
+++ b/peripheral/libupm/src/l298/javaupm_l298.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "l298.hpp"
+ #include "l298.h"
%}
-%include "l298.hpp"
+%include "l298.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/l298/jsupm_l298.i b/peripheral/libupm/src/l298/jsupm_l298.i
index 0d779c2..7fec3a0 100644
--- a/peripheral/libupm/src/l298/jsupm_l298.i
+++ b/peripheral/libupm/src/l298/jsupm_l298.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "l298.hpp"
+ #include "l298.h"
%}
-%include "l298.hpp"
+%include "l298.h"
diff --git a/peripheral/libupm/src/l298/l298.cxx b/peripheral/libupm/src/l298/l298.cxx
index 75d7587..00c08ec 100644
--- a/peripheral/libupm/src/l298/l298.cxx
+++ b/peripheral/libupm/src/l298/l298.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "l298.hpp"
+#include "l298.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/l298/l298.hpp b/peripheral/libupm/src/l298/l298.h
index 985a07c..985a07c 100644
--- a/peripheral/libupm/src/l298/l298.hpp
+++ b/peripheral/libupm/src/l298/l298.h
diff --git a/peripheral/libupm/src/l298/pyupm_l298.i b/peripheral/libupm/src/l298/pyupm_l298.i
index b26d936..c8aaa5f 100644
--- a/peripheral/libupm/src/l298/pyupm_l298.i
+++ b/peripheral/libupm/src/l298/pyupm_l298.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "l298.hpp"
+%include "l298.h"
%{
- #include "l298.hpp"
+ #include "l298.h"
%}
diff --git a/peripheral/libupm/src/l3gd20/CMakeLists.txt b/peripheral/libupm/src/l3gd20/CMakeLists.txt
deleted file mode 100644
index 8c0fe93..0000000
--- a/peripheral/libupm/src/l3gd20/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set (libname "l3gd20")
-set (libdescription "upm l3gd20 sensor module")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/l3gd20/jsupm_l3gd20.i b/peripheral/libupm/src/l3gd20/jsupm_l3gd20.i
deleted file mode 100644
index 49ff312..0000000
--- a/peripheral/libupm/src/l3gd20/jsupm_l3gd20.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module jsupm_l3gd20
-%include "../upm.i"
-
-%{
- #include "l3gd20.hpp"
-%}
-
-%include "l3gd20.hpp"
diff --git a/peripheral/libupm/src/l3gd20/l3gd20.cxx b/peripheral/libupm/src/l3gd20/l3gd20.cxx
deleted file mode 100755
index 6675be2..0000000
--- a/peripheral/libupm/src/l3gd20/l3gd20.cxx
+++ /dev/null
@@ -1,458 +0,0 @@
-/*
- * Author: Lay, Kuan Loon <kuan.loon.lay@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-#include <string>
-#include <stdexcept>
-#include <string.h>
-#include <math.h>
-#include "l3gd20.hpp"
-
-#define NUMBER_OF_BITS_IN_BYTE 8
-#define GYRO_MIN_SAMPLES 5 /* Drop first few gyro samples after enable */
-#define GYRO_MAX_ERR 0.05
-#define GYRO_DS_SIZE 100
-
-#define GYRO_DENOISE_MAX_SAMPLES 5
-#define GYRO_DENOISE_NUM_FIELDS 3
-
-using namespace upm;
-
-L3GD20::L3GD20(int device)
-{
- float gyro_scale;
- char trigger[64];
-
- if (!(m_iio = mraa_iio_init(device))) {
- throw std::invalid_argument(std::string(__FUNCTION__) +
- ": mraa_iio_init() failed, invalid device?");
- return;
- }
- m_scale = 1;
- m_iio_device_num = device;
- sprintf(trigger, "hrtimer-l3gd20-hr-dev%d", device);
-
- if (mraa_iio_create_trigger(m_iio, trigger) != MRAA_SUCCESS)
- fprintf(stderr, "Create trigger %s failed\n", trigger);
-
- if (mraa_iio_get_mount_matrix(m_iio, "in_mount_matrix", m_mount_matrix) == MRAA_SUCCESS)
- m_mount_matrix_exist = true;
- else
- m_mount_matrix_exist = false;
-
- if (mraa_iio_read_float(m_iio, "in_anglvel_x_scale", &gyro_scale) == MRAA_SUCCESS)
- m_scale = gyro_scale;
-
- m_event_count = 0;
-
- // initial calibrate data
- initCalibrate();
-
- // initial denoise data
- m_filter.buff =
- (float*) calloc(GYRO_DENOISE_MAX_SAMPLES, sizeof(float) * GYRO_DENOISE_NUM_FIELDS);
- if (m_filter.buff == NULL) {
- throw std::invalid_argument(std::string(__FUNCTION__) +
- ": mraa_iio_init() failed, calloc denoise data");
- return;
- }
- m_filter.sample_size = GYRO_DENOISE_MAX_SAMPLES;
- m_filter.count = 0;
- m_filter.idx = 0;
-}
-
-L3GD20::~L3GD20()
-{
- if (m_filter.buff) {
- free(m_filter.buff);
- m_filter.buff = NULL;
- }
- if (m_iio)
- mraa_iio_close(m_iio);
-}
-
-void
-L3GD20::installISR(void (*isr)(char*), void* arg)
-{
- mraa_iio_trigger_buffer(m_iio, isr, NULL);
-}
-
-int64_t
-L3GD20::getChannelValue(unsigned char* input, mraa_iio_channel* chan)
-{
- uint64_t u64 = 0;
- int i;
- int storagebits = chan->bytes * NUMBER_OF_BITS_IN_BYTE;
- int realbits = chan->bits_used;
- int zeroed_bits = storagebits - realbits;
- uint64_t sign_mask;
- uint64_t value_mask;
-
- if (!chan->lendian)
- for (i = 0; i < storagebits / NUMBER_OF_BITS_IN_BYTE; i++)
- u64 = (u64 << 8) | input[i];
- else
- for (i = storagebits / NUMBER_OF_BITS_IN_BYTE - 1; i >= 0; i--)
- u64 = (u64 << 8) | input[i];
-
- u64 = (u64 >> chan->shift) & (~0ULL >> zeroed_bits);
-
- if (!chan->signedd)
- return (int64_t) u64; /* We don't handle unsigned 64 bits int */
-
- /* Signed integer */
-
- switch (realbits) {
- case 0 ... 1:
- return 0;
-
- case 8:
- return (int64_t)(int8_t) u64;
-
- case 16:
- return (int64_t)(int16_t) u64;
-
- case 32:
- return (int64_t)(int32_t) u64;
-
- case 64:
- return (int64_t) u64;
-
- default:
- sign_mask = 1 << (realbits - 1);
- value_mask = sign_mask - 1;
-
- if (u64 & sign_mask)
- return -((~u64 & value_mask) + 1); /* Negative value: return 2-complement */
- else
- return (int64_t) u64; /* Positive value */
- }
-}
-
-bool
-L3GD20::enableBuffer(int length)
-{
- mraa_iio_write_int(m_iio, "buffer/length", length);
- // enable must be last step, else will have error in writing above config
- mraa_iio_write_int(m_iio, "buffer/enable", 1);
- return true;
-}
-
-bool
-L3GD20::disableBuffer()
-{
- mraa_iio_write_int(m_iio, "buffer/enable", 0);
- return true;
-}
-
-bool
-L3GD20::setScale(float scale)
-{
- m_scale = scale;
-
- mraa_iio_write_float(m_iio, "in_anglvel_x_scale", scale);
- mraa_iio_write_float(m_iio, "in_anglvel_y_scale", scale);
- mraa_iio_write_float(m_iio, "in_anglvel_z_scale", scale);
- return true;
-}
-
-bool
-L3GD20::setSamplingFrequency(float sampling_frequency)
-{
- mraa_iio_write_float(m_iio, "sampling_frequency", sampling_frequency);
- return true;
-}
-
-bool
-L3GD20::enable3AxisChannel()
-{
- char trigger[64];
- sprintf(trigger, "l3gd20-hr-dev%d", m_iio_device_num);
-
- mraa_iio_write_string(m_iio, "trigger/current_trigger", trigger);
- mraa_iio_write_int(m_iio, "scan_elements/in_anglvel_x_en", 1);
- mraa_iio_write_int(m_iio, "scan_elements/in_anglvel_y_en", 1);
- mraa_iio_write_int(m_iio, "scan_elements/in_anglvel_z_en", 1);
-
- // need update channel data size after enable
- mraa_iio_update_channels(m_iio);
- return true;
-}
-
-bool
-L3GD20::extract3Axis(char* data, float* x, float* y, float* z)
-{
- mraa_iio_channel* channels = mraa_iio_get_channels(m_iio);
- float tmp[3];
- int iio_x, iio_y, iio_z;
-
- m_event_count++;
-
- if (m_event_count < GYRO_MIN_SAMPLES) {
- /* drop the sample */
- return false;
- }
-
- iio_x = getChannelValue((unsigned char*) (data + channels[0].location), &channels[0]);
- iio_y = getChannelValue((unsigned char*) (data + channels[1].location), &channels[1]);
- iio_z = getChannelValue((unsigned char*) (data + channels[2].location), &channels[2]);
-
- // Raw data is x, y, z axis angular velocity. Units after application of scale are radians per
- // second
- *x = (iio_x * m_scale);
- *y = (iio_y * m_scale);
- *z = (iio_z * m_scale);
-
- if (m_mount_matrix_exist) {
- tmp[0] = *x * m_mount_matrix[0] + *y * m_mount_matrix[1] + *z * m_mount_matrix[2];
- tmp[1] = *x * m_mount_matrix[3] + *y * m_mount_matrix[4] + *z * m_mount_matrix[5];
- tmp[2] = *x * m_mount_matrix[6] + *y * m_mount_matrix[7] + *z * m_mount_matrix[8];
-
- *x = tmp[0];
- *y = tmp[1];
- *z = tmp[2];
- }
-
- /* Attempt gyroscope calibration if we have not reached this state */
- if (m_calibrated == false)
- m_calibrated = gyroCollect(*x, *y, *z);
-
- *x = *x - m_cal_data.bias_x;
- *y = *y - m_cal_data.bias_y;
- *z = *z - m_cal_data.bias_z;
-
-
- gyroDenoiseMedian(x, y, z);
- clampGyroReadingsToZero(x, y, z);
-
- return true;
-}
-
-void
-L3GD20::initCalibrate()
-{
- m_calibrated = false;
- m_cal_data.count = 0;
- m_cal_data.bias_x = m_cal_data.bias_y = m_cal_data.bias_z = 0;
- m_cal_data.min_x = m_cal_data.min_y = m_cal_data.min_z = 1.0;
- m_cal_data.max_x = m_cal_data.max_y = m_cal_data.max_z = -1.0;
-}
-
-bool
-L3GD20::getCalibratedStatus()
-{
- return m_calibrated;
-}
-
-void
-L3GD20::getCalibratedData(float* bias_x, float* bias_y, float* bias_z)
-{
- *bias_x = m_cal_data.bias_x;
- *bias_y = m_cal_data.bias_y;
- *bias_z = m_cal_data.bias_z;
-}
-
-void
-L3GD20::loadCalibratedData(float bias_x, float bias_y, float bias_z)
-{
- m_calibrated = true;
- m_cal_data.bias_x = bias_x;
- m_cal_data.bias_y = bias_y;
- m_cal_data.bias_z = bias_z;
-}
-
-bool
-L3GD20::gyroCollect(float x, float y, float z)
-{
- /* Analyze gyroscope data */
-
- if (fabs(x) >= 1 || fabs(y) >= 1 || fabs(z) >= 1) {
- /* We're supposed to be standing still ; start over */
- m_cal_data.count = 0;
- m_cal_data.bias_x = m_cal_data.bias_y = m_cal_data.bias_z = 0;
- m_cal_data.min_x = m_cal_data.min_y = m_cal_data.min_z = 1.0;
- m_cal_data.max_x = m_cal_data.max_y = m_cal_data.max_z = -1.0;
-
- return false; /* Uncalibrated */
- }
-
- /* Thanks to https://github.com/01org/android-iio-sensors-hal for calibration algorithm */
- if (m_cal_data.count < GYRO_DS_SIZE) {
- if (x < m_cal_data.min_x)
- m_cal_data.min_x = x;
-
- if (y < m_cal_data.min_y)
- m_cal_data.min_y = y;
-
- if (z < m_cal_data.min_z)
- m_cal_data.min_z = z;
-
- if (x > m_cal_data.max_x)
- m_cal_data.max_x = x;
-
- if (y > m_cal_data.max_y)
- m_cal_data.max_y = y;
-
- if (z > m_cal_data.max_z)
- m_cal_data.max_z = z;
-
- if (fabs(m_cal_data.max_x - m_cal_data.min_x) <= GYRO_MAX_ERR &&
- fabs(m_cal_data.max_y - m_cal_data.min_y) <= GYRO_MAX_ERR &&
- fabs(m_cal_data.max_z - m_cal_data.min_z) <= GYRO_MAX_ERR)
- m_cal_data.count++; /* One more conformant sample */
- else {
- /* Out of spec sample ; start over */
- m_calibrated = false;
- m_cal_data.count = 0;
- m_cal_data.bias_x = m_cal_data.bias_y = m_cal_data.bias_z = 0;
- m_cal_data.min_x = m_cal_data.min_y = m_cal_data.min_z = 1.0;
- m_cal_data.max_x = m_cal_data.max_y = m_cal_data.max_z = -1.0;
- }
-
- return false; /* Still uncalibrated */
- }
-
- /* We got enough stable samples to estimate gyroscope bias */
- m_cal_data.bias_x = (m_cal_data.max_x + m_cal_data.min_x) / 2;
- m_cal_data.bias_y = (m_cal_data.max_y + m_cal_data.min_y) / 2;
- m_cal_data.bias_z = (m_cal_data.max_z + m_cal_data.min_z) / 2;
-
- return true; /* Calibrated! */
-}
-
-void
-L3GD20::gyroDenoiseMedian(float* x, float* y, float* z)
-{
- /* Thanks to https://github.com/01org/android-iio-sensors-hal for denoise algorithm */
- unsigned int offset;
-
- /* If we are at event count 1 reset the indices */
- if (m_event_count == 1) {
- m_filter.count = 0;
- m_filter.idx = 0;
- }
-
- if (m_filter.count < m_filter.sample_size)
- m_filter.count++;
-
- offset = 0;
- m_filter.buff[offset + m_filter.idx] = *x;
- *x = median(m_filter.buff + offset, m_filter.count);
-
- offset = m_filter.sample_size * 1;
- m_filter.buff[offset + m_filter.idx] = *y;
- *y = median(m_filter.buff + offset, m_filter.count);
-
- offset = m_filter.sample_size * 2;
- m_filter.buff[offset + m_filter.idx] = *z;
- *z = median(m_filter.buff + offset, m_filter.count);
-
- m_filter.idx = (m_filter.idx + 1) % m_filter.sample_size;
-}
-
-float
-L3GD20::median(float* queue, unsigned int size)
-{
- /* http://en.wikipedia.org/wiki/Quickselect */
-
- unsigned int left = 0;
- unsigned int right = size - 1;
- unsigned int pivot_index;
- unsigned int median_index = (right / 2);
- float temp[size];
-
- memcpy(temp, queue, size * sizeof(float));
-
- /* If the list has only one element return it */
- if (left == right)
- return temp[left];
-
- while (left < right) {
- pivot_index = (left + right) / 2;
- pivot_index = partition(temp, left, right, pivot_index);
- if (pivot_index == median_index)
- return temp[median_index];
- else if (pivot_index > median_index)
- right = pivot_index - 1;
- else
- left = pivot_index + 1;
- }
-
- return temp[left];
-}
-
-unsigned int
-L3GD20::partition(float* list, unsigned int left, unsigned int right, unsigned int pivot_index)
-{
- unsigned int i;
- unsigned int store_index = left;
- float aux;
- float pivot_value = list[pivot_index];
-
- /* Swap list[pivotIndex] and list[right] */
- aux = list[pivot_index];
- list[pivot_index] = list[right];
- list[right] = aux;
-
- for (i = left; i < right; i++) {
- if (list[i] < pivot_value) {
- /* Swap list[store_index] and list[i] */
- aux = list[store_index];
- list[store_index] = list[i];
- list[i] = aux;
- store_index++;
- }
- }
-
- /* Swap list[right] and list[store_index] */
- aux = list[right];
- list[right] = list[store_index];
- list[store_index] = aux;
- return store_index;
-}
-
-void
-L3GD20::clampGyroReadingsToZero(float* x, float* y, float* z)
-{
- float near_zero;
-
- /* If we're calibrated, don't filter out as much */
- if (m_calibrated)
- near_zero = 0.02; /* rad/s */
- else
- near_zero = 0.1;
-
- /* If motion on all axes is small enough */
- if (fabs(*x) < near_zero && fabs(*y) < near_zero && fabs(*z) < near_zero) {
- /*
- * Report that we're not moving at all... but not exactly zero as composite sensors
- * (orientation, rotation vector) don't
- * seem to react very well to it.
- */
-
- *x *= 0.000001;
- *y *= 0.000001;
- *z *= 0.000001;
- }
-}
diff --git a/peripheral/libupm/src/l3gd20/l3gd20.hpp b/peripheral/libupm/src/l3gd20/l3gd20.hpp
deleted file mode 100644
index 9cffeb8..0000000
--- a/peripheral/libupm/src/l3gd20/l3gd20.hpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Author: Lay, Kuan Loon <kuan.loon.lay@intel.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * Thanks to https://github.com/01org/android-iio-sensors-hal for gyroscope
- * calibration and denoise algorithm.
- */
-#pragma once
-
-#include <string>
-#include <mraa/iio.h>
-
-namespace upm
-{
-/**
- * @brief L3GD20 Tri-axis Digital Gyroscope
- * @defgroup l3gd20 libupm-l3gd20
- * @ingroup STMicroelectronics iio i2c tri-axis digital gyroscope
- */
-
-/**
- * @library l3gd20
- * @sensor l3gd20
- * @comname L3GD20 Tri-axis Digital Gyroscope
- * @type gyroscope
- * @man STMicroelectronics
- * @con iio i2c
- *
- * @brief L3GD20 Tri-axis Digital Gyroscope API
- *
- * The L3GD20 The L3GD20 is a low-power three-axis angular rate sensor.
- *
- * @snippet l3gd20.cxx Interesting
- */
-
-class L3GD20
-{
- public:
- typedef struct {
- float bias_x, bias_y, bias_z;
- int count;
- float min_x, min_y, min_z;
- float max_x, max_y, max_z;
- } gyro_cal_t;
-
- typedef struct {
- float* buff;
- unsigned int idx;
- unsigned int count;
- unsigned int sample_size;
- } filter_median_t;
- /**
- * L3GD20 Tri-axis Digital Gyroscope
- *
- * @param iio device number
- */
- L3GD20(int device);
-
- /**
- * L3GD20 destructor
- */
- ~L3GD20();
-
- /**
- * Installs an interrupt service routine (ISR) to be called when
- * an interrupt occurs
- *
- * @param interrupt channel
- * @param fptr Pointer to a function to be called on interrupt
- * @param arg Pointer to an object to be supplied as an
- * argument to the ISR.
- */
- void installISR(void (*isr)(char*), void* arg);
-
- /**
- * Extract the channel value based on channel type
- * @param input Channel data
- * @param chan MRAA iio-layer channel info
- */
- int64_t getChannelValue(unsigned char* input, mraa_iio_channel* chan);
-
- /**
- * Enable trigger buffer
- * @param trigger buffer length in integer
- */
- bool enableBuffer(int length);
-
- /**
- * Disable trigger buffer
- */
- bool disableBuffer();
-
- /**
- * Set scale
- * @param scale in float
- * Available scales are 0.000153(250dps), 0.000305(500dps), and 0.001222(2000dps)
- * Default scale is 0.000153
- */
- bool setScale(const float scale);
-
- /**
- * Set sampling frequency
- * @param sampling frequency in float
- * Available sampling frequency are 95, 190, 380, and 760
- * Default sampling frequency is 95
- */
- bool setSamplingFrequency(const float sampling_frequency);
-
- /**
- * Enable 3 axis scan element
- */
- bool enable3AxisChannel();
-
- /**
- * Process enabled channel buffer and return x, y, z axis
- * @param data Enabled channel data, 6 bytes, each axis 2 bytes
- * @param x X-Axis
- * @param y Y-Axis
- * @param z Z-Axis
- */
- bool extract3Axis(char* data, float* x, float* y, float* z);
-
- /**
- * Reset calibration data and start collect calibration data again
- */
- void initCalibrate();
-
- /**
- * Get calibrated status, return true if calibrate successfully
- */
- bool getCalibratedStatus();
-
- /**
- * Get calibrated data
- */
- void getCalibratedData(float* bias_x, float* bias_y, float* bias_z);
-
- /**
- * Load calibrated data
- */
- void loadCalibratedData(float bias_x, float bias_y, float bias_z);
-
- /**
- * Calibrate gyro
- * @param x X-Axis
- * @param y Y-Axis
- * @param z Z-Axis
- */
- bool gyroCollect(float x, float y, float z);
-
- /**
- * Denoise gyro
- * @param x X-Axis
- * @param y Y-Axis
- * @param z Z-Axis
- */
- void gyroDenoiseMedian(float* x, float* y, float* z);
-
- /**
- * median algorithm
- * @param queue
- * @param size
- */
- float median(float* queue, unsigned int size);
-
- /**
- * partition algorithm
- * @param list
- * @param left
- * @param right
- * @param pivot_index
- */
- unsigned int
- partition(float* list, unsigned int left, unsigned int right, unsigned int pivot_index);
-
- /**
- * Clamp Gyro Readings to Zero
- * @param x X-Axis
- * @param y Y-Axis
- * @param z Z-Axis
- */
- void clampGyroReadingsToZero(float* x, float* y, float* z);
-
- private:
- mraa_iio_context m_iio;
- int m_iio_device_num;
- bool m_mount_matrix_exist; // is mount matrix exist
- float m_mount_matrix[9]; // mount matrix
- float m_scale; // gyroscope data scale
- int m_event_count; // sample data arrive
- bool m_calibrated; // calibrate state
- gyro_cal_t m_cal_data; // calibrate data
- filter_median_t m_filter; // filter data
-};
-}
diff --git a/peripheral/libupm/src/l3gd20/pyupm_l3gd20.i b/peripheral/libupm/src/l3gd20/pyupm_l3gd20.i
deleted file mode 100644
index a66a85b..0000000
--- a/peripheral/libupm/src/l3gd20/pyupm_l3gd20.i
+++ /dev/null
@@ -1,9 +0,0 @@
-%module pyupm_l3gd20
-%include "../upm.i"
-
-%feature("autodoc", "3");
-
-%include "l3gd20.hpp"
-%{
- #include "l3gd20.hpp"
-%}
diff --git a/peripheral/libupm/src/lcd/CMakeLists.txt b/peripheral/libupm/src/lcd/CMakeLists.txt
index 26be0cb..c21ea8a 100755
--- a/peripheral/libupm/src/lcd/CMakeLists.txt
+++ b/peripheral/libupm/src/lcd/CMakeLists.txt
@@ -2,5 +2,5 @@ set (libname "i2clcd")
set (classname "lcd")
set (libdescription "upm lcd/oled displays")
set (module_src lcd.cxx lcm1602.cxx jhd1313m1.cxx ssd1308.cxx eboled.cxx ssd1327.cxx sainsmartks.cxx ssd1306.cxx)
-set (module_hpp lcd.hpp lcm1602.hpp jhd1313m1.hpp ssd1308.hpp eboled.hpp ssd1327.hpp ssd.hpp sainsmartks.hpp ssd1306.hpp)
+set (module_h lcd.h lcm1602.h jhd1313m1.h ssd1308.h eboled.h ssd1327.h ssd.h sainsmartks.h ssd1306.h)
upm_module_init()
diff --git a/peripheral/libupm/src/lcd/eboled.cxx b/peripheral/libupm/src/lcd/eboled.cxx
index cf56147..295591f 100644
--- a/peripheral/libupm/src/lcd/eboled.cxx
+++ b/peripheral/libupm/src/lcd/eboled.cxx
@@ -27,7 +27,7 @@
#include <unistd.h>
#include <iostream>
-#include "eboled.hpp"
+#include "eboled.h"
using namespace upm;
using namespace std;
@@ -556,7 +556,7 @@ mraa::Result EBOLED::command(uint8_t cmd)
mraa::Result EBOLED::data(uint16_t data)
{
- m_spi.writeWord(data);
+ m_spi.write_word(data);
return mraa::SUCCESS;
}
diff --git a/peripheral/libupm/src/lcd/eboled.hpp b/peripheral/libupm/src/lcd/eboled.h
index a25b063..bd6f3d0 100644
--- a/peripheral/libupm/src/lcd/eboled.hpp
+++ b/peripheral/libupm/src/lcd/eboled.h
@@ -34,8 +34,8 @@
#include <mraa/gpio.hpp>
-#include "lcd.hpp"
-#include "ssd.hpp"
+#include "lcd.h"
+#include "ssd.h"
#define EBOLED_DEFAULT_SPI_BUS 0
#define EBOLED_DEFAULT_CD 36
diff --git a/peripheral/libupm/src/lcd/hd44780_bits.hpp b/peripheral/libupm/src/lcd/hd44780_bits.h
index e3f60c4..e3f60c4 100644
--- a/peripheral/libupm/src/lcd/hd44780_bits.hpp
+++ b/peripheral/libupm/src/lcd/hd44780_bits.h
diff --git a/peripheral/libupm/src/lcd/javaupm_i2clcd.i b/peripheral/libupm/src/lcd/javaupm_i2clcd.i
index 2bf10d4..4705025 100644
--- a/peripheral/libupm/src/lcd/javaupm_i2clcd.i
+++ b/peripheral/libupm/src/lcd/javaupm_i2clcd.i
@@ -23,26 +23,26 @@
}
%{
- #include "lcd.hpp"
- #include "ssd.hpp"
- #include "ssd1327.hpp"
- #include "ssd1308.hpp"
- #include "ssd1306.hpp"
- #include "eboled.hpp"
- #include "lcm1602.hpp"
- #include "jhd1313m1.hpp"
- #include "sainsmartks.hpp"
+ #include "lcd.h"
+ #include "ssd.h"
+ #include "ssd1327.h"
+ #include "ssd1308.h"
+ #include "ssd1306.h"
+ #include "eboled.h"
+ #include "lcm1602.h"
+ #include "jhd1313m1.h"
+ #include "sainsmartks.h"
%}
-%include "lcd.hpp"
-%include "ssd.hpp"
-%include "ssd1327.hpp"
-%include "ssd1308.hpp"
-%include "ssd1306.hpp"
-%include "eboled.hpp"
-%include "lcm1602.hpp"
-%include "jhd1313m1.hpp"
-%include "sainsmartks.hpp"
+%include "lcd.h"
+%include "ssd.h"
+%include "ssd1327.h"
+%include "ssd1308.h"
+%include "ssd1306.h"
+%include "eboled.h"
+%include "lcm1602.h"
+%include "jhd1313m1.h"
+%include "sainsmartks.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/lcd/jhd1313m1.cxx b/peripheral/libupm/src/lcd/jhd1313m1.cxx
index c161f34..d1afc92 100644
--- a/peripheral/libupm/src/lcd/jhd1313m1.cxx
+++ b/peripheral/libupm/src/lcd/jhd1313m1.cxx
@@ -28,9 +28,9 @@
#include <stdexcept>
#include <unistd.h>
-#include "lcd_private.hpp"
-#include "hd44780_bits.hpp"
-#include "jhd1313m1.hpp"
+#include "lcd_private.h"
+#include "hd44780_bits.h"
+#include "jhd1313m1.h"
using namespace upm;
@@ -46,23 +46,13 @@ Jhd1313m1::Jhd1313m1(int bus, int lcdAddress, int rgbAddress)
": I2c.address() failed");
}
- /* HD44780 requires writing three times to initialize or reset
- according to the hardware errata on page 45 figure 23 of
- the Hitachi HD44780 datasheet */
- /* First try */
usleep(50000);
- ret = command(LCD_FUNCTIONSET | LCD_8BITMODE);
- /* Second try */
- usleep(4500);
- ret = command(LCD_FUNCTIONSET | LCD_8BITMODE);
- /* Third try */
- usleep(150);
- ret = command(LCD_FUNCTIONSET | LCD_8BITMODE);
- UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller");
+ ret = command(LCD_FUNCTIONSET | LCD_2LINE);
- /* Set 2 row mode and font size */
- ret = command(LCD_FUNCTIONSET | LCD_8BITMODE | LCD_2LINE | LCD_5x10DOTS);
- UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller");
+ if (!ret) {
+ ret = command(LCD_FUNCTIONSET | LCD_2LINE);
+ UPM_CHECK_MRAA_SUCCESS(ret, "Unable to initialise the LCD controller");
+ }
usleep(100);
ret = displayOn();
diff --git a/peripheral/libupm/src/lcd/jhd1313m1.hpp b/peripheral/libupm/src/lcd/jhd1313m1.h
index 0009d13..e13b646 100644
--- a/peripheral/libupm/src/lcd/jhd1313m1.hpp
+++ b/peripheral/libupm/src/lcd/jhd1313m1.h
@@ -26,7 +26,7 @@
#pragma once
#include <string>
-#include "lcm1602.hpp"
+#include "lcm1602.h"
namespace upm
{
diff --git a/peripheral/libupm/src/lcd/jsupm_i2clcd.i b/peripheral/libupm/src/lcd/jsupm_i2clcd.i
index 3999a90..fe106b7 100755
--- a/peripheral/libupm/src/lcd/jsupm_i2clcd.i
+++ b/peripheral/libupm/src/lcd/jsupm_i2clcd.i
@@ -2,43 +2,43 @@
%include "../upm.i"
%include "../carrays_uint8_t.i"
-%include "ssd.hpp"
-%include "lcd.hpp"
+%include "ssd.h"
+%include "lcd.h"
%{
- #include "lcd.hpp"
+ #include "lcd.h"
%}
-%include "lcm1602.hpp"
+%include "lcm1602.h"
%{
- #include "lcm1602.hpp"
+ #include "lcm1602.h"
%}
-%include "jhd1313m1.hpp"
+%include "jhd1313m1.h"
%{
- #include "jhd1313m1.hpp"
+ #include "jhd1313m1.h"
%}
-%include "ssd1327.hpp"
+%include "ssd1327.h"
%{
- #include "ssd1327.hpp"
+ #include "ssd1327.h"
%}
-%include "ssd1308.hpp"
+%include "ssd1308.h"
%{
- #include "ssd1308.hpp"
+ #include "ssd1308.h"
%}
-%include "eboled.hpp"
+%include "eboled.h"
%{
- #include "eboled.hpp"
+ #include "eboled.h"
%}
-%include "sainsmartks.hpp"
+%include "sainsmartks.h"
%{
- #include "sainsmartks.hpp"
+ #include "sainsmartks.h"
%}
-%include "ssd1306.hpp"
+%include "ssd1306.h"
%{
- #include "ssd1306.hpp"
+ #include "ssd1306.h"
%}
diff --git a/peripheral/libupm/src/lcd/lcd.cxx b/peripheral/libupm/src/lcd/lcd.cxx
index 21b3a12..af3d082 100644
--- a/peripheral/libupm/src/lcd/lcd.cxx
+++ b/peripheral/libupm/src/lcd/lcd.cxx
@@ -25,7 +25,7 @@
#include <iostream>
#include <unistd.h>
-#include "lcd.hpp"
+#include "lcd.h"
using namespace upm;
diff --git a/peripheral/libupm/src/lcd/lcd.hpp b/peripheral/libupm/src/lcd/lcd.h
index a4f48e8..a4f48e8 100644
--- a/peripheral/libupm/src/lcd/lcd.hpp
+++ b/peripheral/libupm/src/lcd/lcd.h
diff --git a/peripheral/libupm/src/lcd/lcd_private.hpp b/peripheral/libupm/src/lcd/lcd_private.h
index b09ae5b..b09ae5b 100644
--- a/peripheral/libupm/src/lcd/lcd_private.hpp
+++ b/peripheral/libupm/src/lcd/lcd_private.h
diff --git a/peripheral/libupm/src/lcd/lcm1602.cxx b/peripheral/libupm/src/lcd/lcm1602.cxx
index e39d593..38f0c87 100644
--- a/peripheral/libupm/src/lcd/lcm1602.cxx
+++ b/peripheral/libupm/src/lcd/lcm1602.cxx
@@ -35,8 +35,8 @@
#include <stdexcept>
#include <unistd.h>
-#include "hd44780_bits.hpp"
-#include "lcm1602.hpp"
+#include "hd44780_bits.h"
+#include "lcm1602.h"
using namespace upm;
@@ -50,7 +50,6 @@ Lcm1602::Lcm1602(int bus_in, int addr_in, bool isExpander,
mraa::Result error = mraa::SUCCESS;
m_name = "Lcm1602 (I2C)";
m_isI2C = true;
- m_backlight = LCD_BACKLIGHT;
m_lcd_control_address = addr_in;
@@ -74,7 +73,7 @@ Lcm1602::Lcm1602(int bus_in, int addr_in, bool isExpander,
return;
usleep(50000);
- backlightOn();
+ expandWrite(LCD_BACKLIGHT);
usleep(100000);
write4bits(0x03 << 4);
@@ -112,7 +111,6 @@ Lcm1602::Lcm1602(uint8_t rs, uint8_t enable, uint8_t d0,
mraa::Result error = mraa::SUCCESS;
m_name = "Lcm1602 (4-bit GPIO)";
m_isI2C = false;
- m_backlight = LCD_BACKLIGHT;
// setup our gpios
@@ -324,18 +322,6 @@ mraa::Result Lcm1602::cursorBlinkOff()
return command(LCD_DISPLAYCONTROL | m_displayControl);
}
-mraa::Result Lcm1602::backlightOn()
-{
- m_backlight = LCD_BACKLIGHT;
- return expandWrite(m_backlight);
-}
-
-mraa::Result Lcm1602::backlightOff()
-{
- m_backlight = LCD_NOBACKLIGHT;
- return expandWrite(m_backlight);
-}
-
mraa::Result Lcm1602::scrollDisplayLeft()
{
return command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT);
@@ -445,7 +431,7 @@ Lcm1602::expandWrite(uint8_t value)
if (!m_isI2C)
return mraa::ERROR_INVALID_RESOURCE;
- uint8_t buffer = value | m_backlight;
+ uint8_t buffer = value | LCD_BACKLIGHT;
return m_i2c_lcd_control->writeByte(buffer);
}
diff --git a/peripheral/libupm/src/lcd/lcm1602.hpp b/peripheral/libupm/src/lcd/lcm1602.h
index 5f37cf5..6c26082 100644
--- a/peripheral/libupm/src/lcd/lcm1602.hpp
+++ b/peripheral/libupm/src/lcd/lcm1602.h
@@ -38,7 +38,7 @@
#include <mraa/gpio.hpp>
-#include "lcd.hpp"
+#include "lcd.h"
namespace upm
{
@@ -73,15 +73,13 @@ class Lcm1602 : public LCD
/**
* Lcm1602 constructor; calls libmraa initialisation functions
*
- * @param bus I2C bus to use. Default 0 (autodetect).
- * @param address Slave address the LCD is registered on. Default 0x27
+ * @param bus I2C bus to use
+ * @param address Slave address the LCD is registered on
* @param isExpander True if we are dealing with an I2C expander,
* false otherwise. Default is true.
- * @param numColumns Number of columns the display has. Default 16.
- * @param numRows Number of rows the display has. Default 2.
*/
- Lcm1602(int bus = 0, int address = 0x27, bool isExpander=true,
- uint8_t numColumns = 16, uint8_t numRows = 2);
+ Lcm1602(int bus, int address, bool isExpander=true,
+ uint8_t numColumns = 16, uint8_t numRows = 4);
/**
* Lcm1602 alternate constructor, used for GPIO based HD44780
@@ -94,12 +92,10 @@ class Lcm1602 : public LCD
* @param d1 Data 1 pin
* @param d2 Data 2 pin
* @param d3 Data 3 pin
- * @param numColumns Number of columns the display has. Default 16.
- * @param numRows Number of rows the display has. Default 2.
*/
Lcm1602(uint8_t rs, uint8_t enable,
uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3,
- uint8_t numColumns = 16, uint8_t numRows = 2);
+ uint8_t numColumns = 16, uint8_t numRows = 4);
/**
* Lcm1602 destructor
@@ -186,20 +182,6 @@ class Lcm1602 : public LCD
mraa::Result cursorBlinkOff();
/**
- * Turn backlight on
- *
- * @return Result of operation
- */
- mraa::Result backlightOn();
-
- /**
- * Turn backlight off
- *
- * @return Result of operation
- */
- mraa::Result backlightOff();
-
- /**
* Scroll the display left, without changing the character RAM
*
* @return Result of operation
@@ -254,9 +236,6 @@ class Lcm1602 : public LCD
// Display size
uint8_t m_numColumns;
uint8_t m_numRows;
-
- // Backlight
- uint8_t m_backlight;
// Add a command() and data() virtual member functions, with a
// default implementation in lcm1602. This is expected to be
diff --git a/peripheral/libupm/src/lcd/pyupm_i2clcd.i b/peripheral/libupm/src/lcd/pyupm_i2clcd.i
index 7de2f55..04cab46 100755
--- a/peripheral/libupm/src/lcd/pyupm_i2clcd.i
+++ b/peripheral/libupm/src/lcd/pyupm_i2clcd.i
@@ -6,43 +6,43 @@
%feature("autodoc", "3");
-%include "ssd.hpp"
-%include "lcd.hpp"
+%include "ssd.h"
+%include "lcd.h"
%{
- #include "lcd.hpp"
+ #include "lcd.h"
%}
-%include "lcm1602.hpp"
+%include "lcm1602.h"
%{
- #include "lcm1602.hpp"
+ #include "lcm1602.h"
%}
-%include "jhd1313m1.hpp"
+%include "jhd1313m1.h"
%{
- #include "jhd1313m1.hpp"
+ #include "jhd1313m1.h"
%}
-%include "ssd1327.hpp"
+%include "ssd1327.h"
%{
- #include "ssd1327.hpp"
+ #include "ssd1327.h"
%}
-%include "ssd1308.hpp"
+%include "ssd1308.h"
%{
- #include "ssd1308.hpp"
+ #include "ssd1308.h"
%}
-%include "eboled.hpp"
+%include "eboled.h"
%{
- #include "eboled.hpp"
+ #include "eboled.h"
%}
-%include "sainsmartks.hpp"
+%include "sainsmartks.h"
%{
- #include "sainsmartks.hpp"
+ #include "sainsmartks.h"
%}
-%include "ssd1306.hpp"
+%include "ssd1306.h"
%{
- #include "ssd1306.hpp"
+ #include "ssd1306.h"
%}
diff --git a/peripheral/libupm/src/lcd/sainsmartks.cxx b/peripheral/libupm/src/lcd/sainsmartks.cxx
index f65311d..5c1eb99 100644
--- a/peripheral/libupm/src/lcd/sainsmartks.cxx
+++ b/peripheral/libupm/src/lcd/sainsmartks.cxx
@@ -25,7 +25,7 @@
#include <iostream>
#include <unistd.h>
-#include "sainsmartks.hpp"
+#include "sainsmartks.h"
using namespace upm;
diff --git a/peripheral/libupm/src/lcd/sainsmartks.hpp b/peripheral/libupm/src/lcd/sainsmartks.h
index f51dd2a..fa4e4cc 100644
--- a/peripheral/libupm/src/lcd/sainsmartks.hpp
+++ b/peripheral/libupm/src/lcd/sainsmartks.h
@@ -25,7 +25,7 @@
#include <string>
#include <mraa/aio.hpp>
-#include "lcm1602.hpp"
+#include "lcm1602.h"
namespace upm
{
diff --git a/peripheral/libupm/src/lcd/ssd.hpp b/peripheral/libupm/src/lcd/ssd.h
index 860bb15..860bb15 100644
--- a/peripheral/libupm/src/lcd/ssd.hpp
+++ b/peripheral/libupm/src/lcd/ssd.h
diff --git a/peripheral/libupm/src/lcd/ssd1306.cxx b/peripheral/libupm/src/lcd/ssd1306.cxx
index 834096a..29ffa7e 100644
--- a/peripheral/libupm/src/lcd/ssd1306.cxx
+++ b/peripheral/libupm/src/lcd/ssd1306.cxx
@@ -29,8 +29,8 @@
#include <string>
#include <unistd.h>
-#include "hd44780_bits.hpp"
-#include "ssd1306.hpp"
+#include "hd44780_bits.h"
+#include "ssd1306.h"
using namespace upm;
diff --git a/peripheral/libupm/src/lcd/ssd1306.hpp b/peripheral/libupm/src/lcd/ssd1306.h
index 52d226e..e1fbc46 100644
--- a/peripheral/libupm/src/lcd/ssd1306.hpp
+++ b/peripheral/libupm/src/lcd/ssd1306.h
@@ -30,8 +30,8 @@
#include <string>
#include <mraa/i2c.hpp>
-#include "lcd.hpp"
-#include "ssd.hpp"
+#include "lcd.h"
+#include "ssd.h"
namespace upm
{
diff --git a/peripheral/libupm/src/lcd/ssd1308.cxx b/peripheral/libupm/src/lcd/ssd1308.cxx
index a48a1f7..7adc830 100644
--- a/peripheral/libupm/src/lcd/ssd1308.cxx
+++ b/peripheral/libupm/src/lcd/ssd1308.cxx
@@ -26,8 +26,8 @@
#include <string>
#include <unistd.h>
-#include "hd44780_bits.hpp"
-#include "ssd1308.hpp"
+#include "hd44780_bits.h"
+#include "ssd1308.h"
using namespace upm;
diff --git a/peripheral/libupm/src/lcd/ssd1308.hpp b/peripheral/libupm/src/lcd/ssd1308.h
index 59c9da1..8fd2b35 100644
--- a/peripheral/libupm/src/lcd/ssd1308.hpp
+++ b/peripheral/libupm/src/lcd/ssd1308.h
@@ -26,8 +26,8 @@
#include <string>
#include <mraa/i2c.hpp>
-#include "lcd.hpp"
-#include "ssd.hpp"
+#include "lcd.h"
+#include "ssd.h"
namespace upm
{
diff --git a/peripheral/libupm/src/lcd/ssd1327.cxx b/peripheral/libupm/src/lcd/ssd1327.cxx
index 65c5306..28cc343 100644
--- a/peripheral/libupm/src/lcd/ssd1327.cxx
+++ b/peripheral/libupm/src/lcd/ssd1327.cxx
@@ -26,8 +26,8 @@
#include <string>
#include <unistd.h>
-#include "hd44780_bits.hpp"
-#include "ssd1327.hpp"
+#include "hd44780_bits.h"
+#include "ssd1327.h"
using namespace upm;
diff --git a/peripheral/libupm/src/lcd/ssd1327.hpp b/peripheral/libupm/src/lcd/ssd1327.h
index 4e26f4d..5785080 100644
--- a/peripheral/libupm/src/lcd/ssd1327.hpp
+++ b/peripheral/libupm/src/lcd/ssd1327.h
@@ -26,8 +26,8 @@
#include <string>
#include <mraa/i2c.hpp>
-#include "lcd.hpp"
-#include "ssd.hpp"
+#include "lcd.h"
+#include "ssd.h"
namespace upm
{
diff --git a/peripheral/libupm/src/ldt0028/CMakeLists.txt b/peripheral/libupm/src/ldt0028/CMakeLists.txt
index bae2383..e066e35 100644
--- a/peripheral/libupm/src/ldt0028/CMakeLists.txt
+++ b/peripheral/libupm/src/ldt0028/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "ldt0028")
set (libdescription "upm ldt0028")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/ldt0028/javaupm_ldt0028.i b/peripheral/libupm/src/ldt0028/javaupm_ldt0028.i
index c8a132a..6407f5f 100644
--- a/peripheral/libupm/src/ldt0028/javaupm_ldt0028.i
+++ b/peripheral/libupm/src/ldt0028/javaupm_ldt0028.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "ldt0028.hpp"
+ #include "ldt0028.h"
%}
-%include "ldt0028.hpp"
+%include "ldt0028.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/ldt0028/jsupm_ldt0028.i b/peripheral/libupm/src/ldt0028/jsupm_ldt0028.i
index 3c22594..7682fb2 100644
--- a/peripheral/libupm/src/ldt0028/jsupm_ldt0028.i
+++ b/peripheral/libupm/src/ldt0028/jsupm_ldt0028.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "ldt0028.hpp"
+ #include "ldt0028.h"
%}
-%include "ldt0028.hpp"
+%include "ldt0028.h"
diff --git a/peripheral/libupm/src/ldt0028/ldt0028.cxx b/peripheral/libupm/src/ldt0028/ldt0028.cxx
index 19e712f..c1c8445 100644
--- a/peripheral/libupm/src/ldt0028/ldt0028.cxx
+++ b/peripheral/libupm/src/ldt0028/ldt0028.cxx
@@ -25,7 +25,7 @@
#include <string>
#include <stdexcept>
-#include "ldt0028.hpp"
+#include "ldt0028.h"
using namespace upm;
diff --git a/peripheral/libupm/src/ldt0028/ldt0028.hpp b/peripheral/libupm/src/ldt0028/ldt0028.h
index 532d47f..532d47f 100644
--- a/peripheral/libupm/src/ldt0028/ldt0028.hpp
+++ b/peripheral/libupm/src/ldt0028/ldt0028.h
diff --git a/peripheral/libupm/src/ldt0028/pyupm_ldt0028.i b/peripheral/libupm/src/ldt0028/pyupm_ldt0028.i
index 1d6c942..6760eed 100644
--- a/peripheral/libupm/src/ldt0028/pyupm_ldt0028.i
+++ b/peripheral/libupm/src/ldt0028/pyupm_ldt0028.i
@@ -5,8 +5,8 @@
%feature("autodoc", "3");
-%include "ldt0028.hpp"
+%include "ldt0028.h"
%{
- #include "ldt0028.hpp"
+ #include "ldt0028.h"
%}
diff --git a/peripheral/libupm/src/lm35/CMakeLists.txt b/peripheral/libupm/src/lm35/CMakeLists.txt
index e2c15d4..54e41fa 100644
--- a/peripheral/libupm/src/lm35/CMakeLists.txt
+++ b/peripheral/libupm/src/lm35/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "lm35")
set (libdescription "upm DFRobot LM35 temperature sensor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/lm35/javaupm_lm35.i b/peripheral/libupm/src/lm35/javaupm_lm35.i
index 4274ed2..aafab80 100644
--- a/peripheral/libupm/src/lm35/javaupm_lm35.i
+++ b/peripheral/libupm/src/lm35/javaupm_lm35.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "lm35.hpp"
+ #include "lm35.h"
%}
-%include "lm35.hpp"
+%include "lm35.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/lm35/jsupm_lm35.i b/peripheral/libupm/src/lm35/jsupm_lm35.i
index 73a7af2..a0cb334 100644
--- a/peripheral/libupm/src/lm35/jsupm_lm35.i
+++ b/peripheral/libupm/src/lm35/jsupm_lm35.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "lm35.hpp"
+ #include "lm35.h"
%}
-%include "lm35.hpp"
+%include "lm35.h"
diff --git a/peripheral/libupm/src/lm35/lm35.cxx b/peripheral/libupm/src/lm35/lm35.cxx
index 03f478d..07509e8 100644
--- a/peripheral/libupm/src/lm35/lm35.cxx
+++ b/peripheral/libupm/src/lm35/lm35.cxx
@@ -23,7 +23,7 @@
*/
#include <iostream>
-#include "lm35.hpp"
+#include "lm35.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/src/lm35/lm35.hpp b/peripheral/libupm/src/lm35/lm35.h
index 2bf6fba..2bf6fba 100644
--- a/peripheral/libupm/src/lm35/lm35.hpp
+++ b/peripheral/libupm/src/lm35/lm35.h
diff --git a/peripheral/libupm/src/lm35/pyupm_lm35.i b/peripheral/libupm/src/lm35/pyupm_lm35.i
index 8e669b4..5a29a37 100644
--- a/peripheral/libupm/src/lm35/pyupm_lm35.i
+++ b/peripheral/libupm/src/lm35/pyupm_lm35.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "lm35.hpp"
+%include "lm35.h"
%{
- #include "lm35.hpp"
+ #include "lm35.h"
%}
diff --git a/peripheral/libupm/src/lol/CMakeLists.txt b/peripheral/libupm/src/lol/CMakeLists.txt
index 694e7bf..d43c02b 100644
--- a/peripheral/libupm/src/lol/CMakeLists.txt
+++ b/peripheral/libupm/src/lol/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "lol")
set (libdescription "LoL Olimex LoL rev A")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/lol/javaupm_lol.i b/peripheral/libupm/src/lol/javaupm_lol.i
index 2947ae7..6c1ceae 100644
--- a/peripheral/libupm/src/lol/javaupm_lol.i
+++ b/peripheral/libupm/src/lol/javaupm_lol.i
@@ -19,10 +19,10 @@
}
%{
- #include "lol.hpp"
+ #include "lol.h"
%}
-%include "lol.hpp"
+%include "lol.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/lol/jsupm_lol.i b/peripheral/libupm/src/lol/jsupm_lol.i
index 3280ecb..73659e8 100644
--- a/peripheral/libupm/src/lol/jsupm_lol.i
+++ b/peripheral/libupm/src/lol/jsupm_lol.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "lol.hpp"
+ #include "lol.h"
%}
-%include "lol.hpp"
+%include "lol.h"
diff --git a/peripheral/libupm/src/lol/lol.cxx b/peripheral/libupm/src/lol/lol.cxx
index e6672aa..aa712e6 100644
--- a/peripheral/libupm/src/lol/lol.cxx
+++ b/peripheral/libupm/src/lol/lol.cxx
@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <functional>
#include <string.h>
-#include "lol.hpp"
+#include "lol.h"
using namespace upm;
diff --git a/peripheral/libupm/src/lol/lol.hpp b/peripheral/libupm/src/lol/lol.h
index a1ea32c..a1ea32c 100644
--- a/peripheral/libupm/src/lol/lol.hpp
+++ b/peripheral/libupm/src/lol/lol.h
diff --git a/peripheral/libupm/src/lol/pyupm_lol.i b/peripheral/libupm/src/lol/pyupm_lol.i
index 92153e4..aedf997 100644
--- a/peripheral/libupm/src/lol/pyupm_lol.i
+++ b/peripheral/libupm/src/lol/pyupm_lol.i
@@ -7,7 +7,7 @@
%feature("autodoc", "3");
-%include "lol.hpp"
+%include "lol.h"
%{
- #include "lol.hpp"
+ #include "lol.h"
%}
diff --git a/peripheral/libupm/src/loudness/CMakeLists.txt b/peripheral/libupm/src/loudness/CMakeLists.txt
index 41fffd7..49e6af6 100644
--- a/peripheral/libupm/src/loudness/CMakeLists.txt
+++ b/peripheral/libupm/src/loudness/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "loudness")
set (libdescription "upm loudness sensors")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/loudness/javaupm_loudness.i b/peripheral/libupm/src/loudness/javaupm_loudness.i
index 91e949c..5818ee7 100644
--- a/peripheral/libupm/src/loudness/javaupm_loudness.i
+++ b/peripheral/libupm/src/loudness/javaupm_loudness.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "loudness.hpp"
+ #include "loudness.h"
%}
-%include "loudness.hpp"
+%include "loudness.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/loudness/jsupm_loudness.i b/peripheral/libupm/src/loudness/jsupm_loudness.i
index d6e8533..5a3ed4f 100644
--- a/peripheral/libupm/src/loudness/jsupm_loudness.i
+++ b/peripheral/libupm/src/loudness/jsupm_loudness.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "loudness.hpp"
+ #include "loudness.h"
%}
-%include "loudness.hpp"
+%include "loudness.h"
diff --git a/peripheral/libupm/src/loudness/loudness.cxx b/peripheral/libupm/src/loudness/loudness.cxx
index 3aa381c..d16610f 100644
--- a/peripheral/libupm/src/loudness/loudness.cxx
+++ b/peripheral/libupm/src/loudness/loudness.cxx
@@ -24,7 +24,7 @@
#include <iostream>
-#include "loudness.hpp"
+#include "loudness.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/src/loudness/loudness.hpp b/peripheral/libupm/src/loudness/loudness.h
index 526eaf2..526eaf2 100644
--- a/peripheral/libupm/src/loudness/loudness.hpp
+++ b/peripheral/libupm/src/loudness/loudness.h
diff --git a/peripheral/libupm/src/loudness/pyupm_loudness.i b/peripheral/libupm/src/loudness/pyupm_loudness.i
index 6f0a715..4fc9c8d 100644
--- a/peripheral/libupm/src/loudness/pyupm_loudness.i
+++ b/peripheral/libupm/src/loudness/pyupm_loudness.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "loudness.hpp"
+%include "loudness.h"
%{
- #include "loudness.hpp"
+ #include "loudness.h"
%}
diff --git a/peripheral/libupm/src/lp8860/CMakeLists.txt b/peripheral/libupm/src/lp8860/CMakeLists.txt
deleted file mode 100644
index c4e99fb..0000000
--- a/peripheral/libupm/src/lp8860/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-include_directories(..)
-set (libname "lp8860")
-set (libdescription “LED lighting controller”)
-set (module_src ${libname}.cxx mraa-utils.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/lp8860/javaupm_lp8860.i b/peripheral/libupm/src/lp8860/javaupm_lp8860.i
deleted file mode 100644
index 5479cbd..0000000
--- a/peripheral/libupm/src/lp8860/javaupm_lp8860.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module javaupm_lp8860
-%include "../upm.i"
-
-%{
- #include "lp8860.hpp"
-%}
-
-%include "lp8860.hpp"
diff --git a/peripheral/libupm/src/lp8860/jsupm_lp8860.i b/peripheral/libupm/src/lp8860/jsupm_lp8860.i
deleted file mode 100644
index d7c0fbc..0000000
--- a/peripheral/libupm/src/lp8860/jsupm_lp8860.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module jsupm_lp8860
-%include "../upm.i"
-
-%{
- #include "lp8860.hpp"
-%}
-
-%include "lp8860.hpp"
diff --git a/peripheral/libupm/src/lp8860/lp8860.cxx b/peripheral/libupm/src/lp8860/lp8860.cxx
deleted file mode 100644
index 97db81b..0000000
--- a/peripheral/libupm/src/lp8860/lp8860.cxx
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-#include <unistd.h>
-#include <string.h>
-#include "lp8860.hpp"
-#include "mraa-utils.hpp"
-
-// Used to prevent silent failure in mraa_i2c_write()
-// Value come from I2C_SMBUS_I2C_BLOCK_MAX in i2c driver
-#define MAX_I2C_WRITE_SIZE 32
-
-#define LP8860_I2C_ADDR 0x2D
-
-#define LP8860_DISP_CL1_BRT_MSB 0x00
-#define LP8860_DISP_CL1_BRT_LSB 0x01
-#define LP8860_DISP_CL1_CURR_MSB 0x02
-#define LP8860_DISP_CL1_CURR_LSB 0x03
-#define LP8860_CL2_BRT_MSB 0x04
-#define LP8860_CL2_BRT_LSB 0x05
-#define LP8860_CL2_CURRENT 0x06
-#define LP8860_CL3_BRT_MSB 0x07
-#define LP8860_CL3_BRT_LSB 0x08
-#define LP8860_CL3_CURRENT 0x09
-#define LP8860_CL4_BRT_MSB 0x0a
-#define LP8860_CL4_BRT_LSB 0x0b
-#define LP8860_CL4_CURRENT 0x0c
-#define LP8860_CONFIG 0x0d
-#define LP8860_STATUS 0x0e
-#define LP8860_FAULT 0x0f
-#define LP8860_LED_FAULT 0x10
-#define LP8860_FAULT_CLEAR 0x11
-#define LP8860_ID 0x12
-#define LP8860_TEMP_MSB 0x13
-#define LP8860_TEMP_LSB 0x14
-#define LP8860_DISP_LED_CURR_MSB 0x15
-#define LP8860_DISP_LED_CURR_LSB 0x16
-#define LP8860_DISP_LED_PWM_MSB 0x17
-#define LP8860_DISP_LED_PWM_LSB 0x18
-#define LP8860_EEPROM_CNTRL 0x19
-#define LP8860_EEPROM_UNLOCK 0x1a
-
-#define LP8860_EEPROM_REG_0 0x60
-#define LP8860_EEPROM_REG_1 0x61
-#define LP8860_EEPROM_REG_2 0x62
-#define LP8860_EEPROM_REG_3 0x63
-#define LP8860_EEPROM_REG_4 0x64
-#define LP8860_EEPROM_REG_5 0x65
-#define LP8860_EEPROM_REG_6 0x66
-#define LP8860_EEPROM_REG_7 0x67
-#define LP8860_EEPROM_REG_8 0x68
-#define LP8860_EEPROM_REG_9 0x69
-#define LP8860_EEPROM_REG_10 0x6a
-#define LP8860_EEPROM_REG_11 0x6b
-#define LP8860_EEPROM_REG_12 0x6c
-#define LP8860_EEPROM_REG_13 0x6d
-#define LP8860_EEPROM_REG_14 0x6e
-#define LP8860_EEPROM_REG_15 0x6f
-#define LP8860_EEPROM_REG_16 0x70
-#define LP8860_EEPROM_REG_17 0x71
-#define LP8860_EEPROM_REG_18 0x72
-#define LP8860_EEPROM_REG_19 0x73
-#define LP8860_EEPROM_REG_20 0x74
-#define LP8860_EEPROM_REG_21 0x75
-#define LP8860_EEPROM_REG_22 0x76
-#define LP8860_EEPROM_REG_23 0x77
-#define LP8860_EEPROM_REG_24 0x78
-
-#define LP8860_LOCK_EEPROM 0x00
-#define LP8860_UNLOCK_EEPROM 0x01
-#define LP8860_LOAD_EEPROM 0x01
-#define LP8860_PROGRAM_EEPROM 0x02
-#define LP8860_EEPROM_CODE_1 0x08
-#define LP8860_EEPROM_CODE_2 0xba
-#define LP8860_EEPROM_CODE_3 0xef
-
-#define LP8860_CLEAR_FAULTS 0x01
-#define LP8860_INVALID_ID 0x00
-
-using namespace upm;
-
-LP8860::LP8860(int gpioPower, int i2cBus)
-{
- status = mraa::ERROR_INVALID_RESOURCE;
- mraa_set_log_level(7);
- pinPower = gpioPower;
- i2c = new mraa::I2c(i2cBus);
- i2c->address(LP8860_I2C_ADDR);
- if (isAvailable())
- status = mraa::SUCCESS;
- if (status != mraa::SUCCESS)
- UPM_THROW("i2c config failed.");
-}
-
-LP8860::~LP8860()
-{
- delete i2c;
-}
-
-
-bool LP8860::isAvailable()
-{
- bool wasPowered = true;
-
- // Check power state
- if(!isPowered()) {
- wasPowered = false;
- MraaUtils::setGpio(pinPower, 1);
- }
-
- // Read ID register
- // mraa_i2c_address(i2c, LP8860_I2C_ADDR);
- uint8_t id = i2c->readReg(LP8860_ID);
- // Turn off to save power if not required
- if (!wasPowered)
- MraaUtils::setGpio(pinPower, 0);
-
- return id >= 0x10;
-}
-
-
-bool LP8860::isPowered()
-{
- return MraaUtils::getGpio(pinPower);
-}
-
-
-void LP8860::setPowerOn()
-{
- if (!isPowered())
- {
- MraaUtils::setGpio(pinPower, 1);
- setBrightness(0);
- loadEEPROM();
- allowMaxCurrent();
- }
-}
-
-
-void LP8860::setPowerOff()
-{
- MraaUtils::setGpio(pinPower, 0);
-}
-
-
-int LP8860::getBrightness()
-{
- uint8_t msb = i2cReadByte(LP8860_DISP_CL1_BRT_MSB);
- uint8_t lsb = i2cReadByte(LP8860_DISP_CL1_BRT_LSB);
- int percent = (100 * ((int)msb << 8 | lsb)) / 0xFFFF;
- return percent;
-}
-
-
-void LP8860::setBrightness(int dutyPercent)
-{
- int value = (0xFFFF * dutyPercent) / 100;
- int msb = value >> 8;
- int lsb = value & 0xFF;
- i2cWriteByte(LP8860_DISP_CL1_BRT_MSB, msb);
- i2cWriteByte(LP8860_DISP_CL1_BRT_LSB, lsb);
- value = (0x1FFF * dutyPercent) / 100;
- msb = value >> 8;
- lsb = value & 0xFF;
- i2cWriteByte(LP8860_CL2_BRT_MSB, msb);
- i2cWriteByte(LP8860_CL2_BRT_LSB, lsb);
- i2cWriteByte(LP8860_CL3_BRT_MSB, msb);
- i2cWriteByte(LP8860_CL3_BRT_LSB, lsb);
- i2cWriteByte(LP8860_CL4_BRT_MSB, msb);
- i2cWriteByte(LP8860_CL4_BRT_LSB, lsb);
-}
-
-
-void LP8860::loadEEPROM()
-{
- const int eepromTableSize = 0x19;
- uint8_t eepromInitTable[] = {
- 0xEF, 0xFF, 0xDC, 0xAE, 0x5F, 0xE5, 0xF2, 0x77,
- 0x77, 0x71, 0x3F, 0xB7, 0x17, 0xEF, 0xB0, 0x87,
- 0xCF, 0x72, 0xC5, 0xDE, 0x35, 0x06, 0xDE, 0xFF,
- 0x3E
- };
-
- uint8_t* buf = new unsigned char[eepromTableSize + 1];
-
- // Load EEPROM
- // printf("Loading LP8860 EEPROM\n");
- i2cWriteByte(LP8860_EEPROM_CNTRL, LP8860_LOAD_EEPROM);
- usleep(100000);
-
- // Check contents and program if not already done
- i2cReadBuffer(LP8860_EEPROM_REG_0, buf, eepromTableSize);
- if (memcmp(eepromInitTable, buf, eepromTableSize) != 0)
- {
- printf("LP8860 EEPROM not initialized - programming...\n");
- // Unlock EEPROM
- i2cWriteByte(LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_1);
- i2cWriteByte(LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_2);
- i2cWriteByte(LP8860_EEPROM_UNLOCK, LP8860_EEPROM_CODE_3);
- i2cWriteBuffer(LP8860_EEPROM_REG_0, eepromInitTable, eepromTableSize);
- i2cWriteByte(LP8860_EEPROM_CNTRL, LP8860_PROGRAM_EEPROM);
- usleep(200000);
- i2cWriteByte(LP8860_EEPROM_CNTRL, 0);
- i2cWriteByte(LP8860_EEPROM_UNLOCK, LP8860_LOCK_EEPROM);
- }
-}
-
-
-void LP8860::allowMaxCurrent()
-{
- i2cWriteByte(LP8860_DISP_CL1_CURR_MSB, 0x0F);
- i2cWriteByte(LP8860_DISP_CL1_CURR_LSB, 0xFF);
- i2cWriteByte(LP8860_CL2_CURRENT, 0xFF);
- i2cWriteByte(LP8860_CL3_CURRENT, 0xFF);
- i2cWriteByte(LP8860_CL4_CURRENT, 0xFF);
-}
-
-
-void LP8860::i2cWriteByte(int reg, int value)
-{
- i2c->address(LP8860_I2C_ADDR);
- status = i2c->writeReg(static_cast<uint8_t>(reg), static_cast<uint8_t>(value));
- if (status != mraa::SUCCESS)
- UPM_THROW("i2cWriteByte failed");
-}
-
-
-uint8_t LP8860::i2cReadByte(uint8_t reg)
-{
- uint8_t value;
- i2c->address(LP8860_I2C_ADDR);
- if (i2c->readBytesReg(reg, &value, 1) != 1)
- UPM_THROW("i2cReadByte failed");
- return value;
-}
-
-
-void LP8860::i2cWriteBuffer(int reg, uint8_t* buf, int length)
-{
- if (length <= MAX_I2C_WRITE_SIZE)
- {
- uint8_t* writeBuf = new unsigned char[length + 1];
- writeBuf[0] = reg;
- memcpy(&writeBuf[1], buf, length);
- i2c->address(LP8860_I2C_ADDR);
- status = i2c->write(writeBuf, length + 1);
- delete[] writeBuf;
- }
- else
- status = mraa::ERROR_INVALID_PARAMETER;
- if (status != mraa::SUCCESS)
- UPM_THROW("i2cWriteBuffer failed");
-}
-
-
-void LP8860::i2cReadBuffer(int reg, uint8_t* buf, int length)
-{
- i2c->address(LP8860_I2C_ADDR);
- if (i2c->readBytesReg(reg, buf, length) != length)
- UPM_THROW("i2cReadBuffer failed");
-}
-
diff --git a/peripheral/libupm/src/lp8860/lp8860.hpp b/peripheral/libupm/src/lp8860/lp8860.hpp
deleted file mode 100644
index 4b96dff..0000000
--- a/peripheral/libupm/src/lp8860/lp8860.hpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include "upm/iLightController.hpp"
-#include "mraa/i2c.hpp"
-
-namespace upm
-{
-/**
- * @brief lp8860 LED lighting controller library
- * @defgroup lp8860 libupm-lp8860
- * @ingroup ti i2c light ilightcontroller
- */
-
-/**
- * @brief API for LP8860 LED Lighting Controller
- *
- * The Texas Instrumements
- * [LP8860-Q1](http://www.ti.com/product/lp8860-q1)
- * Automotive Catalog Low-EMI, High-Performance 4-Channel LED Driver
- *
- * @library lp8860
- * @sensor lp8860
- * @comname TI LP8860 LED lighting controller
- * @altname LP8860
- * @type light
- * @man ti
- * @con i2c
- * @if ilightcontroller
- *
- */
-class LP8860 : public upm::ILightController
-{
-public:
- LP8860(int gpioPower, int i2cBus);
- ~LP8860();
- const char* getModuleName() { return "lp8860"; }
- bool isPowered();
- void setPowerOn();
- void setPowerOff();
- int getBrightness();
- void setBrightness(int dutyPercent);
-
-private:
- void i2cWriteByte(int reg, int value);
- void i2cWriteBuffer(int reg, uint8_t* buf, int length);
- uint8_t i2cReadByte(uint8_t reg);
- void i2cReadBuffer(int reg, uint8_t* buf, int length);
- void loadEEPROM();
- void allowMaxCurrent();
- bool isAvailable();
-
- mraa::Result status;
- mraa::I2c* i2c;
- int pinPower;
-};
-
-
-}
-
diff --git a/peripheral/libupm/src/lp8860/mraa-utils.cxx b/peripheral/libupm/src/lp8860/mraa-utils.cxx
deleted file mode 100644
index 528a79b..0000000
--- a/peripheral/libupm/src/lp8860/mraa-utils.cxx
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <string>
-#include "mraa-utils.hpp"
-#include "mraa/gpio.hpp"
-
- #define UPM_THROW(msg) throw std::runtime_error(std::string(__FUNCTION__) + ": " + (msg))
-
-void MraaUtils::setGpio(int pin, int level)
-{
-/*
- mraa_result_t status = MRAA_ERROR_NO_RESOURCES;
- mraa_gpio_context gpio = mraa_gpio_init(pin);
- if (gpio != NULL)
- {
- mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
- status = mraa_gpio_write(gpio, level);
- mraa_gpio_close(gpio);
- }
- return status;
-*/
- mraa::Gpio gpio(pin);
- gpio.dir(mraa::DIR_OUT);
- if (gpio.write(level) != mraa::SUCCESS)
- UPM_THROW("gpio write failed");
-}
-
-
-int MraaUtils::getGpio(int pin)
-{
-/*
- mraa_result_t status = MRAA_ERROR_NO_RESOURCES;
- mraa_gpio_context gpio = mraa_gpio_init(pin);
- if (gpio != NULL)
- {
- status = mraa_gpio_dir(gpio, MRAA_GPIO_IN);
- int value = mraa_gpio_read(gpio);
- if (value != -1)
- *level = value;
- else
- status = MRAA_ERROR_NO_RESOURCES;
- mraa_gpio_close(gpio);
- }
- return status;
-*/
- mraa::Gpio gpio(pin);
- gpio.dir(mraa::DIR_IN);
- return gpio.read();
-}
-
-
diff --git a/peripheral/libupm/src/lp8860/mraa-utils.hpp b/peripheral/libupm/src/lp8860/mraa-utils.hpp
deleted file mode 100644
index f9e6acc..0000000
--- a/peripheral/libupm/src/lp8860/mraa-utils.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#pragma once
-
-#include "mraa/types.h"
-
-class __attribute__ ((visibility("hidden"))) MraaUtils
-{
-public:
- static void setGpio(int pin, int level);
- static int getGpio(int pin);
-};
-
-
-
diff --git a/peripheral/libupm/src/lp8860/pyupm_lp8860.i b/peripheral/libupm/src/lp8860/pyupm_lp8860.i
deleted file mode 100644
index 04eafe5..0000000
--- a/peripheral/libupm/src/lp8860/pyupm_lp8860.i
+++ /dev/null
@@ -1,9 +0,0 @@
-%module pyupm_lp8860
-%include "../upm.i"
-
-%feature("autodoc", "3");
-
-%include "lp8860.hpp"
-%{
- #include "lp8860.hpp"
-%}
diff --git a/peripheral/libupm/src/lpd8806/.DS_Store b/peripheral/libupm/src/lpd8806/.DS_Store
new file mode 100644
index 0000000..095d5c9
--- /dev/null
+++ b/peripheral/libupm/src/lpd8806/.DS_Store
Binary files differ
diff --git a/peripheral/libupm/src/lpd8806/._.DS_Store b/peripheral/libupm/src/lpd8806/._.DS_Store
new file mode 100644
index 0000000..16d5ab2
--- /dev/null
+++ b/peripheral/libupm/src/lpd8806/._.DS_Store
Binary files differ
diff --git a/peripheral/libupm/src/lpd8806/._CMakeLists.txt b/peripheral/libupm/src/lpd8806/._CMakeLists.txt
new file mode 100644
index 0000000..2802dda
--- /dev/null
+++ b/peripheral/libupm/src/lpd8806/._CMakeLists.txt
Binary files differ
diff --git a/peripheral/libupm/src/lpd8806/._jsupm_lpd8806.i b/peripheral/libupm/src/lpd8806/._jsupm_lpd8806.i
new file mode 100644
index 0000000..59e6f40
--- /dev/null
+++ b/peripheral/libupm/src/lpd8806/._jsupm_lpd8806.i
Binary files differ
diff --git a/peripheral/libupm/src/lpd8806/._pyupm_lpd8806.i b/peripheral/libupm/src/lpd8806/._pyupm_lpd8806.i
new file mode 100644
index 0000000..b4ee648
--- /dev/null
+++ b/peripheral/libupm/src/lpd8806/._pyupm_lpd8806.i
Binary files differ
diff --git a/peripheral/libupm/src/lpd8806/CMakeLists.txt b/peripheral/libupm/src/lpd8806/CMakeLists.txt
index 0bbd74c..146ce83 100644
--- a/peripheral/libupm/src/lpd8806/CMakeLists.txt
+++ b/peripheral/libupm/src/lpd8806/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "lpd8806")
set (libdescription “Digital RGB LED strip”)
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/lpd8806/javaupm_lpd8806.i b/peripheral/libupm/src/lpd8806/javaupm_lpd8806.i
index 0faac25..5de138a 100644
--- a/peripheral/libupm/src/lpd8806/javaupm_lpd8806.i
+++ b/peripheral/libupm/src/lpd8806/javaupm_lpd8806.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "lpd8806.hpp"
+ #include "lpd8806.h"
%}
-%include "lpd8806.hpp"
+%include "lpd8806.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/lpd8806/jsupm_lpd8806.i b/peripheral/libupm/src/lpd8806/jsupm_lpd8806.i
index bafc2b4..279c8fe 100644
--- a/peripheral/libupm/src/lpd8806/jsupm_lpd8806.i
+++ b/peripheral/libupm/src/lpd8806/jsupm_lpd8806.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "lpd8806.hpp"
+ #include "lpd8806.h"
%}
-%include "lpd8806.hpp"
+%include "lpd8806.h"
diff --git a/peripheral/libupm/src/lpd8806/lpd8806.cxx b/peripheral/libupm/src/lpd8806/lpd8806.cxx
index 6f0bffb..40c1e82 100644
--- a/peripheral/libupm/src/lpd8806/lpd8806.cxx
+++ b/peripheral/libupm/src/lpd8806/lpd8806.cxx
@@ -28,7 +28,7 @@
#include <cstring>
#include <stdexcept>
-#include "lpd8806.hpp"
+#include "lpd8806.h"
using namespace upm;
diff --git a/peripheral/libupm/src/lpd8806/lpd8806.hpp b/peripheral/libupm/src/lpd8806/lpd8806.h
index cc8f7e4..cc8f7e4 100644
--- a/peripheral/libupm/src/lpd8806/lpd8806.hpp
+++ b/peripheral/libupm/src/lpd8806/lpd8806.h
diff --git a/peripheral/libupm/src/lpd8806/pyupm_lpd8806.i b/peripheral/libupm/src/lpd8806/pyupm_lpd8806.i
index 643abcd..ee8db84 100644
--- a/peripheral/libupm/src/lpd8806/pyupm_lpd8806.i
+++ b/peripheral/libupm/src/lpd8806/pyupm_lpd8806.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "lpd8806.hpp"
+%include "lpd8806.h"
%{
- #include "lpd8806.hpp"
+ #include "lpd8806.h"
%}
diff --git a/peripheral/libupm/src/lsm303/CMakeLists.txt b/peripheral/libupm/src/lsm303/CMakeLists.txt
index 7349b35..d97e58b 100644
--- a/peripheral/libupm/src/lsm303/CMakeLists.txt
+++ b/peripheral/libupm/src/lsm303/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "lsm303")
set (libdescription "upm lsm303")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/lsm303/javaupm_lsm303.i b/peripheral/libupm/src/lsm303/javaupm_lsm303.i
index da0ce2b..961c74f 100644
--- a/peripheral/libupm/src/lsm303/javaupm_lsm303.i
+++ b/peripheral/libupm/src/lsm303/javaupm_lsm303.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "lsm303.hpp"
+ #include "lsm303.h"
%}
%typemap(jni) int16_t* "jshortArray"
@@ -18,7 +18,7 @@
JCALL4(SetShortArrayRegion, jenv, $result, 0, 3, (jshort*)$1);
}
-%include "lsm303.hpp"
+%include "lsm303.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/lsm303/jsupm_lsm303.i b/peripheral/libupm/src/lsm303/jsupm_lsm303.i
index ba6d27b..f6f65cf 100644
--- a/peripheral/libupm/src/lsm303/jsupm_lsm303.i
+++ b/peripheral/libupm/src/lsm303/jsupm_lsm303.i
@@ -9,7 +9,7 @@
}
%{
- #include "lsm303.hpp"
+ #include "lsm303.h"
%}
-%include "lsm303.hpp"
+%include "lsm303.h"
diff --git a/peripheral/libupm/src/lsm303/lsm303.cxx b/peripheral/libupm/src/lsm303/lsm303.cxx
index 268a411..87d4afe 100644
--- a/peripheral/libupm/src/lsm303/lsm303.cxx
+++ b/peripheral/libupm/src/lsm303/lsm303.cxx
@@ -31,7 +31,7 @@
#include <unistd.h>
#include <stdlib.h>
-#include "lsm303.hpp"
+#include "lsm303.h"
using namespace upm;
diff --git a/peripheral/libupm/src/lsm303/lsm303.hpp b/peripheral/libupm/src/lsm303/lsm303.h
index 767d547..767d547 100644
--- a/peripheral/libupm/src/lsm303/lsm303.hpp
+++ b/peripheral/libupm/src/lsm303/lsm303.h
diff --git a/peripheral/libupm/src/lsm303/pyupm_lsm303.i b/peripheral/libupm/src/lsm303/pyupm_lsm303.i
index f865cee..b32d25e 100644
--- a/peripheral/libupm/src/lsm303/pyupm_lsm303.i
+++ b/peripheral/libupm/src/lsm303/pyupm_lsm303.i
@@ -12,7 +12,7 @@
resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_int16Array, 0 | 0 );
}
-%include "lsm303.hpp"
+%include "lsm303.h"
%{
- #include "lsm303.hpp"
+ #include "lsm303.h"
%}
diff --git a/peripheral/libupm/src/lsm9ds0/CMakeLists.txt b/peripheral/libupm/src/lsm9ds0/CMakeLists.txt
index 917385b..d4a45fd 100644
--- a/peripheral/libupm/src/lsm9ds0/CMakeLists.txt
+++ b/peripheral/libupm/src/lsm9ds0/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "lsm9ds0")
set (libdescription "gyro, accelerometer and magnometer sensor based on lsm9ds0")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/lsm9ds0/javaupm_lsm9ds0.i b/peripheral/libupm/src/lsm9ds0/javaupm_lsm9ds0.i
index a91723f..05ca5dc 100644
--- a/peripheral/libupm/src/lsm9ds0/javaupm_lsm9ds0.i
+++ b/peripheral/libupm/src/lsm9ds0/javaupm_lsm9ds0.i
@@ -39,10 +39,10 @@
%ignore getMagnetometer(float *, float *, float *);
%{
- #include "lsm9ds0.hpp"
+ #include "lsm9ds0.h"
%}
-%include "lsm9ds0.hpp"
+%include "lsm9ds0.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/lsm9ds0/jsupm_lsm9ds0.i b/peripheral/libupm/src/lsm9ds0/jsupm_lsm9ds0.i
index 982d652..3f0c6ad 100644
--- a/peripheral/libupm/src/lsm9ds0/jsupm_lsm9ds0.i
+++ b/peripheral/libupm/src/lsm9ds0/jsupm_lsm9ds0.i
@@ -4,8 +4,8 @@
%pointer_functions(float, floatp);
-%include "lsm9ds0.hpp"
+%include "lsm9ds0.h"
%{
- #include "lsm9ds0.hpp"
+ #include "lsm9ds0.h"
%}
diff --git a/peripheral/libupm/src/lsm9ds0/lsm9ds0.cxx b/peripheral/libupm/src/lsm9ds0/lsm9ds0.cxx
index b8e4f1c..3253a62 100644
--- a/peripheral/libupm/src/lsm9ds0/lsm9ds0.cxx
+++ b/peripheral/libupm/src/lsm9ds0/lsm9ds0.cxx
@@ -27,14 +27,14 @@
#include <stdexcept>
#include <string.h>
-#include "lsm9ds0.hpp"
+#include "lsm9ds0.h"
using namespace upm;
using namespace std;
-LSM9DS0::LSM9DS0(int bus, bool raw, uint8_t gAddress, uint8_t xmAddress) :
- m_i2cG(bus, raw), m_i2cXM(bus, raw), m_gpioG_INT(0), m_gpioG_DRDY(0),
+LSM9DS0::LSM9DS0(int bus, uint8_t gAddress, uint8_t xmAddress) :
+ m_i2cG(bus), m_i2cXM(bus), m_gpioG_INT(0), m_gpioG_DRDY(0),
m_gpioXM_GEN1(0), m_gpioXM_GEN2(0)
{
m_gAddr = gAddress;
diff --git a/peripheral/libupm/src/lsm9ds0/lsm9ds0.hpp b/peripheral/libupm/src/lsm9ds0/lsm9ds0.h
index cc872cc..17648d6 100644
--- a/peripheral/libupm/src/lsm9ds0/lsm9ds0.hpp
+++ b/peripheral/libupm/src/lsm9ds0/lsm9ds0.h
@@ -1058,12 +1058,9 @@ namespace upm {
* lsm9ds0 constructor
*
* @param bus i2c bus to use
- * @param raw bypass board definition file, set to true if using Sparkfun
- * 9DOF Block on an Intel Edison Arduino board
* @param address the address for this device
*/
- LSM9DS0(int bus=LSM9DS0_I2C_BUS,
- bool raw=false,
+ LSM9DS0(int bus=LSM9DS0_I2C_BUS,
uint8_t gAddress=LSM9DS0_DEFAULT_GYRO_ADDR,
uint8_t xmAddress=LSM9DS0_DEFAULT_XM_ADDR);
diff --git a/peripheral/libupm/src/lsm9ds0/pyupm_lsm9ds0.i b/peripheral/libupm/src/lsm9ds0/pyupm_lsm9ds0.i
index 4665f27..7472a9d 100644
--- a/peripheral/libupm/src/lsm9ds0/pyupm_lsm9ds0.i
+++ b/peripheral/libupm/src/lsm9ds0/pyupm_lsm9ds0.i
@@ -10,8 +10,8 @@
%pointer_functions(float, floatp);
-%include "lsm9ds0.hpp"
+%include "lsm9ds0.h"
%{
- #include "lsm9ds0.hpp"
+ #include "lsm9ds0.h"
%}
diff --git a/peripheral/libupm/src/m24lr64e/CMakeLists.txt b/peripheral/libupm/src/m24lr64e/CMakeLists.txt
index ee9ad3f..57daeac 100644
--- a/peripheral/libupm/src/m24lr64e/CMakeLists.txt
+++ b/peripheral/libupm/src/m24lr64e/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "m24lr64e")
set (libdescription "upm m24lr64e grove NFC tag")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/m24lr64e/javaupm_m24lr64e.i b/peripheral/libupm/src/m24lr64e/javaupm_m24lr64e.i
index 048e188..185e7e5 100644
--- a/peripheral/libupm/src/m24lr64e/javaupm_m24lr64e.i
+++ b/peripheral/libupm/src/m24lr64e/javaupm_m24lr64e.i
@@ -20,10 +20,10 @@
}
%{
- #include "m24lr64e.hpp"
+ #include "m24lr64e.h"
%}
-%include "m24lr64e.hpp"
+%include "m24lr64e.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/m24lr64e/jsupm_m24lr64e.i b/peripheral/libupm/src/m24lr64e/jsupm_m24lr64e.i
index 104efae..8e1993c 100644
--- a/peripheral/libupm/src/m24lr64e/jsupm_m24lr64e.i
+++ b/peripheral/libupm/src/m24lr64e/jsupm_m24lr64e.i
@@ -4,7 +4,7 @@
%include "stdint.i"
%{
- #include "m24lr64e.hpp"
+ #include "m24lr64e.h"
%}
-%include "m24lr64e.hpp"
+%include "m24lr64e.h"
diff --git a/peripheral/libupm/src/m24lr64e/m24lr64e.cxx b/peripheral/libupm/src/m24lr64e/m24lr64e.cxx
index a4e1cd7..633d5e7 100644
--- a/peripheral/libupm/src/m24lr64e/m24lr64e.cxx
+++ b/peripheral/libupm/src/m24lr64e/m24lr64e.cxx
@@ -27,7 +27,7 @@
#include <iostream>
#include <string>
-#include "m24lr64e.hpp"
+#include "m24lr64e.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/m24lr64e/m24lr64e.hpp b/peripheral/libupm/src/m24lr64e/m24lr64e.h
index ffdaf25..ffdaf25 100644
--- a/peripheral/libupm/src/m24lr64e/m24lr64e.hpp
+++ b/peripheral/libupm/src/m24lr64e/m24lr64e.h
diff --git a/peripheral/libupm/src/m24lr64e/pyupm_m24lr64e.i b/peripheral/libupm/src/m24lr64e/pyupm_m24lr64e.i
index 5b8b538..7b70298 100644
--- a/peripheral/libupm/src/m24lr64e/pyupm_m24lr64e.i
+++ b/peripheral/libupm/src/m24lr64e/pyupm_m24lr64e.i
@@ -11,7 +11,7 @@
%include "m24lr64e_doc.i"
#endif
-%include "m24lr64e.hpp"
+%include "m24lr64e.h"
%{
- #include "m24lr64e.hpp"
+ #include "m24lr64e.h"
%}
diff --git a/peripheral/libupm/src/max31723/CMakeLists.txt b/peripheral/libupm/src/max31723/CMakeLists.txt
index f6e5c72..911b374 100644
--- a/peripheral/libupm/src/max31723/CMakeLists.txt
+++ b/peripheral/libupm/src/max31723/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "max31723")
set (libdescription "Very accurate temperature sensor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/max31723/javaupm_max31723.i b/peripheral/libupm/src/max31723/javaupm_max31723.i
index c4a6a0b..419a34a 100644
--- a/peripheral/libupm/src/max31723/javaupm_max31723.i
+++ b/peripheral/libupm/src/max31723/javaupm_max31723.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "max31723.hpp"
+ #include "max31723.h"
%}
-%include "max31723.hpp"
+%include "max31723.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/max31723/jsupm_max31723.i b/peripheral/libupm/src/max31723/jsupm_max31723.i
index cfb8a7e..e35ead5 100644
--- a/peripheral/libupm/src/max31723/jsupm_max31723.i
+++ b/peripheral/libupm/src/max31723/jsupm_max31723.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "max31723.hpp"
+ #include "max31723.h"
%}
-%include "max31723.hpp"
+%include "max31723.h"
diff --git a/peripheral/libupm/src/max31723/max31723.cxx b/peripheral/libupm/src/max31723/max31723.cxx
index f34dd88..133a44d 100644
--- a/peripheral/libupm/src/max31723/max31723.cxx
+++ b/peripheral/libupm/src/max31723/max31723.cxx
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include <stdexcept>
-#include "max31723.hpp"
+#include "max31723.h"
using namespace upm;
diff --git a/peripheral/libupm/src/max31723/max31723.hpp b/peripheral/libupm/src/max31723/max31723.h
index 9aaaca2..9aaaca2 100644
--- a/peripheral/libupm/src/max31723/max31723.hpp
+++ b/peripheral/libupm/src/max31723/max31723.h
diff --git a/peripheral/libupm/src/max31723/pyupm_max31723.i b/peripheral/libupm/src/max31723/pyupm_max31723.i
index da8e497..2694b7d 100644
--- a/peripheral/libupm/src/max31723/pyupm_max31723.i
+++ b/peripheral/libupm/src/max31723/pyupm_max31723.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "max31723.hpp"
+%include "max31723.h"
%{
- #include "max31723.hpp"
+ #include "max31723.h"
%}
diff --git a/peripheral/libupm/src/max31855/CMakeLists.txt b/peripheral/libupm/src/max31855/CMakeLists.txt
index 312ee00..b2ff5df 100644
--- a/peripheral/libupm/src/max31855/CMakeLists.txt
+++ b/peripheral/libupm/src/max31855/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "max31855")
set (libdescription "K type thermistor amplifier")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/max31855/javaupm_max31855.i b/peripheral/libupm/src/max31855/javaupm_max31855.i
index 17bbdc5..a778d37 100644
--- a/peripheral/libupm/src/max31855/javaupm_max31855.i
+++ b/peripheral/libupm/src/max31855/javaupm_max31855.i
@@ -3,10 +3,10 @@
%include "../upm.i"
%{
- #include "max31855.hpp"
+ #include "max31855.h"
%}
-%include "max31855.hpp"
+%include "max31855.h"
//! [Interesting]
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/max31855/jsupm_max31855.i b/peripheral/libupm/src/max31855/jsupm_max31855.i
index d3c2897..6bb6967 100644
--- a/peripheral/libupm/src/max31855/jsupm_max31855.i
+++ b/peripheral/libupm/src/max31855/jsupm_max31855.i
@@ -3,8 +3,8 @@
%include "../upm.i"
%{
- #include "max31855.hpp"
+ #include "max31855.h"
%}
-%include "max31855.hpp"
+%include "max31855.h"
//! [Interesting]
diff --git a/peripheral/libupm/src/max31855/max31855.cxx b/peripheral/libupm/src/max31855/max31855.cxx
index d940703..3037aaf 100644
--- a/peripheral/libupm/src/max31855/max31855.cxx
+++ b/peripheral/libupm/src/max31855/max31855.cxx
@@ -30,7 +30,7 @@
#include <functional>
#include <string.h>
-#include "max31855.hpp"
+#include "max31855.h"
using namespace upm;
diff --git a/peripheral/libupm/src/max31855/max31855.hpp b/peripheral/libupm/src/max31855/max31855.h
index bbd6af8..bbd6af8 100644
--- a/peripheral/libupm/src/max31855/max31855.hpp
+++ b/peripheral/libupm/src/max31855/max31855.h
diff --git a/peripheral/libupm/src/max31855/pyupm_max31855.i b/peripheral/libupm/src/max31855/pyupm_max31855.i
index cfbfd7a..e06c7b7 100644
--- a/peripheral/libupm/src/max31855/pyupm_max31855.i
+++ b/peripheral/libupm/src/max31855/pyupm_max31855.i
@@ -7,7 +7,7 @@
%feature("autodoc", "3");
-%include "max31855.hpp"
+%include "max31855.h"
%{
- #include "max31855.hpp"
+ #include "max31855.h"
%}
diff --git a/peripheral/libupm/src/max44000/CMakeLists.txt b/peripheral/libupm/src/max44000/CMakeLists.txt
index 430e64d..1109061 100644
--- a/peripheral/libupm/src/max44000/CMakeLists.txt
+++ b/peripheral/libupm/src/max44000/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "max44000")
set (libdescription "upm MAX44000")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/max44000/javaupm_max44000.i b/peripheral/libupm/src/max44000/javaupm_max44000.i
index b4080d6..fbf331a 100644
--- a/peripheral/libupm/src/max44000/javaupm_max44000.i
+++ b/peripheral/libupm/src/max44000/javaupm_max44000.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "max44000.hpp"
+ #include "max44000.h"
%}
-%include "max44000.hpp"
+%include "max44000.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/max44000/jsupm_max44000.i b/peripheral/libupm/src/max44000/jsupm_max44000.i
index d8f90e4..80a2b5a 100644
--- a/peripheral/libupm/src/max44000/jsupm_max44000.i
+++ b/peripheral/libupm/src/max44000/jsupm_max44000.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "max44000.hpp"
+ #include "max44000.h"
%}
-%include "max44000.hpp"
+%include "max44000.h"
diff --git a/peripheral/libupm/src/max44000/max44000.cxx b/peripheral/libupm/src/max44000/max44000.cxx
index 384e747..eb7025d 100644
--- a/peripheral/libupm/src/max44000/max44000.cxx
+++ b/peripheral/libupm/src/max44000/max44000.cxx
@@ -28,7 +28,7 @@
#include <unistd.h>
#include <stdlib.h>
-#include "max44000.hpp"
+#include "max44000.h"
using namespace upm;
diff --git a/peripheral/libupm/src/max44000/max44000.hpp b/peripheral/libupm/src/max44000/max44000.h
index fdd4e93..fdd4e93 100644
--- a/peripheral/libupm/src/max44000/max44000.hpp
+++ b/peripheral/libupm/src/max44000/max44000.h
diff --git a/peripheral/libupm/src/max44000/pyupm_max44000.i b/peripheral/libupm/src/max44000/pyupm_max44000.i
index 6fb6920..f427531 100644
--- a/peripheral/libupm/src/max44000/pyupm_max44000.i
+++ b/peripheral/libupm/src/max44000/pyupm_max44000.i
@@ -7,7 +7,7 @@
%feature("autodoc", "3");
-%include "max44000.hpp"
+%include "max44000.h"
%{
- #include "max44000.hpp"
+ #include "max44000.h"
%}
diff --git a/peripheral/libupm/src/max44009/CMakeLists.txt b/peripheral/libupm/src/max44009/CMakeLists.txt
deleted file mode 100644
index 8a3a9a4..0000000
--- a/peripheral/libupm/src/max44009/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-include_directories(..)
-set (libname "max44009")
-set (libdescription "upm MAX44009")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/max44009/javaupm_max44009.i b/peripheral/libupm/src/max44009/javaupm_max44009.i
deleted file mode 100644
index c6ce339..0000000
--- a/peripheral/libupm/src/max44009/javaupm_max44009.i
+++ /dev/null
@@ -1,23 +0,0 @@
-%module javaupm_max44009
-%include "../upm.i"
-%include "arrays_java.i";
-%include "../java_buffer.i"
-%include "cpointer.i"
-%include "typemaps.i"
-
-%{
- #include "max44009.hpp"
-%}
-
-%include "max44009.hpp"
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_max44009");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/max44009/jsupm_max44009.i b/peripheral/libupm/src/max44009/jsupm_max44009.i
deleted file mode 100644
index afebbae..0000000
--- a/peripheral/libupm/src/max44009/jsupm_max44009.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module jsupm_max44009
-%include "../upm.i"
-
-%{
- #include "max44009.hpp"
-%}
-
-%include "max44009.hpp"
diff --git a/peripheral/libupm/src/max44009/max44009.cxx b/peripheral/libupm/src/max44009/max44009.cxx
deleted file mode 100644
index d7696c1..0000000
--- a/peripheral/libupm/src/max44009/max44009.cxx
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Author: Scott Ware <scott.r.ware@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-#include <unistd.h>
-#include <stdlib.h>
-#include <math.h>
-
-#include "max44009.hpp"
-
-using namespace upm;
-
-MAX44009::MAX44009 (int bus, int devAddr) {
-
- m_maxControlAddr = devAddr;
- i2c = new mraa::I2c(bus);
- i2c->address(m_maxControlAddr);
-
- // Reset chip to defaults
- status = mraa::SUCCESS;
- reset();
- if (status != mraa::SUCCESS)
- UPM_THROW("config failure");
-}
-
-MAX44009::~MAX44009() {
- delete i2c;
-}
-
-mraa::Result
-MAX44009::reset() {
- uint8_t address[5] = {MAX44009_INT_ENABLE_ADDR, MAX44009_CONFIG_ADDR, \
- MAX44009_THR_HIGH_ADDR, MAX44009_THR_LOW_ADDR, \
- MAX44009_THR_TIMER_ADDR};
- uint8_t value[5] = {MAX44009_INT_DISABLED, MAX44009_DEFAULT_CONFIGURATION, \
- 0xFF, 0x00, 0xFF};
- uint8_t i;
- for (i = 0; i < sizeof(address) && status == mraa::SUCCESS; i++) {
- status = i2c->writeReg(address[i], value[i]);
- }
- return status;
-}
-
-uint16_t
-MAX44009::getVisibleRaw() {
- uint8_t exponent, mantissa;
- uint8_t data[MAX44009_LUX_LENGTH];
- uint16_t* value = reinterpret_cast<uint16_t*>(&data[0]);
-
- int length = i2c->readBytesReg(MAX44009_LUX_START_ADDR, data, MAX44009_LUX_LENGTH);
-
- if(length != MAX44009_LUX_LENGTH)
- UPM_THROW("Read error");
-
- return *value;
-}
-
-
-double
-MAX44009::getVisibleLux() {
- uint16_t rawValue = getVisibleRaw();
- uint8_t rawValueMsb = rawValue >> 8;
- uint8_t rawValueLsb = rawValue & 0xFF;
- uint8_t exponent = (( rawValueMsb & 0xF0 ) >> 4);
- uint8_t mantissa = (( rawValueMsb & 0x0F ) << 4 ) | ( rawValueLsb & 0x0F );
-
- // Check for overrange condition
- if(exponent == MAX44009_OVERRANGE_CONDITION)
- UPM_THROW("Overrange error");
-
- return pow((double)2,(double)exponent) * mantissa * 0.045;
-}
-
diff --git a/peripheral/libupm/src/max44009/max44009.hpp b/peripheral/libupm/src/max44009/max44009.hpp
deleted file mode 100644
index 87b98ff..0000000
--- a/peripheral/libupm/src/max44009/max44009.hpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Author: Scott Ware <scott.r.ware@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <mraa/i2c.hpp>
-
-#include "upm/iLightSensor.hpp"
-
-/* ADDRESS AND NOT_FOUND VALUE */
-#define MAX44009_ADDRESS ( 0x4A )
-#define MAX44009_NOT_FOUND ( 0x00 )
-
-/* I2C BUS */
-#define MAX44009_I2C_BUS ( 1 )
-
-/* REGISTER ADDRESSES */
-#define MAX44009_INT_STATUS_ADDR ( 0x00 ) // R
-#define MAX44009_INT_ENABLE_ADDR ( 0x01 ) // R/W
-#define MAX44009_CONFIG_ADDR ( 0x02 ) // R/W
-#define MAX44009_LUX_START_ADDR ( 0x03 )
-#define MAX44009_LUX_LENGTH ( 2 )
-#define MAX44009_LUX_HIGH ( 0 )
-#define MAX44009_LUX_LOW ( 1 )
-#define MAX44009_THR_HIGH_ADDR ( 0x05 ) // R/W
-#define MAX44009_THR_LOW_ADDR ( 0x06 ) // R/W
-#define MAX44009_THR_TIMER_ADDR ( 0x07 ) // R/W
-
-/* INTERRUPT VALUES */
-#define MAX44009_INT_STATUS_OFF ( 0x00 )
-#define MAX44009_INT_STATUS_ON ( 0x01 )
-#define MAX44009_INT_DISABLED ( 0x00 )
-#define MAX44009_INT_ENABLED ( 0x01 )
-
-/* CONFIGURATION VALUES */
-#define MAX44009_CONFIG_DEFAULT ( 0 << 7 )
-#define MAX44009_CONFIG_CONTINUOUS ( 1 << 7 )
-#define MAX44009_CONFIG_AUTO ( 0 << 6 )
-#define MAX44009_CONFIG_MANUAL ( 1 << 6 )
-#define MAX44009_CONFIG_CDR_NORMAL ( 0 << 3 )
-#define MAX44009_CONFIG_CDR_DIVIDED ( 1 << 3 )
-#define MAX44009_CONFIG_INTEGRATION_800ms ( 0 << 0 )
-#define MAX44009_CONFIG_INTEGRATION_400ms ( 1 << 0 )
-#define MAX44009_CONFIG_INTEGRATION_200ms ( 2 << 0 )
-#define MAX44009_CONFIG_INTEGRATION_100ms ( 3 << 0 )
-#define MAX44009_CONFIG_INTEGRATION_50ms ( 4 << 0 )
-#define MAX44009_CONFIG_INTEGRATION_25ms ( 5 << 0 )
-#define MAX44009_CONFIG_INTEGRATION_12ms ( 6 << 0 )
-#define MAX44009_CONFIG_INTEGRATION_6ms ( 7 << 0 )
-
-/* DEFAULT CONFIGURATION */
-#define MAX44009_DEFAULT_CONFIGURATION ( MAX44009_CONFIG_DEFAULT | \
- MAX44009_CONFIG_AUTO | \
- MAX44009_CONFIG_CDR_NORMAL | \
- MAX44009_CONFIG_INTEGRATION_100ms )
-
-/* MISCELLANEOUS */
-#define MAX44009_OVERRANGE_CONDITION ( 0x0F )
-
-namespace upm {
-
-/**
- * @brief max44009 ambient light sensor library
- * @defgroup max44009 libupm-max44009
- * @ingroup maxim i2c light ilightsensor
- */
-
-/**
- * @brief C++ API for MAX44009 chip (Ambient Light Sensor)
- *
- * The Maxim Integrated
- * [MAX44009](http://datasheets.maximintegrated.com/en/ds/MAX44009.pdf)
- * is Industry’s Lowest-Power Ambient Light Sensor with ADC.
- *
- * @library max44009
- * @sensor max44009
- * @comname MAX44009 Ambient Light Sensor
- * @altname MAX44009
- * @type light
- * @man maxim
- * @con i2c
- * @if ilightsensor
- *
- * @snippet iLightSensor.hpp Interesting
- *
- */
-class MAX44009 : public ILightSensor {
- public:
- /**
- * Instanciates a MAX44009 object
- *
- * @param bus number of used bus
- * @param devAddr address of used i2c device
- */
- MAX44009 (int bus = MAX44009_I2C_BUS, int devAddr = MAX44009_ADDRESS);
-
- /**
- * MAX44009 object destructor, basicaly it close i2c connection.
- */
- ~MAX44009 ();
-
- /**
- * Read the raw visible light value
- */
- uint16_t getVisibleRaw();
-
- /**
- * Read the lux value
- */
- double getVisibleLux();
-
- const char* getModuleName() { return "max44009"; }
-
- private:
- mraa::Result reset();
-
- int m_maxControlAddr;
- mraa::I2c* i2c;
- mraa::Result status;
-};
-
-}
diff --git a/peripheral/libupm/src/max44009/pyupm_max44009.i b/peripheral/libupm/src/max44009/pyupm_max44009.i
deleted file mode 100644
index c8e614f..0000000
--- a/peripheral/libupm/src/max44009/pyupm_max44009.i
+++ /dev/null
@@ -1,11 +0,0 @@
-%module pyupm_max44009
-%include "../upm.i"
-
-%include "stdint.i"
-
-%feature("autodoc", "3");
-
-%include "max44009.hpp"
-%{
- #include "max44009.hpp"
-%}
diff --git a/peripheral/libupm/src/max5487/CMakeLists.txt b/peripheral/libupm/src/max5487/CMakeLists.txt
index d546ebd..e6d59b6 100644
--- a/peripheral/libupm/src/max5487/CMakeLists.txt
+++ b/peripheral/libupm/src/max5487/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "max5487")
set (libdescription "Digital potentiometer")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/max5487/javaupm_max5487.i b/peripheral/libupm/src/max5487/javaupm_max5487.i
index e5873b4..e31fed5 100644
--- a/peripheral/libupm/src/max5487/javaupm_max5487.i
+++ b/peripheral/libupm/src/max5487/javaupm_max5487.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "max5487.hpp"
+ #include "max5487.h"
%}
-%include "max5487.hpp"
+%include "max5487.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/max5487/jsupm_max5487.i b/peripheral/libupm/src/max5487/jsupm_max5487.i
index 9dd9c51..880aeaa 100644
--- a/peripheral/libupm/src/max5487/jsupm_max5487.i
+++ b/peripheral/libupm/src/max5487/jsupm_max5487.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "max5487.hpp"
+ #include "max5487.h"
%}
-%include "max5487.hpp"
+%include "max5487.h"
diff --git a/peripheral/libupm/src/max5487/max5487.cxx b/peripheral/libupm/src/max5487/max5487.cxx
index a7e93e2..4eb90ac 100644
--- a/peripheral/libupm/src/max5487/max5487.cxx
+++ b/peripheral/libupm/src/max5487/max5487.cxx
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include <stdexcept>
-#include "max5487.hpp"
+#include "max5487.h"
using namespace upm;
diff --git a/peripheral/libupm/src/max5487/max5487.hpp b/peripheral/libupm/src/max5487/max5487.h
index 287d30a..287d30a 100644
--- a/peripheral/libupm/src/max5487/max5487.hpp
+++ b/peripheral/libupm/src/max5487/max5487.h
diff --git a/peripheral/libupm/src/max5487/pyupm_max5487.i b/peripheral/libupm/src/max5487/pyupm_max5487.i
index e8026ec..693d526 100644
--- a/peripheral/libupm/src/max5487/pyupm_max5487.i
+++ b/peripheral/libupm/src/max5487/pyupm_max5487.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "max5487.hpp"
+%include "max5487.h"
%{
- #include "max5487.hpp"
+ #include "max5487.h"
%}
diff --git a/peripheral/libupm/src/maxds3231m/CMakeLists.txt b/peripheral/libupm/src/maxds3231m/CMakeLists.txt
index ff1fdd0..561ead4 100644
--- a/peripheral/libupm/src/maxds3231m/CMakeLists.txt
+++ b/peripheral/libupm/src/maxds3231m/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "maxds3231m")
set (libdescription "realtime clock sensor from MAX family")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/maxds3231m/javaupm_maxds3231m.i b/peripheral/libupm/src/maxds3231m/javaupm_maxds3231m.i
index a7a6801..4dcf6f3 100644
--- a/peripheral/libupm/src/maxds3231m/javaupm_maxds3231m.i
+++ b/peripheral/libupm/src/maxds3231m/javaupm_maxds3231m.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "maxds3231m.hpp"
+ #include "maxds3231m.h"
%}
-%include "maxds3231m.hpp"
+%include "maxds3231m.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/maxds3231m/jsupm_maxds3231m.i b/peripheral/libupm/src/maxds3231m/jsupm_maxds3231m.i
index aba6c8c..b18f347 100644
--- a/peripheral/libupm/src/maxds3231m/jsupm_maxds3231m.i
+++ b/peripheral/libupm/src/maxds3231m/jsupm_maxds3231m.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "maxds3231m.hpp"
+ #include "maxds3231m.h"
%}
-%include "maxds3231m.hpp"
+%include "maxds3231m.h"
diff --git a/peripheral/libupm/src/maxds3231m/maxds3231m.cxx b/peripheral/libupm/src/maxds3231m/maxds3231m.cxx
index 10bb234..7748303 100644
--- a/peripheral/libupm/src/maxds3231m/maxds3231m.cxx
+++ b/peripheral/libupm/src/maxds3231m/maxds3231m.cxx
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include <stdexcept>
-#include "maxds3231m.hpp"
+#include "maxds3231m.h"
using namespace upm;
diff --git a/peripheral/libupm/src/maxds3231m/maxds3231m.hpp b/peripheral/libupm/src/maxds3231m/maxds3231m.h
index 60dcf1e..60dcf1e 100644
--- a/peripheral/libupm/src/maxds3231m/maxds3231m.hpp
+++ b/peripheral/libupm/src/maxds3231m/maxds3231m.h
diff --git a/peripheral/libupm/src/maxds3231m/pyupm_maxds3231m.i b/peripheral/libupm/src/maxds3231m/pyupm_maxds3231m.i
index 7c2f8f9..05c3039 100644
--- a/peripheral/libupm/src/maxds3231m/pyupm_maxds3231m.i
+++ b/peripheral/libupm/src/maxds3231m/pyupm_maxds3231m.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "maxds3231m.hpp"
+%include "maxds3231m.h"
%{
- #include "maxds3231m.hpp"
+ #include "maxds3231m.h"
%}
diff --git a/peripheral/libupm/src/maxsonarez/CMakeLists.txt b/peripheral/libupm/src/maxsonarez/CMakeLists.txt
index 5e4fcde..09441bb 100644
--- a/peripheral/libupm/src/maxsonarez/CMakeLists.txt
+++ b/peripheral/libupm/src/maxsonarez/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "maxsonarez")
set (libdescription "upm MaxSonar EZ family of ultrasonic rangers")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/maxsonarez/javaupm_maxsonarez.i b/peripheral/libupm/src/maxsonarez/javaupm_maxsonarez.i
index 6c56b8b..dc3faef 100644
--- a/peripheral/libupm/src/maxsonarez/javaupm_maxsonarez.i
+++ b/peripheral/libupm/src/maxsonarez/javaupm_maxsonarez.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "maxsonarez.hpp"
+ #include "maxsonarez.h"
%}
-%include "maxsonarez.hpp"
+%include "maxsonarez.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/maxsonarez/jsupm_maxsonarez.i b/peripheral/libupm/src/maxsonarez/jsupm_maxsonarez.i
index 05911d3..b0af4c4 100644
--- a/peripheral/libupm/src/maxsonarez/jsupm_maxsonarez.i
+++ b/peripheral/libupm/src/maxsonarez/jsupm_maxsonarez.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "maxsonarez.hpp"
+ #include "maxsonarez.h"
%}
-%include "maxsonarez.hpp"
+%include "maxsonarez.h"
diff --git a/peripheral/libupm/src/maxsonarez/maxsonarez.cxx b/peripheral/libupm/src/maxsonarez/maxsonarez.cxx
index d6974e7..5122466 100644
--- a/peripheral/libupm/src/maxsonarez/maxsonarez.cxx
+++ b/peripheral/libupm/src/maxsonarez/maxsonarez.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "maxsonarez.hpp"
+#include "maxsonarez.h"
using namespace std;
using namespace upm;
@@ -55,9 +55,6 @@ MAXSONAREZ::~MAXSONAREZ()
int MAXSONAREZ::inches()
{
int val = mraa_aio_read(m_aio);
- if (val == -1) {
- return -1;
- }
float volts = float(val) * (m_aref / m_aRes);
return int(volts / m_vI);
diff --git a/peripheral/libupm/src/maxsonarez/maxsonarez.hpp b/peripheral/libupm/src/maxsonarez/maxsonarez.h
index b63226d..b63226d 100644
--- a/peripheral/libupm/src/maxsonarez/maxsonarez.hpp
+++ b/peripheral/libupm/src/maxsonarez/maxsonarez.h
diff --git a/peripheral/libupm/src/maxsonarez/pyupm_maxsonarez.i b/peripheral/libupm/src/maxsonarez/pyupm_maxsonarez.i
index 2ebfc26..e4504c8 100644
--- a/peripheral/libupm/src/maxsonarez/pyupm_maxsonarez.i
+++ b/peripheral/libupm/src/maxsonarez/pyupm_maxsonarez.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "maxsonarez.hpp"
+%include "maxsonarez.h"
%{
- #include "maxsonarez.hpp"
+ #include "maxsonarez.h"
%}
diff --git a/peripheral/libupm/src/mcp9808/CMakeLists.txt b/peripheral/libupm/src/mcp9808/CMakeLists.txt
index 1200446..11d39e7 100644
--- a/peripheral/libupm/src/mcp9808/CMakeLists.txt
+++ b/peripheral/libupm/src/mcp9808/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "mcp9808")
set (libdescription "upm mcp9808 Precision I2c temperature sensor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/mcp9808/javaupm_mcp9808.i b/peripheral/libupm/src/mcp9808/javaupm_mcp9808.i
index 1e5e5c8..ff6383b 100644
--- a/peripheral/libupm/src/mcp9808/javaupm_mcp9808.i
+++ b/peripheral/libupm/src/mcp9808/javaupm_mcp9808.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "mcp9808.hpp"
+ #include "mcp9808.h"
%}
-%include "mcp9808.hpp"
+%include "mcp9808.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/mcp9808/jsupm_mcp9808.i b/peripheral/libupm/src/mcp9808/jsupm_mcp9808.i
index 4bd46cb..60e4f2f 100644
--- a/peripheral/libupm/src/mcp9808/jsupm_mcp9808.i
+++ b/peripheral/libupm/src/mcp9808/jsupm_mcp9808.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "mcp9808.hpp"
+ #include "mcp9808.h"
%}
-%include "mcp9808.hpp"
+%include "mcp9808.h"
diff --git a/peripheral/libupm/src/mcp9808/mcp9808.cxx b/peripheral/libupm/src/mcp9808/mcp9808.cxx
index 2d0fa2a..a9da8ed 100644
--- a/peripheral/libupm/src/mcp9808/mcp9808.cxx
+++ b/peripheral/libupm/src/mcp9808/mcp9808.cxx
@@ -24,7 +24,7 @@
-#include "mcp9808.hpp"
+#include "mcp9808.h"
#include <cmath>
diff --git a/peripheral/libupm/src/mcp9808/mcp9808.hpp b/peripheral/libupm/src/mcp9808/mcp9808.h
index ac2f4d1..ac2f4d1 100644
--- a/peripheral/libupm/src/mcp9808/mcp9808.hpp
+++ b/peripheral/libupm/src/mcp9808/mcp9808.h
diff --git a/peripheral/libupm/src/mcp9808/pyupm_mcp9808.i b/peripheral/libupm/src/mcp9808/pyupm_mcp9808.i
index 7a9db9b..2f094ec 100644
--- a/peripheral/libupm/src/mcp9808/pyupm_mcp9808.i
+++ b/peripheral/libupm/src/mcp9808/pyupm_mcp9808.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "mcp9808.hpp"
+%include "mcp9808.h"
%{
- #include "mcp9808.hpp"
+ #include "mcp9808.h"
%}
diff --git a/peripheral/libupm/src/mg811/CMakeLists.txt b/peripheral/libupm/src/mg811/CMakeLists.txt
index 1a91c4f..66b70da 100644
--- a/peripheral/libupm/src/mg811/CMakeLists.txt
+++ b/peripheral/libupm/src/mg811/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "mg811")
set (libdescription "upm DFRobot CO2 sensor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/mg811/javaupm_mg811.i b/peripheral/libupm/src/mg811/javaupm_mg811.i
index 574fa79..3f7e201 100644
--- a/peripheral/libupm/src/mg811/javaupm_mg811.i
+++ b/peripheral/libupm/src/mg811/javaupm_mg811.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "mg811.hpp"
+ #include "mg811.h"
%}
-%include "mg811.hpp"
+%include "mg811.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/mg811/jsupm_mg811.i b/peripheral/libupm/src/mg811/jsupm_mg811.i
index 06fd8b5..0a4a4bb 100644
--- a/peripheral/libupm/src/mg811/jsupm_mg811.i
+++ b/peripheral/libupm/src/mg811/jsupm_mg811.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "mg811.hpp"
+ #include "mg811.h"
%}
-%include "mg811.hpp"
+%include "mg811.h"
diff --git a/peripheral/libupm/src/mg811/mg811.cxx b/peripheral/libupm/src/mg811/mg811.cxx
index 8330f88..622dd85 100644
--- a/peripheral/libupm/src/mg811/mg811.cxx
+++ b/peripheral/libupm/src/mg811/mg811.cxx
@@ -28,7 +28,7 @@
#include <iostream>
#include <math.h>
-#include "mg811.hpp"
+#include "mg811.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/src/mg811/mg811.hpp b/peripheral/libupm/src/mg811/mg811.h
index d8c4934..d8c4934 100644
--- a/peripheral/libupm/src/mg811/mg811.hpp
+++ b/peripheral/libupm/src/mg811/mg811.h
diff --git a/peripheral/libupm/src/mg811/pyupm_mg811.i b/peripheral/libupm/src/mg811/pyupm_mg811.i
index 34c3437..614da5c 100644
--- a/peripheral/libupm/src/mg811/pyupm_mg811.i
+++ b/peripheral/libupm/src/mg811/pyupm_mg811.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "mg811.hpp"
+%include "mg811.h"
%{
- #include "mg811.hpp"
+ #include "mg811.h"
%}
diff --git a/peripheral/libupm/src/mhz16/CMakeLists.txt b/peripheral/libupm/src/mhz16/CMakeLists.txt
index d435cc8..b032acb 100644
--- a/peripheral/libupm/src/mhz16/CMakeLists.txt
+++ b/peripheral/libupm/src/mhz16/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "mhz16")
set (libdescription "upm grove CO2 sensor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/mhz16/javaupm_mhz16.i b/peripheral/libupm/src/mhz16/javaupm_mhz16.i
index 3be6f6c..c2735a3 100644
--- a/peripheral/libupm/src/mhz16/javaupm_mhz16.i
+++ b/peripheral/libupm/src/mhz16/javaupm_mhz16.i
@@ -8,11 +8,11 @@
%apply int *OUTPUT { int *gas, int *temp };
%{
- #include "mhz16.hpp"
+ #include "mhz16.h"
speed_t int_B9600 = B9600;
%}
-%include "mhz16.hpp"
+%include "mhz16.h"
speed_t int_B9600 = B9600;
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/mhz16/jsupm_mhz16.i b/peripheral/libupm/src/mhz16/jsupm_mhz16.i
index 14e6f28..2b3f9d8 100644
--- a/peripheral/libupm/src/mhz16/jsupm_mhz16.i
+++ b/peripheral/libupm/src/mhz16/jsupm_mhz16.i
@@ -5,9 +5,9 @@
/* Send "int *" to JavaScript as intp */
%pointer_functions(int, intp);
%{
- #include "mhz16.hpp"
+ #include "mhz16.h"
speed_t int_B9600 = B9600;
%}
-%include "mhz16.hpp"
+%include "mhz16.h"
speed_t int_B9600 = B9600;
diff --git a/peripheral/libupm/src/mhz16/mhz16.cxx b/peripheral/libupm/src/mhz16/mhz16.cxx
index 161451c..8ea3925 100644
--- a/peripheral/libupm/src/mhz16/mhz16.cxx
+++ b/peripheral/libupm/src/mhz16/mhz16.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "mhz16.hpp"
+#include "mhz16.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/mhz16/mhz16.hpp b/peripheral/libupm/src/mhz16/mhz16.h
index b23072c..b23072c 100644
--- a/peripheral/libupm/src/mhz16/mhz16.hpp
+++ b/peripheral/libupm/src/mhz16/mhz16.h
diff --git a/peripheral/libupm/src/mhz16/pyupm_mhz16.i b/peripheral/libupm/src/mhz16/pyupm_mhz16.i
index dee82ae..843b380 100644
--- a/peripheral/libupm/src/mhz16/pyupm_mhz16.i
+++ b/peripheral/libupm/src/mhz16/pyupm_mhz16.i
@@ -9,8 +9,8 @@
/* Send "int *" to JavaScript as intp */
%pointer_functions(int, intp);
%{
- #include "mhz16.hpp"
+ #include "mhz16.h"
speed_t int_B9600 = B9600;
%}
-%include "mhz16.hpp"
+%include "mhz16.h"
speed_t int_B9600 = B9600;
diff --git a/peripheral/libupm/src/mic/CMakeLists.txt b/peripheral/libupm/src/mic/CMakeLists.txt
index 12b5c62..c21cce7 100644
--- a/peripheral/libupm/src/mic/CMakeLists.txt
+++ b/peripheral/libupm/src/mic/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "mic")
set (libdescription "Microphone simple API")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/mic/javaupm_mic.i b/peripheral/libupm/src/mic/javaupm_mic.i
index fb7965d..5abc65c 100644
--- a/peripheral/libupm/src/mic/javaupm_mic.i
+++ b/peripheral/libupm/src/mic/javaupm_mic.i
@@ -4,7 +4,7 @@
%include "arrays_java.i"
%{
- #include "mic.hpp"
+ #include "mic.h"
%}
%typemap(jni) (uint16_t *buffer, int len) "jshortArray";
@@ -37,7 +37,7 @@
JCALL3(ReleaseShortArrayElements, jenv, $input, (jshort *)$2, 0);
}
-%include "mic.hpp"
+%include "mic.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/mic/jsupm_mic.i b/peripheral/libupm/src/mic/jsupm_mic.i
index 567f8b2..c6fcad3 100644
--- a/peripheral/libupm/src/mic/jsupm_mic.i
+++ b/peripheral/libupm/src/mic/jsupm_mic.i
@@ -3,7 +3,7 @@
%include "../carrays_uint16_t.i"
%{
- #include "mic.hpp"
+ #include "mic.h"
%}
-%include "mic.hpp"
+%include "mic.h"
diff --git a/peripheral/libupm/src/mic/mic.cxx b/peripheral/libupm/src/mic/mic.cxx
index 8a4978c..ac4eb9b 100644
--- a/peripheral/libupm/src/mic/mic.cxx
+++ b/peripheral/libupm/src/mic/mic.cxx
@@ -29,7 +29,7 @@
#include <stdlib.h>
#include <functional>
#include <string.h>
-#include "mic.hpp"
+#include "mic.h"
using namespace upm;
@@ -69,11 +69,7 @@ Microphone::getSampledWindow (unsigned int freqMS, int numberOfSamples,
}
while (sampleIdx < numberOfSamples) {
- int x = mraa_aio_read (m_micCtx);
- if (x == -1) {
- return 0;
- }
- buffer[sampleIdx++] = x;
+ buffer[sampleIdx++] = mraa_aio_read (m_micCtx);
usleep(freqMS * 1000);
}
diff --git a/peripheral/libupm/src/mic/mic.hpp b/peripheral/libupm/src/mic/mic.h
index f54147d..08c07be 100644
--- a/peripheral/libupm/src/mic/mic.hpp
+++ b/peripheral/libupm/src/mic/mic.h
@@ -47,7 +47,7 @@ namespace upm {
* @altname Grove Sound Sensor
* @type sound
* @man seeed
- * @web http://www.seeedstudio.com/wiki/Grove_-_Sound_Sensor
+ * @web http://www.seeedstudio.com/wiki/Grove_-_Sound_Sensors
* @con pwm
* @kit gsk
*
diff --git a/peripheral/libupm/src/mic/pyupm_mic.i b/peripheral/libupm/src/mic/pyupm_mic.i
index 9cf904b..4cf7ff9 100644
--- a/peripheral/libupm/src/mic/pyupm_mic.i
+++ b/peripheral/libupm/src/mic/pyupm_mic.i
@@ -5,6 +5,6 @@
%include "../carrays_uint16_t.i"
%{
- #include "mic.hpp"
+ #include "mic.h"
%}
-%include "mic.hpp"
+%include "mic.h"
diff --git a/peripheral/libupm/src/micsv89/CMakeLists.txt b/peripheral/libupm/src/micsv89/CMakeLists.txt
index 97a191e..7297e08 100644
--- a/peripheral/libupm/src/micsv89/CMakeLists.txt
+++ b/peripheral/libupm/src/micsv89/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "micsv89")
set (libdescription "upm micsv89 environmental sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/micsv89/javaupm_micsv89.i b/peripheral/libupm/src/micsv89/javaupm_micsv89.i
index e904570..1e11060 100644
--- a/peripheral/libupm/src/micsv89/javaupm_micsv89.i
+++ b/peripheral/libupm/src/micsv89/javaupm_micsv89.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "micsv89.hpp"
+ #include "micsv89.h"
%}
-%include "micsv89.hpp"
+%include "micsv89.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/micsv89/jsupm_micsv89.i b/peripheral/libupm/src/micsv89/jsupm_micsv89.i
index 5e51fac..98c92c0 100644
--- a/peripheral/libupm/src/micsv89/jsupm_micsv89.i
+++ b/peripheral/libupm/src/micsv89/jsupm_micsv89.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "micsv89.hpp"
+ #include "micsv89.h"
%}
-%include "micsv89.hpp"
+%include "micsv89.h"
diff --git a/peripheral/libupm/src/micsv89/micsv89.cxx b/peripheral/libupm/src/micsv89/micsv89.cxx
index 9637c22..6fa6036 100644
--- a/peripheral/libupm/src/micsv89/micsv89.cxx
+++ b/peripheral/libupm/src/micsv89/micsv89.cxx
@@ -22,7 +22,7 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "micsv89.hpp"
+#include "micsv89.h"
using namespace upm;
diff --git a/peripheral/libupm/src/micsv89/micsv89.hpp b/peripheral/libupm/src/micsv89/micsv89.h
index 0fc369c..0fc369c 100644
--- a/peripheral/libupm/src/micsv89/micsv89.hpp
+++ b/peripheral/libupm/src/micsv89/micsv89.h
diff --git a/peripheral/libupm/src/micsv89/pyupm_micsv89.i b/peripheral/libupm/src/micsv89/pyupm_micsv89.i
index ba45581..8ae233f 100644
--- a/peripheral/libupm/src/micsv89/pyupm_micsv89.i
+++ b/peripheral/libupm/src/micsv89/pyupm_micsv89.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "micsv89.hpp"
+%include "micsv89.h"
%{
- #include "micsv89.hpp"
+ #include "micsv89.h"
%}
diff --git a/peripheral/libupm/src/mlx90614/.DS_Store b/peripheral/libupm/src/mlx90614/.DS_Store
new file mode 100644
index 0000000..dea2fac
--- /dev/null
+++ b/peripheral/libupm/src/mlx90614/.DS_Store
Binary files differ
diff --git a/peripheral/libupm/src/mlx90614/._.DS_Store b/peripheral/libupm/src/mlx90614/._.DS_Store
new file mode 100644
index 0000000..d83d264
--- /dev/null
+++ b/peripheral/libupm/src/mlx90614/._.DS_Store
Binary files differ
diff --git a/peripheral/libupm/src/mlx90614/CMakeLists.txt b/peripheral/libupm/src/mlx90614/CMakeLists.txt
index 28d3be7..ca02e69 100644
--- a/peripheral/libupm/src/mlx90614/CMakeLists.txt
+++ b/peripheral/libupm/src/mlx90614/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "mlx90614")
set (libdescription "Infrared thermometer designed for non-contact emperature sensing")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/mlx90614/javaupm_mlx90614.i b/peripheral/libupm/src/mlx90614/javaupm_mlx90614.i
index dddd699..a580925 100644
--- a/peripheral/libupm/src/mlx90614/javaupm_mlx90614.i
+++ b/peripheral/libupm/src/mlx90614/javaupm_mlx90614.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "mlx90614.hpp"
+ #include "mlx90614.h"
%}
-%include "mlx90614.hpp"
+%include "mlx90614.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/mlx90614/jsupm_mlx90614.i b/peripheral/libupm/src/mlx90614/jsupm_mlx90614.i
index 7ccde4c..a73650e 100644
--- a/peripheral/libupm/src/mlx90614/jsupm_mlx90614.i
+++ b/peripheral/libupm/src/mlx90614/jsupm_mlx90614.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "mlx90614.hpp"
+ #include "mlx90614.h"
%}
-%include "mlx90614.hpp"
+%include "mlx90614.h"
diff --git a/peripheral/libupm/src/mlx90614/mlx90614.cxx b/peripheral/libupm/src/mlx90614/mlx90614.cxx
index 5afaac3..aaa05ae 100644
--- a/peripheral/libupm/src/mlx90614/mlx90614.cxx
+++ b/peripheral/libupm/src/mlx90614/mlx90614.cxx
@@ -27,7 +27,7 @@
#include <stdlib.h>
#include <stdexcept>
-#include "mlx90614.hpp"
+#include "mlx90614.h"
using namespace upm;
diff --git a/peripheral/libupm/src/mlx90614/mlx90614.hpp b/peripheral/libupm/src/mlx90614/mlx90614.h
index 0cfe27c..0cfe27c 100644
--- a/peripheral/libupm/src/mlx90614/mlx90614.hpp
+++ b/peripheral/libupm/src/mlx90614/mlx90614.h
diff --git a/peripheral/libupm/src/mlx90614/pyupm_mlx90614.i b/peripheral/libupm/src/mlx90614/pyupm_mlx90614.i
index fada9ef..59c6cb4 100644
--- a/peripheral/libupm/src/mlx90614/pyupm_mlx90614.i
+++ b/peripheral/libupm/src/mlx90614/pyupm_mlx90614.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "mlx90614.hpp"
+%include "mlx90614.h"
%{
- #include "mlx90614.hpp"
+ #include "mlx90614.h"
%}
diff --git a/peripheral/libupm/src/mma7455/CMakeLists.txt b/peripheral/libupm/src/mma7455/CMakeLists.txt
index 96b993c..a52cbc9 100644
--- a/peripheral/libupm/src/mma7455/CMakeLists.txt
+++ b/peripheral/libupm/src/mma7455/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "mma7455")
set (libdescription "upm MMA7455")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/mma7455/javaupm_mma7455.i b/peripheral/libupm/src/mma7455/javaupm_mma7455.i
index 44b50f9..04a1f1f 100644
--- a/peripheral/libupm/src/mma7455/javaupm_mma7455.i
+++ b/peripheral/libupm/src/mma7455/javaupm_mma7455.i
@@ -23,10 +23,10 @@
%ignore readData(short *, short *, short *);
%{
- #include "mma7455.hpp"
+ #include "mma7455.h"
%}
-%include "mma7455.hpp"
+%include "mma7455.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/mma7455/jsupm_mma7455.i b/peripheral/libupm/src/mma7455/jsupm_mma7455.i
index b067397..3ec5f13 100644
--- a/peripheral/libupm/src/mma7455/jsupm_mma7455.i
+++ b/peripheral/libupm/src/mma7455/jsupm_mma7455.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "mma7455.hpp"
+ #include "mma7455.h"
%}
-%include "mma7455.hpp"
+%include "mma7455.h"
diff --git a/peripheral/libupm/src/mma7455/mma7455.cxx b/peripheral/libupm/src/mma7455/mma7455.cxx
index c54b5ce..371ac2f 100644
--- a/peripheral/libupm/src/mma7455/mma7455.cxx
+++ b/peripheral/libupm/src/mma7455/mma7455.cxx
@@ -31,7 +31,7 @@
#include <pthread.h>
#include <math.h>
-#include "mma7455.hpp"
+#include "mma7455.h"
using namespace upm;
diff --git a/peripheral/libupm/src/mma7455/mma7455.hpp b/peripheral/libupm/src/mma7455/mma7455.h
index e643dec..e643dec 100644
--- a/peripheral/libupm/src/mma7455/mma7455.hpp
+++ b/peripheral/libupm/src/mma7455/mma7455.h
diff --git a/peripheral/libupm/src/mma7455/pyupm_mma7455.i b/peripheral/libupm/src/mma7455/pyupm_mma7455.i
index f990a3c..309a138 100644
--- a/peripheral/libupm/src/mma7455/pyupm_mma7455.i
+++ b/peripheral/libupm/src/mma7455/pyupm_mma7455.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "mma7455.hpp"
+%include "mma7455.h"
%{
- #include "mma7455.hpp"
+ #include "mma7455.h"
%}
diff --git a/peripheral/libupm/src/mma7660/CMakeLists.txt b/peripheral/libupm/src/mma7660/CMakeLists.txt
index 1eaa49f..4748db5 100644
--- a/peripheral/libupm/src/mma7660/CMakeLists.txt
+++ b/peripheral/libupm/src/mma7660/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "mma7660")
set (libdescription "upm mma7660 I2C 3-axis digital accelermeter (1.5g)")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/mma7660/javaupm_mma7660.i b/peripheral/libupm/src/mma7660/javaupm_mma7660.i
index abe2ace..50a2116 100644
--- a/peripheral/libupm/src/mma7660/javaupm_mma7660.i
+++ b/peripheral/libupm/src/mma7660/javaupm_mma7660.i
@@ -7,7 +7,7 @@
%apply float *OUTPUT { float *ax, float *ay, float *az };
%{
- #include "mma7660.hpp"
+ #include "mma7660.h"
%}
%typemap(jni) float* "jfloatArray"
@@ -42,7 +42,7 @@
%ignore getRawValues(int *, int *, int *);
%ignore getAcceleration(float *, float *, float *);
-%include "mma7660.hpp"
+%include "mma7660.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/mma7660/jsupm_mma7660.i b/peripheral/libupm/src/mma7660/jsupm_mma7660.i
index 64a3cfa..25adc07 100644
--- a/peripheral/libupm/src/mma7660/jsupm_mma7660.i
+++ b/peripheral/libupm/src/mma7660/jsupm_mma7660.i
@@ -7,7 +7,7 @@
%pointer_functions(float, floatp);
%{
- #include "mma7660.hpp"
+ #include "mma7660.h"
%}
-%include "mma7660.hpp"
+%include "mma7660.h"
diff --git a/peripheral/libupm/src/mma7660/mma7660.cxx b/peripheral/libupm/src/mma7660/mma7660.cxx
index 2f2aea6..2215221 100644
--- a/peripheral/libupm/src/mma7660/mma7660.cxx
+++ b/peripheral/libupm/src/mma7660/mma7660.cxx
@@ -26,7 +26,7 @@
#include <stdexcept>
#include <string>
-#include "mma7660.hpp"
+#include "mma7660.h"
using namespace upm;
using namespace std;
@@ -78,11 +78,7 @@ bool MMA7660::writeByte(uint8_t reg, uint8_t byte)
uint8_t MMA7660::readByte(uint8_t reg)
{
- int x = mraa_i2c_read_byte_data(m_i2c, reg);
- if (x != -1) {
- return (uint8_t) x;
- }
- return 0;
+ return mraa_i2c_read_byte_data(m_i2c, reg);
}
void MMA7660::getRawValues(int *x, int *y, int *z)
diff --git a/peripheral/libupm/src/mma7660/mma7660.cxx.orig b/peripheral/libupm/src/mma7660/mma7660.cxx.orig
new file mode 100644
index 0000000..a563dd4
--- /dev/null
+++ b/peripheral/libupm/src/mma7660/mma7660.cxx.orig
@@ -0,0 +1,275 @@
+/*
+ * Author: Jon Trulson <jtrulson@ics.com>
+ * Copyright (c) 2015 Intel Corporation.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * 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.
+ */
+
+#include <iostream>
+#include <stdexcept>
+#include <string>
+
+#include "mma7660.h"
+
+using namespace upm;
+using namespace std;
+
+
+MMA7660::MMA7660(int bus, uint8_t address)
+{
+ m_addr = address;
+ m_isrInstalled = false;
+
+ // setup our i2c link
+ if ( !(m_i2c = mraa_i2c_init(bus)) )
+ {
+ throw std::invalid_argument(std::string(__FUNCTION__) +
+ ": mraa_i2c_init() failed");
+ return;
+ }
+
+ mraa_result_t rv;
+
+ if ( (rv = mraa_i2c_address(m_i2c, m_addr)) != MRAA_SUCCESS)
+ {
+ throw std::invalid_argument(std::string(__FUNCTION__) +
+ ": mraa_i2c_address() failed");
+ return;
+ }
+}
+
+MMA7660::~MMA7660()
+{
+ if (m_isrInstalled)
+ uninstallISR();
+
+ setModeStandby();
+ mraa_i2c_stop(m_i2c);
+}
+
+bool MMA7660::writeByte(uint8_t reg, uint8_t byte)
+{
+ mraa_result_t rv = mraa_i2c_write_byte_data(m_i2c, byte, reg);
+
+ if (rv != MRAA_SUCCESS)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+uint8_t MMA7660::readByte(uint8_t reg)
+{
+ return mraa_i2c_read_byte_data(m_i2c, reg);
+}
+
+void MMA7660::getRawValues(int *x, int *y, int *z)
+{
+ *x = getVerifiedAxis(REG_XOUT);
+ *y = getVerifiedAxis(REG_YOUT);
+ *z = getVerifiedAxis(REG_ZOUT);
+}
+
+#ifdef JAVACALLBACK
+int *MMA7660::getRawValues()
+{
+ int *values = new int[3];
+ getRawValues(&values[0], &values[1], &values[2]);
+ return values;
+}
+#endif
+
+void MMA7660::setModeActive()
+{
+ uint8_t modeReg = readByte(REG_MODE);
+
+ // The D2 (TON bit) should be cleared, and the MODE bit set
+
+ modeReg &= ~MODE_TON;
+ modeReg |= MODE_MODE;
+
+ writeByte(REG_MODE, modeReg);
+}
+
+void MMA7660::setModeStandby()
+{
+ uint8_t modeReg = readByte(REG_MODE);
+
+ // the D0 (mode bit) and D2 (TON bit) should be cleared.
+
+ modeReg &= ~MODE_TON;
+ modeReg &= ~MODE_MODE;
+
+ writeByte(REG_MODE, modeReg);
+}
+
+// read an axis value, verifying it's validity
+int MMA7660::getVerifiedAxis(MMA7660_REG_T axis)
+{
+ // We only want one of the 3 axes
+
+ if (axis > 2)
+ {
+ throw std::out_of_range(std::string(__FUNCTION__) +
+ ": axis must be 0, 1, or 2.");
+ return 0;
+ }
+
+ // we need to check the alert bit and sign bits if the alert bit is
+ // set, this means that the register was being updated when the
+ // register was read, so re-read until it's clear.
+
+ uint8_t val;
+ do {
+ val = readByte(axis);
+
+ // check alert bit
+ } while (val & 0x40);
+
+ // shift the sign bit over, and compensate
+ return (char(val << 2) / 4);
+}
+
+// read the tilt register, verifying it's validity
+uint8_t MMA7660::getVerifiedTilt()
+{
+ // we need to check the alert bit and sign bits if the alert bit is
+ // set, this means that the register was being updated when the
+ // register was read, so re-read until it's clear.
+
+ uint8_t val;
+ do {
+ val = readByte(REG_TILT);
+
+ // check alert bit
+ } while (val & 0x40);
+
+ return val;
+}
+
+uint8_t MMA7660::tiltBackFront()
+{
+ uint8_t val = getVerifiedTilt();
+
+ // mask off the bits we don't care about
+ val &= 0x03;
+ return val;
+}
+
+uint8_t MMA7660::tiltLandscapePortrait()
+{
+ uint8_t val = getVerifiedTilt();
+
+ // mask off the bits we don't care about
+ val >>= 2;
+ val &= 0x07;
+ return val;
+}
+
+bool MMA7660::tiltTap()
+{
+ uint8_t val = getVerifiedTilt();
+
+ if (val & 0x20)
+ return true;
+ else
+ return false;
+}
+
+bool MMA7660::tiltShake()
+{
+ uint8_t val = getVerifiedTilt();
+
+ if (val & 0x80)
+ return true;
+ else
+ return false;
+}
+
+#ifdef JAVACALLBACK
+void MMA7660::installISR(int pin, IsrCallback *cb)
+{
+ installISR(pin, generic_callback_isr, cb);
+}
+#endif
+
+void MMA7660::installISR(int pin, void (*isr)(void *), void *arg)
+{
+ if (m_isrInstalled)
+ uninstallISR();
+
+ if ( !(m_gpio = mraa_gpio_init(pin)) )
+ {
+ throw std::invalid_argument(std::string(__FUNCTION__) +
+ ": mraa_gpio_init() failed, invalid pin?");
+ return;
+ }
+
+ mraa_gpio_dir(m_gpio, MRAA_GPIO_IN);
+
+ // install our interrupt handler
+ mraa_gpio_isr(m_gpio, MRAA_GPIO_EDGE_RISING,
+ isr, arg);
+ m_isrInstalled = true;
+}
+
+void MMA7660::uninstallISR()
+{
+ if (!m_isrInstalled)
+ return;
+
+ mraa_gpio_isr_exit(m_gpio);
+ m_isrInstalled = false;
+ mraa_gpio_close(m_gpio);
+}
+
+bool MMA7660::setInterruptBits(uint8_t ibits)
+{
+ return writeByte(REG_INTSU, ibits);
+}
+
+bool MMA7660::setSampleRate(MMA7660_AUTOSLEEP_T sr)
+{
+ return writeByte(REG_SR, sr);
+}
+
+void MMA7660::getAcceleration(float *ax, float *ay, float *az)
+{
+ int x, y, z;
+
+ getRawValues(&x, &y, &z);
+
+ // 21.33, typical counts/g
+
+ *ax = x/21.33;
+ *ay = y/21.33;
+ *az = z/21.33;
+}
+
+#ifdef JAVACALLBACK
+float *MMA7660::getAcceleration()
+{
+ float *values = new float[3];
+ getAcceleration(&values[0], &values[1], &values[2]);
+ return values;
+}
+#endif
+
diff --git a/peripheral/libupm/src/mma7660/mma7660.hpp b/peripheral/libupm/src/mma7660/mma7660.h
index f18a5de..f18a5de 100644
--- a/peripheral/libupm/src/mma7660/mma7660.hpp
+++ b/peripheral/libupm/src/mma7660/mma7660.h
diff --git a/peripheral/libupm/src/mma7660/pyupm_mma7660.i b/peripheral/libupm/src/mma7660/pyupm_mma7660.i
index c653bad..23ba3fd 100644
--- a/peripheral/libupm/src/mma7660/pyupm_mma7660.i
+++ b/peripheral/libupm/src/mma7660/pyupm_mma7660.i
@@ -14,7 +14,7 @@
%include "mma7660_doc.i"
#endif
-%include "mma7660.hpp"
+%include "mma7660.h"
%{
- #include "mma7660.hpp"
+ #include "mma7660.h"
%}
diff --git a/peripheral/libupm/src/mpl3115a2/CMakeLists.txt b/peripheral/libupm/src/mpl3115a2/CMakeLists.txt
index 74c5d36..586cf21 100644
--- a/peripheral/libupm/src/mpl3115a2/CMakeLists.txt
+++ b/peripheral/libupm/src/mpl3115a2/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "mpl3115a2")
set (libdescription "libupm Pressure/Temperature Sensor")
set (module_src ${libname}.cpp)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/mpl3115a2/javaupm_mpl3115a2.i b/peripheral/libupm/src/mpl3115a2/javaupm_mpl3115a2.i
index 5c1f3d3..651dbcc 100644
--- a/peripheral/libupm/src/mpl3115a2/javaupm_mpl3115a2.i
+++ b/peripheral/libupm/src/mpl3115a2/javaupm_mpl3115a2.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "mpl3115a2.hpp"
+ #include "mpl3115a2.h"
%}
-%include "mpl3115a2.hpp"
+%include "mpl3115a2.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/mpl3115a2/jsupm_mpl3115a2.i b/peripheral/libupm/src/mpl3115a2/jsupm_mpl3115a2.i
index 4578520..318c8a3 100644
--- a/peripheral/libupm/src/mpl3115a2/jsupm_mpl3115a2.i
+++ b/peripheral/libupm/src/mpl3115a2/jsupm_mpl3115a2.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "mpl3115a2.hpp"
+ #include "mpl3115a2.h"
%}
-%include "mpl3115a2.hpp"
+%include "mpl3115a2.h"
diff --git a/peripheral/libupm/src/mpl3115a2/mpl3115a2.cpp b/peripheral/libupm/src/mpl3115a2/mpl3115a2.cpp
index df80c68..0ed700a 100644
--- a/peripheral/libupm/src/mpl3115a2/mpl3115a2.cpp
+++ b/peripheral/libupm/src/mpl3115a2/mpl3115a2.cpp
@@ -32,7 +32,7 @@
#include <unistd.h>
#include <stdlib.h>
-#include "mpl3115a2.hpp"
+#include "mpl3115a2.h"
using namespace upm;
diff --git a/peripheral/libupm/src/mpl3115a2/mpl3115a2.hpp b/peripheral/libupm/src/mpl3115a2/mpl3115a2.h
index 56ae8fd..56ae8fd 100644
--- a/peripheral/libupm/src/mpl3115a2/mpl3115a2.hpp
+++ b/peripheral/libupm/src/mpl3115a2/mpl3115a2.h
diff --git a/peripheral/libupm/src/mpl3115a2/pyupm_mpl3115a2.i b/peripheral/libupm/src/mpl3115a2/pyupm_mpl3115a2.i
index 27bee18..2221d3a 100644
--- a/peripheral/libupm/src/mpl3115a2/pyupm_mpl3115a2.i
+++ b/peripheral/libupm/src/mpl3115a2/pyupm_mpl3115a2.i
@@ -9,7 +9,7 @@
%include "mpl3115a2_doc.i"
#endif
-%include "mpl3115a2.hpp"
+%include "mpl3115a2.h"
%{
- #include "mpl3115a2.hpp"
+ #include "mpl3115a2.h"
%}
diff --git a/peripheral/libupm/src/mpr121/CMakeLists.txt b/peripheral/libupm/src/mpr121/CMakeLists.txt
index 669a59e..e4ffacb 100644
--- a/peripheral/libupm/src/mpr121/CMakeLists.txt
+++ b/peripheral/libupm/src/mpr121/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "mpr121")
set (libdescription "upm mpr121 I2C Touch module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/mpr121/javaupm_mpr121.i b/peripheral/libupm/src/mpr121/javaupm_mpr121.i
index 7e2a7ee..8f1e146 100644
--- a/peripheral/libupm/src/mpr121/javaupm_mpr121.i
+++ b/peripheral/libupm/src/mpr121/javaupm_mpr121.i
@@ -4,10 +4,10 @@
%include "../java_buffer.i"
%{
- #include "mpr121.hpp"
+ #include "mpr121.h"
%}
-%include "mpr121.hpp"
+%include "mpr121.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/mpr121/jsupm_mpr121.i b/peripheral/libupm/src/mpr121/jsupm_mpr121.i
index a1a14d0..d725fd2 100644
--- a/peripheral/libupm/src/mpr121/jsupm_mpr121.i
+++ b/peripheral/libupm/src/mpr121/jsupm_mpr121.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "mpr121.hpp"
+ #include "mpr121.h"
%}
-%include "mpr121.hpp"
+%include "mpr121.h"
diff --git a/peripheral/libupm/src/mpr121/mpr121.cxx b/peripheral/libupm/src/mpr121/mpr121.cxx
index 93a9149..8e7f703 100644
--- a/peripheral/libupm/src/mpr121/mpr121.cxx
+++ b/peripheral/libupm/src/mpr121/mpr121.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "mpr121.hpp"
+#include "mpr121.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/mpr121/mpr121.hpp b/peripheral/libupm/src/mpr121/mpr121.h
index 3b01071..3b01071 100644
--- a/peripheral/libupm/src/mpr121/mpr121.hpp
+++ b/peripheral/libupm/src/mpr121/mpr121.h
diff --git a/peripheral/libupm/src/mpr121/pyupm_mpr121.i b/peripheral/libupm/src/mpr121/pyupm_mpr121.i
index baa8f51..993e0c4 100644
--- a/peripheral/libupm/src/mpr121/pyupm_mpr121.i
+++ b/peripheral/libupm/src/mpr121/pyupm_mpr121.i
@@ -9,7 +9,7 @@
%include "mpr121_doc.i"
#endif
-%include "mpr121.hpp"
+%include "mpr121.h"
%{
- #include "mpr121.hpp"
+ #include "mpr121.h"
%}
diff --git a/peripheral/libupm/src/mpu9150/CMakeLists.txt b/peripheral/libupm/src/mpu9150/CMakeLists.txt
index f77bc5f..816f46c 100644
--- a/peripheral/libupm/src/mpu9150/CMakeLists.txt
+++ b/peripheral/libupm/src/mpu9150/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "mpu9150")
set (libdescription "gyro, acceleromter and magnometer sensor based on mpu9150")
set (module_src ${libname}.cxx ak8975.cxx mpu60x0.cxx mpu9250.cxx)
-set (module_hpp ${libname}.hpp ak8975.hpp mpu60x0.hpp mpu9250.hpp)
+set (module_h ${libname}.h ak8975.h mpu60x0.h mpu9250.h)
upm_module_init()
diff --git a/peripheral/libupm/src/mpu9150/ak8975.cxx b/peripheral/libupm/src/mpu9150/ak8975.cxx
index 83c80aa..7330eb3 100644
--- a/peripheral/libupm/src/mpu9150/ak8975.cxx
+++ b/peripheral/libupm/src/mpu9150/ak8975.cxx
@@ -27,7 +27,7 @@
#include <string>
#include <stdexcept>
-#include "ak8975.hpp"
+#include "ak8975.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/mpu9150/ak8975.hpp b/peripheral/libupm/src/mpu9150/ak8975.h
index ba9788c..ba9788c 100644
--- a/peripheral/libupm/src/mpu9150/ak8975.hpp
+++ b/peripheral/libupm/src/mpu9150/ak8975.h
diff --git a/peripheral/libupm/src/mpu9150/javaupm_mpu9150.i b/peripheral/libupm/src/mpu9150/javaupm_mpu9150.i
index 012afab..0d7c70b 100644
--- a/peripheral/libupm/src/mpu9150/javaupm_mpu9150.i
+++ b/peripheral/libupm/src/mpu9150/javaupm_mpu9150.i
@@ -7,8 +7,8 @@
%apply int {mraa::Edge};
%{
- #include "mpu60x0.hpp"
- #include "mpu9150.hpp"
+ #include "mpu60x0.h"
+ #include "mpu9150.h"
%}
@@ -30,8 +30,8 @@
%ignore getGyroscope(float *, float *, float *);
%ignore getMagnetometer(float *, float *, float *);
-%include "mpu60x0.hpp"
-%include "mpu9150.hpp"
+%include "mpu60x0.h"
+%include "mpu9150.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/mpu9150/jsupm_mpu9150.i b/peripheral/libupm/src/mpu9150/jsupm_mpu9150.i
index f0a728b..b08eb53 100644
--- a/peripheral/libupm/src/mpu9150/jsupm_mpu9150.i
+++ b/peripheral/libupm/src/mpu9150/jsupm_mpu9150.i
@@ -5,26 +5,26 @@
%pointer_functions(float, floatp);
%{
- #include "mpu9150.hpp"
+ #include "mpu9150.h"
%}
-%include "ak8975.hpp"
+%include "ak8975.h"
%{
- #include "ak8975.hpp"
+ #include "ak8975.h"
%}
-%include "mpu60x0.hpp"
+%include "mpu60x0.h"
%{
- #include "mpu60x0.hpp"
+ #include "mpu60x0.h"
%}
-%include "mpu9150.hpp"
+%include "mpu9150.h"
%{
- #include "mpu9150.hpp"
+ #include "mpu9150.h"
%}
-%include "mpu9250.hpp"
+%include "mpu9250.h"
%{
- #include "mpu9250.hpp"
+ #include "mpu9250.h"
%}
diff --git a/peripheral/libupm/src/mpu9150/mpu60x0.cxx b/peripheral/libupm/src/mpu9150/mpu60x0.cxx
index 7962c38..ad79051 100644
--- a/peripheral/libupm/src/mpu9150/mpu60x0.cxx
+++ b/peripheral/libupm/src/mpu9150/mpu60x0.cxx
@@ -26,7 +26,7 @@
#include <iostream>
#include <string.h>
-#include "mpu60x0.hpp"
+#include "mpu60x0.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/mpu9150/mpu60x0.hpp b/peripheral/libupm/src/mpu9150/mpu60x0.h
index 23f292f..1737a69 100644
--- a/peripheral/libupm/src/mpu9150/mpu60x0.hpp
+++ b/peripheral/libupm/src/mpu9150/mpu60x0.h
@@ -851,7 +851,7 @@ namespace upm {
/**
* enable I2C Bypass. Enabling this feature allows devices on the
- * MPU60X0 auxiliary I2C bus to be visible on the MCU's I2C bus.
+ * MPU60X0 auxillary I2C bus to be visible on the MCU's I2C bus.
*
* @param enable true to I2C bypass
* @return true if successful, false otherwise
diff --git a/peripheral/libupm/src/mpu9150/mpu9150.cxx b/peripheral/libupm/src/mpu9150/mpu9150.cxx
index d699466..a253e84 100644
--- a/peripheral/libupm/src/mpu9150/mpu9150.cxx
+++ b/peripheral/libupm/src/mpu9150/mpu9150.cxx
@@ -26,7 +26,7 @@
#include <unistd.h>
#include <stdlib.h>
-#include "mpu9150.hpp"
+#include "mpu9150.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/mpu9150/mpu9150.hpp b/peripheral/libupm/src/mpu9150/mpu9150.h
index b49f6fd..2a53fea 100644
--- a/peripheral/libupm/src/mpu9150/mpu9150.hpp
+++ b/peripheral/libupm/src/mpu9150/mpu9150.h
@@ -24,8 +24,8 @@
#pragma once
-#include "mpu60x0.hpp"
-#include "ak8975.hpp"
+#include "mpu60x0.h"
+#include "ak8975.h"
#define MPU9150_I2C_BUS 0
#define MPU9150_DEFAULT_I2C_ADDR MPU60X0_DEFAULT_I2C_ADDR
@@ -66,11 +66,9 @@ namespace upm {
* @param bus I2C bus to use
* @param address The address for this device
* @param magAddress The address of the connected magnetometer
- * @param enableAk8975 Enables i2c bypass mode for magnetometer, default
- * is true
*/
MPU9150 (int bus=MPU9150_I2C_BUS, int address=MPU9150_DEFAULT_I2C_ADDR,
- int magAddress=AK8975_DEFAULT_I2C_ADDR, bool enableAk8975=true);
+ int magAddress=AK8975_DEFAULT_I2C_ADDR, bool enableAk8975=false);
/**
* MPU9150 destructor
diff --git a/peripheral/libupm/src/mpu9150/mpu9250.cxx b/peripheral/libupm/src/mpu9150/mpu9250.cxx
index e0135a6..c646a98 100644
--- a/peripheral/libupm/src/mpu9150/mpu9250.cxx
+++ b/peripheral/libupm/src/mpu9150/mpu9250.cxx
@@ -26,7 +26,7 @@
#include <unistd.h>
#include <stdlib.h>
-#include "mpu9250.hpp"
+#include "mpu9250.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/mpu9150/mpu9250.hpp b/peripheral/libupm/src/mpu9150/mpu9250.h
index 3b1c50c..c4da944 100644
--- a/peripheral/libupm/src/mpu9150/mpu9250.hpp
+++ b/peripheral/libupm/src/mpu9150/mpu9250.h
@@ -24,7 +24,7 @@
#pragma once
-#include "mpu9150.hpp"
+#include "mpu9150.h"
#define MPU9250_I2C_BUS 0
#define MPU9250_DEFAULT_I2C_ADDR MPU9150_DEFAULT_I2C_ADDR
diff --git a/peripheral/libupm/src/mpu9150/pyupm_mpu9150.i b/peripheral/libupm/src/mpu9150/pyupm_mpu9150.i
index 87fbbfd..0918efb 100644
--- a/peripheral/libupm/src/mpu9150/pyupm_mpu9150.i
+++ b/peripheral/libupm/src/mpu9150/pyupm_mpu9150.i
@@ -10,23 +10,23 @@
%pointer_functions(float, floatp);
-%include "ak8975.hpp"
+%include "ak8975.h"
%{
- #include "ak8975.hpp"
+ #include "ak8975.h"
%}
-%include "mpu60x0.hpp"
+%include "mpu60x0.h"
%{
- #include "mpu60x0.hpp"
+ #include "mpu60x0.h"
%}
-%include "mpu9150.hpp"
+%include "mpu9150.h"
%{
- #include "mpu9150.hpp"
+ #include "mpu9150.h"
%}
-%include "mpu9250.hpp"
+%include "mpu9250.h"
%{
- #include "mpu9250.hpp"
+ #include "mpu9250.h"
%}
diff --git a/peripheral/libupm/src/mq303a/CMakeLists.txt b/peripheral/libupm/src/mq303a/CMakeLists.txt
index 2607608..aae1c75 100644
--- a/peripheral/libupm/src/mq303a/CMakeLists.txt
+++ b/peripheral/libupm/src/mq303a/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "mq303a")
set (libdescription "upm mq303a module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/mq303a/javaupm_mq303a.i b/peripheral/libupm/src/mq303a/javaupm_mq303a.i
index d6aa0dc..da7c5bb 100644
--- a/peripheral/libupm/src/mq303a/javaupm_mq303a.i
+++ b/peripheral/libupm/src/mq303a/javaupm_mq303a.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "mq303a.hpp"
+ #include "mq303a.h"
%}
-%include "mq303a.hpp"
+%include "mq303a.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/mq303a/jsupm_mq303a.i b/peripheral/libupm/src/mq303a/jsupm_mq303a.i
index f254749..857b92a 100644
--- a/peripheral/libupm/src/mq303a/jsupm_mq303a.i
+++ b/peripheral/libupm/src/mq303a/jsupm_mq303a.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "mq303a.hpp"
+ #include "mq303a.h"
%}
-%include "mq303a.hpp"
+%include "mq303a.h"
diff --git a/peripheral/libupm/src/mq303a/mq303a.cxx b/peripheral/libupm/src/mq303a/mq303a.cxx
index 0f5a959..612ffd5 100644
--- a/peripheral/libupm/src/mq303a/mq303a.cxx
+++ b/peripheral/libupm/src/mq303a/mq303a.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "mq303a.hpp"
+#include "mq303a.h"
using namespace upm;
diff --git a/peripheral/libupm/src/mq303a/mq303a.hpp b/peripheral/libupm/src/mq303a/mq303a.h
index 41e5c3b..41e5c3b 100644
--- a/peripheral/libupm/src/mq303a/mq303a.hpp
+++ b/peripheral/libupm/src/mq303a/mq303a.h
diff --git a/peripheral/libupm/src/mq303a/pyupm_mq303a.i b/peripheral/libupm/src/mq303a/pyupm_mq303a.i
index 3d6eec4..4aee330 100644
--- a/peripheral/libupm/src/mq303a/pyupm_mq303a.i
+++ b/peripheral/libupm/src/mq303a/pyupm_mq303a.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "mq303a.hpp"
+%include "mq303a.h"
%{
- #include "mq303a.hpp"
+ #include "mq303a.h"
%}
diff --git a/peripheral/libupm/src/my9221/CMakeLists.txt b/peripheral/libupm/src/my9221/CMakeLists.txt
index 451bc91..dbf8ba6 100644
--- a/peripheral/libupm/src/my9221/CMakeLists.txt
+++ b/peripheral/libupm/src/my9221/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "my9221")
set (libdescription "upm my9221")
set (module_src ${libname}.cxx groveledbar.cxx grovecircularled.cxx)
-set (module_hpp ${libname}.hpp groveledbar.hpp grovecircularled.hpp)
+set (module_h ${libname}.h groveledbar.h grovecircularled.h)
upm_module_init()
diff --git a/peripheral/libupm/src/my9221/grovecircularled.cxx b/peripheral/libupm/src/my9221/grovecircularled.cxx
index 4eba41d..7c89cd6 100644
--- a/peripheral/libupm/src/my9221/grovecircularled.cxx
+++ b/peripheral/libupm/src/my9221/grovecircularled.cxx
@@ -39,7 +39,7 @@
#include <unistd.h>
#include <stdlib.h>
-#include "grovecircularled.hpp"
+#include "grovecircularled.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/my9221/grovecircularled.hpp b/peripheral/libupm/src/my9221/grovecircularled.h
index 0ec7de3..51bc2da 100644
--- a/peripheral/libupm/src/my9221/grovecircularled.hpp
+++ b/peripheral/libupm/src/my9221/grovecircularled.h
@@ -37,7 +37,7 @@
#include <string>
#include <mraa/common.hpp>
#include <mraa/gpio.hpp>
-#include "my9221.hpp"
+#include "my9221.h"
namespace upm {
diff --git a/peripheral/libupm/src/my9221/groveledbar.cxx b/peripheral/libupm/src/my9221/groveledbar.cxx
index c81d0c4..0146a84 100644
--- a/peripheral/libupm/src/my9221/groveledbar.cxx
+++ b/peripheral/libupm/src/my9221/groveledbar.cxx
@@ -39,7 +39,7 @@
#include <unistd.h>
#include <stdlib.h>
-#include "groveledbar.hpp"
+#include "groveledbar.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/my9221/groveledbar.hpp b/peripheral/libupm/src/my9221/groveledbar.h
index 3dbf452..35c8c4d 100644
--- a/peripheral/libupm/src/my9221/groveledbar.hpp
+++ b/peripheral/libupm/src/my9221/groveledbar.h
@@ -38,7 +38,7 @@
#include <mraa/common.hpp>
#include <mraa/gpio.hpp>
-#include "my9221.hpp"
+#include "my9221.h"
namespace upm {
diff --git a/peripheral/libupm/src/my9221/javaupm_my9221.i b/peripheral/libupm/src/my9221/javaupm_my9221.i
index cb98ab2..0534108 100644
--- a/peripheral/libupm/src/my9221/javaupm_my9221.i
+++ b/peripheral/libupm/src/my9221/javaupm_my9221.i
@@ -1,19 +1,19 @@
%module javaupm_my9221
%include "../upm.i"
-%include "my9221.hpp"
+%include "my9221.h"
%{
- #include "my9221.hpp"
+ #include "my9221.h"
%}
-%include "groveledbar.hpp"
+%include "groveledbar.h"
%{
- #include "groveledbar.hpp"
+ #include "groveledbar.h"
%}
-%include "grovecircularled.hpp"
+%include "grovecircularled.h"
%{
- #include "grovecircularled.hpp"
+ #include "grovecircularled.h"
%}
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/my9221/jsupm_my9221.i b/peripheral/libupm/src/my9221/jsupm_my9221.i
index 29df86b..a8e51e7 100644
--- a/peripheral/libupm/src/my9221/jsupm_my9221.i
+++ b/peripheral/libupm/src/my9221/jsupm_my9221.i
@@ -1,18 +1,18 @@
%module jsupm_my9221
%include "../upm.i"
-%include "my9221.hpp"
+%include "my9221.h"
%{
- #include "my9221.hpp"
+ #include "my9221.h"
%}
-%include "groveledbar.hpp"
+%include "groveledbar.h"
%{
- #include "groveledbar.hpp"
+ #include "groveledbar.h"
%}
-%include "grovecircularled.hpp"
+%include "grovecircularled.h"
%{
- #include "grovecircularled.hpp"
+ #include "grovecircularled.h"
%}
diff --git a/peripheral/libupm/src/my9221/my9221.cxx b/peripheral/libupm/src/my9221/my9221.cxx
index 4cb10c6..a5df3fb 100644
--- a/peripheral/libupm/src/my9221/my9221.cxx
+++ b/peripheral/libupm/src/my9221/my9221.cxx
@@ -39,7 +39,7 @@
#include <unistd.h>
#include <stdlib.h>
-#include "my9221.hpp"
+#include "my9221.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/my9221/my9221.hpp b/peripheral/libupm/src/my9221/my9221.h
index 5eebb39..5eebb39 100644
--- a/peripheral/libupm/src/my9221/my9221.hpp
+++ b/peripheral/libupm/src/my9221/my9221.h
diff --git a/peripheral/libupm/src/my9221/pyupm_my9221.i b/peripheral/libupm/src/my9221/pyupm_my9221.i
index 8428619..ee9422a 100644
--- a/peripheral/libupm/src/my9221/pyupm_my9221.i
+++ b/peripheral/libupm/src/my9221/pyupm_my9221.i
@@ -5,17 +5,17 @@
%feature("autodoc", "3");
-%include "my9221.hpp"
+%include "my9221.h"
%{
- #include "my9221.hpp"
+ #include "my9221.h"
%}
-%include "groveledbar.hpp"
+%include "groveledbar.h"
%{
- #include "groveledbar.hpp"
+ #include "groveledbar.h"
%}
-%include "grovecircularled.hpp"
+%include "grovecircularled.h"
%{
- #include "grovecircularled.hpp"
+ #include "grovecircularled.h"
%}
diff --git a/peripheral/libupm/src/nlgpio16/CMakeLists.txt b/peripheral/libupm/src/nlgpio16/CMakeLists.txt
index a9f33db..585c781 100644
--- a/peripheral/libupm/src/nlgpio16/CMakeLists.txt
+++ b/peripheral/libupm/src/nlgpio16/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "nlgpio16")
set (libdescription "upm module for the Numato Labs GPIO 16 USB")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/nlgpio16/javaupm_nlgpio16.i b/peripheral/libupm/src/nlgpio16/javaupm_nlgpio16.i
index f741c3a..481df82 100644
--- a/peripheral/libupm/src/nlgpio16/javaupm_nlgpio16.i
+++ b/peripheral/libupm/src/nlgpio16/javaupm_nlgpio16.i
@@ -4,10 +4,10 @@
%include "std_string.i"
%{
- #include "nlgpio16.hpp"
+ #include "nlgpio16.h"
%}
-%include "nlgpio16.hpp"
+%include "nlgpio16.h"
%array_class(char, charArray);
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/nlgpio16/jsupm_nlgpio16.i b/peripheral/libupm/src/nlgpio16/jsupm_nlgpio16.i
index a5118b2..d44e4d9 100644
--- a/peripheral/libupm/src/nlgpio16/jsupm_nlgpio16.i
+++ b/peripheral/libupm/src/nlgpio16/jsupm_nlgpio16.i
@@ -4,8 +4,8 @@
%include "std_string.i"
%{
- #include "nlgpio16.hpp"
+ #include "nlgpio16.h"
%}
-%include "nlgpio16.hpp"
+%include "nlgpio16.h"
%array_class(char, charArray);
diff --git a/peripheral/libupm/src/nlgpio16/nlgpio16.cxx b/peripheral/libupm/src/nlgpio16/nlgpio16.cxx
index 466af88..591dece 100644
--- a/peripheral/libupm/src/nlgpio16/nlgpio16.cxx
+++ b/peripheral/libupm/src/nlgpio16/nlgpio16.cxx
@@ -25,7 +25,7 @@
#include <iostream>
#include <time.h>
-#include "nlgpio16.hpp"
+#include "nlgpio16.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/nlgpio16/nlgpio16.hpp b/peripheral/libupm/src/nlgpio16/nlgpio16.h
index fa65276..4070690 100644
--- a/peripheral/libupm/src/nlgpio16/nlgpio16.hpp
+++ b/peripheral/libupm/src/nlgpio16/nlgpio16.h
@@ -177,8 +177,8 @@ namespace upm {
/**
* Set the driection mode (input or output) for all gpios enabled
- * by gpioSetIOMask(). A 0 in a given bit position (LSB = gpio0)
- * configures the gpio as an output, and a 1 bit configures the
+ * by gpioSetIOMask(). A 0 in a given bit postion (LSB = gpio0)
+ * configures the gpio as an ouput, and a 1 bit configures the
* gpio as an input. Only the gpios enabled by gpioSetMask() are
* affected by this call.
*
@@ -211,7 +211,7 @@ namespace upm {
/**
* Read the raw analog input value present at the given gpio and
- * return the corresponding voltage value at the pin. The gpio is
+ * return the coresponding voltage value at the pin. The gpio is
* switched to analog input mode by this call, regardless of any
* previous mode. The returned value will be a number between
* 0.0-3.3, depending on the voltage present at the pin. Only the
diff --git a/peripheral/libupm/src/nlgpio16/pyupm_nlgpio16.i b/peripheral/libupm/src/nlgpio16/pyupm_nlgpio16.i
index 823d0c2..e268375 100644
--- a/peripheral/libupm/src/nlgpio16/pyupm_nlgpio16.i
+++ b/peripheral/libupm/src/nlgpio16/pyupm_nlgpio16.i
@@ -8,7 +8,7 @@
%feature("autodoc", "3");
%{
- #include "nlgpio16.hpp"
+ #include "nlgpio16.h"
%}
-%include "nlgpio16.hpp"
+%include "nlgpio16.h"
%array_class(char, charArray);
diff --git a/peripheral/libupm/src/nrf24l01/CMakeLists.txt b/peripheral/libupm/src/nrf24l01/CMakeLists.txt
index 46ebe24..538d3a1 100644
--- a/peripheral/libupm/src/nrf24l01/CMakeLists.txt
+++ b/peripheral/libupm/src/nrf24l01/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "nrf24l01")
set (libdescription "libupm NRF tx/rx")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/nrf24l01/Callback.hpp b/peripheral/libupm/src/nrf24l01/Callback.h
index 3e0cd96..3e0cd96 100644
--- a/peripheral/libupm/src/nrf24l01/Callback.hpp
+++ b/peripheral/libupm/src/nrf24l01/Callback.h
diff --git a/peripheral/libupm/src/nrf24l01/javaupm_nrf24l01.i b/peripheral/libupm/src/nrf24l01/javaupm_nrf24l01.i
index d3e32b9..a78cbc3 100644
--- a/peripheral/libupm/src/nrf24l01/javaupm_nrf24l01.i
+++ b/peripheral/libupm/src/nrf24l01/javaupm_nrf24l01.i
@@ -7,12 +7,12 @@ SWIG_DIRECTOR_OWNED(Callback)
%include "arrays_java.i";
%apply signed char[] {uint8_t *};
-%include "Callback.hpp"
+%include "Callback.h"
%{
- #include "nrf24l01.hpp"
+ #include "nrf24l01.h"
%}
-%include "nrf24l01.hpp"
+%include "nrf24l01.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/nrf24l01/jsupm_nrf24l01.i b/peripheral/libupm/src/nrf24l01/jsupm_nrf24l01.i
index 71ed709..2be49ab 100644
--- a/peripheral/libupm/src/nrf24l01/jsupm_nrf24l01.i
+++ b/peripheral/libupm/src/nrf24l01/jsupm_nrf24l01.i
@@ -1,9 +1,8 @@
%module jsupm_nrf24l01
%include "../upm.i"
-%include "../carrays_uint8_t.i"
%{
- #include "nrf24l01.hpp"
+ #include "nrf24l01.h"
%}
-%include "nrf24l01.hpp"
+%include "nrf24l01.h"
diff --git a/peripheral/libupm/src/nrf24l01/nrf24l01.cxx b/peripheral/libupm/src/nrf24l01/nrf24l01.cxx
index 57092da..1b8b702 100644
--- a/peripheral/libupm/src/nrf24l01/nrf24l01.cxx
+++ b/peripheral/libupm/src/nrf24l01/nrf24l01.cxx
@@ -29,7 +29,7 @@
#include <stdexcept>
#include <stdlib.h>
-#include "nrf24l01.hpp"
+#include "nrf24l01.h"
using namespace upm;
diff --git a/peripheral/libupm/src/nrf24l01/nrf24l01.hpp b/peripheral/libupm/src/nrf24l01/nrf24l01.h
index 9a38662..0a468b8 100644
--- a/peripheral/libupm/src/nrf24l01/nrf24l01.hpp
+++ b/peripheral/libupm/src/nrf24l01/nrf24l01.h
@@ -34,7 +34,7 @@
#include <cstring>
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
-#include "Callback.hpp"
+#include "Callback.h"
#endif
/* Memory Map */
diff --git a/peripheral/libupm/src/nrf24l01/pyupm_nrf24l01.i b/peripheral/libupm/src/nrf24l01/pyupm_nrf24l01.i
index 1cb91ea..55d8f43 100644
--- a/peripheral/libupm/src/nrf24l01/pyupm_nrf24l01.i
+++ b/peripheral/libupm/src/nrf24l01/pyupm_nrf24l01.i
@@ -2,11 +2,10 @@
%include "pyupm_doxy2swig.i"
%module pyupm_nrf24l01
%include "../upm.i"
-%include "../carrays_uint8_t.i"
%feature("autodoc", "3");
-%include "nrf24l01.hpp"
+%include "nrf24l01.h"
%{
- #include "nrf24l01.hpp"
+ #include "nrf24l01.h"
%}
diff --git a/peripheral/libupm/src/nrf8001/CMakeLists.txt b/peripheral/libupm/src/nrf8001/CMakeLists.txt
index 15c606b..a449e44 100644
--- a/peripheral/libupm/src/nrf8001/CMakeLists.txt
+++ b/peripheral/libupm/src/nrf8001/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "nrf8001")
set (libdescription "BLE module from NordicSemiconductor family")
set (module_src hal_aci_tl.cpp aci_setup.cpp aci_queue.cpp acilib.cpp lib_aci.cpp ${libname}.cxx)
-set (module_hpp hal_aci_tl.h aci_setup.h aci_queue.h acilib.h lib_aci.h ${libname}.hpp)
+set (module_h hal_aci_tl.h aci_setup.h aci_queue.h acilib.h lib_aci.h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/vcap/javaupm_vcap.i b/peripheral/libupm/src/nrf8001/javaupm_nrf8001.i
index da11649..9956b43 100644
--- a/peripheral/libupm/src/vcap/javaupm_vcap.i
+++ b/peripheral/libupm/src/nrf8001/javaupm_nrf8001.i
@@ -1,19 +1,19 @@
-%module javaupm_vcap
+%module javaupm_nrf8001
%include "../upm.i"
-%include "std_string.i"
-%include "vcap.hpp"
%{
- #include "vcap.hpp"
+ #include "nrf8001.h"
%}
+%include "nrf8001.h"
+
%pragma(java) jniclasscode=%{
static {
try {
- System.loadLibrary("javaupm_vcap");
+ System.loadLibrary("javaupm_nrf8001");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. \n" + e);
System.exit(1);
}
}
-%}
+%} \ No newline at end of file
diff --git a/peripheral/libupm/src/nrf8001/jsupm_nrf8001.i b/peripheral/libupm/src/nrf8001/jsupm_nrf8001.i
index d9d710d..cb1aadd 100644
--- a/peripheral/libupm/src/nrf8001/jsupm_nrf8001.i
+++ b/peripheral/libupm/src/nrf8001/jsupm_nrf8001.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "nrf8001.hpp"
+ #include "nrf8001.h"
%}
-%include "nrf8001.hpp"
+%include "nrf8001.h"
diff --git a/peripheral/libupm/src/nrf8001/nrf8001.cxx b/peripheral/libupm/src/nrf8001/nrf8001.cxx
index d7b111b..b771436 100644
--- a/peripheral/libupm/src/nrf8001/nrf8001.cxx
+++ b/peripheral/libupm/src/nrf8001/nrf8001.cxx
@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <stdint.h>
-#include "nrf8001.hpp"
+#include "nrf8001.h"
/**
* Include the services_lock.h to put the setup in the OTP memory of the nRF8001.
diff --git a/peripheral/libupm/src/nrf8001/nrf8001.hpp b/peripheral/libupm/src/nrf8001/nrf8001.h
index a34fcee..a34fcee 100644
--- a/peripheral/libupm/src/nrf8001/nrf8001.hpp
+++ b/peripheral/libupm/src/nrf8001/nrf8001.h
diff --git a/peripheral/libupm/src/nrf8001/pyupm_nrf8001.i b/peripheral/libupm/src/nrf8001/pyupm_nrf8001.i
index 1515c76..a6b5dd5 100644
--- a/peripheral/libupm/src/nrf8001/pyupm_nrf8001.i
+++ b/peripheral/libupm/src/nrf8001/pyupm_nrf8001.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "nrf8001.hpp"
+%include "nrf8001.h"
%{
- #include "nrf8001.hpp"
+ #include "nrf8001.h"
%}
diff --git a/peripheral/libupm/src/nunchuck/CMakeLists.txt b/peripheral/libupm/src/nunchuck/CMakeLists.txt
index 72e4495..7263ec8 100644
--- a/peripheral/libupm/src/nunchuck/CMakeLists.txt
+++ b/peripheral/libupm/src/nunchuck/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "nunchuck")
set (libdescription "upm wii nunchuck module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/nunchuck/javaupm_nunchuck.i b/peripheral/libupm/src/nunchuck/javaupm_nunchuck.i
index 57b0d92..e479d05 100644
--- a/peripheral/libupm/src/nunchuck/javaupm_nunchuck.i
+++ b/peripheral/libupm/src/nunchuck/javaupm_nunchuck.i
@@ -3,10 +3,10 @@
%include "../java_buffer.i"
%{
- #include "nunchuck.hpp"
+ #include "nunchuck.h"
%}
-%include "nunchuck.hpp"
+%include "nunchuck.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/nunchuck/jsupm_nunchuck.i b/peripheral/libupm/src/nunchuck/jsupm_nunchuck.i
index 006895e..2e67267 100644
--- a/peripheral/libupm/src/nunchuck/jsupm_nunchuck.i
+++ b/peripheral/libupm/src/nunchuck/jsupm_nunchuck.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "nunchuck.hpp"
+ #include "nunchuck.h"
%}
-%include "nunchuck.hpp"
+%include "nunchuck.h"
diff --git a/peripheral/libupm/src/nunchuck/nunchuck.cxx b/peripheral/libupm/src/nunchuck/nunchuck.cxx
index a6f00d9..2790deb 100644
--- a/peripheral/libupm/src/nunchuck/nunchuck.cxx
+++ b/peripheral/libupm/src/nunchuck/nunchuck.cxx
@@ -27,7 +27,7 @@
#include <stdexcept>
#include <unistd.h>
-#include "nunchuck.hpp"
+#include "nunchuck.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/nunchuck/nunchuck.hpp b/peripheral/libupm/src/nunchuck/nunchuck.h
index 24d509f..24d509f 100644
--- a/peripheral/libupm/src/nunchuck/nunchuck.hpp
+++ b/peripheral/libupm/src/nunchuck/nunchuck.h
diff --git a/peripheral/libupm/src/nunchuck/pyupm_nunchuck.i b/peripheral/libupm/src/nunchuck/pyupm_nunchuck.i
index cdad26c..091eba6 100644
--- a/peripheral/libupm/src/nunchuck/pyupm_nunchuck.i
+++ b/peripheral/libupm/src/nunchuck/pyupm_nunchuck.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "nunchuck.hpp"
+%include "nunchuck.h"
%{
- #include "nunchuck.hpp"
+ #include "nunchuck.h"
%}
diff --git a/peripheral/libupm/src/otp538u/CMakeLists.txt b/peripheral/libupm/src/otp538u/CMakeLists.txt
index 5b010b0..25004b7 100644
--- a/peripheral/libupm/src/otp538u/CMakeLists.txt
+++ b/peripheral/libupm/src/otp538u/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "otp538u")
set (libdescription "upm otp538u IR temperature sensor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/otp538u/javaupm_otp538u.i b/peripheral/libupm/src/otp538u/javaupm_otp538u.i
index 455c6c5..90703b8 100644
--- a/peripheral/libupm/src/otp538u/javaupm_otp538u.i
+++ b/peripheral/libupm/src/otp538u/javaupm_otp538u.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "otp538u.hpp"
+ #include "otp538u.h"
%}
-%include "otp538u.hpp"
+%include "otp538u.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/otp538u/jsupm_otp538u.i b/peripheral/libupm/src/otp538u/jsupm_otp538u.i
index 038cdb5..f8972ce 100644
--- a/peripheral/libupm/src/otp538u/jsupm_otp538u.i
+++ b/peripheral/libupm/src/otp538u/jsupm_otp538u.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "otp538u.hpp"
+ #include "otp538u.h"
%}
-%include "otp538u.hpp"
+%include "otp538u.h"
diff --git a/peripheral/libupm/src/otp538u/otp538u.cxx b/peripheral/libupm/src/otp538u/otp538u.cxx
index 8fd830c..6231ae3 100644
--- a/peripheral/libupm/src/otp538u/otp538u.cxx
+++ b/peripheral/libupm/src/otp538u/otp538u.cxx
@@ -26,10 +26,10 @@
#include <string>
#include <stdexcept>
-#include "otp538u.hpp"
+#include "otp538u.h"
-#include "thermopile_vt_table.hpp"
-#include "thermister_rt_table.hpp"
+#include "thermopile_vt_table.h"
+#include "thermister_rt_table.h"
using namespace upm;
using namespace std;
@@ -92,10 +92,6 @@ float OTP538U::ambientTemperature()
for (int i=0; i<samples; i++)
{
val = mraa_aio_read(m_aioA);
- if (val == -1) {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": failed to do aio read");
- }
temp += val;
usleep(10000);
}
@@ -157,11 +153,6 @@ float OTP538U::objectTemperature()
for (int i=0; i<samples; i++)
{
val = mraa_aio_read(m_aioO);
- if (val == -1) {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": failed to do aio read.");
- return 0;
- }
temp += val;
usleep(10000);
}
diff --git a/peripheral/libupm/src/otp538u/otp538u.hpp b/peripheral/libupm/src/otp538u/otp538u.h
index cc81719..cc81719 100644
--- a/peripheral/libupm/src/otp538u/otp538u.hpp
+++ b/peripheral/libupm/src/otp538u/otp538u.h
diff --git a/peripheral/libupm/src/otp538u/pyupm_otp538u.i b/peripheral/libupm/src/otp538u/pyupm_otp538u.i
index 764e0e1..cb03b1e 100644
--- a/peripheral/libupm/src/otp538u/pyupm_otp538u.i
+++ b/peripheral/libupm/src/otp538u/pyupm_otp538u.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "otp538u.hpp"
+%include "otp538u.h"
%{
- #include "otp538u.hpp"
+ #include "otp538u.h"
%}
diff --git a/peripheral/libupm/src/otp538u/thermister_rt_table.hpp b/peripheral/libupm/src/otp538u/thermister_rt_table.h
index bb8d3c9..bb8d3c9 100644
--- a/peripheral/libupm/src/otp538u/thermister_rt_table.hpp
+++ b/peripheral/libupm/src/otp538u/thermister_rt_table.h
diff --git a/peripheral/libupm/src/otp538u/thermopile_vt_table.hpp b/peripheral/libupm/src/otp538u/thermopile_vt_table.h
index d97d137..d97d137 100644
--- a/peripheral/libupm/src/otp538u/thermopile_vt_table.hpp
+++ b/peripheral/libupm/src/otp538u/thermopile_vt_table.h
diff --git a/peripheral/libupm/src/ozw/CMakeLists.txt b/peripheral/libupm/src/ozw/CMakeLists.txt
index 31fa553..6c67157 100644
--- a/peripheral/libupm/src/ozw/CMakeLists.txt
+++ b/peripheral/libupm/src/ozw/CMakeLists.txt
@@ -1,20 +1,21 @@
set (libname "ozw")
set (libdescription "upm module for the OpenZWave library interface")
set (module_src ${libname}.cxx zwNode.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
-pkg_check_modules(OPENZWAVE libopenzwave)
+pkg_search_module(OPENZWAVE libopenzwave)
if (OPENZWAVE_FOUND)
set (reqlibname "libopenzwave")
include_directories(${OPENZWAVE_INCLUDE_DIRS})
upm_module_init()
+ add_dependencies(${libname} ${OPENZWAVE_LIBRARIES})
target_link_libraries(${libname} ${OPENZWAVE_LIBRARIES})
if (BUILDSWIG)
if (BUILDSWIGNODE)
- swig_link_libraries (jsupm_${libname} ${OPENZWAVE_LIBRARIES})
+ swig_link_libraries (jsupm_${libname} ${OPENZWAVE_LIBRARIES} ${MRAA_LIBRARIES} ${NODE_LIBRARIES})
endif()
if (BUILDSWIGPYTHON)
- swig_link_libraries (pyupm_${libname} ${OPENZWAVE_LIBRARIES})
+ swig_link_libraries (pyupm_${libname} ${OPENZWAVE_LIBRARIES} ${PYTHON_LIBRARIES} ${MRAA_LIBRARIES})
endif()
endif()
endif ()
diff --git a/peripheral/libupm/src/ozw/javaupm_ozw.i b/peripheral/libupm/src/ozw/javaupm_ozw.i
index 3f0d915..1b6ccdc 100644
--- a/peripheral/libupm/src/ozw/javaupm_ozw.i
+++ b/peripheral/libupm/src/ozw/javaupm_ozw.i
@@ -6,10 +6,10 @@
%include "../java_buffer.i"
%{
- #include "ozw.hpp"
+ #include "ozw.h"
%}
-%include "ozw.hpp"
+%include "ozw.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/ozw/jsupm_ozw.i b/peripheral/libupm/src/ozw/jsupm_ozw.i
index b3ad852..209fe62 100644
--- a/peripheral/libupm/src/ozw/jsupm_ozw.i
+++ b/peripheral/libupm/src/ozw/jsupm_ozw.i
@@ -5,8 +5,8 @@
%pointer_functions(float, floatp);
-%include "ozw.hpp"
+%include "ozw.h"
%{
- #include "ozw.hpp"
+ #include "ozw.h"
%}
diff --git a/peripheral/libupm/src/ozw/ozw.cxx b/peripheral/libupm/src/ozw/ozw.cxx
index 02f5e7c..4f8df34 100644
--- a/peripheral/libupm/src/ozw/ozw.cxx
+++ b/peripheral/libupm/src/ozw/ozw.cxx
@@ -30,9 +30,9 @@
#include "platform/Log.h"
-#include "zwNode.hpp"
+#include "zwNode.h"
-#include "ozw.hpp"
+#include "ozw.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/ozw/ozw.hpp b/peripheral/libupm/src/ozw/ozw.h
index d76fdcd..e4f4152 100644
--- a/peripheral/libupm/src/ozw/ozw.hpp
+++ b/peripheral/libupm/src/ozw/ozw.h
@@ -398,7 +398,7 @@ namespace upm {
* library. Most modern devices are never polled, rather they are
* configured to report changing values to the controller on their
* own at device specific intervals or when appropriate events
- * (depending the device) have occurred.
+ * (depending the device) have occured.
*
* @param nodeId The node ID
* @param index The value index (see dumpNodes()) of the value to query.
diff --git a/peripheral/libupm/src/ozw/pyupm_ozw.i b/peripheral/libupm/src/ozw/pyupm_ozw.i
index b05579b..ee987a3 100644
--- a/peripheral/libupm/src/ozw/pyupm_ozw.i
+++ b/peripheral/libupm/src/ozw/pyupm_ozw.i
@@ -10,8 +10,8 @@
%pointer_functions(float, floatp);
-%include "ozw.hpp"
+%include "ozw.h"
%{
- #include "ozw.hpp"
+ #include "ozw.h"
%}
diff --git a/peripheral/libupm/src/ozw/zwNode.cxx b/peripheral/libupm/src/ozw/zwNode.cxx
index 673880d..a55729b 100644
--- a/peripheral/libupm/src/ozw/zwNode.cxx
+++ b/peripheral/libupm/src/ozw/zwNode.cxx
@@ -24,7 +24,7 @@
#include <stdint.h>
#include <string>
-#include "zwNode.hpp"
+#include "zwNode.h"
#include "Node.h"
diff --git a/peripheral/libupm/src/ozw/zwNode.hpp b/peripheral/libupm/src/ozw/zwNode.h
index 0b01dc6..0b01dc6 100644
--- a/peripheral/libupm/src/ozw/zwNode.hpp
+++ b/peripheral/libupm/src/ozw/zwNode.h
diff --git a/peripheral/libupm/src/package.json.in b/peripheral/libupm/src/package.json.in
index 09eb85d..f7c68cd 100644
--- a/peripheral/libupm/src/package.json.in
+++ b/peripheral/libupm/src/package.json.in
@@ -9,7 +9,7 @@
"url": "https://github.com/intel-iot-devkit/upm"
},
"engines" : {
- "node": ">= 4.4.x"
+ "node": ">= 0.10.x"
},
"bugs": {
"url" : "http://github.com/intel-iot-devkit/upm/issues"
diff --git a/peripheral/libupm/src/pca9685/CMakeLists.txt b/peripheral/libupm/src/pca9685/CMakeLists.txt
index 56e6c36..621148f 100644
--- a/peripheral/libupm/src/pca9685/CMakeLists.txt
+++ b/peripheral/libupm/src/pca9685/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "pca9685")
set (libdescription "upm pca9685 I2C 16ch, 12b pwm, LED controller")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/pca9685/javaupm_pca9685.i b/peripheral/libupm/src/pca9685/javaupm_pca9685.i
index ccca3fc..4ff6198 100644
--- a/peripheral/libupm/src/pca9685/javaupm_pca9685.i
+++ b/peripheral/libupm/src/pca9685/javaupm_pca9685.i
@@ -3,10 +3,10 @@
%include "cpointer.i"
%{
- #include "pca9685.hpp"
+ #include "pca9685.h"
%}
-%include "pca9685.hpp"
+%include "pca9685.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/pca9685/jsupm_pca9685.i b/peripheral/libupm/src/pca9685/jsupm_pca9685.i
index db3b629..63515d0 100644
--- a/peripheral/libupm/src/pca9685/jsupm_pca9685.i
+++ b/peripheral/libupm/src/pca9685/jsupm_pca9685.i
@@ -3,7 +3,7 @@
%include "cpointer.i"
%{
- #include "pca9685.hpp"
+ #include "pca9685.h"
%}
-%include "pca9685.hpp"
+%include "pca9685.h"
diff --git a/peripheral/libupm/src/pca9685/pca9685.cxx b/peripheral/libupm/src/pca9685/pca9685.cxx
index 7974598..ce0ae38 100644
--- a/peripheral/libupm/src/pca9685/pca9685.cxx
+++ b/peripheral/libupm/src/pca9685/pca9685.cxx
@@ -28,7 +28,7 @@
#include <string>
#include <stdexcept>
-#include "pca9685.hpp"
+#include "pca9685.h"
using namespace upm;
using namespace std;
@@ -107,20 +107,12 @@ bool PCA9685::writeWord(uint8_t reg, uint16_t word)
uint8_t PCA9685::readByte(uint8_t reg)
{
- int x = mraa_i2c_read_byte_data(m_i2c, reg);
- if (x != -1) {
- return (uint8_t) x;
- }
- return 0;
+ return mraa_i2c_read_byte_data(m_i2c, reg);
}
uint16_t PCA9685::readWord(uint8_t reg)
{
- int x = mraa_i2c_read_word_data(m_i2c, reg);
- if (x != -1) {
- return (uint16_t) x;
- }
- return 0;
+ return mraa_i2c_read_word_data(m_i2c, reg);
}
bool PCA9685::setModeSleep(bool sleep)
diff --git a/peripheral/libupm/src/pca9685/pca9685.hpp b/peripheral/libupm/src/pca9685/pca9685.h
index d7b23cc..d7b23cc 100644
--- a/peripheral/libupm/src/pca9685/pca9685.hpp
+++ b/peripheral/libupm/src/pca9685/pca9685.h
diff --git a/peripheral/libupm/src/pca9685/pyupm_pca9685.i b/peripheral/libupm/src/pca9685/pyupm_pca9685.i
index 2580e7f..dd0b949 100644
--- a/peripheral/libupm/src/pca9685/pyupm_pca9685.i
+++ b/peripheral/libupm/src/pca9685/pyupm_pca9685.i
@@ -9,7 +9,7 @@
%include "pca9685_doc.i"
#endif
-%include "pca9685.hpp"
+%include "pca9685.h"
%{
- #include "pca9685.hpp"
+ #include "pca9685.h"
%}
diff --git a/peripheral/libupm/src/pn532/CMakeLists.txt b/peripheral/libupm/src/pn532/CMakeLists.txt
index 54db39e..a03aeb4 100644
--- a/peripheral/libupm/src/pn532/CMakeLists.txt
+++ b/peripheral/libupm/src/pn532/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "pn532")
set (libdescription "upm pn532 NFC/RFID reader/writer")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/pn532/javaupm_pn532.i b/peripheral/libupm/src/pn532/javaupm_pn532.i
index a833817..ad97bf3 100644
--- a/peripheral/libupm/src/pn532/javaupm_pn532.i
+++ b/peripheral/libupm/src/pn532/javaupm_pn532.i
@@ -10,10 +10,10 @@
%ignore i2cContext;
%{
- #include "pn532.hpp"
+ #include "pn532.h"
%}
-%include "pn532.hpp"
+%include "pn532.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/pn532/jsupm_pn532.i b/peripheral/libupm/src/pn532/jsupm_pn532.i
index 66e5599..9fab172 100644
--- a/peripheral/libupm/src/pn532/jsupm_pn532.i
+++ b/peripheral/libupm/src/pn532/jsupm_pn532.i
@@ -3,7 +3,7 @@
%include "../carrays_uint8_t.i"
%{
- #include "pn532.hpp"
+ #include "pn532.h"
%}
-%include "pn532.hpp"
+%include "pn532.h"
diff --git a/peripheral/libupm/src/pn532/pn532.cxx b/peripheral/libupm/src/pn532/pn532.cxx
index a86ee09..6764d00 100644
--- a/peripheral/libupm/src/pn532/pn532.cxx
+++ b/peripheral/libupm/src/pn532/pn532.cxx
@@ -36,7 +36,7 @@
#undef JAVACALLBACK
#endif
-#include "pn532.hpp"
+#include "pn532.h"
using namespace upm;
using namespace std;
@@ -100,7 +100,7 @@ bool PN532::init()
}
/**************************************************************************/
-/*!
+/*!
@brief Prints a hexadecimal value in plain characters
@param data Pointer to the byte data
@@ -110,7 +110,7 @@ bool PN532::init()
static void PrintHex(const uint8_t * data, const uint32_t numBytes)
{
uint32_t szPos;
- for (szPos=0; szPos < numBytes; szPos++)
+ for (szPos=0; szPos < numBytes; szPos++)
{
fprintf(stderr, "0x%02x ", data[szPos] & 0xff);
}
@@ -118,7 +118,7 @@ static void PrintHex(const uint8_t * data, const uint32_t numBytes)
}
/**************************************************************************/
-/*!
+/*!
@brief Prints a hexadecimal value in plain characters, along with
the char equivalents in the following format
@@ -131,12 +131,12 @@ static void PrintHex(const uint8_t * data, const uint32_t numBytes)
static void PrintHexChar(const uint8_t * data, const uint32_t numBytes)
{
uint32_t szPos;
- for (szPos=0; szPos < numBytes; szPos++)
+ for (szPos=0; szPos < numBytes; szPos++)
{
fprintf(stderr, "0x%02x ", data[szPos] & 0xff);
}
fprintf(stderr, " ");
- for (szPos=0; szPos < numBytes; szPos++)
+ for (szPos=0; szPos < numBytes; szPos++)
{
if (data[szPos] <= 0x1F)
fprintf(stderr, ".");
@@ -148,7 +148,7 @@ static void PrintHexChar(const uint8_t * data, const uint32_t numBytes)
/**************************************************************************/
-/*!
+/*!
@brief Checks the firmware version of the PN5xx chip
@returns The chip's firmware version and ID
@@ -159,13 +159,13 @@ uint32_t PN532::getFirmwareVersion()
uint32_t response = 0;
pn532_packetbuffer[0] = CMD_GETFIRMWAREVERSION;
-
+
if (! sendCommandCheckAck(pn532_packetbuffer, 1))
return 0;
-
+
// read data packet
readData(pn532_packetbuffer, 12);
-
+
int offset = 7; // Skip the ready byte when using I2C
response <<= 8;
@@ -176,7 +176,7 @@ uint32_t PN532::getFirmwareVersion()
response |= pn532_packetbuffer[offset++];
if (response != pn532_firmwarerev)
- fprintf(stderr,
+ fprintf(stderr,
"Warning: firmware revision 0x%08x does not match expected rev 0x%08x\n",
response, pn532_firmwarerev);
@@ -185,29 +185,29 @@ uint32_t PN532::getFirmwareVersion()
/**************************************************************************/
-/*!
+/*!
@brief Sends a command and waits a specified period for the ACK
@param cmd Pointer to the command buffer
- @param cmdlen The size of the command in bytes
+ @param cmdlen The size of the command in bytes
@param timeout timeout before giving up
-
- @returns 1 if everything is OK, 0 if timeout occurred before an
- ACK was received
+
+ @returns 1 if everything is OK, 0 if timeout occured before an
+ ACK was recieved
*/
/**************************************************************************/
// default timeout of one second
-bool PN532::sendCommandCheckAck(uint8_t *cmd, uint8_t cmdlen,
+bool PN532::sendCommandCheckAck(uint8_t *cmd, uint8_t cmdlen,
uint16_t timeout)
{
uint16_t timer = 0;
// clear any outstanding irq's
isReady();
-
+
// write the command
writeCommand(cmd, cmdlen);
-
+
// Wait for chip to say its ready!
if (!waitForReady(timeout)) {
cerr << __FUNCTION__ << ": Not ready, timeout" << endl;
@@ -216,7 +216,7 @@ bool PN532::sendCommandCheckAck(uint8_t *cmd, uint8_t cmdlen,
if (m_pn532Debug)
cerr << __FUNCTION__ << ": IRQ received" << endl;
-
+
// read acknowledgement
if (!readAck()) {
if (m_pn532Debug)
@@ -229,7 +229,7 @@ bool PN532::sendCommandCheckAck(uint8_t *cmd, uint8_t cmdlen,
}
/**************************************************************************/
-/*!
+/*!
@brief Configures the SAM (Secure Access Module)
*/
/**************************************************************************/
@@ -239,24 +239,24 @@ bool PN532::SAMConfig(void)
pn532_packetbuffer[1] = 0x01; // normal mode;
pn532_packetbuffer[2] = 0x14; // timeout 50ms * 20 = 1 second
pn532_packetbuffer[3] = 0x01; // use IRQ pin!
-
+
if (! sendCommandCheckAck(pn532_packetbuffer, 4))
return false;
// read data packet
readData(pn532_packetbuffer, 8);
-
+
int offset = 6;
return (pn532_packetbuffer[offset] == 0x15);
}
/**************************************************************************/
-/*!
+/*!
Sets the MxRtyPassiveActivation byte of the RFConfiguration register
-
+
@param maxRetries 0xFF to wait forever, 0x00..0xFE to timeout
after mxRetries
-
+
@returns 1 if everything executed properly, 0 for an error
*/
/**************************************************************************/
@@ -269,38 +269,38 @@ bool PN532::setPassiveActivationRetries(uint8_t maxRetries)
pn532_packetbuffer[4] = maxRetries;
if (m_mifareDebug)
- cerr << __FUNCTION__ << ": Setting MxRtyPassiveActivation to "
+ cerr << __FUNCTION__ << ": Setting MxRtyPassiveActivation to "
<< (int)maxRetries << endl;
-
+
if (! sendCommandCheckAck(pn532_packetbuffer, 5))
return false; // no ACK
-
+
return true;
}
/***** ISO14443A Commands ******/
/**************************************************************************/
-/*!
+/*!
Waits for an ISO14443A target to enter the field
-
+
@param cardBaudRate Baud rate of the card
@param uid Pointer to the array that will be populated
with the card's UID (up to 7 bytes)
@param uidLength Pointer to the variable that will hold the
length of the card's UID.
-
+
@returns 1 if everything executed properly, 0 for an error
*/
/**************************************************************************/
-bool PN532::readPassiveTargetID(BAUD_T cardbaudrate, uint8_t * uid,
+bool PN532::readPassiveTargetID(BAUD_T cardbaudrate, uint8_t * uid,
uint8_t * uidLength, uint16_t timeout)
{
pn532_packetbuffer[0] = CMD_INLISTPASSIVETARGET;
pn532_packetbuffer[1] = 1; // max 1 cards at once (we can set this
// to 2 later)
pn532_packetbuffer[2] = cardbaudrate;
-
+
if (!sendCommandCheckAck(pn532_packetbuffer, 3, timeout))
{
if (m_pn532Debug)
@@ -319,14 +319,14 @@ bool PN532::readPassiveTargetID(BAUD_T cardbaudrate, uint8_t * uid,
return false;
}
-
+
// read data packet
readData(pn532_packetbuffer, 20);
// check some basic stuff
/* ISO14443A card response should be in the following format:
-
+
byte Description
------------- ------------------------------------------
b0..6 Frame header and preamble
@@ -339,17 +339,17 @@ bool PN532::readPassiveTargetID(BAUD_T cardbaudrate, uint8_t * uid,
// SENS_RES SEL_RES Manufacturer/Card Type NFCID Len
// -------- ------- ----------------------- ---------
- // 00 04 08 NXP Mifare Classic 1K 4 bytes
+ // 00 04 08 NXP Mifare Classic 1K 4 bytes
// 00 02 18 NXP Mifare Classic 4K 4 bytes
-
+
if (m_mifareDebug)
cerr << __FUNCTION__ << ": Found " << (int)pn532_packetbuffer[7] << " tags"
<< endl;
// only one card can be handled currently
- if (pn532_packetbuffer[7] != 1)
+ if (pn532_packetbuffer[7] != 1)
return false;
-
+
uint16_t sens_res = pn532_packetbuffer[9];
sens_res <<= 8;
sens_res |= pn532_packetbuffer[10];
@@ -362,7 +362,7 @@ bool PN532::readPassiveTargetID(BAUD_T cardbaudrate, uint8_t * uid,
if (m_mifareDebug)
{
- fprintf(stderr, "ATQA: 0x%04x\n", m_ATQA);
+ fprintf(stderr, "ATQA: 0x%04x\n", m_ATQA);
fprintf(stderr, "SAK: 0x%02x\n", m_SAK);
}
@@ -371,13 +371,13 @@ bool PN532::readPassiveTargetID(BAUD_T cardbaudrate, uint8_t * uid,
*uidLength = pn532_packetbuffer[12];
if (m_mifareDebug)
- fprintf(stderr, "UID: ");
+ fprintf(stderr, "UID: ");
- for (uint8_t i=0; i < pn532_packetbuffer[12]; i++)
+ for (uint8_t i=0; i < pn532_packetbuffer[12]; i++)
{
uid[i] = pn532_packetbuffer[13+i];
if (m_mifareDebug)
- fprintf(stderr, "0x%02x ", uid[i]);
+ fprintf(stderr, "0x%02x ", uid[i]);
}
if (m_mifareDebug)
fprintf(stderr, "\n");
@@ -386,7 +386,7 @@ bool PN532::readPassiveTargetID(BAUD_T cardbaudrate, uint8_t * uid,
}
/**************************************************************************/
-/*!
+/*!
@brief Exchanges an APDU with the currently inlisted peer
@param send Pointer to data to send
@@ -406,13 +406,13 @@ bool PN532::inDataExchange(uint8_t * send, uint8_t sendLength,
return false;
}
uint8_t i;
-
+
pn532_packetbuffer[0] = CMD_INDATAEXCHANGE; // 0x40
pn532_packetbuffer[1] = m_inListedTag;
for (i=0; i<sendLength; ++i) {
pn532_packetbuffer[i+2] = send[i];
}
-
+
if (!sendCommandCheckAck(pn532_packetbuffer,sendLength+2,1000)) {
if (m_pn532Debug)
cerr << __FUNCTION__ << ": Could not send ADPU" << endl;
@@ -428,11 +428,11 @@ bool PN532::inDataExchange(uint8_t * send, uint8_t sendLength,
}
readData(pn532_packetbuffer, sizeof(pn532_packetbuffer));
-
+
if (pn532_packetbuffer[0] == 0 && pn532_packetbuffer[1] == 0 &&
pn532_packetbuffer[2] == 0xff)
{
-
+
uint8_t length = pn532_packetbuffer[3];
if (pn532_packetbuffer[4]!=(uint8_t)(~length+1))
{
@@ -442,37 +442,37 @@ bool PN532::inDataExchange(uint8_t * send, uint8_t sendLength,
return false;
}
- if (pn532_packetbuffer[5]==PN532_PN532TOHOST &&
+ if (pn532_packetbuffer[5]==PN532_PN532TOHOST &&
pn532_packetbuffer[6]==RSP_INDATAEXCHANGE)
{
if ((pn532_packetbuffer[7] & 0x3f)!=0)
{
if (m_pn532Debug)
- cerr << __FUNCTION__ << ": Status code indicates an error"
+ cerr << __FUNCTION__ << ": Status code indicates an error"
<< endl;
return false;
}
-
+
length -= 3;
-
+
if (length > *responseLength) {
length = *responseLength; // silent truncation...
}
-
+
for (i=0; i<length; ++i) {
response[i] = pn532_packetbuffer[8+i];
}
*responseLength = length;
-
+
return true;
- }
+ }
else {
fprintf(stderr, "Don't know how to handle this command: 0x%02x\n",
pn532_packetbuffer[6]);
return false;
- }
- }
+ }
+ }
else {
cerr << __FUNCTION__ << ": Preamble missing" << endl;
return false;
@@ -480,19 +480,19 @@ bool PN532::inDataExchange(uint8_t * send, uint8_t sendLength,
}
/**************************************************************************/
-/*!
+/*!
@brief 'InLists' a passive target. PN532 acting as reader/initiator,
peer acting as card/responder.
*/
/**************************************************************************/
-bool PN532::inListPassiveTarget()
+bool PN532::inListPassiveTarget()
{
m_inListedTag = 0;
pn532_packetbuffer[0] = CMD_INLISTPASSIVETARGET;
pn532_packetbuffer[1] = 1;
pn532_packetbuffer[2] = 0;
-
+
if (m_pn532Debug)
cerr << __FUNCTION__ << ": About to inList passive target" << endl;
@@ -508,8 +508,8 @@ bool PN532::inListPassiveTarget()
}
readData(pn532_packetbuffer, sizeof(pn532_packetbuffer));
-
- if (pn532_packetbuffer[0] == 0 && pn532_packetbuffer[1] == 0 &&
+
+ if (pn532_packetbuffer[0] == 0 && pn532_packetbuffer[1] == 0 &&
pn532_packetbuffer[2] == 0xff) {
uint8_t length = pn532_packetbuffer[3];
@@ -520,18 +520,18 @@ bool PN532::inListPassiveTarget()
return false;
}
- if (pn532_packetbuffer[5]==PN532_PN532TOHOST &&
+ if (pn532_packetbuffer[5]==PN532_PN532TOHOST &&
pn532_packetbuffer[6]==RSP_INLISTPASSIVETARGET) {
if (pn532_packetbuffer[7] != 1) {
cerr << __FUNCTION__ << ": Unhandled number of tags inlisted: "
<< (int)pn532_packetbuffer[7] << endl;
return false;
}
-
+
m_inListedTag = pn532_packetbuffer[8];
if (m_pn532Debug)
cerr << __FUNCTION__ << ": Tag number: " << (int)m_inListedTag << endl;
-
+
return true;
} else {
if (m_pn532Debug)
@@ -539,8 +539,8 @@ bool PN532::inListPassiveTarget()
<< endl;
return false;
- }
- }
+ }
+ }
else {
if (m_pn532Debug)
cerr << __FUNCTION__ << ": Preamble missing" << endl;
@@ -564,13 +564,13 @@ bool PN532::inListPassiveTarget()
MF1S503x Mifare Classic 1K data sheet:
http://www.nxp.com/documents/data_sheet/MF1S503x.pdf
-
+
MF1S70yyX MIFARE Classic 4K data sheet:
http://www.nxp.com/documents/data_sheet/MF1S70YYX.pdf
Mifare Classic cards typically have a a 4-byte NUID, though you may
find cards with 7 byte IDs as well
-
+
EEPROM MEMORY
=============
Mifare Classic cards have either 1K or 4K of EEPROM memory. Each
@@ -625,12 +625,12 @@ bool PN532::inListPassiveTarget()
configure them as "Value Blocks". Value blocks allow performing electronic
purse functions (valid commands are: read, write, increment, decrement,
restore, transfer).
-
+
Each Value block contains a single signed 32-bit value, and this value is
stored 3 times for data integrity and security reasons. It is stored twice
non-inverted, and once inverted. The last 4 bytes are used for a 1-byte
address, which is stored 4 times (twice non-inverted, and twice inverted).
-
+
Data blocks configured as "Value Blocks" have the following structure:
Value Block Bytes
@@ -674,7 +674,7 @@ bool PN532::inListPassiveTarget()
access rules defined in the Sector Trailer block for that sector.
This can be done using pn532_mifareclassic_AuthenticateBlock(),
passing in the appropriate key value.
-
+
Most new cards have a default Key A of 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF,
but some common values worth trying are:
@@ -695,7 +695,7 @@ bool PN532::inListPassiveTarget()
*/
/**************************************************************************/
-/*!
+/*!
Indicates whether the specified block number is the first block
in the sector (block 0 relative to the current sector)
*/
@@ -710,7 +710,7 @@ bool PN532::mifareclassic_IsFirstBlock (uint32_t uiBlock)
}
/**************************************************************************/
-/*!
+/*!
Indicates whether the specified block number is the sector trailer
*/
/**************************************************************************/
@@ -724,7 +724,7 @@ bool PN532::mifareclassic_IsTrailerBlock (uint32_t uiBlock)
}
/**************************************************************************/
-/*!
+/*!
Tries to authenticate a block of memory on a MIFARE card using the
INDATAEXCHANGE command. See section 7.3.8 of the PN532 User Manual
for more information on sending MIFARE and other commands.
@@ -738,7 +738,7 @@ bool PN532::mifareclassic_IsTrailerBlock (uint32_t uiBlock)
(0 = MIFARE_CMD_AUTH_A, 1 = MIFARE_CMD_AUTH_B)
@param keyData Pointer to a byte array containing the 6 byte
key value
-
+
@returns 1 if everything executed properly, 0 for an error
*/
/**************************************************************************/
@@ -749,21 +749,21 @@ bool PN532::mifareclassic_AuthenticateBlock (uint8_t * uid, uint8_t uidLen,
{
uint8_t len;
uint8_t i;
-
+
// Hang on to the key and uid data
memcpy (m_key, keyData, 6);
memcpy (m_uid, uid, uidLen);
- m_uidLen = uidLen;
-
+ m_uidLen = uidLen;
+
if (m_mifareDebug)
{
fprintf(stderr, "Trying to authenticate card ");
PrintHex(m_uid, m_uidLen);
- fprintf(stderr, "Using authentication KEY %c: ",
+ fprintf(stderr, "Using authentication KEY %c: ",
keyNumber ? 'B' : 'A');
PrintHex(m_key, 6);
}
-
+
// Prepare the authentication command //
pn532_packetbuffer[0] = CMD_INDATAEXCHANGE; /* Data Exchange Header */
pn532_packetbuffer[1] = 1; /* Max card numbers */
@@ -779,10 +779,10 @@ bool PN532::mifareclassic_AuthenticateBlock (uint8_t * uid, uint8_t uidLen,
{
pn532_packetbuffer[10+i] = m_uid[i]; /* 4 byte card ID */
}
-
+
if (! sendCommandCheckAck(pn532_packetbuffer, 10+m_uidLen))
return false;
-
+
if (!waitForReady(1000)) {
if (m_pn532Debug)
cerr << __FUNCTION__ << ": timeout waiting auth..." << endl;
@@ -792,7 +792,7 @@ bool PN532::mifareclassic_AuthenticateBlock (uint8_t * uid, uint8_t uidLen,
// Read the response packet
readData(pn532_packetbuffer, 12);
-
+
// check if the response is valid and we are authenticated???
// for an auth success it should be bytes 5-7: 0xD5 0x41 0x00
// Mifare auth error is technically byte 7: 0x14 but anything other
@@ -807,12 +807,12 @@ bool PN532::mifareclassic_AuthenticateBlock (uint8_t * uid, uint8_t uidLen,
return false;
}
-
+
return true;
}
/**************************************************************************/
-/*!
+/*!
Tries to read an entire 16-byte data block at the specified block
address.
@@ -820,16 +820,16 @@ bool PN532::mifareclassic_AuthenticateBlock (uint8_t * uid, uint8_t uidLen,
1KB cards, and 0..255 for 4KB cards).
@param data Pointer to the byte array that will hold the
retrieved data (if any)
-
+
@returns 1 if everything executed properly, 0 for an error
*/
/**************************************************************************/
bool PN532::mifareclassic_ReadDataBlock (uint8_t blockNumber, uint8_t * data)
{
if (m_mifareDebug)
- cerr << __FUNCTION__ << ": Trying to read 16 bytes from block "
+ cerr << __FUNCTION__ << ": Trying to read 16 bytes from block "
<< (int)blockNumber << endl;
-
+
/* Prepare the command */
pn532_packetbuffer[0] = CMD_INDATAEXCHANGE;
pn532_packetbuffer[1] = 1; /* Card number */
@@ -838,20 +838,20 @@ bool PN532::mifareclassic_ReadDataBlock (uint8_t blockNumber, uint8_t * data)
pn532_packetbuffer[3] = blockNumber; /* Block Number
(0..63 for 1K,
0..255 for 4K) */
-
+
/* Send the command */
if (! sendCommandCheckAck(pn532_packetbuffer, 4))
{
if (m_mifareDebug)
- cerr << __FUNCTION__ << ": Failed to receive ACK for read command"
+ cerr << __FUNCTION__ << ": Failed to receive ACK for read command"
<< endl;
return false;
}
-
+
/* Read the response packet */
readData(pn532_packetbuffer, 26);
-
+
/* If byte 8 isn't 0x00 we probably have an error */
if (pn532_packetbuffer[7] != 0x00)
{
@@ -862,30 +862,30 @@ bool PN532::mifareclassic_ReadDataBlock (uint8_t blockNumber, uint8_t * data)
}
return false;
}
-
+
/* Copy the 16 data bytes to the output buffer */
/* Block content starts at byte 9 of a valid response */
memcpy (data, pn532_packetbuffer+8, 16);
-
+
/* Display data for debug if requested */
if (m_mifareDebug)
{
fprintf(stderr, "Block %d: ", blockNumber);
PrintHexChar(data, 16);
}
-
+
return true;
}
/**************************************************************************/
-/*!
+/*!
Tries to write an entire 16-byte data block at the specified block
address.
@param blockNumber The block number to authenticate. (0..63 for
1KB cards, and 0..255 for 4KB cards).
@param data The byte array that contains the data to write.
-
+
@returns 1 if everything executed properly, 0 for an error
*/
/**************************************************************************/
@@ -893,7 +893,7 @@ bool PN532::mifareclassic_WriteDataBlock (uint8_t blockNumber, uint8_t * data)
{
if (m_mifareDebug)
fprintf(stderr, "Trying to write 16 bytes to block %d\n", blockNumber);
-
+
/* Prepare the first command */
pn532_packetbuffer[0] = CMD_INDATAEXCHANGE;
pn532_packetbuffer[1] = 1; /* Card number */
@@ -903,7 +903,7 @@ bool PN532::mifareclassic_WriteDataBlock (uint8_t blockNumber, uint8_t * data)
(0..63 for 1K,
0..255 for 4K) */
memcpy (pn532_packetbuffer+4, data, 16); /* Data Payload */
-
+
/* Send the command */
if (! sendCommandCheckAck(pn532_packetbuffer, 20))
{
@@ -912,25 +912,25 @@ bool PN532::mifareclassic_WriteDataBlock (uint8_t blockNumber, uint8_t * data)
<< endl;
return false;
- }
+ }
usleep(10000);
-
+
/* Read the response packet */
readData(pn532_packetbuffer, 26);
-
+
return true;
}
/**************************************************************************/
-/*!
- Formats a Mifare Classic card to store NDEF Records
-
+/*!
+ Formats a Mifare Classic card to store NDEF Records
+
@returns 1 if everything executed properly, 0 for an error
*/
/**************************************************************************/
bool PN532::mifareclassic_FormatNDEF (void)
{
- uint8_t sectorbuffer1[16] = {0x14, 0x01, 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
+ uint8_t sectorbuffer1[16] = {0x14, 0x01, 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1};
uint8_t sectorbuffer2[16] = {0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1};
@@ -954,9 +954,9 @@ bool PN532::mifareclassic_FormatNDEF (void)
}
/**************************************************************************/
-/*!
+/*!
Writes an NDEF URI Record to the specified sector (1..15)
-
+
Note that this function assumes that the Mifare Classic card is
already formatted to work as an "NFC Forum Tag" and uses a MAD1
file system. You can use the NXP TagWriter app on Android to
@@ -964,14 +964,14 @@ bool PN532::mifareclassic_FormatNDEF (void)
@param sectorNumber The sector that the URI record should be written
to (can be 1..15 for a 1K card)
- @param uriIdentifier The uri identifier code (0 = none, 0x01 =
+ @param uriIdentifier The uri identifier code (0 = none, 0x01 =
"http://www.", etc.)
@param url The uri text to write (max 38 characters).
-
+
@returns 1 if everything executed properly, 0 for an error
*/
/**************************************************************************/
-bool PN532::mifareclassic_WriteNDEFURI (uint8_t sectorNumber,
+bool PN532::mifareclassic_WriteNDEFURI (uint8_t sectorNumber,
NDEF_URI_T uriIdentifier,
const char * url)
{
@@ -980,32 +980,31 @@ bool PN532::mifareclassic_WriteNDEFURI (uint8_t sectorNumber,
// Figure out how long the string is
uint8_t len = strlen(url);
-
+
// Make sure we're within a 1K limit for the sector number
if ((sectorNumber < 1) || (sectorNumber > 15))
return false;
-
+
// Make sure the URI payload is between 1 and 38 chars
if ((len < 1) || (len > 38))
return false;
// Note 0xD3 0xF7 0xD3 0xF7 0xD3 0xF7 must be used for key A
// in NDEF records
-
+
// Setup the sector buffer (w/pre-formatted TLV wrapper and NDEF message)
uint8_t sectorbuffer1[16] = {0x00, 0x00, 0x03, static_cast<uint8_t>(len+5),
- 0xD1, 0x01, static_cast<uint8_t>(len+1),
- 0x55, static_cast<uint8_t>(uriIdentifier),
- 0x00, 0x00, 0x00, 0x00,
+ 0xD1, 0x01, static_cast<uint8_t>(len+1),
+ 0x55, static_cast<uint8_t>(uriIdentifier), 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00};
- uint8_t sectorbuffer2[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ uint8_t sectorbuffer2[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00};
- uint8_t sectorbuffer3[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ uint8_t sectorbuffer3[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00};
- uint8_t sectorbuffer4[16] = {0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7, 0x7F,
- 0x07, 0x88, 0x40, 0xFF, 0xFF, 0xFF, 0xFF,
+ uint8_t sectorbuffer4[16] = {0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7, 0x7F,
+ 0x07, 0x88, 0x40, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF};
if (len <= 6)
{
@@ -1041,7 +1040,7 @@ bool PN532::mifareclassic_WriteNDEFURI (uint8_t sectorNumber,
memcpy (sectorbuffer3, url+23, len-24);
sectorbuffer3[len-23] = 0xFE;
}
-
+
// Now write all three blocks back to the card
if (!(mifareclassic_WriteDataBlock (sectorNumber*4, sectorbuffer1)))
return false;
@@ -1073,10 +1072,10 @@ bool PN532::mifareclassic_WriteNDEFURI (uint8_t sectorNumber,
MF0ICU1 Mifare Ultralight Functional Specification:
http://www.nxp.com/documents/data_sheet/MF0ICU1.pdf
-
+
Mifare Ultralight cards have a 7-byte UID
-
+
EEPROM MEMORY
=============
Mifare Ultralight cards have 512 bits (64 bytes) of EEPROM memory,
@@ -1116,7 +1115,7 @@ bool PN532::mifareclassic_WriteNDEFURI (uint8_t sectorNumber,
Data Pages (Pages 4..15)
------------------------
- Pages 4 to 15 are can be freely read from and written to,
+ Pages 4 to 15 are can be freely read from and written to,
provided there is no conflict with the Lock Bytes described above.
After production, the bytes have the following default values:
@@ -1143,7 +1142,7 @@ bool PN532::mifareclassic_WriteNDEFURI (uint8_t sectorNumber,
/**************************************************************************/
-/*!
+/*!
Tries to read an entire 4-byte page at the specified address.
@param page The page number (0..63 in most cases)
@@ -1159,7 +1158,7 @@ bool PN532::ntag2xx_ReadPage (uint8_t page, uint8_t * buffer)
// NTAG 213 45 4 39
// NTAG 215 135 4 129
// NTAG 216 231 4 225
-
+
if (page >= 231)
{
cerr << __FUNCTION__ << ": Page value out of range" << endl;
@@ -1185,7 +1184,7 @@ bool PN532::ntag2xx_ReadPage (uint8_t page, uint8_t * buffer)
return false;
}
-
+
/* Read the response packet */
readData(pn532_packetbuffer, 26);
@@ -1228,14 +1227,14 @@ bool PN532::ntag2xx_ReadPage (uint8_t page, uint8_t * buffer)
}
/**************************************************************************/
-/*!
+/*!
Tries to write an entire 4-byte page at the specified block
address.
@param page The page number to write. (0..63 for most cases)
@param data The byte array that contains the data to write.
Should be exactly 4 bytes long.
-
+
@returns 1 if everything executed properly, 0 for an error
*/
/**************************************************************************/
@@ -1256,7 +1255,7 @@ bool PN532::ntag2xx_WritePage (uint8_t page, uint8_t * data)
if (m_mifareDebug)
fprintf(stderr, "Trying to write 4 byte page %d\n", page);
-
+
/* Prepare the first command */
pn532_packetbuffer[0] = CMD_INDATAEXCHANGE;
pn532_packetbuffer[1] = 1; /* Card number */
@@ -1277,46 +1276,46 @@ bool PN532::ntag2xx_WritePage (uint8_t page, uint8_t * data)
// Return Failed Signal
return false;
- }
+ }
usleep(10000);
-
+
/* Read the response packet */
readData(pn532_packetbuffer, 26);
-
+
// Return OK Signal
return true;
}
/**************************************************************************/
-/*!
+/*!
Writes an NDEF URI Record starting at the specified page (4..nn)
-
+
Note that this function assumes that the NTAG2xx card is
already formatted to work as an "NFC Forum Tag".
- @param uriIdentifier The uri identifier code (0 = none, 0x01 =
+ @param uriIdentifier The uri identifier code (0 = none, 0x01 =
"http://www.", etc.)
@param url The uri text to write (null-terminated string).
@param dataLen The size of the data area for overflow checks.
-
+
@returns 1 if everything executed properly, 0 for an error
*/
/**************************************************************************/
-bool PN532::ntag2xx_WriteNDEFURI (NDEF_URI_T uriIdentifier, char * url,
+bool PN532::ntag2xx_WriteNDEFURI (NDEF_URI_T uriIdentifier, char * url,
uint8_t dataLen)
{
uint8_t pageBuffer[4] = { 0, 0, 0, 0 };
-
+
// Remove NDEF record overhead from the URI data (pageHeader below)
uint8_t wrapperSize = 12;
-
+
// Figure out how long the string is
uint8_t len = strlen(url);
-
+
// Make sure the URI payload will fit in dataLen (include 0xFE trailer)
if ((len < 1) || (len+1 > (dataLen-wrapperSize)))
return false;
-
+
// Setup the record header
// See NFCForum-TS-Type-2-Tag_1.1.pdf for details
uint8_t pageHeader[12] =
@@ -1332,15 +1331,18 @@ bool PN532::ntag2xx_WriteNDEFURI (NDEF_URI_T uriIdentifier, char * url,
each lock bit can lock (4 bit + 4 bits) */
/* NDEF Message TLV - URI Record */
0x03, /* Tag Field (0x03 = NDEF Message) */
- static_cast<uint8_t>(len+5), /* Payload Length (not including 0xFE trailer) */
+ static_cast<uint8_t>(len+5),
+ /* Payload Length (not including 0xFE trailer) */
0xD1, /* NDEF Record Header (TNF=0x1:Well known record +
SR + ME + MB) */
0x01, /* Type Length for the record type indicator */
- static_cast<uint8_t>(len+1), /* Payload len */
+ static_cast<uint8_t>(len+1),
+ /* Payload len */
0x55, /* Record Type Indicator (0x55 or 'U' = URI Record) */
- static_cast<uint8_t>(uriIdentifier) /* URI Prefix (ex. 0x01 = "http://www.") */
+ static_cast<uint8_t>(uriIdentifier)
+ /* URI Prefix (ex. 0x01 = "http://www.") */
};
-
+
// Write 12 byte header (three pages of data starting at page 4)
memcpy (pageBuffer, pageHeader, 4);
if (!(ntag2xx_WritePage (4, pageBuffer)))
@@ -1351,7 +1353,7 @@ bool PN532::ntag2xx_WriteNDEFURI (NDEF_URI_T uriIdentifier, char * url,
memcpy (pageBuffer, pageHeader+8, 4);
if (!(ntag2xx_WritePage (6, pageBuffer)))
return false;
-
+
// Write URI (starting at page 7)
uint8_t currentPage = 7;
char * urlcopy = url;
@@ -1391,21 +1393,21 @@ bool PN532::ntag2xx_WriteNDEFURI (NDEF_URI_T uriIdentifier, char * url,
len-=4;
}
}
-
+
// Seems that everything was OK (?!)
return true;
}
/**************************************************************************/
-/*!
+/*!
@brief Tries to read/verify the ACK packet
*/
/**************************************************************************/
bool PN532::readAck()
{
uint8_t ackbuff[6];
-
+
readData(ackbuff, 6);
return (0 == memcmp((char *)ackbuff, (char *)pn532ack, 6));
@@ -1413,7 +1415,7 @@ bool PN532::readAck()
/**************************************************************************/
-/*!
+/*!
@brief Return true if the PN532 is ready with a response.
*/
/**************************************************************************/
@@ -1430,7 +1432,7 @@ bool PN532::isReady()
}
/**************************************************************************/
-/*!
+/*!
@brief Waits until the PN532 is ready.
@param timeout Timeout before giving up
@@ -1455,7 +1457,7 @@ bool PN532::waitForReady(uint16_t timeout)
}
/**************************************************************************/
-/*!
+/*!
@brief Reads n bytes of data from the PN532 via SPI or I2C.
@param buff Pointer to the buffer where data will be written
@@ -1468,7 +1470,7 @@ void PN532::readData(uint8_t* buff, uint8_t n)
int rv;
memset(buf, 0, n+2);
- usleep(2000);
+ usleep(2000);
if (m_i2c.address(m_addr) != mraa::SUCCESS)
{
throw std::runtime_error(std::string(__FUNCTION__) +
@@ -1489,7 +1491,7 @@ void PN532::readData(uint8_t* buff, uint8_t n)
for (int i=0; i<n; i++)
buff[i] = buf[i+1];
-
+
if (m_pn532Debug)
{
fprintf(stderr, "(returned) buf (%d) = \n", n);
@@ -1499,12 +1501,12 @@ void PN532::readData(uint8_t* buff, uint8_t n)
}
/**************************************************************************/
-/*!
+/*!
@brief Writes a command to the PN532, automatically inserting the
preamble and required frame details (checksum, len, etc.)
@param cmd Pointer to the command buffer
- @param cmdlen Command length in bytes
+ @param cmdlen Command length in bytes
*/
/**************************************************************************/
void PN532::writeCommand(uint8_t* cmd, uint8_t cmdlen)
@@ -1530,16 +1532,16 @@ void PN532::writeCommand(uint8_t* cmd, uint8_t cmdlen)
buf[offset++] = cmdlen;
buf[offset++] = ~cmdlen + 1;
-
+
buf[offset++] = PN532_HOSTTOPN532;
checksum += PN532_HOSTTOPN532;
- for (uint8_t i=0; i<cmdlen - 1; i++)
+ for (uint8_t i=0; i<cmdlen - 1; i++)
{
buf[offset++] = cmd[i];
checksum += cmd[i];
}
-
+
buf[offset++] = ~checksum;
buf[offset] = PN532_POSTAMBLE;
@@ -1559,12 +1561,12 @@ void PN532::writeCommand(uint8_t* cmd, uint8_t cmdlen)
if (m_pn532Debug)
{
- cerr << __FUNCTION__ << ": cmdlen + 8 = " << cmdlen + 8
+ cerr << __FUNCTION__ << ": cmdlen + 8 = " << cmdlen + 8
<<", offset = " << offset << endl;
PrintHex(buf, cmdlen + 8);
}
-}
+}
void PN532::dataReadyISR(void *ctx)
{
diff --git a/peripheral/libupm/src/pn532/pn532.hpp b/peripheral/libupm/src/pn532/pn532.h
index 0ac7b3a..206eb5b 100644
--- a/peripheral/libupm/src/pn532/pn532.hpp
+++ b/peripheral/libupm/src/pn532/pn532.h
@@ -232,8 +232,8 @@ namespace upm {
* @param cmdlen the size of the command in bytes
* @param timeout timeout before giving up (in ms)
*
- * @return true if everything is OK, false if timeout occurred
- * before an ACK was received
+ * @return true if everything is OK, false if timeout occured
+ * before an ACK was recieved
*/
bool sendCommandCheckAck(uint8_t *cmd, uint8_t cmdlen,
uint16_t timeout=1000);
diff --git a/peripheral/libupm/src/pn532/pyupm_pn532.i b/peripheral/libupm/src/pn532/pyupm_pn532.i
index bccbc35..64bfad3 100644
--- a/peripheral/libupm/src/pn532/pyupm_pn532.i
+++ b/peripheral/libupm/src/pn532/pyupm_pn532.i
@@ -10,7 +10,7 @@
%include "pn532_doc.i"
#endif
-%include "pn532.hpp"
+%include "pn532.h"
%{
- #include "pn532.hpp"
+ #include "pn532.h"
%}
diff --git a/peripheral/libupm/src/ppd42ns/CMakeLists.txt b/peripheral/libupm/src/ppd42ns/CMakeLists.txt
index f7b10af..7cffed1 100644
--- a/peripheral/libupm/src/ppd42ns/CMakeLists.txt
+++ b/peripheral/libupm/src/ppd42ns/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "ppd42ns")
set (libdescription "upm ppd42ns dust sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init("-lrt")
diff --git a/peripheral/libupm/src/ppd42ns/javaupm_ppd42ns.i b/peripheral/libupm/src/ppd42ns/javaupm_ppd42ns.i
index 2be86f7..beecd3e 100644
--- a/peripheral/libupm/src/ppd42ns/javaupm_ppd42ns.i
+++ b/peripheral/libupm/src/ppd42ns/javaupm_ppd42ns.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "ppd42ns.hpp"
+ #include "ppd42ns.h"
%}
-%include "ppd42ns.hpp"
+%include "ppd42ns.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/ppd42ns/jsupm_ppd42ns.i b/peripheral/libupm/src/ppd42ns/jsupm_ppd42ns.i
index 415c4d5..812d7cb 100644
--- a/peripheral/libupm/src/ppd42ns/jsupm_ppd42ns.i
+++ b/peripheral/libupm/src/ppd42ns/jsupm_ppd42ns.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "ppd42ns.hpp"
+ #include "ppd42ns.h"
%}
-%include "ppd42ns.hpp"
+%include "ppd42ns.h"
diff --git a/peripheral/libupm/src/ppd42ns/ppd42ns.cxx b/peripheral/libupm/src/ppd42ns/ppd42ns.cxx
index 651049c..a7b0e0d 100644
--- a/peripheral/libupm/src/ppd42ns/ppd42ns.cxx
+++ b/peripheral/libupm/src/ppd42ns/ppd42ns.cxx
@@ -30,7 +30,7 @@
#include <time.h>
#include <math.h>
#include <sys/sysinfo.h>
-#include "ppd42ns.hpp"
+#include "ppd42ns.h"
using namespace upm;
diff --git a/peripheral/libupm/src/ppd42ns/ppd42ns.hpp b/peripheral/libupm/src/ppd42ns/ppd42ns.h
index 0c65467..0c65467 100644
--- a/peripheral/libupm/src/ppd42ns/ppd42ns.hpp
+++ b/peripheral/libupm/src/ppd42ns/ppd42ns.h
diff --git a/peripheral/libupm/src/ppd42ns/pyupm_ppd42ns.i b/peripheral/libupm/src/ppd42ns/pyupm_ppd42ns.i
index 1f5852c..38fab6d 100644
--- a/peripheral/libupm/src/ppd42ns/pyupm_ppd42ns.i
+++ b/peripheral/libupm/src/ppd42ns/pyupm_ppd42ns.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "ppd42ns.hpp"
+%include "ppd42ns.h"
%{
- #include "ppd42ns.hpp"
+ #include "ppd42ns.h"
%}
diff --git a/peripheral/libupm/src/pulsensor/CMakeLists.txt b/peripheral/libupm/src/pulsensor/CMakeLists.txt
index 9bf0997..223c642 100644
--- a/peripheral/libupm/src/pulsensor/CMakeLists.txt
+++ b/peripheral/libupm/src/pulsensor/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "pulsensor")
set (libdescription "upm PULSENSOR")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/pulsensor/Callback.hpp b/peripheral/libupm/src/pulsensor/Callback.h
index f9c291a..f9c291a 100644
--- a/peripheral/libupm/src/pulsensor/Callback.hpp
+++ b/peripheral/libupm/src/pulsensor/Callback.h
diff --git a/peripheral/libupm/src/pulsensor/javaupm_pulsensor.i b/peripheral/libupm/src/pulsensor/javaupm_pulsensor.i
index 5f2669a..91b34cc 100644
--- a/peripheral/libupm/src/pulsensor/javaupm_pulsensor.i
+++ b/peripheral/libupm/src/pulsensor/javaupm_pulsensor.i
@@ -10,12 +10,12 @@ SWIG_DIRECTOR_OWNED(Callback)
%ignore do_sample;
%ignore callback;
-%include "Callback.hpp"
+%include "Callback.h"
%{
- #include "pulsensor.hpp"
+ #include "pulsensor.h"
%}
-%include "pulsensor.hpp"
+%include "pulsensor.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/pulsensor/jsupm_pulsensor.i b/peripheral/libupm/src/pulsensor/jsupm_pulsensor.i
index f401d1e..d92312a 100644
--- a/peripheral/libupm/src/pulsensor/jsupm_pulsensor.i
+++ b/peripheral/libupm/src/pulsensor/jsupm_pulsensor.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "pulsensor.hpp"
+ #include "pulsensor.h"
%}
-%include "pulsensor.hpp"
+%include "pulsensor.h"
diff --git a/peripheral/libupm/src/pulsensor/pulsensor.cxx b/peripheral/libupm/src/pulsensor/pulsensor.cxx
index e0bff81..73d9a09 100644
--- a/peripheral/libupm/src/pulsensor/pulsensor.cxx
+++ b/peripheral/libupm/src/pulsensor/pulsensor.cxx
@@ -28,7 +28,7 @@
#include <unistd.h>
#include <stdlib.h>
-#include "pulsensor.hpp"
+#include "pulsensor.h"
using namespace upm;
diff --git a/peripheral/libupm/src/pulsensor/pulsensor.hpp b/peripheral/libupm/src/pulsensor/pulsensor.h
index de1144b..8c9866d 100644
--- a/peripheral/libupm/src/pulsensor/pulsensor.hpp
+++ b/peripheral/libupm/src/pulsensor/pulsensor.h
@@ -48,7 +48,7 @@ struct clbk_data {
};
#if defined(SWIGJAVA) || defined(JAVACALLBACK)
-#include "Callback.hpp"
+#include "Callback.h"
#else
typedef void (* callback_handler) (clbk_data);
#endif
diff --git a/peripheral/libupm/src/pulsensor/pyupm_pulsensor.i b/peripheral/libupm/src/pulsensor/pyupm_pulsensor.i
index 3d340e5..7d470cf 100644
--- a/peripheral/libupm/src/pulsensor/pyupm_pulsensor.i
+++ b/peripheral/libupm/src/pulsensor/pyupm_pulsensor.i
@@ -7,7 +7,7 @@
%feature("autodoc", "3");
-%include "pulsensor.hpp"
+%include "pulsensor.h"
%{
- #include "pulsensor.hpp"
+ #include "pulsensor.h"
%}
diff --git a/peripheral/libupm/src/rfr359f/CMakeLists.txt b/peripheral/libupm/src/rfr359f/CMakeLists.txt
index 539e6b7..94cb79d 100644
--- a/peripheral/libupm/src/rfr359f/CMakeLists.txt
+++ b/peripheral/libupm/src/rfr359f/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "rfr359f")
set (libdescription "upm rfr359f grove distance interrupter")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/rfr359f/javaupm_rfr359f.i b/peripheral/libupm/src/rfr359f/javaupm_rfr359f.i
index ce2e2ee..ebd528f 100644
--- a/peripheral/libupm/src/rfr359f/javaupm_rfr359f.i
+++ b/peripheral/libupm/src/rfr359f/javaupm_rfr359f.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "rfr359f.hpp"
+ #include "rfr359f.h"
%}
-%include "rfr359f.hpp"
+%include "rfr359f.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/rfr359f/jsupm_rfr359f.i b/peripheral/libupm/src/rfr359f/jsupm_rfr359f.i
index 93709a5..be5748f 100644
--- a/peripheral/libupm/src/rfr359f/jsupm_rfr359f.i
+++ b/peripheral/libupm/src/rfr359f/jsupm_rfr359f.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "rfr359f.hpp"
+ #include "rfr359f.h"
%}
-%include "rfr359f.hpp"
+%include "rfr359f.h"
diff --git a/peripheral/libupm/src/rfr359f/pyupm_rfr359f.i b/peripheral/libupm/src/rfr359f/pyupm_rfr359f.i
index 3900e6e..eacc68a 100644
--- a/peripheral/libupm/src/rfr359f/pyupm_rfr359f.i
+++ b/peripheral/libupm/src/rfr359f/pyupm_rfr359f.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "rfr359f.hpp"
+%include "rfr359f.h"
%{
- #include "rfr359f.hpp"
+ #include "rfr359f.h"
%}
diff --git a/peripheral/libupm/src/rfr359f/rfr359f.cxx b/peripheral/libupm/src/rfr359f/rfr359f.cxx
index e24ce73..96dfc22 100644
--- a/peripheral/libupm/src/rfr359f/rfr359f.cxx
+++ b/peripheral/libupm/src/rfr359f/rfr359f.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "rfr359f.hpp"
+#include "rfr359f.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/rfr359f/rfr359f.hpp b/peripheral/libupm/src/rfr359f/rfr359f.h
index 862574b..862574b 100644
--- a/peripheral/libupm/src/rfr359f/rfr359f.hpp
+++ b/peripheral/libupm/src/rfr359f/rfr359f.h
diff --git a/peripheral/libupm/src/rgbringcoder/CMakeLists.txt b/peripheral/libupm/src/rgbringcoder/CMakeLists.txt
index da1f695..86d6ee4 100644
--- a/peripheral/libupm/src/rgbringcoder/CMakeLists.txt
+++ b/peripheral/libupm/src/rgbringcoder/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "rgbringcoder")
set (libdescription "upm Sparkfun RGB RingCoder")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/rgbringcoder/javaupm_rgbringcoder.i b/peripheral/libupm/src/rgbringcoder/javaupm_rgbringcoder.i
index 4210915..2e67125 100644
--- a/peripheral/libupm/src/rgbringcoder/javaupm_rgbringcoder.i
+++ b/peripheral/libupm/src/rgbringcoder/javaupm_rgbringcoder.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "rgbringcoder.hpp"
+ #include "rgbringcoder.h"
%}
-%include "rgbringcoder.hpp"
+%include "rgbringcoder.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/rgbringcoder/jsupm_rgbringcoder.i b/peripheral/libupm/src/rgbringcoder/jsupm_rgbringcoder.i
index a208ace..8f4f5f8 100644
--- a/peripheral/libupm/src/rgbringcoder/jsupm_rgbringcoder.i
+++ b/peripheral/libupm/src/rgbringcoder/jsupm_rgbringcoder.i
@@ -3,7 +3,7 @@
%include "stdint.i"
%{
- #include "rgbringcoder.hpp"
+ #include "rgbringcoder.h"
%}
-%include "rgbringcoder.hpp"
+%include "rgbringcoder.h"
diff --git a/peripheral/libupm/src/rgbringcoder/pyupm_rgbringcoder.i b/peripheral/libupm/src/rgbringcoder/pyupm_rgbringcoder.i
index 25560a6..7f7afff 100644
--- a/peripheral/libupm/src/rgbringcoder/pyupm_rgbringcoder.i
+++ b/peripheral/libupm/src/rgbringcoder/pyupm_rgbringcoder.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "rgbringcoder.hpp"
+%include "rgbringcoder.h"
%{
- #include "rgbringcoder.hpp"
+ #include "rgbringcoder.h"
%}
diff --git a/peripheral/libupm/src/rgbringcoder/rgbringcoder.cxx b/peripheral/libupm/src/rgbringcoder/rgbringcoder.cxx
index 4a48314..6716f81 100644
--- a/peripheral/libupm/src/rgbringcoder/rgbringcoder.cxx
+++ b/peripheral/libupm/src/rgbringcoder/rgbringcoder.cxx
@@ -27,7 +27,7 @@
#ifdef JAVACALLBACK
#undef JAVACALLBACK
#endif
-#include "rgbringcoder.hpp"
+#include "rgbringcoder.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/src/rgbringcoder/rgbringcoder.hpp b/peripheral/libupm/src/rgbringcoder/rgbringcoder.h
index 5675c4f..5675c4f 100644
--- a/peripheral/libupm/src/rgbringcoder/rgbringcoder.hpp
+++ b/peripheral/libupm/src/rgbringcoder/rgbringcoder.h
diff --git a/peripheral/libupm/src/rhusb/CMakeLists.txt b/peripheral/libupm/src/rhusb/CMakeLists.txt
index f5525a2..64f2aff 100644
--- a/peripheral/libupm/src/rhusb/CMakeLists.txt
+++ b/peripheral/libupm/src/rhusb/CMakeLists.txt
@@ -1,6 +1,6 @@
set (libname "rhusb")
set (libdescription "upm module for the Omega RH-USB sensor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/rhusb/javaupm_rhusb.i b/peripheral/libupm/src/rhusb/javaupm_rhusb.i
index c6a600c..e72f423 100644
--- a/peripheral/libupm/src/rhusb/javaupm_rhusb.i
+++ b/peripheral/libupm/src/rhusb/javaupm_rhusb.i
@@ -6,10 +6,10 @@
%include "../java_buffer.i"
%{
- #include "rhusb.hpp"
+ #include "rhusb.h"
%}
-%include "rhusb.hpp"
+%include "rhusb.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/rhusb/jsupm_rhusb.i b/peripheral/libupm/src/rhusb/jsupm_rhusb.i
index 17a1466..3786cb7 100644
--- a/peripheral/libupm/src/rhusb/jsupm_rhusb.i
+++ b/peripheral/libupm/src/rhusb/jsupm_rhusb.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%include "stdint.i"
-%include "rhusb.hpp"
+%include "rhusb.h"
%{
- #include "rhusb.hpp"
+ #include "rhusb.h"
%}
diff --git a/peripheral/libupm/src/rhusb/pyupm_rhusb.i b/peripheral/libupm/src/rhusb/pyupm_rhusb.i
index 214fbc6..83322af 100644
--- a/peripheral/libupm/src/rhusb/pyupm_rhusb.i
+++ b/peripheral/libupm/src/rhusb/pyupm_rhusb.i
@@ -6,7 +6,7 @@
%feature("autodoc", "3");
-%include "rhusb.hpp"
+%include "rhusb.h"
%{
- #include "rhusb.hpp"
+ #include "rhusb.h"
%}
diff --git a/peripheral/libupm/src/rhusb/rhusb.cxx b/peripheral/libupm/src/rhusb/rhusb.cxx
index ca51d6e..6b6b88c 100644
--- a/peripheral/libupm/src/rhusb/rhusb.cxx
+++ b/peripheral/libupm/src/rhusb/rhusb.cxx
@@ -28,7 +28,7 @@
#include <stdexcept>
#include <string>
-#include "rhusb.hpp"
+#include "rhusb.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/rhusb/rhusb.hpp b/peripheral/libupm/src/rhusb/rhusb.h
index 4fd4548..4fd4548 100644
--- a/peripheral/libupm/src/rhusb/rhusb.hpp
+++ b/peripheral/libupm/src/rhusb/rhusb.h
diff --git a/peripheral/libupm/src/rotaryencoder/CMakeLists.txt b/peripheral/libupm/src/rotaryencoder/CMakeLists.txt
index 099e87d..56b8f57 100644
--- a/peripheral/libupm/src/rotaryencoder/CMakeLists.txt
+++ b/peripheral/libupm/src/rotaryencoder/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "rotaryencoder")
set (libdescription "upm grove rotary encoder module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/rotaryencoder/javaupm_rotaryencoder.i b/peripheral/libupm/src/rotaryencoder/javaupm_rotaryencoder.i
index 404df45..af10c23 100644
--- a/peripheral/libupm/src/rotaryencoder/javaupm_rotaryencoder.i
+++ b/peripheral/libupm/src/rotaryencoder/javaupm_rotaryencoder.i
@@ -4,10 +4,10 @@
%ignore signalAISR;
%{
- #include "rotaryencoder.hpp"
+ #include "rotaryencoder.h"
%}
-%include "rotaryencoder.hpp"
+%include "rotaryencoder.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/rotaryencoder/jsupm_rotaryencoder.i b/peripheral/libupm/src/rotaryencoder/jsupm_rotaryencoder.i
index b217742..13fd7b8 100644
--- a/peripheral/libupm/src/rotaryencoder/jsupm_rotaryencoder.i
+++ b/peripheral/libupm/src/rotaryencoder/jsupm_rotaryencoder.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "rotaryencoder.hpp"
+ #include "rotaryencoder.h"
%}
-%include "rotaryencoder.hpp"
+%include "rotaryencoder.h"
diff --git a/peripheral/libupm/src/rotaryencoder/pyupm_rotaryencoder.i b/peripheral/libupm/src/rotaryencoder/pyupm_rotaryencoder.i
index 26d9e6f..ea27bc3 100644
--- a/peripheral/libupm/src/rotaryencoder/pyupm_rotaryencoder.i
+++ b/peripheral/libupm/src/rotaryencoder/pyupm_rotaryencoder.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "rotaryencoder.hpp"
+%include "rotaryencoder.h"
%{
- #include "rotaryencoder.hpp"
+ #include "rotaryencoder.h"
%}
diff --git a/peripheral/libupm/src/rotaryencoder/rotaryencoder.cxx b/peripheral/libupm/src/rotaryencoder/rotaryencoder.cxx
index cc368d7..15b7b5d 100644
--- a/peripheral/libupm/src/rotaryencoder/rotaryencoder.cxx
+++ b/peripheral/libupm/src/rotaryencoder/rotaryencoder.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "rotaryencoder.hpp"
+#include "rotaryencoder.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/rotaryencoder/rotaryencoder.hpp b/peripheral/libupm/src/rotaryencoder/rotaryencoder.h
index 2cf6bff..2cf6bff 100644
--- a/peripheral/libupm/src/rotaryencoder/rotaryencoder.hpp
+++ b/peripheral/libupm/src/rotaryencoder/rotaryencoder.h
diff --git a/peripheral/libupm/src/rpr220/CMakeLists.txt b/peripheral/libupm/src/rpr220/CMakeLists.txt
index 2f63724..2a88bf0 100644
--- a/peripheral/libupm/src/rpr220/CMakeLists.txt
+++ b/peripheral/libupm/src/rpr220/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "rpr220")
set (libdescription "upm rpr220 grove IR reflective sensor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/rpr220/javaupm_rpr220.i b/peripheral/libupm/src/rpr220/javaupm_rpr220.i
index ec4b300..fd466d8 100644
--- a/peripheral/libupm/src/rpr220/javaupm_rpr220.i
+++ b/peripheral/libupm/src/rpr220/javaupm_rpr220.i
@@ -3,9 +3,9 @@
%{
- #include "rpr220.hpp"
+ #include "rpr220.h"
%}
-%include "rpr220.hpp"
+%include "rpr220.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/rpr220/jsupm_rpr220.i b/peripheral/libupm/src/rpr220/jsupm_rpr220.i
index 6c83979..75706ae 100644
--- a/peripheral/libupm/src/rpr220/jsupm_rpr220.i
+++ b/peripheral/libupm/src/rpr220/jsupm_rpr220.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "rpr220.hpp"
+ #include "rpr220.h"
%}
-%include "rpr220.hpp"
+%include "rpr220.h"
diff --git a/peripheral/libupm/src/rpr220/pyupm_rpr220.i b/peripheral/libupm/src/rpr220/pyupm_rpr220.i
index 1dd955b..2f356ca 100644
--- a/peripheral/libupm/src/rpr220/pyupm_rpr220.i
+++ b/peripheral/libupm/src/rpr220/pyupm_rpr220.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "rpr220.hpp"
+%include "rpr220.h"
%{
- #include "rpr220.hpp"
+ #include "rpr220.h"
%}
diff --git a/peripheral/libupm/src/rpr220/rpr220.cxx b/peripheral/libupm/src/rpr220/rpr220.cxx
index acf3fc4..8068eaa 100644
--- a/peripheral/libupm/src/rpr220/rpr220.cxx
+++ b/peripheral/libupm/src/rpr220/rpr220.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "rpr220.hpp"
+#include "rpr220.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/rpr220/rpr220.hpp b/peripheral/libupm/src/rpr220/rpr220.h
index c9db2e9..c9db2e9 100644
--- a/peripheral/libupm/src/rpr220/rpr220.hpp
+++ b/peripheral/libupm/src/rpr220/rpr220.h
diff --git a/peripheral/libupm/src/servo/CMakeLists.txt b/peripheral/libupm/src/servo/CMakeLists.txt
index 9cd0227..923c09c 100644
--- a/peripheral/libupm/src/servo/CMakeLists.txt
+++ b/peripheral/libupm/src/servo/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "servo")
set (libdescription "upm servo")
set (module_src servo.cxx es08a.cxx es9257.cxx)
-set (module_hpp servo.hpp es08a.hpp es9257.hpp)
+set (module_h servo.h es08a.h es9257.h)
upm_module_init()
diff --git a/peripheral/libupm/src/servo/es08a.cxx b/peripheral/libupm/src/servo/es08a.cxx
index eab14c9..b7d72d3 100644
--- a/peripheral/libupm/src/servo/es08a.cxx
+++ b/peripheral/libupm/src/servo/es08a.cxx
@@ -25,7 +25,7 @@
#include <iostream>
#include <unistd.h>
-#include "es08a.hpp"
+#include "es08a.h"
using namespace upm;
diff --git a/peripheral/libupm/src/servo/es08a.hpp b/peripheral/libupm/src/servo/es08a.h
index 8822389..2c28096 100644
--- a/peripheral/libupm/src/servo/es08a.hpp
+++ b/peripheral/libupm/src/servo/es08a.h
@@ -24,7 +24,7 @@
#pragma once
#include <string>
-#include "servo.hpp"
+#include "servo.h"
namespace upm {
diff --git a/peripheral/libupm/src/servo/es9257.cxx b/peripheral/libupm/src/servo/es9257.cxx
index 6f55d45..b7edf0f 100644
--- a/peripheral/libupm/src/servo/es9257.cxx
+++ b/peripheral/libupm/src/servo/es9257.cxx
@@ -25,7 +25,7 @@
#include <iostream>
#include <unistd.h>
-#include "es9257.hpp"
+#include "es9257.h"
using namespace upm;
diff --git a/peripheral/libupm/src/servo/es9257.hpp b/peripheral/libupm/src/servo/es9257.h
index a2e2e5c..51b41ef 100644
--- a/peripheral/libupm/src/servo/es9257.hpp
+++ b/peripheral/libupm/src/servo/es9257.h
@@ -24,7 +24,7 @@
#pragma once
#include <string>
-#include "servo.hpp"
+#include "servo.h"
namespace upm {
diff --git a/peripheral/libupm/src/servo/javaupm_servo.i b/peripheral/libupm/src/servo/javaupm_servo.i
index 1ab59ea..38e0436 100644
--- a/peripheral/libupm/src/servo/javaupm_servo.i
+++ b/peripheral/libupm/src/servo/javaupm_servo.i
@@ -1,19 +1,19 @@
%module javaupm_servo
%include "../upm.i"
-%include "servo.hpp"
+%include "servo.h"
%{
- #include "servo.hpp"
+ #include "servo.h"
%}
-%include "es08a.hpp"
+%include "es08a.h"
%{
- #include "es08a.hpp"
+ #include "es08a.h"
%}
-%include "es9257.hpp"
+%include "es9257.h"
%{
- #include "es9257.hpp"
+ #include "es9257.h"
%}
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/servo/jsupm_servo.i b/peripheral/libupm/src/servo/jsupm_servo.i
index 72ef29c..6b17bc2 100644
--- a/peripheral/libupm/src/servo/jsupm_servo.i
+++ b/peripheral/libupm/src/servo/jsupm_servo.i
@@ -1,17 +1,17 @@
%module jsupm_servo
%include "../upm.i"
-%include "servo.hpp"
+%include "servo.h"
%{
- #include "servo.hpp"
+ #include "servo.h"
%}
-%include "es08a.hpp"
+%include "es08a.h"
%{
- #include "es08a.hpp"
+ #include "es08a.h"
%}
-%include "es9257.hpp"
+%include "es9257.h"
%{
- #include "es9257.hpp"
+ #include "es9257.h"
%}
diff --git a/peripheral/libupm/src/servo/pyupm_servo.i b/peripheral/libupm/src/servo/pyupm_servo.i
index 4023975..8db40d6 100644
--- a/peripheral/libupm/src/servo/pyupm_servo.i
+++ b/peripheral/libupm/src/servo/pyupm_servo.i
@@ -3,17 +3,17 @@
%module pyupm_servo
%include "../upm.i"
-%include "servo.hpp"
+%include "servo.h"
%{
- #include "servo.hpp"
+ #include "servo.h"
%}
-%include "es08a.hpp"
+%include "es08a.h"
%{
- #include "es08a.hpp"
+ #include "es08a.h"
%}
-%include "es9257.hpp"
+%include "es9257.h"
%{
- #include "es9257.hpp"
+ #include "es9257.h"
%}
diff --git a/peripheral/libupm/src/servo/servo.cxx b/peripheral/libupm/src/servo/servo.cxx
index 9ed031d..b956ec4 100644
--- a/peripheral/libupm/src/servo/servo.cxx
+++ b/peripheral/libupm/src/servo/servo.cxx
@@ -30,7 +30,7 @@
#include <stdlib.h>
#include <math.h>
-#include "servo.hpp"
+#include "servo.h"
using namespace upm;
diff --git a/peripheral/libupm/src/servo/servo.hpp b/peripheral/libupm/src/servo/servo.h
index 17bdf13..17bdf13 100644
--- a/peripheral/libupm/src/servo/servo.hpp
+++ b/peripheral/libupm/src/servo/servo.h
diff --git a/peripheral/libupm/src/si1132/CMakeLists.txt b/peripheral/libupm/src/si1132/CMakeLists.txt
deleted file mode 100644
index e09e9db..0000000
--- a/peripheral/libupm/src/si1132/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-include_directories(..)
-set (libname "si1132")
-set (libdescription "upm Si1132")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/si1132/javaupm_si1132.i b/peripheral/libupm/src/si1132/javaupm_si1132.i
deleted file mode 100644
index 3b0786a..0000000
--- a/peripheral/libupm/src/si1132/javaupm_si1132.i
+++ /dev/null
@@ -1,17 +0,0 @@
-%module(directors="1") javaupm_si1132
-%include "../upm.i"
-%include "../upm/javaupm_interfaces.i"
-
-%{
- #include "si1132.hpp"
-%}
-
-/*
-%include "../upm/iModuleStatus.hpp"
-%include "../upm/iLightSensor.hpp"
-
-%feature("director") IModuleStatus;
-%feature("director") ILightSensor;
-*/
-
-%include "si1132.hpp"
diff --git a/peripheral/libupm/src/si1132/jsupm_si1132.i b/peripheral/libupm/src/si1132/jsupm_si1132.i
deleted file mode 100644
index 5e117df..0000000
--- a/peripheral/libupm/src/si1132/jsupm_si1132.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module jsupm_si1132
-%include "../upm.i"
-
-%{
- #include "si1132.hpp"
-%}
-
-%include "si1132.hpp"
diff --git a/peripheral/libupm/src/si1132/pyupm_si1132.i b/peripheral/libupm/src/si1132/pyupm_si1132.i
deleted file mode 100644
index 00a4d94..0000000
--- a/peripheral/libupm/src/si1132/pyupm_si1132.i
+++ /dev/null
@@ -1,11 +0,0 @@
-%module pyupm_si1132
-%include "../upm.i"
-
-%include "stdint.i"
-
-%feature("autodoc", "3");
-
-%include "si1132.hpp"
-%{
- #include "si1132.hpp"
-%}
diff --git a/peripheral/libupm/src/si1132/si1132.cxx b/peripheral/libupm/src/si1132/si1132.cxx
deleted file mode 100644
index 5d81eae..0000000
--- a/peripheral/libupm/src/si1132/si1132.cxx
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Author: Scott Ware <scott.r.ware@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-#include <unistd.h>
-#include <stdlib.h>
-#include <math.h>
-#include <errno.h>
-
-#include "si1132.hpp"
-
-
-#define SI1132_ADDRESS 0x60
-
-/* REGISTER ADDRESSES */
-#define SI1132_REG_PART_ID 0x00
-#define SI1132_REG_INT_CFG 0x03
-#define SI1132_REG_IRQ_ENABLE 0x04
-#define SI1132_REG_HW_KEY 0x07
-#define SI1132_REG_MEAS_RATE0 0x08
-#define SI1132_REG_MEAS_RATE1 0x09
-#define SI1132_REG_PARAM_WR 0x17
-#define SI1132_REG_COMMAND 0x18
-#define SI1132_REG_RESPONSE 0x20
-#define SI1132_REG_ALS_VIS_DATA0 0x22
-#define SI1132_REG_ALS_VIS_DATA1 0x23
-#define SI1132_REG_PARAM_RD 0x2E
-#define SI1132_REG_CHIP_STAT 0x30
-
-/* REGISTER VALUES */
-#define SI1132_PART_ID 0x32
-#define SI1132_HW_KEY_INIT 0x17
-
- /* COMMAND VALUES */
-#define SI1132_COMMAND_RESET 0x01
-#define SI1132_COMMAND_ALS_FORCE 0x06
-#define SI1132_COMMAND_PARAM_QUERY 0x80
-#define SI1132_COMMAND_PARAM_SET 0xA0
-#define SI1132_COMMAND_ALS_AUTO 0x0E
-
-/* PARAMETER RAM ADDRESSES */
-#define SI1132_PARAM_CHLIST 0x01
-#define SI1132_PARAM_ALS_VIS_ADC_COUNT 0x10
-#define SI1132_PARAM_ALS_VIS_ADC_GAIN 0x11
-#define SI1132_PARAM_ALS_VIS_ADC_MISC 0x12
-
-/* PARAMETER RAM VALUES */
-#define SI1132_PARAM_CHLIST_ENALSVIS 0x10
-#define SI1132_PARAM_ALS_VIS_RANGE_STD 0x00
-#define SI1132_PARAM_ALS_VIS_RANGE_HI 0x20
-
-
-
-using namespace upm;
-
-SI1132::SI1132 (int bus) {
- i2c = new mraa::I2c(bus);
- i2c->address(SI1132_ADDRESS);
-
- // Reset chip to defaults
- status = reset();
- if (status != mraa::SUCCESS)
- UPM_THROW("config failure");
-}
-
-SI1132::~SI1132() {
- delete i2c;
-}
-
-mraa::Result SI1132::reset() {
- i2c->address(SI1132_ADDRESS);
-
- // Check version
- uint8_t regValue = i2c->readReg(SI1132_REG_PART_ID);
- if (regValue != SI1132_PART_ID) {
- fprintf(stderr, "SI1132: Read ID failed. Data = %02x\n", regValue);
- status = mraa::ERROR_UNSPECIFIED;
- return status;
- }
-
- // disable automatic updates
- uint16_t rate = 0;
- status = i2c->writeWordReg(SI1132_REG_MEAS_RATE0, rate);
- if (status != mraa::SUCCESS) {
- fprintf(stderr, "SI1132_REG_MEAS_RATE0 failed\n");
- return status;
- }
-
- // reset device
- status = i2c->writeReg(SI1132_REG_COMMAND, SI1132_COMMAND_RESET);
- if (status != mraa::SUCCESS) {
- fprintf(stderr, "SI1132: Reset failed.\n");
- status = mraa::ERROR_UNSPECIFIED;
- return status;
- }
- sleepMs(30);
-
- // start state machine
- i2c->writeReg(SI1132_REG_HW_KEY, SI1132_HW_KEY_INIT);
- regValue = i2c->readReg(SI1132_REG_HW_KEY);
- if (regValue != SI1132_HW_KEY_INIT) {
- fprintf(stderr, "Si1132: Did not start\n");
- status = mraa::ERROR_UNSPECIFIED;
- return status;
- }
-
- status = writeParam(SI1132_PARAM_CHLIST, SI1132_PARAM_CHLIST_ENALSVIS);
-
- // set visible light range for indoor lighting
- status = writeParam(SI1132_PARAM_ALS_VIS_ADC_MISC, SI1132_PARAM_ALS_VIS_RANGE_STD);
-
- // set visible light gain to 8
- status = writeParam(SI1132_PARAM_ALS_VIS_ADC_GAIN, 3);
- status = writeParam(SI1132_PARAM_ALS_VIS_ADC_COUNT, 3 << 4);
- return status;
-}
-
-
-uint16_t SI1132::getVisibleRaw() {
- status = runCommand(SI1132_COMMAND_ALS_FORCE);
- if (status != mraa::SUCCESS)
- UPM_THROW("command failed");
- return i2c->readWordReg(SI1132_REG_ALS_VIS_DATA0);
-}
-
-
-double SI1132::getVisibleLux() {
- uint16_t rawValue = getVisibleRaw();
- if (rawValue < 256)
- rawValue = 0;
- else
- rawValue -= 256;
- return static_cast<double>(rawValue);
-}
-
-
-mraa::Result SI1132::clearResponseRegister()
-{
- uint8_t regValue = 0xFF;
- status = i2c->writeReg(SI1132_REG_COMMAND, 0);
- if (status != mraa::SUCCESS)
- return status;
- int bytesRead = i2c->readBytesReg(SI1132_REG_RESPONSE, &regValue, 1);
- if (bytesRead == 1 && regValue == 0)
- status = mraa::SUCCESS;
- else
- status = mraa::ERROR_UNSPECIFIED;
- return status;
-}
-
-mraa::Result SI1132::runCommand(uint8_t command)
-{
- uint8_t response = 0;
- int sleepTimeMs = 5;
- int timeoutMs = 50;
- int waitTimeMs = 0;
- i2c->address(SI1132_ADDRESS);
- status = clearResponseRegister();
- if (status != mraa::SUCCESS)
- return status;
- status = i2c->writeReg(SI1132_REG_COMMAND, command);
- if (status != mraa::SUCCESS)
- return status;
- while (response == 0 && waitTimeMs < timeoutMs) {
- response = i2c->readReg(SI1132_REG_RESPONSE);
- sleepMs(sleepTimeMs);
- waitTimeMs += sleepTimeMs;
- }
- if (response == 0) {
- status = mraa::ERROR_UNSPECIFIED;
- fprintf(stderr, "Command %d failed\n", command);
- }
- return status;
-}
-
-mraa::Result SI1132::writeParam(uint8_t param, uint8_t value)
-{
- i2c->address(SI1132_ADDRESS);
- status = i2c->writeReg(SI1132_REG_PARAM_WR, value);
- if (status != mraa::SUCCESS)
- return status;
- return runCommand(SI1132_COMMAND_PARAM_SET | param);
-}
-
-mraa::Result SI1132::readParam(uint8_t param, uint8_t* value)
-{
- status = runCommand(SI1132_COMMAND_PARAM_QUERY | param);
- if (status != mraa::SUCCESS)
- return status;
- if (i2c->readBytesReg(SI1132_REG_PARAM_RD, value, 1) != 1)
- status = mraa::ERROR_UNSPECIFIED;
- return status;
-}
-
-
-void SI1132::sleepMs(int mseconds)
-{
- struct timespec sleepTime;
-
- sleepTime.tv_sec = mseconds / 1000; // Number of seconds
- sleepTime.tv_nsec = ( mseconds % 1000 ) * 1000000; // Convert fractional seconds to nanoseconds
-
- // Iterate nanosleep in a loop until the total sleep time is the original
- // value of the seconds parameter
- while ( ( nanosleep( &sleepTime, &sleepTime ) != 0 ) && ( errno == EINTR ) );
-}
diff --git a/peripheral/libupm/src/si1132/si1132.hpp b/peripheral/libupm/src/si1132/si1132.hpp
deleted file mode 100644
index 5526001..0000000
--- a/peripheral/libupm/src/si1132/si1132.hpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include "mraa/i2c.hpp"
-#include "upm/iLightSensor.hpp"
-
-
-namespace upm {
-
-/**
- * @brief Si1132 UV and visible light sensor library
- * @defgroup Si1132 libupm-Si1132
- * @ingroup silabs i2c light ilightsensor
- */
-
-/**
- * @brief API for Si1132 UV and Visible Light Sensor
- *
- * The Silicon Labs
- * [Si1132](https://www.silabs.com/Support%20Documents/TechnicalDocs/Si1132.pdf)
- * is a low-power, ultraviolet (UV) index, and ambient light sensor with I2C
- * digital interface and programmable-event interrupt output.
- *
- * @library si1132
- * @sensor si1132
- * @comname Si1132 Light Sensor
- * @altname Si1132
- * @type light
- * @man silabs
- * @con i2c
- * @if ilightsensor
-
- */
-class SI1132 : public ILightSensor {
- public:
- /**
- * Instanciates a Si1132 object
- *
- * @param bus number of used bus
- * @param devAddr address of used i2c device
- */
- SI1132 (int bus);
-
- /**
- * Si1132 object destructor, basicaly it close i2c connection.
- */
- ~SI1132 ();
-
- /**
- * Read the raw visible light value
- */
- uint16_t getVisibleRaw();
-
- /**
- * Read the lux value
- */
- double getVisibleLux();
-
- const char* getModuleName() { return "si1132"; }
-
- private:
- mraa::Result reset();
- mraa::Result clearResponseRegister();
- mraa::Result runCommand(uint8_t command);
- mraa::Result readParam(uint8_t param, uint8_t* value);
- mraa::Result writeParam(uint8_t param, uint8_t value);
- void sleepMs(int mseconds);
-
- mraa::I2c* i2c;
- mraa::Result status;
-};
-
-}
diff --git a/peripheral/libupm/src/si114x/CMakeLists.txt b/peripheral/libupm/src/si114x/CMakeLists.txt
index 0d1c24f..e2d8f2e 100644
--- a/peripheral/libupm/src/si114x/CMakeLists.txt
+++ b/peripheral/libupm/src/si114x/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "si114x")
set (libdescription "upm si114x UV/IR/Visible light sensor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/si114x/javaupm_si114x.i b/peripheral/libupm/src/si114x/javaupm_si114x.i
index 1bb6612..173c4a6 100644
--- a/peripheral/libupm/src/si114x/javaupm_si114x.i
+++ b/peripheral/libupm/src/si114x/javaupm_si114x.i
@@ -3,10 +3,10 @@
%include "cpointer.i"
%{
- #include "si114x.hpp"
+ #include "si114x.h"
%}
-%include "si114x.hpp"
+%include "si114x.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/si114x/jsupm_si114x.i b/peripheral/libupm/src/si114x/jsupm_si114x.i
index 1b0d015..9ee70e0 100644
--- a/peripheral/libupm/src/si114x/jsupm_si114x.i
+++ b/peripheral/libupm/src/si114x/jsupm_si114x.i
@@ -3,7 +3,7 @@
%include "cpointer.i"
%{
- #include "si114x.hpp"
+ #include "si114x.h"
%}
-%include "si114x.hpp"
+%include "si114x.h"
diff --git a/peripheral/libupm/src/si114x/pyupm_si114x.i b/peripheral/libupm/src/si114x/pyupm_si114x.i
index 5aa596f..7b35cb8 100644
--- a/peripheral/libupm/src/si114x/pyupm_si114x.i
+++ b/peripheral/libupm/src/si114x/pyupm_si114x.i
@@ -9,7 +9,7 @@
%include "si114x_doc.i"
#endif
-%include "si114x.hpp"
+%include "si114x.h"
%{
- #include "si114x.hpp"
+ #include "si114x.h"
%}
diff --git a/peripheral/libupm/src/si114x/si114x.cxx b/peripheral/libupm/src/si114x/si114x.cxx
index 7d75445..6887690 100644
--- a/peripheral/libupm/src/si114x/si114x.cxx
+++ b/peripheral/libupm/src/si114x/si114x.cxx
@@ -30,7 +30,7 @@
#include <stdexcept>
#include <string>
-#include "si114x.hpp"
+#include "si114x.h"
using namespace upm;
using namespace std;
@@ -91,20 +91,12 @@ bool SI114X::writeByte(uint8_t reg, uint8_t byte)
uint8_t SI114X::readByte(uint8_t reg)
{
- int x = mraa_i2c_read_byte_data(m_i2c, reg);
- if (x != -1) {
- return (uint8_t) x;
- }
- return 0;
+ return mraa_i2c_read_byte_data(m_i2c, reg);
}
uint16_t SI114X::readWord(uint8_t reg)
{
- int x = mraa_i2c_read_word_data(m_i2c, reg);
- if (x != -1) {
- return (uint16_t) x;
- }
- return 0;
+ return mraa_i2c_read_word_data(m_i2c, reg);
}
void SI114X::setUVCalibration(uint8_t uvcoeff0, uint8_t uvcoeff1,
diff --git a/peripheral/libupm/src/si114x/si114x.hpp b/peripheral/libupm/src/si114x/si114x.h
index 0905997..0905997 100644
--- a/peripheral/libupm/src/si114x/si114x.hpp
+++ b/peripheral/libupm/src/si114x/si114x.h
diff --git a/peripheral/libupm/src/si7005/CMakeLists.txt b/peripheral/libupm/src/si7005/CMakeLists.txt
deleted file mode 100644
index 2c068a0..0000000
--- a/peripheral/libupm/src/si7005/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-include_directories(..)
-set (libname "si7005")
-set (libdescription "upm SI7005")
-set (module_src ${libname}.cxx mraa-utils.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/si7005/javaupm_si7005.i b/peripheral/libupm/src/si7005/javaupm_si7005.i
deleted file mode 100644
index 66e9dff..0000000
--- a/peripheral/libupm/src/si7005/javaupm_si7005.i
+++ /dev/null
@@ -1,23 +0,0 @@
-%module javaupm_si7005
-%include "../upm.i"
-%include "arrays_java.i";
-%include "../java_buffer.i"
-%include "cpointer.i"
-%include "typemaps.i"
-
-%{
- #include "si7005.hpp"
-%}
-
-%include "si7005.hpp"
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_si7005");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/si7005/jsupm_si7005.i b/peripheral/libupm/src/si7005/jsupm_si7005.i
deleted file mode 100644
index 6f614ee..0000000
--- a/peripheral/libupm/src/si7005/jsupm_si7005.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module jsupm_si7005
-%include "../upm.i"
-
-%{
- #include "si7005.hpp"
-%}
-
-%include "si7005.hpp"
diff --git a/peripheral/libupm/src/si7005/mraa-utils.cxx b/peripheral/libupm/src/si7005/mraa-utils.cxx
deleted file mode 100644
index 528a79b..0000000
--- a/peripheral/libupm/src/si7005/mraa-utils.cxx
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <string>
-#include "mraa-utils.hpp"
-#include "mraa/gpio.hpp"
-
- #define UPM_THROW(msg) throw std::runtime_error(std::string(__FUNCTION__) + ": " + (msg))
-
-void MraaUtils::setGpio(int pin, int level)
-{
-/*
- mraa_result_t status = MRAA_ERROR_NO_RESOURCES;
- mraa_gpio_context gpio = mraa_gpio_init(pin);
- if (gpio != NULL)
- {
- mraa_gpio_dir(gpio, MRAA_GPIO_OUT);
- status = mraa_gpio_write(gpio, level);
- mraa_gpio_close(gpio);
- }
- return status;
-*/
- mraa::Gpio gpio(pin);
- gpio.dir(mraa::DIR_OUT);
- if (gpio.write(level) != mraa::SUCCESS)
- UPM_THROW("gpio write failed");
-}
-
-
-int MraaUtils::getGpio(int pin)
-{
-/*
- mraa_result_t status = MRAA_ERROR_NO_RESOURCES;
- mraa_gpio_context gpio = mraa_gpio_init(pin);
- if (gpio != NULL)
- {
- status = mraa_gpio_dir(gpio, MRAA_GPIO_IN);
- int value = mraa_gpio_read(gpio);
- if (value != -1)
- *level = value;
- else
- status = MRAA_ERROR_NO_RESOURCES;
- mraa_gpio_close(gpio);
- }
- return status;
-*/
- mraa::Gpio gpio(pin);
- gpio.dir(mraa::DIR_IN);
- return gpio.read();
-}
-
-
diff --git a/peripheral/libupm/src/si7005/mraa-utils.hpp b/peripheral/libupm/src/si7005/mraa-utils.hpp
deleted file mode 100644
index f9e6acc..0000000
--- a/peripheral/libupm/src/si7005/mraa-utils.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#pragma once
-
-#include "mraa/types.h"
-
-class __attribute__ ((visibility("hidden"))) MraaUtils
-{
-public:
- static void setGpio(int pin, int level);
- static int getGpio(int pin);
-};
-
-
-
diff --git a/peripheral/libupm/src/si7005/pyupm_si7005.i b/peripheral/libupm/src/si7005/pyupm_si7005.i
deleted file mode 100644
index 914d3ff..0000000
--- a/peripheral/libupm/src/si7005/pyupm_si7005.i
+++ /dev/null
@@ -1,11 +0,0 @@
-%module pyupm_si7005
-%include "../upm.i"
-
-%include "stdint.i"
-
-%feature("autodoc", "3");
-
-%include "si7005.hpp"
-%{
- #include "si7005.hpp"
-%}
diff --git a/peripheral/libupm/src/si7005/si7005.cxx b/peripheral/libupm/src/si7005/si7005.cxx
deleted file mode 100644
index 6dd07a6..0000000
--- a/peripheral/libupm/src/si7005/si7005.cxx
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Author: Scott Ware <scott.r.ware@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-#include <unistd.h>
-#include <stdlib.h>
-#include <math.h>
-
-#include "mraa-utils.hpp"
-#include "si7005.hpp"
-
-/* REGISTER ADDRESSES */
-#define SI7005_REG_STATUS ( 0x00 )
-#define SI7005_REG_DATA_LENGTH ( 2 )
-#define SI7005_REG_DATA_START ( 0x01 )
-#define SI7005_REG_DATA_HIGH ( 0 )
-#define SI7005_REG_DATA_LOW ( 1 )
-#define SI7005_REG_CONFIG ( 0x03 )
-#define SI7005_REG_ID ( 0x11 )
-
-/* STATUS REGISTER */
-#define SI7005_STATUS_NOT_READY ( 0x01 )
-
-/* CONFIG REGISTER */
-#define SI7005_CONFIG_START ( 0x01 )
-#define SI7005_CONFIG_HEAT ( 0x02 )
-#define SI7005_CONFIG_HUMIDITY ( 0x00 )
-#define SI7005_CONFIG_TEMPERATURE ( 0x10 )
-#define SI7005_CONFIG_FAST ( 0x20 )
-#define SI7005_CONFIG_RESET ( 0x00 )
-
-/* ID REGISTER */
-#define SI7005_ID ( 0x50 )
-
-/* COEFFICIENTS */
-#define SI7005_TEMPERATURE_OFFSET ( 50 )
-#define SI7005_TEMPERATURE_SLOPE ( 32 )
-#define SI7005_HUMIDITY_OFFSET ( 24 )
-#define SI7005_HUMIDITY_SLOPE ( 16 )
-#define A0 ( -4.7844 )
-#define A1 ( 0.4008 )
-#define A2 ( -0.00393 )
-#define Q0 ( 0.1973 )
-#define Q1 ( 0.00237 )
-
-/* MISCELLANEOUS */
-#define SI7005_WAKE_UP_TIME ( 15000 )
-
-using namespace upm;
-
-SI7005::SI7005 (int bus, int pin) {
-
- m_controlAddr = SI7005_ADDRESS;
- m_bus = bus;
- m_pin = pin;
- last_temperature = 25.0;
- config_reg = SI7005_CONFIG_RESET;
-
- // Disable chip until we need to do something with it
- MraaUtils::setGpio(m_pin, 1);
- m_i2c = new mraa::I2c(m_bus);
- status = m_i2c->address(m_controlAddr);
- if (!isAvailable())
- UPM_THROW("config failure");
-}
-
-SI7005::~SI7005() {
- delete m_i2c;
-}
-
-uint16_t
-SI7005::getTemperatureRaw () {
- return getMeasurement( SI7005_CONFIG_TEMPERATURE );
-}
-
-int
-SI7005::getTemperatureCelcius () {
- uint16_t rawTemperature = getTemperatureRaw();
- rawTemperature = ((rawTemperature >> 2) & 0xFFFF);
- last_temperature = ((float)rawTemperature) / SI7005_TEMPERATURE_SLOPE - SI7005_TEMPERATURE_OFFSET;
- return static_cast<int>(last_temperature + 0.5);
-}
-
-uint16_t
-SI7005::getHumidityRaw () {
- return getMeasurement( SI7005_CONFIG_HUMIDITY );
-}
-
-int
-SI7005::getHumidityRelative () {
- uint16_t rawHumidity = getHumidityRaw();
- rawHumidity = ((rawHumidity >> 4) & 0xFFFF);
- float linearHumidity = ((float)rawHumidity) / SI7005_HUMIDITY_SLOPE - SI7005_HUMIDITY_OFFSET;
- linearHumidity -= A2 * linearHumidity * linearHumidity + A1 * linearHumidity + A0;
- linearHumidity += ( last_temperature - 30 ) * ( Q1 * linearHumidity + Q0 );
- return static_cast<int>(linearHumidity + 0.5);
-}
-
-
-uint16_t SI7005::getMeasurement(uint8_t configValue) {
-
- uint16_t rawData;
- uint8_t data[SI7005_REG_DATA_LENGTH];
- uint8_t measurementStatus;
-
- // Enable the sensor
- MraaUtils::setGpio(m_pin, 0);
-
- // Wait for sensor to wake up
- usleep(SI7005_WAKE_UP_TIME);
-
- // Setup config register
- m_i2c->address(m_controlAddr);
- status = m_i2c->writeReg(SI7005_REG_CONFIG, SI7005_CONFIG_START | configValue | config_reg);
-
- // FIXME: readReg() returns 0 on failure which is same as "reading ready" status
- // FIXME: no timeout if device never gets to "reading ready" status
- // Wait for the measurement to finish
- measurementStatus = SI7005_STATUS_NOT_READY;
- while ( measurementStatus == SI7005_STATUS_NOT_READY ) {
- measurementStatus = m_i2c->readReg(SI7005_REG_STATUS);
- }
-
- // Read data registers
- int length = m_i2c->readBytesReg(SI7005_REG_DATA_START, data, SI7005_REG_DATA_LENGTH);
-
- // Disable the sensor
- MraaUtils::setGpio(m_pin, 1);
-
- // Check we got the data we need
- if(length != SI7005_REG_DATA_LENGTH)
- UPM_THROW("read error");
-
- // Merge MSB and LSB
- rawData = ((uint16_t)( data[SI7005_REG_DATA_LOW] & 0xFFFF )) + ( (uint16_t)(( data[SI7005_REG_DATA_HIGH] & 0xFFFF ) << 8 ));
-
- return rawData;
-}
-
-
-bool
-SI7005::isAvailable( )
-{
- // Enable the sensor
- MraaUtils::setGpio(m_pin, 0);
-
- // Wait for sensor to wake up
- usleep(SI7005_WAKE_UP_TIME);
-
- // Read id register
- m_i2c->address(m_controlAddr);
- uint8_t deviceID = m_i2c->readReg(SI7005_REG_ID);
-
- // Disable the sensor
- MraaUtils::setGpio(m_pin, 1);
-
- return (( deviceID & SI7005_ID) == SI7005_ID );
-}
-
-void
-SI7005::enableHeater( )
-{
- config_reg |= SI7005_CONFIG_HEAT;
-}
-
-void
-SI7005::disableHeater( )
-{
- config_reg ^= SI7005_CONFIG_HEAT;
-}
-
-void
-SI7005::enableFastConversionMode( )
-{
- config_reg |= SI7005_CONFIG_FAST;
-}
-
-void
-SI7005::disableFastConversionMode( )
-{
- config_reg ^= SI7005_CONFIG_FAST;
-}
diff --git a/peripheral/libupm/src/si7005/si7005.hpp b/peripheral/libupm/src/si7005/si7005.hpp
deleted file mode 100644
index bec2825..0000000
--- a/peripheral/libupm/src/si7005/si7005.hpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Author: Scott Ware <scott.r.ware@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <mraa/i2c.hpp>
-
-#include "upm/iTemperatureSensor.hpp"
-#include "upm/iHumiditySensor.hpp"
-
-/* ADDRESS AND NOT_FOUND VALUE */
-#define SI7005_ADDRESS ( 0x40 )
-#define SI7005_NOT_FOUND ( 0x00 )
-
-
-namespace upm {
-
-/**
- * @brief Si7005 digital I2C humidity and temperature sensor library
- * @defgroup si7005 libupm-si7005
- * @ingroup i2c silabs temp itemperaturesensor
- */
-
-/**
- * @brief C++ API for SI7005 sensor (Humidity And Temperature Sensor)
- *
- * The Silicon Labs Si7005
- * [SI7005](https://www.silabs.com/Support%20Documents/TechnicalDocs/Si7005.pdf)
- * is a digital relative humidity and temperature sensor.
- *
- * @library si7005
- * @sensor si7005
- * @comname Silicon Labs Si7005 LED lighting controller
- * @altname Si7005
- * @type temp
- * @man silabs
- * @con i2c
- * @if itemperaturesensor
-
- */
-class SI7005 : public ITemperatureSensor, public IHumiditySensor {
- public:
- /**
- * Instantiates a SI7005 object
- *
- * @param bus number of used bus
- * @param devAddr address of used i2c device
- * @param pin mraa gpio number for chip select pin
- */
- SI7005 (int bus, int pin);
-
- /**
- * SI7005 object destructor.
- */
- ~SI7005 ();
-
- /**
- * Get temperature measurement.
- */
- uint16_t getTemperatureRaw ();
-
- /**
- * Get temperature measurement.
- */
- int getTemperatureCelcius ();
-
- /**
- * Get relative humidity measurement.
- */
- uint16_t getHumidityRaw ();
-
- /**
- * Get relative humidity measurement.
- */
- int getHumidityRelative ();
-
- /**
- * Returns sensor module name
- */
- const char* getModuleName() { return "si7005"; }
-
- /**
- * Detects the sensor to ensure it is connected as required.
- */
- bool isAvailable();
-
- /**
- * Enables the integrated heating element.
- */
- void enableHeater();
-
- /**
- * Disables the integrated heating element.
- */
- void disableHeater();
-
- /**
- * Enables fast conversion mode.
- */
- void enableFastConversionMode();
-
- /**
- * Enables fast conversion mode.
- */
- void disableFastConversionMode();
-
- private:
- int m_controlAddr;
- int m_bus;
- int m_pin;
- mraa::I2c* m_i2c;
- mraa::Result status;
- uint8_t config_reg;
- float last_temperature;
-
- uint16_t getMeasurement(uint8_t configValue);
-};
-
-}
diff --git a/peripheral/libupm/src/sm130/CMakeLists.txt b/peripheral/libupm/src/sm130/CMakeLists.txt
index 71de868..1875951 100644
--- a/peripheral/libupm/src/sm130/CMakeLists.txt
+++ b/peripheral/libupm/src/sm130/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "sm130")
set (libdescription "upm rfid reader")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/sm130/javaupm_sm130.i b/peripheral/libupm/src/sm130/javaupm_sm130.i
index 648620e..5c1e1a9 100644
--- a/peripheral/libupm/src/sm130/javaupm_sm130.i
+++ b/peripheral/libupm/src/sm130/javaupm_sm130.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "sm130.hpp"
+ #include "sm130.h"
%}
-%include "sm130.hpp"
+%include "sm130.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/sm130/jsupm_sm130.i b/peripheral/libupm/src/sm130/jsupm_sm130.i
index ee9e2bc..6ee7806 100644
--- a/peripheral/libupm/src/sm130/jsupm_sm130.i
+++ b/peripheral/libupm/src/sm130/jsupm_sm130.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "sm130.hpp"
+ #include "sm130.h"
%}
-%include "sm130.hpp"
+%include "sm130.h"
diff --git a/peripheral/libupm/src/sm130/pyupm_sm130.i b/peripheral/libupm/src/sm130/pyupm_sm130.i
index 29cfd32..d7cd2b1 100644
--- a/peripheral/libupm/src/sm130/pyupm_sm130.i
+++ b/peripheral/libupm/src/sm130/pyupm_sm130.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "sm130.hpp"
+%include "sm130.h"
%{
- #include "sm130.hpp"
+ #include "sm130.h"
%}
diff --git a/peripheral/libupm/src/sm130/sm130.cxx b/peripheral/libupm/src/sm130/sm130.cxx
index 79489c0..fb84c11 100644
--- a/peripheral/libupm/src/sm130/sm130.cxx
+++ b/peripheral/libupm/src/sm130/sm130.cxx
@@ -24,7 +24,7 @@
#include <stdexcept>
-#include "sm130.hpp"
+#include "sm130.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/sm130/sm130.hpp b/peripheral/libupm/src/sm130/sm130.h
index 2665d5d..2665d5d 100644
--- a/peripheral/libupm/src/sm130/sm130.hpp
+++ b/peripheral/libupm/src/sm130/sm130.h
diff --git a/peripheral/libupm/src/smartdrive/CMakeLists.txt b/peripheral/libupm/src/smartdrive/CMakeLists.txt
deleted file mode 100644
index 014a4dd..0000000
--- a/peripheral/libupm/src/smartdrive/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set (libname "smartdrive")
-set (libdescription "upm SmartDrive")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/smartdrive/javaupm_smartdrive.i b/peripheral/libupm/src/smartdrive/javaupm_smartdrive.i
deleted file mode 100644
index e7183a9..0000000
--- a/peripheral/libupm/src/smartdrive/javaupm_smartdrive.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module javaupm_smartdrive
-%include "../upm.i"
-
-%{
- #include "smartdrive.hpp"
-%}
-
-%include "smartdrive.hpp"
diff --git a/peripheral/libupm/src/smartdrive/jsupm_smartdrive.i b/peripheral/libupm/src/smartdrive/jsupm_smartdrive.i
deleted file mode 100644
index d8b0b55..0000000
--- a/peripheral/libupm/src/smartdrive/jsupm_smartdrive.i
+++ /dev/null
@@ -1,8 +0,0 @@
-%module jsupm_smartdrive
-%include "../upm.i"
-
-%{
- #include "smartdrive.hpp"
-%}
-
-%include "smartdrive.hpp"
diff --git a/peripheral/libupm/src/smartdrive/pyupm_smartdrive.i b/peripheral/libupm/src/smartdrive/pyupm_smartdrive.i
deleted file mode 100644
index 3ed4ff2..0000000
--- a/peripheral/libupm/src/smartdrive/pyupm_smartdrive.i
+++ /dev/null
@@ -1,9 +0,0 @@
-%module pyupm_smartdrive
-%include "../upm.i"
-
-%include "stdint.i"
-
-%include "smartdrive.hpp"
-%{
- #include "smartdrive.hpp"
-%}
diff --git a/peripheral/libupm/src/smartdrive/smartdrive.cxx b/peripheral/libupm/src/smartdrive/smartdrive.cxx
deleted file mode 100644
index 7c94591..0000000
--- a/peripheral/libupm/src/smartdrive/smartdrive.cxx
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Author: Oussema Harbi <oussema.elharbi@gmail.com>
- * Copyright (c) <2016> <Oussema Harbi>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-#include <exception>
-#include <stdexcept>
-#include <unistd.h>
-#include <unistd.h>
-#include <stdlib.h>
-
-#include "smartdrive.hpp"
-
-
-using namespace upm;
-
-SmartDrive::SmartDrive(int i2c_bus, int address): m_smartdrive_control_address(address), m_i2c_smartdrive_control(i2c_bus)
-{
- mraa::Result ret = m_i2c_smartdrive_control.address(m_smartdrive_control_address);
- if (ret != mraa::SUCCESS) {
- throw std::invalid_argument(std::string(__FUNCTION__) +
- ": mraa_i2c_address() failed");
- return;
- }
-}
-
-
-void
-SmartDrive::writeByte(uint8_t addr, uint8_t value) {
- try {
- m_i2c_smartdrive_control.writeReg(addr, value);
- } catch (int e) {
- std::cout << "Failed to write " << value << " to address " << addr << " --> " << e << std::endl;
- }
-}
-
-uint8_t
-SmartDrive::readByte(uint8_t addr) {
- try {
- return m_i2c_smartdrive_control.readReg(addr);
- } catch (int e) {
- std::cout << "Failed to read byte at address " << addr << " --> " << e << std::endl;
- }
- return -1;
-}
-
-void
-SmartDrive::writeArray(uint8_t* array) {
- try {
- m_i2c_smartdrive_control.write(array, sizeof(array)/sizeof(uint8_t));
- } catch (int e) {
- std::cout << "Failed to write array values to address " << array[0] << " --> " << e << std::endl;
- }
-}
-
-uint16_t
-SmartDrive::readInteger(uint8_t addr) {
- try {
- return m_i2c_smartdrive_control.readWordReg(addr);
- } catch (int e) {
- std::cout << "Failed to read value at address " << addr << " --> " << e << std::endl;
- }
- return -1;
-}
-
-uint32_t
-SmartDrive::readLongSigned(uint8_t addr) {
- uint8_t bytes[4]={0};
-
- try {
- m_i2c_smartdrive_control.readBytesReg(addr, bytes, sizeof(bytes)/sizeof(uint8_t));
- return (bytes[0]|(bytes[1]<<8)|(bytes[2]<<16)|(bytes[3]<<24));
- } catch (int e) {
- std::cout << "Failed to read integer value at address " << addr << " --> " << e << std::endl;
- }
- return -1;
-}
-
-void
-SmartDrive::command(uint8_t cmd) {
- std::cout << "Running Command : " << cmd << std::endl;
- writeByte(SmartDrive_COMMAND, cmd);
-}
-
-
-float
-SmartDrive::GetBattVoltage() {
- uint8_t value = 0;
- try {
- value = readByte(SmartDrive_BATT_VOLTAGE);
- return (value * SmartDrive_VOLTAGE_MULTIPLIER);
- } catch (int e) {
- std::cout << "Error: Could not read voltage -> " << e << std::endl;
- }
- return -1.0f;
-}
-
-
-uint32_t
-SmartDrive::ReadTachometerPosition(int motor_id) {
- try {
- if (motor_id == 1 )
- return readLongSigned(SmartDrive_POSITION_M1);
- else
- return readLongSigned(SmartDrive_POSITION_M2);
- } catch (int e) {
- std::cout << "Error: Could not read encoders" << std::endl;
- }
- return -1;
-}
-
-
-void
-SmartDrive::Run_Unlimited(int motor_id, int direction, uint8_t speed) {
- uint8_t ctrl = 0;
- ctrl |= SmartDrive_CONTROL_SPEED;
- ctrl |= SmartDrive_CONTROL_BRK;
-
- std::cout << "Running with speed : " << (int) speed << std::endl;
-
- if ( motor_id != SmartDrive_Motor_ID_BOTH )
- ctrl |= SmartDrive_CONTROL_GO;
- if ( direction != SmartDrive_Dir_Forward )
- speed = speed * -1;
- if ( motor_id != SmartDrive_Motor_ID_2) {
- uint8_t array [5] = {SmartDrive_SPEED_M1, speed, 0, 0, ctrl};
- writeArray(array);
- }
- if ( motor_id != SmartDrive_Motor_ID_1) {
- uint8_t array [5] = {SmartDrive_SPEED_M2, speed, 0, 0, ctrl};
- writeArray(array);
- }
- if ( motor_id == SmartDrive_Motor_ID_BOTH )
- writeByte(SmartDrive_COMMAND, CMD_S);
-}
-
-
-void
-SmartDrive::StopMotor(int motor_id, int next_action ) {
- if ( next_action !=SmartDrive_Action_Float )
- writeByte(SmartDrive_COMMAND, CMD_A+motor_id-1);
- else
- writeByte(SmartDrive_COMMAND, CMD_a+motor_id-1);
-}
-
-void
-SmartDrive::Run_Seconds(int motor_id, int direction, uint8_t speed, uint8_t duration, bool wait_for_completion, int next_action ) {
- uint8_t ctrl = 0;
- ctrl |= SmartDrive_CONTROL_SPEED;
- ctrl |= SmartDrive_CONTROL_TIME;
-
- if ( next_action ==SmartDrive_Action_Brake )
- ctrl |= SmartDrive_CONTROL_BRK;
- if ( next_action ==SmartDrive_Action_BrakeHold ) {
- ctrl |= SmartDrive_CONTROL_BRK;
- ctrl |= SmartDrive_CONTROL_ON;
- }
- if ( motor_id != SmartDrive_Motor_ID_BOTH )
- ctrl |= SmartDrive_CONTROL_GO;
- if ( direction != SmartDrive_Dir_Forward )
- speed = speed * -1;
- if ( motor_id != SmartDrive_Motor_ID_2) {
- uint8_t array[5] = {SmartDrive_SPEED_M1, speed, duration, 0, ctrl};
- writeArray(array);
- }
- if ( motor_id != SmartDrive_Motor_ID_1) {
- uint8_t array[5] = {SmartDrive_SPEED_M2, speed, duration, 0, ctrl};
- writeArray(array);
- }
- if ( motor_id == SmartDrive_Motor_ID_BOTH )
- writeByte(SmartDrive_COMMAND, CMD_S);
- if ( wait_for_completion ) {
- sleep(1); //this delay is required for the status byte to be available for reading.
- WaitUntilTimeDone(motor_id);
- }
-}
-
-
-void
-SmartDrive::WaitUntilTimeDone(int motor_id) {
- while (IsTimeDone(motor_id) == false)
- sleep(1);
-}
-
-
-bool
-SmartDrive::IsTimeDone(int motor_id) {
- uint8_t result_1 = 0, result_2 = 0;
- if ( motor_id != SmartDrive_Motor_ID_2 )
- result_1 = readByte(SmartDrive_STATUS_M1);
- if ( motor_id != SmartDrive_Motor_ID_1 )
- result_2 = readByte(SmartDrive_STATUS_M2);
- return (((result_1 & 0x40) == 0) && ((result_2 & 0x40) == 0) ); //look for time bits to be zero
-}
-
-
-void
-SmartDrive::Run_Degrees(int motor_id, int direction, uint8_t speed, uint32_t degrees, bool wait_for_completion, int next_action) {
- uint8_t ctrl = 0;
- ctrl |= SmartDrive_CONTROL_SPEED;
- ctrl |= SmartDrive_CONTROL_TACHO;
- ctrl |= SmartDrive_CONTROL_RELATIVE;
-
- uint32_t d = degrees;
- if ( direction != SmartDrive_Dir_Forward )
- d = degrees * -1 ;
-
- uint8_t t4 = (d/0x1000000);
- uint8_t t3 = ((d%0x1000000)/0x10000);
- uint8_t t2 = (((d%0x1000000)%0x10000)/0x100);
- uint8_t t1 = (((d%0x1000000)%0x10000)%0x100);
-
- if ( next_action ==SmartDrive_Action_Brake )
- ctrl |= SmartDrive_CONTROL_BRK;
- if ( next_action ==SmartDrive_Action_BrakeHold ) {
- ctrl |= SmartDrive_CONTROL_BRK;
- ctrl |= SmartDrive_CONTROL_ON;
- }
- if ( motor_id != SmartDrive_Motor_ID_BOTH )
- ctrl |= SmartDrive_CONTROL_GO;
- if ( motor_id != SmartDrive_Motor_ID_2) {
- uint8_t array[9] = {SmartDrive_SETPT_M1, t1, t2, t3, t4, speed, 0, 0, ctrl};
- writeArray(array);
- }
- if ( motor_id != SmartDrive_Motor_ID_1){
- uint8_t array[9] = {SmartDrive_SETPT_M2, t1, t2, t3, t4, speed, 0, 0, ctrl};
- writeArray(array);
- }
- if ( motor_id == SmartDrive_Motor_ID_BOTH )
- writeByte(SmartDrive_COMMAND, CMD_S);
- if ( wait_for_completion ) {
- sleep(1);//this delay is required for the status byte to be available for reading.
- WaitUntilTachoDone(motor_id);
- }
-}
-
-
-void
-SmartDrive::Run_Rotations(int motor_id, int direction, uint8_t speed, uint32_t rotations, bool wait_for_completion, int next_action) {
- uint8_t ctrl = 0;
- ctrl |= SmartDrive_CONTROL_SPEED;
- ctrl |= SmartDrive_CONTROL_TACHO;
- ctrl |= SmartDrive_CONTROL_RELATIVE;
-
- uint32_t d = rotations * 360;
- if ( direction != SmartDrive_Dir_Forward )
- d = (rotations * 360) * -1;
-
- uint8_t t4 = (d/0x1000000);
- uint8_t t3 = ((d%0x1000000)/0x10000);
- uint8_t t2 = (((d%0x1000000)%0x10000)/0x100);
- uint8_t t1 = (((d%0x1000000)%0x10000)%0x100);
-
- if ( next_action ==SmartDrive_Action_Brake )
- ctrl |= SmartDrive_CONTROL_BRK;
- if ( next_action ==SmartDrive_Action_BrakeHold ) {
- ctrl |= SmartDrive_CONTROL_BRK;
- ctrl |= SmartDrive_CONTROL_ON;
- }
- if ( motor_id != SmartDrive_Motor_ID_BOTH )
- ctrl |= SmartDrive_CONTROL_GO;
- if ( motor_id != SmartDrive_Motor_ID_2) {
- uint8_t array[9] = {SmartDrive_SETPT_M1, t1, t2, t3, t4, speed, 0, 0, ctrl};
- writeArray(array);
- }
- if ( motor_id != SmartDrive_Motor_ID_1) {
- uint8_t array[9] = {SmartDrive_SETPT_M2, t1, t2, t3, t4, speed, 0, 0, ctrl};
- writeArray(array);
- }
- if ( motor_id == SmartDrive_Motor_ID_BOTH )
- writeByte(SmartDrive_COMMAND, CMD_S);
- if ( wait_for_completion) {
- sleep(1); //this delay is required for the status byte to be available for reading.
- WaitUntilTachoDone(motor_id);
- }
-}
-
-
-void
-SmartDrive::Run_Tacho(int motor_id, uint8_t speed, uint32_t tacho_count, bool wait_for_completion, int next_action) {
- uint8_t ctrl = 0;
- ctrl |= SmartDrive_CONTROL_SPEED;
- ctrl |= SmartDrive_CONTROL_TACHO;
-
- uint32_t d = tacho_count;
-
- uint8_t t4 = (d/0x1000000);
- uint8_t t3 = ((d%0x1000000)/0x10000);
- uint8_t t2 = (((d%0x1000000)%0x10000)/0x100);
- uint8_t t1 = (((d%0x1000000)%0x10000)%0x100);
-
- if ( next_action ==SmartDrive_Action_Brake )
- ctrl |= SmartDrive_CONTROL_BRK;
- if ( next_action ==SmartDrive_Action_BrakeHold ) {
- ctrl |= SmartDrive_CONTROL_BRK;
- ctrl |= SmartDrive_CONTROL_ON;
- }
- if ( motor_id != SmartDrive_Motor_ID_BOTH )
- ctrl |= SmartDrive_CONTROL_GO;
- if ( motor_id != SmartDrive_Motor_ID_2){
- uint8_t array[9]= {SmartDrive_SETPT_M1, t1, t2, t3, t4, speed, 0, 0, ctrl};
- writeArray(array);
- }
- if ( motor_id != SmartDrive_Motor_ID_1){
- uint8_t array[9]= {SmartDrive_SETPT_M2, t1, t2, t3, t4, speed, 0, 0, ctrl};
- writeArray(array);
- }
- if ( motor_id == SmartDrive_Motor_ID_BOTH )
- writeByte(SmartDrive_COMMAND, CMD_S);
- if ( wait_for_completion )
- sleep(1); //this delay is required for the status byte to be available for reading.
- WaitUntilTachoDone(motor_id);
-}
-
-
-void
-SmartDrive::WaitUntilTachoDone(int motor_id) {
- while (IsTachoDone(motor_id) == false)
- sleep(1);
-}
-
-
-bool
-SmartDrive::IsTachoDone(int motor_id) {
- uint8_t result_1 = 0, result_2 = 0;
-
- if ( motor_id != SmartDrive_Motor_ID_2 )
- result_1 = readByte(SmartDrive_STATUS_M1);
- if ( motor_id != SmartDrive_Motor_ID_1 )
- result_2 = readByte(SmartDrive_STATUS_M2);
- //look for both time bits to be zero
- return (((result_1 & 0x08) == 0) && ((result_2 & 0x08) == 0) );
-}
-
-
-void
-SmartDrive::SetPerformanceParameters( uint16_t Kp_tacho, uint16_t Ki_tacho, uint16_t Kd_tacho, uint16_t Kp_speed, uint16_t Ki_speed, uint16_t Kd_speed, uint8_t passcount, uint8_t tolerance) {
- uint8_t Kp_t1 = Kp_tacho%0x100;
- uint8_t Kp_t2 = Kp_tacho/0x100;
- uint8_t Ki_t1 = Ki_tacho%0x100;
- uint8_t Ki_t2 = Ki_tacho/0x100;
- uint8_t Kd_t1 = Kd_tacho%0x100;
- uint8_t Kd_t2 = Kd_tacho/0x100;
- uint8_t Kp_s1 = Kp_speed%0x100;
- uint8_t Kp_s2 = Kp_speed/0x100;
- uint8_t Ki_s1 = Ki_speed%0x100;
- uint8_t Ki_s2 = Ki_speed/0x100;
- uint8_t Kd_s1 = Kd_speed%0x100;
- uint8_t Kd_s2 = Kd_speed/0x100;
-
- uint8_t array[15] = {SmartDrive_P_Kp, Kp_t1 , Kp_t2 , Ki_t1, Ki_t2, Kd_t1, Kd_t2, Kp_s1, Kp_s2, Ki_s1, Ki_s2, Kd_s1, Kd_s2, passcount, tolerance};
- writeArray(array);
-}
-
-
-void
-SmartDrive::ReadPerformanceParameters() {
- try {
- std::cout << "Pkp: " << readInteger(SmartDrive_P_Kp) << std::endl;
- std::cout << "Pki: " << readInteger(SmartDrive_P_Ki) << std::endl;
- std::cout << "Pkd: " << readInteger(SmartDrive_P_Kd) << std::endl;
- std::cout << "Skp: " << readInteger(SmartDrive_S_Kp) << std::endl;
- std::cout << "Ski: " << readInteger(SmartDrive_S_Ki) << std::endl;
- std::cout << "Skd: " << readInteger(SmartDrive_S_Kd) << std::endl;
- std::cout << "Passcount: " << SmartDrive_PASSCOUNT << std::endl; //ToDo : Check if these should actually be Register Reads !!
- std::cout << "Tolerance: " << SmartDrive_PASSTOLERANCE << std::endl;
- } catch( int e) {
- std::cout << "Error: Could not read PID values -> " << e << std::endl;
- }
-}
-
-uint8_t
-SmartDrive::GetMotorStatus(int motor_id) {
- uint8_t status=0;
- if (motor_id == SmartDrive_Motor_ID_1)
- status = readByte(SmartDrive_STATUS_M1);
- if (motor_id == SmartDrive_Motor_ID_2)
- status = readByte(SmartDrive_STATUS_M1);
- if (motor_id == SmartDrive_Motor_ID_BOTH) {
- std::cout << "Please specify which motor's status you want to fetch !" << std::endl;
- }
- return status;
-}
-
-void
-SmartDrive::PrintMotorStatus(int motor_id) {
- if (motor_id != SmartDrive_Motor_ID_BOTH) {
- uint8_t status = GetMotorStatus(motor_id);
- uint8_t control_on = (status & SmartDrive_MOTOR_CONTROL_ON);
- uint8_t is_ramping = (status & SmartDrive_MOTOR_IS_RAMPING);
- uint8_t is_powered = (status & SmartDrive_MOTOR_IS_POWERED);
- uint8_t pos_control_on = (status & SmartDrive_MOTOR_POS_CTRL_ON);
- uint8_t in_brake_mode = (status & SmartDrive_MOTOR_IN_BRAKE_MODE);
- uint8_t is_overloaded = (status & SmartDrive_MOTOR_OVERLOADED);
- uint8_t in_time_mode = (status & SmartDrive_MOTOR_IN_TIME_MODE);
- uint8_t is_stalled = (status & SmartDrive_MOTOR_IS_STALLED);
-
- std::cout << "Motor " << motor_id+1 << " is programemd to move at " << ( (control_on == 0) ? "variable" : "fixed") << " speed" << std::endl;
- std::cout << "Motor " << motor_id+1 << " is " << ((is_ramping == 0) ? "NOT" : "") << " ramping" << std::endl;
- std::cout << "Motor " << motor_id+1 << " is " << ((is_powered == 0) ? "NOT" : "") << " powered" << std::endl;
- std::cout << "Motor " << motor_id+1 << " is " << ((pos_control_on == 0) ? "moving towards desired encoder " : "holding it ") << "position" << std::endl;
- std::cout << "Motor " << motor_id+1 << " is in " << ((in_brake_mode == 0) ? "brake" : "float") << " mode" << std::endl;
- std::cout << "Motor " << motor_id+1 << " is " << ((is_overloaded == 0) ? "NOT" : "") << " overloaded" << std::endl;
- std::cout << "Motor " << motor_id+1 << " is " << ((in_time_mode == 0) ? "NOT" : "") << " in time mode" << std::endl;
- std::cout << "Motor " << motor_id+1 << " is " << ((is_stalled == 0) ? "NOT" : "") << " stalled" << std::endl;
-
- } else {
- std::cout << "Please specify which motor's status you want to fetch !" << std::endl;
- }
-}
diff --git a/peripheral/libupm/src/smartdrive/smartdrive.hpp b/peripheral/libupm/src/smartdrive/smartdrive.hpp
deleted file mode 100644
index 72bcb92..0000000
--- a/peripheral/libupm/src/smartdrive/smartdrive.hpp
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * The MIT License (MIT)
- *
- * Author: Oussema Harbi <oussema.elharbi@gmail.com>
- * Copyright (c) <2016> <Oussema Harbi>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of
- * this software and associated documentation files (the "Software"), to deal in
- * the Software without restriction, including without limitation the rights to
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
- * the Software, and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#pragma once
-
-#include <mraa/i2c.hpp>
-
-//We can use direct integer IDs,
-//or we can use the typedef here to help limit the error cases
-//and still support extension to support more Motors in the future
-//But when using typedef, we need to cast these when sending them in i2c bus
-#define SmartDrive_Motor_ID_1 0x01
-#define SmartDrive_Motor_ID_2 0x02
-#define SmartDrive_Motor_ID_BOTH 0x03
-
-#define SmartDrive_Dir_Reverse 0x00
-#define SmartDrive_Dir_Forward 0x01
-
-#define SmartDrive_Action_Float 0x00 //stop and let the motor coast.
-#define SmartDrive_Action_Brake 0x01 //apply brakes, and resist change to tachometer
-#define SmartDrive_Action_BrakeHold 0x02 //apply brakes, and restore externally forced change to tachometer
-
-//Next action (upon completion of current action)
-#define SmartDrive_Completion_Wait_For 0x01
-#define SmartDrive_Completion_Dont_Wait 0x00
-
-#define SmartDrive_DefaultAddress 0x1b
-#define SmartDrive_VOLTAGE_MULTIPLIER 212.7
-
-//Commonly used speed constants, these are just convenience constants
-//You can use any value between 0 and 100.
-#define SmartDrive_Speed_Full 90
-#define SmartDrive_Speed_Medium 60
-#define SmartDrive_Speed_Slow 25
-
-//Different commands
-#define SmartDrive_CONTROL_SPEED 0x01
-#define SmartDrive_CONTROL_RAMP 0x02
-#define SmartDrive_CONTROL_RELATIVE 0x04
-#define SmartDrive_CONTROL_TACHO 0x08
-#define SmartDrive_CONTROL_BRK 0x10
-#define SmartDrive_CONTROL_ON 0x20
-#define SmartDrive_CONTROL_TIME 0x40
-#define SmartDrive_CONTROL_GO 0x80
-
-#define SmartDrive_COMMAND 0x41
-#define SmartDrive_SETPT_M1 0x42
-#define SmartDrive_SPEED_M1 0x46
-#define SmartDrive_TIME_M1 0x47
-#define SmartDrive_CMD_B_M1 0x48
-#define SmartDrive_CMD_A_M1 0x49
-
-#define SmartDrive_SETPT_M2 0x4A
-#define SmartDrive_SPEED_M2 0x4E
-#define SmartDrive_TIME_M2 0x4F
-#define SmartDrive_CMD_B_M2 0x50
-#define SmartDrive_CMD_A_M2 0x51
-
-//Read registers.
-#define SmartDrive_POSITION_M1 0x52
-#define SmartDrive_POSITION_M2 0x56
-#define SmartDrive_STATUS_M1 0x5A
-#define SmartDrive_STATUS_M2 0x5B
-#define SmartDrive_TASKS_M1 0x5C
-#define SmartDrive_TASKS_M2 0x5D
-
-//PID control registers
-#define SmartDrive_P_Kp 0x5E //proportional gain-position
-#define SmartDrive_P_Ki 0x60 //integral gain-position
-#define SmartDrive_P_Kd 0x62 //derivative gain-position
-#define SmartDrive_S_Kp 0x64 //proportional gain-speed
-#define SmartDrive_S_Ki 0x66 //integral gain-speed
-#define SmartDrive_S_Kd 0x68 //derivative gain-speed
-#define SmartDrive_PASSCOUNT 0x6A
-#define SmartDrive_PASSTOLERANCE 0x6B
-
-#define SmartDrive_CHKSUM 0x6C
-
-//Power data registers
-#define SmartDrive_BATT_VOLTAGE 0x6E
-#define SmartDrive_RESETSTATUS 0x6F
-#define SmartDrive_CURRENT_M1 0x70
-#define SmartDrive_CURRENT_M2 0x72
-
-//Supported I2C commands
-#define CMD_R 0x52
-#define CMD_S 0x53
-#define CMD_a 0x61
-#define CMD_b 0x62
-#define CMD_c 0x63
-#define CMD_A 0x41
-#define CMD_B 0x42
-#define CMD_C 0x43
-
-//Motor Status Masks
-#define SmartDrive_MOTOR_CONTROL_ON 0x1
-#define SmartDrive_MOTOR_IS_RAMPING 0x2
-#define SmartDrive_MOTOR_IS_POWERED 0x4
-#define SmartDrive_MOTOR_POS_CTRL_ON 0x8
-#define SmartDrive_MOTOR_IN_BRAKE_MODE 0x10
-#define SmartDrive_MOTOR_OVERLOADED 0x20
-#define SmartDrive_MOTOR_IN_TIME_MODE 0x40
-#define SmartDrive_MOTOR_IS_STALLED 0x80
-
-namespace upm {
-
-/**
- * @brief SmartDrive library
- * @defgroup smartdrive libupm-smartdrive
- * @ingroup i2c motor openelectrons
- */
-
-/**
- * @library smartdrive
- * @sensor smartdrive
- * @comname SmartDrive advanced motor controller
- * @altname smartdrive
- * @type motor
- * @man openelectrons
- * @con i2c
- *
- * @brief API for the SmartDrive advanced motor controller from OpenElectronis
- *
- * SmartDrive is a multiplexer to control high current DC motors
- *
- * This module has been tested on the SmartDrive.
- *
- * @snippet smartdrive.cxx Interesting
- */
-//Class definition
-class SmartDrive {
-
-public:
- /**
- * Initialize the class with the i2c address of your SmartDrive
- * @param SmartDrive_address Address of your SmartDrive.
- */
- SmartDrive(int i2c_bus, int address = SmartDrive_DefaultAddress);
-
- /**
- * Writes a specified command on the command register of the SmartDrive
- * @param cmd The command you wish the SmartDrive to execute.
- */
- void command(uint8_t cmd);
-
- /**
- * Reads the battery voltage. Multiplier constant not yet verified
- */
- float GetBattVoltage();
-
- /**
- * Reads the tacheometer position of the specified motor
- * @param motor_id Number of the motor you wish to read.
- */
- uint32_t ReadTachometerPosition(int motor_id);
-
- /**
- * Turns the specified motor(s) forever
- * @param motor_id Number of the motor(s) you wish to turn.
- * @param direction The direction you wish to turn the motor(s).
- * @param speed The speed at which you wish to turn the motor(s).
- */
- void Run_Unlimited(int motor_id, int direction, uint8_t speed);
-
- /**
- * Stops the specified motor(s)
- * @param motor_id Number of the motor(s) you wish to turn.
- * @param next_action How you wish to stop the motor(s).
- */
- void StopMotor(int motor_id, int next_action );
-
- /**
- * Turns the specified motor(s) for a given amount of seconds
- * @param motor_id Number of the motor(s) you wish to turn.
- * @param direction The direction you wish to turn the motor(s).
- * @param speed The speed at which you wish to turn the motor(s).
- * @param duration The time in seconds you wish to turn the motor(s).
- * @param wait_for_completion Tells the program when to handle the next line of code.
- * @param next_action How you wish to stop the motor(s).
- */
- void Run_Seconds(int motor_id, int direction, uint8_t speed, uint8_t duration, bool wait_for_completion, int next_action );
-
- /**
- * Waits until the specified time for the motor(s) to run is completed
- * @param motor_id Number of the motor(s) to wait for.
- */
- void WaitUntilTimeDone(int motor_id);
-
- /**
- * Checks to ensure the specified time for the motor(s) to run is completed.
- * @param motor_id Number of the motor(s) to check.
- */
- bool IsTimeDone(int motor_id);
-
- /**
- * Turns the specified motor(s) for given relative tacheometer count
- * @param motor_id Number of the motor(s) you wish to turn.
- * @param direction The direction you wish to turn the motor(s).
- * @param speed The speed at which you wish to turn the motor(s).
- * @param degrees The relative tacheometer count you wish to turn the motor(s).
- * @param wait_for_completion Tells the program when to handle the next line of code.
- * @param next_action How you wish to stop the motor(s).
- */
- void Run_Degrees(int motor_id, int direction, uint8_t speed, uint32_t degrees, bool wait_for_completion, int next_action);
-
- /**
- * Turns the specified motor(s) for given relative tacheometer count
- * @param motor_id Number of the motor(s) you wish to turn.
- * @param direction The direction you wish to turn the motor(s).
- * @param speed The speed at which you wish to turn the motor(s).
- * @param rotations The relative amount of rotations you wish to turn the motor(s).
- * @param wait_for_completion Tells the program when to handle the next line of code.
- * @param next_action How you wish to stop the motor(s).
- */
- void Run_Rotations(int motor_id, int direction, uint8_t speed, uint32_t rotations, bool wait_for_completion, int next_action);
-
- /**
- * Turns the specified motor(s) for given absolute tacheometer count
- * @param motor_id Number of the motor(s) you wish to turn.
- * @param direction The direction you wish to turn the motor(s).
- * @param speed The speed at which you wish to turn the motor(s).
- * @param tacho_count The absolute tacheometer count you wish to turn the motor(s).
- * @param wait_for_completion Tells the program when to handle the next line of code.
- * @param next_action How you wish to stop the motor(s).
- */
- void Run_Tacho(int motor_id, uint8_t speed, uint32_t tacho_count, bool wait_for_completion, int next_action);
-
- /**
- * Waits until the specified tacheomter count for the motor(s) to run is reached.
- * @param motor_id Number of the motor(s) to wait for.
- */
- void WaitUntilTachoDone(int motor_id);
-
- /**
- * Checks to ensure the specified tacheomter count for the motor(s) to run is reached.
- * @param motor_id Number of the motor(s) to check.
- */
- bool IsTachoDone(int motor_id);
-
- /**
- * Writes user specified values to the PID control registers
- * @param Kp_tacho Proportional-gain of the tacheometer position of the motor.
- * @param Ki_tacho Integral-gain of the tacheometer position of the motor.
- * @param Kd_tacho Derivative-gain of the tacheometer position of the motor.
- * @param Kp_speed Proportional-gain of the speed of the motor.
- * @param Ki_speed Integral-gain of the speed of the motor.
- * @param Kd_speed Derivative-gain of the speed of the motor.
- */
- void SetPerformanceParameters( uint16_t Kp_tacho, uint16_t Ki_tacho, uint16_t Kd_tacho, uint16_t Kp_speed, uint16_t Ki_speed, uint16_t Kd_speed, uint8_t passcount, uint8_t tolerance);
-
- /**
- * Reads the values of the PID control registers
- */
- void ReadPerformanceParameters();
-
- /**
- * Read the status of a motor, and return it in a uint8_t
- * param motor_id Number fo the motor to check
- */
- uint8_t GetMotorStatus(int motor_id);
-
- /**
- * Print the detailed status of the motor
- * @param motor_id Number fo the motor to check
- */
- void PrintMotorStatus(int motor_id);
-
-private:
- void writeByte(uint8_t addr, uint8_t value);
- void writeArray(uint8_t* array);
- uint8_t readByte(uint8_t addr);
- uint16_t readInteger(uint8_t addr);
- uint32_t readLongSigned(uint8_t addr);
-
-private:
- int m_smartdrive_control_address;
- mraa::I2c m_i2c_smartdrive_control;
-
-};
-
-}
diff --git a/peripheral/libupm/src/ssd1351/CMakeLists.txt b/peripheral/libupm/src/ssd1351/CMakeLists.txt
index 03a9b6c..ee75b73 100644
--- a/peripheral/libupm/src/ssd1351/CMakeLists.txt
+++ b/peripheral/libupm/src/ssd1351/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "ssd1351")
set (libdescription "libupm SSD1351 SPI LCD")
-set (module_src ssd1351_gfx.cxx ssd1351.cxx)
-set (module_hpp ssd1351_gfx.hpp ssd1351.hpp)
+set (module_src gfx.cxx ssd1351.cxx)
+set (module_h gfx.h ssd1351.h)
upm_module_init()
diff --git a/peripheral/libupm/src/ssd1351/ssd1351_gfx.cxx b/peripheral/libupm/src/ssd1351/gfx.cxx
index 0eadfd1..443932e 100644
--- a/peripheral/libupm/src/ssd1351/ssd1351_gfx.cxx
+++ b/peripheral/libupm/src/ssd1351/gfx.cxx
@@ -28,7 +28,7 @@
#include <unistd.h>
#include <stdlib.h>
-#include "ssd1351_gfx.hpp"
+#include "gfx.h"
using namespace upm;
diff --git a/peripheral/libupm/src/ssd1351/ssd1351_gfx.hpp b/peripheral/libupm/src/ssd1351/gfx.h
index e199cd2..e199cd2 100644
--- a/peripheral/libupm/src/ssd1351/ssd1351_gfx.hpp
+++ b/peripheral/libupm/src/ssd1351/gfx.h
diff --git a/peripheral/libupm/src/ssd1351/javaupm_ssd1351.i b/peripheral/libupm/src/ssd1351/javaupm_ssd1351.i
index 36ca159..7adb59a 100644
--- a/peripheral/libupm/src/ssd1351/javaupm_ssd1351.i
+++ b/peripheral/libupm/src/ssd1351/javaupm_ssd1351.i
@@ -6,14 +6,14 @@
%ignore m_map;
%ignore font;
-%include "ssd1351_gfx.hpp"
+%include "gfx.h"
%{
- #include "ssd1351_gfx.hpp"
+ #include "gfx.h"
%}
-%include "ssd1351.hpp"
+%include "ssd1351.h"
%{
- #include "ssd1351.hpp"
+ #include "ssd1351.h"
%}
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/ssd1351/jsupm_ssd1351.i b/peripheral/libupm/src/ssd1351/jsupm_ssd1351.i
index 37677fc..b096151 100644
--- a/peripheral/libupm/src/ssd1351/jsupm_ssd1351.i
+++ b/peripheral/libupm/src/ssd1351/jsupm_ssd1351.i
@@ -1,12 +1,12 @@
%module jsupm_ssd1351
%include "../upm.i"
-%include "ssd1351_gfx.hpp"
+%include "gfx.h"
%{
- #include "ssd1351_gfx.hpp"
+ #include "gfx.h"
%}
-%include "ssd1351.hpp"
+%include "ssd1351.h"
%{
- #include "ssd1351.hpp"
+ #include "ssd1351.h"
%}
diff --git a/peripheral/libupm/src/ssd1351/pyupm_ssd1351.i b/peripheral/libupm/src/ssd1351/pyupm_ssd1351.i
index 70aa066..fee480d 100644
--- a/peripheral/libupm/src/ssd1351/pyupm_ssd1351.i
+++ b/peripheral/libupm/src/ssd1351/pyupm_ssd1351.i
@@ -6,12 +6,12 @@
%feature("autodoc", "3");
%rename("printString") print(std::string msg);
-%include "ssd1351_gfx.hpp"
+%include "gfx.h"
%{
- #include "ssd1351_gfx.hpp"
+ #include "gfx.h"
%}
-%include "ssd1351.hpp"
+%include "ssd1351.h"
%{
- #include "ssd1351.hpp"
+ #include "ssd1351.h"
%}
diff --git a/peripheral/libupm/src/ssd1351/ssd1351.cxx b/peripheral/libupm/src/ssd1351/ssd1351.cxx
index ab4e1f3..2103603 100644
--- a/peripheral/libupm/src/ssd1351/ssd1351.cxx
+++ b/peripheral/libupm/src/ssd1351/ssd1351.cxx
@@ -30,7 +30,7 @@
#include <unistd.h>
#include <stdlib.h>
-#include "ssd1351.hpp"
+#include "ssd1351.h"
using namespace upm;
using namespace std;
@@ -44,7 +44,7 @@ SSD1351::SSD1351 (uint8_t oc, uint8_t dc, uint8_t rst) :
// Setup SPI bus
m_spi.frequency(8 * 1000000);
- m_spi.mode(mraa::SPI_MODE0);
+ m_spi.mode(mraa::SPI_MODE3);
m_spi.writeByte(0x00); // Need to bring clk high before init
// Init pins
diff --git a/peripheral/libupm/src/ssd1351/ssd1351.hpp b/peripheral/libupm/src/ssd1351/ssd1351.h
index 4462fca..6f23c66 100644
--- a/peripheral/libupm/src/ssd1351/ssd1351.hpp
+++ b/peripheral/libupm/src/ssd1351/ssd1351.h
@@ -30,7 +30,7 @@
#include <mraa/common.hpp>
#include <mraa/gpio.hpp>
#include <mraa/spi.hpp>
-#include "ssd1351_gfx.hpp"
+#include "gfx.h"
// Display Size
#define SSD1351WIDTH 128
@@ -92,13 +92,7 @@ namespace upm {
*
* @brief API for SSD1351 OLED displays
*
- * This module defines the interface for the SSD1351 display library. It was
- * tested with the Adafruit 1.5" OLED Display, but should work with any SSD1351
- * display running in SPI mode.
- *
- * On the Intel Edison don't forget to disable SPI Power Management (PM) for
- * this driver to work, you can find more details on this topic here:
- * http://iotdk.intel.com/docs/master/mraa/edison.html
+ * This module defines the interface for the SSD1351 display library
*
* @image html ssd1351.jpg
* @snippet ssd1351.cxx Interesting
diff --git a/peripheral/libupm/src/st7735/CMakeLists.txt b/peripheral/libupm/src/st7735/CMakeLists.txt
index b424779..f3b3a37 100644
--- a/peripheral/libupm/src/st7735/CMakeLists.txt
+++ b/peripheral/libupm/src/st7735/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "st7735")
set (libdescription "libupm SPI LCD")
-set (module_src st7735_gfx.cxx st7735.cxx)
-set (module_hpp st7735_gfx.hpp st7735.hpp)
+set (module_src gfx.cxx st7735.cxx)
+set (module_h gfx.h st7735.h)
upm_module_init()
diff --git a/peripheral/libupm/src/st7735/st7735_gfx.cxx b/peripheral/libupm/src/st7735/gfx.cxx
index 00c56be..80cd2db 100644
--- a/peripheral/libupm/src/st7735/st7735_gfx.cxx
+++ b/peripheral/libupm/src/st7735/gfx.cxx
@@ -26,7 +26,7 @@
#include <unistd.h>
#include <stdlib.h>
-#include "st7735_gfx.hpp"
+#include "gfx.h"
using namespace upm;
diff --git a/peripheral/libupm/src/st7735/st7735_gfx.hpp b/peripheral/libupm/src/st7735/gfx.h
index 94cb4ef..94cb4ef 100644
--- a/peripheral/libupm/src/st7735/st7735_gfx.hpp
+++ b/peripheral/libupm/src/st7735/gfx.h
diff --git a/peripheral/libupm/src/st7735/javaupm_st7735.i b/peripheral/libupm/src/st7735/javaupm_st7735.i
index be91f46..e60367c 100644
--- a/peripheral/libupm/src/st7735/javaupm_st7735.i
+++ b/peripheral/libupm/src/st7735/javaupm_st7735.i
@@ -35,14 +35,14 @@
$1 = (unsigned char *)JCALL2(GetByteArrayElements, jenv, $input, NULL);
}
-%include "st7735_gfx.hpp"
+%include "gfx.h"
%{
- #include "st7735_gfx.hpp"
+ #include "gfx.h"
%}
-%include "st7735.hpp"
+%include "st7735.h"
%{
- #include "st7735.hpp"
+ #include "st7735.h"
%}
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/st7735/jsupm_st7735.i b/peripheral/libupm/src/st7735/jsupm_st7735.i
index 258db94..ea3809b 100644
--- a/peripheral/libupm/src/st7735/jsupm_st7735.i
+++ b/peripheral/libupm/src/st7735/jsupm_st7735.i
@@ -1,12 +1,12 @@
%module jsupm_st7735
%include "../upm.i"
-%include "st7735_gfx.hpp"
+%include "gfx.h"
%{
- #include "st7735_gfx.hpp"
+ #include "gfx.h"
%}
-%include "st7735.hpp"
+%include "st7735.h"
%{
- #include "st7735.hpp"
+ #include "st7735.h"
%}
diff --git a/peripheral/libupm/src/st7735/pyupm_st7735.i b/peripheral/libupm/src/st7735/pyupm_st7735.i
index a41316b..f1d416e 100644
--- a/peripheral/libupm/src/st7735/pyupm_st7735.i
+++ b/peripheral/libupm/src/st7735/pyupm_st7735.i
@@ -6,12 +6,12 @@
%feature("autodoc", "3");
%rename("printString") print(std::string msg);
-%include "st7735_gfx.hpp"
+%include "gfx.h"
%{
- #include "st7735_gfx.hpp"
+ #include "gfx.h"
%}
-%include "st7735.hpp"
+%include "st7735.h"
%{
- #include "st7735.hpp"
+ #include "st7735.h"
%}
diff --git a/peripheral/libupm/src/st7735/st7735.cxx b/peripheral/libupm/src/st7735/st7735.cxx
index a666cea..ac01c56 100644
--- a/peripheral/libupm/src/st7735/st7735.cxx
+++ b/peripheral/libupm/src/st7735/st7735.cxx
@@ -30,7 +30,7 @@
#include <stdio.h>
#include <string.h>
-#include "st7735.hpp"
+#include "st7735.h"
using namespace upm;
@@ -128,7 +128,7 @@ ST7735::setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) {
m_spiBuffer[1] = x0 + colstart; // XSTART
m_spiBuffer[2] = 0x00;
m_spiBuffer[3] = x1 + colstart; // XEND
- free(m_spi.write(m_spiBuffer, 4));
+ m_spi.write(m_spiBuffer, 4);
write (ST7735_RASET); // Row addr set
@@ -137,7 +137,7 @@ ST7735::setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) {
m_spiBuffer[1] = y0 + rowstart; // YSTART
m_spiBuffer[2] = 0x00;
m_spiBuffer[3] = y1 + rowstart; // YEND
- free(m_spi.write(m_spiBuffer, 4));
+ m_spi.write(m_spiBuffer, 4);
write (ST7735_RAMWR); // write to RAM
}
@@ -157,7 +157,7 @@ ST7735::refresh () {
int fragmentSize = m_height * m_width * 2 / 20;
for (int fragment = 0; fragment < 20; fragment++) {
- free(m_spi.write(&m_map[fragment * fragmentSize], fragmentSize));
+ m_spi.write(&m_map[fragment * fragmentSize], fragmentSize);
}
}
diff --git a/peripheral/libupm/src/st7735/st7735.hpp b/peripheral/libupm/src/st7735/st7735.h
index 4d80400..5f9b902 100644
--- a/peripheral/libupm/src/st7735/st7735.hpp
+++ b/peripheral/libupm/src/st7735/st7735.h
@@ -33,7 +33,7 @@
#include <mraa/gpio.hpp>
#include <mraa/spi.hpp>
-#include "st7735_gfx.hpp"
+#include "gfx.h"
#define INITR_GREENTAB 0x0
#define INITR_REDTAB 0x1
diff --git a/peripheral/libupm/src/stepmotor/CMakeLists.txt b/peripheral/libupm/src/stepmotor/CMakeLists.txt
index 562a50c..666086b 100644
--- a/peripheral/libupm/src/stepmotor/CMakeLists.txt
+++ b/peripheral/libupm/src/stepmotor/CMakeLists.txt
@@ -1,6 +1,6 @@
set (libname "stepmotor")
set (libdescription "upm STEPMOTOR")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
target_link_libraries(${libname} rt)
diff --git a/peripheral/libupm/src/stepmotor/javaupm_stepmotor.i b/peripheral/libupm/src/stepmotor/javaupm_stepmotor.i
index 90505c5..96ec7bc 100644
--- a/peripheral/libupm/src/stepmotor/javaupm_stepmotor.i
+++ b/peripheral/libupm/src/stepmotor/javaupm_stepmotor.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "stepmotor.hpp"
+ #include "stepmotor.h"
%}
-%include "stepmotor.hpp"
+%include "stepmotor.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/stepmotor/jsupm_stepmotor.i b/peripheral/libupm/src/stepmotor/jsupm_stepmotor.i
index dac8f4f..9cea2ec 100644
--- a/peripheral/libupm/src/stepmotor/jsupm_stepmotor.i
+++ b/peripheral/libupm/src/stepmotor/jsupm_stepmotor.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "stepmotor.hpp"
+ #include "stepmotor.h"
%}
-%include "stepmotor.hpp"
+%include "stepmotor.h"
diff --git a/peripheral/libupm/src/stepmotor/pyupm_stepmotor.i b/peripheral/libupm/src/stepmotor/pyupm_stepmotor.i
index d2bdfae..83ade00 100644
--- a/peripheral/libupm/src/stepmotor/pyupm_stepmotor.i
+++ b/peripheral/libupm/src/stepmotor/pyupm_stepmotor.i
@@ -7,7 +7,7 @@
%feature("autodoc", "3");
-%include "stepmotor.hpp"
+%include "stepmotor.h"
%{
- #include "stepmotor.hpp"
+ #include "stepmotor.h"
%}
diff --git a/peripheral/libupm/src/stepmotor/stepmotor.cxx b/peripheral/libupm/src/stepmotor/stepmotor.cxx
index 6a4f5d0..574c536 100644
--- a/peripheral/libupm/src/stepmotor/stepmotor.cxx
+++ b/peripheral/libupm/src/stepmotor/stepmotor.cxx
@@ -28,7 +28,7 @@
#include <stdexcept>
#include <stdlib.h>
#include <time.h>
-#include "stepmotor.hpp"
+#include "stepmotor.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/stepmotor/stepmotor.hpp b/peripheral/libupm/src/stepmotor/stepmotor.h
index 1d996d9..1d996d9 100644
--- a/peripheral/libupm/src/stepmotor/stepmotor.hpp
+++ b/peripheral/libupm/src/stepmotor/stepmotor.h
diff --git a/peripheral/libupm/src/sx1276/CMakeLists.txt b/peripheral/libupm/src/sx1276/CMakeLists.txt
index d5078cf..21fb5ad 100644
--- a/peripheral/libupm/src/sx1276/CMakeLists.txt
+++ b/peripheral/libupm/src/sx1276/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "sx1276")
set (libdescription "SZ1276 LoRa/FSK/OOK radio")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/sx1276/javaupm_sx1276.i b/peripheral/libupm/src/sx1276/javaupm_sx1276.i
index 8b1dd8a..61bb24b 100644
--- a/peripheral/libupm/src/sx1276/javaupm_sx1276.i
+++ b/peripheral/libupm/src/sx1276/javaupm_sx1276.i
@@ -6,13 +6,13 @@
%include "../java_buffer.i"
%{
- #include "sx1276.hpp"
+ #include "sx1276.h"
%}
%ignore send(uint8_t *buffer, uint8_t size, int txTimeout);
%ignore getRxBuffer();
-%include "sx1276.hpp"
+%include "sx1276.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/sx1276/jsupm_sx1276.i b/peripheral/libupm/src/sx1276/jsupm_sx1276.i
index a75f54b..2911804 100644
--- a/peripheral/libupm/src/sx1276/jsupm_sx1276.i
+++ b/peripheral/libupm/src/sx1276/jsupm_sx1276.i
@@ -2,8 +2,8 @@
%include "../upm.i"
%include "cpointer.i"
-%include "sx1276.hpp"
+%include "sx1276.h"
%{
- #include "sx1276.hpp"
+ #include "sx1276.h"
%}
diff --git a/peripheral/libupm/src/sx1276/pyupm_sx1276.i b/peripheral/libupm/src/sx1276/pyupm_sx1276.i
index 0373063..196de39 100644
--- a/peripheral/libupm/src/sx1276/pyupm_sx1276.i
+++ b/peripheral/libupm/src/sx1276/pyupm_sx1276.i
@@ -10,8 +10,8 @@
%pointer_functions(float, floatp);
-%include "sx1276.hpp"
+%include "sx1276.h"
%{
- #include "sx1276.hpp"
+ #include "sx1276.h"
%}
diff --git a/peripheral/libupm/src/sx1276/sx1276.cxx b/peripheral/libupm/src/sx1276/sx1276.cxx
index de37c08..64a5ae3 100644
--- a/peripheral/libupm/src/sx1276/sx1276.cxx
+++ b/peripheral/libupm/src/sx1276/sx1276.cxx
@@ -33,7 +33,7 @@
#undef JAVACALLBACK
#endif
-#include "sx1276.hpp"
+#include "sx1276.h"
using namespace upm;
using namespace std;
@@ -167,7 +167,7 @@ SX1276::~SX1276()
uint8_t SX1276::readReg(uint8_t reg)
{
- uint8_t pkt[2] = {static_cast<uint8_t>(reg & 0x7f), 0};
+ uint8_t pkt[2] = {(reg & 0x7f), 0};
csOn();
if (m_spi.transfer(pkt, pkt, 2))
@@ -184,7 +184,7 @@ uint8_t SX1276::readReg(uint8_t reg)
bool SX1276::writeReg(uint8_t reg, uint8_t val)
{
- uint8_t pkt[2] = {static_cast<uint8_t>(reg | m_writeMode), val};
+ uint8_t pkt[2] = {reg | m_writeMode, val};
csOn();
if (m_spi.transfer(pkt, NULL, 2))
diff --git a/peripheral/libupm/src/sx1276/sx1276.hpp b/peripheral/libupm/src/sx1276/sx1276.h
index 6ef88cf..e23a395 100644
--- a/peripheral/libupm/src/sx1276/sx1276.hpp
+++ b/peripheral/libupm/src/sx1276/sx1276.h
@@ -1740,7 +1740,7 @@ namespace upm {
* FSK : N/A ( set to 0 )
* LoRa: timeout in symbols
* @param fixLen Fixed length packets [false: variable, true: fixed]
- * @param payloadLen Sets payload length when fixed length is used
+ * @param payloadLen Sets payload length when fixed lenght is used
* @param crcOn Enables/Disables the CRC [false: OFF, true: ON]
* @param FreqHopOn Enables disables the intra-packet frequency hopping
* FSK : N/A ( set to 0 )
diff --git a/peripheral/libupm/src/sx6119/CMakeLists.txt b/peripheral/libupm/src/sx6119/CMakeLists.txt
index 459de73..6effe43 100644
--- a/peripheral/libupm/src/sx6119/CMakeLists.txt
+++ b/peripheral/libupm/src/sx6119/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "sx6119")
set (libdescription "upm grove FM receiver")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/sx6119/javaupm_sx6119.i b/peripheral/libupm/src/sx6119/javaupm_sx6119.i
index 4bbf6b7..f7e5327 100644
--- a/peripheral/libupm/src/sx6119/javaupm_sx6119.i
+++ b/peripheral/libupm/src/sx6119/javaupm_sx6119.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "sx6119.hpp"
+ #include "sx6119.h"
%}
-%include "sx6119.hpp"
+%include "sx6119.h"
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/sx6119/jsupm_sx6119.i b/peripheral/libupm/src/sx6119/jsupm_sx6119.i
index eef4381..807008f 100644
--- a/peripheral/libupm/src/sx6119/jsupm_sx6119.i
+++ b/peripheral/libupm/src/sx6119/jsupm_sx6119.i
@@ -2,8 +2,8 @@
%include "../upm.i"
%{
- #include "sx6119.hpp"
+ #include "sx6119.h"
%}
-%include "sx6119.hpp"
+%include "sx6119.h"
diff --git a/peripheral/libupm/src/sx6119/pyupm_sx6119.i b/peripheral/libupm/src/sx6119/pyupm_sx6119.i
index 42cf97b..d98477d 100644
--- a/peripheral/libupm/src/sx6119/pyupm_sx6119.i
+++ b/peripheral/libupm/src/sx6119/pyupm_sx6119.i
@@ -6,8 +6,8 @@
%feature("autodoc", "3");
%{
- #include "sx6119.hpp"
+ #include "sx6119.h"
%}
-%include "sx6119.hpp"
+%include "sx6119.h"
diff --git a/peripheral/libupm/src/sx6119/sx6119.cxx b/peripheral/libupm/src/sx6119/sx6119.cxx
index 5de0911..caa8d96 100644
--- a/peripheral/libupm/src/sx6119/sx6119.cxx
+++ b/peripheral/libupm/src/sx6119/sx6119.cxx
@@ -27,7 +27,7 @@
#include <string>
#include <stdexcept>
-#include "sx6119.hpp"
+#include "sx6119.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/sx6119/sx6119.hpp b/peripheral/libupm/src/sx6119/sx6119.h
index f226883..f226883 100644
--- a/peripheral/libupm/src/sx6119/sx6119.hpp
+++ b/peripheral/libupm/src/sx6119/sx6119.h
diff --git a/peripheral/libupm/src/t3311/CMakeLists.txt b/peripheral/libupm/src/t3311/CMakeLists.txt
index 9938378..89bc6b9 100644
--- a/peripheral/libupm/src/t3311/CMakeLists.txt
+++ b/peripheral/libupm/src/t3311/CMakeLists.txt
@@ -1,23 +1,24 @@
set (libname "t3311")
set (libdescription "upm module for the Comet System T3311")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
-pkg_check_modules(MODBUS libmodbus)
+pkg_search_module(MODBUS libmodbus)
if (MODBUS_FOUND)
set (reqlibname "libmodbus")
include_directories(${MODBUS_INCLUDE_DIRS})
upm_module_init()
+ add_dependencies(${libname} ${MODBUS_LIBRARIES})
target_link_libraries(${libname} ${MODBUS_LIBRARIES})
if (BUILDSWIG)
if (BUILDSWIGNODE)
- swig_link_libraries (jsupm_${libname} ${MODBUS_LIBRARIES})
+ swig_link_libraries (jsupm_${libname} ${MODBUS_LIBRARIES} ${MRAA_LIBRARIES} ${NODE_LIBRARIES})
endif()
if (BUILDSWIGPYTHON)
- swig_link_libraries (pyupm_${libname} ${MODBUS_LIBRARIES})
+ swig_link_libraries (pyupm_${libname} ${MODBUS_LIBRARIES} ${PYTHON_LIBRARIES} ${MRAA_LIBRARIES})
endif()
if (BUILDSWIGJAVA)
- swig_link_libraries (javaupm_${libname} ${MODBUS_LIBRARIES})
+ swig_link_libraries (javaupm_${libname} ${MODBUS_LIBRARIES} ${MRAAJAVA_LDFLAGS} ${JAVA_LDFLAGS})
endif()
endif()
endif ()
diff --git a/peripheral/libupm/src/t3311/javaupm_t3311.i b/peripheral/libupm/src/t3311/javaupm_t3311.i
index 611a347..a383b49 100644
--- a/peripheral/libupm/src/t3311/javaupm_t3311.i
+++ b/peripheral/libupm/src/t3311/javaupm_t3311.i
@@ -6,10 +6,10 @@
%include "../java_buffer.i"
%{
- #include "t3311.hpp"
+ #include "t3311.h"
%}
-%include "t3311.hpp"
+%include "t3311.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/t3311/jsupm_t3311.i b/peripheral/libupm/src/t3311/jsupm_t3311.i
index d9e76e4..4b07290 100644
--- a/peripheral/libupm/src/t3311/jsupm_t3311.i
+++ b/peripheral/libupm/src/t3311/jsupm_t3311.i
@@ -5,7 +5,7 @@
%pointer_functions(float, floatp);
-%include "t3311.hpp"
+%include "t3311.h"
%{
- #include "t3311.hpp"
+ #include "t3311.h"
%}
diff --git a/peripheral/libupm/src/t3311/pyupm_t3311.i b/peripheral/libupm/src/t3311/pyupm_t3311.i
index 203517a..51f706b 100644
--- a/peripheral/libupm/src/t3311/pyupm_t3311.i
+++ b/peripheral/libupm/src/t3311/pyupm_t3311.i
@@ -9,7 +9,7 @@
%pointer_functions(float, floatp);
-%include "t3311.hpp"
+%include "t3311.h"
%{
- #include "t3311.hpp"
+ #include "t3311.h"
%}
diff --git a/peripheral/libupm/src/t3311/t3311.cxx b/peripheral/libupm/src/t3311/t3311.cxx
index 342ebfa..0111556 100644
--- a/peripheral/libupm/src/t3311/t3311.cxx
+++ b/peripheral/libupm/src/t3311/t3311.cxx
@@ -29,7 +29,7 @@
#include <sstream>
#include <pthread.h>
-#include "t3311.hpp"
+#include "t3311.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/t3311/t3311.hpp b/peripheral/libupm/src/t3311/t3311.h
index f84dc95..f84dc95 100644
--- a/peripheral/libupm/src/t3311/t3311.hpp
+++ b/peripheral/libupm/src/t3311/t3311.h
diff --git a/peripheral/libupm/src/t6713/CMakeLists.txt b/peripheral/libupm/src/t6713/CMakeLists.txt
deleted file mode 100644
index b610aa9..0000000
--- a/peripheral/libupm/src/t6713/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set (libname "t6713")
-set (libdescription "upm Amphenol Telaire 6713 Series CO2 Module")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/t6713/javaupm_t6713.i b/peripheral/libupm/src/t6713/javaupm_t6713.i
deleted file mode 100644
index 9851bea..0000000
--- a/peripheral/libupm/src/t6713/javaupm_t6713.i
+++ /dev/null
@@ -1,23 +0,0 @@
-%module javaupm_t6713
-%include "../upm.i"
-%include "arrays_java.i";
-%include "../java_buffer.i"
-%include "cpointer.i"
-%include "typemaps.i"
-
-%{
- #include "t6713.hpp"
-%}
-
-%include "t6713.hpp"
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_t6713");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/t6713/jsupm_t6713.i b/peripheral/libupm/src/t6713/jsupm_t6713.i
deleted file mode 100644
index f929b29..0000000
--- a/peripheral/libupm/src/t6713/jsupm_t6713.i
+++ /dev/null
@@ -1,9 +0,0 @@
-%module jsupm_t6713
-%include "../upm.i"
-%include "../carrays_uint16_t.i"
-
-%{
- #include "t6713.hpp"
-%}
-
-%include "t6713.hpp"
diff --git a/peripheral/libupm/src/t6713/pyupm_t6713.i b/peripheral/libupm/src/t6713/pyupm_t6713.i
deleted file mode 100644
index ab74916..0000000
--- a/peripheral/libupm/src/t6713/pyupm_t6713.i
+++ /dev/null
@@ -1,10 +0,0 @@
-%module pyupm_t6713
-%include "../upm.i"
-%include "stdint.i"
-
-%feature("autodoc", "3");
-
-%include "t6713.hpp"
-%{
- #include "t6713.hpp"
-%}
diff --git a/peripheral/libupm/src/t6713/t6713.cxx b/peripheral/libupm/src/t6713/t6713.cxx
deleted file mode 100644
index c2c9126..0000000
--- a/peripheral/libupm/src/t6713/t6713.cxx
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Author: HCL
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-#include <unistd.h>
-#include <stdlib.h>
-#include <math.h>
-#include <errno.h>
-#include <t6713.hpp>
-
-#define T6713_ADDR 0x15
-
-/* REGISTER ADDRESSES */
-#define T6713_REG_FIRMWARE_REVISION 0x1389
-
-#define T6713_REG_STATUS 0x138A
-
-#define T6713_REG_GAS_PPM 0x138B
-
-#define T6713_REG_RESET_DEVICE 0x03E8
-
-#define T6713_REG_START_SINGLE_POINT_CAL 0x03EC
-
-#define T6713_REG_CHANGE_SLAVE_ADDRESS 0x0FA5
-
-#define T6713_REG_ABC_LOGIC_ENABLE_DISABLE 0x03EE
-
-using namespace upm;
-using namespace upm::t6713_co2;
-
-T6713::T6713 (int bus)
-{
- i2c = new mraa::I2c(bus);
- status = i2c->address(T6713_ADDR);
- uint16_t firmwareRevision = getFirmwareRevision();
- if (firmwareRevision != mraa::SUCCESS)
- UPM_THROW("config failure");
-}
-
-T6713::~T6713()
-{
- delete i2c;
-}
-
-const char* T6713::getModuleName()
-{
- return "t6713";
-}
-
-uint16_t T6713::getFirmwareRevision()
-{
- return(getSensorData(T6713_COMMAND_GET_FIRMWARE_REVISION));
-}
-
-uint16_t T6713::getPpm ()
-{
- return(getSensorData(T6713_COMMAND_GET_GAS_PPM));
-}
-
-uint16_t T6713::getSensorData (MODBUS_COMMANDS cmd)
-{
- uint16_t data ,readBytes ;
- STATUS currStatus ;
- switch(currStatus = getStatus()) /* handle error conditions */
- {
- case ERROR_CONDITION:
- UPM_THROW ("error condition");
- break;
- case FLASH_ERROR:
- UPM_THROW ("flash error");
- break;
- case CALIBRATION_ERROR:
- UPM_THROW ("calibration error");
- break;
- case WARMUP_MODE:
- //UPM_THROW ("warmup mode");
- break;
- case RS232:
- //printf("\nRS232 mode set\n ");
- break;
- case RS485:
- //printf("\nRS485 mode set\n ");
- break;
- case I2C:
- //printf("\nI2C mode set\n");
- data = 0;
- runCommand(cmd);
- mraa::Result ret = i2c->address(T6713_ADDR);
- if (ret != mraa::SUCCESS)
- {
- UPM_THROW ("I2C error setting slave address");
- // TODO: need to handle this
- }
- RESPONSE * response = new RESPONSE ;
- if(readBytes = i2c->read((uint8_t*)(response), sizeof(RESPONSE) ) != sizeof(RESPONSE))
- {
- UPM_THROW("I2C read failed");
- // TODO
- }
- if(response->function_code == READ_INPUT_REGISTERS)
- {
- if(response->byte_count == 2)
- {
- data = (response->status_msb << 8 | response->status_lsb);
- }
- }
- delete(response); response=NULL;
- return(data);
- break;
- }
- return 0;
-
-}
-
-
-mraa::Result T6713::runCommand(MODBUS_COMMANDS cmd)
-{
-
- COMMAND * cmdPacket = new COMMAND ;
- mraa::Result ret;
-
- switch(cmd)
- {
- case T6713_COMMAND_RESET:
- cmdPacket->function_code = WRITE_SINGLE_COIL;
- cmdPacket->register_address_msb = (T6713_REG_RESET_DEVICE >> 8);
- cmdPacket->register_address_lsb = (T6713_REG_RESET_DEVICE & 0xff);
- cmdPacket->input_registers_to_read_msb = 0xff;
- cmdPacket->input_registers_to_read_lsb = 0x00;
- ret = i2c->write((const uint8_t*) (cmdPacket), sizeof(COMMAND));
- /*no response from the slave */
- break;
- case T6713_COMMAND_STATUS:
- /*created the modbus status command packet*/
- cmdPacket->function_code = READ_INPUT_REGISTERS;
- cmdPacket->register_address_msb = (T6713_REG_STATUS >> 8);
- cmdPacket->register_address_lsb = (T6713_REG_STATUS & 0xff);
- cmdPacket->input_registers_to_read_msb = 0;
- cmdPacket->input_registers_to_read_lsb = 1;
- ret = i2c->address(T6713_ADDR);
- if (ret != mraa::SUCCESS)
- {
- UPM_THROW ("I2C error setting slave address");
- }
-
- if((ret = i2c->write((const uint8_t*) (cmdPacket), sizeof(COMMAND))) != mraa::SUCCESS)
- {
- UPM_THROW("I2C write failed");
- }
-
-
- break;
- case T6713_COMMAND_GET_FIRMWARE_REVISION:
- cmdPacket->function_code = READ_INPUT_REGISTERS;
- cmdPacket->register_address_msb = (T6713_REG_FIRMWARE_REVISION >> 8);
- cmdPacket->register_address_lsb = (T6713_REG_FIRMWARE_REVISION & 0xff);
- cmdPacket->input_registers_to_read_msb = 0;
- cmdPacket->input_registers_to_read_lsb = 1;
- ret = i2c->write((const uint8_t*) (cmdPacket), sizeof(COMMAND));
- break;
- case T6713_COMMAND_GET_GAS_PPM:
- cmdPacket->function_code = READ_INPUT_REGISTERS;
- cmdPacket->register_address_msb = (T6713_REG_GAS_PPM >> 8);
- cmdPacket->register_address_lsb = (T6713_REG_GAS_PPM & 0xff);
-
- cmdPacket->input_registers_to_read_msb = 0;
- cmdPacket->input_registers_to_read_lsb = 1;
- ret = i2c->address(T6713_ADDR);
- if (ret != mraa::SUCCESS)
- {
- UPM_THROW ("I2C error setting slave address");
- //need to handle this
- }
-
-
- if((ret = i2c->write((const uint8_t*) (cmdPacket), sizeof(COMMAND))) != mraa::SUCCESS)
- {
- UPM_THROW("I2C write failed");
- }
-
- break;
- }
- delete cmdPacket; cmdPacket=NULL;
-
- return ret;
-}
-
-
-STATUS T6713::getStatus()
-{
- uint16_t responseStatus = 0, readBytes = 0;
- RESPONSE * response = new RESPONSE ;
- runCommand(T6713_COMMAND_STATUS);
- mraa::Result ret = i2c->address(T6713_ADDR);
- if (ret != mraa::SUCCESS)
- {
- UPM_THROW ("I2C error setting slave address");
- //need to handle tnis
- }
- if(readBytes = i2c->read((uint8_t*) (response), sizeof(RESPONSE)) != sizeof(RESPONSE))
- {
- UPM_THROW("I2C read failed");
-
- }
- if(response->function_code == READ_INPUT_REGISTERS)
- {
- if(response->byte_count == 2)
- {
- responseStatus = (response->status_msb << 8 | response->status_lsb);
- }
- else
- {
- UPM_THROW("I2C read failed");
-
- }
- }
- else
- {
- UPM_THROW("MODBUS function code failed");
- }
-
- delete(response);
-
- if(responseStatus & 0x0001)
- {
- return ERROR_CONDITION;
- }
- if(responseStatus & 0x0002)
- {
- return FLASH_ERROR;
- }
- if(responseStatus & 0x0004)
- {
- return CALIBRATION_ERROR;
- }
- if(responseStatus & 0x0800)
- {
- return WARMUP_MODE;
- }
- if(responseStatus & 0x8000)
- {
- return SINGLE_POINT_CALIBRATION;
- }
- if(responseStatus & 0x0100)
- {
- return RS232;
- }
- if(responseStatus & 0x0400)
- {
- return RS485;
- }
- else
- {
- return I2C;
- }
-}
-
diff --git a/peripheral/libupm/src/t6713/t6713.hpp b/peripheral/libupm/src/t6713/t6713.hpp
deleted file mode 100644
index 06a973b..0000000
--- a/peripheral/libupm/src/t6713/t6713.hpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Author: HCL
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-#include "mraa/i2c.hpp"
-#include "upm/iCO2Sensor.hpp"
-
-namespace upm {
-
-/**
- * @brief Amphenol Telaire 6713 Series CO2 Module
- * @defgroup t6713 libupm-t6713
- * @ingroup i2c telaire gas ico2sensor
- */
-
-/**
- * @brief C++ API for Amphenol Telaire 6713 Series CO2 Module
- *
- * The Telaire 6713 Series CO2 Module
- * [6713](http://amphenol-sensors.com/en/products/co2/co2-modules/3215-t6700#specifications-t6713)
- * is a CO2 Module sensor.
- *
- * @library t6713
- * @sensor t6713
- * @comname Telaire 6713 Series CO2 Module
- * @altname T6713
- * @type gaseous
- * @man amphenol
- * @con i2c
- * @if ic02sensor
-
- */
-namespace t6713_co2
-{
- /* COMMAND VALUES */
- typedef enum
- {
- T6713_COMMAND_RESET,
- T6713_COMMAND_STATUS,
- T6713_COMMAND_GET_FIRMWARE_REVISION,
- T6713_COMMAND_GET_GAS_PPM
- }MODBUS_COMMANDS;
-
-
-
- typedef enum
- {
- ERROR_CONDITION,
- FLASH_ERROR,
- CALIBRATION_ERROR,
- WARMUP_MODE,
- SINGLE_POINT_CALIBRATION,
- RS232,
- I2C,
- RS485
- }STATUS;
-
- typedef struct
- {
- uint8_t function_code;
- uint8_t register_address_msb;
- uint8_t register_address_lsb;
- uint8_t input_registers_to_read_msb;
- uint8_t input_registers_to_read_lsb;
-
- }COMMAND;
-
- typedef struct
- {
- uint8_t function_code;
- uint8_t byte_count;
- uint8_t status_msb;
- uint8_t status_lsb;
-
- }RESPONSE;
-
-
- typedef enum
- {
- READ_INPUT_REGISTERS = 4,
- WRITE_SINGLE_COIL,
- WRITE_SINGLE_HOLDING_REGISTER
- }FUNCTION_CODES;
-}//namespace t6713_co2
-
-
-class T6713 : public ICO2Sensor {
- public:
- /**
- * Instantiates a T6713 object
- *
- * @param bus number of used bus
- */
- T6713 (int bus);
-
- /**
- * SI7005 object destructor.
- */
- ~T6713 ();
-
- /**
- * Returns sensor module name
- */
- const char* getModuleName();
-
- /**
- * Get relative humidity measurement.
- */
- uint16_t getPpm ();
- /**
- * Get the firmware version
- */
- uint16_t getFirmwareRevision();
-
-
- private:
- mraa::Result runCommand(t6713_co2::MODBUS_COMMANDS command);
- uint16_t getSensorData (t6713_co2::MODBUS_COMMANDS cmd);
- t6713_co2::STATUS getStatus();
-
- int bus;
- mraa::I2c* i2c;
- mraa::Result status;
-};
-
-
-}//namespace upm
diff --git a/peripheral/libupm/src/t8100/CMakeLists.txt b/peripheral/libupm/src/t8100/CMakeLists.txt
deleted file mode 100644
index cc68020..0000000
--- a/peripheral/libupm/src/t8100/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-set (libname "t8100")
-set (libdescription "upm module for the Telaire T8100 Ventostat")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-
-pkg_check_modules(BACNET libbacnet)
-if (BACNET_FOUND)
- # upm-libbacnetmstp will bring in libbacnet, I hope
- set (reqlibname "upm-bacnetmstp")
- include_directories(${BACNET_INCLUDE_DIRS})
- include_directories("../bacnetmstp")
- upm_module_init()
- target_link_libraries(${libname} bacnetmstp)
- if (BUILDSWIG)
- if (BUILDSWIGNODE)
- set_target_properties(${SWIG_MODULE_jsupm_${libname}_REAL_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE)
- swig_link_libraries (jsupm_${libname} bacnetmstp)
- endif()
- if (BUILDSWIGPYTHON)
- set_target_properties(${SWIG_MODULE_pyupm_${libname}_REAL_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE)
- swig_link_libraries (pyupm_${libname} bacnetmstp)
- endif()
- if (BUILDSWIGJAVA)
- set_target_properties(${SWIG_MODULE_javaupm_${libname}_REAL_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE)
- swig_link_libraries (javaupm_${libname} bacnetmstp)
- endif()
- endif()
-endif ()
diff --git a/peripheral/libupm/src/t8100/javaupm_t8100.i b/peripheral/libupm/src/t8100/javaupm_t8100.i
deleted file mode 100644
index 20e9a92..0000000
--- a/peripheral/libupm/src/t8100/javaupm_t8100.i
+++ /dev/null
@@ -1,22 +0,0 @@
-%module javaupm_t8100
-%include "../upm.i"
-%include "typemaps.i"
-
-%include "bacnetmstp.hpp"
-%include "bacnetutil.hpp"
-%include "t8100.hpp"
-%{
- #include "t8100.hpp"
-%}
-
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_t8100");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/t8100/jsupm_t8100.i b/peripheral/libupm/src/t8100/jsupm_t8100.i
deleted file mode 100644
index 147dc73..0000000
--- a/peripheral/libupm/src/t8100/jsupm_t8100.i
+++ /dev/null
@@ -1,10 +0,0 @@
-%module jsupm_t8100
-%include "../upm.i"
-%include "stdint.i"
-
-%include "bacnetmstp.hpp"
-%include "bacnetutil.hpp"
-%include "t8100.hpp"
-%{
- #include "t8100.hpp"
-%}
diff --git a/peripheral/libupm/src/t8100/pyupm_t8100.i b/peripheral/libupm/src/t8100/pyupm_t8100.i
deleted file mode 100644
index db003c7..0000000
--- a/peripheral/libupm/src/t8100/pyupm_t8100.i
+++ /dev/null
@@ -1,14 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_t8100
-%include "../upm.i"
-%include "stdint.i"
-
-%feature("autodoc", "3");
-
-%include "bacnetmstp.hpp"
-%include "bacnetutil.hpp"
-%include "t8100.hpp"
-%{
- #include "t8100.hpp"
-%}
diff --git a/peripheral/libupm/src/t8100/t8100.cxx b/peripheral/libupm/src/t8100/t8100.cxx
deleted file mode 100644
index 6e5b596..0000000
--- a/peripheral/libupm/src/t8100/t8100.cxx
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <assert.h>
-#include <errno.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-
-#include "t8100.hpp"
-
-using namespace upm;
-using namespace std;
-
-// conversion from fahrenheit to celcius and back
-
-static float f2c(float f)
-{
- return ((f - 32.0) / (9.0 / 5.0));
-}
-
-static float c2f(float c)
-{
- return (c * (9.0 / 5.0) + 32.0);
-}
-
-
-T8100::T8100(uint32_t targetDeviceObjectID) :
- BACNETUTIL(targetDeviceObjectID)
-{
- setDebug(false);
-
- // we disable this by default for performance reasons
- checkReliability(false);
-
- m_isTempInitialized = false;
- m_isCelcius = false;
-
- m_humidity = 0.0;
- m_temperature = 0.0;
- m_co2 = 0.0;
- m_relayState = false;
-}
-
-T8100::~T8100()
-{
-}
-
-void T8100::update()
-{
- if (!m_isTempInitialized)
- {
- // this will update internals so conversions work properly
- getTemperatureScale();
- }
-
- float tmpF = getAnalogInput(AI_Temperature_Thermistor);
-
- if (m_isCelcius)
- m_temperature = tmpF;
- else
- m_temperature = f2c(tmpF);
-
- m_humidity = getAnalogInput(AI_Relative_Humidity);
- m_co2 = getAnalogInput(AI_CO2);
- m_relayState = getBinaryInput(BI_Relay_State);
-}
-
-float T8100::getTemperature(bool fahrenheit)
-{
- if (fahrenheit)
- return c2f(m_temperature);
- else
- return m_temperature;
-}
-
-void T8100::setTemperatureScale(bool fahrenheit)
-{
- setBinaryValue(BV_Temperature_Units, fahrenheit);
-
- m_isTempInitialized = true;
- m_isCelcius = (fahrenheit) ? false : true;
-}
-
-bool T8100::getTemperatureScale()
-{
- bool scale = getBinaryValue(BV_Temperature_Units);
-
- m_isTempInitialized = true;
- m_isCelcius = !scale;
-
- return scale;
-}
-
-float T8100::getTemperatureOffset()
-{
- return getAnalogValue(AV_Temperature_Offset);
-}
-
-void T8100::setTemperatureOffset(float value)
-{
- // Always in C...
- if (value < -50.0 || value > 50.0)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": value must be between -50 and 50,"
- + " in degrees Celcius");
-
- }
-
- setAnalogValue(AV_Temperature_Offset, value);
-}
-
-float T8100::getHumidityOffset()
-{
- return getAnalogValue(AV_RH_Offset);
-}
-
-void T8100::setHumidityOffset(float value)
-{
- if (value < -100.0 || value > 100.0)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": value must be between -100 and 100");
- }
-
- setAnalogValue(AV_RH_Offset, value);
-}
-
-float T8100::getRelaySetPoint()
-{
- return getAnalogValue(AV_Relay_Set_Point);
-}
-
-void T8100::setRelaySetPoint(float value)
-{
- if (value < 0.00 || value > 65535.0)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": value must be between 0 and 65535");
- }
-
- setAnalogValue(AV_Relay_Set_Point, value);
-}
-
-float T8100::getRelayHysteresis()
-{
- return getAnalogValue(AV_Relay_Hysteresis);
-}
-
-void T8100::setRelayHysteresis(float value)
-{
- if (value < 0.00 || value > 65535.0)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": value must be between 0 and 65535");
- }
-
- setAnalogValue(AV_Relay_Hysteresis, value);
-}
-
-float T8100::getElevation()
-{
- return getAnalogValue(AV_Elevation);
-}
-
-void T8100::setElevation(float value)
-{
- if (value < 0.00 || value > 65535.0)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": value must be between 0 and 65535");
- }
-
- setAnalogValue(AV_Elevation, value);
-}
-
-float T8100::getCalibrationSinglePoint()
-{
- return getAnalogValue(AV_Calibration_Single_Point);
-}
-
-void T8100::setCalibrationSinglePoint(float value)
-{
- if (value < 0.00 || value > 65535.0)
- {
- throw std::out_of_range(std::string(__FUNCTION__)
- + ": value must be between 0 and 65535");
- }
-
- setAnalogValue(AV_Calibration_Single_Point, value);
-}
-
-float T8100::getBaudRate()
-{
- return getAnalogValue(AV_Baud_Rate);
-}
-
-float T8100::getMACAddress()
-{
- return getAnalogValue(AV_MAC_Address);
-}
-
-bool T8100::getABCLogicState()
-{
- return getBinaryValue(BV_ABC_Logic_State);
-}
-
-void T8100::setABCLogicState(bool value)
-{
- setBinaryValue(BV_ABC_Logic_State, value);
-}
-
-bool T8100::getABCLogicReset()
-{
- return getBinaryValue(BV_ABC_Logic_Reset);
-}
-
-void T8100::setABCLogicReset(bool value)
-{
- setBinaryValue(BV_ABC_Logic_Reset, value);
-}
-
-bool T8100::getCO2Calibration()
-{
- return getBinaryValue(BV_CO2_Calibration);
-}
-
-void T8100::setCO2Calibration(bool value)
-{
- setBinaryValue(BV_CO2_Calibration, value);
-}
diff --git a/peripheral/libupm/src/t8100/t8100.hpp b/peripheral/libupm/src/t8100/t8100.hpp
deleted file mode 100644
index bc53d82..0000000
--- a/peripheral/libupm/src/t8100/t8100.hpp
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <map>
-
-#include "bacnetmstp.hpp"
-#include "bacnetutil.hpp"
-
-namespace upm {
-
- /**
- * @brief Amphenol Telaire Ventostat T8100 Ventilation Controller
- * @defgroup t8100 libupm-t8100
- * @ingroup uart temp gaseous
- */
-
- /**
- * @library t8100
- * @sensor t8100
- * @comname UPM API for the Amphenol Telaire Ventostat T8100
- * Ventilation Controller
- * @type gaseous temp
- * @man amphenol
- * @con uart
- * @web https://www.instrumart.com/products/configure/18180?quantity=1
- *
- * @brief UPM API for the Amphenol Telaire Ventostat T8100
- * Ventilation Controller
- *
- * This module implements support for the Amphenol Telaire Ventostat
- * T8100 Ventilation Controller with BACnet interface. It may also
- * support the T8200 and T8300 models, but they have not been
- * tested.
- *
- * The Telaire Ventostat T8100 reports Temperature, Humidity and CO2
- * concentrations. It supports an optional relay with a settable
- * trigger point. The unit this driver was tested under did not
- * support the optional relay. The temperature range supported is
- * 0-50C, humidity is 0-100% non-condensing, and CO2 range is
- * appoximately 0-2000 PPM for the T8100. Other sensors in this
- * family support wider ranges.
- *
- * This module was developed using the upm::BACNETMSTP library,
- * based on libbacnet-stack 0.8.3. Both libbacnet 0.8.3 and the
- * upm::BACNETMSTP libraries must be present in order to build this
- * module.
- *
- * It was connected using an RS232->RS485 interface. You cannot use
- * the built in MCU TTL UART pins for accessing this device -- you
- * must use a full Serial RS232->RS485 or USB-RS485 interface
- * connected via USB.
- *
- * @snippet t8100.cxx Interesting
- */
-
- class T8100 : public BACNETUTIL {
- public:
-
- // Supported Analog Value Objects. These are readable and writable.
- typedef enum : uint32_t {
- AV_Temperature_Offset = 1,
- AV_RH_Offset = 2,
- AV_Relay_Set_Point = 3,
- AV_Relay_Hysteresis = 4,
- AV_Elevation = 5,
- AV_Calibration_Single_Point = 6,
- AV_Baud_Rate = 7,
- AV_MAC_Address = 8
- } ANALOG_VALUES_T;
-
- // Supported Analog Input Objects. These are read only.
- typedef enum : uint32_t {
- AI_CO2 = 1,
- AI_Relative_Humidity = 2,
- AI_Temperature_ChipCap = 3,
- AI_Temperature_Thermistor = 4
- } ANALOG_INPUTS_T;
-
- // Supported Binary Value Objects. These are readable and writable.
- typedef enum : uint32_t {
- BV_Temperature_Units = 1,
- BV_ABC_Logic_State = 2,
- BV_ABC_Logic_Reset = 3,
- BV_CO2_Calibration = 4
- } BINARY_VALUES_T;
-
- // Supported Binary Input Objects. These are read only.
- typedef enum : uint32_t {
- BI_Relay_State = 1
- } BINARY_INPUTS_T;
-
-
- /**
- * T8100 constructor
- *
- * @param targetDeviceObjectID the unique Instance ID of the
- * Device Object. This number is used to uniquely identify
- * devices on the BACnet network, and ranges from 1 to 4194302.
- * This is not the device's MAC address, though on some devices,
- * the MAC address may be used as part of this number. On the
- * T8100, this number is 568XXX, where XXX are the 3 digits of the
- * set MAC address. The MAC address is configured via DIP switches
- * within the device.
- */
- T8100(uint32_t targetDeviceObjectID);
-
- /**
- * T8100 Destructor
- */
- ~T8100();
-
- /**
- * Read current values from the sensor and update internal stored
- * values for temperature, humidity, CO2 concentration and relay
- * state. This method must be called prior to querying any
- * of the aforementioned values.
- */
- void update();
-
- /**
- * Get the current relative humidity. update() must have been
- * called prior to calling this method.
- *
- * @return The last humidity reading
- */
- float getHumidity()
- {
- return m_humidity;
- }
-
- /**
- * Get the current CO2 concentration in Parts per Million (PPM).
- * update() must have been called prior to calling this method.
- *
- * @return The last CO2 reading
- */
- float getCO2()
- {
- return m_co2;
- }
-
- /**
- * Get the current temperature. update() must have been called
- * prior to calling this method.
- *
- * @param fahrenheit true to return the temperature in degrees
- * fahrenheit, false to return the temperature in degrees celcius.
- * The default is false (degrees Celcius).
- * @return The last temperature reading in Celcius or Fahrenheit.
- */
- float getTemperature(bool fahrenheit=false);
-
- /**
- * Return the current state of the relay. This function will
- * always return false if the relay option is not installed.
- * update() must have been called prior to calling this method.
- *
- * @return true if the relay is active, false if inactive.
- */
- bool getRelayState()
- {
- return m_relayState;
- }
-
- /**
- * Set the device temperature scale to Celcius of Fahrenheit. For
- * devices with an LCD display, this will affect which scale is
- * displayed. When changing the scale, it may take several
- * seconds for the setting to take effect.
- *
- * @param fahrenheit true to set the scale to fahrenheit, false
- * for celcius.
- */
- void setTemperatureScale(bool fahrenheit);
-
- /**
- * Get the device temperature scale.
- *
- * @return true if scale is fahrenheit, false for celcius.
- */
- bool getTemperatureScale();
-
- /**
- * Get the current temperature offset.
- *
- * @return The configured temperature offset.
- */
- float getTemperatureOffset();
-
- /**
- * Set the device temperature offset. The offset is applied by
- * the device internally to the temperature reading. The offset
- * must always be specified in degrees Celcius. Valid values must
- * be between -50 and 50.
- *
- * @param value The temperature offset to configure.
- */
- void setTemperatureOffset(float value);
-
- /**
- * Get the current humidity offset.
- *
- * @return The configured humidity offset.
- */
- float getHumidityOffset();
-
- /**
- * Set the device humidity offset. The offset is applied by the
- * device internally to the humidity reading. Valid values must
- * be between -100 and 100.
- *
- * @param value The humidity offset to configure.
- */
- void setHumidityOffset(float value);
-
- /**
- * Return the current relay set point (in PPM). This set point is
- * the CO2 concentration point in PPM that causes the relay to
- * trigger.
- *
- * @return The relay set point value.
- */
- float getRelaySetPoint();
-
- /**
- * Set the relay set point in PPM. This set point is the CO2
- * concentration point in PPM that causes the relay to trigger.
- * Valid values are between 0-65535.
- *
- * @param value The desired relay set point value.
- */
- void setRelaySetPoint(float value);
-
- /**
- * Return the current relay hysteresis.
- *
- * @return The relay hysteresis value.
- */
- float getRelayHysteresis();
-
- /**
- * Set the relay hysteresis. Valid values are between 0-65535.
- *
- * @param value The desired relay set point value.
- */
- void setRelayHysteresis(float value);
-
- /**
- * Return the current elevation setting (in meters).
- *
- * @return The current elevation setting.
- */
- float getElevation();
-
- /**
- * Set the elevation setting in meters. Valid values are between
- * 0-65535.
- *
- * @param value The desired elevation setting in meters.
- */
- void setElevation(float value);
-
- /**
- * Return the current calibration single point value (in PPM).
- *
- * @return The current calibration single point value.
- */
- float getCalibrationSinglePoint();
-
- /**
- * Set the calibration single point value in PPM. Valid values
- * are between 0-65535.
- *
- * @param value The desired calibration single point value in PPM.
- */
- void setCalibrationSinglePoint(float value);
-
- /**
- * Return the current baud rate.
- *
- * @return The current baud rate.
- */
- float getBaudRate();
-
- /**
- * Return the current MAC address. The MAC address is configured
- * via DIP switches within the device.
- *
- * @return The current MAC address.
- */
- float getMACAddress();
-
- /**
- * Return the current ABC (Automatic Background Calibration)
- * logic state. See the datasheet for details.
- *
- * @return The current ABC logic state.
- */
- bool getABCLogicState();
-
- /**
- * Set the ABC (Automatic Background Calibration) logic state.
- * Valid values are true for ON, false for OFF.
- *
- * @param value The desired ABC logic state.
- */
- void setABCLogicState(bool value);
-
- /**
- * Return the current ABC (Automatic Background Calibration)
- * reset state. See the datasheet for details.
- *
- * @return The current ABC reset state.
- */
- bool getABCLogicReset();
-
- /**
- * Set the ABC (Automatic Background Calibration) reset state.
- * Valid values are true for Reset, false for Normal.
- *
- * @param value The desired ABC reset state.
- */
- void setABCLogicReset(bool value);
-
- /**
- * Return the current CO2 calibration state. See the datasheet
- * for details.
- *
- * @return The current CO2 calibration state.
- */
- bool getCO2Calibration();
-
- /**
- * Set the CO2 calibration state.
- * Valid values are true for Calibrate, false for Normal.
- *
- * @param value The desired ABC reset state.
- */
- void setCO2Calibration(bool value);
-
-
- protected:
- float m_humidity;
- // always stored in C
- float m_temperature;
- float m_co2;
- bool m_relayState;
-
- private:
- // Have we checked the device's temperature unit setting yet
- bool m_isTempInitialized;
-
- // Is the device configured for Celcius?
- bool m_isCelcius;
- };
-}
diff --git a/peripheral/libupm/src/ta12200/CMakeLists.txt b/peripheral/libupm/src/ta12200/CMakeLists.txt
index f7e1b0a..0f3f0ba 100644
--- a/peripheral/libupm/src/ta12200/CMakeLists.txt
+++ b/peripheral/libupm/src/ta12200/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "ta12200")
set (libdescription "upm ta12200 current transformer module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/ta12200/javaupm_ta12200.i b/peripheral/libupm/src/ta12200/javaupm_ta12200.i
index a3fae85..3feb468 100644
--- a/peripheral/libupm/src/ta12200/javaupm_ta12200.i
+++ b/peripheral/libupm/src/ta12200/javaupm_ta12200.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "ta12200.hpp"
+ #include "ta12200.h"
%}
-%include "ta12200.hpp"
+%include "ta12200.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/ta12200/jsupm_ta12200.i b/peripheral/libupm/src/ta12200/jsupm_ta12200.i
index 3f90ced..519f1ec 100644
--- a/peripheral/libupm/src/ta12200/jsupm_ta12200.i
+++ b/peripheral/libupm/src/ta12200/jsupm_ta12200.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "ta12200.hpp"
+ #include "ta12200.h"
%}
-%include "ta12200.hpp"
+%include "ta12200.h"
diff --git a/peripheral/libupm/src/ta12200/pyupm_ta12200.i b/peripheral/libupm/src/ta12200/pyupm_ta12200.i
index 5ca0db5..d1838fc 100644
--- a/peripheral/libupm/src/ta12200/pyupm_ta12200.i
+++ b/peripheral/libupm/src/ta12200/pyupm_ta12200.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "ta12200.hpp"
+%include "ta12200.h"
%{
- #include "ta12200.hpp"
+ #include "ta12200.h"
%}
diff --git a/peripheral/libupm/src/ta12200/ta12200.cxx b/peripheral/libupm/src/ta12200/ta12200.cxx
index bc29c90..f9d3cb0 100644
--- a/peripheral/libupm/src/ta12200/ta12200.cxx
+++ b/peripheral/libupm/src/ta12200/ta12200.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "ta12200.hpp"
+#include "ta12200.h"
using namespace upm;
using namespace std;
@@ -82,22 +82,18 @@ uint32_t TA12200::getMillis()
}
-int TA12200::highestValue()
+unsigned int TA12200::highestValue()
{
- int hiVal = 0;
- int val;
+ unsigned int hiVal = 0;
+ unsigned int val;
uint32_t start = getMillis();
// 1 second
while (getMillis() < (start + 1000))
{
val = mraa_aio_read(m_aio);
- if (val == -1) {
- return -1;
- }
- if (val > hiVal) {
+ if (val > hiVal)
hiVal = val;
- }
}
return hiVal;
diff --git a/peripheral/libupm/src/ta12200/ta12200.hpp b/peripheral/libupm/src/ta12200/ta12200.h
index cc025e0..b3561d4 100644
--- a/peripheral/libupm/src/ta12200/ta12200.hpp
+++ b/peripheral/libupm/src/ta12200/ta12200.h
@@ -89,9 +89,9 @@ namespace upm {
/**
* Gets the conversion value from the sensor
*
- * @return Highest value obtained over 1 second of measuring or -1 if error
+ * @return Highest value obtained over 1 second of measuring
*/
- int highestValue();
+ unsigned int highestValue();
/**
* Computes the measured voltage
diff --git a/peripheral/libupm/src/tb7300/CMakeLists.txt b/peripheral/libupm/src/tb7300/CMakeLists.txt
deleted file mode 100644
index 8564c80..0000000
--- a/peripheral/libupm/src/tb7300/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-set (libname "tb7300")
-set (libdescription "upm module for the TB7300 Fan Coil Thermostat")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-
-pkg_check_modules(BACNET libbacnet)
-if (BACNET_FOUND)
- # upm-libbacnetmstp will bring in libbacnet, I hope
- set (reqlibname "upm-bacnetmstp")
- include_directories(${BACNET_INCLUDE_DIRS})
- include_directories("../bacnetmstp")
- upm_module_init()
- target_link_libraries(${libname} bacnetmstp)
- if (BUILDSWIG)
- if (BUILDSWIGNODE)
- set_target_properties(${SWIG_MODULE_jsupm_${libname}_REAL_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE)
- swig_link_libraries (jsupm_${libname} bacnetmstp)
- endif()
- if (BUILDSWIGPYTHON)
- set_target_properties(${SWIG_MODULE_pyupm_${libname}_REAL_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE)
- swig_link_libraries (pyupm_${libname} bacnetmstp)
- endif()
- if (BUILDSWIGJAVA)
- set_target_properties(${SWIG_MODULE_javaupm_${libname}_REAL_NAME} PROPERTIES SKIP_BUILD_RPATH TRUE)
- swig_link_libraries (javaupm_${libname} bacnetmstp)
- endif()
- endif()
-endif ()
diff --git a/peripheral/libupm/src/tb7300/javaupm_tb7300.i b/peripheral/libupm/src/tb7300/javaupm_tb7300.i
deleted file mode 100644
index 7374878..0000000
--- a/peripheral/libupm/src/tb7300/javaupm_tb7300.i
+++ /dev/null
@@ -1,32 +0,0 @@
-%module javaupm_tb7300
-%include "../upm.i"
-%include "typemaps.i"
-
-// We need to use this method for enum wrapping since the enum typedefs used
-// by the derived classes (like ANALOG_VALUES_T) are passed to methods
-// in the base class which expect a uint32_t. This is fine, and
-// works everywhere except Java. It's type safety is a little too
-// stringent in these cases. %javaconst(1) is generally recommended
-// as it avoids JNI calls to determine the enumerant values at
-// runtime.
-%include "enumtypeunsafe.swg"
-%javaconst(1);
-
-%include "bacnetmstp.hpp"
-%include "bacnetutil.hpp"
-%include "tb7300.hpp"
-%{
- #include "tb7300.hpp"
-%}
-
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_tb7300");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/tb7300/jsupm_tb7300.i b/peripheral/libupm/src/tb7300/jsupm_tb7300.i
deleted file mode 100644
index e18f592..0000000
--- a/peripheral/libupm/src/tb7300/jsupm_tb7300.i
+++ /dev/null
@@ -1,10 +0,0 @@
-%module jsupm_tb7300
-%include "../upm.i"
-%include "stdint.i"
-
-%include "bacnetmstp.hpp"
-%include "bacnetutil.hpp"
-%include "tb7300.hpp"
-%{
- #include "tb7300.hpp"
-%}
diff --git a/peripheral/libupm/src/tb7300/pyupm_tb7300.i b/peripheral/libupm/src/tb7300/pyupm_tb7300.i
deleted file mode 100644
index a1e7bfe..0000000
--- a/peripheral/libupm/src/tb7300/pyupm_tb7300.i
+++ /dev/null
@@ -1,14 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_tb7300
-%include "../upm.i"
-%include "stdint.i"
-
-%feature("autodoc", "3");
-
-%include "bacnetmstp.hpp"
-%include "bacnetutil.hpp"
-%include "tb7300.hpp"
-%{
- #include "tb7300.hpp"
-%}
diff --git a/peripheral/libupm/src/tb7300/tb7300.cxx b/peripheral/libupm/src/tb7300/tb7300.cxx
deleted file mode 100644
index d4f14cc..0000000
--- a/peripheral/libupm/src/tb7300/tb7300.cxx
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <unistd.h>
-#include <errno.h>
-#include <iostream>
-#include <stdexcept>
-#include <string>
-
-#include "tb7300.hpp"
-
-using namespace upm;
-using namespace std;
-
-// conversion from fahrenheit to celcius and back
-
-static float f2c(float f)
-{
- return ((f - 32.0) / (9.0 / 5.0));
-}
-
-static float c2f(float c)
-{
- return (c * (9.0 / 5.0) + 32.0);
-}
-
-
-TB7300::TB7300(uint32_t targetDeviceObjectID) :
- BACNETUTIL(targetDeviceObjectID)
-{
- setDebug(false);
-
- // we disable this by default for performance reasons
- checkReliability(false);
-
- m_isTempInitialized = false;
- m_isCelcius = false;
-
- // room temperature only
- m_temperature = 0.0;
-}
-
-TB7300::~TB7300()
-{
-}
-
-void TB7300::update()
-{
- if (!m_isTempInitialized)
- {
- // this will update internals so conversions work properly
- getTemperatureScale();
- }
-
- float tmpF = getAnalogValue(AV_Room_Temperature);
-
- if (m_isCelcius)
- m_temperature = tmpF;
- else
- m_temperature = f2c(tmpF);
-}
-
-float TB7300::getTemperature(bool fahrenheit)
-{
- if (fahrenheit)
- return c2f(m_temperature);
- else
- return m_temperature;
-}
-
-void TB7300::setTemperatureScale(bool fahrenheit)
-{
- setBinaryValue(BV_Temperature_Scale, fahrenheit);
-
- m_isTempInitialized = true;
- m_isCelcius = (fahrenheit) ? false : true;
-}
-
-bool TB7300::getTemperatureScale()
-{
- bool scale = getBinaryValue(BV_Temperature_Scale);
-
- m_isTempInitialized = true;
- m_isCelcius = !scale;
-
- return scale;
-}
diff --git a/peripheral/libupm/src/tb7300/tb7300.hpp b/peripheral/libupm/src/tb7300/tb7300.hpp
deleted file mode 100644
index 2b6a0cc..0000000
--- a/peripheral/libupm/src/tb7300/tb7300.hpp
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <map>
-
-#include "bacnetmstp.hpp"
-#include "bacnetutil.hpp"
-
-namespace upm {
-
- /**
- * @brief Honeywell TB7300 Communicating Fan Coil Thermostat
- * @defgroup tb7300 libupm-tb7300
- * @ingroup uart temp
- */
-
- /**
- * @library tb7300
- * @sensor tb7300
- * @comname UPM API for the Honeywell TB7300 Communicating Fan Coil
- * Thermostat
- * @type temp
- * @man honeywell
- * @con uart
- * @web https://parts-hvac.com/tb7300c5014b.html
- *
- * @brief Honeywell TB7300 Communicating Fan Coil Thermostat
- *
- * This module implements support for the Honeywell TB7300
- * Communicating Fan Coil Thermostat. It may also support the
- * TB7200, though only the TB7300 was available for development of
- * this driver.
- *
- * The TB7200 Series PI thermostats are designed for zoning
- * applications, and the TB7300 Series PI thermostats are designed
- * for fan coil control. Both Series are communicating thermostats
- * with models available in BACnet® MS/TP protocol and can be easily
- * integrated into a WEBs-AX building automation system based on the
- * NiagaraAX® platform.
- *
- * TB7200 and TB7300 Series thermostats are compatible with the
- * Honeywell Occupancy Sensor Cover. Thermostats equipped with an
- * occupancy sensor cover provide advanced active occupancy logic,
- * which will automatically switch occupancy levels from Occupied to
- * Stand-By and Unoccupied as required by local activity being
- * present or not. This advanced occupancy functionality provides
- * advantageous energy savings during occupied hours without
- * sacrificing occupant comfort. All thermostats can be ordered with
- * or without a factory installed PIR cover.
- *
- * If you intend to work with this device and driver, it is
- * strongly suggested you get the BACnet Intergration Guide document
- * for this device: 63-4524.pdf as recommended in the device
- * documentation.
- *
- * This module was developed using the upm::BACNETMSTP library,
- * based on libbacnet-stack 0.8.3. Both libbacnet 0.8.3 and the
- * upm::BACNETMSTP libraries must be present in order to build this
- * module.
- *
- * It was connected using an RS232->RS485 interface. You cannot use
- * the built in MCU TTL UART pins for accessing this device -- you
- * must use a full Serial RS232->RS485 or USB-RS485 interface
- * connected via USB.
- *
- * @snippet tb7300.cxx Interesting
- */
-
- class TB7300 : public BACNETUTIL {
- public:
-
- // Supported Analog Value Objects. These are readable and writable.
- typedef enum : uint32_t {
- AV_Room_Temperature = 7,
-
- // GRP 20 Control Output
- AV_PI_Heating_Demand = 21,
- AV_PI_Cooling_Demand = 22,
-
- // GRP 38 Temperature Setpoints
- AV_Occupied_Heat_Setpoint = 39,
- AV_Occupied_Cool_Setpoint = 40,
- AV_Standby_Heat_Setpoint = 41,
- AV_Standby_Cool_Setpoint = 42,
- AV_Unoccupied_Heat_Setpoint = 43,
- AV_Unoccupied_Cool_Setpoint = 44,
-
- // GRP 55 General Options 2
- AV_Password_Value = 56,
- AV_Heating_Setpoint_Limit = 58,
- AV_Cooling_Setpoint_Limit = 59,
- AV_Deadband = 63,
- AV_Standby_Time = 67,
- AV_Unoccupied_Time = 68
- } ANALOG_VALUES_T;
-
- // Supported Analog Input Objects. These are read only.
- typedef enum : uint32_t {
- AI_Supply_Temperature = 12
- } ANALOG_INPUTS_T;
-
- // Supported Binary Value Objects. These are readable and writable.
- typedef enum : uint32_t {
- BV_Temp_Override = 8,
- BV_Aux_Command = 14,
-
- // GRP 45 General Options 1
- BV_Menu_Scroll = 49,
- BV_Auto_Mode_Enable = 50,
- BV_Temperature_Scale = 51,
-
- // GRP 55 General Option 2
- BV_Setpoint_Type = 60,
- BV_Setpoint_Function = 61,
- BV_Reheat_Timebase = 64,
- BV_Auto_Fan = 66,
-
- // GRP 74 Output Configuration Options
- BV_Control_type = 75,
- BV_Direct_Reverse_Acting = 78
- } BINARY_VALUES_T;
-
- // Supported Binary Input Objects. These are read only.
- typedef enum : uint32_t {
- // GRP 24 Controller Status
- BI_AUX_Status = 25,
- BI_BI1_Status = 29,
- BI_BI2_Status = 30,
- BI_UI3_Status = 31,
- BI_Local_Motion = 32,
-
- // GRP 34 Controller Alarms
- BI_Window_Alarm = 35,
- BI_Filter_Alarm = 36,
- BI_Service_Alarm = 37
- } BINARY_INPUTS_T;
-
- // Supported Multi-State Value Objects. These are readable and
- // writable.
- typedef enum : uint32_t {
- MV_Sequence_of_Operation = 15,
- MV_System_Mode = 16,
- MV_Fan_Mode = 17,
- MV_Occupancy_Command = 18,
- MV_Keypad_Lockout = 19,
-
- // GRP 24 Controller Status
- MV_Heating_Valve_Status = 26,
- MV_Cooling_Valve_Status = 27,
- MV_Fan_Status = 28,
- MV_Effective_Occupancy = 33,
-
- // GRP 45 General Options 1
- MV_BI1_Configuration = 46,
- MV_BI2_Configuration = 47,
- MV_UI1_Configuration = 48,
- MV_Pipe_Number = 52,
- MV_Out1_Config = 53,
- MV_AUX_Configuration = 54,
-
- // GRP 55 General Option 2
- MV_Fan_Mode_Sequence = 58,
- MV_Temporary_Occupancy_Time = 62,
- MV_Proportional_Band = 65,
-
- // GRP 74 Output Configuration Options
- MV_Floating_Motor_Timing = 76,
- MV_On_Off_Control_CPH = 77
- } MULTISTATE_VALUES_T;
-
- /**
- * TB7300 constructor
- *
- * @param targetDeviceObjectID the unique Instance ID of the
- * Device Object. This number is used to uniquely identify
- * devices on the BACnet network, and ranges from 1 to 4194302.
- * This is not the device's MAC address, though on some devices,
- * the MAC address may be used as part of this number. On the
- * TB7300, this number depends on the model and the MAC address.
- */
- TB7300(uint32_t targetDeviceObjectID);
-
- /**
- * TB7300 Destructor
- */
- ~TB7300();
-
- /**
- * Read current temperature from the sensor and update internal
- * stored value. This method must be called prior to querying the
- * temperature. All other values in the device must be queried
- * directly via the appropriate BACNETUTIL::get*() methods
- * depending on the object of interest.
- */
- void update();
-
- /**
- * Get the current temperature. update() must have been called
- * prior to calling this method.
- *
- * @param fahrenheit true to return the temperature in degrees
- * fahrenheit, false to return the temperature in degrees celcius.
- * The default is false (degrees Celcius).
- * @return The last temperature reading in Celcius or Fahrenheit.
- */
- float getTemperature(bool fahrenheit=false);
-
- /**
- * Set the device temperature scale to Celcius of Fahrenheit. For
- * devices with an LCD display, this will affect which scale is
- * displayed. When changing the scale, it may take several
- * seconds for the setting to take effect.
- *
- * @param fahrenheit true to set the scale to fahrenheit, false
- * for celcius.
- */
- void setTemperatureScale(bool fahrenheit);
-
- /**
- * Get the device temperature scale.
- *
- * @return true if scale is fahrenheit, false for celcius.
- */
- bool getTemperatureScale();
-
- protected:
- // always stored in C
- float m_temperature;
-
- bool m_isTempInitialized;
- bool m_isCelcius;
-
- private:
- };
-}
diff --git a/peripheral/libupm/src/tcs3414cs/.DS_Store b/peripheral/libupm/src/tcs3414cs/.DS_Store
new file mode 100644
index 0000000..b152328
--- /dev/null
+++ b/peripheral/libupm/src/tcs3414cs/.DS_Store
Binary files differ
diff --git a/peripheral/libupm/src/tcs3414cs/._.DS_Store b/peripheral/libupm/src/tcs3414cs/._.DS_Store
new file mode 100644
index 0000000..d4698e3
--- /dev/null
+++ b/peripheral/libupm/src/tcs3414cs/._.DS_Store
Binary files differ
diff --git a/peripheral/libupm/src/tcs3414cs/CMakeLists.txt b/peripheral/libupm/src/tcs3414cs/CMakeLists.txt
index 7d68dc6..fbdebd9 100644
--- a/peripheral/libupm/src/tcs3414cs/CMakeLists.txt
+++ b/peripheral/libupm/src/tcs3414cs/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "tcs3414cs")
set (libdescription "I2C Color sensor")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/tcs3414cs/javaupm_tcs3414cs.i b/peripheral/libupm/src/tcs3414cs/javaupm_tcs3414cs.i
index 1389d3f..61724e1 100644
--- a/peripheral/libupm/src/tcs3414cs/javaupm_tcs3414cs.i
+++ b/peripheral/libupm/src/tcs3414cs/javaupm_tcs3414cs.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "tcs3414cs.hpp"
+ #include "tcs3414cs.h"
%}
-%include "tcs3414cs.hpp"
+%include "tcs3414cs.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/tcs3414cs/jsupm_tcs3414cs.i b/peripheral/libupm/src/tcs3414cs/jsupm_tcs3414cs.i
index db7f453..58fa1bf 100644
--- a/peripheral/libupm/src/tcs3414cs/jsupm_tcs3414cs.i
+++ b/peripheral/libupm/src/tcs3414cs/jsupm_tcs3414cs.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "tcs3414cs.hpp"
+ #include "tcs3414cs.h"
%}
-%include "tcs3414cs.hpp"
+%include "tcs3414cs.h"
diff --git a/peripheral/libupm/src/tcs3414cs/pyupm_tcs3414cs.i b/peripheral/libupm/src/tcs3414cs/pyupm_tcs3414cs.i
index 8022fbb..243c05c 100644
--- a/peripheral/libupm/src/tcs3414cs/pyupm_tcs3414cs.i
+++ b/peripheral/libupm/src/tcs3414cs/pyupm_tcs3414cs.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "tcs3414cs.hpp"
+%include "tcs3414cs.h"
%{
- #include "tcs3414cs.hpp"
+ #include "tcs3414cs.h"
%}
diff --git a/peripheral/libupm/src/tcs3414cs/tcs3414cs.cxx b/peripheral/libupm/src/tcs3414cs/tcs3414cs.cxx
index 2d58f9a..28defac 100644
--- a/peripheral/libupm/src/tcs3414cs/tcs3414cs.cxx
+++ b/peripheral/libupm/src/tcs3414cs/tcs3414cs.cxx
@@ -31,7 +31,7 @@
#include <stdlib.h>
#include <stdexcept>
-#include "tcs3414cs.hpp"
+#include "tcs3414cs.h"
using namespace upm;
diff --git a/peripheral/libupm/src/tcs3414cs/tcs3414cs.hpp b/peripheral/libupm/src/tcs3414cs/tcs3414cs.h
index d944912..d944912 100644
--- a/peripheral/libupm/src/tcs3414cs/tcs3414cs.hpp
+++ b/peripheral/libupm/src/tcs3414cs/tcs3414cs.h
diff --git a/peripheral/libupm/src/teams/CMakeLists.txt b/peripheral/libupm/src/teams/CMakeLists.txt
deleted file mode 100644
index ec0974e..0000000
--- a/peripheral/libupm/src/teams/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set (libname "teams")
-set (libdescription "upm Veris TEAMS Temperature transmitter")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/teams/javaupm_teams.i b/peripheral/libupm/src/teams/javaupm_teams.i
deleted file mode 100644
index eb8c43c..0000000
--- a/peripheral/libupm/src/teams/javaupm_teams.i
+++ /dev/null
@@ -1,19 +0,0 @@
-%module javaupm_teams
-%include "../upm.i"
-%include "std_string.i"
-
-%include "teams.hpp"
-%{
- #include "teams.hpp"
-%}
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_teams");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/teams/jsupm_teams.i b/peripheral/libupm/src/teams/jsupm_teams.i
deleted file mode 100644
index 97d6628..0000000
--- a/peripheral/libupm/src/teams/jsupm_teams.i
+++ /dev/null
@@ -1,10 +0,0 @@
-%module jsupm_teams
-%include "../upm.i"
-%include "std_string.i"
-
-%{
- #include "teams.hpp"
-%}
-
-%include "teams.hpp"
-
diff --git a/peripheral/libupm/src/teams/pyupm_teams.i b/peripheral/libupm/src/teams/pyupm_teams.i
deleted file mode 100644
index efce3a1..0000000
--- a/peripheral/libupm/src/teams/pyupm_teams.i
+++ /dev/null
@@ -1,13 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_teams
-%include "../upm.i"
-%include "std_string.i"
-
-%feature("autodoc", "3");
-
-%{
- #include "teams.hpp"
-%}
-%include "teams.hpp"
-
diff --git a/peripheral/libupm/src/teams/teams.cxx b/peripheral/libupm/src/teams/teams.cxx
deleted file mode 100644
index eab59c1..0000000
--- a/peripheral/libupm/src/teams/teams.cxx
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-
-#include "teams.hpp"
-
-using namespace upm;
-using namespace std;
-
-// for current loop reads that seems a little noisy, we average over
-// several aio reads.
-static const int maxSamples = 50;
-
-// conversion from celcius to fahrenheit
-
-static float c2f(float c)
-{
- return (c * (9.0 / 5.0) + 32.0);
-}
-
-
-TEAMS::TEAMS(int tPin, float rResistor, float aref) :
- m_aioTemp(tPin)
-{
- if (rResistor < 0.0)
- {
- throw std::out_of_range(std::string(__FUNCTION__) +
- ": rResistor must be >= 0.0");
- }
-
- m_aResTemp = (1 << m_aioTemp.getBit());
-
- m_temperature = 0.0;
-
- m_aref = aref;
- m_rResistor = rResistor;
- m_connected = false;
-
- // this will only be non-zero when using a direct 4-20ma interface
- // like libelium
- m_rawMilliamps = 0.0;
-
- m_offset = 0.0;
-}
-
-TEAMS::~TEAMS()
-{
-}
-
-void TEAMS::update()
-{
- float milliamps = 0.0;
-
- int val = average(maxSamples);
- float volts = (float(val) * (m_aref / m_aResTemp));
-
- // valid temp range is 25.0 (35C - 10C), current loop range is 16ma
- // (20ma - 4ma)
- if (m_rResistor)
- {
- // direct 4-20 current loop interface
- milliamps = (volts / m_rResistor * 1000.0) + m_offset;
- m_rawMilliamps = milliamps;
-
- // subtract 0 (4ma) value
- milliamps -= 4.0;
- if (milliamps < 0.0) // not connected
- {
- milliamps = 0.0;
- m_connected = false;
- }
- else
- m_connected = true;
-
- m_temperature = (milliamps * (25.0 / 16.0)) + 10.0;
- }
- else
- {
- // normal analog read, already scaled to 0-5v, always connected
- m_temperature = ((volts / m_aref) * 25.0) + 10.0;
- m_connected = true;
- }
-}
-
-float TEAMS::getTemperature(bool fahrenheit)
-{
- if (fahrenheit)
- return c2f(m_temperature);
- else
- return m_temperature;
-}
-
-int TEAMS::average(int samples)
-{
- if (samples <= 0)
- samples = 1;
-
- int avg = 0;
- for (int i=0; i<samples; i++)
- avg += m_aioTemp.read();
-
- return (avg / samples);
-}
diff --git a/peripheral/libupm/src/teams/teams.hpp b/peripheral/libupm/src/teams/teams.hpp
deleted file mode 100644
index 6e8ed8f..0000000
--- a/peripheral/libupm/src/teams/teams.hpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <iostream>
-
-#include <mraa/aio.hpp>
-
-// Unlikey to be changable
-#define TEAMS_DEFAULT_AREF 5.0
-
-namespace upm {
- /**
- * @brief Veris TEAMS Temperature Transmitter
- * @defgroup teams libupm-teams
- * @ingroup veris ainput temp
- */
-
- /**
- * @library teams
- * @sensor teams
- * @comname Veris TEAMS Temperature Transmitter
- * @type temp
- * @man veris
- * @con ainput
- * @web http://www.veris.com/Item/TEAMS.aspx
- *
- * @brief API for the Veris TEAMS Temperature Transmitter
- *
- * The Veris TEAMS temperature sensor provides it's output via a
- * 4-20ma current loop. The supported temperature range is 10C to
- * 35C.
- *
- * This sensor was developed with a Cooking Hacks (Libelium)
- * 4-channel 4-20ma Arduino interface shield. For this interface,
- * the receiver resistance (rResistor) was specified as 165.0
- * ohms.
- *
- * When using a 4-20ma current loop interface which scales the
- * sensors' values to a 0-5vdc range, you can supply 0.0 as the
- * rResistor value in the constructor (default), and it will act
- * just like a normal analog input.
- *
- * @snippet teams.cxx Interesting
- */
-
- class TEAMS {
- public:
-
- /**
- * TEAMS object constructor
- *
- * @param tPin Analog pin to use for temperature.
- * @param rResistor The receiver resistance in ohms, when using a
- * 4-20ma current loop interface. When specified, this value will
- * be used in computing the current based on the voltage read when
- * scaling the return values. Default is 0.0, for standard
- * scaling based on voltage output rather than current (4-20ma
- * mode).
- * @param aref The analog reference voltage, default 5.0
- */
- TEAMS(int tPin, float rResistor=0.0, float aref=TEAMS_DEFAULT_AREF);
-
- /**
- * TEAMS object destructor
- */
- ~TEAMS();
-
- /**
- * Read current values from the sensor and update internal stored
- * values. This method must be called prior to querying any
- * values, such as temperature.
- */
- void update();
-
- /**
- * Get the current temperature. update() must have been called
- * prior to calling this method.
- *
- * @param fahrenheit true to return the temperature in degrees
- * fahrenheit, false to return the temperature in degrees celcius.
- * The default is false (degrees Celcius).
- * @return The last temperature reading in Celcius or Fahrenheit
- */
- float getTemperature(bool fahrenheit=false);
-
- /**
- * When using a direct 4-20ma interface (rResistor supplied in the
- * constructor is >0.0), this function will return false when the
- * computed milliamps falls below 4ma, indicating that the sensor
- * is not connected. If rResistor was specified as 0.0 in the
- * constructor, this function will always return true.
- *
- * @return true if the sensor is connected, false otherwise.
- */
- bool isConnected()
- {
- return m_connected;
- };
-
- /**
- * When using a direct 4-20ma interface (rResistor supplied in the
- * constructor is >0.0), this function will return the computed
- * milliamps (after the offset has been applied). If rResistor was
- * specified as 0.0 in the constructor, this function will always
- * return 0.0.
- *
- * @return The last measured current in milliamps after any offset
- * has been applied.
- */
- float getRawMilliamps()
- {
- return m_rawMilliamps;
- };
-
- /**
- * Specify an offset in milliamps to be applied to the computed
- * current prior to scaling and conversion. This can be used to
- * 'adjust' the computed value. If rResistor was specified as 0.0
- * in the constructor, this function will have no effect.
- *
- * @param offset a positive or negative value that will be applied
- * to the computed current measured.
- */
- void setOffsetMilliamps(float offset)
- {
- m_offset = offset;
- };
-
- protected:
- mraa::Aio m_aioTemp;
-
- private:
- float m_aref;
- float m_rResistor;
- int m_aResTemp;
-
- // for a 4-20 ma loop
- bool m_connected;
- float m_rawMilliamps;
-
- // in Celcius
- float m_temperature;
-
- // in case an offset should be applied to the cumputed current
- float m_offset;
-
- int average(int samples);
- };
-}
-
-
diff --git a/peripheral/libupm/src/tex00/CMakeLists.txt b/peripheral/libupm/src/tex00/CMakeLists.txt
deleted file mode 100644
index 210deab..0000000
--- a/peripheral/libupm/src/tex00/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-set (libname "tex00")
-set (libdescription "upm Veris TEX00 Temperature thermistors")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-upm_module_init()
diff --git a/peripheral/libupm/src/tex00/javaupm_tex00.i b/peripheral/libupm/src/tex00/javaupm_tex00.i
deleted file mode 100644
index f59ddd4..0000000
--- a/peripheral/libupm/src/tex00/javaupm_tex00.i
+++ /dev/null
@@ -1,19 +0,0 @@
-%module javaupm_tex00
-%include "../upm.i"
-%include "std_string.i"
-
-%include "tex00.hpp"
-%{
- #include "tex00.hpp"
-%}
-
-%pragma(java) jniclasscode=%{
- static {
- try {
- System.loadLibrary("javaupm_tex00");
- } catch (UnsatisfiedLinkError e) {
- System.err.println("Native code library failed to load. \n" + e);
- System.exit(1);
- }
- }
-%}
diff --git a/peripheral/libupm/src/tex00/jsupm_tex00.i b/peripheral/libupm/src/tex00/jsupm_tex00.i
deleted file mode 100644
index 3ddae3b..0000000
--- a/peripheral/libupm/src/tex00/jsupm_tex00.i
+++ /dev/null
@@ -1,10 +0,0 @@
-%module jsupm_tex00
-%include "../upm.i"
-%include "std_string.i"
-
-%{
- #include "tex00.hpp"
-%}
-
-%include "tex00.hpp"
-
diff --git a/peripheral/libupm/src/tex00/pyupm_tex00.i b/peripheral/libupm/src/tex00/pyupm_tex00.i
deleted file mode 100644
index 220106a..0000000
--- a/peripheral/libupm/src/tex00/pyupm_tex00.i
+++ /dev/null
@@ -1,13 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_tex00
-%include "../upm.i"
-%include "std_string.i"
-
-%feature("autodoc", "3");
-
-%{
- #include "tex00.hpp"
-%}
-%include "tex00.hpp"
-
diff --git a/peripheral/libupm/src/tex00/tex00.cxx b/peripheral/libupm/src/tex00/tex00.cxx
deleted file mode 100644
index 2a3c1ad..0000000
--- a/peripheral/libupm/src/tex00/tex00.cxx
+++ /dev/null
@@ -1,692 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-#include <math.h>
-#include "tex00.hpp"
-
-using namespace upm;
-using namespace std;
-
-// we average over several aio reads.
-static const int maxSamples = 10;
-
-// conversion from celcius to fahrenheit
-
-static float c2f(float c)
-{
- return (c * (9.0 / 5.0) + 32.0);
-}
-
-
-TEX00::TEX00(int tPin, float balanceResistor, SENSOR_TYPES_T stype,
- float aref) :
- m_aioTemp(tPin)
-{
- m_aResTemp = (1 << m_aioTemp.getBit());
-
- m_temperature = 0.0;
- m_outOfRange = false;
-
- m_aref = aref;
- m_balanceResistor = balanceResistor;
-
- // set default to NTC, however per-sensor init functions should set
- // properly for the relevant sensor
- m_isNTC = true;
-
- switch (stype)
- {
- case STYPE_THERMISTOR_TED:
- initThermistorTED();
- break;
-
- case STYPE_THERMISTOR_TEB:
- initThermistorTEB();
- break;
-
- case STYPE_THERMISTOR_TEC:
- initThermistorTEC();
- break;
-
- case STYPE_THERMISTOR_TEI:
- initThermistorTEI();
- break;
-
- case STYPE_THERMISTOR_TEE:
- initThermistorTEE();
- break;
-
- case STYPE_THERMISTOR_TEF:
- initThermistorTEF();
- break;
-
- case STYPE_THERMISTOR_TEH:
- initThermistorTEH();
- break;
-
- case STYPE_THERMISTOR_TEJ:
- initThermistorTEJ();
- break;
-
- case STYPE_THERMISTOR_TES:
- initThermistorTES();
- break;
-
- case STYPE_THERMISTOR_TER:
- initThermistorTER();
- break;
-
- case STYPE_THERMISTOR_TEM:
- initThermistorTEM();
- break;
-
- case STYPE_THERMISTOR_TEU:
- initThermistorTEU();
- break;
-
- case STYPE_THERMISTOR_TET:
- initThermistorTET();
- break;
-
- default:
- throw std::logic_error(std::string(__FUNCTION__) +
- ": internal error: invalid stype");
- }
-}
-
-TEX00::~TEX00()
-{
-}
-
-void TEX00::update()
-{
- int val = average(maxSamples);
-
- // now determine the resistance of the sensor (this is a voltage divider)
- float resistance = m_balanceResistor /
- ((float(m_aResTemp - 1) / float(val)) - 1.0);
-
- // cerr << "Val = " << val << ", resistance = " << resistance << endl;
-
- m_temperature = thermistor(resistance);
-}
-
-float TEX00::getTemperature(bool fahrenheit)
-{
- if (fahrenheit)
- return c2f(m_temperature);
- else
- return m_temperature;
-}
-
-int TEX00::average(int samples)
-{
- if (samples <= 0)
- samples = 1;
-
- int avg = 0;
- for (int i=0; i<samples; i++)
- avg += m_aioTemp.read();
-
- return (avg / samples);
-}
-
-float TEX00::thermistor(float ohms)
-{
- // sanity check
- if (m_tempVector.empty())
- {
- throw std::logic_error(std::string(__FUNCTION__) +
- ": internal error: temperature table is empty");
- }
-
- int found = -1;
- int next = -1;
-
- if (m_isNTC)
- {
- // reverse search
- for (int i=m_tempVector.size() - 1; i>=0; i--)
- if (ohms < m_tempVector[i].ohms)
- {
- found = i;
- next = found + 1;
- break;
- }
- }
- else
- {
- // PTC
- for (int i=0; i<m_tempVector.size(); i++)
- if (ohms < m_tempVector[i].ohms)
- {
- found = i;
- next = found - 1;
- break;
- }
- }
-
- if (found < 0 || next < 0 ||
- found >= m_tempVector.size() || next >= m_tempVector.size())
- {
- m_outOfRange = true;
- // return last measured temperature
- return m_temperature;
- }
- else
- m_outOfRange = false;
-
- // calculate the percentages of ohms and temp
- float diffO = m_tempVector[found].ohms - m_tempVector[next].ohms;
- ohms -= m_tempVector[next].ohms;
-
- diffO = ohms / diffO;
-
- float diffT;
- if (m_isNTC)
- diffT = m_tempVector[next].temp - m_tempVector[found].temp;
- else
- diffT = m_tempVector[found].temp - m_tempVector[next].temp;
-
- // compute offset
- float tempOffset = fabs(diffT * diffO);
-
- // apply according to NTC or PTC
- if (m_isNTC)
- return m_tempVector[next].temp - tempOffset;
- else
- return m_tempVector[next].temp + tempOffset;
-}
-
-float TEX00::getTemperatureRangeMin()
-{
- if (m_tempVector.empty())
- {
- throw std::logic_error(std::string(__FUNCTION__) +
- ": internal error: temperature table is empty");
- }
-
- return m_tempVector[0].temp;
-}
-
-float TEX00::getTemperatureRangeMax()
-{
- if (m_tempVector.empty())
- {
- throw std::logic_error(std::string(__FUNCTION__) +
- ": internal error: temperature table is empty");
- }
-
- return m_tempVector[m_tempVector.size() - 1].temp;
-}
-
-
-void TEX00::initThermistorTED()
-{
- // this is an NTC type thermistor
- m_isNTC = true;
-
- // This data comes from the Veris TW_TE_d0116.pdf datasheet for the
- // "D" (10K type 2) column
-
- // clear and initialize the vector, ordered from lowest to highest
- // temperature
- m_tempVector.clear();
-
- // ohms temperature (C)
- m_tempVector.push_back(tempEntry(692700, -50));
- m_tempVector.push_back(tempEntry(344700, -40));
- m_tempVector.push_back(tempEntry(180100, -30));
- m_tempVector.push_back(tempEntry(98320, -20));
- m_tempVector.push_back(tempEntry(55790, -10));
- m_tempVector.push_back(tempEntry(32770, 0));
- m_tempVector.push_back(tempEntry(19930, 10));
- m_tempVector.push_back(tempEntry(12500, 20));
- m_tempVector.push_back(tempEntry(10000, 25));
- m_tempVector.push_back(tempEntry(8055, 30));
- m_tempVector.push_back(tempEntry(5323, 40));
- m_tempVector.push_back(tempEntry(3599, 50));
- m_tempVector.push_back(tempEntry(2486, 60));
- m_tempVector.push_back(tempEntry(1753, 70));
- m_tempVector.push_back(tempEntry(1258, 80));
- m_tempVector.push_back(tempEntry(919, 90));
- m_tempVector.push_back(tempEntry(682, 100));
- m_tempVector.push_back(tempEntry(513, 110));
- m_tempVector.push_back(tempEntry(392, 120));
- m_tempVector.push_back(tempEntry(303, 130));
-}
-
-void TEX00::initThermistorTEB()
-{
- // this is a PTC type thermistor
- m_isNTC = false;
-
- // This data comes from the Veris TW_TE_d0116.pdf datasheet for the
- // "B" (100 Ohm) column
-
- // clear and initialize the vector, ordered from lowest to highest
- // temperature
- m_tempVector.clear();
-
- // ohms temperature (C)
- m_tempVector.push_back(tempEntry(80.306, -50));
- m_tempVector.push_back(tempEntry(84.271, -40));
- m_tempVector.push_back(tempEntry(88.222, -30));
- m_tempVector.push_back(tempEntry(92.160, -20));
- m_tempVector.push_back(tempEntry(96.086, -10));
- m_tempVector.push_back(tempEntry(100, 0));
- m_tempVector.push_back(tempEntry(103.903, 10));
- m_tempVector.push_back(tempEntry(107.794, 20));
- m_tempVector.push_back(tempEntry(109.735, 25));
- m_tempVector.push_back(tempEntry(111.673, 30));
- m_tempVector.push_back(tempEntry(115.541, 40));
- m_tempVector.push_back(tempEntry(119.397, 50));
- m_tempVector.push_back(tempEntry(123.242, 60));
- m_tempVector.push_back(tempEntry(127.075, 70));
- m_tempVector.push_back(tempEntry(130.897, 80));
- m_tempVector.push_back(tempEntry(134.707, 90));
- m_tempVector.push_back(tempEntry(138.506, 100));
- m_tempVector.push_back(tempEntry(142.293, 110));
- m_tempVector.push_back(tempEntry(146.068, 120));
- m_tempVector.push_back(tempEntry(149.332, 130));
-}
-
-void TEX00::initThermistorTEC()
-{
- // this is a PTC type thermistor
- m_isNTC = false;
-
- // This data comes from the Veris TW_TE_d0116.pdf datasheet for the
- // "C" (1000 Ohm) column
-
- // clear and initialize the vector, ordered from lowest to highest
- // temperature
- m_tempVector.clear();
-
- // ohms temperature (C)
- m_tempVector.push_back(tempEntry(803.06, -50));
- m_tempVector.push_back(tempEntry(842.71, -40));
- m_tempVector.push_back(tempEntry(882.22, -30));
- m_tempVector.push_back(tempEntry(921.60, -20));
- m_tempVector.push_back(tempEntry(960.86, -10));
- m_tempVector.push_back(tempEntry(1000, 0));
- m_tempVector.push_back(tempEntry(1039.03, 10));
- m_tempVector.push_back(tempEntry(1077.94, 20));
- m_tempVector.push_back(tempEntry(1097.35, 25));
- m_tempVector.push_back(tempEntry(1116.73, 30));
- m_tempVector.push_back(tempEntry(1155.41, 40));
- m_tempVector.push_back(tempEntry(1193.97, 50));
- m_tempVector.push_back(tempEntry(1232.42, 60));
- m_tempVector.push_back(tempEntry(1270.75, 70));
- m_tempVector.push_back(tempEntry(1308.97, 80));
- m_tempVector.push_back(tempEntry(1347.07, 90));
- m_tempVector.push_back(tempEntry(1385.06, 100));
- m_tempVector.push_back(tempEntry(1422.93, 110));
- m_tempVector.push_back(tempEntry(1460.68, 120));
- m_tempVector.push_back(tempEntry(1493.32, 130));
-}
-
-void TEX00::initThermistorTEI()
-{
- // this is a PTC type thermistor
- m_isNTC = false;
-
- // This data comes from the Veris TW_TE_d0116.pdf datasheet for the
- // "I" (1000 Ohm) column
-
- // clear and initialize the vector, ordered from lowest to highest
- // temperature
- m_tempVector.clear();
-
- // ohms temperature (C)
- m_tempVector.push_back(tempEntry(740.46, -50));
- m_tempVector.push_back(tempEntry(773.99, -40));
- m_tempVector.push_back(tempEntry(806.02, -30));
- m_tempVector.push_back(tempEntry(841, -20));
- m_tempVector.push_back(tempEntry(877.76, -10));
- m_tempVector.push_back(tempEntry(913.66, 0));
- m_tempVector.push_back(tempEntry(952.25, 10));
- m_tempVector.push_back(tempEntry(991.82, 20));
- m_tempVector.push_back(tempEntry(1013.50, 25));
- m_tempVector.push_back(tempEntry(1035.18, 30));
- m_tempVector.push_back(tempEntry(1077.68, 40));
- m_tempVector.push_back(tempEntry(1120.52, 50));
- m_tempVector.push_back(tempEntry(1166.13, 60));
- m_tempVector.push_back(tempEntry(1210.75, 70));
- m_tempVector.push_back(tempEntry(1254.55, 80));
- m_tempVector.push_back(tempEntry(1301.17, 90));
- m_tempVector.push_back(tempEntry(1348.38, 100));
- m_tempVector.push_back(tempEntry(1397.13, 110));
- m_tempVector.push_back(tempEntry(1447.44, 120));
- m_tempVector.push_back(tempEntry(1496.28, 130));
-}
-
-void TEX00::initThermistorTEE()
-{
- // this is an NTC type thermistor
- m_isNTC = true;
-
- // This data comes from the Veris TW_TE_d0116.pdf datasheet for the
- // "E" (2.2k Ohm) column
-
- // clear and initialize the vector, ordered from lowest to highest
- // temperature
- m_tempVector.clear();
-
- // ohms temperature (C)
- m_tempVector.push_back(tempEntry(154464, -50));
- m_tempVector.push_back(tempEntry(77081, -40));
- m_tempVector.push_back(tempEntry(40330, -30));
- m_tempVector.push_back(tempEntry(22032, -20));
- m_tempVector.push_back(tempEntry(12519, -10));
- m_tempVector.push_back(tempEntry(7373, 0));
- m_tempVector.push_back(tempEntry(4487, 10));
- m_tempVector.push_back(tempEntry(2814, 20));
- m_tempVector.push_back(tempEntry(2252, 25));
- m_tempVector.push_back(tempEntry(1814, 30));
- m_tempVector.push_back(tempEntry(1199, 40));
- m_tempVector.push_back(tempEntry(811.5, 50));
- m_tempVector.push_back(tempEntry(561, 60));
- m_tempVector.push_back(tempEntry(395.5, 70));
- m_tempVector.push_back(tempEntry(284, 80));
- m_tempVector.push_back(tempEntry(207.4, 90));
- m_tempVector.push_back(tempEntry(153.8, 100));
- m_tempVector.push_back(tempEntry(115.8, 110));
- m_tempVector.push_back(tempEntry(88.3, 120));
- m_tempVector.push_back(tempEntry(68.3, 130));
-}
-
-void TEX00::initThermistorTEF()
-{
- // this is an NTC type thermistor
- m_isNTC = true;
-
- // This data comes from the Veris TW_TE_d0116.pdf datasheet for the
- // "F" (3k Ohm) column
-
- // clear and initialize the vector, ordered from lowest to highest
- // temperature
- m_tempVector.clear();
-
- // ohms temperature (C)
- m_tempVector.push_back(tempEntry(205800, -50));
- m_tempVector.push_back(tempEntry(102690, -40));
- m_tempVector.push_back(tempEntry(53730, -30));
- m_tempVector.push_back(tempEntry(29346, -20));
- m_tempVector.push_back(tempEntry(16674, -10));
- m_tempVector.push_back(tempEntry(9822, 0));
- m_tempVector.push_back(tempEntry(5976, 10));
- m_tempVector.push_back(tempEntry(3750, 20));
- m_tempVector.push_back(tempEntry(3000, 25));
- m_tempVector.push_back(tempEntry(2417, 30));
- m_tempVector.push_back(tempEntry(1598, 40));
- m_tempVector.push_back(tempEntry(1081, 50));
- m_tempVector.push_back(tempEntry(747, 60));
- m_tempVector.push_back(tempEntry(527, 70));
- m_tempVector.push_back(tempEntry(378, 80));
-}
-
-void TEX00::initThermistorTEH()
-{
- // this is an NTC type thermistor
- m_isNTC = true;
-
- // This data comes from the Veris TW_TE_d0116.pdf datasheet for the
- // "H" (10k Type 3) column
-
- // clear and initialize the vector, ordered from lowest to highest
- // temperature
- m_tempVector.clear();
-
- // ohms temperature (C)
- m_tempVector.push_back(tempEntry(454910, -50));
- m_tempVector.push_back(tempEntry(245089, -40));
- m_tempVector.push_back(tempEntry(137307, -30));
- m_tempVector.push_back(tempEntry(79729, -20));
- m_tempVector.push_back(tempEntry(47843, -10));
- m_tempVector.push_back(tempEntry(29588, 0));
- m_tempVector.push_back(tempEntry(18813, 10));
- m_tempVector.push_back(tempEntry(12272, 20));
- m_tempVector.push_back(tempEntry(10000, 25));
- m_tempVector.push_back(tempEntry(8195, 30));
- m_tempVector.push_back(tempEntry(5593, 40));
- m_tempVector.push_back(tempEntry(3894, 50));
- m_tempVector.push_back(tempEntry(2763, 60));
- m_tempVector.push_back(tempEntry(1994, 70));
- m_tempVector.push_back(tempEntry(1462, 80));
- m_tempVector.push_back(tempEntry(1088, 90));
- m_tempVector.push_back(tempEntry(821, 100));
- m_tempVector.push_back(tempEntry(628, 110));
- m_tempVector.push_back(tempEntry(486, 120));
- m_tempVector.push_back(tempEntry(380, 130));
-}
-
-void TEX00::initThermistorTEJ()
-{
- // this is an NTC type thermistor
- m_isNTC = true;
-
- // This data comes from the Veris TW_TE_d0116.pdf datasheet for the
- // "J" (10k Dale) column
-
- // clear and initialize the vector, ordered from lowest to highest
- // temperature
- m_tempVector.clear();
-
- // ohms temperature (C)
- m_tempVector.push_back(tempEntry(672300, -50));
- m_tempVector.push_back(tempEntry(337200, -40));
- m_tempVector.push_back(tempEntry(177200, -30));
- m_tempVector.push_back(tempEntry(97130, -20));
- m_tempVector.push_back(tempEntry(55340, -10));
- m_tempVector.push_back(tempEntry(32660, 0));
- m_tempVector.push_back(tempEntry(19900, 10));
- m_tempVector.push_back(tempEntry(12490, 20));
- m_tempVector.push_back(tempEntry(10000, 25));
- m_tempVector.push_back(tempEntry(8056, 30));
- m_tempVector.push_back(tempEntry(5326, 40));
- m_tempVector.push_back(tempEntry(3602, 50));
- m_tempVector.push_back(tempEntry(2489, 60));
- m_tempVector.push_back(tempEntry(1753, 70));
- m_tempVector.push_back(tempEntry(1258, 80));
- m_tempVector.push_back(tempEntry(917, 90));
- m_tempVector.push_back(tempEntry(679, 100));
- m_tempVector.push_back(tempEntry(511, 110));
- m_tempVector.push_back(tempEntry(389, 120));
- m_tempVector.push_back(tempEntry(301, 130));
-}
-
-void TEX00::initThermistorTES()
-{
- // this is an NTC type thermistor
- m_isNTC = true;
-
- // This data comes from the Veris TW_TE_d0116.pdf datasheet for the
- // "S" (10k 3A221) column
-
- // clear and initialize the vector, ordered from lowest to highest
- // temperature
- m_tempVector.clear();
-
- // ohms temperature (C)
- m_tempVector.push_back(tempEntry(333562, -40));
- m_tempVector.push_back(tempEntry(176081, -30));
- m_tempVector.push_back(tempEntry(96807, -20));
- m_tempVector.push_back(tempEntry(55252, -10));
- m_tempVector.push_back(tempEntry(32639, 0));
- m_tempVector.push_back(tempEntry(19901, 10));
- m_tempVector.push_back(tempEntry(12493, 20));
- m_tempVector.push_back(tempEntry(10000, 25));
- m_tempVector.push_back(tempEntry(8055, 30));
- m_tempVector.push_back(tempEntry(5324, 40));
- m_tempVector.push_back(tempEntry(3600, 50));
- m_tempVector.push_back(tempEntry(2486, 60));
- m_tempVector.push_back(tempEntry(1751, 70));
- m_tempVector.push_back(tempEntry(1255, 80));
- m_tempVector.push_back(tempEntry(915, 90));
- m_tempVector.push_back(tempEntry(678, 100));
- m_tempVector.push_back(tempEntry(509, 110));
- m_tempVector.push_back(tempEntry(388, 120));
- m_tempVector.push_back(tempEntry(299, 130));
-}
-
-void TEX00::initThermistorTER()
-{
- // this is an NTC type thermistor
- m_isNTC = true;
-
- // This data comes from the Veris TW_TE_d0116.pdf datasheet for the
- // "R" (10k "G" US) column
-
- // clear and initialize the vector, ordered from lowest to highest
- // temperature
- m_tempVector.clear();
-
- // ohms temperature (C)
- m_tempVector.push_back(tempEntry(441200, -50));
- m_tempVector.push_back(tempEntry(239700, -40));
- m_tempVector.push_back(tempEntry(135300, -30));
- m_tempVector.push_back(tempEntry(78910, -20));
- m_tempVector.push_back(tempEntry(47540, -10));
- m_tempVector.push_back(tempEntry(29490, 0));
- m_tempVector.push_back(tempEntry(18780, 10));
- m_tempVector.push_back(tempEntry(12260, 20));
- m_tempVector.push_back(tempEntry(10000, 25));
- m_tempVector.push_back(tempEntry(8194, 30));
- m_tempVector.push_back(tempEntry(5592, 40));
- m_tempVector.push_back(tempEntry(3893, 50));
- m_tempVector.push_back(tempEntry(2760, 60));
- m_tempVector.push_back(tempEntry(1990, 70));
- m_tempVector.push_back(tempEntry(1458, 80));
- m_tempVector.push_back(tempEntry(1084, 90));
- m_tempVector.push_back(tempEntry(816.8, 100));
- m_tempVector.push_back(tempEntry(623.6, 110));
- m_tempVector.push_back(tempEntry(481.8, 120));
- m_tempVector.push_back(tempEntry(376.4, 130));
-}
-
-void TEX00::initThermistorTEM()
-{
- // this is an NTC type thermistor
- m_isNTC = true;
-
- // This data comes from the Veris TW_TE_d0116.pdf datasheet for the
- // "M" (20k NTC) column
-
- // clear and initialize the vector, ordered from lowest to highest
- // temperature
- m_tempVector.clear();
-
- // ohms temperature (C)
- m_tempVector.push_back(tempEntry(1267600, -50));
- m_tempVector.push_back(tempEntry(643800, -40));
- m_tempVector.push_back(tempEntry(342000, -30));
- m_tempVector.push_back(tempEntry(189080, -20));
- m_tempVector.push_back(tempEntry(108380, -10));
- m_tempVector.push_back(tempEntry(64160, 0));
- m_tempVector.push_back(tempEntry(38440, 10));
- m_tempVector.push_back(tempEntry(24920, 20));
- m_tempVector.push_back(tempEntry(20000, 25));
- m_tempVector.push_back(tempEntry(16144, 30));
- m_tempVector.push_back(tempEntry(10696, 40));
- m_tempVector.push_back(tempEntry(7234, 50));
- m_tempVector.push_back(tempEntry(4992, 60));
- m_tempVector.push_back(tempEntry(3512, 70));
- m_tempVector.push_back(tempEntry(2516, 80));
- m_tempVector.push_back(tempEntry(1833, 90));
- m_tempVector.push_back(tempEntry(1356, 100));
- m_tempVector.push_back(tempEntry(1016, 110));
- m_tempVector.push_back(tempEntry(770, 120));
- m_tempVector.push_back(tempEntry(591, 130));
-}
-
-void TEX00::initThermistorTEU()
-{
- // this is an NTC type thermistor
- m_isNTC = true;
-
- // This data comes from the Veris TW_TE_d0116.pdf datasheet for the
- // "U" (20k "D") column
-
- // clear and initialize the vector, ordered from lowest to highest
- // temperature
- m_tempVector.clear();
-
- // ohms temperature (C)
- m_tempVector.push_back(tempEntry(803200, -40));
- m_tempVector.push_back(tempEntry(412800, -30));
- m_tempVector.push_back(tempEntry(220600, -20));
- m_tempVector.push_back(tempEntry(112400, -10));
- m_tempVector.push_back(tempEntry(70200, 0));
- m_tempVector.push_back(tempEntry(41600, 10));
- m_tempVector.push_back(tempEntry(25340, 20));
- m_tempVector.push_back(tempEntry(20000, 25));
- m_tempVector.push_back(tempEntry(15884, 30));
- m_tempVector.push_back(tempEntry(10210, 40));
- m_tempVector.push_back(tempEntry(6718, 50));
- m_tempVector.push_back(tempEntry(4518, 60));
- m_tempVector.push_back(tempEntry(3100, 70));
- m_tempVector.push_back(tempEntry(2168, 80));
- m_tempVector.push_back(tempEntry(1542, 90));
- m_tempVector.push_back(tempEntry(1134, 100));
- m_tempVector.push_back(tempEntry(816, 110));
- m_tempVector.push_back(tempEntry(606, 120));
- m_tempVector.push_back(tempEntry(456, 130));
-}
-
-void TEX00::initThermistorTET()
-{
- // this is an NTC type thermistor
- m_isNTC = true;
-
- // This data comes from the Veris TW_TE_d0116.pdf datasheet for the
- // "T" (100k) column
-
- // clear and initialize the vector, ordered from lowest to highest
- // temperature
- m_tempVector.clear();
-
- // ohms temperature (C)
- m_tempVector.push_back(tempEntry(3366000, -40));
- m_tempVector.push_back(tempEntry(1770000, -30));
- m_tempVector.push_back(tempEntry(971200, -20));
- m_tempVector.push_back(tempEntry(553400, -10));
- m_tempVector.push_back(tempEntry(326600, 0));
- m_tempVector.push_back(tempEntry(199000, 10));
- m_tempVector.push_back(tempEntry(124900, 20));
- m_tempVector.push_back(tempEntry(100000, 25));
- m_tempVector.push_back(tempEntry(80580, 30));
- m_tempVector.push_back(tempEntry(53260, 40));
- m_tempVector.push_back(tempEntry(36020, 50));
- m_tempVector.push_back(tempEntry(24880, 60));
- m_tempVector.push_back(tempEntry(17510, 70));
- m_tempVector.push_back(tempEntry(12560, 80));
- m_tempVector.push_back(tempEntry(9164, 90));
- m_tempVector.push_back(tempEntry(6792, 100));
- m_tempVector.push_back(tempEntry(5108, 110));
- m_tempVector.push_back(tempEntry(3894, 120));
- m_tempVector.push_back(tempEntry(3006, 130));
-}
-
diff --git a/peripheral/libupm/src/tex00/tex00.hpp b/peripheral/libupm/src/tex00/tex00.hpp
deleted file mode 100644
index d747f7b..0000000
--- a/peripheral/libupm/src/tex00/tex00.hpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <iostream>
-#include <vector>
-
-#include <mraa/aio.hpp>
-
-#define TEX00_DEFAULT_AREF 5.0
-
-namespace upm {
- /**
- * @brief Veris TEX00 Temperature Sensor
- * @defgroup tex00 libupm-tex00
- * @ingroup veris ainput temp
- */
-
- /**
- * @library tex00
- * @sensor tex00
- * @comname Veris TEX00 Temperature Sensor
- * @type temp
- * @man veris
- * @con ainput
- * @web http://www.veris.com/Item/TED00.aspx
- *
- * @brief API for the Veris TEX00 Temperature Sensor
- *
- * The Veris TEX00 temperature sensor family is made up of a
- * series of RTD thermistors in wall mount packaging.
- *
- * This driver was developed using the TED00, which utilizes a 10K
- * Ohm Type 2 thermistor. However, this driver can support the
- * other 12 variants of the TE series as well by providing the
- * correct sensor type to the class constructor. These other
- * sensor types have not been tested. Only the TED00 was tested
- * with this driver.
- *
- * This sensor must be connected as part of a voltage divider,
- * with the balancing resistor ideally matched to the sensor's 25C
- * detection range. For the TED00 (10kt2), a 10K Ohm (1%
- * tolerance) resistor was used in a circuit like the following:
- *
- * GND o----|TED00(10k2)|----o----|balanceResistor(10K)|----o VCC (+5vdc)
- * |
- * |
- * |----o A0 (analog input to MCU)
- *
- * A 3.3vdc voltage can be used as well if desired.
- *
- * @snippet tex00.cxx Interesting
- */
-
- class TEX00 {
- public:
-
- typedef enum {
- STYPE_THERMISTOR_TED = 0, // 10k type 2
- STYPE_THERMISTOR_TEB, // 100 Ohm
- STYPE_THERMISTOR_TEC, // 1000 Ohm
- STYPE_THERMISTOR_TEI, // 1000 Ohm
- STYPE_THERMISTOR_TEE, // 2.2k
- STYPE_THERMISTOR_TEF, // 3k
- STYPE_THERMISTOR_TEH, // 10k type 3
- STYPE_THERMISTOR_TEJ, // 10k Dale
- STYPE_THERMISTOR_TES, // 10k 3A221
- STYPE_THERMISTOR_TER, // 10k "G" US
- STYPE_THERMISTOR_TEM, // 20k NTC
- STYPE_THERMISTOR_TEU, // 20k "D"
- STYPE_THERMISTOR_TET // 100k
- } SENSOR_TYPES_T;
-
- /**
- * TEX00 object constructor
- *
- * @param tPin Analog pin to use for temperature.
- * @param balanceResistor Resistance (in Ohms) of the balance
- * resistor used in your voltage divider.
- * @param stype The sensor type. One of the SENSOR_TYPES_T values.
- * @param aref The analog reference voltage, default 5.0
- */
- TEX00(int tPin, float balanceResistor, SENSOR_TYPES_T stype,
- float aref=TEX00_DEFAULT_AREF);
-
- /**
- * TEX00 object destructor
- */
- ~TEX00();
-
- /**
- * Read current values from the sensor and update internal stored
- * values. This method must be called prior to querying any
- * values, such as temperature.
- */
- void update();
-
- /**
- * Get the current temperature. update() must have been called
- * prior to calling this method.
- *
- * @param fahrenheit true to return the temperature in degrees
- * fahrenheit, false to return the temperature in degrees celcius.
- * The default is false (degrees Celcius).
- * @return The last temperature reading in Celcius or Fahrenheit
- */
- float getTemperature(bool fahrenheit=false);
-
- /**
- * Return the smallest temperature that can be measured by the
- * current sensor.
- *
- * @return The smallest detectable temperature this sensor can
- * measure, in C.
- */
- float getTemperatureRangeMin();
-
- /**
- * Return the largest temperature that can be measured by the
- * current sensor.
- *
- * @return The largest detectable temperature this sensor can
- * measure, in C.
- */
- float getTemperatureRangeMax();
-
- /**
- * Detect whether the last measurement exceeded the sensors
- * detection range. update() must have been called prior to
- * calling this method.
- *
- * @return true if the last measurement was out of range, false
- * otherwise.
- */
- bool isOutOfRange()
- {
- return m_outOfRange;
- }
-
- protected:
- mraa::Aio m_aioTemp;
-
- // compute the temperature based on the resistance of the thermistor
- float thermistor(float ohms);
-
- private:
- float m_aref;
- int m_aResTemp;
-
- // in Celcius
- float m_temperature;
- // temp reading out of range
- bool m_outOfRange;
-
- // resistance of the other half of our voltage divider
- float m_balanceResistor;
-
- int average(int samples);
-
- // Negative Temperature Coefficient (NTC) or Positive Temperature
- // Coefficient (PTC)
- bool m_isNTC;
-
- // This may generate a SWIG warning. It can be safely ignored
- // since this structure is never exposed outside the class.
- struct tempEntry
- {
- tempEntry(float o, float t) : ohms(o), temp(t) {};
-
- float ohms;
- float temp; // in C
- };
-
- // ohms/temperature table store
- std::vector<tempEntry> m_tempVector;
-
- // table temperature init functions
- void initThermistorTED();
- void initThermistorTEB();
- void initThermistorTEC();
- void initThermistorTEI();
- void initThermistorTEE();
- void initThermistorTEF();
- void initThermistorTEH();
- void initThermistorTEJ();
- void initThermistorTES();
- void initThermistorTER();
- void initThermistorTEM();
- void initThermistorTEU();
- void initThermistorTET();
- };
-}
-
-
diff --git a/peripheral/libupm/src/th02/CMakeLists.txt b/peripheral/libupm/src/th02/CMakeLists.txt
index 5ceb30e..94426f4 100644
--- a/peripheral/libupm/src/th02/CMakeLists.txt
+++ b/peripheral/libupm/src/th02/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "th02")
set (libdescription "Temperature and Humidity Sensor Pro")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/th02/javaupm_th02.i b/peripheral/libupm/src/th02/javaupm_th02.i
index d20e899..d16ae4f 100644
--- a/peripheral/libupm/src/th02/javaupm_th02.i
+++ b/peripheral/libupm/src/th02/javaupm_th02.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "th02.hpp"
+ #include "th02.h"
%}
-%include "th02.hpp"
+%include "th02.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/th02/jsupm_th02.i b/peripheral/libupm/src/th02/jsupm_th02.i
index 8ab407f..dcf48cf 100644
--- a/peripheral/libupm/src/th02/jsupm_th02.i
+++ b/peripheral/libupm/src/th02/jsupm_th02.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "th02.hpp"
+ #include "th02.h"
%}
-%include "th02.hpp"
+%include "th02.h"
diff --git a/peripheral/libupm/src/th02/pyupm_th02.i b/peripheral/libupm/src/th02/pyupm_th02.i
index 77b3688..b280c7d 100644
--- a/peripheral/libupm/src/th02/pyupm_th02.i
+++ b/peripheral/libupm/src/th02/pyupm_th02.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "th02.hpp"
+%include "th02.h"
%{
- #include "th02.hpp"
+ #include "th02.h"
%}
diff --git a/peripheral/libupm/src/th02/th02.cxx b/peripheral/libupm/src/th02/th02.cxx
index 5e79e06..ae7230b 100644
--- a/peripheral/libupm/src/th02/th02.cxx
+++ b/peripheral/libupm/src/th02/th02.cxx
@@ -30,7 +30,7 @@
#include <stdlib.h>
#include <stdexcept>
-#include "th02.hpp"
+#include "th02.h"
using namespace std;
using namespace upm;
diff --git a/peripheral/libupm/src/th02/th02.hpp b/peripheral/libupm/src/th02/th02.h
index 404180a..404180a 100644
--- a/peripheral/libupm/src/th02/th02.hpp
+++ b/peripheral/libupm/src/th02/th02.h
diff --git a/peripheral/libupm/src/tm1637/CMakeLists.txt b/peripheral/libupm/src/tm1637/CMakeLists.txt
index 0b0176d..6138d2e 100644
--- a/peripheral/libupm/src/tm1637/CMakeLists.txt
+++ b/peripheral/libupm/src/tm1637/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "tm1637")
set (libdescription "C++ API for the TM1637 7-segment display")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/tm1637/javaupm_tm1637.i b/peripheral/libupm/src/tm1637/javaupm_tm1637.i
index b6d283f..a0e5546 100644
--- a/peripheral/libupm/src/tm1637/javaupm_tm1637.i
+++ b/peripheral/libupm/src/tm1637/javaupm_tm1637.i
@@ -11,10 +11,10 @@
%apply uint8_t *INPUT { uint8_t *digits }
%{
- #include "tm1637.hpp"
+ #include "tm1637.h"
%}
-%include "tm1637.hpp"
+%include "tm1637.h"
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/tm1637/jsupm_tm1637.i b/peripheral/libupm/src/tm1637/jsupm_tm1637.i
index 3a71411..57992e0 100644
--- a/peripheral/libupm/src/tm1637/jsupm_tm1637.i
+++ b/peripheral/libupm/src/tm1637/jsupm_tm1637.i
@@ -8,8 +8,8 @@
%rename("writeString") write(std::string digits);
%{
- #include "tm1637.hpp"
+ #include "tm1637.h"
%}
-%include "tm1637.hpp"
+%include "tm1637.h"
diff --git a/peripheral/libupm/src/tm1637/pyupm_tm1637.i b/peripheral/libupm/src/tm1637/pyupm_tm1637.i
index a607e70..fe347eb 100644
--- a/peripheral/libupm/src/tm1637/pyupm_tm1637.i
+++ b/peripheral/libupm/src/tm1637/pyupm_tm1637.i
@@ -7,6 +7,6 @@
%varargs(4, int digit = 0) write;
%{
- #include "tm1637.hpp"
+ #include "tm1637.h"
%}
-%include "tm1637.hpp"
+%include "tm1637.h"
diff --git a/peripheral/libupm/src/tm1637/tm1637.cxx b/peripheral/libupm/src/tm1637/tm1637.cxx
index b2c2722..74507f2 100644
--- a/peripheral/libupm/src/tm1637/tm1637.cxx
+++ b/peripheral/libupm/src/tm1637/tm1637.cxx
@@ -24,7 +24,7 @@
#include <string>
#include <stdexcept>
-#include "tm1637.hpp"
+#include "tm1637.h"
#include <stdarg.h>
const uint8_t m_brkt[2] = {0x39, 0x0f};
diff --git a/peripheral/libupm/src/tm1637/tm1637.hpp b/peripheral/libupm/src/tm1637/tm1637.h
index 08ad2f3..08ad2f3 100644
--- a/peripheral/libupm/src/tm1637/tm1637.hpp
+++ b/peripheral/libupm/src/tm1637/tm1637.h
diff --git a/peripheral/libupm/src/tsl2561/CMakeLists.txt b/peripheral/libupm/src/tsl2561/CMakeLists.txt
index 1a39639..9434da3 100644
--- a/peripheral/libupm/src/tsl2561/CMakeLists.txt
+++ b/peripheral/libupm/src/tsl2561/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "tsl2561")
set (libdescription "upm tsl2561")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/tsl2561/javaupm_tsl2561.i b/peripheral/libupm/src/tsl2561/javaupm_tsl2561.i
index 78606b5..2d542e6 100644
--- a/peripheral/libupm/src/tsl2561/javaupm_tsl2561.i
+++ b/peripheral/libupm/src/tsl2561/javaupm_tsl2561.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "tsl2561.hpp"
+ #include "tsl2561.h"
%}
-%include "tsl2561.hpp"
+%include "tsl2561.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/tsl2561/jsupm_tsl2561.i b/peripheral/libupm/src/tsl2561/jsupm_tsl2561.i
index d344730..e5403d1 100644
--- a/peripheral/libupm/src/tsl2561/jsupm_tsl2561.i
+++ b/peripheral/libupm/src/tsl2561/jsupm_tsl2561.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "tsl2561.hpp"
+ #include "tsl2561.h"
%}
-%include "tsl2561.hpp"
+%include "tsl2561.h"
diff --git a/peripheral/libupm/src/tsl2561/pyupm_tsl2561.i b/peripheral/libupm/src/tsl2561/pyupm_tsl2561.i
index 56189bf..1e4ac90 100644
--- a/peripheral/libupm/src/tsl2561/pyupm_tsl2561.i
+++ b/peripheral/libupm/src/tsl2561/pyupm_tsl2561.i
@@ -9,7 +9,7 @@
%include "tsl2561_doc.i"
#endif
-%include "tsl2561.hpp"
+%include "tsl2561.h"
%{
- #include "tsl2561.hpp"
+ #include "tsl2561.h"
%}
diff --git a/peripheral/libupm/src/tsl2561/tsl2561.cxx b/peripheral/libupm/src/tsl2561/tsl2561.cxx
index 14eb673..7bbbfc0 100644
--- a/peripheral/libupm/src/tsl2561/tsl2561.cxx
+++ b/peripheral/libupm/src/tsl2561/tsl2561.cxx
@@ -30,7 +30,7 @@
#include <string>
#include <stdexcept>
#include <unistd.h>
-#include "tsl2561.hpp"
+#include "tsl2561.h"
using namespace upm;
diff --git a/peripheral/libupm/src/tsl2561/tsl2561.hpp b/peripheral/libupm/src/tsl2561/tsl2561.h
index 2b83533..2b83533 100644
--- a/peripheral/libupm/src/tsl2561/tsl2561.hpp
+++ b/peripheral/libupm/src/tsl2561/tsl2561.h
diff --git a/peripheral/libupm/src/ttp223/CMakeLists.txt b/peripheral/libupm/src/ttp223/CMakeLists.txt
index 3ae4594..33341e1 100644
--- a/peripheral/libupm/src/ttp223/CMakeLists.txt
+++ b/peripheral/libupm/src/ttp223/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "ttp223")
set (libdescription "upm ttp223")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/ttp223/javaupm_ttp223.i b/peripheral/libupm/src/ttp223/javaupm_ttp223.i
index c3b5e29..c6b77c6 100644
--- a/peripheral/libupm/src/ttp223/javaupm_ttp223.i
+++ b/peripheral/libupm/src/ttp223/javaupm_ttp223.i
@@ -6,10 +6,10 @@
%{
- #include "ttp223.hpp"
+ #include "ttp223.h"
%}
-%include "ttp223.hpp"
+%include "ttp223.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/ttp223/jsupm_ttp223.i b/peripheral/libupm/src/ttp223/jsupm_ttp223.i
index d408dea..f083dd8 100644
--- a/peripheral/libupm/src/ttp223/jsupm_ttp223.i
+++ b/peripheral/libupm/src/ttp223/jsupm_ttp223.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "ttp223.hpp"
+ #include "ttp223.h"
%}
-%include "ttp223.hpp"
+%include "ttp223.h"
diff --git a/peripheral/libupm/src/ttp223/pyupm_ttp223.i b/peripheral/libupm/src/ttp223/pyupm_ttp223.i
index 8f2194f..8037e91 100644
--- a/peripheral/libupm/src/ttp223/pyupm_ttp223.i
+++ b/peripheral/libupm/src/ttp223/pyupm_ttp223.i
@@ -5,8 +5,8 @@
%feature("autodoc", "3");
-%include "ttp223.hpp"
+%include "ttp223.h"
%{
- #include "ttp223.hpp"
+ #include "ttp223.h"
%}
diff --git a/peripheral/libupm/src/ttp223/ttp223.cxx b/peripheral/libupm/src/ttp223/ttp223.cxx
index 7e2775d..c20e468 100644
--- a/peripheral/libupm/src/ttp223/ttp223.cxx
+++ b/peripheral/libupm/src/ttp223/ttp223.cxx
@@ -25,7 +25,7 @@
#include <string>
#include <stdexcept>
-#include "ttp223.hpp"
+#include "ttp223.h"
using namespace upm;
diff --git a/peripheral/libupm/src/ttp223/ttp223.hpp b/peripheral/libupm/src/ttp223/ttp223.h
index d2a3738..d2a3738 100644
--- a/peripheral/libupm/src/ttp223/ttp223.hpp
+++ b/peripheral/libupm/src/ttp223/ttp223.h
diff --git a/peripheral/libupm/src/ublox6/CMakeLists.txt b/peripheral/libupm/src/ublox6/CMakeLists.txt
index 91ba1b6..5db1266 100644
--- a/peripheral/libupm/src/ublox6/CMakeLists.txt
+++ b/peripheral/libupm/src/ublox6/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "ublox6")
set (libdescription "upm u-blox 6 GPS UART support module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/ublox6/javaupm_ublox6.i b/peripheral/libupm/src/ublox6/javaupm_ublox6.i
index d8f6e5a..c5f0777 100644
--- a/peripheral/libupm/src/ublox6/javaupm_ublox6.i
+++ b/peripheral/libupm/src/ublox6/javaupm_ublox6.i
@@ -3,11 +3,11 @@
%include "../java_buffer.i"
%{
- #include "ublox6.hpp"
+ #include "ublox6.h"
speed_t int_B9600 = B9600;
%}
-%include "ublox6.hpp"
+%include "ublox6.h"
speed_t int_B9600 = B9600;
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/ublox6/jsupm_ublox6.i b/peripheral/libupm/src/ublox6/jsupm_ublox6.i
index e255681..12c7552 100644
--- a/peripheral/libupm/src/ublox6/jsupm_ublox6.i
+++ b/peripheral/libupm/src/ublox6/jsupm_ublox6.i
@@ -4,10 +4,10 @@
%include "carrays.i"
%{
- #include "ublox6.hpp"
+ #include "ublox6.h"
speed_t int_B9600 = B9600;
%}
-%include "ublox6.hpp"
+%include "ublox6.h"
speed_t int_B9600 = B9600;
%array_class(char, charArray);
diff --git a/peripheral/libupm/src/ublox6/pyupm_ublox6.i b/peripheral/libupm/src/ublox6/pyupm_ublox6.i
index dc1c378..8567d50 100644
--- a/peripheral/libupm/src/ublox6/pyupm_ublox6.i
+++ b/peripheral/libupm/src/ublox6/pyupm_ublox6.i
@@ -8,10 +8,10 @@
%feature("autodoc", "3");
%{
- #include "ublox6.hpp"
+ #include "ublox6.h"
speed_t int_B9600 = B9600;
%}
-%include "ublox6.hpp"
+%include "ublox6.h"
speed_t int_B9600 = B9600;
%array_class(char, charArray);
diff --git a/peripheral/libupm/src/ublox6/ublox6.cxx b/peripheral/libupm/src/ublox6/ublox6.cxx
index f9eb966..b9d15c5 100644
--- a/peripheral/libupm/src/ublox6/ublox6.cxx
+++ b/peripheral/libupm/src/ublox6/ublox6.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "ublox6.hpp"
+#include "ublox6.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/ublox6/ublox6.hpp b/peripheral/libupm/src/ublox6/ublox6.h
index d98aad3..d98aad3 100644
--- a/peripheral/libupm/src/ublox6/ublox6.hpp
+++ b/peripheral/libupm/src/ublox6/ublox6.h
diff --git a/peripheral/libupm/src/uln200xa/CMakeLists.txt b/peripheral/libupm/src/uln200xa/CMakeLists.txt
index 88a732d..3ac82ff 100644
--- a/peripheral/libupm/src/uln200xa/CMakeLists.txt
+++ b/peripheral/libupm/src/uln200xa/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "uln200xa")
set (libdescription "upm uln200xa darlington stepper driver")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/uln200xa/javaupm_uln200xa.i b/peripheral/libupm/src/uln200xa/javaupm_uln200xa.i
index 3b11bf2..0805ae3 100644
--- a/peripheral/libupm/src/uln200xa/javaupm_uln200xa.i
+++ b/peripheral/libupm/src/uln200xa/javaupm_uln200xa.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "uln200xa.hpp"
+ #include "uln200xa.h"
%}
-%include "uln200xa.hpp"
+%include "uln200xa.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/uln200xa/jsupm_uln200xa.i b/peripheral/libupm/src/uln200xa/jsupm_uln200xa.i
index a7ee87d..48127af 100644
--- a/peripheral/libupm/src/uln200xa/jsupm_uln200xa.i
+++ b/peripheral/libupm/src/uln200xa/jsupm_uln200xa.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "uln200xa.hpp"
+ #include "uln200xa.h"
%}
-%include "uln200xa.hpp"
+%include "uln200xa.h"
diff --git a/peripheral/libupm/src/uln200xa/pyupm_uln200xa.i b/peripheral/libupm/src/uln200xa/pyupm_uln200xa.i
index 60a16b7..6385933 100644
--- a/peripheral/libupm/src/uln200xa/pyupm_uln200xa.i
+++ b/peripheral/libupm/src/uln200xa/pyupm_uln200xa.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "uln200xa.hpp"
+%include "uln200xa.h"
%{
- #include "uln200xa.hpp"
+ #include "uln200xa.h"
%}
diff --git a/peripheral/libupm/src/uln200xa/uln200xa.cxx b/peripheral/libupm/src/uln200xa/uln200xa.cxx
index 49a3dda..068c766 100644
--- a/peripheral/libupm/src/uln200xa/uln200xa.cxx
+++ b/peripheral/libupm/src/uln200xa/uln200xa.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "uln200xa.hpp"
+#include "uln200xa.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/uln200xa/uln200xa.hpp b/peripheral/libupm/src/uln200xa/uln200xa.h
index 5a941b1..5a941b1 100644
--- a/peripheral/libupm/src/uln200xa/uln200xa.hpp
+++ b/peripheral/libupm/src/uln200xa/uln200xa.h
diff --git a/peripheral/libupm/src/upm.h b/peripheral/libupm/src/upm.h
index e287c82..eaecb3f 100644
--- a/peripheral/libupm/src/upm.h
+++ b/peripheral/libupm/src/upm.h
@@ -42,11 +42,6 @@
*/
/**
- * @brief Sensors grouped by C++ interface
- * @defgroup byif C++ Interface
- */
-
-/**
* @brief Sensors grouped by connection type
* @defgroup bycon Connection Type
*/
@@ -222,58 +217,11 @@
*/
/**
- * @brief Provide video or video camera access
- * @defgroup video Video
- * @ingroup bycat
- */
-
-/**
* @brief Provide WiFi, Bluetooth, RF communication
* @defgroup wifi Wireless Communication
* @ingroup bycat
*/
-////////////////////////////////////////////////////////////////// @cond IF
-/// Groups for the various Sensor C++ Interfaces.
-////////////////////////////////////////////////////////////////// @endcond IF
-
-/**
- * @brief Implements ILightSensor
- * @defgroup ilightsensor ILightSensor
- * @ingroup byif
- */
-
- /**
- * @brief Implements ILightController
- * @defgroup ilightcontroller ILightController
- * @ingroup byif
- */
-
-/**
- * @brief Implements IPressureSensor
- * @defgroup ipressuresensor IPressureSensor
- * @ingroup byif
- */
-
- /**
- * @brief Implements ITemperatureSensor
- * @defgroup itemperaturesensor ITemperatureSensor
- * @ingroup byif
- */
-
-/**
- * @brief Implements IADC
- * @defgroup iadc IADC
- * @ingroup byif
- */
-
- /**
- * @brief Implements ICOSensor
- * @defgroup ic02sensor ICOSensor
- * @ingroup byif
- */
-
-
////////////////////////////////////////////////////////////////// @cond CON
/// Groups for the various Connection Types.
////////////////////////////////////////////////////////////////// @endcond CON
@@ -379,12 +327,6 @@
*/
/**
- * @brief Mouser
- * @defgroup mouser Mouser
- * @ingroup byman
- */
-
-/**
* @brief Omega
* @defgroup omega Omega
* @ingroup byman
@@ -414,30 +356,6 @@
* @ingroup byman
*/
- /**
- * @brief Silicon Labs
- * @defgroup silabs Silicon Labs
- * @ingroup byman
- */
-
-/**
- * @brief Bosch
- * @defgroup bosch Bosch
- * @ingroup byman
- */
-
-/**
- * @brief Amphenol
- * @defgroup amphenol Amphenol
- * @ingroup byman
- */
-
-/**
- * @brief Open Electrons
- * @defgroup openelectrons Open Electrons
- * @ingroup byman
- */
-
////////////////////////////////////////////////////////////////// @cond KIT
/// Groups for the various Starter Kits.
////////////////////////////////////////////////////////////////// @endcond KIT
diff --git a/peripheral/libupm/src/upm/CMakeLists.txt b/peripheral/libupm/src/upm/CMakeLists.txt
deleted file mode 100644
index cd9b479..0000000
--- a/peripheral/libupm/src/upm/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-install (DIRECTORY . DESTINATION include/upm FILES_MATCHING PATTERN "*.hpp")
-if (BUILDSWIGJAVA AND BUILDSWIG)
- set (libname "interfaces")
- set (libdescription "upm interfaces")
- set (module_src ${libname}.cxx)
-# set (module_hpp ${libname}.hpp)
- upm_module_init()
-endif()
diff --git a/peripheral/libupm/src/upm/iADC.hpp b/peripheral/libupm/src/upm/iADC.hpp
deleted file mode 100644
index ad127ed..0000000
--- a/peripheral/libupm/src/upm/iADC.hpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-#pragma once
-#include <stdint.h>
-#include "mraa/common.h"
-#include "iModuleStatus.hpp"
-
-
-namespace upm
-{
-/**
- * @brief Interface for ADC Sensors
- */
-
- class IADC : public IModuleStatus
- {
- public:
- virtual unsigned int getResolutionInBits() = 0;
- virtual unsigned int getNumInputs() = 0;
- virtual uint16_t getRawValue(unsigned int input) = 0;
- virtual float getVoltage(unsigned int input) = 0;
- virtual ~IADC() {}
- };
-
-}
-
diff --git a/peripheral/libupm/src/upm/iCO2Sensor.hpp b/peripheral/libupm/src/upm/iCO2Sensor.hpp
deleted file mode 100644
index cbb1460..0000000
--- a/peripheral/libupm/src/upm/iCO2Sensor.hpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-#pragma once
-#include "iModuleStatus.hpp"
-
-
-namespace upm
-{
-/**
- * @brief Interface for CO Sensor
- */
-
- class ICO2Sensor : public IModuleStatus
- {
- public:
- virtual uint16_t getPpm() = 0;
- virtual ~ICO2Sensor() {}
- };
-
-}
-
diff --git a/peripheral/libupm/src/upm/iHumiditySensor.hpp b/peripheral/libupm/src/upm/iHumiditySensor.hpp
deleted file mode 100644
index 360d91e..0000000
--- a/peripheral/libupm/src/upm/iHumiditySensor.hpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#pragma once
-#include "iModuleStatus.hpp"
-
-namespace upm
-{
-/**
- * @brief Interface for Humidity Sensors
- */
-
- class IHumiditySensor : public IModuleStatus
- {
- public:
- virtual int getHumidityRelative () = 0;
- virtual ~IHumiditySensor() {}
- };
-
-}
-
diff --git a/peripheral/libupm/src/upm/iLightController.hpp b/peripheral/libupm/src/upm/iLightController.hpp
deleted file mode 100644
index 395cbf4..0000000
--- a/peripheral/libupm/src/upm/iLightController.hpp
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#pragma once
-
-#include "iModuleStatus.hpp"
-
-namespace upm
-{
-/**
- * @brief ILightController Interface for Light Controllers
- */
-
-/**
- *
- * @brief Interface for Light Controllers
-
- * This interface is used to represent light controllers
-
- * @snippet light-controllers.cxx Interesting
- */
-
- class ILightController : public IModuleStatus
- {
- public:
- /**
- * Turn on power
- *
- * @throws std::runtime_error
- */
- virtual void setPowerOn() = 0;
-
- /**
- * Turn off power
- *
- * @throws std::runtime_error
- */
- virtual void setPowerOff() = 0;
-
- /**
- * Get power state
- *
- * @return true if powered, false otherwise
- *
- * @throws std::runtime_error
- */
- virtual bool isPowered() = 0;
-
- /**
- * Set brightness
- *
- * @param brightness as percentage
- *
- * @throws std::runtime_error
- */
- virtual void setBrightness(int percent) = 0;
-
- /**
- * Get brightness
- *
- * @return brightness as percentage
- *
- * @throws std::runtime_error
- */
- virtual int getBrightness() = 0;
-
- virtual ~ILightController() {}
- };
-
-}
-
-
-
diff --git a/peripheral/libupm/src/upm/iLightSensor.hpp b/peripheral/libupm/src/upm/iLightSensor.hpp
deleted file mode 100644
index 1d58e62..0000000
--- a/peripheral/libupm/src/upm/iLightSensor.hpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-#pragma once
-
-#include <stdint.h>
-#include "iModuleStatus.hpp"
-
-namespace upm
-{
-/**
- * @brief ILightSensor Interface for Light Sensors
- */
-
-/**
- *
- * @brief Interface for Light Sensors
-
- * This interface is used to represent light sensors
-
- * @snippet light-sensor.cxx Interesting
- */
-
- class ILightSensor : public IModuleStatus
- {
- public:
-
- /**
- * Get visible illuminance in Lux.
- *
- * @return double visible illuminance in Lux
- */
- virtual double getVisibleLux() = 0;
-
-
- virtual ~ILightSensor() {}
- };
-}
-
diff --git a/peripheral/libupm/src/upm/iModuleStatus.hpp b/peripheral/libupm/src/upm/iModuleStatus.hpp
deleted file mode 100644
index 1ba8ca7..0000000
--- a/peripheral/libupm/src/upm/iModuleStatus.hpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#pragma once
-
-#include <stdexcept>
-
-namespace upm
-{
-/**
- * @brief Interface for Module Status. Sensor and Actuactor Interfaces Derive from this Interface.
- */
-
-#define UPM_THROW(msg) throw std::runtime_error(std::string(__FUNCTION__) + ": " + (msg))
-
-class IModuleStatus
-{
-public:
- /**
- * Returns name of module. This is the string in library name after libupm_
-
- * @return name of module
- */
- virtual const char* getModuleName() = 0;
-
- virtual ~IModuleStatus() {}
-};
-
-}
-
-
-
diff --git a/peripheral/libupm/src/upm/iPressureSensor.hpp b/peripheral/libupm/src/upm/iPressureSensor.hpp
deleted file mode 100644
index 63688b1..0000000
--- a/peripheral/libupm/src/upm/iPressureSensor.hpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2014 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-
-#pragma once
-
-#include <stdint.h>
-#include "mraa/common.h"
-#include "iModuleStatus.hpp"
-
-namespace upm
-{
-/**
- * @brief Interface for Pressue Sensors
- */
-
- class IPressureSensor : public IModuleStatus
- {
- public:
- virtual int getPressurePa() = 0;
- virtual ~IPressureSensor() {}
- };
-
-}
-
diff --git a/peripheral/libupm/src/upm/iTemperatureSensor.hpp b/peripheral/libupm/src/upm/iTemperatureSensor.hpp
deleted file mode 100644
index 7b393e8..0000000
--- a/peripheral/libupm/src/upm/iTemperatureSensor.hpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Author: Henry Bruce <henry.bruce@intel.com>
- * Copyright (c) 2015 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#pragma once
-#include "iModuleStatus.hpp"
-
-namespace upm
-{
-/**
- * @brief Interface for Temperature Sensors
- */
-
- class ITemperatureSensor : public IModuleStatus
- {
- public:
- virtual int getTemperatureCelcius () = 0;
- virtual ~ITemperatureSensor() {}
- };
-
-}
-
diff --git a/peripheral/libupm/src/upm/interfaces.cxx b/peripheral/libupm/src/upm/interfaces.cxx
deleted file mode 100644
index e76f706..0000000
--- a/peripheral/libupm/src/upm/interfaces.cxx
+++ /dev/null
@@ -1 +0,0 @@
-#include "upm/iLightSensor.hpp"
diff --git a/peripheral/libupm/src/upm/javaupm_interfaces.i b/peripheral/libupm/src/upm/javaupm_interfaces.i
deleted file mode 100644
index 42b9450..0000000
--- a/peripheral/libupm/src/upm/javaupm_interfaces.i
+++ /dev/null
@@ -1,15 +0,0 @@
-%module(directors="1") javaupm_interfaces
-
-%feature("director") IModuleStatus;
-%feature("director") ILightSensor;
-%feature("director") ILightController;
-
-
-%{
- #include "../upm/iLightSensor.hpp"
- #include "../upm/iLightController.hpp"
-%}
-
-%include "iModuleStatus.hpp"
-%include "iLightSensor.hpp"
-%include "iLightController.hpp"
diff --git a/peripheral/libupm/src/upm/javaupm_light_sensor.i b/peripheral/libupm/src/upm/javaupm_light_sensor.i
deleted file mode 100644
index d285ee8..0000000
--- a/peripheral/libupm/src/upm/javaupm_light_sensor.i
+++ /dev/null
@@ -1,15 +0,0 @@
-%module(directors="1") javaupm_light_sensor
-
-%{
- #include "iLightSensor.hpp"
-%}
-
-/*
-%include "../upm/iModuleStatus.hpp"
-*/
-%include "iLightSensor.hpp"
-
-%feature("director") IModuleStatus;
-%feature("director") ILightSensor;
-
-%include "iLightSensor.hpp"
diff --git a/peripheral/libupm/src/upm/jsupm_interfaces.i b/peripheral/libupm/src/upm/jsupm_interfaces.i
deleted file mode 100644
index 4cdfda6..0000000
--- a/peripheral/libupm/src/upm/jsupm_interfaces.i
+++ /dev/null
@@ -1,11 +0,0 @@
-%module jsupm_interfaces
-%include "../upm.i"
-
-%{
- #include "../upm/iLightSensor.hpp"
- #include "../upm/iLightController.hpp"
-%}
-
-%include "iModuleStatus.hpp"
-%include "iLightSensor.hpp"
-%include "iLightController.hpp"
diff --git a/peripheral/libupm/src/upm/pyupm_interfaces.i b/peripheral/libupm/src/upm/pyupm_interfaces.i
deleted file mode 100644
index 2914ee4..0000000
--- a/peripheral/libupm/src/upm/pyupm_interfaces.i
+++ /dev/null
@@ -1,13 +0,0 @@
-%module pyupm_interfaces
-%include "../upm.i"
-
-%feature("autodoc", "3");
-
-%{
- #include "../upm/iLightSensor.hpp"
- #include "../upm/iLightController.hpp"
-%}
-
-%include "iModuleStatus.hpp"
-%include "iLightSensor.hpp"
-%include "iLightController.hpp"
diff --git a/peripheral/libupm/src/urm37/CMakeLists.txt b/peripheral/libupm/src/urm37/CMakeLists.txt
index 8db4793..91a490e 100644
--- a/peripheral/libupm/src/urm37/CMakeLists.txt
+++ b/peripheral/libupm/src/urm37/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "urm37")
set (libdescription "upm DFRobot URM37 Ultrasonic ranger")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/urm37/javaupm_urm37.i b/peripheral/libupm/src/urm37/javaupm_urm37.i
index 7d16974..725bafe 100644
--- a/peripheral/libupm/src/urm37/javaupm_urm37.i
+++ b/peripheral/libupm/src/urm37/javaupm_urm37.i
@@ -3,10 +3,10 @@
%include "std_string.i"
%{
- #include "urm37.hpp"
+ #include "urm37.h"
%}
-%include "urm37.hpp"
+%include "urm37.h"
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/urm37/jsupm_urm37.i b/peripheral/libupm/src/urm37/jsupm_urm37.i
index 744978a..bc02946 100644
--- a/peripheral/libupm/src/urm37/jsupm_urm37.i
+++ b/peripheral/libupm/src/urm37/jsupm_urm37.i
@@ -3,8 +3,8 @@
%include "std_string.i"
%{
- #include "urm37.hpp"
+ #include "urm37.h"
%}
-%include "urm37.hpp"
+%include "urm37.h"
diff --git a/peripheral/libupm/src/urm37/pyupm_urm37.i b/peripheral/libupm/src/urm37/pyupm_urm37.i
index 23ebae4..4635dbb 100644
--- a/peripheral/libupm/src/urm37/pyupm_urm37.i
+++ b/peripheral/libupm/src/urm37/pyupm_urm37.i
@@ -7,7 +7,7 @@
%feature("autodoc", "3");
%{
- #include "urm37.hpp"
+ #include "urm37.h"
%}
-%include "urm37.hpp"
+%include "urm37.h"
diff --git a/peripheral/libupm/src/urm37/urm37.cxx b/peripheral/libupm/src/urm37/urm37.cxx
index faa68f9..85305d3 100644
--- a/peripheral/libupm/src/urm37/urm37.cxx
+++ b/peripheral/libupm/src/urm37/urm37.cxx
@@ -24,7 +24,7 @@
#include <iostream>
-#include "urm37.hpp"
+#include "urm37.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/urm37/urm37.hpp b/peripheral/libupm/src/urm37/urm37.h
index 21554b9..21554b9 100644
--- a/peripheral/libupm/src/urm37/urm37.hpp
+++ b/peripheral/libupm/src/urm37/urm37.h
diff --git a/peripheral/libupm/src/vcap/CMakeLists.txt b/peripheral/libupm/src/vcap/CMakeLists.txt
deleted file mode 100644
index e0c634e..0000000
--- a/peripheral/libupm/src/vcap/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-set (libname "vcap")
-set (libdescription "upm Video Frame Capture and image save utility")
-set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
-
-find_package (JPEG)
-if (JPEG_FOUND)
- set (reqlibname "jpeg")
- upm_module_init()
- target_link_libraries(${libname} jpeg)
- if (BUILDSWIG)
- if (BUILDSWIGNODE)
- swig_link_libraries (jsupm_${libname} jpeg)
- endif()
- if (BUILDSWIGPYTHON)
- swig_link_libraries (pyupm_${libname} jpeg)
- endif()
- if (BUILDSWIGJAVA)
- swig_link_libraries (javaupm_${libname} jpeg)
- endif()
- endif()
-endif() \ No newline at end of file
diff --git a/peripheral/libupm/src/vcap/jsupm_vcap.i b/peripheral/libupm/src/vcap/jsupm_vcap.i
deleted file mode 100644
index 0b5e5eb..0000000
--- a/peripheral/libupm/src/vcap/jsupm_vcap.i
+++ /dev/null
@@ -1,10 +0,0 @@
-%module jsupm_vcap
-%include "../upm.i"
-%include "std_string.i"
-
-%include "vcap.hpp"
-%{
- #include "vcap.hpp"
-%}
-
-
diff --git a/peripheral/libupm/src/vcap/pyupm_vcap.i b/peripheral/libupm/src/vcap/pyupm_vcap.i
deleted file mode 100644
index c56ec4b..0000000
--- a/peripheral/libupm/src/vcap/pyupm_vcap.i
+++ /dev/null
@@ -1,14 +0,0 @@
-// Include doxygen-generated documentation
-%include "pyupm_doxy2swig.i"
-%module pyupm_vcap
-%include "../upm.i"
-%include "std_string.i"
-
-%feature("autodoc", "3");
-
-%include "vcap.hpp"
-%{
- #include "vcap.hpp"
-%}
-
-
diff --git a/peripheral/libupm/src/vcap/vcap.cxx b/peripheral/libupm/src/vcap/vcap.cxx
deleted file mode 100644
index 8a992ce..0000000
--- a/peripheral/libupm/src/vcap/vcap.cxx
+++ /dev/null
@@ -1,524 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-
-#include <iostream>
-#include <stdexcept>
-#include <unistd.h>
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-
-#include "vcap.hpp"
-
-using namespace upm;
-using namespace std;
-
-#define CLAMP(_val, _min, _max) \
- (((_val) < (_min)) ? (_min) : (((_val) > (_max)) ? (_max) : (_val)))
-
-VCAP::VCAP(string videoDev) :
- m_buffer(0), m_fd(-1)
-{
- memset(&m_caps, 0, sizeof(struct v4l2_capability));
- memset(&m_format, 0, sizeof(struct v4l2_format));
-
- m_debugging = false;
- m_bufferLen = 0;
- m_videoDevice = videoDev;
- setJPGQuality(VCAP_DEFAULT_JPEG_QUALITY);
-
- // try to open the video device, and set a default format.
- if (!initVideoDevice())
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": initVideoDevice() failed");
-
- m_height = 0;
- m_width = 0;
- m_imageCaptured = false;
-}
-
-VCAP::~VCAP()
-{
- releaseBuffer();
-
- if (m_fd >= 0)
- close(m_fd);
-
- m_fd = -1;
-}
-
-bool VCAP::initVideoDevice()
-{
- if (m_videoDevice.empty())
- return false;
-
- if ((m_fd = open(m_videoDevice.c_str(), O_RDWR)) < 0)
- {
- cerr << __FUNCTION__ << ": open failed: " << strerror(errno) << endl;
- return false;
- }
-
- if (!checkCapabilities())
- {
- close(m_fd);
- m_fd = -1;
- return false;
- }
-
- return true;
-}
-
-// This seems... odd, but appears to be necessary.
-// Ignore error and retry if the ioctl fails due to EINTR
-int VCAP::xioctl(int fd, int request, void* argp)
-{
- int r;
-
- do {
- r = ioctl(fd, request, argp);
- }
- while (r == -1 && errno == EINTR);
-
- return r;
-}
-
-bool VCAP::checkCapabilities()
-{
- if (xioctl(m_fd, VIDIOC_QUERYCAP, &m_caps) < 0)
- {
- cerr << __FUNCTION__ << ": ioctl(VIDIOC_QUERYCAP) failed: "
- << strerror(errno) << endl;
- return false;
- }
-
- if (m_debugging)
- {
- cerr << "Driver: " << m_caps.driver << endl;
- cerr << "Device: " << m_caps.card << endl;
- cerr << "Caps : 0x" << std::hex << m_caps.capabilities << std::dec
- << endl;
- }
-
- // see if capturing is supported
- if (!(m_caps.capabilities & V4L2_CAP_VIDEO_CAPTURE))
- {
- cerr << __FUNCTION__ << ": Device does not support video capture"
- << endl;
- return false;
- }
-
- if (!(m_caps.capabilities & V4L2_CAP_STREAMING))
- {
- cerr << __FUNCTION__ << ": Device does not support streaming I/O"
- << endl;
- return false;
- }
-
- return true;
-}
-
-bool VCAP::setResolution(int width, int height)
-{
- // in case we already created one
- releaseBuffer();
-
- m_width = width;
- m_height = height;
-
- m_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- // initialize with the current format
- if (xioctl(m_fd, VIDIOC_G_FMT, &m_format) < 0)
- {
- cerr << __FUNCTION__ << ": ioctl(VIDIOC_G_FMT) failed: "
- << strerror(errno) << endl;
- return false;
- }
-
- // make our changes...
- m_format.fmt.pix.width = m_width;
- m_format.fmt.pix.height = m_height;
- m_format.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
- m_format.fmt.pix.field = V4L2_FIELD_ANY;
-
- if (xioctl(m_fd, VIDIOC_S_FMT, &m_format) < 0)
- {
- cerr << __FUNCTION__ << ": ioctl(VIDIOC_S_FMT) failed: "
- << strerror(errno) << endl;
-
- // If it's just busy, then this still might work, so don't fail here
- if (errno != EBUSY)
- return false;
- }
-
- // Now retrieve the driver's selected format and check it -
- // specifically, the width and height might change, causing
- // coredumps if we don't adjust them accordingly.
-
- if (xioctl(m_fd, VIDIOC_G_FMT, &m_format) < 0)
- {
- cerr << __FUNCTION__ << ": ioctl(VIDIOC_G_FMT) failed: "
- << strerror(errno) << endl;
- return false;
- }
-
- // G_FMT will have adjusted these if neccessary, so verify
- if (m_format.fmt.pix.width != m_width)
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": Warning: Selected width "
- << std::to_string(m_width)
- << " adjusted by driver to "
- << std::to_string(m_format.fmt.pix.width)
- << endl;
-
- m_width = m_format.fmt.pix.width;
- }
-
- if (m_format.fmt.pix.height != m_height)
- {
- if (m_debugging)
- cerr << __FUNCTION__ << ": Warning: Selected height "
- << std::to_string(m_height)
- << " adjusted by driver to "
- << std::to_string(m_format.fmt.pix.height)
- << endl;
-
- m_height = m_format.fmt.pix.height;
- }
-
- // now alloc the buffers here
- if (!allocBuffer())
- return false;
-
- return true;
-}
-
-bool VCAP::allocBuffer()
-{
- struct v4l2_requestbuffers rb;
- memset(&rb, 0, sizeof(rb));
-
- // we just want one buffer, and we only support mmap().
- rb.count = 1;
- rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- rb.memory = V4L2_MEMORY_MMAP;
-
- if (xioctl(m_fd, VIDIOC_REQBUFS, &rb) < 0)
- {
- if (errno == EINVAL)
- {
- cerr << __FUNCTION__ << ": Capture device does not support mmapped "
- << "buffers"
- << endl;
- }
- cerr << __FUNCTION__ << ": ioctl(VIDIOC_REQBUFS) failed: "
- << strerror(errno) << endl;
-
- return false;
- }
-
- // get the buffer and mmap it
- struct v4l2_buffer mbuf;
- memset(&mbuf, 0, sizeof(mbuf));
-
- mbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- mbuf.memory = V4L2_MEMORY_MMAP;
- mbuf.index = 0;
-
- if (xioctl(m_fd, VIDIOC_QUERYBUF, &mbuf) < 0)
- {
- cerr << __FUNCTION__ << ": ioctl(VIDIOC_QUERYBUF) failed: "
- << strerror(errno) << endl;
- return false;
- }
-
- // map it
- m_buffer = (unsigned char *)mmap(NULL, mbuf.length,
- PROT_READ | PROT_WRITE, MAP_SHARED,
- m_fd, mbuf.m.offset);
-
- if (m_buffer == MAP_FAILED)
- {
- cerr << __FUNCTION__ << ": mmap() failed: "
- << strerror(errno) << endl;
- return false;
- }
-
- // we'll need this when unmapping
- m_bufferLen = mbuf.length;
-
- return true;
-}
-
-void VCAP::releaseBuffer()
-{
- // first unmap any buffers
- if (m_buffer)
- munmap(m_buffer, m_bufferLen);
-
- m_buffer = 0;
- m_bufferLen = 0;
-
- // then, tell the kernel driver to free any allocated buffer(s)...
- struct v4l2_requestbuffers rb;
- memset(&rb, 0, sizeof(rb));
-
- rb.count = 0;
- rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- rb.memory = V4L2_MEMORY_MMAP;
-
- if (xioctl(m_fd, VIDIOC_REQBUFS, &rb) < 0)
- {
- cerr << __FUNCTION__ << ": ioctl(VIDIOC_REQBUFS) failed while freeing: "
- << strerror(errno) << endl;
- }
-
- // reset captured flag
- m_imageCaptured = false;
-}
-
-
-bool VCAP::YUYV2JPEG(FILE *file)
-{
- struct jpeg_compress_struct jpgInfo;
- struct jpeg_error_mgr jerr;
- JSAMPROW row_pointer[1];
- unsigned char *row_buffer = NULL;
- unsigned char *yuyv = NULL;
- int z;
-
- row_buffer = (unsigned char *)calloc(m_width * 3, 1);
- if (!row_buffer)
- {
- cerr << __FUNCTION__ << ": allocation of line buffer failed."
- << endl;
- return false;
- }
-
- yuyv = m_buffer;
-
- jpgInfo.err = jpeg_std_error(&jerr);
- jpeg_create_compress(&jpgInfo);
- jpeg_stdio_dest(&jpgInfo, file);
-
- jpgInfo.image_width = m_width;
- jpgInfo.image_height = m_height;
-
- // components R, G, B
- jpgInfo.input_components = 3;
- jpgInfo.in_color_space = JCS_RGB;
-
- jpeg_set_defaults(&jpgInfo);
- jpeg_set_quality(&jpgInfo, m_jpgQuality, TRUE);
-
- jpeg_start_compress(&jpgInfo, TRUE);
-
- z = 0;
-
- while (jpgInfo.next_scanline < jpgInfo.image_height)
- {
- int x;
- unsigned char *ptr = row_buffer;
-
- for (x = 0; x < m_width; x++)
- {
- int r, g, b;
- int y, u, v;
-
- if (!z)
- y = yuyv[0] << 8;
- else
- y = yuyv[2] << 8;
- u = yuyv[1] - 128;
- v = yuyv[3] - 128;
-
- r = (y + (359 * v)) >> 8;
- g = (y - (88 * u) - (183 * v)) >> 8;
- b = (y + (454 * u)) >> 8;
-
- *(ptr++) = CLAMP(r, 0, 255);
- *(ptr++) = CLAMP(g, 0, 255);
- *(ptr++) = CLAMP(b, 0, 255);
-
- if (z++)
- {
- z = 0;
- yuyv += 4;
- }
- }
-
- row_pointer[0] = row_buffer;
- jpeg_write_scanlines(&jpgInfo, row_pointer, 1);
- }
-
- jpeg_finish_compress(&jpgInfo);
- jpeg_destroy_compress(&jpgInfo);
-
- free(row_buffer);
-
- return true;
-}
-
-bool VCAP::saveImage(string filename)
-{
- // check m_buffer to make sure we have an actual buffer... If not,
- // we throw here.
- if (!m_buffer)
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": no buffer. Call setResolution() first");
- }
-
- // if we haven't done at least one capture yet...
- if (!m_imageCaptured)
- {
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": No data, call captureImage() first");
- }
-
- FILE *file;
- if ((file = fopen(filename.c_str(), "wb")) == NULL)
- {
- cerr << __FUNCTION__ << ": fopen() failed: "
- << strerror(errno) << endl;
- return false;
- }
-
- YUYV2JPEG(file);
- fclose(file);
-
- if (m_debugging)
- cerr << __FUNCTION__ << ": Saved image to " << filename << endl;
-
- return true;
-}
-
-bool VCAP::captureImage()
-{
- // first, make sure a resolution was specified. If not, set the
- // default
- if (m_width == 0 || m_height == 0)
- {
- if (!setResolution(VCAP_DEFAULT_WIDTH, VCAP_DEFAULT_HEIGHT))
- throw std::runtime_error(std::string(__FUNCTION__) +
- ": setResolution() failed");
- }
-
- // we basically just call doCaptureImage() twice - once to grab and
- // discard the first frame (which is usually a remnent of a previous
- // capture), and another to grab the real frame we are interesed in.
-
- if (!doCaptureImage())
- {
- cerr << __FUNCTION__ << ": capture of first frame failed"
- << endl;
- }
-
- return doCaptureImage();
-}
-
-
-// the real workhorse
-bool VCAP::doCaptureImage()
-{
- struct v4l2_buffer buf = {0};
- buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- buf.memory = V4L2_MEMORY_MMAP;
- buf.index = 0;
-
- // queue our buffer
- if (xioctl(m_fd, VIDIOC_QBUF, &buf) < 0)
- {
- cerr << __FUNCTION__ << ": ioctl(VIDIOC_QBUF) failed: "
- << strerror(errno) << endl;
-
- return false;
- }
-
- // enable streaming
- if (xioctl(m_fd, VIDIOC_STREAMON, &buf.type) < 0)
- {
- cerr << __FUNCTION__ << ": ioctl(VIDIOC_STREAMON) failed: "
- << strerror(errno) << endl;
-
- return false;
- }
-
- // use select to wait for a complete frame.
- fd_set fds;
-
- FD_ZERO(&fds);
- FD_SET(m_fd, &fds);
-
- struct timeval tv;
- memset(&tv, 0, sizeof(tv));
-
- // 5 seconds should be more than enough
- tv.tv_sec = 5;
-
- int rv;
- if ((rv = select(m_fd + 1, &fds, NULL, NULL, &tv)) < 0)
- {
- cerr << __FUNCTION__ << ": select() failed: "
- << strerror(errno) << endl;
- return false;
- }
-
- if (!rv)
- {
- // timed out
- cerr << __FUNCTION__ << ": select() timed out waiting for frame"
- << endl;
-
- return false;
- }
-
- // de-queue the buffer, we're now free to access it via the mmapped
- // ptr (m_buffer)
- if (xioctl(m_fd, VIDIOC_DQBUF, &buf) < 0)
- {
- cerr << __FUNCTION__ << ": ioctl(VIDIOC_DQBUF) failed: "
- << strerror(errno) << endl;
-
- return false;
- }
-
- // turn off streaming
- if (xioctl(m_fd, VIDIOC_STREAMOFF, &buf.type) < 0)
- {
- cerr << __FUNCTION__ << ": ioctl(VIDIOC_STREAMOFF) failed: "
- << strerror(errno) << endl;
-
- return false;
- }
-
- m_imageCaptured = true;
-
- return true;
-}
-
- void VCAP::setJPGQuality(unsigned int qual)
- {
- m_jpgQuality = CLAMP(qual, 0, 100);
- }
diff --git a/peripheral/libupm/src/vcap/vcap.hpp b/peripheral/libupm/src/vcap/vcap.hpp
deleted file mode 100644
index 9b222d7..0000000
--- a/peripheral/libupm/src/vcap/vcap.hpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Author: Jon Trulson <jtrulson@ics.com>
- * Copyright (c) 2016 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- */
-#pragma once
-
-#include <string>
-#include <iostream>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <jpeglib.h>
-#include <linux/videodev2.h>
-
-#define VCAP_DEFAULT_VIDEODEV "/dev/video0"
-#define VCAP_DEFAULT_OUTPUTFILE "vcap.jpg"
-#define VCAP_DEFAULT_WIDTH 640
-#define VCAP_DEFAULT_HEIGHT 480
-#define VCAP_DEFAULT_JPEG_QUALITY 99
-
-namespace upm {
- /**
- * @brief Take a snapshot from a video camera and save as a JPEG
- * @defgroup vcap libupm-vcap
- * @ingroup video
- */
-
- /**
- * @library vcap
- * @sensor vcap
- * @comname Video Capture
- * @type video
- *
- * @brief API for the Video Capture driver
- *
- * This UPM module captures a still frame from a Linux V4L device,
- * such as a USB webcam, and and then allows you to save it as a
- * JPEG image into a file.
- *
- * The camera and driver in use must support streaming, mmap-able
- * buffers and must provide data in YUYV format. This should
- * encompass most video cameras out there. It has been tested
- * with a few off the shelf cameras without any problems.
- *
- * @snippet vcap.cxx Interesting
- */
-
- class VCAP {
- public:
-
- /**
- * VCAP object constructor
- *
- * @param videoDev The path to the video device, default is /dev/video0.
- */
- VCAP(std::string videoDev=VCAP_DEFAULT_VIDEODEV);
-
- /**
- * VCAP object destructor
- */
- ~VCAP();
-
- /**
- * Set the desired resolution of the output image. Note, this is
- * a hint to the underlying video driver. The video driver is
- * free to lower the specified resolution if the hardware cannot
- * support it. You can use getHeight() and getWidth() after
- * calling this method to see what the video driver chose.
- *
- * @param width The desired width of the image.
- * @param width The desired height of the image.
- * @return true if the operation succeeded, false otherwise.
- */
- bool setResolution(int width, int height);
-
- /**
- * Capture an image from the camera.
- *
- * @return true if the operation succeeded, false otherwise.
- */
- bool captureImage();
-
- /**
- * Save the captured image (created with captureImage()) to a file
- * in JPEG format. The file will be overwritten if it already
- * exists.
- *
- * @param filename The name of the file in which to store the image.
- * @return true if the operation succeeded, false otherwise.
- */
- bool saveImage(std::string filename=VCAP_DEFAULT_OUTPUTFILE);
-
- /**
- * Return the current width of the image. You can use this method
- * to determine if the video driver downgraded it after a call to
- * setResolution().
- *
- * @return true Current width of capture.
- */
- int getWidth() const
- {
- return m_width;
- };
-
- /**
- * Return the current height of the image. You can use this method
- * to determine if the video driver downgraded it after a call to
- * setResolution().
- *
- * @return true Current height of capture.
- */
- int getHeight() const
- {
- return m_height;
- };
-
- /**
- * Set the JPEG quality.
- *
- * @param quality A number between 0-100, with higher numbers
- * meaning higher quality. Numbers less than 0 will be clamped to
- * 0, numbers higher than 100 will be clamped to 100.
- */
- void setJPGQuality(unsigned int quality);
-
- /**
- * Get the current JPEG quality setting.
- *
- * @return the current JPEG quality setting.
- */
- int getJPGQuality() const
- {
- return m_jpgQuality;
- };
-
- /**
- * Enable or disable debugging output.
- *
- * @param enable true to enable debugging, false otherwise
- */
- void setDebug(bool enable)
- {
- m_debugging = enable;
- };
-
- protected:
- // open the device and check that it meats minimum requirements
- bool initVideoDevice();
-
- // make sure device is streamable, supports mmap and capture
- bool checkCapabilities();
-
- // read the mmapped buffer in YUYV format and create a jpeg image
- bool YUYV2JPEG(FILE *file);
-
- // buffer management
- bool allocBuffer();
- void releaseBuffer();
-
- // does the actual capture
- bool doCaptureImage();
-
- private:
- // internal ioctl
- int xioctl(int fd, int request, void* argp);
-
- std::string m_videoDevice;
-
- // our file descriptor to the video device
- int m_fd;
-
- // v4l info
- struct v4l2_capability m_caps;
- struct v4l2_format m_format;
-
- // our mmaped buffer
- unsigned char *m_buffer;
- size_t m_bufferLen;
-
- // the resolution and quality
- int m_width;
- int m_height;
- int m_jpgQuality;
-
- // at least one image captured with current settings?
- bool m_imageCaptured;
-
- // are we debugging?
- bool m_debugging;
- };
-}
-
-
diff --git a/peripheral/libupm/src/waterlevel/CMakeLists.txt b/peripheral/libupm/src/waterlevel/CMakeLists.txt
index f92eddc..4f985e2 100644
--- a/peripheral/libupm/src/waterlevel/CMakeLists.txt
+++ b/peripheral/libupm/src/waterlevel/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "waterlevel")
set (libdescription "upm waterlevel sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init("-lrt")
diff --git a/peripheral/libupm/src/waterlevel/javaupm_waterlevel.i b/peripheral/libupm/src/waterlevel/javaupm_waterlevel.i
index b9e9f2d..7365c37 100644
--- a/peripheral/libupm/src/waterlevel/javaupm_waterlevel.i
+++ b/peripheral/libupm/src/waterlevel/javaupm_waterlevel.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "waterlevel.hpp"
+ #include "waterlevel.h"
%}
-%include "waterlevel.hpp"
+%include "waterlevel.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/waterlevel/jsupm_waterlevel.i b/peripheral/libupm/src/waterlevel/jsupm_waterlevel.i
index 7eef682..44a715e 100644
--- a/peripheral/libupm/src/waterlevel/jsupm_waterlevel.i
+++ b/peripheral/libupm/src/waterlevel/jsupm_waterlevel.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "waterlevel.hpp"
+ #include "waterlevel.h"
%}
-%include "waterlevel.hpp"
+%include "waterlevel.h"
diff --git a/peripheral/libupm/src/waterlevel/pyupm_waterlevel.i b/peripheral/libupm/src/waterlevel/pyupm_waterlevel.i
index 40f98d4..75b6bda 100644
--- a/peripheral/libupm/src/waterlevel/pyupm_waterlevel.i
+++ b/peripheral/libupm/src/waterlevel/pyupm_waterlevel.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "waterlevel.hpp"
+%include "waterlevel.h"
%{
- #include "waterlevel.hpp"
+ #include "waterlevel.h"
%}
diff --git a/peripheral/libupm/src/waterlevel/waterlevel.cxx b/peripheral/libupm/src/waterlevel/waterlevel.cxx
index 02db04f..8a06019 100644
--- a/peripheral/libupm/src/waterlevel/waterlevel.cxx
+++ b/peripheral/libupm/src/waterlevel/waterlevel.cxx
@@ -24,7 +24,7 @@
#include <string>
#include <stdexcept>
-#include "waterlevel.hpp"
+#include "waterlevel.h"
using namespace upm;
diff --git a/peripheral/libupm/src/waterlevel/waterlevel.hpp b/peripheral/libupm/src/waterlevel/waterlevel.h
index a2fc877..a2fc877 100644
--- a/peripheral/libupm/src/waterlevel/waterlevel.hpp
+++ b/peripheral/libupm/src/waterlevel/waterlevel.h
diff --git a/peripheral/libupm/src/wheelencoder/CMakeLists.txt b/peripheral/libupm/src/wheelencoder/CMakeLists.txt
index c11f975..9528920 100644
--- a/peripheral/libupm/src/wheelencoder/CMakeLists.txt
+++ b/peripheral/libupm/src/wheelencoder/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "wheelencoder")
set (libdescription "upm DFRobot wheelencoder")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/wheelencoder/javaupm_wheelencoder.i b/peripheral/libupm/src/wheelencoder/javaupm_wheelencoder.i
index 7baff36..2b29f35 100644
--- a/peripheral/libupm/src/wheelencoder/javaupm_wheelencoder.i
+++ b/peripheral/libupm/src/wheelencoder/javaupm_wheelencoder.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "wheelencoder.hpp"
+ #include "wheelencoder.h"
%}
-%include "wheelencoder.hpp"
+%include "wheelencoder.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/wheelencoder/jsupm_wheelencoder.i b/peripheral/libupm/src/wheelencoder/jsupm_wheelencoder.i
index bd6bd12..ded5481 100644
--- a/peripheral/libupm/src/wheelencoder/jsupm_wheelencoder.i
+++ b/peripheral/libupm/src/wheelencoder/jsupm_wheelencoder.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "wheelencoder.hpp"
+ #include "wheelencoder.h"
%}
-%include "wheelencoder.hpp"
+%include "wheelencoder.h"
diff --git a/peripheral/libupm/src/wheelencoder/pyupm_wheelencoder.i b/peripheral/libupm/src/wheelencoder/pyupm_wheelencoder.i
index 46df2f0..9cfab7e 100644
--- a/peripheral/libupm/src/wheelencoder/pyupm_wheelencoder.i
+++ b/peripheral/libupm/src/wheelencoder/pyupm_wheelencoder.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "wheelencoder.hpp"
+%include "wheelencoder.h"
%{
- #include "wheelencoder.hpp"
+ #include "wheelencoder.h"
%}
diff --git a/peripheral/libupm/src/wheelencoder/wheelencoder.cxx b/peripheral/libupm/src/wheelencoder/wheelencoder.cxx
index ffcf709..ae48c1d 100644
--- a/peripheral/libupm/src/wheelencoder/wheelencoder.cxx
+++ b/peripheral/libupm/src/wheelencoder/wheelencoder.cxx
@@ -27,7 +27,7 @@
#ifdef JAVACALLBACK
#undef JAVACALLBACK
#endif
-#include "wheelencoder.hpp"
+#include "wheelencoder.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/wheelencoder/wheelencoder.hpp b/peripheral/libupm/src/wheelencoder/wheelencoder.h
index 17356e0..17356e0 100644
--- a/peripheral/libupm/src/wheelencoder/wheelencoder.hpp
+++ b/peripheral/libupm/src/wheelencoder/wheelencoder.h
diff --git a/peripheral/libupm/src/wt5001/CMakeLists.txt b/peripheral/libupm/src/wt5001/CMakeLists.txt
index d0d6e50..f70c82b 100644
--- a/peripheral/libupm/src/wt5001/CMakeLists.txt
+++ b/peripheral/libupm/src/wt5001/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "wt5001")
set (libdescription "upm grove serial mp3 (wt5001) module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/wt5001/javaupm_wt5001.i b/peripheral/libupm/src/wt5001/javaupm_wt5001.i
index dd9c9dc..fa38c56 100644
--- a/peripheral/libupm/src/wt5001/javaupm_wt5001.i
+++ b/peripheral/libupm/src/wt5001/javaupm_wt5001.i
@@ -14,7 +14,7 @@
%apply uint8_t *OUTPUT { uint8_t *hour, uint8_t *minute, uint8_t *second };
%{
- #include "wt5001.hpp"
+ #include "wt5001.h"
speed_t int_B9600 = B9600;
%}
@@ -30,7 +30,7 @@ READDATA_EXCEPTION(getNumFiles(WT5001_PLAYSOURCE_T psrc))
%ignore getCurrentFile(uint16_t *curf);
READDATA_EXCEPTION(getCurrentFile())
-%include "wt5001.hpp"
+%include "wt5001.h"
speed_t int_B9600 = B9600;
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/wt5001/jsupm_wt5001.i b/peripheral/libupm/src/wt5001/jsupm_wt5001.i
index 336e693..c53fc57 100644
--- a/peripheral/libupm/src/wt5001/jsupm_wt5001.i
+++ b/peripheral/libupm/src/wt5001/jsupm_wt5001.i
@@ -4,9 +4,9 @@
%include "../carrays_uint16_t.i"
%{
- #include "wt5001.hpp"
+ #include "wt5001.h"
speed_t int_B9600 = B9600;
%}
-%include "wt5001.hpp"
+%include "wt5001.h"
speed_t int_B9600 = B9600;
diff --git a/peripheral/libupm/src/wt5001/pyupm_wt5001.i b/peripheral/libupm/src/wt5001/pyupm_wt5001.i
index a074be4..aa0089d 100644
--- a/peripheral/libupm/src/wt5001/pyupm_wt5001.i
+++ b/peripheral/libupm/src/wt5001/pyupm_wt5001.i
@@ -13,8 +13,8 @@
%feature("autodoc", "3");
%{
- #include "wt5001.hpp"
+ #include "wt5001.h"
speed_t int_B9600 = B9600;
%}
-%include "wt5001.hpp"
+%include "wt5001.h"
speed_t int_B9600 = B9600;
diff --git a/peripheral/libupm/src/wt5001/wt5001.cxx b/peripheral/libupm/src/wt5001/wt5001.cxx
index 9d2e61e..e4d18ba 100644
--- a/peripheral/libupm/src/wt5001/wt5001.cxx
+++ b/peripheral/libupm/src/wt5001/wt5001.cxx
@@ -27,7 +27,7 @@
#include <string>
#include <stdexcept>
-#include "wt5001.hpp"
+#include "wt5001.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/wt5001/wt5001.hpp b/peripheral/libupm/src/wt5001/wt5001.h
index c21135a..c21135a 100644
--- a/peripheral/libupm/src/wt5001/wt5001.hpp
+++ b/peripheral/libupm/src/wt5001/wt5001.h
diff --git a/peripheral/libupm/src/xbee/CMakeLists.txt b/peripheral/libupm/src/xbee/CMakeLists.txt
index 7c0c9bc..3f46f2d 100644
--- a/peripheral/libupm/src/xbee/CMakeLists.txt
+++ b/peripheral/libupm/src/xbee/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "xbee")
set (libdescription "upm XBee serial module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/xbee/javaupm_xbee.i b/peripheral/libupm/src/xbee/javaupm_xbee.i
index 95d7cea..c886424 100644
--- a/peripheral/libupm/src/xbee/javaupm_xbee.i
+++ b/peripheral/libupm/src/xbee/javaupm_xbee.i
@@ -4,10 +4,10 @@
%include "std_string.i"
%{
- #include "xbee.hpp"
+ #include "xbee.h"
%}
-%include "xbee.hpp"
+%include "xbee.h"
%array_class(char, charArray);
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/xbee/jsupm_xbee.i b/peripheral/libupm/src/xbee/jsupm_xbee.i
index 1d7339d..f71f0ce 100644
--- a/peripheral/libupm/src/xbee/jsupm_xbee.i
+++ b/peripheral/libupm/src/xbee/jsupm_xbee.i
@@ -4,8 +4,8 @@
%include "std_string.i"
%{
- #include "xbee.hpp"
+ #include "xbee.h"
%}
-%include "xbee.hpp"
+%include "xbee.h"
%array_class(char, charArray);
diff --git a/peripheral/libupm/src/xbee/pyupm_xbee.i b/peripheral/libupm/src/xbee/pyupm_xbee.i
index 12433de..a895f54 100644
--- a/peripheral/libupm/src/xbee/pyupm_xbee.i
+++ b/peripheral/libupm/src/xbee/pyupm_xbee.i
@@ -8,7 +8,7 @@
%feature("autodoc", "3");
%{
- #include "xbee.hpp"
+ #include "xbee.h"
%}
-%include "xbee.hpp"
+%include "xbee.h"
%array_class(char, charArray);
diff --git a/peripheral/libupm/src/xbee/xbee.cxx b/peripheral/libupm/src/xbee/xbee.cxx
index d3073e1..91c2150 100644
--- a/peripheral/libupm/src/xbee/xbee.cxx
+++ b/peripheral/libupm/src/xbee/xbee.cxx
@@ -25,7 +25,7 @@
#include <iostream>
#include <time.h>
-#include "xbee.hpp"
+#include "xbee.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/xbee/xbee.hpp b/peripheral/libupm/src/xbee/xbee.h
index c03c00a..c03c00a 100644
--- a/peripheral/libupm/src/xbee/xbee.hpp
+++ b/peripheral/libupm/src/xbee/xbee.h
diff --git a/peripheral/libupm/src/yg1006/CMakeLists.txt b/peripheral/libupm/src/yg1006/CMakeLists.txt
index 01bdc2a..8f58549 100644
--- a/peripheral/libupm/src/yg1006/CMakeLists.txt
+++ b/peripheral/libupm/src/yg1006/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "yg1006")
set (libdescription "upm yg1006 flame sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/yg1006/javaupm_yg1006.i b/peripheral/libupm/src/yg1006/javaupm_yg1006.i
index a2c2650..c3b01c4 100644
--- a/peripheral/libupm/src/yg1006/javaupm_yg1006.i
+++ b/peripheral/libupm/src/yg1006/javaupm_yg1006.i
@@ -2,10 +2,10 @@
%include "../upm.i"
%{
- #include "yg1006.hpp"
+ #include "yg1006.h"
%}
-%include "yg1006.hpp"
+%include "yg1006.h"
%pragma(java) jniclasscode=%{
static {
diff --git a/peripheral/libupm/src/yg1006/jsupm_yg1006.i b/peripheral/libupm/src/yg1006/jsupm_yg1006.i
index e9ae926..1b83ad1 100644
--- a/peripheral/libupm/src/yg1006/jsupm_yg1006.i
+++ b/peripheral/libupm/src/yg1006/jsupm_yg1006.i
@@ -2,7 +2,7 @@
%include "../upm.i"
%{
- #include "yg1006.hpp"
+ #include "yg1006.h"
%}
-%include "yg1006.hpp"
+%include "yg1006.h"
diff --git a/peripheral/libupm/src/yg1006/pyupm_yg1006.i b/peripheral/libupm/src/yg1006/pyupm_yg1006.i
index 92bbcb6..2b5dd5a 100644
--- a/peripheral/libupm/src/yg1006/pyupm_yg1006.i
+++ b/peripheral/libupm/src/yg1006/pyupm_yg1006.i
@@ -5,7 +5,7 @@
%feature("autodoc", "3");
-%include "yg1006.hpp"
+%include "yg1006.h"
%{
- #include "yg1006.hpp"
+ #include "yg1006.h"
%}
diff --git a/peripheral/libupm/src/yg1006/yg1006.cxx b/peripheral/libupm/src/yg1006/yg1006.cxx
index 07be0ef..7ac721a 100644
--- a/peripheral/libupm/src/yg1006/yg1006.cxx
+++ b/peripheral/libupm/src/yg1006/yg1006.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "yg1006.hpp"
+#include "yg1006.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/yg1006/yg1006.hpp b/peripheral/libupm/src/yg1006/yg1006.h
index a64f32d..a64f32d 100644
--- a/peripheral/libupm/src/yg1006/yg1006.hpp
+++ b/peripheral/libupm/src/yg1006/yg1006.h
diff --git a/peripheral/libupm/src/zfm20/CMakeLists.txt b/peripheral/libupm/src/zfm20/CMakeLists.txt
index b7d055b..1ad514b 100644
--- a/peripheral/libupm/src/zfm20/CMakeLists.txt
+++ b/peripheral/libupm/src/zfm20/CMakeLists.txt
@@ -1,5 +1,5 @@
set (libname "zfm20")
set (libdescription "upm grove zfm20 fingerprint sensor module")
set (module_src ${libname}.cxx)
-set (module_hpp ${libname}.hpp)
+set (module_h ${libname}.h)
upm_module_init()
diff --git a/peripheral/libupm/src/zfm20/javaupm_zfm20.i b/peripheral/libupm/src/zfm20/javaupm_zfm20.i
index cbecc9e..561ec12 100644
--- a/peripheral/libupm/src/zfm20/javaupm_zfm20.i
+++ b/peripheral/libupm/src/zfm20/javaupm_zfm20.i
@@ -8,12 +8,12 @@
%apply uint16_t *OUTPUT { uint16_t *id, uint16_t *score };
%{
- #include "zfm20.hpp"
+ #include "zfm20.h"
speed_t int_B57600 = B57600;
%}
-%include "zfm20.hpp"
+%include "zfm20.h"
speed_t int_B57600 = B57600;
%pragma(java) jniclasscode=%{
diff --git a/peripheral/libupm/src/zfm20/jsupm_zfm20.i b/peripheral/libupm/src/zfm20/jsupm_zfm20.i
index 0dcb44b..55b07b1 100644
--- a/peripheral/libupm/src/zfm20/jsupm_zfm20.i
+++ b/peripheral/libupm/src/zfm20/jsupm_zfm20.i
@@ -1,6 +1,5 @@
%module jsupm_zfm20
%include "../upm.i"
-%include "../carrays_uint8_t.i"
%include "../carrays_uint16_t.i"
%include "../carrays_uint32_t.i"
%include "cpointer.i"
@@ -8,9 +7,9 @@
/* Send "int *" to JavaScript as intp */
%pointer_functions(int, intp);
%{
- #include "zfm20.hpp"
+ #include "zfm20.h"
speed_t int_B57600 = B57600;
%}
-%include "zfm20.hpp"
+%include "zfm20.h"
speed_t int_B57600 = B57600;
diff --git a/peripheral/libupm/src/zfm20/pyupm_zfm20.i b/peripheral/libupm/src/zfm20/pyupm_zfm20.i
index 5ff2458..d1cac93 100644
--- a/peripheral/libupm/src/zfm20/pyupm_zfm20.i
+++ b/peripheral/libupm/src/zfm20/pyupm_zfm20.i
@@ -2,7 +2,6 @@
%include "pyupm_doxy2swig.i"
%module pyupm_zfm20
%include "../upm.i"
-%include "../carrays_uint8_t.i"
%include "../carrays_uint16_t.i"
%include "../carrays_uint32_t.i"
%include "cpointer.i"
@@ -12,8 +11,8 @@
/* Send "int *" to python as intp */
%pointer_functions(int, intp);
%{
- #include "zfm20.hpp"
+ #include "zfm20.h"
speed_t int_B57600 = B57600;
%}
-%include "zfm20.hpp"
+%include "zfm20.h"
speed_t int_B57600 = B57600;
diff --git a/peripheral/libupm/src/zfm20/zfm20.cxx b/peripheral/libupm/src/zfm20/zfm20.cxx
index 0c4825a..f0e42c8 100644
--- a/peripheral/libupm/src/zfm20/zfm20.cxx
+++ b/peripheral/libupm/src/zfm20/zfm20.cxx
@@ -26,7 +26,7 @@
#include <string>
#include <stdexcept>
-#include "zfm20.hpp"
+#include "zfm20.h"
using namespace upm;
using namespace std;
diff --git a/peripheral/libupm/src/zfm20/zfm20.hpp b/peripheral/libupm/src/zfm20/zfm20.h
index 91ae18b..91ae18b 100644
--- a/peripheral/libupm/src/zfm20/zfm20.hpp
+++ b/peripheral/libupm/src/zfm20/zfm20.h
diff --git a/peripheral/sensors/mraa/sensors/GroveLight.hpp b/peripheral/sensors/mraa/sensors/GroveLight.hpp
index a33bca5..401e834 100644
--- a/peripheral/sensors/mraa/sensors/GroveLight.hpp
+++ b/peripheral/sensors/mraa/sensors/GroveLight.hpp
@@ -19,7 +19,7 @@
#include <hardware/sensors.h>
#include "Sensor.hpp"
-#include "grove.hpp"
+#include "grove.h"
struct sensors_event_t;
diff --git a/peripheral/sensors/mraa/sensors/GroveTemperature.hpp b/peripheral/sensors/mraa/sensors/GroveTemperature.hpp
index 5ef5617..a3df4db 100644
--- a/peripheral/sensors/mraa/sensors/GroveTemperature.hpp
+++ b/peripheral/sensors/mraa/sensors/GroveTemperature.hpp
@@ -19,7 +19,7 @@
#include <hardware/sensors.h>
#include "Sensor.hpp"
-#include "grove.hpp"
+#include "grove.h"
struct sensors_event_t;
diff --git a/peripheral/sensors/mraa/sensors/LSM9DS0Accelerometer.hpp b/peripheral/sensors/mraa/sensors/LSM9DS0Accelerometer.hpp
index 9066967..4be9acd 100644
--- a/peripheral/sensors/mraa/sensors/LSM9DS0Accelerometer.hpp
+++ b/peripheral/sensors/mraa/sensors/LSM9DS0Accelerometer.hpp
@@ -19,7 +19,7 @@
#include <hardware/sensors.h>
#include "Sensor.hpp"
-#include "lsm9ds0.hpp"
+#include "lsm9ds0.h"
struct sensors_event_t;
diff --git a/peripheral/sensors/mraa/sensors/MMA7660Accelerometer.hpp b/peripheral/sensors/mraa/sensors/MMA7660Accelerometer.hpp
index ed3b6fd..5233868 100644
--- a/peripheral/sensors/mraa/sensors/MMA7660Accelerometer.hpp
+++ b/peripheral/sensors/mraa/sensors/MMA7660Accelerometer.hpp
@@ -19,7 +19,7 @@
#include <hardware/sensors.h>
#include "Sensor.hpp"
-#include "mma7660.hpp"
+#include "mma7660.h"
struct sensors_event_t;
diff --git a/peripheral/sensors/mraa/sensors/MPU9150Accelerometer.hpp b/peripheral/sensors/mraa/sensors/MPU9150Accelerometer.hpp
index 0e14330..100eb6b 100644
--- a/peripheral/sensors/mraa/sensors/MPU9150Accelerometer.hpp
+++ b/peripheral/sensors/mraa/sensors/MPU9150Accelerometer.hpp
@@ -19,7 +19,7 @@
#include <hardware/sensors.h>
#include "Sensor.hpp"
-#include "mpu9150.hpp"
+#include "mpu9150.h"
struct sensors_event_t;
diff --git a/peripheral/sensors/mraa/sensors/ProximityGPIO.hpp b/peripheral/sensors/mraa/sensors/ProximityGPIO.hpp
index 047dfb3..24935f7 100644
--- a/peripheral/sensors/mraa/sensors/ProximityGPIO.hpp
+++ b/peripheral/sensors/mraa/sensors/ProximityGPIO.hpp
@@ -19,7 +19,7 @@
#include <hardware/sensors.h>
#include "Sensor.hpp"
-#include "grove.hpp"
+#include "grove.h"
struct sensors_event_t;