@@ -34,7 +34,12 @@ extern "C" {
34
34
/**
35
35
* @brief Default I2C address of SRF02 sensors
36
36
*/
37
- #define SRF02_DEFAULT_ADDR (0xe0)
37
+ #define SRF02_DEFAULT_ADDR (0xe0) /* 224 decimal */
38
+
39
+ /**
40
+ * @brief The datasheet tells us, that ranging takes 70ms
41
+ */
42
+ #define SRF02_RANGE_DELAY (70000U)
38
43
39
44
/**
40
45
* @brief Device descriptor for SRF02 sensors
@@ -69,11 +74,38 @@ typedef enum {
69
74
int srf02_init (srf02_t * dev , i2c_t i2c , uint8_t addr );
70
75
71
76
/**
72
- * @brief Get the distance measured from the SRF02 ultrasonic sensor
77
+ * @brief Trigger a new measurement
78
+ *
79
+ * This function triggers a new ranging operation. After triggering this
80
+ * operation, you have to wait at least 70ms for the result to be ready.
73
81
*
74
82
* The result of the ranging operation is returned in inches, centimeters or
75
83
* microseconds - depending on the given @p mode parameter.
76
84
*
85
+ * @param[in] dev device to trigger
86
+ * @param[in] mode there are three real ranging modes, which return
87
+ * the result in inches, centimeters or microseconds.
88
+ * Another set of three fake ranging modes do the same
89
+ * but without transmitting the burst
90
+ */
91
+ void srf02_trigger (srf02_t * dev , srf02_mode_t mode );
92
+
93
+ /**
94
+ * @brief Read the results of the last ranging operation
95
+ *
96
+ * @param[in] dev device to read from
97
+ *
98
+ * @return result of the last ranging operation, meaning depends on the mode
99
+ * parameter given to the srf02_trigger function
100
+ */
101
+ uint16_t srf02_read (srf02_t * dev );
102
+
103
+ /**
104
+ * @brief Get the distance measured from the SRF02 ultrasonic sensor
105
+ *
106
+ * This function combines the srf02_trigger and the srf02_read functions for
107
+ * simplified usage in simple (single sensor) setups.
108
+ *
77
109
* @param[in] dev device descriptor of an SRF02 sensor
78
110
* @param[in] mode there are three real ranging modes, which return
79
111
* the result in inches, centimeters or microseconds.
0 commit comments