diff --git a/daemons/README.txt b/daemons/README.txt new file mode 100644 index 0000000..bc0da59 --- /dev/null +++ b/daemons/README.txt @@ -0,0 +1,14 @@ + + Daemons (Server processes) + +include Link to common header files + +Standard daemons +================ +cand CAN data server using Linux-CAN with PCAN-USB +gpsd GPS daemon for serving GPS data +logd Logging daemon that supports multiple types of logs +rtcmd RTCM daemon used to forward corrections data +seriald Serial data relay/service +stdiod Stdio data relay/service +trackd GPS tracking service diff --git a/src/libPIC/Doxygen b/src/libPIC/Doxygen deleted file mode 100644 index c6ba53b..0000000 --- a/src/libPIC/Doxygen +++ /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 = PIC C Library - -# 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 = - -# 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 = YES - -# 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 = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful 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 = YES - -# 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 = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = 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 = NO - -# 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 = *.c *.h - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = NO - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# 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 = YES - -# 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 = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# 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 = YES - -# 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 = YES - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# 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 = YES - -# 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 = YES - -# 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 = YES - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = YES - -# 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 = YES - -# 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/src/libPIC/PIC-LIB.kpf b/src/libPIC/PIC-LIB.kpf deleted file mode 100644 index 7bd55b9..0000000 --- a/src/libPIC/PIC-LIB.kpf +++ /dev/null @@ -1,230 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/libPIC/TODO b/src/libPIC/TODO deleted file mode 100644 index b77b5a4..0000000 --- a/src/libPIC/TODO +++ /dev/null @@ -1,30 +0,0 @@ - - TODO - -Message -------- -Messaging software - Local or remote messaging (queued per task) - Runs on PIC, Windows or Linux - Uses Packet for remote - Routing table (task id -> packet id) - -Packet ------- -Packet interrupt routine needs to timeout on packet. -Use Id high byte for - 0=serial - 1=SPI - 2=I2C - 3=... - other=socket - -I2C ---- - I2C API Rewrite/Update - Fix I2C Master - Fix Bitbanged timing - -Chips ------ -Add links (for Doxygen) to chip manuals diff --git a/src/libPIC/ad_linux.c b/src/libPIC/ad_linux.c deleted file mode 100644 index 8266922..0000000 --- a/src/libPIC/ad_linux.c +++ /dev/null @@ -1,93 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Linux A/D Emulation Driver - *---------------------------------------------------------------------------- - * Linux Analog Drivers (hook into Comedi) -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "analog.h" -#include "delay.h" - -#ifdef __linux__ -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -static short sAnalogData[16] = { 0 }; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -// MAX186 -void AdMax186Init( void ) -{ -} - -WORD AdMax186Read( BYTE byChan ) -{ - return (WORD)sAnalogData[byChan&15]++; -} - -// supports two MAX355 Muxes -void AdMax355Mux( BYTE c ) -{ -} - -// MCP320X -void AdMcp320XInit( void ) -{ -} - -WORD AdMcp320XRead( BYTE byChan ) -{ - return (WORD)sAnalogData[byChan&15]++; -} - -// MCP3301 -void AdMcp3301Init( void ) -{ -} - -short AdMcp3301Read( void ) -{ - return sAnalogData[0]++; -} - -#endif diff --git a/src/libPIC/ad_max186.c b/src/libPIC/ad_max186.c deleted file mode 100644 index 42b40c5..0000000 --- a/src/libPIC/ad_max186.c +++ /dev/null @@ -1,152 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * MAX 186 A/D Chip - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "analog.h" -#include "delay.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -// see spec as channel #s aren't same as select bits -#define AD_MUX(C) (((C)<<4)|0x8E) - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -// table -#ifdef ANALOG_MAX186 -static const BYTE byChTbl[8] = { - AD_MUX( 0 ), - AD_MUX( 4 ), - AD_MUX( 1 ), - AD_MUX( 5 ), - AD_MUX( 2 ), - AD_MUX( 6 ), - AD_MUX( 3 ), - AD_MUX( 7 ) -}; -#endif - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ -#ifdef ANALOG_MAX186 - -void AdMax186Init( void ) -{ - // disable - AD_CS = 1; - AD_CK_DIR = 1; - AD_DT_DIR = 1; -} - -// output channel # to read -static void AdMax186Chan( BYTE x ) -{ - BYTE n = 8; - - // kick mux & start conversion - x = byChTbl[x & 7]; // map - - while ( n-- ) - { - // bits out - if ( x & 0x80 ) - AD_OUT = 1; - else - AD_OUT = 0; - x <<= 1; - - // rising edge and hold - DelayNs0100(); - AD_CK = 1; - DelayNs0200(); - AD_CK = 0; - } -} - -static WORD AdMax186Rd( void ) -{ - BYTE n = 16; - WORD w = 0; - - while ( n-- ) - { - // falling edge - AD_CK = 1; - DelayNs0200(); - AD_CK = 0; - DelayNs0100(); - - // bits in - w <<= 1; - w |= AD_IN; - } - - // return data - return w >> 4; -} - -WORD AdMax186Read( BYTE chan ) -{ - WORD data; - - // clock out, data in and select - AD_CK_DIR = 0; - AD_DT_DIR = 1; - AD_CS = 0; - - // set channel - AdChan( chan ); - - DelayUsec( 10 ); - - // read data - data = AdMax186AdRd(); - - // deselect - AD_CS = 1; - AD_CK_DIR = 1; - AD_DT_DIR = 1; - - return data; -} -#endif diff --git a/src/libPIC/ad_max355.c b/src/libPIC/ad_max355.c deleted file mode 100644 index 29ff8c7..0000000 --- a/src/libPIC/ad_max355.c +++ /dev/null @@ -1,91 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * MAX 255 A/D Multiplexor - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "analog.h" -#include "delay.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ -#ifdef ADMUX_MAX355 - -// supports two MAX355 Muxes -void AdMax355Mux( BYTE c ) -{ - // call with channel number 0..7 - - // turn mux off - ADMUX_ENABLE0 = 0; -#ifdef ADMUX_ENABLE1 - ADMUX_ENABLE1 = 0; -#endif - // wait to transition off - DelayNs0400(); - - // mux off - if ( c == 0xff ) - return; - - // select channel - ADMUX_A0 = ( c & 1 ) ? 1 : 0; - ADMUX_A1 = ( c & 2 ) ? 1 : 0; - - // wait to switch - DelayNs0400(); - -#ifdef ADMUX_ENABLE1 - if ( c & 4 ) - ADMUX_ENABLE1 = 1; // 4..7 - else - ADMUX_ENABLE0 = 1; // 0..3 -#else - ADMUX_ENABLE0 = 1; -#endif - // wait to settle - DelayNs2000(); -} -#endif diff --git a/src/libPIC/ad_mcp320x.c b/src/libPIC/ad_mcp320x.c deleted file mode 100644 index 8a430aa..0000000 --- a/src/libPIC/ad_mcp320x.c +++ /dev/null @@ -1,102 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Microchip MCP320X A/D Chip - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "analog.h" -#include "delay.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ -#if defined(ANALOG_MCP3204) || defined(ANALOG_MCP3208) - -void AdMcp320XInit( void ) -{ - AD_CK = 0; - AD_CS = 1; -} - -// one channel -WORD AdMcp320XRead( BYTE byChan ) -{ - WORD wChan = byChan; - BYTE n = 10; - WORD wData = 0; - - wChan &= 7; // mask address - wChan |= 0x18; // start bit, single ended mode - - AD_CK = 0; // might have already been - AD_CS = 0; // select the chip - - // send channel - while ( n-- ) - { - AD_OUT = (wChan & 0x200) ? 1 : 0; - AD_CK = 1; - DelayUsec( 2 ); - AD_CK = 0; - wChan <<= 1; - DelayUsec( 2 ); - } - - // read - n = 14; - while ( n-- ) - { - wData << = 1; - AD_CK = 1; - wData |= AD_IN; - DelayNs0200(); - AD_CK = 0; - DelayNs0100(); - } - - AD_CS = 1; // de-select the chip - - return wData & 0xfff; // 12 bit mask -} -#endif diff --git a/src/libPIC/ad_mcp3301.c b/src/libPIC/ad_mcp3301.c deleted file mode 100644 index ff05f8c..0000000 --- a/src/libPIC/ad_mcp3301.c +++ /dev/null @@ -1,102 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Microchip MCP3301 A/D Chip - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "analog.h" -#include "delay.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ -#ifdef ANALOG_MCP3301 - -void AdMcp3301Init( void ) -{ - AD_CK = 0; - AD_CS = 1; -} - -// one channel -short AdMcp3301Read( void ) -{ - // returns signed a/d value, 12 bits plus sign bit. - // for MCP330X a/d on bit-bang SPI bus - BYTE n = 3; - WORD x = 0; - - AD_CK = 0; // might have already been - AD_CS = 0; // select the chip - - // convert, interrupts blocked here - while ( n-- ) - { - AD_CK = 1; - DelayUsec( 5 ); - AD_CK = 0; - DelayUsec( 5 ); - } - - // read - n = 13; - while ( n-- ) - { - x << = 1; - AD_CK = 1; - x |= AD_DAT; - DelayNs0300(); - AD_CK = 0; - DelayNs0200(); - } - - AD_CS = 1; // de-select the chip - - // mask and sign extend - x &= 0x1fff; - if ( x & 0x1000 ) - x |= 0xf000; - return (short) x; -} -#endif diff --git a/src/libPIC/adc.c b/src/libPIC/adc.c deleted file mode 100644 index 80b9a30..0000000 --- a/src/libPIC/adc.c +++ /dev/null @@ -1,112 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC A/D Interface - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include -#include - -#include "system.h" -#include "analog.h" -#include "delay.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -#ifdef __linux__ -static WORD wAdcData[8] = { 0 }; -#endif - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void AdInit( void ) -{ -#ifdef __linux__ - bzero( wAdcData, sizeof(wAdcData) ); -#else - ADON = 1; - ADFM = 1; -#if defined(_PIC18) && XTAL==40 - ADCS2 = 1; -#endif - ADCS1 = 1; - ADCS0 = 0; -#endif -} - -WORD AdRead( BYTE byCh ) -{ -#ifdef __linux__ - return wAdcData[byCh&7]++; -#else - short_word data; - - ADCON0 = ( byCh << 3 ) | 0b10000000; -#ifdef _PIC18 - DelayUsec(13); -#else - DelayUsec(20); -#endif - -#ifdef _PIC18 - GODONE = 1; - while ( GODONE ) // wait for conversion complete - ; -#else - ADGO = 1; - while ( ADGO ) // wait for conversion complete - ; -#endif - data.b.h = ADRESH; - data.b.l = ADRESL; - - return data.w; -#endif -} - -#ifdef __linux__ -void AdWrite( BYTE byCh, WORD wData ) -{ - wAdcData[byCh&7] = wData; -} -#endif diff --git a/src/libPIC/adc.h b/src/libPIC/adc.h deleted file mode 100644 index feec572..0000000 --- a/src/libPIC/adc.h +++ /dev/null @@ -1,57 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC 10-bit A/D - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _ADC_H_ -#define _ADC_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -// Internal Analog -extern void AdInit( void ); -extern WORD AdRead( BYTE byCh ); -extern void AdWrite( BYTE byCh, WORD wData ); - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/analog.h b/src/libPIC/analog.h deleted file mode 100644 index 5d32fb1..0000000 --- a/src/libPIC/analog.h +++ /dev/null @@ -1,101 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Generic A/D Chip Interface - *---------------------------------------------------------------------------- - * PIC 10-bit A/D - * Maxim 186, 188, 355 - * Microchip MCP320X, MCP3301 -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _ANALOG_H_ -#define _ANALOG_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -#ifdef ANALOG_MAX186 -#define ANALOG_MODULE -#define AnalogInit() AdMax186Init() -#define AnalogRead(C) AdMax186Read(C) -#endif - -#ifdef ANALOG_MCP320X -#define ANALOG_MODULE -#define AnalogInit() AdMcp320XInit() -#define AnalogRead(C) AdMcp320XRead(C) -#endif - -#ifdef ANALOG_MCP3301 -#define ANALOG_MODULE -#define AnalogInit() AdMcp3301Init() -#define AnalogRead(C) AdMcp3301Read() -#endif - -#ifdef ADMUX_MAX355 -#define AnalogMux(C) AdMax355Mux(C) -#endif - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -// Internal Analog -extern void AdInit( void ); -extern WORD AdRead( BYTE byCh ); -extern void AdWrite( BYTE byCh, WORD wData ); - -// Analog Drivers -#ifdef ANALOG_MAX186 -extern void AdMax186Init(void); -extern WORD AdMax186Read( BYTE byChan ); -#endif -#ifdef ANALOG_MCP320X -extern void AdMcp320XInit( void ); -extern WORD AdMcp320XRead( BYTE byChan ); -#endif -#ifdef ANALOG_MCP3301 -extern void AdMcp3301Init( void ); -extern short AdMcp3301Read( void ); -#endif - -// Analog Multiplexors -#ifdef ADMUX_MAX355 -extern void AdMax355Mux( BYTE byChan ); -#endif - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/atmel.c b/src/libPIC/atmel.c deleted file mode 100644 index 139e811..0000000 --- a/src/libPIC/atmel.c +++ /dev/null @@ -1,493 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Atmel Data Flash Driver - *---------------------------------------------------------------------------- - * Atmel AT45DB041B, AT45DB081B, AT45DB161B Data Flash Driver - * SPI or Bitbanged -*****************************************************************************/ - -/****************************************************************************/ - -#include "system.h" -#include "delay.h" - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "delay.h" -#include "atmel.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -#if defined(ATMEL_MODULE) || defined(__linux__) - -#ifdef __linux__ -#define ATMEL_SIZE 1048510L -#define MEMORY_EMUL -#else -#define ATMEL_PAGE 264 -#endif - -#ifdef ATMEL_SIZE -#define MEMORY_SIZE ATMEL_SIZE -#endif -#define MEMORY_NAME "Atmel" -#define MEMORY_FILE "atmel.pic" -#ifdef MEMORY_DEBUG -#define MEMORY_ERROR -#define READ_PROTECT -#define WRITE_PROTECT -#endif - -#define ATYPE DWORD - -#include "memio.h" - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -// number of pages -const static WORD wAtmelSizes[16] = { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 2048, // AT45DB041B - 0, - 4096, // AT45DB081B - 0, - 0, - 0, - 8192, // AT45DB161B - 0, - 0 -}; - -/***************************************************************************** - * static variables -*****************************************************************************/ - -LIBBANK static bit bAtmelBank = 0; - -// current page -LIBBANK static bit bWritePending = 0; -LIBBANK static DWORD dwWriteAddr = 0L; -LIBBANK static DWORD dwNextPage = 0L; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -// templated -#include "memio.c" - -/* Init *****************************************************************/ - -#ifdef MEMORY_EMUL - -BYTE AtmelStatus( void ) -{ - return 0; -} - -DWORD AtmelSize( void ) -{ - return MemGetSize(); -} - -#else - -void DevInit( void ) -{ -#ifdef ATMEL_WP - ATMEL_WP = 0; -#endif - ATMEL_CS1 = 1; -#ifndef ATMEL_SPI - ATMEL_CLK = 0; -#endif - MemSetSize( AtmelSize() ); - -#ifdef ATMEL_SPI - // spi setup - SpiInit(); - SpiWaitTime( 0 ); -#endif -} - -/* Internal *****************************************************************/ - -BYTE AtmelStatus( void ) -{ - BYTE c; - - // start - ATMEL_CS1 = 0; - - // status command and status read - DevWriteByte( 0, 0xD7 ); - c = DevReadByte( 0 ); - - // end - ATMEL_CS1 = 1; - - return c; -} - -DWORD AtmelSize( void ) -{ - // status has id bits - BYTE c = AtmelStatus(); - if ( c == 0xff ) - return 0; - - // map id bits to # of pages times page size - return (DWORD)wAtmelSizes[(c>>2) & 0x0f] * ATMEL_PAGE; -} - -void AtmelWait( void ) -{ - // wait till ready - while ( ( AtmelStatus() & 0x80 ) == 0 ) - CLRWDT(); -} - -/* Command *****************************************************************/ - -static void AtmelSendCommand( BYTE cd, DWORD dwAddr, BYTE n ) -{ - BYTE i; - WORD wSegment; - WORD wOffset; - - // break up address into page segment and offset - wSegment = (dwAddr / ATMEL_PAGE) << 1; // 15 bit segment - wOffset = (dwAddr % ATMEL_PAGE); // 9 bit offset -#if ATMEL_PAGE > 256 - wPage |= (wOffset>>8) & 1; // 9th bit to segment -#endif - // wait till ready - AtmelWait(); - - // start command - ATMEL_CS1 = 0; - - // send command and 24 bit address - DevWriteByte( 0, cd ); - DevWriteByte( 0, wSegment >> 8 ); - DevWriteByte( 0, wSegment ); - DevWriteByte( 0, wOffset ); - for ( i = 0; i < n; i++ ) - DevWriteByte( 0, 0 ); - - // may be followed by data -} - -// page writing control -static void AtmelReadPage( DWORD dwAddr ) -{ - // Page to Buffer 1/2 (ignores offset) - AtmelSendCommand( bAtmelBank ? 0x55 : 0x53, dwAddr, 0 ); - - ATMEL_CS1 = 1; // end command - - // write address - dwWriteAddr = dwAddr; - dwNextPage = (dwAddr / ATMEL_PAGE) * ATMEL_PAGE; -} - -static void AtmelWritePage( void ) -{ - if ( !bWritePending ) - return; - - // Buffer 1/2 to Page w/ Erase (ignores offset) - AtmelSendCommand( bAtmelBank ? 0x86 : 0x83, dwWriteAddr, 0 ); - - bAtmelBank ^= 1; // switch buffers - ATMEL_CS1 = 1; // end command - - bWritePending = 0; -} - -static void AtmelWriteBuffer( DWORD dwAddr ) -{ - // Buffer 1 or 2 Write (ignores segment) - AtmelSendCommand( bAtmelBank ? 0x87 : 0x84, dwAddr, 0 ); - // followed by data -} - -void AtmelFlush( void ) -{ - AtmelWritePage(); - -#ifdef ATMEL_WP - ATMEL_WP = 0; -#endif -} - -/* Write ****************************************************************/ - - -static BYTE DevStartWrite( DWORD dwAddr, WORD nBytes ) -{ -#ifdef ATMEL_WP - // write protect first 64K - if ( dwAddr < 0x10000L ) - ATMEL_WP = 1; -#endif - // flush pending write - AtmelWritePage(); - - // read page to buffer - AtmelReadPage( dwAddr ); - - // begin buffer write - AtmelWriteBuffer( dwAddr ); - - return 1; -} - -static void DevStopWrite( void ) -{ - // end buffer write - ATMEL_CS1 = 1; - - // check for end of page - if ( MemGetAddr() == dwNextPage ) - AtmelWritePage(); -} - -static void DevWriteByte( DWORD dwAddr, BYTE byData ) -{ - // write page buffering - if ( dwAddr == dwNextPage ) - { - AtmelWritePage(); - AtmelReadPage( dwAddr ); - } -#ifdef ATMEL_SPI - SpiWriteByte( byData ); -#else - byte_bits x; - x.byte = byData; - ATMEL_CLK = 0; - ATMEL_OUT = x.bits.b7; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - ATMEL_OUT = x.bits.b6; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - ATMEL_OUT = x.bits.b5; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - ATMEL_OUT = x.bits.b4; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - ATMEL_OUT = x.bits.b3; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - ATMEL_OUT = x.bits.b2; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - ATMEL_OUT = x.bits.b1; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - ATMEL_OUT = x.bits.b0; - ATMEL_CLK = 1; -#endif - // write pending only if anything actually written to buffer - bWritePending = 1; -} - -/* Read *****************************************************************/ - -static BYTE DevStartRead( DWORD dwAddr, WORD nBytes ) -{ - // flush any pending writes - AtmelWritePage(); - - // Continuous Array Read - AtmelSendCommand( 0xE8, dwAddr, 4 ); - - return 1; -} - -static void DevStopRead( void ) -{ - ATMEL_CS1 = 1; -} - -static BYTE DevReadByte( DWORD dwAddr ) -{ -#ifdef ATMEL_SPI - return SpiReadByte(); -#else - // fast - byte_bits x; - x.byte = 0; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - x.bits.b7 = ATMEL_IN; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - x.bits.b6 = ATMEL_IN; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - x.bits.b5 = ATMEL_IN; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - x.bits.b4 = ATMEL_IN; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - x.bits.b3 = ATMEL_IN; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - x.bits.b2 = ATMEL_IN; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - x.bits.b1 = ATMEL_IN; - ATMEL_CLK = 1; - ATMEL_CLK = 0; - x.bits.b0 = ATMEL_IN; - return x.byte; -#endif -} - -#endif - -// desired functions -MT_Init(Atmel) -MT_GetChecksum(Atmel) -MT_GetError(Atmel) - -MT_ReadBlock(Atmel) -MT_ReadNext(Atmel) -MT_ReadBytes(Atmel) - -MT_WriteBlock(Atmel) -MT_WriteNext(Atmel) -MT_WriteBytes(Atmel) - -MT_ReadData(Atmel) -MT_WriteData(Atmel) - -MT_ReadCSData(Atmel) -MT_WriteCSData(Atmel) - -MT_SkipNext(Atmel) -MT_WriteFill(Atmel) - -// additional functions - -/* Peek/Poke ****************************************************************/ - -#ifdef ATMEL_DIRECT -BYTE AtmelReadByte( DWORD dwAddr ) -{ - BYTE byData = 0; - AtmelReadData( dwAddr, &byData, sizeof(BYTE) ); - return byData; -} - -WORD AtmelReadWord( DWORD dwAddr ) -{ - WORD wData = 0; - AtmelReadData( dwAddr, (BYTE*)&wData, sizeof(WORD) ); - return wData; -} - -DWORD AtmelReadDword( DWORD dwAddr ) -{ - DWORD dwData = 0; - AtmelReadData( dwAddr, (BYTE*)&dwData, sizeof(DWORD) ); - return dwData; -} - -void AtmelWriteByte( DWORD dwAddr, BYTE byData ) -{ - AtmelWriteData( dwAddr, (const BYTE *)&byData, sizeof(BYTE) ); -} - -void AtmelWriteWord( DWORD dwAddr, WORD wData ) -{ - AtmelWriteData( dwAddr, (const BYTE *)&wData, sizeof(WORD) ); -} - -void AtmelWriteDword( DWORD dwAddr, DWORD dwData ) -{ - AtmelWriteData( dwAddr, (const BYTE *)&dwData, sizeof(DWORD) ); -} -#endif - -/* Erase ********************************************************************/ - -#ifdef ATMEL_ERASE -void AtmelEraseBlock( DWORD a, DWORD l ) -{ -#ifdef MEMORY_EMUL - AtmelWriteFill( a, 0, l ); -#else - l &= 0x00fff800; - while ( l ) - { - AtmelWait(); - AtmelSendCommand( 0x50, a, 0 ); - ATMEL_CS1 = 1; - a += 0x800; - l -= 0x800; - } -#endif -} - -void AtmelErasePage( DWORD a, DWORD l ) -{ -#ifdef MEMORY_EMUL - AtmelWriteFill( a, 0, l ); -#else - l &= 0x00ffff00; - while ( l ) - { - AtmelWait(); - AtmelSendCommand( 0x81, a, 0 ); - ATMEL_CS1 = 1; - a += 0x100; - l -= 0x100; - } -#endif -} -#endif - -#endif diff --git a/src/libPIC/atmel.h b/src/libPIC/atmel.h deleted file mode 100644 index 93c3d23..0000000 --- a/src/libPIC/atmel.h +++ /dev/null @@ -1,88 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Atmel Data Flash Chip - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _ATMEL_H_ -#define _ATMEL_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "types.h" - -#ifdef ATMEL_MODULE -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -#define AtmelGetSize() AtmelSize() -#define AtmelReadNextByte() AtmelReadNext() -#define AtmelWriteNextByte(B) AtmelWriteNext(B) - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -extern void AtmelInit( void ); -extern BYTE AtmelStatus( void ); -extern DWORD AtmelSize( void ); -extern void AtmelFlush( void ); - -extern WORD AtmelReadBlock( DWORD dwAddr, WORD nBytes ); -extern BYTE AtmelReadNext( void ); -extern WORD AtmelReadBytes( BYTE *pbyData, WORD nBytes ); -extern WORD AtmelReadData( DWORD dwAddr, BYTE * pbyData, WORD nBytes ); - -extern WORD AtmelWriteBlock( DWORD dwAddr, WORD nBytes ); -extern void AtmelWriteNext( BYTE byData ); -extern WORD AtmelWriteBytes( const BYTE *pbyData, WORD nBytes ); -extern WORD AtmelWriteData( DWORD dwAddr, const BYTE *pbyData, WORD nBytes ); -extern WORD AtmelWriteFill( DWORD dwAddr, BYTE byFill, WORD nBytes ); - -extern WORD AtmelReadCSData( DWORD dwAddr, BYTE *pbyData, WORD nBytes ); -extern WORD AtmelWriteCSData( DWORD dwAddr, const BYTE *pbyData, WORD nBytes ); - -extern BYTE AtmelReadByte( DWORD dwAddr ); -extern WORD AtmelReadWord( DWORD dwAddr ); -extern DWORD AtmelReadDword( DWORD dwAddr ); - -extern void AtmelWriteByte( DWORD dwAddr, BYTE byData ); -extern void AtmelWriteWord( DWORD dwAddr, WORD wData ); -extern void AtmelWriteDword( DWORD dwAddr, DWORD dwData ); - -extern void AtmelEraseBlock( DWORD dwAddr, DWORD nBytes ); -extern void AtmelErasePage( DWORD dwAddr, DWORD nBytes ); - -#ifdef __cpluscplus -} -#endif -#endif -#endif diff --git a/src/libPIC/atmel.pic b/src/libPIC/atmel.pic deleted file mode 100644 index cf95c1d..0000000 Binary files a/src/libPIC/atmel.pic and /dev/null differ diff --git a/src/libPIC/atmeltest.c b/src/libPIC/atmeltest.c deleted file mode 100644 index 3d4a5af..0000000 --- a/src/libPIC/atmeltest.c +++ /dev/null @@ -1,128 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Atmel Memory Test - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#ifdef __linux__ -#include -#endif - -#include "atmel.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -BYTE byBuf1[256] = { 0 }; -BYTE byBuf2[256] = { 0 }; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -int main() -{ - int i; - - // init - for ( i=0 ; i - -#ifdef __linux__ -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void ClkNju6355Init( void ) -{ -} - -void ClkNju6355Write( CLKBANK NJU6355Clock * pClk ) -{ -} - -void ClkNju6355Read( CLKBANK NJU6355Clock * pClk ) -{ - // read time - time_t t; - struct tm *ptm; - - time( &t ); - ptm = localtime( &t ); - - // 52 bits - pClk->byYear = bin2bcd( ptm->tm_year - 100 ); - pClk->byMonth = bin2bcd( ptm->tm_mon + 1 ); - pClk->byDay = bin2bcd( ptm->tm_mday ); - pClk->byWeekDay = ptm->tm_wday + 1; - pClk->byHour = bin2bcd( ptm->tm_hour ); - pClk->byMinute = bin2bcd( ptm->tm_min ); - pClk->bySecond = bin2bcd( ptm->tm_sec ); - pClk->byHundredth = 0; -} - -#endif diff --git a/src/libPIC/clk_nju6355.c b/src/libPIC/clk_nju6355.c deleted file mode 100644 index 607f655..0000000 --- a/src/libPIC/clk_nju6355.c +++ /dev/null @@ -1,184 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * NJU 6355 Clock Driver - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "clock.h" -#include "delay.h" - -#ifndef _PIC -#include -#endif - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ -#ifdef CLOCK_NJU6355 - -void ClkNju6355Init( void ) -{ - // deselect - CLK_CE = 0; - - // float all inputs - CLK_CK_DIR = 1; - CLK_CK = 1; - CLK_DT_DIR = 1; - CLK_DT = 1; -} - -static void ClockWriteBits( BYTE x, BYTE n ) -{ - // push bits out LSB first - while ( n-- ) - { - // low - CLK_CK = 0; - - // data - CLK_DT = ( x & 1 ) ? 1 : 0; - x >>= 1; - - // clock on rising edge - DelayNs0100(); // Twds - CLK_CK = 1; - DelayNs0100(); // Twdh - } - CLK_CK = 0; -} - -void ClkNju6355Write( CLKBANK NJU6355Clock * pClk ) -{ - // all outputs - CLK_CK = 0; - CLK_DT = 0; - CLK_CK_DIR = 0; - CLK_DT_DIR = 0; - - // select chip - CLK_IO = 1; // slow to rise - DelayNs0100(); // Tds - CLK_CE = 1; - DelayNs0500(); // Tcs - - // 44 bits, write order - ClockWriteBits( pClk->byYear, 8 ); - ClockWriteBits( pClk->byMonth, 8 ); - ClockWriteBits( pClk->byDay, 8 ); - ClockWriteBits( pClk->byWeekDay, 4 ); - ClockWriteBits( pClk->byHour, 8 ); - ClockWriteBits( pClk->byMinute, 8 ); - - // deselect chip - CLK_CE = 0; - CLK_IO = 0; - - // float inputs - CLK_CK_DIR = 1; - CLK_DT_DIR = 1; -} - -static BYTE ClockReadBits( BYTE n ) -{ - BYTE x = 0; - BYTE b = 1; - - // pop bits in LSB first - while ( n-- ) - { - // high - DelayNs0200(); - CLK_CK = 1; - - // read data (previous falling edge) - if ( CLK_DT ) - x |= b; - b <<= 1; - - // falling edge -#if XTAL == 40 - DelayNs0200(); -#endif - CLK_CK = 0; - DelayNs0200(); - } - DelayNs0300(); - CLK_CK = 1; - - // returns BCD - return x; -} - -void ClkNju6355Read( CLKBANK NJU6355Clock * pClk ) -{ - // clock out, data in - CLK_CK = 0; - CLK_CK_DIR = 0; - CLK_DT_DIR = 1; - - // select chip - CLK_IO = 0; - DelayNs0100(); // Tds - CLK_CE = 1; - DelayNs0500(); // Tcs - - // 52 bits - pClk->byYear = ClockReadBits( 8 ); // bad year means low voltage - pClk->byMonth = ClockReadBits( 8 ); - pClk->byDay = ClockReadBits( 8 ); - pClk->byWeekDay = ClockReadBits( 4 ); - pClk->byHour = ClockReadBits( 8 ); - pClk->byMinute = ClockReadBits( 8 ); - pClk->bySecond = ClockReadBits( 8 ); - - // deselect chip - CLK_CE = 0; - - // float inputs - CLK_CK_DIR = 1; - CLK_DT_DIR = 1; -} - -#endif diff --git a/src/libPIC/clock.h b/src/libPIC/clock.h deleted file mode 100644 index f8aee7f..0000000 --- a/src/libPIC/clock.h +++ /dev/null @@ -1,93 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Generic Clock Chip Interface - *---------------------------------------------------------------------------- - * NJU 6355 -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _CLOCK_H_ -#define _CLOCK_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -#ifdef CLOCK_NJU6355 -#define CLOCK_MODULE -// JRC NJU6355 -#define SECOND 0 -#define MINUTE 1 -#define HOUR 2 -#define WEEKDAY 3 -#define DATE 4 -#define MONTH 5 -#define YEAR 6 -#endif - -/***************************************************************************** - * macros -*****************************************************************************/ - -#ifdef CLOCK_NJU6355 -#define ClockInit() ClockNju6355Init() -#define ClockWrite(C) ClockNju6355Write(C) -#define ClockRead(C) ClockNju6355Read(C) -#endif - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -typedef struct _GenericClock -{ - BYTE byHundredth; // 100th second - BYTE bySecond; // 0-59 - BYTE byMinute; // 0-59 - BYTE byHour; // 0-23 - BYTE byWeekDay; // 1-7 - BYTE byDay; // 1-31 - BYTE byMonth; // 1-12 - BYTE byYear; // 0-99 starting from 2000 -} GenericClock; - -#ifdef CLOCK_NJU6355 -typedef struct _GenericClock NJU6355Clock; -#endif - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef CLOCK_NJU6355 -extern void ClkNju6355Init( void ); -extern void ClkNju6355Write( CLKBANK NJU6355Clock * pClk ); -extern void ClkNju6355Read( CLKBANK NJU6355Clock * pClk ); -#endif - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/config.h b/src/libPIC/config.h deleted file mode 100644 index 7d69bea..0000000 --- a/src/libPIC/config.h +++ /dev/null @@ -1,137 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC C Library Custom Build Configuration - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _CONFIG_H_ -#define _CONFIG_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -// -// bump this number on each release of this library -// -#define PICLIB_VERSION 1 -#define PICLIB_BUILD 1 - -/***************************************************************************** - * defines -*****************************************************************************/ - -// The following modules are always used -#define TIMER_MODULE // Interrupts for timers -#define SERIAL_MODULE // Should double check serial.h for port assignments - -// The following modules are linked in if we use them -#define FLASH_MODULE // compile this in, so it's available -#define PACKET_MODULE // default, but should be compiled for app - -#ifdef __linux__ -//---------------------------------------------------------------------------- -// Linux port -//---------------------------------------------------------------------------- -#define XTAL 20L - -#define LIBBANK -#define PKTBANK -#define SERBANK - -#elif _PIC18 -//---------------------------------------------------------------------------- -// PIC-18 Port -//---------------------------------------------------------------------------- -#ifndef XTAL -#define XTAL 40L -#endif - -#define LIBBANK near -#define PKTBANK -#define SERBANK - -#define PACKET_FILTER - -#else -//---------------------------------------------------------------------------- -// PIC-16 Port -//---------------------------------------------------------------------------- -#ifndef XTAL -#define XTAL 20L -#endif - -#define LIBBANK bank1 -#define PKTBANK bank2 -#define SERBANK bank2 - -#endif - -//----------------------------------------------------------------------------- -// Defaults -//----------------------------------------------------------------------------- -#ifndef BAUD -#define BAUD 56700L // serial port -#endif - -// timers -#define TIMER1_INT // fast timer -#define TIMER2_INT // msec timer -#ifdef _PIC18 -#define SW_TIMERS 4 -#else -#define SW_TIMERS 2 -#endif - -// counters -#define CCP1_PIN -#define CCP2_PIN - -// portb i/o -#define RB0_PIN -#define RB1_PIN -#define RB2_PIN -#define RB4_PIN -#define RB5_PIN -#define RB6_PIN -#define RB7_PIN - -//----------------------------------------------------------------------------- -// Dependencies -//----------------------------------------------------------------------------- - -// timer 1 needed for period counting -#if (defined(CCP1_PIN) && defined(CCP2_PIN)) && !defined(TIMER1_INT) -#define TIMER1_INT -#endif - -// timer 1 needed for pin interrupt time stamp -#if defined(RB0_PIN) && !defined(TIMER1_INT) -#define TIMER1_INT -#endif - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ - -#endif diff --git a/src/libPIC/dataee.c b/src/libPIC/dataee.c deleted file mode 100644 index 94ba5cb..0000000 --- a/src/libPIC/dataee.c +++ /dev/null @@ -1,229 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Data EE Driver - *---------------------------------------------------------------------------- - * Low end PICs have FLASH, while high end PICs have EEPROM - * This does not access the program flash memory! -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "dataee.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -// Linux emulation -#ifdef __linux__ -#define MEMORY_EMUL -#endif - -// default size -#ifndef EEPROM_SIZE -#define EEPROM_SIZE 256 -#endif - -#define MEMORY_NAME "DataEE" -#define MEMORY_FILE "dataee.pic" -#define MEMORY_SIZE EEPROM_SIZE -#ifdef MEMORY_DEBUG -#if EEPROM_SIZE > 256 -#define READ_PROTECT -#endif -#define WRITE_COUNTING -#endif - -#if EEPROM_SIZE <= 256 -#define ATYPE BYTE -#define STYPE BYTE -#else -#define ATYPE WORD -#define STYPE BYTE -#endif - -#include "memio.h" - -/***************************************************************************** - * macros -*****************************************************************************/ - -#ifndef MEMORY_EMUL -// hardware i/o -#define DevStartRead(A,N) DevStart() -#define DevStopRead() -#define DevStartWrite(A,N) DevStart() -#define DevStopWrite() - -// map byte i/o -#define DevReadByte(A) eeprom_read(A) -#endif - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ -#ifndef MEMORY_EMUL - -// device functions -static void DevInit( void ) -{ - MemSetSize( EEPROM_SIZE ); -} - -static BYTE DevStart( void ) -{ -#ifdef _PIC18 - // access data eeprom - EEPGD = 0; - CFGS = 0; -#endif - return 1; -} - -static void DevWriteByte( WORD wAddr, BYTE byData ) -{ - BYTE byComp; - BYTE nTries = 3; - - while ( nTries-- ) - { - // read - byComp = EEPROM_READ(wAddr); - - // compare - if ( byData == byComp ) - return; - - // write - EEPROM_WRITE(wAddr,byData); - -#ifdef WRITE_COUNTING - // bump write count - MemIncrCount(); -#endif - } - -#ifdef MEMORY_ERROR - // mark error - MemSetError( MEM_ERR_WRITE ); -#endif -} - -// special functions -#ifdef WRITE_COUNTING -void DataEERefresh( void ) -{ - WORD a = 0; - WORD n = EEPROM_SIZE; - BYTE d; - - while ( n-- ) - { - d = DevReadByte( a ); - DevWriteByte( a++, d ); - } -} -#endif -#endif - -// templated -#include "memio.c" - -// desired functions -MT_Init(DataEE) -MT_GetChecksum(DataEE) -MT_GetError(DataEE) - -MT_ReadBlock(DataEE) -MT_ReadNext(DataEE) -MT_ReadBytes(DataEE) - -MT_WriteBlock(DataEE) -MT_WriteNext(DataEE) -MT_WriteBytes(DataEE) - -MT_ReadData(DataEE) -MT_WriteData(DataEE) - -MT_ReadCSData(DataEE) -MT_WriteCSData(DataEE) - -MT_SkipNext(DataEE) -MT_WriteFill(DataEE) - -#ifdef WRITE_COUNTING -// additional functions -DWORD DataEEGetCount( void ) -{ - return MemGetCount(); -} - -void DataEESetCount( DWORD dwCount ) -{ - MemSetCount( dwCount ); -} -#endif - -#ifdef DATAEE_DIRECT -WORD DataEEReadWord( ATYPE wAddr ) -{ - short_word data; - data.b.l = DevReadByte( wAddr++ ); - data.b.h = DevReadByte( wAddr ); - return data.w; -} - -void DataEEWriteWord( ATYPE wAddr, WORD wData ) -{ - DevWriteByte( wAddr++, wData ); - DevWriteByte( wAddr, wData >> 8 ); -} - -DWORD DataEEReadDword( ATYPE wAddr ) -{ - long_dword data; - data.b.ll = DevReadByte( wAddr++ ); - data.b.lh = DevReadByte( wAddr++ ); - data.b.hl = DevReadByte( wAddr++ ); - data.b.hh = DevReadByte( wAddr ); - return data.dw; -} - -void DataEEWriteDword( ATYPE wAddr, DWORD dwData ) -{ - DevWriteByte( wAddr++, dwData ); - DevWriteByte( wAddr++, dwData >> 8 ); - DevWriteByte( wAddr++, dwData >> 16 ); - DevWriteByte( wAddr, dwData >> 24 ); -} -#endif diff --git a/src/libPIC/dataee.h b/src/libPIC/dataee.h deleted file mode 100644 index 5e2716a..0000000 --- a/src/libPIC/dataee.h +++ /dev/null @@ -1,98 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Data EEPROM - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _DATAEE_H_ -#define _DATAEE_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "config.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -#ifndef EEPROM_SIZE -#define EEPROM_SIZE 256 -#endif - -#if EEPROM_SIZE <= 256 -#define ATYPE BYTE -#define STYPE BYTE -#else -#define ATYPE WORD -#define STYPE BYTE -#endif - -/***************************************************************************** - * macros -*****************************************************************************/ - -#define DataEEGetSize() EEPROM_SIZE - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -extern STYPE DataEEReadBlock( ATYPE xAddr, BYTE nBytes ); -extern STYPE DataEEWriteBlock( ATYPE xAddr, BYTE nBytes ); -extern void DataEESkip( BYTE nBytes ); - -extern BYTE DataEEReadNext( void ); -extern STYPE DataEEReadBytes( BYTE *pbyData, BYTE nBytes ); -extern STYPE DataEEReadData( ATYPE xAddr, BYTE *pbyData, BYTE nBytes ); - -extern void DataEEWriteNext( BYTE byData ); -extern STYPE DataEEWriteBytes( const BYTE *pbyData, BYTE nBytes ); -extern STYPE DataEEWriteData( ATYPE xAddr, const BYTE *pbyData, BYTE nBytes ); -extern STYPE DataEEWriteFill( ATYPE xAddr, BYTE byFill, BYTE nBytes ); - -extern STYPE DataEEReadCSData( ATYPE xAddr, BYTE *pbyData, BYTE nBytes ); -extern STYPE DataEEWriteCSData( ATYPE xAddr, const BYTE *pbyData, BYTE nBytes ); - -extern WORD DataEEReadWord( ATYPE xAddr ); -extern void DataEEWriteWord( ATYPE xAddr, WORD wData ); - -extern DWORD DataEEReadDword( ATYPE xAddr ); -extern void DataEEWriteDword( ATYPE xAddr, DWORD dwData ); - -extern BYTE DataEEGetChecksum( void ); -extern BYTE DataEEGetError( void ); - -extern DWORD DataEEGetCount( void ); -extern void DataEESetCount( DWORD dwCount ); -extern void DataEERefresh( void ); - -#ifdef __cpluscplus -} -#endif - -#undef ATYPE -#undef STYPE -#endif diff --git a/src/libPIC/dataee.pic b/src/libPIC/dataee.pic deleted file mode 100644 index 15d236f..0000000 Binary files a/src/libPIC/dataee.pic and /dev/null differ diff --git a/src/libPIC/deetest.c b/src/libPIC/deetest.c deleted file mode 100644 index d794b39..0000000 --- a/src/libPIC/deetest.c +++ /dev/null @@ -1,113 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Data EE Test - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#ifdef __linux__ -#include -#endif - -#include "dataee.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -BYTE byBuf1[256] = { 0 }; -BYTE byBuf2[256] = { 0 }; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -int main() -{ - int i; - - // init - for ( i=0 ; i -#endif - -/***************************************************************************** - * defines -*****************************************************************************/ - -#ifdef __linux__ -//----------------------------------------------------------------------------- -// Delays mapped to sleep functions -//----------------------------------------------------------------------------- -#define DelayInit() -#define DelayUsec(C) usleep(C) -#define DelayMsec(C) usleep((C)*1000) -#define DelaySec(C) sleep(C) -#else -//----------------------------------------------------------------------------- -// Microsecond delay routine -//----------------------------------------------------------------------------- -#if XTAL == 20 -// PIC-18 20Mhz -#define DelayUs(x) { \ - _dcnt = x; \ - while(--_dcnt) { \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - } \ -} -#elif XTAL == 40 -// PIC-18 40Mhz -#define DelayUs(x) { \ - _dcnt = x; \ - while(--_dcnt) { \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - } \ -} -#endif -#endif - -/***************************************************************************** - * macros -*****************************************************************************/ - -#ifndef __linux__ -//----------------------------------------------------------------------------- -// Fixed Delays -//----------------------------------------------------------------------------- -#ifdef XTAL == 20 -// 20Mhz PIC-16 or PIC-18 -#define DelayNs0100() { \ - asm("nop"); \ -} -#define DelayNs0200() { \ - asm("nop"); \ -} -#define DelayNs0300() { \ - asm("nop"); \ - asm("nop"); \ -} -#define DelayNs0400() { \ - asm("nop"); \ - asm("nop"); \ -} -#define DelayNs0500() { \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ -} -#define DelayNs1000() { \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ -} - -#elif XTAL == 40 -// PIC-18 40Mhz -#define DelayNs0100() { \ - asm("nop"); \ -} -#define DelayNs0200() { \ - asm("nop"); \ - asm("nop"); \ -} -#define DelayNs0300() { \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ -} -#define DelayNs0400() { \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ -} -#define DelayNs0500() { \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ -} -#define DelayNs1000() { \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ - asm("nop"); \ -} -#endif - -// Nanosecond delays -#define DelayNs1500() { \ - DelayNs0500(); \ - DelayNs1000(); \ -} -#define DelayNs2000() { \ - DelayNs1000(); \ - DelayNs1000(); \ -} -#define DelayNs3000() { \ - DelayNs2000(); \ - DelayNs1000(); \ -} -#define DelayNs4000() { \ - DelayNs2000(); \ - DelayNs2000(); \ -} -#define DelayNs5000() { \ - DelayNs2000(); \ - DelayNs2000(); \ - DelayNs1000(); \ -} - -// Microsecond delays -#define DelayUs1() DelayNs1000() -#define DelayUs2() DelayNs2000() -#define DelayUs3() DelayNs3000() -#define DelayUs4() DelayNs4000() -#define DelayUs5() DelayNs5000() - -#define DelayUs10() { \ - DelayUs5(); \ - DelayUs5(); \ -} -#endif - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -#ifndef __linux__ -extern LIBBANK volatile BYTE _dcnt; -#endif - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef __linux__ -extern void DelayInit( void ); // Timer #0 init - -// library delay routines -extern void DelayUsec( BYTE byCount ); // short delays up to 50usec -extern void DelayUsecW( WORD wCount ); // longer delays over 5usec -extern void DelayMsec( WORD wCount ); -extern void DelaySec( WORD wCount ); -#endif - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/dly_msec.c b/src/libPIC/dly_msec.c deleted file mode 100644 index 2804424..0000000 --- a/src/libPIC/dly_msec.c +++ /dev/null @@ -1,70 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Millisecond Delay - *---------------------------------------------------------------------------- - * 200nsec instruction cycle at 20Mhz, 100nsec at 40Mhz - * You have to examine the asm output to count the instructions - * Make sure this code is compiled with optimization -O -Zg4 -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "delay.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void DelayMsec( WORD n ) -{ - while ( n-- ) - { -#ifdef _PIC18 - DelayUsecW( 1000 ); -#else - DelayUsec( 250 ); - DelayUsec( 250 ); - DelayUsec( 250 ); - DelayUsec( 250 ); -#endif - CLRWDT(); - } -} diff --git a/src/libPIC/dly_sec.c b/src/libPIC/dly_sec.c deleted file mode 100644 index 97fd47c..0000000 --- a/src/libPIC/dly_sec.c +++ /dev/null @@ -1,58 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Second Delay Routine - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "delay.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void DelaySec( WORD n ) -{ - while ( n-- ) - DelayMsec( 1000 ); -} diff --git a/src/libPIC/dly_usec.c b/src/libPIC/dly_usec.c deleted file mode 100644 index 5d0cf4f..0000000 --- a/src/libPIC/dly_usec.c +++ /dev/null @@ -1,113 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Microsecond Delay Routine using Timer 0 - *---------------------------------------------------------------------------- - * 200nsec instruction cycle at 20Mhz, 100nsec at 40Mhz - * You have to examine the asm output to count the instructions - * Make sure this code is compiled with optimization -O -Zg4 -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "delay.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -// used by DelayUs() macro -LIBBANK volatile BYTE _dcnt = 0; - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void DelayInit( void ) -{ - // timer #0 as counter, 2 nsec counts (5 per usec) -#ifdef _PIC18 -#if XTAL==40 - T0CON = 0b10000000; // prescalar = 2 -#else - T0CON = 0b10001000; // no prescalar -#endif -#else - OPTION = 0b10000000; -#endif -} - -// short delays up to 255 usec -void DelayUsec( BYTE n ) -{ - // clear counter -#ifdef _PIC18 - TMR0H = 0; - TMR0L = 0; -#else - TMR0 = 0; -#endif - // # ticks per usec - n--; // calling overhead - n *= 5; - - // wait till count reaches -#ifdef _PIC18 - while ( TMR0L < n ) - ; -#else - while ( TMR0 < n ) - ; -#endif -} - -// longer delays up to 10000 usec (10 msec) -#ifdef _PIC18 -void DelayUsecW( WORD n ) -{ - // clear counter - TMR0H = 0; - TMR0L = 0; - - // 5 ticks per usec - n--; // calling overhead - n *= 5; - - // wait till count reaches - while ( TMR0 < n ) - ; -} -#endif diff --git a/src/libPIC/emul.c b/src/libPIC/emul.c deleted file mode 100644 index 54d3032..0000000 --- a/src/libPIC/emul.c +++ /dev/null @@ -1,54 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Linux Digital I/O Emulation Driver - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "emul.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -byte_bits bbDigdir[8]; -byte_bits bbDigio[8]; - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ diff --git a/src/libPIC/emul.h b/src/libPIC/emul.h deleted file mode 100644 index 711d72d..0000000 --- a/src/libPIC/emul.h +++ /dev/null @@ -1,169 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Linux PIC Emulation - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _EMUL_H_ -#define _EMUL_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -// macros -#define _port_byte(A) bbDigio[A].byte -#define _port_bit(A,B) bbDigio[A].bits.b(B) - -#define _port_dirbyte(A) bbDigdir[A].byte -#define _port_dirbit(A,D) bbDigdir[A].bits.b(D) - -// -// emulation -#define PORTA _port_byte(0) -#define RA0 _port_bit(0,0) -#define RA1 _port_bit(0,1) -#define RA2 _port_bit(0,2) -#define RA3 _port_bit(0,3) -#define RA4 _port_bit(0,4) -#define RA5 _port_bit(0,5) -#define RA6 _port_bit(0,6) -#define RA7 _port_bit(0,7) - -#define PORTB _port_byte(1) -#define RB0 _port_bit(1,0) -#define RB1 _port_bit(1,1) -#define RB2 _port_bit(1,2) -#define RB3 _port_bit(1,3) -#define RB4 _port_bit(1,4) -#define RB5 _port_bit(1,5) -#define RB6 _port_bit(1,6) -#define RB7 _port_bit(1,7) - -#define PORTC _port_byte(2) -#define RC0 _port_bit(2,0) -#define RC1 _port_bit(2,1) -#define RC2 _port_bit(2,2) -#define RC3 _port_bit(2,3) -#define RC4 _port_bit(2,4) -#define RC5 _port_bit(2,5) -#define RC6 _port_bit(2,6) -#define RC7 _port_bit(2,7) - -#define PORTD _port_byte(3) -#define RD0 _port_bit(3,0) -#define RD1 _port_bit(3,1) -#define RD2 _port_bit(3,2) -#define RD3 _port_bit(3,3) -#define RD4 _port_bit(3,4) -#define RD5 _port_bit(3,5) -#define RD6 _port_bit(3,6) -#define RD7 _port_bit(3,7) - -#define PORTE _port_byte(4) -#define RE0 _port_bit(4,0) -#define RE1 _port_bit(4,1) -#define RE2 _port_bit(4,2) -#define RE3 _port_bit(4,3) -#define RE4 _port_bit(4,4) -#define RE5 _port_bit(4,5) -#define RE6 _port_bit(4,6) -#define RE7 _port_bit(4,7) - -#define TRISA _port_dirbyte(0) -#define TRISA0 _port_dirbit(0,0) -#define TRISA1 _port_dirbit(0,1) -#define TRISA2 _port_dirbit(0,2) -#define TRISA3 _port_dirbit(0,3) -#define TRISA4 _port_dirbit(0,4) -#define TRISA5 _port_dirbit(0,5) -#define TRISA6 _port_dirbit(0,6) -#define TRISA7 _port_dirbit(0,7) - -#define TRISB _port_dirbyte(1) -#define TRISB0 _port_dirbit(1,0) -#define TRISB1 _port_dirbit(1,1) -#define TRISB2 _port_dirbit(1,2) -#define TRISB3 _port_dirbit(1,3) -#define TRISB4 _port_dirbit(1,4) -#define TRISB5 _port_dirbit(1,5) -#define TRISB6 _port_dirbit(1,6) -#define TRISB7 _port_dirbit(1,7) - -#define TRISC _port_dirbyte(2) -#define TRISC0 _port_dirbit(2,0) -#define TRISC1 _port_dirbit(2,1) -#define TRISC2 _port_dirbit(2,2) -#define TRISC3 _port_dirbit(2,3) -#define TRISC4 _port_dirbit(2,4) -#define TRISC5 _port_dirbit(2,5) -#define TRISC6 _port_dirbit(2,6) -#define TRISC7 _port_dirbit(2,7) - -#define TRISD _port_dirbyte(3) -#define TRISD0 _port_dirbit(3,0) -#define TRISD1 _port_dirbit(3,1) -#define TRISD2 _port_dirbit(3,2) -#define TRISD3 _port_dirbit(3,3) -#define TRISD4 _port_dirbit(3,4) -#define TRISD5 _port_dirbit(3,5) -#define TRISD6 _port_dirbit(3,6) -#define TRISD7 _port_dirbit(3,7) - -#define TRISE _port_dirbyte(4) -#define TRISE0 _port_dirbit(4,0) -#define TRISE1 _port_dirbit(4,1) -#define TRISE2 _port_dirbit(4,2) -#define TRISE3 _port_dirbit(4,3) -#define TRISE4 _port_dirbit(4,4) -#define TRISE5 _port_dirbit(4,5) -#define TRISE6 _port_dirbit(4,6) -#define TRISE7 _port_dirbit(4,7) - -#define TO 1 -#define BOR 1 -#define RI 1 - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -extern byte_bits bbDigdir[8]; -extern byte_bits bbDigio[8]; - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - - - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/fram.c b/src/libPIC/fram.c deleted file mode 100644 index 68b2f86..0000000 --- a/src/libPIC/fram.c +++ /dev/null @@ -1,260 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * FRAM Chip Driver - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "delay.h" -#include "fram.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -#if defined(FRAM_MODULE) || defined(__linux__) - -#ifdef __linux__ -#define FRAM_SIZE 8192 -#undef FRAM_SCL -// Linux I2C driver? -#define MEMORY_EMUL -#endif - -#ifdef FRAM_SIZE -#define MEMORY_SIZE FRAM_SIZE -#endif -#define MEMORY_FILE "fram.pic" -#define MEMORY_NAME "Fram" -#ifdef MEMORY_DEBUG -#define MEMORY_ERROR // track errors -#define READ_PROTECT -#define WRITE_PROTECT -#endif - -#include "memio.h" - -#ifdef FRAM_SCL -// internalize the module for I2C bit banged I/O -#define I2C_INTERNAL -#define I2C_MODULE -#endif - -#ifdef I2C_INTERNAL -// port definitions from project.h -#define SCL FRAM_SCL -#define SCL_DIR FRAM_SCL_DIR -#define SDA FRAM_SDA -#define SDA_DIR FRAM_SDA_DIR - -// include the C modules directly -// adjusted timings -#define I2C_TM_PUT_FUDGE 0 -#define I2C_TM_START_SU 1 -#define I2C_TM_START_HD 1 -#define I2C_TM_SCL_LOW 0 -#define I2C_TM_SCL_HIGH 0 -#define I2C_TM_DATA_SU 0 -#define I2C_TM_DATA_HD 0 -#define I2C_TM_SCL_TO_DATA 0 // SCL low to data valid -#define I2C_TM_STOP_SU 1 -#define I2C_TM_STOP_HD 0 -#define I2C_TM_BUS_FREE 1 -#define I2C_TM_SCL_TMO 0 // clock time out - -#include "i2c_master.h" -#include "i2c_bitbang.c" -#else -//#include "i2c_master.h" -#endif - -/***************************************************************************** - * macros -*****************************************************************************/ - -#ifndef MEMORY_EMUL -#define DevStopRead() i2c_StopRead() -#define DevStopWrite() i2c_StopWrite() -#endif - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -// templated -#include "memio.c" - -/* Init *****************************************************************/ - -// special functions -DWORD FramSize( void ) -{ -#ifdef FRAM_SIZE - return FRAM_SIZE; -#else - BYTE byZero, byTest, byCount; - WORD wAddr; - - // already sized? - if ( MemGetSize() ) - return MemGetSize(); - - wAddr = 0; // establish test byte addr - byZero = FramReadByte(wAddr); // store test byte - FramWriteByte(wAddr, 0); // establish test byte value - - byCount=0; - while (FramReadByte(0) == 0) - { - if (++byCount > 1) - FramWriteByte(wAddr, byTest); // restore real byte - wAddr += 8192; // increment address 8K - byTest = FramReadByte(wAddr); // store real byte - FramWriteByte(wAddr, byCount); // write real/test byte - } - FramWriteByte(0, byZero); // restore test byte - - return (DWORD)wAddr; -#endif -} - -/* I/O ******************************************************************/ - -#ifndef MEMORY_EMUL -// device functions -static BYTE FramWriteAddr( WORD wAddr ) -{ - // setup up for write - BYTE byCtl = ROM | ((wAddr & 0x8000) >> 14); - i2c_WriteTo( byCtl ); - i2c_PutByte( wAddr >> 8 ); - i2c_PutByte( wAddr ); - return byCtl; -} - -static void DevInit( void ) -{ -#ifdef I2C_INTERNAL - I2C_init(); -#endif - MemSetSize( FramSize() ); -} - -static BYTE DevStartRead( WORD wAddr, WORD nBytes ) -{ - i2c_ReadFrom( FramWriteAddr( wAddr ) ); - return 1; -} - -static BYTE DevReadByte( WORD wAddr ) -{ - return i2c_GetByte( MemGetLen() > 0 ? I2C_MORE : I2C_LAST ); -} - -static BYTE DevStartWrite( WORD wAddr, WORD nBytes ) -{ - FramWriteAddr( wAddr ); - return 1; -} - -static void DevWriteByte( WORD wAddr, BYTE byData ) -{ - i2c_PutByte( byData ); -} -#endif - -// desired functions -MT_Init(Fram) -MT_GetChecksum(Fram) -MT_GetError(Fram) - -MT_ReadBlock(Fram) -MT_ReadNext(Fram) -MT_ReadBytes(Fram) - -MT_WriteBlock(Fram) -MT_WriteNext(Fram) -MT_WriteBytes(Fram) - -MT_ReadData(Fram) -MT_WriteData(Fram) - -MT_ReadCSData(Fram) -MT_WriteCSData(Fram) - -MT_SkipNext(Fram) -MT_WriteFill(Fram) - -// additional functions -#ifdef FRAM_DIRECT -BYTE FramReadByte( WORD wAddr ) -{ - BYTE byData = 0; - FramReadData( wAddr, &byData, sizeof(BYTE) ); - return byData; -} - -WORD FramReadWord( WORD wAddr ) -{ - WORD wData = 0; - FramReadData( wAddr, (BYTE*)&wData, sizeof(WORD) ); - return wData; -} - -DWORD FramReadDword( WORD wAddr ) -{ - DWORD dwData = 0; - FramReadData( wAddr, (BYTE*)&dwData, sizeof(DWORD) ); - return dwData; -} - -void FramWriteByte( WORD wAddr, BYTE byData ) -{ - FramWriteData( wAddr, (const BYTE *)&byData, sizeof(BYTE) ); -} - -void FramWriteWord( WORD wAddr, WORD wData ) -{ - FramWriteData( wAddr, (const BYTE *)&wData, sizeof(WORD) ); -} - -void FramWriteDword( WORD wAddr, DWORD dwData ) -{ - FramWriteData( wAddr, (const BYTE *)&dwData, sizeof(DWORD) ); -} -#endif - -#endif diff --git a/src/libPIC/fram.h b/src/libPIC/fram.h deleted file mode 100644 index e7d3a57..0000000 --- a/src/libPIC/fram.h +++ /dev/null @@ -1,84 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * FRAM Chip Interface - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _FRAM_H_ -#define _FRAM_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "config.h" -#include "types.h" - -#ifdef FRAM_MODULE -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -#define FramGetSize() FramSize() - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -extern void FramInit( void ); -extern DWORD FramSize( void ); - -extern WORD FramReadBlock( WORD wAddr, WORD nBytes ); -extern BYTE FramReadNext( void ); -extern WORD FramReadBytes( BYTE *pbyData, WORD nBytes ); -extern WORD FramReadData( WORD wAddr, BYTE *pbyData, WORD nBytes ); - -extern WORD FramWriteBlock( WORD wAddr, WORD nBytes ); -extern void FramWriteNext( BYTE byData ); -extern WORD FramWriteBytes( const BYTE *pbyData, WORD nBytes ); -extern WORD FramWriteData( WORD wAddr, const BYTE *pbyData, WORD nBytes ); -extern WORD FramWriteFill( WORD wAddr, BYTE byFill, WORD nBytes ); - -extern WORD FramReadCSData( WORD wAddr, BYTE *pbyData, WORD nBytes ); -extern WORD FramWriteCSData( WORD wAddr, const BYTE *pbyData, WORD nBytes ); - -extern BYTE FramGetChecksum( void ); -extern BYTE FramGetError( void ); - -extern BYTE FramReadByte( WORD wAddr ); -extern WORD FramReadWord( WORD wAddr ); -extern DWORD FramReadDword( WORD wAddr ); - -extern void FramWriteByte( WORD wAddr, BYTE byData ); -extern void FramWriteWord( WORD wAddr, WORD wData ); -extern void FramWriteDword( WORD wAddr, DWORD dwData ); - -#ifdef __cpluscplus -} -#endif -#endif -#endif diff --git a/src/libPIC/fram.pic b/src/libPIC/fram.pic deleted file mode 100644 index b1567f0..0000000 Binary files a/src/libPIC/fram.pic and /dev/null differ diff --git a/src/libPIC/framtest.c b/src/libPIC/framtest.c deleted file mode 100644 index ddb3310..0000000 --- a/src/libPIC/framtest.c +++ /dev/null @@ -1,128 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * FRAM Memory Test - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#ifdef __linux__ -#include -#endif - -#include "fram.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -BYTE byBuf1[256] = { 0 }; -BYTE byBuf2[256] = { 0 }; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -int main() -{ - int i; - - // init - for ( i=0 ; i0 - DelayUs( I2C_TM_DATA_SU ); -#endif - SCL_HIGH(); /* float clock high */ - -#if I2C_TM_SCL_TMO>0 - i2c_WaitForSCL(); /* wait for clock release */ -#endif - -#if I2C_TM_STOP_SU==1 - DelayNs1000(); -#elif I2C_TM_STOP_SU>1 - DelayUs( I2C_TM_STOP_SU ); -#endif - - SDA_HIGH(); /* the low->high data transistion */ -#if I2C_TM_STOP_HD>0 - DelayUs( I2C_TM_STOP_HD ); /* bus free time before next start */ -#endif - SDA_HIGH(); /* float data high */ -#if I2C_TM_BUS_FREE>0 - DelayUs( I2C_TM_BUS_FREE ); /* bus free time before next start */ -#endif - - return; -} - -/* - * Send stop condition - * - data low-high while clock high - * add SCL_LOW so we get to a different pulse for stopping than the last of write par011001 - */ - -I2C_EXPORT void i2c_StopWrite( void ) -{ - /* don't assume SCL is high on entry */ -#if I2C_TM_SCL_HIGH>0 - DelayUs( I2C_TM_SCL_HIGH ); -#endif - SCL_LOW(); -#if I2C_TM_SCL_LOW>0 - DelayUs( I2C_TM_SCL_LOW ); -#endif - i2c_Stop(); - - return; -} - -/* - * Send (re)start condition - * - ensure data is high then issue a start condition - * - see also i2c_Start() macro - */ - -I2C_EXPORT void i2c_Restart( void ) -{ - SCL_HIGH(); /* clock pulse high - should already be */ -#if I2C_TM_SCL_HIGH==1 - DelayNs1000(); -#elif I2C_TM_SCL_HIGH>1 - DelayUs( I2C_TM_START_SU ); -#endif - SDA_LOW(); /* the high->low transition */ -#if I2C_TM_START_HD==1 - DelayNs1000(); -#elif I2C_TM_START_HD>1 - DelayUs( I2C_TM_START_HD ); -#endif - SCL_LOW(); - return; -} - -/* - * Send a byte to the slave - * - returns true on error - */ - -I2C_EXPORT BYTE i2c_SendByte( BYTE byte ) -{ - BYTE n = 8; - - while ( n-- ) - { - SCL_LOW(); /* drive clock low */ - - /* data hold time = 0, send data now (DO NOT REMOVE BRACES!) */ - if ( byte & 0x80 ) - { - SDA_HIGH(); - } - else - { - SDA_LOW(); - } -#if I2C_TM_DATA_SU>0 - DelayUs( I2C_TM_DATA_SU ); -#endif - SCL_HIGH(); /* float clock high */ -#if I2C_TM_SCL_TMO>0 - if ( i2c_WaitForSCL() ) /* wait for clock release */ - return TRUE; /* bus error */ -#endif -#if I2C_TM_SCL_HIGH==1 - DelayNs0400(); -#elif I2C_TM_SCL_HIGH>0 - DelayUs( I2C_TM_SCL_HIGH ); /* clock high time */ -#endif - byte <<= 1; - } - return FALSE; -} - -/* - * send an address and data direction to the slave - * - 7-bit address (lsb ignored) - * - direction (FALSE = write ) - */ - -I2C_EXPORT BYTE i2c_SendAddress( BYTE address, BYTE rw ) -{ - return i2c_SendByte( address | ( rw ? 1 : 0 ) ); -} - -/* - * Check for an acknowledge - * - returns ack or ~ack, or ERROR if a bus error - */ - -I2C_EXPORT CHAR i2c_ReadAcknowledge( void ) -{ - BYTE ack; - - SCL_LOW(); /* make clock is low */ - DelayNs0500(); - SDA_HIGH(); /* disable data line - listen for ack */ -#if I2C_TM_SCL_TO_DATA>0 - DelayUs( I2C_TM_SCL_TO_DATA ); /* SCL low to data out valid */ -#endif - SCL_HIGH(); /* float clock high */ -#if I2C_TM_DATA_SU>0 - DelayUs( I2C_TM_DATA_SU ); -#endif - ack = SDA; /* read the acknowledge */ - - /* wait for slave to release clock line after processing byte */ -#if I2C_TM_SCL_TMO>0 - if ( i2c_WaitForSCL() ) - return I2C_ERROR; -#endif - return ack; -} - -/* - * Read a byte from the slave - * - returns the byte, or I2C_ERROR if a bus error - */ - -I2C_EXPORT int i2c_ReadByte( void ) -{ - BYTE n = 8; - BYTE byte = 0; - - while ( n-- ) - { - SCL_LOW(); /* drive clock low */ -#if I2C_TM_SCL_LOW>0 - DelayUs( I2C_TM_SCL_LOW ); /* min clock low period */ -#endif - SDA_HIGH(); /* release data line */ - SCL_HIGH(); /* float clock high */ -#if I2C_TM_SCL_TMO>0 - if ( i2c_WaitForSCL() ) - return I2C_ERROR; -#endif -#if I2C_TM_SCL_HIGH>0 - DelayUs( I2C_TM_SCL_HIGH ); -#endif - byte <<= 1; /* read the next bit */ - byte |= SDA; - } - return ( int ) byte; -} - -/* - * Send an (~)acknowledge to the slave - * - status of I2C_LAST implies this is the last byte to be sent - */ - -I2C_EXPORT void i2c_SendAcknowledge( BYTE status ) -{ - SCL_LOW(); - if ( status & 0x01 ) - { - SDA_LOW(); /* drive line low -> more to come */ - } - else - { - SDA_HIGH(); - } -#if I2C_TM_DATA_SU>0 - DelayUs( I2C_TM_DATA_SU ); -#endif - SCL_HIGH(); /* float clock high */ -#if I2C_TM_SCL_HIGH>0 - DelayUs( I2C_TM_SCL_HIGH ); -#endif - return; -} - -/* - * Send a byte to the slave and acknowledges the transfer - * - returns I2C_ERROR, ack or ~ack - */ - -I2C_EXPORT CHAR i2c_PutByte( BYTE data ) -{ - if ( i2c_SendByte( data ) ) - return I2C_ERROR; - return i2c_ReadAcknowledge(); /* returns ack, ~ack */ -} - -/* - * Get a byte from the slave and acknowledges the transfer - * - returns true on I2C_ERROR or byte - */ - -I2C_EXPORT int i2c_GetByte( BYTE more ) -{ - int byte; - - if ( ( byte = i2c_ReadByte() ) == I2C_ERROR ) - return I2C_ERROR; - - i2c_SendAcknowledge( more ); -#if I2C_TM_PUT_FUDGE>0 - DelayUs( I2C_TM_PUT_FUDGE ); -#endif - - return byte; -} - -#ifdef I2C_STRING -/* - * Send an array of bytes to the slave and acknowledges the transfer - * - returns number of bytes not successfully transmitted - */ -I2C_EXPORT int i2c_PutString( const BYTE * str, BYTE length ) -{ - CHAR error; - - while ( length ) - { - if ( ( error = i2c_PutByte( *str++ ) ) == I2C_ERROR ) - return -( int ) length; /* bus error */ - else if ( error ) - return ( int ) length; /* non acknowledge */ - length--; - } - - return FALSE; /* everything OK */ -} - -/* - * Reads number bytes from the slave, stores them at str and acknowledges the transfer - * - returns number of bytes not successfully read in - */ - -I2C_EXPORT BYTE i2c_GetString( BYTE * str, BYTE number ) -{ - int byte; - - while ( number ) - { - if ( ( byte = i2c_GetByte( number - 1 ) ) == I2C_ERROR ) - return number; /* bus error */ - else - *str++ = ( BYTE ) byte; - number--; - } - - return FALSE; /* everything OK */ -} -#endif - -/* - * Opens communication with a device at address. mode - * indicates I2C_READ or I2C_WRITE. - * - returns TRUE if address is not acknowledged - */ - -I2C_EXPORT BYTE i2c_Open( BYTE address, BYTE mode ) -{ - i2c_Start(); - i2c_SendAddress( address, mode ); - if ( i2c_ReadAcknowledge() ) - return TRUE; - - return FALSE; -} - -/* - * wait for the clock line to be released by slow slaves - * - returns TRUE if SCL was not released after the - * time out period. - * - returns FALSE if and when SCL released - */ - -#if I2C_TM_SCL_TMO>0 -I2C_EXPORT BYTE i2c_WaitForSCL( void ) -{ - /* SCL_DIR should be input here */ - WORD d = I2C_TM_SCL_TMO; - - while ( d-- ) - { - if ( SCL ) - return FALSE; - DelayNs1000(); - } - return TRUE; -} -#endif - -#endif diff --git a/src/libPIC/i2c_bitbang.h b/src/libPIC/i2c_bitbang.h deleted file mode 100644 index 82a4cdb..0000000 --- a/src/libPIC/i2c_bitbang.h +++ /dev/null @@ -1,52 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * I2C BitBang Master - *---------------------------------------------------------------------------- - * Not very reliable -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _I2C_BITBANG_H_ -#define _I2C_BITBANG_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - - - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/i2c_master.c b/src/libPIC/i2c_master.c deleted file mode 100644 index f3dddb9..0000000 --- a/src/libPIC/i2c_master.c +++ /dev/null @@ -1,265 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC I2C Master - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "flash.h" -#include "inter.h" - -#include "i2c_slave.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -#ifndef _PIC18 -#define DA STAT_DA -#define RW STAT_RW -#define SSPCON1 SSPCON -#endif - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -// RX -static volatile BYTE *pbyRxBuf = NULL; // pointer to buffer -static volatile BYTE *pbyRxPtr = NULL; // input pointer -static LIBBANK volatile BYTE byRxCount = 0;// input counter -static LIBBANK volatile BYTE byRxSize = 0; // size of buffer -static LIBBANK volatile BYTE byLastRxByte = 0; - -// TX -static volatile BYTE *pbyTxBuf = NULL; // pointer to buffer -static volatile BYTE *pbyTxPtr = NULL; // output pointer -static LIBBANK volatile BYTE byTxCount = 0;// output counter -static LIBBANK volatile BYTE byTxSize = 0; // size of buffer -static LIBBANK volatile BYTE byTxMax = 0; - -// misc -volatile LIBBANK BYTE byCheckSum = 0; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -/* c functions ---------------------------------------------------------*/ - -BYTE I2C_bufferSlave( BYTE byAddress ) -{ - // I2C init here - // need to double check this, MSSP port is different than old SSP port?? - // sspstat was read only? - no action needed - //'do not try to clear sspcon 4 so as to enable clock stretching? - // 'bit0 of SSPADD is R/W, with 0=a write to this device - // need to set tris registers too - // need to enable interrupts - - SSPIE = 0; // disable interrupt while configuring - TRISC |= 0b00011000; // make sure RC3 and RC4 are tristated - SSPCON1 = 0b00110110; // Configure SSP as I2C Slave and enable (with 7 bit address) - SSPCON2 = 0b10000001; // Enable rx broadcast and enable rx, clock stretching - SSPSTAT = 0; // set to normal I2C specifications - SSPADD = byAddress; // set node address - SSPIF = 0; // clear interrupt flag - SSPIE = 1; // enable SSP interrupt -#ifdef _PIC18 - SSPIP = 1; // high priority -#endif - bI2CRxBusy = 0; - bI2CRxDone = 0; - bI2CTxBusy = 0; - bI2CTxDone = 0; - - return TRUE; -} - -BYTE I2C_setRxBuffer( BYTE *pbyBuf, BYTE maxBuf ) -{ - BYTE byRC = 1; - if ( bI2CRxBusy ) - { - byRC = 0; - } - else - { - pbyRxBuf = pbyRxPtr = pbyBuf; - byRxSize = maxBuf; - byRxCount = 0; - bI2CRxBusy = 0; - bI2CRxDone = 0; - } - return byRC; -} - -BYTE I2C_getRxCount( void ) -{ - return byRxCount; -} - -BYTE I2C_setTxBuffer( BYTE *pbyBuf, BYTE maxBuf ) -{ - BYTE byRC = 1; - if ( bI2CTxBusy ) - { - byRC = 0; - } - else - { - pbyTxBuf = pbyTxPtr = pbyBuf; - byTxSize = byTxMax = maxBuf; - byTxCount = 0; - bI2CTxBusy = 0; - bI2CTxDone = 0; - } - return byRC; -} - -BYTE I2C_getTxCount( void ) -{ - return byTxCount; -} - -// high priority communications interrupt -void I2C_buffer_handler( void ) -{ - // must be SSP interrupt - if ( !SSPIF ) - return; - SSPOV = 0; // clear errors - CKP = 0; - - if ( DA == 0 ) //sspstat data/addr bit - { - // previous checksum - byCheckSum = 0; // zap checksum - - // we've got an address (just read from SSPBUF) - if ( RW ) // sspstat r/w bit - { - // read request, start transmit buffer - pbyTxPtr = pbyTxBuf; - byTxSize = byTxMax; - byTxCount = 0; - - // send first byte - if ( byTxCount++ < byTxSize ) - SSPBUF = byCheckSum = *pbyTxPtr++; // send first - else - SSPBUF = 0; - - // busy till all sent - if ( byTxCount < byTxSize ) - { - bI2CTxBusy = 1; - bI2CTxDone = 0; - } - else - { - bI2CTxBusy = 0; - bI2CTxDone = 1; - } - // cancels receive - bI2CRxBusy = 0; - bI2CRxDone = 1; - } - else - { - byLastRxByte = SSPBUF; // fetch the address - - // write request, prep receive buffer - pbyRxPtr = pbyRxBuf; - byRxCount = 0; - bI2CRxBusy = 1; - bI2CRxDone = 0; - // cancels transmit - bI2CTxBusy = 0; - bI2CTxDone = 1; - } - } - else - { - if ( RW && bI2CTxBusy ) - { - // master reading what we buffered - if ( byTxCount++ < byTxSize ) - { - // put data, add to checksum - byCheckSum += *pbyTxPtr; - SSPBUF = *pbyTxPtr++; - } - else - { - // put checksum - SSPBUF = 256 - byCheckSum; - byCheckSum = 0; - } - - // filled? - if ( byTxCount >= byTxSize ) - { - bI2CTxBusy = 0; - bI2CTxDone = 1; - } - } - else if ( bI2CRxBusy ) - { - // fetch the byte (ok even if sending) - byLastRxByte = SSPBUF; - // add to checksum - byCheckSum += byLastRxByte; - - // slave reading the master - if ( byRxCount++ < byRxSize ) - *pbyRxPtr++ = byLastRxByte; // get data - - // filled? - if ( byRxCount >= byRxSize ) - bI2CRxDone = 1; - - // clean up - if ( bI2CRxDone ) - bI2CRxBusy = 0; - } - } - - CKP = 1; // we must release clock! - SSPIF = 0; // clear SSP interrupt flag - - TRISC |= 0b00011000; // make sure RC3 and RC4 are tristated - // EK not required per datasheet but the dash needed this too. -} diff --git a/src/libPIC/i2c_master.h b/src/libPIC/i2c_master.h deleted file mode 100644 index 3a9dd18..0000000 --- a/src/libPIC/i2c_master.h +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * I2C Hardware Master - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _I2C_MASTER_H_ -#define _I2C_MASTER_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - - - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/i2c_slave.c b/src/libPIC/i2c_slave.c deleted file mode 100644 index d93455c..0000000 --- a/src/libPIC/i2c_slave.c +++ /dev/null @@ -1,268 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC I2C Slave - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "i2c.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -// RX -static volatile BYTE *pbyRxBuf = NULL; // pointer to buffer -static volatile BYTE *pbyRxPtr = NULL; // input pointer -static near volatile BYTE byRxCount = 0;// input counter -static near volatile BYTE byRxSize = 0; // size of buffer -static near volatile BYTE byLastRxByte = 0; -volatile bit bRxBusy = 0; // busy receiving -volatile bit bRxDone = 0; // set when full - -// TX -static volatile BYTE *pbyTxBuf = NULL; // pointer to buffer -static volatile BYTE *pbyTxPtr = NULL; // output pointer -static near volatile BYTE byTxCount = 0;// output counter -static near volatile BYTE byTxSize = 0; // size of buffer -static near volatile BYTE byTxMax = 0; -volatile bit bTxBusy = 0; // busy sending -volatile bit bTxDone = 0; // set when done - -// misc -static near BYTE byTmp = 0; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -/* c functions ---------------------------------------------------------*/ - -BYTE I2C_initSlave( BYTE byAddress ) -{ - // I2C init here - - SSPIE = 0; // disable interrupt while configuring - TRISC |= 0b00011000; // make sure RC3 and RC4 are tristated - SSPCON1 = 0b00110110; // Configure SSP as I2C Slave and enable (with 7 bit address) - SSPCON2 = 0b10000001; // Enable rx broadcast and enable rx, clock stretching - SSPSTAT = 0; // set to normal I2C specifications - SSPADD = byAddress; // set node address - SSPIF = 0; // clear interrupt flag - SSPIE = 1; // enable SSP interrupt - SSPIP = 1; // high priority - - bRxBusy = 0; - bRxDone = 0; - bTxBusy = 0; - bTxDone = 0; - - return TRUE; -} - -BYTE I2C_setRxBuffer( BYTE *pbyBuf, BYTE maxBuf ) -{ - BYTE byRC = 1; - if ( bRxBusy ) - { - byRC = 0; - } - else - { - pbyRxBuf = pbyRxPtr = pbyBuf; - byRxSize = maxBuf; - byRxCount = 0; - bRxBusy = 0; - bRxDone = 0; - } - return byRC; -} - -BYTE I2C_getRxCount( void ) -{ - return byRxCount; -} - -void I2C_clrRxDone( void ) -{ - bRxDone = 0; -} - -BYTE I2C_setTxBuffer( BYTE *pbyBuf, BYTE maxBuf ) -{ - BYTE byRC = 1; - if ( bTxBusy ) - { - byRC = 0; - } - else - { - pbyTxBuf = pbyTxPtr = pbyBuf; - byTxSize = byTxMax = maxBuf; - byTxCount = 0; - bTxBusy = 0; - bTxDone = 0; - } - return byRC; -} - -BYTE I2C_getTxCount( void ) -{ - return byTxCount; -} - -void I2C_clrTxDone( void ) -{ - bTxDone = 0; -} - -// high priority communications interrupt -void I2CSlaveHandler( void ) -{ - // must be SSP interrupt - if ( !SSPIF ) - goto default_handler; - SSPOV = 0; // clear errors - CKP = 0; - - if ( DA == 0 ) - { - // we've got an address (just read from SSPBUF) - if ( RW ) - { - pbyTxPtr = pbyTxBuf; - byTxSize = byTxMax; - byTxCount = 0; - - // send first byte - if ( byTxCount++ < byTxSize ) - SSPBUF = byCheckSum = *pbyTxPtr++; // send first - else - SSPBUF = 0; - - // busy till all sent - if ( byTxCount < byTxSize ) - { - bTxBusy = 1; - bTxDone = 0; - } - else - { - bTxBusy = 0; - bTxDone = 1; - } - // cancels receive - bRxBusy = 0; - bRxDone = 1; - } - else - { - byLastRxByte = SSPBUF; // fetch the address - - // write request, prep receive buffer - pbyRxPtr = pbyRxBuf; - byRxCount = 0; - byCmdByte = 0; - byCfgByte = 0xff; - bRxBusy = 1; - bRxDone = 0; - // cancels transmit - bTxBusy = 0; - bTxDone = 1; - } - } - else - { - if ( RW && bTxBusy ) - { - // generic transmit - if ( bTxCalib ) - { - pbyTxPtr = (BYTE*)&ezCalib; - byTxSize = sizeof(ezCalib)+1; - bTxCalib = 0; - } - - // master reading what we buffered - if ( byTxCount++ < byTxSize ) - { - // put data, add to checksum - byCheckSum += *pbyTxPtr; - SSPBUF = *pbyTxPtr++; - } - else - { - // put checksum - SSPBUF = 256 - byCheckSum; - byCheckSum = 0; - } - - // filled? - if ( byTxCount >= byTxSize ) - { - bTxBusy = 0; - bTxDone = 1; - } - } - else if ( bRxBusy ) - { - // fetch the byte (ok even if sending) - byLastRxByte = SSPBUF; - // add to checksum - byCheckSum += byLastRxByte; - - // slave reading the master - if ( byRxCount++ < byRxSize ) - *pbyRxPtr++ = byLastRxByte; // get data - - // filled? - if ( byRxCount >= byRxSize ) - bRxDone = 1; - - // clean up - if ( bRxDone ) - bRxBusy = 0; - } - } - - CKP = 1; // we must release clock! - SSPIF = 0; // clear SSP interrupt flag - - TRISC |= 0b00011000; // make sure RC3 and RC4 are tristated -} diff --git a/src/libPIC/i2c_slave.h b/src/libPIC/i2c_slave.h deleted file mode 100644 index 975e141..0000000 --- a/src/libPIC/i2c_slave.h +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * I2C Hardware Slave - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _I2C_SLAVE_H_ -#define _I2C_SLAVE_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - - - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/inter16.c b/src/libPIC/inter16.c deleted file mode 100644 index 8a8e661..0000000 --- a/src/libPIC/inter16.c +++ /dev/null @@ -1,231 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Generic 18F Interrupt Handler - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "timers.h" -#include "period.h" -#include "portb.h" -#include "serial.h" -#include "queue.h" - -#if defined(INTER_MODULE) && !defined(_PIC18) -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -LIBBANK static volatile long_dword intTemp; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void InterruptInit( void ) -{ -#ifdef RB0_PIN - PortB0Init(); -#endif -#if defined(RB4_PIN) || defined(RB5_PIN) || defined(RB6_PIN) || defined(RB7_PIN) - PortB4567Init(); -#endif -#ifdef TIMER_MODULE - TimerInit(); -#endif -#ifdef PERIOD_MODULE - PeriodInit(); -#endif - PEIE = 1; - ei(); -} - -// 16F only -#ifndef INTER_HANDLER -void interrupt interrupt_handler( void ) -{ - // RB0 interrupt pin - if ( INTF ) - { - g_bRb0Flag = 1; - g_stCount0.w.h = g_wTimer1High; // high first so can check for change - g_stCount0.b.lh = TMR1H; - g_stCount0.b.ll = TMR1L; - if ( g_stCount0.w.h != intTimerH || g_stCount0.b.lh != TMR1H ) - { - g_stCount0.w.h = g_wTimer1High; - g_stCount0.b.lh = TMR1H; - g_stCount0.b.ll = TMR1L; - } - INTF = 0; - g_wCount0++; - } - - // Timer1 overflow -#ifdef TIMER1_INT - if ( TMR1IF ) - { - g_wTimer1High++; - TMR1IF = 0; - } -#endif - // Timer2 interrupt -#ifdef TIMER2_INT - if ( TMR2IF ) - { - g_dwTimer2++; - TMR2IF = 0; -#ifdef SW_TIMERS - if ( g_wTimers2[0] ) - g_wTimers2[0]--; -#if SW_TIMERS > 1 - if ( g_wTimers2[1] ) - g_wTimers2[1]--; -#endif -#if SW_TIMERS > 2 - if ( g_wTimers2[2] ) - g_wTimers2[2]--; -#endif -#if SW_TIMERS > 3 - if ( g_wTimers2[3] ) - g_wTimers2[3]--; -#endif -#endif - } -#endif - - // RC2/CCP1 overflow -#ifdef CCP1_PIN - if ( CCP1IF ) - { - s_dwLast1 = s_stNext1.dw; // keep last reading - s_stNext1.w.h = g_wTimer1High; // high first so can check for change - s_stNext1.b.lh = CCPR1H; - s_stNext1.b.ll = CCPR1L; - if ( s_stNext1.w.h != g_wTimer1High || s_stNext1.b.lh != CCPR1H ) - { - s_stNext1.w.h = g_wTimer1High; - s_stNext1.b.lh = CCPR1H; - s_stNext1.b.ll = CCPR1L; - } - // keep this and last reading - s_dwSum1 += (s_stNext1.dw - s_dwLast1); - g_wPeriod1++; - CCP1IF = 0; - } -#endif -#ifdef CCP2_PIN - // RC1/CCP2 overflow - if ( CCP2IF ) - { - s_dwLast2 = s_stNext2.dw; // keep last reading - s_stNext2.w.h = g_wTimer1High; // high first so can check for change - s_stNext2.b.lh = CCPR2H; - s_stNext2.b.ll = CCPR2L; - if ( s_stNext2.w.h != g_wTimer1High || s_stNext2.b.lh != CCPR2H ) - { - s_stNext2.w.h = g_wTimer1High; - s_stNext2.b.lh = CCPR2H; - s_stNext2.b.ll = CCPR2L; - } - // keep this and last reading - s_dwSum2 += (s_stNext2.dw - s_dwLast2); - g_wPeriod2++; - CCP2IF = 0; - } -#endif - - // Port B 4-7 Changed - if ( !RBIF ) - return; - - // read bits, measure width -#ifdef RB4_PIN - if ( g_bRb4Flag != RB4 ) - { - // RB4 changed - if ( RB4 ) - g_wRb4Low = TMR1 - g_wRb4Last; // pulse width low - else - g_wRb4High = TMR1 - g_wRb4Last; // pulse width high - g_wRb4Last = TMR1; - g_bRb4Flag = RB4; - } -#endif -#ifdef RB5_PIN - if ( g_bRb5Flag != RB5 ) - { - // RB5 changed - if ( RB5 ) - g_wRb5Low = TMR1 - g_wRb5Last; // pulse width low - else - g_wRb5High = TMR1 - g_wRb5Last; // pulse width high - g_wRb5Last = TMR1; - g_bRb5Flag = RB5; - } -#endif -#ifdef RB6_PIN - if ( g_bRb6Flag != RB6 ) - { - // RB6 changed - if ( RB6 ) - g_wRb6Low = TMR1 - g_wRb6Last; // pulse width low - else - g_wRb6High = TMR1 - g_wRb6Last; // pulse width high - g_wRb6Last = TMR1; - g_bRb6Flag = RB6; - } -#endif -#ifdef RB7_PIN - if ( g_bRb7Flag != RB7 ) - { - // RB7 changed - if ( RB7 ) - g_wRb7Low = TMR1 - g_wRb7Last; // pulse width low - else - g_wRb7High = TMR1 - g_wRb7Last; // pulse width high - g_wRb7Last = TMR1; - g_bRb7Flag = RB7; - } - RBIF = 0; -#endif -} -#endif - -#endif diff --git a/src/libPIC/inter18.c b/src/libPIC/inter18.c deleted file mode 100644 index b1cd56d..0000000 --- a/src/libPIC/inter18.c +++ /dev/null @@ -1,116 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Generic 18F Interrupt Handler - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "timers.h" -#include "period.h" -#include "portb.h" - -#include "project.h" - -#if defined(INTER_MODULE) && defined(_PIC18) -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -bit bPowerFail = 0; - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -// initialize interrupts -void InterruptInit( void ) -{ -#ifdef RB0_PIN - PortB0Init(); -#endif -#if defined(RB1_PIN) || defined(RB2_PIN) - PortB12Init(); // app turns them on -#endif -#if defined(RB4_PIN) || defined(RB5_PIN) || defined(RB6_PIN) || defined(RB7_PIN) - PortB4567Init(); -#endif -#ifdef TIMER_MODULE - TimerInit(); -#endif -#ifdef PERIOD_MODULE - PeriodInit(); -#endif - GIE = PEIE = 1; - ei(); -} - -// callable handler -void InterruptHandler( void ) -{ - // default handler - if ( LVDIE && LVDIF ) - { - PowerfailHandler(); - bPowerFail = 1; - LVDIF = 0; - return; - } - bPowerFail = 0; - - // high priority only -#ifdef RB0_PIN - PortB0handler(); -#endif - // low priority default -#if defined(RB1_PIN) || defined(RB2_PIN) - PortB12Handler(); -#endif -#ifdef TIMER_MODULE - TimerHandler(); -#endif -#ifdef PERIOD_MODULE - PeriodHandler(); -#endif -#if defined(RB4_PIN) || defined(RB5_PIN) || defined(RB6_PIN) || defined(RB7_PIN) - PortB47Handler(); -#endif -} - -#endif diff --git a/src/libPIC/lin_period.c b/src/libPIC/lin_period.c deleted file mode 100644 index 9a82568..0000000 --- a/src/libPIC/lin_period.c +++ /dev/null @@ -1,164 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Linux PIC Period Emulation - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "period.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -// RC2/CCP1 flag, status and counters -#ifdef CCP1_PIN -volatile long_dword Period1; -LIBBANK volatile WORD wPeriod1 = 0; -extern LIBBANK volatile WORD wTimer1High; -#endif - -#ifdef CCP2_PIN -// RC1/CCP2 flag, status and counters -volatile long_dword Period2; -LIBBANK volatile WORD wPeriod2 = 0; -#endif - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -// RC2/CCP1 flag, status and counters -#ifdef CCP1_PIN -static LIBBANK volatile long_dword Next1; // current reading -static LIBBANK volatile DWORD dwLast1 = 0L; // last reading -static LIBBANK volatile DWORD dwSum1 = 0L; -static BYTE byDrop1 = 0xff; -static BYTE byZero1 = 0; -#endif - -#ifdef CCP2_PIN -// RC1/CCP2 flag, status and counters -static LIBBANK volatile long_dword Next2; // current reading -static LIBBANK volatile DWORD dwLast2 = 0L; // last reading -static LIBBANK volatile DWORD dwSum2 = 0L; -static BYTE byDrop2 = 0xff; -static BYTE byZero2 = 0; -#endif - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void PeriodInit( void ) -{ - wPeriod1 = 0; - wPeriod1 = 0; -} - -void PeriodHandler( void ) -{ -} - -void PeriodZero( BYTE byZ1, BYTE byZ2 ) -{ - byZero1 = byZ1; - byZero2 = byZ2; -} - -BYTE PeriodRead( void ) -{ - BYTE byFlag = 0; - - PeriodHandler(); - -#ifdef CCP1_PIN - if ( wPeriod1 ) - { - // current reading minus last reading for period -// CCP1IE = 0; - Period1.dw = dwSum1 / wPeriod1; - dwSum1 = wPeriod1 = 0; -// CCP1IE = 1; - byFlag |= 1; - byDrop1 = 0; - } - else - { - // drop zero - if ( byDrop1 < byZero1 ) - { - byDrop1++; // stopping - Period1.dw = 0; - } - else if ( byDrop1 == byZero1 ) - { - // stopped - byDrop1++; - byFlag |= 1; - Period1.dw = 0x7FFFFFFF; - } - } -#endif -#ifdef CCP2_PIN - if ( wPeriod2 ) - { - // current reading minus last reading for period -// CCP2IE = 0; - Period2.dw = dwSum2 / wPeriod2; - dwSum2 = wPeriod2 = 0; -// CCP2IE = 1; - byFlag |= 2; - byDrop2 = 0; - } - else - { - if ( byDrop2 < byZero2 ) - { - byDrop2++; // stopping - Period2.dw = 0; - } - else if ( byDrop2 == byZero2 ) - { - // stopped - byDrop2++; - byFlag |= 2; - Period2.dw = 0x7FFFFFFF; - } - } -#endif - return byFlag; -} - diff --git a/src/libPIC/lin_pin0.c b/src/libPIC/lin_pin0.c deleted file mode 100644 index 302fc79..0000000 --- a/src/libPIC/lin_pin0.c +++ /dev/null @@ -1,80 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Linux PIC Pin0 Emulation - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "inter.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -// external interrupt pin (RB0), flag and counter -volatile bit intFlag = 0; -volatile long_parts intCount; -volatile WORD intCounter = 0L; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void init_pin0( void ) -{ - intFlag = 0; - intCount.LN = 0L; - intCounter = 0L; -} - -void int0_pin_edge( BYTE byEdge ) -{ -} - -// high priority only -void int0_pin_handler( void ) -{ - // RB0 interrupt pin -// if ( INT0IF ) -// { -// intFlag = 1; -// intCount.LN = int_timer(); -// intCounter++; -// } -} diff --git a/src/libPIC/lin_pinx.c b/src/libPIC/lin_pinx.c deleted file mode 100644 index c6bde9f..0000000 --- a/src/libPIC/lin_pinx.c +++ /dev/null @@ -1,92 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Linux PIC Emulation - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "inter.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -volatile bit int1Flag = 0; -volatile WORD int1Counter = 0L; - -volatile bit int2Flag = 0; -volatile WORD int2Counter = 0L; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void init_pins( BYTE byPins ) -{ - if ( byPins & 1 ) - { - int1Flag = 0; - int1Counter = 0L; - } - - if ( byPins & 2 ) - { - int2Flag = 0; - int2Counter = 0L; - } -} - -void int_pins_edge( BYTE byEdge ) -{ -} - -void intx_pin_handler( void ) -{ -// if ( INT1IF ) -// { -// int1Flag = 1; -// int1Counter++; -// } - -// if ( INT2IF ) -// { -// int2Flag = 1; -// int2Counter++; -// } -} diff --git a/src/libPIC/lin_rb47.c b/src/libPIC/lin_rb47.c deleted file mode 100644 index 496937e..0000000 --- a/src/libPIC/lin_rb47.c +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Linux PIC RB47 Emulation - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "inter.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -// not good for long pulses -volatile bit bRb4; -volatile WORD int4High = 0L; -volatile WORD int4Low = 0L; -volatile WORD int4Last = 0L; -volatile bit bRb5; -volatile WORD int5High = 0L; -volatile WORD int5Low = 0L; -volatile WORD int5Last = 0L; - -// not good for long pulses -volatile bit bRb6; -volatile WORD int6High = 0L; -volatile WORD int6Low = 0L; -volatile WORD int6Last = 0L; -volatile bit bRb7; -volatile WORD int7High = 0L; -volatile WORD int7Low = 0L; -volatile WORD int7Last = 0L; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void init_rb47( void ) -{ -} - -// 18F callable -void int_rb47_handler( void ) -{ -} diff --git a/src/libPIC/lin_timer.c b/src/libPIC/lin_timer.c deleted file mode 100644 index 036e5fd..0000000 --- a/src/libPIC/lin_timer.c +++ /dev/null @@ -1,114 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Linux Timer Emulation - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include -#include - -#include "system.h" -#include "timers.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -// Timer #1 -volatile long_dword Timer1; - -// Timer #2 -volatile DWORD dwTimer2; -volatile WORD wTimers2[SW_TIMERS] = { 0 }; - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -// Timer #2 -static DWORD dwLastClock = 0; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void TimerInit( void ) -{ - int i; - - for ( i=0 ; i<4 ; i++ ) - MsecTimerSet( i, 0 ); - - Timer1Clear(); - - Timer2Clr(); -} - -void TimerHandler( void ) -{ - DWORD dwMsec; - int i; - - // timer - Timer1.dw = clock() * 625L / 1000L; - - // clock - dwTimer2 = clock() / 1000L; - - // every msec, decrement timers - if ( dwMsec = dwTimer2 - dwLastClock ) - { - for ( i=0 ; i<4 ; i++ ) - { - if ( wTimers2[i] ) - wTimers2[i] -= dwMsec; - } - - // save last reading - dwLastClock = dwTimer2; - } -} - -void Timer1Clear( void ) -{ - Timer1.dw = 0L; -} - -DWORD Timer1Read( void ) -{ - TimerHandler(); - - return Timer1.dw; -} diff --git a/src/libPIC/memio.c b/src/libPIC/memio.c deleted file mode 100644 index 0a98eea..0000000 --- a/src/libPIC/memio.c +++ /dev/null @@ -1,403 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Linux Memory Emulation Driver - *---------------------------------------------------------------------------- - * Uses file for non-volatile storage. -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _MEMIO_C_ -#define _MEMIO_C_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#ifdef MEMORY_EMUL -#include -#include -#include -#endif - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -#ifdef MEMORY_EMUL -static FILE *pDev = NULL; // block device or file -#endif - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ -#ifdef MEMORY_EMUL - -static int EmulOpenFile( char *pszFile ) -{ - BYTE byData[1024]; - int i, n; - - if ( pDev ) - return 1; - - // check file existence - if ( access( pszFile, F_OK ) != 0 ) - { - // create file if missing - if ( pDev = fopen( pszFile, "wb" ) ) - { - // zap - memset( byData, 0, sizeof(byData) ); - - n = MemGetSize(); - while ( n ) - { - if ( n < sizeof(byData) ) - i = n; - else - i = sizeof(byData); - - fwrite( byData, 1, i, pDev ); - n -= i; - } - fclose( pDev ); - } - else - return 0; - } - - // open file for reading/writing - if ( pDev = fopen( pszFile, "r+b" ) ) - { - fseek( pDev, 0, SEEK_SET ); - return 1; - } - return 0; -} - -// close -static void EmulCloseFile( void ) -{ - if ( pDev ) - fclose( pDev ); -} - -// init -static void DevInit( void ) -{ - EmulOpenFile( MEMORY_FILE ); - MemSetSize( MEMORY_SIZE ); - MemSetProtect(0); -} - -// map byte i/o -static BYTE DevReadByte( ATYPE xAddr ) -{ - if ( pDev ) - { - return fgetc( pDev ); - } - return 0; -} - -static void DevWriteByte( ATYPE xAddr, BYTE byData ) -{ - if ( pDev ) - { - fputc( byData, pDev ); - } -} - -// hardware i/o -static STYPE DevStartRead( ATYPE xAddr, STYPE nBytes ) -{ - int n; - - // create file - if ( pDev ) - { - if ( fseek( pDev, xAddr, SEEK_SET ) == 0 ) - return nBytes; - } - return 0; -} - -static void DevStopRead( void ) -{ - if ( pDev ) - fflush( pDev ); -} - -static STYPE DevStartWrite( ATYPE xAddr, STYPE nBytes ) -{ - // create file - if ( pDev ) - { - if ( fseek( pDev, xAddr, SEEK_SET ) == 0 ) - return nBytes; - } - return 0; -} - -static void DevStopWrite( void ) -{ - if ( pDev ) - fflush( pDev ); -} - -#endif - -#define MT_Init(NAME) \ -void NAME ## Init( void ) \ -{ \ - DevInit(); \ -} - -#define MT_GetChecksum(NAME) \ -BYTE NAME ## GetChecksum( void ) \ -{ \ - return MemGetChecksum(); \ -} - -#define MT_GetError(NAME) \ -BYTE NAME ## GetError( void ) \ -{ \ - return MemGetError(); \ -} - -#define MT_GetSize(NAME) \ -ATYPE NAME ## GetSize( void ) \ -{ \ - return MemGetSize(); \ -} - -#define MT_ReadBlock(NAME) \ -STYPE NAME ## ReadBlock( ATYPE wAddr, STYPE nBytes ) \ -{ \ - MemStopBlock(); \ - \ - if ( MemStartRead( wAddr, nBytes ) ) \ - { \ - MemStartBlock( wAddr, nBytes ); \ - MemClrChecksum(); \ - return nBytes; \ - } \ - MemStartBlock( 0, 0 ); \ - MemSetError( MEM_ERR_BOUNDARY ); \ - return 0; \ -} - -#define MT_WriteBlock(NAME) \ -STYPE NAME ## WriteBlock( ATYPE wAddr, STYPE nBytes ) \ -{ \ - MemStopBlock(); \ -\ - if ( MemStartWrite( wAddr, nBytes ) ) \ - { \ - MemStartBlock( wAddr, nBytes ); \ - MemClrChecksum(); \ - return nBytes; \ - } \ - MemStartBlock( 0, 0 ); \ - MemSetError( MEM_ERR_BOUNDARY ); \ - return 0; \ -} - -#define MT_SkipNext(NAME) \ -void NAME ## SkipNext( STYPE nBytes ) \ -{ \ - if ( MemBytesCheck( nBytes ) ) \ - { \ - MemBlockBytes( nBytes ); \ - } \ - else \ - MemSetError( MEM_ERR_OVERFLOW ); \ -} - -// -// The byte i/o work is done here -// -#define MT_ReadNext(NAME) \ -BYTE NAME ## ReadNext( void ) \ -{ \ - BYTE byData; \ -\ - if ( MemDecrLen() ) \ - { \ - byData = DevReadByte( MemGetAddr() ); \ - MemIncrAddr(); \ - MemAddChecksum( byData ); \ - if ( !MemGetLen() ) \ - MemStopRead(); \ - return byData; \ - } \ - MemSetError( MEM_ERR_OVERFLOW ); \ - return 0; \ -} - -#define MT_ReadBytes(NAME) \ -STYPE NAME ## ReadBytes( BYTE *pbyData, STYPE nBytes ) \ -{ \ - STYPE nRead = 0; \ - BYTE byData; \ -\ - if ( !MemBytesCheck( nBytes ) ) \ - { \ - nBytes = MemGetLen(); \ - MemSetError( MEM_ERR_OVERFLOW ); \ - } \ - nRead = nBytes; \ -\ - while ( nBytes-- ) \ - { \ - byData = NAME ## ReadNext(); \ - if ( pbyData ) \ - *pbyData++ = byData; \ - } \ -\ - return nRead; \ -} - -#define MT_WriteNext(NAME) \ -void NAME ## WriteNext( BYTE byData ) \ -{ \ - if ( MemDecrLen() ) \ - { \ - DevWriteByte( MemGetAddr(), byData ); \ - MemIncrAddr();\ - MemAddChecksum( byData ); \ - if ( MemDoChecksum() && MemGetLen() == 1 ) \ - { \ - MemDecrLen(); \ - DevWriteByte( MemGetAddr(), 256 - MemGetChecksum() ); \ - MemIncrAddr(); \ - } \ - if ( !MemGetLen() ) \ - MemStopWrite(); \ - return; \ - } \ -\ - MemSetError( MEM_ERR_OVERFLOW ); \ -} - -#define MT_WriteBytes(NAME) \ -STYPE NAME ## WriteBytes( const BYTE *pbyData, STYPE nBytes ) \ -{ \ - STYPE nWrite = 0; \ -\ - if ( !MemBytesCheck( nBytes ) ) \ - { \ - nBytes = MemGetLen(); \ - MemSetError( MEM_ERR_OVERFLOW ); \ - } \ - nWrite = nBytes; \ -\ - if ( pbyData ) \ - { \ - while ( nBytes-- ) \ - NAME ## WriteNext( *pbyData++ ); \ - } \ - else if ( MemDoChecksum() ) \ - { \ - while ( --nBytes ) \ - NAME ## ReadNext(); \ - NAME ## WriteNext( 0 ); \ - } \ -\ - return nWrite; \ -} - -// -// The data i/o work is done here -// -#define MT_ReadData(NAME) \ -STYPE NAME ## ReadData( ATYPE wAddr, BYTE *pbyData, STYPE nBytes ) \ -{ \ - if ( NAME ## ReadBlock( wAddr, nBytes ) ) \ - return NAME ## ReadBytes( pbyData, nBytes ); \ - return 0; \ -} - -#define MT_WriteData(NAME) \ -STYPE NAME ## WriteData( ATYPE wAddr, const BYTE *pbyData, STYPE nBytes ) \ -{ \ - if ( NAME ## WriteBlock( wAddr, nBytes ) ) \ - { \ - MemDisChecksum(); \ - return NAME ## WriteBytes( pbyData, nBytes ); \ - } \ - return 0; \ -} - -#define MT_ReadCSData(NAME) \ -STYPE NAME ## ReadCSData( ATYPE wAddr, BYTE *pbyData, STYPE nBytes ) \ -{ \ - if ( NAME ## ReadData( wAddr, pbyData, nBytes ) ) \ - { \ - if ( MemGetChecksum() == 0 ) \ - return nBytes; \ - return (STYPE)0xFFFFFFFF; \ - } \ - return 0; \ -} - -#define MT_WriteCSData(NAME) \ -STYPE NAME ## WriteCSData( ATYPE wAddr, const BYTE *pbyData, STYPE nBytes ) \ -{ \ - if ( NAME ## WriteBlock( wAddr, nBytes ) ) \ - { \ - MemEnaChecksum(); \ - return NAME ## WriteBytes( pbyData, nBytes ); \ - } \ - return 0; \ -} - -#define MT_WriteFill(NAME) \ -STYPE NAME ## WriteFill( ATYPE wAddr, BYTE byFill, STYPE nBytes ) \ -{ \ - int nWrite = nBytes; \ -\ - if ( NAME ## WriteBlock( wAddr, nBytes ) ) \ - { \ - while ( MemDecrLen() ) \ - { \ - DevWriteByte( MemGetAddr(), byFill ); \ - MemIncrAddr(); \ - } \ - return nWrite; \ - } \ - return 0; \ -} - -#endif diff --git a/src/libPIC/memio.h b/src/libPIC/memio.h deleted file mode 100644 index b2ff74c..0000000 --- a/src/libPIC/memio.h +++ /dev/null @@ -1,179 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Internal Memory Interface Template - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _MEMORY_H_ -#define _MEMORY_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -#ifdef MEMORY_DEBUG -#define MEMORY_ERROR -#endif - -// flags -#define MEM_DO_CHECKSUM 1 - -// error bits -#define MEM_ERR_BOUNDARY 1 // out of bounds block -#define MEM_ERR_UNDERFLOW 2 // didn't finish last block -#define MEM_ERR_OVERFLOW 4 // overflowed last block -#define MEM_ERR_CHECKSUM 8 // bad checksum -#define MEM_ERR_WRITE 16 // write failed -#define MEM_ERR_MEDIA 32 // removable media error - -// default address and size types -#ifndef ATYPE -#define ATYPE WORD -#endif - -#ifndef STYPE -#define STYPE WORD -#endif - -/***************************************************************************** - * macros -*****************************************************************************/ - -#ifdef MEMORY_SIZE -#define MemSetSize(S) -#define MemGetSize() MEMORY_SIZE -#else -#define MemSetSize(S) MemCtrl.xMemSize=(S) -#define MemGetSize() MemCtrl.xMemSize -#endif - -#ifdef READ_PROTECT -#define MemReadCheck(A,S) ((A)+(S)<=MemGetSize()) -#define MemStartRead(A,S) (MemReadCheck(A,S) && DevStartRead(A,S)) -#else -#define MemStartRead(A,S) DevStartRead(A,S) -#endif - -#ifdef WRITE_PROTECT -#define MemSetProtect(A) MemCtrl.xMemProt=(A) -#define MemWriteCheck(A,S) ((A)>=MemCtrl.xMemProt) -#define MemStartWrite(A,S) (MemWriteCheck(A,S) && MemReadCheck(A,S) && DevStartWrite(A,S)) -#else -#ifdef READ_PROTECT -#define MemStartWrite(A,S) (MemReadCheck(A,S) && DevStartWrite(A,S)) -#else -#define MemStartWrite(A,S) DevStartWrite(A,S) -#endif -#endif -#ifndef MemSetProtect -#define MemSetProtect(A) -#endif - -#define MemBytesCheck(N) ((N)<=MemCtrl.xBlockLen) - -#define MemStartBlock(A,S) {MemCtrl.xBlockAddr=(A);MemCtrl.xBlockLen=(S);} -#ifdef MEMORY_ERROR -#define MemStopBlock() if(MemCtrl.xBlockLen)MemSetError(MEM_ERR_UNDERFLOW) -#define MemStopRead() {DevStopRead();MemStopBlock();} -#define MemStopWrite() {DevStopWrite();MemStopBlock();} -#else -#define MemStopBlock() -#define MemStopRead() DevStopRead() -#define MemStopWrite() DevStopWrite() -#endif - -#define MemGetAddr() MemCtrl.xBlockAddr -#define MemGetLen() MemCtrl.xBlockLen -#define MemIncrAddr() MemCtrl.xBlockAddr++ -#define MemDecrLen() MemCtrl.xBlockLen-- -#define MemSetLen -#define MemBlockNext() {MemCtrl.xBlockAddr++;MemCtrl.xBlockLen--;} -#define MemBlockBytes(B) {MemCtrl.xBlockAddr+=(B);MemCtrl.xBlockLen-=(B);} - -#define MemEnaChecksum() MemCtrl.byMemFlag|=MEM_DO_CHECKSUM -#define MemDisChecksum() MemCtrl.byMemFlag&=~MEM_DO_CHECKSUM -#define MemDoChecksum() (MemCtrl.byMemFlag & MEM_DO_CHECKSUM) -#define MemClrChecksum() MemCtrl.byCheckSum=0 -#define MemAddChecksum(B) MemCtrl.byCheckSum+=(B) -#define MemGetChecksum() MemCtrl.byCheckSum - -#ifdef MEMORY_ERROR -#define MemClrError() MemCtrl.byErrorFlag=0 -#define MemSetError(E) MemCtrl.byErrorFlag|=(E) -#define MemGetError() MemCtrl.byErrorFlag -#else -#define MemClrError() -#define MemSetError(E) -#define MemGetError() 0 -#endif - -#ifdef WRITE_COUNTING -#define MemIncrCount() MemCtrl.dwWriteCount++ -#define MemClearCount() MemCtrl.dwWriteCount=0 -#define MemGetCount() MemCtrl.dwWriteCount -#define MemSetCount(C) MemCtrl.dwWriteCount=(C) -#else -#define MemIncrCount() -#define MemClearCount() -#define MemGetCount() 0 -#define MemSetCount(C) -#endif - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -typedef struct _MindCtrl { - ATYPE xBlockAddr; // start of current block - STYPE xBlockLen; // remaining length of current block - BYTE byMemFlag; - BYTE byCheckSum; // checksum of current block -#if defined(READ_PROTECT) && !defined(MEMORY_SIZE) - ATYPE xMemSize; // end read/write region (size) -#endif -#ifdef WRITE_PROTECT - ATYPE xMemProt; // begin write region -#endif -#ifdef MEMORY_ERROR - BYTE byErrorFlag; // last error -#endif -#ifdef WRITE_COUNTING - DWORD dwWriteCount; // write counts -#endif -} MindCtrl; - -/***************************************************************************** - * global constants -*****************************************************************************/ - -// memory block control structure -static near MindCtrl MemCtrl = { 0 }; - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - - - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/packet.h b/src/libPIC/packet.h deleted file mode 100644 index d71a544..0000000 --- a/src/libPIC/packet.h +++ /dev/null @@ -1,293 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Packet Interface - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _PACKET_H_ -#define _PACKET_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#if defined (__linux__) -// Linux, for testing -#include -#include -#ifndef BYTE -#define BYTE u_char -#define WORD u_short -#define UINT u_int -#define DWORD u_long -#endif -#define PKTBANK -#define DelayUs(X) usleep(X) -#define DelayMs(X) usleep((X)*1000) -#elif defined(_WINDOWS) -#define PKTBANK -#define DelayUs(X) _sleep((X)/1000) -#define DelayMs(X) _sleep(X) -#define usleep(X) _sleep((X)/1000) -#else -// PIC -#define PIC_PACKET -#include "system.h" -#include "types.h" -#include "serial.h" -#endif - -/***************************************************************************** - * defines -*****************************************************************************/ - -// -// Packet Synchonization Header -// -#ifndef PACKET_SYNC_LENGTH -#define PACKET_SYNC_LENGTH 3 // minimum of 2, includes padding and sync char -#endif -#ifndef PACKET_SYNC_PAD -#define PACKET_SYNC_PAD 0xFF -#endif -#ifndef PACKET_SYNC_CHAR -#define PACKET_SYNC_CHAR 0x00 -#endif -#ifndef PACKET_RECV_SYNC -#define PACKET_RECV_SYNC PACKET_SYNC_PAD -#endif -#ifndef PACKET_XMIT_SYNC -#define PACKET_XMIT_SYNC PACKET_SYNC_PAD -#endif - -// -// Packet Identification (required with radio) -// -#if (defined(RADIO_BIDI) || defined(RADIO_UNI)) && !defined(PACKET_IDENT) -#define PACKET_IDENT // required for radio, packet ids -#undef PACKET_ID_SIZE -#undef PACKET_CK_SIZE -#define PACKET_ID_SIZE 2 // ID -#define PACKET_CK_SIZE 1 // CRC default? -#endif - -// -// Packet Identification Size (defaults) -// -#ifndef PACKET_ID_SIZE -#define PACKET_ID_SIZE 2 // default -#endif - -// -// Packet Flag -// -#define PACKET_FLAG_USER1 0x01 -#define PACKET_FLAG_USER2 0x02 -#define PACKET_FLAG_USER3 0x04 -#define PACKET_FLAG_USER4 0x08 -#define PACKET_FLAG_CRC 0x10 -#define PACKET_FLAG_STREAM 0x80 - - -// -// Packet Streaming Control -// -#ifdef PACKET_STREAM -#define PACKET_FL_SIZE 1 -#ifdef PACKET_LARGE -#define PACKET_MAX_STREAM 0x8000 -#else -#define PACKET_MAX_STREAM 0x80 -#endif -#else -#define PACKET_FL_SIZE 0 -#define PACKET_FLAG_STREAM 0x80 -#define PACKET_MAX_STREAM 0x80 -#endif - -// -// Packet Buffer Size -// -#ifdef PACKET_LARGE -#define PACKET_BC_SIZE 2 // 32767 byte packets max (too big for normal apps) -#define PACKET_MAX_PACKET 0xffff -#else -#define PACKET_BC_SIZE 1 // 255 byte packets max -#define PACKET_MAX_PACKET 0xff -#endif - -// -// Checksum/CRC Size -// -#ifndef PACKET_CK_SIZE -#define PACKET_CK_SIZE 1 // 1 = 8 bit checksum, 2 = 16 bit CRC -#endif - -// -// serial errors included -// -#define PACKET_ERR_DEVICE -1 -#define PACKET_ERR_TIMEOUT -2 -#define PACKET_BAD_PACKET -3 -#define PACKET_BAD_CHECKSUM -4 -#define PACKET_BUF_TOOBIG -5 -#define PACKET_BUF_OVERWRITE -6 -#define PACKET_ERR_SEQUENCE -7 -#define PACKET_ERR_STREAM -8 -#define PACKET_ERR_NOISE -9 -#define PACKET_ERR_ALIEN -10 - -// -// Character timeouts -// -#define TIMEOUT 50 - -// -// Serial Data Rate -// -#ifndef BAUD -#if defined(RADIO_BIDI) -#define BAUD 19200L -#elif defined(RADIO_UNI) -#define BAUD 38400L -#else -#define BAUD 57600L -#endif -#endif -#define PACKET_CHAR_TIME ((1000000L*10L)/BAUD) // usec time, 1 start, 8 bits, 1 stop - -// -// Radio Packet Handling -// -#if defined(RADIO_UNI) && defined(RADIO_BIDI) -#error You cannot choose both unidirectional and bidirectional radio packet handling -#endif -#if defined(RADIO_UNI) || defined(RADIO_BIDI) -#define RADIO -#endif -// worst case (PC RX->TX, PIC TX->RX) wait timeout -#define PACKET_WAIT_TIME 5000L // time to wait for packet -// worst case (PC TX->RX, PIC RX->TX) -#define PACKET_SWITCH_TIME 8000L -#define RADIO_NOCHAR_TIME 5000L // PC xmit timeout (worst case) -#define PACKET_NOCHAR_TIME RADIO_NOCHAR_TIME - -// padding needed to allow resync between consecutive packets -#define PACKET_RESYNC_LENGTH (PACKET_SYNC_LENGTH+1) -// padding needed which switching direction, plus sync chars -#define PACKET_HEADER_LENGTH ((PACKET_SWITCH_TIME/PACKET_CHAR_TIME)+PACKET_RESYNC_LENGTH+1) -#define PACKET_TRAILER_LENGTH 1 // sacrificed to TX->RX switch - -// radio direction control -#define RADIO_DISABLE 0xff -#define RADIO_OFF 0 // no radio -#define RADIO_LISTEN 1 -#define RADIO_TALK 2 -#define RADIO_DIRECT 3 // direct connect override / no radio - -// -// Packet Lengths (sync+id+flag+bc+checksum) -// -#define PACKET_LENGTH (PACKET_SYNC_LENGTH+PACKET_ID_SIZE+PACKET_FL_SIZE+PACKET_BC_SIZE+PACKET_CK_SIZE) - -/***************************************************************************** - * macros -*****************************************************************************/ - -#ifdef SERIAL_RECV_BUFFER -// really can't do without it -#define PACKET_FILTER -#ifdef PACKET_IDENT -#define recvFilter(I) g_wPacketId=(I) -#else -#define recvFilter(I) g_wPacketId=0 -#endif -#define recvAvail() g_byPacketAvail -#endif - -#ifdef RADIO_BIDI -#define baudRadio(B) serial_baud(B) -#endif - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -#ifdef PACKET_FILTER -extern PKTBANK WORD g_wPacketId; -extern PKTBANK BYTE g_byPacketAvail; -#endif -extern PKTBANK bit g_bPacketCRC; - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -// Radio Control -extern BYTE getRadio( void ); -extern BYTE dirRadio( BYTE bXmit ); -extern void noRadio( void ); - -// Misc Utility -extern BYTE doCheckSum( const BYTE *pbyData, BYTE nBytes ); - -// Port Control -extern void PacketInit( void ); -extern void PacketHandler( void ); -#ifndef PIC_PACKET -extern int openPort( int iCom, int iBaud ); -extern int closePort( void ); -#endif - -// Receive Functions -extern int recvWait( UINT iWait ); -extern int recvHeader( WORD *pwCheck, WORD *pwId, BYTE *pbyFlag ); -extern int recvByte( WORD *pwCheck ); -extern int recvData( WORD *pwCheck, PKTBANK BYTE *pbyData, WORD nBytes, WORD maxBytes ); -extern int recvTrailer( WORD *pwCheck ); -extern void recvClear( BYTE nBytes ); -extern void recvFlush( void ); - -// Send Functions -extern void sendSynch( BYTE nBytes ); -extern void sendPadding( BYTE nBytes ); -extern void sendSpacing( BYTE nBytes ); -extern void sendHeader( WORD *pwCheckSum, WORD wId, BYTE byFlag, WORD nBytes ); -extern void sendByte( WORD *pwCheckSum, BYTE byByte ); -extern void sendData( WORD *pwCheckSum, const BYTE *pbyData, WORD nBytes ); -extern void sendTrailer( WORD *pwCheckSum ); -extern void sendFlush( void ); - -// All in One -extern int recvPacket( WORD *pwId, PKTBANK BYTE *pbyData, BYTE *pbyFlag, WORD maxBytes ); // all in one -extern int sendPacket( WORD wId, const BYTE *pbyData, WORD nBytes ); // all in one - -// Streaming Functions -extern int recvFinish( WORD nBytes ); -extern int recvSequence( WORD *pwId, WORD *pwCheck, BYTE *pbySeq ); -extern int recvStream( WORD wId, PKTBANK BYTE *pbyData, WORD nBytes ); -extern int readStream( WORD wMyBoxId, void(*put)(BYTE c), WORD wBytes ); - -extern int sendStream( WORD wId, const BYTE *pbyData, WORD nBytes ); -extern int writeStream( WORD wMyBoxId, BYTE(*get)(void), WORD wBytes ); - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/period.c b/src/libPIC/period.c deleted file mode 100644 index 725dbbf..0000000 --- a/src/libPIC/period.c +++ /dev/null @@ -1,237 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Period Counters - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "period.h" -#include "timers.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -// RC2/CCP1 flag, status and counters -#ifdef CCP1_PIN -volatile long_dword g_stPeriod1 = 0L; -LIBBANK volatile WORD g_wPeriod1 = 0; -extern LIBBANK volatile WORD g_wTimer1High; -#endif - -#ifdef CCP2_PIN -// RC1/CCP2 flag, status and counters -volatile long_dword g_stPeriod2 = 0L; -LIBBANK volatile WORD g_wPeriod2 = 0; -#endif - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -// RC2/CCP1 flag, status and counters -#ifdef CCP1_PIN -static LIBBANK volatile long_dword s_stNext1 = 0L; // current reading -static LIBBANK volatile DWORD s_dwLast1 = 0L; // last reading -static LIBBANK volatile DWORD s_dwSum1 = 0L; -static BYTE s_byDrop1 = 0xff; -static BYTE s_byZero1 = 0; -#endif - -#ifdef CCP2_PIN -// RC1/CCP2 flag, status and counters -static LIBBANK volatile long_dword s_stNext2 = 0L; // current reading -static LIBBANK volatile DWORD s_dwLast2 = 0L; // last reading -static LIBBANK volatile DWORD s_dwSum2 = 0L; -static BYTE s_byDrop2 = 0xff; -static BYTE s_byZero2 = 0; -#endif - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void PeriodInit( void ) -{ -#ifdef CCP1_PIN - RC2 = 0; - TRISC2 = 1; - CCP1IE = 1; -#ifdef _PIC18 - CCP1IP = 0; - CCP1CON |= 0x80; // RD16 -#endif - CCP1CON = 0b00000101; // default every rising edge - g_wPeriod1 = 0; -#endif - -#ifdef CCP2_PIN - RC1 = 0; - TRISC1 = 1; - CCP2IE = 1; -#ifdef _PIC18 - CCP2IP = 0; - CCP2CON |= 0x80; // 16 bit read/write -#endif - CCP2CON = 0b00000101; // default every rising edge - g_wPeriod2 = 0; -#endif - -#ifdef _PIC18 - // CCP1, CCP2 source - T3CCP1 = 0; -#if defined(_18F442) || defined(_18F452) - T3CCP2 = 0; -#endif -#endif -} - -#ifdef _PIC18 -void PeriodHandler( void ) -{ - // RC2/CCP1 overflow -#ifdef CCP1_PIN - if ( CCP1IF ) - { - s_dwLast1 = s_stNext1.dw; // keep last reading - s_stNext1.w.h = g_wTimer1High; // high first so can check for change - s_stNext1.w.l = CCPR1; - if ( s_stNext1.w.h != g_wTimer1High || s_stNext1.b.lh != CCPR1H ) - { - s_stNext1.w.h = g_wTimer1High; - s_stNext1.w.l = CCPR1; - } - // keep this and last reading - s_dwSum1 += (s_stNext1.dw - s_dwLast1); - g_wPeriod1++; - CCP1IF = 0; - } -#endif -#ifdef CCP2_PIN - // RC1/CCP2 overflow - if ( CCP2IF ) - { - s_dwLast2 = s_stNext2.dw; // keep last reading - s_stNext2.w.h = g_wTimer1High; // high first so can check for change - s_stNext2.w.l = CCPR2; - if ( s_stNext2.w.h != g_wTimer1High || s_stNext2.b.lh != CCPR2H ) - { - s_stNext2.w.h = g_wTimer1High; - s_stNext2.w.l = CCPR2; - } - // keep this and last reading - s_dwSum2 += (s_stNext2.dw - s_dwLast2); - g_wPeriod2++; - CCP2IF = 0; - } -#endif -} -#endif - - -void PeriodZero( BYTE byZero1, BYTE byZero2 ) -{ -#ifdef CCP1_PIN - s_byZero1 = byZero1; -#endif -#ifdef CCP2_PIN - s_byZero2 = byZero2; -#endif -} - -BYTE PeriodRead( void ) -{ - BYTE byFlag = 0; -#ifdef CCP1_PIN - if ( g_wPeriod1 ) - { - // current reading minus last reading for period - CCP1IE = 0; - g_stPeriod1.dw = s_dwSum1 / g_wPeriod1; - s_dwSum1 = g_wPeriod1 = 0; - CCP1IE = 1; - byFlag |= 1; - s_byDrop1 = 0; - } - else - { - // no reading available - if ( s_byDrop1 < s_byZero1 ) - { - // drop zero - s_byDrop1++; // stopping - g_stPeriod1.dw = 0; - } - else if ( s_byDrop1 == s_byZero1 ) - { - // stopped - s_byDrop1++; - byFlag |= 1; - g_stPeriod1.dw = 0x7FFFFFFF; - } - } -#endif -#ifdef CCP2_PIN - if ( g_wPeriod2 ) - { - // current reading minus last reading for period - CCP2IE = 0; - g_stPeriod2.dw = s_dwSum2 / g_wPeriod2; - s_dwSum2 = g_wPeriod2 = 0; - CCP2IE = 1; - byFlag |= 2; - s_byDrop2 = 0; - } - else - { - // no reading available - if ( s_byDrop2 < s_byZero2 ) - { - // drop zero - s_byDrop2++; // stopping - g_stPeriod2.dw = 0; - } - else if ( s_byDrop2 == s_byZero2 ) - { - // stopped - s_byDrop2++; - byFlag |= 2; - g_stPeriod2.dw = 0x7FFFFFFF; - } - } -#endif - return byFlag; -} - diff --git a/src/libPIC/period.h b/src/libPIC/period.h deleted file mode 100644 index 192e470..0000000 --- a/src/libPIC/period.h +++ /dev/null @@ -1,83 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Period Counters - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _PERIOD_H_ -#define _PERIOD_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -// this is application specific -#include "system.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -// CCP1/CCP2 -#ifdef CCP1_PIN -#define Period1Cnt() g_wPeriod1 -#define Period1Clr() g_wPeriod1=0 -#define Period1Clear() g_stPeriod1.dw=0 -#define Period1Read() g_stPeriod1.dw -#endif -#ifdef CCP2_PIN -#define Period2Cnt() g_wPeriod2 -#define Period2Clr() g_wPeriod2=0 -#define Period2Clear() g_stPeriod2.dw=0 -#define Period2Read() g_stPeriod2.dw -#endif - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -#ifdef CCP1_PIN -LIBBANK extern volatile WORD g_wPeriod1; -extern volatile long_dword g_stPeriod1; -#endif -#ifdef CCP2_PIN -LIBBANK extern volatile WORD g_wPeriod2; -extern volatile long_dword g_stPeriod2; -#endif - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -// counters -extern void PeriodInit( void ); -extern void PeriodHandler( void ); -extern void PeriodClear( void ); -extern BYTE PeriodRead( void ); -extern void PeriodZero( BYTE byZero1, BYTE byZero2 ); - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/pkt_int.c b/src/libPIC/pkt_int.c deleted file mode 100644 index 00ab13d..0000000 --- a/src/libPIC/pkt_int.c +++ /dev/null @@ -1,226 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Packet Serial Interrupt Handling - * Description - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -/***************************************************************************** - * defines -*****************************************************************************/ - -#include "system.h" -#include "serial.h" -#include "packet.h" -#include "queue.h" - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -// queues used -extern SERBANK Queue g_qSerialRx; -extern SERBANK Queue g_qSerialTx; - -// global packet control -PKTBANK WORD g_wPacketId = 0; -PKTBANK BYTE g_byPacketAvail = 0; // used by interrupt handler -PKTBANK bit g_bPacketCRC = 0; - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -// interrupt driven serial i/o -static LIBBANK volatile WORD s_wPcktId = 0; -static LIBBANK volatile BYTE s_byPcktCnt = 0; -static LIBBANK volatile BYTE s_byByteCnt = 0; -static LIBBANK volatile BYTE s_byCheckSum = 0; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void PacketInit( void ) -{ -#if PACKET_CK_SIZE - g_bPacketCRC = 1; -#endif -} - -void PacketHandler( void ) -{ - // temps -static LIBBANK BYTE byRx; -static LIBBANK BYTE byTx; - - // RC6/TX - if ( TXIF ) - { - // ready to xmit - byTx = _QueueCount( g_qSerialTx ); - if ( byTx ) - { - // output from queue - _QueueGet( g_qSerialTx, TXREG ); - } - if ( byTx <= 1 ) - { - // nothing left, disable - TXIE = 0; - } - } - - // RC7/RX - if ( !RCIF ) - return; - - // check queue, lose a byte if necessary - while ( _QueueFull( g_qSerialRx ) ) - _QueueGet( g_qSerialRx, byRx ); - - // read char - byRx = RCREG; - - // depacketizer - if ( s_byByteCnt ) - { - // data byte, last is checksum - if ( s_byByteCnt-- ) - { - if ( s_byPcktCnt ) - { - s_byPcktCnt++; - _QueuePut( g_qSerialRx, byRx ); - s_byCheckSum += byRx; - } - } - // done with packet? - if ( s_byByteCnt == 0 ) - { - if ( g_bPacketCRC == 1 ) - { - g_byPacketAvail++; // defer CRC check - } - else if ( g_bPacketCRC == 0 && s_byCheckSum == 0 ) - { - // signal good packet is available - g_byPacketAvail++; - } - else if ( s_byPcktCnt == _QueueSize( g_qSerialRx ) ) - { - // eat bad packet - _QueueClear( g_qSerialRx ); - } - s_byPcktCnt = 0; - } - } - else if ( s_byPcktCnt < 3 ) - { - // look for sync chars - if ( byRx == PACKET_RECV_SYNC ) - { - if ( s_byPcktCnt < PACKET_SYNC_LENGTH-1 ) - s_byPcktCnt++; - } - else if ( byRx == PACKET_SYNC_CHAR ) - { - if ( s_byPcktCnt == PACKET_SYNC_LENGTH-1 ) - s_byPcktCnt++; - else - s_byPcktCnt = 0; - } - else - s_byPcktCnt = 0; - } - else - { - // reading packet - s_byPcktCnt++; - - // got byte count? -#if PACKET_ID_SIZE >= 1 - if ( s_byPcktCnt == 4 ) - s_wPcktId = byRx; - else -#if PACKET_ID_SIZE == 2 - if ( s_byPcktCnt == 5 ) - s_wPcktId |= byRx << 8; - else -#endif -#endif - if ( s_byPcktCnt == PACKET_LENGTH-1 ) - { - // bytes to slurp - s_byByteCnt = byRx + g_bPacketCRC ? 2 : 1; // got byte count + checksum - s_byCheckSum = 0; - - // my packet? -#ifdef PACKET_IDENT - if ( g_wPacketId == 0 || g_wPacketId == s_wPcktId ) - { -#endif - // dump header into queue - _QueuePut(g_qSerialRx, PACKET_RECV_SYNC); - _QueuePut(g_qSerialRx, PACKET_RECV_SYNC); - _QueuePut(g_qSerialRx, PACKET_SYNC_CHAR); -#if PACKET_ID_SIZE >= 1 - _QueuePut( g_qSerialRx, s_wPcktId ); -#endif -#if PACKET_ID_SIZE == 2 - _QueuePut( g_qSerialRx, s_wPcktId >> 8 ); -#endif -#if PACKET_FL_SIZE >= 1 - _QueuePut( g_qSerialRx, s_byCheckSum ); -#endif - _QueuePut( g_qSerialRx, byRx ); // bc -#ifdef PACKET_IDENT - } - else - s_byPcktCnt = 0; // ignore packet data -#endif - } -#if PACKET_FL_SIZE >= 1 - else - { - s_byCheckSum = byRx; // tmp for flag byte - } -#endif - } - - // doesn't handle overflow, so app had better have big buffer - if ( OERR ) - { - // overrun error (lost data) - CREN = 0; - CREN = 1; - } -} diff --git a/src/libPIC/pkt_radio.c b/src/libPIC/pkt_radio.c deleted file mode 100644 index 551787d..0000000 --- a/src/libPIC/pkt_radio.c +++ /dev/null @@ -1,144 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Packet Radio Control - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "delay.h" -#include "types.h" -#include "serial.h" -#include "packet.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -static BYTE s_byDir = RADIO_OFF; // radio status - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -BYTE getRadio( void ) -{ - return s_byDir; -} - -BYTE dirRadio( BYTE byFlag ) -{ -#if defined(RXEN_RADIO) || defined(TXEN_RADIO) - // radio logic disabled - if ( s_byDir == RADIO_DISABLE ) - return 0; - - // direct connect? -#ifdef OVER_RADIO - if ( !OVER_RADIO ) - byFlag = RADIO_DIRECT; // includes debug -#endif - // change direction only if necessary - if ( s_byDir == byFlag ) - return 0; - - // flush buffer - sendFlush(); - - // shut off radio - if ( byFlag == RADIO_OFF ) - { - // shut it all off - serial_baud( 38400 ); -#ifdef RXEN_RADIO - RXEN_RADIO = 0; -#endif -#ifdef TXEN_RADIO - TXEN_RADIO = 0; -#endif - } - else if ( byFlag == RADIO_LISTEN ) - { - // flush, wait and switch - serial_baud( BAUD ); -#ifdef TXEN_RADIO - TXEN_RADIO = 0; -#endif -#ifdef RXEN_RADIO - RXEN_RADIO = 1; -#endif - } - else if ( byFlag == RADIO_TALK ) - { - // let's talk - serial_baud( BAUD ); -#ifdef RXEN_RADIO - RXEN_RADIO = 0; -#endif - // switch -#ifdef TXEN_RADIO - TXEN_RADIO = 1; -#endif - } - else if ( byFlag == RADIO_DIRECT ) - { - // bump speed - serial_baud( 115200 ); -#ifdef RXEN_RADIO - RXEN_RADIO = 0; -#endif -#ifdef TXEN_RADIO - TXEN_RADIO = 0; -#endif - } - - // ready to listen - recvFlush(); - - // remember radio state - s_byDir = byFlag; - return 1; -#else - return 0; -#endif -} - -void noRadio( void ) -{ - s_byDir = RADIO_DISABLE; -} diff --git a/src/libPIC/pkt_recv.c b/src/libPIC/pkt_recv.c deleted file mode 100644 index 9c1954c..0000000 --- a/src/libPIC/pkt_recv.c +++ /dev/null @@ -1,297 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Packet Receive - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "delay.h" -#include "types.h" -#include "serial.h" -#include "packet.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -/////////////////////////////////////////////////////////////////////////////// -// de-Packetizer -/////////////////////////////////////////////////////////////////////////////// - -void recvClear( BYTE n ) -{ - // clear buffer till end of current packet - n++; - while ( n-- && getchavail() ) - getch(); -} - -void recvFlush( void ) -{ - // flush queue - SerialClear(); -} - -int recvGet( BYTE n ) -{ - int c; - BYTE i; - UINT t; - DWORD v = 0; - - for ( i = 0; i < n; i++ ) - { - t = TIMEOUT; - if ( ( c = getchtimeout( &t ) ) < 0 ) - return PACKET_ERR_TIMEOUT; - v |= ( c << ( i * 8 ) ); - } - return v; -} - -int recvWait( UINT iWait ) -{ - iWait /= 10; - - // wait for a packet - while ( iWait-- ) - { - if ( getchavail() > 0 ) - return 1; - DelayUsec( 100 ); - } - return 0; -} - -int recvHeader( WORD *pwCheck, WORD *pwId, BYTE *pbyFlag ) -{ - int c = 0; - WORD n = 0; - UINT t; - - // software timeouts - // check if line needs to turn around - if ( dirRadio( RADIO_LISTEN ) ) - { - // generous wait for a packet - if ( !recvWait( PACKET_WAIT_TIME ) ) - return PACKET_ERR_TIMEOUT; - } - else - { - // wait for next packet - if ( !recvWait( PACKET_WAIT_TIME/2 ) ) - return PACKET_ERR_TIMEOUT; - } - - // wait till synchronization string - while ( n < PACKET_SYNC_LENGTH ) - { - t = TIMEOUT; - c = getchtimeout( &t ); - - if ( c == PACKET_RECV_SYNC ) - { - if ( n < PACKET_SYNC_LENGTH - 1 ) - n++; - } - else if ( c == PACKET_SYNC_CHAR ) - { - if ( n == PACKET_SYNC_LENGTH - 1 ) - n++; - else - n = 0; - } - else if ( c < 0 ) - return c; - else - n = 0; - } - -#ifdef PACKET_FILTER - // got it - if ( g_byPacketAvail ) - g_byPacketAvail--; -#endif - // init checksum or CRC - *pwCheck = 0; - - // id - *pwId = (WORD) recvGet( PACKET_ID_SIZE ); - - // flag byte - *pbyFlag = (BYTE) recvGet( PACKET_FL_SIZE ); - - // byte count - n = (WORD) recvGet( PACKET_BC_SIZE ); - - // check flag - if ( *pbyFlag ) - { - // check control flag bits - if ( *pbyFlag & PACKET_FLAG_STREAM ) - return n; // ignore rest of bits used for streaming counter - - // check each flag - if ( *pbyFlag & PACKET_FLAG_CRC ) - g_bPacketCRC = 1; - } - - return n; -} - -int recvByte( WORD *pwCheck ) -{ - UINT t = TIMEOUT; - int c; - - if ( ( c = getchtimeout( &t ) ) < 0 ) - return c; - - if ( g_bPacketCRC ) - *pwCheck = doCRC16( *pwCheck, c ); - else - *pwCheck += (BYTE) c; - return (BYTE) c; -} - -int recvData( WORD *pwCheck, PKTBANK BYTE * pbyData, WORD nBytes, WORD maxBytes ) -{ - WORD nRead = 0; - UINT t; - int c; - - // read bytes - while ( nBytes-- ) - { - // read - t = TIMEOUT; - c = getchtimeout( &t ); - if ( c < 0 ) - return c; - - // store data away - if ( pbyData && ( nRead < maxBytes ) ) - *pbyData++ = c; - - // CRC or checksum - if ( g_bPacketCRC ) - *pwCheck = doCRC16( *pwCheck, c ); - else - *pwCheck += (BYTE) c; - - // count - nRead++; - } - - return nRead; -} - -int recvTrailer( WORD *pwCheck ) -{ - UINT t = TIMEOUT; - WORD wCheck; - int c; - - if ( ( c = getchtimeout( &t ) ) < 0 ) - return c; - - // CRC or checksum - if ( g_bPacketCRC ) - { - // low byte - wCheck = c; - // high byte - if ( ( c = getchtimeout( &t ) ) < 0 ) - return c; - wCheck |= (c << 8); - - // compare CRCs - if ( *pwCheck != wCheck ) - return 0; - } - else - { - // byte, masked - *pwCheck += (BYTE) c; - *pwCheck &= 0xff; - - // good checksum is zero - if ( *pwCheck ) - return 0; - } - return 1; -} - -int recvPacket( WORD *pwId, PKTBANK BYTE *pbyPacket, BYTE *pbyFlag, WORD maxBytes ) -{ - WORD wCheck; - int nBytes; - - // header - if ( ( nBytes = recvHeader( &wCheck, pwId, pbyFlag ) ) < 0 ) - return nBytes; - - // check - if ( nBytes > maxBytes ) - return PACKET_BUF_TOOBIG; - - // data - if ( ( nBytes = recvData( &wCheck, pbyPacket, (WORD)nBytes, (WORD)maxBytes ) ) < 0 ) - return nBytes; - - // checksum - if ( recvTrailer( &wCheck ) ) - return nBytes; - return PACKET_BAD_CHECKSUM; -} - -int recvFinish( WORD nBytes ) -{ - WORD wCheck; - - recvData( &wCheck, NULL, nBytes, nBytes ); - if ( recvTrailer( &wCheck ) ) - return nBytes; - return PACKET_BAD_CHECKSUM; -} diff --git a/src/libPIC/pkt_recvs.c b/src/libPIC/pkt_recvs.c deleted file mode 100644 index b6d5348..0000000 --- a/src/libPIC/pkt_recvs.c +++ /dev/null @@ -1,203 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Streaming Packet Receive - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "delay.h" -#include "serial.h" -#include "types.h" -#include "serial.h" -#include "packet.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -int recvSequence( WORD *pwId, WORD *pwCheck, BYTE *pwCheckSeq ) -{ - BYTE byFlag = 0; - int nBytes; - - // get header - if ( ( nBytes = recvHeader( pwCheck, pwId, &byFlag ) ) < 0 ) - return nBytes; - - // check sequence number (last packet need not have flag) - if ( ( byFlag ^ *pwCheckSeq ) & 0x7f ) - { - recvFinish( nBytes ); - return PACKET_ERR_SEQUENCE; - } - - // must be streaming packet - if ( !( byFlag & PACKET_FLAG_STREAM ) && nBytes == 0 ) - { - recvFinish( nBytes ); - return PACKET_ERR_STREAM; - } - - // bump sequence - ( *pwCheckSeq )++; - - return nBytes; -} - -int recvStream( WORD wBoxId, PKTBANK BYTE *pbyData, WORD nLen ) -{ - WORD wId; - WORD wCheck = 0; - BYTE bySeq = 0; - WORD nTotal = 0; - int nBytes = PACKET_ERR_TIMEOUT; - - do - { - // get header - if ( ( nBytes = recvSequence( &wId, &wCheck, &bySeq ) ) < 0 ) - return nBytes; // error - - // check id - if ( wBoxId != wId ) - { - // ignore - recvFinish( nBytes ); - continue; - } - - // to read - if ( nBytes > nLen ) - { - recvFinish( nBytes ); -// return PACKET_BUF_OVERWRITE; - continue; - } - - // gobble the rest - if ( nLen == 0 ) - pbyData = NULL; - - // receive data - if ( recvData( &wCheck, pbyData, nBytes, nLen ) != nBytes ) - { - recvTrailer( &wCheck ); - return nBytes; - } - - // checksum - if ( !recvTrailer( &wCheck ) ) - return PACKET_BAD_CHECKSUM; - - // next - if ( pbyData ) - pbyData += nBytes; - nTotal += nBytes; - nLen -= nBytes; - - // flag off - if ( !( bySeq & PACKET_FLAG_STREAM ) ) - break; - } - while ( nBytes > 0 ); - - return nTotal; -} - -int readStream( WORD wBoxId, void (*put)(BYTE), WORD nLen ) -{ - WORD wId; - WORD wCheck = 0; - BYTE bySeq = 0; - WORD nTotal = 0; - int nBytes = PACKET_ERR_TIMEOUT; - int n, c; - - do - { - // get header - if ( ( nBytes = recvSequence( &wId, &wCheck, &bySeq ) ) < 0 ) - return nBytes; // error - - // check id - if ( wBoxId != wId ) - { - // ignore - recvFinish( nBytes ); - continue; - } - - // to read - if ( nBytes > nLen ) - { - recvFinish( nBytes ); -// return PACKET_BUF_OVERWRITE; - continue; - } - - // receive data - n = nBytes; - while ( n-- ) - { - if ( ( c = recvByte( &wCheck ) ) >= 0 ) - ( *put ) ( c ); // call user's function - else - return c; // timeout - } - - // checksum - if ( !recvTrailer( &wCheck ) ) - return PACKET_BAD_CHECKSUM; - - // next - nTotal += nBytes; - nLen -= nBytes; - - // flag off - if ( !( bySeq & PACKET_FLAG_STREAM ) ) - break; - } - while ( nBytes > 0 ); - - return nTotal; -} diff --git a/src/libPIC/pkt_xmit.c b/src/libPIC/pkt_xmit.c deleted file mode 100644 index 3bfdead..0000000 --- a/src/libPIC/pkt_xmit.c +++ /dev/null @@ -1,191 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Packet Transmitter - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "delay.h" -#include "types.h" -#include "serial.h" -#include "packet.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -/////////////////////////////////////////////////////////////////////////////// -// Packetizer -/////////////////////////////////////////////////////////////////////////////// - -void sendPadding( BYTE nBytes ) -{ - // packet header for synchronization - while ( nBytes-- ) - putch( PACKET_SYNC_PAD ); -} - -void sendSpacing( BYTE nBytes ) -{ - // inter packet spacing - while ( nBytes-- ) - putch( PACKET_SYNC_CHAR ); -} - -void sendPut( int v, int n ) -{ - while ( n-- ) - { - putch( v ); - v >>= 8; - } -} - -void sendSynch( BYTE nBytes ) -{ - // packet header for synchronization - while ( nBytes-- > PACKET_SYNC_LENGTH ) - putch( PACKET_SYNC_PAD ); - while ( nBytes-- ) - putch( PACKET_XMIT_SYNC ); - putch( PACKET_SYNC_CHAR ); -} - -void sendHeader( WORD *pwCheck, WORD wId, BYTE byFlag, WORD nBytes ) -{ - // check if line needs to turn around - // packet header for synchronization - // switch the radio - - if ( getRadio() == RADIO_DIRECT ) - sendSynch( PACKET_RESYNC_LENGTH ); // direct connection - else if ( dirRadio( RADIO_TALK ) ) - sendSynch( PACKET_HEADER_LENGTH ); // padding for worst case TX->RX switch - else - sendSynch( PACKET_RESYNC_LENGTH ); - - // put id - sendPut( wId, PACKET_ID_SIZE ); - - // put flag - sendPut( byFlag, PACKET_FL_SIZE ); - - // send byte count - sendPut( nBytes, PACKET_BC_SIZE ); - - // init chksum - *pwCheck = 0; -} - -void sendByte( WORD *pwCheck, BYTE byByte ) -{ - putch( byByte ); - if ( *pwCheck ) - { - // CRC or checksum - if ( g_bPacketCRC ) - *pwCheck = doCRC16( *pwCheck, byByte ); - else - *pwCheck += byByte; - } -} - -void sendData( WORD *pwCheck, const BYTE *pbyData, WORD nBytes ) -{ - // output data and compute checksum - while ( nBytes-- ) - { - // CRC or checksum - if ( g_bPacketCRC ) - *pwCheck = doCRC16( *pwCheck, *pbyData ); - else - *pwCheck += *pbyData; - putch( *pbyData++ ); - } -} - -void sendTrailer( WORD *pwCheck ) -{ - // CRC or checksum - if ( g_bPacketCRC ) - { - // CRC - putch( *pwCheck++ ); - putch( *pwCheck ); - } - else - { - // final checksum - *pwCheck = 256 - (BYTE)*pwCheck; - putch( *pwCheck ); - } - - // padding - if ( getRadio() == RADIO_TALK ) - sendPadding( PACKET_TRAILER_LENGTH ); // PIC TX->RX switch may kill last char - sendFlush(); -} - -void sendFlush( void ) -{ - while ( !putchempty() ) - CLRWDT(); -} - -int sendPacket( WORD wId, const BYTE *pbyPacket, WORD nBytes ) -{ - WORD wCheck = 0; - - // header - sendHeader( &wCheck, wId, 0, (WORD)(pbyPacket ? nBytes : 0) ); - - // data - if ( pbyPacket && nBytes ) - sendData( &wCheck, pbyPacket, nBytes ); - - // trailer - sendTrailer( &wCheck ); - - return nBytes; -} - diff --git a/src/libPIC/pkt_xmits.c b/src/libPIC/pkt_xmits.c deleted file mode 100644 index d314538..0000000 --- a/src/libPIC/pkt_xmits.c +++ /dev/null @@ -1,133 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Streaming Packet Transmitter - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "delay.h" -#include "types.h" -#include "serial.h" -#include "packet.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -int sendStream( WORD wId, const BYTE *pbyData, WORD nLen ) -{ - WORD wCheck; - BYTE bySeq = 0; - WORD nTotal = 0; - int nBytes; - - while ( nLen > 0 ) - { - // how much can I send? - nBytes = nLen; - if ( nBytes > PACKET_MAX_STREAM ) - nBytes = PACKET_MAX_STREAM; - - // last packet? - if ( nBytes == nLen ) - bySeq &= ~PACKET_FLAG_STREAM; - else - bySeq |= PACKET_FLAG_STREAM; - - // send data - sendHeader( &wCheck, wId, bySeq, nBytes ); - sendData( &wCheck, pbyData, nBytes ); - sendTrailer( &wCheck ); - - // next - pbyData += nBytes; - nTotal += nBytes; - nLen -= nBytes; - bySeq++; // bump sequence - } - - return nTotal; -} - -int writeStream( WORD wId, BYTE(*get)(void), WORD nLen ) -{ - WORD wCheck; - BYTE bySeq = 0; - WORD nTotal = 0; - BYTE byData; - int nBytes; - int n; - - while ( nLen > 0 ) - { - // how much can I send? - nBytes = nLen; - if ( nBytes > PACKET_MAX_STREAM ) - nBytes = PACKET_MAX_STREAM; - - // last packet? - if ( nBytes == nLen ) - bySeq &= ~PACKET_FLAG_STREAM; - else - bySeq |= PACKET_FLAG_STREAM; - - // send data - sendHeader( &wCheck, wId, bySeq, nBytes ); - - n = nBytes; - while ( n-- ) - { - byData = ( *get ) ( ); - sendByte( &wCheck, byData ); - } - sendTrailer( &wCheck ); - - // next - nTotal += nBytes; - nLen -= nBytes; - bySeq++; // bump sequence - } - - return nTotal; -} - diff --git a/src/libPIC/portb.h b/src/libPIC/portb.h deleted file mode 100644 index f0e11dc..0000000 --- a/src/libPIC/portb.h +++ /dev/null @@ -1,150 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Port B - *---------------------------------------------------------------------------- - * Int Pin 0 Interrupt - * Int Pin 1-2 Interrupt - * Int Pin 4-7 Change detect -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _PORTB_H_ -#define _PORTB_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -// this is application specific -#include "system.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - - -// INT0 -#ifdef RB0_PIN -#define PortB0Clr() g_bRb0Flag=0 -#define PortB0Set() g_bRb0Flag=1 -#define PortB0Get() g_bRb0Flag -#define PortB0Clear() g_wRb0Count0=0 -#define PortB0Count() g_wRb0Count0 -#define PortB0Read() g_stCount0.dw // timer #1 reading -#endif - -// INT0-2 -#ifdef _PIC18 -#ifdef RB1_PIN -#define PortB1Clr() g_bRb1Flag=0 -#define PortB1Set() g_bRb1Flag=1 -#define PortB1Get() g_bRb1Flag -#define PortB1Clear() g_wRb1Count=0 -#define PortB1Count() g_wRb1Count -#endif -#ifdef RB2_PIN -#define PortB2Clr() g_bRb2Flag=0 -#define PortB2Set() g_bRb2Flag=1 -#define PortB2Get() g_bRb2Flag -#define PortB2Clear() g_wRb2Count=0 -#define PortB2Count() g_wRb2Count -#endif -#endif - -#define PortB4567Flag() g_bRb4567Flag -#define PortB4567Clear() g_bRb4567Flag=0 -#ifdef RB4_PIN -#define PortB4High() g_wRb4High -#define PortB4Low() g_wRb4Low -#endif -#ifdef RB5_PIN -#define PortB5High() g_wRb5High -#define PortB5Low() g_wRb5Low -#endif -#ifdef RB6_PIN -#define PortB6High() g_wRb6High -#define PortB6Low() g_wRb6Low -#endif -#ifdef RB7_PIN -#define PortB7High() g_wRb7High -#define PortB7Low() g_wRb7Low -#endif - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -#ifdef RB0_PIN -LIBBANK extern volatile bit g_bRb0Flag; -LIBBANK extern volatile long_dword g_stCount0; -LIBBANK extern volatile WORD g_wRb0Counter; -#endif -#ifdef RB1_PIN -LIBBANK extern volatile bit g_bRb1Flag; -LIBBANK extern volatile WORD g_wRb1Counter; -#endif -#ifdef RB2_PIN -LIBBANK extern volatile bit g_bRb2Flag; -LIBBANK extern volatile WORD g_wRb2Counter; -#endif - -LIBBANK extern volatile bit g_bRb4567Flag; -#ifdef RB4_PIN -LIBBANK extern volatile bit g_bRb4Flag; -LIBBANK extern volatile WORD g_wRb4Low; -LIBBANK extern volatile WORD g_wRb4High; -#endif -#ifdef RB5_PIN -LIBBANK extern volatile bit g_bRb5Flag; -LIBBANK extern volatile WORD g_wRb5Low; -LIBBANK extern volatile WORD g_wRb5High; -#endif -#ifdef RB6_PIN -LIBBANK extern volatile bit g_bRb6Flag; -LIBBANK extern volatile WORD g_wRb6Low; -LIBBANK extern volatile WORD g_wRb7High; -#endif -#ifdef RB7_PIN -LIBBANK extern volatile bit g_bRb7Flag; -LIBBANK extern volatile WORD g_wRb7Low; -LIBBANK extern volatile WORD g_wRb7High; -#endif - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -// interrupt pins -extern void PortB0Init( void ); -extern void PortB0Handler( void ); - -extern void PortB12Init( BYTE byPins ); -extern void PortB12Handler( void ); - -extern void PortB4567Init( void ); -extern void PortB4567Handler( void ); - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/portb_0.c b/src/libPIC/portb_0.c deleted file mode 100644 index 91f6678..0000000 --- a/src/libPIC/portb_0.c +++ /dev/null @@ -1,111 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Port B Pin 0 Interrupt (INT0) - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "portb.h" - -#ifdef RB0_PIN -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -// external interrupt pin (RB0), flag and counter -LIBBANK volatile bit g_bRb0Flag = 0; -LIBBANK volatile long_dword g_stCount0; -LIBBANK volatile WORD g_wCount0 = 0L; - -extern LIBBANK volatile WORD g_wTimer1High; - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void PortB0Init( void ) -{ - RB0 = 0; - TRISB0 = 1; // input -#ifdef _PIC18 - INT0IE = 1; - INTEDG0 = 1; // default rising -#else - INTE = 1; - INTEDG = 1; // default rising -#endif - g_bRb0Flag = 0; - g_stCount0.dw = 0L; -} - -// high priority only -void PortB0Handler( void ) -{ - // RB0 interrupt pin -#ifdef _PIC18 - if ( INT0IF ) -#else - if ( INTF ) -#endif - { - g_bRb0Flag = 1; -#ifdef _PIC18 - g_stCount0.w.h = g_wTimer1High; // high first so can check for change - g_stCount0.w.l = TMR1; -#else - g_stCount0.w.h = g_wTimer1High; // high first so can check for change - g_stCount0.b.lh = TMR1H; - g_stCount0.b.ll = TMR1L; - if ( g_stCount0.w.h != g_wTimer1High || g_stCount0.b.lh != TMR1H ) - { - g_stCount0.w.h = g_wTimer1High; - g_stCount0.b.lh = TMR1H; - g_stCount0.b.ll = TMR1L; - } -#endif -#ifdef _PIC18 - INT0IF = 0; -#else - INTF = 0; -#endif - g_wCount0++; - } -} - -#endif diff --git a/src/libPIC/portb_12.c b/src/libPIC/portb_12.c deleted file mode 100644 index 4effa25..0000000 --- a/src/libPIC/portb_12.c +++ /dev/null @@ -1,113 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Port B Pins 1-2 Interrupt (INT1-2) - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "portb.h" - -#if (defined(RB1_PIN) || defined(RB2_PIN)) && defined(_PIC18) -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -#ifdef RB1_PIN -LIBBANK volatile WORD g_wRb1Count = 0L; -#endif - -#ifdef RB2_PIN -LIBBANK volatile WORD g_wRb2Count = 0L; -#endif - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void PortB12Init( BYTE byPins ) -{ -#ifdef RB1_PIN - RB1 = 0; - if ( byPins & 1 ) - { - TRISB1 = 1; // input - INT1IE = 1; - INT1IP = 0; - INTEDG1 = 1; // default rising - g_wRb1Count = 0L; - } -#endif - -#ifdef RB2_PIN - RB2 = 0; - if ( byPins & 2 ) - { - TRISB2 = 1; // input - INT2IE = 1; - INT2IP = 0; - INTEDG2 = 1; // default rising - g_wRb2Count = 0L; - } -#endif -} - -void PortB12Edge( BYTE byEdge ) -{ - INTEDG1 = byEdge; - INTEDG2 = byEdge >> 1; -} - -void PortB12Handler( void ) -{ - if ( INT1IF ) - { - g_bRb1Flag = 1; - g_wRb1Count++; - INT1IF = 0; - } - - if ( INT2IF ) - { - g_bRb2Flag = 1; - g_wRb2Count++; - INT2IF = 0; - } -} -#endif diff --git a/src/libPIC/portb_4567.c b/src/libPIC/portb_4567.c deleted file mode 100644 index 4190def..0000000 --- a/src/libPIC/portb_4567.c +++ /dev/null @@ -1,171 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Port B Pin 4-7 Change Detect - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "project.h" -#include "portb.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -LIBBANK volatile bit g_bRb4567Flag = 0; - -// not good for long pulses -#ifdef RB4_PIN -LIBBANK volatile bit g_bRb4Flag = 0; -LIBBANK volatile WORD g_wRb4High = 0L; -LIBBANK volatile WORD g_wRb4Low = 0L; -LIBBANK volatile WORD g_wRb4Last = 0L; -#endif -#ifdef RB5_PIN -LIBBANK volatile bit g_bRb5Flag = 0; -LIBBANK volatile WORD g_wRb5High = 0L; -LIBBANK volatile WORD g_wRb5Low = 0L; -LIBBANK volatile WORD g_wRb5Last = 0L; -#endif -#ifdef RB6_PIN -// not good for long pulses -LIBBANK volatile bit g_bRb6Flag = 0; -LIBBANK volatile WORD g_wRb6High = 0L; -LIBBANK volatile WORD g_wRb6Low = 0L; -LIBBANK volatile WORD g_wRb6Last = 0L; -#endif -#ifdef RB7_PIN -LIBBANK volatile bit g_bRb7Flag = 0; -LIBBANK volatile WORD g_wRb7High = 0L; -LIBBANK volatile WORD g_wRb7Low = 0L; -LIBBANK volatile WORD g_wRb7Last = 0L; -#endif - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void PortB4567Init( void ) -{ -#ifdef RB4_PIN - RB4 = 0; - g_bRb4Flag = RB4; - TRISC4 = 0; -#endif -#ifdef RB5_PIN - RB5 = 0; - g_bRb5Flag = RB5; - TRISC5 = 0; -#endif -#ifdef RB6_PIN - RB6 = 0; - g_bRb6Flag = RB6; - TRISC6 = 0; -#endif -#ifdef RB7_PIN - RB7 = 0; - g_bRb7Flag = RB7; - TRISC7 = 0; -#endif - RBIE = 1; -#ifdef _PIC18 - RBIP = 0; -#endif -} - -// 18F callable -#ifdef _PIC18 -void PortB4567Handler( void ) -{ - if ( !RBIF ) - return; - g_bRb4567Flag = 1; - - // read bits, measure width -#ifdef RB4_PIN - if ( g_bRb4Flag != RB4 ) - { - // RB4 changed - if ( RB4 ) - g_wRb4Low = TMR1 - g_wRb4Last; // pulse width low - else - g_wRb4High = TMR1 - g_wRb4Last; // pulse width high - g_wRb4Last = TMR1; - g_bRb4Flag = RB4; - } -#endif -#ifdef RB5_PIN - if ( g_bRb5Flag != RB5 ) - { - // RB5 changed - if ( RB5 ) - g_wRb5Low = TMR1 - g_wRb5Last; // pulse width low - else - g_wRb5High = TMR1 - g_wRb5Last; // pulse width high - g_wRb5Last = TMR1; - g_bRb5Flag = RB5; - } -#endif -#ifdef RB6_PIN - if ( g_bRb6Flag != RB6 ) - { - // RB6 changed - if ( RB6 ) - g_wRb6Low = TMR1 - g_wRb6Last; // pulse width low - else - g_wRb6High = TMR1 - g_wRb6Last; // pulse width high - g_wRb6Last = TMR1; - g_bRb6Flag = RB6; - } -#endif -#ifdef RB7_PIN - if ( g_bRb7Flag != RB7 ) - { - // RB7 changed - if ( RB7 ) - g_wRb7Low = TMR1 - g_wRb7Last; // pulse width low - else - g_wRb7High = TMR1 - g_wRb7Last; // pulse width high - g_wRb7Last = TMR1; - g_bRb7Flag = RB7; - } -#endif - RBIF = 0; -} -#endif diff --git a/src/libPIC/project.h b/src/libPIC/project.h deleted file mode 100644 index 5459353..0000000 --- a/src/libPIC/project.h +++ /dev/null @@ -1,51 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Project Header - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _PROJECT_H_ -#define _PROJECT_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - - - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/pwm.c b/src/libPIC/pwm.c deleted file mode 100644 index c711591..0000000 --- a/src/libPIC/pwm.c +++ /dev/null @@ -1,87 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PWM Output - *---------------------------------------------------------------------------- - * Output PWM (8 bit resolution for now) -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "delay.h" -#include "pwm.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - - -void PwmInit( void ) -{ - RC1 = RC2 = 0; - PR2 = 255; // max period - T2CON = 0b00000111; // 16:1 prescale - // PWM1 - TRISC1 = 0; - CCPR1L = 0; - CCP1CON = 0b00001100; - // PMW2 - TRISC2 = 0; - CCPR2L = 0; - CCP2CON = 0b00001100; -} - -// duty cycle 0-PWM_DUTY_MAX (use macro) -void PwmOut( BYTE byPin, WORD wDuty ) -{ - // clip - if ( wDuty > PWM_DUTY_MAX ) - wDuty = PWM_DUTY_MAX; - - // allows custom rate for timer 2 - if ( PR2 != 255 ) - wDuty = wDuty * PR2 / PWM_DUTY_CYCLE; - - // scale duty cycle - if ( byPin == 1 ) - CCPR1L = wDuty; - if ( byPin == 2 ) - CCPR2L = wDuty; -} diff --git a/src/libPIC/pwm.h b/src/libPIC/pwm.h deleted file mode 100644 index 587594c..0000000 --- a/src/libPIC/pwm.h +++ /dev/null @@ -1,61 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PWM Output - *---------------------------------------------------------------------------- - * PWM1 - * PWM2 -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _PWM_H_ -#define _PWM_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -#define PWM_DUTY_CYCLE 256 -#define PWM_DUTY_MIN 0 -#define PWM_DUTY_HALF (PWM_DUTY_CYCLE/2) -#define PWM_DUTY_MAX (PWM_DUTY_CYCLE-1) - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -extern void PwmInit( void ); -extern void PwmOut( BYTE pin, WORD duty ); - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/queue.h b/src/libPIC/queue.h deleted file mode 120000 index fcb4c93..0000000 --- a/src/libPIC/queue.h +++ /dev/null @@ -1 +0,0 @@ -../include/bytequeue.h \ No newline at end of file diff --git a/src/libPIC/ser_baud.c b/src/libPIC/ser_baud.c deleted file mode 100644 index 1aa1c36..0000000 --- a/src/libPIC/ser_baud.c +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Serial Baud Rate - *---------------------------------------------------------------------------- - * Serial port driver loop using USART, interrupt driven. -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "serial.h" -#include "delay.h" -#include "queue.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void SerialBaud( DWORD dwBaud ) -{ -#ifdef __linux__ - openPort( closePort(), dwBaud ); -#else - SPBRG = USART_GEN( dwBaud ); -#endif -} diff --git a/src/libPIC/ser_getn.c b/src/libPIC/ser_getn.c deleted file mode 100644 index f088b3d..0000000 --- a/src/libPIC/ser_getn.c +++ /dev/null @@ -1,133 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Serial Number Input - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "serial.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -static DWORD getun_internal( BYTE echo ) -{ - DWORD n; - char c; - - do - { - c = getch( ); - if ( echo ) - putch( c ); - } - while ( c < '0' || c > '9' ); - - n = 0; - for ( ;; ) - { - if ( c >= ( ( int ) '0' ) && c <= ( ( int ) '9' ) ) - { - n *= 10; - n += c - '0'; - } - else - break; - c = getch( ); - if ( echo ) - putch( c ); - } - return n; -} - -DWORD getun( void ) -{ - return ( getun_internal( 1 ) ); -} - -DWORD getunn( void ) -{ - return ( getun_internal( 0 ) ); -} - -static DWORD getuntimeout_internal( UINT * t, BYTE echo ) -{ - WORD n; - char c; - - do - { - c = getchtimeout( t ); - if ( echo ) - putch( c ); - } - while ( c < '0' || c > '9' ); - - n = 0; - for ( ;; ) - { - if ( c >= ( ( int ) '0' ) && c <= ( ( int ) '9' ) ) - { - n *= 10; - n += c - '0'; - } - else - break; - - c = getchtimeout( t ); - if ( echo ) - putch( c ); - } - return n; -} - -DWORD getuntimeout( UINT * t ) -{ - return getuntimeout_internal( t, 1 ); -} - -DWORD getunntimeout( UINT * t ) -{ - return getuntimeout_internal( t, 0 ); -} diff --git a/src/libPIC/ser_gets.c b/src/libPIC/ser_gets.c deleted file mode 100644 index 49e2e76..0000000 --- a/src/libPIC/ser_gets.c +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Serial String Input - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "serial.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -#ifdef SERIAL_GET -int serial_get( BYTE *s, WORD n ) -{ - int r = n; - while ( n-- ) - *s++ = getch(); - return r; -} -#endif - -int gets( char *s, short n ) -{ - char c; - int l = 0; - - while ( (c = getch()) && n-- ) - { - if ( c == '\r' ) - { - putch( c ); - putch( '\n' ); - break; - } - *s++ = c; - l++; - } - return l; -} diff --git a/src/libPIC/ser_getw.c b/src/libPIC/ser_getw.c deleted file mode 100644 index 19c9313..0000000 --- a/src/libPIC/ser_getw.c +++ /dev/null @@ -1,72 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Serial Input - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "serial.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -WORD getword( ) -{ - short_word word; - - word.b.l = getch(); - word.b.h = getch(); - return word.w; -} - -DWORD getdword( ) -{ - long_dword dword; - - dword.b.ll = getch(); - dword.b.lh = getch(); - dword.b.hl = getch(); - dword.b.hh = getch(); - return dword.dw; -} diff --git a/src/libPIC/ser_init.c b/src/libPIC/ser_init.c deleted file mode 100644 index 4f0aa34..0000000 --- a/src/libPIC/ser_init.c +++ /dev/null @@ -1,154 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Serial Initialization & Interrupt Handler - *---------------------------------------------------------------------------- - * Serial port driver loop using USART, interrupt driven. -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "serial.h" -#include "delay.h" -#include "queue.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -// interrupt driven serial i/o uses queues -SERBANK Queue g_qSerialRx = { 0, 0, 0, 0 }; -SERBANK Queue g_qSerialTx = { 0, 0, 0, 0 }; - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -static LIBBANK BYTE byRx = 0; -static LIBBANK BYTE byTx = 0; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void SerialInit( void ) -{ - // fix these - RC6 = 1; - RC7 = 1; - TRISC6 = 0; - TRISC7 = 1; - - // baud rate - SerialBaud( BAUD ); - - // asynchronous serial - // recv, 8 bits, continuous - RCSTA = 0b10010000; - // xmit, 8 bits, high speed - TXSTA = 0b00100110; - - CREN = 0; - CREN = 1; -} - -void SerialAlloc( BYTE *pbyTx, BYTE nTx, BYTE *pbyRx, BYTE nRx ) -{ - QueueAlloc( &g_qSerialTx, pbyTx, nTx ); - QueueAlloc( &g_qSerialRx, pbyRx, nRx ); - if ( nTx ) - { - RCIE = 1; -#ifdef _PIC18 - RCIP = 1; -#endif - } - if ( nRx ) - { - TXIE = 0; // turned on by putch() -#ifdef _PIC18 - TXIP = 1; -#endif - } - RCIF = TXIF = 0; -} - -void SerialClear( void ) -{ - CREN = 0; - CREN = 1; - QueueClear( &g_qSerialTx ); - QueueClear( &g_qSerialRx ); - getchflush(); -} - -void SerialHandler( void ) -{ - // RC7/RX - if ( RCIF ) - { - // check queue, lose a byte if necessary - while ( _QueueFull( g_qSerialRx ) ) - _QueueGet( g_qSerialRx, byRx ); - - // read char - byRx = RCREG; - _QueuePut( g_qSerialRx, byRx ); - - // doesn't handle overflow, so app had better have big buffer - if ( OERR ) - { - // overrun error (lost data) - CREN = 0; - CREN = 1; - } - RCIF = 0; - } - // RC6/TX - if ( TXIF ) - { - // ready to xmit - byTx = _QueueCount( g_qSerialTx ); - if ( byTx ) - { - // output from queue - _QueueGet( g_qSerialTx, TXREG ); - byTx--; - } - if ( byTx == 0 ) - { - // nothing left, disable - TXIE = 0; - } - TXIF = 0; - } -} diff --git a/src/libPIC/ser_input.c b/src/libPIC/ser_input.c deleted file mode 100644 index b4767b9..0000000 --- a/src/libPIC/ser_input.c +++ /dev/null @@ -1,137 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Serial Char/Byte Input - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "serial.h" -#include "delay.h" -#include "queue.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -extern SERBANK Queue g_qSerialRx; - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -BYTE getchavail( void ) -{ - if ( QueueSize( &g_qSerialRx ) ) - return QueueCount( &g_qSerialRx ); - return RCIF; -} - -void getchflush( void ) -{ - char c; - if ( QueueSize( &g_qSerialRx ) ) - { - QueueClear( &g_qSerialRx ); - } - else - { - while ( RCIF ) - c = RCREG; - } - CREN = 0; - CREN = 1; -} - -int getch( void ) -{ - int c; - BYTE b; - - // from buffer - if ( QueueSize( &g_qSerialRx ) ) - { - while ( QueueCount( &g_qSerialRx ) == 0 ) - CLRWDT(); - QueueGet( &g_qSerialRx, &b ); - c = b; - } - else - { - while ( !RCIF ) - CLRWDT(); - c = RCREG; - } - - // check for errors - if ( FERR ) - c = SER_ERR_FRAME; - else if ( OERR ) - c = SER_ERR_OVERRUN; - if ( c < 0 ) - { - CREN = 0; - CREN = 1; - } - - return c; -} - -int getchtimeout( UINT * t ) -{ - WORD d = *t * 100; - if ( QueueSize( &g_qSerialRx ) ) - { - while ( d-- ) - { - if ( QueueCount( &g_qSerialRx ) ) - return getch(); - } - } - else - { - while ( d-- ) - { - if ( RCIF ) - return getch(); - DelayUsec( 10 ); - *t = d / 10; - } - } - return SER_ERR_TIMEOUT; -} diff --git a/src/libPIC/ser_lnx.c b/src/libPIC/ser_lnx.c deleted file mode 100644 index 402816f..0000000 --- a/src/libPIC/ser_lnx.c +++ /dev/null @@ -1,243 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Linux Serial Driver - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -#if defined(__linux__) -/***************************************************************************** - * includes -*****************************************************************************/ - -// Linux -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef unsigned long DWORD; - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -static int port = -1; -static int fd = -1; - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -// defaults to stdio for debugging purposes until serial port is opened -// Better to use select() in the at the app level when reading serial port - -int openPort( int iPort, int iBaud ) -{ - struct termios oldtio, newtio; - char tty[255]; - - // old port - if ( iPort < 0 ) - iPort = port; - else - port = iPort; - if ( iPort < 0 ) - return -1; - - // device name - sprintf( tty, "/dev/ttyS%d", iPort - 1 ); - - fd = open( tty, O_RDWR | O_NOCTTY ); - if ( fd < 0 ) - { - perror( tty ); - return -1; - } - - // termios - tcgetattr( fd, &oldtio ); /* save current serial port settings */ - bzero( &newtio, sizeof(newtio) ); /* clear struct for new port settings */ - - // no handshake, 8N1, local - newtio.c_cflag = CS8 | CLOCAL | CREAD; - - // speed - switch ( iBaud ) - { - case 9600: - newtio.c_cflag |= B9600; - break; - case 19200: - newtio.c_cflag |= B19200; - break; - case 38400: - newtio.c_cflag |= B38400; - break; - case 57600: - newtio.c_cflag |= B57600; - break; - case 115200: - newtio.c_cflag |= B115200; - break; - default: - close( fd ); - return -1; - } - - // raw mode, no special character processing - newtio.c_iflag = 0; - newtio.c_oflag = 0; - newtio.c_lflag = 0; - - // timing - newtio.c_cc[VMIN] = 1; // 1 char at a time - newtio.c_cc[VTIME] = 1; // 100msec timeout - - // set it - tcflush( fd, TCIFLUSH ); - tcsetattr( fd, TCSANOW, &newtio ); - - // return handle - return fd; -} - -int closePort( void ) -{ - if ( fd >= 0 ) - close( fd ); - else - port = -1; - fd = -1; - return port; -} - -int getchavail( void ) -{ - int n = 0; - - if ( fd < 0 ) - { - if ( feof( stdin ) == 0 ) - return 1; - return -1; - } - - ioctl( fd, FIONREAD, &n ); - return n; -} - -int getchflush( void ) -{ - if ( fd < 0 ) - return fd; - - tcflush( fd, TCIFLUSH ); - return 0; -} - -int getch( void ) -{ - char c = 0; - - if ( fd < 0 ) - return getchar(); - - while ( read( fd, &c, 1 ) < 1 ) - ; - return c; -} - -int getchtimeout( int *t ) -{ - char c = 0; - - if ( fd < 0 ) - return getchar(); - - // ignore timeout - if ( read( fd, &c, 1 ) == 1 ) - return c; - return -2; -} - -void putch( int i ) -{ - char c = i; - - if ( fd < 0 ) - { - putchar( c ); - return; - } - - // not particularly efficient - write( fd, &c, 1 ); -} - -BYTE putchempty( void ) -{ - if ( fd < 0 ) - { - fflush( stdout ); - return 1; - } - - // flush it - tcflush( fd, TCOFLUSH ); - tcdrain( fd ); - return 1; -} - -void putchflush( void ) -{ - if ( fd < 0 ) - { - fflush( stdout ); - return; - } - - // flush it - tcflush( fd, TCOFLUSH ); - tcdrain( fd ); -} - -#endif diff --git a/src/libPIC/ser_output.c b/src/libPIC/ser_output.c deleted file mode 100644 index 321e9b1..0000000 --- a/src/libPIC/ser_output.c +++ /dev/null @@ -1,106 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Serial Char/Byte Output - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "serial.h" -#include "delay.h" -#include "queue.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -extern SERBANK Queue g_qSerialTx; - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -BYTE putchempty( void ) -{ - if ( QueueSize( &g_qSerialTx ) ) - { - if ( QueueCount( &g_qSerialTx ) ) - return 0; - } - return TRMT; -} - -void putchflush( void ) -{ - if ( QueueSize( &g_qSerialTx ) ) - { - while ( QueueCount( &g_qSerialTx ) ) - CLRWDT(); - QueueClear( &g_qSerialTx ); - } - else - { - while ( !TRMT ) - CLRWDT(); - } -} - -// put character -void putch( char c ) -{ - // buffer - if ( QueueSize( &g_qSerialTx ) ) - { - if ( TXIE ) - { - // interrupts are running, store in buffer - while ( QueueFull( &g_qSerialTx ) ) - CLRWDT(); - QueuePut( &g_qSerialTx, (BYTE*)&c ); - return; - } - QueueClear( &g_qSerialTx ); - TXIE = 1; // enable interrupt - } - - // put char - while ( !TXIF ) - CLRWDT(); - TXREG = c; -} - diff --git a/src/libPIC/ser_putn.c b/src/libPIC/ser_putn.c deleted file mode 100644 index eb104d6..0000000 --- a/src/libPIC/ser_putn.c +++ /dev/null @@ -1,88 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Serial Number Output - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "serial.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -// warning, only does 8 digits -void putun( DWORD l ) -{ - BYTE i = 0; - DWORD o = 0; - - while ( l ) - { - o <<= 4; - o |= ( l % 10 ); - l /= 10; - i++; - } - - if ( i == 0 ) - i++; - - while ( i-- ) - { - putch( (o & 0xf) + '0' ); - o >>= 4; - } - - putch( ' ' ); -} - -void putn( long n ) -{ - if ( n < 0 ) - { - putch( '-' ); - n = -n; - } - putun( n ); -} diff --git a/src/libPIC/ser_puts.c b/src/libPIC/ser_puts.c deleted file mode 100644 index 791a98d..0000000 --- a/src/libPIC/ser_puts.c +++ /dev/null @@ -1,87 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Serial String Output - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "serial.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -#ifdef __linux__ -#define putch(C) putchar(C) -#endif - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -#ifdef SERIAL_PUTS -int serial_puts( const BYTE *s, WORD n ) -{ - int r = n; - while ( n-- ) - putch( *s++ ); - return r; -} -#endif - -int puts( const char *s ) -{ - char c; - int n = 0; - - while ( c = *s++ ) - { - if ( c == '\n' ) - { - putch( '\r' ); - n++; - } - putch( c ); - n++; - } - putch( '\r' ); - putch( '\n' ); - - return n+2; -} diff --git a/src/libPIC/ser_putw.c b/src/libPIC/ser_putw.c deleted file mode 100644 index 8a6717f..0000000 --- a/src/libPIC/ser_putw.c +++ /dev/null @@ -1,66 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Serial Output - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "serial.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void putword( WORD i ) -{ - putch( i ); - putch( i >> 8 ); -} - -void putdword( DWORD i ) -{ - putch( i ); - putch( i >> 8 ); - putch( i >> 16 ); - putch( i >> 24 ); -} diff --git a/src/libPIC/ser_putx.c b/src/libPIC/ser_putx.c deleted file mode 100644 index c19572d..0000000 --- a/src/libPIC/ser_putx.c +++ /dev/null @@ -1,83 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Serial Hex Output - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "serial.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void puthex( DWORD l, BYTE s ) -{ - BYTE d; - - while ( s ) - { - s -= 4; - d = ( l >> s ) & 0x0f; - if ( d < 10 ) - putch( d + 0x30 ); - else - putch( d - 10 + 0x41 ); - } - putch( ' ' ); -} - -void putbx( BYTE b ) -{ - puthex( b, 8 ); -} - -void putwx( WORD w ) -{ - puthex( w, 16 ); -} - -void putdwx( DWORD l ) -{ - puthex( l, 32 ); -} diff --git a/src/libPIC/ser_win.c b/src/libPIC/ser_win.c deleted file mode 100644 index 9de3914..0000000 --- a/src/libPIC/ser_win.c +++ /dev/null @@ -1,296 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Windows Serial Emulation Driver - *---------------------------------------------------------------------------- - * Win32 API serial communications -*****************************************************************************/ - -#if defined(_WINDOWS) -/***************************************************************************** - * includes -*****************************************************************************/ - -// Windows -#include -#include -#include -#include -#include "wtypes.h" -#ifdef USB_FTDI -// USB instead of serial -#include "FTD2XX.h" -#endif - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -#ifdef USB_FTDI -static FT_HANDLE m_ftHandle; -static FT_DEVICE m_ftDevice; -static DWORD m_dwDeviceId = 0; -#else -static HANDLE hComm = NULL; -#endif - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -int openPort( int iPort, int iBaud ) -{ -#ifdef USB_FTDI - // default USB device - if ( FT_OpenEx( "DLP-USB232M", FT_OPEN_BY_DESCRIPTION, &m_ftHandle ) == FT_OK ) - { - // DLP/FTDI D2XX unprogrammed, probably a virtual communications port (VCP) - } -#ifdef CORSA_USB_RADIO - else if ( FT_OpenEx( "Corsa-USB232M-Radio", FT_OPEN_BY_DESCRIPTION, &m_ftHandle ) == FT_OK ) - { - // Corsa EZ-Logger, by description - } -#endif - else - return 0; - - // set speed, if standard or custom - if ( iBaud == 1200 || iBaud == 2400 || iBaud == 4800 || iBaud == 9600 || - iBaud == 19200 || iBaud == 38400 || iBaud == 57600 || iBaud == 115200 ) - { - // use default divisors - if ( FT_SetBaudRate( m_ftHandle, iBaud ) != FT_OK ) - { - FT_Close( m_ftHandle ); - return 0; - } - } - else - { - // note that I ignored the fractional portion (for now) - if ( FT_SetDivisor( m_ftHandle, 3000000 / iBaud ) != FT_OK ) - { - FT_Close( m_ftHandle ); - return 0; - } - } - - // setup - if ( FT_ResetDevice( m_ftHandle ) != FT_OK || - FT_SetDataCharacteristics( m_ftHandle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_NONE ) != FT_OK || - FT_SetFlowControl( m_ftHandle, FT_FLOW_NONE, 0, 0 ) != FT_OK || - FT_SetChars( m_ftHandle, 0, 0, 0, 0 ) != FT_OK || - FT_SetTimeouts( m_ftHandle, 100, 0 ) != FT_OK ) - { - FT_Close( m_ftHandle ); - return 0; - } - return 1; -#else - char szPort[256]; - COMMTIMEOUTS timeouts; - DCB dcb; - - // comm port name - sprintf( szPort, "COM%d", iPort ); - - // open - hComm = CreateFile( szPort, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0 ); - if ( hComm == INVALID_HANDLE_VALUE ) - { - hComm = 0; - return -1; - } - - // control - FillMemory( &dcb, sizeof( dcb ), 0 ); - dcb.DCBlength = sizeof( dcb ); - sprintf( szPort, "%d,n,8,1", iBaud ); - if ( !BuildCommDCB( szPort, &dcb ) ) - { - CloseHandle( hComm ); - hComm = 0; - return -1; - } - - // handshake - dcb.fDtrControl = DTR_CONTROL_DISABLE; - dcb.fRtsControl = RTS_CONTROL_DISABLE; - if ( !SetCommState( hComm, &dcb ) ) - { - CloseHandle( hComm ); - hComm = 0; - return -1; - } - - // the first two don't help at all, so don't set them! - memset( &timeouts, 0, sizeof( timeouts ) ); - timeouts.ReadIntervalTimeout = 0; // between chars (no char time) - timeouts.ReadTotalTimeoutMultiplier = 0; // * #chars to read - timeouts.ReadTotalTimeoutConstant = 500; // wait time till something arrives - - if ( !SetCommTimeouts( hComm, &timeouts ) ) - { - CloseHandle( hComm ); - hComm = 0; - return -1; - } - - // generous buffering - SetupComm( hComm, 16384, 16384 ); - - // done - return iPort; -#endif -} - -int closePort( void ) -{ -#ifdef USB_FTDI - if ( m_ftHandle ) - { - FT_Close( m_ftHandle ); - m_ftHandle = 0; - } - return 0; -#else - if ( hComm ) - { - return CloseHandle( hComm ); - hComm = 0; - } - return 0; -#endif -} - -int getchavail( void ) -{ -#ifdef USB_FTDI - DWORD dwAvail = 0; - - if ( FT_GetQueueStatus( m_ftHandle, &dwAvail ) == FT_OK ) - return ( int ) dwAvail; - return 0; -#else - COMSTAT comStat; - DWORD dwErrors; - - // weird - if ( !ClearCommError( hComm, &dwErrors, &comStat ) ) - return -1; - return comStat.cbInQue; -#endif -} - -int getch( void ) -{ - DWORD dwRead = 0; - BYTE c = 0; -#ifdef USB_FTDI - if ( FT_Read( m_ftHandle, &c, 1, &dwRead ) == FT_OK ) - { - if ( dwRead == 1 ) - return c; - } -#else - - if ( ReadFile( hComm, &c, 1, &dwRead, NULL ) ) - { - if ( dwRead == 1 ) - return c; - } -#endif - return -2; -} - -void getchflush( void ) -{ -#ifdef USB_FTDI - FT_Purge( m_ftHandle, FT_PURGE_RX ); -#else - int i, n = 0; - - while ( (i = getchavail()) > 0 ) - { - n += i; - while ( i-- ) - getch(); - } -#endif -} - -int getchtimeout( int *t ) -{ - BYTE c = 0; - DWORD dwRead = 0; -#ifdef USB_FTDI - if ( FT_Read( m_ftHandle, &c, 1, &dwRead ) == FT_OK ) - { - if ( dwRead == 1 ) - return c; - } -#else - if ( ReadFile( hComm, &c, 1, &dwRead, NULL ) ) - { - if ( dwRead == 1 ) - return c; - } -#endif - return -2; -} - -void putch( int c ) -{ - DWORD dwWrite = 0; -#ifdef USB_FTDI - FT_Write( m_ftHandle, &byData, 1, &dwWrite ); -#else - WriteFile( hComm, &c, 1, &dwWrite, NULL ); -#endif -} - -BYTE putchempty( void ) -{ -#ifdef USB_FTDI - if ( FT_Purge( m_ftHandle, FT_PURGE_TX ) == FT_OK ) - return 1; - return 0; -#else - // flush - FlushFileBuffers( hComm ); - return 1; -#endif -} - -#endif diff --git a/src/libPIC/ser_xdump.c b/src/libPIC/ser_xdump.c deleted file mode 100644 index e1d9a71..0000000 --- a/src/libPIC/ser_xdump.c +++ /dev/null @@ -1,87 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Serial Hex Dump - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "serial.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void hexdump( DWORD dwAddr, const BYTE *pbyData, WORD nBytes ) -{ - WORD n; - BYTE i; - BYTE c; - - while ( nBytes ) - { - puthex( dwAddr, 32 ); - - n = 16; - if ( nBytes < n ) - n = nBytes; - - // hex - for ( i = 0; i < n; i++ ) - puthex( *( pbyData + i ), 8 ); - - // string - for ( i = 0; i < n; i++ ) - { - c = *( pbyData + i ); - if ( 0x20 <= c && c < 0x7f ) - putch( c ); - else - putch( '.' ); - } - putnl(); - - dwAddr += 16; - pbyData += 16; - nBytes -= n; - } -} diff --git a/src/libPIC/serial.h b/src/libPIC/serial.h deleted file mode 100644 index 3d09ca5..0000000 --- a/src/libPIC/serial.h +++ /dev/null @@ -1,136 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Serial I/O Interface - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _SERIAL_H_ -#define _SERIAL_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -#ifndef BAUD -#define BAUD 57600 -#endif - -// some of these may not apply w/ -DSERIAL_LOOP -#define SER_ERR_DEVICE (-1) -#define SER_ERR_TIMEOUT (-2) -#define SER_ERR_OVERRUN (-3) -#define SER_ERR_FRAME (-4) -#define SER_NO_DATA (-5) - -/***************************************************************************** - * macros -*****************************************************************************/ - -// rate generation -#define USART_GEN(B) ((((byXtal*1000000L)/(B))/16L)-1) -#define USART_RATE USART_GEN(BAUD) - -#define hexchar(c) ((c >= (int)'0' && c <= (int)'9') || \ - (c >= (int)'A' && c <= (int)'F') || (c >= (int)'a' && c <= (int)'f')) - -#define putnl() puts("\n") -#define putlf() putch('\f') -#define putbl() putch(' ') -#define putline(s) puts(s);putnl() - -// memory i/o style semantics -#define SerialReadByte() getch() -#define SerialWriteByte(B) putch(B) -#define SerialReadBlock(B,N) serial_get(B,N) -#define SerialWriteBlock(B,N) serial_put(B,N) - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -extern void SerialIdle( void ); // user supplied serial idle routine -extern void SerialInit( void ); -extern void SerialBaud( DWORD dwBaud ); -extern void SerialClear( void ); -extern void SerialAlloc( BYTE *pbyTx, BYTE nTx, BYTE *pbyRx, BYTE nRx ); - -// interrupt -extern void SerialHandler( void ); - -extern BYTE getchavail( void ); -extern void getchflush( void ); -extern BYTE putchempty( void ); -extern void putchflush( void ); - -extern void putch( char c ); - -extern BYTE gethook( void ); // nonzero if cable plugged in - -#ifndef _STDIO_H_ -extern int getch( void ); // <0 error -#endif -extern int getchtimeout( UINT * t ); // <0 error - -// primitive data i/o -#define putint(I) putword(I) -extern void putword( WORD i ); - -#define putlint(L) putdword(L) -extern void putdword( DWORD i ); - -#define getint() getword() -extern WORD getword( void ); - -#define getlint() getdword() -extern DWORD getdword( void ); - -// string i/o -extern int puts( const char *s ); -extern int serial_put( const BYTE *s, WORD n ); -extern void puthex( DWORD l, BYTE s ); -extern void putbx( BYTE n ); -extern void putwx( WORD b ); -extern void putdwx( DWORD n ); -extern void putun( DWORD n ); -extern void putn( long n ); - -extern int serial_get( const BYTE *s, WORD n ); -extern DWORD getx( void ); -extern DWORD getun( void ); -extern DWORD getuntimeout( UINT * t ); -extern DWORD getunn( void ); // no echo -extern DWORD getunntimeout( UINT * t ); // no echo - -extern void hexdump( DWORD dwAddr, const BYTE * pbyData, WORD nBytes ); - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/spi.c b/src/libPIC/spi.c deleted file mode 100644 index fb75790..0000000 --- a/src/libPIC/spi.c +++ /dev/null @@ -1,145 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * SPI Polled Hardware I/O - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "spi.h" -#include "delay.h" -#include "queue.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -// master -#ifdef SPI_FAST -#define SPI_SSPCON 0b00100001 -#ifndef SPI_WAIT -#define SPI_WAIT 9 -#endif -#else -#define SPI_SSPCON 0b00100010 -#ifndef SPI_WAIT -#define SPI_WAIT 18 -#endif -#endif - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -static LIBBANK BYTE bySpiWait = SPI_WAIT; - -#ifdef SPI_DEBUG -static LIBBANK BYTE cSpiLastXmit = 0; -static LIBBANK BYTE cSpiThisXmit = 0; -#endif - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void SpiInit( void ) -{ - // init - RC3 = RC4 = RC5 = 0; - - // fix these - TRISC3 = 0; - TRISC4 = 1; - TRISC5 = 0; - - SSPSTAT = 0; -#ifdef _PIC18 - SSPCON1 = SPI_SSPCON; -#else - SSPCON = SPI_SSPCON; -#endif -} - -void SpiWaitTime( BYTE byUsec ) -{ - bySpiWait = byUsec; -} - -BYTE SpiXferByte( BYTE byOut ) -{ - BYTE byIn; - - // send byte - SSPBUF = byOut; - while ( WCOL ) - { - // xmit collision - WCOL = 0; - SSPBUF = byOut; - } - - // recv byte -#ifdef _PIC18 - while ( !BF ) - ; -#else - while ( !(SSPSTAT & 1) ) - ; -#endif - byIn = SSPBUF; - -#ifdef SPI_DEBUG - cSpiLastXmit = byIn; - if ( cSpiLastXmit != cSpiNextXmit ) - SPI_DEBUG = 1; - else - SPI_DEBUG = 0; - cSpiNextXmit = byOut; -#endif - if ( bySpiWait ) - DelayUsec( bySpiWait ); // be patient - return byIn; -} - -void SpiReadData( BYTE *pbyData, BYTE nBytes ) -{ - while ( nBytes-- ) - *pbyData++ = SpiXferByte( 0 ); -} - -void SpiWriteData( const BYTE *pbyData, BYTE nBytes ) -{ - while ( nBytes-- ) - SpiXferByte( *pbyData++ ); -} diff --git a/src/libPIC/spi.h b/src/libPIC/spi.h deleted file mode 100644 index 16ff6af..0000000 --- a/src/libPIC/spi.h +++ /dev/null @@ -1,70 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC SPI Interface - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _SPI_H_ -#define _SPI_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "queue.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -#ifdef _PIC18 -#define SSPCON SSPCON1 -#define STAT_RW RW -#define STAT_DA DA -#endif - -/***************************************************************************** - * macros -*****************************************************************************/ - -#define SpiReadByte() SpiXferByte(0) -#define SpiWriteByte(B) SpiXferByte(B) - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -extern void SpiInit( void ); -extern void SpiWaitTime( BYTE byUsec ); - -extern BYTE SpiXferByte( BYTE byOut ); - -extern void SpiReadData( BYTE *pbyData, BYTE nBytes ); -extern void SpiWriteData( const BYTE *pbyData, BYTE nBytes ); - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/stack.h b/src/libPIC/stack.h deleted file mode 120000 index 5b0c384..0000000 --- a/src/libPIC/stack.h +++ /dev/null @@ -1 +0,0 @@ -../include/bytestack.h \ No newline at end of file diff --git a/src/libPIC/system.c b/src/libPIC/system.c deleted file mode 100644 index 7af080c..0000000 --- a/src/libPIC/system.c +++ /dev/null @@ -1,156 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Board Support Initialization - * Description - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include - -#include "system.h" -#include "delay.h" - -#include "analog.h" -#include "clock.h" - -// user's project -#include "project.h" - -// hardware -#include "timers.h" -#ifdef PERIOD_MODULE -#include "period.h" -#endif -#ifdef PWM_MODULE -#include "pwm.h" -#endif - -// communications -#ifdef I2C_MODULE -#include "i2c.h" -#endif -#ifdef SPI_MODULE -#include "spi.h" -#endif -#ifdef SERIAL_MODULE -#include "serial.h" -#endif - -// mass storage -#ifdef ATMEL_MODULE -#include "atmel.h" -#endif -#ifdef FRAM_MODULE -#include "fram.h" -#endif - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -const BYTE byXtal = XTAL; - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void SystemInit( void ) -{ - di(); - - // low voltage detect -#ifdef _PIC18 - LVDIF = 0; - LVDCON = 0b00011101; // 4.2V - while ( LVDIF ) - ; - LVDIF = 0; -#endif - // init delay (timer 0) - DelayInit(); - - // Application's hardware initializations - BoardInit(); - - // the following inits may alter the app's inits - AdInit(); -#ifdef ANALOG_MODULE - AnalogInit(); -#endif -#ifdef CLOCK_MODULE - ClockInit(); -#endif - -#ifdef I2C_MODULE - I2CInit(); -#endif -#ifdef SPI_MODULE - SpiInit(); -#endif -#ifdef SERIAL_MODULE - SerialInit(); -#endif - - TimerInit(); -#ifdef PERIOD_MODULE - PeriodInit(); -#endif -#ifdef PWM_MODULE - PwmInit(); -#endif - - // Memory devices -#ifdef ATMEL_MODULE - AtmelInit(); -#endif -#ifdef FRAM_MODULE - FramInit(); -#endif - - // application takes care of watchdog - CLRWDT(); - - // persistent across reset - persist_check(1); - - // interrupts -#ifdef INTER_MODULE - InterruptInit(); -#endif -} diff --git a/src/libPIC/system.h b/src/libPIC/system.h deleted file mode 100644 index 2f7fe06..0000000 --- a/src/libPIC/system.h +++ /dev/null @@ -1,76 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Initialization & Runtime - *---------------------------------------------------------------------------- -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _SYSTEM_H_ -#define _SYSTEM_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#ifdef __linux__ -#include "emul.h" -#elif defined(_PIC18) -#include -#else -#include -#endif -#include "types.h" - -// this works out the nitty gritty -#include "config.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -#define getXtalFreq() byXtal -#define inPowerFail() bPowerFail - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -extern const BYTE byXtal; - -/***************************************************************************** - * global variables -*****************************************************************************/ - -extern bit bPowerFail; - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -extern void BoardInit( void ); // system specific initialization -extern void SystemInit( void ); // calls board_init and library inits -extern void InterruptInit( void ); // interrupt inits -extern void WatchdogInit( void ); // turn on watchdog - -extern void InterruptHandler( void ); -extern void PowerfailHandler( void ); - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/timers.c b/src/libPIC/timers.c deleted file mode 100644 index 4b00bbe..0000000 --- a/src/libPIC/timers.c +++ /dev/null @@ -1,187 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Timers - *---------------------------------------------------------------------------- - * Timer #1 - Fast clock counter - * Timer #2 - 1 msec software timer -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" -#include "timers.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -// Timer #1 -#ifdef TIMER1_INT -volatile long_dword g_stTimer1 = { 0 }; -LIBBANK volatile WORD g_wTimer1High = 0; -#endif - -// Timer 2, used for time stamping and msec timing -#ifdef TIMER2_INT -LIBBANK volatile DWORD g_dwTimer2 = 0L; -LIBBANK volatile WORD g_wTimers2[SW_TIMERS] = { 0 }; -#endif - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void TimerInit( void ) -{ - // Timer 1 setup -#ifdef TIMER1_INT - TMR1IE = 1; -#ifdef _PIC18 - T1CON = 0b10110001; // 16 bit read of Timer 1 - TMR1IP = 0; // low priority -#else - T1CON = 0b00110001; -#endif - PIR1 = 0; - PIR2 = 0; - TMR1L = 0; - TMR1H = 0; - g_wTimer1High = 0; - g_stTimer1.dw = 0L; -#endif - - // Timer 2 setup -#ifdef TIMER2_INT - TMR2IE = 1; -#ifdef _PIC18 - TMR2IP = 0; -#endif -#if XTAL==40 - // pre 1:4, post 1:10 (100us..1ms period) - T2CON = 0b10000101 | ( (10-1) << 3 ); - PR2 = 250; -#else - // pre 1:4, post 1:5 (1ms period) - T2CON = 0b00100101; - PR2 = 250; -#endif - TMR2 = 0; - g_dwTimer2 = 0L; -#endif -} - -#ifdef _PIC18 -void TimerHandler( void ) -{ - // Timer1 overflow -#ifdef TIMER1_INT - if ( TMR1IF ) - { - g_wTimer1High++; - TMR1IF = 0; - } -#endif - // Timer2 interrupt -#ifdef TIMER2_INT - if ( TMR2IF ) - { - g_dwTimer2++; - TMR2IF = 0; -#ifdef SW_TIMERS - if ( g_wTimers2[0] ) - g_wTimers2[0]--; -#if SW_TIMERS > 1 - if ( g_wTimers2[1] ) - g_wTimers2[1]--; -#endif -#if SW_TIMERS > 2 - if ( g_wTimers2[2] ) - g_wTimers2[2]--; -#endif -#if SW_TIMERS > 3 - if ( g_wTimers2[3] ) - g_wTimers2[3]--; -#endif -#endif - } -#endif -} -#endif - -void Timer1Clear( void ) -{ -#ifdef TIMER1_INT - g_wTimer1High = 0; - TMR1ON = 0; -#ifdef _PIC18 - TMR1 = 0; -#else - TMR1H = 0; - TMR1L = 0; -#endif - TMR1ON = 1; - g_stTimer1.dw = 0L; -#endif -} - -DWORD Timer1Read( void ) -{ -#ifdef TIMER1_INT -#ifdef _PIC18 - g_stTimer1.w.h = g_wTimer1High; // high first so can check for change - g_stTimer1.w.l = TMR1; - if ( g_stTimer1.w.h != g_wTimer1High ) - { - g_stTimer1.w.h = g_wTimer1High; - g_stTimer1.w.l = TMR1; - } -#else - g_stTimer1.w.h = g_wTimer1High; // high first so can check for change - g_stTimer1.b.lh = TMR1H; - g_stTimer1.b.ll = TMR1L; - if ( g_stTimer1.w.h != g_wTimer1High || g_stTimer1.b.lh != TMR1H ) - { - g_stTimer1.w.h = g_wTimer1High; - g_stTimer1.b.lh = TMR1H; - g_stTimer1.b.ll = TMR1L; - } -#endif - return g_stTimer1.dw; -#else - return 0L; -#endif -} - diff --git a/src/libPIC/timers.h b/src/libPIC/timers.h deleted file mode 100644 index 9acb534..0000000 --- a/src/libPIC/timers.h +++ /dev/null @@ -1,112 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * PIC Timer Interface - *---------------------------------------------------------------------------- - * Timer #0 - Used by delay routines (dly_usec.c) - * Timer #1 - Fast clock counter - * Timer #2 - 1 msec software timer -*****************************************************************************/ - -/* prevent multiple inclusions */ -#ifndef _TIMERS_H_ -#define _TIMERS_H_ - -/***************************************************************************** - * includes -*****************************************************************************/ - -// this is application specific -#include "system.h" -#include "types.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -// Timer #1: 1:8 prescale, Fosc/4 (625000/sec @ 20Mhz, 1250000/sec @ 40Mhz) -#define COUNTER_SEC_TICKS ((XTAL*1000000L)/32L) -#define COUNTER_MSEC_TICKS (COUNTER_SEC_TICKS/1000L) - -// Timer #2 -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 1000L -#endif - -/***************************************************************************** - * macros -*****************************************************************************/ - -// Timer #1 -#ifdef TIMER1_INT -#define Timer1Rd() g_stTimer1.dw -#define Timer1Clr() g_stTimer1.dw=0 -#define Timer1Set(V) g_stTimer1.dw=(V) -#define Timer1Ticks() COUNTER_SEC_TICKS -#endif - -// Timer #2 (millisecond) -#ifdef TIMER2_INT -#define Timer2Rd() g_dwTimer2 -#define Timer2Clr() g_dwTimer2=0 -#define Timer2Set(V) g_dwTimer2=(V) -#endif - -#ifdef TIMER2_INT -#define clock() g_dwTimer2 -#ifdef SW_TIMERS -#define MsecTimerGet(i) g_wTimers2[i] -#define MsecTimerSet(i,d) g_wTimers2[i]=(d) -#endif -#else -#define clock() (Timer1Rd()/COUNTER_MSEC_TICKS) -#endif - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -// Timer #1 -#ifdef TIMER1_INT -extern volatile long_dword g_stTimer1; -#endif - -// Timer #2 -#ifdef TIMER2_INT -LIBBANK extern volatile DWORD g_dwTimer2; -#ifdef SW_TIMERS -LIBBANK extern volatile WORD g_wTimers2[SW_TIMERS]; -#endif -#endif - -/***************************************************************************** - * C function prototypes -*****************************************************************************/ -/* export C functions to C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -extern void TimerInit( void ); -extern void TimerHandler( void ); - -// timer #1 -extern void Timer1Clear( void ); -extern DWORD Timer1Read( void ); - -// timer #2 - -#ifdef __cpluscplus -} -#endif -#endif diff --git a/src/libPIC/types.h b/src/libPIC/types.h deleted file mode 120000 index b72bd04..0000000 --- a/src/libPIC/types.h +++ /dev/null @@ -1 +0,0 @@ -../include/embtypes.h \ No newline at end of file diff --git a/src/libPIC/watchdog.c b/src/libPIC/watchdog.c deleted file mode 100644 index 959e672..0000000 --- a/src/libPIC/watchdog.c +++ /dev/null @@ -1,61 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2008 - * ProbeStar Telematics, LLC - * All Rights Reserved. Proprietary and Confidential. - *============================================================================ - * Watchdog Initialization - *---------------------------------------------------------------------------- - * Details -*****************************************************************************/ - -/***************************************************************************** - * includes -*****************************************************************************/ - -#include "system.h" - -/***************************************************************************** - * defines -*****************************************************************************/ - -/***************************************************************************** - * macros -*****************************************************************************/ - -/***************************************************************************** - * structs & typedefs -*****************************************************************************/ - -/***************************************************************************** - * global constants -*****************************************************************************/ - -/***************************************************************************** - * global variables -*****************************************************************************/ - -/***************************************************************************** - * static constants -*****************************************************************************/ - -/***************************************************************************** - * static variables -*****************************************************************************/ - -/***************************************************************************** - * static prototypes -*****************************************************************************/ - -/***************************************************************************** - * C functions -*****************************************************************************/ - -void WatchdogInit( void ) -{ - // watchdog rate programming? -#ifdef _PIC18 - SWDTEN = 1; // unless already programmed in config -#else - OPTION |= 0b00000100; -#endif -} diff --git a/src/libsig++/AnalogInputChannel.cpp b/src/libsig++/AnalogInputChannel.cpp deleted file mode 100644 index 1687f5a..0000000 --- a/src/libsig++/AnalogInputChannel.cpp +++ /dev/null @@ -1,80 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "AnalogInputChannel.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -AnalogInputChannel::AnalogInputChannel() -{ -} - -AnalogInputChannel::AnalogInputChannel(const AnalogInputChannel ©) -{ -} - -AnalogInputChannel::~AnalogInputChannel() -{ -} - -AnalogInputChannel& AnalogInputChannel::operator=(const AnalogInputChannel &rhs) -{ - return *this; -} - -double AnalogInputChannel::ReadEu( void ) -{ - long raw; - double data; - raw = ReadRaw(); - Raw2Eu( &raw, &data, 1 ); - return data; -} diff --git a/src/libsig++/AnalogInputChannel.h b/src/libsig++/AnalogInputChannel.h deleted file mode 100644 index 7c2e9f3..0000000 --- a/src/libsig++/AnalogInputChannel.h +++ /dev/null @@ -1,62 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __AnalogInputChannel__ -#define __AnalogInputChannel__ - -/* includes *****************************************************************/ - -#include -#include - -#include "InputChannel.h" -#include "RawType.h" -#include "VoltType.h" - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class AnalogInputChannel : public InputChannel, public VoltType { - // public data -public: - - // protected data - - // private data -private: - - // static data - - // public methods -public: - // constructors - AnalogInputChannel(); - AnalogInputChannel(const AnalogInputChannel ©); - - // destructor - virtual ~AnalogInputChannel(); - - // operators - AnalogInputChannel &operator=(const AnalogInputChannel &rhs); - - // public methods - - // virtual functions - virtual double ReadEu( void ); - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/AnalogOutputChannel.cpp b/src/libsig++/AnalogOutputChannel.cpp deleted file mode 100644 index ea521b6..0000000 --- a/src/libsig++/AnalogOutputChannel.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "AnalogOutputChannel.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -AnalogOutputChannel::AnalogOutputChannel() -{ -} - -AnalogOutputChannel::AnalogOutputChannel(const AnalogOutputChannel ©) -{ -} - -AnalogOutputChannel::~AnalogOutputChannel() -{ -} - -AnalogOutputChannel& AnalogOutputChannel::operator=(const AnalogOutputChannel &rhs) -{ - return *this; -} - -void AnalogOutputChannel::WriteEu( double eu ) -{ - long raw; - Eu2Raw( &eu, &raw, 1 ); - WriteRaw( raw ); -} diff --git a/src/libsig++/AnalogOutputChannel.h b/src/libsig++/AnalogOutputChannel.h deleted file mode 100644 index abf5133..0000000 --- a/src/libsig++/AnalogOutputChannel.h +++ /dev/null @@ -1,62 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __AnalogOutputChannel__ -#define __AnalogOutputChannel__ - -/* includes *****************************************************************/ - -#include -#include - -#include "OutputChannel.h" -#include "RawType.h" -#include "VoltType.h" - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class AnalogOutputChannel : public OutputChannel, public VoltType { - // public data -public: - - // protected data - - // private data -private: - - // static data - - // public methods -public: - // constructors - AnalogOutputChannel(); - AnalogOutputChannel(const AnalogOutputChannel ©); - - // destructor - virtual ~AnalogOutputChannel(); - - // operators - AnalogOutputChannel &operator=(const AnalogOutputChannel &rhs); - - // public methods - - // virtual functions - virtual void WriteEu( double eu ); - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/BaseChannel.cpp b/src/libsig++/BaseChannel.cpp deleted file mode 100644 index 9bdee4a..0000000 --- a/src/libsig++/BaseChannel.cpp +++ /dev/null @@ -1,77 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "BaseChannel.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -BaseChannel::BaseChannel() -{ - Channel = 0; - Resolution = 0; -} - -BaseChannel::BaseChannel(const BaseChannel ©) -{ - Channel = copy.Channel; - Resolution = copy.Resolution; -} - -BaseChannel::~BaseChannel() -{ -} - -BaseChannel& BaseChannel::operator=(const BaseChannel &rhs) -{ - this->Channel = rhs.Channel; - this->Resolution = rhs.Resolution; - return *this; -} diff --git a/src/libsig++/BaseChannel.h b/src/libsig++/BaseChannel.h deleted file mode 100644 index 2f65697..0000000 --- a/src/libsig++/BaseChannel.h +++ /dev/null @@ -1,70 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __BaseChannel__ -#define __BaseChannel__ - -/* includes *****************************************************************/ - -#include -#include - -#include "Comedi.h" - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class BaseChannel { - // public data -public: - - // protected data -protected: - int Device; - int SubDevice; - int Channel; - int Resolution; // 8, 12, 16, 24, 32 bits - - // private data -private: - - // static data - - // public methods -public: - // constructors - BaseChannel(); - BaseChannel(const BaseChannel ©); - - // destructor - virtual ~BaseChannel(); - - // operators - BaseChannel &operator=(const BaseChannel &rhs); - - // public methods - void SetDevice( int dev, int sub=0, int chan=0 ) {Device=dev;SubDevice=sub;Channel=chan;}; - comedi_t *GetDevice(void) { return Comedi::GetDevice(Device); }; - void SetChannel( int chan ) { Channel = chan; }; - int GetChannel( void ) { return Channel; }; - void SetResolution( int bits ) { Resolution = bits; }; - int GetResolution( void ) { return Resolution; }; - - // virtual functions - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/BaseDevice.cpp b/src/libsig++/BaseDevice.cpp deleted file mode 100644 index 427652d..0000000 --- a/src/libsig++/BaseDevice.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "BaseDevice.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -BaseDevice::BaseDevice() -{ -} - -BaseDevice::~BaseDevice() -{ -} diff --git a/src/libsig++/BaseDevice.h b/src/libsig++/BaseDevice.h deleted file mode 100644 index 994516e..0000000 --- a/src/libsig++/BaseDevice.h +++ /dev/null @@ -1,54 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __BaseDevice__ -#define __BaseDevice__ - -/* includes *****************************************************************/ - -#include -#include - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class BaseDevice { - // public data -public: - std::string Name; - - // protected data - - // private data -private: - - // static data - - // public methods -public: - // constructors - BaseDevice(); - - // destructor - virtual ~BaseDevice(); - - // public methods - - // virtual functions - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/BaseSignal.cpp b/src/libsig++/BaseSignal.cpp deleted file mode 100644 index 38121ba..0000000 --- a/src/libsig++/BaseSignal.cpp +++ /dev/null @@ -1,75 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "BaseSignal.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -BaseSignal::BaseSignal() -{ -} - -BaseSignal::BaseSignal(const BaseSignal ©) -{ - Name = copy.Name; - Units = copy.Units; -} - -BaseSignal::~BaseSignal() -{ -} - -BaseSignal& BaseSignal::operator=(const BaseSignal &rhs) -{ - this->Name = rhs.Name; - this->Units = rhs.Units; - return *this; -} diff --git a/src/libsig++/BaseSignal.h b/src/libsig++/BaseSignal.h deleted file mode 100644 index fd02834..0000000 --- a/src/libsig++/BaseSignal.h +++ /dev/null @@ -1,59 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __BaseSignal__ -#define __BaseSignal__ - -/* includes *****************************************************************/ - -#include -#include - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -// based on .dbc data - -/* c class definitions ******************************************************/ - -class BaseSignal { - // public data -public: - std::string Name; // Signal Name - std::string Units; // Signal Units - - // private data -private: - - // static data - - // public methods -public: - // constructors - BaseSignal(); - BaseSignal(const BaseSignal &BaseSignal); - - // destructor - virtual ~BaseSignal(); - - // operators - BaseSignal &operator=(const BaseSignal &rhs); - - // virtual functions - - // public methods - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/BoardDevice.cpp b/src/libsig++/BoardDevice.cpp deleted file mode 100644 index 4499e12..0000000 --- a/src/libsig++/BoardDevice.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "BoardDevice.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -BoardDevice::BoardDevice() -{ -} - -BoardDevice::BoardDevice( const char *name, comedi_t *it ) -{ - Name = name; - Handle = it; -} - -BoardDevice::~BoardDevice() -{ - AnalogInputs.clear(); - AnalogOutputs.clear(); - DigitalInputs.clear(); - DigitalOutputs.clear(); -} diff --git a/src/libsig++/BoardDevice.h b/src/libsig++/BoardDevice.h deleted file mode 100644 index dfc2781..0000000 --- a/src/libsig++/BoardDevice.h +++ /dev/null @@ -1,73 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __BoardDevice__ -#define __BoardDevice__ - -/* includes *****************************************************************/ - -#include -#include -#include - -#include "comedilib.hpp" - -#include "BaseDevice.h" -#include "AnalogInputChannel.h" -#include "AnalogOutputChannel.h" -#include "DigitalInputChannel.h" -#include "DigitalOutputChannel.h" -#include "DigitalInOutChannel.h" -//#include "CounterChannel.h" -//#include "TimerChannel.h" -//#include "PWMChannel.h" - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class BoardDevice : public BaseDevice { - // public data -public: - std::vector AnalogInputs; - std::vector AnalogOutputs; - std::vector DigitalInputs; - std::vector DigitalOutputs; - std::vector DigitalInOuts; - - // protected data - - // private data -private: - comedi_t *Handle; - - // static data - - // public methods -public: - // constructors - BoardDevice(); - BoardDevice( const char *name, comedi_t *it ); - - // destructor - virtual ~BoardDevice(); - - // public methods - - // virtual functions - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/Comedi.cpp b/src/libsig++/Comedi.cpp deleted file mode 100644 index a6bfcaa..0000000 --- a/src/libsig++/Comedi.cpp +++ /dev/null @@ -1,178 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "Comedi.h" -using namespace comedi; - -#include "BoardDevice.h" - -#include "netlib.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -static int ndevices = 0; -static comedi_t *devices[COMEDI_NDEVICES] = { NULL }; - -BoardDevice *Devices[COMEDI_NDEVICES] = { NULL }; - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -Comedi::Comedi() -{ - log_printf( "Comedi: Initializing" ); - - // poll for devices - for ( int i=0 ; i> 16)&0xff, (vers >> 8)&0xff, vers&0xff, num ); - - // instantiate class - BoardDevice *dev = new BoardDevice( name, it ); - Devices[i] = dev; - - AnalogInputChannel ad; - AnalogOutputChannel da; - DigitalInputChannel di; - DigitalOutputChannel doh; - DigitalInOutChannel dio; - - // log devices and subdevice info - for ( unsigned int j=0 ; jAnalogInputs.push_back( ad ); - break; - case COMEDI_SUBD_AO: /* analog output */ - da.SetDevice( i, j, k ); - dev->AnalogOutputs.push_back( da ); - break; - case COMEDI_SUBD_DI: /* digital input */ - di.SetDevice( i, j, k ); - dev->DigitalInputs.push_back( di ); - break; - case COMEDI_SUBD_DO: /* digital output */ - doh.SetDevice( i, j, k ); - dev->DigitalOutputs.push_back( doh ); - break; - case COMEDI_SUBD_DIO: /* digital input/output */ - dio.SetDevice( i, j, k ); - dev->DigitalInOuts.push_back( dio ); - break; - case COMEDI_SUBD_COUNTER: /* counter */ - break; - case COMEDI_SUBD_TIMER: /* timer */ - break; - case COMEDI_SUBD_MEMORY: /* memory, EEPROM, DPRAM */ - break; - case COMEDI_SUBD_CALIB: /* calibration DACs */ - break; - case COMEDI_SUBD_PROC: /* processor, DSP */ - break; - case COMEDI_SUBD_SERIAL: /* serial IO */ - break; - case COMEDI_SUBD_PWM: /* PWM */ - break; - } - } - } - } - else - break; - } - log_printf( "Comedi: %d devices found" ); -} - -Comedi::~Comedi() -{ - while ( ndevices ) - { - delete Devices[ndevices]; - comedi_close( devices[ndevices] ); - ndevices--; - } -} - -comedi_t *Comedi::GetDevice( int device ) -{ - if ( device < 0 || device >= COMEDI_NDEVICES ) - { - // should throw exception - throw DeviceIndexError(); - return NULL; - } - return devices[device]; -} diff --git a/src/libsig++/Comedi.h b/src/libsig++/Comedi.h deleted file mode 100644 index c0faf9f..0000000 --- a/src/libsig++/Comedi.h +++ /dev/null @@ -1,59 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __Comedi__ -#define __Comedi__ - -/* includes *****************************************************************/ - -#include -#include -#include "comedilib.hpp" - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class Comedi { - // public data -public: - std::string Name; - - // protected data - - // private data -private: - - // static data - - // public methods -public: - // constructors - Comedi(); - - // destructor - virtual ~Comedi(); - - // exceptions - class DeviceIndexError{}; - - // public methods - - // virtual functions - - // static methods -static comedi_t *GetDevice( int device ); - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/DigitalInOutChannel.cpp b/src/libsig++/DigitalInOutChannel.cpp deleted file mode 100644 index 97907b7..0000000 --- a/src/libsig++/DigitalInOutChannel.cpp +++ /dev/null @@ -1,86 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "DigitalInOutChannel.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -DigitalInOutChannel::DigitalInOutChannel() -{ - Resolution = 1; -} - -DigitalInOutChannel::DigitalInOutChannel(const DigitalInOutChannel ©) -{ -} - -DigitalInOutChannel::~DigitalInOutChannel() -{ -} - -DigitalInOutChannel& DigitalInOutChannel::operator=(const DigitalInOutChannel &rhs) -{ - return *this; -} - -long DigitalInOutChannel::ReadRaw( void ) -{ - unsigned int bit; - - comedi_dio_read( GetDevice(), SubDevice, Channel, &bit); - - return bit; -} - -void DigitalInOutChannel::WriteRaw( long data ) -{ - comedi_dio_write( GetDevice(), SubDevice, Channel, (unsigned int)data); -} diff --git a/src/libsig++/DigitalInOutChannel.h b/src/libsig++/DigitalInOutChannel.h deleted file mode 100644 index 2c449e8..0000000 --- a/src/libsig++/DigitalInOutChannel.h +++ /dev/null @@ -1,62 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __DigitalInOutChannel__ -#define __DigitalInOutChannel__ - -/* includes *****************************************************************/ - -#include -#include - -#include "InOutChannel.h" -#include "RawType.h" - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class DigitalInOutChannel : public InOutChannel, public RawType { - // public data -public: - - // protected data - - // private data -private: - - // static data - - // public methods -public: - // constructors - DigitalInOutChannel(); - DigitalInOutChannel(const DigitalInOutChannel ©); - - // destructor - virtual ~DigitalInOutChannel(); - - // operators - DigitalInOutChannel &operator=(const DigitalInOutChannel &rhs); - - // public methods - long ReadRaw( void ); - void WriteRaw( long data ); - - // virtual functions - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/DigitalInputChannel.cpp b/src/libsig++/DigitalInputChannel.cpp deleted file mode 100644 index 879f099..0000000 --- a/src/libsig++/DigitalInputChannel.cpp +++ /dev/null @@ -1,81 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "DigitalInputChannel.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -DigitalInputChannel::DigitalInputChannel() -{ - Resolution = 1; -} - -DigitalInputChannel::DigitalInputChannel(const DigitalInputChannel ©) -{ -} - -DigitalInputChannel::~DigitalInputChannel() -{ -} - -DigitalInputChannel& DigitalInputChannel::operator=(const DigitalInputChannel &rhs) -{ - return *this; -} - -long DigitalInputChannel::ReadRaw( void ) -{ - unsigned int bit; - - comedi_dio_read( GetDevice(), SubDevice, Channel, &bit); - - return bit; -} diff --git a/src/libsig++/DigitalInputChannel.h b/src/libsig++/DigitalInputChannel.h deleted file mode 100644 index 99028bc..0000000 --- a/src/libsig++/DigitalInputChannel.h +++ /dev/null @@ -1,62 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __DigitalInputChannel__ -#define __DigitalInputChannel__ - -/* includes *****************************************************************/ - -#include -#include - -#include "InputChannel.h" -#include "RawType.h" - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class DigitalInputChannel : public InputChannel, public RawType { - // public data -public: - - // protected data - - // private data -private: - - // static data - - // public methods -public: - // constructors - DigitalInputChannel(); - DigitalInputChannel(const DigitalInputChannel ©); - - // destructor - virtual ~DigitalInputChannel(); - - // operators - DigitalInputChannel &operator=(const DigitalInputChannel &rhs); - - // public methods - long ReadRaw( void ); - void WriteRaw( long data ); - - // virtual functions - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/DigitalOutputChannel.cpp b/src/libsig++/DigitalOutputChannel.cpp deleted file mode 100644 index 581dbd0..0000000 --- a/src/libsig++/DigitalOutputChannel.cpp +++ /dev/null @@ -1,77 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "DigitalOutputChannel.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -DigitalOutputChannel::DigitalOutputChannel() -{ - Resolution = 1; -} - -DigitalOutputChannel::DigitalOutputChannel(const DigitalOutputChannel ©) -{ -} - -DigitalOutputChannel::~DigitalOutputChannel() -{ -} - -DigitalOutputChannel& DigitalOutputChannel::operator=(const DigitalOutputChannel &rhs) -{ - return *this; -} - -void DigitalOutputChannel::WriteRaw( long data ) -{ - comedi_dio_write( GetDevice(), SubDevice, Channel, (unsigned int)data); -} diff --git a/src/libsig++/DigitalOutputChannel.h b/src/libsig++/DigitalOutputChannel.h deleted file mode 100644 index b508ef9..0000000 --- a/src/libsig++/DigitalOutputChannel.h +++ /dev/null @@ -1,61 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __DigitalOutputChannel__ -#define __DigitalOutputChannel__ - -/* includes *****************************************************************/ - -#include -#include - -#include "OutputChannel.h" -#include "RawType.h" - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class DigitalOutputChannel : public OutputChannel, public RawType { - // public data -public: - - // protected data - - // private data -private: - - // static data - - // public methods -public: - // constructors - DigitalOutputChannel(); - DigitalOutputChannel(const DigitalOutputChannel ©); - - // destructor - virtual ~DigitalOutputChannel(); - - // operators - DigitalOutputChannel &operator=(const DigitalOutputChannel &rhs); - - // public methods - void WriteRaw( long data ); - - // virtual functions - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/EuType.cpp b/src/libsig++/EuType.cpp deleted file mode 100644 index 9ead516..0000000 --- a/src/libsig++/EuType.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "EuType.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -EuType::EuType() -{ -} - -EuType::~EuType() -{ -} diff --git a/src/libsig++/EuType.h b/src/libsig++/EuType.h deleted file mode 100644 index b368fb2..0000000 --- a/src/libsig++/EuType.h +++ /dev/null @@ -1,57 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __EuType__ -#define __EuType__ - -/* includes *****************************************************************/ - -#include -#include - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -// based on .dbc data - -/* c class definitions ******************************************************/ - -class EuType { - // public data -public: - - // private data -private: - - // static data - - // public methods -public: - // constructors - EuType(); - EuType(const EuType ©); - - // destructor - virtual ~EuType(); - - // operators - EuType &operator=(const EuType &rhs); - - // virtual functions - - // public methods - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/InOutChannel.cpp b/src/libsig++/InOutChannel.cpp deleted file mode 100644 index 0b19386..0000000 --- a/src/libsig++/InOutChannel.cpp +++ /dev/null @@ -1,71 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "InOutChannel.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -InOutChannel::InOutChannel() -{ -} - -InOutChannel::InOutChannel(const InOutChannel ©) -{ -} - -InOutChannel::~InOutChannel() -{ -} - -InOutChannel& InOutChannel::operator=(const InOutChannel &rhs) -{ - return *this; -} diff --git a/src/libsig++/InOutChannel.h b/src/libsig++/InOutChannel.h deleted file mode 100644 index 6af31f9..0000000 --- a/src/libsig++/InOutChannel.h +++ /dev/null @@ -1,63 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __InOutChannel__ -#define __InOutChannel__ - -/* includes *****************************************************************/ - -#include -#include - -#include "BaseChannel.h" - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class InOutChannel : public BaseChannel { - // public data -public: - - // protected data - - // private data -private: - - // static data - - // public methods -public: - // constructors - InOutChannel(); - InOutChannel(const InOutChannel ©); - - // destructor - virtual ~InOutChannel(); - - // operators - InOutChannel &operator=(const InOutChannel &rhs); - - // public methods - - // virtual functions - virtual long ReadRaw( void ) { return 0; }; - virtual double ReadEu( void ) { return (double)ReadRaw(); }; - virtual void WriteRaw( long raw ) {}; - virtual void WriteEu( double eu ) { WriteRaw((long)eu); }; - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/InputChannel.cpp b/src/libsig++/InputChannel.cpp deleted file mode 100644 index f84e325..0000000 --- a/src/libsig++/InputChannel.cpp +++ /dev/null @@ -1,71 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "InputChannel.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -InputChannel::InputChannel() -{ -} - -InputChannel::InputChannel(const InputChannel ©) -{ -} - -InputChannel::~InputChannel() -{ -} - -InputChannel& InputChannel::operator=(const InputChannel &rhs) -{ - return *this; -} diff --git a/src/libsig++/InputChannel.h b/src/libsig++/InputChannel.h deleted file mode 100644 index f366ab2..0000000 --- a/src/libsig++/InputChannel.h +++ /dev/null @@ -1,61 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __InputChannel__ -#define __InputChannel__ - -/* includes *****************************************************************/ - -#include -#include - -#include "BaseChannel.h" - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class InputChannel : public BaseChannel { - // public data -public: - - // protected data - - // private data -private: - - // static data - - // public methods -public: - // constructors - InputChannel(); - InputChannel(const InputChannel ©); - - // destructor - virtual ~InputChannel(); - - // operators - InputChannel &operator=(const InputChannel &rhs); - - // public methods - - // virtual functions - virtual long ReadRaw( void ) { return 0; }; - virtual double ReadEu( void ) { return (double)ReadRaw(); }; - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/InputDevice.cpp b/src/libsig++/InputDevice.cpp deleted file mode 100644 index 6582907..0000000 --- a/src/libsig++/InputDevice.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "InputDevice.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -InputDevice::InputDevice() -{ -} - -InputDevice::~InputDevice() -{ -} - -int InputDevice::ReadChannel( long *data, int chan, int n ) -{ - return 0; -} - -int InputDevice::ReadSample( long *data, int start, int end, int n ) -{ - return 0; -} diff --git a/src/libsig++/InputDevice.h b/src/libsig++/InputDevice.h deleted file mode 100644 index 6e53c7d..0000000 --- a/src/libsig++/InputDevice.h +++ /dev/null @@ -1,55 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __InputDevice__ -#define __InputDevice__ - -/* includes *****************************************************************/ - -#include -#include - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class InputDevice { - // public data -public: - - // protected data - - // private data -private: - - // static data - - // public methods -public: - // constructors - InputDevice(); - - // destructor - virtual ~InputDevice(); - - // public methods - - // virtual functions - virtual int ReadChannel( long *data, int chan, int n=1 ); - virtual int ReadSample( long *data, int start, int end, int n=1 ); - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/OutputChannel.cpp b/src/libsig++/OutputChannel.cpp deleted file mode 100644 index 2ca0f57..0000000 --- a/src/libsig++/OutputChannel.cpp +++ /dev/null @@ -1,71 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "OutputChannel.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -OutputChannel::OutputChannel() -{ -} - -OutputChannel::OutputChannel(const OutputChannel ©) -{ -} - -OutputChannel::~OutputChannel() -{ -} - -OutputChannel& OutputChannel::operator=(const OutputChannel &rhs) -{ - return *this; -} diff --git a/src/libsig++/OutputChannel.h b/src/libsig++/OutputChannel.h deleted file mode 100644 index 23ef648..0000000 --- a/src/libsig++/OutputChannel.h +++ /dev/null @@ -1,61 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __OutputChannel__ -#define __OutputChannel__ - -/* includes *****************************************************************/ - -#include -#include - -#include "BaseChannel.h" - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class OutputChannel : public BaseChannel { - // public data -public: - - // protected data - - // private data -private: - - // static data - - // public methods -public: - // constructors - OutputChannel(); - OutputChannel(const OutputChannel ©); - - // destructor - virtual ~OutputChannel(); - - // operators - OutputChannel &operator=(const OutputChannel &rhs); - - // public methods - - // virtual functions - virtual void WriteRaw( long raw ) {}; - virtual void WriteEu( double eu ) { WriteRaw((long)eu); }; - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/OutputDevice.cpp b/src/libsig++/OutputDevice.cpp deleted file mode 100644 index 76a09e5..0000000 --- a/src/libsig++/OutputDevice.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "OutputDevice.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -OutputDevice::OutputDevice() -{ -} - -OutputDevice::~OutputDevice() -{ -} - -int OutputDevice::WriteChannel( const long *data, int chan, int n ) -{ - return 0; -} - -int OutputDevice::WriteSample( const long *data, int start, int end, int n ) -{ - return 0; -} diff --git a/src/libsig++/OutputDevice.h b/src/libsig++/OutputDevice.h deleted file mode 100644 index b1f398d..0000000 --- a/src/libsig++/OutputDevice.h +++ /dev/null @@ -1,55 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __OutputDevice__ -#define __OutputDevice__ - -/* includes *****************************************************************/ - -#include -#include - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class OutputDevice { - // public data -public: - - // protected data - - // private data -private: - - // static data - - // public methods -public: - // constructors - OutputDevice(); - - // destructor - virtual ~OutputDevice(); - - // public methods - - // virtual functions - virtual int WriteChannel( const long *data, int chan, int n=1 ); - virtual int WriteSample( const long *data, int start, int end, int n=1 ); - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/RawType.cpp b/src/libsig++/RawType.cpp deleted file mode 100644 index f4d232f..0000000 --- a/src/libsig++/RawType.cpp +++ /dev/null @@ -1,112 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "RawType.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -RawType::RawType() -{ - Shift = 0; - Mask = -1; - Signed = false; -} - -RawType::RawType(const RawType ©) -{ - Shift = copy.Shift; - Mask = copy.Mask; - Signed = copy.Signed; -} - -RawType::~RawType() -{ -} - -RawType& RawType::operator=(const RawType &rhs) -{ - this->Shift = rhs.Shift; - this->Mask = rhs.Mask; - this->Signed = rhs.Signed; - return *this; -} - -long RawType::SetRawMask( int size ) -{ - Mask = ~(-1L << size); - return Mask; -} - -int RawType::Raw2Eu( long *raw, double *eu, int n ) -{ - int t = n; - raw += n; - eu += n; - - while ( n-- ) - { - long val = (*--raw >> Shift) & Mask; - - if ( Signed && val && (val & (~Mask >> 1)) ) - val |= ~Mask; - - *--eu = (double)(val); - } - return t; -} - -int RawType::Eu2Raw( double *eu, long *raw, int n ) -{ - int t = n; - while ( n-- ) - *raw++ = ((long)*eu++ & Mask) << Shift; - return t; -} diff --git a/src/libsig++/RawType.h b/src/libsig++/RawType.h deleted file mode 100644 index 52611c9..0000000 --- a/src/libsig++/RawType.h +++ /dev/null @@ -1,65 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __RawType__ -#define __RawType__ - -/* includes *****************************************************************/ - -#include -#include - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class RawType { - // public data -public: - - // private data -private: - // shift and mask - long Mask; - int Shift; - bool Signed; - - // static data - - // public methods -public: - // constructors - RawType(); - RawType(const RawType ©); - - // destructor - virtual ~RawType(); - - // operators - RawType &operator=(const RawType &rhs); - - // public methods - long SetRawMask( int size ); - void SetRawMaskShift( long mask, int shift=0 ) { Mask=mask;Shift=shift; }; - long GetRawMask( void ) { return Mask; }; - int GetRawShift( void ) { return Shift; }; - - // virtual functions - virtual int Raw2Eu( long *raw, double *eu, int n=1 ); - virtual int Eu2Raw( double *eu, long *raw, int n=1 ); - - // static methods - - // private methods -private: -}; - -#endif diff --git a/src/libsig++/TODO b/src/libsig++/TODO deleted file mode 100644 index cfd63a4..0000000 --- a/src/libsig++/TODO +++ /dev/null @@ -1,8 +0,0 @@ - - TODO - ==== - -Work on configuration and setup -Map channel i/o into sample i/o -Implement COMEDI Interface - diff --git a/src/libsig++/VoltType.cpp b/src/libsig++/VoltType.cpp deleted file mode 100644 index db28e80..0000000 --- a/src/libsig++/VoltType.cpp +++ /dev/null @@ -1,143 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2007 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -//**************************************************************************** -// includes -//***************************************************************************/ - -#include -#include -#include - -#include -#include - -#include "VoltType.h" - -//**************************************************************************** -// defines -//***************************************************************************/ - -//**************************************************************************** -// macros -//***************************************************************************/ - -//**************************************************************************** -// structs & typedefs -//***************************************************************************/ - -//**************************************************************************** -// global constants -//***************************************************************************/ - -//**************************************************************************** -// global variables -//***************************************************************************/ - -//**************************************************************************** -// static constants -//***************************************************************************/ - -//**************************************************************************** -// static variables -//***************************************************************************/ - -//**************************************************************************** -// static functions -//***************************************************************************/ - -//**************************************************************************** -// C++ functions -//***************************************************************************/ - -VoltType::VoltType() -{ - Zero = 0; - Gain = 1.0; - Scale = 1.0; - Offset = 0.0; -} - -VoltType::VoltType(const VoltType ©) -{ - Zero = copy.Zero; - Gain = copy.Gain; - Scale = copy.Scale; - Offset = copy.Offset; -} - -VoltType::~VoltType() -{ -} - -VoltType& VoltType::operator=(const VoltType &rhs) -{ - this->Zero = rhs.Zero; - this->Gain = rhs.Gain; - this->Scale = rhs.Scale; - this->Offset = rhs.Offset; - return *this; -} - -int VoltType::Raw2Volts( long *raw, double *volts, int n ) -{ - int t = n; - raw += n; - volts += n; - - while ( n-- ) - { - // calibs - double volt = ((double)*--raw + Zero) * Gain; - - // scale - volt = volt*Scale + Offset; - - *--volts = volt; - } - return t; -} - -int VoltType::Volts2Raw( double *volts, long *raw, int n ) -{ - int t = n; - - while ( n-- ) - { - double volt = *volts++; - - // unscale - volt = (volt - Offset) / Scale; - - // uncalib - *raw++ = (long)volt/Gain - Zero; - } - return t; -} - -int VoltType::Volts2Eu( double *volts, double *eu, int n ) -{ - int t = n; - - while ( n-- ) - { - // scale - *eu++ = *volts++ * Scale + Offset; - } - return t; -} - -int VoltType::Eu2Volts( double *eu, double *volts, int n ) -{ - int t = n; - - while ( n-- ) - { - // unscale - *volts++ = (*eu++ - Offset) / Scale; - } - return t; -} diff --git a/src/libsig++/VoltType.h b/src/libsig++/VoltType.h deleted file mode 100644 index aa03747..0000000 --- a/src/libsig++/VoltType.h +++ /dev/null @@ -1,80 +0,0 @@ -//**************************************************************************** -// Copyright (C) 2009 -// ProbeStar Telematics -// All Rights Reserved. Proprietary and Confidential. -//============================================================================ - -/* prevent multiple inclusions */ -#ifndef __VoltType__ -#define __VoltType__ - -/* includes *****************************************************************/ - -#include -#include - -#include "RawType.h" - -/* defines ******************************************************************/ - -/* macros *******************************************************************/ - -/* structs & typedefs *******************************************************/ - -/* c class definitions ******************************************************/ - -class VoltType : public RawType { - // public data -public: - -protected: - // conversion - double Scale; - double Offset; - - // private data -private: - // calibration - double Gain; - long Zero; - - // static data - - // public methods -public: - // constructors - VoltType(); - VoltType(const VoltType ©); - - // destructor - virtual ~VoltType(); - - // operators - VoltType &operator=(const VoltType &rhs); - - // virtual functions - - // public methods - void SetCalibration( double gain, double zero ) { Gain=gain; Zero=zero; }; - void SetScaling( double scale=1.0, double offset=0.0 ) { Scale=scale; Offset=offset; }; - double GetScale( void ) { return Scale; }; - double GetOffset( void ) { return Offset; }; - - int Raw2Volts( long *raw, double *eu, int n=1 ); - int Volts2Raw( double *eu, long *raw, int n=1 ); - - // override - int Raw2Eu( long *raw, double *eu, int n=1 ) { return Raw2Volts(raw,eu,n); }; - int Eu2Raw( double *eu, long *raw, int n=1 ) { return Volts2Raw(eu,raw,n); }; - - // conversion - int Volts2Eu( double *volts, double *eu, int n=1 ); - int Eu2Volts( double *eu, double *volts, int n=1 ); - - // static methods - - // private methods -private: -}; - -#endif