ISSDK  1.8
IoT Sensing Software Development Kit
sensor_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 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_drv.h
11  * @brief The sensor_drv.h file contains sensor state and error definitions.
12  */
13 
14 #ifndef _SENSOR_DRV_H
15 #define _SENSOR_DRV_H
16 
17 #include <stddef.h>
18 #include <stdint.h>
19 #include <stdbool.h>
20 /*******************************************************************************
21  * Definitions
22  ******************************************************************************/
23 /* @brief This enum defines Write flag for the Register Write. */
24 typedef enum EWriteFlags
25 {
26  WRITE_OVERWRITE = 0, /* Overwrite the Register Value.*/
27  WRITE_MASK = 1 /* Read and Mask and OR it with Register content.*/
29 
30 /* @brief This enum defines Sensor State. */
32 {
39 };
40 
41 /* The MAXIMUM number of Sensor Registers possible. */
42 #define SENSOR_MAX_REGISTER_COUNT 128 /* As per 7-Bit address. */
43 
44 /* Used with the RegisterWriteList types as a list terminator */
45 #define __END_WRITE_DATA__ \
46  { \
47  .writeTo = 0xFFFF, .value = 0 \
48  }
49 
50 /* Used with the RegisterReadList types as a list terminator */
51 #define __END_READ_DATA__ \
52  { \
53  .readFrom = 0xFFFF, .numBytes = 0 \
54  }
55 
56 /* Used with the Sensor Command List types as a list terminator */
57 #define __END_WRITE_CMD__ \
58  { \
59  .writeTo = 0xFFFF, .numBytes = 0 \
60  }
61 
62 /*******************************************************************************
63  * Types
64  ******************************************************************************/
65 /*!
66  * @brief This structure defines the Write command List.
67  */
68 typedef struct
69 {
70  uint16_t writeTo; /* Address where the value is writes to.*/
71  uint8_t value; /* value. Note that value should be shifted based on the bit position.*/
72  uint8_t mask; /* mask of the field to be set with given value.*/
74 
75 /*!
76  * @brief This structure defines the Read command List.
77  */
78 typedef struct
79 {
80  uint16_t readFrom; /* Address where the value is read from .*/
81  uint8_t numBytes; /* Number of bytes to read.*/
83 
84 /*!
85  * @brief This structure defines the Block command List.
86  */
87 typedef struct
88 {
89  const uint8_t *pWriteBuffer; /* Buffer containing the bytes to be written. */
90  uint16_t writeTo; /* Register Address where the bytes are to be written. */
91  uint8_t numBytes; /* Number of bytes to be written. */
93 
94 /*!
95  * @brief This is the register idle function type.
96  */
97 typedef void (*registeridlefunction_t)(void *userParam);
98 
99 /*!
100  * @brief This structure defines the device specific info required by register I/O.
101  */
102 typedef struct
103 {
106  uint8_t deviceInstance;
108 
109 #endif //_SENSOR_DRV_H
This structure defines the device specific info required by register I/O.
Definition: sensor_drv.h:102
This structure defines the Write command List.
Definition: sensor_drv.h:68
enum EWriteFlags EWriteFlags_t
This structure defines the Block command List.
Definition: sensor_drv.h:87
EWriteFlags
Definition: sensor_drv.h:24
void(* registeridlefunction_t)(void *userParam)
This is the register idle function type.
Definition: sensor_drv.h:97
uint16_t readFrom
Definition: sensor_drv.h:80
ESensorErrors
Definition: sensor_drv.h:31
This structure defines the Read command List.
Definition: sensor_drv.h:78
const uint8_t * pWriteBuffer
Definition: sensor_drv.h:89
registeridlefunction_t idleFunction
Definition: sensor_drv.h:104