mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
max44000: Added swig to the module and set i2c methods as public
Signed-off-by: Kiveisha Yevgeniy <yevgeniy.kiveisha@intel.com>
This commit is contained in:
parent
3be0cdf5c2
commit
12b2ab6991
@ -3,6 +3,41 @@ add_library (max44000 SHARED max44000.cxx)
|
|||||||
include_directories (${MAA_INCLUDE_DIR})
|
include_directories (${MAA_INCLUDE_DIR})
|
||||||
target_link_libraries (max44000 ${MAA_LIBRARIES})
|
target_link_libraries (max44000 ${MAA_LIBRARIES})
|
||||||
|
|
||||||
|
if (SWIG_FOUND)
|
||||||
|
find_package (PythonLibs)
|
||||||
|
|
||||||
|
include_directories (
|
||||||
|
${PYTHON_INCLUDE_PATH}
|
||||||
|
${PYTHON_INCLUDE_DIRS}
|
||||||
|
${MAA_INCLUDE_DIR}
|
||||||
|
.
|
||||||
|
)
|
||||||
|
|
||||||
|
set_source_files_properties (pyupm_max44000.i PROPERTIES CPLUSPLUS ON)
|
||||||
|
set_source_files_properties (jsupm_max44000.i PROPERTIES CPLUSPLUS ON)
|
||||||
|
set_source_files_properties (jsupm_max44000.i PROPERTIES SWIG_FLAGS "-node")
|
||||||
|
|
||||||
|
swig_add_module (pyupm_max44000 python pyupm_max44000.i max44000.cxx)
|
||||||
|
# swig_add_module (jsupm_grove javascript jsupm_grove.i grove.cxx)
|
||||||
|
|
||||||
|
swig_link_libraries (pyupm_max44000 ${PYTHON_LIBRARIES} ${MAA_LIBRARIES})
|
||||||
|
# swig_link_libraries (jsupm_grove ${MAA_LIBRARIES})
|
||||||
|
|
||||||
|
if (DOXYGEN_FOUND)
|
||||||
|
set (CMAKE_SWIG_FLAGS -DDOXYGEN=${DOXYGEN_FOUND})
|
||||||
|
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i
|
||||||
|
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../doxy2swig.py -n
|
||||||
|
${CMAKE_BINARY_DIR}/xml/${libname}_8h.xml
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i
|
||||||
|
DEPENDS ${CMAKE_BINARY_DIR}/xml/${libname}_8h.xml
|
||||||
|
)
|
||||||
|
add_custom_target (${libname}doc_i DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${libname}_doc.i)
|
||||||
|
add_dependencies (${libname}doc_i doc)
|
||||||
|
add_dependencies (${SWIG_MODULE_pyupm_grove_REAL_NAME} ${libname}doc_i)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
endif ()
|
||||||
|
|
||||||
install (TARGETS ${libname} DESTINATION lib/upm COMPONENT ${libname})
|
install (TARGETS ${libname} DESTINATION lib/upm COMPONENT ${libname})
|
||||||
install (FILES max44000.h DESTINATION include/upm COMPONENT ${libname})
|
install (FILES max44000.h DESTINATION include/upm COMPONENT ${libname})
|
||||||
|
|
||||||
|
@ -43,8 +43,8 @@ MAX44000::MAX44000 (int bus, int devAddr) {
|
|||||||
fprintf(stderr, "Messed up i2c bus\n");
|
fprintf(stderr, "Messed up i2c bus\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
i2cWriteReg (MCR, 0x2C);
|
// i2cWriteReg (MCR, 0x2C);
|
||||||
i2cWriteReg (TCR, 0x6);
|
// i2cWriteReg (TCR, 0x6);
|
||||||
}
|
}
|
||||||
|
|
||||||
MAX44000::~MAX44000() {
|
MAX44000::~MAX44000() {
|
||||||
@ -64,7 +64,7 @@ MAX44000::getProximity () {
|
|||||||
uint16_t
|
uint16_t
|
||||||
MAX44000::getAmbient () {
|
MAX44000::getAmbient () {
|
||||||
uint16_t data = 0;
|
uint16_t data = 0;
|
||||||
|
|
||||||
data = (i2cReadReg_8 (ALSDATA_HIGH) & 0x7F) << 8;
|
data = (i2cReadReg_8 (ALSDATA_HIGH) & 0x7F) << 8;
|
||||||
data = data | i2cReadReg_8 (ALSDATA_LOW);
|
data = data | i2cReadReg_8 (ALSDATA_LOW);
|
||||||
|
|
||||||
|
@ -29,12 +29,23 @@
|
|||||||
#define ADDR 0x4A // device address
|
#define ADDR 0x4A // device address
|
||||||
|
|
||||||
// registers address
|
// registers address
|
||||||
#define ALSDATA_HIGH 0x04 // ambient sensor data high byte
|
#define ISR 0x00 // Interrupt Status Register
|
||||||
#define ALSDATA_LOW 0x05 // ambient sensor data low byte
|
|
||||||
#define PRXDATA 0x15 // proximity sensor data
|
|
||||||
#define MCR 0x01 // Main Configuration Register
|
#define MCR 0x01 // Main Configuration Register
|
||||||
#define RCR 0x02 // Receive Configuration Register
|
#define RCR 0x02 // Receive Configuration Register
|
||||||
#define TCR 0x03 // Transmit Configuration Register
|
#define TCR 0x03 // Transmit Configuration Register
|
||||||
|
#define ALSDATA_HIGH 0x04 // ambient sensor data high byte
|
||||||
|
#define ALSDATA_LOW 0x05 // ambient sensor data low byte
|
||||||
|
#define PRXDATA 0x15 // proximity sensor data
|
||||||
|
|
||||||
|
#define ALS_UP_THRESH_HIGH 0x06 // ALS Interrupt Threshold Registers High
|
||||||
|
#define ALS_UP_THRESH_LOW 0x07 // ALS Interrupt Threshold Registers LOW
|
||||||
|
#define ALS_LO_THRESH_HIGH 0x08 // ALS Interrupt Threshold Registers High
|
||||||
|
#define ALS_LO_THRESH_LOW 0x09 // ALS Interrupt Threshold Registers Low
|
||||||
|
#define TPTR 0x0A // ALS/PROX Threshold Persist Timer Register
|
||||||
|
#define PROX_THRESH_IND 0x0B // Proximity Threshold Register
|
||||||
|
#define PROX_THRESH 0x0C // Proximity Threshold Register
|
||||||
|
#define TRIM_GAIN_GREEN 0x0F // Digital Gain Trim Register
|
||||||
|
#define TRIM_GAIN_IR 0x10 // Digital Gain Trim Register
|
||||||
|
|
||||||
#define HIGH 1
|
#define HIGH 1
|
||||||
#define LOW 0
|
#define LOW 0
|
||||||
@ -90,14 +101,12 @@ class MAX44000 {
|
|||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
private:
|
|
||||||
uint16_t getALSData ();
|
|
||||||
uint16_t getPRXData ();
|
|
||||||
|
|
||||||
uint8_t i2cReadReg_8 (int reg);
|
uint8_t i2cReadReg_8 (int reg);
|
||||||
uint16_t i2cReadReg_16 (int reg);
|
uint16_t i2cReadReg_16 (int reg);
|
||||||
maa_result_t i2cWriteReg (uint8_t reg, uint8_t value);
|
maa_result_t i2cWriteReg (uint8_t reg, uint8_t value);
|
||||||
|
|
||||||
|
private:
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
|
|
||||||
int m_maxControlAddr;
|
int m_maxControlAddr;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
%module pyupm_max44000
|
%module pyupm_max44000
|
||||||
|
|
||||||
|
%include "stdint.i"
|
||||||
|
|
||||||
%feature("autodoc", "3");
|
%feature("autodoc", "3");
|
||||||
|
|
||||||
%include "max44000.h"
|
%include "max44000.h"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user