Press buttons to activate the LED.
Dependencies: BLE_API nRF51822
Fork of Puck by
Log.h@25:cd6703df9501, 2015-03-09 (annotated)
- Committer:
- aleksanb
- Date:
- Mon Mar 09 13:38:22 2015 +0000
- Revision:
- 25:cd6703df9501
- Parent:
- 12:8a8cc109f048
Add power usage note to log.h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cristea | 12:8a8cc109f048 | 1 | /** |
cristea | 12:8a8cc109f048 | 2 | * Copyright 2014 Nordic Semiconductor |
cristea | 12:8a8cc109f048 | 3 | * |
cristea | 12:8a8cc109f048 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
cristea | 12:8a8cc109f048 | 5 | * you may not use this file except in compliance with the License. |
cristea | 12:8a8cc109f048 | 6 | * You may obtain a copy of the License at |
cristea | 12:8a8cc109f048 | 7 | * |
cristea | 12:8a8cc109f048 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
cristea | 12:8a8cc109f048 | 9 | * |
cristea | 12:8a8cc109f048 | 10 | * Unless required by applicable law or agreed to in writing, software |
cristea | 12:8a8cc109f048 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
cristea | 12:8a8cc109f048 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
cristea | 12:8a8cc109f048 | 13 | * See the License for the specific language governing permissions and |
cristea | 12:8a8cc109f048 | 14 | * limitations under the License |
cristea | 12:8a8cc109f048 | 15 | */ |
cristea | 12:8a8cc109f048 | 16 | |
cristea | 7:c07c01c2a741 | 17 | #ifndef __LOG__H__ |
cristea | 7:c07c01c2a741 | 18 | #define __LOG__H__ |
cristea | 7:c07c01c2a741 | 19 | |
aleksanb | 25:cd6703df9501 | 20 | /** |
aleksanb | 25:cd6703df9501 | 21 | * Warning: remove LOG_LEVEL_* defines in production for major power savings. |
aleksanb | 25:cd6703df9501 | 22 | * |
aleksanb | 25:cd6703df9501 | 23 | * Defining a log level will set up a serial connection to use for logging. |
aleksanb | 25:cd6703df9501 | 24 | * This serial connection sets up a timer prohibiting the mbed chip |
aleksanb | 25:cd6703df9501 | 25 | * from entering low power states, drawing ~1.4mAh instead of ~20µAh with logging disabled. |
aleksanb | 25:cd6703df9501 | 26 | */ |
cristea | 7:c07c01c2a741 | 27 | |
cristea | 7:c07c01c2a741 | 28 | #ifdef LOG_LEVEL_VERBOSE |
cristea | 7:c07c01c2a741 | 29 | #define __PUCK_LOG_LEVEL_VERBOSE__ |
cristea | 7:c07c01c2a741 | 30 | #endif |
cristea | 7:c07c01c2a741 | 31 | #ifdef LOG_LEVEL_DEBUG |
cristea | 7:c07c01c2a741 | 32 | #define __PUCK_LOG_LEVEL_DEBUG__ |
cristea | 7:c07c01c2a741 | 33 | #endif |
cristea | 7:c07c01c2a741 | 34 | #ifdef LOG_LEVEL_INFO |
cristea | 7:c07c01c2a741 | 35 | #define __PUCK_LOG_LEVEL_INFO__ |
cristea | 7:c07c01c2a741 | 36 | #endif |
cristea | 7:c07c01c2a741 | 37 | #ifdef LOG_LEVEL_WARN |
cristea | 7:c07c01c2a741 | 38 | #define __PUCK_LOG_LEVEL_WARN__ |
cristea | 7:c07c01c2a741 | 39 | #endif |
cristea | 7:c07c01c2a741 | 40 | #ifdef LOG_LEVEL_ERROR |
cristea | 7:c07c01c2a741 | 41 | #define __PUCK_LOG_LEVEL_ERROR__ |
cristea | 7:c07c01c2a741 | 42 | #endif |
cristea | 7:c07c01c2a741 | 43 | |
cristea | 7:c07c01c2a741 | 44 | #ifdef __PUCK_LOG_LEVEL_VERBOSE__ |
cristea | 7:c07c01c2a741 | 45 | #define LOG_VERBOSE(fmt, ...) do { logger.printf("[V] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) |
cristea | 7:c07c01c2a741 | 46 | #define __PUCK_LOG_LEVEL_DEBUG__ |
cristea | 7:c07c01c2a741 | 47 | #else |
cristea | 7:c07c01c2a741 | 48 | #define LOG_VERBOSE(fmt, ...) |
cristea | 7:c07c01c2a741 | 49 | #endif |
cristea | 7:c07c01c2a741 | 50 | |
cristea | 7:c07c01c2a741 | 51 | #ifdef __PUCK_LOG_LEVEL_DEBUG__ |
cristea | 7:c07c01c2a741 | 52 | #define LOG_DEBUG(fmt, ...) do { logger.printf("[D] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) |
cristea | 7:c07c01c2a741 | 53 | #define __PUCK_LOG_LEVEL_INFO__ |
cristea | 7:c07c01c2a741 | 54 | #else |
cristea | 7:c07c01c2a741 | 55 | #define LOG_DEBUG(fmt, ...) |
cristea | 7:c07c01c2a741 | 56 | #endif |
cristea | 7:c07c01c2a741 | 57 | |
cristea | 7:c07c01c2a741 | 58 | #ifdef __PUCK_LOG_LEVEL_INFO__ |
cristea | 7:c07c01c2a741 | 59 | #define LOG_INFO(fmt, ...) do { logger.printf("[I] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) |
cristea | 7:c07c01c2a741 | 60 | #define __PUCK_LOG_LEVEL_WARN__ |
cristea | 7:c07c01c2a741 | 61 | #else |
cristea | 7:c07c01c2a741 | 62 | #define LOG_INFO(fmt, ...) |
cristea | 7:c07c01c2a741 | 63 | #endif |
cristea | 7:c07c01c2a741 | 64 | |
cristea | 7:c07c01c2a741 | 65 | #ifdef __PUCK_LOG_LEVEL_WARN__ |
cristea | 7:c07c01c2a741 | 66 | #define LOG_WARN(fmt, ...) do { logger.printf("![W] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) |
cristea | 7:c07c01c2a741 | 67 | #define __PUCK_LOG_LEVEL_ERROR__ |
cristea | 7:c07c01c2a741 | 68 | #else |
cristea | 7:c07c01c2a741 | 69 | #define LOG_WARN(fmt, ...) |
cristea | 7:c07c01c2a741 | 70 | #endif |
cristea | 7:c07c01c2a741 | 71 | |
cristea | 7:c07c01c2a741 | 72 | #ifdef __PUCK_LOG_LEVEL_ERROR__ |
cristea | 7:c07c01c2a741 | 73 | #define LOG_ERROR(fmt, ...) do { logger.printf("!![E] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) |
cristea | 7:c07c01c2a741 | 74 | #else |
cristea | 7:c07c01c2a741 | 75 | #define LOG_ERROR(fmt, ...) |
cristea | 7:c07c01c2a741 | 76 | #endif |
cristea | 7:c07c01c2a741 | 77 | |
cristea | 7:c07c01c2a741 | 78 | #ifdef __PUCK_LOG_LEVEL_ERROR__ |
cristea | 7:c07c01c2a741 | 79 | static Serial logger(USBTX, USBRX); |
cristea | 7:c07c01c2a741 | 80 | #endif |
cristea | 7:c07c01c2a741 | 81 | |
cristea | 7:c07c01c2a741 | 82 | |
cristea | 7:c07c01c2a741 | 83 | #endif //__LOG__H__ |