Ajout FishPeper
This commit is contained in:
44
OpenSky_BL/.gitignore
vendored
Normal file
44
OpenSky_BL/.gitignore
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
*.bin
|
||||
*.rst
|
||||
*.user
|
||||
*.asm
|
||||
*.map
|
||||
*.lk
|
||||
*_preprocessed
|
||||
*.mem
|
||||
*.sym
|
||||
*.rel
|
||||
*.lst
|
||||
# Object files
|
||||
*.o
|
||||
*.ko
|
||||
*.obj
|
||||
*.elf
|
||||
|
||||
# Precompiled Headers
|
||||
*.gch
|
||||
*.pch
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
*.la
|
||||
*.lo
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
*.su
|
||||
674
OpenSky_BL/LICENSE
Normal file
674
OpenSky_BL/LICENSE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
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 <http://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:
|
||||
|
||||
{project} Copyright (C) {year} {fullname}
|
||||
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
|
||||
<http://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
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
85
OpenSky_BL/Makefile
Normal file
85
OpenSky_BL/Makefile
Normal file
@@ -0,0 +1,85 @@
|
||||
BOOTLOADER_SIZE = 0x0C00 #use 3 pages for bootloader (1 page = 0x400)
|
||||
|
||||
FLASH_SIZE ?= 0x4000 #default to 16k flash
|
||||
FLASH_PAGESIZE ?= 0x400 #1k page size for all targets
|
||||
|
||||
CC = sdcc
|
||||
|
||||
#set some flags depending on the target
|
||||
CFLAGS = -DBOOTLOADER_SIZE=$(BOOTLOADER_SIZE)
|
||||
CFLAGS += -DFLASH_SIZE=$(FLASH_SIZE)
|
||||
CFLAGS += -DFLASH_PAGESIZE=$(FLASH_PAGESIZE)
|
||||
|
||||
#allow a custom config file to be passed
|
||||
CONFIG_INCLUDE_DIR ?= default
|
||||
CFLAGS += -I $(CONFIG_INCLUDE_DIR)
|
||||
|
||||
SDCC_FLAGS = --model-small --opt-code-speed -I /usr/share/sdcc/include $(CFLAGS)
|
||||
LDFLAGS_FLASH = \
|
||||
--out-fmt-ihx \
|
||||
--code-loc 0x000 --code-size $(BOOTLOADER_SIZE) \
|
||||
--xram-loc 0xf000 --xram-size 0x7FF \
|
||||
--iram-size 0x100
|
||||
|
||||
AS = sdas8051
|
||||
ASFLAGS = -plosgff
|
||||
|
||||
#programmer binary
|
||||
CC_TOOL ?= cc-tool
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += --debug
|
||||
endif
|
||||
|
||||
SRC = main.c uart.c delay.c flash.c io.c
|
||||
|
||||
ADB=$(SRC:.c=.adb)
|
||||
ASM=$(SRC:.c=.asm)
|
||||
LNK=$(SRC:.c=.lnk)
|
||||
LST=$(SRC:.c=.lst)
|
||||
REL=$(SRC:.c=.rel)
|
||||
RST=$(SRC:.c=.rst)
|
||||
SYM=$(SRC:.c=.sym)
|
||||
BL_TARGET=bootloader
|
||||
|
||||
PCDB=$(PROGS:.hex=.cdb)
|
||||
PLNK=$(PROGS:.hex=.lnk)
|
||||
PMAP=$(PROGS:.hex=.map)
|
||||
PMEM=$(PROGS:.hex=.mem)
|
||||
PAOM=$(PROGS:.hex=)
|
||||
HEADER=$(wildcard *.h)
|
||||
|
||||
all: stylecheck $(BL_TARGET).hex
|
||||
|
||||
stylecheck: $(HEADER) $(SRC)
|
||||
ifdef STYLECHECK_DISABLED
|
||||
@echo "stylecheck disabled by parameter"
|
||||
else
|
||||
./stylecheck/cpplint.py \
|
||||
--filter=-build/include,-build/storage_class,-readability/casting,-runtime/arrays \
|
||||
--extensions="h,c" --linelength=100 $(HEADER) $(SRC) || true
|
||||
endif
|
||||
|
||||
startup.rel : startup.s
|
||||
@cpp -P $(CFLAGS) $< > $<_preprocessed
|
||||
$(AS) $(ASFLAGS) $<_preprocessed
|
||||
|
||||
%.rel : %.c
|
||||
$(CC) -c $(SDCC_FLAGS) -o$*.rel $<
|
||||
|
||||
$(BL_TARGET).hex: startup.rel $(REL) Makefile
|
||||
$(CC) $(LDFLAGS_FLASH) $(SDCC_FLAGS) -o $(BL_TARGET).hex $(REL) startup.rel
|
||||
|
||||
$(BL_TARGET).bin: $(BL_TARGET).hex
|
||||
@objcopy -Iihex -Obinary $(BL_TARGET).hex $(BL_TARGET).bin
|
||||
|
||||
clean:
|
||||
@rm -f startup.rel
|
||||
@rm -f $(ADB) $(ASM) $(LNK) $(LST) $(REL) $(RST) $(SYM)
|
||||
@rm -f $(BL_TARGET) $(PCDB) $(PLNK) $(PMAP) $(PMEM) $(PAOM)
|
||||
@rm -f *_preprocessed
|
||||
|
||||
flash: $(BL_TARGET).hex
|
||||
$(CC_TOOL) -f -e -w $(BL_TARGET).hex
|
||||
|
||||
.PHONY: stylecheck clean flash
|
||||
1
OpenSky_BL/OpenSky_BL.config
Normal file
1
OpenSky_BL/OpenSky_BL.config
Normal file
@@ -0,0 +1 @@
|
||||
// ADD PREDEFINED MACROS HERE!
|
||||
1
OpenSky_BL/OpenSky_BL.creator
Normal file
1
OpenSky_BL/OpenSky_BL.creator
Normal file
@@ -0,0 +1 @@
|
||||
[General]
|
||||
16
OpenSky_BL/OpenSky_BL.files
Normal file
16
OpenSky_BL/OpenSky_BL.files
Normal file
@@ -0,0 +1,16 @@
|
||||
config.h
|
||||
led.h
|
||||
main.c
|
||||
main.h
|
||||
portmacros.h
|
||||
ivect.asm
|
||||
uart.c
|
||||
uart.h
|
||||
delay.c
|
||||
delay.h
|
||||
device.h
|
||||
flash.c
|
||||
flash.h
|
||||
cc25xx.h
|
||||
dma.h
|
||||
ivect.s
|
||||
1
OpenSky_BL/OpenSky_BL.includes
Normal file
1
OpenSky_BL/OpenSky_BL.includes
Normal file
@@ -0,0 +1 @@
|
||||
.
|
||||
7
OpenSky_BL/OpenSky_BL.pro
Normal file
7
OpenSky_BL/OpenSky_BL.pro
Normal file
@@ -0,0 +1,7 @@
|
||||
TEMPLATE = app
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
CONFIG -= qt
|
||||
|
||||
SOURCES += main.c
|
||||
|
||||
22
OpenSky_BL/README.md
Normal file
22
OpenSky_BL/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# OpenSky_BL
|
||||
|
||||
Bootloader code for the cc2510 to be used by the [OpenSky project](https://github.com/fishpepper/OpenSky).
|
||||
The bootloader protocol used is the same as used for stm32f0/1/3, see [application note](www.st.com/resource/en/application_note/cd00264342.pdf).
|
||||
|
||||
The idea is to have a bootloader that can be used from within betaflight without the need for any further software. As betaflight supports the stm32 bootloader protocol, i choosed to implement it for the cc2510.
|
||||
This allows to update/flash the receiver firmware without the need of a cc-tool isp programmer.
|
||||
|
||||
#Status
|
||||
Bootloader upload/erase/go is working. Tested with betaflight configurator and stm32flash.
|
||||
Note that Opensky needs to be compiled to with --code-loc 0x0c00 in order to be stored behind the bootloader. The bootloader code redirects all interrupts to the interrupt vector located at 0x0C00.
|
||||
|
||||
#TODO
|
||||
Use a gpio hi/lo signal to decide wether to enter the bootloader or to jump to the app.
|
||||
|
||||
misc docs:
|
||||
www.st.com/resource/en/application_note/cd00264342.pdf
|
||||
http://www.ti.com/lit/an/swra222b/swra222b.pdf
|
||||
http://www.ti.com/lit/gpn/cc2510
|
||||
https://github.com/betaflight/betaflight-configurator/blob/master/js/protocols/stm32.js
|
||||
https://sourceforge.net/p/stm32flash/code/ci/master/tree/stm32.c
|
||||
http://www.ti.com/general/docs/litabsmultiplefilelist.tsp?literatureNumber=swra371a
|
||||
55
OpenSky_BL/blink_test/Makefile
Normal file
55
OpenSky_BL/blink_test/Makefile
Normal file
@@ -0,0 +1,55 @@
|
||||
BOOTLOADER_SIZE = 0x0C00 #use 3kb for bootloader
|
||||
|
||||
CC = sdcc
|
||||
CFLAGS = -Wl-bHOME=$(BOOTLOADER_SIZE)
|
||||
SDCC_FLAGS = --model-small --opt-code-speed -I /usr/share/sdcc/include $(CFLAGS)
|
||||
LDFLAGS_FLASH = \
|
||||
--out-fmt-ihx \
|
||||
--code-loc 0x000 --code-size $(BOOTLOADER_SIZE) \
|
||||
--xram-loc 0xf000 --xram-size 0x7FF \
|
||||
--iram-size 0x100
|
||||
|
||||
AS = sdas8051
|
||||
ASFLAGS = -plosgff
|
||||
|
||||
#programmer binary
|
||||
CC_TOOL ?= cc-tool
|
||||
|
||||
ifdef DEBUG
|
||||
CFLAGS += --debug
|
||||
endif
|
||||
|
||||
SRC = main.c ../delay.c
|
||||
|
||||
ADB=$(SRC:.c=.adb)
|
||||
ASM=$(SRC:.c=.asm)
|
||||
LNK=$(SRC:.c=.lnk)
|
||||
LST=$(SRC:.c=.lst)
|
||||
REL=$(SRC:.c=.rel)
|
||||
RST=$(SRC:.c=.rst)
|
||||
SYM=$(SRC:.c=.sym)
|
||||
TARGET=blinky
|
||||
PCDB=$(PROGS:.hex=.cdb)
|
||||
PLNK=$(PROGS:.hex=.lnk)
|
||||
PMAP=$(PROGS:.hex=.map)
|
||||
PMEM=$(PROGS:.hex=.mem)
|
||||
PAOM=$(PROGS:.hex=)
|
||||
HEADER=$(wildcard *.h)
|
||||
|
||||
all: $(TARGET).bin
|
||||
|
||||
%.rel : %.c
|
||||
$(CC) -c $(SDCC_FLAGS) -o$*.rel $<
|
||||
|
||||
$(TARGET).hex: $(REL) Makefile
|
||||
$(CC) $(LDFLAGS_FLASH) $(SDCC_FLAGS) -o $(TARGET).hex $(REL)
|
||||
|
||||
$(TARGET).bin: $(TARGET).hex
|
||||
objcopy -Iihex -Obinary $(TARGET).hex $(TARGET).bin
|
||||
|
||||
|
||||
clean:
|
||||
rm -f $(ADB) $(ASM) $(LNK) $(LST) $(REL) $(RST) $(SYM)
|
||||
rm -f $(TARGET) $(PCDB) $(PLNK) $(PMAP) $(PMEM) $(PAOM)
|
||||
|
||||
.PHONY: clean
|
||||
32
OpenSky_BL/blink_test/main.c
Normal file
32
OpenSky_BL/blink_test/main.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../led.h"
|
||||
#include "../delay.h"
|
||||
|
||||
|
||||
void main(void) {
|
||||
led_init();
|
||||
|
||||
while(1){
|
||||
delay_ms(500);
|
||||
led_green_toggle();
|
||||
}
|
||||
}
|
||||
119
OpenSky_BL/cc25xx.h
Normal file
119
OpenSky_BL/cc25xx.h
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
|
||||
#ifndef CC25XX_H_
|
||||
#define CC25XX_H_
|
||||
#include <stdint.h>
|
||||
#include <cc2510fx.h>
|
||||
|
||||
#define PERCFG_U0CFG (1<<0)
|
||||
#define PERCFG_U1CFG (1<<1)
|
||||
#define PERCFG_T4CFG (1<<4)
|
||||
#define PERCFG_T3CFG (1<<5)
|
||||
#define PERCFG_T1CFG (1<<6)
|
||||
|
||||
#define IEN0_RFTXRXIE (1<<0)
|
||||
#define IEN0_ADCIE (1<<1)
|
||||
#define IEN0_URX0IE (1<<2)
|
||||
#define IEN0_URX1IE (1<<3)
|
||||
#define IEN0_ENCIE (1<<4)
|
||||
#define IEN0_STIE (1<<5)
|
||||
#define IEN0_EA (1<<7)
|
||||
|
||||
// bit 7 - unused
|
||||
// bit 6 - unused
|
||||
#define PICTL_P2IEN (1<<5)
|
||||
#define PICTL_P0IENH (1<<4)
|
||||
#define PICTL_P0IENL (1<<3)
|
||||
#define PICTL_P2ICON (1<<2)
|
||||
#define PICTL_P1ICON (1<<1)
|
||||
#define PICTL_P0ICON (1<<0)
|
||||
|
||||
#define IEN1_P0IE (1<<5)
|
||||
#define IEN1_T4IE (1<<4)
|
||||
#define IEN1_T3IE (1<<3)
|
||||
#define IEN1_T2IE (1<<2)
|
||||
#define IEN1_T1IE (1<<1)
|
||||
#define IEN1_DMAIE (1<<0)
|
||||
|
||||
#define IEN2_RFIE (1<<0)
|
||||
#define IEN2_P2IE (1<<1)
|
||||
#define IEN2_UTX0IE (1<<2)
|
||||
#define IEN2_UTX1IE (1<<3)
|
||||
#define IEN2_P1IE (1<<4)
|
||||
#define IEN2_WDTIE (1<<5)
|
||||
|
||||
#define U0GCR_ORDER (1<<5)
|
||||
#define U0GCR_CPHA (1<<6)
|
||||
#define U0GCR_CPOL (1<<7)
|
||||
#define U0CSR_TX_BYTE (1<<1)
|
||||
|
||||
#define U1GCR_ORDER (1<<5)
|
||||
#define U1GCR_CPHA (1<<6)
|
||||
#define U1GCR_CPOL (1<<7)
|
||||
#define U1CSR_TX_BYTE (1<<1)
|
||||
|
||||
#define CLKCON_TICKSPD_001 (0b00001000)
|
||||
#define CLKCON_TICKSPD_010 (0b00010000)
|
||||
#define CLKCON_TICKSPD_011 (0b00011000)
|
||||
#define CLKCON_TICKSPD_100 (0b00100000)
|
||||
#define CLKCON_TICKSPD_101 (0b00101000)
|
||||
#define CLKCON_TICKSPD_110 (0b00110000)
|
||||
#define CLKCON_TICKSPD_111 (0b00111000)
|
||||
#define CLKCON_OSC32K (1<<7)
|
||||
|
||||
#define ADCCON2_SREF_INT (0b00<<6)
|
||||
#define ADCCON2_SREF_EXT (0b01<<6)
|
||||
#define ADCCON2_SREF_AVDD (0b10<<6)
|
||||
#define ADCCON2_SREF_EXTDIFF (0b11<<6)
|
||||
#define ADCCON2_SDIV_7BIT (0b00<<4)
|
||||
#define ADCCON2_SDIV_9BIT (0b01<<4)
|
||||
#define ADCCON2_SDIV_10BIT (0b10<<4)
|
||||
#define ADCCON2_SDIV_12BIT (0b11<<4)
|
||||
#define ADCCON2_SCH_AIN0 (0b0000<<0)
|
||||
#define ADCCON2_SCH_AIN1 (0b0001<<0)
|
||||
#define ADCCON2_SCH_AIN2 (0b0010<<0)
|
||||
#define ADCCON2_SCH_AIN3 (0b0011<<0)
|
||||
#define ADCCON2_SCH_AIN4 (0b0100<<0)
|
||||
#define ADCCON2_SCH_AIN5 (0b0101<<0)
|
||||
#define ADCCON2_SCH_AIN6 (0b0110<<0)
|
||||
#define ADCCON2_SCH_AIN7 (0b0111<<0)
|
||||
#define ADCCON2_SCH_AIN0AIN1 (0b1000<<0)
|
||||
#define ADCCON2_SCH_AIN2AIN3 (0b1001<<0)
|
||||
#define ADCCON2_SCH_AIN4AIN5 (0b1010<<0)
|
||||
#define ADCCON2_SCH_AIN6AIN7 (0b1011<<0)
|
||||
#define ADCCON2_SCH_GND (0b1100<<0)
|
||||
#define ADCCON2_SCH_POSVREF (0b1101<<0)
|
||||
#define ADCCON2_SCH_TEMP (0b1110<<0)
|
||||
#define ADCCON2_SCH_VDD3 (0b1111<<0)
|
||||
|
||||
#define ADCCON1_ST (1<<6)
|
||||
#define ADCCON1_STSEL_FULL_SPEED (0b01<<4)
|
||||
|
||||
#define WDCTL_EN (1<<3)
|
||||
#define WDCTL_MODE (1<<2)
|
||||
#define WDCTL_INT (0b11)
|
||||
#define WDCTL_INT_1S (0b00)
|
||||
|
||||
#define FCTL_BUSY (1<<7)
|
||||
#define FCTL_SWBUSY (1<<6)
|
||||
#define FCTL_WRITE (1<<1)
|
||||
#define FCTL_ERASE (1<<0)
|
||||
|
||||
#endif // CC25XX_H_
|
||||
39
OpenSky_BL/default/config.h
Normal file
39
OpenSky_BL/default/config.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
#ifndef DEFAULT_CONFIG_CONFIG_H_
|
||||
#define DEFAULT_CONFIG_CONFIG_H_
|
||||
|
||||
// use defaults
|
||||
#define BOOTLOADER_LED_GREEN_PORT P2
|
||||
#define BOOTLOADER_LED_GREEN_PIN 4
|
||||
#define BOOTLOADER_LED_RED_PORT P2
|
||||
#define BOOTLOADER_LED_RED_PIN 3
|
||||
|
||||
#define BOOTLOADER_UART_NUM 1
|
||||
#define BOOTLOADER_UART_PORT 0
|
||||
#define BOOTLOADER_UART_INVERTED 0
|
||||
#define BOOTLOADER_UART_BAUDRATE 57600
|
||||
#define BOOTLOADER_UART_USE_PARITY 0
|
||||
|
||||
// use ISP interface clock pin as bootloader enable pin
|
||||
// pull this low during startup to enter bootloader mode
|
||||
#define BOOTLOADER_ENABLE_PORT P2
|
||||
#define BOOTLOADER_ENABLE_PIN 2
|
||||
|
||||
#endif // DEFAULT_CONFIG_CONFIG_H_
|
||||
57
OpenSky_BL/delay.c
Normal file
57
OpenSky_BL/delay.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
#include "delay.h"
|
||||
|
||||
// busy wait delay loop. not 100% accurate
|
||||
void delay_ms(uint16_t ms) {
|
||||
#define DELAY_MS_LOOP_A 86
|
||||
#define DELAY_MS_LOOP_B 30
|
||||
|
||||
while (ms--) {
|
||||
// this asm snippet gives us roughly 1ms delay:
|
||||
__asm
|
||||
mov r1, #DELAY_MS_LOOP_A
|
||||
00000$: // delay_ms_loop_outer
|
||||
dec r1
|
||||
mov a, r1
|
||||
jz 00002$
|
||||
mov r2, #DELAY_MS_LOOP_B
|
||||
00001$: // delay_ms_loop_inner
|
||||
dec r2
|
||||
mov a, r2
|
||||
jz 00000$
|
||||
sjmp 00001$
|
||||
00002$: // delay_ms_done
|
||||
__endasm;
|
||||
}
|
||||
}
|
||||
|
||||
// busy wait delay loop
|
||||
// this is more or less accurate
|
||||
void delay_us(uint16_t us) {
|
||||
#define DELAY_US_LOOP 1
|
||||
|
||||
while (us--) {
|
||||
__asm
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
__endasm;
|
||||
}
|
||||
}
|
||||
27
OpenSky_BL/delay.h
Normal file
27
OpenSky_BL/delay.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
|
||||
#ifndef DELAY_H_
|
||||
#define DELAY_H_
|
||||
#include <stdint.h>
|
||||
|
||||
void delay_ms(uint16_t ms);
|
||||
void delay_us(uint16_t us);
|
||||
|
||||
#endif // DELAY_H_
|
||||
32
OpenSky_BL/device.h
Normal file
32
OpenSky_BL/device.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
|
||||
#ifndef DEVICE_H_
|
||||
#define DEVICE_H_
|
||||
#include <cc2510fx.h>
|
||||
|
||||
#define CLOCKSOURCE_OSC_PD_BIT 0x04
|
||||
#define CLOCKSOURCE_XOSC_STABLE_BIT 0x40
|
||||
#define CLOCKSOURCE_XOSC_STABLE() (SLEEP & (CLOCKSOURCE_XOSC_STABLE_BIT))
|
||||
|
||||
#ifndef NOP
|
||||
#define NOP() { __asm nop __endasm; }
|
||||
#endif // NOP
|
||||
|
||||
#endif // DEVICE_H_
|
||||
122
OpenSky_BL/dma.h
Normal file
122
OpenSky_BL/dma.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
|
||||
#ifndef DMA_H_
|
||||
#define DMA_H_
|
||||
|
||||
// HAL_DMA CONFIG
|
||||
// see https://e2e.ti.com/support/wireless_connectivity/f/156/t/16922
|
||||
typedef struct {
|
||||
uint8_t SRCADDRH;
|
||||
uint8_t SRCADDRL;
|
||||
uint8_t DESTADDRH;
|
||||
uint8_t DESTADDRL;
|
||||
uint8_t LENH : 5;
|
||||
uint8_t VLEN : 3;
|
||||
uint8_t LENL : 8;
|
||||
uint8_t TRIG : 5;
|
||||
uint8_t TMODE : 2;
|
||||
uint8_t WORDSIZE : 1;
|
||||
uint8_t PRIORITY : 2;
|
||||
uint8_t M8 : 1;
|
||||
uint8_t IRQMASK : 1;
|
||||
uint8_t DESTINC : 2;
|
||||
uint8_t SRCINC : 2;
|
||||
} dma_desc_t;
|
||||
|
||||
#define HI(a) (uint8_t) ((uint16_t)(a) >> 8 )
|
||||
#define LO(a) (uint8_t) ((uint16_t)(a) & 0xFF )
|
||||
#define SET_WORD(H, L, val) { (H) = HI(val); (L) = LO(val); }
|
||||
|
||||
#define DMA_PRI_LOW 0x00 // Low, CPU has priority
|
||||
#define DMA_PRI_GUARANTEED 0x01 // Guaranteed, DMA at least every second try
|
||||
#define DMA_PRI_HIGH 0x02 // High, DMA has priority
|
||||
#define DMA_PRI_ABSOLUTE 0x03 // Highest, DMA has priority. Reserved for DMA port access.
|
||||
#define DMA_PRI_LOW 0x00 // Low, CPU has priority
|
||||
|
||||
#define DMA_TRIG_NONE 0 // No trigger, setting DMAREQ.DMAREQx bit starts transfer
|
||||
#define DMA_TRIG_PREV 1 // DMA channel is triggered by completion of previous channel
|
||||
#define DMA_TRIG_T1_CH0 2 // Timer 1, compare, channel 0
|
||||
#define DMA_TRIG_T1_CH1 3 // Timer 1, compare, channel 1
|
||||
#define DMA_TRIG_T1_CH2 4 // Timer 1, compare, channel 2
|
||||
#define DMA_TRIG_T2_COMP 5 // Timer 2, compare
|
||||
#define DMA_TRIG_T2_OVFL 6 // Timer 2, overflow
|
||||
#define DMA_TRIG_T3_CH0 7 // Timer 3, compare, channel 0
|
||||
#define DMA_TRIG_T3_CH1 8 // Timer 3, compare, channel 1
|
||||
#define DMA_TRIG_T4_CH0 9 // Timer 4, compare, channel 0
|
||||
#define DMA_TRIG_T4_CH1 10 // Timer 4, compare, channel 1
|
||||
#define DMA_TRIG_ST 11 // Sleep Timer compare
|
||||
#define DMA_TRIG_IOC_0 12 // Port 0 I/O pin input transition
|
||||
#define DMA_TRIG_IOC_1 13 // Port 1 I/O pin input transition
|
||||
#define DMA_TRIG_URX0 14 // USART0 RX complete
|
||||
#define DMA_TRIG_UTX0 15 // USART0 TX complete
|
||||
#define DMA_TRIG_URX1 16 // USART1 RX complete
|
||||
#define DMA_TRIG_UTX1 17 // USART1 TX complete
|
||||
#define DMA_TRIG_FLASH 18 // Flash data write complete
|
||||
#define DMA_TRIG_RADIO 19 // RF packet byte received/transmit
|
||||
#define DMA_TRIG_ADC_CHALL 20 // ADC end of a conversion in a sequence, sample ready
|
||||
#define DMA_TRIG_ADC_CH0 21 // ADC end of conversion channel 0 in sequence, sample ready
|
||||
#define DMA_TRIG_ADC_CH1 22 // ADC end of conversion channel 1 in sequence, sample ready
|
||||
#define DMA_TRIG_ADC_CH2 23 // ADC end of conversion channel 2 in sequence, sample ready
|
||||
#define DMA_TRIG_ADC_CH3 24 // ADC end of conversion channel 3 in sequence, sample ready
|
||||
#define DMA_TRIG_ADC_CH4 25 // ADC end of conversion channel 4 in sequence, sample ready
|
||||
#define DMA_TRIG_ADC_CH5 26 // ADC end of conversion channel 5 in sequence, sample ready
|
||||
#define DMA_TRIG_ADC_CH6 27 // ADC end of conversion channel 6 in sequence, sample ready
|
||||
#define DMA_TRIG_ADC_CH7 28 // ADC end of conversion channel 7 in sequence, sample ready
|
||||
#define DMA_TRIG_ENC_DW 29 // AES encryption processor requests download input data
|
||||
#define DMA_TRIG_ENC_UP 30 // AES encryption processor requests upload output data
|
||||
#define DMA_VLEN_USE_LEN 0x00 // Use LEN for transfer count
|
||||
#define DMA_VLEN_FIRST_BYTE_P_1 0x01 // tx the nr of bytes specified by the 1st byte +1
|
||||
#define DMA_VLEN_FIRST_BYTE 0x02 // tx the nr of bytes indicated by the 1st byte (itself incl.)
|
||||
#define DMA_VLEN_FIRST_BYTE_P_2 0x03 // tx the nr of bytes specified by the 1st byte +2
|
||||
#define DMA_VLEN_FIRST_BYTE_P_3 0x04 // tx the nr of bytes specified by the 1st byte +3
|
||||
#define DMA_LEN_MAX 0xFF // The maximum length is always decided by the 1st byte
|
||||
#define DMA_WORDSIZE_BYTE 0x00 // tx a byte at a time
|
||||
#define DMA_WORDSIZE_WORD 0x01 // tx a 16-bit word at a time
|
||||
#define DMA_TMODE_SINGLE 0x00 // tx a single byte/word after each DMA trigger
|
||||
#define DMA_TMODE_BLOCK 0x01 // tx block of data (length len) after each DMA trigger
|
||||
#define DMA_TMODE_SINGLE_REPEATED 0x02 // tx single byte/word (after len transfers, rearm DMA)
|
||||
#define DMA_TMODE_BLOCK_REPEATED 0x03 // tx block of data (after len transfers, rearm DMA)
|
||||
|
||||
#define DMA_ARM_ABORT 0x80
|
||||
#define DMA_ARM_CH0 (1<<0)
|
||||
|
||||
#define DMA_SRCINC_0 0x00 // Increment source pointer by 0 bytes/words after each transfer
|
||||
#define DMA_SRCINC_1 0x01 // Increment source pointer by 1 bytes/words after each transfer
|
||||
#define DMA_SRCINC_2 0x02 // Increment source pointer by 2 bytes/words after each transfer
|
||||
#define DMA_SRCINC_M1 0x03 // Decrement source pointer by 1 bytes/words after each transfer
|
||||
|
||||
#define DMA_DESTINC_0 0x00 // Increment dest pointer by 0 bytes/words after each transfer
|
||||
#define DMA_DESTINC_1 0x01 // Increment dest pointer by 1 bytes/words after each transfer
|
||||
#define DMA_DESTINC_2 0x02 // Increment dest pointer by 2 bytes/words after each transfer
|
||||
#define DMA_DESTINC_M1 0x03 // Decrement dest pointer by 1 bytes/words after each transfer
|
||||
|
||||
#define DMA_IRQMASK_DISABLE 0x00 // Disable interrupt generation
|
||||
#define DMA_IRQMASK_ENABLE 0x01 // Enable interrupt generation upon DMA channel done
|
||||
|
||||
#define DMA_M8_USE_8_BITS 0x00 // Use all 8 bits for transfer count
|
||||
#define DMA_M8_USE_7_BITS 0x01 // Use 7 LSB for transfer count
|
||||
|
||||
#define DMAIRQ_DMAIF0 (1<<0)
|
||||
#define DMAIRQ_DMAIF1 (1<<1)
|
||||
#define DMAIRQ_DMAIF2 (1<<2)
|
||||
#define DMAIRQ_DMAIF3 (1<<3)
|
||||
#define DMAIRQ_DMAIF4 (1<<4)
|
||||
|
||||
#endif // DMA_H_
|
||||
163
OpenSky_BL/flash.c
Normal file
163
OpenSky_BL/flash.c
Normal file
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
|
||||
#include "flash.h"
|
||||
#include "config.h"
|
||||
#include "main.h"
|
||||
#include "dma.h"
|
||||
#include "device.h"
|
||||
#include "cc25xx.h"
|
||||
|
||||
__xdata dma_desc_t flash_dma_config;
|
||||
|
||||
void flash_init(void) {
|
||||
// cancel _ALL_ ongoing DMA transfers:
|
||||
DMAARM = DMA_ARM_ABORT | 0x1F;
|
||||
|
||||
flash_dma_config.PRIORITY = DMA_PRI_HIGH; // high prio
|
||||
flash_dma_config.M8 = DMA_M8_USE_8_BITS; // irrelevant since we use LEN
|
||||
flash_dma_config.IRQMASK = DMA_IRQMASK_DISABLE; // disable ints from this ch
|
||||
flash_dma_config.TRIG = DMA_TRIG_FLASH; // use dma data write complete trigger
|
||||
flash_dma_config.TMODE = DMA_TMODE_SINGLE; // single mode, see datasheet
|
||||
flash_dma_config.WORDSIZE = DMA_WORDSIZE_BYTE; // one byte
|
||||
flash_dma_config.VLEN = DMA_VLEN_USE_LEN; // use LEN
|
||||
flash_dma_config.SRCINC = DMA_SRCINC_1; // set srcinc to 1 byte
|
||||
flash_dma_config.DESTINC = DMA_DESTINC_0; // fixed, always write to FWDATA
|
||||
|
||||
// set length of transfer in bytes
|
||||
SET_WORD(flash_dma_config.LENH, flash_dma_config.LENL, 0);
|
||||
// set src: address of data to be written
|
||||
SET_WORD(flash_dma_config.SRCADDRH, flash_dma_config.SRCADDRL, 0);
|
||||
// destination is flash controller data reg
|
||||
SET_WORD(flash_dma_config.DESTADDRH, flash_dma_config.DESTADDRL, &X_FWDATA);
|
||||
|
||||
// save pointer to the DMA configuration struct into DMA-channel 0
|
||||
// configuration registers
|
||||
SET_WORD(DMA0CFGH, DMA0CFGL, flash_dma_config);
|
||||
}
|
||||
|
||||
|
||||
// NOTE: this will read len+1 bytes to buffer buf
|
||||
void flash_read(uint16_t address, __xdata uint8_t *buf, uint16_t len) {
|
||||
__xdata uint8_t * flash_ptr = (__xdata uint8_t *)address;
|
||||
|
||||
// copy len bytes to buf
|
||||
while (len--) {
|
||||
*buf++ = *flash_ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t flash_write_data(uint16_t address, __xdata uint8_t *buf, uint16_t len) {
|
||||
// make sure not to overwrite bootloader:
|
||||
if (address < BOOTLOADER_SIZE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// make sure not to overwrite beyound valid flash region:
|
||||
if ((address + len) >= FLASH_SIZE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (address & 1) {
|
||||
// this should not happen, flash write needs an even start address
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (len & 1) {
|
||||
// this should also not happen, flash write has to write even number of bytes
|
||||
return 0;
|
||||
}
|
||||
|
||||
// cancel _ALL_ ongoing DMA transfers:
|
||||
DMAARM = DMA_ARM_ABORT | 0x1F;
|
||||
|
||||
// set length of transfer in bytes
|
||||
SET_WORD(flash_dma_config.LENH, flash_dma_config.LENL, len);
|
||||
// set src: address of data to be written
|
||||
SET_WORD(flash_dma_config.SRCADDRH, flash_dma_config.SRCADDRL, buf);
|
||||
// destination is flash controller data reg
|
||||
SET_WORD(flash_dma_config.DESTADDRH, flash_dma_config.DESTADDRL, &X_FWDATA);
|
||||
|
||||
// set up address:
|
||||
SET_WORD(FADDRH, FADDRL, ((uint16_t)address)>>1);
|
||||
|
||||
// waiting for the flash controller to be ready
|
||||
while (FCTL & FCTL_BUSY) {}
|
||||
|
||||
// configure flash controller for 26mhz clock
|
||||
FWT = 0x2A; // (21 * 26) / (16);
|
||||
|
||||
// arm the DMA channel, so that a DMA trigger will initiate DMA writing
|
||||
DMAARM = DMA_ARM_CH0;
|
||||
NOP();
|
||||
|
||||
// trigger flash write. this generates a DMA trigger.
|
||||
flash_trigger_write();
|
||||
|
||||
// wait for dma finish
|
||||
while (!(DMAIRQ & DMAIRQ_DMAIF0)) {}
|
||||
|
||||
// wait until flash controller not busy
|
||||
while (FCTL & (FCTL_BUSY | FCTL_SWBUSY)) {}
|
||||
|
||||
// by now, the transfer is completed, so the transfer count is reached.
|
||||
// the DMA channel 0 interrupt flag is then set, so we clear it here.
|
||||
DMAIRQ &= ~DMAIRQ_DMAIF0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint8_t flash_erase_page(uint8_t page) {
|
||||
if (page >= PAGECOUNT_FLASH) {
|
||||
// maximum page exceeded, abort
|
||||
return 0;
|
||||
}
|
||||
|
||||
// deny deletion of bootloader
|
||||
if (page < PAGECOUNT_BOOTLOADER) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// wait until flash controller is ready
|
||||
while (FCTL & FCTL_BUSY) {}
|
||||
|
||||
// set up flash address FADDRH[5:1] set flash page
|
||||
FADDRH = page << 1;
|
||||
|
||||
// configure flash controller for 26mhz clock
|
||||
FWT = 0x2A;
|
||||
|
||||
// execute erase
|
||||
FCTL |= FCTL_ERASE;
|
||||
NOP();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void flash_trigger_write(void) {
|
||||
// trigger flash write. this generates a DMA trigger
|
||||
// this was moved to a separate function as sdcc does not
|
||||
// optimize functions that include asm code (!)
|
||||
__asm
|
||||
.even // IMPORTANT: PLACE THIS ON A 2BYTE BOUNDARY!
|
||||
ORL _FCTL, #0x02; // FCTL |= FCTL_WRITE
|
||||
NOP
|
||||
__endasm;
|
||||
}
|
||||
|
||||
38
OpenSky_BL/flash.h
Normal file
38
OpenSky_BL/flash.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
|
||||
#ifndef FLASH_H_
|
||||
#define FLASH_H_
|
||||
#include <stdint.h>
|
||||
|
||||
void flash_init(void);
|
||||
void flash_read(uint16_t address, __xdata uint8_t *buf, uint16_t len);
|
||||
uint8_t flash_write_data(uint16_t address, __xdata uint8_t *buf, uint16_t len);
|
||||
uint8_t flash_erase_page(uint8_t page);
|
||||
static void flash_trigger_write(void);
|
||||
|
||||
#if ((FLASH_SIZE) > 65535)
|
||||
#error "ERROR: maximum supported flash size is 64k!"
|
||||
#endif // ((DEVICE_FLASH_SIZE) > 65535)
|
||||
|
||||
#define PAGECOUNT_BOOTLOADER ((BOOTLOADER_SIZE) / (FLASH_PAGESIZE))
|
||||
#define PAGECOUNT_FLASH ((FLASH_SIZE) / (FLASH_PAGESIZE))
|
||||
|
||||
|
||||
#endif // FLASH_H_
|
||||
41
OpenSky_BL/io.c
Normal file
41
OpenSky_BL/io.c
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
|
||||
#include "io.h"
|
||||
#include "config.h"
|
||||
#include <cc2510fx.h>
|
||||
#include "portmacros.h"
|
||||
|
||||
void io_init(void) {
|
||||
// enable pullup on bootloader input
|
||||
PORT2INP(BOOTLOADER_ENABLE_PORT) &= ~(1 << BOOTLOADER_ENABLE_PIN);
|
||||
|
||||
// set bootloader activation pin to input
|
||||
PORT2DIR(BOOTLOADER_ENABLE_PORT) &= ~(1 << BOOTLOADER_ENABLE_PIN);
|
||||
}
|
||||
|
||||
uint8_t io_bootloader_enabled(void) {
|
||||
if (BOOTLOADER_ENABLE_PORT & (1 << BOOTLOADER_ENABLE_PIN)) {
|
||||
// pin is high
|
||||
return 0;
|
||||
} else {
|
||||
// pin is low
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
27
OpenSky_BL/io.h
Normal file
27
OpenSky_BL/io.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
|
||||
#ifndef IO_H_
|
||||
#define IO_H_
|
||||
#include <stdint.h>
|
||||
|
||||
void io_init(void);
|
||||
uint8_t io_bootloader_enabled(void);
|
||||
|
||||
#endif // IO_H_.
|
||||
45
OpenSky_BL/led.h
Normal file
45
OpenSky_BL/led.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
|
||||
#ifndef LED_H_
|
||||
#define LED_H_
|
||||
#include <cc2510fx.h>
|
||||
#include "portmacros.h"
|
||||
#include "config.h"
|
||||
|
||||
#define BOOTLOADER_LED_GREEN_DIR PORT2DIR(BOOTLOADER_LED_GREEN_PORT)
|
||||
#define BOOTLOADER_LED_RED_DIR PORT2DIR(BOOTLOADER_LED_RED_PORT)
|
||||
#define BOOTLOADER_LED_RED_BIT PORT2BIT(BOOTLOADER_LED_RED_PORT, BOOTLOADER_LED_RED_PIN)
|
||||
#define BOOTLOADER_LED_GREEN_BIT PORT2BIT(BOOTLOADER_LED_GREEN_PORT, BOOTLOADER_LED_GREEN_PIN)
|
||||
|
||||
#define led_green_init() { BOOTLOADER_LED_GREEN_DIR |= (1 << BOOTLOADER_LED_GREEN_PIN); \
|
||||
led_green_off(); }
|
||||
#define led_green_on() { BOOTLOADER_LED_GREEN_BIT = 1; }
|
||||
#define led_green_off() { BOOTLOADER_LED_GREEN_BIT = 0; }
|
||||
#define led_green_toggle() { BOOTLOADER_LED_GREEN_BIT = !BOOTLOADER_LED_GREEN_BIT; }
|
||||
|
||||
#define led_red_init() { BOOTLOADER_LED_RED_DIR |= (1 << BOOTLOADER_LED_RED_PIN); led_red_off(); }
|
||||
#define led_red_on() { BOOTLOADER_LED_RED_BIT = 1; }
|
||||
#define led_red_off() { BOOTLOADER_LED_RED_BIT = 0; }
|
||||
#define led_red_toggle() { BOOTLOADER_LED_RED_BIT = !BOOTLOADER_LED_RED_BIT; }
|
||||
|
||||
// led init routines
|
||||
#define led_init() { led_red_init(); led_green_init(); }
|
||||
|
||||
#endif // LED_H_
|
||||
464
OpenSky_BL/main.c
Normal file
464
OpenSky_BL/main.c
Normal file
@@ -0,0 +1,464 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
#pragma noiv
|
||||
|
||||
#include <stdint.h>
|
||||
#include "cc25xx.h"
|
||||
#include "main.h"
|
||||
#include "uart.h"
|
||||
#include "led.h"
|
||||
#include "delay.h"
|
||||
#include "device.h"
|
||||
#include "flash.h"
|
||||
#include "io.h"
|
||||
|
||||
static void bootloader_init_clocks(void) {
|
||||
// power up osc (?)
|
||||
SLEEP &= ~CLOCKSOURCE_OSC_PD_BIT;
|
||||
|
||||
// wait for XOSC stable
|
||||
while (!CLOCKSOURCE_XOSC_STABLE()) {}
|
||||
NOP();
|
||||
|
||||
// start crystal osc as HS clocksource, OSC32 is int rc osc
|
||||
CLKCON = 0x80;
|
||||
|
||||
// wait for selection to be active
|
||||
while (!CLOCKSOURCE_XOSC_STABLE()) {}
|
||||
NOP();
|
||||
|
||||
// power down the unused oscillator
|
||||
SLEEP |= CLOCKSOURCE_OSC_PD_BIT;
|
||||
}
|
||||
|
||||
static void bootloader_init(void) {
|
||||
// show bootloader activity:
|
||||
led_red_on();
|
||||
led_green_on();
|
||||
|
||||
// set up clocks
|
||||
bootloader_init_clocks();
|
||||
|
||||
// turn on cache pre-fetch mode
|
||||
FCTL = 0x08;
|
||||
|
||||
// wait for vcc to stabilize
|
||||
delay_ms(50);
|
||||
}
|
||||
|
||||
|
||||
static uint8_t bootloader_decode_address(uint16_t *address) {
|
||||
uint8_t rx;
|
||||
uint8_t checksum = 0;
|
||||
|
||||
// as we only accept 16bit addresses
|
||||
// stm32 uses 0x0800xxyy as address for flash
|
||||
// ignore the first two bytes
|
||||
checksum ^= uart_getc();
|
||||
checksum ^= uart_getc();
|
||||
|
||||
// high byte of 16bit
|
||||
rx = uart_getc();
|
||||
*address = rx;
|
||||
checksum ^= rx;
|
||||
|
||||
// low byte of 16bit
|
||||
rx = uart_getc();
|
||||
*address = ((*address) << 8) | rx;
|
||||
checksum ^= rx;
|
||||
|
||||
// read address checksum
|
||||
rx = uart_getc();
|
||||
|
||||
// verify checksum
|
||||
if (rx != checksum) {
|
||||
// checksum invalid -> abort here
|
||||
return 0;
|
||||
}
|
||||
|
||||
// verify if this is within memory bounds:
|
||||
if ((*address) > (FLASH_SIZE)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// everything is fine
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void bootloader_jump_to_app(void) {
|
||||
// disable all interrupts
|
||||
EA = 0;
|
||||
IEN0 = 0;
|
||||
IEN1 = 0;
|
||||
IEN2 = 0;
|
||||
|
||||
// jump to main app. this will never return
|
||||
__asm
|
||||
ljmp #(BOOTLOADER_SIZE)
|
||||
sjmp .
|
||||
__endasm;
|
||||
}
|
||||
|
||||
void bootloader_main(void) {
|
||||
__xdata uint8_t buffer[256+2];
|
||||
uint8_t state = 0;
|
||||
uint8_t command = 0;
|
||||
uint8_t rx = 0;
|
||||
uint16_t address;
|
||||
uint8_t *data_ptr = 0;
|
||||
uint8_t checksum;
|
||||
uint8_t len = 0;
|
||||
uint16_t len16 = 0;
|
||||
uint8_t i;
|
||||
myfuncptr_t jump_helper;
|
||||
|
||||
io_init();
|
||||
led_init();
|
||||
|
||||
// check if we have to enter the bootloader
|
||||
// or jump to the application
|
||||
// wait some time for the voltage level on i/o to
|
||||
// stabilize
|
||||
delay_ms(25);
|
||||
if (!io_bootloader_enabled()) {
|
||||
// bootloader enable pin pulled low
|
||||
if (*((__xdata uint8_t*)(BOOTLOADER_SIZE)) != 0xFF) {
|
||||
// there is valid flash content on this address
|
||||
// so it is safe to jump to main app!
|
||||
bootloader_jump_to_app();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bootloader_init();
|
||||
uart_init();
|
||||
flash_init();
|
||||
|
||||
led_green_on();
|
||||
led_red_off();
|
||||
|
||||
|
||||
|
||||
// the bootloader enable pin was high or
|
||||
// there was no valid code uploaded yet -> enter bootloader mode
|
||||
while (1) {
|
||||
// uart_putc_d(state);
|
||||
// do main statemachine
|
||||
switch (state) {
|
||||
default:
|
||||
case(0):
|
||||
// fetch command byte
|
||||
command = uart_getc();
|
||||
if (command == BOOTLOADER_COMMAND_INIT) {
|
||||
// init sequence, send ack
|
||||
uart_putc(BOOTLOADER_RESPONSE_ACK);
|
||||
} else {
|
||||
// real command
|
||||
state = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case(1):
|
||||
// check command checksum (inverted)
|
||||
rx = uart_getc();
|
||||
// NOTE: ~x seems to be calculated in uint16_t !
|
||||
if (rx == (command ^ 0xFF)) {
|
||||
// fine, valid command -> decode
|
||||
switch (command) {
|
||||
// unknown or unsupported command
|
||||
default:
|
||||
// invalid command, abort
|
||||
state = 0xFF;
|
||||
break;
|
||||
|
||||
// all known commands
|
||||
case(BOOTLOADER_COMMAND_GET):
|
||||
case(BOOTLOADER_COMMAND_GET_VERSION):
|
||||
case(BOOTLOADER_COMMAND_GET_ID):
|
||||
case(BOOTLOADER_COMMAND_READ_MEMORY):
|
||||
case(BOOTLOADER_COMMAND_GO):
|
||||
case(BOOTLOADER_COMMAND_WRITE_MEMORY):
|
||||
case(BOOTLOADER_COMMAND_ERASE):
|
||||
// send ACK and continue with command handler
|
||||
uart_putc(BOOTLOADER_RESPONSE_ACK);
|
||||
state = 10 + command;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// mismatch - this was either a comm error or we are
|
||||
// in the middle of a command, retry with the current byte as cmd byte:
|
||||
if (rx == BOOTLOADER_COMMAND_INIT) {
|
||||
// init sequence, send ack
|
||||
uart_putc(BOOTLOADER_RESPONSE_ACK);
|
||||
state = 0;
|
||||
} else {
|
||||
// real command
|
||||
command = rx;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// send GET response
|
||||
case(10 + BOOTLOADER_COMMAND_GET):
|
||||
// number of command bytes that will follow
|
||||
uart_putc(7);
|
||||
// version
|
||||
uart_putc(BOOTLOADER_VERSION);
|
||||
// send supported commands
|
||||
uart_putc(BOOTLOADER_COMMAND_GET);
|
||||
uart_putc(BOOTLOADER_COMMAND_GET_VERSION);
|
||||
uart_putc(BOOTLOADER_COMMAND_GET_ID);
|
||||
uart_putc(BOOTLOADER_COMMAND_READ_MEMORY);
|
||||
uart_putc(BOOTLOADER_COMMAND_GO);
|
||||
uart_putc(BOOTLOADER_COMMAND_WRITE_MEMORY);
|
||||
uart_putc(BOOTLOADER_COMMAND_ERASE);
|
||||
// send ack
|
||||
uart_putc(BOOTLOADER_RESPONSE_ACK);
|
||||
// wait for next command
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
// send GET_ID response
|
||||
case(10 + BOOTLOADER_COMMAND_GET_ID):
|
||||
// number of response bytes to follow
|
||||
uart_putc(1);
|
||||
// send product id of an F1 chip with the same pagesize (1024)
|
||||
uart_putc(BOOTLOADER_DEVICE_ID >> 8);
|
||||
uart_putc(BOOTLOADER_DEVICE_ID & 0xFF);
|
||||
// send ack
|
||||
uart_putc(BOOTLOADER_RESPONSE_ACK);
|
||||
// wait for next command
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
// send GET_VERSION response
|
||||
case (10 + BOOTLOADER_COMMAND_GET_VERSION):
|
||||
// bootloader version
|
||||
uart_putc(BOOTLOADER_VERSION);
|
||||
// send option bytes
|
||||
uart_putc(0x00);
|
||||
uart_putc(0x00);
|
||||
// send ack
|
||||
uart_putc(BOOTLOADER_RESPONSE_ACK);
|
||||
// wait for next command
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
// send READ_MEMORY response
|
||||
case(10 + BOOTLOADER_COMMAND_READ_MEMORY):
|
||||
if (!bootloader_decode_address(&address)) {
|
||||
// abort now
|
||||
state = 0xFF;
|
||||
break;
|
||||
}
|
||||
|
||||
// addresss is valid, send ack
|
||||
uart_putc(BOOTLOADER_RESPONSE_ACK);
|
||||
|
||||
// fetch data
|
||||
len = uart_getc();
|
||||
checksum = uart_getc();
|
||||
|
||||
// verify checksum
|
||||
if (len != (checksum ^ 0xFF)) {
|
||||
// checksum invalid -> abort here
|
||||
state = 0xFF;
|
||||
break;
|
||||
}
|
||||
|
||||
// checksum test passed, send ack
|
||||
uart_putc(BOOTLOADER_RESPONSE_ACK);
|
||||
|
||||
// fetch flash content (len+1 bytes!)
|
||||
flash_read(address, buffer, ((uint16_t) len) + 1);
|
||||
|
||||
// send len+1 bytes
|
||||
data_ptr = &buffer[0];
|
||||
uart_putc(*data_ptr++);
|
||||
while (len--) {
|
||||
uart_putc(*data_ptr++);
|
||||
}
|
||||
|
||||
// wait for next command
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
// send GO response
|
||||
case(10 + BOOTLOADER_COMMAND_GO):
|
||||
if (!bootloader_decode_address(&address)) {
|
||||
// abort now
|
||||
state = 0xFF;
|
||||
break;
|
||||
}
|
||||
|
||||
// addresss is valid, send ack
|
||||
uart_putc(BOOTLOADER_RESPONSE_ACK);
|
||||
|
||||
// now jump to user application given by address
|
||||
// disable all interrupts
|
||||
EA = 0;
|
||||
IEN0 = 0;
|
||||
IEN1 = 0;
|
||||
IEN2 = 0;
|
||||
jump_helper = (myfuncptr_t) address;
|
||||
jump_helper();
|
||||
|
||||
// wait for next command
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
// send WRITE_MEMORY response
|
||||
case(10 + BOOTLOADER_COMMAND_WRITE_MEMORY):
|
||||
if (!bootloader_decode_address(&address)) {
|
||||
// abort now
|
||||
state = 0xFF;
|
||||
break;
|
||||
}
|
||||
|
||||
// addresss is valid, send ack
|
||||
uart_putc(BOOTLOADER_RESPONSE_ACK);
|
||||
|
||||
// fetch len
|
||||
len = uart_getc();
|
||||
checksum = len;
|
||||
|
||||
// place to store data
|
||||
data_ptr = &buffer[0];
|
||||
|
||||
// we will have to write len+1 bytes
|
||||
len16 = ((uint16_t) len) + 1;
|
||||
|
||||
// we can only start the write on even addresses
|
||||
if (address & 1) {
|
||||
// not an even address, add a dummy write of 0xFF to the data:
|
||||
address--;
|
||||
*data_ptr++ = 0xFF;
|
||||
len16++;
|
||||
}
|
||||
|
||||
|
||||
// retrieve N+1 data bytes
|
||||
rx = uart_getc();
|
||||
*data_ptr++ = rx;
|
||||
checksum ^= rx;
|
||||
|
||||
for (i=0; i < len; i++) {
|
||||
rx = uart_getc();
|
||||
*data_ptr++ = rx;
|
||||
checksum ^= rx;
|
||||
}
|
||||
|
||||
// verify checksum
|
||||
rx = uart_getc();
|
||||
if (checksum != rx) {
|
||||
// checksum invalid -> abort here
|
||||
state = 0xFF;
|
||||
break;
|
||||
}
|
||||
|
||||
// we have to write an even number of bytes as well
|
||||
if (len16 & 1) {
|
||||
// not even, fix it by appending a dumm write of 0xFF
|
||||
*data_ptr++ = 0xFF;
|
||||
len16++;
|
||||
}
|
||||
|
||||
|
||||
// checksum ok - store data
|
||||
if (!flash_write_data(address, buffer, len16)) {
|
||||
// write failed
|
||||
state = 0xFF;
|
||||
break;
|
||||
}
|
||||
|
||||
// done
|
||||
uart_putc(BOOTLOADER_RESPONSE_ACK);
|
||||
|
||||
// wait for next command
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
// send ERASE response
|
||||
case(10 + BOOTLOADER_COMMAND_ERASE):
|
||||
// get number of pages to be erased
|
||||
len = uart_getc();
|
||||
checksum = len;
|
||||
|
||||
if (len == 0xFF) {
|
||||
// special case, full flash erase
|
||||
if (uart_getc() == 0x00) {
|
||||
// valid command, mark all pages to be erased
|
||||
len = 0;
|
||||
data_ptr = &buffer[0];
|
||||
for (i = PAGECOUNT_BOOTLOADER; i < PAGECOUNT_FLASH; i++) {
|
||||
buffer[len] = i;
|
||||
len++;
|
||||
}
|
||||
} else {
|
||||
// checksum error, abort
|
||||
state = 0xFF;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// fetch len+1 pages to be erased
|
||||
data_ptr = &buffer[0];
|
||||
rx = uart_getc();
|
||||
*data_ptr++ = rx;
|
||||
checksum ^= rx;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
rx = uart_getc();
|
||||
*data_ptr++ = rx;
|
||||
checksum ^= rx;
|
||||
}
|
||||
|
||||
// fetch checksum
|
||||
rx = uart_getc();
|
||||
|
||||
if (rx != checksum) {
|
||||
// checksum mismatch, abort
|
||||
state = 0xFF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// fine, the len+1 pages to be erased are now in buffer[]
|
||||
// execute the erase of len+1 pages
|
||||
data_ptr = &buffer[0];
|
||||
if (!flash_erase_page(*data_ptr++)) { state = 0xFF; break;}
|
||||
while (len--) {
|
||||
if (!flash_erase_page(*data_ptr++)) { state = 0xFF; break;}
|
||||
}
|
||||
|
||||
// execute suceeded!
|
||||
uart_putc(BOOTLOADER_RESPONSE_ACK);
|
||||
|
||||
// wait for next command
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
// ABORT STATE - send nack and goto idle
|
||||
case(0xFF):
|
||||
uart_putc(BOOTLOADER_RESPONSE_NACK);
|
||||
state = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
46
OpenSky_BL/main.h
Normal file
46
OpenSky_BL/main.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
|
||||
#ifndef MAIN_H_
|
||||
#define MAIN_H_
|
||||
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
|
||||
#define BOOTLOADER_COMMAND_INIT 0x7F
|
||||
#define BOOTLOADER_COMMAND_GET 0x00
|
||||
#define BOOTLOADER_COMMAND_GET_VERSION 0x01
|
||||
#define BOOTLOADER_COMMAND_GET_ID 0x02
|
||||
#define BOOTLOADER_COMMAND_READ_MEMORY 0x11
|
||||
#define BOOTLOADER_COMMAND_GO 0x21
|
||||
#define BOOTLOADER_COMMAND_WRITE_MEMORY 0x31
|
||||
#define BOOTLOADER_COMMAND_ERASE 0x43
|
||||
|
||||
#define BOOTLOADER_RESPONSE_ACK 0x79
|
||||
#define BOOTLOADER_RESPONSE_NACK 0x1F
|
||||
|
||||
// version 1.0
|
||||
#define BOOTLOADER_VERSION 0x10
|
||||
#define BOOTLOADER_DEVICE_ID 0x0410
|
||||
// #define BOOTLOADER_DEVICE_ID 0x0412
|
||||
|
||||
typedef void (*myfuncptr_t)(void);
|
||||
|
||||
#endif // MAIN_H_
|
||||
31
OpenSky_BL/portmacros.h
Normal file
31
OpenSky_BL/portmacros.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
|
||||
#ifndef PORTMACROS_H_
|
||||
#define PORTMACROS_H_
|
||||
|
||||
// define some helpers
|
||||
#define PORT2DIR_(X) X ## DIR
|
||||
#define PORT2DIR(PORTNAME) PORT2DIR_(PORTNAME)
|
||||
#define PORT2BIT_(X, N) X ## _ ## N
|
||||
#define PORT2BIT(PORTNAME, PIN) PORT2BIT_(PORTNAME, PIN)
|
||||
#define PORT2INP_(X) X ## INP
|
||||
#define PORT2INP(PORTNAME) PORT2INP_(PORTNAME)
|
||||
|
||||
#endif // PORTMACROS_H_
|
||||
119
OpenSky_BL/startup.s
Normal file
119
OpenSky_BL/startup.s
Normal file
@@ -0,0 +1,119 @@
|
||||
;
|
||||
; Copyright 2016 fishpepper <AT> gmail.com
|
||||
;
|
||||
; 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 <http://www.gnu.org/licenses/>.
|
||||
;
|
||||
; author: fishpepper <AT> gmail.com
|
||||
|
||||
;main application will be moved to the following location:
|
||||
APP_OFFSET=BOOTLOADER_SIZE
|
||||
|
||||
|
||||
.globl __start__stack
|
||||
;--------------------------------------------------------
|
||||
; Stack segment in internal ram
|
||||
;--------------------------------------------------------
|
||||
.area SSEG (DATA)
|
||||
__start__stack:
|
||||
.ds 1
|
||||
|
||||
;--------------------------------------------------------
|
||||
; custom interrupt vector -> redirect all isrs
|
||||
;--------------------------------------------------------
|
||||
.area VECTOR (ABS, CODE)
|
||||
.globl __interrupt_vect
|
||||
__interrupt_vect:
|
||||
ljmp __sdcc_gsinit_startup
|
||||
|
||||
;0x0003: RF TX done / RX ready
|
||||
ljmp #(0x0003 + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x000B: ADC end of conversion
|
||||
ljmp #(0x000B + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x0013: USART0 RX complete
|
||||
ljmp #(0x0013 + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x001B: USART1 RX complete
|
||||
ljmp #(0x001B + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x0023: AES enc/dec complete
|
||||
ljmp #(0x0023 + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x002B: Sleep Timer compare
|
||||
ljmp #(0x002B + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x0033; Port 2 inputs
|
||||
ljmp #(0x0033 + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x003B: USART0 TXC
|
||||
ljmp #(0x003B + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x0043: DMA transfer complete
|
||||
ljmp #(0x0043 + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x004B: Timer 1 (16-bit) capture/Compare/overflow
|
||||
ljmp #(0x004B + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x0053: Timer 2 (MAC Timer) overflow
|
||||
ljmp #(0x0053 + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x005B: Timer 3 (8-bit) capture/compare/overflow
|
||||
ljmp #(0x005B + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x0063: Timer 4 (8-bit) capture/compare/overflow
|
||||
ljmp #(0x0063 + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x006B: Port 0 inputs
|
||||
ljmp #(0x006B + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x0073: USART1 TXC
|
||||
ljmp #(0x0073 + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x007B: Port 1 inputs
|
||||
ljmp #(0x007B + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x0083: RF general interrupts
|
||||
ljmp #(0x0083 + APP_OFFSET)
|
||||
.ds 5
|
||||
|
||||
;0x008B: Watchdog overflow in timer mode
|
||||
ljmp #(0x008B + APP_OFFSET)
|
||||
|
||||
.globl __start__stack
|
||||
.area GSINIT0 (CODE)
|
||||
|
||||
__sdcc_gsinit_startup:
|
||||
mov sp,#__start__stack - 1
|
||||
|
||||
.area GSFINAL (CODE)
|
||||
ljmp _bootloader_main
|
||||
;return from main will lock up
|
||||
sjmp .
|
||||
45
OpenSky_BL/stylecheck/README
Normal file
45
OpenSky_BL/stylecheck/README
Normal file
@@ -0,0 +1,45 @@
|
||||
This is automated checker to make sure a C++ file follows Google's C++ style
|
||||
guide (https://google.github.io/styleguide/cppguide.html). As it
|
||||
heavily relies on regular expressions, cpplint.py won't catch all violations of
|
||||
the style guide and will very occasionally report a false positive. There is a
|
||||
list of things we currently don't handle very well at the top of cpplint.py,
|
||||
and we welcome patches to improve it.
|
||||
|
||||
The linting tool takes a list of files as input. For full usage instructions,
|
||||
please see the output of:
|
||||
|
||||
./cpplint.py --help
|
||||
|
||||
Unit tests are provided in cpplint_unittest.py. This file can safely be ignored
|
||||
by end users who have downloaded this package and only want to run the lint
|
||||
tool.
|
||||
|
||||
---
|
||||
|
||||
cpplint.py and its corresponding unit tests are Copyright (C) 2009 Google Inc.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
* Neither the name of Google Inc. nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
6122
OpenSky_BL/stylecheck/cpplint.py
vendored
Executable file
6122
OpenSky_BL/stylecheck/cpplint.py
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1
OpenSky_BL/stylecheck/cpplint_test_header.h
Normal file
1
OpenSky_BL/stylecheck/cpplint_test_header.h
Normal file
@@ -0,0 +1 @@
|
||||
// A test header for cpplint_unittest.py.
|
||||
5645
OpenSky_BL/stylecheck/cpplint_unittest.py
Executable file
5645
OpenSky_BL/stylecheck/cpplint_unittest.py
Executable file
File diff suppressed because it is too large
Load Diff
206
OpenSky_BL/uart.c
Normal file
206
OpenSky_BL/uart.c
Normal file
@@ -0,0 +1,206 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
|
||||
#include "uart.h"
|
||||
#include "config.h"
|
||||
#include "led.h"
|
||||
#include "cc25xx.h"
|
||||
|
||||
|
||||
#if (BOOTLOADER_UART_NUM == 0)
|
||||
#define UxBAUD U0BAUD
|
||||
#define UxGCR U0GCR
|
||||
#define UxGCR_ORDER U0GCR_ORDER
|
||||
#define UxCSR U0CSR
|
||||
#define UxCSR_TX_BYTE U0CSR_TX_BYTE
|
||||
#define UxUCR U0UCR
|
||||
#define UxDBUF U0DBUF
|
||||
#define URXxIF URX0IF
|
||||
#define UTXxIF UTX0IF
|
||||
#else
|
||||
#define UxBAUD U1BAUD
|
||||
#define UxGCR U1GCR
|
||||
#define UxGCR_ORDER U1GCR_ORDER
|
||||
#define UxCSR U1CSR
|
||||
#define UxCSR_TX_BYTE U1CSR_TX_BYTE
|
||||
#define UxUCR U1UCR
|
||||
#define UxDBUF U1DBUF
|
||||
#define URXxIF URX1IF
|
||||
#define UTXxIF UTX1IF
|
||||
#endif // BOOTLOADER_UART
|
||||
|
||||
void uart_init(void) {
|
||||
__xdata union uart_config_t uart_config;
|
||||
|
||||
#if ((BOOTLOADER_UART_NUM) == 0) && ((BOOTLOADER_UART_PORT) == 0)
|
||||
// -> USART0_P0
|
||||
// use ALT1 -> Clear flag -> P0_3 = TX / P0_2 = RX
|
||||
PERCFG &= ~(PERCFG_U0CFG);
|
||||
|
||||
// configure pins as peripheral:
|
||||
P0SEL |= (1<<3) | (1<<2);
|
||||
|
||||
// make sure all P1 pins switch to normal GPIO
|
||||
P1SEL &= ~(0x3C);
|
||||
|
||||
// make tx pin output:
|
||||
P0DIR |= (1<<3);
|
||||
#elif ((BOOTLOADER_UART_NUM) == 0) && ((BOOTLOADER_UART_PORT) == 1)
|
||||
// -> USART0_P1
|
||||
// use ALT2 -> Set flag -> P1_5 = TX / P1_4 = RX
|
||||
PERCFG |= (PERCFG_U0CFG);
|
||||
|
||||
// configure pins as peripheral:
|
||||
P1SEL |= (1<<5) | (1<<4);
|
||||
|
||||
// make sure all P0 pins switch to normal GPIO
|
||||
P0SEL &= ~(0x3C);
|
||||
|
||||
// make tx pin output:
|
||||
P1DIR |= (1<<5);
|
||||
#elif ((BOOTLOADER_UART_NUM) == 1) && ((BOOTLOADER_UART_PORT) == 0)
|
||||
// -> USART1_P0
|
||||
// use ALT1 -> Clear flag -> P0_4 = TX / P0_5 = RX
|
||||
PERCFG &= ~(PERCFG_U1CFG);
|
||||
|
||||
// USART1 has priority when USART0 is also enabled
|
||||
P2DIR = (P2DIR & 0x3F) | 0b01000000;
|
||||
|
||||
// configure pins as peripheral:
|
||||
P0SEL |= (1<<4) | (1<<5);
|
||||
|
||||
// make sure all P1 pins switch to normal GPIO
|
||||
P1SEL &= ~(0xF0);
|
||||
|
||||
// make tx pin output:
|
||||
P0DIR |= (1<<4);
|
||||
#elif ((BOOTLOADER_UART_NUM) == 1) && ((BOOTLOADER_UART_PORT) == 1)
|
||||
// -> USART1_P1
|
||||
// use ALT2 -> set flag -> P1_6 = TX / P1_7 = RX
|
||||
PERCFG |= (PERCFG_U1CFG);
|
||||
|
||||
// USART1 has priority when USART0 is also enabled
|
||||
P2DIR = (P2DIR & 0x3F) | 0b01000000;
|
||||
|
||||
// configure pins as peripheral:
|
||||
P1SEL |= (1<<6) | (1<<7);
|
||||
|
||||
// make sure all P0 pins switch to normal GPIO
|
||||
P0SEL &= ~(0x3C);
|
||||
|
||||
// make tx pin output:
|
||||
P1DIR |= (1<<6);
|
||||
#else
|
||||
#error "ERROR: UNSUPPORTED DEBUG UART"
|
||||
#endif // BOOTLOADER_UART_*
|
||||
|
||||
// this assumes cpu runs from XOSC (26mhz) !
|
||||
// set baudrate
|
||||
UxBAUD = UART_BAUD_M;
|
||||
UxGCR = (UxGCR & ~0x1F) | (UART_BAUD_E);
|
||||
|
||||
// set up config
|
||||
#if BOOTLOADER_UART_INVERTED
|
||||
// this is a really nice feature of the cc2510:
|
||||
// we can invert the idle level of the usart
|
||||
// by setting STOP to zero. by inverting
|
||||
// the parity, the startbit, and the data
|
||||
// we can effectively invert the usart in software :)
|
||||
uart_config.bit.START = 1; // startbit level = low
|
||||
uart_config.bit.STOP = 0; // stopbit level = high
|
||||
uart_config.bit.D9 = 1; // UNEven parity
|
||||
#else
|
||||
// standard usart, non-inverted mode
|
||||
uart_config.bit.START = 0; // startbit level = low
|
||||
uart_config.bit.STOP = 1; // stopbit level = high
|
||||
uart_config.bit.D9 = 0; // Even parity
|
||||
#endif // BOOTLOADER_UART_INVERTED
|
||||
|
||||
#if BOOTLOADER_UART_USE_2STOPBITS
|
||||
uart_config.bit.SPB = 1; // 2 stopbit
|
||||
#else
|
||||
uart_config.bit.SPB = 0; // 1 stopbit
|
||||
#endif // BOOTLOADER_UART_USE_2STOPBITS
|
||||
|
||||
#if BOOTLOADER_UART_USE_PARITY
|
||||
// use parity
|
||||
uart_config.bit.PARITY = 1; // 1 = parity enabled, D9=0 -> even parity
|
||||
uart_config.bit.BIT9 = 1; // 8+1 parity bit
|
||||
#else
|
||||
// no parity
|
||||
uart_config.bit.PARITY = 0; // no parity
|
||||
uart_config.bit.BIT9 = 0; // 8+0 parity bit
|
||||
#endif // BOOTLOADER_USE_PARITY
|
||||
|
||||
uart_config.bit.FLOW = 0; // no hw flow control
|
||||
uart_config.bit.ORDER = 0; // lsb first
|
||||
|
||||
// enable uart mode
|
||||
UxCSR |= 0x80;
|
||||
|
||||
// store config to UxUCR register
|
||||
UxUCR = uart_config.byte & (0x7F);
|
||||
|
||||
// store config to UxGCR: (msb/lsb)
|
||||
if (uart_config.bit.ORDER) {
|
||||
UxGCR |= UxGCR_ORDER;
|
||||
} else {
|
||||
UxGCR &= ~UxGCR_ORDER;
|
||||
}
|
||||
|
||||
// enable receiver
|
||||
UxCSR |= 0x40;
|
||||
}
|
||||
|
||||
uint8_t uart_getc(void) {
|
||||
uint8_t res = 0;
|
||||
|
||||
led_green_toggle();
|
||||
|
||||
// wait for RX
|
||||
while (!URXxIF) {}
|
||||
|
||||
// fetch data
|
||||
#if BOOTLOADER_UART_INVERTED
|
||||
res = 0xFF ^ UxDBUF;
|
||||
#else
|
||||
res = UxDBUF;
|
||||
#endif // BOOTLOADER_UART_INVERTED
|
||||
|
||||
// clear flag
|
||||
URXxIF = 0;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void uart_putc(uint8_t c) {
|
||||
UTXxIF = 0;
|
||||
|
||||
#if BOOTLOADER_UART_INVERTED
|
||||
UxDBUF = 0xFF ^ c;
|
||||
#else
|
||||
UxDBUF = c;
|
||||
#endif // BOOTLOADER_UART_INVERTED
|
||||
|
||||
led_red_toggle();
|
||||
|
||||
while (!UTXxIF) {}
|
||||
UTXxIF = 0;
|
||||
}
|
||||
|
||||
71
OpenSky_BL/uart.h
Normal file
71
OpenSky_BL/uart.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright 2016 fishpepper <AT> gmail.com
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
author: fishpepper <AT> gmail.com
|
||||
*/
|
||||
#ifndef UART_H_
|
||||
#define UART_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "config.h"
|
||||
|
||||
// for a 26MHz Crystal:
|
||||
#define CC2510_BAUD_M_115200 34
|
||||
#define CC2510_BAUD_E_115200 12
|
||||
#define CC2510_BAUD_M_57600 34
|
||||
#define CC2510_BAUD_E_57600 11
|
||||
// best match for 100kbit/s = 99975.5859375 bit/s
|
||||
// baudrate = (((256.0 + baud_m)*2.0**baud_e) / (2**28)) * 26000000.0
|
||||
#define CC2510_BAUD_E_100000 11
|
||||
#define CC2510_BAUD_M_100000 248
|
||||
|
||||
|
||||
// set baudrate:
|
||||
#if (BOOTLOADER_UART_BAUDRATE == 57600)
|
||||
#define UART_BAUD_M CC2510_BAUD_M_57600
|
||||
#define UART_BAUD_E CC2510_BAUD_E_57600
|
||||
#elif (BOOTLOADER_UART_BAUDRATE == 115200)
|
||||
#define UART_BAUD_M CC2510_BAUD_M_115200
|
||||
#define UART_BAUD_E CC2510_BAUD_E_115200
|
||||
#elif (BOOTLOADER_UART_BAUDRATE == 100000)
|
||||
#define UART_BAUD_M CC2510_BAUD_M_100000
|
||||
#define UART_BAUD_E CC2510_BAUD_E_100000
|
||||
#else
|
||||
#error INVALID BAUDRATE SELECTED ! BOOTLOADER_UART_BAUDRATE
|
||||
#endif // BOOTLOADER_UART_BAUDRATE
|
||||
|
||||
|
||||
void uart_init(void);
|
||||
|
||||
union uart_config_t{
|
||||
uint8_t byte;
|
||||
struct {
|
||||
uint8_t START : 1; // start bit level
|
||||
uint8_t STOP : 1; // stop bit level
|
||||
uint8_t SPB : 1; // stop bits (0=1, 1=2)
|
||||
uint8_t PARITY: 1; // parity (on/off)
|
||||
uint8_t BIT9 : 1; // 9 bit mode
|
||||
uint8_t D9 : 1; // 9th bit level or parity type
|
||||
uint8_t FLOW : 1; // flow control
|
||||
uint8_t ORDER : 1; // data bit order (LSB or MSB first)
|
||||
} bit;
|
||||
};
|
||||
|
||||
uint8_t uart_getc(void);
|
||||
void uart_putc(uint8_t c);
|
||||
|
||||
|
||||
#endif // UART_H_
|
||||
Reference in New Issue
Block a user