Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of kionix-kx123-driver by
Diff: kx123.h
- Revision:
- 0:a3f43eb92f86
- Child:
- 1:f328083fb80b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/kx123.h Thu Sep 29 15:05:08 2016 +0000
@@ -0,0 +1,67 @@
+/* Copyright 2016 Rohm Semiconductor
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+#ifndef KX123_H
+#define KX123_H
+
+//#include "mbed.h" //types
+#include "I2C.h" //I2C
+
+#include "RegisterWriter/RegisterWriter/rohm_hal2.h"
+#include "RegisterWriter/RegisterWriter/RegisterWriter.h"
+
+
+/**
+* KX123 accelerometer driver
+*/
+class KX123
+{
+public:
+ /**
+ * Create a KX123 instance which is connected to pre-instantiated I2C object.
+ *
+ * @param sad slave address of sensor.
+ * @param wai who_am_i value (i.e. sensor type/model)
+ */
+ KX123(RegisterWriter &i2c_obj, uint8_t sad = KX123_DEFAULT_SLAVE_ADDRESS, uint8_t wai = KX123_WHO_AM_I_WAI_ID);
+
+ /**
+ * KX123 destructor
+ */
+ ~KX123();
+
+ /**
+ * Probe and setup kx123 (or other accelerometer from same family)
+ */
+ bool set_defaults(void);
+ /**
+ * Get results in raw value
+ */
+ bool getresults_raw(int16_t* buf);
+ /**
+ * Get results in 1G-values
+ */
+ bool getresults_g(float* buf);
+
+
+private:
+ void set_tilt_position_defaults();
+
+ RegisterWriter i2c_rw;
+ uint16_t resolution_divider;
+ uint8_t sad;
+ uint8_t wai;
+};
+
+#endif
\ No newline at end of file
