Subversion Repositories idreammicro-avr

Compare Revisions

Ignore whitespace Rev 1 → Rev HEAD

/trunk/Doxyfile
0,0 → 1,1813
# Doxyfile 1.7.6.1
 
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project
#
# All text after a hash (#) is considered a comment and will be ignored
# The format is:
# TAG = value [value, ...]
# For lists items can also be appended using:
# TAG += value [value, ...]
# Values that contain spaces should be placed between quotes (" ")
 
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
 
# This tag specifies the encoding used for all characters in the config file
# that follow. The default is UTF-8 which is also the encoding used for all
# text before the first occurrence of this tag. Doxygen uses libiconv (or the
# iconv built into libc) for the transcoding. See
# http://www.gnu.org/software/libiconv for the list of possible encodings.
 
DOXYFILE_ENCODING = UTF-8
 
# The PROJECT_NAME tag is a single word (or sequence of words) that should
# identify the project. Note that if you do not use Doxywizard you need
# to put quotes around the project name if it contains spaces.
 
PROJECT_NAME = idreammicro-avr
 
# The PROJECT_NUMBER tag can be used to enter a project or revision number.
# This could be handy for archiving the generated documentation or
# if some version control system is used.
 
PROJECT_NUMBER =
 
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer
# a quick idea about the purpose of the project. Keep the description short.
 
PROJECT_BRIEF =
 
# With the PROJECT_LOGO tag one can specify an logo or icon that is
# included in the documentation. The maximum height of the logo should not
# exceed 55 pixels and the maximum width should not exceed 200 pixels.
# Doxygen will copy the logo to the output directory.
 
PROJECT_LOGO =
 
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.
# If a relative path is entered, it will be relative to the location
# where doxygen was started. If left blank the current directory will be used.
 
OUTPUT_DIRECTORY = ./doc
 
# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
# 4096 sub-directories (in 2 levels) under the output directory of each output
# format and will distribute the generated files over these directories.
# Enabling this option can be useful when feeding doxygen a huge amount of
# source files, where putting all generated files in the same directory would
# otherwise cause performance problems for the file system.
 
CREATE_SUBDIRS = NO
 
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
# documentation generated by doxygen is written. Doxygen will use this
# information to generate all constant output in the proper language.
# The default language is English, other supported languages are:
# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,
# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
 
OUTPUT_LANGUAGE = English
 
# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
# include brief member descriptions after the members that are listed in
# the file and class documentation (similar to JavaDoc).
# Set to NO to disable this.
 
BRIEF_MEMBER_DESC = YES
 
# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
# the brief description of a member or function before the detailed description.
# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
# brief descriptions will be completely suppressed.
 
REPEAT_BRIEF = YES
 
# This tag implements a quasi-intelligent brief description abbreviator
# that is used to form the text in various listings. Each string
# in this list, if found as the leading text of the brief description, will be
# stripped from the text and the result after processing the whole list, is
# used as the annotated text. Otherwise, the brief description is used as-is.
# If left blank, the following values are used ("$name" is automatically
# replaced with the name of the entity): "The $name class" "The $name widget"
# "The $name file" "is" "provides" "specifies" "contains"
# "represents" "a" "an" "the"
 
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
 
# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
# Doxygen will generate a detailed section even if there is only a brief
# description.
 
ALWAYS_DETAILED_SEC = NO
 
# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
# inherited members of a class in the documentation of that class as if those
# members were ordinary class members. Constructors, destructors and assignment
# operators of the base classes will not be shown.
 
INLINE_INHERITED_MEMB = NO
 
# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
# path before files name in the file list and in the header files. If set
# to NO the shortest path that makes the file name unique will be used.
 
FULL_PATH_NAMES = YES
 
# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
# can be used to strip a user-defined part of the path. Stripping is
# only done if one of the specified strings matches the left-hand part of
# the path. The tag can be used to show relative paths in the file list.
# If left blank the directory from which doxygen is run is used as the
# path to strip.
 
STRIP_FROM_PATH =
 
# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
# the path mentioned in the documentation of a class, which tells
# the reader which header file to include in order to use a class.
# If left blank only the name of the header file containing the class
# definition is used. Otherwise one should specify the include paths that
# are normally passed to the compiler using the -I flag.
 
STRIP_FROM_INC_PATH =
 
# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
# (but less readable) file names. This can be useful if your file system
# doesn't support long names like on DOS, Mac, or CD-ROM.
 
SHORT_NAMES = NO
 
# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
# will interpret the first line (until the first dot) of a JavaDoc-style
# comment as the brief description. If set to NO, the JavaDoc
# comments will behave just like regular Qt-style comments
# (thus requiring an explicit @brief command for a brief description.)
 
JAVADOC_AUTOBRIEF = NO
 
# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
# interpret the first line (until the first dot) of a Qt-style
# comment as the brief description. If set to NO, the comments
# will behave just like regular Qt-style comments (thus requiring
# an explicit \brief command for a brief description.)
 
QT_AUTOBRIEF = NO
 
# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
# treat a multi-line C++ special comment block (i.e. a block of //! or ///
# comments) as a brief description. This used to be the default behaviour.
# The new default is to treat a multi-line C++ comment block as a detailed
# description. Set this tag to YES if you prefer the old behaviour instead.
 
MULTILINE_CPP_IS_BRIEF = NO
 
# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
# member inherits the documentation from any documented member that it
# re-implements.
 
INHERIT_DOCS = YES
 
# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
# a new page for each member. If set to NO, the documentation of a member will
# be part of the file/class/namespace that contains it.
 
SEPARATE_MEMBER_PAGES = NO
 
# The TAB_SIZE tag can be used to set the number of spaces in a tab.
# Doxygen uses this value to replace tabs by spaces in code fragments.
 
TAB_SIZE = 8
 
# This tag can be used to specify a number of aliases that acts
# as commands in the documentation. An alias has the form "name=value".
# For example adding "sideeffect=\par Side Effects:\n" will allow you to
# put the command \sideeffect (or @sideeffect) in the documentation, which
# will result in a user-defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines.
 
ALIASES =
 
# This tag can be used to specify a number of word-keyword mappings (TCL only).
# A mapping has the form "name=value". For example adding
# "class=itcl::class" will allow you to use the command class in the
# itcl::class meaning.
 
TCL_SUBST =
 
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
# sources only. Doxygen will then generate output that is more tailored for C.
# For instance, some of the names that are used will be different. The list
# of all members will be omitted, etc.
 
OPTIMIZE_OUTPUT_FOR_C = YES
 
# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
# sources only. Doxygen will then generate output that is more tailored for
# Java. For instance, namespaces will be presented as packages, qualified
# scopes will look different, etc.
 
OPTIMIZE_OUTPUT_JAVA = NO
 
# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
# sources only. Doxygen will then generate output that is more tailored for
# Fortran.
 
OPTIMIZE_FOR_FORTRAN = NO
 
# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
# sources. Doxygen will then generate output that is tailored for
# VHDL.
 
OPTIMIZE_OUTPUT_VHDL = NO
 
# Doxygen selects the parser to use depending on the extension of the files it
# parses. With this tag you can assign which parser to use for a given extension.
# Doxygen has a built-in mapping, but you can override or extend it using this
# tag. The format is ext=language, where ext is a file extension, and language
# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C,
# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make
# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C
# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions
# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
 
EXTENSION_MAPPING =
 
# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
# to include (a tag file for) the STL sources as input, then you should
# set this tag to YES in order to let doxygen match functions declarations and
# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
# func(std::string) {}). This also makes the inheritance and collaboration
# diagrams that involve STL classes more complete and accurate.
 
BUILTIN_STL_SUPPORT = NO
 
# If you use Microsoft's C++/CLI language, you should set this option to YES to
# enable parsing support.
 
CPP_CLI_SUPPORT = NO
 
# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
# Doxygen will parse them like normal C++ but will assume all classes use public
# instead of private inheritance when no explicit protection keyword is present.
 
SIP_SUPPORT = NO
 
# For Microsoft's IDL there are propget and propput attributes to indicate getter
# and setter methods for a property. Setting this option to YES (the default)
# will make doxygen replace the get and set methods by a property in the
# documentation. This will only work if the methods are indeed getting or
# setting a simple type. If this is not the case, or you want to show the
# methods anyway, you should set this option to NO.
 
IDL_PROPERTY_SUPPORT = YES
 
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
# tag is set to YES, then doxygen will reuse the documentation of the first
# member in the group (if any) for the other members of the group. By default
# all members of a group must be documented explicitly.
 
DISTRIBUTE_GROUP_DOC = NO
 
# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
# the same type (for instance a group of public functions) to be put as a
# subgroup of that type (e.g. under the Public Functions section). Set it to
# NO to prevent subgrouping. Alternatively, this can be done per class using
# the \nosubgrouping command.
 
SUBGROUPING = YES
 
# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
# unions are shown inside the group in which they are included (e.g. using
# @ingroup) instead of on a separate page (for HTML and Man pages) or
# section (for LaTeX and RTF).
 
INLINE_GROUPED_CLASSES = NO
 
# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and
# unions with only public data fields will be shown inline in the documentation
# of the scope in which they are defined (i.e. file, namespace, or group
# documentation), provided this scope is documented. If set to NO (the default),
# structs, classes, and unions are shown on a separate page (for HTML and Man
# pages) or section (for LaTeX and RTF).
 
INLINE_SIMPLE_STRUCTS = NO
 
# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
# is documented as struct, union, or enum with the name of the typedef. So
# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
# with name TypeT. When disabled the typedef will appear as a member of a file,
# namespace, or class. And the struct will be named TypeS. This can typically
# be useful for C code in case the coding convention dictates that all compound
# types are typedef'ed and only the typedef is referenced, never the tag name.
 
TYPEDEF_HIDES_STRUCT = NO
 
# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
# determine which symbols to keep in memory and which to flush to disk.
# When the cache is full, less often used symbols will be written to disk.
# For small to medium size projects (<1000 input files) the default value is
# probably good enough. For larger projects a too small cache size can cause
# doxygen to be busy swapping symbols to and from disk most of the time
# causing a significant performance penalty.
# If the system has enough physical memory increasing the cache will improve the
# performance by keeping more symbols in memory. Note that the value works on
# a logarithmic scale so increasing the size by one will roughly double the
# memory usage. The cache size is given by this formula:
# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
# corresponding to a cache size of 2^16 = 65536 symbols.
 
SYMBOL_CACHE_SIZE = 0
 
# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be
# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given
# their name and scope. Since this can be an expensive process and often the
# same symbol appear multiple times in the code, doxygen keeps a cache of
# pre-resolved symbols. If the cache is too small doxygen will become slower.
# If the cache is too large, memory is wasted. The cache size is given by this
# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0,
# corresponding to a cache size of 2^16 = 65536 symbols.
 
LOOKUP_CACHE_SIZE = 0
 
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
 
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
# documentation are documented, even if no documentation was available.
# Private class members and static file members will be hidden unless
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
 
EXTRACT_ALL = NO
 
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
# will be included in the documentation.
 
EXTRACT_PRIVATE = NO
 
# If the EXTRACT_STATIC tag is set to YES all static members of a file
# will be included in the documentation.
 
EXTRACT_STATIC = NO
 
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
# defined locally in source files will be included in the documentation.
# If set to NO only classes defined in header files are included.
 
EXTRACT_LOCAL_CLASSES = YES
 
# This flag is only useful for Objective-C code. When set to YES local
# methods, which are defined in the implementation section but not in
# the interface are included in the documentation.
# If set to NO (the default) only methods in the interface are included.
 
EXTRACT_LOCAL_METHODS = NO
 
# If this flag is set to YES, the members of anonymous namespaces will be
# extracted and appear in the documentation as a namespace called
# 'anonymous_namespace{file}', where file will be replaced with the base
# name of the file that contains the anonymous namespace. By default
# anonymous namespaces are hidden.
 
EXTRACT_ANON_NSPACES = NO
 
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
# undocumented members of documented classes, files or namespaces.
# If set to NO (the default) these members will be included in the
# various overviews, but no documentation section is generated.
# This option has no effect if EXTRACT_ALL is enabled.
 
HIDE_UNDOC_MEMBERS = NO
 
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
# undocumented classes that are normally visible in the class hierarchy.
# If set to NO (the default) these classes will be included in the various
# overviews. This option has no effect if EXTRACT_ALL is enabled.
 
HIDE_UNDOC_CLASSES = NO
 
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
# friend (class|struct|union) declarations.
# If set to NO (the default) these declarations will be included in the
# documentation.
 
HIDE_FRIEND_COMPOUNDS = NO
 
# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
# documentation blocks found inside the body of a function.
# If set to NO (the default) these blocks will be appended to the
# function's detailed documentation block.
 
HIDE_IN_BODY_DOCS = NO
 
# The INTERNAL_DOCS tag determines if documentation
# that is typed after a \internal command is included. If the tag is set
# to NO (the default) then the documentation will be excluded.
# Set it to YES to include the internal documentation.
 
INTERNAL_DOCS = NO
 
# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
# file names in lower-case letters. If set to YES upper-case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
# and Mac users are advised to set this option to NO.
 
CASE_SENSE_NAMES = NO
 
# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
# will show members with their full class and namespace scopes in the
# documentation. If set to YES the scope will be hidden.
 
HIDE_SCOPE_NAMES = YES
 
# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
# will put a list of the files that are included by a file in the documentation
# of that file.
 
SHOW_INCLUDE_FILES = YES
 
# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
# will list include files with double quotes in the documentation
# rather than with sharp brackets.
 
FORCE_LOCAL_INCLUDES = NO
 
# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
# is inserted in the documentation for inline members.
 
INLINE_INFO = YES
 
# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
# will sort the (detailed) documentation of file and class members
# alphabetically by member name. If set to NO the members will appear in
# declaration order.
 
SORT_MEMBER_DOCS = YES
 
# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
# brief documentation of file, namespace and class members alphabetically
# by member name. If set to NO (the default) the members will appear in
# declaration order.
 
SORT_BRIEF_DOCS = NO
 
# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
# will sort the (brief and detailed) documentation of class members so that
# constructors and destructors are listed first. If set to NO (the default)
# the constructors will appear in the respective orders defined by
# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
 
SORT_MEMBERS_CTORS_1ST = NO
 
# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
# hierarchy of group names into alphabetical order. If set to NO (the default)
# the group names will appear in their defined order.
 
SORT_GROUP_NAMES = NO
 
# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
# sorted by fully-qualified names, including namespaces. If set to
# NO (the default), the class list will be sorted only by class name,
# not including the namespace part.
# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
# Note: This option applies only to the class list, not to the
# alphabetical list.
 
SORT_BY_SCOPE_NAME = NO
 
# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to
# do proper type resolution of all parameters of a function it will reject a
# match between the prototype and the implementation of a member function even
# if there is only one candidate or it is obvious which candidate to choose
# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen
# will still accept a match between prototype and implementation in such cases.
 
STRICT_PROTO_MATCHING = NO
 
# The GENERATE_TODOLIST tag can be used to enable (YES) or
# disable (NO) the todo list. This list is created by putting \todo
# commands in the documentation.
 
GENERATE_TODOLIST = YES
 
# The GENERATE_TESTLIST tag can be used to enable (YES) or
# disable (NO) the test list. This list is created by putting \test
# commands in the documentation.
 
GENERATE_TESTLIST = YES
 
# The GENERATE_BUGLIST tag can be used to enable (YES) or
# disable (NO) the bug list. This list is created by putting \bug
# commands in the documentation.
 
GENERATE_BUGLIST = YES
 
# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
# disable (NO) the deprecated list. This list is created by putting
# \deprecated commands in the documentation.
 
GENERATE_DEPRECATEDLIST= YES
 
# The ENABLED_SECTIONS tag can be used to enable conditional
# documentation sections, marked by \if sectionname ... \endif.
 
ENABLED_SECTIONS =
 
# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
# the initial value of a variable or macro consists of for it to appear in
# the documentation. If the initializer consists of more lines than specified
# here it will be hidden. Use a value of 0 to hide initializers completely.
# The appearance of the initializer of individual variables and macros in the
# documentation can be controlled using \showinitializer or \hideinitializer
# command in the documentation regardless of this setting.
 
MAX_INITIALIZER_LINES = 30
 
# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
# at the bottom of the documentation of classes and structs. If set to YES the
# list will mention the files that were used to generate the documentation.
 
SHOW_USED_FILES = YES
 
# If the sources in your project are distributed over multiple directories
# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
# in the documentation. The default is NO.
 
SHOW_DIRECTORIES = NO
 
# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
# This will remove the Files entry from the Quick Index and from the
# Folder Tree View (if specified). The default is YES.
 
SHOW_FILES = YES
 
# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
# Namespaces page. This will remove the Namespaces entry from the Quick Index
# and from the Folder Tree View (if specified). The default is YES.
 
SHOW_NAMESPACES = YES
 
# The FILE_VERSION_FILTER tag can be used to specify a program or script that
# doxygen should invoke to get the current version for each file (typically from
# the version control system). Doxygen will invoke the program by executing (via
# popen()) the command <command> <input-file>, where <command> is the value of
# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
# provided by doxygen. Whatever the program writes to standard output
# is used as the file version. See the manual for examples.
 
FILE_VERSION_FILTER =
 
# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
# by doxygen. The layout file controls the global structure of the generated
# output files in an output format independent way. The create the layout file
# that represents doxygen's defaults, run doxygen with the -l option.
# You can optionally specify a file name after the option, if omitted
# DoxygenLayout.xml will be used as the name of the layout file.
 
LAYOUT_FILE =
 
# The CITE_BIB_FILES tag can be used to specify one or more bib files
# containing the references data. This must be a list of .bib files. The
# .bib extension is automatically appended if omitted. Using this command
# requires the bibtex tool to be installed. See also
# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style
# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this
# feature you need bibtex and perl available in the search path.
 
CITE_BIB_FILES =
 
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
 
# The QUIET tag can be used to turn on/off the messages that are generated
# by doxygen. Possible values are YES and NO. If left blank NO is used.
 
QUIET = NO
 
# The WARNINGS tag can be used to turn on/off the warning messages that are
# generated by doxygen. Possible values are YES and NO. If left blank
# NO is used.
 
WARNINGS = YES
 
# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
# automatically be disabled.
 
WARN_IF_UNDOCUMENTED = YES
 
# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
# potential errors in the documentation, such as not documenting some
# parameters in a documented function, or documenting parameters that
# don't exist or using markup commands wrongly.
 
WARN_IF_DOC_ERROR = YES
 
# The WARN_NO_PARAMDOC option can be enabled to get warnings for
# functions that are documented, but have no documentation for their parameters
# or return value. If set to NO (the default) doxygen will only warn about
# wrong or incomplete parameter documentation, but not about the absence of
# documentation.
 
WARN_NO_PARAMDOC = NO
 
# The WARN_FORMAT tag determines the format of the warning messages that
# doxygen can produce. The string should contain the $file, $line, and $text
# tags, which will be replaced by the file and line number from which the
# warning originated and the warning text. Optionally the format may contain
# $version, which will be replaced by the version of the file (if it could
# be obtained via FILE_VERSION_FILTER)
 
WARN_FORMAT = "$file:$line: $text"
 
# The WARN_LOGFILE tag can be used to specify a file to which warning
# and error messages should be written. If left blank the output is written
# to stderr.
 
WARN_LOGFILE =
 
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
 
# The INPUT tag can be used to specify the files and/or directories that contain
# documented source files. You may enter file names like "myfile.cpp" or
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
 
INPUT = ./
 
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
# also the default input encoding. Doxygen uses libiconv (or the iconv built
# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
# the list of possible encodings.
 
INPUT_ENCODING = UTF-8
 
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank the following patterns are tested:
# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh
# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
# *.f90 *.f *.for *.vhd *.vhdl
 
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.d \
*.java \
*.ii \
*.ixx \
*.ipp \
*.i++ \
*.inl \
*.h \
*.hh \
*.hxx \
*.hpp \
*.h++ \
*.idl \
*.odl \
*.cs \
*.php \
*.php3 \
*.inc \
*.m \
*.mm \
*.dox \
*.py \
*.f90 \
*.f \
*.for \
*.vhd \
*.vhdl
 
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
# If left blank NO is used.
 
RECURSIVE = YES
 
# The EXCLUDE tag can be used to specify files and/or directories that should be
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
# Note that relative paths are relative to the directory from which doxygen is
# run.
 
EXCLUDE =
 
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
# from the input.
 
EXCLUDE_SYMLINKS = NO
 
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
# certain files from those directories. Note that the wildcards are matched
# against the file with absolute path, so to exclude all test directories
# for example use the pattern */test/*
 
EXCLUDE_PATTERNS =
 
# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
# output. The symbol name can be a fully qualified name, a word, or if the
# wildcard * is used, a substring. Examples: ANamespace, AClass,
# AClass::ANamespace, ANamespace::*Test
 
EXCLUDE_SYMBOLS =
 
# The EXAMPLE_PATH tag can be used to specify one or more files or
# directories that contain example code fragments that are included (see
# the \include command).
 
EXAMPLE_PATH =
 
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# and *.h) to filter out the source-files in the directories. If left
# blank all files are included.
 
EXAMPLE_PATTERNS = *
 
# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
# searched for input files to be used with the \include or \dontinclude
# commands irrespective of the value of the RECURSIVE tag.
# Possible values are YES and NO. If left blank NO is used.
 
EXAMPLE_RECURSIVE = NO
 
# The IMAGE_PATH tag can be used to specify one or more files or
# directories that contain image that are included in the documentation (see
# the \image command).
 
IMAGE_PATH =
 
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
# by executing (via popen()) the command <filter> <input-file>, where <filter>
# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
# input file. Doxygen will then use the output that the filter program writes
# to standard output. If FILTER_PATTERNS is specified, this tag will be
# ignored.
 
INPUT_FILTER =
 
# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
# basis. Doxygen will compare the file name with each pattern and apply the
# filter if there is a match. The filters are a list of the form:
# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
# info on how filters are used. If FILTER_PATTERNS is empty or if
# non of the patterns match the file name, INPUT_FILTER is applied.
 
FILTER_PATTERNS =
 
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
# INPUT_FILTER) will be used to filter the input files when producing source
# files to browse (i.e. when SOURCE_BROWSER is set to YES).
 
FILTER_SOURCE_FILES = NO
 
# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
# pattern. A pattern will override the setting for FILTER_PATTERN (if any)
# and it is also possible to disable source filtering for a specific pattern
# using *.ext= (so without naming a filter). This option only has effect when
# FILTER_SOURCE_FILES is enabled.
 
FILTER_SOURCE_PATTERNS =
 
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
 
# If the SOURCE_BROWSER tag is set to YES then a list of source files will
# be generated. Documented entities will be cross-referenced with these sources.
# Note: To get rid of all source code in the generated output, make sure also
# VERBATIM_HEADERS is set to NO.
 
SOURCE_BROWSER = NO
 
# Setting the INLINE_SOURCES tag to YES will include the body
# of functions and classes directly in the documentation.
 
INLINE_SOURCES = NO
 
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
# doxygen to hide any special comment blocks from generated source code
# fragments. Normal C and C++ comments will always remain visible.
 
STRIP_CODE_COMMENTS = YES
 
# If the REFERENCED_BY_RELATION tag is set to YES
# then for each documented function all documented
# functions referencing it will be listed.
 
REFERENCED_BY_RELATION = NO
 
# If the REFERENCES_RELATION tag is set to YES
# then for each documented function all documented entities
# called/used by that function will be listed.
 
REFERENCES_RELATION = NO
 
# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
# link to the source code. Otherwise they will link to the documentation.
 
REFERENCES_LINK_SOURCE = YES
 
# If the USE_HTAGS tag is set to YES then the references to source code
# will point to the HTML generated by the htags(1) tool instead of doxygen
# built-in source browser. The htags tool is part of GNU's global source
# tagging system (see http://www.gnu.org/software/global/global.html). You
# will need version 4.8.6 or higher.
 
USE_HTAGS = NO
 
# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
# will generate a verbatim copy of the header file for each class for
# which an include is specified. Set to NO to disable this.
 
VERBATIM_HEADERS = YES
 
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
 
# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
# of all compounds will be generated. Enable this if the project
# contains a lot of classes, structs, unions or interfaces.
 
ALPHABETICAL_INDEX = YES
 
# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
# in which this list will be split (can be a number in the range [1..20])
 
COLS_IN_ALPHA_INDEX = 5
 
# In case all classes in a project start with a common prefix, all
# classes will be put under the same header in the alphabetical index.
# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
# should be ignored while generating the index headers.
 
IGNORE_PREFIX =
 
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
 
# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
# generate HTML output.
 
GENERATE_HTML = YES
 
# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `html' will be used as the default path.
 
HTML_OUTPUT = html
 
# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
# doxygen will generate files with .html extension.
 
HTML_FILE_EXTENSION = .html
 
# The HTML_HEADER tag can be used to specify a personal HTML header for
# each generated HTML page. If it is left blank doxygen will generate a
# standard header. Note that when using a custom header you are responsible
# for the proper inclusion of any scripts and style sheets that doxygen
# needs, which is dependent on the configuration options used.
# It is advised to generate a default header using "doxygen -w html
# header.html footer.html stylesheet.css YourConfigFile" and then modify
# that header. Note that the header is subject to change so you typically
# have to redo this when upgrading to a newer version of doxygen or when
# changing the value of configuration settings such as GENERATE_TREEVIEW!
 
HTML_HEADER =
 
# The HTML_FOOTER tag can be used to specify a personal HTML footer for
# each generated HTML page. If it is left blank doxygen will generate a
# standard footer.
 
HTML_FOOTER =
 
# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
# style sheet that is used by each HTML page. It can be used to
# fine-tune the look of the HTML output. If the tag is left blank doxygen
# will generate a default style sheet. Note that doxygen will try to copy
# the style sheet file to the HTML output directory, so don't put your own
# style sheet in the HTML output directory as well, or it will be erased!
 
HTML_STYLESHEET =
 
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note
# that these files will be copied to the base HTML output directory. Use the
# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
# files. In the HTML_STYLESHEET file, use the file name only. Also note that
# the files will be copied as-is; there are no commands or markers available.
 
HTML_EXTRA_FILES =
 
# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
# Doxygen will adjust the colors in the style sheet and background images
# according to this color. Hue is specified as an angle on a colorwheel,
# see http://en.wikipedia.org/wiki/Hue for more information.
# For instance the value 0 represents red, 60 is yellow, 120 is green,
# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
# The allowed range is 0 to 359.
 
HTML_COLORSTYLE_HUE = 220
 
# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
# the colors in the HTML output. For a value of 0 the output will use
# grayscales only. A value of 255 will produce the most vivid colors.
 
HTML_COLORSTYLE_SAT = 100
 
# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
# the luminance component of the colors in the HTML output. Values below
# 100 gradually make the output lighter, whereas values above 100 make
# the output darker. The value divided by 100 is the actual gamma applied,
# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
# and 100 does not change the gamma.
 
HTML_COLORSTYLE_GAMMA = 80
 
# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
# page will contain the date and time when the page was generated. Setting
# this to NO can help when comparing the output of multiple runs.
 
HTML_TIMESTAMP = YES
 
# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
# files or namespaces will be aligned in HTML using tables. If set to
# NO a bullet list will be used.
 
HTML_ALIGN_MEMBERS = YES
 
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
# documentation will contain sections that can be hidden and shown after the
# page has loaded. For this to work a browser that supports
# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
 
HTML_DYNAMIC_SECTIONS = NO
 
# If the GENERATE_DOCSET tag is set to YES, additional index files
# will be generated that can be used as input for Apple's Xcode 3
# integrated development environment, introduced with OSX 10.5 (Leopard).
# To create a documentation set, doxygen will generate a Makefile in the
# HTML output directory. Running make will produce the docset in that
# directory and running "make install" will install the docset in
# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
# it at startup.
# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
# for more information.
 
GENERATE_DOCSET = NO
 
# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
# feed. A documentation feed provides an umbrella under which multiple
# documentation sets from a single provider (such as a company or product suite)
# can be grouped.
 
DOCSET_FEEDNAME = "Doxygen generated docs"
 
# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
# should uniquely identify the documentation set bundle. This should be a
# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
# will append .docset to the name.
 
DOCSET_BUNDLE_ID = org.doxygen.Project
 
# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify
# the documentation publisher. This should be a reverse domain-name style
# string, e.g. com.mycompany.MyDocSet.documentation.
 
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
 
# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
 
DOCSET_PUBLISHER_NAME = Publisher
 
# If the GENERATE_HTMLHELP tag is set to YES, additional index files
# will be generated that can be used as input for tools like the
# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
# of the generated HTML documentation.
 
GENERATE_HTMLHELP = NO
 
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
# be used to specify the file name of the resulting .chm file. You
# can add a path in front of the file if the result should not be
# written to the html output directory.
 
CHM_FILE =
 
# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
# be used to specify the location (absolute path including file name) of
# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
# the HTML help compiler on the generated index.hhp.
 
HHC_LOCATION =
 
# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
# controls if a separate .chi index file is generated (YES) or that
# it should be included in the master .chm file (NO).
 
GENERATE_CHI = NO
 
# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
# is used to encode HtmlHelp index (hhk), content (hhc) and project file
# content.
 
CHM_INDEX_ENCODING =
 
# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
# controls whether a binary table of contents is generated (YES) or a
# normal table of contents (NO) in the .chm file.
 
BINARY_TOC = NO
 
# The TOC_EXPAND flag can be set to YES to add extra items for group members
# to the contents of the HTML help documentation and to the tree view.
 
TOC_EXPAND = NO
 
# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
# that can be used as input for Qt's qhelpgenerator to generate a
# Qt Compressed Help (.qch) of the generated HTML documentation.
 
GENERATE_QHP = NO
 
# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
# be used to specify the file name of the resulting .qch file.
# The path specified is relative to the HTML output folder.
 
QCH_FILE =
 
# The QHP_NAMESPACE tag specifies the namespace to use when generating
# Qt Help Project output. For more information please see
# http://doc.trolltech.com/qthelpproject.html#namespace
 
QHP_NAMESPACE = org.doxygen.Project
 
# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
# Qt Help Project output. For more information please see
# http://doc.trolltech.com/qthelpproject.html#virtual-folders
 
QHP_VIRTUAL_FOLDER = doc
 
# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
# add. For more information please see
# http://doc.trolltech.com/qthelpproject.html#custom-filters
 
QHP_CUST_FILTER_NAME =
 
# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
# custom filter to add. For more information please see
# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">
# Qt Help Project / Custom Filters</a>.
 
QHP_CUST_FILTER_ATTRS =
 
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
# project's
# filter section matches.
# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">
# Qt Help Project / Filter Attributes</a>.
 
QHP_SECT_FILTER_ATTRS =
 
# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
# be used to specify the location of Qt's qhelpgenerator.
# If non-empty doxygen will try to run qhelpgenerator on the generated
# .qhp file.
 
QHG_LOCATION =
 
# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
# will be generated, which together with the HTML files, form an Eclipse help
# plugin. To install this plugin and make it available under the help contents
# menu in Eclipse, the contents of the directory containing the HTML and XML
# files needs to be copied into the plugins directory of eclipse. The name of
# the directory within the plugins directory should be the same as
# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
# the help appears.
 
GENERATE_ECLIPSEHELP = NO
 
# A unique identifier for the eclipse help plugin. When installing the plugin
# the directory name containing the HTML and XML files should also have
# this name.
 
ECLIPSE_DOC_ID = org.doxygen.Project
 
# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs)
# at top of each HTML page. The value NO (the default) enables the index and
# the value YES disables it. Since the tabs have the same information as the
# navigation tree you can set this option to NO if you already set
# GENERATE_TREEVIEW to YES.
 
DISABLE_INDEX = NO
 
# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
# structure should be generated to display hierarchical information.
# If the tag value is set to YES, a side panel will be generated
# containing a tree-like index structure (just like the one that
# is generated for HTML Help). For this to work a browser that supports
# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
# Windows users are probably better off using the HTML help feature.
# Since the tree basically has the same information as the tab index you
# could consider to set DISABLE_INDEX to NO when enabling this option.
 
GENERATE_TREEVIEW = YES
 
# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
# (range [0,1..20]) that doxygen will group on one line in the generated HTML
# documentation. Note that a value of 0 will completely suppress the enum
# values from appearing in the overview section.
 
ENUM_VALUES_PER_LINE = 4
 
# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
# and Class Hierarchy pages using a tree view instead of an ordered list.
 
USE_INLINE_TREES = NO
 
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
# used to set the initial width (in pixels) of the frame in which the tree
# is shown.
 
TREEVIEW_WIDTH = 250
 
# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
# links to external symbols imported via tag files in a separate window.
 
EXT_LINKS_IN_WINDOW = NO
 
# Use this tag to change the font size of Latex formulas included
# as images in the HTML documentation. The default is 10. Note that
# when you change the font size after a successful doxygen run you need
# to manually remove any form_*.png images from the HTML output directory
# to force them to be regenerated.
 
FORMULA_FONTSIZE = 10
 
# Use the FORMULA_TRANPARENT tag to determine whether or not the images
# generated for formulas are transparent PNGs. Transparent PNGs are
# not supported properly for IE 6.0, but are supported on all modern browsers.
# Note that when changing this option you need to delete any form_*.png files
# in the HTML output before the changes have effect.
 
FORMULA_TRANSPARENT = YES
 
# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax
# (see http://www.mathjax.org) which uses client side Javascript for the
# rendering instead of using prerendered bitmaps. Use this if you do not
# have LaTeX installed or if you want to formulas look prettier in the HTML
# output. When enabled you also need to install MathJax separately and
# configure the path to it using the MATHJAX_RELPATH option.
 
USE_MATHJAX = NO
 
# When MathJax is enabled you need to specify the location relative to the
# HTML output directory using the MATHJAX_RELPATH option. The destination
# directory should contain the MathJax.js script. For instance, if the mathjax
# directory is located at the same level as the HTML output directory, then
# MATHJAX_RELPATH should be ../mathjax. The default value points to the
# mathjax.org site, so you can quickly see the result without installing
# MathJax, but it is strongly recommended to install a local copy of MathJax
# before deployment.
 
MATHJAX_RELPATH = http://www.mathjax.org/mathjax
 
# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension
# names that should be enabled during MathJax rendering.
 
MATHJAX_EXTENSIONS =
 
# When the SEARCHENGINE tag is enabled doxygen will generate a search box
# for the HTML output. The underlying search engine uses javascript
# and DHTML and should work on any modern browser. Note that when using
# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
# (GENERATE_DOCSET) there is already a search function so this one should
# typically be disabled. For large projects the javascript based search engine
# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
 
SEARCHENGINE = YES
 
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
# implemented using a PHP enabled web server instead of at the web client
# using Javascript. Doxygen will generate the search PHP script and index
# file to put on the web server. The advantage of the server
# based approach is that it scales better to large projects and allows
# full text search. The disadvantages are that it is more difficult to setup
# and does not have live searching capabilities.
 
SERVER_BASED_SEARCH = NO
 
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
 
# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
# generate Latex output.
 
GENERATE_LATEX = NO
 
# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `latex' will be used as the default path.
 
LATEX_OUTPUT = latex
 
# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
# invoked. If left blank `latex' will be used as the default command name.
# Note that when enabling USE_PDFLATEX this option is only used for
# generating bitmaps for formulas in the HTML output, but not in the
# Makefile that is written to the output directory.
 
LATEX_CMD_NAME = latex
 
# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
# generate index for LaTeX. If left blank `makeindex' will be used as the
# default command name.
 
MAKEINDEX_CMD_NAME = makeindex
 
# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
# LaTeX documents. This may be useful for small projects and may help to
# save some trees in general.
 
COMPACT_LATEX = NO
 
# The PAPER_TYPE tag can be used to set the paper type that is used
# by the printer. Possible values are: a4, letter, legal and
# executive. If left blank a4wide will be used.
 
PAPER_TYPE = a4
 
# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
# packages that should be included in the LaTeX output.
 
EXTRA_PACKAGES =
 
# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
# the generated latex document. The header should contain everything until
# the first chapter. If it is left blank doxygen will generate a
# standard header. Notice: only use this tag if you know what you are doing!
 
LATEX_HEADER =
 
# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for
# the generated latex document. The footer should contain everything after
# the last chapter. If it is left blank doxygen will generate a
# standard footer. Notice: only use this tag if you know what you are doing!
 
LATEX_FOOTER =
 
# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
# is prepared for conversion to pdf (using ps2pdf). The pdf file will
# contain links (just like the HTML output) instead of page references
# This makes the output suitable for online browsing using a pdf viewer.
 
PDF_HYPERLINKS = YES
 
# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
# plain latex in the generated Makefile. Set this option to YES to get a
# higher quality PDF documentation.
 
USE_PDFLATEX = YES
 
# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
# command to the generated LaTeX files. This will instruct LaTeX to keep
# running if errors occur, instead of asking the user for help.
# This option is also used when generating formulas in HTML.
 
LATEX_BATCHMODE = NO
 
# If LATEX_HIDE_INDICES is set to YES then doxygen will not
# include the index chapters (such as File Index, Compound Index, etc.)
# in the output.
 
LATEX_HIDE_INDICES = NO
 
# If LATEX_SOURCE_CODE is set to YES then doxygen will include
# source code with syntax highlighting in the LaTeX output.
# Note that which sources are shown also depends on other settings
# such as SOURCE_BROWSER.
 
LATEX_SOURCE_CODE = NO
 
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See
# http://en.wikipedia.org/wiki/BibTeX for more info.
 
LATEX_BIB_STYLE = plain
 
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
 
# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
# The RTF output is optimized for Word 97 and may not look very pretty with
# other RTF readers or editors.
 
GENERATE_RTF = NO
 
# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `rtf' will be used as the default path.
 
RTF_OUTPUT = rtf
 
# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
# RTF documents. This may be useful for small projects and may help to
# save some trees in general.
 
COMPACT_RTF = NO
 
# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
# will contain hyperlink fields. The RTF file will
# contain links (just like the HTML output) instead of page references.
# This makes the output suitable for online browsing using WORD or other
# programs which support those fields.
# Note: wordpad (write) and others do not support links.
 
RTF_HYPERLINKS = NO
 
# Load style sheet definitions from file. Syntax is similar to doxygen's
# config file, i.e. a series of assignments. You only have to provide
# replacements, missing definitions are set to their default value.
 
RTF_STYLESHEET_FILE =
 
# Set optional variables used in the generation of an rtf document.
# Syntax is similar to doxygen's config file.
 
RTF_EXTENSIONS_FILE =
 
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
 
# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
# generate man pages
 
GENERATE_MAN = NO
 
# The MAN_OUTPUT tag is used to specify where the man pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `man' will be used as the default path.
 
MAN_OUTPUT = man
 
# The MAN_EXTENSION tag determines the extension that is added to
# the generated man pages (default is the subroutine's section .3)
 
MAN_EXTENSION = .3
 
# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
# then it will generate one additional man file for each entity
# documented in the real man page(s). These additional files
# only source the real man page, but without them the man command
# would be unable to find the correct page. The default is NO.
 
MAN_LINKS = NO
 
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
 
# If the GENERATE_XML tag is set to YES Doxygen will
# generate an XML file that captures the structure of
# the code including all documentation.
 
GENERATE_XML = NO
 
# The XML_OUTPUT tag is used to specify where the XML pages will be put.
# If a relative path is entered the value of OUTPUT_DIRECTORY will be
# put in front of it. If left blank `xml' will be used as the default path.
 
XML_OUTPUT = xml
 
# The XML_SCHEMA tag can be used to specify an XML schema,
# which can be used by a validating XML parser to check the
# syntax of the XML files.
 
XML_SCHEMA =
 
# The XML_DTD tag can be used to specify an XML DTD,
# which can be used by a validating XML parser to check the
# syntax of the XML files.
 
