Include first driver: SHT31

Make I2C reads blocking w/ timeout
Add SHT31 driver, roughly :)
Fix mg_time() to return a double.
This commit is contained in:
Pim van Pelt
2018-04-02 17:29:13 +02:00
parent cef7c5107d
commit b1d92a32a8
9 changed files with 396 additions and 35 deletions

View File

@ -2,6 +2,7 @@
*/
#include "mgos_mock.h"
#include <unistd.h>
int _mgos_timers = 0;
@ -31,14 +32,18 @@ int log_print_prefix(enum cs_log_level l, const char *func, const char *file) {
return 1;
}
float mg_time() {
struct timeval tod;
float time;
double mg_time() {
struct timespec ts;
double ret;
gettimeofday(&tod, NULL);
clock_gettime(CLOCK_REALTIME_COARSE, &ts);
time = tod.tv_sec;
time += tod.tv_usec/1000000;
ret = (double) ts.tv_sec;
ret += ((double)ts.tv_nsec)/1000000000;
return time;
return ret;
}
void mgos_usleep(uint32_t usecs) {
usleep(usecs);
}