├── external ├── Docs │ └── README.txt ├── Drivers │ └── Sensor │ │ └── Bosch-Sensortec │ │ ├── README.txt │ │ ├── bma2x2.c │ │ └── bma2x2.h ├── RTOS │ └── RTX │ │ └── lib │ │ ├── RTX_CM3.lib │ │ ├── RTX_CM4F.lib │ │ ├── RTX_CM3_PROF.lib │ │ └── RTX_CM4F_PROF.lib └── MCU │ ├── NXP-5410x │ ├── CSLib │ │ ├── Inc │ │ │ ├── pll_5410x.h │ │ │ ├── fpu_init.h │ │ │ ├── cmsis.h │ │ │ ├── rtc_ut.h │ │ │ ├── romapi_5410x.h │ │ │ └── pdm_api.h │ │ └── Libs │ │ │ ├── keil_lib_power.lib │ │ │ └── lib_chip_5410x.lib │ └── Retarget │ │ └── Retarget.c │ └── STM32F1-CM3 │ └── Retarget │ └── Retarget.c ├── embedded ├── docs │ └── README.txt ├── common │ ├── app │ │ ├── app_msgdef.h │ │ ├── hw_setup.h │ │ └── appmsgstruct.h │ ├── asf │ │ ├── asf_msgdef.h │ │ ├── asf_taskdeftype.h │ │ ├── asf_tqenum.h │ │ ├── asf_tdefmacros.h │ │ ├── asf_types.h │ │ ├── asf_tasks.h │ │ └── asf_taskstruct.h │ ├── hostinterface │ │ ├── ConfigManager.c │ │ ├── ConfigManager.h │ │ ├── BatchManager.h │ │ └── BlockMemory.h │ ├── templates │ │ ├── __SourceFile.h │ │ └── __SourceFile.c │ ├── modules │ │ ├── sensor-drivers │ │ │ ├── acc_bmc150_i2c.h │ │ │ ├── mag_bmc150_i2c.h │ │ │ ├── gyro_bmg160_i2c.h │ │ │ ├── Bosch_I2C_Adapter.h │ │ │ ├── mag_common.h │ │ │ ├── acc_common.h │ │ │ └── gyro_common.h │ │ └── bus-drivers │ │ │ └── i2c_driver.h │ └── alg │ │ ├── significantmotiondetector.h │ │ ├── stepdetector.h │ │ ├── osp-alg-types.h │ │ └── signalgenerator.h └── projects │ ├── SH-Xpresso-LPC54102 │ ├── sources │ │ ├── app │ │ │ ├── algorithm_t.c │ │ │ ├── hostif_i2c.h │ │ │ ├── appversion.h │ │ │ ├── app_tasks.h │ │ │ └── taskinit_user.c │ │ └── boardsupport │ │ │ └── SPI_SlaveDriver.h │ └── keil-mdk-build │ │ ├── preBuildCmd.bat │ │ └── Jenkins_Build.bat │ ├── osp-steval-mki109v2 │ └── sources │ │ ├── app │ │ ├── algorithm_t.c │ │ ├── appversion.h │ │ └── app_tasks.h │ │ ├── config │ │ └── stm32f10x_conf.h │ │ └── boardsupport │ │ └── stm32f10x_it.h │ └── step-example │ ├── example_platform_interface.h │ └── CMakeLists.txt ├── docs ├── images │ ├── osp_logo.png │ ├── osp_framework.png │ ├── osp_hub_framework.png │ └── osp_android_framework.png ├── Host Inteface Protocol Specification.pdf ├── osp-footer.html └── osp-api-docs.h ├── algorithm └── osp │ ├── lib │ └── osp_algs_CM3.lib │ ├── step.h │ ├── sigmot.h │ ├── tilt.h │ ├── ecompass.h │ ├── Makefile │ ├── rotvec.h │ ├── gravity_lin.h │ ├── sigmot.c │ ├── osp.h │ ├── lpf.h │ ├── fp_sensor.h │ ├── OSP_interface.c │ ├── fp_trig.c │ ├── gravity_lin.c │ ├── fp_atan2.c │ ├── fp_sqrt.c │ ├── fpsup.h │ ├── tilt.c │ ├── step.c │ ├── rotvec_precise.c │ ├── SecondOrderLPF.c │ ├── include │ └── osp-alg-types.h │ ├── rotvec.c │ └── ecompass.c ├── .gitignore ├── linux └── sensorhubd │ ├── README.md │ ├── CMakeLists.txt │ ├── uinpututils.h │ ├── osp_debuglogging.h │ ├── osp_remoteprocedurecalls.h │ ├── osp_names.h │ ├── osp_datatypes.h │ ├── virtualsensordevicemanager.h │ └── osp_relayinterface.h ├── README.md ├── scripts └── generateVersionDotH.py └── include └── osp-version.h /external/Docs/README.txt: -------------------------------------------------------------------------------- 1 | This folder should only contain documents/datasheets provided by thirdparty sources. -------------------------------------------------------------------------------- /embedded/docs/README.txt: -------------------------------------------------------------------------------- 1 | This folder should contain documentation related to the open source projects and software -------------------------------------------------------------------------------- /external/Drivers/Sensor/Bosch-Sensortec/README.txt: -------------------------------------------------------------------------------- 1 | For latest drivers refer to: https://github.com/BoschSensortec -------------------------------------------------------------------------------- /docs/images/osp_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/docs/images/osp_logo.png -------------------------------------------------------------------------------- /docs/images/osp_framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/docs/images/osp_framework.png -------------------------------------------------------------------------------- /docs/images/osp_hub_framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/docs/images/osp_hub_framework.png -------------------------------------------------------------------------------- /embedded/common/app/app_msgdef.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/embedded/common/app/app_msgdef.h -------------------------------------------------------------------------------- /embedded/common/asf/asf_msgdef.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/embedded/common/asf/asf_msgdef.h -------------------------------------------------------------------------------- /external/RTOS/RTX/lib/RTX_CM3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/external/RTOS/RTX/lib/RTX_CM3.lib -------------------------------------------------------------------------------- /algorithm/osp/lib/osp_algs_CM3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/algorithm/osp/lib/osp_algs_CM3.lib -------------------------------------------------------------------------------- /external/RTOS/RTX/lib/RTX_CM4F.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/external/RTOS/RTX/lib/RTX_CM4F.lib -------------------------------------------------------------------------------- /docs/images/osp_android_framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/docs/images/osp_android_framework.png -------------------------------------------------------------------------------- /external/RTOS/RTX/lib/RTX_CM3_PROF.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/external/RTOS/RTX/lib/RTX_CM3_PROF.lib -------------------------------------------------------------------------------- /external/RTOS/RTX/lib/RTX_CM4F_PROF.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/external/RTOS/RTX/lib/RTX_CM4F_PROF.lib -------------------------------------------------------------------------------- /docs/Host Inteface Protocol Specification.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/docs/Host Inteface Protocol Specification.pdf -------------------------------------------------------------------------------- /embedded/common/hostinterface/ConfigManager.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/embedded/common/hostinterface/ConfigManager.c -------------------------------------------------------------------------------- /external/MCU/NXP-5410x/CSLib/Inc/pll_5410x.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/external/MCU/NXP-5410x/CSLib/Inc/pll_5410x.h -------------------------------------------------------------------------------- /external/Drivers/Sensor/Bosch-Sensortec/bma2x2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/external/Drivers/Sensor/Bosch-Sensortec/bma2x2.c -------------------------------------------------------------------------------- /external/Drivers/Sensor/Bosch-Sensortec/bma2x2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/external/Drivers/Sensor/Bosch-Sensortec/bma2x2.h -------------------------------------------------------------------------------- /algorithm/osp/step.h: -------------------------------------------------------------------------------- 1 | #ifndef _STEP_H_ 2 | #define _STEP_H_ 3 | 4 | void OSP_step_process(struct ThreeAxis *, struct StepInfo *); 5 | void OSP_step_init(void); 6 | #endif 7 | -------------------------------------------------------------------------------- /external/MCU/NXP-5410x/CSLib/Libs/keil_lib_power.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/external/MCU/NXP-5410x/CSLib/Libs/keil_lib_power.lib -------------------------------------------------------------------------------- /external/MCU/NXP-5410x/CSLib/Libs/lib_chip_5410x.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/external/MCU/NXP-5410x/CSLib/Libs/lib_chip_5410x.lib -------------------------------------------------------------------------------- /embedded/projects/SH-Xpresso-LPC54102/sources/app/algorithm_t.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/embedded/projects/SH-Xpresso-LPC54102/sources/app/algorithm_t.c -------------------------------------------------------------------------------- /embedded/projects/osp-steval-mki109v2/sources/app/algorithm_t.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sensorplatforms/open-sensor-platform/HEAD/embedded/projects/osp-steval-mki109v2/sources/app/algorithm_t.c -------------------------------------------------------------------------------- /algorithm/osp/sigmot.h: -------------------------------------------------------------------------------- 1 | #ifndef _SIGMOT_H_ 2 | #define _SIGMOT_H_ 3 | #include "fp_sensor.h" 4 | 5 | void OSP_sigmot_init(void); 6 | void OSP_sigmot_process(struct ThreeAxis *, struct ThreeAxis *); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /embedded/projects/SH-Xpresso-LPC54102/keil-mdk-build/preBuildCmd.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | rem generate OSP hub version from git tag. Requires Python 2.7 installed and in system path 3 | python ..\..\..\..\scripts\generateVersionDotH.py -------------------------------------------------------------------------------- /algorithm/osp/tilt.h: -------------------------------------------------------------------------------- 1 | #ifndef _TILT_H_ 2 | #define _TILT_H_ 3 | 4 | #include "fp_sensor.h" 5 | void OSP_tilt_init(void); 6 | 7 | void OSP_tilt_process(struct ThreeAxis *acc, struct ThreeAxis *tilt); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /algorithm/osp/ecompass.h: -------------------------------------------------------------------------------- 1 | #ifndef _ECOMPAAS_H_ 2 | #define _ECOMPASS_H_ 1 3 | #include "fp_sensor.h" 4 | 5 | /* Start a cal sequence */ 6 | void OSP_ecompass_cal(void); 7 | void OSP_ecompass_process(struct ThreeAxis *, 8 | struct ThreeAxis *, 9 | struct Euler *result); 10 | void OSP_ecompass_init(void); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /algorithm/osp/Makefile: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | CFLAGS=-Wall -g -Iinclude -I../../include -DFEAT_STEP 3 | 4 | OSP_OBJS=SecondOrderLPF.o ecompass.o fp_atan2.o fp_sqrt.o fp_trig.o fpsup.o gravity_lin.o osp.o rotvec.o step.o tilt.o sigmot.o 5 | 6 | all: libOSP.a 7 | 8 | libOSP.a: $(OSP_OBJS) 9 | ar r libOSP.a $(OSP_OBJS) 10 | 11 | clean: 12 | rm -f *.o libOSP.a 13 | -------------------------------------------------------------------------------- /algorithm/osp/rotvec.h: -------------------------------------------------------------------------------- 1 | #ifndef _ROTVEC_H_ 2 | #define _ROTVEC_H_ 3 | 4 | #include "fp_sensor.h" 5 | 6 | void OSP_rotvec_init(void); 7 | #ifdef FEAT_ROTVEC_PRECISE 8 | void OSP_rotvec_process(struct ThreeAxis *, struct ThreeAxis *, struct Quat_precise *); 9 | #else 10 | void OSP_rotvec_process(struct ThreeAxis *, struct ThreeAxis *, struct Quat *); 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /algorithm/osp/gravity_lin.h: -------------------------------------------------------------------------------- 1 | #ifndef _GRAVITY_LIN_H_ 2 | #define _GRAVITY_LIN_H_ 1 3 | #include "fp_sensor.h" 4 | 5 | void OSP_gravity_init(void); 6 | void OSP_gravity_process(struct ThreeAxis *acc, struct ThreeAxis *res); 7 | 8 | void OSP_linear_acc_init(void); 9 | void OSP_linear_acc_process(struct ThreeAxis *acc, 10 | struct ThreeAxis *gravity, 11 | struct ThreeAxis *res); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /algorithm/osp/sigmot.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2015 HY Research LLC 3 | * Author: hy-git@hy-research.com 4 | * 5 | * Apache License. 6 | * 7 | * Initial attempt at the significant motion sensor. 8 | */ 9 | 10 | 11 | #include "sigmot.h" 12 | 13 | enum { 14 | SIGMOT_RESET, 15 | SIGMOT_WAIT, 16 | }; 17 | 18 | int state; 19 | 20 | void OSP_sigmot_init(void) 21 | { 22 | state = SIGMOT_WAIT; 23 | } 24 | 25 | void OSP_sigmot_process(struct ThreeAxis *acc, struct ThreeAxis *res) 26 | { 27 | res->x = 0; 28 | } 29 | -------------------------------------------------------------------------------- /algorithm/osp/osp.h: -------------------------------------------------------------------------------- 1 | #ifndef OSP_H 2 | #define OSP_H 1 3 | 4 | #include "osp-fixedpoint-types.h" 5 | #include "fpsup.h" 6 | #if 0 7 | void OSP_init(void); 8 | void OSPalg_Process(void); 9 | void OSPalg_SetDataAcc(Q15_t, Q15_t, Q15_t, NTTIME); 10 | void OSPalg_SetDataMag(Q15_t, Q15_t, Q15_t, NTTIME); 11 | void OSPalg_SetDataGyr(Q15_t, Q15_t, Q15_t, NTTIME); 12 | void OSPalg_cal(void); 13 | void OSPalg_EnableSensorCB(unsigned int, void (*ready)(struct Results *, int)); 14 | void OSPalg_DisableSensor(unsigned int); 15 | #endif 16 | #endif -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.map 5 | 6 | # Keil uVision 7 | *.bak 8 | *.d 9 | *.crf 10 | *.lnp 11 | *.dep 12 | *.uvguix.* 13 | *.uvgui.* 14 | *.lst 15 | *.sct 16 | *.iex 17 | *.__i 18 | *.*~ 19 | *.TMP 20 | *.tmp 21 | *.uvproj.saved_uv4 22 | *.build_log.* 23 | 24 | # Libraries 25 | *.lib 26 | *.a 27 | *.zip 28 | 29 | # Shared objects (inc. Windows DLLs) 30 | *.dll 31 | *.so 32 | *.so.* 33 | *.dylib 34 | 35 | # Executables 36 | *.exe 37 | *.out 38 | *.app 39 | *.axf 40 | *.bin 41 | *.hex 42 | 43 | # Visual Studio 44 | *.suo 45 | *.ipch 46 | *.vcxproj.* 47 | *.sdf 48 | *.sln.* 49 | 50 | -------------------------------------------------------------------------------- /embedded/projects/SH-Xpresso-LPC54102/keil-mdk-build/Jenkins_Build.bat: -------------------------------------------------------------------------------- 1 | REM text within <> needs to be replaced with original path on the test PC before using this batch file. 2 | 3 | set path=%path%;\UV4; 4 | cd \jobs\Coverity_test\workspace\embedded 5 | rd fmlib /s /q 6 | md fmlib 7 | 8 | REM fmlib is to be taken from \\fs2\Public\Host_Software\MotionQ\release_1.x.xx folder 9 | copy \FMLib_Embedded.lib fmlib\ 10 | cd \jobs\Coverity_test\workspace 11 | UV4.exe -r embedded\projects\SH-Xpresso-LPC54102\keil-mdk-build\SH-Xpresso-LPC54102.uvprojx 12 | -------------------------------------------------------------------------------- /docs/osp-footer.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /algorithm/osp/lpf.h: -------------------------------------------------------------------------------- 1 | #ifndef LPF_H 2 | #define LPF_H 1 3 | 4 | struct LPF { 5 | Q15_t iQ; 6 | Q15_t fc; 7 | Q15_t K; 8 | Q15_t iD; 9 | Q15_t a0; 10 | Q15_t a1; 11 | Q15_t b1; 12 | Q15_t b2; 13 | 14 | Q15_t x1; 15 | Q15_t x2; 16 | Q15_t y1; 17 | Q15_t y2; 18 | }; 19 | 20 | struct LPF_CBQF { 21 | struct LPF mA; 22 | struct LPF mB; 23 | }; 24 | 25 | void LPF_init(struct LPF *lpf, Q15_t Q, Q15_t fc); 26 | void LPF_setSamplingPeriod(struct LPF *lpf, Q15_t dT); 27 | Q15_t LPF_BQF_init(struct LPF *lpf, Q15_t x); 28 | Q15_t LPF_BQF_data(struct LPF *lpf, Q15_t x); 29 | void LPF_CBQF_init(struct LPF_CBQF *clpf, struct LPF *lpf, Q15_t x); 30 | Q15_t LPF_CBQF_data(struct LPF_CBQF *clpf, Q15_t x); 31 | 32 | 33 | 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /algorithm/osp/fp_sensor.h: -------------------------------------------------------------------------------- 1 | #ifndef FP_SENSOR_H 2 | #define FP_SENSOR_H 1 3 | 4 | #include "fpsup.h" 5 | #include "osp-sensors.h" 6 | 7 | /* NTEXTENDED is int32_t Q12 */ 8 | /* NTPRECISE is int32_t Q24 */ 9 | #define Q15_to_NTEXTENDED(x) (x >> (Q15_SHIFT-12)) 10 | #define Q15_to_NTPRECISE(x) (x << (24-Q15_SHIFT)) 11 | #define NTEXTENDED_to_Q15(x) (x << (Q15_SHIFT-12)) 12 | #define NTPRECISE_to_Q15(x) (x >> (24-Q15_SHIFT)) 13 | 14 | #define FLAG(x) (1 << x) 15 | 16 | struct ThreeAxis { 17 | Q15_t x; 18 | Q15_t y; 19 | Q15_t z; 20 | }; 21 | 22 | struct Euler { 23 | Q15_t roll; 24 | Q15_t pitch; 25 | Q15_t yaw; 26 | }; 27 | 28 | struct Quat { 29 | Q15_t x; 30 | Q15_t y; 31 | Q15_t z; 32 | Q15_t w; 33 | }; 34 | 35 | #ifdef FEAT_ROTVEC_PRECISE 36 | struct Quat_precise { 37 | Q24_t x; 38 | Q24_t y; 39 | Q24_t z; 40 | Q24_t w; 41 | }; 42 | #endif 43 | 44 | struct StepInfo { 45 | int32_t count; 46 | int32_t detect; 47 | }; 48 | 49 | struct Results { 50 | union { 51 | struct ThreeAxis result; 52 | struct Euler euler; 53 | #ifdef FEAT_ROTVEC_PRECISE 54 | struct Quat_precise quat; 55 | #else 56 | struct Quat quat; 57 | #endif 58 | #ifdef FEAT_STEP 59 | struct StepInfo step; 60 | #endif 61 | } ResType; 62 | uint32_t time; 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /algorithm/osp/OSP_interface.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2015 HY Research LLC 3 | * Author: hy-git@hy-research.com 4 | * 5 | * Apache License. 6 | * 7 | * Interface layer for OSP. Implements a subset of the public 8 | * functions as defined by the OSP API. 9 | */ 10 | 11 | #include 12 | 13 | #include "osp-api.h" 14 | 15 | /* Dummy routines for OSP */ 16 | 17 | OSP_STATUS_t OSP_Initialize(const SystemDescriptor_t* pSystemDesc) 18 | { 19 | return OSP_STATUS_OK; 20 | } 21 | 22 | OSP_STATUS_t OSP_DoForegroundProcessing(void) 23 | { 24 | return OSP_STATUS_IDLE; 25 | } 26 | 27 | OSP_STATUS_t OSP_DoBackgroundProcessing(void) 28 | { 29 | return OSP_STATUS_IDLE; 30 | } 31 | 32 | OSP_STATUS_t OSP_SetInputData(InputSensorHandle_t h, TriAxisSensorRawData_t *d) 33 | { 34 | return OSP_STATUS_OK; 35 | } 36 | 37 | OSP_STATUS_t OSP_RegisterInputSensor(const SensorDescriptor_t *pSensorDescriptor, InputSensorHandle_t *pReturnedHandle) 38 | { 39 | return OSP_STATUS_OK; 40 | } 41 | 42 | OSP_STATUS_t OSP_SubscribeSensorResult(ResultDescriptor_t *pResultDescriptor, ResultHandle_t *pResultHandle) 43 | { 44 | return OSP_STATUS_OK; 45 | } 46 | 47 | 48 | static const OSP_Library_Version_t Version = { 49 | .VersionNumber = 0x99889988, 50 | .VersionString = "OSP Dummy stub library", 51 | .buildTime = __DATE__"@"__TIME__, 52 | }; 53 | 54 | OSP_STATUS_t OSP_GetVersion(const OSP_Library_Version_t **ppVersionStruct) 55 | { 56 | *ppVersionStruct = &Version; 57 | return OSP_STATUS_OK; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /algorithm/osp/fp_trig.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2015 HY Research LLC 3 | * Author: hy-git@hy-research.com 4 | * 5 | * Apache License. 6 | * 7 | * Table look up tan/sin/cos 8 | */ 9 | #include "fpsup.h" 10 | #include "trig_sin.c" 11 | 12 | 13 | Q15_t sin_q15(Q15_t ang) 14 | { 15 | int adj = 1; 16 | int i; 17 | 18 | do { 19 | /* Sine is odd */ 20 | if (ang >= q15_pi/2 && ang < q15_pi) { 21 | ang -= q15_pi/2; 22 | break; 23 | } else if (ang >= q15_pi) { 24 | ang -= q15_pi; 25 | adj = -1 * adj; 26 | } else if (ang < 0) { 27 | ang += q15_pi; 28 | adj = -1 * adj; 29 | } else { 30 | /* Between 0 - pi/2 */ 31 | break; 32 | } 33 | } while(1); 34 | 35 | for (i = 0; i < sizeof(trig_sin)/sizeof(struct TRIG_SIN); i++) { 36 | if (ang < trig_sin[i].ang) { 37 | return trig_sin[i].sin * adj; 38 | } 39 | } 40 | return 0; 41 | } 42 | 43 | Q15_t cos_q15(Q15_t ang) 44 | { 45 | return sin_q15(ang + q15_pi/2); 46 | } 47 | 48 | Q15_t tan_q15(Q15_t ang) 49 | { 50 | return DIV_Q15(sin_q15(ang),cos_q15(ang)); 51 | } 52 | 53 | Q15_t arcsin_q15(Q15_t v) 54 | { 55 | Q15_t l, ang; 56 | int i, adj; 57 | 58 | if (v < 0) adj = -1; else adj = 1; 59 | l = v * adj; 60 | 61 | for (i = 0; i < sizeof(trig_sin)/sizeof(struct TRIG_SIN); i++) { 62 | if (l < trig_sin[i].sin) { 63 | ang = trig_sin[i].ang; 64 | break; 65 | } 66 | } 67 | return ang*adj; 68 | 69 | } 70 | 71 | Q15_t arccos_q15(Q15_t v) 72 | { 73 | Q15_t ang; 74 | 75 | ang = arcsin_q15(v); 76 | return (q15_pi/2 - ang); 77 | } 78 | -------------------------------------------------------------------------------- /algorithm/osp/gravity_lin.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2015 HY Research LLC 3 | * Author: hy-git@hy-research.com 4 | * 5 | * Apache License. 6 | * 7 | */ 8 | 9 | 10 | /* 11 | * Gravity and linear acceleration computation from AOSP. 12 | */ 13 | #include "fpsup.h" 14 | #include "lpf.h" 15 | #include "fp_sensor.h" 16 | #include "gravity_lin.h" 17 | 18 | static struct LPF xlpf, ylpf, zlpf; 19 | static struct LPF_CBQF xclpf, yclpf, zclpf; 20 | 21 | static const Q15_t SAMPLE_PERIOD = FP_to_Q15(0.020f); 22 | 23 | void OSP_gravity_init(void) 24 | { 25 | LPF_init(&xlpf,FP_to_Q15(0.707107f), FP_to_Q15(1.5f)); 26 | LPF_init(&ylpf,FP_to_Q15(0.707107f), FP_to_Q15(1.5f)); 27 | LPF_init(&zlpf,FP_to_Q15(0.707107f), FP_to_Q15(1.5f)); 28 | LPF_setSamplingPeriod(&xlpf, SAMPLE_PERIOD); 29 | LPF_setSamplingPeriod(&ylpf, SAMPLE_PERIOD); 30 | LPF_setSamplingPeriod(&zlpf, SAMPLE_PERIOD); 31 | LPF_CBQF_init(&xclpf, &xlpf, 0); 32 | LPF_CBQF_init(&yclpf, &ylpf, 0); 33 | LPF_CBQF_init(&zclpf, &zlpf, FP_to_Q15(9.8f)); 34 | } 35 | 36 | void OSP_linear_acc_init(void) 37 | { 38 | } 39 | 40 | void OSP_gravity_process(struct ThreeAxis *acc, struct ThreeAxis *res) 41 | { 42 | res->x = LPF_CBQF_data(&xclpf, acc->x); 43 | res->y = LPF_CBQF_data(&yclpf, acc->y); 44 | res->z = LPF_CBQF_data(&zclpf, acc->z); 45 | }; 46 | 47 | void OSP_linear_acc_process(struct ThreeAxis *acc, 48 | struct ThreeAxis *gravity, 49 | struct ThreeAxis *res) 50 | { 51 | res->x = acc->x - (gravity->x); 52 | res->y = acc->y - (gravity->y); 53 | res->z = acc->z - (gravity->z); 54 | } 55 | -------------------------------------------------------------------------------- /embedded/projects/step-example/example_platform_interface.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | /*! 19 | * \file Simple platform abstraction for examples * 20 | * 21 | ****************************************************************************/ 22 | #ifndef EXAMPLEPLATFORMIMPLEMENTATION_H 23 | #define EXAMPLEPLATFORMIMPLEMENTATION_H 24 | 25 | #include 26 | 27 | #define PRINTF(fmt, ...) printf(fmt, __VA_ARGS__) 28 | 29 | #include "osp-api.h" 30 | 31 | void Platform_Initialize(void); 32 | void Platform_HandleErrorIf(char isError, const char* msg); 33 | SensorDescriptor_t* Platform_GetSensorDescriptorByName(const char* sensorType); 34 | const SystemDescriptor_t* Platform_GetSystemDescriptor(); 35 | uint32_t Platform_BlockOnNewSensorReadings(); 36 | 37 | #endif // EXAMPLEPLATFORMIMPLEMENTATION_H 38 | -------------------------------------------------------------------------------- /embedded/projects/step-example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Open Sensor Platform Project 3 | # https://github.com/sensorplatforms/open-sensor-platform 4 | # 5 | # Copyright (C) 2013 Sensor Platforms Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | ################################################################################ 20 | # 21 | # To Build 22 | # - cmake 23 | # - make 24 | # 25 | ################################################################################ 26 | cmake_minimum_required (VERSION 2.6) 27 | 28 | project(step-example) 29 | 30 | # 31 | # Include Paths 32 | ## 33 | set (PUBLIC_INCLUDE_DIRS 34 | ${CMAKE_CURRENT_SOURCE_DIR} 35 | ${CMAKE_CURRENT_SOURCE_DIR}/../../../include 36 | ) 37 | include_directories(${PUBLIC_INCLUDE_DIRS}) 38 | 39 | # 40 | # Linker Paths 41 | ## 42 | link_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../../lib ) 43 | 44 | # 45 | # Compile Time Defines 46 | ## 47 | #add_definitions( -D BOARD_XXX) 48 | 49 | # 50 | # Step Counter Example 51 | ## 52 | set(StepExample_SOURCES 53 | main.c 54 | simulated_platform.c) 55 | add_executable(step-example ${StepExample_SOURCES}) 56 | target_link_libraries(step-example osp) 57 | -------------------------------------------------------------------------------- /algorithm/osp/fp_atan2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Approximate atan2 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include "fpsup.h" 9 | 10 | /* 11 | * arctan of y/x 12 | */ 13 | 14 | static const Q15_t q15_pi_4 = FP_to_Q15(M_PI/4.0); 15 | 16 | Q15_t atan2_q15(Q15_t y, Q15_t x) 17 | { 18 | const Q15_t q15_3_4_PI = FP_to_Q15(3.0*M_PI/4.0f); 19 | Q15_t abs_y, r, rt, angle; 20 | 21 | if (y == 0 && x < 0) return q15_pi; 22 | if (y == 0 && x > 0) return 0; 23 | if (y < 0 && x == 0) return -(q15_pi >> 1); /* -PI/2 */ 24 | if (y > 0 && x == 0) return (q15_pi >> 1); /* PI/2 */ 25 | if (y == 0 && x == 0) return q15_pi; 26 | 27 | abs_y = abs_q15(y); 28 | 29 | if (x >= 0) { 30 | rt = RECIP_Q15(x+abs_y); 31 | r = MUL_Q15((x-abs_y), rt); 32 | 33 | angle = q15_pi_4 - MUL_Q15(q15_pi_4, r); 34 | } else { 35 | rt = RECIP_Q15(abs_y-x); 36 | r = MUL_Q15((x+abs_y), rt); 37 | angle = q15_3_4_PI - MUL_Q15(q15_pi_4, r); 38 | } 39 | 40 | if (y < 0) 41 | return -angle; 42 | else 43 | return angle; 44 | } 45 | #ifdef TEST 46 | int main(int argc, char **argv) 47 | { 48 | float ang; 49 | float ang_rad; 50 | Q15_t qy, qx, qat; 51 | float fy, fx, fat; 52 | float err = 0.0; 53 | 54 | if (argc > 1) { 55 | err = atof(argv[1]); 56 | if (err > 2.0) 57 | err = 0.0; 58 | } 59 | 60 | fprintf(stderr, "Printing errors greater then %f\n", err); 61 | 62 | for (ang = 0; ang < 360.0f; ang+= 0.5) { 63 | ang_rad = ang * M_PI/180.0f; 64 | qx = q15_c1; 65 | fx = 1.0; 66 | fy = tan(ang_rad); 67 | qy = FP_to_Q15(fy); 68 | 69 | fat = atan2(fy, fx); 70 | qat = atan2_q15(qy, qx); 71 | if ((Q15_to_FP(qat)-fat) > err) { 72 | 73 | fprintf(stderr, 74 | "ANG: %f - tan = %f (%f), atan() = %f (%f) err = %f\n", 75 | ang, fy, Q15_to_FP(qy), 76 | fat, Q15_to_FP(qat), 77 | Q15_to_FP(qat)-fat); 78 | } 79 | } 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /linux/sensorhubd/README.md: -------------------------------------------------------------------------------- 1 | sensorhubd 2 | -------------------------------------------- 3 | Sensorhubd bridges from a serial UART into Input Event virtual sensor device nodes. 4 | 5 | 6 | ### Data Path 7 | It creates three input event devices : accel, mag, and gyro. They are integer values in android conventions, 8 | but need to be scaled down by 1000 to be put into floating point values. 9 | 10 | Find their event IDs by doing a cat /proc/bus/input/devices or using getevent with no arguments 11 | 12 | ### Control Path 13 | For sensor enable/disable and setDelay sensorhubd reads on named pipes it creates, specifically: 14 | 15 | /data/misc/sensorhubd/osp-accel/enable 16 | /data/misc/sensorhubd/osp-accel/delayMs 17 | 18 | /data/misc/sensorhubd/osp-mag/enable 19 | /data/misc/sensorhubd/osp-mag/delayMs 20 | 21 | /data/misc/sensorhubd/osp-gyro/enable 22 | /data/misc/sensorhubd/osp-gyro/delayMs 23 | 24 | 25 | ### usage 26 | usage: sensorhubd 27 | 28 | ### verifying functionality 29 | assuming that no daemons are started in init.rc, adb shell logs in as root 30 | 31 | *hook up the serial port and start sensor hub daemon* 32 | 33 | adb shell 34 | sensorhubd & 35 | 36 | *read out accelerometer event data from another shell* 37 | 38 | adb shell cat /proc/bus/input/devices | awk '/osp-accel/,/event/ {d=$1; if (/N:/) {split($2,n,"=")}; if(/H:/) {split($2,e," "); print $3 "\t" n[2];}}' 39 | adb shell getevent `adb shell cat /proc/bus/input/devices | awk '/osp-accel/,/event/ {d=$1; if (/N:/) {split($2,n,"=")}; if(/H:/) {split($2,e," "); print "/dev/input/" $3 ;}}'` #no events come, so press 40 | adb shell echo 1 > /data/misc/sensorhubd/osp-accel/enable 41 | adb shell getevent `adb shell cat /proc/bus/input/devices | awk '/osp-accel/,/event/ {d=$1; if (/N:/) {split($2,n,"=")}; if(/H:/) {split($2,e," "); print "/dev/input/" $3 ;}}'` 42 | -------------------------------------------------------------------------------- /algorithm/osp/fp_sqrt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2015 HY Research LLC 3 | * Author: hy-git@hy-research.com 4 | * 5 | * Apache License. 6 | * 7 | * Math support routines for sqrt. 8 | */ 9 | /* Apache Licensed code from PebbleFit */ 10 | #include 11 | #include "fpsup.h" 12 | 13 | #ifdef ENABLE_Q12 14 | Q12_t sqrt_q12(Q12_t num) 15 | { 16 | Q12_t a, p, e = FP_to_Q12(0.001f), b; 17 | Q12_t t; 18 | int nb = 0; 19 | 20 | a = num; 21 | 22 | p = MUL_Q12(a, a);; 23 | while ((p - num >= e) && (nb++ < 40)) { 24 | t = RECIP_Q12(a); 25 | b = a + MUL_Q12(num, t); 26 | a = b >> 1; 27 | p = MUL_Q12(a, a); 28 | } 29 | 30 | return a; 31 | } 32 | #endif 33 | Q15_t sqrt_q15(Q15_t num) 34 | { 35 | Q15_t ans; 36 | LQ15_t a, b; 37 | LQ15_t p, e = FP_to_Q15(0.0001f); 38 | LQ15_t t, numl; 39 | int nb = 0; 40 | 41 | numl = num; 42 | a = numl; 43 | 44 | p = MUL_LQ15(a, a); 45 | while ((abs_lq15(p - num) >= e) && (nb++ < 64)) { 46 | t = RECIP_LQ15(a); 47 | b = a + MUL_LQ15(numl, t); 48 | a = b >> 1; 49 | p = MUL_LQ15(a, a); 50 | nb++; 51 | } 52 | ans = a; 53 | #if 0 54 | printf("SQRT: %f = %f nb = %i\n", LQ15_to_FP(numl), LQ15_to_FP(a), nb); 55 | #endif 56 | return ans; 57 | } 58 | 59 | #ifdef ENABLE_Q24 60 | Q24_t sqrt_q24(Q24_t num) 61 | { 62 | Q24_t a, p, e = FP_to_Q24(0.001f), b; 63 | Q24_t t; 64 | int nb = 0; 65 | 66 | a = num; 67 | 68 | p = MUL_Q24(a, a);; 69 | while ((abs_q24(p - num) >= e) && (nb++ < 40)) { 70 | t = RECIP_Q24(a); 71 | b = a + MUL_Q24(num, t); 72 | a = b >> 1; 73 | p = MUL_Q24(a, a); 74 | nb++; 75 | } 76 | return a; 77 | } 78 | #endif 79 | 80 | #ifdef TEST_SQRT 81 | #include 82 | int main(int argc, char **argv) 83 | { 84 | float testv[] = { 85 | 37483.949219f, 86 | -1.0f 87 | }; 88 | int i; 89 | 90 | for (i = 0; testv[i] > 0; i++) { 91 | printf("SQRT(%f) = (Q15: %f, float: %f)\n", 92 | testv[i], Q15_to_FP(sqrt_q15(FP_to_Q15(testv[i]))), 93 | sqrt(testv[i])); 94 | } 95 | return 0; 96 | } 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /external/MCU/NXP-5410x/CSLib/Inc/fpu_init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @brief FPU init code 3 | * 4 | * @note 5 | * Copyright(C) NXP Semiconductors, 2012 6 | * All rights reserved. 7 | * 8 | * @par 9 | * Software that is described herein is for illustrative purposes only 10 | * which provides customers with programming information regarding the 11 | * LPC products. This software is supplied "AS IS" without any warranties of 12 | * any kind, and NXP Semiconductors and its licensor disclaim any and 13 | * all warranties, express or implied, including all implied warranties of 14 | * merchantability, fitness for a particular purpose and non-infringement of 15 | * intellectual property rights. NXP Semiconductors assumes no responsibility 16 | * or liability for the use of the software, conveys no license or rights under any 17 | * patent, copyright, mask work right, or any other intellectual property rights in 18 | * or to any products. NXP Semiconductors reserves the right to make changes 19 | * in the software without notification. NXP Semiconductors also makes no 20 | * representation or warranty that such application will be suitable for the 21 | * specified use without further testing or modification. 22 | * 23 | * @par 24 | * Permission to use, copy, modify, and distribute this software and its 25 | * documentation is hereby granted, under NXP Semiconductors' and its 26 | * licensor's relevant copyrights in the software, without fee, provided that it 27 | * is used in conjunction with NXP Semiconductors microcontrollers. This 28 | * copyright, permission, and disclaimer notice must appear in all copies of 29 | * this code. 30 | */ 31 | 32 | #ifndef __FPU_INIT_H_ 33 | #define __FPU_INIT_H_ 34 | 35 | /** 36 | * @defgroup CHIP_FPU_CMX CHIP: FPU initialization 37 | * @ingroup CHIP_Common 38 | * Cortex FPU initialization 39 | * @{ 40 | */ 41 | 42 | /** 43 | * @brief Early initialization of the FPU 44 | * @return Nothing 45 | */ 46 | void fpuInit(void); 47 | 48 | /** 49 | * @} 50 | */ 51 | 52 | #endif /* __FPU_INIT_H_ */ 53 | -------------------------------------------------------------------------------- /linux/sensorhubd/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Open Sensor Platform Project 3 | # https://github.com/sensorplatforms/open-sensor-platform 4 | # 5 | # Copyright (C) 2013 Sensor Platforms Inc. 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | ################################################################################ 20 | # 21 | # To Build 22 | # - cmake 23 | # - make 24 | # 25 | ############################################################################### 26 | cmake_minimum_required (VERSION 2.6) 27 | 28 | project(sensorhubd) 29 | 30 | 31 | 32 | # 33 | # Include paths 34 | ## 35 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../include) 36 | 37 | # 38 | # Linker include paths 39 | ## 40 | #link_directories() 41 | 42 | # 43 | # 44 | ## 45 | IF(CMAKE_BUILD_TYPE MATCHES Release) 46 | message(STATUS "building in Release mode") 47 | add_definitions(-DNDEBUG) 48 | ENDIF(CMAKE_BUILD_TYPE MATCHES Release) 49 | 50 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x -fPIC -Wall -Werror") 51 | 52 | # 53 | # App 54 | ## 55 | set(app_SOURCES 56 | main.cpp 57 | virtualsensordevicemanager.h 58 | virtualsensordevicemanager.cpp 59 | osp_remoteprocedurecalls.h 60 | osp_remoteprocedurecalls_relay.cpp 61 | osp_configuration.cpp 62 | uinpututils.c 63 | ) 64 | 65 | add_executable(sensorhubd ${app_SOURCES}) 66 | 67 | if(${CMAKE_CXX_COMPILER} MATCHES "arm") 68 | target_link_libraries(sensorhubd log android) 69 | else() 70 | target_link_libraries(sensorhubd pthread) 71 | endif() 72 | -------------------------------------------------------------------------------- /external/MCU/NXP-5410x/CSLib/Inc/cmsis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @brief LPC5410x selective CMSIS inclusion file 3 | * 4 | * Copyright(C) NXP Semiconductors, 2014 5 | * All rights reserved. 6 | * 7 | * Software that is described herein is for illustrative purposes only 8 | * which provides customers with programming information regarding the 9 | * LPC products. This software is supplied "AS IS" without any warranties of 10 | * any kind, and NXP Semiconductors and its licensor disclaim any and 11 | * all warranties, express or implied, including all implied warranties of 12 | * merchantability, fitness for a particular purpose and non-infringement of 13 | * intellectual property rights. NXP Semiconductors assumes no responsibility 14 | * or liability for the use of the software, conveys no license or rights under any 15 | * patent, copyright, mask work right, or any other intellectual property rights in 16 | * or to any products. NXP Semiconductors reserves the right to make changes 17 | * in the software without notification. NXP Semiconductors also makes no 18 | * representation or warranty that such application will be suitable for the 19 | * specified use without further testing or modification. 20 | * 21 | * Permission to use, copy, modify, and distribute this software and its 22 | * documentation is hereby granted, under NXP Semiconductors' and its 23 | * licensor's relevant copyrights in the software, without fee, provided that it 24 | * is used in conjunction with NXP Semiconductors microcontrollers. This 25 | * copyright, permission, and disclaimer notice must appear in all copies of 26 | * this code. 27 | */ 28 | 29 | #ifndef __CMSIS_H_ 30 | #define __CMSIS_H_ 31 | 32 | #include "lpc_types.h" 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /* Select correct CMSIS include file based on CORE_* definition */ 39 | #if defined(CORE_M4) 40 | #include "cmsis_5410x.h" 41 | typedef LPC5410X_IRQn_Type IRQn_Type; 42 | #include "core_cm4.h" /*!< Cortex-M4 processor and core peripherals */ 43 | #elif defined(CORE_M0PLUS) 44 | #include "cmsis_5410x_m0.h" 45 | typedef LPC5410X_M0_IRQn_Type IRQn_Type; 46 | #include "core_cm0plus.h" /*!< Cortex-M0 Plus processor and core peripherals */ 47 | #else 48 | #error "No CORE_* definition is defined" 49 | #endif 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif /* __CMSIS_H_ */ 56 | -------------------------------------------------------------------------------- /embedded/common/asf/asf_taskdeftype.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | /* This file maybe included more than once */ 19 | 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | C O N S T A N T S & M A C R O S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | /* 25 | ** ASF_TASK_DEF_TYPE should be defined to be either 26 | ** 27 | ** ASF_TASK_IDS 28 | ** ASF_QUEUE_SETUP 29 | ** ASF_STACK_SETUP 30 | ** ASF_TASK_SETUP 31 | ** ASF_TASK_DECLARE 32 | ** 33 | ** by the including file 34 | */ 35 | #define ASF_TASK_IDS 1 36 | #define ASF_STACK_SETUP 2 37 | #define ASF_QUEUE_SETUP 3 38 | #define ASF_TASK_SETUP 4 39 | #define ASF_TASK_DECLARE 5 40 | 41 | #define IN_ASF_TASK_DEF 42 | 43 | #if defined (ASF_TASK_STATIC) 44 | # undef ASF_TASK_STATIC 45 | #endif 46 | 47 | /*************************************************************************** 48 | * Include OS specific macros 49 | **************************************************************************/ 50 | 51 | #include "asf_tdefmacros.h" 52 | 53 | 54 | #if !defined (ASF_TASK_STATIC) 55 | # error ASF_TASK_STATIC must be defined 56 | #endif 57 | 58 | #undef ASF_TASK_DEF_TYPE 59 | #undef IN_ASF_TASK_DEF 60 | 61 | #define ASF_TASK __task 62 | #define ASF_TASK_ARG void *argv 63 | 64 | 65 | /*-------------------------------------------------------------------------------------------------*\ 66 | | E N D O F F I L E 67 | \*-------------------------------------------------------------------------------------------------*/ 68 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | open-sensor-platform 2 | ==================== 3 | 4 | Open Sensor Platform (OSP) is open source software built to enable 5 | systems with sensor hubs. It is a framework specifically for sensor 6 | data acquisition, communication, and interpretation. The embedded 7 | code is in C to allow easy compatibility with any CPU architecture or 8 | real-time operating system. The linux code allows easy implementation 9 | of sensor hub data up to an Application Processor (AP) an Android 10 | Hardware Abstraction Layer (HAL). The framework is simple and 11 | flexible enough to be extended to more use-cases. 12 | 13 | This project can be used to support various embedded sensor 14 | applications such as: 15 | * Android KitKat compliant buffering sensor hubs, 16 | * always-on context aware hubs, 17 | * multi-function wearable devices. 18 | 19 | ### Community Contributions 20 | 21 | OSP encourages developers to focus on creating low-level applications 22 | for sensors rather than reinventing the wheel on the sensor interface. 23 | By open sourcing this software, community contributions can continue 24 | to develop this framework. Ports of OSP to other platforms can be 25 | contributed to this project. 26 | 27 | OSP is released by Sensor Platforms Inc. under the Apache 2.0 license. 28 | 29 | ### Trying it out 30 | 31 | A reference sensor hub example is provided for easily available hardware: 32 | * an STEVAL board with ARM-CortexM3 based microprocessor and 9-axis sensors attached, 33 | * a Nexus7 tablet with KitKat connected over I2C to the STEVAL board as a sensor hub. 34 | 35 | This example can be ported to a Cortex-M0+, or any other MCU or DSP 36 | architecture. 37 | 38 | The example uses the Keil-MDK toolchain, but 39 | future releases will utilize gcc under Keil as well as full 40 | gcc/Makefile based build system. 41 | 42 | The project uses the Keil RTX Real Time Operating system and will 43 | eventually leverage the platform agnostic CMSIS APIs. 44 | 45 | ### Additional Questions 46 | 47 | Refer to the detailed [FAQ](https://github.com/sensorplatforms/open-sensor-platform/wiki) on the wiki section of this project. 48 | 49 | 50 | ### Project Structure 51 | * doc - Doxygen creation 52 | * embedded - sensor hub code 53 | * external - Source code, library, documentation, algorithms, etc. from external sources available under open-source license 54 | * linux - Android application processor code 55 | -------------------------------------------------------------------------------- /external/MCU/NXP-5410x/Retarget/Retarget.c: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2015 Audience Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #include 19 | #include "Common.h" 20 | 21 | #pragma import(__use_no_semihosting_swi) 22 | 23 | #ifdef __GNUC__ 24 | /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf 25 | set to 'Yes') calls __io_putchar() */ 26 | #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) 27 | #else 28 | #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) 29 | #endif /* __GNUC__ */ 30 | 31 | int ser_putchar (int c); 32 | int ser_getchar (void); 33 | 34 | struct __FILE { int handle; /* Add whatever you need here */ }; 35 | FILE __stdout; 36 | FILE __stdin; 37 | 38 | 39 | PUTCHAR_PROTOTYPE 40 | { 41 | return (ser_putchar(ch)); 42 | } 43 | 44 | int fgetc (FILE *f) { return (ser_getchar()); } 45 | 46 | 47 | int ferror(FILE *f) { 48 | /* Your implementation of ferror */ 49 | return EOF; 50 | } 51 | 52 | 53 | void _ttywrch(int ch) { ser_putchar(ch); } 54 | 55 | 56 | void _sys_exit(int return_code) { 57 | label: goto label; /* endless loop */ 58 | } 59 | 60 | /*---------------------------------------------------------------------------- 61 | Write character to Serial Port (blocking) 62 | *----------------------------------------------------------------------------*/ 63 | int ser_putchar (int byte) { 64 | 65 | while (!(DBG_IF_UART->STAT & UART_STAT_TXRDY)); 66 | DBG_IF_UART->TXDAT = (uint32_t)(byte & 0xFF); 67 | 68 | return byte; 69 | } 70 | 71 | 72 | /*---------------------------------------------------------------------------- 73 | Read character from Serial Port (blocking read) 74 | *----------------------------------------------------------------------------*/ 75 | int ser_getchar (void) { 76 | 77 | while (!(DBG_IF_UART->STAT & UART_STAT_RXRDY)); 78 | 79 | return ((int)(DBG_IF_UART->RXDAT & 0x000000FF)); 80 | } 81 | -------------------------------------------------------------------------------- /algorithm/osp/fpsup.h: -------------------------------------------------------------------------------- 1 | #ifndef FP_SUP_H 2 | #define FP_SUP_H 1 3 | #include 4 | 5 | #ifndef M_PI 6 | #define M_PI 3.141592f 7 | #endif 8 | typedef int32_t Q15_t; 9 | #define Q15_SHIFT 15 10 | #define FP_to_Q15(v) ((v)*(1<> (Q15_SHIFT-Q12_SHIFT)) 30 | #define Q12_to_Q15(x) ((x) << (Q15_SHIFT-Q12_SHIFT)) 31 | Q12_t RECIP_Q12(Q12_t); 32 | Q12_t DIV_Q12(Q12_t, Q12_t); 33 | #endif 34 | 35 | #define MAX_Q15 0x7fffffff 36 | #define MIN_Q15 0x80000000 37 | 38 | Q15_t DIV_Q15(Q15_t, Q15_t); 39 | LQ15_t DIV_LQ15(LQ15_t, LQ15_t); 40 | Q15_t MUL_Q15(Q15_t, Q15_t); 41 | LQ15_t MUL_LQ15(LQ15_t, LQ15_t); 42 | Q15_t RECIP_Q15(Q15_t); 43 | LQ15_t RECIP_LQ15(LQ15_t); 44 | 45 | extern const Q15_t q15_pi; 46 | extern const Q15_t q15_c360; 47 | extern const Q15_t q15_c180; 48 | extern const Q15_t q15_c90; 49 | extern const Q15_t q15_c1; 50 | extern const Q15_t q15_c2; 51 | extern const Q15_t q15_half; 52 | extern const Q15_t q15_quarter; 53 | 54 | #ifdef ENABLE_Q12 55 | const Q12_t q12_pi; 56 | const Q12_t q12_c360; 57 | const Q12_t q12_c180; 58 | const Q12_t q12_c90; 59 | const Q12_t q12_c1; 60 | const Q12_t q12_c2; 61 | const Q12_t q12_half; 62 | const Q12_t q12_quarter; 63 | #endif 64 | 65 | #ifdef ENABLE_Q24 66 | Q24_t DIV_Q24(Q24_t, Q24_t); 67 | Q24_t MUL_Q24(Q24_t, Q24_t); 68 | Q24_t RECIP_Q24(Q24_t); 69 | 70 | const Q24_t q24_pi; 71 | const Q24_t q24_c360; 72 | const Q24_t q24_c180; 73 | const Q24_t q24_c90; 74 | const Q24_t q24_c1; 75 | const Q24_t q24_c2; 76 | const Q24_t q24_half; 77 | const Q24_t q24_quarter; 78 | 79 | double Q24_to_FP(Q24_t); 80 | #endif 81 | double Q15_to_FP(Q15_t); 82 | double LQ15_to_FP(LQ15_t); 83 | 84 | #ifdef ENABLE_Q12 85 | double Q12_to_FP(Q12_t); 86 | #endif 87 | 88 | Q15_t atan2_q15(Q15_t, Q15_t); 89 | Q15_t tan_q15(Q15_t); 90 | Q15_t sqrt_q15(Q15_t); 91 | Q15_t arccos_q15(Q15_t); 92 | Q15_t arcsin_q15(Q15_t); 93 | #ifdef ENABLE_Q24 94 | Q15_t sqrt_q24(Q15_t); 95 | #endif 96 | 97 | Q15_t pow_q15(Q15_t, Q15_t); 98 | Q15_t abs_q15(Q15_t); 99 | LQ15_t abs_lq15(LQ15_t); 100 | #endif 101 | -------------------------------------------------------------------------------- /external/MCU/STM32F1-CM3/Retarget/Retarget.c: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #include 19 | #include "Common.h" 20 | 21 | #pragma import(__use_no_semihosting_swi) 22 | 23 | #ifdef __GNUC__ 24 | /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf 25 | set to 'Yes') calls __io_putchar() */ 26 | #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) 27 | #else 28 | #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) 29 | #endif /* __GNUC__ */ 30 | 31 | #define USARTx DBG_IF_UART //As defined in the hw_setup_xxxx.h file 32 | 33 | int ser_putchar (int c); 34 | int ser_getchar (void); 35 | 36 | 37 | struct __FILE { int handle; /* Add whatever you need here */ }; 38 | FILE __stdout; 39 | FILE __stdin; 40 | 41 | 42 | PUTCHAR_PROTOTYPE 43 | { 44 | return (ser_putchar(ch)); 45 | } 46 | 47 | int fgetc (FILE *f) { return (ser_getchar()); } 48 | 49 | 50 | int ferror(FILE *f) { 51 | /* Your implementation of ferror */ 52 | return EOF; 53 | } 54 | 55 | 56 | void _ttywrch(int ch) { ser_putchar(ch); } 57 | 58 | 59 | void _sys_exit(int return_code) { 60 | label: goto label; /* endless loop */ 61 | } 62 | 63 | /*---------------------------------------------------------------------------- 64 | Write character to Serial Port (blocking) 65 | *----------------------------------------------------------------------------*/ 66 | int ser_putchar (int c) { 67 | 68 | while (!(USARTx->SR & USART_FLAG_TXE)); 69 | USARTx->DR = (c & 0xFF); 70 | return (c); 71 | } 72 | 73 | 74 | /*---------------------------------------------------------------------------- 75 | Read character from Serial Port (blocking read) 76 | *----------------------------------------------------------------------------*/ 77 | int ser_getchar (void) { 78 | 79 | while (!(USARTx->SR & USART_FLAG_RXNE)); 80 | 81 | return ((int)(USARTx->DR & 0xFF)); 82 | } 83 | -------------------------------------------------------------------------------- /embedded/common/asf/asf_tqenum.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (ASF_TQENUM_H) 19 | #define ASF_TQENUM_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #define ASF_TASK_DEF_TYPE ASF_TASK_IDS 25 | #include "asf_taskdeftype.h" 26 | 27 | /*-------------------------------------------------------------------------------------------------*\ 28 | | T Y P E D E F I N I T I O N S 29 | \*-------------------------------------------------------------------------------------------------*/ 30 | typedef enum TaskIdTag 31 | { 32 | 33 | #include "asf_tasks.h" 34 | 35 | NUMBER_OF_TASKS, 36 | 37 | UNKNOWN_TASK_ID = 0xFF, 38 | } TaskId; 39 | 40 | 41 | /*-------------------------------------------------------------------------------------------------*\ 42 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 43 | \*-------------------------------------------------------------------------------------------------*/ 44 | 45 | /*-------------------------------------------------------------------------------------------------*\ 46 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 47 | \*-------------------------------------------------------------------------------------------------*/ 48 | 49 | /*-------------------------------------------------------------------------------------------------*\ 50 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 51 | \*-------------------------------------------------------------------------------------------------*/ 52 | 53 | 54 | #endif /* ASF_TQENUM_H */ 55 | /*-------------------------------------------------------------------------------------------------*\ 56 | | E N D O F F I L E 57 | \*-------------------------------------------------------------------------------------------------*/ 58 | -------------------------------------------------------------------------------- /embedded/common/templates/__SourceFile.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2015 Audience Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (YOUR_HEADER_FILE_NAME_H) 19 | #define YOUR_HEADER_FILE_NAME_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | 25 | /*-------------------------------------------------------------------------------------------------*\ 26 | | C O N S T A N T S & M A C R O S 27 | \*-------------------------------------------------------------------------------------------------*/ 28 | 29 | /*-------------------------------------------------------------------------------------------------*\ 30 | | T Y P E D E F I N I T I O N S 31 | \*-------------------------------------------------------------------------------------------------*/ 32 | 33 | /*-------------------------------------------------------------------------------------------------*\ 34 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 35 | \*-------------------------------------------------------------------------------------------------*/ 36 | 37 | /*-------------------------------------------------------------------------------------------------*\ 38 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 39 | \*-------------------------------------------------------------------------------------------------*/ 40 | 41 | /*-------------------------------------------------------------------------------------------------*\ 42 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 43 | \*-------------------------------------------------------------------------------------------------*/ 44 | 45 | 46 | #endif /* YOUR_HEADER_FILE_NAME_H */ 47 | /*-------------------------------------------------------------------------------------------------*\ 48 | | E N D O F F I L E 49 | \*-------------------------------------------------------------------------------------------------*/ 50 | -------------------------------------------------------------------------------- /algorithm/osp/tilt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2015 HY Research LLC 3 | * Author: hy-git@hy-research.com 4 | * 5 | * Apache License. 6 | * 7 | */ 8 | 9 | /* Compute a tilt sensor as defined by Android */ 10 | #include "fpsup.h" 11 | #include "tilt.h" 12 | 13 | #define NUM_SAMPLE2 50 14 | #define NUM_SAMPLE1 25 15 | 16 | static struct ThreeAxis accHist[NUM_SAMPLE2]; 17 | static struct ThreeAxis prevMean; 18 | int sampcount; 19 | int samp_head, samp_tail; 20 | 21 | #define ABS(x) ((x > 0)?x:-x) 22 | 23 | void OSP_tilt_init(void) 24 | { 25 | sampcount = 0; 26 | samp_head = 49, samp_tail = 0; 27 | } 28 | 29 | static void computeMean(struct ThreeAxis *mean, struct ThreeAxis *buf, int beg, int end) 30 | { 31 | int i, count; 32 | 33 | count = 0; 34 | mean->x = 0; mean->y = 0; mean->z = 0; 35 | for (i = beg; i != end; i++, i %= NUM_SAMPLE2) { 36 | mean->x += buf[i].x; 37 | mean->y += buf[i].y; 38 | mean->z += buf[i].z; 39 | count++; 40 | } 41 | mean->x = DIV_Q15(mean->x, INT_to_Q15(count)); 42 | mean->y = DIV_Q15(mean->y, INT_to_Q15(count)); 43 | mean->z = DIV_Q15(mean->z, INT_to_Q15(count)); 44 | } 45 | 46 | static Q15_t dotProduct(struct ThreeAxis *v1, struct ThreeAxis *v2) 47 | { 48 | Q15_t res; 49 | 50 | res = MUL_Q15(v1->x, v2->x); 51 | res += MUL_Q15(v1->y, v2->y); 52 | res += MUL_Q15(v1->z, v2->z); 53 | 54 | return res; 55 | } 56 | 57 | static Q15_t norm(struct ThreeAxis *v1) 58 | { 59 | Q15_t sum; 60 | 61 | sum = MUL_Q15(v1->x, v1->x); 62 | sum += MUL_Q15(v1->y, v1->y); 63 | sum += MUL_Q15(v1->z, v1->z); 64 | return sqrt_q15(sum); 65 | } 66 | 67 | static Q15_t computeAngle(struct ThreeAxis *v1, struct ThreeAxis *v2) 68 | { 69 | Q15_t v, n; 70 | 71 | v = dotProduct(v1, v2); 72 | n = MUL_Q15(norm(v1), norm(v2)); 73 | v = DIV_Q15(v, n); 74 | 75 | return arccos_q15(v); 76 | } 77 | 78 | /* Assumes the sensor runs at 50Hz */ 79 | void OSP_tilt_process(struct ThreeAxis *acc, struct ThreeAxis *tilt) 80 | { 81 | struct ThreeAxis cur; 82 | int ang = 0; 83 | 84 | if (sampcount > 10000) { 85 | tilt->x = 0; 86 | return; 87 | } 88 | 89 | 90 | accHist[samp_head] = *acc; 91 | 92 | if (sampcount < (NUM_SAMPLE2-1)) { 93 | if (sampcount == (NUM_SAMPLE1-1)) { 94 | computeMean(&prevMean, accHist, 0, NUM_SAMPLE1); 95 | } 96 | sampcount++; 97 | samp_head++; 98 | samp_head %= NUM_SAMPLE2; 99 | tilt->x = 0; 100 | return; 101 | } 102 | 103 | computeMean(&cur, accHist, samp_tail, samp_head); 104 | samp_head++; samp_head %= NUM_SAMPLE2; 105 | samp_tail++; samp_tail %= NUM_SAMPLE2; 106 | ang = computeAngle(&cur, &prevMean); 107 | if (ABS(ang) > INT_to_Q15(35)) { 108 | tilt->x = 1; 109 | sampcount = 99999; 110 | } 111 | return; 112 | } 113 | -------------------------------------------------------------------------------- /algorithm/osp/step.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2015 HY Research LLC 3 | * Author: hy-git@hy-research.com 4 | * 5 | * Apache License. 6 | * 7 | * Adopted from alg from PebbleFit, Apache Licensed . 8 | */ 9 | 10 | #include 11 | #include "fpsup.h" 12 | #include "fp_sensor.h" 13 | #include "step.h" 14 | 15 | static const Q15_t q15_0_20c = FP_to_Q15(0.20f); 16 | static Q15_t sens_Const = FP_to_Q15(200.0f); 17 | static Q15_t threshold = 0; 18 | 19 | void OSP_step_init(void) 20 | { 21 | } 22 | 23 | /* 24 | * Det is number of steps detected. 25 | * Count is count accumated count. On return: 26 | * *count += det; 27 | * Assumes a call back at a period of 0.020sec 28 | */ 29 | void OSP_step_process(struct ThreeAxis *acc, struct StepInfo *step) 30 | { 31 | static int sampcnt = 0; /* Used for avaeraging */ 32 | static Q15_t x = 0, y = 0, z = 0; 33 | static Q15_t dAcc, sampleOld = 0, sampleNew = 0; 34 | Q15_t min = FP_to_Q15(10000.0f), max = FP_to_Q15(-10000.0f); 35 | static int lastStepSamp = 0; 36 | static int sampcnt2 = 0; 37 | static int regulation = 0; 38 | 39 | 40 | /* Process groups of 5 samples */ 41 | x += acc->x; y += acc->y; z+= acc->z; 42 | sampcnt++; 43 | sampcnt2++; 44 | 45 | step->detect = 0; 46 | 47 | if (sampcnt > 5) { 48 | sampcnt = 0; 49 | x = MUL_Q15(x, q15_0_20c); 50 | y = MUL_Q15(y, q15_0_20c); 51 | z = MUL_Q15(z, q15_0_20c); 52 | dAcc = MUL_Q15(x,x) + MUL_Q15(y,y) + MUL_Q15(z,z); 53 | dAcc = sqrt_q15(dAcc); 54 | sampleOld = sampleNew; 55 | if (abs_q15(dAcc - sampleNew) > sens_Const) 56 | sampleNew = dAcc; 57 | if ((sampleNew < threshold && 58 | sampleOld > threshold) && 59 | sampleOld != 0) { 60 | /* Cadence sanity check: 61 | * 0.2sec - 2sec between steps. 62 | */ 63 | if (lastStepSamp && 64 | (sampcnt2 - lastStepSamp) > 9 && 65 | (sampcnt2 - lastStepSamp) < 100) { 66 | /* Require 5 consecutive steps for validity */ 67 | regulation++; 68 | 69 | if (regulation == 5) { 70 | step->detect = 1; 71 | step->count += 5; 72 | } else if (regulation > 5) { 73 | step->detect = 1; 74 | step->count += 1; 75 | } 76 | } else { 77 | regulation = 0; 78 | } 79 | lastStepSamp = sampcnt2; 80 | } 81 | if (dAcc < min) min = dAcc; 82 | if (dAcc > max) max = dAcc; 83 | 84 | threshold = (max+min) >> 1; 85 | } 86 | 87 | /* Avoid wrap */ 88 | if (sampcnt2 > (1 << 30)) { 89 | if (lastStepSamp == 0) { 90 | sampcnt2 -= (1 << 30); 91 | } else if (lastStepSamp > 0 && lastStepSamp > (1<<30)) { 92 | sampcnt2 -= (1 << 30); 93 | lastStepSamp -= (1 << 30); 94 | } else if ((sampcnt2 - lastStepSamp) > 1000) { 95 | sampcnt2 -= (1 << 30); 96 | lastStepSamp = 0; 97 | } 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /scripts/generateVersionDotH.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import sys 3 | import subprocess 4 | import os 5 | import time 6 | import re 7 | 8 | # This script is used for auto-generation of OSP Firmware version based on the git tag available for the commit 9 | # Tags should have the format of _X.Y.Z or -X.Y.Z where is any string identifier e.g. "tag" or "release" 10 | # and X.Y.Z are Major.Minor.Patch decimal numbers. Examples of tag: "tag_OSP-1.1.16", "release-2.0.1" 11 | # If no git tag is available (e.g. for developer builds), version is set as 0.0.0.git# 12 | # This script needs Python 2.7 installed and in environment path to be able to run in windows/Linux 13 | # IMPORTANT: This script must be invoked as pre-build step to generate the header file that will be included 14 | # in the library sources 15 | 16 | def start(scriptpath): 17 | #scriptpath = os.path.dirname(os.path.realpath('__file__')) 18 | #os.chdir(scriptpath+"/../") 19 | 20 | #Set default values for version in case no tag exists on HEAD 21 | verMajor = 0 22 | verMinor = 0 23 | verPatch = 0 24 | 25 | ghash = subprocess.check_output("git rev-parse --short HEAD".split()).strip('\n') 26 | gtag = subprocess.check_output("git tag -l --contains HEAD".split()).strip('\n') 27 | if gtag: 28 | verList = re.split('_|-',gtag)[-1].split('.') 29 | if len(verList) >= 3: 30 | verMajor = int(verList[0]) 31 | verMinor = int(verList[1]) 32 | verPatch = int(verList[2]) 33 | 34 | tagVersion = "%d.%d.%d" %(verMajor,verMinor,verPatch) 35 | 36 | modified_files = subprocess.check_output("git status -s --porcelain".split() ) 37 | filelist = modified_files.split('\n') 38 | dirty = 0 39 | for afile in filelist: 40 | if not('??' in afile) and ('M' in afile): 41 | dirty = dirty+1 42 | if dirty > 0 : ghash = "%s#%d" %(ghash,dirty) 43 | 44 | with open(scriptpath+"/../include/"+"osp-sh-version.h","w") as outputfile: 45 | outputfile.write("/*\n * Auto-generated file! Do not edit and do not commit to git.\n */\n") 46 | outputfile.write("#ifndef __OSP_SH_VERSION_H\n") 47 | outputfile.write("#define __OSP_SH_VERSION_H\n\n") 48 | outputfile.write("#define SH_MODULE_NAME \"Open Sensor Platform Hub\"\n") 49 | outputfile.write("#define SH_VERSION_MAJOR %d\n" %(verMajor)) 50 | outputfile.write("#define SH_VERSION_MINOR %d\n" %(verMinor)) 51 | outputfile.write("#define SH_VERSION_PATCH %d\n" %(verPatch)) 52 | outputfile.write("#define SH_VERSION_STRING \"%s.%s\"\n" %(tagVersion,ghash.strip())) 53 | 54 | outputfile.write("\n#endif /* __OSP_SH_VERSION_H */\n") 55 | outputfile.write("/*\n * END OF FILE\n */\n") 56 | 57 | def main(): 58 | if len(sys.argv) > 0: 59 | start(os.path.dirname(os.path.realpath(sys.argv[0]))) 60 | sys.exit(0) 61 | 62 | 63 | if __name__ == '__main__': 64 | main() -------------------------------------------------------------------------------- /embedded/common/modules/sensor-drivers/acc_bmc150_i2c.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (ACC_BMC150_I2C_H) 19 | #define ACC_BMC150_I2C_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include "bma2x2.h" 25 | #include "bosch_i2c_adapter.h" 26 | 27 | /*-------------------------------------------------------------------------------------------------*\ 28 | | C O N S T A N T S & M A C R O S 29 | \*-------------------------------------------------------------------------------------------------*/ 30 | 31 | /*-------------------------------------------------------------------------------------------------*\ 32 | | T Y P E D E F I N I T I O N S 33 | \*-------------------------------------------------------------------------------------------------*/ 34 | 35 | /*-------------------------------------------------------------------------------------------------*\ 36 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 37 | \*-------------------------------------------------------------------------------------------------*/ 38 | 39 | /*-------------------------------------------------------------------------------------------------*\ 40 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 41 | \*-------------------------------------------------------------------------------------------------*/ 42 | 43 | /*-------------------------------------------------------------------------------------------------*\ 44 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 45 | \*-------------------------------------------------------------------------------------------------*/ 46 | 47 | 48 | #endif /* ACC_BMC150_I2C_H */ 49 | /*-------------------------------------------------------------------------------------------------*\ 50 | | E N D O F F I L E 51 | \*-------------------------------------------------------------------------------------------------*/ 52 | -------------------------------------------------------------------------------- /embedded/common/modules/sensor-drivers/mag_bmc150_i2c.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (MAG_BMC150_I2C_H) 19 | #define MAG_BMC150_I2C_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include "bmm050.h" 25 | #include "bosch_i2c_adapter.h" 26 | 27 | /*-------------------------------------------------------------------------------------------------*\ 28 | | C O N S T A N T S & M A C R O S 29 | \*-------------------------------------------------------------------------------------------------*/ 30 | 31 | /*-------------------------------------------------------------------------------------------------*\ 32 | | T Y P E D E F I N I T I O N S 33 | \*-------------------------------------------------------------------------------------------------*/ 34 | 35 | /*-------------------------------------------------------------------------------------------------*\ 36 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 37 | \*-------------------------------------------------------------------------------------------------*/ 38 | 39 | /*-------------------------------------------------------------------------------------------------*\ 40 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 41 | \*-------------------------------------------------------------------------------------------------*/ 42 | 43 | /*-------------------------------------------------------------------------------------------------*\ 44 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 45 | \*-------------------------------------------------------------------------------------------------*/ 46 | 47 | 48 | #endif /* MAG_BMC150_I2C_H */ 49 | /*-------------------------------------------------------------------------------------------------*\ 50 | | E N D O F F I L E 51 | \*-------------------------------------------------------------------------------------------------*/ 52 | -------------------------------------------------------------------------------- /embedded/common/modules/sensor-drivers/gyro_bmg160_i2c.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (GYRO_BMG160_I2C_H) 19 | #define GYRO_BMG160_I2C_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include "bmg160.h" 25 | #include "bosch_i2c_adapter.h" 26 | 27 | /*-------------------------------------------------------------------------------------------------*\ 28 | | C O N S T A N T S & M A C R O S 29 | \*-------------------------------------------------------------------------------------------------*/ 30 | 31 | /*-------------------------------------------------------------------------------------------------*\ 32 | | T Y P E D E F I N I T I O N S 33 | \*-------------------------------------------------------------------------------------------------*/ 34 | 35 | /*-------------------------------------------------------------------------------------------------*\ 36 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 37 | \*-------------------------------------------------------------------------------------------------*/ 38 | 39 | /*-------------------------------------------------------------------------------------------------*\ 40 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 41 | \*-------------------------------------------------------------------------------------------------*/ 42 | 43 | /*-------------------------------------------------------------------------------------------------*\ 44 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 45 | \*-------------------------------------------------------------------------------------------------*/ 46 | 47 | 48 | #endif /* GYRO_BMG160_I2C_H */ 49 | /*-------------------------------------------------------------------------------------------------*\ 50 | | E N D O F F I L E 51 | \*-------------------------------------------------------------------------------------------------*/ 52 | -------------------------------------------------------------------------------- /linux/sensorhubd/uinpututils.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef UINPUTUTILS_H 19 | #define UINPUTUTILS_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | 25 | /*-------------------------------------------------------------------------------------------------*\ 26 | | C O N S T A N T S & M A C R O S 27 | \*-------------------------------------------------------------------------------------------------*/ 28 | 29 | /*-------------------------------------------------------------------------------------------------*\ 30 | | T Y P E D E F I N I T I O N S 31 | \*-------------------------------------------------------------------------------------------------*/ 32 | 33 | /*-------------------------------------------------------------------------------------------------*\ 34 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 35 | \*-------------------------------------------------------------------------------------------------*/ 36 | 37 | /*-------------------------------------------------------------------------------------------------*\ 38 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 39 | \*-------------------------------------------------------------------------------------------------*/ 40 | 41 | /*-------------------------------------------------------------------------------------------------*\ 42 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 43 | \*-------------------------------------------------------------------------------------------------*/ 44 | int openInputEventDevice(const char* inputName); 45 | int openInputEventDeviceExt(const char* inputName, char *actual); 46 | 47 | #endif // UINPUTUTILS_H 48 | /*-------------------------------------------------------------------------------------------------*\ 49 | | E N D O F F I L E 50 | \*-------------------------------------------------------------------------------------------------*/ 51 | -------------------------------------------------------------------------------- /algorithm/osp/rotvec_precise.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2015 HY Research LLC 3 | * Author: hy-git@hy-research.com 4 | * 5 | * Apache License. 6 | * 7 | */ 8 | 9 | 10 | /* 11 | * Precise version of rotation vector using Q24's. 12 | * Based on Android implementation. Converted to fixed point. 13 | */ 14 | #include 15 | #include "fpsup.h" 16 | #include "fp_sensor.h" 17 | #include "rotvec.h" 18 | 19 | static Q24_t copysign_q24(Q24_t v, Q24_t s) 20 | { 21 | if (s < 0) return -v; 22 | else return v; 23 | } 24 | 25 | 26 | static Q24_t clamp_q24(Q24_t v) 27 | { 28 | if (v < 0) return 0; 29 | return v; 30 | } 31 | 32 | void OSP_rotvec_init() 33 | { 34 | } 35 | 36 | void OSP_rotvec_process( 37 | struct ThreeAxis *mag, 38 | struct ThreeAxis *acc, 39 | struct Quat_precise *rot) 40 | { 41 | Q24_t normH; 42 | Q24_t magMag2, accMag2; 43 | Q24_t invH, invA; 44 | Q24_t Hx, Hy, Hz; 45 | Q24_t Ax, Ay, Az; 46 | Q24_t Mx, My, Mz; 47 | Q24_t Ex, Ey, Ez; 48 | 49 | Q15_t qw, qx, qy, qz; 50 | 51 | Ax = q15_to_q24(acc->x); 52 | Ay = q15_to_q24(acc->y); 53 | Az = q15_to_q24(acc->z); 54 | 55 | Ex = q15_to_q24(mag->x); 56 | Ey = q15_to_q24(mag->y); 57 | Ez = q15_to_q24(mag->z); 58 | #if 0 59 | printf("RV using: Ax: %f Ay: %f: Az: %f, Mx: %f, My: %f, Mz: %f\n", 60 | Q15_to_FP(Ax), Q15_to_FP(Ay), Q15_to_FP(Az), 61 | Q15_to_FP(Ex), Q15_to_FP(Ey), Q15_to_FP(Ez)); 62 | #endif 63 | Hx = MUL_Q24(Ey, Az) - MUL_Q24(Ez, Ay); 64 | Hy = MUL_Q24(Ez, Ax) - MUL_Q24(Ex, Az); 65 | Hz = MUL_Q24(Ex, Ay) - MUL_Q24(Ey, Ax); 66 | 67 | magMag2 = MUL_Q24(Hx,Hx); 68 | magMag2 += MUL_Q24(Hy, Hy); 69 | magMag2 += MUL_Q24(Hz, Hz); 70 | 71 | normH = sqrt_q24(magMag2); 72 | 73 | if (normH < FP_to_Q24(0.1f)) { 74 | printf("Bad mag? %f\n", Q24_to_FP(normH)); 75 | return; 76 | } 77 | invH = RECIP_Q24(normH); 78 | 79 | accMag2 = MUL_Q24(Ax, Ax); 80 | accMag2 += MUL_Q24(Ay, Ay); 81 | accMag2 += MUL_Q24(Az, Az); 82 | 83 | invA = RECIP_Q24(sqrt_q24(accMag2)); 84 | 85 | Hx = MUL_Q24(Hx, invH); 86 | Hy = MUL_Q24(Hy, invH); 87 | Hz = MUL_Q24(Hz, invH); 88 | 89 | Ax = MUL_Q24(Ax, invA); 90 | Ay = MUL_Q24(Ay, invA); 91 | Az = MUL_Q24(Az, invA); 92 | 93 | Mx = MUL_Q24(Ay, Hz) - MUL_Q15(Az, Hy); 94 | My = MUL_Q24(Az, Hx) - MUL_Q15(Ax, Hz); 95 | Mz = MUL_Q24(Ax, Hy) - MUL_Q15(Ay, Hx); 96 | 97 | qw = sqrt_q24(MUL_Q24(clamp_q24( Hx+My+Az+q24_c1), q24_quarter)); 98 | qx = sqrt_q24(MUL_Q24(clamp_q24( Hx-My-Az+q24_c1), q24_quarter)); 99 | qy = sqrt_q24(MUL_Q24(clamp_q24(-Hx+My-Az+q24_c1), q24_quarter)); 100 | qz = sqrt_q24(MUL_Q24(clamp_q24(-Hx-My+Az+q24_c1), q24_quarter)); 101 | 102 | qx = copysign_q24(qx, Ay - Mz); 103 | qy = copysign_q24(qy, Hz - Ax); 104 | qz = copysign_q24(qz, Mx - Hy); 105 | 106 | rot->x = qx; 107 | rot->y = qy; 108 | rot->z = qz; 109 | rot->w = qw; 110 | } 111 | -------------------------------------------------------------------------------- /embedded/projects/SH-Xpresso-LPC54102/sources/app/hostif_i2c.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2015 Audience Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (HOSTIF_I2C_H) 19 | #define HOSTIF_I2C_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | 25 | /*-------------------------------------------------------------------------------------------------*\ 26 | | C O N S T A N T S & M A C R O S 27 | \*-------------------------------------------------------------------------------------------------*/ 28 | 29 | /*-------------------------------------------------------------------------------------------------*\ 30 | | T Y P E D E F I N I T I O N S 31 | \*-------------------------------------------------------------------------------------------------*/ 32 | 33 | /*-------------------------------------------------------------------------------------------------*\ 34 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 35 | \*-------------------------------------------------------------------------------------------------*/ 36 | 37 | /*-------------------------------------------------------------------------------------------------*\ 38 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 39 | \*-------------------------------------------------------------------------------------------------*/ 40 | 41 | /*-------------------------------------------------------------------------------------------------*\ 42 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 43 | \*-------------------------------------------------------------------------------------------------*/ 44 | void Hostif_I2C_Init(void); 45 | void Hostif_QueueTx(uint8_t *pBuf, uint16_t size); 46 | uint32_t Hostif_Process(void); 47 | 48 | 49 | #endif /* HOSTIF_I2C_H */ 50 | /*-------------------------------------------------------------------------------------------------*\ 51 | | E N D O F F I L E 52 | \*-------------------------------------------------------------------------------------------------*/ 53 | -------------------------------------------------------------------------------- /algorithm/osp/SecondOrderLPF.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2015 HY Research LLC 3 | * Author: hy-git@hy-research.com 4 | * 5 | * Apache License. 6 | * 7 | * Second order IIR BiCubicFilter. based on 8 | * Implementation from Android AOSP. 9 | */ 10 | 11 | #include 12 | #include "string.h" 13 | #include "fpsup.h" 14 | #include "lpf.h" 15 | #if 0 16 | struct LPF { 17 | Q15_t iQ; 18 | Q15_t fc; 19 | Q15_t K; 20 | Q15_t iD; 21 | Q15_t a0; 22 | Q15_t a1; 23 | Q15_t b1; 24 | Q15_t b2; 25 | 26 | Q15_t x1; 27 | Q15_t x2; 28 | Q15_t y1; 29 | Q15_t y2; 30 | }; 31 | 32 | struct LPF_CBQF { 33 | struct LPF mA; 34 | struct LPF mB; 35 | }; 36 | #endif 37 | 38 | void LPF_init(struct LPF *lpf, Q15_t Q, Q15_t fc) 39 | { 40 | lpf->iQ = RECIP_Q15(Q); 41 | lpf->fc = fc; 42 | } 43 | 44 | void LPF_setSamplingPeriod(struct LPF *lpf, Q15_t dT) 45 | { 46 | 47 | Q15_t tmp, k2; 48 | #if 1 49 | tmp = MUL_Q15(q15_pi, lpf->fc); 50 | tmp = MUL_Q15(tmp, dT); 51 | #else 52 | tmp = MUL_Q15(q15_pi, q15_c1); 53 | #endif 54 | lpf->K = tan_q15(tmp); 55 | k2 = MUL_Q15(lpf->K, lpf->K); 56 | 57 | lpf->iD = RECIP_Q15(k2 + MUL_Q15(lpf->K, lpf->iQ) + q15_c1); 58 | lpf->a0 = MUL_Q15(k2, lpf->iD); 59 | lpf->a1 = MUL_Q15(q15_c2, lpf->a0); 60 | lpf->b1 = MUL_Q15(q15_c2, lpf->iD); 61 | lpf->b1 = MUL_Q15(k2 - q15_c1, lpf->b1); 62 | lpf->b2 = MUL_Q15(lpf->iD, (k2 - MUL_Q15(lpf->K, lpf->iQ) + q15_c1)); 63 | } 64 | 65 | Q15_t LPF_BQF_init(struct LPF *lpf, Q15_t x) 66 | { 67 | lpf->x1 = x; 68 | lpf->x2 = x; 69 | 70 | lpf->y1 = x; 71 | lpf->y2 = x; 72 | 73 | return x; 74 | } 75 | 76 | Q15_t LPF_BQF_data(struct LPF *lpf, Q15_t x) 77 | { 78 | Q15_t y; 79 | 80 | y = MUL_Q15((x+lpf->x2), lpf->a0); 81 | y += MUL_Q15(lpf->x1, lpf->a1); 82 | y -= MUL_Q15(lpf->y1, lpf->b1); 83 | y -= MUL_Q15(lpf->y2, lpf->b2); 84 | 85 | lpf->x2 = lpf->x1; 86 | lpf->y2 = lpf->y1; 87 | lpf->x1 = x; 88 | lpf->y1 = y; 89 | 90 | return y; 91 | } 92 | 93 | 94 | void LPF_CBQF_init(struct LPF_CBQF *clpf, struct LPF *lpf, Q15_t x) 95 | { 96 | memcpy(&clpf->mA, lpf, sizeof(struct LPF)); 97 | memcpy(&clpf->mB, lpf, sizeof(struct LPF)); 98 | 99 | LPF_BQF_init(&clpf->mA, x); 100 | LPF_BQF_init(&clpf->mB, x); 101 | } 102 | 103 | 104 | Q15_t LPF_CBQF_data(struct LPF_CBQF *clpf, Q15_t x) 105 | { 106 | return LPF_BQF_data(&clpf->mB, LPF_BQF_data(&clpf->mA, x)); 107 | } 108 | 109 | #if 0 110 | int main(int argc, char **argv) 111 | { 112 | struct LPF lpf; 113 | struct LPF_CBQF clpf; 114 | Q15_t d; 115 | 116 | int i; 117 | 118 | LPF_init(&lpf,FP_to_Q15(0.707107f), FP_to_Q15(1.5f)); 119 | LPF_setSamplingPeriod(&lpf, FP_to_Q15(0.020f)); 120 | LPF_CBQF_init(&clpf, &lpf, FP_to_Q15(9.8f)); 121 | 122 | for (i = 0; i < 200; i++) { 123 | d = LPF_CBQF_data(&clpf, FP_to_Q15(9.8f)); 124 | printf("Data: %f\n", Q15_to_FP(d)); 125 | } 126 | } 127 | #endif 128 | -------------------------------------------------------------------------------- /embedded/common/asf/asf_tdefmacros.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | /* This file maybe included more than once */ 19 | 20 | /* 21 | ** ASF_TASK_DEF_TYPE should be defined to be either 22 | ** 23 | ** ASF_TASK_IDS 24 | ** ASF_QUEUE_IDS 25 | ** ASF_STACK_SETUP 26 | ** ASF_TASK_SETUP 27 | ** ASF_TASK_DECLARE 28 | ** 29 | ** by the including file 30 | */ 31 | 32 | 33 | /*-------------------------------------------------------------------------------------------------*\ 34 | | C O N S T A N T S & M A C R O S 35 | \*-------------------------------------------------------------------------------------------------*/ 36 | #if !defined (IN_ASF_TASK_DEF) 37 | # error This file can only be included in ASF_TaskDefType.h 38 | #endif 39 | 40 | #if ASF_TASK_DEF_TYPE == ASF_TASK_IDS 41 | # define ASF_TASK_STATIC( ThreadId, EntryFunction, Priority, StackSize, QueueSize ) ThreadId, 42 | #endif 43 | 44 | #if ASF_TASK_DEF_TYPE == ASF_STACK_SETUP 45 | # define ASF_TASK_STATIC( ThreadId, EntryFunction, Priority, StackSize, QueueSize ) \ 46 | const uint32_t ThreadId##_StkSize = StackSize; 47 | #endif 48 | 49 | #if ASF_TASK_DEF_TYPE == ASF_QUEUE_SETUP 50 | # define ASF_TASK_STATIC( ThreadId, EntryFunction, Priority, StackSize, QueueSize ) \ 51 | os_mbx_declare( Q_##ThreadId, QueueSize ); 52 | #endif 53 | 54 | #if ASF_TASK_DEF_TYPE == ASF_TASK_DECLARE 55 | # define ASF_TASK_STATIC( ThreadId, EntryFunction, Priority, StackSize, QueueSize ) \ 56 | extern void EntryFunction(void); 57 | #endif 58 | 59 | #if ASF_TASK_DEF_TYPE == ASF_TASK_SETUP 60 | # define ASF_TASK_STATIC( ThreadId, EntryFunction, Priority, StackSize, QueueSize ) \ 61 | { ThreadId, EntryFunction, #EntryFunction, Q_##ThreadId, sizeof(Q_##ThreadId), StackSize, Priority, #ThreadId }, 62 | #endif 63 | 64 | #if ASF_TASK_DEF_TYPE == ASF_TOTAL_STACK_NEEDED 65 | # define ASF_TASK_STATIC( ThreadId, EntryFunction, Priority, StackSize, QueueSize ) \ 66 | +ThreadId##_StkSize 67 | #endif 68 | 69 | 70 | /*-------------------------------------------------------------------------------------------------*\ 71 | | E N D O F F I L E 72 | \*-------------------------------------------------------------------------------------------------*/ 73 | -------------------------------------------------------------------------------- /embedded/projects/SH-Xpresso-LPC54102/sources/app/appversion.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2015 Audience Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (APP_VERSION_H) 19 | #define APP_VERSION_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | 25 | /*-------------------------------------------------------------------------------------------------*\ 26 | | C O N S T A N T S & M A C R O S 27 | \*-------------------------------------------------------------------------------------------------*/ 28 | #define APP_MODULE_NAME "OSP LPC54102 Xpresso" 29 | #define APP_VERSION_MAJOR 0 30 | #define APP_VERSION_MINOR 7 31 | #define APP_VERSION_PATCH 0 32 | 33 | #define APP_VERSION_STRING "0.7.0" 34 | 35 | /*-------------------------------------------------------------------------------------------------*\ 36 | | T Y P E D E F I N I T I O N S 37 | \*-------------------------------------------------------------------------------------------------*/ 38 | 39 | /*-------------------------------------------------------------------------------------------------*\ 40 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 41 | \*-------------------------------------------------------------------------------------------------*/ 42 | 43 | /*-------------------------------------------------------------------------------------------------*\ 44 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 45 | \*-------------------------------------------------------------------------------------------------*/ 46 | 47 | /*-------------------------------------------------------------------------------------------------*\ 48 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 49 | \*-------------------------------------------------------------------------------------------------*/ 50 | 51 | 52 | #endif /* APP_VERSION_H */ 53 | /*-------------------------------------------------------------------------------------------------*\ 54 | | E N D O F F I L E 55 | \*-------------------------------------------------------------------------------------------------*/ 56 | -------------------------------------------------------------------------------- /embedded/projects/osp-steval-mki109v2/sources/app/appversion.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (APP_VERSION_H) 19 | #define APP_VERSION_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | 25 | /*-------------------------------------------------------------------------------------------------*\ 26 | | C O N S T A N T S & M A C R O S 27 | \*-------------------------------------------------------------------------------------------------*/ 28 | #define APP_MODULE_NAME "OSP STEVAL-MKI109V2" 29 | #define APP_VERSION_MAJOR 0 30 | #define APP_VERSION_MINOR 7 31 | #define APP_VERSION_PATCH 0 32 | 33 | #define APP_VERSION_STRING "0.7.0" 34 | 35 | /*-------------------------------------------------------------------------------------------------*\ 36 | | T Y P E D E F I N I T I O N S 37 | \*-------------------------------------------------------------------------------------------------*/ 38 | 39 | /*-------------------------------------------------------------------------------------------------*\ 40 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 41 | \*-------------------------------------------------------------------------------------------------*/ 42 | 43 | /*-------------------------------------------------------------------------------------------------*\ 44 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 45 | \*-------------------------------------------------------------------------------------------------*/ 46 | 47 | /*-------------------------------------------------------------------------------------------------*\ 48 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 49 | \*-------------------------------------------------------------------------------------------------*/ 50 | 51 | 52 | #endif /* APP_VERSION_H */ 53 | /*-------------------------------------------------------------------------------------------------*\ 54 | | E N D O F F I L E 55 | \*-------------------------------------------------------------------------------------------------*/ 56 | -------------------------------------------------------------------------------- /embedded/common/modules/sensor-drivers/Bosch_I2C_Adapter.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (BOSCH_I2C_ADAPTER_H) 19 | #define BOSCH_I2C_ADAPTER_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | 25 | /*-------------------------------------------------------------------------------------------------*\ 26 | | C O N S T A N T S & M A C R O S 27 | \*-------------------------------------------------------------------------------------------------*/ 28 | 29 | /*-------------------------------------------------------------------------------------------------*\ 30 | | T Y P E D E F I N I T I O N S 31 | \*-------------------------------------------------------------------------------------------------*/ 32 | 33 | /*-------------------------------------------------------------------------------------------------*\ 34 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 35 | \*-------------------------------------------------------------------------------------------------*/ 36 | 37 | /*-------------------------------------------------------------------------------------------------*\ 38 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 39 | \*-------------------------------------------------------------------------------------------------*/ 40 | 41 | /*-------------------------------------------------------------------------------------------------*\ 42 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 43 | \*-------------------------------------------------------------------------------------------------*/ 44 | void dev_i2c_delay(unsigned int msec); 45 | char dev_i2c_write(unsigned char dev_addr,unsigned char reg_addr, unsigned char *reg_data, unsigned char cnt); 46 | char dev_i2c_read(unsigned char dev_addr,unsigned char reg_addr, unsigned char *reg_data, unsigned char cnt); 47 | 48 | 49 | #endif /* BOSCH_I2C_ADAPTER_H */ 50 | /*-------------------------------------------------------------------------------------------------*\ 51 | | E N D O F F I L E 52 | \*-------------------------------------------------------------------------------------------------*/ 53 | -------------------------------------------------------------------------------- /embedded/projects/SH-Xpresso-LPC54102/sources/boardsupport/SPI_SlaveDriver.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2015 Audience Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (SPI_SLAVEDRIVER_H) 19 | #define SPI_SLAVEDRIVER_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | 25 | /*-------------------------------------------------------------------------------------------------*\ 26 | | C O N S T A N T S & M A C R O S 27 | \*-------------------------------------------------------------------------------------------------*/ 28 | #define DummyData 0x00 // Dummy data during read 29 | 30 | #define DECLARE_INTR_SAVE() int wasMasked 31 | #define SPI_ENTER_CRITICAL() wasMasked = __disable_irq() 32 | #define SPI_LEAVE_CRITICAL() if (!wasMasked) __enable_irq() 33 | 34 | /*-------------------------------------------------------------------------------------------------*\ 35 | | T Y P E D E F I N I T I O N S 36 | \*-------------------------------------------------------------------------------------------------*/ 37 | 38 | /*-------------------------------------------------------------------------------------------------*\ 39 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 40 | \*-------------------------------------------------------------------------------------------------*/ 41 | 42 | /*-------------------------------------------------------------------------------------------------*\ 43 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 44 | \*-------------------------------------------------------------------------------------------------*/ 45 | 46 | /*-------------------------------------------------------------------------------------------------*\ 47 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 48 | \*-------------------------------------------------------------------------------------------------*/ 49 | void SPISlaveDriverInit( void ); 50 | void SPISlaveSetup( void ); 51 | 52 | 53 | #endif /* SPI_SLAVEDRIVER_H */ 54 | /*-------------------------------------------------------------------------------------------------*\ 55 | | E N D O F F I L E 56 | \*-------------------------------------------------------------------------------------------------*/ 57 | -------------------------------------------------------------------------------- /include/osp-version.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2015 Audience Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (_OSP_VERSION_H_) 19 | #define _OSP_VERSION_H_ 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | 25 | /*-------------------------------------------------------------------------------------------------*\ 26 | | C O N S T A N T S & M A C R O S 27 | \*-------------------------------------------------------------------------------------------------*/ 28 | /* Following is the version information for the OSP APIs, not to be confused with the Sensor Hub 29 | * Application version. 30 | */ 31 | #define OSP_MODULE_NAME "Open Sensor Platform API" 32 | #define OSP_VERSION_MAJOR 1 33 | #define OSP_VERSION_MINOR 0 34 | #define OSP_VERSION_PATCH 0 35 | 36 | #define OSP_VERSION_STRING "1.0.0" 37 | 38 | /*-------------------------------------------------------------------------------------------------*\ 39 | | T Y P E D E F I N I T I O N S 40 | \*-------------------------------------------------------------------------------------------------*/ 41 | 42 | /*-------------------------------------------------------------------------------------------------*\ 43 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 44 | \*-------------------------------------------------------------------------------------------------*/ 45 | 46 | /*-------------------------------------------------------------------------------------------------*\ 47 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 48 | \*-------------------------------------------------------------------------------------------------*/ 49 | 50 | /*-------------------------------------------------------------------------------------------------*\ 51 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 52 | \*-------------------------------------------------------------------------------------------------*/ 53 | 54 | 55 | #endif /* _OSP_VERSION_H_ */ 56 | /*-------------------------------------------------------------------------------------------------*\ 57 | | E N D O F F I L E 58 | \*-------------------------------------------------------------------------------------------------*/ 59 | -------------------------------------------------------------------------------- /embedded/common/modules/sensor-drivers/mag_common.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (MAG_COMMON_H) 19 | #define MAG_COMMON_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include "common.h" 25 | 26 | /*-------------------------------------------------------------------------------------------------*\ 27 | | C O N S T A N T S & M A C R O S 28 | \*-------------------------------------------------------------------------------------------------*/ 29 | 30 | /*-------------------------------------------------------------------------------------------------*\ 31 | | T Y P E D E F I N I T I O N S 32 | \*-------------------------------------------------------------------------------------------------*/ 33 | typedef MsgMagData MagData_t; 34 | 35 | /*-------------------------------------------------------------------------------------------------*\ 36 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 37 | \*-------------------------------------------------------------------------------------------------*/ 38 | 39 | /*-------------------------------------------------------------------------------------------------*\ 40 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 41 | \*-------------------------------------------------------------------------------------------------*/ 42 | 43 | /*-------------------------------------------------------------------------------------------------*\ 44 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 45 | \*-------------------------------------------------------------------------------------------------*/ 46 | void Mag_HardwareSetup( osp_bool_t enable ); 47 | void Mag_Initialize( void ); 48 | void Mag_ReadData( MagData_t *pxyzData ); 49 | void Mag_ClearDataInt( void ); 50 | void Mag_ConfigDataInt( osp_bool_t enInt ); 51 | void Mag_ResetDevice( void ); 52 | osp_bool_t Mag_SelfTest( void ); 53 | void Mag_TriggerDataAcq( void ); 54 | void Mag_SetLowPowerMode( void ); 55 | 56 | 57 | #endif /* MAG_COMMON_H */ 58 | /*-------------------------------------------------------------------------------------------------*\ 59 | | E N D O F F I L E 60 | \*-------------------------------------------------------------------------------------------------*/ 61 | -------------------------------------------------------------------------------- /embedded/common/asf/asf_types.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (ASF_TYPES_H) 19 | #define ASF_TYPES_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include 25 | #include "rtl.h" 26 | 27 | /*-------------------------------------------------------------------------------------------------*\ 28 | | C O N S T A N T S & M A C R O S 29 | \*-------------------------------------------------------------------------------------------------*/ 30 | 31 | /*-------------------------------------------------------------------------------------------------*\ 32 | | T Y P E D E F I N I T I O N S 33 | \*-------------------------------------------------------------------------------------------------*/ 34 | /* 35 | * Task Handle type. This type is OS-dependent. 36 | */ 37 | typedef struct AsfTaskHandleTag { 38 | OS_TID handle; 39 | void *pStack; 40 | uint16_t stkSize; 41 | } AsfTaskHandle; 42 | 43 | /* 44 | * Semaphore ID type. This type is OS-dependent. 45 | */ 46 | typedef OS_SEM* AsfSemIdType; 47 | 48 | /* 49 | * Timer ID type. This type is OS-dependent. 50 | */ 51 | typedef OS_ID TimerId; 52 | 53 | 54 | /*-------------------------------------------------------------------------------------------------*\ 55 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 56 | \*-------------------------------------------------------------------------------------------------*/ 57 | 58 | /*-------------------------------------------------------------------------------------------------*\ 59 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 60 | \*-------------------------------------------------------------------------------------------------*/ 61 | 62 | /*-------------------------------------------------------------------------------------------------*\ 63 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 64 | \*-------------------------------------------------------------------------------------------------*/ 65 | 66 | 67 | #endif /* ASF_TYPES_H */ 68 | /*-------------------------------------------------------------------------------------------------*\ 69 | | E N D O F F I L E 70 | \*-------------------------------------------------------------------------------------------------*/ 71 | -------------------------------------------------------------------------------- /embedded/common/modules/sensor-drivers/acc_common.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (ACC_COMMON_H) 19 | #define ACC_COMMON_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include "common.h" 25 | 26 | /*-------------------------------------------------------------------------------------------------*\ 27 | | C O N S T A N T S & M A C R O S 28 | \*-------------------------------------------------------------------------------------------------*/ 29 | 30 | /*-------------------------------------------------------------------------------------------------*\ 31 | | T Y P E D E F I N I T I O N S 32 | \*-------------------------------------------------------------------------------------------------*/ 33 | typedef enum AccelInitOptionTag 34 | { 35 | INIT_NORMAL, 36 | INIT_MOTION_SENSE, 37 | INIT_SLEEP, 38 | } AccelInitOption; 39 | 40 | /*-------------------------------------------------------------------------------------------------*\ 41 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 42 | \*-------------------------------------------------------------------------------------------------*/ 43 | 44 | /*-------------------------------------------------------------------------------------------------*\ 45 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 46 | \*-------------------------------------------------------------------------------------------------*/ 47 | 48 | /*-------------------------------------------------------------------------------------------------*\ 49 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 50 | \*-------------------------------------------------------------------------------------------------*/ 51 | void Accel_HardwareSetup( osp_bool_t initOption ); 52 | void Accel_Initialize( AccelInitOption option ); 53 | void Accel_ReadData( AccelData_t *pxyzData ); 54 | void Accel_ClearDataInt( void ); 55 | void Accel_ConfigDataInt( osp_bool_t enInt ); 56 | void Accel_ResetDevice( void ); 57 | osp_bool_t Accel_SelfTest( void ); 58 | 59 | 60 | #endif /* ACC_COMMON_H */ 61 | /*-------------------------------------------------------------------------------------------------*\ 62 | | E N D O F F I L E 63 | \*-------------------------------------------------------------------------------------------------*/ 64 | -------------------------------------------------------------------------------- /embedded/common/modules/sensor-drivers/gyro_common.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (GYRO_COMMON_H) 19 | #define GYRO_COMMON_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include "common.h" 25 | 26 | /*-------------------------------------------------------------------------------------------------*\ 27 | | C O N S T A N T S & M A C R O S 28 | \*-------------------------------------------------------------------------------------------------*/ 29 | 30 | /*-------------------------------------------------------------------------------------------------*\ 31 | | T Y P E D E F I N I T I O N S 32 | \*-------------------------------------------------------------------------------------------------*/ 33 | typedef MsgGyroData GyroData_t; 34 | 35 | /*-------------------------------------------------------------------------------------------------*\ 36 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 37 | \*-------------------------------------------------------------------------------------------------*/ 38 | 39 | /*-------------------------------------------------------------------------------------------------*\ 40 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 41 | \*-------------------------------------------------------------------------------------------------*/ 42 | 43 | /*-------------------------------------------------------------------------------------------------*\ 44 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 45 | \*-------------------------------------------------------------------------------------------------*/ 46 | void Gyro_HardwareSetup( osp_bool_t enable ); 47 | void Gyro_Initialize( void ); 48 | void Gyro_ReadData( GyroData_t *pxyzData ); 49 | void Gyro_WaitDataReady( uint16_t timeOut ); 50 | void Gyro_ClearDataInt( void ); 51 | void Gyro_ConfigDataInt( osp_bool_t enInt ); 52 | void Gyro_ResetDevice( void ); 53 | osp_bool_t Gyro_SelfTest( void ); 54 | void Gyro_TriggerDataAcq( void ); 55 | void Gyro_SetLowPowerMode( void ); 56 | 57 | 58 | #endif /* GYRO_COMMON_H */ 59 | /*-------------------------------------------------------------------------------------------------*\ 60 | | E N D O F F I L E 61 | \*-------------------------------------------------------------------------------------------------*/ 62 | -------------------------------------------------------------------------------- /embedded/common/app/hw_setup.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (HW_SETUP_H) 19 | #define HW_SETUP_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | 25 | #ifdef DISCOVERY_L1_BOARD 26 | # include "hw_setup_discovery_l1.h" 27 | #endif 28 | 29 | #ifdef STEVAL_MKI109V2 30 | # include "hw_setup_steval_mki109v2.h" 31 | #endif 32 | 33 | #ifdef XPRESSO_LPC54102_BOARD 34 | # include "hw_setup_xpresso_lpc54102.h" 35 | #endif 36 | 37 | /*-------------------------------------------------------------------------------------------------*\ 38 | | C O N S T A N T S & M A C R O S 39 | \*-------------------------------------------------------------------------------------------------*/ 40 | 41 | /*-------------------------------------------------------------------------------------------------*\ 42 | | T Y P E D E F I N I T I O N S 43 | \*-------------------------------------------------------------------------------------------------*/ 44 | 45 | /*-------------------------------------------------------------------------------------------------*\ 46 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 47 | \*-------------------------------------------------------------------------------------------------*/ 48 | 49 | /*-------------------------------------------------------------------------------------------------*\ 50 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 51 | \*-------------------------------------------------------------------------------------------------*/ 52 | 53 | /*-------------------------------------------------------------------------------------------------*\ 54 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 55 | \*-------------------------------------------------------------------------------------------------*/ 56 | void SystemGPIOConfig( void ); 57 | void SystemInterruptConfig( void ); 58 | void DebugPortInit( void ); 59 | void DebugUARTConfig( uint32_t baud, uint32_t dataLen, uint32_t stopBits, uint32_t parity ); 60 | void RTC_Configuration( void ); 61 | 62 | 63 | #endif /* HW_SETUP_H */ 64 | /*-------------------------------------------------------------------------------------------------*\ 65 | | E N D O F F I L E 66 | \*-------------------------------------------------------------------------------------------------*/ 67 | -------------------------------------------------------------------------------- /embedded/common/asf/asf_tasks.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | /* This file maybe included more than once */ 19 | 20 | /*-------------------------------------------------------------------------------------------------*\ 21 | | C O N S T A N T S & M A C R O S 22 | \*-------------------------------------------------------------------------------------------------*/ 23 | /** 24 | ** ASF_TASK_STATIC ( ThreadId, EntryFunction, Priority, StackSize, QueueSize ) 25 | ** This macro declares a static thread that will be created (along with an 26 | ** associated queue) automatically by the ASF startup initialization and 27 | ** will persist throughout the lifetime of the application. 28 | ** 29 | ** Parameters: 30 | ** ThreadId - User defined C-Style identifier for the thread. 31 | ** E.g. MY_THREAD_ID. This identifier will be used in the 32 | ** application to access the thread properties and its 33 | ** associated queue. 34 | ** EntryFunction - Thread entry function name. 35 | ** Priority - Thread priority in the range of 51 through 254. Higher value 36 | ** implies higher priority. Values 0 through 50 are reserved and 37 | ** should not be used. 38 | ** StackSize - Thread stack size in bytes. 39 | ** QueueSize - This denotes the maximum number of messages that are allowed 40 | ** to be queued for the thread. An optimum value should be 41 | ** chosen for this parameter to minimize memory wastage. 42 | ** 43 | ** Example: ASF_TASK_STATIC ( COMM_THREAD, CommThreadEntry, 55, 1024, 10 ) 44 | ** 45 | ** Entry Function must be declared in the following manner: 46 | ** ASF_TASK MyThreadEntry ( ASF_TASK_ARG ) 47 | ** { 48 | ** ... 49 | ** } 50 | ** 51 | */ 52 | /* Declare all ASF tasks here */ 53 | /* This task creates other tasks and OS resources and must always be present */ 54 | ASF_TASK_STATIC ( INSTR_MANAGER_TASK_ID, InstrManagerTask, 50, 0x400, 4 ) 55 | 56 | /* Handles command input from UART */ 57 | ASF_TASK_STATIC ( CMD_HNDLR_TASK_ID, CmdHandlerTask, 92, 0x400, 4 ) 58 | 59 | /* Additional tasks specific to application is defined in App_Tasks.h */ 60 | #include "app_tasks.h" 61 | 62 | 63 | /*-------------------------------------------------------------------------------------------------*\ 64 | | E N D O F F I L E 65 | \*-------------------------------------------------------------------------------------------------*/ 66 | -------------------------------------------------------------------------------- /external/MCU/NXP-5410x/CSLib/Inc/rtc_ut.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @brief RTC tick to (a more) Universal Time 3 | * Adds conversion functions to use an RTC that only provides a 4 | * seconds capability to provide "struct tm" support. 5 | * 6 | * @note 7 | * Copyright(C) NXP Semiconductors, 2014 8 | * All rights reserved. 9 | * 10 | * @par 11 | * Software that is described herein is for illustrative purposes only 12 | * which provides customers with programming information regarding the 13 | * LPC products. This software is supplied "AS IS" without any warranties of 14 | * any kind, and NXP Semiconductors and its licenser disclaim any and 15 | * all warranties, express or implied, including all implied warranties of 16 | * merchantability, fitness for a particular purpose and non-infringement of 17 | * intellectual property rights. NXP Semiconductors assumes no responsibility 18 | * or liability for the use of the software, conveys no license or rights under any 19 | * patent, copyright, mask work right, or any other intellectual property rights in 20 | * or to any products. NXP Semiconductors reserves the right to make changes 21 | * in the software without notification. NXP Semiconductors also makes no 22 | * representation or warranty that such application will be suitable for the 23 | * specified use without further testing or modification. 24 | * 25 | * @par 26 | * Permission to use, copy, modify, and distribute this software and its 27 | * documentation is hereby granted, under NXP Semiconductors' and its 28 | * licensor's relevant copyrights in the software, without fee, provided that it 29 | * is used in conjunction with NXP Semiconductors microcontrollers. This 30 | * copyright, permission, and disclaimer notice must appear in all copies of 31 | * this code. 32 | */ 33 | 34 | #ifndef __RTC_UT_H_ 35 | #define __RTC_UT_H_ 36 | 37 | #include "chip.h" 38 | #include 39 | #include 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** @defgroup RTC_UT CHIP: RTC tick to (a more) Universal Time conversion functions 46 | * @ingroup CHIP_Common 47 | * This driver converts between a RTC 1-second tick value and 48 | * a Universal time format in a structure of type 'struct tm'. 49 | * @{ 50 | */ 51 | 52 | /* Starting year and starting day of week for the driver */ 53 | #define TM_YEAR_BASE (1900) 54 | #define TM_DAYOFWEEK (1) 55 | 56 | /** 57 | * @brief Converts a RTC tick time to Universal time 58 | * @param rtcTick : Current RTC time value 59 | * @param pTime : Pointer to time structure to fill 60 | * @return Nothing 61 | * @note When setting time, the 'tm_wday', 'tm_yday', and 'tm_isdst' 62 | * fields are not used. 63 | */ 64 | void ConvertRtcTime(uint32_t rtcTick, struct tm *pTime); 65 | 66 | /** 67 | * @brief Converts a Universal time to RTC tick time 68 | * @param pTime : Pointer to time structure to use 69 | * @param rtcTick : Pointer to RTC time value to fill 70 | * @return Nothing 71 | * @note When converting time, the 'tm_isdst' field is not 72 | * populated by the conversion function. 73 | */ 74 | void ConvertTimeRtc(struct tm *pTime, uint32_t *rtcTick); 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | 84 | #endif /* __RTC_UT_H_ */ 85 | -------------------------------------------------------------------------------- /docs/osp-api-docs.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | /*! 20 | \mainpage Overview 21 | 22 | This documentation describes the Open-Sensor-Platform (OSP) project 23 | for a resource constrained Sensor Hub or Smart Sensor device. The 24 | following figures show the aspects of OSP provided in Android and in an 25 | embedded core. 26 | 27 | \image html osp_framework.png 28 | \image latex osp_android_framework.png 29 | \image latex osp_hub_framework.png 30 | 31 |

