ISF  2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
MMA865x_1.c
Go to the documentation of this file.
1 /* ###################################################################
2 ** This component module is generated by Processor Expert. Do not modify it.
3 ** Filename : MMA865x_1.c
4 ** CDE edition : Community
5 ** Project : ISF2P2_K64F_MQX_PROJ
6 ** Processor : MK64FN1M0VLL12
7 ** Component : ISF_KSDK_Sensor_MMA865x_Accelerometer
8 ** Version : Component 02.500, Driver 01.00, CPU db: 3.00.000
9 ** Repository : My Components
10 ** Compiler : GNU C Compiler
11 ** Date/Time : 2016-10-06, 13:38, # CodeGen: 0
12 ** Abstract :
13 **
14 ** Settings :
15 ** Component Name : MMA865x_1
16 ** Device Address : 0x1D
17 ** Comm Channel : I2C1
18 ** Allowed Sample Rates : 800Hz
19 ** Allowed Full-scale Range : ±2 g
20 ** Sensor Specific Configuration : yes
21 ** XYZ_DATA_CFG : yes
22 ** HPF_OUT : 0
23 ** FS : 0
24 ** HP_FILTER_CUTOFF : yes
25 ** PULSE_HPF_BYP : 0
26 ** PULSE_LPF_EN : 0
27 ** SEL : 0
28 ** PL_CFG : yes
29 ** DBCNTM : 1
30 ** PL_EN : 0
31 ** PL_COUNT : 0
32 ** FF_MT_CFG : yes
33 ** ELE : 0
34 ** OAE : 0
35 ** ZEFE : 0
36 ** YEFE : 0
37 ** XEFE : 0
38 ** FF_MT_THS : yes
39 ** DBCNTM : 0
40 ** THS : 0
41 ** FF_MT_COUNT : 0
42 ** CTRL_REG1 : yes
43 ** F_READ : 0
44 ** CTRL_REG2 : yes
45 ** SMODS : 0
46 ** SLPE : 0
47 ** MODS : 0
48 ** Contents :
49 ** No public methods
50 **
51 ** (c) Copyright Freescale Semiconductor Inc, 2015
52 http://www.freescale.com
53 ** ###################################################################*/
54 /*!
55 ** @file MMA865x_1.c
56 ** @version 01.00
57 ** @brief
58 **
59 */
60 /*!
61 ** @addtogroup MMA865x_1_module MMA865x_1 module documentation
62 ** @{
63 */
64 
65 /* MODULE MMA865x_1. */
66 
67 #include "MMA865x_1.h"
68 #include "mma865x.h"
69 
71 {
72  .accelFullScaleRange = 0, // Capture the accelerometer full-scale range for use in conversion routines.
73  .regCount = 20, // Number of register pairs to follow
74  .regPairs =
75  {
76  // Data configuration registers.
77  { MMA865x_XYZ_DATA_CFG, (MMA865x_SET_FIELD(HPF_OUT,0)) | (MMA865x_SET_FIELD(FS,0)) },
78  { MMA865x_HP_FILTER_CUTOFF, (MMA865x_SET_FIELD(PULSE_HPF_BYP,0)) | (MMA865x_SET_FIELD(PULSE_LPF_EN,0)) | (MMA865x_SET_FIELD(SEL,0)) },
79  // Portrait Landscape registers.
80  { MMA865x_PL_CFG, (MMA865x_SET_FIELD(DBCNTM,1)) | (MMA865x_SET_FIELD(PL_EN,0)) },
81  { MMA865x_PL_COUNT, 0 },
82  { MMA865x_PL_BF_ZCOMP, (MMA865x_SET_FIELD(BKFR,1)) | (MMA865x_SET_FIELD(ZLOCK,4)) },
83  { MMA865x_PL_P_L_THS, (MMA865x_SET_FIELD(P_L_THS,16)) | (MMA865x_SET_FIELD(HYS,4)) },
84  // Freefall/Motion Detection registers.
85  { MMA865x_FF_MT_CFG, (MMA865x_SET_FIELD(ELE,0)) | (MMA865x_SET_FIELD(OAE,0)) | (MMA865x_SET_FIELD(ZEFE,0)) | (MMA865x_SET_FIELD(YEFE,0)) | (MMA865x_SET_FIELD(XEFE,0)) },
86  { MMA865x_FF_MT_THS, (MMA865x_SET_FIELD(DBCNTM,0)) | (MMA865x_SET_FIELD(THS,0)) },
87  { MMA865x_FF_MT_COUNT, 0 },
88  // Transient Detection registers.
89  { MMA865x_TRANSIENT_CFG, 0 }, // Feature disabled by default (for now).
90  // Pulse Detection registers.
91  { MMA865x_PULSE_CFG, 0 }, // Feature is disabled by default (for now).
92  // Auto-WAKE/SLEEP Detection registers.
93  { MMA865x_ASLP_COUNT, 0 },
94  // System and Control registers.
95  { MMA865x_CTRL_REG1, (MMA865x_SET_FIELD(ASLP_RATE,0)) | (MMA865x_SET_FIELD(DR,0)) | (MMA865x_SET_FIELD(FREAD,0)) },
96  { MMA865x_CTRL_REG2, (MMA865x_SET_FIELD(ST,0)) | (MMA865x_SET_FIELD(RST,0)) | (MMA865x_SET_FIELD(SMODS,0)) | (MMA865x_SET_FIELD(SLPE,0)) | (MMA865x_SET_FIELD(MODS,0)) },
97  { MMA865x_CTRL_REG3, 0 }, // Interrupt sources disabled, Active Low, Push-Pull Open Drain (defaults).
98  { MMA865x_CTRL_REG4, 0 }, // Interrupts disabled (defaults).
99  { MMA865x_CTRL_REG5, 0 }, // INT2 Pin (defaults).
100  // Calibration Offset registers.
101  { MMA865x_OFF_X, 0 },
102  { MMA865x_OFF_Y, 0 },
103  { MMA865x_OFF_Z, 0 }
104  }
105  };
106 
107 /*!
108  * @brief This creates the sensor adapter instance for the target sensor.
109  *
110  */
112 {
114  .devInfo.pSupportedSensorDataTypes = mma865x_SupportedDataTypes,
115  .devInfo.nNativeDataSetSize = sizeof(mma865x_DataBuffer_t),
116  .control.Initialize = &fsl_mma865x_i2c_3D_accel_Initialize,
117  .control.ValidateSettings = &fsl_mma865x_i2c_3D_accel_ValidateSettings,
118  .control.Configure = &fsl_mma865x_i2c_3D_accel_Configure,
119  .control.StartData = &fsl_mma865x_i2c_3D_accel_StartData,
120  .control.EndData = &fsl_mma865x_i2c_3D_accel_EndData,
121  .control.Calibrate = &fsl_mma865x_i2c_3D_accel_Calibrate,
122  .control.Shutdown = &fsl_mma865x_i2c_3D_accel_Shutdown,
123  .control.Convert = &fsl_mma865x_i2c_3D_accel_Convert
124 };
125 
126 const i2c_device_t MMA865x_1_DeviceInfo =
127 {
128  .baudRate_kbps = 400, // default baud rate (kbps).
129  .address = 29 // instance specific device address.
130 };
131 
132 
133 /* END MMA865x_1. */
134 
135 /*!
136 ** @}
137 */
138 /*
139 ** ###################################################################
140 **
141 ** This file was created by Processor Expert 10.5 [05.21]
142 ** for the Freescale Kinetis series of microcontrollers.
143 **
144 ** ###################################################################
145 */
isf_dsa_status_t fsl_mma865x_i2c_3D_accel_Initialize(isf_SensorHandle_t *pSensorHandle)
This structure defines the dummy DSA data buffer format.
isf_dsa_status_t fsl_mma865x_i2c_3D_accel_EndData(isf_SensorHandle_t *pSensorHandle)
isf_dsa_status_t fsl_mma865x_i2c_3D_accel_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData)
const isf_dsa_Adapter_t MMA865x_1_Adapter
This creates the sensor adapter instance for the target sensor.
Definition: MMA865x_1.c:111
The mma865x.h contains the MMA865x Accelerometer register definitions, access macros, and device access functions.
isf_dsa_status_t fsl_mma865x_i2c_3D_accel_StartData(isf_SensorHandle_t *pSensorHandle)
isf_SensorDataTypes_t mma865x_SupportedDataTypes[]
#define MMA865x_SET_FIELD(name, val)
Definition: mma865x.h:81
isf_dsa_DeviceInfoBlock_t devInfo
isf_SensorTypes_t mma865x_SupportedSensorTypes[]
Supported sensor and data types for MMA865x.
isf_dsa_status_t fsl_mma865x_i2c_3D_accel_Convert(volatile isf_SensorHandle_t *pSensorHandle, isf_SensorDataTypes_t convertToType, isf_dsa_result_types_t resultType, void *pNativeSample, void *pConvertedSample, int32 *numBytes)
This function coverts the raw sample data to the desired output type.
isf_dsa_status_t fsl_mma865x_i2c_3D_accel_Shutdown(isf_SensorHandle_t *pSensorHandle)
This defines the DSA adapter structure required for static initialization of the concrete instance of...
isf_SensorTypes_t * pSupportedSensorTypes
const i2c_device_t MMA865x_1_DeviceInfo
This allows access to the sensor communications specific configuration.
Definition: MMA865x_1.c:126
isf_dsa_status_t fsl_mma865x_i2c_3D_accel_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
isf_dsa_status_t fsl_mma865x_i2c_3D_accel_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
mma865x_Sensor_Specific_Settings_t MMA865x_1_Sensor_Specific_Config
This allows access to the sensor specific configuration for the target sensor.
Definition: MMA865x_1.c:70