ME11C Sample Code in Maxim Integrated Team
Dependencies: BMI160 max32630hsp3 MemoryLCD USBDevice
Fork of Host_Software_MAX32664GWEC_SpO2_HR-_EXTE by
SHMAX8614X/HostAccelHelper.h@0:b259fd1a88f5, 2019-03-18 (annotated)
- Committer:
- seyhmus.cacina
- Date:
- Mon Mar 18 14:09:48 2019 +0300
- Revision:
- 0:b259fd1a88f5
ME11C Sample Code First Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
seyhmus.cacina | 0:b259fd1a88f5 | 1 | /******************************************************************************* |
seyhmus.cacina | 0:b259fd1a88f5 | 2 | * Copyright (C) 2018 Maxim Integrated Products, Inc., All Rights Reserved. |
seyhmus.cacina | 0:b259fd1a88f5 | 3 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
seyhmus.cacina | 0:b259fd1a88f5 | 5 | * copy of this software and associated documentation files (the "Software"), |
seyhmus.cacina | 0:b259fd1a88f5 | 6 | * to deal in the Software without restriction, including without limitation |
seyhmus.cacina | 0:b259fd1a88f5 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
seyhmus.cacina | 0:b259fd1a88f5 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
seyhmus.cacina | 0:b259fd1a88f5 | 9 | * Software is furnished to do so, subject to the following conditions: |
seyhmus.cacina | 0:b259fd1a88f5 | 10 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 11 | * The above copyright notice and this permission notice shall be included |
seyhmus.cacina | 0:b259fd1a88f5 | 12 | * in all copies or substantial portions of the Software. |
seyhmus.cacina | 0:b259fd1a88f5 | 13 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
seyhmus.cacina | 0:b259fd1a88f5 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
seyhmus.cacina | 0:b259fd1a88f5 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
seyhmus.cacina | 0:b259fd1a88f5 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
seyhmus.cacina | 0:b259fd1a88f5 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
seyhmus.cacina | 0:b259fd1a88f5 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
seyhmus.cacina | 0:b259fd1a88f5 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
seyhmus.cacina | 0:b259fd1a88f5 | 21 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
seyhmus.cacina | 0:b259fd1a88f5 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
seyhmus.cacina | 0:b259fd1a88f5 | 24 | * Products, Inc. Branding Policy. |
seyhmus.cacina | 0:b259fd1a88f5 | 25 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 26 | * The mere transfer of this software does not imply any licenses |
seyhmus.cacina | 0:b259fd1a88f5 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
seyhmus.cacina | 0:b259fd1a88f5 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
seyhmus.cacina | 0:b259fd1a88f5 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
seyhmus.cacina | 0:b259fd1a88f5 | 30 | * ownership rights. |
seyhmus.cacina | 0:b259fd1a88f5 | 31 | ******************************************************************************* |
seyhmus.cacina | 0:b259fd1a88f5 | 32 | */ |
seyhmus.cacina | 0:b259fd1a88f5 | 33 | |
seyhmus.cacina | 0:b259fd1a88f5 | 34 | #ifndef _HOST_ACCEL_HELPER_H_ |
seyhmus.cacina | 0:b259fd1a88f5 | 35 | #define _HOST_ACCEL_HELPER_H_ |
seyhmus.cacina | 0:b259fd1a88f5 | 36 | |
seyhmus.cacina | 0:b259fd1a88f5 | 37 | #include <stdint.h> |
seyhmus.cacina | 0:b259fd1a88f5 | 38 | |
seyhmus.cacina | 0:b259fd1a88f5 | 39 | /* Struct defining the sample of accelerometer |
seyhmus.cacina | 0:b259fd1a88f5 | 40 | * Note: as alogorithms expect data as mg or g ; calculations needs to be done over raws accel sensordata and convert to mg or g |
seyhmus.cacina | 0:b259fd1a88f5 | 41 | * acceld data is feed to sensor hub in mg or g format for all 3 axis,s data. Float definitions below are for mg and g |
seyhmus.cacina | 0:b259fd1a88f5 | 42 | * calculations and can be modified to work with fixed point data type. |
seyhmus.cacina | 0:b259fd1a88f5 | 43 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 44 | * */ |
seyhmus.cacina | 0:b259fd1a88f5 | 45 | typedef struct _accel_data_t { |
seyhmus.cacina | 0:b259fd1a88f5 | 46 | float x; |
seyhmus.cacina | 0:b259fd1a88f5 | 47 | float y; |
seyhmus.cacina | 0:b259fd1a88f5 | 48 | float z; |
seyhmus.cacina | 0:b259fd1a88f5 | 49 | int16_t x_raw; |
seyhmus.cacina | 0:b259fd1a88f5 | 50 | int16_t y_raw; |
seyhmus.cacina | 0:b259fd1a88f5 | 51 | int16_t z_raw; |
seyhmus.cacina | 0:b259fd1a88f5 | 52 | } accel_data_t; |
seyhmus.cacina | 0:b259fd1a88f5 | 53 | |
seyhmus.cacina | 0:b259fd1a88f5 | 54 | /** |
seyhmus.cacina | 0:b259fd1a88f5 | 55 | * @brief Initialize the accelerometer on the host device |
seyhmus.cacina | 0:b259fd1a88f5 | 56 | */ |
seyhmus.cacina | 0:b259fd1a88f5 | 57 | void CSTMR_SH_HostAccelerometerInitialize(); |
seyhmus.cacina | 0:b259fd1a88f5 | 58 | |
seyhmus.cacina | 0:b259fd1a88f5 | 59 | /** |
seyhmus.cacina | 0:b259fd1a88f5 | 60 | * @brief Set default parameters for the accelerometer |
seyhmus.cacina | 0:b259fd1a88f5 | 61 | */ |
seyhmus.cacina | 0:b259fd1a88f5 | 62 | void CSTMR_SH_HostAccelerometerSetDefaults(); |
seyhmus.cacina | 0:b259fd1a88f5 | 63 | |
seyhmus.cacina | 0:b259fd1a88f5 | 64 | /** |
seyhmus.cacina | 0:b259fd1a88f5 | 65 | * @brief Set the sampling rate of the accelerometer |
seyhmus.cacina | 0:b259fd1a88f5 | 66 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 67 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 68 | * @return 0 on SUCCESS |
seyhmus.cacina | 0:b259fd1a88f5 | 69 | */ |
seyhmus.cacina | 0:b259fd1a88f5 | 70 | int CSTMR_SH_HostAccelerometerSetSampleRate(int sampleRate); |
seyhmus.cacina | 0:b259fd1a88f5 | 71 | |
seyhmus.cacina | 0:b259fd1a88f5 | 72 | /** |
seyhmus.cacina | 0:b259fd1a88f5 | 73 | * @brief Enable data ready interrupt of the accelerometer |
seyhmus.cacina | 0:b259fd1a88f5 | 74 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 75 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 76 | * @return 0 on SUCCESS |
seyhmus.cacina | 0:b259fd1a88f5 | 77 | */ |
seyhmus.cacina | 0:b259fd1a88f5 | 78 | int CSTMR_SH_HostAccelerometerEnableDataReadyInterrupt(); |
seyhmus.cacina | 0:b259fd1a88f5 | 79 | |
seyhmus.cacina | 0:b259fd1a88f5 | 80 | /** |
seyhmus.cacina | 0:b259fd1a88f5 | 81 | * @brief Gets a sample from the accelerometer if the sample is ready |
seyhmus.cacina | 0:b259fd1a88f5 | 82 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 83 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 84 | * @return 0 on SUCCESS |
seyhmus.cacina | 0:b259fd1a88f5 | 85 | */ |
seyhmus.cacina | 0:b259fd1a88f5 | 86 | int CSTMR_SH_HostAccelerometerGet_sensor_xyz(accel_data_t *accel_data); |
seyhmus.cacina | 0:b259fd1a88f5 | 87 | |
seyhmus.cacina | 0:b259fd1a88f5 | 88 | /** |
seyhmus.cacina | 0:b259fd1a88f5 | 89 | * @brief Add the given sample to the accelerometer queue |
seyhmus.cacina | 0:b259fd1a88f5 | 90 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 91 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 92 | * @return 0 on SUCCESS |
seyhmus.cacina | 0:b259fd1a88f5 | 93 | */ |
seyhmus.cacina | 0:b259fd1a88f5 | 94 | int CSTMR_SH_HostAccelerometerEnqueueData(accel_data_t *accel_data); |
seyhmus.cacina | 0:b259fd1a88f5 | 95 | |
seyhmus.cacina | 0:b259fd1a88f5 | 96 | /** |
seyhmus.cacina | 0:b259fd1a88f5 | 97 | * @brief Get the sample count in the accelerometer queue |
seyhmus.cacina | 0:b259fd1a88f5 | 98 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 99 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 100 | * @return 0 on SUCCESS |
seyhmus.cacina | 0:b259fd1a88f5 | 101 | */ |
seyhmus.cacina | 0:b259fd1a88f5 | 102 | int CSTMR_SH_HostAccelerometerGetDataCount(); |
seyhmus.cacina | 0:b259fd1a88f5 | 103 | |
seyhmus.cacina | 0:b259fd1a88f5 | 104 | /** |
seyhmus.cacina | 0:b259fd1a88f5 | 105 | * @brief Get a sample from the accelerometer queue |
seyhmus.cacina | 0:b259fd1a88f5 | 106 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 107 | * |
seyhmus.cacina | 0:b259fd1a88f5 | 108 | * @return 0 on SUCCESS |
seyhmus.cacina | 0:b259fd1a88f5 | 109 | */ |
seyhmus.cacina | 0:b259fd1a88f5 | 110 | int CSTMR_SH_HostAccelerometerDequeuData(accel_data_t *accel_data); |
seyhmus.cacina | 0:b259fd1a88f5 | 111 | |
seyhmus.cacina | 0:b259fd1a88f5 | 112 | |
seyhmus.cacina | 0:b259fd1a88f5 | 113 | |
seyhmus.cacina | 0:b259fd1a88f5 | 114 | |
seyhmus.cacina | 0:b259fd1a88f5 | 115 | |
seyhmus.cacina | 0:b259fd1a88f5 | 116 | |
seyhmus.cacina | 0:b259fd1a88f5 | 117 | #endif |
seyhmus.cacina | 0:b259fd1a88f5 | 118 |