Hiroshi Yamaguchi / SCP1000

Dependents:   SCP1000Example 0sample_SCP1000_USB SCP1000_Fastsensing

Files at this revision

API Documentation at this revision

Comitter:
yamaguch
Date:
Tue Feb 08 07:26:42 2011 +0000
Parent:
2:4c2784b363ad
Child:
4:112b70cfd265
Commit message:
0.94

Changed in this revision

SCP1000.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
--- a/SCP1000.h	Fri Feb 04 11:56:49 2011 +0000
+++ b/SCP1000.h	Tue Feb 08 07:26:42 2011 +0000
@@ -4,10 +4,9 @@
 #include "mbed.h"
 
 /**
- * SCP1000 Pressure/Temperature sensor
+ * SCP1000 pressure/temperature sensor
  */
 
-
 class SCP1000 {
 public:
     enum OperationMode {
@@ -20,7 +19,7 @@
     };
     
     /**
-    * Constructor
+    * creates an SCP1000 interface with specified pins
     *
     * @param PinName mosi SPI MOSI pin
     * @param PinName miso SPI MISO pin
@@ -33,51 +32,51 @@
     ~SCP1000() {};
 
     /**
-     * Reads revision number
+     * reads revision number
      *
      * @returns revision number
      */
     int revision();
 
     /**
-     * Checks if data is ready
+     * checks if data is ready
      *
-     * @returns true if data is ready, otherwise false
+     * @returns true if data is ready, false otherwise
      */
     bool isReady();
 
     /**
-     * Perform software reset
+     * performs software reset
      */
     void reset();
 
     /**
-     * Set operation mode
+     * sets operation mode
      */
     void setOperationMode(OperationMode mode);
 
     /**
-     * Perform self test
+     * Performs self test
      *
-     * @returns Result of the test (true if succeeded, otherwise false)
+     * @returns the result of the test (true if succeeded, false otherwise)
      */
     bool performSelfTest();
 
     /**
-     * Read pressure
+     * reads pressure
      *
-     * @param waitForDataReady if true, waits until data becomes ready to read
+     * @param waitForDataReady if true, it will wait until data becomes ready to read
      *
-     * @returns Pressure in hectopascal
+     * @returns pressure in hectopascal
      */
     float readPressure(bool waitForDataReady = false);
 
     /**
-     * Read temperature
+     * reads temperature
      *
-     * @param waitForDataReady if true, waits until data becomes ready to read
+     * @param waitForDataReady if true, it will wait until data becomes ready to read
      *
-     * @returns Temperature in Celsius
+     * @returns temperature in Celsius
      */
     float readTemperature(bool waitForDataReady = false);
 
--- a/main.cpp	Fri Feb 04 11:56:49 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-#include "mbed.h"
-#include "SCP1000.h"
-
-DigitalIn sw(p9);
-DigitalOut leds[4] = {LED1, LED2, LED3, LED4};
-SCP1000 scp1000(p11, p12, p13, p10);
-LocalFileSystem local("local");
-
-void printMeasurements(char *title, int n = 10) {
-    FILE *fp = fopen("/local/scp1000.txt", "a");
-    fprintf(fp, "%s\n", title);
-
-    for (int i = 0; !sw && i < n; i++) {
-        while (!scp1000.isReady())
-            ;
-        time_t seconds = time(NULL);
-        char buf[16];
-        strftime(buf, sizeof(buf), "%X", localtime(&seconds));
-        fprintf(fp, "%s %3.2f, %3.3f\n", buf, scp1000.readTemperature(), scp1000.readPressure());
-        leds[i % 4] = (i % 8) < 4;
-        if (i % 100 == 99) {
-            fclose(fp);
-            fp = fopen("/local/scp1000.txt", "a");
-        }
-    }
-
-    fclose(fp);
-    wait(1.0);
-}
-
-int main() {
-    char buf[32];
-    
-    for (int i = 0; !sw; i = (i + 1) % 8) {
-        leds[i < 4 ? i : 7 - i] = 1;
-        wait(0.05);
-        leds[i < 4 ? i : 7 - i] = 0;
-    }
-
-    FILE *fp = fopen("/local/scp1000.txt", "a");
-    if (fp == NULL) exit(-1);
-
-    time_t seconds = time(NULL);
-    strftime(buf, sizeof(buf), "%x %X", localtime(&seconds));
-    fprintf(fp, "Time: %s\n", buf);
-    fprintf(fp, "SCP1000 ASIC revision number = %d\n", scp1000.revision());
-    bool result = scp1000.performSelfTest();
-    fprintf(fp, "SCP1000 self test: %s\n", result ? "PASSED" : "FAILED");
-    fprintf(fp, "SCP1000 reset\n");
-    scp1000.reset();
-    fclose(fp);
-
-    scp1000.setOperationMode(SCP1000::HIGH_SPEED_MODE);
-    printMeasurements("SCP1000 High Speed Mode - 9Hz", 3600 * 9);
-
-    scp1000.setOperationMode(SCP1000::HIGH_RESOLUTION_MODE);
-    printMeasurements("SCP1000 High Resolution Mode - 1.8Hz",  3600 * 9 / 5);
-
-    scp1000.setOperationMode(SCP1000::ULTRA_LOW_POWER_MODE);
-    printMeasurements("SCP1000 Ultra Low Power Mode - 1Hz", 3600 * 10);
-}
\ No newline at end of file
--- a/mbed.bld	Fri Feb 04 11:56:49 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/9a9732ce53a1