Manuel Caballero / MICS_VZ_89TE

Files at this revision

API Documentation at this revision

Comitter:
mcm
Date:
Wed Jun 09 17:42:19 2021 +0000
Parent:
3:8381e6057dac
Commit message:
The driver was completed and tested (NUCLEO-L152RE), it works as expected.

Changed in this revision

MICS_VZ_89TE.h Show annotated file Show diff for this revision Revisions of this file
diff -r 8381e6057dac -r b00d73e7a096 MICS_VZ_89TE.h
--- a/MICS_VZ_89TE.h	Tue Jun 08 19:14:02 2021 +0000
+++ b/MICS_VZ_89TE.h	Wed Jun 09 17:42:19 2021 +0000
@@ -23,7 +23,99 @@
     Example:
 
 @code
+#include "mbed.h"
+#include "MICS_VZ_89TE.h"
 
+MICS_VZ_89TE myMICS_VZ_89TE ( I2C_SDA, I2C_SCL, MICS_VZ_89TE::MICS_VZ_89TE_ADDRESS, 100000 );               // I2C_SDA | I2C_SCL
+Serial pc     ( USBTX, USBRX );                                                 // tx, rx
+
+DigitalOut  myled   ( LED1 );
+Ticker      newAction;
+
+
+//@brief Constants.
+
+
+//@brief Variables.
+volatile uint32_t myState;                                                      // State that indicates when to perform a new sample
+
+
+//@brief   FUNCTION PROTOTYPES
+void    changeDATA     ( void );
+
+
+//@brief FUNCTION FOR APPLICATION MAIN ENTRY.
+int main()
+{
+    MICS_VZ_89TE::MICS_VZ_89TE_status_t aux;
+    MICS_VZ_89TE::MICS_VZ_89TE_data_t   myMICS_VZ_89TE_Data;
+
+    pc.baud ( 115200 );
+
+    myled   =   1;
+    wait(3);
+    myled   =   0;
+
+    // It triggers the Revision command and gets the result
+    aux  =   myMICS_VZ_89TE.MICS_VZ_89TE_TriggersRevision ();
+    wait_ms (100);
+    aux  =   myMICS_VZ_89TE.MICS_VZ_89TE_GetRevision ( &myMICS_VZ_89TE_Data.device );
+
+    // It triggers the R0 ( calibration ) command and gets the result
+    aux  =   myMICS_VZ_89TE.MICS_VZ_89TE_TriggersR0 ();
+    wait_ms (100);
+    aux  =   myMICS_VZ_89TE.MICS_VZ_89TE_GetR0 ( &myMICS_VZ_89TE_Data.r0_raw, &myMICS_VZ_89TE_Data.r0 );
+
+    pc.printf ( "Revision: %d | R0: %d\r\n", myMICS_VZ_89TE_Data.device, myMICS_VZ_89TE_Data.r0 );
+
+
+    myState  =   0UL;                                                           // Reset the variable
+    newAction.attach( &changeDATA, 5U );                                        // the address of the function to be attached ( changeDATA ) and the interval ( 5s )
+
+    // Let the callbacks take care of everything
+    while(1) {
+        sleep();
+
+        if ( myState == 1UL ) {
+            myled = 1U;
+
+            // Trigger to get a new data value
+            aux  =   myMICS_VZ_89TE.MICS_VZ_89TE_TriggersStatus ();
+            wait_ms (100);
+
+            // Get the values: tVOC, CO2_equ and Resistor
+            aux  =   myMICS_VZ_89TE.MICS_VZ_89TE_GetUpdateValues ( &myMICS_VZ_89TE_Data.status, &myMICS_VZ_89TE_Data.values );
+
+            // Send data through the UART
+            pc.printf ( "tVOC: %d [ppb], CO2_equ: %d [ppm], R: %d [kOhms]\r\n", (uint32_t)myMICS_VZ_89TE_Data.values.tvoc, (uint32_t)myMICS_VZ_89TE_Data.values.co2_equ, (uint32_t)myMICS_VZ_89TE_Data.values.resistor );
+
+            // Reset the variables
+            myState  =   0UL;
+            myled    =   0U;
+        }
+    }
+}
+
+
+// @brief       changeDATA ( void  )
+//
+// @details     It changes myState variable
+//
+// @param[in]    N/A
+//
+// @param[out]   N/A.
+//
+// @return       N/A.
+//
+// @author      Manuel Caballero
+// @date        09/June/2021
+// @version     09/June/2021   The ORIGIN
+// @pre         N/A
+// @warning     N/A.
+void changeDATA ( void )
+{
+    myState  =   1UL;
+}
 @endcode
 */