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

Committer:
MikkoZ
Date:
Tue Apr 12 04:57:59 2016 +0000
Revision:
1:4d6dc19a2347
Parent:
0:38c206f19bb7
Child:
7:f83fa2f3cfab
Added support for mbed OS

Added support for mbed OS.
Successfully compiled and tested program for frdm-k64f-gcc/bm1383.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikkoZ 0:38c206f19bb7 1 /* Copyright 2016 Rohm Semiconductor
MikkoZ 0:38c206f19bb7 2
MikkoZ 0:38c206f19bb7 3 Licensed under the Apache License, Version 2.0 (the "License");
MikkoZ 0:38c206f19bb7 4 you may not use this file except in compliance with the License.
MikkoZ 0:38c206f19bb7 5 You may obtain a copy of the License at
MikkoZ 0:38c206f19bb7 6
MikkoZ 0:38c206f19bb7 7 http://www.apache.org/licenses/LICENSE-2.0
MikkoZ 0:38c206f19bb7 8
MikkoZ 0:38c206f19bb7 9 Unless required by applicable law or agreed to in writing, software
MikkoZ 0:38c206f19bb7 10 distributed under the License is distributed on an "AS IS" BASIS,
MikkoZ 0:38c206f19bb7 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MikkoZ 0:38c206f19bb7 12 See the License for the specific language governing permissions and
MikkoZ 0:38c206f19bb7 13 limitations under the License.
MikkoZ 0:38c206f19bb7 14 */
MikkoZ 0:38c206f19bb7 15 #ifndef ROHM_HAL_H
MikkoZ 0:38c206f19bb7 16 #define ROHM_HAL_H
MikkoZ 0:38c206f19bb7 17
MikkoZ 0:38c206f19bb7 18 /* This file is meant for making same code work on many platforms easier. */
MikkoZ 0:38c206f19bb7 19 #ifdef __MBED__
MikkoZ 1:4d6dc19a2347 20 /* Mbed Classic */
MikkoZ 0:38c206f19bb7 21 #include "mbed.h" //types
MikkoZ 1:4d6dc19a2347 22 #include "I2C.h" //I2C
MikkoZ 0:38c206f19bb7 23
MikkoZ 1:4d6dc19a2347 24 #ifndef uint8_t
MikkoZ 1:4d6dc19a2347 25 #define uint8_t int
MikkoZ 1:4d6dc19a2347 26 #endif
MikkoZ 0:38c206f19bb7 27 #define USE_MBED_HARDWARE_I2C
MikkoZ 0:38c206f19bb7 28 extern Serial pc;
MikkoZ 0:38c206f19bb7 29 //Serial pc(USBTX, USBRX); done in main.cpp
MikkoZ 0:38c206f19bb7 30 #define DEBUG_print(...) pc.printf(__VA_ARGS__)
MikkoZ 0:38c206f19bb7 31 #define DEBUG_printf(...) pc.printf(__VA_ARGS__)
MikkoZ 0:38c206f19bb7 32 #define DEBUG_println(...) pc.printf(__VA_ARGS__);pc.printf("\r\n")
MikkoZ 1:4d6dc19a2347 33 #elif defined(YOTTA_MODULE_NAME)
MikkoZ 1:4d6dc19a2347 34 /* Mbed OS */
MikkoZ 1:4d6dc19a2347 35 #include "mbed-drivers/mbed.h" //types, Serial, I2C -type, ...
MikkoZ 1:4d6dc19a2347 36 #include "mbed-drivers/I2C.h" //I2C
MikkoZ 1:4d6dc19a2347 37
MikkoZ 1:4d6dc19a2347 38 #define USE_MBED_HARDWARE_I2C
MikkoZ 1:4d6dc19a2347 39 //get_stdio_serial().baud(115200); done in main.cpp
MikkoZ 1:4d6dc19a2347 40
MikkoZ 1:4d6dc19a2347 41 #define DEBUG_print(...) printf(__VA_ARGS__)
MikkoZ 1:4d6dc19a2347 42 #define DEBUG_printf(...) printf(__VA_ARGS__)
MikkoZ 1:4d6dc19a2347 43 #define DEBUG_println(...) printf(__VA_ARGS__);printf("\r\n")
MikkoZ 0:38c206f19bb7 44
MikkoZ 0:38c206f19bb7 45 #elif __ARDUINO__
MikkoZ 1:4d6dc19a2347 46 /* Arduino */
MikkoZ 0:38c206f19bb7 47 #include <arduino.h> //types, Serial
MikkoZ 0:38c206f19bb7 48
MikkoZ 0:38c206f19bb7 49 //#define USE_ARDUINO_SOFTWARE_I2C
MikkoZ 0:38c206f19bb7 50 #define USE_ARDUINO_HARDWARE_I2C
MikkoZ 0:38c206f19bb7 51
MikkoZ 0:38c206f19bb7 52 #define DEBUG_printf(a) Serial.print(a)
MikkoZ 0:38c206f19bb7 53 #define DEBUG_printf(a, b) Serial.print(a);Serial.print(b)
MikkoZ 0:38c206f19bb7 54 #define DEBUG_printf(a, b, c) Serial.print(a);Serial.print(b);Serial.print(c)
MikkoZ 0:38c206f19bb7 55 #define DEBUG_printf(a, b, c, ...) Serial.print(a);Serial.print(b);Serial.print(c)
MikkoZ 0:38c206f19bb7 56 #define DEBUG_print() Serial.print()
MikkoZ 0:38c206f19bb7 57 #define DEBUG_println() Serial.println()
MikkoZ 1:4d6dc19a2347 58 #else
MikkoZ 1:4d6dc19a2347 59 #error "rohm_hal.h: Not valid target."
MikkoZ 0:38c206f19bb7 60 #endif
MikkoZ 0:38c206f19bb7 61
MikkoZ 0:38c206f19bb7 62 #if 0 //Enable/disable debug prints
MikkoZ 0:38c206f19bb7 63 #define DEBUG_print()
MikkoZ 0:38c206f19bb7 64 #define DEBUG_printf()
MikkoZ 0:38c206f19bb7 65 #define DEBUG_println()
MikkoZ 0:38c206f19bb7 66 #endif
MikkoZ 0:38c206f19bb7 67
MikkoZ 0:38c206f19bb7 68 #endif /* ROHM_HAL_H */