From 0dc7d778857c75ed501a65b32970e47d1cdf948c Mon Sep 17 00:00:00 2001 From: Michael Moon Date: Tue, 22 Mar 2011 01:34:36 +1100 Subject: [PATCH] Massive Doxygen documentation addition 'make doc' then point your browser at doc/html/ Needs plenty of cleanup and polishing, but the main bulk is here even documents your configuration! ;) --- .gitignore | 2 +- Doxyfile | 1657 +++++++++++++++++++++++++++++++++++++++++++ Makefile | 5 +- analog.c | 17 +- analog.h | 1 + arduino.h | 26 +- clock.c | 22 +- config.gen3.h | 107 +-- config.gen6.h | 95 +-- config.h.dist | 120 ++-- config.ramps.h | 114 +-- crc.c | 13 + dda.c | 102 ++- dda.h | 72 +- dda_queue.c | 23 +- delay.c | 18 +- extruder/analog.c | 17 +- extruder/analog.h | 1 + extruder/arduino.h | 30 +- extruder/crc.c | 13 + extruder/delay.c | 18 +- extruder/heater.c | 96 ++- extruder/intercom.c | 20 +- extruder/intercom.h | 45 +- extruder/temp.c | 85 ++- extruder/timer.c | 51 +- extruder/watchdog.c | 15 +- gcode_parse.c | 28 +- gcode_parse.h | 47 +- gcode_process.c | 83 ++- heater.c | 96 ++- home.c | 19 +- intercom.c | 20 +- intercom.h | 45 +- mendel.c | 46 +- pinio.h | 4 + serial.c | 49 +- sermsg.c | 23 + sersendf.c | 29 +- temp.c | 85 ++- timer.c | 50 +- watchdog.c | 15 +- 42 files changed, 2875 insertions(+), 549 deletions(-) create mode 100644 Doxyfile diff --git a/.gitignore b/.gitignore index 7295814..8344773 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,4 @@ temporal_data config.h ThermistorTable.h sim - +doc diff --git a/Doxyfile b/Doxyfile new file mode 100644 index 0000000..32dbc95 --- /dev/null +++ b/Doxyfile @@ -0,0 +1,1657 @@ +# Doxyfile 1.7.2 + +# 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 a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = Teacup + +# 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 = + +# 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-Cyrilic, 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 = + +# 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 = NO + +# 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 = YES + +# 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 = YES + +# 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 = 2 + +# 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 = + +# 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 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 penality. +# 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 + +#--------------------------------------------------------------------------- +# 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 = YES + +# 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 = NO + +# 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 + +# 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 = YES + +# 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 , where is the value of +# the FILE_VERSION_FILTER tag, and 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 = +# FILE_VERSION_FILTER = "/bin/sh -c 'git log --pretty=\"format:%ci, author:%aN <%aE>, commit:%h\" -1 \"${1}\" || echo no git'" + +# 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 = + +#--------------------------------------------------------------------------- +# 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 = ./ extruder lufa_serial + +# 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 *.vhd *.vhdl + +FILE_PATTERNS = *.c *.h + +# 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 = NO + +# The EXCLUDE tag can be used to specify files and/or directories that should +# 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. + +EXCLUDE = .git + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix filesystem 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 = */.git/* */.git */LUFA */LUFA/* + +# 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 , where +# is the value of the INPUT_FILTER tag, and 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, INPUT_FILTER +# is applied to all files. + +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 + +#--------------------------------------------------------------------------- +# 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 = YES + +# 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. + +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 +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the stylesheet 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 +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +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 at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This 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 + +# 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. + +GENERATE_TREEVIEW = NO + +# 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 = YES + +# 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 + +# 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 = + +# 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 + +#--------------------------------------------------------------------------- +# 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 stylesheet 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 +# in the INCLUDE_PATH (see below) will be search if 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. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all function-like macros that are alone +# on a line, have an all uppercase name, and do not end with a semicolon. Such +# function macros are typically used for boiler-plate code, and 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 = YES + +# 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 = NO + +# 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 write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need 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 = FreeSans.ttf + +# 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 output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +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 +# 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 = NO + +# 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 = NO + +# 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 png, jpg, or gif. +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# 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 diff --git a/Makefile b/Makefile index 0c8cbf9..efe86ac 100644 --- a/Makefile +++ b/Makefile @@ -91,7 +91,7 @@ PROGPORT = /dev/arduino #PROGBAUD = 19200 # atmega328p, 644p, 1280 PROGBAUD = 57600 -# atmega 2560 +# atmega 2560 #PROGBAUD = 115200 # at least mega2560 needs stk500v2 @@ -178,6 +178,9 @@ config.h: config.h.dist @diff -bBEuF '^. [[:digit:]]. [[:upper:]]' config.h config.h.dist @false +doc: Doxyfile *.c *.h + doxygen $< + %.o: %.c config.h Makefile @echo " CC $@" @$(CC) -c $(CFLAGS) -Wa,-adhlns=$(<:.c=.al) -o $@ $(subst .o,.c,$@) diff --git a/analog.c b/analog.c index ddced7b..7dc0aca 100644 --- a/analog.c +++ b/analog.c @@ -1,10 +1,16 @@ -#include "analog.h" +#include "analog.h" + +/** \file + \brief Analog subsystem +*/ + #include "temp.h" #include /* OR-combined mask of all channels */ #undef DEFINE_TEMP_SENSOR +//! automagically generate analog_mask from DEFINE_TEMP_SENSOR entries in config.h #define DEFINE_TEMP_SENSOR(name, type, pin) | (((type == TT_THERMISTOR) || (type == TT_AD595)) ? 1 << (pin) : 0) static const uint8_t analog_mask = 0 #include "config.h" @@ -14,6 +20,7 @@ static const uint8_t analog_mask = 0 static uint8_t adc_counter; static volatile uint16_t adc_result[8] __attribute__ ((__section__ (".bss"))); +//! Configure all registers, start interrupt loop void analog_init() { if (analog_mask > 0) { #ifdef PRR @@ -36,6 +43,10 @@ void analog_init() { } /* analog_mask > 0 */ } +/*! Analog Interrupt + + This is where we read our analog value and store it in an array for later retrieval +*/ ISR(ADC_vect, ISR_NOBLOCK) { // emulate free-running mode but be more deterministic about exactly which result we have, since this project has long-running interrupts if (analog_mask > 0) { @@ -52,6 +63,10 @@ ISR(ADC_vect, ISR_NOBLOCK) { } } +/*! Read analog value from saved result array + \param channel Channel to be read + \return analog reading, 10-bit right aligned +*/ uint16_t analog_read(uint8_t channel) { if (analog_mask > 0) { uint16_t r; diff --git a/analog.h b/analog.h index 21ab830..ba7396e 100644 --- a/analog.h +++ b/analog.h @@ -26,6 +26,7 @@ #endif void analog_init(void); + uint16_t analog_read(uint8_t channel); #endif /* _ANALOG_H */ diff --git a/arduino.h b/arduino.h index fa90d9f..d63fb55 100644 --- a/arduino.h +++ b/arduino.h @@ -1,3 +1,10 @@ +/*! + \file + \brief pin definitions and I/O macros + + why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html +*/ + #ifndef _ARDUINO_H #define _ARDUINO_H @@ -8,7 +15,8 @@ */ #ifndef MASK -#define MASK(PIN) (1 << PIN) +/// MASKING- returns \f$2^PIN\f$ + #define MASK(PIN) (1 << PIN) #endif /* @@ -17,26 +25,40 @@ now you can simply SET_OUTPUT(STEP); WRITE(STEP, 1); WRITE(STEP, 0); */ +/// Read a pin #define _READ(IO) (IO ## _RPORT & MASK(IO ## _PIN)) +/// write to a pin #define _WRITE(IO, v) do { if (v) { IO ## _WPORT |= MASK(IO ## _PIN); } else { IO ## _WPORT &= ~MASK(IO ## _PIN); }; } while (0) +/// toggle a pin #define _TOGGLE(IO) do { IO ## _RPORT = MASK(IO ## _PIN); } while (0) +/// set pin as input #define _SET_INPUT(IO) do { IO ## _DDR &= ~MASK(IO ## _PIN); } while (0) +/// set pin as output #define _SET_OUTPUT(IO) do { IO ## _DDR |= MASK(IO ## _PIN); } while (0) +/// check if pin is an input #define _GET_INPUT(IO) ((IO ## _DDR & MASK(IO ## _PIN)) == 0) +/// check if pin is an output #define _GET_OUTPUT(IO) ((IO ## _DDR & MASK(IO ## _PIN)) != 0) -// why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html +// why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html +/// Read a pin wrapper #define READ(IO) _READ(IO) +/// Write to a pin wrapper #define WRITE(IO, v) _WRITE(IO, v) +/// toggle a pin wrapper #define TOGGLE(IO) _TOGGLE(IO) +/// set pin as input wrapper #define SET_INPUT(IO) _SET_INPUT(IO) +/// set pin as output wrapper #define SET_OUTPUT(IO) _SET_OUTPUT(IO) +/// check if pin is an input wrapper #define GET_INPUT(IO) _GET_INPUT(IO) +/// check if pin is an output wrapper #define GET_OUTPUT(IO) _GET_OUTPUT(IO) /* diff --git a/clock.c b/clock.c index e49ad3b..63a85c8 100644 --- a/clock.c +++ b/clock.c @@ -1,5 +1,9 @@ #include "clock.h" +/** \file + \brief Do stuff periodically +*/ + #include "pinio.h" #include "sersendf.h" #include "dda_queue.h" @@ -10,21 +14,25 @@ #include "heater.h" #include "serial.h" +/*! do stuff every 1/4 second + + called from clock_10ms(), do not call directly +*/ void clock_250ms() { if (steptimeout > (30 * 4)) { power_off(); } else if (heaters_all_off()) steptimeout++; - + ifclock(CLOCK_FLAG_1S) { if (debug_flags & DEBUG_POSITION) { // current position sersendf_P(PSTR("Pos: %ld,%ld,%ld,%ld,%lu\n"), current_position.X, current_position.Y, current_position.Z, current_position.E, current_position.F); - + // target position sersendf_P(PSTR("Dst: %ld,%ld,%ld,%ld,%lu\n"), movebuffer[mb_tail].endpoint.X, movebuffer[mb_tail].endpoint.Y, movebuffer[mb_tail].endpoint.Z, movebuffer[mb_tail].endpoint.E, movebuffer[mb_tail].endpoint.F); - + // Queue print_queue(); @@ -40,12 +48,16 @@ void clock_250ms() { #endif } +/*! do stuff every 10 milliseconds + + call from ifclock(CLOCK_FLAG_10MS) in busy loops +*/ void clock_10ms() { // reset watchdog wd_reset(); - + temp_tick(); - + ifclock(CLOCK_FLAG_250MS) { clock_250ms(); } diff --git a/config.gen3.h b/config.gen3.h index d1994a2..7388fcc 100644 --- a/config.gen3.h +++ b/config.gen3.h @@ -1,8 +1,11 @@ /* Notice to developers: this file is intentionally included twice. */ +/** \file + \brief Gen3 Electronics Sample Configuration +*/ /* CONTENTS - + 1. Mechanical/Hardware 2. Acceleration settings 3. Pinouts @@ -30,14 +33,14 @@ #error GEN3 has a 644P/644PA! set your cpu type in Makefile! #endif -/* +/** \def F_CPU CPU clock rate */ #ifndef F_CPU #define F_CPU 16000000L #endif -/* +/** \def HOST This is the motherboard, as opposed to the extruder. See extruder/ directory for GEN3 extruder firmware */ #define HOST @@ -45,17 +48,17 @@ /* Values reflecting the gearing of your machine. All numbers are fixed point integers, so no more than 3 digits to the right of the decimal point, please :-) -*/ -// calculate these values appropriate for your machine -// for threaded rods, this is (steps motor per turn) / (pitch of the thread) -// for belts, this is (steps per motor turn) / (number of gear teeth) / (belt module) -// half-stepping doubles the number, quarter stepping requires * 4, etc. + calculate these values appropriate for your machine + for threaded rods, this is (steps motor per turn) / (pitch of the thread) + for belts, this is (steps per motor turn) / (number of gear teeth) / (belt module) + half-stepping doubles the number, quarter stepping requires * 4, etc. +*/ #define STEPS_PER_MM_X 320.000 #define STEPS_PER_MM_Y 320.000 #define STEPS_PER_MM_Z 200.000 -// http://blog.arcol.hu/?p=157 may help with this next one +/// http://blog.arcol.hu/?p=157 may help with this one #define STEPS_PER_MM_E 320.000 @@ -66,25 +69,25 @@ Units are mm/min */ -// used for G0 rapid moves and as a cap for all other feedrates +/// used for G0 rapid moves and as a cap for all other feedrates #define MAXIMUM_FEEDRATE_X 200 #define MAXIMUM_FEEDRATE_Y 200 #define MAXIMUM_FEEDRATE_Z 100 #define MAXIMUM_FEEDRATE_E 200 -// used when searching endstops and as default feedrate +/// used when searching endstops and as default feedrate #define SEARCH_FEEDRATE_X 50 #define SEARCH_FEEDRATE_Y 50 #define SEARCH_FEEDRATE_Z 50 #define SEARCH_FEEDRATE_E 50 -// this is how many steps to suck back the filament by when we stop. set to zero to disable +/// this is how many steps to suck back the filament by when we stop. set to zero to disable #define E_STARTSTOP_STEPS 20 -/* -Soft axis limits, in mm -undefine if you don't want to use them +/** + Soft axis limits, in mm + undefine if you don't want to use them */ #define X_MIN 0.0 @@ -108,25 +111,25 @@ undefine if you don't want to use them * * \***************************************************************************/ -/* +/** \def ACCELERATION_REPRAP acceleration, reprap style. Each movement starts at the speed of the previous command and accelerates or decelerates linearly to reach target speed at the end of the movement. */ // #define ACCELERATION_REPRAP -/* +/** \def ACCELERATION_RAMPING acceleration and deceleration ramping. Each movement starts at (almost) no speed, linearly accelerates to target speed and decelerates just in time to smoothly stop at the target. alternative to ACCELERATION_REPRAP */ #define ACCELERATION_RAMPING -// how fast to accelerate when using ACCELERATION_RAMPING -// smaller values give quicker acceleration -// valid range = 1 to 8,000,000; 500,000 is a good starting point +/// how fast to accelerate when using ACCELERATION_RAMPING +/// smaller values give quicker acceleration +/// valid range = 1 to 8,000,000; 500,000 is a good starting point #define ACCELERATION_STEEPNESS 500000 -/* +/** \def ACCELERATION_TEMPORAL temporal step algorithm This algorithm causes the timer to fire when any axis needs to step, instead of synchronising to the axis with the most steps ala bresenham. @@ -136,7 +139,7 @@ undefine if you don't want to use them The Bresenham algorithm is great for drawing lines, but not so good for steppers - In the case where X steps 3 times to Y's two, Y experiences massive jitter as it steps in sync with X every 2 out of 3 X steps. This is a worst-case, but the problem exists for most non-45/90 degree moves. At higher speeds, the jitter /will/ cause position loss and unnecessary vibration. This algorithm instead calculates when a step occurs on any axis, and sets the timer to that value. - // TODO: figure out how to add acceleration to this algorithm + \todo figure out how to add acceleration to this algorithm */ // #define ACCELERATION_TEMPORAL @@ -148,7 +151,7 @@ undefine if you don't want to use them * * \***************************************************************************/ -/* +/** Machine Pin Definitions - make sure to avoid duplicate usage of a pin - comment out pins not in use, as this drops the corresponding code and makes operations faster @@ -156,13 +159,13 @@ undefine if you don't want to use them #include "arduino.h" -/* +/** \def USE_INTERNAL_PULLUPS internal pullup resistors the ATmega has internal pullup resistors on it's input pins which are counterproductive with the commonly used eletronic endstops, so they should be switched off. For other endstops, like mechanical ones, you may want to uncomment this. */ //#define USE_INTERNAL_PULLUPS -/* +/** this is the official gen3 reprap motherboard pinout */ #define TX_ENABLE_PIN DIO12 @@ -214,15 +217,17 @@ undefine if you don't want to use them * * \***************************************************************************/ -/* +/** TEMP_HYSTERESIS: actual temperature must be target +/- hysteresis before target temperature can be achieved. NOTE: format is 30.2 fixed point, so value of 20 actually means +/- 5 degrees +*/ +#define TEMP_HYSTERESIS 20 +/** TEMP_RESIDENCY_TIME: actual temperature must be close to target for this long before target is achieved temperature is "achieved" for purposes of M109 and friends when actual temperature is within [hysteresis] of target for [residency] seconds */ -#define TEMP_HYSTERESIS 20 #define TEMP_RESIDENCY_TIME 60 // which temperature sensors are you using? (intercom is the gen3-style separate extruder board) @@ -259,15 +264,17 @@ DEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, 0) * * \***************************************************************************/ -// check if heater responds to changes in target temperature, disable and spit errors if not -// largely untested, please comment in forum if this works, or doesn't work for you! +/** \def HEATER_SANITY_CHECK + check if heater responds to changes in target temperature, disable and spit errors if not + largely untested, please comment in forum if this works, or doesn't work for you! +*/ // #define HEATER_SANITY_CHECK /***************************************************************************\ * * * Define your heaters here * * * -* WARNING: For GEN3, ONLY DEFINE HEATERS CONNECTED TO YOUR MOTHERBOARD HERE * +* \WARNING For GEN3, ONLY DEFINE HEATERS CONNECTED TO YOUR MOTHERBOARD HERE * * Heaters connected to your extruder controller belong in extruder/config.h * * * * If your heater isn't on a PWM-able pin, set heater_pwm to zero and we'll * @@ -296,11 +303,15 @@ DEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, 0) // DEFINE_HEATER(chamber, PORTD, PIND7, OCR2A) // DEFINE_HEATER(motor, PORTD, PIND6, OCR2B) -// and now because the c preprocessor isn't as smart as it could be, -// uncomment the ones you've listed above and comment the rest. -// NOTE: these are used to enable various capability-specific chunks of code, you do NOT need to create new entries unless you are adding new capabilities elsewhere in the code! -// so if you list a bed above, uncomment HEATER_BED, but if you list a chamber you do NOT need to create HEATED_CHAMBER -// I have searched high and low for a way to make the preprocessor do this for us, but so far I have not found a way. +/** \def HEATER_EXTRUDER + \def HEATER_BED + \def HEATER_FAN + and now because the c preprocessor isn't as smart as it could be, + uncomment the ones you've listed above and comment the rest. + \NOTE these are used to enable various capability-specific chunks of code, you do NOT need to create new entries unless you are adding new capabilities elsewhere in the code! + so if you list a bed above, uncomment HEATER_BED, but if you list a chamber you do NOT need to create HEATED_CHAMBER + I have searched high and low for a way to make the preprocessor do this for us, but so far I have not found a way. +*/ // #define HEATER_EXTRUDER HEATER_extruder // #define HEATER_BED HEATER_bed @@ -314,7 +325,7 @@ DEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, 0) * * \***************************************************************************/ -/* +/** \def REPRAP_HOST_COMPATIBILITY RepRap Host changes it's communications protocol from time to time and intentionally avoids backwards compatibility. Set this to the date the source code of your Host was fetched from RepRap's repository, which is likely also the build date. See the discussion on the reprap-dev mailing list from 11 Oct. 2010. @@ -324,12 +335,12 @@ DEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, 0) #define REPRAP_HOST_COMPATIBILITY 20100806 // #define REPRAP_HOST_COMPATIBILITY -/* +/** Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600. */ #define BAUD 115200 -/* +/** \def XONXOFF Xon/Xoff flow control. Redundant when using RepRap Host for sending GCode, but mandatory when sending GCode files with a plain terminal emulator, like GtkTerm (Linux), CoolTerm (Mac) or HyperTerminal (Windows). Can also be set in Makefile @@ -344,7 +355,7 @@ DEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, 0) * * \***************************************************************************/ -/* +/** \def DEBUG DEBUG enables /heaps/ of extra output, and some extra M-codes. WARNING: this WILL break most host-side talkers that expect particular responses from firmware such as reprap host and replicatorG @@ -352,12 +363,14 @@ DEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, 0) */ // #define DEBUG -/* +/** \def BANG_BANG BANG_BANG drops PID loop from heater control, reduces code size significantly (1300 bytes!) may allow DEBUG on '168 +*//** \def BANG_BANG_ON BANG_BANG_ON PWM value for 'on' +*//** \def BANG_BANG_OFF BANG_BANG_OFF PWM value for 'off' */ @@ -365,44 +378,44 @@ DEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, 0) // #define BANG_BANG_ON 200 // #define BANG_BANG_OFF 45 -/* +/** move buffer size, in number of moves note that each move takes a fair chunk of ram (69 bytes as of this writing) so don't make the buffer too big - a bigger serial readbuffer may help more than increasing this unless your gcodes are more than 70 characters long on average. however, a larger movebuffer will probably help with lots of short consecutive moves, as each move takes a bunch of math (hence time) to set up so a longer buffer allows more of the math to be done during preceding longer moves */ #define MOVEBUFFER_SIZE 8 -/* +/** \def DC_EXTRUDER DC extruder If you have a DC motor extruder, configure it as a "heater" above and define this value as the index or name. You probably also want to comment out E_STEP_PIN and E_DIR_PIN in the Pinouts section above */ // #define DC_EXTRUDER HEATER_motor // #define DC_EXTRUDER_PWM 180 -/* +/** \def USE_WATCHDOG Teacup implements a watchdog, which has to be reset every 250ms or it will reboot the controller. As rebooting (and letting the GCode sending application trying to continue the build with a then different Home point) is probably even worse than just hanging, and there is no better restore code in place, this is disabled for now. */ // #define USE_WATCHDOG -/* +/** analog subsystem stuff REFERENCE - which analog reference to use. see analog.h for choices */ #define REFERENCE REFERENCE_AVCC -/* +/** \def STEP_INTERRUPT_INTERRUPTIBLE this option makes the step interrupt interruptible (nested). this should help immensely with dropped serial characters, but may also make debugging infuriating due to the complexities arising from nested interrupts */ #define STEP_INTERRUPT_INTERRUPTIBLE 1 -/* +/** temperature history count. This is how many temperature readings to keep in order to calculate derivative in PID loop higher values make PID derivative term more stable at the expense of reaction time */ #define TH_COUNT 8 -// this is the scaling of internally stored PID values. 1024L is a good value +/// this is the scaling of internally stored PID values. 1024L is a good value #define PID_SCALE 1024L diff --git a/config.gen6.h b/config.gen6.h index b32c5fe..c7b062f 100644 --- a/config.gen6.h +++ b/config.gen6.h @@ -1,13 +1,13 @@ /* Notice to developers: this file is intentionally included twice. */ -/* - Sample configuration file for the GEN6-Board sold by Camiel Gubbels. +/** \file + \brief Sample configuration file for the GEN6-Board sold by Camiel Gubbels. http://www.reprap.org/wiki/Generation_6_Electronics */ /* CONTENTS - + 1. Mechanical/Hardware 2. Acceleration settings 3. Pinouts @@ -33,14 +33,14 @@ #error GEN6 has a 644P! set your cpu type in Makefile! #endif -/* +/** \def F_CPU CPU clock rate */ #ifndef F_CPU #define F_CPU 16000000L #endif -/* +/** \def HOST This is the motherboard, as opposed to the extruder. See extruder/ directory for GEN3 extruder firmware */ #define HOST @@ -58,7 +58,7 @@ #define STEPS_PER_MM_Y (320.000*8) #define STEPS_PER_MM_Z (200.000*8) -// http://blog.arcol.hu/?p=157 may help with this next one +/// http://blog.arcol.hu/?p=157 may help with this one #define STEPS_PER_MM_E (320.000*8) @@ -69,25 +69,25 @@ Units are mm/min */ -// used for G0 rapid moves and as a cap for all other feedrates +/// used for G0 rapid moves and as a cap for all other feedrates #define MAXIMUM_FEEDRATE_X 200 #define MAXIMUM_FEEDRATE_Y 200 #define MAXIMUM_FEEDRATE_Z 100 #define MAXIMUM_FEEDRATE_E 200 -// used when searching endstops and as default feedrate +/// used when searching endstops and as default feedrate #define SEARCH_FEEDRATE_X 50 #define SEARCH_FEEDRATE_Y 50 #define SEARCH_FEEDRATE_Z 50 #define SEARCH_FEEDRATE_E 50 -// this is how many steps to suck back the filament by when we stop. set to zero to disable +/// this is how many steps to suck back the filament by when we stop. set to zero to disable #define E_STARTSTOP_STEPS 20 -/* -Soft axis limits, in mm -undefine if you don't want to use them +/** + Soft axis limits, in mm + undefine if you don't want to use them */ #define X_MIN 0.0 @@ -111,24 +111,24 @@ undefine if you don't want to use them * * \***************************************************************************/ -/* +/** \def ACCELERATION_REPRAP acceleration, reprap style. Each movement starts at the speed of the previous command and accelerates or decelerates linearly to reach target speed at the end of the movement. */ // #define ACCELERATION_REPRAP -/* +/** \def ACCELERATION_RAMPING acceleration and deceleration ramping. Each movement starts at (almost) no speed, linearly accelerates to target speed and decelerates just in time to smoothly stop at the target. alternative to ACCELERATION_REPRAP */ #define ACCELERATION_RAMPING -// how fast to accelerate when using ACCELERATION_RAMPING -// smaller values give quicker acceleration -// valid range = 1 to 8,000,000; 500,000 is a good starting point +/// how fast to accelerate when using ACCELERATION_RAMPING +/// smaller values give quicker acceleration +/// valid range = 1 to 8,000,000; 500,000 is a good starting point #define ACCELERATION_STEEPNESS 500000 -/* +/** \def ACCELERATION_TEMPORAL temporal step algorithm This algorithm causes the timer to fire when any axis needs to step, instead of synchronising to the axis with the most steps ala bresenham. @@ -138,7 +138,7 @@ undefine if you don't want to use them The Bresenham algorithm is great for drawing lines, but not so good for steppers - In the case where X steps 3 times to Y's two, Y experiences massive jitter as it steps in sync with X every 2 out of 3 X steps. This is a worst-case, but the problem exists for most non-45/90 degree moves. At higher speeds, the jitter /will/ cause position loss and unnecessary vibration. This algorithm instead calculates when a step occurs on any axis, and sets the timer to that value. - // TODO: figure out how to add acceleration to this algorithm + \TODO figure out how to add acceleration to this algorithm */ // #define ACCELERATION_TEMPORAL @@ -158,7 +158,7 @@ undefine if you don't want to use them #include "arduino.h" -/* +/** \def USE_INTERNAL_PULLUPS internal pullup resistors the ATmega has internal pullup resistors on it's input pins which are counterproductive with the commonly used eletronic endstops, so they should be switched off. For other endstops, like mechanical ones, you may want to uncomment this. */ @@ -211,18 +211,19 @@ undefine if you don't want to use them * * \***************************************************************************/ -/* +/** TEMP_HYSTERESIS: actual temperature must be target +/- hysteresis before target temperature can be achieved. NOTE: format is 30.2 fixed point, so value of 20 actually means +/- 5 degrees - +*/ +#define TEMP_HYSTERESIS 20 +/** TEMP_RESIDENCY_TIME: actual temperature must be close to target for this long before target is achieved temperature is "achieved" for purposes of M109 and friends when actual temperature is within [hysteresis] of target for [residency] seconds */ -#define TEMP_HYSTERESIS 20 #define TEMP_RESIDENCY_TIME 60 -// which temperature sensors are you using? (intercom is the gen3-style separate extruder board) +/// which temperature sensors are you using? (intercom is the gen3-style separate extruder board) // #define TEMP_MAX6675 #define TEMP_THERMISTOR // #define TEMP_AD595 @@ -257,8 +258,10 @@ DEFINE_TEMP_SENSOR(extruder, TT_THERMISTOR, PINA5) * * \***************************************************************************/ -// check if heater responds to changes in target temperature, disable and spit errors if not -// largely untested, please comment in forum if this works, or doesn't work for you! +/** \def HEATER_SANITY_CHECK + check if heater responds to changes in target temperature, disable and spit errors if not + largely untested, please comment in forum if this works, or doesn't work for you! +*/ // #define HEATER_SANITY_CHECK /***************************************************************************\ @@ -287,11 +290,11 @@ DEFINE_TEMP_SENSOR(extruder, TT_THERMISTOR, PINA5) // name port pin pwm DEFINE_HEATER(extruder, PORTD, PIND6, OCR2B) -// and now because the c preprocessor isn't as smart as it could be, -// uncomment the ones you've listed above and comment the rest. -// NOTE: these are used to enable various capability-specific chunks of code, you do NOT need to create new entries unless you are adding new capabilities elsewhere in the code! -// so if you list a bed above, uncomment HEATER_BED, but if you list a chamber you do NOT need to create HEATED_CHAMBER -// I have searched high and low for a way to make the preprocessor do this for us, but so far I have not found a way. +/// and now because the c preprocessor isn't as smart as it could be, +/// uncomment the ones you've listed above and comment the rest. +/// \NOTE these are used to enable various capability-specific chunks of code, you do NOT need to create new entries unless you are adding new capabilities elsewhere in the code! +/// so if you list a bed above, uncomment HEATER_BED, but if you list a chamber you do NOT need to create HEATED_CHAMBER +/// I have searched high and low for a way to make the preprocessor do this for us, but so far I have not found a way. #define HEATER_EXTRUDER HEATER_extruder // #define HEATER_BED HEATER_bed @@ -305,7 +308,7 @@ DEFINE_HEATER(extruder, PORTD, PIND6, OCR2B) * * \***************************************************************************/ -/* +/** \def REPRAP_HOST_COMPATIBILITY RepRap Host changes it's communications protocol from time to time and intentionally avoids backwards compatibility. Set this to the date the source code of your Host was fetched from RepRap's repository, which is likely also the build date. See the discussion on the reprap-dev mailing list from 11 Oct. 2010. @@ -315,12 +318,12 @@ DEFINE_HEATER(extruder, PORTD, PIND6, OCR2B) #define REPRAP_HOST_COMPATIBILITY 20100806 // #define REPRAP_HOST_COMPATIBILITY -/* +/** Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600. */ #define BAUD 115200 -/* +/** \def XONXOFF Xon/Xoff flow control. Redundant when using RepRap Host for sending GCode, but mandatory when sending GCode files with a plain terminal emulator, like GtkTerm (Linux), CoolTerm (Mac) or HyperTerminal (Windows). Can also be set in Makefile @@ -335,7 +338,7 @@ DEFINE_HEATER(extruder, PORTD, PIND6, OCR2B) * * \***************************************************************************/ -/* +/** \def DEBUG DEBUG enables /heaps/ of extra output, and some extra M-codes. WARNING: this WILL break most host-side talkers that expect particular responses from firmware such as reprap host and replicatorG @@ -343,34 +346,38 @@ DEFINE_HEATER(extruder, PORTD, PIND6, OCR2B) */ // #define DEBUG -/* +/** \def BANG_BANG BANG_BANG drops PID loop from heater control, reduces code size significantly (1300 bytes!) may allow DEBUG on '168 - BANG_BANG_ON - PWM value for 'on' - BANG_BANG_OFF - PWM value for 'off' */ // #define BANG_BANG +/** \def BANG_BANG_ON +BANG_BANG_ON +PWM value for 'on' +*/ // #define BANG_BANG_ON 200 +/** \def BANG_BANG_OFF +BANG_BANG_OFF +PWM value for 'off' +*/ // #define BANG_BANG_OFF 45 -/* +/** move buffer size, in number of moves note that each move takes a fair chunk of ram (69 bytes as of this writing) so don't make the buffer too big - a bigger serial readbuffer may help more than increasing this unless your gcodes are more than 70 characters long on average. however, a larger movebuffer will probably help with lots of short consecutive moves, as each move takes a bunch of math (hence time) to set up so a longer buffer allows more of the math to be done during preceding longer moves */ #define MOVEBUFFER_SIZE 8 -/* +/** \def DC_EXTRUDER DC extruder If you have a DC motor extruder, configure it as a "heater" above and define this value as the index or name. You probably also want to comment out E_STEP_PIN and E_DIR_PIN in the Pinouts section above */ // #define DC_EXTRUDER HEATER_motor // #define DC_EXTRUDER_PWM 180 -/* +/** \def USE_WATCHDOG Teacup implements a watchdog, which has to be reset every 250ms or it will reboot the controller. As rebooting (and letting the GCode sending application trying to continue the build with a then different Home point) is probably even worse than just hanging, and there is no better restore code in place, this is disabled for now. */ // #define USE_WATCHDOG @@ -381,7 +388,7 @@ DEFINE_HEATER(extruder, PORTD, PIND6, OCR2B) */ #define REFERENCE REFERENCE_AVCC -/* +/** \def STEP_INTERRUPT_INTERRUPTIBLE this option makes the step interrupt interruptible (nested). this should help immensely with dropped serial characters, but may also make debugging infuriating due to the complexities arising from nested interrupts */ diff --git a/config.h.dist b/config.h.dist index 4a7d91a..2ba6eb3 100644 --- a/config.h.dist +++ b/config.h.dist @@ -1,8 +1,14 @@ /* Notice to developers: this file is intentionally included twice. */ +/** \file + \brief Sample Configuration + + \note this sample uses AIO0 for both X_STEP and thermistor, and is intended to be an example only! +*/ + /* CONTENTS - + 1. Mechanical/Hardware 2. Acceleration settings 3. Pinouts @@ -25,14 +31,14 @@ If you want to port this to a new chip, start off with arduino.h and see how you go. */ -/* +/** \def F_CPU CPU clock rate */ #ifndef F_CPU #define F_CPU 16000000L #endif -/* +/** \def HOST This is the motherboard, as opposed to the extruder. See extruder/ directory for GEN3 extruder firmware */ #define HOST @@ -42,16 +48,16 @@ All numbers are fixed point integers, so no more than 3 digits to the right of the decimal point, please :-) */ -// calculate these values appropriate for your machine -// for threaded rods, this is (steps motor per turn) / (pitch of the thread) -// for belts, this is (steps per motor turn) / (number of gear teeth) / (belt module) -// half-stepping doubles the number, quarter stepping requires * 4, etc. -// valid range = 0.020 to 4194.303 +/// calculate these values appropriate for your machine +/// for threaded rods, this is (steps motor per turn) / (pitch of the thread) +/// for belts, this is (steps per motor turn) / (number of gear teeth) / (belt module) +/// half-stepping doubles the number, quarter stepping requires * 4, etc. +/// valid range = 0.020 to 4194.303 #define STEPS_PER_MM_X 320.000 #define STEPS_PER_MM_Y 320.000 #define STEPS_PER_MM_Z 320.000 -// http://blog.arcol.hu/?p=157 may help with this next one +/// http://blog.arcol.hu/?p=157 may help with this one #define STEPS_PER_MM_E 320.000 @@ -62,24 +68,24 @@ Units are mm/min */ -// used for G0 rapid moves and as a cap for all other feedrates +/// used for G0 rapid moves and as a cap for all other feedrates #define MAXIMUM_FEEDRATE_X 200 #define MAXIMUM_FEEDRATE_Y 200 #define MAXIMUM_FEEDRATE_Z 100 #define MAXIMUM_FEEDRATE_E 200 -// used when searching endstops and as default feedrate +/// used when searching endstops and as default feedrate #define SEARCH_FEEDRATE_X 50 #define SEARCH_FEEDRATE_Y 50 #define SEARCH_FEEDRATE_Z 50 #define SEARCH_FEEDRATE_E 50 -// this is how many steps to suck back the filament by when we stop. set to zero to disable +/// this is how many steps to suck back the filament by when we stop. set to zero to disable #define E_STARTSTOP_STEPS 20 -/* -Soft axis limits, in mm -undefine if you don't want to use them +/** + Soft axis limits, in mm + undefine if you don't want to use them */ #define X_MIN 0.0 @@ -103,24 +109,24 @@ undefine if you don't want to use them * * \***************************************************************************/ -/* +/** \def ACCELERATION_REPRAP acceleration, reprap style. Each movement starts at the speed of the previous command and accelerates or decelerates linearly to reach target speed at the end of the movement. */ // #define ACCELERATION_REPRAP -/* +/** \def ACCELERATION_RAMPING acceleration and deceleration ramping. Each movement starts at (almost) no speed, linearly accelerates to target speed and decelerates just in time to smoothly stop at the target. alternative to ACCELERATION_REPRAP */ -// #define ACCELERATION_RAMPING +#define ACCELERATION_RAMPING -// how fast to accelerate when using ACCELERATION_RAMPING -// smaller values give quicker acceleration -// valid range = 1 to 8,000,000; 500,000 is a good starting point +/// how fast to accelerate when using ACCELERATION_RAMPING +/// smaller values give quicker acceleration +/// valid range = 1 to 8,000,000; 500,000 is a good starting point #define ACCELERATION_STEEPNESS 500000 -/* +/** \def ACCELERATION_TEMPORAL temporal step algorithm This algorithm causes the timer to fire when any axis needs to step, instead of synchronising to the axis with the most steps ala bresenham. @@ -150,7 +156,7 @@ undefine if you don't want to use them #include "arduino.h" -/* +/** \def USE_INTERNAL_PULLUPS internal pullup resistors the ATmega has internal pullup resistors on it's input pins which are counterproductive with the commonly used eletronic endstops, so they should be switched off. For other endstops, like mechanical ones, you may want to uncomment this. */ @@ -207,18 +213,19 @@ undefine if you don't want to use them * * \***************************************************************************/ -/* +/** TEMP_HYSTERESIS: actual temperature must be target +/- hysteresis before target temperature can be achieved. NOTE: format is 30.2 fixed point, so value of 20 actually means +/- 5 degrees - +*/ +#define TEMP_HYSTERESIS 20 +/** TEMP_RESIDENCY_TIME: actual temperature must be close to target for this long before target is achieved temperature is "achieved" for purposes of M109 and friends when actual temperature is within [hysteresis] of target for [residency] seconds */ -#define TEMP_HYSTERESIS 20 #define TEMP_RESIDENCY_TIME 60 -// which temperature sensors are you using? (intercom is the gen3-style separate extruder board) +/// which temperature sensors are you using? (intercom is the gen3-style separate extruder board) // #define TEMP_MAX6675 #define TEMP_THERMISTOR // #define TEMP_AD595 @@ -255,8 +262,10 @@ DEFINE_TEMP_SENSOR(extruder, TT_THERMISTOR, 0) * * \***************************************************************************/ -// check if heater responds to changes in target temperature, disable and spit errors if not -// largely untested, please comment in forum if this works, or doesn't work for you! +/** \def HEATER_SANITY_CHECK + check if heater responds to changes in target temperature, disable and spit errors if not + largely untested, please comment in forum if this works, or doesn't work for you! +*/ // #define HEATER_SANITY_CHECK /***************************************************************************\ @@ -289,11 +298,11 @@ DEFINE_HEATER(bed, PORTB, PINB4, OCR0B) // DEFINE_HEATER(chamber, PORTD, PIND7, OCR2A) // DEFINE_HEATER(motor, PORTD, PIND6, OCR2B) -// and now because the c preprocessor isn't as smart as it could be, -// uncomment the ones you've listed above and comment the rest. -// NOTE: these are used to enable various capability-specific chunks of code, you do NOT need to create new entries unless you are adding new capabilities elsewhere in the code! -// so if you list a bed above, uncomment HEATER_BED, but if you list a chamber you do NOT need to create HEATED_CHAMBER -// I have searched high and low for a way to make the preprocessor do this for us, but so far I have not found a way. +/// and now because the c preprocessor isn't as smart as it could be, +/// uncomment the ones you've listed above and comment the rest. +/// NOTE: these are used to enable various capability-specific chunks of code, you do NOT need to create new entries unless you are adding new capabilities elsewhere in the code! +/// so if you list a bed above, uncomment HEATER_BED, but if you list a chamber you do NOT need to create HEATED_CHAMBER +/// I have searched high and low for a way to make the preprocessor do this for us, but so far I have not found a way. #define HEATER_EXTRUDER HEATER_extruder #define HEATER_BED HEATER_bed @@ -307,7 +316,7 @@ DEFINE_HEATER(bed, PORTB, PINB4, OCR0B) * * \***************************************************************************/ -/* +/** \def REPRAP_HOST_COMPATIBILITY RepRap Host changes it's communications protocol from time to time and intentionally avoids backwards compatibility. Set this to the date the source code of your Host was fetched from RepRap's repository, which is likely also the build date. See the discussion on the reprap-dev mailing list from 11 Oct. 2010. @@ -317,12 +326,12 @@ DEFINE_HEATER(bed, PORTB, PINB4, OCR0B) #define REPRAP_HOST_COMPATIBILITY 20100806 // #define REPRAP_HOST_COMPATIBILITY -/* +/** Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600. */ #define BAUD 115200 -/* +/** \def XONXOFF Xon/Xoff flow control. Redundant when using RepRap Host for sending GCode, but mandatory when sending GCode files with a plain terminal emulator, like GtkTerm (Linux), CoolTerm (Mac) or HyperTerminal (Windows). Can also be set in Makefile @@ -337,7 +346,7 @@ DEFINE_HEATER(bed, PORTB, PINB4, OCR0B) * * \***************************************************************************/ -/* +/** \def DEBUG DEBUG enables /heaps/ of extra output, and some extra M-codes. WARNING: this WILL break most host-side talkers that expect particular responses from firmware such as reprap host and replicatorG @@ -345,57 +354,62 @@ DEFINE_HEATER(bed, PORTB, PINB4, OCR0B) */ // #define DEBUG -/* - BANG_BANG - drops PID loop from heater control, reduces code size significantly (1300 bytes!) - may allow DEBUG on '168 - BANG_BANG_ON - PWM value for 'on' - BANG_BANG_OFF - PWM value for 'off' +/** \def BANG_BANG +BANG_BANG +drops PID loop from heater control, reduces code size significantly (1300 bytes!) +may allow DEBUG on '168 */ // #define BANG_BANG +/** \def BANG_BANG_ON +BANG_BANG_ON +PWM value for 'on' +*/ // #define BANG_BANG_ON 200 +/** \def BANG_BANG_OFF +BANG_BANG_OFF +PWM value for 'off' +*/ // #define BANG_BANG_OFF 45 -/* +/** move buffer size, in number of moves note that each move takes a fair chunk of ram (69 bytes as of this writing) so don't make the buffer too big - a bigger serial readbuffer may help more than increasing this unless your gcodes are more than 70 characters long on average. however, a larger movebuffer will probably help with lots of short consecutive moves, as each move takes a bunch of math (hence time) to set up so a longer buffer allows more of the math to be done during preceding longer moves */ #define MOVEBUFFER_SIZE 8 -/* +/** \def DC_EXTRUDER DC extruder If you have a DC motor extruder, configure it as a "heater" above and define this value as the index or name. You probably also want to comment out E_STEP_PIN and E_DIR_PIN in the Pinouts section above */ // #define DC_EXTRUDER HEATER_motor // #define DC_EXTRUDER_PWM 180 -/* +/** \def USE_WATCHDOG Teacup implements a watchdog, which has to be reset every 250ms or it will reboot the controller. As rebooting (and letting the GCode sending application trying to continue the build with a then different Home point) is probably even worse than just hanging, and there is no better restore code in place, this is disabled for now. */ // #define USE_WATCHDOG -/* +/** analog subsystem stuff REFERENCE - which analog reference to use. see analog.h for choices */ #define REFERENCE REFERENCE_AVCC -/* +/** \def STEP_INTERRUPT_INTERRUPTIBLE this option makes the step interrupt interruptible (nested). this should help immensely with dropped serial characters, but may also make debugging infuriating due to the complexities arising from nested interrupts + \note disable this option if you're using a '168 or for some reason your ram usage is above 90%. This option hugely increases likelihood of stack smashing. */ #define STEP_INTERRUPT_INTERRUPTIBLE 1 -/* +/** temperature history count. This is how many temperature readings to keep in order to calculate derivative in PID loop higher values make PID derivative term more stable at the expense of reaction time */ #define TH_COUNT 8 -// this is the scaling of internally stored PID values. 1024L is a good value +/// this is the scaling of internally stored PID values. 1024L is a good value #define PID_SCALE 1024L diff --git a/config.ramps.h b/config.ramps.h index f07a53d..5fbe6ad 100644 --- a/config.ramps.h +++ b/config.ramps.h @@ -1,8 +1,13 @@ /* Notice to developers: this file is intentionally included twice. */ +/** \file + \brief RAMPS Sample Configuration + http://reprap.org/wiki/Arduino_Mega_Pololu_Shield +*/ + /* CONTENTS - + 1. Mechanical/Hardware 2. Acceleration settings 3. Pinouts @@ -28,14 +33,14 @@ #error RAMPS has 1280/2560! set your cpu type in Makefile! #endif -/* +/** \def F_CPU CPU clock rate */ #ifndef F_CPU #define F_CPU 16000000L #endif -/* +/** \def HOST This is the motherboard, as opposed to the extruder. See extruder/ directory for GEN3 extruder firmware */ #define HOST @@ -58,7 +63,7 @@ #define STEPS_PER_MM_Y (5.023*MICROSTEPPING_Y) #define STEPS_PER_MM_Z (416.699*MICROSTEPPING_Z) -// http://blog.arcol.hu/?p=157 may help with this next one +/// http://blog.arcol.hu/?p=157 may help with this one #define STEPS_PER_MM_E (2.759*MICROSTEPPING_E) @@ -69,25 +74,25 @@ Units are mm/min */ -// used for G0 rapid moves and as a cap for all other feedrates +/// used for G0 rapid moves and as a cap for all other feedrates #define MAXIMUM_FEEDRATE_X 200 #define MAXIMUM_FEEDRATE_Y 200 #define MAXIMUM_FEEDRATE_Z 100 #define MAXIMUM_FEEDRATE_E 600 -// used when searching endstops and as default feedrate +/// used when searching endstops and as default feedrate #define SEARCH_FEEDRATE_X 50 #define SEARCH_FEEDRATE_Y 50 #define SEARCH_FEEDRATE_Z 1 #define SEARCH_FEEDRATE_E 50 -// this is how many steps to suck back the filament by when we stop. set to zero to disable +/// this is how many steps to suck back the filament by when we stop. set to zero to disable #define E_STARTSTOP_STEPS 0 -/* -Soft axis limits, in mm -undefine if you don't want to use them +/** + Soft axis limits, in mm + undefine if you don't want to use them */ #define X_MIN 0.0 @@ -111,24 +116,24 @@ undefine if you don't want to use them * * \***************************************************************************/ -/* +/** \def ACCELERATION_REPRAP acceleration, reprap style. Each movement starts at the speed of the previous command and accelerates or decelerates linearly to reach target speed at the end of the movement. */ -#define ACCELERATION_REPRAP +// #define ACCELERATION_REPRAP -/* +/** \def ACCELERATION_RAMPING acceleration and deceleration ramping. Each movement starts at (almost) no speed, linearly accelerates to target speed and decelerates just in time to smoothly stop at the target. alternative to ACCELERATION_REPRAP */ -// #define ACCELERATION_RAMPING +#define ACCELERATION_RAMPING -// how fast to accelerate when using ACCELERATION_RAMPING -// smaller values give quicker acceleration -// valid range = 1 to 8,000,000; 500,000 is a good starting point +/// how fast to accelerate when using ACCELERATION_RAMPING +/// smaller values give quicker acceleration +/// valid range = 1 to 8,000,000; 500,000 is a good starting point #define ACCELERATION_STEEPNESS 500000 -/* +/** \def ACCELERATION_TEMPORAL temporal step algorithm This algorithm causes the timer to fire when any axis needs to step, instead of synchronising to the axis with the most steps ala bresenham. @@ -158,7 +163,7 @@ undefine if you don't want to use them #include "arduino.h" -/* +/** \def USE_INTERNAL_PULLUPS internal pullup resistors the ATmega has internal pullup resistors on it's input pins which are counterproductive with the commonly used eletronic endstops, so they should be switched off. For other endstops, like mechanical ones, you may want to uncomment this. */ @@ -217,18 +222,19 @@ undefine if you don't want to use them * * \***************************************************************************/ -/* +/** TEMP_HYSTERESIS: actual temperature must be target +/- hysteresis before target temperature can be achieved. NOTE: format is 30.2 fixed point, so value of 20 actually means +/- 5 degrees - - TEMP_RESIDENCY_TIME: actual temperature must be close to target for this long before target is achieved - - temperature is "achieved" for purposes of M109 and friends when actual temperature is within [hysteresis] of target for [residency] seconds */ #define TEMP_HYSTERESIS 20 +/** +TEMP_RESIDENCY_TIME: actual temperature must be close to target for this long before target is achieved + +temperature is "achieved" for purposes of M109 and friends when actual temperature is within [hysteresis] of target for [residency] seconds +*/ #define TEMP_RESIDENCY_TIME 60 -// which temperature sensors are you using? (intercom is the gen3-style separate extruder board) +/// which temperature sensors are you using? (intercom is the gen3-style separate extruder board) // #define TEMP_MAX6675 #define TEMP_THERMISTOR // #define TEMP_AD595 @@ -262,8 +268,10 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO1_PIN) * * \***************************************************************************/ -// check if heater responds to changes in target temperature, disable and spit errors if not -// largely untested, please comment in forum if this works, or doesn't work for you! +/** \def HEATER_SANITY_CHECK + check if heater responds to changes in target temperature, disable and spit errors if not + largely untested, please comment in forum if this works, or doesn't work for you! +*/ // #define HEATER_SANITY_CHECK /***************************************************************************\ @@ -297,11 +305,11 @@ DEFINE_HEATER(fan, PORTH, PINH6, OCR2B) // DEFINE_HEATER(chamber, PORTD, PIND7, OCR2A) // DEFINE_HEATER(motor, PORTD, PIND6, OCR2B) -// and now because the c preprocessor isn't as smart as it could be, -// uncomment the ones you've listed above and comment the rest. -// NOTE: these are used to enable various capability-specific chunks of code, you do NOT need to create new entries unless you are adding new capabilities elsewhere in the code! -// so if you list a bed above, uncomment HEATER_BED, but if you list a chamber you do NOT need to create HEATED_CHAMBER -// I have searched high and low for a way to make the preprocessor do this for us, but so far I have not found a way. +/// and now because the c preprocessor isn't as smart as it could be, +/// uncomment the ones you've listed above and comment the rest. +/// NOTE: these are used to enable various capability-specific chunks of code, you do NOT need to create new entries unless you are adding new capabilities elsewhere in the code! +/// so if you list a bed above, uncomment HEATER_BED, but if you list a chamber you do NOT need to create HEATED_CHAMBER +/// I have searched high and low for a way to make the preprocessor do this for us, but so far I have not found a way. #define HEATER_EXTRUDER HEATER_extruder #define HEATER_BED HEATER_bed @@ -315,7 +323,7 @@ DEFINE_HEATER(fan, PORTH, PINH6, OCR2B) * * \***************************************************************************/ -/* +/** \def REPRAP_HOST_COMPATIBILITY RepRap Host changes it's communications protocol from time to time and intentionally avoids backwards compatibility. Set this to the date the source code of your Host was fetched from RepRap's repository, which is likely also the build date. See the discussion on the reprap-dev mailing list from 11 Oct. 2010. @@ -325,12 +333,12 @@ DEFINE_HEATER(fan, PORTH, PINH6, OCR2B) #define REPRAP_HOST_COMPATIBILITY 20100806 // #define REPRAP_HOST_COMPATIBILITY -/* +/** Baud rate for the connection to the host. Usually 115200, other common values are 19200, 38400 or 57600. */ #define BAUD 115200 -/* +/** \def XONXOFF Xon/Xoff flow control. Redundant when using RepRap Host for sending GCode, but mandatory when sending GCode files with a plain terminal emulator, like GtkTerm (Linux), CoolTerm (Mac) or HyperTerminal (Windows). Can also be set in Makefile @@ -345,7 +353,7 @@ DEFINE_HEATER(fan, PORTH, PINH6, OCR2B) * * \***************************************************************************/ -/* +/** \def DEBUG DEBUG enables /heaps/ of extra output, and some extra M-codes. WARNING: this WILL break most host-side talkers that expect particular responses from firmware such as reprap host and replicatorG @@ -353,57 +361,61 @@ DEFINE_HEATER(fan, PORTH, PINH6, OCR2B) */ // #define DEBUG -/* - BANG_BANG - drops PID loop from heater control, reduces code size significantly (1300 bytes!) - may allow DEBUG on '168 - BANG_BANG_ON - PWM value for 'on' - BANG_BANG_OFF - PWM value for 'off' +/** \def BANG_BANG +BANG_BANG +drops PID loop from heater control, reduces code size significantly (1300 bytes!) +may allow DEBUG on '168 */ // #define BANG_BANG +/** \def BANG_BANG_ON +BANG_BANG_ON +PWM value for 'on' +*/ // #define BANG_BANG_ON 200 +/** \def BANG_BANG_OFF +BANG_BANG_OFF +PWM value for 'off' +*/ // #define BANG_BANG_OFF 45 -/* +/** move buffer size, in number of moves note that each move takes a fair chunk of ram (69 bytes as of this writing) so don't make the buffer too big - a bigger serial readbuffer may help more than increasing this unless your gcodes are more than 70 characters long on average. however, a larger movebuffer will probably help with lots of short consecutive moves, as each move takes a bunch of math (hence time) to set up so a longer buffer allows more of the math to be done during preceding longer moves */ #define MOVEBUFFER_SIZE 8 -/* +/** \def DC_EXTRUDER DC extruder If you have a DC motor extruder, configure it as a "heater" above and define this value as the index or name. You probably also want to comment out E_STEP_PIN and E_DIR_PIN in the Pinouts section above */ // #define DC_EXTRUDER HEATER_motor // #define DC_EXTRUDER_PWM 180 -/* +/** \def USE_WATCHDOG Teacup implements a watchdog, which has to be reset every 250ms or it will reboot the controller. As rebooting (and letting the GCode sending application trying to continue the build with a then different Home point) is probably even worse than just hanging, and there is no better restore code in place, this is disabled for now. */ // #define USE_WATCHDOG -/* +/** analog subsystem stuff REFERENCE - which analog reference to use. see analog.h for choices */ #define REFERENCE REFERENCE_AVCC -/* +/** this option makes the step interrupt interruptible (nested). this should help immensely with dropped serial characters, but may also make debugging infuriating due to the complexities arising from nested interrupts */ #define STEP_INTERRUPT_INTERRUPTIBLE 1 -/* +/** temperature history count. This is how many temperature readings to keep in order to calculate derivative in PID loop higher values make PID derivative term more stable at the expense of reaction time */ #define TH_COUNT 8 -// this is the scaling of internally stored PID values. 1024L is a good value +/// this is the scaling of internally stored PID values. 1024L is a good value #define PID_SCALE 1024L diff --git a/crc.c b/crc.c index 2a8a10c..faeb5cd 100644 --- a/crc.c +++ b/crc.c @@ -1,7 +1,13 @@ #include "crc.h" +/** \file + \brief crc16 routine +*/ + #include +// avr-libc's _crc16_update is equivalent to the following: +// // uint16_t _crc16_update(uint16_t crc, uint8_t a) { // int i; // crc ^= a; @@ -15,6 +21,13 @@ // return crc; // } +/** block-at-once CRC16 calculator + \param *data data to find crc16 for + \param len length of data + \return uint16 crc16 of passed data + + uses avr-libc's optimised crc16 routine +*/ uint16_t crc_block(void *data, uint16_t len) { uint16_t crc = 0; for (; len; data++, len--) { diff --git a/dda.c b/dda.c index 208977d..4e2a203 100644 --- a/dda.c +++ b/dda.c @@ -1,5 +1,9 @@ #include "dda.h" +/** \file + \brief Digital differential analyser - this is where we figure out which steppers need to move, and when they need to move +*/ + #include #include #include @@ -18,25 +22,30 @@ #include "heater.h" #endif -/* - Used in distance calculation during DDA setup -*/ +// Used in distance calculation during DDA setup +/// micrometers per step X #define UM_PER_STEP_X 1000L / ((uint32_t) STEPS_PER_MM_X) +/// micrometers per step Y #define UM_PER_STEP_Y 1000L / ((uint32_t) STEPS_PER_MM_Y) +/// micrometers per step Z #define UM_PER_STEP_Z 1000L / ((uint32_t) STEPS_PER_MM_Z) +/// micrometers per step E #define UM_PER_STEP_E 1000L / ((uint32_t) STEPS_PER_MM_E) -/* - step timeout -*/ - +/// step timeout uint8_t steptimeout = 0; /* position tracking */ +/// \var startpoint +/// \brief target position of last move in queue TARGET startpoint __attribute__ ((__section__ (".bss"))); + +/// \var current_position +/// \brief actual position of extruder head +/// \todo make current_position = real_position (from endstops) + offset from G28 and friends TARGET current_position __attribute__ ((__section__ (".bss"))); /* @@ -44,6 +53,13 @@ TARGET current_position __attribute__ ((__section__ (".bss"))); */ // courtesy of http://www.flipcode.com/archives/Fast_Approximate_Distance_Functions.shtml +/*! linear approximation 2d distance formula + \param dx distance in X plane + \param dy distance in Y plane + \return 3-part linear approximation of \f$\sqrt{\Delta x^2 + \Delta y^2}\f$ + + see http://www.flipcode.com/archives/Fast_Approximate_Distance_Functions.shtml +*/ uint32_t approx_distance( uint32_t dx, uint32_t dy ) { uint32_t min, max, approx; @@ -66,6 +82,14 @@ uint32_t approx_distance( uint32_t dx, uint32_t dy ) } // courtesy of http://www.oroboro.com/rafael/docserv.php/index/programming/article/distance +/*! linear approximation 3d distance formula + \param dx distance in X plane + \param dy distance in Y plane + \param dz distance in Z plane + \return 3-part linear approximation of \f$\sqrt{\Delta x^2 + \Delta y^2 + \Delta z^2}\f$ + + see http://www.oroboro.com/rafael/docserv.php/index/programming/article/distance +*/ uint32_t approx_distance_3( uint32_t dx, uint32_t dy, uint32_t dz ) { uint32_t min, med, max, approx; @@ -100,6 +124,13 @@ uint32_t approx_distance_3( uint32_t dx, uint32_t dy, uint32_t dz ) return (( approx + 512 ) >> 10 ); } +/*! + integer square root algorithm + \param a find square root of this number + \return sqrt(a - 1) < returnvalue <= sqrt(a) + + see http://www.embedded-systems.com/98/9802fe2.htm +*/ // courtesy of http://www.embedded-systems.com/98/9802fe2.htm uint16_t int_sqrt(uint32_t a) { uint32_t rem = 0; @@ -123,6 +154,10 @@ uint16_t int_sqrt(uint32_t a) { // this is an ultra-crude pseudo-logarithm routine, such that: // 2 ^ msbloc(v) >= v +/*! crude logarithm algorithm + \param v value to find \f$log_2\f$ of + \return floor(log(v) / log(2)) +*/ const uint8_t msbloc (uint32_t v) { uint8_t i; uint32_t c; @@ -134,10 +169,18 @@ const uint8_t msbloc (uint32_t v) { return 0; } -/* - CREATE a dda given current_position and a target, save to passed location so we can write directly into the queue -*/ +/*! CREATE a dda given current_position and a target, save to passed location so we can write directly into the queue + \param *dda pointer to a dda_queue entry to overwrite + \param *target the target position of this move + \ref startpoint the beginning position of this move + + This function does a /lot/ of math. It works out directions for each axis, distance travelled, the time between the first and second step + + It also pre-fills any data that the selected accleration algorithm needs, and can be pre-computed for the whole move. + + This algorithm is probably the main limiting factor to print speed in terms of firmware limitations +*/ void dda_create(DDA *dda, TARGET *target) { uint32_t distance, c_limit, c_limit_calc; @@ -193,13 +236,13 @@ void dda_create(DDA *dda, TARGET *target) { distance = dda->z_delta * UM_PER_STEP_Z; else distance = approx_distance_3(dda->x_delta * UM_PER_STEP_X, dda->y_delta * UM_PER_STEP_Y, dda->z_delta * UM_PER_STEP_Z); - + if (distance < 2) distance = dda->e_delta * UM_PER_STEP_E; - + if (debug_flags & DEBUG_DDA) sersendf_P(PSTR(",ds:%lu"), distance); - + #ifdef ACCELERATION_TEMPORAL // bracket part of this equation in an attempt to avoid overflow: 60 * 16MHz * 5mm is >32 bits uint32_t move_duration = distance * (60 * F_CPU / startpoint.F); @@ -224,7 +267,7 @@ void dda_create(DDA *dda, TARGET *target) { // distance * 2400 .. * F_CPU / 40000 so we can move a distance of up to 1800mm without overflowing uint32_t move_duration = ((distance * 2400) / dda->total_steps) * (F_CPU / 40000); #endif - + // similarly, find out how fast we can run our axes. // do this for each axis individually, as the combined speed of two or more axes can be higher than the capabilities of a single one. c_limit = 0; @@ -340,10 +383,15 @@ void dda_create(DDA *dda, TARGET *target) { startpoint.E = 0; } -/* - Start a prepared DDA -*/ +/*! Start a prepared DDA + \param *dda pointer to entry in dda_queue to start + This function actually begins the move described by the passed DDA entry. + + We set direction and enable outputs, and set the timer for the first step from the precalculated value. + + We also mark this DDA as running, so other parts of the firmware know that something is happening +*/ void dda_start(DDA *dda) { // called from interrupt context: keep it simple! if (dda->nullmove) { @@ -384,10 +432,18 @@ void dda_start(DDA *dda) { } } -/* - STEP -*/ +/*! STEP + \param *dda the current move + This is called from our timer interrupt every time a step needs to occur. + We first work out which axes need to step, and generate step pulses for them + Then we re-enable global interrupts so serial data reception and other important things can occur while we do some math. + Next, we work out how long until our next step using the selected acceleration algorithm and set the timer. + Then we decide if this was the last step for this move, and if so mark this dda as dead so next timer interrupt we can start a new one. + Finally we de-assert any asserted step pins. + + \todo take into account the time that interrupt takes to run +*/ void dda_step(DDA *dda) { // called from interrupt context! keep it as simple as possible uint8_t did_step = 0; @@ -581,7 +637,7 @@ void dda_step(DDA *dda) { dda->c <<= 8; #endif - + if (did_step) { // we stepped, reset timeout steptimeout = 0; @@ -602,9 +658,9 @@ void dda_step(DDA *dda) { // z stepper is only enabled while moving z_disable(); } - + setTimer(dda->c >> 8); - + // turn off step outputs, hopefully they've been on long enough by now to register with the drivers // if not, too bad. or insert a (very!) small delay here, or fire up a spare timer or something. // we also hope that we don't step before the drivers register the low- limit maximum speed if you think this is a problem. diff --git a/dda.h b/dda.h index 83f26cc..0bbc0ca 100644 --- a/dda.h +++ b/dda.h @@ -34,68 +34,79 @@ typedef struct { uint32_t F; } TARGET; -// this is a digital differential analyser data struct +/** + \struct DDA + \brief this is a digital differential analyser data struct + + This struct holds all the details of an individual multi-axis move, including pre-calculated acceleration data. + This struct is filled in by dda_create(), called from enqueue(), called mostly from gcode_process() and from a few other places too (eg \file homing.c) +*/ typedef struct { - // this is where we should finish + /// this is where we should finish TARGET endpoint; union { struct { // status fields - uint8_t nullmove :1; - uint8_t live :1; + uint8_t nullmove :1; ///< bool: no axes move, maybe we wait for temperatures or change speed + uint8_t live :1; ///< bool: this DDA is running and still has steps to do #ifdef ACCELERATION_REPRAP - uint8_t accel :1; + uint8_t accel :1; ///< bool: speed changes during this move, run accel code #endif // wait for temperature to stabilise flag - uint8_t waitfor_temp :1; + uint8_t waitfor_temp :1; ///< bool: wait for temperatures to reach their set values // directions - uint8_t x_direction :1; - uint8_t y_direction :1; - uint8_t z_direction :1; - uint8_t e_direction :1; + uint8_t x_direction :1; ///< direction flag for X axis + uint8_t y_direction :1; ///< direction flag for Y axis + uint8_t z_direction :1; ///< direction flag for Z axis + uint8_t e_direction :1; ///< direction flag for E axis }; - uint8_t allflags; // used for clearing all flags + uint8_t allflags; ///< used for clearing all flags }; // distances - uint32_t x_delta; - uint32_t y_delta; - uint32_t z_delta; - uint32_t e_delta; + uint32_t x_delta; ///< number of steps on X axis + uint32_t y_delta; ///< number of steps on Y axis + uint32_t z_delta; ///< number of steps on Z axis + uint32_t e_delta; ///< number of steps on E axis // bresenham counters - int32_t x_counter; - int32_t y_counter; - int32_t z_counter; - int32_t e_counter; + int32_t x_counter; ///< counter for total_steps vs this axis, used for bresenham calculations. + int32_t y_counter; ///< counter for total_steps vs this axis, used for bresenham calculations. + int32_t z_counter; ///< counter for total_steps vs this axis, used for bresenham calculations. + int32_t e_counter; ///< counter for total_steps vs this axis, used for bresenham calculations. - // total number of steps: set to max(x_delta, y_delta, z_delta, e_delta) + /// total number of steps: set to \f$\max(\Delta x, \Delta y, \Delta z, \Delta e)\f$ uint32_t total_steps; // linear acceleration variables: c and end_c are 24.8 fixed point timer values, n is the tracking variable - uint32_t c; + uint32_t c; ///< time until next step #ifdef ACCELERATION_REPRAP - uint32_t end_c; - int32_t n; + uint32_t end_c; ///< time between 2nd last step and last step + int32_t n; ///< precalculated step time offset variable. At every step we calculate \f$c = c - (2 c / n)\f$; \f$n+=4\f$. See http://www.embedded.com/columns/technicalinsights/56800129?printable=true for full description #endif #ifdef ACCELERATION_RAMPING - // start of down-ramp, intitalized with total_steps / 2 + /// start of down-ramp, intitalized with total_steps / 2 uint32_t ramp_steps; - // counts actual steps done + /// counts actual steps done uint32_t step_no; - // 24.8 fixed point timer value, maximum speed + /// 24.8 fixed point timer value, maximum speed uint32_t c_min; - // tracking variable + /// tracking variable int32_t n; + /// keep track of whether we're ramping up, down, or plateauing ramp_state_t ramp_state; #endif #ifdef ACCELERATION_TEMPORAL + /// time between steps on X axis uint32_t x_step_interval; + /// time between steps on Y axis uint32_t y_step_interval; + /// time between steps on Z axis uint32_t z_step_interval; + /// time between steps on E axis uint32_t e_step_interval; #endif } DDA; @@ -104,14 +115,13 @@ typedef struct { variables */ -// steptimeout is set to zero when we step, and increases over time so we can turn the motors off when they've been idle for a while +/// steptimeout is set to zero when we step, and increases over time so we can turn the motors off when they've been idle for a while extern uint8_t steptimeout; -// startpoint holds the endpoint of the most recently created DDA, so we know where the next one created starts -// could also be called last_endpoint +/// startpoint holds the endpoint of the most recently created DDA, so we know where the next one created starts. could also be called last_endpoint extern TARGET startpoint; -// current_position holds the machine's current position. this is only updated when we step, or when G92 (set home) is received. +/// current_position holds the machine's current position. this is only updated when we step, or when G92 (set home) is received. extern TARGET current_position; /* diff --git a/dda_queue.c b/dda_queue.c index ebd8ad5..5bc87be 100644 --- a/dda_queue.c +++ b/dda_queue.c @@ -1,5 +1,9 @@ #include "dda_queue.h" +/** \file + \brief DDA Queue - manage the move queue +*/ + #include #include @@ -12,14 +16,22 @@ #include "sersendf.h" #include "clock.h" +/// movebuffer head pointer. Points to the last move in the queue. uint8_t mb_head = 0; + +/// movebuffer tail pointer. Points to the currently executing move uint8_t mb_tail = 0; + +/// move buffer. +/// holds move queue DDA movebuffer[MOVEBUFFER_SIZE] __attribute__ ((__section__ (".bss"))); +/// check if the queue is completely full uint8_t queue_full() { return (((mb_tail - mb_head - 1) & (MOVEBUFFER_SIZE - 1)) == 0)?255:0; } +/// check if the queue is completely empty uint8_t queue_empty() { return ((mb_tail == mb_head) && (movebuffer[mb_tail].live == 0))?255:0; } @@ -28,6 +40,7 @@ uint8_t queue_empty() { // This is the one function called by the timer interrupt. // It calls a few other functions, though. // ------------------------------------------------------- +/// Take a step or go to the next move. void queue_step() { // do our next step if (movebuffer[mb_tail].live) { @@ -54,6 +67,8 @@ void queue_step() { next_move(); } +/// add a move to the movebuffer +/// \note this function waits for space to be available if necessary, check queue_full() first if waiting is a problem void enqueue(TARGET *t) { // don't call this function when the queue is full, but just in case, wait for a move to complete and free up the space for the passed target while (queue_full()) @@ -85,7 +100,8 @@ void enqueue(TARGET *t) { next_move(); } -// sometimes called from normal program execution, sometimes from interrupt context +/// go to the next move. +/// be aware that this is sometimes called from interrupt context, sometimes not. void next_move() { if (queue_empty() == 0) { do { @@ -109,10 +125,14 @@ void next_move() { setTimer(0); } +/// DEBUG - print queue. +/// Qt/hs format, t is tail, h is head, s is F/full, E/empty or neither void print_queue() { sersendf_P(PSTR("Q%d/%d%c"), mb_tail, mb_head, (queue_full()?'F':(queue_empty()?'E':' '))); } +/// dump queue for emergency stop. +/// \todo effect on startpoint/current_position is undefined! void queue_flush() { // save interrupt flag uint8_t sreg = SREG; @@ -128,6 +148,7 @@ void queue_flush() { SREG = sreg; } +/// waits for a space in the queue to become available void queue_wait() { for (;queue_empty() == 0;) { ifclock(CLOCK_FLAG_10MS) { diff --git a/delay.c b/delay.c index fb3e2bb..b5840a2 100644 --- a/delay.c +++ b/delay.c @@ -1,8 +1,13 @@ #include "delay.h" +/** \file + \brief Delay routines +*/ + #include "watchdog.h" -// delay( microseconds ) +/// delay microseconds +/// \param delay time to wait in microseconds void delay(uint32_t delay) { wd_reset(); while (delay > 65535) { @@ -14,7 +19,8 @@ void delay(uint32_t delay) { wd_reset(); } -// delay_ms( milliseconds ) +/// delay milliseconds +/// \param delay time to wait in milliseconds void delay_ms(uint32_t delay) { wd_reset(); while (delay > 65) { @@ -26,21 +32,23 @@ void delay_ms(uint32_t delay) { wd_reset(); } +/// internal- wait for up to 65.5ms using a busy loop +/// \param us time to wait in microseconds void delayMicrosecondsInterruptible(uint16_t us) { // for a one-microsecond delay, simply return. the overhead // of the function call yields a delay of approximately 1 1/8 us. if (--us == 0) return; - + // the following loop takes a quarter of a microsecond (4 cycles) // per iteration, so execute it four times for each microsecond of // delay requested. us <<= 2; - + // account for the time taken in the preceeding commands. us -= 2; - + // busy wait __asm__ __volatile__ ("1: sbiw %0,1" "\n\t" // 2 cycles "brne 1b" : diff --git a/extruder/analog.c b/extruder/analog.c index ddced7b..7dc0aca 100644 --- a/extruder/analog.c +++ b/extruder/analog.c @@ -1,10 +1,16 @@ -#include "analog.h" +#include "analog.h" + +/** \file + \brief Analog subsystem +*/ + #include "temp.h" #include /* OR-combined mask of all channels */ #undef DEFINE_TEMP_SENSOR +//! automagically generate analog_mask from DEFINE_TEMP_SENSOR entries in config.h #define DEFINE_TEMP_SENSOR(name, type, pin) | (((type == TT_THERMISTOR) || (type == TT_AD595)) ? 1 << (pin) : 0) static const uint8_t analog_mask = 0 #include "config.h" @@ -14,6 +20,7 @@ static const uint8_t analog_mask = 0 static uint8_t adc_counter; static volatile uint16_t adc_result[8] __attribute__ ((__section__ (".bss"))); +//! Configure all registers, start interrupt loop void analog_init() { if (analog_mask > 0) { #ifdef PRR @@ -36,6 +43,10 @@ void analog_init() { } /* analog_mask > 0 */ } +/*! Analog Interrupt + + This is where we read our analog value and store it in an array for later retrieval +*/ ISR(ADC_vect, ISR_NOBLOCK) { // emulate free-running mode but be more deterministic about exactly which result we have, since this project has long-running interrupts if (analog_mask > 0) { @@ -52,6 +63,10 @@ ISR(ADC_vect, ISR_NOBLOCK) { } } +/*! Read analog value from saved result array + \param channel Channel to be read + \return analog reading, 10-bit right aligned +*/ uint16_t analog_read(uint8_t channel) { if (analog_mask > 0) { uint16_t r; diff --git a/extruder/analog.h b/extruder/analog.h index 21ab830..ba7396e 100644 --- a/extruder/analog.h +++ b/extruder/analog.h @@ -26,6 +26,7 @@ #endif void analog_init(void); + uint16_t analog_read(uint8_t channel); #endif /* _ANALOG_H */ diff --git a/extruder/arduino.h b/extruder/arduino.h index b8d1a06..d63fb55 100644 --- a/extruder/arduino.h +++ b/extruder/arduino.h @@ -1,3 +1,10 @@ +/*! + \file + \brief pin definitions and I/O macros + + why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html +*/ + #ifndef _ARDUINO_H #define _ARDUINO_H @@ -8,7 +15,8 @@ */ #ifndef MASK -#define MASK(PIN) (1 << PIN) +/// MASKING- returns \f$2^PIN\f$ + #define MASK(PIN) (1 << PIN) #endif /* @@ -17,26 +25,40 @@ now you can simply SET_OUTPUT(STEP); WRITE(STEP, 1); WRITE(STEP, 0); */ +/// Read a pin #define _READ(IO) (IO ## _RPORT & MASK(IO ## _PIN)) +/// write to a pin #define _WRITE(IO, v) do { if (v) { IO ## _WPORT |= MASK(IO ## _PIN); } else { IO ## _WPORT &= ~MASK(IO ## _PIN); }; } while (0) +/// toggle a pin #define _TOGGLE(IO) do { IO ## _RPORT = MASK(IO ## _PIN); } while (0) +/// set pin as input #define _SET_INPUT(IO) do { IO ## _DDR &= ~MASK(IO ## _PIN); } while (0) +/// set pin as output #define _SET_OUTPUT(IO) do { IO ## _DDR |= MASK(IO ## _PIN); } while (0) +/// check if pin is an input #define _GET_INPUT(IO) ((IO ## _DDR & MASK(IO ## _PIN)) == 0) +/// check if pin is an output #define _GET_OUTPUT(IO) ((IO ## _DDR & MASK(IO ## _PIN)) != 0) -// why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html +// why double up on these macros? see http://gcc.gnu.org/onlinedocs/cpp/Stringification.html +/// Read a pin wrapper #define READ(IO) _READ(IO) +/// Write to a pin wrapper #define WRITE(IO, v) _WRITE(IO, v) +/// toggle a pin wrapper #define TOGGLE(IO) _TOGGLE(IO) +/// set pin as input wrapper #define SET_INPUT(IO) _SET_INPUT(IO) +/// set pin as output wrapper #define SET_OUTPUT(IO) _SET_OUTPUT(IO) +/// check if pin is an input wrapper #define GET_INPUT(IO) _GET_INPUT(IO) +/// check if pin is an output wrapper #define GET_OUTPUT(IO) _GET_OUTPUT(IO) /* @@ -61,6 +83,10 @@ #include "arduino_1280.h" //2560 has the same pins and ports so we can reuse the 1280 file. #endif +#if defined (__AVR_AT90USB1287__) + #include "arduino_usb1287.h" +#endif + #ifndef DIO0_PIN #error pins for this chip not defined in arduino.h! If you write an appropriate pin definition and have this firmware work on your chip, please tell us via the forum thread #endif diff --git a/extruder/crc.c b/extruder/crc.c index 2a8a10c..faeb5cd 100644 --- a/extruder/crc.c +++ b/extruder/crc.c @@ -1,7 +1,13 @@ #include "crc.h" +/** \file + \brief crc16 routine +*/ + #include +// avr-libc's _crc16_update is equivalent to the following: +// // uint16_t _crc16_update(uint16_t crc, uint8_t a) { // int i; // crc ^= a; @@ -15,6 +21,13 @@ // return crc; // } +/** block-at-once CRC16 calculator + \param *data data to find crc16 for + \param len length of data + \return uint16 crc16 of passed data + + uses avr-libc's optimised crc16 routine +*/ uint16_t crc_block(void *data, uint16_t len) { uint16_t crc = 0; for (; len; data++, len--) { diff --git a/extruder/delay.c b/extruder/delay.c index fb3e2bb..b5840a2 100644 --- a/extruder/delay.c +++ b/extruder/delay.c @@ -1,8 +1,13 @@ #include "delay.h" +/** \file + \brief Delay routines +*/ + #include "watchdog.h" -// delay( microseconds ) +/// delay microseconds +/// \param delay time to wait in microseconds void delay(uint32_t delay) { wd_reset(); while (delay > 65535) { @@ -14,7 +19,8 @@ void delay(uint32_t delay) { wd_reset(); } -// delay_ms( milliseconds ) +/// delay milliseconds +/// \param delay time to wait in milliseconds void delay_ms(uint32_t delay) { wd_reset(); while (delay > 65) { @@ -26,21 +32,23 @@ void delay_ms(uint32_t delay) { wd_reset(); } +/// internal- wait for up to 65.5ms using a busy loop +/// \param us time to wait in microseconds void delayMicrosecondsInterruptible(uint16_t us) { // for a one-microsecond delay, simply return. the overhead // of the function call yields a delay of approximately 1 1/8 us. if (--us == 0) return; - + // the following loop takes a quarter of a microsecond (4 cycles) // per iteration, so execute it four times for each microsecond of // delay requested. us <<= 2; - + // account for the time taken in the preceeding commands. us -= 2; - + // busy wait __asm__ __volatile__ ("1: sbiw %0,1" "\n\t" // 2 cycles "brne 1b" : diff --git a/extruder/heater.c b/extruder/heater.c index ea79dc5..9aed236 100644 --- a/extruder/heater.c +++ b/extruder/heater.c @@ -1,5 +1,9 @@ #include "heater.h" +/** \file + \brief Manage heaters +*/ + #include #include #include @@ -13,13 +17,16 @@ #include "sersendf.h" #endif +/// \struct heater_definition_t +/// \brief simply holds pinout data- port, pin, pwm channel if used typedef struct { - volatile uint8_t *heater_port; - uint8_t heater_pin; - volatile uint8_t *heater_pwm; + volatile uint8_t *heater_port; ///< pointer to port. DDR is inferred from this pointer too + uint8_t heater_pin; ///< heater pin, not masked. eg for PB3 enter '3' here, or PB3_PIN or similar + volatile uint8_t *heater_pwm; ///< pointer to 8-bit PWM register, eg OCR0A (8-bit) or ORC3L (low byte, 16-bit) } heater_definition_t; #undef DEFINE_HEATER +/// \brief helper macro to fill heater definition struct from config.h #define DEFINE_HEATER(name, port, pin, pwm) { &(port), (pin), &(pwm) }, static const heater_definition_t heaters[NUM_HEATERS] = { @@ -27,45 +34,62 @@ static const heater_definition_t heaters[NUM_HEATERS] = }; #undef DEFINE_HEATER -// this struct holds the heater PID factors that are stored in the EEPROM during poweroff +/** + \var heaters_pid + \brief this struct holds the heater PID factors + + PID is a fascinating way to control any closed loop control, combining the error (P), cumulative error (I) and rate at which we're approacing the setpoint (D) in such a way that when correctly tuned, the system will achieve target temperature quickly and with little to no overshoot + + At every sample, we calculate \f$OUT = k_P (S - T) + k_I \int (S - T) + k_D \frac{dT}{dt}\f$ where S is setpoint and T is temperature. + + The three factors kP, kI, kD are chosen to give the desired behaviour given the dynamics of the system. + + See http://www.eetimes.com/design/embedded/4211211/PID-without-a-PhD for the full story +*/ struct { - int32_t p_factor; - int32_t i_factor; - int32_t d_factor; - int16_t i_limit; + int32_t p_factor; ///< scaled P factor + int32_t i_factor; ///< scaled I factor + int32_t d_factor; ///< scaled D factor + int16_t i_limit; ///< scaled I limit, such that \f$-i_{limit} < i_{factor} < i_{limit}\f$ } heaters_pid[NUM_HEATERS]; -// this struct holds the runtime heater data- PID integrator history, temperature history, sanity checker +/// \brief this struct holds the runtime heater data- PID integrator history, temperature history, sanity checker struct { - int16_t heater_i; + int16_t heater_i; ///< integrator, \f$-i_{limit} < \sum{\Delta t} < i_{limit}\f$ - uint16_t temp_history[TH_COUNT]; - uint8_t temp_history_pointer; + uint16_t temp_history[TH_COUNT]; ///< store last TH_COUNT readings in a ring, so we can smooth out our differentiator + uint8_t temp_history_pointer; ///< pointer to last entry in ring #ifdef HEATER_SANITY_CHECK - uint16_t sanity_counter; - uint16_t sane_temperature; + uint16_t sanity_counter; ///< how long things haven't seemed sane + uint16_t sane_temperature; ///< a temperature we consider sane given the heater settings #endif - uint8_t heater_output; + uint8_t heater_output; ///< this is the PID value we eventually send to the heater } heaters_runtime[NUM_HEATERS]; +/// default scaled P factor, equivalent to 8.0 #define DEFAULT_P 8192 +/// default scaled I factor, equivalent to 0.5 #define DEFAULT_I 512 +/// default scaled D factor, equivalent to 24 #define DEFAULT_D 24576 +/// default scaled I limit #define DEFAULT_I_LIMIT 384 -// this lives in the eeprom so we can save our PID settings for each heater +/// this lives in the eeprom so we can save our PID settings for each heater typedef struct { int32_t EE_p_factor; int32_t EE_i_factor; int32_t EE_d_factor; int16_t EE_i_limit; - uint16_t crc; + uint16_t crc; ///< crc so we can use defaults if eeprom data is invalid } EE_factor; EE_factor EEMEM EE_factors[NUM_HEATERS]; +/// \brief initialise heater subsystem +/// Set directions, initialise PWM timers, read PID factors from eeprom, etc void heater_init() { heater_t i; // setup pins @@ -115,6 +139,7 @@ void heater_init() { } } +/// \brief Write PID factors to eeprom void heater_save_settings() { #ifndef BANG_BANG heater_t i; @@ -128,6 +153,12 @@ void heater_save_settings() { #endif /* BANG_BANG */ } +/** \brief run heater PID algorithm + \param h which heater we're running the loop for + \param t which temp sensor this heater is attached to + \param current_temp the temperature that the associated temp sensor is reporting + \param target_temp the temperature we're trying to achieve +*/ void heater_tick(heater_t h, temp_sensor_t t, uint16_t current_temp, uint16_t target_temp) { uint8_t pid_output; @@ -187,7 +218,7 @@ void heater_tick(heater_t h, temp_sensor_t t, uint16_t current_temp, uint16_t ta else pid_output = BANG_BANG_ON; #endif - + #ifdef HEATER_SANITY_CHECK // check heater sanity // implementation is a moving window with some slow-down to compensate for thermal mass @@ -247,6 +278,12 @@ void heater_tick(heater_t h, temp_sensor_t t, uint16_t current_temp, uint16_t ta heater_set(h, pid_output); } +/** \brief manually set PWM output + \param index the heater we're setting the output for + \param value the PWM value to write + + anything done by this function is overwritten by heater_tick above if the heater has an associated temp sensor +*/ void heater_set(heater_t index, uint8_t value) { if (index >= NUM_HEATERS) return; @@ -268,6 +305,10 @@ void heater_set(heater_t index, uint8_t value) { } } +/** \brief turn off all heaters + + for emergency stop +*/ uint8_t heaters_all_off() { uint8_t i; for (i = 0; i < NUM_HEATERS; i++) { @@ -278,6 +319,10 @@ uint8_t heaters_all_off() { return 255; } +/** \brief set heater P factor + \param index heater to change factor for + \param p scaled P factor +*/ void pid_set_p(heater_t index, int32_t p) { #ifndef BANG_BANG if (index >= NUM_HEATERS) @@ -287,6 +332,10 @@ void pid_set_p(heater_t index, int32_t p) { #endif /* BANG_BANG */ } +/** \brief set heater I factor + \param index heater to change I factor for + \param i scaled I factor +*/ void pid_set_i(heater_t index, int32_t i) { #ifndef BANG_BANG if (index >= NUM_HEATERS) @@ -296,6 +345,10 @@ void pid_set_i(heater_t index, int32_t i) { #endif /* BANG_BANG */ } +/** \brief set heater D factor + \param index heater to change D factor for + \param d scaled D factor +*/ void pid_set_d(heater_t index, int32_t d) { #ifndef BANG_BANG if (index >= NUM_HEATERS) @@ -305,6 +358,10 @@ void pid_set_d(heater_t index, int32_t d) { #endif /* BANG_BANG */ } +/** \brief set heater I limit + \param index heater to set I limit for + \param i_limit scaled I limit +*/ void pid_set_i_limit(heater_t index, int32_t i_limit) { #ifndef BANG_BANG if (index >= NUM_HEATERS) @@ -315,6 +372,9 @@ void pid_set_i_limit(heater_t index, int32_t i_limit) { } #ifndef EXTRUDER +/** \brief send heater debug info to host + \param i index of heater to send info for +*/ void heater_print(uint16_t i) { sersendf_P(PSTR("P:%ld I:%ld D:%ld Ilim:%u crc:%u "), heaters_pid[i].p_factor, heaters_pid[i].i_factor, heaters_pid[i].d_factor, heaters_pid[i].i_limit, crc_block(&heaters_pid[i].p_factor, 14)); } diff --git a/extruder/intercom.c b/extruder/intercom.c index ec02cac..6bcfe35 100644 --- a/extruder/intercom.c +++ b/extruder/intercom.c @@ -1,5 +1,9 @@ #include "intercom.h" +/** \file + \brief motherboard <-> extruder board protocol +*/ + #include #include @@ -11,12 +15,16 @@ #define START 0x55 -intercom_packet tx; // this packet will be send -intercom_packet rx; // the last received packet with correct checksum -intercom_packet _tx; // current packet in transmission -intercom_packet _rx; // receiving packet +intercom_packet tx; ///< this packet will be sent +intercom_packet rx; ///< the last received packet with correct checksum +intercom_packet _tx; ///< current packet in transmission +intercom_packet _rx; ///< current packet being received +/// pointer to location in transferring packet. +/// since we run half duplex, we can share the pointer between rx and tx uint8_t packet_pointer; +/// crc for currently transferring packet +/// since we run half duplex, we can share the crc between rx and tx uint8_t rxcrc; volatile uint8_t intercom_flags; @@ -92,7 +100,7 @@ void start_send(void) { // enable transmit pin enable_transmit(); - + // set start byte tx.packet.start = START; @@ -161,7 +169,7 @@ ISR(USART_RX_vect) packet_pointer = 0; #ifndef HOST - if (rxcrc == _rx.packet.crc && + if (rxcrc == _rx.packet.crc && _rx.packet.controller_num == THIS_CONTROLLER_NUM){ #else if (rxcrc == _rx.packet.crc){ diff --git a/extruder/intercom.h b/extruder/intercom.h index 988ccdc..0b754b8 100644 --- a/extruder/intercom.h +++ b/extruder/intercom.h @@ -12,26 +12,31 @@ #define disable_transmit() do { WRITE(TX_ENABLE_PIN,0); UCSR0B &= ~(MASK(TXCIE0) | MASK(UDRIE0)); UCSR0B |= MASK(RXEN0); } while(0) #endif +/// list of error codes, not many so far... enum { ERROR_BAD_CRC } err_codes; +/** \brief intercom packet structure, both tx and rx +*/ typedef struct { - uint8_t start; - uint8_t dio; - uint8_t controller_num; - uint8_t control_word; - uint8_t control_index; + uint8_t start; ///< start byte, must be 0x55 + uint8_t dio; ///< gpio + uint8_t controller_num; ///< controller index + uint8_t control_word; ///< what to do + uint8_t control_index; ///< what to do it to + /// data with which to do it union { int32_t control_data_int32; uint32_t control_data_uint32; float control_data_float; uint16_t temp[2]; }; - uint8_t err; - uint8_t crc; + uint8_t err; ///< error code, if any + uint8_t crc; ///< crc for packet verification. packets with bad crc are simply ignored } intercom_packet_t; +/// this allows us to fill the packet struct, then pass it to something that expects an array of bytes typedef union { intercom_packet_t packet; uint8_t data[sizeof(intercom_packet_t)]; @@ -40,33 +45,33 @@ typedef union { extern intercom_packet tx; extern intercom_packet rx; -// initialise serial subsystem +/// initialise serial subsystem void intercom_init(void); -// if host, send target temperature to extruder -// if extruder, send actual temperature to host +/// if host, send target temperature to extruder +/// if extruder, send actual temperature to host void send_temperature(uint8_t index, uint16_t temperature); -// if host, read actual temperature from extruder -// if extruder, read target temperature from host +/// if host, read actual temperature from extruder +/// if extruder, read target temperature from host uint16_t read_temperature(uint8_t index); -// if host, set DIOs on extruder controller -// if extruder, report DIO state +/// if host, set DIOs on extruder controller +/// if extruder, report DIO state void set_dio(uint8_t index, uint8_t value); -// if host, read extruder DIO inputs -// if extruder, set DIO outputs +/// if host, read extruder DIO inputs +/// if extruder, set DIO outputs uint8_t get_dio(uint8_t index); -// set error code to send to other end +/// set error code to send to other end void set_err(uint8_t err); -// get error code sent from other end +/// get error code sent from other end uint8_t get_err(void); -// if host, send packet to extruder -// if extruder, return packet to host +/// if host, send packet to extruder +/// if extruder, return packet to host void start_send(void); #define FLAG_RX_IN_PROGRESS 1 diff --git a/extruder/temp.c b/extruder/temp.c index b0159f5..4c25958 100644 --- a/extruder/temp.c +++ b/extruder/temp.c @@ -1,5 +1,11 @@ #include "temp.h" +/** \file + \brief Manage temperature sensors + + \note \b ALL temperatures are stored as 14.2 fixed point in teacup, so we have a range of 0 - 16383.75 celsius and a precision of 0.25 celsius. That includes the ThermistorTable, which is why you can't copy and paste one from other firmwares which don't do this. +*/ + #include #include #include @@ -20,13 +26,15 @@ typedef enum { TCOPEN } temp_flags_enum; +/// holds metadata for each temperature sensor typedef struct { - temp_type_t temp_type; - uint8_t temp_pin; - heater_t heater; + temp_type_t temp_type; ///< type of sensor + uint8_t temp_pin; ///< pin that sensor is on + heater_t heater; ///< associated heater if any } temp_sensor_definition_t; #undef DEFINE_TEMP_SENSOR +/// help build list of sensors from entries in config.h #define DEFINE_TEMP_SENSOR(name, type, pin) { (type), (pin), (HEATER_ ## name) }, static const temp_sensor_definition_t temp_sensors[NUM_TEMP_SENSORS] = { @@ -34,16 +42,16 @@ static const temp_sensor_definition_t temp_sensors[NUM_TEMP_SENSORS] = }; #undef DEFINE_TEMP_SENSOR -// this struct holds the runtime sensor data- read temperatures, targets, etc +/// this struct holds the runtime sensor data- read temperatures, targets, etc struct { - temp_flags_enum temp_flags; - - uint16_t last_read_temp; - uint16_t target_temp; - - uint8_t temp_residency; - - uint16_t next_read_time; + temp_flags_enum temp_flags; ///< flags + + uint16_t last_read_temp; ///< last received reading + uint16_t target_temp; ///< manipulate attached heater to attempt to achieve this value + + uint8_t temp_residency; ///< how long have we been close to target temperature? + + uint16_t next_read_time; ///< how long until we can read this sensor again? } temp_sensors_runtime[NUM_TEMP_SENSORS]; #ifdef TEMP_MAX6675 @@ -58,6 +66,7 @@ struct { #include "analog.h" #endif +/// set up temp sensors. Currently only the 'intercom' sensor needs initialisation. void temp_init() { temp_sensor_t i; for (i = 0; i < NUM_TEMP_SENSORS; i++) { @@ -93,6 +102,7 @@ void temp_init() { } } +/// called every 10ms from clock.c - check all temp sensors that are ready for checking void temp_sensor_tick() { temp_sensor_t i = 0; for (; i < NUM_TEMP_SENSORS; i++) { @@ -110,29 +120,29 @@ void temp_sensor_tick() { #elif defined PRR0 PRR0 &= ~MASK(PRSPI); #endif - + SPCR = MASK(MSTR) | MASK(SPE) | MASK(SPR0); - + // enable TT_MAX6675 WRITE(SS, 0); - + // ensure 100ns delay - a bit extra is fine delay(1); - + // read MSB SPDR = 0; for (;(SPSR & MASK(SPIF)) == 0;); temp = SPDR; temp <<= 8; - + // read LSB SPDR = 0; for (;(SPSR & MASK(SPIF)) == 0;); temp |= SPDR; - + // disable TT_MAX6675 WRITE(SS, 1); - + temp_sensors_runtime[i].temp_flags = 0; if ((temp & 0x8002) == 0) { // got "device id" @@ -145,13 +155,13 @@ void temp_sensor_tick() { temp = temp >> 3; } } - + // this number depends on how frequently temp_sensor_tick is called. the MAX6675 can give a reading every 0.22s, so set this to about 250ms temp_sensors_runtime[i].next_read_time = 25; - + break; #endif /* TEMP_MAX6675 */ - + #ifdef TEMP_THERMISTOR case TT_THERMISTOR: do { @@ -175,7 +185,7 @@ void temp_sensor_tick() { // x₁= temptable[j][0] // y₀= temptable[j-1][1] // y₁= temptable[j][1] - // y = + // y = // Wikipedia's example linear interpolation formula. temp = ( // ((x - x₀)y₁ @@ -185,7 +195,7 @@ void temp_sensor_tick() { // (x₁-x) (pgm_read_word(&(temptable[j][0])) - (uint32_t)temp) // y₀ ) - * pgm_read_word(&(temptable[j-1][1]))) + * pgm_read_word(&(temptable[j-1][1]))) // / / // (x₁ - x₀) @@ -201,7 +211,7 @@ void temp_sensor_tick() { if (debug_flags & DEBUG_PID) sersendf_P(PSTR(" Sensor:%d\n"),i); #endif - + //Clamp for overflows if (j == NUMTEMPS) @@ -211,17 +221,17 @@ void temp_sensor_tick() { } while (0); break; #endif /* TEMP_THERMISTOR */ - + #ifdef TEMP_AD595 case TT_AD595: temp = analog_read(temp_sensors[i].temp_pin); - + // convert // >>8 instead of >>10 because internal temp is stored as 14.2 fixed point temp = (temp * 500L) >> 8; - + temp_sensors_runtime[i].next_read_time = 0; - + break; #endif /* TEMP_AD595 */ @@ -239,7 +249,7 @@ void temp_sensor_tick() { break; #endif /* TEMP_INTERCOM */ - + #ifdef TEMP_DUMMY case TT_DUMMY: temp = temp_sensors_runtime[i].last_read_temp; @@ -258,7 +268,7 @@ void temp_sensor_tick() { break; } temp_sensors_runtime[i].last_read_temp = temp; - + if (labs(temp - temp_sensors_runtime[i].target_temp) < TEMP_HYSTERESIS) { if (temp_sensors_runtime[i].temp_residency < TEMP_RESIDENCY_TIME) temp_sensors_runtime[i].temp_residency++; @@ -266,7 +276,7 @@ void temp_sensor_tick() { else { temp_sensors_runtime[i].temp_residency = 0; } - + if (temp_sensors[i].heater < NUM_HEATERS) { heater_tick(temp_sensors[i].heater, i, temp_sensors_runtime[i].last_read_temp, temp_sensors_runtime[i].target_temp); } @@ -274,6 +284,8 @@ void temp_sensor_tick() { } } +/// report whether all temp sensors are reading their target temperatures +/// used for M109 and friends uint8_t temp_achieved() { temp_sensor_t i; uint8_t all_ok = 255; @@ -285,6 +297,9 @@ uint8_t temp_achieved() { return all_ok; } +/// specify a target temperature +/// \param index sensor to set a target for +/// \param temperature target temperature to aim for void temp_set(temp_sensor_t index, uint16_t temperature) { if (index >= NUM_TEMP_SENSORS) return; @@ -297,6 +312,8 @@ void temp_set(temp_sensor_t index, uint16_t temperature) { #endif } +/// return most recent reading for a sensor +/// \param index sensor to read uint16_t temp_get(temp_sensor_t index) { if (index >= NUM_TEMP_SENSORS) return 0; @@ -306,6 +323,8 @@ uint16_t temp_get(temp_sensor_t index) { // extruder doesn't have sersendf_P #ifndef EXTRUDER +/// send temperatures to host +/// \param index sensor value to send void temp_print(temp_sensor_t index) { uint8_t c = 0; @@ -318,7 +337,7 @@ void temp_print(temp_sensor_t index) { #ifdef HEATER_BED uint8_t b = 0; b = (temp_sensors_runtime[HEATER_BED].last_read_temp & 3) * 25; - + sersendf_P(PSTR(" B:%u.%u"), temp_sensors_runtime[HEATER_bed].last_read_temp >> 2 , b); #endif diff --git a/extruder/timer.c b/extruder/timer.c index 296f2bc..308c467 100644 --- a/extruder/timer.c +++ b/extruder/timer.c @@ -1,5 +1,15 @@ #include "timer.h" +/** \file + \brief Timer management - step pulse clock and system clock + + Teacup uses timer1 to generate both step pulse clock and system clock. + + We achieve this by using the output compare registers to generate the two clocks while the timer free-runs. + + Teacup has tried numerous timer management methods, and this is the best so far. +*/ + #include #include "arduino.h" @@ -9,24 +19,28 @@ #include "dda_queue.h" #endif -/* - how often we overflow and update our clock; with F_CPU=16MHz, max is < 4.096ms (TICK_TIME = 65535) -*/ +/// how often we overflow and update our clock; with F_CPU=16MHz, max is < 4.096ms (TICK_TIME = 65535) #define TICK_TIME 2 MS +/// convert back to ms from cpu ticks so our system clock runs properly if you change TICK_TIME #define TICK_TIME_MS (TICK_TIME / (F_CPU / 1000)) +/// time until next step, as output compare register is too small for long step times volatile uint32_t next_step_time; +/// every time our clock fires, we increment this so we know when 10ms has elapsed uint8_t clock_counter_10ms = 0; +/// keep track of when 250ms has elapsed uint8_t clock_counter_250ms = 0; +/// keep track of when 1s has elapsed uint8_t clock_counter_1s = 0; +/// flags to tell main loop when above have elapsed volatile uint8_t clock_flag = 0; -// comparator B is the "clock", happens every TICK_TIME +/// comparator B is the system clock, happens every TICK_TIME ISR(TIMER1_COMPB_vect) { // set output compare register to the next clock tick OCR1B = (OCR1B + TICK_TIME) & 0xFFFF; - + /* clock stuff */ @@ -34,12 +48,12 @@ ISR(TIMER1_COMPB_vect) { if (clock_counter_10ms >= 10) { clock_counter_10ms -= 10; clock_flag |= CLOCK_FLAG_10MS; - + clock_counter_250ms += 1; if (clock_counter_250ms >= 25) { clock_counter_250ms -= 25; clock_flag |= CLOCK_FLAG_250MS; - + clock_counter_1s += 1; if (clock_counter_1s >= 4) { clock_counter_1s -= 4; @@ -54,27 +68,26 @@ void timer1_compa_isr(void) __attribute__ ((hot)); void timer1_compa_isr() { // led on WRITE(SCK, 1); - + // disable this interrupt. if we set a new timeout, it will be re-enabled when appropriate TIMSK1 &= ~MASK(OCIE1A); - + // stepper tick queue_step(); - + // led off WRITE(SCK, 0); } -// comparator A is the step timer. It has higher priority then B. +/// comparator A is the step timer. It has higher priority then B. ISR(TIMER1_COMPA_vect) { // Check if this is a real step, or just a next_step_time "overflow" if (next_step_time < 65536) { - next_step_time = 0; // step! timer1_compa_isr(); return; } - + next_step_time -= 65536; // similar algorithm as described in setTimer below. @@ -88,6 +101,8 @@ ISR(TIMER1_COMPA_vect) { } #endif /* ifdef HOST */ +/// initialise timer and enable system clock interrupt. +/// step interrupt is enabled later when we start using it void timer_init() { // no outputs @@ -101,6 +116,7 @@ void timer_init() } #ifdef HOST +/// specify how long until the step timer should fire void setTimer(uint32_t delay) { // save interrupt flag @@ -111,7 +127,7 @@ void setTimer(uint32_t delay) // re-enable clock interrupt in case we're recovering from emergency stop TIMSK1 |= MASK(OCIE1B); - + if (delay > 0) { if (delay <= 16) { // unfortunately, force registers don't trigger an interrupt, so we do the following @@ -119,7 +135,7 @@ void setTimer(uint32_t delay) timer1_compa_isr(); } else { - // Assume all steps belong to one move. Within one move the delay is + // Assume all steps belong to one move. Within one move the delay is // from one step to the next one, which should be more or less the same // as from one step interrupt to the next one. The last step interrupt happend // at OCR1A, so start delay from there. @@ -144,7 +160,7 @@ void setTimer(uint32_t delay) else { OCR1A = step_start; } - + TIMSK1 |= MASK(OCIE1A); } } else { @@ -152,11 +168,12 @@ void setTimer(uint32_t delay) next_step_time = 0; TIMSK1 &= ~MASK(OCIE1A); } - + // restore interrupt flag SREG = sreg; } +/// stop timers - emergency stop void timer_stop() { // disable all interrupts TIMSK1 = 0; diff --git a/extruder/watchdog.c b/extruder/watchdog.c index 28cbe32..e4e4306 100644 --- a/extruder/watchdog.c +++ b/extruder/watchdog.c @@ -1,6 +1,15 @@ - #include "watchdog.h" +/** \file + \brief Watchdog - reset if main loop doesn't run for too long + + The usefulness of this feature is questionable at best. + + What do you think will happen if your avr resets in the middle of a print? + + Is that preferable to it simply locking up? +*/ + #ifdef USE_WATCHDOG #include @@ -26,16 +35,18 @@ ISR(WDT_vect) { wd_flag |= 1; } +/// intialise watchdog void wd_init() { // check if we were reset by the watchdog // if (mcusr_mirror & MASK(WDRF)) // serial_writestr_P(PSTR("Watchdog Reset!\n")); - // 0.25s timeout, interrupt and system reset + // 0.5s timeout, interrupt and system reset wdt_enable(WDTO_500MS); WDTCSR |= MASK(WDIE); } +/// reset watchdog. MUST be called every 0.5s after init or avr will reset. void wd_reset() { wdt_reset(); if (wd_flag) { diff --git a/gcode_parse.c b/gcode_parse.c index 020255c..c0829c6 100644 --- a/gcode_parse.c +++ b/gcode_parse.c @@ -1,5 +1,9 @@ #include "gcode_parse.h" +/** \file + \brief Parse received G-Codes +*/ + #include #include "serial.h" @@ -39,12 +43,17 @@ #define STEPS_PER_IN_Z ((uint32_t) ((25.4 * STEPS_PER_MM_Z) + 0.5)) #define STEPS_PER_IN_E ((uint32_t) ((25.4 * STEPS_PER_MM_E) + 0.5)) +/// current or previous gcode word +/// for working out what to do with data just received uint8_t last_field = 0; +/// crude crc macro #define crc(a, b) (a ^ b) +/// crude floating point data storage decfloat read_digit __attribute__ ((__section__ (".bss"))); +/// this is where we store all the data for the current command before we work out what to do with it GCODE_COMMAND next_target __attribute__ ((__section__ (".bss"))); /* @@ -73,6 +82,13 @@ GCODE_COMMAND next_target __attribute__ ((__section__ (".bss"))); extern const uint32_t powers[]; // defined in sermsg.c const int32_t rounding[DECFLOAT_EXP_MAX] = {0, 5, 50, 500}; +/// convert a floating point input value into an integer with appropriate scaling. +/// \param *df pointer to floating point structure that holds fp value to convert +/// \param multiplicand multiply by this amount during conversion to integer +/// \param denominator divide by this amount during conversion to integer +/// +/// lots of work has been done in exploring this function's limitations in terms of overflow and rounding +/// this work may not be finished static int32_t decfloat_to_int(decfloat *df, uint32_t multiplicand, uint32_t denominator) { uint32_t r = df->mantissa; uint8_t e = df->exponent; @@ -98,12 +114,8 @@ static int32_t decfloat_to_int(decfloat *df, uint32_t multiplicand, uint32_t den return df->sign ? -(int32_t)r : (int32_t)r; } -/**************************************************************************** -* * -* Character Received - add it to our command * -* * -****************************************************************************/ - +/// Character Received - add it to our command +/// \param c the next character to process void gcode_parse_char(uint8_t c) { // uppercase if (c >= 'a' && c <= 'z') @@ -350,12 +362,12 @@ void gcode_parse_char(uint8_t c) { } else { sersendf_P(PSTR("rs N%ld Expected checksum %d\n"), next_target.N_expected, next_target.checksum_calculated); - request_resend(); +// request_resend(); } } else { sersendf_P(PSTR("rs N%ld Expected line number %ld\n"), next_target.N_expected, next_target.N_expected); - request_resend(); +// request_resend(); } // reset variables diff --git a/gcode_parse.h b/gcode_parse.h index 8866ebe..749cf3d 100644 --- a/gcode_parse.h +++ b/gcode_parse.h @@ -12,15 +12,16 @@ // wether to insist on a checksum //#define REQUIRE_CHECKSUM -// this is a very crude decimal-based floating point structure. -// a real floating point would at least have signed exponent. +/// this is a very crude decimal-based floating point structure. +/// a real floating point would at least have signed exponent.\n +/// resulting value is \f$ mantissa * 10^{-(exponent - 1)} * ((sign * 2) - 1)\f$ typedef struct { - uint32_t mantissa; - uint8_t exponent :7; - uint8_t sign :1; + uint32_t mantissa; ///< the actual digits of our floating point number + uint8_t exponent :7; ///< scale mantissa by \f$10^{-exponent}\f$ + uint8_t sign :1; ///< positive or negative? } decfloat; -// this holds all the possible data from a received command +/// this holds all the possible data from a received command typedef struct { union { struct { @@ -36,35 +37,35 @@ typedef struct { uint8_t seen_P :1; uint8_t seen_T :1; uint8_t seen_N :1; - uint8_t seen_checksum :1; - uint8_t seen_semi_comment :1; - uint8_t seen_parens_comment :1; - uint8_t option_relative :1; - uint8_t option_inches :1; + uint8_t seen_checksum :1; ///< seen a checksum? + uint8_t seen_semi_comment :1; ///< seen a semicolon? + uint8_t seen_parens_comment :1; ///< seen an open parenthesis + uint8_t option_relative :1; ///< relative or absolute coordinates? + uint8_t option_inches :1; ///< inches or millimeters? }; uint16_t flags; }; - uint8_t G; - uint8_t M; - TARGET target; + uint8_t G; ///< G command number + uint8_t M; ///< M command number + TARGET target; ///< target position: X, Y, Z, E and F - int16_t S; - uint16_t P; + int16_t S; ///< S word (various uses) + uint16_t P; ///< P word (various uses) - uint8_t T; + uint8_t T; ///< T word (tool index) - uint32_t N; - uint32_t N_expected; + uint32_t N; ///< line number + uint32_t N_expected; ///< expected line number - uint8_t checksum_read; - uint8_t checksum_calculated; + uint8_t checksum_read; ///< checksum in gcode command + uint8_t checksum_calculated; ///< checksum we calculated } GCODE_COMMAND; -// the command being processed +/// the command being processed extern GCODE_COMMAND next_target; -// accept the next character and process it +/// accept the next character and process it void gcode_parse_char(uint8_t c); // uses the global variable next_target.N diff --git a/gcode_process.c b/gcode_process.c index 549fe50..4fc108c 100644 --- a/gcode_process.c +++ b/gcode_process.c @@ -1,5 +1,9 @@ #include "gcode_process.h" +/** \file + \brief Work out what to do with received G-Code commands +*/ + #include #include "gcode_parse.h" @@ -19,9 +23,10 @@ #include "config.h" #include "home.h" -// the current tool +/// the current tool uint8_t tool; -// the tool to be changed when we get an M6 + +/// the tool to be changed when we get an M6 uint8_t next_tool; @@ -31,6 +36,7 @@ uint8_t next_tool; this is where we construct a move without a gcode command, useful for gcodes which require multiple moves eg; homing */ +/// move to X = 0 static void zero_x(void) { TARGET t = startpoint; t.X = 0; @@ -38,6 +44,7 @@ static void zero_x(void) { enqueue(&t); } +/// move to Y = 0 static void zero_y(void) { TARGET t = startpoint; t.Y = 0; @@ -45,6 +52,7 @@ static void zero_y(void) { enqueue(&t); } +/// move to Z = 0 static void zero_z(void) { TARGET t = startpoint; t.Z = 0; @@ -52,6 +60,7 @@ static void zero_z(void) { enqueue(&t); } +/// move E by a certain amount at a certain speed static void SpecialMoveE(int32_t e, uint32_t f) { TARGET t = startpoint; t.E = e; @@ -59,15 +68,19 @@ static void SpecialMoveE(int32_t e, uint32_t f) { enqueue(&t); } -/**************************************************************************** -* * -* Command Received - process it * -* * -****************************************************************************/ +/************************************************************************//** + + \brief Processes command stored in global \ref next_target. + This is where we work out what to actually do with each command we + receive. All data has already been scaled to integers in gcode_process. + If you want to add support for a new G or M code, this is the place. + + +*//*************************************************************************/ void process_gcode_command() { uint32_t backup_f; - + // convert relative to absolute if (next_target.option_relative) { next_target.target.X += startpoint.X; @@ -122,18 +135,18 @@ void process_gcode_command() { enqueue(&next_target.target); next_target.target.F = backup_f; break; - + // G1 - synchronised motion case 1: enqueue(&next_target.target); break; - + // G2 - Arc Clockwise // unimplemented - + // G3 - Arc Counter-clockwise // unimplemented - + // G4 - Dwell case 4: // wait for all moves to complete @@ -146,26 +159,26 @@ void process_gcode_command() { delay_ms(1); } break; - + // G20 - inches as units case 20: next_target.option_inches = 1; break; - + // G21 - mm as units case 21: next_target.option_inches = 0; break; - + // G30 - go home via point case 30: enqueue(&next_target.target); // no break here, G30 is move and then go home - + // G28 - go home case 28: queue_wait(); - + if (next_target.seen_X) { zero_x(); axisSelected = 1; @@ -179,25 +192,25 @@ void process_gcode_command() { axisSelected = 1; } // there's no point in moving E, as E is always relative - + if (!axisSelected) { zero_x(); zero_y(); zero_z(); } - + break; - + // G90 - absolute positioning case 90: next_target.option_relative = 0; break; - + // G91 - relative positioning case 91: next_target.option_relative = 1; break; - + // G92 - set home case 92: // wait for queue to empty @@ -242,7 +255,7 @@ void process_gcode_command() { if (next_target.seen_Z) home_z_positive(); break; - + // unknown gcode: spit an error default: sersendf_P(PSTR("E: Bad G-code %d"), next_target.G); @@ -290,9 +303,9 @@ void process_gcode_command() { } while (0); #endif break; - + // M102- extruder reverse - + // M5/M103- extruder off case 5: case 103: @@ -308,19 +321,19 @@ void process_gcode_command() { } while (0); #endif break; - + // M104- set temperature case 104: temp_set(next_target.P, next_target.S); if (next_target.S) power_on(); break; - + // M105- get temperature case 105: temp_print(next_target.P); break; - + // M7/M106- fan on case 7: case 106: @@ -335,7 +348,7 @@ void process_gcode_command() { heater_set(HEATER_FAN, 0); #endif break; - + // M109- set temp and wait case 109: temp_set(next_target.P, next_target.S); @@ -348,7 +361,7 @@ void process_gcode_command() { } enqueue(NULL); break; - + // M110- set line number case 110: // this is a no-op in Teacup @@ -422,7 +435,7 @@ void process_gcode_command() { power_on(); #endif break; - + // M190- power on case 190: power_on(); @@ -440,7 +453,7 @@ void process_gcode_command() { e_disable(); power_off(); break; - + #ifdef DEBUG // M240- echo off case 240: @@ -454,7 +467,7 @@ void process_gcode_command() { serial_writestr_P(PSTR("Echo on")); // newline is sent from gcode_parse after we return break; - + // DEBUG: return current position, end position, queue case 250: sersendf_P(PSTR("{X:%ld,Y:%ld,Z:%ld,E:%ld,F:%lu,c:%lu}\t{X:%ld,Y:%ld,Z:%ld,E:%ld,F:%lu,c:%lu}\t"), current_position.X, current_position.Y, current_position.Z, current_position.E, current_position.F, movebuffer[mb_tail].c, movebuffer[mb_tail].endpoint.X, movebuffer[mb_tail].endpoint.Y, movebuffer[mb_tail].endpoint.Z, movebuffer[mb_tail].endpoint.E, movebuffer[mb_tail].endpoint.F, @@ -467,7 +480,7 @@ void process_gcode_command() { print_queue(); break; - + // DEBUG: read arbitrary memory location case 253: if (next_target.seen_P == 0) @@ -478,7 +491,7 @@ void process_gcode_command() { } // newline is sent from gcode_parse after we return break; - + // DEBUG: write arbitrary memory locatiom case 254: sersendf_P(PSTR("%x:%x->%x"), next_target.S, *(volatile uint8_t *)(next_target.S), next_target.P); diff --git a/heater.c b/heater.c index ea79dc5..9aed236 100644 --- a/heater.c +++ b/heater.c @@ -1,5 +1,9 @@ #include "heater.h" +/** \file + \brief Manage heaters +*/ + #include #include #include @@ -13,13 +17,16 @@ #include "sersendf.h" #endif +/// \struct heater_definition_t +/// \brief simply holds pinout data- port, pin, pwm channel if used typedef struct { - volatile uint8_t *heater_port; - uint8_t heater_pin; - volatile uint8_t *heater_pwm; + volatile uint8_t *heater_port; ///< pointer to port. DDR is inferred from this pointer too + uint8_t heater_pin; ///< heater pin, not masked. eg for PB3 enter '3' here, or PB3_PIN or similar + volatile uint8_t *heater_pwm; ///< pointer to 8-bit PWM register, eg OCR0A (8-bit) or ORC3L (low byte, 16-bit) } heater_definition_t; #undef DEFINE_HEATER +/// \brief helper macro to fill heater definition struct from config.h #define DEFINE_HEATER(name, port, pin, pwm) { &(port), (pin), &(pwm) }, static const heater_definition_t heaters[NUM_HEATERS] = { @@ -27,45 +34,62 @@ static const heater_definition_t heaters[NUM_HEATERS] = }; #undef DEFINE_HEATER -// this struct holds the heater PID factors that are stored in the EEPROM during poweroff +/** + \var heaters_pid + \brief this struct holds the heater PID factors + + PID is a fascinating way to control any closed loop control, combining the error (P), cumulative error (I) and rate at which we're approacing the setpoint (D) in such a way that when correctly tuned, the system will achieve target temperature quickly and with little to no overshoot + + At every sample, we calculate \f$OUT = k_P (S - T) + k_I \int (S - T) + k_D \frac{dT}{dt}\f$ where S is setpoint and T is temperature. + + The three factors kP, kI, kD are chosen to give the desired behaviour given the dynamics of the system. + + See http://www.eetimes.com/design/embedded/4211211/PID-without-a-PhD for the full story +*/ struct { - int32_t p_factor; - int32_t i_factor; - int32_t d_factor; - int16_t i_limit; + int32_t p_factor; ///< scaled P factor + int32_t i_factor; ///< scaled I factor + int32_t d_factor; ///< scaled D factor + int16_t i_limit; ///< scaled I limit, such that \f$-i_{limit} < i_{factor} < i_{limit}\f$ } heaters_pid[NUM_HEATERS]; -// this struct holds the runtime heater data- PID integrator history, temperature history, sanity checker +/// \brief this struct holds the runtime heater data- PID integrator history, temperature history, sanity checker struct { - int16_t heater_i; + int16_t heater_i; ///< integrator, \f$-i_{limit} < \sum{\Delta t} < i_{limit}\f$ - uint16_t temp_history[TH_COUNT]; - uint8_t temp_history_pointer; + uint16_t temp_history[TH_COUNT]; ///< store last TH_COUNT readings in a ring, so we can smooth out our differentiator + uint8_t temp_history_pointer; ///< pointer to last entry in ring #ifdef HEATER_SANITY_CHECK - uint16_t sanity_counter; - uint16_t sane_temperature; + uint16_t sanity_counter; ///< how long things haven't seemed sane + uint16_t sane_temperature; ///< a temperature we consider sane given the heater settings #endif - uint8_t heater_output; + uint8_t heater_output; ///< this is the PID value we eventually send to the heater } heaters_runtime[NUM_HEATERS]; +/// default scaled P factor, equivalent to 8.0 #define DEFAULT_P 8192 +/// default scaled I factor, equivalent to 0.5 #define DEFAULT_I 512 +/// default scaled D factor, equivalent to 24 #define DEFAULT_D 24576 +/// default scaled I limit #define DEFAULT_I_LIMIT 384 -// this lives in the eeprom so we can save our PID settings for each heater +/// this lives in the eeprom so we can save our PID settings for each heater typedef struct { int32_t EE_p_factor; int32_t EE_i_factor; int32_t EE_d_factor; int16_t EE_i_limit; - uint16_t crc; + uint16_t crc; ///< crc so we can use defaults if eeprom data is invalid } EE_factor; EE_factor EEMEM EE_factors[NUM_HEATERS]; +/// \brief initialise heater subsystem +/// Set directions, initialise PWM timers, read PID factors from eeprom, etc void heater_init() { heater_t i; // setup pins @@ -115,6 +139,7 @@ void heater_init() { } } +/// \brief Write PID factors to eeprom void heater_save_settings() { #ifndef BANG_BANG heater_t i; @@ -128,6 +153,12 @@ void heater_save_settings() { #endif /* BANG_BANG */ } +/** \brief run heater PID algorithm + \param h which heater we're running the loop for + \param t which temp sensor this heater is attached to + \param current_temp the temperature that the associated temp sensor is reporting + \param target_temp the temperature we're trying to achieve +*/ void heater_tick(heater_t h, temp_sensor_t t, uint16_t current_temp, uint16_t target_temp) { uint8_t pid_output; @@ -187,7 +218,7 @@ void heater_tick(heater_t h, temp_sensor_t t, uint16_t current_temp, uint16_t ta else pid_output = BANG_BANG_ON; #endif - + #ifdef HEATER_SANITY_CHECK // check heater sanity // implementation is a moving window with some slow-down to compensate for thermal mass @@ -247,6 +278,12 @@ void heater_tick(heater_t h, temp_sensor_t t, uint16_t current_temp, uint16_t ta heater_set(h, pid_output); } +/** \brief manually set PWM output + \param index the heater we're setting the output for + \param value the PWM value to write + + anything done by this function is overwritten by heater_tick above if the heater has an associated temp sensor +*/ void heater_set(heater_t index, uint8_t value) { if (index >= NUM_HEATERS) return; @@ -268,6 +305,10 @@ void heater_set(heater_t index, uint8_t value) { } } +/** \brief turn off all heaters + + for emergency stop +*/ uint8_t heaters_all_off() { uint8_t i; for (i = 0; i < NUM_HEATERS; i++) { @@ -278,6 +319,10 @@ uint8_t heaters_all_off() { return 255; } +/** \brief set heater P factor + \param index heater to change factor for + \param p scaled P factor +*/ void pid_set_p(heater_t index, int32_t p) { #ifndef BANG_BANG if (index >= NUM_HEATERS) @@ -287,6 +332,10 @@ void pid_set_p(heater_t index, int32_t p) { #endif /* BANG_BANG */ } +/** \brief set heater I factor + \param index heater to change I factor for + \param i scaled I factor +*/ void pid_set_i(heater_t index, int32_t i) { #ifndef BANG_BANG if (index >= NUM_HEATERS) @@ -296,6 +345,10 @@ void pid_set_i(heater_t index, int32_t i) { #endif /* BANG_BANG */ } +/** \brief set heater D factor + \param index heater to change D factor for + \param d scaled D factor +*/ void pid_set_d(heater_t index, int32_t d) { #ifndef BANG_BANG if (index >= NUM_HEATERS) @@ -305,6 +358,10 @@ void pid_set_d(heater_t index, int32_t d) { #endif /* BANG_BANG */ } +/** \brief set heater I limit + \param index heater to set I limit for + \param i_limit scaled I limit +*/ void pid_set_i_limit(heater_t index, int32_t i_limit) { #ifndef BANG_BANG if (index >= NUM_HEATERS) @@ -315,6 +372,9 @@ void pid_set_i_limit(heater_t index, int32_t i_limit) { } #ifndef EXTRUDER +/** \brief send heater debug info to host + \param i index of heater to send info for +*/ void heater_print(uint16_t i) { sersendf_P(PSTR("P:%ld I:%ld D:%ld Ilim:%u crc:%u "), heaters_pid[i].p_factor, heaters_pid[i].i_factor, heaters_pid[i].d_factor, heaters_pid[i].i_limit, crc_block(&heaters_pid[i].p_factor, 14)); } diff --git a/home.c b/home.c index 088e062..e5e6747 100644 --- a/home.c +++ b/home.c @@ -1,10 +1,15 @@ #include "home.h" +/** \file + \brief Homing routines +*/ + #include "dda.h" #include "dda_queue.h" #include "delay.h" #include "pinio.h" +/// home all 3 axes void home() { queue_wait(); @@ -13,13 +18,13 @@ void home() { #elif defined X_MAX_PIN home_x_positive(); #endif - + #if defined Y_MIN_PIN home_y_negative(); #elif defined Y_MAX_PIN home_y_positive(); #endif - + #if defined Z_MIN_PIN home_z_negative(); #elif defined Z_MAX_PIN @@ -27,6 +32,7 @@ void home() { #endif } +/// find X MIN endstop void home_x_negative() { #if defined X_MIN_PIN uint8_t denoise_count = 0; @@ -65,7 +71,8 @@ void home_x_negative() { startpoint.X = current_position.X = 0; #endif } - + +/// find X_MAX endstop void home_x_positive() { #if defined X_MAX_PIN uint8_t denoise_count = 0; @@ -109,7 +116,8 @@ void home_x_positive() { enqueue(&t); #endif } - + +/// fund Y MIN endstop void home_y_negative() { #if defined Y_MIN_PIN uint8_t denoise_count = 0; @@ -149,6 +157,7 @@ void home_y_negative() { #endif } +/// find Y MAX endstop void home_y_positive() { #if defined Y_MAX_PIN uint8_t denoise_count = 0; @@ -193,6 +202,7 @@ void home_y_positive() { #endif } +/// find Z MIN endstop void home_z_negative() { #if defined Z_MIN_PIN uint8_t denoise_count = 0; @@ -233,6 +243,7 @@ void home_z_negative() { #endif } +/// find Z MAX endstop void home_z_positive() { #if defined Z_MAX_PIN uint8_t denoise_count = 0; diff --git a/intercom.c b/intercom.c index ec02cac..6bcfe35 100644 --- a/intercom.c +++ b/intercom.c @@ -1,5 +1,9 @@ #include "intercom.h" +/** \file + \brief motherboard <-> extruder board protocol +*/ + #include #include @@ -11,12 +15,16 @@ #define START 0x55 -intercom_packet tx; // this packet will be send -intercom_packet rx; // the last received packet with correct checksum -intercom_packet _tx; // current packet in transmission -intercom_packet _rx; // receiving packet +intercom_packet tx; ///< this packet will be sent +intercom_packet rx; ///< the last received packet with correct checksum +intercom_packet _tx; ///< current packet in transmission +intercom_packet _rx; ///< current packet being received +/// pointer to location in transferring packet. +/// since we run half duplex, we can share the pointer between rx and tx uint8_t packet_pointer; +/// crc for currently transferring packet +/// since we run half duplex, we can share the crc between rx and tx uint8_t rxcrc; volatile uint8_t intercom_flags; @@ -92,7 +100,7 @@ void start_send(void) { // enable transmit pin enable_transmit(); - + // set start byte tx.packet.start = START; @@ -161,7 +169,7 @@ ISR(USART_RX_vect) packet_pointer = 0; #ifndef HOST - if (rxcrc == _rx.packet.crc && + if (rxcrc == _rx.packet.crc && _rx.packet.controller_num == THIS_CONTROLLER_NUM){ #else if (rxcrc == _rx.packet.crc){ diff --git a/intercom.h b/intercom.h index 988ccdc..0b754b8 100644 --- a/intercom.h +++ b/intercom.h @@ -12,26 +12,31 @@ #define disable_transmit() do { WRITE(TX_ENABLE_PIN,0); UCSR0B &= ~(MASK(TXCIE0) | MASK(UDRIE0)); UCSR0B |= MASK(RXEN0); } while(0) #endif +/// list of error codes, not many so far... enum { ERROR_BAD_CRC } err_codes; +/** \brief intercom packet structure, both tx and rx +*/ typedef struct { - uint8_t start; - uint8_t dio; - uint8_t controller_num; - uint8_t control_word; - uint8_t control_index; + uint8_t start; ///< start byte, must be 0x55 + uint8_t dio; ///< gpio + uint8_t controller_num; ///< controller index + uint8_t control_word; ///< what to do + uint8_t control_index; ///< what to do it to + /// data with which to do it union { int32_t control_data_int32; uint32_t control_data_uint32; float control_data_float; uint16_t temp[2]; }; - uint8_t err; - uint8_t crc; + uint8_t err; ///< error code, if any + uint8_t crc; ///< crc for packet verification. packets with bad crc are simply ignored } intercom_packet_t; +/// this allows us to fill the packet struct, then pass it to something that expects an array of bytes typedef union { intercom_packet_t packet; uint8_t data[sizeof(intercom_packet_t)]; @@ -40,33 +45,33 @@ typedef union { extern intercom_packet tx; extern intercom_packet rx; -// initialise serial subsystem +/// initialise serial subsystem void intercom_init(void); -// if host, send target temperature to extruder -// if extruder, send actual temperature to host +/// if host, send target temperature to extruder +/// if extruder, send actual temperature to host void send_temperature(uint8_t index, uint16_t temperature); -// if host, read actual temperature from extruder -// if extruder, read target temperature from host +/// if host, read actual temperature from extruder +/// if extruder, read target temperature from host uint16_t read_temperature(uint8_t index); -// if host, set DIOs on extruder controller -// if extruder, report DIO state +/// if host, set DIOs on extruder controller +/// if extruder, report DIO state void set_dio(uint8_t index, uint8_t value); -// if host, read extruder DIO inputs -// if extruder, set DIO outputs +/// if host, read extruder DIO inputs +/// if extruder, set DIO outputs uint8_t get_dio(uint8_t index); -// set error code to send to other end +/// set error code to send to other end void set_err(uint8_t err); -// get error code sent from other end +/// get error code sent from other end uint8_t get_err(void); -// if host, send packet to extruder -// if extruder, return packet to host +/// if host, send packet to extruder +/// if extruder, return packet to host void start_send(void); #define FLAG_RX_IN_PROGRESS 1 diff --git a/mendel.c b/mendel.c index 29495c4..9d1f3bb 100644 --- a/mendel.c +++ b/mendel.c @@ -1,3 +1,28 @@ +/** \file + \brief Main file - this is where it all starts, and ends +*/ + +/** \mainpage Teacup Reprap Firmware + \section intro_sec Introduction + Teacup Reprap Firmware (originally named FiveD on Arduino) is a firmware package for numerous reprap electronics sets. + + Please see README for a full introduction and long-winded waffle about this project + \section install_sec Installation + \subsection step1 Step 1: Download + \code git clone git://github.com/triffid/Teacup_Firmware \endcode + \subsection step2 Step 2: configure + \code cp config.[yourboardhere].h config.h \endcode + Edit config.h to suit your machone + Edit Makefile to select the correct chip and programming settings + \subsection step3 Step 3: Compile + \code make \endcode + \code make program \endcode + \subsection step4 Step 4: Test! + \code ./func.sh mendel_reset + ./func.sh mendel_talk + M115 + ctrl+d \endcode +*/ #include #include @@ -22,17 +47,18 @@ #include "clock.h" #include "intercom.h" +/// initialise all I/O - set pins as input or output, turn off unused subsystems, etc void io_init(void) { // disable modules we don't use #ifdef PRR PRR = MASK(PRTWI) | MASK(PRADC) | MASK(PRSPI); #elif defined PRR0 PRR0 = MASK(PRTWI) | MASK(PRADC) | MASK(PRSPI); - #if defined(PRUSART3) + #if defined(PRUSART3) // don't use USART2 or USART3- leave USART1 for GEN3 and derivatives PRR1 |= MASK(PRUSART3) | MASK(PRUSART2); #endif - #if defined(PRUSART2) + #if defined(PRUSART2) // don't use USART2 or USART3- leave USART1 for GEN3 and derivatives PRR1 |= MASK(PRUSART2); #endif @@ -83,7 +109,7 @@ void io_init(void) { #ifdef Y_ENABLE_PIN WRITE(Y_ENABLE_PIN, 1); SET_OUTPUT(Y_ENABLE_PIN); #endif - + #if defined Z_STEP_PIN && defined Z_DIR_PIN WRITE(Z_STEP_PIN, 0); SET_OUTPUT(Z_STEP_PIN); WRITE(Z_DIR_PIN, 0); SET_OUTPUT(Z_DIR_PIN); @@ -107,7 +133,7 @@ void io_init(void) { #ifdef Z_ENABLE_PIN WRITE(Z_ENABLE_PIN, 1); SET_OUTPUT(Z_ENABLE_PIN); #endif - + #if defined E_STEP_PIN && defined E_DIR_PIN WRITE(E_STEP_PIN, 0); SET_OUTPUT(E_STEP_PIN); WRITE(E_DIR_PIN, 0); SET_OUTPUT(E_DIR_PIN); @@ -136,7 +162,7 @@ void io_init(void) { OCR3A = 0; OCR3B = 0; #endif - + #ifdef TCCR4A TCCR4A = MASK(WGM40); TCCR4B = MASK(WGM42) | MASK(CS40); @@ -144,7 +170,7 @@ void io_init(void) { OCR4A = 0; OCR4B = 0; #endif - + #ifdef TCCR5A TCCR5A = MASK(WGM50); TCCR5B = MASK(WGM52) | MASK(CS50); @@ -152,7 +178,7 @@ void io_init(void) { OCR5A = 0; OCR5B = 0; #endif - + #ifdef STEPPER_ENABLE_PIN power_off(); #endif @@ -164,7 +190,7 @@ void io_init(void) { WRITE(MISO, 1); SET_INPUT(MISO); WRITE(SS, 1); SET_OUTPUT(SS); #endif - + #ifdef TEMP_INTERCOM // Enable the RS485 transceiver SET_OUTPUT(RX_ENABLE_PIN); @@ -174,6 +200,7 @@ void io_init(void) { #endif } +/// Startup code, run when we come out of reset void init(void) { // set up watchdog wd_init(); @@ -211,6 +238,9 @@ void init(void) { } +/// this is where it all starts, and ends +/// +/// just run init(), then run an endless loop where we pass characters from the serial RX buffer to gcode_parse_char() and check the clocks int main (void) { init(); diff --git a/pinio.h b/pinio.h index 0a85b61..c38a23e 100644 --- a/pinio.h +++ b/pinio.h @@ -1,3 +1,7 @@ +/** \file + \brief I/O primitives - step, enable, direction, endstops etc +*/ + #ifndef _PINIO_H #define _PINIO_H diff --git a/serial.c b/serial.c index 191c18d..999eca0 100644 --- a/serial.c +++ b/serial.c @@ -1,29 +1,52 @@ #include "serial.h" +/** \file + \brief Serial subsystem + + Teacup's serial subsystem is a powerful, thoroughly tested and highly modular serial management system. + + It uses ringbuffers for both transmit and receive, and intelligently decides whether to wait or drop transmitted characters if the buffer is full. + + It also supports XON/XOFF flow control of the receive buffer, to help avoid overruns. +*/ + #include #include "config.h" #include "arduino.h" +/// size of TX and RX buffers. MUST be a \f$2^n\f$ value #define BUFSIZE 64 +/// ascii XOFF character #define ASCII_XOFF 19 +/// ascii XON character #define ASCII_XON 17 +/// rx buffer head pointer. Points to next available space. volatile uint8_t rxhead = 0; +/// rx buffer tail pointer. Points to last character in buffer volatile uint8_t rxtail = 0; +/// rx buffer volatile uint8_t rxbuf[BUFSIZE]; +/// tx buffer head pointer. Points to next available space. volatile uint8_t txhead = 0; +/// tx buffer tail pointer. Points to last character in buffer volatile uint8_t txtail = 0; +/// tx buffer volatile uint8_t txbuf[BUFSIZE]; +/// check if we can read from this buffer #define buf_canread(buffer) ((buffer ## head - buffer ## tail ) & (BUFSIZE - 1)) -#define buf_canwrite(buffer) ((buffer ## tail - buffer ## head - 1) & (BUFSIZE - 1)) - -#define buf_push(buffer, data) do { buffer ## buf[buffer ## head] = data; buffer ## head = (buffer ## head + 1) & (BUFSIZE - 1); } while (0) +/// read from buffer #define buf_pop(buffer, data) do { data = buffer ## buf[buffer ## tail]; buffer ## tail = (buffer ## tail + 1) & (BUFSIZE - 1); } while (0) +/// check if we can write to this buffer +#define buf_canwrite(buffer) ((buffer ## tail - buffer ## head - 1) & (BUFSIZE - 1)) +/// write to buffer +#define buf_push(buffer, data) do { buffer ## buf[buffer ## head] = data; buffer ## head = (buffer ## head + 1) & (BUFSIZE - 1); } while (0) + /* ringbuffer logic: head = written data pointer @@ -55,6 +78,9 @@ volatile uint8_t txbuf[BUFSIZE]; volatile uint8_t flowflags = FLOWFLAG_SEND_XON; #endif +/// initialise serial subsystem +/// +/// set up baud generator and interrupts, clear buffers void serial_init() { #if BAUD > 38401 @@ -75,6 +101,9 @@ void serial_init() Interrupts */ +/// receive interrupt +/// +/// we have received a character, stuff it in the rx buffer if we can, or drop it if we can't #ifdef USART_RX_vect ISR(USART_RX_vect) #else @@ -101,6 +130,9 @@ ISR(USART0_RX_vect) #endif } +/// transmit buffer ready interrupt +/// +/// provide the next character to transmit if we can, otherwise disable this interrupt #ifdef USART_UDRE_vect ISR(USART_UDRE_vect) #else @@ -128,11 +160,13 @@ ISR(USART0_UDRE_vect) Read */ +/// check how many characters can be read uint8_t serial_rxchars() { return buf_canread(rx); } +/// read one character uint8_t serial_popchar() { uint8_t c = 0; @@ -156,6 +190,7 @@ uint8_t serial_popchar() Write */ +/// send one character void serial_writechar(uint8_t data) { // check if interrupts are enabled @@ -174,6 +209,7 @@ void serial_writechar(uint8_t data) UCSR0B |= MASK(UDRIE0); } +/// send a whole block void serial_writeblock(void *data, int datalen) { int i; @@ -182,6 +218,7 @@ void serial_writeblock(void *data, int datalen) serial_writechar(((uint8_t *) data)[i]); } +/// send a string- look for null byte instead of expecting a length void serial_writestr(uint8_t *data) { uint8_t i = 0, r; @@ -190,8 +227,8 @@ void serial_writestr(uint8_t *data) serial_writechar(r); } -/* - Write from FLASH +/** + Write block from FLASH Extensions to output flash memory pointers. This prevents the data to become part of the .data segment instead of the .code segment. That means @@ -200,7 +237,6 @@ void serial_writestr(uint8_t *data) For single character writes (i.e. '\n' instead of "\n"), using serial_writechar() directly is the better choice. */ - void serial_writeblock_P(PGM_P data, int datalen) { int i; @@ -209,6 +245,7 @@ void serial_writeblock_P(PGM_P data, int datalen) serial_writechar(pgm_read_byte(&data[i])); } +/// Write string from FLASH void serial_writestr_P(PGM_P data) { uint8_t r, i = 0; diff --git a/sermsg.c b/sermsg.c index baed297..429c144 100644 --- a/sermsg.c +++ b/sermsg.c @@ -1,7 +1,14 @@ #include "sermsg.h" +/** \file sermsg.c + \brief primitives for sending numbers over the serial link +*/ + #include "serial.h" +/** write a single hex digit + \param v hex digit to write, higher nibble ignored +*/ void serwrite_hex4(uint8_t v) { v &= 0xF; if (v < 10) @@ -10,23 +17,36 @@ void serwrite_hex4(uint8_t v) { serial_writechar('A' - 10 + v); } +/** write a pair of hex digits + \param v byte to write. One byte gives two hex digits +*/ void serwrite_hex8(uint8_t v) { serwrite_hex4(v >> 4); serwrite_hex4(v & 0x0F); } +/** write four hex digits + \param v word to write +*/ void serwrite_hex16(uint16_t v) { serwrite_hex8(v >> 8); serwrite_hex8(v & 0xFF); } +/** write eight hex digits + \param v long word to write +*/ void serwrite_hex32(uint32_t v) { serwrite_hex16(v >> 16); serwrite_hex16(v & 0xFFFF); } +/// list of powers of ten, used for dividing down decimal numbers for sending, and also for our crude floating point algorithm const uint32_t powers[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000}; +/** write decimal digits from a long unsigned int + \param v number to send +*/ void serwrite_uint32(uint32_t v) { uint8_t e, t; @@ -43,6 +63,9 @@ void serwrite_uint32(uint32_t v) { while (e--); } +/** write decimal digits from a long signed int + \param v number to send +*/ void serwrite_int32(int32_t v) { if (v < 0) { serial_writechar('-'); diff --git a/sersendf.c b/sersendf.c index baa158e..f6dca87 100644 --- a/sersendf.c +++ b/sersendf.c @@ -1,17 +1,22 @@ #include "sersendf.h" +/** \file sersendf.c + \brief Simplified printf implementation +*/ + #include #include #include "serial.h" #include "sermsg.h" +/// for sending hex data PGM_P str_ox = "0x"; // void sersendf(char *format, ...) { // va_list args; // va_start(args, format); -// +// // uint16_t i = 0; // uint8_t c, j = 0; // while ((c = format[i++])) { @@ -69,6 +74,28 @@ PGM_P str_ox = "0x"; // va_end(args); // } +/** \brief Simplified printf + \param format pointer to output format specifier string stored in FLASH. + \param ... output data + + Implements only a tiny subset of printf's format specifiers :- + + %[ls][udcx%] + + l - following data is (32 bits)\n + s - following data is short (8 bits)\n + none - following data is 16 bits. + + u - unsigned int\n + d - signed int\n + c - character\n + x - hex\n + % - send a literal % character + + Example: + + \code sersendf_P(PSTR("X:%ld Y:%ld temp:%u.%d flags:%sx Q%su/%su%c\n"), target.X, target.Y, current_temp >> 2, (current_temp & 3) * 25, dda.allflags, mb_head, mb_tail, (queue_full()?'F':(queue_empty()?'E':' '))) \endcode +*/ void sersendf_P(PGM_P format, ...) { va_list args; va_start(args, format); diff --git a/temp.c b/temp.c index b0159f5..4c25958 100644 --- a/temp.c +++ b/temp.c @@ -1,5 +1,11 @@ #include "temp.h" +/** \file + \brief Manage temperature sensors + + \note \b ALL temperatures are stored as 14.2 fixed point in teacup, so we have a range of 0 - 16383.75 celsius and a precision of 0.25 celsius. That includes the ThermistorTable, which is why you can't copy and paste one from other firmwares which don't do this. +*/ + #include #include #include @@ -20,13 +26,15 @@ typedef enum { TCOPEN } temp_flags_enum; +/// holds metadata for each temperature sensor typedef struct { - temp_type_t temp_type; - uint8_t temp_pin; - heater_t heater; + temp_type_t temp_type; ///< type of sensor + uint8_t temp_pin; ///< pin that sensor is on + heater_t heater; ///< associated heater if any } temp_sensor_definition_t; #undef DEFINE_TEMP_SENSOR +/// help build list of sensors from entries in config.h #define DEFINE_TEMP_SENSOR(name, type, pin) { (type), (pin), (HEATER_ ## name) }, static const temp_sensor_definition_t temp_sensors[NUM_TEMP_SENSORS] = { @@ -34,16 +42,16 @@ static const temp_sensor_definition_t temp_sensors[NUM_TEMP_SENSORS] = }; #undef DEFINE_TEMP_SENSOR -// this struct holds the runtime sensor data- read temperatures, targets, etc +/// this struct holds the runtime sensor data- read temperatures, targets, etc struct { - temp_flags_enum temp_flags; - - uint16_t last_read_temp; - uint16_t target_temp; - - uint8_t temp_residency; - - uint16_t next_read_time; + temp_flags_enum temp_flags; ///< flags + + uint16_t last_read_temp; ///< last received reading + uint16_t target_temp; ///< manipulate attached heater to attempt to achieve this value + + uint8_t temp_residency; ///< how long have we been close to target temperature? + + uint16_t next_read_time; ///< how long until we can read this sensor again? } temp_sensors_runtime[NUM_TEMP_SENSORS]; #ifdef TEMP_MAX6675 @@ -58,6 +66,7 @@ struct { #include "analog.h" #endif +/// set up temp sensors. Currently only the 'intercom' sensor needs initialisation. void temp_init() { temp_sensor_t i; for (i = 0; i < NUM_TEMP_SENSORS; i++) { @@ -93,6 +102,7 @@ void temp_init() { } } +/// called every 10ms from clock.c - check all temp sensors that are ready for checking void temp_sensor_tick() { temp_sensor_t i = 0; for (; i < NUM_TEMP_SENSORS; i++) { @@ -110,29 +120,29 @@ void temp_sensor_tick() { #elif defined PRR0 PRR0 &= ~MASK(PRSPI); #endif - + SPCR = MASK(MSTR) | MASK(SPE) | MASK(SPR0); - + // enable TT_MAX6675 WRITE(SS, 0); - + // ensure 100ns delay - a bit extra is fine delay(1); - + // read MSB SPDR = 0; for (;(SPSR & MASK(SPIF)) == 0;); temp = SPDR; temp <<= 8; - + // read LSB SPDR = 0; for (;(SPSR & MASK(SPIF)) == 0;); temp |= SPDR; - + // disable TT_MAX6675 WRITE(SS, 1); - + temp_sensors_runtime[i].temp_flags = 0; if ((temp & 0x8002) == 0) { // got "device id" @@ -145,13 +155,13 @@ void temp_sensor_tick() { temp = temp >> 3; } } - + // this number depends on how frequently temp_sensor_tick is called. the MAX6675 can give a reading every 0.22s, so set this to about 250ms temp_sensors_runtime[i].next_read_time = 25; - + break; #endif /* TEMP_MAX6675 */ - + #ifdef TEMP_THERMISTOR case TT_THERMISTOR: do { @@ -175,7 +185,7 @@ void temp_sensor_tick() { // x₁= temptable[j][0] // y₀= temptable[j-1][1] // y₁= temptable[j][1] - // y = + // y = // Wikipedia's example linear interpolation formula. temp = ( // ((x - x₀)y₁ @@ -185,7 +195,7 @@ void temp_sensor_tick() { // (x₁-x) (pgm_read_word(&(temptable[j][0])) - (uint32_t)temp) // y₀ ) - * pgm_read_word(&(temptable[j-1][1]))) + * pgm_read_word(&(temptable[j-1][1]))) // / / // (x₁ - x₀) @@ -201,7 +211,7 @@ void temp_sensor_tick() { if (debug_flags & DEBUG_PID) sersendf_P(PSTR(" Sensor:%d\n"),i); #endif - + //Clamp for overflows if (j == NUMTEMPS) @@ -211,17 +221,17 @@ void temp_sensor_tick() { } while (0); break; #endif /* TEMP_THERMISTOR */ - + #ifdef TEMP_AD595 case TT_AD595: temp = analog_read(temp_sensors[i].temp_pin); - + // convert // >>8 instead of >>10 because internal temp is stored as 14.2 fixed point temp = (temp * 500L) >> 8; - + temp_sensors_runtime[i].next_read_time = 0; - + break; #endif /* TEMP_AD595 */ @@ -239,7 +249,7 @@ void temp_sensor_tick() { break; #endif /* TEMP_INTERCOM */ - + #ifdef TEMP_DUMMY case TT_DUMMY: temp = temp_sensors_runtime[i].last_read_temp; @@ -258,7 +268,7 @@ void temp_sensor_tick() { break; } temp_sensors_runtime[i].last_read_temp = temp; - + if (labs(temp - temp_sensors_runtime[i].target_temp) < TEMP_HYSTERESIS) { if (temp_sensors_runtime[i].temp_residency < TEMP_RESIDENCY_TIME) temp_sensors_runtime[i].temp_residency++; @@ -266,7 +276,7 @@ void temp_sensor_tick() { else { temp_sensors_runtime[i].temp_residency = 0; } - + if (temp_sensors[i].heater < NUM_HEATERS) { heater_tick(temp_sensors[i].heater, i, temp_sensors_runtime[i].last_read_temp, temp_sensors_runtime[i].target_temp); } @@ -274,6 +284,8 @@ void temp_sensor_tick() { } } +/// report whether all temp sensors are reading their target temperatures +/// used for M109 and friends uint8_t temp_achieved() { temp_sensor_t i; uint8_t all_ok = 255; @@ -285,6 +297,9 @@ uint8_t temp_achieved() { return all_ok; } +/// specify a target temperature +/// \param index sensor to set a target for +/// \param temperature target temperature to aim for void temp_set(temp_sensor_t index, uint16_t temperature) { if (index >= NUM_TEMP_SENSORS) return; @@ -297,6 +312,8 @@ void temp_set(temp_sensor_t index, uint16_t temperature) { #endif } +/// return most recent reading for a sensor +/// \param index sensor to read uint16_t temp_get(temp_sensor_t index) { if (index >= NUM_TEMP_SENSORS) return 0; @@ -306,6 +323,8 @@ uint16_t temp_get(temp_sensor_t index) { // extruder doesn't have sersendf_P #ifndef EXTRUDER +/// send temperatures to host +/// \param index sensor value to send void temp_print(temp_sensor_t index) { uint8_t c = 0; @@ -318,7 +337,7 @@ void temp_print(temp_sensor_t index) { #ifdef HEATER_BED uint8_t b = 0; b = (temp_sensors_runtime[HEATER_BED].last_read_temp & 3) * 25; - + sersendf_P(PSTR(" B:%u.%u"), temp_sensors_runtime[HEATER_bed].last_read_temp >> 2 , b); #endif diff --git a/timer.c b/timer.c index 4f93dd9..308c467 100644 --- a/timer.c +++ b/timer.c @@ -1,5 +1,15 @@ #include "timer.h" +/** \file + \brief Timer management - step pulse clock and system clock + + Teacup uses timer1 to generate both step pulse clock and system clock. + + We achieve this by using the output compare registers to generate the two clocks while the timer free-runs. + + Teacup has tried numerous timer management methods, and this is the best so far. +*/ + #include #include "arduino.h" @@ -9,24 +19,28 @@ #include "dda_queue.h" #endif -/* - how often we overflow and update our clock; with F_CPU=16MHz, max is < 4.096ms (TICK_TIME = 65535) -*/ +/// how often we overflow and update our clock; with F_CPU=16MHz, max is < 4.096ms (TICK_TIME = 65535) #define TICK_TIME 2 MS +/// convert back to ms from cpu ticks so our system clock runs properly if you change TICK_TIME #define TICK_TIME_MS (TICK_TIME / (F_CPU / 1000)) +/// time until next step, as output compare register is too small for long step times volatile uint32_t next_step_time; +/// every time our clock fires, we increment this so we know when 10ms has elapsed uint8_t clock_counter_10ms = 0; +/// keep track of when 250ms has elapsed uint8_t clock_counter_250ms = 0; +/// keep track of when 1s has elapsed uint8_t clock_counter_1s = 0; +/// flags to tell main loop when above have elapsed volatile uint8_t clock_flag = 0; -// comparator B is the "clock", happens every TICK_TIME +/// comparator B is the system clock, happens every TICK_TIME ISR(TIMER1_COMPB_vect) { // set output compare register to the next clock tick OCR1B = (OCR1B + TICK_TIME) & 0xFFFF; - + /* clock stuff */ @@ -34,12 +48,12 @@ ISR(TIMER1_COMPB_vect) { if (clock_counter_10ms >= 10) { clock_counter_10ms -= 10; clock_flag |= CLOCK_FLAG_10MS; - + clock_counter_250ms += 1; if (clock_counter_250ms >= 25) { clock_counter_250ms -= 25; clock_flag |= CLOCK_FLAG_250MS; - + clock_counter_1s += 1; if (clock_counter_1s >= 4) { clock_counter_1s -= 4; @@ -54,18 +68,18 @@ void timer1_compa_isr(void) __attribute__ ((hot)); void timer1_compa_isr() { // led on WRITE(SCK, 1); - + // disable this interrupt. if we set a new timeout, it will be re-enabled when appropriate TIMSK1 &= ~MASK(OCIE1A); - + // stepper tick queue_step(); - + // led off WRITE(SCK, 0); } -// comparator A is the step timer. It has higher priority then B. +/// comparator A is the step timer. It has higher priority then B. ISR(TIMER1_COMPA_vect) { // Check if this is a real step, or just a next_step_time "overflow" if (next_step_time < 65536) { @@ -73,7 +87,7 @@ ISR(TIMER1_COMPA_vect) { timer1_compa_isr(); return; } - + next_step_time -= 65536; // similar algorithm as described in setTimer below. @@ -87,6 +101,8 @@ ISR(TIMER1_COMPA_vect) { } #endif /* ifdef HOST */ +/// initialise timer and enable system clock interrupt. +/// step interrupt is enabled later when we start using it void timer_init() { // no outputs @@ -100,6 +116,7 @@ void timer_init() } #ifdef HOST +/// specify how long until the step timer should fire void setTimer(uint32_t delay) { // save interrupt flag @@ -110,7 +127,7 @@ void setTimer(uint32_t delay) // re-enable clock interrupt in case we're recovering from emergency stop TIMSK1 |= MASK(OCIE1B); - + if (delay > 0) { if (delay <= 16) { // unfortunately, force registers don't trigger an interrupt, so we do the following @@ -118,7 +135,7 @@ void setTimer(uint32_t delay) timer1_compa_isr(); } else { - // Assume all steps belong to one move. Within one move the delay is + // Assume all steps belong to one move. Within one move the delay is // from one step to the next one, which should be more or less the same // as from one step interrupt to the next one. The last step interrupt happend // at OCR1A, so start delay from there. @@ -143,7 +160,7 @@ void setTimer(uint32_t delay) else { OCR1A = step_start; } - + TIMSK1 |= MASK(OCIE1A); } } else { @@ -151,11 +168,12 @@ void setTimer(uint32_t delay) next_step_time = 0; TIMSK1 &= ~MASK(OCIE1A); } - + // restore interrupt flag SREG = sreg; } +/// stop timers - emergency stop void timer_stop() { // disable all interrupts TIMSK1 = 0; diff --git a/watchdog.c b/watchdog.c index 28cbe32..e4e4306 100644 --- a/watchdog.c +++ b/watchdog.c @@ -1,6 +1,15 @@ - #include "watchdog.h" +/** \file + \brief Watchdog - reset if main loop doesn't run for too long + + The usefulness of this feature is questionable at best. + + What do you think will happen if your avr resets in the middle of a print? + + Is that preferable to it simply locking up? +*/ + #ifdef USE_WATCHDOG #include @@ -26,16 +35,18 @@ ISR(WDT_vect) { wd_flag |= 1; } +/// intialise watchdog void wd_init() { // check if we were reset by the watchdog // if (mcusr_mirror & MASK(WDRF)) // serial_writestr_P(PSTR("Watchdog Reset!\n")); - // 0.25s timeout, interrupt and system reset + // 0.5s timeout, interrupt and system reset wdt_enable(WDTO_500MS); WDTCSR |= MASK(WDIE); } +/// reset watchdog. MUST be called every 0.5s after init or avr will reset. void wd_reset() { wdt_reset(); if (wd_flag) {