ISSDK  1.7
IoT Sensing Software Development Kit
sensor_io_spi.h
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
4  * Copyright 2016-2017 NXP
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without modification,
8  * are permitted (subject to the limitations in the disclaimer below) provided
9  * that the following conditions are met:
10  *
11  * o Redistributions of source code must retain the above copyright notice, this list
12  * of conditions and the following disclaimer.
13  *
14  * o Redistributions in binary form must reproduce the above copyright notice, this
15  * list of conditions and the following disclaimer in the documentation and/or
16  * other materials provided with the distribution.
17  *
18  * o Neither the name of the copyright holder nor the names of its
19  * contributors may be used to endorse or promote products derived from this
20  * software without specific prior written permission.
21  *
22  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 /**
36  * @file sensor_io_spi.h
37  * @brief The sensor_io_spi.h file declares low-level interface functions for reading
38  * and writing sensor registers using CMSIS APIs.
39  */
40 
41 #ifndef __SENSOR_IO_SPI_H
42 #define __SENSOR_IO_SPI_H
43 
44 #include <stdint.h>
45 #include <stdbool.h>
46 #include "Driver_SPI.h"
47 #include "register_io_spi.h"
48 
49 /*******************************************************************************
50  * API
51  ******************************************************************************/
52 /*! @brief Write commands to a sensor
53 
54  * @param[in] pCommDrv pointer to the I2C ARM driver to use.
55  * @param[in] devInfo The SPI device number and idle function.
56  * @param[in] pWriteParams The SPI slave slect handle of the sensor to write to.
57  * @param[in] pCommandList A list of one or more commands to write.
58  * @param[in] error_mask The mask for Error Code Bits in CoCo Byte.
59  *
60  * @return returns the execution status of the operation using ::ESensorErrors
61  */
62 int32_t Sensor_SPI_BlockWrite(ARM_DRIVER_SPI *pCommDrv,
63  registerDeviceInfo_t *devInfo,
64  void *pWriteParams,
65  const registercommandlist_t *pCommandList,
66  uint8_t error_mask);
67 
68 /*! @brief Write register data to a sensor
69 
70  * @param[in] pCommDrv Pointer to the SPI ARM driver to use
71  * @param[in] devInfo The SPI device number and idle function.
72  * @param[in] pWriteParams SPI slave Params to write to.
73  * @param[in] pRegWriteList A list of one or more register/value pairs to write.
74  *
75  * @return returns the execution status of the operation using ::ESensorErrors
76  */
77 int32_t Sensor_SPI_Write(ARM_DRIVER_SPI *pCommDrv,
78  registerDeviceInfo_t *devInfo,
79  void *pWriteParams,
80  const registerwritelist_t *pRegWriteList);
81 
82 /*! @brief Read register data from a sensor
83 
84  * @param[in] pCommDrv Pointer to the SPI ARM driver to use.
85  * @param[in] devInfo The SPI device number and idle function.
86  * @param[in] pReadParams SPI slave Params read from.
87  * @param[in] pReadList A list of one or more register addresses and lengths to read.
88  * @param[in] pOutBuffer A pointer of sufficient size to contain the requested read data.
89  *
90  * @return returns the execution status of the operation using ::ESensorErrors
91  */
92 int32_t Sensor_SPI_Read(ARM_DRIVER_SPI *pCommDrv,
93  registerDeviceInfo_t *devInfo,
94  void *pReadParams,
95  const registerreadlist_t *pReadList,
96  uint8_t *pOutBuffer);
97 
98 #endif /* __SENSOR_IO_SPI_H */
int32_t Sensor_SPI_Read(ARM_DRIVER_SPI *pCommDrv, registerDeviceInfo_t *devInfo, void *pReadParams, const registerreadlist_t *pReadList, uint8_t *pOutBuffer)
Read register data from a sensor.
int32_t Sensor_SPI_BlockWrite(ARM_DRIVER_SPI *pCommDrv, registerDeviceInfo_t *devInfo, void *pWriteParams, const registercommandlist_t *pCommandList, uint8_t error_mask)
Write commands to a sensor.
Definition: sensor_io_spi.c:50
int32_t Sensor_SPI_Write(ARM_DRIVER_SPI *pCommDrv, registerDeviceInfo_t *devInfo, void *pWriteParams, const registerwritelist_t *pRegWriteList)
Write register data to a sensor.
Definition: sensor_io_spi.c:97
typedef int32_t(DATA_FORMAT_Append_t))(void *pData
The interface function to append the data on the formated stream.
This structure defines the Write command List.
Definition: sensor_drv.h:94
This structure defines the Read command List.
Definition: sensor_drv.h:104
This structure defines the device specific info required by register I/O.
Definition: sensor_drv.h:128
This structure defines the Block command List.
Definition: sensor_drv.h:113
The register_io_spi.h file declares low-level interface functions for reading and writing sensor regi...