A multifunctional and modular Firmware for Multitech's mDot based on ARM mBed provides a widerange of functionality for several Sensors such as MAX44009, BME280, MPU9250, SI1143 and uBlox. It allows you to quickly build a Sensornode that measures specific data with its sensors and sends it via LoRaWAN.

Dependencies:   mDot_LoRa_Sensornode_Flowmeter_impl mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers MAX44009Config.h Source File

MAX44009Config.h

Go to the documentation of this file.
00001 /**
00002  * @file MAX44009Config.h
00003  *
00004  * @author Adrian
00005  * @date 25.05.2016
00006  *
00007  */
00008 #include <stdint.h>
00009 #ifndef APP_MAX44009CONFIG_H_
00010 #define APP_MAX44009CONFIG_H_
00011 
00012 #define MAX_44009_CONTINOUS_MODE_ON         0b1
00013 #define MAX_44009_CONTINOUS_MODE_OFF        0b0
00014 #define MAX_44009_MANUAL_CONFIG_ON          0b1
00015 #define MAX_44009_MANUAL_CONFIG_OFF         0b0
00016 
00017 //Integration Times
00018 #define MAX_44009_INTEGRATION_TIME_800_MS   0b000
00019 #define MAX_44009_INTEGRATION_TIME_400_MS   0b001
00020 #define MAX_44009_INTEGRATION_TIME_200_MS   0b010
00021 #define MAX_44009_INTEGRATION_TIME_100_MS   0b011
00022 #define MAX_44009_INTEGRATION_TIME_50_MS    0b100
00023 #define MAX_44009_INTEGRATION_TIME_25_MS    0b101
00024 #define MAX_44009_INTEGRATION_TIME_12_5_MS  0b110
00025 #define MAX_44009_INTEGRATION_TIME_6_25_MS  0b111
00026 
00027 #define MAX_44009_IRQ_ENABLED               0x1
00028 #define MAX_44009_THRESHOLD_4096_LUX        0xC0
00029 
00030 /**
00031  * MAX44009 Modes
00032  */
00033 enum MAX44009_MODE{
00034     MAX44009_MODE_0,//!< MAX44009_MODE_0
00035     MAX44009_MODE_1,//!< MAX44009_MODE_1
00036     MAX44009_MODE_2,//!< MAX44009_MODE_2
00037     MAX44009_MODE_3,//!< MAX44009_MODE_3
00038     MAX44009_MODE_4,//!< MAX44009_MODE_4
00039     MAX44009_MODE_5,//!< MAX44009_MODE_5
00040     MAX44009_MODE_6,//!< MAX44009_MODE_6
00041 };
00042 
00043 /**
00044  * @class MAX44009Config
00045  * @brief A configuration container for the MAX44009 Sensor.
00046  * All its configuration values are stored an held inside
00047  * this Class. Depending on the MAX44009_MODE using
00048  * as a parameter for the build() method it sets all the configuration values.
00049  */
00050 
00051 class MAX44009Config {
00052 public:
00053     MAX44009Config();
00054     MAX44009Config(MAX44009_MODE);
00055     virtual ~MAX44009Config();
00056 
00057     /**
00058      * @brief Generates a configuration according to the chosen MAX44009_MODE
00059      * by setting all LoRa Module specific configuration values depending on the chosen MAX44009_MODE
00060      * @param desiredMode the mode to build the configuration according to
00061      */
00062     void build(MAX44009_MODE desiredMode);
00063 
00064 
00065     /**
00066      * @brief Gets the integration Time for Lux Measurements defined in the actual
00067      * MAX44009Config
00068      * @return
00069      */
00070     uint8_t getIntegrationTime();
00071 
00072     /**
00073      * @brief Gets the Continuous Mode for Lux Measurements defined in the actual
00074      * MAX44009Config
00075      * @return
00076      */
00077     uint8_t getContinousMode();
00078 
00079     /**
00080      * @brief Gets the Manual Config for the Sensor defined in the actual
00081      * MAX44009Config
00082      * @return
00083      */
00084     uint8_t getManualConfig();
00085 
00086     /**
00087      * @brief Gets the interrupt Enable Value that has to be written to the MAX44009
00088      * according to the actual MAX44009Config
00089      * @return
00090      */
00091     uint8_t getInterruptEnable();
00092 
00093     /**
00094      * @brief Gets the upper Threshold Value that has to be written to the MAX44009
00095      * according to the actual MAX44009Config
00096      * @return
00097      */
00098     uint8_t getUpperThreshold();
00099 
00100     /**
00101      * @brief Gets the lower Threshold Value that has to be written to the MAX44009
00102      * according to the actual MAX44009Config
00103      * @return
00104      */
00105     uint8_t getLowerThreshold();
00106 
00107 private:
00108     uint8_t integrationTime;
00109     uint8_t continousMode;
00110     uint8_t manualConfig;
00111     uint8_t interruptEnable;
00112     uint8_t upperThreshold;
00113     uint8_t lowerThreshold;
00114 
00115     /**
00116      * @brief Sets the integration time value of the MAX44009Config. The value later will be written
00117      * inside MAX44009 specific register by MAX44009 itself
00118      * @param integrationTime integration Time register value
00119      */
00120     void setIntegrationTime(uint8_t integrationTime);
00121 
00122     /**
00123      * @brief Sets the continuous mode value of the MAX44009Config. The value later will be written
00124      * inside MAX44009 specific register by MAX44009 itself
00125      * @param continuousMode continuous mode register value
00126      */
00127     void setContinousMode(uint8_t continuousMode);
00128 
00129     /**
00130      * @brief Sets the continuous mode value of the MAX44009Config. The value later will be written
00131      * inside MAX44009 specific register by MAX44009 itself
00132      * @param continuousMode continuous mode register value
00133      */
00134     void setManualConfig(uint8_t manualConfig);
00135 
00136     /**
00137      * @brief Sets the interrupt enable value of the MAX44009Config. The value later will be written
00138      * inside MAX44009 specific register by MAX44009 itself
00139      * @param interruptEnable interruptEnable register value
00140      */
00141     void setInterruptEnable(uint8_t interruptEnable);
00142 
00143     /**
00144      * @brief Sets the upper threshold value of the MAX44009Config. The value later will be written
00145      * inside MAX44009 specific register by MAX44009 itself
00146      * @param upperThreshold upper threshold register value
00147      */
00148     void setInterruptUpperThreshold(uint8_t upperThreshold);
00149 
00150     /**
00151      * @brief Sets the lower threshold value of the MAX44009Config. The value later will be written
00152      * inside MAX44009 specific register by MAX44009 itself
00153      * @param upperThreshold upper threshold register value
00154      */
00155     void setInterruptLowerThreshold(uint8_t lowerThreshold);
00156 };
00157 
00158 #endif /* APP_MAX44009CONFIG_H_ */