API Reference

32 | Functions 33 |
34 | Data Structures 35 |
36 | 37 | 38 |

High Level Usage Overview

39 | At boot time: 40 | - get sensor calibration data from non-volatile memory or the host 41 | - call OSP_Initialize() 42 | - let the Library know about what sensors are on the system by filling in a SensorDescriptor_t and calling OSP_RegisterInputSensor() for each sensor 43 | 44 | During steady state operation: 45 | - queue data from sensor ISRs by calling OSP_SetData() 46 | - execute primary fusion computation by calling OSP_DoForegroundProcessing() at least twice as fast as your max expected output rate 47 | - execute calibration computation by calling OSP_DoBackgroundProcessing() at least as fast as your min expected output rate 48 | - as enable commands come from the host construct an appropriate SensorDescriptor_t and call OSP_SubscribeOutputSensor() to start receiving data callbacks 49 | - as disable commands come from the host call OSP_UnsubscribeOutputSensor() 50 | - as setDelay commands come from the host do an appropriate OSP_UnsubscribeOutputSensor(), update the OutputDataRate, then call OSP_SubscribeOutputSensor() 51 | 52 | Data will be returned via callbacks: 53 | - Sensor fusion will call your callbacks with output sensor data (Device Orientation Rotation Vector, Calibrated Magnetometer Data, etc) 54 | - ResourceManager will provide callbacks for enabling/disabling/rate changing input sensor drivers 55 | - Errors and warnings are also available via callbacks 56 | - When sensor calibration callbacks fire, store the calibration parameters to non-volatile memory locally or on the host 57 | 58 | 59 |

