1 /*
2  * Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 /**
10  * @file sensor_io_spi.h
11  * @brief The sensor_io_spi.h file declares low-level interface functions for reading
12  * and writing sensor registers using CMSIS APIs.
13  */
14 
15 #ifndef __SENSOR_IO_SPI_H
16 #define __SENSOR_IO_SPI_H
17 
18 #include <stdint.h>
19 #include <stdbool.h>
20 #include "Driver_SPI.h"
21 #include "register_io_spi.h"
22 
23 /*******************************************************************************
24  * API
25  ******************************************************************************/
26 /*! @brief       Write commands to a sensor
27 
28  *  @param[in]   pCommDrv      pointer to the I2C ARM driver to use.
29  *  @param[in]   devInfo       The SPI device number and idle function.
30  *  @param[in]   pWriteParams  The SPI slave slect handle of the sensor to write to.
31  *  @param[in]   pCommandList  A list of one or more commands to write.
32  *  @param[in]   error_mask    The mask for Error Code Bits in CoCo Byte.
33  *
34  *  @return      returns the execution status of the operation using ::ESensorErrors
35  */
36 int32_t Sensor_SPI_BlockWrite(ARM_DRIVER_SPI *pCommDrv,
37                               registerDeviceInfo_t *devInfo,
38                               void *pWriteParams,
39                               const registercommandlist_t *pCommandList,
40                               uint8_t error_mask);
41 
42 /*! @brief       Write register data to a sensor
43 
44  *  @param[in]   pCommDrv       Pointer to the SPI ARM driver to use
45  *  @param[in]   devInfo        The SPI device number and idle function.
46  *  @param[in]   pWriteParams   SPI slave Params to write to.
47  *  @param[in]   pRegWriteList  A list of one or more register/value pairs to write.
48  *
49  *  @return      returns the execution status of the operation using ::ESensorErrors
50  */
51 int32_t Sensor_SPI_Write(ARM_DRIVER_SPI *pCommDrv,
52                          registerDeviceInfo_t *devInfo,
53                          void *pWriteParams,
54                          const registerwritelist_t *pRegWriteList);
55 
56 /*! @brief       Read register data from a sensor
57 
58  *  @param[in]   pCommDrv     Pointer to the SPI ARM driver to use.
59  *  @param[in]   devInfo      The SPI device number and idle function.
60  *  @param[in]   pReadParams  SPI slave Params read from.
61  *  @param[in]   pReadList    A list of one or more register addresses and lengths to read.
62  *  @param[in]   pOutBuffer   A pointer of sufficient size to contain the requested read data.
63  *
64  *  @return      returns the execution status of the operation using ::ESensorErrors
65  */
66 int32_t Sensor_SPI_Read(ARM_DRIVER_SPI *pCommDrv,
67                         registerDeviceInfo_t *devInfo,
68                         void *pReadParams,
69                         const registerreadlist_t *pReadList,
70                         uint8_t *pOutBuffer);
71 
72 #endif /* __SENSOR_IO_SPI_H */
73