mirror of
https://github.com/halleysfifthinc/AVCLAN-Mockingboard.git
synced 2026-08-11 16:32:52 +00:00
Compare commits
76 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7352a279e7 | |||
| 5ce848f7dd | |||
| 80e971b978 | |||
| 9880c66c0f | |||
| b809e91d73 | |||
| 17f5510b16 | |||
| 1d6690a234 | |||
| 0fe2f64eed | |||
| ebb5ec95ca | |||
| cabcd06e67 | |||
| ff55d7e671 | |||
| 1cafed82d0 | |||
| 9fcca0a6fb | |||
| 3c5c1d269e | |||
| de658f1fb7 | |||
| 64cd4b9958 | |||
| 18202c5264 | |||
| 08f7fe934d | |||
| da6a3371fd | |||
| bcd07d0ffb | |||
| 4c19f27992 | |||
| 012649d156 | |||
| a9ea586ed4 | |||
| 7245695bc7 | |||
| 09bcd75811 | |||
| d6d1995ae4 | |||
| 332fb4545f | |||
| ba40f96d44 | |||
| ba27167b2e | |||
| d7af6529ef | |||
| 82ab967b7c | |||
| cedad9df9f | |||
| f13ccffa8d | |||
| 230709a103 | |||
| 9c024506c0 | |||
| 3fd8c0255b | |||
| 9a47ba77eb | |||
| 064fc01ac6 | |||
| b736816de0 | |||
| 3e008f32eb | |||
| b9bae7a65f | |||
| 9581957eca | |||
| 003c4c7f2f | |||
| acd6709e73 | |||
| 70d153f77c | |||
| 2a5b95c3f5 | |||
| 208fe2a097 | |||
| e14cbe40c0 | |||
| 408f648f77 | |||
| 9226e7e0f8 | |||
| 8a7184a620 | |||
| 4952ecb12b | |||
| 368ac7cb5f | |||
| fb0bbbe3ca | |||
| eb93931522 | |||
| 23ea7ee463 | |||
| 5559f38a51 | |||
| 522fb41290 | |||
| 553dadfdd0 | |||
| e21f1a979a | |||
| 4fcdf4af36 | |||
| c4f67378ae | |||
| 48b20a9c5c | |||
| c07083423f | |||
| 98e371b529 | |||
| d27250ec11 | |||
| 5ba6e46827 | |||
| 14bf33bb97 | |||
| 84fa2fdebc | |||
| 1da1a52c68 | |||
| e8d7f5b297 | |||
| 241b7cf50a | |||
| 66633db24e | |||
| feccda9e69 | |||
| 0a9bd4d988 | |||
| 49ceb1e5e8 |
@@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
UseCRLF: false
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
AllowShortBlocksOnASingleLine: Empty
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentPPDirectives: BeforeHash
|
||||||
|
AlignConsecutiveMacros: Consecutive
|
||||||
|
...
|
||||||
+291
@@ -0,0 +1,291 @@
|
|||||||
|
---
|
||||||
|
Checks: "-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-core.NullDereference,bugprone-*,misc-*,modernize-*,performance-*"
|
||||||
|
WarningsAsErrors: ""
|
||||||
|
HeaderFilterRegex: ""
|
||||||
|
AnalyzeTemporaryDtors: false
|
||||||
|
FormatStyle: none
|
||||||
|
CheckOptions:
|
||||||
|
- key: bugprone-argument-comment.CommentBoolLiterals
|
||||||
|
value: "0"
|
||||||
|
- key: bugprone-argument-comment.CommentCharacterLiterals
|
||||||
|
value: "0"
|
||||||
|
- key: bugprone-argument-comment.CommentFloatLiterals
|
||||||
|
value: "0"
|
||||||
|
- key: bugprone-argument-comment.CommentIntegerLiterals
|
||||||
|
value: "0"
|
||||||
|
- key: bugprone-argument-comment.CommentNullPtrs
|
||||||
|
value: "0"
|
||||||
|
- key: bugprone-argument-comment.CommentStringLiterals
|
||||||
|
value: "0"
|
||||||
|
- key: bugprone-argument-comment.CommentUserDefinedLiterals
|
||||||
|
value: "0"
|
||||||
|
- key: bugprone-argument-comment.IgnoreSingleArgument
|
||||||
|
value: "0"
|
||||||
|
- key: bugprone-argument-comment.StrictMode
|
||||||
|
value: "0"
|
||||||
|
- key: bugprone-assert-side-effect.AssertMacros
|
||||||
|
value: assert,NSAssert,NSCAssert
|
||||||
|
- key: bugprone-assert-side-effect.CheckFunctionCalls
|
||||||
|
value: "false"
|
||||||
|
- key: bugprone-assert-side-effect.IgnoredFunctions
|
||||||
|
value: __builtin_expect
|
||||||
|
- key: bugprone-dangling-handle.HandleClasses
|
||||||
|
value: "std::basic_string_view;std::experimental::basic_string_view"
|
||||||
|
- key: bugprone-dynamic-static-initializers.HeaderFileExtensions
|
||||||
|
value: ";h;hh;hpp;hxx"
|
||||||
|
- key: bugprone-easily-swappable-parameters.IgnoredParameterNames
|
||||||
|
value: '"";iterator;Iterator;begin;Begin;end;End;first;First;last;Last;lhs;LHS;rhs;RHS'
|
||||||
|
- key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes
|
||||||
|
value: "bool;Bool;_Bool;it;It;iterator;Iterator;inputit;InputIt;forwardit;ForwardIt;bidirit;BidirIt;constiterator;const_iterator;Const_Iterator;Constiterator;ConstIterator;RandomIt;randomit;random_iterator;ReverseIt;reverse_iterator;reverse_const_iterator;ConstReverseIterator;Const_Reverse_Iterator;const_reverse_iterator;Constreverseiterator;constreverseiterator"
|
||||||
|
- key: bugprone-easily-swappable-parameters.MinimumLength
|
||||||
|
value: "2"
|
||||||
|
- key: bugprone-easily-swappable-parameters.ModelImplicitConversions
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold
|
||||||
|
value: "1"
|
||||||
|
- key: bugprone-easily-swappable-parameters.QualifiersMix
|
||||||
|
value: "false"
|
||||||
|
- key: bugprone-easily-swappable-parameters.SuppressParametersUsedTogether
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-exception-escape.FunctionsThatShouldNotThrow
|
||||||
|
value: ""
|
||||||
|
- key: bugprone-exception-escape.IgnoredExceptions
|
||||||
|
value: ""
|
||||||
|
- key: bugprone-implicit-widening-of-multiplication-result.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: bugprone-implicit-widening-of-multiplication-result.UseCXXHeadersInCppSources
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-misplaced-widening-cast.CheckImplicitCasts
|
||||||
|
value: "false"
|
||||||
|
- key: bugprone-narrowing-conversions.IgnoreConversionFromTypes
|
||||||
|
value: ""
|
||||||
|
- key: bugprone-narrowing-conversions.PedanticMode
|
||||||
|
value: "false"
|
||||||
|
- key: bugprone-narrowing-conversions.WarnOnEquivalentBitWidth
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-narrowing-conversions.WarnOnFloatingPointNarrowingConversion
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-narrowing-conversions.WarnOnIntegerNarrowingConversion
|
||||||
|
value: "false"
|
||||||
|
- key: bugprone-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-narrowing-conversions.WarnWithinTemplateInstantiation
|
||||||
|
value: "false"
|
||||||
|
- key: bugprone-not-null-terminated-result.WantToUseSafeFunctions
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-reserved-identifier.AggressiveDependentMemberLookup
|
||||||
|
value: "false"
|
||||||
|
- key: bugprone-reserved-identifier.AllowedIdentifiers
|
||||||
|
value: ""
|
||||||
|
- key: bugprone-reserved-identifier.Invert
|
||||||
|
value: "false"
|
||||||
|
- key: bugprone-signal-handler.AsyncSafeFunctionSet
|
||||||
|
value: POSIX
|
||||||
|
- key: bugprone-signed-char-misuse.CharTypdefsToIgnore
|
||||||
|
value: ""
|
||||||
|
- key: bugprone-signed-char-misuse.DiagnoseSignedUnsignedCharComparisons
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-sizeof-expression.WarnOnSizeOfConstant
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression
|
||||||
|
value: "false"
|
||||||
|
- key: bugprone-sizeof-expression.WarnOnSizeOfThis
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-string-constructor.LargeLengthThreshold
|
||||||
|
value: "8388608"
|
||||||
|
- key: bugprone-string-constructor.StringNames
|
||||||
|
value: "::std::basic_string;::std::basic_string_view"
|
||||||
|
- key: bugprone-string-constructor.WarnOnLargeLength
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-stringview-nullptr.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: bugprone-suspicious-enum-usage.StrictMode
|
||||||
|
value: "false"
|
||||||
|
- key: bugprone-suspicious-include.HeaderFileExtensions
|
||||||
|
value: ";h;hh;hpp;hxx"
|
||||||
|
- key: bugprone-suspicious-include.ImplementationFileExtensions
|
||||||
|
value: "c;cc;cpp;cxx"
|
||||||
|
- key: bugprone-suspicious-missing-comma.MaxConcatenatedTokens
|
||||||
|
value: "5"
|
||||||
|
- key: bugprone-suspicious-missing-comma.RatioThreshold
|
||||||
|
value: "0.200000"
|
||||||
|
- key: bugprone-suspicious-missing-comma.SizeThreshold
|
||||||
|
value: "5"
|
||||||
|
- key: bugprone-suspicious-string-compare.StringCompareLikeFunctions
|
||||||
|
value: ""
|
||||||
|
- key: bugprone-suspicious-string-compare.WarnOnImplicitComparison
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison
|
||||||
|
value: "false"
|
||||||
|
- key: bugprone-too-small-loop-variable.MagnitudeBitsUpperLimit
|
||||||
|
value: "16"
|
||||||
|
- key: bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField
|
||||||
|
value: "true"
|
||||||
|
- key: bugprone-unused-return-value.CheckedFunctions
|
||||||
|
value: "::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty;::std::back_inserter;::std::distance;::std::find;::std::find_if;::std::inserter;::std::lower_bound;::std::make_pair;::std::map::count;::std::map::find;::std::map::lower_bound;::std::multimap::equal_range;::std::multimap::upper_bound;::std::set::count;::std::set::find;::std::setfill;::std::setprecision;::std::setw;::std::upper_bound;::std::vector::at;::bsearch;::ferror;::feof;::isalnum;::isalpha;::isblank;::iscntrl;::isdigit;::isgraph;::islower;::isprint;::ispunct;::isspace;::isupper;::iswalnum;::iswprint;::iswspace;::isxdigit;::memchr;::memcmp;::strcmp;::strcoll;::strncmp;::strpbrk;::strrchr;::strspn;::strstr;::wcscmp;::access;::bind;::connect;::difftime;::dlsym;::fnmatch;::getaddrinfo;::getopt;::htonl;::htons;::iconv_open;::inet_addr;::isascii;::isatty;::mmap;::newlocale;::openat;::pathconf;::pthread_equal;::pthread_getspecific;::pthread_mutex_trylock;::readdir;::readlink;::recvmsg;::regexec;::scandir;::semget;::setjmp;::shm_open;::shmget;::sigismember;::strcasecmp;::strsignal;::ttyname"
|
||||||
|
- key: cert-dcl16-c.NewSuffixes
|
||||||
|
value: "L;LL;LU;LLU"
|
||||||
|
- key: cert-err33-c.CheckedFunctions
|
||||||
|
value: "::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;"
|
||||||
|
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
|
||||||
|
value: "false"
|
||||||
|
- key: cert-str34-c.DiagnoseSignedUnsignedCharComparisons
|
||||||
|
value: "false"
|
||||||
|
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
|
||||||
|
value: "true"
|
||||||
|
- key: google-readability-braces-around-statements.ShortStatementLines
|
||||||
|
value: "1"
|
||||||
|
- key: google-readability-function-size.StatementThreshold
|
||||||
|
value: "800"
|
||||||
|
- key: google-readability-namespace-comments.ShortNamespaceLines
|
||||||
|
value: "10"
|
||||||
|
- key: google-readability-namespace-comments.SpacesBeforeComments
|
||||||
|
value: "2"
|
||||||
|
- key: llvm-else-after-return.WarnOnConditionVariables
|
||||||
|
value: "false"
|
||||||
|
- key: llvm-else-after-return.WarnOnUnfixable
|
||||||
|
value: "false"
|
||||||
|
- key: llvm-qualified-auto.AddConstToQualified
|
||||||
|
value: "false"
|
||||||
|
- key: misc-definitions-in-headers.HeaderFileExtensions
|
||||||
|
value: ";h;hh;hpp;hxx"
|
||||||
|
- key: misc-definitions-in-headers.UseHeaderFileExtension
|
||||||
|
value: "true"
|
||||||
|
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
|
||||||
|
value: "false"
|
||||||
|
- key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables
|
||||||
|
value: "false"
|
||||||
|
- key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries
|
||||||
|
value: "true"
|
||||||
|
- key: misc-throw-by-value-catch-by-reference.MaxSize
|
||||||
|
value: "-1"
|
||||||
|
- key: misc-throw-by-value-catch-by-reference.WarnOnLargeObjects
|
||||||
|
value: "false"
|
||||||
|
- key: misc-uniqueptr-reset-release.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: misc-unused-parameters.StrictMode
|
||||||
|
value: "false"
|
||||||
|
- key: modernize-avoid-bind.PermissiveParameterList
|
||||||
|
value: "false"
|
||||||
|
- key: modernize-loop-convert.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: modernize-loop-convert.MakeReverseRangeFunction
|
||||||
|
value: ""
|
||||||
|
- key: modernize-loop-convert.MakeReverseRangeHeader
|
||||||
|
value: ""
|
||||||
|
- key: modernize-loop-convert.MaxCopySize
|
||||||
|
value: "16"
|
||||||
|
- key: modernize-loop-convert.MinConfidence
|
||||||
|
value: reasonable
|
||||||
|
- key: modernize-loop-convert.NamingStyle
|
||||||
|
value: CamelCase
|
||||||
|
- key: modernize-loop-convert.UseCxx20ReverseRanges
|
||||||
|
value: "true"
|
||||||
|
- key: modernize-make-shared.IgnoreDefaultInitialization
|
||||||
|
value: "true"
|
||||||
|
- key: modernize-make-shared.IgnoreMacros
|
||||||
|
value: "true"
|
||||||
|
- key: modernize-make-shared.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: modernize-make-shared.MakeSmartPtrFunction
|
||||||
|
value: "std::make_shared"
|
||||||
|
- key: modernize-make-shared.MakeSmartPtrFunctionHeader
|
||||||
|
value: "<memory>"
|
||||||
|
- key: modernize-make-unique.IgnoreDefaultInitialization
|
||||||
|
value: "true"
|
||||||
|
- key: modernize-make-unique.IgnoreMacros
|
||||||
|
value: "true"
|
||||||
|
- key: modernize-make-unique.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: modernize-make-unique.MakeSmartPtrFunction
|
||||||
|
value: "std::make_unique"
|
||||||
|
- key: modernize-make-unique.MakeSmartPtrFunctionHeader
|
||||||
|
value: "<memory>"
|
||||||
|
- key: modernize-pass-by-value.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: modernize-pass-by-value.ValuesOnly
|
||||||
|
value: "false"
|
||||||
|
- key: modernize-raw-string-literal.DelimiterStem
|
||||||
|
value: lit
|
||||||
|
- key: modernize-raw-string-literal.ReplaceShorterLiterals
|
||||||
|
value: "false"
|
||||||
|
- key: modernize-replace-auto-ptr.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: modernize-replace-disallow-copy-and-assign-macro.MacroName
|
||||||
|
value: DISALLOW_COPY_AND_ASSIGN
|
||||||
|
- key: modernize-replace-random-shuffle.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: modernize-use-auto.MinTypeNameLength
|
||||||
|
value: "5"
|
||||||
|
- key: modernize-use-auto.RemoveStars
|
||||||
|
value: "false"
|
||||||
|
- key: modernize-use-bool-literals.IgnoreMacros
|
||||||
|
value: "true"
|
||||||
|
- key: modernize-use-default-member-init.IgnoreMacros
|
||||||
|
value: "true"
|
||||||
|
- key: modernize-use-default-member-init.UseAssignment
|
||||||
|
value: "false"
|
||||||
|
- key: modernize-use-emplace.ContainersWithPushBack
|
||||||
|
value: "::std::vector;::std::list;::std::deque"
|
||||||
|
- key: modernize-use-emplace.IgnoreImplicitConstructors
|
||||||
|
value: "false"
|
||||||
|
- key: modernize-use-emplace.SmartPointers
|
||||||
|
value: "::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr"
|
||||||
|
- key: modernize-use-emplace.TupleMakeFunctions
|
||||||
|
value: "::std::make_pair;::std::make_tuple"
|
||||||
|
- key: modernize-use-emplace.TupleTypes
|
||||||
|
value: "::std::pair;::std::tuple"
|
||||||
|
- key: modernize-use-equals-default.IgnoreMacros
|
||||||
|
value: "true"
|
||||||
|
- key: modernize-use-equals-delete.IgnoreMacros
|
||||||
|
value: "true"
|
||||||
|
- key: modernize-use-nodiscard.ReplacementString
|
||||||
|
value: "[[nodiscard]]"
|
||||||
|
- key: modernize-use-noexcept.ReplacementString
|
||||||
|
value: ""
|
||||||
|
- key: modernize-use-noexcept.UseNoexceptFalse
|
||||||
|
value: "true"
|
||||||
|
- key: modernize-use-nullptr.NullMacros
|
||||||
|
value: "NULL"
|
||||||
|
- key: modernize-use-override.AllowOverrideAndFinal
|
||||||
|
value: "false"
|
||||||
|
- key: modernize-use-override.FinalSpelling
|
||||||
|
value: final
|
||||||
|
- key: modernize-use-override.IgnoreDestructors
|
||||||
|
value: "false"
|
||||||
|
- key: modernize-use-override.OverrideSpelling
|
||||||
|
value: override
|
||||||
|
- key: modernize-use-transparent-functors.SafeMode
|
||||||
|
value: "false"
|
||||||
|
- key: modernize-use-using.IgnoreMacros
|
||||||
|
value: "true"
|
||||||
|
- key: performance-faster-string-find.StringLikeClasses
|
||||||
|
value: "::std::basic_string;::std::basic_string_view"
|
||||||
|
- key: performance-for-range-copy.AllowedTypes
|
||||||
|
value: ""
|
||||||
|
- key: performance-for-range-copy.WarnOnAllAutoCopies
|
||||||
|
value: "false"
|
||||||
|
- key: performance-inefficient-string-concatenation.StrictMode
|
||||||
|
value: "false"
|
||||||
|
- key: performance-inefficient-vector-operation.EnableProto
|
||||||
|
value: "false"
|
||||||
|
- key: performance-inefficient-vector-operation.VectorLikeClasses
|
||||||
|
value: "::std::vector"
|
||||||
|
- key: performance-move-const-arg.CheckTriviallyCopyableMove
|
||||||
|
value: "true"
|
||||||
|
- key: performance-no-automatic-move.AllowedTypes
|
||||||
|
value: ""
|
||||||
|
- key: performance-type-promotion-in-math-fn.IncludeStyle
|
||||||
|
value: llvm
|
||||||
|
- key: performance-unnecessary-copy-initialization.AllowedTypes
|
||||||
|
value: ""
|
||||||
|
- key: performance-unnecessary-copy-initialization.ExcludedContainerTypes
|
||||||
|
value: ""
|
||||||
|
- key: performance-unnecessary-value-param.AllowedTypes
|
||||||
|
value: ""
|
||||||
|
- key: performance-unnecessary-value-param.IncludeStyle
|
||||||
|
value: llvm
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||||
|
// README at: https://github.com/devcontainers/templates/tree/main/src/alpine
|
||||||
|
{
|
||||||
|
"name": "AVR toolchain",
|
||||||
|
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
||||||
|
"image": "mcr.microsoft.com/devcontainers/base:alpine-3.18",
|
||||||
|
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||||
|
"features": {},
|
||||||
|
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||||
|
// "forwardPorts": [],
|
||||||
|
// Use 'postCreateCommand' to run commands after the container is created.
|
||||||
|
"postCreateCommand": "bash scripts/install-toolchain.sh",
|
||||||
|
// Configure tool-specific properties.
|
||||||
|
"customizations": {
|
||||||
|
"vscode": {
|
||||||
|
"extensions": [
|
||||||
|
"ms-vscode.cpptools",
|
||||||
|
"ms-vscode.cmake-tools",
|
||||||
|
"rockcat.avr-support",
|
||||||
|
"harikrishnan94.cxx-compiler-explorer"
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"C_Cpp.codeAnalysis.clangTidy.checks.disabled": [
|
||||||
|
"clang-analyzer-core.NullDereference"
|
||||||
|
],
|
||||||
|
"C_Cpp.files.exclude": {
|
||||||
|
"build/**": true
|
||||||
|
},
|
||||||
|
"files.associations": {
|
||||||
|
"*.S": "avr"
|
||||||
|
},
|
||||||
|
"cmake.configureOnOpen": true,
|
||||||
|
"compilerexplorer.compilationDirectory": "${workspaceFolder}/build",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||||
|
// "remoteUser": "root"
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
*.o
|
*.o
|
||||||
*.elf
|
*.elf
|
||||||
*.hex
|
*.hex
|
||||||
|
build/
|
||||||
Vendored
+17
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Linux",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**"
|
||||||
|
],
|
||||||
|
"defines": [],
|
||||||
|
"cStandard": "c17",
|
||||||
|
"cppStandard": "c++17",
|
||||||
|
"intelliSenseMode": "${default}",
|
||||||
|
"compilerArgs": [],
|
||||||
|
"configurationProvider": "ms-vscode.cmake-tools"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
Vendored
+14
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"C_Cpp.codeAnalysis.clangTidy.checks.disabled": [
|
||||||
|
"clang-analyzer-core.NullDereference"
|
||||||
|
],
|
||||||
|
"C_Cpp.files.exclude": {
|
||||||
|
"build/**": true
|
||||||
|
},
|
||||||
|
"files.associations": {
|
||||||
|
"*.S": "avr"
|
||||||
|
},
|
||||||
|
"cmake.configureOnOpen": true,
|
||||||
|
"compilerexplorer.compilationDirectory": "${workspaceFolder}/build",
|
||||||
|
}
|
||||||
+139
@@ -0,0 +1,139 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
include(CMakeDependentOption)
|
||||||
|
|
||||||
|
set(WITH_MCU OFF)
|
||||||
|
set(AVR_MCU "attiny3216")
|
||||||
|
set(AVR_UPLOADTOOL_PORT /dev/ttyUSB0)
|
||||||
|
set(AVR_PROGRAMMER serialupdi)
|
||||||
|
set(AVR_UPLOADTOOL_BAUDRATE 230400)
|
||||||
|
|
||||||
|
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/avr-gcc-toolchain.cmake")
|
||||||
|
|
||||||
|
project(avclan-mockingboard VERSION 1 LANGUAGES C CXX ASM)
|
||||||
|
|
||||||
|
set(FREQSEL 16MHz CACHE STRING "Select the operating frequency")
|
||||||
|
set_property(CACHE FREQSEL PROPERTY STRINGS "20MHz" "16MHz")
|
||||||
|
|
||||||
|
if(FREQSEL MATCHES "20MHz")
|
||||||
|
set(FREQSEL 20000000L)
|
||||||
|
set(AVR_UPLOADTOOL_BASE_OPTIONS ${AVR_UPLOADTOOL_BASE_OPTIONS} -U osccfg:w:0x2:m)
|
||||||
|
else()
|
||||||
|
set(FREQSEL 16000000L)
|
||||||
|
set(AVR_UPLOADTOOL_BASE_OPTIONS ${AVR_UPLOADTOOL_BASE_OPTIONS} -U osccfg:w:0x1:m)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(CLK_PRESCALE "Enable the main clock prescaler")
|
||||||
|
cmake_dependent_option(CLK_PRESCALE_DIV "Prescaler divisor" CLKCTRL_PDIV_2X_gc STRING "CLK_PRESCALE")
|
||||||
|
if(DEFINED CACHE{CLK_PRESCALE_DIV})
|
||||||
|
set_property(CACHE CLK_PRESCALE_DIV PROPERTY STRINGS
|
||||||
|
CLKCTRL_PDIV_2X_gc
|
||||||
|
CLKCTRL_PDIV_4X_gc
|
||||||
|
CLKCTRL_PDIV_8X_gc
|
||||||
|
CLKCTRL_PDIV_16X_gc
|
||||||
|
CLKCTRL_PDIV_32X_gc
|
||||||
|
CLKCTRL_PDIV_64X_gc
|
||||||
|
CLKCTRL_PDIV_6X_gc
|
||||||
|
CLKCTRL_PDIV_10X_gc
|
||||||
|
CLKCTRL_PDIV_12X_gc
|
||||||
|
CLKCTRL_PDIV_24X_gc
|
||||||
|
CLKCTRL_PDIV_48X_gc
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
set(CLK_PRESCALE_DIV CLKCTRL_PDIV_2X_gc)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(TCB_CLKSEL "TCB_CLKSEL_CLKDIV2_gc" CACHE STRING "Choose the clock for TCB")
|
||||||
|
set_property(CACHE TCB_CLKSEL PROPERTY STRINGS
|
||||||
|
TCB_CLKSEL_CLKDIV1_gc
|
||||||
|
TCB_CLKSEL_CLKDIV2_gc
|
||||||
|
TCB_CLKSEL_CLKTCA_gc
|
||||||
|
)
|
||||||
|
|
||||||
|
set(USART_RXMODE "USART_RXMODE_CLK2X_gc" CACHE STRING "USART at normal or double speed operation")
|
||||||
|
set_property(CACHE USART_RXMODE PROPERTY STRINGS
|
||||||
|
USART_RXMODE_CLK2X_gc
|
||||||
|
USART_RXMODE_NORMAL_gc
|
||||||
|
)
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.3")
|
||||||
|
message(FATAL_ERROR "Insufficient AVR-GCC version; Support for ATtiny3216 was added in GCC v8")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Handle libc versioning
|
||||||
|
try_compile(LIBC_VERSION_TEST
|
||||||
|
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/libc-version-test.cpp"
|
||||||
|
COMPILE_DEFINITIONS -mmcu=${AVR_MCU}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT LIBC_VERSION_TEST)
|
||||||
|
include(FetchContent)
|
||||||
|
FetchContent_Declare(
|
||||||
|
attiny_atpack
|
||||||
|
URL http://packs.download.atmel.com/Atmel.ATtiny_DFP.2.0.368.atpack
|
||||||
|
URL_HASH SHA512=ee16a8ebecb57bd998a9cd4373368e3d45982cbbc3825e18d1dcac58215db6b9d907ad1ba2020cba9187fed7ba8c6f255a4fa1214e40c7a17ab2d18474f4d079
|
||||||
|
DOWNLOAD_NAME Atmel.ATtiny_DFP.2.0.368.atpack.zip
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(attiny_atpack)
|
||||||
|
try_compile(LIBC_VERSION_TEST
|
||||||
|
SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/libc-version-test.cpp"
|
||||||
|
COMPILE_DEFINITIONS
|
||||||
|
-B "${attiny_atpack_SOURCE_DIR}/gcc/dev/${AVR_MCU}"
|
||||||
|
-isystem "${attiny_atpack_SOURCE_DIR}/include"
|
||||||
|
-mmcu=${AVR_MCU}
|
||||||
|
)
|
||||||
|
if(NOT LIBC_VERSION_TEST)
|
||||||
|
message(FATAL_ERROR "Insufficient AVR-LIBC/Microchip pack for chosen MCU '${AVR_MCU}'")
|
||||||
|
else()
|
||||||
|
include_directories(SYSTEM "${attiny_atpack_SOURCE_DIR}/include")
|
||||||
|
add_compile_options(
|
||||||
|
-B "${attiny_atpack_SOURCE_DIR}/gcc/dev/${AVR_MCU}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
set(CMAKE_C_STANDARD 17)
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE MATCHES Release)
|
||||||
|
set(CMAKE_C_FLAGS_RELEASE "-Os")
|
||||||
|
endif(CMAKE_BUILD_TYPE MATCHES Release)
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
|
||||||
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os -save-temps -g -gdwarf-3 -gstrict-dwarf")
|
||||||
|
endif(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "-O0 -save-temps -g -gdwarf-3 -gstrict-dwarf")
|
||||||
|
endif(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||||
|
|
||||||
|
# Set startup time to 8 ms (0x4)
|
||||||
|
set(AVR_UPLOADTOOL_BASE_OPTIONS ${AVR_UPLOADTOOL_BASE_OPTIONS} -U syscfg1:w:0x4:m)
|
||||||
|
|
||||||
|
add_avr_executable(mockingboard
|
||||||
|
src/sniffer.c
|
||||||
|
src/com232.c
|
||||||
|
src/avclandrv.c)
|
||||||
|
|
||||||
|
target_link_options(mockingboard PUBLIC
|
||||||
|
-B "${attiny_atpack_SOURCE_DIR}/gcc/dev/${AVR_MCU}"
|
||||||
|
)
|
||||||
|
target_compile_definitions(mockingboard PRIVATE
|
||||||
|
FREQSEL=${FREQSEL}
|
||||||
|
CLK_PRESCALE=$<IF:$<BOOL:${CLK_PRESCALE}>,0x01,0x00>
|
||||||
|
CLK_PRESCALE_DIV=${CLK_PRESCALE_DIV}
|
||||||
|
__CLK_PRESCALE_DIV=__${CLK_PRESCALE_DIV}
|
||||||
|
TCB_CLKSEL=${TCB_CLKSEL}
|
||||||
|
USART_RXMODE=${USART_RXMODE}
|
||||||
|
)
|
||||||
|
target_compile_options(mockingboard PRIVATE
|
||||||
|
--param=min-pagesize=0
|
||||||
|
-ffunction-sections
|
||||||
|
-fdata-sections
|
||||||
|
-fshort-enums
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"version": 2,
|
||||||
|
"configurePresets": [
|
||||||
|
{
|
||||||
|
"name": "default",
|
||||||
|
"displayName": "Debug",
|
||||||
|
"description": "Configure with Debug build settings",
|
||||||
|
"generator": "Unix Makefiles",
|
||||||
|
"binaryDir": "${sourceDir}/build",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "Debug",
|
||||||
|
"FREQSEL": "20MHz",
|
||||||
|
"TCB_CLKSEL": "TCB_CLKSEL_CLKDIV1_gc"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "relwithdebinfo",
|
||||||
|
"displayName": "RelWithDebInfo",
|
||||||
|
"description": "Configure with RelWithDebInfo build settings",
|
||||||
|
"generator": "Unix Makefiles",
|
||||||
|
"binaryDir": "${sourceDir}/build",
|
||||||
|
"inherits": "default",
|
||||||
|
"cacheVariables": {
|
||||||
|
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
|
||||||
|
"FREQSEL": "20MHz",
|
||||||
|
"TCB_CLKSEL": "TCB_CLKSEL_CLKDIV1_gc",
|
||||||
|
"USART_RXMODE": "USART_RXMODE_CLK2X_gc"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
-37
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
this file is a part of the TOYOTA Corolla MP3 Player Project
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
http://www.softservice.com.pl/corolla/avc
|
|
||||||
|
|
||||||
May 28 / 2009 - version 2
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "GlobalDef.h"
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
// max 10 events in fifo
|
|
||||||
byte EventCount;
|
|
||||||
byte EventCmd[10];
|
|
||||||
byte Event;
|
|
||||||
|
|
||||||
byte showLog;
|
|
||||||
byte showLog2;
|
|
||||||
-85
@@ -1,85 +0,0 @@
|
|||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
Name : GlobalDef.h
|
|
||||||
|
|
||||||
Description : Global definitions.
|
|
||||||
|
|
||||||
History : 2004/04/06 - Created by Louis Frigon.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
#ifndef _GLOBALDEF_H_
|
|
||||||
#define _GLOBALDEF_H_
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
Constants
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
#define FALSE 0
|
|
||||||
#define TRUE (!FALSE)
|
|
||||||
|
|
||||||
// AVC LAN bus directly connected to internal analog comparator (PD6/7)
|
|
||||||
// PD6 AIN0 +
|
|
||||||
// PD7 AIN1 -
|
|
||||||
#define DATAIN_PIN ACSR
|
|
||||||
#define DATAIN ACO
|
|
||||||
|
|
||||||
#define INPUT_IS_SET ( bit_is_set( DATAIN_PIN, DATAIN ) )
|
|
||||||
#define INPUT_IS_CLEAR ( bit_is_clear( DATAIN_PIN, DATAIN ) )
|
|
||||||
|
|
||||||
#define LED_DDR DDRB
|
|
||||||
#define LED_PORT PORTB
|
|
||||||
#define LEDOUT _BV(PORT5)
|
|
||||||
|
|
||||||
#define sbi(port, bit) (port) |= (1 << (bit)) // Set bit (i.e. to 1)
|
|
||||||
#define cbi(port, bit) (port) &= ~(1 << (bit)) // Clear bit (i.e. set bit to 0)
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
Type definitions
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
typedef unsigned char byte;
|
|
||||||
typedef unsigned int word;
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
Prototypes
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
inline void LedOff( void );
|
|
||||||
inline void LedOn( void );
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
From Marcin's "const.h"
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
// max 10 events in fifo
|
|
||||||
extern byte EventCount;
|
|
||||||
extern byte EventCmd[10];
|
|
||||||
extern byte Event;
|
|
||||||
|
|
||||||
#define EV_NOTHING 0
|
|
||||||
#define EV_DISPLAY 1
|
|
||||||
#define EV_STATUS 4
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// const
|
|
||||||
#define smYear 1
|
|
||||||
#define smMonth 2
|
|
||||||
#define smDay 3
|
|
||||||
#define smHour 4
|
|
||||||
#define smMin 5
|
|
||||||
#define smWDay 6
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#define STOPEvent cbi(TIMSK, TOIE1); cbi(UCSRB, RXCIE);
|
|
||||||
//#define STARTEvent sbi(TIMSK, TOIE1); sbi(UCSRB, RXCIE);
|
|
||||||
|
|
||||||
|
|
||||||
extern byte showLog;
|
|
||||||
extern byte showLog2;
|
|
||||||
|
|
||||||
#endif // _GLOBALDEF_H_
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------------------------------
|
|
||||||
End of file.
|
|
||||||
--------------------------------------------------------------------------------------------------*/
|
|
||||||
@@ -1,22 +1,674 @@
|
|||||||
The MIT License (MIT)
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
Copyright (c) 2015 halleysfifthinc
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Preamble
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The GNU General Public License is a free, copyleft license for
|
||||||
copies or substantial portions of the Software.
|
software and other kinds of works.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
The licenses for most software and other practical works are designed
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
to take away your freedom to share and change the works. By contrast,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
share and change all versions of a program--to make sure it remains free
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
GNU General Public License for most of our software; it applies also to
|
||||||
SOFTWARE.
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
CC=avr-g++
|
|
||||||
CFLAGS=-c -g -Os -Wall -mmcu=atmega328p
|
|
||||||
CFLAGS+=-fno-exceptions -fpermissive -ffunction-sections -fdata-sections -fno-threadsafe-statics
|
|
||||||
DEFS= -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR
|
|
||||||
LFLAGS=-g -MMD -mmcu=atmega328p
|
|
||||||
|
|
||||||
all: sniffer.hex
|
|
||||||
|
|
||||||
sniffer.hex: sniffer.elf
|
|
||||||
avr-objcopy -j .text -j .data -O ihex sniffer.elf sniffer.hex
|
|
||||||
|
|
||||||
sniffer.elf: sniffer.o com232.o avclandrv.o GlobalDef.o
|
|
||||||
$(CC) $(LFLAGS) $(DEFS) -o sniffer.elf sniffer.o com232.o avclandrv.o GlobalDef.o
|
|
||||||
|
|
||||||
sniffer.o: sniffer.c GlobalDef.h com232.h avclandrv.h
|
|
||||||
$(CC) $(CFLAGS) $(DEFS) sniffer.c
|
|
||||||
|
|
||||||
com232.o: com232.c com232.h GlobalDef.h
|
|
||||||
$(CC) $(CFLAGS) $(DEFS) com232.c
|
|
||||||
|
|
||||||
avclandrv.o: avclandrv.c GlobalDef.h com232.h avclandrv.h
|
|
||||||
$(CC) $(CFLAGS) $(DEFS) avclandrv.c
|
|
||||||
|
|
||||||
GlobalDef.o: GlobalDef.c GlobalDef.h
|
|
||||||
$(CC) $(CFLAGS) $(DEFS) GlobalDef.c
|
|
||||||
|
|
||||||
clean::
|
|
||||||
@rm -f *.o *.hex *.elf
|
|
||||||
|
|
||||||
.PHONY: upload connect size
|
|
||||||
|
|
||||||
upload: sniffer.hex
|
|
||||||
avrdude -C/home/allen/Programs/arduino-1.6.5/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/arduino -b57600 -D -Uflash:w:sniffer.hex:i
|
|
||||||
|
|
||||||
connect:
|
|
||||||
@picocom --nolock -b 115200 /dev/arduino ||:
|
|
||||||
|
|
||||||
size:
|
|
||||||
avr-size -C --mcu=atmega328p sniffer.elf
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
-996
@@ -1,996 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (C) 2015 Allen Hill <allenofthehills@gmail.com>.
|
|
||||||
|
|
||||||
Portions of the following source code are:
|
|
||||||
Copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
this file is a part of the TOYOTA Corolla MP3 Player Project
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
http://www.softservice.com.pl/corolla/avc
|
|
||||||
|
|
||||||
May 28 / 2009 - version 2
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <avr/interrupt.h>
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
|
|
||||||
#include "avclandrv.h"
|
|
||||||
#include "com232.h"
|
|
||||||
#include "GlobalDef.h"
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#define AVC_OUT_EN() sbi(PORTD, 6); sbi(DDRD, 6); sbi(DDRD, 7); sbi(ACSR, ACD);
|
|
||||||
#define AVC_OUT_DIS() cbi(PORTD, 6); cbi(DDRD, 6); cbi(DDRD, 7); cbi(ACSR, ACD);
|
|
||||||
#define AVC_SET_1() sbi(PORTD, 6);
|
|
||||||
#define AVC_SET_0() cbi(PORTD, 6);
|
|
||||||
|
|
||||||
|
|
||||||
byte CD_ID_1;
|
|
||||||
byte CD_ID_2;
|
|
||||||
|
|
||||||
byte HU_ID_1;
|
|
||||||
byte HU_ID_2;
|
|
||||||
|
|
||||||
byte parity_bit;
|
|
||||||
|
|
||||||
byte repeatMode;
|
|
||||||
byte randomMode;
|
|
||||||
|
|
||||||
byte playMode;
|
|
||||||
|
|
||||||
byte cd_Disc;
|
|
||||||
byte cd_Track;
|
|
||||||
byte cd_Time_Min;
|
|
||||||
byte cd_Time_Sec;
|
|
||||||
|
|
||||||
byte answerReq;
|
|
||||||
|
|
||||||
cd_modes CD_Mode;
|
|
||||||
|
|
||||||
|
|
||||||
byte broadcast;
|
|
||||||
byte master1;
|
|
||||||
byte master2;
|
|
||||||
byte slave1;
|
|
||||||
byte slave2;
|
|
||||||
byte message_len;
|
|
||||||
byte message[MAXMSGLEN];
|
|
||||||
|
|
||||||
byte data_control;
|
|
||||||
byte data_len;
|
|
||||||
byte data[MAXMSGLEN];
|
|
||||||
|
|
||||||
// we need check answer (to avclan check) timeout
|
|
||||||
// when is more then 1 min, FORCE answer.
|
|
||||||
byte check_timeout;
|
|
||||||
|
|
||||||
#define SW_ID 0x11 // 11 For my stereo
|
|
||||||
|
|
||||||
// commands
|
|
||||||
const byte stat1[] = { 0x4, 0x00, 0x00, 0x01, 0x0A };
|
|
||||||
const byte stat2[] = { 0x4, 0x00, 0x00, 0x01, 0x08 };
|
|
||||||
const byte stat3[] = { 0x4, 0x00, 0x00, 0x01, 0x0D };
|
|
||||||
const byte stat4[] = { 0x4, 0x00, 0x00, 0x01, 0x0C };
|
|
||||||
|
|
||||||
// broadcast
|
|
||||||
const byte lan_stat1[] = { 0x3, 0x00, 0x01, 0x0A };
|
|
||||||
const byte lan_reg[] = { 0x3, SW_ID, 0x01, 0x00 };
|
|
||||||
const byte lan_init[] = { 0x3, SW_ID, 0x01, 0x01 };
|
|
||||||
const byte lan_check[] = { 0x3, SW_ID, 0x01, 0x20 };
|
|
||||||
const byte lan_playit[] = { 0x4, SW_ID, 0x01, 0x45, 0x63 };
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const byte play_req1[] = { 0x4, 0x00, 0x25, 0x63, 0x80 };
|
|
||||||
|
|
||||||
#ifdef __AVENSIS__
|
|
||||||
const byte play_req2[] = { 0x6, 0x00, SW_ID, 0x63, 0x42 };
|
|
||||||
#else
|
|
||||||
const byte play_req2[] = { 0x6, 0x00, SW_ID, 0x63, 0x42, 0x01, 0x00 };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const byte play_req3[] = { 0x6, 0x00, SW_ID, 0x63, 0x42, 0x41, 0x00 };
|
|
||||||
const byte stop_req[] = { 0x5, 0x00, SW_ID, 0x63, 0x43, 0x01 };
|
|
||||||
const byte stop_req2[] = { 0x5, 0x00, SW_ID, 0x63, 0x43, 0x41 };
|
|
||||||
|
|
||||||
|
|
||||||
// answers
|
|
||||||
const byte CMD_REGISTER[] = {0x1, 0x05, 0x00, 0x01, SW_ID, 0x10, 0x63 };
|
|
||||||
const byte CMD_STATUS1[] = {0x1, 0x04, 0x00, 0x01, 0x00, 0x1A };
|
|
||||||
const byte CMD_STATUS2[] = {0x1, 0x04, 0x00, 0x01, 0x00, 0x18 };
|
|
||||||
const byte CMD_STATUS3[] = {0x1, 0x04, 0x00, 0x01, 0x00, 0x1D };
|
|
||||||
const byte CMD_STATUS4[] = {0x1, 0x05, 0x00, 0x01, 0x00, 0x1C, 0x00 };
|
|
||||||
byte CMD_CHECK[] = {0x1, 0x06, 0x00, 0x01, SW_ID, 0x30, 0x00, 0x00 };
|
|
||||||
|
|
||||||
const byte CMD_STATUS5[] = {0x1, 0x05, 0x00, 0x5C, 0x12, 0x53, 0x02 };
|
|
||||||
const byte CMD_STATUS5A[] = {0x0, 0x05, 0x5C, 0x31, 0xF1, 0x00, 0x00 };
|
|
||||||
|
|
||||||
const byte CMD_STATUS6[] = {0x1, 0x06, 0x00, 0x5C, 0x32, 0xF0, 0x02, 0x00 };
|
|
||||||
|
|
||||||
|
|
||||||
const byte CMD_PLAY_OK1[] = {0x1, 0x05, 0x00, 0x63, SW_ID, 0x50, 0x01 };
|
|
||||||
const byte CMD_PLAY_OK2[] = {0x1, 0x05, 0x00, 0x63, SW_ID, 0x52, 0x01 };
|
|
||||||
const byte CMD_PLAY_OK3[] = {0x0, 0x0B, 0x63, 0x31, 0xF1, 0x01, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0x00, 0x80 };
|
|
||||||
byte CMD_PLAY_OK4[] = {0x0, 0x0B, 0x63, 0x31, 0xF1, 0x01, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80 };
|
|
||||||
|
|
||||||
const byte CMD_STOP1[] = {0x1, 0x05, 0x00, 0x63, SW_ID, 0x53, 0x01 };
|
|
||||||
byte CMD_STOP2[] = {0x0, 0x0B, 0x63, 0x31, 0xF1, 0x00, 0x30, 0x00, 0x00,0x00, 0x00, 0x00, 0x80 };
|
|
||||||
|
|
||||||
const byte CMD_BEEP[] = {0x1, 0x05, 0x00, 0x63, 0x29, 0x60, 0x02 };
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
// DONE: Timing adjusted, however refactoring may make code more clear/efficient
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void AVC_HoldLine()
|
|
||||||
{
|
|
||||||
STOPEvent;
|
|
||||||
|
|
||||||
// wait for free line
|
|
||||||
byte line_busy = 1;
|
|
||||||
|
|
||||||
TCNT0 = 0;
|
|
||||||
do {
|
|
||||||
while (INPUT_IS_CLEAR) {
|
|
||||||
/* The comparison value was originally 25 with CK64 (tick period of 4.34 us)
|
|
||||||
at a clock frequency 14.7456MHz.
|
|
||||||
For a more accurate tick period of .5 us at 16MHz, the value should be approximately 225*/
|
|
||||||
if (TCNT0 >= 225) break;
|
|
||||||
}
|
|
||||||
if (TCNT0 > 216) line_busy=0;
|
|
||||||
} while (line_busy);
|
|
||||||
|
|
||||||
// switch to out mode
|
|
||||||
AVC_OUT_EN();
|
|
||||||
AVC_SET_1();
|
|
||||||
|
|
||||||
STARTEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: No changes necessary
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void AVC_ReleaseLine()
|
|
||||||
{
|
|
||||||
AVC_SET_0();
|
|
||||||
AVC_OUT_DIS();
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
// DONE: No changes necessary
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void AVCLan_Init()
|
|
||||||
{
|
|
||||||
// OUTPUT ( set as input for comparator )
|
|
||||||
cbi(PORTD, 6);
|
|
||||||
cbi(DDRD, 6);
|
|
||||||
|
|
||||||
// INPUT
|
|
||||||
cbi(PORTD, 7);
|
|
||||||
cbi(DDRD, 7);
|
|
||||||
|
|
||||||
// Analog comparator
|
|
||||||
|
|
||||||
cbi(ADCSRB, ACME); // Analog Comparator Multiplexer Enable - NO
|
|
||||||
/*
|
|
||||||
cbi(ACSR, ACBG); // Analog Comparator Bandgap Select
|
|
||||||
// ACI: Analog Comparator Interrupt Flag
|
|
||||||
|
|
||||||
cbi(ACSR, ACIE); // Analog Comparator Interrupt Enable - NO
|
|
||||||
cbi(ACSR, ACIC); // Analog Comparator Input Capture Enable - NO
|
|
||||||
*/
|
|
||||||
cbi(ACSR, ACIS1); // Analog Comparator Interrupt Mode Select
|
|
||||||
cbi(ACSR, ACIS0); // Comparator Interrupt on Output Toggle
|
|
||||||
|
|
||||||
cbi(ACSR, ACD); // Analog Comparator Disable - NO
|
|
||||||
|
|
||||||
TCCR0B = _BV(CS01); // Timer 0 prescaler = 8 ( 2 count / us )
|
|
||||||
|
|
||||||
message_len = 0;
|
|
||||||
answerReq = cmNull;
|
|
||||||
check_timeout = 0;
|
|
||||||
|
|
||||||
cd_Disc = 1;
|
|
||||||
cd_Track = 1;
|
|
||||||
cd_Time_Min = 0;
|
|
||||||
cd_Time_Sec = 0;
|
|
||||||
repeatMode = 0;
|
|
||||||
randomMode = 0;
|
|
||||||
playMode = 0;
|
|
||||||
CD_Mode = stStop;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Timing adjusted, however refactoring may make code more clear/efficient
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_Read_Byte(byte length)
|
|
||||||
{
|
|
||||||
byte bite = 0;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
while (INPUT_IS_CLEAR);
|
|
||||||
TCNT0 = 0;
|
|
||||||
while (INPUT_IS_SET); // If input was set for less than a
|
|
||||||
if ( TCNT0 < 52 ) { // generous half period, bit was a 1
|
|
||||||
bite++;
|
|
||||||
parity_bit++;
|
|
||||||
}
|
|
||||||
length--;
|
|
||||||
if (!length) return bite;
|
|
||||||
bite = bite << 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Timing adjusted
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_Send_StartBit()
|
|
||||||
{
|
|
||||||
AVC_SET_1();
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 255 );
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 76 );
|
|
||||||
|
|
||||||
AVC_SET_0();
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 61 );
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Timing adjusted. Comparison values are timer ticks, not us.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void AVCLan_Send_Bit1()
|
|
||||||
{
|
|
||||||
AVC_SET_1();
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 41 );
|
|
||||||
|
|
||||||
AVC_SET_0();
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 38 ); // 12-21 us
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Timing adjusted
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void AVCLan_Send_Bit0()
|
|
||||||
{
|
|
||||||
AVC_SET_1();
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 65 ); // 28-37 us
|
|
||||||
|
|
||||||
AVC_SET_0();
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 15 ); // 00-09 us
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Timing adjusted.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_Read_ACK()
|
|
||||||
{
|
|
||||||
AVC_SET_1();
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 39 );
|
|
||||||
|
|
||||||
AVC_SET_0();
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 4 ); // Replace with AVC_ReleaseLine?
|
|
||||||
|
|
||||||
|
|
||||||
AVC_OUT_DIS(); // switch to read mode
|
|
||||||
TCNT0 = 1;
|
|
||||||
while(1) {
|
|
||||||
if (INPUT_IS_SET && (TCNT0 > 5)) break; // Make sure INPUT is not still set from us
|
|
||||||
// Line of experimentation: Try changing TCNT0 comparison value or remove check entirely
|
|
||||||
if (TCNT0 > 174 ) return 1; // Not sure if this fix is intent correct
|
|
||||||
}
|
|
||||||
|
|
||||||
while(INPUT_IS_SET);
|
|
||||||
AVC_OUT_EN(); // back to write mode
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Timing adjusted.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_Send_ACK()
|
|
||||||
{
|
|
||||||
TCNT0 = 0;
|
|
||||||
while (INPUT_IS_CLEAR) {
|
|
||||||
if (TCNT0 >= 225) return 0; // max wait time
|
|
||||||
}
|
|
||||||
|
|
||||||
AVC_OUT_EN();
|
|
||||||
|
|
||||||
AVC_SET_1();
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 65 ); //28-37
|
|
||||||
|
|
||||||
AVC_SET_0();
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 15 ); //00-09
|
|
||||||
|
|
||||||
AVC_OUT_DIS();
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: var 'byte' adjusted to 'bite' to avoid reserved word conflict
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_Send_Byte(byte bite, byte len)
|
|
||||||
{
|
|
||||||
byte b;
|
|
||||||
if (len==8) {
|
|
||||||
b = bite;
|
|
||||||
} else {
|
|
||||||
b = bite << (8-len);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
if ( (b & 128)!=0 ) {
|
|
||||||
AVCLan_Send_Bit1();
|
|
||||||
parity_bit++;
|
|
||||||
} else {
|
|
||||||
AVCLan_Send_Bit0();
|
|
||||||
}
|
|
||||||
len--;
|
|
||||||
if (!len) {
|
|
||||||
//if (INPUT_IS_SET) RS232_Print_P(PSTR("SBER\n")); // Send Bit ERror
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
b = b << 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Nothing needed.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_Send_ParityBit()
|
|
||||||
{
|
|
||||||
if ( (parity_bit & 1)!=0 ) {
|
|
||||||
AVCLan_Send_Bit1();
|
|
||||||
//parity_bit++;
|
|
||||||
} else {
|
|
||||||
AVCLan_Send_Bit0();
|
|
||||||
}
|
|
||||||
parity_bit=0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Nothing needed.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte CheckCmd(byte *cmd)
|
|
||||||
{
|
|
||||||
byte i;
|
|
||||||
byte *c;
|
|
||||||
byte l;
|
|
||||||
|
|
||||||
c = cmd;
|
|
||||||
l = *c++;
|
|
||||||
|
|
||||||
for (i=0; i<l; i++) {
|
|
||||||
if (message[i] != *c) return 0;
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Timing adjusted.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_Read_Message()
|
|
||||||
{
|
|
||||||
STOPEvent; // disable timer1 interrupt
|
|
||||||
|
|
||||||
byte i;
|
|
||||||
byte for_me = 0;
|
|
||||||
|
|
||||||
//RS232_Print_P(PSTR("$ "));
|
|
||||||
// TCCR1B |= (1 << CS11)|(1 << CS10); // Timer1 prescaler at 64
|
|
||||||
// TCNT1 = 0;
|
|
||||||
// TCNT0 = 0;
|
|
||||||
// while (INPUT_IS_SET) {
|
|
||||||
// if ( TCNT0 > 255 ) { // 170 us
|
|
||||||
// // TCCR1B = 0;
|
|
||||||
// // TCCR1B |= (1 << WGM12)|(1 << CS12); // Set CTC, prescaler at 256
|
|
||||||
// STARTEvent;
|
|
||||||
// RS232_Print_P(PSTR("LAN>T1\n"));
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if ( TCNT0 < 20 ) { // 20 us
|
|
||||||
// // TCCR1B = 0;
|
|
||||||
// // TCCR1B |= (1 << WGM12)|(1 << CS12);
|
|
||||||
// STARTEvent;
|
|
||||||
// RS232_Print_P(PSTR("LAN>T2\n"));
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
AVCLan_Read_Byte(1);
|
|
||||||
|
|
||||||
broadcast = AVCLan_Read_Byte(1);
|
|
||||||
|
|
||||||
parity_bit = 0;
|
|
||||||
master1 = AVCLan_Read_Byte(4);
|
|
||||||
master2 = AVCLan_Read_Byte(8);
|
|
||||||
if ((parity_bit&1)!=AVCLan_Read_Byte(1)) {
|
|
||||||
STARTEvent;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
parity_bit = 0;
|
|
||||||
slave1 = AVCLan_Read_Byte(4);
|
|
||||||
slave2 = AVCLan_Read_Byte(8);
|
|
||||||
if ((parity_bit&1)!=AVCLan_Read_Byte(1)) {
|
|
||||||
STARTEvent;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// is this command for me ?
|
|
||||||
if ((slave1==CD_ID_1)&&(slave2==CD_ID_2)) {
|
|
||||||
for_me=1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (for_me) AVCLan_Send_ACK();
|
|
||||||
else AVCLan_Read_Byte(1);
|
|
||||||
|
|
||||||
parity_bit = 0;
|
|
||||||
AVCLan_Read_Byte(4); // control - always 0xF
|
|
||||||
if ((parity_bit&1)!=AVCLan_Read_Byte(1)) {
|
|
||||||
STARTEvent;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (for_me) AVCLan_Send_ACK();
|
|
||||||
else AVCLan_Read_Byte(1);
|
|
||||||
|
|
||||||
parity_bit = 0;
|
|
||||||
message_len = AVCLan_Read_Byte(8);
|
|
||||||
if ((parity_bit&1)!=AVCLan_Read_Byte(1)) {
|
|
||||||
STARTEvent;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (for_me) AVCLan_Send_ACK();
|
|
||||||
else AVCLan_Read_Byte(1);
|
|
||||||
|
|
||||||
if (message_len > MAXMSGLEN) {
|
|
||||||
// RS232_Print_P(PSTR("LAN> Command error"));
|
|
||||||
STARTEvent;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=0; i<message_len; i++) {
|
|
||||||
parity_bit = 0;
|
|
||||||
message[i] = AVCLan_Read_Byte(8);
|
|
||||||
if ((parity_bit&1)!=AVCLan_Read_Byte(1)) {
|
|
||||||
STARTEvent;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (for_me) {
|
|
||||||
AVCLan_Send_ACK();
|
|
||||||
} else {
|
|
||||||
AVCLan_Read_Byte(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
STARTEvent;
|
|
||||||
|
|
||||||
if (showLog) ShowInMessage();
|
|
||||||
|
|
||||||
if (for_me) {
|
|
||||||
|
|
||||||
if (CheckCmd((byte*)stat1)) { answerReq = cmStatus1; return 1; }
|
|
||||||
if (CheckCmd((byte*)stat2)) { answerReq = cmStatus2; return 1; }
|
|
||||||
if (CheckCmd((byte*)stat3)) { answerReq = cmStatus3; return 1; }
|
|
||||||
if (CheckCmd((byte*)stat4)) { answerReq = cmStatus4; return 1; }
|
|
||||||
// if (CheckCmd((byte*)stat5)) { answerReq = cmStatus5; return 1; }
|
|
||||||
|
|
||||||
if (CheckCmd((byte*)play_req1)) { answerReq = cmPlayReq1; return 1; }
|
|
||||||
if (CheckCmd((byte*)play_req2)) { answerReq = cmPlayReq2; return 1; }
|
|
||||||
if (CheckCmd((byte*)play_req3)) { answerReq = cmPlayReq3; return 1; }
|
|
||||||
if (CheckCmd((byte*)stop_req)) { answerReq = cmStopReq; return 1; }
|
|
||||||
if (CheckCmd((byte*)stop_req2)) { answerReq = cmStopReq2; return 1; }
|
|
||||||
|
|
||||||
} else { // broadcast check
|
|
||||||
|
|
||||||
if (CheckCmd((byte*)lan_playit)) { answerReq = cmPlayIt; return 1; }
|
|
||||||
if (CheckCmd((byte*)lan_check)) {
|
|
||||||
answerReq = cmCheck;
|
|
||||||
CMD_CHECK[6]=message[3];
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (CheckCmd((byte*)lan_reg)) { answerReq = cmRegister; return 1; }
|
|
||||||
if (CheckCmd((byte*)lan_init)) { answerReq = cmInit; return 1; }
|
|
||||||
if (CheckCmd((byte*)lan_stat1)) { answerReq = cmStatus1; return 1; }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
answerReq = cmNull;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Timing adjusted.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_SendData()
|
|
||||||
{
|
|
||||||
byte i;
|
|
||||||
|
|
||||||
STOPEvent;
|
|
||||||
|
|
||||||
// wait for free line
|
|
||||||
byte line_busy = 1;
|
|
||||||
|
|
||||||
TCNT0 = 0;
|
|
||||||
do {
|
|
||||||
while (INPUT_IS_CLEAR) {
|
|
||||||
if ( TCNT0 >= 225 ) break;
|
|
||||||
}
|
|
||||||
if ( TCNT0 > 216 ) line_busy=0;
|
|
||||||
} while (line_busy);
|
|
||||||
|
|
||||||
|
|
||||||
// switch to output mode
|
|
||||||
AVC_OUT_EN();
|
|
||||||
|
|
||||||
AVCLan_Send_StartBit();
|
|
||||||
AVCLan_Send_Byte(0x1, 1); // regular communication
|
|
||||||
|
|
||||||
|
|
||||||
parity_bit = 0;
|
|
||||||
AVCLan_Send_Byte(CD_ID_1, 4); // CD Changer ID as master
|
|
||||||
AVCLan_Send_Byte(CD_ID_2, 8);
|
|
||||||
AVCLan_Send_ParityBit();
|
|
||||||
|
|
||||||
AVCLan_Send_Byte(HU_ID_1, 4); // HeadUnit ID as slave
|
|
||||||
AVCLan_Send_Byte(HU_ID_2, 8);
|
|
||||||
|
|
||||||
AVCLan_Send_ParityBit();
|
|
||||||
|
|
||||||
if (AVCLan_Read_ACK()) {
|
|
||||||
AVC_OUT_DIS();
|
|
||||||
STARTEvent;
|
|
||||||
RS232_Print_P(PSTR("Error ACK 1 (Transmission ACK)\n"));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
AVCLan_Send_Byte(0xF, 4); // 0xf - control -> COMMAND WRITE
|
|
||||||
AVCLan_Send_ParityBit();
|
|
||||||
if (AVCLan_Read_ACK()) {
|
|
||||||
AVC_OUT_DIS();
|
|
||||||
STARTEvent;
|
|
||||||
RS232_Print_P(PSTR("Error ACK 2 (COMMMAND WRITE)\n"));
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
AVCLan_Send_Byte(data_len, 8);// data length
|
|
||||||
AVCLan_Send_ParityBit();
|
|
||||||
if (AVCLan_Read_ACK()) {
|
|
||||||
AVC_OUT_DIS();
|
|
||||||
STARTEvent;
|
|
||||||
RS232_Print_P(PSTR("Error ACK 3 (Data Length)\n"));
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i=0;i<data_len;i++) {
|
|
||||||
AVCLan_Send_Byte(data[i], 8);// data byte
|
|
||||||
AVCLan_Send_ParityBit();
|
|
||||||
if (AVCLan_Read_ACK()) {
|
|
||||||
AVC_OUT_DIS();
|
|
||||||
STARTEvent;
|
|
||||||
RS232_Print_P(PSTR("Error ACK 4 (Data Byte: "));
|
|
||||||
RS232_PrintDec(i);
|
|
||||||
RS232_Print_P(PSTR(")\n"));
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// back to read mode
|
|
||||||
AVC_OUT_DIS();
|
|
||||||
|
|
||||||
STARTEvent;
|
|
||||||
if (showLog) ShowOutMessage();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Timing adjusted.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_SendDataBroadcast()
|
|
||||||
{
|
|
||||||
byte i;
|
|
||||||
|
|
||||||
STOPEvent;
|
|
||||||
|
|
||||||
// wait for free line
|
|
||||||
byte line_busy = 1;
|
|
||||||
|
|
||||||
TCNT0 = 0;
|
|
||||||
do {
|
|
||||||
while (INPUT_IS_CLEAR) {
|
|
||||||
if ( TCNT0 >= 225 ) break;
|
|
||||||
}
|
|
||||||
if ( TCNT0 > 216 ) line_busy=0;
|
|
||||||
} while (line_busy);
|
|
||||||
|
|
||||||
|
|
||||||
AVC_OUT_EN();
|
|
||||||
|
|
||||||
AVCLan_Send_StartBit();
|
|
||||||
AVCLan_Send_Byte(0x0, 1); // broadcast
|
|
||||||
|
|
||||||
parity_bit = 0;
|
|
||||||
AVCLan_Send_Byte(CD_ID_1, 4); // CD Changer ID as master
|
|
||||||
AVCLan_Send_Byte(CD_ID_2, 8);
|
|
||||||
AVCLan_Send_ParityBit();
|
|
||||||
|
|
||||||
AVCLan_Send_Byte(0x1, 4); // all audio devices
|
|
||||||
AVCLan_Send_Byte(0xFF, 8);
|
|
||||||
AVCLan_Send_ParityBit();
|
|
||||||
AVCLan_Send_Bit1();
|
|
||||||
|
|
||||||
AVCLan_Send_Byte(0xF, 4); // 0xf - control -> COMMAND WRITE
|
|
||||||
AVCLan_Send_ParityBit();
|
|
||||||
AVCLan_Send_Bit1();
|
|
||||||
|
|
||||||
AVCLan_Send_Byte(data_len, 8); // data lenght
|
|
||||||
AVCLan_Send_ParityBit();
|
|
||||||
AVCLan_Send_Bit1();
|
|
||||||
|
|
||||||
for (i=0;i<data_len;i++) {
|
|
||||||
AVCLan_Send_Byte(data[i], 8); // data byte
|
|
||||||
AVCLan_Send_ParityBit();
|
|
||||||
AVCLan_Send_Bit1();
|
|
||||||
}
|
|
||||||
|
|
||||||
AVC_OUT_DIS();
|
|
||||||
STARTEvent;
|
|
||||||
if (showLog) ShowOutMessage();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Nothing needed.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_SendAnswerFrame(byte *cmd)
|
|
||||||
{
|
|
||||||
byte i;
|
|
||||||
byte *c;
|
|
||||||
byte b;
|
|
||||||
|
|
||||||
c = cmd;
|
|
||||||
|
|
||||||
b = *c++;
|
|
||||||
data_control = 0xF;
|
|
||||||
data_len = *c++;
|
|
||||||
for (i=0; i<data_len; i++) {
|
|
||||||
data[i]= *c++;
|
|
||||||
}
|
|
||||||
if (b)
|
|
||||||
return AVCLan_SendData();
|
|
||||||
else
|
|
||||||
return AVCLan_SendDataBroadcast();
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Nothing needed.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_SendMyData(byte *data_tmp, byte s_len)
|
|
||||||
{
|
|
||||||
byte i;
|
|
||||||
byte *c;
|
|
||||||
|
|
||||||
c = data_tmp;
|
|
||||||
|
|
||||||
data_control = 0xF;
|
|
||||||
data_len = s_len;
|
|
||||||
for (i=0; i<data_len; i++) {
|
|
||||||
data[i]= *c++;
|
|
||||||
}
|
|
||||||
return AVCLan_SendData();
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Nothing needed.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_SendMyDataBroadcast(byte *data_tmp, byte s_len)
|
|
||||||
{
|
|
||||||
byte i;
|
|
||||||
byte *c;
|
|
||||||
|
|
||||||
|
|
||||||
c = data_tmp;
|
|
||||||
|
|
||||||
data_control = 0xF;
|
|
||||||
data_len = s_len;
|
|
||||||
for (i=0; i<data_len; i++) {
|
|
||||||
data[i]= *c++;
|
|
||||||
}
|
|
||||||
return AVCLan_SendDataBroadcast();
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Nothing needed.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_SendInitCommands()
|
|
||||||
{
|
|
||||||
byte r;
|
|
||||||
|
|
||||||
const byte c1[] = { 0x0, 0x0B, 0x63, 0x31, 0xF1, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x80 };
|
|
||||||
const byte c2[] = { 0x0, 0x0A, 0x63, 0x31, 0xF3, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x02 };
|
|
||||||
const byte c3[] = { 0x0, 0x0A, 0x63, 0x31, 0xF3, 0x00, 0x3F, 0x00, 0x01, 0x00, 0x01, 0x02 };
|
|
||||||
const byte c4[] = { 0x0, 0x0A, 0x63, 0x31, 0xF3, 0x00, 0x3D, 0x00, 0x01, 0x00, 0x01, 0x02 };
|
|
||||||
const byte c5[] = { 0x0, 0x0A, 0x63, 0x31, 0xF3, 0x00, 0x39, 0x00, 0x01, 0x00, 0x01, 0x02 };
|
|
||||||
const byte c6[] = { 0x0, 0x0A, 0x63, 0x31, 0xF3, 0x00, 0x31, 0x00, 0x01, 0x00, 0x01, 0x02 };
|
|
||||||
const byte c7[] = { 0x0, 0x0A, 0x63, 0x31, 0xF3, 0x00, 0x21, 0x00, 0x01, 0x00, 0x01, 0x02 };
|
|
||||||
const byte c8[] = { 0x0, 0x0B, 0x63, 0x31, 0xF1, 0x00, 0x90, 0x01, 0xFF, 0xFF, 0xFF, 0x00, 0x80 };
|
|
||||||
const byte c9[] = { 0x0, 0x0A, 0x63, 0x31, 0xF3, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02 };
|
|
||||||
const byte cA[] = { 0x0, 0x0B, 0x63, 0x31, 0xF1, 0x00, 0x30, 0x01, 0xFF, 0xFF, 0xFF, 0x00, 0x80 };
|
|
||||||
|
|
||||||
r = AVCLan_SendAnswerFrame((byte*)c1);
|
|
||||||
if (!r) r = AVCLan_SendAnswerFrame((byte*)c2);
|
|
||||||
if (!r) r = AVCLan_SendAnswerFrame((byte*)c3);
|
|
||||||
if (!r) r = AVCLan_SendAnswerFrame((byte*)c4);
|
|
||||||
if (!r) r = AVCLan_SendAnswerFrame((byte*)c5);
|
|
||||||
if (!r) r = AVCLan_SendAnswerFrame((byte*)c6);
|
|
||||||
if (!r) r = AVCLan_SendAnswerFrame((byte*)c7);
|
|
||||||
if (!r) r = AVCLan_SendAnswerFrame((byte*)c8);
|
|
||||||
if (!r) r = AVCLan_SendAnswerFrame((byte*)c9);
|
|
||||||
if (!r) r = AVCLan_SendAnswerFrame((byte*)cA);
|
|
||||||
|
|
||||||
//const byte c1[] = { 0x0, 0x0B, 0x63, 0x31, 0xF1, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x80 };
|
|
||||||
//r = AVCLan_SendAnswerFrame((byte*)c1);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Nothing needed.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void AVCLan_Send_Status()
|
|
||||||
{
|
|
||||||
// disc track t_min t_sec
|
|
||||||
byte STATUS[] = {0x0, 0x0B, 0x63, 0x31, 0xF1, 0x01, 0x10, 0x01, 0x01, 0x00, 0x00, 0x00, 0x80 };
|
|
||||||
|
|
||||||
STATUS[7] = cd_Disc;
|
|
||||||
STATUS[8] = cd_Track;
|
|
||||||
STATUS[9] = cd_Time_Min;
|
|
||||||
STATUS[10] = cd_Time_Sec;
|
|
||||||
|
|
||||||
STATUS[11] = 0;
|
|
||||||
|
|
||||||
AVCLan_SendAnswerFrame((byte*)STATUS);
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Nothing needed.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_SendAnswer()
|
|
||||||
{
|
|
||||||
byte r = 0 ;
|
|
||||||
|
|
||||||
switch (answerReq) {
|
|
||||||
case cmStatus1: r = AVCLan_SendAnswerFrame((byte*)CMD_STATUS1);
|
|
||||||
break;
|
|
||||||
case cmStatus2: r = AVCLan_SendAnswerFrame((byte*)CMD_STATUS2);
|
|
||||||
break;
|
|
||||||
case cmStatus3: r = AVCLan_SendAnswerFrame((byte*)CMD_STATUS3);
|
|
||||||
break;
|
|
||||||
case cmStatus4: r = AVCLan_SendAnswerFrame((byte*)CMD_STATUS4);
|
|
||||||
break;
|
|
||||||
case cmRegister: r = AVCLan_SendAnswerFrame((byte*)CMD_REGISTER);
|
|
||||||
break;
|
|
||||||
case cmInit: //RS232_Print_P(PSTR("INIT\n"));
|
|
||||||
r = AVCLan_SendInitCommands();
|
|
||||||
break;
|
|
||||||
case cmCheck: r = AVCLan_SendAnswerFrame((byte*)CMD_CHECK);
|
|
||||||
check_timeout = 0;
|
|
||||||
CMD_CHECK[6]++;
|
|
||||||
RS232_Print_P(PSTR("AVCCHK\n"));
|
|
||||||
break;
|
|
||||||
case cmPlayReq1: playMode = 0;
|
|
||||||
r = AVCLan_SendAnswerFrame((byte*)CMD_PLAY_OK1);
|
|
||||||
break;
|
|
||||||
case cmPlayReq2:
|
|
||||||
case cmPlayReq3: playMode = 0;
|
|
||||||
r = AVCLan_SendAnswerFrame((byte*)CMD_PLAY_OK2);
|
|
||||||
if (!r) r = AVCLan_SendAnswerFrame((byte*)CMD_PLAY_OK3);
|
|
||||||
CD_Mode = stPlay;
|
|
||||||
break;
|
|
||||||
case cmPlayIt: playMode = 1;
|
|
||||||
RS232_Print_P(PSTR("PLAY\n"));
|
|
||||||
CMD_PLAY_OK4[7]=cd_Disc;
|
|
||||||
CMD_PLAY_OK4[8]=cd_Track;
|
|
||||||
CMD_PLAY_OK4[9]=cd_Time_Min;
|
|
||||||
CMD_PLAY_OK4[10]=cd_Time_Sec;
|
|
||||||
r = AVCLan_SendAnswerFrame((byte*)CMD_PLAY_OK4);
|
|
||||||
if (!r) AVCLan_Send_Status();
|
|
||||||
CD_Mode = stPlay;
|
|
||||||
break;
|
|
||||||
case cmStopReq:
|
|
||||||
case cmStopReq2: CD_Mode = stStop;
|
|
||||||
playMode = 0;
|
|
||||||
|
|
||||||
r = AVCLan_SendAnswerFrame((byte*)CMD_STOP1);
|
|
||||||
CMD_STOP2[7]=cd_Disc;
|
|
||||||
CMD_STOP2[8]=cd_Track;
|
|
||||||
CMD_STOP2[9]=cd_Time_Min;
|
|
||||||
CMD_STOP2[10]=cd_Time_Sec;
|
|
||||||
r = AVCLan_SendAnswerFrame((byte*)CMD_STOP2);
|
|
||||||
break;
|
|
||||||
case cmBeep: AVCLan_SendAnswerFrame((byte*)CMD_BEEP);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
answerReq = cmNull;
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Nothing needed.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void AVCLan_Register()
|
|
||||||
{
|
|
||||||
RS232_Print_P(PSTR("REG_ST\n"));
|
|
||||||
AVCLan_SendAnswerFrame((byte*)CMD_REGISTER);
|
|
||||||
RS232_Print_P(PSTR("REG_END\n"));
|
|
||||||
//AVCLan_Command( cmRegister );
|
|
||||||
AVCLan_Command( cmInit );
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Nothing needed.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte AVCLan_Command(byte command)
|
|
||||||
{
|
|
||||||
byte r;
|
|
||||||
|
|
||||||
answerReq = command;
|
|
||||||
r = AVCLan_SendAnswer();
|
|
||||||
/*
|
|
||||||
RS232_Print_P(PSTR("ret="));
|
|
||||||
RS232_PrintHex8(r);
|
|
||||||
RS232_Print_P(PSTR("\n"));
|
|
||||||
*/
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Nothing needed.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte HexInc(byte data)
|
|
||||||
{
|
|
||||||
if ((data & 0x9)==0x9)
|
|
||||||
return (data + 7);
|
|
||||||
|
|
||||||
return (data+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Nothing needed.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
byte HexDec(byte data)
|
|
||||||
{
|
|
||||||
if ((data & 0xF)==0)
|
|
||||||
return (data - 7);
|
|
||||||
|
|
||||||
return (data-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: Nothing needed.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// encode decimal valute to 'toyota' format :-)
|
|
||||||
// ex. 42 (dec) = 0x42 (toy)
|
|
||||||
byte Dec2Toy(byte data)
|
|
||||||
{
|
|
||||||
byte d,d1;
|
|
||||||
d = (unsigned int)data/(unsigned int)10;
|
|
||||||
d1 = d * 16;
|
|
||||||
d = d1 + (data - 10*d);
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
// DONE: No timing adjustment needed.
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void ShowInMessage()
|
|
||||||
{
|
|
||||||
if (message_len==0) return;
|
|
||||||
|
|
||||||
AVC_HoldLine();
|
|
||||||
|
|
||||||
|
|
||||||
RS232_Print_P(PSTR("HU < ("));
|
|
||||||
|
|
||||||
if (broadcast==0) RS232_Print_P(PSTR("bro) "));
|
|
||||||
else RS232_Print_P(PSTR("dir) "));
|
|
||||||
|
|
||||||
RS232_PrintHex4(master1);
|
|
||||||
RS232_PrintHex8(master2);
|
|
||||||
RS232_Print_P(PSTR("| "));
|
|
||||||
RS232_PrintHex4(slave1);
|
|
||||||
RS232_PrintHex8(slave2);
|
|
||||||
RS232_Print_P(PSTR("| "));
|
|
||||||
|
|
||||||
byte i;
|
|
||||||
for (i=0;i<message_len;i++) {
|
|
||||||
RS232_PrintHex8(message[i]);
|
|
||||||
RS232_Print_P(PSTR(" "));
|
|
||||||
}
|
|
||||||
RS232_Print_P(PSTR("\n"));
|
|
||||||
|
|
||||||
AVC_ReleaseLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void ShowOutMessage()
|
|
||||||
{
|
|
||||||
byte i;
|
|
||||||
|
|
||||||
AVC_HoldLine();
|
|
||||||
|
|
||||||
RS232_Print_P(PSTR("out > "));
|
|
||||||
for (i=0; i<data_len; i++) {
|
|
||||||
RS232_PrintHex8(data[i]);
|
|
||||||
RS232_SendByte(' ');
|
|
||||||
}
|
|
||||||
RS232_Print_P(PSTR("\n"));
|
|
||||||
|
|
||||||
AVC_ReleaseLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AVCLan_Measure()
|
|
||||||
{
|
|
||||||
STOPEvent;
|
|
||||||
|
|
||||||
word tmp, tmp1, tmp2, bit0, bit1;
|
|
||||||
word n = 0;
|
|
||||||
|
|
||||||
cbi(TCCR1B,CS12);
|
|
||||||
TCCR1B = _BV(CS10);
|
|
||||||
|
|
||||||
while ( n < 1000 )
|
|
||||||
{
|
|
||||||
while(INPUT_IS_CLEAR);
|
|
||||||
|
|
||||||
TCNT1 = 0;
|
|
||||||
|
|
||||||
while(INPUT_IS_SET);
|
|
||||||
|
|
||||||
tmp = TCNT1;
|
|
||||||
|
|
||||||
while(INPUT_IS_CLEAR);
|
|
||||||
|
|
||||||
tmp1 = TCNT1;
|
|
||||||
|
|
||||||
while(INPUT_IS_SET);
|
|
||||||
|
|
||||||
tmp2 = TCNT1;
|
|
||||||
|
|
||||||
bit0 = tmp1-tmp;
|
|
||||||
bit1 = tmp2-tmp1;
|
|
||||||
|
|
||||||
RS232_Print_P(PSTR("1,"));
|
|
||||||
RS232_PrintDec(bit1);
|
|
||||||
RS232_Print_P(PSTR("\n"));
|
|
||||||
|
|
||||||
RS232_Print_P(PSTR("0,"));
|
|
||||||
RS232_PrintDec(bit0);
|
|
||||||
RS232_Print_P(PSTR("\n"));
|
|
||||||
n++;
|
|
||||||
}
|
|
||||||
|
|
||||||
RS232_Print_P(PSTR("Done.\n"));
|
|
||||||
|
|
||||||
cbi(TCCR1B,CS10);
|
|
||||||
TCCR1B = _BV(CS12);
|
|
||||||
|
|
||||||
STARTEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
-136
@@ -1,136 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (C) 2015 Allen Hill <allenofthehills@gmail.com>.
|
|
||||||
|
|
||||||
Portions of the following source code are:
|
|
||||||
Copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
this file is a part of the TOYOTA Corolla MP3 Player Project
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
http://www.softservice.com.pl/corolla/avc
|
|
||||||
|
|
||||||
May 28 / 2009 - version 2
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef __AVCLANDRV_H
|
|
||||||
#define __AVCLANDRV_H
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#include "GlobalDef.h"
|
|
||||||
|
|
||||||
#define STOPEvent cbi(TIMSK1, TOIE1); cbi(UCSR0B, RXCIE0);
|
|
||||||
#define STARTEvent sbi(TIMSK1, TOIE1); sbi(UCSR0B, RXCIE0);
|
|
||||||
|
|
||||||
|
|
||||||
#define CHECK_AVC_LINE if (INPUT_IS_SET) AVCLan_Read_Message();
|
|
||||||
|
|
||||||
void AVC_HoldLine();
|
|
||||||
void AVC_ReleaseLine();
|
|
||||||
|
|
||||||
#define MAXMSGLEN 32
|
|
||||||
|
|
||||||
// Head Unid ID
|
|
||||||
extern byte HU_ID_1; // 0x01
|
|
||||||
extern byte HU_ID_2; // 0x40
|
|
||||||
|
|
||||||
extern byte CD_ID_1; // 0x03
|
|
||||||
extern byte CD_ID_2; // 0x60
|
|
||||||
|
|
||||||
|
|
||||||
// DVD CHANGER
|
|
||||||
//#define CD_ID_1 0x02
|
|
||||||
//#define CD_ID_2 0x50
|
|
||||||
|
|
||||||
#define cmNull 0
|
|
||||||
#define cmStatus1 1
|
|
||||||
#define cmStatus2 2
|
|
||||||
#define cmStatus3 3
|
|
||||||
#define cmStatus4 4
|
|
||||||
|
|
||||||
|
|
||||||
#define cmRegister 100
|
|
||||||
#define cmInit 101
|
|
||||||
#define cmCheck 102
|
|
||||||
#define cmPlayIt 103
|
|
||||||
#define cmBeep 110
|
|
||||||
|
|
||||||
#define cmNextTrack 120
|
|
||||||
#define cmPrevTrack 121
|
|
||||||
#define cmNextDisc 122
|
|
||||||
#define cmPrevDisc 123
|
|
||||||
|
|
||||||
#define cmScanModeOn 130
|
|
||||||
#define cmScanModeOff 131
|
|
||||||
|
|
||||||
#define cmPlayReq1 5
|
|
||||||
#define cmPlayReq2 6
|
|
||||||
#define cmPlayReq3 7
|
|
||||||
#define cmStopReq 8
|
|
||||||
#define cmStopReq2 9
|
|
||||||
|
|
||||||
typedef enum { stStop=0, stPlay=1 } cd_modes;
|
|
||||||
extern cd_modes CD_Mode;
|
|
||||||
|
|
||||||
|
|
||||||
extern byte broadcast;
|
|
||||||
extern byte master1;
|
|
||||||
extern byte master2;
|
|
||||||
extern byte slave1;
|
|
||||||
extern byte slave2;
|
|
||||||
extern byte message_len;
|
|
||||||
extern byte message[MAXMSGLEN];
|
|
||||||
|
|
||||||
extern byte data_control;
|
|
||||||
extern byte data_len;
|
|
||||||
extern byte data[MAXMSGLEN];
|
|
||||||
|
|
||||||
byte AVCLan_Read_Message();
|
|
||||||
void AVCLan_Send_Status();
|
|
||||||
|
|
||||||
void AVCLan_Init();
|
|
||||||
void AVCLan_Register();
|
|
||||||
byte AVCLan_SendData();
|
|
||||||
byte AVCLan_SendAnswer();
|
|
||||||
byte AVCLan_SendDataBroadcast();
|
|
||||||
byte AVCLan_Command(byte command);
|
|
||||||
|
|
||||||
byte HexInc(byte data);
|
|
||||||
byte HexDec(byte data);
|
|
||||||
byte Dec2Toy(byte data);
|
|
||||||
|
|
||||||
extern byte check_timeout;
|
|
||||||
|
|
||||||
extern byte cd_Disc;
|
|
||||||
extern byte cd_Track;
|
|
||||||
extern byte cd_Time_Min;
|
|
||||||
extern byte cd_Time_Sec;
|
|
||||||
|
|
||||||
extern byte playMode;
|
|
||||||
|
|
||||||
byte AVCLan_SendMyData(byte *data_tmp, byte s_len);
|
|
||||||
byte AVCLan_SendMyDataBroadcast(byte *data_tmp, byte s_len);
|
|
||||||
|
|
||||||
void ShowInMessage();
|
|
||||||
void ShowOutMessage();
|
|
||||||
|
|
||||||
void AVCLan_Measure();
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
extern byte answerReq;
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#endif
|
|
||||||
@@ -0,0 +1,400 @@
|
|||||||
|
##########################################################################
|
||||||
|
# "THE ANY BEVERAGE-WARE LICENSE" (Revision 42 - based on beer-ware
|
||||||
|
# license):
|
||||||
|
# <dev@layer128.net> wrote this file. As long as you retain this notice
|
||||||
|
# you can do whatever you want with this stuff. If we meet some day, and
|
||||||
|
# you think this stuff is worth it, you can buy me a be(ve)er(age) in
|
||||||
|
# return. (I don't like beer much.)
|
||||||
|
#
|
||||||
|
# Matthias Kleemann
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# The toolchain requires some variables set.
|
||||||
|
#
|
||||||
|
# AVR_MCU (default: atmega8)
|
||||||
|
# the type of AVR the application is built for
|
||||||
|
# AVR_L_FUSE (NO DEFAULT)
|
||||||
|
# the LOW fuse value for the MCU used
|
||||||
|
# AVR_H_FUSE (NO DEFAULT)
|
||||||
|
# the HIGH fuse value for the MCU used
|
||||||
|
# AVR_UPLOADTOOL (default: avrdude)
|
||||||
|
# the application used to upload to the MCU
|
||||||
|
# NOTE: The toolchain is currently quite specific about
|
||||||
|
# the commands used, so it needs tweaking.
|
||||||
|
# AVR_UPLOADTOOL_PORT (default: usb)
|
||||||
|
# the port used for the upload tool, e.g. usb
|
||||||
|
# AVR_PROGRAMMER (default: avrispmkII)
|
||||||
|
# the programmer hardware used, e.g. avrispmkII
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# options
|
||||||
|
##########################################################################
|
||||||
|
option(WITH_MCU "Add the mCU type to the target file name." ON)
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# executables in use
|
||||||
|
##########################################################################
|
||||||
|
find_program(AVR_CC avr-gcc REQUIRED)
|
||||||
|
find_program(AVR_CXX avr-g++ REQUIRED)
|
||||||
|
find_program(AVR_OBJCOPY avr-objcopy REQUIRED)
|
||||||
|
find_program(AVR_SIZE_TOOL avr-size REQUIRED)
|
||||||
|
find_program(AVR_OBJDUMP avr-objdump REQUIRED)
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# toolchain starts with defining mandatory variables
|
||||||
|
##########################################################################
|
||||||
|
set(CMAKE_SYSTEM_NAME Generic)
|
||||||
|
set(CMAKE_SYSTEM_PROCESSOR avr)
|
||||||
|
set(CMAKE_C_COMPILER ${AVR_CC})
|
||||||
|
set(CMAKE_CXX_COMPILER ${AVR_CXX})
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# Identification
|
||||||
|
##########################################################################
|
||||||
|
set(AVR 1)
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# some necessary tools and variables for AVR builds, which may not
|
||||||
|
# defined yet
|
||||||
|
# - AVR_UPLOADTOOL
|
||||||
|
# - AVR_UPLOADTOOL_PORT
|
||||||
|
# - AVR_PROGRAMMER
|
||||||
|
# - AVR_MCU
|
||||||
|
# - AVR_SIZE_ARGS
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
# default upload tool
|
||||||
|
if(NOT AVR_UPLOADTOOL)
|
||||||
|
set(
|
||||||
|
AVR_UPLOADTOOL avrdude
|
||||||
|
CACHE STRING "Set default upload tool: avrdude"
|
||||||
|
)
|
||||||
|
find_program(AVR_UPLOADTOOL avrdude)
|
||||||
|
endif(NOT AVR_UPLOADTOOL)
|
||||||
|
|
||||||
|
# default upload tool port
|
||||||
|
if(NOT AVR_UPLOADTOOL_PORT)
|
||||||
|
set(
|
||||||
|
AVR_UPLOADTOOL_PORT usb
|
||||||
|
CACHE STRING "Set default upload tool port: usb"
|
||||||
|
)
|
||||||
|
endif(NOT AVR_UPLOADTOOL_PORT)
|
||||||
|
|
||||||
|
# default programmer (hardware)
|
||||||
|
if(NOT AVR_PROGRAMMER)
|
||||||
|
set(
|
||||||
|
AVR_PROGRAMMER avrispmkII
|
||||||
|
CACHE STRING "Set default programmer hardware model: avrispmkII"
|
||||||
|
)
|
||||||
|
endif(NOT AVR_PROGRAMMER)
|
||||||
|
|
||||||
|
# default MCU (chip)
|
||||||
|
if(NOT AVR_MCU)
|
||||||
|
set(
|
||||||
|
AVR_MCU atmega8
|
||||||
|
CACHE STRING "Set default MCU: atmega8 (see 'avr-gcc --target-help' for valid values)"
|
||||||
|
)
|
||||||
|
endif(NOT AVR_MCU)
|
||||||
|
|
||||||
|
#default avr-size args
|
||||||
|
if(NOT AVR_SIZE_ARGS)
|
||||||
|
if(APPLE)
|
||||||
|
set(AVR_SIZE_ARGS -B)
|
||||||
|
else(APPLE)
|
||||||
|
set(AVR_SIZE_ARGS -G)
|
||||||
|
endif(APPLE)
|
||||||
|
endif(NOT AVR_SIZE_ARGS)
|
||||||
|
|
||||||
|
# prepare base flags for upload tool
|
||||||
|
set(AVR_UPLOADTOOL_BASE_OPTIONS -p ${AVR_MCU} -c ${AVR_PROGRAMMER})
|
||||||
|
|
||||||
|
# use AVR_UPLOADTOOL_BAUDRATE as baudrate for upload tool (if defined)
|
||||||
|
if(AVR_UPLOADTOOL_BAUDRATE)
|
||||||
|
set(AVR_UPLOADTOOL_BASE_OPTIONS ${AVR_UPLOADTOOL_BASE_OPTIONS} -b ${AVR_UPLOADTOOL_BAUDRATE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# check build types:
|
||||||
|
# - Debug
|
||||||
|
# - Release
|
||||||
|
# - RelWithDebInfo
|
||||||
|
#
|
||||||
|
# Release is chosen, because of some optimized functions in the
|
||||||
|
# AVR toolchain, e.g. _delay_ms().
|
||||||
|
##########################################################################
|
||||||
|
if(NOT ((CMAKE_BUILD_TYPE MATCHES Release) OR
|
||||||
|
(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) OR
|
||||||
|
(CMAKE_BUILD_TYPE MATCHES Debug) OR
|
||||||
|
(CMAKE_BUILD_TYPE MATCHES MinSizeRel)))
|
||||||
|
set(
|
||||||
|
CMAKE_BUILD_TYPE Release
|
||||||
|
CACHE STRING "Choose cmake build type: Debug Release RelWithDebInfo MinSizeRel"
|
||||||
|
FORCE
|
||||||
|
)
|
||||||
|
endif(NOT ((CMAKE_BUILD_TYPE MATCHES Release) OR
|
||||||
|
(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) OR
|
||||||
|
(CMAKE_BUILD_TYPE MATCHES Debug) OR
|
||||||
|
(CMAKE_BUILD_TYPE MATCHES MinSizeRel)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# target file name add-on
|
||||||
|
##########################################################################
|
||||||
|
if(WITH_MCU)
|
||||||
|
set(MCU_TYPE_FOR_FILENAME "-${AVR_MCU}")
|
||||||
|
else(WITH_MCU)
|
||||||
|
set(MCU_TYPE_FOR_FILENAME "")
|
||||||
|
endif(WITH_MCU)
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# add_avr_executable
|
||||||
|
# - IN_VAR: EXECUTABLE_NAME
|
||||||
|
#
|
||||||
|
# Creates targets and dependencies for AVR toolchain, building an
|
||||||
|
# executable. Calls add_executable with ELF file as target name, so
|
||||||
|
# any link dependencies need to be using that target, e.g. for
|
||||||
|
# target_link_libraries(<EXECUTABLE_NAME>-${AVR_MCU}.elf ...).
|
||||||
|
##########################################################################
|
||||||
|
function(add_avr_executable EXECUTABLE_NAME)
|
||||||
|
|
||||||
|
if(NOT ARGN)
|
||||||
|
message(FATAL_ERROR "No source files given for ${EXECUTABLE_NAME}.")
|
||||||
|
endif(NOT ARGN)
|
||||||
|
|
||||||
|
# set file names
|
||||||
|
set(hex_file ${EXECUTABLE_NAME}${MCU_TYPE_FOR_FILENAME}.hex)
|
||||||
|
set(lst_file ${EXECUTABLE_NAME}${MCU_TYPE_FOR_FILENAME}.lst)
|
||||||
|
set(map_file ${EXECUTABLE_NAME}${MCU_TYPE_FOR_FILENAME}.map)
|
||||||
|
set(eeprom_image ${EXECUTABLE_NAME}${MCU_TYPE_FOR_FILENAME}-eeprom.hex)
|
||||||
|
|
||||||
|
set (${EXECUTABLE_NAME}_ELF_TARGET ${EXECUTABLE_NAME} PARENT_SCOPE)
|
||||||
|
set (${EXECUTABLE_NAME}_HEX_TARGET ${hex_file} PARENT_SCOPE)
|
||||||
|
set (${EXECUTABLE_NAME}_LST_TARGET ${lst_file} PARENT_SCOPE)
|
||||||
|
set (${EXECUTABLE_NAME}_MAP_TARGET ${map_file} PARENT_SCOPE)
|
||||||
|
set (${EXECUTABLE_NAME}_EEPROM_TARGET ${eeprom_file} PARENT_SCOPE)
|
||||||
|
# elf file
|
||||||
|
add_executable(${EXECUTABLE_NAME} ${ARGN})
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
${EXECUTABLE_NAME}
|
||||||
|
PROPERTIES
|
||||||
|
COMPILE_FLAGS "-mmcu=${AVR_MCU}"
|
||||||
|
LINK_FLAGS "-mmcu=${AVR_MCU} -Wl,--gc-sections -mrelax -Wl,-Map,${map_file}"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${lst_file}
|
||||||
|
COMMAND
|
||||||
|
${AVR_OBJDUMP} -d ${EXECUTABLE_NAME} > ${lst_file}
|
||||||
|
DEPENDS ${EXECUTABLE_NAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
# eeprom
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${eeprom_image}
|
||||||
|
COMMAND
|
||||||
|
${AVR_OBJCOPY} -j .eeprom --set-section-flags=.eeprom=alloc,load
|
||||||
|
--change-section-lma .eeprom=0 --no-change-warnings
|
||||||
|
-O ihex ${EXECUTABLE_NAME} ${eeprom_image}
|
||||||
|
DEPENDS ${EXECUTABLE_NAME}
|
||||||
|
)
|
||||||
|
|
||||||
|
# clean
|
||||||
|
get_directory_property(clean_files ADDITIONAL_MAKE_CLEAN_FILES)
|
||||||
|
set_directory_properties(
|
||||||
|
PROPERTIES
|
||||||
|
ADDITIONAL_MAKE_CLEAN_FILES "${map_file}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# upload - with avrdude
|
||||||
|
add_custom_target(
|
||||||
|
upload_${EXECUTABLE_NAME}
|
||||||
|
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} ${AVR_UPLOADTOOL_OPTIONS}
|
||||||
|
-U flash:w:${EXECUTABLE_NAME}:e
|
||||||
|
-P ${AVR_UPLOADTOOL_PORT}
|
||||||
|
DEPENDS ${EXECUTABLE_NAME}
|
||||||
|
COMMENT "Uploading ${hex_file} to ${AVR_MCU} using ${AVR_PROGRAMMER}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# upload eeprom only - with avrdude
|
||||||
|
# see also bug http://savannah.nongnu.org/bugs/?40142
|
||||||
|
add_custom_target(
|
||||||
|
upload_${EXECUTABLE_NAME}_eeprom
|
||||||
|
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} ${AVR_UPLOADTOOL_OPTIONS}
|
||||||
|
-U eeprom:w:${eeprom_image}
|
||||||
|
-P ${AVR_UPLOADTOOL_PORT}
|
||||||
|
DEPENDS ${eeprom_image}
|
||||||
|
COMMENT "Uploading ${eeprom_image} to ${AVR_MCU} using ${AVR_PROGRAMMER}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# disassemble
|
||||||
|
add_custom_target(
|
||||||
|
disassemble_${EXECUTABLE_NAME}
|
||||||
|
${AVR_OBJDUMP} -h -S ${EXECUTABLE_NAME} > ${EXECUTABLE_NAME}.lst
|
||||||
|
DEPENDS ${EXECUTABLE_NAME}
|
||||||
|
)
|
||||||
|
endfunction(add_avr_executable)
|
||||||
|
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# add_avr_library
|
||||||
|
# - IN_VAR: LIBRARY_NAME
|
||||||
|
#
|
||||||
|
# Calls add_library with an optionally concatenated name
|
||||||
|
# <LIBRARY_NAME>${MCU_TYPE_FOR_FILENAME}.
|
||||||
|
# This needs to be used for linking against the library, e.g. calling
|
||||||
|
# target_link_libraries(...).
|
||||||
|
##########################################################################
|
||||||
|
function(add_avr_library LIBRARY_NAME)
|
||||||
|
if(NOT ARGN)
|
||||||
|
message(FATAL_ERROR "No source files given for ${LIBRARY_NAME}.")
|
||||||
|
endif(NOT ARGN)
|
||||||
|
|
||||||
|
set(lib_file ${LIBRARY_NAME}${MCU_TYPE_FOR_FILENAME})
|
||||||
|
set (${LIBRARY_NAME}_LIB_TARGET ${elf_file} PARENT_SCOPE)
|
||||||
|
|
||||||
|
add_library(${lib_file} STATIC ${ARGN})
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
${lib_file}
|
||||||
|
PROPERTIES
|
||||||
|
COMPILE_FLAGS "-mmcu=${AVR_MCU}"
|
||||||
|
OUTPUT_NAME "${lib_file}"
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT TARGET ${LIBRARY_NAME})
|
||||||
|
add_custom_target(
|
||||||
|
${LIBRARY_NAME}
|
||||||
|
ALL
|
||||||
|
DEPENDS ${lib_file}
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
${LIBRARY_NAME}
|
||||||
|
PROPERTIES
|
||||||
|
OUTPUT_NAME "${lib_file}"
|
||||||
|
)
|
||||||
|
endif(NOT TARGET ${LIBRARY_NAME})
|
||||||
|
|
||||||
|
endfunction(add_avr_library)
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# avr_target_link_libraries
|
||||||
|
# - IN_VAR: EXECUTABLE_TARGET
|
||||||
|
# - ARGN : targets and files to link to
|
||||||
|
#
|
||||||
|
# Calls target_link_libraries with AVR target names (concatenation,
|
||||||
|
# extensions and so on.
|
||||||
|
##########################################################################
|
||||||
|
function(avr_target_link_libraries EXECUTABLE_TARGET)
|
||||||
|
if(NOT ARGN)
|
||||||
|
message(FATAL_ERROR "Nothing to link to ${EXECUTABLE_TARGET}.")
|
||||||
|
endif(NOT ARGN)
|
||||||
|
|
||||||
|
get_target_property(TARGET_LIST ${EXECUTABLE_TARGET} OUTPUT_NAME)
|
||||||
|
|
||||||
|
foreach(TGT ${ARGN})
|
||||||
|
if(TARGET ${TGT})
|
||||||
|
get_target_property(ARG_NAME ${TGT} OUTPUT_NAME)
|
||||||
|
list(APPEND NON_TARGET_LIST ${ARG_NAME})
|
||||||
|
else(TARGET ${TGT})
|
||||||
|
list(APPEND NON_TARGET_LIST ${TGT})
|
||||||
|
endif(TARGET ${TGT})
|
||||||
|
endforeach(TGT ${ARGN})
|
||||||
|
|
||||||
|
target_link_libraries(${TARGET_LIST} ${NON_TARGET_LIST})
|
||||||
|
endfunction(avr_target_link_libraries EXECUTABLE_TARGET)
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# avr_target_include_directories
|
||||||
|
#
|
||||||
|
# Calls target_include_directories with AVR target names
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
function(avr_target_include_directories EXECUTABLE_TARGET)
|
||||||
|
if(NOT ARGN)
|
||||||
|
message(FATAL_ERROR "No include directories to add to ${EXECUTABLE_TARGET}.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_target_property(TARGET_LIST ${EXECUTABLE_TARGET} OUTPUT_NAME)
|
||||||
|
set(extra_args ${ARGN})
|
||||||
|
|
||||||
|
target_include_directories(${TARGET_LIST} ${extra_args})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# avr_target_compile_definitions
|
||||||
|
#
|
||||||
|
# Calls target_compile_definitions with AVR target names
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
function(avr_target_compile_definitions EXECUTABLE_TARGET)
|
||||||
|
if(NOT ARGN)
|
||||||
|
message(FATAL_ERROR "No compile definitions to add to ${EXECUTABLE_TARGET}.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_target_property(TARGET_LIST ${EXECUTABLE_TARGET} OUTPUT_NAME)
|
||||||
|
set(extra_args ${ARGN})
|
||||||
|
|
||||||
|
target_compile_definitions(${TARGET_LIST} ${extra_args})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(avr_generate_fixed_targets)
|
||||||
|
# get status
|
||||||
|
add_custom_target(
|
||||||
|
get_status
|
||||||
|
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT} -n -v
|
||||||
|
COMMENT "Get status from ${AVR_MCU}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# get fuses
|
||||||
|
add_custom_target(
|
||||||
|
get_fuses
|
||||||
|
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT} -n
|
||||||
|
-U lfuse:r:-:b
|
||||||
|
-U hfuse:r:-:b
|
||||||
|
COMMENT "Get fuses from ${AVR_MCU}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# set fuses
|
||||||
|
add_custom_target(
|
||||||
|
set_fuses
|
||||||
|
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT}
|
||||||
|
-U lfuse:w:${AVR_L_FUSE}:m
|
||||||
|
-U hfuse:w:${AVR_H_FUSE}:m
|
||||||
|
COMMENT "Setup: High Fuse: ${AVR_H_FUSE} Low Fuse: ${AVR_L_FUSE}"
|
||||||
|
)
|
||||||
|
|
||||||
|
# get oscillator calibration
|
||||||
|
add_custom_target(
|
||||||
|
get_calibration
|
||||||
|
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT}
|
||||||
|
-U calibration:r:${AVR_MCU}_calib.tmp:r
|
||||||
|
COMMENT "Write calibration status of internal oscillator to ${AVR_MCU}_calib.tmp."
|
||||||
|
)
|
||||||
|
|
||||||
|
# set oscillator calibration
|
||||||
|
add_custom_target(
|
||||||
|
set_calibration
|
||||||
|
${AVR_UPLOADTOOL} ${AVR_UPLOADTOOL_BASE_OPTIONS} -P ${AVR_UPLOADTOOL_PORT}
|
||||||
|
-U calibration:w:${AVR_MCU}_calib.hex
|
||||||
|
COMMENT "Program calibration status of internal oscillator from ${AVR_MCU}_calib.hex."
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
##########################################################################
|
||||||
|
# Bypass the link step in CMake's "compiler sanity test" check
|
||||||
|
#
|
||||||
|
# CMake throws in a try_compile() target test in some generators, but does
|
||||||
|
# not know that this is a cross compiler so the executable can't link.
|
||||||
|
# Change the target type:
|
||||||
|
#
|
||||||
|
# https://stackoverflow.com/q/53633705
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#if __has_include(<component-version.h>)
|
||||||
|
#include <component-version.h>
|
||||||
|
#if ((COMPONENT_VERSION_MAJOR == 1) && (COMPONENT_VERSION_MINOR == 2) && \
|
||||||
|
(BUILD_NUMBER < 118))
|
||||||
|
#error \
|
||||||
|
"Microchip pack component version greater than 1.2.118 required to support ATtiny3216"
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#include <avr/version.h>
|
||||||
|
#if !(__AVR_LIBC_VERSION__ > 20100UL)
|
||||||
|
#error "AVR LibC version greater than 2.1 does support ATtiny3216"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
|
||||||
|
int main() { return 0; }
|
||||||
@@ -1,129 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
this file is a part of the TOYOTA Corolla MP3 Player Project
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
http://www.softservice.com.pl/corolla/avc
|
|
||||||
|
|
||||||
May 28 / 2009 - version 2
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <avr/interrupt.h>
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
#include "com232.h"
|
|
||||||
|
|
||||||
byte RS232_RxCharBuffer[25], RS232_RxCharBegin, RS232_RxCharEnd;
|
|
||||||
byte readkey;
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void RS232_Init(void)
|
|
||||||
{
|
|
||||||
// init LED
|
|
||||||
sbi(DDRB, 5);
|
|
||||||
cbi(PORTB, 5);
|
|
||||||
|
|
||||||
RS232_RxCharBegin = RS232_RxCharEnd = 0;
|
|
||||||
|
|
||||||
UCSR0A = 0;
|
|
||||||
UCSR0B = ((1<<RXCIE0) | (1<<RXEN0) | (1<<TXEN0)); // enable RxD/TxD and interrupts
|
|
||||||
UCSR0C = ((1<<UCSZ01)|(1<<UCSZ00)); // 8N1
|
|
||||||
UBRR0L = 8; // Baud Rate 9600 (3 for 250000)
|
|
||||||
// 103 => 9600
|
|
||||||
// 51 => 19200
|
|
||||||
// 25 => 38400
|
|
||||||
// 8 => 115200
|
|
||||||
// 3 => 250000
|
|
||||||
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
ISR(USART_RX_vect)
|
|
||||||
{
|
|
||||||
RS232_RxCharBuffer[RS232_RxCharEnd] = UDR0; // Store received character to the End of Buffer
|
|
||||||
RS232_RxCharEnd++;
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void RS232_SendByte(byte Data)
|
|
||||||
{
|
|
||||||
while ((UCSR0A & _BV(UDRE0)) != _BV(UDRE0)); // wait for UART to become available
|
|
||||||
UDR0 = Data; // send character
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void RS232_Print_P(const char * str_addr)
|
|
||||||
{
|
|
||||||
register byte c;
|
|
||||||
while ( (c = pgm_read_byte(str_addr++) ) )
|
|
||||||
{
|
|
||||||
if (c == '\n')
|
|
||||||
RS232_SendByte('\r');
|
|
||||||
RS232_SendByte(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void RS232_Print(const char *pBuf)
|
|
||||||
{
|
|
||||||
register byte c;
|
|
||||||
while ((c = *pBuf++))
|
|
||||||
{
|
|
||||||
if (c == '\n')
|
|
||||||
RS232_SendByte('\r');
|
|
||||||
RS232_SendByte(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void RS232_PrintHex4(byte Data)
|
|
||||||
{
|
|
||||||
byte Character = Data & 0x0f;
|
|
||||||
Character += '0';
|
|
||||||
if (Character > '9')
|
|
||||||
Character += 'A' - '0' - 10;
|
|
||||||
RS232_SendByte(Character);
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void RS232_PrintHex8(byte Data)
|
|
||||||
{
|
|
||||||
RS232_PrintHex4(Data >> 4);
|
|
||||||
RS232_PrintHex4(Data);
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void RS232_PrintDec(byte Data)
|
|
||||||
{
|
|
||||||
if (Data>99) {
|
|
||||||
RS232_SendByte('*');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (Data<10) {
|
|
||||||
RS232_SendByte('0'+Data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
byte c;
|
|
||||||
unsigned short v,v1;
|
|
||||||
v = Data;
|
|
||||||
v1 = v/10;
|
|
||||||
c = '0' + (v-v1*10);
|
|
||||||
RS232_SendByte('0'+v1);
|
|
||||||
RS232_SendByte(c);
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void RS232_PrintDec2(byte Data)
|
|
||||||
{
|
|
||||||
if (Data<10) RS232_SendByte('0');
|
|
||||||
RS232_PrintDec(Data);
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
this file is a part of the TOYOTA Corolla MP3 Player Project
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
http://www.softservice.com.pl/corolla/avc
|
|
||||||
|
|
||||||
May 28 / 2009 - version 2
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __COM232_H
|
|
||||||
#define __COM232_H
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include "GlobalDef.h"
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
extern byte RS232_RxCharBuffer[25], RS232_RxCharBegin, RS232_RxCharEnd;
|
|
||||||
extern byte readkey;
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void RS232_Init(void);
|
|
||||||
extern void RS232_Print_P(const char * str_addr);
|
|
||||||
extern void RS232_SendByte(byte Data);
|
|
||||||
extern void RS232_Print(const char *pBuf);
|
|
||||||
extern void RS232_PrintHex4(byte Data);
|
|
||||||
extern void RS232_PrintHex8(byte Data);
|
|
||||||
extern void RS232_PrintDec(byte Data);
|
|
||||||
extern void RS232_PrintDec2(byte Data);
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// LED
|
|
||||||
#define LED_ON() cbi(PORTB, 5)
|
|
||||||
#define LED_OFF() sbi(PORTB, 5)
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
#endif
|
|
||||||
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
sudo apk add make cmake avrdude avr-libc gcc-avr
|
||||||
@@ -1,298 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>.
|
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
|
||||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
this file is a part of the TOYOTA Corolla MP3 Player Project
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
http://www.softservice.com.pl/corolla/avc
|
|
||||||
|
|
||||||
May 28 / 2009 - version 2
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <avr/interrupt.h>
|
|
||||||
#include <avr/pgmspace.h>
|
|
||||||
|
|
||||||
#include "GlobalDef.h"
|
|
||||||
#include "com232.h"
|
|
||||||
#include "avclandrv.h"
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
void Setup();
|
|
||||||
|
|
||||||
byte rcv_command[5];
|
|
||||||
byte rcv_pos = 0;
|
|
||||||
byte rcv_time_clr = 0;
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
// MAIN PROGRAM
|
|
||||||
//
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
// byte h;
|
|
||||||
|
|
||||||
|
|
||||||
byte readSeq = 0;
|
|
||||||
byte s_len = 0;
|
|
||||||
byte s_dig = 0;
|
|
||||||
byte s_c[2];
|
|
||||||
byte i;
|
|
||||||
byte data_tmp[32];
|
|
||||||
|
|
||||||
Setup();
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 250 );
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 250 );
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 250 );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RS232_Print("AVCLan reader 1.00\nReady\n\n");
|
|
||||||
LED_OFF();
|
|
||||||
RS232_Print_P(PSTR("D - device id\nH - HU id\nS - read sequence\nW - send command\nQ - send broadcast\nL/l - log on/off\nK/k - seq. echo on/off\nR/r - register device\nB - Beep\nT - Measure interval\n"));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
|
|
||||||
if (INPUT_IS_SET) { // if message from some device on AVCLan begin
|
|
||||||
LED_ON();
|
|
||||||
AVCLan_Read_Message();
|
|
||||||
// show message
|
|
||||||
} else {
|
|
||||||
LED_OFF();
|
|
||||||
// check command from HU
|
|
||||||
if (answerReq != 0) AVCLan_SendAnswer();
|
|
||||||
}
|
|
||||||
|
|
||||||
// HandleEvent
|
|
||||||
switch (Event) {
|
|
||||||
case EV_STATUS: Event &= ~EV_STATUS;
|
|
||||||
AVCLan_Send_Status();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Key handler
|
|
||||||
if (RS232_RxCharEnd) {
|
|
||||||
cbi(UCSR0B, RXCIE0); // disable RX complete interrupt
|
|
||||||
readkey = RS232_RxCharBuffer[RS232_RxCharBegin];// read begin of received Buffer
|
|
||||||
RS232_RxCharBegin++;
|
|
||||||
if (RS232_RxCharBegin == RS232_RxCharEnd) // if Buffer is empty
|
|
||||||
RS232_RxCharBegin = RS232_RxCharEnd = 0; // do reset Buffer
|
|
||||||
sbi(UCSR0B, RXCIE0); // enable RX complete interrupt
|
|
||||||
switch (readkey) {
|
|
||||||
case 'D': if (readSeq) {
|
|
||||||
CD_ID_1 = data_tmp[0];
|
|
||||||
CD_ID_2 = data_tmp[1];
|
|
||||||
RS232_Print_P(PSTR("DEV ID SET: 0x"));
|
|
||||||
RS232_PrintHex8(CD_ID_1);
|
|
||||||
RS232_PrintHex8(CD_ID_2);
|
|
||||||
RS232_Print_P(PSTR("\n"));
|
|
||||||
showLog = 1;
|
|
||||||
readSeq=0;
|
|
||||||
} else {
|
|
||||||
showLog = 0;
|
|
||||||
RS232_Print_P(PSTR("DEV ID > \n"));
|
|
||||||
readSeq = 1;
|
|
||||||
s_len=0;
|
|
||||||
s_dig=0;
|
|
||||||
s_c[0]=s_c[1]=0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'H': if (readSeq) {
|
|
||||||
HU_ID_1 = data_tmp[0];
|
|
||||||
HU_ID_2 = data_tmp[1];
|
|
||||||
RS232_Print_P(PSTR("HU ID SET: 0x"));
|
|
||||||
RS232_PrintHex8(HU_ID_1);
|
|
||||||
RS232_PrintHex8(HU_ID_2);
|
|
||||||
RS232_Print_P(PSTR("\n"));
|
|
||||||
showLog = 1;
|
|
||||||
readSeq=0;
|
|
||||||
} else {
|
|
||||||
showLog = 0;
|
|
||||||
RS232_Print_P(PSTR("HU ID > \n"));
|
|
||||||
readSeq = 1;
|
|
||||||
s_len=0;
|
|
||||||
s_dig=0;
|
|
||||||
s_c[0]=s_c[1]=0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'S': showLog = 0;
|
|
||||||
RS232_Print_P(PSTR("READ SEQUENCE > \n"));
|
|
||||||
readSeq = 1;
|
|
||||||
s_len=0;
|
|
||||||
s_dig=0;
|
|
||||||
s_c[0]=s_c[1]=0;
|
|
||||||
break;
|
|
||||||
case 'W' : showLog = 1;
|
|
||||||
readSeq=0;
|
|
||||||
AVCLan_SendMyData(data_tmp, s_len);
|
|
||||||
break;
|
|
||||||
case 'Q' : showLog = 1;
|
|
||||||
readSeq=0;
|
|
||||||
AVCLan_SendMyDataBroadcast(data_tmp, s_len);
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case 'R': RS232_Print_P(PSTR("REGIST:\n"));
|
|
||||||
AVCLan_Command( cmRegister );
|
|
||||||
TCNT0 = 0;
|
|
||||||
while( TCNT0 < 135 );
|
|
||||||
CHECK_AVC_LINE;
|
|
||||||
break;
|
|
||||||
case 'r': AVCLan_Register();
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case 'l': RS232_Print_P(PSTR("Log OFF\n"));
|
|
||||||
showLog = 0;
|
|
||||||
break;
|
|
||||||
case 'L': RS232_Print_P(PSTR("Log ON\n"));
|
|
||||||
showLog = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'k': RS232_Print_P(PSTR("str OFF\n"));
|
|
||||||
showLog2 = 0;
|
|
||||||
break;
|
|
||||||
case 'K': RS232_Print_P(PSTR("str ON\n"));
|
|
||||||
showLog2 = 1;
|
|
||||||
break;
|
|
||||||
case 'B':
|
|
||||||
data_tmp[0] = 0x00;
|
|
||||||
data_tmp[0] = 0x5E;
|
|
||||||
data_tmp[0] = 0x29;
|
|
||||||
data_tmp[0] = 0x60;
|
|
||||||
data_tmp[0] = 0x01;
|
|
||||||
s_len = 5;
|
|
||||||
AVCLan_SendMyData(data_tmp, s_len);
|
|
||||||
break;
|
|
||||||
case 'T':
|
|
||||||
AVCLan_Measure();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default :
|
|
||||||
if (readSeq==1) {
|
|
||||||
s_c[s_dig]=readkey;
|
|
||||||
|
|
||||||
s_dig++;
|
|
||||||
if (s_dig==2) {
|
|
||||||
if (s_c[0]<':') s_c[0] -= 48;
|
|
||||||
else s_c[0] -= 55;
|
|
||||||
data_tmp[s_len] = 16 * s_c[0];
|
|
||||||
if (s_c[1]<':') s_c[1] -= 48;
|
|
||||||
else s_c[1] -= 55;
|
|
||||||
data_tmp[s_len] += s_c[1];
|
|
||||||
s_len++;
|
|
||||||
s_dig=0;
|
|
||||||
s_c[0]=s_c[1]=0;
|
|
||||||
}
|
|
||||||
if (showLog2) {
|
|
||||||
RS232_Print_P(PSTR("CURRENT SEQUENCE > "));
|
|
||||||
for (i=0; i<s_len; i++) {
|
|
||||||
RS232_PrintHex8(data_tmp[i]);
|
|
||||||
RS232_SendByte(' ');
|
|
||||||
}
|
|
||||||
RS232_Print_P(PSTR("\n"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // switch (readkey)
|
|
||||||
|
|
||||||
}// if (RS232_RxCharEnd)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
// Setup - uP: ATMega328p
|
|
||||||
//
|
|
||||||
void Setup()
|
|
||||||
{
|
|
||||||
// GIMSK = 0; // (GICR ?) disable external interupts
|
|
||||||
|
|
||||||
CD_ID_1 = 0x03;
|
|
||||||
CD_ID_2 = 0x60;
|
|
||||||
|
|
||||||
HU_ID_1 = 0x01;
|
|
||||||
HU_ID_2 = 0x90;
|
|
||||||
|
|
||||||
showLog = 1;
|
|
||||||
showLog2 = 1;
|
|
||||||
|
|
||||||
MCUCR = 0;
|
|
||||||
|
|
||||||
// Timer 1
|
|
||||||
TIMSK1 = 0;
|
|
||||||
sbi(TIMSK1, OCIE1A); // Enable timer1 compare interrupt
|
|
||||||
TCCR1A = 0;
|
|
||||||
TCCR1B |= (1 << WGM12)|(1 << CS12); // Set CTC, prescaler at 256
|
|
||||||
OCR1A = 62499; // Compare match at 1sec intervals
|
|
||||||
|
|
||||||
|
|
||||||
RS232_Init();
|
|
||||||
|
|
||||||
|
|
||||||
AVCLan_Init();
|
|
||||||
|
|
||||||
Event = EV_NOTHING;
|
|
||||||
sei();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
// -------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
byte s1=0;
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
ISR(TIMER1_COMPA_vect) // Timer1 compare match every 1Sec
|
|
||||||
{
|
|
||||||
s1++;
|
|
||||||
if (s1==2) {
|
|
||||||
s1=0;
|
|
||||||
if (CD_Mode==stPlay) {
|
|
||||||
cd_Time_Sec=HexInc(cd_Time_Sec);
|
|
||||||
if (cd_Time_Sec==0x60) {
|
|
||||||
cd_Time_Sec = 0;
|
|
||||||
cd_Time_Min=HexInc(cd_Time_Min);
|
|
||||||
if (cd_Time_Min==0xA0) {
|
|
||||||
cd_Time_Min=0x0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Event |= EV_STATUS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
+1168
File diff suppressed because it is too large
Load Diff
+124
@@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
AVCLAN-Mockingboard
|
||||||
|
Copyright (C) 2015 Allen Hill <allenofthehills@gmail.com>
|
||||||
|
|
||||||
|
Portions of the following source code are based on code that is
|
||||||
|
copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>
|
||||||
|
copyright (C) 2007 Louis Frigon
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __AVCLANDRV_H
|
||||||
|
#define __AVCLANDRV_H
|
||||||
|
|
||||||
|
// AVC LAN bus on AC2 (PA6/7)
|
||||||
|
// PA6 AINP0 +
|
||||||
|
// PA7 AINN1 -
|
||||||
|
#define BUS_IS_IDLE (bit_is_clear(AC2_STATUS, AC_STATE_bp))
|
||||||
|
|
||||||
|
#define sbi(port, bit) (port) |= (1 << (bit)) // Set bit (i.e. to 1)
|
||||||
|
#define cbi(port, bit) (port) &= ~(1 << (bit)) // Clear bit (i.e. set bit to 0)
|
||||||
|
|
||||||
|
#define STOPEvent \
|
||||||
|
cbi(RTC.PITINTCTRL, RTC_PI_bp); \
|
||||||
|
cbi(USART0.CTRLA, USART_RXCIE_bp);
|
||||||
|
#define STARTEvent \
|
||||||
|
sbi(RTC.PITINTCTRL, RTC_PI_bp); \
|
||||||
|
sbi(USART0.CTRLA, USART_RXCIE_bp);
|
||||||
|
|
||||||
|
#define CHECK_AVC_LINE \
|
||||||
|
if (!BUS_IS_IDLE) \
|
||||||
|
AVCLAN_readframe();
|
||||||
|
|
||||||
|
#define MAXMSGLEN 32
|
||||||
|
|
||||||
|
extern uint16_t CD_ID; // CD Changer ID
|
||||||
|
extern uint16_t HU_ID; // Head-unit ID
|
||||||
|
|
||||||
|
extern uint8_t printAllFrames;
|
||||||
|
extern uint8_t verbose;
|
||||||
|
extern uint8_t printBinary;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
cm_Null = 0,
|
||||||
|
cm_Status1 = 1,
|
||||||
|
cm_Status2 = 2,
|
||||||
|
cm_Status3 = 3,
|
||||||
|
cm_Status4 = 4,
|
||||||
|
cm_PlayReq1 = 5,
|
||||||
|
cm_PlayReq2 = 6,
|
||||||
|
cm_PlayReq3 = 7,
|
||||||
|
cm_StopReq = 8,
|
||||||
|
cm_StopReq2 = 9,
|
||||||
|
cm_Register = 100,
|
||||||
|
cm_Init = 101,
|
||||||
|
cm_Check = 102,
|
||||||
|
cm_PlayIt = 103,
|
||||||
|
cm_Beep = 110,
|
||||||
|
cm_NextTrack = 120,
|
||||||
|
cm_PrevTrack = 121,
|
||||||
|
cm_NextDisc = 122,
|
||||||
|
cm_PrevDisc = 123,
|
||||||
|
cm_ScanModeOn = 130,
|
||||||
|
cm_ScanModeOff = 131,
|
||||||
|
} commands;
|
||||||
|
|
||||||
|
typedef enum { stStop = 0, stPlay = 1 } cd_modes;
|
||||||
|
extern cd_modes CD_Mode;
|
||||||
|
|
||||||
|
typedef enum MSG_TYPE { BROADCAST = 0, UNICAST = 1 } MSG_TYPE_t;
|
||||||
|
|
||||||
|
typedef struct AVCLAN_KnownMessage_struct {
|
||||||
|
MSG_TYPE_t broadcast;
|
||||||
|
uint8_t length;
|
||||||
|
uint8_t data[11];
|
||||||
|
} AVCLAN_KnownMessage_t;
|
||||||
|
|
||||||
|
typedef struct AVCLAN_frame_struct {
|
||||||
|
uint8_t valid;
|
||||||
|
MSG_TYPE_t broadcast; // 0 for broadcast messages
|
||||||
|
uint16_t controller_addr; // formerly "master"
|
||||||
|
uint16_t peripheral_addr; // formerly "slave"
|
||||||
|
uint8_t control;
|
||||||
|
uint8_t length;
|
||||||
|
uint8_t *data;
|
||||||
|
} AVCLAN_frame_t;
|
||||||
|
|
||||||
|
uint8_t AVCLAN_readframe();
|
||||||
|
uint8_t AVCLAN_sendframe(const AVCLAN_frame_t *frame);
|
||||||
|
void AVCLAN_printframe(const AVCLAN_frame_t *frame, uint8_t binary);
|
||||||
|
AVCLAN_frame_t *AVCLAN_parseframe(const uint8_t *bytes, uint8_t len);
|
||||||
|
|
||||||
|
void AVCLAN_init();
|
||||||
|
void AVCLan_Send_Status();
|
||||||
|
void AVCLan_Register();
|
||||||
|
uint8_t AVCLan_SendAnswer();
|
||||||
|
|
||||||
|
extern uint8_t cd_Track;
|
||||||
|
extern uint8_t cd_Time_Min;
|
||||||
|
extern uint8_t cd_Time_Sec;
|
||||||
|
|
||||||
|
extern uint8_t playMode;
|
||||||
|
|
||||||
|
extern uint8_t answerReq;
|
||||||
|
|
||||||
|
#ifdef SOFTWARE_DEBUG
|
||||||
|
void AVCLan_Measure();
|
||||||
|
#endif
|
||||||
|
#ifdef HARDWARE_DEBUG
|
||||||
|
void SetHighLow();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // __AVCLANDRV_H
|
||||||
+148
@@ -0,0 +1,148 @@
|
|||||||
|
/*
|
||||||
|
AVCLAN-Mockingboard
|
||||||
|
Copyright (C) 2015 Allen Hill <allenofthehills@gmail.com>
|
||||||
|
|
||||||
|
Portions of the following source code are based on code that is
|
||||||
|
copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>
|
||||||
|
copyright (C) 2007 Louis Frigon
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/sfr_defs.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "com232.h"
|
||||||
|
#include "timing.h"
|
||||||
|
|
||||||
|
#if USART_RXMODE == USART_RXMODE_CLK2X_gc
|
||||||
|
#define RXMODE_S 8
|
||||||
|
#elif USART_RXMODE == USART_RXMODE_NORMAL_gc
|
||||||
|
#define RXMODE_S 16
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define USART_BAUD_RATE(BAUD_RATE) \
|
||||||
|
(uint16_t)((float)(F_CPU * 64 / (RXMODE_S * (float)BAUD_RATE)) + 0.5)
|
||||||
|
|
||||||
|
uint8_t RS232_RxCharBuffer[25], RS232_RxCharBegin, RS232_RxCharEnd;
|
||||||
|
uint8_t readkey;
|
||||||
|
|
||||||
|
void RS232_Init(void) {
|
||||||
|
RS232_RxCharBegin = RS232_RxCharEnd = 0;
|
||||||
|
|
||||||
|
PORTMUX.CTRLB = PORTMUX_USART0_ALTERNATE_gc; // Use PA1/PA2 for TxD/RxD
|
||||||
|
|
||||||
|
PORTA.DIRSET = PIN1_bm;
|
||||||
|
PORTA.DIRCLR = PIN2_bm;
|
||||||
|
|
||||||
|
USART0.CTRLA = USART_RXCIE_bm; // Enable receive interrupts
|
||||||
|
USART0.CTRLB = USART_RXEN_bm | USART_TXEN_bm | // Enable Rx/Tx and set receive
|
||||||
|
USART_RXMODE; // mode
|
||||||
|
USART0.CTRLC = USART_CMODE_ASYNCHRONOUS_gc | USART_PMODE_DISABLED_gc |
|
||||||
|
USART_CHSIZE_8BIT_gc |
|
||||||
|
USART_SBMODE_1BIT_gc; // Async UART with 8N1 config
|
||||||
|
USART0.BAUD = USART_BAUD_RATE(500000);
|
||||||
|
}
|
||||||
|
|
||||||
|
ISR(USART0_RXC_vect) {
|
||||||
|
// Store received character to the End of Buffer
|
||||||
|
RS232_RxCharBuffer[RS232_RxCharEnd] = USART0_RXDATAL;
|
||||||
|
RS232_RxCharEnd++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RS232_SendByte(uint8_t Data) {
|
||||||
|
loop_until_bit_is_set(USART0_STATUS,
|
||||||
|
USART_DREIF_bp); // wait for UART to become available
|
||||||
|
USART0_TXDATAL = Data; // send character
|
||||||
|
}
|
||||||
|
|
||||||
|
void RS232_sendbytes(const uint8_t *bytes, uint8_t len) {
|
||||||
|
const uint8_t *end = bytes + len;
|
||||||
|
while (bytes < end) {
|
||||||
|
RS232_SendByte(*bytes++);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RS232_Print(const char *pBuf) {
|
||||||
|
register uint8_t c;
|
||||||
|
while ((c = *pBuf++)) {
|
||||||
|
if (c == '\n')
|
||||||
|
RS232_SendByte('\r');
|
||||||
|
RS232_SendByte(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RS232_PrintHex4(uint8_t Data) {
|
||||||
|
uint8_t Character = Data & 0x0f;
|
||||||
|
Character += '0';
|
||||||
|
if (Character > '9')
|
||||||
|
Character += 'A' - '0' - 10;
|
||||||
|
RS232_SendByte(Character);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RS232_PrintHex8(uint8_t Data) {
|
||||||
|
RS232_PrintHex4(Data >> 4);
|
||||||
|
RS232_PrintHex4(Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RS232_PrintHex12(uint16_t x) {
|
||||||
|
RS232_PrintHex4(*(((uint8_t *)&x) + 1));
|
||||||
|
RS232_PrintHex8(*(((uint8_t *)&x) + 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void RS232_PrintDec(uint8_t Data) {
|
||||||
|
if (Data > 99) {
|
||||||
|
RS232_SendByte('*');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (Data < 10) {
|
||||||
|
RS232_SendByte('0' + Data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint8_t c;
|
||||||
|
unsigned short v, v1;
|
||||||
|
v = Data;
|
||||||
|
v1 = v / 10;
|
||||||
|
c = '0' + (v - v1 * 10);
|
||||||
|
RS232_SendByte('0' + v1);
|
||||||
|
RS232_SendByte(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RS232_PrintDec2(uint8_t Data) {
|
||||||
|
if (Data < 10)
|
||||||
|
RS232_SendByte('0');
|
||||||
|
RS232_PrintDec(Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *itoa(int i, char b[]) {
|
||||||
|
char const digit[] = "0123456789";
|
||||||
|
char *p = b;
|
||||||
|
if (i < 0) {
|
||||||
|
*p++ = '-';
|
||||||
|
i *= -1;
|
||||||
|
}
|
||||||
|
int shifter = i;
|
||||||
|
do { // Move to where representation ends
|
||||||
|
++p;
|
||||||
|
shifter = shifter / 10;
|
||||||
|
} while (shifter);
|
||||||
|
*p = '\0';
|
||||||
|
do { // Move back, inserting digits as u go
|
||||||
|
*--p = digit[i % 10];
|
||||||
|
i = i / 10;
|
||||||
|
} while (i);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
AVCLAN-Mockingboard
|
||||||
|
Copyright (C) 2015 Allen Hill <allenofthehills@gmail.com>
|
||||||
|
|
||||||
|
Portions of the following source code are based on code that is
|
||||||
|
copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>
|
||||||
|
copyright (C) 2007 Louis Frigon
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COM232_H
|
||||||
|
#define __COM232_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
extern uint8_t RS232_RxCharBuffer[25], RS232_RxCharBegin, RS232_RxCharEnd;
|
||||||
|
extern uint8_t readkey;
|
||||||
|
|
||||||
|
void RS232_Init(void);
|
||||||
|
void RS232_Print_P(const char *str_addr);
|
||||||
|
void RS232_SendByte(uint8_t Data);
|
||||||
|
void RS232_sendbytes(const uint8_t *bytes, uint8_t len);
|
||||||
|
void RS232_Print(const char *pBuf);
|
||||||
|
void RS232_PrintHex4(uint8_t Data);
|
||||||
|
void RS232_PrintHex8(uint8_t Data);
|
||||||
|
void RS232_PrintHex12(uint16_t x);
|
||||||
|
void RS232_PrintDec(uint8_t Data);
|
||||||
|
void RS232_PrintDec2(uint8_t Data);
|
||||||
|
|
||||||
|
#endif // __COM232_H
|
||||||
+340
@@ -0,0 +1,340 @@
|
|||||||
|
/*
|
||||||
|
AVCLAN-Mockingboard
|
||||||
|
Copyright (C) 2015 Allen Hill <allenofthehills@gmail.com>
|
||||||
|
|
||||||
|
Portions of the following source code are based on code that is
|
||||||
|
copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>
|
||||||
|
copyright (C) 2007 Louis Frigon
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/sfr_defs.h>
|
||||||
|
#include <avr/xmega.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "avclandrv.h"
|
||||||
|
#include "com232.h"
|
||||||
|
|
||||||
|
#define EV_NOTHING 0
|
||||||
|
#define EV_STATUS 4
|
||||||
|
|
||||||
|
uint8_t Event;
|
||||||
|
uint8_t echoCharacters;
|
||||||
|
uint8_t readBinary;
|
||||||
|
|
||||||
|
const char const *offon[] = {"OFF", "ON"};
|
||||||
|
|
||||||
|
void Setup();
|
||||||
|
void general_GPIO_init();
|
||||||
|
void print_help();
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
uint8_t readSeq = 0;
|
||||||
|
uint8_t s_len = 0;
|
||||||
|
uint8_t s_dig = 0;
|
||||||
|
uint8_t s_c[2];
|
||||||
|
uint8_t i;
|
||||||
|
uint8_t data_tmp[MAXMSGLEN];
|
||||||
|
AVCLAN_frame_t msg = {
|
||||||
|
.broadcast = UNICAST,
|
||||||
|
.controller_addr = CD_ID,
|
||||||
|
.control = 0xF,
|
||||||
|
.data = data_tmp,
|
||||||
|
};
|
||||||
|
|
||||||
|
Setup();
|
||||||
|
print_help();
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
|
||||||
|
if (!BUS_IS_IDLE) {
|
||||||
|
AVCLAN_readframe();
|
||||||
|
} else {
|
||||||
|
// check command from HU
|
||||||
|
if (answerReq != 0)
|
||||||
|
AVCLan_SendAnswer();
|
||||||
|
}
|
||||||
|
|
||||||
|
// HandleEvent
|
||||||
|
switch (Event) {
|
||||||
|
case EV_STATUS:
|
||||||
|
Event &= ~EV_STATUS;
|
||||||
|
AVCLan_Send_Status();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Key handler
|
||||||
|
if (RS232_RxCharEnd) {
|
||||||
|
cli();
|
||||||
|
readkey = RS232_RxCharBuffer[RS232_RxCharBegin];
|
||||||
|
RS232_RxCharBegin++;
|
||||||
|
if (RS232_RxCharBegin == RS232_RxCharEnd) // if buffer is consumed
|
||||||
|
RS232_RxCharBegin = RS232_RxCharEnd = 0; // reset buffer
|
||||||
|
sei();
|
||||||
|
switch (readkey) {
|
||||||
|
case '?':
|
||||||
|
print_help();
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
verbose ^= 1;
|
||||||
|
RS232_Print("Verbose: ");
|
||||||
|
RS232_Print(offon[verbose]);
|
||||||
|
RS232_Print("\n");
|
||||||
|
break;
|
||||||
|
case 'X':
|
||||||
|
printBinary = 1;
|
||||||
|
RS232_Print("Binary: ");
|
||||||
|
RS232_Print(offon[1]);
|
||||||
|
RS232_Print("\n");
|
||||||
|
break;
|
||||||
|
case 'x':
|
||||||
|
printBinary = 0;
|
||||||
|
RS232_Print("Binary: ");
|
||||||
|
RS232_Print(offon[0]);
|
||||||
|
RS232_Print("\n");
|
||||||
|
break;
|
||||||
|
case 'S': // Read sequence
|
||||||
|
printAllFrames = 0;
|
||||||
|
RS232_Print("READ SEQUENCE > \n");
|
||||||
|
readSeq = 1;
|
||||||
|
s_len = 0;
|
||||||
|
s_dig = 0;
|
||||||
|
s_c[0] = s_c[1] = 0;
|
||||||
|
break;
|
||||||
|
case 'W': // Send command
|
||||||
|
printAllFrames = 1;
|
||||||
|
readSeq = 0;
|
||||||
|
msg.broadcast = UNICAST;
|
||||||
|
msg.length = s_len;
|
||||||
|
AVCLAN_sendframe(&msg);
|
||||||
|
break;
|
||||||
|
case 'Q': // Send broadcast
|
||||||
|
printAllFrames = 1;
|
||||||
|
readSeq = 0;
|
||||||
|
msg.broadcast = BROADCAST;
|
||||||
|
msg.peripheral_addr = 0x1FF;
|
||||||
|
msg.length = s_len;
|
||||||
|
AVCLAN_sendframe(&msg);
|
||||||
|
msg.peripheral_addr = HU_ID;
|
||||||
|
break;
|
||||||
|
case 'R': // Register and wait for a response
|
||||||
|
RS232_Print("REGIST:\n");
|
||||||
|
AVCLan_Register();
|
||||||
|
TCB1.CNT = 0;
|
||||||
|
while (TCB1.CNT < 540) {}
|
||||||
|
CHECK_AVC_LINE;
|
||||||
|
break;
|
||||||
|
case 'r': // Register into the abyss
|
||||||
|
AVCLan_Register();
|
||||||
|
break;
|
||||||
|
case 'l': // Print received messages
|
||||||
|
printAllFrames ^= 1;
|
||||||
|
RS232_Print("Logging: ");
|
||||||
|
RS232_Print(offon[printAllFrames]);
|
||||||
|
RS232_Print("\n");
|
||||||
|
break;
|
||||||
|
case 'k': // Echo input
|
||||||
|
echoCharacters ^= 1;
|
||||||
|
RS232_Print("Echo characters: ");
|
||||||
|
RS232_Print(offon[echoCharacters]);
|
||||||
|
RS232_Print("\n");
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
case 'B': // Beep
|
||||||
|
answerReq = cm_Beep;
|
||||||
|
AVCLan_SendAnswer();
|
||||||
|
break;
|
||||||
|
case 'e': // Beep
|
||||||
|
data_tmp[0] = 0x00;
|
||||||
|
data_tmp[1] = 0x01;
|
||||||
|
data_tmp[2] = 0x11;
|
||||||
|
data_tmp[3] = 0x50;
|
||||||
|
data_tmp[4] = 0x63;
|
||||||
|
msg.length = 5;
|
||||||
|
msg.broadcast = UNICAST;
|
||||||
|
msg.controller_addr = CD_ID;
|
||||||
|
msg.peripheral_addr = HU_ID;
|
||||||
|
AVCLAN_sendframe(&msg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifdef SOFTWARE_DEBUG
|
||||||
|
case 'M':
|
||||||
|
AVCLan_Measure();
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case 0x10: // Signals binary sequence incoming
|
||||||
|
if (!readSeq && !readBinary) {
|
||||||
|
readSeq = 1;
|
||||||
|
readBinary = 1;
|
||||||
|
s_len = 0;
|
||||||
|
break;
|
||||||
|
} // else (readSeq || readBinary); fall through to default
|
||||||
|
case '\n':
|
||||||
|
if (readSeq && readBinary && data_tmp[s_len] == 0x17) {
|
||||||
|
s_len--;
|
||||||
|
AVCLAN_frame_t *frame = AVCLAN_parseframe(data_tmp, s_len);
|
||||||
|
if (frame) {
|
||||||
|
AVCLAN_sendframe(frame);
|
||||||
|
free(frame);
|
||||||
|
readSeq = 0;
|
||||||
|
readBinary = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} // else (readSeq || readBinary || most recent char != 0x17);
|
||||||
|
// fall through to default
|
||||||
|
default:
|
||||||
|
if (readSeq) {
|
||||||
|
if (readBinary) {
|
||||||
|
data_tmp[s_len++] = readkey;
|
||||||
|
} else {
|
||||||
|
s_c[s_dig] = readkey;
|
||||||
|
|
||||||
|
s_dig++;
|
||||||
|
if (s_dig == 2) {
|
||||||
|
if (s_c[0] < ':')
|
||||||
|
s_c[0] -= 48;
|
||||||
|
else
|
||||||
|
s_c[0] -= 55;
|
||||||
|
data_tmp[s_len] = 16 * s_c[0];
|
||||||
|
if (s_c[1] < ':')
|
||||||
|
s_c[1] -= 48;
|
||||||
|
else
|
||||||
|
s_c[1] -= 55;
|
||||||
|
data_tmp[s_len] += s_c[1];
|
||||||
|
s_len++;
|
||||||
|
s_dig = 0;
|
||||||
|
s_c[0] = s_c[1] = 0;
|
||||||
|
}
|
||||||
|
if (echoCharacters) {
|
||||||
|
RS232_Print("CURRENT SEQUENCE > ");
|
||||||
|
for (i = 0; i < s_len; i++) {
|
||||||
|
RS232_PrintHex8(data_tmp[i]);
|
||||||
|
RS232_SendByte(' ');
|
||||||
|
}
|
||||||
|
RS232_Print("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // switch (readkey)
|
||||||
|
} // if (RS232_RxCharEnd)
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Setup() {
|
||||||
|
CD_ID = 0x360;
|
||||||
|
HU_ID = 0x190;
|
||||||
|
|
||||||
|
printAllFrames = 1;
|
||||||
|
echoCharacters = 1;
|
||||||
|
readBinary = 0;
|
||||||
|
printBinary = 0;
|
||||||
|
|
||||||
|
_PROTECTED_WRITE(CLKCTRL.MCLKCTRLB, (CLK_PRESCALE | CLK_PRESCALE_DIV));
|
||||||
|
|
||||||
|
general_GPIO_init();
|
||||||
|
|
||||||
|
// Setup RTC as 1 sec periodic timer
|
||||||
|
loop_until_bit_is_clear(RTC_STATUS, RTC_CTRLABUSY_bp);
|
||||||
|
RTC.CTRLA = RTC_PRESCALER_DIV1_gc;
|
||||||
|
RTC.CLKSEL = RTC_CLKSEL_INT32K_gc;
|
||||||
|
RTC.PITINTCTRL = RTC_PI_bm;
|
||||||
|
loop_until_bit_is_clear(RTC_PITSTATUS, RTC_CTRLBUSY_bp);
|
||||||
|
RTC.PITCTRLA = RTC_PERIOD_CYC32768_gc | RTC_PITEN_bm;
|
||||||
|
|
||||||
|
RS232_Init();
|
||||||
|
|
||||||
|
AVCLAN_init();
|
||||||
|
|
||||||
|
Event = EV_NOTHING;
|
||||||
|
sei();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Configure pin settings which are not configured by peripherals */
|
||||||
|
void general_GPIO_init() {
|
||||||
|
// Set pins PC2-3, PB0,3-5 as inputs
|
||||||
|
PORTC.DIRCLR = (PIN2_bm | // Unconnected
|
||||||
|
PIN3_bm); // CTS
|
||||||
|
PORTB.DIRCLR = (PIN0_bm | // Unconnected
|
||||||
|
PIN3_bm | // IGN_SENSE
|
||||||
|
PIN4_bm | // Unused, but connected to WOC (PC0)
|
||||||
|
PIN5_bm); // Unused, but connected to WOD (PC1)
|
||||||
|
|
||||||
|
// Enable pull-up resistor and disable input buffer (reduces any EM caused pin
|
||||||
|
// toggling and saves power) for unused and unconnected pins
|
||||||
|
PORTC.PIN2CTRL = PORT_PULLUPEN_bm | PORT_ISC_INPUT_DISABLE_gc;
|
||||||
|
PORTB.PIN0CTRL = PORT_PULLUPEN_bm | PORT_ISC_INPUT_DISABLE_gc;
|
||||||
|
|
||||||
|
// Output only pins: PA3-5, PB1-2,4-5; PC0-1
|
||||||
|
// TODO: TxD (PA1), RTS (PA3) is output only, test if RxD needs the input
|
||||||
|
// buffer or if the UART peripheral bypasses it
|
||||||
|
PORTA.PIN3CTRL = PORT_ISC_INPUT_DISABLE_gc; // RTS
|
||||||
|
PORTA.PIN4CTRL = PORT_ISC_INPUT_DISABLE_gc; // WOA
|
||||||
|
PORTA.PIN5CTRL = PORT_ISC_INPUT_DISABLE_gc; // WOB
|
||||||
|
PORTB.PIN1CTRL = PORT_ISC_INPUT_DISABLE_gc; // MIC_CONTROL
|
||||||
|
PORTB.PIN4CTRL = PORT_ISC_INPUT_DISABLE_gc; // non-driving WOC
|
||||||
|
PORTB.PIN5CTRL = PORT_ISC_INPUT_DISABLE_gc; // non-driving WOD
|
||||||
|
PORTC.PIN0CTRL = PORT_ISC_INPUT_DISABLE_gc; // WOC
|
||||||
|
PORTC.PIN1CTRL = PORT_ISC_INPUT_DISABLE_gc; // WOD
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_help() {
|
||||||
|
RS232_Print("AVCLAN Mockingboard v1\n");
|
||||||
|
RS232_Print("S - read sequence\n"
|
||||||
|
"W - send command\n"
|
||||||
|
"Q - send broadcast\n"
|
||||||
|
"l - Toggle message logging\n"
|
||||||
|
"k - Toggle character echo\n"
|
||||||
|
"R/r - register device\n"
|
||||||
|
"B - Beep\n"
|
||||||
|
"v - Toggle verbose logging\n"
|
||||||
|
#ifdef SOFTWARE_DEBUG
|
||||||
|
"M - Measure bit-timing (pulse-widths and periods)\n"
|
||||||
|
#endif
|
||||||
|
#ifdef HARDWARE_DEBUG
|
||||||
|
"1 - Hold High/low\n"
|
||||||
|
"E - Print line status\n"
|
||||||
|
#endif
|
||||||
|
"? - Print this message\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Increment packed 2-digit BCD number.
|
||||||
|
WARNING: Overflow behavior is incorrect (e.g. `incBCD(0x99) != 0x00`) */
|
||||||
|
uint8_t incBCD(uint8_t data) {
|
||||||
|
if ((data & 0x9) == 0x9)
|
||||||
|
return (data + 7);
|
||||||
|
|
||||||
|
return (data + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Periodic interrupt with a 1 sec period
|
||||||
|
ISR(RTC_PIT_vect) {
|
||||||
|
if (CD_Mode == stPlay) {
|
||||||
|
cd_Time_Sec = incBCD(cd_Time_Sec);
|
||||||
|
if (cd_Time_Sec == 0x60) {
|
||||||
|
cd_Time_Sec = 0;
|
||||||
|
cd_Time_Min = incBCD(cd_Time_Min);
|
||||||
|
if (cd_Time_Min == 0xA0) {
|
||||||
|
cd_Time_Min = 0x0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Event |= EV_STATUS;
|
||||||
|
RTC.PITINTFLAGS |= RTC_PI_bm;
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
#ifndef _TIMING_HPP_
|
||||||
|
#define _TIMING_HPP_
|
||||||
|
|
||||||
|
#define __CLKCTRL_PDIV_2X_gc 2
|
||||||
|
#define __CLKCTRL_PDIV_4X_gc 4
|
||||||
|
#define __CLKCTRL_PDIV_8X_gc 8
|
||||||
|
#define __CLKCTRL_PDIV_16X_gc 16
|
||||||
|
#define __CLKCTRL_PDIV_32X_gc 32
|
||||||
|
#define __CLKCTRL_PDIV_64X_gc 64
|
||||||
|
#define __CLKCTRL_PDIV_6X_gc 6
|
||||||
|
#define __CLKCTRL_PDIV_10X_gc 10
|
||||||
|
#define __CLKCTRL_PDIV_12X_gc 12
|
||||||
|
#define __CLKCTRL_PDIV_24X_gc 24
|
||||||
|
#define __CLKCTRL_PDIV_48X_gc 48
|
||||||
|
|
||||||
|
#if CLK_PRESCALE == 0x01
|
||||||
|
#define F_CPU (FREQSEL / __CLK_PRESCALE_DIV)
|
||||||
|
#define CYCLE_MUL __CLK_PRESCALE_DIV
|
||||||
|
#else
|
||||||
|
#define F_CPU (FREQSEL)
|
||||||
|
#define CYCLE_MUL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if FREQSEL == 20000000L
|
||||||
|
#define CPU_CYCLE (50 * CYCLE_MUL)
|
||||||
|
#elif FREQSEL == 16000000L
|
||||||
|
#define CPU_CYCLE (62.5 * CYCLE_MUL)
|
||||||
|
#else
|
||||||
|
#error "Not implemented"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TCB_CLKSEL_CLKDIV1_gc
|
||||||
|
#define TCB_CLKSEL_CLKDIV1_gc (0x00 << 1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TCB_CLKSEL_CLKDIV2_gc
|
||||||
|
#define TCB_CLKSEL_CLKDIV2_gc (0x01 << 1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TCB_CLKSEL_CLKTCA_gc
|
||||||
|
#define TCB_CLKSEL_CLKTCA_gc (0x02 << 1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if TCB_CLKSEL == TCB_CLKSEL_CLKDIV1_gc
|
||||||
|
#define TCB_TICK (CPU_CYCLE)
|
||||||
|
#elif TCB_CLKSEL == TCB_CLKSEL_CLKDIV2_gc
|
||||||
|
#define TCB_TICK (CPU_CYCLE * 2)
|
||||||
|
#elif TCB_CLKSEL == TCB_CLKSEL_CLKTCA_gc
|
||||||
|
#error "Not implemented"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Measured at ±0.02 μs @ F_CPU=20MHz, TCB_CLKSEL=TCB_CLKSEL_CLKDIV1_gc
|
||||||
|
#define AVCLAN_STARTBIT_LOGIC_0 (169e3 / TCB_TICK)
|
||||||
|
#define AVCLAN_STARTBIT_LOGIC_1 (20.6e3 / TCB_TICK)
|
||||||
|
|
||||||
|
#define AVCLAN_BIT1_LOGIC_0 (19.7e3 / TCB_TICK)
|
||||||
|
#define AVCLAN_BIT1_LOGIC_1 (18.1e3 / TCB_TICK)
|
||||||
|
|
||||||
|
#define AVCLAN_BIT0_LOGIC_0 (32.85e3 / TCB_TICK)
|
||||||
|
#define AVCLAN_BIT0_LOGIC_1 (6.2e3 / TCB_TICK)
|
||||||
|
|
||||||
|
#define AVCLAN_READBIT_THRESHOLD (26e3 / TCB_TICK)
|
||||||
|
|
||||||
|
#define AVCLAN_BIT_LENGTH_MAX (39.1e3 / TCB_TICK)
|
||||||
|
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
-16784
File diff suppressed because it is too large
Load Diff
Vendored
+22
@@ -0,0 +1,22 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2015 jnk0le
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
Vendored
+80
@@ -0,0 +1,80 @@
|
|||||||
|
# AVR-UART-lib
|
||||||
|
An interrupt-driven USART (RS232) library for AVR microcontrollers, with support for multiple hardware UARTs, using ring
|
||||||
|
buffers for receive/transmit. Designed especially for real-time or high throughput applications, with narrow resource limits.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
- selectable support for up to 4 USART's
|
||||||
|
- up to 255 byte FIFOs
|
||||||
|
- only 2 (+1 wasted slot) byte memory footprint except actual buffer for every implemented RX or TX path
|
||||||
|
- no dynamic memory allocations
|
||||||
|
- extremly light interrupts
|
||||||
|
- software(RTS/CTS) and hardware flow control support (DCE naming)
|
||||||
|
- RS 485 compatibility
|
||||||
|
- MPCM master and slave mode support
|
||||||
|
- printf()/scanf() streams compatibility
|
||||||
|
- V-USB compatibility (25 cycle ISR restriction)
|
||||||
|
- optimized as much as possible to reduce code size and execution times
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
- Lot of terminals sends only CR character as a newline terminator, instead of CRLF or even unix style LF
|
||||||
|
(BTW PuTTY doesn't allow to change this) but in return requires CRLF terminator to show not broken text.
|
||||||
|
This behaviour can be covered by RX_NEWLINE_MODE macro, by default set to CRLF.
|
||||||
|
|
||||||
|
- 0 - CR
|
||||||
|
- 1 - LF
|
||||||
|
- 2 - CRLF (default)
|
||||||
|
|
||||||
|
- In order to reinitialize uart baudrate after any traffic was occurring, function uart_reinit() have to be used. (memory FIFO buffers will not be flushed)
|
||||||
|
|
||||||
|
- Any used IO pin have to be accessible from bottom IO address space. (eg. few ports on mega2560 cannot be used as a control IO)
|
||||||
|
|
||||||
|
- In half duplex (RS485) transmission modes, the application code is responsible of starting transmission only when bus is idle.
|
||||||
|
If RE and DE are shorted together additional pullup on RX pin is required.
|
||||||
|
Pin used as a RS485 control line have to be kept in low state during boot process via a pulldown resistor or at least not driving it high even by an internall pull-up. (especially on multi node buses)
|
||||||
|
|
||||||
|
- In MPCM mode first received byte is address by which device was called (own or general call), application is also responsible of restoring into "idle listening" state withing described bus silence time after receiving entire packet.
|
||||||
|
|
||||||
|
- uart_putc() function is not thread/interrupt-safe nor reentrant. It shouldn't be called from within atomic blocks or interrupt handlers since it re-enables interrupt flag on exit or even hangs in infinite loop waiting for execution of UDRE interrupt.
|
||||||
|
|
||||||
|
- this library is written in c99/gnu99 dialect standard.
|
||||||
|
|
||||||
|
## Flow control
|
||||||
|
|
||||||
|
This library provides a software implementation of CTS/RTS control lines (DTR/DSR respectively) to signal whether buffer is full (not an 80' style handshaking).
|
||||||
|
It should be used, in order to achieve stable bidirectional >100kbps transmissions, especially when using non deterministic usb-serial converters (ft232, ch340 etc).
|
||||||
|
The legendary "noise" that causes losing blocks of characters (not damaging) can also be fixed by that.
|
||||||
|
|
||||||
|
### Config
|
||||||
|
- soft CTS pins have to be configured as an input, and both edge interrupt source (INT/PCINT), before entering uart_init().
|
||||||
|
The application code should call cts_isr_handlers from interrupts corresponding to used pins. (see [example](example(flow control).c))
|
||||||
|
If CTS line goes high during transmission (before UDRE interrupt is fired), only one additional byte will be transmitted. (due to 2 level transmit register)
|
||||||
|
|
||||||
|
- soft RTS pins have to be configured as input without pullup or output in low state, before entering uart_init().
|
||||||
|
If interrupts are not missed, the receiver can accept up to 2 additional bytes after buffer is filled, one from next or ongoing transmission
|
||||||
|
and another one if transmitter misses RTS signal (last one is stored in shift register).
|
||||||
|
|
||||||
|
- Any used IO pin have to be accessible from bottom IO address space. (eg. few ports on mega2560 cannot be used as a flow control IO)
|
||||||
|
|
||||||
|
- For proper operation of hardware RTS, USART_EXTEND_RX_BUFFER have to be defined.
|
||||||
|
|
||||||
|
## ISR timmings (cycles)
|
||||||
|
|
||||||
|
| ISR case | attiny2313 | atmega8 | atmega328 | atmega2560 | lgt8f88A |
|
||||||
|
| --- | --- | --- | --- | --- | --- |
|
||||||
|
| **TX best** | 37 | 40 | 40 | 42 | 30 |
|
||||||
|
| **TX worst** | 38 | 41 | 44 | 46 | 35 |
|
||||||
|
| **RX best** | 36 | 36 | 37 | 39 | 27 |
|
||||||
|
| **RX worst** | 40 | 42 | 43 | 45 | 32 |
|
||||||
|
| **RX rts full** | 41 | 41 | 44 | 46 | 32 |
|
||||||
|
| **RX rts normal** | 40 | 42 | 43 | 45 | 32 |
|
||||||
|
| **BUFFER_SIZE = 256** | x | -1 | -1 | -1 | -1 |
|
||||||
|
| **G_SREG_SAVE** | -4 | -4 | -4 | -4 | -2 |
|
||||||
|
| **G_Z_SAVE** | -6 | -6 | -6 | -6 | -2 |
|
||||||
|
|
||||||
|
- TX best case - send byte from buffer
|
||||||
|
- TX worst case - send byte from buffer and disable UDRIE interrupt (will not generate double shot)
|
||||||
|
- RX best case - load byte and do nothing (buffer full)
|
||||||
|
- RX worst case - load byte and put it into buffer
|
||||||
|
- RX rts full - rise RTS line and disable RXCIE interrupt
|
||||||
|
- RX rts normal - load byte and put it into buffer if there is available space
|
||||||
|
|
||||||
Vendored
+6239
File diff suppressed because it is too large
Load Diff
Vendored
+3063
File diff suppressed because it is too large
Load Diff
+431
@@ -0,0 +1,431 @@
|
|||||||
|
/*!
|
||||||
|
* \brief
|
||||||
|
*
|
||||||
|
* \author Jan Oleksiewicz <jnk0le@hotmail.com>
|
||||||
|
* \license SPDX-License-Identifier: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef USART_CONFIG_H_
|
||||||
|
#define USART_CONFIG_H_
|
||||||
|
|
||||||
|
// DO NOT DEFINE F_CPU, BUFFERS SIZES OR ANY OTHER SHARED MACROS IN 'main.c'
|
||||||
|
// CODE instead of this, define it in makefile (-D flag) or "Project Properties
|
||||||
|
// -> AVR C Compiler -> Symbols"
|
||||||
|
|
||||||
|
// #define NO_USART_RX // disable all receiver code and dependencies
|
||||||
|
// #define NO_USART_TX // disable all transmitter code and dependencies
|
||||||
|
|
||||||
|
// globally enable MPCM operation mode
|
||||||
|
// 9 bit data frame only
|
||||||
|
// always set frame format to 8 data bits
|
||||||
|
// #define USART_MPCM_MODE
|
||||||
|
|
||||||
|
// enables double speed for all available USART interfaces
|
||||||
|
#define USE_DOUBLE_SPEED
|
||||||
|
|
||||||
|
// echoes back received characters in getchar() function (for reading in
|
||||||
|
// scanf())
|
||||||
|
#define RX_STDIO_GETCHAR_ECHO
|
||||||
|
// #define RX_GETC_ECHO // echoes back received characters in getc() function
|
||||||
|
|
||||||
|
// allow for unix style (\n only) newline terminator in stored strings
|
||||||
|
// not included into putc_noblock
|
||||||
|
// #define PUTC_CONVERT_LF_TO_CRLF
|
||||||
|
|
||||||
|
// a lot of terminals sends only \r character as a newline terminator, instead
|
||||||
|
// of \r\n or even unix style \n (BTW PuTTY doesn't allow to change this) but in
|
||||||
|
// return requires \r\n terminator to show not broken text
|
||||||
|
// 0 - \r, 1 - \n, 2 - \r\n
|
||||||
|
#define RX_NEWLINE_MODE 1
|
||||||
|
|
||||||
|
// do not use prematures that might break compilers ABI (non-gcc calling
|
||||||
|
// conventions), compilers that are not forcing constant number of call-used
|
||||||
|
// registers might generate even better code
|
||||||
|
// #define USART_NO_ABI_BREAKING_PREMATURES
|
||||||
|
|
||||||
|
// use uppercase letters in uart_puthex() function
|
||||||
|
#define USART_PUTHEX_IN_UPPERCASE
|
||||||
|
|
||||||
|
// extend RX buffer by hardware 2/3 byte FIFO
|
||||||
|
// required for hardware and software RTS
|
||||||
|
// #define USART_EXTEND_RX_BUFFER
|
||||||
|
|
||||||
|
// skip FIFO procedure and write directly
|
||||||
|
// data to the UDR register when possible
|
||||||
|
// probably required for full bus utilization at highest speed (f_cpu/8)
|
||||||
|
// #define USART_PUTC_FAST_INSERTIONS
|
||||||
|
|
||||||
|
// do not allocate temporary buffers on stack for integer/float <-> asci
|
||||||
|
// conversions and use globally visible u_tmp_buff[] instead it have to be
|
||||||
|
// declared in application part and have to be at least of 6-17 bytes wide
|
||||||
|
// (depending on what is being converted)
|
||||||
|
// #define USART_NO_LOCAL_BUFFERS
|
||||||
|
|
||||||
|
// max 19 cycles of interrupt latency
|
||||||
|
// 3+PC bytes on stack
|
||||||
|
// will not interrupt itself
|
||||||
|
// #define USART_UNSAFE_TX_INTERRUPT
|
||||||
|
|
||||||
|
// max 23 cycles of interrupt latency
|
||||||
|
// 4+PC bytes on stack
|
||||||
|
// will not interrupt itself
|
||||||
|
// #define USART_UNSAFE_RX_INTERRUPT
|
||||||
|
|
||||||
|
// remap hardware registers of USART1/2/3 to USART0 if only one interface is
|
||||||
|
// used
|
||||||
|
// #define USART_REMAP_LAST_INTERFACE
|
||||||
|
|
||||||
|
// do not generate code for writing to ubrrh if calculated value is zero
|
||||||
|
// prematures out 2 bytes if ubrr is compile time constant
|
||||||
|
// #define USART_SKIP_UBRRH_IF_ZERO
|
||||||
|
|
||||||
|
// prematures out 4 cycles from every isr run
|
||||||
|
// requires one globally reserved lower register
|
||||||
|
#define USART_USE_GLOBALLY_RESERVED_ISR_SREG_SAVE
|
||||||
|
|
||||||
|
// prematures out 6 cycles from every isr run
|
||||||
|
// requires pair of globally reserved lower registers usage of globally reserved
|
||||||
|
// register for temporary storage in interrupts, should be combined with other
|
||||||
|
// interrupts for best results. special care have to be taken when doing so,
|
||||||
|
// since those registers can still be used by other compilation units (fixable
|
||||||
|
// in gcc by -ffixed-n flag, where n is a suppressed register), precompiled
|
||||||
|
// libraries (vprintf, vscanf, qsort, strtod, strtol, strtoul), or even assembly
|
||||||
|
// hardcoded libraries (fft, aes). registers r2-r7 should be used instead of the
|
||||||
|
// higher ones, since those are never used by gcc for eg. argument passing.
|
||||||
|
#define USART_USE_GLOBALLY_RESERVED_ISR_Z_SAVE
|
||||||
|
|
||||||
|
// have to be redeclared under the same name if the same registers are reused in
|
||||||
|
// other instances (libs)
|
||||||
|
#define USART_SREG_SAVE_REG_NAME G_sreg_save
|
||||||
|
#define USART_SREG_SAVE_REG_NUM "r4"
|
||||||
|
|
||||||
|
// have to be redeclared under the same name if the same registers are reused in
|
||||||
|
// other instances (libs)
|
||||||
|
#define USART_Z_SAVE_REG_NAME G_z_save
|
||||||
|
|
||||||
|
// register pair rn and rn+1 (rn+1:rn gives "invalid register name")
|
||||||
|
#define USART_Z_SAVE_REG_NUM "r2"
|
||||||
|
|
||||||
|
// Size of the ring buffers, must be power of 2
|
||||||
|
// default 32
|
||||||
|
#define RX_BUFFER_SIZE 64
|
||||||
|
|
||||||
|
// Size of the ring buffers, must be power of 2
|
||||||
|
// default 32
|
||||||
|
#define TX_BUFFER_SIZE 128
|
||||||
|
|
||||||
|
/*******************config for multiple USART * mcu's*************************/
|
||||||
|
|
||||||
|
// #define NO_USART0 // disable usage of uart0
|
||||||
|
// #define NO_USART1 // disable usage of uart1
|
||||||
|
// #define NO_USART2 // disable usage of uart2
|
||||||
|
// #define NO_USART3 // disable usage of uart3
|
||||||
|
|
||||||
|
// #define RX0_BUFFER_SIZE 128
|
||||||
|
// #define TX0_BUFFER_SIZE 64
|
||||||
|
|
||||||
|
// #define RX1_BUFFER_SIZE 128
|
||||||
|
// #define TX1_BUFFER_SIZE 64
|
||||||
|
|
||||||
|
// #define RX2_BUFFER_SIZE 128
|
||||||
|
// #define TX2_BUFFER_SIZE 64
|
||||||
|
|
||||||
|
// #define RX3_BUFFER_SIZE 128
|
||||||
|
// #define TX3_BUFFER_SIZE 64
|
||||||
|
|
||||||
|
/****** Disable RX interrupts ******/
|
||||||
|
// removes whole receive code (including ISR) and frees RX0 pin
|
||||||
|
// combining with NO_USART_RX is not necessary
|
||||||
|
// #define NO_RX0_INTERRUPT
|
||||||
|
|
||||||
|
// removes whole receive code (including ISR) and frees RX1 pin
|
||||||
|
// #define NO_RX1_INTERRUPT
|
||||||
|
|
||||||
|
// removes whole receive code (including ISR) and frees RX2 pin
|
||||||
|
// #define NO_RX2_INTERRUPT
|
||||||
|
|
||||||
|
// removes whole receive code (including ISR) and frees RX3 pin
|
||||||
|
// #define NO_RX3_INTERRUPT
|
||||||
|
|
||||||
|
/****** Disable TX interrupts ******/
|
||||||
|
// removes whole transmit code (including ISR) and frees TX0 pin
|
||||||
|
// combining with NO_USART_TX is not necessary
|
||||||
|
// #define NO_TX0_INTERRUPT
|
||||||
|
|
||||||
|
// removes whole transmit code (including ISR) and frees TX1 pin
|
||||||
|
// #define NO_TX1_INTERRUPT
|
||||||
|
|
||||||
|
// removes whole transmit code (including ISR) and frees TX2 pin
|
||||||
|
// #define NO_TX2_INTERRUPT
|
||||||
|
|
||||||
|
// removes whole transmit code (including ISR) and frees TX3 pin
|
||||||
|
// #define NO_TX3_INTERRUPT
|
||||||
|
|
||||||
|
// #define USART0_U2X_SPEED // enables double speed for USART0
|
||||||
|
// #define USART1_U2X_SPEED // enables double speed for USART1
|
||||||
|
// #define USART2_U2X_SPEED // enables double speed for USART2
|
||||||
|
// #define USART3_U2X_SPEED // enables double speed for USART3
|
||||||
|
|
||||||
|
// #define RX0_GETC_ECHO
|
||||||
|
// #define RX1_GETC_ECHO
|
||||||
|
// #define RX2_GETC_ECHO
|
||||||
|
// #define RX3_GETC_ECHO
|
||||||
|
|
||||||
|
// #define PUTC0_CONVERT_LF_TO_CRLF
|
||||||
|
// #define PUTC1_CONVERT_LF_TO_CRLF
|
||||||
|
// #define PUTC2_CONVERT_LF_TO_CRLF
|
||||||
|
// #define PUTC3_CONVERT_LF_TO_CRLF
|
||||||
|
|
||||||
|
// #define USART0_EXTEND_RX_BUFFER
|
||||||
|
// #define USART1_EXTEND_RX_BUFFER
|
||||||
|
// #define USART2_EXTEND_RX_BUFFER
|
||||||
|
// #define USART3_EXTEND_RX_BUFFER
|
||||||
|
|
||||||
|
// #define USART0_PUTC_FAST_INSERTIONS
|
||||||
|
// #define USART1_PUTC_FAST_INSERTIONS
|
||||||
|
// #define USART2_PUTC_FAST_INSERTIONS
|
||||||
|
// #define USART3_PUTC_FAST_INSERTIONS
|
||||||
|
|
||||||
|
// #define USART0_MPCM_MODE
|
||||||
|
// #define USART1_MPCM_MODE
|
||||||
|
// #define USART2_MPCM_MODE
|
||||||
|
// #define USART3_MPCM_MODE
|
||||||
|
|
||||||
|
/***********************soft flow control * config*****************************/
|
||||||
|
// define IO instance to enable software CTS
|
||||||
|
// CTS handlers also have to be placed into INT/PCINT interrupt in the
|
||||||
|
// application code, see example(flow control).c
|
||||||
|
|
||||||
|
// #define CTS0_DDR // DDRB
|
||||||
|
// #define CTS0_PORT // PORTB
|
||||||
|
// #define CTS0_PIN // PINB
|
||||||
|
// #define CTS0_IONUM // 0 // pin number
|
||||||
|
|
||||||
|
// #define CTS1_DDR
|
||||||
|
// #define CTS1_PORT
|
||||||
|
// #define CTS1_PIN
|
||||||
|
// #define CTS1_IONUM
|
||||||
|
|
||||||
|
// #define CTS2_DDR
|
||||||
|
// #define CTS2_PORT
|
||||||
|
// #define CTS2_PIN
|
||||||
|
// #define CTS2_IONUM
|
||||||
|
|
||||||
|
// #define CTS3_DDR
|
||||||
|
// #define CTS3_PORT
|
||||||
|
// #define CTS3_PIN
|
||||||
|
// #define CTS3_IONUM
|
||||||
|
|
||||||
|
// define IO instance to enable software RTS
|
||||||
|
|
||||||
|
// #define RTS0_DDR // DDRB
|
||||||
|
// #define RTS0_PORT // PORTB
|
||||||
|
// #define RTS0_PIN // PINB
|
||||||
|
// #define RTS0_IONUM // 1 // pin number
|
||||||
|
|
||||||
|
// #define RTS1_DDR
|
||||||
|
// #define RTS1_PORT
|
||||||
|
// #define RTS1_PIN
|
||||||
|
// #define RTS1_IONUM
|
||||||
|
|
||||||
|
// #define RTS2_DDR
|
||||||
|
// #define RTS2_PORT
|
||||||
|
// #define RTS2_PIN
|
||||||
|
// #define RTS2_IONUM
|
||||||
|
|
||||||
|
// #define RTS3_DDR
|
||||||
|
// #define RTS3_PORT
|
||||||
|
// #define RTS3_PIN
|
||||||
|
// #define RTS3_IONUM
|
||||||
|
|
||||||
|
/*****************************RS 485 config***********************************/
|
||||||
|
// define IO instance to enable half duplex rs485 operation mode // used pin
|
||||||
|
// should be initially kept in low state before boot
|
||||||
|
|
||||||
|
// #define RS485_CONTROL0_DDR // DDRB
|
||||||
|
// #define RS485_CONTROL0_PORT // PORTB
|
||||||
|
// #define RS485_CONTROL0_PIN // PINB
|
||||||
|
// #define RS485_CONTROL0_IONUM // 2 // pin number
|
||||||
|
|
||||||
|
// #define RS485_CONTROL1_DDR
|
||||||
|
// #define RS485_CONTROL1_PORT
|
||||||
|
// #define RS485_CONTROL1_PIN
|
||||||
|
// #define RS485_CONTROL1_IONUM
|
||||||
|
|
||||||
|
// #define RS485_CONTROL2_DDR
|
||||||
|
// #define RS485_CONTROL2_PORT
|
||||||
|
// #define RS485_CONTROL2_PIN
|
||||||
|
// #define RS485_CONTROL2_IONUM
|
||||||
|
|
||||||
|
// #define RS485_CONTROL3_DDR
|
||||||
|
// #define RS485_CONTROL3_PORT
|
||||||
|
// #define RS485_CONTROL3_PIN
|
||||||
|
// #define RS485_CONTROL3_IONUM
|
||||||
|
|
||||||
|
/*****************************MPCM config***********************************/
|
||||||
|
|
||||||
|
#define MPCM0_ADDRESS 0x01
|
||||||
|
#define MPCM1_ADDRESS 0x02
|
||||||
|
#define MPCM2_ADDRESS 0x03
|
||||||
|
#define MPCM3_ADDRESS 0x04
|
||||||
|
|
||||||
|
// #define MPCM0_GCALL_ADDRESS 0x00
|
||||||
|
// #define MPCM1_GCALL_ADDRESS 0x00
|
||||||
|
// #define MPCM2_GCALL_ADDRESS 0x00
|
||||||
|
// #define MPCM3_GCALL_ADDRESS 0x00
|
||||||
|
|
||||||
|
// #define MPCM0_MASTER_ONLY // do not include slave code into RX ISR
|
||||||
|
// #define MPCM1_MASTER_ONLY // do not include slave code into RX ISR
|
||||||
|
// #define MPCM2_MASTER_ONLY // do not include slave code into RX ISR
|
||||||
|
// #define MPCM3_MASTER_ONLY // do not include slave code into RX ISR
|
||||||
|
|
||||||
|
// Optional macros for placing user-defined code that will be executed inside of
|
||||||
|
// USART interrupt handlers. Only inline asm and its input operand lists are
|
||||||
|
// allowed to be put here. Too large code may generate weird cryptic linker
|
||||||
|
// errors, what is caused by exceeded range of branch instructions.
|
||||||
|
// http://www.nongnu.org/avr-libc/user-manual/inline_asm.html
|
||||||
|
|
||||||
|
// example:
|
||||||
|
// #define STH_EVENT "nop \n\t"\ //
|
||||||
|
// "ldi r31, %M[A_MASK] \n\t"\ //
|
||||||
|
// "out %M[TIMADDR], r31 \n\t"
|
||||||
|
// #define OPERAND_LIST [A_MASK] "M" (0x55),\ //
|
||||||
|
// [TIMADDR] "M" (_SFR_IO_ADDR(TCCR0A)),
|
||||||
|
|
||||||
|
// code executed on every ISR call, before feeding UDR (for this racing
|
||||||
|
// implementation only), can be placed here // r30 and r31 are free to use
|
||||||
|
#define TX0_EVERYCAL_EVENT "\n\t"
|
||||||
|
|
||||||
|
// code executed on every byte transmission, can be placed here // r30 and r31
|
||||||
|
// are free to use // r30 contains currently transmitted data byte
|
||||||
|
#define TX0_TRANSMIT_EVENT "\n\t"
|
||||||
|
|
||||||
|
#define TX0_INPUT_OPERAND_LIST
|
||||||
|
|
||||||
|
#if !defined(USART0_EXTEND_RX_BUFFER) // DO NOT CHANGE
|
||||||
|
// code executed before reading UDR register can be placed here // r25 is free
|
||||||
|
// to use // executed before enabling interrupts in unsafe mode
|
||||||
|
#define RX0_FRAMING_EVENT "\n\t"
|
||||||
|
|
||||||
|
// #define USART0_PUSH_BEFORE_RX // frees r30 an r31 for FRAMING_EVENT
|
||||||
|
#else
|
||||||
|
// code executed before reading UDR register can be placed here // r25 and r31
|
||||||
|
// are free to use
|
||||||
|
#define RX0_FRAMING_EVENT "\n\t"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// code executed on every ISR call, can be placed here // r30 and r31 are free
|
||||||
|
// to use // r25 contains received data byte if 'extended buffer' mode is not
|
||||||
|
// used, free to use otherwise
|
||||||
|
#define RX0_EVERYCALL_EVENT "\n\t"
|
||||||
|
|
||||||
|
// code executed only when databyte was received, before buffer store, can be
|
||||||
|
// placed here // r31 is free to use // r25 contains received data byte, r30
|
||||||
|
// rxn_last_byte buffer index // MPCM ??
|
||||||
|
#define RX0_EARLY_RECEIVE_EVENT "\n\t"
|
||||||
|
|
||||||
|
// code executed only when databyte was received, can be placed here //
|
||||||
|
// r25,r30,r31 are free to use // r25 contains received data byte
|
||||||
|
#define RX0_LATE_RECEIVE_EVENT "\n\t"
|
||||||
|
|
||||||
|
#define RX0_INPUT_OPERAND_LIST
|
||||||
|
|
||||||
|
//************************************************
|
||||||
|
|
||||||
|
#define TX1_EVERYCAL_EVENT "\n\t"
|
||||||
|
#define TX1_TRANSMIT_EVENT "\n\t"
|
||||||
|
|
||||||
|
#define TX1_INPUT_OPERAND_LIST
|
||||||
|
|
||||||
|
#if !defined(USART1_EXTEND_RX_BUFFER) // DO NOT CHANGE
|
||||||
|
#define RX1_FRAMING_EVENT "\n\t"
|
||||||
|
// #define USART1_PUSH_BEFORE_RX
|
||||||
|
#else
|
||||||
|
#define RX1_FRAMING_EVENT "\n\t"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define RX1_EVERYCALL_EVENT "\n\t"
|
||||||
|
#define RX1_EARLY_RECEIVE_EVENT "\n\t"
|
||||||
|
#define RX1_LATE_RECEIVE_EVENT "\n\t"
|
||||||
|
|
||||||
|
#define RX1_INPUT_OPERAND_LIST
|
||||||
|
|
||||||
|
//************************************************
|
||||||
|
|
||||||
|
#define TX2_EVERYCAL_EVENT "\n\t"
|
||||||
|
#define TX2_TRANSMIT_EVENT "\n\t"
|
||||||
|
|
||||||
|
#define TX2_INPUT_OPERAND_LIST
|
||||||
|
|
||||||
|
#if !defined(USART2_EXTEND_RX_BUFFER) // DO NOT CHANGE
|
||||||
|
#define RX2_FRAMING_EVENT "\n\t"
|
||||||
|
// #define USART2_PUSH_BEFORE_RX
|
||||||
|
#else
|
||||||
|
#define RX2_FRAMING_EVENT "\n\t"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define RX2_EVERYCALL_EVENT "\n\t"
|
||||||
|
#define RX2_EARLY_RECEIVE_EVENT "\n\t"
|
||||||
|
#define RX2_LATE_RECEIVE_EVENT "\n\t"
|
||||||
|
|
||||||
|
#define RX2_INPUT_OPERAND_LIST
|
||||||
|
|
||||||
|
//************************************************
|
||||||
|
|
||||||
|
#define TX3_EVERYCAL_EVENT "\n\t"
|
||||||
|
#define TX3_TRANSMIT_EVENT "\n\t"
|
||||||
|
|
||||||
|
#define TX3_INPUT_OPERAND_LIST
|
||||||
|
|
||||||
|
#if !defined(USART3_EXTEND_RX_BUFFER) // DO NOT CHANGE
|
||||||
|
#define RX3_FRAMING_EVENT "\n\t"
|
||||||
|
// #define USART3_PUSH_BEFORE_RX
|
||||||
|
#else
|
||||||
|
#define RX3_FRAMING_EVENT "\n\t"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define RX3_EVERYCALL_EVENT "\n\t"
|
||||||
|
#define RX3_EARLY_RECEIVE_EVENT "\n\t"
|
||||||
|
#define RX3_LATE_RECEIVE_EVENT "\n\t"
|
||||||
|
|
||||||
|
#define RX3_INPUT_OPERAND_LIST
|
||||||
|
|
||||||
|
// events executed inside transmit complete interrupts (last byte has been
|
||||||
|
// transmitted, UDR buffer is empty) if USATRn_NO_NAKED_TXC_INTERRUPT is not
|
||||||
|
// defined then inline asm is required here // any modified regs have to be
|
||||||
|
// pushed first
|
||||||
|
// inline void TXCn_interrupt_event(void)
|
||||||
|
//{
|
||||||
|
// asm volatile("\n\t"
|
||||||
|
// "nop \n\t"
|
||||||
|
// "lpm \n\t"
|
||||||
|
// "st Z+, r0 \n\t"
|
||||||
|
// :: );
|
||||||
|
//}
|
||||||
|
// mpcm ??
|
||||||
|
|
||||||
|
// #define USATR0_NO_NAKED_TXC_INTERRUPT
|
||||||
|
// #define USART0_USE_TXC_INTERRUPT // if rs485 is not used
|
||||||
|
|
||||||
|
inline void TXC0_interrupt_event(void) __attribute__((always_inline));
|
||||||
|
inline void TXC0_interrupt_event(void) {}
|
||||||
|
|
||||||
|
// #define USATR1_NO_NAKED_TXC_INTERRUPT
|
||||||
|
// #define USART1_USE_TXC_INTERRUPT
|
||||||
|
|
||||||
|
inline void TXC1_interrupt_event(void) __attribute__((always_inline));
|
||||||
|
inline void TXC1_interrupt_event(void) {}
|
||||||
|
|
||||||
|
// #define USATR2_NO_NAKED_TXC_INTERRUPT
|
||||||
|
// #define USART2_USE_TXC_INTERRUPT
|
||||||
|
|
||||||
|
inline void TXC2_interrupt_event(void) __attribute__((always_inline));
|
||||||
|
inline void TXC2_interrupt_event(void) {}
|
||||||
|
|
||||||
|
// #define USATR3_NO_NAKED_TXC_INTERRUPT
|
||||||
|
// #define USART3_USE_TXC_INTERRUPT
|
||||||
|
|
||||||
|
inline void TXC3_interrupt_event(void) __attribute__((always_inline));
|
||||||
|
inline void TXC3_interrupt_event(void) {}
|
||||||
|
|
||||||
|
#endif /* USART_CONFIG_H_ */
|
||||||
Reference in New Issue
Block a user