ISF  2.1
Intelligent Sensing Framework for Kinetis with Processor Expert
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
FXLS8471_1.c
Go to the documentation of this file.
1 /* ###################################################################
2 ** THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
3 ** Filename : FXLS8471_1.c
4 ** CDE edition : Community
5 ** Project : ISF_K64F_CW_PROJ
6 ** Processor : MK64FN1M0VLL12
7 ** Component : ISF_Sensor_FXLS8471_Accelerometer
8 ** Version : Component 01.000, Driver 01.00, CPU db: 3.00.000
9 ** Compiler : GNU C Compiler
10 ** Date/Time : 2015-03-03, 11:01, # CodeGen: 0
11 ** Abstract :
12 **
13 ** Settings :
14 ** Contents :
15 ** No public methods
16 **
17 ** For non-commercial use only.
18 (c) Copyright <company/user-name>, 2014
19 http://www.<company>.com
20 mail: info@<company>.com
21 ** ###################################################################*/
22 /*!
23 ** @file FXLS8471_1.c
24 ** @version 01.00
25 ** @brief
26 **
27 */
28 /*!
29 ** @addtogroup FXLS8471_1_module FXLS8471_1 module documentation
30 ** @{
31 */
32 
33 /* MODULE FXLS8471_1. */
34 
35 #include "FXLS8471_1.h"
36 #include "isf_target.h"
37 #include "isf.h"
38 #include "isf_spi_master_types.h"
39 #include "isf_util.h"
40 #include "GPIO1.h"
41 
43 isf_status_t fsl_veryon_spi_slave_write_preprocess(void *pCmdOut, uint32 offset, uint32 size, void *pWritebuffer);
46 isf_status_t fsl_veryon_spi_slave_read_postprocess(void *pCmdOut, void* pDataOut);
47 
49 {
50  .accelFullScaleRange = 0, // Capture the accelerometer full-scale range for use in conversion routines.
51  .regCount = 41, // Number of register pairs to follow
52  .regPairs =
53  {
54  { FXLS8471_F_SETUP, 0 },
55  { FXLS8471_TRIG_CFG, 0 },
56  // Data configuration registers.
58  { FXLS8471_HP_FILTER_CUTOFF, (FXLS8471_SET_FIELD(PULSE_HPF_BYP,0)) | (FXLS8471_SET_FIELD(PULSE_LPF_EN,0)) | (FXLS8471_SET_FIELD(SEL,0)) },
59  // Portrait Landscape registers.
60  { FXLS8471_PL_CFG, (FXLS8471_SET_FIELD(DBCNTM,1)) | (FXLS8471_SET_FIELD(PL_EN,0)) },
61  { FXLS8471_PL_COUNT, 0 },
63  { FXLS8471_PL_THS, (FXLS8471_SET_FIELD(PL_THS,16)) | (FXLS8471_SET_FIELD(HYS,4)) },
64  { FXLS8471_PULSE_THSX, 0 },
65  { FXLS8471_PULSE_THSY, 0 },
66  { FXLS8471_PULSE_THSZ, 0 },
67  // Freefall/Motion Detection registers.
68  { FXLS8471_FFMT_CFG, (FXLS8471_SET_FIELD(A_FFMT_ELE,0)) | (FXLS8471_SET_FIELD(A_FFMT_OAE,0)) | (FXLS8471_SET_FIELD(A_FFMT_ZEFE,0)) | (FXLS8471_SET_FIELD(A_FFMT_YEFE,0)) | (FXLS8471_SET_FIELD(A_FFMT_XEFE,0)) },
69  { FXLS8471_FFMT_THS, (FXLS8471_SET_FIELD(A_FFMT_DBCNTM,0)) | (FXLS8471_SET_FIELD(A_FFMT_THS,0)) },
70  { FXLS8471_A_FFMT_THS_X_MSB, (FXLS8471_SET_FIELD(A_FFMT_THS_XYZ_EN,0) | 0 ) },
76  { FXLS8471_FFMT_COUNT, 0 },
77  // Transient Detection registers.
78  { FXLS8471_TRANSIENT_CFG, 0 }, // Feature disabled by default (for now).
79  // Pulse Detection registers.
80  { FXLS8471_PULSE_CFG, 0 }, // Feature is disabled by default (for now).
81  // Auto-WAKE/SLEEP Detection registers.
82  { FXLS8471_ASLP_COUNT, 0 },
83  // System and Control registers.
84  { FXLS8471_CTRL_REG1, (FXLS8471_SET_FIELD(ASLP_RATE,0)) | (FXLS8471_SET_FIELD(DR,0)) | (FXLS8471_SET_FIELD(LNOISE,0)) | (FXLS8471_SET_FIELD(FREAD,0)) },
85  { FXLS8471_CTRL_REG2, (FXLS8471_SET_FIELD(SMODS,0)) | (FXLS8471_SET_FIELD(SLPE,0)) | (FXLS8471_SET_FIELD(MODS,0)) },
86  { FXLS8471_CTRL_REG3, 0 }, // Interrupt sources disabled, Active Low, Push-Pull Open Drain (defaults).
87  { FXLS8471_CTRL_REG4, 0 }, // Interrupts disabled (defaults).
88  { FXLS8471_CTRL_REG5, 0 }, // INT2 Pin (defaults).
89  // Calibration Offset registers.
90  { FXLS8471_OFF_X, 0 },
91  { FXLS8471_OFF_Y, 0 },
92  { FXLS8471_OFF_Z, 0 },
93  // Vector Magnitude Configuration registers.
94  { FXLS8471_A_VECM_CFG, (FXLS8471_SET_FIELD(A_VECM_ELE,0)) | (FXLS8471_SET_FIELD(A_VECM_INITM,0)) | (FXLS8471_SET_FIELD(A_VECM_UPDM,0)) | (FXLS8471_SET_FIELD(A_VECM_EN,0)) },
95  { FXLS8471_A_VECM_THS_MSB, (FXLS8471_SET_FIELD(A_VECM_DBCNTM,0)) | (FXLS8471_SET_FIELD(A_VECM_THS_MSB, 0)) },
97  { FXLS8471_A_VECM_CNT, 0 },
104  }
105  };
106 
107 /*!
108  * @brief This creates the sensor adapter instance for the target sensor.
109  *
110  */
112 {
114  .devInfo.pSupportedSensorDataTypes = fxls8471_SupportedDataTypes,
115  .devInfo.nNativeDataSetSize = sizeof(fxls8471_DataBuffer_t),
116  .control.Initialize = &fsl_fxls8471_i2cspi_3D_accel_Initialize,
117  .control.ValidateSettings = &fsl_fxls8471_i2cspi_3D_accel_ValidateSettings,
118  .control.Configure = &fsl_fxls8471_i2cspi_3D_accel_Configure,
119  .control.StartData = &fsl_fxls8471_i2cspi_3D_accel_StartData,
120  .control.EndData = &fsl_fxls8471_i2cspi_3D_accel_EndData,
121  .control.Calibrate = &fsl_fxls8471_i2cspi_3D_accel_Calibrate,
122  .control.Shutdown = &fsl_fxls8471_i2cspi_3D_accel_Shutdown,
123  .control.Convert = &fsl_fxls8471_i2cspi_3D_accel_Convert
124 };
125 
126 #define FSL_SENSOR_SPI_CMD_LENG 0x2
133 };
134 
135 
137 {
138  .busConfig =
139  {
140  .timeout = 0x5000,
141  .config.busFrequencyKHz = 300,
142  .config.polarity = kSpiClockPolarity_ActiveHigh,
143  .config.phase = kSpiClockPhase_FirstEdge,
144  .config.direction = kSpiMsbFirst
145  },
146  .pSlaveInfo = &fsl_spi_sensor_type
147 };
148 
149 static LDD_TDeviceData* pGPIO_LDD;
150 
151 static uint8 spiWriteBuffer[64];
152 static uint8 spiReadBuffer[64];
153 
155 {
156  // Call the GPIO_LDD function to initialize the chip-select.
157  pGPIO_LDD = GPIO1_Init(NULL);
158  return ISF_SUCCESS;
159 }
160 
161 isf_status_t fsl_veryon_spi_slave_write_preprocess(void *pCmdOut, uint32 offset, uint32 size, void *pWritebuffer)
162 {
163 
164  spi_mater_slaveCmd_t* pSlaveCmd = (spi_mater_slaveCmd_t*)pCmdOut;
165 
166  uint8 *pWBuff = (uint8*)spiWriteBuffer;
167  uint8 *pRBuff = (uint8 *)(pWBuff + (size + FSL_SENSOR_SPI_CMD_LENG));
168  // formatting the command for the FSL_SENSORS
169  *pWBuff = offset | 0x80 ; // offset is the internal register address of the sensor at which write is performed.
170  *(pWBuff + 1) = offset & 0x80 ; // offset is the internal register address of the sensor at which write is performed.
171  // Copy the command
172  ISF_MEM_CPY((uint8*)pWritebuffer, (pWBuff + 2), size);
173  // Create the slave command.
174  pSlaveCmd->size = size + FSL_SENSOR_SPI_CMD_LENG;
175  pSlaveCmd->pWriteBuffer = (uint8*)pWBuff;
176  pSlaveCmd->pReadBuffer = (uint8*)pRBuff;
177  // Call the GPIO_LDD function to clear chip-select.
178  GPIO1_ClearPortBits(pGPIO_LDD,GPIO1_ALLOCATED_PINS_MASK);
179  return ISF_SUCCESS;
180 }
181 
183 {
184  spi_mater_slaveCmd_t* pSlaveCmd = (spi_mater_slaveCmd_t*)pCmdOut;
185 
186  // Call the GPIO_LDD function to set chip-select.
187  GPIO1_SetPortBits(pGPIO_LDD,GPIO1_ALLOCATED_PINS_MASK);
188  return ISF_SUCCESS;
189 }
190 
192 {
193 
194  spi_mater_slaveCmd_t* pSlaveCmd = (spi_mater_slaveCmd_t*)pCmdOut;
195 
196  uint8 *pWBuff = (uint8*)spiReadBuffer;
197  uint8 *pRBuff = (uint8 *)(pWBuff + (size + FSL_SENSOR_SPI_CMD_LENG));
198  // formatting the command for the FSL_SENSORS
199  *pWBuff = offset & 0x7F ; // offset is the internal register address of the sensor at which write is performed.
200  *(pWBuff + 1) = offset & 0x80 ; // offset is the internal register address of the sensor at which write is performed.
201  // Note: We don't care what the values are at *pWBuff after the first two bytes.
202  // Create the slave command.
203  pSlaveCmd->size = size + FSL_SENSOR_SPI_CMD_LENG;
204  pSlaveCmd->pWriteBuffer = (uint8*)pWBuff;
205  pSlaveCmd->pReadBuffer = (uint8*)pRBuff;
206  // Call the GPIO_LDD function to clear chip-select.
207  GPIO1_ClearPortBits(pGPIO_LDD,GPIO1_ALLOCATED_PINS_MASK);
208  return ISF_SUCCESS;
209 }
210 
212 {
213 
214  spi_mater_slaveCmd_t* pSlaveCmd = (spi_mater_slaveCmd_t*)pCmdOut;
215 
216  ISF_MEM_CPY((uint8*)(pSlaveCmd->pReadBuffer + FSL_SENSOR_SPI_CMD_LENG), pDataOut , (pSlaveCmd->size - FSL_SENSOR_SPI_CMD_LENG) );
217  // Call the GPIO_LDD function to set chip-select.
218  GPIO1_SetPortBits(pGPIO_LDD,GPIO1_ALLOCATED_PINS_MASK);
219  return ISF_SUCCESS;
220 }
221 
222 
223 /* END FXLS8471_1. */
224 
225 /*!
226 ** @}
227 */
228 /*
229 ** ###################################################################
230 **
231 ** This file was created by Processor Expert 10.3 [05.09]
232 ** for the Freescale Kinetis series of microcontrollers.
233 **
234 ** ###################################################################
235 */
ISF board support header files.
unsigned char uint8
This defines uint8 as unsigned char.
Definition: isf_types.h:18
isf_status_t(* fnreadpostProcossing_t)(void *cmd, void *dataOut)
spi_master_slaveInfo_t fsl_spi_sensor_type
Definition: FXLS8471_1.c:127
#define ISF_MEM_CPY(src, dest, number_of_bytes)
Macro for the memory copy.
Definition: isf_util.h:68
isf_status_t(* fnwritepreProcessing_t)(void *cmdOut, uint32 offset, uint32 size, void *writebuffer)
isf_status_t fsl_veryon_spi_slave_write_postprocess(void *pCmdOut)
Definition: FXLS8471_1.c:182
isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_EndData(isf_SensorHandle_t *pSensorHandle)
isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_Shutdown(isf_SensorHandle_t *pSensorHandle)
isf_status_t(* fnwritepostProcossing_t)(void *cmd)
fxls8471_Sensor_Specific_Settings_t FXLS8471_1_Sensor_Specific_Config
This allows access to the sensor specific configuration for the target sensor.
Definition: FXLS8471_1.c:48
isf_status_t fsl_veryon_spi_slave_read_preprocess(void *pCmdOut, uint32 offset, uint32 size)
Definition: FXLS8471_1.c:191
This structure defines the slave specific spi information.
unsigned long uint32
This defines uint32 as unsigned long.
Definition: isf_types.h:36
spi_master_busConfig_t busConfig
isf_status_t(* fnslaveinit_t)(void)
#define FXLS8471_SET_FIELD(name, val)
Definition: fxls8471.h:96
const spi_master_CommSpecificInfo_t FXLS8471_1_DeviceInfo
This allows access to the sensor communications specific configuration.
Definition: FXLS8471_1.c:136
isf_dsa_status_t fsl_fxls8471_i2cspi_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_fxls8471_i2cspi_3D_accel_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
isf_status_t fsl_veryon_spi_slave_read_postprocess(void *pCmdOut, void *pDataOut)
Definition: FXLS8471_1.c:211
isf_dsa_DeviceInfoBlock_t devInfo
isf_SensorTypes_t fxls8471_SupportedSensorTypes[]
Supported sensor and data types for FXLS8471.
The isf_util.h file contains the utility method declarations and macros.
isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData)
This defines the DSA adapter structure required for static initialization of the concrete instance of...
isf_status_t(* fnreadpreProcessing_t)(void *cmdout, uint32 offset, uint32 size)
isf_status_t fsl_veryon_spi_slave_write_preprocess(void *pCmdOut, uint32 offset, uint32 size, void *pWritebuffer)
Definition: FXLS8471_1.c:161
isf_SensorTypes_t * pSupportedSensorTypes
This structure defines the spi slave command format.
#define FSL_SENSOR_SPI_CMD_LENG
Definition: FXLS8471_1.c:126
isf_SensorDataTypes_t fxls8471_SupportedDataTypes[]
isf_status_t fsl_veryon_spi_slave_init(void)
Definition: FXLS8471_1.c:154
const isf_dsa_Adapter_t FXLS8471_1_Adapter
This creates the sensor adapter instance for the target sensor.
Definition: FXLS8471_1.c:111
Main ISF header file. Contains code common to all ISF components.
isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_StartData(isf_SensorHandle_t *pSensorHandle)
int32 isf_status_t
ISF return status type.
Definition: isf.h:51
This structure defines the dummy DSA data buffer format.
isf_spi_master_types.h defines the spi protocol adapter structure and types.
isf_dsa_status_t fsl_fxls8471_i2cspi_3D_accel_Initialize(isf_SensorHandle_t *pSensorHandle)