Platform HAL for rohm sensor drivers. Used for abstracting Arduino/mbed os/mbed classic.

Dependents:   rohm-bm1383-hello-mbedclassic rohm-bh1726-hello rohm-rpr0521-hello rohm-bh1745-hello ... more

Revision:
1:4d6dc19a2347
Parent:
0:38c206f19bb7
Child:
7:f83fa2f3cfab
--- a/rohm-sensor-hal/rohm_hal.h	Mon Apr 11 08:26:39 2016 +0000
+++ b/rohm-sensor-hal/rohm_hal.h	Tue Apr 12 04:57:59 2016 +0000
@@ -17,16 +17,33 @@
 
 /* This file is meant for making same code work on many platforms easier. */
 #ifdef __MBED__
+    /* Mbed Classic */
     #include "mbed.h"               //types
+    #include "I2C.h"                //I2C
 
+    #ifndef uint8_t
+        #define uint8_t int
+    #endif
     #define USE_MBED_HARDWARE_I2C
     extern Serial pc;
     //Serial pc(USBTX, USBRX); done in main.cpp
     #define DEBUG_print(...)    pc.printf(__VA_ARGS__)
     #define DEBUG_printf(...)   pc.printf(__VA_ARGS__)
     #define DEBUG_println(...)  pc.printf(__VA_ARGS__);pc.printf("\r\n")
+#elif defined(YOTTA_MODULE_NAME)
+    /* Mbed OS */
+    #include "mbed-drivers/mbed.h"  //types, Serial, I2C -type, ...
+    #include "mbed-drivers/I2C.h"   //I2C
+
+    #define USE_MBED_HARDWARE_I2C
+    //get_stdio_serial().baud(115200); done in main.cpp
+
+    #define DEBUG_print(...)    printf(__VA_ARGS__)
+    #define DEBUG_printf(...)   printf(__VA_ARGS__)
+    #define DEBUG_println(...)  printf(__VA_ARGS__);printf("\r\n")
 
 #elif __ARDUINO__
+    /* Arduino */
     #include <arduino.h>            //types, Serial
 
     //#define USE_ARDUINO_SOFTWARE_I2C
@@ -38,6 +55,8 @@
     #define DEBUG_printf(a, b, c, ...)  Serial.print(a);Serial.print(b);Serial.print(c)
     #define DEBUG_print()           Serial.print()
     #define DEBUG_println()         Serial.println()
+#else
+    #error "rohm_hal.h: Not valid target."
 #endif
 
 #if 0       //Enable/disable debug prints