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
rohm-sensor-hal/rohm_hal.h@9:aecd1e03720a, 2019-02-27 (annotated)
- Committer:
- MACRUM
- Date:
- Wed Feb 27 04:43:34 2019 +0000
- Revision:
- 9:aecd1e03720a
- Parent:
- 7:f83fa2f3cfab
Fix debug print
Who changed what in which revision?
| User | Revision | Line number | New 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 | 0:38c206f19bb7 | 24 | #define USE_MBED_HARDWARE_I2C |
| MACRUM | 9:aecd1e03720a | 25 | #if MBED_MAJOR_VERSION >= 5 |
| MACRUM | 9:aecd1e03720a | 26 | #if _DEBUG |
| MACRUM | 9:aecd1e03720a | 27 | #define DEBUG_print(...) printf(__VA_ARGS__) |
| MACRUM | 9:aecd1e03720a | 28 | #define DEBUG_printf(...) printf(__VA_ARGS__) |
| MACRUM | 9:aecd1e03720a | 29 | #define DEBUG_println(...) printf(__VA_ARGS__);printf("\r\n") |
| MACRUM | 9:aecd1e03720a | 30 | #else |
| MACRUM | 9:aecd1e03720a | 31 | #define DEBUG_print(...) |
| MACRUM | 9:aecd1e03720a | 32 | #define DEBUG_printf(...) |
| MACRUM | 9:aecd1e03720a | 33 | #define DEBUG_println(...) |
| MACRUM | 9:aecd1e03720a | 34 | #endif |
| MACRUM | 9:aecd1e03720a | 35 | #else |
| MikkoZ | 0:38c206f19bb7 | 36 | extern Serial pc; |
| MikkoZ | 0:38c206f19bb7 | 37 | //Serial pc(USBTX, USBRX); done in main.cpp |
| MikkoZ | 0:38c206f19bb7 | 38 | #define DEBUG_print(...) pc.printf(__VA_ARGS__) |
| MikkoZ | 0:38c206f19bb7 | 39 | #define DEBUG_printf(...) pc.printf(__VA_ARGS__) |
| MikkoZ | 0:38c206f19bb7 | 40 | #define DEBUG_println(...) pc.printf(__VA_ARGS__);pc.printf("\r\n") |
| MACRUM | 9:aecd1e03720a | 41 | #endif |
| MikkoZ | 1:4d6dc19a2347 | 42 | #elif defined(YOTTA_MODULE_NAME) |
| MikkoZ | 1:4d6dc19a2347 | 43 | /* Mbed OS */ |
| MikkoZ | 1:4d6dc19a2347 | 44 | #include "mbed-drivers/mbed.h" //types, Serial, I2C -type, ... |
| MikkoZ | 1:4d6dc19a2347 | 45 | #include "mbed-drivers/I2C.h" //I2C |
| MikkoZ | 1:4d6dc19a2347 | 46 | |
| MikkoZ | 1:4d6dc19a2347 | 47 | #define USE_MBED_HARDWARE_I2C |
| MikkoZ | 1:4d6dc19a2347 | 48 | //get_stdio_serial().baud(115200); done in main.cpp |
| MikkoZ | 1:4d6dc19a2347 | 49 | |
| MikkoZ | 1:4d6dc19a2347 | 50 | #define DEBUG_print(...) printf(__VA_ARGS__) |
| MikkoZ | 1:4d6dc19a2347 | 51 | #define DEBUG_printf(...) printf(__VA_ARGS__) |
| MikkoZ | 1:4d6dc19a2347 | 52 | #define DEBUG_println(...) printf(__VA_ARGS__);printf("\r\n") |
| MikkoZ | 0:38c206f19bb7 | 53 | |
| MikkoZ | 0:38c206f19bb7 | 54 | #elif __ARDUINO__ |
| MikkoZ | 1:4d6dc19a2347 | 55 | /* Arduino */ |
| MikkoZ | 0:38c206f19bb7 | 56 | #include <arduino.h> //types, Serial |
| MikkoZ | 0:38c206f19bb7 | 57 | |
| MikkoZ | 0:38c206f19bb7 | 58 | //#define USE_ARDUINO_SOFTWARE_I2C |
| MikkoZ | 0:38c206f19bb7 | 59 | #define USE_ARDUINO_HARDWARE_I2C |
| MikkoZ | 0:38c206f19bb7 | 60 | |
| MikkoZ | 0:38c206f19bb7 | 61 | #define DEBUG_printf(a) Serial.print(a) |
| MikkoZ | 0:38c206f19bb7 | 62 | #define DEBUG_printf(a, b) Serial.print(a);Serial.print(b) |
| MikkoZ | 0:38c206f19bb7 | 63 | #define DEBUG_printf(a, b, c) Serial.print(a);Serial.print(b);Serial.print(c) |
| MikkoZ | 0:38c206f19bb7 | 64 | #define DEBUG_printf(a, b, c, ...) Serial.print(a);Serial.print(b);Serial.print(c) |
| MikkoZ | 0:38c206f19bb7 | 65 | #define DEBUG_print() Serial.print() |
| MikkoZ | 0:38c206f19bb7 | 66 | #define DEBUG_println() Serial.println() |
| MikkoZ | 1:4d6dc19a2347 | 67 | #else |
| MikkoZ | 1:4d6dc19a2347 | 68 | #error "rohm_hal.h: Not valid target." |
| MikkoZ | 0:38c206f19bb7 | 69 | #endif |
| MikkoZ | 0:38c206f19bb7 | 70 | |
| MikkoZ | 0:38c206f19bb7 | 71 | #if 0 //Enable/disable debug prints |
| MikkoZ | 0:38c206f19bb7 | 72 | #define DEBUG_print() |
| MikkoZ | 0:38c206f19bb7 | 73 | #define DEBUG_printf() |
| MikkoZ | 0:38c206f19bb7 | 74 | #define DEBUG_println() |
| MikkoZ | 0:38c206f19bb7 | 75 | #endif |
| MikkoZ | 0:38c206f19bb7 | 76 | |
| MikkoZ | 0:38c206f19bb7 | 77 | #endif /* ROHM_HAL_H */ |