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.
Fork of ReferredCoursework2016 by
sensor.cpp
00001 /*sensor.cpp simply reads in the acceleration measurements 00002 using the NUCLEO board and using the function and struct 00003 from buffer.cpp, stores the values in to the circular buffer*/ 00004 #include "mbed.h" 00005 #include "x_nucleo_iks01a1.h" 00006 #include "buffer.h" 00007 #include "sensor.h" 00008 00009 Mutex mutex; 00010 00011 /* Instantiate the expansion board */ 00012 static X_NUCLEO_IKS01A1 *mems_expansion_board = X_NUCLEO_IKS01A1::Instance(D14, D15); 00013 00014 /* Retrieve the composing elements of the expansion board */ 00015 static MotionSensor *accelerometer = mems_expansion_board->GetAccelerometer(); 00016 00017 extern char *printDouble(char* str, double v, int decimalDigits = 2); 00018 00019 int32_t axes[3]; 00020 00021 void sensor_run(){ 00022 while (1) { 00023 mutex.lock(); 00024 00025 accelerometer->Get_X_Axes(axes); 00026 00027 AccelData d; 00028 d.x = axes[0]; 00029 d.y = axes[1]; 00030 d.z = axes[2]; 00031 00032 log_push(d); 00033 mutex.unlock(); 00034 } 00035 00036 }
Generated on Sat Jul 16 2022 05:47:21 by
