Various LUFA library updates and tested support for Micropendous boards.
This commit is contained in:
		
							
								
								
									
										1565
									
								
								Micropendous/Firmware/MassStorageHost/Doxygen.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1565
									
								
								Micropendous/Firmware/MassStorageHost/Doxygen.conf
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -0,0 +1 @@ | ||||
| <AVRStudio><MANAGEMENT><ProjectName>MassStorageHost</ProjectName><Created>13-Jul-2010 15:05:05</Created><LastEdit>13-Jul-2010 15:05:19</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>13-Jul-2010 15:05:05</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\Host\ClassDriver\MassStorageHost\</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>MassStorageHost.c</SOURCEFILE><HEADERFILE>MassStorageHost.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>MassStorageHost.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> | ||||
							
								
								
									
										304
									
								
								Micropendous/Firmware/MassStorageHost/MassStorageHost.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										304
									
								
								Micropendous/Firmware/MassStorageHost/MassStorageHost.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,304 @@ | ||||
| /* | ||||
|              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 MassStorageHost demo. This file contains the main tasks of | ||||
|  *  the demo and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #include "MassStorageHost.h" | ||||
|  | ||||
| /** LUFA Mass Storage Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all Mass Storage Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_MS_Host_t FlashDisk_MS_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.DataINPipeNumber       = 1, | ||||
| 				.DataINPipeDoubleBank   = false, | ||||
|  | ||||
| 				.DataOUTPipeNumber      = 2, | ||||
| 				.DataOUTPipeDoubleBank  = false, | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
|  | ||||
| /** Main program entry point. This routine configures the hardware required by the application, then | ||||
|  *  enters a loop to run the application tasks in sequence. | ||||
|  */ | ||||
| int main(void) | ||||
| { | ||||
| 	SetupHardware(); | ||||
|  | ||||
| 	puts_P(PSTR(ESC_FG_CYAN "Mass Storage Host Demo running.\r\n" ESC_FG_WHITE)); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| 	sei(); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		MassStorageHost_Task(); | ||||
| 		 | ||||
| 		MS_Host_USBTask(&FlashDisk_MS_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 */ | ||||
| 	Serial_Init(9600, false); | ||||
| 	LEDs_Init(); | ||||
| 	USB_Init(); | ||||
|  | ||||
| 	/* Create a stdio stream for the serial port for stdin and stdout */ | ||||
| 	Serial_CreateStream(NULL); | ||||
| } | ||||
|  | ||||
| /** Task to manage an enumerated USB Mass Storage device once connected, to print out | ||||
|  *  data from the device. | ||||
|  */ | ||||
| void MassStorageHost_Task(void) | ||||
| { | ||||
| 	if (USB_HostState != HOST_STATE_Configured) | ||||
| 	  return; | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_BUSY); | ||||
|  | ||||
| 	puts_P(PSTR("Waiting until ready...\r\n")); | ||||
|  | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		uint8_t ErrorCode = MS_Host_TestUnitReady(&FlashDisk_MS_Interface, 0); | ||||
|  | ||||
| 		if (!(ErrorCode)) | ||||
| 		  break; | ||||
|  | ||||
| 		/* Check if an error other than a logical command error (device busy) received */ | ||||
| 		if (ErrorCode != MS_ERROR_LOGICAL_CMD_FAILED) | ||||
| 		{ | ||||
| 			puts_P(PSTR("Error waiting for device to be ready.\r\n")); | ||||
| 			LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 			USB_Host_SetDeviceConfiguration(0); | ||||
| 			return; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	puts_P(PSTR("Retrieving Capacity...\r\n")); | ||||
|  | ||||
| 	SCSI_Capacity_t DiskCapacity; | ||||
| 	if (MS_Host_ReadDeviceCapacity(&FlashDisk_MS_Interface, 0, &DiskCapacity)) | ||||
| 	{ | ||||
| 		puts_P(PSTR("Error retrieving device capacity.\r\n")); | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		USB_Host_SetDeviceConfiguration(0); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	printf_P(PSTR("%lu blocks of %lu bytes.\r\n"), DiskCapacity.Blocks, DiskCapacity.BlockSize); | ||||
|  | ||||
| 	uint8_t BlockBuffer[DiskCapacity.BlockSize]; | ||||
|  | ||||
| 	if (MS_Host_ReadDeviceBlocks(&FlashDisk_MS_Interface, 0, 0x00000000, 1, DiskCapacity.BlockSize, BlockBuffer)) | ||||
| 	{ | ||||
| 		puts_P(PSTR("Error reading device block.\r\n")); | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		USB_Host_SetDeviceConfiguration(0); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	puts_P(PSTR("\r\nContents of first block:\r\n")); | ||||
|  | ||||
| 	for (uint16_t Chunk = 0; Chunk < (DiskCapacity.BlockSize >> 4); Chunk++) | ||||
| 	{ | ||||
| 		uint8_t* ChunkPtr = &BlockBuffer[Chunk << 4]; | ||||
|  | ||||
| 		/* Print out the 16 bytes of the chunk in HEX format */ | ||||
| 		for (uint8_t ByteOffset = 0; ByteOffset < (1 << 4); ByteOffset++) | ||||
| 		{ | ||||
| 			char CurrByte = *(ChunkPtr + ByteOffset); | ||||
| 			printf_P(PSTR("%.2X "), CurrByte); | ||||
| 		} | ||||
|  | ||||
| 		printf_P(PSTR("    ")); | ||||
|  | ||||
| 		/* Print out the 16 bytes of the chunk in ASCII format */ | ||||
| 		for (uint8_t ByteOffset = 0; ByteOffset < (1 << 4); ByteOffset++) | ||||
| 		{ | ||||
| 			char CurrByte = *(ChunkPtr + ByteOffset); | ||||
| 			putchar(isprint(CurrByte) ? CurrByte : '.'); | ||||
| 		} | ||||
|  | ||||
| 		printf_P(PSTR("\r\n")); | ||||
| 	} | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_READY); | ||||
| 	USB_Host_SetDeviceConfiguration(0); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB_DeviceAttached event. This indicates that a device has been attached to the host, and | ||||
|  *  starts the library USB task to begin the enumeration and USB management process. | ||||
|  */ | ||||
| void EVENT_USB_Host_DeviceAttached(void) | ||||
| { | ||||
| 	puts_P(PSTR("Device Attached.\r\n")); | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB_DeviceUnattached event. This indicates that a device has been removed from the host, and | ||||
|  *  stops the library USB task management process. | ||||
|  */ | ||||
| void EVENT_USB_Host_DeviceUnattached(void) | ||||
| { | ||||
| 	puts_P(PSTR("\r\nDevice Unattached.\r\n")); | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB_DeviceEnumerationComplete event. This indicates that a device has been successfully | ||||
|  *  enumerated by the host and is now ready to be used by the application. | ||||
|  */ | ||||
| void EVENT_USB_Host_DeviceEnumerationComplete(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
|  | ||||
| 	uint16_t ConfigDescriptorSize; | ||||
| 	uint8_t  ConfigDescriptorData[512]; | ||||
|  | ||||
| 	if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, | ||||
| 	                                       sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) | ||||
| 	{ | ||||
| 		puts_P(PSTR("Error Retrieving Configuration Descriptor.\r\n")); | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	if (MS_Host_ConfigurePipes(&FlashDisk_MS_Interface, | ||||
| 	                           ConfigDescriptorSize, ConfigDescriptorData) != MS_ENUMERROR_NoError) | ||||
| 	{ | ||||
| 		puts_P(PSTR("Attached Device Not a Valid Mass Storage Device.\r\n")); | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) | ||||
| 	{ | ||||
| 		puts_P(PSTR("Error Setting Device Configuration.\r\n")); | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	uint8_t MaxLUNIndex; | ||||
| 	if (MS_Host_GetMaxLUN(&FlashDisk_MS_Interface, &MaxLUNIndex)) | ||||
| 	{ | ||||
| 		puts_P(PSTR("Error retrieving max LUN index.\r\n")); | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		USB_Host_SetDeviceConfiguration(0); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	printf_P(PSTR("Total LUNs: %d - Using first LUN in device.\r\n"), (MaxLUNIndex + 1)); | ||||
|  | ||||
| 	if (MS_Host_ResetMSInterface(&FlashDisk_MS_Interface)) | ||||
| 	{ | ||||
| 		puts_P(PSTR("Error resetting Mass Storage interface.\r\n")); | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		USB_Host_SetDeviceConfiguration(0); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	SCSI_Request_Sense_Response_t SenseData; | ||||
| 	if (MS_Host_RequestSense(&FlashDisk_MS_Interface, 0, &SenseData) != 0) | ||||
| 	{ | ||||
| 		puts_P(PSTR("Error retrieving device sense.\r\n")); | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		USB_Host_SetDeviceConfiguration(0); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	if (MS_Host_PreventAllowMediumRemoval(&FlashDisk_MS_Interface, 0, true)) | ||||
| 	{ | ||||
| 		puts_P(PSTR("Error setting Prevent Device Removal bit.\r\n")); | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		USB_Host_SetDeviceConfiguration(0); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	SCSI_Inquiry_Response_t InquiryData; | ||||
| 	if (MS_Host_GetInquiryData(&FlashDisk_MS_Interface, 0, &InquiryData)) | ||||
| 	{ | ||||
| 		puts_P(PSTR("Error retrieving device Inquiry data.\r\n")); | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		USB_Host_SetDeviceConfiguration(0); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	printf_P(PSTR("Vendor \"%.8s\", Product \"%.16s\"\r\n"), InquiryData.VendorID, InquiryData.ProductID); | ||||
|  | ||||
| 	puts_P(PSTR("Mass Storage Device Enumerated.\r\n")); | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_READY); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB_HostError event. This indicates that a hardware error occurred while in host mode. */ | ||||
| void EVENT_USB_Host_HostError(const uint8_t ErrorCode) | ||||
| { | ||||
| 	USB_Disable(); | ||||
|  | ||||
| 	printf_P(PSTR(ESC_FG_RED "Host Mode Error\r\n" | ||||
| 	                         " -- Error Code %d\r\n" ESC_FG_WHITE), ErrorCode); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 	for(;;); | ||||
| } | ||||
|  | ||||
| /** Event handler for the USB_DeviceEnumerationFailed event. This indicates that a problem occurred while | ||||
|  *  enumerating an attached USB device. | ||||
|  */ | ||||
| void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, | ||||
|                                             const uint8_t SubErrorCode) | ||||
| { | ||||
| 	printf_P(PSTR(ESC_FG_RED "Dev Enum Error\r\n" | ||||
| 	                         " -- Error Code %d\r\n" | ||||
| 	                         " -- Sub Error Code %d\r\n" | ||||
| 	                         " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| } | ||||
|  | ||||
							
								
								
									
										82
									
								
								Micropendous/Firmware/MassStorageHost/MassStorageHost.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										82
									
								
								Micropendous/Firmware/MassStorageHost/MassStorageHost.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,82 @@ | ||||
| /* | ||||
|              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 MassStorage.c. | ||||
|  */ | ||||
|  | ||||
| #ifndef _MASS_STORAGE_HOST_H_ | ||||
| #define _MASS_STORAGE_HOST_H_ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include <avr/io.h> | ||||
| 		#include <avr/wdt.h> | ||||
| 		#include <avr/pgmspace.h> | ||||
| 		#include <avr/power.h> | ||||
| 		#include <avr/interrupt.h> | ||||
| 		#include <ctype.h> | ||||
| 		#include <stdio.h> | ||||
|  | ||||
| 		#include <LUFA/Version.h> | ||||
| 		#include <LUFA/Drivers/Misc/TerminalCodes.h> | ||||
| 		#include <LUFA/Drivers/Peripheral/Serial.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) | ||||
|  | ||||
| 		/** LED mask for the library LED driver, to indicate that the USB interface is busy. */ | ||||
| 		#define LEDMASK_USB_BUSY          LEDS_LED2 | ||||
|  | ||||
| 	/* Function Prototypes: */ | ||||
| 		void SetupHardware(void); | ||||
| 		void MassStorageHost_Task(void); | ||||
| 		 | ||||
| 		void EVENT_USB_Host_HostError(const uint8_t ErrorCode); | ||||
| 		void EVENT_USB_Host_DeviceAttached(void); | ||||
| 		void EVENT_USB_Host_DeviceUnattached(void); | ||||
| 		void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, | ||||
| 		                                            const uint8_t SubErrorCode); | ||||
| 		void EVENT_USB_Host_DeviceEnumerationComplete(void); | ||||
|  | ||||
| #endif | ||||
|  | ||||
							
								
								
									
										68
									
								
								Micropendous/Firmware/MassStorageHost/MassStorageHost.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								Micropendous/Firmware/MassStorageHost/MassStorageHost.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,68 @@ | ||||
| /** \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 Mass Storage Host Demo | ||||
|  * | ||||
|  *  \section Sec_Compat Demo Compatibility: | ||||
|  * | ||||
|  *  The following list indicates what microcontrollers are compatible with this demo. | ||||
|  * | ||||
|  *  - Series 7 USB AVRs (AT90USBxxx7) | ||||
|  * | ||||
|  *  \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>Host</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Class:</b></td> | ||||
|  *    <td>Mass Storage Device</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>USB Subclass:</b></td> | ||||
|  *    <td>Bulk Only</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Relevant Standards:</b></td> | ||||
|  *    <td>USBIF Mass Storage Standard \n | ||||
|  *        USB Bulk-Only Transport Standard \n | ||||
|  *        SCSI Primary Commands Specification \n | ||||
|  *        SCSI Block Commands Specification</td> | ||||
|  *   </tr> | ||||
|  *   <tr> | ||||
|  *    <td><b>Usable Speeds:</b></td> | ||||
|  *    <td>Full Speed Mode</td> | ||||
|  *   </tr> | ||||
|  *  </table> | ||||
|  * | ||||
|  *  \section Sec_Description Project Description: | ||||
|  * | ||||
|  *  Mass Storage host demonstration application. This gives a simple reference | ||||
|  *  application for implementing a USB Mass Storage host, for USB storage devices | ||||
|  *  using the standard Mass Storage USB profile. | ||||
|  * | ||||
|  *  The first 512 bytes (boot sector) of an attached disk's memory will be dumped | ||||
|  *  out of the serial port in HEX and ASCII form when it is attached to the AT90USB1287 | ||||
|  *  AVR. The device will then wait for HWB to be pressed, whereupon the entire ASCII contents | ||||
|  *  of the disk will be dumped to the serial port. | ||||
|  * | ||||
|  *  \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> | ||||
|  */ | ||||
|  | ||||
							
								
								
									
										723
									
								
								Micropendous/Firmware/MassStorageHost/makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										723
									
								
								Micropendous/Firmware/MassStorageHost/makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,723 @@ | ||||
| # Hey Emacs, this is a -*- makefile -*- | ||||
| #---------------------------------------------------------------------------- | ||||
| # WinAVR Makefile Template written by Eric B. Weddington, J<>rg Wunsch, et al. | ||||
| #  >> Modified for use with the LUFA project. << | ||||
| # | ||||
| # Released to the Public Domain | ||||
| # | ||||
| # Additional material for this makefile was written by: | ||||
| # Peter Fleury | ||||
| # Tim Henigan | ||||
| # Colin O'Flynn | ||||
| # Reiner Patommel | ||||
| # Markus Pfaff | ||||
| # Sander Pool | ||||
| # Frederik Rouleau | ||||
| # Carlos Lamas | ||||
| # Dean Camera | ||||
| # Opendous Inc. | ||||
| # Denver Gingerich | ||||
| # | ||||
| #---------------------------------------------------------------------------- | ||||
| # On command line: | ||||
| # | ||||
| # make all = Make software. | ||||
| # | ||||
| # make clean = Clean out built project files. | ||||
| # | ||||
| # make coff = Convert ELF to AVR COFF. | ||||
| # | ||||
| # make extcoff = Convert ELF to AVR Extended COFF. | ||||
| # | ||||
| # make program = Download the hex file to the device, using avrdude. | ||||
| #                Please customize the avrdude settings below first! | ||||
| # | ||||
| # make dfu = Download the hex file to the device, using dfu-programmer (must | ||||
| #            have dfu-programmer installed). | ||||
| # | ||||
| # make flip = Download the hex file to the device, using Atmel FLIP (must | ||||
| #             have Atmel FLIP installed). | ||||
| # | ||||
| # make dfu-ee = Download the eeprom file to the device, using dfu-programmer | ||||
| #               (must have dfu-programmer installed). | ||||
| # | ||||
| # make flip-ee = Download the eeprom file to the device, using Atmel FLIP | ||||
| #                (must have Atmel FLIP installed). | ||||
| # | ||||
| # make doxygen = Generate DoxyGen documentation for the project (must have | ||||
| #                DoxyGen installed) | ||||
| # | ||||
| # make debug = Start either simulavr or avarice as specified for debugging, | ||||
| #              with avr-gdb or avr-insight as the front end for debugging. | ||||
| # | ||||
| # make filename.s = Just compile filename.c into the assembler code only. | ||||
| # | ||||
| # make filename.i = Create a preprocessed source file for use in submitting | ||||
| #                   bug reports to the GCC project. | ||||
| # | ||||
| # To rebuild project do "make clean" then "make all". | ||||
| #---------------------------------------------------------------------------- | ||||
|  | ||||
|  | ||||
| # MCU name | ||||
| MCU = at90usb1287 | ||||
|  | ||||
|  | ||||
| # Target architecture (see library "Board Types" documentation). | ||||
| ARCH = AVR8 | ||||
|  | ||||
|  | ||||
| # Target board (see library "Board Types" documentation, NONE for projects not requiring | ||||
| # LUFA board drivers). If USER is selected, put custom board drivers in a directory called | ||||
| # "Board" inside the application directory. | ||||
| BOARD = USBKEY | ||||
|  | ||||
|  | ||||
| # Processor frequency. | ||||
| #     This will define a symbol, F_CPU, in all source code files equal to the | ||||
| #     processor frequency in Hz. You can then use this symbol in your source code to | ||||
| #     calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||||
| #     automatically to create a 32-bit value in your source code. | ||||
| # | ||||
| #     This will be an integer division of F_USB below, as it is sourced by | ||||
| #     F_USB after it has run through any CPU prescalers. Note that this value | ||||
| #     does not *change* the processor frequency - it should merely be updated to | ||||
| #     reflect the processor speed set externally so that the code can use accurate | ||||
| #     software delays. | ||||
| F_CPU = 8000000 | ||||
|  | ||||
|  | ||||
| # Input clock frequency. | ||||
| #     This will define a symbol, F_USB, in all source code files equal to the | ||||
| #     input clock frequency (before any prescaling is performed) in Hz. This value may | ||||
| #     differ from F_CPU if prescaling is used on the latter, and is required as the | ||||
| #     raw input clock is fed directly to the PLL sections of the AVR for high speed | ||||
| #     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||||
| #     at the end, this will be done automatically to create a 32-bit value in your | ||||
| #     source code. | ||||
| # | ||||
| #     If no clock division is performed on the input clock inside the AVR (via the | ||||
| #     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||||
| F_USB = $(F_CPU) | ||||
|  | ||||
|  | ||||
| # Output format. (can be srec, ihex, binary) | ||||
| FORMAT = ihex | ||||
|  | ||||
|  | ||||
| # Target file name (without extension). | ||||
| TARGET = MassStorageHost | ||||
|  | ||||
|  | ||||
| # Object files directory | ||||
| #     To put object files in current directory, use a dot (.), do NOT make | ||||
| #     this an empty or blank macro! | ||||
| OBJDIR = . | ||||
|  | ||||
|  | ||||
| # Path to the LUFA library | ||||
| LUFA_PATH = ../../../.. | ||||
|  | ||||
|  | ||||
| # LUFA library compile-time options and predefined tokens | ||||
| LUFA_OPTS  = -D USB_HOST_ONLY | ||||
| LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" | ||||
| LUFA_OPTS += -D USB_STREAM_TIMEOUT_MS=5000 | ||||
|  | ||||
|  | ||||
| # Create the LUFA source path variables by including the LUFA root makefile | ||||
| include $(LUFA_PATH)/LUFA/makefile | ||||
|  | ||||
|  | ||||
| # List C source files here. (C dependencies are automatically generated.) | ||||
| SRC = $(TARGET).c                                                 \ | ||||
| 	  $(LUFA_SRC_USB)                                             \ | ||||
| 	  $(LUFA_SRC_USBCLASS)                                        \ | ||||
| 	  $(LUFA_SRC_SERIAL) | ||||
|  | ||||
|  | ||||
| # List C++ source files here. (C dependencies are automatically generated.) | ||||
| CPPSRC = | ||||
|  | ||||
|  | ||||
| # List Assembler source files here. | ||||
| #     Make them always end in a capital .S.  Files ending in a lowercase .s | ||||
| #     will not be considered source files but generated files (assembler | ||||
| #     output from the compiler), and will be deleted upon "make clean"! | ||||
| #     Even though the DOS/Win* filesystem matches both .s and .S the same, | ||||
| #     it will preserve the spelling of the filenames, and gcc itself does | ||||
| #     care about how the name is spelled on its command-line. | ||||
| ASRC = | ||||
|  | ||||
|  | ||||
| # Optimization level, can be [0, 1, 2, 3, s]. | ||||
| #     0 = turn off optimization. s = optimize for size. | ||||
| #     (Note: 3 is not always the best optimization level. See avr-libc FAQ.) | ||||
| OPT = s | ||||
|  | ||||
|  | ||||
| # Debugging format. | ||||
| #     Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. | ||||
| #     AVR Studio 4.10 requires dwarf-2. | ||||
| #     AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. | ||||
| DEBUG = dwarf-2 | ||||
|  | ||||
|  | ||||
| # List any extra directories to look for include files here. | ||||
| #     Each directory must be seperated by a space. | ||||
| #     Use forward slashes for directory separators. | ||||
| #     For a directory that has spaces, enclose it in quotes. | ||||
| EXTRAINCDIRS = $(LUFA_PATH)/ | ||||
|  | ||||
|  | ||||
| # Compiler flag to set the C Standard level. | ||||
| #     c89   = "ANSI" C | ||||
| #     gnu89 = c89 plus GCC extensions | ||||
| #     c99   = ISO C99 standard (not yet fully implemented) | ||||
| #     gnu99 = c99 plus GCC extensions | ||||
| CSTANDARD = -std=c99 | ||||
|  | ||||
|  | ||||
| # Place -D or -U options here for C sources | ||||
| CDEFS  = -DF_CPU=$(F_CPU)UL | ||||
| CDEFS += -DF_USB=$(F_USB)UL | ||||
| CDEFS += -DBOARD=BOARD_$(BOARD) -DARCH=ARCH_$(ARCH) | ||||
| CDEFS += $(LUFA_OPTS) | ||||
|  | ||||
|  | ||||
| # Place -D or -U options here for ASM sources | ||||
| ADEFS  = -DF_CPU=$(F_CPU) | ||||
| ADEFS += -DF_USB=$(F_USB)UL | ||||
| ADEFS += -DBOARD=BOARD_$(BOARD) | ||||
| ADEFS += $(LUFA_OPTS) | ||||
|  | ||||
| # Place -D or -U options here for C++ sources | ||||
| CPPDEFS  = -DF_CPU=$(F_CPU)UL | ||||
| CPPDEFS += -DF_USB=$(F_USB)UL | ||||
| CPPDEFS += -DBOARD=BOARD_$(BOARD) | ||||
| CPPDEFS += $(LUFA_OPTS) | ||||
| #CPPDEFS += -D__STDC_LIMIT_MACROS | ||||
| #CPPDEFS += -D__STDC_CONSTANT_MACROS | ||||
|  | ||||
|  | ||||
|  | ||||
| #---------------- Compiler Options C ---------------- | ||||
| #  -g*:          generate debugging information | ||||
| #  -O*:          optimization level | ||||
| #  -f...:        tuning, see GCC manual and avr-libc documentation | ||||
| #  -Wall...:     warning level | ||||
| #  -Wa,...:      tell GCC to pass this to the assembler. | ||||
| #    -adhlns...: create assembler listing | ||||
| CFLAGS = -g$(DEBUG) | ||||
| CFLAGS += $(CDEFS) | ||||
| CFLAGS += -O$(OPT) | ||||
| CFLAGS += -funsigned-char | ||||
| CFLAGS += -funsigned-bitfields | ||||
| CFLAGS += -ffunction-sections | ||||
| CFLAGS += -fno-inline-small-functions | ||||
| CFLAGS += -fpack-struct | ||||
| CFLAGS += -fshort-enums | ||||
| CFLAGS += -fno-strict-aliasing | ||||
| CFLAGS += -Wall | ||||
| CFLAGS += -Wstrict-prototypes | ||||
| #CFLAGS += -mshort-calls | ||||
| #CFLAGS += -fno-unit-at-a-time | ||||
| #CFLAGS += -Wundef | ||||
| #CFLAGS += -Wunreachable-code | ||||
| #CFLAGS += -Wsign-compare | ||||
| CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) | ||||
| CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) | ||||
| CFLAGS += $(CSTANDARD) | ||||
|  | ||||
|  | ||||
| #---------------- Compiler Options C++ ---------------- | ||||
| #  -g*:          generate debugging information | ||||
| #  -O*:          optimization level | ||||
| #  -f...:        tuning, see GCC manual and avr-libc documentation | ||||
| #  -Wall...:     warning level | ||||
| #  -Wa,...:      tell GCC to pass this to the assembler. | ||||
| #    -adhlns...: create assembler listing | ||||
| CPPFLAGS = -g$(DEBUG) | ||||
| CPPFLAGS += $(CPPDEFS) | ||||
| CPPFLAGS += -O$(OPT) | ||||
| CPPFLAGS += -funsigned-char | ||||
| CPPFLAGS += -funsigned-bitfields | ||||
| CPPFLAGS += -fpack-struct | ||||
| CPPFLAGS += -fshort-enums | ||||
| CPPFLAGS += -fno-exceptions | ||||
| CPPFLAGS += -Wall | ||||
| CPPFLAGS += -Wundef | ||||
| #CPPFLAGS += -mshort-calls | ||||
| #CPPFLAGS += -fno-unit-at-a-time | ||||
| #CPPFLAGS += -Wstrict-prototypes | ||||
| #CPPFLAGS += -Wunreachable-code | ||||
| #CPPFLAGS += -Wsign-compare | ||||
| CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) | ||||
| CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) | ||||
| #CPPFLAGS += $(CSTANDARD) | ||||
|  | ||||
|  | ||||
| #---------------- Assembler Options ---------------- | ||||
| #  -Wa,...:   tell GCC to pass this to the assembler. | ||||
| #  -adhlns:   create listing | ||||
| #  -gstabs:   have the assembler create line number information; note that | ||||
| #             for use in COFF files, additional information about filenames | ||||
| #             and function names needs to be present in the assembler source | ||||
| #             files -- see avr-libc docs [FIXME: not yet described there] | ||||
| #  -listing-cont-lines: Sets the maximum number of continuation lines of hex | ||||
| #       dump that will be displayed for a given single line of source input. | ||||
| ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 | ||||
|  | ||||
|  | ||||
| #---------------- Library Options ---------------- | ||||
| # Minimalistic printf version | ||||
| PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min | ||||
|  | ||||
| # Floating point printf version (requires MATH_LIB = -lm below) | ||||
| PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt | ||||
|  | ||||
| # If this is left blank, then it will use the Standard printf version. | ||||
| PRINTF_LIB = | ||||
| #PRINTF_LIB = $(PRINTF_LIB_MIN) | ||||
| #PRINTF_LIB = $(PRINTF_LIB_FLOAT) | ||||
|  | ||||
|  | ||||
| # Minimalistic scanf version | ||||
| SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min | ||||
|  | ||||
| # Floating point + %[ scanf version (requires MATH_LIB = -lm below) | ||||
| SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt | ||||
|  | ||||
| # If this is left blank, then it will use the Standard scanf version. | ||||
| SCANF_LIB = | ||||
| #SCANF_LIB = $(SCANF_LIB_MIN) | ||||
| #SCANF_LIB = $(SCANF_LIB_FLOAT) | ||||
|  | ||||
|  | ||||
| MATH_LIB = -lm | ||||
|  | ||||
|  | ||||
| # List any extra directories to look for libraries here. | ||||
| #     Each directory must be seperated by a space. | ||||
| #     Use forward slashes for directory separators. | ||||
| #     For a directory that has spaces, enclose it in quotes. | ||||
| EXTRALIBDIRS = | ||||
|  | ||||
|  | ||||
|  | ||||
| #---------------- External Memory Options ---------------- | ||||
|  | ||||
| # 64 KB of external RAM, starting after internal RAM (ATmega128!), | ||||
| # used for variables (.data/.bss) and heap (malloc()). | ||||
| #EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff | ||||
|  | ||||
| # 64 KB of external RAM, starting after internal RAM (ATmega128!), | ||||
| # only used for heap (malloc()). | ||||
| #EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff | ||||
|  | ||||
| EXTMEMOPTS = | ||||
|  | ||||
|  | ||||
|  | ||||
| #---------------- Linker Options ---------------- | ||||
| #  -Wl,...:     tell GCC to pass this to linker. | ||||
| #    -Map:      create map file | ||||
| #    --cref:    add cross reference to  map file | ||||
| LDFLAGS  = -Wl,-Map=$(TARGET).map,--cref | ||||
| LDFLAGS += -Wl,--relax | ||||
| LDFLAGS += -Wl,--gc-sections | ||||
| LDFLAGS += $(EXTMEMOPTS) | ||||
| LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) | ||||
| LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) | ||||
| #LDFLAGS += -T linker_script.x | ||||
|  | ||||
|  | ||||
|  | ||||
| #---------------- Programming Options (avrdude) ---------------- | ||||
|  | ||||
| # Programming hardware | ||||
| # Type: avrdude -c ? | ||||
| # to get a full listing. | ||||
| # | ||||
| AVRDUDE_PROGRAMMER = jtagmkII | ||||
|  | ||||
| # com1 = serial port. Use lpt1 to connect to parallel port. | ||||
| AVRDUDE_PORT = usb | ||||
|  | ||||
| AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex | ||||
| #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep | ||||
|  | ||||
|  | ||||
| # Uncomment the following if you want avrdude's erase cycle counter. | ||||
| # Note that this counter needs to be initialized first using -Yn, | ||||
| # see avrdude manual. | ||||
| #AVRDUDE_ERASE_COUNTER = -y | ||||
|  | ||||
| # Uncomment the following if you do /not/ wish a verification to be | ||||
| # performed after programming the device. | ||||
| #AVRDUDE_NO_VERIFY = -V | ||||
|  | ||||
| # Increase verbosity level.  Please use this when submitting bug | ||||
| # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> | ||||
| # to submit bug reports. | ||||
| #AVRDUDE_VERBOSE = -v -v | ||||
|  | ||||
| AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) | ||||
| AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) | ||||
| AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) | ||||
| AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) | ||||
|  | ||||
|  | ||||
|  | ||||
| #---------------- Debugging Options ---------------- | ||||
|  | ||||
| # For simulavr only - target MCU frequency. | ||||
| DEBUG_MFREQ = $(F_CPU) | ||||
|  | ||||
| # Set the DEBUG_UI to either gdb or insight. | ||||
| # DEBUG_UI = gdb | ||||
| DEBUG_UI = insight | ||||
|  | ||||
| # Set the debugging back-end to either avarice, simulavr. | ||||
| DEBUG_BACKEND = avarice | ||||
| #DEBUG_BACKEND = simulavr | ||||
|  | ||||
| # GDB Init Filename. | ||||
| GDBINIT_FILE = __avr_gdbinit | ||||
|  | ||||
| # When using avarice settings for the JTAG | ||||
| JTAG_DEV = /dev/com1 | ||||
|  | ||||
| # Debugging port used to communicate between GDB / avarice / simulavr. | ||||
| DEBUG_PORT = 4242 | ||||
|  | ||||
| # Debugging host used to communicate between GDB / avarice / simulavr, normally | ||||
| #     just set to localhost unless doing some sort of crazy debugging when | ||||
| #     avarice is running on a different computer. | ||||
| DEBUG_HOST = localhost | ||||
|  | ||||
|  | ||||
|  | ||||
| #============================================================================ | ||||
|  | ||||
|  | ||||
| # Define programs and commands. | ||||
| SHELL = sh | ||||
| CC = avr-gcc | ||||
| OBJCOPY = avr-objcopy | ||||
| OBJDUMP = avr-objdump | ||||
| SIZE = avr-size | ||||
| AR = avr-ar rcs | ||||
| NM = avr-nm | ||||
| AVRDUDE = avrdude | ||||
| REMOVE = rm -f | ||||
| REMOVEDIR = rm -rf | ||||
| COPY = cp | ||||
| WINSHELL = cmd | ||||
|  | ||||
|  | ||||
| # Define Messages | ||||
| # English | ||||
| MSG_ERRORS_NONE = Errors: none | ||||
| MSG_BEGIN = -------- begin -------- | ||||
| MSG_END = --------  end  -------- | ||||
| MSG_SIZE_BEFORE = Size before: | ||||
| MSG_SIZE_AFTER = Size after: | ||||
| MSG_COFF = Converting to AVR COFF: | ||||
| MSG_EXTENDED_COFF = Converting to AVR Extended COFF: | ||||
| MSG_FLASH = Creating load file for Flash: | ||||
| MSG_EEPROM = Creating load file for EEPROM: | ||||
| MSG_EXTENDED_LISTING = Creating Extended Listing: | ||||
| MSG_SYMBOL_TABLE = Creating Symbol Table: | ||||
| MSG_LINKING = Linking: | ||||
| MSG_COMPILING = Compiling C: | ||||
| MSG_COMPILING_CPP = Compiling C++: | ||||
| MSG_ASSEMBLING = Assembling: | ||||
| MSG_CLEANING = Cleaning project: | ||||
| MSG_CREATING_LIBRARY = Creating library: | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| # Define all object files. | ||||
| OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) | ||||
|  | ||||
| # Define all listing files. | ||||
| LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) | ||||
|  | ||||
|  | ||||
| # Compiler flags to generate dependency files. | ||||
| GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d | ||||
|  | ||||
|  | ||||
| # Combine all necessary flags and optional flags. | ||||
| # Add target processor to flags. | ||||
| ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) | ||||
| ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) | ||||
| ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| # Default target. | ||||
| all: begin gccversion sizebefore build sizeafter end | ||||
|  | ||||
| # Change the build target to build a HEX file or a library. | ||||
| build: elf hex eep lss sym | ||||
| #build: lib | ||||
|  | ||||
|  | ||||
| elf: $(TARGET).elf | ||||
| hex: $(TARGET).hex | ||||
| eep: $(TARGET).eep | ||||
| lss: $(TARGET).lss | ||||
| sym: $(TARGET).sym | ||||
| LIBNAME=lib$(TARGET).a | ||||
| lib: $(LIBNAME) | ||||
|  | ||||
|  | ||||
|  | ||||
| # Eye candy. | ||||
| # AVR Studio 3.x does not check make's exit code but relies on | ||||
| # the following magic strings to be generated by the compile job. | ||||
| begin: | ||||
| 	@echo | ||||
| 	@echo $(MSG_BEGIN) | ||||
|  | ||||
| end: | ||||
| 	@echo $(MSG_END) | ||||
| 	@echo | ||||
|  | ||||
|  | ||||
| # Display size of file. | ||||
| HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex | ||||
| ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf | ||||
| MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) | ||||
| FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) | ||||
|  | ||||
|  | ||||
| sizebefore: | ||||
| 	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ | ||||
| 	2>/dev/null; echo; fi | ||||
|  | ||||
| sizeafter: | ||||
| 	@if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ | ||||
| 	2>/dev/null; echo; fi | ||||
|  | ||||
|  | ||||
|  | ||||
| # Display compiler version information. | ||||
| gccversion : | ||||
| 	@$(CC) --version | ||||
|  | ||||
|  | ||||
| # Program the device. | ||||
| program: $(TARGET).hex $(TARGET).eep | ||||
| 	$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) | ||||
|  | ||||
| flip: $(TARGET).hex | ||||
| 	batchisp -hardware usb -device $(MCU) -operation erase f | ||||
| 	batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program | ||||
| 	batchisp -hardware usb -device $(MCU) -operation start reset 0 | ||||
|  | ||||
| dfu: $(TARGET).hex | ||||
| 	dfu-programmer $(MCU) erase | ||||
| 	dfu-programmer $(MCU) flash $(TARGET).hex | ||||
| 	dfu-programmer $(MCU) reset | ||||
|  | ||||
| flip-ee: $(TARGET).hex $(TARGET).eep | ||||
| 	$(COPY) $(TARGET).eep $(TARGET)eep.hex | ||||
| 	batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase | ||||
| 	batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program | ||||
| 	batchisp -hardware usb -device $(MCU) -operation start reset 0 | ||||
| 	$(REMOVE) $(TARGET)eep.hex | ||||
|  | ||||
| dfu-ee: $(TARGET).hex $(TARGET).eep | ||||
| 	dfu-programmer $(MCU) eeprom-flash $(TARGET).eep | ||||
| 	dfu-programmer $(MCU) reset | ||||
|  | ||||
|  | ||||
| # Generate avr-gdb config/init file which does the following: | ||||
| #     define the reset signal, load the target file, connect to target, and set | ||||
| #     a breakpoint at main(). | ||||
| gdb-config: | ||||
| 	@$(REMOVE) $(GDBINIT_FILE) | ||||
| 	@echo define reset >> $(GDBINIT_FILE) | ||||
| 	@echo SIGNAL SIGHUP >> $(GDBINIT_FILE) | ||||
| 	@echo end >> $(GDBINIT_FILE) | ||||
| 	@echo file $(TARGET).elf >> $(GDBINIT_FILE) | ||||
| 	@echo target remote $(DEBUG_HOST):$(DEBUG_PORT)  >> $(GDBINIT_FILE) | ||||
| ifeq ($(DEBUG_BACKEND),simulavr) | ||||
| 	@echo load  >> $(GDBINIT_FILE) | ||||
| endif | ||||
| 	@echo break main >> $(GDBINIT_FILE) | ||||
|  | ||||
| debug: gdb-config $(TARGET).elf | ||||
| ifeq ($(DEBUG_BACKEND), avarice) | ||||
| 	@echo Starting AVaRICE - Press enter when "waiting to connect" message displays. | ||||
| 	@$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ | ||||
| 	$(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) | ||||
| 	@$(WINSHELL) /c pause | ||||
|  | ||||
| else | ||||
| 	@$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ | ||||
| 	$(DEBUG_MFREQ) --port $(DEBUG_PORT) | ||||
| endif | ||||
| 	@$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. | ||||
| COFFCONVERT = $(OBJCOPY) --debugging | ||||
| COFFCONVERT += --change-section-address .data-0x800000 | ||||
| COFFCONVERT += --change-section-address .bss-0x800000 | ||||
| COFFCONVERT += --change-section-address .noinit-0x800000 | ||||
| COFFCONVERT += --change-section-address .eeprom-0x810000 | ||||
|  | ||||
|  | ||||
|  | ||||
| coff: $(TARGET).elf | ||||
| 	@echo | ||||
| 	@echo $(MSG_COFF) $(TARGET).cof | ||||
| 	$(COFFCONVERT) -O coff-avr $< $(TARGET).cof | ||||
|  | ||||
|  | ||||
| extcoff: $(TARGET).elf | ||||
| 	@echo | ||||
| 	@echo $(MSG_EXTENDED_COFF) $(TARGET).cof | ||||
| 	$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof | ||||
|  | ||||
|  | ||||
|  | ||||
| # Create final output files (.hex, .eep) from ELF output file. | ||||
| %.hex: %.elf | ||||
| 	@echo | ||||
| 	@echo $(MSG_FLASH) $@ | ||||
| 	$(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@ | ||||
|  | ||||
| %.eep: %.elf | ||||
| 	@echo | ||||
| 	@echo $(MSG_EEPROM) $@ | ||||
| 	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ | ||||
| 	--change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 | ||||
|  | ||||
| # Create extended listing file from ELF output file. | ||||
| %.lss: %.elf | ||||
| 	@echo | ||||
| 	@echo $(MSG_EXTENDED_LISTING) $@ | ||||
| 	$(OBJDUMP) -h -S -z $< > $@ | ||||
|  | ||||
| # Create a symbol table from ELF output file. | ||||
| %.sym: %.elf | ||||
| 	@echo | ||||
| 	@echo $(MSG_SYMBOL_TABLE) $@ | ||||
| 	$(NM) -n $< > $@ | ||||
|  | ||||
|  | ||||
|  | ||||
| # Create library from object files. | ||||
| .SECONDARY : $(TARGET).a | ||||
| .PRECIOUS : $(OBJ) | ||||
| %.a: $(OBJ) | ||||
| 	@echo | ||||
| 	@echo $(MSG_CREATING_LIBRARY) $@ | ||||
| 	$(AR) $@ $(OBJ) | ||||
|  | ||||
|  | ||||
| # Link: create ELF output file from object files. | ||||
| .SECONDARY : $(TARGET).elf | ||||
| .PRECIOUS : $(OBJ) | ||||
| %.elf: $(OBJ) | ||||
| 	@echo | ||||
| 	@echo $(MSG_LINKING) $@ | ||||
| 	$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) | ||||
|  | ||||
|  | ||||
| # Compile: create object files from C source files. | ||||
| $(OBJDIR)/%.o : %.c | ||||
| 	@echo | ||||
| 	@echo $(MSG_COMPILING) $< | ||||
| 	$(CC) -c $(ALL_CFLAGS) $< -o $@ | ||||
|  | ||||
|  | ||||
| # Compile: create object files from C++ source files. | ||||
| $(OBJDIR)/%.o : %.cpp | ||||
| 	@echo | ||||
| 	@echo $(MSG_COMPILING_CPP) $< | ||||
| 	$(CC) -c $(ALL_CPPFLAGS) $< -o $@ | ||||
|  | ||||
|  | ||||
| # Compile: create assembler files from C source files. | ||||
| %.s : %.c | ||||
| 	$(CC) -S $(ALL_CFLAGS) $< -o $@ | ||||
|  | ||||
|  | ||||
| # Compile: create assembler files from C++ source files. | ||||
| %.s : %.cpp | ||||
| 	$(CC) -S $(ALL_CPPFLAGS) $< -o $@ | ||||
|  | ||||
|  | ||||
| # Assemble: create object files from assembler source files. | ||||
| $(OBJDIR)/%.o : %.S | ||||
| 	@echo | ||||
| 	@echo $(MSG_ASSEMBLING) $< | ||||
| 	$(CC) -c $(ALL_ASFLAGS) $< -o $@ | ||||
|  | ||||
|  | ||||
| # Create preprocessed source for use in sending a bug report. | ||||
| %.i : %.c | ||||
| 	$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ | ||||
|  | ||||
|  | ||||
| # Target: clean project. | ||||
| clean: begin clean_list end | ||||
|  | ||||
| clean_list : | ||||
| 	@echo | ||||
| 	@echo $(MSG_CLEANING) | ||||
| 	$(REMOVE) $(TARGET).hex | ||||
| 	$(REMOVE) $(TARGET).eep | ||||
| 	$(REMOVE) $(TARGET).cof | ||||
| 	$(REMOVE) $(TARGET).elf | ||||
| 	$(REMOVE) $(TARGET).map | ||||
| 	$(REMOVE) $(TARGET).sym | ||||
| 	$(REMOVE) $(TARGET).lss | ||||
| 	$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) | ||||
| 	$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) | ||||
| 	$(REMOVE) $(SRC:.c=.s) | ||||
| 	$(REMOVE) $(SRC:.c=.d) | ||||
| 	$(REMOVE) $(SRC:.c=.i) | ||||
| 	$(REMOVEDIR) .dep | ||||
|  | ||||
| doxygen: | ||||
| 	@echo Generating Project Documentation \($(TARGET)\)... | ||||
| 	@doxygen Doxygen.conf | ||||
| 	@echo Documentation Generation Complete. | ||||
|  | ||||
| clean_doxygen: | ||||
| 	rm -rf Documentation | ||||
|  | ||||
| checksource: | ||||
| 	@for f in $(SRC) $(CPPSRC) $(ASRC); do \ | ||||
| 		if [ -f $$f ]; then \ | ||||
| 			echo "Found Source File: $$f" ; \ | ||||
| 		else \ | ||||
| 			echo "Source File Not Found: $$f" ; \ | ||||
| 		fi; done  | ||||
|  | ||||
|  | ||||
| # Create object files directory | ||||
| $(shell mkdir $(OBJDIR) 2>/dev/null) | ||||
|  | ||||
|  | ||||
| # Include the dependency files. | ||||
| -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) | ||||
|  | ||||
|  | ||||
| # Listing of phony targets. | ||||
| .PHONY : all begin finish end sizebefore sizeafter gccversion \ | ||||
| build elf hex eep lss sym coff extcoff doxygen clean          \ | ||||
| clean_list clean_doxygen program dfu flip flip-ee dfu-ee      \ | ||||
| debug gdb-config checksource | ||||
| @@ -191,9 +191,9 @@ const USB_Descriptor_String_t LanguageString = | ||||
|  */ | ||||
| const USB_Descriptor_String_t ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String}, | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(22), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"AVR CDC Bootloader" | ||||
| 	.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" | ||||
|   | ||||
| @@ -132,9 +132,9 @@ const USB_Descriptor_String_t LanguageString = | ||||
|  */ | ||||
| const USB_Descriptor_String_t ProductString = | ||||
| { | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String}, | ||||
| 	.Header                 = {.Size = USB_STRING_LEN(22), .Type = DTYPE_String}, | ||||
|  | ||||
| 	.UnicodeString          = L"AVR DFU Bootloader" | ||||
| 	.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" | ||||
|   | ||||
| @@ -107,6 +107,8 @@ void SetupHardware(void) | ||||
| 	USB_Init(); | ||||
| } | ||||
|  | ||||
| #define BUTTONS_BUTTON1      (1 << 2) | ||||
|  | ||||
| /** Checks for changes in the position of the board joystick, sending strings to the host upon each change. */ | ||||
| void CheckJoystickMovement(void) | ||||
| { | ||||
| @@ -127,10 +129,13 @@ void CheckJoystickMovement(void) | ||||
| 	else | ||||
| 	  ActionSent = false; | ||||
|  | ||||
| 	if ((ReportString != NULL) && (ActionSent == false)) | ||||
| 	if (((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1)) | ||||
| 	{ | ||||
| 		DDRE  &= ~BUTTONS_BUTTON1; | ||||
| 		PORTE |=  BUTTONS_BUTTON1; | ||||
| 		 | ||||
| 		ActionSent = true; | ||||
|  | ||||
| 		ReportString = "Joystick Pressed\r\n"; | ||||
| 		/* Write the string to the virtual COM port via the created character stream */ | ||||
| 		fputs(ReportString, &USBSerialStream); | ||||
|  | ||||
|   | ||||
| @@ -60,7 +60,7 @@ | ||||
|  | ||||
|  | ||||
| # MCU name | ||||
| MCU = at90usb1287 | ||||
| MCU = atmega32u4 | ||||
|  | ||||
|  | ||||
| # Target architecture (see library "Board Types" documentation). | ||||
|   | ||||
| @@ -2,14 +2,15 @@ This directory contains the 2011-10-09 LUFA distribution | ||||
| with the following modifications: | ||||
|  | ||||
|  | ||||
|  | ||||
| Files Added: | ||||
|  | ||||
| * Defines missing from certain versions of avr-gcc | ||||
|   ./LUFA/MissingDefines.h | ||||
|   ./MissingDefines.h | ||||
|  | ||||
| * Defines related to various Micropendous boards | ||||
|   ./LUFA/Drivers/Board/AVR8/MICROPENDOUS_A/... | ||||
|   ./LUFA/Drivers/Board/AVR8/MICROPENDOUS_OLD/... | ||||
|   ./LUFA/Drivers/Board/AVR8/MICROPENDOUS_32U2/... | ||||
|   ./LUFA/Drivers/Board/AVR8/MICROPENDOUS_REV1/... | ||||
|   ./LUFA/Drivers/Board/AVR8/MICROPENDOUS_REV2/... | ||||
|  | ||||
| @@ -18,17 +19,30 @@ Files Added: | ||||
| Files Changed: | ||||
|  | ||||
| * Include MissingDefines.h with all source | ||||
|   ./LUFA/Version.h | ||||
|   ./Version.h | ||||
|  | ||||
| * Allow Micropendous-related board defines to be included: | ||||
|   ./LUFA/Drivers/Board/Buttons.h | ||||
|   ./LUFA/Drivers/Board/LEDs.h | ||||
|   ./LUFA/Common/BoardTypes.h | ||||
|  | ||||
| * Included NO_AUTO_VBUS_MANAGEMENT option code from Dean Camera | ||||
|   ./LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c | ||||
|   ./LUFA/Drivers/USB/Core/AVR8/Host_AVR8.h | ||||
|  | ||||
|  | ||||
|  | ||||
| LUFA SVN Updates Included Following LUFA-111009 Release: | ||||
|  | ||||
| * r1974 Update incomplete StandaloneProgrammer project to latest LUFA | ||||
|     ./Projects/Incomplete/StandaloneProgrammer/DiskHost.c | ||||
|     ./Projects/Incomplete/StandaloneProgrammer/StandaloneProgrammer.c | ||||
|  | ||||
| * r1971 Fixed race condition in class drivers | ||||
|     ./LUFA/Drivers/USB/Class/Device/CDC.c | ||||
|     ./LUFA/Drivers/USB/Class/Device/HID.c | ||||
|     ./LUFA/Drivers/USB/Class/Device/MassStorage.c | ||||
|  | ||||
| * r1963 Added INVERTED_ISP_MISO compile time option to AVRISP-MKII | ||||
|     ./Projects/AVRISP-MKII/AVRISP-MKII.txt | ||||
|     ./Projects/AVRISP-MKII/Lib/ISP/ISPTarget.h | ||||
| @@ -53,18 +67,17 @@ LUFA SVN Updates Included Following LUFA-111009 Release: | ||||
|     ./LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c | ||||
|  | ||||
| * r1943 Added User Application APIs to the CDC and DFU class bootloaders | ||||
|     ./LUFA/Bootloaders/CDC/BootloaderAPI.c | ||||
|     ./LUFA/Bootloaders/CDC/BootloaderAPI.h | ||||
|     ./LUFA/Bootloaders/CDC/BootloaderAPITable.S | ||||
|     ./LUFA/Bootloaders/CDC/BootloaderCDC.c | ||||
|     ./LUFA/Bootloaders/CDC/BootloaderCDC.h | ||||
|     ./LUFA/Bootloaders/CDC/BootloaderCDC.txt | ||||
|     ./LUFA/Bootloaders/CDC/makefile | ||||
|     ./LUFA/Bootloaders/DFU/BootloaderAPI.c | ||||
|     ./LUFA/Bootloaders/DFU/BootloaderAPI.h | ||||
|     ./LUFA/Bootloaders/DFU/BootloaderAPITable.S | ||||
|     ./LUFA/Bootloaders/DFU/BootloaderDFU.c | ||||
|     ./LUFA/Bootloaders/DFU/BootloaderDFU.h | ||||
|     ./LUFA/Bootloaders/DFU/BootloaderDFU.txt | ||||
|     ./LUFA/Bootloaders/DFU/makefile | ||||
|  | ||||
|     ./Bootloaders/CDC/BootloaderAPI.c | ||||
|     ./Bootloaders/CDC/BootloaderAPI.h | ||||
|     ./Bootloaders/CDC/BootloaderAPITable.S | ||||
|     ./Bootloaders/CDC/BootloaderCDC.c | ||||
|     ./Bootloaders/CDC/BootloaderCDC.h | ||||
|     ./Bootloaders/CDC/BootloaderCDC.txt | ||||
|     ./Bootloaders/CDC/makefile | ||||
|     ./Bootloaders/DFU/BootloaderAPI.c | ||||
|     ./Bootloaders/DFU/BootloaderAPI.h | ||||
|     ./Bootloaders/DFU/BootloaderAPITable.S | ||||
|     ./Bootloaders/DFU/BootloaderDFU.c | ||||
|     ./Bootloaders/DFU/BootloaderDFU.h | ||||
|     ./Bootloaders/DFU/BootloaderDFU.txt | ||||
|     ./Bootloaders/DFU/makefile | ||||
|   | ||||
| @@ -156,20 +156,19 @@ | ||||
| 			/** Selects the Atmel EVK1104 specific board drivers, including the Button and LED drivers. */ | ||||
| 			#define BOARD_EVK1104		30 | ||||
|  | ||||
| 			/** Selects the initial revision Micropendous3 or Micropendous4 specific board drivers for the HWB Button and external SRAM. */ | ||||
| 			#define BOARD_MICROPENDOUS_OLD	31 | ||||
| 			/** Selects the Opendous Micropendous-32U2 specific board drivers for the HWB Button and LED. */ | ||||
| 			#define BOARD_MICROPENDOUS_32U2	31 | ||||
|  | ||||
| 			/** Selects the Opendous Micropendous-A specific board drivers for the HWB Button and external SRAM. */ | ||||
| 			/** Selects the Opendous Micropendous-A/3/4 specific board drivers for the HWB Button and external SRAM. */ | ||||
| 			#define BOARD_MICROPENDOUS_A	32 | ||||
|  | ||||
| 			/** Selects the Opendous Micropendous Rev1 Arduino-like specific board drivers for the HWB Button, USB Connector Switch, external SRAM, and LED. */ | ||||
| 			#define BOARD_MICROPENDOUS_REV1	33 | ||||
|  | ||||
| 			/** Selects the Opendous Micropendous Rev1 Arduino-like specific board drivers for the HWB Button, USB Connector Switch, external SRAM, and LED. */ | ||||
| 			/** Selects the Opendous Micropendous Rev2 Arduino-like specific board drivers for the HWB Button, USB Connector Switch, external SRAM, and LED. */ | ||||
| 			#define BOARD_MICROPENDOUS_REV2	34 | ||||
|  | ||||
| 			/** Selects the Opendous Micropendous Rev1 Arduino-like specific board drivers for the HWB Button, USB Connector Switch, external SRAM, and LED. */ | ||||
| 			#define BOARD_MICROPENDOUS_32U2	35 | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -70,6 +70,7 @@ | ||||
| 		#include "Architectures.h" | ||||
| 		#include "Attributes.h" | ||||
| 		#include "BoardTypes.h" | ||||
| 		#include "MissingDefines.h" | ||||
| 		 | ||||
| 	/* Enable C linkage for C++ Compilers: */ | ||||
| 		#if defined(__cplusplus) | ||||
|   | ||||
							
								
								
									
										182
									
								
								Micropendous/libs/LUFA/LUFA/Common/MissingDefines.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										182
									
								
								Micropendous/libs/LUFA/LUFA/Common/MissingDefines.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,182 @@ | ||||
| /* Copyright (c) 2009  By Eric B. Weddington | ||||
|    All rights reserved. | ||||
|  | ||||
|    Defines missing from currently used versions of avr-libc. | ||||
|  | ||||
|    Redistribution and use in source and binary forms, with or without | ||||
|    modification, are permitted provided that the following conditions are met: | ||||
|  | ||||
|    * Redistributions of source code must retain the above copyright | ||||
|      notice, this list of conditions and the following disclaimer. | ||||
|    * Redistributions in binary form must reproduce the above copyright | ||||
|      notice, this list of conditions and the following disclaimer in | ||||
|      the documentation and/or other materials provided with the | ||||
|      distribution. | ||||
|    * Neither the name of the copyright holders nor the names of | ||||
|      contributors may be used to endorse or promote products derived | ||||
|      from this software without specific prior written permission. | ||||
|  | ||||
|   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||||
|   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||||
|   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||||
|   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||||
|   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||||
|   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||||
|   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||||
|   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||||
|   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||||
|   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||||
|   POSSIBILITY OF SUCH DAMAGE. | ||||
| */ | ||||
|  | ||||
| #ifndef __MISSING_DEFINES__ | ||||
| #define __MISSING_DEFINES__ | ||||
|  | ||||
| #include <avr/version.h> | ||||
|  | ||||
|  | ||||
| #ifndef PINHIGH | ||||
| 	#define PINHIGH(PORT, PIN)		PORT |= (1 << PIN); | ||||
| #endif | ||||
|  | ||||
| #ifndef PINLOW | ||||
| 	#define PINLOW(PORT, PIN)		PORT &= ~(1 << PIN); | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Missing WinAVR include defines */ | ||||
| /* WinAVR does not define these for the ATmega??u4*/ | ||||
| #if (defined(__AVR_ATmega16U4__)  || defined(__AVR_ATmega32U4__)) | ||||
| 	#ifndef PB7 | ||||
| 		#define PB7		7 | ||||
| 	#endif | ||||
| 	#ifndef PB6 | ||||
| 		#define PB6		6 | ||||
| 	#endif | ||||
| 	#ifndef PB5 | ||||
| 		#define PB5		5 | ||||
| 	#endif | ||||
| 	#ifndef PB4 | ||||
| 		#define PB4		4 | ||||
| 	#endif | ||||
| 	#ifndef PB3 | ||||
| 		#define PB3		3 | ||||
| 	#endif | ||||
| 	#ifndef PB2 | ||||
| 		#define PB2		2 | ||||
| 	#endif | ||||
| 	#ifndef PB1 | ||||
| 		#define PB1		1 | ||||
| 	#endif | ||||
| 	#ifndef PB0 | ||||
| 		#define PB0		0 | ||||
| 	#endif | ||||
| 	#ifndef PC7 | ||||
| 		#define PC7		7 | ||||
| 	#endif | ||||
| 	#ifndef PC6 | ||||
| 		#define PC6		6 | ||||
| 	#endif | ||||
| 	#ifndef PD7 | ||||
| 		#define PD7		7 | ||||
| 	#endif | ||||
| 	#ifndef PD6 | ||||
| 		#define PD6		6 | ||||
| 	#endif | ||||
| 	#ifndef PD5 | ||||
| 		#define PD5		5 | ||||
| 	#endif | ||||
| 	#ifndef PD4 | ||||
| 		#define PD4		4 | ||||
| 	#endif | ||||
| 	#ifndef PD3 | ||||
| 		#define PD3		3 | ||||
| 	#endif | ||||
| 	#ifndef PD2 | ||||
| 		#define PD2		2 | ||||
| 	#endif | ||||
| 	#ifndef PD1 | ||||
| 		#define PD1		1 | ||||
| 	#endif | ||||
| 	#ifndef PD0 | ||||
| 		#define PD0		0 | ||||
| 	#endif | ||||
| 	#ifndef PE2 | ||||
| 		#define PE2		2 | ||||
| 	#endif | ||||
| 	#ifndef PE6 | ||||
| 		#define PE6		6 | ||||
| 	#endif | ||||
| 	#ifndef PF7 | ||||
| 		#define PF7		7 | ||||
| 	#endif | ||||
| 	#ifndef PF6 | ||||
| 		#define PF6		6 | ||||
| 	#endif | ||||
| 	#ifndef PF5 | ||||
| 		#define PF5		5 | ||||
| 	#endif | ||||
| 	#ifndef PF4 | ||||
| 		#define PF4		4 | ||||
| 	#endif | ||||
| 	#ifndef PF1 | ||||
| 		#define PF1		1 | ||||
| 	#endif | ||||
| 	#ifndef PF0 | ||||
| 		#define PF0		0 | ||||
| 	#endif | ||||
| #endif | ||||
|  | ||||
| // missing avr-libc Linux defines | ||||
| //#ifndef clock_prescale_set | ||||
| //#if (__AVR_LIBC_VERSION__ < 10606UL) | ||||
|  | ||||
| 	#ifndef clock_div_1 | ||||
| 		#define clock_div_1		0 | ||||
| 	#endif | ||||
| 	#ifndef clock_div_2 | ||||
| 		#define clock_div_2		1 | ||||
| 	#endif | ||||
| 	#ifndef clock_div_4 | ||||
| 		#define clock_div_4		2 | ||||
| 	#endif | ||||
| 	#ifndef clock_div_8 | ||||
| 		#define clock_div_8		3 | ||||
| 	#endif | ||||
| 	#ifndef clock_div_16 | ||||
| 		#define clock_div_16		4 | ||||
| 	#endif | ||||
| 	#ifndef clock_div_32 | ||||
| 		#define clock_div_32		5 | ||||
| 	#endif | ||||
| 	#ifndef clock_div_64 | ||||
| 		#define clock_div_64		6 | ||||
| 	#endif | ||||
| 	#ifndef clock_div_128 | ||||
| 		#define clock_div_128	7 | ||||
| 	#endif | ||||
| 	#ifndef clock_div_256 | ||||
| 		#define clock_div_256	8 | ||||
| 	#endif | ||||
|  | ||||
| 	#ifndef clock_prescale_set | ||||
| 		#define clock_prescale_set(x) \ | ||||
| 		{ \ | ||||
| 		uint8_t tmp = _BV(CLKPCE); \ | ||||
| 		__asm__ __volatile__ ( \ | ||||
| 		        "in __tmp_reg__,__SREG__" "\n\t" \ | ||||
| 		        "cli" "\n\t" \ | ||||
| 		        "sts %1, %0" "\n\t" \ | ||||
| 		        "sts %1, %2" "\n\t" \ | ||||
| 		        "out __SREG__, __tmp_reg__" \ | ||||
| 		        : /* no outputs */ \ | ||||
| 		        : "d" (tmp), \ | ||||
| 		          "M" (_SFR_MEM_ADDR(CLKPR)), \ | ||||
| 		          "d" (x) \ | ||||
| 		        : "r0"); \ | ||||
| 		} | ||||
| 	#endif | ||||
|  | ||||
| //#endif // (__AVR_LIBC_VERSION__ < 10606UL) | ||||
|  | ||||
| #endif // MissingDefines.h | ||||
| @@ -9,6 +9,15 @@ | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   For use with Micropendous-A, Micropendous3, or Micropendous4 boards where | ||||
|   PE6 is the external SRAM Chip Enable Pin and PE7 is Address Bit 17/Bank Selector Pin | ||||
|  | ||||
|   www.Micropendous.org/Micropendous-A | ||||
|   www.Micropendous.org/Micropendous3 | ||||
|   www.Micropendous.org/Micropendous4 | ||||
|  | ||||
|   Note there is only 1 user button on these boards: PE2 - HWB | ||||
|  | ||||
|   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 | ||||
| @@ -29,24 +38,24 @@ | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  *  \brief Board specific Buttons driver header for the Atmel USBKEY. | ||||
|  *  \copydetails Group_Buttons_USBKEY | ||||
|  *  \brief Board specific Buttons driver header for the Micropendous Rev2 board (www.Micropendous.org/Micropendous). | ||||
|  *  \copydetails Group_Buttons_MICROPENDOUS_REV2 | ||||
|  * | ||||
|  *  \note This file should not be included directly. It is automatically included as needed by the Buttons driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/Buttons.h. | ||||
|  */ | ||||
|  | ||||
| /** \ingroup Group_Buttons | ||||
|  *  \defgroup Group_Buttons_USBKEY USBKEY | ||||
|  *  \brief Board specific Buttons driver header for the Atmel USBKEY. | ||||
|  *  \defgroup Group_Buttons_MICROPENDOUS_REV2 MICROPENDOUS_REV2 | ||||
|  *  \brief Board specific Buttons driver header for the Micropendous Rev2. | ||||
|  * | ||||
|  *  Board specific Buttons driver header for the Atmel USBKEY. | ||||
|  *  Board specific Buttons driver header for the Micropendous Rev2 (www.Micropendous.org/Micropendous). | ||||
|  * | ||||
|  *  @{ | ||||
|  */ | ||||
|  | ||||
| #ifndef __BUTTONS_USBKEY_H__ | ||||
| #define __BUTTONS_USBKEY_H__ | ||||
| #ifndef __BUTTONS_MICROPENDOUS_H__ | ||||
| #define __BUTTONS_MICROPENDOUS_H__ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include "../../../../Common/Common.h" | ||||
| @@ -86,7 +95,6 @@ | ||||
| 			} | ||||
| 		#endif | ||||
|  | ||||
| #endif | ||||
| #endif // __BUTTONS_MICROPENDOUS_H__ | ||||
|  | ||||
| /** @} */ | ||||
|  | ||||
|   | ||||
| @@ -1,13 +1,11 @@ | ||||
| /* | ||||
|              LUFA Library | ||||
|      Copyright (C) Dean Camera, 2011. | ||||
|   Copyright 2011-11-11 By Opendous Inc. | ||||
|   For use with Micropendous-A, Micropendous3, or Micropendous4 boards where | ||||
|   PE6 is the external SRAM Chip Enable Pin and PE7 is Address Bit 17/Bank Selector Pin | ||||
|  | ||||
|   dean [at] fourwalledcubicle [dot] com | ||||
|            www.lufa-lib.org | ||||
| */ | ||||
|  | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|   www.Micropendous.org/Micropendous-A | ||||
|   www.Micropendous.org/Micropendous3 | ||||
|   www.Micropendous.org/Micropendous4 | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
| @@ -29,162 +27,53 @@ | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  *  \brief Board specific Dataflash driver header for the Atmel USBKEY. | ||||
|  *  \copydetails Group_Dataflash_USBKEY | ||||
|  *  \brief Board specific external SRAM driver header for the older style Micropendous-A/3/4 boards (www.Micropendous.org/Micropendous-A). | ||||
|  *        where PE6 is the external SRAM Chip Enable Pin and PE7 is Address Bit 17/Bank Selector Pin | ||||
|  *  \copydetails Group_Buttons_MICROPENDOUS_A | ||||
|  * | ||||
|  *  \note This file should not be included directly. It is automatically included as needed by the dataflash driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/Dataflash.h. | ||||
|  *  \note This file should not be included directly. It is automatically included by the buttons driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/Buttons.h. | ||||
|  */ | ||||
|  | ||||
| /** \ingroup Group_Dataflash | ||||
|  *  \defgroup Group_Dataflash_USBKEY USBKEY | ||||
|  *  \brief Board specific Dataflash driver header for the Atmel USBKEY. | ||||
| /** \ingroup Group_Buttons | ||||
|  *  \defgroup Group_Buttons_MICROPENDOUS_A MICROPENDOUS_A | ||||
|  *  \brief Board specific external SRAM driver header for the older style Micropendous-A/3/4 board | ||||
|  *        where PE6 is the external SRAM Chip Enable Pin and PE7 is Address Bit 17/Bank Selector Pin | ||||
|  * | ||||
|  *  Board specific Dataflash driver header for the Atmel USBKEY board. | ||||
|  *  Board specific external SRAM driver header for the Micropendous board (www.Micropendous.org/Micropendous-A). | ||||
|  * | ||||
|  *  @{ | ||||
|  */ | ||||
|  | ||||
| #ifndef __DATAFLASH_USBKEY_H__ | ||||
| #define __DATAFLASH_USBKEY_H__ | ||||
| #ifndef __EXTERNAL_SRAM_MICROPENDOUS_A_H__ | ||||
| #define __EXTERNAL_SRAM_MICROPENDOUS_A_H__ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include "../../../../Common/Common.h" | ||||
| 		#include "../../../Misc/AT45DB642D.h" | ||||
| 	#include "../../../../Common/Common.h" | ||||
|  | ||||
| 	/* Preprocessor Checks: */ | ||||
| 		#if !defined(__INCLUDE_FROM_DATAFLASH_H) | ||||
| 			#error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead. | ||||
| 		#endif | ||||
|  | ||||
| 	/* Private Interface - For use in library only: */ | ||||
| 	#if !defined(__DOXYGEN__) | ||||
| 		/* Macros: */ | ||||
| 			#define DATAFLASH_CHIPCS_MASK                ((1 << 1) | (1 << 0)) | ||||
| 			#define DATAFLASH_CHIPCS_DDR                 DDRE | ||||
| 			#define DATAFLASH_CHIPCS_PORT                PORTE | ||||
| 	/* Enable C linkage for C++ Compilers: */ | ||||
| 	#if defined(__cplusplus) | ||||
| 		extern "C" { | ||||
| 	#endif | ||||
|  | ||||
| 	/* Public Interface - May be used in end-application: */ | ||||
| 		/* Macros: */ | ||||
| 			/** Constant indicating the total number of dataflash ICs mounted on the selected board. */ | ||||
| 			#define DATAFLASH_TOTALCHIPS                 2 | ||||
| 	// On older Micropendous3/4 boards, nCE is PE6 and Address Bit 17 is PE7.  PE0,1,2 are also control signals. | ||||
| 	#define PORTE_EXT_SRAM_SETUP	DDRE = ((1 << PE0) | (1 << PE1) | (1 << PE2) | (1 << PE6) | (1 << PE7)); PORTE = ((1 << PE0) | (1 << PE1) | (1 << PE6) | (1 << PE7)); | ||||
| 	#define ENABLE_EXT_SRAM		DDRE |= (1 << PE6); PORTE &= ~(1 << PE6); | ||||
| 	#define DISABLE_EXT_SRAM	DDRE |= (1 << PE6); PORTE |= (1 << PE6); | ||||
| 	#define SELECT_EXT_SRAM_BANK0	DDRE |= (1 << PE7); PORTE &= ~(1 << PE7); | ||||
| 	#define SELECT_EXT_SRAM_BANK1	DDRE |= (1 << PE7); PORTE |= (1 << PE7); | ||||
| 	#define CURRENT_SRAM_BANK	((PINE >> 7) & (0x01)) | ||||
|  | ||||
| 			/** Mask for no dataflash chip selected. */ | ||||
| 			#define DATAFLASH_NO_CHIP                    DATAFLASH_CHIPCS_MASK | ||||
| 	#if (!defined(NO_AUTO_VBUS_MANAGEMENT)) | ||||
| 		#error Micropendous-A boards require the NO_AUTO_VBUS_MANAGEMENT compile-time LUFA option. | ||||
| 	#endif | ||||
|  | ||||
| 			/** Mask for the first dataflash chip selected. */ | ||||
| 			#define DATAFLASH_CHIP1                      (1 << 1) | ||||
| 	/* Disable C linkage for C++ Compilers: */ | ||||
| 	#if defined(__cplusplus) | ||||
| 		} | ||||
| 	#endif | ||||
|  | ||||
| 			/** Mask for the second dataflash chip selected. */ | ||||
| 			#define DATAFLASH_CHIP2                      (1 << 0) | ||||
|  | ||||
| 			/** Internal main memory page size for the board's dataflash ICs. */ | ||||
| 			#define DATAFLASH_PAGE_SIZE                  1024 | ||||
|  | ||||
| 			/** Total number of pages inside each of the board's dataflash ICs. */ | ||||
| 			#define DATAFLASH_PAGES                      8192 | ||||
|  | ||||
| 		/* Inline Functions: */ | ||||
| 			/** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. | ||||
| 			 *  The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used. | ||||
| 			 */ | ||||
| 			static inline void Dataflash_Init(void) | ||||
| 			{ | ||||
| 				DATAFLASH_CHIPCS_DDR  |= DATAFLASH_CHIPCS_MASK; | ||||
| 				DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK; | ||||
| 			} | ||||
|  | ||||
| 			/** Determines the currently selected dataflash chip. | ||||
| 			 * | ||||
| 			 *  \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected | ||||
| 			 *  or a DATAFLASH_CHIPn mask (where n is the chip number). | ||||
| 			 */ | ||||
| 			static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; | ||||
| 			static inline uint8_t Dataflash_GetSelectedChip(void) | ||||
| 			{ | ||||
| 				return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK); | ||||
| 			} | ||||
|  | ||||
| 			/** Selects the given dataflash chip. | ||||
| 			 * | ||||
| 			 *  \param[in]  ChipMask  Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is | ||||
| 			 *              the chip number). | ||||
| 			 */ | ||||
| 			static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE; | ||||
| 			static inline void Dataflash_SelectChip(const uint8_t ChipMask) | ||||
| 			{ | ||||
| 				DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask); | ||||
| 			} | ||||
|  | ||||
| 			/** Deselects the current dataflash chip, so that no dataflash is selected. */ | ||||
| 			static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; | ||||
| 			static inline void Dataflash_DeselectChip(void) | ||||
| 			{ | ||||
| 				Dataflash_SelectChip(DATAFLASH_NO_CHIP); | ||||
| 			} | ||||
|  | ||||
| 			/** Selects a dataflash IC from the given page number, which should range from 0 to | ||||
| 			 *  ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one | ||||
| 			 *  dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside | ||||
| 			 *  the total number of pages contained in the boards dataflash ICs, all dataflash ICs | ||||
| 			 *  are deselected. | ||||
| 			 * | ||||
| 			 *  \param[in] PageAddress  Address of the page to manipulate, ranging from | ||||
| 			 *                          0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). | ||||
| 			 */ | ||||
| 			static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) | ||||
| 			{ | ||||
| 				Dataflash_DeselectChip(); | ||||
|  | ||||
| 				if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS)) | ||||
| 				  return; | ||||
|  | ||||
| 				if (PageAddress & 0x01) | ||||
| 				  Dataflash_SelectChip(DATAFLASH_CHIP2); | ||||
| 				else | ||||
| 				  Dataflash_SelectChip(DATAFLASH_CHIP1); | ||||
| 			} | ||||
|  | ||||
| 			/** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive | ||||
| 			 *  a new command. | ||||
| 			 */ | ||||
| 			static inline void Dataflash_ToggleSelectedChipCS(void) | ||||
| 			{ | ||||
| 				uint8_t SelectedChipMask = Dataflash_GetSelectedChip(); | ||||
|  | ||||
| 				Dataflash_DeselectChip(); | ||||
| 				Dataflash_SelectChip(SelectedChipMask); | ||||
| 			} | ||||
|  | ||||
| 			/** Spin-loops while the currently selected dataflash is busy executing a command, such as a main | ||||
| 			 *  memory page program or main memory to buffer transfer. | ||||
| 			 */ | ||||
| 			static inline void Dataflash_WaitWhileBusy(void) | ||||
| 			{ | ||||
| 				Dataflash_ToggleSelectedChipCS(); | ||||
| 				Dataflash_SendByte(DF_CMD_GETSTATUS); | ||||
| 				while (!(Dataflash_ReceiveByte() & DF_STATUS_READY)); | ||||
| 				Dataflash_ToggleSelectedChipCS(); | ||||
| 			} | ||||
|  | ||||
| 			/** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with | ||||
| 			 *  dataflash commands which require a complete 24-bit address. | ||||
| 			 * | ||||
| 			 *  \param[in] PageAddress  Page address within the selected dataflash IC | ||||
| 			 *  \param[in] BufferByte   Address within the dataflash's buffer | ||||
| 			 */ | ||||
| 			static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, | ||||
| 			                                              const uint16_t BufferByte) | ||||
| 			{ | ||||
| 				PageAddress >>= 1; | ||||
|  | ||||
| 				Dataflash_SendByte(PageAddress >> 5); | ||||
| 				Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); | ||||
| 				Dataflash_SendByte(BufferByte); | ||||
| 			} | ||||
|  | ||||
| #endif | ||||
| #endif // __EXTERNAL_SRAM_MICROPENDOUS_A_H__ | ||||
|  | ||||
| /** @} */ | ||||
|  | ||||
|   | ||||
| @@ -9,6 +9,12 @@ | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Modified for the Micropendous Rev1 boards by Opendous Inc. 2011-11-11 | ||||
|   www.Micropendous.org/Micropendous-REV1 | ||||
|   www.Micropendous.org/Micropendous-DIP | ||||
|  | ||||
|   Note there is only 1 user button on the Micropendous boards: PE2 - HWB | ||||
|  | ||||
|   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 | ||||
| @@ -29,24 +35,24 @@ | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  *  \brief Board specific Buttons driver header for the Atmel USBKEY. | ||||
|  *  \copydetails Group_Buttons_USBKEY | ||||
|  *  \brief Board specific Buttons driver header for the Micropendous Rev2 board (www.Micropendous.org/Micropendous). | ||||
|  *  \copydetails Group_Buttons_MICROPENDOUS_REV2 | ||||
|  * | ||||
|  *  \note This file should not be included directly. It is automatically included as needed by the Buttons driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/Buttons.h. | ||||
|  */ | ||||
|  | ||||
| /** \ingroup Group_Buttons | ||||
|  *  \defgroup Group_Buttons_USBKEY USBKEY | ||||
|  *  \brief Board specific Buttons driver header for the Atmel USBKEY. | ||||
|  *  \defgroup Group_Buttons_MICROPENDOUS_REV2 MICROPENDOUS_REV2 | ||||
|  *  \brief Board specific Buttons driver header for the Micropendous Rev2. | ||||
|  * | ||||
|  *  Board specific Buttons driver header for the Atmel USBKEY. | ||||
|  *  Board specific Buttons driver header for the Micropendous Rev2 (www.Micropendous.org/Micropendous). | ||||
|  * | ||||
|  *  @{ | ||||
|  */ | ||||
|  | ||||
| #ifndef __BUTTONS_USBKEY_H__ | ||||
| #define __BUTTONS_USBKEY_H__ | ||||
| #ifndef __BUTTONS_MICROPENDOUS_H__ | ||||
| #define __BUTTONS_MICROPENDOUS_H__ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include "../../../../Common/Common.h" | ||||
| @@ -86,7 +92,6 @@ | ||||
| 			} | ||||
| 		#endif | ||||
|  | ||||
| #endif | ||||
| #endif // __BUTTONS_MICROPENDOUS_H__ | ||||
|  | ||||
| /** @} */ | ||||
|  | ||||
|   | ||||
| @@ -1,13 +1,8 @@ | ||||
| /* | ||||
|              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) | ||||
|   Copyright 2011-11-11 By Opendous Inc. | ||||
|   For use with the Micropendous Rev1 boards | ||||
|   www.Micropendous.org/Micropendous-REV1 | ||||
|   www.Micropendous.org/Micropendous-DIP | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
| @@ -29,162 +24,47 @@ | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  *  \brief Board specific Dataflash driver header for the Atmel USBKEY. | ||||
|  *  \copydetails Group_Dataflash_USBKEY | ||||
|  *  \brief Board specific external SRAM driver header for the Micropendous Rev1 board (www.Micropendous.org/Micropendous-REV1). | ||||
|  *  \copydetails Group_Buttons_MICROPENDOUS_REV1 | ||||
|  * | ||||
|  *  \note This file should not be included directly. It is automatically included as needed by the dataflash driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/Dataflash.h. | ||||
|  *  \note This file should not be included directly. It is automatically included by the buttons driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/Buttons.h. | ||||
|  */ | ||||
|  | ||||
| /** \ingroup Group_Dataflash | ||||
|  *  \defgroup Group_Dataflash_USBKEY USBKEY | ||||
|  *  \brief Board specific Dataflash driver header for the Atmel USBKEY. | ||||
| /** \ingroup Group_Buttons | ||||
|  *  \defgroup Group_Buttons_MICROPENDOUS_REV1 MICROPENDOUS_REV1 | ||||
|  *  \brief Board specific external SRAM driver header for the Micropendous Rev1 board. | ||||
|  * | ||||
|  *  Board specific Dataflash driver header for the Atmel USBKEY board. | ||||
|  *  Board specific external SRAM driver header for the Micropendous Rev1 board (www.Micropendous.org/Micropendous-REV1). | ||||
|  * | ||||
|  *  @{ | ||||
|  */ | ||||
|  | ||||
| #ifndef __DATAFLASH_USBKEY_H__ | ||||
| #define __DATAFLASH_USBKEY_H__ | ||||
| #ifndef __EXTERNAL_SRAM_MICROPENDOUS_REV2_H__ | ||||
| #define __EXTERNAL_SRAM_MICROPENDOUS_REV2_H__ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include "../../../../Common/Common.h" | ||||
| 		#include "../../../Misc/AT45DB642D.h" | ||||
| 	#include "../../../../Common/Common.h" | ||||
|  | ||||
| 	/* Preprocessor Checks: */ | ||||
| 		#if !defined(__INCLUDE_FROM_DATAFLASH_H) | ||||
| 			#error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead. | ||||
| 		#endif | ||||
|  | ||||
| 	/* Private Interface - For use in library only: */ | ||||
| 	#if !defined(__DOXYGEN__) | ||||
| 		/* Macros: */ | ||||
| 			#define DATAFLASH_CHIPCS_MASK                ((1 << 1) | (1 << 0)) | ||||
| 			#define DATAFLASH_CHIPCS_DDR                 DDRE | ||||
| 			#define DATAFLASH_CHIPCS_PORT                PORTE | ||||
| 	/* Enable C linkage for C++ Compilers: */ | ||||
| 	#if defined(__cplusplus) | ||||
| 		extern "C" { | ||||
| 	#endif | ||||
|  | ||||
| 	/* Public Interface - May be used in end-application: */ | ||||
| 		/* Macros: */ | ||||
| 			/** Constant indicating the total number of dataflash ICs mounted on the selected board. */ | ||||
| 			#define DATAFLASH_TOTALCHIPS                 2 | ||||
| 	// On Micropendous Rev2 boards nCE is PE4 and Address Bit 17 is PE5.  PE0,1,2 are also control signals. | ||||
| 	#define PORTE_EXT_SRAM_SETUP	DDRE = ((1 << PE0) | (1 << PE1) | (1 << PE2) | (1 << PE4) | (1 << PE5)); PORTE = ((1 << PE0) | (1 << PE1) | (1 << PE2) | (1 << PE4)); | ||||
| 	#define ENABLE_EXT_SRAM		DDRE |= (1 << PE4); PORTE &= ~(1 << PE4); | ||||
| 	#define DISABLE_EXT_SRAM	DDRE |= (1 << PE4); PORTE |= (1 << PE4); | ||||
| 	#define SELECT_EXT_SRAM_BANK0	DDRE |= (1 << PE5); PORTE &= ~(1 << PE5); | ||||
| 	#define SELECT_EXT_SRAM_BANK1	DDRE |= (1 << PE5); PORTE |= (1 << PE5); | ||||
| 	#define CURRENT_SRAM_BANK	((PINE >> 5) & (0x01)) | ||||
|  | ||||
| 			/** Mask for no dataflash chip selected. */ | ||||
| 			#define DATAFLASH_NO_CHIP                    DATAFLASH_CHIPCS_MASK | ||||
| 	/* Disable C linkage for C++ Compilers: */ | ||||
| 	#if defined(__cplusplus) | ||||
| 		} | ||||
| 	#endif | ||||
|  | ||||
| 			/** Mask for the first dataflash chip selected. */ | ||||
| 			#define DATAFLASH_CHIP1                      (1 << 1) | ||||
|  | ||||
| 			/** Mask for the second dataflash chip selected. */ | ||||
| 			#define DATAFLASH_CHIP2                      (1 << 0) | ||||
|  | ||||
| 			/** Internal main memory page size for the board's dataflash ICs. */ | ||||
| 			#define DATAFLASH_PAGE_SIZE                  1024 | ||||
|  | ||||
| 			/** Total number of pages inside each of the board's dataflash ICs. */ | ||||
| 			#define DATAFLASH_PAGES                      8192 | ||||
|  | ||||
| 		/* Inline Functions: */ | ||||
| 			/** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. | ||||
| 			 *  The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used. | ||||
| 			 */ | ||||
| 			static inline void Dataflash_Init(void) | ||||
| 			{ | ||||
| 				DATAFLASH_CHIPCS_DDR  |= DATAFLASH_CHIPCS_MASK; | ||||
| 				DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK; | ||||
| 			} | ||||
|  | ||||
| 			/** Determines the currently selected dataflash chip. | ||||
| 			 * | ||||
| 			 *  \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected | ||||
| 			 *  or a DATAFLASH_CHIPn mask (where n is the chip number). | ||||
| 			 */ | ||||
| 			static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; | ||||
| 			static inline uint8_t Dataflash_GetSelectedChip(void) | ||||
| 			{ | ||||
| 				return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK); | ||||
| 			} | ||||
|  | ||||
| 			/** Selects the given dataflash chip. | ||||
| 			 * | ||||
| 			 *  \param[in]  ChipMask  Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is | ||||
| 			 *              the chip number). | ||||
| 			 */ | ||||
| 			static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE; | ||||
| 			static inline void Dataflash_SelectChip(const uint8_t ChipMask) | ||||
| 			{ | ||||
| 				DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask); | ||||
| 			} | ||||
|  | ||||
| 			/** Deselects the current dataflash chip, so that no dataflash is selected. */ | ||||
| 			static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; | ||||
| 			static inline void Dataflash_DeselectChip(void) | ||||
| 			{ | ||||
| 				Dataflash_SelectChip(DATAFLASH_NO_CHIP); | ||||
| 			} | ||||
|  | ||||
| 			/** Selects a dataflash IC from the given page number, which should range from 0 to | ||||
| 			 *  ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one | ||||
| 			 *  dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside | ||||
| 			 *  the total number of pages contained in the boards dataflash ICs, all dataflash ICs | ||||
| 			 *  are deselected. | ||||
| 			 * | ||||
| 			 *  \param[in] PageAddress  Address of the page to manipulate, ranging from | ||||
| 			 *                          0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). | ||||
| 			 */ | ||||
| 			static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) | ||||
| 			{ | ||||
| 				Dataflash_DeselectChip(); | ||||
|  | ||||
| 				if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS)) | ||||
| 				  return; | ||||
|  | ||||
| 				if (PageAddress & 0x01) | ||||
| 				  Dataflash_SelectChip(DATAFLASH_CHIP2); | ||||
| 				else | ||||
| 				  Dataflash_SelectChip(DATAFLASH_CHIP1); | ||||
| 			} | ||||
|  | ||||
| 			/** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive | ||||
| 			 *  a new command. | ||||
| 			 */ | ||||
| 			static inline void Dataflash_ToggleSelectedChipCS(void) | ||||
| 			{ | ||||
| 				uint8_t SelectedChipMask = Dataflash_GetSelectedChip(); | ||||
|  | ||||
| 				Dataflash_DeselectChip(); | ||||
| 				Dataflash_SelectChip(SelectedChipMask); | ||||
| 			} | ||||
|  | ||||
| 			/** Spin-loops while the currently selected dataflash is busy executing a command, such as a main | ||||
| 			 *  memory page program or main memory to buffer transfer. | ||||
| 			 */ | ||||
| 			static inline void Dataflash_WaitWhileBusy(void) | ||||
| 			{ | ||||
| 				Dataflash_ToggleSelectedChipCS(); | ||||
| 				Dataflash_SendByte(DF_CMD_GETSTATUS); | ||||
| 				while (!(Dataflash_ReceiveByte() & DF_STATUS_READY)); | ||||
| 				Dataflash_ToggleSelectedChipCS(); | ||||
| 			} | ||||
|  | ||||
| 			/** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with | ||||
| 			 *  dataflash commands which require a complete 24-bit address. | ||||
| 			 * | ||||
| 			 *  \param[in] PageAddress  Page address within the selected dataflash IC | ||||
| 			 *  \param[in] BufferByte   Address within the dataflash's buffer | ||||
| 			 */ | ||||
| 			static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, | ||||
| 			                                              const uint16_t BufferByte) | ||||
| 			{ | ||||
| 				PageAddress >>= 1; | ||||
|  | ||||
| 				Dataflash_SendByte(PageAddress >> 5); | ||||
| 				Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); | ||||
| 				Dataflash_SendByte(BufferByte); | ||||
| 			} | ||||
|  | ||||
| #endif | ||||
| #endif // __EXTERNAL_SRAM_MICROPENDOUS_REV2_H__ | ||||
|  | ||||
| /** @} */ | ||||
|  | ||||
|   | ||||
| @@ -9,6 +9,12 @@ | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Modified for the Micropendous Rev1 boards by Opendous Inc. 2011-11-11 | ||||
|   www.Micropendous.org/Micropendous-REV1 | ||||
|   www.Micropendous.org/Micropendous-DIP | ||||
|  | ||||
|   Note there is only 1 LED on the Micropendous boards: PB1 - SCK | ||||
|  | ||||
|   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 | ||||
| @@ -29,24 +35,24 @@ | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  *  \brief Board specific LED driver header for the Atmel USBKEY. | ||||
|  *  \copydetails Group_LEDs_USBKEY | ||||
|  *  \brief Board specific LED driver header for the Micropendous Rev1 board (www.Micropendous.org/Micropendous-REV1). | ||||
|  *  \copydetails Group_MICROPENDOUS_REV1 | ||||
|  * | ||||
|  *  \note This file should not be included directly. It is automatically included as needed by the LEDs driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/LEDs.h. | ||||
|  */ | ||||
|  | ||||
| /** \ingroup Group_LEDs | ||||
|  *  \defgroup Group_LEDs_USBKEY USBKEY | ||||
|  *  \brief Board specific LED driver header for the Atmel USBKEY. | ||||
|  *  \defgroup Group_LEDs_MICROPENDOUS_REV1 MICROPENDOUS_REV1 | ||||
|  *  \brief Board specific LED driver header for the Micropendous Rev1 board. | ||||
|  * | ||||
|  *  Board specific LED driver header for the Atmel USBKEY. | ||||
|  *  Board specific LED driver header for the Micropendous Rev1 board (www.Micropendous.org/Micropendous-REV1). | ||||
|  * | ||||
|  *  @{ | ||||
|  */ | ||||
|  | ||||
| #ifndef __LEDS_USBKEY_H__ | ||||
| #define __LEDS_USBKEY_H__ | ||||
| #ifndef __LEDS_MICROPENDOUS_REV1_H__ | ||||
| #define __LEDS_MICROPENDOUS_REV1_H__ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include "../../../../Common/Common.h" | ||||
| @@ -64,16 +70,16 @@ | ||||
| 	/* Public Interface - May be used in end-application: */ | ||||
| 		/* Macros: */ | ||||
| 			/** LED mask for the first LED on the board. */ | ||||
| 			#define LEDS_LED1        (1 << 4) | ||||
| 			#define LEDS_LED1        (1 << 1) | ||||
|  | ||||
| 			/** LED mask for the second LED on the board. */ | ||||
| 			#define LEDS_LED2        (1 << 5) | ||||
| 			#define LEDS_LED2        (0 << 0) | ||||
|  | ||||
| 			/** LED mask for the third LED on the board. */ | ||||
| 			#define LEDS_LED3        (1 << 7) | ||||
| 			#define LEDS_LED3        (0 << 0) | ||||
|  | ||||
| 			/** LED mask for the fourth LED on the board. */ | ||||
| 			#define LEDS_LED4        (1 << 6) | ||||
| 			#define LEDS_LED4        (0 << 0) | ||||
|  | ||||
| 			/** LED mask for all the LEDs on the board. */ | ||||
| 			#define LEDS_ALL_LEDS    (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4) | ||||
| @@ -85,40 +91,40 @@ | ||||
| 		#if !defined(__DOXYGEN__) | ||||
| 			static inline void LEDs_Init(void) | ||||
| 			{ | ||||
| 				DDRD  |=  LEDS_ALL_LEDS; | ||||
| 				PORTD &= ~LEDS_ALL_LEDS; | ||||
| 				DDRB  |=  LEDS_ALL_LEDS; | ||||
| 				PORTB &= ~LEDS_ALL_LEDS; | ||||
| 			} | ||||
|  | ||||
| 			static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) | ||||
| 			{ | ||||
| 				PORTD |= LEDMask; | ||||
| 				PORTB |= LEDMask; | ||||
| 			} | ||||
|  | ||||
| 			static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) | ||||
| 			{ | ||||
| 				PORTD &= ~LEDMask; | ||||
| 				PORTB &= ~LEDMask; | ||||
| 			} | ||||
|  | ||||
| 			static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) | ||||
| 			{ | ||||
| 				PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask); | ||||
| 				PORTB = ((PORTB & ~LEDS_ALL_LEDS) | LEDMask); | ||||
| 			} | ||||
|  | ||||
| 			static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, | ||||
| 			                                   const uint8_t ActiveMask) | ||||
| 			{ | ||||
| 				PORTD = ((PORTD & ~LEDMask) | ActiveMask); | ||||
| 				PORTB = ((PORTB & ~LEDMask) | ActiveMask); | ||||
| 			} | ||||
|  | ||||
| 			static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) | ||||
| 			{ | ||||
| 				PORTD ^= LEDMask; | ||||
| 				PORTB ^= LEDMask; | ||||
| 			} | ||||
|  | ||||
| 			static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; | ||||
| 			static inline uint8_t LEDs_GetLEDs(void) | ||||
| 			{ | ||||
| 				return (PORTD & LEDS_ALL_LEDS); | ||||
| 				return (PORTB & LEDS_ALL_LEDS); | ||||
| 			} | ||||
| 		#endif | ||||
|  | ||||
| @@ -127,6 +133,6 @@ | ||||
| 			} | ||||
| 		#endif | ||||
|  | ||||
| #endif | ||||
| #endif // __LEDS_MICROPENDOUS_REV1_H__ | ||||
|  | ||||
| /** @} */ | ||||
|   | ||||
| @@ -1,13 +1,8 @@ | ||||
| /* | ||||
|              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) | ||||
|   Copyright 2011-11-11 By Opendous Inc. | ||||
|   For use with the Micropendous Rev1 boards | ||||
|   www.Micropendous.org/Micropendous-REV1 | ||||
|   www.Micropendous.org/Micropendous-DIP | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
| @@ -29,88 +24,53 @@ | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  *  \brief Board specific joystick driver header for the Atmel USBKEY. | ||||
|  *  \copydetails Group_Joystick_USBKEY | ||||
|  *  \brief Board specific USB Power+Signal switch driver header for the | ||||
|  *        Micropendous Rev1 board (www.Micropendous.org/Micropendous). | ||||
|  *  \copydetails Group_Buttons_MICROPENDOUS_REV1 | ||||
|  * | ||||
|  *  \note This file should not be included directly. It is automatically included as needed by the joystick driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/Joystick.h. | ||||
|  *  \note This file should not be included directly. It is automatically included by the buttons driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/Buttons.h. | ||||
|  */ | ||||
|  | ||||
| /** \ingroup Group_Joystick | ||||
|  *  \defgroup Group_Joystick_USBKEY USBKEY | ||||
|  *  \brief Board specific joystick driver header for the Atmel USBKEY. | ||||
| /** \ingroup Group_Buttons | ||||
|  *  \defgroup Group_Buttons_MICROPENDOUS_REV1 MICROPENDOUS_REV1 | ||||
|  *  \brief Board specific USB Power+Signal switch driver header for the Micropendous Rev1 board. | ||||
|  * | ||||
|  *  Board specific joystick driver header for the Atmel USBKEY. | ||||
|  *  Board specific USB Power+Signal switch driver header for the | ||||
|  *        Micropendous Rev1 board (www.Micropendous.org/Micropendous-REV1). | ||||
|  * | ||||
|  *  @{ | ||||
|  */ | ||||
|  | ||||
| #ifndef __JOYSTICK_USBKEY_H__ | ||||
| #define __JOYSTICK_USBKEY_H__ | ||||
| #ifndef __USB_SWITCH_MICROPENDOUS_REV1_H__ | ||||
| #define __USB_SWITCH_MICROPENDOUS_REV1_H__ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include "../../../../Common/Common.h" | ||||
| 	#include "../../../../Common/Common.h" | ||||
|  | ||||
| 	/* Enable C linkage for C++ Compilers: */ | ||||
| 		#if defined(__cplusplus) | ||||
| 			extern "C" { | ||||
| 		#endif | ||||
|  | ||||
| 	/* Preprocessor Checks: */ | ||||
| 		#if !defined(__INCLUDE_FROM_JOYSTICK_H) | ||||
| 			#error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead. | ||||
| 		#endif | ||||
|  | ||||
| 	/* Private Interface - For use in library only: */ | ||||
| 	#if !defined(__DOXYGEN__) | ||||
| 		/* Macros: */ | ||||
| 			#define JOY_BMASK                 ((1 << 5) | (1 << 6) | (1 << 7)) | ||||
| 			#define JOY_EMASK                 ((1 << 4) | (1 << 5)) | ||||
| 			 | ||||
| 			#define JOY_PORTE_MASK_SHIFT      1 | ||||
| 	#if defined(__cplusplus) | ||||
| 		extern "C" { | ||||
| 	#endif | ||||
|  | ||||
| 	/* Public Interface - May be used in end-application: */ | ||||
| 		/* Macros: */ | ||||
| 			/** Mask for the joystick being pushed in the left direction. */ | ||||
| 			#define JOY_LEFT                  (1 << 6) | ||||
| 	// On Micropendous Rev1 boards the USB Power+Signal switches | ||||
| 	// are controlled by PE7 and are Active-Low | ||||
| 	#if (!defined(NO_AUTO_VBUS_MANAGEMENT)) | ||||
| 		#error Micropendous_REV1 boards require the NO_AUTO_VBUS_MANAGEMENT compile-time LUFA option. | ||||
| 	#endif | ||||
| 	#define SELECT_USB_A		DDRE |= (1 << PE7); PORTE &= ~(1 << PE7); | ||||
| 	#define SELECT_USB_B		DDRE |= (1 << PE7); PORTE |= (1 << PE7); | ||||
|  | ||||
| 			/** Mask for the joystick being pushed in the right direction. */ | ||||
| 			#define JOY_RIGHT                ((1 << 4) >> JOY_PORTE_MASK_SHIFT) | ||||
|  | ||||
| 			/** Mask for the joystick being pushed in the upward direction. */ | ||||
| 			#define JOY_UP                    (1 << 7) | ||||
|  | ||||
| 			/** Mask for the joystick being pushed in the downward direction. */ | ||||
| 			#define JOY_DOWN                 ((1 << 5) >> JOY_PORTE_MASK_SHIFT) | ||||
|  | ||||
| 			/** Mask for the joystick being pushed inward. */ | ||||
| 			#define JOY_PRESS                 (1 << 5) | ||||
|  | ||||
| 		/* Inline Functions: */ | ||||
| 		#if !defined(__DOXYGEN__) | ||||
| 			static inline void Joystick_Init(void) | ||||
| 			{ | ||||
| 				DDRB  &= ~(JOY_BMASK); | ||||
| 				DDRE  &= ~(JOY_EMASK); | ||||
|  | ||||
| 				PORTB |= JOY_BMASK; | ||||
| 				PORTE |= JOY_EMASK; | ||||
| 			} | ||||
|  | ||||
| 			static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; | ||||
| 			static inline uint8_t Joystick_GetStatus(void) | ||||
| 			{ | ||||
| 				return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> JOY_PORTE_MASK_SHIFT)); | ||||
| 			} | ||||
| 		#endif | ||||
| 	// the Rev.1 board does not connect the overcurrent flag to any input pin | ||||
| 	#define OVERCURRENT_FLAG_ENABLE		__asm__ volatile ("NOP" ::) | ||||
| 	#define OVERCURRENT_FLAG_STATUS		0 | ||||
|  | ||||
| 	/* Disable C linkage for C++ Compilers: */ | ||||
| 		#if defined(__cplusplus) | ||||
| 			} | ||||
| 		#endif | ||||
| 	#if defined(__cplusplus) | ||||
| 		} | ||||
| 	#endif | ||||
|  | ||||
| #endif | ||||
| #endif // __USB_SWITCH_MICROPENDOUS_REV1_H__ | ||||
|  | ||||
| /** @} */ | ||||
|  | ||||
|   | ||||
| @@ -9,6 +9,11 @@ | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Modified for the Micropendous series of boards by Opendous Inc. 2011-11-11 | ||||
|   www.Micropendous.org | ||||
|  | ||||
|   Note there is only 1 user button on the Micropendous boards: PE2 - HWB | ||||
|  | ||||
|   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 | ||||
| @@ -29,24 +34,24 @@ | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  *  \brief Board specific Buttons driver header for the Atmel USBKEY. | ||||
|  *  \copydetails Group_Buttons_USBKEY | ||||
|  *  \brief Board specific Buttons driver header for the Micropendous Rev2 board (www.Micropendous.org/Micropendous). | ||||
|  *  \copydetails Group_Buttons_MICROPENDOUS_REV2 | ||||
|  * | ||||
|  *  \note This file should not be included directly. It is automatically included as needed by the Buttons driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/Buttons.h. | ||||
|  */ | ||||
|  | ||||
| /** \ingroup Group_Buttons | ||||
|  *  \defgroup Group_Buttons_USBKEY USBKEY | ||||
|  *  \brief Board specific Buttons driver header for the Atmel USBKEY. | ||||
|  *  \defgroup Group_Buttons_MICROPENDOUS_REV2 MICROPENDOUS_REV2 | ||||
|  *  \brief Board specific Buttons driver header for the Micropendous Rev2. | ||||
|  * | ||||
|  *  Board specific Buttons driver header for the Atmel USBKEY. | ||||
|  *  Board specific Buttons driver header for the Micropendous Rev2 (www.Micropendous.org/Micropendous). | ||||
|  * | ||||
|  *  @{ | ||||
|  */ | ||||
|  | ||||
| #ifndef __BUTTONS_USBKEY_H__ | ||||
| #define __BUTTONS_USBKEY_H__ | ||||
| #ifndef __BUTTONS_MICROPENDOUS_H__ | ||||
| #define __BUTTONS_MICROPENDOUS_H__ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include "../../../../Common/Common.h" | ||||
| @@ -86,7 +91,6 @@ | ||||
| 			} | ||||
| 		#endif | ||||
|  | ||||
| #endif | ||||
| #endif // __BUTTONS_MICROPENDOUS_H__ | ||||
|  | ||||
| /** @} */ | ||||
|  | ||||
|   | ||||
| @@ -1,13 +1,6 @@ | ||||
| /* | ||||
|              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) | ||||
|   Copyright 2011-11-11 By Opendous Inc. | ||||
|   For use with the Micropendous Rev2 board (www.Micropendous.org/Micropendous) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
| @@ -29,162 +22,47 @@ | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  *  \brief Board specific Dataflash driver header for the Atmel USBKEY. | ||||
|  *  \copydetails Group_Dataflash_USBKEY | ||||
|  *  \brief Board specific external SRAM driver header for the Micropendous Rev2 board (www.Micropendous.org/Micropendous). | ||||
|  *  \copydetails Group_EXTERNALSRAM_MICROPENDOUS_REV2 | ||||
|  * | ||||
|  *  \note This file should not be included directly. It is automatically included as needed by the dataflash driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/Dataflash.h. | ||||
|  *  \note This file should not be included directly. It is automatically included by the buttons driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/Buttons.h. | ||||
|  */ | ||||
|  | ||||
| /** \ingroup Group_Dataflash | ||||
|  *  \defgroup Group_Dataflash_USBKEY USBKEY | ||||
|  *  \brief Board specific Dataflash driver header for the Atmel USBKEY. | ||||
| /** \ingroup Group_Buttons | ||||
|  *  \defgroup Group_EXTERNALSRAM_MICROPENDOUS_REV2 MICROPENDOUS_REV2 | ||||
|  *  \brief Board specific external SRAM driver header for the Micropendous Rev2 board. | ||||
|  * | ||||
|  *  Board specific Dataflash driver header for the Atmel USBKEY board. | ||||
|  *  Board specific external SRAM driver header for the Micropendous Rev2 board (www.Micropendous.org/Micropendous). | ||||
|  * | ||||
|  *  @{ | ||||
|  */ | ||||
|  | ||||
| #ifndef __DATAFLASH_USBKEY_H__ | ||||
| #define __DATAFLASH_USBKEY_H__ | ||||
| #ifndef __EXTERNAL_SRAM_MICROPENDOUS_REV2_H__ | ||||
| #define __EXTERNAL_SRAM_MICROPENDOUS_REV2_H__ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include "../../../../Common/Common.h" | ||||
| 		#include "../../../Misc/AT45DB642D.h" | ||||
| 	#include "../../../../Common/Common.h" | ||||
|  | ||||
| 	/* Preprocessor Checks: */ | ||||
| 		#if !defined(__INCLUDE_FROM_DATAFLASH_H) | ||||
| 			#error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead. | ||||
| 		#endif | ||||
|  | ||||
| 	/* Private Interface - For use in library only: */ | ||||
| 	#if !defined(__DOXYGEN__) | ||||
| 		/* Macros: */ | ||||
| 			#define DATAFLASH_CHIPCS_MASK                ((1 << 1) | (1 << 0)) | ||||
| 			#define DATAFLASH_CHIPCS_DDR                 DDRE | ||||
| 			#define DATAFLASH_CHIPCS_PORT                PORTE | ||||
| 	/* Enable C linkage for C++ Compilers: */ | ||||
| 	#if defined(__cplusplus) | ||||
| 		extern "C" { | ||||
| 	#endif | ||||
|  | ||||
| 	/* Public Interface - May be used in end-application: */ | ||||
| 		/* Macros: */ | ||||
| 			/** Constant indicating the total number of dataflash ICs mounted on the selected board. */ | ||||
| 			#define DATAFLASH_TOTALCHIPS                 2 | ||||
| 	// On Micropendous Rev2 boards nCE is PE4 and Address Bit 17 is PE5.  PE0,1,2 are also control signals. | ||||
| 	#define PORTE_EXT_SRAM_SETUP	DDRE = ((1 << PE0) | (1 << PE1) | (1 << PE2) | (1 << PE4) | (1 << PE5)); PORTE = ((1 << PE0) | (1 << PE1) | (1 << PE2) | (1 << PE4)); | ||||
| 	#define ENABLE_EXT_SRAM		DDRE |= (1 << PE4); PORTE &= ~(1 << PE4); | ||||
| 	#define DISABLE_EXT_SRAM	DDRE |= (1 << PE4); PORTE |= (1 << PE4); | ||||
| 	#define SELECT_EXT_SRAM_BANK0	DDRE |= (1 << PE5); PORTE &= ~(1 << PE5); | ||||
| 	#define SELECT_EXT_SRAM_BANK1	DDRE |= (1 << PE5); PORTE |= (1 << PE5); | ||||
| 	#define CURRENT_SRAM_BANK	((PINE >> 5) & (0x01)) | ||||
|  | ||||
| 			/** Mask for no dataflash chip selected. */ | ||||
| 			#define DATAFLASH_NO_CHIP                    DATAFLASH_CHIPCS_MASK | ||||
| 	/* Disable C linkage for C++ Compilers: */ | ||||
| 	#if defined(__cplusplus) | ||||
| 		} | ||||
| 	#endif | ||||
|  | ||||
| 			/** Mask for the first dataflash chip selected. */ | ||||
| 			#define DATAFLASH_CHIP1                      (1 << 1) | ||||
|  | ||||
| 			/** Mask for the second dataflash chip selected. */ | ||||
| 			#define DATAFLASH_CHIP2                      (1 << 0) | ||||
|  | ||||
| 			/** Internal main memory page size for the board's dataflash ICs. */ | ||||
| 			#define DATAFLASH_PAGE_SIZE                  1024 | ||||
|  | ||||
| 			/** Total number of pages inside each of the board's dataflash ICs. */ | ||||
| 			#define DATAFLASH_PAGES                      8192 | ||||
|  | ||||
| 		/* Inline Functions: */ | ||||
| 			/** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC. | ||||
| 			 *  The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used. | ||||
| 			 */ | ||||
| 			static inline void Dataflash_Init(void) | ||||
| 			{ | ||||
| 				DATAFLASH_CHIPCS_DDR  |= DATAFLASH_CHIPCS_MASK; | ||||
| 				DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK; | ||||
| 			} | ||||
|  | ||||
| 			/** Determines the currently selected dataflash chip. | ||||
| 			 * | ||||
| 			 *  \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected | ||||
| 			 *  or a DATAFLASH_CHIPn mask (where n is the chip number). | ||||
| 			 */ | ||||
| 			static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT; | ||||
| 			static inline uint8_t Dataflash_GetSelectedChip(void) | ||||
| 			{ | ||||
| 				return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK); | ||||
| 			} | ||||
|  | ||||
| 			/** Selects the given dataflash chip. | ||||
| 			 * | ||||
| 			 *  \param[in]  ChipMask  Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is | ||||
| 			 *              the chip number). | ||||
| 			 */ | ||||
| 			static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE; | ||||
| 			static inline void Dataflash_SelectChip(const uint8_t ChipMask) | ||||
| 			{ | ||||
| 				DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask); | ||||
| 			} | ||||
|  | ||||
| 			/** Deselects the current dataflash chip, so that no dataflash is selected. */ | ||||
| 			static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE; | ||||
| 			static inline void Dataflash_DeselectChip(void) | ||||
| 			{ | ||||
| 				Dataflash_SelectChip(DATAFLASH_NO_CHIP); | ||||
| 			} | ||||
|  | ||||
| 			/** Selects a dataflash IC from the given page number, which should range from 0 to | ||||
| 			 *  ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one | ||||
| 			 *  dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside | ||||
| 			 *  the total number of pages contained in the boards dataflash ICs, all dataflash ICs | ||||
| 			 *  are deselected. | ||||
| 			 * | ||||
| 			 *  \param[in] PageAddress  Address of the page to manipulate, ranging from | ||||
| 			 *                          0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). | ||||
| 			 */ | ||||
| 			static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress) | ||||
| 			{ | ||||
| 				Dataflash_DeselectChip(); | ||||
|  | ||||
| 				if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS)) | ||||
| 				  return; | ||||
|  | ||||
| 				if (PageAddress & 0x01) | ||||
| 				  Dataflash_SelectChip(DATAFLASH_CHIP2); | ||||
| 				else | ||||
| 				  Dataflash_SelectChip(DATAFLASH_CHIP1); | ||||
| 			} | ||||
|  | ||||
| 			/** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive | ||||
| 			 *  a new command. | ||||
| 			 */ | ||||
| 			static inline void Dataflash_ToggleSelectedChipCS(void) | ||||
| 			{ | ||||
| 				uint8_t SelectedChipMask = Dataflash_GetSelectedChip(); | ||||
|  | ||||
| 				Dataflash_DeselectChip(); | ||||
| 				Dataflash_SelectChip(SelectedChipMask); | ||||
| 			} | ||||
|  | ||||
| 			/** Spin-loops while the currently selected dataflash is busy executing a command, such as a main | ||||
| 			 *  memory page program or main memory to buffer transfer. | ||||
| 			 */ | ||||
| 			static inline void Dataflash_WaitWhileBusy(void) | ||||
| 			{ | ||||
| 				Dataflash_ToggleSelectedChipCS(); | ||||
| 				Dataflash_SendByte(DF_CMD_GETSTATUS); | ||||
| 				while (!(Dataflash_ReceiveByte() & DF_STATUS_READY)); | ||||
| 				Dataflash_ToggleSelectedChipCS(); | ||||
| 			} | ||||
|  | ||||
| 			/** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with | ||||
| 			 *  dataflash commands which require a complete 24-bit address. | ||||
| 			 * | ||||
| 			 *  \param[in] PageAddress  Page address within the selected dataflash IC | ||||
| 			 *  \param[in] BufferByte   Address within the dataflash's buffer | ||||
| 			 */ | ||||
| 			static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, | ||||
| 			                                              const uint16_t BufferByte) | ||||
| 			{ | ||||
| 				PageAddress >>= 1; | ||||
|  | ||||
| 				Dataflash_SendByte(PageAddress >> 5); | ||||
| 				Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8)); | ||||
| 				Dataflash_SendByte(BufferByte); | ||||
| 			} | ||||
|  | ||||
| #endif | ||||
| #endif // __EXTERNAL_SRAM_MICROPENDOUS_REV2_H__ | ||||
|  | ||||
| /** @} */ | ||||
|  | ||||
|   | ||||
| @@ -9,6 +9,11 @@ | ||||
| /* | ||||
|   Copyright 2011  Dean Camera (dean [at] fourwalledcubicle [dot] com) | ||||
|  | ||||
|   Modified for the Micropendous Rev2 board by Opendous Inc. 2011-11-08 | ||||
|   www.Micropendous.org/Micropendous | ||||
|  | ||||
|   Note there is only 1 LED on the Micropendous board: PB1 - SCK | ||||
|  | ||||
|   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 | ||||
| @@ -29,24 +34,24 @@ | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  *  \brief Board specific LED driver header for the Atmel USBKEY. | ||||
|  *  \copydetails Group_LEDs_USBKEY | ||||
|  *  \brief Board specific LED driver header for the Micropendous Rev2 board (www.Micropendous.org/Micropendous). | ||||
|  *  \copydetails Group_MICROPENDOUS_REV2 | ||||
|  * | ||||
|  *  \note This file should not be included directly. It is automatically included as needed by the LEDs driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/LEDs.h. | ||||
|  */ | ||||
|  | ||||
| /** \ingroup Group_LEDs | ||||
|  *  \defgroup Group_LEDs_USBKEY USBKEY | ||||
|  *  \brief Board specific LED driver header for the Atmel USBKEY. | ||||
|  *  \defgroup Group_LEDs_MICROPENDOUS_REV2 MICROPENDOUS_REV2 | ||||
|  *  \brief Board specific LED driver header for the Micropendous Rev2 board. | ||||
|  * | ||||
|  *  Board specific LED driver header for the Atmel USBKEY. | ||||
|  *  Board specific LED driver header for the Micropendous Rev2 board (www.Micropendous.org/Micropendous). | ||||
|  * | ||||
|  *  @{ | ||||
|  */ | ||||
|  | ||||
| #ifndef __LEDS_USBKEY_H__ | ||||
| #define __LEDS_USBKEY_H__ | ||||
| #ifndef __LEDS_MICROPENDOUS_REV2_H__ | ||||
| #define __LEDS_MICROPENDOUS_REV2_H__ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include "../../../../Common/Common.h" | ||||
| @@ -64,16 +69,16 @@ | ||||
| 	/* Public Interface - May be used in end-application: */ | ||||
| 		/* Macros: */ | ||||
| 			/** LED mask for the first LED on the board. */ | ||||
| 			#define LEDS_LED1        (1 << 4) | ||||
| 			#define LEDS_LED1        (1 << 1) | ||||
|  | ||||
| 			/** LED mask for the second LED on the board. */ | ||||
| 			#define LEDS_LED2        (1 << 5) | ||||
| 			#define LEDS_LED2        (0 << 0) | ||||
|  | ||||
| 			/** LED mask for the third LED on the board. */ | ||||
| 			#define LEDS_LED3        (1 << 7) | ||||
| 			#define LEDS_LED3        (0 << 0) | ||||
|  | ||||
| 			/** LED mask for the fourth LED on the board. */ | ||||
| 			#define LEDS_LED4        (1 << 6) | ||||
| 			#define LEDS_LED4        (0 << 0) | ||||
|  | ||||
| 			/** LED mask for all the LEDs on the board. */ | ||||
| 			#define LEDS_ALL_LEDS    (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4) | ||||
| @@ -85,40 +90,40 @@ | ||||
| 		#if !defined(__DOXYGEN__) | ||||
| 			static inline void LEDs_Init(void) | ||||
| 			{ | ||||
| 				DDRD  |=  LEDS_ALL_LEDS; | ||||
| 				PORTD &= ~LEDS_ALL_LEDS; | ||||
| 				DDRB  |=  LEDS_ALL_LEDS; | ||||
| 				PORTB &= ~LEDS_ALL_LEDS; | ||||
| 			} | ||||
|  | ||||
| 			static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) | ||||
| 			{ | ||||
| 				PORTD |= LEDMask; | ||||
| 				PORTB |= LEDMask; | ||||
| 			} | ||||
|  | ||||
| 			static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) | ||||
| 			{ | ||||
| 				PORTD &= ~LEDMask; | ||||
| 				PORTB &= ~LEDMask; | ||||
| 			} | ||||
|  | ||||
| 			static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) | ||||
| 			{ | ||||
| 				PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask); | ||||
| 				PORTB = ((PORTB & ~LEDS_ALL_LEDS) | LEDMask); | ||||
| 			} | ||||
|  | ||||
| 			static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, | ||||
| 			                                   const uint8_t ActiveMask) | ||||
| 			{ | ||||
| 				PORTD = ((PORTD & ~LEDMask) | ActiveMask); | ||||
| 				PORTB = ((PORTB & ~LEDMask) | ActiveMask); | ||||
| 			} | ||||
|  | ||||
| 			static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) | ||||
| 			{ | ||||
| 				PORTD ^= LEDMask; | ||||
| 				PORTB ^= LEDMask; | ||||
| 			} | ||||
|  | ||||
| 			static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; | ||||
| 			static inline uint8_t LEDs_GetLEDs(void) | ||||
| 			{ | ||||
| 				return (PORTD & LEDS_ALL_LEDS); | ||||
| 				return (PORTB & LEDS_ALL_LEDS); | ||||
| 			} | ||||
| 		#endif | ||||
|  | ||||
| @@ -127,6 +132,6 @@ | ||||
| 			} | ||||
| 		#endif | ||||
|  | ||||
| #endif | ||||
| #endif // __LEDS_MICROPENDOUS_REV2_H__ | ||||
|  | ||||
| /** @} */ | ||||
|   | ||||
| @@ -1,13 +1,6 @@ | ||||
| /* | ||||
|              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) | ||||
|   Copyright 2011-11-08 By Opendous Inc. | ||||
|   For use with the Micropendous Rev2 board (www.Micropendous.org/Micropendous) | ||||
|  | ||||
|   Permission to use, copy, modify, distribute, and sell this | ||||
|   software and its documentation for any purpose is hereby granted | ||||
| @@ -29,88 +22,49 @@ | ||||
| */ | ||||
|  | ||||
| /** \file | ||||
|  *  \brief Board specific joystick driver header for the Atmel USBKEY. | ||||
|  *  \copydetails Group_Joystick_USBKEY | ||||
|  *  \brief Board specific USB Power+Signal switch driver header for the | ||||
|  *        Micropendous Rev2 board (www.Micropendous.org/Micropendous). | ||||
|  *  \copydetails Group_Buttons_MICROPENDOUS_REV2 | ||||
|  * | ||||
|  *  \note This file should not be included directly. It is automatically included as needed by the joystick driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/Joystick.h. | ||||
|  *  \note This file should not be included directly. It is automatically included by the buttons driver | ||||
|  *        dispatch header located in LUFA/Drivers/Board/Buttons.h. | ||||
|  */ | ||||
|  | ||||
| /** \ingroup Group_Joystick | ||||
|  *  \defgroup Group_Joystick_USBKEY USBKEY | ||||
|  *  \brief Board specific joystick driver header for the Atmel USBKEY. | ||||
| /** \ingroup Group_Buttons | ||||
|  *  \defgroup Group_Buttons_MICROPENDOUS_REV2 MICROPENDOUS_REV2 | ||||
|  *  \brief Board specific USB Power+Signal switch driver header for the Micropendous Rev2 board. | ||||
|  * | ||||
|  *  Board specific joystick driver header for the Atmel USBKEY. | ||||
|  *  Board specific USB Power+Signal switch driver header for the | ||||
|  *        Micropendous Rev2 board (www.Micropendous.org/Micropendous). | ||||
|  * | ||||
|  *  @{ | ||||
|  */ | ||||
|  | ||||
| #ifndef __JOYSTICK_USBKEY_H__ | ||||
| #define __JOYSTICK_USBKEY_H__ | ||||
| #ifndef __USB_SWITCH_MICROPENDOUS_REV2_H__ | ||||
| #define __USB_SWITCH_MICROPENDOUS_REV2_H__ | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include "../../../../Common/Common.h" | ||||
| 	#include "../../../../Common/Common.h" | ||||
|  | ||||
| 	/* Enable C linkage for C++ Compilers: */ | ||||
| 		#if defined(__cplusplus) | ||||
| 			extern "C" { | ||||
| 		#endif | ||||
|  | ||||
| 	/* Preprocessor Checks: */ | ||||
| 		#if !defined(__INCLUDE_FROM_JOYSTICK_H) | ||||
| 			#error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead. | ||||
| 		#endif | ||||
|  | ||||
| 	/* Private Interface - For use in library only: */ | ||||
| 	#if !defined(__DOXYGEN__) | ||||
| 		/* Macros: */ | ||||
| 			#define JOY_BMASK                 ((1 << 5) | (1 << 6) | (1 << 7)) | ||||
| 			#define JOY_EMASK                 ((1 << 4) | (1 << 5)) | ||||
| 			 | ||||
| 			#define JOY_PORTE_MASK_SHIFT      1 | ||||
| 	#if defined(__cplusplus) | ||||
| 		extern "C" { | ||||
| 	#endif | ||||
|  | ||||
| 	/* Public Interface - May be used in end-application: */ | ||||
| 		/* Macros: */ | ||||
| 			/** Mask for the joystick being pushed in the left direction. */ | ||||
| 			#define JOY_LEFT                  (1 << 6) | ||||
| 	// On Micropendous Rev2 boards the USB Power+Signal switches | ||||
| 	// are controlled by PE7 and are Active-High | ||||
| 	#define SELECT_USB_A		DDRE |= (1 << PE7); PORTE |= (1 << PE7); | ||||
| 	#define SELECT_USB_B		DDRE |= (1 << PE7); PORTE &= ~(1 << PE7); | ||||
|  | ||||
| 			/** Mask for the joystick being pushed in the right direction. */ | ||||
| 			#define JOY_RIGHT                ((1 << 4) >> JOY_PORTE_MASK_SHIFT) | ||||
|  | ||||
| 			/** Mask for the joystick being pushed in the upward direction. */ | ||||
| 			#define JOY_UP                    (1 << 7) | ||||
|  | ||||
| 			/** Mask for the joystick being pushed in the downward direction. */ | ||||
| 			#define JOY_DOWN                 ((1 << 5) >> JOY_PORTE_MASK_SHIFT) | ||||
|  | ||||
| 			/** Mask for the joystick being pushed inward. */ | ||||
| 			#define JOY_PRESS                 (1 << 5) | ||||
|  | ||||
| 		/* Inline Functions: */ | ||||
| 		#if !defined(__DOXYGEN__) | ||||
| 			static inline void Joystick_Init(void) | ||||
| 			{ | ||||
| 				DDRB  &= ~(JOY_BMASK); | ||||
| 				DDRE  &= ~(JOY_EMASK); | ||||
|  | ||||
| 				PORTB |= JOY_BMASK; | ||||
| 				PORTE |= JOY_EMASK; | ||||
| 			} | ||||
|  | ||||
| 			static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT; | ||||
| 			static inline uint8_t Joystick_GetStatus(void) | ||||
| 			{ | ||||
| 				return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> JOY_PORTE_MASK_SHIFT)); | ||||
| 			} | ||||
| 		#endif | ||||
| 	#define OVERCURRENT_FLAG_ENABLE		DDRE &= ~(1 << PE6); PORTE &= ~(1 << PE6); | ||||
| 	#define OVERCURRENT_FLAG_STATUS		~((PINE >> 6) & (0x01)) | ||||
|  | ||||
| 	/* Disable C linkage for C++ Compilers: */ | ||||
| 		#if defined(__cplusplus) | ||||
| 			} | ||||
| 		#endif | ||||
| 	#if defined(__cplusplus) | ||||
| 		} | ||||
| 	#endif | ||||
|  | ||||
| #endif | ||||
| #endif // __USB_SWITCH_MICROPENDOUS_REV2_H__ | ||||
|  | ||||
| /** @} */ | ||||
|  | ||||
|   | ||||
							
								
								
									
										148
									
								
								Micropendous/libs/LUFA/LUFA/Drivers/Board/BoardSupport.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										148
									
								
								Micropendous/libs/LUFA/LUFA/Drivers/Board/BoardSupport.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,148 @@ | ||||
