Johnson Sun Application / SASD August 2012 Freescale, the Freescale logo, AltiVec, C-5, CodeTEST, CodeWarrior, ColdFire, ColdFire+, C-Ware, the Energy Efficient Solutions logo, Kinetis, mobilegt, PowerQUICC, Processor Expert, QorIQ, Qorivva, StarCore, Symphony and VortiQa are trademarks of Freescale Semiconductor, Inc., Reg. U.S. Pat. & Tm. Off. Airfast, BeeKit, BeeStack, CoreNet, Flexis, MagniV, MXC, Platform in a Package, QorIQ Qonverge, QUICC Engine, Ready Play, SafeAssure, the SafeAssure logo, SMAROS, TurboLink, Vybrid and Xtrinsic are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners. 2012 Freescale Semiconductor, Inc..
Sensor is now becoming a mandatory topic in OS for mobile applications like smart phone, tablet.. This session focuses on sensor requirements from Android and Windows 8 Freescale sensor enablement for OS 2
Know about sensor requirements from Android and Windows 8 OS. Getting familiar with Freescale s sensor portfolio for mobile sensing Learn about Android sensor framework, and Freescale Android sensor driver implementation. Learn about Freescale Xtrinsic 12 axis Windows 8 sensing platform reference design 3
Smartphone OS Market Overview Android and Windows 8 Sensor Requirements Android sensor framework Freescale Android Sensor Support Freescale Windows 8 Sensor Support Demo Q&A 4
Year Win7 Vista Win NT WinXP Linux Mac Mobile 2012Apr 51.3% 4.2% 0.6% 27.3% 4.9% 9.3% 1.5% 2011Apr 35.9% 7.6% 0.9% 40.9% 5.1% 8.3% 0.8% 2010Apr 16.7% 13.2% 1.8% 56.1% 4.5% 7.1% - source: http://www.w3schools.com/browsers/browsers_os.asp Collected from W3Schools' log-files over a period of seven years, long term trends of operating system usage. Windows 7 and Windows XP are the most popular operating systems. The Windows family counts for over 80% Mobile accounts for 2 fold increase. 5
6
Platform Codename API Level Distribution Android 1.5 Cupcake 3 0.3% Android 1.6 Donut 4 0.7% Android 2.1 Eclair 7 5.5% Android 2.2 Froyo 8 20.9% Android 2.3 - Android 2.3.2 Android 2.3.3 - Android 2.3.7 Gingerbread 9 0.5% 10 63.9% Android 3.0 11 0.1% Android 3.1 Honeycomb 12 1.0% Android 3.2 13 2.2% Android 4.0 - Android 4.0.2 Android 4.0.3 - Android 4.0.4 Ice Cream Sandwich 14 0.5% 15 4.4% source: http://developer.android.com/resources/dashboard/platfor m-versions.html 7
8
Android Sensor Android 4.0 (API Level 14) Android 2.3 (API Level 9) Android 2.2 (API Level 8) Android 1.5 (API Level 3) TYPE_ACCELEROMETER Yes Yes Yes Yes Yes TYPE_AMBIENT_TEMPERATURE Yes n/a n/a n/a Yes TYPE_GRAVITY Yes Yes n/a n/a n/a TYPE_GYROSCOPE Yes Yes n/a 1 n/a 1 Yes TYPE_LIGHT Yes Yes Yes Yes Yes TYPE_LINEAR_ACCELERATION Yes Yes n/a n/a Yes TYPE_MAGNETIC_FIELD Yes Yes Yes Yes Yes TYPE_ORIENTATION Yes 2 Yes 2 Yes 2 Yes Yes TYPE_PRESSURE Yes Yes n/a 1 n/a 1 Yes TYPE_PROXIMITY Yes Yes Yes Yes Yes TYPE_RELATIVE_HUMIDITY Yes n/a n/a n/a Yes TYPE_ROTATION_VECTOR Yes Yes n/a n/a Yes Windows 8 equivalent TYPE_TEMPERATURE Yes 2 Yes Yes Yes Not standard 1. This sensor type was added in Adroid 1.5 (API Level 3), but it was not available for use until Android 2.3 (API Level 9) 2. The sensor is available, but it has been deprecated. source: http://developer.android.com/guide/topics/sensors/sensors_overview.html 9
Sensor Type Acceleration With gravity Physical Gravity Magnetic Field Gyroscope Without gravity Physical / Virtual Virtual Virtual Physical Physical Orientation Rotation Matrix Virtual Ambient Temperature Light Pressure Proximity Relative Humidity Quaternion Euler Angles / Inclination Compass heading Virtual Virtual Virtual Physical Physical Physical Physical Physical 10
Android: Compatibility is checked via the Android Compatibility Test Suite (CTS) available at http://source.android.com/compatibility/downloads.html. See http://source.android.com/compatibility/ for more details Windows 8 Microsoft supports a graphical sensor diagnostic tool for verification of sensor data and properties. Information on Windows 8 Hardware Certification Requirements can be found at http://msdn.microsoft.com/enus/library/windows/hardware/hh748200.aspx Additional information is available under NDA from Microsoft 11
Feature Android 4.0.x Android 2.3.3 Android 2.2 / 2.1 / 1.6 Win 8 Slate / Convertible Laptop 3-axis accelerometer 3-axis magnetometer GPS SHOULD have Min sps = 50 sps Min +/- 2g range Min resolution = 8 bits Max std dev = 0.05m/s 2 SHOULD have Min sps = 10 sps Range > earth mag field Min resolution = 8 bits Max std dev = 0.5 T SHOULD have assisted GPS suggested Ditto 4.0.x Ditto 4.0.x MUST include >= 50 sps MUST include a 3-axis Compass >= 10 sps Ditto 4.0.X Ditto 4.0.X Supported REQUIRED Range = +/- 2 g min Range = +/- 8 g optimal 100 sps required 200 sps optimal 350 g / rthz @10Hz 0.5% non-linearity REQUIRED for sensor fusion, not directly accessible +/- 1000 T 0.5 T / rthz @ 8 Hz 0.3 T / LSB desired Min sps = 8 Gyroscope SHOULD have (but only if 3- axis acc is present) Temp compensation required Min Range = 5.5 π rad/sec Min sps = 100 Min resolution = 12 bits Variance <= 10-7 rad 2 /sec 2 /Hz Timestamp required Range >= 5.5π radians/sec >= 100 sps >= 8 bits No mention REQUIRED Range = +/- 720 dps min Range = +/- 2000 dps optimal 0.2% non-linearity Noise: 0.05 dps-rms@100hz Sensitivity scale factor tolerance = +/- 3% at 25C Zero rate offset = +/- 20 dps Recommended sps > 100 12
Feature 4.0.x / 2.3.3 2.2 / 2.1 / 1.6 Windows 8 barometer thermometer photometer (ambient light sensor) proximity sensor MAY have >= 5 sps MUST have adequate precision to enable estimating altitude MAY but SHOULD NOT MUST measure CPU temp only. This sensor type is deprecated in Android 2.3 and 4.0 APIs. No mention Supported Supported Supported MAY include No mention Supported via ACPI MAY include 1 bit accuracy or greater No mention Supported Notes: 1. Tables are based on information in Android Compatibility Definitions for these releases 2. Excepting ambient light sensor, Windows 8 utilizes HID over USB or simple peripheral bus (SPI, I 2 C for sensor support) 3. Windows 8 HID definitions support other sensor types which are not shown (current, power, voltage, switches, etc.) 13
Android Windows 8 Accelerometer output Acceleration Gravity (-1 g) (+9.8m/s 2 ) Axes alignment ENU ENU Accel units m/s 2 g Mag units T integer T fractional Angles standard Left handed Right handed Roll range -90 to 90-90 to 90 Pitch range -180 to 180-180 to 180 Yaw range 0 to 360 0 to 360 Compass heading Yaw Minus Yaw Compass heading change for 180 deg roll 180 deg None Compass heading change for 180 deg pitch None 180 deg 14
Feature Android Windows 8 Sensor Fusion light fusion included in Android Sensor fusion generally provided by sensor vendor or OEM 15
Freescale: Solution Provider 16
ecompass Magnetometers Accelerometers Touch Sensors Gyro Altimeter / Pressure 17
Sensor Type Part Number Accelerometer MMA865x MMA845x MMA7660 Magnetometer MAG3110 FXOS8700 Barometer/Altimeter MPL3115 Touch Sensor MPR121 MPR03x Sensor Hub MMA955x 18
Sensor Part Number Basic Feature Android Driver Full Feature Android Driver MMA845x MMA8450 MMA7660 MAG3110 MPL3115 X MPR031 X MPR121 X MMA955x X 19
Optimized for Freescale sensors Maximized the capabilities of sensor's embedded feature sets Feature Interface through sysfs data event embedded func event configuration and state Interrupt & Poll 20
21
22
Android application: 3D compass SensorManager, sensor JNI Application Layer Sensor Framework Sensor Service/Daemon Sensor HAL Middleware, Libraries Input subsystem Event Dev Device driver Bus driver Linux Kernel Sensor devices: MMA845x Hardware 23
Android sensor main framework Gsensor App Ecompas App Gryo App SensorManager Android Sensor Framework & App SensorService Middle level Sensor HAL Linux kernel Accelerate Magnetic Gyro Pressure 24
Linux kernel Standard Linux kernel, including all bus and hardware drivers and some patches provided by Google for Android mma845x.c mag3110.c Android hardware library(hal) Supply interfaces to access hardware driver, in sensor HAL, it provide some interfaces to enable sensor and read sensor data sensors.default.so Android framework Supply all interfaces for Android application, It supply some java interfaces for Android application, such as interfaces to register sensor and unregistersensor. SensorManager, SenosrService Android Application (APK) You can download other android apk from Android Market Eyes.apk Mcompass.apk, 25
Android apk and framework Gsensor APP Ecompass APP Gryo App register Gsensor type Polling time Gsensor data SensorManager thread Enable sensor SetDelay Poll all sensors All sensor data SensorService 26
Android HAL SensorService Enable setdelay poll Sensor HAL Android Middle layer Enable setdelay poll data Linux kernel driver Accelerate Magnetic Gyro Pressure 27
Android sensor HAL must fulfill three interfaces enable enable/disable a type of sensor setdelay set the delay time interval to report data Note : It means how much time delay to get the next data poll read all sensor data from kernel driver 28
How android apk calls Android sensor interfaces Define a class implement SensorEventListener public class MySensorClass implements SensorEventListener { } public void onsensorchanged(sensorevent event) { } public void onaccuracychanged(sensor sensor, int accuracy) { } Note: in the SensorEventListener, there are two interfaces, one is onsensorchange and the other is onaccarcychanged onsensorchanged is Called when sensor values have changed. you can do any sensor processor here. onaccuracychanged is called when the accuracy of a sensor has changed, sometimes, we do noting here. 29
How android apk calls Android sensor interfaces Get the type of sensor msensormanager = (SensorManager)getSystemService(SENSOR_SERVICE) msensor = msensormanager.getdefaultsensor(type); mysensor = new MySensorClass(); Note: Firstly, we get a SensorManager object by getsystemservice, then get the type of sensor by SensorManager interfaces getdefaultsensor, 30
How android apk calls Android sensor interfaces Register sensor msensormanager.registerlistener(mysensor, msensor, rate) Unregister sensor msensormanager.unregisterlistener(mysensor) NOTE: when you want to use the type of sensor in your apk, please register the type of sensor, and use unregister to disable the type of sensor 31
registerlistener parameters mysensor a object which implement SensorEventListener msensor which type of sensor to use, call getdefaultsensor(type) to get TYPE_ACCELEROMETER //gsensor TYPE_MAGNETIC_FIELD //magnetic sensor TYPE_ORIENTATION //orienation sensor TYPE_PRESSURE //pressure sensor.. rate time interval to report data SENSOR_DELAY_FAST SENSOR_DELAY_GAME SENSOR_DELAY_NORMAL SENSOR_DELAY_UI 32
MMA845X and MAG3110 Android application & framework read all sensor data magd Android sensor hal read acc raw data read mag raw data write calibrated data report mag calibrated data and Orientation data report acc raw data Linux kernel Freescale magnetometer poll input device ecompass event device Freescale accelerometer poll input device Mag3110 driver MMA845X driver 33
Environment Hardward i.mx53 qsb board, MMA845x and MAG3110 sensors Software Android source code i.mx53-qsb-android-gingerbread-release4.2 Freescale sensor driver package FSL_mma845x_mma7660_mag3110_mpl3115_Android_v2.0.tar.gz debug tools adb a tool running on pc to let you communicate with Android device dmesg a linux shell command to print kernel log 34
i.mx53-qsb-android-gingerbread-release4.2 - src The source code of i.mx 53 qsb Android2.3 scripts Some linux shell to compile source code and download images to i.mx53 qsb doc Some user guide document out The image output directory 35
FSL_mma845x_mma7660_mag3110_mpl3115_Android_v2.0 app Some Android sensor application driver linux kernel drivers source code of Freescale sensors libsensors Freescale sensor Andorid HAL source code magd MAG3110 calibration source code 36
Freescale sensors Linux kernel driver porting Sensors body frame to OS frame change: set sensor position value according to the porting guide manual Check kernel log print, use adb shell dmesg Use getevent or evtest to check to sensor data reported form kernel Freescale Android sensor HAL and magd daemon porting Add LOGD in source code Use logcat to check Android log print Use magd arguments to print out raw data and calibrated data, calibration status threshold 37
Test complete porting by using application APK Use Eyes.apk to check accelerometer reading Put the device 6 faces aligned with facing horizontal desktop, check accel X/Y/Z reading will be around +/-9.8 Calibrate first magneto reading by 8 figure calibration. After calibration, check the Orientation status is at 3 and Orientation X will change along the device heading. check mag X/Y/Z reading is below 70 ut. 38
To see magneto ecompass reading visually, use mcompass.apk Rotate the device to check the ecompass Heading Keep the ecompass fixed heading and tilt the device, check if the heading value keep same or changes only a little 39
Freescale Xtrinsic Sensor Platform for Windows 8 Xtrinsic sensor fusion in tablets, slates, convertible/non-convertible laptops and other portable devices 40
Freescale Window 8 Sensor Fusion Platform Features & Benefits Features MCU + Sensor Breadth Benefits Fully integrated solution 12-Axis Solution Helps differentiate customers Sensor Fusion Code Essential to the Windows 8 solution Ease of Integration Streamlines development Low-Power Conducive for portable devices 41
Freescale s parts: MMA8451Q 3-axis accelerometer MAG3110 3-axis magnetometer MPL3115A2 precision altimeter ColdFire+ MCF51JU128VHS MCU (New ColdFire+ cores) Other parts: Ambient light sensor Gyroscope 12-axis solution with IMU plus 2 more axes with the ambient light sensor and temperature 42
First phase design uses USB connectivity Hardware includes: Accelerometer Magnetometer Gyro Altitude Touch Ambient Light Sensor Sensor Fusion provides Gyro trim Compass heading Orientation / Rotation In development: Magnetic anomaly handling Power reduction I2C interface 43
44
Host Processor Windows8 USB HID I2C HID ColdFire+ MCF51JU128 Microcontroller 128 K Flash 32 K RAM Analog Control Ambient Light Sensor I2C & Interrupts Xtrinsic Accelerometer MMA8451Q Xtrinsic Magnetometer MAG3110 Xtrinsic Barometer/ Thermometer MPL3115A2 Gyro Freescale Technology Learn more at www/freescale.com/windows8 45
Physical Devices Ambient Light Barometer Thermometer 3D Accelerometer 3D Gyroscope 3D Magnetometer Firmware Processing Pass-Through and Calibration Calibration Sensor Fusion Windows Sensors Ambient Light Barometer Thermometer Accelerometer Gyrometer Compass Inclinometer Orientation 46
Green = 3rd Party Black = HW + Firmware Metro style app Win32 app UMDF/KMDF Sensor Driver (3rd Party) Sensor Hardware (non-hid) Sensor Hardware (HID) Microcontroller Accelerometer Magnetometer Gyroscope.. 47
HID sensor class driver Buses supported = USB, I 2 C Sensors supported = light, motion, presence Built on industry standard USB-IF, HID protocol Save development time USB/HID Plug and Play benefits 48
Windows Hardware Certification Kit (WHCK) entails the following: Windows 8 sensor test criteria for passing Tests ensure hardware/software compatibility Outcome: Windows 8 device manager compatibility Standard driver download is added to Microsoft s database Freescale status: Freescale passed all the tests in WHCK (July/12) Learn more at http://www.microsoft.com/windows 49
50
Android and Windows 8 OS mandatory requirements on sensors Freescale sensor portfolio for mobile sensing Freescale complete sensor HW/SW solution including both advanced sensor chips, sensor drivers, reference design platform. Visit Freescale sensor website www.freescale.com/sensors Further questions contact: Johnson.sun@freescale.com +86 21-28937311 +86 13918668532 Freescale on Kaixin Tag yourself in photos and upload your own! Weibo? Please use hashtag #FTF2012# Session materials will be posted @ www.freescale.com/ftf 51