The MGC3130 is the world’s first electrical-field (E-field) based three-dimensional (3D) tracking and gesture controller
Dependents: NucleoMGC3130 i2c_master
MGC3130.h@3:b657bfcffc0a, 2015-10-08 (annotated)
- Committer:
- yangcq88517
- Date:
- Thu Oct 08 17:37:33 2015 +0000
- Revision:
- 3:b657bfcffc0a
- Parent:
- 2:c7d984193741
- Child:
- 6:b511421e7dc8
bug fix, add some runtime message
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yangcq88517 | 0:92f17b057d6b | 1 | #ifndef UK_AC_HERTS_SMARTLAB_MGC3130 |
yangcq88517 | 0:92f17b057d6b | 2 | #define UK_AC_HERTS_SMARTLAB_MGC3130 |
yangcq88517 | 0:92f17b057d6b | 3 | |
yangcq88517 | 0:92f17b057d6b | 4 | #include "mbed.h" |
yangcq88517 | 0:92f17b057d6b | 5 | #include "GestICMsg.h" |
yangcq88517 | 0:92f17b057d6b | 6 | #include "SensorData.h" |
yangcq88517 | 1:621c4e9238ef | 7 | #include "Parameter.h" |
yangcq88517 | 1:621c4e9238ef | 8 | #include "TouchDetection.h" |
yangcq88517 | 1:621c4e9238ef | 9 | #include "AirWheelDetection.h" |
yangcq88517 | 1:621c4e9238ef | 10 | #include "ApproachDetection.h" |
yangcq88517 | 1:621c4e9238ef | 11 | #include "TouchInfo.h" |
yangcq88517 | 1:621c4e9238ef | 12 | #include "OutputEnable.h" |
yangcq88517 | 3:b657bfcffc0a | 13 | #include "Trigger.h" |
yangcq88517 | 3:b657bfcffc0a | 14 | #include "MakePersistent.h" |
yangcq88517 | 3:b657bfcffc0a | 15 | #include "CalibrationMode.h" |
yangcq88517 | 3:b657bfcffc0a | 16 | #include "GestureProcessing.h" |
yangcq88517 | 0:92f17b057d6b | 17 | |
yangcq88517 | 2:c7d984193741 | 18 | /** |
yangcq88517 | 2:c7d984193741 | 19 | * Outlines the function of the Library’s I2C message interface, and contains the complete message reference to control and operate the MGC3X30 system. |
yangcq88517 | 2:c7d984193741 | 20 | */ |
yangcq88517 | 0:92f17b057d6b | 21 | class MGC3130 |
yangcq88517 | 0:92f17b057d6b | 22 | { |
yangcq88517 | 0:92f17b057d6b | 23 | private: |
yangcq88517 | 0:92f17b057d6b | 24 | static const int FREQUENCY_STANDARD = 100000; |
yangcq88517 | 0:92f17b057d6b | 25 | static const int FREQUENCY_FULL = 400000; |
yangcq88517 | 0:92f17b057d6b | 26 | static const int FREQUENCY_FAST = 1000000; |
yangcq88517 | 0:92f17b057d6b | 27 | static const int FREQUENCY_HIGH = 3200000; |
yangcq88517 | 0:92f17b057d6b | 28 | |
yangcq88517 | 2:c7d984193741 | 29 | /// EI0 Pin: The TS line is used to check whether the I2C data is valid and can be sent from MGC3X30 to the host controller. |
yangcq88517 | 0:92f17b057d6b | 30 | DigitalInOut TS_Line; |
yangcq88517 | 0:92f17b057d6b | 31 | |
yangcq88517 | 0:92f17b057d6b | 32 | I2C _i2c_bus; |
yangcq88517 | 0:92f17b057d6b | 33 | int _speed; |
yangcq88517 | 0:92f17b057d6b | 34 | int _addr; |
yangcq88517 | 0:92f17b057d6b | 35 | GestICMsg msg; |
yangcq88517 | 0:92f17b057d6b | 36 | SensorData sensor; |
yangcq88517 | 0:92f17b057d6b | 37 | |
yangcq88517 | 1:621c4e9238ef | 38 | protected: |
yangcq88517 | 1:621c4e9238ef | 39 | GestICMsg * readMsg(); |
yangcq88517 | 1:621c4e9238ef | 40 | |
yangcq88517 | 0:92f17b057d6b | 41 | public: |
yangcq88517 | 2:c7d984193741 | 42 | /** Construct a message with existing @GestICMsg as its base. |
yangcq88517 | 2:c7d984193741 | 43 | * IS2 is available for address selection and enables the user to connect up to two MGC3X30 devices on the same bus without address conflict. |
yangcq88517 | 2:c7d984193741 | 44 | * The MGC3X30 I2C addresses are 0x42 and 0x43. They are given as device addresses without the R/W bit. |
yangcq88517 | 2:c7d984193741 | 45 | * In addition, MGC3X30 requires a dedicated transfer status line (TS), which features a |
yangcq88517 | 2:c7d984193741 | 46 | * data transfer status function. The TS is used by both I2C Master and Slave to control |
yangcq88517 | 2:c7d984193741 | 47 | * the data flow. I2C SCL, I2C SDA and TS lines require an open-drain connection on |
yangcq88517 | 2:c7d984193741 | 48 | * MGC3X30 and the connected host controller. To function properly, I2C SCL and I2C |
yangcq88517 | 2:c7d984193741 | 49 | * SDA need to be pulled up to VCC with 1.8 kΩ resistors and the TS line needs to be |
yangcq88517 | 2:c7d984193741 | 50 | * pulled up to VCC with a 10 kΩ resistor. |
yangcq88517 | 2:c7d984193741 | 51 | * |
yangcq88517 | 2:c7d984193741 | 52 | * @param sda I2C sda signal |
yangcq88517 | 2:c7d984193741 | 53 | * @param scl I2C scl signal |
yangcq88517 | 3:b657bfcffc0a | 54 | * @param EI0 transfer status line |
yangcq88517 | 2:c7d984193741 | 55 | * @param IS2 High->true, Low->false |
yangcq88517 | 2:c7d984193741 | 56 | * |
yangcq88517 | 2:c7d984193741 | 57 | */ |
yangcq88517 | 0:92f17b057d6b | 58 | MGC3130(PinName sda, PinName scl, PinName EI0, bool IS2); |
yangcq88517 | 0:92f17b057d6b | 59 | |
yangcq88517 | 2:c7d984193741 | 60 | /** Get a sensor data payload from the device, will block if the device is busy. |
yangcq88517 | 2:c7d984193741 | 61 | * |
yangcq88517 | 2:c7d984193741 | 62 | * @returns @SensorData NULL means data not avaliable |
yangcq88517 | 2:c7d984193741 | 63 | * |
yangcq88517 | 2:c7d984193741 | 64 | */ |
yangcq88517 | 0:92f17b057d6b | 65 | SensorData * readSensorData(); |
yangcq88517 | 1:621c4e9238ef | 66 | |
yangcq88517 | 2:c7d984193741 | 67 | /** Set the system runtime parameters. |
yangcq88517 | 2:c7d984193741 | 68 | * |
yangcq88517 | 2:c7d984193741 | 69 | * @param para @Parameter and any RuntimeParameter classes |
yangcq88517 | 2:c7d984193741 | 70 | * |
yangcq88517 | 2:c7d984193741 | 71 | * @returns |
yangcq88517 | 2:c7d984193741 | 72 | *0x0000 NoError OK |
yangcq88517 | 2:c7d984193741 | 73 | *0x0001 UnknownCommand Message ID is unknown |
yangcq88517 | 2:c7d984193741 | 74 | *0x0002 InvalidSessionId Session ID is invalid or does not match (0x0 is not allowed) (message Fw_Update_Start, Fw_Update_Completed) |
yangcq88517 | 3:b657bfcffc0a | 75 | *0x0003 InvalidCrc CRC is invalid thrown by messages: Fw_Update_Block, Fw_Update_Start, Fw_Update_Completed |
yangcq88517 | 2:c7d984193741 | 76 | *0x0004 InvalidLength Length is invalid (message Fw_Update_Block) |
yangcq88517 | 2:c7d984193741 | 77 | *0x0005 InvalidAddress Address is invalid (message Fw_Update_Block) |
yangcq88517 | 2:c7d984193741 | 78 | *0x0006 InvalidFunction Function-Id is invalid (message Fw_Update_Start, Fw_Update_Block, Fw_Update_Completed) |
yangcq88517 | 2:c7d984193741 | 79 | *0x0008 ContentMismatch The VerifyOnly function found a mismatch between content and Flash memory (message: Fw_Update_Block) |
yangcq88517 | 2:c7d984193741 | 80 | *0x000B WrongParameterAddr Parameter Start address, contained in the new Library FW to be loaded, does not match Library Loader assumption. The Library Update is therefore aborted. (message: Fw_Update_Start) |
yangcq88517 | 2:c7d984193741 | 81 | *0x0014 WrongParameterValue The value of the Argument/Parameter of a RuntimeParameter command is out of the valid range (message: Request_Message and Set_Runtime_Parameter) |
yangcq88517 | 2:c7d984193741 | 82 | *0x0015 UnknownParameterID The MessageID or RuntimeParameterID is unknown or out of the valid range (message: Request_Message and Set_Runtime_Parameter) |
yangcq88517 | 2:c7d984193741 | 83 | *0x001A WakeupHappend A wake-up by Host was detected |
yangcq88517 | 2:c7d984193741 | 84 | *0x0080 LoaderUpdateStarted The Library Loader update started |
yangcq88517 | 2:c7d984193741 | 85 | *0x0081 LoaderUpdateFinished The Library Loader update finished |
yangcq88517 | 1:621c4e9238ef | 86 | */ |
yangcq88517 | 1:621c4e9238ef | 87 | int setRuntimeParameter(Parameter * para); |
yangcq88517 | 0:92f17b057d6b | 88 | }; |
yangcq88517 | 0:92f17b057d6b | 89 | |
yangcq88517 | 0:92f17b057d6b | 90 | #endif |