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.
main.cpp@3:9eae869bdf8e, 2016-03-23 (annotated)
- Committer:
- AswinSivakumar
- Date:
- Wed Mar 23 05:36:14 2016 +0000
- Revision:
- 3:9eae869bdf8e
- Parent:
- 1:d8ca07afb3ec
- Child:
- 4:87df61d02921
Initial commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| AswinSivakumar | 0:6b858a805a38 | 1 | /* Copyright (c) 2015 NXP Semiconductors. MIT License |
| AswinSivakumar | 0:6b858a805a38 | 2 | * |
| AswinSivakumar | 0:6b858a805a38 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
| AswinSivakumar | 0:6b858a805a38 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
| AswinSivakumar | 0:6b858a805a38 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
| AswinSivakumar | 0:6b858a805a38 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
| AswinSivakumar | 0:6b858a805a38 | 7 | * Software is furnished to do so, subject to the following conditions: |
| AswinSivakumar | 0:6b858a805a38 | 8 | * |
| AswinSivakumar | 0:6b858a805a38 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
| AswinSivakumar | 0:6b858a805a38 | 10 | * substantial portions of the Software. |
| AswinSivakumar | 0:6b858a805a38 | 11 | * |
| AswinSivakumar | 0:6b858a805a38 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
| AswinSivakumar | 0:6b858a805a38 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| AswinSivakumar | 0:6b858a805a38 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| AswinSivakumar | 0:6b858a805a38 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| AswinSivakumar | 0:6b858a805a38 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| AswinSivakumar | 0:6b858a805a38 | 17 | */ |
| AswinSivakumar | 3:9eae869bdf8e | 18 | #include "FXLS8471.h" |
| AswinSivakumar | 0:6b858a805a38 | 19 | #include "mbed.h" |
| AswinSivakumar | 0:6b858a805a38 | 20 | |
| AswinSivakumar | 0:6b858a805a38 | 21 | // Initialize Serial port |
| AswinSivakumar | 0:6b858a805a38 | 22 | Serial pc(USBTX, USBRX); |
| AswinSivakumar | 0:6b858a805a38 | 23 | |
| AswinSivakumar | 0:6b858a805a38 | 24 | // Initialize pins for I2C communication for sensors. Set jumpers J6,J7 in FRDM-STBC-AGM01 board accordingly. |
| AswinSivakumar | 3:9eae869bdf8e | 25 | FXLS8471 accel(D11, D12, D13, D10); |
| AswinSivakumar | 3:9eae869bdf8e | 26 | |
| AswinSivakumar | 0:6b858a805a38 | 27 | |
| AswinSivakumar | 1:d8ca07afb3ec | 28 | |
| AswinSivakumar | 1:d8ca07afb3ec | 29 | |
| AswinSivakumar | 0:6b858a805a38 | 30 | int main() |
| AswinSivakumar | 0:6b858a805a38 | 31 | { |
| AswinSivakumar | 1:d8ca07afb3ec | 32 | |
| AswinSivakumar | 1:d8ca07afb3ec | 33 | // Configure Accelerometer FXOS8700, Magnetometer FXOS8700 & Gyroscope FXAS21002 |
| AswinSivakumar | 3:9eae869bdf8e | 34 | accel.FXLS8471_config(); |
| AswinSivakumar | 3:9eae869bdf8e | 35 | |
| AswinSivakumar | 1:d8ca07afb3ec | 36 | |
| AswinSivakumar | 0:6b858a805a38 | 37 | float accel_data[3]; float accel_rms=0.0; |
| AswinSivakumar | 3:9eae869bdf8e | 38 | |
| AswinSivakumar | 1:d8ca07afb3ec | 39 | printf("Begin Data Acquisition....\r\n\r\n"); |
| AswinSivakumar | 0:6b858a805a38 | 40 | wait(0.5); |
| AswinSivakumar | 0:6b858a805a38 | 41 | |
| AswinSivakumar | 0:6b858a805a38 | 42 | while(1) |
| AswinSivakumar | 0:6b858a805a38 | 43 | { |
| AswinSivakumar | 3:9eae869bdf8e | 44 | accel.acquire_FXLS8471_data_g(accel_data); |
| AswinSivakumar | 0:6b858a805a38 | 45 | accel_rms = sqrt(((accel_data[0]*accel_data[0])+(accel_data[1]*accel_data[1])+(accel_data[2]*accel_data[2]))/3); |
| AswinSivakumar | 1:d8ca07afb3ec | 46 | printf("%4.2f,%4.2f,%4.2f,\t",accel_data[0],accel_data[1],accel_data[2]); |
| AswinSivakumar | 0:6b858a805a38 | 47 | wait(0.005); |
| AswinSivakumar | 3:9eae869bdf8e | 48 | |
| AswinSivakumar | 1:d8ca07afb3ec | 49 | printf("\n\r"); |
| AswinSivakumar | 1:d8ca07afb3ec | 50 | |
| AswinSivakumar | 1:d8ca07afb3ec | 51 | |
| AswinSivakumar | 0:6b858a805a38 | 52 | } |
| AswinSivakumar | 0:6b858a805a38 | 53 | |
| AswinSivakumar | 0:6b858a805a38 | 54 | } |
NXP FRDMSTBC-A8471