Rohm / rohm-sensor-hal

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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers rohm_hal.h Source File

rohm_hal.h

00001 /*   Copyright 2016 Rohm Semiconductor
00002 
00003    Licensed under the Apache License, Version 2.0 (the "License");
00004    you may not use this file except in compliance with the License.
00005    You may obtain a copy of the License at
00006 
00007        http://www.apache.org/licenses/LICENSE-2.0
00008 
00009    Unless required by applicable law or agreed to in writing, software
00010    distributed under the License is distributed on an "AS IS" BASIS,
00011    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012    See the License for the specific language governing permissions and
00013    limitations under the License.
00014 */
00015 #ifndef ROHM_HAL_H
00016 #define ROHM_HAL_H
00017 
00018 /* This file is meant for making same code work on many platforms easier. */
00019 #ifdef __MBED__
00020     /* Mbed Classic */
00021     #include "mbed.h"               //types
00022     #include "I2C.h"                //I2C
00023 
00024     #define USE_MBED_HARDWARE_I2C
00025 #if MBED_MAJOR_VERSION >= 5
00026 #if _DEBUG
00027     #define DEBUG_print(...)    printf(__VA_ARGS__)
00028     #define DEBUG_printf(...)   printf(__VA_ARGS__)
00029     #define DEBUG_println(...)  printf(__VA_ARGS__);printf("\r\n")
00030 #else
00031     #define DEBUG_print(...)
00032     #define DEBUG_printf(...)
00033     #define DEBUG_println(...)
00034 #endif
00035 #else
00036     extern Serial pc;
00037     //Serial pc(USBTX, USBRX); done in main.cpp
00038     #define DEBUG_print(...)    pc.printf(__VA_ARGS__)
00039     #define DEBUG_printf(...)   pc.printf(__VA_ARGS__)
00040     #define DEBUG_println(...)  pc.printf(__VA_ARGS__);pc.printf("\r\n")
00041 #endif
00042 #elif defined(YOTTA_MODULE_NAME)
00043     /* Mbed OS */
00044     #include "mbed-drivers/mbed.h"  //types, Serial, I2C -type, ...
00045     #include "mbed-drivers/I2C.h"   //I2C
00046 
00047     #define USE_MBED_HARDWARE_I2C
00048     //get_stdio_serial().baud(115200); done in main.cpp
00049 
00050     #define DEBUG_print(...)    printf(__VA_ARGS__)
00051     #define DEBUG_printf(...)   printf(__VA_ARGS__)
00052     #define DEBUG_println(...)  printf(__VA_ARGS__);printf("\r\n")
00053 
00054 #elif __ARDUINO__
00055     /* Arduino */
00056     #include <arduino.h>            //types, Serial
00057 
00058     //#define USE_ARDUINO_SOFTWARE_I2C
00059     #define USE_ARDUINO_HARDWARE_I2C
00060 
00061     #define DEBUG_printf(a)         Serial.print(a)
00062     #define DEBUG_printf(a, b)      Serial.print(a);Serial.print(b)
00063     #define DEBUG_printf(a, b, c)       Serial.print(a);Serial.print(b);Serial.print(c)
00064     #define DEBUG_printf(a, b, c, ...)  Serial.print(a);Serial.print(b);Serial.print(c)
00065     #define DEBUG_print()           Serial.print()
00066     #define DEBUG_println()         Serial.println()
00067 #else
00068     #error "rohm_hal.h: Not valid target."
00069 #endif
00070 
00071 #if 0       //Enable/disable debug prints
00072     #define DEBUG_print()
00073     #define DEBUG_printf()
00074     #define DEBUG_println()
00075 #endif
00076 
00077 #endif /* ROHM_HAL_H */