Examples

60 |

Step Example

61 | Simplified example demonstrating step counting. Uses simulated data, and can be used as a benchmark 62 | 63 | step-example 64 | 65 | 66 | */ 67 | /*! 68 | * \example main.c 69 | * Simplified example demonstrating step counting. Uses simulated data, and can be used as a benchmark 70 | * 71 | * 72 | */ 73 | -------------------------------------------------------------------------------- /linux/sensorhubd/osp_debuglogging.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef OSP_DEBUGLOGGING_H 19 | #define OSP_DEBUGLOGGING_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include 25 | 26 | /*-------------------------------------------------------------------------------------------------*\ 27 | | C O N S T A N T S & M A C R O S 28 | \*-------------------------------------------------------------------------------------------------*/ 29 | #ifdef NDEBUG 30 | # define LOGI(...) 31 | # define LOGT(...) /* Function trace log */ 32 | # define LOGS(...) /* Sensor data log */ 33 | # define LOG_Info(...) 34 | #else 35 | # define LOG_Err LOGE 36 | # define LOG_Info LOGI 37 | # define LOGT(...) fprintf(stderr, __VA_ARGS__) 38 | # define LOGS(...) /* printf(__VA_ARGS__) */ 39 | # define LOGE(...) {\ 40 | __android_log_print(ANDROID_LOG_ERROR, "OSPD", __VA_ARGS__); \ 41 | } 42 | # define LOGI(...) {\ 43 | __android_log_print(ANDROID_LOG_INFO, "OSPD", __VA_ARGS__); \ 44 | } 45 | #endif 46 | 47 | /*-------------------------------------------------------------------------------------------------*\ 48 | | T Y P E D E F I N I T I O N S 49 | \*-------------------------------------------------------------------------------------------------*/ 50 | 51 | /*-------------------------------------------------------------------------------------------------*\ 52 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 53 | \*-------------------------------------------------------------------------------------------------*/ 54 | 55 | /*-------------------------------------------------------------------------------------------------*\ 56 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 57 | \*-------------------------------------------------------------------------------------------------*/ 58 | 59 | /*-------------------------------------------------------------------------------------------------*\ 60 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 61 | \*-------------------------------------------------------------------------------------------------*/ 62 | 63 | 64 | 65 | #endif // OSP_DEBUGLOGGING_H 66 | /*-------------------------------------------------------------------------------------------------*\ 67 | | E N D O F F I L E 68 | \*-------------------------------------------------------------------------------------------------*/ 69 | -------------------------------------------------------------------------------- /embedded/common/alg/significantmotiondetector.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef _SIGNIFICANTMOTIONDETECTOR_H_ 19 | #define _SIGNIFICANTMOTIONDETECTOR_H_ 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include "osp-alg-types.h" 25 | 26 | /* 27 | * This module detects significant motion events 28 | */ 29 | 30 | /*-------------------------------------------------------------------------------------------------*\ 31 | | C O N S T A N T S & M A C R O S 32 | \*-------------------------------------------------------------------------------------------------*/ 33 | 34 | /*-------------------------------------------------------------------------------------------------*\ 35 | | T Y P E D E F I N I T I O N S 36 | \*-------------------------------------------------------------------------------------------------*/ 37 | 38 | /*-------------------------------------------------------------------------------------------------*\ 39 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 40 | \*-------------------------------------------------------------------------------------------------*/ 41 | 42 | /*-------------------------------------------------------------------------------------------------*\ 43 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 44 | \*-------------------------------------------------------------------------------------------------*/ 45 | 46 | /*-------------------------------------------------------------------------------------------------*\ 47 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 48 | \*-------------------------------------------------------------------------------------------------*/ 49 | 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | // Constructor, destructor and reset methods 55 | void SignificantMotDetector_Init(OSP_EventResultCallback_t pSigMotionCallback); 56 | 57 | void SignificantMotDetector_CleanUp(void); 58 | void SignificantMotDetector_Reset(void); 59 | 60 | // Set methods 61 | void SignificantMotDetector_SetFilteredAccelerometerMeasurement(const NTTIME tstamp, const osp_float_t acc[NUM_ACCEL_AXES]); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif //_SIGNIFICANTMOTIONDETECTOR_H_ 68 | /*-------------------------------------------------------------------------------------------------*\ 69 | | E N D O F F I L E 70 | \*-------------------------------------------------------------------------------------------------*/ 71 | -------------------------------------------------------------------------------- /linux/sensorhubd/osp_remoteprocedurecalls.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef OSP_RPC_H 19 | #define OSP_RPC_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include 25 | #include "osp-api.h" 26 | 27 | /*-------------------------------------------------------------------------------------------------*\ 28 | | C O N S T A N T S & M A C R O S 29 | \*-------------------------------------------------------------------------------------------------*/ 30 | 31 | /*-------------------------------------------------------------------------------------------------*\ 32 | | T Y P E D E F I N I T I O N S 33 | \*-------------------------------------------------------------------------------------------------*/ 34 | typedef struct { 35 | union { 36 | double d; 37 | int64_t ll; 38 | } timestamp; 39 | union { 40 | float f; 41 | int32_t i; 42 | } data[3]; 43 | } OSPD_ThreeAxisData_t; 44 | 45 | typedef void (*OSPD_ResultDataCallback_t)(SensorType_t sensorType, void* data); 46 | 47 | /*-------------------------------------------------------------------------------------------------*\ 48 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 49 | \*-------------------------------------------------------------------------------------------------*/ 50 | 51 | /*-------------------------------------------------------------------------------------------------*\ 52 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 53 | \*-------------------------------------------------------------------------------------------------*/ 54 | 55 | /*-------------------------------------------------------------------------------------------------*\ 56 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 57 | \*-------------------------------------------------------------------------------------------------*/ 58 | osp_status_t OSPD_Initialize(void); 59 | osp_status_t OSPD_GetVersion(char* versionString, int bufSize); 60 | osp_status_t OSPD_SubscribeResult(SensorType_t sensorType, OSPD_ResultDataCallback_t dataReadyCallback ); 61 | osp_status_t OSPD_UnsubscribeResult(SensorType_t sensorType); 62 | osp_status_t OSPD_Deinitialize(void); 63 | 64 | 65 | #endif /* OSP_RPC_H */ 66 | /*-------------------------------------------------------------------------------------------------*\ 67 | | E N D O F F I L E 68 | \*-------------------------------------------------------------------------------------------------*/ 69 | -------------------------------------------------------------------------------- /external/MCU/NXP-5410x/CSLib/Inc/romapi_5410x.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @brief LPC5410X ROM API declarations and functions 3 | * 4 | * @note 5 | * Copyright(C) NXP Semiconductors, 2014 6 | * All rights reserved. 7 | * 8 | * @par 9 | * Software that is described herein is for illustrative purposes only 10 | * which provides customers with programming information regarding the 11 | * LPC products. This software is supplied "AS IS" without any warranties of 12 | * any kind, and NXP Semiconductors and its licensor disclaim any and 13 | * all warranties, express or implied, including all implied warranties of 14 | * merchantability, fitness for a particular purpose and non-infringement of 15 | * intellectual property rights. NXP Semiconductors assumes no responsibility 16 | * or liability for the use of the software, conveys no license or rights under any 17 | * patent, copyright, mask work right, or any other intellectual property rights in 18 | * or to any products. NXP Semiconductors reserves the right to make changes 19 | * in the software without notification. NXP Semiconductors also makes no 20 | * representation or warranty that such application will be suitable for the 21 | * specified use without further testing or modification. 22 | * 23 | * @par 24 | * Permission to use, copy, modify, and distribute this software and its 25 | * documentation is hereby granted, under NXP Semiconductors' and its 26 | * licensor's relevant copyrights in the software, without fee, provided that it 27 | * is used in conjunction with NXP Semiconductors microcontrollers. This 28 | * copyright, permission, and disclaimer notice must appear in all copies of 29 | * this code. 30 | */ 31 | 32 | #ifndef __ROMAPI_5410X_H_ 33 | #define __ROMAPI_5410X_H_ 34 | 35 | #include 36 | #include "iap.h" 37 | #include "error.h" 38 | #include "cmsis.h" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /** @defgroup ROMAPI_5410X CHIP: LPC5410X ROM API declarations and functions 45 | * @ingroup CHIP_5410X_DRIVERS 46 | * @{ 47 | */ 48 | 49 | /** 50 | * @brief High level ROM API structure 51 | */ 52 | typedef struct { 53 | const uint32_t reserved_usb; /*!< Reserved */ 54 | const uint32_t reserved_clib; /*!< Reserved */ 55 | const uint32_t reserved_can; /*!< Reserved */ 56 | const uint32_t reserved_pwrd; /*!< Reserved */ 57 | const uint32_t reserved_div; /*!< Reserved */ 58 | const uint32_t reserved_i2cd; /*!< Reserved */ 59 | const uint32_t reserved_dmad; /*!< Reserved */ 60 | const uint32_t reserved_spid; /*!< Reserved */ 61 | const uint32_t reserved_adcd; /*!< Reserved */ 62 | const uint32_t reserved_uartd; /*!< Reserved */ 63 | const uint32_t reserved_vfifo; /*!< Reserved */ 64 | const uint32_t reserved_usart; /*!< Reserved */ 65 | } LPC_ROM_API_T; 66 | 67 | /* Pointer to ROM API function address */ 68 | #define LPC_ROM_API_BASE_LOC 0x03000200UL 69 | #define LPC_ROM_API (*(LPC_ROM_API_T * *) LPC_ROM_API_BASE_LOC) 70 | 71 | /* Pointer to ROM IAP entry functions */ 72 | #define IAP_ENTRY_LOCATION 0x03000205 73 | 74 | /** 75 | * @brief LPC5410x IAP_ENTRY API function type 76 | */ 77 | static INLINE void iap_entry(unsigned int cmd_param[5], unsigned int status_result[4]) 78 | { 79 | ((IAP_ENTRY_T) IAP_ENTRY_LOCATION)(cmd_param, status_result); 80 | } 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif /* __ROMAPI_5410X_H_ */ 91 | -------------------------------------------------------------------------------- /embedded/projects/osp-steval-mki109v2/sources/app/app_tasks.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | /* This file in only included in ASF_Tasks.h and nowhere else */ 19 | 20 | /*-------------------------------------------------------------------------------------------------*\ 21 | | C O N S T A N T S & M A C R O S 22 | \*-------------------------------------------------------------------------------------------------*/ 23 | /** 24 | ** ASF_TASK_STATIC ( ThreadId, EntryFunction, Priority, StackSize, QueueSize ) 25 | ** This macro declares a static thread that will be created (along with an 26 | ** associated queue) automatically by the ASF startup initialization and 27 | ** will persist throughout the lifetime of the application. 28 | ** 29 | ** Parameters: 30 | ** ThreadId - User defined C-Style identifier for the thread. 31 | ** E.g. MY_THREAD_ID. This identifier will be used in the 32 | ** application to access the thread properties and its 33 | ** associated queue. 34 | ** EntryFunction - Thread entry function name. 35 | ** Priority - Thread priority in the range of 51 through 254. Higher value 36 | ** implies higher priority. Values 0 through 50 are reserved and 37 | ** should not be used. 38 | ** StackSize - Thread stack size in bytes. 39 | ** QueueSize - This denotes the maximum number of messages that are allowed 40 | ** to be queued for the thread. An optimum value should be 41 | ** chosen for this parameter to minimize memory wastage. 42 | ** 43 | ** Example: ASF_TASK_STATIC ( COMM_THREAD, CommThreadEntry, 55, 1024, 10 ) 44 | ** 45 | ** Entry Function must be declared in the following manner: 46 | ** ASF_TASK MyThreadEntry ( ASF_TASK_ARG ) 47 | ** { 48 | ** ... 49 | ** } 50 | ** 51 | */ 52 | /* Declare additional application specific tasks here */ 53 | /* NOTE: STACK_INCREASE can be used to increase the stack size of all tasks by a constant amount. 54 | This value is set in ASF_TaskInit.c file and is normally 0. Use this for Debugging crashes */ 55 | #ifdef ANDROID_DEMO 56 | ASF_TASK_STATIC( I2CSLAVE_COMM_TASK_ID, I2CCommTask, 99, (0x200+STACK_INCREASE), 16 ) 57 | #endif 58 | ASF_TASK_STATIC( ALGORITHM_TASK_ID, AlgorithmTask, 90, (0x800+STACK_INCREASE), 16 ) 59 | ASF_TASK_STATIC( ALG_BG_TASK_ID, AlgBackGndTask, 85, (0x800+STACK_INCREASE), 32 ) 60 | 61 | 62 | /*-------------------------------------------------------------------------------------------------*\ 63 | | E N D O F F I L E 64 | \*-------------------------------------------------------------------------------------------------*/ 65 | -------------------------------------------------------------------------------- /linux/sensorhubd/osp_names.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef _OSP_NAMES_H_ 19 | #define _OSP_NAMES_H_ 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include 25 | #include "osp-types.h" 26 | 27 | /*-------------------------------------------------------------------------------------------------*\ 28 | | C O N S T A N T S & M A C R O S 29 | \*-------------------------------------------------------------------------------------------------*/ 30 | 31 | /*-------------------------------------------------------------------------------------------------*\ 32 | | T Y P E / C L A S S D E F I N I T I O N S 33 | \*-------------------------------------------------------------------------------------------------*/ 34 | class Names { 35 | public: 36 | typedef const char* NameString; 37 | 38 | static constexpr NameString INPUT_EVENT_TIMESTAMP = "EVENT_TIMESTAMP"; 39 | static constexpr NameString INPUT_EVENT_EMBEDDED_32_BIT_TIMESTAMP = "EMBEDDED_32_BIT_TIMESTAMP"; 40 | static constexpr NameString INPUT_EVENT_EMBEDDED_64_BIT_TIMESTAMP = "EMBEDDED_64_BIT_TIMESTAMP"; 41 | 42 | 43 | static constexpr NameString SYSTEM_EVENT = "SYSTEM_EVENT"; 44 | static constexpr NameString RAW_ACCELEROMETER = "RAW_ACCELEROMETER"; 45 | static constexpr NameString RAW_MAGNETOMETER = "RAW_MAGNETOMETER"; 46 | static constexpr NameString RAW_GYROSCOPE = "RAW_GYROSCOPE"; 47 | 48 | }; 49 | 50 | /*-------------------------------------------------------------------------------------------------*\ 51 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 52 | \*-------------------------------------------------------------------------------------------------*/ 53 | 54 | /*-------------------------------------------------------------------------------------------------*\ 55 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 56 | \*-------------------------------------------------------------------------------------------------*/ 57 | 58 | /*-------------------------------------------------------------------------------------------------*\ 59 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 60 | \*-------------------------------------------------------------------------------------------------*/ 61 | 62 | #endif // _OSP_NAMES_H_ 63 | /*-------------------------------------------------------------------------------------------------*\ 64 | | E N D O F F I L E 65 | \*-------------------------------------------------------------------------------------------------*/ 66 | -------------------------------------------------------------------------------- /embedded/common/hostinterface/ConfigManager.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2015 Audience Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (CONFIG_MANAGER_H) 19 | #define CONFIG_MANAGER_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include "SensorPackets.h" 25 | 26 | /*-------------------------------------------------------------------------------------------------*\ 27 | | C O N S T A N T S & M A C R O S 28 | \*-------------------------------------------------------------------------------------------------*/ 29 | 30 | /*-------------------------------------------------------------------------------------------------*\ 31 | | T Y P E D E F I N I T I O N S 32 | \*-------------------------------------------------------------------------------------------------*/ 33 | 34 | /*-------------------------------------------------------------------------------------------------*\ 35 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 36 | \*-------------------------------------------------------------------------------------------------*/ 37 | 38 | /*-------------------------------------------------------------------------------------------------*\ 39 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 40 | \*-------------------------------------------------------------------------------------------------*/ 41 | 42 | /*-------------------------------------------------------------------------------------------------*\ 43 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 44 | \*-------------------------------------------------------------------------------------------------*/ 45 | 46 | /* SHConfigManager_ProcessControlRequest: Parse serialized Control Request packet, take action as necessary 47 | * 48 | * Parse serialized Control Request packet, take action as necessary 49 | * (rejecting if action not allowed by current Batch state), make serialized 50 | * Control Response packet and send to BatchManager Enqueue, if indicated (if 51 | * Sequence Number field in Request packet is nonzero). Returns 52 | * negative error code on non-respondable error, otherwise zero if no response 53 | * requested, otherwise positive response packet length. 54 | */ 55 | int32_t SHConfigManager_ProcessControlRequest( const uint8_t *pRequestPacket, uint16_t requestPacketBufferSize ); 56 | 57 | #endif /* CONFIG_MANAGER_H */ 58 | /*-------------------------------------------------------------------------------------------------*\ 59 | | E N D O F F I L E 60 | \*-------------------------------------------------------------------------------------------------*/ 61 | -------------------------------------------------------------------------------- /embedded/projects/osp-steval-mki109v2/sources/config/stm32f10x_conf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file RCC/RCC_ClockConfig/stm32f10x_conf.h 4 | * @author MCD Application Team 5 | * @version V3.5.0 6 | * @date 08-April-2011 7 | * @brief Library configuration file. 8 | ****************************************************************************** 9 | * @attention 10 | * 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 17 | * 18 | *

