Moved all source to the trunk directory.
[pub/lufa.git] / LUFA / Common / ButtLoadTag.h
diff --git a/LUFA/Common/ButtLoadTag.h b/LUFA/Common/ButtLoadTag.h
new file mode 100644 (file)
index 0000000..54fab0f
--- /dev/null
@@ -0,0 +1,77 @@
+/*\r
+             LUFA Library\r
+     Copyright (C) Dean Camera, 2009.\r
+              \r
+  dean [at] fourwalledcubicle [dot] com\r
+      www.fourwalledcubicle.com\r
+*/\r
+\r
+/*\r
+  Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+  Permission to use, copy, modify, and distribute this software\r
+  and its documentation for any purpose and without fee is hereby\r
+  granted, provided that the above copyright notice appear in all\r
+  copies and that both that the copyright notice and this\r
+  permission notice and warranty disclaimer appear in supporting\r
+  documentation, and that the name of the author not be used in\r
+  advertising or publicity pertaining to distribution of the\r
+  software without specific, written prior permission.\r
+\r
+  The author disclaim all warranties with regard to this\r
+  software, including all implied warranties of merchantability\r
+  and fitness.  In no event shall the author be liable for any\r
+  special, indirect or consequential damages or any damages\r
+  whatsoever resulting from loss of use, data or profits, whether\r
+  in an action of contract, negligence or other tortious action,\r
+  arising out of or in connection with the use or performance of\r
+  this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ *  This file contains macros for the embedding of compile-time strings into the resultant project binary for\r
+ *  identification purposes. It is designed to prefix "tags" with the magic string of "@(#)" so that the tags\r
+ *  can easily be identified in the binary data.\r
+ *\r
+ *  These tags are compatible with the ButtLoad project at http://www.fourwalledcubicle.com/ButtLoad.php .\r
+ */\r
+\r
+#ifndef __BUTTLOADTAG_H__\r
+#define __BUTTLOADTAG_H__\r
+\r
+       /* Includes: */\r
+               #include <avr/io.h>\r
+               #include <avr/pgmspace.h>\r
+\r
+       /* Public Interface - May be used in end-application: */\r
+               /* Macros: */\r
+                       /** Creates a new tag in the resultant binary, containing the specified data array. The macro id\r
+                        *  parameter is only for identification purposes (so that the tag data can be referenced in code)\r
+                        *  and is not visible in the compiled binary.\r
+                        */\r
+                       #define BUTTLOADTAG(id, data)  const struct ButtLoadTagData BUTTTAG_##id \\r
+                                                      PROGMEM __attribute__((used, externally_visible)) = \\r
+                                                      {MagicString: BT_TAGHEADER, TagData: data}\r
+                       \r
+                       /** Macro for retrieving a reference to the specified tag's contents. The tag data is located in\r
+                        *  the program memory (FLASH) space, and so must be read out with the macros in avr-libc which\r
+                        *  deal with embedded data.\r
+                        */\r
+                       #define BUTTLOADTAG_DATA(id)  BUTTTAG_##id.TagData\r
+\r
+               /* Structures: */\r
+                       /** Structure for ButtLoad compatible binary tags. */\r
+                       struct ButtLoadTagData\r
+                       {\r
+                               char MagicString[4]; /**< Magic tag header, containing the string "@(#)". */\r
+                               char TagData[];      /**< Tag contents as a char array. */\r
+                       };                                                                                \r
+\r
+       /* Private Interface - For use in library only: */      \r
+       #if !defined(__DOXYGEN__)\r
+               /* Macros: */\r
+                       #define BT_TAGHEADER          {'@','(','#',')'}\r
+       #endif\r
+       \r
+#endif\r