The MGC3130 is the world’s first electrical-field (E-field) based three-dimensional (3D) tracking and gesture controller

Dependencies:   BufferedArray

Dependents:   NucleoMGC3130 i2c_master

Committer:
yangcq88517
Date:
Thu Oct 08 11:14:18 2015 +0000
Revision:
2:c7d984193741
Parent:
1:621c4e9238ef
Child:
3:b657bfcffc0a
add some documentation

Who changed what in which revision?

UserRevisionLine numberNew 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 0:92f17b057d6b 13
yangcq88517 2:c7d984193741 14 /**
yangcq88517 2:c7d984193741 15 * 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 16 */
yangcq88517 0:92f17b057d6b 17 class MGC3130
yangcq88517 0:92f17b057d6b 18 {
yangcq88517 0:92f17b057d6b 19 private:
yangcq88517 0:92f17b057d6b 20 static const int FREQUENCY_STANDARD = 100000;
yangcq88517 0:92f17b057d6b 21 static const int FREQUENCY_FULL = 400000;
yangcq88517 0:92f17b057d6b 22 static const int FREQUENCY_FAST = 1000000;
yangcq88517 0:92f17b057d6b 23 static const int FREQUENCY_HIGH = 3200000;
yangcq88517 0:92f17b057d6b 24
yangcq88517 2:c7d984193741 25 /// 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 26 DigitalInOut TS_Line;
yangcq88517 0:92f17b057d6b 27
yangcq88517 0:92f17b057d6b 28 I2C _i2c_bus;
yangcq88517 0:92f17b057d6b 29 int _speed;
yangcq88517 0:92f17b057d6b 30 int _addr;
yangcq88517 0:92f17b057d6b 31 GestICMsg msg;
yangcq88517 0:92f17b057d6b 32 SensorData sensor;
yangcq88517 0:92f17b057d6b 33
yangcq88517 1:621c4e9238ef 34 protected:
yangcq88517 1:621c4e9238ef 35 GestICMsg * readMsg();
yangcq88517 1:621c4e9238ef 36
yangcq88517 0:92f17b057d6b 37 public:
yangcq88517 2:c7d984193741 38 /** Construct a message with existing @GestICMsg as its base.
yangcq88517 2:c7d984193741 39 * 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 40 * The MGC3X30 I2C addresses are 0x42 and 0x43. They are given as device addresses without the R/W bit.
yangcq88517 2:c7d984193741 41 * In addition, MGC3X30 requires a dedicated transfer status line (TS), which features a
yangcq88517 2:c7d984193741 42 * data transfer status function. The TS is used by both I2C Master and Slave to control
yangcq88517 2:c7d984193741 43 * the data flow. I2C SCL, I2C SDA and TS lines require an open-drain connection on
yangcq88517 2:c7d984193741 44 * MGC3X30 and the connected host controller. To function properly, I2C SCL and I2C
yangcq88517 2:c7d984193741 45 * SDA need to be pulled up to VCC with 1.8 kΩ resistors and the TS line needs to be
yangcq88517 2:c7d984193741 46 * pulled up to VCC with a 10 kΩ resistor.
yangcq88517 2:c7d984193741 47 *
yangcq88517 2:c7d984193741 48 * @param sda I2C sda signal
yangcq88517 2:c7d984193741 49 * @param scl I2C scl signal
yangcq88517 2:c7d984193741 50 * @param ET0
yangcq88517 2:c7d984193741 51 * @param IS2 High->true, Low->false
yangcq88517 2:c7d984193741 52 *
yangcq88517 2:c7d984193741 53 */
yangcq88517 0:92f17b057d6b 54 MGC3130(PinName sda, PinName scl, PinName EI0, bool IS2);
yangcq88517 0:92f17b057d6b 55
yangcq88517 2:c7d984193741 56 /** Get a sensor data payload from the device, will block if the device is busy.
yangcq88517 2:c7d984193741 57 *
yangcq88517 2:c7d984193741 58 * @returns @SensorData NULL means data not avaliable
yangcq88517 2:c7d984193741 59 *
yangcq88517 2:c7d984193741 60 */
yangcq88517 0:92f17b057d6b 61 SensorData * readSensorData();
yangcq88517 1:621c4e9238ef 62
yangcq88517 2:c7d984193741 63 /** Set the system runtime parameters.
yangcq88517 2:c7d984193741 64 *
yangcq88517 2:c7d984193741 65 * @param para @Parameter and any RuntimeParameter classes
yangcq88517 2:c7d984193741 66 *
yangcq88517 2:c7d984193741 67 * @returns
yangcq88517 2:c7d984193741 68 *0x0000 NoError OK
yangcq88517 2:c7d984193741 69 *0x0001 UnknownCommand Message ID is unknown
yangcq88517 2:c7d984193741 70 *0x0002 InvalidSessionId Session ID is invalid or does not match (0x0 is not allowed) (message Fw_Update_Start, Fw_Update_Completed)
yangcq88517 2:c7d984193741 71 *0x003 InvalidCrc CRC is invalid thrown by messages: Fw_Update_Block, Fw_Update_Start, Fw_Update_Completed
yangcq88517 2:c7d984193741 72 *0x0004 InvalidLength Length is invalid (message Fw_Update_Block)
yangcq88517 2:c7d984193741 73 *0x0005 InvalidAddress Address is invalid (message Fw_Update_Block)
yangcq88517 2:c7d984193741 74 *0x0006 InvalidFunction Function-Id is invalid (message Fw_Update_Start, Fw_Update_Block, Fw_Update_Completed)
yangcq88517 2:c7d984193741 75 *0x0008 ContentMismatch The VerifyOnly function found a mismatch between content and Flash memory (message: Fw_Update_Block)
yangcq88517 2:c7d984193741 76 *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 77 *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 78 *0x0015 UnknownParameterID The MessageID or RuntimeParameterID is unknown or out of the valid range (message: Request_Message and Set_Runtime_Parameter)
yangcq88517 2:c7d984193741 79 *0x001A WakeupHappend A wake-up by Host was detected
yangcq88517 2:c7d984193741 80 *0x0080 LoaderUpdateStarted The Library Loader update started
yangcq88517 2:c7d984193741 81 *0x0081 LoaderUpdateFinished The Library Loader update finished
yangcq88517 1:621c4e9238ef 82 */
yangcq88517 1:621c4e9238ef 83 int setRuntimeParameter(Parameter * para);
yangcq88517 0:92f17b057d6b 84 };
yangcq88517 0:92f17b057d6b 85
yangcq88517 0:92f17b057d6b 86 #endif