XML_DTD =
 
# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
# dump the program listings (including syntax highlighting
# and cross-referencing information) to the XML output. Note that
# enabling this will significantly increase the size of the XML output.
 
XML_PROGRAMLISTING = YES
 
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
 
# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
# generate an AutoGen Definitions (see autogen.sf.net) file
# that captures the structure of the code including all
# documentation. Note that this feature is still experimental
# and incomplete at the moment.
 
GENERATE_AUTOGEN_DEF = NO
 
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
 
# If the GENERATE_PERLMOD tag is set to YES Doxygen will
# generate a Perl module file that captures the structure of
# the code including all documentation. Note that this
# feature is still experimental and incomplete at the
# moment.
 
GENERATE_PERLMOD = NO
 
# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
# the necessary Makefile rules, Perl scripts and LaTeX code to be able
# to generate PDF and DVI output from the Perl module output.
 
PERLMOD_LATEX = NO
 
# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
# nicely formatted so it can be parsed by a human reader. This is useful
# if you want to understand what is going on. On the other hand, if this
# tag is set to NO the size of the Perl module output will be much smaller
# and Perl will parse it just the same.
 
PERLMOD_PRETTY = YES
 
# The names of the make variables in the generated doxyrules.make file
# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
# This is useful so different doxyrules.make files included by the same
# Makefile don't overwrite each other's variables.
 
PERLMOD_MAKEVAR_PREFIX =
 
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
 
# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
# evaluate all C-preprocessor directives found in the sources and include
# files.
 
ENABLE_PREPROCESSING = YES
 
# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
# names in the source code. If set to NO (the default) only conditional
# compilation will be performed. Macro expansion can be done in a controlled
# way by setting EXPAND_ONLY_PREDEF to YES.
 
MACRO_EXPANSION = NO
 
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
# then the macro expansion is limited to the macros specified with the
# PREDEFINED and EXPAND_AS_DEFINED tags.
 
EXPAND_ONLY_PREDEF = NO
 
# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
# pointed to by INCLUDE_PATH will be searched when a #include is found.
 
SEARCH_INCLUDES = YES
 
# The INCLUDE_PATH tag can be used to specify one or more directories that
# contain include files that are not input files but should be processed by
# the preprocessor.
 
INCLUDE_PATH =
 
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
# directories. If left blank, the patterns specified with FILE_PATTERNS will
# be used.
 
INCLUDE_FILE_PATTERNS =
 
# The PREDEFINED tag can be used to specify one or more macro names that
# are defined before the preprocessor is started (similar to the -D option of
# gcc). The argument of the tag is a list of macros of the form: name
# or name=definition (no spaces). If the definition and the = are
# omitted =1 is assumed. To prevent a macro definition from being
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.
 
PREDEFINED =
 
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
# The macro definition that is found in the sources will be used.
# Use the PREDEFINED tag if you want to use a different macro definition that
# overrules the definition found in the source code.
 
EXPAND_AS_DEFINED =
 
# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
# doxygen's preprocessor will remove all references to function-like macros
# that are alone on a line, have an all uppercase name, and do not end with a
# semicolon, because these will confuse the parser if not removed.
 
SKIP_FUNCTION_MACROS = YES
 
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
 
# The TAGFILES option can be used to specify one or more tagfiles.
# Optionally an initial location of the external documentation
# can be added for each tagfile. The format of a tag file without
# this location is as follows:
# TAGFILES = file1 file2 ...
# Adding location for the tag files is done as follows:
# TAGFILES = file1=loc1 "file2 = loc2" ...
# where "loc1" and "loc2" can be relative or absolute paths or
# URLs. If a location is present for each tag, the installdox tool
# does not have to be run to correct the links.
# Note that each tag file must have a unique name
# (where the name does NOT include the path)
# If a tag file is not located in the directory in which doxygen
# is run, you must also specify the path to the tagfile here.
 
TAGFILES =
 
# When a file name is specified after GENERATE_TAGFILE, doxygen will create
# a tag file that is based on the input files it reads.
 
GENERATE_TAGFILE =
 
# If the ALLEXTERNALS tag is set to YES all external classes will be listed
# in the class index. If set to NO only the inherited external classes
# will be listed.
 
ALLEXTERNALS = NO
 
# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
# in the modules index. If set to NO, only the current project's groups will
# be listed.
 
