ISSDK  1.7
IoT Sensing Software Development Kit
sensor_drv.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_drv.h
37  * @brief The sensor_drv.h file contains sensor state and error definitions.
38  */
39 
40 #ifndef _SENSOR_DRV_H
41 #define _SENSOR_DRV_H
42 
43 #include <stddef.h>
44 #include <stdint.h>
45 #include <stdbool.h>
46 /*******************************************************************************
47  * Definitions
48  ******************************************************************************/
49 /* @brief This enum defines Write flag for the Register Write. */
50 typedef enum EWriteFlags
51 {
52  WRITE_OVERWRITE = 0, /* Overwrite the Register Value.*/
53  WRITE_MASK = 1 /* Read and Mask and OR it with Register content.*/
55 
56 /* @brief This enum defines Sensor State. */
58 {
65 };
66 
67 /* The MAXIMUM number of Sensor Registers possible. */
68 #define SENSOR_MAX_REGISTER_COUNT 128 /* As per 7-Bit address. */
69 
70 /* Used with the RegisterWriteList types as a list terminator */
71 #define __END_WRITE_DATA__ \
72  { \
73  .writeTo = 0xFFFF, .value = 0 \
74  }
75 
76 /* Used with the RegisterReadList types as a list terminator */
77 #define __END_READ_DATA__ \
78  { \
79  .readFrom = 0xFFFF, .numBytes = 0 \
80  }
81 
82 /* Used with the Sensor Command List types as a list terminator */
83 #define __END_WRITE_CMD__ \
84  { \
85  .writeTo = 0xFFFF, .numBytes = 0 \
86  }
87 
88 /*******************************************************************************
89  * Types
90  ******************************************************************************/
91 /*!
92  * @brief This structure defines the Write command List.
93  */
94 typedef struct
95 {
96  uint16_t writeTo; /* Address where the value is writes to.*/
97  uint8_t value; /* value. Note that value should be shifted based on the bit position.*/
98  uint8_t mask; /* mask of the field to be set with given value.*/
100 
101 /*!
102  * @brief This structure defines the Read command List.
103  */
104 typedef struct
105 {
106  uint16_t readFrom; /* Address where the value is read from .*/
107  uint8_t numBytes; /* Number of bytes to read.*/
109 
110 /*!
111  * @brief This structure defines the Block command List.
112  */
113 typedef struct
114 {
115  const uint8_t *pWriteBuffer; /* Buffer containing the bytes to be written. */
116  uint16_t writeTo; /* Register Address where the bytes are to be written. */
117  uint8_t numBytes; /* Number of bytes to be written. */
119 
120 /*!
121  * @brief This is the register idle function type.
122  */
123 typedef void (*registeridlefunction_t)(void *userParam);
124 
125 /*!
126  * @brief This structure defines the device specific info required by register I/O.
127  */
128 typedef struct
129 {
132  uint8_t deviceInstance;
134 
135 #endif //_SENSOR_DRV_H
registeridlefunction_t idleFunction
Definition: sensor_drv.h:130
enum EWriteFlags EWriteFlags_t
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
Definition: sensor_drv.h:123
EWriteFlags
Definition: sensor_drv.h:50
ESensorErrors
Definition: sensor_drv.h:57
const uint8_t * pWriteBuffer
Definition: sensor_drv.h:115
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