mirror of
				https://github.com/eclipse/upm.git
				synced 2025-11-04 09:05:34 +03:00 
			
		
		
		
	sht1x: move defines/register defs into separate header for SWIG
Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
				
			|||||||
upm_mixed_module_init (NAME sht1x
 | 
					upm_mixed_module_init (NAME sht1x
 | 
				
			||||||
    DESCRIPTION "Temperature and Humidity Sensor"
 | 
					    DESCRIPTION "Temperature and Humidity Sensor"
 | 
				
			||||||
    C_HDR sht1x.h
 | 
					    C_HDR sht1x.h sht1x_defs.h
 | 
				
			||||||
    C_SRC sht1x.c
 | 
					    C_SRC sht1x.c
 | 
				
			||||||
    CPP_HDR sht1x.hpp
 | 
					    CPP_HDR sht1x.hpp
 | 
				
			||||||
    CPP_SRC sht1x.cxx
 | 
					    CPP_SRC sht1x.cxx
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,6 +4,7 @@
 | 
				
			|||||||
%include "stdint.i"
 | 
					%include "stdint.i"
 | 
				
			||||||
%include "typemaps.i"
 | 
					%include "typemaps.i"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%include "sht1x_defs.h"
 | 
				
			||||||
%include "sht1x.hpp"
 | 
					%include "sht1x.hpp"
 | 
				
			||||||
%{
 | 
					%{
 | 
				
			||||||
    #include "sht1x.hpp"
 | 
					    #include "sht1x.hpp"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,6 +2,7 @@
 | 
				
			|||||||
%include "../upm.i"
 | 
					%include "../upm.i"
 | 
				
			||||||
%include "std_string.i"
 | 
					%include "std_string.i"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%include "sht1x_defs.h"
 | 
				
			||||||
%include "sht1x.hpp"
 | 
					%include "sht1x.hpp"
 | 
				
			||||||
%{
 | 
					%{
 | 
				
			||||||
    #include "sht1x.hpp"
 | 
					    #include "sht1x.hpp"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,6 +6,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
%feature("autodoc", "3");
 | 
					%feature("autodoc", "3");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%include "sht1x_defs.h"
 | 
				
			||||||
%include "sht1x.hpp"
 | 
					%include "sht1x.hpp"
 | 
				
			||||||
%{
 | 
					%{
 | 
				
			||||||
    #include "sht1x.hpp"
 | 
					    #include "sht1x.hpp"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,8 @@
 | 
				
			|||||||
#include "upm.h"
 | 
					#include "upm.h"
 | 
				
			||||||
#include "mraa/gpio.h"
 | 
					#include "mraa/gpio.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "sht1x_defs.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef __cplusplus
 | 
					#ifdef __cplusplus
 | 
				
			||||||
extern "C" {
 | 
					extern "C" {
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -67,40 +69,6 @@ extern "C" {
 | 
				
			|||||||
    float                    coeff_t2;
 | 
					    float                    coeff_t2;
 | 
				
			||||||
  } *sht1x_context;
 | 
					  } *sht1x_context;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // SHT1X commands.  The first 3 msb's are the address, which are
 | 
					 | 
				
			||||||
  // always 0.  The following 5 bits are the actual command.
 | 
					 | 
				
			||||||
  typedef enum {
 | 
					 | 
				
			||||||
    SHT1X_CMD_MEAS_TEMPERATURE            = 0x03,
 | 
					 | 
				
			||||||
    SHT1X_CMD_MEAS_HUMIDITY               = 0x05,
 | 
					 | 
				
			||||||
    SHT1X_CMD_WRITE_STATUS                = 0x06,
 | 
					 | 
				
			||||||
    SHT1X_CMD_READ_STATUS                 = 0x07,
 | 
					 | 
				
			||||||
    SHT1X_CMD_SOFT_RESET                  = 0x1e
 | 
					 | 
				
			||||||
  } SHT1X_CMD_T;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // status register bits
 | 
					 | 
				
			||||||
  typedef enum {
 | 
					 | 
				
			||||||
    SHT1X_STATUS_RESOLUTION_LOW           = 0x01, // 0=12b RH/14b temp (dflt)
 | 
					 | 
				
			||||||
    SHT1X_STATUS_NO_RELOAD_FROM_OTP       = 0x02,
 | 
					 | 
				
			||||||
    SHT1X_STATUS_HEATER_EN                = 0x04,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 0x08-0x20 reserved
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    SHT1X_STATUS_LOW_VOLT                 = 0x40 // low battery
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 0x80 reserved
 | 
					 | 
				
			||||||
  } SHT1X_STATUS_BITS_T;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // The Vdd voltage can affect the temperature coefficients, so we
 | 
					 | 
				
			||||||
  // provide a way to indicate the closest voltage and set up the
 | 
					 | 
				
			||||||
  // compensation accordingly.
 | 
					 | 
				
			||||||
  typedef enum {
 | 
					 | 
				
			||||||
    SHT1X_VOLTS_5                         = 0, // 5 volts
 | 
					 | 
				
			||||||
    SHT1X_VOLTS_4                         = 1,
 | 
					 | 
				
			||||||
    SHT1X_VOLTS_3_5                       = 2, // 3.5v
 | 
					 | 
				
			||||||
    SHT1X_VOLTS_3                         = 3,
 | 
					 | 
				
			||||||
    SHT1X_VOLTS_2_5                       = 4
 | 
					 | 
				
			||||||
  } SHT1X_VOLTS_T;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * SHT1X Initializer
 | 
					   * SHT1X Initializer
 | 
				
			||||||
   *
 | 
					   *
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										68
									
								
								src/sht1x/sht1x_defs.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								src/sht1x/sht1x_defs.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Author: Jon Trulson <jtrulson@ics.com>
 | 
				
			||||||
 | 
					 * Copyright (c) 2016 Intel Corporation.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Permission is hereby granted, free of charge, to any person obtaining
 | 
				
			||||||
 | 
					 * a copy of this software and associated documentation files (the
 | 
				
			||||||
 | 
					 * "Software"), to deal in the Software without restriction, including
 | 
				
			||||||
 | 
					 * without limitation the rights to use, copy, modify, merge, publish,
 | 
				
			||||||
 | 
					 * distribute, sublicense, and/or sell copies of the Software, and to
 | 
				
			||||||
 | 
					 * permit persons to whom the Software is furnished to do so, subject to
 | 
				
			||||||
 | 
					 * the following conditions:
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * The above copyright notice and this permission notice shall be
 | 
				
			||||||
 | 
					 * included in all copies or substantial portions of the Software.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 | 
				
			||||||
 | 
					 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 | 
				
			||||||
 | 
					 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 | 
				
			||||||
 | 
					 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 | 
				
			||||||
 | 
					 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 | 
				
			||||||
 | 
					 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 | 
				
			||||||
 | 
					 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					extern "C" {
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // SHT1X commands.  The first 3 msb's are the address, which are
 | 
				
			||||||
 | 
					  // always 0.  The following 5 bits are the actual command.
 | 
				
			||||||
 | 
					  typedef enum {
 | 
				
			||||||
 | 
					    SHT1X_CMD_MEAS_TEMPERATURE            = 0x03,
 | 
				
			||||||
 | 
					    SHT1X_CMD_MEAS_HUMIDITY               = 0x05,
 | 
				
			||||||
 | 
					    SHT1X_CMD_WRITE_STATUS                = 0x06,
 | 
				
			||||||
 | 
					    SHT1X_CMD_READ_STATUS                 = 0x07,
 | 
				
			||||||
 | 
					    SHT1X_CMD_SOFT_RESET                  = 0x1e
 | 
				
			||||||
 | 
					  } SHT1X_CMD_T;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // status register bits
 | 
				
			||||||
 | 
					  typedef enum {
 | 
				
			||||||
 | 
					    SHT1X_STATUS_RESOLUTION_LOW           = 0x01, // 0=12b RH/14b temp (dflt)
 | 
				
			||||||
 | 
					    SHT1X_STATUS_NO_RELOAD_FROM_OTP       = 0x02,
 | 
				
			||||||
 | 
					    SHT1X_STATUS_HEATER_EN                = 0x04,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 0x08-0x20 reserved
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    SHT1X_STATUS_LOW_VOLT                 = 0x40 // low battery
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 0x80 reserved
 | 
				
			||||||
 | 
					  } SHT1X_STATUS_BITS_T;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // The Vdd voltage can affect the temperature coefficients, so we
 | 
				
			||||||
 | 
					  // provide a way to indicate the closest voltage and set up the
 | 
				
			||||||
 | 
					  // compensation accordingly.
 | 
				
			||||||
 | 
					  typedef enum {
 | 
				
			||||||
 | 
					    SHT1X_VOLTS_5                         = 0, // 5 volts
 | 
				
			||||||
 | 
					    SHT1X_VOLTS_4                         = 1,
 | 
				
			||||||
 | 
					    SHT1X_VOLTS_3_5                       = 2, // 3.5v
 | 
				
			||||||
 | 
					    SHT1X_VOLTS_3                         = 3,
 | 
				
			||||||
 | 
					    SHT1X_VOLTS_2_5                       = 4
 | 
				
			||||||
 | 
					  } SHT1X_VOLTS_T;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef __cplusplus
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		Reference in New Issue
	
	Block a user