EXTERNAL_GROUPS = YES
 
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of `which perl').
 
PERL_PATH = /usr/bin/perl
 
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
 
# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
# or super classes. Setting the tag to NO turns the diagrams off. Note that
# this option also works with HAVE_DOT disabled, but it is recommended to
# install and use dot, since it yields more powerful graphs.
 
CLASS_DIAGRAMS = NO
 
# You can define message sequence charts within doxygen comments using the \msc
# command. Doxygen will then run the mscgen tool (see
# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
# documentation. The MSCGEN_PATH tag allows you to specify the directory where
# the mscgen tool resides. If left empty the tool is assumed to be found in the
# default search path.
 
MSCGEN_PATH =
 
# If set to YES, the inheritance and collaboration graphs will hide
# inheritance and usage relations if the target is undocumented
# or is not a class.
 
HIDE_UNDOC_RELATIONS = YES
 
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
# available from the path. This tool is part of Graphviz, a graph visualization
# toolkit from AT&T and Lucent Bell Labs. The other options in this section
# have no effect if this option is set to NO (the default)
 
HAVE_DOT = YES
 
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
# allowed to run in parallel. When set to 0 (the default) doxygen will
# base this on the number of processors available in the system. You can set it
# explicitly to a value larger than 0 to get control over the balance
# between CPU load and processing speed.
 
DOT_NUM_THREADS = 0
 
# By default doxygen will use the Helvetica font for all dot files that
# doxygen generates. When you want a differently looking font you can specify
# the font name using DOT_FONTNAME. You need to make sure dot is able to find
# the font, which can be done by putting it in a standard location or by setting
# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
# directory containing the font.
 
DOT_FONTNAME = Helvetica
 
# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
# The default size is 10pt.
 
DOT_FONTSIZE = 10
 
# By default doxygen will tell dot to use the Helvetica font.
# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to
# set the path where dot can find it.
 
DOT_FONTPATH =
 
# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect inheritance relations. Setting this tag to YES will force the
# CLASS_DIAGRAMS tag to NO.
 
CLASS_GRAPH = YES
 
# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for each documented class showing the direct and
# indirect implementation dependencies (inheritance, containment, and
# class references variables) of the class with other documented classes.
 
COLLABORATION_GRAPH = YES
 
# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
# will generate a graph for groups, showing the direct groups dependencies
 
GROUP_GRAPHS = YES
 
# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
# collaboration diagrams in a style similar to the OMG's Unified Modeling
# Language.
 
UML_LOOK = NO
 
# If set to YES, the inheritance and collaboration graphs will show the
# relations between templates and their instances.
 
TEMPLATE_RELATIONS = NO
 
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
# tags are set to YES then doxygen will generate a graph for each documented
# file showing the direct and indirect include dependencies of the file with
# other documented files.
 
INCLUDE_GRAPH = YES
 
# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
# documented header file showing the documented files that directly or
# indirectly include this file.
 
INCLUDED_BY_GRAPH = YES
 
# If the CALL_GRAPH and HAVE_DOT options are set to YES then
# doxygen will generate a call dependency graph for every global function
# or class method. Note that enabling this option will significantly increase
# the time of a run. So in most cases it will be better to enable call graphs
# for selected functions only using the \callgraph command.
 
CALL_GRAPH = YES
 
# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
# doxygen will generate a caller dependency graph for every global function
# or class method. Note that enabling this option will significantly increase
# the time of a run. So in most cases it will be better to enable caller
# graphs for selected functions only using the \callergraph command.
 
CALLER_GRAPH = YES
 
# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
# will generate a graphical hierarchy of all classes instead of a textual one.
 
GRAPHICAL_HIERARCHY = YES
 
# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
# then doxygen will show the dependencies a directory has on other directories
# in a graphical way. The dependency relations are determined by the #include
# relations between the files in the directories.
 
DIRECTORY_GRAPH = YES
 
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
# generated by dot. Possible values are svg, png, jpg, or gif.
# If left blank png will be used. If you choose svg you need to set
# HTML_FILE_EXTENSION to xhtml in order to make the SVG files
# visible in IE 9+ (other browsers do not have this requirement).
 
DOT_IMAGE_FORMAT = png
 
# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
# enable generation of interactive SVG images that allow zooming and panning.
# Note that this requires a modern browser other than Internet Explorer.
# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you
# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files
# visible. Older versions of IE do not have SVG support.
 
INTERACTIVE_SVG = NO
 
# The tag DOT_PATH can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found in the path.
 
DOT_PATH =
 
# The DOTFILE_DIRS tag can be used to specify one or more directories that
# contain dot files that are included in the documentation (see the
# \dotfile command).
 
DOTFILE_DIRS =
 
# The MSCFILE_DIRS tag can be used to specify one or more directories that
# contain msc files that are included in the documentation (see the
# \mscfile command).
 
MSCFILE_DIRS =
 
# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
# nodes that will be shown in the graph. If the number of nodes in a graph
# becomes larger than this value, doxygen will truncate the graph, which is
# visualized by representing a node as a red box. Note that doxygen if the
# number of direct children of the root node in a graph is already larger than
# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
 
DOT_GRAPH_MAX_NODES = 50
 
# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
# graphs generated by dot. A depth value of 3 means that only nodes reachable
# from the root by following a path via at most 3 edges will be shown. Nodes
# that lay further from the root node will be omitted. Note that setting this
# option to 1 or 2 may greatly reduce the computation time needed for large
# code bases. Also note that the size of a graph can be further restricted by
# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
 
MAX_DOT_GRAPH_DEPTH = 0
 
# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
# background. This is disabled by default, because dot on Windows does not
# seem to support this out of the box. Warning: Depending on the platform used,
# enabling this option may lead to badly anti-aliased labels on the edges of
# a graph (i.e. they become hard to read).
 
DOT_TRANSPARENT = NO
 
# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
# files in one run (i.e. multiple -o and -T options on the command line). This
# makes dot run faster, but since only newer versions of dot (>1.8.10)
# support this, this feature is disabled by default.
 
DOT_MULTI_TARGETS = NO
 
# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
# generate a legend page explaining the meaning of the various boxes and
# arrows in the dot generated graphs.
 
GENERATE_LEGEND = YES
 
# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
# remove the intermediate dot files that are used to generate
# the various graphs.
 
DOT_CLEANUP = YES
/trunk/libraries/max7219/demo/max7219__demo.c
0,0 → 1,75
/**************************************************************************//**
* \brief USART library - Demonstration program
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090314
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file demo_max7219.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <max7219/max7219.h>
 
#include <util/delay.h>
 
#include <stdbool.h>
#include <stdlib.h>
 
/******************************************************************************
* Main function.
******************************************************************************/
 
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
******************************************************************************/
int
main
(
void
){
// Initialize and configure MAX7219.
max7219__initialize();
max7219__set_scan_limit(max7219__scan_limit__digit_0_to_7);
max7219__set_intensity(max7219__intensity__level_15);
max7219__set_decode_mode(max7219__decode_mode__all_digits);
 
// Switch on MAX7219 display.
max7219__set_shutdown_mode(max7219__shutdown_mode__normal_operation);
 
// Write values on digits.
 
max7219__write_char_on_digit(max7219__digit__0, max7219__character__zero, false);
max7219__write_char_on_digit(max7219__digit__1, max7219__character__one, true);
max7219__write_char_on_digit(max7219__digit__2, max7219__character__two, false);
max7219__write_char_on_digit(max7219__digit__3, max7219__character__three, true);
max7219__write_char_on_digit(max7219__digit__4, max7219__character__four, false);
max7219__write_char_on_digit(max7219__digit__5, max7219__character__five, true);
max7219__write_char_on_digit(max7219__digit__6, max7219__character__six, false);
max7219__write_char_on_digit(max7219__digit__7, max7219__character__seven, true);
 
for (;;);
 
return 0;
}
/trunk/libraries/max7219/src/SConscript
0,0 → 1,13
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'max7219'
 
# Define source files.
sources = [
'max7219.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/max7219/src/max7219.c
0,0 → 1,269
/**************************************************************************//**
* \brief MAX7219 library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20110908
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file max7219.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../max7219.h"
 
#include <digital_io/digital_io.h>
#include <spi/spi.h>
 
#include <util/delay.h>
 
#include <stdbool.h>
#include <stdint.h>
 
/******************************************************************************
* Private macros.
******************************************************************************/
 
#define REG_NO_OP 0x00
#define REG_DIGIT_0 0x01
#define REG_DIGIT_1 0x02
#define REG_DIGIT_2 0x03
#define REG_DIGIT_3 0x04
#define REG_DIGIT_4 0x05
#define REG_DIGIT_5 0x06
#define REG_DIGIT_6 0x07
#define REG_DIGIT_7 0x08
#define REG_DECODE_MODE 0x09
#define REG_INTENSITY 0x0A
#define REG_SCAN_LIMIT 0x0B
#define REG_SHUTDOWN 0x0C
#define REG_DISPLAY_TEST 0x0F
 
/******************************************************************************
* Private constants.
******************************************************************************/
 
static const digital_io__pin_position_t chip_select_pin =
DIGITAL_IO__PORT_B | DIGITAL_IO__PIN_2;
 
/******************************************************************************
* Private function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void max7219__write(uint8_t address, uin8_t value)
*
* \brief Write value into MAX7219 register.
*
* \param address Register address.
* \param value Value to write.
******************************************************************************/
void
max7219__write
(
uint8_t address,
uint8_t value
);
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void max7219__initialize(void)
*
* \brief Initialize SPI to drive MAX7219.
******************************************************************************/
void
max7219__initialize
(
void
){
// Configure chip select pin as output.
digital_io__configure_pin(chip_select_pin, DIGITAL_IO__DIRECTION__OUTPUT);
digital_io__set_pin_level(chip_select_pin, DIGITAL_IO__LEVEL__HIGH);
// Wait a little to allow MAX7219 to see a correct logic level on CS pin.
_delay_ms(2);
// Configure SPI.
spi_master__initialize();
spi__set_data_order(SPI__DATA_ORDER__MSB_FIRST);
spi__set_data_mode(SPI__DATA_MODE_0);
spi__set_clock_rate(SPI__CLOCK_RATE__FOSC_OVER_4);
}
 
/**************************************************************************//**
* \fn void max7219__set_decode_mode(max7219__decode_mode_t mode)
*
* \brief Set MAX7219 decode mode.
*
* \param mode Decode mode to set.
******************************************************************************/
void
max7219__set_decode_mode
(
max7219__decode_mode_t mode
){
max7219__write(REG_DECODE_MODE, mode);
}
 
/**************************************************************************//**
* \fn void max7219__set_intensity(max7219__intensity_t intensity)
*
* \brief Set MAX7219 intensity.
*
* \param intensity Intensity to set.
******************************************************************************/
void
max7219__set_intensity
(
max7219__intensity_t intensity
){
max7219__write(REG_INTENSITY, intensity);
}
 
/**************************************************************************//**
* \fn void max7219__set_scan_limit(max7219__scan_limit_t limit)
*
* \brief Set MAX7219 scan limit.
*
* \param limit Scan limit to set.
******************************************************************************/
void
max7219__set_scan_limit
(
max7219__scan_limit_t limit
){
max7219__write(REG_SCAN_LIMIT, limit);
}
 
/**************************************************************************//**
* \fn void max7219__set_shutdown_mode(max7219__shutdown_mode_t mode)
*
* \brief Set MAX7219 shutdown mode.
*
* \param mode Shutdown mode to set.
******************************************************************************/
void
max7219__set_shutdown_mode
(
max7219__shutdown_mode_t mode
){
max7219__write(REG_SHUTDOWN, mode);
}
 
/**************************************************************************//**
* \fn void max7219__set_display_test_mode(max7219__display_test_mode_t mode)
*
* \brief Set MAX7219 display test mode.
*
* \param mode Display test mode to set.
*****************************************************************************/
void
max7219__set_display_test_mode
(
max7219__display_test_mode_t mode
){
max7219__write(REG_DISPLAY_TEST, mode);
}
 
/**************************************************************************//**
* \fn void max7219__write_char_on_digit(
* max7219__digit_t digit,
* max7219__character_t character,
* bool decimal_point)
*
* \brief Write character on digit.
*
* \param digit Digit to write.
* \param character Character to write.
* \param decimal_point Display decimal point.
******************************************************************************/
void
max7219__write_char_on_digit
(
max7219__digit_t digit,
max7219__character_t character,
bool decimal_point
){
uint8_t value = character;
if (decimal_point)
{
// If decimal point must be switched on.
value |= max7219__segment__DP;
}
max7219__write(digit, value);
}
 
/**************************************************************************//**
* \fn void max7219__write_segments_on_digit(
* max7219__digit_t digit,
* max7219__segment_t segments)
*
* \brief Set segment(s) on digit.
*
* \param digit Digit to write.
* \param segment Segment(s) to set.
******************************************************************************/
void
max7219__write_segments_on_digit
(
max7219__digit_t digit,
max7219__segment_t segments
){
max7219__write(digit, segments);
}
 
/******************************************************************************
* Private function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void max7219__write(uint8_t address, uint8_t value)
*
* \brief Write value into MAX7219 register.
*
* \param address Register address.
* \param value Value to write.
******************************************************************************/
void
max7219__write
(
uint8_t address,
uint8_t value
){
// Reset chip select pin to select the device.
digital_io__set_pin_level(chip_select_pin, DIGITAL_IO__LEVEL__LOW);
 
// tcss
_delay_ms(1);
 
// Transmit data to the device, register address and value.
spi_master__transmit(address);
spi_master__transmit(value);
 
// Set chip select pin to valid data onto the device.
digital_io__set_pin_level(chip_select_pin, DIGITAL_IO__LEVEL__HIGH);
 
// tcsw
_delay_ms(1);
}
/trunk/libraries/max7219/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/max7219/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/max7219/max7219.h
0,0 → 1,299
/**************************************************************************//**
* \brief MAX7219 library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20110908
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile max7219.h
******************************************************************************/
#ifndef H__IDREAMMICRO__MAX7219__H
#define H__IDREAMMICRO__MAX7219__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <stdbool.h>
 
/******************************************************************************
* Public types.
******************************************************************************/
 
/**************************************************************************//**
* \enum max7219__decode_modes
* \typedef max7219__decode_mode_t
******************************************************************************/
typedef enum max7219__decode_modes
{
max7219__decode_mode__none = 0x00,
max7219__decode_mode__digit_0 = 0x01,
max7219__decode_mode__digit_1 = 0x02,
max7219__decode_mode__digit_2 = 0x04,
max7219__decode_mode__digit_3 = 0x08,
max7219__decode_mode__digit_4 = 0x10,
max7219__decode_mode__digit_5 = 0x20,
max7219__decode_mode__digit_6 = 0x40,
max7219__decode_mode__digit_7 = 0x80,
max7219__decode_mode__all_digits = 0xFF
} max7219__decode_mode_t;
 
/**************************************************************************//**
* \enum max7219__intensities
* \typedef max7219__intensity_t
******************************************************************************/
typedef enum max7219__intensities
{
max7219__intensity__level_0 = 0x00,
max7219__intensity__level_1 = 0x01,
max7219__intensity__level_2 = 0x02,
max7219__intensity__level_3 = 0x03,
max7219__intensity__level_4 = 0x04,
max7219__intensity__level_5 = 0x05,
max7219__intensity__level_6 = 0x06,
max7219__intensity__level_7 = 0x07,
max7219__intensity__level_8 = 0x08,
max7219__intensity__level_9 = 0x09,
max7219__intensity__level_10 = 0x0A,
max7219__intensity__level_11 = 0x0B,
max7219__intensity__level_12 = 0x0C,
max7219__intensity__level_13 = 0x0D,
max7219__intensity__level_14 = 0x0E,
max7219__intensity__level_15 = 0x0F
} max7219__intensity_t;
 
/**************************************************************************//**
* \enum max7219__scan_limits
* \typedef max7219__scan_limit_t
******************************************************************************/
typedef enum max7219__scan_limits
{
max7219__scan_limit__digit_0 = 0x00,
max7219__scan_limit__digit_0_to_1 = 0x01,
max7219__scan_limit__digit_0_to_2 = 0x02,
max7219__scan_limit__digit_0_to_3 = 0x03,
max7219__scan_limit__digit_0_to_4 = 0x04,
max7219__scan_limit__digit_0_to_5 = 0x05,
max7219__scan_limit__digit_0_to_6 = 0x06,
max7219__scan_limit__digit_0_to_7 = 0x07
} max7219__scan_limit_t;
 
/**************************************************************************//**
* \enum max7219__shutdown_modes
* \typedef max7219__shutdown_mode_t
******************************************************************************/
typedef enum max7219__shutdown_modes
{
max7219__shutdown_mode__shutdown = 0x00,
max7219__shutdown_mode__normal_operation = 0x01
} max7219__shutdown_mode_t;
 
/**************************************************************************//**
* \enum max7219__display_test_modes
* \typedef max7219__display_test_mode_t
******************************************************************************/
typedef enum max7219__display_test_modes
{
max7219__display_test_mode__normal_operation = 0x00,
max7219__display_test_mode__test_mode = 0x01
} max7219__display_test_mode_t;
 
/**************************************************************************//**
* \enum max7219__digits
* \typedef max7219__digit_t
******************************************************************************/
typedef enum max7219__digits
{
max7219__digit__0 = 0x01,
max7219__digit__1 = 0x02,
max7219__digit__2 = 0x03,
max7219__digit__3 = 0x04,
max7219__digit__4 = 0x05,
max7219__digit__5 = 0x06,
max7219__digit__6 = 0x07,
max7219__digit__7 = 0x08
} max7219__digit_t;
 
/**************************************************************************//**
* \enum max7219__characters
* \typedef max7219__character_t
******************************************************************************/
typedef enum max7219__characters
{
max7219__character__zero = 0x00,
max7219__character__one = 0x01,
max7219__character__two = 0x02,
max7219__character__three = 0x03,
max7219__character__four = 0x04,
max7219__character__five = 0x05,
max7219__character__six = 0x06,
max7219__character__seven = 0x07,
max7219__character__eight = 0x08,
max7219__character__nine = 0x09,
max7219__character__dash = 0x0A,
max7219__character__e = 0x0B,
max7219__character__h = 0x0C,
max7219__character__l = 0x0D,
max7219__character__p = 0x0E,
max7219__character__blank = 0x0F
} max7219__character_t;
 
/**************************************************************************//**
* \enum max7219__segments
* \typedef max7219__segment_t
******************************************************************************/
typedef enum max7219__segments
{
max7219__segment__DP = 0x80,
max7219__segment__A = 0x40,
max7219__segment__B = 0x20,
max7219__segment__C = 0x10,
max7219__segment__D = 0x08,
max7219__segment__E = 0x04,
max7219__segment__F = 0x02,
max7219__segment__G = 0x01
} max7219__segment_t;
 
/******************************************************************************
* Public function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void max7219__initialize(void)
*
* \brief Initialize SPI to drive MAX7219.
******************************************************************************/
void
max7219__initialize
(
void
);
 
/**************************************************************************//**
* \fn void max7219__set_decode_mode(max7219__decode_mode_t mode)
*
* \brief Set MAX7219 decode mode.
*
* \param mode Decode mode to set.
******************************************************************************/
void
max7219__set_decode_mode
(
max7219__decode_mode_t mode
);
 
/**************************************************************************//**
* \fn void max7219__set_intensity(max7219__intensity_t intensity)
*
* \brief Set MAX7219 intensity.
*
* \param itensity Intensity to set.
******************************************************************************/
void
max7219__set_intensity
(
max7219__intensity_t intensity
);
 
/**************************************************************************//**
* \fn void max7219__set_scan_limit(max7219__scan_limit_t limit)
*
* \brief Set MAX7219 scan limit.
*
* \param limit Scan limit to set.
******************************************************************************/
void
max7219__set_scan_limit
(
max7219__scan_limit_t limit
);
 
/**************************************************************************//**
* \fn void max7219__set_shutdown_mode(max7219__shutdown_mode_t mode)
*
* \brief Set MAX7219 shutdown mode.
*
* \param mode Shutdown mode to set.
******************************************************************************/
void
max7219__set_shutdown_mode
(
max7219__shutdown_mode_t mode
);
 
/**************************************************************************//**
* \fn void max7219__set_display_test_mode(max7219__display_test_mode_t mode)
*
* \brief Set MAX7219 display test mode.
*
* \param mode Display test mode to set.
*****************************************************************************/
void
max7219__set_display_test_mode
(
max7219__display_test_mode_t mode
);
 
/**************************************************************************//**
* \fn void max7219__write_char_on_digit(
* max7219__digit_t digit,
* max7219__character_t character,
* bool decimal_point)
*
* \brief Write character on digit.
*
* \param digit Digit to write.
* \param character Character to write.
* \param decimal_point Display decimal point.
******************************************************************************/
void
max7219__write_char_on_digit
(
max7219__digit_t digit,
max7219__character_t character,
bool decimal_point
);
 
/**************************************************************************//**
* \fn void max7219__write_segments_on_digit(
* max7219__digit_t digit,
* max7219__segment_t segments)
*
* \brief Set segment(s) on digit.
*
* \param digit Digit to write.
* \param segment Segment(s) to set.
******************************************************************************/
void
max7219__write_segments_on_digit
(
max7219__digit_t digit,
max7219__segment_t segment
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__MAX7219__H */
/trunk/libraries/spi/spi.h
0,0 → 1,174
/**************************************************************************//**
* \brief SPI library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20110315
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile spi.h
******************************************************************************/
#ifndef H__IDREAMMICRO__SPI__H
#define H__IDREAMMICRO__SPI__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <stdint.h>
 
/******************************************************************************
* Public types.
******************************************************************************/
 
/**************************************************************************//**
*
******************************************************************************/
typedef enum spi__clock_rates
{
SPI__CLOCK_RATE__FOSC_OVER_2,
SPI__CLOCK_RATE__FOSC_OVER_4,
SPI__CLOCK_RATE__FOSC_OVER_8,
SPI__CLOCK_RATE__FOSC_OVER_16,
SPI__CLOCK_RATE__FOSC_OVER_32,
SPI__CLOCK_RATE__FOSC_OVER_64,
SPI__CLOCK_RATE__FOSC_OVER_128
} spi__clock_rate_t;
 
/**************************************************************************//**
*
******************************************************************************/
typedef enum spi__data_modes
{
SPI__DATA_MODE_0,
SPI__DATA_MODE_1,
SPI__DATA_MODE_2,
SPI__DATA_MODE_3
} spi__data_mode_t;
 
/**************************************************************************//**
*
******************************************************************************/
typedef enum spi__data_orders
{
SPI__DATA_ORDER__MSB_FIRST,
SPI__DATA_ORDER__LSB_FIRST
} spi__data_order_t;
 
/******************************************************************************
* Public function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void spi_master__initialize(void)
*
* \brief Initialize SPI in master mode.
******************************************************************************/
void
spi_master__initialize
(
void
);
 
/**************************************************************************//**
* \fn void spi_master__transmit(uint8_t data)
*
* \brief Transmit data.
*
* \param data Data to transmit.
******************************************************************************/
void
spi_master__transmit
(
uint8_t data
);
 
/**************************************************************************//**
* \fn void spi_slave__initialize(void)
*
* \brief Initialize SPI in slave mode.
******************************************************************************/
void
spi_slave__initialize
(
void
);
 
/**************************************************************************//**
* \fn uint8_t spi_slave__receive(void)
*
* \brief Receive data.
*
* \return Received data.
******************************************************************************/
uint8_t
spi_slave__receive
(
void
);
 
/**************************************************************************//**
* \fn void spi__set_clock_rate(spi__clock_rate_t clock_rate)
*
* \brief Set clock rate.
*
* \param[in] clock_rate Clock rate to set.
******************************************************************************/
void
spi__set_clock_rate
(
spi__clock_rate_t clock_rate
);
 
/**************************************************************************//**
* \fn void spi__set_data_mode(spi__data_mode_t mode)
*
* \brief Set SPI data mode.
*
* \param[in] mode Data mode to set.
******************************************************************************/
void
spi__set_data_mode
(
spi__data_mode_t data_mode
);
 
/**************************************************************************//**
* \fn void spi__set_data_order(spi__data_order_t data_order)
*
* \brief Set SPI data order.
*
* \param[in] data_order Data order to set.
******************************************************************************/
void
spi__set_data_order
(
spi__data_order_t data_order
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__SPI__H */
 
/trunk/libraries/spi/include/spi_atmega128.h
0,0 → 1,55
/**************************************************************************//**
* \brief SPI library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20110315
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile spi_atmega128.h
******************************************************************************/
#ifndef H__IDREAMMICRO__SPI_ATMEGA128__H
#define H__IDREAMMICRO__SPI_ATMEGA128__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <avr/io.h>
 
/******************************************************************************
* Public macros.
******************************************************************************/
 
#define DDR_SPI DDRB
#define DD_SS PB0
#define DD_SCK PB1
#define DD_MOSI PB2
#define DD_MISO PB3
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__SPI_ATMEGA128__H */
 
/trunk/libraries/spi/include/spi_atmega2560.h
0,0 → 1,55
/**************************************************************************//**
* \brief SPI library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20110315
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile spi_atmega2560.h
******************************************************************************/
#ifndef H__IDREAMMICRO__SPI_ATMEGA2560__H
#define H__IDREAMMICRO__SPI_ATMEGA2560__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <avr/io.h>
 
/******************************************************************************
* Public macros.
******************************************************************************/
 
#define DDR_SPI DDRB
#define DD_SS PB0
#define DD_SCK PB1
#define DD_MOSI PB2
#define DD_MISO PB3
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__SPI_ATMEGA2560__H */
 
/trunk/libraries/spi/include/spi_atmega328.h
0,0 → 1,55
/**************************************************************************//**
* \brief SPI library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20110315
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile spi_atmega328.h
******************************************************************************/
#ifndef H__IDREAMMICRO__SPI_ATMEGA328__H
#define H__IDREAMMICRO__SPI_ATMEGA328__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <avr/io.h>
 
/******************************************************************************
* Public macros.
******************************************************************************/
 
#define DDR_SPI DDRB
#define DD_SS PB2
#define DD_SCK PB5
#define DD_MOSI PB3
#define DD_MISO PB4
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__SPI_ATMEGA328__H */
 
/trunk/libraries/spi/src/spi_slave.c
0,0 → 1,85
/**************************************************************************//**
* \brief SPI library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20110315
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file spi_slave.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <spi/spi.h>
 
#include <useful/bits.h>
 
#include <avr/io.h>
 
#include <stdint.h>
 
#if defined (__AVR_ATmega128__)
#include "../include/spi_atmega128.h"
#elif defined (__AVR_ATmega328P__) || defined (__AVR_ATmega328__)
#include "../include/spi_atmega328.h"
#elif defined (__AVR_ATmega2560__)
#include "../include/spi_atmega2560.h"
#endif
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void spi_slave__initialize(void)
*
* \brief Initialize SPI in slave mode.
******************************************************************************/
void
spi_slave__initialize
(
void
){
// Configure pins.
DDR_SPI = _BV(DD_MISO);
 
// Enable SPI.
SPCR = _BV(SPE);
}
 
/**************************************************************************//**
* \fn uint8_t spi_slave__receive(void)
*
* \brief Receive data.
*
* \return Received data.
******************************************************************************/
uint8_t
spi_slave__receive
(
void
){
// Wait for previous transmission complete.
while (!(SPSR & (1 << SPIF)));
 
// Read data from SPI data register.
return SPDR;
}
/trunk/libraries/spi/src/SConscript
0,0 → 1,15
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'spi'
 
# Define source files.
sources = [
'spi.c',
'spi_master.c',
'spi_slave.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/spi/src/spi_master.c
0,0 → 1,85
/**************************************************************************//**
* \brief SPI library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20110315
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file spi_master.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <spi/spi.h>
 
#include <useful/bits.h>
 
#include <avr/io.h>
 
#include <stdint.h>
 
#if defined (__AVR_ATmega128__)
#include "../include/spi_atmega128.h"
#elif defined (__AVR_ATmega328P__) || defined (__AVR_ATmega328__)
#include "../include/spi_atmega328.h"
#elif defined (__AVR_ATmega2560__)
#include "../include/spi_atmega2560.h"
#endif
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void spi_master__initialize(void)
*
* \brief Initialize SPI in master mode.
******************************************************************************/
void
spi_master__initialize
(
void
){
// Configure pins.
DDR_SPI |= _BV(DD_MOSI) | _BV(DD_SCK);
 
// Enable SPI and set master mode.
SPCR = _BV(SPE) | _BV(MSTR);
}
 
/**************************************************************************//**
* \fn void spi_master__transmit(uint8_t data)
*
* \brief Transmit data.
*
* \param data Data to transmit.
******************************************************************************/
void
spi_master__transmit
(
uint8_t data
){
// Write data to SPI data register.
SPDR = data;
 
// Wait for transmission complete.
while (!(SPSR & (1 << SPIF)));
}
/trunk/libraries/spi/src/spi.c
0,0 → 1,193
/**************************************************************************//**
* \brief SPI library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20110315
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file spi.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <spi/spi.h>
 
#include <useful/bits.h>
 
#include <avr/io.h>
 
#include <stdint.h>
 
#if defined (__AVR_ATmega128__)
#include "../include/spi_atmega128.h"
#elif defined (__AVR_ATmega328P__) || defined (__AVR_ATmega328__)
#include "../include/spi_atmega328.h"
#elif defined (__AVR_ATmega2560__)
#include "../include/spi_atmega2560.h"
#endif
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void spi__set_clock_rate(spi__clock_rate_t clock_rate)
*
* \brief Set clock rate.
*
* \param[in] clock_rate Clock rate to set.
******************************************************************************/
void
spi__set_clock_rate
(
spi__clock_rate_t clock_rate
){
switch (clock_rate)
{
case SPI__CLOCK_RATE__FOSC_OVER_2:
{
BIT__SET(SPCR, SPI2X);
BIT__RST(SPCR, SPR1);
BIT__RST(SPCR, SPR0);
}
break;
 
case SPI__CLOCK_RATE__FOSC_OVER_4:
{
BIT__RST(SPCR, SPI2X);
BIT__RST(SPCR, SPR1);
BIT__RST(SPCR, SPR0);
}
break;
 
case SPI__CLOCK_RATE__FOSC_OVER_8:
{
BIT__SET(SPCR, SPI2X);
BIT__RST(SPCR, SPR1);
BIT__SET(SPCR, SPR0);
}
break;
 
case SPI__CLOCK_RATE__FOSC_OVER_16:
{
BIT__RST(SPCR, SPI2X);
BIT__RST(SPCR, SPR1);
BIT__SET(SPCR, SPR0);
}
break;
 
case SPI__CLOCK_RATE__FOSC_OVER_32:
{
BIT__SET(SPCR, SPI2X);
BIT__SET(SPCR, SPR1);
BIT__RST(SPCR, SPR0);
}
break;
 
case SPI__CLOCK_RATE__FOSC_OVER_64:
{
BIT__SET(SPCR, SPI2X);
BIT__SET(SPCR, SPR1);
BIT__SET(SPCR, SPR0);
}
break;
 
case SPI__CLOCK_RATE__FOSC_OVER_128:
{
BIT__RST(SPCR, SPI2X);
BIT__SET(SPCR, SPR1);
BIT__SET(SPCR, SPR0);
}
break;
default:
break;
}
}
 
/**************************************************************************//**
* \fn void spi__set_data_mode(spi__data_mode_t mode)
*
* \brief Set SPI data mode.
*
* \param[in] mode Data mode to set.
******************************************************************************/
void
spi__set_data_mode
(
spi__data_mode_t mode
){
switch (mode)
{
case SPI__DATA_MODE_0:
{
BIT__RST(SPCR, CPOL);
BIT__RST(SPCR, CPHA);
}
break;
 
case SPI__DATA_MODE_1:
{
BIT__RST(SPCR, CPOL);
BIT__SET(SPCR, CPHA);
}
break;
 
case SPI__DATA_MODE_2:
{
BIT__SET(SPCR, CPOL);
BIT__RST(SPCR, CPHA);
}
break;
 
case SPI__DATA_MODE_3:
{
BIT__SET(SPCR, CPOL);
BIT__SET(SPCR, CPHA);
}
break;
 
default:
break;
}
}
 
/**************************************************************************//**
* \fn void spi__set_data_order(spi__data_order_t data_order)
*
* \brief Set SPI data order.
*
* \param[in] data_order Data order to set.
******************************************************************************/
void
spi__set_data_order
(
spi__data_order_t data_order
){
if (SPI__DATA_ORDER__LSB_FIRST == data_order)
{
BIT__SET(SPCR, DORD);
}
else
{
BIT__RST(SPCR, DORD);
}
}
/trunk/libraries/spi/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/spi/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/spi/SConstruct
0,0 → 1,40
# Import build tools.
SConscript('#min_env/build_tools.py')
 
# Set environment for AVR-GCC.
SConscript('#min_env/env_target.py')
 
# Import environment set for AVR-GCC.
Import('env_target')
 
# Append CPPPATH.
env_target.Append(CPPPATH = [ '#../' ])
 
# Build library.
SConscript(
'src/SConscript',
variant_dir = '#build/lib/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Append LIBPATH and LIBS.
env_target.Append(LIBPATH = [ '#build/lib/'])
env_target.Append(LIBS = [ 'spi' ])
 
# Build demonstration program.
SConscript(
'demo/SConscript',
variant_dir = '#build/demo/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Build test program.
SConscript(
'test/SConscript',
variant_dir = '#build/test/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
/trunk/libraries/spi/min_env/env_target.py
0,0 → 1,27
# Create and initialize the environment.
env_target = Environment()
 
# Set environment for AVR-GCC.
env_target['CC'] = 'avr-gcc'
env_target['CPPPATH'] = '/usr/lib/avr/include'
env_target['OBJCOPY'] = 'avr-objcopy'
env_target['SIZE'] = 'avr-size'
env_target['AR'] = 'avr-ar'
env_target['RANLIB'] = 'avr-ranlib'
env_target.Append(CCFLAGS = '-Os')
 
# Define environment name.
env_target.Append(NAME = 'env_target')
 
# Microcontroller type.
env_target.Append(MCU = 'atmega328p')
# Microcontroller frequency in Hertz.
env_target.Append(F_CPU = '16000000UL')
 
# Set environment for an Atmel AVR ATmega328p microcontroller.
env_target.Append(CCFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(LINKFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(CPPDEFINES = 'F_CPU=' + env_target['F_CPU'])
 
# Export environment set for target.
Export('env_target')
/trunk/libraries/spi/min_env/build_tools.py
0,0 → 1,41
"""
Build project.
"""
def BuildProject(env, sources, target_name):
# Build program.
env.Program(target = target_name + '.elf', source = sources)
# Create hex binary file.
env.Command(
target_name + '.hex',
target_name + '.elf',
env['OBJCOPY'] + ' -O ihex $SOURCE $TARGET'
)
AddMethod(Environment, BuildProject)
 
"""
Build library.
"""
def BuildLibrary(env, sources, target_name):
# Build static library.
env.StaticLibrary(target = target_name, source = sources)
# Append LIBPATH and LIBS.
env.Append(LIBPATH = [ '#build/libraries/' + target_name + '/' + env['NAME'] ])
env.Append(LIBS = [ target_name ])
 
AddMethod(Environment, BuildLibrary)
 
"""
Compute memory usage.
"""
def ComputeMemoryUsage(env, target_name):
# Compute memory usage.
env.Command(
None,
target_name + '.elf',
env['SIZE'] + ' -C --mcu=' + env['MCU'] + ' $SOURCE'
)
AddMethod(Environment, ComputeMemoryUsage)
/trunk/libraries/eeprom/demo/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'eeprom__demo'
 
# Set source file.
sources = [
'eeprom__demo.c'
]
 
# Build project and libraries.
env_target.BuildProject(sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/libraries/eeprom/demo/eeprom__demo.c
0,0 → 1,51
/**************************************************************************//**
* \brief EEPROM library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20111017
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file eeprom__demo.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../eeprom.h"
 
#include <stdint.h>
 
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
******************************************************************************/
int
main
(
void
){
eeprom__write_byte(0, 0x85);
uint8_t read_byte = eeprom__read_byte(0);
 
for (;;);
 
return 0;
}
/trunk/libraries/eeprom/src/SConscript
0,0 → 1,13
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'eeprom'
 
# Define source files.
sources = [
'eeprom.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/eeprom/src/eeprom.c
0,0 → 1,159
/**************************************************************************//**
* \brief EEPROM library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20111017
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file eeprom.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <eeprom/eeprom.h>
 
#include <avr/io.h>
 
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void eeprom__write_byte(
* uint16_t address,
* uint8_t data)
*
* \brief Write a byte in EEPROM.
*
* \param address Address.
* \param data Data to write.
******************************************************************************/
void
eeprom__write_byte
(
uint16_t address,
uint8_t data
){
// Wait for completion of previous write.
while (EECR & (1 << EEPE));
 
// Set up address.
EEAR = address;
 
// Set up data.
EEDR = data;
 
// Write logical one to EEMPE.
EECR |= (1 << EEMPE);
 
// Start EEPROM write.
EECR |= (1 << EEPE);
}
 
/**************************************************************************//**
* \fn void eeprom__write_bytes(
* uint16_t address,
* uint16_t size,
* uint8_t* p_data)
*
* \brief Write bytes into EEPOM.
*
* \param address Address.
* \param size Data size.
* \param[in] p_data Data to write.
******************************************************************************/
void
eeprom__write_bytes
(
uint16_t address,
uint16_t size,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
for (uint16_t i = 0; i < size; i++)
{
eeprom__write_byte(address + i, p_data[i]);
}
}
 
/**************************************************************************//**
* \fn uint8_t eeprom__read_byte(
* uint16_t address)
*
* \brief Read data into EEPROM.
*
* \param address Address of data to read.
*
* \return Read data.
******************************************************************************/
uint8_t
eeprom__read_byte
(
uint16_t address
){
// Wait for completion of previous write.
while (EECR & (1 << EEPE));
 
// Set up address.
EEAR = address;
 
// Start EEPROM read.
EECR |= (1 << EERE);
 
// Read data register.
uint8_t data = EEDR;
 
return data;
}
 
/**************************************************************************//**
* \fn void eeprom__read_bytes(
* uint16_t address,
* uint16_t size,
* uint8_t* p_data)
*
* \brief Read bytes from EEPROM.
*
* \param address Address to read.
* \param size Data size to read.
* \param[in] p_data Data buffer.
******************************************************************************/
void
eeprom__read_bytes
(
uint16_t address,
uint16_t size,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
for (uint16_t i = 0; i < size; i++)
{
p_data[i] = eeprom__read_byte(address + i);
}
}
/trunk/libraries/eeprom/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/eeprom/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/eeprom/SConstruct
0,0 → 1,40
# Import build tools.
SConscript('#min_env/build_tools.py')
 
# Set environment for AVR-GCC.
SConscript('#min_env/env_target.py')
 
# Import environment set for AVR-GCC.
Import('env_target')
 
# Append CPPPATH.
env_target.Append(CPPPATH = [ '#../' ])
 
# Build library.
SConscript(
'src/SConscript',
variant_dir = '#build/lib/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Append LIBPATH and LIBS.
env_target.Append(LIBPATH = [ '#build/lib/'])
env_target.Append(LIBS = [ 'eeprom' ])
 
# Build demonstration program.
SConscript(
'demo/SConscript',
variant_dir = '#build/demo/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Build test program.
SConscript(
'test/SConscript',
variant_dir = '#build/test/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
/trunk/libraries/eeprom/min_env/env_target.py
0,0 → 1,28
# Create and initialize the environment.
env_target = Environment()
 
# Set environment for AVR-GCC.
env_target['CC'] = 'avr-gcc'
env_target['CPPPATH'] = '/usr/lib/avr/include'
env_target['OBJCOPY'] = 'avr-objcopy'
env_target['SIZE'] = 'avr-size'
env_target['AR'] = 'avr-ar'
env_target['RANLIB'] = 'avr-ranlib'
env_target.Append(CCFLAGS = '-Os')
env_target.Append(CCFLAGS = '-std=c99')
 
# Define environment name.
env_target.Append(NAME = 'env_target')
 
# Microcontroller type.
env_target.Append(MCU = 'atmega328p')
# Microcontroller frequency in Hertz.
env_target.Append(F_CPU = '16000000UL')
 
# Set environment for an Atmel AVR ATmega328p microcontroller.
env_target.Append(CCFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(LINKFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(CPPDEFINES = 'F_CPU=' + env_target['F_CPU'])
 
# Export environment set for target.
Export('env_target')
/trunk/libraries/eeprom/min_env/build_tools.py
0,0 → 1,41
"""
Build project.
"""
def BuildProject(env, sources, target_name):
# Build program.
env.Program(target = target_name + '.elf', source = sources)
# Create hex binary file.
env.Command(
target_name + '.hex',
target_name + '.elf',
env['OBJCOPY'] + ' -O ihex $SOURCE $TARGET'
)
AddMethod(Environment, BuildProject)
 
"""
Build library.
"""
def BuildLibrary(env, sources, target_name):
# Build static library.
env.StaticLibrary(target = target_name, source = sources)
# Append LIBPATH and LIBS.
env.Append(LIBPATH = [ '#build/libraries/' + target_name + '/' + env['NAME'] ])
env.Append(LIBS = [ target_name ])
 
AddMethod(Environment, BuildLibrary)
 
"""
Compute memory usage.
"""
def ComputeMemoryUsage(env, target_name):
# Compute memory usage.
env.Command(
None,
target_name + '.elf',
env['SIZE'] + ' -C --mcu=' + env['MCU'] + ' $SOURCE'
)
AddMethod(Environment, ComputeMemoryUsage)
/trunk/libraries/eeprom/eeprom.h
0,0 → 1,121
/**************************************************************************//**
* \brief EEPROM library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20111017
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile eeprom.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__EEPROM__H
#define H__IDREAMMICRO__EEPROM__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <stdint.h>
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void eeprom__write_byte(
* uint16_t address,
* uint8_t data)
*
* \brief Write a byte in EEPROM.
*
* \param address Address.
* \param data Data to write.
******************************************************************************/
void
eeprom__write_byte
(
uint16_t address,
uint8_t data
);
 
/**************************************************************************//**
* \fn void eeprom__write_bytes(
* uint16_t address,
* uint16_t size,
* uint8_t* p_data)
*
* \brief Write bytes into EEPOM.
*
* \param address Address.
* \param size Data size.
* \param[in] p_data Data to write.
******************************************************************************/
void
eeprom__write_bytes
(
uint16_t address,
uint16_t size,
uint8_t* p_data
);
 
/**************************************************************************//**
* \fn uint8_t eeprom__read_byte(
* uint16_t address)
*
* \brief Read data into EEPROM.
*
* \param address Address of data to read.
*
* \return Read data.
******************************************************************************/
uint8_t
eeprom__read_byte
(
uint16_t address
);
 
/**************************************************************************//**
* \fn void eeprom__read_bytes(
* uint16_t address,
* uint16_t size,
* uint8_t* p_data)
*
* \brief Read bytes from EEPROM.
*
* \param address Address to read.
* \param size Data size to read.
* \param[in] p_data Data buffer.
******************************************************************************/
void
eeprom__read_bytes
(
uint16_t address,
uint16_t size,
uint8_t* p_data
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__EEPROM__H */
/trunk/libraries/eeprom
Modification de propriétés sur libraries/eeprom
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,2 ##
+build
+.sconsign.dblite
/trunk/libraries/digital_io/src/digital_io.c
0,0 → 1,359
/**************************************************************************//**
* \brief Digital I/O library - Implementation
* \author Copyright (C) 2009 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090314
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file digital_io.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <digital_io/digital_io.h>
 
#include <useful/bits.h>
 
#include <avr/io.h>
 
#include <stdint.h>
 
/******************************************************************************
* Private macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def DIGITAL_IO__PORT_DIRECTION__INPUT
* \brief
******************************************************************************/
#define DIGITAL_IO__PORT_DIRECTION__INPUT 0x00
 
/**************************************************************************//**
* \def DIGITAL_IO__PORT_DIRECTION__OUTPUT
* \brief
******************************************************************************/
#define DIGITAL_IO__PORT_DIRECTION__OUTPUT 0xFF
 
/**************************************************************************//**
* \def digital_io__get_index(port)
* \brief
******************************************************************************/
#define digital_io__get_index(port) ((port) >> 4)
/******************************************************************************
* Private types.
******************************************************************************/
 
/**************************************************************************//**
* \struct digital_io__register
* \brief Digital I/O register.
*
* \typedef digital_io__register_t
* \brief Digital IO register.
******************************************************************************/
typedef struct digital_io__register
{
const uint8_t volatile * const p_input;
uint8_t volatile * const p_output;
uint8_t volatile * const p_direction;
} digital_io__register_t;
 
/******************************************************************************
* Private variable definitions.
******************************************************************************/
 
static const digital_io__register_t ports[] =
{
#ifdef PORTA
[digital_io__get_index(DIGITAL_IO__PORT_A)]
{ // PORT A.
.p_input = &PINA,
.p_output = &PORTA,
.p_direction = &DDRA
},
#endif
#ifdef PORTB
[digital_io__get_index(DIGITAL_IO__PORT_B)]
{ // PORT B.
.p_input = &PINB,
.p_output = &PORTB,
.p_direction = &DDRB
},
#endif
#ifdef PORTC
[digital_io__get_index(DIGITAL_IO__PORT_C)]
{ // PORT C.
.p_input = &PINC,
.p_output = &PORTC,
.p_direction = &DDRC
},
#endif
#ifdef PORTD
[digital_io__get_index(DIGITAL_IO__PORT_D)]
{ // PORT D.
.p_input = &PIND,
.p_output = &PORTD,
.p_direction = &DDRD
},
#endif
#ifdef PORTE
[digital_io__get_index(DIGITAL_IO__PORT_E)]
{ // PORT E.
.p_input = &PINE,
.p_output = &PORTE,
.p_direction = &DDRE
},
#endif
#ifdef PORTF
[digital_io__get_index(DIGITAL_IO__PORT_F)]
{ // PORT F.
.p_input = &PINF,
.p_output = &PORTF,
.p_direction = &DDRF
},
#endif
#ifdef PORTG
[digital_io__get_index(DIGITAL_IO__PORT_G)]
{ // PORT G.
.p_input = &PING,
.p_output = &PORTG,
.p_direction = &DDRG
},
#endif
#ifdef PORTH
[digital_io__get_index(DIGITAL_IO__PORT_H)]
{ // PORT H.
.p_input = &PINH,
.p_output = &PORTH,
.p_direction = &DDRH
},
#endif
#ifdef PORTJ
[digital_io__get_index(DIGITAL_IO__PORT_J)]
{ // PORT J.
.p_input = &PINJ,
.p_output = &PORTJ,
.p_direction = &DDRJ
},
#endif
#ifdef PORTK
[digital_io__get_index(DIGITAL_IO__PORT_K)] =
{ // PORT K.
.p_input = &PINK,
.p_output = &PORTK,
.p_direction = &DDRK
},
#endif
#ifdef PORTL
[digital_io__get_index(DIGITAL_IO__PORT_L)]
{ // PORT L.
.p_input = &PINL,
.p_output = &PORTL,
.p_direction = &DDRL
}
#endif
};
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void digital_io__configure_pin(
* digital_io__pin_position_t pin_position,
* digital_io__direction_t direction)
*
* \brief Configure a pin.
*
* \param[in] pin_position pin position to configure
* \param direction pin direction
******************************************************************************/
void
digital_io__configure_pin
(
digital_io__pin_position_t pin_position,
digital_io__direction_t direction
){
// Alias.
digital_io__register_t const* p_register =
&(ports[digital_io__get_port(pin_position)]);
 
if (DIGITAL_IO__DIRECTION__INPUT == direction)
{
BIT__RST(*(p_register->p_direction), digital_io__get_pin(pin_position));
}
else
{
BIT__SET(*(p_register->p_direction), digital_io__get_pin(pin_position));
}
}
 
/**************************************************************************//**
* \fn digital_io__level_t digital_io__get_pin_level(
* digital_io__pin_position_t pin_position)
*
* \brief Get the level of a pin.
*
* \param pin_position pin position to get level
*
* \return digital io level
******************************************************************************/
digital_io__level_t
digital_io__get_pin_level
(
digital_io__pin_position_t pin_position
){
// Alias.
digital_io__register_t const* p_register =
&(ports[digital_io__get_port(pin_position)]);
 
digital_io__level_t level =
BIT__TST(*(p_register->p_input), digital_io__get_pin(pin_position)) ?
DIGITAL_IO__LEVEL__HIGH : DIGITAL_IO__LEVEL__LOW;
 
return level;
}
 
/**************************************************************************//**
* \fn void digital_io__set_pin_level(
* digital_io__pin_position_t pin_position,
* digital_io__level_t level)
*
* \brief Set the level of a pin.
*
* \param[in] pin_position pin position to set level
* \param level level to set
******************************************************************************/
void
digital_io__set_pin_level
(
digital_io__pin_position_t pin_position,
digital_io__level_t level
){
// Alias.
digital_io__register_t const* p_register =
&(ports[digital_io__get_port(pin_position)]);
 
if (DIGITAL_IO__LEVEL__LOW == level)
{
BIT__RST(*(p_register->p_output), digital_io__get_pin(pin_position));
}
else
{
BIT__SET(*(p_register->p_output), digital_io__get_pin(pin_position));
}
}
 
/**************************************************************************//**
* \fn void digital_io__toggle_pin_level(
* digital_io__pin_position_t pin_position)
*
* \brief Toggle the level of a pin.
*
* \param pin_position pin position to toggle level
******************************************************************************/
void
digital_io__toggle_pin_level
(
digital_io__pin_position_t pin_position
){
// Alias.
digital_io__register_t const* p_register =
&(ports[digital_io__get_port(pin_position)]);
 
BIT__TGL(*(p_register->p_output), digital_io__get_pin(pin_position));
}
 
/**************************************************************************//**
* \fn void digital_io__configure_port(
* digital_io__port_t port,
* digital_io__direction_t direction)
*
* \brief Configure a port.
*
* \param port port to configure
* \param direction port direction to configure
******************************************************************************/
void
digital_io__configure_port
(
digital_io__port_t port,
digital_io__direction_t direction
){
// Alias.
digital_io__register_t const* p_register =
&(ports[digital_io__get_port(port)]);
 
if (DIGITAL_IO__DIRECTION__INPUT == direction)
{
*(p_register->p_direction) = DIGITAL_IO__PORT_DIRECTION__INPUT;
}
else
{
*(p_register->p_direction) = DIGITAL_IO__PORT_DIRECTION__OUTPUT;
}
}
 
/**************************************************************************//**
* \fn uint8_t digital_io__get_port_value(digital_io__port_t port)
*
* \brief Get the value of a port.
*
* \param port port to get value
*
* \return port value
******************************************************************************/
digital_io__port_value_t
digital_io__get_port_value
(
digital_io__port_t port
){
// Alias.
digital_io__register_t const* p_register =
&(ports[digital_io__get_port(port)]);
 
uint8_t value = *(p_register->p_input);
 
return value;
}
 
/**************************************************************************//**
* \fn void digital_io__set_port_value(
* digital_io__port_t port,
* digital_io__port_value_t value)
*
* \brief Set the value of a port.
*
* \param port port to set value
* \param value port value to set
******************************************************************************/
void
digital_io__set_port_value
(
digital_io__port_t port,
digital_io__port_value_t value
){
// Alias.
digital_io__register_t const* p_register =
&(ports[digital_io__get_port(port)]);
 
*(p_register->p_output) = value;
}
/trunk/libraries/digital_io/src/SConscript
0,0 → 1,13
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'digital_io'
 
# Define source files.
sources = [
'digital_io.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/digital_io/digital_io.h
0,0 → 1,354
/**************************************************************************//**
* \brief Digital I/O library - API
* \author Copyright (C) 2009 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090314
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile digital_io.h
*
* \brief
*
* \see
******************************************************************************/
#ifndef H__IDREAMMICRO__DIGITAL_IO__H
#define H__IDREAMMICRO__DIGITAL_IO__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <avr/io.h>
 
#include <stdint.h>
 
/******************************************************************************
* Public macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def digital_io__get_port(pin_position)
* \brief Get port from pin position.
******************************************************************************/
#define digital_io__get_port(pin_position) ((pin_position) >> 4)
 
/**************************************************************************//**
* \def digital_io__get_pin(pin_position)
* \brief Get pin form pin position.
******************************************************************************/
#define digital_io__get_pin(pin_position) ((pin_position) & 0x0F)
 
/**************************************************************************//**
* \def DIGITAL_IO__PORT_A
* \brief Port A.
******************************************************************************/
#define DIGITAL_IO__PORT_A 0x00
 
/**************************************************************************//**
* \def DIGITAL_IO__PORT_B
* \brief Port B.
******************************************************************************/
#define DIGITAL_IO__PORT_B 0x10
 
/**************************************************************************//**
* \def DIGITAL_IO__PORT_C
* \brief Port C.
******************************************************************************/
#define DIGITAL_IO__PORT_C 0x20
 
/**************************************************************************//**
* \def DIGITAL_IO__PORT_D
* \brief Port D.
******************************************************************************/
#define DIGITAL_IO__PORT_D 0x30
 
/**************************************************************************//**
* \def DIGITAL_IO__PORT_E
* \brief Port E.
******************************************************************************/
#define DIGITAL_IO__PORT_E 0x40
 
/**************************************************************************//**
* \def DIGITAL_IO__PORT_F
* \brief Port F.
******************************************************************************/
#define DIGITAL_IO__PORT_F 0x50
 
/**************************************************************************//**
* \def DIGITAL_IO__PORT_G
* \brief Port G.
******************************************************************************/
#define DIGITAL_IO__PORT_G 0x60
 
/**************************************************************************//**
* \def DIGITAL_IO__PORT_H
* \brief port H.
******************************************************************************/
#define DIGITAL_IO__PORT_H 0x70
 
/**************************************************************************//**
* \def DIGITAL_IO__PORT_J
* \brief Port J.
******************************************************************************/
#define DIGITAL_IO__PORT_J 0x80
 
/**************************************************************************//**
* \def DIGITAL_IO__PORT_K
* \brief Port K.
******************************************************************************/
#define DIGITAL_IO__PORT_K 0x90
 
/**************************************************************************//**
* \def DIGITAL_IO__PORT_L
* \brief Port L.
******************************************************************************/
#define DIGITAL_IO__PORT_L 0xA0
 
/**************************************************************************//**
* \def DIGITAL_IO__PIN_0
* \brief Pin 0.
******************************************************************************/
#define DIGITAL_IO__PIN_0 0
 
/**************************************************************************//**
* \def DIGITAL_IO__PIN_1
* \brief Pin 1.
******************************************************************************/
#define DIGITAL_IO__PIN_1 1
 
/**************************************************************************//**
* \def DIGITAL_IO__PIN_2
* \brief Pin 2.
******************************************************************************/
#define DIGITAL_IO__PIN_2 2
 
/**************************************************************************//**
* \def DIGITAL_IO__PIN_3
* \brief Pin 3.
******************************************************************************/
#define DIGITAL_IO__PIN_3 3
 
/**************************************************************************//**
* \def DIGITAL_IO__PIN_4
* \brief Pin 4.
******************************************************************************/
#define DIGITAL_IO__PIN_4 4
 
/**************************************************************************//**
* \def DIGITAL_IO__PIN_5
* \brief Pin 5.
******************************************************************************/
#define DIGITAL_IO__PIN_5 5
 
/**************************************************************************//**
* \def DIGITAL_IO__PIN_6
* \brief Pin 6.
******************************************************************************/
#define DIGITAL_IO__PIN_6 6
 
/**************************************************************************//**
* \def DIGITAL_IO__PIN_7
* \brief Pin 7.
******************************************************************************/
#define DIGITAL_IO__PIN_7 7
 
/******************************************************************************
* Public types.
******************************************************************************/
 
/**************************************************************************//**
* \typedef digital_io__port_t
* \brief Represent a digital port.
******************************************************************************/
typedef uint8_t digital_io__port_t;
 
/**************************************************************************//**
* \typedef digital_io__pin_t
* \brief Represent a digital pin.
******************************************************************************/
typedef uint8_t digital_io__pin_t;
 
/**************************************************************************//**
* \typedef digital_io__pin_position_t
* \brief Digital IO pin position.
* High nibble is used for the port, low nibble is used for the pin.
* digital_io__pin_position_t pin = DIGITAL_IO__PORT_B | DIGITAL_IO__PIN_5;
******************************************************************************/
typedef uint8_t digital_io__pin_position_t;
 
/**************************************************************************//**
* \enum digital_io__directions
* \brief Digital IO directions.
*
* \typedef digital_io__direction_t
* \brief Digital IO direction.
******************************************************************************/
typedef enum digital_io__directions
{
DIGITAL_IO__DIRECTION__INPUT, /*!< Input. */
DIGITAL_IO__DIRECTION__OUTPUT /*!< Output. */
} digital_io__direction_t;
 
/**************************************************************************//**
* \enum digital_io__levels
* \brief Digital IO levels.
*
* \typedef digital_io__level_t
* \brief Digital IO level.
******************************************************************************/
typedef enum digital_io__levels
{
DIGITAL_IO__LEVEL__LOW, /*!< Low level. */
DIGITAL_IO__LEVEL__HIGH /*!< High level. */
} digital_io__level_t;
 
/**************************************************************************//**
* \typedef digital_io__port_value_t
* \brief Port value.
******************************************************************************/
typedef uint8_t digital_io__port_value_t;
 
/******************************************************************************
* Public function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void digital_io__configure_pin(
* digital_io__pin_position_t pin_position,
* digital_io__direction_t direction)
*
* \brief Configure a pin.
*
* \param pin_position pin position to configure
* \param direction pin direction to set
******************************************************************************/
void
digital_io__configure_pin
(
digital_io__pin_position_t pin_position,
digital_io__direction_t direction
);
 
/**************************************************************************//**
* \fn digital_io__level_t digital_io__get_pin_level(
* digital_io__pin_position_t pin_position)
*
* \brief Get the level of a pin.
*
* \param pin_position pin position to get level
*
* \return digital io level
******************************************************************************/
digital_io__level_t
digital_io__get_pin_level
(
digital_io__pin_position_t pin_position
);
 
/**************************************************************************//**
* \fn void digital_io__set_pin_level(
* digital_io__pin_position_t pin_position,
* digital_io__level_t level)
*
* \brief Set the level of a pin.
*
* \param pin_position pin position to set level
* \param level level to set
******************************************************************************/
void
digital_io__set_pin_level
(
digital_io__pin_position_t pin_position,
digital_io__level_t level
);
 
/**************************************************************************//**
* \fn void digital_io__toggle_pin_level(
* digital_io__pin_position_t pin_position)
*
* \brief Toggle the level of a pin.
*
* \param pin_position pin position to toggle level
******************************************************************************/
void
digital_io__toggle_pin_level
(
digital_io__pin_position_t pin_position
);
 
/**************************************************************************//**
* \fn void digital_io__configure_port(
* digital_io__port_t port,
* digital_io__direction_t direction)
*
* \brief Configure a port.
*
* \param port port to configure
* \param direction port direction to configure
******************************************************************************/
void
digital_io__configure_port
(
digital_io__port_t port,
digital_io__direction_t direction
);
 
/**************************************************************************//**
* \fn uint8_t digital_io__get_port_value(digital_io__port_t port)
*
* \brief Get the value of a port.
*
* \param port port to get value
*
* \return Port value
******************************************************************************/
digital_io__port_value_t
digital_io__get_port_value
(
digital_io__port_t port
);
 
/**************************************************************************//**
* \fn void digital_io__set_port_value(
* digital_io__port_t port,
* digital_io__port_value_t value)
*
* \brief Set the value of a port.
*
* \param port port to set value
* \param value port value to set
******************************************************************************/
void
digital_io__set_port_value
(
digital_io__port_t port,
digital_io__port_value_t value
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__DIGITAL_IO__H */
 
/trunk/libraries/digital_io/test/digital_io__test.c
0,0 → 1,68
/**************************************************************************//**
* \brief Digital I/O library - Test program
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090314
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file digital_io__test.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../digital_io.h"
 
#include <avr/io.h>
#include <util/delay.h>
 
/******************************************************************************
* Main function.
******************************************************************************/
 
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
******************************************************************************/
int
main
(
void
){
// Declare pin.
digital_io__pin_position_t pin = DIGITAL_IO__PORT_B | DIGITAL_IO__PIN_5;
// Configure pin as output.
digital_io__configure_pin(pin, DIGITAL_IO__DIRECTION__OUTPUT);
 
for (;;)
{
// Set pin level.
digital_io__set_pin_level(pin, DIGITAL_IO__LEVEL__HIGH);
_delay_ms(1000);
 
// Reset pin level.
digital_io__set_pin_level(pin, DIGITAL_IO__LEVEL__LOW);
_delay_ms(1000);
}
 
return 0;
}
/trunk/libraries/digital_io/test/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'digital_io__test'
 
# Set source file.
sources = [
'digital_io__test.c'
]
 
# Build project and libraries.
env_target.BuildProject(sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/libraries/digital_io/demo/digital_io__demo.c
0,0 → 1,68
/**************************************************************************//**
* \brief Digital I/O library - Demonstration program
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090314
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file digital_io__demo.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../digital_io.h"
 
#include <avr/io.h>
#include <util/delay.h>
 
/******************************************************************************
* Main function.
******************************************************************************/
 
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
******************************************************************************/
int
main
(
void
){
// Declare pin.
digital_io__pin_position_t pin = DIGITAL_IO__PORT_B | DIGITAL_IO__PIN_5;
// Configure pin as output.
digital_io__configure_pin(pin, DIGITAL_IO__DIRECTION__OUTPUT);
 
for (;;)
{
// Set pin level.
digital_io__set_pin_level(pin, DIGITAL_IO__LEVEL__HIGH);
_delay_ms(1000);
 
// Reset pin level.
digital_io__set_pin_level(pin, DIGITAL_IO__LEVEL__LOW);
_delay_ms(1000);
}
 
return 0;
}
/trunk/libraries/digital_io/demo/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'digital_io__demo'
 
# Set source file.
sources = [
'digital_io__demo.c'
]
 
# Build project and libraries.
env_target.BuildProject(sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/libraries/digital_io/demo/.sconsign.dblite
/trunk/libraries/digital_io/demo/.sconsign.dblite
Modification de propriétés sur libraries/digital_io/demo/.sconsign.dblite
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
/trunk/libraries/digital_io/SConstruct
0,0 → 1,40
# Import build tools.
SConscript('#min_env/build_tools.py')
 
# Set environment for AVR-GCC.
SConscript('#min_env/env_target.py')
 
# Import environment set for AVR-GCC.
Import('env_target')
 
# Append CPPPATH.
env_target.Append(CPPPATH = [ '#../' ])
 
# Build library.
SConscript(
'src/SConscript',
variant_dir = '#build/lib/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Append LIBPATH and LIBS.
env_target.Append(LIBPATH = [ '#build/lib/'])
env_target.Append(LIBS = [ 'digital_io' ])
 
# Build demonstration program.
SConscript(
'demo/SConscript',
variant_dir = '#build/demo/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Build test program.
SConscript(
'test/SConscript',
variant_dir = '#build/test/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
/trunk/libraries/digital_io/min_env/env_target.py
0,0 → 1,27
# Create and initialize the environment.
env_target = Environment()
 
# Set environment for AVR-GCC.
env_target['CC'] = 'avr-gcc'
env_target['CPPPATH'] = '/usr/lib/avr/include'
env_target['OBJCOPY'] = 'avr-objcopy'
env_target['SIZE'] = 'avr-size'
env_target['AR'] = 'avr-ar'
env_target['RANLIB'] = 'avr-ranlib'
env_target.Append(CCFLAGS = '-Os')
 
# Define environment name.
env_target.Append(NAME = 'env_target')
 
# Microcontroller type.
env_target.Append(MCU = 'atmega328p')
# Microcontroller frequency in Hertz.
env_target.Append(F_CPU = '16000000UL')
 
# Set environment for an Atmel AVR ATmega328p microcontroller.
env_target.Append(CCFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(LINKFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(CPPDEFINES = 'F_CPU=' + env_target['F_CPU'])
 
# Export environment set for target.
Export('env_target')
/trunk/libraries/digital_io/min_env/build_tools.py
0,0 → 1,41
"""
Build project.
"""
def BuildProject(env, sources, target_name):
# Build program.
env.Program(target = target_name + '.elf', source = sources)
# Create hex binary file.
env.Command(
target_name + '.hex',
target_name + '.elf',
env['OBJCOPY'] + ' -O ihex $SOURCE $TARGET'
)
AddMethod(Environment, BuildProject)
 
"""
Build library.
"""
def BuildLibrary(env, sources, target_name):
# Build static library.
env.StaticLibrary(target = target_name, source = sources)
# Append LIBPATH and LIBS.
env.Append(LIBPATH = [ '#build/libraries/' + target_name + '/' + env['NAME'] ])
env.Append(LIBS = [ target_name ])
 
AddMethod(Environment, BuildLibrary)
 
"""
Compute memory usage.
"""
def ComputeMemoryUsage(env, target_name):
# Compute memory usage.
env.Command(
None,
target_name + '.elf',
env['SIZE'] + ' -C --mcu=' + env['MCU'] + ' $SOURCE'
)
AddMethod(Environment, ComputeMemoryUsage)
/trunk/libraries/digital_io/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/digital_io/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/digital_io/.sconsign.dblite
/trunk/libraries/digital_io/.sconsign.dblite
Modification de propriétés sur libraries/digital_io/.sconsign.dblite
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
/trunk/libraries/digital_io
Modification de propriétés sur libraries/digital_io
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+build
/trunk/libraries/ds1307/ds1307.h
0,0 → 1,273
/**************************************************************************//**
* \brief DS1307 RTC library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090501
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile ds1307.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__DS1307__H
#define H__IDREAMMICRO__DS1307__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <useful/datetime.h>
 
#include <stdbool.h>
 
/******************************************************************************
* Public macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def DS1307__CLOCK_RATE
* \brief DS1307 frequency in Hertz.
******************************************************************************/
#define DS1307__CLOCK_RATE 100000
 
/******************************************************************************
* Public type definitions.
******************************************************************************/
 
/**************************************************************************//**
* \enum ds1307__hour_modes.
* \brief RTC hour modes.
*
* \typedef ds1307__hour_mode_t.
* \brief RTC hour mode.
******************************************************************************/
typedef enum ds1307__hour_modes
{
DS1307__HOUR_MODE__24_HOUR = 0, /*!< 24-hour mode. */
DS1307__HOUR_MODE__12_HOUR = 1 /*!< 12-hour mode. */
} ds1307__hour_mode_t;
 
/**************************************************************************//**
* \enum ds1307__sqw_out_levels
* \brief
*
* \typedef ds1307__sqw_out_level_t
* \brief
******************************************************************************/
typedef enum ds1307__sqw_out_levels
{
DS1307__SQW_LEVEL__LOW, /*!< Low level. */
DS1307__SQW_LEVEL__HIGH /*!< High level. */
} ds1307__sqw_out_level_t;
 
/**************************************************************************//**
* \enum ds1307__sqw_out_frequencies
* \brief
*
* \typedef ds1307__sqw_out__frequency_t
* \brief
******************************************************************************/
typedef enum ds1307__sqw_out_frequencies
{
DS1307__SQW_FREQUENCY__1_HZ,
DS1307__SQW_FREQUENCY__4096_HZ,
DS1307__SQW_FREQUENCY__8192_HZ,
DS1307__SQW_FREQUENCY__32768_HZ
} ds1307__sqw_out__frequency_t;
 
/******************************************************************************
* Public function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void ds1307__initialize(void)
*
* \brief Initialize DS1307 RTC.
******************************************************************************/
void
ds1307__initialize
(
void
);
 
/**************************************************************************//**
* \fn void ds1307__get_time(
* date_time__time_t* p_time,
* ds1307__hour_mode_t* p_hour_mode)
*
* \brief Get RTC time.
*
* \param p_time a pointer to fill with RTC time
* \param p_hour_mode a pointer to fill with RTC hour mode
******************************************************************************/
void
ds1307__get_time
(
datetime__time_t* p_time,
ds1307__hour_mode_t* p_hour_mode
);
 
/**************************************************************************//**
* \fn void ds1307__set_time(
* date_time__time_t* p_time,
* ds1307__hour_mode_t hour_mode)
*
* \brief Set RTC time.
*
* \param p_time time to set. p_time->meridiem isn't used in 12-hour mode.
* \param hour_mode hour mode
******************************************************************************/
void
ds1307__set_time
(
datetime__time_t* p_time,
ds1307__hour_mode_t hour_mode
);
 
/**************************************************************************//**
* \fn void ds1307__get_date(date_time__date_t* p_date)
*
* \brief Get RTC date.
*
* \param p_date a pointer to fill with RTC date
******************************************************************************/
void
ds1307__get_date
(
datetime__date_t* p_date
);
 
/**************************************************************************//**
* \fn void ds1307__set_date(date_time__date_t* p_date)
*
* \brief Set RTC date.
*
* \param p_date date to set
******************************************************************************/
void
ds1307__set_date
(
datetime__date_t* p_date
);
 
/**************************************************************************//**
* \fn void ds1307__set_square_wave_output_level(ds1307__sqw_out_level_t level)
*
* \brief Set square wave output pin level.
*
* \param level Level to set.
******************************************************************************/
void
ds1307__set_square_wave_output_level
(
ds1307__sqw_out_level_t level
);
 
/**************************************************************************//**
* \fn void ds1307__set_square_wave_output_signal(
* ds1307__sqw_out__frequency_t frequency,
* bool enable)
*
* \brief Set Square-Wave output signal.
*
* \param frequency Frequency.
* \param enable Status.
******************************************************************************/
void
ds1307__set_square_wave_output_signal
(
ds1307__sqw_out__frequency_t frequency,
bool enable
);
 
/**************************************************************************//**
* \fn uint8_t ds1307__read_byte_in_ram(uint8_t address)
*
* \brief Read a byte in DS1307 RAM.
*
* \param address Address to read.
*
* \return Read byte.
******************************************************************************/
uint8_t
ds1307__read_byte_in_ram
(
uint8_t address
);
 
/**************************************************************************//**
* \fn void ds1307__read_bytes_in_ram(
* uint8_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Read bytes in DS1307 RAM.
*
* \param address Address to read.
* \param length Number of bytes to read.
* \param[in] p_data Buffer to fill.
******************************************************************************/
void
ds1307__read_bytes_in_ram
(
uint8_t address,
uint8_t length,
uint8_t* p_data
);
 
/**************************************************************************//**
* \fn void ds1307__write_byte_in_ram(uint8_t address, uint8_t data)
*
* \brief Write a byte in DS1307 RAM.
*
* \param address Address to write.
* \param data Byte to write.
******************************************************************************/
void
ds1307__write_byte_in_ram
(
uint8_t address,
uint8_t data
);
 
/**************************************************************************//**
* \fn void ds1307__write_bytes_in_ram(uint8_t address, uint8_t data)
*
* \brief Write a byte in DS1307 RAM.
*
* \param address Address to write.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
void
ds1307__write_bytes_in_ram
(
uint8_t address,
uint8_t length,
uint8_t* p_data
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__DS1307__H */
/trunk/libraries/ds1307/src/ds1307.c
0,0 → 1,451
/**************************************************************************//**
* \brief DS1307 RTC library
* \author Copyright (C) 2009 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090501
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file ds1307.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <ds1307/ds1307.h>
 
#include <twi/twi.h>
#include <useful/bits.h>
#include <useful/datetime.h>
 
#include <avr/io.h>
 
#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
 
/******************************************************************************
* Private macros.
******************************************************************************/
 
#define DS1307__ADDRESS 0xD0
 
#define DS1307__REG_SECONDS 0x00
#define DS1307__REG_MINUTES 0x01
#define DS1307__REG_HOURS 0x02
#define DS1307__REG_DAY 0x03
#define DS1307__REG_DATE 0x04
#define DS1307__REG_MONTH 0x05
#define DS1307__REG_YEAR 0x06
#define DS1307__REG_CONTROL 0x07
 
#define DS1307__RS0 0x00
#define DS1307__RS1 0x01
#define DS1307__SQWE 0x04
#define DS1307__OUT 0x07
 
/**************************************************************************//**
* \def DS1307__REG_RAM
* \brief Start address of RAM registers (locations 0x08 to 0x3F).
******************************************************************************/
#define DS1307__REG_RAM 0x08
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void ds1307__initialize(void)
*
* \brief Initialize RTC.
******************************************************************************/
void
ds1307__initialize
(
void
){
// We don't initialize TWI here: we may have several devices on the bus.
// Initialize TWI.
//twi__initialize(DS1307__CLOCK_RATE);
}
 
/**************************************************************************//**
* \fn void ds1307__get_time(
* date_time__time_t* p_time,
* ds1307__hour_mode_t* p_hour_mode)
*
* \brief Get RTC time.
*
* \param p_time a pointer to fill with RTC time
* \param p_hour_mode a pointer to fill with RTC hour mode
******************************************************************************/
void
ds1307__get_time
(
datetime__time_t* p_time,
ds1307__hour_mode_t* p_hour_mode
){
// Check the preconditions.
assert(NULL != p_time);
assert(NULL != p_hour_mode);
 
twi__start();
twi__send_slaw(DS1307__ADDRESS);
twi__send_data(DS1307__REG_SECONDS);
twi__stop();
 
twi__start();
twi__send_slar(DS1307__ADDRESS);
uint8_t seconds = 0;
twi__receive_data_ack(&seconds);
uint8_t minutes = 0;
twi__receive_data_ack(&minutes);
uint8_t hours = 0;
twi__receive_data_nack(&hours);
p_time->seconds = (((seconds & 0x70) >> 4) * 10) + (seconds & 0x0F);
p_time->minutes = (((minutes & 0x70) >> 4) * 10) + (minutes & 0x0F);
*p_hour_mode = (ds1307__hour_mode_t)((hours & 0x40) >> 6);
if (DS1307__HOUR_MODE__12_HOUR == *p_hour_mode)
{
p_time->meridiem = (datetime__meridiem_t)((hours & 0x20) >> 5);
p_time->hours = (((hours & 0x10) >> 4) * 10) + (hours & 0x0F);
}
else
{
p_time->hours = (((hours & 0x30) >> 4) * 10) + (hours & 0x0F);
}
twi__stop();
}
 
/**************************************************************************//**
* \fn void ds1307__set_time(
* date_time__time_t* p_time,
* ds1307__hour_mode_t hour_mode)
*
* \brief Set RTC time.
*
* \param p_time time to set. p_time->meridiem isn't used in 12-hour mode.
* \param hour_mode hour mode
******************************************************************************/
void
ds1307__set_time
(
datetime__time_t* p_time,
ds1307__hour_mode_t hour_mode
){
// Check the preconditions.
assert(NULL != p_time);
 
twi__start();
twi__send_slaw(DS1307__ADDRESS);
twi__send_data(DS1307__REG_SECONDS);
 
uint8_t seconds = ((p_time->seconds / 10) << 4) + (p_time->seconds % 10);
uint8_t minutes = ((p_time->minutes / 10) << 4) + (p_time->minutes % 10);
uint8_t hours = 0;
if (DS1307__HOUR_MODE__12_HOUR == hour_mode)
{
hours = (hour_mode << 6) + (p_time->meridiem << 5)
+ ((p_time->hours / 10) << 4) + (p_time->hours % 10);
}
else
{
hours = (hour_mode << 6) + ((p_time->hours / 10) << 4)
+ (p_time->hours % 10);
}
 
twi__send_data(seconds);
twi__send_data(minutes);
twi__send_data(hours);
 
twi__stop();
}
 
/**************************************************************************//**
* \fn void ds1307__get_date(date_time__date_t* p_date)
*
* \brief Get RTC date.
*
* \param p_date a pointer to fill with RTC date
******************************************************************************/
void
ds1307__get_date
(
datetime__date_t* p_date
){
// Check the preconditions.
assert(NULL != p_date);
 
twi__start();
twi__send_slaw(DS1307__ADDRESS);
twi__send_data(DS1307__REG_DAY);
twi__stop();
 
twi__start();
twi__send_slar(DS1307__ADDRESS);
 
uint8_t day = 0;
twi__receive_data_ack(&day);
uint8_t date = 0;
twi__receive_data_ack(&date);
uint8_t month = 0;
twi__receive_data_ack(&month);
uint8_t year = 0;
twi__receive_data_nack(&year);
 
p_date->day = day;
p_date->date = (((date & 0x30) >> 4) * 10) + (date & 0x0F);
p_date->month = (((month & 0x10) >> 4) * 10) + (month & 0x0F);
p_date->year = (((year & 0xF0) >> 4) * 10) + (year & 0x0F);
 
twi__stop();
}
 
/**************************************************************************//**
* \fn void ds1307__set_date(date_time__date_t* p_date)
*
* \brief Set RTC date.
*
* \param p_date date to set
******************************************************************************/
void
ds1307__set_date
(
datetime__date_t* p_date
){
// Check the preconditions.
assert(NULL != p_date);
 
twi__start();
twi__send_slaw(DS1307__ADDRESS);
twi__send_data(DS1307__REG_DAY);
 
uint8_t date = ((p_date->date / 10) << 4) + (p_date->date % 10);
uint8_t month = ((p_date->month / 10) << 4) + (p_date->month % 10);
uint8_t year = ((p_date->year / 10) << 4) + (p_date->year % 10);
 
twi__send_data(p_date->day);
twi__send_data(date);
twi__send_data(month);
twi__send_data(year);
 
twi__stop();
}
 
/**************************************************************************//**
* \fn void ds1307__set_square_wave_output_level(ds1307__sqw_out_level_t level)
*
* \brief Set square wave output pin level.
*
* \param level Level to set.
******************************************************************************/
void
ds1307__set_square_wave_output_level
(
ds1307__sqw_out_level_t level
){
twi__start();
twi__send_slaw(DS1307__ADDRESS);
twi__send_data(DS1307__REG_CONTROL);
uint8_t register_value = (level == DS1307__SQW_LEVEL__LOW) ? 0x00 : 0x80;
twi__send_data(register_value);
twi__stop();
}
 
/**************************************************************************//**
* \fn void ds1307__set_square_wave_output_signal(
* ds1307__sqw_out__frequency_t frequency,
* bool enable)
*
* \brief Set Square-Wave output signal.
*
* \param frequency Frequency.
* \param enable Status.
******************************************************************************/
void
ds1307__set_square_wave_output_signal
(
ds1307__sqw_out__frequency_t frequency,
bool enable
){
uint8_t register_value = 0;
 
// Rate select.
switch (frequency)
{
case DS1307__SQW_FREQUENCY__4096_HZ:
register_value = _BV(DS1307__RS0);
break;
 
case DS1307__SQW_FREQUENCY__8192_HZ:
register_value = _BV(DS1307__RS1);
break;
 
case DS1307__SQW_FREQUENCY__32768_HZ:
register_value = _BV(DS1307__RS1) | _BV(DS1307__RS0);
break;
 
case DS1307__SQW_FREQUENCY__1_HZ:
default:
register_value = 0;
break;
}
 
// Square-Wave enable.
if (enable)
{
BIT__SET(register_value, DS1307__SQWE);
}
 
twi__start();
twi__send_slaw(DS1307__ADDRESS);
twi__send_data(DS1307__REG_CONTROL);
twi__send_data(register_value);
twi__stop();
}
 
/**************************************************************************//**
* \fn uint8_t ds1307__read_byte_in_ram(uint8_t address)
*
* \brief Read a byte in DS1307 RAM.
*
* \param address Address to read.
*
* \return Read byte.
******************************************************************************/
uint8_t
ds1307__read_byte_in_ram
(
uint8_t address
){
// Check the preconditions.
assert(address >= 0x08);
assert(address <= 0x3F);
 
uint8_t data = 0;
 
twi__start();
twi__send_slaw(DS1307__ADDRESS);
twi__send_data(address);
twi__stop();
 
twi__start();
twi__send_slar(DS1307__ADDRESS);
twi__receive_data_nack(&data);
twi__stop();
 
return data;
}
 
/**************************************************************************//**
* \fn void ds1307__read_bytes_in_ram(
* uint8_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Read bytes in DS1307 RAM.
*
* \param address Address to read.
* \param length Number of bytes to read.
* \param[in] p_data Buffer to fill.
******************************************************************************/
void
ds1307__read_bytes_in_ram
(
uint8_t address,
uint8_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
assert(address >= 0x08);
assert(address <= 0x3F);
assert(length <= 56);
 
twi__start();
twi__send_slaw(DS1307__ADDRESS);
twi__send_data(address);
twi__stop();
 
twi__start();
twi__send_slar(DS1307__ADDRESS);
for (uint8_t i = 0; i < length - 1; i++)
{
twi__receive_data_ack(p_data + i);
}
twi__receive_data_nack(p_data + length - 1);
twi__stop();
}
 
/**************************************************************************//**
* \fn void ds1307__write_byte_in_ram(uint8_t address, uint8_t data)
*
* \brief Write a byte in DS1307 RAM.
*
* \param address Address to write.
* \param data Byte to write.
******************************************************************************/
void
ds1307__write_byte_in_ram
(
uint8_t address,
uint8_t data
){
// Check the preconditions.
assert(address >= 0x08);
assert(address <= 0x3F);
 
twi__start();
twi__send_slaw(DS1307__ADDRESS);
twi__send_data(address);
twi__send_data(data);
twi__stop();
}
 
/**************************************************************************//**
* \fn void ds1307__write_bytes_in_ram(uint8_t address, uint8_t data)
*
* \brief Write a byte in DS1307 RAM.
*
* \param address Address to write.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
void
ds1307__write_bytes_in_ram
(
uint8_t address,
uint8_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
assert(address >= 0x08);
assert(address <= 0x3F);
assert(length <= 56);
 
twi__start();
twi__send_slaw(DS1307__ADDRESS);
twi__send_data(address);
for (uint8_t i = 0; i < length; i++)
{
twi__send_data(p_data[i]);
}
twi__stop();
}
/trunk/libraries/ds1307/src/SConscript
0,0 → 1,13
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'ds1307'
 
# Define source files.
sources = [
'ds1307.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/ds1307/demo/ds1307__demo.c
0,0 → 1,95
/**************************************************************************//**
* \brief DS1307 RTC library - Demonstration program
* \author Copyright (C) 2009 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090501
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file ds1307__demo.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../ds1307.h"
 
#include <twi/twi.h>
#include <useful/datetime.h>
 
#include <util/delay.h>
 
#include <stdio.h>
 
/******************************************************************************
* Main function.
******************************************************************************/
 
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
*
* \return 0
******************************************************************************/
int main(void)
{
// Initialize TWI.
twi__initialize(DS1307__CLOCK_RATE);
 
// Initialize RTC.
ds1307__initialize();
 
// Declare some variables.
datetime__time_t time =
{
.seconds = 00,
.minutes = 29,
.hours = 19,
.meridiem = 0
};
ds1307__hour_mode_t hour_mode = DS1307__HOUR_MODE__24_HOUR;
 
datetime__date_t date =
{
.day = 3,
.date = 5,
.month = 5,
.year = 9
};
 
// Set time and hour mode.
ds1307__set_time(&time, hour_mode);
 
// Set date.
ds1307__set_date(&date);
 
for (;;)
{
// Get RTC time.
ds1307__get_time(&time, &hour_mode);
 
// Get RTC date.
ds1307__get_date(&date);
 
_delay_ms(100);
}
 
return 0;
}
/trunk/libraries/ds1307/demo/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'ds1307__demo'
 
# Set source file.
sources = [
'ds1307__demo.c'
]
 
# Build project and libraries.
env_target.BuildProject(sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/libraries/ds1307/test/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'ds1307__test'
 
# Set source file.
sources = [
'ds1307__test.c'
]
 
# Build project and libraries.
env_target.BuildProject(sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/libraries/ds1307/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/ds1307/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/ds1307/SConstruct
0,0 → 1,40
# Import build tools.
SConscript('#min_env/build_tools.py')
 
# Set environment for AVR-GCC.
SConscript('#min_env/env_target.py')
 
# Import environment set for AVR-GCC.
Import('env_target')
 
# Append CPPPATH.
env_target.Append(CPPPATH = [ '#../' ])
 
# Build library.
SConscript(
'src/SConscript',
variant_dir = '#build/lib/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Append LIBPATH and LIBS.
env_target.Append(LIBPATH = [ '#build/lib/'])
env_target.Append(LIBS = [ 'ds1307' ])
 
# Build demonstration program.
SConscript(
'demo/SConscript',
variant_dir = '#build/demo/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Build test program.
SConscript(
'test/SConscript',
variant_dir = '#build/test/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
/trunk/libraries/ds1307/min_env/env_target.py
0,0 → 1,27
# Create and initialize the environment.
env_target = Environment()
 
# Set environment for AVR-GCC.
env_target['CC'] = 'avr-gcc'
env_target['CPPPATH'] = '/usr/lib/avr/include'
env_target['OBJCOPY'] = 'avr-objcopy'
env_target['SIZE'] = 'avr-size'
env_target['AR'] = 'avr-ar'
env_target['RANLIB'] = 'avr-ranlib'
env_target.Append(CCFLAGS = '-Os')
 
# Define environment name.
env_target.Append(NAME = 'env_target')
 
# Microcontroller type.
env_target.Append(MCU = 'atmega328p')
# Microcontroller frequency in Hertz.
env_target.Append(F_CPU = '16000000UL')
 
# Set environment for an Atmel AVR ATmega328p microcontroller.
env_target.Append(CCFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(LINKFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(CPPDEFINES = 'F_CPU=' + env_target['F_CPU'])
 
# Export environment set for target.
Export('env_target')
/trunk/libraries/ds1307/min_env/build_tools.py
0,0 → 1,41
"""
Build project.
"""
def BuildProject(env, sources, target_name):
# Build program.
env.Program(target = target_name + '.elf', source = sources)
# Create hex binary file.
env.Command(
target_name + '.hex',
target_name + '.elf',
env['OBJCOPY'] + ' -O ihex $SOURCE $TARGET'
)
AddMethod(Environment, BuildProject)
 
"""
Build library.
"""
def BuildLibrary(env, sources, target_name):
# Build static library.
env.StaticLibrary(target = target_name, source = sources)
# Append LIBPATH and LIBS.
env.Append(LIBPATH = [ '#build/libraries/' + target_name + '/' + env['NAME'] ])
env.Append(LIBS = [ target_name ])
 
AddMethod(Environment, BuildLibrary)
 
"""
Compute memory usage.
"""
def ComputeMemoryUsage(env, target_name):
# Compute memory usage.
env.Command(
None,
target_name + '.elf',
env['SIZE'] + ' -C --mcu=' + env['MCU'] + ' $SOURCE'
)
AddMethod(Environment, ComputeMemoryUsage)
/trunk/libraries/adc/demo/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'adc__demo'
 
# Set source file.
sources = [
'adc__demo.c'
]
 
# Build project and libraries.
env_target.BuildProject(sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/libraries/adc/demo/adc__demo.c
0,0 → 1,60
/**************************************************************************//**
* \brief ADC library - Demonstration program
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121104
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file adc__demo.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../adc.h"
 
#include <util/delay.h>
 
/******************************************************************************
* Main function.
******************************************************************************/
 
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
******************************************************************************/
int
main
(
void
){
// Initialize ADC.
adc__single_channel_initialize(ADC__CHANNEL_0);
 
for (;;)
{
// Read ADC value.
uint16_t value = adc__single_channel_read();
_delay_ms(100);
}
 
return 0;
}
/trunk/libraries/adc/src/adc.c
0,0 → 1,98
/**************************************************************************//**
* \brief ADC library.
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121029
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file adc.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../adc.h"
 
#include <useful/bits.h>
 
#include <avr/io.h>
 
#include <stdint.h>
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void adc__single_channel_initialize(adc__channel_t channel)
*
* \brief Initialize ADC.
*
* \param channel ADC channel.
******************************************************************************/
void
adc__single_channel_initialize
(
adc__channel_t channel
){
// Enable ADC.
BIT__SET(ADCSRA, ADEN);
 
// Clock prescaled by 16.
// If Clock speed is 16 MHz, then ADC clock = 16 MHz / 16 = 1 MHz.
ADCSRA |= 0b00000100;
 
// Disable Digital Input on ADC Channel 0 to reduce power consumption
DIDR0 = 0b00111111;
 
// Disable Left-Adjust.
ADMUX = 0b01000000;
 
// Select ADC channel as input.
ADMUX |= channel;
}
 
/**************************************************************************//**
* \fn uint16_t adc__single_channel_read(void)
*
* \brief Read ADC.
*
* \return Read value.
******************************************************************************/
uint16_t
adc__single_channel_read
(
void
){
// Start ADC Conversion.
BIT__SET(ADCSRA, ADSC);
 
// Wait till conversion is complete.
//while ((ADCSRA & (1 << ADIF)) != 0x10);
while (!BIT__TST(ADCSRA, ADIF));
 
// Read the ADC Result.
uint16_t value = ADC;
 
// Clear ADC Conversion Interrupt Flag.
BIT__RST(ADCSRA, ADIF);
 
return value;
}
/trunk/libraries/adc/src/SConscript
0,0 → 1,13
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'adc'
 
# Define source files.
sources = [
'adc.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/adc/min_env/env_target.py
0,0 → 1,27
# Create and initialize the environment.
env_target = Environment()
 
# Set environment for AVR-GCC.
env_target['CC'] = 'avr-gcc'
env_target['CPPPATH'] = '/usr/lib/avr/include'
env_target['OBJCOPY'] = 'avr-objcopy'
env_target['SIZE'] = 'avr-size'
env_target['AR'] = 'avr-ar'
env_target['RANLIB'] = 'avr-ranlib'
env_target.Append(CCFLAGS = '-Os')
 
# Define environment name.
env_target.Append(NAME = 'env_target')
 
# Microcontroller type.
env_target.Append(MCU = 'atmega328p')
# Microcontroller frequency in Hertz.
env_target.Append(F_CPU = '16000000UL')
 
# Set environment for an Atmel AVR ATmega328p microcontroller.
env_target.Append(CCFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(LINKFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(CPPDEFINES = 'F_CPU=' + env_target['F_CPU'])
 
# Export environment set for target.
Export('env_target')
/trunk/libraries/adc/min_env/build_tools.py
0,0 → 1,41
"""
Build project.
"""
def BuildProject(env, sources, target_name):
# Build program.
env.Program(target = target_name + '.elf', source = sources)
# Create hex binary file.
env.Command(
target_name + '.hex',
target_name + '.elf',
env['OBJCOPY'] + ' -O ihex $SOURCE $TARGET'
)
AddMethod(Environment, BuildProject)
 
"""
Build library.
"""
def BuildLibrary(env, sources, target_name):
# Build static library.
env.StaticLibrary(target = target_name, source = sources)
# Append LIBPATH and LIBS.
env.Append(LIBPATH = [ '#build/libraries/' + target_name + '/' + env['NAME'] ])
env.Append(LIBS = [ target_name ])
 
AddMethod(Environment, BuildLibrary)
 
"""
Compute memory usage.
"""
def ComputeMemoryUsage(env, target_name):
# Compute memory usage.
env.Command(
None,
target_name + '.elf',
env['SIZE'] + ' -C --mcu=' + env['MCU'] + ' $SOURCE'
)
AddMethod(Environment, ComputeMemoryUsage)
/trunk/libraries/adc/adc.h
0,0 → 1,99
/**************************************************************************//**
* \brief ADC library.
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121029
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile adc.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__ADC__H
#define H__IDREAMMICRO__ADC__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <stdint.h>
 
/******************************************************************************
* Public type definitions.
******************************************************************************/
 
/**************************************************************************//**
* \enum adc__channels
* \brief ADC channels.
*
* \typedef adc__channel_t
* \brief ADC channel.
******************************************************************************/
typedef enum adc__channels
{
ADC__CHANNEL_0, /*!< Channel 0. */
ADC__CHANNEL_1, /*!< Channel 1. */
ADC__CHANNEL_2, /*!< Channel 2. */
ADC__CHANNEL_3, /*!< Channel 3. */
ADC__CHANNEL_4, /*!< Channel 4. */
ADC__CHANNEL_5, /*!< Channel 5. */
ADC__CHANNEL_6, /*!< Channel 6. */
ADC__CHANNEL_7, /*!< Channel 7. */
ADC__CHANNEL_8 /*!< Channel 8. */
} adc__channel_t;
 
/******************************************************************************
* Public function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void adc__single_channel_initialize(adc__channel_t channel)
*
* \brief Initialize ADC.
*
* \param channel ADC channel.
******************************************************************************/
void
adc__single_channel_initialize
(
adc__channel_t channel
);
 
/**************************************************************************//**
* \fn uint16_t adc__single_channel_read(void)
*
* \brief Read ADC.
*
* \return Read value.
******************************************************************************/
uint16_t
adc__single_channel_read
(
void
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__ADC__H */
 
/trunk/libraries/adc/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/adc/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/adc/SConstruct
0,0 → 1,40
# Import build tools.
SConscript('#min_env/build_tools.py')
 
# Set environment for AVR-GCC.
SConscript('#min_env/env_target.py')
 
# Import environment set for AVR-GCC.
Import('env_target')
 
# Append CPPPATH.
env_target.Append(CPPPATH = [ '#../' ])
 
# Build library.
SConscript(
'src/SConscript',
variant_dir = '#build/lib/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Append LIBPATH and LIBS.
env_target.Append(LIBPATH = [ '#build/lib/'])
env_target.Append(LIBS = [ 'adc' ])
 
# Build demonstration program.
SConscript(
'demo/SConscript',
variant_dir = '#build/demo/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Build test program.
SConscript(
'test/SConscript',
variant_dir = '#build/test/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
/trunk/libraries/adc
Modification de propriétés sur libraries/adc
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,2 ##
+build
+.sconsign.dblite
/trunk/libraries/deuligne/demo/deuligne__demo.c
0,0 → 1,103
/**************************************************************************//**
* \brief Deuligne library - Demonstration program
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121026
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file deuligne__demo.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <deuligne/deuligne.h>
#include <mcp23008/mcp23008.h>
#include <twi/twi.h>
 
#include <util/delay.h>
 
#include <stdio.h>
 
/******************************************************************************
* Private constant definitions.
******************************************************************************/
 
static const char* strings[] =
{
[DEULIGNE__KEY__RIGHT] = "Right Key OK ",
[DEULIGNE__KEY__UP] = "Up Key OK ",
[DEULIGNE__KEY__DOWN] = "Down Key OK ",
[DEULIGNE__KEY__LEFT] = "Left Key OK ",
[DEULIGNE__KEY__SELECT] = "Select Key OK"
};
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
******************************************************************************/
int
main
(
void
){
// Initialize TWI.
twi__initialize(MCP23008__CLOCK_RATE);
 
// Initialize Deuligne and configure display.
deuligne__initialize();
deuligne__set_display(true, false, false);
 
// Switch on backlight.
deuligne__switch_on_backlight();
 
deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_1, 5);
deuligne__write_string("Setup");
deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_2, 7);
deuligne__write_string("ok");
_delay_ms(2000);
 
deuligne__clear_display();
deuligne__write_string("Move Joystick");
 
// Infinite loop.
for(;;)
{
// Get key.
deuligne__key_t key = deuligne__get_key();
if (key != DEULIGNE__KEY__NONE)
{
// Set cursor position.
deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_2, 0);
 
// Write string.
deuligne__write_string(strings[key]);
}
 
_delay_ms(250);
}
 
return 0;
}
/trunk/libraries/deuligne/demo/SConscript
0,0 → 1,26
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'deuligne__demo'
 
# Set libraries to use.
libraries = [
'deuligne',
'mcp23008',
'adc',
'twi'
]
 
# Set source file.
sources = [
'deuligne__demo.c'
]
 
# Build project and libraries.
env_target.BuildProject(sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/libraries/deuligne/min_env/env_target.py
0,0 → 1,27
# Create and initialize the environment.
env_target = Environment()
 
# Set environment for AVR-GCC.
env_target['CC'] = 'avr-gcc'
env_target['CPPPATH'] = '/usr/lib/avr/include'
env_target['OBJCOPY'] = 'avr-objcopy'
env_target['SIZE'] = 'avr-size'
env_target['AR'] = 'avr-ar'
env_target['RANLIB'] = 'avr-ranlib'
env_target.Append(CCFLAGS = '-Os')
 
# Define environment name.
env_target.Append(NAME = 'env_target')
 
# Microcontroller type.
env_target.Append(MCU = 'atmega328p')
# Microcontroller frequency in Hertz.
env_target.Append(F_CPU = '16000000UL')
 
# Set environment for an Atmel AVR ATmega328p microcontroller.
env_target.Append(CCFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(LINKFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(CPPDEFINES = 'F_CPU=' + env_target['F_CPU'])
 
# Export environment set for target.
Export('env_target')
/trunk/libraries/deuligne/min_env/build_tools.py
0,0 → 1,41
"""
Build project.
"""
def BuildProject(env, sources, target_name):
# Build program.
env.Program(target = target_name + '.elf', source = sources)
# Create hex binary file.
env.Command(
target_name + '.hex',
target_name + '.elf',
env['OBJCOPY'] + ' -O ihex $SOURCE $TARGET'
)
AddMethod(Environment, BuildProject)
 
"""
Build library.
"""
def BuildLibrary(env, sources, target_name):
# Build static library.
env.StaticLibrary(target = target_name, source = sources)
# Append LIBPATH and LIBS.
env.Append(LIBPATH = [ '#build/libraries/' + target_name + '/' + env['NAME'] ])
env.Append(LIBS = [ target_name ])
 
AddMethod(Environment, BuildLibrary)
 
"""
Compute memory usage.
"""
def ComputeMemoryUsage(env, target_name):
# Compute memory usage.
env.Command(
None,
target_name + '.elf',
env['SIZE'] + ' -C --mcu=' + env['MCU'] + ' $SOURCE'
)
AddMethod(Environment, ComputeMemoryUsage)
/trunk/libraries/deuligne/deuligne.h
0,0 → 1,344
/**************************************************************************//**
* \brief Snootlab Deuligne library
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121026
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile deuligne.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__DEULIGNE__H
#define H__IDREAMMICRO__DEULIGNE__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <stdbool.h>
#include <stdint.h>
 
/******************************************************************************
* Public types.
******************************************************************************/
 
/**************************************************************************//**
* \enum deuligne__keys
* \brief Available keys.
*
* \typedef deuligne__key_t
* \brief Key.
******************************************************************************/
typedef enum deuligne__keys
{
DEULIGNE__KEY__RIGHT,
DEULIGNE__KEY__UP,
DEULIGNE__KEY__DOWN,
DEULIGNE__KEY__LEFT,
DEULIGNE__KEY__SELECT,
DEULIGNE__KEY__NONE
} deuligne__key_t;
 
/**************************************************************************//**
* \enum deuligne__display_lines
* \brief LCD display lines.
*
* \typedef deuligne__display_line_t
* \brief LCD display line.
******************************************************************************/
typedef enum deuligne__display_lines
{
DEULIGNE__DISPLAY_LINE_1, /*!< One line display. */
DEULIGNE__DISPLAY_LINE_2 /*!< Two lines or more display. */
} deuligne__display_line_t;
 
/**************************************************************************//**
* \enum lcd__character_fonts
* \brief LCD character fonts.
*
* \typedef lcd__character_font_t
* \brief LCD character font.
******************************************************************************/
typedef enum deuligne__character_fonts
{
DEULIGNE__CHARACTER_FONT_5x8_DOTS, /*!< 5x8 character font. */
DEULIGNE__CHARACTER_FONT_5x10_DOTS /*!< 5x10 character font. */
} deuligne__character_font_t;
 
/**************************************************************************//**
* \enum lcd__address_modes
* \brief LCD address modes.
*
* \typedef lcd__address_mode_t
* \brief LCD address mode.
******************************************************************************/
typedef enum deuligne__address_modes
{
DEULIGNE__INCREMENT_ADDRESS, /*!< Increment address. */
DEULIGNE__DECREMENT_ADDRESS /*!< Decrement address. */
} deuligne__address_mode_t;
 
/**************************************************************************//**
* \enum lcd__display_shifts
* \brief LCD display shift types.
*
* \typedef lcd__display_shift_t
* \brief LCD display shift type.
******************************************************************************/
typedef enum deuligne__display_shifts
{
DEULIGNE__DISPLAY_SHIFT_DISABLED, /*!< Display shift disabled. */
DEULIGNE__DISPLAY_SHIFT_RIGHT, /*!< Display shift to right. */
DEULIGNE__DISPLAY_SHIFT_LEFT /*!< Display shift to left */
} deuligne__display_shift_t;
 
/**************************************************************************//**
* \enum lcd__shift_directions
* \brief LCD shift directions.
*
* \typedef lcd__shift_direction_t
* \brief LCD shift direction.
******************************************************************************/
typedef enum deuligne__shift_directions
{
DEULIGNE__SHIFT_DIRECTION_RIGHT, /*!< Shift to right. */
DEULIGNE__SHIFT_DIRECTION_LEFT /*!< Shift to left. */
} deuligne__shift_direction_t;
 
/**************************************************************************//**
* \enum lcd__lines
* \brief LCD lines.
*
* \typedef lcd__line_t
* \brief LCD line.
******************************************************************************/
typedef enum deuligne__lines
{
DEULIGNE__LINE_1, /*!< Line 1. */
DEULIGNE__LINE_2, /*!< Line 2. */
DEULIGNE__LINE_3, /*!< Line 3. */
DEULIGNE__LINE_4 /*!< Line 4. */
} deuligne__line_t;
 
/******************************************************************************
* Public function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void deuligne__initialize(void)
*
* \brief Initialize Deuligne.
******************************************************************************/
void
deuligne__initialize
(
void
);
 
/**************************************************************************//**
* \fn void deuligne__set_function(
* deuligne__display_line_t display_line,
* deuligne__character_font_t character_font)
*
* \brief Set the number of lines available on LCD display and the character font.
*
* \param display_line number of lines
* \param character_font character font
******************************************************************************/
void
deuligne__set_function
(
deuligne__display_line_t display_line,
deuligne__character_font_t character_font
);
 
/**************************************************************************//**
* \fn void deuligne__set_entry_mode(
* deuligne__address_mode_t address_mode,
* deuligne__display_shift_t display_shift)
*
* \brief Set LCD display entry mode.
*
* \param address_mode specify if DDRAM address is incremented or decremented
* when a character code is written
* \param display_shift set the display shift when a character code is written
******************************************************************************/
void
deuligne__set_entry_mode
(
deuligne__address_mode_t address_mode,
deuligne__display_shift_t display_shift
);
 
/**************************************************************************//**
* \fn void deuligne__set_display(
* bool enable_display,
* bool enable_cursor_display,
* bool enable_cursor_blink)
*
* \brief Set LCD display.
* Enable or disable display, cursor display and cursor blink.
*
* \param enable_display true to enable display or false in contrary case
* \param enable_cursor_display true to enable cursor display or false in
* contrary case
* \param enable_cursor_blink true to enable cursor blink or false in contrary
* case
******************************************************************************/
void
deuligne__set_display
(
bool enable_display,
bool enable_cursor_display,
bool enable_cursor_blink
);
 
/**************************************************************************//**
* \fn void deuligne__clear_display(void)
*
* \brief Clear LCD display.
******************************************************************************/
void
deuligne__clear_display
(
void
);
 
/**************************************************************************//**
* \fn void deuligne__return_home(void)
*
* \brief Set cursor on the first column of the first line.
******************************************************************************/
void
deuligne__return_home
(
void
);
 
/**************************************************************************//**
*\fn void deuligne__set_cursor_position(deuligne__line_t line, uint8_t column)
*
* \brief Set cursor position.
*
* \param line destination line
* \param column destination column
******************************************************************************/
void
deuligne__set_cursor_position
(
deuligne__line_t line,
uint8_t column
);
 
/**************************************************************************//**
* \fn void deuligne__shift_display(deuligne__shift_direction_t shift_direction)
*
* \brief Shift the display on the right or on the left.
*
* \param shift_direction display shift direction
******************************************************************************/
void
deuligne__shift_display
(
deuligne__shift_direction_t shift_direction
);
 
/**************************************************************************//**
* \fn void deuligne__shift_cursor(deuligne__shift_direction_t shift_direction)
*
* \brief Shift the cursor on the right or on the left.
*
* \param shift_direction cursor shift direction
******************************************************************************/
void
deuligne__shift_cursor
(
deuligne__shift_direction_t shift_direction
);
 
/**************************************************************************//**
* \fn void deuligne__switch_on_backlight(void)
*
* \brief Switch on LCD backlight.
******************************************************************************/
void
deuligne__switch_on_backlight
(
void
);
 
/**************************************************************************//**
* \fn void deuligne__switch_off(voif)
*
* \brief Switch off backlight.
******************************************************************************/
void
deuligne__switch_off_backlight
(
void
);
 
/**************************************************************************//**
* \fn void deuligne__write_char(char data)
*
* \brief Write a character on LCD.
*
* \param data Character to write.
******************************************************************************/
void
deuligne__write_char
(
char data
);
 
/**************************************************************************//**
* \fn void deuligne__write_string(const char* string_to_write)
*
* \brief Write a string on LCD display from current cursor position.
*
* \param string_to_write string to write
******************************************************************************/
void
deuligne__write_string
(
const char* string_to_write
);
 
/**************************************************************************//**
* \fn void deuligne__get_key(void)
*
* \brief Get key.
*
* \return Key.
******************************************************************************/
deuligne__key_t
deuligne__get_key
(
void
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__DEULIGNE__H */
/trunk/libraries/deuligne/src/SConscript
0,0 → 1,13
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'deuligne'
 
# Define source files.
sources = [
'deuligne.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/deuligne/src/deuligne.c
0,0 → 1,733
/**************************************************************************//**
* \brief Snootlab Deuligne library
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121026
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile deuligne.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../deuligne.h"
 
#include <adc/adc.h>
#include <mcp23008/mcp23008.h>
 
#include <util/delay.h>
 
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
 
/******************************************************************************
* Private macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def DEULIGNE__HARDWARE_ADDRESS
* \brief MCP23008 hardware address. Pins A0 to A3.
******************************************************************************/
#define DEULIGNE__HARDWARE_ADDRESS 0x07
 
#define DEULIGNE__GPIO_E 4
#define DEULIGNE__GPIO_RW 5
#define DEULIGNE__GPIO_RS 6
#define DEULIGNE__GPIO_BACKLIGHT 7
 
/**************************************************************************//**
* \def LCD__CMD_CLEAR_DISPLAY
* \brief Clear display.
******************************************************************************/
#define LCD__CMD_CLEAR_DISPLAY 0x01
 
/**************************************************************************//**
* \def LCD__CMD_RETURN_HOME
* \brief Return Home (execution time = 1.52 ms).
******************************************************************************/
#define LCD__CMD_RETURN_HOME 0x02
 
// Function set (execution time = 37 s).
#define LCD__CMD_FUNCTION_SET 0x20
#define LCD__CMD_DATA_LENGTH_4_BIT 0x00
#define LCD__CMD_DATA_LENGTH_8_BIT 0x10
#define LCD__CMD_DISPLAY_LINE_1 0x00
#define LCD__CMD_DISPLAY_LINE_2 0x08
#define LCD__CMD_CHARACTER_FONT_5x8_DOTS 0x00
#define LCD__CMD_CHARACTER_FONT_5x10_DOTS 0x04
 
// Set entry mode (execution time = 37 s).
#define LCD__CMD_ENTRY_MODE_SET 0x04
#define LCD__CMD_INCREMENT_ADDRESS 0x02
#define LCD__CMD_DECREMENT_ADDRESS 0x00
#define LCD__CMD_DISPLAY_SHIFT_DISABLED 0x00
#define LCD__CMD_DISPLAY_SHIFT_RIGHT 0x01
#define LCD__CMD_DISPLAY_SHIFT_LEFT 0x03
 
// Display on/off control (execution time = 37 s).
#define LCD__CMD_DISPLAY_CONTROL 0x08
#define LCD__CMD_ENABLE_DISPLAY 0x04
#define LCD__CMD_DISABLE_DISPLAY 0x00
#define LCD__CMD_ENABLE_CURSOR_DISPLAY 0x02
#define LCD__CMD_DISABLE_CURSOR_DISPLAY 0x00
#define LCD__CMD_ENABLE_CURSOR_BLINK 0x01
#define LCD__CMD_DISABLE_CURSOR_BLINK 0x00
 
// Cursor or display shift (execution time = 37 s).
#define LCD__CMD_CURSOR_OR_DISPLAY_SHIFT 0x10
#define LCD__CMD_SHIFT_CURSOR 0x00
#define LCD__CMD_SHIFT_DISPLAY 0x08
#define LCD__CMD_SHIFT_RIGHT 0x04
#define LCD__CMD_SHIFT_LEFT 0x00
 
// CGRAM address.
#define LCD__CMD_SET_CGRAM_ADDRESS 0x40
 
// DDRAM address.
#define LCD__CMD_SET_DDRAM_ADDRESS 0x80
 
// Line addresses.
#define LCD__LINE_1_ADDRESS 0x40
#define LCD__LINE_2_ADDRESS 0x80
#define LCD__LINE_3_ADDRESS 0x54
#define LCD__LINE_4_ADDRESS 0x94
 
/******************************************************************************
* Private function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void deuligne__write_command(uint8_t command)
*
* \brief Write a command on LCD port.
*
* \param command Command to write.
******************************************************************************/
static
void
deuligne__write_command
(
uint8_t command
);
 
/**************************************************************************//**
* \fn static void deuligne__write_byte(uint8_t data)
*
* \brief Write a byte on LCD port.
*
* \param data Byte to write.
******************************************************************************/
static
void
deuligne__write_byte
(
uint8_t data
);
 
/**************************************************************************//**
* \fn static void deuligne__write_high_nibble(uint8_t data)
*
* \brief Write the high nibble of a byte on LCD port.
*
* \param data Byte which write high nibble.
******************************************************************************/
static
void
deuligne__write_high_nibble
(
uint8_t data
);
 
/**************************************************************************//**
* \fn static void deuligne__enable_data(void)
*
* \brief Enable data on LCD port.
******************************************************************************/
static
void
deuligne__enable_data
(
void
);
 
/******************************************************************************
* Private constant definitions.
******************************************************************************/
 
/**************************************************************************//**
*
******************************************************************************/
static const uint16_t deuligne__adc_values[] =
{
[DEULIGNE__KEY__RIGHT] = 50,
[DEULIGNE__KEY__UP] = 190,
[DEULIGNE__KEY__DOWN] = 400,
[DEULIGNE__KEY__LEFT] = 540,
[DEULIGNE__KEY__SELECT] = 770,
[DEULIGNE__KEY__NONE] = 1024
};
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void deuligne__initialize(void)
*
* \brief Initialize Deuligne.
******************************************************************************/
void
deuligne__initialize
(
void
){
// Initialize MCP23008.
mcp23008__initialize(DEULIGNE__HARDWARE_ADDRESS);
 
// Configure all GPIOs in output.
mcp23008__configure_port(0x00);
 
mcp23008__set_pin_level(DEULIGNE__GPIO_RW, MCP23008__LEVEL__LOW);
 
// Wait for LCD display power-up initialization.
_delay_ms(45);
 
// Initialize LCD display.
 
// Set interface.
deuligne__write_high_nibble(LCD__CMD_FUNCTION_SET | LCD__CMD_DATA_LENGTH_8_BIT);
deuligne__write_high_nibble(LCD__CMD_FUNCTION_SET | LCD__CMD_DATA_LENGTH_8_BIT);
deuligne__write_high_nibble(LCD__CMD_FUNCTION_SET | LCD__CMD_DATA_LENGTH_8_BIT);
deuligne__write_high_nibble(LCD__CMD_FUNCTION_SET | LCD__CMD_DATA_LENGTH_4_BIT);
 
// Set function.
deuligne__set_function(DEULIGNE__DISPLAY_LINE_2, DEULIGNE__CHARACTER_FONT_5x8_DOTS);
 
// Set entry mode.
deuligne__set_entry_mode(DEULIGNE__INCREMENT_ADDRESS, DEULIGNE__DISPLAY_SHIFT_DISABLED);
 
// Clear display.
deuligne__clear_display();
 
// Initialize ADC.
adc__single_channel_initialize(ADC__CHANNEL_0);
}
 
/**************************************************************************//**
* \fn void deuligne__switch_on_backlight(void)
*
* \brief Switch on backlight.
******************************************************************************/
void
deuligne__switch_on_backlight
(
void
){
mcp23008__set_pin_level(DEULIGNE__GPIO_BACKLIGHT, MCP23008__LEVEL__HIGH);
}
 
/**************************************************************************//**
* \fn void deuligne__switch_off_backlight(void)
*
* \brief Switch off backlight.
******************************************************************************/
void
deuligne__switch_off_backlight
(
void
){
mcp23008__set_pin_level(DEULIGNE__GPIO_BACKLIGHT, MCP23008__LEVEL__LOW);
}
 
/**************************************************************************//**
* \fn void deuligne__set_function(
* deuligne__display_line_t display_line,
* deuligne__character_font_t character_font)
*
* \brief Set the number of lines available on LCD display and the character font.
*
* \param display_line number of lines
* \param character_font character font
******************************************************************************/
void
deuligne__set_function
(
deuligne__display_line_t display_line,
deuligne__character_font_t character_font
){
uint8_t command = LCD__CMD_FUNCTION_SET;
 
switch (display_line)
{
case DEULIGNE__DISPLAY_LINE_1:
{
command |= LCD__CMD_DISPLAY_LINE_1;
}
break;
 
case DEULIGNE__DISPLAY_LINE_2:
{
command |= LCD__CMD_DISPLAY_LINE_2;
}
break;
 
default:
break;
}
 
switch (character_font)
{
case DEULIGNE__CHARACTER_FONT_5x8_DOTS:
{
command |= LCD__CMD_CHARACTER_FONT_5x8_DOTS;
}
break;
 
case DEULIGNE__CHARACTER_FONT_5x10_DOTS:
{
command |= LCD__CMD_CHARACTER_FONT_5x10_DOTS;
}
break;
 
default:
break;
}
 
deuligne__write_command(command);
}
 
/**************************************************************************//**
* \fn void deuligne__set_entry_mode(
* deuligne__address_mode_t address_mode,
* deuligne__display_shift_t display_shift)
*
* \brief Set LCD display entry mode.
*
* \param address_mode specify if DDRAM address is incremented or decremented
* when a character code is written
* \param display_shift set the display shift when a character code is written
******************************************************************************/
void
deuligne__set_entry_mode
(
deuligne__address_mode_t address_mode,
deuligne__display_shift_t display_shift
){
uint8_t command = LCD__CMD_ENTRY_MODE_SET;
 
switch (address_mode)
{
case DEULIGNE__INCREMENT_ADDRESS:
{
command |= LCD__CMD_INCREMENT_ADDRESS;
}
break;
 
case DEULIGNE__DECREMENT_ADDRESS:
{
command |= LCD__CMD_DECREMENT_ADDRESS;
}
break;
 
default:
break;
}
 
switch (display_shift)
{
case DEULIGNE__DISPLAY_SHIFT_DISABLED:
{
command |= LCD__CMD_DISPLAY_SHIFT_DISABLED;
}
break;
 
case DEULIGNE__DISPLAY_SHIFT_RIGHT:
{
command |= LCD__CMD_DISPLAY_SHIFT_RIGHT;
}
break;
 
case DEULIGNE__DISPLAY_SHIFT_LEFT:
{
command |= LCD__CMD_DISPLAY_SHIFT_LEFT;
}
break;
 
default:
break;
}
 
deuligne__write_command(command);
}
 
/**************************************************************************//**
* \fn void deuligne__set_display(
* bool enable_display,
* bool enable_cursor_display,
* bool enable_cursor_blink)
*
* \brief Set LCD display.
* Enable or disable display, cursor display and cursor blink.
*
* \param enable_display true to enable display or false in contrary case
* \param enable_cursor_display true to enable cursor display or false in
* contrary case
* \param enable_cursor_blink true to enable cursor blink or false in contrary
* case
******************************************************************************/
void
deuligne__set_display
(
bool enable_display,
bool enable_cursor_display,
bool enable_cursor_blink
){
uint8_t command = LCD__CMD_DISPLAY_CONTROL;
if (enable_display)
{
command |= LCD__CMD_ENABLE_DISPLAY;
}
if (enable_cursor_display)
{
command |= LCD__CMD_ENABLE_CURSOR_DISPLAY;
}
if (enable_cursor_blink)
{
command |= LCD__CMD_ENABLE_CURSOR_BLINK;
}
deuligne__write_command(command);
}
 
/**************************************************************************//**
* \fn void deuligne__clear_display(void)
*
* \brief Clear LCD display.
* Wait time of 2 ms.
******************************************************************************/
void
deuligne__clear_display
(
void
){
deuligne__write_command(LCD__CMD_CLEAR_DISPLAY);
_delay_ms(2);
}
 
/**************************************************************************//**
* \fn void deuligne__return_home(void)
*
* \brief Set cursor on the first column of the first line.
* Wait time of 2 ms.
******************************************************************************/
void
deuligne__return_home
(
void
){
deuligne__write_command(LCD__CMD_RETURN_HOME);
_delay_ms(2);
}
 
/**************************************************************************//**
*\fn void deuligne__set_cursor_position(
* deuligne__line_t line,
* uint8_t column)
*
* \brief Set cursor position.
*
* \param line destination line
* \param column destination column
******************************************************************************/
void
deuligne__set_cursor_position
(
deuligne__line_t line,
uint8_t column
){
uint8_t address = 0;
 
switch (line)
{
case DEULIGNE__LINE_1:
{
address = LCD__LINE_1_ADDRESS;
}
break;
 
case DEULIGNE__LINE_2:
{
address = LCD__LINE_2_ADDRESS;
}
break;
 
case DEULIGNE__LINE_3:
{
address = LCD__LINE_3_ADDRESS;
}
break;
 
case DEULIGNE__LINE_4:
{
address = LCD__LINE_4_ADDRESS;
}
break;
 
default:
{
address = LCD__LINE_1_ADDRESS;
}
break;
}
 
address += column;
 
deuligne__write_command(LCD__CMD_SET_CGRAM_ADDRESS + address);
}
 
/**************************************************************************//**
* \fn void deuligne__shift_display(deuligne__shift_direction_t shift_direction)
*
* \brief Shift the display on the right or on the left.
*
* \param shift_direction display shift direction
******************************************************************************/
void
deuligne__shift_display
(
deuligne__shift_direction_t shift_direction
){
uint8_t command = LCD__CMD_CURSOR_OR_DISPLAY_SHIFT | LCD__CMD_SHIFT_DISPLAY;
 
switch (shift_direction)
{
case DEULIGNE__SHIFT_DIRECTION_RIGHT:
{
command |= LCD__CMD_SHIFT_RIGHT;
}
break;
 
case DEULIGNE__SHIFT_DIRECTION_LEFT:
{
command |= LCD__CMD_SHIFT_LEFT;
}
break;
 
default:
break;
}
 
deuligne__write_command(command);
}
 
/**************************************************************************//**
* \fn void deuligne__shift_cursor(deuligne__shift_direction_t shift_direction)
*
* \brief Shift the cursor on the right or on the left.
*
* \param shift_direction cursor shift direction
******************************************************************************/
void
deuligne__shift_cursor
(
deuligne__shift_direction_t shift_direction
){
uint8_t command = LCD__CMD_CURSOR_OR_DISPLAY_SHIFT | LCD__CMD_SHIFT_CURSOR;
 
switch (shift_direction)
{
case DEULIGNE__SHIFT_DIRECTION_RIGHT:
{
command |= LCD__CMD_SHIFT_RIGHT;
}
break;
 
case DEULIGNE__SHIFT_DIRECTION_LEFT:
{
command |= LCD__CMD_SHIFT_LEFT;
}
break;
 
default:
break;
}
 
deuligne__write_command(command);
}
 
/**************************************************************************//**
* \fn void deuligne__write_char(char data)
*
* \brief Write a character on LCD.
*
* \param data Character to write.
******************************************************************************/
void
deuligne__write_char
(
char data
){
mcp23008__set_pin_level(DEULIGNE__GPIO_RS, MCP23008__LEVEL__HIGH);
deuligne__write_byte(data);
}
 
/**************************************************************************//**
* \fn void deuligne__write_string(const char* string_to_write)
*
* \brief Write a string on LCD display from current cursor position.
*
* \param string_to_write string to write
******************************************************************************/
void
deuligne__write_string
(
const char* string_to_write
){
// Check the preconditions.
assert(NULL != string_to_write);
 
while (*string_to_write != '\0')
{
deuligne__write_char(*string_to_write++);
}
}
 
/**************************************************************************//**
* \fn void deuligne__get_key(void)
*
* \brief Get key.
*
* \return Key.
******************************************************************************/
deuligne__key_t
deuligne__get_key
(
void
){
deuligne__key_t key = DEULIGNE__KEY__NONE;
 
// Read ADC0 value.
uint16_t value = adc__single_channel_read();
 
// Find key.
for (deuligne__key_t i = DEULIGNE__KEY__RIGHT; i <= DEULIGNE__KEY__NONE; i++)
{
if (value < deuligne__adc_values[i])
{
key = i;
break;
}
}
 
return key;
}
 
/******************************************************************************
* Private function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void deuligne__write_command(uint8_t command)
*
* \brief Write a command on LCD port.
*
* \param command Command to write.
******************************************************************************/
static
void
deuligne__write_command
(
uint8_t command
){
mcp23008__set_pin_level(DEULIGNE__GPIO_RS, MCP23008__LEVEL__LOW);
deuligne__write_byte(command);
}
 
/**************************************************************************//**
* \fn static void deuligne__write_byte(uint8_t data)
*
* \brief Write a byte on LCD port.
*
* \param data Byte to write.
******************************************************************************/
static
void
deuligne__write_byte
(
uint8_t data
){
// Get current port value.
uint8_t port_value = mcp23008__get_port_value() & 0xF0;
 
// Write high nibble.
port_value |= data >> 4;
mcp23008__set_port_value(port_value);
deuligne__enable_data();
_delay_ms(1);
 
// Write low nibble.
port_value &= 0xF0;
port_value |= data & 0x0F;
mcp23008__set_port_value(port_value);
deuligne__enable_data();
_delay_ms(1);
}
 
/**************************************************************************//**
* \fn static void deuligne__write_high_nibble(uint8_t data)
*
* \brief Write the high nibble of a byte on LCD port.
*
* \param data Byte which write high nibble.
******************************************************************************/
static
void
deuligne__write_high_nibble
(
uint8_t data
){
// Get current port value.
uint8_t port_value = mcp23008__get_port_value() & 0xF0;
 
// Write high nibble.
port_value |= data >> 4;
mcp23008__set_port_value(port_value);
deuligne__enable_data();
_delay_ms(1);
}
 
/**************************************************************************//**
* \fn static void deuligne__enable_data(void)
*
* \brief Enable data on LCD port.
******************************************************************************/
static
void
deuligne__enable_data
(
void
){
mcp23008__set_pin_level(DEULIGNE__GPIO_E, MCP23008__LEVEL__HIGH);
_delay_ms(1);
mcp23008__set_pin_level(DEULIGNE__GPIO_E, MCP23008__LEVEL__LOW);
_delay_ms(1);
}
/trunk/libraries/deuligne/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/deuligne/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/deuligne/SConstruct
0,0 → 1,40
# Import build tools.
SConscript('#min_env/build_tools.py')
 
# Set environment for AVR-GCC.
SConscript('#min_env/env_target.py')
 
# Import environment set for AVR-GCC.
Import('env_target')
 
# Append CPPPATH.
env_target.Append(CPPPATH = [ '#../' ])
 
# Build library.
SConscript(
'src/SConscript',
variant_dir = '#build/lib/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Append LIBPATH and LIBS.
env_target.Append(LIBPATH = [ '#build/lib/'])
env_target.Append(LIBS = [ 'deuligne' ])
 
# Build demonstration program.
SConscript(
'demo/SConscript',
variant_dir = '#build/demo/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Build test program.
SConscript(
'test/SConscript',
variant_dir = '#build/test/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
/trunk/libraries/mcp23008/src/mcp23008.c
0,0 → 1,375
/**************************************************************************//**
* \brief MCP23008 library
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 201201025
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file mcp23008.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <mcp23008/mcp23008.h>
 
#include <twi/twi.h>
#include <useful/bits.h>
 
#include <stdint.h>
 
/******************************************************************************
* Private macros.
******************************************************************************/
 
/**************************************************************************//**
* \def MCP23008__ADDRESS
* \brief MCP23008 address on TWI bus (doesn't include hardware address).
* This value is given by the datasheet.
******************************************************************************/
#define MCP23008__ADDRESS 0x40
 
/**************************************************************************//**
* \def MCP23008__REG_IODIR
* \brief I/O direction register.
******************************************************************************/
#define MCP23008__REG_IODIR 0x00
 
/**************************************************************************//**
* \def MCP23008__REG_IPOL
* \brief Input polarity register.
******************************************************************************/
#define MCP23008__REG_IPOL 0x01
 
/**************************************************************************//**
* \def MCP23008__REG_GPINTEN
* \brief Interrupt on change control register.
******************************************************************************/
#define MCP23008__REG_GPINTEN 0x02
 
/**************************************************************************//**
* \def MCP23008__REG_DEFVAL
* \brief Default compare register for interrupt on change.
******************************************************************************/
#define MCP23008__REG_DEFVAL 0x03
 
/**************************************************************************//**
* \def MCP23008__REG_INTCON
* \brief Interrupt control register.
******************************************************************************/
#define MCP23008__REG_INTCON 0x04
 
/**************************************************************************//**
* \def MCP23008__REG_IOCON
* \brief Configuration register.
******************************************************************************/
#define MCP23008__REG_IOCON 0x05
 
/**************************************************************************//**
* \def MCP23008__REG_GPPU
* \brief Pull-up resistor configuration register.
******************************************************************************/
#define MCP23008__REG_GPPU 0x06
 
/**************************************************************************//**
* \def MCP23008__REG_INTF
* \brief Interrupt flag register.
******************************************************************************/
#define MCP23008__REG_INTF 0x07
 
/**************************************************************************//**
* \def MCP23008__REG_INTCAP
* \brief Interrupt capture register.
******************************************************************************/
#define MCP23008__REG_INTCAP 0x08
 
/**************************************************************************//**
* \def MCP23008__REG_GPIO
* \brief Port register.
******************************************************************************/
#define MCP23008__REG_GPIO 0x09
 
/**************************************************************************//**
* \def MCP23008__REG_OLAT
* \brief Output latch register.
******************************************************************************/
#define MCP23008__REG_OLAT 0x0A
 
/******************************************************************************
* Private function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn static uint8_t mcp23008__read_register(uint8_t address)
*
* \brief Read MCP23008 register value.
*
* \param address Address of the register to read value.
******************************************************************************/
static
uint8_t
mcp23008__read_register
(
uint8_t address
);
 
/**************************************************************************//**
* \fn static void mcp23008__write_register(uint8_t address, uint8_t value)
*
* \brief Write MCP23008 register value.
*
* \param address Address of the register to write value.
* \param value Value to write.
******************************************************************************/
static
void
mcp23008__write_register
(
uint8_t address,
uint8_t value
);
 
/******************************************************************************
* Private variable declarations.
******************************************************************************/
 
static uint8_t mcp23008__twi_address = 0;
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void mcp23008__initialize(uint8_t hardware_address)
*
* \brief Initialize MCP23008.
*
* \param hardware_address Hardware address defined by pins A0 to A2.
******************************************************************************/
void
mcp23008__initialize
(
uint8_t hardware_address
){
// We don't initialize TWI here: we may have several devices on the bus.
// Initialize TWI.
//twi__initialize(MCP23008__CLOCK_RATE);
 
// Compute MCP23008 TWI address.
mcp23008__twi_address = MCP23008__ADDRESS | (hardware_address << 1);
 
twi__start();
twi__send_slaw(mcp23008__twi_address);
twi__send_data(MCP23008__REG_IODIR);
twi__send_data(0xFF);
twi__send_data(0x00);
twi__send_data(0x00);
twi__send_data(0x00);
twi__send_data(0x00);
twi__send_data(0x00);
twi__send_data(0x00);
twi__send_data(0x00);
twi__send_data(0x00);
twi__send_data(0x00);
twi__stop();
}
 
/**************************************************************************//**
* \fn void mcp23008__configure pin(
* mcp23008__gpio_t pin,
* mcp23008__direction_t direction)
*
* \brief Configure pin direction.
*
* \param pin Pin to configure.
* \param direction Pin direction.
******************************************************************************/
void
mcp23008__configure_pin
(
 
mcp23008__gpio_t pin,
mcp23008__direction_t direction
){
uint8_t port_configuration = mcp23008__read_register(MCP23008__REG_IODIR);
 
if (MCP23008__DIRECTION__INPUT == direction)
{
BIT__SET(port_configuration, pin);
}
else
{
BIT__RST(port_configuration, pin);
}
 
mcp23008__write_register(MCP23008__REG_IODIR, port_configuration);
}
 
/**************************************************************************//**
* \fn void mcp23008__configure_port(mcp23008__direction_t direction)
*
* \brief Configure port direction.
*
* \param direction Port direction.
******************************************************************************/
void
mcp23008__configure_port
(
mcp23008__direction_t direction
){
mcp23008__write_register(MCP23008__REG_IODIR, direction);
}
 
/**************************************************************************//**
* \fn mcp23008__level_t mcp23008__get_pin_level(mcp23008__gpio_t pin)
*
* \brief Get pin level.
*
* \param pin Pin to get level.
*
* \return Pin level.
******************************************************************************/
mcp23008__level_t
mcp23008__get_pin_level
(
mcp23008__gpio_t pin
){
uint8_t port_value = mcp23008__read_register(MCP23008__REG_GPIO);
 
mcp23008__level_t level = BIT__TST(port_value, pin);
 
return level;
}
 
/**************************************************************************//**
* \fn void mcp23008__set_pin_level(
* mcp23008__gpio_t pin,
* mcp23008__level_t level)
*
* \brief Set pin level.
*
* \param pin Pin to set level.
* \param level Level to set.
******************************************************************************/
void
mcp23008__set_pin_level
(
mcp23008__gpio_t pin,
mcp23008__level_t level
){
uint8_t port_value = mcp23008__read_register(MCP23008__REG_GPIO);
 
if (MCP23008__LEVEL__HIGH == level)
{
BIT__SET(port_value, pin);
}
else
{
BIT__RST(port_value, pin);
}
 
mcp23008__write_register(MCP23008__REG_GPIO, port_value);
}
 
/**************************************************************************//**
* \fn uin8_t mcp23008__get_port_value(void)
*
* \brief Get port value.
*
* \return Port value.
******************************************************************************/
uint8_t
mcp23008__get_port_value
(
void
){
uint8_t value = mcp23008__read_register(MCP23008__REG_GPIO);
 
return value;
}
 
/**************************************************************************//**
* \fn void mcp23008__set_port_value(uint8_t value)
*
* \brief Set port value.
*
* \param value Value to set.
******************************************************************************/
void
mcp23008__set_port_value
(
uint8_t value
){
mcp23008__write_register(MCP23008__REG_GPIO, value);
}
 
/******************************************************************************
* Private function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn static uint8_t mcp23008__read_register(uint8_t address)
*
* \brief Read MCP23008 register value.
*
* \param address Address of the register to read value.
******************************************************************************/
static
uint8_t
mcp23008__read_register
(
uint8_t address
){
uint8_t value = 0;
 
twi__start();
twi__send_slaw(mcp23008__twi_address);
twi__send_data(address);
twi__stop();
 
twi__start();
twi__send_slar(mcp23008__twi_address);
twi__receive_data_nack(&value);
twi__stop();
 
return value;
}
 
/**************************************************************************//**
* \fn static void mcp23008__write_register(uint8_t address, uint8_t value)
*
* \brief Write MCP23008 register value.
*
* \param address Address of the register to write value.
* \param value Value to write.
******************************************************************************/
static
void
mcp23008__write_register
(
uint8_t address,
uint8_t value
){
twi__start();
twi__send_slaw(mcp23008__twi_address);
twi__send_data(address);
twi__send_data(value);
twi__stop();
}
/trunk/libraries/mcp23008/src/SConscript
0,0 → 1,13
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'mcp23008'
 
# Define source files.
sources = [
'mcp23008.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/mcp23008/mcp23008.h
0,0 → 1,248
/**************************************************************************//**
* \brief MCP23008 library
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121025
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile mcp23008.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__MCP23008__H
#define H__IDREAMMICRO__MCP23008__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <stdint.h>
 
/******************************************************************************
* Public macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def MCP23008__CLOCK_RATE
* \brief MCP23008 frequency in Hertz.
* On ATmega, can be 100 kHz or 400 Khz.
******************************************************************************/
#define MCP23008__CLOCK_RATE 400000
 
/******************************************************************************
* MCP23008 GPIOs.
******************************************************************************/
 
/**************************************************************************//**
* \def MCP23008__GP0
* \brief I/O pin 0.
******************************************************************************/
#define MCP23008__GP0 0
 
/**************************************************************************//**
* \def MCP23008__GP1
* \brief I/O pin 1.
******************************************************************************/
#define MCP23008__GP1 1
 
/**************************************************************************//**
* \def MCP23008__GP2
* \brief I/O iin 2.
******************************************************************************/
#define MCP23008__GP2 2
 
/**************************************************************************//**
* \def MCP23008__GP3
* \brief I/O pin 3.
******************************************************************************/
#define MCP23008__GP3 3
 
/**************************************************************************//**
* \def MCP23008__GP4
* \brief I/O pin 4.
******************************************************************************/
#define MCP23008__GP4 4
 
/**************************************************************************//**
* \def MCP23008__GP5
* \brief I/O pin 5.
******************************************************************************/
#define MCP23008__GP5 5
 
/**************************************************************************//**
* \def MCP23008__GP6
* \brief I/O pin 6.
******************************************************************************/
#define MCP23008__GP6 6
 
/**************************************************************************//**
* \def MCP23008__GP7
* \brief I/O pin 7.
******************************************************************************/
#define MCP23008__GP7 7
 
/******************************************************************************
* Public type definitions.
******************************************************************************/
 
/**************************************************************************//**
* \enum mcp23008__directions
* \brief MCP23008 pin/port directions.
*
* \typedef mcp23008__direction_t
* \brief MCP23008 pin/port direction.
******************************************************************************/
typedef enum mcp23008__directions
{
MCP23008__DIRECTION__INPUT, /*!< Input. */
MCP23008__DIRECTION__OUTPUT /*!< Output. */
} mcp23008__direction_t;
 
/**************************************************************************//**
* \enum mcp23008__levels
* \brief MCP23008 GPIO levels.
*
* \typedef mcp23008__level_t
* \brief MCP23008 GPIO level.
******************************************************************************/
typedef enum mcp23008__levels
{
MCP23008__LEVEL__LOW, /*!< Low level. */
MCP23008__LEVEL__HIGH /*!< High level. */
} mcp23008__level_t;
 
/**************************************************************************//**
* \typedef mcp23008__gpio_t
* \brief
******************************************************************************/
typedef uint8_t mcp23008__gpio_t;
 
/******************************************************************************
* Public function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void mcp23008__initialize(uint8_t hardware_address)
*
* \brief Initialize MCP23008.
*
* \param hardware_address Hardware address defined by pins A0 to A2.
******************************************************************************/
void
mcp23008__initialize
(
uint8_t hardware_address
);
 
/**************************************************************************//**
* \fn void mcp23008__configure pin(
* mcp23008__gpio_t pin,
* mcp23008__direction_t direction)
*
* \brief Configure pin direction.
*
* \param pin Pin to configure.
* \param direction Pin direction.
******************************************************************************/
void
mcp23008__configure_pin
(
mcp23008__gpio_t pin,
mcp23008__direction_t direction
);
 
/**************************************************************************//**
* \fn void mcp23008__configure_port(mcp23008__direction_t direction)
*
* \brief Configure port direction.
*
* \param direction Port direction.
******************************************************************************/
void
mcp23008__configure_port
(
mcp23008__direction_t direction
);
 
/**************************************************************************//**
* \fn mcp23008__level_t mcp23008__get_pin_level(mcp23008__gpio_t pin)
*
* \brief Get pin level.
*
* \param pin Pin to get level.
*
* \return Pin level.
******************************************************************************/
mcp23008__level_t
mcp23008__get_pin_level
(
mcp23008__gpio_t pin
);
 
/**************************************************************************//**
* \fn void mcp23008__set_pin_level(
* mcp23008__gpio_t pin,
* mcp23008__level_t level)
*
* \brief Set pin level.
*
* \param pin Pin to set level.
* \param level Level to set.
******************************************************************************/
void
mcp23008__set_pin_level
(
mcp23008__gpio_t pin,
mcp23008__level_t level
);
 
/**************************************************************************//**
* \fn uin8_t mcp23008__get_port_value(void)
*
* \brief Get port value.
*
* \return Port value.
******************************************************************************/
uint8_t
mcp23008__get_port_value
(
void
);
 
/**************************************************************************//**
* \fn void mcp23008__set_port_value(uint8_t value)
*
* \brief Set port value.
*
* \param value Value to set.
******************************************************************************/
void
mcp23008__set_port_value
(
uint8_t value
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__MCP23008__H */
/trunk/libraries/mcp23008/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/mcp23008/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/mcp23008/SConstruct
0,0 → 1,40
# Import build tools.
SConscript('#min_env/build_tools.py')
 
# Set environment for AVR-GCC.
SConscript('#min_env/env_target.py')
 
# Import environment set for AVR-GCC.
Import('env_target')
 
# Append CPPPATH.
env_target.Append(CPPPATH = [ '#../' ])
 
# Build library.
SConscript(
'src/SConscript',
variant_dir = '#build/lib/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Append LIBPATH and LIBS.
env_target.Append(LIBPATH = [ '#build/lib/'])
env_target.Append(LIBS = [ 'mcp23008' ])
 
# Build demonstration program.
SConscript(
'demo/SConscript',
variant_dir = '#build/demo/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Build test program.
SConscript(
'test/SConscript',
variant_dir = '#build/test/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
/trunk/libraries/eeprom_24c128_24c256/src/eeprom_24c128_24c256.c
0,0 → 1,293
/**************************************************************************//**
* \brief EEPROM 24C128/24C256 library.
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121102
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file eeprom_24c128_24c256.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../eeprom_24c128_24c256.h"
 
#include <twi/twi.h>
 
#include <util/delay.h>
 
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
 
/******************************************************************************
* Private macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def EEPROM_24C128_24C256__ADDRESS
* \brief EEPROM 24C128/24C256 address. Given by datasheet.
******************************************************************************/
#define EEPROM_24C128_24C256__ADDRESS 0xA0
 
/**************************************************************************//**
* \def EEPROM_24C128_24C256__PAGE_SIZE
* \brief Size of a page in EEPROM memory.
* This size is given by EEPROM memory datasheet.
******************************************************************************/
#define EEPROM_24C128_24C256__PAGE_SIZE 64
 
/******************************************************************************
* Private function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void eeprom_24c128_24c256__write_page(
* uint16_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Write a page in memory.
*
* \param address Start address of data to write.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
static
void
eeprom_24c128_24c256__write_page
(
uint16_t address,
uint8_t length,
uint8_t* p_data
);
 
/******************************************************************************
* Private variable declarations.
******************************************************************************/
 
static uint8_t device_address = 0;
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void eeprom_24c128_24c256__initialize(uint8_t hardware_address)
*
* \brief Initialize EEPROM 24C128/24C256.
*
* \param hardware_address Hardware address. Pins A0 to A2.
******************************************************************************/
void
eeprom_24c128_24c256__initialize
(
uint8_t hardware_address
){
// Compute device address.
device_address = EEPROM_24C128_24C256__ADDRESS | ((hardware_address & 0x07) << 1);
 
// We don't initialize TWI here: we may have several devices on the bus.
// Initialize TWI.
//twi__initialize(EEPROM_24C128_24C256__CLOCK_RATE);
}
 
/**************************************************************************//**
* \fn void eeprom_24c128_24c256__write_byte(uint16_t address, uint8_t data)
*
* \brief Write a byte into memory.
*
* \param address Address in memory.
* \param data Byte to write.
******************************************************************************/
void
eeprom_24c128_24c256__write_byte
(
uint16_t address,
uint8_t data
){
twi__start();
twi__send_slaw(device_address);
twi__send_data(address >> 8);
twi__send_data(address & 0xFF);
twi__send_data(data);
twi__stop();
}
 
/**************************************************************************//**
* \fn void eeprom_24c128_24c256__write_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Write bytes into memory.
*
* \param address Start address.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
void
eeprom_24c128_24c256__write_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
// Write first page if not aligned.
uint8_t not_aligned_length = 0;
uint8_t page_offset = address % EEPROM_24C128_24C256__PAGE_SIZE;
if (page_offset > 0)
{
not_aligned_length = EEPROM_24C128_24C256__PAGE_SIZE - page_offset;
eeprom_24c128_24c256__write_page(address, not_aligned_length, p_data);
length -= not_aligned_length;
}
 
if (length > 0)
{
address += not_aligned_length;
p_data += not_aligned_length;
 
// Write complete and aligned pages.
uint16_t page_count = length / EEPROM_24C128_24C256__PAGE_SIZE;
for (uint16_t i = 0; i < page_count; i++)
{
eeprom_24c128_24c256__write_page(address, EEPROM_24C128_24C256__PAGE_SIZE, p_data);
address += EEPROM_24C128_24C256__PAGE_SIZE;
p_data += EEPROM_24C128_24C256__PAGE_SIZE;
length -= EEPROM_24C128_24C256__PAGE_SIZE;
}
 
if (length > 0)
{
// Write remaining uncomplete page.
eeprom_24c128_24c256__write_page(address, length, p_data);
}
}
}
 
/**************************************************************************//**
* \fn uint8_t eeprom_24c128_24c256__read_byte(uint16_t address)
*
* \brief Read a byte in memory.
*
* \param address Address to read.
*
* \return Read byte.
******************************************************************************/
uint8_t
eeprom_24c128_24c256__read_byte
(
uint16_t address
){
uint8_t data = 0;
 
twi__start();
twi__send_slaw(device_address);
twi__send_data(address >> 8);
twi__send_data(address & 0xFF);
twi__repeat_start();
twi__send_slar(device_address);
twi__receive_data_nack(&data);
twi__stop();
 
return data;
}
 
/**************************************************************************//**
* \fn void eeprom_24c128_24c256__read_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Read bytes in memory.
*
* \param address Start address of data to read.
* \param length Number of bytes to read.
* \param[in] p_data Buffer to fill with read bytes.
******************************************************************************/
void
eeprom_24c128_24c256__read_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
twi__start();
twi__send_slaw(device_address);
twi__send_data(address >> 8);
twi__send_data(address & 0xFF);
twi__repeat_start();
twi__send_slar(device_address);
for (uint16_t i = 0; i < length - 1; i++)
{
twi__receive_data_ack(p_data + i);
}
twi__receive_data_nack(p_data + length - 1);
twi__stop();
}
 
/******************************************************************************
* Private function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void eeprom_24c128_24c256__write_page(
* uint16_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Write a page in memory.
*
* \param address Start address of data to write.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
static
void
eeprom_24c128_24c256__write_page
(
uint16_t address,
uint8_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
twi__start();
twi__send_slaw(device_address);
twi__send_data(address >> 8);
twi__send_data(address & 0xFF);
for (uint8_t i = 0; i < length; i++)
{
twi__send_data(p_data[i]);
}
twi__stop();
 
// Write cycle time (tWR). See EEPROM memory datasheet for more details.
_delay_ms(10);
}
/trunk/libraries/eeprom_24c128_24c256/src/SConscript
0,0 → 1,13
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'eeprom_24c128_24c256'
 
# Define source files.
sources = [
'eeprom_24c128_24c256.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/eeprom_24c128_24c256/eeprom_24c128_24c256.h
0,0 → 1,142
/**************************************************************************//**
* \brief EEPROM 24C128/24C256 library.
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121102
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile eeprom_24c128_24c256.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__EEPROM_24C128_24C256__H
#define H__IDREAMMICRO__EEPROM_24C128_24C256__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusion.
******************************************************************************/
 
#include <stdint.h>
 
/******************************************************************************
* Public macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def EEPROM_24C128_24C256__CLOCK_RATE
* \brief 24C128/24C256 frequency in Hertz.
* On ATmega, can be 100 kHz or 400 Khz.
******************************************************************************/
#define EEPROM_24C128_24C256__CLOCK_RATE 100000
 
/******************************************************************************
* Public function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void eeprom_24c128_24c256__initialize(uint8_t hardware_address)
*
* \brief Initialize EEPROM 24C128/24C256.
*
* \param hardware_address Hardware address. Pins A0 to A2.
******************************************************************************/
void
eeprom_24c128_24c256__initialize
(
uint8_t hardware_address
);
 
/**************************************************************************//**
* \fn void eeprom_24c128_24c256__write_byte(uint16_t address, uint8_t data)
*
* \brief Write a byte into memory.
*
* \param address Address in memory.
* \param data Byte to write.
******************************************************************************/
void
eeprom_24c128_24c256__write_byte
(
uint16_t address,
uint8_t data
);
 
/**************************************************************************//**
* \fn void eeprom_24c128_24c256__write_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Write bytes into memory.
*
* \param address Start address.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
void
eeprom_24c128_24c256__write_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
);
 
/**************************************************************************//**
* \fn uint8_t eeprom_24c128_24c256__read_byte(uint16_t address)
*
* \brief Read a byte in memory.
*
* \param address Address to read.
*
* \return Read byte.
******************************************************************************/
uint8_t
eeprom_24c128_24c256__read_byte
(
uint16_t address
);
 
/**************************************************************************//**
* \fn void eeprom_24c128_24c256__read_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Read bytes in memory.
*
* \param address Start address of data to read.
* \param length Number of bytes to read.
* \param[in] p_data Buffer to fill with read bytes.
******************************************************************************/
void
eeprom_24c128_24c256__read_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__EEPROM_24C128_24C256__H */
/trunk/libraries/eeprom_24c128_24c256/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/eeprom_24c128_24c256/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/eeprom_24c04_24c16/src/eeprom_24c04_24c16.c
0,0 → 1,289
/**************************************************************************//**
* \brief EEPROM 24C04/24C08/24C16 library.
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121102
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file eeprom_24c04_24c16.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../eeprom_24c04_24c16.h"
 
#include <twi/twi.h>
 
#include <util/delay.h>
 
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
 
/******************************************************************************
* Private macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def EEPROM_24C04_24C16__ADDRESS
* \brief EEPROM 24C04/24C08/24C16 address. Given by datasheet.
******************************************************************************/
#define EEPROM_24C04_24C16__ADDRESS 0xA0
 
/**************************************************************************//**
* \def EEPROM_24C04_24C16__PAGE_SIZE
* \brief Size of a page in EEPROM memory.
* This size is given by EEPROM memory datasheet.
******************************************************************************/
#define EEPROM_24C04_24C16__PAGE_SIZE 16
 
/******************************************************************************
* Private function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void eeprom_24c04_24c16__write_page(
* uint16_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Write a page in memory.
*
* \param address Start address of data to write.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
static
void
eeprom_24c04_24c16__write_page
(
uint16_t address,
uint8_t length,
uint8_t* p_data
);
 
/******************************************************************************
* Private variable declarations.
******************************************************************************/
 
static uint8_t device_address = 0;
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void eeprom_24c04_24c16__initialize(uint8_t hardware_address)
*
* \brief Initialize EEPROM 24C04/24C08/24C16.
*
* \param hardware_address Hardware address. Pins A1 to A2.
******************************************************************************/
void
eeprom_24c04_24c16__initialize
(
uint8_t hardware_address
){
// Compute device address.
device_address = EEPROM_24C04_24C16__ADDRESS | ((hardware_address & 0x06) << 1);
 
// We don't initialize TWI here: we may have several devices on the bus.
// Initialize TWI.
//twi__initialize(EEPROM_24C04_24C16__CLOCK_RATE);
}
 
/**************************************************************************//**
* \fn void eeprom_24c04_24c16__write_byte(uint16_t address, uint8_t data)
*
* \brief Write a byte into memory.
*
* \param address Address in memory.
* \param data Byte to write.
******************************************************************************/
void
eeprom_24c04_24c16__write_byte
(
uint16_t address,
uint8_t data
){
twi__start();
twi__send_slaw(device_address | ((address & 0x30) >> 7));
twi__send_data(address & 0xFF);
twi__send_data(data);
twi__stop();
}
 
/**************************************************************************//**
* \fn void eeprom_24c04_24c16__write_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Write bytes into memory.
*
* \param address Start address.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
void
eeprom_24c04_24c16__write_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
// Write first page if not aligned.
uint8_t not_aligned_length = 0;
uint8_t page_offset = address % EEPROM_24C04_24C16__PAGE_SIZE;
if (page_offset > 0)
{
not_aligned_length = EEPROM_24C04_24C16__PAGE_SIZE - page_offset;
eeprom_24c04_24c16__write_page(address, not_aligned_length, p_data);
length -= not_aligned_length;
}
 
if (length > 0)
{
address += not_aligned_length;
p_data += not_aligned_length;
 
// Write complete and aligned pages.
uint16_t page_count = length / EEPROM_24C04_24C16__PAGE_SIZE;
for (uint16_t i = 0; i < page_count; i++)
{
eeprom_24c04_24c16__write_page(address, EEPROM_24C04_24C16__PAGE_SIZE, p_data);
address += EEPROM_24C04_24C16__PAGE_SIZE;
p_data += EEPROM_24C04_24C16__PAGE_SIZE;
length -= EEPROM_24C04_24C16__PAGE_SIZE;
}
 
if (length > 0)
{
// Write remaining uncomplete page.
eeprom_24c04_24c16__write_page(address, length, p_data);
}
}
}
 
/**************************************************************************//**
* \fn uint8_t eeprom_24c04_24c16__read_byte(uint16_t address)
*
* \brief Read a byte in memory.
*
* \param address Address to read.
*
* \return Read byte.
******************************************************************************/
uint8_t
eeprom_24c04_24c16__read_byte
(
uint16_t address
){
uint8_t data = 0;
 
twi__start();
twi__send_slaw(device_address | ((address & 0x30) >> 7));
twi__send_data(address & 0xFF);
twi__repeat_start();
twi__send_slar(device_address);
twi__receive_data_nack(&data);
twi__stop();
 
return data;
}
 
/**************************************************************************//**
* \fn void eeprom_24c04_24c16__read_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Read bytes in memory.
*
* \param address Start address of data to read.
* \param length Number of bytes to read.
* \param[in] p_data Buffer to fill with read bytes.
******************************************************************************/
void
eeprom_24c04_24c16__read_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
twi__start();
twi__send_slaw(device_address | ((address & 0x30) >> 7));
twi__send_data(address & 0xFF);
twi__repeat_start();
twi__send_slar(device_address);
for (uint16_t i = 0; i < length - 1; i++)
{
twi__receive_data_ack(p_data + i);
}
twi__receive_data_nack(p_data + length - 1);
twi__stop();
}
 
/******************************************************************************
* Private function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void eeprom_24c04_24c16__write_page(
* uint16_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Write a page in memory.
*
* \param address Start address of data to write.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
static
void
eeprom_24c04_24c16__write_page
(
uint16_t address,
uint8_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
twi__start();
twi__send_slaw(device_address | ((address & 0x30) >> 7));
twi__send_data(address & 0xFF);
for (uint8_t i = 0; i < length; i++)
{
twi__send_data(p_data[i]);
}
twi__stop();
 
// Write cycle time (tWR). See EEPROM memory datasheet for more details.
_delay_ms(10);
}
/trunk/libraries/eeprom_24c04_24c16/src/SConscript
0,0 → 1,13
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'eeprom_24c04_24c16'
 
# Define source files.
sources = [
'eeprom_24c04_24c16.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/eeprom_24c04_24c16/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/eeprom_24c04_24c16/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/eeprom_24c04_24c16/eeprom_24c04_24c16.h
0,0 → 1,142
/**************************************************************************//**
* \brief EEPROM 24C04/24C08/24C16 library.
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121102
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile eeprom_24c04_24c16.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__EEPROM_24C04_24C16__H
#define H__IDREAMMICRO__EEPROM_24C04_24C16__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusion.
******************************************************************************/
 
#include <stdint.h>
 
/******************************************************************************
* Public macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def EEPROM_24C04_24C16__CLOCK_RATE
* \brief 24C04/24C16 frequency in Hertz.
* On ATmega, can be 100 kHz or 400 Khz.
******************************************************************************/
#define EEPROM_24C04_24C16__CLOCK_RATE 100000
 
/******************************************************************************
* Public function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void eeprom_24c04_24c16__initialize(uint8_t hardware_address)
*
* \brief Initialize EEPROM 24C04/24C08/24C16.
*
* \param hardware_address Hardware address. Pins A1 to A2.
******************************************************************************/
void
eeprom_24c04_24c16__initialize
(
uint8_t hardware_address
);
 
/**************************************************************************//**
* \fn void eeprom_24c04_24c16__write_byte(uint16_t address, uint8_t data)
*
* \brief Write a byte into memory.
*
* \param address Address in memory.
* \param data Byte to write.
******************************************************************************/
void
eeprom_24c04_24c16__write_byte
(
uint16_t address,
uint8_t data
);
 
/**************************************************************************//**
* \fn void eeprom_24c04_24c16__write_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Write bytes into memory.
*
* \param address Start address.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
void
eeprom_24c04_24c16__write_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
);
 
/**************************************************************************//**
* \fn uint8_t eeprom_24c04_24c16__read_byte(uint16_t address)
*
* \brief Read a byte in memory.
*
* \param address Address to read.
*
* \return Read byte.
******************************************************************************/
uint8_t
eeprom_24c04_24c16__read_byte
(
uint16_t address
);
 
/**************************************************************************//**
* \fn void eeprom_24c04_24c16__read_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Read bytes in memory.
*
* \param address Start address of data to read.
* \param length Number of bytes to read.
* \param[in] p_data Buffer to fill with read bytes.
******************************************************************************/
void
eeprom_24c04_24c16__read_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__EEPROM_24C04_24C16__H */
/trunk/libraries/eeprom_24c32_24c64/src/eeprom_24c32_24c64.c
0,0 → 1,293
/**************************************************************************//**
* \brief EEPROM 24C32/24C64 library.
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121102
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file eeprom_24c32_24c64.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../eeprom_24c32_24c64.h"
 
#include <twi/twi.h>
 
#include <util/delay.h>
 
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
 
/******************************************************************************
* Private macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def EEPROM_24C32_24C64__ADDRESS
* \brief EEPROM 24C32/24C64 address. Given by datasheet.
******************************************************************************/
#define EEPROM_24C32_24C64__ADDRESS 0xA0
 
/**************************************************************************//**
* \def EEPROM_24C32_24C64__PAGE_SIZE
* \brief Size of a page in EEPROM memory.
* This size is given by EEPROM memory datasheet.
******************************************************************************/
#define EEPROM_24C32_24C64__PAGE_SIZE 32
 
/******************************************************************************
* Private function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void eeprom_24c32_24c64__write_page(
* uint16_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Write a page in memory.
*
* \param address Start address of data to write.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
static
void
eeprom_24c32_24c64__write_page
(
uint16_t address,
uint8_t length,
uint8_t* p_data
);
 
/******************************************************************************
* Private variable declarations.
******************************************************************************/
 
static uint8_t device_address = 0;
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void eeprom_24c32_24c64__initialize(uint8_t hardware_address)
*
* \brief Initialize EEPROM 24C32/24C64.
*
* \param hardware_address Hardware address. Pins A0 to A2.
******************************************************************************/
void
eeprom_24c32_24c64__initialize
(
uint8_t hardware_address
){
// Compute device address.
device_address = EEPROM_24C32_24C64__ADDRESS | ((hardware_address & 0x07) << 1);
 
// We don't initialize TWI here: we may have several devices on the bus.
// Initialize TWI.
//twi__initialize(EEPROM_24C32_24C64__CLOCK_RATE);
}
 
/**************************************************************************//**
* \fn void eeprom_24c32_24c64__write_byte(uint16_t address, uint8_t data)
*
* \brief Write a byte into memory.
*
* \param address Address in memory.
* \param data Byte to write.
******************************************************************************/
void
eeprom_24c32_24c64__write_byte
(
uint16_t address,
uint8_t data
){
twi__start();
twi__send_slaw(device_address);
twi__send_data(address >> 8);
twi__send_data(address & 0xFF);
twi__send_data(data);
twi__stop();
}
 
/**************************************************************************//**
* \fn void eeprom_24c32_24c64__write_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Write bytes into memory.
*
* \param address Start address.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
void
eeprom_24c32_24c64__write_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
// Write first page if not aligned.
uint8_t not_aligned_length = 0;
uint8_t page_offset = address % EEPROM_24C32_24C64__PAGE_SIZE;
if (page_offset > 0)
{
not_aligned_length = EEPROM_24C32_24C64__PAGE_SIZE - page_offset;
eeprom_24c32_24c64__write_page(address, not_aligned_length, p_data);
length -= not_aligned_length;
}
 
if (length > 0)
{
address += not_aligned_length;
p_data += not_aligned_length;
 
// Write complete and aligned pages.
uint16_t page_count = length / EEPROM_24C32_24C64__PAGE_SIZE;
for (uint16_t i = 0; i < page_count; i++)
{
eeprom_24c32_24c64__write_page(address, EEPROM_24C32_24C64__PAGE_SIZE, p_data);
address += EEPROM_24C32_24C64__PAGE_SIZE;
p_data += EEPROM_24C32_24C64__PAGE_SIZE;
length -= EEPROM_24C32_24C64__PAGE_SIZE;
}
 
if (length > 0)
{
// Write remaining uncomplete page.
eeprom_24c32_24c64__write_page(address, length, p_data);
}
}
}
 
/**************************************************************************//**
* \fn uint8_t eeprom_24c32_24c64__read_byte(uint16_t address)
*
* \brief Read a byte in memory.
*
* \param address Address to read.
*
* \return Read byte.
******************************************************************************/
uint8_t
eeprom_24c32_24c64__read_byte
(
uint16_t address
){
uint8_t data = 0;
 
twi__start();
twi__send_slaw(device_address);
twi__send_data(address >> 8);
twi__send_data(address & 0xFF);
twi__repeat_start();
twi__send_slar(device_address);
twi__receive_data_nack(&data);
twi__stop();
 
return data;
}
 
/**************************************************************************//**
* \fn void eeprom_24c32_24c64__read_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Read bytes in memory.
*
* \param address Start address of data to read.
* \param length Number of bytes to read.
* \param[in] p_data Buffer to fill with read bytes.
******************************************************************************/
void
eeprom_24c32_24c64__read_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
twi__start();
twi__send_slaw(device_address);
twi__send_data(address >> 8);
twi__send_data(address & 0xFF);
twi__repeat_start();
twi__send_slar(device_address);
for (uint16_t i = 0; i < length - 1; i++)
{
twi__receive_data_ack(p_data + i);
}
twi__receive_data_nack(p_data + length - 1);
twi__stop();
}
 
/******************************************************************************
* Private function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void eeprom_24c32_24c64__write_page(
* uint16_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Write a page in memory.
*
* \param address Start address of data to write.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
static
void
eeprom_24c32_24c64__write_page
(
uint16_t address,
uint8_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
twi__start();
twi__send_slaw(device_address);
twi__send_data(address >> 8);
twi__send_data(address & 0xFF);
for (uint8_t i = 0; i < length; i++)
{
twi__send_data(p_data[i]);
}
twi__stop();
 
// Write cycle time (tWR). See EEPROM memory datasheet for more details.
_delay_ms(10);
}
/trunk/libraries/eeprom_24c32_24c64/src/SConscript
0,0 → 1,13
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'eeprom_24c32_24c64'
 
# Define source files.
sources = [
'eeprom_24c32_24c64.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/eeprom_24c32_24c64/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/eeprom_24c32_24c64/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/eeprom_24c32_24c64/eeprom_24c32_24c64.h
0,0 → 1,142
/**************************************************************************//**
* \brief EEPROM 24C32/24C64 library.
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121102
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile eeprom_24c32_24c64.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__EEPROM_24C32_24C64__H
#define H__IDREAMMICRO__EEPROM_24C32_24C64__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusion.
******************************************************************************/
 
#include <stdint.h>
 
/******************************************************************************
* Public macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def EEPROM_24C32_24C64__CLOCK_RATE
* \brief 24C32/24C64 frequency in Hertz.
* On ATmega, can be 100 kHz or 400 Khz.
******************************************************************************/
#define EEPROM_24C32_24C64__CLOCK_RATE 100000
 
/******************************************************************************
* Public function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void eeprom_24c32_24c64__initialize(uint8_t hardware_address)
*
* \brief Initialize EEPROM 24C32/24C64.
*
* \param hardware_address Hardware address. Pins A0 to A2.
******************************************************************************/
void
eeprom_24c32_24c64__initialize
(
uint8_t hardware_address
);
 
/**************************************************************************//**
* \fn void eeprom_24c32_24c64__write_byte(uint16_t address, uint8_t data)
*
* \brief Write a byte into memory.
*
* \param address Address in memory.
* \param data Byte to write.
******************************************************************************/
void
eeprom_24c32_24c64__write_byte
(
uint16_t address,
uint8_t data
);
 
/**************************************************************************//**
* \fn void eeprom_24c32_24c64__write_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Write bytes into memory.
*
* \param address Start address.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
void
eeprom_24c32_24c64__write_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
);
 
/**************************************************************************//**
* \fn uint8_t eeprom_24c32_24c64__read_byte(uint16_t address)
*
* \brief Read a byte in memory.
*
* \param address Address to read.
*
* \return Read byte.
******************************************************************************/
uint8_t
eeprom_24c32_24c64__read_byte
(
uint16_t address
);
 
/**************************************************************************//**
* \fn void eeprom_24c32_24c64__read_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Read bytes in memory.
*
* \param address Start address of data to read.
* \param length Number of bytes to read.
* \param[in] p_data Buffer to fill with read bytes.
******************************************************************************/
void
eeprom_24c32_24c64__read_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__EEPROM_24C32_24C64__H */
/trunk/libraries/eeprom_24c512/src/eeprom_24c512.c
0,0 → 1,293
/**************************************************************************//**
* \brief EEPROM 24C512 library.
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121031
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file eeprom_24c512.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../eeprom_24c512.h"
 
#include <twi/twi.h>
 
#include <util/delay.h>
 
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
 
/******************************************************************************
* Private macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def EEPROM_24C512__ADDRESS
* \brief EEPROM 24C512 address. Given by datasheet.
******************************************************************************/
#define EEPROM_24C512__ADDRESS 0xA0
 
/**************************************************************************//**
* \def EEPROM_24C512__PAGE_SIZE
* \brief Size of a page in EEPROM memory.
* This size is given by EEPROM memory datasheet.
******************************************************************************/
#define EEPROM_24C512__PAGE_SIZE 128
 
/******************************************************************************
* Private function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void eeprom_24c512__write_page(
* uint16_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Write a page in memory.
*
* \param address Start address of data to write.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
static
void
eeprom_24c512__write_page
(
uint16_t address,
uint8_t length,
uint8_t* p_data
);
 
/******************************************************************************
* Private variable declarations.
******************************************************************************/
 
static uint8_t device_address = 0;
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void eeprom_24c512__initialize(uint8_t hardware_address)
*
* \brief Initialize EEPROM 24C512.
*
* \param hardware_address Hardware address. Pins A0 to A1.
******************************************************************************/
void
eeprom_24c512__initialize
(
uint8_t hardware_address
){
// Compute device address.
device_address = EEPROM_24C512__ADDRESS | ((hardware_address & 0x03) << 1);
 
// We don't initialize TWI here: we may have several devices on the bus.
// Initialize TWI.
//twi__initialize(EEPROM_24C512__CLOCK_RATE);
}
 
/**************************************************************************//**
* \fn void eeprom_24c512__write_byte(uint16_t address, uint8_t data)
*
* \brief Write a byte into memory.
*
* \param address Address in memory.
* \param data Byte to write.
******************************************************************************/
void
eeprom_24c512__write_byte
(
uint16_t address,
uint8_t data
){
twi__start();
twi__send_slaw(device_address);
twi__send_data(address >> 8);
twi__send_data(address & 0xFF);
twi__send_data(data);
twi__stop();
}
 
/**************************************************************************//**
* \fn void eeprom_24c512__write_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Write bytes into memory.
*
* \param address Start address.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
void
eeprom_24c512__write_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
// Write first page if not aligned.
uint8_t not_aligned_length = 0;
uint8_t page_offset = address % EEPROM_24C512__PAGE_SIZE;
if (page_offset > 0)
{
not_aligned_length = EEPROM_24C512__PAGE_SIZE - page_offset;
eeprom_24c512__write_page(address, not_aligned_length, p_data);
length -= not_aligned_length;
}
 
if (length > 0)
{
address += not_aligned_length;
p_data += not_aligned_length;
 
// Write complete and aligned pages.
uint16_t page_count = length / EEPROM_24C512__PAGE_SIZE;
for (uint16_t i = 0; i < page_count; i++)
{
eeprom_24c512__write_page(address, EEPROM_24C512__PAGE_SIZE, p_data);
address += EEPROM_24C512__PAGE_SIZE;
p_data += EEPROM_24C512__PAGE_SIZE;
length -= EEPROM_24C512__PAGE_SIZE;
}
 
if (length > 0)
{
// Write remaining uncomplete page.
eeprom_24c512__write_page(address, length, p_data);
}
}
}
 
/**************************************************************************//**
* \fn uint8_t eeprom_24c512__read_byte(uint16_t address)
*
* \brief Read a byte in memory.
*
* \param address Address to read.
*
* \return Read byte.
******************************************************************************/
uint8_t
eeprom_24c512__read_byte
(
uint16_t address
){
uint8_t data = 0;
 
twi__start();
twi__send_slaw(device_address);
twi__send_data(address >> 8);
twi__send_data(address & 0xFF);
twi__repeat_start();
twi__send_slar(device_address);
twi__receive_data_nack(&data);
twi__stop();
 
return data;
}
 
/**************************************************************************//**
* \fn void eeprom_24c512__read_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Read bytes in memory.
*
* \param address Start address of data to read.
* \param length Number of bytes to read.
* \param[in] p_data Buffer to fill with read bytes.
******************************************************************************/
void
eeprom_24c512__read_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
twi__start();
twi__send_slaw(device_address);
twi__send_data(address >> 8);
twi__send_data(address & 0xFF);
twi__repeat_start();
twi__send_slar(device_address);
for (uint16_t i = 0; i < length - 1; i++)
{
twi__receive_data_ack(p_data + i);
}
twi__receive_data_nack(p_data + length - 1);
twi__stop();
}
 
/******************************************************************************
* Private function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void eeprom_24c512__write_page(
* uint16_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Write a page in memory.
*
* \param address Start address of data to write.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
static
void
eeprom_24c512__write_page
(
uint16_t address,
uint8_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
twi__start();
twi__send_slaw(device_address);
twi__send_data(address >> 8);
twi__send_data(address & 0xFF);
for (uint8_t i = 0; i < length; i++)
{
twi__send_data(p_data[i]);
}
twi__stop();
 
// Write cycle time (tWR). See EEPROM memory datasheet for more details.
_delay_ms(10);
}
/trunk/libraries/eeprom_24c512/src/SConscript
0,0 → 1,13
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'eeprom_24c512'
 
# Define source files.
sources = [
'eeprom_24c512.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/eeprom_24c512/eeprom_24c512.h
0,0 → 1,142
/**************************************************************************//**
* \brief EEPROM 24C512 library.
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121031
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile eeprom_24c512.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__EEPROM_24C512__H
#define H__IDREAMMICRO__EEPROM_24C512__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusion.
******************************************************************************/
 
#include <stdint.h>
 
/******************************************************************************
* Public macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def EEPROM_24C512__CLOCK_RATE
* \brief 24C512 frequency in Hertz.
* On ATmega, can be 100 kHz or 400 Khz.
******************************************************************************/
#define EEPROM_24C512__CLOCK_RATE 100000
 
/******************************************************************************
* Public function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void eeprom_24c512__initialize(uint8_t hardware_address)
*
* \brief Initialize EEPROM 24C512.
*
* \param hardware_address Hardware address. Pins A0 to A1.
******************************************************************************/
void
eeprom_24c512__initialize
(
uint8_t hardware_address
);
 
/**************************************************************************//**
* \fn void eeprom_24c512__write_byte(uint16_t address, uint8_t data)
*
* \brief Write a byte into memory.
*
* \param address Address in memory.
* \param data Byte to write.
******************************************************************************/
void
eeprom_24c512__write_byte
(
uint16_t address,
uint8_t data
);
 
/**************************************************************************//**
* \fn void eeprom_24c512__write_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Write bytes into memory.
*
* \param address Start address.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
void
eeprom_24c512__write_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
);
 
/**************************************************************************//**
* \fn uint8_t eeprom_24c512__read_byte(uint16_t address)
*
* \brief Read a byte in memory.
*
* \param address Address to read.
*
* \return Read byte.
******************************************************************************/
uint8_t
eeprom_24c512__read_byte
(
uint16_t address
);
 
/**************************************************************************//**
* \fn void eeprom_24c512__read_bytes(
* uint16_t address,
* uint16_t length,
* uint8_t* p_data)
*
* \brief Read bytes in memory.
*
* \param address Start address of data to read.
* \param length Number of bytes to read.
* \param[in] p_data Buffer to fill with read bytes.
******************************************************************************/
void
eeprom_24c512__read_bytes
(
uint16_t address,
uint16_t length,
uint8_t* p_data
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__EEPROM_24C512__H */
/trunk/libraries/eeprom_24c512/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/eeprom_24c512/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/eeprom_24c01_24c02/src/eeprom_24c01_24c02.c
0,0 → 1,289
/**************************************************************************//**
* \brief EEPROM 24C01/24C02 library.
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121102
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file eeprom_24c01_24c02.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../eeprom_24c01_24c02.h"
 
#include <twi/twi.h>
 
#include <util/delay.h>
 
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
 
/******************************************************************************
* Private macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def EEPROM_24C01_24C02__ADDRESS
* \brief EEPROM 24C01/24C02 address. Given by datasheet.
******************************************************************************/
#define EEPROM_24C01_24C02__ADDRESS 0xA0
 
/**************************************************************************//**
* \def EEPROM_24C01_24C02__PAGE_SIZE
* \brief Size of a page in EEPROM memory.
* This size is given by EEPROM memory datasheet.
******************************************************************************/
#define EEPROM_24C01_24C02__PAGE_SIZE 8
 
/******************************************************************************
* Private function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void eeprom_24c01_24c02__write_page(
* uint8_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Write a page in memory.
*
* \param address Start address of data to write.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
static
void
eeprom_24c01_24c02__write_page
(
uint8_t address,
uint8_t length,
uint8_t* p_data
);
 
/******************************************************************************
* Private variable declarations.
******************************************************************************/
 
static uint8_t device_address = 0;
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void eeprom_24c01_24c02__initialize(uint8_t hardware_address)
*
* \brief Initialize EEPROM 24C01/24C02.
*
* \param hardware_address Hardware address. Pins A0 to A2.
******************************************************************************/
void
eeprom_24c01_24c02__initialize
(
uint8_t hardware_address
){
// Compute device address.
device_address = EEPROM_24C01_24C02__ADDRESS | ((hardware_address & 0x07) << 1);
 
// We don't initialize TWI here: we may have several devices on the bus.
// Initialize TWI.
//twi__initialize(EEPROM_24C01_24C02__CLOCK_RATE);
}
 
/**************************************************************************//**
* \fn void eeprom_24c01_24c02__write_byte(uint8_t address, uint8_t data)
*
* \brief Write a byte into memory.
*
* \param address Address in memory.
* \param data Byte to write.
******************************************************************************/
void
eeprom_24c01_24c02__write_byte
(
uint8_t address,
uint8_t data
){
twi__start();
twi__send_slaw(device_address);
twi__send_data(address);
twi__send_data(data);
twi__stop();
}
 
/**************************************************************************//**
* \fn void eeprom_24c01_24c02__write_bytes(
* uint8_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Write bytes into memory.
*
* \param address Start address.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
void
eeprom_24c01_24c02__write_bytes
(
uint8_t address,
uint8_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
// Write first page if not aligned.
uint8_t not_aligned_length = 0;
uint8_t page_offset = address % EEPROM_24C01_24C02__PAGE_SIZE;
if (page_offset > 0)
{
not_aligned_length = EEPROM_24C01_24C02__PAGE_SIZE - page_offset;
eeprom_24c01_24c02__write_page(address, not_aligned_length, p_data);
length -= not_aligned_length;
}
 
if (length > 0)
{
address += not_aligned_length;
p_data += not_aligned_length;
 
// Write complete and aligned pages.
uint8_t page_count = length / EEPROM_24C01_24C02__PAGE_SIZE;
for (uint8_t i = 0; i < page_count; i++)
{
eeprom_24c01_24c02__write_page(address, EEPROM_24C01_24C02__PAGE_SIZE, p_data);
address += EEPROM_24C01_24C02__PAGE_SIZE;
p_data += EEPROM_24C01_24C02__PAGE_SIZE;
length -= EEPROM_24C01_24C02__PAGE_SIZE;
}
 
if (length > 0)
{
// Write remaining uncomplete page.
eeprom_24c01_24c02__write_page(address, length, p_data);
}
}
}
 
/**************************************************************************//**
* \fn uint8_t eeprom_24c01_24c02__read_byte(uint8_t address)
*
* \brief Read a byte in memory.
*
* \param address Address to read.
*
* \return Read byte.
******************************************************************************/
uint8_t
eeprom_24c01_24c02__read_byte
(
uint8_t address
){
uint8_t data = 0;
 
twi__start();
twi__send_slaw(device_address);
twi__send_data(address);
twi__repeat_start();
twi__send_slar(device_address);
twi__receive_data_nack(&data);
twi__stop();
 
return data;
}
 
/**************************************************************************//**
* \fn void eeprom_24c01_24c02__read_bytes(
* uint8_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Read bytes in memory.
*
* \param address Start address of data to read.
* \param length Number of bytes to read.
* \param[in] p_data Buffer to fill with read bytes.
******************************************************************************/
void
eeprom_24c01_24c02__read_bytes
(
uint8_t address,
uint8_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
twi__start();
twi__send_slaw(device_address);
twi__send_data(address);
twi__repeat_start();
twi__send_slar(device_address);
for (uint8_t i = 0; i < length - 1; i++)
{
twi__receive_data_ack(p_data + i);
}
twi__receive_data_nack(p_data + length - 1);
twi__stop();
}
 
/******************************************************************************
* Private function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void eeprom_24c01_24c02__write_page(
* uint8_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Write a page in memory.
*
* \param address Start address of data to write.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
static
void
eeprom_24c01_24c02__write_page
(
uint8_t address,
uint8_t length,
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
twi__start();
twi__send_slaw(device_address);
twi__send_data(address);
for (uint8_t i = 0; i < length; i++)
{
twi__send_data(p_data[i]);
}
twi__stop();
 
// Write cycle time (tWR). See EEPROM memory datasheet for more details.
_delay_ms(10);
}
/trunk/libraries/eeprom_24c01_24c02/src/SConscript
0,0 → 1,13
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'eeprom_24c01_24c02'
 
# Define source files.
sources = [
'eeprom_24c01_24c02.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/eeprom_24c01_24c02/eeprom_24c01_24c02.h
0,0 → 1,142
/**************************************************************************//**
* \brief EEPROM 24C01/24C02 library.
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20121102
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile eeprom_24c01_24c02.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__EEPROM_24C01_24C02__H
#define H__IDREAMMICRO__EEPROM_24C01_24C02__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusion.
******************************************************************************/
 
#include <stdint.h>
 
/******************************************************************************
* Public macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def EEPROM_24C01_24C02__CLOCK_RATE
* \brief 24C01/24C02 frequency in Hertz.
* On ATmega, can be 100 kHz or 400 Khz.
******************************************************************************/
#define EEPROM_24C01_24C02__CLOCK_RATE 100000
 
/******************************************************************************
* Public function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void eeprom_24c01_24c02__initialize(uint8_t hardware_address)
*
* \brief Initialize EEPROM 24C01/24C02.
*
* \param hardware_address Hardware address. Pins A0 to A2.
******************************************************************************/
void
eeprom_24c01_24c02__initialize
(
uint8_t hardware_address
);
 
/**************************************************************************//**
* \fn void eeprom_24c01_24c02__write_byte(uint8_t address, uint8_t data)
*
* \brief Write a byte into memory.
*
* \param address Address in memory.
* \param data Byte to write.
******************************************************************************/
void
eeprom_24c01_24c02__write_byte
(
uint8_t address,
uint8_t data
);
 
/**************************************************************************//**
* \fn void eeprom_24c01_24c02__write_bytes(
* uint8_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Write bytes into memory.
*
* \param address Start address.
* \param length Number of bytes to write.
* \param[in] p_data Bytes to write.
******************************************************************************/
void
eeprom_24c01_24c02__write_bytes
(
uint8_t address,
uint8_t length,
uint8_t* p_data
);
 
/**************************************************************************//**
* \fn uint8_t eeprom_24c01_24c02__read_byte(uint8_t address)
*
* \brief Read a byte in memory.
*
* \param address Address to read.
*
* \return Read byte.
******************************************************************************/
uint8_t
eeprom_24c01_24c02__read_byte
(
uint8_t address
);
 
/**************************************************************************//**
* \fn void eeprom_24c01_24c02__read_bytes(
* uint8_t address,
* uint8_t length,
* uint8_t* p_data)
*
* \brief Read bytes in memory.
*
* \param address Start address of data to read.
* \param length Number of bytes to read.
* \param[in] p_data Buffer to fill with read bytes.
******************************************************************************/
void
eeprom_24c01_24c02__read_bytes
(
uint8_t address,
uint8_t length,
uint8_t* p_data
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__EEPROM_24C01_24C02__H */
/trunk/libraries/eeprom_24c01_24c02/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/eeprom_24c01_24c02/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/twi/src/twi.c
0,0 → 1,426
/**************************************************************************//**
* \brief TWI library
* \author Copyright (C) 2009 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090501
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file twi.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <twi/twi.h>
#include <useful/bits.h>
 
#include <avr/io.h>
#include <util/twi.h>
 
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
 
/******************************************************************************
* Private macros.
******************************************************************************/
 
/**************************************************************************//**
* \def TWI__MAX_FREQUENCY
* \brief Max frequency of TWI bus.
******************************************************************************/
#define TWI__MAX_FREQUENCY 400000
 
/******************************************************************************
* Private types.
******************************************************************************/
 
/**************************************************************************//**
* \enum twi__prescaler_values
* \brief Available TWI bus prescaler values.
*
* \typedef twi__prescaler_value_t
* \brief TWI bus prescaler value.
******************************************************************************/
typedef enum twi__prescaler_values
{
TWI__PRESCALER_VALUE__1,
TWI__PRESCALER_VALUE__4,
TWI__PRESCALER_VALUE__16,
TWI__PRESCALER_VALUE__64,
TWI__PRESCALER_VALUE__INVALID
} twi__prescaler_value_t;
 
/**************************************************************************//**
* \struct twi__prescaler_configuration
* \brief TWI bus prescaler configuration.
*
* \typedef twi__prescaler_configuration_t
* \brief TWI bus prescaler configuration.
******************************************************************************/
typedef struct twi__prescaler_configuration
{
uint8_t value;
uint8_t bits;
} twi__prescaler_configuration_t;
 
/******************************************************************************
* Private constant definitions.
******************************************************************************/
 
/**************************************************************************//**
* \var prescaler_configurations
* \brief Available prescaler configurations.
******************************************************************************/
static const twi__prescaler_configuration_t prescaler_configurations[] =
{
[TWI__PRESCALER_VALUE__1] =
{
.value = 1,
.bits = 0
},
[TWI__PRESCALER_VALUE__4] =
{
.value = 4,
.bits = _BV(TWPS0)
},
[TWI__PRESCALER_VALUE__16] =
{
.value = 16,
.bits = _BV(TWPS1)
},
[TWI__PRESCALER_VALUE__64] =
{
.value = 64,
.bits = _BV(TWPS1) | _BV(TWPS0)
}
};
 
/******************************************************************************
* Private function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn static inline uint8_t twi__compute_bit_rate(
* uint32_t f_scl,
* uint8_t prescaler_value)
*
* \brief
*
* \param f_scl SCL frequency.
* \param prescaler_value Prescaler value.
******************************************************************************/
static inline
uint8_t
twi__compute_bit_rate
(
uint32_t f_scl,
uint8_t prescaler_value
);
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void twi__initialize(uint32_t frequency)
*
* \brief Initialize TWI.
*
* \param frequency TWI frequency (up to 400 kHz).
******************************************************************************/
void twi__initialize
(
uint32_t frequency
){
// Check the preconditions.
assert(TWI__MAX_FREQUENCY >= frequency);
 
uint16_t bit_rate = UINT16_MAX;
twi__prescaler_value_t prescaler_value = TWI__PRESCALER_VALUE__1;
 
// Compute bit rate and prescaler value.
do
{
bit_rate = twi__compute_bit_rate
(
frequency,
prescaler_configurations[prescaler_value].value
);
} while (UINT8_MAX < bit_rate && TWI__PRESCALER_VALUE__INVALID > prescaler_value++);
 
// Set bit rate.
TWBR = bit_rate;
 
// Set prescaler value.
TWSR = prescaler_configurations[prescaler_value].bits;
}
 
/**************************************************************************//**
* \fn twi__error_t twi__start(void)
*
* \brief
******************************************************************************/
twi__error_t
twi__start
(
void
){
// Send start condition.
TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
 
// Wait for TWINT flag set. This indicates that the START condition has
// been transmitted.
while (!(TWCR & (1 << TWINT)));
 
// Check value of TWI Status Register. Mask prescaler bits.
if (TWSR & TW_NO_INFO != TW_START)
{
// If status is different from START (TW_START), return error.
return TWI__ERROR__ERROR;
}
 
return TWI__ERROR__NONE;
}
 
/**************************************************************************//**
* \fn twi__error_t twi__repeat_start(void)
*
* \brief
******************************************************************************/
twi__error_t
twi__repeat_start
(
void
){
// TODO: check if TWSTO must be set.
// Send start condition.
TWCR = (1 << TWEN) | (1 << TWINT) | (1 << TWSTA) | (1 << TWSTO);
 
// Wait for TWINT flag set. This indicates that the START condition has
// been transmitted.
while (!(TWCR & (1 << TWINT)));
 
// Check value of TWI Status Register. Mask prescaler bits.
if (TWSR & TW_NO_INFO != TW_REP_START)
{
// If status different from START (TW_REP_START), return error.
return TWI__ERROR__ERROR;
}
 
return TWI__ERROR__NONE;
}
 
/**************************************************************************//**
* \fn twi__error_t twi__send_slar(uint8_t sla)
*
* \brief
*
* \param sla
******************************************************************************/
twi__error_t
twi__send_slar
(
uint8_t sla
){
// Load SLA into TWDR register.
TWDR = sla | TW_READ;
 
// Clear TWINT bit in TWCR to start transmission of address.
TWCR = (1 << TWINT) | (1 << TWEN);
 
// Wait for TWINT flag set. This indicates that the SLA+W (TW_WRITE) has
// been transmitted, and ACK/NACK has been received.
while (!(TWCR & (1 << TWINT)));
 
// Check value of TWI Status Register. Mask prescaler bits. If status
// different from MT_SLA_ACK (TW_MR_SLA_ACK), return error.
if (TWSR & TW_NO_INFO != TW_MR_SLA_ACK)
{
return TWI__ERROR__ERROR;
}
 
return TWI__ERROR__NONE;
}
 
/**************************************************************************//**
* \fn twi__error_t twi__send_slaw(uint8_t sla)
*
* \brief
*
* \param sla
******************************************************************************/
twi__error_t
twi__send_slaw
(
uint8_t sla
){
// Load SLA into TWDR register.
TWDR = sla | TW_WRITE;
 
// Clear TWINT bit in TWCR to start transmission of address.
TWCR = (1 << TWINT) | (1 << TWEN);
 
// Wait for TWINT flag set. This indicates that the SLA+W (TW_WRITE) has
// been transmitted, and ACK/NACK has been received.
while (!(TWCR & (1 << TWINT)));
 
// Check value of TWI Status Register. Mask prescaler bits. If status
// different from MT_SLA_ACK (TW_MT_SLA_ACK), return error.
if (TWSR & TW_NO_INFO != TW_MT_SLA_ACK)
{
return TWI__ERROR__ERROR;
}
 
return TWI__ERROR__NONE;
}
 
/**************************************************************************//**
* \fn twi__error_t twi__send_data(uint8_t data)
*
* \brief
*
* \param data Data to send.
******************************************************************************/
twi__error_t
twi__send_data
(
uint8_t data
){
// Load data into TWDR register.
TWDR = data;
 
// Clear TWINT bit in TWCR to start transmission of data.
TWCR = (1 << TWINT) | (1 << TWEN);
 
// Wait for TWINT flag set. This indicates that the data has been
// transmitted, and ACK/NACK has been receiver.
while (!(TWCR & (1 << TWINT)));
 
// Check value of TWI status register. Mask prescaler bits. If status
// different from MT_DATA_ACK (TW_MT_DATA_ACK), return error.
if (TWSR & TW_NO_INFO != TW_MT_DATA_ACK)
{
return TWI__ERROR__ERROR;
}
 
return TWI__ERROR__NONE;
}
 
/**************************************************************************//**
* \fn twi__error_t twi__receive_data_ack(uint8_t* p_data)
*
* \brief
*
* \param p_data
******************************************************************************/
twi__error_t
twi__receive_data_ack
(
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
TWCR = (1 << TWEN) | (1 << TWINT) | (1 << TWEA);
 
while (!(TWCR & (1 << TWINT)));
 
if ((TWSR & TW_NO_INFO) != TW_MR_DATA_ACK)
{
return TWI__ERROR__ERROR;
}
 
*p_data = TWDR;
 
return TWI__ERROR__NONE;
}
 
/**************************************************************************//**
* \fn twi__error_t twi__receive_data_nack(uint8_t* p_data)
*
* \brief
*
* \param p_data
******************************************************************************/
twi__error_t
twi__receive_data_nack
(
uint8_t* p_data
){
// Check the preconditions.
assert(NULL != p_data);
 
TWCR = (1 << TWEN) | (1 << TWINT);
 
while (!(TWCR & (1 << TWINT)));
 
if ((TWSR & TW_NO_INFO) != TW_MR_DATA_NACK)
{
return TWI__ERROR__ERROR;
}
 
*p_data = TWDR;
 
return TWI__ERROR__NONE;
}
 
/**************************************************************************//**
* \fn void twi__stop(void)
*
* \brief Stop TWI.
******************************************************************************/
void
twi__stop
(
void
){
// Transmit stop operation.
TWCR = (1 << TWINT) | (1 << TWEN) | (1 << TWSTO);
 
// Wait for stop.
while (TWCR & (1 << TWSTO));
}
 
/******************************************************************************
* Private function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn static inline uint8_t twi__compute_bit_rate(
* uint32_t f_scl,
* uint8_t prescaler_value)
*
* \brief
*
* \param f_scl SCL frequency.
* \param prescaler_value Prescaler value.
******************************************************************************/
static inline
uint8_t
twi__compute_bit_rate
(
uint32_t f_scl,
uint8_t prescaler_value
){
uint8_t bit_rate = (F_CPU - 16 * f_scl) / (2 * f_scl * prescaler_value);
 
return bit_rate;
}
/trunk/libraries/twi/src/SConscript
0,0 → 1,13
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'twi'
 
# Define source files.
sources = [
'twi.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/twi/twi.h
0,0 → 1,176
/**************************************************************************//**
* \brief TWI library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090501
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile twi.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__TWI__H
#define H__IDREAMMICRO__TWI__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <stdint.h>
 
/******************************************************************************
* Public type definitions.
******************************************************************************/
 
/**************************************************************************//**
* \typedef twi__error_t
*
* \brief TWI errors.
******************************************************************************/
// TODO: more errors.
typedef enum twi__errors
{
TWI__ERROR__NONE,
TWI__ERROR__ERROR,
TWI__ERROR__INVALID
} twi__error_t;
 
/******************************************************************************
* Public function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void twi__initialize(uint32_t frequency)
*
* \brief Initialize TWI.
*
* \param frequency TWI frequency (up to 400 kHz).
******************************************************************************/
void
twi__initialize
(
uint32_t frequency
);
 
/**************************************************************************//**
* \fn twi__error_t twi__start(void)
*
* \brief
******************************************************************************/
twi__error_t
twi__start
(
void
);
 
/**************************************************************************//**
* \fn twi__error_t twi__repeat_start(void)
*
* \brief
******************************************************************************/
twi__error_t
twi__repeat_start
(
void
);
 
/**************************************************************************//**
* \fn twi__error_t twi__send_slar(uint8_t sla)
*
* \brief
*
* \param sla
******************************************************************************/
twi__error_t
twi__send_slar
(
uint8_t sla
);
 
/**************************************************************************//**
* \fn twi__error_t twi__send_slaw(uint8_t sla)
*
* \brief
*
* \param sla
******************************************************************************/
twi__error_t
twi__send_slaw
(
uint8_t sla
);
 
/**************************************************************************//**
* \fn twi__error_t twi__send_data(uint8_t data)
*
* \brief
*
* \param data Data to send.
******************************************************************************/
twi__error_t
twi__send_data
(
uint8_t data
);
 
/**************************************************************************//**
* \fn twi__error_t twi__receive_data_ack(uint8_t* p_data)
*
* \brief
*
* \param p_data
******************************************************************************/
twi__error_t
twi__receive_data_ack
(
uint8_t* p_data
);
 
/**************************************************************************//**
* \fn twi__error_t twi__receive_data_nack(uint8_t* p_data)
*
* \brief
*
* \param p_data
******************************************************************************/
twi__error_t
twi__receive_data_nack
(
uint8_t* p_data
);
 
/**************************************************************************//**
* \fn void twi__stop(void)
*
* \brief
******************************************************************************/
void
twi__stop
(
void
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__TWI__H */
/trunk/libraries/twi/test/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'twi__test'
 
# Set source file.
sources = [
'twi__test.c'
]
 
# Build project and libraries.
env_target.BuildProject(sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/libraries/twi/demo/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'twi__demo'
 
# Set source file.
sources = [
'twi__demo.c'
]
 
# Build project and libraries.
env_target.BuildProject(sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/libraries/twi/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/twi/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/twi/SConstruct
0,0 → 1,40
# Import build tools.
SConscript('#min_env/build_tools.py')
 
# Set environment for AVR-GCC.
SConscript('#min_env/env_target.py')
 
# Import environment set for AVR-GCC.
Import('env_target')
 
# Append CPPPATH.
env_target.Append(CPPPATH = [ '#../' ])
 
# Build library.
SConscript(
'src/SConscript',
variant_dir = '#build/lib/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Append LIBPATH and LIBS.
env_target.Append(LIBPATH = [ '#build/lib/'])
env_target.Append(LIBS = [ 'twi' ])
 
# Build demonstration program.
SConscript(
'demo/SConscript',
variant_dir = '#build/demo/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Build test program.
SConscript(
'test/SConscript',
variant_dir = '#build/test/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
/trunk/libraries/twi/min_env/env_target.py
0,0 → 1,27
# Create and initialize the environment.
env_target = Environment()
 
# Set environment for AVR-GCC.
env_target['CC'] = 'avr-gcc'
env_target['CPPPATH'] = '/usr/lib/avr/include'
env_target['OBJCOPY'] = 'avr-objcopy'
env_target['SIZE'] = 'avr-size'
env_target['AR'] = 'avr-ar'
env_target['RANLIB'] = 'avr-ranlib'
env_target.Append(CCFLAGS = '-Os')
 
# Define environment name.
env_target.Append(NAME = 'env_target')
 
# Microcontroller type.
env_target.Append(MCU = 'atmega328p')
# Microcontroller frequency in Hertz.
env_target.Append(F_CPU = '16000000UL')
 
# Set environment for an Atmel AVR ATmega328p microcontroller.
env_target.Append(CCFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(LINKFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(CPPDEFINES = 'F_CPU=' + env_target['F_CPU'])
 
# Export environment set for target.
Export('env_target')
/trunk/libraries/twi/min_env/build_tools.py
0,0 → 1,41
"""
Build project.
"""
def BuildProject(env, sources, target_name):
# Build program.
env.Program(target = target_name + '.elf', source = sources)
# Create hex binary file.
env.Command(
target_name + '.hex',
target_name + '.elf',
env['OBJCOPY'] + ' -O ihex $SOURCE $TARGET'
)
AddMethod(Environment, BuildProject)
 
"""
Build library.
"""
def BuildLibrary(env, sources, target_name):
# Build static library.
env.StaticLibrary(target = target_name, source = sources)
# Append LIBPATH and LIBS.
env.Append(LIBPATH = [ '#build/libraries/' + target_name + '/' + env['NAME'] ])
env.Append(LIBS = [ target_name ])
 
AddMethod(Environment, BuildLibrary)
 
"""
Compute memory usage.
"""
def ComputeMemoryUsage(env, target_name):
# Compute memory usage.
env.Command(
None,
target_name + '.elf',
env['SIZE'] + ' -C --mcu=' + env['MCU'] + ' $SOURCE'
)
AddMethod(Environment, ComputeMemoryUsage)
/trunk/libraries/usart/usart0.h
0,0 → 1,339
/**************************************************************************//**
* \brief USART0 library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090426
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile usart0.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__USART0__H
#define H__IDREAMMICRO__USART0__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <usart/usart.h>
 
#include <stdbool.h>
#include <stdint.h>
 
/******************************************************************************
* Public function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn void usart0__initialize(usart__configuration_t* p_configuration)
*
* \brief Initialize USART0.
*
* \param[in] p_configuration USART configuration. If null, default settings
* will be used.
*
* Default settings:
* - baudrate = 9600 bps;
* - 8 data bits;
* - 1 stop bit;
* - no parity.
******************************************************************************/
void
usart0__initialize
(
const usart__configuration_t* p_configuration
);
 
/**************************************************************************//**
* \fn void usart0__set_baudrate(usart__baudrate_t baudrate)
*
* \brief Set USART0 baudrate.
*
* \param baudrate baudrate to set (in bauds per second)
******************************************************************************/
void
usart0__set_baudrate
(
usart__baudrate_t baudrate
);
 
/**************************************************************************//**
* \fn void usart0__set_mode(usart__mode_t usart_mode)
*
* \brief Set USART0 mode.
*
* \param usart_mode Mode to set.
******************************************************************************/
void
usart0__set_mode
(
usart__mode_t usart_mode
);
 
/**************************************************************************//**
* \fn void usart0__set_data_size(usart__data_size_t data_size)
*
* \brief Set USART0 data size.
*
* \param data_size data size (in bits)
******************************************************************************/
void
usart0__set_data_size
(
usart__data_size_t data_size
);
 
/**************************************************************************//**
* \fn void usart0__set_stop_size(usart__stop_size_t stop_size)
*
* \brief Set USART0 stop size.
*
* \param stop_size stop size (in bits)
******************************************************************************/
void
usart0__set_stop_size
(
usart__stop_size_t stop_size
);
 
/**************************************************************************//**
* \fn void usart0__set_parity(usart__parity_t parity)
*
* \brief Set USART0 parity.
*
* \param parity parity to set
******************************************************************************/
void
usart0__set_parity
(
usart__parity_t parity
);
 
/**************************************************************************//**
* \fn void usart0__set_double_speed(bool double_speed)
*
* \brief Set double speed.
*
* \param double_speed True to set double speed, false otherwise.
******************************************************************************/
void
usart0__set_double_speed
(
bool double_speed
);
 
/**************************************************************************//**
* \fn void usart0__enable_receiver(void)
*
* \brief Enable USART 0 receiver.
******************************************************************************/
void
usart0__enable_receiver
(
void
);
 
/**************************************************************************//**
* \fn void usart0__disable_receiver(void)
*
* \brief Disable USART 0 receiver.
******************************************************************************/
void
usart0__disable_receiver
(
void
);
 
/**************************************************************************//**
* \fn void usart0__enable_transmitter(void)
*
* \brief Enable USART 0 transmitter.
******************************************************************************/
void
usart0__enable_transmitter
(
void
);
 
/**************************************************************************//**
* \fn void usart0__disable_transmitter(void)
*
* \brief Disable USART 0 transmitter.
******************************************************************************/
void
usart0__disable_transmitter
(
void
);
 
/**************************************************************************//**
* \fn uint8_t usart0__receive_byte(void)
*
* \brief Receive a byte on USART0.
*
* \return received byte
******************************************************************************/
uint16_t
usart0__receive_byte
(
void
);
 
/**************************************************************************//**
* \fn usart0__transmit_byte(uint8_t byte_to_transmit)
*
* \brief Transmit a byte on USART0.
*
* \param byte_to_transmit byte to transmit
******************************************************************************/
void
usart0__transmit_byte
(
uint16_t byte_to_transmit
);
 
/**************************************************************************//**
* \fn void usart0__flush(void)
*
* \brief Flush USART0 receiver buffer.
******************************************************************************/
void
usart0__flush
(
void
);
 
/**************************************************************************//**
* \fn void usart0__enable_rx_complete_interrupt(void)
*
* \brief Enable USART 0 receive complete interrupt.
******************************************************************************/
void
usart0__enable_rx_complete_interrupt
(
void
);
 
/**************************************************************************//**
* \fn void usart0__disable_rx_complete_interrupt(void)
*
* \brief Disable USART 0 receive complete interrupt.
******************************************************************************/
void
usart0__disable_rx_complete_interrupt
(
void
);
 
/**************************************************************************//**
* \fn void usart0__set_rx_complete_callback(
* const usart__rx_complete_callback_t* p_callback)
*
* \brief Set a callback to call when receive byte complete interrupt is
* generated.
*
* \param[in] p_callback Callback to set.
******************************************************************************/
void
usart0__set_rx_complete_callback
(
const usart__rx_complete_callback_t* p_callback
);
 
/**************************************************************************//**
* \fn void usart0__enable_tx_complete_interrupt(void)
*
* \brief Enable interrupt when TX complete.
******************************************************************************/
void
usart0__enable_tx_complete_interrupt
(
void
);
 
/**************************************************************************//**
* \fn void usart0__disable_tx_complete_interrupt(void)
*
* \brief Disable interrupt when TX complete.
******************************************************************************/
void
usart0__disable_tx_complete_interrupt
(
void
);
 
/**************************************************************************//**
* \fn void usart0__set_tx_complete_callback(
* const usart__tx_complete_callback_t* p_callback)
*
* \brief Set a callback to call when TX is complete.
*
* \param[in] p_callback Function to call.
******************************************************************************/
void
usart0__set_tx_complete_callback
(
const usart__tx_complete_callback_t* p_callback
);
 
/**************************************************************************//**
* \fn void usart0__enable_data_register_empty_interrupt()
*
* \brief Enable interrupt when data register is empty.
******************************************************************************/
void
usart0__enable_data_register_empty_interrupt
(
void
);
 
/**************************************************************************//**
* \fn void usart0__disable_data_register_empty_interrupt()
*
* \brief Disable interrupt when data register is empty.
******************************************************************************/
void
usart0__disable_data_register_empty_interrupt
(
void
);
 
/**************************************************************************//**
* \fn void usart0__set_data_register_empty_callback(
* const usart__data_register_empty_callback_t* p_callback)
*
* \brief Set a callback to call when data register is empty.
*
* \param[in] p_callback Function to call.
******************************************************************************/
void
usart0__set_data_register_empty_callback
(
const usart__data_register_empty_callback_t* p_callback
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__USART0__H */
/trunk/libraries/usart/src/usart0_m128.c
0,0 → 1,664
/**************************************************************************//**
* \brief USART0 library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090426
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file usart0_m128.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../usart0.h"
 
#include <usart/usart.h>
 
#include <useful/bits.h>
 
#include <avr/interrupt.h>
#include <avr/io.h>
 
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
 
/******************************************************************************
* Private variable declarations.
******************************************************************************/
 
static usart__rx_complete_callback_t* p_rx_complete = NULL;
static usart__tx_complete_callback_t* p_tx_complete = NULL;
static usart__data_register_empty_callback_t* p_data_register_empty = NULL;
 
static usart__configuration_t configuration =
{
.mode = USART__MODE__ASYNCHRONOUS,
.baudrate = USART__BAUDRATE__9600,
.data_size = USART__DATA_SIZE__8_BITS,
.stop_size = USART__STOP_SIZE__1_BIT,
.parity = USART__PARITY__DISABLED
};
 
static bool double_speed_is_set = false;
 
/******************************************************************************
* Private function prototypes.
******************************************************************************/
 
/**************************************************************************//**
*
******************************************************************************/
static inline
uint16_t
usart0__compute_ubrr
(
void
);
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void usart0__initialize(usart__configuration_t* p_configuration)
*
* \brief Initialize USART0.
*
* \param[in] p_configuration USART configuration. If null, default settings
* will be used.
*
* Default settings:
* - baudrate = 9600 bps;
* - 8 data bits;
* - 1 stop bit;
* - no parity.
******************************************************************************/
void
usart0__initialize
(
const usart__configuration_t* p_configuration
){
// If p_configuration is not null, use it!
if (NULL != p_configuration)
{
configuration = *p_configuration;
}
 
// Set mode.
usart0__set_mode(configuration.mode);
 
// Set baud rate.
usart0__set_baudrate(configuration.baudrate);
usart0__set_double_speed(false);
 
// Configure settings.
usart0__set_data_size(configuration.data_size);
usart0__set_stop_size(configuration.stop_size);
usart0__set_parity(configuration.parity);
}
 
/**************************************************************************//**
* \fn void usart0__set_baudrate(usart__baudrate_t baudrate)
*
* \brief Set USART0 baudrate.
*
* \param baudrate baudrate to set (in bauds per second)
******************************************************************************/
void
usart0__set_baudrate
(
usart__baudrate_t baudrate
){
configuration.baudrate = baudrate;
 
uint16_t ubrr = usart0__compute_ubrr();
UBRR0H = (uint8_t)(ubrr >> 8);
UBRR0L = (uint8_t)ubrr;
}
 
/**************************************************************************//**
* \fn void usart0__set_mode(usart__mode_t usart_mode)
*
* \brief Set USART0 mode.
*
* \param usart_mode Mode to set.
******************************************************************************/
void
usart0__set_mode
(
usart__mode_t usart_mode
){
// Check the preconditions.
assert(USART__MODE__INVALID > usart_mode);
 
configuration.mode = usart_mode;
 
switch (usart_mode)
{
case USART__MODE__ASYNCHRONOUS:
{
BIT__RST(UCSR0C, UMSEL0);
}
break;
 
case USART__MODE__SYNCHRONOUS:
{
BIT__SET(UCSR0C, UMSEL0);
}
break;
 
case USART__MODE__MASTER_SPI:
case USART__MODE__INVALID:
default:
break;
}
}
 
/**************************************************************************//**
* \fn void usart0__set_data_size(usart__data_sizet data_size)
*
* \brief Set USART0 data size.
*
* \param data_size data size (in bits)
******************************************************************************/
void
usart0__set_data_size
(
usart__data_size_t data_size
){
configuration.data_size = data_size;
 
switch (data_size)
{
case USART__DATA_SIZE__5_BITS:
{
BIT__RST(UCSR0B, UCSZ02);
BIT__RST(UCSR0C, UCSZ01);
BIT__RST(UCSR0C, UCSZ00);
}
break;
 
case USART__DATA_SIZE__6_BITS:
{
BIT__RST(UCSR0B, UCSZ02);
BIT__RST(UCSR0C, UCSZ01);
BIT__SET(UCSR0C, UCSZ00);
}
break;
 
case USART__DATA_SIZE__7_BITS:
{
BIT__RST(UCSR0B, UCSZ02);
BIT__SET(UCSR0C, UCSZ01);
BIT__RST(UCSR0C, UCSZ00);
}
break;
 
case USART__DATA_SIZE__8_BITS:
{
BIT__RST(UCSR0B, UCSZ02);
BIT__SET(UCSR0C, UCSZ01);
BIT__SET(UCSR0C, UCSZ00);
}
break;
 
case USART__DATA_SIZE__9_BITS:
{
BIT__SET(UCSR0B, UCSZ02);
BIT__SET(UCSR0C, UCSZ01);
BIT__SET(UCSR0C, UCSZ00);
}
break;
 
default:
break;
}
}
 
/**************************************************************************//**
* \fn void usart0__set_stop_size(usart__stop_size_t stop_size)
*
* \brief Set USART0 stop size.
*
* \param stop_size stop size (in bits)
******************************************************************************/
void
usart0__set_stop_size
(
usart__stop_size_t stop_size
){
configuration.stop_size = stop_size;
 
if (USART__STOP_SIZE__1_BIT == stop_size)
{
BIT__RST(UCSR0C, USBS0);
}
else
{
BIT__SET(UCSR0C, USBS0);
}
}
 
/**************************************************************************//**
* \fn void usart0__set_parity(usart__parity_t parity)
*
* \brief Set USART0 parity.
*
* \param parity parity to set
******************************************************************************/
void
usart0__set_parity
(
usart__parity_t parity
){
configuration.parity = parity;
 
switch (parity)
{
case USART__PARITY__DISABLED:
{
BIT__RST(UCSR0C, UPM01);
BIT__RST(UCSR0C, UPM00);
}
break;
 
case USART__PARITY__EVEN:
{
BIT__SET(UCSR0C, UPM01);
BIT__RST(UCSR0C, UPM00);
}
break;
 
case USART__PARITY__ODD:
{
BIT__SET(UCSR0C, UPM01);
BIT__SET(UCSR0C, UPM00);
}
break;
 
default:
break;
}
}
 
/**************************************************************************//**
* \fn void usart0__set_double_speed(bool double_speed)
*
* \brief Set double speed.
*
* \param double_speed True to set double speed, false otherwise.
******************************************************************************/
void
usart0__set_double_speed
(
bool double_speed
){
double_speed_is_set = double_speed;
 
if (double_speed_is_set)
{
BIT__SET(UCSR0A, U2X0);
}
else
{
BIT__RST(UCSR0A, U2X0);
}
}
 
/**************************************************************************//**
* \fn void usart0__enable_receiver(void)
*
* \brief Enable USART 0 receiver.
******************************************************************************/
void
usart0__enable_receiver
(
void
){
BIT__SET(UCSR0B, RXEN0);
}
 
/**************************************************************************//**
* \fn void usart0__disable_receiver(void)
*
* \brief Disable USART 0 receiver.
******************************************************************************/
void
usart0__disable_receiver
(
void
){
BIT__RST(UCSR0B, RXEN0);
}
 
/**************************************************************************//**
* \fn void usart0__enable_transmitter(void)
*
* \brief Enable USART 0 transmitter.
******************************************************************************/
void
usart0__enable_transmitter
(
void
){
BIT__SET(UCSR0B, TXEN0);
}
 
/**************************************************************************//**
* \fn void usart0__disable_transmitter(void)
*
* \brief Disable USART 0 transmitter.
******************************************************************************/
void
usart0__disable_transmitter
(
void
){
BIT__RST(UCSR0B, TXEN0);
}
 
/**************************************************************************//**
* \fn uint8_t usart0__receive_byte(void)
*
* \brief Receive a byte on USART0.
*
* \return received byte
******************************************************************************/
uint16_t
usart0__receive_byte
(
void
){
// Wait for data to be received.
while (!(UCSR0A & (1 << RXC0)));
 
// Get received data.
uint16_t received_byte = UDR0;
 
if (USART__DATA_SIZE__9_BITS == configuration.data_size)
{
// If 9-bit data size, get 9th bit.
uint8_t resh = UCSR0B;
resh = (resh >> 1) & 0x01;
received_byte = (resh << 8) | received_byte;
}
 
// Return received data from buffer.
return received_byte;
}
 
/**************************************************************************//**
* \fn usart0__transmit_byte(uint8_t byte_to_transmit)
*
* \brief Transmit a byte on USART0.
*
* \param byte_to_transmit byte to transmit
******************************************************************************/
void
usart0__transmit_byte
(
uint16_t byte_to_transmit
){
// Wait for empty transmit buffer.
while (!(UCSR0A & (1 << UDRE0)));
 
if (USART__DATA_SIZE__9_BITS == configuration.data_size)
{
// If 9-bit data size, copy 9th bit to TXB80.
UCSR0B &= ~(1 << TXB80);
if (byte_to_transmit & 0x0100)
{
UCSR0B |= (1 << TXB80);
}
}
 
// Put data into transmit buffer, sends the data.
UDR0 = byte_to_transmit;
}
 
/**************************************************************************//**
* \fn void usart0__flush(void)
*
* \brief Flush USART0 receiver buffer.
******************************************************************************/
void
usart0__flush
(
void
){
uint8_t dummy = 0;
while (UCSR0A & (1 << RXC0))
{
dummy = UDR0;
}
}
 
/**************************************************************************//**
* \fn void usart0__enable_rx_complete_interrupt(void)
*
* \brief Enable USART 0 receive complete interrupt.
******************************************************************************/
void
usart0__enable_rx_complete_interrupt
(
void
){
BIT__SET(UCSR0B, RXCIE0);
sei();
}
 
/**************************************************************************//**
* \fn void usart0__disable_rx_complete_interrupt(void)
*
* \brief Disable USART 0 receive complete interrupt.
******************************************************************************/
void
usart0__disable_rx_complete_interrupt
(
void
){
BIT__RST(UCSR0B, RXCIE0);
sei();
}
 
/**************************************************************************//**
* \fn void usart0__set_rx_complete_callback(
* const usart__rx_complete_callback_t* p_callback)
*
* \brief Set a callback to call when receive byte complete interrupt is generated.
*
* \param[in] p_callback Callback to set.
******************************************************************************/
void
usart0__set_rx_complete_callback
(
const usart__rx_complete_callback_t* p_callback
){
// Check the preconditions.
assert(NULL != p_callback);
 
p_rx_complete = p_callback;
}
 
/**************************************************************************//**
*
******************************************************************************/
void
usart0__enable_tx_complete_interrupt
(
void
){
BIT__SET(UCSR0B, TXCIE0);
sei();
}
 
/**************************************************************************//**
*
******************************************************************************/
void
usart0__disable_tx_complete_interrupt
(
void
){
BIT__RST(UCSR0B, TXCIE0);
sei();
}
 
/**************************************************************************//**
*
******************************************************************************/
void
usart0__set_tx_complete_callback
(
const usart__tx_complete_callback_t* p_callback
){
// Check the preconditions.
assert(NULL != p_callback);
 
p_tx_complete = p_callback;
}
 
/**************************************************************************//**
*
******************************************************************************/
void
usart0__enable_data_register_empty_interrupt
(
void
){
BIT__SET(UCSR0B, UDRIE0);
sei();
}
 
/**************************************************************************//**
*
******************************************************************************/
void
usart0__disable_data_register_empty_interrupt
(
void
){
BIT__RST(UCSR0B, UDRIE0);
sei();
}
 
/**************************************************************************//**
*
******************************************************************************/
void
usart0__set_data_register_empty_callback
(
const usart__data_register_empty_callback_t* p_callback
){
// Check the preconditions.
assert(NULL != p_callback);
 
p_data_register_empty = p_callback;
}
 
/******************************************************************************
* Private function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn static uint16_t usart0__compute_ubrr(void)
*
* \brief Compute ubrr value.
*
* \return ubrr value.
******************************************************************************/
static inline
uint16_t
usart0__compute_ubrr
(
void
){
uint16_t ubrr = 0;
 
switch (configuration.mode)
{
case USART__MODE__ASYNCHRONOUS:
{
if (!double_speed_is_set)
{
ubrr = F_CPU / (16 * usart__baudrate_values[configuration.baudrate]) - 1;
}
else
{
ubrr = F_CPU / (8 * usart__baudrate_values[configuration.baudrate]) - 1;
}
}
break;
 
case USART__MODE__SYNCHRONOUS:
{
ubrr = F_CPU / (2 * usart__baudrate_values[configuration.baudrate]) - 1;
}
break;
 
case USART__MODE__MASTER_SPI:
break;
 
default:
break;
}
 
return ubrr;
}
 
/******************************************************************************
* Interrupt vectors.
******************************************************************************/
 
/**************************************************************************//**
* \fn ISR(USART_RX_vect)
******************************************************************************/
ISR(USART0_RX_vect)
{
if (NULL != p_rx_complete)
{
p_rx_complete();
}
}
 
/**************************************************************************//**
* \fn ISR(USART_TX_vect)
******************************************************************************/
ISR(USART0_TX_vect)
{
if (NULL != p_tx_complete)
{
p_tx_complete();
}
}
 
/**************************************************************************//**
* \fn ISR(USART_UDRE_vect)
******************************************************************************/
ISR(USART0_UDRE_vect)
{
if (NULL != p_data_register_empty)
{
p_data_register_empty();
}
}
/trunk/libraries/usart/src/usart0_m2560.c
0,0 → 1,702
/**************************************************************************//**
* \brief USART0 library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090426
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file usart0_m2560.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../usart0.h"
#include "../include/usart_prv.h"
 
#include <usart/usart.h>
 
#include <useful/bits.h>
 
#include <avr/interrupt.h>
#include <avr/io.h>
 
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
 
/******************************************************************************
* Private variable declarations.
******************************************************************************/
 
static usart__rx_complete_callback_t* p_rx_complete = NULL;
static usart__tx_complete_callback_t* p_tx_complete = NULL;
static usart__data_register_empty_callback_t* p_data_register_empty = NULL;
 
static usart__configuration_t configuration =
{
.mode = USART__MODE__ASYNCHRONOUS,
.baudrate = USART__BAUDRATE__9600,
.data_size = USART__DATA_SIZE__8_BITS,
.stop_size = USART__STOP_SIZE__1_BIT,
.parity = USART__PARITY__DISABLED
};
 
static bool double_speed_is_set = false;
 
/******************************************************************************
* Private function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn static inline uint16_t usart0__compute_ubrr(void)
*
* \brief Compute UBRR register value.
*
* \return UBRR value.
******************************************************************************/
static inline
uint16_t
usart0__compute_ubrr
(
void
);
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void usart0__initialize(usart__configuration_t* p_configuration)
*
* \brief Initialize USART0.
*
* \param[in] p_configuration USART configuration. If null, default settings
* will be used.
*
* Default settings:
* - baudrate = 9600 bps;
* - 8 data bits;
* - 1 stop bit;
* - no parity.
******************************************************************************/
void
usart0__initialize
(
const usart__configuration_t* p_configuration
){
// If p_configuration is not null, use it!
if (NULL != p_configuration)
{
configuration = *p_configuration;
}
 
// Set mode.
usart0__set_mode(configuration.mode);
 
// Set baud rate.
usart0__set_baudrate(configuration.baudrate);
usart0__set_double_speed(false);
 
// Configure settings.
usart0__set_data_size(configuration.data_size);
usart0__set_stop_size(configuration.stop_size);
usart0__set_parity(configuration.parity);
}
 
/**************************************************************************//**
* \fn void usart0__set_baudrate(usart__baudrate_t baudrate)
*
* \brief Set USART0 baudrate.
*
* \param baudrate baudrate to set (in bauds per second)
******************************************************************************/
void
usart0__set_baudrate
(
usart__baudrate_t baudrate
){
configuration.baudrate = baudrate;
 
uint16_t ubrr = usart0__compute_ubrr();
UBRR0H = (uint8_t)(ubrr >> 8);
UBRR0L = (uint8_t)ubrr;
}
 
/**************************************************************************//**
* \fn void usart0__set_mode(usart__mode_t usart_mode)
*
* \brief Set USART0 mode.
*
* \param usart_mode Mode to set.
******************************************************************************/
void
usart0__set_mode
(
usart__mode_t usart_mode
){
// Check the preconditions.
assert(USART__MODE__INVALID > usart_mode);
 
configuration.mode = usart_mode;
 
switch (usart_mode)
{
case USART__MODE__ASYNCHRONOUS:
{
BIT__RST(UCSR0C, UMSEL01);
BIT__RST(UCSR0C, UMSEL00);
}
break;
 
case USART__MODE__SYNCHRONOUS:
{
BIT__RST(UCSR0C, UMSEL01);
BIT__SET(UCSR0C, UMSEL00);
}
break;
 
case USART__MODE__MASTER_SPI:
{
BIT__SET(UCSR0C, UMSEL01);
BIT__SET(UCSR0C, UMSEL00);
}
break;
 
case USART__MODE__INVALID:
default:
break;
}
}
 
/**************************************************************************//**
* \fn void usart0__set_data_size(usart__data_sizet data_size)
*
* \brief Set USART0 data size.
*
* \param data_size data size (in bits)
******************************************************************************/
void
usart0__set_data_size
(
usart__data_size_t data_size
){
configuration.data_size = data_size;
 
switch (data_size)
{
case USART__DATA_SIZE__5_BITS:
{
BIT__RST(UCSR0B, UCSZ02);
BIT__RST(UCSR0C, UCSZ01);
BIT__RST(UCSR0C, UCSZ00);
}
break;
 
case USART__DATA_SIZE__6_BITS:
{
BIT__RST(UCSR0B, UCSZ02);
BIT__RST(UCSR0C, UCSZ01);
BIT__SET(UCSR0C, UCSZ00);
}
break;
 
case USART__DATA_SIZE__7_BITS:
{
BIT__RST(UCSR0B, UCSZ02);
BIT__SET(UCSR0C, UCSZ01);
BIT__RST(UCSR0C, UCSZ00);
}
break;
 
case USART__DATA_SIZE__8_BITS:
{
BIT__RST(UCSR0B, UCSZ02);
BIT__SET(UCSR0C, UCSZ01);
BIT__SET(UCSR0C, UCSZ00);
}
break;
 
case USART__DATA_SIZE__9_BITS:
{
BIT__SET(UCSR0B, UCSZ02);
BIT__SET(UCSR0C, UCSZ01);
BIT__SET(UCSR0C, UCSZ00);
}
break;
 
default:
break;
}
}
 
/**************************************************************************//**
* \fn void usart0__set_stop_size(usart__stop_size_t stop_size)
*
* \brief Set USART0 stop size.
*
* \param stop_size stop size (in bits)
******************************************************************************/
void
usart0__set_stop_size
(
usart__stop_size_t stop_size
){
configuration.stop_size = stop_size;
 
if (USART__STOP_SIZE__1_BIT == stop_size)
{
BIT__RST(UCSR0C, USBS0);
}
else
{
BIT__SET(UCSR0C, USBS0);
}
}
 
/**************************************************************************//**
* \fn void usart0__set_parity(usart__parity_t parity)
*
* \brief Set USART0 parity.
*
* \param parity parity to set
******************************************************************************/
void
usart0__set_parity
(
usart__parity_t parity
){
configuration.parity = parity;
 
switch (parity)
{
case USART__PARITY__DISABLED:
{
BIT__RST(UCSR0C, UPM01);
BIT__RST(UCSR0C, UPM00);
}
break;
 
case USART__PARITY__EVEN:
{
BIT__SET(UCSR0C, UPM01);
BIT__RST(UCSR0C, UPM00);
}
break;
 
case USART__PARITY__ODD:
{
BIT__SET(UCSR0C, UPM01);
BIT__SET(UCSR0C, UPM00);
}
break;
 
default:
break;
}
}
 
/**************************************************************************//**
* \fn void usart0__set_double_speed(bool double_speed)
*
* \brief Set double speed.
*
* \param double_speed True to set double speed, false otherwise.
******************************************************************************/
void
usart0__set_double_speed
(
bool double_speed
){
double_speed_is_set = double_speed;
 
if (double_speed_is_set)
{
BIT__SET(UCSR0A, U2X0);
}
else
{
BIT__RST(UCSR0A, U2X0);
}
}
 
/**************************************************************************//**
* \fn void usart0__enable_receiver(void)
*
* \brief Enable USART 0 receiver.
******************************************************************************/
void
usart0__enable_receiver
(
void
){
BIT__SET(UCSR0B, RXEN0);
}
 
/**************************************************************************//**
* \fn void usart0__disable_receiver(void)
*
* \brief Disable USART 0 receiver.
******************************************************************************/
void
usart0__disable_receiver
(
void
){
BIT__RST(UCSR0B, RXEN0);
}
 
/**************************************************************************//**
* \fn void usart0__enable_transmitter(void)
*
* \brief Enable USART 0 transmitter.
******************************************************************************/
void
usart0__enable_transmitter
(
void
){
BIT__SET(UCSR0B, TXEN0);
}
 
/**************************************************************************//**
* \fn void usart0__disable_transmitter(void)
*
* \brief Disable USART 0 transmitter.
******************************************************************************/
void
usart0__disable_transmitter
(
void
){
BIT__RST(UCSR0B, TXEN0);
}
 
/**************************************************************************//**
* \fn uint8_t usart0__receive_byte(void)
*
* \brief Receive a byte on USART0.
*
* \return received byte
******************************************************************************/
uint16_t
usart0__receive_byte
(
void
){
// Wait for data to be received.
while (!(UCSR0A & (1 << RXC0)));
 
// Get received data.
uint16_t received_byte = UDR0;
 
if (USART__DATA_SIZE__9_BITS == configuration.data_size)
{
// If 9-bit data size, get 9th bit.
uint8_t resh = UCSR0B;
resh = (resh >> 1) & 0x01;
received_byte = (resh << 8) | received_byte;
}
 
// Return received data from buffer.
return received_byte;
}
 
/**************************************************************************//**
* \fn usart0__transmit_byte(uint8_t byte_to_transmit)
*
* \brief Transmit a byte on USART0.
*
* \param byte_to_transmit byte to transmit
******************************************************************************/
void
usart0__transmit_byte
(
uint16_t byte_to_transmit
){
// Wait for empty transmit buffer.
while (!(UCSR0A & (1 << UDRE0)));
 
if (USART__DATA_SIZE__9_BITS == configuration.data_size)
{
// If 9-bit data size, copy 9th bit to TXB80.
UCSR0B &= ~(1 << TXB80);
if (byte_to_transmit & 0x0100)
{
UCSR0B |= (1 << TXB80);
}
}
 
// Put data into transmit buffer, sends the data.
UDR0 = byte_to_transmit;
}
 
/**************************************************************************//**
* \fn void usart0__flush(void)
*
* \brief Flush USART0 receiver buffer.
******************************************************************************/
void
usart0__flush
(
void
){
uint8_t dummy = 0;
while (UCSR0A & (1 << RXC0))
{
dummy = UDR0;
}
}
 
/**************************************************************************//**
* \fn void usart0__enable_rx_complete_interrupt(void)
*
* \brief Enable USART 0 receive complete interrupt.
******************************************************************************/
void
usart0__enable_rx_complete_interrupt
(
void
){
BIT__SET(UCSR0B, RXCIE0);
sei();
}
 
/**************************************************************************//**
* \fn void usart0__disable_rx_complete_interrupt(void)
*
* \brief Disable USART 0 receive complete interrupt.
******************************************************************************/
void
usart0__disable_rx_complete_interrupt
(
void
){
BIT__RST(UCSR0B, RXCIE0);
sei();
}
 
/**************************************************************************//**
* \fn void usart0__set_rx_complete_callback(
* const usart__rx_complete_callback_t* p_callback)
*
* \brief Set a callback to call when receive byte complete interrupt is
* generated.
*
* \param[in] p_callback Callback to set.
******************************************************************************/
void
usart0__set_rx_complete_callback
(
const usart__rx_complete_callback_t* p_callback
){
// Check the preconditions.
assert(NULL != p_callback);
 
p_rx_complete = p_callback;
}
 
/**************************************************************************//**
* \fn void usart0__enable_tx_complete_interrupt(void)
*
* \brief Enable interrupt when TX complete.
******************************************************************************/
void
usart0__enable_tx_complete_interrupt
(
void
){
BIT__SET(UCSR0B, TXCIE0);
sei();
}
 
/**************************************************************************//**
* \fn void usart0__disable_tx_complete_interrupt(void)
*
* \brief Disable interrupt when TX complete.
******************************************************************************/
void
usart0__disable_tx_complete_interrupt
(
void
){
BIT__RST(UCSR0B, TXCIE0);
sei();
}
 
/**************************************************************************//**
* \fn void usart0__set_tx_complete_callback(
* const usart__tx_complete_callback_t* p_callback)
*
* \brief Set a callback to call when TX is complete.
*
* \param[in] p_callback Function to call.
******************************************************************************/
void
usart0__set_tx_complete_callback
(
const usart__tx_complete_callback_t* p_callback
){
// Check the preconditions.
assert(NULL != p_callback);
 
p_tx_complete = p_callback;
}
 
/**************************************************************************//**
* \fn void usart0__enable_data_register_empty_interrupt()
*
* \brief Enable interrupt when data register is empty.
******************************************************************************/
void
usart0__enable_data_register_empty_interrupt
(
void
){
BIT__SET(UCSR0B, UDRIE0);
sei();
}
 
/**************************************************************************//**
* \fn void usart0__disable_data_register_empty_interrupt()
*
* \brief Disable interrupt when data register is empty.
******************************************************************************/
void
usart0__disable_data_register_empty_interrupt
(
void
){
BIT__RST(UCSR0B, UDRIE0);
sei();
}
 
/**************************************************************************//**
* \fn void usart0__set_data_register_empty_callback(
* const usart__data_register_empty_callback_t* p_callback)
*
* \brief Set a callback to call when data register is empty.
*
* \param[in] p_callback Function to call.
******************************************************************************/
void
usart0__set_data_register_empty_callback
(
const usart__data_register_empty_callback_t* p_callback
){
// Check the preconditions.
assert(NULL != p_callback);
 
p_data_register_empty = p_callback;
}
 
/******************************************************************************
* Private function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn static inline uint16_t usart0__compute_ubrr(void)
*
* \brief Compute UBRR register value.
*
* \return UBRR value.
******************************************************************************/
static inline
uint16_t
usart0__compute_ubrr
(
void
){
uint16_t ubrr = 0;
 
switch (configuration.mode)
{
case USART__MODE__ASYNCHRONOUS:
{
if (!double_speed_is_set)
{
ubrr = F_CPU / (16 * usart__baudrate_values[configuration.baudrate]) - 1;
}
else
{
ubrr = F_CPU / (8 * usart__baudrate_values[configuration.baudrate]) - 1;
}
}
break;
 
case USART__MODE__SYNCHRONOUS:
{
ubrr = F_CPU / (2 * usart__baudrate_values[configuration.baudrate]) - 1;
}
break;
 
case USART__MODE__MASTER_SPI:
break;
 
default:
break;
}
 
return ubrr;
}
 
/******************************************************************************
* Interrupt vectors.
******************************************************************************/
 
/**************************************************************************//**
* \fn ISR(USART_RX_vect)
*
* \brief RX interrupt vector.
******************************************************************************/
ISR(USART0_RX_vect)
{
if (NULL != p_rx_complete)
{
p_rx_complete();
}
}
 
/**************************************************************************//**
* \fn ISR(USART_TX_vect)
*
* \brief TX interrupt vector.
******************************************************************************/
ISR(USART0_TX_vect)
{
if (NULL != p_tx_complete)
{
p_tx_complete();
}
}
 
/**************************************************************************//**
* \fn ISR(USART_UDRE_vect)
*
* \brief Data register empty interrupt vector.
******************************************************************************/
ISR(USART0_UDRE_vect)
{
if (NULL != p_data_register_empty)
{
p_data_register_empty();
}
}
/trunk/libraries/usart/src/usart0_m328.c
0,0 → 1,702
/**************************************************************************//**
* \brief USART0 library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090426
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file usart0_m328.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../usart0.h"
#include "../include/usart_prv.h"
 
#include <usart/usart.h>
 
#include <useful/bits.h>
 
#include <avr/interrupt.h>
#include <avr/io.h>
 
#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
 
/******************************************************************************
* Private variable declarations.
******************************************************************************/
 
static usart__rx_complete_callback_t* p_rx_complete = NULL;
static usart__tx_complete_callback_t* p_tx_complete = NULL;
static usart__data_register_empty_callback_t* p_data_register_empty = NULL;
 
static usart__configuration_t configuration =
{
.mode = USART__MODE__ASYNCHRONOUS,
.baudrate = USART__BAUDRATE__9600,
.data_size = USART__DATA_SIZE__8_BITS,
.stop_size = USART__STOP_SIZE__1_BIT,
.parity = USART__PARITY__DISABLED
};
 
static bool double_speed_is_set = false;
 
/******************************************************************************
* Private function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn static inline uint16_t usart0__compute_ubrr(void)
*
* \brief Compute UBRR register value.
*
* \return UBRR value.
******************************************************************************/
static inline
uint16_t
usart0__compute_ubrr
(
void
);
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn void usart0__initialize(usart__configuration_t* p_configuration)
*
* \brief Initialize USART0.
*
* \param[in] p_configuration USART configuration. If null, default settings
* will be used.
*
* Default settings:
* - baudrate = 9600 bps;
* - 8 data bits;
* - 1 stop bit;
* - no parity.
******************************************************************************/
void
usart0__initialize
(
const usart__configuration_t* p_configuration
){
// If p_configuration is not null, use it!
if (NULL != p_configuration)
{
configuration = *p_configuration;
}
 
// Set mode.
usart0__set_mode(configuration.mode);
 
// Set baud rate.
usart0__set_baudrate(configuration.baudrate);
usart0__set_double_speed(false);
 
// Configure settings.
usart0__set_data_size(configuration.data_size);
usart0__set_stop_size(configuration.stop_size);
usart0__set_parity(configuration.parity);
}
 
/**************************************************************************//**
* \fn void usart0__set_baudrate(usart__baudrate_t baudrate)
*
* \brief Set USART0 baudrate.
*
* \param baudrate baudrate to set (in bauds per second)
******************************************************************************/
void
usart0__set_baudrate
(
usart__baudrate_t baudrate
){
configuration.baudrate = baudrate;
 
uint16_t ubrr = usart0__compute_ubrr();
UBRR0H = (uint8_t)(ubrr >> 8);
UBRR0L = (uint8_t)ubrr;
}
 
/**************************************************************************//**
* \fn void usart0__set_mode(usart__mode_t usart_mode)
*
* \brief Set USART0 mode.
*
* \param usart_mode Mode to set.
******************************************************************************/
void
usart0__set_mode
(
usart__mode_t usart_mode
){
// Check the preconditions.
assert(USART__MODE__INVALID > usart_mode);
 
configuration.mode = usart_mode;
 
switch (usart_mode)
{
case USART__MODE__ASYNCHRONOUS:
{
BIT__RST(UCSR0C, UMSEL01);
BIT__RST(UCSR0C, UMSEL00);
}
break;
 
case USART__MODE__SYNCHRONOUS:
{
BIT__RST(UCSR0C, UMSEL01);
BIT__SET(UCSR0C, UMSEL00);
}
break;
 
case USART__MODE__MASTER_SPI:
{
BIT__SET(UCSR0C, UMSEL01);
BIT__SET(UCSR0C, UMSEL00);
}
break;
 
case USART__MODE__INVALID:
default:
break;
}
}
 
/**************************************************************************//**
* \fn void usart0__set_data_size(usart__data_sizet data_size)
*
* \brief Set USART0 data size.
*
* \param data_size data size (in bits)
******************************************************************************/
void
usart0__set_data_size
(
usart__data_size_t data_size
){
configuration.data_size = data_size;
 
switch (data_size)
{
case USART__DATA_SIZE__5_BITS:
{
BIT__RST(UCSR0B, UCSZ02);
BIT__RST(UCSR0C, UCSZ01);
BIT__RST(UCSR0C, UCSZ00);
}
break;
 
case USART__DATA_SIZE__6_BITS:
{
BIT__RST(UCSR0B, UCSZ02);
BIT__RST(UCSR0C, UCSZ01);
BIT__SET(UCSR0C, UCSZ00);
}
break;
 
case USART__DATA_SIZE__7_BITS:
{
BIT__RST(UCSR0B, UCSZ02);
BIT__SET(UCSR0C, UCSZ01);
BIT__RST(UCSR0C, UCSZ00);
}
break;
 
case USART__DATA_SIZE__8_BITS:
{
BIT__RST(UCSR0B, UCSZ02);
BIT__SET(UCSR0C, UCSZ01);
BIT__SET(UCSR0C, UCSZ00);
}
break;
 
case USART__DATA_SIZE__9_BITS:
{
BIT__SET(UCSR0B, UCSZ02);
BIT__SET(UCSR0C, UCSZ01);
BIT__SET(UCSR0C, UCSZ00);
}
break;
 
default:
break;
}
}
 
/**************************************************************************//**
* \fn void usart0__set_stop_size(usart__stop_size_t stop_size)
*
* \brief Set USART0 stop size.
*
* \param stop_size stop size (in bits)
******************************************************************************/
void
usart0__set_stop_size
(
usart__stop_size_t stop_size
){
configuration.stop_size = stop_size;
 
if (USART__STOP_SIZE__1_BIT == stop_size)
{
BIT__RST(UCSR0C, USBS0);
}
else
{
BIT__SET(UCSR0C, USBS0);
}
}
 
/**************************************************************************//**
* \fn void usart0__set_parity(usart__parity_t parity)
*
* \brief Set USART0 parity.
*
* \param parity parity to set
******************************************************************************/
void
usart0__set_parity
(
usart__parity_t parity
){
configuration.parity = parity;
 
switch (parity)
{
case USART__PARITY__DISABLED:
{
BIT__RST(UCSR0C, UPM01);
BIT__RST(UCSR0C, UPM00);
}
break;
 
case USART__PARITY__EVEN:
{
BIT__SET(UCSR0C, UPM01);
BIT__RST(UCSR0C, UPM00);
}
break;
 
case USART__PARITY__ODD:
{
BIT__SET(UCSR0C, UPM01);
BIT__SET(UCSR0C, UPM00);
}
break;
 
default:
break;
}
}
 
/**************************************************************************//**
* \fn void usart0__set_double_speed(bool double_speed)
*
* \brief Set double speed.
*
* \param double_speed True to set double speed, false otherwise.
******************************************************************************/
void
usart0__set_double_speed
(
bool double_speed
){
double_speed_is_set = double_speed;
 
if (double_speed_is_set)
{
BIT__SET(UCSR0A, U2X0);
}
else
{
BIT__RST(UCSR0A, U2X0);
}
}
 
/**************************************************************************//**
* \fn void usart0__enable_receiver(void)
*
* \brief Enable USART 0 receiver.
******************************************************************************/
void
usart0__enable_receiver
(
void
){
BIT__SET(UCSR0B, RXEN0);
}
 
/**************************************************************************//**
* \fn void usart0__disable_receiver(void)
*
* \brief Disable USART 0 receiver.
******************************************************************************/
void
usart0__disable_receiver
(
void
){
BIT__RST(UCSR0B, RXEN0);
}
 
/**************************************************************************//**
* \fn void usart0__enable_transmitter(void)
*
* \brief Enable USART 0 transmitter.
******************************************************************************/
void
usart0__enable_transmitter
(
void
){
BIT__SET(UCSR0B, TXEN0);
}
 
/**************************************************************************//**
* \fn void usart0__disable_transmitter(void)
*
* \brief Disable USART 0 transmitter.
******************************************************************************/
void
usart0__disable_transmitter
(
void
){
BIT__RST(UCSR0B, TXEN0);
}
 
/**************************************************************************//**
* \fn uint8_t usart0__receive_byte(void)
*
* \brief Receive a byte on USART0.
*
* \return received byte
******************************************************************************/
uint16_t
usart0__receive_byte
(
void
){
// Wait for data to be received.
while (!(UCSR0A & (1 << RXC0)));
 
// Get received data.
uint16_t received_byte = UDR0;
 
if (USART__DATA_SIZE__9_BITS == configuration.data_size)
{
// If 9-bit data size, get 9th bit.
uint8_t resh = UCSR0B;
resh = (resh >> 1) & 0x01;
received_byte = (resh << 8) | received_byte;
}
 
// Return received data from buffer.
return received_byte;
}
 
/**************************************************************************//**
* \fn usart0__transmit_byte(uint8_t byte_to_transmit)
*
* \brief Transmit a byte on USART0.
*
* \param byte_to_transmit byte to transmit
******************************************************************************/
void
usart0__transmit_byte
(
uint16_t byte_to_transmit
){
// Wait for empty transmit buffer.
while (!(UCSR0A & (1 << UDRE0)));
 
if (USART__DATA_SIZE__9_BITS == configuration.data_size)
{
// If 9-bit data size, copy 9th bit to TXB80.
UCSR0B &= ~(1 << TXB80);
if (byte_to_transmit & 0x0100)
{
UCSR0B |= (1 << TXB80);
}
}
 
// Put data into transmit buffer, sends the data.
UDR0 = byte_to_transmit;
}
 
/**************************************************************************//**
* \fn void usart0__flush(void)
*
* \brief Flush USART0 receiver buffer.
******************************************************************************/
void
usart0__flush
(
void
){
uint8_t dummy = 0;
while (UCSR0A & (1 << RXC0))
{
dummy = UDR0;
}
}
 
/**************************************************************************//**
* \fn void usart0__enable_rx_complete_interrupt(void)
*
* \brief Enable USART 0 receive complete interrupt.
******************************************************************************/
void
usart0__enable_rx_complete_interrupt
(
void
){
BIT__SET(UCSR0B, RXCIE0);
sei();
}
 
/**************************************************************************//**
* \fn void usart0__disable_rx_complete_interrupt(void)
*
* \brief Disable USART 0 receive complete interrupt.
******************************************************************************/
void
usart0__disable_rx_complete_interrupt
(
void
){
BIT__RST(UCSR0B, RXCIE0);
sei();
}
 
/**************************************************************************//**
* \fn void usart0__set_rx_complete_callback(
* const usart__rx_complete_callback_t* p_callback)
*
* \brief Set a callback to call when receive byte complete interrupt is
* generated.
*
* \param[in] p_callback Callback to set.
******************************************************************************/
void
usart0__set_rx_complete_callback
(
const usart__rx_complete_callback_t* p_callback
){
// Check the preconditions.
assert(NULL != p_callback);
 
p_rx_complete = p_callback;
}
 
/**************************************************************************//**
* \fn void usart0__enable_tx_complete_interrupt(void)
*
* \brief Enable interrupt when TX complete.
******************************************************************************/
void
usart0__enable_tx_complete_interrupt
(
void
){
BIT__SET(UCSR0B, TXCIE0);
sei();
}
 
/**************************************************************************//**
* \fn void usart0__disable_tx_complete_interrupt(void)
*
* \brief Disable interrupt when TX complete.
******************************************************************************/
void
usart0__disable_tx_complete_interrupt
(
void
){
BIT__RST(UCSR0B, TXCIE0);
sei();
}
 
/**************************************************************************//**
* \fn void usart0__set_tx_complete_callback(
* const usart__tx_complete_callback_t* p_callback)
*
* \brief Set a callback to call when TX is complete.
*
* \param[in] p_callback Function to call.
******************************************************************************/
void
usart0__set_tx_complete_callback
(
const usart__tx_complete_callback_t* p_callback
){
// Check the preconditions.
assert(NULL != p_callback);
 
p_tx_complete = p_callback;
}
 
/**************************************************************************//**
* \fn void usart0__enable_data_register_empty_interrupt()
*
* \brief Enable interrupt when data register is empty.
******************************************************************************/
void
usart0__enable_data_register_empty_interrupt
(
void
){
BIT__SET(UCSR0B, UDRIE0);
sei();
}
 
/**************************************************************************//**
* \fn void usart0__disable_data_register_empty_interrupt()
*
* \brief Disable interrupt when data register is empty.
******************************************************************************/
void
usart0__disable_data_register_empty_interrupt
(
void
){
BIT__RST(UCSR0B, UDRIE0);
sei();
}
 
/**************************************************************************//**
* \fn void usart0__set_data_register_empty_callback(
* const usart__data_register_empty_callback_t* p_callback)
*
* \brief Set a callback to call when data register is empty.
*
* \param[in] p_callback Function to call.
******************************************************************************/
void
usart0__set_data_register_empty_callback
(
const usart__data_register_empty_callback_t* p_callback
){
// Check the preconditions.
assert(NULL != p_callback);
 
p_data_register_empty = p_callback;
}
 
/******************************************************************************
* Private function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn static inline uint16_t usart0__compute_ubrr(void)
*
* \brief Compute UBRR register value.
*
* \return UBRR value.
******************************************************************************/
static inline
uint16_t
usart0__compute_ubrr
(
void
){
uint16_t ubrr = 0;
 
switch (configuration.mode)
{
case USART__MODE__ASYNCHRONOUS:
{
if (!double_speed_is_set)
{
ubrr = F_CPU / (16 * usart__baudrate_values[configuration.baudrate]) - 1;
}
else
{
ubrr = F_CPU / (8 * usart__baudrate_values[configuration.baudrate]) - 1;
}
}
break;
 
case USART__MODE__SYNCHRONOUS:
{
ubrr = F_CPU / (2 * usart__baudrate_values[configuration.baudrate]) - 1;
}
break;
 
case USART__MODE__MASTER_SPI:
break;
 
default:
break;
}
 
return ubrr;
}
 
/******************************************************************************
* Interrupt vectors.
******************************************************************************/
 
/**************************************************************************//**
* \fn ISR(USART_RX_vect)
*
* \brief RX interrupt vector.
******************************************************************************/
ISR(USART_RX_vect)
{
if (NULL != p_rx_complete)
{
p_rx_complete();
}
}
 
/**************************************************************************//**
* \fn ISR(USART_TX_vect)
*
* \brief TX interrupt vector.
******************************************************************************/
ISR(USART_TX_vect)
{
if (NULL != p_tx_complete)
{
p_tx_complete();
}
}
 
/**************************************************************************//**
* \fn ISR(USART_UDRE_vect)
*
* \brief Data register empty interrupt vector.
******************************************************************************/
ISR(USART_UDRE_vect)
{
if (NULL != p_data_register_empty)
{
p_data_register_empty();
}
}
/trunk/libraries/usart/src/SConscript
0,0 → 1,18
# Import environment set for target.
Import('env_target')
 
# Define target name.
TARGET = 'usart'
 
# Define source files.
if env_target['MCU'] == 'atmega328p':
sources = [
'usart0_m328.c'
]
elif env_target['MCU'] == 'atmega2560':
sources = [
'usart0_m2560.c'
]
 
# Build library.
env_target.BuildLibrary(sources, TARGET)
/trunk/libraries/usart/include/usart_prv.h
0,0 → 1,68
/**************************************************************************//**
* \brief USART library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090426
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile usart_prv.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__USART_PRV__H
#define H__IDREAMMICRO__USART_PRV__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/**************************************************************************//**
* Header file inclusions.
******************************************************************************/
 
#include "../usart.h"
 
#include <stdint.h>
 
/**************************************************************************//**
* Internal constant definitions.
******************************************************************************/
 
const uint32_t usart__baudrate_values[] =
{
[USART__BAUDRATE__2400] = 2400,
[USART__BAUDRATE__4800] = 4800,
[USART__BAUDRATE__9600] = 9600,
[USART__BAUDRATE__14400] = 14400,
[USART__BAUDRATE__19200] = 19200,
[USART__BAUDRATE__28800] = 28800,
[USART__BAUDRATE__38400] = 38400,
[USART__BAUDRATE__57600] = 57600,
[USART__BAUDRATE__76800] = 76800,
[USART__BAUDRATE__115200] = 115200,
[USART__BAUDRATE__230400] = 230400,
[USART__BAUDRATE__250000] = 250000,
[USART__BAUDRATE__500000] = 500000,
[USART__BAUDRATE__1000000] = 1000000
};
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__USART__H */
/trunk/libraries/usart/usart.h
0,0 → 1,174
/**************************************************************************//**
* \brief USART library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090426
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile usart.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__USART__H
#define H__IDREAMMICRO__USART__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Public types.
******************************************************************************/
 
/**************************************************************************//**
* \enum usart__baudrates
* \brief USART baudrates (in baud per second).
*
* \typedef usart__baudrate_t
* \brief USART baudrate (in baud per second).
******************************************************************************/
typedef enum usart__baudrates
{
USART__BAUDRATE__2400, /*!< 2400 bps. */
USART__BAUDRATE__4800, /*!< 4800 bps. */
USART__BAUDRATE__9600, /*!< 9600 bps. */
USART__BAUDRATE__14400, /*!< 14400 bps. */
USART__BAUDRATE__19200, /*!< 19200 bps. */
USART__BAUDRATE__28800, /*!< 28800 bps. */
USART__BAUDRATE__38400, /*!< 38400 bps. */
USART__BAUDRATE__57600, /*!< 57600 bps. */
USART__BAUDRATE__76800, /*!< 76800 bps. */
USART__BAUDRATE__115200, /*!< 115200 bps. */
USART__BAUDRATE__230400, /*!< 230400 bps. */
USART__BAUDRATE__250000, /*!< 250000 bps. */
USART__BAUDRATE__500000, /*!< 500000 bps. */
USART__BAUDRATE__1000000 /*!< 1000000 bps. */
} usart__baudrate_t;
 
/**************************************************************************//**
* \enum usart__modes
* \brief USART modes.
*
* \typedef usart__mode_t
* \brief USART mode.
******************************************************************************/
typedef enum usart__modes
{
USART__MODE__ASYNCHRONOUS,
USART__MODE__SYNCHRONOUS,
USART__MODE__MASTER_SPI,
USART__MODE__INVALID
} usart__mode_t;
 
/**************************************************************************//**
* \enum usart__data_sizes
* \brief USART data sizes.
*
* \typedef usart__data_size_t
* \brief USART data size.
******************************************************************************/
typedef enum usart__data_sizes
{
USART__DATA_SIZE__5_BITS, /*!< 5 data bits. */
USART__DATA_SIZE__6_BITS, /*!< 6 data bits. */
USART__DATA_SIZE__7_BITS, /*!< 7 data bits. */
USART__DATA_SIZE__8_BITS, /*!< 8 data bits. */
USART__DATA_SIZE__9_BITS /*!< 9 data bits. */
} usart__data_size_t;
 
/**************************************************************************//**
* \enum usart__stop_sizes
* \brief USART stop bits.
*
* \typedef usart__stop_size_t
* \brief USART stop bits.
******************************************************************************/
typedef enum usart__stop_sizes
{
USART__STOP_SIZE__1_BIT, /*!< 1 stop bit. */
USART__STOP_SIZE__2_BITS /*!< 2 stop bits. */
} usart__stop_size_t;
 
/**************************************************************************//**
* \enum usart__parities
* \brief USART parities.
*
* \typedef usart__parity_t
* \brief USART parity.
******************************************************************************/
typedef enum usart__parities
{
USART__PARITY__DISABLED, /*!< Parity disabled. */
USART__PARITY__EVEN, /*!< Even parity. */
USART__PARITY__ODD /*!< Odd parity. */
} usart__parity_t;
 
/**************************************************************************//**
* \struct usart__configuration
* \brief USART configuration.
*
* \typedef usart__configuration_t
* \brief USART configuration.
******************************************************************************/
typedef struct usart__configuration
{
usart__mode_t mode;
usart__baudrate_t baudrate;
usart__data_size_t data_size;
usart__stop_size_t stop_size;
usart__parity_t parity;
} usart__configuration_t;
 
/**************************************************************************//**
* \typedef usart__rx_complete_callback_t
* \brief RX complete callback.
******************************************************************************/
typedef
void
usart__rx_complete_callback_t
(
void
);
 
/**************************************************************************//**
* \typedef usart__tx_complete_callback_t
* \brief TX complete callback.
******************************************************************************/
typedef
void
usart__tx_complete_callback_t
(
void
);
 
/**************************************************************************//**
* \typedef usart__data_register_empty_callback_t
* \brief Data register empty callback.
******************************************************************************/
typedef
void
usart__data_register_empty_callback_t
(
void
);
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__USART__H */
/trunk/libraries/usart/test/usart0__test.c
0,0 → 1,78
/**************************************************************************//**
* \brief USART library - Test program
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090314
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file usart0__test.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../usart0.h"
 
#include <util/delay.h>
 
#include <stdlib.h>
 
/******************************************************************************
* Main function.
******************************************************************************/
 
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
*****************************************************************************/
int
main
(
void
){
// Initialize USART0.
usart0__initialize(NULL);
 
// Enbale transmitter.
usart0__enable_transmitter();
 
// Transmit characters.
for (;;)
{
usart0__transmit_byte('H');
usart0__transmit_byte('e');
usart0__transmit_byte('l');
usart0__transmit_byte('l');
usart0__transmit_byte('o');
usart0__transmit_byte(' ');
usart0__transmit_byte('W');
usart0__transmit_byte('o');
usart0__transmit_byte('r');
usart0__transmit_byte('l');
usart0__transmit_byte('d');
usart0__transmit_byte('!');
usart0__transmit_byte('\n');
 
_delay_ms(500);
}
 
return 0;
}
/trunk/libraries/usart/test/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'usart0__test'
 
# Set source file.
sources = [
'usart0__test.c'
]
 
# Build project and libraries.
env_target.BuildProject(sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/libraries/usart/demo/usart0__demo.c
0,0 → 1,78
/**************************************************************************//**
* \brief USART library - Demonstration program
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090314
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file usart0__demo.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include "../usart0.h"
 
#include <util/delay.h>
 
#include <stdlib.h>
 
/******************************************************************************
* Main function.
******************************************************************************/
 
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
*****************************************************************************/
int
main
(
void
){
// Initialize USART0.
usart0__initialize(NULL);
 
// Enbale transmitter.
usart0__enable_transmitter();
 
// Transmit characters.
for (;;)
{
usart0__transmit_byte('H');
usart0__transmit_byte('e');
usart0__transmit_byte('l');
usart0__transmit_byte('l');
usart0__transmit_byte('o');
usart0__transmit_byte(' ');
usart0__transmit_byte('W');
usart0__transmit_byte('o');
usart0__transmit_byte('r');
usart0__transmit_byte('l');
usart0__transmit_byte('d');
usart0__transmit_byte('!');
usart0__transmit_byte('\n');
 
_delay_ms(500);
}
 
return 0;
}
/trunk/libraries/usart/demo/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'usart0__demo'
 
# Set source file.
sources = [
'usart0__demo.c'
]
 
# Build project and libraries.
env_target.BuildProject(sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/libraries/usart/.sconsign.dblite
/trunk/libraries/usart/.sconsign.dblite
Modification de propriétés sur libraries/usart/.sconsign.dblite
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
/trunk/libraries/usart/SConscript
0,0 → 1,16
# Import environment set for target.
Import('env_target')
 
# Define directories to process.
directories = [
'src/'
]
 
# Process directories.
for directory in directories:
SConscript(
directory + 'SConscript',
variant_dir = '#build/' + '/libraries/usart/' + env_target['NAME'],
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/libraries/usart/SConstruct
0,0 → 1,40
# Import build tools.
SConscript('#min_env/build_tools.py')
 
# Set environment for AVR-GCC.
SConscript('#min_env/env_target.py')
 
# Import environment set for AVR-GCC.
Import('env_target')
 
# Append CPPPATH.
env_target.Append(CPPPATH = [ '#../' ])
 
# Build library.
SConscript(
'src/SConscript',
variant_dir = '#build/lib/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Append LIBPATH and LIBS.
env_target.Append(LIBPATH = [ '#build/lib/'])
env_target.Append(LIBS = [ 'usart' ])
 
# Build demonstration program.
SConscript(
'demo/SConscript',
variant_dir = '#build/demo/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
# Build test program.
SConscript(
'test/SConscript',
variant_dir = '#build/test/',
exports = { 'env_target' : env_target },
duplicate = 0
)
 
/trunk/libraries/usart/min_env/env_target.py
0,0 → 1,27
# Create and initialize the environment.
env_target = Environment()
 
# Set environment for AVR-GCC.
env_target['CC'] = 'avr-gcc'
env_target['CPPPATH'] = '/usr/lib/avr/include'
env_target['OBJCOPY'] = 'avr-objcopy'
env_target['SIZE'] = 'avr-size'
env_target['AR'] = 'avr-ar'
env_target['RANLIB'] = 'avr-ranlib'
env_target.Append(CCFLAGS = '-Os')
 
# Define environment name.
env_target.Append(NAME = 'env_target')
 
# Microcontroller type.
env_target.Append(MCU = 'atmega328p')
# Microcontroller frequency in Hertz.
env_target.Append(F_CPU = '16000000UL')
 
# Set environment for an Atmel AVR ATmega328p microcontroller.
env_target.Append(CCFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(LINKFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(CPPDEFINES = 'F_CPU=' + env_target['F_CPU'])
 
# Export environment set for target.
Export('env_target')
/trunk/libraries/usart/min_env/build_tools.py
0,0 → 1,41
"""
Build project.
"""
def BuildProject(env, sources, target_name):
# Build program.
env.Program(target = target_name + '.elf', source = sources)
# Create hex binary file.
env.Command(
target_name + '.hex',
target_name + '.elf',
env['OBJCOPY'] + ' -O ihex $SOURCE $TARGET'
)
AddMethod(Environment, BuildProject)
 
"""
Build library.
"""
def BuildLibrary(env, sources, target_name):
# Build static library.
env.StaticLibrary(target = target_name, source = sources)
# Append LIBPATH and LIBS.
env.Append(LIBPATH = [ '#build/libraries/' + target_name + '/' + env['NAME'] ])
env.Append(LIBS = [ target_name ])
 
AddMethod(Environment, BuildLibrary)
 
"""
Compute memory usage.
"""
def ComputeMemoryUsage(env, target_name):
# Compute memory usage.
env.Command(
None,
target_name + '.elf',
env['SIZE'] + ' -C --mcu=' + env['MCU'] + ' $SOURCE'
)
AddMethod(Environment, ComputeMemoryUsage)
/trunk/libraries/usart
Modification de propriétés sur libraries/usart
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,2 ##
+build
+.sconsign.dblite
/trunk/libraries/useful/datetime.h
0,0 → 1,91
/**************************************************************************//**
* \brief Date and time management library
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090501
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile datetime.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__USEFUL__DATETIME__H
#define H__IDREAMMICRO__USEFUL__DATETIME__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <stdint.h>
 
/******************************************************************************
* Public types definitions.
******************************************************************************/
 
/**************************************************************************//**
* \enum datetime__meridiems
* \brief Time meridiems.
*
* \typedef datetime__meridiem_t
* \brief Time meridiem.
******************************************************************************/
typedef enum datetime__meridiems
{
DATETIME__MERIDIEM__AM = 0, /*!< Ante meridiem. */
DATETIME__MERIDIEM__PM = 1 /*!< Post meridiem. */
} datetime__meridiem_t;
 
/**************************************************************************//**
* \struct datetime__time
* \brief Time.
*
* \typedef datetime__time_t
* \brief Time.
******************************************************************************/
typedef struct datetime__time
{
uint8_t seconds; /*!< Seconds (0-59). */
uint8_t minutes; /*!< Minutes (0-59). */
uint8_t hours; /*!< Hours (1-12 or 0-23). */
datetime__meridiem_t meridiem; /*!< Meridiem (AM-PM). */
} datetime__time_t;
 
/**************************************************************************//**
* \struct datetime__date
* \brief Date.
*
* \typedef datetime__date_t
* \brief Date.
******************************************************************************/
typedef struct datetime__date
{
uint8_t day; /*!< Day (1-7). */
uint8_t date; /*!< Date (1-31). */
uint8_t month; /*!< Month (1-12). */
uint8_t year; /*!< Year (0-99). */
} datetime__date_t;
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__USEFUL__DATETIME__H */
/trunk/libraries/useful/miscellaneous.h
0,0 → 1,49
/**************************************************************************//**
* \brief Miscellaneous facilities
* \author Copyright (C) 2012 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20120709
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile miscellaneous.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__USEFUL__MISCELLANEOUS__H
#define H__IDREAMMICRO__USEFUL__MISCELLANEOUS__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Public macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def ITEMS_IN_ARRAY
* \brief Get number of items in array.
******************************************************************************/
#define ITEMS_IN_ARRAY(array) (sizeof(array) / sizeof(*array))
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__USEFUL__MISCELLANEOUS__H */
 
/trunk/libraries/useful/bits.h
0,0 → 1,67
/**************************************************************************//**
* \brief Bit manipulation library - API
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20110823
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \headerfile bits.h
******************************************************************************/
 
#ifndef H__IDREAMMICRO__USEFUL__BITS__H
#define H__IDREAMMICRO__USEFUL__BITS__H
 
#ifdef _cplusplus
extern "C"{
#endif
 
/******************************************************************************
* Public macro definitions.
******************************************************************************/
 
/**************************************************************************//**
* \def BIT__SET
* \brief Set a bit in a byte.
******************************************************************************/
#define BIT__SET(variable, bit) (variable |= (1 << bit))
 
/**************************************************************************//**
* \def BIT__RST
* \brief Reset a bit in a byte.
******************************************************************************/
#define BIT__RST(variable, bit) (variable &= ~(1 << bit))
 
/**************************************************************************//**
* \def BIT__TGL
* \brief Toggle a bit in a byte.
******************************************************************************/
#define BIT__TGL(variable, bit) (variable ^= (1 << bit))
 
/**************************************************************************//**
* \def BIT__TST
* \brief Test a bit in a byte.
******************************************************************************/
#define BIT__TST(variable, bit) (variable & (1 << bit))
 
#ifdef _cplusplus
}
#endif
 
#endif /* H__IDREAMMICRO__USEFUL__BITS__H */
 
/trunk/build_system/env_avr.py
0,0 → 1,29
# Create and initialize the environment.
env_avr = Environment()
 
# Set environment for AVR-GCC.
env_avr['CC'] = 'avr-gcc'
env_avr['OBJCOPY'] = 'avr-objcopy'
env_avr['SIZE'] = 'avr-size'
env_avr['AR'] = 'avr-ar'
env_avr['RANLIB'] = 'avr-ranlib'
env_avr['CPPPATH'] = '/usr/lib/avr/include'
 
# Set language standard.
env_avr.Append(CCFLAGS = '-std=c99')
 
# Set optimization level and call prologues/epilogues.
env_avr.Append(CCFLAGS = '-Os -mcall-prologues')
 
# Use short types.
env_avr.Append(CCFLAGS = '-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums')
 
# Don't include unused function and data.
env_avr.Append(CCFLAGS = '-ffunction-sections -fdata-sections')
env_avr.Append(LINKFLAGS = '-Wl,--gc-sections')
 
# Enable linker relaxation.
env_avr.Append(LINKFLAGS = '-Wl,--relax')
 
# Export environment set for AVR-GCC.
Export('env_avr')
/trunk/build_system/env_arduino_leonardo.py
0,0 → 1,21
# Import environment set for AVR-GCC.
Import('env_avr')
 
# Create target environment by cloning AVR environment.
env_target = env_avr.Clone()
 
# Define environment name.
env_target.Append(NAME = 'env_arduino_leonardo')
 
# Microcontroller type.
env_target.Append(MCU = 'atmega32u4')
# Microcontroller frequency in Hertz.
env_target.Append(F_CPU = '16000000UL')
 
# Set environment for an Atmel AVR ATmega32u4 microcontroller.
env_target.Append(CCFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(LINKFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(CPPDEFINES = 'F_CPU=' + env_target['F_CPU'])
 
# Export environment set for target.
Export('env_target')
/trunk/build_system/build_tools.py
0,0 → 1,49
"""
Build project.
"""
def BuildProject(env, libraries, sources, target_name):
# Build libraries.
for library in libraries:
SConscript(
'#libraries/' + library + '/SConscript',
exports = { 'env' : env },
duplicate = 0
)
# Build program.
env.Program(target = target_name + '.elf', source = sources)
# Create hex binary file.
env.Command(
target_name + '.hex',
target_name + '.elf',
env['OBJCOPY'] + ' -O ihex $SOURCE $TARGET'
)
AddMethod(Environment, BuildProject)
 
"""
Build library.
"""
def BuildLibrary(env, sources, target_name):
# Build static library.
env.StaticLibrary(target = target_name, source = sources)
# Append LIBPATH and LIBS.
env.Append(LIBPATH = [ '#build/libraries/' + target_name + '/' + env['NAME'] ])
env.Append(LIBS = [ target_name ])
 
AddMethod(Environment, BuildLibrary)
 
"""
Compute memory usage.
"""
def ComputeMemoryUsage(env, target_name):
# Compute memory usage.
env.Command(
None,
target_name + '.elf',
env['SIZE'] + ' -C --mcu=' + env['MCU'] + ' $SOURCE'
)
AddMethod(Environment, ComputeMemoryUsage)
/trunk/build_system/env_arduino_uno.py
0,0 → 1,21
# Import environment set for AVR-GCC.
Import('env_avr')
 
# Create target environment by cloning AVR environment.
env_target = env_avr.Clone()
 
# Define environment name.
env_target.Append(NAME = 'env_arduino_uno')
 
# Microcontroller type.
env_target.Append(MCU = 'atmega328p')
# Microcontroller frequency in Hertz.
env_target.Append(F_CPU = '16000000UL')
 
# Set environment for an Atmel AVR ATmega328p microcontroller.
env_target.Append(CCFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(LINKFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(CPPDEFINES = 'F_CPU=' + env_target['F_CPU'])
 
# Export environment set for target.
Export('env_target')
/trunk/build_system/env_arduino_mega2560.py
0,0 → 1,21
# Import environment set for AVR-GCC.
Import('env_avr')
 
# Create target environment by cloning AVR environment.
env_target = env_avr.Clone()
 
# Define environment name.
env_target.Append(NAME = 'env_arduino_mega2560')
 
# Microcontroller type.
env_target.Append(MCU = 'atmega2560')
# Microcontroller frequency in Hertz.
env_target.Append(F_CPU = '16000000UL')
 
# Set environment for an Atmel AVR Atmega 2560 microcontroller.
env_target.Append(CCFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(LINKFLAGS = '-mmcu=' + env_target['MCU'])
env_target.Append(CPPDEFINES = 'F_CPU=' + env_target['F_CPU'])
 
# Export environment set for target.
Export('env_target')
/trunk/projects/clock/clock.c
0,0 → 1,172
/**************************************************************************//**
* \brief DS1307 RTC library - Demonstration program
* \author Copyright (C) 2011 Julien Le Sech - www.idreammicro.com
* \version 1.0
* \date 20090501
*
* This file is part of the iDreamMicro library.
*
* This library is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/
******************************************************************************/
 
/**************************************************************************//**
* \file demo_ds1307.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <deuligne/deuligne.h>
#include <ds1307/ds1307.h>
#include <twi/twi.h>
#include <usart/usart0.h>
#include <useful/datetime.h>
 
#include <avr/io.h>
#include <util/delay.h>
 
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
/******************************************************************************
* Private function prototypes.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void clock__transmit_string(const char* p_string)
*
* \brief Transmit a string through USART.
*
* \param[in] p_string String to transmit.
******************************************************************************/
static
void
clock__transmit_string
(
const char* p_string
);
 
/******************************************************************************
* Main function.
******************************************************************************/
 
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
*
* \return 0
******************************************************************************/
int main(void)
{
// Initialize USART0.
usart0__initialize(NULL);
 
// Enable transmitter.
usart0__enable_transmitter();
 
// Initialize TWI.
twi__initialize(DS1307__CLOCK_RATE);
 
// Initialize RTC.
ds1307__initialize();
 
// Declare some variables.
datetime__time_t time;
ds1307__hour_mode_t hour_mode;
datetime__date_t date;
 
// Initialize Deuligne and configure display.
deuligne__initialize();
deuligne__set_display(true, false, false);
 
// Switch on backlight.
deuligne__switch_on_backlight();
 
for (;;)
{
// Get RTC time.
ds1307__get_time(&time, &hour_mode);
 
// Get RTC date.
ds1307__get_date(&date);
 
char str_date[] = "dd/mm/yy";
snprintf
(
str_date,
strlen(str_date) + 1,
"%02u/%02u/%02u",
date.date,
date.month,
date.year
);
 
char str_time[] = "hh:mm:ss";
snprintf
(
str_time,
strlen(str_time) + 1,
"%02u:%02u:%02u",
time.hours,
time.minutes,
time.seconds
);
 
clock__transmit_string(&(str_date[0]));
usart0__transmit_byte(' ');
clock__transmit_string(&(str_time[0]));
usart0__transmit_byte('\n');
 
deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_1, 0);
deuligne__write_string(str_date);
 
deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_2, 0);
deuligne__write_string(str_time);
 
_delay_ms(1000);
}
 
return 0;
}
 
/******************************************************************************
* Private function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn static void clock__transmit_string(const char* p_string)
*
* \brief Transmit a string through USART.
*
* \param[in] p_string String to transmit.
******************************************************************************/
static
void
clock__transmit_string
(
const char* p_string
){
// Check the preconditions.
assert(NULL != p_string);
 
while (*p_string != '\0')
{
usart0__transmit_byte(*p_string);
p_string++;
}
}
/trunk/projects/clock/SConscript
0,0 → 1,26
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'clock'
 
# Set libraries to use.
libraries = [
'deuligne',
'ds1307',
'mcp23008',
'adc',
'twi',
'usart'
]
 
# Set source file.
sources = 'clock.c'
 
# Build project and libraries.
env_target.BuildProject(libraries, sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/projects/clock/SConstruct
0,0 → 1,30
# Set environment for AVR-GCC.
SConscript('#build_system/env_avr.py')
 
# Import environment set for AVR-GCC.
Import('env_avr')
 
# Append CPPPATH with the root path of libraries.
env_avr.Append(CPPPATH = [ '#libraries/' ])
 
# Define environments to use (one environment per target).
environments = [
'env_arduino_uno'
]
 
# Browse environments.
for environment in environments:
# Set environment for target.
SConscript(
'#build_system/' + environment + '.py',
exports = 'env_avr'
)
# Import environment set for target.
Import('env_target')
# Build program.
SConscript(
'SConscript',
variant_dir = '#build/' + 'projects/clock/' + environment,
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/projects/ultimate/SConscript
0,0 → 1,23
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'ultimate'
 
# Set libraries to use.
libraries = [
'ds1307',
'digital_io',
'twi',
'usart'
]
 
# Set source file.
sources = 'ultimate.c'
 
# Build project and libraries.
env_target.BuildProject(libraries, sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/projects/ultimate/ultimate.c
0,0 → 1,35
/**************************************************************************//**
* \file helloworld.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <digital_io/digital_io.h>
#include <twi/twi.h>
#include <usart/usart0.h>
 
#include <avr/io.h>
#include <util/delay.h>
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
******************************************************************************/
int
main
(
void
){
for (;;)
{
_delay_ms(500);
}
return 0;
}
/trunk/projects/ultimate/SConstruct
0,0 → 1,31
# Set environment for AVR-GCC.
SConscript('#build_system/env_avr.py')
 
# Import environment set for AVR-GCC.
Import('env_avr')
 
# Append CPPPATH with the root path of libraries.
env_avr.Append(CPPPATH = [ '#libraries/' ])
 
# Define environments to use (one environment per target).
environments = [
'env_arduino_uno',
'env_arduino_mega2560'
]
 
# Browse environments.
for environment in environments:
# Set environment for target.
SConscript(
'#build_system/' + environment + '.py',
exports = 'env_avr'
)
# Import environment set for target.
Import('env_target')
# Build program.
SConscript(
'SConscript',
variant_dir = '#build/' + 'projects/ultimate/' + environment,
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/projects/input_to_output/input_to_output.c
0,0 → 1,48
/**************************************************************************//**
* \file input_to_output.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <digital_io/digital_io.h>
 
#include <avr/io.h>
#include <util/delay.h>
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
******************************************************************************/
int
main
(
void
){
// Configure PB4 as input.
digital_io__pin_position_t input = DIGITAL_IO__PORT_B | DIGITAL_IO__PIN_4;
digital_io__configure_pin(input, DIGITAL_IO__DIRECTION__INPUT);
// Configure PB5 as output.
digital_io__pin_position_t output = DIGITAL_IO__PORT_B | DIGITAL_IO__PIN_5;
digital_io__configure_pin(output, DIGITAL_IO__DIRECTION__OUTPUT);
 
for (;;)
{
// Get input level on PB4.
digital_io__level_t level = digital_io__get_pin_level(input);
 
// Set output level on PB5.
digital_io__set_pin_level(output, level);
 
_delay_ms(250);
}
 
return 0;
}
/trunk/projects/input_to_output/SConscript
0,0 → 1,19
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'input_to_output'
 
# Set libraries to use.
libraries = [
'digital_io'
]
 
# Set source file.
sources = 'input_to_output.c'
 
# Build project and libraries.
env_target.BuildProject(libraries, sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/projects/input_to_output/SConstruct
0,0 → 1,32
# Set environment for AVR-GCC.
SConscript('#build_system/env_avr.py')
 
# Import environment set for AVR-GCC.
Import('env_avr')
 
# Append CPPPATH with the root path of libraries.
env_avr.Append(CPPPATH = [ '#libraries/' ])
 
# Define environments to use (one environment per target).
environments = [
'env_arduino_uno',
'env_arduino_mega2560'
]
 
# Browse environments.
for environment in environments:
# Set environment for target.
SConscript(
'#build_system/' + environment + '.py',
exports = 'env_avr'
)
# Import environment set for target.
Import('env_target')
# Build program.
SConscript(
'SConscript',
variant_dir = '#build/' + 'projects/input_to_output/' + environment,
exports = { 'env_target' : env_target },
duplicate = 0
)
 
/trunk/projects/helloworld/helloworld.c
0,0 → 1,46
/**************************************************************************//**
* \file helloworld.c
******************************************************************************/
 
/******************************************************************************
* Header file inclusions.
******************************************************************************/
 
#include <digital_io/digital_io.h>
 
#include <avr/io.h>
#include <util/delay.h>
 
/******************************************************************************
* Public function definitions.
******************************************************************************/
 
/**************************************************************************//**
* \fn int main(void)
*
* \brief Main function.
******************************************************************************/
int
main
(
void
){
// Declare pin.
digital_io__pin_position_t pin = DIGITAL_IO__PORT_B | DIGITAL_IO__PIN_5;
// Configure pin as output.
digital_io__configure_pin(pin, DIGITAL_IO__DIRECTION__OUTPUT);
 
for (;;)
{
// Set pin level.
digital_io__set_pin_level(pin, DIGITAL_IO__LEVEL__HIGH);
_delay_ms(1000);
 
// Reset pin level.
digital_io__set_pin_level(pin, DIGITAL_IO__LEVEL__LOW);
_delay_ms(1000);
}
 
return 0;
}
/trunk/projects/helloworld/SConscript
0,0 → 1,19
# Import environment set for target.
Import('env_target')
 
# Set target name.
TARGET = 'helloworld'
 
# Set libraries to use.
libraries = [
'digital_io'
]
 
# Set source file.
sources = 'helloworld.c'
 
# Build project and libraries.
env_target.BuildProject(libraries, sources, TARGET)
 
# Compute memory usage.
env_target.ComputeMemoryUsage(TARGET)
/trunk/projects/helloworld/SConstruct
0,0 → 1,31
# Set environment for AVR-GCC.
SConscript('#build_system/env_avr.py')
 
# Import environment set for AVR-GCC.
Import('env_avr')
 
# Append CPPPATH with the root path of libraries.
env_avr.Append(CPPPATH = [ '#libraries/' ])
 
# Define environments to use (one environment per target).
environments = [
'env_arduino_uno',
'env_arduino_mega2560'
]
 
# Browse environments.
for environment in environments:
# Set environment for target.
SConscript(
'#build_system/' + environment + '.py',
exports = 'env_avr'
)
# Import environment set for target.
Import('env_target')
# Build program.
SConscript(
'SConscript',
variant_dir = '#build/' + 'projects/helloworld/' + environment,
exports = { 'env_target' : env_target },
duplicate = 0
)
/trunk/projects/SConscript
0,0 → 1,11
# Define projects to build.
projects = [
'clock/',
'helloworld/',
'input_to_output/',
'ultimate/'
]
 
# Build each project.
for project in projects:
SConscript(project + 'SConstruct')
/trunk/SConstruct
0,0 → 1,5
# Import build tools.
SConscript('build_system/build_tools.py')
 
# Execute projects SConscript.
SConscript('projects/SConscript')
/trunk/.
Modification de propriétés sur .
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+build