ISF  2.2 rev 5
Intelligent Sensing Framework for Kinetis with Processor Expert
FXAS21002_2.c
Go to the documentation of this file.
1 /* ###################################################################
2 ** This component module is generated by Processor Expert. Do not modify it.
3 ** Filename : FXAS21002_2.c
4 ** CDE edition : Standard
5 ** Project : ISF2P2_K64F_MQX_PROJ
6 ** Processor : MK64FN1M0VLL12
7 ** Component : ISF_KSDK_Sensor_FXAS21002_Gyrometer
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 : FXAS21002_2
16 ** Device Address : 0x20
17 ** Comm Channel : SPI1
18 ** Is SPI Selected : yes
19 ** Chip Select : SensorReset
20 ** Allowed Full-scale Ranges : ±250 dps (FXAS21002)
21 ** Sensor Specific Configuration : yes
22 ** CTRL_REG0 : yes
23 ** BW : 0
24 ** SPIW : 0
25 ** SEL : 0
26 ** HPF_EN : 0
27 ** FS : 3
28 ** CTRL_REG1 : yes
29 ** DR : 0
30 ** CTRL_REG3 : yes
31 ** WRAPTOONE : 0
32 ** EXTCTRLEN : 0
33 ** FS_DOUBLE : 0
34 ** Contents :
35 ** No public methods
36 **
37 ** (c) Copyright <company/user-name>, 2015,
38 http://www.<company>.com
39 mail: info@<company>.com
40 ** ###################################################################*/
41 /*!
42 ** @file FXAS21002_2.c
43 ** @version 01.00
44 ** @brief
45 **
46 */
47 /*!
48 ** @addtogroup FXAS21002_2_module FXAS21002_2 module documentation
49 ** @{
50 */
51 
52 /* MODULE FXAS21002_2. */
53 
54 #include "FXAS21002_2.h"
55 #include "isf_target.h"
56 #include "isf.h"
57 #include "isf_util.h"
58 #include "isf_spi_master_types.h"
59 #include "SensorReset.h"
60 
62 isf_status_t fsl_leon_spi_slave_write_preprocess(void *pCmdOut, uint32 offset, uint32 size, void *pWritebuffer);
65 isf_status_t fsl_leon_spi_slave_read_postprocess(void *pCmdOut, void* pDataOut);
66 
68 {
69  .gyroFullScaleRange = 3, // Capture the accelerometer full-scale range for use in conversion routines.
70  .fsdouble = 0,
71  .regCount = 4, // Number of register pairs to follow
72  .regPairs =
73  {
74  // System and Control registers.
77  { FXAS21002_CTRL_REG2, 0 }, // Interrupt sources disabled, Active Low, Push-Pull Open Drain (defaults).
78  { FXAS21002_CTRL_REG3, (FXAS21002_SET_FIELD(WRAPTOONE,0)) | (FXAS21002_SET_FIELD(EXTCTRLEN,0)) | (FXAS21002_SET_FIELD(FSDOUBLE,0)) },
79  }
80  };
81 
82 /*!
83  * @brief This creates the sensor adapter instance for the target sensor.
84  *
85  */
87 {
89  .devInfo.pSupportedSensorDataTypes = fxas21002_SupportedDataTypes,
90  .devInfo.nNativeDataSetSize = sizeof(fxas21002_DataBuffer_t),
91  .control.Initialize = &fsl_fxas21002_i2cspi_3D_gyro_Initialize,
92  .control.ValidateSettings = &fsl_fxas21002_i2cspi_3D_gyro_ValidateSettings,
93  .control.Configure = &fsl_fxas21002_i2cspi_3D_gyro_Configure,
94  .control.StartData = &fsl_fxas21002_i2cspi_3D_gyro_StartData,
95  .control.EndData = &fsl_fxas21002_i2cspi_3D_gyro_EndData,
96  .control.Calibrate = &fsl_fxas21002_i2cspi_3D_gyro_Calibrate,
97  .control.Shutdown = &fsl_fxas21002_i2cspi_3D_gyro_Shutdown,
98  .control.Convert = &fsl_fxas21002_i2cspi_3D_gyro_Convert
99 };
100 
101 
102 #define FSL_SENSOR_SPI_CMD_LENG 0x1
109 };
110 
111 
113 {
114  .busConfig =
115  {
116  .timeout = 1000U,
117  .device =
118  {
119  .bitsPerSec = 500000U,
120  .dataBusConfig.bitsPerFrame = 8U,
121  .dataBusConfig.clkPolarity = kDspiClockPolarity_ActiveHigh,
122  .dataBusConfig.clkPhase = kDspiClockPhase_FirstEdge,
123  .dataBusConfig.direction = kDspiMsbFirst,
124  },
125  .userConfig =
126  {
127  .whichCtar = kDspiCtar0,
128  .isSckContinuous = false,
129  .isChipSelectContinuous = false,
130  .whichPcs = kDspiPcs0,
131  .pcsPolarity = kDspiPcs_ActiveHigh,
132  },
133  },
134  .pSlaveInfo = &fsl_spi_sensor_type_FXAS21002_2
135 };
136 
137 static uint8 spiRead_CmdBuffer[64];
138 static uint8 spiRead_DataBuffer[64];
139 static uint8 spiWrite_CmdDataBuffer[64];
140 
142 {
143  // Call the GPIO_LDD function to initialize the chip-select.
144  GPIO_DRV_OutputPinInit(&(ResetSensor_OutConfig0));
145 
146  return ISF_SUCCESS;
147 }
148 
149 isf_status_t fsl_leon_spi_slave_write_preprocess(void *pCmdOut, uint32 offset, uint32 size, void *pWritebuffer)
150 {
151  spi_mater_slaveCmd_t* pSlaveCmd = (spi_mater_slaveCmd_t*)pCmdOut;
152 
153  uint8 *pWBuff = spiWrite_CmdDataBuffer;
154  uint8 *pRBuff = spiWrite_CmdDataBuffer + size + FSL_SENSOR_SPI_CMD_LENG;
155 
156  // formatting the command for the FSL_SENSORS
157  *pWBuff = offset & 0x7F ; // offset is the internal register address of the sensor at which write is performed.
158 
159  // Copy the command
160  ISF_MEM_CPY((uint8*)pWritebuffer, (pWBuff + FSL_SENSOR_SPI_CMD_LENG), size);
161 
162  // Create the slave command.
163  pSlaveCmd->size = size + FSL_SENSOR_SPI_CMD_LENG;
164  pSlaveCmd->pWriteBuffer = (uint8*)pWBuff;
165  pSlaveCmd->pReadBuffer = (uint8*)pRBuff;
166 
167  // Call the GPIO_LDD function to clear chip-select.
168  GPIO_DRV_ClearPinOutput(J1_1);
169 
170  return ISF_SUCCESS;
171 }
172 
174 {
175  // Call the GPIO_LDD function to set chip-select.
176  GPIO_DRV_SetPinOutput(J1_1);
177 
178  return ISF_SUCCESS;
179 }
180 
182 {
183  spi_mater_slaveCmd_t* pSlaveCmd = (spi_mater_slaveCmd_t*)pCmdOut;
184 
185  uint8 *pWBuff = spiRead_CmdBuffer;
186  uint8 *pRBuff = spiRead_DataBuffer;
187 
188  // formatting the command for the FSL_SENSORS
189  *pWBuff = offset | 0x80 ; // offset is the internal register address of the sensor at which write is performed.
190 
191  // Create the slave command.
192  pSlaveCmd->size = size + FSL_SENSOR_SPI_CMD_LENG;
193  pSlaveCmd->pWriteBuffer = (uint8*)pWBuff;
194  pSlaveCmd->pReadBuffer = (uint8*)pRBuff;
195 
196  // Call the GPIO_LDD function to clear chip-select.
197  GPIO_DRV_ClearPinOutput(J1_1);
198 
199  return ISF_SUCCESS;
200 }
201 
202 isf_status_t fsl_leon_spi_slave_read_postprocess(void *pCmdOut, void* pDataOut)
203 {
204  spi_mater_slaveCmd_t* pSlaveCmd = (spi_mater_slaveCmd_t*)pCmdOut;
205 
206  ISF_MEM_CPY((uint8*)(pSlaveCmd->pReadBuffer + FSL_SENSOR_SPI_CMD_LENG), pDataOut , (pSlaveCmd->size - FSL_SENSOR_SPI_CMD_LENG) );
207 
208  // Call the GPIO_LDD function to set chip-select.
209  GPIO_DRV_SetPinOutput(J1_1);
210 
211  return ISF_SUCCESS;
212 }
213 
214 /* END FXAS21002_2. */
215 
216 /*!
217 ** @}
218 */
219 /*
220 ** ###################################################################
221 **
222 ** This file was created by Processor Expert 10.5 [05.21]
223 ** for the Freescale Kinetis series of microcontrollers.
224 **
225 ** ###################################################################
226 */
ISF board support header files.
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_Calibrate(isf_SensorHandle_t *pSensorHandle, void *pCalData)
This is the concrete implementation of the FXAS21002 sensor adapter for calibration ...
unsigned char uint8
Definition: isf_types.h:76
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_EndData(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXAS21002 sensor adapter for End Data. ...
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_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.
#define FSL_SENSOR_SPI_CMD_LENG
Definition: FXAS21002_2.c:102
#define ISF_MEM_CPY(src, dest, number_of_bytes)
Macro for the memory copy.
Definition: isf_util.h:68
This structure defines the dummy DSA data buffer format.
isf_SensorTypes_t fxas21002_SupportedSensorTypes[]
Supported sensor and data types for FXAS21002.
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_Configure(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
This is the concrete implementation of the FXAS21002 sensor adapter for configuration.
const spi_master_CommSpecificInfo_t FXAS21002_2_DeviceInfo
This allows access to the sensor communications specific configuration.
Definition: FXAS21002_2.c:112
This structure defines the slave specific spi information.
spi_master_busConfig_t busConfig
isf_status_t fsl_leon_spi_slave_write_postprocess(void *pCmdOut)
Definition: FXAS21002_2.c:173
const gpio_output_pin_user_config_t ResetSensor_OutConfig0[]
Configuration structure 0 for output pins.
Definition: ResetSensor.c:56
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_StartData(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXAS21002 sensor adapter for start Data.
isf_dsa_DeviceInfoBlock_t devInfo
The isf_util.h file contains the utility method declarations and macros.
spi_master_slaveInfo_t fsl_spi_sensor_type_FXAS21002_2
Definition: FXAS21002_2.c:103
#define FXAS21002_SET_FIELD(name, val)
Definition: fxas21002.h:66
This defines the DSA adapter structure required for static initialization of the concrete instance of...
isf_SensorTypes_t * pSupportedSensorTypes
isf_status_t(* fnwritepreProcessing_t)(void *cmdOut, uint32 offset, uint32 size, void *writebuffer)
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_ValidateSettings(isf_SensorHandle_t *pSensorHandle, isf_dsa_SensorSettings_t *pSensorSettings)
This is the concrete implementation of the FXAS21002 sensor adapter for validating current settings...
This structure defines the spi slave command format.
isf_status_t fsl_leon_spi_slave_read_postprocess(void *pCmdOut, void *pDataOut)
Definition: FXAS21002_2.c:202
isf_status_t(* fnwritepostProcossing_t)(void *cmd)
Main ISF header file. Contains code common to all ISF components.
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_Shutdown(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXAS21002 sensor adapter for shutdown .
isf_SensorDataTypes_t fxas21002_SupportedDataTypes[]
isf_status_t(* fnreadpreProcessing_t)(void *cmdout, uint32 offset, uint32 size)
const isf_dsa_Adapter_t FXAS21002_2_Adapter
This creates the sensor adapter instance for the target sensor.
Definition: FXAS21002_2.c:86
int32 isf_status_t
ISF return status type.
Definition: isf.h:76
isf_status_t fsl_leon_spi_slave_read_preprocess(void *pCmdOut, uint32 offset, uint32 size)
Definition: FXAS21002_2.c:181
isf_dsa_status_t fsl_fxas21002_i2cspi_3D_gyro_Initialize(isf_SensorHandle_t *pSensorHandle)
This is the concrete implementation of the FXAS21002 sensor adapter initialization.
isf_spi_master_types.h defines the spi protocol adapter structure and types.
isf_status_t(* fnreadpostProcossing_t)(void *cmd, void *dataOut)
fxas21002_Sensor_Specific_Settings_t FXAS21002_2_Sensor_Specific_Config
This allows access to the sensor specific configuration for the target sensor.
Definition: FXAS21002_2.c:67
unsigned long int uint32
Definition: isf_types.h:78
isf_status_t fsl_leon_spi_slave_write_preprocess(void *pCmdOut, uint32 offset, uint32 size, void *pWritebuffer)
Definition: FXAS21002_2.c:149
isf_status_t fsl_leon_spi_slave_init(void)
Definition: FXAS21002_2.c:141
isf_status_t(* fnslaveinit_t)(void)