Vybhav Kadaba
/
EV-PRO-MW1001_Development
added wait_us(31) in admw_spi.cpp to support hibernation mode
inc/admw1001/admw1001_host_comms.h@48:5731f1aa2c5a, 2020-02-06 (annotated)
- Committer:
- Vkadaba
- Date:
- Thu Feb 06 11:01:37 2020 +0000
- Revision:
- 48:5731f1aa2c5a
- Parent:
- 32:52445bef314d
- Child:
- 50:d84305e5e1c0
Added wakeup support
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Vkadaba | 5:0728bde67bdb | 1 | /* |
Vkadaba | 6:9d393a9677f4 | 2 | Copyright 2019 (c) Analog Devices, Inc. |
Vkadaba | 6:9d393a9677f4 | 3 | |
Vkadaba | 6:9d393a9677f4 | 4 | All rights reserved. |
Vkadaba | 6:9d393a9677f4 | 5 | |
Vkadaba | 6:9d393a9677f4 | 6 | Redistribution and use in source and binary forms, with or without |
Vkadaba | 6:9d393a9677f4 | 7 | modification, are permitted provided that the following conditions are met: |
Vkadaba | 6:9d393a9677f4 | 8 | - Redistributions of source code must retain the above copyright |
Vkadaba | 6:9d393a9677f4 | 9 | notice, this list of conditions and the following disclaimer. |
Vkadaba | 6:9d393a9677f4 | 10 | - Redistributions in binary form must reproduce the above copyright |
Vkadaba | 6:9d393a9677f4 | 11 | notice, this list of conditions and the following disclaimer in |
Vkadaba | 6:9d393a9677f4 | 12 | the documentation and/or other materials provided with the |
Vkadaba | 6:9d393a9677f4 | 13 | distribution. |
Vkadaba | 6:9d393a9677f4 | 14 | - Neither the name of Analog Devices, Inc. nor the names of its |
Vkadaba | 6:9d393a9677f4 | 15 | contributors may be used to endorse or promote products derived |
Vkadaba | 6:9d393a9677f4 | 16 | from this software without specific prior written permission. |
Vkadaba | 6:9d393a9677f4 | 17 | - The use of this software may or may not infringe the patent rights |
Vkadaba | 6:9d393a9677f4 | 18 | of one or more patent holders. This license does not release you |
Vkadaba | 6:9d393a9677f4 | 19 | from the requirement that you obtain separate licenses from these |
Vkadaba | 6:9d393a9677f4 | 20 | patent holders to use this software. |
Vkadaba | 6:9d393a9677f4 | 21 | - Use of the software either in source or binary form, must be run |
Vkadaba | 6:9d393a9677f4 | 22 | on or directly connected to an Analog Devices Inc. component. |
Vkadaba | 6:9d393a9677f4 | 23 | |
Vkadaba | 6:9d393a9677f4 | 24 | THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR |
Vkadaba | 6:9d393a9677f4 | 25 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, |
Vkadaba | 6:9d393a9677f4 | 26 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
Vkadaba | 6:9d393a9677f4 | 27 | IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, |
Vkadaba | 6:9d393a9677f4 | 28 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
Vkadaba | 6:9d393a9677f4 | 29 | LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR |
Vkadaba | 6:9d393a9677f4 | 30 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
Vkadaba | 6:9d393a9677f4 | 31 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
Vkadaba | 6:9d393a9677f4 | 32 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Vkadaba | 6:9d393a9677f4 | 33 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Vkadaba | 6:9d393a9677f4 | 34 | */ |
Vkadaba | 6:9d393a9677f4 | 35 | |
Vkadaba | 5:0728bde67bdb | 36 | #ifndef __ADMW1001_HOST_COMMS_H__ |
Vkadaba | 5:0728bde67bdb | 37 | #define __ADMW1001_HOST_COMMS_H__ |
Vkadaba | 5:0728bde67bdb | 38 | |
Vkadaba | 5:0728bde67bdb | 39 | #include "admw_types.h" |
Vkadaba | 6:9d393a9677f4 | 40 | |
Vkadaba | 5:0728bde67bdb | 41 | /* |
Vkadaba | 5:0728bde67bdb | 42 | * The host is expected to transfer a 16-bit command, followed by data bytes, in 2 |
Vkadaba | 5:0728bde67bdb | 43 | * separate transfers delineated by the CS signal and a short delay in between. |
Vkadaba | 5:0728bde67bdb | 44 | * |
Vkadaba | 5:0728bde67bdb | 45 | * The 16-bit command contains a right-justified 11-bit register address (offset), |
Vkadaba | 5:0728bde67bdb | 46 | * and the remaining upper 5 bits are reserved as command bits assigned as follows: |
Vkadaba | 5:0728bde67bdb | 47 | * [15:11] 10000b = write command, 01000b = read command, anything else is invalid |
Vkadaba | 5:0728bde67bdb | 48 | * [10:0] register address (0-2047) |
Vkadaba | 5:0728bde67bdb | 49 | */ |
Vkadaba | 5:0728bde67bdb | 50 | |
Vkadaba | 5:0728bde67bdb | 51 | /* Register address space is limited to 2048 bytes (11 bit address) */ |
Vkadaba | 5:0728bde67bdb | 52 | #define ADMW1001_HOST_COMMS_CMD_MASK 0xF800 |
Vkadaba | 5:0728bde67bdb | 53 | #define ADMW1001_HOST_COMMS_ADR_MASK 0x07FF |
Vkadaba | 5:0728bde67bdb | 54 | |
Vkadaba | 5:0728bde67bdb | 55 | /* |
Vkadaba | 5:0728bde67bdb | 56 | * The following commands are currently supported, anything else is treated |
Vkadaba | 5:0728bde67bdb | 57 | * as an error |
Vkadaba | 5:0728bde67bdb | 58 | */ |
Vkadaba | 5:0728bde67bdb | 59 | #define ADMW1001_HOST_COMMS_WRITE_CMD 0x8000 |
Vkadaba | 5:0728bde67bdb | 60 | #define ADMW1001_HOST_COMMS_READ_CMD 0x4000 |
Vkadaba | 5:0728bde67bdb | 61 | |
Vkadaba | 6:9d393a9677f4 | 62 | #define ADMW1001_HOST_COMMS_DEBUG_WRITE_CMD 0x8800 |
Vkadaba | 6:9d393a9677f4 | 63 | #define ADMW1001_HOST_COMMS_DEBUG_READ_CMD 0x4800 |
Vkadaba | 6:9d393a9677f4 | 64 | |
Vkadaba | 5:0728bde67bdb | 65 | /* |
Vkadaba | 5:0728bde67bdb | 66 | * The following bytes are sent back to the host when a command is recieved, |
Vkadaba | 5:0728bde67bdb | 67 | * to be used by the host to verify that we were ready to receive the command. |
Vkadaba | 5:0728bde67bdb | 68 | */ |
Vkadaba | 5:0728bde67bdb | 69 | #define ADMW1001_HOST_COMMS_CMD_RESP_0 0xF0 |
Vkadaba | 5:0728bde67bdb | 70 | #define ADMW1001_HOST_COMMS_CMD_RESP_1 0xE1 |
Vkadaba | 5:0728bde67bdb | 71 | |
Vkadaba | 5:0728bde67bdb | 72 | /* |
Vkadaba | 5:0728bde67bdb | 73 | * The following minimum delay, in microseconds, must be inserted after each SPI |
Vkadaba | 5:0728bde67bdb | 74 | * transfer to allow time for it to be processed by the device |
Vkadaba | 5:0728bde67bdb | 75 | */ |
Vkadaba | 48:5731f1aa2c5a | 76 | #define ADMW1001_HOST_COMMS_XFER_DELAY (40) |
Vkadaba | 5:0728bde67bdb | 77 | |
Vkadaba | 32:52445bef314d | 78 | /* |
Vkadaba | 32:52445bef314d | 79 | * The following defines the maximum number of retries before aborting a transfer. |
Vkadaba | 32:52445bef314d | 80 | */ |
Vkadaba | 32:52445bef314d | 81 | #define ADMW1001_HOST_COMMS_MAX_RETRIES (10) |
Vkadaba | 32:52445bef314d | 82 | |
Vkadaba | 32:52445bef314d | 83 | |
Vkadaba | 5:0728bde67bdb | 84 | /*! ADMW1001 Sensor Result bit field structure */ |
Vkadaba | 6:9d393a9677f4 | 85 | typedef struct ADMW1001_Sensor_Result_t { |
Vkadaba | 5:0728bde67bdb | 86 | union { |
Vkadaba | 5:0728bde67bdb | 87 | struct { |
Vkadaba | 5:0728bde67bdb | 88 | float32_t Sensor_Result; /**< Linearized and compensated sensor result */ |
Vkadaba | 5:0728bde67bdb | 89 | uint32_t Channel_ID : 4; /**< Indicates which channel this result corresponds to */ |
Vkadaba | 5:0728bde67bdb | 90 | uint32_t Ch_Error : 1; /**< Indicates Error on channel */ |
Vkadaba | 5:0728bde67bdb | 91 | uint32_t Ch_Alert : 1; /**< Indicates Alert on channel */ |
Vkadaba | 5:0728bde67bdb | 92 | uint32_t Ch_Raw : 1; /**< Indicates if Raw sensor data field is valid */ |
Vkadaba | 5:0728bde67bdb | 93 | uint32_t Ch_Valid : 1; /**< Indicates if this Result structure is valid */ |
Vkadaba | 5:0728bde67bdb | 94 | uint32_t Raw_Sample : 24; /**< Raw sensor data value */ |
Vkadaba | 5:0728bde67bdb | 95 | }; |
Vkadaba | 5:0728bde67bdb | 96 | uint64_t VALUE64; |
Vkadaba | 5:0728bde67bdb | 97 | }; |
Vkadaba | 5:0728bde67bdb | 98 | } ADMW1001_Sensor_Result_t; |
Vkadaba | 5:0728bde67bdb | 99 | |
Vkadaba | 5:0728bde67bdb | 100 | #endif /* __ADMW1001_HOST_COMMS_H__ */ |