Satellite Observers Workbench. NOT yet complete, just published for forum posters to \"cherry pick\" pieces of code as requiered as an example.
debug/debug.h@0:0a841b89d614, 2010-10-11 (annotated)
- Committer:
- AjK
- Date:
- Mon Oct 11 10:34:55 2010 +0000
- Revision:
- 0:0a841b89d614
Totally Alpha quality as this project isn\t completed. Just publishing it as it answers many questions asked in the forums
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AjK | 0:0a841b89d614 | 1 | /**************************************************************************** |
AjK | 0:0a841b89d614 | 2 | * Copyright 2010 Andy Kirkham, Stellar Technologies Ltd |
AjK | 0:0a841b89d614 | 3 | * |
AjK | 0:0a841b89d614 | 4 | * This file is part of the Satellite Observers Workbench (SOWB). |
AjK | 0:0a841b89d614 | 5 | * |
AjK | 0:0a841b89d614 | 6 | * SOWB is free software: you can redistribute it and/or modify |
AjK | 0:0a841b89d614 | 7 | * it under the terms of the GNU General Public License as published by |
AjK | 0:0a841b89d614 | 8 | * the Free Software Foundation, either version 3 of the License, or |
AjK | 0:0a841b89d614 | 9 | * (at your option) any later version. |
AjK | 0:0a841b89d614 | 10 | * |
AjK | 0:0a841b89d614 | 11 | * SOWB is distributed in the hope that it will be useful, |
AjK | 0:0a841b89d614 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
AjK | 0:0a841b89d614 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
AjK | 0:0a841b89d614 | 14 | * GNU General Public License for more details. |
AjK | 0:0a841b89d614 | 15 | * |
AjK | 0:0a841b89d614 | 16 | * You should have received a copy of the GNU General Public License |
AjK | 0:0a841b89d614 | 17 | * along with SOWB. If not, see <http://www.gnu.org/licenses/>. |
AjK | 0:0a841b89d614 | 18 | * |
AjK | 0:0a841b89d614 | 19 | * $Id: main.cpp 5 2010-07-12 20:51:11Z ajk $ |
AjK | 0:0a841b89d614 | 20 | * |
AjK | 0:0a841b89d614 | 21 | ***************************************************************************/ |
AjK | 0:0a841b89d614 | 22 | |
AjK | 0:0a841b89d614 | 23 | #ifndef DEBUG_H |
AjK | 0:0a841b89d614 | 24 | #define DEBUG_H |
AjK | 0:0a841b89d614 | 25 | |
AjK | 0:0a841b89d614 | 26 | /* Comment out the following to totally disable debugging output on UART0. |
AjK | 0:0a841b89d614 | 27 | This is the global kill switch for debug output. */ |
AjK | 0:0a841b89d614 | 28 | #define DEBUG_ON |
AjK | 0:0a841b89d614 | 29 | |
AjK | 0:0a841b89d614 | 30 | |
AjK | 0:0a841b89d614 | 31 | /* These are finer grained debug enable switches. */ |
AjK | 0:0a841b89d614 | 32 | #ifdef DEBUG_ON |
AjK | 0:0a841b89d614 | 33 | #define DEBUG_USE_UART0 |
AjK | 0:0a841b89d614 | 34 | #endif |
AjK | 0:0a841b89d614 | 35 | |
AjK | 0:0a841b89d614 | 36 | /* The following is used "interally" by the debug.c and various other modules. */ |
AjK | 0:0a841b89d614 | 37 | |
AjK | 0:0a841b89d614 | 38 | void debug_init(void); |
AjK | 0:0a841b89d614 | 39 | |
AjK | 0:0a841b89d614 | 40 | /* Buffer sizes MUST be a aligned 2^, for example 8, 16, 32, 64, 128, 256, 512, 1024, etc |
AjK | 0:0a841b89d614 | 41 | Do NOT use any other value or the buffer wrapping firmware won't work. */ |
AjK | 0:0a841b89d614 | 42 | #ifdef DEBUG_USE_UART0 |
AjK | 0:0a841b89d614 | 43 | #define UART0_TX_BUFFER_SIZE 8192 |
AjK | 0:0a841b89d614 | 44 | #define UART0_RX_BUFFER_SIZE 16 |
AjK | 0:0a841b89d614 | 45 | #else |
AjK | 0:0a841b89d614 | 46 | #define UART0_TX_BUFFER_SIZE 4 |
AjK | 0:0a841b89d614 | 47 | #define UART0_RX_BUFFER_SIZE 4 |
AjK | 0:0a841b89d614 | 48 | #endif |
AjK | 0:0a841b89d614 | 49 | |
AjK | 0:0a841b89d614 | 50 | |
AjK | 0:0a841b89d614 | 51 | #ifdef DEBUG_USE_UART0 |
AjK | 0:0a841b89d614 | 52 | /* If debugging is on declare the real function prototypes. */ |
AjK | 0:0a841b89d614 | 53 | int debug_printf(const char *format, ...); |
AjK | 0:0a841b89d614 | 54 | int debug_sprintf(char *out, const char *format, ...); |
AjK | 0:0a841b89d614 | 55 | void debug_string(char *s); |
AjK | 0:0a841b89d614 | 56 | void debug_stringl(char *s, int length); |
AjK | 0:0a841b89d614 | 57 | |
AjK | 0:0a841b89d614 | 58 | #else |
AjK | 0:0a841b89d614 | 59 | |
AjK | 0:0a841b89d614 | 60 | /* If no debugging, replace debug functions with simple empty macros. */ |
AjK | 0:0a841b89d614 | 61 | #define debug_printf(x, ...) |
AjK | 0:0a841b89d614 | 62 | #define debug_sprintf(x, y, ...) |
AjK | 0:0a841b89d614 | 63 | #define debug_string(x) |
AjK | 0:0a841b89d614 | 64 | #define debug_stringl(x, y) |
AjK | 0:0a841b89d614 | 65 | |
AjK | 0:0a841b89d614 | 66 | /* End #ifdef DEBUG_USE_UART0 */ |
AjK | 0:0a841b89d614 | 67 | #endif |
AjK | 0:0a841b89d614 | 68 | |
AjK | 0:0a841b89d614 | 69 | #define DEBUG_INIT_START debug_printf("INIT: %s()... ", __FUNCTION__) |
AjK | 0:0a841b89d614 | 70 | #define DEBUG_INIT_END debug_printf("complete.\r\n") |
AjK | 0:0a841b89d614 | 71 | |
AjK | 0:0a841b89d614 | 72 | /* These function prototypes are always declared. */ |
AjK | 0:0a841b89d614 | 73 | void Uart0_putc(char c); |
AjK | 0:0a841b89d614 | 74 | int Uart0_getc(int block); |
AjK | 0:0a841b89d614 | 75 | |
AjK | 0:0a841b89d614 | 76 | |
AjK | 0:0a841b89d614 | 77 | /* End #ifndef DEBUG_H */ |
AjK | 0:0a841b89d614 | 78 | #endif |
AjK | 0:0a841b89d614 | 79 |