Updated LUFA to SVN r1992.
This commit is contained in:
		| @@ -1,74 +1,74 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Bootloader user application API functions. | ||||
|  */ | ||||
|  | ||||
| #include "BootloaderAPI.h" | ||||
|  | ||||
| void BootloaderAPI_ErasePage(uint32_t Address) | ||||
| { | ||||
| 	boot_page_erase_safe(Address); | ||||
| 	boot_rww_enable(); | ||||
| } | ||||
|  | ||||
| void BootloaderAPI_WritePage(uint32_t Address) | ||||
| { | ||||
| 	boot_page_write_safe(Address); | ||||
| 	boot_rww_enable(); | ||||
| } | ||||
|  | ||||
| void BootloaderAPI_FillWord(uint32_t Address, uint16_t Word) | ||||
| { | ||||
| 	boot_page_fill_safe(Address, Word); | ||||
| } | ||||
|  | ||||
| uint8_t BootloaderAPI_ReadSignature(uint16_t Address) | ||||
| { | ||||
| 	return boot_signature_byte_get(Address); | ||||
| } | ||||
|  | ||||
| uint8_t BootloaderAPI_ReadFuse(uint16_t Address) | ||||
| { | ||||
| 	return boot_lock_fuse_bits_get(Address); | ||||
| } | ||||
|  | ||||
| uint8_t BootloaderAPI_ReadLock(void) | ||||
| { | ||||
| 	return boot_lock_fuse_bits_get(GET_LOCK_BITS); | ||||
| } | ||||
|  | ||||
| void BootloaderAPI_WriteLock(uint8_t LockBits) | ||||
| { | ||||
| 	boot_lock_bits_set_safe(LockBits); | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Bootloader user application API functions. | ||||
|  */ | ||||
|  | ||||
| #include "BootloaderAPI.h" | ||||
|  | ||||
| void BootloaderAPI_ErasePage(uint32_t Address) | ||||
| { | ||||
| 	boot_page_erase_safe(Address); | ||||
| 	boot_rww_enable(); | ||||
| } | ||||
|  | ||||
| void BootloaderAPI_WritePage(uint32_t Address) | ||||
| { | ||||
| 	boot_page_write_safe(Address); | ||||
| 	boot_rww_enable(); | ||||
| } | ||||
|  | ||||
| void BootloaderAPI_FillWord(uint32_t Address, uint16_t Word) | ||||
| { | ||||
| 	boot_page_fill_safe(Address, Word); | ||||
| } | ||||
|  | ||||
| uint8_t BootloaderAPI_ReadSignature(uint16_t Address) | ||||
| { | ||||
| 	return boot_signature_byte_get(Address); | ||||
| } | ||||
|  | ||||
| uint8_t BootloaderAPI_ReadFuse(uint16_t Address) | ||||
| { | ||||
| 	return boot_lock_fuse_bits_get(Address); | ||||
| } | ||||
|  | ||||
| uint8_t BootloaderAPI_ReadLock(void) | ||||
| { | ||||
| 	return boot_lock_fuse_bits_get(GET_LOCK_BITS); | ||||
| } | ||||
|  | ||||
| void BootloaderAPI_WriteLock(uint8_t LockBits) | ||||
| { | ||||
| 	boot_lock_bits_set_safe(LockBits); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,59 +1,56 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for BootloaderAPI.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _BOOTLOADER_API_H_ | ||||
| #define _BOOTLOADER_API_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/boot.h> | ||||
| 		#include <stdbool.h> | ||||
| 		 | ||||
| 		#include <LUFA/Common/Common.h> | ||||
| 	 | ||||
| 	/* External Variables: */ | ||||
| 		extern uint8_t* BootloaderAPI_JumpTable; | ||||
| 	 | ||||
| 	/* Function Prototypes: */ | ||||
| 		void    BootloaderAPI_ErasePage(uint32_t Address); | ||||
| 		void    BootloaderAPI_WritePage(uint32_t Address); | ||||
| 		void    BootloaderAPI_FillWord(uint32_t Address, uint16_t Word); | ||||
| 		uint8_t BootloaderAPI_ReadSignature(uint16_t Address); | ||||
| 		uint8_t BootloaderAPI_ReadFuse(uint16_t Address); | ||||
| 		uint8_t BootloaderAPI_ReadLock(void); | ||||
| 		void    BootloaderAPI_WriteLock(uint8_t LockBits); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for BootloaderAPI.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _BOOTLOADER_API_H_ | ||||
| #define _BOOTLOADER_API_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/boot.h> | ||||
| 		#include <stdbool.h> | ||||
| 		 | ||||
| 		#include <LUFA/Common/Common.h> | ||||
| 	 | ||||
| 	/* Function Prototypes: */ | ||||
| 		void    BootloaderAPI_ErasePage(uint32_t Address); | ||||
| 		void    BootloaderAPI_WritePage(uint32_t Address); | ||||
| 		void    BootloaderAPI_FillWord(uint32_t Address, uint16_t Word); | ||||
| 		uint8_t BootloaderAPI_ReadSignature(uint16_t Address); | ||||
| 		uint8_t BootloaderAPI_ReadFuse(uint16_t Address); | ||||
| 		uint8_t BootloaderAPI_ReadLock(void); | ||||
| 		void    BootloaderAPI_WriteLock(uint8_t LockBits); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,43 +1,43 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| ; Bootloader API Jump Table | ||||
| .section .apitable, "ax" | ||||
| .org 0 | ||||
|  | ||||
| .global BootloaderAPI_JumpTable | ||||
| BootloaderAPI_JumpTable: | ||||
| 	jmp BootloaderAPI_ErasePage | ||||
| 	jmp BootloaderAPI_WritePage | ||||
| 	jmp BootloaderAPI_FillWord | ||||
| 	jmp BootloaderAPI_ReadSignature | ||||
| 	jmp BootloaderAPI_ReadFuse | ||||
| 	jmp BootloaderAPI_ReadLock | ||||
| 	jmp BootloaderAPI_WriteLock | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| ; Bootloader API Jump Table | ||||
| .section .apitable, "ax" | ||||
| .org 0 | ||||
|  | ||||
| .global BootloaderAPI_JumpTable | ||||
| BootloaderAPI_JumpTable: | ||||
| 	jmp BootloaderAPI_ErasePage | ||||
| 	jmp BootloaderAPI_WritePage | ||||
| 	jmp BootloaderAPI_FillWord | ||||
| 	jmp BootloaderAPI_ReadSignature | ||||
| 	jmp BootloaderAPI_ReadFuse | ||||
| 	jmp BootloaderAPI_ReadLock | ||||
| 	jmp BootloaderAPI_WriteLock | ||||
|   | ||||
| @@ -1,250 +0,0 @@ | ||||
| :020000021000EC | ||||
| :10E000004BC0000066C0000064C0000062C0000099 | ||||
| :10E0100060C000005EC000005CC000005AC000008C | ||||
| :10E0200058C0000056C00000BEC4000052C000002E | ||||
| :10E0300050C000004EC000004CC000004AC00000AC | ||||
| :10E0400048C0000046C0000044C0000042C00000BC | ||||
| :10E0500041C000003EC000003CC000003AC00000CB | ||||
| :10E0600038C0000036C0000034C0000032C00000DC | ||||
| :10E0700030C000002EC000002CC000002AC00000EC | ||||
| :10E0800028C0000026C0000024C0000022C00000FC | ||||
| :10E0900020C000001EC0000011241FBECFEFD0E240 | ||||
| :10E0A000DEBFCDBF11E0A0E0B1E0E8EBFEEE01E0A5 | ||||
| :10E0B0000BBF02C007900D92AC38B107D9F711E041 | ||||
| :10E0C000ACE8B1E001C01D92AA39B107E1F734D341 | ||||
| :10E0D000F1C696CF1F920F920FB60F9211240F9098 | ||||
| :10E0E0000FBE0F901F90189584E08093E9000DC03B | ||||
| :10E0F0008091E8008B778093E80003C08EB388237B | ||||
| :10E1000051F08091E80082FFF9CF8091E80085FF0F | ||||
| :10E11000EFCF8091F1000895982F83E08093E9007C | ||||
| :10E120008091E80085FD0DC08091E8008E77809396 | ||||
| :10E13000E80003C08EB3882331F08091E80080FFAF | ||||
| :10E14000F9CF9093F10008954F925F926F927F9272 | ||||
| :10E150008F929F92AF92BF92CF92DF92EF92FF92F7 | ||||
| :10E160000F931F93CF93DF9384E08093E900809116 | ||||
| :10E17000E80082FF73C2B8DF182F853419F41092BB | ||||
| :10E18000080103C0843519F4AFDF8DE03DC28C3443 | ||||
| :10E19000E1F38035D1F3843711F484E495C08136FE | ||||
| :10E1A00011F489E531C28134B1F49EDF182F9CDF70 | ||||
| :10E1B00090E0880F991FAA2797FDA095BA2F312FBD | ||||
| :10E1C000330F20E0442737FD4095542F822B932BAB | ||||
| :10E1D000A42BB52BEAC1803711F483E515C2833532 | ||||
| :10E1E00049F4C0E0D1E0899197DF41E0C730D4071E | ||||
| :10E1F000D1F70BC2863521F481E38EDF80E304C2C0 | ||||
| :10E20000833731F482E888DF87E986DF8EE1FCC15D | ||||
| :10E21000853629F580E090E0A0E0B0E033E025E02D | ||||
| :10E22000FC01A0935B0030935700E89507B600FC13 | ||||
| :10E23000FDCFFC01A0935B0020935700E89507B643 | ||||
| :10E2400000FCFDCF80509F4FAF4FBF4F803040EE5E | ||||
| :10E25000940741E0A40740E0B40711F796CF8C364D | ||||
| :10E2600051F442DF809599E0E1E0F0E0082E9093D0 | ||||
| :10E270005700E8958ACF823739F4E1E0F0E089E091 | ||||
| :10E28000809357008491C0C1863439F4E0E0F0E017 | ||||
| :10E2900089E0809357008491B7C18E3439F4E3E06C | ||||
| :10E2A000F0E089E0809357008491AEC1813539F464 | ||||
| :10E2B000E2E0F0E089E0809357008491A5C18236C6 | ||||
| :10E2C00031F489E529DF81E027DF80E09DC18234D8 | ||||
| :10E2D00019F0873609F0E6C007DF082F05DFF82EB2 | ||||
| :10E2E00003DF682E8554823008F08DC1902F80E0C6 | ||||
| :10E2F000CF2DD0E0C82BD92B173609F050C081E1C3 | ||||
| :10E3000080935700E895DD24CC24C39444C0E0906A | ||||
| :10E310008C01F0908D0100918E0110918F0186E4A7 | ||||
| :10E32000681601F58D2D90E0A0E0B0E08E299F29C0 | ||||
| :10E33000A02BB12BABBFFC018791EEDEDD2081F07D | ||||
| :10E3400082E090E0A0E0B0E0E80EF91E0A1F1B1F7B | ||||
| :10E35000E0928C01F0928D0100938E0110938F0159 | ||||
| :10E36000DC2418C0D801C701B695A7959795879565 | ||||
| :10E370008BD5D2DE82E090E0A0E0B0E0E80EF91E9E | ||||
| :10E380000A1F1B1FE0928C01F0928D0100938E01F9 | ||||
| :10E3900010938F012197209709F0B9CF36C1809053 | ||||
| :10E3A0008C0190908D01A0908E01B0908F0196E429 | ||||
| :10E3B000691609F061C083E0F401A0925B008093CC | ||||
| :10E3C0005700E89507B600FCFDCF56C0A6E46A16D4 | ||||
| :10E3D00071F5772041F1E0908C01F0908D01009172 | ||||
| :10E3E0008E0110918F0180DED82ECC24852D90E0F7 | ||||
| :10E3F0008C299D290C01F70100935B004092570086 | ||||
| :10E40000E895112482E090E0A0E0B0E0E80EF91E6B | ||||
| :10E410000A1F1B1FE0928C01F0928D0100938E0168 | ||||
| :10E4200010938F0102C060DE582E742423C0E09048 | ||||
| :10E430008C01F0908D0100918E0110918F01169545 | ||||
| :10E440000795F794E79450DE682FC70125D5809192 | ||||
| :10E450008C0190918D01A0918E01B0918F01029657 | ||||
| :10E46000A11DB11D80938C0190938D01A0938E010D | ||||
| :10E47000B0938F01219704C05524772444244394FA | ||||
| :10E48000209709F0A3CF96E4691609F07ECE85E0C7 | ||||
| :10E49000F401A0925B0080935700E89507B600FC5A | ||||
| :10E4A000FDCF73CE8334A1F4E0908C01F0908D0108 | ||||
| :10E4B00000918E0110918F0117DE90E021E00C0198 | ||||
| :10E4C000F70100935B0020935700E89511245DCE7F | ||||
| :10E4D000833639F5E0908C01F0908D0100918E012A | ||||
| :10E4E00010918F0101DEA8019701216090E061E0A9 | ||||
| :10E4F0000C01F90140935B0060935700E8951124EB | ||||
| :10E5000082E090E0A0E0B0E0E80EF91E0A1F1B1FB9 | ||||
| :10E51000E0928C01F0928D0100938E0110938F0197 | ||||
| :10E5200034CE8D3699F480918C0190918D01A0911B | ||||
| :10E530008E01B0918F0125E0FC01A0935B00209338 | ||||
| :10E540005700E89507B600FCFDCF1FCE823581F459 | ||||
| :10E55000E0908C01F0908D0100918E0110918F015F | ||||
| :10E560000BBFF701E790F6908F2DD6DD8E2D4CC0B6 | ||||
| :10E57000843421F5E0908C01F0908D0100918E01A2 | ||||
| :10E5800010918F0116950795F794E794ADDD682FEC | ||||
| :10E59000C70182D480918C0190918D01A0918E0150 | ||||
| :10E5A000B0918F010296A11DB11D80938C019093B3 | ||||
| :10E5B0008D01A0938E01B0938F01E7CD843609F5CC | ||||
| :10E5C000E0908C01F0908D0100918E0110918F01EF | ||||
| :10E5D000D801C701B695A7959795879555D49CDD29 | ||||
| :10E5E00082E090E0A0E0B0E0E80EF91E0A1F1B1FD9 | ||||
| :10E5F000E0928C01F0928D0100938E0110938F01B7 | ||||
| :10E6000004C08B3111F08FE387DD83E08093E90054 | ||||
| :10E610009091E8008091E8008E778093E80095FF64 | ||||
| :10E6200004C010C08EB38823C9F08091E80080FF39 | ||||
| :10E63000F9CF8091E8008E778093E80003C08EB315 | ||||
| :10E64000882361F08091E80080FFF9CF84E0809317 | ||||
| :10E65000E9008091E8008B778093E800DF91CF910B | ||||
| :10E660001F910F91FF90EF90DF90CF90BF90AF90F0 | ||||
| :10E670009F908F907F906F905F904F9008959091B2 | ||||
| :10E680009201892F8F77813249F5809193018032F1 | ||||
| :10E69000A1F0813219F5913A09F58091E800877F60 | ||||
| :10E6A0008093E80089E091E067E070E031D28091EA | ||||
| :10E6B000E8008B778093E8000895913279F4809197 | ||||
| :10E6C000E800877F8093E80089E091E067E070E0F0 | ||||
| :10E6D0007BD28091E8008E778093E800089582E0F5 | ||||
| :10E6E00061EC42E0D4D083E061E842E1D0D084E044 | ||||
| :10E6F00060E842E1CCC01F9384B7877F84BF88E184 | ||||
| :10E700000FB6F89480936000109260000FBE90E006 | ||||
| :10E7100080E80FB6F89480936100909361000FBE7B | ||||
| :10E7200011E015BF82E085BF28D110936F0083E010 | ||||
| :10E73000809381001F910895DF93CF9300D0CDB7D0 | ||||
| :10E74000DEB78091E0FF9091E1FF9A838983898110 | ||||
| :10E750009A81D1DF789402C0F7DC84D380910801DC | ||||
| :10E760008823D1F78091E00081608093E0002CE065 | ||||
| :10E7700088E190E00FB6F894A895809360000FBEF2 | ||||
| :10E7800020936000FFCF9B01AC0107B600FCFDCFDA | ||||
| :10E79000F999FECF83E0F90140935B008093570025 | ||||
| :10E7A000E89581E180935700E89508959B01AC01BD | ||||
| :10E7B00007B600FCFDCFF999FECF85E0F901409343 | ||||
| :10E7C0005B0080935700E89581E180935700E895BE | ||||
| :10E7D00008950F931F938B019C0107B600FCFDCF9A | ||||
| :10E7E000F999FECF81E00A01F80120935B00809344 | ||||
| :10E7F0005700E89511241F910F91089521E2FC0123 | ||||
| :10E80000209357002491822F089529E0FC01209342 | ||||
| :10E8100057002491822F0895E1E0F0E089E0809391 | ||||
| :10E82000570084910895982F07B600FCFDCFF99901 | ||||
| :10E83000FECF909589E0E1E0F0E0092E809357004B | ||||
| :10E84000E8950895FA01923071F0933089F0913093 | ||||
| :10E8500029F480E191E022E130E015C080E090E011 | ||||
| :10E8600020E030E010C082E291E02EE330E00BC007 | ||||
| :10E87000882329F480E691E024E030E004C084E6B7 | ||||
| :10E8800091E026E230E091838083C901089580936E | ||||
| :10E89000E9008091EB0081608093EB001092ED0025 | ||||
| :10E8A0006093EC004093ED008091EE00881F882774 | ||||
| :10E8B000881F08958091920188238CF403C08EB341 | ||||
| :10E8C0008823B1F08091E80082FFF9CF8091E800C1 | ||||
| :10E8D0008B778093E80008958EB3882349F0809168 | ||||
| :10E8E000E80080FFF9CF8091E8008E778093E80000 | ||||
| :10E8F0000895EF92FF920F931F9348D04FD008EDE9 | ||||
| :10E9000010E0F80180818F77808380818068808328 | ||||
| :10E9100080818F7D8083E7EDF0E080818068808357 | ||||
| :10E9200019BC1EBA1092900180EEE82EF12CF7016E | ||||
| :10E9300080818B7F8083F80180818160808380E08B | ||||
| :10E9400060E042E0A4DFE1EEF0E080818E7F808332 | ||||
| :10E95000E2EEF0E080818160808380818860808346 | ||||
| :10E96000F70180818E7F8083F801808180618083C0 | ||||
| :10E970001F910F91FF90EF900895E7EDF0E08081F7 | ||||
| :10E980008160808381E080939101B3CFE8EDF0E076 | ||||
| :10E9900080818C7F80831092E20008951092DA00CB | ||||
| :10E9A0001092E10008951F920F920FB60F920BB6CE | ||||
| :10E9B0000F9211242F933F934F935F936F937F9305 | ||||
| :10E9C0008F939F93AF93BF93EF93FF938091DA0060 | ||||
| :10E9D00080FF1BC08091D80080FF17C08091DA00B3 | ||||
| :10E9E0008E7F8093DA008091D90080FF0BC084E194 | ||||
| :10E9F00089BD86E189BD09B400FEFDCF81E08EBBF3 | ||||
| :10EA000030D203C019BC1EBA2CD28091E10080FF25 | ||||
| :10EA100017C08091E20080FF13C08091E2008E7FDA | ||||
| :10EA20008093E2008091E20080618093E200809117 | ||||
| :10EA3000D80080628093D80019BC85E08EBB11D2CB | ||||
| :10EA40008091E10084FF2CC08091E20084FF28C007 | ||||
| :10EA500084E189BD86E189BD09B400FEFDCF8091C6 | ||||
| :10EA6000D8008F7D8093D8008091E1008F7E8093C5 | ||||
| :10EA7000E1008091E2008F7E8093E2008091E200CD | ||||
| :10EA800081608093E20080919001882331F480912D | ||||
| :10EA9000E30087FD02C081E001C084E08EBBE1D1CC | ||||
| :10EAA0008091E10083FF21C08091E20083FF1DC0BF | ||||
| :10EAB0008091E100877F8093E10082E08EBB10921D | ||||
| :10EAC00090018091E1008E7F8093E1008091E200CF | ||||
| :10EAD0008E7F8093E2008091E20080618093E2006B | ||||
| :10EAE00080E060E042E0D3DEBCD1FF91EF91BF91C6 | ||||
| :10EAF000AF919F918F917F916F915F914F913F91D6 | ||||
| :10EB00002F910F900BBE0F900FBE0F901F90189576 | ||||
| :10EB10009C0140919801509199014617570718F4AC | ||||
| :10EB2000F90190E03CC06115710511F0AB01F8CF1F | ||||
| :10EB30008091E8008E778093E80040E050E0F0CFCD | ||||
| :10EB40008EB38823E9F18530E9F18091E80083FFF5 | ||||
| :10EB500002C081E008958091E80082FD2BC0809181 | ||||
| :10EB6000E80080FF1CC02091F2003091F30007C044 | ||||
| :10EB700081918093F100415050402F5F3F4F4115EC | ||||
| :10EB8000510519F02830310598F390E0283031050F | ||||
| :10EB900009F491E08091E8008E778093E8004115B8 | ||||
| :10EBA000510571F6992361F605C08EB3882341F0B3 | ||||
| :10EBB000853041F08091E80082FFF7CF80E0089532 | ||||
| :10EBC00082E0089583E008959C016115710529F4A0 | ||||
| :10EBD0008091E8008B778093E800F90121C08EB323 | ||||
| :10EBE000882369F1853069F18091E80083FF02C0D4 | ||||
| :10EBF00081E008958091E80082FFF1CF06C0809106 | ||||
| :10EC0000F10081936150704031F08091F200909159 | ||||
| :10EC1000F300892BA1F78091E8008B778093E800BF | ||||
| :10EC200061157105E1F605C08EB3882341F085308A | ||||
| :10EC300041F08091E80080FFF7CF80E0089582E006 | ||||
| :10EC4000089583E008950F931F93DF93CF9300D02F | ||||
| :10EC5000CDB7DEB7E2E9F1E08091F100819381E088 | ||||
| :10EC6000EA39F807C9F70BDD8091E80083FFE4C0BB | ||||
| :10EC70008091920190919301953009F46DC0963086 | ||||
| :10EC800040F4913081F1913070F0933009F0D4C0AC | ||||
| :10EC90002AC0983009F4A3C0993009F4B2C0963064 | ||||
| :10ECA00009F0CAC07CC0803809F4C6C0823809F0B7 | ||||
| :10ECB000C3C08091960187708093E9008091EB003A | ||||
| :10ECC0001092E9002091E800277F2093E80090E06F | ||||
| :10ECD00025E0969587952A95E1F781708093F1005C | ||||
| :10ECE0001092F10087C0882319F0823009F0A4C087 | ||||
| :10ECF0008F71823009F0A0C080919401882331F592 | ||||
| :10ED000020919601277009F497C02093E900809123 | ||||
| :10ED1000EB0080FF1BC0933021F48091EB008062F8 | ||||
| :10ED200013C08091EB0080618093EB0081E090E064 | ||||
| :10ED300002C0880F991F2A95E2F78093EA0010928B | ||||
| :10ED4000EA008091EB0088608093EB001092E9006C | ||||
| :10ED50008091E800877F51C0882309F06DC0109131 | ||||
| :10ED600094011F770FB7F8948091E800877F809314 | ||||
| :10ED7000E800A0DD8091E80080FFFCCF8091E300F7 | ||||
| :10ED80008078812B8093E30080688093E3001123D7 | ||||
| :10ED900011F482E001C083E08EBB0FBF4DC08058EC | ||||
| :10EDA000823008F049C08091940190919501609162 | ||||
| :10EDB0009601AE014F5F5F4F45DDBC01009709F43E | ||||
| :10EDC0003BC08091E800877F8093E80089819A8129 | ||||
| :10EDD0009FDE8091E8008B778093E8002DC080381B | ||||
| :10EDE00059F58091E800877F8093E8008091900139 | ||||
| :10EDF0008093F1008091E8008E778093E8005ADDDF | ||||
| :10EE00001BC08823C9F4909194019230A8F480919A | ||||
| :10EE1000E800877F8093E800909390014BDD80911C | ||||
| :10EE20009001882331F48091E30087FD02C081E0E6 | ||||
| :10EE300001C084E08EBB53DC8091E80083FF0AC0F0 | ||||
| :10EE40008091EB0080628093EB008091E800877FE7 | ||||
| :10EE50008093E8000F900F90CF91DF911F910F9159 | ||||
| :10EE6000089508951F938EB3882361F01091E900EF | ||||
| :10EE70001092E9008091E80083FF01C0E4DE177082 | ||||
| :10EE80001093E9001F910895F999FECF92BD81BDBD | ||||
| :10EE9000F89A992780B50895262FF999FECF1FBAC1 | ||||
| :10EEA00092BD81BD20BD0FB6F894FA9AF99A0FBEB3 | ||||
| :08EEB00001960895F894FFCFCC | ||||
| :10EEB8004C5546414344430001000000000000084F | ||||
| :10EEC8001201100102000008EB034A2001000001B2 | ||||
| :10EED800000109023E00020100803209040000011D | ||||
| :10EEE800020201000524001001042402040524067E | ||||
| :10EEF8000001070582030800FF09040100020A0057 | ||||
| :10EF08000000070504021000010705830210000134 | ||||
| :10EF18000403090426034100560052002000430060 | ||||
| :10EF280044004300200042006F006F0074006C0032 | ||||
| :0CEF38006F0061006400650072000000C2 | ||||
| :10FFE0000C94C3F30C94D6F30C94E9F30C94FEF345 | ||||
| :0CFFF0000C9405F40C940CF40C9413F425 | ||||
| :040000031000E00009 | ||||
| :00000001FF | ||||
| @@ -1 +1 @@ | ||||
| <AVRStudio><MANAGEMENT><ProjectName>BootloaderCDC</ProjectName><Created>13-Jul-2010 14:41:25</Created><LastEdit>13-Jul-2010 14:42:12</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 14:41:25</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>BootloaderCDC.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM></COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>BootloaderCDC.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>BootloaderCDC.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>BootloaderCDC.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><ProjectFiles><Files><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\BootloaderCDC.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\Descriptors.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\BootloaderCDC.c</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\Descriptors.c</Name></Files></ProjectFiles><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
| <AVRStudio><MANAGEMENT><ProjectName>BootloaderCDC</ProjectName><Created>13-Jul-2010 14:41:25</Created><LastEdit>13-Jul-2010 14:42:12</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 14:41:25</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>BootloaderCDC.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM></COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>BootloaderCDC.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>BootloaderCDC.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>BootloaderCDC.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><ProjectFiles><Files><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\BootloaderCDC.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\Descriptors.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\BootloaderCDC.c</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\Descriptors.c</Name></Files></ProjectFiles><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,89 +1,89 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for BootloaderCDC.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _CDC_H_ | ||||
| #define _CDC_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/boot.h> | ||||
| 		#include <avr/eeprom.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <stdbool.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
| 		#include "BootloaderAPI.h"		 | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Version major of the CDC bootloader. */ | ||||
| 		#define BOOTLOADER_VERSION_MAJOR     0x01 | ||||
|  | ||||
| 		/** Version minor of the CDC bootloader. */ | ||||
| 		#define BOOTLOADER_VERSION_MINOR     0x00 | ||||
|  | ||||
| 		/** Hardware version major of the CDC bootloader. */ | ||||
| 		#define BOOTLOADER_HWVERSION_MAJOR   0x01 | ||||
|  | ||||
| 		/** Hardware version minor of the CDC bootloader. */ | ||||
| 		#define BOOTLOADER_HWVERSION_MINOR   0x00 | ||||
|  | ||||
| 		/** Eight character bootloader firmware identifier reported to the host when requested */ | ||||
| 		#define SOFTWARE_IDENTIFIER          "LUFACDC" | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for a non-returning pointer to the start of the loaded application in flash memory. */ | ||||
| 		typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void CDC_Task(void); | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
|  | ||||
| 		#if defined(INCLUDE_FROM_BOOTLOADERCDC_C) || defined(__DOXYGEN__) | ||||
| 			#if !defined(NO_BLOCK_SUPPORT) | ||||
| 			static void    ReadWriteMemoryBlock(const uint8_t Command); | ||||
| 			#endif | ||||
| 			static uint8_t FetchNextCommandByte(void); | ||||
| 			static void    WriteNextResponseByte(const uint8_t Response); | ||||
| 		#endif | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for BootloaderCDC.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _CDC_H_ | ||||
| #define _CDC_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/boot.h> | ||||
| 		#include <avr/eeprom.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <stdbool.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
| 		#include "BootloaderAPI.h"		 | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Version major of the CDC bootloader. */ | ||||
| 		#define BOOTLOADER_VERSION_MAJOR     0x01 | ||||
|  | ||||
| 		/** Version minor of the CDC bootloader. */ | ||||
| 		#define BOOTLOADER_VERSION_MINOR     0x00 | ||||
|  | ||||
| 		/** Hardware version major of the CDC bootloader. */ | ||||
| 		#define BOOTLOADER_HWVERSION_MAJOR   0x01 | ||||
|  | ||||
| 		/** Hardware version minor of the CDC bootloader. */ | ||||
| 		#define BOOTLOADER_HWVERSION_MINOR   0x00 | ||||
|  | ||||
| 		/** Eight character bootloader firmware identifier reported to the host when requested */ | ||||
| 		#define SOFTWARE_IDENTIFIER          "LUFACDC" | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for a non-returning pointer to the start of the loaded application in flash memory. */ | ||||
| 		typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void CDC_Task(void); | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
|  | ||||
| 		#if defined(INCLUDE_FROM_BOOTLOADERCDC_C) || defined(__DOXYGEN__) | ||||
| 			#if !defined(NO_BLOCK_SUPPORT) | ||||
| 			static void    ReadWriteMemoryBlock(const uint8_t Command); | ||||
| 			#endif | ||||
| 			static uint8_t FetchNextCommandByte(void); | ||||
| 			static void    WriteNextResponseByte(const uint8_t Response); | ||||
| 		#endif | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,138 +1,138 @@ | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage CDC Class USB AVR Bootloader | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  *  - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Communications Device Class (CDC)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>Abstract Control Model (ACM)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF CDC Class Standard</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  This bootloader enumerates to the host as a CDC Class device (virtual serial port), allowing for AVR109 | ||||
|  *  protocol compatible programming software to load firmware onto the AVR. | ||||
|  * | ||||
|  *  Out of the box this bootloader builds for the USB1287, and will fit into 4KB of bootloader space. If | ||||
|  *  you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU | ||||
|  *  values in the accompanying makefile. | ||||
|  * | ||||
|  *  When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the | ||||
|  *  bootloader from the normal user application. | ||||
|  * | ||||
|  *  \section Sec_Installation Driver Installation | ||||
|  * | ||||
|  *  After running this bootloader for the first time on a new computer, you will need to supply the .INF | ||||
|  *  file located in this bootloader project's directory as the device's driver when running under Windows. | ||||
|  *  This will enable Windows to use its inbuilt CDC drivers, negating the need for custom drivers for the | ||||
|  *  device. Other Operating Systems should automatically use their own inbuilt CDC-ACM drivers. | ||||
|  * | ||||
|  *  \section Sec_HostApp Host Controller Application | ||||
|  * | ||||
|  *  This bootloader is compatible with the open source application AVRDUDE, Atmel's AVRPROG, or other | ||||
|  *  applications implementing the AVR109 protocol, which is documented on the Atmel website as an application | ||||
|  *  note. | ||||
|  * | ||||
|  *  \subsection SSec_AVRDude AVRDUDE (Windows, Mac, Linux) | ||||
|  * | ||||
|  *  AVRDude is a free, cross-platform and open source command line programmer for Atmel and third party AVR | ||||
|  *  programmers. It is available on the the Windows platform as part of the "WinAVR" package, or on other systems | ||||
|  *  either from a build from the official source code, or in many distributions as a precompiled binary package. | ||||
|  * | ||||
|  *  To load a new HEX file with AVRDude, specify "AVR109" as the programmer, with the allocated COM port. On Windows | ||||
|  *  platforms this will be a COMx port name: | ||||
|  *  \code | ||||
|  *  avrdude -c AVR109 -p at90usb1287 -P COM0 -U flash:w:Mouse.hex | ||||
|  *  \endcode | ||||
|  * | ||||
|  *  On Linux systems, this will typically be a /dev/ttyACMx port name: | ||||
|  *  \code | ||||
|  *  avrdude -c AVR109 -p at90usb1287 -P /dev/ttyACM0 -U flash:w:Mouse.hex | ||||
|  *  \endcode | ||||
|  * | ||||
|  *  Refer to the AVRDude project documentation for additional usage instructions. | ||||
|  * | ||||
|  *  \section Sec_API User Application API | ||||
|  * | ||||
|  *  Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader, | ||||
|  *  allowing the user application to call into the bootloader at runtime to read and write FLASH data. | ||||
|  * | ||||
|  *  By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the | ||||
|  *  following layout: | ||||
|  * | ||||
|  *  \code | ||||
|  *  #define BOOTLOADER_API_START(Index)        (void*)(((FLASHEND - 32) + (2 * Index)) / 2) | ||||
|  *  void    (*BootloaderAPI_ErasePage)(uint32_t Address)               = BOOTLOADER_API_START(0); | ||||
|  *  void    (*BootloaderAPI_WritePage)(uint32_t Address)               = BOOTLOADER_API_START(1); | ||||
|  *  void    (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_START(2); | ||||
|  *  uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address)           = BOOTLOADER_API_START(3); | ||||
|  *  uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address)                = BOOTLOADER_API_START(4); | ||||
|  *  uint8_t (*BootloaderAPI_ReadLock)(void)                            = BOOTLOADER_API_START(5); | ||||
|  *  void    (*BootloaderAPI_WriteLock)(uint8_t LockBits)               = BOOTLOADER_API_START(6); | ||||
|  *  \endcode | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td>NO_BLOCK_SUPPORT</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>Define to disable memory block read/write support in the bootloader, requiring all reads and writes to be made | ||||
|  *        using the byte-level commands.</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>NO_EEPROM_BYTE_SUPPORT</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>Define to disable EEPROM memory byte read/write support in the bootloader, requiring all EEPROM reads and writes | ||||
|  *        to be made using the block-level commands.</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>NO_FLASH_BYTE_SUPPORT</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>Define to disable FLASH memory byte read/write support in the bootloader, requiring all FLASH reads and writes | ||||
|  *        to be made using the block-level commands.</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>NO_LOCK_BYTE_WRITE_SUPPORT</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>Define to disable lock byte write support in the bootloader, preventing the lock bits from being set programmatically.</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage CDC Class USB AVR Bootloader | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  *  - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Communications Device Class (CDC)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>Abstract Control Model (ACM)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF CDC Class Standard</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  This bootloader enumerates to the host as a CDC Class device (virtual serial port), allowing for AVR109 | ||||
|  *  protocol compatible programming software to load firmware onto the AVR. | ||||
|  * | ||||
|  *  Out of the box this bootloader builds for the USB1287, and will fit into 4KB of bootloader space. If | ||||
|  *  you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU | ||||
|  *  values in the accompanying makefile. | ||||
|  * | ||||
|  *  When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the | ||||
|  *  bootloader from the normal user application. | ||||
|  * | ||||
|  *  \section Sec_Installation Driver Installation | ||||
|  * | ||||
|  *  After running this bootloader for the first time on a new computer, you will need to supply the .INF | ||||
|  *  file located in this bootloader project's directory as the device's driver when running under Windows. | ||||
|  *  This will enable Windows to use its inbuilt CDC drivers, negating the need for custom drivers for the | ||||
|  *  device. Other Operating Systems should automatically use their own inbuilt CDC-ACM drivers. | ||||
|  * | ||||
|  *  \section Sec_HostApp Host Controller Application | ||||
|  * | ||||
|  *  This bootloader is compatible with the open source application AVRDUDE, Atmel's AVRPROG, or other | ||||
|  *  applications implementing the AVR109 protocol, which is documented on the Atmel website as an application | ||||
|  *  note. | ||||
|  * | ||||
|  *  \subsection SSec_AVRDude AVRDUDE (Windows, Mac, Linux) | ||||
|  * | ||||
|  *  AVRDude is a free, cross-platform and open source command line programmer for Atmel and third party AVR | ||||
|  *  programmers. It is available on the the Windows platform as part of the "WinAVR" package, or on other systems | ||||
|  *  either from a build from the official source code, or in many distributions as a precompiled binary package. | ||||
|  * | ||||
|  *  To load a new HEX file with AVRDude, specify "AVR109" as the programmer, with the allocated COM port. On Windows | ||||
|  *  platforms this will be a COMx port name: | ||||
|  *  \code | ||||
|  *  avrdude -c AVR109 -p at90usb1287 -P COM0 -U flash:w:Mouse.hex | ||||
|  *  \endcode | ||||
|  * | ||||
|  *  On Linux systems, this will typically be a /dev/ttyACMx port name: | ||||
|  *  \code | ||||
|  *  avrdude -c AVR109 -p at90usb1287 -P /dev/ttyACM0 -U flash:w:Mouse.hex | ||||
|  *  \endcode | ||||
|  * | ||||
|  *  Refer to the AVRDude project documentation for additional usage instructions. | ||||
|  * | ||||
|  *  \section Sec_API User Application API | ||||
|  * | ||||
|  *  Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader, | ||||
|  *  allowing the user application to call into the bootloader at runtime to read and write FLASH data. | ||||
|  * | ||||
|  *  By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the | ||||
|  *  following layout: | ||||
|  * | ||||
|  *  \code | ||||
|  *  #define BOOTLOADER_API_START(Index)        (void*)(((FLASHEND - 32) + (2 * Index)) / 2) | ||||
|  *  void    (*BootloaderAPI_ErasePage)(uint32_t Address)               = BOOTLOADER_API_START(0); | ||||
|  *  void    (*BootloaderAPI_WritePage)(uint32_t Address)               = BOOTLOADER_API_START(1); | ||||
|  *  void    (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_START(2); | ||||
|  *  uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address)           = BOOTLOADER_API_START(3); | ||||
|  *  uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address)                = BOOTLOADER_API_START(4); | ||||
|  *  uint8_t (*BootloaderAPI_ReadLock)(void)                            = BOOTLOADER_API_START(5); | ||||
|  *  void    (*BootloaderAPI_WriteLock)(uint8_t LockBits)               = BOOTLOADER_API_START(6); | ||||
|  *  \endcode | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td>NO_BLOCK_SUPPORT</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>Define to disable memory block read/write support in the bootloader, requiring all reads and writes to be made | ||||
|  *        using the byte-level commands.</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>NO_EEPROM_BYTE_SUPPORT</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>Define to disable EEPROM memory byte read/write support in the bootloader, requiring all EEPROM reads and writes | ||||
|  *        to be made using the block-level commands.</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>NO_FLASH_BYTE_SUPPORT</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>Define to disable FLASH memory byte read/write support in the bootloader, requiring all FLASH reads and writes | ||||
|  *        to be made using the block-level commands.</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>NO_LOCK_BYTE_WRITE_SUPPORT</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>Define to disable lock byte write support in the bootloader, preventing the lock bits from being set programmatically.</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
|   | ||||
| @@ -1,243 +1,243 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = CDC_CSCP_CDCClass, | ||||
| 	.SubClass               = CDC_CSCP_NoSpecificSubclass, | ||||
| 	.Protocol               = CDC_CSCP_NoSpecificProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x204A, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = NO_DESCRIPTOR, | ||||
| 	.ProductStrIndex        = 0x01, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in SRAM memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 2, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = USB_CONFIG_ATTR_BUSPOWERED, | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_CCI_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0, | ||||
| 			.AlternateSetting       = 0, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCClass, | ||||
| 			.SubClass               = CDC_CSCP_ACMSubclass, | ||||
| 			.Protocol               = CDC_CSCP_ATCommandProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_Functional_Header = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = 0x00, | ||||
|  | ||||
| 			.CDCSpecification       = VERSION_BCD(01.10), | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_Functional_ACM = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = 0x02, | ||||
|  | ||||
| 			.Capabilities           = 0x04, | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_Functional_Union = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = 0x06, | ||||
|  | ||||
| 			.MasterInterfaceNumber  = 0, | ||||
| 			.SlaveInterfaceNumber   = 1, | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_NotificationEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_NOTIFICATION_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0xFF | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_DCI_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 1, | ||||
| 			.AlternateSetting       = 0, | ||||
|  | ||||
| 			.TotalEndpoints         = 2, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCDataClass, | ||||
| 			.SubClass               = CDC_CSCP_NoDataSubclass, | ||||
| 			.Protocol               = CDC_CSCP_NoDataProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_DataOutEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_OUT | CDC_RX_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_TXRX_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_DataInEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | CDC_TX_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_TXRX_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		} | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in SRAM memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(22), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"AVR CDC API Bootloader" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see LUFA library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			if (!(DescriptorNumber)) | ||||
| 			{ | ||||
| 				Address = &LanguageString; | ||||
| 				Size    = LanguageString.Header.Size; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				Address = &ProductString; | ||||
| 				Size    = ProductString.Header.Size; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = CDC_CSCP_CDCClass, | ||||
| 	.SubClass               = CDC_CSCP_NoSpecificSubclass, | ||||
| 	.Protocol               = CDC_CSCP_NoSpecificProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x204A, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = NO_DESCRIPTOR, | ||||
| 	.ProductStrIndex        = 0x01, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in SRAM memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 2, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = USB_CONFIG_ATTR_BUSPOWERED, | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_CCI_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0, | ||||
| 			.AlternateSetting       = 0, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCClass, | ||||
| 			.SubClass               = CDC_CSCP_ACMSubclass, | ||||
| 			.Protocol               = CDC_CSCP_ATCommandProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_Functional_Header = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = 0x00, | ||||
|  | ||||
| 			.CDCSpecification       = VERSION_BCD(01.10), | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_Functional_ACM = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = 0x02, | ||||
|  | ||||
| 			.Capabilities           = 0x04, | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_Functional_Union = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = 0x06, | ||||
|  | ||||
| 			.MasterInterfaceNumber  = 0, | ||||
| 			.SlaveInterfaceNumber   = 1, | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_NotificationEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | CDC_NOTIFICATION_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_NOTIFICATION_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0xFF | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_DCI_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 1, | ||||
| 			.AlternateSetting       = 0, | ||||
|  | ||||
| 			.TotalEndpoints         = 2, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCDataClass, | ||||
| 			.SubClass               = CDC_CSCP_NoDataSubclass, | ||||
| 			.Protocol               = CDC_CSCP_NoDataProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_DataOutEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_OUT | CDC_RX_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_TXRX_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
|  | ||||
| 	.CDC_DataInEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | CDC_TX_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_TXRX_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		} | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in SRAM memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"AVR CDC Bootloader" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see LUFA library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			if (!(DescriptorNumber)) | ||||
| 			{ | ||||
| 				Address = &LanguageString; | ||||
| 				Size    = LanguageString.Header.Size; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				Address = &ProductString; | ||||
| 				Size    = ProductString.Header.Size; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,139 +1,139 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		#if defined(__AVR_AT90USB1287__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x97 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_AT90USB647__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x96 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_AT90USB1286__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x97 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_AT90USB646__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x96 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_ATmega32U6__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x95 | ||||
| 			#define AVR_SIGNATURE_3               0x88 | ||||
| 		#elif defined(__AVR_ATmega32U4__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x95 | ||||
| 			#define AVR_SIGNATURE_3               0x87 | ||||
| 		#elif defined(__AVR_ATmega16U4__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x88 | ||||
| 		#elif defined(__AVR_ATmega32U2__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x95 | ||||
| 			#define AVR_SIGNATURE_3               0x8A | ||||
| 		#elif defined(__AVR_ATmega16U2__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x89 | ||||
| 		#elif defined(__AVR_AT90USB162__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_ATmega8U2__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x93 | ||||
| 			#define AVR_SIGNATURE_3               0x89 | ||||
| 		#elif defined(__AVR_AT90USB82__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#else | ||||
| 			#error The selected AVR part is not currently supported by this bootloader. | ||||
| 		#endif | ||||
|  | ||||
| 		/** Endpoint number for the CDC control interface event notification endpoint. */ | ||||
| 		#define CDC_NOTIFICATION_EPNUM         2 | ||||
|  | ||||
| 		/** Endpoint number for the CDC data interface TX (data IN) endpoint. */ | ||||
| 		#define CDC_TX_EPNUM                   3 | ||||
|  | ||||
| 		/** Endpoint number for the CDC data interface RX (data OUT) endpoint. */ | ||||
| 		#define CDC_RX_EPNUM                   4 | ||||
|  | ||||
| 		/** Size of the CDC data interface TX and RX data endpoint banks, in bytes. */ | ||||
| 		#define CDC_TXRX_EPSIZE                16 | ||||
|  | ||||
| 		/** Size of the CDC control interface notification endpoint bank, in bytes. */ | ||||
| 		#define CDC_NOTIFICATION_EPSIZE        8 | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t    Config; | ||||
| 			 | ||||
| 			// CDC Control Interface | ||||
| 			USB_Descriptor_Interface_t               CDC_CCI_Interface; | ||||
| 			USB_CDC_Descriptor_FunctionalHeader_t    CDC_Functional_Header; | ||||
| 			USB_CDC_Descriptor_FunctionalACM_t       CDC_Functional_ACM; | ||||
| 			USB_CDC_Descriptor_FunctionalUnion_t     CDC_Functional_Union; | ||||
| 			USB_Descriptor_Endpoint_t                CDC_NotificationEndpoint; | ||||
| 			 | ||||
| 			// CDC Data Interface | ||||
| 			USB_Descriptor_Interface_t               CDC_DCI_Interface; | ||||
| 			USB_Descriptor_Endpoint_t                CDC_DataOutEndpoint; | ||||
| 			USB_Descriptor_Endpoint_t                CDC_DataInEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		#if defined(__AVR_AT90USB1287__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x97 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_AT90USB647__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x96 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_AT90USB1286__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x97 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_AT90USB646__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x96 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_ATmega32U6__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x95 | ||||
| 			#define AVR_SIGNATURE_3               0x88 | ||||
| 		#elif defined(__AVR_ATmega32U4__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x95 | ||||
| 			#define AVR_SIGNATURE_3               0x87 | ||||
| 		#elif defined(__AVR_ATmega16U4__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x88 | ||||
| 		#elif defined(__AVR_ATmega32U2__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x95 | ||||
| 			#define AVR_SIGNATURE_3               0x8A | ||||
| 		#elif defined(__AVR_ATmega16U2__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x89 | ||||
| 		#elif defined(__AVR_AT90USB162__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_ATmega8U2__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x93 | ||||
| 			#define AVR_SIGNATURE_3               0x89 | ||||
| 		#elif defined(__AVR_AT90USB82__) | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#else | ||||
| 			#error The selected AVR part is not currently supported by this bootloader. | ||||
| 		#endif | ||||
|  | ||||
| 		/** Endpoint number for the CDC control interface event notification endpoint. */ | ||||
| 		#define CDC_NOTIFICATION_EPNUM         2 | ||||
|  | ||||
| 		/** Endpoint number for the CDC data interface TX (data IN) endpoint. */ | ||||
| 		#define CDC_TX_EPNUM                   3 | ||||
|  | ||||
| 		/** Endpoint number for the CDC data interface RX (data OUT) endpoint. */ | ||||
| 		#define CDC_RX_EPNUM                   4 | ||||
|  | ||||
| 		/** Size of the CDC data interface TX and RX data endpoint banks, in bytes. */ | ||||
| 		#define CDC_TXRX_EPSIZE                16 | ||||
|  | ||||
| 		/** Size of the CDC control interface notification endpoint bank, in bytes. */ | ||||
| 		#define CDC_NOTIFICATION_EPSIZE        8 | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t    Config; | ||||
| 			 | ||||
| 			// CDC Control Interface | ||||
| 			USB_Descriptor_Interface_t               CDC_CCI_Interface; | ||||
| 			USB_CDC_Descriptor_FunctionalHeader_t    CDC_Functional_Header; | ||||
| 			USB_CDC_Descriptor_FunctionalACM_t       CDC_Functional_ACM; | ||||
| 			USB_CDC_Descriptor_FunctionalUnion_t     CDC_Functional_Union; | ||||
| 			USB_Descriptor_Endpoint_t                CDC_NotificationEndpoint; | ||||
| 			 | ||||
| 			// CDC Data Interface | ||||
| 			USB_Descriptor_Interface_t               CDC_DCI_Interface; | ||||
| 			USB_Descriptor_Endpoint_t                CDC_DataOutEndpoint; | ||||
| 			USB_Descriptor_Endpoint_t                CDC_DataInEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,106 +1,106 @@ | ||||
| ;************************************************************ | ||||
| ; Windows USB CDC ACM Setup File | ||||
| ; Copyright (c) 2000 Microsoft Corporation | ||||
|  | ||||
|  | ||||
| [Version] | ||||
| Signature="$Windows NT$" | ||||
| Class=Ports | ||||
| ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} | ||||
| Provider=%MFGNAME% | ||||
| LayoutFile=layout.inf | ||||
| CatalogFile=%MFGFILENAME%.cat | ||||
| DriverVer=11/15/2007,5.1.2600.0 | ||||
|  | ||||
| [Manufacturer] | ||||
| %MFGNAME%=DeviceList, NTamd64 | ||||
|  | ||||
| [DestinationDirs] | ||||
| DefaultDestDir=12 | ||||
|  | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  Windows 2000/XP/Vista-32bit Sections | ||||
| ;------------------------------------------------------------------------------ | ||||
|  | ||||
| [DriverInstall.nt] | ||||
| include=mdmcpq.inf | ||||
| CopyFiles=DriverCopyFiles.nt | ||||
| AddReg=DriverInstall.nt.AddReg | ||||
|  | ||||
| [DriverCopyFiles.nt] | ||||
| usbser.sys,,,0x20 | ||||
|  | ||||
| [DriverInstall.nt.AddReg] | ||||
| HKR,,DevLoader,,*ntkern | ||||
| HKR,,NTMPDriver,,%DRIVERFILENAME%.sys | ||||
| HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" | ||||
|  | ||||
| [DriverInstall.nt.Services] | ||||
| AddService=usbser, 0x00000002, DriverService.nt | ||||
|  | ||||
| [DriverService.nt] | ||||
| DisplayName=%SERVICE% | ||||
| ServiceType=1 | ||||
| StartType=3 | ||||
| ErrorControl=1 | ||||
| ServiceBinary=%12%\%DRIVERFILENAME%.sys | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  Vista-64bit Sections | ||||
| ;------------------------------------------------------------------------------ | ||||
|  | ||||
| [DriverInstall.NTamd64] | ||||
| include=mdmcpq.inf | ||||
| CopyFiles=DriverCopyFiles.NTamd64 | ||||
| AddReg=DriverInstall.NTamd64.AddReg | ||||
|  | ||||
| [DriverCopyFiles.NTamd64] | ||||
| %DRIVERFILENAME%.sys,,,0x20 | ||||
|  | ||||
| [DriverInstall.NTamd64.AddReg] | ||||
| HKR,,DevLoader,,*ntkern | ||||
| HKR,,NTMPDriver,,%DRIVERFILENAME%.sys | ||||
| HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" | ||||
|  | ||||
| [DriverInstall.NTamd64.Services] | ||||
| AddService=usbser, 0x00000002, DriverService.NTamd64 | ||||
|  | ||||
| [DriverService.NTamd64] | ||||
| DisplayName=%SERVICE% | ||||
| ServiceType=1 | ||||
| StartType=3 | ||||
| ErrorControl=1 | ||||
| ServiceBinary=%12%\%DRIVERFILENAME%.sys | ||||
|  | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  Vendor and Product ID Definitions | ||||
| ;------------------------------------------------------------------------------ | ||||
| ; When developing your USB device, the VID and PID used in the PC side | ||||
| ; application program and the firmware on the microcontroller must match. | ||||
| ; Modify the below line to use your VID and PID.  Use the format as shown below. | ||||
| ; Note: One INF file can be used for multiple devices with different VID and PIDs. | ||||
| ; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line. | ||||
| ;------------------------------------------------------------------------------ | ||||
| [SourceDisksFiles] | ||||
| [SourceDisksNames] | ||||
| [DeviceList] | ||||
| %DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A | ||||
|  | ||||
| [DeviceList.NTamd64] | ||||
| %DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A | ||||
|  | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  String Definitions | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;Modify these strings to customize your device | ||||
| ;------------------------------------------------------------------------------ | ||||
| [Strings] | ||||
| MFGFILENAME="CDC_vista" | ||||
| DRIVERFILENAME ="usbser" | ||||
| MFGNAME="http://www.lufa-lib.org" | ||||
| INSTDISK="LUFA CDC Bootloader Driver Installer" | ||||
| DESCRIPTION="Communications Port" | ||||
| ;************************************************************ | ||||
| ; Windows USB CDC ACM Setup File | ||||
| ; Copyright (c) 2000 Microsoft Corporation | ||||
|  | ||||
|  | ||||
| [Version] | ||||
| Signature="$Windows NT$" | ||||
| Class=Ports | ||||
| ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} | ||||
| Provider=%MFGNAME% | ||||
| LayoutFile=layout.inf | ||||
| CatalogFile=%MFGFILENAME%.cat | ||||
| DriverVer=11/15/2007,5.1.2600.0 | ||||
|  | ||||
| [Manufacturer] | ||||
| %MFGNAME%=DeviceList, NTamd64 | ||||
|  | ||||
| [DestinationDirs] | ||||
| DefaultDestDir=12 | ||||
|  | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  Windows 2000/XP/Vista-32bit Sections | ||||
| ;------------------------------------------------------------------------------ | ||||
|  | ||||
| [DriverInstall.nt] | ||||
| include=mdmcpq.inf | ||||
| CopyFiles=DriverCopyFiles.nt | ||||
| AddReg=DriverInstall.nt.AddReg | ||||
|  | ||||
| [DriverCopyFiles.nt] | ||||
| usbser.sys,,,0x20 | ||||
|  | ||||
| [DriverInstall.nt.AddReg] | ||||
| HKR,,DevLoader,,*ntkern | ||||
| HKR,,NTMPDriver,,%DRIVERFILENAME%.sys | ||||
| HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" | ||||
|  | ||||
| [DriverInstall.nt.Services] | ||||
| AddService=usbser, 0x00000002, DriverService.nt | ||||
|  | ||||
| [DriverService.nt] | ||||
| DisplayName=%SERVICE% | ||||
| ServiceType=1 | ||||
| StartType=3 | ||||
| ErrorControl=1 | ||||
| ServiceBinary=%12%\%DRIVERFILENAME%.sys | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  Vista-64bit Sections | ||||
| ;------------------------------------------------------------------------------ | ||||
|  | ||||
| [DriverInstall.NTamd64] | ||||
| include=mdmcpq.inf | ||||
| CopyFiles=DriverCopyFiles.NTamd64 | ||||
| AddReg=DriverInstall.NTamd64.AddReg | ||||
|  | ||||
| [DriverCopyFiles.NTamd64] | ||||
| %DRIVERFILENAME%.sys,,,0x20 | ||||
|  | ||||
| [DriverInstall.NTamd64.AddReg] | ||||
| HKR,,DevLoader,,*ntkern | ||||
| HKR,,NTMPDriver,,%DRIVERFILENAME%.sys | ||||
| HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" | ||||
|  | ||||
| [DriverInstall.NTamd64.Services] | ||||
| AddService=usbser, 0x00000002, DriverService.NTamd64 | ||||
|  | ||||
| [DriverService.NTamd64] | ||||
| DisplayName=%SERVICE% | ||||
| ServiceType=1 | ||||
| StartType=3 | ||||
| ErrorControl=1 | ||||
| ServiceBinary=%12%\%DRIVERFILENAME%.sys | ||||
|  | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  Vendor and Product ID Definitions | ||||
| ;------------------------------------------------------------------------------ | ||||
| ; When developing your USB device, the VID and PID used in the PC side | ||||
| ; application program and the firmware on the microcontroller must match. | ||||
| ; Modify the below line to use your VID and PID.  Use the format as shown below. | ||||
| ; Note: One INF file can be used for multiple devices with different VID and PIDs. | ||||
| ; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line. | ||||
| ;------------------------------------------------------------------------------ | ||||
| [SourceDisksFiles] | ||||
| [SourceDisksNames] | ||||
| [DeviceList] | ||||
| %DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A | ||||
|  | ||||
| [DeviceList.NTamd64] | ||||
| %DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204A | ||||
|  | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  String Definitions | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;Modify these strings to customize your device | ||||
| ;------------------------------------------------------------------------------ | ||||
| [Strings] | ||||
| MFGFILENAME="CDC_vista" | ||||
| DRIVERFILENAME ="usbser" | ||||
| MFGNAME="http://www.lufa-lib.org" | ||||
| INSTDISK="LUFA CDC Bootloader Driver Installer" | ||||
| DESCRIPTION="Communications Port" | ||||
| SERVICE="USB RS-232 Emulation Driver" | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,74 +1,74 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Bootloader user application API functions. | ||||
|  */ | ||||
|  | ||||
| #include "BootloaderAPI.h" | ||||
|  | ||||
| void BootloaderAPI_ErasePage(uint32_t Address) | ||||
| { | ||||
| 	boot_page_erase_safe(Address); | ||||
| 	boot_rww_enable(); | ||||
| } | ||||
|  | ||||
| void BootloaderAPI_WritePage(uint32_t Address) | ||||
| { | ||||
| 	boot_page_write_safe(Address); | ||||
| 	boot_rww_enable(); | ||||
| } | ||||
|  | ||||
| void BootloaderAPI_FillWord(uint32_t Address, uint16_t Word) | ||||
| { | ||||
| 	boot_page_fill_safe(Address, Word); | ||||
| } | ||||
|  | ||||
| uint8_t BootloaderAPI_ReadSignature(uint16_t Address) | ||||
| { | ||||
| 	return boot_signature_byte_get(Address); | ||||
| } | ||||
|  | ||||
| uint8_t BootloaderAPI_ReadFuse(uint16_t Address) | ||||
| { | ||||
| 	return boot_lock_fuse_bits_get(Address); | ||||
| } | ||||
|  | ||||
| uint8_t BootloaderAPI_ReadLock(void) | ||||
| { | ||||
| 	return boot_lock_fuse_bits_get(GET_LOCK_BITS); | ||||
| } | ||||
|  | ||||
| void BootloaderAPI_WriteLock(uint8_t LockBits) | ||||
| { | ||||
| 	boot_lock_bits_set_safe(LockBits); | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Bootloader user application API functions. | ||||
|  */ | ||||
|  | ||||
| #include "BootloaderAPI.h" | ||||
|  | ||||
| void BootloaderAPI_ErasePage(uint32_t Address) | ||||
| { | ||||
| 	boot_page_erase_safe(Address); | ||||
| 	boot_rww_enable(); | ||||
| } | ||||
|  | ||||
| void BootloaderAPI_WritePage(uint32_t Address) | ||||
| { | ||||
| 	boot_page_write_safe(Address); | ||||
| 	boot_rww_enable(); | ||||
| } | ||||
|  | ||||
| void BootloaderAPI_FillWord(uint32_t Address, uint16_t Word) | ||||
| { | ||||
| 	boot_page_fill_safe(Address, Word); | ||||
| } | ||||
|  | ||||
| uint8_t BootloaderAPI_ReadSignature(uint16_t Address) | ||||
| { | ||||
| 	return boot_signature_byte_get(Address); | ||||
| } | ||||
|  | ||||
| uint8_t BootloaderAPI_ReadFuse(uint16_t Address) | ||||
| { | ||||
| 	return boot_lock_fuse_bits_get(Address); | ||||
| } | ||||
|  | ||||
| uint8_t BootloaderAPI_ReadLock(void) | ||||
| { | ||||
| 	return boot_lock_fuse_bits_get(GET_LOCK_BITS); | ||||
| } | ||||
|  | ||||
| void BootloaderAPI_WriteLock(uint8_t LockBits) | ||||
| { | ||||
| 	boot_lock_bits_set_safe(LockBits); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,59 +1,56 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for BootloaderAPI.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _BOOTLOADER_API_H_ | ||||
| #define _BOOTLOADER_API_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/boot.h> | ||||
| 		#include <stdbool.h> | ||||
| 		 | ||||
| 		#include <LUFA/Common/Common.h> | ||||
| 	 | ||||
| 	/* External Variables: */ | ||||
| 		extern uint8_t* BootloaderAPI_JumpTable; | ||||
| 	 | ||||
| 	/* Function Prototypes: */ | ||||
| 		void    BootloaderAPI_ErasePage(uint32_t Address); | ||||
| 		void    BootloaderAPI_WritePage(uint32_t Address); | ||||
| 		void    BootloaderAPI_FillWord(uint32_t Address, uint16_t Word); | ||||
| 		uint8_t BootloaderAPI_ReadSignature(uint16_t Address); | ||||
| 		uint8_t BootloaderAPI_ReadFuse(uint16_t Address); | ||||
| 		uint8_t BootloaderAPI_ReadLock(void); | ||||
| 		void    BootloaderAPI_WriteLock(uint8_t LockBits); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for BootloaderAPI.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _BOOTLOADER_API_H_ | ||||
| #define _BOOTLOADER_API_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/boot.h> | ||||
| 		#include <stdbool.h> | ||||
| 		 | ||||
| 		#include <LUFA/Common/Common.h> | ||||
| 	 | ||||
| 	/* Function Prototypes: */ | ||||
| 		void    BootloaderAPI_ErasePage(uint32_t Address); | ||||
| 		void    BootloaderAPI_WritePage(uint32_t Address); | ||||
| 		void    BootloaderAPI_FillWord(uint32_t Address, uint16_t Word); | ||||
| 		uint8_t BootloaderAPI_ReadSignature(uint16_t Address); | ||||
| 		uint8_t BootloaderAPI_ReadFuse(uint16_t Address); | ||||
| 		uint8_t BootloaderAPI_ReadLock(void); | ||||
| 		void    BootloaderAPI_WriteLock(uint8_t LockBits); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,43 +1,43 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| ; Bootloader API Jump Table | ||||
| .section .apitable, "ax" | ||||
| .org 0 | ||||
|  | ||||
| .global BootloaderAPI_JumpTable | ||||
| BootloaderAPI_JumpTable: | ||||
| 	jmp BootloaderAPI_ErasePage | ||||
| 	jmp BootloaderAPI_WritePage | ||||
| 	jmp BootloaderAPI_FillWord | ||||
| 	jmp BootloaderAPI_ReadSignature | ||||
| 	jmp BootloaderAPI_ReadFuse | ||||
| 	jmp BootloaderAPI_ReadLock | ||||
| 	jmp BootloaderAPI_WriteLock | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| ; Bootloader API Jump Table | ||||
| .section .apitable, "ax" | ||||
| .org 0 | ||||
|  | ||||
| .global BootloaderAPI_JumpTable | ||||
| BootloaderAPI_JumpTable: | ||||
| 	jmp BootloaderAPI_ErasePage | ||||
| 	jmp BootloaderAPI_WritePage | ||||
| 	jmp BootloaderAPI_FillWord | ||||
| 	jmp BootloaderAPI_ReadSignature | ||||
| 	jmp BootloaderAPI_ReadFuse | ||||
| 	jmp BootloaderAPI_ReadLock | ||||
| 	jmp BootloaderAPI_WriteLock | ||||
|   | ||||
| @@ -1 +1 @@ | ||||
| <AVRStudio><MANAGEMENT><ProjectName>BootloaderDFU</ProjectName><Created>13-Jul-2010 14:42:28</Created><LastEdit>13-Jul-2010 14:46:54</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 14:42:28</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>BootloaderDFU.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\DFU\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM></COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>BootloaderDFU.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>BootloaderDFU.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>BootloaderDFU.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
| <AVRStudio><MANAGEMENT><ProjectName>BootloaderDFU</ProjectName><Created>13-Jul-2010 14:42:28</Created><LastEdit>13-Jul-2010 14:46:54</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 14:42:28</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>BootloaderDFU.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\DFU\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM></COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>BootloaderDFU.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>BootloaderDFU.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>BootloaderDFU.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,211 +1,211 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for BootloaderDFU.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _BOOTLOADER_H_ | ||||
| #define _BOOTLOADER_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/boot.h> | ||||
| 		#include <avr/pgmspace.h> | ||||
| 		#include <avr/eeprom.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <util/delay.h> | ||||
| 		#include <stdbool.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
| 		#include "BootloaderAPI.h" | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Configuration define. Define this token to true to case the bootloader to reject all memory commands | ||||
| 		 *  until a memory erase has been performed. When used in conjunction with the lockbits of the AVR, this | ||||
| 		 *  can protect the AVR's firmware from being dumped from a secured AVR. When false, memory operations are | ||||
| 		 *  allowed at any time. | ||||
| 		 */ | ||||
| 		#define SECURE_MODE              false | ||||
|  | ||||
| 		/** Major bootloader version number. */ | ||||
| 		#define BOOTLOADER_VERSION_MINOR 2 | ||||
|  | ||||
| 		/** Minor bootloader version number. */ | ||||
| 		#define BOOTLOADER_VERSION_REV   0 | ||||
|  | ||||
| 		/** Complete bootloader version number expressed as a packed byte, constructed from the | ||||
| 		 *  two individual bootloader version macros. | ||||
| 		 */ | ||||
| 		#define BOOTLOADER_VERSION       ((BOOTLOADER_VERSION_MINOR << 4) | BOOTLOADER_VERSION_REV) | ||||
|  | ||||
| 		/** First byte of the bootloader identification bytes, used to identify a device's bootloader. */ | ||||
| 		#define BOOTLOADER_ID_BYTE1      0xDC | ||||
|  | ||||
| 		/** Second byte of the bootloader identification bytes, used to identify a device's bootloader. */ | ||||
| 		#define BOOTLOADER_ID_BYTE2      0xFB | ||||
|  | ||||
| 		/** Convenience macro, used to determine if the issued command is the given one-byte long command. | ||||
| 		 * | ||||
| 		 *  \param[in] dataarr  Command byte array to check against | ||||
| 		 *  \param[in] cb1      First command byte to check | ||||
| 		 */ | ||||
| 		#define IS_ONEBYTE_COMMAND(dataarr, cb1)       (dataarr[0] == (cb1)) | ||||
|  | ||||
| 		/** Convenience macro, used to determine if the issued command is the given two-byte long command. | ||||
| 		 * | ||||
| 		 *  \param[in] dataarr  Command byte array to check against | ||||
| 		 *  \param[in] cb1      First command byte to check | ||||
| 		 *  \param[in] cb2      Second command byte to check | ||||
| 		 */ | ||||
| 		#define IS_TWOBYTE_COMMAND(dataarr, cb1, cb2) ((dataarr[0] == (cb1)) && (dataarr[1] == (cb2))) | ||||
|  | ||||
| 		/** Length of the DFU file suffix block, appended to the end of each complete memory write command. | ||||
| 		 *  The DFU file suffix is currently unused (but is designed to give extra file information, such as | ||||
| 		 *  a CRC of the complete firmware for error checking) and so is discarded. | ||||
| 		 */ | ||||
| 		#define DFU_FILE_SUFFIX_SIZE     16 | ||||
|  | ||||
| 		/** Length of the DFU file filler block, appended to the start of each complete memory write command. | ||||
| 		 *  Filler bytes are added to the start of each complete memory write command, and must be discarded. | ||||
| 		 */ | ||||
| 		#define DFU_FILLER_BYTES_SIZE    26 | ||||
|  | ||||
| 		/** DFU class command request to detach from the host. */ | ||||
| 		#define DFU_REQ_DETATCH          0x00 | ||||
|  | ||||
| 		/** DFU class command request to send data from the host to the bootloader. */ | ||||
| 		#define DFU_REQ_DNLOAD           0x01 | ||||
|  | ||||
| 		/** DFU class command request to send data from the bootloader to the host. */ | ||||
| 		#define DFU_REQ_UPLOAD           0x02 | ||||
|  | ||||
| 		/** DFU class command request to get the current DFU status and state from the bootloader. */ | ||||
| 		#define DFU_REQ_GETSTATUS        0x03 | ||||
|  | ||||
| 		/** DFU class command request to reset the current DFU status and state variables to their defaults. */ | ||||
| 		#define DFU_REQ_CLRSTATUS        0x04 | ||||
|  | ||||
| 		/** DFU class command request to get the current DFU state of the bootloader. */ | ||||
| 		#define DFU_REQ_GETSTATE         0x05 | ||||
|  | ||||
| 		/** DFU class command request to abort the current multi-request transfer and return to the dfuIDLE state. */ | ||||
| 		#define DFU_REQ_ABORT            0x06 | ||||
|  | ||||
| 		/** DFU command to begin programming the device's memory. */ | ||||
| 		#define COMMAND_PROG_START       0x01 | ||||
|  | ||||
| 		/** DFU command to begin reading the device's memory. */ | ||||
| 		#define COMMAND_DISP_DATA        0x03 | ||||
|  | ||||
| 		/** DFU command to issue a write command. */ | ||||
| 		#define COMMAND_WRITE            0x04 | ||||
|  | ||||
| 		/** DFU command to issue a read command. */ | ||||
| 		#define COMMAND_READ             0x05 | ||||
|  | ||||
| 		/** DFU command to issue a memory base address change command, to set the current 64KB flash page | ||||
| 		 *  that subsequent flash operations should use. */ | ||||
| 		#define COMMAND_CHANGE_BASE_ADDR 0x06 | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for a non-returning function pointer to the loaded application. */ | ||||
| 		typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; | ||||
|  | ||||
| 		/** Type define for a structure containing a complete DFU command issued by the host. */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			uint8_t  Command; /**< Single byte command to perform, one of the COMMAND_* macro values */ | ||||
| 			uint8_t  Data[5]; /**< Command parameters */ | ||||
| 			uint16_t DataSize; /**< Size of the command parameters */ | ||||
| 		} DFU_Command_t; | ||||
|  | ||||
| 	/* Enums: */ | ||||
| 		/** DFU bootloader states. Refer to the DFU class specification for information on each state. */ | ||||
| 		enum DFU_State_t | ||||
| 		{ | ||||
| 			appIDLE                      = 0, | ||||
| 			appDETACH                    = 1, | ||||
| 			dfuIDLE                      = 2, | ||||
| 			dfuDNLOAD_SYNC               = 3, | ||||
| 			dfuDNBUSY                    = 4, | ||||
| 			dfuDNLOAD_IDLE               = 5, | ||||
| 			dfuMANIFEST_SYNC             = 6, | ||||
| 			dfuMANIFEST                  = 7, | ||||
| 			dfuMANIFEST_WAIT_RESET       = 8, | ||||
| 			dfuUPLOAD_IDLE               = 9, | ||||
| 			dfuERROR	                 = 10 | ||||
| 		}; | ||||
|  | ||||
| 		/** DFU command status error codes. Refer to the DFU class specification for information on each error code. */ | ||||
| 		enum DFU_Status_t | ||||
| 		{ | ||||
| 			OK                           = 0, | ||||
| 			errTARGET                    = 1, | ||||
| 			errFILE                      = 2, | ||||
| 			errWRITE                     = 3, | ||||
| 			errERASE                     = 4, | ||||
| 			errCHECK_ERASED              = 5, | ||||
| 			errPROG                      = 6, | ||||
| 			errVERIFY                    = 7, | ||||
| 			errADDRESS                   = 8, | ||||
| 			errNOTDONE                   = 9, | ||||
| 			errFIRMWARE                  = 10, | ||||
| 			errVENDOR                    = 11, | ||||
| 			errUSBR                      = 12, | ||||
| 			errPOR                       = 13, | ||||
| 			errUNKNOWN                   = 14, | ||||
| 			errSTALLEDPKT	             = 15 | ||||
| 		}; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
| 		void ResetHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
|  | ||||
| 		#if defined(INCLUDE_FROM_BOOTLOADER_C) | ||||
| 			static void DiscardFillerBytes(uint8_t NumberOfBytes); | ||||
| 			static void ProcessBootloaderCommand(void); | ||||
| 			static void LoadStartEndAddresses(void); | ||||
| 			static void ProcessMemProgCommand(void); | ||||
| 			static void ProcessMemReadCommand(void); | ||||
| 			static void ProcessWriteCommand(void); | ||||
| 			static void ProcessReadCommand(void); | ||||
| 		#endif | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for BootloaderDFU.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _BOOTLOADER_H_ | ||||
| #define _BOOTLOADER_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/boot.h> | ||||
| 		#include <avr/pgmspace.h> | ||||
| 		#include <avr/eeprom.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <util/delay.h> | ||||
| 		#include <stdbool.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
| 		#include "BootloaderAPI.h" | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Configuration define. Define this token to true to case the bootloader to reject all memory commands | ||||
| 		 *  until a memory erase has been performed. When used in conjunction with the lockbits of the AVR, this | ||||
| 		 *  can protect the AVR's firmware from being dumped from a secured AVR. When false, memory operations are | ||||
| 		 *  allowed at any time. | ||||
| 		 */ | ||||
| 		#define SECURE_MODE              false | ||||
|  | ||||
| 		/** Major bootloader version number. */ | ||||
| 		#define BOOTLOADER_VERSION_MINOR 2 | ||||
|  | ||||
| 		/** Minor bootloader version number. */ | ||||
| 		#define BOOTLOADER_VERSION_REV   0 | ||||
|  | ||||
| 		/** Complete bootloader version number expressed as a packed byte, constructed from the | ||||
| 		 *  two individual bootloader version macros. | ||||
| 		 */ | ||||
| 		#define BOOTLOADER_VERSION       ((BOOTLOADER_VERSION_MINOR << 4) | BOOTLOADER_VERSION_REV) | ||||
|  | ||||
| 		/** First byte of the bootloader identification bytes, used to identify a device's bootloader. */ | ||||
| 		#define BOOTLOADER_ID_BYTE1      0xDC | ||||
|  | ||||
| 		/** Second byte of the bootloader identification bytes, used to identify a device's bootloader. */ | ||||
| 		#define BOOTLOADER_ID_BYTE2      0xFB | ||||
|  | ||||
| 		/** Convenience macro, used to determine if the issued command is the given one-byte long command. | ||||
| 		 * | ||||
| 		 *  \param[in] dataarr  Command byte array to check against | ||||
| 		 *  \param[in] cb1      First command byte to check | ||||
| 		 */ | ||||
| 		#define IS_ONEBYTE_COMMAND(dataarr, cb1)       (dataarr[0] == (cb1)) | ||||
|  | ||||
| 		/** Convenience macro, used to determine if the issued command is the given two-byte long command. | ||||
| 		 * | ||||
| 		 *  \param[in] dataarr  Command byte array to check against | ||||
| 		 *  \param[in] cb1      First command byte to check | ||||
| 		 *  \param[in] cb2      Second command byte to check | ||||
| 		 */ | ||||
| 		#define IS_TWOBYTE_COMMAND(dataarr, cb1, cb2) ((dataarr[0] == (cb1)) && (dataarr[1] == (cb2))) | ||||
|  | ||||
| 		/** Length of the DFU file suffix block, appended to the end of each complete memory write command. | ||||
| 		 *  The DFU file suffix is currently unused (but is designed to give extra file information, such as | ||||
| 		 *  a CRC of the complete firmware for error checking) and so is discarded. | ||||
| 		 */ | ||||
| 		#define DFU_FILE_SUFFIX_SIZE     16 | ||||
|  | ||||
| 		/** Length of the DFU file filler block, appended to the start of each complete memory write command. | ||||
| 		 *  Filler bytes are added to the start of each complete memory write command, and must be discarded. | ||||
| 		 */ | ||||
| 		#define DFU_FILLER_BYTES_SIZE    26 | ||||
|  | ||||
| 		/** DFU class command request to detach from the host. */ | ||||
| 		#define DFU_REQ_DETATCH          0x00 | ||||
|  | ||||
| 		/** DFU class command request to send data from the host to the bootloader. */ | ||||
| 		#define DFU_REQ_DNLOAD           0x01 | ||||
|  | ||||
| 		/** DFU class command request to send data from the bootloader to the host. */ | ||||
| 		#define DFU_REQ_UPLOAD           0x02 | ||||
|  | ||||
| 		/** DFU class command request to get the current DFU status and state from the bootloader. */ | ||||
| 		#define DFU_REQ_GETSTATUS        0x03 | ||||
|  | ||||
| 		/** DFU class command request to reset the current DFU status and state variables to their defaults. */ | ||||
| 		#define DFU_REQ_CLRSTATUS        0x04 | ||||
|  | ||||
| 		/** DFU class command request to get the current DFU state of the bootloader. */ | ||||
| 		#define DFU_REQ_GETSTATE         0x05 | ||||
|  | ||||
| 		/** DFU class command request to abort the current multi-request transfer and return to the dfuIDLE state. */ | ||||
| 		#define DFU_REQ_ABORT            0x06 | ||||
|  | ||||
| 		/** DFU command to begin programming the device's memory. */ | ||||
| 		#define COMMAND_PROG_START       0x01 | ||||
|  | ||||
| 		/** DFU command to begin reading the device's memory. */ | ||||
| 		#define COMMAND_DISP_DATA        0x03 | ||||
|  | ||||
| 		/** DFU command to issue a write command. */ | ||||
| 		#define COMMAND_WRITE            0x04 | ||||
|  | ||||
| 		/** DFU command to issue a read command. */ | ||||
| 		#define COMMAND_READ             0x05 | ||||
|  | ||||
| 		/** DFU command to issue a memory base address change command, to set the current 64KB flash page | ||||
| 		 *  that subsequent flash operations should use. */ | ||||
| 		#define COMMAND_CHANGE_BASE_ADDR 0x06 | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for a non-returning function pointer to the loaded application. */ | ||||
| 		typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; | ||||
|  | ||||
| 		/** Type define for a structure containing a complete DFU command issued by the host. */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			uint8_t  Command; /**< Single byte command to perform, one of the COMMAND_* macro values */ | ||||
| 			uint8_t  Data[5]; /**< Command parameters */ | ||||
| 			uint16_t DataSize; /**< Size of the command parameters */ | ||||
| 		} DFU_Command_t; | ||||
|  | ||||
| 	/* Enums: */ | ||||
| 		/** DFU bootloader states. Refer to the DFU class specification for information on each state. */ | ||||
| 		enum DFU_State_t | ||||
| 		{ | ||||
| 			appIDLE                      = 0, | ||||
| 			appDETACH                    = 1, | ||||
| 			dfuIDLE                      = 2, | ||||
| 			dfuDNLOAD_SYNC               = 3, | ||||
| 			dfuDNBUSY                    = 4, | ||||
| 			dfuDNLOAD_IDLE               = 5, | ||||
| 			dfuMANIFEST_SYNC             = 6, | ||||
| 			dfuMANIFEST                  = 7, | ||||
| 			dfuMANIFEST_WAIT_RESET       = 8, | ||||
| 			dfuUPLOAD_IDLE               = 9, | ||||
| 			dfuERROR	                 = 10 | ||||
| 		}; | ||||
|  | ||||
| 		/** DFU command status error codes. Refer to the DFU class specification for information on each error code. */ | ||||
| 		enum DFU_Status_t | ||||
| 		{ | ||||
| 			OK                           = 0, | ||||
| 			errTARGET                    = 1, | ||||
| 			errFILE                      = 2, | ||||
| 			errWRITE                     = 3, | ||||
| 			errERASE                     = 4, | ||||
| 			errCHECK_ERASED              = 5, | ||||
| 			errPROG                      = 6, | ||||
| 			errVERIFY                    = 7, | ||||
| 			errADDRESS                   = 8, | ||||
| 			errNOTDONE                   = 9, | ||||
| 			errFIRMWARE                  = 10, | ||||
| 			errVENDOR                    = 11, | ||||
| 			errUSBR                      = 12, | ||||
| 			errPOR                       = 13, | ||||
| 			errUNKNOWN                   = 14, | ||||
| 			errSTALLEDPKT	             = 15 | ||||
| 		}; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
| 		void ResetHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
|  | ||||
| 		#if defined(INCLUDE_FROM_BOOTLOADER_C) | ||||
| 			static void DiscardFillerBytes(uint8_t NumberOfBytes); | ||||
| 			static void ProcessBootloaderCommand(void); | ||||
| 			static void LoadStartEndAddresses(void); | ||||
| 			static void ProcessMemProgCommand(void); | ||||
| 			static void ProcessMemReadCommand(void); | ||||
| 			static void ProcessWriteCommand(void); | ||||
| 			static void ProcessReadCommand(void); | ||||
| 		#endif | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,132 +1,132 @@ | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage DFU Class USB AVR Bootloader | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  *  - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  * <table> | ||||
|  *  <tr> | ||||
|  *   <td><b>USB Mode:</b></td> | ||||
|  *   <td>Device</td> | ||||
|  *  </tr> | ||||
|  *  <tr> | ||||
|  *   <td><b>USB Class:</b></td> | ||||
|  *   <td>Device Firmware Update Class (DFU)</td> | ||||
|  *  </tr> | ||||
|  *  <tr> | ||||
|  *   <td><b>USB Subclass:</b></td> | ||||
|  *   <td>None</td> | ||||
|  *  </tr> | ||||
|  *  <tr> | ||||
|  *   <td><b>Relevant Standards:</b></td> | ||||
|  *   <td>USBIF DFU Class Standard, Atmel USB Bootloader Datasheet</td> | ||||
|  *  </tr> | ||||
|  *  <tr> | ||||
|  *   <td><b>Usable Speeds:</b></td> | ||||
|  *   <td>Full Speed Mode</td> | ||||
|  *  </tr> | ||||
|  * </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  This bootloader enumerates to the host as a DFU Class device, allowing for DFU-compatible programming | ||||
|  *  software to load firmware onto the AVR. | ||||
|  * | ||||
|  *  Out of the box this bootloader builds for the USB1287, and should fit into 4KB of bootloader space. If | ||||
|  *  you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU | ||||
|  *  values in the accompanying makefile. | ||||
|  * | ||||
|  *  When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the | ||||
|  *  bootloader from the normal user application. | ||||
|  * | ||||
|  *  \section Sec_Installation Driver Installation | ||||
|  * | ||||
|  *  This bootloader is designed to be compatible with Atmel's provided Windows DFU class drivers. You will need to | ||||
|  *  install Atmel's DFU drivers prior to using this bootloader on Windows platforms. If you are using a 64 bit Windows | ||||
|  *  OS, you will need to either disable the driver signing requirement (see online tutorials for details) or use a | ||||
|  *  digitally signed version of the official Atmel driver provided by a third party AVR user at | ||||
|  *  <a>http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_id=2196&item_type=project</a>. | ||||
|  * | ||||
|  *  \note This device spoofs Atmel's DFU Bootloader USB VID and PID so that the Atmel DFU bootloader | ||||
|  *        drivers included with FLIP will work. If you do not wish to use Atmel's ID codes, please | ||||
|  *        manually change them in Descriptors.c and alter your driver's INF file accordingly. | ||||
|  * | ||||
|  *  \section Sec_HostApp Host Controller Application | ||||
|  *   | ||||
|  *  This bootloader is compatible with Atmel's FLIP utility on Windows machines, and dfu-programmer on Linux machines. | ||||
|  * | ||||
|  *  \subsection SSec_FLIP FLIP (Windows) | ||||
|  * | ||||
|  *  FLIP (Flexible In-System Programmer) is a utility written by Atmel, and distributed for free on the Atmel website. | ||||
|  *  The FLIP utility is designed to assist in the bootloader programming of a range of Atmel devices, through several | ||||
|  *  popular physical interfaces including USB. It is written in Java, however makes use of native extensions for USB | ||||
|  *  support and thus is only offered on Windows. | ||||
|  * | ||||
|  *  To program a device using FLIP, refer to the Atmel FLIP documentation. | ||||
|  * | ||||
|  *  \subsection SSec_DFUProgrammer dfu-programmer (Linux) | ||||
|  * | ||||
|  *  dfu-programmer is an open-source command line solution for the bootloader programming of Atmel devices through a | ||||
|  *  USB connection, using the DFU protocol, available for download at <a>http://sourceforge.net/projects/dfu-programmer/</a>. | ||||
|  * | ||||
|  *  The following example loads a HEX file into the AVR's FLASH memory using dfu-programmer: | ||||
|  *  \code | ||||
|  *  dfu-programmer at90usb1287 erase flash Mouse.hex | ||||
|  *  \endcode | ||||
|  * | ||||
|  *  \section Sec_API User Application API | ||||
|  * | ||||
|  *  Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader, | ||||
|  *  allowing the user application to call into the bootloader at runtime to read and write FLASH data. | ||||
|  * | ||||
|  *  \note The APIs exposed by the DFU class bootloader are \b NOT compatible with the API exposed by the official Atmel DFU bootloader. | ||||
|  * | ||||
|  *  By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the | ||||
|  *  following layout: | ||||
|  * | ||||
|  *  \code | ||||
|  *  #define BOOTLOADER_API_START(Index)        (void*)(((FLASHEND - 32) + (2 * Index)) / 2) | ||||
|  *  void    (*BootloaderAPI_ErasePage)(uint32_t Address)               = BOOTLOADER_API_START(0); | ||||
|  *  void    (*BootloaderAPI_WritePage)(uint32_t Address)               = BOOTLOADER_API_START(1); | ||||
|  *  void    (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_START(2); | ||||
|  *  uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address)           = BOOTLOADER_API_START(3); | ||||
|  *  uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address)                = BOOTLOADER_API_START(4); | ||||
|  *  uint8_t (*BootloaderAPI_ReadLock)(void)                            = BOOTLOADER_API_START(5); | ||||
|  *  void    (*BootloaderAPI_WriteLock)(uint8_t LockBits)               = BOOTLOADER_API_START(6); | ||||
|  *  \endcode | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>Define Name:</b></td> | ||||
|  *    <td><b>Location:</b></td> | ||||
|  *    <td><b>Description:</b></td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>SECURE_MODE</td> | ||||
|  *    <td>BootloaderDFU.h</td> | ||||
|  *    <td>If defined to true, the bootloader will not accept any memory commands other than a chip erase on start-up, until an | ||||
|  *        erase has been performed. This can be used in conjunction with the AVR's lockbits to prevent the AVRs firmware from | ||||
|  *        being dumped by unauthorized persons.</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage DFU Class USB AVR Bootloader | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  *  - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  * <table> | ||||
|  *  <tr> | ||||
|  *   <td><b>USB Mode:</b></td> | ||||
|  *   <td>Device</td> | ||||
|  *  </tr> | ||||
|  *  <tr> | ||||
|  *   <td><b>USB Class:</b></td> | ||||
|  *   <td>Device Firmware Update Class (DFU)</td> | ||||
|  *  </tr> | ||||
|  *  <tr> | ||||
|  *   <td><b>USB Subclass:</b></td> | ||||
|  *   <td>None</td> | ||||
|  *  </tr> | ||||
|  *  <tr> | ||||
|  *   <td><b>Relevant Standards:</b></td> | ||||
|  *   <td>USBIF DFU Class Standard, Atmel USB Bootloader Datasheet</td> | ||||
|  *  </tr> | ||||
|  *  <tr> | ||||
|  *   <td><b>Usable Speeds:</b></td> | ||||
|  *   <td>Full Speed Mode</td> | ||||
|  *  </tr> | ||||
|  * </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  This bootloader enumerates to the host as a DFU Class device, allowing for DFU-compatible programming | ||||
|  *  software to load firmware onto the AVR. | ||||
|  * | ||||
|  *  Out of the box this bootloader builds for the USB1287, and should fit into 4KB of bootloader space. If | ||||
|  *  you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU | ||||
|  *  values in the accompanying makefile. | ||||
|  * | ||||
|  *  When the bootloader is running, the board's LED(s) will flash at regular intervals to distinguish the | ||||
|  *  bootloader from the normal user application. | ||||
|  * | ||||
|  *  \section Sec_Installation Driver Installation | ||||
|  * | ||||
|  *  This bootloader is designed to be compatible with Atmel's provided Windows DFU class drivers. You will need to | ||||
|  *  install Atmel's DFU drivers prior to using this bootloader on Windows platforms. If you are using a 64 bit Windows | ||||
|  *  OS, you will need to either disable the driver signing requirement (see online tutorials for details) or use a | ||||
|  *  digitally signed version of the official Atmel driver provided by a third party AVR user at | ||||
|  *  <a>http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_id=2196&item_type=project</a>. | ||||
|  * | ||||
|  *  \note This device spoofs Atmel's DFU Bootloader USB VID and PID so that the Atmel DFU bootloader | ||||
|  *        drivers included with FLIP will work. If you do not wish to use Atmel's ID codes, please | ||||
|  *        manually change them in Descriptors.c and alter your driver's INF file accordingly. | ||||
|  * | ||||
|  *  \section Sec_HostApp Host Controller Application | ||||
|  *   | ||||
|  *  This bootloader is compatible with Atmel's FLIP utility on Windows machines, and dfu-programmer on Linux machines. | ||||
|  * | ||||
|  *  \subsection SSec_FLIP FLIP (Windows) | ||||
|  * | ||||
|  *  FLIP (Flexible In-System Programmer) is a utility written by Atmel, and distributed for free on the Atmel website. | ||||
|  *  The FLIP utility is designed to assist in the bootloader programming of a range of Atmel devices, through several | ||||
|  *  popular physical interfaces including USB. It is written in Java, however makes use of native extensions for USB | ||||
|  *  support and thus is only offered on Windows. | ||||
|  * | ||||
|  *  To program a device using FLIP, refer to the Atmel FLIP documentation. | ||||
|  * | ||||
|  *  \subsection SSec_DFUProgrammer dfu-programmer (Linux) | ||||
|  * | ||||
|  *  dfu-programmer is an open-source command line solution for the bootloader programming of Atmel devices through a | ||||
|  *  USB connection, using the DFU protocol, available for download at <a>http://sourceforge.net/projects/dfu-programmer/</a>. | ||||
|  * | ||||
|  *  The following example loads a HEX file into the AVR's FLASH memory using dfu-programmer: | ||||
|  *  \code | ||||
|  *  dfu-programmer at90usb1287 erase flash Mouse.hex | ||||
|  *  \endcode | ||||
|  * | ||||
|  *  \section Sec_API User Application API | ||||
|  * | ||||
|  *  Several user application functions for FLASH and other special memory area manipulations are exposed by the bootloader, | ||||
|  *  allowing the user application to call into the bootloader at runtime to read and write FLASH data. | ||||
|  * | ||||
|  *  \note The APIs exposed by the DFU class bootloader are \b NOT compatible with the API exposed by the official Atmel DFU bootloader. | ||||
|  * | ||||
|  *  By default, the bootloader API jump table is located 32 bytes from the end of the device's FLASH memory, and follows the | ||||
|  *  following layout: | ||||
|  * | ||||
|  *  \code | ||||
|  *  #define BOOTLOADER_API_START(Index)        (void*)(((FLASHEND - 32) + (2 * Index)) / 2) | ||||
|  *  void    (*BootloaderAPI_ErasePage)(uint32_t Address)               = BOOTLOADER_API_START(0); | ||||
|  *  void    (*BootloaderAPI_WritePage)(uint32_t Address)               = BOOTLOADER_API_START(1); | ||||
|  *  void    (*BootloaderAPI_FillWord)(uint32_t Address, uint16_t Word) = BOOTLOADER_API_START(2); | ||||
|  *  uint8_t (*BootloaderAPI_ReadSignature)(uint16_t Address)           = BOOTLOADER_API_START(3); | ||||
|  *  uint8_t (*BootloaderAPI_ReadFuse)(uint16_t Address)                = BOOTLOADER_API_START(4); | ||||
|  *  uint8_t (*BootloaderAPI_ReadLock)(void)                            = BOOTLOADER_API_START(5); | ||||
|  *  void    (*BootloaderAPI_WriteLock)(uint8_t LockBits)               = BOOTLOADER_API_START(6); | ||||
|  *  \endcode | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>Define Name:</b></td> | ||||
|  *    <td><b>Location:</b></td> | ||||
|  *    <td><b>Description:</b></td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>SECURE_MODE</td> | ||||
|  *    <td>BootloaderDFU.h</td> | ||||
|  *    <td>If defined to true, the bootloader will not accept any memory commands other than a chip erase on start-up, until an | ||||
|  *        erase has been performed. This can be used in conjunction with the AVR's lockbits to prevent the AVRs firmware from | ||||
|  *        being dumped by unauthorized persons.</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
|   | ||||
| @@ -1,184 +1,184 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = PRODUCT_ID_CODE, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.00), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = NO_DESCRIPTOR, | ||||
| 	.ProductStrIndex        = 0x01, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in SRAM memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 1, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = USB_CONFIG_ATTR_BUSPOWERED, | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.DFU_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0, | ||||
| 			.AlternateSetting       = 0, | ||||
|  | ||||
| 			.TotalEndpoints         = 0, | ||||
|  | ||||
| 			.Class                  = 0xFE, | ||||
| 			.SubClass               = 0x01, | ||||
| 			.Protocol               = 0x02, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.DFU_Functional = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_DFU_Functional_t), .Type = DTYPE_DFUFunctional}, | ||||
|  | ||||
| 			.Attributes             = (ATTR_CAN_UPLOAD | ATTR_CAN_DOWNLOAD), | ||||
|  | ||||
| 			.DetachTimeout          = 0x0000, | ||||
| 			.TransferSize           = 0x0C00, | ||||
|  | ||||
| 			.DFUSpecification       = VERSION_BCD(01.01) | ||||
| 		} | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in SRAM memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(22), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"AVR DFU API Bootloader" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration:  | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String:  | ||||
| 			if (!(DescriptorNumber)) | ||||
| 			{ | ||||
| 				Address = &LanguageString; | ||||
| 				Size    = LanguageString.Header.Size; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				Address = &ProductString; | ||||
| 				Size    = ProductString.Header.Size; | ||||
| 			} | ||||
| 			 | ||||
| 			break; | ||||
| 	} | ||||
| 	 | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = PRODUCT_ID_CODE, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.00), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = NO_DESCRIPTOR, | ||||
| 	.ProductStrIndex        = 0x01, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in SRAM memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 1, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = USB_CONFIG_ATTR_BUSPOWERED, | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.DFU_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0, | ||||
| 			.AlternateSetting       = 0, | ||||
|  | ||||
| 			.TotalEndpoints         = 0, | ||||
|  | ||||
| 			.Class                  = 0xFE, | ||||
| 			.SubClass               = 0x01, | ||||
| 			.Protocol               = 0x02, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.DFU_Functional = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_DFU_Functional_t), .Type = DTYPE_DFUFunctional}, | ||||
|  | ||||
| 			.Attributes             = (ATTR_CAN_UPLOAD | ATTR_CAN_DOWNLOAD), | ||||
|  | ||||
| 			.DetachTimeout          = 0x0000, | ||||
| 			.TransferSize           = 0x0C00, | ||||
|  | ||||
| 			.DFUSpecification       = VERSION_BCD(01.01) | ||||
| 		} | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in SRAM memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"AVR DFU Bootloader" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration:  | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String:  | ||||
| 			if (!(DescriptorNumber)) | ||||
| 			{ | ||||
| 				Address = &LanguageString; | ||||
| 				Size    = LanguageString.Header.Size; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				Address = &ProductString; | ||||
| 				Size    = ProductString.Header.Size; | ||||
| 			} | ||||
| 			 | ||||
| 			break; | ||||
| 	} | ||||
| 	 | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,177 +1,177 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Descriptor type value for a DFU class functional descriptor. */ | ||||
| 		#define DTYPE_DFUFunctional               0x21 | ||||
|  | ||||
| 		/** DFU attribute mask, indicating that the DFU device will detach and re-attach when a DFU_DETACH | ||||
| 		 *  command is issued, rather than the host issuing a USB Reset. | ||||
| 		 */ | ||||
| 		#define ATTR_WILL_DETATCH                 (1 << 3) | ||||
|  | ||||
| 		/** DFU attribute mask, indicating that the DFU device can communicate during the manifestation phase | ||||
| 		 *  (memory programming phase). | ||||
| 		 */ | ||||
| 		#define ATTR_MANEFESTATION_TOLLERANT      (1 << 2) | ||||
|  | ||||
| 		/** DFU attribute mask, indicating that the DFU device can accept DFU_UPLOAD requests to send data from | ||||
| 		 *  the device to the host. | ||||
| 		 */ | ||||
| 		#define ATTR_CAN_UPLOAD                   (1 << 1) | ||||
|  | ||||
| 		/** DFU attribute mask, indicating that the DFU device can accept DFU_DNLOAD requests to send data from | ||||
| 		 *  the host to the device. | ||||
| 		 */ | ||||
| 		#define ATTR_CAN_DOWNLOAD                 (1 << 0) | ||||
|  | ||||
| 		#if defined(__AVR_AT90USB1287__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FFB | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x97 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_AT90USB647__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FF9 | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x96 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_AT90USB1286__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FFB | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x97 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_AT90USB646__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FF9 | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x96 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_ATmega32U6__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FFB | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x95 | ||||
| 			#define AVR_SIGNATURE_3               0x88 | ||||
| 		#elif defined(__AVR_ATmega32U4__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FF4 | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x95 | ||||
| 			#define AVR_SIGNATURE_3               0x87 | ||||
| 		#elif defined(__AVR_ATmega16U4__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FF3 | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x88 | ||||
| 		#elif defined(__AVR_ATmega32U2__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FF0 | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x95 | ||||
| 			#define AVR_SIGNATURE_3               0x8A | ||||
| 		#elif defined(__AVR_ATmega16U2__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FEF | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x89 | ||||
| 		#elif defined(__AVR_AT90USB162__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FFA | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_ATmega8U2__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FF7 | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x93 | ||||
| 			#define AVR_SIGNATURE_3               0x89 | ||||
| 		#elif defined(__AVR_AT90USB82__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FEE | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#else | ||||
| 			#error The selected AVR part is not currently supported by this bootloader. | ||||
| 		#endif | ||||
|  | ||||
| 		#if !defined(PRODUCT_ID_CODE) | ||||
| 			#error Current AVR model is not supported by this bootloader. | ||||
| 		#endif | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for a DFU class function descriptor. This descriptor gives DFU class information | ||||
| 		 *  to the host when read, indicating the DFU device's capabilities. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Header_t Header; /**< Standard descriptor header structure */ | ||||
|  | ||||
| 			uint8_t                 Attributes; /**< DFU device attributes, a mask comprising of the | ||||
| 			                                     *  ATTR_* macros listed in this source file | ||||
| 			                                     */ | ||||
| 			uint16_t                DetachTimeout; /**< Timeout in milliseconds between a USB_DETACH | ||||
| 			                                        *  command being issued and the device detaching | ||||
| 			                                        *  from the USB bus | ||||
| 			                                        */ | ||||
| 			uint16_t                TransferSize; /**< Maximum number of bytes the DFU device can accept | ||||
| 			                                       *  from the host in a transaction | ||||
| 			                                       */ | ||||
| 			uint16_t                DFUSpecification; /**< BCD packed DFU specification number this DFU | ||||
| 			                                           *  device complies with | ||||
| 			                                           */ | ||||
| 		} USB_Descriptor_DFU_Functional_t; | ||||
|  | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t Config; | ||||
| 			 | ||||
| 			// DFU Interface | ||||
| 			USB_Descriptor_Interface_t            DFU_Interface; | ||||
| 			USB_Descriptor_DFU_Functional_t       DFU_Functional; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Descriptor type value for a DFU class functional descriptor. */ | ||||
| 		#define DTYPE_DFUFunctional               0x21 | ||||
|  | ||||
| 		/** DFU attribute mask, indicating that the DFU device will detach and re-attach when a DFU_DETACH | ||||
| 		 *  command is issued, rather than the host issuing a USB Reset. | ||||
| 		 */ | ||||
| 		#define ATTR_WILL_DETATCH                 (1 << 3) | ||||
|  | ||||
| 		/** DFU attribute mask, indicating that the DFU device can communicate during the manifestation phase | ||||
| 		 *  (memory programming phase). | ||||
| 		 */ | ||||
| 		#define ATTR_MANEFESTATION_TOLLERANT      (1 << 2) | ||||
|  | ||||
| 		/** DFU attribute mask, indicating that the DFU device can accept DFU_UPLOAD requests to send data from | ||||
| 		 *  the device to the host. | ||||
| 		 */ | ||||
| 		#define ATTR_CAN_UPLOAD                   (1 << 1) | ||||
|  | ||||
| 		/** DFU attribute mask, indicating that the DFU device can accept DFU_DNLOAD requests to send data from | ||||
| 		 *  the host to the device. | ||||
| 		 */ | ||||
| 		#define ATTR_CAN_DOWNLOAD                 (1 << 0) | ||||
|  | ||||
| 		#if defined(__AVR_AT90USB1287__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FFB | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x97 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_AT90USB647__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FF9 | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x96 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_AT90USB1286__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FFB | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x97 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_AT90USB646__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FF9 | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x96 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_ATmega32U6__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FFB | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x95 | ||||
| 			#define AVR_SIGNATURE_3               0x88 | ||||
| 		#elif defined(__AVR_ATmega32U4__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FF4 | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x95 | ||||
| 			#define AVR_SIGNATURE_3               0x87 | ||||
| 		#elif defined(__AVR_ATmega16U4__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FF3 | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x88 | ||||
| 		#elif defined(__AVR_ATmega32U2__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FF0 | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x95 | ||||
| 			#define AVR_SIGNATURE_3               0x8A | ||||
| 		#elif defined(__AVR_ATmega16U2__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FEF | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x89 | ||||
| 		#elif defined(__AVR_AT90USB162__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FFA | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#elif defined(__AVR_ATmega8U2__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FF7 | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x93 | ||||
| 			#define AVR_SIGNATURE_3               0x89 | ||||
| 		#elif defined(__AVR_AT90USB82__) | ||||
| 			#define PRODUCT_ID_CODE               0x2FEE | ||||
| 			#define AVR_SIGNATURE_1               0x1E | ||||
| 			#define AVR_SIGNATURE_2               0x94 | ||||
| 			#define AVR_SIGNATURE_3               0x82 | ||||
| 		#else | ||||
| 			#error The selected AVR part is not currently supported by this bootloader. | ||||
| 		#endif | ||||
|  | ||||
| 		#if !defined(PRODUCT_ID_CODE) | ||||
| 			#error Current AVR model is not supported by this bootloader. | ||||
| 		#endif | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for a DFU class function descriptor. This descriptor gives DFU class information | ||||
| 		 *  to the host when read, indicating the DFU device's capabilities. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Header_t Header; /**< Standard descriptor header structure */ | ||||
|  | ||||
| 			uint8_t                 Attributes; /**< DFU device attributes, a mask comprising of the | ||||
| 			                                     *  ATTR_* macros listed in this source file | ||||
| 			                                     */ | ||||
| 			uint16_t                DetachTimeout; /**< Timeout in milliseconds between a USB_DETACH | ||||
| 			                                        *  command being issued and the device detaching | ||||
| 			                                        *  from the USB bus | ||||
| 			                                        */ | ||||
| 			uint16_t                TransferSize; /**< Maximum number of bytes the DFU device can accept | ||||
| 			                                       *  from the host in a transaction | ||||
| 			                                       */ | ||||
| 			uint16_t                DFUSpecification; /**< BCD packed DFU specification number this DFU | ||||
| 			                                           *  device complies with | ||||
| 			                                           */ | ||||
| 		} USB_Descriptor_DFU_Functional_t; | ||||
|  | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t Config; | ||||
| 			 | ||||
| 			// DFU Interface | ||||
| 			USB_Descriptor_Interface_t            DFU_Interface; | ||||
| 			USB_Descriptor_DFU_Functional_t       DFU_Functional; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1 +1 @@ | ||||
| <AVRStudio><MANAGEMENT><ProjectName>BootloaderHID</ProjectName><Created>15-Jan-2011 21:49:00</Created><LastEdit>15-Jan-2011 21:49:00</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 14:41:25</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>BootloaderHID.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM></COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>BootloaderHID.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>BootloaderHID.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>BootloaderCDC.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><ProjectFiles><Files><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\BootloaderHID.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\Descriptors.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\BootloaderHID.c</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\Descriptors.c</Name></Files></ProjectFiles><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
| <AVRStudio><MANAGEMENT><ProjectName>BootloaderHID</ProjectName><Created>15-Jan-2011 21:49:00</Created><LastEdit>15-Jan-2011 21:49:00</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 14:41:25</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>BootloaderHID.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM></COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>BootloaderHID.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>BootloaderHID.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>BootloaderCDC.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><ProjectFiles><Files><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\BootloaderHID.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\Descriptors.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\HID\BootloaderHID.c</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Bootloaders\CDC\Descriptors.c</Name></Files></ProjectFiles><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
|   | ||||
| @@ -1,164 +1,164 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this  | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in  | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting  | ||||
|   documentation, and that the name of the author not be used in  | ||||
|   advertising or publicity pertaining to distribution of the  | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the HID class bootloader. This file contains the complete bootloader logic. | ||||
|  */ | ||||
|   | ||||
| #include "BootloaderHID.h" | ||||
|  | ||||
| /** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run | ||||
|  *  via a soft reset. When cleared, the bootloader will abort, the USB interface will shut down and the application | ||||
|  *  started via a forced watchdog reset. | ||||
|  */ | ||||
| static bool RunBootloader = true; | ||||
|  | ||||
| /** Main program entry point. This routine configures the hardware required by the bootloader, then continuously  | ||||
|  *  runs the bootloader processing routine until instructed to soft-exit. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	/* Setup hardware required for the bootloader */ | ||||
| 	SetupHardware(); | ||||
| 	 | ||||
| 	/* Enable global interrupts so that the USB stack can function */ | ||||
| 	sei(); | ||||
|  | ||||
| 	while (RunBootloader) | ||||
| 	  USB_USBTask(); | ||||
| 	 | ||||
| 	/* Disconnect from the host - USB interface will be reset later along with the AVR */ | ||||
| 	USB_Detach(); | ||||
|  | ||||
| 	/* Enable the watchdog and force a timeout to reset the AVR */ | ||||
| 	wdt_enable(WDTO_250MS); | ||||
|  | ||||
| 	for (;;); | ||||
| } | ||||
|  | ||||
| /** Configures all hardware required for the bootloader. */ | ||||
| void SetupHardware(void) | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Relocate the interrupt vector table to the bootloader section */ | ||||
| 	MCUCR = (1 << IVCE); | ||||
| 	MCUCR = (1 << IVSEL); | ||||
|  | ||||
| 	/* Initialize USB subsystem */ | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready | ||||
|  *  to relay data to and from the attached USB host. | ||||
|  */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	/* Setup HID Report Endpoint */ | ||||
| 	Endpoint_ConfigureEndpoint(HID_IN_EPNUM, EP_TYPE_INTERRUPT, | ||||
| 		                       ENDPOINT_DIR_IN, HID_IN_EPSIZE, | ||||
| 	                           ENDPOINT_BANK_SINGLE); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to | ||||
|  *  the device from the USB host before passing along unhandled control requests to the library for processing | ||||
|  *  internally. | ||||
|  */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	/* Ignore any requests that aren't directed to the HID interface */ | ||||
| 	if ((USB_ControlRequest.bmRequestType & (CONTROL_REQTYPE_TYPE | CONTROL_REQTYPE_RECIPIENT)) != | ||||
| 	    (REQTYPE_CLASS | REQREC_INTERFACE)) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	/* Process HID specific control requests */ | ||||
| 	switch (USB_ControlRequest.bRequest) | ||||
| 	{ | ||||
| 		case HID_REQ_SetReport: | ||||
| 			Endpoint_ClearSETUP(); | ||||
| 			 | ||||
| 			/* Wait until the command has been sent by the host */ | ||||
| 			while (!(Endpoint_IsOUTReceived())); | ||||
| 		 | ||||
| 			/* Read in the write destination address */ | ||||
| 			#if (FLASHEND > 0xFFFF) | ||||
| 			uint32_t PageAddress = ((uint32_t)Endpoint_Read_16_LE() << 8); | ||||
| 			#else | ||||
| 			uint16_t PageAddress = Endpoint_Read_16_LE(); | ||||
| 			#endif | ||||
| 			 | ||||
| 			/* Check if the command is a program page command, or a start application command */ | ||||
| 			#if (FLASHEND > 0xFFFF) | ||||
| 			if ((uint16_t)(PageAddress >> 8) == COMMAND_STARTAPPLICATION) | ||||
| 			#else | ||||
| 			if (PageAddress == COMMAND_STARTAPPLICATION) | ||||
| 			#endif | ||||
| 			{ | ||||
| 				RunBootloader = false; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				/* Erase the given FLASH page, ready to be programmed */ | ||||
| 				boot_page_erase(PageAddress); | ||||
| 				boot_spm_busy_wait(); | ||||
| 				 | ||||
| 				/* Write each of the FLASH page's bytes in sequence */ | ||||
| 				for (uint8_t PageWord = 0; PageWord < (SPM_PAGESIZE / 2); PageWord++)				 | ||||
| 				{ | ||||
| 					/* Check if endpoint is empty - if so clear it and wait until ready for next packet */ | ||||
| 					if (!(Endpoint_BytesInEndpoint())) | ||||
| 					{ | ||||
| 						Endpoint_ClearOUT(); | ||||
| 						while (!(Endpoint_IsOUTReceived())); | ||||
| 					} | ||||
|  | ||||
| 					/* Write the next data word to the FLASH page */ | ||||
| 					boot_page_fill(PageAddress + ((uint16_t)PageWord << 1), Endpoint_Read_16_LE()); | ||||
| 				} | ||||
|  | ||||
| 				/* Write the filled FLASH page to memory */ | ||||
| 				boot_page_write(PageAddress); | ||||
| 				boot_spm_busy_wait(); | ||||
|  | ||||
| 				/* Re-enable RWW section */ | ||||
| 				boot_rww_enable(); | ||||
| 			} | ||||
|  | ||||
| 			Endpoint_ClearOUT(); | ||||
|  | ||||
| 			Endpoint_ClearStatusStage(); | ||||
| 			break; | ||||
| 	} | ||||
| } | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this  | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in  | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting  | ||||
|   documentation, and that the name of the author not be used in  | ||||
|   advertising or publicity pertaining to distribution of the  | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the HID class bootloader. This file contains the complete bootloader logic. | ||||
|  */ | ||||
|   | ||||
| #include "BootloaderHID.h" | ||||
|  | ||||
| /** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run | ||||
|  *  via a soft reset. When cleared, the bootloader will abort, the USB interface will shut down and the application | ||||
|  *  started via a forced watchdog reset. | ||||
|  */ | ||||
| static bool RunBootloader = true; | ||||
|  | ||||
| /** Main program entry point. This routine configures the hardware required by the bootloader, then continuously  | ||||
|  *  runs the bootloader processing routine until instructed to soft-exit. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	/* Setup hardware required for the bootloader */ | ||||
| 	SetupHardware(); | ||||
| 	 | ||||
| 	/* Enable global interrupts so that the USB stack can function */ | ||||
| 	sei(); | ||||
|  | ||||
| 	while (RunBootloader) | ||||
| 	  USB_USBTask(); | ||||
| 	 | ||||
| 	/* Disconnect from the host - USB interface will be reset later along with the AVR */ | ||||
| 	USB_Detach(); | ||||
|  | ||||
| 	/* Enable the watchdog and force a timeout to reset the AVR */ | ||||
| 	wdt_enable(WDTO_250MS); | ||||
|  | ||||
| 	for (;;); | ||||
| } | ||||
|  | ||||
| /** Configures all hardware required for the bootloader. */ | ||||
| void SetupHardware(void) | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Relocate the interrupt vector table to the bootloader section */ | ||||
| 	MCUCR = (1 << IVCE); | ||||
| 	MCUCR = (1 << IVSEL); | ||||
|  | ||||
| 	/* Initialize USB subsystem */ | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB_ConfigurationChanged event. This configures the device's endpoints ready | ||||
|  *  to relay data to and from the attached USB host. | ||||
|  */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	/* Setup HID Report Endpoint */ | ||||
| 	Endpoint_ConfigureEndpoint(HID_IN_EPNUM, EP_TYPE_INTERRUPT, | ||||
| 		                       ENDPOINT_DIR_IN, HID_IN_EPSIZE, | ||||
| 	                           ENDPOINT_BANK_SINGLE); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB_ControlRequest event. This is used to catch and process control requests sent to | ||||
|  *  the device from the USB host before passing along unhandled control requests to the library for processing | ||||
|  *  internally. | ||||
|  */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	/* Ignore any requests that aren't directed to the HID interface */ | ||||
| 	if ((USB_ControlRequest.bmRequestType & (CONTROL_REQTYPE_TYPE | CONTROL_REQTYPE_RECIPIENT)) != | ||||
| 	    (REQTYPE_CLASS | REQREC_INTERFACE)) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	/* Process HID specific control requests */ | ||||
| 	switch (USB_ControlRequest.bRequest) | ||||
| 	{ | ||||
| 		case HID_REQ_SetReport: | ||||
| 			Endpoint_ClearSETUP(); | ||||
| 			 | ||||
| 			/* Wait until the command has been sent by the host */ | ||||
| 			while (!(Endpoint_IsOUTReceived())); | ||||
| 		 | ||||
| 			/* Read in the write destination address */ | ||||
| 			#if (FLASHEND > 0xFFFF) | ||||
| 			uint32_t PageAddress = ((uint32_t)Endpoint_Read_16_LE() << 8); | ||||
| 			#else | ||||
| 			uint16_t PageAddress = Endpoint_Read_16_LE(); | ||||
| 			#endif | ||||
| 			 | ||||
| 			/* Check if the command is a program page command, or a start application command */ | ||||
| 			#if (FLASHEND > 0xFFFF) | ||||
| 			if ((uint16_t)(PageAddress >> 8) == COMMAND_STARTAPPLICATION) | ||||
| 			#else | ||||
| 			if (PageAddress == COMMAND_STARTAPPLICATION) | ||||
| 			#endif | ||||
| 			{ | ||||
| 				RunBootloader = false; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				/* Erase the given FLASH page, ready to be programmed */ | ||||
| 				boot_page_erase(PageAddress); | ||||
| 				boot_spm_busy_wait(); | ||||
| 				 | ||||
| 				/* Write each of the FLASH page's bytes in sequence */ | ||||
| 				for (uint8_t PageWord = 0; PageWord < (SPM_PAGESIZE / 2); PageWord++)				 | ||||
| 				{ | ||||
| 					/* Check if endpoint is empty - if so clear it and wait until ready for next packet */ | ||||
| 					if (!(Endpoint_BytesInEndpoint())) | ||||
| 					{ | ||||
| 						Endpoint_ClearOUT(); | ||||
| 						while (!(Endpoint_IsOUTReceived())); | ||||
| 					} | ||||
|  | ||||
| 					/* Write the next data word to the FLASH page */ | ||||
| 					boot_page_fill(PageAddress + ((uint16_t)PageWord << 1), Endpoint_Read_16_LE()); | ||||
| 				} | ||||
|  | ||||
| 				/* Write the filled FLASH page to memory */ | ||||
| 				boot_page_write(PageAddress); | ||||
| 				boot_spm_busy_wait(); | ||||
|  | ||||
| 				/* Re-enable RWW section */ | ||||
| 				boot_rww_enable(); | ||||
| 			} | ||||
|  | ||||
| 			Endpoint_ClearOUT(); | ||||
|  | ||||
| 			Endpoint_ClearStatusStage(); | ||||
| 			break; | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -1,61 +1,61 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
| 	   | ||||
|   Permission to use, copy, modify, distribute, and sell this  | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in  | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting  | ||||
|   documentation, and that the name of the author not be used in  | ||||
|   advertising or publicity pertaining to distribution of the  | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for TeensyHID.c. | ||||
|  */ | ||||
|   | ||||
| #ifndef _TEENSYHID_H_ | ||||
| #define _TEENSYHID_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/boot.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <stdbool.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
| 		 | ||||
| 	/* Macros: */		 | ||||
| 		/** Bootloader special address to start the user application */ | ||||
| 		#define COMMAND_STARTAPPLICATION   0xFFFF | ||||
| 		 | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_UnhandledControlRequest(void); | ||||
| 		 | ||||
| #endif | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
| 	   | ||||
|   Permission to use, copy, modify, distribute, and sell this  | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in  | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting  | ||||
|   documentation, and that the name of the author not be used in  | ||||
|   advertising or publicity pertaining to distribution of the  | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for TeensyHID.c. | ||||
|  */ | ||||
|   | ||||
| #ifndef _TEENSYHID_H_ | ||||
| #define _TEENSYHID_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/boot.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <stdbool.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
| 		 | ||||
| 	/* Macros: */		 | ||||
| 		/** Bootloader special address to start the user application */ | ||||
| 		#define COMMAND_STARTAPPLICATION   0xFFFF | ||||
| 		 | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_UnhandledControlRequest(void); | ||||
| 		 | ||||
| #endif | ||||
|   | ||||
| @@ -1,88 +1,88 @@ | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|   | ||||
| /** \mainpage HID Class USB AVR Bootloader | ||||
|  * | ||||
|  *  \section SSec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  *  - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) | ||||
|  * | ||||
|  *  \section SSec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  * <table> | ||||
|  *  <tr> | ||||
|  *   <td><b>USB Mode:</b></td> | ||||
|  *   <td>Device</td> | ||||
|  *  </tr> | ||||
|  *  <tr> | ||||
|  *   <td><b>USB Class:</b></td> | ||||
|  *   <td>Human Interface Device Class (HID)</td> | ||||
|  *  </tr> | ||||
|  *  <tr>  | ||||
|  *   <td><b>USB Subclass:</b></td> | ||||
|  *   <td>N/A</td> | ||||
|  *  </tr> | ||||
|  *  <tr> | ||||
|  *   <td><b>Relevant Standards:</b></td> | ||||
|  *   <td>USBIF HID Class Standard \n | ||||
|  *       Teensy Programming Protocol Specification</td> | ||||
|  *  </tr> | ||||
|  *  <tr> | ||||
|  *   <td><b>Usable Speeds:</b></td> | ||||
|  *   <td>Low Speed Mode \n | ||||
|  *       Full Speed Mode</td> | ||||
|  *  </tr> | ||||
|  * </table> | ||||
|  * | ||||
|  *  \section SSec_Description Project Description:  | ||||
|  * | ||||
|  *  This bootloader enumerates to the host as a HID Class device, allowing for device FLASH programming through | ||||
|  *  the supplied command line software, which is a modified version of Paul's TeensyHID Command Line loader code | ||||
|  *  from PJRC (used with permission). This bootloader is deliberatley non-compatible with the properietary PJRC | ||||
|  *  HalfKay bootloader GUI; only the command line interface software accompanying this bootloader will work with it. | ||||
|  *   | ||||
|  *  Out of the box this bootloader builds for the USB1287, and will fit into 2KB of bootloader space for the | ||||
|  *  Series 2 USB AVRs (ATMEGAxxU2, AT90USBxx2) or 4KB of bootloader space for all other models. If you wish to | ||||
|  *  enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU values in the | ||||
|  *  accompanying makefile. | ||||
|  * | ||||
|  *  \section Sec_Installation Driver Installation | ||||
|  * | ||||
|  *  This bootloader uses the HID class driver inbuilt into all modern operating systems, thus no additional drivers | ||||
|  *  need to be supplied for correct operation. | ||||
|  * | ||||
|  *  \section Sec_HostApp Host Controller Application | ||||
|  * | ||||
|  *  Due to licensing issues, the supplied bootloader is compatible with the HalfKay bootloader protocol designed | ||||
|  *  by PJRC, but is non-compatible with the cross-platform loader GUI. A modified version of the open source | ||||
|  *  cross-platform TeensyLoader application is supplied, which can be compiled under most operating systems. The | ||||
|  *  command-line loader application should remain compatible with genuine Teensy boards in addition to boards using | ||||
|  *  this custom bootloader. | ||||
|  * | ||||
|  *  Once compiled, programs can be loaded into the AVR's FLASH memory through the following example command: | ||||
|  *  \code | ||||
|  *  hid_bootloader_cli -mmcu=at90usb1287 Mouse.hex | ||||
|  *  \endcode | ||||
|  * | ||||
|  *  \section SSec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td> | ||||
|  *     None | ||||
|  *    </td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|   | ||||
| /** \mainpage HID Class USB AVR Bootloader | ||||
|  * | ||||
|  *  \section SSec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  *  - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) | ||||
|  * | ||||
|  *  \section SSec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  * <table> | ||||
|  *  <tr> | ||||
|  *   <td><b>USB Mode:</b></td> | ||||
|  *   <td>Device</td> | ||||
|  *  </tr> | ||||
|  *  <tr> | ||||
|  *   <td><b>USB Class:</b></td> | ||||
|  *   <td>Human Interface Device Class (HID)</td> | ||||
|  *  </tr> | ||||
|  *  <tr>  | ||||
|  *   <td><b>USB Subclass:</b></td> | ||||
|  *   <td>N/A</td> | ||||
|  *  </tr> | ||||
|  *  <tr> | ||||
|  *   <td><b>Relevant Standards:</b></td> | ||||
|  *   <td>USBIF HID Class Standard \n | ||||
|  *       Teensy Programming Protocol Specification</td> | ||||
|  *  </tr> | ||||
|  *  <tr> | ||||
|  *   <td><b>Usable Speeds:</b></td> | ||||
|  *   <td>Low Speed Mode \n | ||||
|  *       Full Speed Mode</td> | ||||
|  *  </tr> | ||||
|  * </table> | ||||
|  * | ||||
|  *  \section SSec_Description Project Description:  | ||||
|  * | ||||
|  *  This bootloader enumerates to the host as a HID Class device, allowing for device FLASH programming through | ||||
|  *  the supplied command line software, which is a modified version of Paul's TeensyHID Command Line loader code | ||||
|  *  from PJRC (used with permission). This bootloader is deliberatley non-compatible with the properietary PJRC | ||||
|  *  HalfKay bootloader GUI; only the command line interface software accompanying this bootloader will work with it. | ||||
|  *   | ||||
|  *  Out of the box this bootloader builds for the USB1287, and will fit into 2KB of bootloader space for the | ||||
|  *  Series 2 USB AVRs (ATMEGAxxU2, AT90USBxx2) or 4KB of bootloader space for all other models. If you wish to | ||||
|  *  enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU values in the | ||||
|  *  accompanying makefile. | ||||
|  * | ||||
|  *  \section Sec_Installation Driver Installation | ||||
|  * | ||||
|  *  This bootloader uses the HID class driver inbuilt into all modern operating systems, thus no additional drivers | ||||
|  *  need to be supplied for correct operation. | ||||
|  * | ||||
|  *  \section Sec_HostApp Host Controller Application | ||||
|  * | ||||
|  *  Due to licensing issues, the supplied bootloader is compatible with the HalfKay bootloader protocol designed | ||||
|  *  by PJRC, but is non-compatible with the cross-platform loader GUI. A modified version of the open source | ||||
|  *  cross-platform TeensyLoader application is supplied, which can be compiled under most operating systems. The | ||||
|  *  command-line loader application should remain compatible with genuine Teensy boards in addition to boards using | ||||
|  *  this custom bootloader. | ||||
|  * | ||||
|  *  Once compiled, programs can be loaded into the AVR's FLASH memory through the following example command: | ||||
|  *  \code | ||||
|  *  hid_bootloader_cli -mmcu=at90usb1287 Mouse.hex | ||||
|  *  \endcode | ||||
|  * | ||||
|  *  \section SSec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td> | ||||
|  *     None | ||||
|  *    </td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|   | ||||
| @@ -1,186 +1,186 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
| 	   | ||||
|   Permission to use, copy, modify, distribute, and sell this  | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in  | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting  | ||||
|   documentation, and that the name of the author not be used in  | ||||
|   advertising or publicity pertaining to distribution of the  | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special  | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions.   | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** HID class report descriptor. This is a special descriptor constructed with values from the | ||||
|  *  USBIF HID class specification to describe the reports and capabilities of the HID device. This | ||||
|  *  descriptor is parsed by the host and its contents used to determine what data (and in what encoding) | ||||
|  *  the device will send, and what it may be sent back from the host. Refer to the HID specification for | ||||
|  *  more details on HID report descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_HIDReport_Datatype_t HIDReport[] = | ||||
| { | ||||
| 	HID_RI_USAGE_PAGE(16, 0xFFDC), /* Vendor Page 0xDC */ | ||||
| 	HID_RI_USAGE(8, 0xFB), /* Vendor Usage 0xFB */ | ||||
| 	HID_RI_COLLECTION(8, 0x01), /* Vendor Usage 1 */ | ||||
| 	    HID_RI_USAGE(8, 0x02), /* Vendor Usage 2 */ | ||||
| 	    HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||||
| 	    HID_RI_LOGICAL_MAXIMUM(8, 0xFF), | ||||
| 	    HID_RI_REPORT_SIZE(8, 0x08), | ||||
| 	    HID_RI_REPORT_COUNT(16, (sizeof(uint16_t) + SPM_PAGESIZE)),		 | ||||
| 	    HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), | ||||
| 	HID_RI_END_COLLECTION(0), | ||||
| }; | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x2067, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = NO_DESCRIPTOR, | ||||
| 	.ProductStrIndex        = NO_DESCRIPTOR, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config =  | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 1, | ||||
| 				 | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
| 				 | ||||
| 			.ConfigAttributes       = USB_CONFIG_ATTR_BUSPOWERED, | ||||
| 			 | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
| 		 | ||||
| 	.HID_Interface =  | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0x00, | ||||
| 			.AlternateSetting       = 0x00, | ||||
| 			 | ||||
| 			.TotalEndpoints         = 1, | ||||
| 				 | ||||
| 			.Class                  = HID_CSCP_HIDClass, | ||||
| 			.SubClass               = HID_CSCP_NonBootSubclass, | ||||
| 			.Protocol               = HID_CSCP_NonBootProtocol, | ||||
| 				 | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.HID_VendorHID =  | ||||
| 		{   | ||||
| 			.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||||
| 			 | ||||
| 			.HIDSpec                = VERSION_BCD(01.11), | ||||
| 			.CountryCode            = 0x00, | ||||
| 			.TotalReportDescriptors = 1, | ||||
| 			.HIDReportType          = HID_DTYPE_Report, | ||||
| 			.HIDReportLength        = sizeof(HIDReport) | ||||
| 		}, | ||||
| 		 | ||||
| 	.HID_ReportINEndpoint =  | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | HID_IN_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = HID_IN_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t DescriptorType   = (wValue >> 8); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
| 	 | ||||
| 	/* If/Else If chain compiles slightly smaller than a switch case */ | ||||
| 	if (DescriptorType == DTYPE_Device) | ||||
| 	{ | ||||
| 		Address = &DeviceDescriptor; | ||||
| 		Size    = sizeof(USB_Descriptor_Device_t);	 | ||||
| 	} | ||||
| 	else if (DescriptorType == DTYPE_Configuration) | ||||
| 	{ | ||||
| 		Address = &ConfigurationDescriptor; | ||||
| 		Size    = sizeof(USB_Descriptor_Configuration_t);	 | ||||
| 	} | ||||
| 	else if (DescriptorType == HID_DTYPE_HID) | ||||
| 	{ | ||||
| 		Address = &ConfigurationDescriptor.HID_VendorHID; | ||||
| 		Size    = sizeof(USB_HID_Descriptor_HID_t); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		Address = &HIDReport; | ||||
| 		Size    = sizeof(HIDReport); | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
| 	   | ||||
|   Permission to use, copy, modify, distribute, and sell this  | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in  | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting  | ||||
|   documentation, and that the name of the author not be used in  | ||||
|   advertising or publicity pertaining to distribution of the  | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special  | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions.   | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** HID class report descriptor. This is a special descriptor constructed with values from the | ||||
|  *  USBIF HID class specification to describe the reports and capabilities of the HID device. This | ||||
|  *  descriptor is parsed by the host and its contents used to determine what data (and in what encoding) | ||||
|  *  the device will send, and what it may be sent back from the host. Refer to the HID specification for | ||||
|  *  more details on HID report descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_HIDReport_Datatype_t HIDReport[] = | ||||
| { | ||||
| 	HID_RI_USAGE_PAGE(16, 0xFFDC), /* Vendor Page 0xDC */ | ||||
| 	HID_RI_USAGE(8, 0xFB), /* Vendor Usage 0xFB */ | ||||
| 	HID_RI_COLLECTION(8, 0x01), /* Vendor Usage 1 */ | ||||
| 	    HID_RI_USAGE(8, 0x02), /* Vendor Usage 2 */ | ||||
| 	    HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||||
| 	    HID_RI_LOGICAL_MAXIMUM(8, 0xFF), | ||||
| 	    HID_RI_REPORT_SIZE(8, 0x08), | ||||
| 	    HID_RI_REPORT_COUNT(16, (sizeof(uint16_t) + SPM_PAGESIZE)),		 | ||||
| 	    HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), | ||||
| 	HID_RI_END_COLLECTION(0), | ||||
| }; | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x2067, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = NO_DESCRIPTOR, | ||||
| 	.ProductStrIndex        = NO_DESCRIPTOR, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config =  | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 1, | ||||
| 				 | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
| 				 | ||||
| 			.ConfigAttributes       = USB_CONFIG_ATTR_BUSPOWERED, | ||||
| 			 | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
| 		 | ||||
| 	.HID_Interface =  | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0x00, | ||||
| 			.AlternateSetting       = 0x00, | ||||
| 			 | ||||
| 			.TotalEndpoints         = 1, | ||||
| 				 | ||||
| 			.Class                  = HID_CSCP_HIDClass, | ||||
| 			.SubClass               = HID_CSCP_NonBootSubclass, | ||||
| 			.Protocol               = HID_CSCP_NonBootProtocol, | ||||
| 				 | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.HID_VendorHID =  | ||||
| 		{   | ||||
| 			.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||||
| 			 | ||||
| 			.HIDSpec                = VERSION_BCD(01.11), | ||||
| 			.CountryCode            = 0x00, | ||||
| 			.TotalReportDescriptors = 1, | ||||
| 			.HIDReportType          = HID_DTYPE_Report, | ||||
| 			.HIDReportLength        = sizeof(HIDReport) | ||||
| 		}, | ||||
| 		 | ||||
| 	.HID_ReportINEndpoint =  | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | HID_IN_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = HID_IN_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t DescriptorType   = (wValue >> 8); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
| 	 | ||||
| 	/* If/Else If chain compiles slightly smaller than a switch case */ | ||||
| 	if (DescriptorType == DTYPE_Device) | ||||
| 	{ | ||||
| 		Address = &DeviceDescriptor; | ||||
| 		Size    = sizeof(USB_Descriptor_Device_t);	 | ||||
| 	} | ||||
| 	else if (DescriptorType == DTYPE_Configuration) | ||||
| 	{ | ||||
| 		Address = &ConfigurationDescriptor; | ||||
| 		Size    = sizeof(USB_Descriptor_Configuration_t);	 | ||||
| 	} | ||||
| 	else if (DescriptorType == HID_DTYPE_HID) | ||||
| 	{ | ||||
| 		Address = &ConfigurationDescriptor.HID_VendorHID; | ||||
| 		Size    = sizeof(USB_HID_Descriptor_HID_t); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		Address = &HIDReport; | ||||
| 		Size    = sizeof(HIDReport); | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|   | ||||
| @@ -1,70 +1,70 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
| 	   | ||||
|   Permission to use, copy, modify, distribute, and sell this  | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in  | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting  | ||||
|   documentation, and that the name of the author not be used in  | ||||
|   advertising or publicity pertaining to distribution of the  | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t Config; | ||||
| 			 | ||||
| 			// Generic HID Interface | ||||
| 			USB_Descriptor_Interface_t            HID_Interface; | ||||
| 			USB_HID_Descriptor_HID_t              HID_VendorHID; | ||||
| 	        USB_Descriptor_Endpoint_t             HID_ReportINEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
| 					 | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the HID data IN endpoint. */ | ||||
| 		#define HID_IN_EPNUM                 1 | ||||
|  | ||||
| 		/** Size in bytes of the HID reporting IN endpoint. */		 | ||||
| 		#define HID_IN_EPSIZE                64 | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
| 	   | ||||
|   Permission to use, copy, modify, distribute, and sell this  | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in  | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting  | ||||
|   documentation, and that the name of the author not be used in  | ||||
|   advertising or publicity pertaining to distribution of the  | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t Config; | ||||
| 			 | ||||
| 			// Generic HID Interface | ||||
| 			USB_Descriptor_Interface_t            HID_Interface; | ||||
| 			USB_HID_Descriptor_HID_t              HID_VendorHID; | ||||
| 	        USB_Descriptor_Endpoint_t             HID_ReportINEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
| 					 | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the HID data IN endpoint. */ | ||||
| 		#define HID_IN_EPNUM                 1 | ||||
|  | ||||
| 		/** Size in bytes of the HID reporting IN endpoint. */		 | ||||
| 		#define HID_IN_EPSIZE                64 | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,39 +1,39 @@ | ||||
| OS ?= LINUX | ||||
| #OS ?= WINDOWS | ||||
| #OS ?= MACOSX | ||||
| #OS ?= BSD | ||||
|  | ||||
| ifeq ($(OS), LINUX)  # also works on FreeBSD | ||||
| CC ?= gcc | ||||
| CFLAGS ?= -O2 -Wall | ||||
| hid_bootloader_cli: hid_bootloader_cli.c | ||||
| 	$(CC) $(CFLAGS) -s -DUSE_LIBUSB -o hid_bootloader_cli hid_bootloader_cli.c -lusb | ||||
|  | ||||
|  | ||||
| else ifeq ($(OS), WINDOWS) | ||||
| CC = i586-mingw32msvc-gcc | ||||
| CFLAGS ?= -O2 -Wall | ||||
| hid_bootloader_cli.exe: hid_bootloader_cli.c | ||||
| 	$(CC) $(CFLAGS) -s -DUSE_WIN32 -o hid_bootloader_cli.exe hid_bootloader_cli.c -lhid -lsetupapi | ||||
|  | ||||
|  | ||||
| else ifeq ($(OS), MACOSX) | ||||
| CC ?= gcc | ||||
| SDK ?= /Developer/SDKs/MacOSX10.5.sdk | ||||
| CFLAGS ?= -O2 -Wall | ||||
| hid_bootloader_cli: hid_bootloader_cli.c | ||||
| 	$(CC) $(CFLAGS) -DUSE_APPLE_IOKIT -isysroot $(SDK) -o hid_bootloader_cli hid_bootloader_cli.c -Wl,-syslibroot,$(SDK) -framework IOKit -framework CoreFoundation | ||||
|  | ||||
|  | ||||
| else ifeq ($(OS), BSD)  # works on NetBSD and OpenBSD | ||||
| CC ?= gcct | ||||
| CFLAGS ?= -O2 -Wall | ||||
| hid_bootloader_cli: hid_bootloader_cli.c | ||||
| 	$(CC) $(CFLAGS) -s -DUSE_UHID -o hid_bootloader_cli hid_bootloader_cli.c | ||||
|  | ||||
|  | ||||
| endif | ||||
|  | ||||
|  | ||||
| clean: | ||||
| 	rm -f hid_bootloader_cli hid_bootloader_cli.exe | ||||
| OS ?= LINUX | ||||
| #OS ?= WINDOWS | ||||
| #OS ?= MACOSX | ||||
| #OS ?= BSD | ||||
|  | ||||
| ifeq ($(OS), LINUX)  # also works on FreeBSD | ||||
| CC ?= gcc | ||||
| CFLAGS ?= -O2 -Wall | ||||
| hid_bootloader_cli: hid_bootloader_cli.c | ||||
| 	$(CC) $(CFLAGS) -s -DUSE_LIBUSB -o hid_bootloader_cli hid_bootloader_cli.c -lusb | ||||
|  | ||||
|  | ||||
| else ifeq ($(OS), WINDOWS) | ||||
| CC = i586-mingw32msvc-gcc | ||||
| CFLAGS ?= -O2 -Wall | ||||
| hid_bootloader_cli.exe: hid_bootloader_cli.c | ||||
| 	$(CC) $(CFLAGS) -s -DUSE_WIN32 -o hid_bootloader_cli.exe hid_bootloader_cli.c -lhid -lsetupapi | ||||
|  | ||||
|  | ||||
| else ifeq ($(OS), MACOSX) | ||||
| CC ?= gcc | ||||
| SDK ?= /Developer/SDKs/MacOSX10.5.sdk | ||||
| CFLAGS ?= -O2 -Wall | ||||
| hid_bootloader_cli: hid_bootloader_cli.c | ||||
| 	$(CC) $(CFLAGS) -DUSE_APPLE_IOKIT -isysroot $(SDK) -o hid_bootloader_cli hid_bootloader_cli.c -Wl,-syslibroot,$(SDK) -framework IOKit -framework CoreFoundation | ||||
|  | ||||
|  | ||||
| else ifeq ($(OS), BSD)  # works on NetBSD and OpenBSD | ||||
| CC ?= gcct | ||||
| CFLAGS ?= -O2 -Wall | ||||
| hid_bootloader_cli: hid_bootloader_cli.c | ||||
| 	$(CC) $(CFLAGS) -s -DUSE_UHID -o hid_bootloader_cli hid_bootloader_cli.c | ||||
|  | ||||
|  | ||||
| endif | ||||
|  | ||||
|  | ||||
| clean: | ||||
| 	rm -f hid_bootloader_cli hid_bootloader_cli.exe | ||||
|   | ||||
| @@ -1,21 +1,21 @@ | ||||
| OS ?= FreeBSD | ||||
| #OS ?= NetBSD | ||||
| #OS ?= OpenBSD | ||||
|  | ||||
| CFLAGS ?= -O2 -Wall | ||||
| CC ?= gcc | ||||
|  | ||||
| .if $(OS) == "FreeBSD" | ||||
| CFLAGS += -DUSE_LIBUSB | ||||
| LIBS =  -lusb | ||||
| .elif $(OS) == "NetBSD" || $(OS) == "OpenBSD" | ||||
| CFLAGS += -DUSE_UHID | ||||
| LIBS = | ||||
| .endif | ||||
|  | ||||
|  | ||||
| hid_bootloader_cli: hid_bootloader_cli.c | ||||
| 	$(CC) $(CFLAGS) -s -o hid_bootloader_cli hid_bootloader_cli.c $(LIBS) | ||||
|  | ||||
| clean: | ||||
| 	rm -f hid_bootloader_cli | ||||
| OS ?= FreeBSD | ||||
| #OS ?= NetBSD | ||||
| #OS ?= OpenBSD | ||||
|  | ||||
| CFLAGS ?= -O2 -Wall | ||||
| CC ?= gcc | ||||
|  | ||||
| .if $(OS) == "FreeBSD" | ||||
| CFLAGS += -DUSE_LIBUSB | ||||
| LIBS =  -lusb | ||||
| .elif $(OS) == "NetBSD" || $(OS) == "OpenBSD" | ||||
| CFLAGS += -DUSE_UHID | ||||
| LIBS = | ||||
| .endif | ||||
|  | ||||
|  | ||||
| hid_bootloader_cli: hid_bootloader_cli.c | ||||
| 	$(CC) $(CFLAGS) -s -o hid_bootloader_cli hid_bootloader_cli.c $(LIBS) | ||||
|  | ||||
| clean: | ||||
| 	rm -f hid_bootloader_cli | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,30 +1,30 @@ | ||||
| # | ||||
| #             LUFA Library | ||||
| #     Copyright (C) Dean Camera, 2011. | ||||
| # | ||||
| #  dean [at] fourwalledcubicle [dot] com | ||||
| #           www.lufa-lib.org | ||||
| # | ||||
|  | ||||
| # Makefile to build all the LUFA USB Bootloaders. Call with "make all" to | ||||
| # rebuild all bootloaders. | ||||
|  | ||||
| # Bootloaders are pre-cleaned before each one is built, to ensure any | ||||
| # custom LUFA library build options are reflected in the compiled | ||||
| # code. | ||||
|  | ||||
| all: | ||||
| 	$(MAKE) -C CDC clean | ||||
| 	$(MAKE) -C CDC all | ||||
|  | ||||
| 	$(MAKE) -C HID clean | ||||
| 	$(MAKE) -C HID all | ||||
|  | ||||
| 	$(MAKE) -C DFU clean | ||||
| 	$(MAKE) -C DFU all | ||||
|  | ||||
| %: | ||||
| 	$(MAKE) -C CDC $@ | ||||
| 	$(MAKE) -C DFU $@ | ||||
| 	$(MAKE) -C HID $@ | ||||
|  | ||||
| # | ||||
| #             LUFA Library | ||||
| #     Copyright (C) Dean Camera, 2011. | ||||
| # | ||||
| #  dean [at] fourwalledcubicle [dot] com | ||||
| #           www.lufa-lib.org | ||||
| # | ||||
|  | ||||
| # Makefile to build all the LUFA USB Bootloaders. Call with "make all" to | ||||
| # rebuild all bootloaders. | ||||
|  | ||||
| # Bootloaders are pre-cleaned before each one is built, to ensure any | ||||
| # custom LUFA library build options are reflected in the compiled | ||||
| # code. | ||||
|  | ||||
| all: | ||||
| 	$(MAKE) -C CDC clean | ||||
| 	$(MAKE) -C CDC all | ||||
|  | ||||
| 	$(MAKE) -C HID clean | ||||
| 	$(MAKE) -C HID all | ||||
|  | ||||
| 	$(MAKE) -C DFU clean | ||||
| 	$(MAKE) -C DFU all | ||||
|  | ||||
| %: | ||||
| 	$(MAKE) -C CDC $@ | ||||
| 	$(MAKE) -C DFU $@ | ||||
| 	$(MAKE) -C HID $@ | ||||
|  | ||||
|   | ||||
| @@ -1 +1 @@ | ||||
| <AVRStudio><MANAGEMENT><ProjectName>AudioInput</ProjectName><Created>13-Jul-2010 15:22:28</Created><LastEdit>13-Jul-2010 15:22:44</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:22:28</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\AudioInput\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR ONE!</CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>AudioInput.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>AudioInput.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>AudioInput.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
| <AVRStudio><MANAGEMENT><ProjectName>AudioInput</ProjectName><Created>13-Jul-2010 15:22:28</Created><LastEdit>13-Jul-2010 15:22:44</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:22:28</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\AudioInput\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR ONE!</CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>AudioInput.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>AudioInput.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>AudioInput.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
|   | ||||
| @@ -1,235 +1,235 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the AudioInput demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "AudioInput.h" | ||||
|  | ||||
| /** LUFA Audio Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all Audio Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_Audio_Device_t Microphone_Audio_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.StreamingInterfaceNumber = 1, | ||||
|  | ||||
| 				.DataINEndpointNumber     = AUDIO_STREAM_EPNUM, | ||||
| 				.DataINEndpointSize       = AUDIO_STREAM_EPSIZE, | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
| /** Current audio sampling frequency of the streaming audio endpoint. */ | ||||
| static uint32_t CurrentAudioSampleFrequency = 48000; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		Audio_Device_USBTask(&Microphone_Audio_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware(void) | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	LEDs_Init(); | ||||
| 	Buttons_Init(); | ||||
| 	ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_32); | ||||
| 	ADC_SetupChannel(MIC_IN_ADC_CHANNEL); | ||||
| 	USB_Init(); | ||||
|  | ||||
| 	/* Start the ADC conversion in free running mode */ | ||||
| 	ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | MIC_IN_ADC_MUX_MASK); | ||||
| } | ||||
|  | ||||
| /** ISR to handle the reloading of the data endpoint with the next sample. */ | ||||
| ISR(TIMER0_COMPA_vect, ISR_BLOCK) | ||||
| { | ||||
| 	uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint(); | ||||
|  | ||||
| 	/* Check that the USB bus is ready for the next sample to write */ | ||||
| 	if (Audio_Device_IsReadyForNextSample(&Microphone_Audio_Interface)) | ||||
| 	{ | ||||
| 		int16_t AudioSample; | ||||
|  | ||||
| 		#if defined(USE_TEST_TONE) | ||||
| 			static uint8_t SquareWaveSampleCount; | ||||
| 			static int16_t CurrentWaveValue; | ||||
| 			 | ||||
| 			/* In test tone mode, generate a square wave at 1/256 of the sample rate */ | ||||
| 			if (SquareWaveSampleCount++ == 0xFF) | ||||
| 			  CurrentWaveValue ^= 0x8000; | ||||
| 			 | ||||
| 			/* Only generate audio if the board button is being pressed */ | ||||
| 			AudioSample = (Buttons_GetStatus() & BUTTONS_BUTTON1) ? CurrentWaveValue : 0; | ||||
| 		#else | ||||
| 			/* Audio sample is ADC value scaled to fit the entire range */ | ||||
| 			AudioSample = ((SAMPLE_MAX_RANGE / ADC_MAX_RANGE) * ADC_GetResult()); | ||||
|  | ||||
| 			#if defined(MICROPHONE_BIASED_TO_HALF_RAIL) | ||||
| 			/* Microphone is biased to half rail voltage, subtract the bias from the sample value */ | ||||
| 			AudioSample -= (SAMPLE_MAX_RANGE / 2); | ||||
| 			#endif | ||||
| 		#endif | ||||
| 		 | ||||
| 		Audio_Device_WriteSample16(&Microphone_Audio_Interface, AudioSample); | ||||
| 	} | ||||
|  | ||||
| 	Endpoint_SelectEndpoint(PrevEndpoint); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
|  | ||||
| 	/* Sample reload timer initialization */ | ||||
| 	TIMSK0  = (1 << OCIE0A); | ||||
| 	OCR0A   = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1); | ||||
| 	TCCR0A  = (1 << WGM01);  // CTC mode | ||||
| 	TCCR0B  = (1 << CS01);   // Fcpu/8 speed | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
| 	/* Stop the sample reload timer */ | ||||
| 	TCCR0B = 0; | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= Audio_Device_ConfigureEndpoints(&Microphone_Audio_Interface); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	Audio_Device_ProcessControlRequest(&Microphone_Audio_Interface); | ||||
| } | ||||
|  | ||||
| /** Audio class driver callback for the setting and retrieval of streaming endpoint properties. This callback must be implemented | ||||
|  *  in the user application to handle property manipulations on streaming audio endpoints. | ||||
|  * | ||||
|  *  When the DataLength parameter is NULL, this callback should only indicate whether the specified operation is valid for | ||||
|  *  the given endpoint index, and should return as fast as possible. When non-NULL, this value may be altered for GET operations | ||||
|  *  to indicate the size of the retreived data. | ||||
|  * | ||||
|  *  \note The length of the retrieved data stored into the Data buffer on GET operations should not exceed the initial value | ||||
|  *        of the \c DataLength parameter. | ||||
|  * | ||||
|  *  \param[in,out] AudioInterfaceInfo  Pointer to a structure containing an Audio Class configuration and state. | ||||
|  *  \param[in]     EndpointProperty    Property of the endpoint to get or set, a value from Audio_ClassRequests_t. | ||||
|  *  \param[in]     EndpointAddress     Address of the streaming endpoint whose property is being referenced. | ||||
|  *  \param[in]     EndpointControl     Parameter of the endpoint to get or set, a value from Audio_EndpointControls_t. | ||||
|  *  \param[in,out] DataLength          For SET operations, the length of the parameter data to set. For GET operations, the maximum | ||||
|  *                                     length of the retrieved data. When NULL, the function should return whether the given property | ||||
|  *                                     and parameter is valid for the requested endpoint without reading or modifying the Data buffer. | ||||
|  *  \param[in,out] Data                Pointer to a location where the parameter data is stored for SET operations, or where | ||||
|  *                                     the retrieved data is to be stored for GET operations. | ||||
|  * | ||||
|  *  \return Boolean true if the property get/set was successful, false otherwise | ||||
|  */ | ||||
| bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, | ||||
|                                                   const uint8_t EndpointProperty, | ||||
|                                                   const uint8_t EndpointAddress, | ||||
|                                                   const uint8_t EndpointControl, | ||||
|                                                   uint16_t* const DataLength, | ||||
|                                                   uint8_t* Data) | ||||
| { | ||||
| 	/* Check the requested endpoint to see if a supported endpoint is being manipulated */ | ||||
| 	if (EndpointAddress == (ENDPOINT_DIR_IN | Microphone_Audio_Interface.Config.DataINEndpointNumber)) | ||||
| 	{ | ||||
| 		/* Check the requested control to see if a supported control is being manipulated */ | ||||
| 		if (EndpointControl == AUDIO_EPCONTROL_SamplingFreq) | ||||
| 		{ | ||||
| 			switch (EndpointProperty) | ||||
| 			{ | ||||
| 				case AUDIO_REQ_SetCurrent: | ||||
| 					/* Check if we are just testing for a valid property, or actually adjusting it */ | ||||
| 					if (DataLength != NULL) | ||||
| 					{ | ||||
| 						/* Set the new sampling frequency to the value given by the host */ | ||||
| 						CurrentAudioSampleFrequency = (((uint32_t)Data[2] << 16) | ((uint32_t)Data[1] << 8) | (uint32_t)Data[0]); | ||||
|  | ||||
| 						/* Adjust sample reload timer to the new frequency */ | ||||
| 						OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1);				 | ||||
| 					} | ||||
| 					 | ||||
| 					return true;				 | ||||
| 				case AUDIO_REQ_GetCurrent: | ||||
| 					/* Check if we are just testing for a valid property, or actually reading it */ | ||||
| 					if (DataLength != NULL) | ||||
| 					{ | ||||
| 						*DataLength = 3; | ||||
|  | ||||
| 						Data[2] = (CurrentAudioSampleFrequency >> 16); | ||||
| 						Data[1] = (CurrentAudioSampleFrequency >> 8); | ||||
| 						Data[0] = (CurrentAudioSampleFrequency &  0xFF);					 | ||||
| 					} | ||||
| 					 | ||||
| 					return true; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	return false; | ||||
| } | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the AudioInput demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "AudioInput.h" | ||||
|  | ||||
| /** LUFA Audio Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all Audio Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_Audio_Device_t Microphone_Audio_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.StreamingInterfaceNumber = 1, | ||||
|  | ||||
| 				.DataINEndpointNumber     = AUDIO_STREAM_EPNUM, | ||||
| 				.DataINEndpointSize       = AUDIO_STREAM_EPSIZE, | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
| /** Current audio sampling frequency of the streaming audio endpoint. */ | ||||
| static uint32_t CurrentAudioSampleFrequency = 48000; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		Audio_Device_USBTask(&Microphone_Audio_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware(void) | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	LEDs_Init(); | ||||
| 	Buttons_Init(); | ||||
| 	ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_32); | ||||
| 	ADC_SetupChannel(MIC_IN_ADC_CHANNEL); | ||||
| 	USB_Init(); | ||||
|  | ||||
| 	/* Start the ADC conversion in free running mode */ | ||||
| 	ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | MIC_IN_ADC_MUX_MASK); | ||||
| } | ||||
|  | ||||
| /** ISR to handle the reloading of the data endpoint with the next sample. */ | ||||
| ISR(TIMER0_COMPA_vect, ISR_BLOCK) | ||||
| { | ||||
| 	uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint(); | ||||
|  | ||||
| 	/* Check that the USB bus is ready for the next sample to write */ | ||||
| 	if (Audio_Device_IsReadyForNextSample(&Microphone_Audio_Interface)) | ||||
| 	{ | ||||
| 		int16_t AudioSample; | ||||
|  | ||||
| 		#if defined(USE_TEST_TONE) | ||||
| 			static uint8_t SquareWaveSampleCount; | ||||
| 			static int16_t CurrentWaveValue; | ||||
| 			 | ||||
| 			/* In test tone mode, generate a square wave at 1/256 of the sample rate */ | ||||
| 			if (SquareWaveSampleCount++ == 0xFF) | ||||
| 			  CurrentWaveValue ^= 0x8000; | ||||
| 			 | ||||
| 			/* Only generate audio if the board button is being pressed */ | ||||
| 			AudioSample = (Buttons_GetStatus() & BUTTONS_BUTTON1) ? CurrentWaveValue : 0; | ||||
| 		#else | ||||
| 			/* Audio sample is ADC value scaled to fit the entire range */ | ||||
| 			AudioSample = ((SAMPLE_MAX_RANGE / ADC_MAX_RANGE) * ADC_GetResult()); | ||||
|  | ||||
| 			#if defined(MICROPHONE_BIASED_TO_HALF_RAIL) | ||||
| 			/* Microphone is biased to half rail voltage, subtract the bias from the sample value */ | ||||
| 			AudioSample -= (SAMPLE_MAX_RANGE / 2); | ||||
| 			#endif | ||||
| 		#endif | ||||
| 		 | ||||
| 		Audio_Device_WriteSample16(&Microphone_Audio_Interface, AudioSample); | ||||
| 	} | ||||
|  | ||||
| 	Endpoint_SelectEndpoint(PrevEndpoint); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
|  | ||||
| 	/* Sample reload timer initialization */ | ||||
| 	TIMSK0  = (1 << OCIE0A); | ||||
| 	OCR0A   = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1); | ||||
| 	TCCR0A  = (1 << WGM01);  // CTC mode | ||||
| 	TCCR0B  = (1 << CS01);   // Fcpu/8 speed | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
| 	/* Stop the sample reload timer */ | ||||
| 	TCCR0B = 0; | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= Audio_Device_ConfigureEndpoints(&Microphone_Audio_Interface); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	Audio_Device_ProcessControlRequest(&Microphone_Audio_Interface); | ||||
| } | ||||
|  | ||||
| /** Audio class driver callback for the setting and retrieval of streaming endpoint properties. This callback must be implemented | ||||
|  *  in the user application to handle property manipulations on streaming audio endpoints. | ||||
|  * | ||||
|  *  When the DataLength parameter is NULL, this callback should only indicate whether the specified operation is valid for | ||||
|  *  the given endpoint index, and should return as fast as possible. When non-NULL, this value may be altered for GET operations | ||||
|  *  to indicate the size of the retreived data. | ||||
|  * | ||||
|  *  \note The length of the retrieved data stored into the Data buffer on GET operations should not exceed the initial value | ||||
|  *        of the \c DataLength parameter. | ||||
|  * | ||||
|  *  \param[in,out] AudioInterfaceInfo  Pointer to a structure containing an Audio Class configuration and state. | ||||
|  *  \param[in]     EndpointProperty    Property of the endpoint to get or set, a value from Audio_ClassRequests_t. | ||||
|  *  \param[in]     EndpointAddress     Address of the streaming endpoint whose property is being referenced. | ||||
|  *  \param[in]     EndpointControl     Parameter of the endpoint to get or set, a value from Audio_EndpointControls_t. | ||||
|  *  \param[in,out] DataLength          For SET operations, the length of the parameter data to set. For GET operations, the maximum | ||||
|  *                                     length of the retrieved data. When NULL, the function should return whether the given property | ||||
|  *                                     and parameter is valid for the requested endpoint without reading or modifying the Data buffer. | ||||
|  *  \param[in,out] Data                Pointer to a location where the parameter data is stored for SET operations, or where | ||||
|  *                                     the retrieved data is to be stored for GET operations. | ||||
|  * | ||||
|  *  \return Boolean true if the property get/set was successful, false otherwise | ||||
|  */ | ||||
| bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, | ||||
|                                                   const uint8_t EndpointProperty, | ||||
|                                                   const uint8_t EndpointAddress, | ||||
|                                                   const uint8_t EndpointControl, | ||||
|                                                   uint16_t* const DataLength, | ||||
|                                                   uint8_t* Data) | ||||
| { | ||||
| 	/* Check the requested endpoint to see if a supported endpoint is being manipulated */ | ||||
| 	if (EndpointAddress == (ENDPOINT_DIR_IN | Microphone_Audio_Interface.Config.DataINEndpointNumber)) | ||||
| 	{ | ||||
| 		/* Check the requested control to see if a supported control is being manipulated */ | ||||
| 		if (EndpointControl == AUDIO_EPCONTROL_SamplingFreq) | ||||
| 		{ | ||||
| 			switch (EndpointProperty) | ||||
| 			{ | ||||
| 				case AUDIO_REQ_SetCurrent: | ||||
| 					/* Check if we are just testing for a valid property, or actually adjusting it */ | ||||
| 					if (DataLength != NULL) | ||||
| 					{ | ||||
| 						/* Set the new sampling frequency to the value given by the host */ | ||||
| 						CurrentAudioSampleFrequency = (((uint32_t)Data[2] << 16) | ((uint32_t)Data[1] << 8) | (uint32_t)Data[0]); | ||||
|  | ||||
| 						/* Adjust sample reload timer to the new frequency */ | ||||
| 						OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1);				 | ||||
| 					} | ||||
| 					 | ||||
| 					return true;				 | ||||
| 				case AUDIO_REQ_GetCurrent: | ||||
| 					/* Check if we are just testing for a valid property, or actually reading it */ | ||||
| 					if (DataLength != NULL) | ||||
| 					{ | ||||
| 						*DataLength = 3; | ||||
|  | ||||
| 						Data[2] = (CurrentAudioSampleFrequency >> 16); | ||||
| 						Data[1] = (CurrentAudioSampleFrequency >> 8); | ||||
| 						Data[0] = (CurrentAudioSampleFrequency &  0xFF);					 | ||||
| 					} | ||||
| 					 | ||||
| 					return true; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	return false; | ||||
| } | ||||
|   | ||||
| @@ -1,87 +1,87 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for AudioInput.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _AUDIO_INPUT_H_ | ||||
| #define _AUDIO_INPUT_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/Board/Buttons.h> | ||||
| 		#include <LUFA/Drivers/Peripheral/ADC.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** ADC channel number for the microphone input. */ | ||||
| 		#define MIC_IN_ADC_CHANNEL        2 | ||||
|  | ||||
| 		/** ADC channel MUX mask for the microphone input. */ | ||||
| 		#define MIC_IN_ADC_MUX_MASK       ADC_CHANNEL2 | ||||
|  | ||||
| 		/** Maximum audio sample value for the microphone input. */ | ||||
| 		#define SAMPLE_MAX_RANGE          0xFFFF | ||||
|  | ||||
| 		/** Maximum ADC range for the microphone input. */ | ||||
| 		#define ADC_MAX_RANGE             0x3FF | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for AudioInput.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _AUDIO_INPUT_H_ | ||||
| #define _AUDIO_INPUT_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/Board/Buttons.h> | ||||
| 		#include <LUFA/Drivers/Peripheral/ADC.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** ADC channel number for the microphone input. */ | ||||
| 		#define MIC_IN_ADC_CHANNEL        2 | ||||
|  | ||||
| 		/** ADC channel MUX mask for the microphone input. */ | ||||
| 		#define MIC_IN_ADC_MUX_MASK       ADC_CHANNEL2 | ||||
|  | ||||
| 		/** Maximum audio sample value for the microphone input. */ | ||||
| 		#define SAMPLE_MAX_RANGE          0xFFFF | ||||
|  | ||||
| 		/** Maximum ADC range for the microphone input. */ | ||||
| 		#define ADC_MAX_RANGE             0x3FF | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,87 +1,87 @@ | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage Audio Input Device Demo | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Audio Class</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>Standard Audio Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF Audio 1.0 Class Specification \n | ||||
|  *        USBIF Audio 1.0 Class Terminal Types Specification \n | ||||
|  *        USBIF Audio 1.0 Data Formats Specification</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Audio demonstration application. This gives a simple reference | ||||
|  *  application for implementing a USB Audio Input device using the | ||||
|  *  basic USB Audio 1.0 drivers in all modern OSes (i.e. no special drivers | ||||
|  *  required). | ||||
|  * | ||||
|  *  On start-up the system will automatically enumerate and function as a  | ||||
|  *  USB microphone. By default, the demo will produce a square wave test tone | ||||
|  *  when the board button is pressed. If USE_TEST_TONE is not defined in the | ||||
|  *  project makefile, incoming audio from the ADC channel 1 will be sampled | ||||
|  *  and sent to the host computer instead. | ||||
|  * | ||||
|  *  When in microphone mode, connect a microphone to the ADC channel 2. | ||||
|  * | ||||
|  *  Under Windows, if a driver request dialogue pops up, select the option | ||||
|  *  to automatically install the appropriate drivers. | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>Define Name:</b></td> | ||||
|  *    <td><b>Location:</b></td> | ||||
|  *    <td><b>Description:</b></td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>USE_TEST_TONE</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>When defined, this alters the demo to produce a square wave test tone when the first board button is pressed | ||||
|  *        instead of sampling the board microphone.</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>MICROPHONE_BIASED_TO_HALF_RAIL</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>When defined, this alters the demo so that the half VCC bias of the microphone input is subtracted.</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage Audio Input Device Demo | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Audio Class</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>Standard Audio Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF Audio 1.0 Class Specification \n | ||||
|  *        USBIF Audio 1.0 Class Terminal Types Specification \n | ||||
|  *        USBIF Audio 1.0 Data Formats Specification</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Audio demonstration application. This gives a simple reference | ||||
|  *  application for implementing a USB Audio Input device using the | ||||
|  *  basic USB Audio 1.0 drivers in all modern OSes (i.e. no special drivers | ||||
|  *  required). | ||||
|  * | ||||
|  *  On start-up the system will automatically enumerate and function as a  | ||||
|  *  USB microphone. By default, the demo will produce a square wave test tone | ||||
|  *  when the board button is pressed. If USE_TEST_TONE is not defined in the | ||||
|  *  project makefile, incoming audio from the ADC channel 1 will be sampled | ||||
|  *  and sent to the host computer instead. | ||||
|  * | ||||
|  *  When in microphone mode, connect a microphone to the ADC channel 2. | ||||
|  * | ||||
|  *  Under Windows, if a driver request dialogue pops up, select the option | ||||
|  *  to automatically install the appropriate drivers. | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>Define Name:</b></td> | ||||
|  *    <td><b>Location:</b></td> | ||||
|  *    <td><b>Description:</b></td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>USE_TEST_TONE</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>When defined, this alters the demo to produce a square wave test tone when the first board button is pressed | ||||
|  *        instead of sampling the board microphone.</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>MICROPHONE_BIASED_TO_HALF_RAIL</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>When defined, this alters the demo so that the half VCC bias of the microphone input is subtracted.</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
|   | ||||
| @@ -1,327 +1,327 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(02.00), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x2047, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.02), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize   = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces          = 2, | ||||
|  | ||||
| 			.ConfigurationNumber      = 1, | ||||
| 			.ConfigurationStrIndex    = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes         = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption      = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_ControlInterface = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber          = 0, | ||||
| 			.AlternateSetting         = 0, | ||||
|  | ||||
| 			.TotalEndpoints           = 0, | ||||
|  | ||||
| 			.Class                    = AUDIO_CSCP_AudioClass, | ||||
| 			.SubClass                 = AUDIO_CSCP_ControlSubclass, | ||||
| 			.Protocol                 = AUDIO_CSCP_ControlProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex        = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_ControlInterface_SPC = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_Header, | ||||
|  | ||||
| 			.ACSpecification          = VERSION_BCD(01.00), | ||||
| 			.TotalLength              = (sizeof(USB_Audio_Descriptor_Interface_AC_t) + | ||||
| 			                             sizeof(USB_Audio_Descriptor_InputTerminal_t) + | ||||
| 			                             sizeof(USB_Audio_Descriptor_OutputTerminal_t)), | ||||
|  | ||||
| 			.InCollection             = 1, | ||||
| 			.InterfaceNumber          = 1, | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_InputTerminal = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_InputTerminal_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_InputTerminal, | ||||
|  | ||||
| 			.TerminalID               = 0x01, | ||||
| 			.TerminalType             = AUDIO_TERMINAL_IN_MIC, | ||||
| 			.AssociatedOutputTerminal = 0x00, | ||||
|  | ||||
| 			.TotalChannels            = 1, | ||||
| 			.ChannelConfig            = 0, | ||||
|  | ||||
| 			.ChannelStrIndex          = NO_DESCRIPTOR, | ||||
| 			.TerminalStrIndex         = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_OutputTerminal = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_OutputTerminal_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_OutputTerminal, | ||||
|  | ||||
| 			.TerminalID               = 0x02, | ||||
| 			.TerminalType             = AUDIO_TERMINAL_STREAMING, | ||||
| 			.AssociatedInputTerminal  = 0x00, | ||||
|  | ||||
| 			.SourceID                 = 0x01, | ||||
|  | ||||
| 			.TerminalStrIndex         = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamInterface_Alt0 = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber          = 1, | ||||
| 			.AlternateSetting         = 0, | ||||
|  | ||||
| 			.TotalEndpoints           = 0, | ||||
|  | ||||
| 			.Class                    = AUDIO_CSCP_AudioClass, | ||||
| 			.SubClass                 = AUDIO_CSCP_AudioStreamingSubclass, | ||||
| 			.Protocol                 = AUDIO_CSCP_StreamingProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex        = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamInterface_Alt1 = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber          = 1, | ||||
| 			.AlternateSetting         = 1, | ||||
|  | ||||
| 			.TotalEndpoints           = 1, | ||||
|  | ||||
| 			.Class                    = AUDIO_CSCP_AudioClass, | ||||
| 			.SubClass                 = AUDIO_CSCP_AudioStreamingSubclass, | ||||
| 			.Protocol                 = AUDIO_CSCP_StreamingProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex        = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamInterface_SPC = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_Interface_AS_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_General, | ||||
|  | ||||
| 			.TerminalLink             = 0x02, | ||||
|  | ||||
| 			.FrameDelay               = 1, | ||||
| 			.AudioFormat              = 0x0001 | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_AudioFormat = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_Format_t) + | ||||
| 			                                     sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates), | ||||
| 			                             .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_FormatType, | ||||
|  | ||||
| 			.FormatType               = 0x01, | ||||
| 			.Channels                 = 0x01, | ||||
|  | ||||
| 			.SubFrameSize             = 0x02, | ||||
| 			.BitResolution            = 16, | ||||
|  | ||||
| 			.TotalDiscreteSampleRates = (sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates) / sizeof(USB_Audio_SampleFreq_t)) | ||||
| 		}, | ||||
| 	 | ||||
| 	.Audio_AudioFormatSampleRates = | ||||
| 		{ | ||||
| 			AUDIO_SAMPLE_FREQ(8000), | ||||
| 			AUDIO_SAMPLE_FREQ(11025), | ||||
| 			AUDIO_SAMPLE_FREQ(22050), | ||||
| 			AUDIO_SAMPLE_FREQ(44100), | ||||
| 			AUDIO_SAMPLE_FREQ(48000), | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamEndpoint = | ||||
| 		{ | ||||
| 			.Endpoint = | ||||
| 				{ | ||||
| 					.Header              = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 					.EndpointAddress     = (ENDPOINT_DIR_IN | AUDIO_STREAM_EPNUM), | ||||
| 					.Attributes          = (EP_TYPE_ISOCHRONOUS | ENDPOINT_ATTR_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 					.EndpointSize        = AUDIO_STREAM_EPSIZE, | ||||
| 					.PollingIntervalMS   = 0x01 | ||||
| 				}, | ||||
|  | ||||
| 			.Refresh                  = 0, | ||||
| 			.SyncEndpointNumber       = 0 | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamEndpoint_SPC = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Spc_t), .Type = DTYPE_CSEndpoint}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSEndpoint_General, | ||||
|  | ||||
| 			.Attributes               = (AUDIO_EP_ACCEPTS_SMALL_PACKETS | AUDIO_EP_SAMPLE_FREQ_CONTROL), | ||||
|  | ||||
| 			.LockDelayUnits           = 0x00, | ||||
| 			.LockDelay                = 0x0000 | ||||
| 		} | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Audio In Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(02.00), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x2047, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.02), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize   = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces          = 2, | ||||
|  | ||||
| 			.ConfigurationNumber      = 1, | ||||
| 			.ConfigurationStrIndex    = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes         = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption      = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_ControlInterface = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber          = 0, | ||||
| 			.AlternateSetting         = 0, | ||||
|  | ||||
| 			.TotalEndpoints           = 0, | ||||
|  | ||||
| 			.Class                    = AUDIO_CSCP_AudioClass, | ||||
| 			.SubClass                 = AUDIO_CSCP_ControlSubclass, | ||||
| 			.Protocol                 = AUDIO_CSCP_ControlProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex        = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_ControlInterface_SPC = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_Header, | ||||
|  | ||||
| 			.ACSpecification          = VERSION_BCD(01.00), | ||||
| 			.TotalLength              = (sizeof(USB_Audio_Descriptor_Interface_AC_t) + | ||||
| 			                             sizeof(USB_Audio_Descriptor_InputTerminal_t) + | ||||
| 			                             sizeof(USB_Audio_Descriptor_OutputTerminal_t)), | ||||
|  | ||||
| 			.InCollection             = 1, | ||||
| 			.InterfaceNumber          = 1, | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_InputTerminal = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_InputTerminal_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_InputTerminal, | ||||
|  | ||||
| 			.TerminalID               = 0x01, | ||||
| 			.TerminalType             = AUDIO_TERMINAL_IN_MIC, | ||||
| 			.AssociatedOutputTerminal = 0x00, | ||||
|  | ||||
| 			.TotalChannels            = 1, | ||||
| 			.ChannelConfig            = 0, | ||||
|  | ||||
| 			.ChannelStrIndex          = NO_DESCRIPTOR, | ||||
| 			.TerminalStrIndex         = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_OutputTerminal = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_OutputTerminal_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_OutputTerminal, | ||||
|  | ||||
| 			.TerminalID               = 0x02, | ||||
| 			.TerminalType             = AUDIO_TERMINAL_STREAMING, | ||||
| 			.AssociatedInputTerminal  = 0x00, | ||||
|  | ||||
| 			.SourceID                 = 0x01, | ||||
|  | ||||
| 			.TerminalStrIndex         = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamInterface_Alt0 = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber          = 1, | ||||
| 			.AlternateSetting         = 0, | ||||
|  | ||||
| 			.TotalEndpoints           = 0, | ||||
|  | ||||
| 			.Class                    = AUDIO_CSCP_AudioClass, | ||||
| 			.SubClass                 = AUDIO_CSCP_AudioStreamingSubclass, | ||||
| 			.Protocol                 = AUDIO_CSCP_StreamingProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex        = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamInterface_Alt1 = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber          = 1, | ||||
| 			.AlternateSetting         = 1, | ||||
|  | ||||
| 			.TotalEndpoints           = 1, | ||||
|  | ||||
| 			.Class                    = AUDIO_CSCP_AudioClass, | ||||
| 			.SubClass                 = AUDIO_CSCP_AudioStreamingSubclass, | ||||
| 			.Protocol                 = AUDIO_CSCP_StreamingProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex        = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamInterface_SPC = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_Interface_AS_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_General, | ||||
|  | ||||
| 			.TerminalLink             = 0x02, | ||||
|  | ||||
| 			.FrameDelay               = 1, | ||||
| 			.AudioFormat              = 0x0001 | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_AudioFormat = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_Format_t) + | ||||
| 			                                     sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates), | ||||
| 			                             .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_FormatType, | ||||
|  | ||||
| 			.FormatType               = 0x01, | ||||
| 			.Channels                 = 0x01, | ||||
|  | ||||
| 			.SubFrameSize             = 0x02, | ||||
| 			.BitResolution            = 16, | ||||
|  | ||||
| 			.TotalDiscreteSampleRates = (sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates) / sizeof(USB_Audio_SampleFreq_t)) | ||||
| 		}, | ||||
| 	 | ||||
| 	.Audio_AudioFormatSampleRates = | ||||
| 		{ | ||||
| 			AUDIO_SAMPLE_FREQ(8000), | ||||
| 			AUDIO_SAMPLE_FREQ(11025), | ||||
| 			AUDIO_SAMPLE_FREQ(22050), | ||||
| 			AUDIO_SAMPLE_FREQ(44100), | ||||
| 			AUDIO_SAMPLE_FREQ(48000), | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamEndpoint = | ||||
| 		{ | ||||
| 			.Endpoint = | ||||
| 				{ | ||||
| 					.Header              = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 					.EndpointAddress     = (ENDPOINT_DIR_IN | AUDIO_STREAM_EPNUM), | ||||
| 					.Attributes          = (EP_TYPE_ISOCHRONOUS | ENDPOINT_ATTR_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 					.EndpointSize        = AUDIO_STREAM_EPSIZE, | ||||
| 					.PollingIntervalMS   = 0x01 | ||||
| 				}, | ||||
|  | ||||
| 			.Refresh                  = 0, | ||||
| 			.SyncEndpointNumber       = 0 | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamEndpoint_SPC = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Spc_t), .Type = DTYPE_CSEndpoint}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSEndpoint_General, | ||||
|  | ||||
| 			.Attributes               = (AUDIO_EP_ACCEPTS_SMALL_PACKETS | AUDIO_EP_SAMPLE_FREQ_CONTROL), | ||||
|  | ||||
| 			.LockDelayUnits           = 0x00, | ||||
| 			.LockDelay                = 0x0000 | ||||
| 		} | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Audio In Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,86 +1,86 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the Audio isochronous streaming data endpoint. */ | ||||
| 		#define AUDIO_STREAM_EPNUM           1 | ||||
|  | ||||
| 		/** Endpoint size in bytes of the Audio isochronous streaming data endpoint. The Windows audio stack requires | ||||
| 		 *  at least 192 bytes for correct output, thus the smaller 128 byte maximum endpoint size on some of the smaller | ||||
| 		 *  USB AVR models will result in unavoidable distorted output. | ||||
| 		 */ | ||||
| 		#define AUDIO_STREAM_EPSIZE          ENDPOINT_MAX_SIZE(AUDIO_STREAM_EPNUM) | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t     Config; | ||||
|  | ||||
| 			// Audio Control Interface | ||||
| 			USB_Descriptor_Interface_t                Audio_ControlInterface; | ||||
| 			USB_Audio_Descriptor_Interface_AC_t       Audio_ControlInterface_SPC; | ||||
| 			USB_Audio_Descriptor_InputTerminal_t      Audio_InputTerminal; | ||||
| 			USB_Audio_Descriptor_OutputTerminal_t     Audio_OutputTerminal; | ||||
|  | ||||
| 			// Audio Streaming Interface | ||||
| 			USB_Descriptor_Interface_t                Audio_StreamInterface_Alt0; | ||||
| 			USB_Descriptor_Interface_t                Audio_StreamInterface_Alt1; | ||||
| 			USB_Audio_Descriptor_Interface_AS_t       Audio_StreamInterface_SPC; | ||||
| 			USB_Audio_Descriptor_Format_t             Audio_AudioFormat; | ||||
| 			USB_Audio_SampleFreq_t                    Audio_AudioFormatSampleRates[5]; | ||||
| 			USB_Audio_Descriptor_StreamEndpoint_Std_t Audio_StreamEndpoint; | ||||
| 			USB_Audio_Descriptor_StreamEndpoint_Spc_t Audio_StreamEndpoint_SPC; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the Audio isochronous streaming data endpoint. */ | ||||
| 		#define AUDIO_STREAM_EPNUM           1 | ||||
|  | ||||
| 		/** Endpoint size in bytes of the Audio isochronous streaming data endpoint. The Windows audio stack requires | ||||
| 		 *  at least 192 bytes for correct output, thus the smaller 128 byte maximum endpoint size on some of the smaller | ||||
| 		 *  USB AVR models will result in unavoidable distorted output. | ||||
| 		 */ | ||||
| 		#define AUDIO_STREAM_EPSIZE          ENDPOINT_MAX_SIZE(AUDIO_STREAM_EPNUM) | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t     Config; | ||||
|  | ||||
| 			// Audio Control Interface | ||||
| 			USB_Descriptor_Interface_t                Audio_ControlInterface; | ||||
| 			USB_Audio_Descriptor_Interface_AC_t       Audio_ControlInterface_SPC; | ||||
| 			USB_Audio_Descriptor_InputTerminal_t      Audio_InputTerminal; | ||||
| 			USB_Audio_Descriptor_OutputTerminal_t     Audio_OutputTerminal; | ||||
|  | ||||
| 			// Audio Streaming Interface | ||||
| 			USB_Descriptor_Interface_t                Audio_StreamInterface_Alt0; | ||||
| 			USB_Descriptor_Interface_t                Audio_StreamInterface_Alt1; | ||||
| 			USB_Audio_Descriptor_Interface_AS_t       Audio_StreamInterface_SPC; | ||||
| 			USB_Audio_Descriptor_Format_t             Audio_AudioFormat; | ||||
| 			USB_Audio_SampleFreq_t                    Audio_AudioFormatSampleRates[5]; | ||||
| 			USB_Audio_Descriptor_StreamEndpoint_Std_t Audio_StreamEndpoint; | ||||
| 			USB_Audio_Descriptor_StreamEndpoint_Spc_t Audio_StreamEndpoint_SPC; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1 +1 @@ | ||||
| <AVRStudio><MANAGEMENT><ProjectName>AudioOutput</ProjectName><Created>13-Jul-2010 15:23:00</Created><LastEdit>13-Jul-2010 15:23:23</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:23:00</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\AudioOutput\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR ONE!</CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>AudioOutput.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>AudioOutput.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>AudioOutput.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
| <AVRStudio><MANAGEMENT><ProjectName>AudioOutput</ProjectName><Created>13-Jul-2010 15:23:00</Created><LastEdit>13-Jul-2010 15:23:23</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:23:00</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\AudioOutput\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR ONE!</CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>AudioOutput.c</SOURCEFILE><SOURCEFILE>Descriptors.c</SOURCEFILE><HEADERFILE>AudioOutput.h</HEADERFILE><HEADERFILE>Descriptors.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>AudioOutput.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
|   | ||||
| @@ -1,272 +1,272 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the AudioOutput demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "AudioOutput.h" | ||||
|  | ||||
| /** LUFA Audio Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all Audio Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_Audio_Device_t Speaker_Audio_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.StreamingInterfaceNumber = 1, | ||||
|  | ||||
| 				.DataOUTEndpointNumber    = AUDIO_STREAM_EPNUM, | ||||
| 				.DataOUTEndpointSize      = AUDIO_STREAM_EPSIZE, | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
| /** Current audio sampling frequency of the streaming audio endpoint. */ | ||||
| static uint32_t CurrentAudioSampleFrequency = 48000; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		Audio_Device_USBTask(&Speaker_Audio_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware(void) | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	LEDs_Init(); | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** ISR to handle the reloading of the PWM timer with the next sample. */ | ||||
| ISR(TIMER0_COMPA_vect, ISR_BLOCK) | ||||
| { | ||||
| 	uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint(); | ||||
| 	 | ||||
| 	/* Check that the USB bus is ready for the next sample to read */ | ||||
| 	if (Audio_Device_IsSampleReceived(&Speaker_Audio_Interface)) | ||||
| 	{ | ||||
| 		/* Retrieve the signed 16-bit left and right audio samples, convert to 8-bit */ | ||||
| 		int8_t LeftSample_8Bit  = (Audio_Device_ReadSample16(&Speaker_Audio_Interface) >> 8); | ||||
| 		int8_t RightSample_8Bit = (Audio_Device_ReadSample16(&Speaker_Audio_Interface) >> 8); | ||||
|  | ||||
| 		/* Mix the two channels together to produce a mono, 8-bit sample */ | ||||
| 		int8_t MixedSample_8Bit = (((int16_t)LeftSample_8Bit + (int16_t)RightSample_8Bit) >> 1); | ||||
|  | ||||
| 		#if defined(AUDIO_OUT_MONO) | ||||
| 		/* Load the sample into the PWM timer channel */ | ||||
| 		OCR3A = (MixedSample_8Bit ^ (1 << 7)); | ||||
| 		#elif defined(AUDIO_OUT_STEREO) | ||||
| 		/* Load the dual 8-bit samples into the PWM timer channels */ | ||||
| 		OCR3A = (LeftSample_8Bit  ^ (1 << 7)); | ||||
| 		OCR3B = (RightSample_8Bit ^ (1 << 7)); | ||||
| 		#elif defined(AUDIO_OUT_PORTC) | ||||
| 		/* Load the 8-bit mixed sample into PORTC */ | ||||
| 		PORTC = MixedSample_8Bit; | ||||
| 		#endif | ||||
|  | ||||
| 		uint8_t LEDMask = LEDS_NO_LEDS; | ||||
|  | ||||
| 		/* Turn on LEDs as the sample amplitude increases */ | ||||
| 		if (MixedSample_8Bit > 16) | ||||
| 		  LEDMask = (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4); | ||||
| 		else if (MixedSample_8Bit > 8) | ||||
| 		  LEDMask = (LEDS_LED1 | LEDS_LED2 | LEDS_LED3); | ||||
| 		else if (MixedSample_8Bit > 4) | ||||
| 		  LEDMask = (LEDS_LED1 | LEDS_LED2); | ||||
| 		else if (MixedSample_8Bit > 2) | ||||
| 		  LEDMask = (LEDS_LED1); | ||||
|  | ||||
| 		LEDs_SetAllLEDs(LEDMask); | ||||
| 	} | ||||
| 	 | ||||
| 	Endpoint_SelectEndpoint(PrevEndpoint);	 | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
|  | ||||
| 	/* Sample reload timer initialization */ | ||||
| 	TIMSK0  = (1 << OCIE0A); | ||||
| 	OCR0A   = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1); | ||||
| 	TCCR0A  = (1 << WGM01);  // CTC mode | ||||
| 	TCCR0B  = (1 << CS01);   // Fcpu/8 speed | ||||
|  | ||||
| 	#if defined(AUDIO_OUT_MONO) | ||||
| 	/* Set speaker as output */ | ||||
| 	DDRC   |= (1 << 6); | ||||
| 	#elif defined(AUDIO_OUT_STEREO) | ||||
| 	/* Set speakers as outputs */ | ||||
| 	DDRC   |= ((1 << 6) | (1 << 5)); | ||||
| 	#elif defined(AUDIO_OUT_PORTC) | ||||
| 	/* Set PORTC as outputs */ | ||||
| 	DDRC   |= 0xFF; | ||||
| 	#endif | ||||
|  | ||||
| 	#if (defined(AUDIO_OUT_MONO) || defined(AUDIO_OUT_STEREO)) | ||||
| 	/* PWM speaker timer initialization */ | ||||
| 	TCCR3A  = ((1 << WGM30) | (1 << COM3A1) | (1 << COM3A0) | ||||
| 	        | (1 << COM3B1) | (1 << COM3B0)); // Set on match, clear on TOP | ||||
| 	TCCR3B  = ((1 << WGM32) | (1 << CS30));  // Fast 8-Bit PWM, F_CPU speed | ||||
| 	#endif | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
|  | ||||
| 	/* Stop the sample reload timer */ | ||||
| 	TCCR0B = 0; | ||||
|  | ||||
| 	#if (defined(AUDIO_OUT_MONO) || defined(AUDIO_OUT_STEREO)) | ||||
| 	/* Stop the PWM generation timer */ | ||||
| 	TCCR3B = 0; | ||||
| 	#endif | ||||
|  | ||||
| 	#if defined(AUDIO_OUT_MONO) | ||||
| 	/* Set speaker as input to reduce current draw */ | ||||
| 	DDRC  &= ~(1 << 6); | ||||
| 	#elif defined(AUDIO_OUT_STEREO) | ||||
| 	/* Set speakers as inputs to reduce current draw */ | ||||
| 	DDRC  &= ~((1 << 6) | (1 << 5)); | ||||
| 	#elif defined(AUDIO_OUT_PORTC) | ||||
| 	/* Set PORTC low */ | ||||
| 	PORTC = 0x00; | ||||
| 	#endif | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= Audio_Device_ConfigureEndpoints(&Speaker_Audio_Interface); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	Audio_Device_ProcessControlRequest(&Speaker_Audio_Interface); | ||||
| } | ||||
|  | ||||
| /** Audio class driver callback for the setting and retrieval of streaming endpoint properties. This callback must be implemented | ||||
|  *  in the user application to handle property manipulations on streaming audio endpoints. | ||||
|  * | ||||
|  *  When the DataLength parameter is NULL, this callback should only indicate whether the specified operation is valid for | ||||
|  *  the given endpoint index, and should return as fast as possible. When non-NULL, this value may be altered for GET operations | ||||
|  *  to indicate the size of the retreived data. | ||||
|  * | ||||
|  *  \note The length of the retrieved data stored into the Data buffer on GET operations should not exceed the initial value | ||||
|  *        of the \c DataLength parameter. | ||||
|  * | ||||
|  *  \param[in,out] AudioInterfaceInfo  Pointer to a structure containing an Audio Class configuration and state. | ||||
|  *  \param[in]     EndpointProperty    Property of the endpoint to get or set, a value from Audio_ClassRequests_t. | ||||
|  *  \param[in]     EndpointAddress     Address of the streaming endpoint whose property is being referenced. | ||||
|  *  \param[in]     EndpointControl     Parameter of the endpoint to get or set, a value from Audio_EndpointControls_t. | ||||
|  *  \param[in,out] DataLength          For SET operations, the length of the parameter data to set. For GET operations, the maximum | ||||
|  *                                     length of the retrieved data. When NULL, the function should return whether the given property | ||||
|  *                                     and parameter is valid for the requested endpoint without reading or modifying the Data buffer. | ||||
|  *  \param[in,out] Data                Pointer to a location where the parameter data is stored for SET operations, or where | ||||
|  *                                     the retrieved data is to be stored for GET operations. | ||||
|  * | ||||
|  *  \return Boolean true if the property get/set was successful, false otherwise | ||||
|  */ | ||||
| bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, | ||||
|                                                   const uint8_t EndpointProperty, | ||||
|                                                   const uint8_t EndpointAddress, | ||||
|                                                   const uint8_t EndpointControl, | ||||
|                                                   uint16_t* const DataLength, | ||||
|                                                   uint8_t* Data) | ||||
| { | ||||
| 	/* Check the requested endpoint to see if a supported endpoint is being manipulated */ | ||||
| 	if (EndpointAddress == (ENDPOINT_DIR_OUT | Speaker_Audio_Interface.Config.DataOUTEndpointNumber)) | ||||
| 	{ | ||||
| 		/* Check the requested control to see if a supported control is being manipulated */ | ||||
| 		if (EndpointControl == AUDIO_EPCONTROL_SamplingFreq) | ||||
| 		{ | ||||
| 			switch (EndpointProperty) | ||||
| 			{ | ||||
| 				case AUDIO_REQ_SetCurrent: | ||||
| 					/* Check if we are just testing for a valid property, or actually adjusting it */ | ||||
| 					if (DataLength != NULL) | ||||
| 					{ | ||||
| 						/* Set the new sampling frequency to the value given by the host */ | ||||
| 						CurrentAudioSampleFrequency = (((uint32_t)Data[2] << 16) | ((uint32_t)Data[1] << 8) | (uint32_t)Data[0]); | ||||
|  | ||||
| 						/* Adjust sample reload timer to the new frequency */ | ||||
| 						OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1);				 | ||||
| 					} | ||||
| 					 | ||||
| 					return true;				 | ||||
| 				case AUDIO_REQ_GetCurrent: | ||||
| 					/* Check if we are just testing for a valid property, or actually reading it */ | ||||
| 					if (DataLength != NULL) | ||||
| 					{ | ||||
| 						*DataLength = 3; | ||||
|  | ||||
| 						Data[2] = (CurrentAudioSampleFrequency >> 16); | ||||
| 						Data[1] = (CurrentAudioSampleFrequency >> 8); | ||||
| 						Data[0] = (CurrentAudioSampleFrequency &  0xFF);					 | ||||
| 					} | ||||
| 					 | ||||
| 					return true; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	return false; | ||||
| } | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the AudioOutput demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "AudioOutput.h" | ||||
|  | ||||
| /** LUFA Audio Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all Audio Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_Audio_Device_t Speaker_Audio_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.StreamingInterfaceNumber = 1, | ||||
|  | ||||
| 				.DataOUTEndpointNumber    = AUDIO_STREAM_EPNUM, | ||||
| 				.DataOUTEndpointSize      = AUDIO_STREAM_EPSIZE, | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
| /** Current audio sampling frequency of the streaming audio endpoint. */ | ||||
| static uint32_t CurrentAudioSampleFrequency = 48000; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		Audio_Device_USBTask(&Speaker_Audio_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware(void) | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	LEDs_Init(); | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** ISR to handle the reloading of the PWM timer with the next sample. */ | ||||
| ISR(TIMER0_COMPA_vect, ISR_BLOCK) | ||||
| { | ||||
| 	uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint(); | ||||
| 	 | ||||
| 	/* Check that the USB bus is ready for the next sample to read */ | ||||
| 	if (Audio_Device_IsSampleReceived(&Speaker_Audio_Interface)) | ||||
| 	{ | ||||
| 		/* Retrieve the signed 16-bit left and right audio samples, convert to 8-bit */ | ||||
| 		int8_t LeftSample_8Bit  = (Audio_Device_ReadSample16(&Speaker_Audio_Interface) >> 8); | ||||
| 		int8_t RightSample_8Bit = (Audio_Device_ReadSample16(&Speaker_Audio_Interface) >> 8); | ||||
|  | ||||
| 		/* Mix the two channels together to produce a mono, 8-bit sample */ | ||||
| 		int8_t MixedSample_8Bit = (((int16_t)LeftSample_8Bit + (int16_t)RightSample_8Bit) >> 1); | ||||
|  | ||||
| 		#if defined(AUDIO_OUT_MONO) | ||||
| 		/* Load the sample into the PWM timer channel */ | ||||
| 		OCR3A = (MixedSample_8Bit ^ (1 << 7)); | ||||
| 		#elif defined(AUDIO_OUT_STEREO) | ||||
| 		/* Load the dual 8-bit samples into the PWM timer channels */ | ||||
| 		OCR3A = (LeftSample_8Bit  ^ (1 << 7)); | ||||
| 		OCR3B = (RightSample_8Bit ^ (1 << 7)); | ||||
| 		#elif defined(AUDIO_OUT_PORTC) | ||||
| 		/* Load the 8-bit mixed sample into PORTC */ | ||||
| 		PORTC = MixedSample_8Bit; | ||||
| 		#endif | ||||
|  | ||||
| 		uint8_t LEDMask = LEDS_NO_LEDS; | ||||
|  | ||||
| 		/* Turn on LEDs as the sample amplitude increases */ | ||||
| 		if (MixedSample_8Bit > 16) | ||||
| 		  LEDMask = (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4); | ||||
| 		else if (MixedSample_8Bit > 8) | ||||
| 		  LEDMask = (LEDS_LED1 | LEDS_LED2 | LEDS_LED3); | ||||
| 		else if (MixedSample_8Bit > 4) | ||||
| 		  LEDMask = (LEDS_LED1 | LEDS_LED2); | ||||
| 		else if (MixedSample_8Bit > 2) | ||||
| 		  LEDMask = (LEDS_LED1); | ||||
|  | ||||
| 		LEDs_SetAllLEDs(LEDMask); | ||||
| 	} | ||||
| 	 | ||||
| 	Endpoint_SelectEndpoint(PrevEndpoint);	 | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
|  | ||||
| 	/* Sample reload timer initialization */ | ||||
| 	TIMSK0  = (1 << OCIE0A); | ||||
| 	OCR0A   = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1); | ||||
| 	TCCR0A  = (1 << WGM01);  // CTC mode | ||||
| 	TCCR0B  = (1 << CS01);   // Fcpu/8 speed | ||||
|  | ||||
| 	#if defined(AUDIO_OUT_MONO) | ||||
| 	/* Set speaker as output */ | ||||
| 	DDRC   |= (1 << 6); | ||||
| 	#elif defined(AUDIO_OUT_STEREO) | ||||
| 	/* Set speakers as outputs */ | ||||
| 	DDRC   |= ((1 << 6) | (1 << 5)); | ||||
| 	#elif defined(AUDIO_OUT_PORTC) | ||||
| 	/* Set PORTC as outputs */ | ||||
| 	DDRC   |= 0xFF; | ||||
| 	#endif | ||||
|  | ||||
| 	#if (defined(AUDIO_OUT_MONO) || defined(AUDIO_OUT_STEREO)) | ||||
| 	/* PWM speaker timer initialization */ | ||||
| 	TCCR3A  = ((1 << WGM30) | (1 << COM3A1) | (1 << COM3A0) | ||||
| 	        | (1 << COM3B1) | (1 << COM3B0)); // Set on match, clear on TOP | ||||
| 	TCCR3B  = ((1 << WGM32) | (1 << CS30));  // Fast 8-Bit PWM, F_CPU speed | ||||
| 	#endif | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
|  | ||||
| 	/* Stop the sample reload timer */ | ||||
| 	TCCR0B = 0; | ||||
|  | ||||
| 	#if (defined(AUDIO_OUT_MONO) || defined(AUDIO_OUT_STEREO)) | ||||
| 	/* Stop the PWM generation timer */ | ||||
| 	TCCR3B = 0; | ||||
| 	#endif | ||||
|  | ||||
| 	#if defined(AUDIO_OUT_MONO) | ||||
| 	/* Set speaker as input to reduce current draw */ | ||||
| 	DDRC  &= ~(1 << 6); | ||||
| 	#elif defined(AUDIO_OUT_STEREO) | ||||
| 	/* Set speakers as inputs to reduce current draw */ | ||||
| 	DDRC  &= ~((1 << 6) | (1 << 5)); | ||||
| 	#elif defined(AUDIO_OUT_PORTC) | ||||
| 	/* Set PORTC low */ | ||||
| 	PORTC = 0x00; | ||||
| 	#endif | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= Audio_Device_ConfigureEndpoints(&Speaker_Audio_Interface); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	Audio_Device_ProcessControlRequest(&Speaker_Audio_Interface); | ||||
| } | ||||
|  | ||||
| /** Audio class driver callback for the setting and retrieval of streaming endpoint properties. This callback must be implemented | ||||
|  *  in the user application to handle property manipulations on streaming audio endpoints. | ||||
|  * | ||||
|  *  When the DataLength parameter is NULL, this callback should only indicate whether the specified operation is valid for | ||||
|  *  the given endpoint index, and should return as fast as possible. When non-NULL, this value may be altered for GET operations | ||||
|  *  to indicate the size of the retreived data. | ||||
|  * | ||||
|  *  \note The length of the retrieved data stored into the Data buffer on GET operations should not exceed the initial value | ||||
|  *        of the \c DataLength parameter. | ||||
|  * | ||||
|  *  \param[in,out] AudioInterfaceInfo  Pointer to a structure containing an Audio Class configuration and state. | ||||
|  *  \param[in]     EndpointProperty    Property of the endpoint to get or set, a value from Audio_ClassRequests_t. | ||||
|  *  \param[in]     EndpointAddress     Address of the streaming endpoint whose property is being referenced. | ||||
|  *  \param[in]     EndpointControl     Parameter of the endpoint to get or set, a value from Audio_EndpointControls_t. | ||||
|  *  \param[in,out] DataLength          For SET operations, the length of the parameter data to set. For GET operations, the maximum | ||||
|  *                                     length of the retrieved data. When NULL, the function should return whether the given property | ||||
|  *                                     and parameter is valid for the requested endpoint without reading or modifying the Data buffer. | ||||
|  *  \param[in,out] Data                Pointer to a location where the parameter data is stored for SET operations, or where | ||||
|  *                                     the retrieved data is to be stored for GET operations. | ||||
|  * | ||||
|  *  \return Boolean true if the property get/set was successful, false otherwise | ||||
|  */ | ||||
| bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo, | ||||
|                                                   const uint8_t EndpointProperty, | ||||
|                                                   const uint8_t EndpointAddress, | ||||
|                                                   const uint8_t EndpointControl, | ||||
|                                                   uint16_t* const DataLength, | ||||
|                                                   uint8_t* Data) | ||||
| { | ||||
| 	/* Check the requested endpoint to see if a supported endpoint is being manipulated */ | ||||
| 	if (EndpointAddress == (ENDPOINT_DIR_OUT | Speaker_Audio_Interface.Config.DataOUTEndpointNumber)) | ||||
| 	{ | ||||
| 		/* Check the requested control to see if a supported control is being manipulated */ | ||||
| 		if (EndpointControl == AUDIO_EPCONTROL_SamplingFreq) | ||||
| 		{ | ||||
| 			switch (EndpointProperty) | ||||
| 			{ | ||||
| 				case AUDIO_REQ_SetCurrent: | ||||
| 					/* Check if we are just testing for a valid property, or actually adjusting it */ | ||||
| 					if (DataLength != NULL) | ||||
| 					{ | ||||
| 						/* Set the new sampling frequency to the value given by the host */ | ||||
| 						CurrentAudioSampleFrequency = (((uint32_t)Data[2] << 16) | ((uint32_t)Data[1] << 8) | (uint32_t)Data[0]); | ||||
|  | ||||
| 						/* Adjust sample reload timer to the new frequency */ | ||||
| 						OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1);				 | ||||
| 					} | ||||
| 					 | ||||
| 					return true;				 | ||||
| 				case AUDIO_REQ_GetCurrent: | ||||
| 					/* Check if we are just testing for a valid property, or actually reading it */ | ||||
| 					if (DataLength != NULL) | ||||
| 					{ | ||||
| 						*DataLength = 3; | ||||
|  | ||||
| 						Data[2] = (CurrentAudioSampleFrequency >> 16); | ||||
| 						Data[1] = (CurrentAudioSampleFrequency >> 8); | ||||
| 						Data[0] = (CurrentAudioSampleFrequency &  0xFF);					 | ||||
| 					} | ||||
| 					 | ||||
| 					return true; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	return false; | ||||
| } | ||||
|   | ||||
| @@ -1,74 +1,74 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for AudioOutput.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _AUDIO_OUTPUT_H_ | ||||
| #define _AUDIO_OUTPUT_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <stdlib.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for AudioOutput.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _AUDIO_OUTPUT_H_ | ||||
| #define _AUDIO_OUTPUT_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <stdlib.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,92 +1,92 @@ | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage Audio Output Device Demo | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Audio Class</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>Standard Audio Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF Audio 1.0 Class Specification \n | ||||
|  *        USBIF Audio 1.0 Class Terminal Types Specification \n | ||||
|  *        USBIF Audio 1.0 Data Formats Specification</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Audio demonstration application. This gives a simple reference | ||||
|  *  application for implementing a USB Audio Output device using the | ||||
|  *  basic USB Audio 1.0 drivers in all modern OSes (i.e. no special drivers | ||||
|  *  required). | ||||
|  * | ||||
|  *  On start-up the system will automatically enumerate and function | ||||
|  *  as a USB speaker. Outgoing audio will output in 8-bit PWM onto | ||||
|  *  the timer 3 output compare channel A for AUDIO_OUT_MONO mode, on | ||||
|  *  timer 3 channels A and B for AUDIO_OUT_STEREO and on PORTC as a signed | ||||
|  *  mono sample for AUDIO_OUT_PORTC. Audio output will also be indicated on | ||||
|  *  the board LEDs in all modes. Decouple audio outputs with a capacitor and | ||||
|  *  attach to a speaker to hear the audio. | ||||
|  * | ||||
|  *  Under Windows, if a driver request dialogue pops up, select the option | ||||
|  *  to automatically install the appropriate drivers. | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>Define Name:</b></td> | ||||
|  *    <td><b>Location:</b></td> | ||||
|  *    <td><b>Description:</b></td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>AUDIO_OUT_STEREO</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>When defined, this outputs the audio samples in stereo to the timer output pins of the microcontroller.</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>AUDIO_OUT_MONO</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>When defined, this outputs the audio samples in mono to the timer output pin of the microcontroller.</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>AUDIO_OUT_PORTC</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>When defined, this outputs the audio samples in mono to port C of the microcontroller, for connection to an | ||||
|  *        external DAC.</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage Audio Output Device Demo | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Audio Class</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>Standard Audio Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF Audio 1.0 Class Specification \n | ||||
|  *        USBIF Audio 1.0 Class Terminal Types Specification \n | ||||
|  *        USBIF Audio 1.0 Data Formats Specification</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Audio demonstration application. This gives a simple reference | ||||
|  *  application for implementing a USB Audio Output device using the | ||||
|  *  basic USB Audio 1.0 drivers in all modern OSes (i.e. no special drivers | ||||
|  *  required). | ||||
|  * | ||||
|  *  On start-up the system will automatically enumerate and function | ||||
|  *  as a USB speaker. Outgoing audio will output in 8-bit PWM onto | ||||
|  *  the timer 3 output compare channel A for AUDIO_OUT_MONO mode, on | ||||
|  *  timer 3 channels A and B for AUDIO_OUT_STEREO and on PORTC as a signed | ||||
|  *  mono sample for AUDIO_OUT_PORTC. Audio output will also be indicated on | ||||
|  *  the board LEDs in all modes. Decouple audio outputs with a capacitor and | ||||
|  *  attach to a speaker to hear the audio. | ||||
|  * | ||||
|  *  Under Windows, if a driver request dialogue pops up, select the option | ||||
|  *  to automatically install the appropriate drivers. | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>Define Name:</b></td> | ||||
|  *    <td><b>Location:</b></td> | ||||
|  *    <td><b>Description:</b></td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>AUDIO_OUT_STEREO</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>When defined, this outputs the audio samples in stereo to the timer output pins of the microcontroller.</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>AUDIO_OUT_MONO</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>When defined, this outputs the audio samples in mono to the timer output pin of the microcontroller.</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>AUDIO_OUT_PORTC</td> | ||||
|  *    <td>Makefile LUFA_OPTS</td> | ||||
|  *    <td>When defined, this outputs the audio samples in mono to port C of the microcontroller, for connection to an | ||||
|  *        external DAC.</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
|   | ||||
| @@ -1,327 +1,327 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(02.00), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x2046, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.02), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize   = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces          = 2, | ||||
|  | ||||
| 			.ConfigurationNumber      = 1, | ||||
| 			.ConfigurationStrIndex    = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes         = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption      = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_ControlInterface = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber          = 0, | ||||
| 			.AlternateSetting         = 0, | ||||
|  | ||||
| 			.TotalEndpoints           = 0, | ||||
|  | ||||
| 			.Class                    = AUDIO_CSCP_AudioClass, | ||||
| 			.SubClass                 = AUDIO_CSCP_ControlSubclass, | ||||
| 			.Protocol                 = AUDIO_CSCP_ControlProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex        = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_ControlInterface_SPC = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_Header, | ||||
|  | ||||
| 			.ACSpecification          = VERSION_BCD(01.00), | ||||
| 			.TotalLength              = (sizeof(USB_Audio_Descriptor_Interface_AC_t) + | ||||
| 			                             sizeof(USB_Audio_Descriptor_InputTerminal_t) + | ||||
| 			                             sizeof(USB_Audio_Descriptor_OutputTerminal_t)), | ||||
|  | ||||
| 			.InCollection             = 1, | ||||
| 			.InterfaceNumber          = 1, | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_InputTerminal = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_InputTerminal_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_InputTerminal, | ||||
|  | ||||
| 			.TerminalID               = 0x01, | ||||
| 			.TerminalType             = AUDIO_TERMINAL_STREAMING, | ||||
| 			.AssociatedOutputTerminal = 0x00, | ||||
|  | ||||
| 			.TotalChannels            = 2, | ||||
| 			.ChannelConfig            = (AUDIO_CHANNEL_LEFT_FRONT | AUDIO_CHANNEL_RIGHT_FRONT), | ||||
|  | ||||
| 			.ChannelStrIndex          = NO_DESCRIPTOR, | ||||
| 			.TerminalStrIndex         = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_OutputTerminal = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_OutputTerminal_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_OutputTerminal, | ||||
|  | ||||
| 			.TerminalID               = 0x02, | ||||
| 			.TerminalType             = AUDIO_TERMINAL_OUT_SPEAKER, | ||||
| 			.AssociatedInputTerminal  = 0x00, | ||||
|  | ||||
| 			.SourceID                 = 0x01, | ||||
|  | ||||
| 			.TerminalStrIndex         = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamInterface_Alt0 = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber          = 1, | ||||
| 			.AlternateSetting         = 0, | ||||
|  | ||||
| 			.TotalEndpoints           = 0, | ||||
|  | ||||
| 			.Class                    = AUDIO_CSCP_AudioClass, | ||||
| 			.SubClass                 = AUDIO_CSCP_AudioStreamingSubclass, | ||||
| 			.Protocol                 = AUDIO_CSCP_StreamingProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex        = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamInterface_Alt1 = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber          = 1, | ||||
| 			.AlternateSetting         = 1, | ||||
|  | ||||
| 			.TotalEndpoints           = 1, | ||||
|  | ||||
| 			.Class                    = AUDIO_CSCP_AudioClass, | ||||
| 			.SubClass                 = AUDIO_CSCP_AudioStreamingSubclass, | ||||
| 			.Protocol                 = AUDIO_CSCP_StreamingProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex        = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamInterface_SPC = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_Interface_AS_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_General, | ||||
|  | ||||
| 			.TerminalLink             = 0x01, | ||||
|  | ||||
| 			.FrameDelay               = 1, | ||||
| 			.AudioFormat              = 0x0001 | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_AudioFormat = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_Format_t) + | ||||
| 			                                     sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates), | ||||
| 			                             .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_FormatType, | ||||
|  | ||||
| 			.FormatType               = 0x01, | ||||
| 			.Channels                 = 0x02, | ||||
|  | ||||
| 			.SubFrameSize             = 0x02, | ||||
| 			.BitResolution            = 16, | ||||
|  | ||||
| 			.TotalDiscreteSampleRates = (sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates) / sizeof(USB_Audio_SampleFreq_t)), | ||||
| 		}, | ||||
| 	 | ||||
| 	.Audio_AudioFormatSampleRates = | ||||
| 		{ | ||||
| 			AUDIO_SAMPLE_FREQ(8000), | ||||
| 			AUDIO_SAMPLE_FREQ(11025), | ||||
| 			AUDIO_SAMPLE_FREQ(22050), | ||||
| 			AUDIO_SAMPLE_FREQ(44100), | ||||
| 			AUDIO_SAMPLE_FREQ(48000), | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamEndpoint = | ||||
| 		{ | ||||
| 			.Endpoint = | ||||
| 				{ | ||||
| 					.Header              = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 					.EndpointAddress     = (ENDPOINT_DIR_OUT | AUDIO_STREAM_EPNUM), | ||||
| 					.Attributes          = (EP_TYPE_ISOCHRONOUS | ENDPOINT_ATTR_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 					.EndpointSize        = AUDIO_STREAM_EPSIZE, | ||||
| 					.PollingIntervalMS   = 0x01 | ||||
| 				}, | ||||
|  | ||||
| 			.Refresh                  = 0, | ||||
| 			.SyncEndpointNumber       = 0 | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamEndpoint_SPC = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Spc_t), .Type = DTYPE_CSEndpoint}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSEndpoint_General, | ||||
|  | ||||
| 			.Attributes               = (AUDIO_EP_ACCEPTS_SMALL_PACKETS | AUDIO_EP_SAMPLE_FREQ_CONTROL), | ||||
|  | ||||
| 			.LockDelayUnits           = 0x00, | ||||
| 			.LockDelay                = 0x0000 | ||||
| 		} | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(19), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Audio Out Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(02.00), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x2046, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.02), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize   = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces          = 2, | ||||
|  | ||||
| 			.ConfigurationNumber      = 1, | ||||
| 			.ConfigurationStrIndex    = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes         = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption      = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_ControlInterface = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber          = 0, | ||||
| 			.AlternateSetting         = 0, | ||||
|  | ||||
| 			.TotalEndpoints           = 0, | ||||
|  | ||||
| 			.Class                    = AUDIO_CSCP_AudioClass, | ||||
| 			.SubClass                 = AUDIO_CSCP_ControlSubclass, | ||||
| 			.Protocol                 = AUDIO_CSCP_ControlProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex        = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_ControlInterface_SPC = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_Header, | ||||
|  | ||||
| 			.ACSpecification          = VERSION_BCD(01.00), | ||||
| 			.TotalLength              = (sizeof(USB_Audio_Descriptor_Interface_AC_t) + | ||||
| 			                             sizeof(USB_Audio_Descriptor_InputTerminal_t) + | ||||
| 			                             sizeof(USB_Audio_Descriptor_OutputTerminal_t)), | ||||
|  | ||||
| 			.InCollection             = 1, | ||||
| 			.InterfaceNumber          = 1, | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_InputTerminal = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_InputTerminal_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_InputTerminal, | ||||
|  | ||||
| 			.TerminalID               = 0x01, | ||||
| 			.TerminalType             = AUDIO_TERMINAL_STREAMING, | ||||
| 			.AssociatedOutputTerminal = 0x00, | ||||
|  | ||||
| 			.TotalChannels            = 2, | ||||
| 			.ChannelConfig            = (AUDIO_CHANNEL_LEFT_FRONT | AUDIO_CHANNEL_RIGHT_FRONT), | ||||
|  | ||||
| 			.ChannelStrIndex          = NO_DESCRIPTOR, | ||||
| 			.TerminalStrIndex         = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_OutputTerminal = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_OutputTerminal_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_OutputTerminal, | ||||
|  | ||||
| 			.TerminalID               = 0x02, | ||||
| 			.TerminalType             = AUDIO_TERMINAL_OUT_SPEAKER, | ||||
| 			.AssociatedInputTerminal  = 0x00, | ||||
|  | ||||
| 			.SourceID                 = 0x01, | ||||
|  | ||||
| 			.TerminalStrIndex         = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamInterface_Alt0 = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber          = 1, | ||||
| 			.AlternateSetting         = 0, | ||||
|  | ||||
| 			.TotalEndpoints           = 0, | ||||
|  | ||||
| 			.Class                    = AUDIO_CSCP_AudioClass, | ||||
| 			.SubClass                 = AUDIO_CSCP_AudioStreamingSubclass, | ||||
| 			.Protocol                 = AUDIO_CSCP_StreamingProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex        = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamInterface_Alt1 = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber          = 1, | ||||
| 			.AlternateSetting         = 1, | ||||
|  | ||||
| 			.TotalEndpoints           = 1, | ||||
|  | ||||
| 			.Class                    = AUDIO_CSCP_AudioClass, | ||||
| 			.SubClass                 = AUDIO_CSCP_AudioStreamingSubclass, | ||||
| 			.Protocol                 = AUDIO_CSCP_StreamingProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex        = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamInterface_SPC = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_Interface_AS_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_General, | ||||
|  | ||||
| 			.TerminalLink             = 0x01, | ||||
|  | ||||
| 			.FrameDelay               = 1, | ||||
| 			.AudioFormat              = 0x0001 | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_AudioFormat = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_Format_t) + | ||||
| 			                                     sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates), | ||||
| 			                             .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSInterface_FormatType, | ||||
|  | ||||
| 			.FormatType               = 0x01, | ||||
| 			.Channels                 = 0x02, | ||||
|  | ||||
| 			.SubFrameSize             = 0x02, | ||||
| 			.BitResolution            = 16, | ||||
|  | ||||
| 			.TotalDiscreteSampleRates = (sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates) / sizeof(USB_Audio_SampleFreq_t)), | ||||
| 		}, | ||||
| 	 | ||||
| 	.Audio_AudioFormatSampleRates = | ||||
| 		{ | ||||
| 			AUDIO_SAMPLE_FREQ(8000), | ||||
| 			AUDIO_SAMPLE_FREQ(11025), | ||||
| 			AUDIO_SAMPLE_FREQ(22050), | ||||
| 			AUDIO_SAMPLE_FREQ(44100), | ||||
| 			AUDIO_SAMPLE_FREQ(48000), | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamEndpoint = | ||||
| 		{ | ||||
| 			.Endpoint = | ||||
| 				{ | ||||
| 					.Header              = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 					.EndpointAddress     = (ENDPOINT_DIR_OUT | AUDIO_STREAM_EPNUM), | ||||
| 					.Attributes          = (EP_TYPE_ISOCHRONOUS | ENDPOINT_ATTR_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 					.EndpointSize        = AUDIO_STREAM_EPSIZE, | ||||
| 					.PollingIntervalMS   = 0x01 | ||||
| 				}, | ||||
|  | ||||
| 			.Refresh                  = 0, | ||||
| 			.SyncEndpointNumber       = 0 | ||||
| 		}, | ||||
|  | ||||
| 	.Audio_StreamEndpoint_SPC = | ||||
| 		{ | ||||
| 			.Header                   = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Spc_t), .Type = DTYPE_CSEndpoint}, | ||||
| 			.Subtype                  = AUDIO_DSUBTYPE_CSEndpoint_General, | ||||
|  | ||||
| 			.Attributes               = (AUDIO_EP_ACCEPTS_SMALL_PACKETS | AUDIO_EP_SAMPLE_FREQ_CONTROL), | ||||
|  | ||||
| 			.LockDelayUnits           = 0x00, | ||||
| 			.LockDelay                = 0x0000 | ||||
| 		} | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(19), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Audio Out Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,85 +1,85 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the Audio isochronous streaming data endpoint. */ | ||||
| 		#define AUDIO_STREAM_EPNUM           1 | ||||
|  | ||||
| 		/** Endpoint size in bytes of the Audio isochronous streaming data endpoint. The Windows audio stack requires | ||||
| 		 *  at least 192 bytes for correct output, thus the smaller 128 byte maximum endpoint size on some of the smaller | ||||
| 		 *  USB AVR models will result in unavoidable distorted output. | ||||
| 		 */ | ||||
| 		#define AUDIO_STREAM_EPSIZE          ENDPOINT_MAX_SIZE(AUDIO_STREAM_EPNUM) | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t     Config; | ||||
|  | ||||
| 			// Audio Control Interface | ||||
| 			USB_Descriptor_Interface_t                Audio_ControlInterface; | ||||
| 			USB_Audio_Descriptor_Interface_AC_t       Audio_ControlInterface_SPC; | ||||
| 			USB_Audio_Descriptor_InputTerminal_t      Audio_InputTerminal; | ||||
| 			USB_Audio_Descriptor_OutputTerminal_t     Audio_OutputTerminal; | ||||
|  | ||||
| 			// Audio Streaming Interface | ||||
| 			USB_Descriptor_Interface_t                Audio_StreamInterface_Alt0; | ||||
| 			USB_Descriptor_Interface_t                Audio_StreamInterface_Alt1; | ||||
| 			USB_Audio_Descriptor_Interface_AS_t       Audio_StreamInterface_SPC; | ||||
| 			USB_Audio_Descriptor_Format_t             Audio_AudioFormat; | ||||
| 			USB_Audio_SampleFreq_t                    Audio_AudioFormatSampleRates[5]; | ||||
| 			USB_Audio_Descriptor_StreamEndpoint_Std_t Audio_StreamEndpoint; | ||||
| 			USB_Audio_Descriptor_StreamEndpoint_Spc_t Audio_StreamEndpoint_SPC; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the Audio isochronous streaming data endpoint. */ | ||||
| 		#define AUDIO_STREAM_EPNUM           1 | ||||
|  | ||||
| 		/** Endpoint size in bytes of the Audio isochronous streaming data endpoint. The Windows audio stack requires | ||||
| 		 *  at least 192 bytes for correct output, thus the smaller 128 byte maximum endpoint size on some of the smaller | ||||
| 		 *  USB AVR models will result in unavoidable distorted output. | ||||
| 		 */ | ||||
| 		#define AUDIO_STREAM_EPSIZE          ENDPOINT_MAX_SIZE(AUDIO_STREAM_EPNUM) | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t     Config; | ||||
|  | ||||
| 			// Audio Control Interface | ||||
| 			USB_Descriptor_Interface_t                Audio_ControlInterface; | ||||
| 			USB_Audio_Descriptor_Interface_AC_t       Audio_ControlInterface_SPC; | ||||
| 			USB_Audio_Descriptor_InputTerminal_t      Audio_InputTerminal; | ||||
| 			USB_Audio_Descriptor_OutputTerminal_t     Audio_OutputTerminal; | ||||
|  | ||||
| 			// Audio Streaming Interface | ||||
| 			USB_Descriptor_Interface_t                Audio_StreamInterface_Alt0; | ||||
| 			USB_Descriptor_Interface_t                Audio_StreamInterface_Alt1; | ||||
| 			USB_Audio_Descriptor_Interface_AS_t       Audio_StreamInterface_SPC; | ||||
| 			USB_Audio_Descriptor_Format_t             Audio_AudioFormat; | ||||
| 			USB_Audio_SampleFreq_t                    Audio_AudioFormatSampleRates[5]; | ||||
| 			USB_Audio_Descriptor_StreamEndpoint_Std_t Audio_StreamEndpoint; | ||||
| 			USB_Audio_Descriptor_StreamEndpoint_Spc_t Audio_StreamEndpoint_SPC; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,386 +1,386 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /* On some devices, there is a factory set internal serial number which can be automatically sent to the host as | ||||
|  * the device's serial number when the Device Descriptor's .SerialNumStrIndex entry is set to USE_INTERNAL_SERIAL. | ||||
|  * This allows the host to track a device across insertions on different ports, allowing them to retain allocated | ||||
|  * resources like COM port numbers and drivers. On demos using this feature, give a warning on unsupported devices | ||||
|  * so that the user can supply their own serial number descriptor instead or remove the USE_INTERNAL_SERIAL value | ||||
|  * from the Device Descriptor (forcing the host to generate a serial number for each device from the VID, PID and | ||||
|  * port location). | ||||
|  */ | ||||
| #if (USE_INTERNAL_SERIAL == NO_DESCRIPTOR) | ||||
| 	#warning USE_INTERNAL_SERIAL is not available on this AVR - please manually construct a device serial descriptor. | ||||
| #endif | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_IADDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_IADDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_IADDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x204E, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = USE_INTERNAL_SERIAL, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 4, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_IAD = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation}, | ||||
|  | ||||
| 			.FirstInterfaceIndex    = 0, | ||||
| 			.TotalInterfaces        = 2, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCClass, | ||||
| 			.SubClass               = CDC_CSCP_ACMSubclass, | ||||
| 			.Protocol               = CDC_CSCP_ATCommandProtocol, | ||||
|  | ||||
| 			.IADStrIndex            = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_CCI_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0, | ||||
| 			.AlternateSetting       = 0, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCClass, | ||||
| 			.SubClass               = CDC_CSCP_ACMSubclass, | ||||
| 			.Protocol               = CDC_CSCP_ATCommandProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_Functional_Header = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = CDC_DSUBTYPE_CSInterface_Header, | ||||
|  | ||||
| 			.CDCSpecification       = VERSION_BCD(01.10), | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_Functional_ACM = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = CDC_DSUBTYPE_CSInterface_ACM, | ||||
|  | ||||
| 			.Capabilities           = 0x06, | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_Functional_Union = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = CDC_DSUBTYPE_CSInterface_Union, | ||||
|  | ||||
| 			.MasterInterfaceNumber  = 0, | ||||
| 			.SlaveInterfaceNumber   = 1, | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_ManagementEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | CDC1_NOTIFICATION_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_NOTIFICATION_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0xFF | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_DCI_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 1, | ||||
| 			.AlternateSetting       = 0, | ||||
|  | ||||
| 			.TotalEndpoints         = 2, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCDataClass, | ||||
| 			.SubClass               = CDC_CSCP_NoDataSubclass, | ||||
| 			.Protocol               = CDC_CSCP_NoDataProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_DataOutEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_OUT | CDC1_RX_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_TXRX_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_DataInEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | CDC1_TX_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_TXRX_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_IAD = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation}, | ||||
|  | ||||
| 			.FirstInterfaceIndex    = 2, | ||||
| 			.TotalInterfaces        = 2, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCClass, | ||||
| 			.SubClass               = CDC_CSCP_ACMSubclass, | ||||
| 			.Protocol               = CDC_CSCP_ATCommandProtocol, | ||||
|  | ||||
| 			.IADStrIndex            = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_CCI_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 2, | ||||
| 			.AlternateSetting       = 0, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCClass, | ||||
| 			.SubClass               = CDC_CSCP_ACMSubclass, | ||||
| 			.Protocol               = CDC_CSCP_ATCommandProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_Functional_Header = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = CDC_DSUBTYPE_CSInterface_Header, | ||||
|  | ||||
| 			.CDCSpecification       = VERSION_BCD(01.10), | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_Functional_ACM = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = CDC_DSUBTYPE_CSInterface_ACM, | ||||
|  | ||||
| 			.Capabilities           = 0x06, | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_Functional_Union = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = CDC_DSUBTYPE_CSInterface_Union, | ||||
|  | ||||
| 			.MasterInterfaceNumber  = 2, | ||||
| 			.SlaveInterfaceNumber   = 3, | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_ManagementEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | CDC2_NOTIFICATION_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_NOTIFICATION_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0xFF | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_DCI_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 3, | ||||
| 			.AlternateSetting       = 0, | ||||
|  | ||||
| 			.TotalEndpoints         = 2, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCDataClass, | ||||
| 			.SubClass               = CDC_CSCP_NoDataSubclass, | ||||
| 			.Protocol               = CDC_CSCP_NoDataProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_DataOutEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_OUT | CDC2_RX_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_TXRX_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_DataInEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | CDC2_TX_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_TXRX_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		} | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Dual CDC Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /* On some devices, there is a factory set internal serial number which can be automatically sent to the host as | ||||
|  * the device's serial number when the Device Descriptor's .SerialNumStrIndex entry is set to USE_INTERNAL_SERIAL. | ||||
|  * This allows the host to track a device across insertions on different ports, allowing them to retain allocated | ||||
|  * resources like COM port numbers and drivers. On demos using this feature, give a warning on unsupported devices | ||||
|  * so that the user can supply their own serial number descriptor instead or remove the USE_INTERNAL_SERIAL value | ||||
|  * from the Device Descriptor (forcing the host to generate a serial number for each device from the VID, PID and | ||||
|  * port location). | ||||
|  */ | ||||
| #if (USE_INTERNAL_SERIAL == NO_DESCRIPTOR) | ||||
| 	#warning USE_INTERNAL_SERIAL is not available on this AVR - please manually construct a device serial descriptor. | ||||
| #endif | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_IADDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_IADDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_IADDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x204E, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = USE_INTERNAL_SERIAL, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 4, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_IAD = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation}, | ||||
|  | ||||
| 			.FirstInterfaceIndex    = 0, | ||||
| 			.TotalInterfaces        = 2, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCClass, | ||||
| 			.SubClass               = CDC_CSCP_ACMSubclass, | ||||
| 			.Protocol               = CDC_CSCP_ATCommandProtocol, | ||||
|  | ||||
| 			.IADStrIndex            = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_CCI_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0, | ||||
| 			.AlternateSetting       = 0, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCClass, | ||||
| 			.SubClass               = CDC_CSCP_ACMSubclass, | ||||
| 			.Protocol               = CDC_CSCP_ATCommandProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_Functional_Header = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = CDC_DSUBTYPE_CSInterface_Header, | ||||
|  | ||||
| 			.CDCSpecification       = VERSION_BCD(01.10), | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_Functional_ACM = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = CDC_DSUBTYPE_CSInterface_ACM, | ||||
|  | ||||
| 			.Capabilities           = 0x06, | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_Functional_Union = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = CDC_DSUBTYPE_CSInterface_Union, | ||||
|  | ||||
| 			.MasterInterfaceNumber  = 0, | ||||
| 			.SlaveInterfaceNumber   = 1, | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_ManagementEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | CDC1_NOTIFICATION_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_NOTIFICATION_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0xFF | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_DCI_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 1, | ||||
| 			.AlternateSetting       = 0, | ||||
|  | ||||
| 			.TotalEndpoints         = 2, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCDataClass, | ||||
| 			.SubClass               = CDC_CSCP_NoDataSubclass, | ||||
| 			.Protocol               = CDC_CSCP_NoDataProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_DataOutEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_OUT | CDC1_RX_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_TXRX_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
|  | ||||
| 	.CDC1_DataInEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | CDC1_TX_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_TXRX_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_IAD = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation}, | ||||
|  | ||||
| 			.FirstInterfaceIndex    = 2, | ||||
| 			.TotalInterfaces        = 2, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCClass, | ||||
| 			.SubClass               = CDC_CSCP_ACMSubclass, | ||||
| 			.Protocol               = CDC_CSCP_ATCommandProtocol, | ||||
|  | ||||
| 			.IADStrIndex            = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_CCI_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 2, | ||||
| 			.AlternateSetting       = 0, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCClass, | ||||
| 			.SubClass               = CDC_CSCP_ACMSubclass, | ||||
| 			.Protocol               = CDC_CSCP_ATCommandProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_Functional_Header = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = CDC_DSUBTYPE_CSInterface_Header, | ||||
|  | ||||
| 			.CDCSpecification       = VERSION_BCD(01.10), | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_Functional_ACM = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = CDC_DSUBTYPE_CSInterface_ACM, | ||||
|  | ||||
| 			.Capabilities           = 0x06, | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_Functional_Union = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface}, | ||||
| 			.Subtype                = CDC_DSUBTYPE_CSInterface_Union, | ||||
|  | ||||
| 			.MasterInterfaceNumber  = 2, | ||||
| 			.SlaveInterfaceNumber   = 3, | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_ManagementEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | CDC2_NOTIFICATION_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_NOTIFICATION_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0xFF | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_DCI_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 3, | ||||
| 			.AlternateSetting       = 0, | ||||
|  | ||||
| 			.TotalEndpoints         = 2, | ||||
|  | ||||
| 			.Class                  = CDC_CSCP_CDCDataClass, | ||||
| 			.SubClass               = CDC_CSCP_NoDataSubclass, | ||||
| 			.Protocol               = CDC_CSCP_NoDataProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_DataOutEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_OUT | CDC2_RX_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_TXRX_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
|  | ||||
| 	.CDC2_DataInEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | CDC2_TX_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = CDC_TXRX_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		} | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Dual CDC Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,111 +1,111 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the first CDC interface's device-to-host data IN endpoint. */ | ||||
| 		#define CDC1_TX_EPNUM                  1 | ||||
|  | ||||
| 		/** Endpoint number of the first CDC interface's host-to-device data OUT endpoint. */ | ||||
| 		#define CDC1_RX_EPNUM                  2 | ||||
|  | ||||
| 		/** Endpoint number of the first CDC interface's device-to-host notification IN endpoint. */ | ||||
| 		#define CDC1_NOTIFICATION_EPNUM        3 | ||||
|  | ||||
| 		/** Endpoint number of the second CDC interface's device-to-host data IN endpoint. */ | ||||
| 		#define CDC2_TX_EPNUM                  4 | ||||
|  | ||||
| 		/** Endpoint number of the second CDC interface's host-to-device data OUT endpoint. */ | ||||
| 		#define CDC2_RX_EPNUM                  5 | ||||
|  | ||||
| 		/** Endpoint number of the second CDC interface's device-to-host notification IN endpoint. */ | ||||
| 		#define CDC2_NOTIFICATION_EPNUM        6 | ||||
|  | ||||
| 		/** Size in bytes of the CDC device-to-host notification IN endpoints. */ | ||||
| 		#define CDC_NOTIFICATION_EPSIZE        8 | ||||
|  | ||||
| 		/** Size in bytes of the CDC data IN and OUT endpoints. */ | ||||
| 		#define CDC_TXRX_EPSIZE                16 | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t    Config; | ||||
|  | ||||
| 			// First CDC Control Interface | ||||
| 			USB_Descriptor_Interface_Association_t   CDC1_IAD; | ||||
| 			USB_Descriptor_Interface_t               CDC1_CCI_Interface; | ||||
| 			USB_CDC_Descriptor_FunctionalHeader_t    CDC1_Functional_Header; | ||||
| 			USB_CDC_Descriptor_FunctionalACM_t       CDC1_Functional_ACM; | ||||
| 			USB_CDC_Descriptor_FunctionalUnion_t     CDC1_Functional_Union; | ||||
| 			USB_Descriptor_Endpoint_t                CDC1_ManagementEndpoint; | ||||
|  | ||||
| 			// First CDC Data Interface | ||||
| 			USB_Descriptor_Interface_t               CDC1_DCI_Interface; | ||||
| 			USB_Descriptor_Endpoint_t                CDC1_DataOutEndpoint; | ||||
| 			USB_Descriptor_Endpoint_t                CDC1_DataInEndpoint; | ||||
|  | ||||
| 			// Second CDC Control Interface | ||||
| 			USB_Descriptor_Interface_Association_t   CDC2_IAD; | ||||
| 			USB_Descriptor_Interface_t               CDC2_CCI_Interface; | ||||
| 			USB_CDC_Descriptor_FunctionalHeader_t    CDC2_Functional_Header; | ||||
| 			USB_CDC_Descriptor_FunctionalACM_t       CDC2_Functional_ACM; | ||||
| 			USB_CDC_Descriptor_FunctionalUnion_t     CDC2_Functional_Union; | ||||
| 			USB_Descriptor_Endpoint_t                CDC2_ManagementEndpoint; | ||||
|  | ||||
| 			// Second CDC Data Interface | ||||
| 			USB_Descriptor_Interface_t               CDC2_DCI_Interface; | ||||
| 			USB_Descriptor_Endpoint_t                CDC2_DataOutEndpoint; | ||||
| 			USB_Descriptor_Endpoint_t                CDC2_DataInEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the first CDC interface's device-to-host data IN endpoint. */ | ||||
| 		#define CDC1_TX_EPNUM                  1 | ||||
|  | ||||
| 		/** Endpoint number of the first CDC interface's host-to-device data OUT endpoint. */ | ||||
| 		#define CDC1_RX_EPNUM                  2 | ||||
|  | ||||
| 		/** Endpoint number of the first CDC interface's device-to-host notification IN endpoint. */ | ||||
| 		#define CDC1_NOTIFICATION_EPNUM        3 | ||||
|  | ||||
| 		/** Endpoint number of the second CDC interface's device-to-host data IN endpoint. */ | ||||
| 		#define CDC2_TX_EPNUM                  4 | ||||
|  | ||||
| 		/** Endpoint number of the second CDC interface's host-to-device data OUT endpoint. */ | ||||
| 		#define CDC2_RX_EPNUM                  5 | ||||
|  | ||||
| 		/** Endpoint number of the second CDC interface's device-to-host notification IN endpoint. */ | ||||
| 		#define CDC2_NOTIFICATION_EPNUM        6 | ||||
|  | ||||
| 		/** Size in bytes of the CDC device-to-host notification IN endpoints. */ | ||||
| 		#define CDC_NOTIFICATION_EPSIZE        8 | ||||
|  | ||||
| 		/** Size in bytes of the CDC data IN and OUT endpoints. */ | ||||
| 		#define CDC_TXRX_EPSIZE                16 | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t    Config; | ||||
|  | ||||
| 			// First CDC Control Interface | ||||
| 			USB_Descriptor_Interface_Association_t   CDC1_IAD; | ||||
| 			USB_Descriptor_Interface_t               CDC1_CCI_Interface; | ||||
| 			USB_CDC_Descriptor_FunctionalHeader_t    CDC1_Functional_Header; | ||||
| 			USB_CDC_Descriptor_FunctionalACM_t       CDC1_Functional_ACM; | ||||
| 			USB_CDC_Descriptor_FunctionalUnion_t     CDC1_Functional_Union; | ||||
| 			USB_Descriptor_Endpoint_t                CDC1_ManagementEndpoint; | ||||
|  | ||||
| 			// First CDC Data Interface | ||||
| 			USB_Descriptor_Interface_t               CDC1_DCI_Interface; | ||||
| 			USB_Descriptor_Endpoint_t                CDC1_DataOutEndpoint; | ||||
| 			USB_Descriptor_Endpoint_t                CDC1_DataInEndpoint; | ||||
|  | ||||
| 			// Second CDC Control Interface | ||||
| 			USB_Descriptor_Interface_Association_t   CDC2_IAD; | ||||
| 			USB_Descriptor_Interface_t               CDC2_CCI_Interface; | ||||
| 			USB_CDC_Descriptor_FunctionalHeader_t    CDC2_Functional_Header; | ||||
| 			USB_CDC_Descriptor_FunctionalACM_t       CDC2_Functional_ACM; | ||||
| 			USB_CDC_Descriptor_FunctionalUnion_t     CDC2_Functional_Union; | ||||
| 			USB_Descriptor_Endpoint_t                CDC2_ManagementEndpoint; | ||||
|  | ||||
| 			// Second CDC Data Interface | ||||
| 			USB_Descriptor_Interface_t               CDC2_DCI_Interface; | ||||
| 			USB_Descriptor_Endpoint_t                CDC2_DataOutEndpoint; | ||||
| 			USB_Descriptor_Endpoint_t                CDC2_DataInEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1 +1 @@ | ||||
| <AVRStudio><MANAGEMENT><ProjectName>DualVirtualSerial</ProjectName><Created>13-Jul-2010 15:24:20</Created><LastEdit>13-Jul-2010 15:25:07</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:24:20</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\DualVirtualSerial\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR ONE!</CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>Descriptors.c</SOURCEFILE><SOURCEFILE>DualVirtualSerial.c</SOURCEFILE><HEADERFILE>Descriptors.h</HEADERFILE><HEADERFILE>DualVirtualSerial.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>DualVirtualSerial.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
| <AVRStudio><MANAGEMENT><ProjectName>DualVirtualSerial</ProjectName><Created>13-Jul-2010 15:24:20</Created><LastEdit>13-Jul-2010 15:25:07</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:24:20</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\DualVirtualSerial\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR ONE!</CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>Descriptors.c</SOURCEFILE><SOURCEFILE>DualVirtualSerial.c</SOURCEFILE><HEADERFILE>Descriptors.h</HEADERFILE><HEADERFILE>DualVirtualSerial.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>DualVirtualSerial.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
|   | ||||
| @@ -1,193 +1,193 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the DualVirtualSerial demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "DualVirtualSerial.h" | ||||
|  | ||||
| /** LUFA CDC Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all CDC Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. This is for the first CDC interface, | ||||
|  *  which sends strings to the host for each joystick movement. | ||||
|  */ | ||||
| USB_ClassInfo_CDC_Device_t VirtualSerial1_CDC_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.ControlInterfaceNumber           = 0, | ||||
|  | ||||
| 				.DataINEndpointNumber             = CDC1_TX_EPNUM, | ||||
| 				.DataINEndpointSize               = CDC_TXRX_EPSIZE, | ||||
| 				.DataINEndpointDoubleBank         = false, | ||||
|  | ||||
| 				.DataOUTEndpointNumber            = CDC1_RX_EPNUM, | ||||
| 				.DataOUTEndpointSize              = CDC_TXRX_EPSIZE, | ||||
| 				.DataOUTEndpointDoubleBank        = false, | ||||
|  | ||||
| 				.NotificationEndpointNumber       = CDC1_NOTIFICATION_EPNUM, | ||||
| 				.NotificationEndpointSize         = CDC_NOTIFICATION_EPSIZE, | ||||
| 				.NotificationEndpointDoubleBank   = false, | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
| /** LUFA CDC Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all CDC Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. This is for the second CDC interface, | ||||
|  *  which echos back all received data from the host. | ||||
|  */ | ||||
| USB_ClassInfo_CDC_Device_t VirtualSerial2_CDC_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.ControlInterfaceNumber           = 2, | ||||
|  | ||||
| 				.DataINEndpointNumber             = CDC2_TX_EPNUM, | ||||
| 				.DataINEndpointSize               = CDC_TXRX_EPSIZE, | ||||
| 				.DataINEndpointDoubleBank         = false, | ||||
|  | ||||
| 				.DataOUTEndpointNumber            = CDC2_RX_EPNUM, | ||||
| 				.DataOUTEndpointSize              = CDC_TXRX_EPSIZE, | ||||
| 				.DataOUTEndpointDoubleBank        = false, | ||||
|  | ||||
| 				.NotificationEndpointNumber       = CDC2_NOTIFICATION_EPNUM, | ||||
| 				.NotificationEndpointSize         = CDC_NOTIFICATION_EPSIZE, | ||||
| 				.NotificationEndpointDoubleBank   = false, | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		CheckJoystickMovement(); | ||||
|  | ||||
| 		/* Discard all received data on the first CDC interface */ | ||||
| 		CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface); | ||||
|  | ||||
| 		/* Echo all received data on the second CDC interface */ | ||||
| 		int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial2_CDC_Interface); | ||||
| 		if (!(ReceivedByte < 0)) | ||||
| 		  CDC_Device_SendByte(&VirtualSerial2_CDC_Interface, (uint8_t)ReceivedByte); | ||||
|  | ||||
| 		CDC_Device_USBTask(&VirtualSerial1_CDC_Interface); | ||||
| 		CDC_Device_USBTask(&VirtualSerial2_CDC_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware(void) | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	Joystick_Init(); | ||||
| 	LEDs_Init(); | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** Checks for changes in the position of the board joystick, sending strings to the host upon each change | ||||
|  *  through the first of the CDC interfaces. | ||||
|  */ | ||||
| void CheckJoystickMovement(void) | ||||
| { | ||||
| 	uint8_t     JoyStatus_LCL = Joystick_GetStatus(); | ||||
| 	char*       ReportString  = NULL; | ||||
| 	static bool ActionSent = false; | ||||
|  | ||||
| 	if (JoyStatus_LCL & JOY_UP) | ||||
| 	  ReportString = "Joystick Up\r\n"; | ||||
| 	else if (JoyStatus_LCL & JOY_DOWN) | ||||
| 	  ReportString = "Joystick Down\r\n"; | ||||
| 	else if (JoyStatus_LCL & JOY_LEFT) | ||||
| 	  ReportString = "Joystick Left\r\n"; | ||||
| 	else if (JoyStatus_LCL & JOY_RIGHT) | ||||
| 	  ReportString = "Joystick Right\r\n"; | ||||
| 	else if (JoyStatus_LCL & JOY_PRESS) | ||||
| 	  ReportString = "Joystick Pressed\r\n"; | ||||
| 	else | ||||
| 	  ActionSent = false; | ||||
|  | ||||
| 	if ((ReportString != NULL) && (ActionSent == false)) | ||||
| 	{ | ||||
| 		ActionSent = true; | ||||
|  | ||||
| 		CDC_Device_SendString(&VirtualSerial1_CDC_Interface, ReportString); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= CDC_Device_ConfigureEndpoints(&VirtualSerial1_CDC_Interface); | ||||
| 	ConfigSuccess &= CDC_Device_ConfigureEndpoints(&VirtualSerial2_CDC_Interface); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	CDC_Device_ProcessControlRequest(&VirtualSerial1_CDC_Interface); | ||||
| 	CDC_Device_ProcessControlRequest(&VirtualSerial2_CDC_Interface); | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the DualVirtualSerial demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "DualVirtualSerial.h" | ||||
|  | ||||
| /** LUFA CDC Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all CDC Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. This is for the first CDC interface, | ||||
|  *  which sends strings to the host for each joystick movement. | ||||
|  */ | ||||
| USB_ClassInfo_CDC_Device_t VirtualSerial1_CDC_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.ControlInterfaceNumber           = 0, | ||||
|  | ||||
| 				.DataINEndpointNumber             = CDC1_TX_EPNUM, | ||||
| 				.DataINEndpointSize               = CDC_TXRX_EPSIZE, | ||||
| 				.DataINEndpointDoubleBank         = false, | ||||
|  | ||||
| 				.DataOUTEndpointNumber            = CDC1_RX_EPNUM, | ||||
| 				.DataOUTEndpointSize              = CDC_TXRX_EPSIZE, | ||||
| 				.DataOUTEndpointDoubleBank        = false, | ||||
|  | ||||
| 				.NotificationEndpointNumber       = CDC1_NOTIFICATION_EPNUM, | ||||
| 				.NotificationEndpointSize         = CDC_NOTIFICATION_EPSIZE, | ||||
| 				.NotificationEndpointDoubleBank   = false, | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
| /** LUFA CDC Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all CDC Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. This is for the second CDC interface, | ||||
|  *  which echos back all received data from the host. | ||||
|  */ | ||||
| USB_ClassInfo_CDC_Device_t VirtualSerial2_CDC_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.ControlInterfaceNumber           = 2, | ||||
|  | ||||
| 				.DataINEndpointNumber             = CDC2_TX_EPNUM, | ||||
| 				.DataINEndpointSize               = CDC_TXRX_EPSIZE, | ||||
| 				.DataINEndpointDoubleBank         = false, | ||||
|  | ||||
| 				.DataOUTEndpointNumber            = CDC2_RX_EPNUM, | ||||
| 				.DataOUTEndpointSize              = CDC_TXRX_EPSIZE, | ||||
| 				.DataOUTEndpointDoubleBank        = false, | ||||
|  | ||||
| 				.NotificationEndpointNumber       = CDC2_NOTIFICATION_EPNUM, | ||||
| 				.NotificationEndpointSize         = CDC_NOTIFICATION_EPSIZE, | ||||
| 				.NotificationEndpointDoubleBank   = false, | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		CheckJoystickMovement(); | ||||
|  | ||||
| 		/* Discard all received data on the first CDC interface */ | ||||
| 		CDC_Device_ReceiveByte(&VirtualSerial1_CDC_Interface); | ||||
|  | ||||
| 		/* Echo all received data on the second CDC interface */ | ||||
| 		int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial2_CDC_Interface); | ||||
| 		if (!(ReceivedByte < 0)) | ||||
| 		  CDC_Device_SendByte(&VirtualSerial2_CDC_Interface, (uint8_t)ReceivedByte); | ||||
|  | ||||
| 		CDC_Device_USBTask(&VirtualSerial1_CDC_Interface); | ||||
| 		CDC_Device_USBTask(&VirtualSerial2_CDC_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware(void) | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	Joystick_Init(); | ||||
| 	LEDs_Init(); | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** Checks for changes in the position of the board joystick, sending strings to the host upon each change | ||||
|  *  through the first of the CDC interfaces. | ||||
|  */ | ||||
| void CheckJoystickMovement(void) | ||||
| { | ||||
| 	uint8_t     JoyStatus_LCL = Joystick_GetStatus(); | ||||
| 	char*       ReportString  = NULL; | ||||
| 	static bool ActionSent = false; | ||||
|  | ||||
| 	if (JoyStatus_LCL & JOY_UP) | ||||
| 	  ReportString = "Joystick Up\r\n"; | ||||
| 	else if (JoyStatus_LCL & JOY_DOWN) | ||||
| 	  ReportString = "Joystick Down\r\n"; | ||||
| 	else if (JoyStatus_LCL & JOY_LEFT) | ||||
| 	  ReportString = "Joystick Left\r\n"; | ||||
| 	else if (JoyStatus_LCL & JOY_RIGHT) | ||||
| 	  ReportString = "Joystick Right\r\n"; | ||||
| 	else if (JoyStatus_LCL & JOY_PRESS) | ||||
| 	  ReportString = "Joystick Pressed\r\n"; | ||||
| 	else | ||||
| 	  ActionSent = false; | ||||
|  | ||||
| 	if ((ReportString != NULL) && (ActionSent == false)) | ||||
| 	{ | ||||
| 		ActionSent = true; | ||||
|  | ||||
| 		CDC_Device_SendString(&VirtualSerial1_CDC_Interface, ReportString); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= CDC_Device_ConfigureEndpoints(&VirtualSerial1_CDC_Interface); | ||||
| 	ConfigSuccess &= CDC_Device_ConfigureEndpoints(&VirtualSerial2_CDC_Interface); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	CDC_Device_ProcessControlRequest(&VirtualSerial1_CDC_Interface); | ||||
| 	CDC_Device_ProcessControlRequest(&VirtualSerial2_CDC_Interface); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,76 +1,76 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for DualVirtualSerial.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DUAL_VIRTUALSERIAL_H_ | ||||
| #define _DUAL_VIRTUALSERIAL_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <string.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/Board/Joystick.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
| 		void CheckJoystickMovement(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for DualVirtualSerial.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DUAL_VIRTUALSERIAL_H_ | ||||
| #define _DUAL_VIRTUALSERIAL_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <string.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/Board/Joystick.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
| 		void CheckJoystickMovement(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,86 +1,86 @@ | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage Dual Communications Device Class (Dual Virtual Serial Port) Device | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Communications Device Class (CDC)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>Abstract Control Model (ACM)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF CDC Class Standard</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF Interface Association Descriptor ECN \n | ||||
|  *        USBIF CDC Class Standard</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Dual Communications Device Class demonstration application. | ||||
|  *  This gives a simple reference application for implementing | ||||
|  *  a composite device with dual CDC functions acting as a pair | ||||
|  *  of virtual serial ports. This demo uses Interface Association | ||||
|  *  Descriptors to link together the pair of related CDC | ||||
|  *  descriptors for each virtual serial port, which may not be | ||||
|  *  supported in all OSes - Windows Vista is supported, as is | ||||
|  *  XP (although the latter may need a hotfix to function). | ||||
|  * | ||||
|  *  Joystick actions are transmitted to the host as strings | ||||
|  *  through the first serial port. The device does not respond to | ||||
|  *  serial data sent from the host in the first serial port. | ||||
|  * | ||||
|  *  The second serial port echoes back data sent from the host. | ||||
|  * | ||||
|  *  After running this demo for the first time on a new computer, | ||||
|  *  you will need to supply the .INF file located in this demo | ||||
|  *  project's directory as the device's driver when running under | ||||
|  *  Windows. This will enable Windows to use its inbuilt CDC drivers, | ||||
|  *  negating the need for custom drivers for the device. Other | ||||
|  *  Operating Systems should automatically use their own inbuilt | ||||
|  *  CDC-ACM drivers. | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td> | ||||
|  *     None | ||||
|  *    </td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage Dual Communications Device Class (Dual Virtual Serial Port) Device | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Communications Device Class (CDC)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>Abstract Control Model (ACM)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF CDC Class Standard</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF Interface Association Descriptor ECN \n | ||||
|  *        USBIF CDC Class Standard</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Dual Communications Device Class demonstration application. | ||||
|  *  This gives a simple reference application for implementing | ||||
|  *  a composite device with dual CDC functions acting as a pair | ||||
|  *  of virtual serial ports. This demo uses Interface Association | ||||
|  *  Descriptors to link together the pair of related CDC | ||||
|  *  descriptors for each virtual serial port, which may not be | ||||
|  *  supported in all OSes - Windows Vista is supported, as is | ||||
|  *  XP (although the latter may need a hotfix to function). | ||||
|  * | ||||
|  *  Joystick actions are transmitted to the host as strings | ||||
|  *  through the first serial port. The device does not respond to | ||||
|  *  serial data sent from the host in the first serial port. | ||||
|  * | ||||
|  *  The second serial port echoes back data sent from the host. | ||||
|  * | ||||
|  *  After running this demo for the first time on a new computer, | ||||
|  *  you will need to supply the .INF file located in this demo | ||||
|  *  project's directory as the device's driver when running under | ||||
|  *  Windows. This will enable Windows to use its inbuilt CDC drivers, | ||||
|  *  negating the need for custom drivers for the device. Other | ||||
|  *  Operating Systems should automatically use their own inbuilt | ||||
|  *  CDC-ACM drivers. | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td> | ||||
|  *     None | ||||
|  *    </td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
|   | ||||
| @@ -1,106 +1,106 @@ | ||||
| ;************************************************************ | ||||
| ; Windows USB CDC ACM Setup File | ||||
| ; Copyright (c) 2000 Microsoft Corporation | ||||
|  | ||||
|  | ||||
| [Version] | ||||
| Signature="$Windows NT$" | ||||
| Class=Ports | ||||
| ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} | ||||
| Provider=%MFGNAME% | ||||
| LayoutFile=layout.inf | ||||
| CatalogFile=%MFGFILENAME%.cat | ||||
| DriverVer=11/15/2007,5.1.2600.0 | ||||
|  | ||||
| [Manufacturer] | ||||
| %MFGNAME%=DeviceList, NTamd64 | ||||
|  | ||||
| [DestinationDirs] | ||||
| DefaultDestDir=12 | ||||
|  | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  Windows 2000/XP/Vista-32bit Sections | ||||
| ;------------------------------------------------------------------------------ | ||||
|  | ||||
| [DriverInstall.nt] | ||||
| include=mdmcpq.inf | ||||
| CopyFiles=DriverCopyFiles.nt | ||||
| AddReg=DriverInstall.nt.AddReg | ||||
|  | ||||
| [DriverCopyFiles.nt] | ||||
| usbser.sys,,,0x20 | ||||
|  | ||||
| [DriverInstall.nt.AddReg] | ||||
| HKR,,DevLoader,,*ntkern | ||||
| HKR,,NTMPDriver,,%DRIVERFILENAME%.sys | ||||
| HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" | ||||
|  | ||||
| [DriverInstall.nt.Services] | ||||
| AddService=usbser, 0x00000002, DriverService.nt | ||||
|  | ||||
| [DriverService.nt] | ||||
| DisplayName=%SERVICE% | ||||
| ServiceType=1 | ||||
| StartType=3 | ||||
| ErrorControl=1 | ||||
| ServiceBinary=%12%\%DRIVERFILENAME%.sys | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  Vista-64bit Sections | ||||
| ;------------------------------------------------------------------------------ | ||||
|  | ||||
| [DriverInstall.NTamd64] | ||||
| include=mdmcpq.inf | ||||
| CopyFiles=DriverCopyFiles.NTamd64 | ||||
| AddReg=DriverInstall.NTamd64.AddReg | ||||
|  | ||||
| [DriverCopyFiles.NTamd64] | ||||
| %DRIVERFILENAME%.sys,,,0x20 | ||||
|  | ||||
| [DriverInstall.NTamd64.AddReg] | ||||
| HKR,,DevLoader,,*ntkern | ||||
| HKR,,NTMPDriver,,%DRIVERFILENAME%.sys | ||||
| HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" | ||||
|  | ||||
| [DriverInstall.NTamd64.Services] | ||||
| AddService=usbser, 0x00000002, DriverService.NTamd64 | ||||
|  | ||||
| [DriverService.NTamd64] | ||||
| DisplayName=%SERVICE% | ||||
| ServiceType=1 | ||||
| StartType=3 | ||||
| ErrorControl=1 | ||||
| ServiceBinary=%12%\%DRIVERFILENAME%.sys | ||||
|  | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  Vendor and Product ID Definitions | ||||
| ;------------------------------------------------------------------------------ | ||||
| ; When developing your USB device, the VID and PID used in the PC side | ||||
| ; application program and the firmware on the microcontroller must match. | ||||
| ; Modify the below line to use your VID and PID.  Use the format as shown below. | ||||
| ; Note: One INF file can be used for multiple devices with different VID and PIDs. | ||||
| ; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line. | ||||
| ;------------------------------------------------------------------------------ | ||||
| [SourceDisksFiles] | ||||
| [SourceDisksNames] | ||||
| [DeviceList] | ||||
| %DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204E&MI_00, USB\VID_03EB&PID_204E&MI_02 | ||||
|  | ||||
| [DeviceList.NTamd64] | ||||
| %DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204E&MI_00, USB\VID_03EB&PID_204E&MI_02 | ||||
|  | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  String Definitions | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;Modify these strings to customize your device | ||||
| ;------------------------------------------------------------------------------ | ||||
| [Strings] | ||||
| MFGFILENAME="CDC_vista" | ||||
| DRIVERFILENAME ="usbser" | ||||
| MFGNAME="http://www.lufa-lib.org" | ||||
| INSTDISK="LUFA Dual CDC Driver Installer" | ||||
| DESCRIPTION="Communications Port" | ||||
| ;************************************************************ | ||||
| ; Windows USB CDC ACM Setup File | ||||
| ; Copyright (c) 2000 Microsoft Corporation | ||||
|  | ||||
|  | ||||
| [Version] | ||||
| Signature="$Windows NT$" | ||||
| Class=Ports | ||||
| ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} | ||||
| Provider=%MFGNAME% | ||||
| LayoutFile=layout.inf | ||||
| CatalogFile=%MFGFILENAME%.cat | ||||
| DriverVer=11/15/2007,5.1.2600.0 | ||||
|  | ||||
| [Manufacturer] | ||||
| %MFGNAME%=DeviceList, NTamd64 | ||||
|  | ||||
| [DestinationDirs] | ||||
| DefaultDestDir=12 | ||||
|  | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  Windows 2000/XP/Vista-32bit Sections | ||||
| ;------------------------------------------------------------------------------ | ||||
|  | ||||
| [DriverInstall.nt] | ||||
| include=mdmcpq.inf | ||||
| CopyFiles=DriverCopyFiles.nt | ||||
| AddReg=DriverInstall.nt.AddReg | ||||
|  | ||||
| [DriverCopyFiles.nt] | ||||
| usbser.sys,,,0x20 | ||||
|  | ||||
| [DriverInstall.nt.AddReg] | ||||
| HKR,,DevLoader,,*ntkern | ||||
| HKR,,NTMPDriver,,%DRIVERFILENAME%.sys | ||||
| HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" | ||||
|  | ||||
| [DriverInstall.nt.Services] | ||||
| AddService=usbser, 0x00000002, DriverService.nt | ||||
|  | ||||
| [DriverService.nt] | ||||
| DisplayName=%SERVICE% | ||||
| ServiceType=1 | ||||
| StartType=3 | ||||
| ErrorControl=1 | ||||
| ServiceBinary=%12%\%DRIVERFILENAME%.sys | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  Vista-64bit Sections | ||||
| ;------------------------------------------------------------------------------ | ||||
|  | ||||
| [DriverInstall.NTamd64] | ||||
| include=mdmcpq.inf | ||||
| CopyFiles=DriverCopyFiles.NTamd64 | ||||
| AddReg=DriverInstall.NTamd64.AddReg | ||||
|  | ||||
| [DriverCopyFiles.NTamd64] | ||||
| %DRIVERFILENAME%.sys,,,0x20 | ||||
|  | ||||
| [DriverInstall.NTamd64.AddReg] | ||||
| HKR,,DevLoader,,*ntkern | ||||
| HKR,,NTMPDriver,,%DRIVERFILENAME%.sys | ||||
| HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" | ||||
|  | ||||
| [DriverInstall.NTamd64.Services] | ||||
| AddService=usbser, 0x00000002, DriverService.NTamd64 | ||||
|  | ||||
| [DriverService.NTamd64] | ||||
| DisplayName=%SERVICE% | ||||
| ServiceType=1 | ||||
| StartType=3 | ||||
| ErrorControl=1 | ||||
| ServiceBinary=%12%\%DRIVERFILENAME%.sys | ||||
|  | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  Vendor and Product ID Definitions | ||||
| ;------------------------------------------------------------------------------ | ||||
| ; When developing your USB device, the VID and PID used in the PC side | ||||
| ; application program and the firmware on the microcontroller must match. | ||||
| ; Modify the below line to use your VID and PID.  Use the format as shown below. | ||||
| ; Note: One INF file can be used for multiple devices with different VID and PIDs. | ||||
| ; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line. | ||||
| ;------------------------------------------------------------------------------ | ||||
| [SourceDisksFiles] | ||||
| [SourceDisksNames] | ||||
| [DeviceList] | ||||
| %DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204E&MI_00, USB\VID_03EB&PID_204E&MI_02 | ||||
|  | ||||
| [DeviceList.NTamd64] | ||||
| %DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204E&MI_00, USB\VID_03EB&PID_204E&MI_02 | ||||
|  | ||||
|  | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;  String Definitions | ||||
| ;------------------------------------------------------------------------------ | ||||
| ;Modify these strings to customize your device | ||||
| ;------------------------------------------------------------------------------ | ||||
| [Strings] | ||||
| MFGFILENAME="CDC_vista" | ||||
| DRIVERFILENAME ="usbser" | ||||
| MFGNAME="http://www.lufa-lib.org" | ||||
| INSTDISK="LUFA Dual CDC Driver Installer" | ||||
| DESCRIPTION="Communications Port" | ||||
| SERVICE="USB RS-232 Emulation Driver" | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,235 +1,235 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** HID class report descriptor. This is a special descriptor constructed with values from the | ||||
|  *  USBIF HID class specification to describe the reports and capabilities of the HID device. This | ||||
|  *  descriptor is parsed by the host and its contents used to determine what data (and in what encoding) | ||||
|  *  the device will send, and what it may be sent back from the host. Refer to the HID specification for | ||||
|  *  more details on HID report descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] = | ||||
| { | ||||
| 	/* Use the HID class driver's standard Vendor HID report. | ||||
| 	 *  Vendor Usage Page: 0 | ||||
| 	 *  Vendor Collection Usage: 1 | ||||
| 	 *  Vendor Report IN Usage: 2 | ||||
| 	 *  Vendor Report OUT Usage: 3 | ||||
| 	 *  Vendor Report Size: GENERIC_REPORT_SIZE | ||||
| 	 */ | ||||
| 	HID_DESCRIPTOR_VENDOR(0x00, 0x01, 0x02, 0x03, GENERIC_REPORT_SIZE) | ||||
| }; | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x204F, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 1, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0x00, | ||||
| 			.AlternateSetting       = 0x00, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = HID_CSCP_HIDClass, | ||||
| 			.SubClass               = HID_CSCP_NonBootSubclass, | ||||
| 			.Protocol               = HID_CSCP_NonBootProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.HID_GenericHID = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||||
|  | ||||
| 			.HIDSpec                = VERSION_BCD(01.11), | ||||
| 			.CountryCode            = 0x00, | ||||
| 			.TotalReportDescriptors = 1, | ||||
| 			.HIDReportType          = HID_DTYPE_Report, | ||||
| 			.HIDReportLength        = sizeof(GenericReport) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_ReportINEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | GENERIC_IN_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = GENERIC_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(21), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Generic HID Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 		case HID_DTYPE_HID: | ||||
| 			Address = &ConfigurationDescriptor.HID_GenericHID; | ||||
| 			Size    = sizeof(USB_HID_Descriptor_HID_t); | ||||
| 			break; | ||||
| 		case HID_DTYPE_Report: | ||||
| 			Address = &GenericReport; | ||||
| 			Size    = sizeof(GenericReport); | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** HID class report descriptor. This is a special descriptor constructed with values from the | ||||
|  *  USBIF HID class specification to describe the reports and capabilities of the HID device. This | ||||
|  *  descriptor is parsed by the host and its contents used to determine what data (and in what encoding) | ||||
|  *  the device will send, and what it may be sent back from the host. Refer to the HID specification for | ||||
|  *  more details on HID report descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] = | ||||
| { | ||||
| 	/* Use the HID class driver's standard Vendor HID report. | ||||
| 	 *  Vendor Usage Page: 0 | ||||
| 	 *  Vendor Collection Usage: 1 | ||||
| 	 *  Vendor Report IN Usage: 2 | ||||
| 	 *  Vendor Report OUT Usage: 3 | ||||
| 	 *  Vendor Report Size: GENERIC_REPORT_SIZE | ||||
| 	 */ | ||||
| 	HID_DESCRIPTOR_VENDOR(0x00, 0x01, 0x02, 0x03, GENERIC_REPORT_SIZE) | ||||
| }; | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x204F, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 1, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0x00, | ||||
| 			.AlternateSetting       = 0x00, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = HID_CSCP_HIDClass, | ||||
| 			.SubClass               = HID_CSCP_NonBootSubclass, | ||||
| 			.Protocol               = HID_CSCP_NonBootProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.HID_GenericHID = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||||
|  | ||||
| 			.HIDSpec                = VERSION_BCD(01.11), | ||||
| 			.CountryCode            = 0x00, | ||||
| 			.TotalReportDescriptors = 1, | ||||
| 			.HIDReportType          = HID_DTYPE_Report, | ||||
| 			.HIDReportLength        = sizeof(GenericReport) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_ReportINEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | GENERIC_IN_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = GENERIC_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(21), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Generic HID Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 		case HID_DTYPE_HID: | ||||
| 			Address = &ConfigurationDescriptor.HID_GenericHID; | ||||
| 			Size    = sizeof(USB_HID_Descriptor_HID_t); | ||||
| 			break; | ||||
| 		case HID_DTYPE_Report: | ||||
| 			Address = &GenericReport; | ||||
| 			Size    = sizeof(GenericReport); | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,76 +1,76 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t Config; | ||||
|  | ||||
| 			// Generic HID Interface | ||||
| 			USB_Descriptor_Interface_t            HID_Interface; | ||||
| 			USB_HID_Descriptor_HID_t              HID_GenericHID; | ||||
| 	        USB_Descriptor_Endpoint_t             HID_ReportINEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the Generic HID reporting IN endpoint. */ | ||||
| 		#define GENERIC_IN_EPNUM          1 | ||||
|  | ||||
| 		/** Size in bytes of the Generic HID reporting endpoint. */ | ||||
| 		#define GENERIC_EPSIZE            8 | ||||
|  | ||||
| 		/** Size in bytes of the Generic HID reports (including report ID byte). */ | ||||
| 		#define GENERIC_REPORT_SIZE       8 | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t Config; | ||||
|  | ||||
| 			// Generic HID Interface | ||||
| 			USB_Descriptor_Interface_t            HID_Interface; | ||||
| 			USB_HID_Descriptor_HID_t              HID_GenericHID; | ||||
| 	        USB_Descriptor_Endpoint_t             HID_ReportINEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the Generic HID reporting IN endpoint. */ | ||||
| 		#define GENERIC_IN_EPNUM          1 | ||||
|  | ||||
| 		/** Size in bytes of the Generic HID reporting endpoint. */ | ||||
| 		#define GENERIC_EPSIZE            8 | ||||
|  | ||||
| 		/** Size in bytes of the Generic HID reports (including report ID byte). */ | ||||
| 		#define GENERIC_REPORT_SIZE       8 | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1 +1 @@ | ||||
| <AVRStudio><MANAGEMENT><ProjectName>GenericHID</ProjectName><Created>13-Jul-2010 15:26:04</Created><LastEdit>13-Jul-2010 15:26:18</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:26:04</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\GenericHID\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR ONE!</CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>Descriptors.c</SOURCEFILE><SOURCEFILE>GenericHID.c</SOURCEFILE><HEADERFILE>Descriptors.h</HEADERFILE><HEADERFILE>GenericHID.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>GenericHID.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
| <AVRStudio><MANAGEMENT><ProjectName>GenericHID</ProjectName><Created>13-Jul-2010 15:26:04</Created><LastEdit>13-Jul-2010 15:26:18</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:26:04</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\GenericHID\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR ONE!</CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>Descriptors.c</SOURCEFILE><SOURCEFILE>GenericHID.c</SOURCEFILE><HEADERFILE>Descriptors.h</HEADERFILE><HEADERFILE>GenericHID.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>GenericHID.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
|   | ||||
| @@ -1,189 +1,189 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the GenericHID demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "GenericHID.h" | ||||
|  | ||||
| /** Buffer to hold the previously generated HID report, for comparison purposes inside the HID class driver. */ | ||||
| static uint8_t PrevHIDReportBuffer[GENERIC_REPORT_SIZE]; | ||||
|  | ||||
| /** LUFA HID Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all HID Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_HID_Device_t Generic_HID_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.InterfaceNumber              = 0, | ||||
|  | ||||
| 				.ReportINEndpointNumber       = GENERIC_IN_EPNUM, | ||||
| 				.ReportINEndpointSize         = GENERIC_EPSIZE, | ||||
| 				.ReportINEndpointDoubleBank   = false, | ||||
|  | ||||
| 				.PrevReportINBuffer           = PrevHIDReportBuffer, | ||||
| 				.PrevReportINBufferSize       = sizeof(PrevHIDReportBuffer), | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		HID_Device_USBTask(&Generic_HID_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware(void) | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	LEDs_Init(); | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= HID_Device_ConfigureEndpoints(&Generic_HID_Interface); | ||||
|  | ||||
| 	USB_Device_EnableSOFEvents(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	HID_Device_ProcessControlRequest(&Generic_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB device Start Of Frame event. */ | ||||
| void EVENT_USB_Device_StartOfFrame(void) | ||||
| { | ||||
| 	HID_Device_MillisecondElapsed(&Generic_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the creation of HID reports to the host. | ||||
|  * | ||||
|  *  \param[in]     HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in,out] ReportID    Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID | ||||
|  *  \param[in]     ReportType  Type of the report to create, either HID_REPORT_ITEM_In or HID_REPORT_ITEM_Feature | ||||
|  *  \param[out]    ReportData  Pointer to a buffer where the created report should be stored | ||||
|  *  \param[out]    ReportSize  Number of bytes written in the report (or zero if no report is to be sent | ||||
|  * | ||||
|  *  \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent | ||||
|  */ | ||||
| bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                          uint8_t* const ReportID, | ||||
|                                          const uint8_t ReportType, | ||||
|                                          void* ReportData, | ||||
|                                          uint16_t* const ReportSize) | ||||
| { | ||||
| 	uint8_t* Data = (uint8_t*)ReportData; | ||||
| 	uint8_t  CurrLEDMask = LEDs_GetLEDs(); | ||||
| 		 | ||||
| 	Data[0] = ((CurrLEDMask & LEDS_LED1) ? 1 : 0); | ||||
| 	Data[1] = ((CurrLEDMask & LEDS_LED2) ? 1 : 0); | ||||
| 	Data[2] = ((CurrLEDMask & LEDS_LED3) ? 1 : 0); | ||||
| 	Data[3] = ((CurrLEDMask & LEDS_LED4) ? 1 : 0); | ||||
|  | ||||
| 	*ReportSize = GENERIC_REPORT_SIZE; | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the processing of HID reports from the host. | ||||
|  * | ||||
|  *  \param[in] HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in] ReportID    Report ID of the received report from the host | ||||
|  *  \param[in] ReportType  The type of report that the host has sent, either HID_REPORT_ITEM_Out or HID_REPORT_ITEM_Feature | ||||
|  *  \param[in] ReportData  Pointer to a buffer where the received report has been stored | ||||
|  *  \param[in] ReportSize  Size in bytes of the received HID report | ||||
|  */ | ||||
| void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                           const uint8_t ReportID, | ||||
|                                           const uint8_t ReportType, | ||||
|                                           const void* ReportData, | ||||
|                                           const uint16_t ReportSize) | ||||
| { | ||||
| 	uint8_t* Data = (uint8_t*)ReportData; | ||||
| 	uint8_t  NewLEDMask = LEDS_NO_LEDS; | ||||
| 	 | ||||
| 	if (Data[0]) | ||||
| 	  NewLEDMask |= LEDS_LED1; | ||||
|  | ||||
| 	if (Data[1]) | ||||
| 	  NewLEDMask |= LEDS_LED1; | ||||
|  | ||||
| 	if (Data[2]) | ||||
| 	  NewLEDMask |= LEDS_LED1; | ||||
|  | ||||
| 	if (Data[3]) | ||||
| 	  NewLEDMask |= LEDS_LED1; | ||||
| 	   | ||||
| 	LEDs_SetAllLEDs(NewLEDMask); | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the GenericHID demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "GenericHID.h" | ||||
|  | ||||
| /** Buffer to hold the previously generated HID report, for comparison purposes inside the HID class driver. */ | ||||
| static uint8_t PrevHIDReportBuffer[GENERIC_REPORT_SIZE]; | ||||
|  | ||||
| /** LUFA HID Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all HID Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_HID_Device_t Generic_HID_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.InterfaceNumber              = 0, | ||||
|  | ||||
| 				.ReportINEndpointNumber       = GENERIC_IN_EPNUM, | ||||
| 				.ReportINEndpointSize         = GENERIC_EPSIZE, | ||||
| 				.ReportINEndpointDoubleBank   = false, | ||||
|  | ||||
| 				.PrevReportINBuffer           = PrevHIDReportBuffer, | ||||
| 				.PrevReportINBufferSize       = sizeof(PrevHIDReportBuffer), | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		HID_Device_USBTask(&Generic_HID_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware(void) | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	LEDs_Init(); | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= HID_Device_ConfigureEndpoints(&Generic_HID_Interface); | ||||
|  | ||||
| 	USB_Device_EnableSOFEvents(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	HID_Device_ProcessControlRequest(&Generic_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB device Start Of Frame event. */ | ||||
| void EVENT_USB_Device_StartOfFrame(void) | ||||
| { | ||||
| 	HID_Device_MillisecondElapsed(&Generic_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the creation of HID reports to the host. | ||||
|  * | ||||
|  *  \param[in]     HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in,out] ReportID    Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID | ||||
|  *  \param[in]     ReportType  Type of the report to create, either HID_REPORT_ITEM_In or HID_REPORT_ITEM_Feature | ||||
|  *  \param[out]    ReportData  Pointer to a buffer where the created report should be stored | ||||
|  *  \param[out]    ReportSize  Number of bytes written in the report (or zero if no report is to be sent | ||||
|  * | ||||
|  *  \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent | ||||
|  */ | ||||
| bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                          uint8_t* const ReportID, | ||||
|                                          const uint8_t ReportType, | ||||
|                                          void* ReportData, | ||||
|                                          uint16_t* const ReportSize) | ||||
| { | ||||
| 	uint8_t* Data = (uint8_t*)ReportData; | ||||
| 	uint8_t  CurrLEDMask = LEDs_GetLEDs(); | ||||
| 		 | ||||
| 	Data[0] = ((CurrLEDMask & LEDS_LED1) ? 1 : 0); | ||||
| 	Data[1] = ((CurrLEDMask & LEDS_LED2) ? 1 : 0); | ||||
| 	Data[2] = ((CurrLEDMask & LEDS_LED3) ? 1 : 0); | ||||
| 	Data[3] = ((CurrLEDMask & LEDS_LED4) ? 1 : 0); | ||||
|  | ||||
| 	*ReportSize = GENERIC_REPORT_SIZE; | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the processing of HID reports from the host. | ||||
|  * | ||||
|  *  \param[in] HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in] ReportID    Report ID of the received report from the host | ||||
|  *  \param[in] ReportType  The type of report that the host has sent, either HID_REPORT_ITEM_Out or HID_REPORT_ITEM_Feature | ||||
|  *  \param[in] ReportData  Pointer to a buffer where the received report has been stored | ||||
|  *  \param[in] ReportSize  Size in bytes of the received HID report | ||||
|  */ | ||||
| void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                           const uint8_t ReportID, | ||||
|                                           const uint8_t ReportType, | ||||
|                                           const void* ReportData, | ||||
|                                           const uint16_t ReportSize) | ||||
| { | ||||
| 	uint8_t* Data = (uint8_t*)ReportData; | ||||
| 	uint8_t  NewLEDMask = LEDS_NO_LEDS; | ||||
| 	 | ||||
| 	if (Data[0]) | ||||
| 	  NewLEDMask |= LEDS_LED1; | ||||
|  | ||||
| 	if (Data[1]) | ||||
| 	  NewLEDMask |= LEDS_LED1; | ||||
|  | ||||
| 	if (Data[2]) | ||||
| 	  NewLEDMask |= LEDS_LED1; | ||||
|  | ||||
| 	if (Data[3]) | ||||
| 	  NewLEDMask |= LEDS_LED1; | ||||
| 	   | ||||
| 	LEDs_SetAllLEDs(NewLEDMask); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,86 +1,86 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for GenericHID.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _GENERICHID_H_ | ||||
| #define _GENERICHID_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <string.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
| 		void EVENT_USB_Device_StartOfFrame(void); | ||||
|  | ||||
| 		bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                         uint8_t* const ReportID, | ||||
| 		                                         const uint8_t ReportType, | ||||
| 		                                         void* ReportData, | ||||
| 		                                         uint16_t* const ReportSize); | ||||
| 		void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                          const uint8_t ReportID, | ||||
| 		                                          const uint8_t ReportType, | ||||
| 		                                          const void* ReportData, | ||||
| 		                                          const uint16_t ReportSize); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for GenericHID.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _GENERICHID_H_ | ||||
| #define _GENERICHID_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <string.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
| 		void EVENT_USB_Device_StartOfFrame(void); | ||||
|  | ||||
| 		bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                         uint8_t* const ReportID, | ||||
| 		                                         const uint8_t ReportType, | ||||
| 		                                         void* ReportData, | ||||
| 		                                         uint16_t* const ReportSize); | ||||
| 		void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                          const uint8_t ReportID, | ||||
| 		                                          const uint8_t ReportType, | ||||
| 		                                          const void* ReportData, | ||||
| 		                                          const uint16_t ReportSize); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,76 +1,76 @@ | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage Generic HID Device | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  *  - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Human Interface Device (HID)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>N/A</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF HID Specification \n | ||||
|  *        USBIF HID Usage Tables</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Low Speed Mode \n | ||||
|  *        Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Generic HID device demonstration application. This gives a simple reference application | ||||
|  *  for implementing a generic HID device, using the basic USB HID drivers in all modern | ||||
|  *  OSes (i.e. no special drivers required). By default it accepts and sends up to 8 byte reports | ||||
|  *  to and from a USB Host, and transmits the last sent report back to the host. | ||||
|  * | ||||
|  *  On start-up the system will automatically enumerate and function as a vendor HID device. | ||||
|  *  When controlled by a custom HID class application, reports can be sent and received by | ||||
|  *  both the standard data endpoint and control request methods defined in the HID specification. | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>Define Name:</b></td> | ||||
|  *    <td><b>Location:</b></td> | ||||
|  *    <td><b>Description:</b></td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>GENERIC_REPORT_SIZE</td> | ||||
|  *    <td>Descriptors.h</td> | ||||
|  *    <td>This token defines the size of the device reports, both sent and received. The value must be an | ||||
|  *        integer ranging from 1 to 255.</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage Generic HID Device | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  *  - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Human Interface Device (HID)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>N/A</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF HID Specification \n | ||||
|  *        USBIF HID Usage Tables</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Low Speed Mode \n | ||||
|  *        Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Generic HID device demonstration application. This gives a simple reference application | ||||
|  *  for implementing a generic HID device, using the basic USB HID drivers in all modern | ||||
|  *  OSes (i.e. no special drivers required). By default it accepts and sends up to 8 byte reports | ||||
|  *  to and from a USB Host, and transmits the last sent report back to the host. | ||||
|  * | ||||
|  *  On start-up the system will automatically enumerate and function as a vendor HID device. | ||||
|  *  When controlled by a custom HID class application, reports can be sent and received by | ||||
|  *  both the standard data endpoint and control request methods defined in the HID specification. | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>Define Name:</b></td> | ||||
|  *    <td><b>Location:</b></td> | ||||
|  *    <td><b>Description:</b></td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td>GENERIC_REPORT_SIZE</td> | ||||
|  *    <td>Descriptors.h</td> | ||||
|  *    <td>This token defines the size of the device reports, both sent and received. The value must be an | ||||
|  *        integer ranging from 1 to 255.</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,236 +1,236 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** HID class report descriptor. This is a special descriptor constructed with values from the | ||||
|  *  USBIF HID class specification to describe the reports and capabilities of the HID device. This | ||||
|  *  descriptor is parsed by the host and its contents used to determine what data (and in what encoding) | ||||
|  *  the device will send, and what it may be sent back from the host. Refer to the HID specification for | ||||
|  *  more details on HID report descriptors. | ||||
|  */  | ||||
| const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] = | ||||
| { | ||||
| 	/* Use the HID class driver's standard Joystick report. | ||||
| 	 *   Number of Axis: 2 (X/Y) | ||||
| 	 *   Min X/Y Axis values: -100 | ||||
| 	 *   Max X/Y Axis values:  100 | ||||
| 	 *   Min physical X/Y Axis values (used to determine resolution): -1 | ||||
| 	 *   Max physical X/Y Axis values (used to determine resolution):  1 | ||||
| 	 *   Buttons: 2 | ||||
| 	 */ | ||||
| 	HID_DESCRIPTOR_JOYSTICK(2, -100, 100, -1, 1, 2) | ||||
| }; | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x2043, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 1, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0x00, | ||||
| 			.AlternateSetting       = 0x00, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = HID_CSCP_HIDClass, | ||||
| 			.SubClass               = HID_CSCP_NonBootSubclass, | ||||
| 			.Protocol               = HID_CSCP_NonBootProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.HID_JoystickHID = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||||
|  | ||||
| 			.HIDSpec                = VERSION_BCD(01.11), | ||||
| 			.CountryCode            = 0x00, | ||||
| 			.TotalReportDescriptors = 1, | ||||
| 			.HIDReportType          = HID_DTYPE_Report, | ||||
| 			.HIDReportLength        = sizeof(JoystickReport) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_ReportINEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | JOYSTICK_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = JOYSTICK_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		} | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Joystick Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 		case HID_DTYPE_HID: | ||||
| 			Address = &ConfigurationDescriptor.HID_JoystickHID; | ||||
| 			Size    = sizeof(USB_HID_Descriptor_HID_t); | ||||
| 			break; | ||||
| 		case HID_DTYPE_Report: | ||||
| 			Address = &JoystickReport; | ||||
| 			Size    = sizeof(JoystickReport); | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** HID class report descriptor. This is a special descriptor constructed with values from the | ||||
|  *  USBIF HID class specification to describe the reports and capabilities of the HID device. This | ||||
|  *  descriptor is parsed by the host and its contents used to determine what data (and in what encoding) | ||||
|  *  the device will send, and what it may be sent back from the host. Refer to the HID specification for | ||||
|  *  more details on HID report descriptors. | ||||
|  */  | ||||
| const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] = | ||||
| { | ||||
| 	/* Use the HID class driver's standard Joystick report. | ||||
| 	 *   Number of Axis: 2 (X/Y) | ||||
| 	 *   Min X/Y Axis values: -100 | ||||
| 	 *   Max X/Y Axis values:  100 | ||||
| 	 *   Min physical X/Y Axis values (used to determine resolution): -1 | ||||
| 	 *   Max physical X/Y Axis values (used to determine resolution):  1 | ||||
| 	 *   Buttons: 2 | ||||
| 	 */ | ||||
| 	HID_DESCRIPTOR_JOYSTICK(2, -100, 100, -1, 1, 2) | ||||
| }; | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x2043, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 1, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0x00, | ||||
| 			.AlternateSetting       = 0x00, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = HID_CSCP_HIDClass, | ||||
| 			.SubClass               = HID_CSCP_NonBootSubclass, | ||||
| 			.Protocol               = HID_CSCP_NonBootProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.HID_JoystickHID = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||||
|  | ||||
| 			.HIDSpec                = VERSION_BCD(01.11), | ||||
| 			.CountryCode            = 0x00, | ||||
| 			.TotalReportDescriptors = 1, | ||||
| 			.HIDReportType          = HID_DTYPE_Report, | ||||
| 			.HIDReportLength        = sizeof(JoystickReport) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_ReportINEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | JOYSTICK_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = JOYSTICK_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		} | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Joystick Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 		case HID_DTYPE_HID: | ||||
| 			Address = &ConfigurationDescriptor.HID_JoystickHID; | ||||
| 			Size    = sizeof(USB_HID_Descriptor_HID_t); | ||||
| 			break; | ||||
| 		case HID_DTYPE_Report: | ||||
| 			Address = &JoystickReport; | ||||
| 			Size    = sizeof(JoystickReport); | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,73 +1,73 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t Config; | ||||
|  | ||||
| 			// Joystick HID Interface | ||||
| 			USB_Descriptor_Interface_t            HID_Interface; | ||||
| 			USB_HID_Descriptor_HID_t              HID_JoystickHID; | ||||
| 	        USB_Descriptor_Endpoint_t             HID_ReportINEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the Joystick HID reporting IN endpoint. */ | ||||
| 		#define JOYSTICK_EPNUM               1 | ||||
|  | ||||
| 		/** Size in bytes of the Joystick HID reporting IN endpoint. */ | ||||
| 		#define JOYSTICK_EPSIZE              8 | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t Config; | ||||
|  | ||||
| 			// Joystick HID Interface | ||||
| 			USB_Descriptor_Interface_t            HID_Interface; | ||||
| 			USB_HID_Descriptor_HID_t              HID_JoystickHID; | ||||
| 	        USB_Descriptor_Endpoint_t             HID_ReportINEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the Joystick HID reporting IN endpoint. */ | ||||
| 		#define JOYSTICK_EPNUM               1 | ||||
|  | ||||
| 		/** Size in bytes of the Joystick HID reporting IN endpoint. */ | ||||
| 		#define JOYSTICK_EPSIZE              8 | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1 +1 @@ | ||||
| <AVRStudio><MANAGEMENT><ProjectName>Joystick</ProjectName><Created>13-Jul-2010 15:27:08</Created><LastEdit>13-Jul-2010 15:27:41</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:27:08</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\Joystick\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>Descriptors.c</SOURCEFILE><SOURCEFILE>Joystick.c</SOURCEFILE><HEADERFILE>Descriptors.h</HEADERFILE><HEADERFILE>Joystick.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>Joystick.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><ProjectFiles><Files><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\Joystick\Descriptors.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\Joystick\Joystick.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\Joystick\Descriptors.c</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\Joystick\Joystick.c</Name></Files></ProjectFiles><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
| <AVRStudio><MANAGEMENT><ProjectName>Joystick</ProjectName><Created>13-Jul-2010 15:27:08</Created><LastEdit>13-Jul-2010 15:27:41</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:27:08</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\Joystick\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>Descriptors.c</SOURCEFILE><SOURCEFILE>Joystick.c</SOURCEFILE><HEADERFILE>Descriptors.h</HEADERFILE><HEADERFILE>Joystick.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>Joystick.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><ProjectFiles><Files><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\Joystick\Descriptors.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\Joystick\Joystick.h</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\Joystick\Descriptors.c</Name><Name>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\Joystick\Joystick.c</Name></Files></ProjectFiles><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
|   | ||||
| @@ -1,189 +1,189 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the Joystick demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "Joystick.h" | ||||
|  | ||||
| /** Buffer to hold the previously generated HID report, for comparison purposes inside the HID class driver. */ | ||||
| static uint8_t PrevJoystickHIDReportBuffer[sizeof(USB_JoystickReport_Data_t)]; | ||||
|  | ||||
| /** LUFA HID Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all HID Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_HID_Device_t Joystick_HID_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.InterfaceNumber              = 0, | ||||
|  | ||||
| 				.ReportINEndpointNumber       = JOYSTICK_EPNUM, | ||||
| 				.ReportINEndpointSize         = JOYSTICK_EPSIZE, | ||||
| 				.ReportINEndpointDoubleBank   = false, | ||||
|  | ||||
| 				.PrevReportINBuffer           = PrevJoystickHIDReportBuffer, | ||||
| 				.PrevReportINBufferSize       = sizeof(PrevJoystickHIDReportBuffer), | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		HID_Device_USBTask(&Joystick_HID_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware(void) | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	Joystick_Init(); | ||||
| 	LEDs_Init(); | ||||
| 	Buttons_Init(); | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= HID_Device_ConfigureEndpoints(&Joystick_HID_Interface); | ||||
|  | ||||
| 	USB_Device_EnableSOFEvents(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	HID_Device_ProcessControlRequest(&Joystick_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB device Start Of Frame event. */ | ||||
| void EVENT_USB_Device_StartOfFrame(void) | ||||
| { | ||||
| 	HID_Device_MillisecondElapsed(&Joystick_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the creation of HID reports to the host. | ||||
|  * | ||||
|  *  \param[in]     HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in,out] ReportID    Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID | ||||
|  *  \param[in]     ReportType  Type of the report to create, either HID_REPORT_ITEM_In or HID_REPORT_ITEM_Feature | ||||
|  *  \param[out]    ReportData  Pointer to a buffer where the created report should be stored | ||||
|  *  \param[out]    ReportSize  Number of bytes written in the report (or zero if no report is to be sent | ||||
|  * | ||||
|  *  \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent | ||||
|  */ | ||||
| bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                          uint8_t* const ReportID, | ||||
|                                          const uint8_t ReportType, | ||||
|                                          void* ReportData, | ||||
|                                          uint16_t* const ReportSize) | ||||
| { | ||||
| 	USB_JoystickReport_Data_t* JoystickReport = (USB_JoystickReport_Data_t*)ReportData; | ||||
|  | ||||
| 	uint8_t JoyStatus_LCL    = Joystick_GetStatus(); | ||||
| 	uint8_t ButtonStatus_LCL = Buttons_GetStatus(); | ||||
|  | ||||
| 	if (JoyStatus_LCL & JOY_UP) | ||||
| 	  JoystickReport->Y = -100; | ||||
| 	else if (JoyStatus_LCL & JOY_DOWN) | ||||
| 	  JoystickReport->Y =  100; | ||||
|  | ||||
| 	if (JoyStatus_LCL & JOY_LEFT) | ||||
| 	  JoystickReport->X = -100; | ||||
| 	else if (JoyStatus_LCL & JOY_RIGHT) | ||||
| 	  JoystickReport->X =  100; | ||||
|  | ||||
| 	if (JoyStatus_LCL & JOY_PRESS) | ||||
| 	  JoystickReport->Button |= (1 << 1); | ||||
|  | ||||
| 	if (ButtonStatus_LCL & BUTTONS_BUTTON1) | ||||
| 	  JoystickReport->Button |= (1 << 0); | ||||
|  | ||||
| 	*ReportSize = sizeof(USB_JoystickReport_Data_t); | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the processing of HID reports from the host. | ||||
|  * | ||||
|  *  \param[in] HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in] ReportID    Report ID of the received report from the host | ||||
|  *  \param[in] ReportType  The type of report that the host has sent, either HID_REPORT_ITEM_Out or HID_REPORT_ITEM_Feature | ||||
|  *  \param[in] ReportData  Pointer to a buffer where the received report has been stored | ||||
|  *  \param[in] ReportSize  Size in bytes of the received HID report | ||||
|  */ | ||||
| void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                           const uint8_t ReportID, | ||||
|                                           const uint8_t ReportType, | ||||
|                                           const void* ReportData, | ||||
|                                           const uint16_t ReportSize) | ||||
| { | ||||
| 	// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the Joystick demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "Joystick.h" | ||||
|  | ||||
| /** Buffer to hold the previously generated HID report, for comparison purposes inside the HID class driver. */ | ||||
| static uint8_t PrevJoystickHIDReportBuffer[sizeof(USB_JoystickReport_Data_t)]; | ||||
|  | ||||
| /** LUFA HID Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all HID Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_HID_Device_t Joystick_HID_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.InterfaceNumber              = 0, | ||||
|  | ||||
| 				.ReportINEndpointNumber       = JOYSTICK_EPNUM, | ||||
| 				.ReportINEndpointSize         = JOYSTICK_EPSIZE, | ||||
| 				.ReportINEndpointDoubleBank   = false, | ||||
|  | ||||
| 				.PrevReportINBuffer           = PrevJoystickHIDReportBuffer, | ||||
| 				.PrevReportINBufferSize       = sizeof(PrevJoystickHIDReportBuffer), | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		HID_Device_USBTask(&Joystick_HID_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware(void) | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	Joystick_Init(); | ||||
| 	LEDs_Init(); | ||||
| 	Buttons_Init(); | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= HID_Device_ConfigureEndpoints(&Joystick_HID_Interface); | ||||
|  | ||||
| 	USB_Device_EnableSOFEvents(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	HID_Device_ProcessControlRequest(&Joystick_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB device Start Of Frame event. */ | ||||
| void EVENT_USB_Device_StartOfFrame(void) | ||||
| { | ||||
| 	HID_Device_MillisecondElapsed(&Joystick_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the creation of HID reports to the host. | ||||
|  * | ||||
|  *  \param[in]     HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in,out] ReportID    Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID | ||||
|  *  \param[in]     ReportType  Type of the report to create, either HID_REPORT_ITEM_In or HID_REPORT_ITEM_Feature | ||||
|  *  \param[out]    ReportData  Pointer to a buffer where the created report should be stored | ||||
|  *  \param[out]    ReportSize  Number of bytes written in the report (or zero if no report is to be sent | ||||
|  * | ||||
|  *  \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent | ||||
|  */ | ||||
| bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                          uint8_t* const ReportID, | ||||
|                                          const uint8_t ReportType, | ||||
|                                          void* ReportData, | ||||
|                                          uint16_t* const ReportSize) | ||||
| { | ||||
| 	USB_JoystickReport_Data_t* JoystickReport = (USB_JoystickReport_Data_t*)ReportData; | ||||
|  | ||||
| 	uint8_t JoyStatus_LCL    = Joystick_GetStatus(); | ||||
| 	uint8_t ButtonStatus_LCL = Buttons_GetStatus(); | ||||
|  | ||||
| 	if (JoyStatus_LCL & JOY_UP) | ||||
| 	  JoystickReport->Y = -100; | ||||
| 	else if (JoyStatus_LCL & JOY_DOWN) | ||||
| 	  JoystickReport->Y =  100; | ||||
|  | ||||
| 	if (JoyStatus_LCL & JOY_LEFT) | ||||
| 	  JoystickReport->X = -100; | ||||
| 	else if (JoyStatus_LCL & JOY_RIGHT) | ||||
| 	  JoystickReport->X =  100; | ||||
|  | ||||
| 	if (JoyStatus_LCL & JOY_PRESS) | ||||
| 	  JoystickReport->Button |= (1 << 1); | ||||
|  | ||||
| 	if (ButtonStatus_LCL & BUTTONS_BUTTON1) | ||||
| 	  JoystickReport->Button |= (1 << 0); | ||||
|  | ||||
| 	*ReportSize = sizeof(USB_JoystickReport_Data_t); | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the processing of HID reports from the host. | ||||
|  * | ||||
|  *  \param[in] HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in] ReportID    Report ID of the received report from the host | ||||
|  *  \param[in] ReportType  The type of report that the host has sent, either HID_REPORT_ITEM_Out or HID_REPORT_ITEM_Feature | ||||
|  *  \param[in] ReportData  Pointer to a buffer where the received report has been stored | ||||
|  *  \param[in] ReportSize  Size in bytes of the received HID report | ||||
|  */ | ||||
| void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                           const uint8_t ReportID, | ||||
|                                           const uint8_t ReportType, | ||||
|                                           const void* ReportData, | ||||
|                                           const uint16_t ReportSize) | ||||
| { | ||||
| 	// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,99 +1,99 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Joystick.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _JOYSTICK_H_ | ||||
| #define _JOYSTICK_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <string.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/Joystick.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/Board/Buttons.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the joystick HID report structure, for creating and sending HID reports to the host PC. | ||||
| 		 *  This mirrors the layout described to the host in the HID report descriptor, in Descriptors.c. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			int8_t  X; /**< Current absolute joystick X position, as a signed 8-bit integer */ | ||||
| 			int8_t  Y; /**< Current absolute joystick Y position, as a signed 8-bit integer */ | ||||
| 			uint8_t Button; /**< Bit mask of the currently pressed joystick buttons */ | ||||
| 		} USB_JoystickReport_Data_t; | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
| 		void EVENT_USB_Device_StartOfFrame(void); | ||||
|  | ||||
| 		bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                         uint8_t* const ReportID, | ||||
| 		                                         const uint8_t ReportType, | ||||
| 		                                         void* ReportData, | ||||
| 		                                         uint16_t* const ReportSize); | ||||
| 		void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                          const uint8_t ReportID, | ||||
| 		                                          const uint8_t ReportType, | ||||
| 		                                          const void* ReportData, | ||||
| 		                                          const uint16_t ReportSize); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Joystick.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _JOYSTICK_H_ | ||||
| #define _JOYSTICK_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <string.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/Joystick.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/Board/Buttons.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the joystick HID report structure, for creating and sending HID reports to the host PC. | ||||
| 		 *  This mirrors the layout described to the host in the HID report descriptor, in Descriptors.c. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			int8_t  X; /**< Current absolute joystick X position, as a signed 8-bit integer */ | ||||
| 			int8_t  Y; /**< Current absolute joystick Y position, as a signed 8-bit integer */ | ||||
| 			uint8_t Button; /**< Bit mask of the currently pressed joystick buttons */ | ||||
| 		} USB_JoystickReport_Data_t; | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
| 		void EVENT_USB_Device_StartOfFrame(void); | ||||
|  | ||||
| 		bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                         uint8_t* const ReportID, | ||||
| 		                                         const uint8_t ReportType, | ||||
| 		                                         void* ReportData, | ||||
| 		                                         uint16_t* const ReportSize); | ||||
| 		void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                          const uint8_t ReportID, | ||||
| 		                                          const uint8_t ReportType, | ||||
| 		                                          const void* ReportData, | ||||
| 		                                          const uint16_t ReportSize); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,74 +1,74 @@ | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage Joystick Device Demo | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  *  - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Human Interface Device (HID)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>N/A</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF HID Specification \n | ||||
|  *        USBIF HID Usage Tables</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Low Speed Mode \n | ||||
|  *        Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Joystick demonstration application. This gives a simple reference | ||||
|  *  application for implementing a USB Keyboard device, for USB Joysticks | ||||
|  *  using the standard Keyboard HID profile. | ||||
|  * | ||||
|  *  This device will show up as a generic joystick device, with two buttons. | ||||
|  *  Pressing the joystick inwards is the first button, and the HWB button | ||||
|  *  is the second. | ||||
|  * | ||||
|  *  Moving the joystick on the selected board moves the joystick location on | ||||
|  *  the host computer. | ||||
|  * | ||||
|  *  Currently only single interface joysticks are supported. | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td> | ||||
|  *     None | ||||
|  *    </td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage Joystick Device Demo | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  *  - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Human Interface Device (HID)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>N/A</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF HID Specification \n | ||||
|  *        USBIF HID Usage Tables</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Low Speed Mode \n | ||||
|  *        Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Joystick demonstration application. This gives a simple reference | ||||
|  *  application for implementing a USB Keyboard device, for USB Joysticks | ||||
|  *  using the standard Keyboard HID profile. | ||||
|  * | ||||
|  *  This device will show up as a generic joystick device, with two buttons. | ||||
|  *  Pressing the joystick inwards is the first button, and the HWB button | ||||
|  *  is the second. | ||||
|  * | ||||
|  *  Moving the joystick on the selected board moves the joystick location on | ||||
|  *  the host computer. | ||||
|  * | ||||
|  *  Currently only single interface joysticks are supported. | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td> | ||||
|  *     None | ||||
|  *    </td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,231 +1,231 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** HID class report descriptor. This is a special descriptor constructed with values from the | ||||
|  *  USBIF HID class specification to describe the reports and capabilities of the HID device. This | ||||
|  *  descriptor is parsed by the host and its contents used to determine what data (and in what encoding) | ||||
|  *  the device will send, and what it may be sent back from the host. Refer to the HID specification for | ||||
|  *  more details on HID report descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = | ||||
| { | ||||
| 	/* Use the HID class driver's standard Keyboard report. | ||||
| 	 *   Max simultaneous keys: 6 | ||||
| 	 */ | ||||
| 	HID_DESCRIPTOR_KEYBOARD(6) | ||||
| }; | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x2042, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 1, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0x00, | ||||
| 			.AlternateSetting       = 0x00, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = HID_CSCP_HIDClass, | ||||
| 			.SubClass               = HID_CSCP_BootSubclass, | ||||
| 			.Protocol               = HID_CSCP_KeyboardBootProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.HID_KeyboardHID = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||||
|  | ||||
| 			.HIDSpec                = VERSION_BCD(01.11), | ||||
| 			.CountryCode            = 0x00, | ||||
| 			.TotalReportDescriptors = 1, | ||||
| 			.HIDReportType          = HID_DTYPE_Report, | ||||
| 			.HIDReportLength        = sizeof(KeyboardReport) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_ReportINEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | KEYBOARD_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = KEYBOARD_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Keyboard Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 		case HID_DTYPE_HID: | ||||
| 			Address = &ConfigurationDescriptor.HID_KeyboardHID; | ||||
| 			Size    = sizeof(USB_HID_Descriptor_HID_t); | ||||
| 			break; | ||||
| 		case HID_DTYPE_Report: | ||||
| 			Address = &KeyboardReport; | ||||
| 			Size    = sizeof(KeyboardReport); | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** HID class report descriptor. This is a special descriptor constructed with values from the | ||||
|  *  USBIF HID class specification to describe the reports and capabilities of the HID device. This | ||||
|  *  descriptor is parsed by the host and its contents used to determine what data (and in what encoding) | ||||
|  *  the device will send, and what it may be sent back from the host. Refer to the HID specification for | ||||
|  *  more details on HID report descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = | ||||
| { | ||||
| 	/* Use the HID class driver's standard Keyboard report. | ||||
| 	 *   Max simultaneous keys: 6 | ||||
| 	 */ | ||||
| 	HID_DESCRIPTOR_KEYBOARD(6) | ||||
| }; | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x2042, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 1, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0x00, | ||||
| 			.AlternateSetting       = 0x00, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = HID_CSCP_HIDClass, | ||||
| 			.SubClass               = HID_CSCP_BootSubclass, | ||||
| 			.Protocol               = HID_CSCP_KeyboardBootProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.HID_KeyboardHID = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||||
|  | ||||
| 			.HIDSpec                = VERSION_BCD(01.11), | ||||
| 			.CountryCode            = 0x00, | ||||
| 			.TotalReportDescriptors = 1, | ||||
| 			.HIDReportType          = HID_DTYPE_Report, | ||||
| 			.HIDReportLength        = sizeof(KeyboardReport) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_ReportINEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | KEYBOARD_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = KEYBOARD_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Keyboard Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 		case HID_DTYPE_HID: | ||||
| 			Address = &ConfigurationDescriptor.HID_KeyboardHID; | ||||
| 			Size    = sizeof(USB_HID_Descriptor_HID_t); | ||||
| 			break; | ||||
| 		case HID_DTYPE_Report: | ||||
| 			Address = &KeyboardReport; | ||||
| 			Size    = sizeof(KeyboardReport); | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,73 +1,73 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t Config; | ||||
|  | ||||
| 			// Keyboard HID Interface | ||||
| 			USB_Descriptor_Interface_t            HID_Interface; | ||||
| 			USB_HID_Descriptor_HID_t              HID_KeyboardHID; | ||||
| 	        USB_Descriptor_Endpoint_t             HID_ReportINEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the Keyboard HID reporting IN endpoint. */ | ||||
| 		#define KEYBOARD_EPNUM               1 | ||||
|  | ||||
| 		/** Size in bytes of the Keyboard HID reporting IN endpoint. */ | ||||
| 		#define KEYBOARD_EPSIZE              8 | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t Config; | ||||
|  | ||||
| 			// Keyboard HID Interface | ||||
| 			USB_Descriptor_Interface_t            HID_Interface; | ||||
| 			USB_HID_Descriptor_HID_t              HID_KeyboardHID; | ||||
| 	        USB_Descriptor_Endpoint_t             HID_ReportINEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the Keyboard HID reporting IN endpoint. */ | ||||
| 		#define KEYBOARD_EPNUM               1 | ||||
|  | ||||
| 		/** Size in bytes of the Keyboard HID reporting IN endpoint. */ | ||||
| 		#define KEYBOARD_EPSIZE              8 | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1 +1 @@ | ||||
| <AVRStudio><MANAGEMENT><ProjectName>Keyboard</ProjectName><Created>13-Jul-2010 15:27:55</Created><LastEdit>13-Jul-2010 15:28:59</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:27:55</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\Keyboard\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR ONE!</CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>Descriptors.c</SOURCEFILE><SOURCEFILE>Keyboard.c</SOURCEFILE><HEADERFILE>Descriptors.h</HEADERFILE><HEADERFILE>Keyboard.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>Keyboard.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
| <AVRStudio><MANAGEMENT><ProjectName>Keyboard</ProjectName><Created>13-Jul-2010 15:27:55</Created><LastEdit>13-Jul-2010 15:28:59</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:27:55</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\Keyboard\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR ONE!</CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>Descriptors.c</SOURCEFILE><SOURCEFILE>Keyboard.c</SOURCEFILE><HEADERFILE>Descriptors.h</HEADERFILE><HEADERFILE>Keyboard.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>Keyboard.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
|   | ||||
| @@ -1,206 +1,206 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|    | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the Keyboard demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "Keyboard.h" | ||||
|  | ||||
| /** Buffer to hold the previously generated Keyboard HID report, for comparison purposes inside the HID class driver. */ | ||||
| static uint8_t PrevKeyboardHIDReportBuffer[sizeof(USB_KeyboardReport_Data_t)]; | ||||
|  | ||||
| /** LUFA HID Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all HID Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_HID_Device_t Keyboard_HID_Interface = | ||||
|  	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.InterfaceNumber              = 0, | ||||
|  | ||||
| 				.ReportINEndpointNumber       = KEYBOARD_EPNUM, | ||||
| 				.ReportINEndpointSize         = KEYBOARD_EPSIZE, | ||||
| 				.ReportINEndpointDoubleBank   = false, | ||||
|  | ||||
| 				.PrevReportINBuffer           = PrevKeyboardHIDReportBuffer, | ||||
| 				.PrevReportINBufferSize       = sizeof(PrevKeyboardHIDReportBuffer), | ||||
| 			}, | ||||
|     }; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		HID_Device_USBTask(&Keyboard_HID_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware() | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	Joystick_Init(); | ||||
| 	LEDs_Init(); | ||||
| 	Buttons_Init(); | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= HID_Device_ConfigureEndpoints(&Keyboard_HID_Interface); | ||||
|  | ||||
| 	USB_Device_EnableSOFEvents(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	HID_Device_ProcessControlRequest(&Keyboard_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB device Start Of Frame event. */ | ||||
| void EVENT_USB_Device_StartOfFrame(void) | ||||
| { | ||||
| 	HID_Device_MillisecondElapsed(&Keyboard_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the creation of HID reports to the host. | ||||
|  * | ||||
|  *  \param[in]     HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in,out] ReportID    Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID | ||||
|  *  \param[in]     ReportType  Type of the report to create, either HID_REPORT_ITEM_In or HID_REPORT_ITEM_Feature | ||||
|  *  \param[out]    ReportData  Pointer to a buffer where the created report should be stored | ||||
|  *  \param[out]    ReportSize  Number of bytes written in the report (or zero if no report is to be sent | ||||
|  * | ||||
|  *  \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent | ||||
|  */ | ||||
| bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                          uint8_t* const ReportID, | ||||
|                                          const uint8_t ReportType, | ||||
|                                          void* ReportData, | ||||
|                                          uint16_t* const ReportSize) | ||||
| { | ||||
| 	USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData; | ||||
|  | ||||
| 	uint8_t JoyStatus_LCL    = Joystick_GetStatus(); | ||||
| 	uint8_t ButtonStatus_LCL = Buttons_GetStatus(); | ||||
|  | ||||
| 	uint8_t UsedKeyCodes = 0; | ||||
|  | ||||
| 	if (JoyStatus_LCL & JOY_UP) | ||||
| 	  KeyboardReport->KeyCode[UsedKeyCodes++] = HID_KEYBOARD_SC_A; | ||||
| 	else if (JoyStatus_LCL & JOY_DOWN) | ||||
| 	  KeyboardReport->KeyCode[UsedKeyCodes++] = HID_KEYBOARD_SC_B; | ||||
|  | ||||
| 	if (JoyStatus_LCL & JOY_LEFT) | ||||
| 	  KeyboardReport->KeyCode[UsedKeyCodes++] = HID_KEYBOARD_SC_C; | ||||
| 	else if (JoyStatus_LCL & JOY_RIGHT) | ||||
| 	  KeyboardReport->KeyCode[UsedKeyCodes++] = HID_KEYBOARD_SC_D; | ||||
|  | ||||
| 	if (JoyStatus_LCL & JOY_PRESS) | ||||
| 	  KeyboardReport->KeyCode[UsedKeyCodes++] = HID_KEYBOARD_SC_E; | ||||
|  | ||||
| 	if (ButtonStatus_LCL & BUTTONS_BUTTON1) | ||||
| 	  KeyboardReport->KeyCode[UsedKeyCodes++] = HID_KEYBOARD_SC_F; | ||||
|  | ||||
| 	if (UsedKeyCodes) | ||||
| 	  KeyboardReport->Modifier = HID_KEYBOARD_MODIFER_LEFTSHIFT; | ||||
|  | ||||
| 	*ReportSize = sizeof(USB_KeyboardReport_Data_t); | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the processing of HID reports from the host. | ||||
|  * | ||||
|  *  \param[in] HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in] ReportID    Report ID of the received report from the host | ||||
|  *  \param[in] ReportType  The type of report that the host has sent, either HID_REPORT_ITEM_Out or HID_REPORT_ITEM_Feature | ||||
|  *  \param[in] ReportData  Pointer to a buffer where the received report has been stored | ||||
|  *  \param[in] ReportSize  Size in bytes of the received HID report | ||||
|  */ | ||||
| void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                           const uint8_t ReportID, | ||||
|                                           const uint8_t ReportType, | ||||
|                                           const void* ReportData, | ||||
|                                           const uint16_t ReportSize) | ||||
| { | ||||
| 	uint8_t  LEDMask   = LEDS_NO_LEDS; | ||||
| 	uint8_t* LEDReport = (uint8_t*)ReportData; | ||||
|  | ||||
| 	if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK) | ||||
| 	  LEDMask |= LEDS_LED1; | ||||
|  | ||||
| 	if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK) | ||||
| 	  LEDMask |= LEDS_LED3; | ||||
|  | ||||
| 	if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK) | ||||
| 	  LEDMask |= LEDS_LED4; | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMask); | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|    | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the Keyboard demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "Keyboard.h" | ||||
|  | ||||
| /** Buffer to hold the previously generated Keyboard HID report, for comparison purposes inside the HID class driver. */ | ||||
| static uint8_t PrevKeyboardHIDReportBuffer[sizeof(USB_KeyboardReport_Data_t)]; | ||||
|  | ||||
| /** LUFA HID Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all HID Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_HID_Device_t Keyboard_HID_Interface = | ||||
|  	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.InterfaceNumber              = 0, | ||||
|  | ||||
| 				.ReportINEndpointNumber       = KEYBOARD_EPNUM, | ||||
| 				.ReportINEndpointSize         = KEYBOARD_EPSIZE, | ||||
| 				.ReportINEndpointDoubleBank   = false, | ||||
|  | ||||
| 				.PrevReportINBuffer           = PrevKeyboardHIDReportBuffer, | ||||
| 				.PrevReportINBufferSize       = sizeof(PrevKeyboardHIDReportBuffer), | ||||
| 			}, | ||||
|     }; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		HID_Device_USBTask(&Keyboard_HID_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware() | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	Joystick_Init(); | ||||
| 	LEDs_Init(); | ||||
| 	Buttons_Init(); | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= HID_Device_ConfigureEndpoints(&Keyboard_HID_Interface); | ||||
|  | ||||
| 	USB_Device_EnableSOFEvents(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	HID_Device_ProcessControlRequest(&Keyboard_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB device Start Of Frame event. */ | ||||
| void EVENT_USB_Device_StartOfFrame(void) | ||||
| { | ||||
| 	HID_Device_MillisecondElapsed(&Keyboard_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the creation of HID reports to the host. | ||||
|  * | ||||
|  *  \param[in]     HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in,out] ReportID    Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID | ||||
|  *  \param[in]     ReportType  Type of the report to create, either HID_REPORT_ITEM_In or HID_REPORT_ITEM_Feature | ||||
|  *  \param[out]    ReportData  Pointer to a buffer where the created report should be stored | ||||
|  *  \param[out]    ReportSize  Number of bytes written in the report (or zero if no report is to be sent | ||||
|  * | ||||
|  *  \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent | ||||
|  */ | ||||
| bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                          uint8_t* const ReportID, | ||||
|                                          const uint8_t ReportType, | ||||
|                                          void* ReportData, | ||||
|                                          uint16_t* const ReportSize) | ||||
| { | ||||
| 	USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData; | ||||
|  | ||||
| 	uint8_t JoyStatus_LCL    = Joystick_GetStatus(); | ||||
| 	uint8_t ButtonStatus_LCL = Buttons_GetStatus(); | ||||
|  | ||||
| 	uint8_t UsedKeyCodes = 0; | ||||
|  | ||||
| 	if (JoyStatus_LCL & JOY_UP) | ||||
| 	  KeyboardReport->KeyCode[UsedKeyCodes++] = HID_KEYBOARD_SC_A; | ||||
| 	else if (JoyStatus_LCL & JOY_DOWN) | ||||
| 	  KeyboardReport->KeyCode[UsedKeyCodes++] = HID_KEYBOARD_SC_B; | ||||
|  | ||||
| 	if (JoyStatus_LCL & JOY_LEFT) | ||||
| 	  KeyboardReport->KeyCode[UsedKeyCodes++] = HID_KEYBOARD_SC_C; | ||||
| 	else if (JoyStatus_LCL & JOY_RIGHT) | ||||
| 	  KeyboardReport->KeyCode[UsedKeyCodes++] = HID_KEYBOARD_SC_D; | ||||
|  | ||||
| 	if (JoyStatus_LCL & JOY_PRESS) | ||||
| 	  KeyboardReport->KeyCode[UsedKeyCodes++] = HID_KEYBOARD_SC_E; | ||||
|  | ||||
| 	if (ButtonStatus_LCL & BUTTONS_BUTTON1) | ||||
| 	  KeyboardReport->KeyCode[UsedKeyCodes++] = HID_KEYBOARD_SC_F; | ||||
|  | ||||
| 	if (UsedKeyCodes) | ||||
| 	  KeyboardReport->Modifier = HID_KEYBOARD_MODIFIER_LEFTSHIFT; | ||||
|  | ||||
| 	*ReportSize = sizeof(USB_KeyboardReport_Data_t); | ||||
| 	return false; | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the processing of HID reports from the host. | ||||
|  * | ||||
|  *  \param[in] HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in] ReportID    Report ID of the received report from the host | ||||
|  *  \param[in] ReportType  The type of report that the host has sent, either HID_REPORT_ITEM_Out or HID_REPORT_ITEM_Feature | ||||
|  *  \param[in] ReportData  Pointer to a buffer where the received report has been stored | ||||
|  *  \param[in] ReportSize  Size in bytes of the received HID report | ||||
|  */ | ||||
| void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                           const uint8_t ReportID, | ||||
|                                           const uint8_t ReportType, | ||||
|                                           const void* ReportData, | ||||
|                                           const uint16_t ReportSize) | ||||
| { | ||||
| 	uint8_t  LEDMask   = LEDS_NO_LEDS; | ||||
| 	uint8_t* LEDReport = (uint8_t*)ReportData; | ||||
|  | ||||
| 	if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK) | ||||
| 	  LEDMask |= LEDS_LED1; | ||||
|  | ||||
| 	if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK) | ||||
| 	  LEDMask |= LEDS_LED3; | ||||
|  | ||||
| 	if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK) | ||||
| 	  LEDMask |= LEDS_LED4; | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMask); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,89 +1,89 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Keyboard.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _KEYBOARD_H_ | ||||
| #define _KEYBOARD_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <stdbool.h> | ||||
| 		#include <string.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/Joystick.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/Board/Buttons.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
| 		void EVENT_USB_Device_StartOfFrame(void); | ||||
|  | ||||
| 		bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                         uint8_t* const ReportID, | ||||
| 		                                         const uint8_t ReportType, | ||||
| 		                                         void* ReportData, | ||||
| 		                                         uint16_t* const ReportSize); | ||||
| 		void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                          const uint8_t ReportID, | ||||
| 		                                          const uint8_t ReportType, | ||||
| 		                                          const void* ReportData, | ||||
| 		                                          const uint16_t ReportSize); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Keyboard.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _KEYBOARD_H_ | ||||
| #define _KEYBOARD_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <stdbool.h> | ||||
| 		#include <string.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/Joystick.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/Board/Buttons.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
| 		void EVENT_USB_Device_StartOfFrame(void); | ||||
|  | ||||
| 		bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                         uint8_t* const ReportID, | ||||
| 		                                         const uint8_t ReportType, | ||||
| 		                                         void* ReportData, | ||||
| 		                                         uint16_t* const ReportSize); | ||||
| 		void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                          const uint8_t ReportID, | ||||
| 		                                          const uint8_t ReportType, | ||||
| 		                                          const void* ReportData, | ||||
| 		                                          const uint16_t ReportSize); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,73 +1,73 @@ | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage Keyboard Device Demo | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  *  - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Human Interface Device (HID)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>Keyboard Subclass</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF HID Specification \n | ||||
|  *        USBIF HID Usage Tables</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Low Speed Mode \n | ||||
|  *        Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Keyboard demonstration application. This gives a simple reference application | ||||
|  *  for implementing a USB Keyboard using the basic USB HID drivers in all modern | ||||
|  *  OSes (i.e. no special drivers required). It is boot protocol compatible, and thus | ||||
|  *  works under compatible BIOS as if it was a native keyboard (e.g. PS/2). | ||||
|  * | ||||
|  *  On start-up the system will automatically enumerate and function as a keyboard | ||||
|  *  when the USB connection to a host is present. To use the keyboard example, | ||||
|  *  manipulate the joystick to send the letters a, b, c, d and e. See the USB HID | ||||
|  *  documentation for more information on sending keyboard event and key presses. Unlike | ||||
|  *  other LUFA Keyboard demos, this example shows explicitly how to send multiple key presses | ||||
|  *  inside the same report to the host. | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td> | ||||
|  *     None | ||||
|  *    </td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage Keyboard Device Demo | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  *  - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Human Interface Device (HID)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>Keyboard Subclass</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF HID Specification \n | ||||
|  *        USBIF HID Usage Tables</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Low Speed Mode \n | ||||
|  *        Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Keyboard demonstration application. This gives a simple reference application | ||||
|  *  for implementing a USB Keyboard using the basic USB HID drivers in all modern | ||||
|  *  OSes (i.e. no special drivers required). It is boot protocol compatible, and thus | ||||
|  *  works under compatible BIOS as if it was a native keyboard (e.g. PS/2). | ||||
|  * | ||||
|  *  On start-up the system will automatically enumerate and function as a keyboard | ||||
|  *  when the USB connection to a host is present. To use the keyboard example, | ||||
|  *  manipulate the joystick to send the letters a, b, c, d and e. See the USB HID | ||||
|  *  documentation for more information on sending keyboard event and key presses. Unlike | ||||
|  *  other LUFA Keyboard demos, this example shows explicitly how to send multiple key presses | ||||
|  *  inside the same report to the host. | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td> | ||||
|  *     None | ||||
|  *    </td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,302 +1,302 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** HID class report descriptor. This is a special descriptor constructed with values from the | ||||
|  *  USBIF HID class specification to describe the reports and capabilities of the HID device. This | ||||
|  *  descriptor is parsed by the host and its contents used to determine what data (and in what encoding) | ||||
|  *  the device will send, and what it may be sent back from the host. Refer to the HID specification for | ||||
|  *  more details on HID report descriptors. | ||||
|  * | ||||
|  *  This descriptor describes the mouse HID interface's report structure. | ||||
|  */ | ||||
| const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = | ||||
| { | ||||
| 	/* Use the HID class driver's standard Mouse report. | ||||
| 	 *   Min X/Y Axis values: -1 | ||||
| 	 *   Max X/Y Axis values:  1 | ||||
| 	 *   Min physical X/Y Axis values (used to determine resolution): -1 | ||||
| 	 *   Max physical X/Y Axis values (used to determine resolution):  1 | ||||
| 	 *   Buttons: 3 | ||||
| 	 *   Absolute screen coordinates: false | ||||
| 	 */ | ||||
| 	HID_DESCRIPTOR_MOUSE(-1, 1, -1, 1, 3, false) | ||||
| }; | ||||
|  | ||||
| /** Same as the MouseReport structure, but defines the keyboard HID interface's report structure. */ | ||||
| const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = | ||||
| { | ||||
| 	/* Use the HID class driver's standard Keyboard report. | ||||
| 	 *   Max simultaneous keys: 6 | ||||
| 	 */ | ||||
| 	HID_DESCRIPTOR_KEYBOARD(6) | ||||
| }; | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x204D, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 2, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.HID1_KeyboardInterface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0x00, | ||||
| 			.AlternateSetting       = 0x00, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = HID_CSCP_HIDClass, | ||||
| 			.SubClass               = HID_CSCP_BootSubclass, | ||||
| 			.Protocol               = HID_CSCP_KeyboardBootProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.HID1_KeyboardHID = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||||
|  | ||||
| 			.HIDSpec                = VERSION_BCD(01.11), | ||||
| 			.CountryCode            = 0x00, | ||||
| 			.TotalReportDescriptors = 1, | ||||
| 			.HIDReportType          = HID_DTYPE_Report, | ||||
| 			.HIDReportLength        = sizeof(KeyboardReport) | ||||
| 		}, | ||||
|  | ||||
| 	.HID1_ReportINEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = HID_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
|  | ||||
| 	.HID2_MouseInterface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0x01, | ||||
| 			.AlternateSetting       = 0x00, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = HID_CSCP_HIDClass, | ||||
| 			.SubClass               = HID_CSCP_BootSubclass, | ||||
| 			.Protocol               = HID_CSCP_MouseBootProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.HID2_MouseHID = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||||
|  | ||||
| 			.HIDSpec                = VERSION_BCD(01.11), | ||||
| 			.CountryCode            = 0x00, | ||||
| 			.TotalReportDescriptors = 1, | ||||
| 			.HIDReportType          = HID_DTYPE_Report, | ||||
| 			.HIDReportLength        = sizeof(MouseReport) | ||||
| 		}, | ||||
|  | ||||
| 	.HID2_ReportINEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = HID_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		} | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(28), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Mouse and Keyboard Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 		case HID_DTYPE_HID: | ||||
| 			if (!(wIndex)) | ||||
| 			{ | ||||
| 				Address = &ConfigurationDescriptor.HID1_KeyboardHID; | ||||
| 				Size    = sizeof(USB_HID_Descriptor_HID_t); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				Address = &ConfigurationDescriptor.HID2_MouseHID; | ||||
| 				Size    = sizeof(USB_HID_Descriptor_HID_t); | ||||
| 			} | ||||
| 			 | ||||
| 			break; | ||||
| 		case HID_DTYPE_Report: | ||||
| 			if (!(wIndex)) | ||||
| 			{ | ||||
| 				Address = &KeyboardReport; | ||||
| 				Size    = sizeof(KeyboardReport); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				Address = &MouseReport; | ||||
| 				Size    = sizeof(MouseReport); | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** HID class report descriptor. This is a special descriptor constructed with values from the | ||||
|  *  USBIF HID class specification to describe the reports and capabilities of the HID device. This | ||||
|  *  descriptor is parsed by the host and its contents used to determine what data (and in what encoding) | ||||
|  *  the device will send, and what it may be sent back from the host. Refer to the HID specification for | ||||
|  *  more details on HID report descriptors. | ||||
|  * | ||||
|  *  This descriptor describes the mouse HID interface's report structure. | ||||
|  */ | ||||
| const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = | ||||
| { | ||||
| 	/* Use the HID class driver's standard Mouse report. | ||||
| 	 *   Min X/Y Axis values: -1 | ||||
| 	 *   Max X/Y Axis values:  1 | ||||
| 	 *   Min physical X/Y Axis values (used to determine resolution): -1 | ||||
| 	 *   Max physical X/Y Axis values (used to determine resolution):  1 | ||||
| 	 *   Buttons: 3 | ||||
| 	 *   Absolute screen coordinates: false | ||||
| 	 */ | ||||
| 	HID_DESCRIPTOR_MOUSE(-1, 1, -1, 1, 3, false) | ||||
| }; | ||||
|  | ||||
| /** Same as the MouseReport structure, but defines the keyboard HID interface's report structure. */ | ||||
| const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = | ||||
| { | ||||
| 	/* Use the HID class driver's standard Keyboard report. | ||||
| 	 *   Max simultaneous keys: 6 | ||||
| 	 */ | ||||
| 	HID_DESCRIPTOR_KEYBOARD(6) | ||||
| }; | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x204D, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 2, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.HID1_KeyboardInterface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0x00, | ||||
| 			.AlternateSetting       = 0x00, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = HID_CSCP_HIDClass, | ||||
| 			.SubClass               = HID_CSCP_BootSubclass, | ||||
| 			.Protocol               = HID_CSCP_KeyboardBootProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.HID1_KeyboardHID = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||||
|  | ||||
| 			.HIDSpec                = VERSION_BCD(01.11), | ||||
| 			.CountryCode            = 0x00, | ||||
| 			.TotalReportDescriptors = 1, | ||||
| 			.HIDReportType          = HID_DTYPE_Report, | ||||
| 			.HIDReportLength        = sizeof(KeyboardReport) | ||||
| 		}, | ||||
|  | ||||
| 	.HID1_ReportINEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = HID_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
|  | ||||
| 	.HID2_MouseInterface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0x01, | ||||
| 			.AlternateSetting       = 0x00, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = HID_CSCP_HIDClass, | ||||
| 			.SubClass               = HID_CSCP_BootSubclass, | ||||
| 			.Protocol               = HID_CSCP_MouseBootProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.HID2_MouseHID = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||||
|  | ||||
| 			.HIDSpec                = VERSION_BCD(01.11), | ||||
| 			.CountryCode            = 0x00, | ||||
| 			.TotalReportDescriptors = 1, | ||||
| 			.HIDReportType          = HID_DTYPE_Report, | ||||
| 			.HIDReportLength        = sizeof(MouseReport) | ||||
| 		}, | ||||
|  | ||||
| 	.HID2_ReportINEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = HID_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		} | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(28), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Mouse and Keyboard Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 		case HID_DTYPE_HID: | ||||
| 			if (!(wIndex)) | ||||
| 			{ | ||||
| 				Address = &ConfigurationDescriptor.HID1_KeyboardHID; | ||||
| 				Size    = sizeof(USB_HID_Descriptor_HID_t); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				Address = &ConfigurationDescriptor.HID2_MouseHID; | ||||
| 				Size    = sizeof(USB_HID_Descriptor_HID_t); | ||||
| 			} | ||||
| 			 | ||||
| 			break; | ||||
| 		case HID_DTYPE_Report: | ||||
| 			if (!(wIndex)) | ||||
| 			{ | ||||
| 				Address = &KeyboardReport; | ||||
| 				Size    = sizeof(KeyboardReport); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				Address = &MouseReport; | ||||
| 				Size    = sizeof(MouseReport); | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,81 +1,81 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t Config; | ||||
|  | ||||
| 			// Keyboard HID Interface | ||||
| 			USB_Descriptor_Interface_t            HID1_KeyboardInterface; | ||||
| 			USB_HID_Descriptor_HID_t              HID1_KeyboardHID; | ||||
| 			USB_Descriptor_Endpoint_t             HID1_ReportINEndpoint; | ||||
|  | ||||
| 			// Mouse HID Interface | ||||
| 			USB_Descriptor_Interface_t            HID2_MouseInterface; | ||||
| 			USB_HID_Descriptor_HID_t              HID2_MouseHID; | ||||
| 			USB_Descriptor_Endpoint_t             HID2_ReportINEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the Keyboard HID reporting IN endpoint. */ | ||||
| 		#define KEYBOARD_IN_EPNUM         1 | ||||
|  | ||||
| 		/** Endpoint number of the Mouse HID reporting IN endpoint. */ | ||||
| 		#define MOUSE_IN_EPNUM            3 | ||||
|  | ||||
| 		/** Size in bytes of each of the HID reporting IN endpoints. */ | ||||
| 		#define HID_EPSIZE                8 | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t Config; | ||||
|  | ||||
| 			// Keyboard HID Interface | ||||
| 			USB_Descriptor_Interface_t            HID1_KeyboardInterface; | ||||
| 			USB_HID_Descriptor_HID_t              HID1_KeyboardHID; | ||||
| 			USB_Descriptor_Endpoint_t             HID1_ReportINEndpoint; | ||||
|  | ||||
| 			// Mouse HID Interface | ||||
| 			USB_Descriptor_Interface_t            HID2_MouseInterface; | ||||
| 			USB_HID_Descriptor_HID_t              HID2_MouseHID; | ||||
| 			USB_Descriptor_Endpoint_t             HID2_ReportINEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the Keyboard HID reporting IN endpoint. */ | ||||
| 		#define KEYBOARD_IN_EPNUM         1 | ||||
|  | ||||
| 		/** Endpoint number of the Mouse HID reporting IN endpoint. */ | ||||
| 		#define MOUSE_IN_EPNUM            3 | ||||
|  | ||||
| 		/** Size in bytes of each of the HID reporting IN endpoints. */ | ||||
| 		#define HID_EPSIZE                8 | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1 +1 @@ | ||||
| <AVRStudio><MANAGEMENT><ProjectName>KeyboardMouse</ProjectName><Created>13-Jul-2010 15:29:11</Created><LastEdit>13-Jul-2010 15:29:25</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:29:11</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\KeyboardMouse\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>Descriptors.c</SOURCEFILE><SOURCEFILE>KeyboardMouse.c</SOURCEFILE><HEADERFILE>Descriptors.h</HEADERFILE><HEADERFILE>KeyboardMouse.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>KeyboardMouse.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
| <AVRStudio><MANAGEMENT><ProjectName>KeyboardMouse</ProjectName><Created>13-Jul-2010 15:29:11</Created><LastEdit>13-Jul-2010 15:29:25</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:29:11</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\KeyboardMouse\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>Descriptors.c</SOURCEFILE><SOURCEFILE>KeyboardMouse.c</SOURCEFILE><HEADERFILE>Descriptors.h</HEADERFILE><HEADERFILE>KeyboardMouse.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>KeyboardMouse.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
|   | ||||
| @@ -1,260 +1,260 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the KeyboardMouse demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "KeyboardMouse.h" | ||||
|  | ||||
| /** Buffer to hold the previously generated Keyboard HID report, for comparison purposes inside the HID class driver. */ | ||||
| static uint8_t PrevKeyboardHIDReportBuffer[sizeof(USB_KeyboardReport_Data_t)]; | ||||
|  | ||||
| /** Buffer to hold the previously generated Mouse HID report, for comparison purposes inside the HID class driver. */ | ||||
| static uint8_t PrevMouseHIDReportBuffer[sizeof(USB_MouseReport_Data_t)]; | ||||
|  | ||||
| /** LUFA HID Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all HID Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. This is for the keyboard HID | ||||
|  *  interface within the device. | ||||
|  */ | ||||
| USB_ClassInfo_HID_Device_t Keyboard_HID_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.InterfaceNumber              = 0, | ||||
|  | ||||
| 				.ReportINEndpointNumber       = KEYBOARD_IN_EPNUM, | ||||
| 				.ReportINEndpointSize         = HID_EPSIZE, | ||||
| 				.ReportINEndpointDoubleBank   = false, | ||||
|  | ||||
| 				.PrevReportINBuffer           = PrevKeyboardHIDReportBuffer, | ||||
| 				.PrevReportINBufferSize       = sizeof(PrevKeyboardHIDReportBuffer), | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
| /** LUFA HID Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all HID Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. This is for the mouse HID | ||||
|  *  interface within the device. | ||||
|  */ | ||||
| USB_ClassInfo_HID_Device_t Mouse_HID_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.InterfaceNumber              = 1, | ||||
|  | ||||
| 				.ReportINEndpointNumber       = MOUSE_IN_EPNUM, | ||||
| 				.ReportINEndpointSize         = HID_EPSIZE, | ||||
|  | ||||
| 				.PrevReportINBuffer           = PrevMouseHIDReportBuffer, | ||||
| 				.PrevReportINBufferSize       = sizeof(PrevMouseHIDReportBuffer), | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		HID_Device_USBTask(&Keyboard_HID_Interface); | ||||
| 		HID_Device_USBTask(&Mouse_HID_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware() | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	Joystick_Init(); | ||||
| 	LEDs_Init(); | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
|     LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
|     LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= HID_Device_ConfigureEndpoints(&Keyboard_HID_Interface); | ||||
| 	ConfigSuccess &= HID_Device_ConfigureEndpoints(&Mouse_HID_Interface); | ||||
|  | ||||
| 	USB_Device_EnableSOFEvents(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	HID_Device_ProcessControlRequest(&Keyboard_HID_Interface); | ||||
| 	HID_Device_ProcessControlRequest(&Mouse_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB device Start Of Frame event. */ | ||||
| void EVENT_USB_Device_StartOfFrame(void) | ||||
| { | ||||
| 	HID_Device_MillisecondElapsed(&Keyboard_HID_Interface); | ||||
| 	HID_Device_MillisecondElapsed(&Mouse_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the creation of HID reports to the host. | ||||
|  * | ||||
|  *  \param[in]     HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in,out] ReportID    Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID | ||||
|  *  \param[in]     ReportType  Type of the report to create, either HID_REPORT_ITEM_In or HID_REPORT_ITEM_Feature | ||||
|  *  \param[out]    ReportData  Pointer to a buffer where the created report should be stored | ||||
|  *  \param[out]    ReportSize  Number of bytes written in the report (or zero if no report is to be sent | ||||
|  * | ||||
|  *  \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent | ||||
|  */ | ||||
| bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                          uint8_t* const ReportID, | ||||
|                                          const uint8_t ReportType, | ||||
|                                          void* ReportData, | ||||
|                                          uint16_t* const ReportSize) | ||||
| { | ||||
| 	uint8_t JoyStatus_LCL    = Joystick_GetStatus(); | ||||
| 	uint8_t ButtonStatus_LCL = Buttons_GetStatus(); | ||||
|  | ||||
| 	/* Determine which interface must have its report generated */ | ||||
| 	if (HIDInterfaceInfo == &Keyboard_HID_Interface) | ||||
| 	{ | ||||
| 		USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData; | ||||
|  | ||||
| 		/* If first board button not being held down, no keyboard report */ | ||||
| 		if (!(ButtonStatus_LCL & BUTTONS_BUTTON1)) | ||||
| 		  return 0; | ||||
|  | ||||
| 		KeyboardReport->Modifier = HID_KEYBOARD_MODIFER_LEFTSHIFT; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_UP) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_A; | ||||
| 		else if (JoyStatus_LCL & JOY_DOWN) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_B; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_LEFT) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_C; | ||||
| 		else if (JoyStatus_LCL & JOY_RIGHT) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_D; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_PRESS) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_E; | ||||
|  | ||||
| 		*ReportSize = sizeof(USB_KeyboardReport_Data_t); | ||||
| 		return false; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData; | ||||
|  | ||||
| 		/* If first board button being held down, no mouse report */ | ||||
| 		if (ButtonStatus_LCL & BUTTONS_BUTTON1) | ||||
| 		  return 0; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_UP) | ||||
| 		  MouseReport->Y = -1; | ||||
| 		else if (JoyStatus_LCL & JOY_DOWN) | ||||
| 		  MouseReport->Y =  1; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_LEFT) | ||||
| 		  MouseReport->X = -1; | ||||
| 		else if (JoyStatus_LCL & JOY_RIGHT) | ||||
| 		  MouseReport->X =  1; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_PRESS) | ||||
| 		  MouseReport->Button |= (1 << 0); | ||||
|  | ||||
| 		*ReportSize = sizeof(USB_MouseReport_Data_t); | ||||
| 		return true; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the processing of HID reports from the host. | ||||
|  * | ||||
|  *  \param[in] HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in] ReportID    Report ID of the received report from the host | ||||
|  *  \param[in] ReportType  The type of report that the host has sent, either HID_REPORT_ITEM_Out or HID_REPORT_ITEM_Feature | ||||
|  *  \param[in] ReportData  Pointer to a buffer where the received report has been stored | ||||
|  *  \param[in] ReportSize  Size in bytes of the received HID report | ||||
|  */ | ||||
| void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                           const uint8_t ReportID, | ||||
|                                           const uint8_t ReportType, | ||||
|                                           const void* ReportData, | ||||
|                                           const uint16_t ReportSize) | ||||
| { | ||||
| 	if (HIDInterfaceInfo == &Keyboard_HID_Interface) | ||||
| 	{ | ||||
| 		uint8_t  LEDMask   = LEDS_NO_LEDS; | ||||
| 		uint8_t* LEDReport = (uint8_t*)ReportData; | ||||
|  | ||||
| 		if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK) | ||||
| 		  LEDMask |= LEDS_LED1; | ||||
|  | ||||
| 		if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK) | ||||
| 		  LEDMask |= LEDS_LED3; | ||||
|  | ||||
| 		if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK) | ||||
| 		  LEDMask |= LEDS_LED4; | ||||
|  | ||||
| 		LEDs_SetAllLEDs(LEDMask); | ||||
| 	} | ||||
| } | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the KeyboardMouse demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "KeyboardMouse.h" | ||||
|  | ||||
| /** Buffer to hold the previously generated Keyboard HID report, for comparison purposes inside the HID class driver. */ | ||||
| static uint8_t PrevKeyboardHIDReportBuffer[sizeof(USB_KeyboardReport_Data_t)]; | ||||
|  | ||||
| /** Buffer to hold the previously generated Mouse HID report, for comparison purposes inside the HID class driver. */ | ||||
| static uint8_t PrevMouseHIDReportBuffer[sizeof(USB_MouseReport_Data_t)]; | ||||
|  | ||||
| /** LUFA HID Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all HID Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. This is for the keyboard HID | ||||
|  *  interface within the device. | ||||
|  */ | ||||
| USB_ClassInfo_HID_Device_t Keyboard_HID_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.InterfaceNumber              = 0, | ||||
|  | ||||
| 				.ReportINEndpointNumber       = KEYBOARD_IN_EPNUM, | ||||
| 				.ReportINEndpointSize         = HID_EPSIZE, | ||||
| 				.ReportINEndpointDoubleBank   = false, | ||||
|  | ||||
| 				.PrevReportINBuffer           = PrevKeyboardHIDReportBuffer, | ||||
| 				.PrevReportINBufferSize       = sizeof(PrevKeyboardHIDReportBuffer), | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
| /** LUFA HID Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all HID Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. This is for the mouse HID | ||||
|  *  interface within the device. | ||||
|  */ | ||||
| USB_ClassInfo_HID_Device_t Mouse_HID_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.InterfaceNumber              = 1, | ||||
|  | ||||
| 				.ReportINEndpointNumber       = MOUSE_IN_EPNUM, | ||||
| 				.ReportINEndpointSize         = HID_EPSIZE, | ||||
|  | ||||
| 				.PrevReportINBuffer           = PrevMouseHIDReportBuffer, | ||||
| 				.PrevReportINBufferSize       = sizeof(PrevMouseHIDReportBuffer), | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		HID_Device_USBTask(&Keyboard_HID_Interface); | ||||
| 		HID_Device_USBTask(&Mouse_HID_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware() | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	Joystick_Init(); | ||||
| 	LEDs_Init(); | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
|     LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
|     LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= HID_Device_ConfigureEndpoints(&Keyboard_HID_Interface); | ||||
| 	ConfigSuccess &= HID_Device_ConfigureEndpoints(&Mouse_HID_Interface); | ||||
|  | ||||
| 	USB_Device_EnableSOFEvents(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	HID_Device_ProcessControlRequest(&Keyboard_HID_Interface); | ||||
| 	HID_Device_ProcessControlRequest(&Mouse_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB device Start Of Frame event. */ | ||||
| void EVENT_USB_Device_StartOfFrame(void) | ||||
| { | ||||
| 	HID_Device_MillisecondElapsed(&Keyboard_HID_Interface); | ||||
| 	HID_Device_MillisecondElapsed(&Mouse_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the creation of HID reports to the host. | ||||
|  * | ||||
|  *  \param[in]     HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in,out] ReportID    Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID | ||||
|  *  \param[in]     ReportType  Type of the report to create, either HID_REPORT_ITEM_In or HID_REPORT_ITEM_Feature | ||||
|  *  \param[out]    ReportData  Pointer to a buffer where the created report should be stored | ||||
|  *  \param[out]    ReportSize  Number of bytes written in the report (or zero if no report is to be sent | ||||
|  * | ||||
|  *  \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent | ||||
|  */ | ||||
| bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                          uint8_t* const ReportID, | ||||
|                                          const uint8_t ReportType, | ||||
|                                          void* ReportData, | ||||
|                                          uint16_t* const ReportSize) | ||||
| { | ||||
| 	uint8_t JoyStatus_LCL    = Joystick_GetStatus(); | ||||
| 	uint8_t ButtonStatus_LCL = Buttons_GetStatus(); | ||||
|  | ||||
| 	/* Determine which interface must have its report generated */ | ||||
| 	if (HIDInterfaceInfo == &Keyboard_HID_Interface) | ||||
| 	{ | ||||
| 		USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData; | ||||
|  | ||||
| 		/* If first board button not being held down, no keyboard report */ | ||||
| 		if (!(ButtonStatus_LCL & BUTTONS_BUTTON1)) | ||||
| 		  return 0; | ||||
|  | ||||
| 		KeyboardReport->Modifier = HID_KEYBOARD_MODIFIER_LEFTSHIFT; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_UP) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_A; | ||||
| 		else if (JoyStatus_LCL & JOY_DOWN) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_B; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_LEFT) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_C; | ||||
| 		else if (JoyStatus_LCL & JOY_RIGHT) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_D; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_PRESS) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_E; | ||||
|  | ||||
| 		*ReportSize = sizeof(USB_KeyboardReport_Data_t); | ||||
| 		return false; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData; | ||||
|  | ||||
| 		/* If first board button being held down, no mouse report */ | ||||
| 		if (ButtonStatus_LCL & BUTTONS_BUTTON1) | ||||
| 		  return 0; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_UP) | ||||
| 		  MouseReport->Y = -1; | ||||
| 		else if (JoyStatus_LCL & JOY_DOWN) | ||||
| 		  MouseReport->Y =  1; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_LEFT) | ||||
| 		  MouseReport->X = -1; | ||||
| 		else if (JoyStatus_LCL & JOY_RIGHT) | ||||
| 		  MouseReport->X =  1; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_PRESS) | ||||
| 		  MouseReport->Button |= (1 << 0); | ||||
|  | ||||
| 		*ReportSize = sizeof(USB_MouseReport_Data_t); | ||||
| 		return true; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the processing of HID reports from the host. | ||||
|  * | ||||
|  *  \param[in] HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in] ReportID    Report ID of the received report from the host | ||||
|  *  \param[in] ReportType  The type of report that the host has sent, either HID_REPORT_ITEM_Out or HID_REPORT_ITEM_Feature | ||||
|  *  \param[in] ReportData  Pointer to a buffer where the received report has been stored | ||||
|  *  \param[in] ReportSize  Size in bytes of the received HID report | ||||
|  */ | ||||
| void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                           const uint8_t ReportID, | ||||
|                                           const uint8_t ReportType, | ||||
|                                           const void* ReportData, | ||||
|                                           const uint16_t ReportSize) | ||||
| { | ||||
| 	if (HIDInterfaceInfo == &Keyboard_HID_Interface) | ||||
| 	{ | ||||
| 		uint8_t  LEDMask   = LEDS_NO_LEDS; | ||||
| 		uint8_t* LEDReport = (uint8_t*)ReportData; | ||||
|  | ||||
| 		if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK) | ||||
| 		  LEDMask |= LEDS_LED1; | ||||
|  | ||||
| 		if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK) | ||||
| 		  LEDMask |= LEDS_LED3; | ||||
|  | ||||
| 		if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK) | ||||
| 		  LEDMask |= LEDS_LED4; | ||||
|  | ||||
| 		LEDs_SetAllLEDs(LEDMask); | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -1,84 +1,84 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| #ifndef _KEYBOARD_MOUSE_H_ | ||||
| #define _KEYBOARD_MOUSE_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <stdbool.h> | ||||
| 		#include <string.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/Joystick.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/Board/Buttons.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
| 		void EVENT_USB_Device_StartOfFrame(void); | ||||
|  | ||||
| 		bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                         uint8_t* const ReportID, | ||||
| 		                                         const uint8_t ReportType, | ||||
| 		                                         void* ReportData, | ||||
| 		                                         uint16_t* const ReportSize); | ||||
| 		void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                          const uint8_t ReportID, | ||||
| 		                                          const uint8_t ReportType, | ||||
| 		                                          const void* ReportData, | ||||
| 		                                          const uint16_t ReportSize); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| #ifndef _KEYBOARD_MOUSE_H_ | ||||
| #define _KEYBOARD_MOUSE_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <stdbool.h> | ||||
| 		#include <string.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/Joystick.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/Board/Buttons.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
| 		void EVENT_USB_Device_StartOfFrame(void); | ||||
|  | ||||
| 		bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                         uint8_t* const ReportID, | ||||
| 		                                         const uint8_t ReportType, | ||||
| 		                                         void* ReportData, | ||||
| 		                                         uint16_t* const ReportSize); | ||||
| 		void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                          const uint8_t ReportID, | ||||
| 		                                          const uint8_t ReportType, | ||||
| 		                                          const void* ReportData, | ||||
| 		                                          const uint16_t ReportSize); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,78 +1,78 @@ | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage Dual HID Keyboard and Mouse Device Demo | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  *  - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Human Interface Device (HID)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>N/A</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF HID Specification \n | ||||
|  *        USBIF HID Usage Tables</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Low Speed Mode \n | ||||
|  *        Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Keyboard/Mouse demonstration application. This gives a simple reference | ||||
|  *  application for implementing a composite device containing both USB Keyboard | ||||
|  *  and USB Mouse functionality using the basic USB HID drivers in all modern OSes | ||||
|  *  (i.e. no special drivers required). This example uses two separate HID | ||||
|  *  interfaces for each function. It is boot protocol compatible, and thus works under | ||||
|  *  compatible BIOS as if it was a native keyboard and mouse (e.g. PS/2). | ||||
|  * | ||||
|  *  On start-up the system will automatically enumerate and function | ||||
|  *  as a keyboard when the USB connection to a host is present and the HWB is not | ||||
|  *  pressed. When enabled, manipulate the joystick to send the letters | ||||
|  *  a, b, c, d and e. See the USB HID documentation for more information | ||||
|  *  on sending keyboard event and key presses. | ||||
|  * | ||||
|  *  When the HWB is pressed, the mouse mode is enabled. When enabled, move the | ||||
|  *  joystick to move the pointer, and push the joystick inwards to simulate a | ||||
|  *  left-button click. | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td> | ||||
|  *     None | ||||
|  *    </td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  This file contains special DoxyGen information for the generation of the main page and other special | ||||
|  *  documentation pages. It is not a project source file. | ||||
|  */ | ||||
|  | ||||
| /** \mainpage Dual HID Keyboard and Mouse Device Demo | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  *  - Series 6 USB AVRs (AT90USBxxx6) | ||||
|  *  - Series 4 USB AVRs (ATMEGAxxU4) | ||||
|  *  - Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2) | ||||
|  * | ||||
|  *  \section Sec_Info USB Information: | ||||
|  * | ||||
|  *  The following table gives a rundown of the USB utilization of this demo. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Mode:</b></td> | ||||
|  *    <td>Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Human Interface Device (HID)</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>N/A</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF HID Specification \n | ||||
|  *        USBIF HID Usage Tables</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Low Speed Mode \n | ||||
|  *        Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Keyboard/Mouse demonstration application. This gives a simple reference | ||||
|  *  application for implementing a composite device containing both USB Keyboard | ||||
|  *  and USB Mouse functionality using the basic USB HID drivers in all modern OSes | ||||
|  *  (i.e. no special drivers required). This example uses two separate HID | ||||
|  *  interfaces for each function. It is boot protocol compatible, and thus works under | ||||
|  *  compatible BIOS as if it was a native keyboard and mouse (e.g. PS/2). | ||||
|  * | ||||
|  *  On start-up the system will automatically enumerate and function | ||||
|  *  as a keyboard when the USB connection to a host is present and the HWB is not | ||||
|  *  pressed. When enabled, manipulate the joystick to send the letters | ||||
|  *  a, b, c, d and e. See the USB HID documentation for more information | ||||
|  *  on sending keyboard event and key presses. | ||||
|  * | ||||
|  *  When the HWB is pressed, the mouse mode is enabled. When enabled, move the | ||||
|  *  joystick to move the pointer, and push the joystick inwards to simulate a | ||||
|  *  left-button click. | ||||
|  * | ||||
|  *  \section Sec_Options Project Options | ||||
|  * | ||||
|  *  The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. | ||||
|  * | ||||
|  *  <table> | ||||
|  *   <tr> | ||||
|  *    <td> | ||||
|  *     None | ||||
|  *    </td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  */ | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,294 +1,294 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** HID class report descriptor. This is a special descriptor constructed with values from the | ||||
|  *  USBIF HID class specification to describe the reports and capabilities of the HID device. This | ||||
|  *  descriptor is parsed by the host and its contents used to determine what data (and in what encoding) | ||||
|  *  the device will send, and what it may be sent back from the host. Refer to the HID specification for | ||||
|  *  more details on HID report descriptors. | ||||
|  * | ||||
|  *  This descriptor describes the multiple possible reports of the HID interface's report structure. | ||||
|  */ | ||||
| const USB_Descriptor_HIDReport_Datatype_t PROGMEM HIDReport[] = | ||||
| { | ||||
| 	/* Mouse Report */ | ||||
| 	HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | ||||
| 	HID_RI_USAGE(8, 0x02), /* Mouse */ | ||||
| 	HID_RI_COLLECTION(8, 0x01), /* Application */ | ||||
| 		HID_RI_REPORT_ID(8, HID_REPORTID_MouseReport), | ||||
| 	    HID_RI_USAGE(8, 0x01), /* Pointer */ | ||||
| 	    HID_RI_COLLECTION(8, 0x00), /* Physical */ | ||||
| 	        HID_RI_USAGE_PAGE(8, 0x09), /* Button */ | ||||
| 	        HID_RI_USAGE_MINIMUM(8, 0x01), | ||||
| 	        HID_RI_USAGE_MAXIMUM(8, 0x03), | ||||
| 	        HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||||
| 	        HID_RI_LOGICAL_MAXIMUM(8, 0x01), | ||||
| 	        HID_RI_REPORT_COUNT(8, 0x03), | ||||
| 	        HID_RI_REPORT_SIZE(8, 0x01), | ||||
| 	        HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), | ||||
| 	        HID_RI_REPORT_COUNT(8, 0x01), | ||||
| 	        HID_RI_REPORT_SIZE(8, 0x05), | ||||
| 	        HID_RI_INPUT(8, HID_IOF_CONSTANT), | ||||
| 	        HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | ||||
| 	        HID_RI_USAGE(8, 0x30), /* Usage X */ | ||||
| 	        HID_RI_USAGE(8, 0x31), /* Usage Y */ | ||||
| 	        HID_RI_LOGICAL_MINIMUM(8, -1), | ||||
| 	        HID_RI_LOGICAL_MAXIMUM(8, 1), | ||||
| 	        HID_RI_PHYSICAL_MINIMUM(8, -1), | ||||
| 	        HID_RI_PHYSICAL_MAXIMUM(8, 1), | ||||
| 	        HID_RI_REPORT_COUNT(8, 0x02), | ||||
| 	        HID_RI_REPORT_SIZE(8, 0x08), | ||||
| 	        HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), | ||||
| 	    HID_RI_END_COLLECTION(0), | ||||
| 	HID_RI_END_COLLECTION(0), | ||||
| 	 | ||||
| 	/* Keyboard Report */ | ||||
| 	HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | ||||
| 	HID_RI_USAGE(8, 0x06), /* Keyboard */ | ||||
| 	HID_RI_COLLECTION(8, 0x01), /* Application */ | ||||
| 		HID_RI_REPORT_ID(8, HID_REPORTID_KeyboardReport), | ||||
| 	    HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */ | ||||
| 	    HID_RI_USAGE_MINIMUM(8, 0xE0), /* Keyboard Left Control */ | ||||
| 	    HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */ | ||||
| 	    HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||||
| 	    HID_RI_LOGICAL_MAXIMUM(8, 0x01), | ||||
| 	    HID_RI_REPORT_SIZE(8, 0x01), | ||||
| 	    HID_RI_REPORT_COUNT(8, 0x08), | ||||
| 	    HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), | ||||
| 	    HID_RI_REPORT_COUNT(8, 0x01), | ||||
| 	    HID_RI_REPORT_SIZE(8, 0x08), | ||||
| 	    HID_RI_INPUT(8, HID_IOF_CONSTANT), | ||||
| 	    HID_RI_USAGE_PAGE(8, 0x08), /* LEDs */ | ||||
| 	    HID_RI_USAGE_MINIMUM(8, 0x01), /* Num Lock */ | ||||
| 	    HID_RI_USAGE_MAXIMUM(8, 0x05), /* Kana */ | ||||
| 	    HID_RI_REPORT_COUNT(8, 0x05), | ||||
| 	    HID_RI_REPORT_SIZE(8, 0x01), | ||||
| 	    HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), | ||||
| 	    HID_RI_REPORT_COUNT(8, 0x01), | ||||
| 	    HID_RI_REPORT_SIZE(8, 0x03), | ||||
| 	    HID_RI_OUTPUT(8, HID_IOF_CONSTANT), | ||||
| 	    HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||||
| 	    HID_RI_LOGICAL_MAXIMUM(8, 0x65), | ||||
| 	    HID_RI_USAGE_PAGE(8, 0x07), /* Keyboard */ | ||||
| 	    HID_RI_USAGE_MINIMUM(8, 0x00), /* Reserved (no event indicated) */ | ||||
| 	    HID_RI_USAGE_MAXIMUM(8, 0x65), /* Keyboard Application */ | ||||
| 	    HID_RI_REPORT_COUNT(8, 0x06), | ||||
| 	    HID_RI_REPORT_SIZE(8, 0x08), | ||||
| 	    HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), | ||||
| 	HID_RI_END_COLLECTION(0), | ||||
| }; | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x2066, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 1, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0x00, | ||||
| 			.AlternateSetting       = 0x00, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = HID_CSCP_HIDClass, | ||||
| 			.SubClass               = HID_CSCP_NonBootSubclass, | ||||
| 			.Protocol               = HID_CSCP_NonBootProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.HID_HIDData = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||||
|  | ||||
| 			.HIDSpec                = VERSION_BCD(01.11), | ||||
| 			.CountryCode            = 0x00, | ||||
| 			.TotalReportDescriptors = 1, | ||||
| 			.HIDReportType          = HID_DTYPE_Report, | ||||
| 			.HIDReportLength        = sizeof(HIDReport) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_ReportINEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | HID_IN_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = HID_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(26), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Multi HID Report Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 		case HID_DTYPE_HID: | ||||
| 			Address = &ConfigurationDescriptor.HID_HIDData; | ||||
| 			Size    = sizeof(USB_HID_Descriptor_HID_t);			 | ||||
| 			break; | ||||
| 		case HID_DTYPE_Report: | ||||
| 			Address = &HIDReport; | ||||
| 			Size    = sizeof(HIDReport); | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  USB Device Descriptors, for library use when in USB device mode. Descriptors are special | ||||
|  *  computer-readable structures which the host requests upon device enumeration, to determine | ||||
|  *  the device's capabilities and functions. | ||||
|  */ | ||||
|  | ||||
| #include "Descriptors.h" | ||||
|  | ||||
| /** HID class report descriptor. This is a special descriptor constructed with values from the | ||||
|  *  USBIF HID class specification to describe the reports and capabilities of the HID device. This | ||||
|  *  descriptor is parsed by the host and its contents used to determine what data (and in what encoding) | ||||
|  *  the device will send, and what it may be sent back from the host. Refer to the HID specification for | ||||
|  *  more details on HID report descriptors. | ||||
|  * | ||||
|  *  This descriptor describes the multiple possible reports of the HID interface's report structure. | ||||
|  */ | ||||
| const USB_Descriptor_HIDReport_Datatype_t PROGMEM HIDReport[] = | ||||
| { | ||||
| 	/* Mouse Report */ | ||||
| 	HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | ||||
| 	HID_RI_USAGE(8, 0x02), /* Mouse */ | ||||
| 	HID_RI_COLLECTION(8, 0x01), /* Application */ | ||||
| 		HID_RI_REPORT_ID(8, HID_REPORTID_MouseReport), | ||||
| 	    HID_RI_USAGE(8, 0x01), /* Pointer */ | ||||
| 	    HID_RI_COLLECTION(8, 0x00), /* Physical */ | ||||
| 	        HID_RI_USAGE_PAGE(8, 0x09), /* Button */ | ||||
| 	        HID_RI_USAGE_MINIMUM(8, 0x01), | ||||
| 	        HID_RI_USAGE_MAXIMUM(8, 0x03), | ||||
| 	        HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||||
| 	        HID_RI_LOGICAL_MAXIMUM(8, 0x01), | ||||
| 	        HID_RI_REPORT_COUNT(8, 0x03), | ||||
| 	        HID_RI_REPORT_SIZE(8, 0x01), | ||||
| 	        HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), | ||||
| 	        HID_RI_REPORT_COUNT(8, 0x01), | ||||
| 	        HID_RI_REPORT_SIZE(8, 0x05), | ||||
| 	        HID_RI_INPUT(8, HID_IOF_CONSTANT), | ||||
| 	        HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | ||||
| 	        HID_RI_USAGE(8, 0x30), /* Usage X */ | ||||
| 	        HID_RI_USAGE(8, 0x31), /* Usage Y */ | ||||
| 	        HID_RI_LOGICAL_MINIMUM(8, -1), | ||||
| 	        HID_RI_LOGICAL_MAXIMUM(8, 1), | ||||
| 	        HID_RI_PHYSICAL_MINIMUM(8, -1), | ||||
| 	        HID_RI_PHYSICAL_MAXIMUM(8, 1), | ||||
| 	        HID_RI_REPORT_COUNT(8, 0x02), | ||||
| 	        HID_RI_REPORT_SIZE(8, 0x08), | ||||
| 	        HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), | ||||
| 	    HID_RI_END_COLLECTION(0), | ||||
| 	HID_RI_END_COLLECTION(0), | ||||
| 	 | ||||
| 	/* Keyboard Report */ | ||||
| 	HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | ||||
| 	HID_RI_USAGE(8, 0x06), /* Keyboard */ | ||||
| 	HID_RI_COLLECTION(8, 0x01), /* Application */ | ||||
| 		HID_RI_REPORT_ID(8, HID_REPORTID_KeyboardReport), | ||||
| 	    HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */ | ||||
| 	    HID_RI_USAGE_MINIMUM(8, 0xE0), /* Keyboard Left Control */ | ||||
| 	    HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */ | ||||
| 	    HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||||
| 	    HID_RI_LOGICAL_MAXIMUM(8, 0x01), | ||||
| 	    HID_RI_REPORT_SIZE(8, 0x01), | ||||
| 	    HID_RI_REPORT_COUNT(8, 0x08), | ||||
| 	    HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), | ||||
| 	    HID_RI_REPORT_COUNT(8, 0x01), | ||||
| 	    HID_RI_REPORT_SIZE(8, 0x08), | ||||
| 	    HID_RI_INPUT(8, HID_IOF_CONSTANT), | ||||
| 	    HID_RI_USAGE_PAGE(8, 0x08), /* LEDs */ | ||||
| 	    HID_RI_USAGE_MINIMUM(8, 0x01), /* Num Lock */ | ||||
| 	    HID_RI_USAGE_MAXIMUM(8, 0x05), /* Kana */ | ||||
| 	    HID_RI_REPORT_COUNT(8, 0x05), | ||||
| 	    HID_RI_REPORT_SIZE(8, 0x01), | ||||
| 	    HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), | ||||
| 	    HID_RI_REPORT_COUNT(8, 0x01), | ||||
| 	    HID_RI_REPORT_SIZE(8, 0x03), | ||||
| 	    HID_RI_OUTPUT(8, HID_IOF_CONSTANT), | ||||
| 	    HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||||
| 	    HID_RI_LOGICAL_MAXIMUM(8, 0x65), | ||||
| 	    HID_RI_USAGE_PAGE(8, 0x07), /* Keyboard */ | ||||
| 	    HID_RI_USAGE_MINIMUM(8, 0x00), /* Reserved (no event indicated) */ | ||||
| 	    HID_RI_USAGE_MAXIMUM(8, 0x65), /* Keyboard Application */ | ||||
| 	    HID_RI_REPORT_COUNT(8, 0x06), | ||||
| 	    HID_RI_REPORT_SIZE(8, 0x08), | ||||
| 	    HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), | ||||
| 	HID_RI_END_COLLECTION(0), | ||||
| }; | ||||
|  | ||||
| /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall | ||||
|  *  device characteristics, including the supported USB version, control endpoint size and the | ||||
|  *  number of device configurations. The descriptor is read out by the USB host when the enumeration | ||||
|  *  process begins. | ||||
|  */ | ||||
| const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = | ||||
| { | ||||
| 	.Header                 = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, | ||||
|  | ||||
| 	.USBSpecification       = VERSION_BCD(01.10), | ||||
| 	.Class                  = USB_CSCP_NoDeviceClass, | ||||
| 	.SubClass               = USB_CSCP_NoDeviceSubclass, | ||||
| 	.Protocol               = USB_CSCP_NoDeviceProtocol, | ||||
|  | ||||
| 	.Endpoint0Size          = FIXED_CONTROL_ENDPOINT_SIZE, | ||||
|  | ||||
| 	.VendorID               = 0x03EB, | ||||
| 	.ProductID              = 0x2066, | ||||
| 	.ReleaseNumber          = VERSION_BCD(00.01), | ||||
|  | ||||
| 	.ManufacturerStrIndex   = 0x01, | ||||
| 	.ProductStrIndex        = 0x02, | ||||
| 	.SerialNumStrIndex      = NO_DESCRIPTOR, | ||||
|  | ||||
| 	.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS | ||||
| }; | ||||
|  | ||||
| /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage | ||||
|  *  of the device in one of its supported configurations, including information about any device interfaces | ||||
|  *  and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting | ||||
|  *  a configuration so that the host may correctly communicate with the USB device. | ||||
|  */ | ||||
| const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | ||||
| { | ||||
| 	.Config = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | ||||
|  | ||||
| 			.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | ||||
| 			.TotalInterfaces        = 1, | ||||
|  | ||||
| 			.ConfigurationNumber    = 1, | ||||
| 			.ConfigurationStrIndex  = NO_DESCRIPTOR, | ||||
|  | ||||
| 			.ConfigAttributes       = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), | ||||
|  | ||||
| 			.MaxPowerConsumption    = USB_CONFIG_POWER_MA(100) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_Interface = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||||
|  | ||||
| 			.InterfaceNumber        = 0x00, | ||||
| 			.AlternateSetting       = 0x00, | ||||
|  | ||||
| 			.TotalEndpoints         = 1, | ||||
|  | ||||
| 			.Class                  = HID_CSCP_HIDClass, | ||||
| 			.SubClass               = HID_CSCP_NonBootSubclass, | ||||
| 			.Protocol               = HID_CSCP_NonBootProtocol, | ||||
|  | ||||
| 			.InterfaceStrIndex      = NO_DESCRIPTOR | ||||
| 		}, | ||||
|  | ||||
| 	.HID_HIDData = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||||
|  | ||||
| 			.HIDSpec                = VERSION_BCD(01.11), | ||||
| 			.CountryCode            = 0x00, | ||||
| 			.TotalReportDescriptors = 1, | ||||
| 			.HIDReportType          = HID_DTYPE_Report, | ||||
| 			.HIDReportLength        = sizeof(HIDReport) | ||||
| 		}, | ||||
|  | ||||
| 	.HID_ReportINEndpoint = | ||||
| 		{ | ||||
| 			.Header                 = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||||
|  | ||||
| 			.EndpointAddress        = (ENDPOINT_DIR_IN | HID_IN_EPNUM), | ||||
| 			.Attributes             = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||||
| 			.EndpointSize           = HID_EPSIZE, | ||||
| 			.PollingIntervalMS      = 0x01 | ||||
| 		}, | ||||
| }; | ||||
|  | ||||
| /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests | ||||
|  *  the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate | ||||
|  *  via the language ID table available at USB.org what languages the device supports for its string descriptors. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM LanguageString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = {LANGUAGE_ID_ENG} | ||||
| }; | ||||
|  | ||||
| /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable | ||||
|  *  form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ManufacturerString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"Dean Camera" | ||||
| }; | ||||
|  | ||||
| /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, | ||||
|  *  and is read out upon request by the host when the appropriate string ID is requested, listed in the Device | ||||
|  *  Descriptor. | ||||
|  */ | ||||
| const USB_Descriptor_String_t PROGMEM ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(26), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"LUFA Multi HID Report Demo" | ||||
| }; | ||||
|  | ||||
| /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" | ||||
|  *  documentation) by the application code so that the address and size of a requested descriptor can be given | ||||
|  *  to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function | ||||
|  *  is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the | ||||
|  *  USB host. | ||||
|  */ | ||||
| uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
|                                     const uint8_t wIndex, | ||||
|                                     const void** const DescriptorAddress) | ||||
| { | ||||
| 	const uint8_t  DescriptorType   = (wValue >> 8); | ||||
| 	const uint8_t  DescriptorNumber = (wValue & 0xFF); | ||||
|  | ||||
| 	const void* Address = NULL; | ||||
| 	uint16_t    Size    = NO_DESCRIPTOR; | ||||
|  | ||||
| 	switch (DescriptorType) | ||||
| 	{ | ||||
| 		case DTYPE_Device: | ||||
| 			Address = &DeviceDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Device_t); | ||||
| 			break; | ||||
| 		case DTYPE_Configuration: | ||||
| 			Address = &ConfigurationDescriptor; | ||||
| 			Size    = sizeof(USB_Descriptor_Configuration_t); | ||||
| 			break; | ||||
| 		case DTYPE_String: | ||||
| 			switch (DescriptorNumber) | ||||
| 			{ | ||||
| 				case 0x00: | ||||
| 					Address = &LanguageString; | ||||
| 					Size    = pgm_read_byte(&LanguageString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x01: | ||||
| 					Address = &ManufacturerString; | ||||
| 					Size    = pgm_read_byte(&ManufacturerString.Header.Size); | ||||
| 					break; | ||||
| 				case 0x02: | ||||
| 					Address = &ProductString; | ||||
| 					Size    = pgm_read_byte(&ProductString.Header.Size); | ||||
| 					break; | ||||
| 			} | ||||
|  | ||||
| 			break; | ||||
| 		case HID_DTYPE_HID: | ||||
| 			Address = &ConfigurationDescriptor.HID_HIDData; | ||||
| 			Size    = sizeof(USB_HID_Descriptor_HID_t);			 | ||||
| 			break; | ||||
| 		case HID_DTYPE_Report: | ||||
| 			Address = &HIDReport; | ||||
| 			Size    = sizeof(HIDReport); | ||||
| 			break; | ||||
| 	} | ||||
|  | ||||
| 	*DescriptorAddress = Address; | ||||
| 	return Size; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,81 +1,81 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t Config; | ||||
|  | ||||
| 			// Combined Keyboard/Mouse HID Interface | ||||
| 			USB_Descriptor_Interface_t            HID_Interface; | ||||
| 			USB_HID_Descriptor_HID_t              HID_HIDData; | ||||
| 			USB_Descriptor_Endpoint_t             HID_ReportINEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the HID reporting IN endpoint. */ | ||||
| 		#define HID_IN_EPNUM              1 | ||||
|  | ||||
| 		/** Size in bytes of each of the HID reporting IN endpoint. */ | ||||
| 		#define HID_EPSIZE                8 | ||||
| 	 | ||||
| 	/* Enums: */ | ||||
| 		/** Enum for the HID report IDs used in the device. */ | ||||
| 		enum | ||||
| 		{ | ||||
| 			HID_REPORTID_MouseReport    = 0x01, /**< Report ID for the Mouse report within the device. */ | ||||
| 			HID_REPORTID_KeyboardReport = 0x02, /**< Report ID for the Keyboard report within the device. */ | ||||
| 		} HID_Report_IDs; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Header file for Descriptors.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _DESCRIPTORS_H_ | ||||
| #define _DESCRIPTORS_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/pgmspace.h> | ||||
|  | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Type Defines: */ | ||||
| 		/** Type define for the device configuration descriptor structure. This must be defined in the | ||||
| 		 *  application code, as the configuration descriptor contains several sub-descriptors which | ||||
| 		 *  vary between devices, and which describe the device's usage to the host. | ||||
| 		 */ | ||||
| 		typedef struct | ||||
| 		{ | ||||
| 			USB_Descriptor_Configuration_Header_t Config; | ||||
|  | ||||
| 			// Combined Keyboard/Mouse HID Interface | ||||
| 			USB_Descriptor_Interface_t            HID_Interface; | ||||
| 			USB_HID_Descriptor_HID_t              HID_HIDData; | ||||
| 			USB_Descriptor_Endpoint_t             HID_ReportINEndpoint; | ||||
| 		} USB_Descriptor_Configuration_t; | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** Endpoint number of the HID reporting IN endpoint. */ | ||||
| 		#define HID_IN_EPNUM              1 | ||||
|  | ||||
| 		/** Size in bytes of each of the HID reporting IN endpoint. */ | ||||
| 		#define HID_EPSIZE                8 | ||||
| 	 | ||||
| 	/* Enums: */ | ||||
| 		/** Enum for the HID report IDs used in the device. */ | ||||
| 		enum | ||||
| 		{ | ||||
| 			HID_REPORTID_MouseReport    = 0x01, /**< Report ID for the Mouse report within the device. */ | ||||
| 			HID_REPORTID_KeyboardReport = 0x02, /**< Report ID for the Keyboard report within the device. */ | ||||
| 		} HID_Report_IDs; | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | ||||
| 		                                    const uint8_t wIndex, | ||||
| 		                                    const void** const DescriptorAddress) | ||||
| 		                                    ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1 +1 @@ | ||||
| <AVRStudio><MANAGEMENT><ProjectName>KeyboardMouseMultiReport</ProjectName><Created>26-Jan-2011 20:01:00</Created><LastEdit>26-Jan-2011 20:01:00</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>26-Jan-2011 20:01:00</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\KeyboardMouseMultiReport\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>Descriptors.c</SOURCEFILE><SOURCEFILE>KeyboardMouseMultiReport.c</SOURCEFILE><HEADERFILE>Descriptors.h</HEADERFILE><HEADERFILE>KeyboardMouseMultiReport.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>KeyboardMouseMultiReport.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
| <AVRStudio><MANAGEMENT><ProjectName>KeyboardMouseMultiReport</ProjectName><Created>26-Jan-2011 20:01:00</Created><LastEdit>26-Jan-2011 20:01:00</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>26-Jan-2011 20:01:00</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile></ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Users\Dean\Documents\Electronics\Projects\WORK\LUFAWORK\Demos\Device\ClassDriver\KeyboardMouseMultiReport\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET></CURRENT_TARGET><CURRENT_PART></CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>Descriptors.c</SOURCEFILE><SOURCEFILE>KeyboardMouseMultiReport.c</SOURCEFILE><HEADERFILE>Descriptors.h</HEADERFILE><HEADERFILE>KeyboardMouseMultiReport.h</HEADERFILE><OTHERFILE>makefile</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>makefile</EXTERNALMAKEFILE><PART>atmega128</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>KeyboardMouseMultiReport.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio> | ||||
|   | ||||
| @@ -1,223 +1,223 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the KeyboardMouseMultiReport demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "KeyboardMouseMultiReport.h" | ||||
|  | ||||
| /** Buffer to hold the previously generated HID report, for comparison purposes inside the HID class driver. */ | ||||
| static uint8_t PrevHIDReportBuffer[MAX(sizeof(USB_KeyboardReport_Data_t), sizeof(USB_MouseReport_Data_t))]; | ||||
|  | ||||
| /** LUFA HID Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all HID Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_HID_Device_t Device_HID_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.InterfaceNumber              = 0, | ||||
|  | ||||
| 				.ReportINEndpointNumber       = HID_IN_EPNUM, | ||||
| 				.ReportINEndpointSize         = HID_EPSIZE, | ||||
| 				.ReportINEndpointDoubleBank   = false, | ||||
|  | ||||
| 				.PrevReportINBuffer           = PrevHIDReportBuffer, | ||||
| 				.PrevReportINBufferSize       = sizeof(PrevHIDReportBuffer), | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		HID_Device_USBTask(&Device_HID_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware() | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	Joystick_Init(); | ||||
| 	LEDs_Init(); | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
|     LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
|     LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= HID_Device_ConfigureEndpoints(&Device_HID_Interface); | ||||
|  | ||||
| 	USB_Device_EnableSOFEvents(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	HID_Device_ProcessControlRequest(&Device_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB device Start Of Frame event. */ | ||||
| void EVENT_USB_Device_StartOfFrame(void) | ||||
| { | ||||
| 	HID_Device_MillisecondElapsed(&Device_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the creation of HID reports to the host. | ||||
|  * | ||||
|  *  \param[in]     HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in,out] ReportID    Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID | ||||
|  *  \param[in]     ReportType  Type of the report to create, either HID_REPORT_ITEM_In or HID_REPORT_ITEM_Feature | ||||
|  *  \param[out]    ReportData  Pointer to a buffer where the created report should be stored | ||||
|  *  \param[out]    ReportSize  Number of bytes written in the report (or zero if no report is to be sent | ||||
|  * | ||||
|  *  \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent | ||||
|  */ | ||||
| bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                          uint8_t* const ReportID, | ||||
|                                          const uint8_t ReportType, | ||||
|                                          void* ReportData, | ||||
|                                          uint16_t* const ReportSize) | ||||
| { | ||||
| 	uint8_t JoyStatus_LCL    = Joystick_GetStatus(); | ||||
| 	uint8_t ButtonStatus_LCL = Buttons_GetStatus(); | ||||
|  | ||||
| 	if (!(ButtonStatus_LCL & BUTTONS_BUTTON1)) | ||||
| 	{		 | ||||
| 		USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData; | ||||
|  | ||||
| 		KeyboardReport->Modifier = HID_KEYBOARD_MODIFER_LEFTSHIFT; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_UP) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_A; | ||||
| 		else if (JoyStatus_LCL & JOY_DOWN) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_B; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_LEFT) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_C; | ||||
| 		else if (JoyStatus_LCL & JOY_RIGHT) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_D; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_PRESS) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_E; | ||||
|  | ||||
| 		*ReportID   = HID_REPORTID_KeyboardReport; | ||||
| 		*ReportSize = sizeof(USB_KeyboardReport_Data_t); | ||||
| 		return false; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_UP) | ||||
| 		  MouseReport->Y = -1; | ||||
| 		else if (JoyStatus_LCL & JOY_DOWN) | ||||
| 		  MouseReport->Y =  1; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_LEFT) | ||||
| 		  MouseReport->X = -1; | ||||
| 		else if (JoyStatus_LCL & JOY_RIGHT) | ||||
| 		  MouseReport->X =  1; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_PRESS) | ||||
| 		  MouseReport->Button |= (1 << 0); | ||||
|  | ||||
| 		*ReportID   = HID_REPORTID_MouseReport; | ||||
| 		*ReportSize = sizeof(USB_MouseReport_Data_t); | ||||
| 		return true; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the processing of HID reports from the host. | ||||
|  * | ||||
|  *  \param[in] HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in] ReportID    Report ID of the received report from the host | ||||
|  *  \param[in] ReportType  The type of report that the host has sent, either HID_REPORT_ITEM_Out or HID_REPORT_ITEM_Feature | ||||
|  *  \param[in] ReportData  Pointer to a buffer where the received report has been stored | ||||
|  *  \param[in] ReportSize  Size in bytes of the received HID report | ||||
|  */ | ||||
| void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                           const uint8_t ReportID, | ||||
|                                           const uint8_t ReportType, | ||||
|                                           const void* ReportData, | ||||
|                                           const uint16_t ReportSize) | ||||
| { | ||||
| 	uint8_t  LEDMask   = LEDS_NO_LEDS; | ||||
| 	uint8_t* LEDReport = (uint8_t*)ReportData; | ||||
|  | ||||
| 	if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK) | ||||
| 	  LEDMask |= LEDS_LED1; | ||||
|  | ||||
| 	if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK) | ||||
| 	  LEDMask |= LEDS_LED3; | ||||
|  | ||||
| 	if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK) | ||||
| 	  LEDMask |= LEDS_LED4; | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMask); | ||||
| } | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  * | ||||
|  *  Main source file for the KeyboardMouseMultiReport demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "KeyboardMouseMultiReport.h" | ||||
|  | ||||
| /** Buffer to hold the previously generated HID report, for comparison purposes inside the HID class driver. */ | ||||
| static uint8_t PrevHIDReportBuffer[MAX(sizeof(USB_KeyboardReport_Data_t), sizeof(USB_MouseReport_Data_t))]; | ||||
|  | ||||
| /** LUFA HID Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all HID Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_HID_Device_t Device_HID_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.InterfaceNumber              = 0, | ||||
|  | ||||
| 				.ReportINEndpointNumber       = HID_IN_EPNUM, | ||||
| 				.ReportINEndpointSize         = HID_EPSIZE, | ||||
| 				.ReportINEndpointDoubleBank   = false, | ||||
|  | ||||
| 				.PrevReportINBuffer           = PrevHIDReportBuffer, | ||||
| 				.PrevReportINBufferSize       = sizeof(PrevHIDReportBuffer), | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine contains the overall program flow, including initial | ||||
|  *  setup of all components and the main program loop. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		HID_Device_USBTask(&Device_HID_Interface); | ||||
| 		USB_USBTask(); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** Configures the board hardware and chip peripherals for the demo's functionality. */ | ||||
| void SetupHardware() | ||||
| { | ||||
| 	/* Disable watchdog if enabled by bootloader/fuses */ | ||||
| 	MCUSR &= ~(1 << WDRF); | ||||
| 	wdt_disable(); | ||||
|  | ||||
| 	/* Disable clock division */ | ||||
| 	clock_prescale_set(clock_div_1); | ||||
|  | ||||
| 	/* Hardware Initialization */ | ||||
| 	Joystick_Init(); | ||||
| 	LEDs_Init(); | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Connection event. */ | ||||
| void EVENT_USB_Device_Connect(void) | ||||
| { | ||||
|     LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Disconnection event. */ | ||||
| void EVENT_USB_Device_Disconnect(void) | ||||
| { | ||||
|     LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Configuration Changed event. */ | ||||
| void EVENT_USB_Device_ConfigurationChanged(void) | ||||
| { | ||||
| 	bool ConfigSuccess = true; | ||||
|  | ||||
| 	ConfigSuccess &= HID_Device_ConfigureEndpoints(&Device_HID_Interface); | ||||
|  | ||||
| 	USB_Device_EnableSOFEvents(); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
| /** Event handler for the library USB Control Request reception event. */ | ||||
| void EVENT_USB_Device_ControlRequest(void) | ||||
| { | ||||
| 	HID_Device_ProcessControlRequest(&Device_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB device Start Of Frame event. */ | ||||
| void EVENT_USB_Device_StartOfFrame(void) | ||||
| { | ||||
| 	HID_Device_MillisecondElapsed(&Device_HID_Interface); | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the creation of HID reports to the host. | ||||
|  * | ||||
|  *  \param[in]     HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in,out] ReportID    Report ID requested by the host if non-zero, otherwise callback should set to the generated report ID | ||||
|  *  \param[in]     ReportType  Type of the report to create, either HID_REPORT_ITEM_In or HID_REPORT_ITEM_Feature | ||||
|  *  \param[out]    ReportData  Pointer to a buffer where the created report should be stored | ||||
|  *  \param[out]    ReportSize  Number of bytes written in the report (or zero if no report is to be sent | ||||
|  * | ||||
|  *  \return Boolean true to force the sending of the report, false to let the library determine if it needs to be sent | ||||
|  */ | ||||
| bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                          uint8_t* const ReportID, | ||||
|                                          const uint8_t ReportType, | ||||
|                                          void* ReportData, | ||||
|                                          uint16_t* const ReportSize) | ||||
| { | ||||
| 	uint8_t JoyStatus_LCL    = Joystick_GetStatus(); | ||||
| 	uint8_t ButtonStatus_LCL = Buttons_GetStatus(); | ||||
|  | ||||
| 	if (!(ButtonStatus_LCL & BUTTONS_BUTTON1)) | ||||
| 	{		 | ||||
| 		USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData; | ||||
|  | ||||
| 		KeyboardReport->Modifier = HID_KEYBOARD_MODIFIER_LEFTSHIFT; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_UP) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_A; | ||||
| 		else if (JoyStatus_LCL & JOY_DOWN) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_B; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_LEFT) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_C; | ||||
| 		else if (JoyStatus_LCL & JOY_RIGHT) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_D; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_PRESS) | ||||
| 		  KeyboardReport->KeyCode[0] = HID_KEYBOARD_SC_E; | ||||
|  | ||||
| 		*ReportID   = HID_REPORTID_KeyboardReport; | ||||
| 		*ReportSize = sizeof(USB_KeyboardReport_Data_t); | ||||
| 		return false; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_UP) | ||||
| 		  MouseReport->Y = -1; | ||||
| 		else if (JoyStatus_LCL & JOY_DOWN) | ||||
| 		  MouseReport->Y =  1; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_LEFT) | ||||
| 		  MouseReport->X = -1; | ||||
| 		else if (JoyStatus_LCL & JOY_RIGHT) | ||||
| 		  MouseReport->X =  1; | ||||
|  | ||||
| 		if (JoyStatus_LCL & JOY_PRESS) | ||||
| 		  MouseReport->Button |= (1 << 0); | ||||
|  | ||||
| 		*ReportID   = HID_REPORTID_MouseReport; | ||||
| 		*ReportSize = sizeof(USB_MouseReport_Data_t); | ||||
| 		return true; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| /** HID class driver callback function for the processing of HID reports from the host. | ||||
|  * | ||||
|  *  \param[in] HIDInterfaceInfo  Pointer to the HID class interface configuration structure being referenced | ||||
|  *  \param[in] ReportID    Report ID of the received report from the host | ||||
|  *  \param[in] ReportType  The type of report that the host has sent, either HID_REPORT_ITEM_Out or HID_REPORT_ITEM_Feature | ||||
|  *  \param[in] ReportData  Pointer to a buffer where the received report has been stored | ||||
|  *  \param[in] ReportSize  Size in bytes of the received HID report | ||||
|  */ | ||||
| void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
|                                           const uint8_t ReportID, | ||||
|                                           const uint8_t ReportType, | ||||
|                                           const void* ReportData, | ||||
|                                           const uint16_t ReportSize) | ||||
| { | ||||
| 	uint8_t  LEDMask   = LEDS_NO_LEDS; | ||||
| 	uint8_t* LEDReport = (uint8_t*)ReportData; | ||||
|  | ||||
| 	if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK) | ||||
| 	  LEDMask |= LEDS_LED1; | ||||
|  | ||||
| 	if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK) | ||||
| 	  LEDMask |= LEDS_LED3; | ||||
|  | ||||
| 	if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK) | ||||
| 	  LEDMask |= LEDS_LED4; | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMask); | ||||
| } | ||||
|   | ||||
| @@ -1,84 +1,84 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| #ifndef _KEYBOARD_MOUSE_H_ | ||||
| #define _KEYBOARD_MOUSE_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <stdbool.h> | ||||
| 		#include <string.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/Joystick.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/Board/Buttons.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
| 		void EVENT_USB_Device_StartOfFrame(void); | ||||
|  | ||||
| 		bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                         uint8_t* const ReportID, | ||||
| 		                                         const uint8_t ReportType, | ||||
| 		                                         void* ReportData, | ||||
| 		                                         uint16_t* const ReportSize); | ||||
| 		void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                          const uint8_t ReportID, | ||||
| 		                                          const uint8_t ReportType, | ||||
| 		                                          const void* ReportData, | ||||
| 		                                          const uint16_t ReportSize); | ||||
|  | ||||
| #endif | ||||
|  | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
|   without fee, provided that the above copyright notice appear in | ||||
|   all copies and that both that the copyright notice and this | ||||
|   permission notice and warranty disclaimer appear in supporting | ||||
|   documentation, and that the name of the author not be used in | ||||
|   advertising or publicity pertaining to distribution of the | ||||
|   software without specific, written prior permission. | ||||
|  | ||||
|   The author disclaim all warranties with regard to this | ||||
|   software, including all implied warranties of merchantability | ||||
|   and fitness.  In no event shall the author be liable for any | ||||
|   special, indirect or consequential damages or any damages | ||||
|   whatsoever resulting from loss of use, data or profits, whether | ||||
|   in an action of contract, negligence or other tortious action, | ||||
|   arising out of or in connection with the use or performance of | ||||
|   this software. | ||||
| */ | ||||
|  | ||||
| #ifndef _KEYBOARD_MOUSE_H_ | ||||
| #define _KEYBOARD_MOUSE_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <stdbool.h> | ||||
| 		#include <string.h> | ||||
|  | ||||
| 		#include "Descriptors.h" | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Board/Joystick.h> | ||||
| 		#include <LUFA/Drivers/Board/LEDs.h> | ||||
| 		#include <LUFA/Drivers/Board/Buttons.h> | ||||
| 		#include <LUFA/Drivers/USB/USB.h> | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ | ||||
| 		#define LEDMASK_USB_NOTREADY      LEDS_LED1 | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ | ||||
| 		#define LEDMASK_USB_ENUMERATING  (LEDS_LED2 | LEDS_LED3) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is ready. */ | ||||
| 		#define LEDMASK_USB_READY        (LEDS_LED2 | LEDS_LED4) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ | ||||
| 		#define LEDMASK_USB_ERROR        (LEDS_LED1 | LEDS_LED3) | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
|  | ||||
| 		void EVENT_USB_Device_Connect(void); | ||||
| 		void EVENT_USB_Device_Disconnect(void); | ||||
| 		void EVENT_USB_Device_ConfigurationChanged(void); | ||||
| 		void EVENT_USB_Device_ControlRequest(void); | ||||
| 		void EVENT_USB_Device_StartOfFrame(void); | ||||
|  | ||||
| 		bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                         uint8_t* const ReportID, | ||||
| 		                                         const uint8_t ReportType, | ||||
| 		                                         void* ReportData, | ||||
| 		                                         uint16_t* const ReportSize); | ||||
| 		void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo, | ||||
| 		                                          const uint8_t ReportID, | ||||
| 		                                          const uint8_t ReportType, | ||||
| 		                                          const void* ReportData, | ||||
| 		                                          const uint16_t ReportSize); | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user