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.
Dependencies: azure_umqtt_c iothub_mqtt_transport mbed-rtos mbed wolfSSL Socket lwip-eth lwip-sys lwip
SingletonFXOS8700CQ.h
00001 // Copyright (c) Microsoft. All rights reserved. 00002 // Licensed under the MIT license. See LICENSE file at https://github.com/Azure/azure-iot-sdks/blob/master/LICENSE for full license information. 00003 00004 #include "mbed.h" 00005 #include "FXOS8700CQ.h" 00006 00007 typedef struct 00008 { 00009 int16_t x; 00010 int16_t y; 00011 int16_t z; 00012 } AXES; 00013 00014 typedef struct 00015 { 00016 AXES accelerometer; 00017 AXES magnometer; 00018 } READING; 00019 00020 class SingletonFXOS8700CQ 00021 { 00022 private: 00023 00024 SingletonFXOS8700CQ(PinName sda = PTE25, PinName scl = PTE24, int addr = FXOS8700CQ_SLAVE_ADDR1); 00025 SingletonFXOS8700CQ(const SingletonFXOS8700CQ &); 00026 SingletonFXOS8700CQ& operator=(const SingletonFXOS8700CQ&); 00027 00028 FXOS8700CQ fxos; 00029 InterruptIn fxos_int1; // unused, common with SW2 on FRDM-K64F 00030 InterruptIn fxos_int2; // should just be the Data-Ready interrupt 00031 bool fxos_int1_triggered; 00032 bool fxos_int2_triggered; 00033 00034 static void trigger_fxos_int1(void) 00035 { 00036 SingletonFXOS8700CQ::getInstance().setInt1Triggered(true); 00037 } 00038 00039 static void trigger_fxos_int2(void) 00040 { 00041 SingletonFXOS8700CQ::getInstance().setInt2Triggered(true); 00042 //us_ellapsed = t.read_us(); 00043 } 00044 00045 public: 00046 00047 static SingletonFXOS8700CQ& getInstance() 00048 { 00049 static SingletonFXOS8700CQ instance; 00050 00051 return instance; 00052 } 00053 00054 void enable() { fxos.enable(); } 00055 void disable() { fxos.disable(); } 00056 00057 uint8_t getData(READING&); 00058 00059 bool getInt1Triggered() { return fxos_int1_triggered; } 00060 void setInt1Triggered(bool value) { fxos_int1_triggered = value; } 00061 bool getInt2Triggered() { return fxos_int2_triggered; } 00062 void setInt2Triggered(bool value) { fxos_int2_triggered = value; } 00063 uint8_t getWhoAmI() { return fxos.get_whoami(); } 00064 uint8_t getStatus() { return fxos.status(); } 00065 };
Generated on Wed Jul 13 2022 07:19:04 by
1.7.2