diff options
author | Karel Kočí <cynerd@email.cz> | 2017-03-07 10:10:09 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-03-07 10:10:09 +0100 |
commit | fbe0e4d00ba7e026b8b848cfcd0ed583a71f8069 (patch) | |
tree | 21c0c60ebfef4b7fabcd659a8af373bad46dec7f /include/error.h | |
parent | 5ab2332addae2a90a1fa438c91e8069ebbfc4082 (diff) | |
download | avr-ioe-fbe0e4d00ba7e026b8b848cfcd0ed583a71f8069.tar.gz avr-ioe-fbe0e4d00ba7e026b8b848cfcd0ed583a71f8069.tar.bz2 avr-ioe-fbe0e4d00ba7e026b8b848cfcd0ed583a71f8069.zip |
Just huge update
Diffstat (limited to 'include/error.h')
-rw-r--r-- | include/error.h | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/include/error.h b/include/error.h index 7b13bcd..6621633 100644 --- a/include/error.h +++ b/include/error.h @@ -1,3 +1,43 @@ +#include <stdlib.h> #include <stdint.h> -#include <ioport.h> +#ifndef _IOE_ERROR_H_ +#define _IOE_ERROR_H_ +#ifdef CONFIG_ERRORS + +enum ErrorCodes { + EC_OK = 0, // This is not really error code. It triggers error callback but the error function returns + EC_FUNC_ARG, // Invalid argument passed to function + EC_INVALID_PORT, // IO error, requested port is not on your CPU + EC_BUFFER_FULL, // If configured so, full buffer causes this error + _EC_LAST = 128 // Not really error code. This reserver error range for library. User can define its error codes by adding +}; + +#ifdef CONFIG_ERROR_MESSAGES + +void _error(enum ErrorCodes ec, const char *msg); +#define error(EC, MSG) _error(EC, MSG) + +#ifdef CONFIG_ERROR_CALLBACK +void error_callback(enum ErrorCodes ec, const char *msg); +#endif /* CONFIG_ERROR_CALLBACK */ + +#else /* CONFIG_ERROR_MESSAGES*/ + +void _error(enum ErrorCodes ec); +#define error(EC, MSG) _error(EC) + +#ifdef CONFIG_ERROR_CALLBACK +void error_callback(enum ErrorCodes ec); +#endif /* CONFIG_ERROR_CALLBACK */ + +#endif /* CONFIG_ERROR_MESSAGES */ + + +#else /* CONFIG_ERRORS */ + +// Just dummy definition to suppress all errors +#define error(EC, MSG) + +#endif /* CONFIG_ERRORS */ +#endif /* _IOE_ERROR_H_ */ |