Class for making communication easier from code to i2c connected Rohm/Kionix sensors. Maybe could be used later also for abstracting Arduino/mbed os. Code ported from 'C'-library rohm-sensor-hal.
Dependents: kionix-kx123-hello rohm-bh1790glc-hello simple-sensor-client rohm-SensorShield-example
Fork of rohm-sensor-hal by
rohm-sensor-hal/rohm_hal.h@0:38c206f19bb7, 2016-04-11 (annotated)
- Committer:
- MikkoZ
- Date:
- Mon Apr 11 08:26:39 2016 +0000
- Revision:
- 0:38c206f19bb7
- Child:
- 1:4d6dc19a2347
Added initial version of i2C HAL
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 | 0:38c206f19bb7 | 20 | #include "mbed.h" //types |
| MikkoZ | 0:38c206f19bb7 | 21 | |
| MikkoZ | 0:38c206f19bb7 | 22 | #define USE_MBED_HARDWARE_I2C |
| MikkoZ | 0:38c206f19bb7 | 23 | extern Serial pc; |
| MikkoZ | 0:38c206f19bb7 | 24 | //Serial pc(USBTX, USBRX); done in main.cpp |
| MikkoZ | 0:38c206f19bb7 | 25 | #define DEBUG_print(...) pc.printf(__VA_ARGS__) |
| MikkoZ | 0:38c206f19bb7 | 26 | #define DEBUG_printf(...) pc.printf(__VA_ARGS__) |
| MikkoZ | 0:38c206f19bb7 | 27 | #define DEBUG_println(...) pc.printf(__VA_ARGS__);pc.printf("\r\n") |
| MikkoZ | 0:38c206f19bb7 | 28 | |
| MikkoZ | 0:38c206f19bb7 | 29 | #elif __ARDUINO__ |
| MikkoZ | 0:38c206f19bb7 | 30 | #include <arduino.h> //types, Serial |
| MikkoZ | 0:38c206f19bb7 | 31 | |
| MikkoZ | 0:38c206f19bb7 | 32 | //#define USE_ARDUINO_SOFTWARE_I2C |
| MikkoZ | 0:38c206f19bb7 | 33 | #define USE_ARDUINO_HARDWARE_I2C |
| MikkoZ | 0:38c206f19bb7 | 34 | |
| MikkoZ | 0:38c206f19bb7 | 35 | #define DEBUG_printf(a) Serial.print(a) |
| MikkoZ | 0:38c206f19bb7 | 36 | #define DEBUG_printf(a, b) Serial.print(a);Serial.print(b) |
| MikkoZ | 0:38c206f19bb7 | 37 | #define DEBUG_printf(a, b, c) Serial.print(a);Serial.print(b);Serial.print(c) |
| MikkoZ | 0:38c206f19bb7 | 38 | #define DEBUG_printf(a, b, c, ...) Serial.print(a);Serial.print(b);Serial.print(c) |
| MikkoZ | 0:38c206f19bb7 | 39 | #define DEBUG_print() Serial.print() |
| MikkoZ | 0:38c206f19bb7 | 40 | #define DEBUG_println() Serial.println() |
| MikkoZ | 0:38c206f19bb7 | 41 | #endif |
| MikkoZ | 0:38c206f19bb7 | 42 | |
| MikkoZ | 0:38c206f19bb7 | 43 | #if 0 //Enable/disable debug prints |
| MikkoZ | 0:38c206f19bb7 | 44 | #define DEBUG_print() |
| MikkoZ | 0:38c206f19bb7 | 45 | #define DEBUG_printf() |
| MikkoZ | 0:38c206f19bb7 | 46 | #define DEBUG_println() |
| MikkoZ | 0:38c206f19bb7 | 47 | #endif |
| MikkoZ | 0:38c206f19bb7 | 48 | |
| MikkoZ | 0:38c206f19bb7 | 49 | #endif /* ROHM_HAL_H */ |