© COPYRIGHT 2011 STMicroelectronics

19 | ****************************************************************************** 20 | */ 21 | 22 | /* Define to prevent recursive inclusion -------------------------------------*/ 23 | #ifndef __STM32F10x_CONF_H 24 | #define __STM32F10x_CONF_H 25 | 26 | /* Includes ------------------------------------------------------------------*/ 27 | /* Uncomment/Comment the line below to enable/disable peripheral header file inclusion */ 28 | #include "stm32f10x_adc.h" 29 | #include "stm32f10x_bkp.h" 30 | //#include "stm32f10x_can.h" 31 | //#include "stm32f10x_cec.h" 32 | //#include "stm32f10x_crc.h" 33 | //#include "stm32f10x_dac.h" 34 | //#include "stm32f10x_dbgmcu.h" 35 | #include "stm32f10x_dma.h" 36 | #include "stm32f10x_exti.h" 37 | #include "stm32f10x_flash.h" 38 | //#include "stm32f10x_fsmc.h" 39 | #include "stm32f10x_gpio.h" 40 | #include "stm32f10x_i2c.h" 41 | //#include "stm32f10x_iwdg.h" 42 | #include "stm32f10x_pwr.h" 43 | #include "stm32f10x_rcc.h" 44 | #include "stm32f10x_rtc.h" 45 | //#include "stm32f10x_sdio.h" 46 | #include "stm32f10x_spi.h" 47 | #include "stm32f10x_tim.h" 48 | #include "stm32f10x_usart.h" 49 | #include "stm32f10x_wwdg.h" 50 | #include "misc.h" /* High level functions for NVIC and SysTick (add-on to CMSIS functions) */ 51 | 52 | /* Exported types ------------------------------------------------------------*/ 53 | /* Exported constants --------------------------------------------------------*/ 54 | /* Uncomment the line below to expanse the "assert_param" macro in the 55 | Standard Peripheral Library drivers code */ 56 | /* #define USE_FULL_ASSERT 1 */ 57 | 58 | /* Exported macro ------------------------------------------------------------*/ 59 | #ifdef USE_FULL_ASSERT 60 | 61 | /** 62 | * @brief The assert_param macro is used for function's parameters check. 63 | * @param expr: If expr is false, it calls assert_failed function which reports 64 | * the name of the source file and the source line number of the call 65 | * that failed. If expr is true, it returns no value. 66 | * @retval None 67 | */ 68 | #define assert_param(expr) ((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__)) 69 | /* Exported functions ------------------------------------------------------- */ 70 | void assert_failed(uint8_t* file, uint32_t line); 71 | #else 72 | #define assert_param(expr) ((void)0) 73 | #endif /* USE_FULL_ASSERT */ 74 | 75 | #endif /* __STM32F10x_CONF_H */ 76 | 77 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 78 | -------------------------------------------------------------------------------- /embedded/common/alg/stepdetector.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef _STEPDETECTOR_H_ 19 | #define _STEPDETECTOR_H_ 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include "osp-alg-types.h" 25 | 26 | /* 27 | * This module detects steps and produces corresponding step segments and step 28 | * data structures 29 | * 30 | * Step data calculation includes: 31 | * --) step frequency estimation, estimated over a succession of steps 32 | * --) step counts (total and consecutive) 33 | */ 34 | 35 | /*-------------------------------------------------------------------------------------------------*\ 36 | | C O N S T A N T S & M A C R O S 37 | \*-------------------------------------------------------------------------------------------------*/ 38 | 39 | /*-------------------------------------------------------------------------------------------------*\ 40 | | T Y P E D E F I N I T I O N S 41 | \*-------------------------------------------------------------------------------------------------*/ 42 | 43 | /*-------------------------------------------------------------------------------------------------*\ 44 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 45 | \*-------------------------------------------------------------------------------------------------*/ 46 | 47 | /*-------------------------------------------------------------------------------------------------*\ 48 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 49 | \*-------------------------------------------------------------------------------------------------*/ 50 | 51 | /*-------------------------------------------------------------------------------------------------*\ 52 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 53 | \*-------------------------------------------------------------------------------------------------*/ 54 | #ifdef __cplusplus 55 | extern "C" { 56 | #endif 57 | 58 | // Constructor, destructor and reset methods 59 | void StepDetector_Init(OSP_StepResultCallback_t pStepResultReadyCallback, OSP_StepSegmentResultCallback_t); 60 | 61 | void StepDetector_CleanUp(void); 62 | void StepDetector_Reset(void); 63 | 64 | // Set methods 65 | void StepDetector_SetFilteredAccelerometerMeasurement(NTTIME tstamp, const osp_float_t filteredAcc[NUM_ACCEL_AXES]); 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif //_STEPDETECTOR_H_ 72 | /*-------------------------------------------------------------------------------------------------*\ 73 | | E N D O F F I L E 74 | \*-------------------------------------------------------------------------------------------------*/ 75 | -------------------------------------------------------------------------------- /linux/sensorhubd/osp_datatypes.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef OSP_DATATYPES_H 19 | #define OSP_DATATYPES_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | /* We shall use STDINT types such as uint32_t, int8_t, etc. for integer types in all of our code. */ 25 | #include 26 | 27 | /*-------------------------------------------------------------------------------------------------*\ 28 | | C O N S T A N T S & M A C R O S 29 | \*-------------------------------------------------------------------------------------------------*/ 30 | #ifndef TRUE 31 | # define TRUE 1 32 | #endif 33 | 34 | #ifndef FALSE 35 | # define FALSE (!TRUE) 36 | #endif 37 | 38 | 39 | /*-------------------------------------------------------------------------------------------------*\ 40 | | T Y P E D E F I N I T I O N S 41 | \*-------------------------------------------------------------------------------------------------*/ 42 | /* Other types that are not provided by stdint */ 43 | typedef char osp_char_t; 44 | /* Note that char cannot be replaced by int8_t or uint8_t as most compiler treats 45 | char, signed char and unsigned char as different because char itself maybe signed or unsigned */ 46 | typedef unsigned char osp_byte_t; 47 | typedef double osp_dbl_t; 48 | typedef float osp_float_t; 49 | 50 | #ifdef __cplusplus 51 | typedef bool osp_bool_t; 52 | #else 53 | typedef char osp_bool_t; 54 | #endif 55 | 56 | typedef unsigned short osp_size_t; 57 | typedef int osp_status_t; 58 | 59 | /*-------------------------------------------------------------------------------------------------*\ 60 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 61 | \*-------------------------------------------------------------------------------------------------*/ 62 | 63 | /*-------------------------------------------------------------------------------------------------*\ 64 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 65 | \*-------------------------------------------------------------------------------------------------*/ 66 | 67 | /*-------------------------------------------------------------------------------------------------*\ 68 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 69 | \*-------------------------------------------------------------------------------------------------*/ 70 | 71 | 72 | #endif /* OSP_DATATYPES_H */ 73 | /*-------------------------------------------------------------------------------------------------*\ 74 | | E N D O F F I L E 75 | \*-------------------------------------------------------------------------------------------------*/ 76 | -------------------------------------------------------------------------------- /embedded/projects/SH-Xpresso-LPC54102/sources/app/app_tasks.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2015 Audience Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | /* This file in only included in ASF_Tasks.h and nowhere else */ 19 | 20 | /*-------------------------------------------------------------------------------------------------*\ 21 | | C O N S T A N T S & M A C R O S 22 | \*-------------------------------------------------------------------------------------------------*/ 23 | /** 24 | ** ASF_TASK_STATIC ( ThreadId, EntryFunction, Priority, StackSize, QueueSize ) 25 | ** This macro declares a static thread that will be created (along with an 26 | ** associated queue) automatically by the ASF startup initialization and 27 | ** will persist throughout the lifetime of the application. 28 | ** 29 | ** Parameters: 30 | ** ThreadId - User defined C-Style identifier for the thread. 31 | ** E.g. MY_THREAD_ID. This identifier will be used in the 32 | ** application to access the thread properties and its 33 | ** associated queue. 34 | ** EntryFunction - Thread entry function name. 35 | ** Priority - Thread priority in the range of 51 through 254. Higher value 36 | ** implies higher priority. Values 0 through 50 are reserved and 37 | ** should not be used. 38 | ** StackSize - Thread stack size in bytes. 39 | ** QueueSize - This denotes the maximum number of messages that are allowed 40 | ** to be queued for the thread. An optimum value should be 41 | ** chosen for this parameter to minimize memory wastage. 42 | ** 43 | ** Example: ASF_TASK_STATIC ( COMM_THREAD, CommThreadEntry, 55, 1024, 10 ) 44 | ** 45 | ** Entry Function must be declared in the following manner: 46 | ** ASF_TASK MyThreadEntry ( ASF_TASK_ARG ) 47 | ** { 48 | ** ... 49 | ** } 50 | ** 51 | */ 52 | /* Declare additional application specific tasks here */ 53 | /* NOTE: STACK_INCREASE can be used to increase the stack size of all tasks by a constant amount. 54 | This value is set in ASF_TaskInit.c file and is normally 0. Use this for Debugging crashes */ 55 | #ifdef ANDROID_DEMO 56 | ASF_TASK_STATIC( HOST_INTF_TASK_ID, HostIntfTask, 99, (0x400+STACK_INCREASE), 64 ) 57 | #endif 58 | /* Algorithm foreground and background tasks */ 59 | ASF_TASK_STATIC( ALGORITHM_TASK_ID, AlgorithmTask, 90, (0x980+STACK_INCREASE), 64 ) 60 | ASF_TASK_STATIC( ALG_BG_TASK_ID, AlgBackGndTask, 85, (0x1080+STACK_INCREASE), 64 ) 61 | 62 | /* Sensor data handler task */ 63 | ASF_TASK_STATIC( SENSOR_ACQ_TASK_ID, SensorAcqTask, 102, (0x400+STACK_INCREASE), 16 ) 64 | 65 | 66 | /*-------------------------------------------------------------------------------------------------*\ 67 | | E N D O F F I L E 68 | \*-------------------------------------------------------------------------------------------------*/ 69 | -------------------------------------------------------------------------------- /embedded/common/asf/asf_taskstruct.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (ASF_TASKSTRUCT_H) 19 | #define ASF_TASKSTRUCT_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #if !defined (ASF_TQENUM_H) 25 | # include "asf_tqenum.h" 26 | #endif 27 | 28 | 29 | /*-------------------------------------------------------------------------------------------------*\ 30 | | T Y P E D E F I N I T I O N S 31 | \*-------------------------------------------------------------------------------------------------*/ 32 | /** 33 | * This structure is used to hold information about a task that needs to be 34 | * created at run time. This is the base unit of the C_gAsfTaskInitTable array. 35 | * NOTE: that this must hold only things that are known at compile time as 36 | * the C_gAsfTaskInitTable array is marked as constant i.e. in ROM. 37 | */ 38 | typedef struct AsfTaskInitDefTag 39 | { 40 | TaskId taskId; 41 | void (*entryPoint)(); 42 | char *tskName; 43 | OS_ID queue; 44 | uint16_t queueSize; 45 | uint16_t stackSize; 46 | uint8_t priority; 47 | char *tidString; /* String equivalent of the TASK_ID enum */ 48 | 49 | } AsfTaskInitDef; 50 | 51 | 52 | /*-------------------------------------------------------------------------------------------------*\ 53 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 54 | \*-------------------------------------------------------------------------------------------------*/ 55 | /** 56 | * This table holds the Task handle provided by the RTOS. The table is 57 | * filled in when the tasks are created, see ASFInitialiseTasks(). 58 | */ 59 | extern AsfTaskHandle asfTaskHandleTable[NUMBER_OF_TASKS]; 60 | 61 | /** 62 | * This is the task initialization table which details all the information 63 | * that is required to create the tasks. 64 | * NOTE: this array is marked as constant i.e. in ROM. 65 | */ 66 | extern const AsfTaskInitDef C_gAsfTaskInitTable[NUMBER_OF_TASKS]; 67 | 68 | 69 | /*-------------------------------------------------------------------------------------------------*\ 70 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 71 | \*-------------------------------------------------------------------------------------------------*/ 72 | /** 73 | * This function is used to initialize all the defined tasks and their 74 | * associated queues. 75 | */ 76 | void ASFInitialiseTasks ( void ); 77 | 78 | 79 | #endif /* ASF_TASKSTRUCT_H */ 80 | /*-------------------------------------------------------------------------------------------------*\ 81 | | E N D O F F I L E 82 | \*-------------------------------------------------------------------------------------------------*/ 83 | -------------------------------------------------------------------------------- /linux/sensorhubd/virtualsensordevicemanager.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef VIRTUALSENSORDEVICEMANAGER_H 19 | #define VIRTUALSENSORDEVICEMANAGER_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | /*-------------------------------------------------------------------------------------------------*\ 30 | | C O N S T A N T S & M A C R O S 31 | \*-------------------------------------------------------------------------------------------------*/ 32 | 33 | /*-------------------------------------------------------------------------------------------------*\ 34 | | T Y P E / C L A S S D E F I N I T I O N S 35 | \*-------------------------------------------------------------------------------------------------*/ 36 | //! manages the lifecycle of virtual sensor device file descriptors 37 | class VirtualSensorDeviceManager 38 | { 39 | public: 40 | VirtualSensorDeviceManager( const int sleepus = 10000); 41 | ~VirtualSensorDeviceManager(); 42 | 43 | int createSensor(const char* name, const char* physname, int absMin =-2048, 44 | int absMax =2047); 45 | void publish(int deviceFd, input_event data); 46 | void publish(int deviceFd, int* data, 47 | const unsigned int* const timeInMillis = 0); 48 | void publish(int deviceFd, const int32_t data[], 49 | const int64_t time64, int numAxis=3); 50 | 51 | protected: 52 | 53 | void fatalErrorIf(bool condition, int code, const char* msg); 54 | 55 | private: 56 | std::vector _deviceFds; 57 | const int _sleepus; 58 | }; 59 | 60 | /*-------------------------------------------------------------------------------------------------*\ 61 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 62 | \*-------------------------------------------------------------------------------------------------*/ 63 | 64 | /*-------------------------------------------------------------------------------------------------*\ 65 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 66 | \*-------------------------------------------------------------------------------------------------*/ 67 | 68 | /*-------------------------------------------------------------------------------------------------*\ 69 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 70 | \*-------------------------------------------------------------------------------------------------*/ 71 | 72 | #endif // VIRTUALSENSORDEVICEMANAGER_H 73 | /*-------------------------------------------------------------------------------------------------*\ 74 | | E N D O F F I L E 75 | \*-------------------------------------------------------------------------------------------------*/ 76 | -------------------------------------------------------------------------------- /algorithm/osp/include/osp-alg-types.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (OSP_ALG_TYPES) 19 | #define OSP_ALG_TYPES 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include 25 | #include "osp-types.h" 26 | #include "osp-fixedpoint-types.h" 27 | 28 | /*-------------------------------------------------------------------------------------------------*\ 29 | | C O N S T A N T S & M A C R O S 30 | \*-------------------------------------------------------------------------------------------------*/ 31 | #define NUM_ACCEL_AXES (3) 32 | 33 | /*-------------------------------------------------------------------------------------------------*\ 34 | | T Y P E D E F I N I T I O N S 35 | \*-------------------------------------------------------------------------------------------------*/ 36 | //! Enumeration typedef for segment type 37 | typedef enum EStepSegmentType { 38 | firstStep, 39 | midStep, 40 | lastStep 41 | } EStepSegmentType; 42 | 43 | //! Struct definition for a step segment 44 | typedef struct { 45 | //store start/stop times of the last step 46 | NTTIME startTime; 47 | NTTIME stopTime; 48 | EStepSegmentType type; 49 | } StepSegment_t; 50 | 51 | //struct for defining a step 52 | typedef struct StepDataOSP_t{ 53 | NTTIME startTime; 54 | NTTIME stopTime; 55 | osp_float_t stepFrequency; 56 | uint32_t numStepsTotal; 57 | uint32_t numStepsSinceWalking; 58 | } StepDataOSP_t; 59 | 60 | typedef void (*OSP_StepSegmentResultCallback_t)(StepSegment_t * segment); 61 | typedef void (*OSP_StepResultCallback_t)(StepDataOSP_t* stepData); 62 | typedef void (*OSP_EventResultCallback_t)(NTTIME * eventTime); 63 | 64 | /*-------------------------------------------------------------------------------------------------*\ 65 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 66 | \*-------------------------------------------------------------------------------------------------*/ 67 | 68 | /*-------------------------------------------------------------------------------------------------*\ 69 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 70 | \*-------------------------------------------------------------------------------------------------*/ 71 | 72 | /*-------------------------------------------------------------------------------------------------*\ 73 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 74 | \*-------------------------------------------------------------------------------------------------*/ 75 | 76 | 77 | #endif /* OSP_ALG_TYPES */ 78 | /*-------------------------------------------------------------------------------------------------*\ 79 | | E N D O F F I L E 80 | \*-------------------------------------------------------------------------------------------------*/ 81 | -------------------------------------------------------------------------------- /embedded/common/alg/osp-alg-types.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (OSP_ALG_TYPES) 19 | #define OSP_ALG_TYPES 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include 25 | #include "osp-types.h" 26 | #include "osp-fixedpoint-types.h" 27 | 28 | /*-------------------------------------------------------------------------------------------------*\ 29 | | C O N S T A N T S & M A C R O S 30 | \*-------------------------------------------------------------------------------------------------*/ 31 | #define NUM_ACCEL_AXES (3) 32 | 33 | /*-------------------------------------------------------------------------------------------------*\ 34 | | T Y P E D E F I N I T I O N S 35 | \*-------------------------------------------------------------------------------------------------*/ 36 | //! Enumeration typedef for segment type 37 | typedef enum EStepSegmentType { 38 | firstStep, 39 | midStep, 40 | lastStep 41 | } EStepSegmentType; 42 | 43 | //! Struct definition for a step segment 44 | typedef struct { 45 | //store start/stop times of the last step 46 | NTTIME startTime; 47 | NTTIME stopTime; 48 | EStepSegmentType type; 49 | } StepSegment_t; 50 | 51 | //struct for defining a step 52 | typedef struct StepDataOSP_t{ 53 | NTTIME startTime; 54 | NTTIME stopTime; 55 | osp_float_t stepFrequency; 56 | uint32_t numStepsTotal; 57 | uint32_t numStepsSinceWalking; 58 | } StepDataOSP_t; 59 | 60 | typedef void (*OSP_StepSegmentResultCallback_t)(StepSegment_t * segment); 61 | typedef void (*OSP_StepResultCallback_t)(StepDataOSP_t* stepData); 62 | typedef void (*OSP_EventResultCallback_t)(NTTIME * eventTime); 63 | 64 | /*-------------------------------------------------------------------------------------------------*\ 65 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 66 | \*-------------------------------------------------------------------------------------------------*/ 67 | 68 | /*-------------------------------------------------------------------------------------------------*\ 69 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 70 | \*-------------------------------------------------------------------------------------------------*/ 71 | 72 | /*-------------------------------------------------------------------------------------------------*\ 73 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 74 | \*-------------------------------------------------------------------------------------------------*/ 75 | 76 | 77 | #endif /* OSP_ALG_TYPES */ 78 | /*-------------------------------------------------------------------------------------------------*\ 79 | | E N D O F F I L E 80 | \*-------------------------------------------------------------------------------------------------*/ 81 | -------------------------------------------------------------------------------- /embedded/common/hostinterface/BatchManager.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2015 Audience Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (BATCH_MANAGER_H) 19 | #define BATCH_MANAGER_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include "Queue.h" 25 | #include "SensorPackets.h" 26 | #include "main.h" 27 | 28 | /*-------------------------------------------------------------------------------------------------*\ 29 | | C O N S T A N T S & M A C R O S 30 | \*-------------------------------------------------------------------------------------------------*/ 31 | 32 | /*-------------------------------------------------------------------------------------------------*\ 33 | | T Y P E D E F I N I T I O N S 34 | \*-------------------------------------------------------------------------------------------------*/ 35 | 36 | /*-------------------------------------------------------------------------------------------------*\ 37 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 38 | \*-------------------------------------------------------------------------------------------------*/ 39 | 40 | /*-------------------------------------------------------------------------------------------------*\ 41 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 42 | \*-------------------------------------------------------------------------------------------------*/ 43 | 44 | /*-------------------------------------------------------------------------------------------------*\ 45 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 46 | \*-------------------------------------------------------------------------------------------------*/ 47 | int16_t BatchManagerInitialize( void ); 48 | int16_t BatchManagerSensorRegister( ASensorType_t SensorType, uint64_t SamplingPeriod, uint64_t ReportLatency ); 49 | int16_t BatchManagerSensorEnable( ASensorType_t SensorType ); 50 | int16_t BatchManagerSensorDeRegister( ASensorType_t SensorType ); 51 | int16_t BatchManagerSensorDisable( ASensorType_t SensorType ); 52 | int16_t BatchManagerIsSensorEnabled( ASensorType_t sensorType, osp_bool_t *isEnabled ); 53 | int16_t BatchManagerSensorDataEnQueue( HostIFPackets_t *pTodoPacket, uint16_t packetSize, uint32_t sensorType ); 54 | int16_t BatchManagerDeQueue( uint8_t *pBuf, uint32_t *pLength ); 55 | int16_t BatchManagerControlResponseEnQueue( HostIFPackets_t *pHiFControlPacket, uint16_t packetSize ); 56 | int16_t BatchManagerQueueFlush( FifoQ_Type_t qType); 57 | uint32_t BatchManagerMaxQCount( void ); 58 | int16_t BatchManagerGetSensorQueueType( ASensorType_t sensorType, FifoQ_Type_t *sensorQType ); 59 | 60 | #endif /* BATCH_MANAGER_H */ 61 | /*-------------------------------------------------------------------------------------------------*\ 62 | | E N D O F F I L E 63 | \*-------------------------------------------------------------------------------------------------*/ 64 | -------------------------------------------------------------------------------- /embedded/common/hostinterface/BlockMemory.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2015 Audience Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (BLOCK_MEMORY_H) 19 | #define BLOCK_MEMORY_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include "common.h" 25 | 26 | /*-------------------------------------------------------------------------------------------------*\ 27 | | C O N S T A N T S & M A C R O S 28 | \*-------------------------------------------------------------------------------------------------*/ 29 | #define SETUP_CRITICAL_SECTION() OS_SETUP_CRITICAL() 30 | #define ENTER_CRITICAL_SECTION() OS_ENTER_CRITICAL() 31 | #define EXIT_CRITICAL_SECTION() OS_LEAVE_CRITICAL() 32 | 33 | /* The DECLARE_BLOCK_POOL macro declares an array of bytes that can be used as a memory pool for fixed 34 | * block allocation. 35 | * @param [IN]pool - User defined unique C-Style name of the pool 36 | * @param [IN]size - Size in bytes of each memory block that will be allocated from the pool 37 | * @param [IN]cnt - Number of blocks the pool should contain 38 | */ 39 | #define DECLARE_BLOCK_POOL(pool,size,cnt) uint32_t pool[(((size)+3)/4)*(cnt) + 5] 40 | /* Note: +5 is to account for size (in 32-bit values) of local block structure (BlkMem_t) */ 41 | 42 | 43 | /*-------------------------------------------------------------------------------------------------*\ 44 | | T Y P E D E F I N I T I O N S 45 | \*-------------------------------------------------------------------------------------------------*/ 46 | 47 | /*-------------------------------------------------------------------------------------------------*\ 48 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 49 | \*-------------------------------------------------------------------------------------------------*/ 50 | 51 | /*-------------------------------------------------------------------------------------------------*\ 52 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 53 | \*-------------------------------------------------------------------------------------------------*/ 54 | 55 | /*-------------------------------------------------------------------------------------------------*\ 56 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 57 | \*-------------------------------------------------------------------------------------------------*/ 58 | int16_t InitBlockPool( void *pPool, uint32_t poolSizeBytes, uint32_t blkSize ); 59 | void *AllocBlock( void *pPool ); 60 | int16_t FreeBlock( void *pPool, void *pBlock ); 61 | void GetPoolStats( void *pPool, uint32_t *pTotalCount, uint32_t *pUsedCount ); 62 | 63 | 64 | #endif /* BLOCK_MEMORY_H */ 65 | /*-------------------------------------------------------------------------------------------------*\ 66 | | E N D O F F I L E 67 | \*-------------------------------------------------------------------------------------------------*/ 68 | -------------------------------------------------------------------------------- /linux/sensorhubd/osp_relayinterface.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef _RELAY_INTERFACE_H_ 19 | #define _RELAY_INTERFACE_H_ 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include 25 | #include "osp-types.h" 26 | 27 | /*-------------------------------------------------------------------------------------------------*\ 28 | | C O N S T A N T S & M A C R O S 29 | \*-------------------------------------------------------------------------------------------------*/ 30 | 31 | /*-------------------------------------------------------------------------------------------------*\ 32 | | T Y P E D E F I N I T I O N S 33 | \*-------------------------------------------------------------------------------------------------*/ 34 | typedef enum { 35 | ACCEL_INDEX = 0, 36 | MAG_INDEX = 1, 37 | GYRO_INDEX = 2, 38 | STEP_COUNTER_INDEX = 3, 39 | SIG_MOTION_INDEX = 4, 40 | MAX_NUM_SENSORS_TO_HANDLE 41 | } deviceIndex; 42 | 43 | typedef struct { 44 | std::string uinputName; 45 | std::string sysDelayPath; //Sysfs path for setting polling interval 46 | std::string sysEnablePath; //Sysfs path for enable 47 | int32_t enableValue; //Value that enables the device (typically 1)* 48 | int32_t disableValue; //Value that disables the device (typically 0) 49 | int32_t fd; 50 | int32_t repubFd; 51 | osp_float_t conversion[3]; 52 | int swap[3]; 53 | } DeviceConfig_t; 54 | 55 | /* per-cpu buffer info */ 56 | typedef struct 57 | { 58 | size_t produced; 59 | size_t consumed; 60 | size_t max_backlog; /* max # sub-buffers ready at one time */ 61 | } RelayBufStatus_t; 62 | 63 | /*-------------------------------------------------------------------------------------------------*\ 64 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 65 | \*-------------------------------------------------------------------------------------------------*/ 66 | 67 | /*-------------------------------------------------------------------------------------------------*\ 68 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 69 | \*-------------------------------------------------------------------------------------------------*/ 70 | 71 | /*-------------------------------------------------------------------------------------------------*\ 72 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 73 | \*-------------------------------------------------------------------------------------------------*/ 74 | 75 | 76 | #endif /* _RELAY_INTERFACE_H_ */ 77 | /*-------------------------------------------------------------------------------------------------*\ 78 | | E N D O F F I L E 79 | \*-------------------------------------------------------------------------------------------------*/ 80 | -------------------------------------------------------------------------------- /algorithm/osp/rotvec.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2015 HY Research LLC 3 | * Author: hy-git@hy-research.com 4 | * 5 | * Apache License. 6 | * 7 | */ 8 | 9 | 10 | /* 11 | * Compute rotation vector from accel/mag. 12 | * Based on Android implementation. Converted to fixed point. 13 | */ 14 | 15 | #include 16 | #include "fpsup.h" 17 | #include "fp_sensor.h" 18 | #include "rotvec.h" 19 | 20 | #include 21 | 22 | static Q15_t copysign_q15(Q15_t v, Q15_t s) 23 | { 24 | if (s < 0) return -v; 25 | else return v; 26 | } 27 | 28 | 29 | static Q15_t clamp_q15(Q15_t v) 30 | { 31 | if (v < 0) return 0; 32 | return v; 33 | } 34 | 35 | void OSP_rotvec_init() 36 | { 37 | } 38 | 39 | void OSP_rotvec_process( 40 | struct ThreeAxis *mag, 41 | struct ThreeAxis *acc, 42 | struct Quat *rot) 43 | { 44 | Q15_t normH; 45 | Q15_t accMag2; 46 | 47 | Q15_t magMag2; 48 | Q15_t Hx, Hy, Hz; 49 | Q15_t Ex, Ey, Ez; 50 | 51 | Q15_t invA; 52 | Q15_t invH; 53 | 54 | Q15_t Ax, Ay, Az; 55 | Q15_t Mx, My, Mz; 56 | 57 | Q15_t qw, qx, qy, qz; 58 | 59 | Ax = acc->x; 60 | Ay = acc->y; 61 | Az = acc->z; 62 | 63 | if (Ax == 0 && Ay == 0 && Az == 0) return; 64 | 65 | Ex = mag->x; 66 | Ey = mag->y; 67 | Ez = mag->z; 68 | 69 | #if 0 70 | printf("RV using: Ax: %f Ay: %f: Az: %f, Mx: %f, My: %f, Mz: %f\n", 71 | Q15_to_FP(Ax), Q15_to_FP(Ay), Q15_to_FP(Az), 72 | Q15_to_FP(Ex), Q15_to_FP(Ey), Q15_to_FP(Ez)); 73 | #endif 74 | Hx = MUL_Q15(Ey, Az) - MUL_Q15(Ez, Ay); 75 | Hy = MUL_Q15(Ez, Ax) - MUL_Q15(Ex, Az); 76 | Hz = MUL_Q15(Ex, Ay) - MUL_Q15(Ey, Ax); 77 | 78 | 79 | magMag2 = MUL_Q15(Hx,Hx); 80 | magMag2 += MUL_Q15(Hy, Hy); 81 | magMag2 += MUL_Q15(Hz, Hz); 82 | 83 | normH = sqrt_q15(magMag2); 84 | 85 | if (normH < FP_to_Q15(0.1f)) { 86 | printf("Bad mag? %f (from %f)\n", Q15_to_FP(normH), Q15_to_FP(magMag2)); 87 | printf("RV using: Ax: %f Ay: %f: Az: %f, Mx: %f, My: %f, Mz: %f Hx: %f Hy: %f Hz: %f (%f, %f, %f)\n", 88 | Q15_to_FP(Ax), Q15_to_FP(Ay), Q15_to_FP(Az), 89 | Q15_to_FP(Ex), Q15_to_FP(Ey), Q15_to_FP(Ez), 90 | Q15_to_FP(Hx), Q15_to_FP(Hy), Q15_to_FP(Hz), 91 | Q15_to_FP(MUL_Q15(Hx,Hx)), 92 | Q15_to_FP(MUL_Q15(Hy,Hy)), 93 | Q15_to_FP(MUL_Q15(Hz,Hz)) 94 | ); 95 | return; 96 | } 97 | invH = RECIP_Q15(normH); 98 | if (invH <= 0) { 99 | printf("OF/UF?\n"); 100 | } 101 | 102 | accMag2 = MUL_Q15(Ax, Ax); 103 | accMag2 += MUL_Q15(Ay, Ay); 104 | accMag2 += MUL_Q15(Az, Az); 105 | 106 | if (accMag2 < 0) { 107 | printf("OF? - 2\n"); 108 | } 109 | 110 | invA = RECIP_Q15(sqrt_q15(accMag2)); 111 | 112 | Hx = DIV_Q15(Hx, normH); 113 | Hy = DIV_Q15(Hy, normH); 114 | Hz = DIV_Q15(Hz, normH); 115 | 116 | Ax = MUL_Q15(Ax, invA); 117 | Ay = MUL_Q15(Ay, invA); 118 | Az = MUL_Q15(Az, invA); 119 | 120 | Mx = MUL_Q15(Ay, Hz) - MUL_Q15(Az, Hy); 121 | My = MUL_Q15(Az, Hx) - MUL_Q15(Ax, Hz); 122 | Mz = MUL_Q15(Ax, Hy) - MUL_Q15(Ay, Hx); 123 | #if 0 124 | qw = sqrt_q12(MUL_Q12(clamp_q12( Hx+My+Az+q12_c1), q12_quarter)); 125 | qx = sqrt_q12(MUL_Q12(clamp_q12( Hx-My-Az+q12_c1), q12_quarter)); 126 | qy = sqrt_q12(MUL_Q12(clamp_q12(-Hx+My-Az+q12_c1), q12_quarter)); 127 | qz = sqrt_q12(MUL_Q12(clamp_q12(-Hx-My+Az+q12_c1), q12_quarter)); 128 | #else 129 | { 130 | Q15_t t; 131 | 132 | t = MUL_Q15(clamp_q15( Hx+My+Az+q15_c1), q15_quarter); 133 | qw = sqrt_q15(t); 134 | 135 | t = MUL_Q15(clamp_q15( Hx-My-Az+q15_c1), q15_quarter); 136 | qx = sqrt_q15(t); 137 | 138 | t = MUL_Q15(clamp_q15(-Hx+My-Az+q15_c1), q15_quarter); 139 | qy = sqrt_q15(t); 140 | 141 | t = MUL_Q15(clamp_q15(-Hx-My+Az+q15_c1), q15_quarter); 142 | qz = sqrt_q15(t); 143 | } 144 | #endif 145 | 146 | qx = copysign_q15(qx, Ay - Mz); 147 | qy = copysign_q15(qy, Hz - Ax); 148 | qz = copysign_q15(qz, Mx - Hy); 149 | 150 | rot->x = qx; 151 | rot->y = qy; 152 | rot->z = qz; 153 | rot->w = qw; 154 | } 155 | -------------------------------------------------------------------------------- /algorithm/osp/ecompass.c: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2015 HY Research LLC 3 | * Author: hy-git@hy-research.com 4 | * 5 | * Apache License. 6 | * 7 | * Project magnetometer data onto the X/Y plane using the 8 | * accel. Angles are computed from that using trig functions. 9 | */ 10 | 11 | #include 12 | #include 13 | #include "fpsup.h" 14 | #include "fp_sensor.h" 15 | #include "ecompass.h" 16 | 17 | struct Heading { 18 | float roll; 19 | float pitch; 20 | float yaw; 21 | }; 22 | 23 | static struct ThreeAxis HardIron; 24 | static int calstate; 25 | static int samplecount = 0; 26 | static struct ThreeAxis minMag, maxMag; 27 | 28 | static Q15_t deg_atan2(Q15_t y, Q15_t x) 29 | { 30 | return MUL_Q15(atan2_q15(y, x), FP_to_Q15(180.0/M_PI)); 31 | } 32 | 33 | 34 | static void adj_mag(struct ThreeAxis *mag) 35 | { 36 | mag->x -= HardIron.x; 37 | mag->y -= HardIron.y; 38 | mag->z -= HardIron.z; 39 | } 40 | 41 | 42 | static void adj_acc(struct ThreeAxis *acc) 43 | { 44 | } 45 | 46 | void OSP_ecompass_init(void) 47 | { 48 | calstate = 0; 49 | HardIron.x = 0; HardIron.y = 0; HardIron.z = 0; 50 | } 51 | 52 | void OSP_ecompass_process(struct ThreeAxis *mag, 53 | struct ThreeAxis *acc, 54 | struct Euler *result) 55 | { 56 | Q15_t pMx, pMy; 57 | Q15_t hyp; 58 | 59 | samplecount++; 60 | 61 | if (calstate) { 62 | /* Assume 30Hz, this is about 30 seconds */ 63 | if (samplecount > 900) { 64 | calstate = 0; 65 | do { 66 | if (maxMag.x == MIN_Q15 || 67 | maxMag.y == MIN_Q15 || 68 | maxMag.z == MIN_Q15) 69 | break; 70 | if (minMag.x == MAX_Q15 || 71 | minMag.y == MAX_Q15 || 72 | minMag.z == MAX_Q15) 73 | break; 74 | 75 | HardIron.x = MUL_Q15((maxMag.x - minMag.x), q15_half); 76 | HardIron.x = HardIron.x - maxMag.x; 77 | 78 | 79 | HardIron.y = MUL_Q15((maxMag.y - minMag.y), q15_half); 80 | HardIron.y = HardIron.y - maxMag.y; 81 | 82 | HardIron.z = MUL_Q15((maxMag.z - minMag.z), q15_half); 83 | HardIron.z = HardIron.z - maxMag.z; 84 | 85 | } while (0); 86 | printf("Cal completed - Offsets: %f %f %f\n", 87 | Q15_to_FP(HardIron.x), 88 | Q15_to_FP(HardIron.y), 89 | Q15_to_FP(HardIron.z)); 90 | } else { 91 | if (mag->x > maxMag.x) maxMag.x = mag->x; 92 | if (mag->y > maxMag.y) maxMag.y = mag->y; 93 | if (mag->z > maxMag.z) maxMag.z = mag->z; 94 | 95 | if (mag->x < minMag.x) minMag.x = mag->x; 96 | if (mag->y < minMag.y) minMag.y = mag->y; 97 | if (mag->z < minMag.z) minMag.z = mag->z; 98 | } 99 | } 100 | 101 | adj_mag(mag); 102 | adj_acc(acc); 103 | #if 0 104 | acc->y = -acc->y; 105 | acc->x = -acc->x; 106 | acc->z = -acc->z; 107 | #endif 108 | result->roll = deg_atan2(acc->x, acc->z); 109 | #if 0 110 | result->roll = result->roll+FP_to_Q15(180.0f); 111 | if (result->roll > q15_c180) result->roll -= q15_c360; 112 | #endif 113 | 114 | result->pitch = deg_atan2(acc->y, acc->z); 115 | #if 0 116 | result->pitch = result->roll + q15_c180; 117 | if (result->pitch > q15_c180) result->pitch -= q15_c360; 118 | #endif 119 | result->pitch = -result->pitch; 120 | hyp = sqrt_q15(MUL_Q15(acc->x, acc->x) + MUL_Q15(acc->z, acc->z)); 121 | if (hyp == 0) return; 122 | 123 | pMx = (MUL_Q15(mag->x, DIV_Q15(acc->z,hyp)) + MUL_Q15(mag->z, DIV_Q15(acc->x,hyp))); 124 | 125 | hyp = sqrt_q15(MUL_Q15(acc->y, acc->y) + MUL_Q15(acc->z, acc->z)); 126 | if (hyp == 0) return; 127 | 128 | pMy = (MUL_Q15(mag->y, DIV_Q15(acc->z,hyp)) + MUL_Q15(mag->z, DIV_Q15(acc->y,hyp))); 129 | 130 | result->yaw = -1 * deg_atan2(pMx, pMy); 131 | result->yaw += q15_c180; 132 | #if 0 133 | printf("%s roll %f pitch %f yaw %f\n", __func__, Q15_to_FP(result->roll), Q15_to_FP(result->pitch), Q15_to_FP(result->yaw)); 134 | #endif 135 | } 136 | 137 | void OSP_ecompass_cal(void) 138 | { 139 | calstate = 1; 140 | samplecount = 0; 141 | minMag.x = MAX_Q15; 142 | minMag.y = MAX_Q15; 143 | minMag.z = MAX_Q15; 144 | 145 | maxMag.x = MIN_Q15; 146 | maxMag.y = MIN_Q15; 147 | maxMag.z = MIN_Q15; 148 | 149 | printf("Cal requested\n"); 150 | } 151 | -------------------------------------------------------------------------------- /embedded/common/modules/bus-drivers/i2c_driver.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (I2C_DRIVER_H) 19 | #define I2C_DRIVER_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | 25 | /*-------------------------------------------------------------------------------------------------*\ 26 | | C O N S T A N T S & M A C R O S 27 | \*-------------------------------------------------------------------------------------------------*/ 28 | #define FLAG_LAST_TRANS_OK 0x01 29 | #define FLAG_MAG_DATA_READY 0x02 30 | #define I2C_BUFFER_SIZE 15 // Set this to the largest message size that will be sent 31 | // including address byte. 32 | #define I2C_ERR_OK 0 33 | #define I2C_ERR_BUSY 1 34 | #define I2C_ERR_REQ 2 35 | 36 | /**************************************************************************** 37 | Bit and byte definitions 38 | ****************************************************************************/ 39 | #define I2C_READ_BIT 0 // Bit position for R/W bit in "address byte". 40 | #define I2C_ADR_BITS 1 // Bit position for LSB of the slave address bits in the init byte. 41 | 42 | 43 | /*-------------------------------------------------------------------------------------------------*\ 44 | | T Y P E D E F I N I T I O N S 45 | \*-------------------------------------------------------------------------------------------------*/ 46 | typedef enum _SendModeTag { 47 | I2C_MASTER_WRITE, 48 | I2C_MASTER_RESTART, 49 | I2C_MASTER_READ, 50 | I2C_SLAVE_TX, 51 | I2C_SLAVE_RX 52 | } I2C_SendMode_t; 53 | 54 | /*-------------------------------------------------------------------------------------------------*\ 55 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 56 | \*-------------------------------------------------------------------------------------------------*/ 57 | 58 | /*-------------------------------------------------------------------------------------------------*\ 59 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 60 | \*-------------------------------------------------------------------------------------------------*/ 61 | 62 | /*-------------------------------------------------------------------------------------------------*\ 63 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 64 | \*-------------------------------------------------------------------------------------------------*/ 65 | osp_bool_t I2C_HardwareSetup( I2C_TypeDef *busId ); 66 | void I2C_Master_Initialise( void ); 67 | uint8_t I2C_Transceiver_Busy( void ); 68 | uint8_t I2C_Start_Transfer( uint8_t slaveAddr, uint16_t regAddr, uint8_t *pData, uint8_t dataSize, 69 | I2C_SendMode_t sendMode ); 70 | uint8_t I2C_Get_Data_From_Transceiver( uint8_t *, uint8_t ); 71 | void I2C_Wait_Completion( void ); 72 | 73 | 74 | #endif /* I2C_DRIVER_H */ 75 | /*-------------------------------------------------------------------------------------------------*\ 76 | | E N D O F F I L E 77 | \*-------------------------------------------------------------------------------------------------*/ 78 | -------------------------------------------------------------------------------- /embedded/common/alg/signalgenerator.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2013 Sensor Platforms Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #ifndef _SIGNALGENERATOR_H_ 19 | #define _SIGNALGENERATOR_H_ 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include "osp-alg-types.h" 25 | #include "osp-types.h" 26 | 27 | /*-------------------------------------------------------------------------------------------------*\ 28 | | C O N S T A N T S & M A C R O S 29 | \*-------------------------------------------------------------------------------------------------*/ 30 | // Moving average filter length 31 | #define AVERAGING_FILTER_BUF_SIZE_2N (4) 32 | #define AVERAGING_FILTER_BUF_SIZE (1 << AVERAGING_FILTER_BUF_SIZE_2N) 33 | 34 | // Expected sample period in seconds 35 | #define SIGNAL_GENERATOR_EXPECTED_SAMPLE_PERIOD TOFIX_TIME(0.02f) 36 | 37 | // This is the total decimation of the signal generator with respect to incoming data rate 38 | #define SIGNAL_GENERATOR_TOTAL_DECIMATION_2N (3) 39 | 40 | // This is the expected output sample period of the signal generator 41 | #define SIGNAL_GENERATOR_OUTPUT_SAMPLE_PERIOD (SIGNAL_GENERATOR_EXPECTED_SAMPLE_PERIOD << SIGNAL_GENERATOR_TOTAL_DECIMATION_2N) 42 | 43 | // This is the expected time delay of the signal generator output 44 | #define SIGNAL_GENERATOR_DELAY (((AVERAGING_FILTER_BUF_SIZE-1) * SIGNAL_GENERATOR_EXPECTED_SAMPLE_PERIOD) >> 1) 45 | 46 | /*-------------------------------------------------------------------------------------------------*\ 47 | | T Y P E D E F I N I T I O N S 48 | \*-------------------------------------------------------------------------------------------------*/ 49 | 50 | /*-------------------------------------------------------------------------------------------------*\ 51 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 52 | \*-------------------------------------------------------------------------------------------------*/ 53 | 54 | /*-------------------------------------------------------------------------------------------------*\ 55 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 56 | \*-------------------------------------------------------------------------------------------------*/ 57 | 58 | /*-------------------------------------------------------------------------------------------------*\ 59 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 60 | \*-------------------------------------------------------------------------------------------------*/ 61 | 62 | #ifdef __cplusplus 63 | extern "C" { 64 | #endif 65 | 66 | // Constructor 67 | void SignalGenerator_Init(void); 68 | 69 | // Returns true if filtered signal is updated 70 | osp_bool_t SignalGenerator_SetAccelerometerData(const osp_float_t accInMetersPerSecondSquare[NUM_ACCEL_AXES], osp_float_t* accFilteredOut); 71 | 72 | // Moving average function 73 | osp_float_t SignalGenerator_UpdateMovingWindowMean(osp_float_t * buffer, osp_float_t * pMeanAccumulator, 74 | osp_float_t newmeas, uint16_t idx, uint16_t buflen2N); 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | 81 | #endif //_SIGNALGENERATOR_H_ 82 | /*-------------------------------------------------------------------------------------------------*\ 83 | | E N D O F F I L E 84 | \*-------------------------------------------------------------------------------------------------*/ 85 | -------------------------------------------------------------------------------- /embedded/common/templates/__SourceFile.c: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2015 Audience Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | /*-------------------------------------------------------------------------------------------------*\ 19 | | I N C L U D E F I L E S 20 | \*-------------------------------------------------------------------------------------------------*/ 21 | #include "Common.h" 22 | 23 | 24 | /*-------------------------------------------------------------------------------------------------*\ 25 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 26 | \*-------------------------------------------------------------------------------------------------*/ 27 | 28 | /*-------------------------------------------------------------------------------------------------*\ 29 | | P R I V A T E C O N S T A N T S & M A C R O S 30 | \*-------------------------------------------------------------------------------------------------*/ 31 | 32 | /*-------------------------------------------------------------------------------------------------*\ 33 | | P R I V A T E T Y P E D E F I N I T I O N S 34 | \*-------------------------------------------------------------------------------------------------*/ 35 | 36 | /*-------------------------------------------------------------------------------------------------*\ 37 | | S T A T I C V A R I A B L E S D E F I N I T I O N S 38 | \*-------------------------------------------------------------------------------------------------*/ 39 | 40 | /*-------------------------------------------------------------------------------------------------*\ 41 | | F O R W A R D F U N C T I O N D E C L A R A T I O N S 42 | \*-------------------------------------------------------------------------------------------------*/ 43 | 44 | /*-------------------------------------------------------------------------------------------------*\ 45 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 46 | \*-------------------------------------------------------------------------------------------------*/ 47 | 48 | /*-------------------------------------------------------------------------------------------------*\ 49 | | P R I V A T E F U N C T I O N S 50 | \*-------------------------------------------------------------------------------------------------*/ 51 | /**************************************************************************************************** 52 | * @fn StaticFunc1 53 | * Helper routine for ??? 54 | * 55 | ***************************************************************************************************/ 56 | void StaticFunc1( void ) 57 | { 58 | } 59 | 60 | 61 | /*-------------------------------------------------------------------------------------------------*\ 62 | | P U B L I C F U N C T I O N S 63 | \*-------------------------------------------------------------------------------------------------*/ 64 | 65 | /**************************************************************************************************** 66 | * @fn ??? 67 | * 68 | * 69 | * @param none 70 | * 71 | * @return none 72 | * 73 | * @see ??? 74 | ***************************************************************************************************/ 75 | int someFunction ( int some_args ) 76 | { 77 | } 78 | 79 | 80 | /*-------------------------------------------------------------------------------------------------*\ 81 | | E N D O F F I L E 82 | \*-------------------------------------------------------------------------------------------------*/ 83 | -------------------------------------------------------------------------------- /embedded/projects/osp-steval-mki109v2/sources/boardsupport/stm32f10x_it.h: -------------------------------------------------------------------------------- 1 | /******************** (C) COPYRIGHT 2008 STMicroelectronics ******************** 2 | * File Name : stm32f10x_it.h 3 | * Author : MCD Application Team 4 | * Version : V2.0.1 5 | * Date : 06/13/2008 6 | * Description : This file contains the headers of the interrupt handlers. 7 | ******************************************************************************** 8 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 9 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. 10 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, 11 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE 12 | * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING 13 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 14 | *******************************************************************************/ 15 | 16 | /* Define to prevent recursive inclusion -------------------------------------*/ 17 | #ifndef __STM32F10x_IT_H 18 | #define __STM32F10x_IT_H 19 | 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "stm32f10x.h" 22 | 23 | /* Exported types ------------------------------------------------------------*/ 24 | /* Exported constants --------------------------------------------------------*/ 25 | /* Exported macro ------------------------------------------------------------*/ 26 | /* Exported functions ------------------------------------------------------- */ 27 | 28 | void NMI_Handler(void); 29 | void HardFault_Handler(void); 30 | void MemManage_Handler(void); 31 | void BusFault_Handler(void); 32 | void UsageFault_Handler(void); 33 | void DebugMon_Handler(void); 34 | void SVC_Handler(void); 35 | void PendSV_Handler(void); 36 | void SysTick_Handler(void); 37 | void WWDG_IRQHandler(void); 38 | void PVD_IRQHandler(void); 39 | void TAMPER_IRQHandler(void); 40 | void RTC_IRQHandler(void); 41 | void FLASH_IRQHandler(void); 42 | void RCC_IRQHandler(void); 43 | void EXTI0_IRQHandler(void); 44 | void EXTI1_IRQHandler(void); 45 | void EXTI2_IRQHandler(void); 46 | void EXTI3_IRQHandler(void); 47 | void EXTI4_IRQHandler(void); 48 | void DMA1_Channel1_IRQHandler(void); 49 | void DMA1_Channel2_IRQHandler(void); 50 | void DMA1_Channel3_IRQHandler(void); 51 | void DMA1_Channel4_IRQHandler(void); 52 | void DMA1_Channel5_IRQHandler(void); 53 | void DMA1_Channel6_IRQHandler(void); 54 | void DMA1_Channel7_IRQHandler(void); 55 | void ADC1_2_IRQHandler(void); 56 | void USB_HP_CAN1_TX_IRQHandler(void); 57 | void USB_LP_CAN1_RX0_IRQHandler(void); 58 | void CAN1_RX1_IRQHandler(void); 59 | void CAN1_SCE_IRQHandler(void); 60 | void EXTI9_5_IRQHandler(void); 61 | void TIM1_BRK_IRQHandler(void); 62 | void TIM1_UP_IRQHandler(void); 63 | void TIM1_TRG_COM_IRQHandler(void); 64 | void TIM1_CC_IRQHandler(void); 65 | void TIM2_IRQHandler(void); 66 | void TIM3_IRQHandler(void); 67 | void TIM4_IRQHandler(void); 68 | void I2C1_EV_IRQHandler(void); 69 | void I2C1_ER_IRQHandler(void); 70 | void I2C2_EV_IRQHandler(void); 71 | void I2C2_ER_IRQHandler(void); 72 | void SPI1_IRQHandler(void); 73 | void SPI2_IRQHandler(void); 74 | void USART1_IRQHandler(void); 75 | void USART2_IRQHandler(void); 76 | void USART3_IRQHandler(void); 77 | void EXTI15_10_IRQHandler(void); 78 | void RTCAlarm_IRQHandler(void); 79 | void USBWakeUp_IRQHandler(void); 80 | void TIM8_BRK_IRQHandler(void); 81 | void TIM8_UP_IRQHandler(void); 82 | void TIM8_TRG_COM_IRQHandler(void); 83 | void TIM8_CC_IRQHandler(void); 84 | void ADC3_IRQHandler(void); 85 | void FSMC_IRQHandler(void); 86 | void SDIO_IRQHandler(void); 87 | void TIM5_IRQHandler(void); 88 | void SPI3_IRQHandler(void); 89 | void UART4_IRQHandler(void); 90 | void UART5_IRQHandler(void); 91 | void TIM6_IRQHandler(void); 92 | void TIM7_IRQHandler(void); 93 | void DMA2_Channel1_IRQHandler(void); 94 | void DMA2_Channel2_IRQHandler(void); 95 | void DMA2_Channel3_IRQHandler(void); 96 | void DMA2_Channel4_5_IRQHandler(void); 97 | 98 | #endif /* __STM32F10x_IT_H */ 99 | 100 | /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/ 101 | -------------------------------------------------------------------------------- /external/MCU/NXP-5410x/CSLib/Inc/pdm_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * @brief PDM mic interface module 3 | * 4 | * @note 5 | * Copyright(C) NXP Semiconductors, 2014 6 | * All rights reserved. 7 | * 8 | * @par 9 | * Software that is described herein is for illustrative purposes only 10 | * which provides customers with programming information regarding the 11 | * LPC products. This software is supplied "AS IS" without any warranties of 12 | * any kind, and NXP Semiconductors and its licensor disclaim any and 13 | * all warranties, express or implied, including all implied warranties of 14 | * merchantability, fitness for a particular purpose and non-infringement of 15 | * intellectual property rights. NXP Semiconductors assumes no responsibility 16 | * or liability for the use of the software, conveys no license or rights under any 17 | * patent, copyright, mask work right, or any other intellectual property rights in 18 | * or to any products. NXP Semiconductors reserves the right to make changes 19 | * in the software without notification. NXP Semiconductors also makes no 20 | * representation or warranty that such application will be suitable for the 21 | * specified use without further testing or modification. 22 | * 23 | * @par 24 | * Permission to use, copy, modify, and distribute this software and its 25 | * documentation is hereby granted, under NXP Semiconductors' and its 26 | * licensor's relevant copyrights in the software, without fee, provided that it 27 | * is used in conjunction with NXP Semiconductors microcontrollers. This 28 | * copyright, permission, and disclaimer notice must appear in all copies of 29 | * this code. 30 | */ 31 | 32 | #ifndef __PDM_API_H_ 33 | #define __PDM_API_H_ 34 | 35 | #include 36 | #include 37 | #include 38 | #include "lpc_types.h" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /** @defgroup SH_PDM PDMLIB: PDM interface API 45 | * @ingroup SENSOR_HUB 46 | * @{ 47 | */ 48 | 49 | /** 50 | * @brief Initialize PDM module 51 | * @return Nothing 52 | * @note PDM Clock (Clk out or Timer1) should be configured by the application. 53 | */ 54 | extern void PDM_Init(void); 55 | 56 | /** 57 | * @brief Reset PDM interface 58 | * @return Nothing 59 | * @note This function resets the PDM (SI interface) state variables for a fresh start. 60 | */ 61 | extern void PDM_Reset(void); 62 | 63 | /** 64 | * @brief Start capturing PDM data 65 | * @return Nothing 66 | */ 67 | extern void PDM_Start(void); 68 | 69 | /** 70 | * @brief Stop capturing PDM data 71 | * @return Nothing 72 | */ 73 | extern void PDM_Stop(void); 74 | 75 | /****************************************************************************** 76 | * Callback routines 77 | *****************************************************************************/ 78 | /** 79 | * @brief PDM data ready callback 80 | * @return Nothing 81 | * @note This function is called by PDM block when data is ready. Partially 82 | * decimated data is available through @ref pdm_audio buffer and audio envelope_buffer 83 | * data for voice activity detection is available through @ref envelope_buffer. 84 | */ 85 | extern void PDM_DataReady(void); 86 | 87 | /** @brief Audio envelop data. 88 | Envelope information: 89 | - envelope_buffer[0] Fast detector 90 | - envelope_buffer[1] Slow detector 91 | - envelope_buffer[2] Reserved for internal use 92 | - envelope_buffer[3] Reserved for internal use 93 | - envelope_buffer[4] Latest biggest difference between fast and slow detector 94 | - envelope_buffer[5] latest output of pre envelope lowpass filter 95 | - envelope_buffer[6] latest output of pre envelope highpass filter 96 | 97 | */ 98 | extern volatile int32_t envelope_buffer[]; 99 | 100 | /** @brief Decimated PDM data. 101 | A DC cut filter should be applied on this data to get 16bit PCM samples @ 16KHz 102 | */ 103 | extern volatile int32_t pdm_audio[]; 104 | 105 | #define PDM_AUDIO_BUF_SIZE 32 106 | 107 | #define PDM_PONG (*((volatile unsigned *) 0x4004C044)) & (1 << 6) 108 | 109 | #define PDM_IRQn (IRQn_Type) 30 110 | 111 | /** 112 | * @} 113 | */ 114 | 115 | #ifdef __cplusplus 116 | } 117 | #endif 118 | 119 | #endif /* __PDM_API_H_ */ 120 | -------------------------------------------------------------------------------- /embedded/common/app/appmsgstruct.h: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2015 Audience Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | #if !defined (APPMSGSTRUCT_H) 19 | #define APPMSGSTRUCT_H 20 | 21 | /*-------------------------------------------------------------------------------------------------*\ 22 | | I N C L U D E F I L E S 23 | \*-------------------------------------------------------------------------------------------------*/ 24 | #include 25 | 26 | /*-------------------------------------------------------------------------------------------------*\ 27 | | C O N S T A N T S & M A C R O S 28 | \*-------------------------------------------------------------------------------------------------*/ 29 | 30 | /*-------------------------------------------------------------------------------------------------*\ 31 | | T Y P E D E F I N I T I O N S 32 | \*-------------------------------------------------------------------------------------------------*/ 33 | #pragma pack(push) /* push current alignment to stack */ 34 | #pragma pack(4) 35 | 36 | /* Generic structure to satisfy most sensor data passing */ 37 | typedef struct MsgSensorDataTag 38 | { 39 | uint64_t timeStamp; 40 | int32_t X; 41 | int32_t Y; 42 | int32_t Z; 43 | int32_t W; 44 | int32_t HeadingError; 45 | int32_t TiltError; 46 | } MsgSensorData; 47 | 48 | typedef struct MsgSensorBoolTag 49 | { 50 | uint64_t timeStamp; 51 | uint8_t active; 52 | } MsgSensorBoolData; 53 | 54 | 55 | typedef MsgSensorData MsgAccelData; 56 | typedef MsgSensorData MsgMagData; 57 | typedef MsgSensorData MsgGyroData; 58 | typedef MsgSensorData MsgQuaternionData; 59 | typedef MsgSensorData MsgStepData; 60 | typedef MsgSensorData MsgOrientationData; 61 | typedef MsgSensorData MsgGenericTriAxisData; 62 | typedef MsgSensorData MsgPressData; 63 | typedef MsgSensorBoolData MsgSigMotionData; 64 | typedef MsgSensorBoolData MsgStepDetData; 65 | 66 | typedef struct MsgSensorDataRdyTag 67 | { 68 | uint64_t timeStamp; 69 | uint8_t sensorId; 70 | } MsgSensorDataRdy; 71 | 72 | typedef struct MsgCDSegmentDataTag 73 | { 74 | uint64_t endTime; 75 | uint32_t duration; 76 | uint8_t type; 77 | } MsgCDSegmentData; 78 | 79 | typedef struct MsgSensorControlDataTag 80 | { 81 | uint32_t command; 82 | int32_t data; 83 | uint8_t sensorType; 84 | } MsgSensorControlData; 85 | 86 | typedef struct MsgCtrlReqTag 87 | { 88 | uint8_t *pRequestPacket; 89 | uint8_t length; 90 | } MsgCtrlReq; 91 | 92 | 93 | /*-------------------------------------------------------------------------------------------------*\ 94 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 95 | \*-------------------------------------------------------------------------------------------------*/ 96 | 97 | /*-------------------------------------------------------------------------------------------------*\ 98 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 99 | \*-------------------------------------------------------------------------------------------------*/ 100 | 101 | /*-------------------------------------------------------------------------------------------------*\ 102 | | P U B L I C F U N C T I O N D E C L A R A T I O N S 103 | \*-------------------------------------------------------------------------------------------------*/ 104 | 105 | #pragma pack(pop) /* restore original alignment from stack */ 106 | 107 | #endif /* APPMSGSTRUCT_H */ 108 | /*-------------------------------------------------------------------------------------------------*\ 109 | | E N D O F F I L E 110 | \*-------------------------------------------------------------------------------------------------*/ 111 | -------------------------------------------------------------------------------- /embedded/projects/SH-Xpresso-LPC54102/sources/app/taskinit_user.c: -------------------------------------------------------------------------------- 1 | /* Open Sensor Platform Project 2 | * https://github.com/sensorplatforms/open-sensor-platform 3 | * 4 | * Copyright (C) 2015 Audience Inc. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | /*-------------------------------------------------------------------------------------------------*\ 19 | | I N C L U D E F I L E S 20 | \*-------------------------------------------------------------------------------------------------*/ 21 | #include "common.h" 22 | 23 | /*-------------------------------------------------------------------------------------------------*\ 24 | | E X T E R N A L V A R I A B L E S & F U N C T I O N S 25 | \*-------------------------------------------------------------------------------------------------*/ 26 | 27 | /*-------------------------------------------------------------------------------------------------*\ 28 | | P U B L I C V A R I A B L E S D E F I N I T I O N S 29 | \*-------------------------------------------------------------------------------------------------*/ 30 | /* These are the tasks that will be created on startup. This list allows you to disable creation of 31 | one or more tasks in the system if so desired. Allows to have a different run modes with different 32 | task selection list */ 33 | const uint8_t NormalModeTaskList[] = { 34 | INSTR_MANAGER_TASK_ID, 35 | CMD_HNDLR_TASK_ID, 36 | SENSOR_ACQ_TASK_ID, 37 | HOST_INTF_TASK_ID, 38 | ALGORITHM_TASK_ID, 39 | ALG_BG_TASK_ID 40 | }; 41 | const uint8_t NormalModeTaskListSize = sizeof(NormalModeTaskList); 42 | 43 | /*-------------------------------------------------------------------------------------------------*\ 44 | | P R I V A T E C O N S T A N T S & M A C R O S 45 | \*-------------------------------------------------------------------------------------------------*/ 46 | 47 | /*-------------------------------------------------------------------------------------------------*\ 48 | | P R I V A T E T Y P E D E F I N I T I O N S 49 | \*-------------------------------------------------------------------------------------------------*/ 50 | 51 | /*-------------------------------------------------------------------------------------------------*\ 52 | | S T A T I C V A R I A B L E S D E F I N I T I O N S 53 | \*-------------------------------------------------------------------------------------------------*/ 54 | 55 | /*-------------------------------------------------------------------------------------------------*\ 56 | | F O R W A R D F U N C T I O N D E C L A R A T I O N S 57 | \*-------------------------------------------------------------------------------------------------*/ 58 | 59 | /*-------------------------------------------------------------------------------------------------*\ 60 | | P R I V A T E F U N C T I O N S 61 | \*-------------------------------------------------------------------------------------------------*/ 62 | 63 | /*-------------------------------------------------------------------------------------------------*\ 64 | | P U B L I C F U N C T I O N S 65 | \*-------------------------------------------------------------------------------------------------*/ 66 | 67 | /**************************************************************************************************** 68 | * @fn GetTaskList 69 | * Returns info on task list table and size based on application mode 70 | * 71 | * @param pointer to task list 72 | * 73 | * @return task count 74 | * 75 | ***************************************************************************************************/ 76 | uint8_t GetTaskList( uint8_t **pTaskList ) 77 | { 78 | *pTaskList = (uint8_t*)NormalModeTaskList; 79 | return NormalModeTaskListSize; 80 | } 81 | 82 | 83 | /*-------------------------------------------------------------------------------------------------*\ 84 | | E N D O F F I L E 85 | \*-------------------------------------------------------------------------------------------------*/ 86 | --------------------------------------------------------------------------------