00001 /* 00002 Copyright (c) 2002, 2003, Oliver Tscherwitschke 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without 00006 modification, are permitted provided that the following conditions are met: 00007 00008 1. Redistributions of source code must retain the above copyright notice, 00009 this list of conditions and the following disclaimer. 00010 2. Redistributions in binary form must reproduce the above copyright notice, 00011 this list of conditions and the following disclaimer in the documentation 00012 and/or other materials provided with the distribution. 00013 3. The name of the author may not be used to endorse or promote products 00014 derived from this software without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED 00017 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 00019 EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00020 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00021 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00022 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00023 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00024 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00025 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 */ 00027 00035 #include <avr/pgmspace.h> 00036 00037 #include "otos_cfg.h" 00038 #include "otos_def.h" 00039 #include "types.h" 00040 #include "error.h" 00041 00042 00043 /* error handler function pointers */ 00044 void (*g_pErrorHandler)(uint8_t*); /* initialized to NULL by C runtime system */ 00045 void (*g_pErrorHandler_P)(PGM_P); /* initialized to NULL by C runtime system */ 00046 00047 00067 void otosError(uint8_t* pMessage) 00068 { 00069 if (g_pErrorHandler) 00070 (*g_pErrorHandler)(pMessage); /* call error hanlder if available */ 00071 else 00072 while (1); /* else halt system */ 00073 } 00074 00075 00087 void otosError_P(PGM_P pMessage) 00088 { 00089 if (g_pErrorHandler_P) 00090 (*g_pErrorHandler_P)(pMessage); /* call error hanlder if available */ 00091 else 00092 while (1); /* else halt system */ 00093 } 00094 00095 00107 void otosSetErrorHandler(void (*pFunc)(uint8_t*)) 00108 { 00109 g_pErrorHandler = pFunc; 00110 } 00111 00112 00124 void otosSetErrorHandler_P(void (*pFunc)(PGM_P)) 00125 { 00126 g_pErrorHandler_P = pFunc; 00127 } 00128