library for AMS ENS210 temperature and humidity sensor

Dependents:   rIoTwear-temp-humid

Files at this revision

API Documentation at this revision

Comitter:
batman52
Date:
Tue Dec 03 18:48:39 2019 +0000
Parent:
8:1a7d241afbcb
Commit message:
// char cmd[len+1]; works with mbed, but not with IAR/GCC

Changed in this revision

AMS_ENS210.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 1a7d241afbcb -r e121ac861a82 AMS_ENS210.cpp
--- a/AMS_ENS210.cpp	Wed Mar 08 09:44:13 2017 +0000
+++ b/AMS_ENS210.cpp	Tue Dec 03 18:48:39 2019 +0000
@@ -256,10 +256,12 @@
     int write_count = 0;
 
 
-    char cmd[len+1];
+    // char cmd[len+1]; works with mbed, but not with IAR/GCC
+    char *cmd = (char *) malloc( len + 1);
     cmd[0] = reg_addr;
     memcpy(cmd+1, input, len);
     write_count = _i2c.write(ENS210_SLAVE_ADDR, cmd, len+1) + 1;
-
+    free(cmd);
+    
     return write_count;
 }
\ No newline at end of file