Jake Greaves / Mbed OS AdiSense1000_V21
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers adi_sense_1000_host_comms.h Source File

adi_sense_1000_host_comms.h

00001 /*
00002 CONFIDENTIAL AND PROPRIETARY INFORMATION
00003 
00004 Copyright (c) 2018 Emutex Ltd. All rights reserved.
00005 This software and documentation contain confidential and
00006 proprietary information that is the property of
00007 Emutex Ltd. The software and documentation are
00008 furnished under a license agreement and may be used
00009 or copied only in accordance with the terms of the license
00010 agreement. No part of the software and documentation
00011 may be reproduced, transmitted, or translated, in any
00012 form or by any means, electronic, mechanical, manual,
00013 optical, or otherwise, without prior written permission
00014 of Emutex Ltd., or as expressly provided by the license agreement.
00015 Reverse engineering is prohibited, and reproduction,
00016 disclosure or use without specific written authorization
00017 of Emutex Ltd. is strictly forbidden.
00018 */
00019 
00020 #ifndef __ADI_SENSE_1000_HOST_COMMS_H__
00021 #define __ADI_SENSE_1000_HOST_COMMS_H__
00022 
00023 #include "adi_sense_types.h"
00024 
00025 /*
00026  * The host is expected to transfer a 16-bit command, followed by data bytes, in 2
00027  * separate transfers delineated by the CS signal and a short delay in between.
00028  *
00029  * The 16-bit command contains a right-justified 11-bit register address (offset),
00030  * and the remaining upper 5 bits are reserved as command bits assigned as follows:
00031  * [15:11] 10000b = write command, 01000b = read command, anything else is invalid
00032  * [10:0]  register address (0-2047)
00033  */
00034 
00035 /* Register address space is limited to 2048 bytes (11 bit address) */
00036 #define ADI_SENSE_1000_HOST_COMMS_CMD_MASK 0xF800
00037 #define ADI_SENSE_1000_HOST_COMMS_ADR_MASK 0x07FF
00038 
00039 /*
00040  * The following commands are currently supported, anything else is treated
00041  * as an error
00042  */
00043 #define ADI_SENSE_1000_HOST_COMMS_WRITE_CMD 0x8000
00044 #define ADI_SENSE_1000_HOST_COMMS_READ_CMD  0x4000
00045 
00046 /*
00047  * The following bytes are sent back to the host when a command is recieved,
00048  * to be used by the host to verify that we were ready to receive the command.
00049  */
00050 #define ADI_SENSE_1000_HOST_COMMS_CMD_RESP_0 0xF0
00051 #define ADI_SENSE_1000_HOST_COMMS_CMD_RESP_1 0xE1
00052 
00053 /*
00054  * The following minimum delay, in microseconds, must be inserted after each SPI
00055  * transfer to allow time for it to be processed by the device
00056  */
00057 #define ADI_SENSE_1000_HOST_COMMS_XFER_DELAY (30)
00058 
00059 /*! ADSNS1000 Sensor Result bit field structure */
00060 typedef struct _ADI_SENSE_1000_Sensor_Result_t  {
00061     union {
00062         struct {
00063             float32_t Sensor_Result;      /**< Linearized and compensated sensor result */
00064             uint32_t Channel_ID    :  4;  /**< Indicates which channel this result corresponds to */
00065             uint32_t Ch_Error      :  1;  /**< Indicates Error on channel */
00066             uint32_t Ch_Alert      :  1;  /**< Indicates Alert on channel */
00067             uint32_t Ch_Raw        :  1;  /**< Indicates if Raw sensor data field is valid */
00068             uint32_t Ch_Valid      :  1;  /**< Indicates if this Result structure is valid */
00069             uint32_t Raw_Sample    : 24;  /**< Raw sensor data value */
00070         };
00071         uint64_t VALUE64;
00072    };
00073 } ADI_SENSE_1000_Sensor_Result_t ;
00074 
00075 #endif /* __ADI_SENSE_1000_HOST_COMMS_H__ */