| ISF 2.2 rev 5 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

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
61 isf_status_t fsl_leon_spi_slave_init(void);
62 isf_status_t fsl_leon_spi_slave_write_preprocess(void *pCmdOut, uint32 offset, uint32 size, void *pWritebuffer);
63 isf_status_t fsl_leon_spi_slave_write_postprocess(void *pCmdOut);
64 isf_status_t fsl_leon_spi_slave_read_preprocess(void *pCmdOut, uint32 offset, uint32 size);
65 isf_status_t fsl_leon_spi_slave_read_postprocess(void *pCmdOut, void* pDataOut);
66
67 fxas21002_Sensor_Specific_Settings_t FXAS21002_2_Sensor_Specific_Config =
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.
75 { FXAS21002_CTRL_REG0, (FXAS21002_SET_FIELD(BW,0)) | (FXAS21002_SET_FIELD(SPIW,0)) | (FXAS21002_SET_FIELD(HPF_EN,0)) | (FXAS21002_SET_FIELD(FS,3)) },
76 { FXAS21002_CTRL_REG1, (FXAS21002_SET_FIELD(DR,0)) },
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 */
86 const isf_dsa_Adapter_t FXAS21002_2_Adapter =
87 {
88 .devInfo.pSupportedSensorTypes = fxas21002_SupportedSensorTypes,
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
103 spi_master_slaveInfo_t fsl_spi_sensor_type_FXAS21002_2 = {
104 .slaveinit = (fnslaveinit_t)&fsl_leon_spi_slave_init,
105 .writepreProcess = (fnwritepreProcessing_t)fsl_leon_spi_slave_write_preprocess,
106 .writepostProcess = (fnwritepostProcossing_t)fsl_leon_spi_slave_write_postprocess,
107 .readpreProcess = (fnreadpreProcessing_t)fsl_leon_spi_slave_read_preprocess,
108 .readpostProcess = (fnreadpostProcossing_t)fsl_leon_spi_slave_read_postprocess
109 };
110
111
112 const spi_master_CommSpecificInfo_t FXAS21002_2_DeviceInfo =
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
141 isf_status_t fsl_leon_spi_slave_init(void)
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
173 isf_status_t fsl_leon_spi_slave_write_postprocess(void *pCmdOut)
174 {
175 // Call the GPIO_LDD function to set chip-select.
176 GPIO_DRV_SetPinOutput(J1_1);
177
178 return ISF_SUCCESS;
179 }
180
181 isf_status_t fsl_leon_spi_slave_read_preprocess(void *pCmdOut, uint32 offset, uint32 size)
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 */
fxas21002_Sensor_Specific_Settings_t::gyroFullScaleRange
uint8 gyroFullScaleRange
Definition: fxas21002.h:213
spi_mater_SlaveCmd::size
uint32 size
Definition: isf_spi_master_types.h:39
isf_target.h
ISF board support header files.
fsl_fxas21002_i2cspi_3D_gyro_Calibrate
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 ...
Definition: fsl_fxas21002_i2cspi_3D_gyro.c:564
uint8
unsigned char uint8
Definition: isf_types.h:76
spi_mater_slaveInfo::slaveinit
fnslaveinit_t slaveinit
Definition: isf_spi_master_types.h:53
fsl_fxas21002_i2cspi_3D_gyro_EndData
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. ...
Definition: fsl_fxas21002_i2cspi_3D_gyro.c:498
fsl_fxas21002_i2cspi_3D_gyro_Convert
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.
Definition: fsl_fxas21002_i2cspi_3D_gyro.c:727
spi_master_CommSpecificInfo_t
Definition: isf_spi_master_types.h:60
FSL_SENSOR_SPI_CMD_LENG
#define FSL_SENSOR_SPI_CMD_LENG
Definition: FXAS21002_2.c:102
ISF_SUCCESS
Definition: isf.h:31
ISF_MEM_CPY
#define ISF_MEM_CPY(src, dest, number_of_bytes)
Macro for the memory copy.
Definition: isf_util.h:68
SensorReset.h
fxas21002_DataBuffer_t
This structure defines the dummy DSA data buffer format.
Definition: fsl_fxas21002_i2cspi_3D_gyro.h:25
fxas21002_SupportedSensorTypes
isf_SensorTypes_t fxas21002_SupportedSensorTypes[]
Supported sensor and data types for FXAS21002.
Definition: fsl_fxas21002_i2cspi_3D_gyro.c:54
fsl_fxas21002_i2cspi_3D_gyro_Configure
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.
Definition: fsl_fxas21002_i2cspi_3D_gyro.c:306
FXAS21002_2_DeviceInfo
const spi_master_CommSpecificInfo_t FXAS21002_2_DeviceInfo
This allows access to the sensor communications specific configuration.
Definition: FXAS21002_2.c:112
spi_mater_slaveInfo
This structure defines the slave specific spi information.
Definition: isf_spi_master_types.h:51
spi_master_CommSpecificInfo_t::busConfig
spi_master_busConfig_t busConfig
Definition: isf_spi_master_types.h:63
fsl_leon_spi_slave_write_postprocess
isf_status_t fsl_leon_spi_slave_write_postprocess(void *pCmdOut)
Definition: FXAS21002_2.c:173
spi_mater_SlaveCmd::pWriteBuffer
uint8 * pWriteBuffer
Definition: isf_spi_master_types.h:41
ResetSensor_OutConfig0
const gpio_output_pin_user_config_t ResetSensor_OutConfig0[]
Configuration structure 0 for output pins.
Definition: ResetSensor.c:56
fsl_fxas21002_i2cspi_3D_gyro_StartData
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.
Definition: fsl_fxas21002_i2cspi_3D_gyro.c:436
J1_1
Definition: SensorReset.h:82
isf_dsa_Adapter_st::devInfo
isf_dsa_DeviceInfoBlock_t devInfo
Definition: isf_dsa_adapter.h:146
FXAS21002_CTRL_REG3
Definition: fxas21002.h:56
isf_util.h
The isf_util.h file contains the utility method declarations and macros.
fsl_spi_sensor_type_FXAS21002_2
spi_master_slaveInfo_t fsl_spi_sensor_type_FXAS21002_2
Definition: FXAS21002_2.c:103
FXAS21002_SET_FIELD
#define FXAS21002_SET_FIELD(name, val)
Definition: fxas21002.h:66
isf_dsa_Adapter_st
This defines the DSA adapter structure required for static initialization of the concrete instance of...
Definition: isf_dsa_adapter.h:144
FXAS21002_CTRL_REG1
Definition: fxas21002.h:54
isf_dsa_DeviceInfoBlock_st::pSupportedSensorTypes
isf_SensorTypes_t * pSupportedSensorTypes
Definition: isf_dsa_adapter.h:70
fnwritepreProcessing_t
isf_status_t(* fnwritepreProcessing_t)(void *cmdOut, uint32 offset, uint32 size, void *writebuffer)
Definition: isf_spi_master_types.h:45
fxas21002_Sensor_Specific_Settings_t
Definition: fxas21002.h:210
fsl_fxas21002_i2cspi_3D_gyro_ValidateSettings
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...
Definition: fsl_fxas21002_i2cspi_3D_gyro.c:267
spi_mater_SlaveCmd
This structure defines the spi slave command format.
Definition: isf_spi_master_types.h:36
fsl_leon_spi_slave_read_postprocess
isf_status_t fsl_leon_spi_slave_read_postprocess(void *pCmdOut, void *pDataOut)
Definition: FXAS21002_2.c:202
fnwritepostProcossing_t
isf_status_t(* fnwritepostProcossing_t)(void *cmd)
Definition: isf_spi_master_types.h:46
isf.h
Main ISF header file. Contains code common to all ISF components.
fsl_fxas21002_i2cspi_3D_gyro_Shutdown
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 .
Definition: fsl_fxas21002_i2cspi_3D_gyro.c:581
FXAS21002_CTRL_REG0
Definition: fxas21002.h:48
fxas21002_SupportedDataTypes
isf_SensorDataTypes_t fxas21002_SupportedDataTypes[]
Definition: fsl_fxas21002_i2cspi_3D_gyro.c:55
fnreadpreProcessing_t
isf_status_t(* fnreadpreProcessing_t)(void *cmdout, uint32 offset, uint32 size)
Definition: isf_spi_master_types.h:47
FXAS21002_2_Adapter
const isf_dsa_Adapter_t FXAS21002_2_Adapter
This creates the sensor adapter instance for the target sensor.
Definition: FXAS21002_2.c:86
isf_status_t
int32 isf_status_t
ISF return status type.
Definition: isf.h:76
spi_mater_SlaveCmd::pReadBuffer
uint8 * pReadBuffer
Definition: isf_spi_master_types.h:40
fsl_leon_spi_slave_read_preprocess
isf_status_t fsl_leon_spi_slave_read_preprocess(void *pCmdOut, uint32 offset, uint32 size)
Definition: FXAS21002_2.c:181
fsl_fxas21002_i2cspi_3D_gyro_Initialize
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.
Definition: fsl_fxas21002_i2cspi_3D_gyro.c:181
isf_spi_master_types.h
isf_spi_master_types.h defines the spi protocol adapter structure and types.
fnreadpostProcossing_t
isf_status_t(* fnreadpostProcossing_t)(void *cmd, void *dataOut)
Definition: isf_spi_master_types.h:48
FXAS21002_2_Sensor_Specific_Config
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
spi_master_BusConfig_struct::timeout
isf_duration_t timeout
Definition: isf_spi_master_types.h:21
uint32
unsigned long int uint32
Definition: isf_types.h:78
fsl_leon_spi_slave_write_preprocess
isf_status_t fsl_leon_spi_slave_write_preprocess(void *pCmdOut, uint32 offset, uint32 size, void *pWritebuffer)
Definition: FXAS21002_2.c:149
fsl_leon_spi_slave_init
isf_status_t fsl_leon_spi_slave_init(void)
Definition: FXAS21002_2.c:141
fnslaveinit_t
isf_status_t(* fnslaveinit_t)(void)
Definition: isf_spi_master_types.h:44
FXAS21002_CTRL_REG2
Definition: fxas21002.h:55
FXAS21002_2.h
- © Freescale Semiconductor, Inc. 2016. All Rights Reserved.