| /* | ||||
|              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) | ||||
|  | ||||
|   This is Buttons.h modified for general "Board Support" by Opendous Inc. 2011-11-11 | ||||
|  | ||||
|   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 | ||||
|  *  \brief Board Support - drivers for all relevant board hardware. | ||||
|  * | ||||
|  *  This file is the master dispatch header file for the board-specific drivers. | ||||
|  * | ||||
|  *  User code should include this file, which will in turn include all the correct driver header | ||||
|  *  files for the currently selected board. | ||||
|  * | ||||
|  *  If the \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/BoardSupport.h | ||||
|  *  file in the user project directory. | ||||
|  * | ||||
|  *  For possible \c BOARD makefile values, see \ref Group_BoardTypes. | ||||
|  */ | ||||
|  | ||||
| /** \ingroup Group_BoardDrivers | ||||
|  *  \defgroup Group_BoardSupport Board Support Drivers - LUFA/Drivers/Board/BoardSupport.h | ||||
|  *  \brief Drivers for all relevant board hardware. | ||||
|  * | ||||
|  *  \section Sec_Dependencies Module Source Dependencies | ||||
|  *  The following files must be built with any user project that uses this module: | ||||
|  *    - None | ||||
|  * | ||||
|  *  \section Sec_ModDescription Module Description | ||||
|  *  Hardware buttons driver. This provides an easy to use driver for the hardware buttons present on many boards. | ||||
|  *  It provides a way to easily configure and check the status of all the buttons on the board so that appropriate | ||||
|  *  actions can be taken. | ||||
|  * | ||||
|  *  If the \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/BoardSupport.h | ||||
|  *  file in the user project directory. Otherwise, it will include the appropriate built in board driver header file. | ||||
|  * | ||||
|  *  For possible \c BOARD makefile values, see \ref Group_BoardTypes. | ||||
|  * | ||||
|  *  \section Sec_ExampleUsage Example Usage | ||||
|  *  The following snippet is an example of how this module may be used within a typical | ||||
|  *  application. | ||||
|  * | ||||
|  *  \code | ||||
|  *      // Initialize the button driver before first use | ||||
|  *      Board_Init(); | ||||
|  * | ||||
|  *      // Turn on each of the four LEDs in turn | ||||
|  *      LEDs_SetAllLEDs(LEDS_LED1);  | ||||
|  *      Delay_MS(500); | ||||
|  *      LEDs_SetAllLEDs(LEDS_LED2);  | ||||
|  *      Delay_MS(500); | ||||
|  * | ||||
|  *      printf("Waiting for button press...\r\n"); | ||||
|  * | ||||
|  *      // Loop until a board button has been pressed | ||||
|  *      uint8_t ButtonPress; | ||||
|  *      while (!(ButtonPress = Buttons_GetStatus())) {}; | ||||
|  * | ||||
|  *      // Display which button was pressed (assuming two board buttons) | ||||
|  *      printf("Button pressed: %s\r\n", (ButtonPress == BUTTONS_BUTTON1) ? "Button 1" : "Button 2"); | ||||
|  *  \endcode | ||||
|  *  | ||||
|  *  @{ | ||||
|  */ | ||||
|  | ||||
| #ifndef __BOARDSUPPORT_H__ | ||||
| #define __BOARDSUPPORT_H__ | ||||
|  | ||||
| 	/* Macros: */ | ||||
| 		#define __INCLUDE_FROM_BUTTONS_H | ||||
|  | ||||
| 	/* Includes: */ | ||||
| 		#include "../../Common/Common.h" | ||||
|  | ||||
| 		// Button and LED drivers have a do-nothing/empty option so that the following will always successfully include | ||||
| 		#include "Buttons.h" | ||||
| 		#include "LEDs.h" | ||||
|  | ||||
| 		// The Micropendous-A board has external SRAM but otherwise should grab the defines frm the following else clause | ||||
| 		#if (BOARD == BOARD_MICROPENDOUS_A) | ||||
| 			#include "AVR8/MICROPENDOUS_A/External_SRAM.h" | ||||
| 		#endif | ||||
|  | ||||
| 		#if (BOARD == BOARD_MICROPENDOUS_REV1) | ||||
| 			#include "AVR8/MICROPENDOUS_REV1/External_SRAM.h" | ||||
| 			#include "AVR8/MICROPENDOUS_REV1/USB_Switch.h" | ||||
| 			#include "AVR8/MICROPENDOUS_REV1/Voltage_TXRX.h" | ||||
| 		#elif (BOARD == BOARD_MICROPENDOUS_REV2) | ||||
| 			#include "AVR8/MICROPENDOUS_REV2/External_SRAM.h" | ||||
| 			#include "AVR8/MICROPENDOUS_REV2/USB_Switch.h" | ||||
| 			#include "AVR8/MICROPENDOUS_REV2/Voltage_TXRX.h" | ||||
| 		#else | ||||
| 			// the following are board defines that can still exist in functional programs that do | ||||
| 			// not use External SRAM, a Voltage Translator, or the USB Signal+Power switches | ||||
| 			#define DISABLE_VOLTAGE_TXRX	__asm__ volatile ("NOP" ::) | ||||
| 			#define ENABLE_VOLTAGE_TXRX	__asm__ volatile ("NOP" ::) | ||||
| 			#if !defined(DISABLE_EXT_SRAM) | ||||
| 				#define DISABLE_EXT_SRAM	__asm__ volatile ("NOP" ::) | ||||
| 			#endif | ||||
| 			#define SELECT_USB_A		__asm__ volatile ("NOP" ::) | ||||
| 			#define SELECT_USB_B		__asm__ volatile ("NOP" ::) | ||||
| 			#define OVERCURRENT_FLAG_ENABLE		__asm__ volatile ("NOP" ::) | ||||
| 			#define OVERCURRENT_FLAG_STATUS		0 | ||||
| 		#endif | ||||
|  | ||||
| 		#define Board_Init()			Buttons_Init(); LEDs_Init(); | ||||
|  | ||||
| 	/* Pseudo-Functions for Doxygen: */ | ||||
| 	#if defined(__DOXYGEN__) | ||||
| 		/** Initializes the BOARDSUPPORT driver, so that the current button position can be read. This sets the appropriate | ||||
| 		 *  I/O pins to an inputs with pull-ups enabled. | ||||
| 		 * | ||||
| 		 *  \return None | ||||
| 		 * | ||||
| 		 *  This must be called before any driver functions are used. | ||||
| 		 */ | ||||
| 		static inline void Board_Init(void); | ||||
| 	#endif | ||||
|  | ||||
| #endif // __BOARDSUPPORT_H__ | ||||
|  | ||||
| /** @} */ | ||||
| @@ -92,7 +92,9 @@ | ||||
| 		#include "../../Common/Common.h" | ||||
|  | ||||
| 		#if (BOARD == BOARD_NONE) | ||||
| 			#error The Board Buttons driver cannot be used if the makefile BOARD option is not set. | ||||
| 			#define BUTTONS_BUTTON1      (0 << 0) | ||||
| 			static inline void Buttons_Init(void) {}; | ||||
| 			static inline uint8_t Buttons_GetStatus(void) {return 0;}; | ||||
| 		#elif (BOARD == BOARD_USBKEY) | ||||
| 			#include "AVR8/USBKEY/Buttons.h" | ||||
| 		#elif (BOARD == BOARD_STK525) | ||||
| @@ -131,24 +133,21 @@ | ||||
| 			#include "UC3/EVK1100/Buttons.h" | ||||
| 		#elif (BOARD == BOARD_EVK1104) | ||||
| 			#include "UC3/EVK1104/Buttons.h" | ||||
| 		#elif (BOARD == BOARD_MICROPENDOUS_OLD) | ||||
| 			#include "AVR8/MICROPENDOUS_OLD/Buttons.h" | ||||
| 			#include "AVR8/MICROPENDOUS_OLD/External_SRAM.h" | ||||
| 		#elif (BOARD == BOARD_MICROPENDOUS_A) | ||||
| 			#include "AVR8/MICROPENDOUS_A/Buttons.h" | ||||
| 			#include "AVR8/MICROPENDOUS_A/External_SRAM.h" | ||||
| 		#elif (BOARD == BOARD_MICROPENDOUS_REV1) | ||||
| 			#include "AVR8/MICROPENDOUS_REV1/Buttons.h" | ||||
| 			#include "AVR8/MICROPENDOUS_REV1/External_SRAM.h" | ||||
| 			#include "AVR8/MICROPENDOUS_REV1/USB_Switch.h" | ||||
| 		#elif (BOARD == BOARD_MICROPENDOUS_REV2) | ||||
| 			#include "AVR8/MICROPENDOUS_REV2/Buttons.h" | ||||
| 			#include "AVR8/MICROPENDOUS_REV2/External_SRAM.h" | ||||
| 			#include "AVR8/MICROPENDOUS_REV2/USB_Switch.h" | ||||
| 		#elif (BOARD == BOARD_MICROPENDOUS_32U2) | ||||
| 			#include "AVR8/MICROPENDOUS_32U2/Buttons.h" | ||||
| 		#else | ||||
| 		#elif (BOARD == BOARD_USER) | ||||
| 			#include "Board/Buttons.h" | ||||
| 		#else | ||||
| 			// this allows BoardSupport.h to include empty LED drivers | ||||
| 			#define BUTTONS_BUTTON1      (0 << 0) | ||||
| 			static inline void Buttons_Init(void) {}; | ||||
| 			static inline uint8_t Buttons_GetStatus(void) {return 0;}; | ||||
| 		#endif | ||||
|  | ||||
| 	/* Pseudo-Functions for Doxygen: */ | ||||
|   | ||||
| @@ -100,7 +100,9 @@ | ||||
| 		#include "../../Common/Common.h" | ||||
|  | ||||
| 		#if (BOARD == BOARD_NONE) | ||||
| 			#error The Board Joystick driver cannot be used if the makefile BOARD option is not set. | ||||
| 			#warning The currently selected BOARD has no Joystick so the included Joystick driver does nothing. | ||||
| 				static inline void Joystick_Init(void) { __asm__ volatile ("NOP" ::); }; | ||||
| 				static inline uint_reg_t Joystick_GetStatus(void) { return 0; }; | ||||
| 		#elif (BOARD == BOARD_USBKEY) | ||||
| 			#include "AVR8/USBKEY/Joystick.h" | ||||
| 		#elif (BOARD == BOARD_STK525) | ||||
|   | ||||
| @@ -107,7 +107,7 @@ | ||||
| 	/* Includes: */ | ||||
| 		#include "../../Common/Common.h" | ||||
|  | ||||
| 		#if ((BOARD == BOARD_NONE) || (BOARD == BOARD_MICROPENDOUS_OLD) || (BOARD == BOARD_MICROPENDOUS_A)) | ||||
| 		#if ((BOARD == BOARD_NONE) || (BOARD == BOARD_MICROPENDOUS_A)) | ||||
| 			static inline void LEDs_Init(void) {}; | ||||
| 			static inline void LEDs_TurnOnLEDs(const uint_reg_t LEDMask) {}; | ||||
| 			static inline void LEDs_TurnOffLEDs(const uint_reg_t LEDMask) {}; | ||||
| @@ -177,26 +177,43 @@ | ||||
| 			#include "AVR8/MICROPENDOUS_REV2/LEDs.h" | ||||
| 		#elif (BOARD == BOARD_MICROPENDOUS_32U2) | ||||
| 			#include "AVR8/MICROPENDOUS_32U2/LEDs.h" | ||||
| 		#else | ||||
| 		#elif (BOARD == BOARD_USER) | ||||
| 			#include "Board/LEDs.h" | ||||
| 		#else | ||||
| 			// this allows BoardSupport.h to include empty LED drivers | ||||
| 			static inline void LEDs_Init(void) {}; | ||||
| 			static inline void LEDs_TurnOnLEDs(const uint_reg_t LEDMask) {}; | ||||
| 			static inline void LEDs_TurnOffLEDs(const uint_reg_t LEDMask) {}; | ||||
| 			static inline void LEDs_SetAllLEDs(const uint_reg_t LEDMask) {}; | ||||
| 			static inline void LEDs_ChangeLEDs(const uint_reg_t LEDMask, const uint_reg_t ActiveMask) {}; | ||||
| 			static inline void LEDs_ToggleLEDs(const uint_reg_t LEDMask) {}; | ||||
| 			static inline uint_reg_t LEDs_GetLEDs(void) { return 0; } | ||||
| 		#endif | ||||
|  | ||||
| 	/* Preprocessor Checks: */ | ||||
| 		#if !defined(__DOXYGEN__) | ||||
| 			#if !defined(LEDS_LED1) | ||||
| 				#define LEDS_LED1      0 | ||||
| 				#define LEDS_LED1	0 | ||||
| 			#endif | ||||
|  | ||||
| 			#if !defined(LEDS_LED2) | ||||
| 				#define LEDS_LED2      0 | ||||
| 				#define LEDS_LED2	0 | ||||
| 			#endif | ||||
|  | ||||
| 			#if !defined(LEDS_LED3) | ||||
| 				#define LEDS_LED3      0 | ||||
| 				#define LEDS_LED3	0 | ||||
| 			#endif | ||||
|  | ||||
| 			#if !defined(LEDS_LED4) | ||||
| 				#define LEDS_LED4      0 | ||||
| 				#define LEDS_LED4	0 | ||||
| 			#endif | ||||
|  | ||||
| 			#if !defined(LEDS_ALL_LEDS) | ||||
| 				#define LEDS_LED4	0 | ||||
| 			#endif | ||||
|  | ||||
| 			#if !defined(LEDS_LED4) | ||||
| 				#define LEDS_NO_LEDS	0 | ||||
| 			#endif | ||||
| 		#endif | ||||
|  | ||||
|   | ||||
| @@ -51,6 +51,7 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter | ||||
| 			if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) | ||||
| 			{ | ||||
| 				Endpoint_ClearSETUP(); | ||||
| 				while (!(Endpoint_IsINReady())); | ||||
| 				Endpoint_Write_32_LE(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS); | ||||
| 				Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.CharFormat); | ||||
| 				Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.ParityType); | ||||
| @@ -64,6 +65,7 @@ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInter | ||||
| 			if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) | ||||
| 			{ | ||||
| 				Endpoint_ClearSETUP(); | ||||
| 				while (!(Endpoint_IsOUTReceived())); | ||||
| 				CDCInterfaceInfo->State.LineEncoding.BaudRateBPS = Endpoint_Read_32_LE(); | ||||
| 				CDCInterfaceInfo->State.LineEncoding.CharFormat  = Endpoint_Read_8(); | ||||
| 				CDCInterfaceInfo->State.LineEncoding.ParityType  = Endpoint_Read_8(); | ||||
|   | ||||
| @@ -94,6 +94,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter | ||||
| 			if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) | ||||
| 			{ | ||||
| 				Endpoint_ClearSETUP(); | ||||
| 				while (!(Endpoint_IsINReady())); | ||||
| 				Endpoint_Write_8(HIDInterfaceInfo->State.UsingReportProtocol); | ||||
| 				Endpoint_ClearIN(); | ||||
| 				Endpoint_ClearStatusStage(); | ||||
| @@ -124,6 +125,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter | ||||
| 			if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) | ||||
| 			{ | ||||
| 				Endpoint_ClearSETUP(); | ||||
| 				while (!(Endpoint_IsINReady())); | ||||
| 				Endpoint_Write_8(HIDInterfaceInfo->State.IdleCount >> 2); | ||||
| 				Endpoint_ClearIN(); | ||||
| 				Endpoint_ClearStatusStage(); | ||||
|   | ||||
| @@ -61,6 +61,7 @@ void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfac | ||||
| 			if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)) | ||||
| 			{ | ||||
| 				Endpoint_ClearSETUP(); | ||||
| 				while (!(Endpoint_IsINReady())); | ||||
| 				Endpoint_Write_8(MSInterfaceInfo->Config.TotalLUNs - 1); | ||||
| 				Endpoint_ClearIN(); | ||||
| 				Endpoint_ClearStatusStage(); | ||||
|   | ||||
| @@ -77,8 +77,23 @@ void USB_Host_ProcessNextHostState(void) | ||||
| 				USB_Host_VBUS_Manual_Off(); | ||||
|  | ||||
| 				USB_OTGPAD_On(); | ||||
| 				USB_Host_VBUS_Auto_Enable(); | ||||
| 				USB_Host_VBUS_Auto_On(); | ||||
|  | ||||
| 				#if defined(NO_AUTO_VBUS_MANAGEMENT) | ||||
| 					#if (ARCH == ARCH_AVR8) | ||||
| 						// won't work without first calling the auto functions | ||||
| 						USB_Host_VBUS_Auto_Enable(); | ||||
| 						USB_Host_VBUS_Auto_On(); | ||||
| 					#endif | ||||
| 					USB_Host_VBUS_Manual_Enable(); | ||||
| 					USB_Host_VBUS_Manual_Off(); | ||||
| 				#else | ||||
| 					USB_Host_VBUS_Auto_Enable(); | ||||
| 					USB_Host_VBUS_Auto_On(); | ||||
| 				#endif | ||||
|  | ||||
| 				#if defined(INVERTED_VBUS_ENABLE_LINE) | ||||
| 					USB_Host_VBUS_Manual_On(); | ||||
| 				#endif | ||||
|  | ||||
| 				USB_HostState = HOST_STATE_Powered_WaitForConnect; | ||||
| 			} | ||||
| @@ -185,7 +200,11 @@ void USB_Host_ProcessNextHostState(void) | ||||
| 	{ | ||||
| 		EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode); | ||||
|  | ||||
| 		#if !defined(NO_AUTO_VBUS_MANAGEMENT) | ||||
| 		USB_Host_VBUS_Auto_Off(); | ||||
| 		#else | ||||
| 		USB_Host_VBUS_Manual_Off(); | ||||
| 		#endif | ||||
|  | ||||
| 		EVENT_USB_Host_DeviceUnattached(); | ||||
|  | ||||
|   | ||||
| @@ -64,6 +64,10 @@ | ||||
| 			#error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. | ||||
| 		#endif | ||||
|  | ||||
| 		#if defined(INVERTED_VBUS_ENABLE_LINE) && !defined(NO_AUTO_VBUS_MANAGEMENT) | ||||
| 			#error INVERTED_VBUS_ENABLE_LINE compile time option requires NO_AUTO_VBUS_MANAGEMENT on AVR8 devices. | ||||
| 		#endif | ||||
|  | ||||
| 	/* Public Interface - May be used in end-application: */ | ||||
| 		/* Macros: */ | ||||
| 			/** Indicates the fixed USB device address which any attached device is enumerated to when in | ||||
| @@ -310,7 +314,11 @@ | ||||
| 			static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE; | ||||
| 			static inline void USB_Host_VBUS_Manual_On(void) | ||||
| 			{ | ||||
| 				#if defined(INVERTED_VBUS_ENABLE_LINE) | ||||
| 				PORTE  &= ~(1 << 7); | ||||
| 				#else | ||||
| 				PORTE  |=  (1 << 7); | ||||
| 				#endif | ||||
| 			} | ||||
|  | ||||
| 			static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE; | ||||
| @@ -322,7 +330,11 @@ | ||||
| 			static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE; | ||||
| 			static inline void USB_Host_VBUS_Manual_Off(void) | ||||
| 			{ | ||||
| 				#if defined(INVERTED_VBUS_ENABLE_LINE) | ||||
| 				PORTE  |=  (1 << 7); | ||||
| 				#else | ||||
| 				PORTE  &= ~(1 << 7); | ||||
| 				#endif | ||||
| 			} | ||||
|  | ||||
| 			static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; | ||||
|   | ||||
| @@ -256,7 +256,7 @@ static void USB_Init_Host(void) | ||||
|  | ||||
| 	USB_INT_Enable(USB_INT_SRPI); | ||||
| 	USB_INT_Enable(USB_INT_BCERRI); | ||||
| 	 | ||||
|  | ||||
| 	USB_Attach(); | ||||
| } | ||||
| #endif | ||||
|   | ||||
| @@ -1,129 +1,119 @@ | ||||
| /* | ||||
|              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. | ||||
| */ | ||||
|  | ||||
| #include "DiskHost.h" | ||||
|  | ||||
| #if defined(USB_CAN_BE_HOST) | ||||
| /** LUFA Mass Storage Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all Mass Storage Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_MS_Host_t DiskHost_MS_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.DataINPipeNumber       = 1, | ||||
| 				.DataINPipeDoubleBank   = false, | ||||
|  | ||||
| 				.DataOUTPipeNumber      = 2, | ||||
| 				.DataOUTPipeDoubleBank  = false, | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
|  | ||||
| void DiskHost_USBTask(void) | ||||
| { | ||||
| 	if (USB_HostState == HOST_STATE_Addressed) | ||||
| 	{ | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
|  | ||||
| 		uint16_t ConfigDescriptorSize; | ||||
| 		uint8_t  ConfigDescriptorData[512]; | ||||
|  | ||||
| 		if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, | ||||
| 											   sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) | ||||
| 		{ | ||||
| 			LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 			USB_HostState = HOST_STATE_WaitForDeviceRemoval; | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		if (MS_Host_ConfigurePipes(&DiskHost_MS_Interface, | ||||
| 		                           ConfigDescriptorSize, ConfigDescriptorData) != MS_ENUMERROR_NoError) | ||||
| 		{ | ||||
| 			LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 			USB_HostState = HOST_STATE_WaitForDeviceRemoval; | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) | ||||
| 		{ | ||||
| 			LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 			USB_HostState = HOST_STATE_WaitForDeviceRemoval; | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		uint8_t MaxLUNIndex; | ||||
| 		if (MS_Host_GetMaxLUN(&DiskHost_MS_Interface, &MaxLUNIndex)) | ||||
| 		{ | ||||
| 			LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 			USB_HostState = HOST_STATE_WaitForDeviceRemoval; | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		if (MS_Host_ResetMSInterface(&DiskHost_MS_Interface)) | ||||
| 		{ | ||||
| 			LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 			USB_HostState = HOST_STATE_WaitForDeviceRemoval; | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		USB_HostState = HOST_STATE_Configured; | ||||
|  | ||||
| 		/* Note: For the RequestSense call to work, the host state machine must be in the | ||||
| 		 *       Configured state, or the call will be aborted */ | ||||
| 		SCSI_Request_Sense_Response_t SenseData; | ||||
| 		if (MS_Host_RequestSense(&DiskHost_MS_Interface, 0, &SenseData) != 0) | ||||
| 		{ | ||||
| 			LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 			USB_HostState = HOST_STATE_WaitForDeviceRemoval; | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| 		pf_mount(&DiskFATState); | ||||
|  | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_READY); | ||||
| 	} | ||||
|  | ||||
| 	MS_Host_USBTask(&DiskHost_MS_Interface); | ||||
| } | ||||
|  | ||||
| void EVENT_USB_Host_DeviceAttached(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| void EVENT_USB_Host_DeviceUnattached(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| #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. | ||||
| */ | ||||
|  | ||||
| #include "DiskHost.h" | ||||
|  | ||||
| #if defined(USB_CAN_BE_HOST) | ||||
| /** LUFA Mass Storage Class driver interface configuration and state information. This structure is | ||||
|  *  passed to all Mass Storage Class driver functions, so that multiple instances of the same class | ||||
|  *  within a device can be differentiated from one another. | ||||
|  */ | ||||
| USB_ClassInfo_MS_Host_t DiskHost_MS_Interface = | ||||
| 	{ | ||||
| 		.Config = | ||||
| 			{ | ||||
| 				.DataINPipeNumber       = 1, | ||||
| 				.DataINPipeDoubleBank   = false, | ||||
|  | ||||
| 				.DataOUTPipeNumber      = 2, | ||||
| 				.DataOUTPipeDoubleBank  = false, | ||||
| 			}, | ||||
| 	}; | ||||
|  | ||||
|  | ||||
| void DiskHost_USBTask(void) | ||||
| { | ||||
| 	MS_Host_USBTask(&DiskHost_MS_Interface); | ||||
| } | ||||
|  | ||||
| void EVENT_USB_Host_DeviceEnumerationComplete(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
|  | ||||
| 	uint16_t ConfigDescriptorSize; | ||||
| 	uint8_t  ConfigDescriptorData[512]; | ||||
|  | ||||
| 	if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData, | ||||
| 										   sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful) | ||||
| 	{ | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	if (MS_Host_ConfigurePipes(&DiskHost_MS_Interface, | ||||
| 							   ConfigDescriptorSize, ConfigDescriptorData) != MS_ENUMERROR_NoError) | ||||
| 	{ | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) | ||||
| 	{ | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	uint8_t MaxLUNIndex; | ||||
| 	if (MS_Host_GetMaxLUN(&DiskHost_MS_Interface, &MaxLUNIndex)) | ||||
| 	{ | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	if (MS_Host_ResetMSInterface(&DiskHost_MS_Interface)) | ||||
| 	{ | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	SCSI_Request_Sense_Response_t SenseData; | ||||
| 	if (MS_Host_RequestSense(&DiskHost_MS_Interface, 0, &SenseData) != 0) | ||||
| 	{ | ||||
| 		LEDs_SetAllLEDs(LEDMASK_USB_ERROR); | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	pf_mount(&DiskFATState); | ||||
|  | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_READY); | ||||
| } | ||||
|  | ||||
| void EVENT_USB_Host_DeviceAttached(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); | ||||
| } | ||||
|  | ||||
| void EVENT_USB_Host_DeviceUnattached(void) | ||||
| { | ||||
| 	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); | ||||
| } | ||||
|  | ||||
| #endif | ||||
|  | ||||
|   | ||||
| @@ -1,166 +1,165 @@ | ||||
| /* | ||||
|              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 Standalone Programmer project. This file contains the main tasks of | ||||
|  *  the project and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #define  INCLUDE_FROM_STANDALONEPROG_C | ||||
| #include "StandaloneProgrammer.h" | ||||
|  | ||||
| /** Standard file stream for the currently open file on the disk. */ | ||||
| FILE DiskStream = FDEV_SETUP_STREAM(NULL, Disk_getchar, _FDEV_SETUP_READ); | ||||
|  | ||||
| /** Petite FAT Fs structure to hold the internal state of the FAT driver for the Dataflash contents. */ | ||||
| FATFS DiskFATState; | ||||
|  | ||||
|  | ||||
| /** Stream character fetching routine for the FAT driver so that characters from the currently open file can be | ||||
|  *  read in sequence when applied to a stdio stream. | ||||
|  */ | ||||
| static int Disk_getchar(FILE* Stream) | ||||
| { | ||||
| 	char ReadByte; | ||||
| 	WORD ByteWasRead; | ||||
|  | ||||
| 	if (pf_read(&ReadByte, 1, &ByteWasRead) != FR_OK) | ||||
| 	  return _FDEV_ERR; | ||||
|  | ||||
| 	return (ByteWasRead ? ReadByte : _FDEV_EOF); | ||||
| } | ||||
|  | ||||
| #if defined(USB_CAN_BE_BOTH) | ||||
| /** Event to handle mode changes in the library, to clear the FAT library's drive state structure when transitioning | ||||
|  *  between modes. This ensures that the library always works with current disk data. | ||||
|  */ | ||||
| void EVENT_USB_UIDChange(void) | ||||
| { | ||||
| 	pf_mount(&DiskFATState); | ||||
| } | ||||
| #endif | ||||
|  | ||||
| /** Task to determine if the user is wishes to start the programming sequence, and if so executes the | ||||
|  *  required functions to program the attached target (if any) with the files loaded to the Dataflash. | ||||
|  */ | ||||
| void Programmer_Task(void) | ||||
| { | ||||
| 	static bool HasAttempted = false; | ||||
|  | ||||
| 	if (Buttons_GetStatus() & BUTTONS_BUTTON1) | ||||
| 	{ | ||||
| 		if (!(HasAttempted)) | ||||
| 			HasAttempted = true; | ||||
| 		else | ||||
| 			return; | ||||
|  | ||||
| 		puts("==== PROGRAMMING CYCLE STARTED ====\r\n"); | ||||
|  | ||||
| 		#if defined(USB_CAN_BE_BOTH) | ||||
| 		printf("Using %s Drive...\r\n", (USB_CurrentMode == USB_MODE_Host) ? "External" : "Internal"); | ||||
| 		#endif | ||||
|  | ||||
| 		puts("Reading Configuration File...\r\n"); | ||||
| 		if (!(ProgrammerConfig_ProcessConfiguration())) | ||||
| 		  goto EndOfProgCycle; | ||||
|  | ||||
| 		EndOfProgCycle: | ||||
| 		puts("==== PROGRAMMING CYCLE FINISHED ====\r\n"); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		HasAttempted = 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 (;;) | ||||
| 	{ | ||||
| 		Programmer_Task(); | ||||
|  | ||||
| 		if (USB_CurrentMode == USB_MODE_Host) | ||||
| 		{ | ||||
| 			#if defined(USB_CAN_BE_HOST) | ||||
| 			DiskHost_USBTask(); | ||||
| 			#endif | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			#if defined(USB_CAN_BE_DEVICE) | ||||
| 			DiskDevice_USBTask(); | ||||
| 			#endif | ||||
| 		} | ||||
|  | ||||
| 		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 */ | ||||
| 	#if defined(USB_CAN_BE_BOTH) | ||||
| 	USB_Init(USB_MODE_UID); | ||||
| 	#else | ||||
| 	USB_Init(); | ||||
| 	#endif | ||||
|  | ||||
| 	LEDs_Init(); | ||||
| 	SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER); | ||||
| 	Dataflash_Init(); | ||||
| 	Buttons_Init(); | ||||
| 	Serial_Init(9600, true); | ||||
|  | ||||
| 	/* Create a stdio stream for the serial port for stdin and stdout */ | ||||
| 	Serial_CreateStream(NULL); | ||||
|  | ||||
| 	#if defined(USB_CAN_BE_DEVICE) | ||||
| 	/* Clear Dataflash sector protections, if enabled */ | ||||
| 	DataflashManager_ResetDataflashProtections(); | ||||
| 	#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 | ||||
|  * | ||||
|  *  Main source file for the Standalone Programmer project. This file contains the main tasks of | ||||
|  *  the project and is responsible for the initial application hardware configuration. | ||||
|  */ | ||||
|  | ||||
| #define  INCLUDE_FROM_STANDALONEPROG_C | ||||
| #include "StandaloneProgrammer.h" | ||||
|  | ||||
| /** Standard file stream for the currently open file on the disk. */ | ||||
| FILE DiskStream = FDEV_SETUP_STREAM(NULL, Disk_getchar, _FDEV_SETUP_READ); | ||||
|  | ||||
| /** Petite FAT Fs structure to hold the internal state of the FAT driver for the Dataflash contents. */ | ||||
| FATFS DiskFATState; | ||||
|  | ||||
| /** Stream character fetching routine for the FAT driver so that characters from the currently open file can be | ||||
|  *  read in sequence when applied to a stdio stream. | ||||
|  */ | ||||
| static int Disk_getchar(FILE* Stream) | ||||
| { | ||||
| 	char ReadByte; | ||||
| 	WORD ByteWasRead; | ||||
|  | ||||
| 	if (pf_read(&ReadByte, 1, &ByteWasRead) != FR_OK) | ||||
| 	  return _FDEV_ERR; | ||||
|  | ||||
| 	return (ByteWasRead ? ReadByte : _FDEV_EOF); | ||||
| } | ||||
|  | ||||
| #if defined(USB_CAN_BE_BOTH) | ||||
| /** Event to handle mode changes in the library, to clear the FAT library's drive state structure when transitioning | ||||
|  *  between modes. This ensures that the library always works with current disk data. | ||||
|  */ | ||||
| void EVENT_USB_UIDChange(void) | ||||
| { | ||||
| 	pf_mount(&DiskFATState); | ||||
| } | ||||
| #endif | ||||
|  | ||||
| /** Task to determine if the user is wishes to start the programming sequence, and if so executes the | ||||
|  *  required functions to program the attached target (if any) with the files loaded to the Dataflash. | ||||
|  */ | ||||
| void Programmer_Task(void) | ||||
| { | ||||
| 	static bool HasAttempted = false; | ||||
|  | ||||
| 	if (Buttons_GetStatus() & BUTTONS_BUTTON1) | ||||
| 	{ | ||||
| 		if (!(HasAttempted)) | ||||
| 			HasAttempted = true; | ||||
| 		else | ||||
| 			return; | ||||
|  | ||||
| 		puts("==== PROGRAMMING CYCLE STARTED ====\r\n"); | ||||
|  | ||||
| 		#if defined(USB_CAN_BE_BOTH) | ||||
| 		printf("Using %s Drive...\r\n", (USB_CurrentMode == USB_MODE_Host) ? "External" : "Internal"); | ||||
| 		#endif | ||||
|  | ||||
| 		puts("Reading Configuration File...\r\n"); | ||||
| 		if (!(ProgrammerConfig_ProcessConfiguration())) | ||||
| 		  goto EndOfProgCycle; | ||||
|  | ||||
| 		EndOfProgCycle: | ||||
| 		puts("==== PROGRAMMING CYCLE FINISHED ====\r\n"); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		HasAttempted = 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 (;;) | ||||
| 	{ | ||||
| 		Programmer_Task(); | ||||
|  | ||||
| 		if (USB_CurrentMode == USB_MODE_Host) | ||||
| 		{ | ||||
| 			#if defined(USB_CAN_BE_HOST) | ||||
| 			DiskHost_USBTask(); | ||||
| 			#endif | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			#if defined(USB_CAN_BE_DEVICE) | ||||
| 			DiskDevice_USBTask(); | ||||
| 			#endif | ||||
| 		} | ||||
|  | ||||
| 		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 */ | ||||
| 	#if defined(USB_CAN_BE_BOTH) | ||||
| 	USB_Init(USB_MODE_UID); | ||||
| 	#else | ||||
| 	USB_Init(); | ||||
| 	#endif | ||||
|  | ||||
| 	LEDs_Init(); | ||||
| 	SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_SCK_LEAD_FALLING | SPI_SAMPLE_TRAILING | SPI_MODE_MASTER); | ||||
| 	Dataflash_Init(); | ||||
| 	Buttons_Init(); | ||||
| 	Serial_Init(9600, true); | ||||
|  | ||||
| 	/* Create a stdio stream for the serial port for stdin and stdout */ | ||||
| 	Serial_CreateStream(NULL); | ||||
|  | ||||
| 	#if defined(USB_CAN_BE_DEVICE) | ||||
| 	/* Clear Dataflash sector protections, if enabled */ | ||||
| 	DataflashManager_ResetDataflashProtections(); | ||||
| 	#endif | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user