Arslan Test
Dependencies: AMS_ENS210_temp_humid_sensor
Diff: AMS_CCS811.h
- Revision:
- 6:22c0a7f2ece2
- Parent:
- 5:41e97348e9e7
- Child:
- 7:5c95614a61ee
diff -r 41e97348e9e7 -r 22c0a7f2ece2 AMS_CCS811.h --- a/AMS_CCS811.h Fri Jan 20 14:34:41 2017 +0000 +++ b/AMS_CCS811.h Mon Jan 23 14:27:57 2017 +0000 @@ -13,6 +13,7 @@ #include "serialBuffer.h" using utils::SerialBuffer; extern SerialBuffer USBserialComms; +const char *short_to_binary(uint16_t in); /* Library defaults */ #define CONFIG_OP_MODE TEN_SECOND // Every 10 seconds @@ -32,6 +33,7 @@ #define STATUS 0x00 #define ALG_RESULT_DATA 0x02 +#define RAW_DATA 0x03 #define ENV_DATA 0x05 #define ERROR_ID 0xE0 @@ -52,19 +54,21 @@ #define CCS811_HEATER_SUPPLY "The Heater voltage is not being applied correctly" #define CCS811_RESERVED "Reserved for Future Use" /* Library Errors */ -#define CCS811_LIB_ERR_NUM 6 +#define CCS811_LIB_ERR_NUM 7 #define CCS811_LIB_N_WAKE_ID 0 #define CCS811_LIB_N_WAKE "nWAKE pin not set" #define CCS811_LIB_I2C_ID 1 #define CCS811_LIB_I2C "I2C interface is NULL" #define CCS811_LIB_SLAVE_W_ID 2 -#define CCS811_LIB_SLAVE_W "Invaid slave write address" +#define CCS811_LIB_SLAVE_W "Failed to write slave write address" #define CCS811_LIB_REG_ADDR_ID 3 #define CCS811_LIB_REG_ADDR "Failed to write register address" #define CCS811_LIB_I2CWRITE_ID 4 #define CCS811_LIB_I2CWRITE "Failed to write byte" #define CCS811_LIB_SLAVE_R_ID 5 -#define CCS811_LIB_SLAVE_R "Invaid slave read address" +#define CCS811_LIB_SLAVE_R "Failed to write slave read address" +#define CCS811_LIB_INV_MODE_ID 6 +#define CCS811_LIB_INV_MODE "Invalid operation mode" #define CCS811_TOTAL_ERR_NUM CCS811_ERR_NUM+CCS811_LIB_ERR_NUM @@ -125,7 +129,6 @@ * * @param i2c The I2C interface to use for communication * - * @return Write success */ void i2c_interface(I2C * i2c); @@ -133,7 +136,6 @@ * * @param i2c The I2C interface for an attached AMS_ENS210 * - * @return Write success */ void ens210_i2c_interface(I2C * i2c); @@ -173,12 +175,14 @@ int firmware_mode(); /** Set the operation mode \n - * Note: \n When a sensor operating mode is changed to a new mode with\n + * Notes: \n 1.\ When a sensor operating mode is changed to a new mode with\n * a lower sample rate (e.g.\ from SECOND to SIXTY_SECOND), it should be\n * placed in IDLE for at least 10 minutes before enabling the new mode.\ \n * When a sensor operating mode is changed to a new mode with a higher\n * sample rate (e.g.\ from SIXTY_SECOND to SECOND), there is no requirement\n - * to wait before enabling the new mode. + * to wait before enabling the new mode.\ \n + * 2.\ If this method fails, the state of the config register cannot be guaranteed.\ \n + * Check errors and ensure all config settings are as expected. * * @param mode OP_MODES mode to set * @@ -242,30 +246,31 @@ bool env_data(float humid, float temp); /** Get the sensor collection state - * Use when interupts are disabled + * Use when interrupts are disabled. * * @return Current collection state, 1 for new data ready, 0 for data not ready and -1 for error */ int has_new_data(); - /** Get the most recent CO2 measurement. + /** Get the most recent CO2 measurement.\ \n * Must call has_new_data() first when when interupts are disabled otherwise the same data will be returned * * @return Most recent eCO2 measurement in ppm */ uint16_t co2_read(); - /** Get the most recent TVOC measurement. + /** Get the most recent TVOC measurement.\ \n * Must call has_new_data() first when when interupts are disabled otherwise the same data will be returned * * @return Most recent TVOC measurement in ppb */ uint16_t tvoc_read(); - /** Get the most recent RAW data. - * Must call has_new_data() first when when interupts are disabled otherwise the same data will be returned + /** Get the most recent RAW data.\ \n + * Must call has_new_data() first when NOT in CONSTANT mode and interupts are disabled otherwise the same data will be returned.\ \n + * When in CONSTANT mode only this read method will return anything other than 0 or NULL.\ If 0 is returned, check for errors. * - * @return Most recent TVOC measurement in ppb + * @return Most recent RAW data */ uint16_t raw_read(); @@ -319,7 +324,9 @@ return enable_interupt(true); } - /** Set whether the data ready interupt is enabled. + /** Set whether the data ready interupt is enabled.\ \n + * Note: If this method fails, the state of the config register cannot be guaranteed.\ \n + * Check errors and ensure all config settings are as expected. * * @param enabled True for enabled, false for disabled *