| ISF 2.1 Intelligent Sensing Framework for Kinetis with Processor Expert

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
isf_dsa_utils.c
Go to the documentation of this file.
1 /*
2 * @file isf_dsa_utils.c
3 *
4 * @brief The \b isf_dsa_utils.c file contains implementation of the static
5 * ISF Digital Sensor Abstraction utility functions
6 *
7 * @copyright Copyright (c) 2014, Freescale Semiconductor, Inc.
8 */
9
10 #include <isf_dsa_utils.h>
11
12 #include "isf_dsa_adapter.h"
13 #include "isf_sensor_types.h"
14
15 /*
16 ** The following functions are available to be called for all sensor adapters implementing the
17 ** ISF DSA interface.
18 */
19
20 /*!
21 * @brief This function returns the supported sensor types for the specified adapter.
22 * The first call to isf_dsa_get_sensor_types() should be made with *sensorListIdx == 0.
23 The function automatically increments the sensorListIdx value allowing subsequent calls
24 to return additional supported types.
25 The function sets sensorListIdx back to zero when no more new sensor types are available.
26 This allows calls in the form of:
27 uint8 sensorListIdx = 0;
28 isf_dsa_SensorType_t sensorType;
29
30 do {
31 sensorType = isf_dsa_get_sensor_types(isf_dsa_Adapter_t *adapter, &sensorListIdx );
32 handleSensorType(sensorType);
33 while (!sensorListIdx);
34 */
35 isf_SensorTypes_t isf_dsa_get_sensor_types ( isf_dsa_Adapter_t *adapter, uint8 *sensorListIdx)
36 {
37 isf_SensorTypes_t t = adapter->devInfo.pSupportedSensorTypes[*sensorListIdx];
38
39 // Advance the list index. Reset to zero at end of list.
40 *sensorListIdx = (t) ? *sensorListIdx+1 : 0;
41
42 return t;
43 }
44
45
46
47 /*!
48 * @brief This function returns the supported sensor data types for the specified adapter.
49 * The first call to isf_dsa_get_sensor_data_types() should be made with sensorListIdx == 0.
50 The function automatically increments the sensorListIdx value allowing subsequent calls
51 to return additional supported types.
52 The function sets sensorListIdx back to zero when no more new sensor types are available.
53 This allows calls in the form of:
54 uint8 sensorListIdx = 0;
55 isf_dsa_SensorDataType_t sensorDataType;
56
57 do {
58 sensorDataType = isf_dsa_get_sensor_data_types(isf_dsa_Adapter_t *adapter, &sensorListIdx );
59 handleSensorDataType(sensorDataType);
60 } while (!sensorListIdx);
61 */
62 isf_SensorDataTypes_t isf_dsa_get_sensor_data_types ( isf_dsa_Adapter_t *adapter, uint8 *sensorDataListIdx)
63 {
64 isf_SensorTypes_t t = adapter->devInfo.pSupportedSensorDataTypes[*sensorDataListIdx];
65
66 // Advance the list index. Reset to zero at end of list.
67 *sensorDataListIdx = (t) ? *sensorDataListIdx+1 : 0;
68
69 return t;
70 }
71
72
73 /*!
74 * @brief Returns the number of bytes required to hold the sensor's native data type.
75 Note that using the sensor's native data type violates the sensor type abstraction
76 and potentially limits any code using it to working with only that particular sensor.
77 It is recognized, however, that having access to the native data type may be useful in some
78 applications and this is why support for it is made available here.
79 */
80 uint32 isf_dsa_get_sizeof_native_data_type( isf_dsa_Adapter_t *adapter)
81 {
82 return adapter->devInfo.nNativeDataSetSize;
83 }
84
85
86 /*!
87 * @brief Returns a pointer to an adapter's Convert function which may be used to convert
88 * native data samples to supported standard data types.
89 */
90 isf_dsa_data_converter_t *isf_dsa_get_data_converter ( isf_dsa_Adapter_t *adapter )
91 {
92 return adapter->control.Convert;
93 }
94
95
96 /*!
97 * @brief Returns a pointer to an adapter's Info structure that contains things like
98 * the adapter identifier
99 */
100 const isf_dsa_DeviceInfoBlock_t *isf_dsa_get_info ( isf_dsa_Adapter_t *adapter )
101 {
102 return &adapter->devInfo;
103 }
isf_dsa_utils.h
uint8
unsigned char uint8
This defines uint8 as unsigned char.
Definition: isf_types.h:18
isf_dsa_adapter.h
isf_dsa_DeviceInfoBlock_st::nNativeDataSetSize
uint8 nNativeDataSetSize
Definition: isf_dsa_adapter.h:74
isf_dsa_data_converter_t
isf_dsa_status_t( isf_dsa_data_converter_t)(volatile isf_SensorHandle_t *, isf_SensorDataTypes_t, isf_dsa_result_types_t, void *, void *, int32 *numBytes)
Definition: isf_dsa_adapter.h:122
isf_dsa_Adapter_st::control
isf_dsa_ControlInterface_t control
Definition: isf_dsa_adapter.h:147
isf_dsa_DeviceInfoBlock_st
This defines the DSA adapter device information block.
Definition: isf_dsa_adapter.h:70
uint32
unsigned long uint32
This defines uint32 as unsigned long.
Definition: isf_types.h:36
isf_SensorTypes_t
isf_SensorTypes_t
Definition: isf_sensor_types.h:14
isf_dsa_get_data_converter
isf_dsa_data_converter_t * isf_dsa_get_data_converter(isf_dsa_Adapter_t *adapter)
Returns a pointer to an adapter's Convert function which may be used to convert native data samples t...
Definition: isf_dsa_utils.c:90
isf_dsa_ControlInterface_st::Convert
isf_dsa_data_converter_t * Convert
Definition: isf_dsa_adapter.h:136
isf_dsa_Adapter_st::devInfo
isf_dsa_DeviceInfoBlock_t devInfo
Definition: isf_dsa_adapter.h:146
isf_dsa_DeviceInfoBlock_st::pSupportedSensorDataTypes
isf_SensorDataTypes_t * pSupportedSensorDataTypes
Definition: isf_dsa_adapter.h:73
isf_sensor_types.h
The isf_sensor_types.h contains the enumerated list of sensor types used by ISF.
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
isf_dsa_get_sensor_data_types
isf_SensorDataTypes_t isf_dsa_get_sensor_data_types(isf_dsa_Adapter_t *adapter, uint8 *sensorDataListIdx)
This function returns the supported sensor data types for the specified adapter. The first call to is...
Definition: isf_dsa_utils.c:62
isf_dsa_get_sizeof_native_data_type
uint32 isf_dsa_get_sizeof_native_data_type(isf_dsa_Adapter_t *adapter)
Returns the number of bytes required to hold the sensor's native data type. Note that using the senso...
Definition: isf_dsa_utils.c:80
isf_dsa_DeviceInfoBlock_st::pSupportedSensorTypes
isf_SensorTypes_t * pSupportedSensorTypes
Definition: isf_dsa_adapter.h:72
isf_SensorDataTypes_t
isf_SensorDataTypes_t
Definition: isf_sensor_types.h:61
isf_dsa_get_sensor_types
isf_SensorTypes_t isf_dsa_get_sensor_types(isf_dsa_Adapter_t *adapter, uint8 *sensorListIdx)
This function returns the supported sensor types for the specified adapter. The first call to isf_dsa...
Definition: isf_dsa_utils.c:35
isf_dsa_get_info
const isf_dsa_DeviceInfoBlock_t * isf_dsa_get_info(isf_dsa_Adapter_t *adapter)
Returns a pointer to an adapter's Info structure that contains things like the adapter identifier...
Definition: isf_dsa_utils.c:100
- © Freescale Semiconductor, Inc. 2015. All Rights Reserved.