Moved all source to the trunk directory.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
/** \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.
|
||||
*/
|
||||
|
||||
/** \page Page_BuildLibrary Building as a Linkable Library
|
||||
*
|
||||
* The LUFA library can be built as a proper linkable library (with the extention .a) under AVR-GCC, so that
|
||||
* the library does not need to be recompiled with each revision of a user project. Instructions for creating
|
||||
* a library from a given source tree can be found in the AVR-GCC user manual included in the WinAVR install
|
||||
* /Docs/ directory.
|
||||
*
|
||||
* However, building the library is <b>not recommended</b>, as the static (compile-time) options will be
|
||||
* unable to be changed without a recompilation of the LUFA code. Therefore, if the library is to be built
|
||||
* from the LUFA source, it should be made to be application-specific and compiled with the static options
|
||||
* that are required for each project (which should be recorded along with the library).
|
||||
*
|
||||
* Normal library use has the library components compiled in at the same point as the application code, as
|
||||
* demonstrated in the library demos and applications. This is the preferred method, as the library is recompiled
|
||||
* each time to ensure that all static options for a particular application are applied.
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* This file contains constants which can be passed to the compiler (via setting the macro BOARD) in the
|
||||
* user project makefile using the -D option to configure the library board-specific drivers.
|
||||
*
|
||||
* \note Do not include this file directly, rather include the Common.h header file instead to gain this file's
|
||||
* functionality.
|
||||
*/
|
||||
|
||||
#ifndef __BOARDTYPES_H__
|
||||
#define __BOARDTYPES_H__
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__COMMON_H__)
|
||||
#error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Selects the USBKEY specific board drivers, including Dataflash, Joystick and LED drivers. */
|
||||
#define BOARD_USBKEY 0
|
||||
|
||||
/** Selects the STK525 specific board drivers, including Dataflash, Joystick and LED drivers. */
|
||||
#define BOARD_STK525 1
|
||||
|
||||
/** Selects the STK526 specific board drivers, including Dataflash, Joystick and LED drivers. */
|
||||
#define BOARD_STK526 2
|
||||
|
||||
/** Selects the RZUSBSTICK specific board drivers, including the driver for the boards LEDs. */
|
||||
#define BOARD_RZUSBSTICK 3
|
||||
|
||||
/** Selects the ATAVRUSBRF01 specific board drivers, including the driver for the board LEDs. */
|
||||
#define BOARD_ATAVRUSBRF01 4
|
||||
|
||||
/** Selects the user-defined board drivers, which should be placed in the user project's folder
|
||||
* under a directory named /Board/. Each board driver should be named identically to the LUFA
|
||||
* master board driver (i.e., driver in the LUFA/Drivers/Board director) so that the library
|
||||
* can correctly identify it.
|
||||
*/
|
||||
#define BOARD_USER 5
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* This file contains macros for the embedding of compile-time strings into the resultant project binary for
|
||||
* identification purposes. It is designed to prefix "tags" with the magic string of "@(#)" so that the tags
|
||||
* can easily be identified in the binary data.
|
||||
*
|
||||
* These tags are compatible with the ButtLoad project at http://www.fourwalledcubicle.com/ButtLoad.php .
|
||||
*/
|
||||
|
||||
#ifndef __BUTTLOADTAG_H__
|
||||
#define __BUTTLOADTAG_H__
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Creates a new tag in the resultant binary, containing the specified data array. The macro id
|
||||
* parameter is only for identification purposes (so that the tag data can be referenced in code)
|
||||
* and is not visible in the compiled binary.
|
||||
*/
|
||||
#define BUTTLOADTAG(id, data) const struct ButtLoadTagData BUTTTAG_##id \
|
||||
PROGMEM __attribute__((used, externally_visible)) = \
|
||||
{MagicString: BT_TAGHEADER, TagData: data}
|
||||
|
||||
/** Macro for retrieving a reference to the specified tag's contents. The tag data is located in
|
||||
* the program memory (FLASH) space, and so must be read out with the macros in avr-libc which
|
||||
* deal with embedded data.
|
||||
*/
|
||||
#define BUTTLOADTAG_DATA(id) BUTTTAG_##id.TagData
|
||||
|
||||
/* Structures: */
|
||||
/** Structure for ButtLoad compatible binary tags. */
|
||||
struct ButtLoadTagData
|
||||
{
|
||||
char MagicString[4]; /**< Magic tag header, containing the string "@(#)". */
|
||||
char TagData[]; /**< Tag contents as a char array. */
|
||||
};
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Macros: */
|
||||
#define BT_TAGHEADER {'@','(','#',')'}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* This file contains macros which are common to all library elements, and which may be useful in user code. It
|
||||
* also includes other common headees, such as Atomic.h, FunctionAttributes.h and BoardTypes.h.
|
||||
*/
|
||||
|
||||
#ifndef __COMMON_H__
|
||||
#define __COMMON_H__
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <stdio.h>
|
||||
#include <avr/version.h>
|
||||
|
||||
#include "FunctionAttributes.h"
|
||||
#include "BoardTypes.h"
|
||||
|
||||
#include <alloca.h>
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Macro for encasing other multi-statment macros. This should be used along with an opening brace
|
||||
* before the start of any multi-statement macro, so that the macros contents as a whole are treated
|
||||
* as a discreete block and not as a list of seperate statements which may cause problems when used as
|
||||
* a block (such as inline IF statments).
|
||||
*/
|
||||
#define MACROS do
|
||||
|
||||
/** Macro for encasing other multi-statment macros. This should be used along with a preceeding closing
|
||||
* brace at the end of any multi-statement macro, so that the macros contents as a whole are treated
|
||||
* as a discreete block and not as a list of seperate statements which may cause problems when used as
|
||||
* a block (such as inline IF statments).
|
||||
*/
|
||||
#define MACROE while (0)
|
||||
|
||||
/** Defines a volatile NOP statment which cannot be optimized out by the compiler, and thus can always
|
||||
* be set as a breakpoint in the resulting code. Useful for debugging purposes, where the optimizer
|
||||
* removes/reorders code to the point where break points cannot reliably be set.
|
||||
*/
|
||||
#define JTAG_DEBUG_POINT() asm volatile ("NOP" ::)
|
||||
|
||||
/** Defines an explicit JTAG break point in the resulting binary via the ASM BREAK statment. When
|
||||
* a JTAG is used, this causes the program execution to halt when reached until manually resumed. */
|
||||
#define JTAG_DEBUG_BREAK() asm volatile ("BREAK" ::)
|
||||
|
||||
/** Macro for testing condition "x" and breaking via JTAG_DEBUG_BREAK() if the condition is false. */
|
||||
#define JTAG_DEBUG_ASSERT(x) MACROS{ if (!(x)) { JTAG_DEBUG_BREAK(); } }MACROE
|
||||
|
||||
/** Macro for testing condition "x" and writing debug data to the serial stream if false. As a
|
||||
* prerequisite for this macro, the serial stream should be configured via the Serial_Stream driver.
|
||||
*
|
||||
* The serial output takes the form "{FILENAME}: Function {FUNCTION NAME}, Line {LINE NUMBER}: Assertion
|
||||
* {x} failed."
|
||||
*/
|
||||
#define SERIAL_STREAM_ASSERT(x) MACROS{ if (!(x)) { printf_P(PSTR("%s: Function \"%s\", Line %d: " \
|
||||
"Assertion \"%s\" failed.\r\n"), \
|
||||
__FILE__, __func__, __LINE__, #x); \
|
||||
} }MACROE
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Function for reliably setting the AVR's system clock prescaler, using inline assembly. This function
|
||||
* is guaranteed to operate reliably regardless of optimization setting or other compile time options.
|
||||
*
|
||||
* \param PrescalerMask The mask of the new prescaler setting for CLKPR
|
||||
*/
|
||||
static inline void SetSystemClockPrescaler(uint8_t PrescalerMask)
|
||||
{
|
||||
uint8_t tmp = (1 << 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" (PrescalerMask)
|
||||
: "r0");
|
||||
}
|
||||
|
||||
/** Function to reverse the individual bits in a byte - i.e. bit 7 is moved to bit 0, bit 6 to bit 1,
|
||||
* etc.
|
||||
*
|
||||
* \param Byte Byte of data whose bits are to be reversed
|
||||
*/
|
||||
static inline uint8_t BitReverse(uint8_t Byte) ATTR_WARN_UNUSED_RESULT ATTR_CONST;
|
||||
static inline uint8_t BitReverse(uint8_t Byte)
|
||||
{
|
||||
Byte = (((Byte & 0xF0) >> 4) | ((Byte & 0x0F) << 4));
|
||||
Byte = (((Byte & 0xCC) >> 2) | ((Byte & 0x33) << 2));
|
||||
Byte = (((Byte & 0xAA) >> 1) | ((Byte & 0x55) << 1));
|
||||
|
||||
return Byte;
|
||||
}
|
||||
|
||||
/** Function to reverse the byte ordering of the individual bytes in a 16 bit number.
|
||||
*
|
||||
* \param Word Word of data whose bytes are to be swapped
|
||||
*/
|
||||
static inline uint16_t SwapEndian_16(uint16_t Word) ATTR_WARN_UNUSED_RESULT ATTR_CONST;
|
||||
static inline uint16_t SwapEndian_16(uint16_t Word)
|
||||
{
|
||||
return ((Word >> 8) | (Word << 8));
|
||||
}
|
||||
|
||||
/** Function to reverse the byte ordering of the individual bytes in a 32 bit number.
|
||||
*
|
||||
* \param DWord Double word of data whose bytes are to be swapped
|
||||
*/
|
||||
static inline uint32_t SwapEndian_32(uint32_t DWord) ATTR_WARN_UNUSED_RESULT ATTR_CONST;
|
||||
static inline uint32_t SwapEndian_32(uint32_t DWord)
|
||||
{
|
||||
return (((DWord & 0xFF000000) >> 24) |
|
||||
((DWord & 0x00FF0000) >> 8) |
|
||||
((DWord & 0x0000FF00) << 8) |
|
||||
((DWord & 0x000000FF) << 24));
|
||||
}
|
||||
|
||||
/** Function to reverse the byte ordering of the individual bytes in a n byte number.
|
||||
*
|
||||
* \param Data Pointer to a number containing an even number of bytes to be reversed
|
||||
* \param Bytes Length of the data in bytes
|
||||
*/
|
||||
static inline void SwapEndian_n(uint8_t* Data, uint8_t Bytes);
|
||||
static inline void SwapEndian_n(uint8_t* Data, uint8_t Bytes)
|
||||
{
|
||||
uint8_t Temp;
|
||||
|
||||
while (Bytes)
|
||||
{
|
||||
Temp = *Data;
|
||||
*Data = *(Data + Bytes - 1);
|
||||
*(Data + Bytes) = Temp;
|
||||
|
||||
Data++;
|
||||
Bytes -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* This file contains macros for applying GCC specific attributes to functions to control various optimizer
|
||||
* and code generation features of the compiler. Attributes may be placed in the function prototype in any
|
||||
* order, and multiple attributes can be specified for a single function via a space seperated list.
|
||||
*
|
||||
* \note Do not include this file directly, rather include the Common.h header file instead to gain this file's
|
||||
* functionality.
|
||||
*/
|
||||
|
||||
#ifndef __FUNCATTR_H__
|
||||
#define __FUNCATTR_H__
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(__COMMON_H__)
|
||||
#error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Indicates to the compiler that the function can not ever return, so that any stack restoring or
|
||||
* return code may be ommited by the compiler in the resulting binary.
|
||||
*/
|
||||
#define ATTR_NO_RETURN __attribute__ ((noreturn))
|
||||
|
||||
/** Places the function in one of the initilization sections, which execute before the main function
|
||||
* of the application. The init function number can be specified as "x", as an integer. Refer to the
|
||||
* avr-libc manual for more information on the initialization sections.
|
||||
*/
|
||||
#define ATTR_INIT_SECTION(x) __attribute__ ((naked, section (".init" #x )))
|
||||
|
||||
/** Indicates that the function returns a value which should not be ignored by the user code. When
|
||||
* applied, any ignored return value from calling the function will produce a compiler warning.
|
||||
*/
|
||||
#define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))
|
||||
|
||||
/** Indicates that the specified parameters of the function are pointers which should never be NULL.
|
||||
* When applied as a 1-based comma seperated list the compiler will emmit a warning if the specified
|
||||
* parameters are known at compiler time to be NULL at the point of calling the function.
|
||||
*/
|
||||
#define ATTR_NON_NULL_PTR_ARG(...) __attribute__ ((nonnull (__VA_ARGS__)))
|
||||
|
||||
/** Removes any preample or postample from the function. When used, the function will not have any
|
||||
* register or stack saving code. This should be used with caution, and when used the programmer
|
||||
* is responsible for maintaining stack and register integrity.
|
||||
*/
|
||||
#define ATTR_NAKED __attribute__ ((naked))
|
||||
|
||||
/** Prevents the compiler from considering a specified function for inlining. When applied, the given
|
||||
* function will not be inlined under any circumstances.
|
||||
*/
|
||||
#define ATTR_NOINLINE __attribute__ ((noinline))
|
||||
|
||||
/** Forces the compiler to inline the specified function. When applied, the given function will be
|
||||
* inlined under all circumstances.
|
||||
*/
|
||||
#define ATTR_ALWAYSINLINE __attribute__ ((always_inline))
|
||||
|
||||
/** Indicates that the specified function is pure, in that it has no side-effects other than global
|
||||
* or parameter variable access.
|
||||
*/
|
||||
#define ATTR_PURE __attribute__ ((pure))
|
||||
|
||||
/** Indicates that the specified function is constant, in that it has no side effects other than
|
||||
* parameter access.
|
||||
*/
|
||||
#define ATTR_CONST __attribute__ ((const))
|
||||
|
||||
/** Marks a given function as deprecated, which produces a warning if the function is called. */
|
||||
#define ATTR_DEPRECATED __attribute__ ((deprecated))
|
||||
|
||||
/** Marks a function as a weak reference, which can be overridden by other functions with an
|
||||
* identical name (in which case the weak reference is discarded at link time).
|
||||
*/
|
||||
#define ATTR_WEAK __attribute__ ((weak))
|
||||
|
||||
/** Marks a function as an alias for another function of name "x". */
|
||||
#define ATTR_ALIAS(x) __attribute__ ((alias( #x )))
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,167 @@
|
||||
/** \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.
|
||||
*/
|
||||
|
||||
/** \page TokenSummary Summary of Compile Tokens
|
||||
*
|
||||
* The following lists all the possible tokens which can be defined in a project makefile, and passed to the
|
||||
* compiler via the -D switch, to alter the LUFA library code. These tokens may alter the library behaviour,
|
||||
* or remove features unused by a given application in order to save flash space.
|
||||
*
|
||||
* \section Sec_SummaryNonUSBTokens Non USB Related Tokens
|
||||
* This section describes compile tokens which affect non-USB sections of the LUFA library.
|
||||
*
|
||||
* <b>DISABLE_TERMINAL_CODES</b> - TerminalCodes.h \n
|
||||
* If an application contains ANSI terminal control codes listed in TerminalCodes.h, it might be desired to remove them
|
||||
* at compile time for use with a terminal which is non-ANSI control code aware, without modifying the source code. If
|
||||
* this token is defined, all ANSI control codes in the application code from the TerminalCodes.h header are removed from
|
||||
* the source code at compile time.
|
||||
*
|
||||
* <b>NUM_BLOCKS</b> - DynAlloc.h \n
|
||||
* Sets the number of allocable blocks in the psudo-heap of the dynamic memory allocation driver. This should be
|
||||
* defined as a constant larger than zero.
|
||||
*
|
||||
* <b>BLOCK_SIZE</b> - DynAlloc.h \n
|
||||
* Sets the size of each allocable block in the psudo-heap of the dynamic memory allocation driver. This should be
|
||||
* defined as a constant larger than zero.
|
||||
*
|
||||
* <b>NUM_HANDLES</b> - DynAlloc.h \n
|
||||
* Sets the maximum number of managed memory handles which can be handed out by the dynamic memory allocation driver
|
||||
* simultaneously, before a handle (and its associated allocated memory) must be freed.
|
||||
*
|
||||
* \section Sec_SummaryUSBClassTokens USB Class Driver Related Tokens
|
||||
* This section describes compile tokens which affect USB class-specific drivers in the LUFA library.
|
||||
*
|
||||
* <b>HID_ENABLE_FEATURE_PROCESSING</b> - HIDParser.h \n
|
||||
* Define this token to enable the processing of FEATURE HID report items, if any, into the processed HID structure.
|
||||
* By default FEATURE items (which are device features settable by the host but not directly visible by the user) are
|
||||
* skipped when processing a device HID report.
|
||||
*
|
||||
* <b>HID_INCLUDE_CONSTANT_DATA_ITEMS</b> - HIDParser.h \n
|
||||
* By default, constant data items (usually used as spacers to align seperate report items to a byte or word boundary)
|
||||
* in the HID report are skipped during report processing. It is highly unusual for an application to make any use of
|
||||
* constant data items (as they do not carry any useful data and only occupy limited RAM) however if required defining
|
||||
* this switch will put constant data items into the processed HID report structure.
|
||||
*
|
||||
* <b>HID_STATETABLE_STACK_DEPTH</b> - HIDParser.h \n
|
||||
* HID reports may contain PUSH and POP elements, to store and retrieve the current HID state table onto a stack. This
|
||||
* allows for reports to save the state table before modifying it slightly for a data item, and then restore the previous
|
||||
* state table in a compact manner. This token may be defined to a non-zero value to give the maximum depth of the state
|
||||
* table stack. If not defined, this defaults to the value indicated in the HID.h file documentation.
|
||||
*
|
||||
* <b>HID_USAGE_STACK_DEPTH</b> - HIDParser.h \n
|
||||
* HID reports generally contain many USAGE elements, which are assigned to INPUT, OUTPUT and FEATURE items in succession
|
||||
* when multiple items are defined at once (via REPORT COUNT elements). This allows for several items to be defined with
|
||||
* different usages in a compact manner. This token may be defined to a non-zero value to set the maximum depth of the
|
||||
* usage stack, indicating the maximum number of USAGE items which can be stored tempoarily until the next INPUT, OUTPUT
|
||||
* and FEATURE item. If not defined, this defaults to the value indicated in the HID.h file documentation.
|
||||
*
|
||||
* <b>HID_MAX_COLLECTIONS</b> - HIDParser.h \n
|
||||
* HID reports generally contain several COLLECTION elements, used to group related data items together. Collection information
|
||||
* is stored seperately in the processed usage structure (and referred to by the data elements in the structure) to save space.
|
||||
* This token may be defined to a non-zero value to set the maximum number of COLLECTION items which can be processed by the
|
||||
* parser into the resultant processed report structure. If not defined, this defaults to the value indicated in the HID.h file
|
||||
* documentation.
|
||||
*
|
||||
* <b>HID_MAX_REPORTITEMS</b> - HIDParser.h \n
|
||||
* All HID reports contain one or more INPUT, OUTPUT and/or FEATURE items describing the data which can be sent to and from the HID
|
||||
* device. Each item has associated usages, bit offsets in the item reports and other associated data indicating the manner in which
|
||||
* the report data should be interpreted by the host. This token may be defined to a non-zero value to set the maximum number of
|
||||
* data elements which can be stored in the processed HID report strucuture, including INPUT, OUTPUT and (if enabled) FEATURE items.
|
||||
* If a item has a multiple count (i.e. a REPORT COUNT of more than 1), each item in the report count is placed seperately in the
|
||||
* processed HID report table. If not defined, this defaults to the value indicated in the HID.h file documentation.
|
||||
*
|
||||
* \section Sec_SummaryUSBTokens USB Driver Related Tokens
|
||||
* This section describes compile tokens which affect USB driver stack as a whole in the LUFA library.
|
||||
*
|
||||
* <b>USE_RAM_DESCRIPTORS</b> - StdDescriptors.h \n
|
||||
* Define this token to indicate to the USB driver that device descriptors are stored in RAM, rather than the default of
|
||||
* the AVR's flash. RAM descriptors may be desirable in applications where speed or minimizing flash usage is more important
|
||||
* than RAM usage, or applications where the descriptors need to be modified at runtime.
|
||||
*
|
||||
* <b>USE_EEPROM_DESCRIPTORS</b> - StdDescriptors.h \n
|
||||
* Similar to USE_RAM_DESCRIPTORS, but descriptors are stored in the AVR's EEPROM memory rather than RAM.
|
||||
*
|
||||
* <b>USE_NONSTANDARD_DESCRIPTOR_NAMES</b> - StdDescriptors.h \n
|
||||
* The USB 2.0 standard gives some rather obscure names for the elements in the standard descriptor types (device, configuration,
|
||||
* string, endpoint, etc.). By default the LUFA library uses these names in its predefined descriptor structure types for
|
||||
* compatibility. If this token is defined, the structure element names are switched to the LUFA-specific but more descriptive
|
||||
* names documented in the StdDescriptors.h source file.
|
||||
*
|
||||
* <b>FIXED_CONTROL_ENDPOINT_SIZE</b> - Endpoint.h \n
|
||||
* By default, the library determines the size of the control endpoint (when in device mode) by reading the device descriptor.
|
||||
* Normally this reduces the amount of configuration required for the library, allows the value to change dynamically (if
|
||||
* descriptors are stored in EEPROM or RAM rather than flash memory) and reduces code maintenance. However, this token can be
|
||||
* defined to a non-zero value instead to give the size in bytes of the control endpoint, to reduce the size of the compiled
|
||||
* binary at the expense of flexibility.
|
||||
*
|
||||
* <b>STATIC_ENDPOINT_CONFIGURATION</b> - Endpoint.h \n
|
||||
* By default, the endpoint configuration routine is designed to accept dynamic inputs, so that the endpoints can be configured
|
||||
* using variable values known only at runtime. This allows for a great deal of flexibility, however uses a small amount of binary
|
||||
* space which may be wasted if all endpoint configurations are static and known at compile time. Define this token via the -D switch
|
||||
* to optimize the endpoint configuration routine for constant inputs, to reduce the size of the compiled binary at the expense of
|
||||
* flexibility. Note that with this option dynamic values may still be used, but will result in many times more code to be generated than
|
||||
* if the option was disabled. This is designed to be used only if the FIXED_CONTROL_ENDPOINT_SIZE option is also used.
|
||||
*
|
||||
* <b>USE_SINGLE_DEVICE_CONFIGURATION</b> - DevChapter9.h \n
|
||||
* By default, the library determines the number of configurations a USB device supports by reading the device descriptor. This reduces
|
||||
* the amount of configuration required to set up the library, and allows the value to change dynamically (if descriptors are stored in
|
||||
* EEPROM or RAM rather than flash memory) and reduces code maintenance. However, many USB device projects use only a single configuration.
|
||||
* Defining this token enables single-configuration mode, reducing the compiled size of the binary at the expense of flexibility.
|
||||
*
|
||||
* <b>NO_CLEARSET_FEATURE_REQUEST</b> - DevChapter9.h \n
|
||||
* In some limited USB device applications, the Get Feature and Set Feature requests are not used - this is when the device does not have
|
||||
* device level features (such as remote wakeup) nor any data endpoints beyond the mandatory control endpoint. In such limited situations,
|
||||
* this token may be defined to remove the handling of the Get Feature and Set Feature Chapter 9 requests to save space. Generally, this
|
||||
* is usually only useful in (some) bootloaders.
|
||||
*
|
||||
* <b>NO_STREAM_CALLBACKS</b> - Endpoint.h, Pipe.h \n
|
||||
* Both the endpoint and the pipe driver code contains stream functions, allowing for arrays of data to be sent to or from the
|
||||
* host easily via a single function call (rather than complex routines worrying about sending full packets, waiting for the endpoint/
|
||||
* pipe to become ready, etc.). By default, these stream functions require a callback function which is executed after each byte processed,
|
||||
* allowing for early-aborts of stream transfers by the application. If callbacks are not required in an application, they can be removed
|
||||
* by defining this token, reducing the compiled binary size. When removed, the stream functions no longer accept a callback function as
|
||||
* a parameter.
|
||||
*
|
||||
* <b>USB_HOST_TIMEOUT_MS</b> - Host.h \n
|
||||
* When a control transfer is initiated in host mode to an attached device, a timeout is used to abort the transfer if the attached
|
||||
* device fails to respond within the timeout period. This token may be defined to a non-zero value to set the timeout period for
|
||||
* control transfers, specified in milliseconds. If not defined, the default value specified in Host.h is used instead.
|
||||
*
|
||||
* <b>HOST_DEVICE_SETTLE_DELAY_MS</b> - Host.h \n
|
||||
* Some devices require a delay of up to 5 seconds after they are connected to VBUS before the enumeration process can be started, or
|
||||
* they will fail to enumerate correctly. By placing a delay before the enumeration process, it can be ensured that the bus has settled
|
||||
* back to a known idle state before communications occur with the device. This token may be defined to a non-zero value to set the
|
||||
* device settle period, specified in milliseconds. If not defined, the default value specified in Host.h is used instead.
|
||||
*
|
||||
* <b>USE_STATIC_OPTIONS</b> - LowLevel.h \n
|
||||
* By default, the USB_Init() function accepts dynamic options at runtime to alter the library behaviour, including whether the USB pad
|
||||
* voltage regulator is enabled, and the device speed when in device mode. By defining this token to a mask comprised of the USB options
|
||||
* mask defines usually passed as the Options parameter to USB_Init(), the resulting compiled binary can be decreased in size by removing
|
||||
* the dynamic options code, and replacing it with the statically set options. When defined, the USB_Init() function no longer accepts an
|
||||
* Options parameter.
|
||||
*
|
||||
* <b>USB_DEVICE_ONLY</b> - LowLevel.h \n
|
||||
* For the USB AVR models supporting both device and host USB modes, the USB_Init() function contains a Mode parameter which specifies the
|
||||
* mode the library should be initialized to. If only device mode is required, the code for USB host mode can be removed from the binary to
|
||||
* save space. When defined, the USB_Init() function no longer accepts a Mode parameter. This define is irrelevent on smaller USB AVRs which
|
||||
* do not support host mode.
|
||||
*
|
||||
* <b>USB_HOST_ONLY</b> - LowLevel.h \n
|
||||
* Same as USB_DEVICE_ONLY, except the library is fixed to USB host mode rather than USB device mode. Not available on some USB AVR models.
|
||||
*
|
||||
* <b>USB_STREAM_TIMEOUT_MS</b> - LowLevel.h \n
|
||||
* When endpoint and/or pipe stream functions are used, by default there is a timeout between each transfer which the connected device or host
|
||||
* must satisfy, or the stream function aborts the remaining data transfer. This token may be defined to a non-zero value to set the timeout
|
||||
* period for stream transfers, specified in milliseconds. If not defined, the default value specified in LowLevel.h is used instead.
|
||||
*
|
||||
* <b>NO_LIMITED_CONTROLLER_CONNECT</b> - Events.h \n
|
||||
* On the smaller USB AVRs, the USB controller lacks VBUS events to determine the physical connection state of the USB bus to a host. In lieu of
|
||||
* VBUS events, the library attempts to determine the connection state via the bus suspension and wake up events instead. This however may be
|
||||
* slightly inaccurate due to the possibility of the host suspending the bus while the device is still connected. If accurate connection status is
|
||||
* required, the VBUS line of the USB connector should be routed to an AVR pin to detect its level, so that the USB_IsConnected global
|
||||
* can be accurately set and the USB_Connect and USB_Disconnect events manually raised by the RAISE_EVENT macro. When defined, this token disables
|
||||
* the library's auto-detection of the connection state by the aformentioned suspension and wake up events.
|
||||
*/
|
||||
@@ -0,0 +1,119 @@
|
||||
/** \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.
|
||||
*/
|
||||
|
||||
/** \dir Common
|
||||
* \brief Common library header files.
|
||||
*
|
||||
* This folder contains header files which are common to all parts of the LUFA library. They may be used freely in
|
||||
* user applications.
|
||||
*
|
||||
* \dir MemoryAllocator
|
||||
* \brief Auto-defragmenting dynamic memory allocation library.
|
||||
*
|
||||
* This folder contains a simple handle-based dynamic memory allocation library, capable of handing out memory in
|
||||
* block chunks. As new memory is allocated, the library will defragment the already allocated memory to ensure
|
||||
* optimal memory usage. It is not used within the LUFA library, and is provided as a convenience for user applications.
|
||||
*
|
||||
* \dir Scheduler
|
||||
* \brief Simple round-robbin scheduler.
|
||||
*
|
||||
* This folder contains the simple LUFA round-robbin scheduler, provided as a convenience for user applications. It
|
||||
* is very simple in design, and is intended to make code easier to read, rather than providing a complete RTOS kernel.
|
||||
*
|
||||
* \dir Drivers
|
||||
* \brief Library hardware and software drivers.
|
||||
*
|
||||
* This folder contains all the library hardware and software drivers for each supported board and USB AVR
|
||||
* microcontroller model.
|
||||
*
|
||||
* \dir Drivers/Misc
|
||||
* \brief Miscellaneous driver files.
|
||||
*
|
||||
* This folder contains drivers for aspects other than the USB interface, board hardware or AVR peripherals.
|
||||
*
|
||||
* \dir Drivers/AT90USBXXX
|
||||
* \brief USB AVR peripheral driver files.
|
||||
*
|
||||
* This folder contains drivers for several of the AVR internal peripherals such as the USART, compatible with
|
||||
* all USB AVR models.
|
||||
*
|
||||
* \dir Drivers/AT90USBXXX/AT90USBXXX67
|
||||
* \brief AT90USBXXX6, AT90USBXXX7 and ATMEGAXXU4 AVR model peripheral driver files. Its original name is due to legacy
|
||||
* reasons.
|
||||
*
|
||||
* This folder contains drivers for several of the AVR internal peripherals such as the USART, compatible only with
|
||||
* the AT90USBXXX6, AT90USBXXX7 and ATMEGAXXU4 USB AVR models, such as the AT90USB1287. Its contents should <b>not</b> be
|
||||
* included by the user application - the dispatch header file located in the parent AT90USBXXX directory should be used
|
||||
* instead.
|
||||
*
|
||||
* \dir Drivers/USB
|
||||
* \brief USB controller peripheral driver files.
|
||||
*
|
||||
* This folder contains the main header files required to implement the USB interface in the USB supporting AVR models.
|
||||
* The header files contained directly in this folder should be included in the user application in order to gain USB
|
||||
* functionality, and the appropriate C source files in the LowLevel and HighLevel driver folders added to the compile
|
||||
* and link stages.
|
||||
*
|
||||
* \dir Drivers/USB/LowLevel
|
||||
* \brief Low level USB driver files.
|
||||
*
|
||||
* This folder contains low level USB driver source files required to implement USB functionality on the USB AVR microcontrollers.
|
||||
*
|
||||
* \dir Drivers/USB/HighLevel
|
||||
* \brief High level USB driver files.
|
||||
*
|
||||
* This folder contains high level USB driver source files required to implement USB functionality on the USB AVR microcontrollers.
|
||||
*
|
||||
* \dir Drivers/USB/Class
|
||||
* \brief USB Class helper driver files.
|
||||
*
|
||||
* This folder contains drivers for implementing functionality of standardized USB classes. These are not used directly by the library,
|
||||
* but provide a standard and library-maintained way of implementing functionality from some of the defined USB classes without extensive
|
||||
* development effort. Is is recommended that these drivers be used where possible to reduce maintenance of user applications.
|
||||
*
|
||||
* \dir Drivers/Board
|
||||
* \brief Board hardware driver files.
|
||||
*
|
||||
* This folder contains drivers for interfacing with the physical hardware on supported commercial boards, primarily from
|
||||
* the Atmel corporation. Header files in this folder should be included in user applications requring the functionality of
|
||||
* hardware placed on supported boards.
|
||||
*
|
||||
* \dir Drivers/Board/USBKEY
|
||||
* \brief USBKEY board hardware driver files.
|
||||
*
|
||||
* This folder contains drivers for hardware on the Atmel USBKEY demonstration board. The header files in this folder should
|
||||
* not be included directly in user applications; the similarly named dispatch header files located in the parent Board directory
|
||||
* should be included instead.
|
||||
*
|
||||
* \dir Drivers/Board/STK526
|
||||
* \brief STK526 board hardware driver files.
|
||||
*
|
||||
* This folder contains drivers for hardware on the Atmel STK526 development board. The header files in this folder should
|
||||
* not be included directly in user applications; the similarly named dispatch header files located in the parent Board directory
|
||||
* should be included instead.
|
||||
*
|
||||
* \dir Drivers/Board/STK525
|
||||
* \brief STK525 board hardware driver files.
|
||||
*
|
||||
* This folder contains drivers for hardware on the Atmel STK525 development board. The header files in this folder should
|
||||
* not be included directly in user applications; the similarly named dispatch header files located in the parent Board directory
|
||||
* should be included instead.
|
||||
*
|
||||
* \dir Drivers/Board/RZUSBSTICK
|
||||
* \brief RZUSBSTICK board hardware driver files.
|
||||
*
|
||||
* This folder contains drivers for hardware on the Atmel RZUSBSTICK board, as used in the Atmel "Raven" wireless kits. The header
|
||||
* files in this folder should not be included directly in user applications; the similarly named dispatch header files located in
|
||||
* the parent Board directory should be included instead.
|
||||
*
|
||||
* \dir DriverStubs
|
||||
* \brief Driver stub header files for custom boards, to allow the LUFA board drivers to operate.
|
||||
*
|
||||
* This contains stub files for the LUFA board drivers. If the LUFA board drivers are used with board hardare other than those
|
||||
* directly supported by the library, the BOARD parameter of the application's makefile can be set to "USER", and these stub files
|
||||
* copied to the "/Board/" directory of the application's folder. When fleshed out with working driver code for the custom board,
|
||||
* the corresponding LUFA board APIs will work correctly with the non-standard board hardware.
|
||||
*/
|
||||
+1485
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
This is a stub driver header file, for implementing custom board
|
||||
layout hardware with compatible LUFA board specific drivers. If
|
||||
the library is configured to use the BOARD_USER board mode, this
|
||||
driver file should be completed and copied into the "/Board/" folder
|
||||
inside the application's folder.
|
||||
|
||||
This stub is for the board-specific component of the LUFA Dataflash
|
||||
driver.
|
||||
*/
|
||||
|
||||
#ifndef __DATAFLASH_USER_H__
|
||||
#define __DATAFLASH_USER_H__
|
||||
|
||||
/* Includes: */
|
||||
// TODO: Add any required includes here
|
||||
|
||||
/* 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 // TODO: Replace this with a mask of all the /CS pins of all dataflashes
|
||||
#define DATAFLASH_CHIPCS_DDR // TODO: Replace with the DDR register name for the board's Dataflash ICs
|
||||
#define DATAFLASH_CHIPCS_PORT // TODO: Replace with the PORT register name for the board's Dataflash ICs
|
||||
#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 // TODO: Replace with the number of dataflashes on the board, max 2
|
||||
|
||||
/** Mask for no dataflash chip selected. */
|
||||
#define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK
|
||||
|
||||
/** Mask for the first dataflash chip selected. */
|
||||
#define DATAFLASH_CHIP1 // TODO: Replace with mask to select the first Dataflash chip
|
||||
|
||||
/** Mask for the second dataflash chip selected. */
|
||||
#define DATAFLASH_CHIP2 // TODO: Replace with mask to select the second Dataflash chip, if available
|
||||
|
||||
/** Internal main memory page size for the board's dataflash ICs. */
|
||||
#define DATAFLASH_PAGE_SIZE // TODO: Replace with the page size for the Dataflash ICs
|
||||
|
||||
/** Total number of pages inside each of the board's dataflash ICs. */
|
||||
#define DATAFLASH_PAGES // TODO: Replace with the total number of pages inside one of the Dataflash ICs
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
This is a stub driver header file, for implementing custom board
|
||||
layout hardware with compatible LUFA board specific drivers. If
|
||||
the library is configured to use the BOARD_USER board mode, this
|
||||
driver file should be completed and copied into the "/Board/" folder
|
||||
inside the application's folder.
|
||||
|
||||
This stub is for the board-specific component of the LUFA HWB (Hardware
|
||||
Button, a physical button on most Atmel USB boards) driver. This could
|
||||
alternately be driven from any button connected to the USB AVR.
|
||||
*/
|
||||
|
||||
#ifndef __HWB_USER_H__
|
||||
#define __HWB_USER_H__
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
// TODO: Add any required includes here
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(INCLUDE_FROM_HWB_H)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/Board/HWB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Inline Functions: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
static inline void HWB_Init(void)
|
||||
{
|
||||
// TODO: Initialize the appropriate port pin as an input here, with pullup
|
||||
}
|
||||
|
||||
static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool HWB_GetStatus(void)
|
||||
{
|
||||
// TODO: Return current button status here, debounced if required
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
This is a stub driver header file, for implementing custom board
|
||||
layout hardware with compatible LUFA board specific drivers. If
|
||||
the library is configured to use the BOARD_USER board mode, this
|
||||
driver file should be completed and copied into the "/Board/" folder
|
||||
inside the application's folder.
|
||||
|
||||
This stub is for the board-specific component of the LUFA Joystick
|
||||
driver, a small surface mount four-way (plus button) digital joystick
|
||||
on most USB AVR boards.
|
||||
*/
|
||||
|
||||
#ifndef __JOYSTICK_USER_H__
|
||||
#define __JOYSTICK_USER_H__
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
// TODO: Add any required includes here
|
||||
|
||||
/* 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
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Mask for the joystick being pushed in the left direction. */
|
||||
#define JOY_LEFT // TODO: Add mask to indicate joystick left position here
|
||||
|
||||
/** Mask for the joystick being pushed in the right direction. */
|
||||
#define JOY_RIGHT // TODO: Add mask to indicate joystick right position here
|
||||
|
||||
/** Mask for the joystick being pushed in the upward direction. */
|
||||
#define JOY_UP // TODO: Add mask to indicate joystick up position here
|
||||
|
||||
/** Mask for the joystick being pushed in the downward direction. */
|
||||
#define JOY_DOWN // TODO: Add mask to indicate joystick down position here
|
||||
|
||||
/** Mask for the joystick being pushed inward. */
|
||||
#define JOY_PRESS // TODO: Add mask to indicate joystick pressed position here
|
||||
|
||||
/* Inline Functions: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
static inline void Joystick_Init(void)
|
||||
{
|
||||
// TODO: Initialize joystick port pins as inputs with pullups
|
||||
};
|
||||
|
||||
static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint8_t Joystick_GetStatus(void)
|
||||
{
|
||||
// TODO: Return current joystick position data which can be obtained by masking against the JOY_* macros
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
This is a stub driver header file, for implementing custom board
|
||||
layout hardware with compatible LUFA board specific drivers. If
|
||||
the library is configured to use the BOARD_USER board mode, this
|
||||
driver file should be completed and copied into the "/Board/" folder
|
||||
inside the application's folder.
|
||||
|
||||
This stub is for the board-specific component of the LUFA LEDs driver,
|
||||
for the LEDs (up to four) mounted on most USB AVR boards.
|
||||
*/
|
||||
|
||||
#ifndef __LEDS_USER_H__
|
||||
#define __LEDS_USER_H__
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
// TODO: Add any required includes here
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(INCLUDE_FROM_LEDS_H)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** LED mask for the first LED on the board. */
|
||||
#define LEDS_LED1 // TODO: Add mask for first board LED here
|
||||
|
||||
/** LED mask for the second LED on the board. */
|
||||
#define LEDS_LED2 // TODO: Add mask for second board LED here
|
||||
|
||||
/** LED mask for the third LED on the board. */
|
||||
#define LEDS_LED3 // TODO: Add mask for third board LED here
|
||||
|
||||
/** LED mask for the fourth LED on the board. */
|
||||
#define LEDS_LED4 // TODO: Add mask for fourth board LED here
|
||||
|
||||
/** LED mask for all the LEDs on the board. */
|
||||
#define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)
|
||||
|
||||
/** LED mask for the none of the board LEDs */
|
||||
#define LEDS_NO_LEDS 0
|
||||
|
||||
/* Inline Functions: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
static inline void LEDs_Init(void)
|
||||
{
|
||||
// TODO: Add code to initialize LED port pins as outputs here
|
||||
}
|
||||
|
||||
static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)
|
||||
{
|
||||
// TODO: Add code to turn on LEDs given in the LedMask mask here, leave others as-is
|
||||
}
|
||||
|
||||
static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)
|
||||
{
|
||||
// TODO: Add code to turn off LEDs given in the LedMask mask here, leave others as-is
|
||||
}
|
||||
|
||||
static inline void LEDs_SetAllLEDs(const uint8_t LedMask)
|
||||
{
|
||||
// TODO: Add code to turn on only LEDs given in the LedMask mask here, all others off
|
||||
}
|
||||
|
||||
static inline void LEDs_ChangeLEDs(const uint8_t LedMask, const uint8_t ActiveMask)
|
||||
{
|
||||
// TODO: Add code to set the Leds in the given LedMask to the status given in ActiveMask here
|
||||
}
|
||||
|
||||
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint8_t LEDs_GetLEDs(void)
|
||||
{
|
||||
// TODO: Add code to return the current LEDs status' here which can be masked against LED_LED* macros
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* This file is the master dispatch header file for the device-specific ADC driver, for AVRs containing an ADC.
|
||||
*
|
||||
* User code should include this file, which will in turn include the correct ADC driver header file for the
|
||||
* currently selected AVR model.
|
||||
*/
|
||||
|
||||
#ifndef __ADC_H__
|
||||
#define __ADC_H__
|
||||
|
||||
/* Macros: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
#define INCLUDE_FROM_ADC_H
|
||||
#define INCLUDE_FROM_CHIP_DRIVER
|
||||
#endif
|
||||
|
||||
/* Includes: */
|
||||
#if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \
|
||||
defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \
|
||||
defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \
|
||||
defined(__AVR_ATmega32U6__))
|
||||
#include "AT90USBXXX67/ADC.h"
|
||||
#else
|
||||
#error "ADC is not available for the currently selected AVR model."
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* ADC driver for the AT90USB1287, AT90USB1286, AT90USB647, AT90USB646, ATMEGA16U4 and ATMEGA32U4 AVRs.
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the ADC driver
|
||||
* dispatch header located in LUFA/Drivers/AT90USBXXX/ADC.h.
|
||||
*/
|
||||
|
||||
#ifndef __ADC_AT90USBXXX67_H__
|
||||
#define __ADC_AT90USBXXX67_H__
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(INCLUDE_FROM_ADC_H)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/AT90USBXXX/ADC.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Initializes the ADC, ready for conversions. This must be called before any other ADC operations.
|
||||
* The "mode" parameter should be a mask comprised of a conversion mode (free running or single) and
|
||||
* prescaler masks.
|
||||
*/
|
||||
#define ADC_Init(mode) MACROS{ ADCSRA = ((1 << ADEN) | mode); }MACROE
|
||||
|
||||
/** Turns off the ADC. If this is called, any further ADC operations will require a call to the
|
||||
* ADC_Init() macro before the ADC can be used again.
|
||||
*/
|
||||
#define ADC_Off() MACROS{ ADCSRA = 0; }MACROE
|
||||
|
||||
/** Indicates if the ADC is enabled. This macro will return boolean true if the ADC subsystem is
|
||||
* currently enabled, or false otherwise.
|
||||
*/
|
||||
#define ADC_GetStatus() ((ADCSRA & (1 << ADEN)) ? true : false)
|
||||
|
||||
/** Indicates if the current ADC conversion is completed, or still in progress. This returns boolean
|
||||
* false if the reading is still taking place, or true if the conversion is complete and ready to be
|
||||
* read out with ADC_GetResult().
|
||||
*/
|
||||
#define ADC_IsReadingComplete() (!(ADCSRA & (1 << ADSC)))
|
||||
|
||||
/** Returns the result of the last conversion, as a 16-bit wide integer. */
|
||||
#define ADC_GetResult() ADC
|
||||
|
||||
/** Reference mask, for using the voltage present at the AVR's AREF pin for the ADC reference. */
|
||||
#define ADC_REFERENCE_AREF 0
|
||||
|
||||
/** Reference mask, for using the voltage present at the AVR's AVCC pin for the ADC reference. */
|
||||
#define ADC_REFERENCE_AVCC (1 << REFS0)
|
||||
|
||||
/** Reference mask, for using the internally generated 2.56V reference voltage as the ADC reference. */
|
||||
#define ADC_REFERENCE_INT2560MV ((1 << REFS1)| (1 << REFS0))
|
||||
|
||||
/** Left-adjusts the 10-bit ADC result, so that the upper 8 bits of the value returned by the
|
||||
* ADC_GetResult() macro contain the 8 most significant bits of the result. */
|
||||
#define ADC_LEFT_ADJUSTED (1 << ADLAR)
|
||||
|
||||
/** Right-adjusts the 10-bit ADC result, so that the lower 8 bits of the value returned by the
|
||||
* ADC_GetResult() macro contain the 8 least significant bits of the result. */
|
||||
#define ADC_RIGHT_ADJUSTED (0 << ADLAR)
|
||||
|
||||
/** Sets the ADC mode to free running, so that conversions take place continuously as fast as the ADC
|
||||
* is capable of at the given input clock speed. */
|
||||
#define ADC_FREE_RUNNING (1 << ADATE)
|
||||
|
||||
/** Sets the ADC mode to single conversion, so that only a single conversion will take place before
|
||||
* the ADC returns to idle. */
|
||||
#define ADC_SINGLE_CONVERSION (0 << ADATE)
|
||||
|
||||
/** Sets the ADC input clock to prescale by a factor of 2 the AVR's system clock. */
|
||||
#define ADC_PRESCALE_2 (1 << ADPS0)
|
||||
|
||||
/** Sets the ADC input clock to prescale by a factor of 4 the AVR's system clock. */
|
||||
#define ADC_PRESCALE_4 (1 << ADPS1)
|
||||
|
||||
/** Sets the ADC input clock to prescale by a factor of 8 the AVR's system clock. */
|
||||
#define ADC_PRESCALE_8 ((1 << ADPS0) | (1 << ADPS1))
|
||||
|
||||
/** Sets the ADC input clock to prescale by a factor of 16 the AVR's system clock. */
|
||||
#define ADC_PRESCALE_16 (1 << ADPS2)
|
||||
|
||||
/** Sets the ADC input clock to prescale by a factor of 32 the AVR's system clock. */
|
||||
#define ADC_PRESCALE_32 ((1 << ADPS2) | (1 << ADPS0))
|
||||
|
||||
/** Sets the ADC input clock to prescale by a factor of 64 the AVR's system clock. */
|
||||
#define ADC_PRESCALE_64 ((1 << ADPS2) | (1 << ADPS1))
|
||||
|
||||
/** Sets the ADC input clock to prescale by a factor of 128 the AVR's system clock. */
|
||||
#define ADC_PRESCALE_128 ((1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0))
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Configures the given ADC channel, ready for ADC conversions. This function sets the
|
||||
* associated port pin as an input and disables the digital portion of the I/O to reduce
|
||||
* power consumption.
|
||||
*
|
||||
* \param Channel ADC channel number to set up for conversions
|
||||
*/
|
||||
static inline void ADC_SetupChannel(const uint8_t Channel)
|
||||
{
|
||||
DDRD &= ~(1 << Channel);
|
||||
DIDR0 |= (1 << Channel);
|
||||
}
|
||||
|
||||
/** Starts the reading of the given channel, but does not wait until the conversion has completed.
|
||||
* Once executed, the conversion status can be determined via the ADC_IsReadingComplete() macro and
|
||||
* the result read via the ADC_GetResult() macro.
|
||||
*
|
||||
* \param MUXMask Mask comprising of an ADC channel number, reference mask and adjustment mask
|
||||
*/
|
||||
static inline void ADC_StartReading(const uint8_t MUXMask)
|
||||
{
|
||||
ADMUX = MUXMask;
|
||||
|
||||
ADCSRA |= (1 << ADSC);
|
||||
}
|
||||
|
||||
/** Performs a complete single reading from channel, including a polling spinloop to wait for the
|
||||
* conversion to complete, and the returning of the converted value.
|
||||
*
|
||||
* \param MUXMask Mask comprising of an ADC channel number, reference mask and adjustment mask
|
||||
*/
|
||||
static inline uint16_t ADC_GetChannelReading(const uint8_t MUXMask) ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint16_t ADC_GetChannelReading(const uint8_t MUXMask)
|
||||
{
|
||||
ADC_StartReading(MUXMask);
|
||||
|
||||
while (!(ADC_IsReadingComplete()));
|
||||
|
||||
return ADC_GetResult();
|
||||
}
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* Hardware SPI subsystem driver for the supported USB AVRs models.
|
||||
*/
|
||||
|
||||
#ifndef __SPI_H__
|
||||
#define __SPI_H__
|
||||
|
||||
/* Includes: */
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Macros: */
|
||||
#define SPI_USE_DOUBLESPEED (1 << 7)
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 2. */
|
||||
#define SPI_SPEED_FCPU_DIV_2 SPI_USE_DOUBLESPEED
|
||||
|
||||
/** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 4. */
|
||||
#define SPI_SPEED_FCPU_DIV_4 0
|
||||
|
||||
/** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 8. */
|
||||
#define SPI_SPEED_FCPU_DIV_8 (SPI_USE_DOUBLESPEED | (1 << SPR0))
|
||||
|
||||
/** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 16. */
|
||||
#define SPI_SPEED_FCPU_DIV_16 (1 << SPR0)
|
||||
|
||||
/** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 32. */
|
||||
#define SPI_SPEED_FCPU_DIV_32 (SPI_USE_DOUBLESPEED | (1 << SPR1))
|
||||
|
||||
/** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 64. */
|
||||
#define SPI_SPEED_FCPU_DIV_64 (SPI_USE_DOUBLESPEED | (1 << SPR1) | (1 < SPR0))
|
||||
|
||||
/** SPI prescaler mask for SPI_Init(). Divides the system clock by a factor of 128. */
|
||||
#define SPI_SPEED_FCPU_DIV_128 ((1 << SPR1) | (1 < SPR0))
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Initializes the SPI subsystem, ready for transfers. Must be called before calling any other
|
||||
* SPI routines.
|
||||
*
|
||||
* \param PrescalerMask Prescaler mask to set the SPI clock speed
|
||||
* \param Master If true, sets the SPI system to use master mode, slave if false
|
||||
*/
|
||||
static inline void SPI_Init(const uint8_t PrescalerMask, const bool Master)
|
||||
{
|
||||
DDRB |= ((1 << 1) | (1 << 2));
|
||||
PORTB |= ((1 << 0) | (1 << 3));
|
||||
|
||||
SPCR = ((1 << SPE) | (Master << MSTR) | (1 << CPOL) | (1 << CPHA) |
|
||||
(PrescalerMask & ~SPI_USE_DOUBLESPEED));
|
||||
|
||||
if (PrescalerMask & SPI_USE_DOUBLESPEED)
|
||||
SPSR = (1 << SPI2X);
|
||||
}
|
||||
|
||||
/** Sends and receives a byte through the SPI interface, blocking until the transfer is complete.
|
||||
*
|
||||
* \param Byte Byte to send through the SPI interface
|
||||
*
|
||||
* \return Response byte from the attached SPI device
|
||||
*/
|
||||
static inline uint8_t SPI_TransferByte(const uint8_t Byte) ATTR_ALWAYSINLINE;
|
||||
static inline uint8_t SPI_TransferByte(const uint8_t Byte)
|
||||
{
|
||||
SPDR = Byte;
|
||||
while (!(SPSR & (1 << SPIF)));
|
||||
return SPDR;
|
||||
}
|
||||
|
||||
/** Sends a byte through the SPI interface, blocking until the transfer is complete. The response
|
||||
* byte sent to from the attached SPI device is ignored.
|
||||
*
|
||||
* \param Byte Byte to send through the SPI interface
|
||||
*/
|
||||
static inline void SPI_SendByte(const uint8_t Byte) ATTR_ALWAYSINLINE;
|
||||
static inline void SPI_SendByte(const uint8_t Byte)
|
||||
{
|
||||
SPDR = Byte;
|
||||
while (!(SPSR & (1 << SPIF)));
|
||||
}
|
||||
|
||||
/** Sends a dummy byte through the SPI interface, blocking until the transfer is complete. The response
|
||||
* byte from the attached SPI device is returned.
|
||||
*
|
||||
* \return The response byte from the attached SPI device
|
||||
*/
|
||||
static inline uint8_t SPI_ReceiveByte(void) ATTR_ALWAYSINLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint8_t SPI_ReceiveByte(void)
|
||||
{
|
||||
SPDR = 0x00;
|
||||
while (!(SPSR & (1 << SPIF)));
|
||||
return SPDR;
|
||||
}
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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 "Serial.h"
|
||||
|
||||
void Serial_Init(const uint32_t BaudRate, const bool DoubleSpeed)
|
||||
{
|
||||
UCSR1A = ((DoubleSpeed) ? (1 << U2X1) : 0);
|
||||
UCSR1B = ((1 << RXEN1) | (1 << TXEN1));
|
||||
UCSR1C = ((1 << UCSZ11) | (1 << UCSZ10));
|
||||
|
||||
DDRD |= (1 << 3);
|
||||
PORTD |= (1 << 2);
|
||||
|
||||
UBRR1 = SERIAL_UBBRVAL(BaudRate);
|
||||
}
|
||||
|
||||
void Serial_TxString_P(const char *FlashStringPtr)
|
||||
{
|
||||
uint8_t CurrByte;
|
||||
|
||||
while ((CurrByte = pgm_read_byte(FlashStringPtr)) != 0x00)
|
||||
{
|
||||
Serial_TxByte(CurrByte);
|
||||
FlashStringPtr++;
|
||||
}
|
||||
}
|
||||
|
||||
void Serial_TxString(const char *StringPtr)
|
||||
{
|
||||
uint8_t CurrByte;
|
||||
|
||||
while ((CurrByte = *StringPtr) != 0x00)
|
||||
{
|
||||
Serial_TxByte(CurrByte);
|
||||
StringPtr++;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* Driver for the USART subsystem on supported USB AVRs.
|
||||
*/
|
||||
|
||||
#ifndef __SERIAL_H__
|
||||
#define __SERIAL_H__
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../../Common/Common.h"
|
||||
#include "../Misc/TerminalCodes.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Indicates whether a character has been received through the USART - boolean false if no character
|
||||
* has been received, or non-zero if a character is waiting to be read from the reception buffer.
|
||||
*/
|
||||
#define Serial_IsCharReceived() ((UCSR1A & (1 << RXC1)) ? true : false)
|
||||
|
||||
/** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is
|
||||
* not set.
|
||||
*/
|
||||
#define SERIAL_UBBRVAL(baud) (((F_CPU / 16) / baud) - 1)
|
||||
|
||||
/** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is
|
||||
* set.
|
||||
*/
|
||||
#define SERIAL_2X_UBBRVAL(baud) (((F_CPU / 8) / baud) - 1)
|
||||
|
||||
/* Function Prototypes: */
|
||||
/** Initializes the USART, ready for serial data transmission and reception.
|
||||
*
|
||||
* \param BaudRate Baud rate to configure the USART to
|
||||
* \param DoubleSpeed Enables double speed mode when set, halving the sample time to double the baud rate
|
||||
*/
|
||||
void Serial_Init(const uint32_t BaudRate, const bool DoubleSpeed);
|
||||
|
||||
/** Transmits a given string located in program space (FLASH) through the USART.
|
||||
*
|
||||
* \param FlashStringPtr Pointer to a string located in program space
|
||||
*/
|
||||
void Serial_TxString_P(const char *FlashStringPtr) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
||||
/** Transmits a given string located in SRAM memory through the USART.
|
||||
*
|
||||
* \param StringPtr Pointer to a string located in SRAM space
|
||||
*/
|
||||
void Serial_TxString(const char *StringPtr) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Transmits a given byte through the USART.
|
||||
*
|
||||
* \param DataByte Byte to transmit through the USART
|
||||
*/
|
||||
static inline void Serial_TxByte(const char DataByte)
|
||||
{
|
||||
while (!(UCSR1A & (1 << UDRE1)));
|
||||
UDR1 = DataByte;
|
||||
}
|
||||
|
||||
/** Receives a byte from the USART.
|
||||
*
|
||||
* \return Byte received from the USART
|
||||
*/
|
||||
static inline char Serial_RxByte(void)
|
||||
{
|
||||
while (!(UCSR1A & (1 << RXC1)));
|
||||
return UDR1;
|
||||
}
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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 "Serial_Stream.h"
|
||||
|
||||
FILE USARTStream = FDEV_SETUP_STREAM(SerialStream_TxByte, SerialStream_RxByte, _FDEV_SETUP_RW);
|
||||
|
||||
int SerialStream_TxByte(char DataByte, FILE *Stream)
|
||||
{
|
||||
Serial_TxByte(DataByte);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SerialStream_RxByte(FILE *Stream)
|
||||
{
|
||||
return Serial_RxByte();
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* Serial stream driver for the USART subsystem on supported USB AVRs. This makes use of the functions in the
|
||||
* regular USART driver, but allows the avr-libc standard stream functions (printf, puts, etc.) to work with the
|
||||
* USART.
|
||||
**/
|
||||
|
||||
#ifndef __SERIAL_STREAM_H__
|
||||
#define __SERIAL_STREAM_H__
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Serial.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* External Variables: */
|
||||
extern FILE USARTStream;
|
||||
|
||||
/* Function Prototypes: */
|
||||
int SerialStream_TxByte(char DataByte, FILE *Stream) ATTR_NON_NULL_PTR_ARG(2);
|
||||
int SerialStream_RxByte(FILE *Stream) ATTR_NON_NULL_PTR_ARG(1);
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Inline Functions: */
|
||||
/** Initializes the serial stream (and regular USART driver) so that both the stream and regular
|
||||
* USART driver functions can be used. Must be called before any stream or regular USART functions.
|
||||
*
|
||||
* \param BaudRate Baud rate to configure the USART to
|
||||
* \param DoubleSpeed Enables double speed mode when set, halving the sample time to double the baud rate
|
||||
*/
|
||||
static inline void SerialStream_Init(const uint32_t BaudRate, const bool DoubleSpeed)
|
||||
{
|
||||
Serial_Init(BaudRate, DoubleSpeed);
|
||||
|
||||
stdout = &USARTStream;
|
||||
}
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* Board specific HWB driver header for the ATAVRUSBRF01.
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the HWB driver
|
||||
* dispatch header located in LUFA/Drivers/Board/HWB.h.
|
||||
*/
|
||||
|
||||
#ifndef __HWB_ATAVRUSBRF01_H__
|
||||
#define __HWB_ATAVRUSBRF01_H__
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(INCLUDE_FROM_HWB_H)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/Board/HWB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Inline Functions: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
static inline void HWB_Init(void)
|
||||
{
|
||||
DDRD &= ~(1 << 7);
|
||||
PORTD |= (1 << 7);
|
||||
}
|
||||
|
||||
static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool HWB_GetStatus(void)
|
||||
{
|
||||
return (!(PIND & (1 << 7)));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* Board specific LED driver header for the ATAVRUSBRF01.
|
||||
*
|
||||
* \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.
|
||||
*/
|
||||
|
||||
#ifndef __LEDS_ATAVRUSBRF01_H__
|
||||
#define __LEDS_ATAVRUSBRF01_H__
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(INCLUDE_FROM_LEDS_H)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
|
||||
#endif
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Macros: */
|
||||
#define LEDS_PORTD_LEDS (LEDS_LED1 | LEDS_LED2)
|
||||
#define LEDS_PORTE_LEDS (LEDS_LED3 | LEDS_LED4)
|
||||
|
||||
#define LEDS_PORTE_MASK_SHIFT 4
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** LED mask for the first LED on the board. */
|
||||
#define LEDS_LED1 (1 << 0)
|
||||
|
||||
/** LED mask for the second LED on the board. */
|
||||
#define LEDS_LED2 (1 << 1)
|
||||
|
||||
/** LED mask for all the LEDs on the board. */
|
||||
#define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2)
|
||||
|
||||
/** LED mask for the none of the board LEDs */
|
||||
#define LEDS_NO_LEDS 0
|
||||
|
||||
/* Inline Functions: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
static inline void LEDs_Init(void)
|
||||
{
|
||||
DDRD |= LEDS_ALL_LEDS;
|
||||
PORTD &= ~LEDS_ALL_LEDS;
|
||||
}
|
||||
|
||||
static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
|
||||
{
|
||||
PORTD |= (LEDMask & LEDS_ALL_LEDS);
|
||||
}
|
||||
|
||||
static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
|
||||
{
|
||||
PORTD &= ~(LEDMask & LEDS_ALL_LEDS);
|
||||
}
|
||||
|
||||
static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
|
||||
{
|
||||
PORTD = (PORTD & ~LEDS_ALL_LEDS) | (LEDMask & LEDS_ALL_LEDS);
|
||||
}
|
||||
|
||||
static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)
|
||||
{
|
||||
PORTD = (PORTD & ~(LEDMask & LEDS_ALL_LEDS)) | (ActiveMask & LEDS_ALL_LEDS))
|
||||
}
|
||||
|
||||
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint8_t LEDs_GetLEDs(void)
|
||||
{
|
||||
return (PORTD & LEDS_ALL_LEDS);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* This file is the master dispatch header file for the board-specific dataflash driver, for boards containing
|
||||
* dataflash ICs for external non-volatile storage.
|
||||
*
|
||||
* User code should include this file, which will in turn include the correct dataflash driver header file for
|
||||
* the currently selected board.
|
||||
*
|
||||
* If the BOARD value is set to BOARD_USER, this will include the /Board/Dataflash.h file in the user project
|
||||
* directory.
|
||||
*/
|
||||
|
||||
#ifndef __DATAFLASH_H__
|
||||
#define __DATAFLASH_H__
|
||||
|
||||
/* Macros: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
#define INCLUDE_FROM_DATAFLASH_H
|
||||
#define INCLUDE_FROM_BOARD_DRIVER
|
||||
#endif
|
||||
|
||||
/* Includes: */
|
||||
#include "../AT90USBXXX/SPI.h"
|
||||
#include "../../Common/Common.h"
|
||||
|
||||
#if !defined(BOARD)
|
||||
#error BOARD must be set in makefile to a value specified in BoardTypes.h.
|
||||
#elif (BOARD == BOARD_USBKEY)
|
||||
#include "USBKEY/Dataflash.h"
|
||||
#elif (BOARD == BOARD_STK525)
|
||||
#include "STK525/Dataflash.h"
|
||||
#elif (BOARD == BOARD_STK526)
|
||||
#include "STK526/Dataflash.h"
|
||||
#elif (BOARD == BOARD_USER)
|
||||
#include "Board/Dataflash.h"
|
||||
#else
|
||||
#error The selected board does not contain a dataflash IC.
|
||||
#endif
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** Returns the mask of the currently selected Dataflash chip, either DATAFLASH_NO_CHIP or a
|
||||
* DATAFLASH_CHIPn mask (where n is the chip number).
|
||||
*/
|
||||
#define Dataflash_GetSelectedChip() (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK)
|
||||
|
||||
/** Selects the dataflash chip given as a chip mask, in the form of DATAFLASH_CHIPn (where n
|
||||
* is the chip number).
|
||||
*/
|
||||
#define Dataflash_SelectChip(mask) MACROS{ DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT \
|
||||
& ~DATAFLASH_CHIPCS_MASK) | mask); }MACROE
|
||||
|
||||
/** Deselects the current dataflash chip, so that no dataflash is selected. */
|
||||
#define Dataflash_DeselectChip() Dataflash_SelectChip(DATAFLASH_NO_CHIP)
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Initializes the dataflash driver (including the SPI driver) so that commands and data may be
|
||||
* sent to an attached dataflash IC.
|
||||
*
|
||||
* \param PrescalerMask SPI prescaler mask, see SPI.h documentation
|
||||
*/
|
||||
static inline void Dataflash_Init(const uint8_t PrescalerMask)
|
||||
{
|
||||
DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK;
|
||||
DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;
|
||||
|
||||
SPI_Init(PrescalerMask, true);
|
||||
}
|
||||
|
||||
/** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.
|
||||
*
|
||||
* \param Byte of data to send to the dataflash
|
||||
*
|
||||
* \return Last response byte from the dataflash
|
||||
*/
|
||||
static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYSINLINE;
|
||||
static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)
|
||||
{
|
||||
return SPI_TransferByte(Byte);
|
||||
}
|
||||
|
||||
/** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.
|
||||
*
|
||||
* \param Byte of data to send to the dataflash
|
||||
*/
|
||||
static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYSINLINE;
|
||||
static inline void Dataflash_SendByte(const uint8_t Byte)
|
||||
{
|
||||
SPI_SendByte(Byte);
|
||||
}
|
||||
|
||||
/** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.
|
||||
*
|
||||
* \return Last response byte from the dataflash
|
||||
*/
|
||||
static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYSINLINE ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint8_t Dataflash_ReceiveByte(void)
|
||||
{
|
||||
return SPI_ReceiveByte();
|
||||
}
|
||||
|
||||
/** 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)
|
||||
{
|
||||
#if (DATAFLASH_TOTALCHIPS == 2)
|
||||
uint8_t SelectedChipMask = Dataflash_GetSelectedChip();
|
||||
|
||||
Dataflash_DeselectChip();
|
||||
Dataflash_SelectChip(SelectedChipMask);
|
||||
#else
|
||||
Dataflash_DeselectChip();
|
||||
Dataflash_SelectChip(DATAFLASH_CHIP1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Spinloops 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));
|
||||
}
|
||||
|
||||
/** 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 PageAddress Address of the page to manipulate, ranging from
|
||||
* ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).
|
||||
*/
|
||||
static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)
|
||||
{
|
||||
Dataflash_DeselectChip();
|
||||
|
||||
if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS))
|
||||
return;
|
||||
|
||||
#if (DATAFLASH_TOTALCHIPS == 2)
|
||||
if (PageAddress & 0x01)
|
||||
Dataflash_SelectChip(DATAFLASH_CHIP2);
|
||||
else
|
||||
Dataflash_SelectChip(DATAFLASH_CHIP1);
|
||||
#else
|
||||
Dataflash_SelectChip(DATAFLASH_CHIP1);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** 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-byte address.
|
||||
*
|
||||
* \param PageAddress Page address within the selected dataflash IC
|
||||
* \param BufferByte Address within the dataflash's buffer
|
||||
*/
|
||||
static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, const uint16_t BufferByte)
|
||||
{
|
||||
#if (DATAFLASH_TOTALCHIPS == 2)
|
||||
PageAddress >>= 1;
|
||||
#endif
|
||||
|
||||
Dataflash_SendByte(PageAddress >> 5);
|
||||
Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8));
|
||||
Dataflash_SendByte(BufferByte);
|
||||
}
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* This file is the master dispatch header file for the board-specific HWB driver, for boards containing a
|
||||
* physical pushbutton connected to the AVR's HWB IO pin.
|
||||
*
|
||||
* User code should include this file, which will in turn include the correct HWB driver header file for the
|
||||
* currently selected board.
|
||||
*
|
||||
* If the BOARD value is set to BOARD_USER, this will include the /Board/HWB.h file in the user project
|
||||
* directory.
|
||||
*/
|
||||
|
||||
#ifndef __HWB_H__
|
||||
#define __HWB_H__
|
||||
|
||||
/* Macros: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
#define INCLUDE_FROM_HWB_H
|
||||
#define INCLUDE_FROM_BOARD_DRIVER
|
||||
#endif
|
||||
|
||||
/* Includes: */
|
||||
#include "../../Common/Common.h"
|
||||
|
||||
#if !defined(BOARD)
|
||||
#error BOARD must be set in makefile to a value specified in BoardTypes.h.
|
||||
#elif (BOARD == BOARD_USBKEY)
|
||||
#include "USBKEY/HWB.h"
|
||||
#elif (BOARD == BOARD_STK525)
|
||||
#include "STK525/HWB.h"
|
||||
#elif (BOARD == BOARD_STK526)
|
||||
#include "STK526/HWB.h"
|
||||
#elif (BOARD == BOARD_ATAVRUSBRF01)
|
||||
#include "ATAVRUSBRF01/HWB.h"
|
||||
#elif (BOARD == BOARD_USER)
|
||||
#include "Board/HWB.h"
|
||||
#else
|
||||
#error The selected board does not contain a HWB.
|
||||
#endif
|
||||
|
||||
/* Psudo-Functions for Doxygen: */
|
||||
#if defined(__DOXYGEN__)
|
||||
/** Initializes the HWB driver, so that the current button position can be read. This sets the appropriate
|
||||
* I/O pin to an input with pull-up enabled.
|
||||
*
|
||||
* This must be called before any HWB functions are used.
|
||||
*/
|
||||
static inline void HWB_Init(void);
|
||||
|
||||
/** Returns the current position of the HWB button on the board.
|
||||
*
|
||||
* \return Boolean true if the button is currently pressed, false otherwise
|
||||
*/
|
||||
static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* This file is the master dispatch header file for the board-specific Joystick driver, for boards containing a
|
||||
* 5-way joystick.
|
||||
*
|
||||
* User code should include this file, which will in turn include the correct joystick driver header file for the
|
||||
* currently selected board.
|
||||
*
|
||||
* If the BOARD value is set to BOARD_USER, this will include the /Board/Joystick.h file in the user project
|
||||
* directory.
|
||||
*/
|
||||
|
||||
#ifndef __JOYSTICK_H__
|
||||
#define __JOYSTICK_H__
|
||||
|
||||
/* Macros: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
#define INCLUDE_FROM_JOYSTICK_H
|
||||
#define INCLUDE_FROM_BOARD_DRIVER
|
||||
#endif
|
||||
|
||||
/* Includes: */
|
||||
#include "../../Common/Common.h"
|
||||
|
||||
#if !defined(BOARD)
|
||||
#error BOARD must be set in makefile to a value specified in BoardTypes.h.
|
||||
#elif (BOARD == BOARD_USBKEY)
|
||||
#include "USBKEY/Joystick.h"
|
||||
#elif (BOARD == BOARD_STK525)
|
||||
#include "STK525/Joystick.h"
|
||||
#elif (BOARD == BOARD_STK526)
|
||||
#include "STK526/Joystick.h"
|
||||
#elif (BOARD == BOARD_USER)
|
||||
#include "Board/Joystick.h"
|
||||
#else
|
||||
#error The selected board does not contain a joystick.
|
||||
#endif
|
||||
|
||||
/* Psudo-Functions for Doxygen: */
|
||||
#if defined(__DOXYGEN__)
|
||||
/** Initializes the joystick driver so that the joystick position can be read. This sets the appropriate
|
||||
* I/O pins to inputs with their pull-ups enabled.
|
||||
*/
|
||||
static inline void Joystick_Init(void);
|
||||
|
||||
/** Returns the current status of the joystick, as a mask indicating the direction the joystick is
|
||||
* currently facing in (multiple bits can be set).
|
||||
*
|
||||
* \return Mask indicating the joystick direction - see corresponding board specific Joystick.h file
|
||||
* for direction masks
|
||||
*/
|
||||
static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* This file is the master dispatch header file for the board-specific LED driver, for boards containing user
|
||||
* controllable LEDs.
|
||||
*
|
||||
* User code should include this file, which will in turn include the correct LED driver header file for the
|
||||
* currently selected board.
|
||||
*
|
||||
* If the BOARD value is set to BOARD_USER, this will include the /Board/LEDs.h file in the user project
|
||||
* directory.
|
||||
*/
|
||||
|
||||
#ifndef __LEDS_H__
|
||||
#define __LEDS_H__
|
||||
|
||||
/* Macros: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
#define INCLUDE_FROM_LEDS_H
|
||||
#define INCLUDE_FROM_BOARD_DRIVER
|
||||
#endif
|
||||
|
||||
/* Includes: */
|
||||
#include "../../Common/Common.h"
|
||||
|
||||
#if !defined(BOARD)
|
||||
#error BOARD must be set in makefile to a value specified in BoardTypes.h.
|
||||
#elif (BOARD == BOARD_USBKEY)
|
||||
#include "USBKEY/LEDs.h"
|
||||
#elif (BOARD == BOARD_STK525)
|
||||
#include "STK525/LEDs.h"
|
||||
#elif (BOARD == BOARD_STK526)
|
||||
#include "STK526/LEDs.h"
|
||||
#elif (BOARD == BOARD_RZUSBSTICK)
|
||||
#include "RZUSBSTICK/LEDs.h"
|
||||
#elif (BOARD == BOARD_ATAVRUSBRF01)
|
||||
#include "ATAVRUSBRF01/LEDs.h"
|
||||
#elif (BOARD == BOARD_USER)
|
||||
#include "Board/LEDs.h"
|
||||
#endif
|
||||
|
||||
/* Psudo-Functions for Doxygen: */
|
||||
#if defined(__DOXYGEN__)
|
||||
/** Initializes the board LED driver so that the LEDs can be controlled. This sets the appropriate port
|
||||
* I/O pins as outputs, and sets the LEDs to default to off.
|
||||
*/
|
||||
static inline void LEDs_Init(void);
|
||||
|
||||
/** Turns on the LEDs specified in the given LED mask.
|
||||
*
|
||||
* \param LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)
|
||||
*/
|
||||
static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask);
|
||||
|
||||
/** Turns off the LEDs specified in the given LED mask.
|
||||
*
|
||||
* \param LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)
|
||||
*/
|
||||
static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask);
|
||||
|
||||
/** Turns off all LEDs not specified in the given LED mask, and turns on all the LEDs in the given LED
|
||||
* mask.
|
||||
*
|
||||
* \param LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)
|
||||
*/
|
||||
static inline void LEDs_SetAllLEDs(const uint8_t LEDMask);
|
||||
|
||||
/** Turns off all LEDs in the LED mask that are not set in the active mask, and turns on all the LEDs
|
||||
* specified in both the LED and active masks.
|
||||
*
|
||||
* \param LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file)
|
||||
* \param ActiveMask Mask of whether the LEDs in the LED mask should be turned on or off
|
||||
*/
|
||||
static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask);
|
||||
|
||||
/** Returns the status of all the board LEDs; set LED masks in the return value indicate that the
|
||||
* corresponding LED is on.
|
||||
*
|
||||
* \return Mask of the board LEDs which are currently turned on
|
||||
*/
|
||||
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* Board specific LED driver header for the RZUSBSTICK.
|
||||
*
|
||||
* \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.
|
||||
*/
|
||||
|
||||
#ifndef __LEDS_RZUSBSTICK_H__
|
||||
#define __LEDS_RZUSBSTICK_H__
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(INCLUDE_FROM_LEDS_H)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.
|
||||
#endif
|
||||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Macros: */
|
||||
#define LEDS_PORTD_LEDS (LEDS_LED1 | LEDS_LED2)
|
||||
#define LEDS_PORTE_LEDS (LEDS_LED3 | LEDS_LED4)
|
||||
|
||||
#define LEDS_PORTE_MASK_SHIFT 4
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
/** LED mask for the first LED on the board. */
|
||||
#define LEDS_LED1 (1 << 7)
|
||||
|
||||
/** LED mask for the second LED on the board. */
|
||||
#define LEDS_LED2 (1 << 5)
|
||||
|
||||
/** LED mask for the third LED on the board. */
|
||||
#define LEDS_LED3 ((1 << 6) >> LEDS_PORTE_MASK_SHIFT)
|
||||
|
||||
/** LED mask for the fourth LED on the board. */
|
||||
#define LEDS_LED4 ((1 << 7) >> LEDS_PORTE_MASK_SHIFT)
|
||||
|
||||
/** LED mask for all the LEDs on the board. */
|
||||
#define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)
|
||||
|
||||
/** LED mask for the none of the board LEDs */
|
||||
#define LEDS_NO_LEDS 0
|
||||
|
||||
/* Inline Functions: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
static inline void LEDs_Init(void)
|
||||
{
|
||||
DDRD |= LEDS_PORTD_LEDS;
|
||||
PORTD &= ~LEDS_LED1;
|
||||
PORTD |= LEDS_LED2;
|
||||
|
||||
DDRE |= (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);
|
||||
PORTE |= (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);
|
||||
}
|
||||
|
||||
static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)
|
||||
{
|
||||
PORTD |= (LEDMask & LEDS_LED1);
|
||||
PORTD &= ~(LEDMask & LEDS_LED2);
|
||||
PORTE &= ~((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);
|
||||
}
|
||||
|
||||
static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)
|
||||
{
|
||||
PORTD &= ~(LEDMask & LEDS_LED1);
|
||||
PORTD |= (LEDMask & LEDS_LED2);
|
||||
PORTE |= ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);
|
||||
}
|
||||
|
||||
static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)
|
||||
{
|
||||
PORTD = (((PORTD & ~LEDS_LED1) | (LEDMask & LEDS_LED1)) |
|
||||
((PORTD | LEDS_LED2) & ~(LEDMask & LEDS_LED2)));
|
||||
PORTE = ((PORTE | (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT)) &
|
||||
~((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT));
|
||||
}
|
||||
|
||||
static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)
|
||||
{
|
||||
PORTD = (((PORTD & ~(LEDMask & LEDS_LED1)) | (ActiveMask & LEDS_LED1)) |
|
||||
((PORTD | (LEDMask & LEDS_LED2)) & ~(ActiveMask & LEDS_LED2)));
|
||||
PORTE = ((PORTE | ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT)) &
|
||||
~((ActiveMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT));
|
||||
}
|
||||
|
||||
static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;
|
||||
static inline uint8_t LEDs_GetLEDs(void)
|
||||
{
|
||||
return (((PORTD & LEDS_LED1) | (~PORTD & LEDS_LED2)) |
|
||||
((~PORTE & (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT)) >> LEDS_PORTE_MASK_SHIFT));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* Board specific Dataflash commands header for the AT45DB321C as mounted on the STK525.
|
||||
*
|
||||
* \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.
|
||||
*/
|
||||
|
||||
#ifndef __DATAFLASH_CMDS_H__
|
||||
#define __DATAFLASH_CMDS_H__
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Macros: */
|
||||
#define DF_STATUS_READY (1 << 7)
|
||||
#define DF_STATUS_COMPMISMATCH (1 << 6)
|
||||
#define DF_STATUS_SECTORPROTECTION_ON (1 << 1)
|
||||
|
||||
#define DF_MANUFACTURER_ATMEL 0x1F
|
||||
|
||||
#define DF_CMD_GETSTATUS 0xD7
|
||||
|
||||
#define DF_CMD_MAINMEMTOBUFF1 0x53
|
||||
#define DF_CMD_MAINMEMTOBUFF2 0x55
|
||||
#define DF_CMD_MAINMEMTOBUFF1COMP 0x60
|
||||
#define DF_CMD_MAINMEMTOBUFF2COMP 0x61
|
||||
#define DF_CMD_AUTOREWRITEBUFF1 0x58
|
||||
#define DF_CMD_AUTOREWRITEBUFF2 0x59
|
||||
|
||||
#define DF_CMD_MAINMEMPAGEREAD 0xD2
|
||||
#define DF_CMD_CONTARRAYREAD_LF 0xE8
|
||||
#define DF_CMD_BUFF1READ_LF 0xD4
|
||||
#define DF_CMD_BUFF2READ_LF 0xD6
|
||||
|
||||
#define DF_CMD_BUFF1WRITE 0x84
|
||||
#define DF_CMD_BUFF2WRITE 0x87
|
||||
#define DF_CMD_BUFF1TOMAINMEMWITHERASE 0x83
|
||||
#define DF_CMD_BUFF2TOMAINMEMWITHERASE 0x86
|
||||
#define DF_CMD_BUFF1TOMAINMEM 0x88
|
||||
#define DF_CMD_BUFF2TOMAINMEM 0x89
|
||||
#define DF_CMD_MAINMEMPAGETHROUGHBUFF1 0x82
|
||||
#define DF_CMD_MAINMEMPAGETHROUGHBUFF2 0x85
|
||||
|
||||
#define DF_CMD_PAGEERASE 0x81
|
||||
#define DF_CMD_BLOCKERASE 0x50
|
||||
|
||||
#define DF_CMD_SECTORPROTECTIONOFF ((char[]){0x3D, 0x2A, 0x7F, 0xCF})
|
||||
#define DF_CMD_SECTORPROTECTIONOFF_BYTE1 0x3D
|
||||
#define DF_CMD_SECTORPROTECTIONOFF_BYTE2 0x2A
|
||||
#define DF_CMD_SECTORPROTECTIONOFF_BYTE3 0x7F
|
||||
#define DF_CMD_SECTORPROTECTIONOFF_BYTE4 0xCF
|
||||
|
||||
#define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* Board specific HWB driver header for the STK525.
|
||||
*
|
||||
* \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.
|
||||
*/
|
||||
|
||||
#ifndef __DATAFLASH_STK525_H__
|
||||
#define __DATAFLASH_STK525_H__
|
||||
|
||||
/* Includes: */
|
||||
#include "AT45DB321C.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 << 4)
|
||||
#define DATAFLASH_CHIPCS_DDR DDRB
|
||||
#define DATAFLASH_CHIPCS_PORT PORTB
|
||||
#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 1
|
||||
|
||||
/** Mask for no dataflash chip selected. */
|
||||
#define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK
|
||||
|
||||
/** Mask for the first dataflash chip selected. */
|
||||
#define DATAFLASH_CHIP1 0
|
||||
|
||||
/** Internal main memory page size for the board's dataflash IC. */
|
||||
#define DATAFLASH_PAGE_SIZE 512
|
||||
|
||||
/** Total number of pages inside the board's dataflash IC. */
|
||||
#define DATAFLASH_PAGES 8192
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2009.
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, and distribute this software
|
||||
and its documentation for any purpose and without fee is hereby
|
||||
granted, 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
|
||||
*
|
||||
* Board specific HWB driver header for the STK525.
|
||||
*
|
||||
* \note This file should not be included directly. It is automatically included as needed by the HWB driver
|
||||
* dispatch header located in LUFA/Drivers/Board/HWB.h.
|
||||
*/
|
||||
|
||||
#ifndef __HWB_STK525_H__
|
||||
#define __HWB_STK525_H__
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../../../Common/Common.h"
|
||||
|
||||
/* Enable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if !defined(INCLUDE_FROM_HWB_H)
|
||||
#error Do not include this file directly. Include LUFA/Drivers/Board/HWB.h instead.
|
||||
#endif
|
||||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
/* Inline Functions: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
static inline void HWB_Init(void)
|
||||
{
|
||||
DDRE &= ~(1 << 2);
|
||||
PORTE |= (1 << 2);
|
||||
}
|
||||
|
||||
static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
|
||||
static inline bool HWB_GetStatus(void)
|
||||
{
|
||||
return (!(PINE & (1 << 2)));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Disable C linkage for C++ Compilers: */
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user