From 934e73454757d1d40941183de4402163559f3173 Mon Sep 17 00:00:00 2001 From: Wei Shuai Date: Sat, 26 Oct 2013 21:46:16 +0800 Subject: [PATCH 01/28] remove AVR folder this branch will be for STM8L MCU only --- ports/avr/Doxyfile | 1161 ---------------------------------- ports/avr/Makefile | 120 ---- ports/avr/README | 334 ---------- ports/avr/atomport-asm.s | 409 ------------ ports/avr/atomport-private.h | 39 -- ports/avr/atomport-tests.h | 58 -- ports/avr/atomport.c | 355 ----------- ports/avr/atomport.h | 63 -- ports/avr/gdb.txt | 6 - ports/avr/tests-main.c | 302 --------- ports/avr/uart.c | 109 ---- ports/avr/uart.h | 25 - 12 files changed, 2981 deletions(-) delete mode 100644 ports/avr/Doxyfile delete mode 100644 ports/avr/Makefile delete mode 100644 ports/avr/README delete mode 100644 ports/avr/atomport-asm.s delete mode 100644 ports/avr/atomport-private.h delete mode 100644 ports/avr/atomport-tests.h delete mode 100644 ports/avr/atomport.c delete mode 100644 ports/avr/atomport.h delete mode 100644 ports/avr/gdb.txt delete mode 100644 ports/avr/tests-main.c delete mode 100644 ports/avr/uart.c delete mode 100644 ports/avr/uart.h diff --git a/ports/avr/Doxyfile b/ports/avr/Doxyfile deleted file mode 100644 index e6f65710..00000000 --- a/ports/avr/Doxyfile +++ /dev/null @@ -1,1161 +0,0 @@ -# Doxyfile 1.3.9.1 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = atomthreads - -# 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 = doxygen-avr - -# 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: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, -# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, -# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, -# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, -# Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# This tag can be used to specify the encoding used in the generated output. -# The encoding is not always determined by the language that is chosen, -# but also whether or not the output is meant for Windows or non-Windows users. -# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES -# forces the Windows encoding (this is the default for the Windows binary), -# whereas setting the tag to NO uses a Unix-style encoding (the default for -# all platforms other than Windows). - -USE_WINDOWS_ENCODING = NO - -# 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 = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# 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 the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = NO - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = 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 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 - -# 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 = 4 - -# 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 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 - -#--------------------------------------------------------------------------- -# 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 = YES - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = YES - -# 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 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 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_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 define 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 defines 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. - -SHOW_DIRECTORIES = YES - -#--------------------------------------------------------------------------- -# 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_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. - -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 = - -# 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++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp -# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm - -FILE_PATTERNS = - -# 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 = - -# 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. - -EXCLUDE_PATTERNS = - -# 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 (the default) -# 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 (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# 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 = NO - -# 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 = - -# 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 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 compressed 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 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 - -# 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 [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag 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 (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# 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. - -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, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# 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 = NO - -# 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 = NO - -# 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 - -#--------------------------------------------------------------------------- -# 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_PREDEFINED 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 is superseded by the HAVE_DOT option below. This is only a fallback. It is -# recommended to install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# 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 - -# 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 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 tags 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 GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = 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 on 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 MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_HEIGHT = 1024 - -# 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 a graph may be further truncated if the graph's image dimensions are -# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). -# If 0 is used for the depth value (the default), the graph is not depth-constrained. - -MAX_DOT_GRAPH_DEPTH = 0 - -# 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 - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff --git a/ports/avr/Makefile b/ports/avr/Makefile deleted file mode 100644 index c5f214be..00000000 --- a/ports/avr/Makefile +++ /dev/null @@ -1,120 +0,0 @@ -############ -# Settings # -############ - -# Build all test applications: -# make -# -# Program a test application using UISP (appname => test app e.g. sems1): -# make program app=appname - -# Location of build tools and atomthreads sources -KERNEL_DIR=../../kernel -TESTS_DIR=../../tests -CC=/usr/bin/avr-gcc -OBJCOPY=/usr/bin/avr-objcopy -SIZE=/usr/bin/avr-size -UISP=/usr/bin/uisp - -# Modify this to the device name of the UART used for UISP -UISP_DEV=/dev/ttyUSB0 - -# Modify this to the CPU you are using -PART=atmega16 - -# Enable stack-checking. WARNING: the full automated test suite currently -# requires a little over 1KB RAM with stack-checking enabled. If you are -# using a device with 1KB internal SRAM and no external SRAM then you -# must disable stack-checking to run all of the automated tests. -#STACK_CHECK=true - -# Directory for built objects -BUILD_DIR=build - -# Port/application object files -APP_OBJECTS = atomport.o uart.o tests-main.o -APP_ASM_OBJECTS = atomport-asm.o - -# Kernel object files -KERNEL_OBJECTS = atomkernel.o atomsem.o atommutex.o atomtimer.o atomqueue.o - -# Collection of built objects (excluding test applications) -ALL_OBJECTS = $(APP_OBJECTS) $(APP_ASM_OBJECTS) $(KERNEL_OBJECTS) -BUILT_OBJECTS = $(patsubst %,$(BUILD_DIR)/%,$(ALL_OBJECTS)) - -# Test object files (dealt with separately as only one per application build) -TEST_OBJECTS = $(notdir $(patsubst %.c,%.o,$(wildcard $(TESTS_DIR)/*.c))) - -# Target application filenames (.elf and .hex) for each test object -TEST_ELFS = $(patsubst %.o,%.elf,$(TEST_OBJECTS)) -TEST_HEXS = $(patsubst %.o,%.hex,$(TEST_OBJECTS)) - -# Search build/output directory for dependencies -vpath %.o ./$(BUILD_DIR) -vpath %.elf ./$(BUILD_DIR) -vpath %.hex ./$(BUILD_DIR) - -# GCC flags -CFLAGS=-g -mmcu=$(PART) -Wall -Werror - -# Enable stack-checking (disable if not required) -ifeq ($(STACK_CHECK),true) -CFLAGS += -DATOM_STACK_CHECKING -endif - - -################# -# Build targets # -################# - -# All tests -all: $(BUILD_DIR) $(TEST_HEXS) Makefile - -# Make build/output directory -$(BUILD_DIR): - mkdir $(BUILD_DIR) - -# Test HEX files (one application build for each test) -$(TEST_HEXS): %.hex: %.elf - @echo Building $@ - $(OBJCOPY) -j .text -j .data -O ihex $(BUILD_DIR)/$< $(BUILD_DIR)/$@ - -# Test ELF files (one application build for each test) -$(TEST_ELFS): %.elf: %.o $(KERNEL_OBJECTS) $(APP_OBJECTS) $(APP_ASM_OBJECTS) - $(CC) $(CFLAGS) $(BUILD_DIR)/$(notdir $<) $(BUILT_OBJECTS) --output $(BUILD_DIR)/$@ -Wl,-Map,$(BUILD_DIR)/$(basename $@).map - -# Kernel objects builder -$(KERNEL_OBJECTS): %.o: $(KERNEL_DIR)/%.c - $(CC) -c $(CFLAGS) -I. $< -o $(BUILD_DIR)/$(notdir $@) - -# Test objects builder -$(TEST_OBJECTS): %.o: $(TESTS_DIR)/%.c - $(CC) -c $(CFLAGS) -I. -I$(KERNEL_DIR) $< -o $(BUILD_DIR)/$(notdir $@) - -# Application C objects builder -$(APP_OBJECTS): %.o: ./%.c - $(CC) -c $(CFLAGS) -I. -I$(KERNEL_DIR) -I$(TESTS_DIR) $< -o $(BUILD_DIR)/$(notdir $@) - -# Application asm objects builder -$(APP_ASM_OBJECTS): %.o: ./%.s - $(CC) -c $(CFLAGS) -x assembler-with-cpp -I. -I$(KERNEL_DIR) $< -o $(BUILD_DIR)/$(notdir $@) - -# .lst file builder -%.lst: %.c - $(CC) $(CFLAGS) -I. -I$(KERNEL_DIR) -I$(TESTS_DIR) -Wa,-al $< > $@ - -# Clean -clean: - rm -f *.o *.elf *.map *.hex *.bin *.lst - rm -rf doxygen-kernel - rm -rf doxygen-avr - rm -rf build - -# Send to STK500 -program : $(BUILD_DIR)/$(app).hex - $(SIZE) -C $(BUILD_DIR)/$(app).elf - $(UISP) -dprog=stk500 -dserial=$(UISP_DEV) -dpart=$(PART) --erase --upload --verify if=$(BUILD_DIR)/$(app).hex - -doxygen: - doxygen $(KERNEL_DIR)/Doxyfile - doxygen ./Doxyfile diff --git a/ports/avr/README b/ports/avr/README deleted file mode 100644 index df61880c..00000000 --- a/ports/avr/README +++ /dev/null @@ -1,334 +0,0 @@ ---------------------------------------------------------------------------- - -Library: Atomthreads -Author: Kelvin Lawson -Website: http://atomthreads.com -License: BSD Revised - ---------------------------------------------------------------------------- - -AVR/ATMEGA PORT - -This folder contains a port of the Atomthreads real time kernel for the -AVR/ATmega processor architecture. - -All of the cross-platform kernel code is contained in the top-level -'kernel' folder, while ports to specific CPU architectures are contained in -the 'ports' folder tree. A port to a CPU architecture can comprise just one -or two modules which provide the architecture-specific functionality, such -as the context-switch routine which saves and restores processor registers -on a thread switch. In this case, the kernel port is split into two files: - - * atomport.c: Those functions which can be written in C - * atomport-asm.s: The main register save/restore assembler routines - -Each Atomthreads port requires also a header file which describes various -architecture-specific details such as appropriate types for 8-bit, 16-bit -etc variables, the port's system tick frequency, and macros for performing -interrupt lockouts / critical sections: - - * atomuser.h: Port-specific header required by the kernel for each port - -A couple of additional source files are also included here: - - * tests-main.c: Main application file (used for launching automated tests) - * uart.c: Simple driver for the ATmega UART - -Atomthreads includes a suite of automated tests which prove the key OS -functionality, and can be used with any architecture ports. This port -provides an easy mechanism for building, downloading and running the test -suite to prove the OS on your target. - -The port was carried out and tested on both an ATmega16 and ATmega32 -running within an STK500 board, utilising the gcc-avr tools. It is possible -to use it with other processors in the ATmega range, as well as other -hardware platforms and compilers, with minimal changes. Platform and -compiler specific code has been kept to an absolute minimum. - - ---------------------------------------------------------------------------- - -PREREQUISITES - -The port works out-of-the-box with the GCC tools (for building) and UISP -(for programming). It can be built on any OS for which gcc-avr is -available, but by way of example you can install all of the required tools -on Ubuntu/Linux as follows: - - * sudo apt-get install gcc-avr binutils-avr avr-libc uisp - -Use with alternative compiler tools may require some modification, but you -can easily replace UISP by your own favourite programmer if required. - - ---------------------------------------------------------------------------- - -BUILDING THE SOURCE - -A Makefile is provided for building the kernel, port and automated tests. -The full build is carried out using simply: - - * make - -All objects are built into the 'build' folder under ports/avr. The build -process builds separate target applications for each automated test, and -appropriate ELF or HEX files can be found in the build folder ready for -downloading to and running on the target. Because of the limited resources -on the ATmega, and the large amount of automated tests, each test is built -and run as a separate application. - - -All built objects etc can be cleaned using: - - * make clean - - -The Atomthreads sources are documented using Doxygen markup. You can build -both the kernel and AVR port documentation from this folder using: - - * make doxygen - - ---------------------------------------------------------------------------- - -PROGRAMMING TO THE TARGET DEVICE - -Application HEX files which are built into the build folder can be -downloaded to the target using: - - * make program app= - -For example to download the 'sem1.hex' test application to the target use: - - * make program app=sem1 - -This uses UISP which will write the application into flash and reset the -CPU to start running the program automatically. - - ---------------------------------------------------------------------------- - -STK500 SPECIFICS - -If the STK500 is used, you should connect your serial programming cable to -the "RS232 CTRL" connector. - -The test applications make use of a LED to indicate test pass/fail status. -This is currently configured to use a bit in PORTB, which on the STK500 -maps to a LED on the carrier board. You may change the port and register -bit in tests-main.c to utilise a different pin on other hardware platforms. -You may also completely omit the LED flashing in the test application if -you prefer to use the UART for monitoring test status. - -The test applications also make use of the UART to print out pass/fail -indications and other information. For this you should connect a serial -debug cable to the STK500 "RS232 SPARE" connector. You should also connect -PD0/1 to "RS232 SPARE RXD/TXD" respectively using a two-wire link. Use of -a UART is not required if you prefer to use the LED or some other method -of notifying test pass/fail status. - - ---------------------------------------------------------------------------- - -RUNNING THE AUTOMATED TESTS - -Atomthreads contains a set of generic kernel tests which can be run on any -port to prove that all core functionality is working on your target. In -order to accommodate a full testing regime, a large number of test threads -are spawned which on ATmega platforms requires at least 1KB and possibly -more RAM. Bear this in mind if you wish to run all of the automated tests -on your target platform. - -The full set of tests can be found in the top-level 'tests' folder. Each of -these tests is built as an independent application in the 'build' folder. -Run them individually using: - - * make program app=testname - -For example to run the 'kern1.c' test use: - - * make program app=kern1 - -Before running the program and data size for the application is printed -out on the terminal. You can use this to verify that your platform has -enough program and data space to run the application. - -To view the test results, connect a serial debug cable to your target -platform (defaults to 9600bps 8N1). On starting, the test applications -print out "Go" on the UART. Once the test is complete they will print -out "Pass" or "Fail", along with other information if the test failed. - -Most of the tests complete within a few seconds, but some (particularly -the stress tests) can take minutes, so be patient. - -Note that some tests utilise four test threads, which together with the -idle thread and main test thread can consume significant RAM resource. -Those tests which utilise four threads will generally only run on -platforms with greater than 1KB RAM. They do currently run on a system -with 1KB RAM but only with stack-checking disabled and this may change -in future as the RAM usage changes. For platforms with only 1KB internal -SRAM you should disable stack-checking by disabling STACK_CHECK in the -Makefile, or ensuring that the ATOM_STACK_CHECKING macro is not defined. -Platforms with only 512 bytes RAM will be unable to run many of the -automated tests. - -The test application also toggles a bit on PORTB to indicate test success -or failure (once per second if the test was successful and once every -1/8 second if the test failed). On the STK500 this can be connected to an -LED for a visual indication of a passed test without the UART. If you do -not wish to use the UART you may use the LED to indicate passed tests; a -UART is not a requirement for running the tests. - -The full suite of tests endeavours to exercise as much of the kernel code -as possible, and can be used for quick confirmation of core OS -functionality if you ever need to make a change to the kernel or port. - -The test application main() is contained in tests-main.c. This initialises -the OS, creates a main thread, and calls out to the test modules. It also -initialises the UART driver and redirects stdout via the UART. - - ---------------------------------------------------------------------------- - -WRITING APPLICATIONS - -The easiest way to start a new application which utilises the Atomthreads -scheduler is to base your main application startup on tests-main.c. This -initialises the OS, sets up a UART and calls out to the test module entry -functions. You can generally simply replace the call to the test modules by -a call to your own application startup code. - - ---------------------------------------------------------------------------- - -PORTING TO OTHER HARDWARE PLATFORMS - -If you are using a CPU other than the ATmega16, change the PART definition -in the Makefile to your own CPU. - -On CPUs with multiple UARTs, the port uses UART0 to output debug -information. If you wish to use an alternative UART you may change the -registers in uart.c. Note that a UART is not vital for Atomthreads -operation anyway, it is only used by the test applications for indicating -test pass/fail status. If you do not wish to use a UART you may instead -flash a LED or use some other indication mechanism. - -The Atomthreads port uses Timer 1 to drive the system tick. If you wish -to use some other timer then you may do so by modifying atomport.c. - -Note that the build scripts make no assumptions about the RAM and program -space available on your platform, partly because you may have external RAM -over and above the ATmega device's internal SRAM. You must, therefore, -ensure that you have sufficient RAM and program space available for the -applications that you build. This information can be obtained by passing -the application ELF filename to the avr-size utility. - - ---------------------------------------------------------------------------- - -RAM FOOTPRINT & STACK USAGE - -The Atomthreads kernel is written in well-structured pure C which is highly -portable and not targeted at any particular compiler or CPU architecture. -For this reason it is not highly optimised for the AVR architecture, and by -its nature will likely have a higher text and data footprint than an RTOS -targeted at the AVR architecture only. - -It is very lightweight compared to many of the alternatives, but if you -have very limited RAM resources then you may prefer to use a more -AVR-specific RTOS such as those with shared stacks or built entirely from -assembler. The emphasis here is on C-based portable, readable and -maintainable code which can run on any CPU architecture, from the 8-bitters -up. - -A good rule of thumb when using Atomthreads on the AVR architecture is that -a minimum of 1KB RAM is required in order to support an application with 4 -or 5 threads and the idle thread. If a minimum of approximately 128 bytes -per thread stack is acceptable then you will benefit from the easy-to-read, -portable implementation of an RTOS herein. - -The major consumer of RAM when using Atomthreads is your thread stacks. -Functionality that is shared between several kernel modules is farmed out -to separate functions, resulting in readable and maintainable code but -with some associated stack cost of calling out to subroutines. Further, -each thread stack is used for saving its own registers on a context -switch, and there is no separate interrupt stack which means that each -thread stack has to be able to cope with the maximum stack usage of the -kernel (and application) interrupt handlers. - -Clearly the stack requirement for each thread depends on what your -application code does, and what memory model is used etc, but generally -you should find that 128 bytes is enough to allow for the thread to be -switched out (and thus save its registers) while deep within a kernel -or application call stack, and similarly enough to provide stack for -interrupt handlers interrupting while the thread is deep within a kernel -or application call stack. You will need to increase this depending on -what level of stack the application code in question requires. - -At this time the maximum stack consumed by the test threads within the -automated test modules is 124 bytes of stack, and the main test thread has -been seen to consume 198 bytes of stack. At this time the queue9 test is -the largest consumer of test thread stack (124 bytes) and the mutex2 and -mutex5 tests consume the largest main thread stack (198 bytes). If your -applications have large amounts of local data or call several subroutines -then you may find that you need larger than 128 bytes. - -You may monitor the stack usage of your application threads during runtime -by defining the macro ATOM_STACK_CHECKING and calling -atomThreadStackCheck(). This macro is defined by default in the Makefile -so that the automated test modules can check for stack overflows, but you -may wish to undefine this in your application Makefiles when you are happy -that the stack usage is acceptable. Enabling ATOM_STACK_CHECKING will -increase the size of your threads' TCBs slightly, and will incur a minor -CPU cycles overhead whenever threads are created due to prefilling the -thread stack with a known value. - -With careful consideration and few threads it would be possible to use -a platform with 512 bytes RAM, but not all of the automated test suite -would run on such a platform (some of the test modules use 6 threads: a -main thread together with 4 test threads and the idle thread). - -The default stack area used by GCC is at the top of RAM (RAMEND), so when -your application's main() function is called the stack pointer is -initialised to RAMEND. This initial stack is only required during startup -for the main() function, and as soon as the OS is started the stack -pointer switches to the stack areas for the application threads. Once the -OS is started the initial startup stack is no longer used at all. You may -continue to use the top of RAM for your startup stack, but in the test -applications for this port we used another area of RAM. This is an -optimisation to allow all of the automated tests to run on platforms with -1KB RAM. The area reused is the idle thread's stack, which is not -required until the OS is started. Ideally you should provide your own -area for your applications, but this was an optimisation that allowed all -of the automated tests to run on ATmega devices with 1KB RAM and did not -require any AVR-specific changes to the automated test modules. This -startup stack does not require a large amount of RAM, probably less than -64 bytes. - -The application's data starts at the bottom of RAM, and this includes all -of the thread stacks which are statically allocated arrays. The idle -thread, main thread, and automated test thread stacks are allocated here. - -This RAM layout is only the one utilised by the test applications. You -may choose whatever layout you like. - - ---------------------------------------------------------------------------- - -HANDLING CPUS WITH LARGE PROGRAM SPACES - -Some devices such as the ATmega2560/2561 support program memory larger than -128KB. GCC defines __AVR_3_BYTE_PC__ for such devices, which is detected in -the architecture port wherever special handling is required. GCC does not -at this time support function pointers greater than 16-bits, however, which -means that the thread_shell() routine which is the entry point for all -threads must be located in the bottom 128KB of program space. You may need -to force this using a linker directive. - -Note that on the AVR architecture program memory is referenced in multiples -of 2 bytes, which is how 16-bits can reference 128KB of program memory -rather than the 64KB which you might expect. - - ---------------------------------------------------------------------------- - diff --git a/ports/avr/atomport-asm.s b/ports/avr/atomport-asm.s deleted file mode 100644 index 0a84b201..00000000 --- a/ports/avr/atomport-asm.s +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright (c) 2010, Atomthreads Project. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. No personal names or organizations' names associated with the - * Atomthreads project may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ATOMTHREADS PROJECT AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - - -.section .text - -/* - * \b archContextSwitch - * - * Architecture-specific context switch routine. - * - * Note that interrupts are always locked out when this routine is - * called. For cooperative switches, the scheduler will have entered - * a critical region. For preemptions (called from an ISR), the - * ISR will have disabled interrupts on entry. - * - * Note that this function might have been coded in C, but gcc - * was generating prologue and epilogue code to handle the parameters. - * Worse, with the naked attribute set it generated half of the - * prologue/epilogue. Rather than work around the gcc code generation, - * which may change from compiler version to compiler version, we - * just write this function in asm, where we have absolute control - * over the code generation. Important during register saves/restores. - * - * @param[in] old_tcb_ptr Pointer to the thread being scheduled out - * @param[in] new_tcb_ptr Pointer to the thread being scheduled in - * - * @return None - * - * void archContextSwitch (ATOM_TCB *old_tcb_ptr, ATOM_TCB *new_tcb_ptr) - */ -.global archContextSwitch -archContextSwitch: - - /** - * Parameter locations: - * old_tcb_ptr = R25-R24 - * new_tcb_ptr = R23-R22 - */ - - /** - * If this is a cooperative context switch (a thread has called us - * to schedule itself out), gcc will have saved any of the - * registers R18-R27 and R30-R31 which it does not want us to clobber. - * Any registers of that set which it did not need to save are safe - * not to be saved by us anyway. Hence for cooperative context - * switches we only need to save those registers which gcc expects - * us _not_ to modify, that is R2-R17 and R28-R29. - * - * If we were called from an interrupt routine (because a thread - * is being preemptively scheduled out), the situation is exactly - * the same. Any ISR which calls out to a subroutine will have - * similarly saved those registers which it needs us not to - * clobber. In the case of an interrupt, that is every single - * register of the set R18-R27 and R30-R31. (gcc cannot establish - * which of those registers actually need to be saved because - * the information is not available to an ISR). Again, we only - * need to save the registers R2-R17 and R28-29, because these - * are expected to be unclobbered by a subroutine. - * - * Note that in addition to saving R18-R27 and R30-R31, gcc also - * saves R0, R1 and SREG when entering ISRs. In the case of a - * cooperative context switch, it is not necessary to save these. - */ - - /** - * Save registers R2-R17, R28-R29. - */ - push r2 - push r3 - push r4 - push r5 - push r6 - push r7 - push r8 - push r9 - push r10 - push r11 - push r12 - push r13 - push r14 - push r15 - push r16 - push r17 - push r28 - push r29 - - /** - * On devices with large program space we also save RAMPZ, EIND. - * Note that GCC 4.3 and later to actually save RAMPZ when called - * via an interrupt handler, which means that we end up stacking - * RAMPZ twice. However we do need to save RAMPZ for cooperative - * context switches where we are called via a function call rather - * than an ISR (at this time GCC does not save RAMPZ before function - * calls). This has the added benefit that we continue to support - * GCC < 4.3, but with the added overhead of the double-stacking for - * newer versions of GCC. - * - * An alternative method that would work for GCC >= 4.3 only would be - * to detect whether we were called from an interrupt handler and not - * save RAMPZ under those circumstances. - */ -#ifdef __AVR_3_BYTE_PC__ - in r0,_SFR_IO_ADDR(RAMPZ) - push r0 - in r0,_SFR_IO_ADDR(EIND) - push r0 -#endif - - /** - * Save the final stack pointer to the TCB. The parameter pointing to - * the old TCB is still untouched in R25-R24. We have saved R16/R17 - * and R28/R29 so we can use them for our own purposes now. We must be - * careful not to use R23-R22, however, as these still contain the - * other parameter, new_tcb_ptr. - */ - in r16,_SFR_IO_ADDR(SPL) /* Get the current SP into general regs */ - in r17,_SFR_IO_ADDR(SPH) /* R16/R17 which are now free to use. */ - - mov r28,r24 /* Move old_tcb_ptr param into the Y-regs so we */ - mov r29,r25 /* can access the TCB via a pointer. */ - - st Y,r16 /* Store SPH/SPL to old_tcb_ptr->tcb_save_ptr which */ - std Y+1,r17 /* is conveniently the first member of the TCB. */ - - - /** - * At this point, all of the current thread's context has been saved - * so we no longer care about keeping the contents of any registers. - * - * The stack frame if this is a cooperative switch looks as follows: - * - * - * - * - * - * || - * - * - * - * - * (Only certain devices) - * (Only certain devices) - * - * The stack frame if this was a preemptive switch looks as follows: - * - * // saved by ISR - * // - * // - * // (Only certain devices) - * // - * // - * || // - * // - * // - * // - * // - * - * - * - * - * || - * - * - * - * - * (Only certain devices) - * (Only certain devices) - * - * - * In addition, the thread's stack pointer (after context-save) is - * stored in the thread's TCB. - */ - - /** - * We are now ready to restore the new thread's context. We switch - * our stack pointer to the new thread's stack pointer, and pop - * all of its context off the stack. When we have finished popping - * all registers (R2-R17 and R28-R29), we are ready to return. - * - * Note that any further registers that needed to be saved for the - * thread will be restored on exiting this function. If the new - * thread previously scheduled itself out cooperatively, the - * original calling function will restore any registers it chose - * to save. If the new thread was preempted, we will return to the - * ISR which will restore all other system registers, before - * returning to the interrupted thread. - */ - - /** - * Get the new thread's stack pointer off the TCB (new_tcb_ptr). - * new_tcb_ptr is still stored in the parameter registers, R23-R22. - * We are free to use any other registers, however, as we haven't - * yet popped any of the new thread's context off its stack. - */ - mov r28,r22 /* Move new_tcb_ptr into the Y-regs so we */ - mov r29,r23 /* can access the TCB via a pointer. */ - - ld r16,Y /* Load new_tcb_ptr->sp_save_ptr into R16/R17. */ - ldd r17,Y+1 /* It is conveniently the first member of the TCB. */ - - out _SFR_IO_ADDR(SPL),r16 /* Set our stack pointer to the new thread's */ - out _SFR_IO_ADDR(SPH),r17 /* stack pointer, from its TCB. */ - - /** - * On devices with large program space we also restore RAMPZ, EIND. - */ -#ifdef __AVR_3_BYTE_PC__ - pop r0 - in r0,_SFR_IO_ADDR(EIND) - pop r0 - in r0,_SFR_IO_ADDR(RAMPZ) -#endif - - /** - * Restore registers R2-R17, R28-R29. - */ - pop r29 - pop r28 - pop r17 - pop r16 - pop r15 - pop r14 - pop r13 - pop r12 - pop r11 - pop r10 - pop r9 - pop r8 - pop r7 - pop r6 - pop r5 - pop r4 - pop r3 - pop r2 - - /** - * The return address on the stack will now be the new thread's return - * address - i.e. although we just entered this function from a - * function called by the old thread, now that we have restored the new - * thread's context, we actually return from this function to wherever - * the new thread was when it was scheduled out. This could be either a - * regular C routine if the new thread previously scheduled itself out - * cooperatively, or it could be an ISR if this new thread was - * previously preempted (on exiting the ISR, execution will return to - * wherever the new thread was originally interrupted). - */ - - /** - * Note that we always just perform a RET here. Although we may - * come in from an ISR and leave through a regular C routine for - * another thread (and visa versa) this is OK, because we don't - * actually need to perform a RETI to tell the processor the - * interrupt is finished. The only extra thing that RETI does is to - * set the I bit (interrupts enabled). If we enter from a regular - * thread context, but leave through an ISR return address and a RETI, - * that just returns and handily enables interrupts for us. Similarly - * if we enter from an ISR and leave back into some thread context - * calls, interrupts will remain disabled through the regular RET - * calls, and we will reenable interrupts in the CRITICAL_END() call - * when we unlock interrupts. - */ - - ret - - -/** - * \b archFirstThreadRestore - * - * Architecture-specific function to restore and start the first thread. - * This is called by atomOSStart() when the OS is starting. - * - * This function will be largely similar to the latter half of - * archContextSwitch(). Its job is to restore the context for the - * first thread, and finally enable interrupts. - * - * It expects to see the context saved in the same way as if the - * thread has been previously scheduled out, and had its context - * saved. That is, archThreadContextInit() will have been called - * first (via atomThreadCreate()) to create a "fake" context save - * area, containing the relevant register-save values for a thread - * restore. - * - * Note that you can create more than one thread before starting - * the OS - only one thread is restored using this function, so - * all other threads are actually restored by archContextSwitch(). - * This is another reminder that the initial context set up by - * archThreadContextInit() must look the same whether restored by - * archFirstThreadRestore() or archContextSwitch(). - * - * @param[in] new_tcb_ptr Pointer to the thread being scheduled in - * - * @return None - * - * void archFirstThreadRestore (ATOM_TCB *new_tcb_ptr) - */ -.global archFirstThreadRestore -archFirstThreadRestore: - - /** - * Parameter locations: - * new_tcb_ptr = R25-R24 - */ - - /** - * First thread restores in the AVR port expect to see R2-R17 and - * R28-R29 stored as context. The context will look exactly like it - * would had a thread cooperatively scheduled itself out. That is, - * these registers will be stored on the stack, and above those will - * be the return address of the calling function. In this case we - * will have set up this "fake" context in archThreadContextInit(), - * and above these registers will be the return address of the thread - * entry point. A "ret" or "reti" instruction will therefore direct - * the processor to the thread entry point, by popping this "return - * address" off the stack. - */ - - /** - * Get the new thread's stack pointer off the TCB (new_tcb_ptr). - * new_tcb_ptr is stored in the parameter registers, R25-R24. - * We are free to use any other registers, however, as we haven't - * yet popped any of the new thread's context off its stack. - */ - mov r28,r24 /* Move new_tcb_ptr into the Y-regs so we */ - mov r29,r25 /* can access the TCB via a pointer. */ - - ld r16,Y /* Load new_tcb_ptr->sp_save_ptr into R16/R17. */ - ldd r17,Y+1 /* It is conveniently the first member of the TCB. */ - - out _SFR_IO_ADDR(SPL),r16 /* Set our stack pointer to the new thread's */ - out _SFR_IO_ADDR(SPH),r17 /* stack pointer, from its TCB. */ - - /** - * On devices with large program space we also restore RAMPZ, EIND. - */ -#ifdef __AVR_3_BYTE_PC__ - pop r0 - in r0,_SFR_IO_ADDR(EIND) - pop r0 - in r0,_SFR_IO_ADDR(RAMPZ) -#endif - - /** - * Restore registers R2-R17, R28-R29. - */ - pop r29 - pop r28 - pop r17 - pop r16 - pop r15 - pop r14 - pop r13 - pop r12 - pop r11 - pop r10 - pop r9 - pop r8 - pop r7 - pop r6 - pop r5 - pop r4 - pop r3 - pop r2 - - /** - * The "return address" left on the stack now will be the new - * thread's entry point. RETI will take us there as if we had - * actually been there before calling this subroutine, whereas - * the return address was actually set up by archThreadContextInit(). - * - * As discussed above, this function is responsible for enabling - * interrupts once all context has been restored. We can do this - * using a single RETI instruction (return and enable interrupts), - * but it is also safe at this point to have two separate - * instructions: - * sei // enable interrupts - * ret // return to new thread entry point - */ - reti - - diff --git a/ports/avr/atomport-private.h b/ports/avr/atomport-private.h deleted file mode 100644 index 866f6b41..00000000 --- a/ports/avr/atomport-private.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2010, Kelvin Lawson. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. No personal names or organizations' names associated with the - * Atomthreads project may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ATOMTHREADS PROJECT AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __ATOM_PORT_PRIVATE_H -#define __ATOM_PORT_PRIVATE_H - -/* CPU Frequency */ -#define AVR_CPU_HZ 1000000 - -/* Function prototypes */ -void avrInitSystemTickTimer ( void ); - -#endif /* __ATOM_PORT_PRIVATE_H */ diff --git a/ports/avr/atomport-tests.h b/ports/avr/atomport-tests.h deleted file mode 100644 index cb1ca6ec..00000000 --- a/ports/avr/atomport-tests.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2010, Kelvin Lawson. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. No personal names or organizations' names associated with the - * Atomthreads project may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ATOMTHREADS PROJECT AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __ATOM_PORT_TESTS_H -#define __ATOM_PORT_TESTS_H - -/* Include Atomthreads kernel API */ -#include "atom.h" - -/* Prerequisite include for ATOMLOG() macro (via printf) */ -#include - -/* Logger macro for viewing test results */ -#define ATOMLOG printf_P - -/* - * String location macro: for platforms which need to place strings in - * alternative locations, e.g. on avr-gcc strings can be placed in - * program space, saving SRAM. On most platforms this can expand to - * empty. - */ -#define _STR(x) PSTR(x) - -/* Default thread stack size (in bytes) */ -#define TEST_THREAD_STACK_SIZE 128 - -/* Uncomment to enable logging of stack usage to UART */ -/* #define TESTS_LOG_STACK_USAGE */ - - -#endif /* __ATOM_PORT_TESTS_H */ - diff --git a/ports/avr/atomport.c b/ports/avr/atomport.c deleted file mode 100644 index 9ae55550..00000000 --- a/ports/avr/atomport.c +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Copyright (c) 2010, Kelvin Lawson. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. No personal names or organizations' names associated with the - * Atomthreads project may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ATOMTHREADS PROJECT AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#include - -#include "atom.h" -#include "atomport-private.h" - - -/** Forward declarations */ -static void thread_shell (void); - - -/** - * \b thread_shell - * - * Shell routine which is used to call all thread entry points. - * - * This routine is called whenever a new thread is starting, and is - * responsible for taking the entry point parameter off the TCB - * and passing this into the thread entry point, as well as enabling - * interrupts. This is an optional function for a port, as it is - * also possible to do this with a regular context restore if the - * appropriate registers are saved for context switches (parameter - * and interrupt enable). Alternatively a flag could be used to - * notify archFirstThreadRestore() and archContextSwitch() - * that they should this time restore the contents of the parameter - * registers and enable interrupts. After restoring a thread first - * time the context restore routines need not perform those - * operations again. This is discussed in more detail below. - * - * When starting new threads, ports must pass in the entry point - * function parameter, and enable interrupts. This can be handled by - * the first context restore for new threads if they are saved as - * part of the thread's context. However for the AVR port we have - * chosen to save only the minimum registers required for context - * switches. This reduces the cycle time required for all context - * switches during operation. This means, however, that we don't save - * the parameter registers R25/R24 or the SREG. These would otherwise - * be used when restoring a thread for the first time to pass the - * parameter to the entry point, and enabling interrupts in the SREG. - * - * A few of the possible ways round this are to: - * - * a) Save R25/R24 and SREG with the normal context - thus increasing - * the processor cycles required on each context switch. - * b) Use a thread shell routine which is used to start all threads. - * This routine can then pass the parameter and enable interrupts, - * without incurring any overhead on all context switches. - * c) Store a flag in a new thread's TCB to notify the normal context - * switch routine that it must (the first time a thread is restored - * only) pass the parameter, and enable interrupts. - * - * We have chosen to implement (b) in this case, as it does not affect - * normal context switch times just for the benefit of the first restore, - * and it does not incur extra complication to the thread restore - * routines through handling special cases. A thread shell is also handy - * for providing port users with a place to do any initialisation that - * must be done for each thread (e.g. opening stdio files etc). - * - * Other ports are free to implement whatever scheme they wish. In - * particular if you save all necessary registers on a context switch - * then you need not worry about any special requirements for - * starting threads for the first time. - * - * @return None - */ -static void thread_shell (void) -{ - ATOM_TCB *curr_tcb; - - /* Get the TCB of the thread being started */ - curr_tcb = atomCurrentContext(); - - /** - * Enable interrupts - these will not be enabled when a thread - * is first restored. - */ - sei(); - - /* Call the thread entry point */ - if (curr_tcb && curr_tcb->entry_point) - { - curr_tcb->entry_point(curr_tcb->entry_param); - } - - /* Not reached - threads should never return from the entry point */ - -} - - -/** - * \b archThreadContextInit - * - * Architecture-specific thread context initialisation routine. - * - * This function must set up a thread's context ready for restoring - * and running the thread via archFirstThreadRestore() or - * archContextSwitch(). - * - * The layout required to fill the correct register values is - * described in archContextSwitch(). Note that not all registers - * are restored by archContextSwitch() and archFirstThreadRestore() - * as this port takes advantage of the fact that not all registers - * must be stored by gcc-avr C subroutines. This means that we don't - * provide start values for those registers, as they are "don't cares". - * - * Because we don't actually save the parameter registers (R25-R24) - * for this particular architecture, we use a separate thread shell. - * The thread shell is always used as the thread entry point stored - * in the thread context, and it does the actual calling of the - * proper thread entry point, passing the thread entry parameter. - * This allows us to pass the entry parameter without actually - * storing it on the stack (the thread shell routine takes the - * entry point and parameter from the thread's TCB). On other ports - * you may instead choose to store the entry point and parameter - * in the thread context and use no thread shell routine. - * - * Similarly we use the thread shell in this case to enable interrupts. - * When a thread is restored and started for the first time, it must - * also enable interrupts. This might be done by setting up the - * appropriate value in the SREG register for enabled interrupts, which - * would then be restored when the thread is first started. But to - * reduce register-saves we do not save SREG on the AVR port, and - * instead we use the thread shell routine to enable interrupts the - * first time a thread is started. - * - * @param[in] tcb_ptr Pointer to the TCB of the thread being created - * @param[in] stack_top Pointer to the top of the new thread's stack - * @param[in] entry_point Pointer to the thread entry point function - * @param[in] entry_param Parameter to be passed to the thread entry point - * - * @return None - */ -void archThreadContextInit (ATOM_TCB *tcb_ptr, void *stack_top, void (*entry_point)(uint32_t), uint32_t entry_param) -{ - uint8_t *stack_ptr; - - /** Start at stack top */ - stack_ptr = (uint8_t *)stack_top; - - /** - * After restoring all of the context registers, the thread restore - * routines will perform a RET or RETI which expect to find the - * address of the calling routine on the stack. In this case (the - * first time a thread is run) we "return" to the entry point for - * the thread. That is, we store the thread entry point in the - * place that RET and RETI will look for the return address: the - * stack. - * - * Note that we are using the thread_shell() routine to start all - * threads, so we actually store the address of thread_shell() - * here. Other ports may store the real thread entry point here - * and call it directly from the thread restore routines. - * - * Because we are filling the stack from top to bottom, this goes - * on the stack first (at the top). - */ - *stack_ptr-- = (uint8_t)((uint16_t)thread_shell & 0xFF); - *stack_ptr-- = (uint8_t)(((uint16_t)thread_shell >> 8) & 0xFF); - - /** - * Devices with 3 byte program counters (e.g. Atmega25x, Xmega) - * must have 3 bytes stacked for the entry point. In GCC - * function pointers are still 16-bits, however, so we cannot - * actually pass entry points at > 64K in instruction space - * (128KB in real terms) and just set the top byte to zero here. - * This means that the thread_shell() function must be located - * in the bottom 128KB. You may need to modify linker scripts to - * force this. - */ -#ifdef __AVR_3_BYTE_PC__ - *stack_ptr-- = 0; -#endif - - /** - * For the AVR port the parameter registers (R25-R24) are not - * saved and restored by the context switch routines. This means - * that they cannot be used to pass a parameter to the entry - * point the first time a thread is restored. Rather than incur - * the overhead of saving them (just for the benefit of starting - * threads) we can either use a flag here to notify the context - * restore routines (archThreadFirstRestore() and - * archContextSwitch()) that they should restore R25-R24 this - * one time, or we can use a thread shell routine which replaces - * that actual thread entry point. In this case we use a thread - * shell which is responsible for passing the parameters to the - * actual thread entry point, without adding extra processing - * to the context switch routines. - * - * Other ports may wish to store entry_param in the appropriate - * parameter registers when creating a thread's context, - * particularly if that port saves those registers anyway. - * - * Similarly, although interrupts must be enabled when starting - * new threads, we also defer this to the thread shell because - * we don't save the SREG contents for normal context switches. - * Other ports may choose to context switch the relevant - * interrupt enable register, so that the first context switch - * is able to enable interrupts during its normal context - * restore. - */ - - /** - * Store starting register values for R2-R17, R28-R29 - */ - *stack_ptr-- = 0x00; /* R2 */ - *stack_ptr-- = 0x00; /* R3 */ - *stack_ptr-- = 0x00; /* R4 */ - *stack_ptr-- = 0x00; /* R5 */ - *stack_ptr-- = 0x00; /* R6 */ - *stack_ptr-- = 0x00; /* R7 */ - *stack_ptr-- = 0x00; /* R8 */ - *stack_ptr-- = 0x00; /* R9 */ - *stack_ptr-- = 0x00; /* R10 */ - *stack_ptr-- = 0x00; /* R11 */ - *stack_ptr-- = 0x00; /* R12 */ - *stack_ptr-- = 0x00; /* R13 */ - *stack_ptr-- = 0x00; /* R14 */ - *stack_ptr-- = 0x00; /* R15 */ - *stack_ptr-- = 0x00; /* R16 */ - *stack_ptr-- = 0x00; /* R17 */ - *stack_ptr-- = 0x00; /* R28 */ - *stack_ptr-- = 0x00; /* R29 */ - - /** - * On devices with large program space we also context switch RAMPZ, EIND. - */ -#ifdef __AVR_3_BYTE_PC__ - *stack_ptr-- = 0x00; /* RAMPZ */ - *stack_ptr-- = 0x00; /* EIND */ -#endif - - /** - * All thread context has now been initialised. Save the current - * stack pointer to the thread's TCB so it knows where to start - * looking when the thread is started. - */ - tcb_ptr->sp_save_ptr = stack_ptr; - -} - - -/** - * \b avrInitSystemTickTimer - * - * Initialise the system tick timer. Uses the AVR's timer1 facility. - * - * @return None - */ -void avrInitSystemTickTimer ( void ) -{ - /* Set timer 1 compare match value for configured system tick, - * with a prescaler of 256. We will get a compare match 1A - * interrupt on every system tick, in which we must call the - * OS's system tick handler. */ - OCR1A = (AVR_CPU_HZ / 256 / SYSTEM_TICKS_PER_SEC); - - /* Enable compare match 1A interrupt */ -#ifdef TIMSK - TIMSK = _BV(OCIE1A); -#else - TIMSK1 = _BV(OCIE1A); -#endif - - /* Set prescaler 256 */ - TCCR1B = _BV(CS12) | _BV(WGM12); -} - - -/** - * - * System tick ISR. - * - * This is responsible for regularly calling the OS system tick handler. - * The system tick handler checks if any timer callbacks are necessary, - * and runs the scheduler. - * - * The compiler automatically saves all registers necessary before calling - * out to a C routine. This will be (at least) R0, R1, SREG, R18-R27 and - * R30/R31. - * - * The system may decide to schedule in a new thread during the call to - * atomTimerTick(), in which case around half of the thread's context will - * already have been saved here, ready for when we return here when the - * interrupted thread is scheduled back in. The remaining context will be - * saved by the context switch routine. - * - * As with all interrupts, the ISR should call atomIntEnter() and - * atomIntExit() on entry and exit. This serves two purposes: - * - * a) To notify the OS that it is running in interrupt context - * b) To defer the scheduler until after the ISR is completed - * - * We defer all scheduling decisions until after the ISR has completed - * in case the interrupt handler makes more than one thread ready. - * - * @return None - */ -ISR (TIMER1_COMPA_vect) -{ - /* Call the interrupt entry routine */ - atomIntEnter(); - - /* Call the OS system tick handler */ - atomTimerTick(); - - /* Call the interrupt exit routine */ - atomIntExit(TRUE); -} - - -/** - * - * Default (no handler installed) ISR. - * - * Installs a default handler to be called if any interrupts occur for - * which we have not registered an ISR. This is empty and has only been - * included to handle user-created code which may enable interrupts. The - * core OS does not enable any interrupts other than the system timer - * tick interrupt. - * - * @return None - */ -ISR (BADISR_vect) -{ - /* Empty */ -} diff --git a/ports/avr/atomport.h b/ports/avr/atomport.h deleted file mode 100644 index ec1cc78e..00000000 --- a/ports/avr/atomport.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2010, Kelvin Lawson. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. No personal names or organizations' names associated with the - * Atomthreads project may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ATOMTHREADS PROJECT AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __ATOM_PORT_H -#define __ATOM_PORT_H - -#include -#include -#include - -/* Portable uint8_t and friends available from stdint.h on this platform */ -#include - - -/* Required number of system ticks per second (normally 100 for 10ms tick) */ -#define SYSTEM_TICKS_PER_SEC 100 - - -/** - * Architecture-specific types. - * Most of these are available from stdint.h on this platform, which is - * included above. - */ -#define POINTER void * - - -/* Critical region protection */ -#define CRITICAL_STORE uint8_t sreg -#define CRITICAL_START() sreg = SREG; cli(); -#define CRITICAL_END() SREG = sreg - - -/* Uncomment to enable stack-checking */ -/* #define ATOM_STACK_CHECKING */ - - -#endif /* __ATOM_PORT_H */ diff --git a/ports/avr/gdb.txt b/ports/avr/gdb.txt deleted file mode 100644 index 070a8880..00000000 --- a/ports/avr/gdb.txt +++ /dev/null @@ -1,6 +0,0 @@ -delete -file atomapp.elf -target remote localhost:1212 -load -break main_thread_func -cont diff --git a/ports/avr/tests-main.c b/ports/avr/tests-main.c deleted file mode 100644 index 427cd93a..00000000 --- a/ports/avr/tests-main.c +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (c) 2010, Kelvin Lawson. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. No personal names or organizations' names associated with the - * Atomthreads project may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE ATOMTHREADS PROJECT AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "atom.h" -#include "atomport-private.h" -#include "atomtests.h" -#include "atomtimer.h" -#include "uart.h" -#include - - -/* Constants */ - -/* - * Idle thread stack size - * - * This needs to be large enough to handle any interrupt handlers - * and callbacks called by interrupt handlers (e.g. user-created - * timer callbacks) as well as the saving of all context when - * switching away from this thread. - * - * In this case, the idle stack is allocated on the BSS via the - * idle_thread_stack[] byte array. - */ -#define IDLE_STACK_SIZE_BYTES 128 - - -/* - * Main thread stack size - * - * Note that this is not a required OS kernel thread - you will replace - * this with your own application thread. - * - * In this case the Main thread is responsible for calling out to the - * test routines. Once a test routine has finished, the test status is - * printed out on the UART and the thread remains running in a loop - * flashing a LED. - * - * The Main thread stack generally needs to be larger than the idle - * thread stack, as not only does it need to store interrupt handler - * stack saves and context switch saves, but the application main thread - * will generally be carrying out more nested function calls and require - * stack for application code local variables etc. - * - * With all OS tests implemented to date on the AVR, the Main thread - * stack has not exceeded 198 bytes. To allow all tests to run we set - * a minimum main thread stack size of 204 bytes. This may increase in - * future as the codebase changes but for the time being is enough to - * cope with all of the automated tests. - */ -#define MAIN_STACK_SIZE_BYTES 204 - - -/* - * Startup code stack - * - * Some stack space is required at initial startup for running the main() - * routine. This stack space is only temporarily required at first bootup - * and is no longer required as soon as the OS is started. By default - * GCC sets this to the top of RAM (RAMEND) and it grows down from there. - * Because we only need this temporarily, though, it would be wasteful to - * set aside a region at the top of RAM which is not used during runtime. - * - * What we do here is to reuse part of the idle thread's stack during - * initial startup. As soon as we enter the main() routine we move the - * stack pointer to half-way down the idle thread's stack. This is used - * temporarily while calls are made to atomOSInit(), atomThreadCreate() - * and atomOSStart(). Once the OS is started this stack area is no - * longer required, and can be used for its original purpose (for the - * idle thread's stack). - * - * This does mean, however, that we cannot monitor the stack usage of the - * idle thread. Stack usage is monitored by prefilling the stack with a - * known value, and we are obliterating some of that prefilled area by - * using it as our startup stack, so we cannot use the stack-checking API - * to get a true picture of idle thread stack usage. If you wish to - * monitor idle thread stack usage for your applications then you are - * free to use a different region for the startup stack (e.g. set aside - * an area permanently, or place it somewhere you know you can reuse - * later in the application). For the time being, this method gives us a - * simple way of reducing the memory consumption without having to add - * any special AVR-specific considerations to the automated test - * applications. - * - * This optimisation was required to allow some of the larger automated - * test modules to run on devices with 1KB of RAM. You should avoid doing - * this if you can afford to set aside 64 bytes or so, or if you are - * writing your own applications in which you have further control over - * where data is located. - */ - - -/* Local data */ - -/* Application threads' TCBs */ -static ATOM_TCB main_tcb; - -/* Main thread's stack area */ -static uint8_t main_thread_stack[MAIN_STACK_SIZE_BYTES]; - -/* Idle thread's stack area */ -static uint8_t idle_thread_stack[IDLE_STACK_SIZE_BYTES]; - -/* STDIO stream */ -static FILE uart_stdout = FDEV_SETUP_STREAM(uart_putchar, NULL, _FDEV_SETUP_WRITE); - - -/* Forward declarations */ -static void main_thread_func (uint32_t data); - - -/** - * \b main - * - * Program entry point. - * - * Sets up the AVR hardware resources (system tick timer interrupt) necessary - * for the OS to be started. Creates an application thread and starts the OS. - */ - -int main ( void ) -{ - int8_t status; - - /** - * Reuse part of the idle thread's stack for the stack required - * during this startup function. - */ - SP = (int)&idle_thread_stack[(IDLE_STACK_SIZE_BYTES/2) - 1]; - - /** - * Note: to protect OS structures and data during initialisation, - * interrupts must remain disabled until the first thread - * has been restored. They are reenabled at the very end of - * the first thread restore, at which point it is safe for a - * reschedule to take place. - */ - - /** - * Initialise the OS before creating our threads. - * - * Note that we tell the OS that the idle stack is half its actual - * size. This prevents it prefilling the bottom half with known - * values for stack-checkig purposes, which we cannot allow because - * we are temporarily using it for our own stack. The remainder will - * still be available once the OS is started, this only prevents the - * OS from prefilling it. - * - * If you are not reusing the idle thread's stack during startup then - * you should pass in the correct size here. - */ - status = atomOSInit(&idle_thread_stack[IDLE_STACK_SIZE_BYTES - 1], (IDLE_STACK_SIZE_BYTES/2)); - if (status == ATOM_OK) - { - /* Enable the system tick timer */ - avrInitSystemTickTimer(); - - /* Create an application thread */ - status = atomThreadCreate(&main_tcb, - TEST_THREAD_PRIO, main_thread_func, 0, - &main_thread_stack[MAIN_STACK_SIZE_BYTES - 1], - MAIN_STACK_SIZE_BYTES); - if (status == ATOM_OK) - { - /** - * First application thread successfully created. It is - * now possible to start the OS. Execution will not return - * from atomOSStart(), which will restore the context of - * our application thread and start executing it. - * - * Note that interrupts are still disabled at this point. - * They will be enabled as we restore and execute our first - * thread in archFirstThreadRestore(). - */ - atomOSStart(); - } - } - - while (1) - ; - - /* There was an error starting the OS if we reach here */ - return (0); -} - - -/** - * \b main_thread_func - * - * Entry point for main application thread. - * - * This is the first thread that will be executed when the OS is started. - * - * @param[in] data Unused (optional thread entry parameter) - * - * @return None - */ -static void main_thread_func (uint32_t data) -{ - uint32_t test_status; - int sleep_ticks; - - /* Enable all LEDs (STK500-specific) */ - DDRB = 0xFF; - PORTB = 0xFF; - - /* Initialise UART (9600bps) */ - if (uart_init(9600) != 0) - { - /* Error initialising UART */ - } - - /** - * Redirect stdout via the UART. Note that the UART write routine - * is protected via a semaphore, so the OS must be started before - * use of the UART. - */ - stdout = &uart_stdout; - - /* Put a message out on the UART */ - printf_P(PSTR("Go\n")); - - /* Start test. All tests use the same start API. */ - test_status = test_start(); - - /* Check main thread stack usage (if enabled) */ -#ifdef ATOM_STACK_CHECKING - if (test_status == 0) - { - uint32_t used_bytes, free_bytes; - - /* Check idle thread stack usage */ - if (atomThreadStackCheck (&main_tcb, &used_bytes, &free_bytes) == ATOM_OK) - { - /* Check the thread did not use up to the end of stack */ - if (free_bytes == 0) - { - printf_P (PSTR("Main stack overflow\n")); - test_status++; - } - - /* Log the stack usage */ -#ifdef TESTS_LOG_STACK_USAGE - printf_P (PSTR("MainUse:%d\n"), used_bytes); -#endif - } - - } -#endif - - /* Log final status */ - if (test_status == 0) - { - printf_P (PSTR("Pass\n")); - } - else - { - printf_P (PSTR("Fail(%d)\n"), test_status); - } - - /* Flash LED once per second if passed, very quickly if failed */ - sleep_ticks = (test_status == 0) ? SYSTEM_TICKS_PER_SEC : (SYSTEM_TICKS_PER_SEC/8); - - /* Test finished, flash slowly for pass, fast for fail */ - while (1) - { - /* Toggle a LED (STK500-specific) */ - PORTB ^= (1 << 7); - - /* Sleep then toggle LED again */ - atomTimerDelay(sleep_ticks); - } - -} diff --git a/ports/avr/uart.c b/ports/avr/uart.c deleted file mode 100644 index 5d512318..00000000 --- a/ports/avr/uart.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Joerg Wunsch - * ---------------------------------------------------------------------------- - * - * Stdio demo, UART implementation - * - * $Id: uart.c,v 1.1 2005/12/28 21:38:59 joerg_wunsch Exp $ - */ - -#include -#include - -#include - -#include "atom.h" -#include "atommutex.h" -#include "atomport-private.h" -#include "uart.h" - -/* - * Set register-access macros for the first UART across various Atmega devices. - */ -#ifdef UCSRA -/* Device with single UART */ -#define REG_UCSRA UCSRA -#define REG_UCSRB UCSRB -#define REG_UBRRL UBRRL -#define REG_UDR UDR -#define BIT_TXEN TXEN -#define BIT_RXEN RXEN -#define BIT_UDRE UDRE -#else -/* Device with multiple UARTs */ -#define REG_UCSRA UCSR0A -#define REG_UCSRB UCSR0B -#define REG_UBRRL UBRR0L -#define REG_UDR UDR0 -#define BIT_TXEN TXEN0 -#define BIT_RXEN RXEN0 -#define BIT_UDRE UDRE0 -#endif - - -/* - * Semaphore for single-threaded access to UART device - */ -static ATOM_MUTEX uart_mutex; - - -/* - * Initialize the UART to requested baudrate, tx/rx, 8N1. - */ -int -uart_init(uint32_t baudrate) -{ - int status; - - /* Set up the UART device with the selected baudrate */ -#if AVR_CPU_HZ < 2000000UL && defined(U2X) - REG_UCSRA = _BV(U2X); /* improve baud rate error by using 2x clk */ - REG_UBRRL = (AVR_CPU_HZ / (8UL * baudrate)) - 1; -#else - REG_UBRRL = (AVR_CPU_HZ / (16UL * baudrate)) - 1; -#endif - REG_UCSRB = _BV(BIT_TXEN) | _BV(BIT_RXEN); /* tx/rx enable */ - - /* Create a mutex for single-threaded putchar() access */ - if (atomMutexCreate (&uart_mutex) != ATOM_OK) - { - status = -1; - } - else - { - status = 0; - } - - /* Finished */ - return (status); -} - -/* - * Send character c down the UART Tx, wait until tx holding register - * is empty. - */ -int -uart_putchar(char c, FILE *stream) -{ - - /* Block on private access to the UART */ - if (atomMutexGet(&uart_mutex, 0) == ATOM_OK) - { - /* Convert \n to \r\n */ - if (c == '\n') - uart_putchar('\r', stream); - - /* Wait until the UART is ready then send the character out */ - loop_until_bit_is_set(REG_UCSRA, BIT_UDRE); - REG_UDR = c; - - /* Return mutex access */ - atomMutexPut(&uart_mutex); - } - - return 0; -} diff --git a/ports/avr/uart.h b/ports/avr/uart.h deleted file mode 100644 index 15c03705..00000000 --- a/ports/avr/uart.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * wrote this file. As long as you retain this notice you - * can do whatever you want with this stuff. If we meet some day, and you think - * this stuff is worth it, you can buy me a beer in return. Joerg Wunsch - * ---------------------------------------------------------------------------- - * - * Stdio demo, UART declarations - * - * $Id: uart.h,v 1.1 2005/12/28 21:38:59 joerg_wunsch Exp $ - */ - -#include "atom.h" - - -/* - * Perform UART startup initialization. - */ -int uart_init(uint32_t baudrate); - -/* - * Send one character to the UART. - */ -int uart_putchar(char c, FILE *stream); From 51102821a586a41fc760ef42c82b5c47292aaf44 Mon Sep 17 00:00:00 2001 From: Wei Shuai Date: Sat, 26 Oct 2013 21:47:33 +0800 Subject: [PATCH 02/28] remove STM8S peripheral device driver --- ports/stm8/stm8s-periphs/stm8s.h | 2597 ------------------------ ports/stm8/stm8s-periphs/stm8s_clk.c | 94 - ports/stm8/stm8s-periphs/stm8s_clk.h | 404 ---- ports/stm8/stm8s-periphs/stm8s_gpio.c | 140 -- ports/stm8/stm8s-periphs/stm8s_gpio.h | 149 -- ports/stm8/stm8s-periphs/stm8s_itc.c | 323 --- ports/stm8/stm8s-periphs/stm8s_itc.h | 168 -- ports/stm8/stm8s-periphs/stm8s_tim1.c | 184 -- ports/stm8/stm8s-periphs/stm8s_tim1.h | 565 ------ ports/stm8/stm8s-periphs/stm8s_type.h | 103 - ports/stm8/stm8s-periphs/stm8s_uart2.c | 272 --- ports/stm8/stm8s-periphs/stm8s_uart2.h | 412 ---- 12 files changed, 5411 deletions(-) delete mode 100644 ports/stm8/stm8s-periphs/stm8s.h delete mode 100644 ports/stm8/stm8s-periphs/stm8s_clk.c delete mode 100644 ports/stm8/stm8s-periphs/stm8s_clk.h delete mode 100644 ports/stm8/stm8s-periphs/stm8s_gpio.c delete mode 100644 ports/stm8/stm8s-periphs/stm8s_gpio.h delete mode 100644 ports/stm8/stm8s-periphs/stm8s_itc.c delete mode 100644 ports/stm8/stm8s-periphs/stm8s_itc.h delete mode 100644 ports/stm8/stm8s-periphs/stm8s_tim1.c delete mode 100644 ports/stm8/stm8s-periphs/stm8s_tim1.h delete mode 100644 ports/stm8/stm8s-periphs/stm8s_type.h delete mode 100644 ports/stm8/stm8s-periphs/stm8s_uart2.c delete mode 100644 ports/stm8/stm8s-periphs/stm8s_uart2.h diff --git a/ports/stm8/stm8s-periphs/stm8s.h b/ports/stm8/stm8s-periphs/stm8s.h deleted file mode 100644 index 8642bf94..00000000 --- a/ports/stm8/stm8s-periphs/stm8s.h +++ /dev/null @@ -1,2597 +0,0 @@ -/** - ****************************************************************************** - * @file stm8s.h - * @brief This file contains all HW registers definitions and memory mapping. - * @author STMicroelectronics - MCD Application Team - * @version V1.1.1 - * @date 06/05/2009 - ****************************************************************************** - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- * @image html logo.bmp - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM8S_H -#define __STM8S_H - -/******************************************************************************/ -/* Library configuration section */ -/******************************************************************************/ -/* Check the used compiler */ -#if defined(__CSMC__) - #undef _RAISONANCE_ - #undef _IAR_SYSTEMS_ - #define _COSMIC_ -#elif defined(__RCST7__) - #undef _COSMIC_ - #undef _IAR_SYSTEMS_ - #define _RAISONANCE_ -#elif defined(__IAR_SYSTEMS_ICC__) - #undef _COSMIC_ - #undef _RAISONANCE_ - #define _IAR_SYSTEMS_ -#else - #error "Unsupported Compiler!" /* Compiler defines not found */ -#endif - -/* Uncomment the line below according to the target STM8S device used in your - application. - Tip: To avoid modifying this file each time you need to switch between these - devices, you can define the device in your toolchain compiler preprocessor. */ -#if !defined (STM8S208) && !defined (STM8S207) && !defined (STM8S105) && !defined (STM8S103) && !defined (STM8S903) - # error "STM8S device not specified" - /* #define STM8S208 */ - /* #define STM8S207 */ - /* #define STM8S105 */ - /* #define STM8S103 */ - /* #define STM8S903 */ -#endif - - -#if !defined USE_STDPERIPH_DRIVER -/* Comment the line below if you will not use the peripherals drivers. - In this case, these drivers will not be included and the application code will be - based on direct access to peripherals registers */ - #define USE_STDPERIPH_DRIVER -#endif - -/* For FLASH routines, select whether pointer will be declared as near (2 bytes, handle - code smaller than 64KB) or far (3 bytes, handle code larger than 64K) */ -/*#define PointerAttr_Near 1 */ /*!< Used with memory Models for code smaller than 64K */ -#define PointerAttr_Far 2 /*!< Used with memory Models for code larger than 64K */ - -#ifdef _COSMIC_ - #define FAR @far - #define NEAR @near - #define TINY @tiny - #define __CONST const -#endif - -#ifdef _RAISONANCE_ - #define FAR far - #define NEAR data - #define TINY page0 - #define __CONST code -#endif - -#ifdef _IAR_SYSTEMS_ - #define FAR __far - #define NEAR __near - #define TINY __tiny - #define __CONST const -#endif - -#ifdef PointerAttr_Far - #define PointerAttr FAR -#else /* PointerAttr_Near */ - #define PointerAttr NEAR -#endif /* PointerAttr_Far */ - - -/* Uncomment the line below to use the cosmic section */ -#if defined(_COSMIC_) -/* #define USE_COSMIC_SECTIONS (1)*/ -#endif - -/******************************************************************************/ - -/* Includes ------------------------------------------------------------------*/ -#include "stm8s_type.h" - -/* Exported types and constants-----------------------------------------------*/ -/** @addtogroup MAP_FILE_Exported_Types_and_Constants - * @{ - */ - -/******************************************************************************/ -/* IP registers structures */ -/******************************************************************************/ -/*----------------------------------------------------------------------------*/ -/** - * @brief General Purpose I/Os (GPIO) - */ - -typedef struct GPIO_struct -{ - vu8 ODR; /*!< Output Data Register */ - vu8 IDR; /*!< Input Data Register */ - vu8 DDR; /*!< Data Direction Register */ - vu8 CR1; /*!< Configuration Register 1 */ - vu8 CR2; /*!< Configuration Register 2 */ -} -GPIO_TypeDef; - -/** @addtogroup GPIO_Registers_Reset_Value - * @{ - */ - -#define GPIO_ODR_RESET_VALUE ((u8)0x00) -#define GPIO_DDR_RESET_VALUE ((u8)0x00) -#define GPIO_CR1_RESET_VALUE ((u8)0x00) -#define GPIO_CR2_RESET_VALUE ((u8)0x00) - -/** - * @} - */ - -/*----------------------------------------------------------------------------*/ -#if defined(STM8S105) || defined(STM8S103) || defined(STM8S903) -/** - * @brief Analog to Digital Converter (ADC1) - */ -typedef struct ADC1_struct -{ - vu8 DB0RH; /*!< ADC1 Data Buffer Register (MSB) */ - vu8 DB0RL; /*!< ADC1 Data Buffer Register (LSB) */ - vu8 DB1RH; /*!< ADC1 Data Buffer Register (MSB) */ - vu8 DB1RL; /*!< ADC1 Data Buffer Register (LSB) */ - vu8 DB2RH; /*!< ADC1 Data Buffer Register (MSB) */ - vu8 DB2RL; /*!< ADC1 Data Buffer Register (LSB) */ - vu8 DB3RH; /*!< ADC1 Data Buffer Register (MSB) */ - vu8 DB3RL; /*!< ADC1 Data Buffer Register (LSB) */ - vu8 DB4RH; /*!< ADC1 Data Buffer Register (MSB) */ - vu8 DB4RL; /*!< ADC1 Data Buffer Register (LSB) */ - vu8 DB5RH; /*!< ADC1 Data Buffer Register (MSB) */ - vu8 DB5RL; /*!< ADC1 Data Buffer Register (LSB) */ - vu8 DB6RH; /*!< ADC1 Data Buffer Register (MSB) */ - vu8 DB6RL; /*!< ADC1 Data Buffer Register (LSB) */ - vu8 DB7RH; /*!< ADC1 Data Buffer Register (MSB) */ - vu8 DB7RL; /*!< ADC1 Data Buffer Register (LSB) */ - vu8 DB8RH; /*!< ADC1 Data Buffer Register (MSB) */ - vu8 DB8RL; /*!< ADC1 Data Buffer Register (LSB) */ - vu8 DB9RH; /*!< ADC1 Data Buffer Register (MSB) */ - vu8 DB9RL; /*!< ADC1 Data Buffer Register (LSB) */ - vu8 RESERVED[12]; /*!< Reserved byte */ - vu8 CSR; /*!< ADC1 control status register */ - vu8 CR1; /*!< ADC1 configuration register 1 */ - vu8 CR2; /*!< ADC1 configuration register 2 */ - vu8 CR3; /*!< ADC1 configuration register 3 */ - vu8 DRH; /*!< ADC1 Data high */ - vu8 DRL; /*!< ADC1 Data low */ - vu8 TDRH; /*!< ADC1 Schmitt trigger disable register high */ - vu8 TDRL; /*!< ADC1 Schmitt trigger disable register low */ - vu8 HTRH; /*!< ADC1 high threshold register High*/ - vu8 HTRL; /*!< ADC1 high threshold register Low*/ - vu8 LTRH; /*!< ADC1 low threshold register high */ - vu8 LTRL; /*!< ADC1 low threshold register low */ - vu8 AWSRH; /*!< ADC1 watchdog status register high */ - vu8 AWSRL; /*!< ADC1 watchdog status register low */ - vu8 AWCRH; /*!< ADC1 watchdog control register high */ - vu8 AWCRL; /*!< ADC1 watchdog control register low */ -} -ADC1_TypeDef; - -/** @addtogroup ADC1_Registers_Reset_Value - * @{ - */ - -#define ADC1_CSR_RESET_VALUE ((u8)0x00) -#define ADC1_CR1_RESET_VALUE ((u8)0x00) -#define ADC1_CR2_RESET_VALUE ((u8)0x00) -#define ADC1_CR3_RESET_VALUE ((u8)0x00) -#define ADC1_TDRL_RESET_VALUE ((u8)0x00) -#define ADC1_TDRH_RESET_VALUE ((u8)0x00) -#define ADC1_HTRL_RESET_VALUE ((u8)0x03) -#define ADC1_HTRH_RESET_VALUE ((u8)0xFF) -#define ADC1_LTRH_RESET_VALUE ((u8)0x00) -#define ADC1_LTRL_RESET_VALUE ((u8)0x00) -#define ADC1_AWCRH_RESET_VALUE ((u8)0x00) -#define ADC1_AWCRL_RESET_VALUE ((u8)0x00) - -/** - * @} - */ - -/** @addtogroup ADC1_Registers_Bits_Definition - * @{ - */ - -#define ADC1_CSR_EOC ((u8)0x80) /*!< End of Conversion mask */ -#define ADC1_CSR_AWD ((u8)0x40) /*!< Analog Watch Dog Status mask */ -#define ADC1_CSR_EOCIE ((u8)0x20) /*!< Interrupt Enable for EOC mask */ -#define ADC1_CSR_AWDIE ((u8)0x10) /*!< Analog Watchdog interrupt enable mask */ -#define ADC1_CSR_CH ((u8)0x0F) /*!< Channel selection bits mask */ - -#define ADC1_CR1_SPSEL ((u8)0x70) /*!< Prescaler selectiont mask */ -#define ADC1_CR1_CONT ((u8)0x02) /*!< Continuous conversion mask */ -#define ADC1_CR1_ADON ((u8)0x01) /*!< A/D Converter on/off mask */ - -#define ADC1_CR2_EXTTRIG ((u8)0x40) /*!< External trigger enable mask */ -#define ADC1_CR2_EXTSEL ((u8)0x30) /*!< External event selection mask */ -#define ADC1_CR2_ALIGN ((u8)0x08) /*!< Data Alignment mask */ -#define ADC1_CR2_SCAN ((u8)0x02) /*!< Scan mode mask */ - -#define ADC1_CR3_DBUF ((u8)0x80) /*!< Data Buffer Enable mask */ -#define ADC1_CR3_OVR ((u8)0x40) /*!< Overrun Status Flag mask */ - -#endif /* (STM8S105) ||(STM8S103) || (STM8S903) */ -/** - * @} - */ - -/*----------------------------------------------------------------------------*/ -/** - * @brief Analog to Digital Converter (ADC2) - */ -#if defined(STM8S208) || defined(STM8S207) -typedef struct ADC2_struct -{ - vu8 CSR; /*!< ADC2 control status register */ - vu8 CR1; /*!< ADC2 configuration register 1 */ - vu8 CR2; /*!< ADC2 configuration register 2 */ - vu8 RESERVED; /*!< Reserved byte */ - vu8 DRH; /*!< ADC2 Data high */ - vu8 DRL; /*!< ADC2 Data low */ - vu8 TDRH; /*!< ADC2 Schmitt trigger disable register high */ - vu8 TDRL; /*!< ADC2 Schmitt trigger disable register low */ -} -ADC2_TypeDef; - -/** @addtogroup ADC2_Registers_Reset_Value - * @{ - */ - -#define ADC2_CSR_RESET_VALUE ((u8)0x00) -#define ADC2_CR1_RESET_VALUE ((u8)0x00) -#define ADC2_CR2_RESET_VALUE ((u8)0x00) -#define ADC2_TDRL_RESET_VALUE ((u8)0x00) -#define ADC2_TDRH_RESET_VALUE ((u8)0x00) - -/** - * @} - */ - -/** @addtogroup ADC2_Registers_Bits_Definition - * @{ - */ - -#define ADC2_CSR_EOC ((u8)0x80) /*!< End of Conversion mask */ -#define ADC2_CSR_EOCIE ((u8)0x20) /*!< Interrupt Enable for EOC mask */ -#define ADC2_CSR_CH ((u8)0x0F) /*!< Channel selection bits mask */ - -#define ADC2_CR1_SPSEL ((u8)0x70) /*!< Prescaler selectiont mask */ -#define ADC2_CR1_CONT ((u8)0x02) /*!< Continuous conversion mask */ -#define ADC2_CR1_ADON ((u8)0x01) /*!< A/D Converter on/off mask */ - -#define ADC2_CR2_EXTTRIG ((u8)0x40) /*!< External trigger enable mask */ -#define ADC2_CR2_EXTSEL ((u8)0x30) /*!< External event selection mask */ -#define ADC2_CR2_ALIGN ((u8)0x08) /*!< Data Alignment mask */ - -#endif /* (STM8S208) ||(STM8S207) */ -/** - * @} - */ -/*----------------------------------------------------------------------------*/ -/** - * @brief Auto Wake Up (AWU) peripheral registers. - */ - -typedef struct AWU_struct -{ - vu8 CSR; /*!< AWU Control status register */ - vu8 APR; /*!< AWU Asynchronous prescalar buffer */ - vu8 TBR; /*!< AWU Time base selection register */ -} -AWU_TypeDef; - -/** @addtogroup AWU_Registers_Reset_Value - * @{ - */ - -#define AWU_CSR_RESET_VALUE ((u8)0x00) -#define AWU_APR_RESET_VALUE ((u8)0x3F) -#define AWU_TBR_RESET_VALUE ((u8)0x00) - -/** - * @} - */ - -/** @addtogroup AWU_Registers_Bits_Definition - * @{ - */ - -#define AWU_CSR_AWUF ((u8)0x20) /*!< Interrupt flag mask */ -#define AWU_CSR_AWUEN ((u8)0x10) /*!< Auto Wake-up enable mask */ -#define AWU_CSR_MR ((u8)0x02) /*!< Master Reset mask */ -#define AWU_CSR_MSR ((u8)0x01) /*!< Measurement enable mask */ - -#define AWU_APR_APR ((u8)0x3F) /*!< Asynchronous Prescaler divider mask */ - -#define AWU_TBR_AWUTB ((u8)0x0F) /*!< Timebase selection mask */ - -/** - * @} - */ - -/*----------------------------------------------------------------------------*/ -/** - * @brief Beeper (BEEP) peripheral registers. - */ - -typedef struct BEEP_struct -{ - vu8 CSR; /*!< BEEP Control status register */ -} -BEEP_TypeDef; - -/** @addtogroup BEEP_Registers_Reset_Value - * @{ - */ - -#define BEEP_CSR_RESET_VALUE ((u8)0x1F) - -/** - * @} - */ - -/** @addtogroup BEEP_Registers_Bits_Definition - * @{ - */ - -#define BEEP_CSR_BEEPSEL ((u8)0xC0) /*!< Beeper frequency selection mask */ -#define BEEP_CSR_BEEPEN ((u8)0x20) /*!< Beeper enable mask */ -#define BEEP_CSR_BEEPDIV ((u8)0x1F) /*!< Beeper Divider prescalar mask */ - -/** - * @} - */ - -/*----------------------------------------------------------------------------*/ -/** - * @brief Clock Controller (CLK) - */ - -typedef struct CLK_struct -{ - vu8 ICKR; /*!< Internal Clocks Control Register */ - vu8 ECKR; /*!< External Clocks Control Register */ - u8 RESERVED; /*!< Reserved byte */ - vu8 CMSR; /*!< Clock Master Status Register */ - vu8 SWR; /*!< Clock Master Switch Register */ - vu8 SWCR; /*!< Switch Control Register */ - vu8 CKDIVR; /*!< Clock Divider Register */ - vu8 PCKENR1; /*!< Peripheral Clock Gating Register 1 */ - vu8 CSSR; /*!< Clock Security Sytem Register */ - vu8 CCOR; /*!< Configurable Clock Output Register */ - vu8 PCKENR2; /*!< Peripheral Clock Gating Register 2 */ - vu8 CANCCR; /*!< CAN external clock control Register (exist only in STM8S208 otherwise it is reserved) */ - vu8 HSITRIMR; /*!< HSI Calibration Trimmer Register */ - vu8 SWIMCCR; /*!< SWIM clock control register */ -} -CLK_TypeDef; - -/** @addtogroup CLK_Registers_Reset_Value - * @{ - */ - -#define CLK_ICKR_RESET_VALUE ((u8)0x01) -#define CLK_ECKR_RESET_VALUE ((u8)0x00) -#define CLK_CMSR_RESET_VALUE ((u8)0xE1) -#define CLK_SWR_RESET_VALUE ((u8)0xE1) -#define CLK_SWCR_RESET_VALUE ((u8)0x00) -#define CLK_CKDIVR_RESET_VALUE ((u8)0x18) -#define CLK_PCKENR1_RESET_VALUE ((u8)0xFF) -#define CLK_PCKENR2_RESET_VALUE ((u8)0xFF) -#define CLK_CSSR_RESET_VALUE ((u8)0x00) -#define CLK_CCOR_RESET_VALUE ((u8)0x00) -#define CLK_CANCCR_RESET_VALUE ((u8)0x00) -#define CLK_HSITRIMR_RESET_VALUE ((u8)0x00) -#define CLK_SWIMCCR_RESET_VALUE ((u8)0x00) - -/** - * @} - */ - -/** @addtogroup CLK_Registers_Bits_Definition - * @{ - */ - -#define CLK_ICKR_SWUAH ((u8)0x20) /*!< Slow Wake-up from Active Halt/Halt modes */ -#define CLK_ICKR_LSIRDY ((u8)0x10) /*!< Low speed internal oscillator ready */ -#define CLK_ICKR_LSIEN ((u8)0x08) /*!< Low speed internal RC oscillator enable */ -#define CLK_ICKR_FHWU ((u8)0x04) /*!< Fast Wake-up from Active Halt/Halt mode */ -#define CLK_ICKR_HSIRDY ((u8)0x02) /*!< High speed internal RC oscillator ready */ -#define CLK_ICKR_HSIEN ((u8)0x01) /*!< High speed internal RC oscillator enable */ - -#define CLK_ECKR_HSERDY ((u8)0x02) /*!< High speed external crystal oscillator ready */ -#define CLK_ECKR_HSEEN ((u8)0x01) /*!< High speed external crystal oscillator enable */ - -#define CLK_CMSR_CKM ((u8)0xFF) /*!< Clock master status bits */ - -#define CLK_SWR_SWI ((u8)0xFF) /*!< Clock master selection bits */ - -#define CLK_SWCR_SWIF ((u8)0x08) /*!< Clock switch interrupt flag */ -#define CLK_SWCR_SWIEN ((u8)0x04) /*!< Clock switch interrupt enable */ -#define CLK_SWCR_SWEN ((u8)0x02) /*!< Switch start/stop */ -#define CLK_SWCR_SWBSY ((u8)0x01) /*!< Switch busy */ - -#define CLK_CKDIVR_HSIDIV ((u8)0x18) /*!< High speed internal clock prescaler */ -#define CLK_CKDIVR_CPUDIV ((u8)0x07) /*!< CPU clock prescaler */ - -#define CLK_PCKENR1_TIM1 ((u8)0x80) /*!< Timer 1 clock enable */ -#define CLK_PCKENR1_TIM3 ((u8)0x40) /*!< Timer 3 clock enable */ -#define CLK_PCKENR1_TIM2 ((u8)0x20) /*!< Timer 2 clock enable */ -#define CLK_PCKENR1_TIM5 ((u8)0x20) /*!< Timer 5 clock enable */ -#define CLK_PCKENR1_TIM4 ((u8)0x10) /*!< Timer 4 clock enable */ -#define CLK_PCKENR1_TIM6 ((u8)0x10) /*!< Timer 6 clock enable */ -#define CLK_PCKENR1_UART3 ((u8)0x08) /*!< UART3 clock enable */ -#define CLK_PCKENR1_UART2 ((u8)0x08) /*!< UART2 clock enable */ -#define CLK_PCKENR1_UART1 ((u8)0x04) /*!< UART1 clock enable */ -#define CLK_PCKENR1_SPI ((u8)0x02) /*!< SPI clock enable */ -#define CLK_PCKENR1_I2C ((u8)0x01) /*!< I2C clock enable */ - -#define CLK_PCKENR2_CAN ((u8)0x80) /*!< CAN clock enable */ -#define CLK_PCKENR2_ADC ((u8)0x08) /*!< ADC clock enable */ -#define CLK_PCKENR2_AWU ((u8)0x04) /*!< AWU clock enable */ - -#define CLK_CSSR_CSSD ((u8)0x08) /*!< Clock security sytem detection */ -#define CLK_CSSR_CSSDIE ((u8)0x04) /*!< Clock security system detection interrupt enable */ -#define CLK_CSSR_AUX ((u8)0x02) /*!< Auxiliary oscillator connected to master clock */ -#define CLK_CSSR_CSSEN ((u8)0x01) /*!< Clock security system enable */ - -#define CLK_CCOR_CCOBSY ((u8)0x40) /*!< Configurable clock output busy */ -#define CLK_CCOR_CCORDY ((u8)0x20) /*!< Configurable clock output ready */ -#define CLK_CCOR_CCOSEL ((u8)0x1E) /*!< Configurable clock output selection */ -#define CLK_CCOR_CCOEN ((u8)0x01) /*!< Configurable clock output enable */ - -#define CLK_CANCCR_CANDIV ((u8)0x07) /*!< External CAN clock divider */ - -#define CLK_HSITRIMR_HSITRIM ((u8)0x07) /*!< High speed internal oscillator trimmer */ - -#define CLK_SWIMCCR_SWIMDIV ((u8)0x01) /*!< SWIM Clock Dividing Factor */ - -/** - * @} - */ - -/*----------------------------------------------------------------------------*/ -/** - * @brief 16-bit timer with complementary PWM outputs (TIM1) - */ - -typedef struct TIM1_struct -{ - vu8 CR1; /*!< control register 1 */ - vu8 CR2; /*!< control register 2 */ - vu8 SMCR; /*!< Synchro mode control register */ - vu8 ETR; /*!< external trigger register */ - vu8 IER; /*!< interrupt enable register*/ - vu8 SR1; /*!< status register 1 */ - vu8 SR2; /*!< status register 2 */ - vu8 EGR; /*!< event generation register */ - vu8 CCMR1; /*!< CC mode register 1 */ - vu8 CCMR2; /*!< CC mode register 2 */ - vu8 CCMR3; /*!< CC mode register 3 */ - vu8 CCMR4; /*!< CC mode register 4 */ - vu8 CCER1; /*!< CC enable register 1 */ - vu8 CCER2; /*!< CC enable register 2 */ - vu8 CNTRH; /*!< counter high */ - vu8 CNTRL; /*!< counter low */ - vu8 PSCRH; /*!< prescaler high */ - vu8 PSCRL; /*!< prescaler low */ - vu8 ARRH; /*!< auto-reload register high */ - vu8 ARRL; /*!< auto-reload register low */ - vu8 RCR; /*!< Repetition Counter register */ - vu8 CCR1H; /*!< capture/compare register 1 high */ - vu8 CCR1L; /*!< capture/compare register 1 low */ - vu8 CCR2H; /*!< capture/compare register 2 high */ - vu8 CCR2L; /*!< capture/compare register 2 low */ - vu8 CCR3H; /*!< capture/compare register 3 high */ - vu8 CCR3L; /*!< capture/compare register 3 low */ - vu8 CCR4H; /*!< capture/compare register 3 high */ - vu8 CCR4L; /*!< capture/compare register 3 low */ - vu8 BKR; /*!< Break Register */ - vu8 DTR; /*!< dead-time register */ - vu8 OISR; /*!< Output idle register */ -} -TIM1_TypeDef; - -/** @addtogroup TIM1_Registers_Reset_Value - * @{ - */ - -#define TIM1_CR1_RESET_VALUE ((u8)0x00) -#define TIM1_CR2_RESET_VALUE ((u8)0x00) -#define TIM1_SMCR_RESET_VALUE ((u8)0x00) -#define TIM1_ETR_RESET_VALUE ((u8)0x00) -#define TIM1_IER_RESET_VALUE ((u8)0x00) -#define TIM1_SR1_RESET_VALUE ((u8)0x00) -#define TIM1_SR2_RESET_VALUE ((u8)0x00) -#define TIM1_EGR_RESET_VALUE ((u8)0x00) -#define TIM1_CCMR1_RESET_VALUE ((u8)0x00) -#define TIM1_CCMR2_RESET_VALUE ((u8)0x00) -#define TIM1_CCMR3_RESET_VALUE ((u8)0x00) -#define TIM1_CCMR4_RESET_VALUE ((u8)0x00) -#define TIM1_CCER1_RESET_VALUE ((u8)0x00) -#define TIM1_CCER2_RESET_VALUE ((u8)0x00) -#define TIM1_CNTRH_RESET_VALUE ((u8)0x00) -#define TIM1_CNTRL_RESET_VALUE ((u8)0x00) -#define TIM1_PSCRH_RESET_VALUE ((u8)0x00) -#define TIM1_PSCRL_RESET_VALUE ((u8)0x00) -#define TIM1_ARRH_RESET_VALUE ((u8)0xFF) -#define TIM1_ARRL_RESET_VALUE ((u8)0xFF) -#define TIM1_RCR_RESET_VALUE ((u8)0x00) -#define TIM1_CCR1H_RESET_VALUE ((u8)0x00) -#define TIM1_CCR1L_RESET_VALUE ((u8)0x00) -#define TIM1_CCR2H_RESET_VALUE ((u8)0x00) -#define TIM1_CCR2L_RESET_VALUE ((u8)0x00) -#define TIM1_CCR3H_RESET_VALUE ((u8)0x00) -#define TIM1_CCR3L_RESET_VALUE ((u8)0x00) -#define TIM1_CCR4H_RESET_VALUE ((u8)0x00) -#define TIM1_CCR4L_RESET_VALUE ((u8)0x00) -#define TIM1_BKR_RESET_VALUE ((u8)0x00) -#define TIM1_DTR_RESET_VALUE ((u8)0x00) -#define TIM1_OISR_RESET_VALUE ((u8)0x00) - -/** - * @} - */ - -/** @addtogroup TIM1_Registers_Bits_Definition - * @{ - */ -/* CR1*/ -#define TIM1_CR1_ARPE ((u8)0x80) /*!< Auto-Reload Preload Enable mask. */ -#define TIM1_CR1_CMS ((u8)0x60) /*!< Center-aligned Mode Selection mask. */ -#define TIM1_CR1_DIR ((u8)0x10) /*!< Direction mask. */ -#define TIM1_CR1_OPM ((u8)0x08) /*!< One Pulse Mode mask. */ -#define TIM1_CR1_URS ((u8)0x04) /*!< Update Request Source mask. */ -#define TIM1_CR1_UDIS ((u8)0x02) /*!< Update DIsable mask. */ -#define TIM1_CR1_CEN ((u8)0x01) /*!< Counter Enable mask. */ -/* CR2*/ -#define TIM1_CR2_TI1S ((u8)0x80) /*!< TI1S Selection mask. */ -#define TIM1_CR2_MMS ((u8)0x70) /*!< MMS Selection mask. */ -#define TIM1_CR2_COMS ((u8)0x04) /*!< Capture/Compare Control Update Selection mask. */ -#define TIM1_CR2_CCPC ((u8)0x01) /*!< Capture/Compare Preloaded Control mask. */ -/* SMCR*/ -#define TIM1_SMCR_MSM ((u8)0x80) /*!< Master/Slave Mode mask. */ -#define TIM1_SMCR_TS ((u8)0x70) /*!< Trigger Selection mask. */ -#define TIM1_SMCR_SMS ((u8)0x07) /*!< Slave Mode Selection mask. */ -/*ETR*/ -#define TIM1_ETR_ETP ((u8)0x80) /*!< External Trigger Polarity mask. */ -#define TIM1_ETR_ECE ((u8)0x40)/*!< External Clock mask. */ -#define TIM1_ETR_ETPS ((u8)0x30) /*!< External Trigger Prescaler mask. */ -#define TIM1_ETR_ETF ((u8)0x0F) /*!< External Trigger Filter mask. */ -/*IER*/ -#define TIM1_IER_BIE ((u8)0x80) /*!< Break Interrupt Enable mask. */ -#define TIM1_IER_TIE ((u8)0x40) /*!< Trigger Interrupt Enable mask. */ -#define TIM1_IER_COMIE ((u8)0x20) /*!< Commutation Interrupt Enable mask.*/ -#define TIM1_IER_CC4IE ((u8)0x10) /*!< Capture/Compare 4 Interrupt Enable mask. */ -#define TIM1_IER_CC3IE ((u8)0x08) /*!< Capture/Compare 3 Interrupt Enable mask. */ -#define TIM1_IER_CC2IE ((u8)0x04) /*!< Capture/Compare 2 Interrupt Enable mask. */ -#define TIM1_IER_CC1IE ((u8)0x02) /*!< Capture/Compare 1 Interrupt Enable mask. */ -#define TIM1_IER_UIE ((u8)0x01) /*!< Update Interrupt Enable mask. */ -/*SR1*/ -#define TIM1_SR1_BIF ((u8)0x80) /*!< Break Interrupt Flag mask. */ -#define TIM1_SR1_TIF ((u8)0x40) /*!< Trigger Interrupt Flag mask. */ -#define TIM1_SR1_COMIF ((u8)0x20) /*!< Commutation Interrupt Flag mask. */ -#define TIM1_SR1_CC4IF ((u8)0x10) /*!< Capture/Compare 4 Interrupt Flag mask. */ -#define TIM1_SR1_CC3IF ((u8)0x08) /*!< Capture/Compare 3 Interrupt Flag mask. */ -#define TIM1_SR1_CC2IF ((u8)0x04) /*!< Capture/Compare 2 Interrupt Flag mask. */ -#define TIM1_SR1_CC1IF ((u8)0x02) /*!< Capture/Compare 1 Interrupt Flag mask. */ -#define TIM1_SR1_UIF ((u8)0x01) /*!< Update Interrupt Flag mask. */ -/*SR2*/ -#define TIM1_SR2_CC4OF ((u8)0x10) /*!< Capture/Compare 4 Overcapture Flag mask. */ -#define TIM1_SR2_CC3OF ((u8)0x08) /*!< Capture/Compare 3 Overcapture Flag mask. */ -#define TIM1_SR2_CC2OF ((u8)0x04) /*!< Capture/Compare 2 Overcapture Flag mask. */ -#define TIM1_SR2_CC1OF ((u8)0x02) /*!< Capture/Compare 1 Overcapture Flag mask. */ -/*EGR*/ -#define TIM1_EGR_BG ((u8)0x80) /*!< Break Generation mask. */ -#define TIM1_EGR_TG ((u8)0x40) /*!< Trigger Generation mask. */ -#define TIM1_EGR_COMG ((u8)0x20) /*!< Capture/Compare Control Update Generation mask. */ -#define TIM1_EGR_CC4G ((u8)0x10) /*!< Capture/Compare 4 Generation mask. */ -#define TIM1_EGR_CC3G ((u8)0x08) /*!< Capture/Compare 3 Generation mask. */ -#define TIM1_EGR_CC2G ((u8)0x04) /*!< Capture/Compare 2 Generation mask. */ -#define TIM1_EGR_CC1G ((u8)0x02) /*!< Capture/Compare 1 Generation mask. */ -#define TIM1_EGR_UG ((u8)0x01) /*!< Update Generation mask. */ -/*CCMR*/ -#define TIM1_CCMR_ICxPSC ((u8)0x0C) /*!< Input Capture x Prescaler mask. */ -#define TIM1_CCMR_ICxF ((u8)0xF0) /*!< Input Capture x Filter mask. */ -#define TIM1_CCMR_OCM ((u8)0x70) /*!< Output Compare x Mode mask. */ -#define TIM1_CCMR_OCxPE ((u8)0x08) /*!< Output Compare x Preload Enable mask. */ -#define TIM1_CCMR_OCxFE ((u8)0x04) /*!< Output Compare x Fast Enable mask. */ -#define TIM1_CCMR_CCxS ((u8)0x03) /*!< Capture/Compare x Selection mask. */ - -#define CCMR_TIxDirect_Set ((u8)0x01) -/*CCER1*/ -#define TIM1_CCER1_CC2NP ((u8)0x80) /*!< Capture/Compare 2 Complementary output Polarity mask. */ -#define TIM1_CCER1_CC2NE ((u8)0x40) /*!< Capture/Compare 2 Complementary output enable mask. */ -#define TIM1_CCER1_CC2P ((u8)0x20) /*!< Capture/Compare 2 output Polarity mask. */ -#define TIM1_CCER1_CC2E ((u8)0x10) /*!< Capture/Compare 2 output enable mask. */ -#define TIM1_CCER1_CC1NP ((u8)0x08) /*!< Capture/Compare 1 Complementary output Polarity mask. */ -#define TIM1_CCER1_CC1NE ((u8)0x04) /*!< Capture/Compare 1 Complementary output enable mask. */ -#define TIM1_CCER1_CC1P ((u8)0x02) /*!< Capture/Compare 1 output Polarity mask. */ -#define TIM1_CCER1_CC1E ((u8)0x01) /*!< Capture/Compare 1 output enable mask. */ -/*CCER2*/ -#define TIM1_CCER2_CC4P ((u8)0x20) /*!< Capture/Compare 4 output Polarity mask. */ -#define TIM1_CCER2_CC4E ((u8)0x10) /*!< Capture/Compare 4 output enable mask. */ -#define TIM1_CCER2_CC3NP ((u8)0x08) /*!< Capture/Compare 3 Complementary output Polarity mask. */ -#define TIM1_CCER2_CC3NE ((u8)0x04) /*!< Capture/Compare 3 Complementary output enable mask. */ -#define TIM1_CCER2_CC3P ((u8)0x02) /*!< Capture/Compare 3 output Polarity mask. */ -#define TIM1_CCER2_CC3E ((u8)0x01) /*!< Capture/Compare 3 output enable mask. */ -/*CNTRH*/ -#define TIM1_CNTRH_CNT ((u8)0xFF) /*!< Counter Value (MSB) mask. */ -/*CNTRL*/ -#define TIM1_CNTRL_CNT ((u8)0xFF) /*!< Counter Value (LSB) mask. */ -/*PSCH*/ -#define TIM1_PSCH_PSC ((u8)0xFF) /*!< Prescaler Value (MSB) mask. */ -/*PSCL*/ -#define TIM1_PSCL_PSC ((u8)0xFF) /*!< Prescaler Value (LSB) mask. */ -/*ARR*/ -#define TIM1_ARRH_ARR ((u8)0xFF) /*!< Autoreload Value (MSB) mask. */ -#define TIM1_ARRL_ARR ((u8)0xFF) /*!< Autoreload Value (LSB) mask. */ -/*RCR*/ -#define TIM1_RCR_REP ((u8)0xFF) /*!< Repetition Counter Value mask. */ -/*CCR1*/ -#define TIM1_CCR1H_CCR1 ((u8)0xFF) /*!< Capture/Compare 1 Value (MSB) mask. */ -#define TIM1_CCR1L_CCR1 ((u8)0xFF) /*!< Capture/Compare 1 Value (LSB) mask. */ -/*CCR2*/ -#define TIM1_CCR2H_CCR2 ((u8)0xFF) /*!< Capture/Compare 2 Value (MSB) mask. */ -#define TIM1_CCR2L_CCR2 ((u8)0xFF) /*!< Capture/Compare 2 Value (LSB) mask. */ -/*CCR3*/ -#define TIM1_CCR3H_CCR3 ((u8)0xFF) /*!< Capture/Compare 3 Value (MSB) mask. */ -#define TIM1_CCR3L_CCR3 ((u8)0xFF) /*!< Capture/Compare 3 Value (LSB) mask. */ -/*CCR4*/ -#define TIM1_CCR4H_CCR4 ((u8)0xFF) /*!< Capture/Compare 4 Value (MSB) mask. */ -#define TIM1_CCR4L_CCR4 ((u8)0xFF) /*!< Capture/Compare 4 Value (LSB) mask. */ -/*BKR*/ -#define TIM1_BKR_MOE ((u8)0x80) /*!< Main Output Enable mask. */ -#define TIM1_BKR_AOE ((u8)0x40) /*!< Automatic Output Enable mask. */ -#define TIM1_BKR_BKP ((u8)0x20) /*!< Break Polarity mask. */ -#define TIM1_BKR_BKE ((u8)0x10) /*!< Break Enable mask. */ -#define TIM1_BKR_OSSR ((u8)0x08) /*!< Off-State Selection for Run mode mask. */ -#define TIM1_BKR_OSSI ((u8)0x04) /*!< Off-State Selection for Idle mode mask. */ -#define TIM1_BKR_LOCK ((u8)0x03) /*!< Lock Configuration mask. */ -/*DTR*/ -#define TIM1_DTR_DTG ((u8)0xFF) /*!< Dead-Time Generator set-up mask. */ -/*OISR*/ -#define TIM1_OISR_OIS4 ((u8)0x40) /*!< Output Idle state 4 (OC4 output) mask. */ -#define TIM1_OISR_OIS3N ((u8)0x20) /*!< Output Idle state 3 (OC3N output) mask. */ -#define TIM1_OISR_OIS3 ((u8)0x10) /*!< Output Idle state 3 (OC3 output) mask. */ -#define TIM1_OISR_OIS2N ((u8)0x08) /*!< Output Idle state 2 (OC2N output) mask. */ -#define TIM1_OISR_OIS2 ((u8)0x04) /*!< Output Idle state 2 (OC2 output) mask. */ -#define TIM1_OISR_OIS1N ((u8)0x02) /*!< Output Idle state 1 (OC1N output) mask. */ -#define TIM1_OISR_OIS1 ((u8)0x01) /*!< Output Idle state 1 (OC1 output) mask. */ - -/** - * @} - */ - -/*----------------------------------------------------------------------------*/ -/** - * @brief 16-bit timer (TIM2) - */ - -typedef struct TIM2_struct -{ - vu8 CR1; /*!< control register 1 */ -#if defined STM8S103 - vu8 RESERVED1; /*!< Reserved register */ - vu8 RESERVED2; /*!< Reserved register */ -#endif - vu8 IER; /*!< interrupt enable register */ - vu8 SR1; /*!< status register 1 */ - vu8 SR2; /*!< status register 2 */ - vu8 EGR; /*!< event generation register */ - vu8 CCMR1; /*!< CC mode register 1 */ - vu8 CCMR2; /*!< CC mode register 2 */ - vu8 CCMR3; /*!< CC mode register 3 */ - vu8 CCER1; /*!< CC enable register 1 */ - vu8 CCER2; /*!< CC enable register 2 */ - vu8 CNTRH; /*!< counter high */ - vu8 CNTRL; /*!< counter low */ - vu8 PSCR; /*!< prescaler register */ - vu8 ARRH; /*!< auto-reload register high */ - vu8 ARRL; /*!< auto-reload register low */ - vu8 CCR1H; /*!< capture/compare register 1 high */ - vu8 CCR1L; /*!< capture/compare register 1 low */ - vu8 CCR2H; /*!< capture/compare register 2 high */ - vu8 CCR2L; /*!< capture/compare register 2 low */ - vu8 CCR3H; /*!< capture/compare register 3 high */ - vu8 CCR3L; /*!< capture/compare register 3 low */ -} -TIM2_TypeDef; - -/** @addtogroup TIM2_Registers_Reset_Value - * @{ - */ - -#define TIM2_CR1_RESET_VALUE ((u8)0x00) -#define TIM2_IER_RESET_VALUE ((u8)0x00) -#define TIM2_SR1_RESET_VALUE ((u8)0x00) -#define TIM2_SR2_RESET_VALUE ((u8)0x00) -#define TIM2_EGR_RESET_VALUE ((u8)0x00) -#define TIM2_CCMR1_RESET_VALUE ((u8)0x00) -#define TIM2_CCMR2_RESET_VALUE ((u8)0x00) -#define TIM2_CCMR3_RESET_VALUE ((u8)0x00) -#define TIM2_CCER1_RESET_VALUE ((u8)0x00) -#define TIM2_CCER2_RESET_VALUE ((u8)0x00) -#define TIM2_CNTRH_RESET_VALUE ((u8)0x00) -#define TIM2_CNTRL_RESET_VALUE ((u8)0x00) -#define TIM2_PSCR_RESET_VALUE ((u8)0x00) -#define TIM2_ARRH_RESET_VALUE ((u8)0xFF) -#define TIM2_ARRL_RESET_VALUE ((u8)0xFF) -#define TIM2_CCR1H_RESET_VALUE ((u8)0x00) -#define TIM2_CCR1L_RESET_VALUE ((u8)0x00) -#define TIM2_CCR2H_RESET_VALUE ((u8)0x00) -#define TIM2_CCR2L_RESET_VALUE ((u8)0x00) -#define TIM2_CCR3H_RESET_VALUE ((u8)0x00) -#define TIM2_CCR3L_RESET_VALUE ((u8)0x00) - -/** - * @} - */ - -/** @addtogroup TIM2_Registers_Bits_Definition - * @{ - */ -/*CR1*/ -#define TIM2_CR1_ARPE ((u8)0x80) /*!< Auto-Reload Preload Enable mask. */ -#define TIM2_CR1_OPM ((u8)0x08) /*!< One Pulse Mode mask. */ -#define TIM2_CR1_URS ((u8)0x04) /*!< Update Request Source mask. */ -#define TIM2_CR1_UDIS ((u8)0x02) /*!< Update DIsable mask. */ -#define TIM2_CR1_CEN ((u8)0x01) /*!< Counter Enable mask. */ -/*IER*/ -#define TIM2_IER_CC3IE ((u8)0x08) /*!< Capture/Compare 3 Interrupt Enable mask. */ -#define TIM2_IER_CC2IE ((u8)0x04) /*!< Capture/Compare 2 Interrupt Enable mask. */ -#define TIM2_IER_CC1IE ((u8)0x02) /*!< Capture/Compare 1 Interrupt Enable mask. */ -#define TIM2_IER_UIE ((u8)0x01) /*!< Update Interrupt Enable mask. */ -/*SR1*/ -#define TIM2_SR1_CC3IF ((u8)0x08) /*!< Capture/Compare 3 Interrupt Flag mask. */ -#define TIM2_SR1_CC2IF ((u8)0x04) /*!< Capture/Compare 2 Interrupt Flag mask. */ -#define TIM2_SR1_CC1IF ((u8)0x02) /*!< Capture/Compare 1 Interrupt Flag mask. */ -#define TIM2_SR1_UIF ((u8)0x01) /*!< Update Interrupt Flag mask. */ -/*SR2*/ -#define TIM2_SR2_CC3OF ((u8)0x08) /*!< Capture/Compare 3 Overcapture Flag mask. */ -#define TIM2_SR2_CC2OF ((u8)0x04) /*!< Capture/Compare 2 Overcapture Flag mask. */ -#define TIM2_SR2_CC1OF ((u8)0x02) /*!< Capture/Compare 1 Overcapture Flag mask. */ -/*EGR*/ -#define TIM2_EGR_CC3G ((u8)0x08) /*!< Capture/Compare 3 Generation mask. */ -#define TIM2_EGR_CC2G ((u8)0x04) /*!< Capture/Compare 2 Generation mask. */ -#define TIM2_EGR_CC1G ((u8)0x02) /*!< Capture/Compare 1 Generation mask. */ -#define TIM2_EGR_UG ((u8)0x01) /*!< Update Generation mask. */ -/*CCMR*/ -#define TIM2_CCMR_ICxPSC ((u8)0x0C) /*!< Input Capture x Prescaler mask. */ -#define TIM2_CCMR_ICxF ((u8)0xF0) /*!< Input Capture x Filter mask. */ -#define TIM2_CCMR_OCM ((u8)0x70) /*!< Output Compare x Mode mask. */ -#define TIM2_CCMR_OCxPE ((u8)0x08) /*!< Output Compare x Preload Enable mask. */ -#define TIM2_CCMR_CCxS ((u8)0x03) /*!< Capture/Compare x Selection mask. */ -/*CCER1*/ -#define TIM2_CCER1_CC2P ((u8)0x20) /*!< Capture/Compare 2 output Polarity mask. */ -#define TIM2_CCER1_CC2E ((u8)0x10) /*!< Capture/Compare 2 output enable mask. */ -#define TIM2_CCER1_CC1P ((u8)0x02) /*!< Capture/Compare 1 output Polarity mask. */ -#define TIM2_CCER1_CC1E ((u8)0x01) /*!< Capture/Compare 1 output enable mask. */ -/*CCER2*/ -#define TIM2_CCER2_CC3P ((u8)0x02) /*!< Capture/Compare 3 output Polarity mask. */ -#define TIM2_CCER2_CC3E ((u8)0x01) /*!< Capture/Compare 3 output enable mask. */ -/*CNTR*/ -#define TIM2_CNTRH_CNT ((u8)0xFF) /*!< Counter Value (MSB) mask. */ -#define TIM2_CNTRL_CNT ((u8)0xFF) /*!< Counter Value (LSB) mask. */ -/*PSCR*/ -#define TIM2_PSCR_PSC ((u8)0xFF) /*!< Prescaler Value (MSB) mask. */ -/*ARR*/ -#define TIM2_ARRH_ARR ((u8)0xFF) /*!< Autoreload Value (MSB) mask. */ -#define TIM2_ARRL_ARR ((u8)0xFF) /*!< Autoreload Value (LSB) mask. */ -/*CCR1*/ -#define TIM2_CCR1H_CCR1 ((u8)0xFF) /*!< Capture/Compare 1 Value (MSB) mask. */ -#define TIM2_CCR1L_CCR1 ((u8)0xFF) /*!< Capture/Compare 1 Value (LSB) mask. */ -/*CCR2*/ -#define TIM2_CCR2H_CCR2 ((u8)0xFF) /*!< Capture/Compare 2 Value (MSB) mask. */ -#define TIM2_CCR2L_CCR2 ((u8)0xFF) /*!< Capture/Compare 2 Value (LSB) mask. */ -/*CCR3*/ -#define TIM2_CCR3H_CCR3 ((u8)0xFF) /*!< Capture/Compare 3 Value (MSB) mask. */ -#define TIM2_CCR3L_CCR3 ((u8)0xFF) /*!< Capture/Compare 3 Value (LSB) mask. */ - -/** - * @} - */ - -/*----------------------------------------------------------------------------*/ -/** - * @brief 16-bit timer (TIM3) - */ -typedef struct TIM3_struct -{ - vu8 CR1; /*!< control register 1 */ - vu8 IER; /*!< interrupt enable register */ - vu8 SR1; /*!< status register 1 */ - vu8 SR2; /*!< status register 2 */ - vu8 EGR; /*!< event generation register */ - vu8 CCMR1; /*!< CC mode register 1 */ - vu8 CCMR2; /*!< CC mode register 2 */ - vu8 CCER1; /*!< CC enable register 1 */ - vu8 CNTRH; /*!< counter high */ - vu8 CNTRL; /*!< counter low */ - vu8 PSCR; /*!< prescaler register */ - vu8 ARRH; /*!< auto-reload register high */ - vu8 ARRL; /*!< auto-reload register low */ - vu8 CCR1H; /*!< capture/compare register 1 high */ - vu8 CCR1L; /*!< capture/compare register 1 low */ - vu8 CCR2H; /*!< capture/compare register 2 high */ - vu8 CCR2L; /*!< capture/compare register 2 low */ -} -TIM3_TypeDef; - -/** @addtogroup TIM3_Registers_Reset_Value - * @{ - */ - -#define TIM3_CR1_RESET_VALUE ((u8)0x00) -#define TIM3_IER_RESET_VALUE ((u8)0x00) -#define TIM3_SR1_RESET_VALUE ((u8)0x00) -#define TIM3_SR2_RESET_VALUE ((u8)0x00) -#define TIM3_EGR_RESET_VALUE ((u8)0x00) -#define TIM3_CCMR1_RESET_VALUE ((u8)0x00) -#define TIM3_CCMR2_RESET_VALUE ((u8)0x00) -#define TIM3_CCER1_RESET_VALUE ((u8)0x00) -#define TIM3_CNTRH_RESET_VALUE ((u8)0x00) -#define TIM3_CNTRL_RESET_VALUE ((u8)0x00) -#define TIM3_PSCR_RESET_VALUE ((u8)0x00) -#define TIM3_ARRH_RESET_VALUE ((u8)0xFF) -#define TIM3_ARRL_RESET_VALUE ((u8)0xFF) -#define TIM3_CCR1H_RESET_VALUE ((u8)0x00) -#define TIM3_CCR1L_RESET_VALUE ((u8)0x00) -#define TIM3_CCR2H_RESET_VALUE ((u8)0x00) -#define TIM3_CCR2L_RESET_VALUE ((u8)0x00) - -/** - * @} - */ - -/** @addtogroup TIM3_Registers_Bits_Definition - * @{ - */ -/*CR1*/ -#define TIM3_CR1_ARPE ((u8)0x80) /*!< Auto-Reload Preload Enable mask. */ -#define TIM3_CR1_OPM ((u8)0x08) /*!< One Pulse Mode mask. */ -#define TIM3_CR1_URS ((u8)0x04) /*!< Update Request Source mask. */ -#define TIM3_CR1_UDIS ((u8)0x02) /*!< Update DIsable mask. */ -#define TIM3_CR1_CEN ((u8)0x01) /*!< Counter Enable mask. */ -/*IER*/ -#define TIM3_IER_CC2IE ((u8)0x04) /*!< Capture/Compare 2 Interrupt Enable mask. */ -#define TIM3_IER_CC1IE ((u8)0x02) /*!< Capture/Compare 1 Interrupt Enable mask. */ -#define TIM3_IER_UIE ((u8)0x01) /*!< Update Interrupt Enable mask. */ -/*SR1*/ -#define TIM3_SR1_CC2IF ((u8)0x04) /*!< Capture/Compare 2 Interrupt Flag mask. */ -#define TIM3_SR1_CC1IF ((u8)0x02) /*!< Capture/Compare 1 Interrupt Flag mask. */ -#define TIM3_SR1_UIF ((u8)0x01) /*!< Update Interrupt Flag mask. */ -/*SR2*/ -#define TIM3_SR2_CC2OF ((u8)0x04) /*!< Capture/Compare 2 Overcapture Flag mask. */ -#define TIM3_SR2_CC1OF ((u8)0x02) /*!< Capture/Compare 1 Overcapture Flag mask. */ -/*EGR*/ -#define TIM3_EGR_CC2G ((u8)0x04) /*!< Capture/Compare 2 Generation mask. */ -#define TIM3_EGR_CC1G ((u8)0x02) /*!< Capture/Compare 1 Generation mask. */ -#define TIM3_EGR_UG ((u8)0x01) /*!< Update Generation mask. */ -/*CCMR*/ -#define TIM3_CCMR_ICxPSC ((u8)0x0C) /*!< Input Capture x Prescaler mask. */ -#define TIM3_CCMR_ICxF ((u8)0xF0) /*!< Input Capture x Filter mask. */ -#define TIM3_CCMR_OCM ((u8)0x70) /*!< Output Compare x Mode mask. */ -#define TIM3_CCMR_OCxPE ((u8)0x08) /*!< Output Compare x Preload Enable mask. */ -#define TIM3_CCMR_CCxS ((u8)0x03) /*!< Capture/Compare x Selection mask. */ -/*CCER1*/ -#define TIM3_CCER1_CC2P ((u8)0x20) /*!< Capture/Compare 2 output Polarity mask. */ -#define TIM3_CCER1_CC2E ((u8)0x10) /*!< Capture/Compare 2 output enable mask. */ -#define TIM3_CCER1_CC1P ((u8)0x02) /*!< Capture/Compare 1 output Polarity mask. */ -#define TIM3_CCER1_CC1E ((u8)0x01) /*!< Capture/Compare 1 output enable mask. */ -/*CNTR*/ -#define TIM3_CNTRH_CNT ((u8)0xFF) /*!< Counter Value (MSB) mask. */ -#define TIM3_CNTRL_CNT ((u8)0xFF) /*!< Counter Value (LSB) mask. */ -/*PSCR*/ -#define TIM3_PSCR_PSC ((u8)0xFF) /*!< Prescaler Value (MSB) mask. */ -/*ARR*/ -#define TIM3_ARRH_ARR ((u8)0xFF) /*!< Autoreload Value (MSB) mask. */ -#define TIM3_ARRL_ARR ((u8)0xFF) /*!< Autoreload Value (LSB) mask. */ -/*CCR1*/ -#define TIM3_CCR1H_CCR1 ((u8)0xFF) /*!< Capture/Compare 1 Value (MSB) mask. */ -#define TIM3_CCR1L_CCR1 ((u8)0xFF) /*!< Capture/Compare 1 Value (LSB) mask. */ -/*CCR2*/ -#define TIM3_CCR2H_CCR2 ((u8)0xFF) /*!< Capture/Compare 2 Value (MSB) mask. */ -#define TIM3_CCR2L_CCR2 ((u8)0xFF) /*!< Capture/Compare 2 Value (LSB) mask. */ - -/** - * @} - */ - -/*----------------------------------------------------------------------------*/ -/** - * @brief 8-bit system timer (TIM4) - */ - -typedef struct TIM4_struct -{ - vu8 CR1; /*!< control register 1 */ -#if defined STM8S103 - vu8 RESERVED1; /*!< Reserved register */ - vu8 RESERVED2; /*!< Reserved register */ -#endif - vu8 IER; /*!< interrupt enable register */ - vu8 SR1; /*!< status register 1 */ - vu8 EGR; /*!< event generation register */ - vu8 CNTR; /*!< counter register */ - vu8 PSCR; /*!< prescaler register */ - vu8 ARR; /*!< auto-reload register */ -} -TIM4_TypeDef; - -/** @addtogroup TIM4_Registers_Reset_Value - * @{ - */ - -#define TIM4_CR1_RESET_VALUE ((u8)0x00) -#define TIM4_IER_RESET_VALUE ((u8)0x00) -#define TIM4_SR1_RESET_VALUE ((u8)0x00) -#define TIM4_EGR_RESET_VALUE ((u8)0x00) -#define TIM4_CNTR_RESET_VALUE ((u8)0x00) -#define TIM4_PSCR_RESET_VALUE ((u8)0x00) -#define TIM4_ARR_RESET_VALUE ((u8)0xFF) - -/** - * @} - */ - -/** @addtogroup TIM4_Registers_Bits_Definition - * @{ - */ -/*CR1*/ -#define TIM4_CR1_ARPE ((u8)0x80) /*!< Auto-Reload Preload Enable mask. */ -#define TIM4_CR1_OPM ((u8)0x08) /*!< One Pulse Mode mask. */ -#define TIM4_CR1_URS ((u8)0x04) /*!< Update Request Source mask. */ -#define TIM4_CR1_UDIS ((u8)0x02) /*!< Update DIsable mask. */ -#define TIM4_CR1_CEN ((u8)0x01) /*!< Counter Enable mask. */ -/*IER*/ -#define TIM4_IER_UIE ((u8)0x01) /*!< Update Interrupt Enable mask. */ -/*SR1*/ -#define TIM4_SR1_UIF ((u8)0x01) /*!< Update Interrupt Flag mask. */ -/*EGR*/ -#define TIM4_EGR_UG ((u8)0x01) /*!< Update Generation mask. */ -/*CNTR*/ -#define TIM4_CNTR_CNT ((u8)0xFF) /*!< Counter Value (LSB) mask. */ -/*PSCR*/ -#define TIM4_PSCR_PSC ((u8)0x07) /*!< Prescaler Value mask. */ -/*ARR*/ -#define TIM4_ARR_ARR ((u8)0xFF) /*!< Autoreload Value mask. */ - -/** - * @} - */ - -/*----------------------------------------------------------------------------*/ -/** - * @brief 16-bit timer with synchro module (TIM5) - */ - -typedef struct TIM5_struct -{ - vu8 CR1; /*! - #define enableInterrupts() _rim_() /* enable interrupts */ - #define disableInterrupts() _sim_() /* disable interrupts */ - #define rim() _rim_() /* enable interrupts */ - #define sim() _sim_() /* disable interrupts */ - #define nop() _nop_() /* No Operation */ - #define trap() _trap_() /* Trap (soft IT) */ - #define wfi() _wfi_() /* Wait For Interrupt */ - #define halt() _halt_() /* Halt */ -#endif - -#ifdef _COSMIC_ - #define enableInterrupts() {_asm("rim\n");} /* enable interrupts */ - #define disableInterrupts() {_asm("sim\n");} /* disable interrupts */ - #define rim() {_asm("rim\n");} /* enable interrupts */ - #define sim() {_asm("sim\n");} /* disable interrupts */ - #define nop() {_asm("nop\n");} /* No Operation */ - #define trap() {_asm("trap\n");} /* Trap (soft IT) */ - #define wfi() {_asm("wfi\n");} /* Wait For Interrupt */ - #define halt() {_asm("halt\n");} /* Halt */ -#endif - -#ifdef _IAR_SYSTEMS_ - #include - #define enableInterrupts() __enable_interrupt() /* enable interrupts */ - #define disableInterrupts() __disable_interrupt() /* disable interrupts */ - #define rim() __enable_interrupt() /* enable interrupts */ - #define sim() __disable_interrupt() /* disable interrupts */ - #define nop() __no_operation() /* No Operation */ - #define trap() __trap_() /* Trap (soft IT) */ - #define wfi() __wait_for_interrupt() /* Wait For Interrupt */ - #define halt() __halt_() /* Halt */ -#endif - -/*============================== Handling bits ====================================*/ -/*----------------------------------------------------------------------------- -Method : I -Description : Handle the bit from the character variables. -Comments : The different parameters of commands are - - VAR : Name of the character variable where the bit is located. - - Place : Bit position in the variable (7 6 5 4 3 2 1 0) - - Value : Can be 0 (reset bit) or not 0 (set bit) - The "MskBit" command allows to select some bits in a source - variables and copy it in a destination var (return the value). - The "ValBit" command returns the value of a bit in a char - variable: the bit is reseted if it returns 0 else the bit is set. - This method generates not an optimised code yet. ------------------------------------------------------------------------------*/ -#define SetBit(VAR,Place) ( (VAR) |= (u8)((u8)1<<(u8)(Place)) ) -#define ClrBit(VAR,Place) ( (VAR) &= (u8)((u8)((u8)1<<(u8)(Place))^(u8)255) ) - -#define ChgBit(VAR,Place) ( (VAR) ^= (u8)((u8)1<<(u8)(Place)) ) -#define AffBit(VAR,Place,Value) ((Value) ? \ - ((VAR) |= ((u8)1<<(Place))) : \ - ((VAR) &= (((u8)1<<(Place))^(u8)255))) -#define MskBit(Dest,Msk,Src) ( (Dest) = ((Msk) & (Src)) | ((~(Msk)) & (Dest)) ) - -#define ValBit(VAR,Place) ((u8)(VAR) & (u8)((u8)1<<(u8)(Place))) - -#define BYTE_0(n) ((u8)((n) & (u8)0xFF)) /*!< Returns the low byte of the 32-bit value */ -#define BYTE_1(n) ((u8)(BYTE_0((n) >> (u8)8))) /*!< Returns the second byte of the 32-bit value */ -#define BYTE_2(n) ((u8)(BYTE_0((n) >> (u8)16))) /*!< Returns the third byte of the 32-bit value */ -#define BYTE_3(n) ((u8)(BYTE_0((n) >> (u8)24))) /*!< Returns the high byte of the 32-bit value */ - -/*============================== Assert Macros ====================================*/ -#define IS_STATE_VALUE_OK(SensitivityValue) \ - (((SensitivityValue) == ENABLE) || \ - ((SensitivityValue) == DISABLE)) - -/*----------------------------------------------------------------------------- -Method : II -Description : Handle directly the bit. -Comments : The idea is to handle directly with the bit name. For that, it is - necessary to have RAM area descriptions (example: HW register...) - and the following command line for each area. - This method generates the most optimized code. ------------------------------------------------------------------------------*/ - -#define AREA 0x00 /* The area of bits begins at address 0x10. */ - -#define BitClr(BIT) ( *((unsigned char *) (AREA+(BIT)/8)) &= (~(1<<(7-(BIT)%8))) ) -#define BitSet(BIT) ( *((unsigned char *) (AREA+(BIT)/8)) |= (1<<(7-(BIT)%8)) ) -#define BitVal(BIT) ( *((unsigned char *) (AREA+(BIT)/8)) & (1<<(7-(BIT)%8)) ) - -/* Exported functions ------------------------------------------------------- */ - -#endif /* __STM8S_H */ - -/** - * @} - */ - -/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm8/stm8s-periphs/stm8s_clk.c b/ports/stm8/stm8s-periphs/stm8s_clk.c deleted file mode 100644 index 2d1c6347..00000000 --- a/ports/stm8/stm8s-periphs/stm8s_clk.c +++ /dev/null @@ -1,94 +0,0 @@ -/** - ****************************************************************************** - * @file stm8s_clk.c - * @brief This file contains all the functions for the CLK peripheral. - * @author STMicroelectronics - MCD Application Team - * @version V1.1.1 - * @date 06/05/2009 - ****************************************************************************** - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- * @image html logo.bmp - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ - -#include "stm8s_clk.h" - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ - -/* Private Constants ---------------------------------------------------------*/ - -/** - * @addtogroup CLK_Private_Constants - * @{ - */ - -uc8 HSIDivFactor[4] = {1, 2, 4, 8}; /*!< Holds the different HSI Dividor factors */ -uc8 CLKPrescTable[8] = {1, 2, 4, 8, 10, 16, 20, 40}; /*!< Holds the different CLK prescaler values */ - -/** - * @} - */ - -/* Public functions ----------------------------------------------------------*/ -/** - * @addtogroup CLK_Public_Functions - * @{ - */ - - -/** - * @brief This function returns the frequencies of different on chip clocks. - * @par Parameters: - * None - * @retval the master clock frequency - */ -u32 CLK_GetClockFreq(void) -{ - - u32 clockfrequency = 0; - CLK_Source_TypeDef clocksource = CLK_SOURCE_HSI; - u8 tmp = 0, presc = 0; - - /* Get CLK source. */ - clocksource = (CLK_Source_TypeDef)CLK->CMSR; - - if (clocksource == CLK_SOURCE_HSI) - { - tmp = (u8)(CLK->CKDIVR & CLK_CKDIVR_HSIDIV); - tmp = (u8)(tmp >> 3); - presc = HSIDivFactor[tmp]; - clockfrequency = HSI_VALUE / presc; - } - else if ( clocksource == CLK_SOURCE_LSI) - { - clockfrequency = LSI_VALUE; - } - else - { - clockfrequency = HSE_VALUE; - } - - return((u32)clockfrequency); - -} - - -/** - * @} - */ - -/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm8/stm8s-periphs/stm8s_clk.h b/ports/stm8/stm8s-periphs/stm8s_clk.h deleted file mode 100644 index 4cbb896f..00000000 --- a/ports/stm8/stm8s-periphs/stm8s_clk.h +++ /dev/null @@ -1,404 +0,0 @@ -/** - ****************************************************************************** - * @file stm8s_clk.h - * @brief This file contains all functions prototype and macros for the CLK peripheral. - * @author STMicroelectronics - MCD Application Team - * @version V1.1.1 - * @date 06/05/2009 - ****************************************************************************** - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- * @image html logo.bmp - ****************************************************************************** - */ - - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM8S_CLK_H -#define __STM8S_CLK_H - -/* Includes ------------------------------------------------------------------*/ -/* Contains the description of all STM8 hardware registers */ -#include "stm8s.h" - -/* Exported types ------------------------------------------------------------*/ -/** @addtogroup CLK_Exported_Types - * @{ - */ - -/** - * @brief Switch Mode Auto, Manual. - */ -typedef enum { - CLK_SWITCHMODE_MANUAL = (u8)0x00, /*!< Enable the manual clock switching mode */ - CLK_SWITCHMODE_AUTO = (u8)0x01 /*!< Enable the automatic clock switching mode */ -} CLK_SwitchMode_TypeDef; - -/** - * @brief Current Clock State. - */ -typedef enum { - CLK_CURRENTCLOCKSTATE_DISABLE = (u8)0x00, /*!< Current clock disable */ - CLK_CURRENTCLOCKSTATE_ENABLE = (u8)0x01 /*!< Current clock enable */ -} CLK_CurrentClockState_TypeDef; - -/** - * @brief Clock security system configuration. - */ -typedef enum { - CLK_CSSCONFIG_ENABLEWITHIT = (u8)0x05, /*!< Enable CSS with detection interrupt */ - CLK_CSSCONFIG_ENABLE = (u8)0x01, /*!< Enable CSS without detection interrupt */ - CLK_CSSCONFIG_DISABLE = (u8)0x00 /*!< Leave CSS desactivated (to be used in CLK_Init() function) */ -} CLK_CSSConfig_TypeDef; - -/** - * @brief CLK Clock Source. - */ -typedef enum { - CLK_SOURCE_HSI = (u8)0xE1, /*!< Clock Source HSI. */ - CLK_SOURCE_LSI = (u8)0xD2, /*!< Clock Source LSI. */ - CLK_SOURCE_HSE = (u8)0xB4 /*!< Clock Source HSE. */ -} CLK_Source_TypeDef; - -/** - * @brief CLK HSI Calibration Value. - */ -typedef enum { - CLK_HSITRIMVALUE_0 = (u8)0x00, /*!< HSI Calibtation Value 0 */ - CLK_HSITRIMVALUE_1 = (u8)0x01, /*!< HSI Calibtation Value 1 */ - CLK_HSITRIMVALUE_2 = (u8)0x02, /*!< HSI Calibtation Value 2 */ - CLK_HSITRIMVALUE_3 = (u8)0x03, /*!< HSI Calibtation Value 3 */ - CLK_HSITRIMVALUE_4 = (u8)0x04, /*!< HSI Calibtation Value 4 */ - CLK_HSITRIMVALUE_5 = (u8)0x05, /*!< HSI Calibtation Value 5 */ - CLK_HSITRIMVALUE_6 = (u8)0x06, /*!< HSI Calibtation Value 6 */ - CLK_HSITRIMVALUE_7 = (u8)0x07 /*!< HSI Calibtation Value 7 */ -} CLK_HSITrimValue_TypeDef; - -/** - * @brief CLK Clock Output - */ -typedef enum { - CLK_OUTPUT_HSI = (u8)0x00, /*!< Clock Output HSI */ - CLK_OUTPUT_LSI = (u8)0x02, /*!< Clock Output LSI */ - CLK_OUTPUT_HSE = (u8)0x04, /*!< Clock Output HSE */ - CLK_OUTPUT_CPU = (u8)0x08, /*!< Clock Output CPU */ - CLK_OUTPUT_CPUDIV2 = (u8)0x0A, /*!< Clock Output CPU/2 */ - CLK_OUTPUT_CPUDIV4 = (u8)0x0C, /*!< Clock Output CPU/4 */ - CLK_OUTPUT_CPUDIV8 = (u8)0x0E, /*!< Clock Output CPU/8 */ - CLK_OUTPUT_CPUDIV16 = (u8)0x10, /*!< Clock Output CPU/16 */ - CLK_OUTPUT_CPUDIV32 = (u8)0x12, /*!< Clock Output CPU/32 */ - CLK_OUTPUT_CPUDIV64 = (u8)0x14, /*!< Clock Output CPU/64 */ - CLK_OUTPUT_HSIRC = (u8)0x16, /*!< Clock Output HSI RC */ - CLK_OUTPUT_MASTER = (u8)0x18, /*!< Clock Output Master */ - CLK_OUTPUT_OTHERS = (u8)0x1A /*!< Clock Output OTHER */ -} CLK_Output_TypeDef; - -/** - * @brief CLK Enable peripheral - */ -/* Elements values convention: 0xXY - X = choice between the peripheral registers - X = 0 : PCKENR1 - X = 1 : PCKENR2 - Y = Peripheral position in the register -*/ -typedef enum { - CLK_PERIPHERAL_I2C = (u8)0x00, /*!< Peripheral Clock Enable 1, I2C */ - CLK_PERIPHERAL_SPI = (u8)0x01, /*!< Peripheral Clock Enable 1, SPI */ -#if defined(STM8S208) || defined(STM8S207) - CLK_PERIPHERAL_UART1 = (u8)0x02, /*!< Peripheral Clock Enable 1, UART1 */ -#else - CLK_PERIPHERAL_UART1 = (u8)0x03, /*!< Peripheral Clock Enable 1, UART1 */ -#endif - CLK_PERIPHERAL_UART2 = (u8)0x03, /*!< Peripheral Clock Enable 1, UART2 */ - CLK_PERIPHERAL_UART3 = (u8)0x03, /*!< Peripheral Clock Enable 1, UART3 */ - CLK_PERIPHERAL_TIMER6 = (u8)0x04, /*!< Peripheral Clock Enable 1, Timer6 */ - CLK_PERIPHERAL_TIMER4 = (u8)0x04, /*!< Peripheral Clock Enable 1, Timer4 */ - CLK_PERIPHERAL_TIMER5 = (u8)0x05, /*!< Peripheral Clock Enable 1, Timer5 */ - CLK_PERIPHERAL_TIMER2 = (u8)0x05, /*!< Peripheral Clock Enable 1, Timer2 */ - CLK_PERIPHERAL_TIMER3 = (u8)0x06, /*!< Peripheral Clock Enable 1, Timer3 */ - CLK_PERIPHERAL_TIMER1 = (u8)0x07, /*!< Peripheral Clock Enable 1, Timer1 */ - CLK_PERIPHERAL_AWU = (u8)0x12, /*!< Peripheral Clock Enable 2, AWU */ - CLK_PERIPHERAL_ADC = (u8)0x13, /*!< Peripheral Clock Enable 2, ADC */ - CLK_PERIPHERAL_CAN = (u8)0x17 /*!< Peripheral Clock Enable 2, CAN */ -} CLK_Peripheral_TypeDef; - -/** - * @brief CLK Flags. - */ -/* Elements values convention: 0xXZZ - X = choice between the flags registers - X = 1 : ICKR - X = 2 : ECKR - X = 3 : SWCR - X = 4 : CSSR - X = 5 : CCOR - ZZ = flag mask in the register (same as map file) -*/ -typedef enum { - CLK_FLAG_LSIRDY = (u16)0x0110, /*!< Low speed internal oscillator ready Flag */ - CLK_FLAG_HSIRDY = (u16)0x0102, /*!< High speed internal oscillator ready Flag */ - CLK_FLAG_HSERDY = (u16)0x0202, /*!< High speed external oscillator ready Flag */ - CLK_FLAG_SWIF = (u16)0x0308, /*!< Clock switch interrupt Flag */ - CLK_FLAG_SWBSY = (u16)0x0301, /*!< Switch busy Flag */ - CLK_FLAG_CSSD = (u16)0x0408, /*!< Clock security system detection Flag */ - CLK_FLAG_AUX = (u16)0x0402, /*!< Auxiliary oscillator connected to master clock */ - CLK_FLAG_CCOBSY = (u16)0x0504, /*!< Configurable clock output busy */ - CLK_FLAG_CCORDY = (u16)0x0502 /*!< Configurable clock output ready */ - -}CLK_Flag_TypeDef; - -/** - * @brief CLK interrupt configuration and Flags cleared by software. - */ -typedef enum { - CLK_IT_CSSD = (u8)0x0C, /*!< Clock security system detection Flag */ - CLK_IT_SWIF = (u8)0x1C /*!< Clock switch interrupt Flag */ -}CLK_IT_TypeDef; - -/** - * @brief CLK Clock Divisor. - */ -/* Warning: - 0xxxxxx = HSI divider - 1xxxxxx = CPU divider - Other bits correspond to the divider's bits mapping -*/ -typedef enum { - CLK_PRESCALER_HSIDIV1 = (u8)0x00, /*!< High speed internal clock prescaler: 1 */ - CLK_PRESCALER_HSIDIV2 = (u8)0x08, /*!< High speed internal clock prescaler: 2 */ - CLK_PRESCALER_HSIDIV4 = (u8)0x10, /*!< High speed internal clock prescaler: 4 */ - CLK_PRESCALER_HSIDIV8 = (u8)0x18, /*!< High speed internal clock prescaler: 8 */ - CLK_PRESCALER_CPUDIV1 = (u8)0x80, /*!< CPU clock division factors 1 */ - CLK_PRESCALER_CPUDIV2 = (u8)0x81, /*!< CPU clock division factors 2 */ - CLK_PRESCALER_CPUDIV4 = (u8)0x82, /*!< CPU clock division factors 4 */ - CLK_PRESCALER_CPUDIV8 = (u8)0x83, /*!< CPU clock division factors 8 */ - CLK_PRESCALER_CPUDIV16 = (u8)0x84, /*!< CPU clock division factors 16 */ - CLK_PRESCALER_CPUDIV32 = (u8)0x85, /*!< CPU clock division factors 32 */ - CLK_PRESCALER_CPUDIV64 = (u8)0x86, /*!< CPU clock division factors 64 */ - CLK_PRESCALER_CPUDIV128 = (u8)0x87 /*!< CPU clock division factors 128 */ -} CLK_Prescaler_TypeDef; - -/** - * @brief SWIM Clock divider. - */ -typedef enum { - CLK_SWIMDIVIDER_2 = (u8)0x00, /*!< SWIM clock is divided by 2 */ - CLK_SWIMDIVIDER_OTHER = (u8)0x01 /*!< SWIM clock is not divided by 2 */ -}CLK_SWIMDivider_TypeDef; - -/** - * @brief External CAN clock dividern. - */ -typedef enum{ - CLK_CANDIVIDER_1 = (u8)0x00, /*!< External CAN clock = HSE/1 */ - CLK_CANDIVIDER_2 = (u8)0x01, /*!< External CAN clock = HSE/2 */ - CLK_CANDIVIDER_3 = (u8)0x02, /*!< External CAN clock = HSE/3 */ - CLK_CANDIVIDER_4 = (u8)0x03, /*!< External CAN clock = HSE/4 */ - CLK_CANDIVIDER_5 = (u8)0x04, /*!< External CAN clock = HSE/5 */ - CLK_CANDIVIDER_6 = (u8)0x05, /*!< External CAN clock = HSE/6 */ - CLK_CANDIVIDER_7 = (u8)0x06, /*!< External CAN clock = HSE/7 */ - CLK_CANDIVIDER_8 = (u8)0x07 /*!< External CAN clock = HSE/8 */ -}CLK_CANDivider_TypeDef; - -/** - * @} - */ - -/* Exported constants --------------------------------------------------------*/ - -/** @addtogroup CLK_Exported_Constants - * @{ - */ - -#define HSI_VALUE ((u32)16000000) /*!< Typical Value of the HSI in Hz */ -#define LSI_VALUE ((u32)128000) /*!< Typical Value of the LSI in Hz */ -#define CLK_TIMEOUT ((u16)0x491) /*!< Timeout for the clock switch operation. */ -/** - * @} - */ - -/* Private macros ------------------------------------------------------------*/ -/** @addtogroup CLK_Private_Macros - * @{ - */ - -/** - * @brief Macros used by the assert function in order to check the different functions parameters. - */ - -/** - * @brief Macros used by the assert function in order to check the clock switching modes. - */ -#define IS_CLK_SWITCHMODE_OK(MODE) (((MODE) == CLK_SWITCHMODE_MANUAL) || ((MODE) == CLK_SWITCHMODE_AUTO)) - -/** - * @brief Macros used by the assert function in order to check the current clock state. - */ -#define IS_CLK_CURRENTCLOCKSTATE_OK(STATE) (((STATE) == CLK_CURRENTCLOCKSTATE_DISABLE) || ((STATE) == CLK_CURRENTCLOCKSTATE_ENABLE)) - -/** - * @brief Macros used by the assert function in order to check the CSS configuration. - */ -#define IS_CLK_CSSCONFIG_OK(CSSVALUE) (((CSSVALUE) == CLK_CSSCONFIG_ENABLEWITHIT) ||\ - ((CSSVALUE) == CLK_CSSCONFIG_ENABLE) ||\ - ((CSSVALUE) == CLK_CSSCONFIG_DISABLE)) - -/** - * @brief Macros used by the assert function in order to check the different clock sources. - */ -#define IS_CLK_SOURCE_OK(SOURCE) (((SOURCE) == CLK_SOURCE_HSI) ||\ - ((SOURCE) == CLK_SOURCE_LSI) ||\ - ((SOURCE) == CLK_SOURCE_HSE)) - -/** - * @brief Macros used by the assert function in order to check the different HSI trimming values. - */ -#define IS_CLK_HSITRIMVALUE_OK(TRIMVALUE) (((TRIMVALUE) == CLK_HSITRIMVALUE_0) ||\ - ((TRIMVALUE) == CLK_HSITRIMVALUE_1) ||\ - ((TRIMVALUE) == CLK_HSITRIMVALUE_2) ||\ - ((TRIMVALUE) == CLK_HSITRIMVALUE_3) ||\ - ((TRIMVALUE) == CLK_HSITRIMVALUE_4) ||\ - ((TRIMVALUE) == CLK_HSITRIMVALUE_5) ||\ - ((TRIMVALUE) == CLK_HSITRIMVALUE_6) ||\ - ((TRIMVALUE) == CLK_HSITRIMVALUE_7)) - -/** - * @brief Macros used by the assert function in order to check the different clocks to output. - */ -#define IS_CLK_OUTPUT_OK(OUTPUT) (((OUTPUT) == CLK_OUTPUT_HSI) ||\ - ((OUTPUT) == CLK_OUTPUT_HSE) ||\ - ((OUTPUT) == CLK_OUTPUT_LSI) ||\ - ((OUTPUT) == CLK_OUTPUT_CPU) ||\ - ((OUTPUT) == CLK_OUTPUT_CPUDIV2) ||\ - ((OUTPUT) == CLK_OUTPUT_CPUDIV4) ||\ - ((OUTPUT) == CLK_OUTPUT_CPUDIV8) ||\ - ((OUTPUT) == CLK_OUTPUT_CPUDIV16) ||\ - ((OUTPUT) == CLK_OUTPUT_CPUDIV32) ||\ - ((OUTPUT) == CLK_OUTPUT_CPUDIV64) ||\ - ((OUTPUT) == CLK_OUTPUT_HSIRC) ||\ - ((OUTPUT) == CLK_OUTPUT_MASTER) ||\ - ((OUTPUT) == CLK_OUTPUT_OTHERS)) - -/** - * @brief Macros used by the assert function in order to check the different peripheral's clock. - */ -#define IS_CLK_PERIPHERAL_OK(PERIPHERAL) (((PERIPHERAL) == CLK_PERIPHERAL_I2C) ||\ - ((PERIPHERAL) == CLK_PERIPHERAL_SPI) ||\ - ((PERIPHERAL) == CLK_PERIPHERAL_UART3) ||\ - ((PERIPHERAL) == CLK_PERIPHERAL_UART2) ||\ - ((PERIPHERAL) == CLK_PERIPHERAL_UART1) ||\ - ((PERIPHERAL) == CLK_PERIPHERAL_TIMER4) ||\ - ((PERIPHERAL) == CLK_PERIPHERAL_TIMER2) ||\ - ((PERIPHERAL) == CLK_PERIPHERAL_TIMER5) ||\ - ((PERIPHERAL) == CLK_PERIPHERAL_TIMER6) ||\ - ((PERIPHERAL) == CLK_PERIPHERAL_TIMER3) ||\ - ((PERIPHERAL) == CLK_PERIPHERAL_TIMER1) ||\ - ((PERIPHERAL) == CLK_PERIPHERAL_CAN) ||\ - ((PERIPHERAL) == CLK_PERIPHERAL_ADC) ||\ - ((PERIPHERAL) == CLK_PERIPHERAL_AWU)) - -/** - * @brief Macros used by the assert function in order to check the different clock flags. - */ -#define IS_CLK_FLAG_OK(FLAG) (((FLAG) == CLK_FLAG_LSIRDY) ||\ - ((FLAG) == CLK_FLAG_HSIRDY) ||\ - ((FLAG) == CLK_FLAG_HSERDY) ||\ - ((FLAG) == CLK_FLAG_SWIF) ||\ - ((FLAG) == CLK_FLAG_SWBSY) ||\ - ((FLAG) == CLK_FLAG_CSSD) ||\ - ((FLAG) == CLK_FLAG_AUX) ||\ - ((FLAG) == CLK_FLAG_CCOBSY) ||\ - ((FLAG) == CLK_FLAG_CCORDY)) - -/** - * @brief Macros used by the assert function in order to check the different clock IT pending bits. - */ -#define IS_CLK_IT_OK(IT) (((IT) == CLK_IT_CSSD) || ((IT) == CLK_IT_SWIF)) - -/** - * @brief Macros used by the assert function in order to check the different HSI prescaler values. - */ -#define IS_CLK_HSIPRESCALER_OK(PRESCALER) (((PRESCALER) == CLK_PRESCALER_HSIDIV1) ||\ - ((PRESCALER) == CLK_PRESCALER_HSIDIV2) ||\ - ((PRESCALER) == CLK_PRESCALER_HSIDIV4) ||\ - ((PRESCALER) == CLK_PRESCALER_HSIDIV8)) - -/** - * @brief Macros used by the assert function in order to check the different clock prescaler values. - */ -#define IS_CLK_PRESCALER_OK(PRESCALER) (((PRESCALER) == CLK_PRESCALER_HSIDIV1) ||\ - ((PRESCALER) == CLK_PRESCALER_HSIDIV2) ||\ - ((PRESCALER) == CLK_PRESCALER_HSIDIV4) ||\ - ((PRESCALER) == CLK_PRESCALER_HSIDIV8) ||\ - ((PRESCALER) == CLK_PRESCALER_CPUDIV1) ||\ - ((PRESCALER) == CLK_PRESCALER_CPUDIV2) ||\ - ((PRESCALER) == CLK_PRESCALER_CPUDIV4) ||\ - ((PRESCALER) == CLK_PRESCALER_CPUDIV8) ||\ - ((PRESCALER) == CLK_PRESCALER_CPUDIV16) ||\ - ((PRESCALER) == CLK_PRESCALER_CPUDIV32) ||\ - ((PRESCALER) == CLK_PRESCALER_CPUDIV64) ||\ - ((PRESCALER) == CLK_PRESCALER_CPUDIV128)) - -/** - * @brief Macros used by the assert function in order to check the different SWIM dividers values. - */ -#define IS_CLK_SWIMDIVIDER_OK(SWIMDIVIDER) (((SWIMDIVIDER) == CLK_SWIMDIVIDER_2) || ((SWIMDIVIDER) == CLK_SWIMDIVIDER_OTHER)) - -/** - * @brief Macros used by the assert function in order to check the different CAN dividers values. - */ -#define IS_CLK_CANDIVIDER_OK(CANDIVIDER) (((CANDIVIDER) == CLK_CANDIVIDER_1) ||\ - ((CANDIVIDER) == CLK_CANDIVIDER_2) ||\ - ((CANDIVIDER) == CLK_CANDIVIDER_3) ||\ - ((CANDIVIDER) == CLK_CANDIVIDER_4) ||\ - ((CANDIVIDER) == CLK_CANDIVIDER_5) ||\ - ((CANDIVIDER) == CLK_CANDIVIDER_6) ||\ - ((CANDIVIDER) == CLK_CANDIVIDER_7) ||\ - ((CANDIVIDER) == CLK_CANDIVIDER_8)) - -/** - * @} - */ - -/** @addtogroup CLK_Exported_functions - * @{ - */ -void CLK_DeInit(void); -void CLK_HSECmd(FunctionalState NewState); -void CLK_HSICmd(FunctionalState NewState); -void CLK_LSICmd(FunctionalState NewState); -void CLK_CCOCmd(FunctionalState NewState); -void CLK_ClockSwitchCmd(FunctionalState NewState); -void CLK_FastHaltWakeUpCmd(FunctionalState NewState); -void CLK_SlowActiveHaltWakeUpCmd(FunctionalState NewState); -void CLK_PeripheralClockConfig(CLK_Peripheral_TypeDef CLK_Peripheral, FunctionalState NewState); -ErrorStatus CLK_ClockSwitchConfig(CLK_SwitchMode_TypeDef CLK_SwitchMode, CLK_Source_TypeDef CLK_NewClock, FunctionalState ITState, CLK_CurrentClockState_TypeDef CLK_CurrentClockState); -void CLK_HSIPrescalerConfig(CLK_Prescaler_TypeDef HSIPrescaler); -void CLK_CCOConfig(CLK_Output_TypeDef CLK_CCO); -void CLK_ITConfig(CLK_IT_TypeDef CLK_IT, FunctionalState NewState); -void CLK_SYSCLKConfig(CLK_Prescaler_TypeDef CLK_Prescaler); -void CLK_SWIMConfig(CLK_SWIMDivider_TypeDef CLK_SWIMDivider); -void CLK_CANConfig(CLK_CANDivider_TypeDef CLK_CANDivider); -void CLK_ClockSecuritySystemEnable(void); -void CLK_SYSCLKEmergencyClear(void); -void CLK_AdjustHSICalibrationValue(CLK_HSITrimValue_TypeDef CLK_HSICalibrationValue); -u32 CLK_GetClockFreq(void); -CLK_Source_TypeDef CLK_GetSYSCLKSource(void); -FlagStatus CLK_GetFlagStatus(CLK_Flag_TypeDef CLK_FLAG); -ITStatus CLK_GetITStatus(CLK_IT_TypeDef CLK_IT); -void CLK_ClearITPendingBit(CLK_IT_TypeDef CLK_IT); - -/** - * @} - */ -#endif /* __STM8S_CLK_H */ - -/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm8/stm8s-periphs/stm8s_gpio.c b/ports/stm8/stm8s-periphs/stm8s_gpio.c deleted file mode 100644 index 9438a8d2..00000000 --- a/ports/stm8/stm8s-periphs/stm8s_gpio.c +++ /dev/null @@ -1,140 +0,0 @@ -/** - ****************************************************************************** - * @file stm8s_gpio.c - * @brief This file contains all the functions for the GPIO peripheral. - * @author STMicroelectronics - MCD Application Team - * @version V1.1.1 - * @date 06/05/2009 - ****************************************************************************** - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- * @image html logo.bmp - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm8s_gpio.h" - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ -/* Private functions ---------------------------------------------------------*/ - -/* Public functions ----------------------------------------------------------*/ - -/** - * @addtogroup GPIO_Public_Functions - * @{ - */ - -/** - * @brief Deinitializes the GPIOx peripheral registers to their default reset - * values. - * @param[in] GPIOx : Select the GPIO peripheral number (x = A to I). - * @retval None - */ -void GPIO_DeInit(GPIO_TypeDef* GPIOx) -{ - GPIOx->ODR = GPIO_ODR_RESET_VALUE; /* Reset Output Data Register */ - GPIOx->DDR = GPIO_DDR_RESET_VALUE; /* Reset Data Direction Register */ - GPIOx->CR1 = GPIO_CR1_RESET_VALUE; /* Reset Control Register 1 */ - GPIOx->CR2 = GPIO_CR2_RESET_VALUE; /* Reset Control Register 2 */ -} - -/** - * @brief Initializes the GPIOx according to the specified parameters. - * @param[in] GPIOx : Select the GPIO peripheral number (x = A to I). - * @param[in] GPIO_Pin : This parameter contains the pin number, it can be one or many members - * of the @ref GPIO_Pin_TypeDef enumeration. - * @param[in] GPIO_Mode : This parameter can be any of the @Ref GPIO_Mode_TypeDef enumeration. - * @retval None - */ - -void GPIO_Init(GPIO_TypeDef* GPIOx, - GPIO_Pin_TypeDef GPIO_Pin, - GPIO_Mode_TypeDef GPIO_Mode) -{ - /*----------------------*/ - /* Check the parameters */ - /*----------------------*/ - - assert_param(IS_GPIO_MODE_OK(GPIO_Mode)); - assert_param(IS_GPIO_PIN_OK(GPIO_Pin)); - - /*-----------------------------*/ - /* Input/Output mode selection */ - /*-----------------------------*/ - - if ((((u8)(GPIO_Mode)) & (u8)0x80) != (u8)0x00) /* Output mode */ - { - if ((((u8)(GPIO_Mode)) & (u8)0x10) != (u8)0x00) /* High level */ - { - GPIOx->ODR |= (u8)GPIO_Pin; - } else /* Low level */ - { - GPIOx->ODR &= (u8)(~(GPIO_Pin)); - } - /* Set Output mode */ - GPIOx->DDR |= (u8)GPIO_Pin; - } else /* Input mode */ - { - /* Set Input mode */ - GPIOx->DDR &= (u8)(~(GPIO_Pin)); - } - - /*------------------------------------------------------------------------*/ - /* Pull-Up/Float (Input) or Push-Pull/Open-Drain (Output) modes selection */ - /*------------------------------------------------------------------------*/ - - if ((((u8)(GPIO_Mode)) & (u8)0x40) != (u8)0x00) /* Pull-Up or Push-Pull */ - { - GPIOx->CR1 |= (u8)GPIO_Pin; - } else /* Float or Open-Drain */ - { - GPIOx->CR1 &= (u8)(~(GPIO_Pin)); - } - - /*-----------------------------------------------------*/ - /* Interrupt (Input) or Slope (Output) modes selection */ - /*-----------------------------------------------------*/ - - if ((((u8)(GPIO_Mode)) & (u8)0x20) != (u8)0x00) /* Interrupt or Slow slope */ - { - GPIOx->CR2 |= (u8)GPIO_Pin; - } else /* No external interrupt or No slope control */ - { - GPIOx->CR2 &= (u8)(~(GPIO_Pin)); - } - -} - - -/** - * @brief Writes reverse level to the specified GPIO pins. - * @param[in] GPIOx : Select the GPIO peripheral number (x = A to I). - * @param[in] PortPins : Specifies the pins to be reversed to the port output. - * data register. - * @retval None - * @par Required preconditions: - * The port must be configured in output mode. - */ -void GPIO_WriteReverse(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins) -{ - GPIOx->ODR ^= (u8)PortPins; -} - - -/** - * @} - */ - -/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm8/stm8s-periphs/stm8s_gpio.h b/ports/stm8/stm8s-periphs/stm8s_gpio.h deleted file mode 100644 index 72890aeb..00000000 --- a/ports/stm8/stm8s-periphs/stm8s_gpio.h +++ /dev/null @@ -1,149 +0,0 @@ -/** - ****************************************************************************** - * @file stm8s_gpio.h - * @brief This file contains all functions prototype and macros for the GPIO peripheral. - * @author STMicroelectronics - MCD Application Team - * @version V1.1.1 - * @date 06/05/2009 - ****************************************************************************** - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- * @image html logo.bmp - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM8S_GPIO_H -#define __STM8S_GPIO_H - -/* Includes ------------------------------------------------------------------*/ -#include "stm8s.h" - -/* Exported variables ------------------------------------------------------- */ -/* Exported types ------------------------------------------------------------*/ - -/** @addtogroup GPIO_Exported_Types - * @{ - */ - -/** - * @brief GPIO modes - * - * Bits definitions: - * - Bit 7: 0 = INPUT mode - * 1 = OUTPUT mode - * 1 = PULL-UP (input) or PUSH-PULL (output) - * - Bit 5: 0 = No external interrupt (input) or No slope control (output) - * 1 = External interrupt (input) or Slow control enabled (output) - * - Bit 4: 0 = Low level (output) - * 1 = High level (output push-pull) or HI-Z (output open-drain) - */ -typedef enum -{ - GPIO_MODE_IN_FL_NO_IT = (u8)0x00, // 0b00000000, /*!< Input floating, no external interrupt */ - GPIO_MODE_IN_PU_NO_IT = (u8)0x40, // 0b01000000, /*!< Input pull-up, no external interrupt */ - GPIO_MODE_IN_FL_IT = (u8)0x20, // 0b00100000, /*!< Input floating, external interrupt */ - GPIO_MODE_IN_PU_IT = (u8)0x60, // 0b01100000, /*!< Input pull-up, external interrupt */ - GPIO_MODE_OUT_OD_LOW_FAST = (u8)0xA0, // 0b10100000, /*!< Output open-drain, low level, 10MHz */ - GPIO_MODE_OUT_PP_LOW_FAST = (u8)0xE0, // 0b11100000, /*!< Output push-pull, low level, 10MHz */ - GPIO_MODE_OUT_OD_LOW_SLOW = (u8)0x80, // 0b10000000, /*!< Output open-drain, low level, 2MHz */ - GPIO_MODE_OUT_PP_LOW_SLOW = (u8)0xC0, // 0b11000000, /*!< Output push-pull, low level, 2MHz */ - GPIO_MODE_OUT_OD_HIZ_FAST = (u8)0xB0, // 0b10110000, /*!< Output open-drain, high-impedance level,10MHz */ - GPIO_MODE_OUT_PP_HIGH_FAST = (u8)0xF0, // 0b11110000, /*!< Output push-pull, high level, 10MHz */ - GPIO_MODE_OUT_OD_HIZ_SLOW = (u8)0x90, // 0b10010000, /*!< Output open-drain, high-impedance level, 2MHz */ - GPIO_MODE_OUT_PP_HIGH_SLOW = (u8)0xD0 // 0b11010000 /*!< Output push-pull, high level, 2MHz */ -}GPIO_Mode_TypeDef; - -/** - * @brief Definition of the GPIO pins. Used by the @ref GPIO_Init function in - * order to select the pins to be initialized. - */ - -typedef enum -{ - GPIO_PIN_0 = ((u8)0x01), /*!< Pin 0 selected */ - GPIO_PIN_1 = ((u8)0x02), /*!< Pin 1 selected */ - GPIO_PIN_2 = ((u8)0x04), /*!< Pin 2 selected */ - GPIO_PIN_3 = ((u8)0x08), /*!< Pin 3 selected */ - GPIO_PIN_4 = ((u8)0x10), /*!< Pin 4 selected */ - GPIO_PIN_5 = ((u8)0x20), /*!< Pin 5 selected */ - GPIO_PIN_6 = ((u8)0x40), /*!< Pin 6 selected */ - GPIO_PIN_7 = ((u8)0x80), /*!< Pin 7 selected */ - GPIO_PIN_LNIB = ((u8)0x0F), /*!< Low nibble pins selected */ - GPIO_PIN_HNIB = ((u8)0xF0), /*!< High nibble pins selected */ - GPIO_PIN_ALL = ((u8)0xFF) /*!< All pins selected */ -}GPIO_Pin_TypeDef; - -/** - * @} - */ - -/* Exported constants --------------------------------------------------------*/ -/* Exported macros -----------------------------------------------------------*/ -/* Private macros ------------------------------------------------------------*/ - -/** @addtogroup GPIO_Private_Macros - * @{ - */ - -/** - * @brief Macro used by the assert function to check the different functions parameters. - */ - -/** - * @brief Macro used by the assert function in order to check the different - * values of GPIOMode_TypeDef. - */ -#define IS_GPIO_MODE_OK(MODE) \ - (((MODE) == GPIO_MODE_IN_FL_NO_IT) || \ - ((MODE) == GPIO_MODE_IN_PU_NO_IT) || \ - ((MODE) == GPIO_MODE_IN_FL_IT) || \ - ((MODE) == GPIO_MODE_IN_PU_IT) || \ - ((MODE) == GPIO_MODE_OUT_OD_LOW_FAST) || \ - ((MODE) == GPIO_MODE_OUT_PP_LOW_FAST) || \ - ((MODE) == GPIO_MODE_OUT_OD_LOW_SLOW) || \ - ((MODE) == GPIO_MODE_OUT_PP_LOW_SLOW) || \ - ((MODE) == GPIO_MODE_OUT_OD_HIZ_FAST) || \ - ((MODE) == GPIO_MODE_OUT_PP_HIGH_FAST) || \ - ((MODE) == GPIO_MODE_OUT_OD_HIZ_SLOW) || \ - ((MODE) == GPIO_MODE_OUT_PP_HIGH_SLOW)) - -/** - * @brief Macro used by the assert function in order to check the different - * values of GPIO_Pins. - */ -#define IS_GPIO_PIN_OK(PIN) ((PIN) != (u8)0x00) - -/** - * @} - */ - -/* Exported functions ------------------------------------------------------- */ -/** @addtogroup GPIO_Exported_Functions - * @{ - */ - -void GPIO_DeInit(GPIO_TypeDef* GPIOx); -void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, GPIO_Mode_TypeDef GPIO_Mode); -void GPIO_Write(GPIO_TypeDef* GPIOx, u8 PortVal); -void GPIO_WriteHigh(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins); -void GPIO_WriteLow(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins); -void GPIO_WriteReverse(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef PortPins); -u8 GPIO_ReadInputData(GPIO_TypeDef* GPIOx); -u8 GPIO_ReadOutputData(GPIO_TypeDef* GPIOx); -BitStatus GPIO_ReadInputPin(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin); -void GPIO_ExternalPullUpConfig(GPIO_TypeDef* GPIOx, GPIO_Pin_TypeDef GPIO_Pin, FunctionalState NewState); -/** - * @} - */ - -#endif /* __STM8L_GPIO_H */ - -/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm8/stm8s-periphs/stm8s_itc.c b/ports/stm8/stm8s-periphs/stm8s_itc.c deleted file mode 100644 index ca8cc1b0..00000000 --- a/ports/stm8/stm8s-periphs/stm8s_itc.c +++ /dev/null @@ -1,323 +0,0 @@ -/** - ****************************************************************************** - * @file stm8s_itc.c - * @brief This file contains all the functions for the ITC peripheral. - * @author STMicroelectronics - MCD Application Team - * @version V1.1.1 - * @date 06/05/2009 - ****************************************************************************** - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- * @image html logo.bmp - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm8s_itc.h" - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ -/* Private functions ---------------------------------------------------------*/ - -/** @addtogroup ITC_Private_Functions - * @{ - */ - -/** -* @brief Utility function used to read CC register. -* @par Parameters: -* None -* @retval u8 Content of CC register (in A register). - */ -u8 ITC_GetCPUCC(void) -{ -#ifdef _COSMIC_ - _asm("push cc"); - _asm("pop a"); - return; /* Ignore compiler warning, the returned value is in A register */ -#endif - -#ifdef _RAISONANCE_ - return _getCC_(); -#endif - -#ifdef _IAR_SYSTEMS_ - __asm("push cc"); - __asm("pop a"); -#endif -} - - -/** - * @} - */ - -/* Public functions ----------------------------------------------------------*/ - -/** @addtogroup ITC_Public_Functions - * @{ - */ - -/** -* @brief Deinitializes the ITC registers to their default reset value. -* @par Parameters: -* None -* @retval -* None - */ -void ITC_DeInit(void) -{ - ITC->ISPR1 = ITC_SPRX_RESET_VALUE; - ITC->ISPR2 = ITC_SPRX_RESET_VALUE; - ITC->ISPR3 = ITC_SPRX_RESET_VALUE; - ITC->ISPR4 = ITC_SPRX_RESET_VALUE; - ITC->ISPR5 = ITC_SPRX_RESET_VALUE; - ITC->ISPR6 = ITC_SPRX_RESET_VALUE; - ITC->ISPR7 = ITC_SPRX_RESET_VALUE; - ITC->ISPR8 = ITC_SPRX_RESET_VALUE; -} - -/** -* @brief Get the software interrupt priority bits (I1, I0) value from CPU CC register. -* @par Parameters: -* None -* @retval u8 The software interrupt priority bits value. - */ -u8 ITC_GetSoftIntStatus(void) -{ - return (u8)(ITC_GetCPUCC() & CPU_CC_I1I0); -} - -/** -* @brief Get the software priority of the specified interrupt source. -* @param[in] IrqNum The IRQ number to access. -* @retval ITC_PriorityLevel_TypeDef The software priority of the interrupt source. - */ -ITC_PriorityLevel_TypeDef ITC_GetSoftwarePriority(ITC_Irq_TypeDef IrqNum) -{ - - u8 Value = 0; - u8 Mask; - - /* Check function parameters */ - assert_param(IS_ITC_IRQ_OK((u8)IrqNum)); - - /* Define the mask corresponding to the bits position in the SPR register */ - Mask = (u8)(0x03U << (((u8)IrqNum % 4U) * 2U)); - - switch (IrqNum) - { - case ITC_IRQ_TLI: /* TLI software priority can be read but has no meaning */ - case ITC_IRQ_AWU: - case ITC_IRQ_CLK: - case ITC_IRQ_PORTA: - Value = (u8)(ITC->ISPR1 & Mask); /* Read software priority */ - break; - case ITC_IRQ_PORTB: - case ITC_IRQ_PORTC: - case ITC_IRQ_PORTD: - case ITC_IRQ_PORTE: - Value = (u8)(ITC->ISPR2 & Mask); /* Read software priority */ - break; -#ifdef STM8S208 - case ITC_IRQ_CAN_RX: - case ITC_IRQ_CAN_TX: -#endif /*STM8S208*/ - -#ifdef STM8S903 - case ITC_IRQ_PORTF: -#endif /*STM8S903*/ - - case ITC_IRQ_SPI: - case ITC_IRQ_TIM1_OVF: - Value = (u8)(ITC->ISPR3 & Mask); /* Read software priority */ - break; - case ITC_IRQ_TIM1_CAPCOM: -#ifdef STM8S903 - case ITC_IRQ_TIM5_OVFTRI: - case ITC_IRQ_TIM5_CAPCOM: -#else - case ITC_IRQ_TIM2_OVF: - case ITC_IRQ_TIM2_CAPCOM: -#endif /*STM8S903*/ - - case ITC_IRQ_TIM3_OVF: - Value = (u8)(ITC->ISPR4 & Mask); /* Read software priority */ - break; - case ITC_IRQ_TIM3_CAPCOM: - case ITC_IRQ_UART1_TX: - case ITC_IRQ_UART1_RX: - case ITC_IRQ_I2C: - Value = (u8)(ITC->ISPR5 & Mask); /* Read software priority */ - break; -#ifdef STM8S105 - case ITC_IRQ_UART2_TX: - case ITC_IRQ_UART2_RX: -#endif /*STM8S105*/ - -#if defined(STM8S208) ||defined(STM8S207) - case ITC_IRQ_UART3_TX: - case ITC_IRQ_UART3_RX: - case ITC_IRQ_ADC2: -#endif /*STM8S208 or STM8S207*/ - -#if defined(STM8S105) ||defined(STM8S103) ||defined(STM8S905) - case ITC_IRQ_ADC1: -#endif /*STM8S105, STM8S103 or STM8S905 */ - -#ifdef STM8S903 - case ITC_IRQ_TIM6_OVFTRI: -#else - case ITC_IRQ_TIM4_OVF: -#endif /*STM8S903*/ - Value = (u8)(ITC->ISPR6 & Mask); /* Read software priority */ - break; - case ITC_IRQ_EEPROM_EEC: - Value = (u8)(ITC->ISPR7 & Mask); /* Read software priority */ - break; - default: - break; - } - - Value >>= (u8)(((u8)IrqNum % 4u) * 2u); - - return((ITC_PriorityLevel_TypeDef)Value); - -} - -/** -* @brief Set the software priority of the specified interrupt source. -* @param[in] IrqNum The interrupt source to access. -* @param[in] PriorityValue The software priority value to set. -* @retval ITC_PriorityLevel_TypeDef The software priority of the interrupt source. -* @par Required preconditions: -* - The modification of the software priority is only possible when the interrupts are disabled. -* - The normal behavior is to disable the interrupts before calling this function, and re-enable it after. -* - The priority level 0 cannot be set (see product specification for more details). -*/ -void ITC_SetSoftwarePriority(ITC_Irq_TypeDef IrqNum, ITC_PriorityLevel_TypeDef PriorityValue) -{ - - u8 Mask; - u8 NewPriority; - - /* Check function parameters */ - assert_param(IS_ITC_IRQ_OK((u8)IrqNum)); - assert_param(IS_ITC_PRIORITY_OK(PriorityValue)); - - /* Check if interrupts are disabled */ - assert_param(IS_ITC_INTERRUPTS_DISABLED); - - /* Define the mask corresponding to the bits position in the SPR register */ - /* The mask is reversed in order to clear the 2 bits after more easily */ - Mask = (u8)(~(u8)(0x03U << (((u8)IrqNum % 4U) * 2U))); - - /* Define the new priority to write */ - NewPriority = (u8)((u8)(PriorityValue) << (((u8)IrqNum % 4U) * 2U)); - - switch (IrqNum) - { - - case ITC_IRQ_TLI: /* TLI software priority can be written but has no meaning */ - case ITC_IRQ_AWU: - case ITC_IRQ_CLK: - case ITC_IRQ_PORTA: - ITC->ISPR1 &= Mask; - ITC->ISPR1 |= NewPriority; - break; - - case ITC_IRQ_PORTB: - case ITC_IRQ_PORTC: - case ITC_IRQ_PORTD: - case ITC_IRQ_PORTE: - ITC->ISPR2 &= Mask; - ITC->ISPR2 |= NewPriority; - break; - -#ifdef STM8S208 - case ITC_IRQ_CAN_RX: - case ITC_IRQ_CAN_TX: -#endif /*STM8S208*/ - -#ifdef STM8S903 - case ITC_IRQ_PORTF: -#endif /*STM8S903*/ - case ITC_IRQ_SPI: - case ITC_IRQ_TIM1_OVF: - ITC->ISPR3 &= Mask; - ITC->ISPR3 |= NewPriority; - break; - - case ITC_IRQ_TIM1_CAPCOM: -#ifdef STM8S903 - case ITC_IRQ_TIM5_OVFTRI: - case ITC_IRQ_TIM5_CAPCOM: -#else - case ITC_IRQ_TIM2_OVF: - case ITC_IRQ_TIM2_CAPCOM: -#endif /*STM8S903*/ - - case ITC_IRQ_TIM3_OVF: - ITC->ISPR4 &= Mask; - ITC->ISPR4 |= NewPriority; - break; - - case ITC_IRQ_TIM3_CAPCOM: - case ITC_IRQ_UART1_TX: - case ITC_IRQ_UART1_RX: - case ITC_IRQ_I2C: - ITC->ISPR5 &= Mask; - ITC->ISPR5 |= NewPriority; - break; - -#ifdef STM8S105 - case ITC_IRQ_UART2_TX: - case ITC_IRQ_UART2_RX: -#endif /*STM8S105*/ - -#if defined(STM8S208) ||defined(STM8S207) - case ITC_IRQ_UART3_TX: - case ITC_IRQ_UART3_RX: - case ITC_IRQ_ADC2: -#endif /*STM8S208 or STM8S207*/ - -#if defined(STM8S105) ||defined(STM8S103) ||defined(STM8S905) - case ITC_IRQ_ADC1: -#endif /*STM8S105, STM8S103 or STM8S905 */ - -#ifdef STM8S903 - case ITC_IRQ_TIM6_OVFTRI: -#else - case ITC_IRQ_TIM4_OVF: -#endif /*STM8S903*/ - ITC->ISPR6 &= Mask; - ITC->ISPR6 |= NewPriority; - break; - - case ITC_IRQ_EEPROM_EEC: - ITC->ISPR7 &= Mask; - ITC->ISPR7 |= NewPriority; - break; - - default: - break; - - } - -} - -/** - * @} - */ - -/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm8/stm8s-periphs/stm8s_itc.h b/ports/stm8/stm8s-periphs/stm8s_itc.h deleted file mode 100644 index 31a76594..00000000 --- a/ports/stm8/stm8s-periphs/stm8s_itc.h +++ /dev/null @@ -1,168 +0,0 @@ -/** - ****************************************************************************** - * @file stm8s_itc.h - * @brief This file contains all functions prototype and macros for the ITC peripheral. - * @author STMicroelectronics - MCD Application Team - * @version V1.1.1 - * @date 06/05/2009 - ****************************************************************************** - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- * @image html logo.bmp - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM8S_ITC_H__ -#define __STM8S_ITC_H__ - -/* Includes ------------------------------------------------------------------*/ -#include "stm8s.h" - -/* Exported types ------------------------------------------------------------*/ - -/** @addtogroup ITC_Exported_Types - * @{ - */ - -/** - * @brief ITC Interrupt Lines selection - */ -typedef enum { - ITC_IRQ_TLI = (u8)0, - ITC_IRQ_AWU = (u8)1, - ITC_IRQ_CLK = (u8)2, - ITC_IRQ_PORTA = (u8)3, - ITC_IRQ_PORTB = (u8)4, - ITC_IRQ_PORTC = (u8)5, - ITC_IRQ_PORTD = (u8)6, - ITC_IRQ_PORTE = (u8)7, - -#ifdef STM8S208 - ITC_IRQ_CAN_RX = (u8)8, - ITC_IRQ_CAN_TX = (u8)9, -#endif /*STM8S208*/ - -#ifdef STM8S903 - ITC_IRQ_PORTF = (u8)8, -#endif /*STM8S903*/ - - ITC_IRQ_SPI = (u8)10, - ITC_IRQ_TIM1_OVF = (u8)11, - ITC_IRQ_TIM1_CAPCOM = (u8)12, - -#ifdef STM8S903 - ITC_IRQ_TIM5_OVFTRI = (u8)13, - ITC_IRQ_TIM5_CAPCOM = (u8)14, -#else - ITC_IRQ_TIM2_OVF = (u8)13, - ITC_IRQ_TIM2_CAPCOM = (u8)14, -#endif /*STM8S903*/ - - ITC_IRQ_TIM3_OVF = (u8)15, - ITC_IRQ_TIM3_CAPCOM = (u8)16, - ITC_IRQ_UART1_TX = (u8)17, - ITC_IRQ_UART1_RX = (u8)18, - ITC_IRQ_I2C = (u8)19, - -#ifdef STM8S105 - ITC_IRQ_UART2_TX = (u8)20, - ITC_IRQ_UART2_RX = (u8)21, -#endif /*STM8S105*/ - -#if defined(STM8S208) ||defined(STM8S207) - ITC_IRQ_UART3_TX = (u8)20, - ITC_IRQ_UART3_RX = (u8)21, - ITC_IRQ_ADC2 = (u8)22, -#endif /*STM8S208 or STM8S207*/ - -#if defined(STM8S105) ||defined(STM8S103) ||defined(STM8S905) - ITC_IRQ_ADC1 = (u8)22, -#endif /*STM8S105, STM8S103 or STM8S905 */ - -#ifdef STM8S903 - ITC_IRQ_TIM6_OVFTRI = (u8)23, -#else - ITC_IRQ_TIM4_OVF = (u8)23, -#endif /*STM8S903*/ - - ITC_IRQ_EEPROM_EEC = (u8)24 -} ITC_Irq_TypeDef; - -/** - * @brief ITC Priority Levels selection - */ -typedef enum { - ITC_PRIORITYLEVEL_0 = (u8)0x02, /*!< Software priority level 0 (cannot be written) */ - ITC_PRIORITYLEVEL_1 = (u8)0x01, /*!< Software priority level 1 */ - ITC_PRIORITYLEVEL_2 = (u8)0x00, /*!< Software priority level 2 */ - ITC_PRIORITYLEVEL_3 = (u8)0x03 /*!< Software priority level 3 */ -} ITC_PriorityLevel_TypeDef; - -/** - * @} - */ - -/* Exported constants --------------------------------------------------------*/ - -/** @addtogroup ITC_Exported_Constants - * @{ - */ - -#define CPU_SOFT_INT_DISABLED ((u8)0x28) /*!< Mask for I1 and I0 bits in CPU_CC register */ - -/** - * @} - */ - -/* Private macros ------------------------------------------------------------*/ - -/** - * @brief Macros used by the assert function in order to check the different functions parameters. - * @addtogroup ITC_Private_Macros - * @{ - */ - -/* Used by assert function */ -#define IS_ITC_IRQ_OK(IRQ) ((IRQ) <= (u8)24) - -/* Used by assert function */ -#define IS_ITC_PRIORITY_OK(PriorityValue) \ - (((PriorityValue) == ITC_PRIORITYLEVEL_0) || \ - ((PriorityValue) == ITC_PRIORITYLEVEL_1) || \ - ((PriorityValue) == ITC_PRIORITYLEVEL_2) || \ - ((PriorityValue) == ITC_PRIORITYLEVEL_3)) - -/* Used by assert function */ -#define IS_ITC_INTERRUPTS_DISABLED (ITC_GetSoftIntStatus() == CPU_SOFT_INT_DISABLED) - -/** - * @} - */ - -/* Exported functions ------------------------------------------------------- */ - -/** @addtogroup ITC_Exported_Functions - * @{ - */ - -u8 ITC_GetCPUCC(void); -void ITC_DeInit(void); -u8 ITC_GetSoftIntStatus(void); -void ITC_SetSoftwarePriority(ITC_Irq_TypeDef IrqNum, ITC_PriorityLevel_TypeDef PriorityValue); -ITC_PriorityLevel_TypeDef ITC_GetSoftwarePriority(ITC_Irq_TypeDef IrqNum); - -/** - * @} - */ - -#endif /* __STM8S_ITC_H__ */ - -/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm8/stm8s-periphs/stm8s_tim1.c b/ports/stm8/stm8s-periphs/stm8s_tim1.c deleted file mode 100644 index ec36a5c4..00000000 --- a/ports/stm8/stm8s-periphs/stm8s_tim1.c +++ /dev/null @@ -1,184 +0,0 @@ -/** - ****************************************************************************** - * @file stm8s_tim1.c - * @brief This file contains all the functions for the TIM1 peripheral. - * @author STMicroelectronics - MCD Application Team - * @version V1.1.1 - * @date 06/05/2009 - ****************************************************************************** - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- * @image html logo.bmp - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm8s_tim1.h" - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ - -/** - * @addtogroup TIM1_Public_Functions - * @{ - */ - -/** - * @brief Deinitializes the TIM1 peripheral registers to their default reset values. - * @par Parameters: - * None - * @retval None - */ -void TIM1_DeInit(void) -{ - TIM1->CR1 = TIM1_CR1_RESET_VALUE; - TIM1->CR2 = TIM1_CR2_RESET_VALUE; - TIM1->SMCR = TIM1_SMCR_RESET_VALUE; - TIM1->ETR = TIM1_ETR_RESET_VALUE; - TIM1->IER = TIM1_IER_RESET_VALUE; - TIM1->SR2 = TIM1_SR2_RESET_VALUE; - /* Disable channels */ - TIM1->CCER1 = TIM1_CCER1_RESET_VALUE; - TIM1->CCER2 = TIM1_CCER2_RESET_VALUE; - /* Configure channels as inputs: it is necessary if lock level is equal to 2 or 3 */ - TIM1->CCMR1 = 0x01; - TIM1->CCMR2 = 0x01; - TIM1->CCMR3 = 0x01; - TIM1->CCMR4 = 0x01; - /* Then reset channel registers: it also works if lock level is equal to 2 or 3 */ - TIM1->CCER1 = TIM1_CCER1_RESET_VALUE; - TIM1->CCER2 = TIM1_CCER2_RESET_VALUE; - TIM1->CCMR1 = TIM1_CCMR1_RESET_VALUE; - TIM1->CCMR2 = TIM1_CCMR2_RESET_VALUE; - TIM1->CCMR3 = TIM1_CCMR3_RESET_VALUE; - TIM1->CCMR4 = TIM1_CCMR4_RESET_VALUE; - TIM1->CNTRH = TIM1_CNTRH_RESET_VALUE; - TIM1->CNTRL = TIM1_CNTRL_RESET_VALUE; - TIM1->PSCRH = TIM1_PSCRH_RESET_VALUE; - TIM1->PSCRL = TIM1_PSCRL_RESET_VALUE; - TIM1->ARRH = TIM1_ARRH_RESET_VALUE; - TIM1->ARRL = TIM1_ARRL_RESET_VALUE; - TIM1->CCR1H = TIM1_CCR1H_RESET_VALUE; - TIM1->CCR1L = TIM1_CCR1L_RESET_VALUE; - TIM1->CCR2H = TIM1_CCR2H_RESET_VALUE; - TIM1->CCR2L = TIM1_CCR2L_RESET_VALUE; - TIM1->CCR3H = TIM1_CCR3H_RESET_VALUE; - TIM1->CCR3L = TIM1_CCR3L_RESET_VALUE; - TIM1->CCR4H = TIM1_CCR4H_RESET_VALUE; - TIM1->CCR4L = TIM1_CCR4L_RESET_VALUE; - TIM1->OISR = TIM1_OISR_RESET_VALUE; - TIM1->EGR = 0x01; /* TIM1_EGR_UG */ - TIM1->DTR = TIM1_DTR_RESET_VALUE; - TIM1->BKR = TIM1_BKR_RESET_VALUE; - TIM1->RCR = TIM1_RCR_RESET_VALUE; - TIM1->SR1 = TIM1_SR1_RESET_VALUE; -} - -/** - * @brief Initializes the TIM1 Time Base Unit according to the specified parameters. - * @param[in] TIM1_Prescaler specifies the Prescaler value. - * @param[in] TIM1_CounterMode specifies the counter mode from @ref TIM1_CounterMode_TypeDef . - * @param[in] TIM1_Period specifies the Period value. - * @param[in] TIM1_RepetitionCounter specifies the Repetition counter value - * @retval None - */ -void TIM1_TimeBaseInit(u16 TIM1_Prescaler, - TIM1_CounterMode_TypeDef TIM1_CounterMode, - u16 TIM1_Period, - u8 TIM1_RepetitionCounter) -{ - - /* Check parameters */ - assert_param(IS_TIM1_COUNTER_MODE_OK(TIM1_CounterMode)); - - /* Set the Autoreload value */ - TIM1->ARRH = (u8)(TIM1_Period >> 8); - TIM1->ARRL = (u8)(TIM1_Period); - - /* Set the Prescaler value */ - TIM1->PSCRH = (u8)(TIM1_Prescaler >> 8); - TIM1->PSCRL = (u8)(TIM1_Prescaler); - - /* Select the Counter Mode */ - TIM1->CR1 = (u8)(((TIM1->CR1) & (u8)(~(TIM1_CR1_CMS | TIM1_CR1_DIR))) | (u8)(TIM1_CounterMode)); - - /* Set the Repetition Counter value */ - TIM1->RCR = TIM1_RepetitionCounter; - -} - - -/** - * @brief Enables or disables the TIM1 peripheral. - * @param[in] NewState new state of the TIM1 peripheral. - * This parameter can be ENABLE or DISABLE. - * @retval None - */ -void TIM1_Cmd(FunctionalState NewState) -{ - /* Check the parameters */ - assert_param(IS_FUNCTIONALSTATE_OK(NewState)); - - /* set or Reset the CEN Bit */ - if (NewState != DISABLE) - { - TIM1->CR1 |= TIM1_CR1_CEN; - } - else - { - TIM1->CR1 &= (u8)(~TIM1_CR1_CEN); - } -} - - -/** - * @brief Enables or disables the specified TIM1 interrupts. - * @param[in] NewState new state of the TIM1 peripheral. - * This parameter can be: ENABLE or DISABLE. - * @param[in] TIM1_IT specifies the TIM1 interrupts sources to be enabled or disabled. - * This parameter can be any combination of the following values: - * - TIM1_IT_UPDATE: TIM1 update Interrupt source - * - TIM1_IT_CC1: TIM1 Capture Compare 1 Interrupt source - * - TIM1_IT_CC2: TIM1 Capture Compare 2 Interrupt source - * - TIM1_IT_CC3: TIM1 Capture Compare 3 Interrupt source - * - TIM1_IT_CC4: TIM1 Capture Compare 4 Interrupt source - * - TIM1_IT_CCUpdate: TIM1 Capture Compare Update Interrupt source - * - TIM1_IT_TRIGGER: TIM1 Trigger Interrupt source - * - TIM1_IT_BREAK: TIM1 Break Interrupt source - * @param[in] NewState new state of the TIM1 peripheral. - * @retval None - */ -void TIM1_ITConfig(TIM1_IT_TypeDef TIM1_IT, FunctionalState NewState) -{ - /* Check the parameters */ - assert_param(IS_TIM1_IT_OK(TIM1_IT)); - assert_param(IS_FUNCTIONALSTATE_OK(NewState)); - - if (NewState != DISABLE) - { - /* Enable the Interrupt sources */ - TIM1->IER |= (u8)TIM1_IT; - } - else - { - /* Disable the Interrupt sources */ - TIM1->IER &= (u8)(~(u8)TIM1_IT); - } -} - - -/** - * @} - */ - -/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm8/stm8s-periphs/stm8s_tim1.h b/ports/stm8/stm8s-periphs/stm8s_tim1.h deleted file mode 100644 index ede23499..00000000 --- a/ports/stm8/stm8s-periphs/stm8s_tim1.h +++ /dev/null @@ -1,565 +0,0 @@ -/** - ****************************************************************************** - * @file stm8s_tim1.h - * @brief This file contains all functions prototype and macros for the TIM1 peripheral. - * @author STMicroelectronics - MCD Application Team - * @version V1.1.1 - * @date 06/05/2009 - ****************************************************************************** - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- * @image html logo.bmp - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM8S_TIM1_H -#define __STM8S_TIM1_H - -/* Includes ------------------------------------------------------------------*/ -#include "stm8s.h" - -/* Exported types ------------------------------------------------------------*/ - - - -/** TIM1 Output Compare and PWM modes */ - -typedef enum -{ - TIM1_OCMODE_TIMING = ((u8)0x00), - TIM1_OCMODE_ACTIVE = ((u8)0x10), - TIM1_OCMODE_INACTIVE = ((u8)0x20), - TIM1_OCMODE_TOGGLE = ((u8)0x30), - TIM1_OCMODE_PWM1 = ((u8)0x60), - TIM1_OCMODE_PWM2 = ((u8)0x70) -}TIM1_OCMode_TypeDef; - -#define IS_TIM1_OC_MODE_OK(MODE) (((MODE) == TIM1_OCMODE_TIMING) || \ - ((MODE) == TIM1_OCMODE_ACTIVE) || \ - ((MODE) == TIM1_OCMODE_INACTIVE) || \ - ((MODE) == TIM1_OCMODE_TOGGLE)|| \ - ((MODE) == TIM1_OCMODE_PWM1) || \ - ((MODE) == TIM1_OCMODE_PWM2)) - -#define IS_TIM1_OCM_OK(MODE)(((MODE) == TIM1_OCMODE_TIMING) || \ - ((MODE) == TIM1_OCMODE_ACTIVE) || \ - ((MODE) == TIM1_OCMODE_INACTIVE) || \ - ((MODE) == TIM1_OCMODE_TOGGLE)|| \ - ((MODE) == TIM1_OCMODE_PWM1) || \ - ((MODE) == TIM1_OCMODE_PWM2) || \ - ((MODE) == TIM1_FORCEDACTION_ACTIVE) || \ - ((MODE) == TIM1_FORCEDACTION_INACTIVE)) - -/** TIM1 One Pulse Mode */ -typedef enum -{ - TIM1_OPMODE_SINGLE = ((u8)0x01), - TIM1_OPMODE_REPETITIVE = ((u8)0x00) -}TIM1_OPMode_TypeDef; - -#define IS_TIM1_OPM_MODE_OK(MODE) (((MODE) == TIM1_OPMODE_SINGLE) || \ - ((MODE) == TIM1_OPMODE_REPETITIVE)) - -/** TIM1 Channel */ - -typedef enum -{ - TIM1_CHANNEL_1 = ((u8)0x00), - TIM1_CHANNEL_2 = ((u8)0x01), - TIM1_CHANNEL_3 = ((u8)0x02), - TIM1_CHANNEL_4 = ((u8)0x03) -}TIM1_Channel_TypeDef; - - -#define IS_TIM1_CHANNEL_OK(CHANNEL) (((CHANNEL) == TIM1_CHANNEL_1) || \ - ((CHANNEL) == TIM1_CHANNEL_2) || \ - ((CHANNEL) == TIM1_CHANNEL_3) || \ - ((CHANNEL) == TIM1_CHANNEL_4)) - -#define IS_TIM1_PWMI_CHANNEL_OK(CHANNEL) (((CHANNEL) == TIM1_CHANNEL_1) || \ - ((CHANNEL) == TIM1_CHANNEL_2)) - -#define IS_TIM1_COMPLEMENTARY_CHANNEL_OK(CHANNEL) (((CHANNEL) == TIM1_CHANNEL_1) || \ - ((CHANNEL) == TIM1_CHANNEL_2) || \ - ((CHANNEL) == TIM1_CHANNEL_3)) - - -/** TIM1 Counter Mode */ -typedef enum -{ - TIM1_COUNTERMODE_UP = ((u8)0x00), - TIM1_COUNTERMODE_DOWN = ((u8)0x10), - TIM1_COUNTERMODE_CENTERALIGNED1 = ((u8)0x20), - TIM1_COUNTERMODE_CENTERALIGNED2 = ((u8)0x40), - TIM1_COUNTERMODE_CENTERALIGNED3 = ((u8)0x60) -}TIM1_CounterMode_TypeDef; - -#define IS_TIM1_COUNTER_MODE_OK(MODE) (((MODE) == TIM1_COUNTERMODE_UP) || \ - ((MODE) == TIM1_COUNTERMODE_DOWN) || \ - ((MODE) == TIM1_COUNTERMODE_CENTERALIGNED1) || \ - ((MODE) == TIM1_COUNTERMODE_CENTERALIGNED2) || \ - ((MODE) == TIM1_COUNTERMODE_CENTERALIGNED3)) - -/** TIM1 Output Compare Polarity */ -typedef enum -{ - TIM1_OCPOLARITY_HIGH = ((u8)0x00), - TIM1_OCPOLARITY_LOW = ((u8)0x22) -}TIM1_OCPolarity_TypeDef; - -#define IS_TIM1_OC_POLARITY_OK(POLARITY) (((POLARITY) == TIM1_OCPOLARITY_HIGH) || \ - ((POLARITY) == TIM1_OCPOLARITY_LOW)) - -/** TIM1 Output Compare N Polarity */ -typedef enum -{ - TIM1_OCNPOLARITY_HIGH = ((u8)0x00), - TIM1_OCNPOLARITY_LOW = ((u8)0x88) -}TIM1_OCNPolarity_TypeDef; - -#define IS_TIM1_OCN_POLARITY_OK(POLARITY) (((POLARITY) == TIM1_OCNPOLARITY_HIGH) || \ - ((POLARITY) == TIM1_OCNPOLARITY_LOW)) - -/** TIM1 Output Compare states */ -typedef enum -{ - TIM1_OUTPUTSTATE_DISABLE = ((u8)0x00), - TIM1_OUTPUTSTATE_ENABLE = ((u8)0x11) -}TIM1_OutputState_TypeDef; - -#define IS_TIM1_OUTPUT_STATE_OK(STATE) (((STATE) == TIM1_OUTPUTSTATE_DISABLE) || \ - ((STATE) == TIM1_OUTPUTSTATE_ENABLE)) - -/** TIM1 Output Compare N States */ -typedef enum -{ - TIM1_OUTPUTNSTATE_DISABLE = ((u8)0x00), - TIM1_OUTPUTNSTATE_ENABLE = ((u8)0x44) -} TIM1_OutputNState_TypeDef; - -#define IS_TIM1_OUTPUTN_STATE_OK(STATE) (((STATE) == TIM1_OUTPUTNSTATE_DISABLE) ||\ - ((STATE) == TIM1_OUTPUTNSTATE_ENABLE)) - -/** TIM1 Break Input enable/disable */ -typedef enum -{ - TIM1_BREAK_ENABLE = ((u8)0x10), - TIM1_BREAK_DISABLE = ((u8)0x00) -}TIM1_BreakState_TypeDef; -#define IS_TIM1_BREAK_STATE_OK(STATE) (((STATE) == TIM1_BREAK_ENABLE) || \ - ((STATE) == TIM1_BREAK_DISABLE)) - -/** TIM1 Break Polarity */ -typedef enum -{ - TIM1_BREAKPOLARITY_LOW = ((u8)0x00), - TIM1_BREAKPOLARITY_HIGH = ((u8)0x20) -}TIM1_BreakPolarity_TypeDef; -#define IS_TIM1_BREAK_POLARITY_OK(POLARITY) (((POLARITY) == TIM1_BREAKPOLARITY_LOW) || \ - ((POLARITY) == TIM1_BREAKPOLARITY_HIGH)) - -/** TIM1 AOE Bit Set/Reset */ -typedef enum -{ - TIM1_AUTOMATICOUTPUT_ENABLE = ((u8)0x40), - TIM1_AUTOMATICOUTPUT_DISABLE = ((u8)0x00) -}TIM1_AutomaticOutput_TypeDef; - -#define IS_TIM1_AUTOMATIC_OUTPUT_STATE_OK(STATE) (((STATE) == TIM1_AUTOMATICOUTPUT_ENABLE) || \ - ((STATE) == TIM1_AUTOMATICOUTPUT_DISABLE)) - -/** TIM1 Lock levels */ -typedef enum -{ - TIM1_LOCKLEVEL_OFF = ((u8)0x00), - TIM1_LOCKLEVEL_1 = ((u8)0x01), - TIM1_LOCKLEVEL_2 = ((u8)0x02), - TIM1_LOCKLEVEL_3 = ((u8)0x03) -}TIM1_LockLevel_TypeDef; - -#define IS_TIM1_LOCK_LEVEL_OK(LEVEL) (((LEVEL) == TIM1_LOCKLEVEL_OFF) || \ - ((LEVEL) == TIM1_LOCKLEVEL_1) || \ - ((LEVEL) == TIM1_LOCKLEVEL_2) || \ - ((LEVEL) == TIM1_LOCKLEVEL_3)) - -/** TIM1 OSSI: Off-State Selection for Idle mode states */ -typedef enum -{ - TIM1_OSSISTATE_ENABLE = ((u8)0x04), - TIM1_OSSISTATE_DISABLE = ((u8)0x00) -}TIM1_OSSIState_TypeDef; - -#define IS_TIM1_OSSI_STATE_OK(STATE) (((STATE) == TIM1_OSSISTATE_ENABLE) || \ - ((STATE) == TIM1_OSSISTATE_DISABLE)) - -/** TIM1 Output Compare Idle State */ -typedef enum -{ - TIM1_OCIDLESTATE_SET = ((u8)0x55), - TIM1_OCIDLESTATE_RESET = ((u8)0x00) -}TIM1_OCIdleState_TypeDef; - -#define IS_TIM1_OCIDLE_STATE_OK(STATE) (((STATE) == TIM1_OCIDLESTATE_SET) || \ - ((STATE) == TIM1_OCIDLESTATE_RESET)) - -/** TIM1 Output Compare N Idle State */ -typedef enum -{ - TIM1_OCNIDLESTATE_SET = ((u8)0x2A), - TIM1_OCNIDLESTATE_RESET = ((u8)0x00) -}TIM1_OCNIdleState_TypeDef; - -#define IS_TIM1_OCNIDLE_STATE_OK(STATE) (((STATE) == TIM1_OCNIDLESTATE_SET) || \ - ((STATE) == TIM1_OCNIDLESTATE_RESET)) - -/** TIM1 Input Capture Polarity */ -typedef enum -{ - TIM1_ICPOLARITY_RISING = ((u8)0x00), - TIM1_ICPOLARITY_FALLING = ((u8)0x01) -}TIM1_ICPolarity_TypeDef; - -#define IS_TIM1_IC_POLARITY_OK(POLARITY) (((POLARITY) == TIM1_ICPOLARITY_RISING) || \ - ((POLARITY) == TIM1_ICPOLARITY_FALLING)) - -/** TIM1 Input Capture Selection */ -typedef enum -{ - TIM1_ICSELECTION_DIRECTTI = ((u8)0x01), - TIM1_ICSELECTION_INDIRECTTI = ((u8)0x02), - TIM1_ICSELECTION_TRGI = ((u8)0x03) -}TIM1_ICSelection_TypeDef; - -#define IS_TIM1_IC_SELECTION_OK(SELECTION) (((SELECTION) == TIM1_ICSELECTION_DIRECTTI) || \ - ((SELECTION) == TIM1_ICSELECTION_INDIRECTTI) || \ - ((SELECTION) == TIM1_ICSELECTION_TRGI)) - -/** TIM1 Input Capture Prescaler */ -typedef enum -{ - TIM1_ICPSC_DIV1 = ((u8)0x00), - TIM1_ICPSC_DIV2 = ((u8)0x04), - TIM1_ICPSC_DIV4 = ((u8)0x08), - TIM1_ICPSC_DIV8 = ((u8)0x0C) -}TIM1_ICPSC_TypeDef; - -#define IS_TIM1_IC_PRESCALER_OK(PRESCALER) (((PRESCALER) == TIM1_ICPSC_DIV1) || \ - ((PRESCALER) == TIM1_ICPSC_DIV2) || \ - ((PRESCALER) == TIM1_ICPSC_DIV4) || \ - ((PRESCALER) == TIM1_ICPSC_DIV8)) - -/** TIM1 Input Capture Filer Value */ - -#define IS_TIM1_IC_FILTER_OK(ICFILTER) (ICFILTER <= 0x0F) - -/** TIM1 External Trigger Filer Value */ -#define IS_TIM1_EXT_TRG_FILTER_OK(FILTER) (FILTER <= 0x0F) - -/** TIM1 interrupt sources */ -typedef enum -{ - TIM1_IT_UPDATE = ((u8)0x01), - TIM1_IT_CC1 = ((u8)0x02), - TIM1_IT_CC2 = ((u8)0x04), - TIM1_IT_CC3 = ((u8)0x08), - TIM1_IT_CC4 = ((u8)0x10), - TIM1_IT_COM = ((u8)0x20), - TIM1_IT_TRIGGER = ((u8)0x40), - TIM1_IT_BREAK = ((u8)0x80) -}TIM1_IT_TypeDef; - -#define IS_TIM1_IT_OK(IT) (IT != 0x00) - -#define IS_TIM1_GET_IT_OK(IT) (((IT) == TIM1_IT_UPDATE) || \ - ((IT) == TIM1_IT_CC1) || \ - ((IT) == TIM1_IT_CC2) || \ - ((IT) == TIM1_IT_CC3) || \ - ((IT) == TIM1_IT_CC4) || \ - ((IT) == TIM1_IT_COM) || \ - ((IT) == TIM1_IT_TRIGGER) || \ - ((IT) == TIM1_IT_BREAK)) - - -/** TIM1 External Trigger Prescaler */ -typedef enum -{ - TIM1_EXTTRGPSC_OFF = ((u8)0x00), - TIM1_EXTTRGPSC_DIV2 = ((u8)0x10), - TIM1_EXTTRGPSC_DIV4 = ((u8)0x20), - TIM1_EXTTRGPSC_DIV8 = ((u8)0x30) -}TIM1_ExtTRGPSC_TypeDef; - -#define IS_TIM1_EXT_PRESCALER_OK(PRESCALER) (((PRESCALER) == TIM1_EXTTRGPSC_OFF) || \ - ((PRESCALER) == TIM1_EXTTRGPSC_DIV2) || \ - ((PRESCALER) == TIM1_EXTTRGPSC_DIV4) || \ - ((PRESCALER) == TIM1_EXTTRGPSC_DIV8)) - -/** TIM1 Internal Trigger Selection */ -typedef enum -{ - TIM1_TS_TIM6 = ((u8)0x00), /*!< TRIG Input source = TIM6 TRIG Output */ - TIM1_TS_TIM5 = ((u8)0x30), /*!< TRIG Input source = TIM5 TRIG Output */ - TIM1_TS_TI1F_ED = ((u8)0x40), - TIM1_TS_TI1FP1 = ((u8)0x50), - TIM1_TS_TI2FP2 = ((u8)0x60), - TIM1_TS_ETRF = ((u8)0x70) -}TIM1_TS_TypeDef; - -#define IS_TIM1_TRIGGER_SELECTION_OK(SELECTION) (((SELECTION) == TIM1_TS_TI1F_ED) || \ - ((SELECTION) == TIM1_TS_TI1FP1) || \ - ((SELECTION) == TIM1_TS_TI2FP2) || \ - ((SELECTION) == TIM1_TS_ETRF) || \ - ((SELECTION) == TIM1_TS_TIM5) || \ - ((SELECTION) == TIM1_TS_TIM6)) - - -#define IS_TIM1_TIX_TRIGGER_SELECTION_OK(SELECTION) (((SELECTION) == TIM1_TS_TI1F_ED) || \ - ((SELECTION) == TIM1_TS_TI1FP1) || \ - ((SELECTION) == TIM1_TS_TI2FP2)) - -/** TIM1 TIx External Clock Source */ -typedef enum -{ - TIM1_TIXEXTERNALCLK1SOURCE_TI1ED = ((u8)0x40), - TIM1_TIXEXTERNALCLK1SOURCE_TI1 = ((u8)0x50), - TIM1_TIXEXTERNALCLK1SOURCE_TI2 = ((u8)0x60) -}TIM1_TIxExternalCLK1Source_TypeDef; - -#define IS_TIM1_TIXCLK_SOURCE_OK(SOURCE) (((SOURCE) == TIM1_TIXEXTERNALCLK1SOURCE_TI1ED) || \ - ((SOURCE) == TIM1_TIXEXTERNALCLK1SOURCE_TI2) || \ - ((SOURCE) == TIM1_TIXEXTERNALCLK1SOURCE_TI1)) - -/** TIM1 External Trigger Polarity */ -typedef enum -{ - TIM1_EXTTRGPOLARITY_INVERTED = ((u8)0x80), - TIM1_EXTTRGPOLARITY_NONINVERTED = ((u8)0x00) -}TIM1_ExtTRGPolarity_TypeDef; - -#define IS_TIM1_EXT_POLARITY_OK(POLARITY) (((POLARITY) == TIM1_EXTTRGPOLARITY_INVERTED) || \ - ((POLARITY) == TIM1_EXTTRGPOLARITY_NONINVERTED)) - -/** TIM1 Prescaler Reload Mode */ -typedef enum -{ - TIM1_PSCRELOADMODE_UPDATE = ((u8)0x00), - TIM1_PSCRELOADMODE_IMMEDIATE = ((u8)0x01) -}TIM1_PSCReloadMode_TypeDef; - -#define IS_TIM1_PRESCALER_RELOAD_OK(RELOAD) (((RELOAD) == TIM1_PSCRELOADMODE_UPDATE) || \ - ((RELOAD) == TIM1_PSCRELOADMODE_IMMEDIATE)) - -/** TIM1 Encoder Mode */ -typedef enum -{ - TIM1_ENCODERMODE_TI1 = ((u8)0x01), - TIM1_ENCODERMODE_TI2 = ((u8)0x02), - TIM1_ENCODERMODE_TI12 = ((u8)0x03) -}TIM1_EncoderMode_TypeDef; - -#define IS_TIM1_ENCODER_MODE_OK(MODE) (((MODE) == TIM1_ENCODERMODE_TI1) || \ - ((MODE) == TIM1_ENCODERMODE_TI2) || \ - ((MODE) == TIM1_ENCODERMODE_TI12)) - -/** TIM1 Event Source */ -typedef enum -{ - TIM1_EVENTSOURCE_UPDATE = ((u8)0x01), - TIM1_EVENTSOURCE_CC1 = ((u8)0x02), - TIM1_EVENTSOURCE_CC2 = ((u8)0x04), - TIM1_EVENTSOURCE_CC3 = ((u8)0x08), - TIM1_EVENTSOURCE_CC4 = ((u8)0x10), - TIM1_EVENTSOURCE_COM = ((u8)0x20), - TIM1_EVENTSOURCE_TRIGGER = ((u8)0x40), - TIM1_EVENTSOURCE_BREAK = ((u8)0x80) -}TIM1_EventSource_TypeDef; - -#define IS_TIM1_EVENT_SOURCE_OK(SOURCE) ((SOURCE) != 0x00) - -/** TIM1 Update Source */ -typedef enum -{ - TIM1_UPDATESOURCE_GLOBAL = ((u8)0x00), - TIM1_UPDATESOURCE_REGULAR = ((u8)0x01) -}TIM1_UpdateSource_TypeDef; - -#define IS_TIM1_UPDATE_SOURCE_OK(SOURCE) (((SOURCE) == TIM1_UPDATESOURCE_GLOBAL) || \ - ((SOURCE) == TIM1_UPDATESOURCE_REGULAR)) - -/** TIM1 Trigger Output Source */ -typedef enum -{ - TIM1_TRGOSOURCE_RESET = ((u8)0x00), - TIM1_TRGOSOURCE_ENABLE = ((u8)0x10), - TIM1_TRGOSOURCE_UPDATE = ((u8)0x20), - TIM1_TRGOSource_OC1 = ((u8)0x30), - TIM1_TRGOSOURCE_OC1REF = ((u8)0x40), - TIM1_TRGOSOURCE_OC2REF = ((u8)0x50), - TIM1_TRGOSOURCE_OC3REF = ((u8)0x60) -}TIM1_TRGOSource_TypeDef; - -#define IS_TIM1_TRGO_SOURCE_OK(SOURCE) (((SOURCE) == TIM1_TRGOSOURCE_RESET) || \ - ((SOURCE) == TIM1_TRGOSOURCE_ENABLE) || \ - ((SOURCE) == TIM1_TRGOSOURCE_UPDATE) || \ - ((SOURCE) == TIM1_TRGOSource_OC1) || \ - ((SOURCE) == TIM1_TRGOSOURCE_OC1REF) || \ - ((SOURCE) == TIM1_TRGOSOURCE_OC2REF) || \ - ((SOURCE) == TIM1_TRGOSOURCE_OC3REF)) - -/** TIM1 Slave Mode */ -typedef enum -{ - TIM1_SLAVEMODE_RESET = ((u8)0x04), - TIM1_SLAVEMODE_GATED = ((u8)0x05), - TIM1_SLAVEMODE_TRIGGER = ((u8)0x06), - TIM1_SLAVEMODE_EXTERNAL1 = ((u8)0x07) -}TIM1_SlaveMode_TypeDef; - -#define IS_TIM1_SLAVE_MODE_OK(MODE) (((MODE) == TIM1_SLAVEMODE_RESET) || \ - ((MODE) == TIM1_SLAVEMODE_GATED) || \ - ((MODE) == TIM1_SLAVEMODE_TRIGGER) || \ - ((MODE) == TIM1_SLAVEMODE_EXTERNAL1)) - -/** TIM1 Flags */ -typedef enum -{ - TIM1_FLAG_UPDATE = ((u16)0x0001), - TIM1_FLAG_CC1 = ((u16)0x0002), - TIM1_FLAG_CC2 = ((u16)0x0004), - TIM1_FLAG_CC3 = ((u16)0x0008), - TIM1_FLAG_CC4 = ((u16)0x0010), - TIM1_FLAG_COM = ((u16)0x0020), - TIM1_FLAG_TRIGGER = ((u16)0x0040), - TIM1_FLAG_BREAK = ((u16)0x0080), - TIM1_FLAG_CC1OF = ((u16)0x0200), - TIM1_FLAG_CC2OF = ((u16)0x0400), - TIM1_FLAG_CC3OF = ((u16)0x0800), - TIM1_FLAG_CC4OF = ((u16)0x1000) -}TIM1_FLAG_TypeDef; - -#define IS_TIM1_GET_FLAG_OK(FLAG) (((FLAG) == TIM1_FLAG_UPDATE) || \ - ((FLAG) == TIM1_FLAG_CC1) || \ - ((FLAG) == TIM1_FLAG_CC2) || \ - ((FLAG) == TIM1_FLAG_CC3) || \ - ((FLAG) == TIM1_FLAG_CC4) || \ - ((FLAG) == TIM1_FLAG_COM) || \ - ((FLAG) == TIM1_FLAG_TRIGGER) || \ - ((FLAG) == TIM1_FLAG_BREAK) || \ - ((FLAG) == TIM1_FLAG_CC1OF) || \ - ((FLAG) == TIM1_FLAG_CC2OF) || \ - ((FLAG) == TIM1_FLAG_CC3OF) || \ - ((FLAG) == TIM1_FLAG_CC4OF)) - -#define IS_TIM1_CLEAR_FLAG_OK(FLAG) ((((u16)FLAG & (u16)0xE100) == 0x0000) && (FLAG != 0x0000)) - -/** TIM1 Forced Action */ -typedef enum -{ - TIM1_FORCEDACTION_ACTIVE = ((u8)0x50), - TIM1_FORCEDACTION_INACTIVE = ((u8)0x40) -}TIM1_ForcedAction_TypeDef; - -#define IS_TIM1_FORCED_ACTION_OK(ACTION) ((ACTION == TIM1_FORCEDACTION_ACTIVE) || \ - (ACTION == TIM1_FORCEDACTION_INACTIVE)) -/** - * @} - */ - -/* Exported macro ------------------------------------------------------------*/ - -/* Exported functions --------------------------------------------------------*/ - -/** @addtogroup TIM1_Exported_Functions - * @{ - */ - -void TIM1_DeInit(void); -void TIM1_TimeBaseInit(u16 TIM1_Prescaler, TIM1_CounterMode_TypeDef TIM1_CounterMode, u16 TIM1_Period, u8 TIM1_RepetitionCounter); -void TIM1_OC1Init(TIM1_OCMode_TypeDef TIM1_OCMode, TIM1_OutputState_TypeDef TIM1_OutputState, TIM1_OutputNState_TypeDef TIM1_OutputNState, u16 TIM1_Pulse, TIM1_OCPolarity_TypeDef TIM1_OCPolarity, TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity, TIM1_OCIdleState_TypeDef TIM1_OCIdleState, TIM1_OCNIdleState_TypeDef TIM1_OCNIdleState); -void TIM1_OC2Init(TIM1_OCMode_TypeDef TIM1_OCMode, TIM1_OutputState_TypeDef TIM1_OutputState, TIM1_OutputNState_TypeDef TIM1_OutputNState, u16 TIM1_Pulse, TIM1_OCPolarity_TypeDef TIM1_OCPolarity, TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity, TIM1_OCIdleState_TypeDef TIM1_OCIdleState, TIM1_OCNIdleState_TypeDef TIM1_OCNIdleState); -void TIM1_OC3Init(TIM1_OCMode_TypeDef TIM1_OCMode, TIM1_OutputState_TypeDef TIM1_OutputState, TIM1_OutputNState_TypeDef TIM1_OutputNState, u16 TIM1_Pulse, TIM1_OCPolarity_TypeDef TIM1_OCPolarity, TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity, TIM1_OCIdleState_TypeDef TIM1_OCIdleState, TIM1_OCNIdleState_TypeDef TIM1_OCNIdleState); -void TIM1_OC4Init(TIM1_OCMode_TypeDef TIM1_OCMode, TIM1_OutputState_TypeDef TIM1_OutputState, u16 TIM1_Pulse, TIM1_OCPolarity_TypeDef TIM1_OCPolarity, TIM1_OCIdleState_TypeDef TIM1_OCIdleState); -void TIM1_BDTRConfig(TIM1_OSSIState_TypeDef TIM1_OSSIState, TIM1_LockLevel_TypeDef TIM1_LockLevel, u8 TIM1_DeadTime, TIM1_BreakState_TypeDef TIM1_Break, TIM1_BreakPolarity_TypeDef TIM1_BreakPolarity, TIM1_AutomaticOutput_TypeDef TIM1_AutomaticOutput); -void TIM1_ICInit(TIM1_Channel_TypeDef TIM1_Channel, TIM1_ICPolarity_TypeDef TIM1_ICPolarity, TIM1_ICSelection_TypeDef TIM1_ICSelection, TIM1_ICPSC_TypeDef TIM1_ICPrescaler, u8 TIM1_ICFilter); -void TIM1_PWMIConfig(TIM1_Channel_TypeDef TIM1_Channel, TIM1_ICPolarity_TypeDef TIM1_ICPolarity, TIM1_ICSelection_TypeDef TIM1_ICSelection, TIM1_ICPSC_TypeDef TIM1_ICPrescaler, u8 TIM1_ICFilter); -void TIM1_Cmd(FunctionalState NewState); -void TIM1_CtrlPWMOutputs(FunctionalState Newstate); -void TIM1_ITConfig(TIM1_IT_TypeDef TIM1_IT, FunctionalState NewState); -void TIM1_InternalClockConfig(void); -void TIM1_ETRClockMode1Config(TIM1_ExtTRGPSC_TypeDef TIM1_ExtTRGPrescaler, TIM1_ExtTRGPolarity_TypeDef TIM1_ExtTRGPolarity, u8 ExtTRGFilter); -void TIM1_ETRClockMode2Config(TIM1_ExtTRGPSC_TypeDef TIM1_ExtTRGPrescaler, TIM1_ExtTRGPolarity_TypeDef TIM1_ExtTRGPolarity, u8 ExtTRGFilter); -void TIM1_ETRConfig(TIM1_ExtTRGPSC_TypeDef TIM1_ExtTRGPrescaler, TIM1_ExtTRGPolarity_TypeDef TIM1_ExtTRGPolarity, u8 ExtTRGFilter); -void TIM1_TIxExternalClockConfig(TIM1_TIxExternalCLK1Source_TypeDef TIM1_TIxExternalCLKSource, TIM1_ICPolarity_TypeDef TIM1_ICPolarity, u8 ICFilter); -void TIM1_SelectInputTrigger(TIM1_TS_TypeDef TIM1_InputTriggerSource); -void TIM1_UpdateDisableConfig(FunctionalState Newstate); -void TIM1_UpdateRequestConfig(TIM1_UpdateSource_TypeDef TIM1_UpdateSource); -void TIM1_SelectHallSensor(FunctionalState Newstate); -void TIM1_SelectOnePulseMode(TIM1_OPMode_TypeDef TIM1_OPMode); -void TIM1_SelectOutputTrigger(TIM1_TRGOSource_TypeDef TIM1_TRGOSource); -void TIM1_SelectSlaveMode(TIM1_SlaveMode_TypeDef TIM1_SlaveMode); -void TIM1_SelectMasterSlaveMode(FunctionalState NewState); -void TIM1_EncoderInterfaceConfig(TIM1_EncoderMode_TypeDef TIM1_EncoderMode, TIM1_ICPolarity_TypeDef TIM1_IC1Polarity, TIM1_ICPolarity_TypeDef TIM1_IC2Polarity); -void TIM1_PrescalerConfig(u16 Prescaler, TIM1_PSCReloadMode_TypeDef TIM1_PSCReloadMode); -void TIM1_CounterModeConfig(TIM1_CounterMode_TypeDef TIM1_CounterMode); -void TIM1_ForcedOC1Config(TIM1_ForcedAction_TypeDef TIM1_ForcedAction); -void TIM1_ForcedOC2Config(TIM1_ForcedAction_TypeDef TIM1_ForcedAction); -void TIM1_ForcedOC3Config(TIM1_ForcedAction_TypeDef TIM1_ForcedAction); -void TIM1_ForcedOC4Config(TIM1_ForcedAction_TypeDef TIM1_ForcedAction); -void TIM1_ARRPreloadConfig(FunctionalState Newstate); -void TIM1_SelectCOM(FunctionalState Newstate); -void TIM1_CCPreloadControl(FunctionalState Newstate); -void TIM1_OC1PreloadConfig(FunctionalState Newstate); -void TIM1_OC2PreloadConfig(FunctionalState Newstate); -void TIM1_OC3PreloadConfig(FunctionalState Newstate); -void TIM1_OC4PreloadConfig(FunctionalState Newstate); -void TIM1_OC1FastConfig(FunctionalState Newstate); -void TIM1_OC2FastConfig(FunctionalState Newstate); -void TIM1_OC3FastConfig(FunctionalState Newstate); -void TIM1_OC4FastConfig(FunctionalState Newstate); -void TIM1_GenerateEvent(TIM1_EventSource_TypeDef TIM1_EventSource); -void TIM1_OC1PolarityConfig(TIM1_OCPolarity_TypeDef TIM1_OCPolarity); -void TIM1_OC1NPolarityConfig(TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity); -void TIM1_OC2PolarityConfig(TIM1_OCPolarity_TypeDef TIM1_OCPolarity); -void TIM1_OC2NPolarityConfig(TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity); -void TIM1_OC3PolarityConfig(TIM1_OCPolarity_TypeDef TIM1_OCPolarity); -void TIM1_OC3NPolarityConfig(TIM1_OCNPolarity_TypeDef TIM1_OCNPolarity); -void TIM1_OC4PolarityConfig(TIM1_OCPolarity_TypeDef TIM1_OCPolarity); -void TIM1_CCxCmd(TIM1_Channel_TypeDef TIM1_Channel, FunctionalState Newstate); -void TIM1_CCxNCmd(TIM1_Channel_TypeDef TIM1_Channel, FunctionalState Newstate); -void TIM1_SelectOCxM(TIM1_Channel_TypeDef TIM1_Channel, TIM1_OCMode_TypeDef TIM1_OCMode); -void TIM1_SetCounter(u16 Counter); -void TIM1_SetAutoreload(u16 Autoreload); -void TIM1_SetCompare1(u16 Compare1); -void TIM1_SetCompare2(u16 Compare2); -void TIM1_SetCompare3(u16 Compare3); -void TIM1_SetCompare4(u16 Compare4); -void TIM1_SetIC1Prescaler(TIM1_ICPSC_TypeDef TIM1_IC1Prescaler); -void TIM1_SetIC2Prescaler(TIM1_ICPSC_TypeDef TIM1_IC2Prescaler); -void TIM1_SetIC3Prescaler(TIM1_ICPSC_TypeDef TIM1_IC3Prescaler); -void TIM1_SetIC4Prescaler(TIM1_ICPSC_TypeDef TIM1_IC4Prescaler); -u16 TIM1_GetCapture1(void); -u16 TIM1_GetCapture2(void); -u16 TIM1_GetCapture3(void); -u16 TIM1_GetCapture4(void); -u16 TIM1_GetCounter(void); -u16 TIM1_GetPrescaler(void); -FlagStatus TIM1_GetFlagStatus(TIM1_FLAG_TypeDef TIM1_FLAG); -void TIM1_ClearFlag(TIM1_FLAG_TypeDef TIM1_FLAG); -ITStatus TIM1_GetITStatus(TIM1_IT_TypeDef TIM1_IT); -void TIM1_ClearITPendingBit(TIM1_IT_TypeDef TIM1_IT); - -/** - * @} - */ - -#endif /* __STM8S_TIM1_H */ - -/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm8/stm8s-periphs/stm8s_type.h b/ports/stm8/stm8s-periphs/stm8s_type.h deleted file mode 100644 index 5c80f668..00000000 --- a/ports/stm8/stm8s-periphs/stm8s_type.h +++ /dev/null @@ -1,103 +0,0 @@ -/** - ****************************************************************************** - * @file stm8s_type.h - * @brief This file contains all common data types. - * @author STMicroelectronics - MCD Application Team - * @version V1.1.1 - * @date 06/05/2009 - ****************************************************************************** - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- * @image html logo.bmp - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM8S_TYPE_H -#define __STM8S_TYPE_H - -/* Includes ------------------------------------------------------------------*/ -/* Exported types ------------------------------------------------------------*/ -typedef signed long s32; -typedef signed short s16; -typedef signed char s8; - -typedef signed long const sc32; /* Read Only */ -typedef signed short const sc16; /* Read Only */ -typedef signed char const sc8; /* Read Only */ - -typedef volatile signed long vs32; -typedef volatile signed short vs16; -typedef volatile signed char vs8; - -typedef volatile signed long const vsc32; /* Read Only */ -typedef volatile signed short const vsc16; /* Read Only */ -typedef volatile signed char const vsc8; /* Read Only */ - -typedef unsigned long u32; -typedef unsigned short u16; -typedef unsigned char u8; - -typedef unsigned long const uc32; /* Read Only */ -typedef unsigned short const uc16; /* Read Only */ -typedef unsigned char const uc8; /* Read Only */ - -typedef volatile unsigned long vu32; -typedef volatile unsigned short vu16; -typedef volatile unsigned char vu8; - -typedef volatile unsigned long const vuc32; /* Read Only */ -typedef volatile unsigned short const vuc16; /* Read Only */ -typedef volatile unsigned char const vuc8; /* Read Only */ - -typedef enum -{ - FALSE = 0, - TRUE = !FALSE -} -bool; - -typedef enum { - RESET = 0, - SET = !RESET -} -FlagStatus, ITStatus, BitStatus; - -typedef enum { - DISABLE = 0, - ENABLE = !DISABLE -} -FunctionalState; - -#define IS_FUNCTIONALSTATE_OK(VALUE) ( (VALUE == ENABLE) || (VALUE == DISABLE) ) - -typedef enum { - ERROR = 0, - SUCCESS = !ERROR -} -ErrorStatus; - -#define U8_MAX ((u8)255) -#define S8_MAX ((s8)127) -#define S8_MIN ((s8)-128) -#define U16_MAX ((u16)65535u) -#define S16_MAX ((s16)32767) -#define S16_MIN ((s16)-32768) -#define U32_MAX ((u32)4294967295uL) -#define S32_MAX ((s32)2147483647) -#define S32_MIN ((s32)-2147483648) - -/* Exported constants --------------------------------------------------------*/ -/* Exported macro ------------------------------------------------------------*/ -/* Exported functions ------------------------------------------------------- */ - -#endif /* __STM8S_TYPE_H */ - -/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm8/stm8s-periphs/stm8s_uart2.c b/ports/stm8/stm8s-periphs/stm8s_uart2.c deleted file mode 100644 index 406e2e03..00000000 --- a/ports/stm8/stm8s-periphs/stm8s_uart2.c +++ /dev/null @@ -1,272 +0,0 @@ -/** - ******************************************************************************** - * @file stm8s_uart2.c - * @brief This file contains all the functions for the UART2 peripheral. - * @author STMicroelectronics - MCD Application Team - * @version V1.1.1 - * @date 06/05/2009 - ****************************************************************************** - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- * @image html logo.bmp - ****************************************************************************** - */ - -/* Includes ------------------------------------------------------------------*/ -#include "stm8s_uart2.h" -#include "stm8s_clk.h" - -/* Private typedef -----------------------------------------------------------*/ -/* Private define ------------------------------------------------------------*/ -/* Private macro -------------------------------------------------------------*/ -/* Private variables ---------------------------------------------------------*/ -/* Private function prototypes -----------------------------------------------*/ -/* Private functions ---------------------------------------------------------*/ -/* Public functions ----------------------------------------------------------*/ - -/** - * IAR EWSTM8: Ignore unused variable warning on dummy variable. - */ -#ifdef __IAR_SYSTEMS_ICC__ -#pragma diag_suppress=Pe550 -#endif - - -/** @} - * @addtogroup UART2_Public_Functions - * @{ - */ - -/** - * @brief Deinitializes the UART2 peripheral. - * @par Full description: - * Set the UART2 peripheral registers to their default reset values. - * @retval None - */ - -void UART2_DeInit(void) -{ - u8 dummy = 0; - /*< Clear the Idle Line Detected bit in the status rerister by a read - to the UART2_SR register followed by a Read to the UART2_DR register */ - dummy = UART2->SR; - dummy = UART2->DR; - - UART2->BRR2 = UART2_BRR2_RESET_VALUE; /*< Set UART2_BRR2 to reset value 0x00 */ - UART2->BRR1 = UART2_BRR1_RESET_VALUE; /*< Set UART2_BRR1 to reset value 0x00 */ - - UART2->CR1 = UART2_CR1_RESET_VALUE; /*< Set UART2_CR1 to reset value 0x00 */ - UART2->CR2 = UART2_CR2_RESET_VALUE; /*< Set UART2_CR2 to reset value 0x00 */ - UART2->CR3 = UART2_CR3_RESET_VALUE; /*< Set UART2_CR3 to reset value 0x00 */ - UART2->CR4 = UART2_CR4_RESET_VALUE; /*< Set UART2_CR4 to reset value 0x00 */ - UART2->CR5 = UART2_CR5_RESET_VALUE; /*< Set UART2_CR5 to reset value 0x00 */ - UART2->CR6 = UART2_CR6_RESET_VALUE; /*< Set UART2_CR6 to reset value 0x00 */ - -} - -/** - * @brief Initializes the UART2 according to the specified parameters. - * @param[in] BaudRate: The baudrate. - * @param[in] WordLength : This parameter can be any of the @ref UART2_WordLength_TypeDef enumeration. - * @param[in] StopBits: This parameter can be any of the @ref UART2_StopBits_TypeDef enumeration. - * @param[in] Parity: This parameter can be any of the @ref UART2_Parity_TypeDef enumeration. - * @param[in] SyncMode: This parameter can be any of the @ref UART2_SyncMode_TypeDef values. - * @param[in] Mode: This parameter can be any of the @ref UART2_Mode_TypeDef values - * @retval None - */ -void UART2_Init(u32 BaudRate, UART2_WordLength_TypeDef WordLength, UART2_StopBits_TypeDef StopBits, UART2_Parity_TypeDef Parity, UART2_SyncMode_TypeDef SyncMode, UART2_Mode_TypeDef Mode) -{ - u8 BRR2_1, BRR2_2 = 0; - u32 BaudRate_Mantissa, BaudRate_Mantissa100 = 0; - - /* assert_param: BaudRate value should be <= 625000 bps */ - assert_param(IS_UART2_BAUDRATE_OK(BaudRate)); - - assert_param(IS_UART2_WORDLENGTH_OK(WordLength)); - - assert_param(IS_UART2_STOPBITS_OK(StopBits)); - - assert_param(IS_UART2_PARITY_OK(Parity)); - - /* assert_param: UART2_Mode value should exclude values such as UART2_ModeTx_Enable|UART2_ModeTx_Disable */ - assert_param(IS_UART2_MODE_OK((u8)Mode)); - - /* assert_param: UART2_SyncMode value should exclude values such as - UART2_CLOCK_ENABLE|UART2_CLOCK_DISABLE */ - assert_param(IS_UART2_SYNCMODE_OK((u8)SyncMode)); - - UART2->CR1 &= (u8)(~UART2_CR1_M); /**< Clear the word length bit */ - UART2->CR1 |= (u8)WordLength; /**< Set the word length bit according to UART2_WordLength value */ - - UART2->CR3 &= (u8)(~UART2_CR3_STOP); /**< Clear the STOP bits */ - UART2->CR3 |= (u8)StopBits; /**< Set the STOP bits number according to UART2_StopBits value */ - - UART2->CR1 &= (u8)(~(UART2_CR1_PCEN | UART2_CR1_PS )); /**< Clear the Parity Control bit */ - UART2->CR1 |= (u8)Parity; /**< Set the Parity Control bit to UART2_Parity value */ - - UART2->BRR1 &= (u8)(~UART2_BRR1_DIVM); /**< Clear the LSB mantissa of UARTDIV */ - UART2->BRR2 &= (u8)(~UART2_BRR2_DIVM); /**< Clear the MSB mantissa of UARTDIV */ - UART2->BRR2 &= (u8)(~UART2_BRR2_DIVF); /**< Clear the Fraction bits of UARTDIV */ - - /**< Set the UART2 BaudRates in BRR1 and BRR2 registers according to UART2_BaudRate value */ - BaudRate_Mantissa = ((u32)CLK_GetClockFreq() / (BaudRate << 4)); - BaudRate_Mantissa100 = (((u32)CLK_GetClockFreq() * 100) / (BaudRate << 4)); - /**< The fraction and MSB mantissa should be loaded in one step in the BRR2 register*/ - BRR2_1 = (u8)((u8)(((BaudRate_Mantissa100 - (BaudRate_Mantissa * 100)) - << 4) / 100) & (u8)0x0F); /**< Set the fraction of UARTDIV */ - BRR2_2 = (u8)((BaudRate_Mantissa >> 4) & (u8)0xF0); - - UART2->BRR2 = (u8)(BRR2_1 | BRR2_2); - UART2->BRR1 = (u8)BaudRate_Mantissa; /**< Set the LSB mantissa of UARTDIV */ - - UART2->CR2 &= (u8)~(UART2_CR2_TEN | UART2_CR2_REN); /**< Disable the Transmitter and Receiver before seting the LBCL, CPOL and CPHA bits */ - UART2->CR3 &= (u8)~(UART2_CR3_CPOL | UART2_CR3_CPHA | UART2_CR3_LBCL); /**< Clear the Clock Polarity, lock Phase, Last Bit Clock pulse */ - UART2->CR3 |= (u8)((u8)SyncMode & (u8)(UART2_CR3_CPOL | UART2_CR3_CPHA | UART2_CR3_LBCL)); /**< Set the Clock Polarity, lock Phase, Last Bit Clock pulse */ - - if ((u8)Mode & (u8)UART2_MODE_TX_ENABLE) - { - UART2->CR2 |= (u8)UART2_CR2_TEN; /**< Set the Transmitter Enable bit */ - } - else - { - UART2->CR2 &= (u8)(~UART2_CR2_TEN); /**< Clear the Transmitter Disable bit */ - } - if ((u8)Mode & (u8)UART2_MODE_RX_ENABLE) - { - UART2->CR2 |= (u8)UART2_CR2_REN; /**< Set the Receiver Enable bit */ - } - else - { - UART2->CR2 &= (u8)(~UART2_CR2_REN); /**< Clear the Receiver Disable bit */ - } - /**< Set the Clock Enable bit, lock Polarity, lock Phase and Last Bit Clock pulse bits according to UART2_Mode value */ - if ((u8)SyncMode&(u8)UART2_SYNCMODE_CLOCK_DISABLE) - { - UART2->CR3 &= (u8)(~UART2_CR3_CKEN); /**< Clear the Clock Enable bit */ - /**< configure in Push Pull or Open Drain mode the Tx I/O line by setting the correct I/O Port register according the product package and line configuration*/ - } - else - { - UART2->CR3 |= (u8)((u8)SyncMode & UART2_CR3_CKEN); - } -} - - -/** - * @brief Returns the most recent received data by the UART2 peripheral. - * @par Full description: - * Returns the most recent received data by the UART2 peripheral. - * @retval u16 Received Data - * @par Required preconditions: - * UART2_Cmd(ENABLE); - */ -u8 UART2_ReceiveData8(void) -{ - return ((u8)UART2->DR); -} - - -/** - * @brief Transmits 8 bit data through the UART2 peripheral. - * @par Full description: - * Transmits 8 bit data through the UART2 peripheral. - * @param[in] Data: the data to transmit. - * @retval None - * @par Required preconditions: - * UART2_Cmd(ENABLE); - */ -void UART2_SendData8(u8 Data) -{ - /* Transmit Data */ - UART2->DR = Data; -} - - -/** - * @brief Checks whether the specified UART2 flag is set or not. - * @par Full description: - * Checks whether the specified UART2 flag is set or not. - * @param[in] UART2_FLAG specifies the flag to check. - * This parameter can be any of the @ref UART2_Flag_TypeDef enumeration. - * @retval FlagStatus (SET or RESET) - */ - -FlagStatus UART2_GetFlagStatus(UART2_Flag_TypeDef UART2_FLAG) -{ - FlagStatus status = RESET; - - /* Check parameters */ - assert_param(IS_UART2_FLAG_OK(UART2_FLAG)); - - /* Check the status of the specified UART2 flag*/ - if (UART2_FLAG == UART2_FLAG_LBDF) - { - if ((UART2->CR4 & (u8)UART2_FLAG) != (u8)0x00) - { - /* UART2_FLAG is set*/ - status = SET; - } - else - { - /* UART2_FLAG is reset*/ - status = RESET; - } - } - else if (UART2_FLAG == UART2_FLAG_SBK) - { - if ((UART2->CR2 & (u8)UART2_FLAG) != (u8)0x00) - { - /* UART2_FLAG is set*/ - status = SET; - } - else - { - /* UART2_FLAG is reset*/ - status = RESET; - } - } - else if ((UART2_FLAG == UART2_FLAG_LHDF) || (UART2_FLAG == UART2_FLAG_LSF)) - { - if ((UART2->CR6 & (u8)UART2_FLAG) != (u8)0x00) - { - /* UART2_FLAG is set*/ - status = SET; - } - else - { - /* UART2_FLAG is reset*/ - status = RESET; - } - } - else - { - if ((UART2->SR & (u8)UART2_FLAG) != (u8)0x00) - { - /* UART2_FLAG is set*/ - status = SET; - } - else - { - /* UART2_FLAG is reset*/ - status = RESET; - } - } - - /* Return the UART2_FLAG status*/ - return status; -} - - -/** - * @} - */ - - -/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm8/stm8s-periphs/stm8s_uart2.h b/ports/stm8/stm8s-periphs/stm8s_uart2.h deleted file mode 100644 index 57d9b1fd..00000000 --- a/ports/stm8/stm8s-periphs/stm8s_uart2.h +++ /dev/null @@ -1,412 +0,0 @@ -/** - ******************************************************************************** - * @file stm8s_uart2.h - * @brief This file contains all functions prototypes and macros for the UART2 peripheral. - * @author STMicroelectronics - MCD Application Team - * @version V1.1.1 - * @date 06/05/2009 - ****************************************************************************** - * - * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS - * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE - * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY - * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING - * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE - * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. - * - *

© COPYRIGHT 2009 STMicroelectronics

- * @image html logo.bmp - ****************************************************************************** - */ - -/* Define to prevent recursive inclusion -------------------------------------*/ -#ifndef __STM8S_UART2_H -#define __STM8S_UART2_H - -/* Includes ------------------------------------------------------------------*/ -#include "stm8s.h" -/* Exported types ------------------------------------------------------------*/ - -/** @addtogroup UART2_Exported_Types - * @{ - */ - -/** - * @brief UART2 Irda Modes - */ - -typedef enum { UART2_IRDAMODE_NORMAL = (u8)0x00, /**< 0x00 Irda Normal Mode */ - UART2_IRDAMODE_LOWPOWER = (u8)0x01 /**< 0x01 Irda Low Power Mode */ - - } UART2_IrDAMode_TypeDef; - -/** - * @brief UART2 WakeUP Modes - */ - -typedef enum { UART2_WAKEUP_IDLELINE = (u8)0x00, /**< 0x01 Idle Line wake up */ - UART2_WAKEUP_ADDRESSMARK = (u8)0x08 /**< 0x02 Address Mark wake up */ - } UART2_WakeUp_TypeDef; - - -/** - * @brief UART2 LIN Break detection length possible values - */ -typedef enum { UART2_LINBREAKDETECTIONLENGTH_10BITS = (u8)0x00, /**< 0x01 10 bits Lin Break detection */ - UART2_LINBREAKDETECTIONLENGTH_11BITS = (u8)0x01 /**< 0x02 11 bits Lin Break detection */ - } UART2_LINBreakDetectionLength_TypeDef; - -/** - * @brief UART2 stop bits possible values - */ - -typedef enum { UART2_STOPBITS_1 = (u8)0x00, /**< One stop bit is transmitted at the end of frame*/ - UART2_STOPBITS_0_5 = (u8)0x10, /**< Half stop bits is transmitted at the end of frame*/ - UART2_STOPBITS_2 = (u8)0x20, /**< Two stop bits are transmitted at the end of frame*/ - UART2_STOPBITS_1_5 = (u8)0x30 /**< One and half stop bits*/ - } UART2_StopBits_TypeDef; - - -/** - * @brief UART2 parity possible values - */ -typedef enum { UART2_PARITY_NO = (u8)0x00, /**< No Parity*/ - UART2_PARITY_EVEN = (u8)0x04, /**< Even Parity*/ - UART2_PARITY_ODD = (u8)0x06 /**< Odd Parity*/ - } UART2_Parity_TypeDef; -/** - * @brief UART2 Mode possible values - */ -typedef enum { UART2_LIN_MODE_MASTER = (u8)0x00, /**< LIN Master Mode*/ - UART2_LIN_MODE_SLAVE = (u8)0x01 /**< LIN Slave Mode*/ - } UART2_LinMode_TypeDef; -/** - * @brief UART2 automatic resynchronisation possible values - */ -typedef enum { UART2_LIN_AUTOSYNC_DISABLE = (u8)0x00, /**< LIN Autosynchronization Disable*/ - UART2_LIN_AUTOSYNC_ENABLE = (u8)0x01 /**< LIN Autosynchronization Enable*/ - } UART2_LinAutosync_TypeDef; -/** - * @brief UART2 Divider Update Method possible values - */ -typedef enum { UART2_LIN_DIVUP_LBRR1 = (u8)0x00, /**< LIN LDIV is updated as soon as LBRR1 is written*/ - UART2_LIN_DIVUP_NEXTRXNE = (u8)0x01 /**< LIN LDIV is updated at the next received character*/ - } UART2_LinDivUp_TypeDef; - -/** - * @brief UART2 Synchrone modes - */ -typedef enum { UART2_SYNCMODE_CLOCK_DISABLE = (u8)0x80, /**< 0x80 Sync mode Disable, SLK pin Disable */ - UART2_SYNCMODE_CLOCK_ENABLE = (u8)0x08, /**< 0x08 Sync mode Enable, SLK pin Enable */ - UART2_SYNCMODE_CPOL_LOW = (u8)0x40, /**< 0x40 Steady low value on SCLK pin outside transmission window */ - UART2_SYNCMODE_CPOL_HIGH = (u8)0x04, /**< 0x04 Steady high value on SCLK pin outside transmission window */ - UART2_SYNCMODE_CPHA_MIDDLE = (u8)0x20, /**< 0x20 SCLK clock line activated in middle of data bit */ - UART2_SYNCMODE_CPHA_BEGINING = (u8)0x02, /**< 0x02 SCLK clock line activated at beginning of data bit */ - UART2_SYNCMODE_LASTBIT_DISABLE = (u8)0x10, /**< 0x10 The clock pulse of the last data bit is not output to the SCLK pin */ - UART2_SYNCMODE_LASTBIT_ENABLE = (u8)0x01 /**< 0x01 The clock pulse of the last data bit is output to the SCLK pin */ - } UART2_SyncMode_TypeDef; - -/** - * @brief UART2 Word length possible values - */ -typedef enum { UART2_WORDLENGTH_8D = (u8)0x00,/**< 0x00 8 bits Data */ - UART2_WORDLENGTH_9D = (u8)0x10 /**< 0x10 9 bits Data */ - } UART2_WordLength_TypeDef; - -/** - * @brief UART2 Mode possible values - */ -typedef enum { UART2_MODE_RX_ENABLE = (u8)0x08, /**< 0x08 Receive Enable */ - UART2_MODE_TX_ENABLE = (u8)0x04, /**< 0x04 Transmit Enable */ - UART2_MODE_TX_DISABLE = (u8)0x80, /**< 0x80 Transmit Disable */ - UART2_MODE_RX_DISABLE = (u8)0x40, /**< 0x40 Single-wire Half-duplex mode */ - UART2_MODE_TXRX_ENABLE = (u8)0x0C /**< 0x0C Transmit Enable and Receive Enable */ - } UART2_Mode_TypeDef; -/** - * @brief UART2 Flag possible values - */ -typedef enum -{ - UART2_FLAG_TXE = (u16)0x0080, /*!< Transmit Data Register Empty flag */ - UART2_FLAG_TC = (u16)0x0040, /*!< Transmission Complete flag */ - UART2_FLAG_RXNE = (u16)0x0020, /*!< Read Data Register Not Empty flag */ - UART2_FLAG_IDLE = (u16)0x0010, /*!< Idle line detected flag */ - UART2_FLAG_OR_LHE = (u16)0x0008, /*!< OverRun error flag */ - UART2_FLAG_NF = (u16)0x0004, /*!< Noise error flag */ - UART2_FLAG_FE = (u16)0x0002, /*!< Framing Error flag */ - UART2_FLAG_PE = (u16)0x0001, /*!< Parity Error flag */ - UART2_FLAG_SBK = (u16)0x0101, /**< Send Break Complete interrupt flag */ - UART2_FLAG_LBDF = (u16)0x0210, /**< LIN Break Detection Flag */ - UART2_FLAG_LHDF = (u16)0x0302, /**< LIN Header Detection Flag*/ - UART2_FLAG_LSF = (u16)0x0301 /**< LIN Sync Field Flag*/ -} UART2_Flag_TypeDef; - -/** - * @brief UART2 Interrupt definition - * UART2_IT possible values - * Elements values convention: 0xZYX - * X: Position of the corresponding Interrupt - * - For the following values, X means the interrupt position in the CR2 register. - * UART2_IT_TXE - * UART2_IT_TC - * UART2_IT_RXNE - * UART2_IT_IDLE - * UART2_IT_OR - * - For the UART2_IT_PE value, X means the flag position in the CR1 register. - * - For the UART2_IT_LBDF value, X means the flag position in the CR4 register. - * - For the UART2_IT_LHDF value, X means the flag position in the CR6 register. - * Y: Flag position - * - For the following values, Y means the flag (pending bit) position in the SR register. - * UART2_IT_TXE - * UART2_IT_TC - * UART2_IT_RXNE - * UART2_IT_IDLE - * UART2_IT_OR - * UART2_IT_PE - * - For the UART2_IT_LBDF value, Y means the flag position in the CR4 register. - * - For the UART2_IT_LHDF value, Y means the flag position in the CR6 register. - * Z: Register index: indicate in which register the dedicated interrupt source is: - * - 1==> CR1 register - * - 2==> CR2 register - * - 3==> CR4 register - * - 4==> CR6 register - */ -typedef enum { UART2_IT_TXE = (u16)0x0277, /**< Transmit interrupt */ - UART2_IT_TC = (u16)0x0266, /**< Transmission Complete interrupt */ - UART2_IT_RXNE = (u16)0x0255, /**< Data Register Not Empty interrupt */ - UART2_IT_IDLE = (u16)0x0244, /**< Idle line detected interrupt */ - UART2_IT_OR = (u16)0x0235, /**< OverRun error interrupt */ - UART2_IT_PE = (u16)0x0100, /**< Parity Error interrupt */ - UART2_IT_LBDF = (u16)0x0346, /**< LIN Break Detection interrupt */ - UART2_IT_LHDF = (u16)0x0412, /**< LIN Header Detection interrupt*/ - UART2_IT_RXNE_OR = (u16)0x0205 /*!< Receive/Overrun interrupt */ - } UART2_IT_TypeDef; - -/** - * @} - */ - -/* Exported constants --------------------------------------------------------*/ -/* Exported macros ------------------------------------------------------------*/ - -/* Private macros ------------------------------------------------------------*/ - -/** @addtogroup UART2_Private_Macros - * @{ - */ - -/** - * @brief Macro used by the assert function to check the different functions parameters. - */ - -/** - * @brief Macro used by the assert_param function in order to check the different sensitivity - * values for the MODEs possible combination should be one of the following. - */ - -#define IS_UART2_MODE_OK(Mode) \ - (((Mode) == (u8)UART2_MODE_RX_ENABLE) || \ - ((Mode) == (u8)UART2_MODE_RX_DISABLE) || \ - ((Mode) == (u8)UART2_MODE_TX_ENABLE) || \ - ((Mode) == (u8)UART2_MODE_TX_DISABLE) || \ - ((Mode) == (u8)UART2_MODE_TXRX_ENABLE) || \ - ((Mode) == (u8)((u8)UART2_MODE_TX_ENABLE|(u8)UART2_MODE_RX_ENABLE)) || \ - ((Mode) == (u8)((u8)UART2_MODE_TX_ENABLE|(u8)UART2_MODE_RX_DISABLE)) || \ - ((Mode) == (u8)((u8)UART2_MODE_TX_DISABLE|(u8)UART2_MODE_RX_DISABLE)) || \ - ((Mode) == (u8)((u8)UART2_MODE_TX_DISABLE|(u8)UART2_MODE_RX_ENABLE))) - -/** - * @brief Macro used by the assert_param function in order to check the different sensitivity values for the WordLengths - */ -#define IS_UART2_WORDLENGTH_OK(WordLength) \ - (((WordLength) == UART2_WORDLENGTH_8D) || \ - ((WordLength) == UART2_WORDLENGTH_9D)) - -/** - * @brief Macro used by the assert_param function in order to check the different sensitivity values for the SyncModes; it should exclude values such as UART2_CLOCK_ENABLE|UART2_CLOCK_DISABLE - * UART2_SyncMode value should exclude values such as UART2_CLOCK_ENABLE|UART2_CLOCK_DISABLE - */ -#define IS_UART2_SYNCMODE_OK(SyncMode) \ - (!((((SyncMode)&(((u8)UART2_SYNCMODE_CLOCK_ENABLE)|((u8)UART2_SYNCMODE_CLOCK_DISABLE))) == (((u8)UART2_SYNCMODE_CLOCK_ENABLE)|((u8)UART2_SYNCMODE_CLOCK_DISABLE))) || \ - (((SyncMode)&(((u8)UART2_SYNCMODE_CPOL_LOW )|((u8)UART2_SYNCMODE_CPOL_HIGH))) == (((u8)UART2_SYNCMODE_CPOL_LOW )|((u8)UART2_SYNCMODE_CPOL_HIGH))) || \ - (((SyncMode)&(((u8)UART2_SYNCMODE_CPHA_MIDDLE)|((u8)UART2_SYNCMODE_CPHA_BEGINING))) == (((u8)UART2_SYNCMODE_CPHA_MIDDLE)|((u8)UART2_SYNCMODE_CPHA_BEGINING))) || \ - (((SyncMode)&(((u8)UART2_SYNCMODE_LASTBIT_DISABLE)|((u8)UART2_SYNCMODE_LASTBIT_ENABLE))) == (((u8)UART2_SYNCMODE_LASTBIT_DISABLE)|((u8)UART2_SYNCMODE_LASTBIT_ENABLE))))) - -/** - * @brief Macro used by the assert_param function in order to check the different sensitivity values for the FLAGs - */ -#define IS_UART2_FLAG_OK(Flag) \ - (((Flag) == UART2_FLAG_TXE) || \ - ((Flag) == UART2_FLAG_TC) || \ - ((Flag) == UART2_FLAG_RXNE) || \ - ((Flag) == UART2_FLAG_IDLE) || \ - ((Flag) == UART2_FLAG_OR_LHE) || \ - ((Flag) == UART2_FLAG_NF) || \ - ((Flag) == UART2_FLAG_FE) || \ - ((Flag) == UART2_FLAG_PE) || \ - ((Flag) == UART2_FLAG_SBK) || \ - ((Flag) == UART2_FLAG_LSF) || \ - ((Flag) == UART2_FLAG_LHDF) || \ - ((Flag) == UART2_FLAG_LBDF)) - - -/** - * @brief Macro used by the assert_param function in order to check the different sensitivity values for the FLAGs that can be cleared by writing 0 - */ -#define IS_UART2_CLEAR_FLAG_OK(Flag) \ - (((Flag) == UART2_FLAG_RXNE) || \ - ((Flag) == UART2_FLAG_LHDF) || \ - ((Flag) == UART2_FLAG_LSF) || \ - ((Flag) == UART2_FLAG_LBDF)) - -/** - * @brief Macro used by the assert_param function in order to check the different sensitivity values for the Interrupts - */ - -#define IS_UART2_CONFIG_IT_OK(Interrupt) \ - (((Interrupt) == UART2_IT_PE) || \ - ((Interrupt) == UART2_IT_TXE) || \ - ((Interrupt) == UART2_IT_TC) || \ - ((Interrupt) == UART2_IT_RXNE_OR ) || \ - ((Interrupt) == UART2_IT_IDLE) || \ - ((Interrupt) == UART2_IT_LHDF) || \ - ((Interrupt) == UART2_IT_LBDF)) - -/** - * @brief Macro used by the assert function in order to check the different sensitivity values for the pending bit - */ -#define IS_UART2_GET_IT_OK(ITPendingBit) \ - (((ITPendingBit) == UART2_IT_TXE) || \ - ((ITPendingBit) == UART2_IT_TC) || \ - ((ITPendingBit) == UART2_IT_RXNE) || \ - ((ITPendingBit) == UART2_IT_IDLE) || \ - ((ITPendingBit) == UART2_IT_OR) || \ - ((ITPendingBit) == UART2_IT_LBDF) || \ - ((ITPendingBit) == UART2_IT_LHDF) || \ - ((ITPendingBit) == UART2_IT_PE)) - -/** - * @brief Macro used by the assert function in order to check the different sensitivity values for the pending bit that can be cleared by writing 0 - */ -#define IS_UART2_CLEAR_IT_OK(ITPendingBit) \ - (((ITPendingBit) == UART2_IT_RXNE) || \ - ((ITPendingBit) == UART2_IT_LHDF) || \ - ((ITPendingBit) == UART2_IT_LBDF)) - - -/** - * @brief Macro used by the assert_param function in order to check the different sensitivity values for the IrDAModes - */ -#define IS_UART2_IRDAMODE_OK(IrDAMode) \ - (((IrDAMode) == UART2_IRDAMODE_LOWPOWER) || \ - ((IrDAMode) == UART2_IRDAMODE_NORMAL)) - -/** - * @brief Macro used by the assert_param function in order to check the different sensitivity values for the WakeUps - */ -#define IS_UART2_WAKEUP_OK(WakeUp) \ - (((WakeUp) == UART2_WAKEUP_IDLELINE) || \ - ((WakeUp) == UART2_WAKEUP_ADDRESSMARK)) - -/** - * @brief Macro used by the assert_param function in order to check the different sensitivity values for the LINBreakDetectionLengths - */ -#define IS_UART2_LINBREAKDETECTIONLENGTH_OK(LINBreakDetectionLength) \ - (((LINBreakDetectionLength) == UART2_LINBREAKDETECTIONLENGTH_10BITS) || \ - ((LINBreakDetectionLength) == UART2_LINBREAKDETECTIONLENGTH_11BITS)) - -/** - * @brief Macro used by the assert_param function in order to check the different sensitivity values for the UART2_StopBits - */ -#define IS_UART2_STOPBITS_OK(StopBit) (((StopBit) == UART2_STOPBITS_1) || \ - ((StopBit) == UART2_STOPBITS_0_5) || \ - ((StopBit) == UART2_STOPBITS_2) || \ - ((StopBit) == UART2_STOPBITS_1_5 )) - -/** - * @brief Macro used by the assert_param function in order to check the different sensitivity values for the Paritys - */ -#define IS_UART2_PARITY_OK(Parity) (((Parity) == UART2_PARITY_NO) || \ - ((Parity) == UART2_PARITY_EVEN) || \ - ((Parity) == UART2_PARITY_ODD )) - -/** - * @brief Macro used by the assert_param function in order to check the maximum baudrate value - */ -#define IS_UART2_BAUDRATE_OK(NUM) ((NUM) <= (u32)625000) - - -/** - * @brief Macro used by the assert_param function in order to check the address of the UART2 or UART node - */ -#define UART2_ADDRESS_MAX ((u8)16) -#define IS_UART2_ADDRESS_OK(node) ((node) < UART2_ADDRESS_MAX ) - -/** - * @brief Macro used by the assert_param function in order to check the LIN mode - */ -#define IS_UART2_SLAVE_OK(Mode) \ - (((Mode) == UART2_LIN_MODE_MASTER) || \ - ((Mode) == UART2_LIN_MODE_SLAVE)) - -/** - * @brief Macro used by the assert_param function in order to check the LIN automatic resynchronization mode - */ -#define IS_UART2_AUTOSYNC_OK(AutosyncMode) \ - (((AutosyncMode) == UART2_LIN_AUTOSYNC_ENABLE) || \ - ((AutosyncMode) == UART2_LIN_AUTOSYNC_DISABLE)) - -/** - * @brief Macro used by the assert_param function in order to check the LIN divider update method - */ -#define IS_UART2_DIVUP_OK(DivupMethode) \ - (((DivupMethode) == UART2_LIN_DIVUP_LBRR1) || \ - ((DivupMethode) == UART2_LIN_DIVUP_NEXTRXNE)) - - -/** - * @} - */ - -/* Exported functions ------------------------------------------------------- */ - -/** @addtogroup UART2_Exported_Functions - * @{ - */ - -void UART2_DeInit(void); -void UART2_Init(u32 BaudRate, UART2_WordLength_TypeDef WordLength, UART2_StopBits_TypeDef StopBits, UART2_Parity_TypeDef Parity, UART2_SyncMode_TypeDef SyncMode, UART2_Mode_TypeDef Mode); -void UART2_Cmd(FunctionalState NewState); -void UART2_ITConfig(UART2_IT_TypeDef UART2_IT, FunctionalState NewState); -void UART2_HalfDuplexCmd(FunctionalState NewState); -void UART2_IrDAConfig(UART2_IrDAMode_TypeDef UART2_IrDAMode); -void UART2_IrDACmd(FunctionalState NewState); -void UART2_LINBreakDetectionConfig(UART2_LINBreakDetectionLength_TypeDef UART2_LINBreakDetectionLength); -void UART2_LINConfig(UART2_LinMode_TypeDef UART2_Mode, UART2_LinAutosync_TypeDef UART2_Autosync, UART2_LinDivUp_TypeDef UART2_DivUp); -void UART2_LINCmd(FunctionalState NewState); -void UART2_SmartCardCmd(FunctionalState NewState); -void UART2_SmartCardNACKCmd(FunctionalState NewState); -void UART2_WakeUpConfig(UART2_WakeUp_TypeDef UART2_WakeUp); -void UART2_ReceiverWakeUpCmd(FunctionalState NewState); -u8 UART2_ReceiveData8(void); -u16 UART2_ReceiveData9(void); -void UART2_SendData8(u8 Data); -void UART2_SendData9(u16 Data); -void UART2_SendBreak(void); -void UART2_SetAddress(u8 UART2_Address); -void UART2_SetGuardTime(u8 UART2_GuardTime); -void UART2_SetPrescaler(u8 UART2_Prescaler); - -FlagStatus UART2_GetFlagStatus(UART2_Flag_TypeDef UART2_FLAG); -void UART2_ClearFlag(UART2_Flag_TypeDef UART2_FLAG); -ITStatus UART2_GetITStatus(UART2_IT_TypeDef UART2_IT); -void UART2_ClearITPendingBit(UART2_IT_TypeDef UART2_IT); - - -/** - * @} - */ - -#endif /* __STM8S_UART2_H */ - -/******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/ From ecad91d2a43bff19bddb6e0e4d10a04fafe48ffd Mon Sep 17 00:00:00 2001 From: Wei Shuai Date: Sat, 26 Oct 2013 21:52:19 +0800 Subject: [PATCH 03/28] add STM8L standard peripheral drivers V1.6.0 --- .../Release_Notes.html | 166 + .../STM8L15x_StdPeriph_Driver/inc/stm8l15x.h | 3024 +++++++++++++++++ .../inc/stm8l15x_adc.h | 383 +++ .../inc/stm8l15x_aes.h | 155 + .../inc/stm8l15x_beep.h | 114 + .../inc/stm8l15x_clk.h | 441 +++ .../inc/stm8l15x_comp.h | 239 ++ .../inc/stm8l15x_dac.h | 290 ++ .../inc/stm8l15x_dma.h | 338 ++ .../inc/stm8l15x_exti.h | 285 ++ .../inc/stm8l15x_flash.h | 356 ++ .../inc/stm8l15x_gpio.h | 176 + .../inc/stm8l15x_i2c.h | 806 +++++ .../inc/stm8l15x_irtim.h | 65 + .../inc/stm8l15x_itc.h | 269 ++ .../inc/stm8l15x_iwdg.h | 137 + .../inc/stm8l15x_lcd.h | 470 +++ .../inc/stm8l15x_pwr.h | 128 + .../inc/stm8l15x_rst.h | 88 + .../inc/stm8l15x_rtc.h | 953 ++++++ .../inc/stm8l15x_spi.h | 401 +++ .../inc/stm8l15x_syscfg.h | 421 +++ .../inc/stm8l15x_tim1.h | 1041 ++++++ .../inc/stm8l15x_tim2.h | 902 +++++ .../inc/stm8l15x_tim3.h | 906 +++++ .../inc/stm8l15x_tim4.h | 371 ++ .../inc/stm8l15x_tim5.h | 768 +++++ .../inc/stm8l15x_usart.h | 390 +++ .../inc/stm8l15x_wfe.h | 151 + .../inc/stm8l15x_wwdg.h | 93 + .../src/stm8l15x_adc.c | 985 ++++++ .../src/stm8l15x_aes.c | 485 +++ .../src/stm8l15x_beep.c | 244 ++ .../src/stm8l15x_clk.c | 1120 ++++++ .../src/stm8l15x_comp.c | 725 ++++ .../src/stm8l15x_dac.c | 836 +++++ .../src/stm8l15x_dma.c | 750 ++++ .../src/stm8l15x_exti.c | 556 +++ .../src/stm8l15x_flash.c | 914 +++++ .../src/stm8l15x_gpio.c | 407 +++ .../src/stm8l15x_i2c.c | 1366 ++++++++ .../src/stm8l15x_irtim.c | 196 ++ .../src/stm8l15x_itc.c | 390 +++ .../src/stm8l15x_iwdg.c | 217 ++ .../src/stm8l15x_lcd.c | 629 ++++ .../src/stm8l15x_pwr.c | 355 ++ .../src/stm8l15x_rst.c | 169 + .../src/stm8l15x_rtc.c | 2242 ++++++++++++ .../src/stm8l15x_spi.c | 791 +++++ .../src/stm8l15x_syscfg.c | 504 +++ .../src/stm8l15x_tim1.c | 2771 +++++++++++++++ .../src/stm8l15x_tim2.c | 2151 ++++++++++++ .../src/stm8l15x_tim3.c | 2151 ++++++++++++ .../src/stm8l15x_tim4.c | 759 +++++ .../src/stm8l15x_tim5.c | 2151 ++++++++++++ .../src/stm8l15x_usart.c | 1205 +++++++ .../src/stm8l15x_wfe.c | 345 ++ .../src/stm8l15x_wwdg.c | 244 ++ ...5x-16x-05x_al31-l_stdperiph_drivers_um.chm | Bin 0 -> 5257265 bytes 59 files changed, 39985 insertions(+) create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/Release_Notes.html create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_adc.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_aes.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_beep.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_clk.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_comp.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_dac.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_dma.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_exti.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_flash.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_gpio.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_i2c.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_irtim.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_itc.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_iwdg.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_lcd.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_pwr.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_rst.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_rtc.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_spi.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_syscfg.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_tim1.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_tim2.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_tim3.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_tim4.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_tim5.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_usart.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_wfe.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_wwdg.h create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_adc.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_aes.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_beep.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_clk.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_comp.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_dac.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_dma.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_exti.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_flash.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_gpio.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_i2c.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_irtim.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_itc.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_iwdg.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_lcd.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_pwr.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_rst.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_rtc.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_spi.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_syscfg.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_tim1.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_tim2.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_tim3.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_tim4.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_tim5.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_usart.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_wfe.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/src/stm8l15x_wwdg.c create mode 100644 ports/stm8/STM8L15x_StdPeriph_Driver/stm8l15x-16x-05x_al31-l_stdperiph_drivers_um.chm diff --git a/ports/stm8/STM8L15x_StdPeriph_Driver/Release_Notes.html b/ports/stm8/STM8L15x_StdPeriph_Driver/Release_Notes.html new file mode 100644 index 00000000..2c1efcff --- /dev/null +++ b/ports/stm8/STM8L15x_StdPeriph_Driver/Release_Notes.html @@ -0,0 +1,166 @@ + + + + + + +Release Notes for STM8L15x Standard Peripherals Library Drivers + + + + + +
+


+

+
+ + + + + + +
+ + + + + + + + + +
Back to Release page
+

Release +Notes for STM8L15x/16x/05x/AL31_L Standard Peripherals Library Drivers +(StdPeriph_Driver)

+

Copyright 2013 STMicroelectronics

+

+
+

 

+ + + + + + +
+

Contents

+
    +
  1. STM8L15x/16x/05x/AL31_L Standard Peripherals Library +Drivers update History
  2. +
  3. License
  4. +
+ + +

STM8L15x/16x/05x/AL31_L Standard +Peripherals Library Drivers  update History

+

V1.6.0 / 28-June-2013

Main +Changes

+
  • Add the support of STM8L05x Value Line and the STM8AL products devices
  • Update files header with new license disclaimer.
  • stm8l15x.h
    • Add "#define STM8L05X_LD_VL" for STM8L051x3 Low Density Value Line devices
    • Add "#define STM8L05X_MD_VL" for STM8L052x6 Medium Density Value Line devices
    • Add "#define STM8L05X_HD_VL" for STM8L052x8 High Density Value Line devices
    • Add "#define STM8AL31_L_MD" for STM8AL3x Medium Density devices
    • Replace "__RCST7__" by "__RCSTM8__"
    • Add " MemoryAddressCast" define to manage the address cast within the STM8L family.
    • Replace "#include <intrist7.h>" by "#include <intrins.h>"
  • stm8l15x_usart.c/.h
    • Update "USART_ClearITPendingBit()" function and parameter list.
  • stm8l15x_flash.c/.h
    • Update to add the support of the STM8L05x Value Line and the STM8AL products devices
    • Fix memory address cast in the following functions: FALSH_ProgramBlock(), FALSH_ProgramByte(), FALSH_ProgramWord(), FALSH_EraseByte() and FALSH_ReadByte().
  • stm8l15x_itc.c/.h
    • Update to add the support of the STM8L05x Value Line and the STM8AL products devices

V1.5.0 / 13-May-2011

Main +Changes

+
  • Add support of STM8L15x Low Density devices
  • Overall peripheral drivers source +code updated to group functions by lists related to peripheral +features and to add more comments on how to use the API(steps +preconditions and Hints)
  • stm8l15x.h
    • Replace __CONST define by CONST
    • Update function execution from RAM handling
    • Update STM8L15x Standard Peripheral Library main version defines
    • Update RI_Structure to support STM8L15x Low Density devices
    • Update interrupts macro definitions for IAR compiler
  • stm8l15x_clk.c
    • Replace __CONST by CONST in the SYSDivFactor declaration
  • stm8l15x_dac.c/.h
    • Rename DAC_TriangleWaveAmplitude() function to DAC_SetTriangleWaveAmplitude()
    • Rename DAC_NoiseWaveLFSR() function to DAC_SetNoiseWaveLFSR()
  • stm8l15x_rtc.c
    •  RTC +write protection management updated in RTC_DeInit(), RTC_Init(), +RTC_RatioCmd(), RTC_BypassShadowCmd(), RTC_SetTime(), RTC_SetDate(), +RTC_SetAlarm(), RTC_AlarmCmd(), RTC_WakeUpClockConfig(), +RTC_WakeUpCmd() and  RTC_OutputConfig() functions
    • RTC_WaitForSynchro() function updated by adding the write protection management
    • RTC_GetTime(), RTC_GetSubSecond(), RTC_GetDate() functions updated by removing the clear of RSF bit

1.4.0 +- 09/24/2010

+
  1. General  
  • Add support of High Density and  Medium Density Plus  devices.
  • New drivers added for AES and TIM5
  1. STM8L15x_StdPeriph_Driver
+
  • stm8l15x.h  updated to  support High Density and Medium Density Plus  devices
    • Add definition for STM8L15x Medium Density, Medium Density Plus and High Density devices
    • Add "error" directive to force device family choice
    • Add EEPROM definition in compiler defines (COSMIC, RAISONANCE, IAR)
    • Add MEMCPY definition per devices family in RAISONANCE compiler defines
    • Add function execution from RAM handling defines:
       change

       #define USE_COSMIC_SECTIONS  (1)
       by
       #define COSMIC_RAM_EXECUTION  (1) for Cosmic compiler 
    • Add new Medium Density Plus and High Density devices peripheral definition(AES, CSS on LSE, GPIO G/H/I,  SPI2, TIM5, USART2/3)
    • Update Peripheral registers declaration with Medium Density Plus and High Density devices new features
    • IAR interrupt vector handling macro definition update:
        change
        #define STRINGIZE_AUX(x) #x
        #define STRINGIZE(x) STRINGIZE_AUX( vector = (x) )
        #define INTERRUPT_HANDLER( a, b )  \
          _Pragma( STRINGIZE( (b)+2 ) )   \
          __interrupt void (a)( void )
        #define INTERRUPT_HANDLER_TRAP(a) \
          _Pragma( STRINGIZE( 1 ) ) \
          __interrupt void (a) (void)
       
        by
         #define STRINGVECTOR(x) #x
         #define VECTOR_ID(x) STRINGVECTOR( vector = (x) )
         #define INTERRUPT_HANDLER( a, b )  \
          _Pragma( VECTOR_ID( (b)+2 ) )        \
          __interrupt void (a)( void )
         #define INTERRUPT_HANDLER_TRAP(a) \
          _Pragma( VECTOR_ID( 1 ) ) \
          __interrupt void (a) (void) 
    • "INTERRUPT"  added to manage interrupt handler declaration for IAR and Cosmic Compilers
  • stm8l15x_adc.h: updated to support channels 25, 26 and 27
  • stm8l15x_clk.h/.c: updated to support added peripherals: AES, CSSLSE, SPI2, TIM5, USART2 and USART3
    • New functions added:
       CLK_ClockSecuritySytemDeglitchCmd()
       CLK_ClearFlag()
       CLK_LSEClockSecuritySystemEnable()
       CLK_RTCCLKSwitchOnLSEFailureEnable()
  • stm8l15x_comp.c: COMP_TriggerConfig() function updated 
  • stm8l15x_dac.h/.c: updated to support DAC channel2, Wave, noise and triangle signals generation
    • DAC_Trigger_T5_TRGO and DAC_Trigger_Ext added in DAC_Trigger_TypeDef
    • DAC_Channel_2 added in DAC_Channel_TypeDef
    • New functions added:
       DAC_WaveGenerationCmd()
       DAC_NoiseWaveLFSR()
       DAC_TriangleWaveAmplitude()
       DAC_SetChannel2Data()
       DAC_DualSoftwareTriggerCmd()
       DAC_SetDualChannelData()
  • stm8l15x_dma.h/.c: updated to support DMA channel 3
    • New function added : DMA_SetCurrDataCounter()
  • stm8l15x_exti.h/.c: updated to support new added ports (PG, PH, PI)
    • EXTI_GetHalfPortSelection() function removed
    • New function added EXTI_SelectPort()
  • stm8l15x_flash.h/.c: updated to support High Density devices
    • Add +detailed description of execution from RAM using functions +provided by this driver and with the different supported toolchains. +For more information, refer to stm8l15x_flash.h and stm8l15x_flash.c files.
  • stm8l15x_i2c.h/.c: updated to support dual addressing mode
    • New functions added:
       I2C_OwnAddress2Config()
       I2C_DualAddressCmd()
       I2C_ReadRegister()
  • stm8l15x_itc.h/.c: updated to support High Density and  Medium Density Plus devices peripheral IRQ.
  • stm8l15x_lcd.h/.c: updated to support new LCD features:
    • LCD_Duty_1_8  added in LCD_Duty_TypeDef
    • LCD_Bias_1_4 added in LCD_Bias_TypeDef
    • LCD_PortMaskRegister_4 and LCD_PortMaskRegister_5 added in LCD_PortMaskRegister_TypeDef
    • Added in LCD_RAMRegister_TypeDef
       LCD_RAMRegister_14
       LCD_RAMRegister_15
       LCD_RAMRegister_16
       LCD_RAMRegister_17
       LCD_RAMRegister_18
       LCD_RAMRegister_19
       LCD_RAMRegister_20
       LCD_RAMRegister_21
    • New function added : LCD_PageSelect()
  • stm8l15x_rtc.h/.c : updated to support new RTC features: Calibration, Synchronization, tamper and subseconds
    • New functions added:
       RTC_CalibOutputConfig()
       RTC_TamperFilterConfig()
       RTC_TamperSamplingFreqConfig()
       RTC_TamperPinsPrechargeDuration()
       RTC_TamperLevelConfig()
       RTC_TamperCmd()
       RTC_SynchroShiftConfig()
       RTC_SmoothCalibConfig()
       RTC_AlarmStructInit()
       RTC_AlarmSubSecondConfig()
       RTC_GetSubSecond()
       RTC_DateStructInit()
       RTC_TimeStructInit()
       RTC_BypassShadowCmd()
  • stm8l15x_syscfg.h/.c: updated to support High Density and Medium Density Plus devices
    • RI_InputCaptureRouting_1 and RI_InputCaptureRouting_2 added in RI_InputCaptureRouting_TypeDef
    • Added in RI_AnalogSwitch_TypeDef
       RI_AnalogSwitch_9
       RI_AnalogSwitch_10
       RI_AnalogSwitch_11
    • Added in REMAP_Pin_TypeDef
       REMAP_Pin_USART1Clk
       REMAP_Pin_TIM2TRIGPortA
       REMAP_Pin_TIM3TRIGPortA
       REMAP_Pin_TIM2TRIGLSE
       REMAP_Pin_TIM3TRIGLSE
       REMAP_Pin_SPI2Full
       REMAP_Pin_TIM3TRIGPortG
       REMAP_Pin_TIM23BKIN
       REMAP_Pin_SPI1PortF
       REMAP_Pin_USART3TxRxPortF
       REMAP_Pin_USART3Clk
       REMAP_Pin_TIM3Channel1
       REMAP_Pin_TIM3Channel2
       REMAP_Pin_CCO
    • Update functions: SYSCFG_REMAPDeInit() and SYSCFG_REMAPPinConfig()
  • stm8l15x_wfe.h/.c: updated to support added peripherals and Ports: AES, CSSLSE, SPI2, TIM5, USART2 and USART3


1.3.0 +- 07/14/2010

+
  1. STM8L15x_StdPeriph_Driver
+
  • stm8l15x.h file updated to support  IAR Embedded Workbench for +STM8 (EWSTM8) toolchain specific declarations
    • "INTERRUPT_HANDLER" macro added to manage interrupt vector declarations for all supported toochains.
  • stm8l15x_flash.h file updated to  add  FLASH_RASS_KEY1  definition

1.2.0 +- 05/14/2010

+
    +
  1. STM8L15x_StdPeriph_Driver
  2. +
+
    +
  • stm8l15x.h file updated to support BootROM bit mask in CLK_PCKENR2 register
  • +
  • CLK driver stm8l15x_clk.h: add support for BootROM bit in CLK_PCKENR2.
  • +
  • COMP driver stm8l15x_comp.h: COMP_InvertingInput_DAC renamed to COMP_InvertingInput_DAC1.
  • +
  • DMA driver stm8l15x_dma.h : IS_DMA_CHANNEL macro updated
  • +
  • I2C driver stm8l15x_i2c.h/.c: I2C events description and management enhancement.
    • Add +detailed description of I2C events and how to manage them using the +functions provided by this driver. For more information, refer to +stm8l15x_i2c.h and stm8l15x_i2c.c files.
    +
+

License

censed +under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use +this package +except in compliance with the License. You may obtain a copy of the License +at:

+
Unless +required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the +License.
+
+

For complete documentation on + STM8L15x/16x 8-bit microcontrollers platform visit www.st.com
+

+
+

+
+
+

 

+
+ \ No newline at end of file diff --git a/ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x.h b/ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x.h new file mode 100644 index 00000000..3b7b77d7 --- /dev/null +++ b/ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x.h @@ -0,0 +1,3024 @@ +/** + ****************************************************************************** + * @file stm8l15x.h + * @author MCD Application Team + * @version V1.6.0 + * @date 28-June-2013 + * @brief This file contains all the peripheral register's definitions, bits + * definitions and memory mapping for STM8L15x devices. + ****************************************************************************** + * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM8L15x_H + #define __STM8L15x_H + +/** @addtogroup STM8L15x_StdPeriph_Driver + * @{ + */ +/* Uncomment the line below according to the target STM8L15x device used in your + application + */ +/* #define STM8L15X_LD */ /*!< STM8L15X_LD: STM8L15x Low density devices */ +/* #define STM8L15X_MD */ /*!< STM8L15X_MD: STM8L15x Medium density devices */ +/* #define STM8L15X_MDP */ /*!< STM8L15X_MDP: STM8L15x Medium density plus devices */ +/* #define STM8L15X_HD */ /*!< STM8L15X_HD: STM8L15x/16x High density devices */ +/* #define STM8L05X_LD_VL */ /*!< STM8L05X_LD_VL: STM8L051xx3 Low density value line devices */ +/* #define STM8L05X_MD_VL */ /*!< STM8L05X_MD_VL: STM8L052xx6 Medium density value line devices */ +/* #define STM8L05X_HD_VL */ /*!< STM8L05X_HD_VL: STM8L052xx8 High density value line devices */ +/* #define STM8AL31_L_MD */ /*!< STM8AL31_L_MD: STM8AL3x Medium density devices */ + + +/* Tip: To avoid modifying this file each time you need to switch between these + devices, you can define the device in your toolchain compiler preprocessor. + + - Low density STM8L15x devices are STM8L151C3, STM8L151K3, STM8L151G3, STM8L151F3, + STM8L151C2, STM8L151K2, STM8L151G2 and STM8L151F2 microcontrollers where the + Flash memory density ranges between 4 and 8 Kbytes. + - Medium density STM8L15x devices are STM8L151C4, STM8L151C6, STM8L152C4, + STM8L152C6, STM8L151K4, STM8L151K6, STM8L152K4, STM8L152K6, STM8L151G4, + STM8L151G6, STM8L152G4 and STM8L152G6 microcontrollers where the Flash memory + density ranges between 16 and 32 Kbytes. + - Medium density Plus devices are STM8L151R6, STM8L152R6 microcontrollers where + the Flash memory density is fixed and equal to 32 Kbytes and a wider range of + peripheral than the medium density devices. + - High density STM8L15x devices are STM8L151x8, STM8L152x8, STM8L162R8 and STM8L162M8 + microcontrollers where the Flash memory density is fixed and equal to 64 Kbytes with + the same peripheral set than Medium Density Plus devices. + - Value line low density STM8L05xx devices are STM8L051x3 microcontrollers + with 8-KB Flash + - Value line medium density STM8L05xx devices are STM8L052x6 microcontrollers + with 32-KB Flash + - Value line high density STM8L05xx devices: STM8L052x8 microcontrollers + with 64-KB Flash + - Medium density STM8AL31xx/STM8AL3Lxx devices: STM8AL3168, STM8AL3166, + STM8AL3148,STM8AL3146, STM8AL3138, STM8AL3136, STM8AL3L68, STM8AL3L66, + STM8AL3L48, STM8AL3L46 microcontrollers with 8-KB, 16-KB or 32-KB Flash + */ + +#if !defined (STM8L15X_MD) && !defined (STM8L15X_MDP) && !defined (STM8L15X_HD) && !defined (STM8L15X_LD) \ +&& !defined (STM8L05X_LD_VL) && !defined (STM8L05X_MD_VL) && !defined (STM8L05X_HD_VL) && !defined (STM8AL31_L_MD) + #error "Please select first the target STM8L device used in your application (in stm8l15x.h file)" +#endif + +/******************************************************************************/ +/* Library configuration section */ +/******************************************************************************/ +/* Check the used compiler */ +#if defined(__CSMC__) + #define _COSMIC_ +#elif defined(__RCSTM8__) + #define _RAISONANCE_ +#elif defined(__ICCSTM8__) + #define _IAR_ +#else + #error "Unsupported Compiler!" /* Compiler defines not found */ +#endif + +#if !defined USE_STDPERIPH_DRIVER +/* Comment the line below if you will not use the peripherals drivers. + In this case, these drivers will not be included and the application code will be + based on direct access to peripherals registers */ + #define USE_STDPERIPH_DRIVER +#endif + +/** + * @brief In the following line adjust the value of External High Speed oscillator (HSE) + used in your application + + Tip: To avoid modifying this file each time you need to use different HSE, you + can define the HSE value in your toolchain compiler preprocessor. + */ +#if !defined HSE_VALUE + #define HSE_VALUE ((uint32_t)16000000) /*!< Typical Value of the HSE in Hz */ +#endif /* HSE_VALUE */ + +/** + * @brief Definition of External Low Speed oscillator (LSE) frequency + */ +#if !defined LSE_VALUE + #define LSE_VALUE ((uint32_t)32768) /*!< Typical Value of the LSE in Hz */ +#endif /* LSE_VALUE */ +/** + * @brief Definition of Device on-chip RC oscillator frequencies + */ +#if !defined HSI_VALUE + #define HSI_VALUE ((uint32_t)16000000) /*!< Typical Value of the HSI in Hz */ +#endif /* HSI_VALUE */ + +#if !defined LSI_VALUE + #define LSI_VALUE ((uint32_t)38000) /*!< Typical Value of the LSI in Hz */ +#endif /* LSI_VALUE */ + +#ifdef _COSMIC_ + #define FAR @far + #define NEAR @near + #define TINY @tiny + #define EEPROM @eeprom + #define CONST const +#elif defined (_RAISONANCE_) /* __RCSTM8__ */ + #define FAR far + #define NEAR data + #define TINY page0 + #define EEPROM eeprom + #define CONST code + #if defined (STM8L15X_MD) || defined (STM8L15X_MDP) || defined (STM8L05X_MD_VL) || \ + defined (STM8AL31_L_MD) + /*!< Used with memory Models for code less than 64K */ + #define MEMCPY memcpy + #elif defined (STM8L15X_HD) || defined (STM8L05X_HD_VL) + /*!< Used with memory Models for code higher than 64K */ + #define MEMCPY fmemcpy + #endif /* STM8L15X_MD or STM8L15X_MDP or STM8L05X_MD_VL or STM8AL31_L_MD*/ +#else /*_IAR_*/ + #define FAR __far + #define NEAR __near + #define TINY __tiny + #define EEPROM __eeprom + #define CONST const +#endif /* __CSMC__ */ + +/** + * @brief Legacy definition + */ +#define __CONST CONST + +#if defined (STM8L15X_MD) || defined (STM8L15X_MDP) || defined (STM8L15X_LD) || \ +defined (STM8L05X_LD_VL) || defined (STM8L05X_MD_VL) || defined (STM8AL31_L_MD) +/*!< Used with memory Models for code smaller than 64K */ + #define PointerAttr NEAR + #define MemoryAddressCast uint16_t +#elif defined (STM8L15X_HD) || defined (STM8L05X_HD_VL) +/*!< Used with memory Models for code higher than 64K */ + #define PointerAttr FAR + #define MemoryAddressCast uint32_t +#endif /* STM8L15X_MD or STM8L15X_MDP or STM8L15X_LD or STM8L05X_LD_VL or STM8L05X_MD_VL + or STM8AL31_L_MD */ + +/* Uncomment the line below to enable the FLASH functions execution from RAM */ +#if !defined (RAM_EXECUTION) +/* #define RAM_EXECUTION (1) */ +#endif /* RAM_EXECUTION */ + +#ifdef RAM_EXECUTION + #ifdef _COSMIC_ + #define IN_RAM(a) a + #elif defined (_RAISONANCE_) /* __RCSTM8__ */ + #define IN_RAM(a) a inram + #else /*_IAR_*/ + #define IN_RAM(a) __ramfunc a + #endif /* _COSMIC_ */ +#else + #define IN_RAM(a) a +#endif /* RAM_EXECUTION */ + +/*!< [31:16] STM8L15X Standard Peripheral Library main version */ +#define __STM8L15X_STDPERIPH_VERSION_MAIN ((uint8_t)0x01) /*!< [31:24] main version */ +#define __STM8L15X_STDPERIPH_VERSION_SUB1 ((uint8_t)0x06) /*!< [23:16] sub1 version */ +#define __STM8L15X_STDPERIPH_VERSION_SUB2 ((uint8_t)0x00) /*!< [15:8] sub2 version */ +#define __STM8L15X_STDPERIPH_VERSION_RC ((uint8_t)0x00) /*!< [7:0] release candidate */ +#define __STM8L15X_STDPERIPH_VERSION ( (__STM8L15X_STDPERIPH_VERSION_MAIN << 24)\ + |(__STM8L15X_STDPERIPH_VERSION_SUB1 << 16)\ + |(__STM8L15X_STDPERIPH_VERSION_SUB2 << 8)\ + |(__STM8L15X_STDPERIPH_VERSION_RC)) + +/******************************************************************************/ + +/* Includes ------------------------------------------------------------------*/ + +/* Exported types and constants ----------------------------------------------*/ + +/** @addtogroup Exported_types + * @{ + */ + +/** + * IO definitions + * + * define access restrictions to peripheral registers + */ +#define __I volatile const /*!< defines 'read only' permissions */ +#define __O volatile /*!< defines 'write only' permissions */ +#define __IO volatile /*!< defines 'read / write' permissions */ + +/*!< Signed integer types */ +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed long int32_t; + +/*!< Unsigned integer types */ +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned long uint32_t; + +/*!< STM8Lx Standard Peripheral Library old types (maintained for legacy purpose) */ + +typedef int32_t s32; +typedef int16_t s16; +typedef int8_t s8; + +typedef uint32_t u32; +typedef uint16_t u16; +typedef uint8_t u8; + + +typedef enum {FALSE = 0, TRUE = !FALSE} bool; + +typedef enum {RESET = 0, SET = !RESET} FlagStatus, ITStatus, BitStatus, BitAction; + +typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState; +#define IS_FUNCTIONAL_STATE(STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE)) + +typedef enum {ERROR = 0, SUCCESS = !ERROR} ErrorStatus; + +#define U8_MAX (255) +#define S8_MAX (127) +#define S8_MIN (-128) +#define U16_MAX (65535u) +#define S16_MAX (32767) +#define S16_MIN (-32768) +#define U32_MAX (4294967295uL) +#define S32_MAX (2147483647) +#define S32_MIN (-2147483648uL) + +/** + * @} + */ + +/** @addtogroup MAP_FILE_Exported_Types_and_Constants + * @{ + */ + +/******************************************************************************/ +/* IP registers structures */ +/******************************************************************************/ + +/*----------------------------------------------------------------------------*/ +/** + * @brief General Purpose I/Os (GPIO) + */ +typedef struct GPIO_struct +{ + __IO uint8_t ODR; /*!< Output Data Register */ + __IO uint8_t IDR; /*!< Input Data Register */ + __IO uint8_t DDR; /*!< Data Direction Register */ + __IO uint8_t CR1; /*!< Configuration Register 1 */ + __IO uint8_t CR2; /*!< Configuration Register 2 */ +} +GPIO_TypeDef; + +/** @addtogroup GPIO_Registers_Reset_Value + * @{ + */ +#define GPIO_ODR_RESET_VALUE ((uint8_t)0x00) +#define GPIO_DDR_RESET_VALUE ((uint8_t)0x00) +#define GPIO_CR1_RESET_VALUE ((uint8_t)0x00) +#define GPIO_CR2_RESET_VALUE ((uint8_t)0x00) +/** + * @} + */ +/*----------------------------------------------------------------------------*/ + +/** + * @brief Real-Time Clock (RTC) peripheral registers. + */ +typedef struct RTC_struct +{ + __IO uint8_t TR1; /*!< Time Register 1*/ + __IO uint8_t TR2; /*!< Time Register 2*/ + __IO uint8_t TR3; /*!< Time Register 3*/ + + uint8_t RESERVED0; + + __IO uint8_t DR1; /*!< Date Register 1*/ + __IO uint8_t DR2; /*!< Date Register 2*/ + __IO uint8_t DR3; /*!< Date Register 3*/ + + uint8_t RESERVED1; + + __IO uint8_t CR1; /*!< Control Register 1*/ + __IO uint8_t CR2; /*!< Control Register 2*/ + __IO uint8_t CR3; /*!< Control Register 3*/ + + uint8_t RESERVED2; + + __IO uint8_t ISR1; /*!< Initialisation and Status Register 1 */ + __IO uint8_t ISR2; /*!< Initialisation and Status Register 2 */ + + uint8_t RESERVED3; + uint8_t RESERVED4; + + __IO uint8_t SPRERH; /*!< Synchronous Prediv high Register */ + __IO uint8_t SPRERL; /*!< Synchronous Prediv Low Register */ + __IO uint8_t APRER; /*!< Asynchronous Prediv Register */ + + uint8_t RESERVED5; + + __IO uint8_t WUTRH; /*!< Wake-Up Timer High Register */ + __IO uint8_t WUTRL; /*!< Wake-Up Timer Low Register */ + + uint8_t RESERVED6; + + __IO uint8_t SSRH; /*!< Sub Second High Register */ + __IO uint8_t SSRL; /*!< Sub Second Low Register */ + + __IO uint8_t WPR; /*!< Write Protection Register */ + + __IO uint8_t SHIFTRH; /*!< Shift control High Register */ + __IO uint8_t SHIFTRL; /*!< Shift control Low Register */ + + __IO uint8_t ALRMAR1; /*!< ALARM A Register 1 */ + __IO uint8_t ALRMAR2; /*!< ALARM A Register 2 */ + __IO uint8_t ALRMAR3; /*!< ALARM A Register 3 */ + __IO uint8_t ALRMAR4; /*!< ALARM A Register 4 */ + + uint8_t RESERVED7[4]; + + __IO uint8_t ALRMASSRH; /*!< ALARM A Subsecond Register High */ + __IO uint8_t ALRMASSRL; /*!< ALARM A Subsecond Register Low */ + __IO uint8_t ALRMASSMSKR; /*!< ALARM A Subsecond Mask Register */ + + uint8_t RESERVED8[3]; + + __IO uint8_t CALRH; /*!< Calibration register high */ + __IO uint8_t CALRL; /*!< Calibration register low */ + + __IO uint8_t TCR1; /*!< Tamper control register 1 */ + __IO uint8_t TCR2; /*!< Tamper control register 2 */ +} +RTC_TypeDef; + +/** @addtogroup RTC_Registers_Reset_Value + * @{ + */ +#define RTC_TR1_RESET_VALUE ((uint8_t)0x00) +#define RTC_TR2_RESET_VALUE ((uint8_t)0x00) +#define RTC_TR3_RESET_VALUE ((uint8_t)0x00) + +#define RTC_DR1_RESET_VALUE ((uint8_t)0x01) +#define RTC_DR2_RESET_VALUE ((uint8_t)0x21) +#define RTC_DR3_RESET_VALUE ((uint8_t)0x00) + +#define RTC_CR1_RESET_VALUE ((uint8_t)0x00) +#define RTC_CR2_RESET_VALUE ((uint8_t)0x00) +#define RTC_CR3_RESET_VALUE ((uint8_t)0x00) + +#define RTC_ISR1_RESET_VALUE ((uint8_t)0x07) +#define RTC_ISR2_RESET_VALUE ((uint8_t)0x00) + +#define RTC_SPRERH_RESET_VALUE ((uint8_t)0x00) +#define RTC_SPRERL_RESET_VALUE ((uint8_t)0xFF) +#define RTC_APRER_RESET_VALUE ((uint8_t)0x7F) + +#define RTC_WUTRH_RESET_VALUE ((uint8_t)0xFF) +#define RTC_WUTRL_RESET_VALUE ((uint8_t)0xFF) + +#define RTC_WPR_RESET_VALUE ((uint8_t)0x00) + +#define RTC_ALRMAR1_RESET_VALUE ((uint8_t)0x00) +#define RTC_ALRMAR2_RESET_VALUE ((uint8_t)0x00) +#define RTC_ALRMAR3_RESET_VALUE ((uint8_t)0x00) +#define RTC_ALRMAR4_RESET_VALUE ((uint8_t)0x00) + +#define RTC_SHIFTRH_RESET_VALUE ((uint8_t)0x00) +#define RTC_SHIFTRL_RESET_VALUE ((uint8_t)0x00) + +#define RTC_ALRMASSRH_RESET_VALUE ((uint8_t)0x00) +#define RTC_ALRMASSRL_RESET_VALUE ((uint8_t)0x00) +#define RTC_ALRMASSMSKR_RESET_VALUE ((uint8_t)0x00) + +#define RTC_CALRH_RESET_VALUE ((uint8_t)0x00) +#define RTC_CALRL_RESET_VALUE ((uint8_t)0x00) + +#define RTC_TCR1_RESET_VALUE ((uint8_t)0x00) +#define RTC_TCR2_RESET_VALUE ((uint8_t)0x00) + +/** + * @} + */ + +/** @addtogroup RTC_Registers_Bits_Definition + * @{ + */ + +/* Bits definition for RTC_TR1 register*/ +#define RTC_TR1_ST ((uint8_t)0x70) +#define RTC_TR1_SU ((uint8_t)0x0F) + +/* Bits definition for RTC_TR2 register*/ +#define RTC_TR2_MNT ((uint8_t)0x70) +#define RTC_TR2_MNU ((uint8_t)0x0F) + +/* Bits definition for RTC_TR3 register*/ +#define RTC_TR3_PM ((uint8_t)0x40) +#define RTC_TR3_HT ((uint8_t)0x30) +#define RTC_TR3_HU ((uint8_t)0x0F) + +/* Bits definition for RTC_DR1 register*/ +#define RTC_DR1_DT ((uint8_t)0x30) +#define RTC_DR1_DU ((uint8_t)0x0F) + +/* Bits definition for RTC_DR2 register*/ +#define RTC_DR2_WDU ((uint8_t)0xE0) +#define RTC_DR2_MT ((uint8_t)0x10) +#define RTC_DR2_MU ((uint8_t)0x0F) + +/* Bits definition for RTC_DR3 register*/ +#define RTC_DR3_YT ((uint8_t)0xF0) +#define RTC_DR3_YU ((uint8_t)0x0F) + +/* Bits definition for RTC_CR1 register*/ +#define RTC_CR1_FMT ((uint8_t)0x40) +#define RTC_CR1_RATIO ((uint8_t)0x20) +#define RTC_CR1_WUCKSEL ((uint8_t)0x07) +#define RTC_CR1_BYPSHAD ((uint8_t)0x10) + + +/* Bits definition for RTC_CR2 register*/ +#define RTC_CR2_WUTIE ((uint8_t)0x40) +#define RTC_CR2_ALRAIE ((uint8_t)0x10) +#define RTC_CR2_WUTE ((uint8_t)0x04) +#define RTC_CR2_ALRAE ((uint8_t)0x01) +#define RTC_CR2_ALRIE ((uint8_t)0x20) + + + +/* Bits definition for RTC_CR3 register*/ +#define RTC_CR3_COE ((uint8_t)0x80) +#define RTC_CR3_OSEL ((uint8_t)0x60) +#define RTC_CR3_POL ((uint8_t)0x10) +#define RTC_CR3_COSEL ((uint8_t)0x08) +#define RTC_CR3_BCK ((uint8_t)0x04) +#define RTC_CR3_SUB1H ((uint8_t)0x02) +#define RTC_CR3_ADD1H ((uint8_t)0x01) + + +/* Bits definition for RTC_ISR1 register*/ +#define RTC_ISR1_INIT ((uint8_t)0x80) +#define RTC_ISR1_INITF ((uint8_t)0x40) +#define RTC_ISR1_RSF ((uint8_t)0x20) +#define RTC_ISR1_INITS ((uint8_t)0x10) +#define RTC_ISR1_SHPF ((uint8_t)0x08) +#define RTC_ISR1_WUTWF ((uint8_t)0x04) +#define RTC_ISR1_RECALPF ((uint8_t)0x02) +#define RTC_ISR1_ALRAWF ((uint8_t)0x01) + + +/* Bits definition for RTC_ISR2 register*/ +#define RTC_ISR2_WUTF ((uint8_t)0x04) +#define RTC_ISR2_ALRAF ((uint8_t)0x01) +#define RTC_ISR2_TAMP3F ((uint8_t)0x80) +#define RTC_ISR2_TAMP2F ((uint8_t)0x40) +#define RTC_ISR2_TAMP1F ((uint8_t)0x20) + +/* Bits definition for RTC_SHIFTRH register*/ +#define RTC_SHIFTRH_ADD1S ((uint8_t)0x80) +#define RTC_SHIFTRH_SUBFS ((uint8_t)0x7F) + +/* Bits definition for RTC_SHIFTRL register*/ +#define RTC_SHIFTRL_SUBFS ((uint8_t)0xFF) + + +/* Bits definition for RTC_ALRMAR1 register*/ +#define RTC_ALRMAR1_MSK1 ((uint8_t)0x80) +#define RTC_ALRMAR1_ST ((uint8_t)0x70) +#define RTC_ALRMAR1_SU ((uint8_t)0x0F) + +/* Bits definition for RTC_ALRMAR2 register*/ +#define RTC_ALRMAR2_MSK2 ((uint8_t)0x80) +#define RTC_ALRMAR2_MNT ((uint8_t)0x70) +#define RTC_ALRMAR2_MNU ((uint8_t)0x0F) + +/* Bits definition for RTC_ALRMAR3 register*/ +#define RTC_ALRMAR3_MSK3 ((uint8_t)0x80) +#define RTC_ALRMAR3_PM ((uint8_t)0x40) +#define RTC_ALRMAR3_HT ((uint8_t)0x30) +#define RTC_ALRMAR3_HU ((uint8_t)0x0F) + +/* Bits definition for RTC_ALRMAR4 register*/ +#define RTC_ALRMAR4_MSK4 ((uint8_t)0x80) +#define RTC_ALRMAR4_WDSEL ((uint8_t)0x40) +#define RTC_ALRMAR4_DT ((uint8_t)0x30) +#define RTC_ALRMAR4_DU ((uint8_t)0x0F) + +/* Bits definition for RTC_ALRMASSRH register*/ +#define RTC_ALRMASSRH_ALSS ((uint8_t)0x7F) + +/* Bits definition for RTC_ALRMASSRL register*/ +#define RTC_ALRMASSRL_ALSS ((uint8_t)0xFF) + +/* Bits definition for RTC_ALRMASSMSKR register*/ +#define RTC_ALRMASSMSKR_MASKSS ((uint8_t)0x1F) + + +/* Bits definition for RTC_CALRH register*/ +#define RTC_CALRH_CALP ((uint8_t)0x80) +#define RTC_CALRH_CALW8 ((uint8_t)0x40) +#define RTC_CALRH_CALW16 ((uint8_t)0x20) +#define RTC_CALRH_CALWx ((uint8_t)0x60) +#define RTC_CALRH_CALM ((uint8_t)0x01) + +/* Bits definition for RTC_CALRL register*/ +#define RTC_CALRL_CALM ((uint8_t)0xFF) + +/* Bits definition for RTC_TCR1 register*/ +#define RTC_TCR1_TAMP3LEVEL ((uint8_t)0x40) +#define RTC_TCR1_TAMP3E ((uint8_t)0x20) +#define RTC_TCR1_TAMP2LEVEL ((uint8_t)0x10) +#define RTC_TCR1_TAMP2E ((uint8_t)0x08) +#define RTC_TCR1_TAMP1LEVEL ((uint8_t)0x04) +#define RTC_TCR1_TAMP1E ((uint8_t)0x02) +#define RTC_TCR1_TAMPIE ((uint8_t)0x01) + +/* Bits definition for RTC_TCR2 register*/ +#define RTC_TCR2_TAMPPUDIS ((uint8_t)0x80) +#define RTC_TCR2_TAMPPRCH ((uint8_t)0x60) +#define RTC_TCR2_TAMPFLT ((uint8_t)0x18) +#define RTC_TCR2_TAMPFREQ ((uint8_t)0x07) + + +/*RTC special defines */ +#define RTC_WPR_EnableKey ((uint8_t)0xFF) +#define RTC_WPR_DisableKey1 ((uint8_t)0xCA) +#define RTC_WPR_DisableKey2 ((uint8_t)0x53) + +/** + * @} + */ + +/** + * @brief CSS on LSE registers. + */ +typedef struct CSSLSE_struct +{ + __IO uint8_t CSR; /*!< Control and Status Register*/ +} +CSSLSE_TypeDef; + +/** @addtogroup CSSLSE_Registers_Reset_Value + * @{ + */ +#define CSSLSE_CSR_RESET_VALUE ((uint8_t)0x00) + +/** + * @} + */ + +/** @addtogroup CSSLSE_Registers_Bits_Definition + * @{ + */ + +/* Bits definition for CSSLSE_CSR register*/ +#define CSSLSE_CSR_SWITCHF ((uint8_t)0x10) +#define CSSLSE_CSR_CSSF ((uint8_t)0x08) +#define CSSLSE_CSR_CSSIE ((uint8_t)0x04) +#define CSSLSE_CSR_SWITCHEN ((uint8_t)0x02) +#define CSSLSE_CSR_CSSEN ((uint8_t)0x01) + +/** + * @} + */ +/*----------------------------------------------------------------------------*/ +/** + * @brief Beeper (BEEP) peripheral registers. + */ + +typedef struct BEEP_struct +{ + __IO uint8_t CSR1; /*!< BEEP Control status register1 */ + uint8_t RSERVED1; + uint8_t RESERVED2; + __IO uint8_t CSR2; /*!< BEEP Control status register2 */ +} +BEEP_TypeDef; + +/** @addtogroup BEEP_Registers_Reset_Value + * @{ + */ +#define BEEP_CSR1_RESET_VALUE ((uint8_t)0x00) +#define BEEP_CSR2_RESET_VALUE ((uint8_t)0x1F) + +/** + * @} + */ + +/** @addtogroup BEEP_Registers_Bits_Definition + * @{ + */ + +#define BEEP_CSR1_MSR ((uint8_t)0x01) /*!< Measurement enable mask */ + +#define BEEP_CSR2_BEEPSEL ((uint8_t)0xC0) /*!< Beeper frequency selection mask */ +#define BEEP_CSR2_BEEPEN ((uint8_t)0x20) /*!< Beeper enable mask */ +#define BEEP_CSR2_BEEPDIV ((uint8_t)0x1F) /*!< Beeper Divider prescalar mask */ + +/** + * @} + */ + +/*----------------------------------------------------------------------------ok*/ + +/** + * @brief Configuration Registers (CFG) + */ + +typedef struct CFG_struct +{ + __IO uint8_t GCR; /*!< Global Configuration register */ +} +CFG_TypeDef; + +/** @addtogroup CFG_Registers_Reset_Value + * @{ + */ + +#define CFG_GCR_RESET_VALUE ((uint8_t)0x00) + +/** + * @} + */ + +/** @addtogroup CFG_Registers_Bits_Definition + * @{ + */ + +#define CFG_GCR_SWD ((uint8_t)0x01) /*!< Swim disable bit mask */ +#define CFG_GCR_AL ((uint8_t)0x02) /*!< Activation Level bit mask */ + +/** + * @} + */ +/*----------------------------------------------------------------------------ok*/ + +/** + * @brief SYSCFG + */ + +typedef struct SYSCFG_struct +{ + __IO uint8_t RMPCR3; /*!< Remap control register 3 */ + __IO uint8_t RMPCR1; /*!< Remap control register 1 */ + __IO uint8_t RMPCR2; /*!< Remap control register 2 */ +} +SYSCFG_TypeDef; + +/** @addtogroup SYSCFG_Registers_Reset_Value + * @{ + */ +#define SYSCFG_RMPCR1_RESET_VALUE ((uint8_t)0x0C) +#define SYSCFG_RMPCR2_RESET_VALUE ((uint8_t)0x00) +#define SYSCFG_RMPCR3_RESET_VALUE ((uint8_t)0x00) + +/** + * @} + */ + +/** @addtogroup SYSCFG_Registers_Bits_Definition + * @{ + */ + +/* For DMA Channel Mapping*/ +#define SYSCFG_RMPCR1_ADC1DMA_REMAP ((uint8_t)0x03) /*!< ADC1 DMA channel remapping */ +#define SYSCFG_RMPCR1_TIM4DMA_REMAP ((uint8_t)0x0C) /*!< TIM4 DMA channel remapping */ + + +/* For GPIO Reapping*/ +#define SYSCFG_RMPCR1_USART1TR_REMAP ((uint8_t)0x30) /*!< USART1_TX and USART1_RX remapping */ +#define SYSCFG_RMPCR1_USART1CK_REMAP ((uint8_t)0x40) /*!< USART1_CK remapping */ +#define SYSCFG_RMPCR1_SPI1_REMAP ((uint8_t)0x80) /*!< SPI1 remapping */ + +#define SYSCFG_RMPCR2_ADC1TRIG_REMAP ((uint8_t)0x01) /*!< ADC1 External Trigger remap */ +#define SYSCFG_RMPCR2_TIM2TRIG_REMAP ((uint8_t)0x02) /*!< TIM2 Trigger remap */ +#define SYSCFG_RMPCR2_TIM3TRIG_REMAP1 ((uint8_t)0x04) /*!< TIM3 Trigger remap 1 */ +#define SYSCFG_RMPCR2_TIM2TRIG_LSE ((uint8_t)0x08) /*!< TIM2 Trigger remap to LSE */ +#define SYSCFG_RMPCR2_TIM3TRIG_LSE ((uint8_t)0x10) /*!< TIM3 Trigger remap to LSE */ +#define SYSCFG_RMPCR2_SPI2_REMAP ((uint8_t)0x20) /*!< SPI2 remapping */ +#define SYSCFG_RMPCR2_TIM3TRIG_REMAP2 ((uint8_t)0x40) /*!< TIM3 Trigger remap 2 */ +#define SYSCFG_RMPCR2_TIM23BKIN_REMAP ((uint8_t)0x80) /*!< TIM2 & TIM3 Break input remap */ + +#define SYSCFG_RMPCR3_SPI1_REMAP ((uint8_t)0x01) /*!< SPI1 remapping */ +#define SYSCFG_RMPCR3_USART3TR_REMAP ((uint8_t)0x02) /*!< USART3_TX and USART3_RX remapping */ +#define SYSCFG_RMPCR3_USART3CK_REMAP ((uint8_t)0x04) /*!< USART3_CK remapping */ +#define SYSCFG_RMPCR3_TIM3CH1_REMAP ((uint8_t)0x08) /*!< TIM3 channel 1 remapping */ +#define SYSCFG_RMPCR3_TIM3CH2_REMAP ((uint8_t)0x10) /*!< TIM3 channel 2 remapping */ +#define SYSCFG_RMPCR3_CCO_REMAP ((uint8_t)0x20) /*!< CCO remapping */ + +/** + * @} + */ +/*----------------------------------------------------------------------------ok*/ + +/** + * @brief Clock Controller (CLK) + */ +typedef struct CLK_struct +{ + __IO uint8_t CKDIVR; /*!< Clock Master Divider Register */ + __IO uint8_t CRTCR; /*!< RTC Clock selection Register */ + __IO uint8_t ICKCR; /*!< Internal Clocks Control Register */ + __IO uint8_t PCKENR1; /*!< Peripheral Clock Gating Register 1 */ + __IO uint8_t PCKENR2; /*!< Peripheral Clock Gating Register 2 */ + __IO uint8_t CCOR; /*!< Configurable Clock Output Register */ + __IO uint8_t ECKCR; /*!< External Clocks Control Register */ + __IO uint8_t SCSR; /*!< System clock status Register */ + __IO uint8_t SWR; /*!< System clock Switch Register */ + __IO uint8_t SWCR; /*!< Switch Control Register */ + __IO uint8_t CSSR; /*!< Clock Security Sytem Register */ + __IO uint8_t CBEEPR; /*!< Clock BEEP Register */ + __IO uint8_t HSICALR; /*!< HSI Calibration Register */ + __IO uint8_t HSITRIMR; /*!< HSI clock Calibration Trimmer Register */ + __IO uint8_t HSIUNLCKR; /*!< HSI Unlock Register */ + __IO uint8_t REGCSR; /*!< Main regulator control status register */ + __IO uint8_t PCKENR3; /*!< Peripheral Clock Gating Register 3 */ +} +CLK_TypeDef; + +/** @addtogroup CLK_Registers_Reset_Value + * @{ + */ +#define CLK_CKDIVR_RESET_VALUE ((uint8_t)0x03) +#define CLK_CRTCR_RESET_VALUE ((uint8_t)0x00) +#define CLK_ICKCR_RESET_VALUE ((uint8_t)0x11) +#define CLK_PCKENR1_RESET_VALUE ((uint8_t)0x00) +#define CLK_PCKENR2_RESET_VALUE ((uint8_t)0x80) +#define CLK_PCKENR3_RESET_VALUE ((uint8_t)0x00) +#define CLK_CCOR_RESET_VALUE ((uint8_t)0x00) +#define CLK_ECKCR_RESET_VALUE ((uint8_t)0x00) +#define CLK_SCSR_RESET_VALUE ((uint8_t)0x01) +#define CLK_SWR_RESET_VALUE ((uint8_t)0x01) +#define CLK_SWCR_RESET_VALUE ((uint8_t)0x00) +#define CLK_CSSR_RESET_VALUE ((uint8_t)0x00) +#define CLK_CBEEPR_RESET_VALUE ((uint8_t)0x00) +#define CLK_HSICALR_RESET_VALUE ((uint8_t)0x00) +#define CLK_HSITRIMR_RESET_VALUE ((uint8_t)0x00) +#define CLK_HSIUNLCKR_RESET_VALUE ((uint8_t)0x00) +#define CLK_REGCSR_RESET_VALUE ((uint8_t)0xB9) +/** + * @} + */ + +/** @addtogroup CLK_Registers_Bits_Definition + * @{ + */ + +#define CLK_CKDIVR_CKM ((uint8_t)0x07) /*!< System clock prescaler mask */ + +#define CLK_CRTCR_RTCDIV ((uint8_t)0xE0) /*!< RTC clock prescaler mask*/ +#define CLK_CRTCR_RTCSEL ((uint8_t)0x1E) /*!< RTC clock output selection mask */ +#define CLK_CRTCR_RTCSWBSY ((uint8_t)0x01) /*!< RTC clock switch busy */ + +#define CLK_ICKCR_BEEPAHALT ((uint8_t)0x40) /*!< BEEP clock Active Halt/Halt mode */ +#define CLK_ICKCR_FHWU ((uint8_t)0x20) /*!< Fast Wake-up from Active Halt/Halt mode */ +#define CLK_ICKCR_SAHALT ((uint8_t)0x10) /*!< Slow Active-halt mode */ +#define CLK_ICKCR_LSIRDY ((uint8_t)0x08) /*!< Low speed internal RC oscillator ready */ +#define CLK_ICKCR_LSION ((uint8_t)0x04) /*!< Low speed internal RC oscillator enable */ +#define CLK_ICKCR_HSIRDY ((uint8_t)0x02) /*!< High speed internal RC oscillator ready */ +#define CLK_ICKCR_HSION ((uint8_t)0x01) /*!< High speed internal RC oscillator enable */ + +#define CLK_PCKENR1_TIM2 ((uint8_t)0x01) /*!< Timer 2 clock enable */ +#define CLK_PCKENR1_TIM3 ((uint8_t)0x02) /*!< Timer 3 clock enable */ +#define CLK_PCKENR1_TIM4 ((uint8_t)0x04) /*!< Timer 4 clock enable */ +#define CLK_PCKENR1_I2C1 ((uint8_t)0x08) /*!< I2C1 clock enable */ +#define CLK_PCKENR1_SPI1 ((uint8_t)0x10) /*!< SPI1 clock enable */ +#define CLK_PCKENR1_USART1 ((uint8_t)0x20) /*!< USART1 clock enable */ +#define CLK_PCKENR1_BEEP ((uint8_t)0x40) /*!< BEEP clock enable */ +#define CLK_PCKENR1_DAC ((uint8_t)0x80) /*!< DAC clock enable */ + +#define CLK_PCKENR2_ADC1 ((uint8_t)0x01) /*!< ADC1 clock enable */ +#define CLK_PCKENR2_TIM1 ((uint8_t)0x02) /*!< TIM1 clock enable */ +#define CLK_PCKENR2_RTC ((uint8_t)0x04) /*!< RTC clock enable */ +#define CLK_PCKENR2_LCD ((uint8_t)0x08) /*!< LCD clock enable */ +#define CLK_PCKENR2_DMA1 ((uint8_t)0x10) /*!< DMA1 clock enable */ +#define CLK_PCKENR2_COMP ((uint8_t)0x20) /*!< Comparator clock enable */ +#define CLK_PCKENR2_BOOTROM ((uint8_t)0x80) /*!< Boot ROM clock enable */ + +#define CLK_PCKENR3_AES ((uint8_t)0x01) /*!< AES clock enable */ +#define CLK_PCKENR3_TIM5 ((uint8_t)0x02) /*!< Timer 5 clock enable */ +#define CLK_PCKENR3_SPI2 ((uint8_t)0x04) /*!< SPI2 clock enable */ +#define CLK_PCKENR3_UASRT2 ((uint8_t)0x08) /*!< USART2 clock enable */ +#define CLK_PCKENR3_USART3 ((uint8_t)0x10) /*!< USART3 clock enable */ + +#define CLK_CCOR_CCODIV ((uint8_t)0xE0) /*!< Configurable Clock output prescaler */ +#define CLK_CCOR_CCOSEL ((uint8_t)0x1E) /*!< Configurable clock output selection */ +#define CLK_CCOR_CCOSWBSY ((uint8_t)0x01) /*!< Configurable clock output switch busy flag */ + +#define CLK_ECKCR_LSEBYP ((uint8_t)0x20) /*!< Low speed external clock bypass */ +#define CLK_ECKCR_HSEBYP ((uint8_t)0x10) /*!< High speed external clock bypass */ +#define CLK_ECKCR_LSERDY ((uint8_t)0x08) /*!< Low speed external crystal oscillator ready */ +#define CLK_ECKCR_LSEON ((uint8_t)0x04) /*!< Low speed external crystal oscillator enable */ +#define CLK_ECKCR_HSERDY ((uint8_t)0x02) /*!< High speed external crystal oscillator ready */ +#define CLK_ECKCR_HSEON ((uint8_t)0x01) /*!< High speed external crystal oscillator enable */ + +#define CLK_SCSR_CKM ((uint8_t)0x0F) /*!< System clock status bits */ + +#define CLK_SWR_SWI ((uint8_t)0x0F) /*!< System clock selection bits */ + +#define CLK_SWCR_SWIF ((uint8_t)0x08) /*!< Clock switch interrupt flag */ +#define CLK_SWCR_SWIEN ((uint8_t)0x04) /*!< Clock switch interrupt enable */ +#define CLK_SWCR_SWEN ((uint8_t)0x02) /*!< Switch start/stop */ +#define CLK_SWCR_SWBSY ((uint8_t)0x01) /*!< Switch busy */ + +#define CLK_CSSR_CSSDGON ((uint8_t)0x10) /*!< Clock security sytem deglitcher system */ +#define CLK_CSSR_CSSD ((uint8_t)0x08) /*!< Clock security sytem detection */ +#define CLK_CSSR_CSSDIE ((uint8_t)0x04) /*!< Clock security system detection interrupt enable */ +#define CLK_CSSR_AUX ((uint8_t)0x02) /*!< Auxiliary oscillator connected to master clock */ +#define CLK_CSSR_CSSEN ((uint8_t)0x01) /*!< Clock security system enable */ + +#define CLK_CBEEPR_CLKBEEPSEL ((uint8_t)0x06) /*!< Configurable BEEP clock source selection */ +#define CLK_CBEEPR_BEEPSWBSY ((uint8_t)0x01) /*!< BEEP clock busy in switch */ + +#define CLK_HSICALR_HSICAL ((uint8_t)0xFF) /*!< Copy of otpion byte trimming HSI oscillator */ + +#define CLK_HSITRIMR_HSITRIM ((uint8_t)0xFF) /*!< High speed internal oscillator trimmer */ + +#define CLK_HSIUNLCKR_HSIUNLCK ((uint8_t)0xFF) /*!< High speed internal oscillator trimmer unlock */ + +#define CLK_REGCSR_EEREADY ((uint8_t)0x80) /*!< Flash program memory and Data EEPROM ready */ +#define CLK_REGCSR_EEBUSY ((uint8_t)0x40) /*!< Flash program memory and Data EEPROM busy */ +#define CLK_REGCSR_LSEPD ((uint8_t)0x20) /*!< LSE power-down */ +#define CLK_REGCSR_HSEPD ((uint8_t)0x10) /*!< HSE power-down */ +#define CLK_REGCSR_LSIPD ((uint8_t)0x08) /*!< LSI power-down */ +#define CLK_REGCSR_HSIPD ((uint8_t)0x04) /*!< HSI power-down */ +#define CLK_REGCSR_REGOFF ((uint8_t)0x02) /*!< Main regulator OFF */ +#define CLK_REGCSR_REGREADY ((uint8_t)0x01) /*!< Main regulator ready */ + +/** + * @} + */ +/*----------------------------------------------------------------------------ok*/ + +/** + * @brief Comparator interface (COMP) + */ + +typedef struct COMP_struct +{ + __IO uint8_t CSR1; /*!< Control status register 1 */ + __IO uint8_t CSR2; /*!< Control status register 2 */ + __IO uint8_t CSR3; /*!< Control status register 3 */ + __IO uint8_t CSR4; /*!< Control status register 4 */ + __IO uint8_t CSR5; /*!< Control status register 5 */ +} +COMP_TypeDef; + + +/** @addtogroup COMP_Registers_Reset_Value + * @{ + */ +#define COMP_CSR1_RESET_VALUE ((uint8_t)0x00) +#define COMP_CSR2_RESET_VALUE ((uint8_t)0x00) +#define COMP_CSR3_RESET_VALUE ((uint8_t)0xC0) +#define COMP_CSR4_RESET_VALUE ((uint8_t)0x00) +#define COMP_CSR5_RESET_VALUE ((uint8_t)0x00) + +/** + * @} + */ + +/** @addtogroup COMP_Registers_Bits_Definition + * @{ + */ + +/* CSR1 */ +#define COMP_CSR1_IE1 ((uint8_t)0x20) /*!< Comparator 1 Interrupt Enable Mask. */ +#define COMP_CSR1_EF1 ((uint8_t)0x10) /*!< Comparator 1 Event Flag Mask. */ +#define COMP_CSR1_CMP1OUT ((uint8_t)0x08) /*!< Comparator 1 Ouptput Mask. */ +#define COMP_CSR1_STE ((uint8_t)0x04) /*!< Schmitt trigger enable Mask. */ +#define COMP_CSR1_CMP1 ((uint8_t)0x03) /*!< Comparator 1 Configuration Mask. */ + +/* CSR2 */ +#define COMP_CSR2_IE2 ((uint8_t)0x20) /*!< Comparator 2 Interrupt Enable Mask. */ +#define COMP_CSR2_EF2 ((uint8_t)0x10) /*!< Comparator 2 Event Flag Mask. */ +#define COMP_CSR2_CMP2OUT ((uint8_t)0x08) /*!< Comparator 2 Ouptput Mask. */ +#define COMP_CSR2_SPEED ((uint8_t)0x04) /*!< Comparator 2 speed modeMask. */ +#define COMP_CSR2_CMP2 ((uint8_t)0x03) /*!< Comparator 2 Configuration Mask. */ + +/* CSR3 */ +#define COMP_CSR3_OUTSEL ((uint8_t)0xC0) /*!< Comparator 2 output selection Mask. */ +#define COMP_CSR3_INSEL ((uint8_t)0x38) /*!< Inversion input selection Mask. */ +#define COMP_CSR3_VREFEN ((uint8_t)0x04) /*!< Internal reference voltage Enable Mask. */ +#define COMP_CSR3_WNDWE ((uint8_t)0x02) /*!< Window Mode Enable Mask. */ +#define COMP_CSR3_VREFOUTEN ((uint8_t)0x01) /*!< VREF Output Enable Mask. */ + +/* CSR4 */ +#define COMP_CSR4_NINVTRIG ((uint8_t)0x38) /*!< COMP2 non-inverting input Mask. */ +#define COMP_CSR4_INVTRIG ((uint8_t)0x07) /*!< COMP2 inverting input Mask. */ + +/* CSR5 */ +#define COMP_CSR5_DACTRIG ((uint8_t)0x38) /*!< DAC outputs Mask. */ +#define COMP_CSR5_VREFTRIG ((uint8_t)0x07) /*!< VREF outputs Mask. */ + +/** + * @} + */ + +/*----------------------------------------------------------------------------ok*/ + +/** + * @brief External Interrupt Controller (EXTI) + */ +typedef struct EXTI_struct +{ + __IO uint8_t CR1; /*!< The four LSB EXTI pin sensitivity */ + __IO uint8_t CR2; /*!< The four MSB EXTI pin sensitivity */ + __IO uint8_t CR3; /*!< EXTI port B & port D sensitivity */ + __IO uint8_t SR1; /*!< Pins Status flag register 1 */ + __IO uint8_t SR2; /*!< Ports Status flage register 2 */ + __IO uint8_t CONF1; /*!< Port interrupt selector */ + uint8_t RESERVED[4]; /*!< reserved area */ + __IO uint8_t CR4; /*!< EXTI port G & port H sensitivity */ + __IO uint8_t CONF2; /*!< Port interrupt selector */ +} +EXTI_TypeDef; + +/** @addtogroup EXTI_Registers_Reset_Value + * @{ + */ + +#define EXTI_CR1_RESET_VALUE ((uint8_t)0x00) +#define EXTI_CR2_RESET_VALUE ((uint8_t)0x00) +#define EXTI_CR3_RESET_VALUE ((uint8_t)0x00) +#define EXTI_CONF1_RESET_VALUE ((uint8_t)0x00) +#define EXTI_SR1_RESET_VALUE ((uint8_t)0x00) +#define EXTI_SR2_RESET_VALUE ((uint8_t)0x00) +#define EXTI_CR4_RESET_VALUE ((uint8_t)0x00) +#define EXTI_CONF2_RESET_VALUE ((uint8_t)0x00) + +/** + * @} + */ + +/** @addtogroup EXTI_Registers_Bits_Definition + * @{ + */ +/* CR1 */ +#define EXTI_CR1_P3IS ((uint8_t)0xC0) /*!< EXTI Pin 3 external interrupt sensitivity bit Mask */ +#define EXTI_CR1_P2IS ((uint8_t)0x30) /*!< EXTI Pin 2 external interrupt sensitivity bit Mask */ +#define EXTI_CR1_P1IS ((uint8_t)0x0C) /*!< EXTI Pin 1 external interrupt sensitivity bit Mask */ +#define EXTI_CR1_P0IS ((uint8_t)0x03) /*!< EXTI Pin 0 external interrupt sensitivity bit Mask */ + +/* CR2 */ +#define EXTI_CR2_P7IS ((uint8_t)0xC0) /*!< EXTI Pin 7 external interrupt sensitivity bit Mask */ +#define EXTI_CR2_P6IS ((uint8_t)0x30) /*!< EXTI Pin 6 external interrupt sensitivity bit Mask */ +#define EXTI_CR2_P5IS ((uint8_t)0x0C) /*!< EXTI Pin 5 external interrupt sensitivity bit Mask */ +#define EXTI_CR2_P4IS ((uint8_t)0x03) /*!< EXTI Pin 4 external interrupt sensitivity bit Mask */ + +/* CR3 */ +#define EXTI_CR3_PBIS ((uint8_t)0x03) /*!< EXTI PORTB external interrupt sensitivity bits Mask */ +#define EXTI_CR3_PDIS ((uint8_t)0x0C) /*!< EXTI PORTD external interrupt sensitivity bits Mask */ +#define EXTI_CR3_PEIS ((uint8_t)0x30) /*!< EXTI PORTE external interrupt sensitivity bits Mask */ +#define EXTI_CR3_PFIS ((uint8_t)0xC0) /*!< EXTI PORTF external interrupt sensitivity bits Mask */ + +/* CONF1 */ +#define EXTI_CONF1_PBLIS ((uint8_t)0x01) /*!< EXTI PORTB low interrupt selector bit Mask */ +#define EXTI_CONF1_PBHIS ((uint8_t)0x02) /*!< EXTI PORTB high interrupt selector bit Mask */ +#define EXTI_CONF1_PDLIS ((uint8_t)0x04) /*!< EXTI PORTD low interrupt selector bit Mask */ +#define EXTI_CONF1_PDHIS ((uint8_t)0x08) /*!< EXTI PORTD high interrupt selector bit Mask */ +#define EXTI_CONF1_PELIS ((uint8_t)0x10) /*!< EXTI PORTE low interrupt selector bit Mask */ +#define EXTI_CONF1_PEHIS ((uint8_t)0x20) /*!< EXTI PORTE high interrupt selector bit Mask */ +#define EXTI_CONF1_PFLIS ((uint8_t)0x40) /*!< EXTI PORTF low interrupt selector bit Mask */ +#define EXTI_CONF1_PFES ((uint8_t)0x80) /*!< EXTI PORTF or PORTE interrupt selector bit Mask */ + +/* CR4 */ +#define EXTI_CR4_PGIS ((uint8_t)0x03) /*!< EXTI PORTG external interrupt sensitivity bits Mask */ +#define EXTI_CR4_PHIS ((uint8_t)0x0C) /*!< EXTI PORTH external interrupt sensitivity bits Mask */ + +/* CONF2 */ +#define EXTI_CONF2_PFHIS ((uint8_t)0x01) /*!< EXTI PORTF high interrupt selector bit Mask */ +#define EXTI_CONF2_PGLIS ((uint8_t)0x02) /*!< EXTI PORTG low interrupt selector bit Mask */ +#define EXTI_CONF2_PGHIS ((uint8_t)0x04) /*!< EXTI PORTG high interrupt selector bit Mask */ +#define EXTI_CONF2_PHLIS ((uint8_t)0x08) /*!< EXTI PORTH low interrupt selector bit Mask */ +#define EXTI_CONF2_PHHIS ((uint8_t)0x10) /*!< EXTI PORTH high interrupt selector bit Mask */ +#define EXTI_CONF2_PGBS ((uint8_t)0x20) /*!< EXTI PORTB or PORTG interrupt selector bit Mask */ +#define EXTI_CONF2_PHDS ((uint8_t)0x40) /*!< EXTI PORTD or PORTH interrupt selector bit Mask */ + +/** + * @} + */ + +/*----------------------------------------------------------------------------ok*/ + +/** + * @brief FLASH and Data EEPROM + */ +typedef struct FLASH_struct +{ + __IO uint8_t CR1; /*!< Flash control register 1 */ + __IO uint8_t CR2; /*!< Flash control register 2 */ + __IO uint8_t PUKR; /*!< Flash program memory unprotection register */ + __IO uint8_t DUKR; /*!< Data EEPROM unprotection register */ + __IO uint8_t IAPSR; /*!< Flash in-application programming status register */ +} +FLASH_TypeDef; + +/** @addtogroup FLASH_Registers_Reset_Value + * @{ + */ +#define FLASH_CR1_RESET_VALUE ((uint8_t)0x00) +#define FLASH_CR2_RESET_VALUE ((uint8_t)0x00) +#define FLASH_PUKR_RESET_VALUE ((uint8_t)0xAE) +#define FLASH_DUKR_RESET_VALUE ((uint8_t)0x56) +#define FLASH_IAPSR_RESET_VALUE ((uint8_t)0x40) + + +/** + * @} + */ + +/** @addtogroup FLASH_Registers_Bits_Definition + * @{ + */ +#define FLASH_CR1_EEPM ((uint8_t)0x08) /*!< Flash low power selection during Run and Low power run mode Mask */ +#define FLASH_CR1_WAITM ((uint8_t)0x04) /*!< Flash low power selection during Wait and Low power wait mode Mask */ +#define FLASH_CR1_IE ((uint8_t)0x02) /*!< Flash Interrupt enable Mask */ +#define FLASH_CR1_FIX ((uint8_t)0x01) /*!< Fix programming time Mask */ + +#define FLASH_CR2_OPT ((uint8_t)0x80) /*!< Enable write access to option bytes*/ +#define FLASH_CR2_WPRG ((uint8_t)0x40) /*!< Word write once Mask */ +#define FLASH_CR2_ERASE ((uint8_t)0x20) /*!< Erase block Mask */ +#define FLASH_CR2_FPRG ((uint8_t)0x10) /*!< Fast programming mode Mask */ +#define FLASH_CR2_PRG ((uint8_t)0x01) /*!< Program block Mask */ + +#define FLASH_IAPSR_HVOFF ((uint8_t)0x40) /*!< End of high voltage flag Mask */ +#define FLASH_IAPSR_DUL ((uint8_t)0x08) /*!< Data EEPROM unlocked flag Mask */ +#define FLASH_IAPSR_EOP ((uint8_t)0x04) /*!< End of operation flag Mask */ +#define FLASH_IAPSR_PUL ((uint8_t)0x02) /*!< Program memory unlocked flag Mask */ +#define FLASH_IAPSR_WR_PG_DIS ((uint8_t)0x01) /*!< Write attempted to protected page Mask */ + +#define FLASH_PUKR_PUK ((uint8_t)0xFF) /*!< Flash Program memory unprotection mask */ + +#define FLASH_DUKR_DUK ((uint8_t)0xFF) /*!< Data EEPROM unprotection mask */ + + +/** + * @} + */ + +/*----------------------------------------------------------------------------*/ + +/** + * @brief Inter-Integrated Circuit (I2C) + */ +typedef struct I2C_struct +{ + __IO uint8_t CR1; /*!< I2C control register 1 */ + __IO uint8_t CR2; /*!< I2C control register 2 */ + __IO uint8_t FREQR; /*!< I2C frequency register */ + __IO uint8_t OARL; /*!< I2C own address register 1 LSB */ + __IO uint8_t OARH; /*!< I2C own address register 1 MSB */ + __IO uint8_t OAR2; /*!< I2C own address register 2 */ + __IO uint8_t DR; /*!< I2C data register */ + __IO uint8_t SR1; /*!< I2C status register 1 */ + __IO uint8_t SR2; /*!< I2C status register 2 */ + __IO uint8_t SR3; /*!< I2C status register 3 */ + __IO uint8_t ITR; /*!< I2C interrupt & DMA register */ + __IO uint8_t CCRL; /*!< I2C clock control register low */ + __IO uint8_t CCRH; /*!< I2C clock control register high */ + __IO uint8_t TRISER; /*!< I2C maximum rise time register */ + __IO uint8_t PECR; /*!< I2CPacket Error Checking register */ +} +I2C_TypeDef; + +/** @addtogroup I2C_Registers_Reset_Value + * @{ + */ +#define I2C_CR1_RESET_VALUE ((uint8_t)0x00) +#define I2C_CR2_RESET_VALUE ((uint8_t)0x00) +#define I2C_FREQR_RESET_VALUE ((uint8_t)0x00) +#define I2C_OARL_RESET_VALUE ((uint8_t)0x00) +#define I2C_OARH_RESET_VALUE ((uint8_t)0x00) +#define I2C_OAR2_RESET_VALUE ((uint8_t)0x00) +#define I2C_DR_RESET_VALUE ((uint8_t)0x00) +#define I2C_SR1_RESET_VALUE ((uint8_t)0x00) +#define I2C_SR2_RESET_VALUE ((uint8_t)0x00) +#define I2C_SR3_RESET_VALUE ((uint8_t)0x00) +#define I2C_ITR_RESET_VALUE ((uint8_t)0x00) +#define I2C_CCRL_RESET_VALUE ((uint8_t)0x00) +#define I2C_CCRH_RESET_VALUE ((uint8_t)0x00) +#define I2C_TRISER_RESET_VALUE ((uint8_t)0x02) +#define I2C_PECR_RESET_VALUE ((uint8_t)0x00) + +/** + * @} + */ + +/** @addtogroup I2C_Registers_Bits_Definition + * @{ + */ + +#define I2C_CR1_NOSTRETCH ((uint8_t)0x80) /*!< Clock Stretching Disable (Slave mode) */ +#define I2C_CR1_ENGC ((uint8_t)0x40) /*!< General Call Enable */ +#define I2C_CR1_ENPEC ((uint8_t)0x20) /*!< PEC Enable */ +#define I2C_CR1_ARP ((uint8_t)0x10) /*!< ARP Enable */ +#define I2C_CR1_SMBTYPE ((uint8_t)0x08) /*!< SMBus type */ +#define I2C_CR1_SMBUS ((uint8_t)0x02) /*!< SMBus mode */ +#define I2C_CR1_PE ((uint8_t)0x01) /*!< Peripheral Enable */ + +#define I2C_CR2_SWRST ((uint8_t)0x80) /*!< Software Reset */ +#define I2C_CR2_ALERT ((uint8_t)0x20) /*!< SMBus Alert*/ +#define I2C_CR2_PEC ((uint8_t)0x10) /*!< Packet Error Checking */ +#define I2C_CR2_POS ((uint8_t)0x08) /*!< Acknowledge */ +#define I2C_CR2_ACK ((uint8_t)0x04) /*!< Acknowledge Enable */ +#define I2C_CR2_STOP ((uint8_t)0x02) /*!< Stop Generation */ +#define I2C_CR2_START ((uint8_t)0x01) /*!< Start Generation */ + +#define I2C_FREQR_FREQ ((uint8_t)0x3F) /*!< Peripheral Clock Frequency */ + +#define I2C_OARL_ADD ((uint8_t)0xFE) /*!< Interface Address bits [7..1] */ +#define I2C_OARL_ADD0 ((uint8_t)0x01) /*!< Interface Address bit0 */ + +#define I2C_OARH_ADDMODE ((uint8_t)0x80) /*!< Addressing Mode (Slave mode) */ +#define I2C_OARH_ADDCONF ((uint8_t)0x40) /*!< Address mode configuration */ +#define I2C_OARH_ADD ((uint8_t)0x06) /*!< Interface Address bits [9..8] */ + +#define I2C_OAR2_ADD2 ((uint8_t)0xFE) /*!< Interface Address bits [7..1] */ +#define I2C_OAR2_ENDUAL ((uint8_t)0x01) /*!< Dual addressing mode enable */ + +#define I2C_DR_DR ((uint8_t)0xFF) /*!< Data Register */ + +#define I2C_SR1_TXE ((uint8_t)0x80) /*!< Data Register Empty (transmitters) */ +#define I2C_SR1_RXNE ((uint8_t)0x40) /*!< Data Register not Empty (receivers) */ +#define I2C_SR1_STOPF ((uint8_t)0x10) /*!< Stop detection (Slave mode) */ +#define I2C_SR1_ADD10 ((uint8_t)0x08) /*!< 10-bit header sent (Master mode) */ +#define I2C_SR1_BTF ((uint8_t)0x04) /*!< Byte Transfer Finished */ +#define I2C_SR1_ADDR ((uint8_t)0x02) /*!< Address sent (master mode)/matched (slave mode) */ +#define I2C_SR1_SB ((uint8_t)0x01) /*!< Start Bit (Master mode) */ + +#define I2C_SR2_SMBALERT ((uint8_t)0x80) /*!< SMBus Alert */ +#define I2C_SR2_TIMEOUT ((uint8_t)0x40) /*!< Time out or TLow error */ +#define I2C_SR2_WUFH ((uint8_t)0x20) /*!< Wake-up from Halt */ +#define I2C_SR2_PECERR ((uint8_t)0x10) /*!< PEC error in reception */ +#define I2C_SR2_OVR ((uint8_t)0x08) /*!< Overrun/Underrun */ +#define I2C_SR2_AF ((uint8_t)0x04) /*!< Acknowledge Failure */ +#define I2C_SR2_ARLO ((uint8_t)0x02) /*!< Arbitration Lost (master mode) */ +#define I2C_SR2_BERR ((uint8_t)0x01) /*!< Bus Error */ + +#define I2C_SR3_DUALF ((uint8_t)0x80) /*!< Dual flag (Slave mode) */ +#define I2C_SR3_SMBHOST ((uint8_t)0x40) /*!< SMBus Host Header (Slave mode) */ +#define I2C_SR3_SMBDEFAULT ((uint8_t)0x20) /*!< SMBus Default Header (Slave mode) */ +#define I2C_SR3_GENCALL ((uint8_t)0x10) /*!< General Call Header (Slave mode) */ +#define I2C_SR3_TRA ((uint8_t)0x04) /*!< Transmitter/Receiver */ +#define I2C_SR3_BUSY ((uint8_t)0x02) /*!< Bus Busy */ +#define I2C_SR3_MSL ((uint8_t)0x01) /*!< Master/Slave */ + +#define I2C_ITR_LAST ((uint8_t)0x10) /*!< DMA Last transfer */ +#define I2C_ITR_DMAEN ((uint8_t)0x08) /*!< DMA request Enable */ +#define I2C_ITR_ITBUFEN ((uint8_t)0x04) /*!< Buffer Interrupt Enable */ +#define I2C_ITR_ITEVTEN ((uint8_t)0x02) /*!< Event Interrupt Enable */ +#define I2C_ITR_ITERREN ((uint8_t)0x01) /*!< Error Interrupt Enable */ + +#define I2C_CCRL_CCR ((uint8_t)0xFF) /*!< Clock Control Register (Master mode) */ + +#define I2C_CCRH_FS ((uint8_t)0x80) /*!< Master Mode Selection */ +#define I2C_CCRH_DUTY ((uint8_t)0x40) /*!< Fast Mode Duty Cycle */ +#define I2C_CCRH_CCR ((uint8_t)0x0F) /*!< Clock Control Register in Fast/Standard mode (Master mode) bits [11..8] */ + +#define I2C_TRISER_TRISE ((uint8_t)0x3F) /*!< Maximum Rise Time in Fast/Standard mode (Master mode) */ + +#define I2C_PECR_PEC ((uint8_t)0xFF) /*!< Packet error checking */ + +/** + * @} + */ + +/*----------------------------------------------------------------------------*/ + +/** + * @brief IR digital interface (IRTIM) + */ +typedef struct IRTIM_struct +{ + __IO uint8_t CR; /*!< control register */ +} +IRTIM_TypeDef; +/** @addtogroup IRTIM_Registers_Reset_Value + * @{ + */ +#define IRTIM_CR_RESET_VALUE ((uint8_t)0x00) + + +/** +* @} +*/ + +/** @addtogroup IRTIM_Registers_Bits_Definition + * @{ + */ +/* CR*/ +#define IRTIM_CR_EN ((uint8_t)0x01) /*!< IRTIM_OUT enable Mask. */ +#define IRTIM_CR_HSEN ((uint8_t)0x02) /*!< High sink open drain buffer enable Mask */ + +/** + * @} + */ + +/*----------------------------------------------------------------------------*/ + +/** + * @brief Interrupt Controller (ITC) + */ +typedef struct ITC_struct +{ + __IO uint8_t ISPR1; /*!< Interrupt Software Priority register 1 */ + __IO uint8_t ISPR2; /*!< Interrupt Software Priority register 2 */ + __IO uint8_t ISPR3; /*!< Interrupt Software Priority register 3 */ + __IO uint8_t ISPR4; /*!< Interrupt Software Priority register 4 */ + __IO uint8_t ISPR5; /*!< Interrupt Software Priority register 5 */ + __IO uint8_t ISPR6; /*!< Interrupt Software Priority register 6 */ + __IO uint8_t ISPR7; /*!< Interrupt Software Priority register 7 */ + __IO uint8_t ISPR8; /*!< Interrupt Software Priority register 8 */ +} +ITC_TypeDef; + +/** @addtogroup ITC_Registers_Reset_Value + * @{ + */ +#define ITC_SPRX_RESET_VALUE ((uint8_t)0xFF) /*!< Reset value of Software Priority registers 0 to 7 */ +/** + * @} + */ + +/*----------------------------------------------------------------------------*/ + +/** + * @brief Internal Low Speed Watchdog (IWDG) + */ +typedef struct IWDG_struct +{ + __IO uint8_t KR; /*!< Low Speed Watchdog Key Register */ + __IO uint8_t PR; /*!< Low Speed Watchdog Prescaler Register */ + __IO uint8_t RLR; /*!< Low Speed Watchdog Reload Register */ +} +IWDG_TypeDef; + +/** @addtogroup IWDG_Registers_Reset_Value + * @{ + */ +#define IWDG_RLR_RESET_VALUE ((uint8_t)0xFF) /*! + #define enableInterrupts() _rim_() /*! + #define enableInterrupts() __enable_interrupt() /* enable interrupts */ + #define disableInterrupts() __disable_interrupt() /* disable interrupts */ + #define rim() __enable_interrupt() /* enable interrupts */ + #define sim() __disable_interrupt() /* disable interrupts */ + #define nop() __no_operation() /* No Operation */ + #define trap() __trap() /* Trap (soft IT) */ + #define wfi() __wait_for_interrupt() /* Wait For Interrupt */ + #define wfe() __wait_for_event(); /* Wait for event */ + #define halt() __halt() /* Halt */ +#endif /* _RAISONANCE_ */ + +/*============================== Interrupt vector Handling ========================*/ + +#ifdef _COSMIC_ + #define INTERRUPT_HANDLER(a,b) @far @interrupt void a(void) + #define INTERRUPT_HANDLER_TRAP(a) void @far @interrupt a(void) +#endif /* _COSMIC_ */ + +#ifdef _RAISONANCE_ + #define INTERRUPT_HANDLER(a,b) void a(void) interrupt b + #define INTERRUPT_HANDLER_TRAP(a) void a(void) trap +#endif /* _RAISONANCE_ */ + +#ifdef _IAR_ + #define STRINGVECTOR(x) #x + #define VECTOR_ID(x) STRINGVECTOR( vector = (x) ) + #define INTERRUPT_HANDLER( a, b ) \ + _Pragma( VECTOR_ID( (b)+2 ) ) \ + __interrupt void (a)( void ) + #define INTERRUPT_HANDLER_TRAP(a) \ + _Pragma( VECTOR_ID( 1 ) ) \ + __interrupt void (a) (void) +#endif /* _IAR_ */ + +/*============================== Interrupt Handler declaration ========================*/ +#ifdef _COSMIC_ + #define INTERRUPT @far @interrupt +#elif defined(_IAR_) + #define INTERRUPT __interrupt +#endif /* _COSMIC_ */ + +/*============================== Handling bits ====================================*/ +/*----------------------------------------------------------------------------- +Method : I +Description : Handle the bit from the character variables. +Comments : The different parameters of commands are + - VAR : Name of the character variable where the bit is located. + - Place : Bit position in the variable (7 6 5 4 3 2 1 0) + - Value : Can be 0 (reset bit) or not 0 (set bit) + The "MskBit" command allows to select some bits in a source + variables and copy it in a destination var (return the value). + The "ValBit" command returns the value of a bit in a char + variable: the bit is reseted if it returns 0 else the bit is set. + This method generates not an optimised code yet. +-----------------------------------------------------------------------------*/ +#define SetBit(VAR,Place) ( (VAR) |= (uint8_t)((uint8_t)1<<(uint8_t)(Place)) ) +#define ClrBit(VAR,Place) ( (VAR) &= (uint8_t)((uint8_t)((uint8_t)1<<(uint8_t)(Place))^(uint8_t)255) ) + +#define ChgBit(VAR,Place) ( (VAR) ^= (uint8_t)((uint8_t)1<<(uint8_t)(Place)) ) +#define AffBit(VAR,Place,Value) ((Value) ? \ + ((VAR) |= ((uint8_t)1<<(Place))) : \ + ((VAR) &= (((uint8_t)1<<(Place))^(uint8_t)255))) +#define MskBit(Dest,Msk,Src) ( (Dest) = ((Msk) & (Src)) | ((~(Msk)) & (Dest)) ) + +#define ValBit(VAR,Place) ((uint8_t)(VAR) & (uint8_t)((uint8_t)1<<(uint8_t)(Place))) + +#define BYTE_0(n) ((uint8_t)((n) & (uint8_t)0xFF)) /*!< Returns the low byte of the 32-bit value */ +#define BYTE_1(n) ((uint8_t)(BYTE_0((n) >> (uint8_t)8))) /*!< Returns the second byte of the 32-bit value */ +#define BYTE_2(n) ((uint8_t)(BYTE_0((n) >> (uint8_t)16))) /*!< Returns the third byte of the 32-bit value */ +#define BYTE_3(n) ((uint8_t)(BYTE_0((n) >> (uint8_t)24))) /*!< Returns the high byte of the 32-bit value */ + +/*============================== Assert Macros ====================================*/ +#define IS_STATE_VALUE(STATE) \ + (((STATE) == SET) || \ + ((STATE) == RESET)) + +/*----------------------------------------------------------------------------- +Method : II +Description : Handle directly the bit. +Comments : The idea is to handle directly with the bit name. For that, it is + necessary to have RAM area descriptions (example: HW register...) + and the following command line for each area. + This method generates the most optimized code. +-----------------------------------------------------------------------------*/ + +#define AREA 0x00 /* The area of bits begins at address 0x10. */ + +#define BitClr(BIT) ( *((unsigned char *) (AREA+(BIT)/8)) &= (~(1<<(7-(BIT)%8))) ) +#define BitSet(BIT) ( *((unsigned char *) (AREA+(BIT)/8)) |= (1<<(7-(BIT)%8)) ) +#define BitVal(BIT) ( *((unsigned char *) (AREA+(BIT)/8)) & (1<<(7-(BIT)%8)) ) + + +#endif /* __STM8L15x_H */ + +/** + * @} + */ + +/** + * @} + */ + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_adc.h b/ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_adc.h new file mode 100644 index 00000000..22c85256 --- /dev/null +++ b/ports/stm8/STM8L15x_StdPeriph_Driver/inc/stm8l15x_adc.h @@ -0,0 +1,383 @@ +/** + ****************************************************************************** + * @file stm8l15x_adc.h + * @author MCD Application Team + * @version V1.6.0 + * @date 28-June-2013 + * @brief This file contains all the functions prototypes for the ADC + * firmware library. + ****************************************************************************** + * + * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.st.com/software_license_agreement_liberty_v2 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM8L15x_ADC_H +#define __STM8L15x_ADC_H + +/* Includes ------------------------------------------------------------------*/ +#include "stm8l15x.h" + +/** @addtogroup STM8L15x_StdPeriph_Driver + * @{ + */ + +/** @addtogroup ADC + * @{ + */ +/* Exported types ------------------------------------------------------------*/ + +/** @defgroup ADC_Exported_Types + * @{ + */ + + +/** @defgroup ADC_Channels + * @{ + */ +typedef enum +{ + ADC_Channel_0 = ((uint16_t)0x0301), /*!< Channel 00 */ + ADC_Channel_1 = ((uint16_t)0x0302), /*!< Channel 01 */ + ADC_Channel_2 = ((uint16_t)0x0304), /*!< Channel 02 */ + ADC_Channel_3 = ((uint16_t)0x0308), /*!< Channel 03 */ + ADC_Channel_4 = ((uint16_t)0x0310), /*!< Channel 04 */ + ADC_Channel_5 = ((uint16_t)0x0320), /*!< Channel 05 */ + ADC_Channel_6 = ((uint16_t)0x0340), /*!< Channel 06 */ + ADC_Channel_7 = ((uint16_t)0x0380), /*!< Channel 07 */ + + ADC_Channel_8 = ((uint16_t)0x0201), /*!< Channel 08 */ + ADC_Channel_9 = ((uint16_t)0x0202), /*!< Channel 09 */ + ADC_Channel_10 = ((uint16_t)0x0204), /*!< Channel 10 */ + ADC_Channel_11 = ((uint16_t)0x0208), /*!< Channel 11 */ + ADC_Channel_12 = ((uint16_t)0x0210), /*!< Channel 12 */ + ADC_Channel_13 = ((uint16_t)0x0220), /*!< Channel 13 */ + ADC_Channel_14 = ((uint16_t)0x0240), /*!< Channel 14 */ + ADC_Channel_15 = ((uint16_t)0x0280), /*!< Channel 15 */ + + ADC_Channel_16 = ((uint16_t)0x0101), /*!< Channel 16 */ + ADC_Channel_17 = ((uint16_t)0x0102), /*!< Channel 17 */ + ADC_Channel_18 = ((uint16_t)0x0104), /*!< Channel 18 */ + ADC_Channel_19 = ((uint16_t)0x0108), /*!< Channel 19 */ + ADC_Channel_20 = ((uint16_t)0x0110), /*!< Channel 20 */ + ADC_Channel_21 = ((uint16_t)0x0120), /*!< Channel 21 */ + ADC_Channel_22 = ((uint16_t)0x0140), /*!< Channel 22 */ + ADC_Channel_23 = ((uint16_t)0x0180), /*!< Channel 23 */ + + ADC_Channel_24 = ((uint16_t)0x0001), /*!< Channel 24 */ + ADC_Channel_25 = ((uint16_t)0x0002), /*!< Channel 25 */ + ADC_Channel_26 = ((uint16_t)0x0004), /*!< Channel 26 */ + ADC_Channel_27 = ((uint16_t)0x0008), /*!< Channel 27 */ + + ADC_Channel_Vrefint = ((uint16_t)0x0010), /*!< Vrefint Channel */ + ADC_Channel_TempSensor = ((uint16_t)0x0020), /*!< Temperature sensor Channel */ + + /* combination*/ + ADC_Channel_00To07 = ((uint16_t)0x03FF), /*!