1
0
Fork 0

arduino-0018-windows

This commit is contained in:
orange 2010-03-30 21:53:44 +02:00
parent 157fd6f1a1
commit f39fc49523
5182 changed files with 950586 additions and 0 deletions

View file

@ -0,0 +1,15 @@
#
# $Id: AUTHORS,v 1.4 2003/07/24 16:42:39 troth Exp $
#
Main Developer:
Theodore A. Roth <troth@openavr.org>
Contributors:
Ken Restivo <ken@246gt.com>
Reinhard Jessich <reinhard.jessich@telering.at>
Josef Angermeier <josef.angermeier@web.de>
See the ChangeLog file for more contributions.

View file

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) 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
this service 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 make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. 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.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
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
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the 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 a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE 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.
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
convey 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 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision 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, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This 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 Library General
Public License instead of this License.

View file

@ -0,0 +1,409 @@
2008-03-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* configure.ac: Bump version for 0.1.2.5.
2008-03-16 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* src/avrcore.c: Make interrupt slot numbers unsigned int
rather than int, to avoid a GCC 4.x warning.
* src/avrcore.h: (Ditto.)
* src/intvects.h: (Ditto.)
* src/uart.c: (Ditto.)
* src/uart.h: (Ditto.)
2008-03-09 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* configure.ac: Bump version date to indicate post-release
0.1.2.4.
2008-03-09 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* src/disp/disp.c (disp_parse_packet): initialize areg to work
around GCC bug 34793.
* configure.ac: Bump version for release 0.1.2.4
2008-01-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* configure.ac: Bump version date to indicate post-release
0.1.2.3.
2008-01-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* configure.ac: Change version to 0.1.2.3, in preparation of
a new bugfix release.
2008-01-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Some Cygwin fixes:
* src/gdbserver.c: Partially revert the change from rev 1.51;
allocating a 1 MB buffer off the stack turned out to cause a
Cygwin stack overflow so reduce MAX_BUF to 100000.
* test_c/Makefile.am: use $(EXEEXT) for the default names
of ELF files as generated by the linker. Evaluates to an
empty string under Unix, and to .exe under Cygwin.
2008-01-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
bug #11929: simulavr-disp displays garbage characters after
"Reserved"
* src/disp/disp.c (disp_print_io_reg_name): Correctly delimit the
curses field width for the IO register name display.
2008-01-07 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* configure.ac: De-support building the PS documentation.
* configure.ac: Apply quotes to macro TROTH_ENABLE_TESTS to
get rid off an aclocal warning.
* doc/Makefile.am: De-support building the PS documentation,
fix the build sequence for the remaining documentation so
a "make" now correctly builds everything selected, and
"make install" just installs it. Correctly detect the
multitude of options about how different version of
texi2html -split_node could drop their output files, and
act appropriately (heavily borrowed from avrdude).
* src/avrcore.c: Yet another XRAM fix: if no XRAM is present,
set xram_end to sram_end rather than to 0.
2008-01-06 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* src/avrcore.c: Replace "static inline" declarations by just
"static" ones, and leave it to the compiler whether it actually
wants to inline them. This avoids compiler warnings depending
on the compiler version, eventually becoming fatal due to the
-Werror suggested.
* src/decoder.c: (Ditto.)
* src/memory.c: (Ditto.)
* src/register.c: (Ditto.)
2008-01-06 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
[Thanks to Peeter Vois]
patch #4623: making simulavr to compile under Fedora Core 4
* src/gdbserver.c: Add a couple of (char *) typecasts.
2008-01-06 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
[Thanks to Peeter Vois]
patch #4624: socket buffer increased from 400 to 1000000
* src/gdbserver.c: Bump MAX_BUF from 400 to 1000000.
2008-01-06 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
[Thanks to Benjamin Benz <bbe@heise.de>]
patch #4819: Added ATMega32
* configure.ac: Bump version date.
* src/Makefile.am: add defn/mega32.h
* src/devsupp.c: add ATmega32
* src/intvects.c: (Ditto.)
* src/defn/mega32.h: New file.
* simulavr.1.in: Add ATmega32.
2008-01-06 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* doc/doxygen.conf.in: update through doxygen -u; enable
LaTeX batchmode.
* doc/texinfo.tex: Update from the teTeX distribution, so the
current (pdf)latex no longer fails to build a DVI file.
2008-01-05 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* configure.ac: bump version.
2008-01-05 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Fix the external SRAM handling. This finally gets rid of all
the ``Attempt to read invalid mem addr'' warnings during a
memory dump.
* src/avrcore.c: Call mem_new() with the appropriate xram
size rather than assuming it's always present. Attach the
XRAM area (for devices that support it) within
avr_core_construct().
* src/avrcore.h (struct _AvrCore): Add xram.
* src/devsupp.c: Add size.xram, and dev_supp_get_xram_sz().
* src/devsupp.h: Add dev_supp_get_xram_sz().
* src/memory.c (mem_attach): Fix an off-by-one error when
complaining about an address being out of range.
* src/defn/90s4414.h: Add xram.
* src/defn/90s8515.h: (Ditto.)
* src/defn/mega103.h: (Ditto.)
* src/defn/mega128.h: (Ditto.)
2008-01-05 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* src/memory.c (mem_sram_dump_core): correctly calculate the
internal and external SRAM sizes when calling mem_sram_display().
This fixes a segfault resulting from accessing mem->cell[] out
of bounds.
2008-01-04 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* src/avrcore.c: set core->eeprom to NULL to indicate there's
no EEPROM (yet).
2008-01-04 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* bootstrap: Bump requirements to automake 1.9, and
autoconf 2.59, respectively, as these superseded versions
1.7 and 2.57 without causing incompatibilities.
2005-01-13 Klaus Rudolph <lts-rudolph@gmx.de>
[Thanks to Joerg Wunsch]
* src/avrcore.c bugfix: bugfix: devision by zero
2004-09-15 Theodore A. Roth <troth@openavr.org>
[Thanks to Nils Springob <nils@crazy-idea.de> for catching this.]
* configure.ac (AC_INIT): Bump version.
* src/defn/mega128.h: Fix PORTF addr.
2004-05-19 Theodore A. Roth <troth@openavr.org>
[Contributed by Alexander Stohr <Alexander.Stohr@gmx.de>]
* configure.ac (AC_INIT): Bump version.
* src/memory.c (mem_read): Increase verbosity of warning.
(mem_write): Ditto.
2004-04-16 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/avrcore.c (avr_core_construct): Don't call display_clock since
the display hasn't been opened yet.
* src/main.c (main): Call display_clock to send init cycles to display
after opening the display.
* src/main.c (parse_cmd_line): Update copyright year for -v option.
* test_asm/test_8515/Makefile.am (all-local): Fix to allow building
with gcc-3.4/binutils-2.15.
2004-04-15 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/Makefile.am (simulavr_SOURCES): Remove defn/43usb324.h.
2004-03-13 Theodore A. Roth <troth@openavr.org>
[Contributed by Keith Gudger <keith@atmel.com>]
* configure.ac (AC_INIT): Bump version.
* src/adc.c:
* src/adc.h:
* src/spi.c:
* src/spi.h:
* src/timers.c:
* src/timers.h:
* src/uart.c:
* src/uart.h:
* src/usb.c:
* src/usb.h:
* src/defn/43usb320.h:
* src/defn/43usb325.h:
* src/defn/43usb326.h:
* src/defn/43usb351.h:
* src/defn/43usb353.h:
* src/defn/43usb355.h:
Update to new vdev/memory infrastructure.
2004-03-11 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/disp-vcd/vcd.c:
* src/disp-vcd/vcd.h:
Don't inline vcd_set_clock.
2004-02-25 Theodore A. Roth <troth@openavr.org>
* src/decoder.c (avr_op_BREAK): Print out a message whenever a break
point is hit.
* src/disp-vcd/config_scanner.l: Fix flex compile problem.
2004-02-25 Theodore A. Roth <troth@openavr.org>
[Contributed by Keith Gudger <keith@atmel.com>]
* src/devsupp.c:
* src/intvects.c:
* src/defn/43usb320.h:
* src/defn/43usb324.h:
* src/defn/43usb325.h:
* src/defn/43usb326.h:
* src/defn/43usb351.h:
* src/defn/43usb353.h:
* src/defn/43usb355.h:
Drop support for 324 devices.
Stub out the usb device register names.
2004-02-13 Theodore A. Roth <troth@openavr.org>
[Thanks to John Regehr <regehr@cs.utah.edu> for reporting this.]
* src/avrcore.c (avr_run_core): Avoid division by zero when calculating
the executed instructions and clock cycles.
2004-02-13 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/disp-vcd/config_scanner.l: Disable generation of yyunput()
function by flex.
2004-02-01 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* misc/gpl_header: Update copyright year.
* misc/gpl_header_c: Ditto.
* misc/gpl_header_h: Ditto.
* misc/gpl_header_py: Ditto.
* misc/defn_tmpl_h: New file.
* src/Makefile.am (simulavr_SOURCES): Add defn dir headers.
* src/devsupp.c (defn_at90s1200): Move def to header.
(defn_at90s2313): Ditto.
(defn_at90s4414): Ditto.
(defn_at90s8515): Ditto.
(defn_atmega8): Ditto.
(defn_atmega16): Ditto.
(defn_atmega103): Ditto.
(defn_atmega128): Ditto.
(defn_at43usb351): Ditto.
(defn_at43usb353): Ditto.
(defn_at43usb355): Ditto.
(defn_at43usb320): Ditto.
(defn_at43usb324): Ditto.
(defn_at43usb325): Ditto.
(defn_at43usb326): Ditto.
* src/defn/43usb320.h: New file.
* src/defn/43usb324.h: New file.
* src/defn/43usb325.h: New file.
* src/defn/43usb326.h: New file.
* src/defn/43usb351.h: New file.
* src/defn/43usb353.h: New file.
* src/defn/43usb355.h: New file.
* src/defn/90s1200.h: New file.
* src/defn/90s2313.h: New file.
* src/defn/90s4414.h: New file.
* src/defn/90s8515.h: New file.
* src/defn/mega103.h: New file.
* src/defn/mega128.h: New file.
* src/defn/mega16.h: New file.
* src/defn/mega8.h: New file.
2004-01-29 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/adc.c:
* src/adc.h:
* src/avrcore.c:
* src/avrcore.h:
* src/avrerror.c:
* src/device.c:
* src/devsupp.c:
* src/devsupp.h:
* src/eeprom.c:
* src/main.c:
* src/memory.c:
* src/memory.h:
* src/ports.c:
* src/ports.h:
* src/register.c:
* src/spi.c:
* src/spi.h:
* src/sram.c:
* src/stack.c:
* src/stack.h:
* src/timers.c:
* src/timers.h:
* src/uart.c:
* src/uart.h:
* src/usb.c:
* src/vdevs.h:
Convert Memory from a linked list to an array of memory cells. This
gives a significant improvement in speed (more than 50% when running
the test/deep_frame.c program).
Convert core constructor to use new structures previously committed.
There's still alot of registers vdevs that need updated to work
properly with all this changes.
The ports are now much more generic under the new memory attachment
system and all the specfic ports are gone.
The "find vdev by name" mechanism is gone since it was much too
expensive.
A single VDevice can now be installed at many discontinuous memory
addresses.
2004-01-28 Theodore A. Roth <troth@openavr.org>
* src/devsupp.c (struct io_reg_defn): Define.
(IO_REG_DEFN_TERMINATOR): Define.
(struct _DevSuppDefn): Add io_reg array field.
(defn_at90s1200): Add io_reg initializer.
(defn_at90s2313): Ditto.
(defn_at90s4414): Ditto.
(defn_at90s8515): Ditto.
(defn_atmega8): Ditto.
(defn_atmega16): Ditto.
(defn_atmega103): Ditto.
(defn_atmega123): Ditto.
(defn_at43usb351): Ditto.
(defn_at43usb353): Ditto.
(defn_at43usb355): Ditto.
(defn_at43usb320): Ditto.
(defn_at43usb324): Ditto.
(defn_at43usb325): Ditto.
(defn_at43usb326): Ditto.
* src/ports.c (port_create): Stub out new function.
* src/register.c (sreg_create): Ditto.
(rampz_create): Ditto.
* src/stack.c (sp_create): Ditto.
* src/ports.h (port_create): Prototype.
* src/register.h (sreg_create): Ditto.
(rampz_create): Ditto.
* src/stack.h (sp_create): Ditto.
* src/vdevs.h (VDevCreate): New typedef.
(VDevFP_AddAddr): Ditto.
2004-01-28 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* README.mem_vdev: Updated.
* misc/io_gen.py: New file.
* test_c/deep_frame.c: Modified to be a little more useful in testing.
2004-01-18 Theodore A. Roth <troth@openavr.org>
* Released 0.1.2.1.
2004-01-18 Theodore A. Roth <troth@openavr.org>
* Makefile.am: Update copyright year.
(EXTRA_DIST): Add ChangeLog-200[123] files.
(install_aux_files): Ditto.
* configure.ac (AC_INIT): Set version to 0.1.2.1.
2004-01-17 Theodore A. Roth <troth@openavr.org>
* Released 0.1.2.
2004-01-17 Theodore A. Roth <troth@openavr.org>
* configure.ac: Update copyright year.
(AC_INIT): Set version to 0.1.2.
* doc/simulavr.texi: Update copyright year.
2004-01-01 Theodore A. Roth <troth@openavr.org>
[Contributed by Keith Gudger <keith@atmel.com>]
* configure.ac (AC_INIT): Bump version.
* src/Makefile.am (simulavr_SOURCES): Add uart.c, uart.h and usb.c.
* src/devsupp.c: Add uart and usb support.
* src/uart.c: New file.
* src/uart.h: New file.
* src/usb.c: New file.
2004-01-01 Theodore A. Roth <troth@openavr.org>
* ChangeLog: Cycle ChangeLog file.
* ChangeLog-2001: New file.
* ChangeLog-2002: New file.
* ChangeLog-2003: New file.

View file

@ -0,0 +1,767 @@
2001-12-31 Theodore A. Roth <troth@openavr.org>
* gdb-patches/README, gdb-patches/patcher.sh:
Updated to refer to gdb-5.1 patches. Removed references to gdb-5.0
patches.
* gdb-patches/gdb-5.0-avr-patch-0.1,
gdb-patches/gdb-5.0-avr-troth-patch:
Removed obsolete gdb-5.0 patches.
* doc/Makefile.am, Makefile.am, Makefile_AVR_Rules:
Fixes to allow building from separate directory. (thanks to
Reinhard Jessich)
2001-12-30 Theodore A. Roth <troth@openavr.org>
* ChangeLog: Updated.
* Released version 0.0.12.
* ChangeLog, configure.in: Set version to 0.0.12
* Makefile_AVR_Rules: Added -h and --stabs when generating .lst files.
* doc/simulavr.texi:
Documented instruction decoder.
Misc cleanups.
* src/avr.h, src/avrcore.c, src/eeprom.c, src/register.c,
src/timers.c, src/vdevs.h:
Renamed CB_T/CB_FP_T to CallBack/CallBack_FP. Twuz a silly a name.
* src/disp/disp.c: Fixed bug: sreg bit display was reversed.
2001-12-29 Theodore A. Roth <troth@openavr.org>
* src/decoder.c:
Fixed bug: some of the LD/LDD cases I thought were undefined, are
defined.
2001-12-28 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c: When dumping core output, print PC and PC*2.
2001-12-27 Theodore A. Roth <troth@openavr.org>
* src/decoder.c: Fixed bug in SBIW handler: res was byte, now is word.
2001-12-22 Theodore A. Roth <troth@openavr.org>
* ChangeLog: Updated.
* ChangeLog: Tagged and released version 0.0.11.
* doc/simulavr.texi: Fixed some typos.
* ProjSummary: Fixed some typos.
* src/devsupp.c:
Fixed compiler warning about potential uninitialized variables.
* ChangeLog: Removed duplicate entries.
* configure.in: Set version to 0.0.11.
* gdb-patches/README, ChangeLog, TODO: Updated.
2001-12-21 Theodore A. Roth <troth@openavr.org>
* src/disp/disp.c:
Made pipe fd nonblocking to fix problem with blocking read.
Fixed wrefresh()es so that cursor is always in sram window.
* src/Makefile.am: Fixed dtest dependencies.
* src/main.c:
Notify user if they didn't spec a program to run and sim expects one.
* src/avr.h, src/stack.c: fixed stack pointer display update ommision.
* src/disp/disp.c:
Changed main loop to use select() for multiplexing the inputs.
2001-12-20 Theodore A. Roth <troth@openavr.org>
* src/decoder.c:
Changed how sreg is set in opcode handlers so as to only send display
sreg changes once per handler.
* src/avr.h, src/register.c, src/utils.c:
Moved set_bit_in_byte() to utils.c and made it public.
Add set_bit_in_word().
* src/avrcore.c: Print out PC and (PC*2) when -D option is given.
* src/decoder.c:
Fixed bug: Z flag wasn't using previous value in avr_op_CPC
instruction.
2001-12-19 Theodore A. Roth <troth@openavr.org>
* src/disp/Makefile.am, src/disp/disp.c, src/Makefile.am,
src/avr.h, src/avrcore.c, src/display.c, src/display.h,
src/dtest.c, src/eeprom.c, src/flash.c, src/main.c, src/memory.c,
src/register.c, src/sram.c, src/vdevs.h, doc/simulavr.texi,
config/enable_curses.m4, TODO, configure.in:
Added curses based register and memory display.
* ChangeLog: updated
2001-12-16 Theodore A. Roth <troth@openavr.org>
* misc/gpl_header_h:
Changed multiple inclusion macros to reduce potential for clashes.
* src/decoder.c:
Fixed a bug in the CP instruction which was clobbering a register.
2001-12-11 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c, src/memory.c:
Fixed potential memory leaks due to incorrect object referencing.
* src/avr.h, src/device.c, src/memory.c:
Changed memory vdev list to use DList.
* src/utils.c: Added dlist_add_head() function.
* src/vdevs.h: Typedef'd an enum which wasn't.
* TODO: Updated
* src/avr.h, src/avrcore.c, src/devsupp.c, src/devsupp.h:
Simplified mechanism for adding support for new microcontroller
devices.
* src/vdevs.h: Fixed a typo in a comment.
* Makefile.am: Added ProjSummary to EXTRA_DIST.
* src/devsupp.c, src/devsupp.h: Added files.
Preparing to rework core-creation design to make adding support for new
devices easier.
* src/avrcore.c: Moved device creation functions to devsupp.c.
* src/main.c: Added -L, --list-devices command line option.
Changed to use devsupp.[ch] interface.
* src/avr.h, src/gdb.h, src/vdevs.h:
Changed multiple inclusion macros to reduce potential for clashes.
* src/Makefile.am: Added devsupp.h to sources.
* src/Makefile.am: Added gdb.c to EXTRA_DIST.
Added devsupp.c to sources.
2001-12-10 Theodore A. Roth <troth@openavr.org>
* ChangeLog:
Converted to format which allows use of emacs to update from cvs logs.
* ChangeLog, TODO, configure.in: 0.0.11-pre2
* Makefile_AVR_Rules:
When generating .lst files for avr, dump .data section too.
* src/stack.c, src/storage.c, src/timers.c, src/utils.c,
src/avrcore.c, src/avrerror.c, src/avrmalloc.c, src/eeprom.c,
src/flash.c, src/gdb.c, src/gdbserver.c, src/ports.c,
src/register.c: Removed newlines from error message strings (do it
in _avr_error()).
* src/decoder.c:
Removed newlines from error message strings (do it in _avr_error()).
Fixed lpm/elpm addressing problem. (Is the fix right though?)
* src/main.c:
Removed newlines from error message strings (do it in _avr_error()).
Dump core to a file instead of stderr.
Dump core whenever avr_errror() is called.
2001-12-09 Theodore A. Roth <troth@openavr.org>
* ChangeLog, TODO, configure.in: 0.0.11-pre1
* test_c/Makefile.am, test_c/deep_frame.c:
Added deep_frame.c test program to project.
* test_c/big_str.h, test_c/demo.c:
Moved ugly string into big_str.h header.
* src/avr.h, src/avrcore.c, src/gdbserver.c, src/memory.c:
Added support for gdb querying io registers.
2001-12-08 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c:
Added support for writing registers via gdb remote protocol.
2001-12-07 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c:
Changed DATA_OFFSET to match what you get from avr-objdump output.
* src/utils.c:
Fixed: Adding dlist node after head would be immediately unref'd.
2001-12-06 Theodore A. Roth <troth@openavr.org>
* TODO: Updated.
* doc/simulavr.texi: Added object examples and discussion.
* ChangeLog: Updated.
* src/avrmalloc.c: Added newlines to error message string.
Fixed avr_strdup so that it checks ptr before returning.
* Makefile.am: Formating cleanup.
* src/avrclass.c: Added comments for all the functions.
* doc/simulavr.texi: Updated documentation.
* doc/Makefile.am: Added html and pdf generation rules.
2001-12-05 Theodore A. Roth <troth@openavr.org>
* src/avr.h, src/utils.c: Changed some dlist names for consistency
* test_c/Makefile.am, test_c/demo_kr.c: Added demo_kr.c
* test_c/demo.c: cond-compile out uglystring.
* gdb-patches/README: updated
* gdb-patches/gdb-5.0-avr-troth-patch:
synced up with autogenerated patch
* gdb-patches/get_gdb_patches.sh: synced up with gdb cvs tree
* src/avrcore.c: Plugged potential memory leak.
2001-12-04 Theodore A. Roth <troth@openavr.org>
* src/avr.h, src/avrcore.c, src/utils.c:
Changed callback mechanism to use generic DList linked list.
* src/avrcore.c, src/utils.c:
Moved str2ffmt() and get_program_time() from avrcore.c to utils.c.
* src/Makefile.am, src/avr.h, src/avrcore.c, src/utils.c:
Added generic doubly, linked list (DList).
Changed break point list to use DList.
2001-12-03 Theodore A. Roth <troth@openavr.org>
* gdb-patches/get_gdb_patches.sh:
Corrected comments explaining how to setup my gdb cvs.
2001-12-02 Theodore A. Roth <troth@openavr.org>
* TODO, INSTALL, README, README.gdb, README.opcodes: Updated.
* gdb-patches/README, gdb-patches/gdb-5.0-avr-gdbserver-patch,
gdb-patches/gdb-5.0-avr-troth-patch,
gdb-patches/get_gdb_patches.sh, gdb-patches/patcher.sh: Updated to
handled my gdb branching scheme.
* src/memory.c:
Dumping core now outputs io register info in more readable format.
2001-11-30 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c: Really fixed accept(2) failure mode problem.
* gdb-patches/gdb-5.0-avr-troth-patch:
Renaming of gdb-5.0-avr-gdbserver-patch to gdb-5.0-avr-troth-patch.
* gdb-patches/get_gdb_patches.sh:
Script for creating patches for gdb-5.0 from my gdb cvs tree.
* src/Makefile.am: Delete symbolic links on a dist clean.
* src/gdbserver.c:
Made addrLength volatile so gcc won't compile it away when optimizing.
2001-11-29 Theodore A. Roth <troth@openavr.org>
* Makefile.am: Moved doc dir to end of subdirs list.
* src/Makefile.am, src/avr.h, src/avrcore.c, src/avrmalloc.c,
src/gdb.c, src/gdb.h, src/gdbserver.c, src/main.c, src/memory.c:
Deprecate gdb.c in favor of gdbserver.c - adds support for talking
to gdb without the need for gdbserver. Improved breakpoint
support.
2001-11-25 Theodore A. Roth <troth@openavr.org>
* src/main.c: Made usage message values more concise.
2001-11-24 Theodore A. Roth <troth@openavr.org>
* src/main.c, ChangeLog: Added -v, -version command line options.
* ChangeLog, configure.in: Set version to 0.0.10
* src/avr.h, config/acconfig.h, Makefile.am, bootstrap, configure.in:
Use acconfig.h to set byte, word, dword and qword sizes.
2001-11-22 Theodore A. Roth <troth@openavr.org>
* TODO: Formatting and added more ac macro notes.
2001-11-21 Theodore A. Roth <troth@openavr.org>
* Makefile.am: Added Makefile_AVR_Rules. Fixed typo.
* Makefile.am: Added patcher.sh to EXTRA_DIST.
* Makefile.am: Add -p to mkdir on dist-hook.
* configure.in, test_c/Makefile.am,
test_asm/test_8515/8515def.inc, test_asm/test_8515/Makefile.am,
test_asm/test_8515/test_cntr.asm, test_asm/8515def.inc,
test_asm/Makefile.am, test_asm/test.asm, src/Makefile.am,
config/avr_binutils.m4, config/avr_cc.m4,
config/avr_libc_headers.m4, config/check_gnu_make.m4,
config/enable_tests.m4, ChangeLog, INSTALL, Makefile.am,
Makefile_AVR_Rules, README, TODO: Convertion to autotools for
build system.
* doc/Makefile.am, doc/simulavr.texi:
Added beginnings of texinfo based documentation.
2001-11-17 Theodore A. Roth <troth@openavr.org>
* src/avr.h, src/avrcore.c, src/flash.c, src/gdb.c:
Fixed to allow gdb to send odd memaddr or odd len on flash read/writes.
2001-11-16 Theodore A. Roth <troth@openavr.org>
* bootstrap: Added autotools bootstrap script.
* test_c/Makefile, test_asm/test_8515/Makefile, test_asm/Makefile,
src/Makefile, Makefile, setup.py, MANIFEST.in: Removed Makefiles
in convertions to gnu autotools.
* ChangeLog: updated.
* test_c/demo.c: Added a really long string to test PC wrapping.
* src/avr.h, src/avrcore.c:
Fixed problem with larger programs in which PC needed to wrap around.
* misc/gpl_header_c, misc/gpl_header_h:
Added gpl headers for c programs.
2001-11-14 Theodore A. Roth <troth@openavr.org>
* ChangeLog, MANIFEST.in, setup.py: Updated for version 0.0.8.
* gdb-patches/gdb-5.0-avr-gdbserver-patch: Fixed stepping bug.
Added version comment to head of file.
* gdb-patches/README: Added patcher.sh description.
Removed comment about bug in stepping.
* gdb-patches/patcher.sh:
Simple script to automate patching and installing avr-gdb.
* src/gdb.c: Commented out some diagnostic messages.
* Makefile: Added MANIFEST to clean rule.
* test_c/Makefile: Added *.lst to clean rule.
* Makefile: Added test_c to sub_dirs.
* src/gdb.h: Header file for gdb.c.
* ChangeLog: updated
* README.gdb: Readme file for controlling simulator with gdb
* src/gdb.c:
Support for running in gdb mode as an inferior of gdbserver.
* src/main.c: Added gdb mode.
* src/avrcore.c, src/avr.h: Added stack constants.
Added BREAK_POINT and INVALID_OPCODE constants.
Added break_pt field.
Added Program Memory Space Access Methods.
Added Break point access methods.
* src/stack.c:
Use STACK_POINTER_BASE and STACK_POINTER_SIZE instead of hardcoded
values in constructor.
* src/Makefile: Added gdb.c to main src list.
* test_c/Makefile: Generated .lst file by default.
* gdb-patches/README: Updated for first semi working gdb patch.
* gdb-patches/gdb-5.0-avr-gdbserver-patch:
Updated patch. Seems to be mostly working now.
2001-11-13 Theodore A. Roth <troth@openavr.org>
* gdb-patches/gdb-5.0-avr-gdbserver-patch:
Updated patch. Mostly works, but still not done.
2001-11-07 Theodore A. Roth <troth@openavr.org>
* MANIFEST.in, setup.py, test_c/Makefile, test_c/demo.c:
Added a simple avr C program to the project.
* src/main.c: Changed getopt() to getopt_long.
Added gdbserver mode option.
* gdb-patches/README, gdb-patches/gdb-5.0-avr-gdbserver-patch,
gdb-patches/gdb-5.0-avr-patch-0.1: Added gdb patches and README.
2001-11-02 Theodore A. Roth <troth@openavr.org>
* ChangeLog, TODO, harness.py: Updated.
Removed harness.py.
* src/avrcore.c: Print out how many clock cycles were executed.
* src/avrcore.c, src/timers.c, src/vdevs.h:
Added TIMSK, TIFR registers via TimerIntr_T class.
Added Timer/Counter 0 support.
Added ability to stop simulator with a Ctrl-C keyboard interrupt.
* src/main.c: Added -D command line option.
* src/ports.c: Eliminated possible use of uninitialized variable.
* src/avr.h: Added global_debug_inst_output.
* src/register.c: Got rid of a few unnecessary casts.
2001-11-01 Theodore A. Roth <troth@openavr.org>
* src/vdevs.h, src/register.c:
Added core field to VDevice class and removed core field from any
VDevice derived class.
* src/eeprom.c:
Added core field to VDevice class and removed core field from any
VDevice derived class.
Fixed contructor to use reset function correctly.
* src/device.c, src/avrcore.c, src/avr.h:
Added core field to VDevice class and removed core field from any
VDevice derived class.
* src/avr.h: Added comments to clk_cb and async_cb fields of core.
* src/avrcore.c:
Move get_program_time() out of avr_core_cb_exec. Now time val is passed
as argument to allow time to either mean clocks or system time.
* test_asm/test_8515/Makefile, test_asm/test_8515/test_toie0.asm,
test_asm/test_8515/test_toie0_2.asm: Added tests for timer/counter
0 interrupts.
2001-10-31 Theodore A. Roth <troth@openavr.org>
* INSTALL, README: Updated.
* setup.py: Updated version.
Modified so that it knows about move of python scripts into python dir.
* test_asm/Makefile, Makefile: Added depend rule.
* src/vdevs.h, src/register.c, src/eeprom.c, src/avrcore.c, src/avr.h:
Added async_cb to core struct: Now there are two callback lists in
the core. The old clk_cb list is only for callbacks that should be
called every clock cycle. The new async_cb list is for callbacks
that are called periodically even if the device is not being clocked.
Changed ClkCB -> CB_T, ClkCB_FP -> CB_FP_T to make the existing
callback code generic.
Removed the callback type field and methods.
Added CK and inst_CKS fields and methods.
Added async_cb methods.
2001-10-30 Theodore A. Roth <troth@openavr.org>
* src/decoder.c: Added inst_CKS setting to all opcode handlers.
* src/register.c:
Make sure that an installed toe_cb is removed after a reset.
* ChangeLog, TODO: Updated.
* src/vdevs.h: Split TimerIntr class into TIMSK and TIFR.
* src/timers.c: Code to handle timer/counter functionality.
* src/register.c: Removed TimerIntr comment.
* src/avr.h, src/avrcore.c: Added clk_cb type methods.
* src/Makefile: Added timers.c.
2001-10-29 Theodore A. Roth <troth@openavr.org>
* src/avr.h, src/avrcore.c, src/eeprom.c, src/register.c:
Added clock callback type distinctions.
* src/avr.h, src/avrcore.c, src/decoder.c, src/register.c, src/vdevs.h:
Encapsulation cleanups.
Renaming to make some functions more descriptive.
Added code to handle SLEEP modes via MCUCR.
* src/Makefile: Added NDEBUG to DEBUG_FLAGS.
Compile lib before main.
2001-10-26 Theodore A. Roth <troth@openavr.org>
* ChangeLog: updated
2001-10-21 Theodore A. Roth <troth@openavr.org>
* src/avr.h, src/avrcore.c, src/main.c, src/memory.c, src/ports.c,
src/vdevs.h, ChangeLog, TODO: Got io ports as general digital io
working.
* test_asm/test_8515/test_port.asm:
Rewrote to work correctly after testing on real hardware.
2001-10-19 Theodore A. Roth <troth@openavr.org>
* src/ports.c, src/vdevs.h: Simplified port code.
* test_asm/test_8515/test_port.asm: Added port test to project.
* setup.py: ver to 0.0.5
* src/Makefile, src/avrcore.c, src/ports.c, src/vdevs.h:
First cut at IO Ports.
* src/main.c: Added device type listing to usage function.
2001-10-18 Theodore A. Roth <troth@openavr.org>
* src/Makefile, src/avr.h, src/avrcore.c, src/intvects.c, src/main.c:
Added support for 2313 device.
* ChangeLog, TODO: Updated
* test_asm/test.asm: Removed some commented out code.
* src/register.c, src/vdevs.h: Starting timer/counter implementation.
2001-10-16 Theodore A. Roth <troth@openavr.org>
* src/avr.h, src/avrcore.c, src/register.c:
Added irq raise and clear functions.
* src/register.c: Use interrupts issue the reset.
* src/avrcore.c: Clear the interrupt flag after handling the interrupt.
* src/Makefile, src/avr.h, src/avrcore.c, src/intvects.c:
Added interrupt infrastructure.
* src/avr.h: Removed eeprom property from AvrCore struct.
* src/eeprom.c: Fixed a typo in a comment.
* src/avrcore.c, src/register.c, src/vdevs.h:
Renamed ascr -> acsr. That's the way it should have been named.
* src/eeprom.c: Fixed use of uninitialized local variable.
* TODO: updated
* MANIFEST.in: Explicitly added Makefile to test_asm/test_8515.
* test_asm/Makefile: Added tests to all rule.
* ChangeLog, setup.py: updated
* src/eeprom.c: Finished up the eeprom implementation.
* src/vdevs.h: Finished up eeprom implementation.
* src/register.c:
Changed clock callback functions to have data be AvrClass.
* src/avrcore.c: Changed callback result check to be more sane.
Moved debug print statement.
Updated eeprom_new arg lists.
* src/avr.h: Changed ClkCB_FP typedef args.
* Makefile: Added realclean rule.
* test_asm/test_8515/test_eeprom.asm: Program to test the eeprom code.
2001-10-15 Theodore A. Roth <troth@openavr.org>
* TODO, ChangeLog: updated
* test_asm/test_8515/test_stack.asm: Improve use of macros.
* setup.py: Updated version.
* src/main.c:
Added a global storage for the avrcore as an aid in debugging.
* src/vdevs.h: Completed wdtcr class.
* src/stack.c:
Added reset handler for mem based stack pointer virtual device.
* src/sram.c: Added reset handler.
* src/register.c: Added reset handlers.
Added wdtcr virtual device.
* src/memory.c, src/eeprom.c: Added reset handler.
* src/device.c: Added reset handler to VDevice.
* src/decoder.c: Completed wdr instruction handler.
Renamed opcode_FP to Opcode_FP.
* src/avrcore.c:
Improved get_program_time() to safely handle system clock rollovers.
Added state property to avrcore class.
Changed exec_instruction to exec_next_instruction and fixed bug in
which PC/opcode weren't updated in the right order.
Fixed bug in adding new nodes to clk_cb list.
Added wdtcr vdevice to device generators.
* src/avr.h: Added reset code.
Added watchdog control register based reset.
Reordered some typedefs for predeclarations.
Added state codes to avrcore class.
* test_asm/test_8515/test_wdr.asm, test_asm/test_8515/test_wdr2.asm:
Test files for wdr instruction and wdtcr functionality.
2001-10-13 Theodore A. Roth <troth@openavr.org>
* src/avr.h: Added program time to callback system.
* src/avrcore.c: Added program time to clock callback functions.
2001-10-12 Theodore A. Roth <troth@openavr.org>
* MANIFEST.in: Added asm include files
* src/register.c, src/vdevs.h: Added watchdog class.
* src/avrcore.c, src/avr.h: Added clock callback class.
* src/avrcore.c: Added ascr.
* src/register.c: Added ASCR methods.
Fixed mcucr destroy.
* src/vdevs.h: argument name changes.
* src/avrcore.c, src/device.c, src/eeprom.c, src/register.c:
* src/vdevs.h:
Got rid of some magic numbers.
Added mcucr vdevice.
* src/avr.h: Added name field to virtual devices.
Added avr_core_step(), mem_get_vdevice_by_{name,addr}() functions.
* src/avrcore.c: Added avr_core_step() function.
* src/eeprom.c: Added name to vdevice.
* src/memory.c: Added vdev lookup by addr and name functions.
Look up devices for core dump by name instead of address.
* src/register.c, src/sram.c, src/stack.c: Added name to vdevice.
* src/device.c: Added name field to vdevice.
* src/Makefile: Changed dependency generation.
2001-10-11 Theodore A. Roth <troth@openavr.org>
* src/vdevs.h: Added eecr mask.
Added analog comp device.
* src/eeprom.c: Added eecr mask.
* src/avrcore.c: Added eecr_mask.
* src/vdevs.h: Header for virtual devices.
* src/avr.h: Moved virtual devices to vdevs.h.
* src/avr.h, src/decoder.c: Made opcode handlers static.
* src/Makefile, src/avr.h, src/avrcore.c, src/eeprom.c,
* src/main.c, src/memory.c:
Added eeprom virtual device.
* src/avr.h, src/avrerror.c:
Modified message functions to output file and line numbers.
* src/Makefile:
Added conditional rules to allow compiling with or without
optimizations.
* MANIFEST.in, Makefile, setup.py: Distribution updates.
* README, TODO, harness.py: Updates.
* src/Makefile, src/avr.h, src/avrclass.c, src/avrcore.c,
src/avrerror.c, src/avrmalloc.c, src/decoder.c, src/device.c,
src/flash.c, src/main.c, src/memory.c, src/op_names.c,
src/register.c, src/sram.c, src/stack.c, src/storage.c: First
checkin of source for C coded simulator.
* test_asm/test_8515/test_blink.asm,
test_asm/test_8515/test_stack.asm, test_asm/8515def.inc,
test_asm/Makefile, test_asm/test.asm: Modified to work with avr-as
instead of Atmel's avrasm.
2001-10-01 Theodore A. Roth <troth@openavr.org>
* TODO: updated
* Makefile, setup.py, MANIFEST.in:
Updated to use setup.py and MANIFEST.in to build a distribution.
* ChangeLog, INSTALL: Added.
* harness.py: updated usage
* README, README.opcodes, TODO: updated
* Makefile, README, harness.py, setup.py, test_asm/Makefile:
Added GPL header.
* AUTHORS, COPYING, misc/gpl_header: Added.
* harness.py: Added Connections class for handling port connections.
* TODO, test_asm/test.asm: updated
2001-09-28 Theodore A. Roth <troth@openavr.org>
* MANIFEST.in, Makefile, README, README.opcodes, TODO, harness.py,
setup.py, test_asm/Makefile, test_asm/test.asm,
test_asm/test_8515/test_blink.asm,
test_asm/test_8515/test_stack.asm: Imported source.
* MANIFEST.in, Makefile, README, README.opcodes, TODO, harness.py,
setup.py, test_asm/Makefile, test_asm/test.asm,
test_asm/test_8515/test_blink.asm,
test_asm/test_8515/test_stack.asm: New file.

View file

@ -0,0 +1,969 @@
2002-11-16 Theodore A. Roth <troth@openavr.org>
* configure.in: Bump version.
* src/disp-vcd/config_parser.y: Reformat code.
* src/disp-vcd/config_scanner.l: Reformat code.
* src/disp-vcd/disp.c: Reformat code. Remove dead code.
* src/disp-vcd/vcd.c: Reformat code.
* src/disp-vcd/vcd.h: #define VCD_H.
2002-11-15 Theodore A. Roth <troth@openavr.org>
* configure.in: Add checks for yacc and lex.
Add creation of src/disp-vcd/Makefile.
* src/Makefile.am: Add disp-vcd subdir.
* src/disp-vcd/Makefile.am: New file.
Thanks to Carsten Beth for contributing the following files:
* src/disp-vcd/config_parser.y: New file.
* src/disp-vcd/config_scanner.l: New file.
* src/disp-vcd/disp.c: New file.
* src/disp-vcd/vcd.c: New file.
* src/disp-vcd/vcd.cfg: New file.
* src/disp-vcd/vcd.h: New file.
2002-11-13 Theodore A. Roth <troth@openavr.org>
[Thanks to Carsten Beth <Carsten.Beth@Informatik.Uni-Oldenburg.DE> for
the display_clock code.]
* configure.in: Bump version.
* doc/simulavr.texi: Add clock ticks to display protocol.
* src/avrcore.c: Add code for displaying clock ticks.
Fix some minor typos.
* src/display.c: Add display_clock() function.
* src/display.h: Add display_clock() prototype.
* src/flash.c: Fix a comment typo.
2002-10-28 Theodore A. Roth <troth@openavr.org>
* configure.in: Check for autoconf-2.13.
Bump version.
* config/check_autoconf213.m4: New file.
2002-10-20 Theodore A. Roth <troth@openavr.org>
* configure.in: Bump version.
* bootstrap: Make compatible with RedHat-8.0 autotools.
2002-10-15 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c: Add real simulation of rampz register.
* src/avrcore.h: Ditto.
* src/decoder.c: Ditto.
* src/register.c: Ditto.
* src/register.h: Ditto.
2002-10-15 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c src/avrcore.h src/decoder.c * src/gdb.h
* src/gdbserver.c src/op_names.c src/op_names.h:
Add BREAK insn handling to decoder.
Refactor break point mechanism to use the BREAK instruction.
Remove some dead code.
Remove INVALID_VALID opcode usage.
Streamlining of opcode execution loop.
* configure.in: Bump version.
2002-10-12 Theodore A. Roth <troth@openavr.org>
* src/gdb.h: Define BREAK_POINT and INVALID_OPCODE.
Use sdword instead of dword in CommFunc*PC typedefs.
* src/gdbserver.c: Remove BREAK_POINT and INVALID_OPCODE enum entries.
(gdb_write_memory): Reply to gdb with error if target can't write
flash.
* src/op_names.h: Define BREAK_POINT and INVALID_OPCODE instead of
enums.
2002-10-12 Theodore A. Roth <troth@openavr.org>
* Makefile.am: Add man pages.
* configure.in: Add man pages. Bump version.
* simulavr-disp.1.in: New file (Thanks to Shaun Jackman).
* simulavr.1.in: New file (Thanks to Shaun Jackman).
* simulavr.spec.in: Add man pages.
2002-10-12 Theodore A. Roth <troth@openavr.org>
* src/main.c: Print usage to stdout instead of stderr.
2002-10-08 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c: Make core PC access methods use signed 32 bit values.
* src/avrcore.h: Ditto.
2002-10-08 Theodore A. Roth <troth@openavr.org>
* config/avr_doc_pdf.m4: Use '=' instead of '==' in tests.
* config/avr_doc_ps.m4: Ditto.
* config/enable_curses.m4: Ditto.
2002-09-30 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c, src/eeprom.c, src/eeprom.h, src/main.c:
Add ability to load an eeprom data image into eeprom space.
2002-09-20 Theodore A. Roth <troth@openavr.org>
* src/avrcore.h: Change PC values to signed (fix rjmp wrap problem).
2002-09-19 Theodore A. Roth <troth@openavr.org>
* doc/simulavr.texi: Document -X and -C options. Overfill fixups.
* src/main.c: Add -C option so core dumps are only generated at users
request.
2002-09-15 Theodore A. Roth <troth@openavr.org>
* src/Makefile.am src/disp/Makefile.am:
Add -Wall and -Werror to AM_CFLAGS.
* src/avrcore.c, src/ports.c, src/disp/disp.c:
Quell warnings.
2002-09-15 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c, src/decoder.c, src/op_names.h:
Handle unknown opcodes as NOP's.
2002-09-11 Theodore A. Roth <troth@openavr.org>
* src/gdb.h, src/gdbserver.c, src/main.c:
Make gdbserver.c generic so it can be used by other projects.
2002-09-09 Theodore A. Roth <troth@openavr.org>
* Tagged for 0.1.1 release.
* configure.in: Set version to 0.1.1.
2002-09-09 Theodore A. Roth <troth@openavr.org>
* doc/simulavr.texi:
Add note about use of :1212 instead of localhost:1212.
2002-09-08 Theodore A. Roth <troth@openavr.org>
* src/display.c: Remove display debug output. (speeds things up)
2002-09-08 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* src/disp/disp.c: Stop cursor flicker on screen updates.
2002-09-06 Theodore A. Roth <troth@openavr.org>
* src/disp/disp.c: Indent switch statement.
2002-09-06 Theodore A. Roth <troth@openavr.org>
* src/disp/disp.c: Finish implementing the 'g' command.
2002-09-06 Theodore A. Roth <troth@openavr.org>
* src/disp/disp.c: Add floating point register display.
2002-09-05 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* src/disp/disp.c: Speed up disp by only refreshing when idle.
2002-09-05 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c: Reorder some includes to stop errors on FreeBSD.
2002-09-05 Theodore A. Roth <troth@openavr.org>
* configure.in: Bump version to 0.1.1pre1.
* simulavr.spec.in: Require avr-gdb >= 5.2.1. Disable pdf dox (temp).
* test_c/deep_frame.c: Update to use latest avr-libc headers.
* test_c/demo.c: Update to use latest avr-libc headers.
* test_c/demo_kr.c: Update to use latest avr-libc headers.
2002-09-05 Theodore A. Roth <troth@openavr.org>
* bootstrap: Improve checks for correct autotools. (Joerg Wunsch)
* Makefile.am, configure.in, doc/Makefile.am: Allow installation
of docs into a directory without the version number. (Joerg Wunsch)
2002-09-05 Theodore A. Roth <troth@openavr.org>
* src/disp/Makefile.am: Use supplied gnu_getopt.c/gnu_getopt1.c.
* src/disp/disp.c: Include gnu_getopt.h instead of getopt.h.
2002-09-04 Theodore A. Roth <troth@openavr.org>
* doc/simulavr.texi, src/avrcore.c, src/avrcore.h, src/display.c,
* src/display.h, src/dtest.c, src/main.c, src/sram.c, src/sram.h,
* src/storage.c, src/storage.h, src/disp/disp.c:
Change way disp co-process is called to include sram start addr.
New keyboard movement commands for simulavr-disp:
- Home key jumps to addr 0x00.
- End key jumps to last sram addr.
- Page Up key moves cursor up a screen of data.
- Page Down key moves cursor down a screen of data.
- 'g' key will allow user to jump (goto) an addr (not fully
implemented, but stubbed out).
2002-09-04 Theodore A. Roth <troth@openavr.org>
* doc/Makefile.am: s/make -C/${MAKE} -C/ for portability.
* doc/doxygen.config.in: Set USE_PDFLATEX to no.
2002-09-02 Theodore A. Roth <troth@openavr.org>
* doc/simulavr.texi: Add note about avr support in gdb-5.2.1.
2002-08-28 Theodore A. Roth <troth@openavr.org>
* src/ports.c: Fix bug when reading io ports.
2002-08-28 Theodore A. Roth <troth@openavr.org>
* src/devsupp.c, src/intvects.c, src/sram.h:
Add mega103 support.
* src/decoder.c:
Comment out warning message in avr_op_ELPM_Z_incr().
2002-08-27 Theodore A. Roth <troth@openavr.org>
* configure.in: Add AVR_DOC_PS.
* config/avr_doc_ps.m4: New file.
* config/check_doxygen.m4: Inherit from AVR_DOC_P{S,DF}.
* doc/Makefile.am(all-local): ps -> $(TARGET_PS)
2002-08-09 Theodore A. Roth <troth@openavr.org>
* bootstrap: Check for correct versions of automake/autoconf.
2002-08-02 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c:
Fix to stop gdb_write_register() from parsing to many characters when
setting PC.
2002-07-31 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c:
Fix 'P' and 'p' packets to write/read PC as 4 bytes.
2002-07-19 Theodore A. Roth <troth@openavr.org>
* src/intvects.c:
Fix interrupt vector addresses for mega128.
2002-07-16 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c, src/avrcore.h, src/decoder.c, src/devsupp.c,
src/disp/disp.c, src/intvects.c, src/intvects.h, src/sram.h,
src/utils.c, src/utils.h:
Refactored interrupt internals to improve flexibility.
Added minimal mega128 support.
* doc/doxygen.config.in:
Config tweaks.
2002-07-10 Theodore A. Roth <troth@openavr.org>
* src/decoder.c:
Fixed bug in elpm opcodes.
2002-06-08 Theodore A. Roth <troth@openavr.org>
* src/decoder.c:
Fix fmul* opcodes. Thanks to Jeff Mock.
2002-05-27 Theodore A. Roth <troth@openavr.org>
* src/display.c, src/display.h, src/dtest.c, src/main.c:
Added -X, --without-xterm command line options.
* src/register.c:
Fix copy and paste error. D'oh!
2002-05-26 Theodore A. Roth <troth@openavr.org>
* Makefile.am:
Add removal of CVS control dirs from distribution.
* src/register.c:
Fix bug in which mcucr and acsr constructors didn't init func_mask.
2002-04-29 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c:
Fixed typo in comment.
2002-04-18 Theodore A. Roth <troth@openavr.org>
* README.ext_int:
Added temp file for working out external interface design.
* doc/simulavr.texi:
Send bug reports to simulavr development mailing list instead of me.
Updated gdb hints section.
2002-04-17 Theodore A. Roth <troth@openavr.org>
* src/device.c, src/devsupp.c, src/devsupp.h,
src/disp/Makefile.am, src/disp/disp.c, src/display.h,
src/dtest.c, src/eeprom.c, src/flash.c, src/gdb.h,
src/gnu_getopt.c, src/gnu_getopt.h, src/gnu_getopt1.c,
src/intvects.c, src/memory.c, src/op_names.c, src/ports.c,
src/register.c, src/sig.c, src/sig.h, src/sram.c, src/stack.c,
src/storage.c, src/timers.c, src/utils.c, src/vdevs.h,
test_asm/Makefile.am, test_asm/test_8515/Makefile.am,
test_c/Makefile.am, test_c/demo_kr.c, Makefile.am,
Makefile_AVR_Rules, acconfig.h, doc/Makefile.am,
src/Makefile.am, src/avrclass.c, src/avrcore.c, src/avrcore.h,
src/avrerror.c, src/avrmalloc.c, src/decoder.c:
Updated copyright year.
* doc/simulavr.texi:
Removed unused indices.
Updated copyright year.
2002-04-15 Theodore A. Roth <troth@openavr.org>
* Released 0.1.0 ("The Tax Man Commeth" release ;-).
* configure.in:
Bumped version to 0.1.0.
2002-04-12 Theodore A. Roth <troth@openavr.org>
* INSTALL, README, TODO, regress/test_opcodes/TODO:
Minor documentation cleanups.
* simulavr.spec.in:
Added avr-gdb >= 5.1.90 as a install requirement.
Added doxygen as a build requirement.
2002-04-11 Theodore A. Roth <troth@openavr.org>
* README.gdb, gdb-patches/README, regress/modules/gdb_rsp.py,
src/gdbserver.c:
Changed size of PC as passed to and from gdb from 2 to 4 bytes to
sync up with new gdb behaviour.
* src/avrcore.c, src/avrcore.h:
Changed PC from int to dword to avoid potential problems with
truncation.
* gdb-patches/patcher.sh, gdb-patches/get_gdb_patches.sh:
Removed obsolete files.
2002-04-05 Theodore A. Roth <troth@openavr.org>
* configure.in: Bumped version to 0.1.0pre.
* doc/simulavr.texi:
Moved Internals chapter to doxygen.
* src/maindoc.c:
Moved Internals documentation from texinfo file to here.
* src/Makefile.am:
Added maindoc.c to EXTRA_DIST list.
* src/main.c:
Updated copyright year.
* regress/modules/base_test.py, regress/test_opcodes/Makefile.am:
* regress/test_opcodes/TODO, regress/test_opcodes/test_CPSE.py:
* regress/test_opcodes/test_LPM.py:
* regress/test_opcodes/test_LPM_Z.py:
* regress/test_opcodes/test_LPM_Z_incr.py:
* regress/test_opcodes/test_SBRC.py:
* regress/test_opcodes/test_SBRS.py:
Added more regression test cases.
* src/decoder.c:
Removed another check for undefined op which is defined.
Fixed LPM_Z_incr where Z should not be div 2.
2002-04-04 Theodore A. Roth <troth@openavr.org>
* regress/test_opcodes/Makefile.am, regress/test_opcodes/TODO:
* regress/test_opcodes/test_STD_Y.py:
* regress/test_opcodes/test_STD_Z.py:
* regress/test_opcodes/test_ST_X.py:
* regress/test_opcodes/test_ST_X_decr.py:
* regress/test_opcodes/test_ST_X_incr.py:
* regress/test_opcodes/test_ST_Y_decr.py:
* regress/test_opcodes/test_ST_Y_incr.py:
* regress/test_opcodes/test_ST_Z_decr.py:
* regress/test_opcodes/test_ST_Z_incr.py:
Added more regression test cases.
* src/decoder.c:
Removed some invalid error checks (operations are not undefined).
* regress/test_opcodes/Makefile.am, regress/test_opcodes/TODO:
* regress/test_opcodes/test_LDD_Y.py:
* regress/test_opcodes/test_LDD_Z.py:
* regress/test_opcodes/test_LD_X.py:
* regress/test_opcodes/test_LD_X_decr.py:
* regress/test_opcodes/test_LD_X_incr.py:
* regress/test_opcodes/test_LD_Y_decr.py:
* regress/test_opcodes/test_LD_Y_incr.py:
* regress/test_opcodes/test_LD_Z_decr.py:
* regress/test_opcodes/test_LD_Z_incr.py:
Added more regression tests.
* src/decoder.c:
Make X, Y and Z registers words instead of ints.
2002-04-03 Theodore A. Roth <troth@openavr.org>
* regress/test_opcodes/Makefile.am, regress/test_opcodes/TODO:
* regress/test_opcodes/test_LDS.py:
* regress/test_opcodes/test_STS.py:
Added new test cases.
* regress/modules/base_test.py:
Added mem_byte_{read,write}() methods for accessing memory.
2002-04-02 Theodore A. Roth <troth@openavr.org>
* regress/modules/base_test.py, regress/test_opcodes/Makefile.am:
* regress/test_opcodes/TODO, regress/test_opcodes/test_MUL.py
* regress/test_opcodes/test_MULS.py:
* regress/test_opcodes/test_MULSU.py:
* regress/test_opcodes/test_RET.py:
* regress/test_opcodes/test_RETI.py:
Added more opcode tests (thanks Josef Angermeier).
* src/decoder.c:
Untabified file (probably shouldn't have though).
Fixed some bugs in avr_op_{MUL,MULS,MULSU}() (thanks Josef Angermeier).
Fixed bug in which MULSU instruction wasn't decoded correctly.
* acconfig.h:
Added signed versions of byte, word, dword and qword.
* AUTHORS:
Added Josef Angermeier to contributors.
2002-04-01 Theodore A. Roth <troth@openavr.org>
* src/disp/disp.c:
Fixed bug in which io reg names were lost if window was resized.
* src/gdbserver.c:
Disabled attempt to catch zero pointer dereferencing since it's
not working right.
2002-03-26 Theodore A. Roth <troth@openavr.org>
* src/stack.c:
Updated comments about push/pop.
Fixed bug in which display_io_reg() was called twice.
* src/display.c:
Catch interrupted write to make sure co-process can be told to quit.
2002-03-24 Theodore A. Roth <troth@openavr.org>
* src/avrclass.c, src/avrcore.c, src/ports.c:
More documentation updates.
2002-03-19 Theodore A. Roth <troth@openavr.org>
* src/timers.c, src/utils.c, src/avrcore.c, src/devsupp.c,
src/flash.c, src/memory.c, src/ports.c, src/sig.c, src/stack.c:
More conversion of comments to doxygen documentation.
* AUTHORS: Updated.
2002-03-18 Theodore A. Roth <troth@openavr.org>
* misc/gpl_header_h, src/avrclass.h, src/avrcore.h,
src/avrerror.h, src/avrmalloc.h, src/callback.h, src/decoder.h,
src/devsupp.h, src/display.h, src/eeprom.h, src/flash.h,
src/gdb.h, src/intvects.h, src/memory.h, src/op_names.h,
src/ports.h, src/register.h, src/sig.h, src/sram.h, src/stack.h,
src/storage.h, src/timers.h, src/utils.h, src/vdevs.h:
Changed all header protection defines to SIM_xxxx_H to avoid cpp
clashes.
2002-02-26 Theodore A. Roth <troth@openavr.org>
* doc/simulavr.texi:
Make info dir entry consistent with other avr tool entries.
* Makefile.am, src/Makefile.am:
Use DIST_SUBDIRS to put files is dist tarball which are
conditionally set.
2002-02-25 Theodore A. Roth <troth@openavr.org>
* src/display.c, src/sig.c, src/sig.h:
Include signal.h in *.c not *.h.
2002-02-24 Theodore A. Roth <troth@openavr.org>
* src/callback.c:
New file.
* configure.in:
Changed init to use avrcore.h instead of avr.h.
* acconfig.h, src/Makefile.am, src/avr.h, src/avrclass.c,
src/avrclass.h, src/avrcore.c, src/avrcore.h, src/avrerror.c,
src/callback.h, src/decoder.c, src/decoder.h, src/device.c,
src/devsupp.c, src/devsupp.h, src/display.c, src/dtest.c,
src/eeprom.c, src/eeprom.h, src/flash.c, src/flash.h,
src/gdbserver.c, src/intvects.c, src/intvects.h, src/main.c,
src/memory.c, src/memory.h, src/op_names.c, src/op_names.h,
src/ports.c, src/ports.h, src/register.c, src/register.h,
src/sig.c, src/sram.c, src/sram.h, src/stack.c, src/stack.h,
src/storage.c, src/storage.h, src/timers.c, src/timers.h,
src/utils.c, src/utils.h, src/vdevs.h:
Header file reorganization.
* doc/doxygen.config.in:
Added DOXYGEN to PREDEFINED.
Set ENUM_VALUES_PER_LINE to 1.
2002-02-23 Theodore A. Roth <troth@openavr.org>
* src/Makefile.am:
Added avrerror.h and avrmalloc.h.
* src/avr.h, src/vdevs.h:
Moved _VDevice and methods from avr.h to vdevs.h.
* src/avr.h, src/avrmalloc.c, src/avrmalloc.h, src/avrerror.c:
* src/avrerror.h:
Header file cleanup and documentation update.
* doc/doxygen.config.in:
Added MACRO_DOCUMENTATION for precompiler parser.
* regress/test_opcodes/test_INC.py:
Fixed bug in calculation of expect V flag.
* regress/test_opcodes/test_ADC.py,
regress/test_opcodes/test_ADD.py,
regress/test_opcodes/test_ADIW.py,
regress/test_opcodes/test_AND.py,
regress/test_opcodes/test_ANDI.py,
regress/test_opcodes/test_CPI.py,
regress/test_opcodes/test_DEC.py,
regress/test_opcodes/test_INC.py,
regress/test_opcodes/test_NEG.py,
regress/test_opcodes/test_SBC.py,
regress/test_opcodes/test_SBIW.py:
Fixed a few minor problems.
Added more test values to make sure all sreg bits are exercised.
* regress/test_opcodes/Makefile.am, regress/test_opcodes/TODO,
regress/test_opcodes/test_DEC.py,
regress/test_opcodes/test_EOR.py,
regress/test_opcodes/test_INC.py,
regress/test_opcodes/test_LDI.py,
regress/test_opcodes/test_LSR.py,
regress/test_opcodes/test_NEG.py,
regress/test_opcodes/test_OR.py,
regress/test_opcodes/test_ORI.py,
regress/test_opcodes/test_RJMP.py,
regress/test_opcodes/test_ROR.py,
regress/test_opcodes/test_SBC.py,
regress/test_opcodes/test_SBCI.py,
regress/test_opcodes/test_SBIW.py,
regress/test_opcodes/test_SUB.py,
regress/test_opcodes/test_SUBI.py:
Added new test cases.
* regress/test_opcodes/test_ASR.py:
Made expect value calculation more explicit.
2002-02-22 Theodore A. Roth <troth@openavr.org>
* regress/regress.py.in:
Change to insure that simulator is killed.
* regress/test_opcodes/test_COM.py:
Added missing underscore.
* src/decoder.c:
Fixed bug in avr_op_NEG: H flag wasn't set correctly.
* regress/test_opcodes/Makefile.am, regress/test_opcodes/TODO,
regress/test_opcodes/test_COM.py,
regress/test_opcodes/test_CP.py,
regress/test_opcodes/test_CPC.py,
regress/test_opcodes/test_CPI.py:
Added new test cases.
2002-02-21 Theodore A. Roth <troth@openavr.org>
* regress/test_opcodes/Makefile.am, regress/test_opcodes/TODO,
regress/test_opcodes/test_ADIW.py,
regress/test_opcodes/test_AND.py,
regress/test_opcodes/test_ANDI.py,
regress/test_opcodes/test_ASR.py:
Added new test cases.
2002-02-20 Theodore A. Roth <troth@openavr.org>
* regress/regress.py.in:
Changed test case message.
* regress/test_opcodes/Makefile.am, regress/test_opcodes/TODO,
regress/test_opcodes/test_ADC.py,
regress/test_opcodes/test_ADD.py,
regress/test_opcodes/test_MOV.py,
regress/test_opcodes/test_MOVW.py:
Added new test cases.
* regress/modules/base_test.py, regress/test_opcodes/Makefile.am,
regress/test_opcodes/test_BCLR.py, regress/test_opcodes/test_BLD.py,
regress/test_opcodes/test_BRBC.py, regress/test_opcodes/test_BRBS.py,
regress/test_opcodes/test_BSET.py, regress/test_opcodes/test_BST.py,
regress/test_opcodes/test_NOP.py, regress/test_opcodes/test_SWAP.py:
Simplified test cases by moving target access and repeated checks
into base_test.py.
* regress/test_opcodes/TODO:
Fix cvs Id tag.
2002-02-19 Theodore A. Roth <troth@openavr.org>
* TODO, INSTALL:
Updated regression test suite information.
* regress/Makefile.am:
Tee regression output to a file.
* regress/regress.py.in:
Added code to automate spawning an instance of the simulator.
* regress/regress.py.in:
Reverted threading. With latest change to gdbserver.c, it's faster to
run regression tests from a single thread.
* src/gdbserver.c:
Fix a problem in which latest cvs gdb would timeout in mid-packet.
As a side effect, gdb-to-simulavr communication is faster.
2002-02-16 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c:
Fixed incorrect removal of addr offset bits.
Stubbed out read/write of eeprom space from gdb (`x/b 0x81xxxx`).
2002-02-15 Theodore A. Roth <troth@openavr.org>
* doc/doxygen.config.in:
Turn on html tree view.
2002-02-13 Theodore A. Roth <troth@openavr.org>
* src/Makefile.am, src/gdb.c:
Removed src/gdb.c. Old and in the way.
* src/gdbserver.c:
Renamed gdb_extract_reg_num() to gdb_extract_hex_num() and made it
more general. Code cleanups. Made output for -G more consistent.
* src/gdbserver.c:
Tell TCP not to delay small packets, this speeds up response.
* src/main.c:
Issue a warning if user selects unimplemented file format.
* src/utils.c:
Fix so '-F bin' option works.
2002-02-12 Theodore A. Roth <troth@openavr.org>
* Released 0.0.14
* INSTALL, README, README.gdb, doc/simulavr.texi,
gdb-patches/README, regress/README:
Documentation updates.
* configure.in:
Set version to 0.0.14.
* regress/regress.py.in:
Fixed a typo.
* regress/regress.py.in:
Added threading to speed up running test cases.
Added command line option parser.
* regress/modules/gdb_rsp.py:
Fix to only ever recv 1 byte at a time. Threading was causing
recv(2) to only return a single byte.
Added arguments when raising exceptions.
* src/gdbserver.c:
Added missing cksum output if debug is on.
2002-02-11 Theodore A. Roth <troth@openavr.org>
* Makefile.am, simulavr.spec.in:
Fix to keep regress in SUBDIRS if python not found.
Sync up what is installed in docdir.
2002-02-10 Theodore A. Roth <troth@openavr.org>
* Makefile.am:
Fix to get spec file into dist file.
* simulavr.spec.in:
Moved documentation into simulavr-docs subpackage.
* config/check_doxygen.m4:
Removed unused AC_SUBST().
* Makefile.am, configure.in, doc/Makefile.am:
Remove --with-docdir configure option, install docs relative to
datadir instead.
* doc/Makefile.am:
Added EXTRA_DIST files.
* TODO, config/check_doxygen.m4, configure.in, doc/Makefile.am:
Integration of doxygen into build system.
* doc/doxygen.config.in:
Added custom html files.
Changed directory structure.
Added LaTeX output to get ps/pdf files.
* doc/dox.css, doc/dox_html_footer, doc/dox_html_header:
Added customized html files.
* src/display.c:
Fixed doxygen comment.
* doc/texinfo.tex:
Added to avoid using broken texinfo.tex files for pdf generation.
2002-02-08 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c, src/device.c, src/flash.c, src/memory.c,
src/ports.c, src/register.c, src/stack.c, src/utils.c:
Removed inline modifiers. Better to let the compiler do it.
* src/gdb.h, src/gdbserver.c, src/main.c:
Added command line option to turn gdb debug messages on (off by
default).
* simulavr.spec.in:
Added optimization flags.
* INSTALL:
Added notes on optimizing and regression tests.
* Makefile.am, configure.in, simulavr.spec.in:
Added rpm spec file.
* doc/simulavr.texi:
Added dir.info fragment. Updated description.
* src/disp/Makefile.am:
Changed disp program name to simulavr-disp.
* ProjSummary:
Changed URL.
2002-02-05 Theodore A. Roth <troth@openavr.org>
* config/avr_doc_pdf.m4:
Corrected grammar.
* regress/test_opcodes/TODO, regress/test_opcodes/test_BST.py,
regress/test_opcodes/Makefile.am:
Added test case for BST.
* regress/test_opcodes/TODO, regress/test_opcodes/test_BLD.py,
regress/test_opcodes/Makefile.am:
Added test case for BLD.
* regress/modules/registers.py:
Added SREG class for naming sreg bits.
* src/decoder.c:
Fixed bug in avr_op_BLD.
* Makefile.am, config/check_python.m4, configure.in,
misc/gpl_header_py, regress/Makefile.am, regress/README,
regress/modules/Makefile.am, regress/modules/avr_target.py,
regress/modules/base_test.py, regress/modules/gdb_rsp.py,
regress/modules/registers.py, regress/regress.py.in,
regress/test_opcodes/Makefile.am, regress/test_opcodes/TODO,
regress/test_opcodes/test_BCLR.py,
regress/test_opcodes/test_BRBC.py,
regress/test_opcodes/test_BRBS.py,
regress/test_opcodes/test_BSET.py,
regress/test_opcodes/test_NOP.py,
regress/test_opcodes/test_SWAP.py:
Added regression test framework.
2002-02-02 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c:
Send 'E' reply when gdb tries to read/write memory in reg range.
2002-01-31 Theodore A. Roth <troth@openavr.org>
* src/avr.h, src/avrcore.c, src/decoder.c:
Speed optimization for decoder by using a lookup table.
* src/gdbserver.c:
Perform a reset when gdb sends the kill command.
* src/decoder.c:
Fixed some comments.
2002-01-29 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c:
Fixed read/write of PC reg with 'P' and 'p' packets.
2002-01-26 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c:
Added support for 'P' and 'p' packets.
* src/avrclass.c:
Converted comments to doxygen format.
2002-01-25 Theodore A. Roth <troth@openavr.org>
* src/Makefile.am, src/gnu_getopt.c, src/gnu_getopt.h,
src/gnu_getopt1.c, src/main.c:
Added gnu getopt files to improve portability of getopt_long.
2002-01-24 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c:
Fix to allow interruption of stepping on infinite loop.
2002-01-09 Theodore A. Roth <troth@openavr.org>
* Released 0.0.13
* configure.in:
Updated copyright date and set version to 0.0.13.
* config/check_texinfo.m4:
Added more program checks.
2002-01-08 Theodore A. Roth <troth@openavr.org>
* ChangeLog: Updated.
* doc/doxygen.config.in:
Set BRIEF_MEMBER_DESC to NO.
* src/display.c, src/gdbserver.c:
Updated comments for doxygen.
* Makefile.am, config/check_texinfo.m4, configure.in:
Added check for texinfo: if not found, do not build doc dir.
* doc/doxygen.config.in:
Updated configuration.
* src/utils.c:
Updated comments for doxygen.
* config/enable_curses.m4:
Added check for resizeterm function.
Only check for libs if enabled.
* src/utils.c:
Changed get_program_time() to make it more portable.
* configure.in:
Bumped version to 13-pre4.
* misc/gpl_header, misc/gpl_header_c, misc/gpl_header_h:
Updated copyright date.
* TODO, src/gdbserver.c:
Implemented writing to sram.
2002-01-07 Theodore A. Roth <troth@openavr.org>
* TODO: Removed disp term resizing.
* src/decoder.c:
Fixed bug setting carry flag in LSR handler
* src/disp/disp.c, src/display.c:
Implemented terminal resizing of display.
Removed forking of xterm in psuedo term mode.
2002-01-06 Theodore A. Roth <troth@openavr.org>
* ChangeLog, TODO:
Updated.
* src/display.c, src/gdbserver.c: Fixed problem with display zombies.
* src/register.c: Set all general purpose registers to zero on reset.
* test_asm/test_8515/Makefile.am:
Fix problem with 'make dist' from directory other than source.
Run elf files through linker to allow source stepping in gdb.
* Makefile.am:
Fix problem with 'make dist' from directory other than source.
* config/avr_doc_dirsuffix.m4: Added version to doc install dir.
* config/avr_binutils.m4: Added check for avr-ld.
* configure.in: Bumped version to 13-pre3.
* src/gdbserver.c, doc/simulavr.texi:
Added support for 'C' and 'S' packets (cont/step with signal).
Issuing a 'signal SIGHUP' command from gdb will cause sim to reset.
Documented SIGHUP behaviour.
* TODO: Updated, added road map.
* Makefile_AVR_Rules: Added --gstabs when assembling.
2002-01-05 Theodore A. Roth <troth@openavr.org>
* test_asm/test_8515/test_blink.asm:
Fix to allow avr-ld to create a relocated object.
2002-01-04 Theodore A. Roth <troth@openavr.org>
* doc/Makefile.am, config/acconfig.h, config/avr_doc_dirsuffix.m4,
config/avr_doc_pdf.m4, Makefile.am, acconfig.h, bootstrap,
configure.in:
Applied Reinhard Jessich's patch for installing docs.
Fixed problem with config.h not getting updated which would break
compiling.
2002-01-03 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c: Added documentation comments for doxygen.
Added infinite loop around tcp server.
* src/gdbserver.c: Removed redundant if clause.
* src/Makefile.am, src/avr.h, src/avrcore.c, src/gdbserver.c,
src/sig.c, src/sig.h:
Encapsulated signal handling into sig.c.
2002-01-02 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c: Correctly handle gdb sending C-c interrupt.
* src/gdbserver.c:
Modified to allow gdb to send an interrupt while sim is in
continue loop.
* src/gdbserver.c:
Applied Tor Ringstad's patch to improve SIGINT handling.

View file

@ -0,0 +1,676 @@
2003-12-03 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/avrcore.c (avr_core_step): Make sure that one instruction is
executed after a RETI (return from interrupt).
2003-12-02 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c (avr_core_check_interrupts): Don't inline since some
versions of gcc can't inline this function.
2003-12-02 Theodore A. Roth <troth@openavr.org>
[Contributed by Keith Gudger <keith@atmel.com>]
* configure.ac (AC_INIT): Bump version.
* src/devsupp.c (defn_atmega103): Enable adc support.
* src/intvects.c (vtab_at43usb355): Fix TIMER1_COMPB irq name.
(vtab_at43usb320): Ditto.
(vtab_at43usb325): Ditto.
2003-12-02 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c:
* src/decoder.c:
* src/decoder.h:
* src/device.c:
* src/flash.c:
* src/flash.h:
* src/storage.c:
* src/storage.h:
* src/vdevs.h:
Make some speed critical functions inlined.
* src/timers.c (timer0_clk_incr_cb): Eliminate an expensive use of
modulus operation.
(timer16_clk_incr_cb): Ditto.
* src/spi.c: (spi_clk_incr_cb): Ditto.
2003-12-01 Theodore A. Roth <troth@openavr.org>
* src/devsupp.c: Use .field initialization for device definitions.
Clean up after indent and disable it for the device defns.
2003-12-01 Theodore A. Roth <troth@openavr.org>
* src/gdb.h:
* src/gdbserver.c:
Rename CommFuncDisableBreakpoints, CommFuncEnableBreakpoints,
enable_breakpoints and disable_breakpoints to allow sorter lines.
* src/main.c (global_gdb_comm): Use .field initialization.
2003-12-01 Theodore A. Roth <troth@openavr.org>
* src/adc.c:
* src/avrclass.c:
* src/avrcore.c:
* src/avrerror.c:
* src/avrmalloc.c:
* src/callback.c:
* src/decoder.c:
* src/device.c:
* src/devsupp.c:
* src/display.c:
* src/eeprom.c:
* src/flash.c:
* src/gdbserver.c:
* src/intvects.c:
* src/main.c:
* src/memory.c:
* src/op_names.c:
* src/ports.c:
* src/register.c:
* src/sig.c:
* src/spi.c:
* src/sram.c:
* src/stack.c:
* src/storage.c:
* src/timers.c:
* src/utils.c:
Reformat with misc/refmt.sh script.
Update Copyright year.
2003-12-01 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/adc.h:
* src/avrclass.h:
* src/avrcore.h:
* src/avrerror.h:
* src/avrmalloc.h:
* src/callback.h:
* src/decoder.h:
* src/devsupp.h:
* src/display.h:
* src/eeprom.h:
* src/flash.h:
* src/gdb.h:
* src/intvects.h:
* src/memory.h:
* src/op_names.h:
* src/ports.h:
* src/register.h:
* src/sig.h:
* src/spi.h:
* src/sram.h:
* src/stack.h:
* src/storage.h:
* src/timers.h:
* src/usb.h:
* src/utils.h:
* src/vdevs.h:
Reformat with misc/refmt.sh script.
Update Copyright year.
2003-11-30 Theodore A. Roth <troth@openavr.org>
* misc/refmt.sh: Ignore newlines instead of honouring them.
Set the tab size to 1 to avoid comments to the right of code being
pushed farther to the right.
Make grepping for typedefs the default behaviour.
* src/disp/disp.c: Reformat with misc/refmt.sh script.
Wrap long comments.
* src/disp-vcd/disp.c: Ditto.
* src/disp-vcd/vcd.c: Ditto.
2003-11-30 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/avrcore.c:
* src/avrcore.h:
* src/decoder.c:
* src/register.c:
* src/register.h:
* src/utils.c:
* src/utils.h:
Inline simple functions to boost performance a bit.
2003-11-29 Theodore A. Roth <troth@openavr.org>
[Contributed by John Regehr <regehr@cs.utah.edu>]
* src/intvects.c: Add enable and flag initializers to all vector
tables.
Change ANA_COMP to USB_HW for usb devices.
* src/intvects.h (struct _IrqCtrlBit): Define.
(struct _IntVect): Add enable and flag fields.
(struct _IntVectTable): Add USB_HW field.
2003-11-29 Theodore A. Roth <troth@openavr.org>
* src/main.c: Modify handling of --breakpoint option to allow multiple
instances on the command line.
2003-11-29 Theodore A. Roth <troth@openavr.org>
* src/Makefile.am: Remove vars for dtest.
* src/dtest.c: Remove file.
2003-11-29 Theodore A. Roth <troth@openavr.org>
* configure.ac: Add check for avr-nm.
[Contributed by Keith Gudger <keith@atmel.com>]
* src/Makefile.am (simulavr_SOURCES): Add adc.c, adc.h, and usb.h.
* src/devsupp.c: Add adcsr and uier masks.
Install adc vdev.
* src/adc.c: New file.
* src/adc.h: New file.
* src/usb.h: New file.
2003-11-29 Theodore A. Roth <troth@openavr.org>
* misc/refmt.sh: Add indentation of case labels in switch statements.
Let the user select how to get the type info.
[Contributed by Keith Gudger <keith@atmel.com>]
* src/Makefile.am (simulavr_SOURCES): Add spi.c and spi.h.
* src/devsupp.c (struct _DevSuppDefn): Add spcr field.
* src/spi.c: New file.
* src/spi.h: New file.
2003-11-29 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* README.ext_int: Add some new notes.
* misc/gpl_header: Update copyright year.
* misc/gpl_header_c: Update copyright year.
* misc/gpl_header_h: Update copyright year.
* misc/gpl_header_py: Update copyright year.
* misc/irq.py: New file.
* misc/refmt.sh: New file.
* src/avrcore.c: Allow disabling of irq diagnostics at compile time.
* test_asm/test_8515/test_toie0.asm: Exit the idle loop when the
interrupts are done and then go into a done loop.
2003-11-27 Theodore A. Roth <troth@openavr.org>
* simulavr.1.in: Document new options.
Add new usb support to device list.
* doc/simulavr.texi: Document new options.
* src/main.c: Reorder usage strings to improve readability.
Add stub for --clock-freq option.
Add --breakpoint option and implement it.
2003-11-27 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/avrcore.c (avr_core_run): Track the run time and print out the
insns/sec and clks/sec when the program is terminated. (avr_core_run)
(avr_core_reset): Don't reset the clock counter since doing so screws
up the clks/sec calculation and the vcd output.
* src/devsupp.c (defn_atmega103): Fix sram size, should be 4000 instead
of 4096.
2003-11-22 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
If using gcc, enable extra warnings.
* src/Makefile.am:
* src/disp/Makefile.am:
* src/disp-vcd/Makefile.am:
Update copyright year.
Only add gcc specific warnings if compiling with gcc.
2003-11-17 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/timers.c: Dox cleanups.
2003-11-12 Theodore A. Roth <troth@openavr.org>
[Thanks to Hermann Krauss <hnkraus@compuserve.de> for the original patch and
Keith Gudger <keith@atmel.com> for revising it and testing with the usb
devices.]
* configure.ac (AC_INIT): Bump version.
* src/devsupp.c:
* src/timers.c:
* src/timers.h:
Add support for 16 bit timers 1 and 3.
2003-11-11 Theodore A. Roth <troth@openavr.org>
* test_c/timer.c: Tweaks to allow compiling for at43usb320.
2003-11-11 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* doc/main.dox: Clean up some doxygen warnings.
* src/avrclass.c: Clean up some doxygen warnings.
2003-11-02 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c (gdb_parse_packet): When gdb sends the 'D' packet, it
actually does expect the "OK" response. That wasn't clear from the gdb
documentation.
2003-11-02 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/gdbserver.c: Handle 'D' packets (detach request from gdb). When
insight 'disconnects' from the target, it sends a 'D' packet which
caused simulavr to generate a fatal error since gdb closed down the
connection after sending the packet.
2003-11-01 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/gdb.h: Add irq_raise method.
* src/gdbserver.c (gdb_continue_with_signal): If gdb sends a signal
number greater than 94 (e.g. 'signal SIG80' sends signal number 94),
interpret that as being a request to raise avr interrupt number
signal_num-94.
* src/main.c (global_gdb_comm): Add irq_raise method.
2003-10-29 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/avrcore.c (avr_core_irq_raise): Display more info about the irq
in the output message.
2003-10-20 Theodore A. Roth <troth@openavr.org>
[Thanks to Keith Gudger <keith@atmel.com>]
* src/devsupp.c:
* src/intvects.c:
Add support for at43USB355, at43USB320, at43USB324, at43USB325, and
at43USB326.
2003-10-20 Theodore A. Roth <troth@openavr.org>
[Thanks to Keith Gudger <keith@atmel.com>]
* configure.ac (AC_INIT): Bump version.
* src/devsupp.c (dev_supp_create_core): Extend port width to be from
1 to 8 bits.
Fix error output to print chars instead of ints.
Add support for ports E and F.
* src/ports.c (name_PIN): Add "PINE" and "PINF".
(name_DDR): Add "DDRE" and "DDRF".
(name_PORT): Add "PORTE" and "PORTF".
(porte_new, porte_construct, porte_destroy): New functions.
(portf_new, portf_construct, portf_destroy): New functions.
* src/ports.h: Add support for port widths of 1-6.
Add prototypes to support ports E and F.
2003-10-14 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c (avr_core_construct): Cast irq_vtable structure to an
array of IntVect to perform irq indexing.
(avr_core_check_interrupts): Change IRQ_RESET to IRQ_RESET_ADDR to
avoid subtle confusion of array index versus vector address.
* src/intvects.c:
* src/intvects.h:
Simplify vector table initialization by using a structure for the
interrupt vector table instead of an array.
Define irq_vect_table_index() macro for calculating indices.
Define IRQ_RESET_ADDR.
* src/register.c (wdtcr_timer_cb): Use irq_vect_table_index() instead
of enum value.
* src/timers.c (timer_intr_cb): Ditto.
2003-10-14 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/avrcore.c (avr_core_irq_raise): Print out a message when raising
an interrupt.
(avr_core_check_interrupts): Print out a message when vectoring into
the interrupt table.
2003-10-03 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c (avr_core_run): Add note to comment about keeping
functionality out of the avr_core_run function and todo item about
adding rudimentary breakpoint handling to the loop.
2003-09-29 Theodore A. Roth <troth@openavr.org>
* src/devsupp.c:
* src/intvects.c:
Revert previous patch. It didn't even compile (my fault for not
checking that before committing it), so I am assuming that it is
not tested and sending it back to the submitter.
2003-09-26 Theodore A. Roth <troth@openavr.org>
[Contributed by Keith Gudger <keith@atmel.com>]
* src/devsupp.c:
* src/intvects.c:
Add support for at43USB355, at43USB320, at43USB324, at43USB325, and
at43USB326.
2003-09-26 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* doc/Makefile.am (EXTRA_DIST): Add main.dox.
* doc/doxygen.config.in (INPUT): Add @top_srcdir@/doc to search path.
(FILE_PATTERNS): Add *.dox pattern.
* doc/main.dox: Rename of src/maindoc.c.
* src/Makefile.am (EXTRA_DIST): Remove.
* src/maindoc.c: Rename to doc/main.dox.
2003-09-19 Theodore A. Roth <troth@openavr.org>
* README.cygwin: Change CFLAGS to LDFLAGS in configure example.
2003-09-19 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
Add AC_CANONICAL_BUILD, AC_CANONICAL_HOST and AC_CANONICAL_TARGET.
* Makefile.am (EXTRA_DIST): Add README.cygwin.
* README.gdb: Remove references to gdb patches directory.
[Contributed by Eric Weddingtion <eric@ecentral.com>]
* README.cygwin: New file.
2003-09-15 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
(AC_CONFIG_FILES): Untabify src/getopt/Makefile line.
2003-09-12 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
* src/avrcore.c: Hide struct bp_enable_data from doxygen.
* src/callback.c: Hide struct _CallBack from doxygen.
* src/devsupp.c: Hide struct _DevSuppDefn from doxygen.
2003-09-12 Theodore A. Roth <troth@openavr.org>
* configure.ac: Remove typedefs for byte, word, dword, qword, sbyte,
sword, sdword, and sqword.
* src/avrcore.c: Replace byte with uint8_t.
Replace word with uint16_t.
Replace dword with uint32_t.
Replace qword with uint64_t.
Replace sbyte with int8_t.
Replace sword with int16_t.
Replace sdword with int32_t.
Replace sqword with int64_t.
* src/avrcore.h: Ditto.
* src/callback.c: Ditto.
* src/callback.h: Ditto.
* src/decoder.c: Ditto.
* src/decoder.h: Ditto.
* src/device.c: Ditto.
* src/devsupp.c: Ditto.
* src/display.c: Ditto.
* src/display.h: Ditto.
* src/eeprom.c: Ditto.
* src/eeprom.h: Ditto.
* src/flash.c: Ditto.
* src/flash.h: Ditto.
* src/gdb.h: Ditto.
* src/gdbserver.c: Ditto.
* src/intvects.h: Ditto.
* src/main.c: Ditto.
* src/memory.c: Ditto.
* src/memory.h: Ditto.
* src/ports.c: Ditto.
* src/ports.h: Ditto.
* src/register.c: Ditto.
* src/register.h: Ditto.
* src/sram.c: Ditto.
* src/stack.c: Ditto.
* src/stack.h: Ditto.
* src/storage.c: Ditto.
* src/storage.h: Ditto.
* src/timers.c: Ditto.
* src/timers.h: Ditto.
* src/utils.c: Ditto.
* src/utils.h: Ditto.
* src/vdevs.h: Ditto.
2003-09-09 Theodore A. Roth <troth@openavr.org>
[Contributed by Hermann Kraus <hnkraus@compuserve.de>]
* test_c/Makefile.am: Update copyright year.
Add timer program.
Add common.h to all SOURCES variables.
* test_c/common.h: New file.
* test_c/deep_frame.c: Use common.h.
Use 'sfr = val' idiom instead of sbi function.
* test_c/demo.c: Ditto.
* test_c/demo_kr.c: Ditto.
* test_c/timer.c: New file.
2003-09-09 Theodore A. Roth <troth@openavr.org>
[Contributed by Hermann Kraus <hnkraus@compuserve.de>]
* configure.ac (AC_INIT): Bump version.
* src/callback.c (callback_construct): Check data pointer before
passing to class_ref.
(callback_destroy): Check data pointer before passing to class_unref.
2003-08-29 Theodore A. Roth <troth@openavr.org>
[Thanks to Hermann Kraus <hnkraus@compuserve.de>]
* configure.ac (AC_INIT): Bump version.
* simulavr.1.in: Remove '=' from option descriptions since it is
confusing people.
* src/main.c: Diddo.
* doc/simulavr.texi: Diddo.
Update savannah references.
Remove notes about needing to patch gdb for avr.
2003-08-27 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
Add missing call to CHECK_DOXYGEN.
* simulavr.spec.in: Fix broken rpmbuild on RedHat-9.
2003-08-26 Theodore A. Roth <troth@openavr.org>
* configure.ac (AC_INIT): Bump version.
(AC_CHECK_HEADERS): Remove check for libintl.h so it doesn't get used
in gnu_getopt.c.
* src/getopt/gnu_getopt.c: Don't allow _ to be defined to gettext().
2003-08-18 Theodore A. Roth <troth@openavr.org>
* simulavr.1.in: Add version to output.
Add mega8 and mega16 to supported list.
* src/gdbserver.c: Shorten up some long lines.
2003-08-18 Theodore A. Roth <troth@openavr.org>
* configure.ac: Bump version.
* src/gdbserver.c (gdb_interact): Set addrLength correctly so source
IP addresses are reported correctly.
2003-08-13 Theodore A. Roth <troth@openavr.org>
* Makefile.am: Rename @DOC_INST_DIR@ to @ac_doc_inst_dir@.
* configure.ac: Bump version.
Remove --with-docdir option.
Re-instate --enable-versioned-doc option and set ac_doc_inst_dir
relative to $(datadir).
* doc/Makefile.am: Rename @DOC_INST_DIR@ to @ac_doc_inst_dir@.
* test_asm/test_8515/Makefile.am: Add clean-local rule to make sure
final binaries are removed.
2003-08-13 Theodore A. Roth <troth@openavr.org>
* src/device.c: Update copyright year.
2003-08-13 Theodore A. Roth <troth@openavr.org>
[Thanks to Hermann Kraus <hnkraus@compuserve.de>]
* doc/simulavr.texi: Fix 'target remote' note.
* src/avrcore.c: Wrap some line lines.
Document all functions via doxygen.
* src/device.c: Document all functions via doxygen.
2003-08-12 Theodore A. Roth <troth@openavr.org>
* Makefile.am: Remove AUX_DIST and AUX_DIST_EXTRA vars.
Remove refs to acconfig.h and config/.
* configure.ac: Add check for RANLIB.
Add src/getopt/Makefile to output.
* src/Makefile.am: Add getopt subdir.
(AM_CFLAGS): Add src/getopt via -I.
(simulavr_LDADD): Define.
(simulavr_SOURCES): Remove gnu_getopt* sources.
* src/disp/Makefile.am: Link to ../getopt/libgnugetopt.a.
* src/disp-vcd/Makefile.am: Link to ../getopt/libgnugetopt.a.
* src/getopt/Makefile.am: New file to build ../getopt/libgnugetopt.a.
* src/gnu_getopt.c, src/getopt/gnu_getopt.c: Move gnu_getopt.c into
src/getopt subdir.
* src/gnu_getopt.h, src/getopt/gnu_getopt.h: Move gnu_getopt.h into
src/getopt subdir.
* src/gnu_getopt1.c, src/getopt/gnu_getopt1.c: Move gnu_getopt1.c into
src/getopt subdir.
2003-08-12 Theodore A. Roth <troth@openavr.org>
* Makefile.am: Convert to use autoconf-2.57 and automake-1.7.x.
* bootstrap: Convert to use autoconf-2.57 and automake-1.7.x.
* configure.ac: New file.
* acconfig.h: Remove file.
* configure.in: Remove file.
* config/avr_binutils.m4: Remove file.
* config/avr_cc.m4: Remove file.
* config/avr_doc_dirsuffix.m4: Remove file.
* config/avr_doc_pdf.m4: Remove file.
* config/avr_doc_ps.m4: Remove file.
* config/avr_libc_headers.m4: Remove file.
* config/check_autoconf213.m4: Remove file.
* config/check_doxygen.m4: Remove file.
* config/check_gnu_make.m4: Remove file.
* config/check_python.m4: Remove file.
* config/check_texinfo.m4: Remove file.
* config/enable_curses.m4: Remove file.
* config/enable_tests.m4: Remove file.
* config/type_socklen_t.m4: Remove file.
2003-08-12 Theodore A. Roth <troth@openavr.org>
* simulavr.1.in: Update bug report email address.
2003-08-12 Theodore A. Roth <troth@openavr.org>
* configure.in: Add more checks as found by autoscan.
2003-08-08 Theodore A. Roth <troth@openavr.org>
* src/gnu_getopt.h: Define HAVE_DECL_GETOPT to fix declaration clash.
2003-08-08 Theodore A. Roth <troth@openavr.org>
[Contributed by Tuukka Pasanen]
* src/devsupp.c:
* src/intvects.c:
Add basic support for mega8.
2003-08-01 Theodore A. Roth <troth@openavr.org>
* acconfig.h: Handle missing socklen_t type.
2003-08-01 Theodore A. Roth <troth@openavr.org>
* configure.in: Bump version.
Add check to socklen_t.
* config/type_socklen_t.m4: New file.
2003-07-24 Theodore A. Roth <troth@openavr.org>
* AUTHORS:
* ChangeLog:
* config/avr_binutils.m4:
* config/avr_cc.m4:
* config/avr_libc_headers.m4:
* config/check_doxygen.m4:
* config/check_gnu_make.m4:
* config/check_python.m4:
* config/check_texinfo.m4:
* config/enable_curses.m4:
* config/enable_tests.m4:
Update my email address.
2003-07-02 Theodore A. Roth <troth@openavr.org>
* configure.in: Bump version.
* src/main.c: Update copyright year for --version output.
2003-06-20 Theodore A. Roth <troth@openavr.org>
* configure.in: Bump version.
2003-06-20 Theodore A. Roth <troth@openavr.org>
* gdb-patches/README: Remove file.
* simulavr.spec.in: Bump avr-gdb requirement to 5.3.
* src/avrcore.c:
* src/avrcore.h:
* src/gdb.h:
* src/main.c:
Add enable_breakpoints and disable breakpoints methods.
* src/gdbserver.c: Ditto.
Disable breakpoints when a break point is hit. This restores the insn
which was previously replaced with a BREAK insn if the break point was
set by gdb. This was needed to get the sim to send the correct insn
back to gdb instead of the BREAK insn.
2003-06-20 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c: Fix a bug in handled of 'P' packets causing PC to
be truncated.
2003-06-20 Theodore A. Roth <troth@openavr.org>
* src/gdbserver.c: Update copyright year.
If-def out use of EEPROM space since gdb handle it.
2003-04-06 Theodore A. Roth <troth@openavr.org>
[Thanks to Hermann Kraus <hnkraus@compuserve.de>]
* src/devsupp.c:
* src/intvects.c:
Added support for the ATMega16 device
2003-04-04 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c:
* src/decoder.c:
* src/decoder.h:
Speed up the opcode handlers by calculating the argument values at
init time and passing them to the handler when it is called. My tests
show this to be a 1.5 to 3.5 % increase.
2003-04-04 Theodore A. Roth <troth@openavr.org>
* configure.in: Bump version.
* src/disp/disp.c: Include termios.h to get winsize decl on cygwin.
[Thanks to Slawomir Kawalek <sk@centrum.pl>].
2003-03-25 Theodore A. Roth <troth@openavr.org>
* regress/regress.py.in: Fix --sim option to take an argument.
2003-03-04 Theodore A. Roth <troth@openavr.org>
* src/avrcore.c:
* src/gdb.h:
* src/gdbserver.c:
* src/main.c:
Implement the io_fetch method for the gdbserver interface.
2003-02-22 Theodore A. Roth <troth@openavr.org>
* doc/simulavr.texi: Fix gdb configure target argument.

View file

@ -0,0 +1,73 @@
#
# $Id: INSTALL,v 1.8 2002/04/12 23:12:21 troth Exp $
#
This file documents how to build and install simulavr on a unix-like system
using the provided configure script.
Although it is not required, you should have already built and installed
binutils for avr, avr-gcc, uisp and possibly avr-gdb. In order to build and
use the test programs in test_asm/ and test_c/ directories, you must have
avr gcc and avr binutils properly installed and in your PATH. If you don't
have them installed, you should pass configure the "--disable-tests" option.
If you want to use simulavr as a backend to gdb, see the README.gdb file in
the simulavr source.
To build simulavr, run this command in the top level directory:
$ ./configure
This will configure simulavr to be installed in the default "/usr/local/"
location. If you wish to install it in another location, use the
"--prefix=<dir>" option to configure. It is posible to install in your home
directory if you don't have root access to the "/usr/local/". For instance, I
like to install software like this:
$ ./configure --prefix=$HOME/local/simulavr
In this case, if you think that simulavr is crappy software, you can easily
remove it by removing the "$HOME/local/simulavr" directory. If you wish to
keep it, you might need to add "$HOME/local/simulavr/bin" to your PATH
environment variable so that you can run it by just typing `simulavr` instead
of the full path. Theoretically, you should be able to uninstall the installed
files using the 'make uninstall' command.
If you wish to include more agressive build optimizations, do this:
$ my_CFLAGS='-g -O2 -Wall -fomit-frame-pointer -finline-functions \
> -march=i686 -mcpu=i686"
$ CFLAGS=$my_CFLAGS ./configure
I have seen significant speedups using the above optimizations on my Pentium
Pro development system. You may have better luck with other CFLAGS values. See
`man gcc` for other compiler flags. Of course, if you aren't using gcc, your
CFLAGS choices may be quite different.
Once you have run the configure script, you can build and install the
simulator.
$ make
$ make install
If the build fails while trying to build the programs in the test_c directory
complaining about not being able to find the avr libc header files, you will
have to tell the build system where those files are located. This is done by
passing an option to configure:
$ ./configure --with-avr-include=<your path to avr include files>
To view all the available configure options, use the "--help" configure
option:
$ ./configure --help
If you wish to verify that your build of the simulator works, run the
regression tests like this:
$ make check
This will automatically build simulavr if needed. The regression test engine
automatically starts up an instance of simulavr to run the tests. If any test
fails, I want to hear about it, so send me an email.

View file

@ -0,0 +1,27 @@
The Simulavr project is a simulator for the Atmel AVR family of 8-bit, risc
microcontrollers. Currently supported devices include the at90s1200,
at90s2313, at90s4414 and at90s8515. The simulation of these devices is not
quite complete, but most of the useful functionality is present.
Support is also present for running the simulator as a remote target of
gdb-5.x. Since gdb does not currently support the AVR micros, a patch is
supplied with simulavr to provide that support with the hopes that the gdb
patch will eventually be integrated into the gdb source tree proper.
Texinfo based documentation has already been started, but needs much work done
in documenting the internals of the simulator in order to help new developers
learn how to add support for new devices as Atmel introduces them.
The Simulavr project is expected to progress in the following stages:
1. Solidify support for running as a gdb remote target.
2. Acheive 100% simulation of the existing supported devices.
3. Design and implement a modular external periheral interface to allow
simulation of peripherals such as LCD displays, ethernet ports, etc.
4. Add support for all at90sXXXX series devices.
5. Add support for atMegaXXX series devices.
6. Add support for atTinyXXX series devices.
7. ???
The project already exists and you can see it at
http://savannah.gnu.org/projects/simulavr/

View file

@ -0,0 +1,45 @@
#
# $Id: README,v 1.10 2002/04/12 23:12:21 troth Exp $
#
Simulavr: A simulator for the Atmel AVR family of microcontrollers.
This program is still under development and is not ready for production
use. The simulator is stable enough for rudimentary debugging work in
conjuction with a gdb-5.2 (see README.gdb).
At this early stage of development, when simulavr enters a failure mode, it
will print an error message and abort, thus generating a core file. This is
actually quite useful, since you can examine the core file and see what caused
simulavr to get confused. This is similar to what happens when a program seg
faults and dumps core, but the error message should at least tell you where to
start looking since it gives the file name and line number where the error
message was generated. As of version 0.0.14, I haven't seen simulavr abort in
quite some time. Take that with a grain of salt. :)
I've only been testing this with the at90s8515 since that's the only device I
have right now to compare with.
I am hoping to support all AVR devices, but am not going to work on the TINY's
and MEGA's until I get all the features of the at90s* devices working, and
have solid gdb support. If someone else would like to contribute code for TINY
or MEGA support, that would be greatly appreciated.
To build the simulator, you need to use gcc for now. There is some gcc
specific code in the source. I'm only doing this for now since it makes
debugging a little bit easier. I'll gladly accept porting feedback if someone
wishes to work on that front. I'm currently only developing using RedHat 7.2.
Some preliminary porting has been done on NetBSD and FreeBSD.
To build my test asm and C files, you need to have gcc and binutils build for
avr and installed in your path.
See the INSTALL file for more information on building and installing the
simulator.
There is the beginnings of documentation in the doc/ directory. The build
system should automatically build the info, postscript and html formats of the
documentation. If for some reason you have trouble building the documentation
from the texinfo source, check the simulavr web site. I hope to keep the
latest versions of the documenation there.

View file

@ -0,0 +1,34 @@
##
## $Id: README.gdb,v 1.5 2003/09/19 19:59:20 troth Exp $
##
This README file discusses the issues involved with using the simulator
remotely from gdb.
First off, you will need to compile gdb >= 5.2.1 with the avr target support.
Once you've built and installed gdb for avr, you need to know how to use it to
debug a remote program. It's an easy, two step process. First, you need to
start up simulavr in gdbserver mode as such:
$ simulavr --gdbserver [other options]
Second, just start up avr-gdb with an avr elf program, connect to the remote
target, and load the program into the sim with these commands:
$ avr-gdb myprog.elf
(gdb) target remote localhost:<port>
(gdb) load
where <port> is the port number that simulavr is listening on. You need to
have the simulavr running before giving gdb the target command. In most cases,
you'll be running simulavr on the same host as gdb, thus the "localhost"
part. You must use the same port number for simulavr and in the gdb target
command. If you feel the need to run simulavr on another host, just change
localhost to the name of the host that simulavr will be running on.
After gdb has connected to the remote target, you should be able to use gdb
just as if you were debugging a program natively.
For more detailed information, see the documentation in the doc subdirectory.

View file

@ -0,0 +1,247 @@
#
# $Id: README.opcodes,v 1.3 2001/12/02 21:54:45 troth Exp $
#
##############################################################################
##
## Most of the information in this file was taken directly from the Atmel
## data sheets and is most likely copyrighted by Atmel. As such, this file
## may need to disappear.
##
##############################################################################
Instruction Set Nomenclature:
Status Register (SREG)
SREG: Status register
C: Carry flag in status register
Z: Zero flag in status register
N: Negative flag in status register
V: Two's complement overflow indicator
S: N A* V, For signed tests
H: Half Carry flag in the status register
T: Transfer bit used by BLD and BST instructions
I: Global interrupt enable/disable flag
Registers and Operands
Rd: Destination (and source) register in the register file
Rr: Source register in the register file
R: Result after instruction is executed
K: Constant data
k: Constant address
b: Bit in the register file or I/O register (3 bit)
s: Bit in the status register (3 bit)
X,Y,Z: Indirect address register (X=R27:R26, Y=R29:R28 and Z=R31:R30)
A: I/O location address
q: Displacement for direct addressing (6 bit)
I/O Registers
RAMPX, RAMPY, RAMPZ
Registers concatenated with the X, Y and Z registers enabling indirect
addressing of the whole data space on MCUs withmore than 64K bytes data space,
and constant data fetch on MCUs with more than 64K bytes program space.
RAMPD
Register concatenated with the Z register enabling direct addressing of the
whole data space on MCUs with more than 64Kbytes data space.
EIND
Register concatenated with the instruction word enabling indirect jump and
call to the whole program space on MCUs withmore than 64K bytes program space.
Stack
STACK: Stack for return address and pushed registers
SP: Stack Pointer to STACK
Flags
<=>: Flag affected by instruction
0: Flag cleared by instruction
1: Flag set by instruction
-: Flag not affected by instruction
Conditional Branch Summary
Note: 1. Interchange Rd and Rr in the operation before the test. i.e.
CP Rd,Rr -> CP Rr,Rd
Test Boolean Mnemonic Complementary Boolean Mnemonic Comment
Rd > Rr Z&(N ^ V) = 0 BRLT(1) Rd <= Rr Z+(N ^ V) = 1 BRGE* Signed
Rd >= Rr (N ^ V) = 0 BRGE Rd < Rr (N ^ V) = 1 BRLT Signed
Rd = Rr Z = 1 BREQ Rd != Rr Z = 0 BRNE Signed
Rd <= Rr Z+(N ^ V) = 1 BRGE(1) Rd > Rr Z&(N ^ V) = 0 BRLT* Signed
Rd < Rr (N ^ V) = 1 BRLT Rd >= Rr (N ^ V) = 0 BRGE Signed
Rd > Rr C + Z = 0 BRLO(1) Rd <= Rr C + Z = 1 BRSH* Unsigned
Rd >= Rr C = 0 BRSH/BRCC Rd < Rr C = 1 BRLO/BRCS Unsigned
Rd = Rr Z = 1 BREQ Rd != Rr Z = 0 BRNE Unsigned
Rd <= Rr C + Z = 1 BRSH(1) Rd > Rr C + Z = 0 BRLO* Unsigned
Rd < Rr C = 1 BRLO/BRCS Rd >= Rr C = 0 BRSH/BRCC Unsigned
Carry C = 1 BRCS No carry C = 0 BRCC Simple
Negative N = 1 BRMI Positive N = 0 BRPL Simple
Overflow V = 1 BRVS No overflow V = 0 BRVC Simple
Zero Z = 1 BREQ Not zero Z = 0 BRNE Simple
Complete Instruction Set Summary
Notes:
1. Not all instructions are available in all devices. Refer to the device
specific instruction summary.
2. Cycle times for data memory accesses assume internal memory accesses, and
are not valid for accesses via the external RAM interface. For LD, ST, LDS,
STS, PUSH, POP, add one cycle plus one cycle for each wait state. For CALL,
ICALL, EICALL, RCALL, RET, RETI in devices with 16 bit PC, add three cycles
plus two cycles for each wait state. For CALL, ICALL, EICALL, RCALL, RET,
RETI in devices with 22 bit PC, add five cycles plus three cycles for each
wait state.
Instruction Set Summary
Arithmetic and Logic Instructions
| | | | Device Availability|
Mnem | Opcode | Operands | Method Name | 1200 | 4414 | 8515 |
=======|=====================|==========|=============|======|======|======|
ADC | 0001 11rd dddd rrrr | Rd, Rr | ADC | * | * | * |
ADD | 0000 11rd dddd rrrr | Rd, Rr | ADD | * | * | * |
ADIW | 1001 0110 KKdd KKKK | Rd, Rr | ADIW | - | * | * |
AND | 0010 00rd dddd rrrr | Rd, Rr | AND | * | * | * |
ANDI | 0111 KKKK dddd KKKK | Rd, K | ANDI | * | * | * |
ASR | 1001 010d dddd 0101 | Rd | ASR | * | * | * |
BCLR | 1001 0100 1sss 1000 | s | BCLR | * | * | * |
BLD | 1111 100d dddd 0bbb | Rd, b | BLD | * | * | * |
BRBC | 1111 01kk kkkk ksss | s, k | BRCS | * | * | * |
BRBS | 1111 00kk kkkk ksss | s, k | BRBS | * | * | * |
BRCC | 1111 01kk kkkk k000 | k | BRCC | * | * | * |
BRCS | 1111 00kk kkkk k000 | k | BRCS | * | * | * |
BREQ | 1111 00kk kkkk k001 | k | BREQ | * | * | * |
BRGE | 1111 01kk kkkk k100 | k | BRGE | * | * | * |
BRHC | 1111 01kk kkkk k101 | k | BRHC | * | * | * |
BRHS | 1111 00kk kkkk k101 | k | BRHS | * | * | * |
BRID | 1111 01kk kkkk k111 | k | BRID | * | * | * |
BRIE | 1111 00kk kkkk k111 | k | BRIE | * | * | * |
BRLO | 1111 00kk kkkk k000 | k | BRCS | * | * | * |
BRLT | 1111 00kk kkkk k100 | k | BRLT | * | * | * |
BRMI | 1111 00kk kkkk k010 | k | BRMI | * | * | * |
BRNE | 1111 01kk kkkk k001 | k | BRNE | * | * | * |
BRPL | 1111 01kk kkkk k010 | k | BRPL | * | * | * |
BRSH | 1111 01kk kkkk k000 | k | BRCC | * | * | * |
BRTC | 1111 01kk kkkk k110 | k | BRTC | * | * | * |
BRTS | 1111 00kk kkkk k110 | k | BRTS | * | * | * |
BRVC | 1111 01kk kkkk k011 | k | BRVC | * | * | * |
BRVS | 1111 00kk kkkk k011 | k | BRVS | * | * | * |
BSET | 1001 0100 0sss 1000 | s | BSET | * | * | * |
BST | 1111 101d dddd 0bbb | Rr, b | BST | * | * | * |
CALL | 1001 010k kkkk 111k | k | CALL | - | - | - |
| kkkk kkkk kkkk kkkk | | | | | |
CBI | 1001 1000 AAAA Abbb | A, b | CBI | * | * | * |
CBR | 0111 KKKK dddd KKKK | Rd, K | CBR | * | * | * |
CLC | 1001 0100 1000 1000 | | CLC | * | * | * |
CLH | 1001 0100 1101 1000 | | CLH | * | * | * |
CLI | 1001 0100 1111 1000 | | CLI | * | * | * |
CLN | 1001 0100 1010 1000 | | CLN | * | * | * |
CLR | 0010 01dd dddd dddd | Rd | EOR | * | * | * |
CLS | 1001 0100 1100 1000 | | CLS | * | * | * |
CLT | 1001 0100 1110 1000 | | CLT | * | * | * |
CLV | 1001 0100 1011 1000 | | CLV | * | * | * |
CLZ | 1001 0100 1001 1000 | | CLZ | * | * | * |
COM | 1001 010d dddd 0000 | Rd | COM | * | * | * |
CP | 0001 01rd dddd rrrr | Rd, Rr | CP | * | * | * |
CPC | 0000 01rd dddd rrrr | Rd, Rr | CPC | * | * | * |
CPI | 0011 KKKK dddd KKKK | Rd, K | CPI | * | * | * |
CPSE | 0001 00rd dddd rrrr | Rd, Rr | CPSE | * | * | * |
DEC | 1001 010d dddd 1010 | Rd | DEC | * | * | * |
EICALL | 1001 0101 0001 1001 | | EICALL | - | - | - |
EIJMP | 1001 0100 0001 1001 | | EIJMP | - | - | - |
ELPM | 1001 0101 1101 1000 | | ELPM | - | - | - |
ELPM | 1001 000d dddd 0110 | Rd, Z | ELPM_Z | - | - | - |
ELPM | 1001 000d dddd 0111 | Rd, Z+ | ELPM_Z_incr | - | - | - |
EOR | 0010 01rd dddd rrrr | Rd, Rr | EOR | * | * | * |
ESPM | 1001 0101 1111 1000 | | ESPM | - | - | - |
FMUL | 0000 0011 0ddd 1rrr | Rd, Rr | FMUL | - | - | - |
FMULS | 0000 0011 1ddd 0rrr | Rd, Rr | FMULS | - | - | - |
FMULSU | 0000 0011 1ddd 1rrr | Rd, Rr | FMULSU | - | - | - |
ICALL | 1001 0101 0000 1001 | | ICALL | - | * | * |
IJMP | 1001 0100 0000 1001 | | IJMP | - | * | * |
IN | 1011 0AAd dddd AAAA | Rd, A | IN | * | * | * |
INC | 1001 010d dddd 0011 | Rd | INC | * | * | * |
JMP | 1001 010k kkkk 110k | k | JMP | - | - | - |
| kkkk kkkk kkkk kkkk | | | | | |
LD | 1000 000d dddd 1000 | Rd, Y | LDD_Y | - | * | * |
LD | 1001 000d dddd 1001 | Rd, Y+ | LD_Y_incr | - | * | * |
LD | 1000 000d dddd 0000 | Rd, Z | LDD_Z | * | * | * |
LD | 1001 000d dddd 0001 | Rd, Z+ | LD_Z_incr | - | * | * |
LD | 1001 000d dddd 1110 | Rd, -X | LD_X_decr | - | * | * |
LD | 1001 000d dddd 1010 | Rd, -Y | LD_Y_decr | - | * | * |
LD | 1001 000d dddd 0010 | Rd, -Z | LD_Z_decr | - | * | * |
LD | 1001 000d dddd 1100 | Rd, X | LD_X | - | * | * |
LD | 1001 000d dddd 1101 | Rd, X+ | LD_X_incr | - | * | * |
LDD | 10q0 qq0d dddd 1qqq | Rd, Y+q | LDD_Y | - | * | * |
LDD | 10q0 qq0d dddd 0qqq | Rd, Z+q | LDD_Z | - | * | * |
LDI | 1110 KKKK dddd KKKK | Rd, K | LDI | * | * | * |
LDS | 1001 000d dddd 0000 | Rd, k | LDS | - | * | * |
| kkkk kkkk kkkk kkkk | | | | | |
LPM | 1001 0101 1100 1000 | | LPM | - | * | * |
LPM | 1001 000d dddd 0100 | Rd, Z | LPM_Z | - | - | - |
LPM | 1001 000d dddd 0101 | Rd, Z+ | LPM_Z_incr | - | - | - |
LSL | 0000 11dd dddd dddd | Rd | AND | * | * | * |
LSR | 1001 010d dddd 0110 | Rd | LSR | * | * | * |
MOV | 0010 11rd dddd rrrr | Rd, Rr | MOV | * | * | * |
MOVW | 0000 0001 dddd rrrr | Rd, Rr | MOVW | - | - | - |
MUL | 1001 11rd dddd rrrr | Rd, Rr | MUL | - | - | - |
MULS | 0000 0010 dddd rrrr | Rd, Rr | MULS | - | - | - |
MULSU | 0000 0011 dddd rrrr | Rd, Rr | MULSU | - | - | - |
NEG | 1001 010d dddd 0001 | Rd | NEG | * | * | * |
NOP | 0000 0000 0000 0000 | | NOP | * | * | * |
OR | 0010 10rd dddd rrrr | Rd, Rr | OR | * | * | * |
ORI | 0110 KKKK dddd KKKK | Rd, K | ORI | * | * | * |
OUT | 1011 1AAd dddd AAAA | A, Rd | OUT | * | * | * |
POP | 1001 000d dddd 1111 | Rd | POP | - | * | * |
PUSH | 1001 001d dddd 1111 | Rd | PUSH | - | * | * |
RCALL | 1101 kkkk kkkk kkkk | k | RCALL | * | * | * |
RET | 1001 0101 0000 1000 | | RET | * | * | * |
RETI | 1001 0101 0001 1000 | | RETI | * | * | * |
RJMP | 1100 kkkk kkkk kkkk | k | RJMP | * | * | * |
ROL | 0001 11dd dddd dddd | Rd | ADC | * | * | * |
ROR | 1001 010d dddd 0111 | Rd | ROR | * | * | * |
SBC | 0000 10rd dddd rrrr | Rd, Rr | SBC | * | * | * |
SBCI | 0100 KKKK dddd KKKK | Rd, K | SBCI | * | * | * |
SBI | 1001 1010 AAAA Abbb | A, b | SBI | * | * | * |
SBIC | 1001 1001 AAAA Abbb | A, b | SBIC | * | * | * |
SBIS | 1001 1011 AAAA Abbb | A, b | SBIS | * | * | * |
SBIW | 1001 0111 KKdd KKKK | Rd, K | SBIW | - | - | - |
SBR | 0110 KKKK dddd KKKK | Rd, K | SBR | * | * | * |
SBRC | 1111 110d dddd 0bbb | Rd, b | SBRC | * | * | * |
SBRS | 1111 111d dddd 0bbb | Rd, b | SBRS | * | * | * |
SEC | 1001 0100 0000 1000 | | SEC | * | * | * |
SEH | 1001 0100 0101 1000 | | SEH | * | * | * |
SEI | 1001 0100 0111 1000 | | SEI | * | * | * |
SEN | 1001 0100 0010 1000 | | SEN | * | * | * |
SER | 1110 1111 dddd 1111 | Rd | LDI | * | * | * |
SES | 1001 0100 0100 1000 | | SES | * | * | * |
SET | 1001 0100 0110 1000 | | SET | * | * | * |
SEV | 1001 0100 0011 1000 | | SEV | * | * | * |
SEZ | 1001 0100 0001 1000 | | SEZ | * | * | * |
SLEEP | 1001 0101 1000 1000 | | SLEEP | * | * | * |
SPM | 1001 0101 1110 1000 | | SPM | - | - | - |
ST | 1001 001d dddd 1101 | X+, Rd | ST_X_incr | - | * | * |
ST | 1001 001d dddd 1100 | X, Rd | ST_X | - | * | * |
ST | 1001 001d dddd 1001 | Y+, Rd | ST_Y_incr | - | * | * |
ST | 1000 001d dddd 1000 | Y, Rd | STD_Y | - | * | * |
ST | 1001 001d dddd 0001 | Z+, Rd | ST_Z_incr | - | * | * |
ST | 1000 001d dddd 0000 | Z, Rd | STD_Z | * | * | * |
ST | 1001 001d dddd 1110 |-X, Rd | ST_X_decr | - | * | * |
ST | 1001 001d dddd 1010 |-Y, Rd | ST_Y_decr | - | * | * |
ST | 1001 001d dddd 0010 |-Z, Rd | ST_Z_decr | - | * | * |
STD | 10q0 qq1d dddd 1qqq | Y+q, Rd | STD_Y | - | * | * |
STD | 10q0 qq1d dddd 0qqq | Z+q, Rd | STD_Z | - | * | * |
STS | 1001 001d dddd 0000 | k, Rd | STS | - | * | * |
| kkkk kkkk kkkk kkkk | | | | | |
SUB | 0001 10rd dddd rrrr | Rd, Rr | SUB | * | * | * |
SUBI | 0101 KKKK dddd KKKK | Rd, K | SUBI | * | * | * |
SWAP | 1001 010d dddd 0010 | Rd | SWAP | * | * | * |
TST | 0010 00dd dddd dddd | Rd | AND | * | * | * |
WDR | 1001 0101 1010 1000 | | WDR | * | * | * |

View file

@ -0,0 +1,66 @@
During 0.1.x:
- complete simulation of 8515 device.
- external peripheral device connection interface.
- write, read and access watchpoints
- documentation
During 0.2.x:
- add support for all at90s**** devices (Is this too ambitious?)
- speed improvements (optimization)
During 0.3.x:
- add support for megas and tiny's (This might require some redesign
work to get the atmega128 like devices right)
Misc TODO's:
The conversion to autoconf/automake configuration is working, but still needs
to have the actual porting issues worked into the project. Also, the autoconf
macros (the config/*.m4 files) could be robustified. For instance, the
TROTH_PROG_AVR_CC macro really should do more than just checking if avr-gcc is
in yout $PATH. It should also make sure that avr-gcc works. Like wise for the
other macros. It's a start at least.
Build the virtual hardware harness and gui. I'm thinking it be able to plug a
device into something like the Atmel stk200 board thus giving the user LEDs
for visual feed back and push buttons for supplying inputs to the ports. Also,
I'd like to simulate the analog comparators and ADCs if possible. It might
also be interesting to simulate a popular LCD display. More interesting might
be the potential for custom user designed virtual peripherals which could be
plugged into the virtual board. I wonder if I can use the same interface as
gpsim, thus allowing the sharing of modules between the two projects?
Make a python module out of the library.
Need to write functions for loading/dumping eeprom from/to files.
Add support for ihex, srec, elf, and whatever else input file formats.
The interrupt code looks like it needs a major re-thinking. It doesn't handle
the interrupt flag mechanism and doesn't support automatic vectoring into ISRs
that occurred when the interrupt occured and was disabled either globally or
by the specific control register and then the interrupt was subsequently
enabled. This looks like it might be yucky. I'm seriously thinking that
interrupts need to be handled via some asyncronous mechanism like unix
signals. Also, some way to implement the interrupt response time needs to be
thought out.
Add code to output number of instructions executed (and per second) and total
number of clocks (and per second). Should go in main.c.
There's a bunch of FIXME comments in the code in places where someone needs to
give more thought to the logic.
These io registers still need to be implemented:
GIMSK
GIFR
All the timer/counter 1 stuff.
Lots of others too.

View file

@ -0,0 +1,87 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: Top</title>
<meta name="description" content="Simulavr: Top">
<meta name="keywords" content="Simulavr: Top">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Top"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="settitle">Simulavr
</h1>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="simulavr_1.html#SEC1">1. Introduction: What is simulavr?</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> What is simulavr?
</td></tr>
<tr><td align="left" valign="top"><a href="simulavr_2.html#SEC2">2. Invoking Simulavr</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> How to run simulavr
</td></tr>
<tr><td align="left" valign="top"><a href="simulavr_5.html#SEC5">3. Using with GDB</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> How to use simulavr with gdb
</td></tr>
<tr><td align="left" valign="top"><a href="simulavr_8.html#SEC8">4. Display Coprocesses</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> How to display the processors state
</td></tr>
<tr><td align="left" valign="top"><a href="simulavr_9.html#SEC9">5. Simulavr Internals</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> Developing simulavr
</td></tr>
<tr><td align="left" valign="top"><a href="simulavr_10.html#SEC10">6. Reporting Bugs</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> Reporting bugs
</td></tr>
<tr><td align="left" valign="top"><a href="simulavr_11.html#SEC11">Concept Index</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>
<hr size="1">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,87 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: Top</title>
<meta name="description" content="Simulavr: Top">
<meta name="keywords" content="Simulavr: Top">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Top"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="settitle">Simulavr
</h1>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="simulavr_1.html#SEC1">1. Introduction: What is simulavr?</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> What is simulavr?
</td></tr>
<tr><td align="left" valign="top"><a href="simulavr_2.html#SEC2">2. Invoking Simulavr</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> How to run simulavr
</td></tr>
<tr><td align="left" valign="top"><a href="simulavr_5.html#SEC5">3. Using with GDB</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> How to use simulavr with gdb
</td></tr>
<tr><td align="left" valign="top"><a href="simulavr_8.html#SEC8">4. Display Coprocesses</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> How to display the processors state
</td></tr>
<tr><td align="left" valign="top"><a href="simulavr_9.html#SEC9">5. Simulavr Internals</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> Developing simulavr
</td></tr>
<tr><td align="left" valign="top"><a href="simulavr_10.html#SEC10">6. Reporting Bugs</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> Reporting bugs
</td></tr>
<tr><td align="left" valign="top"><a href="simulavr_11.html#SEC11">Concept Index</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>
<hr size="1">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,101 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: 1. Introduction: What is simulavr?</title>
<meta name="description" content="Simulavr: 1. Introduction: What is simulavr?">
<meta name="keywords" content="Simulavr: 1. Introduction: What is simulavr?">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Introduction"></a>
<a name="SEC1"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr.html#Top" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[ &lt;&lt; ]</td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 1. Introduction: What is simulavr? </h1>
<blockquote><p>It's just a model.
<br>
&mdash; Monty Python
</p></blockquote>
<br>
<p>The Simulavr program is a simulator for the Atmel AVR family of
microcontrollers. Simulavr can be used either standalone or as a remote
target for gdb. When used in gdbserver mode, the simulator is used as a
backend so that gdb can be used as a source level debugger for AVR
programs.
</p>
<p>The official website for Simulavr is
<a href="http://savannah.nongnu.org/projects/simulavr/">http://savannah.nongnu.org/projects/simulavr/</a>.
</p>
<p>Because it is protected by the GNU General Public License, users are
free to share and change it.
</p>
<p>Simulavr was written by Theodore A. Roth
</p>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr.html#Top" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[ &lt;&lt; ]</td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Next chapter"> &gt;&gt; </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,92 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: 6. Reporting Bugs</title>
<meta name="description" content="Simulavr: 6. Reporting Bugs">
<meta name="keywords" content="Simulavr: 6. Reporting Bugs">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Problems"></a>
<a name="SEC10"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_9.html#SEC9" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_9.html#SEC9" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 6. Reporting Bugs </h1>
<p>If you find a bug in simulavr, please send electronic mail to
<a href="mailto:simulavr-devel@nongnu.org">simulavr-devel@nongnu.org</a>. Include the
version number, which you can find by running &lsquo;<samp>simulavr
--version</samp>&rsquo;. Also include in your message the output that simulavr
produced, a simple AVR program which reproduces the bug, and the
output you expected. If you are using avr-gdb also include the
version number reported by &lsquo;<samp>avr-gdb --version</samp>&rsquo;.
</p>
<p>If you have other questions, comments or suggestions about simulavr,
contact me via electronic mail at the above address.
</p>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_9.html#SEC9" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_9.html#SEC9" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Next chapter"> &gt;&gt; </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,186 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: Concept Index</title>
<meta name="description" content="Simulavr: Concept Index">
<meta name="keywords" content="Simulavr: Concept Index">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Concept-Index"></a>
<a name="SEC11"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_10.html#SEC10" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[ &gt; ]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_10.html#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ &gt;&gt; ]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="unnumbered"> Concept Index </h1>
<table><tr><th valign="top">Jump to: &nbsp; </th><td><a href="#SEC11_0" class="summary-letter"><b>-</b></a>
&nbsp;
<br>
<a href="#SEC11_1" class="summary-letter"><b>A</b></a>
&nbsp;
<a href="#SEC11_2" class="summary-letter"><b>B</b></a>
&nbsp;
<a href="#SEC11_3" class="summary-letter"><b>D</b></a>
&nbsp;
<a href="#SEC11_4" class="summary-letter"><b>G</b></a>
&nbsp;
<a href="#SEC11_5" class="summary-letter"><b>I</b></a>
&nbsp;
<a href="#SEC11_6" class="summary-letter"><b>O</b></a>
&nbsp;
<a href="#SEC11_7" class="summary-letter"><b>P</b></a>
&nbsp;
<a href="#SEC11_8" class="summary-letter"><b>R</b></a>
&nbsp;
<a href="#SEC11_9" class="summary-letter"><b>S</b></a>
&nbsp;
</td></tr></table>
<table border="0" class="index-cp">
<tr><td></td><th align="left">Index Entry</th><th align="left"> Section</th></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC11_0">-</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX16"><code>--breakpoint</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX15"><code>--clock-freq</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX14"><code>--core-dump</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX2"><code>--debug</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX7"><code>--device</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX12"><code>--disp-prog</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX8"><code>--eeprom-image</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX9"><code>--eeprom-type</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX10"><code>--flash-type</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX5"><code>--gdb-debug</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX4"><code>--gdbserver</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX1"><code>--help</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX11"><code>--list-devices</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX6"><code>--port</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX3"><code>--version</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#IDX13"><code>--without-xterm</code></a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC11_1">A</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_3.html#SEC3">aliasing</a></td><td valign="top"><a href="simulavr_3.html#SEC3">2.1 Aliasing</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_7.html#SEC7">avr-gdb</a></td><td valign="top"><a href="simulavr_7.html#SEC7">3.2 Building GDB for AVR</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC11_2">B</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_10.html#SEC10">bugs</a></td><td valign="top"><a href="simulavr_10.html#SEC10">6. Reporting Bugs</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC11_3">D</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_9.html#SEC9">developing</a></td><td valign="top"><a href="simulavr_9.html#SEC9">5. Simulavr Internals</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_8.html#SEC8">display</a></td><td valign="top"><a href="simulavr_8.html#SEC8">4. Display Coprocesses</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_8.html#SEC8">display protocol</a></td><td valign="top"><a href="simulavr_8.html#SEC8">4. Display Coprocesses</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC11_4">G</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_5.html#SEC5">gdb</a></td><td valign="top"><a href="simulavr_5.html#SEC5">3. Using with GDB</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_7.html#SEC7">gdb, building</a></td><td valign="top"><a href="simulavr_7.html#SEC7">3.2 Building GDB for AVR</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_6.html#SEC6">gdb, hints</a></td><td valign="top"><a href="simulavr_6.html#SEC6">3.1 GDB Hints</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_5.html#SEC5">gdbserver</a></td><td valign="top"><a href="simulavr_5.html#SEC5">3. Using with GDB</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC11_5">I</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_9.html#SEC9">internals</a></td><td valign="top"><a href="simulavr_9.html#SEC9">5. Simulavr Internals</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_1.html#SEC1">introduction</a></td><td valign="top"><a href="simulavr_1.html#SEC1">1. Introduction: What is simulavr?</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_2.html#SEC2">invoking</a></td><td valign="top"><a href="simulavr_2.html#SEC2">2. Invoking Simulavr</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC11_6">O</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_4.html#SEC4">options</a></td><td valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC11_7">P</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_10.html#SEC10">problems</a></td><td valign="top"><a href="simulavr_10.html#SEC10">6. Reporting Bugs</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC11_8">R</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_2.html#SEC2">running</a></td><td valign="top"><a href="simulavr_2.html#SEC2">2. Invoking Simulavr</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
<tr><th><a name="SEC11_9">S</a></th><td></td><td></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_5.html#IDX17">SIGHUP, from gdb</a></td><td valign="top"><a href="simulavr_5.html#SEC5">3. Using with GDB</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_8.html#SEC8"><code>SIM_DISP_PROG</code></a></td><td valign="top"><a href="simulavr_8.html#SEC8">4. Display Coprocesses</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_8.html#SEC8"><code>SIM_PIPE_FD</code></a></td><td valign="top"><a href="simulavr_8.html#SEC8">4. Display Coprocesses</a></td></tr>
<tr><td></td><td valign="top"><a href="simulavr_3.html#SEC3">symbolic linking</a></td><td valign="top"><a href="simulavr_3.html#SEC3">2.1 Aliasing</a></td></tr>
<tr><td colspan="3"> <hr></td></tr>
</table>
<table><tr><th valign="top">Jump to: &nbsp; </th><td><a href="#SEC11_0" class="summary-letter"><b>-</b></a>
&nbsp;
<br>
<a href="#SEC11_1" class="summary-letter"><b>A</b></a>
&nbsp;
<a href="#SEC11_2" class="summary-letter"><b>B</b></a>
&nbsp;
<a href="#SEC11_3" class="summary-letter"><b>D</b></a>
&nbsp;
<a href="#SEC11_4" class="summary-letter"><b>G</b></a>
&nbsp;
<a href="#SEC11_5" class="summary-letter"><b>I</b></a>
&nbsp;
<a href="#SEC11_6" class="summary-letter"><b>O</b></a>
&nbsp;
<a href="#SEC11_7" class="summary-letter"><b>P</b></a>
&nbsp;
<a href="#SEC11_8" class="summary-letter"><b>R</b></a>
&nbsp;
<a href="#SEC11_9" class="summary-letter"><b>S</b></a>
&nbsp;
</td></tr></table>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_10.html#SEC10" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[ &gt; ]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_10.html#SEC10" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[ &gt;&gt; ]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,96 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: 2. Invoking Simulavr</title>
<meta name="description" content="Simulavr: 2. Invoking Simulavr">
<meta name="keywords" content="Simulavr: 2. Invoking Simulavr">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Invoking"></a>
<a name="SEC2"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_1.html#SEC1" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_3.html#SEC3" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_1.html#SEC1" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 2. Invoking Simulavr </h1>
<p>The format for running the simulavr program is:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">simulavr <var>options</var> &hellip; [flash_image]
</pre></td></tr></table>
<p>If the optional &lsquo;<tt>flash_image</tt>&rsquo; file is supplied, it will be loaded
into the flash program memory space of the virtual device.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="simulavr_3.html#SEC3">2.1 Aliasing</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> Simplifying invokation by aliasing.
</td></tr>
<tr><td align="left" valign="top"><a href="simulavr_4.html#SEC4">2.2 Options</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top"> Command line options for simulavr.
</td></tr>
</table>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_1.html#SEC1" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_3.html#SEC3" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_1.html#SEC1" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Next chapter"> &gt;&gt; </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,98 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: 2.1 Aliasing</title>
<meta name="description" content="Simulavr: 2.1 Aliasing">
<meta name="keywords" content="Simulavr: 2.1 Aliasing">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Aliasing"></a>
<a name="SEC3"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_4.html#SEC4" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 2.1 Aliasing </h2>
<p>On most systems, if the simulavr executable is renamed to the name of an
available device, it can be started without specifying the device
type. The easiest way to achieve this is to create symbolic links for
all the supported devices which point to the simulavr executable. For
instance, this command will create a sym link for the at90s8515 device
on a Unix system:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">ln -s simulavr at90s8515
</pre></td></tr></table>
<p>Once the links have been created, the following two commands are
equivalent:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">simulavr -d at90s8515 myprog.bin
at90s8515 myprog.bin
</pre></td></tr></table>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_4.html#SEC4" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Next chapter"> &gt;&gt; </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,200 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: 2.2 Options</title>
<meta name="description" content="Simulavr: 2.2 Options">
<meta name="keywords" content="Simulavr: 2.2 Options">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Options"></a>
<a name="SEC4"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_3.html#SEC3" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 2.2 Options </h2>
<p>simulavr supports the following options:
</p>
<dl compact="compact">
<dd><a name="IDX1"></a>
</dd>
<dt> <code>--help</code></dt>
<dt> <code>-h</code></dt>
<dd><p>Print an informative help message describing the options and available
device types, then exit.
</p>
<a name="IDX2"></a>
</dd>
<dt> <code>--debug</code></dt>
<dt> <code>-D</code></dt>
<dd><p>Print assembly instruction mnemonics and program counter (&lsquo;<samp>PC</samp>&rsquo;) to
output as device program is running.
</p>
<a name="IDX3"></a>
</dd>
<dt> <code>--version</code></dt>
<dt> <code>-v</code></dt>
<dd><p>Print out the version number and exit.
</p>
<a name="IDX4"></a>
</dd>
<dt> <code>--gdbserver</code></dt>
<dt> <code>-g</code></dt>
<dd><p>Run as a gdbserver process.
</p>
<a name="IDX5"></a>
</dd>
<dt> <code>--gdb-debug</code></dt>
<dt> <code>-G</code></dt>
<dd><p>Print out messages for debugging the gdb remote serial protocol interface.
</p>
<a name="IDX6"></a>
</dd>
<dt> <code>--port <var>&lt;port&gt;</var></code></dt>
<dt> <code>-p</code></dt>
<dd><p>Listen for gdb connection on TCP port. If not specified, a default will
be used. Run &lsquo;<samp>simulavr --help</samp>&rsquo; to see what the default is. This
option is ignored if the &lsquo;<samp>--gdbserver</samp>&rsquo; is not specified.
</p>
<a name="IDX7"></a>
</dd>
<dt> <code>--device <var>&lt;dev&gt;</var></code></dt>
<dt> <code>-d</code></dt>
<dd><p>Specify device type. The device types available for use with a specific
version of simulavr can be obtained using the &lsquo;<samp>--list-devices</samp>&rsquo; option.
</p>
<a name="IDX8"></a>
</dd>
<dt> <code>--eeprom-image <var>&lt;img&gt;</var></code></dt>
<dt> <code>-e</code></dt>
<dd><p>Specify an optional eeprom image file to be loaded into the device's
eeprom memory space.
</p>
<a name="IDX9"></a>
</dd>
<dt> <code>--eeprom-type <var>&lt;type&gt;</var></code></dt>
<dt> <code>-E</code></dt>
<dd><p>Specify the type of the eeprom image file. If not specified, the default
is binary.
</p>
<a name="IDX10"></a>
</dd>
<dt> <code>--flash-type <var>&lt;type&gt;</var></code></dt>
<dt> <code>-F</code></dt>
<dd><p>Specify the type of the flash image file. If not specified, the default
is binary.
</p>
<a name="IDX11"></a>
</dd>
<dt> <code>--list-devices</code></dt>
<dt> <code>-L</code></dt>
<dd><p>Prints a list of supported devices to stdout and exits.
</p>
<a name="IDX12"></a>
</dd>
<dt> <code>--disp-prog <var>&lt;prog&gt;</var></code></dt>
<dt> <code>-P</code></dt>
<dd><p>Specify a program to be used to display register and memory information
in real time as a child process. The display program can also be
specified by setting the <code>SIM_DISP_PROG</code> environment variable.
</p>
<a name="IDX13"></a>
</dd>
<dt> <code>--without-xterm</code></dt>
<dt> <code>-X</code></dt>
<dd><p>Don't start display coprocess program in an xterm. This is useful if
the display coprocess supplies it's own window for input and output,
such as a process which uses a GUI.
</p>
<a name="IDX14"></a>
</dd>
<dt> <code>--core-dump</code></dt>
<dt> <code>-C</code></dt>
<dd><p>Dump a core memory image to file on exit. This isn't as useful as it
sounds. The display coprocess mechanism is much more informative.
</p>
<a name="IDX15"></a>
</dd>
<dt> <code>--clock-freq <var>&lt;freq&gt;</var></code></dt>
<dt> <code>-c</code></dt>
<dd><p>Set the simulated mcu clock freqency in Hz.
</p>
<a name="IDX16"></a>
</dd>
<dt> <code>--breakpoint <var>&lt;addr&gt;</var></code></dt>
<dt> <code>-B</code></dt>
<dd><p>Set a breakpoint at <var>&lt;addr&gt;</var>. Note that the break address is
interpreted as a byte address instead of a word address. This makes
it easier on the user since binutils, gcc and gdb all work in terms of
byte addresses. The address can be specified in any base (decimal,
hexidecimal, octal, etc).
</p>
</dd>
</dl>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_3.html#SEC3" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Next chapter"> &gt;&gt; </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,169 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: 3. Using with GDB</title>
<meta name="description" content="Simulavr: 3. Using with GDB">
<meta name="keywords" content="Simulavr: 3. Using with GDB">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Using-with-GDB"></a>
<a name="SEC5"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_4.html#SEC4" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_6.html#SEC6" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_8.html#SEC8" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 3. Using with GDB </h1>
<p>If you want to use gdb as a source-level debugger with
simulavr running as a remote target, start simulavr with the
&lsquo;<samp>--gdbserver</samp>&rsquo; or &lsquo;<samp>-g</samp>&rsquo; option. This will put simulavr
into gdbserver mode. simulavr will then act as a TCP server
program on the localhost listening for a connection from gdb.
</p>
<p>Once simulavr has accepted a connection from gdb, the two programs
communicate via gdb's remote serial protocol (see <a href="../gdb/index.html#Top">GDB Remote Serial Protocol: (gdb)Top</a> section `Protocol' in <cite>Debugging with GDB</cite>).
</p>
<p>Here's how you would start up simulavr in gdbserver mode:
</p>
<table><tr><td>&nbsp;</td><td><table class="cartouche" border="1"><tr><td>
<pre class="example">$ simulavr -d at90s8515 -g
</pre></td></tr></table>
</td></tr></table>
<p>Here's a sample gdb session showing what to do on the gdb
side to get gdb to talk to simulavr:
</p>
<table><tr><td>&nbsp;</td><td><table class="cartouche" border="1"><tr><td>
<pre class="example">This GDB was configured as &quot;--host=i686-pc-linux-gnu --target=avr&quot;.
(gdb) file demo_kr.elf
Reading symbols from demo_kr.elf...done.
(gdb) target remote localhost:1212
Remote debugging using localhost:1212
0x0 in .__start_of_init__ ()
(gdb) load
Loading section .text, size 0x76 lma 0x0
Start address 0x0 , load size 118
Transfer rate: 944 bits in &lt;1 sec, 29 bytes/write.
(gdb) break main
Breakpoint 1 at 0x6e: file demo_kr.c, line 17.
(gdb) continue
Continuing.
Breakpoint 1, main () at demo_kr.c:17
17 sbi(DDRC, (
(gdb) quit
The program is running. Exit anyway? (y or n) y
</pre></td></tr></table>
</td></tr></table>
<p>Notice that simulavr knew nothing about the program to debug when it
was started. Gdb was told which file to debug with the &lsquo;<samp>file</samp>&rsquo;
command. After gdb has read in the program and connected to simulavr,
the program's instructions are downloaded into the simulator via the
&lsquo;<samp>load</samp>&rsquo; command. The &lsquo;<samp>load</samp>&rsquo; command is not necessary if
simulavr already has the program loaded into it's flash memory area. It
is ok to issue multiple &lsquo;<samp>load</samp>&rsquo; commands.
</p>
<p>Also, notice that no &lsquo;<samp>run</samp>&rsquo; command was given to gdb. Gdb assumes
that the simulator has started and is ready to continue. Giving gdb the
&lsquo;<samp>run</samp>&rsquo; command, will cause it to stop the current debug session and
start a new one, which is not likely to be what you want to do.
</p>
<p>When specifying the remote target to connect to, it is sufficient to
write &ldquo;target remote :1212&rdquo; instead of &ldquo;target remote localhost:1212&rdquo;.
</p>
<p>Hitting <kbd>CTRL-c</kbd> in gdb can be used to interrupt the simulator while it is
processing instructions and return control back to gdb. This is most
useful when gdb is waiting for a response from the simulator and the
program running in the simulator is in an infinite loop.
</p>
<p>Issuing a &lsquo;<samp>signal SIGxxx</samp>&rsquo; command from gdb will send the signal to
the simulator via a <i>continue with signal</i> packet. The simulator will
process and interpret the signal, but will not pass it on to the AVR
program running in the simulator since it really makes no sense to do
so. In some circumstances, it may make sense to use the gdb signal
mechanism as a way to initiate some sort of external stimulus to be
passed on to the virtual hardware system of the simulator. Signals from
gdb which are processed have the following meanings:
</p>
<dl compact="compact">
<dd><a name="IDX17"></a>
</dd>
<dt> <code>SIGHUP</code></dt>
<dd><p>Initiate a reset of the simulator. (Simulates a hardware reset).
</p>
</dd>
</dl>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="simulavr_6.html#SEC6">3.1 GDB Hints</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="simulavr_7.html#SEC7">3.2 Building GDB for AVR</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_4.html#SEC4" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_6.html#SEC6" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_2.html#SEC2" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_8.html#SEC8" title="Next chapter"> &gt;&gt; </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,137 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: 3.1 GDB Hints</title>
<meta name="description" content="Simulavr: 3.1 GDB Hints">
<meta name="keywords" content="Simulavr: 3.1 GDB Hints">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="GDB-Hints"></a>
<a name="SEC6"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_7.html#SEC7" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_8.html#SEC8" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.1 GDB Hints </h2>
<p>Since debugging an AVR program with gdb requires gdb to connect to a
remote target (either simulavr or some other debugging tool, such as
avarice), a series of commands must be issued every time gdb is started.
The easiest way around this is to put the commands into a
&lsquo;<tt>.gdbinit</tt>&rsquo; file in the project directory. The following example is
from a &lsquo;<tt>.gdbinit</tt>&rsquo; which I use for many projects.
</p>
<table><tr><td>&nbsp;</td><td><table class="cartouche" border="1"><tr><td>
<pre class="example">
## Print out structures in a sane way
echo (gdb) set print pretty
set print pretty
## Use this for debugging the remote protocol. (Don't use unless
## debugging simulavr or avr-gdb)
#echo (gdb) set debug remote 1\n
#set debug remote 1
## If you don't want specify the program to debug when invoking gdb,
## you can tell gdb to read it in here. The file should be an elf file
## compiled with debugging information (-g for C files and -gstabs for
## asm files).
#echo (gdb) file myprog.elf\n
#file myprog.elf
## Connect to the remote target via a TCP socket on host:port.
echo (gdb) target remote localhost:1212\n
target remote localhost:1212
## If you are using simulavr as the remote target, this will upload
## the program into flash memory for you.
echo (gdb) load\n
load
## Set a break point at the beginning of main().
echo (gdb) break main\n
break main
## Run the program up to the first break point. Gdb's `run` command
## does not work when using a remote target, must use continue.
echo (gdb) continue\n
continue
</pre></td></tr></table>
</td></tr></table>
<p>As you can see, I <code>echo</code> every command so I can see what gdb has
done when it runs the commands in the &lsquo;<tt>.gdbinit</tt>&rsquo; file.
</p>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_7.html#SEC7" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_8.html#SEC8" title="Next chapter"> &gt;&gt; </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,96 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: 3.2 Building GDB for AVR</title>
<meta name="description" content="Simulavr: 3.2 Building GDB for AVR">
<meta name="keywords" content="Simulavr: 3.2 Building GDB for AVR">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Building-GDB"></a>
<a name="SEC7"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_6.html#SEC6" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_8.html#SEC8" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_8.html#SEC8" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 3.2 Building GDB for AVR </h2>
<p>In order to use simulavr as a backend to gdb, you must build a special
AVR version of gdb. All gdb versions starting with gdb-5.2.1
officially support the AVR target. You can just configure gdb with the
<code>--target=avr</code> option. For example, you can use this procedure
to install avr-gdb in /usr/local/bin:
</p>
<table><tr><td>&nbsp;</td><td><table class="cartouche" border="1"><tr><td>
<pre class="example">$ ./configure --target=avr
$ make
$ su
# make install
# exit
</pre></td></tr></table>
</td></tr></table>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_6.html#SEC6" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_8.html#SEC8" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_8.html#SEC8" title="Next chapter"> &gt;&gt; </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,153 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: 4. Display Coprocesses</title>
<meta name="description" content="Simulavr: 4. Display Coprocesses">
<meta name="keywords" content="Simulavr: 4. Display Coprocesses">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Display-Coprocesses"></a>
<a name="SEC8"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_7.html#SEC7" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_9.html#SEC9" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_9.html#SEC9" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 4. Display Coprocesses </h1>
<p>This chapter documents the protocol that simulavr uses to pass register
and memory information to a display coprocess.
</p>
<p>A display coprocess is a separate program started by simulavr for the
sole purpose of displaying register and memory information while an AVR
program is running in the simulator. Using a separate program and a
standardized communication protocol, keeps the simulavr code simpler and
allows for a variety of display programs to be used.
</p>
<p>When the user asks simulavr to display register and memory information
during execution, simulavr will start a coprocess to perform the display
work. A pipe will be opened in simulavr into which the data will be
written using the following commands:
</p>
<table>
<tr><td><p> &lsquo;<samp>q</samp>&rsquo;
</p></td><td><p> Quit.
</p>
</td></tr>
<tr><td><p> &lsquo;<samp>r&lt;reg&gt;:&lt;val&gt;</samp>&rsquo;
</p></td><td><p> Set register to val.
</p>
</td></tr>
<tr><td><p> &lsquo;<samp>p&lt;val&gt;</samp>&rsquo;
</p></td><td><p> Set program counter to val.
</p>
</td></tr>
<tr><td><p> &lsquo;<samp>i&lt;reg&gt;:&lt;val&gt;</samp>&rsquo;
</p></td><td><p> Set io register to val.
</p>
</td></tr>
<tr><td><p> &lsquo;<samp>I&lt;reg&gt;:&lt;name&gt;</samp>&rsquo;
</p></td><td><p> Set io register name.
</p>
</td></tr>
<tr><td><p> &lsquo;<samp>s&lt;addr&gt;,&lt;len&gt;:XX</samp>&rsquo;
</p></td><td><p> Set sram addrs to values (one XX pair per addr).
</p>
</td></tr>
<tr><td><p> &lsquo;<samp>e&lt;addr&gt;,&lt;len&gt;:XX</samp>&rsquo;
</p></td><td><p> Set eeprom addrs to values (one XX pair per addr).
</p>
</td></tr>
<tr><td><p> &lsquo;<samp>f&lt;addr&gt;,&lt;len&gt;:XXXX</samp>&rsquo;
</p></td><td><p> Set flash addrs to values (one XXXX quad per addr).
</p>
</td></tr>
<tr><td><p> &lsquo;<samp>n&lt;clock_ticks&gt;</samp>&rsquo;
</p></td><td><p> Update the number of clock ticks.
</p>
</td></tr>
</table>
<p>All values are hexidecimal numbers, except for &lt;name&gt; which is a string.
</p>
<p>In order for the display process to know which pipe to read the
information, it must handle either the &lsquo;<samp>--pfd &lt;fd&gt;</samp>&rsquo; option or check
the <code>SIM_PIPE_FD</code> enviroment variable. The value passed using
either method will be the file descriptor number of the pipe from which
the display prgram will read the informtion.
</p>
<p>Simulavr will start all display programs like so (sizes are decimal
numbers of bytes and sram_start is just the decimal address of the
first byte of sram, usually 0x60 [96] or 0x100 [256]):
</p>
<p>&lsquo;<samp>&lt;prog&gt; --pfd &lt;fd&gt; &lt;flash_size&gt; &lt;sram_size&gt; &lt;sram_start&gt; &lt;eeprom_size&gt;</samp>&rsquo;
</p>
<p>The user can specify the display program to use via the
&lsquo;<samp>--disp-prog</samp>&rsquo; option to simulavr or using the <code>SIM_DISP_PROG</code>
environment variable. If both are not specified, then no display will be
used.
</p>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_7.html#SEC7" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_9.html#SEC9" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_5.html#SEC5" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_9.html#SEC9" title="Next chapter"> &gt;&gt; </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,92 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: 5. Simulavr Internals</title>
<meta name="description" content="Simulavr: 5. Simulavr Internals">
<meta name="keywords" content="Simulavr: 5. Simulavr Internals">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Internals"></a>
<a name="SEC9"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_8.html#SEC8" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_10.html#SEC10" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_8.html#SEC8" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_10.html#SEC10" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_11.html#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 5. Simulavr Internals </h1>
<p>Simulavr internals are documented using the doxygen system to automate
generation of the documentation from the source code comments. The
documentation for the latest release is always available at:
</p>
<p><a href="http://savannah.nongnu.org/download/simulavr/doc/internals_html/">http://savannah.nongnu.org/download/simulavr/doc/internals_html/</a>
</p>
<p>The most up-to-date documents will most likely be those in the source
code itself. If you wish to help develop simulavr, it is highly
recommended that you get the latest source from cvs and consult the
internals documents there.
</p>
<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr_8.html#SEC8" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_10.html#SEC10" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="simulavr_8.html#SEC8" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="simulavr.html#Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="simulavr_10.html#SEC10" title="Next chapter"> &gt;&gt; </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,167 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: About This Document</title>
<meta name="description" content="Simulavr: About This Document">
<meta name="keywords" content="Simulavr: About This Document">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="SEC_About"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1>About This Document</h1>
<p>
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</p>
<p>
The buttons in the navigation panels have the following meaning:
</p>
<table border="1">
<tr>
<th> Button </th>
<th> Name </th>
<th> Go to </th>
<th> From 1.2.3 go to</th>
</tr>
<tr>
<td align="center"> [ &lt; ] </td>
<td align="center">Back</td>
<td>Previous section in reading order</td>
<td>1.2.2</td>
</tr>
<tr>
<td align="center"> [ &gt; ] </td>
<td align="center">Forward</td>
<td>Next section in reading order</td>
<td>1.2.4</td>
</tr>
<tr>
<td align="center"> [ &lt;&lt; ] </td>
<td align="center">FastBack</td>
<td>Beginning of this chapter or previous chapter</td>
<td>1</td>
</tr>
<tr>
<td align="center"> [ Up ] </td>
<td align="center">Up</td>
<td>Up section</td>
<td>1.2</td>
</tr>
<tr>
<td align="center"> [ &gt;&gt; ] </td>
<td align="center">FastForward</td>
<td>Next chapter</td>
<td>2</td>
</tr>
<tr>
<td align="center"> [Top] </td>
<td align="center">Top</td>
<td>Cover (top) of document</td>
<td> &nbsp; </td>
</tr>
<tr>
<td align="center"> [Contents] </td>
<td align="center">Contents</td>
<td>Table of contents</td>
<td> &nbsp; </td>
</tr>
<tr>
<td align="center"> [Index] </td>
<td align="center">Index</td>
<td>Index</td>
<td> &nbsp; </td>
</tr>
<tr>
<td align="center"> [ ? ] </td>
<td align="center">About</td>
<td>About (help)</td>
<td> &nbsp; </td>
</tr>
</table>
<p>
where the <strong> Example </strong> assumes that the current position is at <strong> Subsubsection One-Two-Three </strong> of a document of the following structure:
</p>
<ul>
<li> 1. Section One
<ul>
<li>1.1 Subsection One-One
<ul>
<li>...</li>
</ul>
</li>
<li>1.2 Subsection One-Two
<ul>
<li>1.2.1 Subsubsection One-Two-One</li>
<li>1.2.2 Subsubsection One-Two-Two</li>
<li>1.2.3 Subsubsection One-Two-Three &nbsp; &nbsp;
<strong>&lt;== Current Position </strong></li>
<li>1.2.4 Subsubsection One-Two-Four</li>
</ul>
</li>
<li>1.3 Subsection One-Three
<ul>
<li>...</li>
</ul>
</li>
<li>1.4 Subsection One-Four</li>
</ul>
</li>
</ul>
<hr size="1">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,87 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on November, 7 2008 by texi2html 1.78 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>Simulavr: Table of Contents</title>
<meta name="description" content="Simulavr: Table of Contents">
<meta name="keywords" content="Simulavr: Table of Contents">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.78">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="SEC_Contents"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1>Table of Contents</h1>
<div class="contents">
<ul class="toc">
<li><a name="TOC1" href="simulavr_1.html#SEC1">1. Introduction: What is simulavr?</a></li>
<li><a name="TOC2" href="simulavr_2.html#SEC2">2. Invoking Simulavr</a>
<ul class="toc">
<li><a name="TOC3" href="simulavr_3.html#SEC3">2.1 Aliasing</a></li>
<li><a name="TOC4" href="simulavr_4.html#SEC4">2.2 Options</a></li>
</ul></li>
<li><a name="TOC5" href="simulavr_5.html#SEC5">3. Using with GDB</a>
<ul class="toc">
<li><a name="TOC6" href="simulavr_6.html#SEC6">3.1 GDB Hints</a></li>
<li><a name="TOC7" href="simulavr_7.html#SEC7">3.2 Building GDB for AVR</a></li>
</ul></li>
<li><a name="TOC8" href="simulavr_8.html#SEC8">4. Display Coprocesses</a></li>
<li><a name="TOC9" href="simulavr_9.html#SEC9">5. Simulavr Internals</a></li>
<li><a name="TOC10" href="simulavr_10.html#SEC10">6. Reporting Bugs</a></li>
<li><a name="TOC11" href="simulavr_11.html#SEC11">Concept Index</a></li>
</ul>
</div>
<hr size="1">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="simulavr.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="#SEC11" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="simulavr_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>eweddington</em> on <em>November, 7 2008</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.78</em></a>.
</font>
<br>
</p>
</body>
</html>

View file

@ -0,0 +1,503 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>adc.c</h1><a href="adc_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: adc.c,v 1.4 2004/03/13 19:55:34 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2003, 2004 Keith Gudger</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/**</span>
<a name="l00027"></a>00027 <span class="comment"> * \file adc.c</span>
<a name="l00028"></a>00028 <span class="comment"> * \brief Module to simulate the AVR's ADC module.</span>
<a name="l00029"></a>00029 <span class="comment"> *</span>
<a name="l00030"></a>00030 <span class="comment"> */</span>
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00033"></a>00033
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include "utils.h"</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include "callback.h"</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include "op_names.h"</span>
<a name="l00044"></a>00044
<a name="l00045"></a>00045 <span class="preprocessor">#include "storage.h"</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include "flash.h"</span>
<a name="l00047"></a>00047
<a name="l00048"></a>00048 <span class="preprocessor">#include "vdevs.h"</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include "memory.h"</span>
<a name="l00050"></a>00050 <span class="preprocessor">#include "stack.h"</span>
<a name="l00051"></a>00051 <span class="preprocessor">#include "register.h"</span>
<a name="l00052"></a>00052 <span class="preprocessor">#include "sram.h"</span>
<a name="l00053"></a>00053 <span class="preprocessor">#include "eeprom.h"</span>
<a name="l00054"></a>00054 <span class="preprocessor">#include "timers.h"</span>
<a name="l00055"></a>00055 <span class="preprocessor">#include "ports.h"</span>
<a name="l00056"></a>00056 <span class="preprocessor">#include "adc.h"</span>
<a name="l00057"></a>00057
<a name="l00058"></a>00058 <span class="preprocessor">#include "avrcore.h"</span>
<a name="l00059"></a>00059
<a name="l00060"></a>00060 <span class="preprocessor">#include "intvects.h"</span>
<a name="l00061"></a>00061
<a name="l00062"></a>00062 <span class="comment">/****************************************************************************\</span>
<a name="l00063"></a>00063 <span class="comment"> *</span>
<a name="l00064"></a>00064 <span class="comment"> * ADC Interrupts </span>
<a name="l00065"></a>00065 <span class="comment"> *</span>
<a name="l00066"></a>00066 <span class="comment">\****************************************************************************/</span>
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="keyword">static</span> <span class="keywordtype">void</span> adc_iadd_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr,
<a name="l00069"></a>00069 <span class="keywordtype">void</span> *data);
<a name="l00070"></a>00070 <span class="keyword">static</span> uint8_t adc_intr_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00071"></a>00071 <span class="keyword">static</span> <span class="keywordtype">void</span> adc_intr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00072"></a>00072 <span class="keyword">static</span> <span class="keywordtype">void</span> adc_intr_reset (VDevice *dev);
<a name="l00073"></a>00073 <span class="keyword">static</span> <span class="keywordtype">int</span> adc_intr_cb (uint64_t time, AvrClass *data);
<a name="l00074"></a>00074 <span class="keyword">static</span> <span class="keywordtype">int</span> adc_clk_incr_cb (uint64_t ck, AvrClass *data);
<a name="l00075"></a>00075 <span class="comment"></span>
<a name="l00076"></a>00076 <span class="comment">/** \brief Allocate a new ADC interrupt */</span>
<a name="l00077"></a>00077
<a name="l00078"></a>00078 VDevice *
<a name="l00079"></a><a class="code" href="adc_8c.html#9879d2be21cb9c2b10bd20b39ff2000d">00079</a> <a class="code" href="adc_8c.html#9879d2be21cb9c2b10bd20b39ff2000d" title="Allocate a new ADC interrupt.">adc_int_create</a> (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00080"></a>00080 {
<a name="l00081"></a>00081 <span class="keywordflow">return</span> (VDevice *)adc_intr_new (addr, name, rel_addr);
<a name="l00082"></a>00082 }
<a name="l00083"></a>00083
<a name="l00084"></a>00084 ADCIntr_T *
<a name="l00085"></a>00085 adc_intr_new (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr)
<a name="l00086"></a>00086 {
<a name="l00087"></a>00087 ADCIntr_T *adc;
<a name="l00088"></a>00088
<a name="l00089"></a>00089 adc = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (ADCIntr_T, 1);
<a name="l00090"></a>00090 <a class="code" href="adc_8c.html#4db5253cbc808007b02e3baed5fcb3e7" title="Constructor for adc interrupt object.">adc_intr_construct</a> (adc, addr, name, rel_addr);
<a name="l00091"></a>00091 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)adc, <a class="code" href="adc_8c.html#5c602673eed7cc14090b7180c4f961fe" title="Destructor for adc interrupt object.">adc_intr_destroy</a>);
<a name="l00092"></a>00092
<a name="l00093"></a>00093 <span class="keywordflow">return</span> adc;
<a name="l00094"></a>00094 }
<a name="l00095"></a>00095 <span class="comment"></span>
<a name="l00096"></a>00096 <span class="comment">/** \brief Constructor for adc interrupt object. */</span>
<a name="l00097"></a>00097
<a name="l00098"></a>00098 <span class="keywordtype">void</span>
<a name="l00099"></a><a class="code" href="adc_8c.html#4db5253cbc808007b02e3baed5fcb3e7">00099</a> <a class="code" href="adc_8c.html#4db5253cbc808007b02e3baed5fcb3e7" title="Constructor for adc interrupt object.">adc_intr_construct</a> (ADCIntr_T *adc, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr)
<a name="l00100"></a>00100 {
<a name="l00101"></a>00101 <span class="keywordflow">if</span> (adc == NULL)
<a name="l00102"></a>00102 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00103"></a>00103
<a name="l00104"></a>00104 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)adc, adc_intr_read, adc_intr_write,
<a name="l00105"></a>00105 adc_intr_reset, adc_iadd_addr);
<a name="l00106"></a>00106
<a name="l00107"></a>00107 <span class="keywordflow">if</span> (rel_addr)
<a name="l00108"></a>00108 adc-&gt;rel_addr = rel_addr;
<a name="l00109"></a>00109 adc_iadd_addr ((VDevice *)adc, addr, name, 0, NULL);
<a name="l00110"></a>00110
<a name="l00111"></a>00111 adc_intr_reset ((VDevice *)adc);
<a name="l00112"></a>00112 }
<a name="l00113"></a>00113
<a name="l00114"></a>00114 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00115"></a>00115 adc_iadd_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00116"></a>00116 {
<a name="l00117"></a>00117 ADCIntr_T *adc = (ADCIntr_T *)vdev;
<a name="l00118"></a>00118
<a name="l00119"></a>00119 <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"ADCSR"</span>, name, 5) == 0)
<a name="l00120"></a>00120 {
<a name="l00121"></a>00121 adc-&gt;adcsr_addr = addr;
<a name="l00122"></a>00122 }
<a name="l00123"></a>00123
<a name="l00124"></a>00124 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"ADMUX"</span>, name, 5) == 0)
<a name="l00125"></a>00125 {
<a name="l00126"></a>00126 adc-&gt;admux_addr = addr;
<a name="l00127"></a>00127 }
<a name="l00128"></a>00128
<a name="l00129"></a>00129 <span class="keywordflow">else</span>
<a name="l00130"></a>00130 {
<a name="l00131"></a>00131 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"invalid ADC register name: '%s' @ 0x%04x"</span>, name, addr);
<a name="l00132"></a>00132 }
<a name="l00133"></a>00133 }
<a name="l00134"></a>00134 <span class="comment"></span>
<a name="l00135"></a>00135 <span class="comment">/** \brief Destructor for adc interrupt object. */</span>
<a name="l00136"></a>00136
<a name="l00137"></a>00137 <span class="keywordtype">void</span>
<a name="l00138"></a><a class="code" href="adc_8c.html#5c602673eed7cc14090b7180c4f961fe">00138</a> <a class="code" href="adc_8c.html#5c602673eed7cc14090b7180c4f961fe" title="Destructor for adc interrupt object.">adc_intr_destroy</a> (<span class="keywordtype">void</span> *adc)
<a name="l00139"></a>00139 {
<a name="l00140"></a>00140 <span class="keywordflow">if</span> (adc == NULL)
<a name="l00141"></a>00141 <span class="keywordflow">return</span>;
<a name="l00142"></a>00142
<a name="l00143"></a>00143 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (adc);
<a name="l00144"></a>00144 }
<a name="l00145"></a>00145
<a name="l00146"></a>00146 <span class="keyword">static</span> uint8_t
<a name="l00147"></a>00147 adc_intr_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00148"></a>00148 {
<a name="l00149"></a>00149 ADCIntr_T *adc = (ADCIntr_T *)dev;
<a name="l00150"></a>00150
<a name="l00151"></a>00151 <span class="keywordflow">if</span> (addr == adc-&gt;adcsr_addr)
<a name="l00152"></a>00152 <span class="keywordflow">return</span> (adc-&gt;adcsr);
<a name="l00153"></a>00153
<a name="l00154"></a>00154 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == adc-&gt;admux_addr)
<a name="l00155"></a>00155 <span class="keywordflow">return</span> (adc-&gt;admux);
<a name="l00156"></a>00156
<a name="l00157"></a>00157 <span class="keywordflow">else</span>
<a name="l00158"></a>00158 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00159"></a>00159
<a name="l00160"></a>00160 <span class="keywordflow">return</span> 0; <span class="comment">/* will never get here */</span>
<a name="l00161"></a>00161 }
<a name="l00162"></a>00162
<a name="l00163"></a>00163 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00164"></a>00164 adc_intr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00165"></a>00165 {
<a name="l00166"></a>00166 ADCIntr_T *adc = (ADCIntr_T *)dev;
<a name="l00167"></a>00167 CallBack *cb;
<a name="l00168"></a>00168 ADC_T *adc_d;
<a name="l00169"></a>00169
<a name="l00170"></a>00170 adc_d =
<a name="l00171"></a>00171 (ADC_T *)<a class="code" href="avrcore_8c.html#f0c70bc7f992dcacd8ab411993bea5b5" title="Returns the VDevice which handles the address addr.">avr_core_get_vdev_by_addr</a> ((AvrCore *)
<a name="l00172"></a>00172 <a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)adc),
<a name="l00173"></a>00173 adc-&gt;rel_addr);
<a name="l00174"></a>00174
<a name="l00175"></a>00175 <span class="keywordflow">if</span> (addr == adc-&gt;adcsr_addr)
<a name="l00176"></a>00176 {
<a name="l00177"></a>00177 <span class="keywordflow">if</span> (val &amp; mask_ADIF) <span class="comment">/* clears interrupt flag */</span>
<a name="l00178"></a>00178 adc-&gt;adcsr = val &amp; ~mask_ADIF;
<a name="l00179"></a>00179 <span class="keywordflow">else</span>
<a name="l00180"></a>00180 adc-&gt;adcsr = val;
<a name="l00181"></a>00181
<a name="l00182"></a>00182 <span class="keywordflow">if</span> ((val &amp; mask_ADSC) &amp;&amp; (val &amp; mask_ADEN))
<a name="l00183"></a>00183 {
<a name="l00184"></a>00184 <span class="keywordflow">if</span> ((adc-&gt;intr_cb == NULL))
<a name="l00185"></a>00185 {
<a name="l00186"></a>00186 <span class="comment">/* we need to install the intr_cb function */</span>
<a name="l00187"></a>00187 cb = callback_new (adc_intr_cb, (AvrClass *)adc);
<a name="l00188"></a>00188 adc-&gt;intr_cb = cb;
<a name="l00189"></a>00189 <a class="code" href="avrcore_8c.html#e821588464c39dbdcc9fb5eea45da0aa" title="Add a new asynchronous callback to list.">avr_core_async_cb_add</a> ((AvrCore *)<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> (dev), cb);
<a name="l00190"></a>00190 }
<a name="l00191"></a>00191 <span class="keywordflow">if</span> ((adc_d-&gt;clk_cb == NULL))
<a name="l00192"></a>00192 {
<a name="l00193"></a>00193 <span class="comment">/* we need to install the clk_cb function */</span>
<a name="l00194"></a>00194 cb = callback_new (adc_clk_incr_cb, (AvrClass *)adc_d);
<a name="l00195"></a>00195 adc_d-&gt;clk_cb = cb;
<a name="l00196"></a>00196 <a class="code" href="avrcore_8c.html#3e755b8388c3c44ea514484ce53ace75" title="Add a new clock callback to list.">avr_core_clk_cb_add</a> ((AvrCore *)
<a name="l00197"></a>00197 <a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)adc_d), cb);
<a name="l00198"></a>00198 }
<a name="l00199"></a>00199 adc_d-&gt;adc_count = 13;
<a name="l00200"></a>00200 <span class="keywordflow">switch</span> ((adc-&gt;adcsr) &amp; (mask_ADPS0 | mask_ADPS1 | mask_ADPS2))
<a name="l00201"></a>00201 {
<a name="l00202"></a>00202 <span class="keywordflow">case</span> ADC_CK_0:
<a name="l00203"></a>00203 <span class="keywordflow">case</span> ADC_CK_2:
<a name="l00204"></a>00204 adc_d-&gt;divisor = 2;
<a name="l00205"></a>00205 <span class="keywordflow">break</span>;
<a name="l00206"></a>00206 <span class="keywordflow">case</span> ADC_CK_4:
<a name="l00207"></a>00207 adc_d-&gt;divisor = 4;
<a name="l00208"></a>00208 <span class="keywordflow">break</span>;
<a name="l00209"></a>00209 <span class="keywordflow">case</span> ADC_CK_8:
<a name="l00210"></a>00210 adc_d-&gt;divisor = 8;
<a name="l00211"></a>00211 <span class="keywordflow">break</span>;
<a name="l00212"></a>00212 <span class="keywordflow">case</span> ADC_CK_16:
<a name="l00213"></a>00213 adc_d-&gt;divisor = 16;
<a name="l00214"></a>00214 <span class="keywordflow">break</span>;
<a name="l00215"></a>00215 <span class="keywordflow">case</span> ADC_CK_32:
<a name="l00216"></a>00216 adc_d-&gt;divisor = 32;
<a name="l00217"></a>00217 <span class="keywordflow">break</span>;
<a name="l00218"></a>00218 <span class="keywordflow">case</span> ADC_CK_64:
<a name="l00219"></a>00219 adc_d-&gt;divisor = 64;
<a name="l00220"></a>00220 <span class="keywordflow">break</span>;
<a name="l00221"></a>00221 <span class="keywordflow">case</span> ADC_CK_128:
<a name="l00222"></a>00222 adc_d-&gt;divisor = 128;
<a name="l00223"></a>00223 <span class="keywordflow">break</span>;
<a name="l00224"></a>00224 <span class="keywordflow">default</span>:
<a name="l00225"></a>00225 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"The impossible happened!"</span>);
<a name="l00226"></a>00226 }
<a name="l00227"></a>00227 }
<a name="l00228"></a>00228 <span class="keywordflow">else</span>
<a name="l00229"></a>00229 {
<a name="l00230"></a>00230 adc-&gt;intr_cb = NULL; <span class="comment">/* no interrupt are enabled, remove</span>
<a name="l00231"></a>00231 <span class="comment"> the callback */</span>
<a name="l00232"></a>00232 }
<a name="l00233"></a>00233 }
<a name="l00234"></a>00234
<a name="l00235"></a>00235 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == adc-&gt;admux_addr)
<a name="l00236"></a>00236 {
<a name="l00237"></a>00237 adc-&gt;admux = val;
<a name="l00238"></a>00238 }
<a name="l00239"></a>00239
<a name="l00240"></a>00240 <span class="keywordflow">else</span>
<a name="l00241"></a>00241 {
<a name="l00242"></a>00242 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00243"></a>00243 }
<a name="l00244"></a>00244 }
<a name="l00245"></a>00245
<a name="l00246"></a>00246 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00247"></a>00247 adc_intr_reset (VDevice *dev)
<a name="l00248"></a>00248 {
<a name="l00249"></a>00249 ADCIntr_T *adc = (ADCIntr_T *)dev;
<a name="l00250"></a>00250
<a name="l00251"></a>00251 adc-&gt;intr_cb = NULL;
<a name="l00252"></a>00252
<a name="l00253"></a>00253 adc-&gt;adcsr = 0;
<a name="l00254"></a>00254 adc-&gt;admux = 0;
<a name="l00255"></a>00255 }
<a name="l00256"></a>00256
<a name="l00257"></a>00257 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00258"></a>00258 adc_intr_cb (uint64_t time, AvrClass *data)
<a name="l00259"></a>00259 {
<a name="l00260"></a>00260 ADCIntr_T *adc = (ADCIntr_T *)data;
<a name="l00261"></a>00261
<a name="l00262"></a>00262 <span class="keywordflow">if</span> (adc-&gt;intr_cb == NULL)
<a name="l00263"></a>00263 <span class="keywordflow">return</span> CB_RET_REMOVE;
<a name="l00264"></a>00264
<a name="l00265"></a>00265 <span class="keywordflow">if</span> ((adc-&gt;adcsr &amp; mask_ADEN) &amp;&amp; (adc-&gt;adcsr &amp; mask_ADIE)
<a name="l00266"></a>00266 &amp;&amp; (adc-&gt;adcsr &amp; mask_ADIF))
<a name="l00267"></a>00267 {
<a name="l00268"></a>00268 <span class="comment">/* an enabled interrupt occured */</span>
<a name="l00269"></a>00269 AvrCore *core = (AvrCore *)<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)adc);
<a name="l00270"></a>00270 <a class="code" href="avrcore_8c.html#90ca5d4a60478f9fccad81724a4be552" title="Raises an irq by adding it&amp;#39;s data to the irq_pending list.">avr_core_irq_raise</a> (core, irq_vect_table_index (ADC));
<a name="l00271"></a>00271 adc-&gt;adcsr &amp;= ~mask_ADIF;
<a name="l00272"></a>00272 }
<a name="l00273"></a>00273
<a name="l00274"></a>00274 <span class="keywordflow">return</span> CB_RET_RETAIN;
<a name="l00275"></a>00275 }
<a name="l00276"></a>00276
<a name="l00277"></a>00277 <span class="comment">/****************************************************************************\</span>
<a name="l00278"></a>00278 <span class="comment"> *</span>
<a name="l00279"></a>00279 <span class="comment"> * ADC </span>
<a name="l00280"></a>00280 <span class="comment"> *</span>
<a name="l00281"></a>00281 <span class="comment">\****************************************************************************/</span>
<a name="l00282"></a>00282
<a name="l00283"></a>00283 <span class="keyword">static</span> <span class="keywordtype">void</span> adc_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr,
<a name="l00284"></a>00284 <span class="keywordtype">void</span> *data);
<a name="l00285"></a>00285 <span class="keyword">static</span> uint8_t adc_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00286"></a>00286 <span class="keyword">static</span> <span class="keywordtype">void</span> adc_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00287"></a>00287 <span class="keyword">static</span> <span class="keywordtype">void</span> adc_reset (VDevice *dev);
<a name="l00288"></a>00288 <span class="comment"></span>
<a name="l00289"></a>00289 <span class="comment">/** \brief Allocate a new ADC structure. */</span>
<a name="l00290"></a>00290
<a name="l00291"></a>00291 VDevice *
<a name="l00292"></a><a class="code" href="adc_8c.html#f02be378f9ec8c8c2a2615225c4521d9">00292</a> <a class="code" href="adc_8c.html#f02be378f9ec8c8c2a2615225c4521d9" title="Allocate a new ADC structure.">adc_create</a> (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00293"></a>00293 {
<a name="l00294"></a>00294 uint8_t *data_ptr = (uint8_t *) data;
<a name="l00295"></a>00295 <span class="keywordflow">if</span> (data)
<a name="l00296"></a>00296 <span class="keywordflow">return</span> (VDevice *)adc_new (addr, name, (uint8_t) * data_ptr,
<a name="l00297"></a>00297 rel_addr);
<a name="l00298"></a>00298 <span class="keywordflow">else</span>
<a name="l00299"></a>00299 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Attempted A/D create with NULL data pointer"</span>);
<a name="l00300"></a>00300 <span class="keywordflow">return</span> 0;
<a name="l00301"></a>00301 }
<a name="l00302"></a>00302
<a name="l00303"></a>00303 ADC_T *
<a name="l00304"></a>00304 adc_new (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, uint8_t uier, <span class="keywordtype">int</span> rel_addr)
<a name="l00305"></a>00305 {
<a name="l00306"></a>00306 ADC_T *adc;
<a name="l00307"></a>00307
<a name="l00308"></a>00308 adc = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (ADC_T, 1);
<a name="l00309"></a>00309 <a class="code" href="adc_8c.html#e4966489f818e0c180369072c0f75424" title="Constructor for ADC object.">adc_construct</a> (adc, addr, name, uier, rel_addr);
<a name="l00310"></a>00310 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)adc, <a class="code" href="adc_8c.html#d3da5f1cc86c9ecde4ddc71eb3468e99" title="Destructor for ADC object.">adc_destroy</a>);
<a name="l00311"></a>00311
<a name="l00312"></a>00312 <span class="keywordflow">return</span> adc;
<a name="l00313"></a>00313 }
<a name="l00314"></a>00314 <span class="comment"></span>
<a name="l00315"></a>00315 <span class="comment">/** \brief Constructor for ADC object. */</span>
<a name="l00316"></a>00316
<a name="l00317"></a>00317 <span class="keywordtype">void</span>
<a name="l00318"></a><a class="code" href="adc_8c.html#e4966489f818e0c180369072c0f75424">00318</a> <a class="code" href="adc_8c.html#e4966489f818e0c180369072c0f75424" title="Constructor for ADC object.">adc_construct</a> (ADC_T *adc, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, uint8_t uier, <span class="keywordtype">int</span> rel_addr)
<a name="l00319"></a>00319 {
<a name="l00320"></a>00320 <span class="keywordflow">if</span> (adc == NULL)
<a name="l00321"></a>00321 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00322"></a>00322
<a name="l00323"></a>00323 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)adc, adc_read, adc_write, adc_reset,
<a name="l00324"></a>00324 adc_add_addr);
<a name="l00325"></a>00325
<a name="l00326"></a>00326 <span class="keywordflow">if</span> (rel_addr)
<a name="l00327"></a>00327 adc-&gt;rel_addr = rel_addr;
<a name="l00328"></a>00328 adc_add_addr ((VDevice *)adc, addr, name, 0, NULL);
<a name="l00329"></a>00329
<a name="l00330"></a>00330 adc_reset ((VDevice *)adc);
<a name="l00331"></a>00331 adc-&gt;u_divisor = uier ? 12 : 1;
<a name="l00332"></a>00332 }
<a name="l00333"></a>00333 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00334"></a>00334 adc_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00335"></a>00335 {
<a name="l00336"></a>00336 ADC_T *adc = (ADC_T *)vdev;
<a name="l00337"></a>00337
<a name="l00338"></a>00338 <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"ADCL"</span>, name, 4) == 0)
<a name="l00339"></a>00339 {
<a name="l00340"></a>00340 adc-&gt;adcl_addr = addr;
<a name="l00341"></a>00341 }
<a name="l00342"></a>00342
<a name="l00343"></a>00343 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"ADCH"</span>, name, 4) == 0)
<a name="l00344"></a>00344 {
<a name="l00345"></a>00345 adc-&gt;adch_addr = addr;
<a name="l00346"></a>00346 }
<a name="l00347"></a>00347
<a name="l00348"></a>00348 <span class="keywordflow">else</span>
<a name="l00349"></a>00349 {
<a name="l00350"></a>00350 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"invalid ADC register name: '%s' @ 0x%04x"</span>, name, addr);
<a name="l00351"></a>00351 }
<a name="l00352"></a>00352 }
<a name="l00353"></a>00353 <span class="comment"></span>
<a name="l00354"></a>00354 <span class="comment">/** \brief Destructor for ADC object. */</span>
<a name="l00355"></a>00355
<a name="l00356"></a>00356 <span class="keywordtype">void</span>
<a name="l00357"></a><a class="code" href="adc_8c.html#d3da5f1cc86c9ecde4ddc71eb3468e99">00357</a> <a class="code" href="adc_8c.html#d3da5f1cc86c9ecde4ddc71eb3468e99" title="Destructor for ADC object.">adc_destroy</a> (<span class="keywordtype">void</span> *adc)
<a name="l00358"></a>00358 {
<a name="l00359"></a>00359 <span class="keywordflow">if</span> (adc == NULL)
<a name="l00360"></a>00360 <span class="keywordflow">return</span>;
<a name="l00361"></a>00361
<a name="l00362"></a>00362 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (adc);
<a name="l00363"></a>00363 }
<a name="l00364"></a>00364
<a name="l00365"></a>00365 <span class="keyword">static</span> uint8_t
<a name="l00366"></a>00366 adc_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00367"></a>00367 {
<a name="l00368"></a>00368 ADC_T *adc = (ADC_T *)dev;
<a name="l00369"></a>00369
<a name="l00370"></a>00370 <span class="keywordflow">if</span> (addr == adc-&gt;adcl_addr)
<a name="l00371"></a>00371 <span class="keywordflow">return</span> adc-&gt;adcl;
<a name="l00372"></a>00372
<a name="l00373"></a>00373 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == adc-&gt;adch_addr)
<a name="l00374"></a>00374 <span class="keywordflow">return</span> adc-&gt;adch;
<a name="l00375"></a>00375
<a name="l00376"></a>00376 <span class="keywordflow">else</span>
<a name="l00377"></a>00377 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00378"></a>00378
<a name="l00379"></a>00379 <span class="keywordflow">return</span> 0; <span class="comment">/* will never get here */</span>
<a name="l00380"></a>00380 }
<a name="l00381"></a>00381
<a name="l00382"></a>00382 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00383"></a>00383 adc_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00384"></a>00384 {
<a name="l00385"></a>00385 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad ADC write address: 0x%04x"</span>, addr);
<a name="l00386"></a>00386 }
<a name="l00387"></a>00387
<a name="l00388"></a>00388 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00389"></a>00389 adc_reset (VDevice *dev)
<a name="l00390"></a>00390 {
<a name="l00391"></a>00391 ADC_T *adc = (ADC_T *)dev;
<a name="l00392"></a>00392
<a name="l00393"></a>00393 adc-&gt;clk_cb = NULL;
<a name="l00394"></a>00394
<a name="l00395"></a>00395 adc-&gt;adcl = 0;
<a name="l00396"></a>00396 adc-&gt;adch = 0;
<a name="l00397"></a>00397
<a name="l00398"></a>00398 adc-&gt;adc_count = 0;
<a name="l00399"></a>00399 adc-&gt;adc_in = 0;
<a name="l00400"></a>00400 adc-&gt;divisor = 0;
<a name="l00401"></a>00401 }
<a name="l00402"></a>00402
<a name="l00403"></a>00403 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00404"></a>00404 adc_clk_incr_cb (uint64_t ck, AvrClass *data)
<a name="l00405"></a>00405 {
<a name="l00406"></a>00406 ADC_T *adc = (ADC_T *)data;
<a name="l00407"></a>00407 uint8_t last = adc-&gt;adc_count;
<a name="l00408"></a>00408 ADCIntr_T *adc_ti;
<a name="l00409"></a>00409
<a name="l00410"></a>00410 adc_ti =
<a name="l00411"></a>00411 (ADCIntr_T *)<a class="code" href="avrcore_8c.html#f0c70bc7f992dcacd8ab411993bea5b5" title="Returns the VDevice which handles the address addr.">avr_core_get_vdev_by_addr</a> ((AvrCore *)
<a name="l00412"></a>00412 <a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)
<a name="l00413"></a>00413 adc),
<a name="l00414"></a>00414 adc-&gt;rel_addr);
<a name="l00415"></a>00415
<a name="l00416"></a>00416 <span class="keywordflow">if</span> (adc-&gt;clk_cb == NULL)
<a name="l00417"></a>00417 <span class="keywordflow">return</span> CB_RET_REMOVE;
<a name="l00418"></a>00418
<a name="l00419"></a>00419 <span class="keywordflow">if</span> (adc-&gt;divisor &lt;= 0)
<a name="l00420"></a>00420 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad divisor value: %d"</span>, adc-&gt;divisor);
<a name="l00421"></a>00421
<a name="l00422"></a>00422 <span class="comment">/* decrement clock if ck is a multiple of divisor */</span>
<a name="l00423"></a>00423 adc-&gt;adc_count -= ((ck % (adc-&gt;divisor * adc-&gt;u_divisor)) == 0);
<a name="l00424"></a>00424
<a name="l00425"></a>00425 <span class="keywordflow">if</span> (adc-&gt;adc_count != last) <span class="comment">/* we've changed the counter */</span>
<a name="l00426"></a>00426 {
<a name="l00427"></a>00427 <span class="keywordflow">if</span> (adc-&gt;adc_count == 0)
<a name="l00428"></a>00428 {
<a name="l00429"></a>00429 adc_ti-&gt;adcsr |= mask_ADIF;
<a name="l00430"></a>00430 adc_ti-&gt;adcsr &amp;= ~mask_ADSC;
<a name="l00431"></a>00431 adc-&gt;adc_in = adc_port_rd (adc_ti-&gt;admux);
<a name="l00432"></a>00432 adc-&gt;adcl = (adc-&gt;adc_in) &amp; 0xff; <span class="comment">/* update adcl to what we</span>
<a name="l00433"></a>00433 <span class="comment"> read */</span>
<a name="l00434"></a>00434 adc-&gt;adch = ((adc-&gt;adc_in) &gt;&gt; 8) &amp; 0x03; <span class="comment">/* update adch */</span>
<a name="l00435"></a>00435 <span class="keywordflow">if</span> (adc_ti-&gt;adcsr &amp; mask_ADFR) <span class="comment">/* free running mode */</span>
<a name="l00436"></a>00436 adc-&gt;adc_count = 13;
<a name="l00437"></a>00437 <span class="keywordflow">else</span>
<a name="l00438"></a>00438 {
<a name="l00439"></a>00439 adc-&gt;clk_cb = NULL;
<a name="l00440"></a>00440 <span class="keywordflow">return</span> CB_RET_REMOVE;
<a name="l00441"></a>00441 }
<a name="l00442"></a>00442 }
<a name="l00443"></a>00443 }
<a name="l00444"></a>00444 <span class="keywordflow">return</span> CB_RET_RETAIN;
<a name="l00445"></a>00445 }
<a name="l00446"></a>00446
<a name="l00447"></a>00447 <span class="comment">/* FIXME: TRoth/2003-11-29: These will eventually need to be plugged into an</span>
<a name="l00448"></a>00448 <span class="comment"> external connection interface. */</span>
<a name="l00449"></a>00449
<a name="l00450"></a>00450 uint16_t
<a name="l00451"></a>00451 adc_port_rd (uint8_t mux)
<a name="l00452"></a>00452 {
<a name="l00453"></a>00453 <span class="keywordtype">int</span> data;
<a name="l00454"></a>00454 <span class="keywordtype">char</span> line[80];
<a name="l00455"></a>00455
<a name="l00456"></a>00456 <span class="keywordflow">while</span> (1)
<a name="l00457"></a>00457 {
<a name="l00458"></a>00458 fprintf (stderr, <span class="stringliteral">"\nEnter data to read into the ADC for channel %d: "</span>,
<a name="l00459"></a>00459 mux);
<a name="l00460"></a>00460
<a name="l00461"></a>00461 <span class="comment">/* try to read in a line of input */</span>
<a name="l00462"></a>00462 <span class="keywordflow">if</span> (fgets (line, <span class="keyword">sizeof</span> (line), stdin) == NULL)
<a name="l00463"></a>00463 <span class="keywordflow">continue</span>;
<a name="l00464"></a>00464
<a name="l00465"></a>00465 <span class="comment">/* try to parse the line for a byte of data */</span>
<a name="l00466"></a>00466 <span class="keywordflow">if</span> (sscanf (line, <span class="stringliteral">"%d\n"</span>, &amp;data) != 1)
<a name="l00467"></a>00467 <span class="keywordflow">continue</span>;
<a name="l00468"></a>00468
<a name="l00469"></a>00469 <span class="keywordflow">break</span>;
<a name="l00470"></a>00470 }
<a name="l00471"></a>00471 <span class="keywordflow">return</span> (uint16_t) (data &amp; 0x3ff);
<a name="l00472"></a>00472 }
<a name="l00473"></a>00473
<a name="l00474"></a>00474 <span class="keywordtype">void</span>
<a name="l00475"></a>00475 adc_port_wr (uint8_t val)
<a name="l00476"></a>00476 {
<a name="l00477"></a>00477 fprintf (stderr, <span class="stringliteral">"wrote 0x%02x to ADC\n"</span>, val);
<a name="l00478"></a>00478 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,309 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>adc.c File Reference</h1>Module to simulate the AVR's ADC module. <a href="#_details">More...</a>
<p>
<p>
<a href="adc_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="adc_8c.html#9879d2be21cb9c2b10bd20b39ff2000d">adc_int_create</a> (int addr, char *name, int rel_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="d732fa5298a86f2e775cf7d0c9fb151d"></a><!-- doxytag: member="adc.c::adc_intr_new" ref="d732fa5298a86f2e775cf7d0c9fb151d" args="(int addr, char *name, int rel_addr)" -->
ADCIntr_T *&nbsp;</td><td class="memItemRight" valign="bottom"><b>adc_intr_new</b> (int addr, char *name, int rel_addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="adc_8c.html#4db5253cbc808007b02e3baed5fcb3e7">adc_intr_construct</a> (ADCIntr_T *adc, int addr, char *name, int rel_addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="adc_8c.html#5c602673eed7cc14090b7180c4f961fe">adc_intr_destroy</a> (void *adc)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="adc_8c.html#f02be378f9ec8c8c2a2615225c4521d9">adc_create</a> (int addr, char *name, int rel_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="76edc593fb88e7d9fa4c72403602046c"></a><!-- doxytag: member="adc.c::adc_new" ref="76edc593fb88e7d9fa4c72403602046c" args="(int addr, char *name, uint8_t uier, int rel_addr)" -->
ADC_T *&nbsp;</td><td class="memItemRight" valign="bottom"><b>adc_new</b> (int addr, char *name, uint8_t uier, int rel_addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="adc_8c.html#e4966489f818e0c180369072c0f75424">adc_construct</a> (ADC_T *adc, int addr, char *name, uint8_t uier, int rel_addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="adc_8c.html#d3da5f1cc86c9ecde4ddc71eb3468e99">adc_destroy</a> (void *adc)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="15764bb8cd0a21e74f07bd489f3628c0"></a><!-- doxytag: member="adc.c::adc_port_rd" ref="15764bb8cd0a21e74f07bd489f3628c0" args="(uint8_t mux)" -->
uint16_t&nbsp;</td><td class="memItemRight" valign="bottom"><b>adc_port_rd</b> (uint8_t mux)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="2494ae016747136da832498847632413"></a><!-- doxytag: member="adc.c::adc_port_wr" ref="2494ae016747136da832498847632413" args="(uint8_t val)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><b>adc_port_wr</b> (uint8_t val)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Module to simulate the AVR's ADC module.
<p>
<p>Definition in file <a class="el" href="adc_8c-source.html">adc.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="9879d2be21cb9c2b10bd20b39ff2000d"></a><!-- doxytag: member="adc.c::adc_int_create" ref="9879d2be21cb9c2b10bd20b39ff2000d" args="(int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* adc_int_create </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new ADC interrupt.
<p>
<p>Definition at line <a class="el" href="adc_8c-source.html#l00079">79</a> of file <a class="el" href="adc_8c-source.html">adc.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="4db5253cbc808007b02e3baed5fcb3e7"></a><!-- doxytag: member="adc.c::adc_intr_construct" ref="4db5253cbc808007b02e3baed5fcb3e7" args="(ADCIntr_T *adc, int addr, char *name, int rel_addr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void adc_intr_construct </td>
<td>(</td>
<td class="paramtype">ADCIntr_T *&nbsp;</td>
<td class="paramname"> <em>adc</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for adc interrupt object.
<p>
<p>Definition at line <a class="el" href="adc_8c-source.html#l00099">99</a> of file <a class="el" href="adc_8c-source.html">adc.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="5c602673eed7cc14090b7180c4f961fe"></a><!-- doxytag: member="adc.c::adc_intr_destroy" ref="5c602673eed7cc14090b7180c4f961fe" args="(void *adc)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void adc_intr_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>adc</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for adc interrupt object.
<p>
<p>Definition at line <a class="el" href="adc_8c-source.html#l00138">138</a> of file <a class="el" href="adc_8c-source.html">adc.c</a>.</p>
<p>References <a class="el" href="device_8c-source.html#l00105">vdev_destroy()</a>.</p>
</div>
</div><p>
<a class="anchor" name="f02be378f9ec8c8c2a2615225c4521d9"></a><!-- doxytag: member="adc.c::adc_create" ref="f02be378f9ec8c8c2a2615225c4521d9" args="(int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* adc_create </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new ADC structure.
<p>
<p>Definition at line <a class="el" href="adc_8c-source.html#l00292">292</a> of file <a class="el" href="adc_8c-source.html">adc.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
</div>
</div><p>
<a class="anchor" name="e4966489f818e0c180369072c0f75424"></a><!-- doxytag: member="adc.c::adc_construct" ref="e4966489f818e0c180369072c0f75424" args="(ADC_T *adc, int addr, char *name, uint8_t uier, int rel_addr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void adc_construct </td>
<td>(</td>
<td class="paramtype">ADC_T *&nbsp;</td>
<td class="paramname"> <em>adc</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&nbsp;</td>
<td class="paramname"> <em>uier</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for ADC object.
<p>
<p>Definition at line <a class="el" href="adc_8c-source.html#l00318">318</a> of file <a class="el" href="adc_8c-source.html">adc.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="d3da5f1cc86c9ecde4ddc71eb3468e99"></a><!-- doxytag: member="adc.c::adc_destroy" ref="d3da5f1cc86c9ecde4ddc71eb3468e99" args="(void *adc)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void adc_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>adc</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for ADC object.
<p>
<p>Definition at line <a class="el" href="adc_8c-source.html#l00357">357</a> of file <a class="el" href="adc_8c-source.html">adc.c</a>.</p>
<p>References <a class="el" href="device_8c-source.html#l00105">vdev_destroy()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,153 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>avrclass.c</h1><a href="avrclass_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: avrclass.c,v 1.8 2003/12/01 09:10:13 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/**</span>
<a name="l00027"></a>00027 <span class="comment"> * \file avrclass.c</span>
<a name="l00028"></a>00028 <span class="comment"> * \brief Methods to provide user interfaces to the AvrClass structure.</span>
<a name="l00029"></a>00029 <span class="comment"> *</span>
<a name="l00030"></a>00030 <span class="comment"> * This module provides the basis for simulavr's object mechanism. For a</span>
<a name="l00031"></a>00031 <span class="comment"> * detailed discussion on using simulavr's class mechanism, see the simulavr</span>
<a name="l00032"></a>00032 <span class="comment"> * users manual. FIXME: [TRoth 2002/03/19] move the discussion here. */</span>
<a name="l00033"></a>00033
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00035"></a>00035
<a name="l00036"></a>00036 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00039"></a>00039 <span class="comment"></span>
<a name="l00040"></a>00040 <span class="comment">/** \brief This function should never be used. </span>
<a name="l00041"></a>00041 <span class="comment"> *</span>
<a name="l00042"></a>00042 <span class="comment"> * The only potential use for it as a template for derived classes. </span>
<a name="l00043"></a>00043 <span class="comment"> * Do Not Use This Function! */</span>
<a name="l00044"></a>00044
<a name="l00045"></a>00045 AvrClass *
<a name="l00046"></a><a class="code" href="avrclass_8c.html#d07c51bd8c81db78fab8d240fd698024">00046</a> <a class="code" href="avrclass_8c.html#d07c51bd8c81db78fab8d240fd698024" title="This function should never be used.">class_new</a> (<span class="keywordtype">void</span>)
<a name="l00047"></a>00047 {
<a name="l00048"></a>00048 AvrClass *klass = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (AvrClass, 1);
<a name="l00049"></a>00049 <a class="code" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e" title="Initializes the AvrClass data structure.">class_construct</a> (klass);
<a name="l00050"></a>00050 <span class="keywordflow">return</span> klass;
<a name="l00051"></a>00051 }
<a name="l00052"></a>00052 <span class="comment"></span>
<a name="l00053"></a>00053 <span class="comment">/** \brief Initializes the AvrClass data structure. </span>
<a name="l00054"></a>00054 <span class="comment"> *</span>
<a name="l00055"></a>00055 <span class="comment"> * A derived class should call this function from their own </span>
<a name="l00056"></a>00056 <span class="comment"> * &lt;klass&gt;_construct() function. All classes should</span>
<a name="l00057"></a>00057 <span class="comment"> * have their constructor function call their parent's constructor</span>
<a name="l00058"></a>00058 <span class="comment"> * function. */</span>
<a name="l00059"></a>00059
<a name="l00060"></a>00060 <span class="keywordtype">void</span>
<a name="l00061"></a><a class="code" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e">00061</a> <a class="code" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e" title="Initializes the AvrClass data structure.">class_construct</a> (AvrClass *klass)
<a name="l00062"></a>00062 {
<a name="l00063"></a>00063 <span class="keywordflow">if</span> (klass == NULL)
<a name="l00064"></a>00064 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00065"></a>00065
<a name="l00066"></a>00066 klass-&gt;ref_count = 1;
<a name="l00067"></a>00067 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> (klass, <a class="code" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5" title="Releases resources allocated by class&amp;#39;s &amp;lt;klass&amp;gt;_new() function.">class_destroy</a>);
<a name="l00068"></a>00068 }
<a name="l00069"></a>00069 <span class="comment"></span>
<a name="l00070"></a>00070 <span class="comment">/** \brief Releases resources allocated by class's &lt;klass&gt;_new() function. </span>
<a name="l00071"></a>00071 <span class="comment"> *</span>
<a name="l00072"></a>00072 <span class="comment"> * This function should never be called except as the last statement </span>
<a name="l00073"></a>00073 <span class="comment"> * of a directly derived class's destroy method. </span>
<a name="l00074"></a>00074 <span class="comment"> * All classes should have their destroy method call their parent's </span>
<a name="l00075"></a>00075 <span class="comment"> * destroy method. */</span>
<a name="l00076"></a>00076
<a name="l00077"></a>00077 <span class="keywordtype">void</span>
<a name="l00078"></a><a class="code" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5">00078</a> <a class="code" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5" title="Releases resources allocated by class&amp;#39;s &amp;lt;klass&amp;gt;_new() function.">class_destroy</a> (<span class="keywordtype">void</span> *klass)
<a name="l00079"></a>00079 {
<a name="l00080"></a>00080 <span class="keywordflow">if</span> (klass == NULL)
<a name="l00081"></a>00081 <span class="keywordflow">return</span>;
<a name="l00082"></a>00082
<a name="l00083"></a>00083 <a class="code" href="avrmalloc_8c.html#082a9d6d40f5e8bad64441ad950ec12c" title="Free malloc&amp;#39;d memory.">avr_free</a> (klass);
<a name="l00084"></a>00084 }
<a name="l00085"></a>00085 <span class="comment"></span>
<a name="l00086"></a>00086 <span class="comment">/** \brief Overload the default destroy method.</span>
<a name="l00087"></a>00087 <span class="comment"> *</span>
<a name="l00088"></a>00088 <span class="comment"> * Derived classes will call this to replace class_destroy() with their own</span>
<a name="l00089"></a>00089 <span class="comment"> * destroy method. */</span>
<a name="l00090"></a>00090
<a name="l00091"></a>00091 <span class="keywordtype">void</span>
<a name="l00092"></a><a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1">00092</a> <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> (AvrClass *klass, AvrClassFP_Destroy destroy)
<a name="l00093"></a>00093 {
<a name="l00094"></a>00094 <span class="keywordflow">if</span> (klass == NULL)
<a name="l00095"></a>00095 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00096"></a>00096
<a name="l00097"></a>00097 klass-&gt;destroy = destroy;
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099 <span class="comment"></span>
<a name="l00100"></a>00100 <span class="comment">/** \brief Increments the reference count for the klass object. </span>
<a name="l00101"></a>00101 <span class="comment"> *</span>
<a name="l00102"></a>00102 <span class="comment"> * The programmer must call this whenever a reference to an object </span>
<a name="l00103"></a>00103 <span class="comment"> * is stored in more than one place. */</span>
<a name="l00104"></a>00104
<a name="l00105"></a>00105 <span class="keywordtype">void</span>
<a name="l00106"></a><a class="code" href="avrclass_8c.html#ff0f5b14bf2740f208041d515f3ba93f">00106</a> <a class="code" href="avrclass_8c.html#ff0f5b14bf2740f208041d515f3ba93f" title="Increments the reference count for the klass object.">class_ref</a> (AvrClass *klass)
<a name="l00107"></a>00107 {
<a name="l00108"></a>00108 <span class="keywordflow">if</span> (klass == NULL)
<a name="l00109"></a>00109 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00110"></a>00110
<a name="l00111"></a>00111 klass-&gt;ref_count++;
<a name="l00112"></a>00112 }
<a name="l00113"></a>00113 <span class="comment"></span>
<a name="l00114"></a>00114 <span class="comment">/** \brief Decrements the reference count for the klass object. </span>
<a name="l00115"></a>00115 <span class="comment"> *</span>
<a name="l00116"></a>00116 <span class="comment"> * When the reference count reaches zero, the class's destroy method </span>
<a name="l00117"></a>00117 <span class="comment"> * is called on the object. */</span>
<a name="l00118"></a>00118
<a name="l00119"></a>00119 <span class="keywordtype">void</span>
<a name="l00120"></a><a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693">00120</a> <a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a> (AvrClass *klass)
<a name="l00121"></a>00121 {
<a name="l00122"></a>00122 <span class="keywordflow">if</span> (klass == NULL)
<a name="l00123"></a>00123 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00124"></a>00124
<a name="l00125"></a>00125 klass-&gt;ref_count--;
<a name="l00126"></a>00126 <span class="keywordflow">if</span> (klass-&gt;ref_count == 0)
<a name="l00127"></a>00127 klass-&gt;destroy (klass);
<a name="l00128"></a>00128 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,228 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>avrclass.c File Reference</h1>Methods to provide user interfaces to the AvrClass structure. <a href="#_details">More...</a>
<p>
<p>
<a href="avrclass_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">AvrClass *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrclass_8c.html#d07c51bd8c81db78fab8d240fd698024">class_new</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e">class_construct</a> (AvrClass *klass)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5">class_destroy</a> (void *klass)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1">class_overload_destroy</a> (AvrClass *klass, AvrClassFP_Destroy destroy)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrclass_8c.html#ff0f5b14bf2740f208041d515f3ba93f">class_ref</a> (AvrClass *klass)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693">class_unref</a> (AvrClass *klass)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Methods to provide user interfaces to the AvrClass structure.
<p>
This module provides the basis for simulavr's object mechanism. For a detailed discussion on using simulavr's class mechanism, see the simulavr users manual. FIXME: [TRoth 2002/03/19] move the discussion here.
<p>Definition in file <a class="el" href="avrclass_8c-source.html">avrclass.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="d07c51bd8c81db78fab8d240fd698024"></a><!-- doxytag: member="avrclass.c::class_new" ref="d07c51bd8c81db78fab8d240fd698024" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">AvrClass* class_new </td>
<td>(</td>
<td class="paramtype">void&nbsp;</td>
<td class="paramname"> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
This function should never be used.
<p>
The only potential use for it as a template for derived classes. Do Not Use This Function!
<p>Definition at line <a class="el" href="avrclass_8c-source.html#l00046">46</a> of file <a class="el" href="avrclass_8c-source.html">avrclass.c</a>.</p>
<p>References <a class="el" href="avrmalloc_8c-source.html#l00057">avr_new</a>, and <a class="el" href="avrclass_8c-source.html#l00061">class_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="ffeb66dd49a62ad1b7606cde0e3b039e"></a><!-- doxytag: member="avrclass.c::class_construct" ref="ffeb66dd49a62ad1b7606cde0e3b039e" args="(AvrClass *klass)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void class_construct </td>
<td>(</td>
<td class="paramtype">AvrClass *&nbsp;</td>
<td class="paramname"> <em>klass</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Initializes the AvrClass data structure.
<p>
A derived class should call this function from their own &lt;klass&gt;_construct() function. All classes should have their constructor function call their parent's constructor function.
<p>Definition at line <a class="el" href="avrclass_8c-source.html#l00061">61</a> of file <a class="el" href="avrclass_8c-source.html">avrclass.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, <a class="el" href="avrclass_8c-source.html#l00078">class_destroy()</a>, and <a class="el" href="avrclass_8c-source.html#l00092">class_overload_destroy()</a>.</p>
<p>Referenced by <a class="el" href="avrclass_8c-source.html#l00046">class_new()</a>, <a class="el" href="memory_8c-source.html#l00080">mem_construct()</a>, <a class="el" href="stack_8c-source.html#l00099">stack_construct()</a>, and <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="86e290a528dd1ed0bf5057056b5731e5"></a><!-- doxytag: member="avrclass.c::class_destroy" ref="86e290a528dd1ed0bf5057056b5731e5" args="(void *klass)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void class_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>klass</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Releases resources allocated by class's &lt;klass&gt;_new() function.
<p>
This function should never be called except as the last statement of a directly derived class's destroy method. All classes should have their destroy method call their parent's destroy method.
<p>Definition at line <a class="el" href="avrclass_8c-source.html#l00078">78</a> of file <a class="el" href="avrclass_8c-source.html">avrclass.c</a>.</p>
<p>References <a class="el" href="avrmalloc_8c-source.html#l00187">avr_free()</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l00539">avr_core_destroy()</a>, <a class="el" href="avrclass_8c-source.html#l00061">class_construct()</a>, <a class="el" href="memory_8c-source.html#l00099">mem_destroy()</a>, <a class="el" href="stack_8c-source.html#l00116">stack_destroy()</a>, and <a class="el" href="device_8c-source.html#l00105">vdev_destroy()</a>.</p>
</div>
</div><p>
<a class="anchor" name="82d397ff00a7f1c1447832dbff1856e1"></a><!-- doxytag: member="avrclass.c::class_overload_destroy" ref="82d397ff00a7f1c1447832dbff1856e1" args="(AvrClass *klass, AvrClassFP_Destroy destroy)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void class_overload_destroy </td>
<td>(</td>
<td class="paramtype">AvrClass *&nbsp;</td>
<td class="paramname"> <em>klass</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">AvrClassFP_Destroy&nbsp;</td>
<td class="paramname"> <em>destroy</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Overload the default destroy method.
<p>
Derived classes will call this to replace <a class="el" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5" title="Releases resources allocated by class&#39;s &lt;klass&gt;_new() function.">class_destroy()</a> with their own destroy method.
<p>Definition at line <a class="el" href="avrclass_8c-source.html#l00092">92</a> of file <a class="el" href="avrclass_8c-source.html">avrclass.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l00355">avr_core_new()</a>, <a class="el" href="avrclass_8c-source.html#l00061">class_construct()</a>, <a class="el" href="flash_8c-source.html#l00117">flash_new()</a>, <a class="el" href="stack_8c-source.html#l00163">hwstack_new()</a>, <a class="el" href="memory_8c-source.html#l00066">mem_new()</a>, <a class="el" href="stack_8c-source.html#l00388">memstack_new()</a>, <a class="el" href="stack_8c-source.html#l00082">stack_new()</a>, and <a class="el" href="device_8c-source.html#l00062">vdev_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="ff0f5b14bf2740f208041d515f3ba93f"></a><!-- doxytag: member="avrclass.c::class_ref" ref="ff0f5b14bf2740f208041d515f3ba93f" args="(AvrClass *klass)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void class_ref </td>
<td>(</td>
<td class="paramtype">AvrClass *&nbsp;</td>
<td class="paramname"> <em>klass</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Increments the reference count for the klass object.
<p>
The programmer must call this whenever a reference to an object is stored in more than one place.
<p>Definition at line <a class="el" href="avrclass_8c-source.html#l00106">106</a> of file <a class="el" href="avrclass_8c-source.html">avrclass.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
<p>Referenced by <a class="el" href="memory_8c-source.html#l00130">mem_attach()</a>, and <a class="el" href="stack_8c-source.html#l00402">memstack_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="0e597261f2fe0c7c5a56de97ecc38693"></a><!-- doxytag: member="avrclass.c::class_unref" ref="0e597261f2fe0c7c5a56de97ecc38693" args="(AvrClass *klass)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void class_unref </td>
<td>(</td>
<td class="paramtype">AvrClass *&nbsp;</td>
<td class="paramname"> <em>klass</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Decrements the reference count for the klass object.
<p>
When the reference count reaches zero, the class's destroy method is called on the object.
<p>Definition at line <a class="el" href="avrclass_8c-source.html#l00120">120</a> of file <a class="el" href="avrclass_8c-source.html">avrclass.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l00539">avr_core_destroy()</a>, <a class="el" href="utils_8c-source.html#l00159">dlist_add()</a>, <a class="el" href="utils_8c-source.html#l00215">dlist_delete()</a>, <a class="el" href="utils_8c-source.html#l00266">dlist_delete_all()</a>, <a class="el" href="memory_8c-source.html#l00099">mem_destroy()</a>, and <a class="el" href="stack_8c-source.html#l00423">memstack_destroy()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,171 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>avrerror.c</h1><a href="avrerror_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: avrerror.c,v 1.8 2004/01/30 07:09:56 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003, 2004 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/**</span>
<a name="l00027"></a>00027 <span class="comment"> \file avrerror.c</span>
<a name="l00028"></a>00028 <span class="comment"> \brief Functions for printing messages, warnings and errors.</span>
<a name="l00029"></a>00029 <span class="comment"></span>
<a name="l00030"></a>00030 <span class="comment"> This module provides output printing facilities. */</span>
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;stdarg.h&gt;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00036"></a>00036
<a name="l00037"></a>00037 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00038"></a>00038
<a name="l00039"></a>00039 <span class="preprocessor">#if MACRO_DOCUMENTATION</span>
<a name="l00040"></a>00040 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00041"></a>00041 <span class="comment">/** \brief Print an ordinary message to stdout. */</span>
<a name="l00042"></a><a class="code" href="avrerror_8c.html#deeaf2330efd6054822bc9146527777b">00042</a> <span class="preprocessor">#define avr_message(fmt, args...) \</span>
<a name="l00043"></a>00043 <span class="preprocessor"> private_avr_message(__FILE__, __LINE__, fmt, ## args)</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00045"></a>00045 <span class="comment">/** \brief Print a warning message to stderr. */</span>
<a name="l00046"></a><a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170">00046</a> <span class="preprocessor">#define avr_warning(fmt, args...) \</span>
<a name="l00047"></a>00047 <span class="preprocessor"> private_avr_warning(__FILE__, __LINE__, fmt, ## args)</span>
<a name="l00048"></a>00048 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00049"></a>00049 <span class="comment">/** \brief Print an error message to stderr and terminate program. */</span>
<a name="l00050"></a><a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a">00050</a> <span class="preprocessor">#define avr_error(fmt, args...) \</span>
<a name="l00051"></a>00051 <span class="preprocessor"> private_avr_error(__FILE__, __LINE__, fmt, ## args)</span>
<a name="l00052"></a>00052 <span class="preprocessor"></span>
<a name="l00053"></a>00053 <span class="preprocessor">#else </span><span class="comment">/* Not Documentation */</span>
<a name="l00054"></a>00054
<a name="l00055"></a>00055 <span class="preprocessor">#if 1</span>
<a name="l00056"></a>00056 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">char</span> *
<a name="l00057"></a>00057 strip_dir (<span class="keywordtype">char</span> *path)
<a name="l00058"></a>00058 {
<a name="l00059"></a>00059 <span class="keywordtype">char</span> *p = path;
<a name="l00060"></a>00060
<a name="l00061"></a>00061 <span class="comment">/* Find the end. */</span>
<a name="l00062"></a>00062
<a name="l00063"></a>00063 <span class="keywordflow">while</span> (*p++)
<a name="l00064"></a>00064 ;
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="comment">/* Find the last '/'. */</span>
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="keywordflow">while</span> (p != path)
<a name="l00069"></a>00069 {
<a name="l00070"></a>00070 <span class="keywordflow">if</span> (*p == <span class="charliteral">'/'</span>)
<a name="l00071"></a>00071 {
<a name="l00072"></a>00072 p++;
<a name="l00073"></a>00073 <span class="keywordflow">break</span>;
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075
<a name="l00076"></a>00076 p--;
<a name="l00077"></a>00077 }
<a name="l00078"></a>00078
<a name="l00079"></a>00079 <span class="keywordflow">return</span> p;
<a name="l00080"></a>00080 }
<a name="l00081"></a>00081 <span class="preprocessor">#else</span>
<a name="l00082"></a>00082 <span class="preprocessor"></span><span class="preprocessor"># define strip_dir(path) (path)</span>
<a name="l00083"></a>00083 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00084"></a>00084 <span class="preprocessor"></span>
<a name="l00085"></a>00085 <span class="preprocessor">#define FLUSH_OUTPUT 1</span>
<a name="l00086"></a>00086 <span class="preprocessor"></span>
<a name="l00087"></a>00087 <span class="keywordtype">void</span>
<a name="l00088"></a>00088 private_avr_message (<span class="keywordtype">char</span> *file, <span class="keywordtype">int</span> line, <span class="keywordtype">char</span> *fmt, ...)
<a name="l00089"></a>00089 {
<a name="l00090"></a>00090 va_list ap;
<a name="l00091"></a>00091 <span class="keywordtype">char</span> ffmt[128];
<a name="l00092"></a>00092
<a name="l00093"></a>00093 snprintf (ffmt, <span class="keyword">sizeof</span> (ffmt), <span class="stringliteral">"%s:%d: MESSAGE: %s"</span>, strip_dir (file),
<a name="l00094"></a>00094 line, fmt);
<a name="l00095"></a>00095 ffmt[127] = <span class="charliteral">'\0'</span>;
<a name="l00096"></a>00096
<a name="l00097"></a>00097 va_start (ap, fmt);
<a name="l00098"></a>00098 vfprintf (stdout, ffmt, ap);
<a name="l00099"></a>00099 va_end (ap);
<a name="l00100"></a>00100
<a name="l00101"></a>00101 <span class="preprocessor">#if defined (FLUSH_OUTPUT)</span>
<a name="l00102"></a>00102 <span class="preprocessor"></span> fflush (stdout);
<a name="l00103"></a>00103 <span class="preprocessor">#endif</span>
<a name="l00104"></a>00104 <span class="preprocessor"></span>}
<a name="l00105"></a>00105
<a name="l00106"></a>00106 <span class="keywordtype">void</span>
<a name="l00107"></a>00107 private_avr_warning (<span class="keywordtype">char</span> *file, <span class="keywordtype">int</span> line, <span class="keywordtype">char</span> *fmt, ...)
<a name="l00108"></a>00108 {
<a name="l00109"></a>00109 va_list ap;
<a name="l00110"></a>00110 <span class="keywordtype">char</span> ffmt[128];
<a name="l00111"></a>00111
<a name="l00112"></a>00112 snprintf (ffmt, <span class="keyword">sizeof</span> (ffmt), <span class="stringliteral">"%s:%d: WARNING: %s"</span>, strip_dir (file),
<a name="l00113"></a>00113 line, fmt);
<a name="l00114"></a>00114 ffmt[127] = <span class="charliteral">'\0'</span>;
<a name="l00115"></a>00115
<a name="l00116"></a>00116 va_start (ap, fmt);
<a name="l00117"></a>00117 vfprintf (stderr, ffmt, ap);
<a name="l00118"></a>00118 va_end (ap);
<a name="l00119"></a>00119
<a name="l00120"></a>00120 <span class="preprocessor">#if defined (FLUSH_OUTPUT)</span>
<a name="l00121"></a>00121 <span class="preprocessor"></span> fflush (stderr);
<a name="l00122"></a>00122 <span class="preprocessor">#endif</span>
<a name="l00123"></a>00123 <span class="preprocessor"></span>}
<a name="l00124"></a>00124
<a name="l00125"></a>00125 <span class="keywordtype">void</span>
<a name="l00126"></a>00126 private_avr_error (<span class="keywordtype">char</span> *file, <span class="keywordtype">int</span> line, <span class="keywordtype">char</span> *fmt, ...)
<a name="l00127"></a>00127 {
<a name="l00128"></a>00128 va_list ap;
<a name="l00129"></a>00129 <span class="keywordtype">char</span> ffmt[128];
<a name="l00130"></a>00130
<a name="l00131"></a>00131 snprintf (ffmt, <span class="keyword">sizeof</span> (ffmt), <span class="stringliteral">"\n%s:%d: ERROR: %s\n\n"</span>, strip_dir (file),
<a name="l00132"></a>00132 line, fmt);
<a name="l00133"></a>00133 ffmt[127] = <span class="charliteral">'\0'</span>;
<a name="l00134"></a>00134
<a name="l00135"></a>00135 va_start (ap, fmt);
<a name="l00136"></a>00136 vfprintf (stderr, ffmt, ap);
<a name="l00137"></a>00137 va_end (ap);
<a name="l00138"></a>00138
<a name="l00139"></a>00139 <span class="preprocessor">#if defined (FLUSH_OUTPUT)</span>
<a name="l00140"></a>00140 <span class="preprocessor"></span> fflush (stderr);
<a name="l00141"></a>00141 <span class="preprocessor">#endif</span>
<a name="l00142"></a>00142 <span class="preprocessor"></span>
<a name="l00143"></a>00143 exit (1); <span class="comment">/* exit instead of abort */</span>
<a name="l00144"></a>00144 }
<a name="l00145"></a>00145
<a name="l00146"></a>00146 <span class="preprocessor">#endif </span><span class="comment">/* Not documenation */</span>
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,134 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>avrerror.c File Reference</h1>Functions for printing messages, warnings and errors. <a href="#_details">More...</a>
<p>
<p>
<a href="avrerror_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrerror_8c.html#deeaf2330efd6054822bc9146527777b">avr_message</a>(fmt, args...)&nbsp;&nbsp;&nbsp;private_avr_message(__FILE__, __LINE__, fmt, ## args)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170">avr_warning</a>(fmt, args...)&nbsp;&nbsp;&nbsp;private_avr_warning(__FILE__, __LINE__, fmt, ## args)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a">avr_error</a>(fmt, args...)&nbsp;&nbsp;&nbsp;private_avr_error(__FILE__, __LINE__, fmt, ## args)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Functions for printing messages, warnings and errors.
<p>
This module provides output printing facilities.
<p>Definition in file <a class="el" href="avrerror_8c-source.html">avrerror.c</a>.</p>
<hr><h2>Define Documentation</h2>
<a class="anchor" name="deeaf2330efd6054822bc9146527777b"></a><!-- doxytag: member="avrerror.c::avr_message" ref="deeaf2330efd6054822bc9146527777b" args="(fmt, args...)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define avr_message </td>
<td>(</td>
<td class="paramtype">fmt, <tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">args...&nbsp;</td>
<td class="paramname"> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%">&nbsp;&nbsp;&nbsp;private_avr_message(__FILE__, __LINE__, fmt, ## args)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Print an ordinary message to stdout.
<p>
<p>Definition at line <a class="el" href="avrerror_8c-source.html#l00042">42</a> of file <a class="el" href="avrerror_8c-source.html">avrerror.c</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l00844">avr_core_irq_raise()</a>, <a class="el" href="avrcore_8c-source.html#l01140">avr_core_run()</a>, and <a class="el" href="decoder_8c-source.html#l03869">decode_init_lookup_table()</a>.</p>
</div>
</div><p>
<a class="anchor" name="0d89f34d142884b2f78e133c88c93170"></a><!-- doxytag: member="avrerror.c::avr_warning" ref="0d89f34d142884b2f78e133c88c93170" args="(fmt, args...)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define avr_warning </td>
<td>(</td>
<td class="paramtype">fmt, <tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">args...&nbsp;</td>
<td class="paramname"> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%">&nbsp;&nbsp;&nbsp;private_avr_warning(__FILE__, __LINE__, fmt, ## args)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Print a warning message to stderr.
<p>
<p>Definition at line <a class="el" href="avrerror_8c-source.html#l00046">46</a> of file <a class="el" href="avrerror_8c-source.html">avrerror.c</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l01234">avr_core_add_ext_rd_wr()</a>, <a class="el" href="display_8c-source.html#l00085">display_open()</a>, <a class="el" href="display_8c-source.html#l00220">display_send_msg()</a>, <a class="el" href="flash_8c-source.html#l00164">flash_load_from_file()</a>, <a class="el" href="memory_8c-source.html#l00212">mem_read()</a>, <a class="el" href="memory_8c-source.html#l00247">mem_write()</a>, <a class="el" href="sig_8c-source.html#l00119">signal_has_occurred()</a>, <a class="el" href="sig_8c-source.html#l00067">signal_watch_start()</a>, <a class="el" href="sig_8c-source.html#l00097">signal_watch_stop()</a>, <a class="el" href="device_8c-source.html#l00195">vdev_add_addr()</a>, and <a class="el" href="device_8c-source.html#l00080">vdev_def_AddAddr()</a>.</p>
</div>
</div><p>
<a class="anchor" name="4f6ec50114a7d63093baecafe47d7f1a"></a><!-- doxytag: member="avrerror.c::avr_error" ref="4f6ec50114a7d63093baecafe47d7f1a" args="(fmt, args...)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define avr_error </td>
<td>(</td>
<td class="paramtype">fmt, <tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">args...&nbsp;</td>
<td class="paramname"> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%">&nbsp;&nbsp;&nbsp;private_avr_error(__FILE__, __LINE__, fmt, ## args)</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Print an error message to stderr and terminate program.
<p>
<p>Definition at line <a class="el" href="avrerror_8c-source.html#l00050">50</a> of file <a class="el" href="avrerror_8c-source.html">avrerror.c</a>.</p>
<p>Referenced by <a class="el" href="adc_8c-source.html#l00318">adc_construct()</a>, <a class="el" href="adc_8c-source.html#l00292">adc_create()</a>, <a class="el" href="adc_8c-source.html#l00099">adc_intr_construct()</a>, <a class="el" href="avrmalloc_8c-source.html#l00093">avr_malloc()</a>, <a class="el" href="avrmalloc_8c-source.html#l00117">avr_malloc0()</a>, <a class="el" href="avrmalloc_8c-source.html#l00143">avr_realloc()</a>, <a class="el" href="avrmalloc_8c-source.html#l00168">avr_strdup()</a>, <a class="el" href="avrclass_8c-source.html#l00061">class_construct()</a>, <a class="el" href="avrclass_8c-source.html#l00092">class_overload_destroy()</a>, <a class="el" href="avrclass_8c-source.html#l00106">class_ref()</a>, <a class="el" href="avrclass_8c-source.html#l00120">class_unref()</a>, <a class="el" href="display_8c-source.html#l00404">display_eeprom()</a>, <a class="el" href="display_8c-source.html#l00340">display_flash()</a>, <a class="el" href="display_8c-source.html#l00220">display_send_msg()</a>, <a class="el" href="display_8c-source.html#l00372">display_sram()</a>, <a class="el" href="utils_8c-source.html#l00215">dlist_delete()</a>, <a class="el" href="utils_8c-source.html#l00357">dlist_iterator()</a>, <a class="el" href="utils_8c-source.html#l00291">dlist_lookup()</a>, <a class="el" href="flash_8c-source.html#l00131">flash_construct()</a>, <a class="el" href="gdbserver_8c-source.html#l01320">gdb_interact()</a>, <a class="el" href="utils_8c-source.html#l00076">get_program_time()</a>, <a class="el" href="stack_8c-source.html#l00177">hwstack_construct()</a>, <a class="el" href="memory_8c-source.html#l00130">mem_attach()</a>, <a class="el" href="memory_8c-source.html#l00080">mem_construct()</a>, <a class="el" href="memory_8c-source.html#l00169">mem_get_vdevice_by_name()</a>, <a class="el" href="stack_8c-source.html#l00402">memstack_construct()</a>, <a class="el" href="timers_8c-source.html#l00935">ocreg16_construct()</a>, <a class="el" href="timers_8c-source.html#l00909">ocreg16_create()</a>, <a class="el" href="spi_8c-source.html#l00267">spi_construct()</a>, <a class="el" href="spi_8c-source.html#l00098">spi_intr_construct()</a>, <a class="el" href="stack_8c-source.html#l00099">stack_construct()</a>, <a class="el" href="timers_8c-source.html#l00370">timer0_construct()</a>, <a class="el" href="timers_8c-source.html#l00608">timer16_construct()</a>, <a class="el" href="timers_8c-source.html#l00582">timer16_create()</a>, <a class="el" href="timers_8c-source.html#l00138">timer_int_create()</a>, <a class="el" href="timers_8c-source.html#l00163">timer_intr_construct()</a>, <a class="el" href="uart_8c-source.html#l00356">uart_construct()</a>, <a class="el" href="uart_8c-source.html#l00095">uart_int_create()</a>, <a class="el" href="uart_8c-source.html#l00128">uart_intr_construct()</a>, <a class="el" href="usb_8c-source.html#l00321">usb_construct()</a>, <a class="el" href="usb_8c-source.html#l00103">usb_intr_construct()</a>, <a class="el" href="usb_8c-source.html#l00078">usbi_create()</a>, and <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,216 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>avrmalloc.c</h1><a href="avrmalloc_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: avrmalloc.c,v 1.7 2003/12/01 09:10:14 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/**</span>
<a name="l00027"></a>00027 <span class="comment"> \file avrmalloc.c</span>
<a name="l00028"></a>00028 <span class="comment"> \brief Memory Management Functions.</span>
<a name="l00029"></a>00029 <span class="comment"></span>
<a name="l00030"></a>00030 <span class="comment"> This module provides facilities for managing memory.</span>
<a name="l00031"></a>00031 <span class="comment"></span>
<a name="l00032"></a>00032 <span class="comment"> There is no need to check the returned values from any of these</span>
<a name="l00033"></a>00033 <span class="comment"> functions. Any memory allocation failure is considered fatal and the</span>
<a name="l00034"></a>00034 <span class="comment"> program is terminated.</span>
<a name="l00035"></a>00035 <span class="comment"></span>
<a name="l00036"></a>00036 <span class="comment"> We want to wrap all functions that allocate memory. This way we can</span>
<a name="l00037"></a>00037 <span class="comment"> add secret code to track memory usage and debug memory leaks if we </span>
<a name="l00038"></a>00038 <span class="comment"> want. Right now, I don't want to ;). */</span>
<a name="l00039"></a>00039
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00042"></a>00042
<a name="l00043"></a>00043 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00045"></a>00045
<a name="l00046"></a>00046 <span class="comment">/* These macros are only here for documentation purposes. */</span>
<a name="l00047"></a>00047
<a name="l00048"></a>00048 <span class="preprocessor">#if MACRO_DOCUMENTATION</span>
<a name="l00049"></a>00049 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00050"></a>00050 <span class="comment">/** \brief Macro for allocating memory.</span>
<a name="l00051"></a>00051 <span class="comment"> \param type The C type of the memory to allocate.</span>
<a name="l00052"></a>00052 <span class="comment"> \param count Allocate enough memory hold count types.</span>
<a name="l00053"></a>00053 <span class="comment"></span>
<a name="l00054"></a>00054 <span class="comment"> This macro is just a wrapper for avr_malloc() and should be used to avoid</span>
<a name="l00055"></a>00055 <span class="comment"> the repetitive task of casting the returned pointer. */</span>
<a name="l00056"></a>00056
<a name="l00057"></a><a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578">00057</a> <span class="preprocessor">#define avr_new(type, count) \</span>
<a name="l00058"></a>00058 <span class="preprocessor"> ((type *) avr_malloc ((unsigned) sizeof (type) * (count)))</span>
<a name="l00059"></a>00059 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00060"></a>00060 <span class="comment">/** \brief Macro for allocating memory and initializing it to zero.</span>
<a name="l00061"></a>00061 <span class="comment"> \param type The C type of the memory to allocate.</span>
<a name="l00062"></a>00062 <span class="comment"> \param count Allocate enough memory hold count types.</span>
<a name="l00063"></a>00063 <span class="comment"></span>
<a name="l00064"></a>00064 <span class="comment"> This macro is just a wrapper for avr_malloc0() and should be used to avoid</span>
<a name="l00065"></a>00065 <span class="comment"> the repetitive task of casting the returned pointer. */</span>
<a name="l00066"></a>00066
<a name="l00067"></a><a class="code" href="avrmalloc_8c.html#ac6d810b48b67b90412badbd4b71f4e3">00067</a> <span class="preprocessor">#define avr_new0(type, count) \</span>
<a name="l00068"></a>00068 <span class="preprocessor"> ((type *) avr_malloc0 ((unsigned) sizeof (type) * (count)))</span>
<a name="l00069"></a>00069 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00070"></a>00070 <span class="comment">/** \brief Macro for allocating memory.</span>
<a name="l00071"></a>00071 <span class="comment"> \param type The C type of the memory to allocate.</span>
<a name="l00072"></a>00072 <span class="comment"> \param mem Pointer to existing memory.</span>
<a name="l00073"></a>00073 <span class="comment"> \param count Allocate enough memory hold count types.</span>
<a name="l00074"></a>00074 <span class="comment"></span>
<a name="l00075"></a>00075 <span class="comment"> This macro is just a wrapper for avr_malloc() and should be used to avoid</span>
<a name="l00076"></a>00076 <span class="comment"> the repetitive task of casting the returned pointer. */</span>
<a name="l00077"></a>00077
<a name="l00078"></a><a class="code" href="avrmalloc_8c.html#2bff90bec7ab1eafa9e1a51d618446e9">00078</a> <span class="preprocessor">#define avr_renew(type, mem, count) \</span>
<a name="l00079"></a>00079 <span class="preprocessor"> ((type *) avr_realloc (mem, (unsigned) sizeof (type) * (count)))</span>
<a name="l00080"></a>00080 <span class="preprocessor"></span>
<a name="l00081"></a>00081 <span class="preprocessor">#endif </span><span class="comment">/* MACRO_DOCUMENTATION */</span>
<a name="l00082"></a>00082 <span class="comment"></span>
<a name="l00083"></a>00083 <span class="comment">/** \brief Allocate memory and initialize to zero.</span>
<a name="l00084"></a>00084 <span class="comment"></span>
<a name="l00085"></a>00085 <span class="comment"> Use the avr_new() macro instead of this function.</span>
<a name="l00086"></a>00086 <span class="comment"></span>
<a name="l00087"></a>00087 <span class="comment"> There is no need to check the returned value, since this function will</span>
<a name="l00088"></a>00088 <span class="comment"> terminate the program if the memory allocation fails.</span>
<a name="l00089"></a>00089 <span class="comment"></span>
<a name="l00090"></a>00090 <span class="comment"> No memory is allocated if passed a size of zero. */</span>
<a name="l00091"></a>00091
<a name="l00092"></a>00092 <span class="keywordtype">void</span> *
<a name="l00093"></a><a class="code" href="avrmalloc_8c.html#26b696030eced4eab8f5ec6cf2fb5781">00093</a> <a class="code" href="avrmalloc_8c.html#26b696030eced4eab8f5ec6cf2fb5781" title="Allocate memory and initialize to zero.">avr_malloc</a> (<span class="keywordtype">size_t</span> size)
<a name="l00094"></a>00094 {
<a name="l00095"></a>00095 <span class="keywordflow">if</span> (size)
<a name="l00096"></a>00096 {
<a name="l00097"></a>00097 <span class="keywordtype">void</span> *ptr;
<a name="l00098"></a>00098 ptr = malloc (size);
<a name="l00099"></a>00099 <span class="keywordflow">if</span> (ptr)
<a name="l00100"></a>00100 <span class="keywordflow">return</span> ptr;
<a name="l00101"></a>00101
<a name="l00102"></a>00102 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"malloc failed"</span>);
<a name="l00103"></a>00103 }
<a name="l00104"></a>00104 <span class="keywordflow">return</span> NULL;
<a name="l00105"></a>00105 }
<a name="l00106"></a>00106 <span class="comment"></span>
<a name="l00107"></a>00107 <span class="comment">/** \brief Allocate memory and initialize to zero.</span>
<a name="l00108"></a>00108 <span class="comment"></span>
<a name="l00109"></a>00109 <span class="comment"> Use the avr_new0() macro instead of this function.</span>
<a name="l00110"></a>00110 <span class="comment"></span>
<a name="l00111"></a>00111 <span class="comment"> There is no need to check the returned value, since this function will</span>
<a name="l00112"></a>00112 <span class="comment"> terminate the program if the memory allocation fails.</span>
<a name="l00113"></a>00113 <span class="comment"></span>
<a name="l00114"></a>00114 <span class="comment"> No memory is allocated if passed a size of zero. */</span>
<a name="l00115"></a>00115
<a name="l00116"></a>00116 <span class="keywordtype">void</span> *
<a name="l00117"></a><a class="code" href="avrmalloc_8c.html#4726a1eed41cbd3b6df7e5f035812683">00117</a> <a class="code" href="avrmalloc_8c.html#4726a1eed41cbd3b6df7e5f035812683" title="Allocate memory and initialize to zero.">avr_malloc0</a> (<span class="keywordtype">size_t</span> size)
<a name="l00118"></a>00118 {
<a name="l00119"></a>00119 <span class="keywordflow">if</span> (size)
<a name="l00120"></a>00120 {
<a name="l00121"></a>00121 <span class="keywordtype">void</span> *ptr;
<a name="l00122"></a>00122 ptr = calloc (1, size);
<a name="l00123"></a>00123 <span class="keywordflow">if</span> (ptr)
<a name="l00124"></a>00124 <span class="keywordflow">return</span> ptr;
<a name="l00125"></a>00125
<a name="l00126"></a>00126 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"malloc0 failed"</span>);
<a name="l00127"></a>00127 }
<a name="l00128"></a>00128 <span class="keywordflow">return</span> NULL;
<a name="l00129"></a>00129 }
<a name="l00130"></a>00130 <span class="comment"></span>
<a name="l00131"></a>00131 <span class="comment">/** \brief Wrapper for realloc().</span>
<a name="l00132"></a>00132 <span class="comment">x</span>
<a name="l00133"></a>00133 <span class="comment"> Resizes and possibly allocates more memory for an existing memory block.</span>
<a name="l00134"></a>00134 <span class="comment"></span>
<a name="l00135"></a>00135 <span class="comment"> Use the avr_renew() macro instead of this function.</span>
<a name="l00136"></a>00136 <span class="comment"></span>
<a name="l00137"></a>00137 <span class="comment"> There is no need to check the returned value, since this function will</span>
<a name="l00138"></a>00138 <span class="comment"> terminate the program if the memory allocation fails.</span>
<a name="l00139"></a>00139 <span class="comment"></span>
<a name="l00140"></a>00140 <span class="comment"> No memory is allocated if passed a size of zero. */</span>
<a name="l00141"></a>00141
<a name="l00142"></a>00142 <span class="keywordtype">void</span> *
<a name="l00143"></a><a class="code" href="avrmalloc_8c.html#258e72f96d28a713d6f0d7d4e4e37d26">00143</a> <a class="code" href="avrmalloc_8c.html#258e72f96d28a713d6f0d7d4e4e37d26" title="Wrapper for realloc(). x Resizes and possibly allocates more memory for an existing...">avr_realloc</a> (<span class="keywordtype">void</span> *ptr, <span class="keywordtype">size_t</span> size)
<a name="l00144"></a>00144 {
<a name="l00145"></a>00145 <span class="keywordflow">if</span> (size)
<a name="l00146"></a>00146 {
<a name="l00147"></a>00147 ptr = realloc (ptr, size);
<a name="l00148"></a>00148 <span class="keywordflow">if</span> (ptr)
<a name="l00149"></a>00149 <span class="keywordflow">return</span> ptr;
<a name="l00150"></a>00150
<a name="l00151"></a>00151 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"realloc failed\n"</span>);
<a name="l00152"></a>00152 }
<a name="l00153"></a>00153 <span class="keywordflow">return</span> NULL;
<a name="l00154"></a>00154 }
<a name="l00155"></a>00155 <span class="comment"></span>
<a name="l00156"></a>00156 <span class="comment">/** \brief Wrapper for strdup().</span>
<a name="l00157"></a>00157 <span class="comment"></span>
<a name="l00158"></a>00158 <span class="comment"> Returns a copy of the passed in string. The returned copy must be</span>
<a name="l00159"></a>00159 <span class="comment"> free'd.</span>
<a name="l00160"></a>00160 <span class="comment"></span>
<a name="l00161"></a>00161 <span class="comment"> There is no need to check the returned value, since this function will</span>
<a name="l00162"></a>00162 <span class="comment"> terminate the program if the memory allocation fails.</span>
<a name="l00163"></a>00163 <span class="comment"></span>
<a name="l00164"></a>00164 <span class="comment"> It is safe to pass a NULL pointer. No memory is allocated if a NULL is</span>
<a name="l00165"></a>00165 <span class="comment"> passed. */</span>
<a name="l00166"></a>00166
<a name="l00167"></a>00167 <span class="keywordtype">char</span> *
<a name="l00168"></a><a class="code" href="avrmalloc_8c.html#2af0d2ad3de670228794080e914120ea">00168</a> <a class="code" href="avrmalloc_8c.html#2af0d2ad3de670228794080e914120ea" title="Wrapper for strdup().">avr_strdup</a> (<span class="keyword">const</span> <span class="keywordtype">char</span> *s)
<a name="l00169"></a>00169 {
<a name="l00170"></a>00170 <span class="keywordflow">if</span> (s)
<a name="l00171"></a>00171 {
<a name="l00172"></a>00172 <span class="keywordtype">char</span> *ptr;
<a name="l00173"></a>00173 ptr = strdup (s);
<a name="l00174"></a>00174 <span class="keywordflow">if</span> (ptr)
<a name="l00175"></a>00175 <span class="keywordflow">return</span> ptr;
<a name="l00176"></a>00176
<a name="l00177"></a>00177 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"strdup failed"</span>);
<a name="l00178"></a>00178 }
<a name="l00179"></a>00179 <span class="keywordflow">return</span> NULL;
<a name="l00180"></a>00180 }
<a name="l00181"></a>00181 <span class="comment"></span>
<a name="l00182"></a>00182 <span class="comment">/** \brief Free malloc'd memory.</span>
<a name="l00183"></a>00183 <span class="comment"></span>
<a name="l00184"></a>00184 <span class="comment"> It is safe to pass a null pointer to this function. */</span>
<a name="l00185"></a>00185
<a name="l00186"></a>00186 <span class="keywordtype">void</span>
<a name="l00187"></a><a class="code" href="avrmalloc_8c.html#082a9d6d40f5e8bad64441ad950ec12c">00187</a> <a class="code" href="avrmalloc_8c.html#082a9d6d40f5e8bad64441ad950ec12c" title="Free malloc&amp;#39;d memory.">avr_free</a> (<span class="keywordtype">void</span> *ptr)
<a name="l00188"></a>00188 {
<a name="l00189"></a>00189 <span class="keywordflow">if</span> (ptr)
<a name="l00190"></a>00190 free (ptr);
<a name="l00191"></a>00191 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,315 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>avrmalloc.c File Reference</h1>Memory Management Functions. <a href="#_details">More...</a>
<p>
<p>
<a href="avrmalloc_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578">avr_new</a>(type, count)&nbsp;&nbsp;&nbsp;((type *) avr_malloc ((unsigned) sizeof (type) * (count)))</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrmalloc_8c.html#ac6d810b48b67b90412badbd4b71f4e3">avr_new0</a>(type, count)&nbsp;&nbsp;&nbsp;((type *) avr_malloc0 ((unsigned) sizeof (type) * (count)))</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">#define&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrmalloc_8c.html#2bff90bec7ab1eafa9e1a51d618446e9">avr_renew</a>(type, mem, count)&nbsp;&nbsp;&nbsp;((type *) avr_realloc (mem, (unsigned) sizeof (type) * (count)))</td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrmalloc_8c.html#26b696030eced4eab8f5ec6cf2fb5781">avr_malloc</a> (size_t size)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrmalloc_8c.html#4726a1eed41cbd3b6df7e5f035812683">avr_malloc0</a> (size_t size)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrmalloc_8c.html#258e72f96d28a713d6f0d7d4e4e37d26">avr_realloc</a> (void *ptr, size_t size)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrmalloc_8c.html#2af0d2ad3de670228794080e914120ea">avr_strdup</a> (const char *s)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="avrmalloc_8c.html#082a9d6d40f5e8bad64441ad950ec12c">avr_free</a> (void *ptr)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Memory Management Functions.
<p>
This module provides facilities for managing memory.<p>
There is no need to check the returned values from any of these functions. Any memory allocation failure is considered fatal and the program is terminated.<p>
We want to wrap all functions that allocate memory. This way we can add secret code to track memory usage and debug memory leaks if we want. Right now, I don't want to ;).
<p>Definition in file <a class="el" href="avrmalloc_8c-source.html">avrmalloc.c</a>.</p>
<hr><h2>Define Documentation</h2>
<a class="anchor" name="a543f348351cdcaebdd8947d1a591578"></a><!-- doxytag: member="avrmalloc.c::avr_new" ref="a543f348351cdcaebdd8947d1a591578" args="(type, count)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define avr_new </td>
<td>(</td>
<td class="paramtype">type, <tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">count&nbsp;</td>
<td class="paramname"> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%">&nbsp;&nbsp;&nbsp;((type *) avr_malloc ((unsigned) sizeof (type) * (count)))</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Macro for allocating memory.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>type</em>&nbsp;</td><td>The C type of the memory to allocate. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>count</em>&nbsp;</td><td>Allocate enough memory hold count types.</td></tr>
</table>
</dl>
This macro is just a wrapper for <a class="el" href="avrmalloc_8c.html#26b696030eced4eab8f5ec6cf2fb5781" title="Allocate memory and initialize to zero.">avr_malloc()</a> and should be used to avoid the repetitive task of casting the returned pointer.
<p>Definition at line <a class="el" href="avrmalloc_8c-source.html#l00057">57</a> of file <a class="el" href="avrmalloc_8c-source.html">avrmalloc.c</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l00355">avr_core_new()</a>, <a class="el" href="avrclass_8c-source.html#l00046">class_new()</a>, <a class="el" href="flash_8c-source.html#l00117">flash_new()</a>, <a class="el" href="stack_8c-source.html#l00163">hwstack_new()</a>, <a class="el" href="stack_8c-source.html#l00388">memstack_new()</a>, and <a class="el" href="stack_8c-source.html#l00082">stack_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="ac6d810b48b67b90412badbd4b71f4e3"></a><!-- doxytag: member="avrmalloc.c::avr_new0" ref="ac6d810b48b67b90412badbd4b71f4e3" args="(type, count)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define avr_new0 </td>
<td>(</td>
<td class="paramtype">type, <tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">count&nbsp;</td>
<td class="paramname"> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%">&nbsp;&nbsp;&nbsp;((type *) avr_malloc0 ((unsigned) sizeof (type) * (count)))</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Macro for allocating memory and initializing it to zero.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>type</em>&nbsp;</td><td>The C type of the memory to allocate. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>count</em>&nbsp;</td><td>Allocate enough memory hold count types.</td></tr>
</table>
</dl>
This macro is just a wrapper for <a class="el" href="avrmalloc_8c.html#4726a1eed41cbd3b6df7e5f035812683" title="Allocate memory and initialize to zero.">avr_malloc0()</a> and should be used to avoid the repetitive task of casting the returned pointer.
<p>Definition at line <a class="el" href="avrmalloc_8c-source.html#l00067">67</a> of file <a class="el" href="avrmalloc_8c-source.html">avrmalloc.c</a>.</p>
<p>Referenced by <a class="el" href="decoder_8c-source.html#l03869">decode_init_lookup_table()</a>, <a class="el" href="display_8c-source.html#l00220">display_send_msg()</a>, <a class="el" href="stack_8c-source.html#l00177">hwstack_construct()</a>, <a class="el" href="memory_8c-source.html#l00080">mem_construct()</a>, <a class="el" href="memory_8c-source.html#l00066">mem_new()</a>, and <a class="el" href="device_8c-source.html#l00062">vdev_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="2bff90bec7ab1eafa9e1a51d618446e9"></a><!-- doxytag: member="avrmalloc.c::avr_renew" ref="2bff90bec7ab1eafa9e1a51d618446e9" args="(type, mem, count)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define avr_renew </td>
<td>(</td>
<td class="paramtype">type, <tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">mem, <tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">count&nbsp;</td>
<td class="paramname"> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%">&nbsp;&nbsp;&nbsp;((type *) avr_realloc (mem, (unsigned) sizeof (type) * (count)))</td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Macro for allocating memory.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>type</em>&nbsp;</td><td>The C type of the memory to allocate. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>mem</em>&nbsp;</td><td>Pointer to existing memory. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>count</em>&nbsp;</td><td>Allocate enough memory hold count types.</td></tr>
</table>
</dl>
This macro is just a wrapper for <a class="el" href="avrmalloc_8c.html#26b696030eced4eab8f5ec6cf2fb5781" title="Allocate memory and initialize to zero.">avr_malloc()</a> and should be used to avoid the repetitive task of casting the returned pointer.
<p>Definition at line <a class="el" href="avrmalloc_8c-source.html#l00078">78</a> of file <a class="el" href="avrmalloc_8c-source.html">avrmalloc.c</a>.</p>
</div>
</div><p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="26b696030eced4eab8f5ec6cf2fb5781"></a><!-- doxytag: member="avrmalloc.c::avr_malloc" ref="26b696030eced4eab8f5ec6cf2fb5781" args="(size_t size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void* avr_malloc </td>
<td>(</td>
<td class="paramtype">size_t&nbsp;</td>
<td class="paramname"> <em>size</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate memory and initialize to zero.
<p>
Use the <a class="el" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new()</a> macro instead of this function.<p>
There is no need to check the returned value, since this function will terminate the program if the memory allocation fails.<p>
No memory is allocated if passed a size of zero.
<p>Definition at line <a class="el" href="avrmalloc_8c-source.html#l00093">93</a> of file <a class="el" href="avrmalloc_8c-source.html">avrmalloc.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
</div>
</div><p>
<a class="anchor" name="4726a1eed41cbd3b6df7e5f035812683"></a><!-- doxytag: member="avrmalloc.c::avr_malloc0" ref="4726a1eed41cbd3b6df7e5f035812683" args="(size_t size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void* avr_malloc0 </td>
<td>(</td>
<td class="paramtype">size_t&nbsp;</td>
<td class="paramname"> <em>size</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate memory and initialize to zero.
<p>
Use the <a class="el" href="avrmalloc_8c.html#ac6d810b48b67b90412badbd4b71f4e3" title="Macro for allocating memory and initializing it to zero.">avr_new0()</a> macro instead of this function.<p>
There is no need to check the returned value, since this function will terminate the program if the memory allocation fails.<p>
No memory is allocated if passed a size of zero.
<p>Definition at line <a class="el" href="avrmalloc_8c-source.html#l00117">117</a> of file <a class="el" href="avrmalloc_8c-source.html">avrmalloc.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
</div>
</div><p>
<a class="anchor" name="258e72f96d28a713d6f0d7d4e4e37d26"></a><!-- doxytag: member="avrmalloc.c::avr_realloc" ref="258e72f96d28a713d6f0d7d4e4e37d26" args="(void *ptr, size_t size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void* avr_realloc </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>ptr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">size_t&nbsp;</td>
<td class="paramname"> <em>size</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Wrapper for realloc(). x Resizes and possibly allocates more memory for an existing memory block.
<p>
Use the <a class="el" href="avrmalloc_8c.html#2bff90bec7ab1eafa9e1a51d618446e9" title="Macro for allocating memory.">avr_renew()</a> macro instead of this function.<p>
There is no need to check the returned value, since this function will terminate the program if the memory allocation fails.<p>
No memory is allocated if passed a size of zero.
<p>Definition at line <a class="el" href="avrmalloc_8c-source.html#l00143">143</a> of file <a class="el" href="avrmalloc_8c-source.html">avrmalloc.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
</div>
</div><p>
<a class="anchor" name="2af0d2ad3de670228794080e914120ea"></a><!-- doxytag: member="avrmalloc.c::avr_strdup" ref="2af0d2ad3de670228794080e914120ea" args="(const char *s)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">char* avr_strdup </td>
<td>(</td>
<td class="paramtype">const char *&nbsp;</td>
<td class="paramname"> <em>s</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Wrapper for strdup().
<p>
Returns a copy of the passed in string. The returned copy must be free'd.<p>
There is no need to check the returned value, since this function will terminate the program if the memory allocation fails.<p>
It is safe to pass a NULL pointer. No memory is allocated if a NULL is passed.
<p>Definition at line <a class="el" href="avrmalloc_8c-source.html#l00168">168</a> of file <a class="el" href="avrmalloc_8c-source.html">avrmalloc.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
</div>
</div><p>
<a class="anchor" name="082a9d6d40f5e8bad64441ad950ec12c"></a><!-- doxytag: member="avrmalloc.c::avr_free" ref="082a9d6d40f5e8bad64441ad950ec12c" args="(void *ptr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void avr_free </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>ptr</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Free malloc'd memory.
<p>
It is safe to pass a null pointer to this function.
<p>Definition at line <a class="el" href="avrmalloc_8c-source.html#l00187">187</a> of file <a class="el" href="avrmalloc_8c-source.html">avrmalloc.c</a>.</p>
<p>Referenced by <a class="el" href="avrclass_8c-source.html#l00078">class_destroy()</a>, <a class="el" href="display_8c-source.html#l00220">display_send_msg()</a>, <a class="el" href="stack_8c-source.html#l00191">hwstack_destroy()</a>, and <a class="el" href="memory_8c-source.html#l00099">mem_destroy()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,30 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1><a class="anchor" name="break_watch_pts">Breakpoints and Watchpoints </a></h1> <p>
Using gdb, it is possible to set breakpoints.<p>
Watch points are not currently implemented.<p>
<b>This</b> <b>is</b> <b>only</b> <b>an</b> <b>idea</b> <b>right</b> <b>now:</b> The way breakpoints are implemented within simulavr, it would be possible at init time to read a file containing breakpoint information. Then, as breakpoints are reached, have something happen which allows the user to check the state of the program. Anyone interested in implementing this, please step forward. </div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,141 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>callback.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: callback.c,v 1.5 2003/12/01 09:10:14 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00030"></a>00030
<a name="l00031"></a>00031 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include "utils.h"</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include "callback.h"</span>
<a name="l00036"></a>00036
<a name="l00037"></a>00037 <span class="comment">/****************************************************************************\</span>
<a name="l00038"></a>00038 <span class="comment"> *</span>
<a name="l00039"></a>00039 <span class="comment"> * Clock Call Back methods</span>
<a name="l00040"></a>00040 <span class="comment"> *</span>
<a name="l00041"></a>00041 <span class="comment">\****************************************************************************/</span>
<a name="l00042"></a>00042
<a name="l00043"></a>00043 <span class="preprocessor">#ifndef DOXYGEN </span><span class="comment">/* don't expose to doxygen */</span>
<a name="l00044"></a>00044
<a name="l00045"></a>00045 <span class="keyword">struct </span>_CallBack
<a name="l00046"></a>00046 {
<a name="l00047"></a>00047 AvrClass parent;
<a name="l00048"></a>00048 CallBack_FP func; <span class="comment">/* the callback function */</span>
<a name="l00049"></a>00049 AvrClass *data; <span class="comment">/* user data to be passed to callback</span>
<a name="l00050"></a>00050 <span class="comment"> function */</span>
<a name="l00051"></a>00051 };
<a name="l00052"></a>00052
<a name="l00053"></a>00053 <span class="preprocessor">#endif </span><span class="comment">/* DOXYGEN */</span>
<a name="l00054"></a>00054
<a name="l00055"></a>00055 CallBack *
<a name="l00056"></a>00056 callback_new (CallBack_FP func, AvrClass *data)
<a name="l00057"></a>00057 {
<a name="l00058"></a>00058 CallBack *cb;
<a name="l00059"></a>00059
<a name="l00060"></a>00060 cb = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (CallBack, 1);
<a name="l00061"></a>00061 callback_construct (cb, func, data);
<a name="l00062"></a>00062 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)cb, callback_destroy);
<a name="l00063"></a>00063
<a name="l00064"></a>00064 <span class="keywordflow">return</span> cb;
<a name="l00065"></a>00065 }
<a name="l00066"></a>00066
<a name="l00067"></a>00067 <span class="keywordtype">void</span>
<a name="l00068"></a>00068 callback_construct (CallBack *cb, CallBack_FP func, AvrClass *data)
<a name="l00069"></a>00069 {
<a name="l00070"></a>00070 <span class="keywordflow">if</span> (cb == NULL)
<a name="l00071"></a>00071 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00072"></a>00072
<a name="l00073"></a>00073 <a class="code" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e" title="Initializes the AvrClass data structure.">class_construct</a> ((AvrClass *)cb);
<a name="l00074"></a>00074
<a name="l00075"></a>00075 cb-&gt;func = func;
<a name="l00076"></a>00076
<a name="l00077"></a>00077 cb-&gt;data = data;
<a name="l00078"></a>00078
<a name="l00079"></a>00079 <span class="keywordflow">if</span> (data)
<a name="l00080"></a>00080 <a class="code" href="avrclass_8c.html#ff0f5b14bf2740f208041d515f3ba93f" title="Increments the reference count for the klass object.">class_ref</a> (data);
<a name="l00081"></a>00081 }
<a name="l00082"></a>00082
<a name="l00083"></a>00083 <span class="keywordtype">void</span>
<a name="l00084"></a>00084 callback_destroy (<span class="keywordtype">void</span> *cb)
<a name="l00085"></a>00085 {
<a name="l00086"></a>00086 CallBack *_cb = (CallBack *)cb;
<a name="l00087"></a>00087
<a name="l00088"></a>00088 <span class="keywordflow">if</span> (cb == NULL)
<a name="l00089"></a>00089 <span class="keywordflow">return</span>;
<a name="l00090"></a>00090
<a name="l00091"></a>00091 <span class="keywordflow">if</span> (_cb-&gt;data)
<a name="l00092"></a>00092 <a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a> (_cb-&gt;data);
<a name="l00093"></a>00093
<a name="l00094"></a>00094 <a class="code" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5" title="Releases resources allocated by class&amp;#39;s &amp;lt;klass&amp;gt;_new() function.">class_destroy</a> (cb);
<a name="l00095"></a>00095 }
<a name="l00096"></a>00096
<a name="l00097"></a>00097 DList *
<a name="l00098"></a>00098 callback_list_add (DList *head, CallBack *cb)
<a name="l00099"></a>00099 {
<a name="l00100"></a>00100 <span class="keywordflow">return</span> <a class="code" href="utils_8c.html#2f451be088e616a1c94508c1312e99ed" title="Add a new node to the end of the list.">dlist_add</a> (head, (AvrClass *)cb, NULL);
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102
<a name="l00103"></a>00103 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00104"></a>00104 callback_execute (AvrClass *data, <span class="keywordtype">void</span> *user_data)
<a name="l00105"></a>00105 {
<a name="l00106"></a>00106 CallBack *cb = (CallBack *)data;
<a name="l00107"></a>00107 uint64_t time = *(uint64_t *) user_data;
<a name="l00108"></a>00108
<a name="l00109"></a>00109 <span class="keywordflow">return</span> cb-&gt;func (time, cb-&gt;data);
<a name="l00110"></a>00110 }
<a name="l00111"></a>00111
<a name="l00112"></a>00112 DList *
<a name="l00113"></a>00113 callback_list_execute_all (DList *head, uint64_t time)
<a name="l00114"></a>00114 {
<a name="l00115"></a>00115 <span class="keywordflow">return</span> <a class="code" href="utils_8c.html#bbba7ec7eefce4bdb4543e1096021186" title="Iterate over all elements of the list.">dlist_iterator</a> (head, callback_execute, &amp;time);
<a name="l00116"></a>00116 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,201 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>decoder.c File Reference</h1>Module for handling opcode decoding. <a href="#_details">More...</a>
<p>
<p>
<a href="decoder_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Enumerations</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">enum &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d">decoder_operand_masks</a> { <br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d72567b93ba2b0b220237be1b612453e9">mask_Rd_2</a> = 0x0030,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4db291bde5fc7c589395619ccfdb0cab22">mask_Rd_3</a> = 0x0070,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4db65c1df2ad87168b0828ff19b568794f">mask_Rd_4</a> = 0x00f0,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d03e9222f48dc9c72606a63f931cdb84d">mask_Rd_5</a> = 0x01f0,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4da42ff712d0e38f8a725730497ef18f10">mask_Rr_3</a> = 0x0007,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4dbf39793679b207f9bf5ec218812b9584">mask_Rr_4</a> = 0x000f,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d6baa83403f524cd30eb34a8e6e3d8891">mask_Rr_5</a> = 0x020f,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4daa83eaace5a8e5c10585e42b07cdc735">mask_K_8</a> = 0x0F0F,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d646704ce73041c50e5d60d1c91f46b7b">mask_K_6</a> = 0x00CF,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d8d97911f0bb89617bed0886469c6d8a0">mask_k_7</a> = 0x03F8,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4dd9f0609ab28e257ca40b34ea153bd105">mask_k_12</a> = 0x0FFF,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d6da049a50243439217ed820e5523785e">mask_k_22</a> = 0x01F1,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4db93caa109e70b4befe8088f5aec8c676">mask_reg_bit</a> = 0x0007,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d98e3e7dd33e97c078a175a254f490130">mask_sreg_bit</a> = 0x0070,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d6a0f87ce56ad1f4962da82398dae660c">mask_q_displ</a> = 0x2C07,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4dd89aab6be79b8d65afd2254959752734">mask_A_5</a> = 0x00F8,
<br>
&nbsp;&nbsp;<a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d523800aea8f896ae36296348874f47d0">mask_A_6</a> = 0x060F
<br>
}</td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="dff244ccc8e68d7e71a40b85586190d6"></a><!-- doxytag: member="decoder.c::avr_op_UNKNOWN" ref="dff244ccc8e68d7e71a40b85586190d6" args="(AvrCore *core, uint16_t opcode, unsigned int arg1, unsigned int arg2)" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><b>avr_op_UNKNOWN</b> (AvrCore *core, uint16_t opcode, unsigned int arg1, unsigned int arg2)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="decoder_8c.html#e3a0b1d94b75719be5f23e9fb9b896dc">decode_init_lookup_table</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct opcode_info *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="decoder_8c.html#53bbe21cbd08336a39da9fbe4e9cb09e">decode_opcode</a> (uint16_t opcode)</td></tr>
<tr><td colspan="2"><br><h2>Variables</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="12b1baccb5dbbe19af48a9a4d56b3a59"></a><!-- doxytag: member="decoder.c::global_opcode_lookup_table" ref="12b1baccb5dbbe19af48a9a4d56b3a59" args="" -->
struct opcode_info *&nbsp;</td><td class="memItemRight" valign="bottom"><b>global_opcode_lookup_table</b></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Module for handling opcode decoding.
<p>
The heart of the instruction decoder is the <a class="el" href="decoder_8c.html#53bbe21cbd08336a39da9fbe4e9cb09e" title="Decode an opcode into the opcode handler function.">decode_opcode()</a> function.<p>
The <a class="el" href="decoder_8c.html#53bbe21cbd08336a39da9fbe4e9cb09e" title="Decode an opcode into the opcode handler function.">decode_opcode()</a> function examines the given opcode to determine which instruction applies and returns a pointer to a function to handler performing the instruction's operation. If the given opcode does not map to an instruction handler, NULL is returned.<p>
Nearly every instruction in Atmel's Instruction Set Data Sheet will have a handler function defined. Each handler will perform all the operations described in the data sheet for a given instruction. A few instructions have synonyms. For example, CBR is a synonym for ANDI.<p>
This should all be fairly straight forward.
<p>Definition in file <a class="el" href="decoder_8c-source.html">decoder.c</a>.</p>
<hr><h2>Enumeration Type Documentation</h2>
<a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4d"></a><!-- doxytag: member="decoder.c::decoder_operand_masks" ref="b6fd98079c0b0b68051c030c2abdca4d" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">enum <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d">decoder_operand_masks</a> </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Masks to help extracting information from opcodes.
<p>
<dl compact><dt><b>Enumerator: </b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4d72567b93ba2b0b220237be1b612453e9"></a><!-- doxytag: member="mask_Rd_2" ref="b6fd98079c0b0b68051c030c2abdca4d72567b93ba2b0b220237be1b612453e9" args="" -->mask_Rd_2</em>&nbsp;</td><td>
2 bit register id ( R24, R26, R28, R30 ) </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4db291bde5fc7c589395619ccfdb0cab22"></a><!-- doxytag: member="mask_Rd_3" ref="b6fd98079c0b0b68051c030c2abdca4db291bde5fc7c589395619ccfdb0cab22" args="" -->mask_Rd_3</em>&nbsp;</td><td>
3 bit register id ( R16 - R23 ) </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4db65c1df2ad87168b0828ff19b568794f"></a><!-- doxytag: member="mask_Rd_4" ref="b6fd98079c0b0b68051c030c2abdca4db65c1df2ad87168b0828ff19b568794f" args="" -->mask_Rd_4</em>&nbsp;</td><td>
4 bit register id ( R16 - R31 ) </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4d03e9222f48dc9c72606a63f931cdb84d"></a><!-- doxytag: member="mask_Rd_5" ref="b6fd98079c0b0b68051c030c2abdca4d03e9222f48dc9c72606a63f931cdb84d" args="" -->mask_Rd_5</em>&nbsp;</td><td>
5 bit register id ( R00 - R31 ) </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4da42ff712d0e38f8a725730497ef18f10"></a><!-- doxytag: member="mask_Rr_3" ref="b6fd98079c0b0b68051c030c2abdca4da42ff712d0e38f8a725730497ef18f10" args="" -->mask_Rr_3</em>&nbsp;</td><td>
3 bit register id ( R16 - R23 ) </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4dbf39793679b207f9bf5ec218812b9584"></a><!-- doxytag: member="mask_Rr_4" ref="b6fd98079c0b0b68051c030c2abdca4dbf39793679b207f9bf5ec218812b9584" args="" -->mask_Rr_4</em>&nbsp;</td><td>
4 bit register id ( R16 - R31 ) </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4d6baa83403f524cd30eb34a8e6e3d8891"></a><!-- doxytag: member="mask_Rr_5" ref="b6fd98079c0b0b68051c030c2abdca4d6baa83403f524cd30eb34a8e6e3d8891" args="" -->mask_Rr_5</em>&nbsp;</td><td>
5 bit register id ( R00 - R31 ) </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4daa83eaace5a8e5c10585e42b07cdc735"></a><!-- doxytag: member="mask_K_8" ref="b6fd98079c0b0b68051c030c2abdca4daa83eaace5a8e5c10585e42b07cdc735" args="" -->mask_K_8</em>&nbsp;</td><td>
for 8 bit constant </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4d646704ce73041c50e5d60d1c91f46b7b"></a><!-- doxytag: member="mask_K_6" ref="b6fd98079c0b0b68051c030c2abdca4d646704ce73041c50e5d60d1c91f46b7b" args="" -->mask_K_6</em>&nbsp;</td><td>
for 6 bit constant </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4d8d97911f0bb89617bed0886469c6d8a0"></a><!-- doxytag: member="mask_k_7" ref="b6fd98079c0b0b68051c030c2abdca4d8d97911f0bb89617bed0886469c6d8a0" args="" -->mask_k_7</em>&nbsp;</td><td>
for 7 bit relative address </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4dd9f0609ab28e257ca40b34ea153bd105"></a><!-- doxytag: member="mask_k_12" ref="b6fd98079c0b0b68051c030c2abdca4dd9f0609ab28e257ca40b34ea153bd105" args="" -->mask_k_12</em>&nbsp;</td><td>
for 12 bit relative address </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4d6da049a50243439217ed820e5523785e"></a><!-- doxytag: member="mask_k_22" ref="b6fd98079c0b0b68051c030c2abdca4d6da049a50243439217ed820e5523785e" args="" -->mask_k_22</em>&nbsp;</td><td>
for 22 bit absolute address </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4db93caa109e70b4befe8088f5aec8c676"></a><!-- doxytag: member="mask_reg_bit" ref="b6fd98079c0b0b68051c030c2abdca4db93caa109e70b4befe8088f5aec8c676" args="" -->mask_reg_bit</em>&nbsp;</td><td>
register bit select </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4d98e3e7dd33e97c078a175a254f490130"></a><!-- doxytag: member="mask_sreg_bit" ref="b6fd98079c0b0b68051c030c2abdca4d98e3e7dd33e97c078a175a254f490130" args="" -->mask_sreg_bit</em>&nbsp;</td><td>
status register bit select </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4d6a0f87ce56ad1f4962da82398dae660c"></a><!-- doxytag: member="mask_q_displ" ref="b6fd98079c0b0b68051c030c2abdca4d6a0f87ce56ad1f4962da82398dae660c" args="" -->mask_q_displ</em>&nbsp;</td><td>
address displacement (q) </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4dd89aab6be79b8d65afd2254959752734"></a><!-- doxytag: member="mask_A_5" ref="b6fd98079c0b0b68051c030c2abdca4dd89aab6be79b8d65afd2254959752734" args="" -->mask_A_5</em>&nbsp;</td><td>
5 bit register id ( R00 - R31 ) </td></tr>
<tr><td valign="top"><em><a class="anchor" name="b6fd98079c0b0b68051c030c2abdca4d523800aea8f896ae36296348874f47d0"></a><!-- doxytag: member="mask_A_6" ref="b6fd98079c0b0b68051c030c2abdca4d523800aea8f896ae36296348874f47d0" args="" -->mask_A_6</em>&nbsp;</td><td>
6 bit IO port id </td></tr>
</table>
</dl>
<p>Definition at line <a class="el" href="decoder_8c-source.html#l00077">77</a> of file <a class="el" href="decoder_8c-source.html">decoder.c</a>.</p>
</div>
</div><p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="e3a0b1d94b75719be5f23e9fb9b896dc"></a><!-- doxytag: member="decoder.c::decode_init_lookup_table" ref="e3a0b1d94b75719be5f23e9fb9b896dc" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void decode_init_lookup_table </td>
<td>(</td>
<td class="paramtype">void&nbsp;</td>
<td class="paramname"> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Initialize the decoder lookup table.
<p>
This is automatically called by avr_core_construct().<p>
It is safe to call this function many times, since if will only create the table the first time it is called.
<p>Definition at line <a class="el" href="decoder_8c-source.html#l03869">3869</a> of file <a class="el" href="decoder_8c-source.html">decoder.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00042">avr_message</a>, and <a class="el" href="avrmalloc_8c-source.html#l00067">avr_new0</a>.</p>
</div>
</div><p>
<a class="anchor" name="53bbe21cbd08336a39da9fbe4e9cb09e"></a><!-- doxytag: member="decoder.c::decode_opcode" ref="53bbe21cbd08336a39da9fbe4e9cb09e" args="(uint16_t opcode)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct opcode_info* decode_opcode </td>
<td>(</td>
<td class="paramtype">uint16_t&nbsp;</td>
<td class="paramname"> <em>opcode</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"><code> [read]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Decode an opcode into the opcode handler function.
<p>
Generates a warning and returns NULL if opcode is invalid.<p>
Returns a pointer to the function to handle the opcode.
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,31 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1><a class="anchor" name="deprecated">Deprecated List </a></h1><a class="anchor" name="_deprecated000001"></a> <dl>
<dt>Global <a class="el" href="memory_8c.html#502735c9e7d8045149e53f5cff95ee6f">mem_get_vdevice_by_name</a> </dt>
<dd></dd>
</dl>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,259 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>device.c</h1><a href="device_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: device.c,v 1.15 2004/01/30 07:09:56 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003, 2004 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include "utils.h"</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include "callback.h"</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include "op_names.h"</span>
<a name="l00038"></a>00038
<a name="l00039"></a>00039 <span class="preprocessor">#include "storage.h"</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include "flash.h"</span>
<a name="l00041"></a>00041
<a name="l00042"></a>00042 <span class="preprocessor">#include "vdevs.h"</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include "memory.h"</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include "stack.h"</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include "register.h"</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include "sram.h"</span>
<a name="l00047"></a>00047 <span class="preprocessor">#include "eeprom.h"</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include "timers.h"</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include "ports.h"</span>
<a name="l00050"></a>00050
<a name="l00051"></a>00051 <span class="preprocessor">#include "avrcore.h"</span>
<a name="l00052"></a>00052 <span class="comment"></span>
<a name="l00053"></a>00053 <span class="comment">/** \file device.c</span>
<a name="l00054"></a>00054 <span class="comment"> * \brief VDevice methods</span>
<a name="l00055"></a>00055 <span class="comment"> *</span>
<a name="l00056"></a>00056 <span class="comment"> * These functions are the base for all other devices</span>
<a name="l00057"></a>00057 <span class="comment"> * mapped into the device space.</span>
<a name="l00058"></a>00058 <span class="comment"> */</span>
<a name="l00059"></a>00059 <span class="comment"></span>
<a name="l00060"></a>00060 <span class="comment">/** \brief Create a new VDevice. */</span>
<a name="l00061"></a>00061 VDevice *
<a name="l00062"></a><a class="code" href="device_8c.html#134ea79c2ecf6f000d28d08b05ed40ca">00062</a> <a class="code" href="device_8c.html#134ea79c2ecf6f000d28d08b05ed40ca" title="Create a new VDevice.">vdev_new</a> (<span class="keywordtype">char</span> *name, VDevFP_Read rd, VDevFP_Write wr, VDevFP_Reset reset,
<a name="l00063"></a>00063 VDevFP_AddAddr add_addr)
<a name="l00064"></a>00064 {
<a name="l00065"></a>00065 VDevice *dev;
<a name="l00066"></a>00066
<a name="l00067"></a>00067 dev = <a class="code" href="avrmalloc_8c.html#ac6d810b48b67b90412badbd4b71f4e3" title="Macro for allocating memory and initializing it to zero.">avr_new0</a> (VDevice, 1);
<a name="l00068"></a>00068 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> (dev, rd, wr, reset, add_addr);
<a name="l00069"></a>00069 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)dev, <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a>);
<a name="l00070"></a>00070
<a name="l00071"></a>00071 <span class="keywordflow">return</span> dev;
<a name="l00072"></a>00072 }
<a name="l00073"></a>00073 <span class="comment"></span>
<a name="l00074"></a>00074 <span class="comment">/** \brief Default AddAddr method.</span>
<a name="l00075"></a>00075 <span class="comment"></span>
<a name="l00076"></a>00076 <span class="comment"> This generate a warning that the should let the developer know that the</span>
<a name="l00077"></a>00077 <span class="comment"> vdev needs to be updated. */</span>
<a name="l00078"></a>00078
<a name="l00079"></a>00079 <span class="keywordtype">void</span>
<a name="l00080"></a><a class="code" href="device_8c.html#5cebfd18a219807f27e4a3f38da4a5d0">00080</a> <a class="code" href="device_8c.html#5cebfd18a219807f27e4a3f38da4a5d0" title="Default AddAddr method.">vdev_def_AddAddr</a> (VDevice *dev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> related_addr,
<a name="l00081"></a>00081 <span class="keywordtype">void</span> *data)
<a name="l00082"></a>00082 {
<a name="l00083"></a>00083 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"Default AddAddr called [addr=0x%x; '%s']\n"</span>, addr, name);
<a name="l00084"></a>00084 }
<a name="l00085"></a>00085
<a name="l00086"></a>00086 <span class="comment"></span>
<a name="l00087"></a>00087 <span class="comment">/** \brief Constructor for a VDevice. */</span>
<a name="l00088"></a>00088 <span class="keywordtype">void</span>
<a name="l00089"></a><a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4">00089</a> <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> (VDevice *dev, VDevFP_Read rd, VDevFP_Write wr,
<a name="l00090"></a>00090 VDevFP_Reset reset, VDevFP_AddAddr add_addr)
<a name="l00091"></a>00091 {
<a name="l00092"></a>00092 <span class="keywordflow">if</span> (dev == NULL)
<a name="l00093"></a>00093 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00094"></a>00094
<a name="l00095"></a>00095 <a class="code" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e" title="Initializes the AvrClass data structure.">class_construct</a> ((AvrClass *)dev);
<a name="l00096"></a>00096
<a name="l00097"></a>00097 dev-&gt;read = rd;
<a name="l00098"></a>00098 dev-&gt;write = wr;
<a name="l00099"></a>00099 dev-&gt;reset = reset;
<a name="l00100"></a>00100 dev-&gt;add_addr = add_addr;
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102 <span class="comment"></span>
<a name="l00103"></a>00103 <span class="comment">/** \brief Destructor for a VDevice. */</span>
<a name="l00104"></a>00104 <span class="keywordtype">void</span>
<a name="l00105"></a><a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9">00105</a> <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (<span class="keywordtype">void</span> *dev)
<a name="l00106"></a>00106 {
<a name="l00107"></a>00107 <span class="keywordflow">if</span> (dev == NULL)
<a name="l00108"></a>00108 <span class="keywordflow">return</span>;
<a name="l00109"></a>00109
<a name="l00110"></a>00110 <a class="code" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5" title="Releases resources allocated by class&amp;#39;s &amp;lt;klass&amp;gt;_new() function.">class_destroy</a> (dev);
<a name="l00111"></a>00111 }
<a name="l00112"></a>00112
<a name="l00113"></a>00113 <span class="preprocessor">#if 0</span>
<a name="l00114"></a>00114 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00115"></a>00115 <span class="comment">/** \brief Compare the names of 2 devices</span>
<a name="l00116"></a>00116 <span class="comment"> * \param c1 The first device.</span>
<a name="l00117"></a>00117 <span class="comment"> * \param c2 is a string and not an AvrClass object, because this function is</span>
<a name="l00118"></a>00118 <span class="comment"> * called by dlist_lookup() which passes two AvrClass pointers. So the string</span>
<a name="l00119"></a>00119 <span class="comment"> * is casted to an *AvrClass.</span>
<a name="l00120"></a>00120 <span class="comment"> */</span>
<a name="l00121"></a>00121 <span class="keywordtype">int</span>
<a name="l00122"></a>00122 vdev_name_cmp (AvrClass *c1, AvrClass *c2)
<a name="l00123"></a>00123 {
<a name="l00124"></a>00124 <span class="keywordflow">return</span> strcmp (((VDevice *)c1)-&gt;name, (<span class="keywordtype">char</span> *)c2);
<a name="l00125"></a>00125 }
<a name="l00126"></a>00126
<a name="l00127"></a>00127 <span class="preprocessor">#endif</span>
<a name="l00128"></a>00128 <span class="preprocessor"></span>
<a name="l00129"></a>00129 <span class="preprocessor">#if 0</span>
<a name="l00130"></a>00130 <span class="preprocessor"></span><span class="comment">/** \brief Checks if a address is in the device's address range</span>
<a name="l00131"></a>00131 <span class="comment"> * \param c1 \c AvrClass to check.</span>
<a name="l00132"></a>00132 <span class="comment"> * \param c2 The address to check.</span>
<a name="l00133"></a>00133 <span class="comment"> *</span>
<a name="l00134"></a>00134 <span class="comment"> * \return The different between the device's address bounds and \a c2 or if</span>
<a name="l00135"></a>00135 <span class="comment"> * \a c2 is within the address range 0.</span>
<a name="l00136"></a>00136 <span class="comment"> *</span>
<a name="l00137"></a>00137 <span class="comment"> * \note When comparing an addr, c2 is really just a pointer (see</span>
<a name="l00138"></a>00138 <span class="comment"> * vdev_name_cmp() for details) to int and then we see if d1-&gt;base &lt;= addr &lt;</span>
<a name="l00139"></a>00139 <span class="comment"> * (d1-&gt;base+d1-&gt;size).</span>
<a name="l00140"></a>00140 <span class="comment"> */</span>
<a name="l00141"></a>00141 <span class="keywordtype">int</span>
<a name="l00142"></a>00142 vdev_addr_cmp (AvrClass *c1, AvrClass *c2)
<a name="l00143"></a>00143 {
<a name="l00144"></a>00144 VDevice *d1 = (VDevice *)c1;
<a name="l00145"></a>00145 <span class="keywordtype">int</span> addr = *(<span class="keywordtype">int</span> *)c2;
<a name="l00146"></a>00146
<a name="l00147"></a>00147 <span class="keywordflow">if</span> (addr &lt; d1-&gt;base)
<a name="l00148"></a>00148 <span class="keywordflow">return</span> (addr - d1-&gt;base);
<a name="l00149"></a>00149
<a name="l00150"></a>00150 <span class="keywordflow">if</span> (addr &gt;= (d1-&gt;base + d1-&gt;size))
<a name="l00151"></a>00151 <span class="comment">/* Add one to ensure we don't return zero. */</span>
<a name="l00152"></a>00152 <span class="keywordflow">return</span> (1 + addr - (d1-&gt;base + d1-&gt;size));
<a name="l00153"></a>00153
<a name="l00154"></a>00154 <span class="comment">/* addr is in device's range */</span>
<a name="l00155"></a>00155 <span class="keywordflow">return</span> 0;
<a name="l00156"></a>00156 }
<a name="l00157"></a>00157 <span class="preprocessor">#endif</span>
<a name="l00158"></a>00158 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00159"></a>00159 <span class="comment">/** \brief Reads the device's value in the register at \a addr. */</span>
<a name="l00160"></a>00160 uint8_t
<a name="l00161"></a><a class="code" href="device_8c.html#2c32d0afc4607136c886acbf362874ed">00161</a> <a class="code" href="device_8c.html#2c32d0afc4607136c886acbf362874ed" title="Reads the device&amp;#39;s value in the register at addr.">vdev_read</a> (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00162"></a>00162 {
<a name="l00163"></a>00163 <span class="keywordflow">return</span> dev-&gt;read (dev, addr);
<a name="l00164"></a>00164 }
<a name="l00165"></a>00165 <span class="comment"></span>
<a name="l00166"></a>00166 <span class="comment">/** \brief Writes an value to the register at \a addr. */</span>
<a name="l00167"></a>00167 <span class="keywordtype">void</span>
<a name="l00168"></a><a class="code" href="device_8c.html#502a4216ffd7501ad3059e95d0f5572f">00168</a> <a class="code" href="device_8c.html#502a4216ffd7501ad3059e95d0f5572f" title="Writes an value to the register at addr.">vdev_write</a> (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00169"></a>00169 {
<a name="l00170"></a>00170 dev-&gt;write (dev, addr, val);
<a name="l00171"></a>00171 }
<a name="l00172"></a>00172 <span class="comment"></span>
<a name="l00173"></a>00173 <span class="comment">/** \brief Resets a device. */</span>
<a name="l00174"></a>00174 <span class="keywordtype">void</span>
<a name="l00175"></a><a class="code" href="device_8c.html#1d98f1f4d77ce7d714ffde36ada57db7">00175</a> <a class="code" href="device_8c.html#1d98f1f4d77ce7d714ffde36ada57db7" title="Resets a device.">vdev_reset</a> (VDevice *dev)
<a name="l00176"></a>00176 {
<a name="l00177"></a>00177 dev-&gt;reset (dev);
<a name="l00178"></a>00178 }
<a name="l00179"></a>00179 <span class="comment"></span>
<a name="l00180"></a>00180 <span class="comment">/** \brief Set the core field. */</span>
<a name="l00181"></a>00181 <span class="keywordtype">void</span>
<a name="l00182"></a><a class="code" href="device_8c.html#2a8db1cadfd3c26e9ea7ea0e6d03c132">00182</a> <a class="code" href="device_8c.html#2a8db1cadfd3c26e9ea7ea0e6d03c132" title="Set the core field.">vdev_set_core</a> (VDevice *dev, AvrClass *core)
<a name="l00183"></a>00183 {
<a name="l00184"></a>00184 dev-&gt;core = (AvrClass *)core;
<a name="l00185"></a>00185 }
<a name="l00186"></a>00186 <span class="comment"></span>
<a name="l00187"></a>00187 <span class="comment">/** \brief Get the core field. */</span>
<a name="l00188"></a>00188 <span class="keyword">extern</span> <span class="keyword">inline</span> AvrClass *<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> (VDevice *dev);
<a name="l00189"></a>00189 <span class="comment"></span>
<a name="l00190"></a>00190 <span class="comment">/** \brief Inform the vdevice that it needs to handle another address.</span>
<a name="l00191"></a>00191 <span class="comment"></span>
<a name="l00192"></a>00192 <span class="comment"> This is primarily used when creating the core in dev_supp_create_core(). */</span>
<a name="l00193"></a>00193
<a name="l00194"></a>00194 <span class="keyword">extern</span> <span class="keywordtype">void</span>
<a name="l00195"></a><a class="code" href="device_8c.html#5777a3eab86212d53f616d687babf6a9">00195</a> <a class="code" href="device_8c.html#5777a3eab86212d53f616d687babf6a9" title="Inform the vdevice that it needs to handle another address.">vdev_add_addr</a> (VDevice *dev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00196"></a>00196 {
<a name="l00197"></a>00197 <span class="keywordflow">if</span> (dev-&gt;add_addr)
<a name="l00198"></a>00198 {
<a name="l00199"></a>00199 dev-&gt;add_addr (dev, addr, name, rel_addr, data);
<a name="l00200"></a>00200 }
<a name="l00201"></a>00201 <span class="keywordflow">else</span>
<a name="l00202"></a>00202 {
<a name="l00203"></a>00203 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"attempt to add addr to vdev with no add_addr() method: "</span>
<a name="l00204"></a>00204 <span class="stringliteral">"%s [0x%04x]\n"</span>, name, addr);
<a name="l00205"></a>00205 }
<a name="l00206"></a>00206 }
<a name="l00207"></a>00207
<a name="l00208"></a>00208 <span class="preprocessor">#if 0</span>
<a name="l00209"></a>00209 <span class="preprocessor"></span><span class="comment">/** \brief Get the device's base address. */</span>
<a name="l00210"></a>00210 <span class="keywordtype">int</span>
<a name="l00211"></a>00211 vdev_get_base (VDevice *dev)
<a name="l00212"></a>00212 {
<a name="l00213"></a>00213 <span class="keywordflow">return</span> dev-&gt;base;
<a name="l00214"></a>00214 }
<a name="l00215"></a>00215 <span class="preprocessor">#endif</span>
<a name="l00216"></a>00216 <span class="preprocessor"></span>
<a name="l00217"></a>00217 <span class="preprocessor">#if 0</span>
<a name="l00218"></a>00218 <span class="preprocessor"></span><span class="comment">/** \brief Set the device's size (the number of bytes of the address space it</span>
<a name="l00219"></a>00219 <span class="comment"> * consumes). */</span>
<a name="l00220"></a>00220 <span class="keywordtype">int</span>
<a name="l00221"></a>00221 vdev_get_size (VDevice *dev)
<a name="l00222"></a>00222 {
<a name="l00223"></a>00223 <span class="keywordflow">return</span> dev-&gt;size;
<a name="l00224"></a>00224 }
<a name="l00225"></a>00225 <span class="preprocessor">#endif</span>
<a name="l00226"></a>00226 <span class="preprocessor"></span>
<a name="l00227"></a>00227 <span class="preprocessor">#if 0</span>
<a name="l00228"></a>00228 <span class="preprocessor"></span><span class="comment">/** \brief Get the device's name. */</span>
<a name="l00229"></a>00229 <span class="keywordtype">char</span> *
<a name="l00230"></a>00230 vdev_get_name (VDevice *dev)
<a name="l00231"></a>00231 {
<a name="l00232"></a>00232 <span class="keywordflow">return</span> dev-&gt;name;
<a name="l00233"></a>00233 }
<a name="l00234"></a>00234 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,460 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>device.c File Reference</h1>VDevice methods. <a href="#_details">More...</a>
<p>
<p>
<a href="device_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="device_8c.html#134ea79c2ecf6f000d28d08b05ed40ca">vdev_new</a> (char *name, VDevFP_Read rd, VDevFP_Write wr, VDevFP_Reset reset, VDevFP_AddAddr add_addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="device_8c.html#5cebfd18a219807f27e4a3f38da4a5d0">vdev_def_AddAddr</a> (VDevice *dev, int addr, char *name, int related_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4">vdev_construct</a> (VDevice *dev, VDevFP_Read rd, VDevFP_Write wr, VDevFP_Reset reset, VDevFP_AddAddr add_addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9">vdev_destroy</a> (void *dev)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">uint8_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="device_8c.html#2c32d0afc4607136c886acbf362874ed">vdev_read</a> (VDevice *dev, int addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="device_8c.html#502a4216ffd7501ad3059e95d0f5572f">vdev_write</a> (VDevice *dev, int addr, uint8_t val)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="device_8c.html#1d98f1f4d77ce7d714ffde36ada57db7">vdev_reset</a> (VDevice *dev)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="device_8c.html#2a8db1cadfd3c26e9ea7ea0e6d03c132">vdev_set_core</a> (VDevice *dev, AvrClass *core)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">AvrClass *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="device_8c.html#b59809dd04174aca0940efa2505a3524">vdev_get_core</a> (VDevice *dev)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="device_8c.html#5777a3eab86212d53f616d687babf6a9">vdev_add_addr</a> (VDevice *dev, int addr, char *name, int rel_addr, void *data)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
VDevice methods.
<p>
These functions are the base for all other devices mapped into the device space.
<p>Definition in file <a class="el" href="device_8c-source.html">device.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="134ea79c2ecf6f000d28d08b05ed40ca"></a><!-- doxytag: member="device.c::vdev_new" ref="134ea79c2ecf6f000d28d08b05ed40ca" args="(char *name, VDevFP_Read rd, VDevFP_Write wr, VDevFP_Reset reset, VDevFP_AddAddr add_addr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* vdev_new </td>
<td>(</td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">VDevFP_Read&nbsp;</td>
<td class="paramname"> <em>rd</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">VDevFP_Write&nbsp;</td>
<td class="paramname"> <em>wr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">VDevFP_Reset&nbsp;</td>
<td class="paramname"> <em>reset</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">VDevFP_AddAddr&nbsp;</td>
<td class="paramname"> <em>add_addr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Create a new VDevice.
<p>
<p>Definition at line <a class="el" href="device_8c-source.html#l00062">62</a> of file <a class="el" href="device_8c-source.html">device.c</a>.</p>
<p>References <a class="el" href="avrmalloc_8c-source.html#l00067">avr_new0</a>, <a class="el" href="avrclass_8c-source.html#l00092">class_overload_destroy()</a>, <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>, and <a class="el" href="device_8c-source.html#l00105">vdev_destroy()</a>.</p>
</div>
</div><p>
<a class="anchor" name="5cebfd18a219807f27e4a3f38da4a5d0"></a><!-- doxytag: member="device.c::vdev_def_AddAddr" ref="5cebfd18a219807f27e4a3f38da4a5d0" args="(VDevice *dev, int addr, char *name, int related_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void vdev_def_AddAddr </td>
<td>(</td>
<td class="paramtype">VDevice *&nbsp;</td>
<td class="paramname"> <em>dev</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>related_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Default AddAddr method.
<p>
This generate a warning that the should let the developer know that the vdev needs to be updated.
<p>Definition at line <a class="el" href="device_8c-source.html#l00080">80</a> of file <a class="el" href="device_8c-source.html">device.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00046">avr_warning</a>.</p>
</div>
</div><p>
<a class="anchor" name="c3488ff879caeddb12999256aaf7bfc4"></a><!-- doxytag: member="device.c::vdev_construct" ref="c3488ff879caeddb12999256aaf7bfc4" args="(VDevice *dev, VDevFP_Read rd, VDevFP_Write wr, VDevFP_Reset reset, VDevFP_AddAddr add_addr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void vdev_construct </td>
<td>(</td>
<td class="paramtype">VDevice *&nbsp;</td>
<td class="paramname"> <em>dev</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">VDevFP_Read&nbsp;</td>
<td class="paramname"> <em>rd</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">VDevFP_Write&nbsp;</td>
<td class="paramname"> <em>wr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">VDevFP_Reset&nbsp;</td>
<td class="paramname"> <em>reset</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">VDevFP_AddAddr&nbsp;</td>
<td class="paramname"> <em>add_addr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for a VDevice.
<p>
<p>Definition at line <a class="el" href="device_8c-source.html#l00089">89</a> of file <a class="el" href="device_8c-source.html">device.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="avrclass_8c-source.html#l00061">class_construct()</a>.</p>
<p>Referenced by <a class="el" href="adc_8c-source.html#l00318">adc_construct()</a>, <a class="el" href="adc_8c-source.html#l00099">adc_intr_construct()</a>, <a class="el" href="timers_8c-source.html#l00935">ocreg16_construct()</a>, <a class="el" href="spi_8c-source.html#l00267">spi_construct()</a>, <a class="el" href="spi_8c-source.html#l00098">spi_intr_construct()</a>, <a class="el" href="timers_8c-source.html#l00370">timer0_construct()</a>, <a class="el" href="timers_8c-source.html#l00608">timer16_construct()</a>, <a class="el" href="timers_8c-source.html#l00163">timer_intr_construct()</a>, <a class="el" href="uart_8c-source.html#l00356">uart_construct()</a>, <a class="el" href="uart_8c-source.html#l00128">uart_intr_construct()</a>, <a class="el" href="usb_8c-source.html#l00321">usb_construct()</a>, <a class="el" href="usb_8c-source.html#l00103">usb_intr_construct()</a>, and <a class="el" href="device_8c-source.html#l00062">vdev_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="abfe90d199261cef657cd6f0b0e674a9"></a><!-- doxytag: member="device.c::vdev_destroy" ref="abfe90d199261cef657cd6f0b0e674a9" args="(void *dev)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void vdev_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>dev</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for a VDevice.
<p>
<p>Definition at line <a class="el" href="device_8c-source.html#l00105">105</a> of file <a class="el" href="device_8c-source.html">device.c</a>.</p>
<p>References <a class="el" href="avrclass_8c-source.html#l00078">class_destroy()</a>.</p>
<p>Referenced by <a class="el" href="adc_8c-source.html#l00357">adc_destroy()</a>, <a class="el" href="adc_8c-source.html#l00138">adc_intr_destroy()</a>, <a class="el" href="spi_8c-source.html#l00300">spi_destroy()</a>, <a class="el" href="spi_8c-source.html#l00134">spi_intr_destroy()</a>, <a class="el" href="timers_8c-source.html#l00387">timer0_destroy()</a>, <a class="el" href="timers_8c-source.html#l00205">timer_intr_destroy()</a>, <a class="el" href="uart_8c-source.html#l00389">uart_destroy()</a>, <a class="el" href="uart_8c-source.html#l00179">uart_intr_destroy()</a>, <a class="el" href="usb_8c-source.html#l00480">usb_destroy()</a>, <a class="el" href="usb_8c-source.html#l00181">usb_intr_destroy()</a>, and <a class="el" href="device_8c-source.html#l00062">vdev_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="2c32d0afc4607136c886acbf362874ed"></a><!-- doxytag: member="device.c::vdev_read" ref="2c32d0afc4607136c886acbf362874ed" args="(VDevice *dev, int addr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint8_t vdev_read </td>
<td>(</td>
<td class="paramtype">VDevice *&nbsp;</td>
<td class="paramname"> <em>dev</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Reads the device's value in the register at <em>addr</em>.
<p>
<p>Definition at line <a class="el" href="device_8c-source.html#l00161">161</a> of file <a class="el" href="device_8c-source.html">device.c</a>.</p>
<p>Referenced by <a class="el" href="memory_8c-source.html#l00322">mem_io_fetch()</a>, and <a class="el" href="memory_8c-source.html#l00212">mem_read()</a>.</p>
</div>
</div><p>
<a class="anchor" name="502a4216ffd7501ad3059e95d0f5572f"></a><!-- doxytag: member="device.c::vdev_write" ref="502a4216ffd7501ad3059e95d0f5572f" args="(VDevice *dev, int addr, uint8_t val)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void vdev_write </td>
<td>(</td>
<td class="paramtype">VDevice *&nbsp;</td>
<td class="paramname"> <em>dev</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&nbsp;</td>
<td class="paramname"> <em>val</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Writes an value to the register at <em>addr</em>.
<p>
<p>Definition at line <a class="el" href="device_8c-source.html#l00168">168</a> of file <a class="el" href="device_8c-source.html">device.c</a>.</p>
<p>Referenced by <a class="el" href="memory_8c-source.html#l00247">mem_write()</a>.</p>
</div>
</div><p>
<a class="anchor" name="1d98f1f4d77ce7d714ffde36ada57db7"></a><!-- doxytag: member="device.c::vdev_reset" ref="1d98f1f4d77ce7d714ffde36ada57db7" args="(VDevice *dev)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void vdev_reset </td>
<td>(</td>
<td class="paramtype">VDevice *&nbsp;</td>
<td class="paramname"> <em>dev</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Resets a device.
<p>
<p>Definition at line <a class="el" href="device_8c-source.html#l00175">175</a> of file <a class="el" href="device_8c-source.html">device.c</a>.</p>
<p>Referenced by <a class="el" href="memory_8c-source.html#l00284">mem_reset()</a>.</p>
</div>
</div><p>
<a class="anchor" name="2a8db1cadfd3c26e9ea7ea0e6d03c132"></a><!-- doxytag: member="device.c::vdev_set_core" ref="2a8db1cadfd3c26e9ea7ea0e6d03c132" args="(VDevice *dev, AvrClass *core)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void vdev_set_core </td>
<td>(</td>
<td class="paramtype">VDevice *&nbsp;</td>
<td class="paramname"> <em>dev</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">AvrClass *&nbsp;</td>
<td class="paramname"> <em>core</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Set the core field.
<p>
<p>Definition at line <a class="el" href="device_8c-source.html#l00182">182</a> of file <a class="el" href="device_8c-source.html">device.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="b59809dd04174aca0940efa2505a3524"></a><!-- doxytag: member="device.c::vdev_get_core" ref="b59809dd04174aca0940efa2505a3524" args="(VDevice *dev)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">AvrClass* vdev_get_core </td>
<td>(</td>
<td class="paramtype">VDevice *&nbsp;</td>
<td class="paramname"> <em>dev</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Get the core field.
<p>
</div>
</div><p>
<a class="anchor" name="5777a3eab86212d53f616d687babf6a9"></a><!-- doxytag: member="device.c::vdev_add_addr" ref="5777a3eab86212d53f616d687babf6a9" args="(VDevice *dev, int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void vdev_add_addr </td>
<td>(</td>
<td class="paramtype">VDevice *&nbsp;</td>
<td class="paramname"> <em>dev</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Inform the vdevice that it needs to handle another address.
<p>
This is primarily used when creating the core in dev_supp_create_core().
<p>Definition at line <a class="el" href="device_8c-source.html#l00195">195</a> of file <a class="el" href="device_8c-source.html">device.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00046">avr_warning</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,380 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>devsupp.c</h1><a href="devsupp_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: devsupp.c,v 1.30 2008/01/06 21:34:16 joerg_wunsch Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003, 2004 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/**</span>
<a name="l00027"></a>00027 <span class="comment"> * \file devsupp.c</span>
<a name="l00028"></a>00028 <span class="comment"> * \brief Contains definitions for device types (i.e. at90s8515, at90s2313,</span>
<a name="l00029"></a>00029 <span class="comment"> * etc.)</span>
<a name="l00030"></a>00030 <span class="comment"> *</span>
<a name="l00031"></a>00031 <span class="comment"> * This module is used to define the attributes for each device in the AVR</span>
<a name="l00032"></a>00032 <span class="comment"> * family. A generic constructor is used to create a new AvrCore object with</span>
<a name="l00033"></a>00033 <span class="comment"> * the proper ports, built-in peripherals, memory layout, registers, and</span>
<a name="l00034"></a>00034 <span class="comment"> * interrupt vectors, etc.</span>
<a name="l00035"></a>00035 <span class="comment"> */</span>
<a name="l00036"></a>00036
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00038"></a>00038
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00042"></a>00042
<a name="l00043"></a>00043 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include "utils.h"</span>
<a name="l00047"></a>00047 <span class="preprocessor">#include "callback.h"</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include "op_names.h"</span>
<a name="l00049"></a>00049
<a name="l00050"></a>00050 <span class="preprocessor">#include "storage.h"</span>
<a name="l00051"></a>00051 <span class="preprocessor">#include "flash.h"</span>
<a name="l00052"></a>00052
<a name="l00053"></a>00053 <span class="preprocessor">#include "vdevs.h"</span>
<a name="l00054"></a>00054 <span class="preprocessor">#include "memory.h"</span>
<a name="l00055"></a>00055 <span class="preprocessor">#include "stack.h"</span>
<a name="l00056"></a>00056 <span class="preprocessor">#include "register.h"</span>
<a name="l00057"></a>00057 <span class="preprocessor">#include "sram.h"</span>
<a name="l00058"></a>00058 <span class="preprocessor">#include "eeprom.h"</span>
<a name="l00059"></a>00059 <span class="preprocessor">#include "timers.h"</span>
<a name="l00060"></a>00060 <span class="preprocessor">#include "ports.h"</span>
<a name="l00061"></a>00061 <span class="preprocessor">#include "spi.h"</span>
<a name="l00062"></a>00062 <span class="preprocessor">#include "adc.h"</span>
<a name="l00063"></a>00063 <span class="preprocessor">#include "usb.h"</span>
<a name="l00064"></a>00064 <span class="preprocessor">#include "uart.h"</span>
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="preprocessor">#include "avrcore.h"</span>
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="preprocessor">#include "devsupp.h"</span>
<a name="l00069"></a>00069
<a name="l00070"></a>00070 <span class="preprocessor">#ifndef DOXYGEN </span><span class="comment">/* don't expose to doxygen */</span>
<a name="l00071"></a>00071
<a name="l00072"></a>00072 <span class="comment">/*</span>
<a name="l00073"></a>00073 <span class="comment"> * Used to select which vector table the device uses.</span>
<a name="l00074"></a>00074 <span class="comment"> * The value is an index into the global_vtable_list[] array </span>
<a name="l00075"></a>00075 <span class="comment"> * defined in intvects.c.</span>
<a name="l00076"></a>00076 <span class="comment"> */</span>
<a name="l00077"></a>00077 <span class="keyword">enum</span> _vector_table_select
<a name="l00078"></a>00078 {
<a name="l00079"></a>00079 VTAB_AT90S1200 = 0,
<a name="l00080"></a>00080 VTAB_AT90S2313,
<a name="l00081"></a>00081 VTAB_AT90S4414,
<a name="l00082"></a>00082 VTAB_ATMEGA8,
<a name="l00083"></a>00083 VTAB_ATMEGA16,
<a name="l00084"></a>00084 VTAB_ATMEGA32,
<a name="l00085"></a>00085 VTAB_ATMEGA103,
<a name="l00086"></a>00086 VTAB_ATMEGA128,
<a name="l00087"></a>00087 VTAB_AT43USB355,
<a name="l00088"></a>00088 VTAB_AT43USB320,
<a name="l00089"></a>00089 VTAB_AT43USB325,
<a name="l00090"></a>00090 VTAB_AT43USB326,
<a name="l00091"></a>00091 };
<a name="l00092"></a>00092
<a name="l00093"></a>00093 <span class="comment">/* IO Register Definition. */</span>
<a name="l00094"></a>00094
<a name="l00095"></a>00095 <span class="keyword">struct </span>io_reg_defn {
<a name="l00096"></a>00096 uint16_t addr; <span class="comment">/* The address of the register (in memory</span>
<a name="l00097"></a>00097 <span class="comment"> space, not IO space). */</span>
<a name="l00098"></a>00098 <span class="keywordtype">char</span> *name; <span class="comment">/* The register name as given by the</span>
<a name="l00099"></a>00099 <span class="comment"> datasheet. */</span>
<a name="l00100"></a>00100 uint16_t ref_addr; <span class="comment">/* Use the vdev reference at the given</span>
<a name="l00101"></a>00101 <span class="comment"> address. If not zero, use the same vdev</span>
<a name="l00102"></a>00102 <span class="comment"> pointer at the given register address. The</span>
<a name="l00103"></a>00103 <span class="comment"> vdev must have already been created at that</span>
<a name="l00104"></a>00104 <span class="comment"> address. Remember that address zero is</span>
<a name="l00105"></a>00105 <span class="comment"> General Register 0 which is not an IO</span>
<a name="l00106"></a>00106 <span class="comment"> register. This value should never be less</span>
<a name="l00107"></a>00107 <span class="comment"> than 0x20. */</span>
<a name="l00108"></a>00108 uint16_t related; <span class="comment">/* A related address. For example, if a device</span>
<a name="l00109"></a>00109 <span class="comment"> has more than one timer, each timer has</span>
<a name="l00110"></a>00110 <span class="comment"> it's own instance of the timer vdev, but</span>
<a name="l00111"></a>00111 <span class="comment"> all timers need access to the TIMSK</span>
<a name="l00112"></a>00112 <span class="comment"> register which should have the addr</span>
<a name="l00113"></a>00113 <span class="comment"> specified here. There might be more than</span>
<a name="l00114"></a>00114 <span class="comment"> one related address for a vdev, so this may</span>
<a name="l00115"></a>00115 <span class="comment"> need to become an array. */</span>
<a name="l00116"></a>00116 VDevCreate vdev_create; <span class="comment">/* The vdev creation function to be used to</span>
<a name="l00117"></a>00117 <span class="comment"> create the vdev. Note that this should be a</span>
<a name="l00118"></a>00118 <span class="comment"> wrapper around the vdev's new method. This</span>
<a name="l00119"></a>00119 <span class="comment"> field is ignored if rel_addr is greater</span>
<a name="l00120"></a>00120 <span class="comment"> than 0x1f. */</span>
<a name="l00121"></a>00121 <span class="keywordtype">void</span> *data; <span class="comment">/* Optional data that may be needed by the</span>
<a name="l00122"></a>00122 <span class="comment"> vdev. May be address specific too. */</span>
<a name="l00123"></a>00123 <span class="keywordtype">int</span> flags; <span class="comment">/* Flags that can change the behaviour of the</span>
<a name="l00124"></a>00124 <span class="comment"> value. (e.g. FL_SET_ON_RESET) */</span>
<a name="l00125"></a>00125 uint8_t reset_value; <span class="comment">/* Initialize the register to this value after</span>
<a name="l00126"></a>00126 <span class="comment"> reset. */</span>
<a name="l00127"></a>00127
<a name="l00128"></a>00128 <span class="comment">/* These should handle PORT width automagically. */</span>
<a name="l00129"></a>00129
<a name="l00130"></a>00130 uint8_t rd_mask; <span class="comment">/* Mask of the readable bits in the</span>
<a name="l00131"></a>00131 <span class="comment"> register. */</span>
<a name="l00132"></a>00132 uint8_t wr_mask; <span class="comment">/* Mask of the writable bits in the</span>
<a name="l00133"></a>00133 <span class="comment"> register. */</span>
<a name="l00134"></a>00134 };
<a name="l00135"></a>00135
<a name="l00136"></a>00136 <span class="preprocessor">#define IO_REG_DEFN_TERMINATOR { .name = NULL, }</span>
<a name="l00137"></a>00137 <span class="preprocessor"></span>
<a name="l00138"></a>00138 <span class="comment">/* Structure for defining a supported device */</span>
<a name="l00139"></a>00139
<a name="l00140"></a>00140 <span class="keyword">struct </span>_DevSuppDefn
<a name="l00141"></a>00141 {
<a name="l00142"></a>00142 <span class="keywordtype">char</span> *name; <span class="comment">/* name of device type */</span>
<a name="l00143"></a>00143
<a name="l00144"></a>00144 StackType stack_type; <span class="comment">/* STACK_HARDWARE or STACK_MEMORY */</span>
<a name="l00145"></a>00145 <span class="keywordtype">int</span> has_ext_io_reg; <span class="comment">/* does the device have extened IO registers */</span>
<a name="l00146"></a>00146 <span class="keywordtype">int</span> irq_vect_idx; <span class="comment">/* interrupt vector table index */</span>
<a name="l00147"></a>00147
<a name="l00148"></a>00148 <span class="keyword">struct</span>
<a name="l00149"></a>00149 {
<a name="l00150"></a>00150 <span class="keywordtype">int</span> pc; <span class="comment">/* width of program counter (usually 2, maybe</span>
<a name="l00151"></a>00151 <span class="comment"> 3) */</span>
<a name="l00152"></a>00152 <span class="keywordtype">int</span> stack; <span class="comment">/* depth of stack (only used by hardware</span>
<a name="l00153"></a>00153 <span class="comment"> stack) */</span>
<a name="l00154"></a>00154 <span class="keywordtype">int</span> flash; <span class="comment">/* bytes of flash memory */</span>
<a name="l00155"></a>00155 <span class="keywordtype">int</span> sram; <span class="comment">/* bytes of sram memory */</span>
<a name="l00156"></a>00156 <span class="keywordtype">int</span> eeprom; <span class="comment">/* bytes of eeprom memory */</span>
<a name="l00157"></a>00157 <span class="keywordtype">int</span> xram; <span class="comment">/* bytes of external SRAM supported */</span>
<a name="l00158"></a>00158 } size;
<a name="l00159"></a>00159
<a name="l00160"></a>00160 <span class="comment">/* This _must_ be the last field of the structure since it is a variable</span>
<a name="l00161"></a>00161 <span class="comment"> length array. (This is new in C99.) */</span>
<a name="l00162"></a>00162
<a name="l00163"></a>00163 <span class="keyword">struct </span>io_reg_defn io_reg[]; <span class="comment">/* Definitions for for all the IO registers</span>
<a name="l00164"></a>00164 <span class="comment"> the device provides. */</span>
<a name="l00165"></a>00165 };
<a name="l00166"></a>00166
<a name="l00167"></a>00167 <span class="preprocessor">#endif </span><span class="comment">/* DOXYGEN */</span>
<a name="l00168"></a>00168
<a name="l00169"></a>00169 <span class="keywordtype">int</span>
<a name="l00170"></a>00170 dev_supp_has_ext_io_reg (DevSuppDefn *dev)
<a name="l00171"></a>00171 {
<a name="l00172"></a>00172 <span class="keywordflow">return</span> dev-&gt;has_ext_io_reg;
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174
<a name="l00175"></a>00175 <span class="keywordtype">int</span>
<a name="l00176"></a>00176 dev_supp_get_flash_sz (DevSuppDefn *dev)
<a name="l00177"></a>00177 {
<a name="l00178"></a>00178 <span class="keywordflow">return</span> dev-&gt;size.flash;
<a name="l00179"></a>00179 }
<a name="l00180"></a>00180
<a name="l00181"></a>00181 <span class="keywordtype">int</span>
<a name="l00182"></a>00182 dev_supp_get_PC_sz (DevSuppDefn *dev)
<a name="l00183"></a>00183 {
<a name="l00184"></a>00184 <span class="keywordflow">return</span> dev-&gt;size.pc;
<a name="l00185"></a>00185 }
<a name="l00186"></a>00186
<a name="l00187"></a>00187 <span class="keywordtype">int</span>
<a name="l00188"></a>00188 dev_supp_get_stack_sz (DevSuppDefn *dev)
<a name="l00189"></a>00189 {
<a name="l00190"></a>00190 <span class="keywordflow">return</span> dev-&gt;size.stack;
<a name="l00191"></a>00191 }
<a name="l00192"></a>00192
<a name="l00193"></a>00193 <span class="keywordtype">int</span>
<a name="l00194"></a>00194 dev_supp_get_vtab_idx (DevSuppDefn *dev)
<a name="l00195"></a>00195 {
<a name="l00196"></a>00196 <span class="keywordflow">return</span> dev-&gt;irq_vect_idx;
<a name="l00197"></a>00197 }
<a name="l00198"></a>00198
<a name="l00199"></a>00199 <span class="keywordtype">int</span>
<a name="l00200"></a>00200 dev_supp_get_sram_sz (DevSuppDefn *dev)
<a name="l00201"></a>00201 {
<a name="l00202"></a>00202 <span class="keywordflow">return</span> dev-&gt;size.sram;
<a name="l00203"></a>00203 }
<a name="l00204"></a>00204
<a name="l00205"></a>00205 <span class="keywordtype">int</span>
<a name="l00206"></a>00206 dev_supp_get_xram_sz (DevSuppDefn *dev)
<a name="l00207"></a>00207 {
<a name="l00208"></a>00208 <span class="keywordflow">return</span> dev-&gt;size.xram;
<a name="l00209"></a>00209 }
<a name="l00210"></a>00210
<a name="l00211"></a>00211 <span class="comment">/*</span>
<a name="l00212"></a>00212 <span class="comment"> * Device Definitions</span>
<a name="l00213"></a>00213 <span class="comment"> */</span>
<a name="l00214"></a>00214
<a name="l00215"></a>00215 <span class="preprocessor">#define IN_DEVSUPP_C</span>
<a name="l00216"></a>00216 <span class="preprocessor"></span>
<a name="l00217"></a>00217 <span class="preprocessor">#include "defn/90s1200.h"</span>
<a name="l00218"></a>00218 <span class="preprocessor">#include "defn/90s2313.h"</span>
<a name="l00219"></a>00219 <span class="preprocessor">#include "defn/90s4414.h"</span>
<a name="l00220"></a>00220 <span class="preprocessor">#include "defn/90s8515.h"</span>
<a name="l00221"></a>00221
<a name="l00222"></a>00222 <span class="preprocessor">#include "defn/mega8.h"</span>
<a name="l00223"></a>00223 <span class="preprocessor">#include "defn/mega16.h"</span>
<a name="l00224"></a>00224 <span class="preprocessor">#include "defn/mega32.h"</span>
<a name="l00225"></a>00225 <span class="preprocessor">#include "defn/mega103.h"</span>
<a name="l00226"></a>00226 <span class="preprocessor">#include "defn/mega128.h"</span>
<a name="l00227"></a>00227
<a name="l00228"></a>00228 <span class="preprocessor">#include "defn/43usb320.h"</span>
<a name="l00229"></a>00229 <span class="preprocessor">#include "defn/43usb325.h"</span>
<a name="l00230"></a>00230 <span class="preprocessor">#include "defn/43usb326.h"</span>
<a name="l00231"></a>00231
<a name="l00232"></a>00232 <span class="preprocessor">#include "defn/43usb351.h"</span>
<a name="l00233"></a>00233 <span class="preprocessor">#include "defn/43usb353.h"</span>
<a name="l00234"></a>00234 <span class="preprocessor">#include "defn/43usb355.h"</span>
<a name="l00235"></a>00235
<a name="l00236"></a>00236 <span class="preprocessor">#undef IN_DEVSUPP_C</span>
<a name="l00237"></a>00237 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00238"></a>00238 <span class="comment">/** \brief List of supported devices. */</span>
<a name="l00239"></a>00239
<a name="l00240"></a>00240 <span class="keyword">static</span> DevSuppDefn *devices_supported[] = {
<a name="l00241"></a>00241 &amp;defn_at90s1200,
<a name="l00242"></a>00242 &amp;defn_at90s2313,
<a name="l00243"></a>00243 &amp;defn_at90s4414,
<a name="l00244"></a>00244 &amp;defn_at90s8515,
<a name="l00245"></a>00245 &amp;defn_atmega8,
<a name="l00246"></a>00246 &amp;defn_atmega16,
<a name="l00247"></a>00247 &amp;defn_atmega32,
<a name="l00248"></a>00248 &amp;defn_atmega103,
<a name="l00249"></a>00249 &amp;defn_atmega128,
<a name="l00250"></a>00250 &amp;defn_at43usb351,
<a name="l00251"></a>00251 &amp;defn_at43usb353,
<a name="l00252"></a>00252 &amp;defn_at43usb355,
<a name="l00253"></a>00253 &amp;defn_at43usb320,
<a name="l00254"></a>00254 &amp;defn_at43usb325,
<a name="l00255"></a>00255 &amp;defn_at43usb326,
<a name="l00256"></a>00256 NULL
<a name="l00257"></a>00257 };
<a name="l00258"></a>00258 <span class="comment"></span>
<a name="l00259"></a>00259 <span class="comment">/**</span>
<a name="l00260"></a>00260 <span class="comment"> * \brief Look up a device name in support list.</span>
<a name="l00261"></a>00261 <span class="comment"> *</span>
<a name="l00262"></a>00262 <span class="comment"> * \returns An opaque pointer to DevSuppDefn or NULL if not found.</span>
<a name="l00263"></a>00263 <span class="comment"> */</span>
<a name="l00264"></a>00264
<a name="l00265"></a>00265 DevSuppDefn *
<a name="l00266"></a><a class="code" href="devsupp_8c.html#016b622b99dbb64383e7ad34a8f746f1">00266</a> <a class="code" href="devsupp_8c.html#016b622b99dbb64383e7ad34a8f746f1" title="Look up a device name in support list.">dev_supp_lookup_device</a> (<span class="keywordtype">char</span> *dev_name)
<a name="l00267"></a>00267 {
<a name="l00268"></a>00268 DevSuppDefn **dev = devices_supported;
<a name="l00269"></a>00269 <span class="keywordtype">int</span> len;
<a name="l00270"></a>00270
<a name="l00271"></a>00271 <span class="keywordflow">while</span> ((*dev))
<a name="l00272"></a>00272 {
<a name="l00273"></a>00273 len = strlen ((*dev)-&gt;name);
<a name="l00274"></a>00274
<a name="l00275"></a>00275 <span class="keywordflow">if</span> (strncmp ((*dev)-&gt;name, dev_name, len) == 0)
<a name="l00276"></a>00276 <span class="keywordflow">return</span> (*dev);
<a name="l00277"></a>00277
<a name="l00278"></a>00278 dev++;
<a name="l00279"></a>00279 }
<a name="l00280"></a>00280 <span class="keywordflow">return</span> NULL;
<a name="l00281"></a>00281 }
<a name="l00282"></a>00282 <span class="comment"></span>
<a name="l00283"></a>00283 <span class="comment">/** \brief Print a list of supported devices to a file pointer. */</span>
<a name="l00284"></a>00284
<a name="l00285"></a>00285 <span class="keywordtype">void</span>
<a name="l00286"></a><a class="code" href="devsupp_8c.html#3fc3008c90677776ac1a67956e2d8701">00286</a> <a class="code" href="devsupp_8c.html#3fc3008c90677776ac1a67956e2d8701" title="Print a list of supported devices to a file pointer.">dev_supp_list_devices</a> (FILE * fp)
<a name="l00287"></a>00287 {
<a name="l00288"></a>00288 DevSuppDefn **dev;
<a name="l00289"></a>00289
<a name="l00290"></a>00290 <span class="keywordflow">for</span> (dev = devices_supported; (*dev); dev++)
<a name="l00291"></a>00291 fprintf (fp, <span class="stringliteral">" %s\n"</span>, (*dev)-&gt;name);
<a name="l00292"></a>00292 }
<a name="l00293"></a>00293
<a name="l00294"></a>00294 <span class="keywordtype">void</span>
<a name="l00295"></a>00295 dev_supp_attach_io_regs (AvrCore *core, DevSuppDefn *dev)
<a name="l00296"></a>00296 {
<a name="l00297"></a>00297 VDevice *vdev;
<a name="l00298"></a>00298 <span class="keyword">struct </span>io_reg_defn *reg = dev-&gt;io_reg;
<a name="l00299"></a>00299
<a name="l00300"></a>00300 <span class="keywordflow">while</span> (reg-&gt;name)
<a name="l00301"></a>00301 {
<a name="l00302"></a>00302 <span class="keywordflow">if</span> (reg-&gt;ref_addr)
<a name="l00303"></a>00303 {
<a name="l00304"></a>00304 <span class="keywordflow">if</span> (reg-&gt;ref_addr &lt; 0x20)
<a name="l00305"></a>00305 {
<a name="l00306"></a>00306 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"can't attach IO reg into general register space"</span>);
<a name="l00307"></a>00307 }
<a name="l00308"></a>00308
<a name="l00309"></a>00309 <span class="comment">/* Get the referenced vdev. */</span>
<a name="l00310"></a>00310
<a name="l00311"></a>00311 vdev = <a class="code" href="avrcore_8c.html#f0c70bc7f992dcacd8ab411993bea5b5" title="Returns the VDevice which handles the address addr.">avr_core_get_vdev_by_addr</a> (core, reg-&gt;ref_addr);
<a name="l00312"></a>00312 <span class="keywordflow">if</span> (vdev == NULL)
<a name="l00313"></a>00313 {
<a name="l00314"></a>00314 <span class="comment">/* This means that the implementor of the vdev screwed up. */</span>
<a name="l00315"></a>00315 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"reference vdev hasn't been created yet"</span>);
<a name="l00316"></a>00316 }
<a name="l00317"></a>00317
<a name="l00318"></a>00318 <a class="code" href="device_8c.html#5777a3eab86212d53f616d687babf6a9" title="Inform the vdevice that it needs to handle another address.">vdev_add_addr</a> (vdev, reg-&gt;addr, reg-&gt;name, reg-&gt;related,
<a name="l00319"></a>00319 reg-&gt;data);
<a name="l00320"></a>00320
<a name="l00321"></a>00321 <a class="code" href="avrcore_8c.html#3ab00f070e80ce3b036f2f24c23408f6" title="Attach a virtual device into the Memory.">avr_core_attach_vdev</a> (core, reg-&gt;addr, reg-&gt;name, vdev, reg-&gt;flags,
<a name="l00322"></a>00322 reg-&gt;reset_value, reg-&gt;rd_mask,
<a name="l00323"></a>00323 reg-&gt;wr_mask);
<a name="l00324"></a>00324
<a name="l00325"></a>00325 <a class="code" href="avrerror_8c.html#deeaf2330efd6054822bc9146527777b" title="Print an ordinary message to stdout.">avr_message</a> (<span class="stringliteral">"attach: IO Reg '%s' at 0x%04x: ref = 0x%04x\n"</span>,
<a name="l00326"></a>00326 reg-&gt;name, reg-&gt;addr, reg-&gt;ref_addr);
<a name="l00327"></a>00327 }
<a name="l00328"></a>00328
<a name="l00329"></a>00329 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (reg-&gt;vdev_create)
<a name="l00330"></a>00330 {
<a name="l00331"></a>00331 vdev = reg-&gt;vdev_create (reg-&gt;addr, reg-&gt;name, reg-&gt;related,
<a name="l00332"></a>00332 reg-&gt;data);
<a name="l00333"></a>00333 <a class="code" href="avrcore_8c.html#3ab00f070e80ce3b036f2f24c23408f6" title="Attach a virtual device into the Memory.">avr_core_attach_vdev</a> (core, reg-&gt;addr, reg-&gt;name, vdev, reg-&gt;flags,
<a name="l00334"></a>00334 reg-&gt;reset_value, reg-&gt;rd_mask,
<a name="l00335"></a>00335 reg-&gt;wr_mask);
<a name="l00336"></a>00336
<a name="l00337"></a>00337 <span class="comment">/* Attaching implicitly references the device so we need to unref</span>
<a name="l00338"></a>00338 <span class="comment"> the newly created vdev since we're done with it here. */</span>
<a name="l00339"></a>00339 <a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a> ((AvrClass *)vdev);
<a name="l00340"></a>00340
<a name="l00341"></a>00341 <a class="code" href="avrerror_8c.html#deeaf2330efd6054822bc9146527777b" title="Print an ordinary message to stdout.">avr_message</a> (<span class="stringliteral">"attach: IO Reg '%s' at 0x%04x: created\n"</span>,
<a name="l00342"></a>00342 reg-&gt;name, reg-&gt;addr);
<a name="l00343"></a>00343 }
<a name="l00344"></a>00344
<a name="l00345"></a>00345 <span class="keywordflow">else</span>
<a name="l00346"></a>00346 {
<a name="l00347"></a>00347 <a class="code" href="avrerror_8c.html#deeaf2330efd6054822bc9146527777b" title="Print an ordinary message to stdout.">avr_message</a> (<span class="stringliteral">"TODO: attach IO Reg '%s' at 0x%04x\n"</span>, reg-&gt;name,
<a name="l00348"></a>00348 reg-&gt;addr);
<a name="l00349"></a>00349
<a name="l00350"></a>00350 avr_core_set_addr_name (core, reg-&gt;addr, reg-&gt;name);
<a name="l00351"></a>00351 }
<a name="l00352"></a>00352
<a name="l00353"></a>00353 reg++;
<a name="l00354"></a>00354 }
<a name="l00355"></a>00355 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,120 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>devsupp.c File Reference</h1>Contains definitions for device types (i.e. at90s8515, at90s2313, etc.). <a href="#_details">More...</a>
<p>
<p>
<a href="devsupp_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a7fb1ad840e8e406529980b990dce11d"></a><!-- doxytag: member="devsupp.c::dev_supp_has_ext_io_reg" ref="a7fb1ad840e8e406529980b990dce11d" args="(DevSuppDefn *dev)" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><b>dev_supp_has_ext_io_reg</b> (DevSuppDefn *dev)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="32fe5042bb68447fced9b89ba374f603"></a><!-- doxytag: member="devsupp.c::dev_supp_get_flash_sz" ref="32fe5042bb68447fced9b89ba374f603" args="(DevSuppDefn *dev)" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><b>dev_supp_get_flash_sz</b> (DevSuppDefn *dev)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="95f6638b1ae8f8d2972d523194b4baf5"></a><!-- doxytag: member="devsupp.c::dev_supp_get_PC_sz" ref="95f6638b1ae8f8d2972d523194b4baf5" args="(DevSuppDefn *dev)" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><b>dev_supp_get_PC_sz</b> (DevSuppDefn *dev)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="42a69bab1271c6bc91202bd6293fc40c"></a><!-- doxytag: member="devsupp.c::dev_supp_get_stack_sz" ref="42a69bab1271c6bc91202bd6293fc40c" args="(DevSuppDefn *dev)" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><b>dev_supp_get_stack_sz</b> (DevSuppDefn *dev)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="3ef07974047118a79d70fb901af60a57"></a><!-- doxytag: member="devsupp.c::dev_supp_get_vtab_idx" ref="3ef07974047118a79d70fb901af60a57" args="(DevSuppDefn *dev)" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><b>dev_supp_get_vtab_idx</b> (DevSuppDefn *dev)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="11d4cd9aa75bb0cfb3dcdeb554bcc6b8"></a><!-- doxytag: member="devsupp.c::dev_supp_get_sram_sz" ref="11d4cd9aa75bb0cfb3dcdeb554bcc6b8" args="(DevSuppDefn *dev)" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><b>dev_supp_get_sram_sz</b> (DevSuppDefn *dev)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="64650b69d3adc157ff364e6ec80172f6"></a><!-- doxytag: member="devsupp.c::dev_supp_get_xram_sz" ref="64650b69d3adc157ff364e6ec80172f6" args="(DevSuppDefn *dev)" -->
int&nbsp;</td><td class="memItemRight" valign="bottom"><b>dev_supp_get_xram_sz</b> (DevSuppDefn *dev)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">DevSuppDefn *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="devsupp_8c.html#016b622b99dbb64383e7ad34a8f746f1">dev_supp_lookup_device</a> (char *dev_name)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="devsupp_8c.html#3fc3008c90677776ac1a67956e2d8701">dev_supp_list_devices</a> (FILE *fp)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="e4cf6261026115f09ef813aafb386886"></a><!-- doxytag: member="devsupp.c::dev_supp_attach_io_regs" ref="e4cf6261026115f09ef813aafb386886" args="(AvrCore *core, DevSuppDefn *dev)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><b>dev_supp_attach_io_regs</b> (AvrCore *core, DevSuppDefn *dev)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Contains definitions for device types (i.e. at90s8515, at90s2313, etc.).
<p>
This module is used to define the attributes for each device in the AVR family. A generic constructor is used to create a new AvrCore object with the proper ports, built-in peripherals, memory layout, registers, and interrupt vectors, etc.
<p>Definition in file <a class="el" href="devsupp_8c-source.html">devsupp.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="016b622b99dbb64383e7ad34a8f746f1"></a><!-- doxytag: member="devsupp.c::dev_supp_lookup_device" ref="016b622b99dbb64383e7ad34a8f746f1" args="(char *dev_name)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">DevSuppDefn* dev_supp_lookup_device </td>
<td>(</td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>dev_name</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Look up a device name in support list.
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>An opaque pointer to DevSuppDefn or NULL if not found. </dd></dl>
<p>Definition at line <a class="el" href="devsupp_8c-source.html#l00266">266</a> of file <a class="el" href="devsupp_8c-source.html">devsupp.c</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l00355">avr_core_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="3fc3008c90677776ac1a67956e2d8701"></a><!-- doxytag: member="devsupp.c::dev_supp_list_devices" ref="3fc3008c90677776ac1a67956e2d8701" args="(FILE *fp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void dev_supp_list_devices </td>
<td>(</td>
<td class="paramtype">FILE *&nbsp;</td>
<td class="paramname"> <em>fp</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Print a list of supported devices to a file pointer.
<p>
<p>Definition at line <a class="el" href="devsupp_8c-source.html#l00286">286</a> of file <a class="el" href="devsupp_8c-source.html">devsupp.c</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,450 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>display.c</h1><a href="display_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: display.c,v 1.14 2003/12/01 09:10:14 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/**</span>
<a name="l00027"></a>00027 <span class="comment"> * \file display.c</span>
<a name="l00028"></a>00028 <span class="comment"> * \brief Interface for using display coprocesses.</span>
<a name="l00029"></a>00029 <span class="comment"> *</span>
<a name="l00030"></a>00030 <span class="comment"> * Simulavr has the ability to use a coprocess to display register and memory</span>
<a name="l00031"></a>00031 <span class="comment"> * values in near real time.</span>
<a name="l00032"></a>00032 <span class="comment"> */</span>
<a name="l00033"></a>00033
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00035"></a>00035
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;errno.h&gt;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;sys/types.h&gt;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;sys/wait.h&gt;</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include &lt;unistd.h&gt;</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include &lt;fcntl.h&gt;</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include &lt;sys/ioctl.h&gt;</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include &lt;signal.h&gt;</span>
<a name="l00046"></a>00046
<a name="l00047"></a>00047 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include "display.h"</span>
<a name="l00050"></a>00050
<a name="l00051"></a>00051 <span class="keyword">enum</span>
<a name="l00052"></a>00052 {
<a name="l00053"></a>00053 MAX_BUF = 1024,
<a name="l00054"></a>00054 };
<a name="l00055"></a>00055
<a name="l00056"></a>00056 <span class="comment">/* I really don't want to use a global here, but I also don't want to have to</span>
<a name="l00057"></a>00057 <span class="comment"> track the pipe's fd in the core. */</span>
<a name="l00058"></a>00058
<a name="l00059"></a>00059 <span class="keyword">static</span> <span class="keywordtype">int</span> global_pipe_fd = -1;
<a name="l00060"></a>00060
<a name="l00061"></a>00061 <span class="comment">/* Need to store the child's pid so that we can kill and waitpid it when you</span>
<a name="l00062"></a>00062 <span class="comment"> close the display. Otherwise we have problems with zombies. */</span>
<a name="l00063"></a>00063
<a name="l00064"></a>00064 <span class="keyword">static</span> pid_t global_child_pid = -1;
<a name="l00065"></a>00065 <span class="comment"></span>
<a name="l00066"></a>00066 <span class="comment">/** \brief Open a display as a coprocess.</span>
<a name="l00067"></a>00067 <span class="comment"> \param prog The program to use as a display coprocess.</span>
<a name="l00068"></a>00068 <span class="comment"> \param no_xterm If non-zero, don't run the disply in an xterm.</span>
<a name="l00069"></a>00069 <span class="comment"> \param flash_sz The size of the flash memory space in bytes.</span>
<a name="l00070"></a>00070 <span class="comment"> \param sram_sz The size of the sram memory space in bytes.</span>
<a name="l00071"></a>00071 <span class="comment"> \param sram_start The addr of the first byte of sram (usually 0x60 or</span>
<a name="l00072"></a>00072 <span class="comment"> 0x100).</span>
<a name="l00073"></a>00073 <span class="comment"> \param eeprom_sz The size of the eeprom memory space in bytes.</span>
<a name="l00074"></a>00074 <span class="comment"></span>
<a name="l00075"></a>00075 <span class="comment"> Try to start up a helper program as a child process for displaying</span>
<a name="l00076"></a>00076 <span class="comment"> registers and memory. If the prog argument is NULL, don't start up a</span>
<a name="l00077"></a>00077 <span class="comment"> display.</span>
<a name="l00078"></a>00078 <span class="comment"></span>
<a name="l00079"></a>00079 <span class="comment"> Returns an open file descriptor of a pipe used to send data to</span>
<a name="l00080"></a>00080 <span class="comment"> the helper program. </span>
<a name="l00081"></a>00081 <span class="comment"> </span>
<a name="l00082"></a>00082 <span class="comment"> Returns -1 if something failed. */</span>
<a name="l00083"></a>00083
<a name="l00084"></a>00084 <span class="keywordtype">int</span>
<a name="l00085"></a><a class="code" href="display_8c.html#aeea9e0008fcf18c0514a45e99a7f4d2">00085</a> <a class="code" href="display_8c.html#aeea9e0008fcf18c0514a45e99a7f4d2" title="Open a display as a coprocess.">display_open</a> (<span class="keywordtype">char</span> *prog, <span class="keywordtype">int</span> no_xterm, <span class="keywordtype">int</span> flash_sz, <span class="keywordtype">int</span> sram_sz,
<a name="l00086"></a>00086 <span class="keywordtype">int</span> sram_start, <span class="keywordtype">int</span> eeprom_sz)
<a name="l00087"></a>00087 {
<a name="l00088"></a>00088 pid_t pid;
<a name="l00089"></a>00089 <span class="keywordtype">int</span> pfd[2]; <span class="comment">/* pipe file desc: pfd[0] is read, pfd[1] is</span>
<a name="l00090"></a>00090 <span class="comment"> write */</span>
<a name="l00091"></a>00091 <span class="keywordtype">int</span> res;
<a name="l00092"></a>00092
<a name="l00093"></a>00093 <span class="keywordflow">if</span> (prog == NULL)
<a name="l00094"></a>00094 {
<a name="l00095"></a>00095 prog = getenv (<span class="stringliteral">"SIM_DISP_PROG"</span>);
<a name="l00096"></a>00096 <span class="keywordflow">if</span> (prog == NULL)
<a name="l00097"></a>00097 <span class="keywordflow">return</span> -1;
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099
<a name="l00100"></a>00100 <span class="comment">/* Open a pipe for writing from the simulator to the display program. </span>
<a name="l00101"></a>00101 <span class="comment"> We don't want to use popen() since the display program might need to </span>
<a name="l00102"></a>00102 <span class="comment"> use stdin/stdout for it's own uses. */</span>
<a name="l00103"></a>00103
<a name="l00104"></a>00104 res = pipe (pfd);
<a name="l00105"></a>00105 <span class="keywordflow">if</span> (res &lt; 0)
<a name="l00106"></a>00106 {
<a name="l00107"></a>00107 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"pipe failed: %s\n"</span>, strerror (errno));
<a name="l00108"></a>00108 <span class="keywordflow">return</span> -1;
<a name="l00109"></a>00109 }
<a name="l00110"></a>00110
<a name="l00111"></a>00111 <span class="comment">/* Fork off a new process. */</span>
<a name="l00112"></a>00112
<a name="l00113"></a>00113 pid = fork ();
<a name="l00114"></a>00114 <span class="keywordflow">if</span> (pid &lt; 0)
<a name="l00115"></a>00115 {
<a name="l00116"></a>00116 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"fork failed: %s\n"</span>, strerror (errno));
<a name="l00117"></a>00117 <span class="keywordflow">return</span> -1;
<a name="l00118"></a>00118 }
<a name="l00119"></a>00119 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (pid &gt; 0) <span class="comment">/* parent process */</span>
<a name="l00120"></a>00120 {
<a name="l00121"></a>00121 <span class="comment">/* close the read side of the pipe */</span>
<a name="l00122"></a>00122 close (pfd[0]);
<a name="l00123"></a>00123
<a name="l00124"></a>00124 <span class="comment">/* remember the child's pid */</span>
<a name="l00125"></a>00125 global_child_pid = pid;
<a name="l00126"></a>00126
<a name="l00127"></a>00127 global_pipe_fd = pfd[1];
<a name="l00128"></a>00128 <span class="keywordflow">return</span> global_pipe_fd;
<a name="l00129"></a>00129 }
<a name="l00130"></a>00130 <span class="keywordflow">else</span> <span class="comment">/* child process */</span>
<a name="l00131"></a>00131 {
<a name="l00132"></a>00132 <span class="keywordtype">char</span> pfd_env[20];
<a name="l00133"></a>00133 <span class="keywordtype">char</span> fl_sz[20], sr_sz[20], sr_start[20], eep_sz[20];
<a name="l00134"></a>00134 <span class="keywordtype">char</span> spfd[10];
<a name="l00135"></a>00135
<a name="l00136"></a>00136 <span class="comment">/* close the write side of the pipe */</span>
<a name="l00137"></a>00137 close (pfd[1]);
<a name="l00138"></a>00138
<a name="l00139"></a>00139 <span class="comment">/* setup the args for display program */</span>
<a name="l00140"></a>00140 snprintf (fl_sz, <span class="keyword">sizeof</span> (fl_sz) - 1, <span class="stringliteral">"%d"</span>, flash_sz);
<a name="l00141"></a>00141 snprintf (sr_sz, <span class="keyword">sizeof</span> (sr_sz) - 1, <span class="stringliteral">"%d"</span>, sram_sz);
<a name="l00142"></a>00142 snprintf (sr_start, <span class="keyword">sizeof</span> (sr_start) - 1, <span class="stringliteral">"%d"</span>, sram_start);
<a name="l00143"></a>00143 snprintf (eep_sz, <span class="keyword">sizeof</span> (eep_sz) - 1, <span class="stringliteral">"%d"</span>, eeprom_sz);
<a name="l00144"></a>00144 snprintf (spfd, <span class="keyword">sizeof</span> (spfd) - 1, <span class="stringliteral">"%d"</span>, pfd[0]);
<a name="l00145"></a>00145
<a name="l00146"></a>00146 <span class="comment">/* set the SIM_PIPE_FD env variable */</span>
<a name="l00147"></a>00147 snprintf (pfd_env, <span class="keyword">sizeof</span> (pfd_env), <span class="stringliteral">"SIM_PIPE_FD=%d"</span>, pfd[0]);
<a name="l00148"></a>00148 putenv (pfd_env);
<a name="l00149"></a>00149
<a name="l00150"></a>00150 <span class="comment">/* The user can specify not to use an xterm since some display</span>
<a name="l00151"></a>00151 <span class="comment"> programs might not need (or want) to be run in an xterm. For</span>
<a name="l00152"></a>00152 <span class="comment"> example, a gtk+ program would be able to handle it's own</span>
<a name="l00153"></a>00153 <span class="comment"> windowing. Of course, starting 'prog' up with it's own xterm, will</span>
<a name="l00154"></a>00154 <span class="comment"> not hurt and 'prog' will put stdout/stderr there instead of mixing</span>
<a name="l00155"></a>00155 <span class="comment"> with simulavr's output. The default is to start prog in an</span>
<a name="l00156"></a>00156 <span class="comment"> xterm. */</span>
<a name="l00157"></a>00157
<a name="l00158"></a>00158 <span class="keywordflow">if</span> (no_xterm)
<a name="l00159"></a>00159 {
<a name="l00160"></a>00160 execlp (prog, prog, <span class="stringliteral">"--pfd"</span>, spfd, fl_sz, sr_sz, sr_start, eep_sz,
<a name="l00161"></a>00161 NULL);
<a name="l00162"></a>00162 }
<a name="l00163"></a>00163 <span class="keywordflow">else</span>
<a name="l00164"></a>00164 {
<a name="l00165"></a>00165 <span class="comment">/* try to start up the display program in it's own xterm */</span>
<a name="l00166"></a>00166 execlp (<span class="stringliteral">"xterm"</span>, <span class="stringliteral">"xterm"</span>, <span class="stringliteral">"-geom"</span>, <span class="stringliteral">"100x50"</span>, <span class="stringliteral">"-e"</span>, prog, <span class="stringliteral">"--pfd"</span>,
<a name="l00167"></a>00167 spfd, fl_sz, sr_sz, sr_start, eep_sz, NULL);
<a name="l00168"></a>00168 }
<a name="l00169"></a>00169
<a name="l00170"></a>00170 <span class="comment">/* if the exec returns, an error occurred */</span>
<a name="l00171"></a>00171 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"exec failed: %s\n"</span>, strerror (errno));
<a name="l00172"></a>00172 _exit (1);
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174
<a name="l00175"></a>00175 <span class="keywordflow">return</span> -1; <span class="comment">/* should never get here */</span>
<a name="l00176"></a>00176 }
<a name="l00177"></a>00177 <span class="comment"></span>
<a name="l00178"></a>00178 <span class="comment">/** \brief Close a display and send coprocess a quit message. */</span>
<a name="l00179"></a>00179
<a name="l00180"></a>00180 <span class="keywordtype">void</span>
<a name="l00181"></a><a class="code" href="display_8c.html#428c3bdca61ba3679fbf3c7c8356c8f6">00181</a> <a class="code" href="display_8c.html#428c3bdca61ba3679fbf3c7c8356c8f6" title="Close a display and send coprocess a quit message.">display_close</a> (<span class="keywordtype">void</span>)
<a name="l00182"></a>00182 {
<a name="l00183"></a>00183 <span class="keywordflow">if</span> (global_pipe_fd &lt; 0)
<a name="l00184"></a>00184 <span class="keywordflow">return</span>;
<a name="l00185"></a>00185
<a name="l00186"></a>00186 <a class="code" href="display_8c.html#f45795a80967d9faeea06240281f34e6" title="Encode the message and send to display.">display_send_msg</a> (<span class="stringliteral">"q"</span>);
<a name="l00187"></a>00187 close (global_pipe_fd);
<a name="l00188"></a>00188 global_pipe_fd = -1;
<a name="l00189"></a>00189
<a name="l00190"></a>00190 kill (global_child_pid, SIGINT);
<a name="l00191"></a>00191 waitpid (0, NULL, 0);
<a name="l00192"></a>00192 }
<a name="l00193"></a>00193
<a name="l00194"></a>00194 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>
<a name="l00195"></a>00195 checksum (<span class="keywordtype">char</span> *s)
<a name="l00196"></a>00196 {
<a name="l00197"></a>00197 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> CC = 0;
<a name="l00198"></a>00198 <span class="keywordflow">while</span> (*s)
<a name="l00199"></a>00199 {
<a name="l00200"></a>00200 CC += *s;
<a name="l00201"></a>00201 s++;
<a name="l00202"></a>00202 }
<a name="l00203"></a>00203
<a name="l00204"></a>00204 <span class="keywordflow">return</span> CC;
<a name="l00205"></a>00205 }
<a name="l00206"></a>00206 <span class="comment"></span>
<a name="l00207"></a>00207 <span class="comment">/** \brief Encode the message and send to display.</span>
<a name="l00208"></a>00208 <span class="comment"> \param msg The message string to be sent to the display process.</span>
<a name="l00209"></a>00209 <span class="comment"></span>
<a name="l00210"></a>00210 <span class="comment"> Encoding is the same as that used by the gdb remote protocol: '\$...\#CC'</span>
<a name="l00211"></a>00211 <span class="comment"> where '...' is msg, CC is checksum. There is no newline termination for</span>
<a name="l00212"></a>00212 <span class="comment"> encoded messages.</span>
<a name="l00213"></a>00213 <span class="comment"></span>
<a name="l00214"></a>00214 <span class="comment"> FIXME: TRoth: This should be a private function. It is only public so that</span>
<a name="l00215"></a>00215 <span class="comment"> dtest.c can be kept simple. dtest.c should be changed to avoid direct use</span>
<a name="l00216"></a>00216 <span class="comment"> of this function. [dtest.c has served it's purpose and will be retired</span>
<a name="l00217"></a>00217 <span class="comment"> soon.] */</span>
<a name="l00218"></a>00218
<a name="l00219"></a>00219 <span class="keywordtype">void</span>
<a name="l00220"></a><a class="code" href="display_8c.html#f45795a80967d9faeea06240281f34e6">00220</a> <a class="code" href="display_8c.html#f45795a80967d9faeea06240281f34e6" title="Encode the message and send to display.">display_send_msg</a> (<span class="keywordtype">char</span> *msg)
<a name="l00221"></a>00221 {
<a name="l00222"></a>00222 <span class="keywordtype">int</span> len = strlen (msg) + 4 + 1;
<a name="l00223"></a>00223 <span class="keywordtype">int</span> res;
<a name="l00224"></a>00224 <span class="keywordtype">char</span> *enc_msg; <span class="comment">/* the encoded msg */</span>
<a name="l00225"></a>00225
<a name="l00226"></a>00226 enc_msg = <a class="code" href="avrmalloc_8c.html#ac6d810b48b67b90412badbd4b71f4e3" title="Macro for allocating memory and initializing it to zero.">avr_new0</a> (<span class="keywordtype">char</span>, len + 1);
<a name="l00227"></a>00227
<a name="l00228"></a>00228 snprintf (enc_msg, len, <span class="stringliteral">"$%s#%02x"</span>, msg, checksum (msg));
<a name="l00229"></a>00229 <span class="preprocessor">#if defined(DISP_DEBUG_OUTPUT_ON)</span>
<a name="l00230"></a>00230 <span class="preprocessor"></span> fprintf (stderr, <span class="stringliteral">"DISP: %s\n"</span>, enc_msg);
<a name="l00231"></a>00231 <span class="preprocessor">#endif</span>
<a name="l00232"></a>00232 <span class="preprocessor"></span>
<a name="l00233"></a>00233 res = write (global_pipe_fd, enc_msg, len);
<a name="l00234"></a>00234 <span class="keywordflow">if</span> ((res &lt; 0) &amp;&amp; (errno == EINTR))
<a name="l00235"></a>00235 {
<a name="l00236"></a>00236 <span class="comment">/* write() was interrupted, try again and if it still fails, let it be</span>
<a name="l00237"></a>00237 <span class="comment"> fatal. */</span>
<a name="l00238"></a>00238 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"Interrupted write()\n"</span>);
<a name="l00239"></a>00239 res = write (global_pipe_fd, enc_msg, len);
<a name="l00240"></a>00240 }
<a name="l00241"></a>00241 <span class="keywordflow">if</span> (res &lt; 0)
<a name="l00242"></a>00242 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"write failed: %s\n"</span>, strerror (errno));
<a name="l00243"></a>00243 <span class="keywordflow">if</span> (res &lt; len)
<a name="l00244"></a>00244 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"incomplete write\n"</span>);
<a name="l00245"></a>00245
<a name="l00246"></a>00246 <a class="code" href="avrmalloc_8c.html#082a9d6d40f5e8bad64441ad950ec12c" title="Free malloc&amp;#39;d memory.">avr_free</a> (enc_msg);
<a name="l00247"></a>00247 }
<a name="l00248"></a>00248
<a name="l00249"></a>00249 <span class="keyword">static</span> <span class="keywordtype">char</span> global_buf[MAX_BUF + 1];
<a name="l00250"></a>00250 <span class="comment"></span>
<a name="l00251"></a>00251 <span class="comment">/** \brief Update the time in the display.</span>
<a name="l00252"></a>00252 <span class="comment"> \param clock The new time in number of clocks. */</span>
<a name="l00253"></a>00253
<a name="l00254"></a>00254 <span class="keywordtype">void</span>
<a name="l00255"></a><a class="code" href="display_8c.html#e210ab2ee875db342dcd52d43fa47693">00255</a> <a class="code" href="display_8c.html#e210ab2ee875db342dcd52d43fa47693" title="Update the time in the display.">display_clock</a> (<span class="keywordtype">int</span> clock)
<a name="l00256"></a>00256 {
<a name="l00257"></a>00257 <span class="keywordflow">if</span> (global_pipe_fd &lt; 0)
<a name="l00258"></a>00258 <span class="keywordflow">return</span>;
<a name="l00259"></a>00259
<a name="l00260"></a>00260 snprintf (global_buf, MAX_BUF, <span class="stringliteral">"n%x"</span>, clock);
<a name="l00261"></a>00261 global_buf[MAX_BUF] = <span class="charliteral">'\0'</span>;
<a name="l00262"></a>00262 <a class="code" href="display_8c.html#f45795a80967d9faeea06240281f34e6" title="Encode the message and send to display.">display_send_msg</a> (global_buf);
<a name="l00263"></a>00263 }
<a name="l00264"></a>00264 <span class="comment"></span>
<a name="l00265"></a>00265 <span class="comment">/** \brief Update the Program Counter in the display.</span>
<a name="l00266"></a>00266 <span class="comment"> \param val The new value of the program counter. */</span>
<a name="l00267"></a>00267
<a name="l00268"></a>00268 <span class="keywordtype">void</span>
<a name="l00269"></a><a class="code" href="display_8c.html#2a7b52120c3b22bf9045b473433a3590">00269</a> <a class="code" href="display_8c.html#2a7b52120c3b22bf9045b473433a3590" title="Update the Program Counter in the display.">display_pc</a> (<span class="keywordtype">int</span> val)
<a name="l00270"></a>00270 {
<a name="l00271"></a>00271 <span class="keywordflow">if</span> (global_pipe_fd &lt; 0)
<a name="l00272"></a>00272 <span class="keywordflow">return</span>;
<a name="l00273"></a>00273
<a name="l00274"></a>00274 snprintf (global_buf, MAX_BUF, <span class="stringliteral">"p%x"</span>, val);
<a name="l00275"></a>00275 global_buf[MAX_BUF] = <span class="charliteral">'\0'</span>;
<a name="l00276"></a>00276 <a class="code" href="display_8c.html#f45795a80967d9faeea06240281f34e6" title="Encode the message and send to display.">display_send_msg</a> (global_buf);
<a name="l00277"></a>00277 }
<a name="l00278"></a>00278 <span class="comment"></span>
<a name="l00279"></a>00279 <span class="comment">/** \brief Update a register in the display.</span>
<a name="l00280"></a>00280 <span class="comment"> \param reg The register number.</span>
<a name="l00281"></a>00281 <span class="comment"> \param val The new value of the register. */</span>
<a name="l00282"></a>00282
<a name="l00283"></a>00283 <span class="keywordtype">void</span>
<a name="l00284"></a><a class="code" href="display_8c.html#225f48cf9ff069c974e3074754f6dbd1">00284</a> <a class="code" href="display_8c.html#225f48cf9ff069c974e3074754f6dbd1" title="Update a register in the display.">display_reg</a> (<span class="keywordtype">int</span> reg, uint8_t val)
<a name="l00285"></a>00285 {
<a name="l00286"></a>00286 <span class="keywordflow">if</span> (global_pipe_fd &lt; 0)
<a name="l00287"></a>00287 <span class="keywordflow">return</span>;
<a name="l00288"></a>00288
<a name="l00289"></a>00289 snprintf (global_buf, MAX_BUF, <span class="stringliteral">"r%x:%02x"</span>, reg, val);
<a name="l00290"></a>00290 global_buf[MAX_BUF] = <span class="charliteral">'\0'</span>;
<a name="l00291"></a>00291 <a class="code" href="display_8c.html#f45795a80967d9faeea06240281f34e6" title="Encode the message and send to display.">display_send_msg</a> (global_buf);
<a name="l00292"></a>00292 }
<a name="l00293"></a>00293 <span class="comment"></span>
<a name="l00294"></a>00294 <span class="comment">/** \brief Update an IO register in the display.</span>
<a name="l00295"></a>00295 <span class="comment"> \param reg The IO register number.</span>
<a name="l00296"></a>00296 <span class="comment"> \param val The new value of the register. */</span>
<a name="l00297"></a>00297
<a name="l00298"></a>00298 <span class="keywordtype">void</span>
<a name="l00299"></a><a class="code" href="display_8c.html#ed9707596c157777dc33fe1371ded7fc">00299</a> <a class="code" href="display_8c.html#ed9707596c157777dc33fe1371ded7fc" title="Update an IO register in the display.">display_io_reg</a> (<span class="keywordtype">int</span> reg, uint8_t val)
<a name="l00300"></a>00300 {
<a name="l00301"></a>00301 <span class="keywordflow">if</span> (global_pipe_fd &lt; 0)
<a name="l00302"></a>00302 <span class="keywordflow">return</span>;
<a name="l00303"></a>00303
<a name="l00304"></a>00304 snprintf (global_buf, MAX_BUF, <span class="stringliteral">"i%x:%02x"</span>, reg, val);
<a name="l00305"></a>00305 global_buf[MAX_BUF] = <span class="charliteral">'\0'</span>;
<a name="l00306"></a>00306 <a class="code" href="display_8c.html#f45795a80967d9faeea06240281f34e6" title="Encode the message and send to display.">display_send_msg</a> (global_buf);
<a name="l00307"></a>00307 }
<a name="l00308"></a>00308 <span class="comment"></span>
<a name="l00309"></a>00309 <span class="comment">/** \brief Specify a name for an IO register.</span>
<a name="l00310"></a>00310 <span class="comment"> \param reg The IO register number.</span>
<a name="l00311"></a>00311 <span class="comment"> \param name The symbolic name of the register.</span>
<a name="l00312"></a>00312 <span class="comment"></span>
<a name="l00313"></a>00313 <span class="comment"> Names of IO registers may be different from device to device. */</span>
<a name="l00314"></a>00314
<a name="l00315"></a>00315 <span class="keywordtype">void</span>
<a name="l00316"></a><a class="code" href="display_8c.html#e2e93695af3a8b1676402cebc82d1b3f">00316</a> <a class="code" href="display_8c.html#e2e93695af3a8b1676402cebc82d1b3f" title="Specify a name for an IO register.">display_io_reg_name</a> (<span class="keywordtype">int</span> reg, <span class="keywordtype">char</span> *name)
<a name="l00317"></a>00317 {
<a name="l00318"></a>00318 <span class="keywordflow">if</span> (global_pipe_fd &lt; 0)
<a name="l00319"></a>00319 <span class="keywordflow">return</span>;
<a name="l00320"></a>00320
<a name="l00321"></a>00321 snprintf (global_buf, MAX_BUF, <span class="stringliteral">"I%x:%s"</span>, reg, name);
<a name="l00322"></a>00322 global_buf[MAX_BUF] = <span class="charliteral">'\0'</span>;
<a name="l00323"></a>00323 <a class="code" href="display_8c.html#f45795a80967d9faeea06240281f34e6" title="Encode the message and send to display.">display_send_msg</a> (global_buf);
<a name="l00324"></a>00324 }
<a name="l00325"></a>00325 <span class="comment"></span>
<a name="l00326"></a>00326 <span class="comment">/** \brief Update a block of flash addresses in the display.</span>
<a name="l00327"></a>00327 <span class="comment"> \param addr Address of beginning of the block.</span>
<a name="l00328"></a>00328 <span class="comment"> \param len Length of the block (number of words).</span>
<a name="l00329"></a>00329 <span class="comment"> \param vals Pointer to an array of \a len words.</span>
<a name="l00330"></a>00330 <span class="comment"></span>
<a name="l00331"></a>00331 <span class="comment"> The display will update each addr of the block to the coresponding value</span>
<a name="l00332"></a>00332 <span class="comment"> in the \a vals array.</span>
<a name="l00333"></a>00333 <span class="comment"></span>
<a name="l00334"></a>00334 <span class="comment"> Each address in the flash references a single 16-bit wide word (or opcode</span>
<a name="l00335"></a>00335 <span class="comment"> or instruction). Therefore, flash addresses are aligned to 16-bit</span>
<a name="l00336"></a>00336 <span class="comment"> boundaries. It is simplest to consider the flash an array of 16-bit values</span>
<a name="l00337"></a>00337 <span class="comment"> indexed by the address. */</span>
<a name="l00338"></a>00338
<a name="l00339"></a>00339 <span class="keywordtype">void</span>
<a name="l00340"></a><a class="code" href="display_8c.html#69d6536d741f20da943fb64373bbae11">00340</a> <a class="code" href="display_8c.html#69d6536d741f20da943fb64373bbae11" title="Update a block of flash addresses in the display.">display_flash</a> (<span class="keywordtype">int</span> addr, <span class="keywordtype">int</span> len, uint16_t * vals)
<a name="l00341"></a>00341 {
<a name="l00342"></a>00342 <span class="keywordtype">int</span> bytes;
<a name="l00343"></a>00343 <span class="keywordtype">int</span> i;
<a name="l00344"></a>00344
<a name="l00345"></a>00345 <span class="keywordflow">if</span> (global_pipe_fd &lt; 0)
<a name="l00346"></a>00346 <span class="keywordflow">return</span>;
<a name="l00347"></a>00347
<a name="l00348"></a>00348 bytes = snprintf (global_buf, MAX_BUF, <span class="stringliteral">"f%x,%x:"</span>, addr, len);
<a name="l00349"></a>00349
<a name="l00350"></a>00350 <span class="keywordflow">for</span> (i = 0; i &lt; len; i++)
<a name="l00351"></a>00351 {
<a name="l00352"></a>00352 <span class="keywordflow">if</span> (MAX_BUF - bytes &lt; 0)
<a name="l00353"></a>00353 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"buffer overflow"</span>);
<a name="l00354"></a>00354
<a name="l00355"></a>00355 bytes +=
<a name="l00356"></a>00356 snprintf (global_buf + bytes, MAX_BUF - bytes, <span class="stringliteral">"%04x"</span>, vals[i]);
<a name="l00357"></a>00357 }
<a name="l00358"></a>00358
<a name="l00359"></a>00359 global_buf[MAX_BUF] = <span class="charliteral">'\0'</span>;
<a name="l00360"></a>00360 <a class="code" href="display_8c.html#f45795a80967d9faeea06240281f34e6" title="Encode the message and send to display.">display_send_msg</a> (global_buf);
<a name="l00361"></a>00361 }
<a name="l00362"></a>00362 <span class="comment"></span>
<a name="l00363"></a>00363 <span class="comment">/** \brief Update a block of sram addresses in the display.</span>
<a name="l00364"></a>00364 <span class="comment"> \param addr Address of beginning of the block.</span>
<a name="l00365"></a>00365 <span class="comment"> \param len Length of the block (number of bytes).</span>
<a name="l00366"></a>00366 <span class="comment"> \param vals Pointer to an array of \a len bytes.</span>
<a name="l00367"></a>00367 <span class="comment"></span>
<a name="l00368"></a>00368 <span class="comment"> The display will update each addr of the block to the coresponding value</span>
<a name="l00369"></a>00369 <span class="comment"> in the \a vals array. */</span>
<a name="l00370"></a>00370
<a name="l00371"></a>00371 <span class="keywordtype">void</span>
<a name="l00372"></a><a class="code" href="display_8c.html#8cfda7ebd92c20bf3376e0355f80bebe">00372</a> <a class="code" href="display_8c.html#8cfda7ebd92c20bf3376e0355f80bebe" title="Update a block of sram addresses in the display.">display_sram</a> (<span class="keywordtype">int</span> addr, <span class="keywordtype">int</span> len, uint8_t * vals)
<a name="l00373"></a>00373 {
<a name="l00374"></a>00374 <span class="keywordtype">int</span> bytes;
<a name="l00375"></a>00375 <span class="keywordtype">int</span> i;
<a name="l00376"></a>00376
<a name="l00377"></a>00377 <span class="keywordflow">if</span> (global_pipe_fd &lt; 0)
<a name="l00378"></a>00378 <span class="keywordflow">return</span>;
<a name="l00379"></a>00379
<a name="l00380"></a>00380 bytes = snprintf (global_buf, MAX_BUF, <span class="stringliteral">"s%x,%x:"</span>, addr, len);
<a name="l00381"></a>00381
<a name="l00382"></a>00382 <span class="keywordflow">for</span> (i = 0; i &lt; len; i++)
<a name="l00383"></a>00383 {
<a name="l00384"></a>00384 <span class="keywordflow">if</span> (MAX_BUF - bytes &lt; 0)
<a name="l00385"></a>00385 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"buffer overflow"</span>);
<a name="l00386"></a>00386
<a name="l00387"></a>00387 bytes +=
<a name="l00388"></a>00388 snprintf (global_buf + bytes, MAX_BUF - bytes, <span class="stringliteral">"%02x"</span>, vals[i]);
<a name="l00389"></a>00389 }
<a name="l00390"></a>00390
<a name="l00391"></a>00391 global_buf[MAX_BUF] = <span class="charliteral">'\0'</span>;
<a name="l00392"></a>00392 <a class="code" href="display_8c.html#f45795a80967d9faeea06240281f34e6" title="Encode the message and send to display.">display_send_msg</a> (global_buf);
<a name="l00393"></a>00393 }
<a name="l00394"></a>00394 <span class="comment"></span>
<a name="l00395"></a>00395 <span class="comment">/** \brief Update a block of eeprom addresses in the display.</span>
<a name="l00396"></a>00396 <span class="comment"> \param addr Address of beginning of the block.</span>
<a name="l00397"></a>00397 <span class="comment"> \param len Length of the block (number of bytes).</span>
<a name="l00398"></a>00398 <span class="comment"> \param vals Pointer to an array of \a len bytes.</span>
<a name="l00399"></a>00399 <span class="comment"></span>
<a name="l00400"></a>00400 <span class="comment"> The display will update each addr of the block to the coresponding value</span>
<a name="l00401"></a>00401 <span class="comment"> in the \a vals array. */</span>
<a name="l00402"></a>00402
<a name="l00403"></a>00403 <span class="keywordtype">void</span>
<a name="l00404"></a><a class="code" href="display_8c.html#6a425136a8b941eba6671bbea330283b">00404</a> <a class="code" href="display_8c.html#6a425136a8b941eba6671bbea330283b" title="Update a block of eeprom addresses in the display.">display_eeprom</a> (<span class="keywordtype">int</span> addr, <span class="keywordtype">int</span> len, uint8_t * vals)
<a name="l00405"></a>00405 {
<a name="l00406"></a>00406 <span class="keywordtype">int</span> bytes;
<a name="l00407"></a>00407 <span class="keywordtype">int</span> i;
<a name="l00408"></a>00408
<a name="l00409"></a>00409 <span class="keywordflow">if</span> (global_pipe_fd &lt; 0)
<a name="l00410"></a>00410 <span class="keywordflow">return</span>;
<a name="l00411"></a>00411
<a name="l00412"></a>00412 bytes = snprintf (global_buf, MAX_BUF, <span class="stringliteral">"e%x,%x:"</span>, addr, len);
<a name="l00413"></a>00413
<a name="l00414"></a>00414 <span class="keywordflow">for</span> (i = 0; i &lt; len; i++)
<a name="l00415"></a>00415 {
<a name="l00416"></a>00416 <span class="keywordflow">if</span> (MAX_BUF - bytes &lt; 0)
<a name="l00417"></a>00417 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"buffer overflow"</span>);
<a name="l00418"></a>00418
<a name="l00419"></a>00419 bytes +=
<a name="l00420"></a>00420 snprintf (global_buf + bytes, MAX_BUF - bytes, <span class="stringliteral">"%02x"</span>, vals[i]);
<a name="l00421"></a>00421 }
<a name="l00422"></a>00422
<a name="l00423"></a>00423 global_buf[MAX_BUF] = <span class="charliteral">'\0'</span>;
<a name="l00424"></a>00424 <a class="code" href="display_8c.html#f45795a80967d9faeea06240281f34e6" title="Encode the message and send to display.">display_send_msg</a> (global_buf);
<a name="l00425"></a>00425 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,536 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>display.c File Reference</h1>Interface for using display coprocesses. <a href="#_details">More...</a>
<p>
<p>
<a href="display_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Enumerations</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">enum &nbsp;</td><td class="memItemRight" valign="bottom">{ <b>MAX_BUF</b> = 1024
}</td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="display_8c.html#aeea9e0008fcf18c0514a45e99a7f4d2">display_open</a> (char *prog, int no_xterm, int flash_sz, int sram_sz, int sram_start, int eeprom_sz)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="display_8c.html#428c3bdca61ba3679fbf3c7c8356c8f6">display_close</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="display_8c.html#f45795a80967d9faeea06240281f34e6">display_send_msg</a> (char *msg)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="display_8c.html#e210ab2ee875db342dcd52d43fa47693">display_clock</a> (int clock)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="display_8c.html#2a7b52120c3b22bf9045b473433a3590">display_pc</a> (int val)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="display_8c.html#225f48cf9ff069c974e3074754f6dbd1">display_reg</a> (int reg, uint8_t val)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="display_8c.html#ed9707596c157777dc33fe1371ded7fc">display_io_reg</a> (int reg, uint8_t val)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="display_8c.html#e2e93695af3a8b1676402cebc82d1b3f">display_io_reg_name</a> (int reg, char *name)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="display_8c.html#69d6536d741f20da943fb64373bbae11">display_flash</a> (int addr, int len, uint16_t *vals)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="display_8c.html#8cfda7ebd92c20bf3376e0355f80bebe">display_sram</a> (int addr, int len, uint8_t *vals)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="display_8c.html#6a425136a8b941eba6671bbea330283b">display_eeprom</a> (int addr, int len, uint8_t *vals)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Interface for using display coprocesses.
<p>
Simulavr has the ability to use a coprocess to display register and memory values in near real time.
<p>Definition in file <a class="el" href="display_8c-source.html">display.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="aeea9e0008fcf18c0514a45e99a7f4d2"></a><!-- doxytag: member="display.c::display_open" ref="aeea9e0008fcf18c0514a45e99a7f4d2" args="(char *prog, int no_xterm, int flash_sz, int sram_sz, int sram_start, int eeprom_sz)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int display_open </td>
<td>(</td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>prog</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>no_xterm</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>flash_sz</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>sram_sz</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>sram_start</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>eeprom_sz</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Open a display as a coprocess.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>prog</em>&nbsp;</td><td>The program to use as a display coprocess. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>no_xterm</em>&nbsp;</td><td>If non-zero, don't run the disply in an xterm. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>flash_sz</em>&nbsp;</td><td>The size of the flash memory space in bytes. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>sram_sz</em>&nbsp;</td><td>The size of the sram memory space in bytes. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>sram_start</em>&nbsp;</td><td>The addr of the first byte of sram (usually 0x60 or 0x100). </td></tr>
<tr><td valign="top"></td><td valign="top"><em>eeprom_sz</em>&nbsp;</td><td>The size of the eeprom memory space in bytes.</td></tr>
</table>
</dl>
Try to start up a helper program as a child process for displaying registers and memory. If the prog argument is NULL, don't start up a display.<p>
Returns an open file descriptor of a pipe used to send data to the helper program.<p>
Returns -1 if something failed.
<p>Definition at line <a class="el" href="display_8c-source.html#l00085">85</a> of file <a class="el" href="display_8c-source.html">display.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00046">avr_warning</a>.</p>
</div>
</div><p>
<a class="anchor" name="428c3bdca61ba3679fbf3c7c8356c8f6"></a><!-- doxytag: member="display.c::display_close" ref="428c3bdca61ba3679fbf3c7c8356c8f6" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void display_close </td>
<td>(</td>
<td class="paramtype">void&nbsp;</td>
<td class="paramname"> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Close a display and send coprocess a quit message.
<p>
<p>Definition at line <a class="el" href="display_8c-source.html#l00181">181</a> of file <a class="el" href="display_8c-source.html">display.c</a>.</p>
<p>References <a class="el" href="display_8c-source.html#l00220">display_send_msg()</a>.</p>
</div>
</div><p>
<a class="anchor" name="f45795a80967d9faeea06240281f34e6"></a><!-- doxytag: member="display.c::display_send_msg" ref="f45795a80967d9faeea06240281f34e6" args="(char *msg)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void display_send_msg </td>
<td>(</td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>msg</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Encode the message and send to display.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>msg</em>&nbsp;</td><td>The message string to be sent to the display process.</td></tr>
</table>
</dl>
Encoding is the same as that used by the gdb remote protocol: '$...#CC' where '...' is msg, CC is checksum. There is no newline termination for encoded messages.<p>
FIXME: TRoth: This should be a private function. It is only public so that dtest.c can be kept simple. dtest.c should be changed to avoid direct use of this function. [dtest.c has served it's purpose and will be retired soon.]
<p>Definition at line <a class="el" href="display_8c-source.html#l00220">220</a> of file <a class="el" href="display_8c-source.html">display.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, <a class="el" href="avrmalloc_8c-source.html#l00187">avr_free()</a>, <a class="el" href="avrmalloc_8c-source.html#l00067">avr_new0</a>, and <a class="el" href="avrerror_8c-source.html#l00046">avr_warning</a>.</p>
<p>Referenced by <a class="el" href="display_8c-source.html#l00255">display_clock()</a>, <a class="el" href="display_8c-source.html#l00181">display_close()</a>, <a class="el" href="display_8c-source.html#l00404">display_eeprom()</a>, <a class="el" href="display_8c-source.html#l00340">display_flash()</a>, <a class="el" href="display_8c-source.html#l00299">display_io_reg()</a>, <a class="el" href="display_8c-source.html#l00316">display_io_reg_name()</a>, <a class="el" href="display_8c-source.html#l00269">display_pc()</a>, <a class="el" href="display_8c-source.html#l00284">display_reg()</a>, and <a class="el" href="display_8c-source.html#l00372">display_sram()</a>.</p>
</div>
</div><p>
<a class="anchor" name="e210ab2ee875db342dcd52d43fa47693"></a><!-- doxytag: member="display.c::display_clock" ref="e210ab2ee875db342dcd52d43fa47693" args="(int clock)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void display_clock </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>clock</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Update the time in the display.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>clock</em>&nbsp;</td><td>The new time in number of clocks. </td></tr>
</table>
</dl>
<p>Definition at line <a class="el" href="display_8c-source.html#l00255">255</a> of file <a class="el" href="display_8c-source.html">display.c</a>.</p>
<p>References <a class="el" href="display_8c-source.html#l00220">display_send_msg()</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l01194">avr_core_reset()</a>.</p>
</div>
</div><p>
<a class="anchor" name="2a7b52120c3b22bf9045b473433a3590"></a><!-- doxytag: member="display.c::display_pc" ref="2a7b52120c3b22bf9045b473433a3590" args="(int val)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void display_pc </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>val</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Update the Program Counter in the display.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>val</em>&nbsp;</td><td>The new value of the program counter. </td></tr>
</table>
</dl>
<p>Definition at line <a class="el" href="display_8c-source.html#l00269">269</a> of file <a class="el" href="display_8c-source.html">display.c</a>.</p>
<p>References <a class="el" href="display_8c-source.html#l00220">display_send_msg()</a>.</p>
</div>
</div><p>
<a class="anchor" name="225f48cf9ff069c974e3074754f6dbd1"></a><!-- doxytag: member="display.c::display_reg" ref="225f48cf9ff069c974e3074754f6dbd1" args="(int reg, uint8_t val)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void display_reg </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>reg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&nbsp;</td>
<td class="paramname"> <em>val</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Update a register in the display.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>reg</em>&nbsp;</td><td>The register number. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>val</em>&nbsp;</td><td>The new value of the register. </td></tr>
</table>
</dl>
<p>Definition at line <a class="el" href="display_8c-source.html#l00284">284</a> of file <a class="el" href="display_8c-source.html">display.c</a>.</p>
<p>References <a class="el" href="display_8c-source.html#l00220">display_send_msg()</a>.</p>
</div>
</div><p>
<a class="anchor" name="ed9707596c157777dc33fe1371ded7fc"></a><!-- doxytag: member="display.c::display_io_reg" ref="ed9707596c157777dc33fe1371ded7fc" args="(int reg, uint8_t val)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void display_io_reg </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>reg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&nbsp;</td>
<td class="paramname"> <em>val</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Update an IO register in the display.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>reg</em>&nbsp;</td><td>The IO register number. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>val</em>&nbsp;</td><td>The new value of the register. </td></tr>
</table>
</dl>
<p>Definition at line <a class="el" href="display_8c-source.html#l00299">299</a> of file <a class="el" href="display_8c-source.html">display.c</a>.</p>
<p>References <a class="el" href="display_8c-source.html#l00220">display_send_msg()</a>.</p>
<p>Referenced by <a class="el" href="memory_8c-source.html#l00247">mem_write()</a>.</p>
</div>
</div><p>
<a class="anchor" name="e2e93695af3a8b1676402cebc82d1b3f"></a><!-- doxytag: member="display.c::display_io_reg_name" ref="e2e93695af3a8b1676402cebc82d1b3f" args="(int reg, char *name)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void display_io_reg_name </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>reg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Specify a name for an IO register.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>reg</em>&nbsp;</td><td>The IO register number. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>name</em>&nbsp;</td><td>The symbolic name of the register.</td></tr>
</table>
</dl>
Names of IO registers may be different from device to device.
<p>Definition at line <a class="el" href="display_8c-source.html#l00316">316</a> of file <a class="el" href="display_8c-source.html">display.c</a>.</p>
<p>References <a class="el" href="display_8c-source.html#l00220">display_send_msg()</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l00723">avr_core_io_display_names()</a>.</p>
</div>
</div><p>
<a class="anchor" name="69d6536d741f20da943fb64373bbae11"></a><!-- doxytag: member="display.c::display_flash" ref="69d6536d741f20da943fb64373bbae11" args="(int addr, int len, uint16_t *vals)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void display_flash </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>len</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint16_t *&nbsp;</td>
<td class="paramname"> <em>vals</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Update a block of flash addresses in the display.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>addr</em>&nbsp;</td><td>Address of beginning of the block. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>len</em>&nbsp;</td><td>Length of the block (number of words). </td></tr>
<tr><td valign="top"></td><td valign="top"><em>vals</em>&nbsp;</td><td>Pointer to an array of <em>len</em> words.</td></tr>
</table>
</dl>
The display will update each addr of the block to the coresponding value in the <em>vals</em> array.<p>
Each address in the flash references a single 16-bit wide word (or opcode or instruction). Therefore, flash addresses are aligned to 16-bit boundaries. It is simplest to consider the flash an array of 16-bit values indexed by the address.
<p>Definition at line <a class="el" href="display_8c-source.html#l00340">340</a> of file <a class="el" href="display_8c-source.html">display.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="display_8c-source.html#l00220">display_send_msg()</a>.</p>
<p>Referenced by <a class="el" href="flash_8c-source.html#l00086">flash_write()</a>.</p>
</div>
</div><p>
<a class="anchor" name="8cfda7ebd92c20bf3376e0355f80bebe"></a><!-- doxytag: member="display.c::display_sram" ref="8cfda7ebd92c20bf3376e0355f80bebe" args="(int addr, int len, uint8_t *vals)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void display_sram </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>len</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t *&nbsp;</td>
<td class="paramname"> <em>vals</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Update a block of sram addresses in the display.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>addr</em>&nbsp;</td><td>Address of beginning of the block. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>len</em>&nbsp;</td><td>Length of the block (number of bytes). </td></tr>
<tr><td valign="top"></td><td valign="top"><em>vals</em>&nbsp;</td><td>Pointer to an array of <em>len</em> bytes.</td></tr>
</table>
</dl>
The display will update each addr of the block to the coresponding value in the <em>vals</em> array.
<p>Definition at line <a class="el" href="display_8c-source.html#l00372">372</a> of file <a class="el" href="display_8c-source.html">display.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="display_8c-source.html#l00220">display_send_msg()</a>.</p>
</div>
</div><p>
<a class="anchor" name="6a425136a8b941eba6671bbea330283b"></a><!-- doxytag: member="display.c::display_eeprom" ref="6a425136a8b941eba6671bbea330283b" args="(int addr, int len, uint8_t *vals)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void display_eeprom </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>len</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t *&nbsp;</td>
<td class="paramname"> <em>vals</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Update a block of eeprom addresses in the display.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>addr</em>&nbsp;</td><td>Address of beginning of the block. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>len</em>&nbsp;</td><td>Length of the block (number of bytes). </td></tr>
<tr><td valign="top"></td><td valign="top"><em>vals</em>&nbsp;</td><td>Pointer to an array of <em>len</em> bytes.</td></tr>
</table>
</dl>
The display will update each addr of the block to the coresponding value in the <em>vals</em> array.
<p>Definition at line <a class="el" href="display_8c-source.html#l00404">404</a> of file <a class="el" href="display_8c-source.html">display.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="display_8c-source.html#l00220">display_send_msg()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,23 @@
H1 { text-align: center; }
A.qindex {}
A.qindexRef {}
A.el { text-decoration: none; font-weight: bold }
A.elRef { font-weight: bold }
A.code { text-decoration: none; font-weight: normal; color: #4444ee }
A.codeRef { font-weight: normal; color: #4444ee }
A:hover { text-decoration: none; background-color: #f2f2ff }
DL.el { margin-left: -1cm }
DIV.fragment { width: 100%; border: none; background-color: #eeeeee }
DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
TD.md { background-color: #f2f2ff; font-weight: bold; }
TD.mdname1 { background-color: #f2f2ff; font-weight: bold; color: #602020; }
TD.mdname { background-color: #f2f2ff; font-weight: bold; color: #602020; width: 600px; }
DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold }
DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller }
FONT.keyword { color: #008000 }
FONT.keywordtype { color: #604020 }
FONT.keywordflow { color: #e08000 }
FONT.comment { color: #800000 }
FONT.preprocessor { color: #806020 }
FONT.stringliteral { color: #002080 }
FONT.charliteral { color: #008080 }

View file

@ -0,0 +1,428 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>eeprom.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: eeprom.c,v 1.20 2004/01/30 07:09:56 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003, 2004 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;errno.h&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;unistd.h&gt;</span>
<a name="l00033"></a>00033
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;sys/types.h&gt;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;sys/stat.h&gt;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;fcntl.h&gt;</span>
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include "utils.h"</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include "callback.h"</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include "op_names.h"</span>
<a name="l00044"></a>00044
<a name="l00045"></a>00045 <span class="preprocessor">#include "storage.h"</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include "flash.h"</span>
<a name="l00047"></a>00047
<a name="l00048"></a>00048 <span class="preprocessor">#include "vdevs.h"</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include "memory.h"</span>
<a name="l00050"></a>00050 <span class="preprocessor">#include "stack.h"</span>
<a name="l00051"></a>00051 <span class="preprocessor">#include "register.h"</span>
<a name="l00052"></a>00052 <span class="preprocessor">#include "sram.h"</span>
<a name="l00053"></a>00053 <span class="preprocessor">#include "eeprom.h"</span>
<a name="l00054"></a>00054 <span class="preprocessor">#include "timers.h"</span>
<a name="l00055"></a>00055 <span class="preprocessor">#include "ports.h"</span>
<a name="l00056"></a>00056
<a name="l00057"></a>00057 <span class="preprocessor">#include "avrcore.h"</span>
<a name="l00058"></a>00058
<a name="l00059"></a>00059 <span class="preprocessor">#include "display.h"</span>
<a name="l00060"></a>00060
<a name="l00061"></a>00061 <span class="keyword">static</span> uint8_t eeprom_reg_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00062"></a>00062 <span class="keyword">static</span> <span class="keywordtype">void</span> eeprom_reg_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00063"></a>00063 <span class="keyword">static</span> <span class="keywordtype">void</span> eeprom_reg_reset (VDevice *dev);
<a name="l00064"></a>00064 <span class="keyword">static</span> <span class="keywordtype">void</span> eeprom_wr_eecr (EEProm *ee, uint8_t val);
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="keyword">static</span> <span class="keywordtype">int</span> eeprom_wr_op_cb (uint64_t time, AvrClass *data);
<a name="l00067"></a>00067 <span class="keyword">static</span> <span class="keywordtype">int</span> eeprom_mwe_clr_cb (uint64_t time, AvrClass *data);
<a name="l00068"></a>00068
<a name="l00069"></a>00069 EEProm *
<a name="l00070"></a>00070 eeprom_new (<span class="keywordtype">int</span> size, uint8_t eecr_mask)
<a name="l00071"></a>00071 {
<a name="l00072"></a>00072 EEProm *eeprom;
<a name="l00073"></a>00073
<a name="l00074"></a>00074 eeprom = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (EEProm, 1);
<a name="l00075"></a>00075 eeprom_construct (eeprom, size, eecr_mask);
<a name="l00076"></a>00076 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)eeprom, eeprom_destroy);
<a name="l00077"></a>00077
<a name="l00078"></a>00078 <span class="keywordflow">return</span> eeprom;
<a name="l00079"></a>00079 }
<a name="l00080"></a>00080
<a name="l00081"></a>00081 <span class="keywordtype">void</span>
<a name="l00082"></a>00082 eeprom_construct (EEProm *eeprom, <span class="keywordtype">int</span> size, uint8_t eecr_mask)
<a name="l00083"></a>00083 {
<a name="l00084"></a>00084 <span class="keywordtype">int</span> i;
<a name="l00085"></a>00085
<a name="l00086"></a>00086 <span class="keywordflow">if</span> (eeprom == NULL)
<a name="l00087"></a>00087 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00088"></a>00088
<a name="l00089"></a>00089 eeprom-&gt;stor = storage_new (0 <span class="comment">/*base */</span> , size);
<a name="l00090"></a>00090
<a name="l00091"></a>00091 <span class="comment">/* init eeprom to ones */</span>
<a name="l00092"></a>00092 <span class="keywordflow">for</span> (i = 0; i &lt; size; i++)
<a name="l00093"></a>00093 storage_writeb (eeprom-&gt;stor, i, 0xff);
<a name="l00094"></a>00094
<a name="l00095"></a>00095 eeprom-&gt;eecr_mask = eecr_mask;
<a name="l00096"></a>00096
<a name="l00097"></a>00097 eeprom_reg_reset ((VDevice *)eeprom);
<a name="l00098"></a>00098
<a name="l00099"></a>00099 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)eeprom, eeprom_reg_read, eeprom_reg_write,
<a name="l00100"></a>00100 eeprom_reg_reset, <a class="code" href="device_8c.html#5cebfd18a219807f27e4a3f38da4a5d0" title="Default AddAddr method.">vdev_def_AddAddr</a>);
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102
<a name="l00103"></a>00103 <span class="keywordtype">void</span>
<a name="l00104"></a>00104 eeprom_destroy (<span class="keywordtype">void</span> *eeprom)
<a name="l00105"></a>00105 {
<a name="l00106"></a>00106 EEProm *_eeprom = (EEProm *)eeprom;
<a name="l00107"></a>00107
<a name="l00108"></a>00108 <span class="keywordflow">if</span> (eeprom == NULL)
<a name="l00109"></a>00109 <span class="keywordflow">return</span>;
<a name="l00110"></a>00110
<a name="l00111"></a>00111 <a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a> ((AvrClass *)_eeprom-&gt;stor);
<a name="l00112"></a>00112
<a name="l00113"></a>00113 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (eeprom);
<a name="l00114"></a>00114 }
<a name="l00115"></a>00115
<a name="l00116"></a>00116 <span class="keywordtype">int</span>
<a name="l00117"></a>00117 eeprom_get_size (EEProm *eeprom)
<a name="l00118"></a>00118 {
<a name="l00119"></a>00119 <span class="keywordflow">return</span> storage_get_size (eeprom-&gt;stor);
<a name="l00120"></a>00120 }
<a name="l00121"></a>00121
<a name="l00122"></a>00122 <span class="keyword">static</span> uint8_t
<a name="l00123"></a>00123 eeprom_reg_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00124"></a>00124 {
<a name="l00125"></a>00125 EEProm *ee = (EEProm *)dev;
<a name="l00126"></a>00126
<a name="l00127"></a>00127 <span class="keywordflow">switch</span> (addr)
<a name="l00128"></a>00128 {
<a name="l00129"></a>00129 <span class="keywordflow">case</span> EECR_ADDR:
<a name="l00130"></a>00130 <span class="keywordflow">return</span> ee-&gt;eecr;
<a name="l00131"></a>00131 <span class="keywordflow">case</span> EEDR_ADDR:
<a name="l00132"></a>00132 <span class="keywordflow">return</span> ee-&gt;eedr;
<a name="l00133"></a>00133 <span class="keywordflow">case</span> EEARL_ADDR:
<a name="l00134"></a>00134 <span class="keywordflow">return</span> ee-&gt;eearl;
<a name="l00135"></a>00135 <span class="keywordflow">case</span> EEARH_ADDR:
<a name="l00136"></a>00136 <span class="keywordflow">return</span> ee-&gt;eearh;
<a name="l00137"></a>00137 }
<a name="l00138"></a>00138 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: %d"</span>, addr);
<a name="l00139"></a>00139 <span class="keywordflow">return</span> 0;
<a name="l00140"></a>00140 }
<a name="l00141"></a>00141
<a name="l00142"></a>00142 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00143"></a>00143 eeprom_reg_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00144"></a>00144 {
<a name="l00145"></a>00145 EEProm *ee = (EEProm *)dev;
<a name="l00146"></a>00146
<a name="l00147"></a>00147 <span class="keywordflow">if</span> (ee-&gt;eecr &amp; mask_EEWE)
<a name="l00148"></a>00148 {
<a name="l00149"></a>00149 <span class="comment">/*</span>
<a name="l00150"></a>00150 <span class="comment"> * From the 8515 data sheet: The user should poll the EEWE bit before</span>
<a name="l00151"></a>00151 <span class="comment"> * starting the read operaton. If a write operation is in progress</span>
<a name="l00152"></a>00152 <span class="comment"> * when new data or address is written to the EEPROM I/O registers,</span>
<a name="l00153"></a>00153 <span class="comment"> * the write operation will be interrupted, and the result is</span>
<a name="l00154"></a>00154 <span class="comment"> * undefined.</span>
<a name="l00155"></a>00155 <span class="comment"> */</span>
<a name="l00156"></a>00156 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Attempt to write to EEPROM I/O reg during write "</span>
<a name="l00157"></a>00157 <span class="stringliteral">"operation"</span>);
<a name="l00158"></a>00158 }
<a name="l00159"></a>00159
<a name="l00160"></a>00160 <span class="keywordflow">switch</span> (addr)
<a name="l00161"></a>00161 {
<a name="l00162"></a>00162 <span class="keywordflow">case</span> EECR_ADDR:
<a name="l00163"></a>00163 eeprom_wr_eecr (ee, val);
<a name="l00164"></a>00164 <span class="keywordflow">return</span>;
<a name="l00165"></a>00165 <span class="keywordflow">case</span> EEDR_ADDR:
<a name="l00166"></a>00166 ee-&gt;eedr = val;
<a name="l00167"></a>00167 <span class="keywordflow">return</span>;
<a name="l00168"></a>00168 <span class="keywordflow">case</span> EEARL_ADDR:
<a name="l00169"></a>00169 ee-&gt;eearl = val;
<a name="l00170"></a>00170 <span class="keywordflow">return</span>;
<a name="l00171"></a>00171 <span class="keywordflow">case</span> EEARH_ADDR:
<a name="l00172"></a>00172 ee-&gt;eearh = val;
<a name="l00173"></a>00173 <span class="keywordflow">return</span>;
<a name="l00174"></a>00174 }
<a name="l00175"></a>00175 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: %d"</span>, addr);
<a name="l00176"></a>00176 }
<a name="l00177"></a>00177
<a name="l00178"></a>00178 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00179"></a>00179 eeprom_reg_reset (VDevice *dev)
<a name="l00180"></a>00180 {
<a name="l00181"></a>00181 EEProm *ee = (EEProm *)dev;
<a name="l00182"></a>00182
<a name="l00183"></a>00183 ee-&gt;wr_op_cb = NULL;
<a name="l00184"></a>00184 ee-&gt;wr_op_clk = 0;
<a name="l00185"></a>00185
<a name="l00186"></a>00186 ee-&gt;mwe_clr_cb = NULL;
<a name="l00187"></a>00187 ee-&gt;mwe_clk = 0;
<a name="l00188"></a>00188
<a name="l00189"></a>00189 ee-&gt;eecr = ee-&gt;eedr = ee-&gt;eearl = ee-&gt;eearh = 0;
<a name="l00190"></a>00190 }
<a name="l00191"></a>00191
<a name="l00192"></a>00192 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00193"></a>00193 eeprom_wr_eecr (EEProm *ee, uint8_t val)
<a name="l00194"></a>00194 {
<a name="l00195"></a>00195 <span class="keywordtype">int</span> addr = (ee-&gt;eearh &lt;&lt; 8) | ee-&gt;eearl;
<a name="l00196"></a>00196
<a name="l00197"></a>00197 CallBack *cb;
<a name="l00198"></a>00198
<a name="l00199"></a>00199 switch (val &amp; ee-&gt;eecr_mask)
<a name="l00200"></a>00200 {
<a name="l00201"></a>00201 <span class="keywordflow">case</span> mask_EERE:
<a name="l00202"></a>00202 <span class="comment">/*</span>
<a name="l00203"></a>00203 <span class="comment"> * we never need to set EERE bit one,</span>
<a name="l00204"></a>00204 <span class="comment"> * just more data from eeprom array into eedr.</span>
<a name="l00205"></a>00205 <span class="comment"> */</span>
<a name="l00206"></a>00206 ee-&gt;eedr = storage_readb (ee-&gt;stor, addr);
<a name="l00207"></a>00207 <span class="keywordflow">break</span>;
<a name="l00208"></a>00208
<a name="l00209"></a>00209 <span class="keywordflow">case</span> mask_EEWE:
<a name="l00210"></a>00210 <span class="keywordflow">if</span> (((ee-&gt;eecr_mask &amp; mask_EEMWE) == 0) <span class="comment">/* device has no MWE</span>
<a name="l00211"></a>00211 <span class="comment"> function */</span>
<a name="l00212"></a>00212 || (ee-&gt;eecr &amp; ee-&gt;eecr_mask &amp; mask_EEMWE)) <span class="comment">/* or MWE bit is</span>
<a name="l00213"></a>00213 <span class="comment"> set */</span>
<a name="l00214"></a>00214 {
<a name="l00215"></a>00215 ee-&gt;eecr |= mask_EEWE;
<a name="l00216"></a>00216 ee-&gt;wr_op_clk = EEPROM_WR_OP_CLKS;
<a name="l00217"></a>00217
<a name="l00218"></a>00218 <span class="comment">/* start write operation */</span>
<a name="l00219"></a>00219 <span class="keywordflow">if</span> (ee-&gt;wr_op_cb == NULL)
<a name="l00220"></a>00220 {
<a name="l00221"></a>00221 cb = callback_new (eeprom_wr_op_cb, (AvrClass *)ee);
<a name="l00222"></a>00222 ee-&gt;wr_op_cb = cb;
<a name="l00223"></a>00223 <a class="code" href="avrcore_8c.html#e821588464c39dbdcc9fb5eea45da0aa" title="Add a new asynchronous callback to list.">avr_core_async_cb_add</a> ((AvrCore *)
<a name="l00224"></a>00224 <a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)ee), cb);
<a name="l00225"></a>00225 }
<a name="l00226"></a>00226 }
<a name="l00227"></a>00227 <span class="keywordflow">break</span>;
<a name="l00228"></a>00228
<a name="l00229"></a>00229 <span class="keywordflow">case</span> mask_EEMWE:
<a name="l00230"></a>00230 ee-&gt;eecr |= mask_EEMWE;
<a name="l00231"></a>00231 ee-&gt;mwe_clk = EEPROM_MWE_CLKS;
<a name="l00232"></a>00232
<a name="l00233"></a>00233 <span class="keywordflow">if</span> (ee-&gt;mwe_clr_cb == NULL)
<a name="l00234"></a>00234 {
<a name="l00235"></a>00235 cb = callback_new (eeprom_mwe_clr_cb, (AvrClass *)ee);
<a name="l00236"></a>00236 ee-&gt;mwe_clr_cb = cb;
<a name="l00237"></a>00237 <a class="code" href="avrcore_8c.html#3e755b8388c3c44ea514484ce53ace75" title="Add a new clock callback to list.">avr_core_clk_cb_add</a> ((AvrCore *)<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)ee),
<a name="l00238"></a>00238 cb);
<a name="l00239"></a>00239 }
<a name="l00240"></a>00240 <span class="keywordflow">break</span>;
<a name="l00241"></a>00241
<a name="l00242"></a>00242 <span class="keywordflow">case</span> (mask_EEMWE | mask_EEWE):
<a name="l00243"></a>00243 <span class="comment">/* just call this function again, but without EEMWE set in val */</span>
<a name="l00244"></a>00244 eeprom_wr_eecr (ee, mask_EEWE);
<a name="l00245"></a>00245 <span class="keywordflow">break</span>;
<a name="l00246"></a>00246
<a name="l00247"></a>00247 <span class="keywordflow">default</span>:
<a name="l00248"></a>00248 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Unknown eeprom control register write operation: "</span>
<a name="l00249"></a>00249 <span class="stringliteral">"0x%02x"</span>, val);
<a name="l00250"></a>00250 }
<a name="l00251"></a>00251 }
<a name="l00252"></a>00252
<a name="l00253"></a>00253 <span class="comment">/*</span>
<a name="l00254"></a>00254 <span class="comment"> * The data sheets say that a write operation takes 2.5 to 4.0 ms to complete</span>
<a name="l00255"></a>00255 <span class="comment"> * depending on Vcc voltage. Since the get_program_time() function only has</span>
<a name="l00256"></a>00256 <span class="comment"> * 10 ms resolution, we'll just simulate a timer with counting down from</span>
<a name="l00257"></a>00257 <span class="comment"> * EEPROM_WR_OP_CLKS to zero. 2500 clocks would be 2.5 ms if simulator is</span>
<a name="l00258"></a>00258 <span class="comment"> * running at 1 MHz. I really don't think that this variation should be </span>
<a name="l00259"></a>00259 <span class="comment"> * critical in most apps, but I'd wouldn't mind being proven wrong.</span>
<a name="l00260"></a>00260 <span class="comment"> */</span>
<a name="l00261"></a>00261 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00262"></a>00262 eeprom_wr_op_cb (uint64_t time, AvrClass *data)
<a name="l00263"></a>00263 {
<a name="l00264"></a>00264 EEProm *ee = (EEProm *)data;
<a name="l00265"></a>00265 <span class="keywordtype">int</span> addr;
<a name="l00266"></a>00266
<a name="l00267"></a>00267 <span class="comment">/*</span>
<a name="l00268"></a>00268 <span class="comment"> * FIXME: At some point in the future, we might need to check if</span>
<a name="l00269"></a>00269 <span class="comment"> * any of the I/O registers have been written to during the write</span>
<a name="l00270"></a>00270 <span class="comment"> * operation which would cause the write op to be interrupted.</span>
<a name="l00271"></a>00271 <span class="comment"> * Right now, the simulator is aborted in that situation.</span>
<a name="l00272"></a>00272 <span class="comment"> */</span>
<a name="l00273"></a>00273
<a name="l00274"></a>00274 <span class="keywordflow">if</span> (ee-&gt;wr_op_clk &gt; 0)
<a name="l00275"></a>00275 {
<a name="l00276"></a>00276 <span class="comment">/* write is not complete yet */</span>
<a name="l00277"></a>00277 ee-&gt;wr_op_clk--;
<a name="l00278"></a>00278 <span class="keywordflow">return</span> CB_RET_RETAIN;
<a name="l00279"></a>00279 }
<a name="l00280"></a>00280
<a name="l00281"></a>00281 <span class="comment">/* write the data in eedr into eeprom at addr */</span>
<a name="l00282"></a>00282 addr = (ee-&gt;eearh &lt;&lt; 8) | ee-&gt;eearl;
<a name="l00283"></a>00283 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"writing 0x%02x to eeprom at 0x%04x\n"</span>, ee-&gt;eedr, addr);
<a name="l00284"></a>00284 <a class="code" href="display_8c.html#6a425136a8b941eba6671bbea330283b" title="Update a block of eeprom addresses in the display.">display_eeprom</a> (addr, 1, &amp;ee-&gt;eedr);
<a name="l00285"></a>00285 storage_writeb (ee-&gt;stor, addr, ee-&gt;eedr);
<a name="l00286"></a>00286
<a name="l00287"></a>00287 <span class="comment">/* Now it's ok to start another write operation */</span>
<a name="l00288"></a>00288 ee-&gt;eecr &amp;= ~(mask_EEWE); <span class="comment">/* clear the write enable bit */</span>
<a name="l00289"></a>00289 ee-&gt;wr_op_cb = NULL; <span class="comment">/* remove callback */</span>
<a name="l00290"></a>00290
<a name="l00291"></a>00291 <span class="keywordflow">return</span> CB_RET_REMOVE;
<a name="l00292"></a>00292 }
<a name="l00293"></a>00293
<a name="l00294"></a>00294 <span class="comment">/*</span>
<a name="l00295"></a>00295 <span class="comment"> * Once set, the hardware will automatically clear the EEMWE bit</span>
<a name="l00296"></a>00296 <span class="comment"> * after EEPROM_MWE_CLKS clock cycles.</span>
<a name="l00297"></a>00297 <span class="comment"> */</span>
<a name="l00298"></a>00298 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00299"></a>00299 eeprom_mwe_clr_cb (uint64_t time, AvrClass *data)
<a name="l00300"></a>00300 {
<a name="l00301"></a>00301 EEProm *ee = (EEProm *)data;
<a name="l00302"></a>00302
<a name="l00303"></a>00303 <span class="keywordflow">if</span> (ee-&gt;mwe_clk &gt; 0)
<a name="l00304"></a>00304 {
<a name="l00305"></a>00305 ee-&gt;mwe_clk--;
<a name="l00306"></a>00306 <span class="keywordflow">return</span> CB_RET_RETAIN;
<a name="l00307"></a>00307 }
<a name="l00308"></a>00308
<a name="l00309"></a>00309 ee-&gt;eecr &amp;= ~(mask_EEMWE); <span class="comment">/* clear the EEMWE bit */</span>
<a name="l00310"></a>00310 ee-&gt;mwe_clr_cb = NULL; <span class="comment">/* remove callback */</span>
<a name="l00311"></a>00311
<a name="l00312"></a>00312 <span class="keywordflow">return</span> CB_RET_REMOVE;
<a name="l00313"></a>00313 }
<a name="l00314"></a>00314
<a name="l00315"></a>00315 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00316"></a>00316 eeprom_load_from_bin_file (EEProm *eeprom, <span class="keywordtype">char</span> *file)
<a name="l00317"></a>00317 {
<a name="l00318"></a>00318 <span class="keywordtype">int</span> fd, res;
<a name="l00319"></a>00319 <span class="keywordtype">int</span> addr = 0;
<a name="l00320"></a>00320 uint8_t datum;
<a name="l00321"></a>00321
<a name="l00322"></a>00322 fd = open (file, O_RDONLY);
<a name="l00323"></a>00323 <span class="keywordflow">if</span> (fd &lt; 0)
<a name="l00324"></a>00324 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Couldn't open binary eeprom image file: %s: %s"</span>, file,
<a name="l00325"></a>00325 strerror (errno));
<a name="l00326"></a>00326
<a name="l00327"></a>00327 <span class="keywordflow">while</span> ((res = read (fd, &amp;datum, <span class="keyword">sizeof</span> (datum))) != 0)
<a name="l00328"></a>00328 {
<a name="l00329"></a>00329 <span class="keywordflow">if</span> (res == -1)
<a name="l00330"></a>00330 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Error reading binary eeprom image file: %s: %s"</span>, file,
<a name="l00331"></a>00331 strerror (errno));
<a name="l00332"></a>00332
<a name="l00333"></a>00333 storage_writeb (eeprom-&gt;stor, addr, datum);
<a name="l00334"></a>00334
<a name="l00335"></a>00335 addr++;
<a name="l00336"></a>00336 }
<a name="l00337"></a>00337
<a name="l00338"></a>00338 close (fd);
<a name="l00339"></a>00339
<a name="l00340"></a>00340 <span class="keywordflow">return</span> 0;
<a name="l00341"></a>00341 }
<a name="l00342"></a>00342 <span class="comment"></span>
<a name="l00343"></a>00343 <span class="comment">/** \brief Load data into eeprom from a file. */</span>
<a name="l00344"></a>00344
<a name="l00345"></a>00345 <span class="keywordtype">int</span>
<a name="l00346"></a>00346 eeprom_load_from_file (EEProm *eeprom, <span class="keywordtype">char</span> *file, <span class="keywordtype">int</span> format)
<a name="l00347"></a>00347 {
<a name="l00348"></a>00348 <span class="keywordflow">switch</span> (format)
<a name="l00349"></a>00349 {
<a name="l00350"></a>00350 <span class="keywordflow">case</span> FFMT_BIN:
<a name="l00351"></a>00351 <span class="keywordflow">return</span> eeprom_load_from_bin_file (eeprom, file);
<a name="l00352"></a>00352 <span class="keywordflow">case</span> FFMT_IHEX:
<a name="l00353"></a>00353 <span class="keywordflow">case</span> FFMT_ELF:
<a name="l00354"></a>00354 <span class="keywordflow">default</span>:
<a name="l00355"></a>00355 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"Unsupported file format\n"</span>);
<a name="l00356"></a>00356 }
<a name="l00357"></a>00357
<a name="l00358"></a>00358 <span class="keywordflow">return</span> -1;
<a name="l00359"></a>00359 }
<a name="l00360"></a>00360
<a name="l00361"></a>00361 <span class="keywordtype">void</span>
<a name="l00362"></a>00362 eeprom_dump_core (EEProm *eeprom, FILE * f_core)
<a name="l00363"></a>00363 {
<a name="l00364"></a>00364 <span class="keywordtype">int</span> i;
<a name="l00365"></a>00365 <span class="keywordtype">int</span> dup = 0;
<a name="l00366"></a>00366 <span class="keywordtype">int</span> ndat = 16;
<a name="l00367"></a>00367 <span class="keywordtype">char</span> line[80];
<a name="l00368"></a>00368 <span class="keywordtype">char</span> last_line[80];
<a name="l00369"></a>00369 <span class="keywordtype">char</span> buf[80];
<a name="l00370"></a>00370 <span class="keywordtype">int</span> size = storage_get_size (eeprom-&gt;stor);
<a name="l00371"></a>00371
<a name="l00372"></a>00372 fprintf (f_core, <span class="stringliteral">"EEPROM Memory Dump:\n"</span>);
<a name="l00373"></a>00373
<a name="l00374"></a>00374 line[0] = last_line[0] = <span class="charliteral">'\0'</span>;
<a name="l00375"></a>00375
<a name="l00376"></a>00376 <span class="keywordflow">for</span> (i = 0; i &lt; size; i++)
<a name="l00377"></a>00377 {
<a name="l00378"></a>00378 <span class="keywordflow">if</span> (((i % ndat) == 0) &amp;&amp; strlen (line))
<a name="l00379"></a>00379 {
<a name="l00380"></a>00380 <span class="keywordflow">if</span> (strncmp (line, last_line, 80) == 0)
<a name="l00381"></a>00381 {
<a name="l00382"></a>00382 dup++;
<a name="l00383"></a>00383 }
<a name="l00384"></a>00384 <span class="keywordflow">else</span>
<a name="l00385"></a>00385 {
<a name="l00386"></a>00386 <span class="keywordflow">if</span> (dup &gt; 0)
<a name="l00387"></a>00387 fprintf (f_core, <span class="stringliteral">" -- last line repeats --\n"</span>);
<a name="l00388"></a>00388 fprintf (f_core, <span class="stringliteral">"%04x : %s\n"</span>, i - ndat, line);
<a name="l00389"></a>00389 dup = 0;
<a name="l00390"></a>00390 }
<a name="l00391"></a>00391 strncpy (last_line, line, 80);
<a name="l00392"></a>00392 line[0] = <span class="charliteral">'\0'</span>;
<a name="l00393"></a>00393 }
<a name="l00394"></a>00394 snprintf (buf, 80, <span class="stringliteral">"%02x "</span>, storage_readb (eeprom-&gt;stor, i));
<a name="l00395"></a>00395 strncat (line, buf, 80);
<a name="l00396"></a>00396 }
<a name="l00397"></a>00397 <span class="keywordflow">if</span> (dup &gt; 0)
<a name="l00398"></a>00398 {
<a name="l00399"></a>00399 fprintf (f_core, <span class="stringliteral">" -- last line repeats --\n"</span>);
<a name="l00400"></a>00400 fprintf (f_core, <span class="stringliteral">"%04x : %s\n"</span>, i - ndat, line);
<a name="l00401"></a>00401 }
<a name="l00402"></a>00402 fprintf (f_core, <span class="stringliteral">"\n"</span>);
<a name="l00403"></a>00403 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,28 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1><a class="anchor" name="ext_devs">External Devices </a></h1><p>
<b>FIXME:</b> empty place holder </div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,63 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li class="current"><a href="files.html"><span>File&nbsp;List</span></a></li>
<li><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>File List</h1>Here is a list of all documented files with brief descriptions:<table>
<tr><td class="indexkey"><a class="el" href="adc_8c.html">adc.c</a> <a href="adc_8c-source.html">[code]</a></td><td class="indexvalue">Module to simulate the AVR's ADC module </td></tr>
<tr><td class="indexkey"><a class="el" href="avrclass_8c.html">avrclass.c</a> <a href="avrclass_8c-source.html">[code]</a></td><td class="indexvalue">Methods to provide user interfaces to the AvrClass structure </td></tr>
<tr><td class="indexkey"><a class="el" href="avrcore_8c.html">avrcore.c</a> <a href="avrcore_8c-source.html">[code]</a></td><td class="indexvalue">Module for the core AvrCore object, which is the AVR CPU to be simulated </td></tr>
<tr><td class="indexkey"><a class="el" href="avrerror_8c.html">avrerror.c</a> <a href="avrerror_8c-source.html">[code]</a></td><td class="indexvalue">Functions for printing messages, warnings and errors </td></tr>
<tr><td class="indexkey"><a class="el" href="avrmalloc_8c.html">avrmalloc.c</a> <a href="avrmalloc_8c-source.html">[code]</a></td><td class="indexvalue">Memory Management Functions </td></tr>
<tr><td class="indexkey"><b>callback.c</b> <a href="callback_8c-source.html">[code]</a></td><td class="indexvalue"></td></tr>
<tr><td class="indexkey"><a class="el" href="decoder_8c.html">decoder.c</a> <a href="decoder_8c-source.html">[code]</a></td><td class="indexvalue">Module for handling opcode decoding </td></tr>
<tr><td class="indexkey"><a class="el" href="device_8c.html">device.c</a> <a href="device_8c-source.html">[code]</a></td><td class="indexvalue">VDevice methods </td></tr>
<tr><td class="indexkey"><a class="el" href="devsupp_8c.html">devsupp.c</a> <a href="devsupp_8c-source.html">[code]</a></td><td class="indexvalue">Contains definitions for device types (i.e. at90s8515, at90s2313, etc.) </td></tr>
<tr><td class="indexkey"><a class="el" href="display_8c.html">display.c</a> <a href="display_8c-source.html">[code]</a></td><td class="indexvalue">Interface for using display coprocesses </td></tr>
<tr><td class="indexkey"><b>eeprom.c</b> <a href="eeprom_8c-source.html">[code]</a></td><td class="indexvalue"></td></tr>
<tr><td class="indexkey"><a class="el" href="flash_8c.html">flash.c</a> <a href="flash_8c-source.html">[code]</a></td><td class="indexvalue">Flash memory methods </td></tr>
<tr><td class="indexkey"><a class="el" href="gdbserver_8c.html">gdbserver.c</a> <a href="gdbserver_8c-source.html">[code]</a></td><td class="indexvalue">Provide an interface to gdb's remote serial protocol </td></tr>
<tr><td class="indexkey"><b>intvects.c</b> <a href="intvects_8c-source.html">[code]</a></td><td class="indexvalue"></td></tr>
<tr><td class="indexkey"><b>main.c</b> <a href="main_8c-source.html">[code]</a></td><td class="indexvalue"></td></tr>
<tr><td class="indexkey"><a class="el" href="memory_8c.html">memory.c</a> <a href="memory_8c-source.html">[code]</a></td><td class="indexvalue">Memory access functions </td></tr>
<tr><td class="indexkey"><b>op_names.c</b> <a href="op__names_8c-source.html">[code]</a></td><td class="indexvalue"></td></tr>
<tr><td class="indexkey"><a class="el" href="ports_8c.html">ports.c</a> <a href="ports_8c-source.html">[code]</a></td><td class="indexvalue">Module for accessing simulated I/O ports </td></tr>
<tr><td class="indexkey"><b>register.c</b> <a href="register_8c-source.html">[code]</a></td><td class="indexvalue"></td></tr>
<tr><td class="indexkey"><a class="el" href="sig_8c.html">sig.c</a> <a href="sig_8c-source.html">[code]</a></td><td class="indexvalue">Public interface to signal handlers </td></tr>
<tr><td class="indexkey"><a class="el" href="spi_8c.html">spi.c</a> <a href="spi_8c-source.html">[code]</a></td><td class="indexvalue">Module to simulate the AVR's SPI module </td></tr>
<tr><td class="indexkey"><b>sram.c</b> <a href="sram_8c-source.html">[code]</a></td><td class="indexvalue"></td></tr>
<tr><td class="indexkey"><a class="el" href="stack_8c.html">stack.c</a> <a href="stack_8c-source.html">[code]</a></td><td class="indexvalue">Module for the definition of the stack </td></tr>
<tr><td class="indexkey"><b>storage.c</b> <a href="storage_8c-source.html">[code]</a></td><td class="indexvalue"></td></tr>
<tr><td class="indexkey"><a class="el" href="timers_8c.html">timers.c</a> <a href="timers_8c-source.html">[code]</a></td><td class="indexvalue">Module to simulate the AVR's on-board timer/counters </td></tr>
<tr><td class="indexkey"><a class="el" href="uart_8c.html">uart.c</a> <a href="uart_8c-source.html">[code]</a></td><td class="indexvalue">Module to simulate the AVR's uart module </td></tr>
<tr><td class="indexkey"><a class="el" href="usb_8c.html">usb.c</a> <a href="usb_8c-source.html">[code]</a></td><td class="indexvalue">Module to simulate the AVR's USB module </td></tr>
<tr><td class="indexkey"><a class="el" href="utils_8c.html">utils.c</a> <a href="utils_8c-source.html">[code]</a></td><td class="indexvalue">Utility functions </td></tr>
</table>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,287 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>flash.c</h1><a href="flash_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: flash.c,v 1.12 2003/12/02 08:25:00 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/**</span>
<a name="l00027"></a>00027 <span class="comment"> * \file flash.c</span>
<a name="l00028"></a>00028 <span class="comment"> * \brief Flash memory methods</span>
<a name="l00029"></a>00029 <span class="comment"> *</span>
<a name="l00030"></a>00030 <span class="comment"> * This module provides functions for reading and writing to flash memory.</span>
<a name="l00031"></a>00031 <span class="comment"> * Flash memory is the program (.text) memory in AVR's Harvard architecture.</span>
<a name="l00032"></a>00032 <span class="comment"> * It is completely separate from RAM, which is simulated in the memory.c</span>
<a name="l00033"></a>00033 <span class="comment"> * file.</span>
<a name="l00034"></a>00034 <span class="comment"> */</span>
<a name="l00035"></a>00035
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;unistd.h&gt;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include &lt;sys/types.h&gt;</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include &lt;sys/stat.h&gt;</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include &lt;fcntl.h&gt;</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include &lt;errno.h&gt;</span>
<a name="l00046"></a>00046
<a name="l00047"></a>00047 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00050"></a>00050 <span class="preprocessor">#include "utils.h"</span>
<a name="l00051"></a>00051
<a name="l00052"></a>00052 <span class="preprocessor">#include "storage.h"</span>
<a name="l00053"></a>00053 <span class="preprocessor">#include "flash.h"</span>
<a name="l00054"></a>00054
<a name="l00055"></a>00055 <span class="preprocessor">#include "display.h"</span>
<a name="l00056"></a>00056
<a name="l00057"></a>00057 <span class="comment">/***************************************************************************\</span>
<a name="l00058"></a>00058 <span class="comment"> *</span>
<a name="l00059"></a>00059 <span class="comment"> * Local Static Function Prototypes</span>
<a name="l00060"></a>00060 <span class="comment"> *</span>
<a name="l00061"></a>00061 <span class="comment">\***************************************************************************/</span>
<a name="l00062"></a>00062
<a name="l00063"></a>00063 <span class="keyword">static</span> <span class="keywordtype">int</span> flash_load_from_bin_file (Flash *flash, <span class="keywordtype">char</span> *file);
<a name="l00064"></a>00064
<a name="l00065"></a>00065 <span class="comment">/***************************************************************************\</span>
<a name="l00066"></a>00066 <span class="comment"> *</span>
<a name="l00067"></a>00067 <span class="comment"> * Flash(Storage) Methods</span>
<a name="l00068"></a>00068 <span class="comment"> *</span>
<a name="l00069"></a>00069 <span class="comment">\***************************************************************************/</span>
<a name="l00070"></a>00070 <span class="comment"></span>
<a name="l00071"></a>00071 <span class="comment">/**</span>
<a name="l00072"></a>00072 <span class="comment"> * \brief Reads a 16-bit word from flash.</span>
<a name="l00073"></a>00073 <span class="comment"> * \return A word.</span>
<a name="l00074"></a>00074 <span class="comment"> */</span>
<a name="l00075"></a>00075
<a name="l00076"></a>00076 <span class="keyword">extern</span> <span class="keyword">inline</span> uint16_t <a class="code" href="flash_8c.html#4fd6af69b0ff01070ff7598920761a2b" title="Reads a 16-bit word from flash.">flash_read</a> (Flash *flash, <span class="keywordtype">int</span> addr);
<a name="l00077"></a>00077 <span class="comment"></span>
<a name="l00078"></a>00078 <span class="comment">/**</span>
<a name="l00079"></a>00079 <span class="comment"> * \brief Reads a 16-bit word from flash.</span>
<a name="l00080"></a>00080 <span class="comment"> * \param flash A pointer to a flash object.</span>
<a name="l00081"></a>00081 <span class="comment"> * \param addr The address to which to write.</span>
<a name="l00082"></a>00082 <span class="comment"> * \param val The byte to write there.</span>
<a name="l00083"></a>00083 <span class="comment"> */</span>
<a name="l00084"></a>00084
<a name="l00085"></a>00085 <span class="keywordtype">void</span>
<a name="l00086"></a><a class="code" href="flash_8c.html#eccaffb7a1e3a2d8faf2ca923735548b">00086</a> <a class="code" href="flash_8c.html#eccaffb7a1e3a2d8faf2ca923735548b" title="Reads a 16-bit word from flash.">flash_write</a> (Flash *flash, <span class="keywordtype">int</span> addr, uint16_t val)
<a name="l00087"></a>00087 {
<a name="l00088"></a>00088 <a class="code" href="display_8c.html#69d6536d741f20da943fb64373bbae11" title="Update a block of flash addresses in the display.">display_flash</a> (addr, 1, &amp;val);
<a name="l00089"></a>00089 storage_writew ((Storage *)flash, addr * 2, val);
<a name="l00090"></a>00090 }
<a name="l00091"></a>00091 <span class="comment"></span>
<a name="l00092"></a>00092 <span class="comment">/** \brief Write the low-order byte of an address.</span>
<a name="l00093"></a>00093 <span class="comment"> *</span>
<a name="l00094"></a>00094 <span class="comment"> * AVRs are little-endian, so lo8 bits in odd addresses.</span>
<a name="l00095"></a>00095 <span class="comment"> */</span>
<a name="l00096"></a>00096
<a name="l00097"></a>00097 <span class="keywordtype">void</span>
<a name="l00098"></a><a class="code" href="flash_8c.html#dc8ba20623259c3f23360c952effa310">00098</a> <a class="code" href="flash_8c.html#dc8ba20623259c3f23360c952effa310" title="Write the low-order byte of an address.">flash_write_lo8</a> (Flash *flash, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00099"></a>00099 {
<a name="l00100"></a>00100 storage_writeb ((Storage *)flash, addr * 2 + 1, val);
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102 <span class="comment"></span>
<a name="l00103"></a>00103 <span class="comment">/** \brief Write the high-order byte of an address.</span>
<a name="l00104"></a>00104 <span class="comment"> *</span>
<a name="l00105"></a>00105 <span class="comment"> * AVRs are little-endian, so hi8 bits in even addresses.</span>
<a name="l00106"></a>00106 <span class="comment"> */</span>
<a name="l00107"></a>00107
<a name="l00108"></a>00108 <span class="keywordtype">void</span>
<a name="l00109"></a><a class="code" href="flash_8c.html#b5a09ffc2f0635cb5e28b5a5c9e1c3f9">00109</a> <a class="code" href="flash_8c.html#b5a09ffc2f0635cb5e28b5a5c9e1c3f9" title="Write the high-order byte of an address.">flash_write_hi8</a> (Flash *flash, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00110"></a>00110 {
<a name="l00111"></a>00111 storage_writeb ((Storage *)flash, addr * 2, val);
<a name="l00112"></a>00112 }
<a name="l00113"></a>00113 <span class="comment"></span>
<a name="l00114"></a>00114 <span class="comment">/** \brief Allocate a new Flash object. */</span>
<a name="l00115"></a>00115
<a name="l00116"></a>00116 Flash *
<a name="l00117"></a><a class="code" href="flash_8c.html#2b69c1bd49cd27f2fe58baf4c453c92c">00117</a> <a class="code" href="flash_8c.html#2b69c1bd49cd27f2fe58baf4c453c92c" title="Allocate a new Flash object.">flash_new</a> (<span class="keywordtype">int</span> size)
<a name="l00118"></a>00118 {
<a name="l00119"></a>00119 Flash *flash;
<a name="l00120"></a>00120
<a name="l00121"></a>00121 flash = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (Flash, 1);
<a name="l00122"></a>00122 <a class="code" href="flash_8c.html#1289488dcdca6e7670ee607575c8d54d" title="Constructor for the flash object.">flash_construct</a> (flash, size);
<a name="l00123"></a>00123 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)flash, <a class="code" href="flash_8c.html#671e5df04d7524f10ae472a04b3a0b4d" title="Destructor for the flash class.">flash_destroy</a>);
<a name="l00124"></a>00124
<a name="l00125"></a>00125 <span class="keywordflow">return</span> flash;
<a name="l00126"></a>00126 }
<a name="l00127"></a>00127 <span class="comment"></span>
<a name="l00128"></a>00128 <span class="comment">/** \brief Constructor for the flash object. */</span>
<a name="l00129"></a>00129
<a name="l00130"></a>00130 <span class="keywordtype">void</span>
<a name="l00131"></a><a class="code" href="flash_8c.html#1289488dcdca6e7670ee607575c8d54d">00131</a> <a class="code" href="flash_8c.html#1289488dcdca6e7670ee607575c8d54d" title="Constructor for the flash object.">flash_construct</a> (Flash *flash, <span class="keywordtype">int</span> size)
<a name="l00132"></a>00132 {
<a name="l00133"></a>00133 <span class="keywordtype">int</span> base = 0;
<a name="l00134"></a>00134 <span class="keywordtype">int</span> i;
<a name="l00135"></a>00135
<a name="l00136"></a>00136 <span class="keywordflow">if</span> (flash == NULL)
<a name="l00137"></a>00137 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00138"></a>00138
<a name="l00139"></a>00139 storage_construct ((Storage *)flash, base, size);
<a name="l00140"></a>00140
<a name="l00141"></a>00141 <span class="comment">/* Init the flash to ones. */</span>
<a name="l00142"></a>00142 <span class="keywordflow">for</span> (i = 0; i &lt; size; i++)
<a name="l00143"></a>00143 storage_writeb ((Storage *)flash, i, 0xff);
<a name="l00144"></a>00144 }
<a name="l00145"></a>00145 <span class="comment"></span>
<a name="l00146"></a>00146 <span class="comment">/**</span>
<a name="l00147"></a>00147 <span class="comment"> * \brief Destructor for the flash class.</span>
<a name="l00148"></a>00148 <span class="comment"> *</span>
<a name="l00149"></a>00149 <span class="comment"> * Not to be called directly, except by a derived class.</span>
<a name="l00150"></a>00150 <span class="comment"> * Called via class_unref.</span>
<a name="l00151"></a>00151 <span class="comment"> */</span>
<a name="l00152"></a>00152 <span class="keywordtype">void</span>
<a name="l00153"></a><a class="code" href="flash_8c.html#671e5df04d7524f10ae472a04b3a0b4d">00153</a> <a class="code" href="flash_8c.html#671e5df04d7524f10ae472a04b3a0b4d" title="Destructor for the flash class.">flash_destroy</a> (<span class="keywordtype">void</span> *flash)
<a name="l00154"></a>00154 {
<a name="l00155"></a>00155 <span class="keywordflow">if</span> (flash == NULL)
<a name="l00156"></a>00156 <span class="keywordflow">return</span>;
<a name="l00157"></a>00157
<a name="l00158"></a>00158 storage_destroy (flash);
<a name="l00159"></a>00159 }
<a name="l00160"></a>00160 <span class="comment"></span>
<a name="l00161"></a>00161 <span class="comment">/** \brief Load program data into flash from a file. */</span>
<a name="l00162"></a>00162
<a name="l00163"></a>00163 <span class="keywordtype">int</span>
<a name="l00164"></a><a class="code" href="flash_8c.html#030c974ad076ab030e961f4860d7300a">00164</a> <a class="code" href="flash_8c.html#030c974ad076ab030e961f4860d7300a" title="Load program data into flash from a file.">flash_load_from_file</a> (Flash *flash, <span class="keywordtype">char</span> *file, <span class="keywordtype">int</span> format)
<a name="l00165"></a>00165 {
<a name="l00166"></a>00166 <span class="keywordflow">switch</span> (format)
<a name="l00167"></a>00167 {
<a name="l00168"></a>00168 <span class="keywordflow">case</span> FFMT_BIN:
<a name="l00169"></a>00169 <span class="keywordflow">return</span> flash_load_from_bin_file (flash, file);
<a name="l00170"></a>00170 <span class="keywordflow">case</span> FFMT_IHEX:
<a name="l00171"></a>00171 <span class="keywordflow">case</span> FFMT_ELF:
<a name="l00172"></a>00172 <span class="keywordflow">default</span>:
<a name="l00173"></a>00173 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"Unsupported file format\n"</span>);
<a name="l00174"></a>00174 }
<a name="l00175"></a>00175
<a name="l00176"></a>00176 <span class="keywordflow">return</span> -1;
<a name="l00177"></a>00177 }
<a name="l00178"></a>00178
<a name="l00179"></a>00179 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00180"></a>00180 flash_load_from_bin_file (Flash *flash, <span class="keywordtype">char</span> *file)
<a name="l00181"></a>00181 {
<a name="l00182"></a>00182 <span class="keywordtype">int</span> fd, res;
<a name="l00183"></a>00183 <span class="keywordtype">int</span> addr = 0;
<a name="l00184"></a>00184 uint16_t inst;
<a name="l00185"></a>00185
<a name="l00186"></a>00186 fd = open (file, O_RDONLY);
<a name="l00187"></a>00187 <span class="keywordflow">if</span> (fd &lt; 0)
<a name="l00188"></a>00188 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Couldn't open binary flash image file: %s: %s"</span>, file,
<a name="l00189"></a>00189 strerror (errno));
<a name="l00190"></a>00190
<a name="l00191"></a>00191 <span class="keywordflow">while</span> ((res = read (fd, &amp;inst, <span class="keyword">sizeof</span> (inst))) != 0)
<a name="l00192"></a>00192 {
<a name="l00193"></a>00193 <span class="keywordflow">if</span> (res == -1)
<a name="l00194"></a>00194 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Error reading binary flash image file: %s: %s"</span>, file,
<a name="l00195"></a>00195 strerror (errno));
<a name="l00196"></a>00196
<a name="l00197"></a>00197 <a class="code" href="flash_8c.html#eccaffb7a1e3a2d8faf2ca923735548b" title="Reads a 16-bit word from flash.">flash_write</a> (flash, addr, inst);
<a name="l00198"></a>00198
<a name="l00199"></a>00199 addr++;
<a name="l00200"></a>00200 }
<a name="l00201"></a>00201
<a name="l00202"></a>00202 close (fd);
<a name="l00203"></a>00203
<a name="l00204"></a>00204 <span class="keywordflow">return</span> 0;
<a name="l00205"></a>00205 }
<a name="l00206"></a>00206 <span class="comment"></span>
<a name="l00207"></a>00207 <span class="comment">/** \brief Accessor method to get the size of a flash. */</span>
<a name="l00208"></a>00208
<a name="l00209"></a>00209 <span class="keywordtype">int</span>
<a name="l00210"></a><a class="code" href="flash_8c.html#83456740d126c8a8790796597129ad9b">00210</a> <a class="code" href="flash_8c.html#83456740d126c8a8790796597129ad9b" title="Accessor method to get the size of a flash.">flash_get_size</a> (Flash *flash)
<a name="l00211"></a>00211 {
<a name="l00212"></a>00212 <span class="keywordflow">return</span> storage_get_size ((Storage *)flash);
<a name="l00213"></a>00213 }
<a name="l00214"></a>00214 <span class="comment"></span>
<a name="l00215"></a>00215 <span class="comment">/**</span>
<a name="l00216"></a>00216 <span class="comment"> * \brief Dump the contents of the flash to a file descriptor in text format.</span>
<a name="l00217"></a>00217 <span class="comment"> *</span>
<a name="l00218"></a>00218 <span class="comment"> * \param flash A pointer to a flash object.</span>
<a name="l00219"></a>00219 <span class="comment"> * \param f_core An open file descriptor.</span>
<a name="l00220"></a>00220 <span class="comment"> */</span>
<a name="l00221"></a>00221
<a name="l00222"></a>00222 <span class="keywordtype">void</span>
<a name="l00223"></a><a class="code" href="flash_8c.html#1adccaaad97ed90fdf2aca154edbedb5">00223</a> <a class="code" href="flash_8c.html#1adccaaad97ed90fdf2aca154edbedb5" title="Dump the contents of the flash to a file descriptor in text format.">flash_dump_core</a> (Flash *flash, FILE * f_core)
<a name="l00224"></a>00224 {
<a name="l00225"></a>00225 <span class="keywordtype">int</span> size = storage_get_size ((Storage *)flash) / 2;
<a name="l00226"></a>00226 <span class="keywordtype">int</span> i;
<a name="l00227"></a>00227 <span class="keywordtype">int</span> dup = 0;
<a name="l00228"></a>00228 <span class="keywordtype">int</span> ndat = 8;
<a name="l00229"></a>00229 <span class="keywordtype">char</span> line[80];
<a name="l00230"></a>00230 <span class="keywordtype">char</span> last_line[80];
<a name="l00231"></a>00231 <span class="keywordtype">char</span> buf[80];
<a name="l00232"></a>00232
<a name="l00233"></a>00233 line[0] = last_line[0] = <span class="charliteral">'\0'</span>;
<a name="l00234"></a>00234
<a name="l00235"></a>00235 fprintf (f_core, <span class="stringliteral">"Program Flash Memory Dump:\n"</span>);
<a name="l00236"></a>00236 <span class="keywordflow">for</span> (i = 0; i &lt; size; i++)
<a name="l00237"></a>00237 {
<a name="l00238"></a>00238 <span class="keywordflow">if</span> (((i % ndat) == 0) &amp;&amp; strlen (line))
<a name="l00239"></a>00239 {
<a name="l00240"></a>00240 <span class="keywordflow">if</span> (strncmp (line, last_line, 80) == 0)
<a name="l00241"></a>00241 {
<a name="l00242"></a>00242 dup++;
<a name="l00243"></a>00243 }
<a name="l00244"></a>00244 <span class="keywordflow">else</span>
<a name="l00245"></a>00245 {
<a name="l00246"></a>00246 <span class="keywordflow">if</span> (dup &gt; 0)
<a name="l00247"></a>00247 fprintf (f_core, <span class="stringliteral">" -- last line repeats --\n"</span>);
<a name="l00248"></a>00248 fprintf (f_core, <span class="stringliteral">"%04x : %s\n"</span>, i - ndat, line);
<a name="l00249"></a>00249 dup = 0;
<a name="l00250"></a>00250 }
<a name="l00251"></a>00251 strncpy (last_line, line, 80);
<a name="l00252"></a>00252 line[0] = <span class="charliteral">'\0'</span>;
<a name="l00253"></a>00253 }
<a name="l00254"></a>00254 snprintf (buf, 80, <span class="stringliteral">"%04x "</span>, <a class="code" href="flash_8c.html#4fd6af69b0ff01070ff7598920761a2b" title="Reads a 16-bit word from flash.">flash_read</a> (flash, i));
<a name="l00255"></a>00255 strncat (line, buf, 80);
<a name="l00256"></a>00256 }
<a name="l00257"></a>00257 <span class="keywordflow">if</span> (dup &gt; 0)
<a name="l00258"></a>00258 {
<a name="l00259"></a>00259 fprintf (f_core, <span class="stringliteral">" -- last line repeats --\n"</span>);
<a name="l00260"></a>00260 fprintf (f_core, <span class="stringliteral">"%04x : %s\n"</span>, i - ndat, line);
<a name="l00261"></a>00261 }
<a name="l00262"></a>00262 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,424 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>flash.c File Reference</h1>Flash memory methods. <a href="#_details">More...</a>
<p>
<p>
<a href="flash_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">uint16_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="flash_8c.html#4fd6af69b0ff01070ff7598920761a2b">flash_read</a> (Flash *flash, int addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="flash_8c.html#eccaffb7a1e3a2d8faf2ca923735548b">flash_write</a> (Flash *flash, int addr, uint16_t val)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="flash_8c.html#dc8ba20623259c3f23360c952effa310">flash_write_lo8</a> (Flash *flash, int addr, uint8_t val)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="flash_8c.html#b5a09ffc2f0635cb5e28b5a5c9e1c3f9">flash_write_hi8</a> (Flash *flash, int addr, uint8_t val)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">Flash *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="flash_8c.html#2b69c1bd49cd27f2fe58baf4c453c92c">flash_new</a> (int size)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="flash_8c.html#1289488dcdca6e7670ee607575c8d54d">flash_construct</a> (Flash *flash, int size)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="flash_8c.html#671e5df04d7524f10ae472a04b3a0b4d">flash_destroy</a> (void *flash)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="flash_8c.html#030c974ad076ab030e961f4860d7300a">flash_load_from_file</a> (Flash *flash, char *file, int format)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="flash_8c.html#83456740d126c8a8790796597129ad9b">flash_get_size</a> (Flash *flash)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="flash_8c.html#1adccaaad97ed90fdf2aca154edbedb5">flash_dump_core</a> (Flash *flash, FILE *f_core)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Flash memory methods.
<p>
This module provides functions for reading and writing to flash memory. Flash memory is the program (.text) memory in AVR's Harvard architecture. It is completely separate from RAM, which is simulated in the <a class="el" href="memory_8c.html" title="Memory access functions.">memory.c</a> file.
<p>Definition in file <a class="el" href="flash_8c-source.html">flash.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="4fd6af69b0ff01070ff7598920761a2b"></a><!-- doxytag: member="flash.c::flash_read" ref="4fd6af69b0ff01070ff7598920761a2b" args="(Flash *flash, int addr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint16_t flash_read </td>
<td>(</td>
<td class="paramtype">Flash *&nbsp;</td>
<td class="paramname"> <em>flash</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Reads a 16-bit word from flash.
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>A word. </dd></dl>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l00874">avr_core_insert_breakpoint()</a>, and <a class="el" href="flash_8c-source.html#l00223">flash_dump_core()</a>.</p>
</div>
</div><p>
<a class="anchor" name="eccaffb7a1e3a2d8faf2ca923735548b"></a><!-- doxytag: member="flash.c::flash_write" ref="eccaffb7a1e3a2d8faf2ca923735548b" args="(Flash *flash, int addr, uint16_t val)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void flash_write </td>
<td>(</td>
<td class="paramtype">Flash *&nbsp;</td>
<td class="paramname"> <em>flash</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint16_t&nbsp;</td>
<td class="paramname"> <em>val</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Reads a 16-bit word from flash.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>flash</em>&nbsp;</td><td>A pointer to a flash object. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>addr</em>&nbsp;</td><td>The address to which to write. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>val</em>&nbsp;</td><td>The byte to write there. </td></tr>
</table>
</dl>
<p>Definition at line <a class="el" href="flash_8c-source.html#l00086">86</a> of file <a class="el" href="flash_8c-source.html">flash.c</a>.</p>
<p>References <a class="el" href="display_8c-source.html#l00340">display_flash()</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l00874">avr_core_insert_breakpoint()</a>, and <a class="el" href="avrcore_8c-source.html#l00888">avr_core_remove_breakpoint()</a>.</p>
</div>
</div><p>
<a class="anchor" name="dc8ba20623259c3f23360c952effa310"></a><!-- doxytag: member="flash.c::flash_write_lo8" ref="dc8ba20623259c3f23360c952effa310" args="(Flash *flash, int addr, uint8_t val)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void flash_write_lo8 </td>
<td>(</td>
<td class="paramtype">Flash *&nbsp;</td>
<td class="paramname"> <em>flash</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&nbsp;</td>
<td class="paramname"> <em>val</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Write the low-order byte of an address.
<p>
AVRs are little-endian, so lo8 bits in odd addresses.
<p>Definition at line <a class="el" href="flash_8c-source.html#l00098">98</a> of file <a class="el" href="flash_8c-source.html">flash.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="b5a09ffc2f0635cb5e28b5a5c9e1c3f9"></a><!-- doxytag: member="flash.c::flash_write_hi8" ref="b5a09ffc2f0635cb5e28b5a5c9e1c3f9" args="(Flash *flash, int addr, uint8_t val)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void flash_write_hi8 </td>
<td>(</td>
<td class="paramtype">Flash *&nbsp;</td>
<td class="paramname"> <em>flash</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&nbsp;</td>
<td class="paramname"> <em>val</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Write the high-order byte of an address.
<p>
AVRs are little-endian, so hi8 bits in even addresses.
<p>Definition at line <a class="el" href="flash_8c-source.html#l00109">109</a> of file <a class="el" href="flash_8c-source.html">flash.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="2b69c1bd49cd27f2fe58baf4c453c92c"></a><!-- doxytag: member="flash.c::flash_new" ref="2b69c1bd49cd27f2fe58baf4c453c92c" args="(int size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">Flash* flash_new </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>size</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new Flash object.
<p>
<p>Definition at line <a class="el" href="flash_8c-source.html#l00117">117</a> of file <a class="el" href="flash_8c-source.html">flash.c</a>.</p>
<p>References <a class="el" href="avrmalloc_8c-source.html#l00057">avr_new</a>, <a class="el" href="avrclass_8c-source.html#l00092">class_overload_destroy()</a>, <a class="el" href="flash_8c-source.html#l00131">flash_construct()</a>, and <a class="el" href="flash_8c-source.html#l00153">flash_destroy()</a>.</p>
</div>
</div><p>
<a class="anchor" name="1289488dcdca6e7670ee607575c8d54d"></a><!-- doxytag: member="flash.c::flash_construct" ref="1289488dcdca6e7670ee607575c8d54d" args="(Flash *flash, int size)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void flash_construct </td>
<td>(</td>
<td class="paramtype">Flash *&nbsp;</td>
<td class="paramname"> <em>flash</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>size</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for the flash object.
<p>
<p>Definition at line <a class="el" href="flash_8c-source.html#l00131">131</a> of file <a class="el" href="flash_8c-source.html">flash.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
<p>Referenced by <a class="el" href="flash_8c-source.html#l00117">flash_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="671e5df04d7524f10ae472a04b3a0b4d"></a><!-- doxytag: member="flash.c::flash_destroy" ref="671e5df04d7524f10ae472a04b3a0b4d" args="(void *flash)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void flash_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>flash</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for the flash class.
<p>
Not to be called directly, except by a derived class. Called via class_unref.
<p>Definition at line <a class="el" href="flash_8c-source.html#l00153">153</a> of file <a class="el" href="flash_8c-source.html">flash.c</a>.</p>
<p>Referenced by <a class="el" href="flash_8c-source.html#l00117">flash_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="030c974ad076ab030e961f4860d7300a"></a><!-- doxytag: member="flash.c::flash_load_from_file" ref="030c974ad076ab030e961f4860d7300a" args="(Flash *flash, char *file, int format)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int flash_load_from_file </td>
<td>(</td>
<td class="paramtype">Flash *&nbsp;</td>
<td class="paramname"> <em>flash</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>file</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>format</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Load program data into flash from a file.
<p>
<p>Definition at line <a class="el" href="flash_8c-source.html#l00164">164</a> of file <a class="el" href="flash_8c-source.html">flash.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00046">avr_warning</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l01297">avr_core_load_program()</a>.</p>
</div>
</div><p>
<a class="anchor" name="83456740d126c8a8790796597129ad9b"></a><!-- doxytag: member="flash.c::flash_get_size" ref="83456740d126c8a8790796597129ad9b" args="(Flash *flash)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int flash_get_size </td>
<td>(</td>
<td class="paramtype">Flash *&nbsp;</td>
<td class="paramname"> <em>flash</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Accessor method to get the size of a flash.
<p>
<p>Definition at line <a class="el" href="flash_8c-source.html#l00210">210</a> of file <a class="el" href="flash_8c-source.html">flash.c</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l00562">avr_core_get_sizes()</a>.</p>
</div>
</div><p>
<a class="anchor" name="1adccaaad97ed90fdf2aca154edbedb5"></a><!-- doxytag: member="flash.c::flash_dump_core" ref="1adccaaad97ed90fdf2aca154edbedb5" args="(Flash *flash, FILE *f_core)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void flash_dump_core </td>
<td>(</td>
<td class="paramtype">Flash *&nbsp;</td>
<td class="paramname"> <em>flash</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">FILE *&nbsp;</td>
<td class="paramname"> <em>f_core</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Dump the contents of the flash to a file descriptor in text format.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>flash</em>&nbsp;</td><td>A pointer to a flash object. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>f_core</em>&nbsp;</td><td>An open file descriptor. </td></tr>
</table>
</dl>
<p>Definition at line <a class="el" href="flash_8c-source.html#l00223">223</a> of file <a class="el" href="flash_8c-source.html">flash.c</a>.</p>
<p>References <a class="el" href="flash_8c.html#4fd6af69b0ff01070ff7598920761a2b">flash_read()</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l01284">avr_core_dump_core()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,98 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>gdbserver.c File Reference</h1>Provide an interface to gdb's remote serial protocol. <a href="#_details">More...</a>
<p>
<p>
<a href="gdbserver_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="gdbserver_8c.html#e6a15ee389d8d89a9f8408490f3d8606">gdb_interact</a> (GdbComm_T *comm, int port, int debug_on)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Provide an interface to gdb's remote serial protocol.
<p>
This module allows a program to be used by gdb as a remote target. The remote target and gdb communicate via gdb's remote serial protocol. The protocol is documented in the gdb manual and will not be repeated here.<p>
Hitting Ctrl-c in gdb can be used to interrupt the remote target while it is processing instructions and return control back to gdb.<p>
Issuing a 'signal SIGxxx' command from gdb will send the signal to the remote target via a "continue with signal" packet. The target will process and interpret the signal, but not pass it on to the AVR program running in the target since it really makes no sense to do so. In some circumstances, it may make sense to use the gdb signal mechanism as a way to initiate some sort of external stimulus to be passed on to the virtual hardware system.<p>
Signals from gdb which are processed have the following meanings:<p>
<ul>
<li><code>SIGHUP</code> Initiate a reset of the target. (Simulates a hardware reset) </li>
</ul>
<p>Definition in file <a class="el" href="gdbserver_8c-source.html">gdbserver.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="e6a15ee389d8d89a9f8408490f3d8606"></a><!-- doxytag: member="gdbserver.c::gdb_interact" ref="e6a15ee389d8d89a9f8408490f3d8606" args="(GdbComm_T *comm, int port, int debug_on)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void gdb_interact </td>
<td>(</td>
<td class="paramtype">GdbComm_T *&nbsp;</td>
<td class="paramname"> <em>comm</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>port</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>debug_on</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Start interacting with gdb.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>comm</em>&nbsp;</td><td>A previously initialized simulator comm </td></tr>
<tr><td valign="top"></td><td valign="top"><em>port</em>&nbsp;</td><td>Port which server will listen for connections on. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>debug_on</em>&nbsp;</td><td>Turn on gdb debug diagnostic messages.</td></tr>
</table>
</dl>
Start a tcp server socket on localhost listening for connections on the given port. Once a connection is established, enter an infinite loop and process command requests from gdb using the remote serial protocol. Only a single connection is allowed at a time.
<p>Definition at line <a class="el" href="gdbserver_8c-source.html#l01320">1320</a> of file <a class="el" href="gdbserver_8c-source.html">gdbserver.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, <a class="el" href="sig_8c-source.html#l00119">signal_has_occurred()</a>, <a class="el" href="sig_8c-source.html#l00067">signal_watch_start()</a>, and <a class="el" href="sig_8c-source.html#l00097">signal_watch_stop()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,474 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li class="current"><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li class="current"><a href="globals.html"><span>All</span></a></li>
<li><a href="globals_func.html"><span>Functions</span></a></li>
<li><a href="globals_vars.html"><span>Variables</span></a></li>
<li><a href="globals_enum.html"><span>Enumerations</span></a></li>
<li><a href="globals_eval.html"><span>Enumerator</span></a></li>
<li><a href="globals_defs.html"><span>Defines</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="#index_a"><span>a</span></a></li>
<li><a href="#index_c"><span>c</span></a></li>
<li><a href="#index_d"><span>d</span></a></li>
<li><a href="#index_f"><span>f</span></a></li>
<li><a href="#index_g"><span>g</span></a></li>
<li><a href="#index_h"><span>h</span></a></li>
<li><a href="#index_m"><span>m</span></a></li>
<li><a href="#index_o"><span>o</span></a></li>
<li><a href="#index_p"><span>p</span></a></li>
<li><a href="#index_s"><span>s</span></a></li>
<li><a href="#index_t"><span>t</span></a></li>
<li><a href="#index_u"><span>u</span></a></li>
<li><a href="#index_v"><span>v</span></a></li>
</ul>
</div>
<p>
</div>
<div class="contents">
Here is a list of all documented functions, variables, defines, enums, and typedefs with links to the documentation:
<p>
<h3><a class="anchor" name="index_a">- a -</a></h3><ul>
<li>adc_construct()
: <a class="el" href="adc_8c.html#e4966489f818e0c180369072c0f75424">adc.c</a>
<li>adc_create()
: <a class="el" href="adc_8c.html#f02be378f9ec8c8c2a2615225c4521d9">adc.c</a>
<li>adc_destroy()
: <a class="el" href="adc_8c.html#d3da5f1cc86c9ecde4ddc71eb3468e99">adc.c</a>
<li>adc_int_create()
: <a class="el" href="adc_8c.html#9879d2be21cb9c2b10bd20b39ff2000d">adc.c</a>
<li>adc_intr_construct()
: <a class="el" href="adc_8c.html#4db5253cbc808007b02e3baed5fcb3e7">adc.c</a>
<li>adc_intr_destroy()
: <a class="el" href="adc_8c.html#5c602673eed7cc14090b7180c4f961fe">adc.c</a>
<li>avr_core_add_ext_rd_wr()
: <a class="el" href="avrcore_8c.html#659be5dd132e4c71fc0fee11b9ee55e2">avrcore.c</a>
<li>avr_core_async_cb_add()
: <a class="el" href="avrcore_8c.html#e821588464c39dbdcc9fb5eea45da0aa">avrcore.c</a>
<li>avr_core_async_cb_exec()
: <a class="el" href="avrcore_8c.html#b1a909800cdeb5312b9108264a9ce63f">avrcore.c</a>
<li>avr_core_attach_vdev()
: <a class="el" href="avrcore_8c.html#3ab00f070e80ce3b036f2f24c23408f6">avrcore.c</a>
<li>avr_core_CK_get()
: <a class="el" href="avrcore_8c.html#da85cb13c88707b79cd17e9e8bc8be2e">avrcore.c</a>
<li>avr_core_CK_incr()
: <a class="el" href="avrcore_8c.html#24979e495b8131dd39916c45633f95d1">avrcore.c</a>
<li>avr_core_clk_cb_add()
: <a class="el" href="avrcore_8c.html#3e755b8388c3c44ea514484ce53ace75">avrcore.c</a>
<li>avr_core_clk_cb_exec()
: <a class="el" href="avrcore_8c.html#6f35a121465954ca33a4386860a4d230">avrcore.c</a>
<li>avr_core_destroy()
: <a class="el" href="avrcore_8c.html#8207cc5f8097a138cb1d973f2516edbd">avrcore.c</a>
<li>avr_core_disable_breakpoints()
: <a class="el" href="avrcore_8c.html#10235f9fb338d7af94fbbfd32960aaf7">avrcore.c</a>
<li>avr_core_dump_core()
: <a class="el" href="avrcore_8c.html#1db4b2fd65cfc5ffb3d651a84ef1ffa8">avrcore.c</a>
<li>avr_core_enable_breakpoints()
: <a class="el" href="avrcore_8c.html#e58a99ad02773957b73949f9101ac19a">avrcore.c</a>
<li>avr_core_get_sizes()
: <a class="el" href="avrcore_8c.html#b93554af0ddae11dc386c7a8017d21c2">avrcore.c</a>
<li>avr_core_get_sleep_mode()
: <a class="el" href="avrcore_8c.html#0ae99fbfe0056db789acb941e21ac485">avrcore.c</a>
<li>avr_core_get_state()
: <a class="el" href="avrcore_8c.html#9b5f4879774fd40d874f001aed064e9a">avrcore.c</a>
<li>avr_core_get_vdev_by_addr()
: <a class="el" href="avrcore_8c.html#f0c70bc7f992dcacd8ab411993bea5b5">avrcore.c</a>
<li>avr_core_get_vdev_by_name()
: <a class="el" href="avrcore_8c.html#2fe7d91e4bb91fbbb2e1856175fd83e8">avrcore.c</a>
<li>avr_core_insert_breakpoint()
: <a class="el" href="avrcore_8c.html#5c69dbf17a369ce91d3e69eff6bdaade">avrcore.c</a>
<li>avr_core_inst_CKS_get()
: <a class="el" href="avrcore_8c.html#c5750625afaaee1d8b300590a8254355">avrcore.c</a>
<li>avr_core_inst_CKS_set()
: <a class="el" href="avrcore_8c.html#9946d3935abc7fb34f71217b4247411a">avrcore.c</a>
<li>avr_core_io_display_names()
: <a class="el" href="avrcore_8c.html#3164b9e917e52fe8679fabb4f90f1047">avrcore.c</a>
<li>avr_core_io_read()
: <a class="el" href="avrcore_8c.html#37c29a0a8e4d35db1645952a3b0c31ec">avrcore.c</a>
<li>avr_core_io_write()
: <a class="el" href="avrcore_8c.html#3de50d67489f392fdd4764eb5907c1cb">avrcore.c</a>
<li>avr_core_irq_clear()
: <a class="el" href="avrcore_8c.html#061cca855f6acfb73bb4defd915d9b46">avrcore.c</a>
<li>avr_core_irq_clear_all()
: <a class="el" href="avrcore_8c.html#8abe1d503b8817a2347cb6b49f6900fb">avrcore.c</a>
<li>avr_core_irq_get_pending()
: <a class="el" href="avrcore_8c.html#6159e6170ce727f6955c11c64c20f47c">avrcore.c</a>
<li>avr_core_irq_raise()
: <a class="el" href="avrcore_8c.html#90ca5d4a60478f9fccad81724a4be552">avrcore.c</a>
<li>avr_core_load_eeprom()
: <a class="el" href="avrcore_8c.html#8d10faddeca29fb2322c2d89692862c2">avrcore.c</a>
<li>avr_core_load_program()
: <a class="el" href="avrcore_8c.html#598a22a9aeb0742cf73d0094ea1ad34a">avrcore.c</a>
<li>avr_core_new()
: <a class="el" href="avrcore_8c.html#5c5f2184f521edd707f9b23f98c4fe9b">avrcore.c</a>
<li>avr_core_PC_incr()
: <a class="el" href="avrcore_8c.html#7eb711367f24d153375ca1a79b811861">avrcore.c</a>
<li>avr_core_PC_size()
: <a class="el" href="avrcore_8c.html#f100fd3104613678ffd2d47b42ac5bc1">avrcore.c</a>
<li>avr_core_rampz_get()
: <a class="el" href="avrcore_8c.html#50111dc4a41bae2dae453f1130572ea7">avrcore.c</a>
<li>avr_core_rampz_set()
: <a class="el" href="avrcore_8c.html#afa2afb8a7264d21b93a3cfe64f2628c">avrcore.c</a>
<li>avr_core_remove_breakpoint()
: <a class="el" href="avrcore_8c.html#ec8478c2c50734c8d02a6ed5c5ab3b7c">avrcore.c</a>
<li>avr_core_reset()
: <a class="el" href="avrcore_8c.html#82a6c62c8efa30fc43de8754895ebddd">avrcore.c</a>
<li>avr_core_run()
: <a class="el" href="avrcore_8c.html#40ce5b08150e1450aad33c78c11dfa5e">avrcore.c</a>
<li>avr_core_set_sleep_mode()
: <a class="el" href="avrcore_8c.html#76bc487fc2fcc2df128c6492d2b5ce82">avrcore.c</a>
<li>avr_core_set_state()
: <a class="el" href="avrcore_8c.html#b312a0bf53e0cc685f84b29dd25e033c">avrcore.c</a>
<li>avr_core_sreg_get_bit()
: <a class="el" href="avrcore_8c.html#4999e93ffea9a303c5a3ad2b97b4fee1">avrcore.c</a>
<li>avr_core_sreg_set_bit()
: <a class="el" href="avrcore_8c.html#998921f9755ca4c89d576389001987e9">avrcore.c</a>
<li>avr_core_stack_pop()
: <a class="el" href="avrcore_8c.html#03d31c526ed7012ed1a282d236d065c3">avrcore.c</a>
<li>avr_core_stack_push()
: <a class="el" href="avrcore_8c.html#518b9d58304247ee508d389137c921b8">avrcore.c</a>
<li>avr_core_step()
: <a class="el" href="avrcore_8c.html#d610fa9920f74abf02206241d7348344">avrcore.c</a>
<li>avr_error
: <a class="el" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a">avrerror.c</a>
<li>avr_free()
: <a class="el" href="avrmalloc_8c.html#082a9d6d40f5e8bad64441ad950ec12c">avrmalloc.c</a>
<li>avr_malloc()
: <a class="el" href="avrmalloc_8c.html#26b696030eced4eab8f5ec6cf2fb5781">avrmalloc.c</a>
<li>avr_malloc0()
: <a class="el" href="avrmalloc_8c.html#4726a1eed41cbd3b6df7e5f035812683">avrmalloc.c</a>
<li>avr_message
: <a class="el" href="avrerror_8c.html#deeaf2330efd6054822bc9146527777b">avrerror.c</a>
<li>avr_new
: <a class="el" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578">avrmalloc.c</a>
<li>avr_new0
: <a class="el" href="avrmalloc_8c.html#ac6d810b48b67b90412badbd4b71f4e3">avrmalloc.c</a>
<li>avr_realloc()
: <a class="el" href="avrmalloc_8c.html#258e72f96d28a713d6f0d7d4e4e37d26">avrmalloc.c</a>
<li>avr_renew
: <a class="el" href="avrmalloc_8c.html#2bff90bec7ab1eafa9e1a51d618446e9">avrmalloc.c</a>
<li>avr_strdup()
: <a class="el" href="avrmalloc_8c.html#2af0d2ad3de670228794080e914120ea">avrmalloc.c</a>
<li>avr_warning
: <a class="el" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170">avrerror.c</a>
</ul>
<h3><a class="anchor" name="index_c">- c -</a></h3><ul>
<li>class_construct()
: <a class="el" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e">avrclass.c</a>
<li>class_destroy()
: <a class="el" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5">avrclass.c</a>
<li>class_new()
: <a class="el" href="avrclass_8c.html#d07c51bd8c81db78fab8d240fd698024">avrclass.c</a>
<li>class_overload_destroy()
: <a class="el" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1">avrclass.c</a>
<li>class_ref()
: <a class="el" href="avrclass_8c.html#ff0f5b14bf2740f208041d515f3ba93f">avrclass.c</a>
<li>class_unref()
: <a class="el" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693">avrclass.c</a>
</ul>
<h3><a class="anchor" name="index_d">- d -</a></h3><ul>
<li>decode_init_lookup_table()
: <a class="el" href="decoder_8c.html#e3a0b1d94b75719be5f23e9fb9b896dc">decoder.c</a>
<li>decode_opcode()
: <a class="el" href="decoder_8c.html#53bbe21cbd08336a39da9fbe4e9cb09e">decoder.c</a>
<li>decoder_operand_masks
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d">decoder.c</a>
<li>dev_supp_list_devices()
: <a class="el" href="devsupp_8c.html#3fc3008c90677776ac1a67956e2d8701">devsupp.c</a>
<li>dev_supp_lookup_device()
: <a class="el" href="devsupp_8c.html#016b622b99dbb64383e7ad34a8f746f1">devsupp.c</a>
<li>display_clock()
: <a class="el" href="display_8c.html#e210ab2ee875db342dcd52d43fa47693">display.c</a>
<li>display_close()
: <a class="el" href="display_8c.html#428c3bdca61ba3679fbf3c7c8356c8f6">display.c</a>
<li>display_eeprom()
: <a class="el" href="display_8c.html#6a425136a8b941eba6671bbea330283b">display.c</a>
<li>display_flash()
: <a class="el" href="display_8c.html#69d6536d741f20da943fb64373bbae11">display.c</a>
<li>display_io_reg()
: <a class="el" href="display_8c.html#ed9707596c157777dc33fe1371ded7fc">display.c</a>
<li>display_io_reg_name()
: <a class="el" href="display_8c.html#e2e93695af3a8b1676402cebc82d1b3f">display.c</a>
<li>display_open()
: <a class="el" href="display_8c.html#aeea9e0008fcf18c0514a45e99a7f4d2">display.c</a>
<li>display_pc()
: <a class="el" href="display_8c.html#2a7b52120c3b22bf9045b473433a3590">display.c</a>
<li>display_reg()
: <a class="el" href="display_8c.html#225f48cf9ff069c974e3074754f6dbd1">display.c</a>
<li>display_send_msg()
: <a class="el" href="display_8c.html#f45795a80967d9faeea06240281f34e6">display.c</a>
<li>display_sram()
: <a class="el" href="display_8c.html#8cfda7ebd92c20bf3376e0355f80bebe">display.c</a>
<li>dlist_add()
: <a class="el" href="utils_8c.html#2f451be088e616a1c94508c1312e99ed">utils.c</a>
<li>dlist_add_head()
: <a class="el" href="utils_8c.html#46d7303de632a8f87f61f2bf555f1840">utils.c</a>
<li>dlist_delete()
: <a class="el" href="utils_8c.html#0be979713f40bde065ecf4c51b41fe0d">utils.c</a>
<li>dlist_delete_all()
: <a class="el" href="utils_8c.html#67215034f68b284935138064aa2f9cd0">utils.c</a>
<li>dlist_get_head_data()
: <a class="el" href="utils_8c.html#7c8dfedd93ef4bc0b91d4c1c45c86f0c">utils.c</a>
<li>dlist_iterator()
: <a class="el" href="utils_8c.html#bbba7ec7eefce4bdb4543e1096021186">utils.c</a>
<li>dlist_lookup()
: <a class="el" href="utils_8c.html#d8319271cd9c519c6e97f381739497a3">utils.c</a>
</ul>
<h3><a class="anchor" name="index_f">- f -</a></h3><ul>
<li>flash_construct()
: <a class="el" href="flash_8c.html#1289488dcdca6e7670ee607575c8d54d">flash.c</a>
<li>flash_destroy()
: <a class="el" href="flash_8c.html#671e5df04d7524f10ae472a04b3a0b4d">flash.c</a>
<li>flash_dump_core()
: <a class="el" href="flash_8c.html#1adccaaad97ed90fdf2aca154edbedb5">flash.c</a>
<li>flash_get_size()
: <a class="el" href="flash_8c.html#83456740d126c8a8790796597129ad9b">flash.c</a>
<li>flash_load_from_file()
: <a class="el" href="flash_8c.html#030c974ad076ab030e961f4860d7300a">flash.c</a>
<li>flash_new()
: <a class="el" href="flash_8c.html#2b69c1bd49cd27f2fe58baf4c453c92c">flash.c</a>
<li>flash_read()
: <a class="el" href="flash_8c.html#4fd6af69b0ff01070ff7598920761a2b">flash.c</a>
<li>flash_write()
: <a class="el" href="flash_8c.html#eccaffb7a1e3a2d8faf2ca923735548b">flash.c</a>
<li>flash_write_hi8()
: <a class="el" href="flash_8c.html#b5a09ffc2f0635cb5e28b5a5c9e1c3f9">flash.c</a>
<li>flash_write_lo8()
: <a class="el" href="flash_8c.html#dc8ba20623259c3f23360c952effa310">flash.c</a>
</ul>
<h3><a class="anchor" name="index_g">- g -</a></h3><ul>
<li>gdb_interact()
: <a class="el" href="gdbserver_8c.html#e6a15ee389d8d89a9f8408490f3d8606">gdbserver.c</a>
<li>get_program_time()
: <a class="el" href="utils_8c.html#d71e2db9144e1b1d539e1326cbdcbf04">utils.c</a>
<li>global_debug_inst_output
: <a class="el" href="avrcore_8c.html#7b9da9db79cd10ee75d5b363dd521c6e">avrcore.c</a>
</ul>
<h3><a class="anchor" name="index_h">- h -</a></h3><ul>
<li>hwstack_construct()
: <a class="el" href="stack_8c.html#d02c1ea58dfb09cff13e4ad524bb8797">stack.c</a>
<li>hwstack_destroy()
: <a class="el" href="stack_8c.html#837cbada76cb76af5aa46618d90ea00e">stack.c</a>
<li>hwstack_new()
: <a class="el" href="stack_8c.html#f9b8a6ec32f0798480f4bd02733996b1">stack.c</a>
</ul>
<h3><a class="anchor" name="index_m">- m -</a></h3><ul>
<li>mask_A_5
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4dd89aab6be79b8d65afd2254959752734">decoder.c</a>
<li>mask_A_6
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d523800aea8f896ae36296348874f47d0">decoder.c</a>
<li>mask_k_12
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4dd9f0609ab28e257ca40b34ea153bd105">decoder.c</a>
<li>mask_k_22
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d6da049a50243439217ed820e5523785e">decoder.c</a>
<li>mask_K_6
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d646704ce73041c50e5d60d1c91f46b7b">decoder.c</a>
<li>mask_k_7
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d8d97911f0bb89617bed0886469c6d8a0">decoder.c</a>
<li>mask_K_8
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4daa83eaace5a8e5c10585e42b07cdc735">decoder.c</a>
<li>mask_q_displ
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d6a0f87ce56ad1f4962da82398dae660c">decoder.c</a>
<li>mask_Rd_2
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d72567b93ba2b0b220237be1b612453e9">decoder.c</a>
<li>mask_Rd_3
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4db291bde5fc7c589395619ccfdb0cab22">decoder.c</a>
<li>mask_Rd_4
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4db65c1df2ad87168b0828ff19b568794f">decoder.c</a>
<li>mask_Rd_5
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d03e9222f48dc9c72606a63f931cdb84d">decoder.c</a>
<li>mask_reg_bit
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4db93caa109e70b4befe8088f5aec8c676">decoder.c</a>
<li>mask_Rr_3
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4da42ff712d0e38f8a725730497ef18f10">decoder.c</a>
<li>mask_Rr_4
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4dbf39793679b207f9bf5ec218812b9584">decoder.c</a>
<li>mask_Rr_5
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d6baa83403f524cd30eb34a8e6e3d8891">decoder.c</a>
<li>mask_sreg_bit
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d98e3e7dd33e97c078a175a254f490130">decoder.c</a>
<li>mem_attach()
: <a class="el" href="memory_8c.html#9c93797cfe896dcfac4c139ad9f3df7b">memory.c</a>
<li>mem_construct()
: <a class="el" href="memory_8c.html#98917d50e483a8f307f80574d5a3b0d2">memory.c</a>
<li>mem_destroy()
: <a class="el" href="memory_8c.html#114285e9d962c71f77ba4abc57f37670">memory.c</a>
<li>mem_dump_core()
: <a class="el" href="memory_8c.html#4d727abdd19adeb472009cd9938886d4">memory.c</a>
<li>mem_get_vdevice_by_addr()
: <a class="el" href="memory_8c.html#c5dc450f9b9f874d58df945f1a27b9c4">memory.c</a>
<li>mem_get_vdevice_by_name()
: <a class="el" href="memory_8c.html#502735c9e7d8045149e53f5cff95ee6f">memory.c</a>
<li>mem_io_fetch()
: <a class="el" href="memory_8c.html#0a2cee082a6775c45b08324be6ded380">memory.c</a>
<li>mem_new()
: <a class="el" href="memory_8c.html#55873ce95bd961891e8a2338bb51fbd9">memory.c</a>
<li>mem_read()
: <a class="el" href="memory_8c.html#7ebc4d26966257412b56ef78dd33ad51">memory.c</a>
<li>mem_reset()
: <a class="el" href="memory_8c.html#fb9d511f1ce2e883195d07fd7900f635">memory.c</a>
<li>mem_write()
: <a class="el" href="memory_8c.html#218836433955d34b6eabfbc3d48aedda">memory.c</a>
<li>memstack_construct()
: <a class="el" href="stack_8c.html#46bd775c5dc8d6c19ec06b2c9da06a41">stack.c</a>
<li>memstack_destroy()
: <a class="el" href="stack_8c.html#64cea8305fc14f82896e499e8fabbe15">stack.c</a>
<li>memstack_new()
: <a class="el" href="stack_8c.html#7b2371560513634e9e008d0e3723e67e">stack.c</a>
</ul>
<h3><a class="anchor" name="index_o">- o -</a></h3><ul>
<li>ocreg16_construct()
: <a class="el" href="timers_8c.html#62c8b38185dbc7ced00aa878a2b96590">timers.c</a>
<li>ocreg16_create()
: <a class="el" href="timers_8c.html#c8de7810ae4a9b1eea06d0ecf50a7a4b">timers.c</a>
</ul>
<h3><a class="anchor" name="index_p">- p -</a></h3><ul>
<li>port_add_ext_rd_wr()
: <a class="el" href="ports_8c.html#4711762fbc2eb589ed9d4973df5d5a88">ports.c</a>
<li>port_create()
: <a class="el" href="ports_8c.html#00826229de675b5cd869c124267b7c3b">ports.c</a>
<li>port_ext_disable()
: <a class="el" href="ports_8c.html#ebb7d0728b81651d94a98d9640d9c328">ports.c</a>
<li>port_ext_enable()
: <a class="el" href="ports_8c.html#034de04c76c1ba1271c13edda67e83ba">ports.c</a>
</ul>
<h3><a class="anchor" name="index_s">- s -</a></h3><ul>
<li>set_bit_in_byte()
: <a class="el" href="utils_8c.html#eb8ce7ee7e6e35ee3ec8d3539bb52519">utils.c</a>
<li>set_bit_in_word()
: <a class="el" href="utils_8c.html#4250710ef21e0fe21d15dcc6203e4298">utils.c</a>
<li>signal_has_occurred()
: <a class="el" href="sig_8c.html#3aff57264b67d02a293d6e14a88b9c58">sig.c</a>
<li>signal_reset()
: <a class="el" href="sig_8c.html#fe45d9546c756459607ce4cbc98860e6">sig.c</a>
<li>signal_watch_start()
: <a class="el" href="sig_8c.html#1a3fd779478f70244e210af9437c3ac5">sig.c</a>
<li>signal_watch_stop()
: <a class="el" href="sig_8c.html#4ef4dc91eb8d929844ea031c9cd85ede">sig.c</a>
<li>sp_create()
: <a class="el" href="stack_8c.html#6df53075eb6ae9223f833080bfc28b94">stack.c</a>
<li>spi_construct()
: <a class="el" href="spi_8c.html#d490c5d5f4d7e69e5d423ab461d66df5">spi.c</a>
<li>spi_create()
: <a class="el" href="spi_8c.html#ef235e6fa60210d1f6c27d5884d0b23d">spi.c</a>
<li>spi_destroy()
: <a class="el" href="spi_8c.html#9ef936c44048c70e2bc6227e64d27216">spi.c</a>
<li>spi_intr_construct()
: <a class="el" href="spi_8c.html#2d31cddf4f3c10bdb40e5aa74c98b87c">spi.c</a>
<li>spi_intr_destroy()
: <a class="el" href="spi_8c.html#a7e63b808478f9afb300edaa7c6f1cd6">spi.c</a>
<li>spii_create()
: <a class="el" href="spi_8c.html#dce1c660a1d1605ba912d1c246ad38ae">spi.c</a>
<li>stack_construct()
: <a class="el" href="stack_8c.html#119a7d0b0be8ef37e798c8f9c6ae4722">stack.c</a>
<li>stack_destroy()
: <a class="el" href="stack_8c.html#c6c460b2f72e2a2095cd70b4414d4933">stack.c</a>
<li>stack_new()
: <a class="el" href="stack_8c.html#83de2962ed4166699cc8f40edcc1f380">stack.c</a>
<li>stack_pop()
: <a class="el" href="stack_8c.html#9077dfc6f98c4fe4b51b43db90055aaa">stack.c</a>
<li>stack_push()
: <a class="el" href="stack_8c.html#bd76f1a4f5bfc1e2b8699f3787cf7af2">stack.c</a>
<li>str2ffmt()
: <a class="el" href="utils_8c.html#5d306d06881ee5b68d679edec2e7fd75">utils.c</a>
</ul>
<h3><a class="anchor" name="index_t">- t -</a></h3><ul>
<li>timer0_construct()
: <a class="el" href="timers_8c.html#4aedd082ecfe36cc7c2a24e4bae44be3">timers.c</a>
<li>timer0_create()
: <a class="el" href="timers_8c.html#3bb4b9cbfa8d8ff090051f306d223bf2">timers.c</a>
<li>timer0_destroy()
: <a class="el" href="timers_8c.html#6d078109b034e0ca46d10df1caa6d7af">timers.c</a>
<li>timer16_construct()
: <a class="el" href="timers_8c.html#f614713078dc3bf66a7c765f409cf517">timers.c</a>
<li>timer16_create()
: <a class="el" href="timers_8c.html#fc0ff9b70476bf2134ee7ea55b6da86d">timers.c</a>
<li>timer_int_create()
: <a class="el" href="timers_8c.html#208259596835cc401b33bd60da45bf6a">timers.c</a>
<li>timer_intr_construct()
: <a class="el" href="timers_8c.html#b6a748a5044a9bad3e7d41bf93e80d41">timers.c</a>
<li>timer_intr_destroy()
: <a class="el" href="timers_8c.html#527da83fda0848baaceb0929eb61815e">timers.c</a>
</ul>
<h3><a class="anchor" name="index_u">- u -</a></h3><ul>
<li>uart_construct()
: <a class="el" href="uart_8c.html#bb93863003e66ea6b40400a4631656aa">uart.c</a>
<li>uart_create()
: <a class="el" href="uart_8c.html#15018100db23349def4e37027d5a8932">uart.c</a>
<li>uart_destroy()
: <a class="el" href="uart_8c.html#c80ec8e26d6b5ece2d7e4c57f371ac01">uart.c</a>
<li>uart_int_create()
: <a class="el" href="uart_8c.html#d7ab0fb5b4d3fbec10a1777c2627c2f0">uart.c</a>
<li>uart_intr_construct()
: <a class="el" href="uart_8c.html#673d5a70c22d5a19f244fe2a17fd6c1d">uart.c</a>
<li>uart_intr_destroy()
: <a class="el" href="uart_8c.html#cc2bbf6f2d72e20d553521a554ab551a">uart.c</a>
<li>usb_construct()
: <a class="el" href="usb_8c.html#b46dace89d6472ed1f0dc235d2b9e5c5">usb.c</a>
<li>usb_create()
: <a class="el" href="usb_8c.html#7b5bc9c47afcbe8cf57d75dd4ed47968">usb.c</a>
<li>usb_destroy()
: <a class="el" href="usb_8c.html#238a235b4fe1c88d56b67e65dc57274d">usb.c</a>
<li>usb_intr_construct()
: <a class="el" href="usb_8c.html#bc59e75f4f846b5075470bb8b7d00cf0">usb.c</a>
<li>usb_intr_destroy()
: <a class="el" href="usb_8c.html#c02f3bf581c2e053d30b3c0e004713f5">usb.c</a>
<li>usbi_create()
: <a class="el" href="usb_8c.html#254a13da6e1f9dcda78a1a01c3324cd8">usb.c</a>
</ul>
<h3><a class="anchor" name="index_v">- v -</a></h3><ul>
<li>vdev_add_addr()
: <a class="el" href="device_8c.html#5777a3eab86212d53f616d687babf6a9">device.c</a>
<li>vdev_construct()
: <a class="el" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4">device.c</a>
<li>vdev_def_AddAddr()
: <a class="el" href="device_8c.html#5cebfd18a219807f27e4a3f38da4a5d0">device.c</a>
<li>vdev_destroy()
: <a class="el" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9">device.c</a>
<li>vdev_get_core()
: <a class="el" href="device_8c.html#b59809dd04174aca0940efa2505a3524">device.c</a>
<li>vdev_new()
: <a class="el" href="device_8c.html#134ea79c2ecf6f000d28d08b05ed40ca">device.c</a>
<li>vdev_read()
: <a class="el" href="device_8c.html#2c32d0afc4607136c886acbf362874ed">device.c</a>
<li>vdev_reset()
: <a class="el" href="device_8c.html#1d98f1f4d77ce7d714ffde36ada57db7">device.c</a>
<li>vdev_set_core()
: <a class="el" href="device_8c.html#2a8db1cadfd3c26e9ea7ea0e6d03c132">device.c</a>
<li>vdev_write()
: <a class="el" href="device_8c.html#502a4216ffd7501ad3059e95d0f5572f">device.c</a>
</ul>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,59 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li class="current"><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="globals.html"><span>All</span></a></li>
<li><a href="globals_func.html"><span>Functions</span></a></li>
<li><a href="globals_vars.html"><span>Variables</span></a></li>
<li><a href="globals_enum.html"><span>Enumerations</span></a></li>
<li><a href="globals_eval.html"><span>Enumerator</span></a></li>
<li class="current"><a href="globals_defs.html"><span>Defines</span></a></li>
</ul>
</div>
</div>
<div class="contents">
&nbsp;
<p>
<ul>
<li>avr_error
: <a class="el" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a">avrerror.c</a>
<li>avr_message
: <a class="el" href="avrerror_8c.html#deeaf2330efd6054822bc9146527777b">avrerror.c</a>
<li>avr_new
: <a class="el" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578">avrmalloc.c</a>
<li>avr_new0
: <a class="el" href="avrmalloc_8c.html#ac6d810b48b67b90412badbd4b71f4e3">avrmalloc.c</a>
<li>avr_renew
: <a class="el" href="avrmalloc_8c.html#2bff90bec7ab1eafa9e1a51d618446e9">avrmalloc.c</a>
<li>avr_warning
: <a class="el" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170">avrerror.c</a>
</ul>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,49 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li class="current"><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="globals.html"><span>All</span></a></li>
<li><a href="globals_func.html"><span>Functions</span></a></li>
<li><a href="globals_vars.html"><span>Variables</span></a></li>
<li class="current"><a href="globals_enum.html"><span>Enumerations</span></a></li>
<li><a href="globals_eval.html"><span>Enumerator</span></a></li>
<li><a href="globals_defs.html"><span>Defines</span></a></li>
</ul>
</div>
</div>
<div class="contents">
&nbsp;
<p>
<ul>
<li>decoder_operand_masks
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d">decoder.c</a>
</ul>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,81 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li class="current"><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="globals.html"><span>All</span></a></li>
<li><a href="globals_func.html"><span>Functions</span></a></li>
<li><a href="globals_vars.html"><span>Variables</span></a></li>
<li><a href="globals_enum.html"><span>Enumerations</span></a></li>
<li class="current"><a href="globals_eval.html"><span>Enumerator</span></a></li>
<li><a href="globals_defs.html"><span>Defines</span></a></li>
</ul>
</div>
</div>
<div class="contents">
&nbsp;
<p>
<ul>
<li>mask_A_5
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4dd89aab6be79b8d65afd2254959752734">decoder.c</a>
<li>mask_A_6
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d523800aea8f896ae36296348874f47d0">decoder.c</a>
<li>mask_k_12
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4dd9f0609ab28e257ca40b34ea153bd105">decoder.c</a>
<li>mask_k_22
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d6da049a50243439217ed820e5523785e">decoder.c</a>
<li>mask_K_6
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d646704ce73041c50e5d60d1c91f46b7b">decoder.c</a>
<li>mask_k_7
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d8d97911f0bb89617bed0886469c6d8a0">decoder.c</a>
<li>mask_K_8
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4daa83eaace5a8e5c10585e42b07cdc735">decoder.c</a>
<li>mask_q_displ
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d6a0f87ce56ad1f4962da82398dae660c">decoder.c</a>
<li>mask_Rd_2
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d72567b93ba2b0b220237be1b612453e9">decoder.c</a>
<li>mask_Rd_3
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4db291bde5fc7c589395619ccfdb0cab22">decoder.c</a>
<li>mask_Rd_4
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4db65c1df2ad87168b0828ff19b568794f">decoder.c</a>
<li>mask_Rd_5
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d03e9222f48dc9c72606a63f931cdb84d">decoder.c</a>
<li>mask_reg_bit
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4db93caa109e70b4befe8088f5aec8c676">decoder.c</a>
<li>mask_Rr_3
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4da42ff712d0e38f8a725730497ef18f10">decoder.c</a>
<li>mask_Rr_4
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4dbf39793679b207f9bf5ec218812b9584">decoder.c</a>
<li>mask_Rr_5
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d6baa83403f524cd30eb34a8e6e3d8891">decoder.c</a>
<li>mask_sreg_bit
: <a class="el" href="decoder_8c.html#b6fd98079c0b0b68051c030c2abdca4d98e3e7dd33e97c078a175a254f490130">decoder.c</a>
</ul>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,424 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li class="current"><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="globals.html"><span>All</span></a></li>
<li class="current"><a href="globals_func.html"><span>Functions</span></a></li>
<li><a href="globals_vars.html"><span>Variables</span></a></li>
<li><a href="globals_enum.html"><span>Enumerations</span></a></li>
<li><a href="globals_eval.html"><span>Enumerator</span></a></li>
<li><a href="globals_defs.html"><span>Defines</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="#index_a"><span>a</span></a></li>
<li><a href="#index_c"><span>c</span></a></li>
<li><a href="#index_d"><span>d</span></a></li>
<li><a href="#index_f"><span>f</span></a></li>
<li><a href="#index_g"><span>g</span></a></li>
<li><a href="#index_h"><span>h</span></a></li>
<li><a href="#index_m"><span>m</span></a></li>
<li><a href="#index_o"><span>o</span></a></li>
<li><a href="#index_p"><span>p</span></a></li>
<li><a href="#index_s"><span>s</span></a></li>
<li><a href="#index_t"><span>t</span></a></li>
<li><a href="#index_u"><span>u</span></a></li>
<li><a href="#index_v"><span>v</span></a></li>
</ul>
</div>
<p>
</div>
<div class="contents">
&nbsp;
<p>
<h3><a class="anchor" name="index_a">- a -</a></h3><ul>
<li>adc_construct()
: <a class="el" href="adc_8c.html#e4966489f818e0c180369072c0f75424">adc.c</a>
<li>adc_create()
: <a class="el" href="adc_8c.html#f02be378f9ec8c8c2a2615225c4521d9">adc.c</a>
<li>adc_destroy()
: <a class="el" href="adc_8c.html#d3da5f1cc86c9ecde4ddc71eb3468e99">adc.c</a>
<li>adc_int_create()
: <a class="el" href="adc_8c.html#9879d2be21cb9c2b10bd20b39ff2000d">adc.c</a>
<li>adc_intr_construct()
: <a class="el" href="adc_8c.html#4db5253cbc808007b02e3baed5fcb3e7">adc.c</a>
<li>adc_intr_destroy()
: <a class="el" href="adc_8c.html#5c602673eed7cc14090b7180c4f961fe">adc.c</a>
<li>avr_core_add_ext_rd_wr()
: <a class="el" href="avrcore_8c.html#659be5dd132e4c71fc0fee11b9ee55e2">avrcore.c</a>
<li>avr_core_async_cb_add()
: <a class="el" href="avrcore_8c.html#e821588464c39dbdcc9fb5eea45da0aa">avrcore.c</a>
<li>avr_core_async_cb_exec()
: <a class="el" href="avrcore_8c.html#b1a909800cdeb5312b9108264a9ce63f">avrcore.c</a>
<li>avr_core_attach_vdev()
: <a class="el" href="avrcore_8c.html#3ab00f070e80ce3b036f2f24c23408f6">avrcore.c</a>
<li>avr_core_CK_get()
: <a class="el" href="avrcore_8c.html#da85cb13c88707b79cd17e9e8bc8be2e">avrcore.c</a>
<li>avr_core_CK_incr()
: <a class="el" href="avrcore_8c.html#24979e495b8131dd39916c45633f95d1">avrcore.c</a>
<li>avr_core_clk_cb_add()
: <a class="el" href="avrcore_8c.html#3e755b8388c3c44ea514484ce53ace75">avrcore.c</a>
<li>avr_core_clk_cb_exec()
: <a class="el" href="avrcore_8c.html#6f35a121465954ca33a4386860a4d230">avrcore.c</a>
<li>avr_core_destroy()
: <a class="el" href="avrcore_8c.html#8207cc5f8097a138cb1d973f2516edbd">avrcore.c</a>
<li>avr_core_disable_breakpoints()
: <a class="el" href="avrcore_8c.html#10235f9fb338d7af94fbbfd32960aaf7">avrcore.c</a>
<li>avr_core_dump_core()
: <a class="el" href="avrcore_8c.html#1db4b2fd65cfc5ffb3d651a84ef1ffa8">avrcore.c</a>
<li>avr_core_enable_breakpoints()
: <a class="el" href="avrcore_8c.html#e58a99ad02773957b73949f9101ac19a">avrcore.c</a>
<li>avr_core_get_sizes()
: <a class="el" href="avrcore_8c.html#b93554af0ddae11dc386c7a8017d21c2">avrcore.c</a>
<li>avr_core_get_sleep_mode()
: <a class="el" href="avrcore_8c.html#0ae99fbfe0056db789acb941e21ac485">avrcore.c</a>
<li>avr_core_get_state()
: <a class="el" href="avrcore_8c.html#9b5f4879774fd40d874f001aed064e9a">avrcore.c</a>
<li>avr_core_get_vdev_by_addr()
: <a class="el" href="avrcore_8c.html#f0c70bc7f992dcacd8ab411993bea5b5">avrcore.c</a>
<li>avr_core_get_vdev_by_name()
: <a class="el" href="avrcore_8c.html#2fe7d91e4bb91fbbb2e1856175fd83e8">avrcore.c</a>
<li>avr_core_insert_breakpoint()
: <a class="el" href="avrcore_8c.html#5c69dbf17a369ce91d3e69eff6bdaade">avrcore.c</a>
<li>avr_core_inst_CKS_get()
: <a class="el" href="avrcore_8c.html#c5750625afaaee1d8b300590a8254355">avrcore.c</a>
<li>avr_core_inst_CKS_set()
: <a class="el" href="avrcore_8c.html#9946d3935abc7fb34f71217b4247411a">avrcore.c</a>
<li>avr_core_io_display_names()
: <a class="el" href="avrcore_8c.html#3164b9e917e52fe8679fabb4f90f1047">avrcore.c</a>
<li>avr_core_io_read()
: <a class="el" href="avrcore_8c.html#37c29a0a8e4d35db1645952a3b0c31ec">avrcore.c</a>
<li>avr_core_io_write()
: <a class="el" href="avrcore_8c.html#3de50d67489f392fdd4764eb5907c1cb">avrcore.c</a>
<li>avr_core_irq_clear()
: <a class="el" href="avrcore_8c.html#061cca855f6acfb73bb4defd915d9b46">avrcore.c</a>
<li>avr_core_irq_clear_all()
: <a class="el" href="avrcore_8c.html#8abe1d503b8817a2347cb6b49f6900fb">avrcore.c</a>
<li>avr_core_irq_get_pending()
: <a class="el" href="avrcore_8c.html#6159e6170ce727f6955c11c64c20f47c">avrcore.c</a>
<li>avr_core_irq_raise()
: <a class="el" href="avrcore_8c.html#90ca5d4a60478f9fccad81724a4be552">avrcore.c</a>
<li>avr_core_load_eeprom()
: <a class="el" href="avrcore_8c.html#8d10faddeca29fb2322c2d89692862c2">avrcore.c</a>
<li>avr_core_load_program()
: <a class="el" href="avrcore_8c.html#598a22a9aeb0742cf73d0094ea1ad34a">avrcore.c</a>
<li>avr_core_new()
: <a class="el" href="avrcore_8c.html#5c5f2184f521edd707f9b23f98c4fe9b">avrcore.c</a>
<li>avr_core_PC_incr()
: <a class="el" href="avrcore_8c.html#7eb711367f24d153375ca1a79b811861">avrcore.c</a>
<li>avr_core_PC_size()
: <a class="el" href="avrcore_8c.html#f100fd3104613678ffd2d47b42ac5bc1">avrcore.c</a>
<li>avr_core_rampz_get()
: <a class="el" href="avrcore_8c.html#50111dc4a41bae2dae453f1130572ea7">avrcore.c</a>
<li>avr_core_rampz_set()
: <a class="el" href="avrcore_8c.html#afa2afb8a7264d21b93a3cfe64f2628c">avrcore.c</a>
<li>avr_core_remove_breakpoint()
: <a class="el" href="avrcore_8c.html#ec8478c2c50734c8d02a6ed5c5ab3b7c">avrcore.c</a>
<li>avr_core_reset()
: <a class="el" href="avrcore_8c.html#82a6c62c8efa30fc43de8754895ebddd">avrcore.c</a>
<li>avr_core_run()
: <a class="el" href="avrcore_8c.html#40ce5b08150e1450aad33c78c11dfa5e">avrcore.c</a>
<li>avr_core_set_sleep_mode()
: <a class="el" href="avrcore_8c.html#76bc487fc2fcc2df128c6492d2b5ce82">avrcore.c</a>
<li>avr_core_set_state()
: <a class="el" href="avrcore_8c.html#b312a0bf53e0cc685f84b29dd25e033c">avrcore.c</a>
<li>avr_core_sreg_get_bit()
: <a class="el" href="avrcore_8c.html#4999e93ffea9a303c5a3ad2b97b4fee1">avrcore.c</a>
<li>avr_core_sreg_set_bit()
: <a class="el" href="avrcore_8c.html#998921f9755ca4c89d576389001987e9">avrcore.c</a>
<li>avr_core_stack_pop()
: <a class="el" href="avrcore_8c.html#03d31c526ed7012ed1a282d236d065c3">avrcore.c</a>
<li>avr_core_stack_push()
: <a class="el" href="avrcore_8c.html#518b9d58304247ee508d389137c921b8">avrcore.c</a>
<li>avr_core_step()
: <a class="el" href="avrcore_8c.html#d610fa9920f74abf02206241d7348344">avrcore.c</a>
<li>avr_free()
: <a class="el" href="avrmalloc_8c.html#082a9d6d40f5e8bad64441ad950ec12c">avrmalloc.c</a>
<li>avr_malloc()
: <a class="el" href="avrmalloc_8c.html#26b696030eced4eab8f5ec6cf2fb5781">avrmalloc.c</a>
<li>avr_malloc0()
: <a class="el" href="avrmalloc_8c.html#4726a1eed41cbd3b6df7e5f035812683">avrmalloc.c</a>
<li>avr_realloc()
: <a class="el" href="avrmalloc_8c.html#258e72f96d28a713d6f0d7d4e4e37d26">avrmalloc.c</a>
<li>avr_strdup()
: <a class="el" href="avrmalloc_8c.html#2af0d2ad3de670228794080e914120ea">avrmalloc.c</a>
</ul>
<h3><a class="anchor" name="index_c">- c -</a></h3><ul>
<li>class_construct()
: <a class="el" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e">avrclass.c</a>
<li>class_destroy()
: <a class="el" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5">avrclass.c</a>
<li>class_new()
: <a class="el" href="avrclass_8c.html#d07c51bd8c81db78fab8d240fd698024">avrclass.c</a>
<li>class_overload_destroy()
: <a class="el" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1">avrclass.c</a>
<li>class_ref()
: <a class="el" href="avrclass_8c.html#ff0f5b14bf2740f208041d515f3ba93f">avrclass.c</a>
<li>class_unref()
: <a class="el" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693">avrclass.c</a>
</ul>
<h3><a class="anchor" name="index_d">- d -</a></h3><ul>
<li>decode_init_lookup_table()
: <a class="el" href="decoder_8c.html#e3a0b1d94b75719be5f23e9fb9b896dc">decoder.c</a>
<li>decode_opcode()
: <a class="el" href="decoder_8c.html#53bbe21cbd08336a39da9fbe4e9cb09e">decoder.c</a>
<li>dev_supp_list_devices()
: <a class="el" href="devsupp_8c.html#3fc3008c90677776ac1a67956e2d8701">devsupp.c</a>
<li>dev_supp_lookup_device()
: <a class="el" href="devsupp_8c.html#016b622b99dbb64383e7ad34a8f746f1">devsupp.c</a>
<li>display_clock()
: <a class="el" href="display_8c.html#e210ab2ee875db342dcd52d43fa47693">display.c</a>
<li>display_close()
: <a class="el" href="display_8c.html#428c3bdca61ba3679fbf3c7c8356c8f6">display.c</a>
<li>display_eeprom()
: <a class="el" href="display_8c.html#6a425136a8b941eba6671bbea330283b">display.c</a>
<li>display_flash()
: <a class="el" href="display_8c.html#69d6536d741f20da943fb64373bbae11">display.c</a>
<li>display_io_reg()
: <a class="el" href="display_8c.html#ed9707596c157777dc33fe1371ded7fc">display.c</a>
<li>display_io_reg_name()
: <a class="el" href="display_8c.html#e2e93695af3a8b1676402cebc82d1b3f">display.c</a>
<li>display_open()
: <a class="el" href="display_8c.html#aeea9e0008fcf18c0514a45e99a7f4d2">display.c</a>
<li>display_pc()
: <a class="el" href="display_8c.html#2a7b52120c3b22bf9045b473433a3590">display.c</a>
<li>display_reg()
: <a class="el" href="display_8c.html#225f48cf9ff069c974e3074754f6dbd1">display.c</a>
<li>display_send_msg()
: <a class="el" href="display_8c.html#f45795a80967d9faeea06240281f34e6">display.c</a>
<li>display_sram()
: <a class="el" href="display_8c.html#8cfda7ebd92c20bf3376e0355f80bebe">display.c</a>
<li>dlist_add()
: <a class="el" href="utils_8c.html#2f451be088e616a1c94508c1312e99ed">utils.c</a>
<li>dlist_add_head()
: <a class="el" href="utils_8c.html#46d7303de632a8f87f61f2bf555f1840">utils.c</a>
<li>dlist_delete()
: <a class="el" href="utils_8c.html#0be979713f40bde065ecf4c51b41fe0d">utils.c</a>
<li>dlist_delete_all()
: <a class="el" href="utils_8c.html#67215034f68b284935138064aa2f9cd0">utils.c</a>
<li>dlist_get_head_data()
: <a class="el" href="utils_8c.html#7c8dfedd93ef4bc0b91d4c1c45c86f0c">utils.c</a>
<li>dlist_iterator()
: <a class="el" href="utils_8c.html#bbba7ec7eefce4bdb4543e1096021186">utils.c</a>
<li>dlist_lookup()
: <a class="el" href="utils_8c.html#d8319271cd9c519c6e97f381739497a3">utils.c</a>
</ul>
<h3><a class="anchor" name="index_f">- f -</a></h3><ul>
<li>flash_construct()
: <a class="el" href="flash_8c.html#1289488dcdca6e7670ee607575c8d54d">flash.c</a>
<li>flash_destroy()
: <a class="el" href="flash_8c.html#671e5df04d7524f10ae472a04b3a0b4d">flash.c</a>
<li>flash_dump_core()
: <a class="el" href="flash_8c.html#1adccaaad97ed90fdf2aca154edbedb5">flash.c</a>
<li>flash_get_size()
: <a class="el" href="flash_8c.html#83456740d126c8a8790796597129ad9b">flash.c</a>
<li>flash_load_from_file()
: <a class="el" href="flash_8c.html#030c974ad076ab030e961f4860d7300a">flash.c</a>
<li>flash_new()
: <a class="el" href="flash_8c.html#2b69c1bd49cd27f2fe58baf4c453c92c">flash.c</a>
<li>flash_read()
: <a class="el" href="flash_8c.html#4fd6af69b0ff01070ff7598920761a2b">flash.c</a>
<li>flash_write()
: <a class="el" href="flash_8c.html#eccaffb7a1e3a2d8faf2ca923735548b">flash.c</a>
<li>flash_write_hi8()
: <a class="el" href="flash_8c.html#b5a09ffc2f0635cb5e28b5a5c9e1c3f9">flash.c</a>
<li>flash_write_lo8()
: <a class="el" href="flash_8c.html#dc8ba20623259c3f23360c952effa310">flash.c</a>
</ul>
<h3><a class="anchor" name="index_g">- g -</a></h3><ul>
<li>gdb_interact()
: <a class="el" href="gdbserver_8c.html#e6a15ee389d8d89a9f8408490f3d8606">gdbserver.c</a>
<li>get_program_time()
: <a class="el" href="utils_8c.html#d71e2db9144e1b1d539e1326cbdcbf04">utils.c</a>
</ul>
<h3><a class="anchor" name="index_h">- h -</a></h3><ul>
<li>hwstack_construct()
: <a class="el" href="stack_8c.html#d02c1ea58dfb09cff13e4ad524bb8797">stack.c</a>
<li>hwstack_destroy()
: <a class="el" href="stack_8c.html#837cbada76cb76af5aa46618d90ea00e">stack.c</a>
<li>hwstack_new()
: <a class="el" href="stack_8c.html#f9b8a6ec32f0798480f4bd02733996b1">stack.c</a>
</ul>
<h3><a class="anchor" name="index_m">- m -</a></h3><ul>
<li>mem_attach()
: <a class="el" href="memory_8c.html#9c93797cfe896dcfac4c139ad9f3df7b">memory.c</a>
<li>mem_construct()
: <a class="el" href="memory_8c.html#98917d50e483a8f307f80574d5a3b0d2">memory.c</a>
<li>mem_destroy()
: <a class="el" href="memory_8c.html#114285e9d962c71f77ba4abc57f37670">memory.c</a>
<li>mem_dump_core()
: <a class="el" href="memory_8c.html#4d727abdd19adeb472009cd9938886d4">memory.c</a>
<li>mem_get_vdevice_by_addr()
: <a class="el" href="memory_8c.html#c5dc450f9b9f874d58df945f1a27b9c4">memory.c</a>
<li>mem_get_vdevice_by_name()
: <a class="el" href="memory_8c.html#502735c9e7d8045149e53f5cff95ee6f">memory.c</a>
<li>mem_io_fetch()
: <a class="el" href="memory_8c.html#0a2cee082a6775c45b08324be6ded380">memory.c</a>
<li>mem_new()
: <a class="el" href="memory_8c.html#55873ce95bd961891e8a2338bb51fbd9">memory.c</a>
<li>mem_read()
: <a class="el" href="memory_8c.html#7ebc4d26966257412b56ef78dd33ad51">memory.c</a>
<li>mem_reset()
: <a class="el" href="memory_8c.html#fb9d511f1ce2e883195d07fd7900f635">memory.c</a>
<li>mem_write()
: <a class="el" href="memory_8c.html#218836433955d34b6eabfbc3d48aedda">memory.c</a>
<li>memstack_construct()
: <a class="el" href="stack_8c.html#46bd775c5dc8d6c19ec06b2c9da06a41">stack.c</a>
<li>memstack_destroy()
: <a class="el" href="stack_8c.html#64cea8305fc14f82896e499e8fabbe15">stack.c</a>
<li>memstack_new()
: <a class="el" href="stack_8c.html#7b2371560513634e9e008d0e3723e67e">stack.c</a>
</ul>
<h3><a class="anchor" name="index_o">- o -</a></h3><ul>
<li>ocreg16_construct()
: <a class="el" href="timers_8c.html#62c8b38185dbc7ced00aa878a2b96590">timers.c</a>
<li>ocreg16_create()
: <a class="el" href="timers_8c.html#c8de7810ae4a9b1eea06d0ecf50a7a4b">timers.c</a>
</ul>
<h3><a class="anchor" name="index_p">- p -</a></h3><ul>
<li>port_add_ext_rd_wr()
: <a class="el" href="ports_8c.html#4711762fbc2eb589ed9d4973df5d5a88">ports.c</a>
<li>port_create()
: <a class="el" href="ports_8c.html#00826229de675b5cd869c124267b7c3b">ports.c</a>
<li>port_ext_disable()
: <a class="el" href="ports_8c.html#ebb7d0728b81651d94a98d9640d9c328">ports.c</a>
<li>port_ext_enable()
: <a class="el" href="ports_8c.html#034de04c76c1ba1271c13edda67e83ba">ports.c</a>
</ul>
<h3><a class="anchor" name="index_s">- s -</a></h3><ul>
<li>set_bit_in_byte()
: <a class="el" href="utils_8c.html#eb8ce7ee7e6e35ee3ec8d3539bb52519">utils.c</a>
<li>set_bit_in_word()
: <a class="el" href="utils_8c.html#4250710ef21e0fe21d15dcc6203e4298">utils.c</a>
<li>signal_has_occurred()
: <a class="el" href="sig_8c.html#3aff57264b67d02a293d6e14a88b9c58">sig.c</a>
<li>signal_reset()
: <a class="el" href="sig_8c.html#fe45d9546c756459607ce4cbc98860e6">sig.c</a>
<li>signal_watch_start()
: <a class="el" href="sig_8c.html#1a3fd779478f70244e210af9437c3ac5">sig.c</a>
<li>signal_watch_stop()
: <a class="el" href="sig_8c.html#4ef4dc91eb8d929844ea031c9cd85ede">sig.c</a>
<li>sp_create()
: <a class="el" href="stack_8c.html#6df53075eb6ae9223f833080bfc28b94">stack.c</a>
<li>spi_construct()
: <a class="el" href="spi_8c.html#d490c5d5f4d7e69e5d423ab461d66df5">spi.c</a>
<li>spi_create()
: <a class="el" href="spi_8c.html#ef235e6fa60210d1f6c27d5884d0b23d">spi.c</a>
<li>spi_destroy()
: <a class="el" href="spi_8c.html#9ef936c44048c70e2bc6227e64d27216">spi.c</a>
<li>spi_intr_construct()
: <a class="el" href="spi_8c.html#2d31cddf4f3c10bdb40e5aa74c98b87c">spi.c</a>
<li>spi_intr_destroy()
: <a class="el" href="spi_8c.html#a7e63b808478f9afb300edaa7c6f1cd6">spi.c</a>
<li>spii_create()
: <a class="el" href="spi_8c.html#dce1c660a1d1605ba912d1c246ad38ae">spi.c</a>
<li>stack_construct()
: <a class="el" href="stack_8c.html#119a7d0b0be8ef37e798c8f9c6ae4722">stack.c</a>
<li>stack_destroy()
: <a class="el" href="stack_8c.html#c6c460b2f72e2a2095cd70b4414d4933">stack.c</a>
<li>stack_new()
: <a class="el" href="stack_8c.html#83de2962ed4166699cc8f40edcc1f380">stack.c</a>
<li>stack_pop()
: <a class="el" href="stack_8c.html#9077dfc6f98c4fe4b51b43db90055aaa">stack.c</a>
<li>stack_push()
: <a class="el" href="stack_8c.html#bd76f1a4f5bfc1e2b8699f3787cf7af2">stack.c</a>
<li>str2ffmt()
: <a class="el" href="utils_8c.html#5d306d06881ee5b68d679edec2e7fd75">utils.c</a>
</ul>
<h3><a class="anchor" name="index_t">- t -</a></h3><ul>
<li>timer0_construct()
: <a class="el" href="timers_8c.html#4aedd082ecfe36cc7c2a24e4bae44be3">timers.c</a>
<li>timer0_create()
: <a class="el" href="timers_8c.html#3bb4b9cbfa8d8ff090051f306d223bf2">timers.c</a>
<li>timer0_destroy()
: <a class="el" href="timers_8c.html#6d078109b034e0ca46d10df1caa6d7af">timers.c</a>
<li>timer16_construct()
: <a class="el" href="timers_8c.html#f614713078dc3bf66a7c765f409cf517">timers.c</a>
<li>timer16_create()
: <a class="el" href="timers_8c.html#fc0ff9b70476bf2134ee7ea55b6da86d">timers.c</a>
<li>timer_int_create()
: <a class="el" href="timers_8c.html#208259596835cc401b33bd60da45bf6a">timers.c</a>
<li>timer_intr_construct()
: <a class="el" href="timers_8c.html#b6a748a5044a9bad3e7d41bf93e80d41">timers.c</a>
<li>timer_intr_destroy()
: <a class="el" href="timers_8c.html#527da83fda0848baaceb0929eb61815e">timers.c</a>
</ul>
<h3><a class="anchor" name="index_u">- u -</a></h3><ul>
<li>uart_construct()
: <a class="el" href="uart_8c.html#bb93863003e66ea6b40400a4631656aa">uart.c</a>
<li>uart_create()
: <a class="el" href="uart_8c.html#15018100db23349def4e37027d5a8932">uart.c</a>
<li>uart_destroy()
: <a class="el" href="uart_8c.html#c80ec8e26d6b5ece2d7e4c57f371ac01">uart.c</a>
<li>uart_int_create()
: <a class="el" href="uart_8c.html#d7ab0fb5b4d3fbec10a1777c2627c2f0">uart.c</a>
<li>uart_intr_construct()
: <a class="el" href="uart_8c.html#673d5a70c22d5a19f244fe2a17fd6c1d">uart.c</a>
<li>uart_intr_destroy()
: <a class="el" href="uart_8c.html#cc2bbf6f2d72e20d553521a554ab551a">uart.c</a>
<li>usb_construct()
: <a class="el" href="usb_8c.html#b46dace89d6472ed1f0dc235d2b9e5c5">usb.c</a>
<li>usb_create()
: <a class="el" href="usb_8c.html#7b5bc9c47afcbe8cf57d75dd4ed47968">usb.c</a>
<li>usb_destroy()
: <a class="el" href="usb_8c.html#238a235b4fe1c88d56b67e65dc57274d">usb.c</a>
<li>usb_intr_construct()
: <a class="el" href="usb_8c.html#bc59e75f4f846b5075470bb8b7d00cf0">usb.c</a>
<li>usb_intr_destroy()
: <a class="el" href="usb_8c.html#c02f3bf581c2e053d30b3c0e004713f5">usb.c</a>
<li>usbi_create()
: <a class="el" href="usb_8c.html#254a13da6e1f9dcda78a1a01c3324cd8">usb.c</a>
</ul>
<h3><a class="anchor" name="index_v">- v -</a></h3><ul>
<li>vdev_add_addr()
: <a class="el" href="device_8c.html#5777a3eab86212d53f616d687babf6a9">device.c</a>
<li>vdev_construct()
: <a class="el" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4">device.c</a>
<li>vdev_def_AddAddr()
: <a class="el" href="device_8c.html#5cebfd18a219807f27e4a3f38da4a5d0">device.c</a>
<li>vdev_destroy()
: <a class="el" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9">device.c</a>
<li>vdev_get_core()
: <a class="el" href="device_8c.html#b59809dd04174aca0940efa2505a3524">device.c</a>
<li>vdev_new()
: <a class="el" href="device_8c.html#134ea79c2ecf6f000d28d08b05ed40ca">device.c</a>
<li>vdev_read()
: <a class="el" href="device_8c.html#2c32d0afc4607136c886acbf362874ed">device.c</a>
<li>vdev_reset()
: <a class="el" href="device_8c.html#1d98f1f4d77ce7d714ffde36ada57db7">device.c</a>
<li>vdev_set_core()
: <a class="el" href="device_8c.html#2a8db1cadfd3c26e9ea7ea0e6d03c132">device.c</a>
<li>vdev_write()
: <a class="el" href="device_8c.html#502a4216ffd7501ad3059e95d0f5572f">device.c</a>
</ul>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,49 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="files.html"><span>File&nbsp;List</span></a></li>
<li class="current"><a href="globals.html"><span>Globals</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="globals.html"><span>All</span></a></li>
<li><a href="globals_func.html"><span>Functions</span></a></li>
<li class="current"><a href="globals_vars.html"><span>Variables</span></a></li>
<li><a href="globals_enum.html"><span>Enumerations</span></a></li>
<li><a href="globals_eval.html"><span>Enumerator</span></a></li>
<li><a href="globals_defs.html"><span>Defines</span></a></li>
</ul>
</div>
</div>
<div class="contents">
&nbsp;
<p>
<ul>
<li>global_debug_inst_output
: <a class="el" href="avrcore_8c.html#7b9da9db79cd10ee75d5b363dd521c6e">avrcore.c</a>
</ul>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,11 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Simulavr</title></head>
<frameset cols="200,*">
<frame src="tree.html" name="treefrm">
<frame src="main.html" name="basefrm">
<noframes>
<a href="main.html">Frames are disabled. Click here to go to the main page.</a>
</noframes>
</frameset>
</html>

View file

@ -0,0 +1,32 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1><a class="anchor" name="insn_decoder">Instruction Decoder </a></h1><p>
Instruction decoding and processing is implemented in the <code>decode.c</code> file.<p>
The heart of the instruction decoder is the <a class="el" href="decoder_8c.html#53bbe21cbd08336a39da9fbe4e9cb09e" title="Decode an opcode into the opcode handler function.">decode_opcode()</a> function.<p>
The <a class="el" href="decoder_8c.html#53bbe21cbd08336a39da9fbe4e9cb09e" title="Decode an opcode into the opcode handler function.">decode_opcode()</a> function examines the given opcode to determine which instruction applies and returns a pointer to a function to handle performing the instruction's operation. If the given opcode does not map to an instruction handler, <code>NULL</code> is returned indicating an invalid instruction.<p>
Nearly every instruction in Atmel's Instruction Set Data Sheet will have a handler function defined. Each handler will perform all the operations described in the data sheet for a given instruction. A few instructions have synonyms. For example, <code>CBR</code> is a synonym for <code>ANDI</code>.<p>
This should all be fairly straight forward. </div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,28 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1><a class="anchor" name="interrupts">Interrupts </a></h1><p>
<b>FIXME:</b> empty place holder </div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,554 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>intvects.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: intvects.c,v 1.18 2008/01/06 21:34:16 joerg_wunsch Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003, 2004 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00030"></a>00030
<a name="l00031"></a>00031 <span class="preprocessor">#include "intvects.h"</span>
<a name="l00032"></a>00032
<a name="l00033"></a>00033 <span class="comment">/****************************************************************************\</span>
<a name="l00034"></a>00034 <span class="comment"> *</span>
<a name="l00035"></a>00035 <span class="comment"> * Interrupt Vector Tables:</span>
<a name="l00036"></a>00036 <span class="comment"> *</span>
<a name="l00037"></a>00037 <span class="comment"> * Since each device could have a different set of available interrupts, the</span>
<a name="l00038"></a>00038 <span class="comment"> * following tables map all interrupts to the addr to jump to when the</span>
<a name="l00039"></a>00039 <span class="comment"> * interrupt happens. If the device doesn't support an interrupt, the table</span>
<a name="l00040"></a>00040 <span class="comment"> * will contain a NULL entry. Only one table will be installed into the core</span>
<a name="l00041"></a>00041 <span class="comment"> * for a given device.</span>
<a name="l00042"></a>00042 <span class="comment"> *</span>
<a name="l00043"></a>00043 <span class="comment"> \****************************************************************************/</span>
<a name="l00044"></a>00044
<a name="l00045"></a>00045 <span class="comment">/* *INDENT-OFF* */</span>
<a name="l00046"></a>00046
<a name="l00047"></a>00047 <span class="comment">/*</span>
<a name="l00048"></a>00048 <span class="comment"> * Vector Table for devices:</span>
<a name="l00049"></a>00049 <span class="comment"> * at90s1200</span>
<a name="l00050"></a>00050 <span class="comment"> */</span>
<a name="l00051"></a>00051 <span class="keyword">static</span> IntVectTable vtab_at90s1200 = {
<a name="l00052"></a>00052 .RESET = { <span class="stringliteral">"IRQ_RESET"</span>,
<a name="l00053"></a>00053 0x00, 0x00, NO_BIT, NO_BIT },
<a name="l00054"></a>00054 .INT0 = { <span class="stringliteral">"IRQ_INT0"</span>,
<a name="l00055"></a>00055 0x01, 0x00, { 0x5b, 1&lt;&lt;6 }, NO_BIT },
<a name="l00056"></a>00056 .TIMER0_OVF = { <span class="stringliteral">"IRQ_TIMER0_OVF"</span>,
<a name="l00057"></a>00057 0x02, 0x00, { 0x59, 1&lt;&lt;1 }, { 0x58, 1&lt;&lt;1 } },
<a name="l00058"></a>00058 .ANA_COMP = { <span class="stringliteral">"IRQ_ANA_COMP"</span>,
<a name="l00059"></a>00059 0x03, 0x00, { 0x28, 1&lt;&lt;3 }, { 0x28, 1&lt;&lt;4 } }
<a name="l00060"></a>00060 };
<a name="l00061"></a>00061
<a name="l00062"></a>00062 <span class="comment">/*</span>
<a name="l00063"></a>00063 <span class="comment"> * Vector Table for devices:</span>
<a name="l00064"></a>00064 <span class="comment"> * at90s2313</span>
<a name="l00065"></a>00065 <span class="comment"> */</span>
<a name="l00066"></a>00066 <span class="keyword">static</span> IntVectTable vtab_at90s2313 = {
<a name="l00067"></a>00067 .RESET = { <span class="stringliteral">"IRQ_RESET"</span>,
<a name="l00068"></a>00068 0x00, 0x00, NO_BIT, NO_BIT },
<a name="l00069"></a>00069 .INT0 = { <span class="stringliteral">"IRQ_INT0"</span>,
<a name="l00070"></a>00070 0x01, 0x00, { 0x5b, 1&lt;&lt;6 }, { 0x5a, 1&lt;&lt;6 } },
<a name="l00071"></a>00071 .INT1 = { <span class="stringliteral">"IRQ_INT1"</span>,
<a name="l00072"></a>00072 0x02, 0x00, { 0x5b, 1&lt;&lt;7 }, { 0x5a, 1&lt;&lt;7 } },
<a name="l00073"></a>00073 .TIMER1_CAPT = { <span class="stringliteral">"IRQ_TIMER1_CAPT"</span>,
<a name="l00074"></a>00074 0x03, 0x00, { 0x59, 1&lt;&lt;3 }, { 0x58, 1&lt;&lt;3 } },
<a name="l00075"></a>00075 .TIMER1_COMPA = { <span class="stringliteral">"IRQ_TIMER1_COMPA"</span>,
<a name="l00076"></a>00076 0x04, 0x00, { 0x59, 1&lt;&lt;6 }, { 0x58, 1&lt;&lt;6 } },
<a name="l00077"></a>00077 .TIMER1_OVF = { <span class="stringliteral">"IRQ_TIMER1_OVF"</span>,
<a name="l00078"></a>00078 0x05, 0x00, { 0x59, 1&lt;&lt;7 }, { 0x58, 1&lt;&lt;7 } },
<a name="l00079"></a>00079 .TIMER0_OVF = { <span class="stringliteral">"IRQ_TIMER0_OVF"</span>,
<a name="l00080"></a>00080 0x06, 0x00, { 0x59, 1&lt;&lt;1 }, { 0x58, 1&lt;&lt;1 } },
<a name="l00081"></a>00081 .UART_RX = { <span class="stringliteral">"IRQ_UART_RX"</span>,
<a name="l00082"></a>00082 0x07, 0x00, { 0x2a, 1&lt;&lt;7 }, { 0x2b, 1&lt;&lt;7 } },
<a name="l00083"></a>00083 .UART_UDRE = { <span class="stringliteral">"IRQ_UART_UDRE"</span>,
<a name="l00084"></a>00084 0x08, 0x00, { 0x2a, 1&lt;&lt;5 }, { 0x2b, 1&lt;&lt;5 } },
<a name="l00085"></a>00085 .UART_TX = { <span class="stringliteral">"IRQ_UART_TX"</span>,
<a name="l00086"></a>00086 0x09, 0x00, { 0x2a, 1&lt;&lt;6 }, { 0x2b, 1&lt;&lt;6 } },
<a name="l00087"></a>00087 .ANA_COMP = { <span class="stringliteral">"IRQ_ANA_COMP"</span>,
<a name="l00088"></a>00088 0x0a, 0x00, { 0x28, 1&lt;&lt;3 }, { 0x28, 1&lt;&lt;4 } }
<a name="l00089"></a>00089 };
<a name="l00090"></a>00090
<a name="l00091"></a>00091 <span class="comment">/*</span>
<a name="l00092"></a>00092 <span class="comment"> * Vector Table for devices:</span>
<a name="l00093"></a>00093 <span class="comment"> * at90s4414, at90s8515</span>
<a name="l00094"></a>00094 <span class="comment"> */</span>
<a name="l00095"></a>00095 <span class="keyword">static</span> IntVectTable vtab_at90s4414 = {
<a name="l00096"></a>00096 .RESET = { <span class="stringliteral">"IRQ_RESET"</span>,
<a name="l00097"></a>00097 0x00, 0x00, NO_BIT, NO_BIT },
<a name="l00098"></a>00098 .INT0 = { <span class="stringliteral">"IRQ_INT0"</span>,
<a name="l00099"></a>00099 0x01, 0x00, { 0x5b, 1&lt;&lt;6 }, { 0x5a, 1&lt;&lt;6 } },
<a name="l00100"></a>00100 .INT1 = { <span class="stringliteral">"IRQ_INT1"</span>,
<a name="l00101"></a>00101 0x02, 0x00, { 0x5b, 1&lt;&lt;7 }, { 0x5a, 1&lt;&lt;7 } },
<a name="l00102"></a>00102 .TIMER1_CAPT = { <span class="stringliteral">"IRQ_TIMER1_CAPT"</span>,
<a name="l00103"></a>00103 0x03, 0x00, { 0x59, 1&lt;&lt;3 }, { 0x58, 1&lt;&lt;3 } },
<a name="l00104"></a>00104 .TIMER1_COMPA = { <span class="stringliteral">"IRQ_TIMER1_COMPA"</span>,
<a name="l00105"></a>00105 0x04, 0x00, { 0x59, 1&lt;&lt;6 }, { 0x58, 1&lt;&lt;6 } },
<a name="l00106"></a>00106 .TIMER1_COMPB = { <span class="stringliteral">"IRQ_TIMER1_COMPB"</span>,
<a name="l00107"></a>00107 0x05, 0x00, { 0x59, 1&lt;&lt;5 }, { 0x58, 1&lt;&lt;5 } },
<a name="l00108"></a>00108 .TIMER1_OVF = { <span class="stringliteral">"IRQ_TIMER1_OVF"</span>,
<a name="l00109"></a>00109 0x06, 0x00, { 0x59, 1&lt;&lt;7 }, { 0x58, 1&lt;&lt;7 } },
<a name="l00110"></a>00110 .TIMER0_OVF = { <span class="stringliteral">"IRQ_TIMER0_OVF"</span>,
<a name="l00111"></a>00111 0x07, 0x00, { 0x59, 1&lt;&lt;1 }, { 0x58, 1&lt;&lt;1 } },
<a name="l00112"></a>00112 .SPI_STC = { <span class="stringliteral">"IRQ_SPI_STC"</span>,
<a name="l00113"></a>00113 0x08, 0x00, { 0x2d, 1&lt;&lt;7 }, NO_BIT },
<a name="l00114"></a>00114 .UART_RX = { <span class="stringliteral">"IRQ_UART_RX"</span>,
<a name="l00115"></a>00115 0x09, 0x00, { 0x2a, 1&lt;&lt;7 }, { 0x2b, 1&lt;&lt;7 } },
<a name="l00116"></a>00116 .UART_UDRE = { <span class="stringliteral">"IRQ_UART_UDRE"</span>,
<a name="l00117"></a>00117 0x0a, 0x00, { 0x2a, 1&lt;&lt;5 }, { 0x2b, 1&lt;&lt;5 } },
<a name="l00118"></a>00118 .UART_TX = { <span class="stringliteral">"IRQ_UART_TX"</span>,
<a name="l00119"></a>00119 0x0b, 0x00, { 0x2a, 1&lt;&lt;6 }, { 0x2b, 1&lt;&lt;6 } },
<a name="l00120"></a>00120 .ANA_COMP = { <span class="stringliteral">"IRQ_ANA_COMP"</span>,
<a name="l00121"></a>00121 0x0c, 0x00, { 0x28, 1&lt;&lt;3 }, { 0x28, 1&lt;&lt;4 } }
<a name="l00122"></a>00122 };
<a name="l00123"></a>00123
<a name="l00124"></a>00124 <span class="comment">/*</span>
<a name="l00125"></a>00125 <span class="comment"> * Vector Table for devices:</span>
<a name="l00126"></a>00126 <span class="comment"> * atmega8</span>
<a name="l00127"></a>00127 <span class="comment"> */</span>
<a name="l00128"></a>00128
<a name="l00129"></a>00129 <span class="keyword">static</span> IntVectTable vtab_atmega8 = {
<a name="l00130"></a>00130 .RESET = { <span class="stringliteral">"IRQ_RESET"</span>,
<a name="l00131"></a>00131 0x00, 0x00, NO_BIT, NO_BIT },
<a name="l00132"></a>00132 .INT0 = { <span class="stringliteral">"IRQ_INT0"</span>,
<a name="l00133"></a>00133 0x01, 0x00, { 0x5b, 1&lt;&lt;6 }, { 0x5a, 1&lt;&lt;6 } },
<a name="l00134"></a>00134 .INT1 = { <span class="stringliteral">"IRQ_INT1"</span>,
<a name="l00135"></a>00135 0x02, 0x00, { 0x5b, 1&lt;&lt;7 }, { 0x5a, 1&lt;&lt;7 } },
<a name="l00136"></a>00136 .TIMER2_COMP = { <span class="stringliteral">"IRQ_TIMER2_COMP"</span>,
<a name="l00137"></a>00137 0x03, 0x00, { 0x59, 1&lt;&lt;7 }, { 0x58, 1&lt;&lt;7 } },
<a name="l00138"></a>00138 .TIMER2_OVF = { <span class="stringliteral">"IRQ_TIMER2_OVF"</span>,
<a name="l00139"></a>00139 0x04, 0x00, { 0x59, 1&lt;&lt;6 }, { 0x58, 1&lt;&lt;6 } },
<a name="l00140"></a>00140 .TIMER1_CAPT = { <span class="stringliteral">"IRQ_TIMER1_CAPT"</span>,
<a name="l00141"></a>00141 0x05, 0x00, { 0x59, 1&lt;&lt;5 }, { 0x58, 1&lt;&lt;5 } },
<a name="l00142"></a>00142 .TIMER1_COMPA = { <span class="stringliteral">"IRQ_TIMER1_COMPA"</span>,
<a name="l00143"></a>00143 0x06, 0x00, { 0x59, 1&lt;&lt;4 }, { 0x58, 1&lt;&lt;4 } },
<a name="l00144"></a>00144 .TIMER1_COMPB = { <span class="stringliteral">"IRQ_TIMER1_COMPB"</span>,
<a name="l00145"></a>00145 0x07, 0x00, { 0x59, 1&lt;&lt;3 }, { 0x58, 1&lt;&lt;3 } },
<a name="l00146"></a>00146 .TIMER1_OVF = { <span class="stringliteral">"IRQ_TIMER1_OVF"</span>,
<a name="l00147"></a>00147 0x08, 0x00, { 0x59, 1&lt;&lt;2 }, { 0x58, 1&lt;&lt;2 } },
<a name="l00148"></a>00148 .TIMER0_OVF = { <span class="stringliteral">"IRQ_TIMER0_OVF"</span>,
<a name="l00149"></a>00149 0x09, 0x00, { 0x59, 1&lt;&lt;0 }, { 0x58, 1&lt;&lt;0 } },
<a name="l00150"></a>00150 .SPI_STC = { <span class="stringliteral">"IRQ_SPI_STC"</span>,
<a name="l00151"></a>00151 0x0a, 0x00, { 0x2d, 1&lt;&lt;7 }, NO_BIT },
<a name="l00152"></a>00152 .UART_RX = { <span class="stringliteral">"IRQ_UART_RX"</span>,
<a name="l00153"></a>00153 0x0b, 0x00, { 0x2a, 1&lt;&lt;7 }, { 0x2b, 1&lt;&lt;7 } },
<a name="l00154"></a>00154 .UART_UDRE = { <span class="stringliteral">"IRQ_UART_UDRE"</span>,
<a name="l00155"></a>00155 0x0c, 0x00, { 0x2a, 1&lt;&lt;5 }, { 0x2b, 1&lt;&lt;5 } },
<a name="l00156"></a>00156 .UART_TX = { <span class="stringliteral">"IRQ_UART_TX"</span>,
<a name="l00157"></a>00157 0x0d, 0x00, { 0x2a, 1&lt;&lt;6 }, { 0x2b, 1&lt;&lt;6 } },
<a name="l00158"></a>00158 .ADC = { <span class="stringliteral">"IRQ_ADC"</span>,
<a name="l00159"></a>00159 0x0e, 0x00, { 0x26, 1&lt;&lt;3 }, { 0x26, 1&lt;&lt;4 } },
<a name="l00160"></a>00160 .EE_READY = { <span class="stringliteral">"IRQ_EE_READY"</span>,
<a name="l00161"></a>00161 0x0f, 0x00, { 0x3c, 1&lt;&lt;3 }, NO_BIT },
<a name="l00162"></a>00162 .ANA_COMP = { <span class="stringliteral">"IRQ_ANA_COMP"</span>,
<a name="l00163"></a>00163 0x10, 0x00, { 0x28, 1&lt;&lt;3 }, { 0x28, 1&lt;&lt;4 } },
<a name="l00164"></a>00164 .TWI = { <span class="stringliteral">"IRQ_TWI"</span>,
<a name="l00165"></a>00165 0x11, 0x00, { 0x56, 1&lt;&lt;0 }, { 0x56, 1&lt;&lt;7 } },
<a name="l00166"></a>00166 .SPM_READY = { <span class="stringliteral">"IRQ_SPM_READY"</span>,
<a name="l00167"></a>00167 0x12, 0x00, { 0x57, 1&lt;&lt;7 }, NO_BIT }
<a name="l00168"></a>00168 };
<a name="l00169"></a>00169
<a name="l00170"></a>00170
<a name="l00171"></a>00171
<a name="l00172"></a>00172 <span class="comment">/*</span>
<a name="l00173"></a>00173 <span class="comment"> * Vector Table for devices:</span>
<a name="l00174"></a>00174 <span class="comment"> * atmega16</span>
<a name="l00175"></a>00175 <span class="comment"> */</span>
<a name="l00176"></a>00176
<a name="l00177"></a>00177 <span class="keyword">static</span> IntVectTable vtab_atmega16 = {
<a name="l00178"></a>00178 .RESET = { <span class="stringliteral">"IRQ_RESET"</span>,
<a name="l00179"></a>00179 0x00, 0x00, NO_BIT, NO_BIT },
<a name="l00180"></a>00180 .INT0 = { <span class="stringliteral">"IRQ_INT0"</span>,
<a name="l00181"></a>00181 0x02, 0x00, { 0x5b, 1&lt;&lt;6 }, { 0x5a, 1&lt;&lt;6 } },
<a name="l00182"></a>00182 .INT1 = { <span class="stringliteral">"IRQ_INT1"</span>,
<a name="l00183"></a>00183 0x04, 0x00, { 0x5b, 1&lt;&lt;7 }, { 0x5a, 1&lt;&lt;7 } },
<a name="l00184"></a>00184 .TIMER2_COMP = { <span class="stringliteral">"IRQ_TIMER2_COMP"</span>,
<a name="l00185"></a>00185 0x06, 0x00, { 0x59, 1&lt;&lt;7 }, { 0x58, 1&lt;&lt;7 } },
<a name="l00186"></a>00186 .TIMER2_OVF = { <span class="stringliteral">"IRQ_TIMER2_OVF"</span>,
<a name="l00187"></a>00187 0x08, 0x00, { 0x59, 1&lt;&lt;6 }, { 0x58, 1&lt;&lt;6 } },
<a name="l00188"></a>00188 .TIMER1_CAPT = { <span class="stringliteral">"IRQ_TIMER1_CAPT"</span>,
<a name="l00189"></a>00189 0x0a, 0x00, { 0x59, 1&lt;&lt;5 }, { 0x58, 1&lt;&lt;5 } },
<a name="l00190"></a>00190 .TIMER1_COMPA = { <span class="stringliteral">"IRQ_TIMER1_COMPA"</span>,
<a name="l00191"></a>00191 0x0c, 0x00, { 0x59, 1&lt;&lt;4 }, { 0x58, 1&lt;&lt;4 } },
<a name="l00192"></a>00192 .TIMER1_COMPB = { <span class="stringliteral">"IRQ_TIMER1_COMPB"</span>,
<a name="l00193"></a>00193 0x0e, 0x00, { 0x59, 1&lt;&lt;3 }, { 0x58, 1&lt;&lt;3 } },
<a name="l00194"></a>00194 .TIMER1_OVF = { <span class="stringliteral">"IRQ_TIMER1_OVF"</span>,
<a name="l00195"></a>00195 0x10, 0x00, { 0x59, 1&lt;&lt;2 }, { 0x58, 1&lt;&lt;2 } },
<a name="l00196"></a>00196 .TIMER0_OVF = { <span class="stringliteral">"IRQ_TIMER0_OVF"</span>,
<a name="l00197"></a>00197 0x12, 0x00, { 0x59, 1&lt;&lt;0 }, { 0x58, 1&lt;&lt;0 } },
<a name="l00198"></a>00198 .SPI_STC = { <span class="stringliteral">"IRQ_SPI_STC"</span>,
<a name="l00199"></a>00199 0x14, 0x00, { 0x2d, 1&lt;&lt;7 }, NO_BIT },
<a name="l00200"></a>00200 .UART_RX = { <span class="stringliteral">"IRQ_UART_RX"</span>,
<a name="l00201"></a>00201 0x16, 0x00, { 0x2a, 1&lt;&lt;7 }, { 0x2b, 1&lt;&lt;7 } },
<a name="l00202"></a>00202 .UART_UDRE = { <span class="stringliteral">"IRQ_UART_UDRE"</span>,
<a name="l00203"></a>00203 0x18, 0x00, { 0x2a, 1&lt;&lt;5 }, { 0x2b, 1&lt;&lt;5 } },
<a name="l00204"></a>00204 .UART_TX = { <span class="stringliteral">"IRQ_UART_TX"</span>,
<a name="l00205"></a>00205 0x1a, 0x00, { 0x2a, 1&lt;&lt;6 }, { 0x2b, 1&lt;&lt;6 } },
<a name="l00206"></a>00206 .ADC = { <span class="stringliteral">"IRQ_ADC"</span>,
<a name="l00207"></a>00207 0x1c, 0x00, { 0x26, 1&lt;&lt;3 }, { 0x26, 1&lt;&lt;4 } },
<a name="l00208"></a>00208 .EE_READY = { <span class="stringliteral">"IRQ_EE_READY"</span>,
<a name="l00209"></a>00209 0x1e, 0x00, { 0x3c, 1&lt;&lt;3 }, NO_BIT },
<a name="l00210"></a>00210 .ANA_COMP = { <span class="stringliteral">"IRQ_ANA_COMP"</span>,
<a name="l00211"></a>00211 0x20, 0x00, { 0x28, 1&lt;&lt;3 }, { 0x28, 1&lt;&lt;4 } },
<a name="l00212"></a>00212 .TWI = { <span class="stringliteral">"IRQ_TWI"</span>,
<a name="l00213"></a>00213 0x22, 0x00, { 0x57, 1&lt;&lt;0 }, { 0x56, 1&lt;&lt;7 } },
<a name="l00214"></a>00214 .INT2 = { <span class="stringliteral">"IRQ_INT2"</span>,
<a name="l00215"></a>00215 0x24, 0x00, { 0x5b, 1&lt;&lt;5 }, { 0x5a, 1&lt;&lt;5 } },
<a name="l00216"></a>00216 .TIMER0_COMP = { <span class="stringliteral">"IRQ_TIMER0_COMP"</span>,
<a name="l00217"></a>00217 0x26, 0x00, { 0x59, 1&lt;&lt;1 }, { 0x58, 1&lt;&lt;1 } },
<a name="l00218"></a>00218 .SPM_READY = { <span class="stringliteral">"IRQ_SPM_READY"</span>,
<a name="l00219"></a>00219 0x28, 0x00, { 0x57, 1&lt;&lt;7 }, NO_BIT }
<a name="l00220"></a>00220 };
<a name="l00221"></a>00221
<a name="l00222"></a>00222 <span class="comment">/*</span>
<a name="l00223"></a>00223 <span class="comment"> * Vector Table for devices:</span>
<a name="l00224"></a>00224 <span class="comment"> * atmega32</span>
<a name="l00225"></a>00225 <span class="comment"> */</span>
<a name="l00226"></a>00226
<a name="l00227"></a>00227 <span class="keyword">static</span> IntVectTable vtab_atmega32 = {
<a name="l00228"></a>00228 .RESET = { <span class="stringliteral">"IRQ_RESET"</span>,
<a name="l00229"></a>00229 0x00, 0x00, NO_BIT, NO_BIT },
<a name="l00230"></a>00230 .INT0 = { <span class="stringliteral">"IRQ_INT0"</span>,
<a name="l00231"></a>00231 0x02, 0x00, { 0x5b, 1&lt;&lt;6 }, { 0x5a, 1&lt;&lt;6 } },
<a name="l00232"></a>00232 .INT1 = { <span class="stringliteral">"IRQ_INT1"</span>,
<a name="l00233"></a>00233 0x04, 0x00, { 0x5b, 1&lt;&lt;7 }, { 0x5a, 1&lt;&lt;7 } },
<a name="l00234"></a>00234 .TIMER2_COMP = { <span class="stringliteral">"IRQ_TIMER2_COMP"</span>,
<a name="l00235"></a>00235 0x06, 0x00, { 0x59, 1&lt;&lt;7 }, { 0x58, 1&lt;&lt;7 } },
<a name="l00236"></a>00236 .TIMER2_OVF = { <span class="stringliteral">"IRQ_TIMER2_OVF"</span>,
<a name="l00237"></a>00237 0x08, 0x00, { 0x59, 1&lt;&lt;6 }, { 0x58, 1&lt;&lt;6 } },
<a name="l00238"></a>00238 .TIMER1_CAPT = { <span class="stringliteral">"IRQ_TIMER1_CAPT"</span>,
<a name="l00239"></a>00239 0x0a, 0x00, { 0x59, 1&lt;&lt;5 }, { 0x58, 1&lt;&lt;5 } },
<a name="l00240"></a>00240 .TIMER1_COMPA = { <span class="stringliteral">"IRQ_TIMER1_COMPA"</span>,
<a name="l00241"></a>00241 0x0c, 0x00, { 0x59, 1&lt;&lt;4 }, { 0x58, 1&lt;&lt;4 } },
<a name="l00242"></a>00242 .TIMER1_COMPB = { <span class="stringliteral">"IRQ_TIMER1_COMPB"</span>,
<a name="l00243"></a>00243 0x0e, 0x00, { 0x59, 1&lt;&lt;3 }, { 0x58, 1&lt;&lt;3 } },
<a name="l00244"></a>00244 .TIMER1_OVF = { <span class="stringliteral">"IRQ_TIMER1_OVF"</span>,
<a name="l00245"></a>00245 0x10, 0x00, { 0x59, 1&lt;&lt;2 }, { 0x58, 1&lt;&lt;2 } },
<a name="l00246"></a>00246 .TIMER0_OVF = { <span class="stringliteral">"IRQ_TIMER0_OVF"</span>,
<a name="l00247"></a>00247 0x12, 0x00, { 0x59, 1&lt;&lt;0 }, { 0x58, 1&lt;&lt;0 } },
<a name="l00248"></a>00248 .SPI_STC = { <span class="stringliteral">"IRQ_SPI_STC"</span>,
<a name="l00249"></a>00249 0x14, 0x00, { 0x2d, 1&lt;&lt;7 }, NO_BIT },
<a name="l00250"></a>00250 .UART_RX = { <span class="stringliteral">"IRQ_UART_RX"</span>,
<a name="l00251"></a>00251 0x16, 0x00, { 0x2a, 1&lt;&lt;7 }, { 0x2b, 1&lt;&lt;7 } },
<a name="l00252"></a>00252 .UART_UDRE = { <span class="stringliteral">"IRQ_UART_UDRE"</span>,
<a name="l00253"></a>00253 0x18, 0x00, { 0x2a, 1&lt;&lt;5 }, { 0x2b, 1&lt;&lt;5 } },
<a name="l00254"></a>00254 .UART_TX = { <span class="stringliteral">"IRQ_UART_TX"</span>,
<a name="l00255"></a>00255 0x1a, 0x00, { 0x2a, 1&lt;&lt;6 }, { 0x2b, 1&lt;&lt;6 } },
<a name="l00256"></a>00256 .ADC = { <span class="stringliteral">"IRQ_ADC"</span>,
<a name="l00257"></a>00257 0x1c, 0x00, { 0x26, 1&lt;&lt;3 }, { 0x26, 1&lt;&lt;4 } },
<a name="l00258"></a>00258 .EE_READY = { <span class="stringliteral">"IRQ_EE_READY"</span>,
<a name="l00259"></a>00259 0x1e, 0x00, { 0x3c, 1&lt;&lt;3 }, NO_BIT },
<a name="l00260"></a>00260 .ANA_COMP = { <span class="stringliteral">"IRQ_ANA_COMP"</span>,
<a name="l00261"></a>00261 0x20, 0x00, { 0x28, 1&lt;&lt;3 }, { 0x28, 1&lt;&lt;4 } },
<a name="l00262"></a>00262 .TWI = { <span class="stringliteral">"IRQ_TWI"</span>,
<a name="l00263"></a>00263 0x22, 0x00, { 0x57, 1&lt;&lt;0 }, { 0x56, 1&lt;&lt;7 } },
<a name="l00264"></a>00264 .INT2 = { <span class="stringliteral">"IRQ_INT2"</span>,
<a name="l00265"></a>00265 0x24, 0x00, { 0x5b, 1&lt;&lt;5 }, { 0x5a, 1&lt;&lt;5 } },
<a name="l00266"></a>00266 .TIMER0_COMP = { <span class="stringliteral">"IRQ_TIMER0_COMP"</span>,
<a name="l00267"></a>00267 0x26, 0x00, { 0x59, 1&lt;&lt;1 }, { 0x58, 1&lt;&lt;1 } },
<a name="l00268"></a>00268 .SPM_READY = { <span class="stringliteral">"IRQ_SPM_READY"</span>,
<a name="l00269"></a>00269 0x28, 0x00, { 0x57, 1&lt;&lt;7 }, NO_BIT }
<a name="l00270"></a>00270 };
<a name="l00271"></a>00271
<a name="l00272"></a>00272
<a name="l00273"></a>00273 <span class="comment">/*</span>
<a name="l00274"></a>00274 <span class="comment"> * Vector Table for devices:</span>
<a name="l00275"></a>00275 <span class="comment"> * atmega103</span>
<a name="l00276"></a>00276 <span class="comment"> */</span>
<a name="l00277"></a>00277
<a name="l00278"></a>00278 <span class="keyword">static</span> IntVectTable vtab_atmega103 = {
<a name="l00279"></a>00279 .RESET = { <span class="stringliteral">"IRQ_RESET"</span>,
<a name="l00280"></a>00280 0x00, 0x00, NO_BIT, NO_BIT },
<a name="l00281"></a>00281 .INT0 = { <span class="stringliteral">"IRQ_INT0"</span>,
<a name="l00282"></a>00282 0x02, 0x00, { 0x59, 1&lt;&lt;0 }, NO_BIT },
<a name="l00283"></a>00283 .INT1 = { <span class="stringliteral">"IRQ_INT1"</span>,
<a name="l00284"></a>00284 0x04, 0x00, { 0x59, 1&lt;&lt;1 }, NO_BIT },
<a name="l00285"></a>00285 .INT2 = { <span class="stringliteral">"IRQ_INT2"</span>,
<a name="l00286"></a>00286 0x06, 0x00, { 0x59, 1&lt;&lt;2 }, NO_BIT },
<a name="l00287"></a>00287 .INT3 = { <span class="stringliteral">"IRQ_INT3"</span>,
<a name="l00288"></a>00288 0x08, 0x00, { 0x59, 1&lt;&lt;3 }, NO_BIT },
<a name="l00289"></a>00289 .INT4 = { <span class="stringliteral">"IRQ_INT4"</span>,
<a name="l00290"></a>00290 0x0a, 0x00, { 0x59, 1&lt;&lt;4 }, { 0x58, 1&lt;&lt;4 } },
<a name="l00291"></a>00291 .INT5 = { <span class="stringliteral">"IRQ_INT5"</span>,
<a name="l00292"></a>00292 0x0c, 0x00, { 0x59, 1&lt;&lt;5 }, { 0x58, 1&lt;&lt;5 } },
<a name="l00293"></a>00293 .INT6 = { <span class="stringliteral">"IRQ_INT6"</span>,
<a name="l00294"></a>00294 0x0e, 0x00, { 0x59, 1&lt;&lt;6 }, { 0x58, 1&lt;&lt;6 } },
<a name="l00295"></a>00295 .INT7 = { <span class="stringliteral">"IRQ_INT7"</span>,
<a name="l00296"></a>00296 0x10, 0x00, { 0x59, 1&lt;&lt;7 }, { 0x58, 1&lt;&lt;7 } },
<a name="l00297"></a>00297 .TIMER2_COMP = { <span class="stringliteral">"IRQ_TIMER2_COMP"</span>,
<a name="l00298"></a>00298 0x12, 0x00, { 0x57, 1&lt;&lt;7 }, { 0x56, 1&lt;&lt;7 } },
<a name="l00299"></a>00299 .TIMER2_OVF = { <span class="stringliteral">"IRQ_TIMER2_OVF"</span>,
<a name="l00300"></a>00300 0x14, 0x00, { 0x57, 1&lt;&lt;6 }, { 0x56, 1&lt;&lt;6 } },
<a name="l00301"></a>00301 .TIMER1_CAPT = { <span class="stringliteral">"IRQ_TIMER1_CAPT"</span>,
<a name="l00302"></a>00302 0x16, 0x00, { 0x57, 1&lt;&lt;5 }, { 0x56, 1&lt;&lt;5 } },
<a name="l00303"></a>00303 .TIMER1_COMPA = { <span class="stringliteral">"IRQ_TIMER1_COMPA"</span>,
<a name="l00304"></a>00304 0x18, 0x00, { 0x57, 1&lt;&lt;4 }, { 0x56, 1&lt;&lt;4 } },
<a name="l00305"></a>00305 .TIMER1_COMPB = { <span class="stringliteral">"IRQ_TIMER1_COMPB"</span>,
<a name="l00306"></a>00306 0x1a, 0x00, { 0x57, 1&lt;&lt;3 }, { 0x56, 1&lt;&lt;3 } },
<a name="l00307"></a>00307 .TIMER1_OVF = { <span class="stringliteral">"IRQ_TIMER1_OVF"</span>,
<a name="l00308"></a>00308 0x1c, 0x00, { 0x57, 1&lt;&lt;2 }, { 0x56, 1&lt;&lt;2 } },
<a name="l00309"></a>00309 .TIMER0_COMP = { <span class="stringliteral">"IRQ_TIMER0_COMP"</span>,
<a name="l00310"></a>00310 0x1e, 0x00, { 0x57, 1&lt;&lt;1 }, { 0x56, 1&lt;&lt;1 } },
<a name="l00311"></a>00311 .TIMER0_OVF = { <span class="stringliteral">"IRQ_TIMER0_OVF"</span>,
<a name="l00312"></a>00312 0x20, 0x00, { 0x57, 1&lt;&lt;0 }, { 0x56, 1&lt;&lt;0 } },
<a name="l00313"></a>00313 .SPI_STC = { <span class="stringliteral">"IRQ_SPI_STC"</span>,
<a name="l00314"></a>00314 0x22, 0x00, { 0x2d, 1&lt;&lt;7 }, NO_BIT },
<a name="l00315"></a>00315 .UART_RX = { <span class="stringliteral">"IRQ_UART_RX"</span>,
<a name="l00316"></a>00316 0x24, 0x00, { 0x2a, 1&lt;&lt;7 }, { 0x2b, 1&lt;&lt;7 } },
<a name="l00317"></a>00317 .UART_UDRE = { <span class="stringliteral">"IRQ_UART_UDRE"</span>,
<a name="l00318"></a>00318 0x26, 0x00, { 0x2a, 1&lt;&lt;5 }, { 0x2b, 1&lt;&lt;5 } },
<a name="l00319"></a>00319 .UART_TX = { <span class="stringliteral">"IRQ_UART_TX"</span>,
<a name="l00320"></a>00320 0x28, 0x00, { 0x2a, 1&lt;&lt;6 }, { 0x2b, 1&lt;&lt;6 } },
<a name="l00321"></a>00321 .ADC = { <span class="stringliteral">"IRQ_ADC"</span>,
<a name="l00322"></a>00322 0x2a, 0x00, { 0x26, 1&lt;&lt;3 }, { 0x26, 1&lt;&lt;4 } },
<a name="l00323"></a>00323 .ANA_COMP = { <span class="stringliteral">"IRQ_ANA_COMP"</span>,
<a name="l00324"></a>00324 0x2e, 0x00, { 0x28, 1&lt;&lt;3 }, { 0x28, 1&lt;&lt;4 } },
<a name="l00325"></a>00325 .EE_READY = { <span class="stringliteral">"IRQ_EE_READY"</span>,
<a name="l00326"></a>00326 0x2c, 0x00, { 0x3c, 1&lt;&lt;3 }, NO_BIT }
<a name="l00327"></a>00327 };
<a name="l00328"></a>00328
<a name="l00329"></a>00329 <span class="comment">/*</span>
<a name="l00330"></a>00330 <span class="comment"> * Vector Table for devices:</span>
<a name="l00331"></a>00331 <span class="comment"> * atmega128</span>
<a name="l00332"></a>00332 <span class="comment"> */</span>
<a name="l00333"></a>00333
<a name="l00334"></a>00334 <span class="comment">/* Note that the mega128 has BOOTRST and IVSEL fuses which can be used to</span>
<a name="l00335"></a>00335 <span class="comment"> change the interrupt vectors. If used, the new vectors are just the</span>
<a name="l00336"></a>00336 <span class="comment"> following plus some Boot Reset Address. This could be implemented just as</span>
<a name="l00337"></a>00337 <span class="comment"> we vector to handler. */</span>
<a name="l00338"></a>00338
<a name="l00339"></a>00339 <span class="comment">/* Note that the vectors address for mega128 are two insn's. This is needed</span>
<a name="l00340"></a>00340 <span class="comment"> since they can use jmp (32-bit) insn at the vector address. */</span>
<a name="l00341"></a>00341
<a name="l00342"></a>00342 <span class="keyword">static</span> IntVectTable vtab_atmega128 = {
<a name="l00343"></a>00343 .RESET = { <span class="stringliteral">"IRQ_RESET"</span>,
<a name="l00344"></a>00344 0x00, 0x00, NO_BIT, NO_BIT },
<a name="l00345"></a>00345 .INT0 = { <span class="stringliteral">"IRQ_INT0"</span>,
<a name="l00346"></a>00346 0x02, 0x00, { 0x59, 1&lt;&lt;7 }, { 0x58, 1&lt;&lt;7 } },
<a name="l00347"></a>00347 .INT1 = { <span class="stringliteral">"IRQ_INT1"</span>,
<a name="l00348"></a>00348 0x04, 0x00, { 0x59, 1&lt;&lt;6 }, { 0x58, 1&lt;&lt;6 } },
<a name="l00349"></a>00349 .INT2 = { <span class="stringliteral">"IRQ_INT2"</span>,
<a name="l00350"></a>00350 0x06, 0x00, { 0x59, 1&lt;&lt;5 }, { 0x58, 1&lt;&lt;5 } },
<a name="l00351"></a>00351 .INT3 = { <span class="stringliteral">"IRQ_INT3"</span>,
<a name="l00352"></a>00352 0x08, 0x00, { 0x59, 1&lt;&lt;4 }, { 0x58, 1&lt;&lt;4 } },
<a name="l00353"></a>00353 .INT4 = { <span class="stringliteral">"IRQ_INT4"</span>,
<a name="l00354"></a>00354 0x0a, 0x00, { 0x59, 1&lt;&lt;3 }, { 0x58, 1&lt;&lt;3 } },
<a name="l00355"></a>00355 .INT5 = { <span class="stringliteral">"IRQ_INT5"</span>,
<a name="l00356"></a>00356 0x0c, 0x00, { 0x59, 1&lt;&lt;2 }, { 0x58, 1&lt;&lt;2 } },
<a name="l00357"></a>00357 .INT6 = { <span class="stringliteral">"IRQ_INT6"</span>,
<a name="l00358"></a>00358 0x0e, 0x00, { 0x59, 1&lt;&lt;1 }, { 0x58, 1&lt;&lt;1 } },
<a name="l00359"></a>00359 .INT7 = { <span class="stringliteral">"IRQ_INT7"</span>,
<a name="l00360"></a>00360 0x10, 0x00, { 0x59, 1&lt;&lt;0 }, { 0x58, 1&lt;&lt;0 } },
<a name="l00361"></a>00361 .TIMER2_COMP = { <span class="stringliteral">"IRQ_TIMER2_COMP"</span>,
<a name="l00362"></a>00362 0x12, 0x00, { 0x57, 1&lt;&lt;7 }, { 0x56, 1&lt;&lt;7 } },
<a name="l00363"></a>00363 .TIMER2_OVF = { <span class="stringliteral">"IRQ_TIMER2_OVF"</span>,
<a name="l00364"></a>00364 0x14, 0x00, { 0x57, 1&lt;&lt;6 }, { 0x56, 1&lt;&lt;6 } },
<a name="l00365"></a>00365 .TIMER1_CAPT = { <span class="stringliteral">"IRQ_TIMER1_CAPT"</span>,
<a name="l00366"></a>00366 0x16, 0x00, { 0x57, 1&lt;&lt;5 }, { 0x56, 1&lt;&lt;5 } },
<a name="l00367"></a>00367 .TIMER1_COMPA = { <span class="stringliteral">"IRQ_TIMER1_COMPA"</span>,
<a name="l00368"></a>00368 0x18, 0x00, { 0x57, 1&lt;&lt;4 }, { 0x56, 1&lt;&lt;4 } },
<a name="l00369"></a>00369 .TIMER1_COMPB = { <span class="stringliteral">"IRQ_TIMER1_COMPB"</span>,
<a name="l00370"></a>00370 0x1a, 0x00, { 0x57, 1&lt;&lt;3 }, { 0x56, 1&lt;&lt;3 } },
<a name="l00371"></a>00371 .TIMER1_OVF = { <span class="stringliteral">"IRQ_TIMER1_OVF"</span>,
<a name="l00372"></a>00372 0x1c, 0x00, { 0x57, 1&lt;&lt;2 }, { 0x56, 1&lt;&lt;2 } },
<a name="l00373"></a>00373 .TIMER0_COMP = { <span class="stringliteral">"IRQ_TIMER0_COMP"</span>,
<a name="l00374"></a>00374 0x1e, 0x00, { 0x57, 1&lt;&lt;1 }, { 0x56, 1&lt;&lt;1 } },
<a name="l00375"></a>00375 .TIMER0_OVF = { <span class="stringliteral">"IRQ_TIMER0_OVF"</span>,
<a name="l00376"></a>00376 0x20, 0x00, { 0x57, 1&lt;&lt;0 }, { 0x56, 1&lt;&lt;0 } },
<a name="l00377"></a>00377 .SPI_STC = { <span class="stringliteral">"IRQ_SPI_STC"</span>,
<a name="l00378"></a>00378 0x22, 0x00, { 0x2d, 1&lt;&lt;7 }, NO_BIT },
<a name="l00379"></a>00379 .USART0_RX = { <span class="stringliteral">"IRQ_USART0_RX"</span>,
<a name="l00380"></a>00380 0x24, 0x00, { 0x2a, 1&lt;&lt;7 }, { 0x2b, 1&lt;&lt;7 } },
<a name="l00381"></a>00381 .USART0_UDRE = { <span class="stringliteral">"IRQ_USART0_UDRE"</span>,
<a name="l00382"></a>00382 0x26, 0x00, { 0x2a, 1&lt;&lt;5 }, { 0x2b, 1&lt;&lt;5 } },
<a name="l00383"></a>00383 .USART0_TX = { <span class="stringliteral">"IRQ_USART0_TX"</span>,
<a name="l00384"></a>00384 0x28, 0x00, { 0x2a, 1&lt;&lt;6 }, { 0x2b, 1&lt;&lt;6 } },
<a name="l00385"></a>00385 .ADC = { <span class="stringliteral">"IRQ_ADC"</span>,
<a name="l00386"></a>00386 0x2a, 0x00, { 0x26, 1&lt;&lt;3 }, { 0x26, 1&lt;&lt;4 } },
<a name="l00387"></a>00387 .EE_READY = { <span class="stringliteral">"IRQ_EE_READY"</span>,
<a name="l00388"></a>00388 0x2c, 0x00, { 0x3c, 1&lt;&lt;3 }, NO_BIT },
<a name="l00389"></a>00389 .ANA_COMP = { <span class="stringliteral">"IRQ_ANA_COMP"</span>,
<a name="l00390"></a>00390 0x2e, 0x00, { 0x28, 1&lt;&lt;3 }, { 0x28, 1&lt;&lt;4 } },
<a name="l00391"></a>00391 .TIMER1_COMPC = { <span class="stringliteral">"IRQ_TIMER1_COMPC"</span>,
<a name="l00392"></a>00392 0x30, 0x00, { 0x7d, 1&lt;&lt;0 }, { 0x7c, 1&lt;&lt;0 } },
<a name="l00393"></a>00393 .TIMER3_CAPT = { <span class="stringliteral">"IRQ_TIMER3_CAPT"</span>,
<a name="l00394"></a>00394 0x32, 0x00, { 0x7d, 1&lt;&lt;5 }, { 0x7c, 1&lt;&lt;5 } },
<a name="l00395"></a>00395 .TIMER3_COMPA = { <span class="stringliteral">"IRQ_TIMER3_COMPA"</span>,
<a name="l00396"></a>00396 0x34, 0x00, { 0x7d, 1&lt;&lt;4 }, { 0x7c, 1&lt;&lt;4 } },
<a name="l00397"></a>00397 .TIMER3_COMPB = { <span class="stringliteral">"IRQ_TIMER3_COMPB"</span>,
<a name="l00398"></a>00398 0x36, 0x00, { 0x7d, 1&lt;&lt;3 }, { 0x7c, 1&lt;&lt;3 } },
<a name="l00399"></a>00399 .TIMER3_COMPC = { <span class="stringliteral">"IRQ_TIMER3_COMPC"</span>,
<a name="l00400"></a>00400 0x38, 0x00, { 0x7d, 1&lt;&lt;1 }, { 0x7c, 1&lt;&lt;1 } },
<a name="l00401"></a>00401 .TIMER3_OVF = { <span class="stringliteral">"IRQ_TIMER3_OVF"</span>,
<a name="l00402"></a>00402 0x3a, 0x00, { 0x7d, 1&lt;&lt;2 }, { 0x7c, 1&lt;&lt;2 } },
<a name="l00403"></a>00403 .USART1_RX = { <span class="stringliteral">"IRQ_USART1_RX"</span>,
<a name="l00404"></a>00404 0x3c, 0x00, { 0x9a, 1&lt;&lt;7 }, { 0x9b, 1&lt;&lt;7 } },
<a name="l00405"></a>00405 .USART1_UDRE = { <span class="stringliteral">"IRQ_USART1_UDRE"</span>,
<a name="l00406"></a>00406 0x3e, 0x00, { 0x9a, 1&lt;&lt;5 }, { 0x9b, 1&lt;&lt;5 } },
<a name="l00407"></a>00407 .USART1_TX = { <span class="stringliteral">"IRQ_USART1_TX"</span>,
<a name="l00408"></a>00408 0x40, 0x00, { 0x9a, 1&lt;&lt;6 }, { 0x9b, 1&lt;&lt;6 } },
<a name="l00409"></a>00409 .TWI = { <span class="stringliteral">"IRQ_TWI"</span>,
<a name="l00410"></a>00410 0x42, 0x00, { 0x74, 1&lt;&lt;0 }, { 0x74, 1&lt;&lt;7 } },
<a name="l00411"></a>00411 .SPM_READY = { <span class="stringliteral">"IRQ_SPM_READY"</span>,
<a name="l00412"></a>00412 0x44, 0x00, { 0x68, 1&lt;&lt;7 }, NO_BIT }
<a name="l00413"></a>00413 };
<a name="l00414"></a>00414
<a name="l00415"></a>00415 <span class="comment">/* supports 355, 353, 351</span>
<a name="l00416"></a>00416 <span class="comment"> NOTE: The vector addresses are not sequential. */</span>
<a name="l00417"></a>00417 <span class="keyword">static</span> IntVectTable vtab_at43usb355 = {
<a name="l00418"></a>00418 .RESET = { <span class="stringliteral">"IRQ_RESET"</span>,
<a name="l00419"></a>00419 0x00, 0x00, NO_BIT, NO_BIT },
<a name="l00420"></a>00420 .INT0 = { <span class="stringliteral">"IRQ_INT0"</span>,
<a name="l00421"></a>00421 0x02, 0x00, { 0x5b, 1&lt;&lt;6 }, { 0x5a, 1&lt;&lt;6 } },
<a name="l00422"></a>00422 .INT1 = { <span class="stringliteral">"IRQ_INT1"</span>,
<a name="l00423"></a>00423 0x04, 0x00, { 0x5b, 1&lt;&lt;7 }, { 0x5a, 1&lt;&lt;7 } },
<a name="l00424"></a>00424 .TIMER1_CAPT = { <span class="stringliteral">"IRQ_TIMER1_CAPT"</span>,
<a name="l00425"></a>00425 0x06, 0x00, { 0x59, 1&lt;&lt;3 }, { 0x58, 1&lt;&lt;3 } },
<a name="l00426"></a>00426 .TIMER1_COMPA = { <span class="stringliteral">"IRQ_TIMER1_COMPA"</span>,
<a name="l00427"></a>00427 0x08, 0x00, { 0x59, 1&lt;&lt;6 }, { 0x58, 1&lt;&lt;6 } },
<a name="l00428"></a>00428 .TIMER1_COMPB = { <span class="stringliteral">"IRQ_TIMER1_COMPB"</span>,
<a name="l00429"></a>00429 0x0a, 0x00, { 0x59, 1&lt;&lt;5 }, { 0x58, 1&lt;&lt;5 } },
<a name="l00430"></a>00430 .TIMER1_OVF = { <span class="stringliteral">"IRQ_TIMER1_OVF"</span>,
<a name="l00431"></a>00431 0x0c, 0x00, { 0x59, 1&lt;&lt;7 }, { 0x58, 1&lt;&lt;7 } },
<a name="l00432"></a>00432 .TIMER0_OVF = { <span class="stringliteral">"IRQ_TIMER0_OVF"</span>,
<a name="l00433"></a>00433 0x0e, 0x00, { 0x59, 1&lt;&lt;1 }, { 0x58, 1&lt;&lt;1 } },
<a name="l00434"></a>00434 .SPI_STC = { <span class="stringliteral">"IRQ_SPI_STC"</span>,
<a name="l00435"></a>00435 0x10, 0x00, { 0x2d, 1&lt;&lt;7 }, NO_BIT },
<a name="l00436"></a>00436 .ADC = { <span class="stringliteral">"IRQ_ADC"</span>,
<a name="l00437"></a>00437 0x16, 0x00, { 0x27, 1&lt;&lt;3 }, { 0x27, 1&lt;&lt;4 } },
<a name="l00438"></a>00438 .USB_HW = { <span class="stringliteral">"IRQ_USB_HW"</span>,
<a name="l00439"></a>00439 0x18, 0x00, NO_BIT, NO_BIT } <span class="comment">/* TODO */</span>
<a name="l00440"></a>00440 };
<a name="l00441"></a>00441
<a name="l00442"></a>00442 <span class="comment">/* supports 320 */</span>
<a name="l00443"></a>00443 <span class="keyword">static</span> IntVectTable vtab_at43usb320 = {
<a name="l00444"></a>00444 .RESET = { <span class="stringliteral">"IRQ_RESET"</span>,
<a name="l00445"></a>00445 0x00, 0x00, NO_BIT, NO_BIT },
<a name="l00446"></a>00446 .INT0 = { <span class="stringliteral">"IRQ_INT0"</span>,
<a name="l00447"></a>00447 0x02, 0x00, { 0x5b, 1&lt;&lt;6 }, { 0x5a, 1&lt;&lt;6 } },
<a name="l00448"></a>00448 .INT1 = { <span class="stringliteral">"IRQ_INT1"</span>,
<a name="l00449"></a>00449 0x04, 0x00, { 0x5b, 1&lt;&lt;7 }, { 0x5a, 1&lt;&lt;7 } },
<a name="l00450"></a>00450 .TIMER1_CAPT = { <span class="stringliteral">"IRQ_TIMER1_CAPT"</span>,
<a name="l00451"></a>00451 0x06, 0x00, { 0x59, 1&lt;&lt;3 }, { 0x58, 1&lt;&lt;3 } },
<a name="l00452"></a>00452 .TIMER1_COMPA = { <span class="stringliteral">"IRQ_TIMER1_COMPA"</span>,
<a name="l00453"></a>00453 0x08, 0x00, { 0x59, 1&lt;&lt;6 }, { 0x58, 1&lt;&lt;6 } },
<a name="l00454"></a>00454 .TIMER1_COMPB = { <span class="stringliteral">"IRQ_TIMER1_COMPB"</span>,
<a name="l00455"></a>00455 0x0a, 0x00, { 0x59, 1&lt;&lt;5 }, { 0x58, 1&lt;&lt;5 } },
<a name="l00456"></a>00456 .TIMER1_OVF = { <span class="stringliteral">"IRQ_TIMER1_OVF"</span>,
<a name="l00457"></a>00457 0x0c, 0x00, { 0x59, 1&lt;&lt;7 }, { 0x58, 1&lt;&lt;7 } },
<a name="l00458"></a>00458 .TIMER0_OVF = { <span class="stringliteral">"IRQ_TIMER0_OVF"</span>,
<a name="l00459"></a>00459 0x0e, 0x00, { 0x59, 1&lt;&lt;1 }, { 0x58, 1&lt;&lt;1 } },
<a name="l00460"></a>00460 .SPI_STC = { <span class="stringliteral">"IRQ_SPI_STC"</span>,
<a name="l00461"></a>00461 0x10, 0x00, { 0x2d, 1&lt;&lt;7 }, NO_BIT },
<a name="l00462"></a>00462 .UART_RX = { <span class="stringliteral">"IRQ_UART_RX"</span>,
<a name="l00463"></a>00463 0x12, 0x00, { 0x2a, 1&lt;&lt;7 }, { 0x2b, 1&lt;&lt;7 } },
<a name="l00464"></a>00464 .UART_UDRE = { <span class="stringliteral">"IRQ_UART_UDRE"</span>,
<a name="l00465"></a>00465 0x14, 0x00, { 0x2a, 1&lt;&lt;5 }, { 0x2b, 1&lt;&lt;5 } },
<a name="l00466"></a>00466 .UART_TX = { <span class="stringliteral">"IRQ_UART_TX"</span>,
<a name="l00467"></a>00467 0x16, 0x00, { 0x2a, 1&lt;&lt;6 }, { 0x2b, 1&lt;&lt;6 } },
<a name="l00468"></a>00468 .USB_HW = { <span class="stringliteral">"IRQ_USB"</span>,
<a name="l00469"></a>00469 0x18, 0x00, NO_BIT, NO_BIT } <span class="comment">/* TODO */</span>
<a name="l00470"></a>00470 };
<a name="l00471"></a>00471
<a name="l00472"></a>00472 <span class="comment">/* supports 325</span>
<a name="l00473"></a>00473 <span class="comment"> NOTE: The vector addresses are not sequential. */</span>
<a name="l00474"></a>00474 <span class="keyword">static</span> IntVectTable vtab_at43usb325 = {
<a name="l00475"></a>00475 .RESET = { <span class="stringliteral">"IRQ_RESET"</span>,
<a name="l00476"></a>00476 0x00, 0x00, NO_BIT, NO_BIT },
<a name="l00477"></a>00477 .INT0 = { <span class="stringliteral">"IRQ_INT0"</span>,
<a name="l00478"></a>00478 0x02, 0x00, { 0x5b, 1&lt;&lt;6 }, { 0x5a, 1&lt;&lt;6 } },
<a name="l00479"></a>00479 .INT1 = { <span class="stringliteral">"IRQ_INT1"</span>,
<a name="l00480"></a>00480 0x04, 0x00, { 0x5b, 1&lt;&lt;7 }, { 0x5a, 1&lt;&lt;7 } },
<a name="l00481"></a>00481 .TIMER1_CAPT = { <span class="stringliteral">"IRQ_TIMER1_CAPT"</span>,
<a name="l00482"></a>00482 0x06, 0x00, { 0x59, 1&lt;&lt;3 }, { 0x58, 1&lt;&lt;3 } },
<a name="l00483"></a>00483 .TIMER1_COMPA = { <span class="stringliteral">"IRQ_TIMER1_COMPA"</span>,
<a name="l00484"></a>00484 0x08, 0x00, { 0x59, 1&lt;&lt;6 }, { 0x58, 1&lt;&lt;6 } },
<a name="l00485"></a>00485 .TIMER1_COMPB = { <span class="stringliteral">"IRQ_TIMER1_COMPB"</span>,
<a name="l00486"></a>00486 0x0a, 0x00, { 0x59, 1&lt;&lt;5 }, { 0x58, 1&lt;&lt;5 } },
<a name="l00487"></a>00487 .TIMER1_OVF = { <span class="stringliteral">"IRQ_TIMER1_OVF"</span>,
<a name="l00488"></a>00488 0x0c, 0x00, { 0x59, 1&lt;&lt;7 }, { 0x58, 1&lt;&lt;7 } },
<a name="l00489"></a>00489 .TIMER0_OVF = { <span class="stringliteral">"IRQ_TIMER0_OVF"</span>,
<a name="l00490"></a>00490 0x0e, 0x00, { 0x59, 1&lt;&lt;1 }, { 0x58, 1&lt;&lt;1 } },
<a name="l00491"></a>00491 .USB_HW = { <span class="stringliteral">"IRQ_USB_HW"</span>,
<a name="l00492"></a>00492 0x18, 0x00, NO_BIT, NO_BIT } <span class="comment">/* TODO */</span>
<a name="l00493"></a>00493 };
<a name="l00494"></a>00494
<a name="l00495"></a>00495 <span class="comment">/* supports 326</span>
<a name="l00496"></a>00496 <span class="comment"> NOTE: The vector addresses are not sequential. */</span>
<a name="l00497"></a>00497 <span class="keyword">static</span> IntVectTable vtab_at43usb326 = {
<a name="l00498"></a>00498 .RESET = { <span class="stringliteral">"IRQ_RESET"</span>,
<a name="l00499"></a>00499 0x00, 0x00, NO_BIT, NO_BIT },
<a name="l00500"></a>00500 .INT0 = { <span class="stringliteral">"IRQ_INT0"</span>,
<a name="l00501"></a>00501 0x02, 0x00, { 0x5b, 1&lt;&lt;6 }, { 0x5a, 1&lt;&lt;6 } },
<a name="l00502"></a>00502 .TIMER0_OVF = { <span class="stringliteral">"IRQ_TIMER0_OVF"</span>,
<a name="l00503"></a>00503 0x0e, 0x00, { 0x59, 1&lt;&lt;1 }, { 0x58, 1&lt;&lt;1 } },
<a name="l00504"></a>00504 .USB_HW = { <span class="stringliteral">"IRQ_USB_HW"</span>,
<a name="l00505"></a>00505 0x18, 0x00, NO_BIT, NO_BIT } <span class="comment">/* TODO */</span>
<a name="l00506"></a>00506 };
<a name="l00507"></a>00507
<a name="l00508"></a>00508 <span class="comment">/* *INDENT-ON* */</span>
<a name="l00509"></a>00509
<a name="l00510"></a>00510 <span class="comment">/*</span>
<a name="l00511"></a>00511 <span class="comment"> * Vector Table Lookup List.</span>
<a name="l00512"></a>00512 <span class="comment"> *</span>
<a name="l00513"></a>00513 <span class="comment"> * Maps a _vector_table_name to a device vector table.</span>
<a name="l00514"></a>00514 <span class="comment"> */</span>
<a name="l00515"></a>00515 IntVectTable *global_vtable_list[] = {
<a name="l00516"></a>00516 &amp;vtab_at90s1200,
<a name="l00517"></a>00517 &amp;vtab_at90s2313,
<a name="l00518"></a>00518 &amp;vtab_at90s4414,
<a name="l00519"></a>00519 &amp;vtab_atmega8,
<a name="l00520"></a>00520 &amp;vtab_atmega16,
<a name="l00521"></a>00521 &amp;vtab_atmega32,
<a name="l00522"></a>00522 &amp;vtab_atmega103,
<a name="l00523"></a>00523 &amp;vtab_atmega128,
<a name="l00524"></a>00524 &amp;vtab_at43usb355,
<a name="l00525"></a>00525 &amp;vtab_at43usb320,
<a name="l00526"></a>00526 &amp;vtab_at43usb325,
<a name="l00527"></a>00527 &amp;vtab_at43usb326,
<a name="l00528"></a>00528 NULL
<a name="l00529"></a>00529 };
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li class="current"><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>Simulavr Internals</h1>
<p>
<h3 align="center">0.1.2.5 </h3><h2><a class="anchor" name="intro">
Introduction</a></h2>
<p>
This chapter documents the internals of simulavr for those wishing to work with the source code to fix bugs, add features, or to just see how it all works. If you only wish to know how to use simulavr, you don't need to read this.<p>
Internals Topics:<p>
<ul>
<li><a class="el" href="memory_management.html">Memory Management </a></li><li><a class="el" href="object_system.html">Objects </a></li><li><a class="el" href="insn_decoder.html">Instruction Decoder </a></li><li><a class="el" href="interrupts.html">Interrupts </a></li><li><a class="el" href="virtual_devs.html">Virtual Devices </a></li><li><a class="el" href="ext_devs.html">External Devices </a></li><li><a class="el" href="break_watch_pts.html">Breakpoints and Watchpoints </a> </li></ul>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,504 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>main.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: main.c,v 1.40 2004/04/17 00:03:51 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003, 2004 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;errno.h&gt;</span>
<a name="l00032"></a>00032
<a name="l00033"></a>00033 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include "utils.h"</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include "callback.h"</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include "op_names.h"</span>
<a name="l00039"></a>00039
<a name="l00040"></a>00040 <span class="preprocessor">#include "storage.h"</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include "flash.h"</span>
<a name="l00042"></a>00042
<a name="l00043"></a>00043 <span class="preprocessor">#include "vdevs.h"</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include "memory.h"</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include "stack.h"</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include "register.h"</span>
<a name="l00047"></a>00047 <span class="preprocessor">#include "sram.h"</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include "eeprom.h"</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include "timers.h"</span>
<a name="l00050"></a>00050 <span class="preprocessor">#include "ports.h"</span>
<a name="l00051"></a>00051
<a name="l00052"></a>00052 <span class="preprocessor">#include "avrcore.h"</span>
<a name="l00053"></a>00053
<a name="l00054"></a>00054 <span class="preprocessor">#include "devsupp.h"</span>
<a name="l00055"></a>00055 <span class="preprocessor">#include "display.h"</span>
<a name="l00056"></a>00056
<a name="l00057"></a>00057 <span class="preprocessor">#include "gdb.h"</span>
<a name="l00058"></a>00058 <span class="preprocessor">#include "gnu_getopt.h"</span>
<a name="l00059"></a>00059
<a name="l00060"></a>00060 <span class="comment">/****************************************************************************\</span>
<a name="l00061"></a>00061 <span class="comment"> *</span>
<a name="l00062"></a>00062 <span class="comment"> * global variables (keep them to a minimum)</span>
<a name="l00063"></a>00063 <span class="comment"> *</span>
<a name="l00064"></a>00064 <span class="comment">\****************************************************************************/</span>
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="keyword">static</span> <span class="keywordtype">char</span> *global_device_type = NULL;
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="keyword">static</span> <span class="keywordtype">int</span> global_eeprom_image_type = FFMT_BIN;
<a name="l00069"></a>00069 <span class="keyword">static</span> <span class="keywordtype">char</span> *global_eeprom_image_file = NULL;
<a name="l00070"></a>00070
<a name="l00071"></a>00071 <span class="keyword">static</span> <span class="keywordtype">int</span> global_flash_image_type = FFMT_BIN;
<a name="l00072"></a>00072 <span class="keyword">static</span> <span class="keywordtype">char</span> *global_flash_image_file = NULL;
<a name="l00073"></a>00073
<a name="l00074"></a>00074 <span class="keyword">static</span> <span class="keywordtype">int</span> global_gdbserver_mode = 0;
<a name="l00075"></a>00075 <span class="keyword">static</span> <span class="keywordtype">int</span> global_gdbserver_port = 1212; <span class="comment">/* default port number */</span>
<a name="l00076"></a>00076 <span class="keyword">static</span> <span class="keywordtype">int</span> global_gdb_debug = 0;
<a name="l00077"></a>00077
<a name="l00078"></a>00078 <span class="keyword">static</span> <span class="keywordtype">char</span> *global_disp_prog = NULL;
<a name="l00079"></a>00079 <span class="keyword">static</span> <span class="keywordtype">int</span> global_disp_without_xterm = 0;
<a name="l00080"></a>00080
<a name="l00081"></a>00081 <span class="keyword">static</span> <span class="keywordtype">int</span> global_dump_core = 0;
<a name="l00082"></a>00082
<a name="l00083"></a>00083 <span class="keyword">static</span> <span class="keywordtype">int</span> global_clock_freq = 8000000; <span class="comment">/* Default is 8 MHz. */</span>
<a name="l00084"></a>00084
<a name="l00085"></a>00085 <span class="comment">/* If the user needs more than LEN_BREAK_LIST on the command line, they've got</span>
<a name="l00086"></a>00086 <span class="comment"> bigger problems. */</span>
<a name="l00087"></a>00087
<a name="l00088"></a>00088 <span class="preprocessor">#define LEN_BREAK_LIST 50</span>
<a name="l00089"></a>00089 <span class="preprocessor"></span><span class="keyword">static</span> <span class="keywordtype">int</span> global_break_count = 0;
<a name="l00090"></a>00090 <span class="keyword">static</span> <span class="keywordtype">int</span> global_break_list[LEN_BREAK_LIST];
<a name="l00091"></a>00091
<a name="l00092"></a>00092 <span class="keyword">static</span> AvrCore *global_core = NULL;
<a name="l00093"></a>00093
<a name="l00094"></a>00094 <span class="comment">/* *INDENT-OFF* */</span>
<a name="l00095"></a>00095 <span class="keyword">static</span> GdbComm_T global_gdb_comm[1] = {{
<a name="l00096"></a>00096 .user_data = NULL, <span class="comment">/* user_data: will be global_core later */</span>
<a name="l00097"></a>00097
<a name="l00098"></a>00098 .read_reg = (CommFuncReadReg) avr_core_gpwr_get,
<a name="l00099"></a>00099 .write_reg = (CommFuncWriteReg) avr_core_gpwr_set,
<a name="l00100"></a>00100
<a name="l00101"></a>00101 .read_sreg = (CommFuncReadSREG) avr_core_sreg_get,
<a name="l00102"></a>00102 .write_sreg = (CommFuncWriteSREG) avr_core_sreg_set,
<a name="l00103"></a>00103
<a name="l00104"></a>00104 .read_pc = (CommFuncReadPC) avr_core_PC_get,
<a name="l00105"></a>00105 .write_pc = (CommFuncWritePC) avr_core_PC_set,
<a name="l00106"></a>00106 .max_pc = (CommFuncMaxPC) avr_core_PC_max,
<a name="l00107"></a>00107
<a name="l00108"></a>00108 .read_sram = (CommFuncReadSRAM) avr_core_mem_read,
<a name="l00109"></a>00109 .write_sram = (CommFuncWriteSRAM) avr_core_mem_write,
<a name="l00110"></a>00110
<a name="l00111"></a>00111 .read_flash = (CommFuncReadFlash) avr_core_flash_read,
<a name="l00112"></a>00112 .write_flash = (CommFuncWriteFlash) avr_core_flash_write,
<a name="l00113"></a>00113 .write_flash_lo8 = (CommFuncWriteFlashLo8) avr_core_flash_write_lo8,
<a name="l00114"></a>00114 .write_flash_hi8 = (CommFuncWriteFlashHi8) avr_core_flash_write_hi8,
<a name="l00115"></a>00115
<a name="l00116"></a>00116 .insert_break = (CommFuncInsertBreak) <a class="code" href="avrcore_8c.html#5c69dbf17a369ce91d3e69eff6bdaade" title="Inserts a break point.">avr_core_insert_breakpoint</a>,
<a name="l00117"></a>00117 .remove_break = (CommFuncRemoveBreak) <a class="code" href="avrcore_8c.html#ec8478c2c50734c8d02a6ed5c5ab3b7c" title="Removes a break point.">avr_core_remove_breakpoint</a>,
<a name="l00118"></a>00118 .enable_breakpts = (CommFuncEnableBrkpts) <a class="code" href="avrcore_8c.html#e58a99ad02773957b73949f9101ac19a" title="Enable breakpoints.">avr_core_enable_breakpoints</a>,
<a name="l00119"></a>00119 .disable_breakpts = (CommFuncDisableBrkpts) <a class="code" href="avrcore_8c.html#10235f9fb338d7af94fbbfd32960aaf7" title="Disable breakpoints.">avr_core_disable_breakpoints</a>,
<a name="l00120"></a>00120
<a name="l00121"></a>00121 .step = (CommFuncStep) <a class="code" href="avrcore_8c.html#d610fa9920f74abf02206241d7348344" title="Process a single program instruction, all side effects and peripheral stimulii.">avr_core_step</a>,
<a name="l00122"></a>00122 .reset = (CommFuncReset) <a class="code" href="avrcore_8c.html#82a6c62c8efa30fc43de8754895ebddd" title="Sets the simulated CPU back to its initial state.">avr_core_reset</a>,
<a name="l00123"></a>00123
<a name="l00124"></a>00124 .io_fetch = (CommFuncIORegFetch) avr_core_io_fetch,
<a name="l00125"></a>00125
<a name="l00126"></a>00126 .irq_raise = (CommFuncIrqRaise) <a class="code" href="avrcore_8c.html#90ca5d4a60478f9fccad81724a4be552" title="Raises an irq by adding it&amp;#39;s data to the irq_pending list.">avr_core_irq_raise</a>,
<a name="l00127"></a>00127 }};
<a name="l00128"></a>00128
<a name="l00129"></a>00129 <span class="keyword">static</span> <span class="keywordtype">char</span> *usage_fmt_str =
<a name="l00130"></a>00130 <span class="stringliteral">"\nUsage: %s [OPTIONS]... [flash_image]\n"</span> <span class="stringliteral">"\n"</span>
<a name="l00131"></a>00131 <span class="stringliteral">"Simulate an avr device. The optional flash_image file is loaded\n"</span>
<a name="l00132"></a>00132 <span class="stringliteral">"into the flash program memory space of the device.\n"</span> <span class="stringliteral">"\n"</span> <span class="stringliteral">"Options:\n"</span>
<a name="l00133"></a>00133 <span class="stringliteral">" -h, --help : Show this message\n"</span>
<a name="l00134"></a>00134 <span class="stringliteral">" -D, --debug : Debug instruction output\n"</span>
<a name="l00135"></a>00135 <span class="stringliteral">" -v, --version : Print out the version number and exit\n"</span>
<a name="l00136"></a>00136 <span class="stringliteral">" -g, --gdbserver : Run as a gdbserver process\n"</span>
<a name="l00137"></a>00137 <span class="stringliteral">" -G, --gdb-debug : Print out debug messages for gdbserver\n"</span>
<a name="l00138"></a>00138 <span class="stringliteral">" -p, --port &lt;port&gt; : Listen for gdb connection on TCP port\n"</span>
<a name="l00139"></a>00139 <span class="stringliteral">" -d, --device &lt;dev&gt; : Specify device type\n"</span>
<a name="l00140"></a>00140 <span class="stringliteral">" -e, --eeprom-image &lt;img&gt; : Specify an eeprom image file\n"</span>
<a name="l00141"></a>00141 <span class="stringliteral">" -E, --eeprom-type &lt;type&gt; : Specify the type of the eeprom image file\n"</span>
<a name="l00142"></a>00142 <span class="stringliteral">" -F, --flash-type &lt;type&gt; : Specify the type of the flash image file\n"</span>
<a name="l00143"></a>00143 <span class="stringliteral">" -L, --list-devices : Print supported devices to stdout and exit\n"</span>
<a name="l00144"></a>00144 <span class="stringliteral">" -P, --disp-prog &lt;prog&gt; : Display register and memory info with prog\n"</span>
<a name="l00145"></a>00145 <span class="stringliteral">" -X, --without-xterm : Don't start disp prog in an xterm\n"</span>
<a name="l00146"></a>00146 <span class="stringliteral">" -C, --core-dump : Dump a core memory image to file on exit\n"</span>
<a name="l00147"></a>00147 <span class="stringliteral">" -c, --clock-freq &lt;freq&gt; : Set the simulated mcu clock freqency (in Hz)\n"</span>
<a name="l00148"></a>00148 <span class="stringliteral">" -B, --breakpoint &lt;addr&gt; : Set a breakpoint (address is a byte address)\n"</span>
<a name="l00149"></a>00149 <span class="stringliteral">"\n"</span> <span class="stringliteral">"If the image file types for eeprom or flash images are not given,\n"</span>
<a name="l00150"></a>00150 <span class="stringliteral">"the default file type is binary.\n"</span> <span class="stringliteral">"\n"</span>
<a name="l00151"></a>00151 <span class="stringliteral">"If you wish to run the simulator in gdbserver mode, you do not\n"</span>
<a name="l00152"></a>00152 <span class="stringliteral">"have to specify a flash-image file since the program can be loaded\n"</span>
<a name="l00153"></a>00153 <span class="stringliteral">"from gdb via the `load` command.\n"</span> <span class="stringliteral">"\n"</span>
<a name="l00154"></a>00154 <span class="stringliteral">"If '--port' option is given, and '--gdbserver' is not, port is ignored\n"</span>
<a name="l00155"></a>00155 <span class="stringliteral">"\n"</span> <span class="stringliteral">"If running in gdbserver mode and port is not specified, a default\n"</span>
<a name="l00156"></a>00156 <span class="stringliteral">"port of 1212 is used.\n"</span> <span class="stringliteral">"\n"</span>
<a name="l00157"></a>00157 <span class="stringliteral">"If using the '--breakpoint' option, note the simulator will terminate when\n"</span>
<a name="l00158"></a>00158 <span class="stringliteral">"the address is hit if you are not running in gdbserver mode. This feature\n"</span>
<a name="l00159"></a>00159 <span class="stringliteral">"not intended for use in gdbserver mode. It is really intended for testing\n"</span>
<a name="l00160"></a>00160 <span class="stringliteral">"the simulator itself, but may be useful for testing avr programs too.\n"</span>
<a name="l00161"></a>00161 <span class="stringliteral">"\n"</span> <span class="stringliteral">"Currently available device types:\n"</span>;
<a name="l00162"></a>00162
<a name="l00163"></a>00163 <span class="comment">/* *INDENT-ON* */</span>
<a name="l00164"></a>00164
<a name="l00165"></a>00165 <span class="comment">/*</span>
<a name="l00166"></a>00166 <span class="comment"> * Print usage message.</span>
<a name="l00167"></a>00167 <span class="comment"> */</span>
<a name="l00168"></a>00168 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00169"></a>00169 usage (<span class="keywordtype">char</span> *prog)
<a name="l00170"></a>00170 {
<a name="l00171"></a>00171 fprintf (stdout, usage_fmt_str, prog);
<a name="l00172"></a>00172 <a class="code" href="devsupp_8c.html#3fc3008c90677776ac1a67956e2d8701" title="Print a list of supported devices to a file pointer.">dev_supp_list_devices</a> (stdout);
<a name="l00173"></a>00173 fprintf (stdout, <span class="stringliteral">"\n"</span>);
<a name="l00174"></a>00174
<a name="l00175"></a>00175 exit (1);
<a name="l00176"></a>00176 }
<a name="l00177"></a>00177
<a name="l00178"></a>00178 <span class="comment">/* *INDENT-OFF* */</span>
<a name="l00179"></a>00179 <span class="keyword">static</span> <span class="keyword">struct </span>option long_opts[] = {
<a name="l00180"></a>00180 <span class="comment">/* name, has_arg, flag, val */</span>
<a name="l00181"></a>00181 { <span class="stringliteral">"help"</span>, 0, 0, <span class="charliteral">'h'</span> },
<a name="l00182"></a>00182 { <span class="stringliteral">"debug"</span>, 0, 0, <span class="charliteral">'D'</span> },
<a name="l00183"></a>00183 { <span class="stringliteral">"version"</span>, 0, 0, <span class="charliteral">'v'</span> },
<a name="l00184"></a>00184 { <span class="stringliteral">"gdbserver"</span>, 0, 0, <span class="charliteral">'g'</span> },
<a name="l00185"></a>00185 { <span class="stringliteral">"gdb-debug"</span>, 0, 0, <span class="charliteral">'G'</span> },
<a name="l00186"></a>00186 { <span class="stringliteral">"port"</span>, 1, 0, <span class="charliteral">'p'</span> },
<a name="l00187"></a>00187 { <span class="stringliteral">"device"</span>, 1, 0, <span class="charliteral">'d'</span> },
<a name="l00188"></a>00188 { <span class="stringliteral">"eeprom-type"</span>, 1, 0, <span class="charliteral">'E'</span> },
<a name="l00189"></a>00189 { <span class="stringliteral">"eeprom-image"</span>, 1, 0, <span class="charliteral">'e'</span> },
<a name="l00190"></a>00190 { <span class="stringliteral">"flash-type"</span>, 1, 0, <span class="charliteral">'F'</span> },
<a name="l00191"></a>00191 { <span class="stringliteral">"list-devices"</span>, 0, 0, <span class="charliteral">'L'</span> },
<a name="l00192"></a>00192 { <span class="stringliteral">"disp-prog"</span>, 1, 0, <span class="charliteral">'P'</span> },
<a name="l00193"></a>00193 { <span class="stringliteral">"without-xterm"</span>, 1, 0, <span class="charliteral">'X'</span> },
<a name="l00194"></a>00194 { <span class="stringliteral">"core-dump"</span>, 0, 0, <span class="charliteral">'C'</span> },
<a name="l00195"></a>00195 { <span class="stringliteral">"clock-freq"</span>, 1, 0, <span class="charliteral">'c'</span> },
<a name="l00196"></a>00196 { <span class="stringliteral">"breakpoint"</span>, 1, 0, <span class="charliteral">'B'</span> },
<a name="l00197"></a>00197 { NULL, 0, 0, 0 }
<a name="l00198"></a>00198 };
<a name="l00199"></a>00199 <span class="comment">/* *INDENT-ON* */</span>
<a name="l00200"></a>00200
<a name="l00201"></a>00201 <span class="comment">/*</span>
<a name="l00202"></a>00202 <span class="comment"> * Parse the command line arguments.</span>
<a name="l00203"></a>00203 <span class="comment"> */</span>
<a name="l00204"></a>00204 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00205"></a>00205 parse_cmd_line (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
<a name="l00206"></a>00206 {
<a name="l00207"></a>00207 <span class="keywordtype">int</span> c;
<a name="l00208"></a>00208 <span class="keywordtype">char</span> *prog = argv[0];
<a name="l00209"></a>00209 <span class="keywordtype">char</span> *basename;
<a name="l00210"></a>00210 <span class="keywordtype">int</span> option_index;
<a name="l00211"></a>00211 <span class="keywordtype">char</span> dummy_char;
<a name="l00212"></a>00212 <span class="keywordtype">int</span> break_addr;
<a name="l00213"></a>00213
<a name="l00214"></a>00214 opterr = 0; <span class="comment">/* disable default error message */</span>
<a name="l00215"></a>00215
<a name="l00216"></a>00216 <span class="keywordflow">while</span> (1)
<a name="l00217"></a>00217 {
<a name="l00218"></a>00218 c = getopt_long (argc, argv, <span class="stringliteral">"hgGvDLd:e:E:F:p:P:XCc:B:"</span>, long_opts,
<a name="l00219"></a>00219 &amp;option_index);
<a name="l00220"></a>00220 <span class="keywordflow">if</span> (c == -1)
<a name="l00221"></a>00221 <span class="keywordflow">break</span>; <span class="comment">/* no more options */</span>
<a name="l00222"></a>00222
<a name="l00223"></a>00223 <span class="keywordflow">switch</span> (c)
<a name="l00224"></a>00224 {
<a name="l00225"></a>00225 <span class="keywordflow">case</span> <span class="charliteral">'h'</span>:
<a name="l00226"></a>00226 <span class="keywordflow">case</span> <span class="charliteral">'?'</span>:
<a name="l00227"></a>00227 usage (prog);
<a name="l00228"></a>00228 <span class="keywordflow">case</span> <span class="charliteral">'g'</span>:
<a name="l00229"></a>00229 global_gdbserver_mode = 1;
<a name="l00230"></a>00230 <span class="keywordflow">break</span>;
<a name="l00231"></a>00231 <span class="keywordflow">case</span> <span class="charliteral">'G'</span>:
<a name="l00232"></a>00232 global_gdb_debug = 1;
<a name="l00233"></a>00233 <span class="keywordflow">break</span>;
<a name="l00234"></a>00234 <span class="keywordflow">case</span> <span class="charliteral">'p'</span>:
<a name="l00235"></a>00235 global_gdbserver_port = atoi (optarg);
<a name="l00236"></a>00236 <span class="keywordflow">break</span>;
<a name="l00237"></a>00237 <span class="keywordflow">case</span> <span class="charliteral">'v'</span>:
<a name="l00238"></a>00238 printf (<span class="stringliteral">"\n%s version %s\n"</span>, PACKAGE, VERSION);
<a name="l00239"></a>00239 printf (<span class="stringliteral">"Copyright 2001, 2002, 2003, 2004"</span>
<a name="l00240"></a>00240 <span class="stringliteral">" Theodore A. Roth.\n"</span>);
<a name="l00241"></a>00241 printf (<span class="stringliteral">"\n%s is free software, covered by the GNU General "</span>
<a name="l00242"></a>00242 <span class="stringliteral">"Public License,\n"</span>, PACKAGE);
<a name="l00243"></a>00243 printf (<span class="stringliteral">"and you are welcome to change it and/or distribute "</span>
<a name="l00244"></a>00244 <span class="stringliteral">"copies of it under\n"</span>);
<a name="l00245"></a>00245 printf (<span class="stringliteral">"the conditions of the GNU General Public License."</span>
<a name="l00246"></a>00246 <span class="stringliteral">"\n\n"</span>);
<a name="l00247"></a>00247 exit (0);
<a name="l00248"></a>00248 <span class="keywordflow">case</span> <span class="charliteral">'D'</span>:
<a name="l00249"></a>00249 <a class="code" href="avrcore_8c.html#7b9da9db79cd10ee75d5b363dd521c6e" title="Flag for enabling output of instruction debug messages.">global_debug_inst_output</a> = 1;
<a name="l00250"></a>00250 <span class="keywordflow">break</span>;
<a name="l00251"></a>00251 <span class="keywordflow">case</span> <span class="charliteral">'d'</span>:
<a name="l00252"></a>00252 global_device_type = optarg;
<a name="l00253"></a>00253 <span class="keywordflow">break</span>;
<a name="l00254"></a>00254 <span class="keywordflow">case</span> <span class="charliteral">'e'</span>:
<a name="l00255"></a>00255 global_eeprom_image_file = <a class="code" href="avrmalloc_8c.html#2af0d2ad3de670228794080e914120ea" title="Wrapper for strdup().">avr_strdup</a> (optarg);
<a name="l00256"></a>00256 <span class="keywordflow">break</span>;
<a name="l00257"></a>00257 <span class="keywordflow">case</span> <span class="charliteral">'E'</span>:
<a name="l00258"></a>00258 <span class="keywordflow">break</span>;
<a name="l00259"></a>00259 global_eeprom_image_type = <a class="code" href="utils_8c.html#5d306d06881ee5b68d679edec2e7fd75" title="Utility function to convert a string to a FileFormatType code.">str2ffmt</a> (optarg);
<a name="l00260"></a>00260 <span class="keywordflow">case</span> <span class="charliteral">'F'</span>:
<a name="l00261"></a>00261 global_flash_image_type = <a class="code" href="utils_8c.html#5d306d06881ee5b68d679edec2e7fd75" title="Utility function to convert a string to a FileFormatType code.">str2ffmt</a> (optarg);
<a name="l00262"></a>00262 <span class="keywordflow">break</span>;
<a name="l00263"></a>00263 <span class="keywordflow">case</span> <span class="charliteral">'L'</span>:
<a name="l00264"></a>00264 <a class="code" href="devsupp_8c.html#3fc3008c90677776ac1a67956e2d8701" title="Print a list of supported devices to a file pointer.">dev_supp_list_devices</a> (stdout);
<a name="l00265"></a>00265 exit (0);
<a name="l00266"></a>00266 <span class="keywordflow">case</span> <span class="charliteral">'P'</span>:
<a name="l00267"></a>00267 global_disp_prog = <a class="code" href="avrmalloc_8c.html#2af0d2ad3de670228794080e914120ea" title="Wrapper for strdup().">avr_strdup</a> (optarg);
<a name="l00268"></a>00268 <span class="keywordflow">break</span>;
<a name="l00269"></a>00269 <span class="keywordflow">case</span> <span class="charliteral">'X'</span>:
<a name="l00270"></a>00270 global_disp_without_xterm = 1;
<a name="l00271"></a>00271 <span class="keywordflow">break</span>;
<a name="l00272"></a>00272 <span class="keywordflow">case</span> <span class="charliteral">'C'</span>:
<a name="l00273"></a>00273 global_dump_core = 1;
<a name="l00274"></a>00274 <span class="keywordflow">break</span>;
<a name="l00275"></a>00275 <span class="keywordflow">case</span> <span class="charliteral">'c'</span>:
<a name="l00276"></a>00276 <span class="keywordflow">if</span> (sscanf (optarg, <span class="stringliteral">"%d%c"</span>, &amp;global_clock_freq, &amp;dummy_char)
<a name="l00277"></a>00277 != 1)
<a name="l00278"></a>00278 {
<a name="l00279"></a>00279 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Invalid clock value: %s"</span>, optarg);
<a name="l00280"></a>00280 }
<a name="l00281"></a>00281 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"Clock frequency option is not yet "</span>
<a name="l00282"></a>00282 <span class="stringliteral">"implemented.\n"</span>);
<a name="l00283"></a>00283 <span class="keywordflow">break</span>;
<a name="l00284"></a>00284 <span class="keywordflow">case</span> <span class="charliteral">'B'</span>:
<a name="l00285"></a>00285 <span class="keywordflow">if</span> (sscanf (optarg, <span class="stringliteral">"%i%c"</span>, &amp;break_addr, &amp;dummy_char) != 1)
<a name="l00286"></a>00286 {
<a name="l00287"></a>00287 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Ignoring invalid break addres: %s"</span>, optarg);
<a name="l00288"></a>00288 }
<a name="l00289"></a>00289
<a name="l00290"></a>00290 <span class="keywordflow">if</span> (global_break_count &lt; LEN_BREAK_LIST)
<a name="l00291"></a>00291 {
<a name="l00292"></a>00292 global_break_list[global_break_count] = break_addr;
<a name="l00293"></a>00293 global_break_count++;
<a name="l00294"></a>00294 }
<a name="l00295"></a>00295 <span class="keywordflow">else</span>
<a name="l00296"></a>00296 {
<a name="l00297"></a>00297 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"Too many break points: igoring %s\n"</span>,
<a name="l00298"></a>00298 optarg);
<a name="l00299"></a>00299 }
<a name="l00300"></a>00300
<a name="l00301"></a>00301 <span class="keywordflow">break</span>;
<a name="l00302"></a>00302 <span class="keywordflow">default</span>:
<a name="l00303"></a>00303 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"getop() did something screwey"</span>);
<a name="l00304"></a>00304 }
<a name="l00305"></a>00305 }
<a name="l00306"></a>00306
<a name="l00307"></a>00307 <span class="keywordflow">if</span> ((optind + 1) == argc)
<a name="l00308"></a>00308 global_flash_image_file = argv[optind];
<a name="l00309"></a>00309 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (optind != argc)
<a name="l00310"></a>00310 usage (prog);
<a name="l00311"></a>00311
<a name="l00312"></a>00312 <span class="comment">/* FIXME: Issue a warning and bail out if user selects a file format type</span>
<a name="l00313"></a>00313 <span class="comment"> we haven't implemented yet. */</span>
<a name="l00314"></a>00314
<a name="l00315"></a>00315 <span class="keywordflow">if</span> ((global_eeprom_image_type != FFMT_BIN)
<a name="l00316"></a>00316 || (global_flash_image_type != FFMT_BIN))
<a name="l00317"></a>00317 {
<a name="l00318"></a>00318 fprintf (stderr,
<a name="l00319"></a>00319 <span class="stringliteral">"Only the bin file format is currently "</span>
<a name="l00320"></a>00320 <span class="stringliteral">"implemented. Sorry.\n"</span>);
<a name="l00321"></a>00321 exit (1);
<a name="l00322"></a>00322 }
<a name="l00323"></a>00323
<a name="l00324"></a>00324 <span class="comment">/* If user didn't specify a device type, see if it can be gleaned from the</span>
<a name="l00325"></a>00325 <span class="comment"> name of the program. */</span>
<a name="l00326"></a>00326
<a name="l00327"></a>00327 <span class="keywordflow">if</span> (global_device_type == NULL)
<a name="l00328"></a>00328 {
<a name="l00329"></a>00329 <span class="comment">/* find the last '/' in dev_name */</span>
<a name="l00330"></a>00330 basename = strrchr (prog, <span class="charliteral">'/'</span>);
<a name="l00331"></a>00331 <span class="keywordflow">if</span> (basename == NULL)
<a name="l00332"></a>00332 <span class="comment">/* no slash in dev_name */</span>
<a name="l00333"></a>00333 global_device_type = prog;
<a name="l00334"></a>00334 <span class="keywordflow">else</span>
<a name="l00335"></a>00335 global_device_type = ++basename;
<a name="l00336"></a>00336 }
<a name="l00337"></a>00337 }
<a name="l00338"></a>00338
<a name="l00339"></a>00339 uint8_t
<a name="l00340"></a>00340 ext_port_rd (<span class="keywordtype">int</span> addr)
<a name="l00341"></a>00341 {
<a name="l00342"></a>00342 <span class="keywordtype">int</span> data;
<a name="l00343"></a>00343 <span class="keywordtype">char</span> line[80];
<a name="l00344"></a>00344
<a name="l00345"></a>00345 <span class="keywordflow">while</span> (1)
<a name="l00346"></a>00346 {
<a name="l00347"></a>00347 fprintf (stderr, <span class="stringliteral">"\nEnter a byte of data to read into 0x%04x: "</span>,
<a name="l00348"></a>00348 addr);
<a name="l00349"></a>00349
<a name="l00350"></a>00350 <span class="comment">/* try to read in a line of input */</span>
<a name="l00351"></a>00351 <span class="keywordflow">if</span> (fgets (line, <span class="keyword">sizeof</span> (line), stdin) == NULL)
<a name="l00352"></a>00352 <span class="keywordflow">continue</span>;
<a name="l00353"></a>00353
<a name="l00354"></a>00354 <span class="comment">/* try to parse the line for a byte of data */</span>
<a name="l00355"></a>00355 <span class="keywordflow">if</span> (sscanf (line, <span class="stringliteral">"%i\n"</span>, &amp;data) != 1)
<a name="l00356"></a>00356 <span class="keywordflow">continue</span>;
<a name="l00357"></a>00357
<a name="l00358"></a>00358 <span class="keywordflow">break</span>;
<a name="l00359"></a>00359 }
<a name="l00360"></a>00360 <span class="keywordflow">return</span> (uint8_t) (data &amp; 0xff);
<a name="l00361"></a>00361 }
<a name="l00362"></a>00362
<a name="l00363"></a>00363 <span class="keywordtype">void</span>
<a name="l00364"></a>00364 ext_port_wr (<span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00365"></a>00365 {
<a name="l00366"></a>00366 fprintf (stderr, <span class="stringliteral">"writing 0x%02x to 0x%04x\n"</span>, val, addr);
<a name="l00367"></a>00367 fflush (stderr);
<a name="l00368"></a>00368 }
<a name="l00369"></a>00369
<a name="l00370"></a>00370 <span class="comment">/* This is called whenever the program terminates via a call to exit(). */</span>
<a name="l00371"></a>00371
<a name="l00372"></a>00372 <span class="keywordtype">void</span>
<a name="l00373"></a>00373 atexit_cleanup (<span class="keywordtype">void</span>)
<a name="l00374"></a>00374 {
<a name="l00375"></a>00375 FILE *dump;
<a name="l00376"></a>00376
<a name="l00377"></a>00377 <span class="keywordflow">if</span> (global_dump_core)
<a name="l00378"></a>00378 {
<a name="l00379"></a>00379 <span class="keywordflow">if</span> ((dump = fopen (<span class="stringliteral">"core_avr_dump.core"</span>, <span class="stringliteral">"w"</span>)) == NULL)
<a name="l00380"></a>00380 {
<a name="l00381"></a>00381 <span class="comment">/* can't call avr_error here since it could have called us */</span>
<a name="l00382"></a>00382 fprintf (stderr, <span class="stringliteral">"fopen failed: core_avr_dump.core: %s\n"</span>,
<a name="l00383"></a>00383 strerror (errno));
<a name="l00384"></a>00384 }
<a name="l00385"></a>00385 <span class="keywordflow">else</span>
<a name="l00386"></a>00386 {
<a name="l00387"></a>00387 <a class="code" href="avrcore_8c.html#1db4b2fd65cfc5ffb3d651a84ef1ffa8" title="Dump the contents of the entire CPU core.">avr_core_dump_core</a> (global_core, dump);
<a name="l00388"></a>00388 fclose (dump);
<a name="l00389"></a>00389 }
<a name="l00390"></a>00390 }
<a name="l00391"></a>00391
<a name="l00392"></a>00392 <a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a> ((AvrClass *)global_core);
<a name="l00393"></a>00393 }
<a name="l00394"></a>00394
<a name="l00395"></a>00395 <span class="comment">/*</span>
<a name="l00396"></a>00396 <span class="comment"> * Symlinks should be created for each supported device to the</span>
<a name="l00397"></a>00397 <span class="comment"> * simulavr program.</span>
<a name="l00398"></a>00398 <span class="comment"> */</span>
<a name="l00399"></a>00399 <span class="keywordtype">int</span>
<a name="l00400"></a>00400 main (<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
<a name="l00401"></a>00401 {
<a name="l00402"></a>00402 <span class="keywordtype">int</span> i;
<a name="l00403"></a>00403 <span class="keywordtype">int</span> flash_sz = 0, sram_sz = 0, eeprom_sz = 0;
<a name="l00404"></a>00404 <span class="keywordtype">int</span> sram_start = 0;
<a name="l00405"></a>00405
<a name="l00406"></a>00406 parse_cmd_line (argc, argv);
<a name="l00407"></a>00407
<a name="l00408"></a>00408 global_core = <a class="code" href="avrcore_8c.html#5c5f2184f521edd707f9b23f98c4fe9b" title="Allocate a new AvrCore object.">avr_core_new</a> (global_device_type);
<a name="l00409"></a>00409 <span class="keywordflow">if</span> (global_core == NULL)
<a name="l00410"></a>00410 {
<a name="l00411"></a>00411 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"Device not supported: %s\n"</span>, global_device_type);
<a name="l00412"></a>00412 exit (1);
<a name="l00413"></a>00413 }
<a name="l00414"></a>00414
<a name="l00415"></a>00415 <a class="code" href="avrerror_8c.html#deeaf2330efd6054822bc9146527777b" title="Print an ordinary message to stdout.">avr_message</a> (<span class="stringliteral">"Simulating clock frequency of %d Hz\n"</span>, global_clock_freq);
<a name="l00416"></a>00416
<a name="l00417"></a>00417 <a class="code" href="avrcore_8c.html#b93554af0ddae11dc386c7a8017d21c2" title="Query the sizes of the 3 memory spaces: flash, sram, and eeprom.">avr_core_get_sizes</a> (global_core, &amp;flash_sz, &amp;sram_sz, &amp;sram_start,
<a name="l00418"></a>00418 &amp;eeprom_sz);
<a name="l00419"></a>00419 <a class="code" href="display_8c.html#aeea9e0008fcf18c0514a45e99a7f4d2" title="Open a display as a coprocess.">display_open</a> (global_disp_prog, global_disp_without_xterm, flash_sz,
<a name="l00420"></a>00420 sram_sz, sram_start, eeprom_sz);
<a name="l00421"></a>00421 <a class="code" href="avrcore_8c.html#3164b9e917e52fe8679fabb4f90f1047" title="Displays all registers.">avr_core_io_display_names</a> (global_core);
<a name="l00422"></a>00422
<a name="l00423"></a>00423 <span class="comment">/* Send initial clock cycles to display */</span>
<a name="l00424"></a>00424 <a class="code" href="display_8c.html#e210ab2ee875db342dcd52d43fa47693" title="Update the time in the display.">display_clock</a> (0);
<a name="l00425"></a>00425
<a name="l00426"></a>00426 <span class="comment">/* install my_atexit to be called when exit() is called */</span>
<a name="l00427"></a>00427 <span class="keywordflow">if</span> (atexit (atexit_cleanup))
<a name="l00428"></a>00428 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Failed to install exit handler"</span>);
<a name="l00429"></a>00429
<a name="l00430"></a>00430 <span class="preprocessor">#if 0</span>
<a name="l00431"></a>00431 <span class="preprocessor"></span> <span class="comment">/* Add external device hooks to ports */</span>
<a name="l00432"></a>00432 <a class="code" href="avrcore_8c.html#659be5dd132e4c71fc0fee11b9ee55e2" title="For adding external read and write callback functions.">avr_core_add_ext_rd_wr</a> (global_core, PORT_B_BASE, ext_port_rd,
<a name="l00433"></a>00433 ext_port_wr);
<a name="l00434"></a>00434 <a class="code" href="avrcore_8c.html#659be5dd132e4c71fc0fee11b9ee55e2" title="For adding external read and write callback functions.">avr_core_add_ext_rd_wr</a> (global_core, PORT_C_BASE, ext_port_rd,
<a name="l00435"></a>00435 ext_port_wr);
<a name="l00436"></a>00436 <a class="code" href="avrcore_8c.html#659be5dd132e4c71fc0fee11b9ee55e2" title="For adding external read and write callback functions.">avr_core_add_ext_rd_wr</a> (global_core, PORT_D_BASE, ext_port_rd,
<a name="l00437"></a>00437 ext_port_wr);
<a name="l00438"></a>00438 <span class="preprocessor">#endif</span>
<a name="l00439"></a>00439 <span class="preprocessor"></span>
<a name="l00440"></a>00440 <span class="comment">/* Load program into flash */</span>
<a name="l00441"></a>00441 <span class="keywordflow">if</span> (global_flash_image_file)
<a name="l00442"></a>00442 <a class="code" href="avrcore_8c.html#598a22a9aeb0742cf73d0094ea1ad34a" title="Load a program from an input file.">avr_core_load_program</a> (global_core, global_flash_image_file,
<a name="l00443"></a>00443 global_flash_image_type);
<a name="l00444"></a>00444
<a name="l00445"></a>00445 <span class="comment">/* Load eeprom data image into eeprom */</span>
<a name="l00446"></a>00446 <span class="keywordflow">if</span> (global_eeprom_image_file)
<a name="l00447"></a>00447 <a class="code" href="avrcore_8c.html#8d10faddeca29fb2322c2d89692862c2" title="Load a program from an input file.">avr_core_load_eeprom</a> (global_core, global_eeprom_image_file,
<a name="l00448"></a>00448 global_eeprom_image_type);
<a name="l00449"></a>00449
<a name="l00450"></a>00450 <span class="keywordflow">for</span> (i = 0; i &lt; global_break_count; i++)
<a name="l00451"></a>00451 {
<a name="l00452"></a>00452 <span class="comment">/* Note that we interpret the break address from the user as a byte</span>
<a name="l00453"></a>00453 <span class="comment"> address instead of a word address. This makes it easier on the user</span>
<a name="l00454"></a>00454 <span class="comment"> since binutils, gcc and gdb all work in terms of byte addresses. */</span>
<a name="l00455"></a>00455
<a name="l00456"></a>00456 <a class="code" href="avrerror_8c.html#deeaf2330efd6054822bc9146527777b" title="Print an ordinary message to stdout.">avr_message</a> (<span class="stringliteral">"Setting breakpoint at 0x%x.\n"</span>, global_break_list[i]);
<a name="l00457"></a>00457 <a class="code" href="avrcore_8c.html#5c69dbf17a369ce91d3e69eff6bdaade" title="Inserts a break point.">avr_core_insert_breakpoint</a> (global_core, global_break_list[i] / 2);
<a name="l00458"></a>00458 }
<a name="l00459"></a>00459
<a name="l00460"></a>00460 <span class="keywordflow">if</span> (global_gdbserver_mode == 1)
<a name="l00461"></a>00461 {
<a name="l00462"></a>00462 global_gdb_comm-&gt;user_data = global_core;
<a name="l00463"></a>00463 <a class="code" href="gdbserver_8c.html#e6a15ee389d8d89a9f8408490f3d8606" title="Start interacting with gdb.">gdb_interact</a> (global_gdb_comm, global_gdbserver_port,
<a name="l00464"></a>00464 global_gdb_debug);
<a name="l00465"></a>00465 }
<a name="l00466"></a>00466 <span class="keywordflow">else</span>
<a name="l00467"></a>00467 {
<a name="l00468"></a>00468 <span class="keywordflow">if</span> (global_flash_image_file)
<a name="l00469"></a>00469 <span class="comment">/* Run the program */</span>
<a name="l00470"></a>00470 <a class="code" href="avrcore_8c.html#40ce5b08150e1450aad33c78c11dfa5e" title="Start the processing of instructions by the simulator.">avr_core_run</a> (global_core);
<a name="l00471"></a>00471 <span class="keywordflow">else</span>
<a name="l00472"></a>00472 fprintf (stderr, <span class="stringliteral">"No program was specified to be run.\n"</span>);
<a name="l00473"></a>00473 }
<a name="l00474"></a>00474
<a name="l00475"></a>00475 <a class="code" href="display_8c.html#428c3bdca61ba3679fbf3c7c8356c8f6" title="Close a display and send coprocess a quit message.">display_close</a> (); <span class="comment">/* close down the display coprocess */</span>
<a name="l00476"></a>00476
<a name="l00477"></a>00477 exit (0);
<a name="l00478"></a>00478 <span class="keywordflow">return</span> 0;
<a name="l00479"></a>00479 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,514 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>memory.c</h1><a href="memory_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: memory.c,v 1.22 2008/01/06 22:38:19 joerg_wunsch Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003, 2004 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/**</span>
<a name="l00027"></a>00027 <span class="comment"> * \file memory.c</span>
<a name="l00028"></a>00028 <span class="comment"> * \brief Memory access functions.</span>
<a name="l00029"></a>00029 <span class="comment"> *</span>
<a name="l00030"></a>00030 <span class="comment"> * This module provides functions for reading and writing to simulated memory.</span>
<a name="l00031"></a>00031 <span class="comment"> * The Memory class is a subclass of AvrClass.</span>
<a name="l00032"></a>00032 <span class="comment"> */</span>
<a name="l00033"></a>00033
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00035"></a>00035
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00039"></a>00039
<a name="l00040"></a>00040 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include "utils.h"</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include "callback.h"</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include "op_names.h"</span>
<a name="l00046"></a>00046
<a name="l00047"></a>00047 <span class="preprocessor">#include "storage.h"</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include "flash.h"</span>
<a name="l00049"></a>00049
<a name="l00050"></a>00050 <span class="preprocessor">#include "vdevs.h"</span>
<a name="l00051"></a>00051 <span class="preprocessor">#include "memory.h"</span>
<a name="l00052"></a>00052 <span class="preprocessor">#include "stack.h"</span>
<a name="l00053"></a>00053 <span class="preprocessor">#include "register.h"</span>
<a name="l00054"></a>00054 <span class="preprocessor">#include "sram.h"</span>
<a name="l00055"></a>00055 <span class="preprocessor">#include "eeprom.h"</span>
<a name="l00056"></a>00056 <span class="preprocessor">#include "timers.h"</span>
<a name="l00057"></a>00057 <span class="preprocessor">#include "ports.h"</span>
<a name="l00058"></a>00058
<a name="l00059"></a>00059 <span class="preprocessor">#include "avrcore.h"</span>
<a name="l00060"></a>00060
<a name="l00061"></a>00061 <span class="preprocessor">#include "display.h"</span>
<a name="l00062"></a>00062 <span class="comment"></span>
<a name="l00063"></a>00063 <span class="comment">/** \brief Allocates memory for a new memory object. */</span>
<a name="l00064"></a>00064
<a name="l00065"></a>00065 Memory *
<a name="l00066"></a><a class="code" href="memory_8c.html#55873ce95bd961891e8a2338bb51fbd9">00066</a> <a class="code" href="memory_8c.html#55873ce95bd961891e8a2338bb51fbd9" title="Allocates memory for a new memory object.">mem_new</a> (<span class="keywordtype">int</span> gpwr_end, <span class="keywordtype">int</span> io_reg_end, <span class="keywordtype">int</span> sram_end, <span class="keywordtype">int</span> xram_end)
<a name="l00067"></a>00067 {
<a name="l00068"></a>00068 Memory *mem;
<a name="l00069"></a>00069
<a name="l00070"></a>00070 mem = <a class="code" href="avrmalloc_8c.html#ac6d810b48b67b90412badbd4b71f4e3" title="Macro for allocating memory and initializing it to zero.">avr_new0</a> (Memory, 1);
<a name="l00071"></a>00071 <a class="code" href="memory_8c.html#98917d50e483a8f307f80574d5a3b0d2" title="Constructor for the memory object.">mem_construct</a> (mem, gpwr_end, io_reg_end, sram_end, xram_end);
<a name="l00072"></a>00072 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)mem, <a class="code" href="memory_8c.html#114285e9d962c71f77ba4abc57f37670" title="Descructor for the memory object.">mem_destroy</a>);
<a name="l00073"></a>00073
<a name="l00074"></a>00074 <span class="keywordflow">return</span> mem;
<a name="l00075"></a>00075 }
<a name="l00076"></a>00076 <span class="comment"></span>
<a name="l00077"></a>00077 <span class="comment">/** \brief Constructor for the memory object. */</span>
<a name="l00078"></a>00078
<a name="l00079"></a>00079 <span class="keywordtype">void</span>
<a name="l00080"></a><a class="code" href="memory_8c.html#98917d50e483a8f307f80574d5a3b0d2">00080</a> <a class="code" href="memory_8c.html#98917d50e483a8f307f80574d5a3b0d2" title="Constructor for the memory object.">mem_construct</a> (Memory *mem, <span class="keywordtype">int</span> gpwr_end, <span class="keywordtype">int</span> io_reg_end, <span class="keywordtype">int</span> sram_end,
<a name="l00081"></a>00081 <span class="keywordtype">int</span> xram_end)
<a name="l00082"></a>00082 {
<a name="l00083"></a>00083 <span class="keywordflow">if</span> (mem == NULL)
<a name="l00084"></a>00084 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00085"></a>00085
<a name="l00086"></a>00086 mem-&gt;gpwr_end = gpwr_end;
<a name="l00087"></a>00087 mem-&gt;io_reg_end = io_reg_end;
<a name="l00088"></a>00088 mem-&gt;sram_end = sram_end;
<a name="l00089"></a>00089 mem-&gt;xram_end = xram_end;
<a name="l00090"></a>00090
<a name="l00091"></a>00091 mem-&gt;cell = <a class="code" href="avrmalloc_8c.html#ac6d810b48b67b90412badbd4b71f4e3" title="Macro for allocating memory and initializing it to zero.">avr_new0</a> (MemoryCell, xram_end + 1);
<a name="l00092"></a>00092
<a name="l00093"></a>00093 <a class="code" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e" title="Initializes the AvrClass data structure.">class_construct</a> ((AvrClass *)mem);
<a name="l00094"></a>00094 }
<a name="l00095"></a>00095 <span class="comment"></span>
<a name="l00096"></a>00096 <span class="comment">/** \brief Descructor for the memory object. */</span>
<a name="l00097"></a>00097
<a name="l00098"></a>00098 <span class="keywordtype">void</span>
<a name="l00099"></a><a class="code" href="memory_8c.html#114285e9d962c71f77ba4abc57f37670">00099</a> <a class="code" href="memory_8c.html#114285e9d962c71f77ba4abc57f37670" title="Descructor for the memory object.">mem_destroy</a> (<span class="keywordtype">void</span> *mem)
<a name="l00100"></a>00100 {
<a name="l00101"></a>00101 <span class="keywordtype">int</span> i;
<a name="l00102"></a>00102
<a name="l00103"></a>00103 Memory *<span class="keyword">this</span> = (Memory *)mem;
<a name="l00104"></a>00104
<a name="l00105"></a>00105 <span class="keywordflow">if</span> (mem == NULL)
<a name="l00106"></a>00106 <span class="keywordflow">return</span>;
<a name="l00107"></a>00107
<a name="l00108"></a>00108 <span class="keywordflow">for</span> (i = 0; i &lt; this-&gt;xram_end; i++)
<a name="l00109"></a>00109 {
<a name="l00110"></a>00110 <span class="keywordflow">if</span> (this-&gt;cell[i].vdev)
<a name="l00111"></a>00111 {
<a name="l00112"></a>00112 <a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a> ((AvrClass *)this-&gt;cell[i].vdev);
<a name="l00113"></a>00113 }
<a name="l00114"></a>00114 }
<a name="l00115"></a>00115
<a name="l00116"></a>00116 <a class="code" href="avrmalloc_8c.html#082a9d6d40f5e8bad64441ad950ec12c" title="Free malloc&amp;#39;d memory.">avr_free</a> (this-&gt;cell);
<a name="l00117"></a>00117
<a name="l00118"></a>00118 <a class="code" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5" title="Releases resources allocated by class&amp;#39;s &amp;lt;klass&amp;gt;_new() function.">class_destroy</a> (mem);
<a name="l00119"></a>00119 }
<a name="l00120"></a>00120 <span class="comment"></span>
<a name="l00121"></a>00121 <span class="comment">/** \brief Attach a device to the device list.</span>
<a name="l00122"></a>00122 <span class="comment"> </span>
<a name="l00123"></a>00123 <span class="comment"> Devices that are accessed more often should be attached</span>
<a name="l00124"></a>00124 <span class="comment"> last so that they will be at the front of the list.</span>
<a name="l00125"></a>00125 <span class="comment"> </span>
<a name="l00126"></a>00126 <span class="comment"> A default virtual device can be overridden by attaching</span>
<a name="l00127"></a>00127 <span class="comment"> a new device ahead of it in the list. */</span>
<a name="l00128"></a>00128
<a name="l00129"></a>00129 <span class="keywordtype">void</span>
<a name="l00130"></a><a class="code" href="memory_8c.html#9c93797cfe896dcfac4c139ad9f3df7b">00130</a> <a class="code" href="memory_8c.html#9c93797cfe896dcfac4c139ad9f3df7b" title="Attach a device to the device list.">mem_attach</a> (Memory *mem, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, VDevice *vdev, <span class="keywordtype">int</span> flags,
<a name="l00131"></a>00131 uint8_t reset_value, uint8_t rd_mask, uint8_t wr_mask)
<a name="l00132"></a>00132 {
<a name="l00133"></a>00133 MemoryCell *cell;
<a name="l00134"></a>00134
<a name="l00135"></a>00135 <span class="keywordflow">if</span> (mem == NULL)
<a name="l00136"></a>00136 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00137"></a>00137
<a name="l00138"></a>00138 <span class="keywordflow">if</span> (vdev == NULL)
<a name="l00139"></a>00139 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"attempt to attach null device"</span>);
<a name="l00140"></a>00140
<a name="l00141"></a>00141 <span class="keywordflow">if</span> ((addr &lt; 0) || (addr &gt; mem-&gt;xram_end))
<a name="l00142"></a>00142 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"address out of range"</span>);
<a name="l00143"></a>00143
<a name="l00144"></a>00144 cell = &amp;mem-&gt;cell[addr];
<a name="l00145"></a>00145
<a name="l00146"></a>00146 cell-&gt;name = name;
<a name="l00147"></a>00147 cell-&gt;flags = flags;
<a name="l00148"></a>00148 cell-&gt;reset_value = reset_value;
<a name="l00149"></a>00149 cell-&gt;rd_mask = rd_mask;
<a name="l00150"></a>00150 cell-&gt;wr_mask = wr_mask;
<a name="l00151"></a>00151
<a name="l00152"></a>00152 <a class="code" href="avrclass_8c.html#ff0f5b14bf2740f208041d515f3ba93f" title="Increments the reference count for the klass object.">class_ref</a> ((AvrClass *)vdev);
<a name="l00153"></a>00153 cell-&gt;vdev = vdev;
<a name="l00154"></a>00154 }
<a name="l00155"></a>00155 <span class="comment"></span>
<a name="l00156"></a>00156 <span class="comment">/** \brief Find the VDevice associated with the given address. */</span>
<a name="l00157"></a>00157
<a name="l00158"></a>00158 VDevice *
<a name="l00159"></a><a class="code" href="memory_8c.html#c5dc450f9b9f874d58df945f1a27b9c4">00159</a> <a class="code" href="memory_8c.html#c5dc450f9b9f874d58df945f1a27b9c4" title="Find the VDevice associated with the given address.">mem_get_vdevice_by_addr</a> (Memory *mem, <span class="keywordtype">int</span> addr)
<a name="l00160"></a>00160 {
<a name="l00161"></a>00161 <span class="keywordflow">return</span> mem-&gt;cell[addr].vdev;
<a name="l00162"></a>00162 }
<a name="l00163"></a>00163 <span class="comment"></span>
<a name="l00164"></a>00164 <span class="comment">/** \brief Find the VDevice associated with the given name. </span>
<a name="l00165"></a>00165 <span class="comment"></span>
<a name="l00166"></a>00166 <span class="comment"> \deprecated */</span>
<a name="l00167"></a>00167
<a name="l00168"></a>00168 VDevice *
<a name="l00169"></a><a class="code" href="memory_8c.html#502735c9e7d8045149e53f5cff95ee6f">00169</a> <a class="code" href="memory_8c.html#502735c9e7d8045149e53f5cff95ee6f" title="Find the VDevice associated with the given name.">mem_get_vdevice_by_name</a> (Memory *mem, <span class="keywordtype">char</span> *name)
<a name="l00170"></a>00170 {
<a name="l00171"></a>00171 <span class="preprocessor">#if 0</span>
<a name="l00172"></a>00172 <span class="preprocessor"></span> <span class="keywordflow">return</span> (VDevice *)<a class="code" href="utils_8c.html#d8319271cd9c519c6e97f381739497a3" title="Lookup an item in the list.">dlist_lookup</a> (mem-&gt;dev, (AvrClass *)name,
<a name="l00173"></a>00173 vdev_name_cmp);
<a name="l00174"></a>00174 <span class="preprocessor">#else</span>
<a name="l00175"></a>00175 <span class="preprocessor"></span> <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"use of deprecated interface"</span>);
<a name="l00176"></a>00176 <span class="keywordflow">return</span> NULL;
<a name="l00177"></a>00177 <span class="preprocessor">#endif</span>
<a name="l00178"></a>00178 <span class="preprocessor"></span>}
<a name="l00179"></a>00179
<a name="l00180"></a>00180 <span class="keyword">static</span> MemoryCell *
<a name="l00181"></a>00181 mem_get_cell (Memory *mem, <span class="keywordtype">int</span> addr)
<a name="l00182"></a>00182 {
<a name="l00183"></a>00183 <span class="keywordflow">return</span> mem-&gt;cell + addr;
<a name="l00184"></a>00184 }
<a name="l00185"></a>00185
<a name="l00186"></a>00186 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00187"></a>00187 mem_is_io_reg (Memory *mem, <span class="keywordtype">int</span> addr)
<a name="l00188"></a>00188 {
<a name="l00189"></a>00189 <span class="keywordflow">return</span> ((addr &gt; mem-&gt;gpwr_end) &amp;&amp; (addr &lt;= mem-&gt;io_reg_end));
<a name="l00190"></a>00190 }
<a name="l00191"></a>00191
<a name="l00192"></a>00192 <span class="keyword">static</span> <span class="keywordtype">char</span> *
<a name="l00193"></a>00193 mem_get_name (Memory *mem, <span class="keywordtype">int</span> addr)
<a name="l00194"></a>00194 {
<a name="l00195"></a>00195 <span class="keywordflow">return</span> mem-&gt;cell[addr].name;
<a name="l00196"></a>00196 }
<a name="l00197"></a>00197
<a name="l00198"></a>00198 <span class="keywordtype">void</span>
<a name="l00199"></a>00199 mem_set_addr_name (Memory *mem, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name)
<a name="l00200"></a>00200 {
<a name="l00201"></a>00201 mem-&gt;cell[addr].name = name;
<a name="l00202"></a>00202 }
<a name="l00203"></a>00203 <span class="comment"></span>
<a name="l00204"></a>00204 <span class="comment">/** \brief Reads byte from memory and sanity-checks for valid address. </span>
<a name="l00205"></a>00205 <span class="comment"> * </span>
<a name="l00206"></a>00206 <span class="comment"> * \param mem A pointer to the memory object</span>
<a name="l00207"></a>00207 <span class="comment"> * \param addr The address to be read </span>
<a name="l00208"></a>00208 <span class="comment"> * \return The byte found at that address addr</span>
<a name="l00209"></a>00209 <span class="comment"> */</span>
<a name="l00210"></a>00210
<a name="l00211"></a>00211 uint8_t
<a name="l00212"></a><a class="code" href="memory_8c.html#7ebc4d26966257412b56ef78dd33ad51">00212</a> <a class="code" href="memory_8c.html#7ebc4d26966257412b56ef78dd33ad51" title="Reads byte from memory and sanity-checks for valid address.">mem_read</a> (Memory *mem, <span class="keywordtype">int</span> addr)
<a name="l00213"></a>00213 {
<a name="l00214"></a>00214 MemoryCell *cell = mem_get_cell (mem, addr);
<a name="l00215"></a>00215
<a name="l00216"></a>00216 <span class="keywordflow">if</span> (cell-&gt;vdev == NULL)
<a name="l00217"></a>00217 {
<a name="l00218"></a>00218 <span class="keywordtype">char</span> *name = mem_get_name (mem, addr);
<a name="l00219"></a>00219
<a name="l00220"></a>00220 <span class="keywordflow">if</span> (name)
<a name="l00221"></a>00221 {
<a name="l00222"></a>00222 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"**** Attempt to read invalid %s: %s at 0x%04x\n"</span>,
<a name="l00223"></a>00223 mem_is_io_reg (mem, addr) ? <span class="stringliteral">"io reg"</span> : <span class="stringliteral">"mem addr"</span>,
<a name="l00224"></a>00224 name, addr);
<a name="l00225"></a>00225 }
<a name="l00226"></a>00226 <span class="keywordflow">else</span>
<a name="l00227"></a>00227 {
<a name="l00228"></a>00228 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"**** Attempt to read invalid %s: 0x%04x\n"</span>,
<a name="l00229"></a>00229 mem_is_io_reg (mem, addr) ? <span class="stringliteral">"io reg"</span> : <span class="stringliteral">"mem addr"</span>,
<a name="l00230"></a>00230 addr);
<a name="l00231"></a>00231 }
<a name="l00232"></a>00232
<a name="l00233"></a>00233 <span class="keywordflow">return</span> 0;
<a name="l00234"></a>00234 }
<a name="l00235"></a>00235
<a name="l00236"></a>00236 <span class="keywordflow">return</span> (<a class="code" href="device_8c.html#2c32d0afc4607136c886acbf362874ed" title="Reads the device&amp;#39;s value in the register at addr.">vdev_read</a> (cell-&gt;vdev, addr) &amp; cell-&gt;rd_mask);
<a name="l00237"></a>00237 }
<a name="l00238"></a>00238 <span class="comment"></span>
<a name="l00239"></a>00239 <span class="comment">/** \brief Writes byte to memory and updates display for io registers. </span>
<a name="l00240"></a>00240 <span class="comment"> * </span>
<a name="l00241"></a>00241 <span class="comment"> * \param mem A pointer to a memory object</span>
<a name="l00242"></a>00242 <span class="comment"> * \param addr The address to be written to</span>
<a name="l00243"></a>00243 <span class="comment"> * \param val The value to be written there</span>
<a name="l00244"></a>00244 <span class="comment"> */</span>
<a name="l00245"></a>00245
<a name="l00246"></a>00246 <span class="keywordtype">void</span>
<a name="l00247"></a><a class="code" href="memory_8c.html#218836433955d34b6eabfbc3d48aedda">00247</a> <a class="code" href="memory_8c.html#218836433955d34b6eabfbc3d48aedda" title="Writes byte to memory and updates display for io registers.">mem_write</a> (Memory *mem, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00248"></a>00248 {
<a name="l00249"></a>00249 MemoryCell *cell = mem_get_cell (mem, addr);
<a name="l00250"></a>00250
<a name="l00251"></a>00251 <span class="keywordflow">if</span> (cell-&gt;vdev == NULL)
<a name="l00252"></a>00252 {
<a name="l00253"></a>00253 <span class="keywordtype">char</span> *name = mem_get_name (mem, addr);
<a name="l00254"></a>00254
<a name="l00255"></a>00255 <span class="keywordflow">if</span> (name)
<a name="l00256"></a>00256 {
<a name="l00257"></a>00257 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"**** Attempt to write invalid %s: %s at 0x%04x\n"</span>,
<a name="l00258"></a>00258 mem_is_io_reg (mem, addr) ? <span class="stringliteral">"io reg"</span> : <span class="stringliteral">"mem addr"</span>,
<a name="l00259"></a>00259 name, addr);
<a name="l00260"></a>00260 }
<a name="l00261"></a>00261 <span class="keywordflow">else</span>
<a name="l00262"></a>00262 {
<a name="l00263"></a>00263 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"**** Attempt to write invalid %s: 0x%04x\n"</span>,
<a name="l00264"></a>00264 mem_is_io_reg (mem, addr) ? <span class="stringliteral">"io reg"</span> : <span class="stringliteral">"mem addr"</span>,
<a name="l00265"></a>00265 addr);
<a name="l00266"></a>00266 }
<a name="l00267"></a>00267
<a name="l00268"></a>00268 <span class="keywordflow">return</span>;
<a name="l00269"></a>00269 }
<a name="l00270"></a>00270
<a name="l00271"></a>00271 <span class="comment">/* update the display for io registers here */</span>
<a name="l00272"></a>00272
<a name="l00273"></a>00273 <span class="keywordflow">if</span> (mem_is_io_reg (mem, addr))
<a name="l00274"></a>00274 <a class="code" href="display_8c.html#ed9707596c157777dc33fe1371ded7fc" title="Update an IO register in the display.">display_io_reg</a> (addr - (mem-&gt;gpwr_end + 1), val &amp; cell-&gt;wr_mask);
<a name="l00275"></a>00275
<a name="l00276"></a>00276 <a class="code" href="device_8c.html#502a4216ffd7501ad3059e95d0f5572f" title="Writes an value to the register at addr.">vdev_write</a> (cell-&gt;vdev, addr, val &amp; cell-&gt;wr_mask);
<a name="l00277"></a>00277 }
<a name="l00278"></a>00278 <span class="comment"></span>
<a name="l00279"></a>00279 <span class="comment">/** \brief Resets every device in the memory object.</span>
<a name="l00280"></a>00280 <span class="comment"> * \param mem A pointer to the memory object.</span>
<a name="l00281"></a>00281 <span class="comment"> */</span>
<a name="l00282"></a>00282
<a name="l00283"></a>00283 <span class="keywordtype">void</span>
<a name="l00284"></a><a class="code" href="memory_8c.html#fb9d511f1ce2e883195d07fd7900f635">00284</a> <a class="code" href="memory_8c.html#fb9d511f1ce2e883195d07fd7900f635" title="Resets every device in the memory object.">mem_reset</a> (Memory *mem)
<a name="l00285"></a>00285 {
<a name="l00286"></a>00286 <span class="keywordtype">int</span> i;
<a name="l00287"></a>00287
<a name="l00288"></a>00288 <span class="keywordflow">for</span> (i = 0; i &lt; mem-&gt;xram_end; i++)
<a name="l00289"></a>00289 {
<a name="l00290"></a>00290 MemoryCell *cell = mem_get_cell (mem, i);
<a name="l00291"></a>00291
<a name="l00292"></a>00292 <span class="keywordflow">if</span> (cell-&gt;vdev)
<a name="l00293"></a>00293 <a class="code" href="device_8c.html#1d98f1f4d77ce7d714ffde36ada57db7" title="Resets a device.">vdev_reset</a> (cell-&gt;vdev);
<a name="l00294"></a>00294 }
<a name="l00295"></a>00295 }
<a name="l00296"></a>00296
<a name="l00297"></a>00297 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00298"></a>00298 mem_reg_dump_core (Memory *mem, FILE * f_core)
<a name="l00299"></a>00299 {
<a name="l00300"></a>00300 <span class="keywordtype">int</span> i, j;
<a name="l00301"></a>00301
<a name="l00302"></a>00302 fprintf (f_core, <span class="stringliteral">"General Purpose Register Dump:\n"</span>);
<a name="l00303"></a>00303 <span class="keywordflow">for</span> (i = 0; i &lt; 32; i += 8)
<a name="l00304"></a>00304 {
<a name="l00305"></a>00305 <span class="keywordflow">for</span> (j = i; j &lt; (i + 8); j++)
<a name="l00306"></a>00306 fprintf (f_core, <span class="stringliteral">"r%02d=%02x "</span>, j, <a class="code" href="memory_8c.html#7ebc4d26966257412b56ef78dd33ad51" title="Reads byte from memory and sanity-checks for valid address.">mem_read</a> (mem, j));
<a name="l00307"></a>00307 fprintf (f_core, <span class="stringliteral">"\n"</span>);
<a name="l00308"></a>00308 }
<a name="l00309"></a>00309 fprintf (f_core, <span class="stringliteral">"\n"</span>);
<a name="l00310"></a>00310 }
<a name="l00311"></a>00311 <span class="comment"></span>
<a name="l00312"></a>00312 <span class="comment">/** \brief Fetch the name and value of the io register (addr). </span>
<a name="l00313"></a>00313 <span class="comment"> *</span>
<a name="l00314"></a>00314 <span class="comment"> * \param mem A pointer to the memory object.</span>
<a name="l00315"></a>00315 <span class="comment"> * \param addr The address to fetch from.</span>
<a name="l00316"></a>00316 <span class="comment"> * \param val A pointer where the value of the register is to be copied.</span>
<a name="l00317"></a>00317 <span class="comment"> * \param buf A pointer to where the name of the register should be copied.</span>
<a name="l00318"></a>00318 <span class="comment"> * \param bufsiz The maximum size of the the buf string.</span>
<a name="l00319"></a>00319 <span class="comment"> */</span>
<a name="l00320"></a>00320
<a name="l00321"></a>00321 <span class="keywordtype">void</span>
<a name="l00322"></a><a class="code" href="memory_8c.html#0a2cee082a6775c45b08324be6ded380">00322</a> <a class="code" href="memory_8c.html#0a2cee082a6775c45b08324be6ded380" title="Fetch the name and value of the io register (addr).">mem_io_fetch</a> (Memory *mem, <span class="keywordtype">int</span> addr, uint8_t * val, <span class="keywordtype">char</span> *buf, <span class="keywordtype">int</span> bufsiz)
<a name="l00323"></a>00323 {
<a name="l00324"></a>00324 MemoryCell *cell;
<a name="l00325"></a>00325
<a name="l00326"></a>00326 <span class="keywordflow">if</span> (mem_is_io_reg (mem, addr))
<a name="l00327"></a>00327 {
<a name="l00328"></a>00328 cell = mem_get_cell (mem, addr);
<a name="l00329"></a>00329
<a name="l00330"></a>00330 <span class="keywordflow">if</span> (cell-&gt;name == NULL)
<a name="l00331"></a>00331 {
<a name="l00332"></a>00332 strncpy (buf, <span class="stringliteral">"Reserved"</span>, bufsiz);
<a name="l00333"></a>00333 *val = 0;
<a name="l00334"></a>00334 }
<a name="l00335"></a>00335 <span class="keywordflow">else</span>
<a name="l00336"></a>00336 {
<a name="l00337"></a>00337 strncpy (buf, cell-&gt;name, bufsiz);
<a name="l00338"></a>00338
<a name="l00339"></a>00339 <span class="keywordflow">if</span> (cell-&gt;vdev)
<a name="l00340"></a>00340 {
<a name="l00341"></a>00341 <span class="comment">/* FIXME: Add vdev_read_no_ext () interface to avoid calling</span>
<a name="l00342"></a>00342 <span class="comment"> the external functions during a read. This will require a</span>
<a name="l00343"></a>00343 <span class="comment"> reworking of how the vdev invokes the external read</span>
<a name="l00344"></a>00344 <span class="comment"> method. */</span>
<a name="l00345"></a>00345
<a name="l00346"></a>00346 *val = (<a class="code" href="device_8c.html#2c32d0afc4607136c886acbf362874ed" title="Reads the device&amp;#39;s value in the register at addr.">vdev_read</a> (cell-&gt;vdev, addr) &amp; cell-&gt;rd_mask);
<a name="l00347"></a>00347 }
<a name="l00348"></a>00348 <span class="keywordflow">else</span>
<a name="l00349"></a>00349 {
<a name="l00350"></a>00350 *val = 0;
<a name="l00351"></a>00351 }
<a name="l00352"></a>00352 }
<a name="l00353"></a>00353 }
<a name="l00354"></a>00354 <span class="keywordflow">else</span>
<a name="l00355"></a>00355 {
<a name="l00356"></a>00356 *val = 0;
<a name="l00357"></a>00357 strncpy (buf, <span class="stringliteral">"NOT AN IO REG"</span>, bufsiz);
<a name="l00358"></a>00358 }
<a name="l00359"></a>00359 }
<a name="l00360"></a>00360
<a name="l00361"></a>00361 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00362"></a>00362 mem_io_reg_dump_core (Memory *mem, FILE * f_core)
<a name="l00363"></a>00363 {
<a name="l00364"></a>00364 <span class="keywordtype">int</span> i, j;
<a name="l00365"></a>00365 <span class="keywordtype">char</span> name[80];
<a name="l00366"></a>00366 uint8_t val;
<a name="l00367"></a>00367
<a name="l00368"></a>00368 <span class="keywordtype">int</span> begin = mem-&gt;gpwr_end + 1;
<a name="l00369"></a>00369 <span class="keywordtype">int</span> end = mem-&gt;io_reg_end;
<a name="l00370"></a>00370 <span class="keywordtype">int</span> half = (end - begin) / 2;
<a name="l00371"></a>00371 <span class="keywordtype">int</span> mid = begin + half;
<a name="l00372"></a>00372
<a name="l00373"></a>00373 fprintf (f_core, <span class="stringliteral">"IO Register Dump:\n"</span>);
<a name="l00374"></a>00374 <span class="keywordflow">for</span> (i = begin; i &lt; mid; i++)
<a name="l00375"></a>00375 {
<a name="l00376"></a>00376 <span class="keywordflow">for</span> (j = i; j &lt; end; j += half)
<a name="l00377"></a>00377 {
<a name="l00378"></a>00378 memset (name, <span class="charliteral">'\0'</span>, <span class="keyword">sizeof</span> (name));
<a name="l00379"></a>00379 <a class="code" href="memory_8c.html#0a2cee082a6775c45b08324be6ded380" title="Fetch the name and value of the io register (addr).">mem_io_fetch</a> (mem, j, &amp;val, name, <span class="keyword">sizeof</span> (name) - 1);
<a name="l00380"></a>00380
<a name="l00381"></a>00381 fprintf (f_core, <span class="stringliteral">"%02x : %-10s : 0x%02x "</span>, j - half,
<a name="l00382"></a>00382 name, val);
<a name="l00383"></a>00383 }
<a name="l00384"></a>00384 fprintf (f_core, <span class="stringliteral">"\n"</span>);
<a name="l00385"></a>00385 }
<a name="l00386"></a>00386 fprintf (f_core, <span class="stringliteral">"\n"</span>);
<a name="l00387"></a>00387 }
<a name="l00388"></a>00388
<a name="l00389"></a>00389 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00390"></a>00390 mem_sram_display (Memory *mem, FILE * f_core, <span class="keywordtype">int</span> base, <span class="keywordtype">int</span> size)
<a name="l00391"></a>00391 {
<a name="l00392"></a>00392 <span class="keywordtype">int</span> i;
<a name="l00393"></a>00393 <span class="keywordtype">int</span> dup = 0;
<a name="l00394"></a>00394 <span class="keywordtype">int</span> ndat = 16;
<a name="l00395"></a>00395 <span class="keywordtype">char</span> line[80];
<a name="l00396"></a>00396 <span class="keywordtype">char</span> last_line[80];
<a name="l00397"></a>00397 <span class="keywordtype">char</span> buf[80];
<a name="l00398"></a>00398 line[0] = last_line[0] = <span class="charliteral">'\0'</span>;
<a name="l00399"></a>00399
<a name="l00400"></a>00400 <span class="keywordflow">for</span> (i = base; i &lt; (base + size); i++)
<a name="l00401"></a>00401 {
<a name="l00402"></a>00402 <span class="keywordflow">if</span> (((i % ndat) == 0) &amp;&amp; strlen (line))
<a name="l00403"></a>00403 {
<a name="l00404"></a>00404 <span class="keywordflow">if</span> (strncmp (line, last_line, 80) == 0)
<a name="l00405"></a>00405 {
<a name="l00406"></a>00406 dup++;
<a name="l00407"></a>00407 }
<a name="l00408"></a>00408 <span class="keywordflow">else</span>
<a name="l00409"></a>00409 {
<a name="l00410"></a>00410 <span class="keywordflow">if</span> (dup &gt; 0)
<a name="l00411"></a>00411 fprintf (f_core, <span class="stringliteral">" -- last line repeats --\n"</span>);
<a name="l00412"></a>00412 fprintf (f_core, <span class="stringliteral">"%04x : %s\n"</span>, i - ndat, line);
<a name="l00413"></a>00413 dup = 0;
<a name="l00414"></a>00414 }
<a name="l00415"></a>00415 strncpy (last_line, line, 80);
<a name="l00416"></a>00416 line[0] = <span class="charliteral">'\0'</span>;
<a name="l00417"></a>00417 }
<a name="l00418"></a>00418 snprintf (buf, 80, <span class="stringliteral">"%02x "</span>, <a class="code" href="memory_8c.html#7ebc4d26966257412b56ef78dd33ad51" title="Reads byte from memory and sanity-checks for valid address.">mem_read</a> (mem, i));
<a name="l00419"></a>00419 strncat (line, buf, 80);
<a name="l00420"></a>00420 }
<a name="l00421"></a>00421 <span class="keywordflow">if</span> (dup &gt; 0)
<a name="l00422"></a>00422 {
<a name="l00423"></a>00423 fprintf (f_core, <span class="stringliteral">" -- last line repeats --\n"</span>);
<a name="l00424"></a>00424 fprintf (f_core, <span class="stringliteral">"%04x : %s\n"</span>, i - ndat, line);
<a name="l00425"></a>00425 }
<a name="l00426"></a>00426 fprintf (f_core, <span class="stringliteral">"\n"</span>);
<a name="l00427"></a>00427 }
<a name="l00428"></a>00428
<a name="l00429"></a>00429 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00430"></a>00430 mem_sram_dump_core (Memory *mem, FILE * f_core)
<a name="l00431"></a>00431 {
<a name="l00432"></a>00432 <span class="keywordtype">int</span> size, base;
<a name="l00433"></a>00433
<a name="l00434"></a>00434 <span class="comment">/*</span>
<a name="l00435"></a>00435 <span class="comment"> * Dump the internal sram</span>
<a name="l00436"></a>00436 <span class="comment"> */</span>
<a name="l00437"></a>00437
<a name="l00438"></a>00438 <span class="keywordflow">if</span> (mem-&gt;io_reg_end == mem-&gt;sram_end)
<a name="l00439"></a>00439 <span class="keywordflow">return</span>; <span class="comment">/* device has no sram */</span>
<a name="l00440"></a>00440
<a name="l00441"></a>00441 fprintf (f_core, <span class="stringliteral">"Internal SRAM Memory Dump:\n"</span>);
<a name="l00442"></a>00442 base = mem-&gt;io_reg_end + 1;
<a name="l00443"></a>00443 size = mem-&gt;sram_end - base + 1;
<a name="l00444"></a>00444 mem_sram_display (mem, f_core, base, size);
<a name="l00445"></a>00445
<a name="l00446"></a>00446 <span class="comment">/*</span>
<a name="l00447"></a>00447 <span class="comment"> * If external sram present, dump it too.</span>
<a name="l00448"></a>00448 <span class="comment"> */</span>
<a name="l00449"></a>00449
<a name="l00450"></a>00450 <span class="keywordflow">if</span> (mem-&gt;sram_end == mem-&gt;xram_end)
<a name="l00451"></a>00451 <span class="keywordflow">return</span>; <span class="comment">/* device has no xram */</span>
<a name="l00452"></a>00452
<a name="l00453"></a>00453 fprintf (f_core, <span class="stringliteral">"External SRAM Memory Dump:\n"</span>);
<a name="l00454"></a>00454 base = mem-&gt;sram_end + 1;
<a name="l00455"></a>00455 size = mem-&gt;xram_end - base + 1;
<a name="l00456"></a>00456 mem_sram_display (mem, f_core, base, size);
<a name="l00457"></a>00457
<a name="l00458"></a>00458 }
<a name="l00459"></a>00459
<a name="l00460"></a>00460 <span class="preprocessor">#if 0</span>
<a name="l00461"></a>00461 <span class="preprocessor"></span>
<a name="l00462"></a>00462 <span class="comment">/* FIXME: Still need to figure out a sane way to look up a specific type of</span>
<a name="l00463"></a>00463 <span class="comment"> vdev by generic name. */</span>
<a name="l00464"></a>00464
<a name="l00465"></a>00465 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00466"></a>00466 mem_eeprom_dump_core (Memory *mem, FILE * f_core)
<a name="l00467"></a>00467 {
<a name="l00468"></a>00468 VDevice *dev = <a class="code" href="memory_8c.html#502735c9e7d8045149e53f5cff95ee6f" title="Find the VDevice associated with the given name.">mem_get_vdevice_by_name</a> (mem, <span class="stringliteral">"EEProm"</span>);
<a name="l00469"></a>00469
<a name="l00470"></a>00470 <span class="keywordflow">if</span> (dev != NULL)
<a name="l00471"></a>00471 eeprom_dump_core ((EEProm *)dev, f_core);
<a name="l00472"></a>00472 }
<a name="l00473"></a>00473 <span class="preprocessor">#endif</span>
<a name="l00474"></a>00474 <span class="preprocessor"></span><span class="comment"></span>
<a name="l00475"></a>00475 <span class="comment">/** \brief Dump all the various memory locations to a file descriptor </span>
<a name="l00476"></a>00476 <span class="comment"> * in text format.</span>
<a name="l00477"></a>00477 <span class="comment"> *</span>
<a name="l00478"></a>00478 <span class="comment"> * \param mem A memory object.</span>
<a name="l00479"></a>00479 <span class="comment"> * \param f_core An open file descriptor.</span>
<a name="l00480"></a>00480 <span class="comment"> */</span>
<a name="l00481"></a>00481
<a name="l00482"></a>00482 <span class="keywordtype">void</span>
<a name="l00483"></a><a class="code" href="memory_8c.html#4d727abdd19adeb472009cd9938886d4">00483</a> <a class="code" href="memory_8c.html#4d727abdd19adeb472009cd9938886d4" title="Dump all the various memory locations to a file descriptor in text format.">mem_dump_core</a> (Memory *mem, FILE * f_core)
<a name="l00484"></a>00484 {
<a name="l00485"></a>00485 mem_reg_dump_core (mem, f_core);
<a name="l00486"></a>00486 mem_io_reg_dump_core (mem, f_core);
<a name="l00487"></a>00487 mem_sram_dump_core (mem, f_core);
<a name="l00488"></a>00488 <span class="comment">/* mem_eeprom_dump_core (mem, f_core); */</span>
<a name="l00489"></a>00489 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,569 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>memory.c File Reference</h1>Memory access functions. <a href="#_details">More...</a>
<p>
<p>
<a href="memory_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">Memory *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory_8c.html#55873ce95bd961891e8a2338bb51fbd9">mem_new</a> (int gpwr_end, int io_reg_end, int sram_end, int xram_end)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory_8c.html#98917d50e483a8f307f80574d5a3b0d2">mem_construct</a> (Memory *mem, int gpwr_end, int io_reg_end, int sram_end, int xram_end)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory_8c.html#114285e9d962c71f77ba4abc57f37670">mem_destroy</a> (void *mem)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory_8c.html#9c93797cfe896dcfac4c139ad9f3df7b">mem_attach</a> (Memory *mem, int addr, char *name, VDevice *vdev, int flags, uint8_t reset_value, uint8_t rd_mask, uint8_t wr_mask)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory_8c.html#c5dc450f9b9f874d58df945f1a27b9c4">mem_get_vdevice_by_addr</a> (Memory *mem, int addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory_8c.html#502735c9e7d8045149e53f5cff95ee6f">mem_get_vdevice_by_name</a> (Memory *mem, char *name)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="abf28cc1ba2c04411136f0bfc4c33245"></a><!-- doxytag: member="memory.c::mem_set_addr_name" ref="abf28cc1ba2c04411136f0bfc4c33245" args="(Memory *mem, int addr, char *name)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><b>mem_set_addr_name</b> (Memory *mem, int addr, char *name)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">uint8_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory_8c.html#7ebc4d26966257412b56ef78dd33ad51">mem_read</a> (Memory *mem, int addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory_8c.html#218836433955d34b6eabfbc3d48aedda">mem_write</a> (Memory *mem, int addr, uint8_t val)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory_8c.html#fb9d511f1ce2e883195d07fd7900f635">mem_reset</a> (Memory *mem)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory_8c.html#0a2cee082a6775c45b08324be6ded380">mem_io_fetch</a> (Memory *mem, int addr, uint8_t *val, char *buf, int bufsiz)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="memory_8c.html#4d727abdd19adeb472009cd9938886d4">mem_dump_core</a> (Memory *mem, FILE *f_core)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Memory access functions.
<p>
This module provides functions for reading and writing to simulated memory. The Memory class is a subclass of AvrClass.
<p>Definition in file <a class="el" href="memory_8c-source.html">memory.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="55873ce95bd961891e8a2338bb51fbd9"></a><!-- doxytag: member="memory.c::mem_new" ref="55873ce95bd961891e8a2338bb51fbd9" args="(int gpwr_end, int io_reg_end, int sram_end, int xram_end)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">Memory* mem_new </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>gpwr_end</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>io_reg_end</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>sram_end</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>xram_end</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocates memory for a new memory object.
<p>
<p>Definition at line <a class="el" href="memory_8c-source.html#l00066">66</a> of file <a class="el" href="memory_8c-source.html">memory.c</a>.</p>
<p>References <a class="el" href="avrmalloc_8c-source.html#l00067">avr_new0</a>, <a class="el" href="avrclass_8c-source.html#l00092">class_overload_destroy()</a>, <a class="el" href="memory_8c-source.html#l00080">mem_construct()</a>, and <a class="el" href="memory_8c-source.html#l00099">mem_destroy()</a>.</p>
</div>
</div><p>
<a class="anchor" name="98917d50e483a8f307f80574d5a3b0d2"></a><!-- doxytag: member="memory.c::mem_construct" ref="98917d50e483a8f307f80574d5a3b0d2" args="(Memory *mem, int gpwr_end, int io_reg_end, int sram_end, int xram_end)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mem_construct </td>
<td>(</td>
<td class="paramtype">Memory *&nbsp;</td>
<td class="paramname"> <em>mem</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>gpwr_end</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>io_reg_end</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>sram_end</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>xram_end</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for the memory object.
<p>
<p>Definition at line <a class="el" href="memory_8c-source.html#l00080">80</a> of file <a class="el" href="memory_8c-source.html">memory.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, <a class="el" href="avrmalloc_8c-source.html#l00067">avr_new0</a>, and <a class="el" href="avrclass_8c-source.html#l00061">class_construct()</a>.</p>
<p>Referenced by <a class="el" href="memory_8c-source.html#l00066">mem_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="114285e9d962c71f77ba4abc57f37670"></a><!-- doxytag: member="memory.c::mem_destroy" ref="114285e9d962c71f77ba4abc57f37670" args="(void *mem)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mem_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>mem</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Descructor for the memory object.
<p>
<p>Definition at line <a class="el" href="memory_8c-source.html#l00099">99</a> of file <a class="el" href="memory_8c-source.html">memory.c</a>.</p>
<p>References <a class="el" href="avrmalloc_8c-source.html#l00187">avr_free()</a>, <a class="el" href="avrclass_8c-source.html#l00078">class_destroy()</a>, and <a class="el" href="avrclass_8c-source.html#l00120">class_unref()</a>.</p>
<p>Referenced by <a class="el" href="memory_8c-source.html#l00066">mem_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="9c93797cfe896dcfac4c139ad9f3df7b"></a><!-- doxytag: member="memory.c::mem_attach" ref="9c93797cfe896dcfac4c139ad9f3df7b" args="(Memory *mem, int addr, char *name, VDevice *vdev, int flags, uint8_t reset_value, uint8_t rd_mask, uint8_t wr_mask)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mem_attach </td>
<td>(</td>
<td class="paramtype">Memory *&nbsp;</td>
<td class="paramname"> <em>mem</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">VDevice *&nbsp;</td>
<td class="paramname"> <em>vdev</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>flags</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&nbsp;</td>
<td class="paramname"> <em>reset_value</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&nbsp;</td>
<td class="paramname"> <em>rd_mask</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&nbsp;</td>
<td class="paramname"> <em>wr_mask</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Attach a device to the device list.
<p>
Devices that are accessed more often should be attached last so that they will be at the front of the list.<p>
A default virtual device can be overridden by attaching a new device ahead of it in the list.
<p>Definition at line <a class="el" href="memory_8c-source.html#l00130">130</a> of file <a class="el" href="memory_8c-source.html">memory.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="avrclass_8c-source.html#l00106">class_ref()</a>.</p>
</div>
</div><p>
<a class="anchor" name="c5dc450f9b9f874d58df945f1a27b9c4"></a><!-- doxytag: member="memory.c::mem_get_vdevice_by_addr" ref="c5dc450f9b9f874d58df945f1a27b9c4" args="(Memory *mem, int addr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* mem_get_vdevice_by_addr </td>
<td>(</td>
<td class="paramtype">Memory *&nbsp;</td>
<td class="paramname"> <em>mem</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Find the VDevice associated with the given address.
<p>
<p>Definition at line <a class="el" href="memory_8c-source.html#l00159">159</a> of file <a class="el" href="memory_8c-source.html">memory.c</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l01234">avr_core_add_ext_rd_wr()</a>, and <a class="el" href="stack_8c-source.html#l00402">memstack_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="502735c9e7d8045149e53f5cff95ee6f"></a><!-- doxytag: member="memory.c::mem_get_vdevice_by_name" ref="502735c9e7d8045149e53f5cff95ee6f" args="(Memory *mem, char *name)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* mem_get_vdevice_by_name </td>
<td>(</td>
<td class="paramtype">Memory *&nbsp;</td>
<td class="paramname"> <em>mem</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Find the VDevice associated with the given name.
<p>
<dl compact><dt><b><a class="el" href="deprecated.html#_deprecated000001">Deprecated:</a></b></dt><dd></dd></dl>
<p>Definition at line <a class="el" href="memory_8c-source.html#l00169">169</a> of file <a class="el" href="memory_8c-source.html">memory.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="utils_8c-source.html#l00291">dlist_lookup()</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l01304">avr_core_load_eeprom()</a>.</p>
</div>
</div><p>
<a class="anchor" name="7ebc4d26966257412b56ef78dd33ad51"></a><!-- doxytag: member="memory.c::mem_read" ref="7ebc4d26966257412b56ef78dd33ad51" args="(Memory *mem, int addr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint8_t mem_read </td>
<td>(</td>
<td class="paramtype">Memory *&nbsp;</td>
<td class="paramname"> <em>mem</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Reads byte from memory and sanity-checks for valid address.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>mem</em>&nbsp;</td><td>A pointer to the memory object </td></tr>
<tr><td valign="top"></td><td valign="top"><em>addr</em>&nbsp;</td><td>The address to be read </td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The byte found at that address addr </dd></dl>
<p>Definition at line <a class="el" href="memory_8c-source.html#l00212">212</a> of file <a class="el" href="memory_8c-source.html">memory.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00046">avr_warning</a>, and <a class="el" href="device_8c-source.html#l00161">vdev_read()</a>.</p>
</div>
</div><p>
<a class="anchor" name="218836433955d34b6eabfbc3d48aedda"></a><!-- doxytag: member="memory.c::mem_write" ref="218836433955d34b6eabfbc3d48aedda" args="(Memory *mem, int addr, uint8_t val)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mem_write </td>
<td>(</td>
<td class="paramtype">Memory *&nbsp;</td>
<td class="paramname"> <em>mem</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&nbsp;</td>
<td class="paramname"> <em>val</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Writes byte to memory and updates display for io registers.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>mem</em>&nbsp;</td><td>A pointer to a memory object </td></tr>
<tr><td valign="top"></td><td valign="top"><em>addr</em>&nbsp;</td><td>The address to be written to </td></tr>
<tr><td valign="top"></td><td valign="top"><em>val</em>&nbsp;</td><td>The value to be written there </td></tr>
</table>
</dl>
<p>Definition at line <a class="el" href="memory_8c-source.html#l00247">247</a> of file <a class="el" href="memory_8c-source.html">memory.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00046">avr_warning</a>, <a class="el" href="display_8c-source.html#l00299">display_io_reg()</a>, and <a class="el" href="device_8c-source.html#l00168">vdev_write()</a>.</p>
</div>
</div><p>
<a class="anchor" name="fb9d511f1ce2e883195d07fd7900f635"></a><!-- doxytag: member="memory.c::mem_reset" ref="fb9d511f1ce2e883195d07fd7900f635" args="(Memory *mem)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mem_reset </td>
<td>(</td>
<td class="paramtype">Memory *&nbsp;</td>
<td class="paramname"> <em>mem</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Resets every device in the memory object.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>mem</em>&nbsp;</td><td>A pointer to the memory object. </td></tr>
</table>
</dl>
<p>Definition at line <a class="el" href="memory_8c-source.html#l00284">284</a> of file <a class="el" href="memory_8c-source.html">memory.c</a>.</p>
<p>References <a class="el" href="device_8c-source.html#l00175">vdev_reset()</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l01194">avr_core_reset()</a>.</p>
</div>
</div><p>
<a class="anchor" name="0a2cee082a6775c45b08324be6ded380"></a><!-- doxytag: member="memory.c::mem_io_fetch" ref="0a2cee082a6775c45b08324be6ded380" args="(Memory *mem, int addr, uint8_t *val, char *buf, int bufsiz)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mem_io_fetch </td>
<td>(</td>
<td class="paramtype">Memory *&nbsp;</td>
<td class="paramname"> <em>mem</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t *&nbsp;</td>
<td class="paramname"> <em>val</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>buf</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>bufsiz</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Fetch the name and value of the io register (addr).
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>mem</em>&nbsp;</td><td>A pointer to the memory object. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>addr</em>&nbsp;</td><td>The address to fetch from. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>val</em>&nbsp;</td><td>A pointer where the value of the register is to be copied. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>buf</em>&nbsp;</td><td>A pointer to where the name of the register should be copied. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>bufsiz</em>&nbsp;</td><td>The maximum size of the the buf string. </td></tr>
</table>
</dl>
<p>Definition at line <a class="el" href="memory_8c-source.html#l00322">322</a> of file <a class="el" href="memory_8c-source.html">memory.c</a>.</p>
<p>References <a class="el" href="device_8c-source.html#l00161">vdev_read()</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l00723">avr_core_io_display_names()</a>.</p>
</div>
</div><p>
<a class="anchor" name="4d727abdd19adeb472009cd9938886d4"></a><!-- doxytag: member="memory.c::mem_dump_core" ref="4d727abdd19adeb472009cd9938886d4" args="(Memory *mem, FILE *f_core)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void mem_dump_core </td>
<td>(</td>
<td class="paramtype">Memory *&nbsp;</td>
<td class="paramname"> <em>mem</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">FILE *&nbsp;</td>
<td class="paramname"> <em>f_core</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Dump all the various memory locations to a file descriptor in text format.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>mem</em>&nbsp;</td><td>A memory object. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>f_core</em>&nbsp;</td><td>An open file descriptor. </td></tr>
</table>
</dl>
<p>Definition at line <a class="el" href="memory_8c-source.html#l00483">483</a> of file <a class="el" href="memory_8c-source.html">memory.c</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l01284">avr_core_dump_core()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,42 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1><a class="anchor" name="memory_management">Memory Management </a></h1><p>
Every program ever written has had to deal with memory management. Simulavr is no exception. For portability and to potentially aid in memory debugging, simulavr supplies it's own functions and macros for handling the allocation and releasing of memory resources.<p>
For memory which could be used by many differing parts of the simulator, an object referencing system has been implemented (see <a class="el" href="object_system.html">Objects</a>).<h2><a class="anchor" name="memory_functions">
Memory Functions</a></h2>
<p>
The following functions provide wrappers for all library functions that return memory which simulavr must manage.<p>
<ul>
<li><a class="el" href="avrmalloc_8c.html#26b696030eced4eab8f5ec6cf2fb5781" title="Allocate memory and initialize to zero.">avr_malloc()</a></li><li><a class="el" href="avrmalloc_8c.html#4726a1eed41cbd3b6df7e5f035812683" title="Allocate memory and initialize to zero.">avr_malloc0()</a></li><li><a class="el" href="avrmalloc_8c.html#258e72f96d28a713d6f0d7d4e4e37d26" title="Wrapper for realloc(). x Resizes and possibly allocates more memory for an existing...">avr_realloc()</a></li><li><a class="el" href="avrmalloc_8c.html#2af0d2ad3de670228794080e914120ea" title="Wrapper for strdup().">avr_strdup()</a></li><li><a class="el" href="avrmalloc_8c.html#082a9d6d40f5e8bad64441ad950ec12c" title="Free malloc&#39;d memory.">avr_free()</a></li></ul>
<p>
All functions which return allocated memory will only return if the allocation was successful. If the allocation failed, an error message is issued and the program is aborted. Thus, the developer does not need write any code to check the returned value.<h2><a class="anchor" name="memory_macros">
Memory Macros</a></h2>
<p>
The following C-preprocessor macro definitions are provided for convenience and should be used instead of the underlying functions. These macros relieve the programmer from having to perform manual type-casting thus making the code easier to read.<p>
<ul>
<li><a class="el" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new()</a></li><li><a class="el" href="avrmalloc_8c.html#ac6d810b48b67b90412badbd4b71f4e3" title="Macro for allocating memory and initializing it to zero.">avr_new0()</a></li><li><a class="el" href="avrmalloc_8c.html#2bff90bec7ab1eafa9e1a51d618446e9" title="Macro for allocating memory.">avr_renew()</a> </li></ul>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,199 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1><a class="anchor" name="object_system">Objects </a></h1><p>
Simulavr uses a simple object oriented system for handling the data structure creation and destruction. Since simulavr is written in C, a class system must be manually implemented and the basis for this class system is the AvrClass structure. All higher level structures are ultimately based on the AvrClass structure.<p>
How the AvrClass structure is defined is not as import as how it is used as a base or parent class structure. A concrete example of simulavr's object system will be discussed (see <a class="el" href="object_system.html#example_derived_class">Derived Class Example</a>), but before jumping into the example, the AvrClass method functions will be introduced.<h2><a class="anchor" name="avrclass">
AvrClass Methods</a></h2>
The following functions provide the user interfaces to the AvrClass structure.<p>
<ul>
<li><a class="el" href="avrclass_8c.html#d07c51bd8c81db78fab8d240fd698024" title="This function should never be used.">class_new()</a></li><li><a class="el" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e" title="Initializes the AvrClass data structure.">class_construct()</a></li><li><a class="el" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5" title="Releases resources allocated by class&#39;s &lt;klass&gt;_new() function.">class_destroy()</a></li><li><a class="el" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy()</a></li><li><a class="el" href="avrclass_8c.html#ff0f5b14bf2740f208041d515f3ba93f" title="Increments the reference count for the klass object.">class_ref()</a></li><li><a class="el" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref()</a></li></ul>
<p>
All classes must provide their own creation function, &lt;klass&gt;_new(). The purpose of the creation function is to:<p>
<ul>
<li>Allocate memory for the class's data structure.</li><li>Call <a class="el" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy()</a> to install the class's own destroy method.</li><li>Call the class's constructor method to fill in the data structure information.</li></ul>
<h2><a class="anchor" name="example_derived_class">
Derived Class Example</a></h2>
<p>
Simulavr's inheritance mechanism is a little more complicated than that of C++, but is still relatively easy to use once it is understood. An example should make it clear how the system works.<p>
First we need to create some objects. Assume that we need to add two new objects to simulavr, <code>foo</code> and <code>bar</code>. To keep things simple, they are both integers. Another requirement is that any time we need to access a <code>foo</code>, we'll also need to access a <code>bar</code>, but sometimes we only need a <code>bar</code> without a <code>foo</code>. Thus, we will have a class hierarchy <code>FooClass-&gt;BarClass-&gt;AvrClass</code>, or <code>FooClass</code> derives from <code>BarClass</code> which derives from <code>AvrClass</code>. To achieve this, we create the following two data structures:<p>
<div class="fragment"><pre class="fragment"><span class="comment">// Define BarClass with AvrClass as parent </span>
<span class="keyword">typedef</span> <span class="keyword">struct </span>_BarClass BarClass;
<span class="keyword">struct </span>_BarClass {
AvrClass parent;
<span class="keywordtype">int</span> bar;
};
<span class="comment">// Define FooClass with BarClass as parent </span>
<span class="keyword">typedef</span> <span class="keyword">struct </span>_FooClass FooClass;
<span class="keyword">struct </span>_FooClass {
BarClass parent;
<span class="keywordtype">int</span> foo;
};
</pre></div><p>
Notice that in both struct definitions, the parent element is not a pointer. When you allocate memory for a <code>BarClass</code>, you automatically allocate memory for an <code>AvrClass</code> at the same time. It's important that the parent is always the first element of any derived class structure.<p>
The trick here is that once we have a class object, we can get at any object in it's class hierarchy with a simple type-cast.<p>
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> func( <span class="keywordtype">void</span> )
{
<span class="keywordtype">int</span> num;
FooClass *Foo = foo_new( 12, 21 );
<span class="comment">// get foo from FooClass </span>
num = Foo-&gt;foo;
<span class="comment">// get bar from BarClass </span>
num = ((BarClass *)Foo)-&gt;bar;
<a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a>( (AvrClass *)Foo );
}
</pre></div><p>
Although the example above works, it assumes that the programmer knows what the <code>FooClass</code> and <code>BarClass</code> structures look like. The programmer has broken the encapsulation of both <code>FooClass</code> and <code>BarClass</code> objects. To solve this problem, we need to write method functions for both classes.<p>
Here's the methods for <code>BarClass:</code> <p>
<div class="fragment"><pre class="fragment"><span class="comment">// BarClass allocator </span>
BarClass *bar_new( <span class="keywordtype">int</span> bar )
{
BarClass *bc;
bc = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a>( BarClass, 1 );
bar_construct( bc, bar );
<a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a>( (AvrClass *)bc, bar_destroy );
<span class="keywordflow">return</span> bc;
}
<span class="comment">// BarClass constructor </span>
<span class="keywordtype">void</span> bar_construct( BarClass *bc, <span class="keywordtype">int</span> bar )
{
<a class="code" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e" title="Initializes the AvrClass data structure.">class_construct</a>( (AvrClass *)bc );
bc-&gt;bar = bar;
}
<span class="comment">// BarClass destructor </span>
<span class="keywordtype">void</span> bar_destroy( <span class="keywordtype">void</span> *bc )
{
<span class="keywordflow">if</span> (bc == NULL)
<span class="keywordflow">return</span>;
<a class="code" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5" title="Releases resources allocated by class&amp;#39;s &amp;lt;klass&amp;gt;_new() function.">class_destroy</a>( bc );
}
<span class="comment">// BarClass public data access methods </span>
<span class="keywordtype">int</span> bar_get_bar( BarClass *bc ) { <span class="keywordflow">return</span> bc-&gt;bar; }
<span class="keywordtype">void</span> bar_set_bar( BarClass *bc, <span class="keywordtype">int</span> val ) { bc-&gt;bar = val; }
</pre></div><p>
And here's the methods for <code>FooClass:</code> <p>
<div class="fragment"><pre class="fragment"><span class="comment">// FooClass allocator </span>
FooClass *foo_new( <span class="keywordtype">int</span> foo, <span class="keywordtype">int</span> bar )
{
FooClass *fc;
fc = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a>( FooClass, 1 );
foo_construct( fc, foo, bar );
<a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a>( (AvrClass *)fc, foo_destroy );
<span class="keywordflow">return</span> fc;
}
<span class="comment">// FooClass constructor </span>
<span class="keywordtype">void</span> foo_construct( FooClass *fc, <span class="keywordtype">int</span> foo, bar )
{
bar_construct( (BarClass *)fc, bar );
fc-&gt;foo = foo;
}
<span class="comment">// FooClass destructor </span>
<span class="keywordtype">void</span> foo_destroy( <span class="keywordtype">void</span> *fc )
{
<span class="keywordflow">if</span> (fc == NULL)
<span class="keywordflow">return</span>;
<a class="code" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5" title="Releases resources allocated by class&amp;#39;s &amp;lt;klass&amp;gt;_new() function.">class_destroy</a>( fc );
}
<span class="comment">// FooClass public data access methods </span>
<span class="keywordtype">int</span> foo_get_foo( FooClass *fc ) { <span class="keywordflow">return</span> fc-&gt;foo; }
<span class="keywordtype">void</span> foo_set_foo( FooClass *fc, <span class="keywordtype">int</span> val ) { fc-&gt;foo = val; }
<span class="keywordtype">int</span> foo_get_bar( FooClass *fc )
{
<span class="keywordflow">return</span> bar_get_bar( (BarClass *)fc );
}
<span class="keywordtype">void</span> foo_set_bar( FooClass *fc, <span class="keywordtype">int</span> val )
{
bar_set_bar( (BarClass *)fc, val );
}
</pre></div><p>
Take a good look at the <code>*_new</code>(), <code>*_construct</code>() and <code>*_destroy</code>() functions in the above examples and make sure you understand what's going on. Of particluar importance is how the constructor and destructor functions are chained up along the various classes. This pattern is used extensively throughout the simulavr source code and once understood, makes some complicated concepts incredibly easy to implement.<p>
Now that we have the method functions, we can rewrite our original example function without the broken encapsulation.<p>
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> func( <span class="keywordtype">void</span> )
{
<span class="keywordtype">int</span> num;
FooClass *Foo = foo_new( 12, 21 );
num = foo_get_foo( Foo );
num = foo_get_bar( Foo );
<a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a>( (AvrClass *)Foo );
}
</pre></div><p>
Now that's better, but you might think that we are breaking encapsulation when we cast <code>Foo</code> to <code>AvrClass</code>. Well, in a way we are, but since <em>all</em> class objects <em>must</em> be derived from <code>AvrClass</code> either directly or indirectly, this is acceptable.<h2><a class="anchor" name="object_refencing">
Object Referencing</a></h2>
<p>
You may have noticed by this point that we haven't called <a class="el" href="avrmalloc_8c.html#082a9d6d40f5e8bad64441ad950ec12c" title="Free malloc&#39;d memory.">avr_free()</a> to free the memory we allocated for our objects. We called <a class="el" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref()</a> instead. This mechanism allows us to store many references to a single object without having to keep track of all of them.<p>
The only thing we must do when we store a reference to an object in a new variable, is call <a class="el" href="avrclass_8c.html#ff0f5b14bf2740f208041d515f3ba93f" title="Increments the reference count for the klass object.">class_ref()</a> on the object. Then, when that stored reference is no longer needed, we simply call <a class="el" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref()</a> on the object. Once the reference count reaches zero, the object's destroy method is automatically called for us. The only hard part for us is knowing when to ref and unref the object.<p>
Here's an example from the simulavr code for callbacks:<p>
<div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> callback_construct( CallBack *cb,
CallBack_FP func,
AvrClass *data )
{
<span class="keywordflow">if</span> (cb == NULL)
<a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a>( <span class="stringliteral">"passed null ptr"</span>);
<a class="code" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e" title="Initializes the AvrClass data structure.">class_construct</a>( (AvrClass *)cb );
cb-&gt;func = func;
cb-&gt;data = data;
<a class="code" href="avrclass_8c.html#ff0f5b14bf2740f208041d515f3ba93f" title="Increments the reference count for the klass object.">class_ref</a>( data );
}
<span class="keywordtype">void</span> callback_destroy( <span class="keywordtype">void</span> *cb )
{
CallBack *_cb = (CallBack *)cb;
<span class="keywordflow">if</span> (cb == NULL)
<span class="keywordflow">return</span>;
<a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a>( _cb-&gt;data );
<a class="code" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5" title="Releases resources allocated by class&amp;#39;s &amp;lt;klass&amp;gt;_new() function.">class_destroy</a>( cb );
}
</pre></div><p>
Notice that <code>data</code> is a pointer to <code>AvrClass</code> and thus can be any class defined by simulavr. <code>CallBack</code> is another class which happens to store a reference to <code>data</code> and must therefore call <a class="el" href="avrclass_8c.html#ff0f5b14bf2740f208041d515f3ba93f" title="Increments the reference count for the klass object.">class_ref()</a> on the <code>data</code> object. When the callback is destroyed (because the reference count reached zero), the callback destroy method calls <a class="el" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref()</a> on the <code>data</code> object. It is assumed that the original reference to <code>data</code> still exists when the callback is created, but may or may not exist when the callback is destroyed. </div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,190 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>op_names.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: op_names.c,v 1.5 2003/12/01 09:10:15 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025
<a name="l00026"></a>00026 <span class="preprocessor">#include "op_names.h"</span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="comment">/*</span>
<a name="l00029"></a>00029 <span class="comment"> * Define a global array of opcode Name strings.</span>
<a name="l00030"></a>00030 <span class="comment"> */</span>
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="comment">/* *INDENT-OFF */</span>
<a name="l00033"></a>00033 <span class="keywordtype">char</span> *global_opcode_name[NUM_OPCODE_HANLDERS] = {
<a name="l00034"></a>00034 <span class="comment">/* opcodes with no operands */</span>
<a name="l00035"></a>00035 <span class="stringliteral">"BREAK"</span>, <span class="comment">/* 0x9598 - 1001 0101 1001 1000 | BREAK */</span>
<a name="l00036"></a>00036 <span class="stringliteral">"EICALL"</span>, <span class="comment">/* 0x9519 - 1001 0101 0001 1001 | EICALL */</span>
<a name="l00037"></a>00037 <span class="stringliteral">"EIJMP"</span>, <span class="comment">/* 0x9419 - 1001 0100 0001 1001 | EIJMP */</span>
<a name="l00038"></a>00038 <span class="stringliteral">"ELPM"</span>, <span class="comment">/* 0x95D8 - 1001 0101 1101 1000 | ELPM */</span>
<a name="l00039"></a>00039 <span class="stringliteral">"ESPM"</span>, <span class="comment">/* 0x95F8 - 1001 0101 1111 1000 | ESPM */</span>
<a name="l00040"></a>00040 <span class="stringliteral">"ICALL"</span>, <span class="comment">/* 0x9509 - 1001 0101 0000 1001 | ICALL */</span>
<a name="l00041"></a>00041 <span class="stringliteral">"IJMP"</span>, <span class="comment">/* 0x9409 - 1001 0100 0000 1001 | IJMP */</span>
<a name="l00042"></a>00042 <span class="stringliteral">"LPM"</span>, <span class="comment">/* 0x95C8 - 1001 0101 1100 1000 | LPM */</span>
<a name="l00043"></a>00043 <span class="stringliteral">"NOP"</span>, <span class="comment">/* 0x0000 - 0000 0000 0000 0000 | NOP */</span>
<a name="l00044"></a>00044 <span class="stringliteral">"RET"</span>, <span class="comment">/* 0x9508 - 1001 0101 0000 1000 | RET */</span>
<a name="l00045"></a>00045 <span class="stringliteral">"RETI"</span>, <span class="comment">/* 0x9518 - 1001 0101 0001 1000 | RETI */</span>
<a name="l00046"></a>00046 <span class="stringliteral">"SLEEP"</span>, <span class="comment">/* 0x9588 - 1001 0101 1000 1000 | SLEEP */</span>
<a name="l00047"></a>00047 <span class="stringliteral">"SPM"</span>, <span class="comment">/* 0x95E8 - 1001 0101 1110 1000 | SPM */</span>
<a name="l00048"></a>00048 <span class="stringliteral">"WDR"</span>, <span class="comment">/* 0x95A8 - 1001 0101 1010 1000 | WDR */</span>
<a name="l00049"></a>00049
<a name="l00050"></a>00050 <span class="comment">/* opcode with a single register (Rd) as operand */</span>
<a name="l00051"></a>00051 <span class="stringliteral">"ASR"</span>, <span class="comment">/* 0x9405 - 1001 010d dddd 0101 | ASR */</span>
<a name="l00052"></a>00052 <span class="stringliteral">"COM"</span>, <span class="comment">/* 0x9400 - 1001 010d dddd 0000 | COM */</span>
<a name="l00053"></a>00053 <span class="stringliteral">"DEC"</span>, <span class="comment">/* 0x940A - 1001 010d dddd 1010 | DEC */</span>
<a name="l00054"></a>00054 <span class="stringliteral">"ELPM_Z"</span>, <span class="comment">/* 0x9006 - 1001 000d dddd 0110 | ELPM */</span>
<a name="l00055"></a>00055 <span class="stringliteral">"ELPM_Z_incr"</span>, <span class="comment">/* 0x9007 - 1001 000d dddd 0111 | ELPM */</span>
<a name="l00056"></a>00056 <span class="stringliteral">"INC"</span>, <span class="comment">/* 0x9403 - 1001 010d dddd 0011 | INC */</span>
<a name="l00057"></a>00057 <span class="stringliteral">"LDS"</span>, <span class="comment">/* 0x9000 - 1001 000d dddd 0000 | LDS */</span>
<a name="l00058"></a>00058 <span class="stringliteral">"LD_X"</span>, <span class="comment">/* 0x900C - 1001 000d dddd 1100 | LD */</span>
<a name="l00059"></a>00059 <span class="stringliteral">"LD_X_decr"</span>, <span class="comment">/* 0x900E - 1001 000d dddd 1110 | LD */</span>
<a name="l00060"></a>00060 <span class="stringliteral">"LD_X_incr"</span>, <span class="comment">/* 0x900D - 1001 000d dddd 1101 | LD */</span>
<a name="l00061"></a>00061 <span class="stringliteral">"LD_Y_decr"</span>, <span class="comment">/* 0x900A - 1001 000d dddd 1010 | LD */</span>
<a name="l00062"></a>00062 <span class="stringliteral">"LD_Y_incr"</span>, <span class="comment">/* 0x9009 - 1001 000d dddd 1001 | LD */</span>
<a name="l00063"></a>00063 <span class="stringliteral">"LD_Z_decr"</span>, <span class="comment">/* 0x9002 - 1001 000d dddd 0010 | LD */</span>
<a name="l00064"></a>00064 <span class="stringliteral">"LD_Z_incr"</span>, <span class="comment">/* 0x9001 - 1001 000d dddd 0001 | LD */</span>
<a name="l00065"></a>00065 <span class="stringliteral">"LPM_Z"</span>, <span class="comment">/* 0x9004 - 1001 000d dddd 0100 | LPM */</span>
<a name="l00066"></a>00066 <span class="stringliteral">"LPM_Z_incr"</span>, <span class="comment">/* 0x9005 - 1001 000d dddd 0101 | LPM */</span>
<a name="l00067"></a>00067 <span class="stringliteral">"LSR"</span>, <span class="comment">/* 0x9406 - 1001 010d dddd 0110 | LSR */</span>
<a name="l00068"></a>00068 <span class="stringliteral">"NEG"</span>, <span class="comment">/* 0x9401 - 1001 010d dddd 0001 | NEG */</span>
<a name="l00069"></a>00069 <span class="stringliteral">"POP"</span>, <span class="comment">/* 0x900F - 1001 000d dddd 1111 | POP */</span>
<a name="l00070"></a>00070 <span class="stringliteral">"PUSH"</span>, <span class="comment">/* 0x920F - 1001 001d dddd 1111 | PUSH */</span>
<a name="l00071"></a>00071 <span class="stringliteral">"ROR"</span>, <span class="comment">/* 0x9407 - 1001 010d dddd 0111 | ROR */</span>
<a name="l00072"></a>00072 <span class="stringliteral">"STS"</span>, <span class="comment">/* 0x9200 - 1001 001d dddd 0000 | STS */</span>
<a name="l00073"></a>00073 <span class="stringliteral">"ST_X"</span>, <span class="comment">/* 0x920C - 1001 001d dddd 1100 | ST */</span>
<a name="l00074"></a>00074 <span class="stringliteral">"ST_X_decr"</span>, <span class="comment">/* 0x920E - 1001 001d dddd 1110 | ST */</span>
<a name="l00075"></a>00075 <span class="stringliteral">"ST_X_incr"</span>, <span class="comment">/* 0x920D - 1001 001d dddd 1101 | ST */</span>
<a name="l00076"></a>00076 <span class="stringliteral">"ST_Y_decr"</span>, <span class="comment">/* 0x920A - 1001 001d dddd 1010 | ST */</span>
<a name="l00077"></a>00077 <span class="stringliteral">"ST_Y_incr"</span>, <span class="comment">/* 0x9209 - 1001 001d dddd 1001 | ST */</span>
<a name="l00078"></a>00078 <span class="stringliteral">"ST_Z_decr"</span>, <span class="comment">/* 0x9202 - 1001 001d dddd 0010 | ST */</span>
<a name="l00079"></a>00079 <span class="stringliteral">"ST_Z_incr"</span>, <span class="comment">/* 0x9201 - 1001 001d dddd 0001 | ST */</span>
<a name="l00080"></a>00080 <span class="stringliteral">"SWAP"</span>, <span class="comment">/* 0x9402 - 1001 010d dddd 0010 | SWAP */</span>
<a name="l00081"></a>00081
<a name="l00082"></a>00082 <span class="comment">/* opcodes with two 5-bit register (Rd and Rr) operands */</span>
<a name="l00083"></a>00083 <span class="stringliteral">"ADC"</span>, <span class="comment">/* 0x1C00 - 0001 11rd dddd rrrr | ADC or ROL */</span>
<a name="l00084"></a>00084 <span class="stringliteral">"ADD"</span>, <span class="comment">/* 0x0C00 - 0000 11rd dddd rrrr | ADD or LSL */</span>
<a name="l00085"></a>00085 <span class="stringliteral">"AND"</span>, <span class="comment">/* 0x2000 - 0010 00rd dddd rrrr | AND or TST</span>
<a name="l00086"></a>00086 <span class="comment"> or LSL */</span>
<a name="l00087"></a>00087 <span class="stringliteral">"CP"</span>, <span class="comment">/* 0x1400 - 0001 01rd dddd rrrr | CP */</span>
<a name="l00088"></a>00088 <span class="stringliteral">"CPC"</span>, <span class="comment">/* 0x0400 - 0000 01rd dddd rrrr | CPC */</span>
<a name="l00089"></a>00089 <span class="stringliteral">"CPSE"</span>, <span class="comment">/* 0x1000 - 0001 00rd dddd rrrr | CPSE */</span>
<a name="l00090"></a>00090 <span class="stringliteral">"EOR"</span>, <span class="comment">/* 0x2400 - 0010 01rd dddd rrrr | EOR or CLR */</span>
<a name="l00091"></a>00091 <span class="stringliteral">"MOV"</span>, <span class="comment">/* 0x2C00 - 0010 11rd dddd rrrr | MOV */</span>
<a name="l00092"></a>00092 <span class="stringliteral">"MUL"</span>, <span class="comment">/* 0x9C00 - 1001 11rd dddd rrrr | MUL */</span>
<a name="l00093"></a>00093 <span class="stringliteral">"OR"</span>, <span class="comment">/* 0x2800 - 0010 10rd dddd rrrr | OR */</span>
<a name="l00094"></a>00094 <span class="stringliteral">"SBC"</span>, <span class="comment">/* 0x0800 - 0000 10rd dddd rrrr | SBC */</span>
<a name="l00095"></a>00095 <span class="stringliteral">"SUB"</span>, <span class="comment">/* 0x1800 - 0001 10rd dddd rrrr | SUB */</span>
<a name="l00096"></a>00096
<a name="l00097"></a>00097 <span class="comment">/* opcodes with two 4-bit register (Rd and Rr) operands */</span>
<a name="l00098"></a>00098 <span class="stringliteral">"MOVW"</span>, <span class="comment">/* 0x0100 - 0000 0001 dddd rrrr | MOVW */</span>
<a name="l00099"></a>00099 <span class="stringliteral">"MULS"</span>, <span class="comment">/* 0x0200 - 0000 0010 dddd rrrr | MULS */</span>
<a name="l00100"></a>00100 <span class="stringliteral">"MULSU"</span>, <span class="comment">/* 0x0300 - 0000 0011 dddd rrrr | MULSU */</span>
<a name="l00101"></a>00101
<a name="l00102"></a>00102 <span class="comment">/* opcodes with two 3-bit register (Rd and Rr) operands */</span>
<a name="l00103"></a>00103 <span class="stringliteral">"FMUL"</span>, <span class="comment">/* 0x0308 - 0000 0011 0ddd 1rrr | FMUL */</span>
<a name="l00104"></a>00104 <span class="stringliteral">"FMULS"</span>, <span class="comment">/* 0x0380 - 0000 0011 1ddd 0rrr | FMULS */</span>
<a name="l00105"></a>00105 <span class="stringliteral">"FMULSU"</span>, <span class="comment">/* 0x0388 - 0000 0011 1ddd 1rrr | FMULSU */</span>
<a name="l00106"></a>00106
<a name="l00107"></a>00107 <span class="comment">/* opcodes with a register (Rd) and a constant data (K) as operands */</span>
<a name="l00108"></a>00108 <span class="stringliteral">"ANDI"</span>, <span class="comment">/* 0x7000 - 0111 KKKK dddd KKKK | CBR or</span>
<a name="l00109"></a>00109 <span class="comment"> ANDI */</span>
<a name="l00110"></a>00110 <span class="stringliteral">"CPI"</span>, <span class="comment">/* 0x3000 - 0011 KKKK dddd KKKK | CPI */</span>
<a name="l00111"></a>00111 <span class="stringliteral">"LDI"</span>, <span class="comment">/* 0xE000 - 1110 KKKK dddd KKKK | LDI */</span>
<a name="l00112"></a>00112 <span class="stringliteral">"ORI"</span>, <span class="comment">/* 0x6000 - 0110 KKKK dddd KKKK | SBR or ORI */</span>
<a name="l00113"></a>00113 <span class="stringliteral">"SBCI"</span>, <span class="comment">/* 0x4000 - 0100 KKKK dddd KKKK | SBCI */</span>
<a name="l00114"></a>00114 <span class="stringliteral">"SUBI"</span>, <span class="comment">/* 0x5000 - 0101 KKKK dddd KKKK | SUBI */</span>
<a name="l00115"></a>00115
<a name="l00116"></a>00116 <span class="comment">/* opcodes with a register (Rd) and a register bit number (b) as</span>
<a name="l00117"></a>00117 <span class="comment"> operands */</span>
<a name="l00118"></a>00118 <span class="stringliteral">"BLD"</span>, <span class="comment">/* 0xF800 - 1111 100d dddd 0bbb | BLD */</span>
<a name="l00119"></a>00119 <span class="stringliteral">"BST"</span>, <span class="comment">/* 0xFA00 - 1111 101d dddd 0bbb | BST */</span>
<a name="l00120"></a>00120 <span class="stringliteral">"SBRC"</span>, <span class="comment">/* 0xFC00 - 1111 110d dddd 0bbb | SBRC */</span>
<a name="l00121"></a>00121 <span class="stringliteral">"SBRS"</span>, <span class="comment">/* 0xFE00 - 1111 111d dddd 0bbb | SBRS */</span>
<a name="l00122"></a>00122
<a name="l00123"></a>00123 <span class="comment">/* opcodes with a relative 7-bit address (k) and a register bit number (b)</span>
<a name="l00124"></a>00124 <span class="comment"> as operands */</span>
<a name="l00125"></a>00125 <span class="stringliteral">"BRBC"</span>, <span class="comment">/* 0xF400 - 1111 01kk kkkk kbbb | BRBC */</span>
<a name="l00126"></a>00126 <span class="stringliteral">"BRBS"</span>, <span class="comment">/* 0xF000 - 1111 00kk kkkk kbbb | BRBS */</span>
<a name="l00127"></a>00127
<a name="l00128"></a>00128 <span class="comment">/* opcodes with a 6-bit address displacement (q) and a register (Rd) as</span>
<a name="l00129"></a>00129 <span class="comment"> operands */</span>
<a name="l00130"></a>00130 <span class="stringliteral">"LDD_Y"</span>, <span class="comment">/* 0x8008 - 10q0 qq0d dddd 1qqq | LDD */</span>
<a name="l00131"></a>00131 <span class="stringliteral">"LDD_Z"</span>, <span class="comment">/* 0x8000 - 10q0 qq0d dddd 0qqq | LDD */</span>
<a name="l00132"></a>00132 <span class="stringliteral">"STD_Y"</span>, <span class="comment">/* 0x8208 - 10q0 qq1d dddd 1qqq | STD */</span>
<a name="l00133"></a>00133 <span class="stringliteral">"STD_Z"</span>, <span class="comment">/* 0x8200 - 10q0 qq1d dddd 0qqq | STD */</span>
<a name="l00134"></a>00134
<a name="l00135"></a>00135 <span class="comment">/* opcodes with a absolute 22-bit address (k) operand */</span>
<a name="l00136"></a>00136 <span class="stringliteral">"CALL"</span>, <span class="comment">/* 0x940E - 1001 010k kkkk 111k | CALL */</span>
<a name="l00137"></a>00137 <span class="stringliteral">"JMP"</span>, <span class="comment">/* 0x940C - 1001 010k kkkk 110k | JMP */</span>
<a name="l00138"></a>00138
<a name="l00139"></a>00139 <span class="comment">/* opcode with a sreg bit select (s) operand */</span>
<a name="l00140"></a>00140 <span class="stringliteral">"BCLR"</span>, <span class="comment">/* 0x9488 - 1001 0100 1sss 1000 | BCLR or</span>
<a name="l00141"></a>00141 <span class="comment"> CL{C,Z,N,V,S,H,T,I} */</span>
<a name="l00142"></a>00142 <span class="stringliteral">"BSET"</span>, <span class="comment">/* 0x9408 - 1001 0100 0sss 1000 | BSET or</span>
<a name="l00143"></a>00143 <span class="comment"> SE{C,Z,N,V,S,H,T,I} */</span>
<a name="l00144"></a>00144
<a name="l00145"></a>00145 <span class="comment">/* opcodes with a 6-bit constant (K) and a register (Rd) as operands */</span>
<a name="l00146"></a>00146 <span class="stringliteral">"ADIW"</span>, <span class="comment">/* 0x9600 - 1001 0110 KKdd KKKK | ADIW */</span>
<a name="l00147"></a>00147 <span class="stringliteral">"SBIW"</span>, <span class="comment">/* 0x9700 - 1001 0111 KKdd KKKK | SBIW */</span>
<a name="l00148"></a>00148
<a name="l00149"></a>00149 <span class="comment">/* opcodes with a 5-bit IO Addr (A) and register bit number (b) as</span>
<a name="l00150"></a>00150 <span class="comment"> operands */</span>
<a name="l00151"></a>00151 <span class="stringliteral">"CBI"</span>, <span class="comment">/* 0x9800 - 1001 1000 AAAA Abbb | CBI */</span>
<a name="l00152"></a>00152 <span class="stringliteral">"SBI"</span>, <span class="comment">/* 0x9A00 - 1001 1010 AAAA Abbb | SBI */</span>
<a name="l00153"></a>00153 <span class="stringliteral">"SBIC"</span>, <span class="comment">/* 0x9900 - 1001 1001 AAAA Abbb | SBIC */</span>
<a name="l00154"></a>00154 <span class="stringliteral">"SBIS"</span>, <span class="comment">/* 0x9B00 - 1001 1011 AAAA Abbb | SBIS */</span>
<a name="l00155"></a>00155
<a name="l00156"></a>00156 <span class="comment">/* opcodes with a 6-bit IO Addr (A) and register (Rd) as operands */</span>
<a name="l00157"></a>00157 <span class="stringliteral">"IN"</span>, <span class="comment">/* 0xB000 - 1011 0AAd dddd AAAA | IN */</span>
<a name="l00158"></a>00158 <span class="stringliteral">"OUT"</span>, <span class="comment">/* 0xB800 - 1011 1AAd dddd AAAA | OUT */</span>
<a name="l00159"></a>00159
<a name="l00160"></a>00160 <span class="comment">/* opcodes with a relative 12-bit address (k) operand */</span>
<a name="l00161"></a>00161 <span class="stringliteral">"RCALL"</span>, <span class="comment">/* 0xD000 - 1101 kkkk kkkk kkkk | RCALL */</span>
<a name="l00162"></a>00162 <span class="stringliteral">"RJMP"</span> <span class="comment">/* 0xC000 - 1100 kkkk kkkk kkkk | RJMP */</span>
<a name="l00163"></a>00163 };
<a name="l00164"></a>00164
<a name="l00165"></a>00165 <span class="comment">/* *INDENT-ON */</span>
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,47 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li class="current"><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>Related Pages</h1>Here is a list of all related documentation pages:<ul>
<li><a class="el" href="memory_management.html">Memory Management</a>
<li><a class="el" href="object_system.html">Objects</a>
<li><a class="el" href="insn_decoder.html">Instruction Decoder</a>
<li><a class="el" href="interrupts.html">Interrupts</a>
<li><a class="el" href="virtual_devs.html">Virtual Devices</a>
<li><a class="el" href="ext_devs.html">External Devices</a>
<li><a class="el" href="break_watch_pts.html">Breakpoints and Watchpoints</a>
<li><a class="el" href="todo.html">Todo List</a>
<li><a class="el" href="deprecated.html">Deprecated List</a>
</ul>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,364 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>ports.c</h1><a href="ports_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: ports.c,v 1.17 2004/01/30 07:09:56 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003, 2004 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/**</span>
<a name="l00027"></a>00027 <span class="comment"> * \file ports.c</span>
<a name="l00028"></a>00028 <span class="comment"> * \brief Module for accessing simulated I/O ports.</span>
<a name="l00029"></a>00029 <span class="comment"> *</span>
<a name="l00030"></a>00030 <span class="comment"> * Defines an abstract Port class as well as subclasses for each individual</span>
<a name="l00031"></a>00031 <span class="comment"> * port.</span>
<a name="l00032"></a>00032 <span class="comment"> *</span>
<a name="l00033"></a>00033 <span class="comment"> * \todo Remove the pins argument and the mask field. That's handled at a</span>
<a name="l00034"></a>00034 <span class="comment"> * higher level so is obsolete here now.</span>
<a name="l00035"></a>00035 <span class="comment"> */</span>
<a name="l00036"></a>00036
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00038"></a>00038
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00042"></a>00042
<a name="l00043"></a>00043 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include "utils.h"</span>
<a name="l00047"></a>00047 <span class="preprocessor">#include "callback.h"</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include "op_names.h"</span>
<a name="l00049"></a>00049
<a name="l00050"></a>00050 <span class="preprocessor">#include "storage.h"</span>
<a name="l00051"></a>00051 <span class="preprocessor">#include "flash.h"</span>
<a name="l00052"></a>00052
<a name="l00053"></a>00053 <span class="preprocessor">#include "vdevs.h"</span>
<a name="l00054"></a>00054 <span class="preprocessor">#include "memory.h"</span>
<a name="l00055"></a>00055 <span class="preprocessor">#include "stack.h"</span>
<a name="l00056"></a>00056 <span class="preprocessor">#include "register.h"</span>
<a name="l00057"></a>00057 <span class="preprocessor">#include "sram.h"</span>
<a name="l00058"></a>00058 <span class="preprocessor">#include "eeprom.h"</span>
<a name="l00059"></a>00059 <span class="preprocessor">#include "timers.h"</span>
<a name="l00060"></a>00060 <span class="preprocessor">#include "ports.h"</span>
<a name="l00061"></a>00061
<a name="l00062"></a>00062 <span class="preprocessor">#include "avrcore.h"</span>
<a name="l00063"></a>00063
<a name="l00064"></a>00064 <span class="comment">/****************************************************************************\</span>
<a name="l00065"></a>00065 <span class="comment"> *</span>
<a name="l00066"></a>00066 <span class="comment"> * Local static prototypes.</span>
<a name="l00067"></a>00067 <span class="comment"> *</span>
<a name="l00068"></a>00068 <span class="comment">\****************************************************************************/</span>
<a name="l00069"></a>00069
<a name="l00070"></a>00070 <span class="keyword">static</span> Port *port_new (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name);
<a name="l00071"></a>00071 <span class="keyword">static</span> <span class="keywordtype">void</span> port_construct (Port *p, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name);
<a name="l00072"></a>00072 <span class="keyword">static</span> <span class="keywordtype">void</span> port_destroy (<span class="keywordtype">void</span> *p);
<a name="l00073"></a>00073
<a name="l00074"></a>00074 <span class="keyword">static</span> uint8_t port_reg_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00075"></a>00075 <span class="keyword">static</span> <span class="keywordtype">void</span> port_reg_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00076"></a>00076 <span class="keyword">static</span> <span class="keywordtype">void</span> port_reset (VDevice *dev);
<a name="l00077"></a>00077
<a name="l00078"></a>00078 <span class="keyword">static</span> uint8_t port_read_pin (Port *p, <span class="keywordtype">int</span> addr);
<a name="l00079"></a>00079
<a name="l00080"></a>00080 <span class="keyword">static</span> <span class="keywordtype">void</span> port_write_port (Port *p, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00081"></a>00081
<a name="l00082"></a>00082 <span class="keyword">static</span> <span class="keywordtype">void</span> port_write_ddr (Port *p, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00083"></a>00083
<a name="l00084"></a>00084 <span class="keyword">static</span> <span class="keywordtype">void</span> port_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr,
<a name="l00085"></a>00085 <span class="keywordtype">void</span> *data);
<a name="l00086"></a>00086
<a name="l00087"></a>00087 <span class="comment">/****************************************************************************\</span>
<a name="l00088"></a>00088 <span class="comment"> *</span>
<a name="l00089"></a>00089 <span class="comment"> * Port(VDevice) : I/O Port registers</span>
<a name="l00090"></a>00090 <span class="comment"> *</span>
<a name="l00091"></a>00091 <span class="comment">\****************************************************************************/</span>
<a name="l00092"></a>00092 <span class="comment"></span>
<a name="l00093"></a>00093 <span class="comment">/**</span>
<a name="l00094"></a>00094 <span class="comment"> * \brief Create a new Port instance.</span>
<a name="l00095"></a>00095 <span class="comment"> *</span>
<a name="l00096"></a>00096 <span class="comment"> * This should only be used in DevSuppDefn initializers.</span>
<a name="l00097"></a>00097 <span class="comment"> */</span>
<a name="l00098"></a>00098
<a name="l00099"></a>00099 VDevice *
<a name="l00100"></a><a class="code" href="ports_8c.html#00826229de675b5cd869c124267b7c3b">00100</a> <a class="code" href="ports_8c.html#00826229de675b5cd869c124267b7c3b" title="Create a new Port instance.">port_create</a> (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00101"></a>00101 {
<a name="l00102"></a>00102 <span class="keywordflow">return</span> (VDevice *)port_new (addr, name);
<a name="l00103"></a>00103 }
<a name="l00104"></a>00104 <span class="comment"></span>
<a name="l00105"></a>00105 <span class="comment">/**</span>
<a name="l00106"></a>00106 <span class="comment"> * \brief Allocates a new Port object.</span>
<a name="l00107"></a>00107 <span class="comment"> */</span>
<a name="l00108"></a>00108
<a name="l00109"></a>00109 <span class="keyword">static</span> Port *
<a name="l00110"></a>00110 port_new (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name)
<a name="l00111"></a>00111 {
<a name="l00112"></a>00112 Port *p;
<a name="l00113"></a>00113
<a name="l00114"></a>00114 p = <a class="code" href="avrmalloc_8c.html#ac6d810b48b67b90412badbd4b71f4e3" title="Macro for allocating memory and initializing it to zero.">avr_new0</a> (Port, 1);
<a name="l00115"></a>00115 port_construct (p, addr, name);
<a name="l00116"></a>00116 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)p, port_destroy);
<a name="l00117"></a>00117
<a name="l00118"></a>00118 <span class="keywordflow">return</span> p;
<a name="l00119"></a>00119 }
<a name="l00120"></a>00120 <span class="comment"></span>
<a name="l00121"></a>00121 <span class="comment">/**</span>
<a name="l00122"></a>00122 <span class="comment"> * \brief Constructor for the Port object.</span>
<a name="l00123"></a>00123 <span class="comment"> */</span>
<a name="l00124"></a>00124
<a name="l00125"></a>00125 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00126"></a>00126 port_construct (Port *p, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name)
<a name="l00127"></a>00127 {
<a name="l00128"></a>00128 <span class="keywordflow">if</span> (p == NULL)
<a name="l00129"></a>00129 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00130"></a>00130
<a name="l00131"></a>00131 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)p, port_reg_read, port_reg_write, port_reset,
<a name="l00132"></a>00132 port_add_addr);
<a name="l00133"></a>00133
<a name="l00134"></a>00134 port_add_addr ((VDevice *)p, addr, name, 0, NULL);
<a name="l00135"></a>00135
<a name="l00136"></a>00136 p-&gt;ext_rd = NULL;
<a name="l00137"></a>00137 p-&gt;ext_wr = NULL;
<a name="l00138"></a>00138
<a name="l00139"></a>00139 port_reset ((VDevice *)p);
<a name="l00140"></a>00140 }
<a name="l00141"></a>00141
<a name="l00142"></a>00142 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00143"></a>00143 port_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00144"></a>00144 {
<a name="l00145"></a>00145 Port *p = (Port *)vdev;
<a name="l00146"></a>00146
<a name="l00147"></a>00147 <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"PORT"</span>, name, 4) == 0)
<a name="l00148"></a>00148 {
<a name="l00149"></a>00149 p-&gt;port_addr = addr;
<a name="l00150"></a>00150 }
<a name="l00151"></a>00151
<a name="l00152"></a>00152 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"DDR"</span>, name, 3) == 0)
<a name="l00153"></a>00153 {
<a name="l00154"></a>00154 p-&gt;ddr_addr = addr;
<a name="l00155"></a>00155 }
<a name="l00156"></a>00156
<a name="l00157"></a>00157 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"PIN"</span>, name, 3) == 0)
<a name="l00158"></a>00158 {
<a name="l00159"></a>00159 p-&gt;pin_addr = addr;
<a name="l00160"></a>00160 }
<a name="l00161"></a>00161
<a name="l00162"></a>00162 <span class="keywordflow">else</span>
<a name="l00163"></a>00163 {
<a name="l00164"></a>00164 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"invalid port register name: '%s' @ 0x%04x"</span>, name, addr);
<a name="l00165"></a>00165 }
<a name="l00166"></a>00166 }
<a name="l00167"></a>00167
<a name="l00168"></a>00168 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00169"></a>00169 port_reset (VDevice *dev)
<a name="l00170"></a>00170 {
<a name="l00171"></a>00171 Port *p = (Port *)dev;
<a name="l00172"></a>00172
<a name="l00173"></a>00173 p-&gt;port = 0;
<a name="l00174"></a>00174 p-&gt;ddr = 0;
<a name="l00175"></a>00175 p-&gt;pin = 0;
<a name="l00176"></a>00176
<a name="l00177"></a>00177 p-&gt;ext_enable = 1;
<a name="l00178"></a>00178 }
<a name="l00179"></a>00179 <span class="comment"></span>
<a name="l00180"></a>00180 <span class="comment">/**</span>
<a name="l00181"></a>00181 <span class="comment"> * \brief Destructor for the Port object</span>
<a name="l00182"></a>00182 <span class="comment"> *</span>
<a name="l00183"></a>00183 <span class="comment"> * This is a virtual method for higher level port implementations and as such</span>
<a name="l00184"></a>00184 <span class="comment"> * should not be used directly.</span>
<a name="l00185"></a>00185 <span class="comment"> */</span>
<a name="l00186"></a>00186 <span class="keywordtype">void</span>
<a name="l00187"></a>00187 port_destroy (<span class="keywordtype">void</span> *p)
<a name="l00188"></a>00188 {
<a name="l00189"></a>00189 <span class="keywordflow">if</span> (p == NULL)
<a name="l00190"></a>00190 <span class="keywordflow">return</span>;
<a name="l00191"></a>00191
<a name="l00192"></a>00192 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (p);
<a name="l00193"></a>00193 }
<a name="l00194"></a>00194 <span class="comment"></span>
<a name="l00195"></a>00195 <span class="comment">/** \brief Disable external port functionality.</span>
<a name="l00196"></a>00196 <span class="comment"> *</span>
<a name="l00197"></a>00197 <span class="comment"> * This is only used when dumping memory to core file. See mem_io_fetch().</span>
<a name="l00198"></a>00198 <span class="comment"> */</span>
<a name="l00199"></a>00199 <span class="keywordtype">void</span>
<a name="l00200"></a><a class="code" href="ports_8c.html#ebb7d0728b81651d94a98d9640d9c328">00200</a> <a class="code" href="ports_8c.html#ebb7d0728b81651d94a98d9640d9c328" title="Disable external port functionality.">port_ext_disable</a> (Port *p)
<a name="l00201"></a>00201 {
<a name="l00202"></a>00202 p-&gt;ext_enable = 0;
<a name="l00203"></a>00203 }
<a name="l00204"></a>00204 <span class="comment"></span>
<a name="l00205"></a>00205 <span class="comment">/** \brief Enable external port functionality.</span>
<a name="l00206"></a>00206 <span class="comment"> *</span>
<a name="l00207"></a>00207 <span class="comment"> * This is only used when dumping memory to core file. See mem_io_fetch().</span>
<a name="l00208"></a>00208 <span class="comment"> */</span>
<a name="l00209"></a>00209 <span class="keywordtype">void</span>
<a name="l00210"></a><a class="code" href="ports_8c.html#034de04c76c1ba1271c13edda67e83ba">00210</a> <a class="code" href="ports_8c.html#034de04c76c1ba1271c13edda67e83ba" title="Enable external port functionality.">port_ext_enable</a> (Port *p)
<a name="l00211"></a>00211 {
<a name="l00212"></a>00212 p-&gt;ext_enable = 1;
<a name="l00213"></a>00213 }
<a name="l00214"></a>00214 <span class="comment"></span>
<a name="l00215"></a>00215 <span class="comment">/**</span>
<a name="l00216"></a>00216 <span class="comment"> * \brief Attaches read and write functions to a particular port</span>
<a name="l00217"></a>00217 <span class="comment"> *</span>
<a name="l00218"></a>00218 <span class="comment"> * I think I may have this backwards. Having the virtual hardware supply</span>
<a name="l00219"></a>00219 <span class="comment"> * functions for the core to call on every io read/write, might cause missed</span>
<a name="l00220"></a>00220 <span class="comment"> * events (like edge triggered). I'm really not too sure how to handle this.</span>
<a name="l00221"></a>00221 <span class="comment"> *</span>
<a name="l00222"></a>00222 <span class="comment"> * In the future, it might be better to have the core supply a function for</span>
<a name="l00223"></a>00223 <span class="comment"> * the virtual hardware to call when data is written to the device. The device</span>
<a name="l00224"></a>00224 <span class="comment"> * supplied function could then check if an interrupt should be generated or</span>
<a name="l00225"></a>00225 <span class="comment"> * just simply write to the port data register.</span>
<a name="l00226"></a>00226 <span class="comment"> *</span>
<a name="l00227"></a>00227 <span class="comment"> * For now, leave it as is since it's easier to test if you can block when the</span>
<a name="l00228"></a>00228 <span class="comment"> * device is reading from the virtual hardware.</span>
<a name="l00229"></a>00229 <span class="comment"> */</span>
<a name="l00230"></a>00230 <span class="keywordtype">void</span>
<a name="l00231"></a><a class="code" href="ports_8c.html#4711762fbc2eb589ed9d4973df5d5a88">00231</a> <a class="code" href="ports_8c.html#4711762fbc2eb589ed9d4973df5d5a88" title="Attaches read and write functions to a particular port.">port_add_ext_rd_wr</a> (Port *p, PortFP_ExtRd ext_rd, PortFP_ExtWr ext_wr)
<a name="l00232"></a>00232 {
<a name="l00233"></a>00233 p-&gt;ext_rd = ext_rd;
<a name="l00234"></a>00234 p-&gt;ext_wr = ext_wr;
<a name="l00235"></a>00235 }
<a name="l00236"></a>00236
<a name="l00237"></a>00237 <span class="keyword">static</span> uint8_t
<a name="l00238"></a>00238 port_read_pin (Port *p, <span class="keywordtype">int</span> addr)
<a name="l00239"></a>00239 {
<a name="l00240"></a>00240 uint8_t data;
<a name="l00241"></a>00241
<a name="l00242"></a>00242 <span class="comment">/* get the data from the external virtual hardware if connected */</span>
<a name="l00243"></a>00243 <span class="keywordflow">if</span> (p-&gt;ext_rd &amp;&amp; p-&gt;ext_enable)
<a name="l00244"></a>00244 data = p-&gt;ext_rd (addr);
<a name="l00245"></a>00245 <span class="keywordflow">else</span>
<a name="l00246"></a>00246 data = 0;
<a name="l00247"></a>00247
<a name="l00248"></a>00248 <span class="comment">/*</span>
<a name="l00249"></a>00249 <span class="comment"> * For a pin n to be enabled as input, DDRn == 0,</span>
<a name="l00250"></a>00250 <span class="comment"> * otherwise it will always read 0.</span>
<a name="l00251"></a>00251 <span class="comment"> */</span>
<a name="l00252"></a>00252 data &amp;= ~(p-&gt;ddr);
<a name="l00253"></a>00253
<a name="l00254"></a>00254 <span class="comment">/*</span>
<a name="l00255"></a>00255 <span class="comment"> * Pass data to alternate read so as to check alternate functions of</span>
<a name="l00256"></a>00256 <span class="comment"> * pins for that port.</span>
<a name="l00257"></a>00257 <span class="comment"> */</span>
<a name="l00258"></a>00258 <span class="comment">/* if (p-&gt;alt_rd) */</span>
<a name="l00259"></a>00259 <span class="comment">/* data = p-&gt;alt_rd(p, addr, data); */</span>
<a name="l00260"></a>00260
<a name="l00261"></a>00261 <span class="keywordflow">return</span> data;
<a name="l00262"></a>00262 }
<a name="l00263"></a>00263
<a name="l00264"></a>00264 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00265"></a>00265 port_write_port (Port *p, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00266"></a>00266 {
<a name="l00267"></a>00267 <span class="comment">/* update port register */</span>
<a name="l00268"></a>00268 p-&gt;port = val;
<a name="l00269"></a>00269
<a name="l00270"></a>00270 <span class="comment">/*</span>
<a name="l00271"></a>00271 <span class="comment"> * Since changing p-&gt;port might change what the virtual hardware</span>
<a name="l00272"></a>00272 <span class="comment"> * sees, we need to call ext_wr() to pass change along.</span>
<a name="l00273"></a>00273 <span class="comment"> */</span>
<a name="l00274"></a>00274 <span class="keywordflow">if</span> (p-&gt;ext_wr &amp;&amp; p-&gt;ext_enable)
<a name="l00275"></a>00275 p-&gt;ext_wr (addr, (p-&gt;port &amp; p-&gt;ddr));
<a name="l00276"></a>00276 }
<a name="l00277"></a>00277
<a name="l00278"></a>00278 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00279"></a>00279 port_write_ddr (Port *p, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00280"></a>00280 {
<a name="l00281"></a>00281 <span class="comment">/* update ddr register */</span>
<a name="l00282"></a>00282 p-&gt;ddr = val;
<a name="l00283"></a>00283
<a name="l00284"></a>00284 <span class="preprocessor">#if 0</span>
<a name="l00285"></a>00285 <span class="preprocessor"></span> <span class="comment">/*</span>
<a name="l00286"></a>00286 <span class="comment"> * Since changing p-&gt;ddr might change what the virtual hardware</span>
<a name="l00287"></a>00287 <span class="comment"> * sees, we need to call ext_wr() to pass change allong.</span>
<a name="l00288"></a>00288 <span class="comment"> */</span>
<a name="l00289"></a>00289 <span class="keywordflow">if</span> (p-&gt;ext_wr &amp;&amp; p-&gt;ext_enable)
<a name="l00290"></a>00290 p-&gt;ext_wr (addr, (p-&gt;port &amp; p-&gt;ddr));
<a name="l00291"></a>00291 <span class="preprocessor">#endif</span>
<a name="l00292"></a>00292 <span class="preprocessor"></span>}
<a name="l00293"></a>00293
<a name="l00294"></a>00294 <span class="keyword">static</span> uint8_t
<a name="l00295"></a>00295 port_reg_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00296"></a>00296 {
<a name="l00297"></a>00297 Port *p = (Port *)dev;
<a name="l00298"></a>00298
<a name="l00299"></a>00299 <span class="keywordflow">if</span> (addr == p-&gt;ddr_addr)
<a name="l00300"></a>00300 <span class="keywordflow">return</span> p-&gt;ddr;
<a name="l00301"></a>00301
<a name="l00302"></a>00302 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == p-&gt;pin_addr)
<a name="l00303"></a>00303 <span class="keywordflow">return</span> port_read_pin (p, addr);
<a name="l00304"></a>00304
<a name="l00305"></a>00305 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == p-&gt;port_addr)
<a name="l00306"></a>00306 <span class="keywordflow">return</span> p-&gt;port;
<a name="l00307"></a>00307
<a name="l00308"></a>00308 <span class="keywordflow">else</span>
<a name="l00309"></a>00309 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Invalid Port Address: 0x%02x"</span>, addr);
<a name="l00310"></a>00310
<a name="l00311"></a>00311 <span class="keywordflow">return</span> 0;
<a name="l00312"></a>00312 }
<a name="l00313"></a>00313
<a name="l00314"></a>00314 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00315"></a>00315 port_reg_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00316"></a>00316 {
<a name="l00317"></a>00317 Port *p = (Port *)dev;
<a name="l00318"></a>00318
<a name="l00319"></a>00319 <span class="keywordflow">if</span> (addr == p-&gt;pin_addr)
<a name="l00320"></a>00320 {
<a name="l00321"></a>00321 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"Attempt to write to readonly PINx register\n"</span>);
<a name="l00322"></a>00322 }
<a name="l00323"></a>00323
<a name="l00324"></a>00324 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == p-&gt;ddr_addr)
<a name="l00325"></a>00325 {
<a name="l00326"></a>00326 port_write_ddr ((Port *)p, addr, val);
<a name="l00327"></a>00327 }
<a name="l00328"></a>00328
<a name="l00329"></a>00329 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == p-&gt;port_addr)
<a name="l00330"></a>00330 {
<a name="l00331"></a>00331 port_write_port ((Port *)p, addr, val);
<a name="l00332"></a>00332 }
<a name="l00333"></a>00333
<a name="l00334"></a>00334 <span class="keywordflow">else</span>
<a name="l00335"></a>00335 {
<a name="l00336"></a>00336 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Invalid Port Address: 0x%02x"</span>, addr);
<a name="l00337"></a>00337 }
<a name="l00338"></a>00338 }
<a name="l00339"></a>00339
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,187 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>ports.c File Reference</h1>Module for accessing simulated I/O ports. <a href="#_details">More...</a>
<p>
<p>
<a href="ports_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="ports_8c.html#00826229de675b5cd869c124267b7c3b">port_create</a> (int addr, char *name, int rel_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="ports_8c.html#ebb7d0728b81651d94a98d9640d9c328">port_ext_disable</a> (Port *p)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="ports_8c.html#034de04c76c1ba1271c13edda67e83ba">port_ext_enable</a> (Port *p)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="ports_8c.html#4711762fbc2eb589ed9d4973df5d5a88">port_add_ext_rd_wr</a> (Port *p, PortFP_ExtRd ext_rd, PortFP_ExtWr ext_wr)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Module for accessing simulated I/O ports.
<p>
Defines an abstract Port class as well as subclasses for each individual port.<p>
<dl compact><dt><b><a class="el" href="todo.html#_todo000002">Todo:</a></b></dt><dd>Remove the pins argument and the mask field. That's handled at a higher level so is obsolete here now. </dd></dl>
<p>Definition in file <a class="el" href="ports_8c-source.html">ports.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="00826229de675b5cd869c124267b7c3b"></a><!-- doxytag: member="ports.c::port_create" ref="00826229de675b5cd869c124267b7c3b" args="(int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* port_create </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Create a new Port instance.
<p>
This should only be used in DevSuppDefn initializers.
<p>Definition at line <a class="el" href="ports_8c-source.html#l00100">100</a> of file <a class="el" href="ports_8c-source.html">ports.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="ebb7d0728b81651d94a98d9640d9c328"></a><!-- doxytag: member="ports.c::port_ext_disable" ref="ebb7d0728b81651d94a98d9640d9c328" args="(Port *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void port_ext_disable </td>
<td>(</td>
<td class="paramtype">Port *&nbsp;</td>
<td class="paramname"> <em>p</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Disable external port functionality.
<p>
This is only used when dumping memory to core file. See <a class="el" href="memory_8c.html#0a2cee082a6775c45b08324be6ded380" title="Fetch the name and value of the io register (addr).">mem_io_fetch()</a>.
<p>Definition at line <a class="el" href="ports_8c-source.html#l00200">200</a> of file <a class="el" href="ports_8c-source.html">ports.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="034de04c76c1ba1271c13edda67e83ba"></a><!-- doxytag: member="ports.c::port_ext_enable" ref="034de04c76c1ba1271c13edda67e83ba" args="(Port *p)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void port_ext_enable </td>
<td>(</td>
<td class="paramtype">Port *&nbsp;</td>
<td class="paramname"> <em>p</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Enable external port functionality.
<p>
This is only used when dumping memory to core file. See <a class="el" href="memory_8c.html#0a2cee082a6775c45b08324be6ded380" title="Fetch the name and value of the io register (addr).">mem_io_fetch()</a>.
<p>Definition at line <a class="el" href="ports_8c-source.html#l00210">210</a> of file <a class="el" href="ports_8c-source.html">ports.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="4711762fbc2eb589ed9d4973df5d5a88"></a><!-- doxytag: member="ports.c::port_add_ext_rd_wr" ref="4711762fbc2eb589ed9d4973df5d5a88" args="(Port *p, PortFP_ExtRd ext_rd, PortFP_ExtWr ext_wr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void port_add_ext_rd_wr </td>
<td>(</td>
<td class="paramtype">Port *&nbsp;</td>
<td class="paramname"> <em>p</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">PortFP_ExtRd&nbsp;</td>
<td class="paramname"> <em>ext_rd</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">PortFP_ExtWr&nbsp;</td>
<td class="paramname"> <em>ext_wr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Attaches read and write functions to a particular port.
<p>
I think I may have this backwards. Having the virtual hardware supply functions for the core to call on every io read/write, might cause missed events (like edge triggered). I'm really not too sure how to handle this.<p>
In the future, it might be better to have the core supply a function for the virtual hardware to call when data is written to the device. The device supplied function could then check if an interrupt should be generated or just simply write to the port data register.<p>
For now, leave it as is since it's easier to test if you can block when the device is reading from the virtual hardware.
<p>Definition at line <a class="el" href="ports_8c-source.html#l00231">231</a> of file <a class="el" href="ports_8c-source.html">ports.c</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l01234">avr_core_add_ext_rd_wr()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,678 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>register.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: register.c,v 1.36 2008/01/06 22:38:19 joerg_wunsch Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003, 2004 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00030"></a>00030
<a name="l00031"></a>00031 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include "utils.h"</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include "callback.h"</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include "op_names.h"</span>
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="preprocessor">#include "storage.h"</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include "flash.h"</span>
<a name="l00040"></a>00040
<a name="l00041"></a>00041 <span class="preprocessor">#include "vdevs.h"</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include "memory.h"</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include "stack.h"</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include "register.h"</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include "sram.h"</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include "eeprom.h"</span>
<a name="l00047"></a>00047 <span class="preprocessor">#include "timers.h"</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include "ports.h"</span>
<a name="l00049"></a>00049
<a name="l00050"></a>00050 <span class="preprocessor">#include "avrcore.h"</span>
<a name="l00051"></a>00051
<a name="l00052"></a>00052 <span class="preprocessor">#include "display.h"</span>
<a name="l00053"></a>00053 <span class="preprocessor">#include "intvects.h"</span>
<a name="l00054"></a>00054
<a name="l00055"></a>00055 <span class="comment">/****************************************************************************\</span>
<a name="l00056"></a>00056 <span class="comment"> *</span>
<a name="l00057"></a>00057 <span class="comment"> * Status Register Methods.</span>
<a name="l00058"></a>00058 <span class="comment"> *</span>
<a name="l00059"></a>00059 <span class="comment">\****************************************************************************/</span>
<a name="l00060"></a>00060
<a name="l00061"></a>00061 <span class="keyword">static</span> uint8_t sreg_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00062"></a>00062 <span class="keyword">static</span> <span class="keywordtype">void</span> sreg_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00063"></a>00063 <span class="keyword">static</span> <span class="keywordtype">void</span> sreg_reset (VDevice *dev);
<a name="l00064"></a>00064 <span class="keyword">static</span> <span class="keywordtype">void</span> sreg_add_addr (VDevice *dev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr,
<a name="l00065"></a>00065 <span class="keywordtype">void</span> *data);
<a name="l00066"></a>00066
<a name="l00067"></a>00067 VDevice *
<a name="l00068"></a>00068 sreg_create (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00069"></a>00069 {
<a name="l00070"></a>00070 <span class="keywordflow">return</span> (VDevice *)sreg_new ();
<a name="l00071"></a>00071 }
<a name="l00072"></a>00072
<a name="l00073"></a>00073 SREG *
<a name="l00074"></a>00074 sreg_new (<span class="keywordtype">void</span>)
<a name="l00075"></a>00075 {
<a name="l00076"></a>00076 SREG *sreg;
<a name="l00077"></a>00077
<a name="l00078"></a>00078 sreg = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (SREG, 1);
<a name="l00079"></a>00079 sreg_construct (sreg);
<a name="l00080"></a>00080 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)sreg, sreg_destroy);
<a name="l00081"></a>00081
<a name="l00082"></a>00082 <span class="keywordflow">return</span> sreg;
<a name="l00083"></a>00083 }
<a name="l00084"></a>00084
<a name="l00085"></a>00085 <span class="keywordtype">void</span>
<a name="l00086"></a>00086 sreg_construct (SREG *sreg)
<a name="l00087"></a>00087 {
<a name="l00088"></a>00088 <span class="keywordflow">if</span> (sreg == NULL)
<a name="l00089"></a>00089 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00090"></a>00090
<a name="l00091"></a>00091 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)sreg, sreg_read, sreg_write, sreg_reset,
<a name="l00092"></a>00092 sreg_add_addr);
<a name="l00093"></a>00093
<a name="l00094"></a>00094 sreg-&gt;sreg.reg = 0;
<a name="l00095"></a>00095 }
<a name="l00096"></a>00096
<a name="l00097"></a>00097 <span class="keywordtype">void</span>
<a name="l00098"></a>00098 sreg_destroy (<span class="keywordtype">void</span> *sreg)
<a name="l00099"></a>00099 {
<a name="l00100"></a>00100 <span class="keywordflow">if</span> (sreg == NULL)
<a name="l00101"></a>00101 <span class="keywordflow">return</span>;
<a name="l00102"></a>00102
<a name="l00103"></a>00103 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (sreg);
<a name="l00104"></a>00104 }
<a name="l00105"></a>00105
<a name="l00106"></a>00106 <span class="keyword">extern</span> uint8_t sreg_get (SREG *sreg);
<a name="l00107"></a>00107
<a name="l00108"></a>00108 <span class="keyword">extern</span> <span class="keywordtype">void</span> sreg_set (SREG *sreg, uint8_t val);
<a name="l00109"></a>00109
<a name="l00110"></a>00110 <span class="keyword">extern</span> uint8_t sreg_get_bit (SREG *sreg, <span class="keywordtype">int</span> bit);
<a name="l00111"></a>00111
<a name="l00112"></a>00112 <span class="keyword">extern</span> <span class="keywordtype">void</span> sreg_set_bit (SREG *sreg, <span class="keywordtype">int</span> bit, <span class="keywordtype">int</span> val);
<a name="l00113"></a>00113
<a name="l00114"></a>00114 <span class="keyword">static</span> uint8_t
<a name="l00115"></a>00115 sreg_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00116"></a>00116 {
<a name="l00117"></a>00117 <span class="keywordflow">return</span> sreg_get ((SREG *)dev);
<a name="l00118"></a>00118 }
<a name="l00119"></a>00119
<a name="l00120"></a>00120 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00121"></a>00121 sreg_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00122"></a>00122 {
<a name="l00123"></a>00123 sreg_set ((SREG *)dev, val);
<a name="l00124"></a>00124 }
<a name="l00125"></a>00125
<a name="l00126"></a>00126 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00127"></a>00127 sreg_reset (VDevice *dev)
<a name="l00128"></a>00128 {
<a name="l00129"></a>00129 <a class="code" href="display_8c.html#ed9707596c157777dc33fe1371ded7fc" title="Update an IO register in the display.">display_io_reg</a> (SREG_IO_REG, 0);
<a name="l00130"></a>00130 ((SREG *)dev)-&gt;sreg.reg = 0;
<a name="l00131"></a>00131 }
<a name="l00132"></a>00132
<a name="l00133"></a>00133 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00134"></a>00134 sreg_add_addr (VDevice *dev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00135"></a>00135 {
<a name="l00136"></a>00136 <span class="comment">/* Nothing to do here. */</span>
<a name="l00137"></a>00137 }
<a name="l00138"></a>00138
<a name="l00139"></a>00139
<a name="l00140"></a>00140 <span class="comment">/****************************************************************************\</span>
<a name="l00141"></a>00141 <span class="comment"> *</span>
<a name="l00142"></a>00142 <span class="comment"> * General Purpose Working Register (gpwr) Methods.</span>
<a name="l00143"></a>00143 <span class="comment"> *</span>
<a name="l00144"></a>00144 <span class="comment">\****************************************************************************/</span>
<a name="l00145"></a>00145
<a name="l00146"></a>00146 <span class="keyword">static</span> uint8_t gpwr_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00147"></a>00147 <span class="keyword">static</span> <span class="keywordtype">void</span> gpwr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00148"></a>00148 <span class="keyword">static</span> <span class="keywordtype">void</span> gpwr_reset (VDevice *dev);
<a name="l00149"></a>00149
<a name="l00150"></a>00150 GPWR *
<a name="l00151"></a>00151 gpwr_new (<span class="keywordtype">void</span>)
<a name="l00152"></a>00152 {
<a name="l00153"></a>00153 GPWR *gpwr;
<a name="l00154"></a>00154
<a name="l00155"></a>00155 gpwr = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (GPWR, 1);
<a name="l00156"></a>00156 gpwr_construct (gpwr);
<a name="l00157"></a>00157 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)gpwr, gpwr_destroy);
<a name="l00158"></a>00158
<a name="l00159"></a>00159 <span class="keywordflow">return</span> gpwr;
<a name="l00160"></a>00160 }
<a name="l00161"></a>00161
<a name="l00162"></a>00162 <span class="keywordtype">void</span>
<a name="l00163"></a>00163 gpwr_construct (GPWR *gpwr)
<a name="l00164"></a>00164 {
<a name="l00165"></a>00165 <span class="keywordflow">if</span> (gpwr == NULL)
<a name="l00166"></a>00166 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00167"></a>00167
<a name="l00168"></a>00168 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)gpwr, gpwr_read, gpwr_write, gpwr_reset, NULL);
<a name="l00169"></a>00169
<a name="l00170"></a>00170 gpwr_reset ((VDevice *)gpwr);
<a name="l00171"></a>00171 }
<a name="l00172"></a>00172
<a name="l00173"></a>00173 <span class="keywordtype">void</span>
<a name="l00174"></a>00174 gpwr_destroy (<span class="keywordtype">void</span> *gpwr)
<a name="l00175"></a>00175 {
<a name="l00176"></a>00176 <span class="keywordflow">if</span> (gpwr == NULL)
<a name="l00177"></a>00177 <span class="keywordflow">return</span>;
<a name="l00178"></a>00178
<a name="l00179"></a>00179 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (gpwr);
<a name="l00180"></a>00180 }
<a name="l00181"></a>00181
<a name="l00182"></a>00182 <span class="keyword">extern</span> uint8_t gpwr_get (GPWR *gpwr, <span class="keywordtype">int</span> reg);
<a name="l00183"></a>00183
<a name="l00184"></a>00184 <span class="keyword">extern</span> <span class="keywordtype">void</span> gpwr_set (GPWR *gpwr, <span class="keywordtype">int</span> reg, uint8_t val);
<a name="l00185"></a>00185
<a name="l00186"></a>00186 <span class="keyword">static</span> uint8_t
<a name="l00187"></a>00187 gpwr_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00188"></a>00188 {
<a name="l00189"></a>00189 <span class="keywordflow">return</span> gpwr_get ((GPWR *)dev, addr);
<a name="l00190"></a>00190 }
<a name="l00191"></a>00191
<a name="l00192"></a>00192 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00193"></a>00193 gpwr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00194"></a>00194 {
<a name="l00195"></a>00195 gpwr_set ((GPWR *)dev, addr, val);
<a name="l00196"></a>00196 }
<a name="l00197"></a>00197
<a name="l00198"></a>00198 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00199"></a>00199 gpwr_reset (VDevice *dev)
<a name="l00200"></a>00200 {
<a name="l00201"></a>00201 <span class="keywordtype">int</span> i;
<a name="l00202"></a>00202
<a name="l00203"></a>00203 <span class="keywordflow">for</span> (i = 0; i &lt; GPWR_SIZE; i++)
<a name="l00204"></a>00204 gpwr_set ((GPWR *)dev, i, 0);
<a name="l00205"></a>00205 }
<a name="l00206"></a>00206
<a name="l00207"></a>00207 <span class="comment">/****************************************************************************\</span>
<a name="l00208"></a>00208 <span class="comment"> *</span>
<a name="l00209"></a>00209 <span class="comment"> * ACSR(VDevice) : Analog Comparator Control and Status Register Definition</span>
<a name="l00210"></a>00210 <span class="comment"> *</span>
<a name="l00211"></a>00211 <span class="comment">\****************************************************************************/</span>
<a name="l00212"></a>00212
<a name="l00213"></a>00213 <span class="keyword">static</span> uint8_t acsr_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00214"></a>00214 <span class="keyword">static</span> <span class="keywordtype">void</span> acsr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00215"></a>00215 <span class="keyword">static</span> <span class="keywordtype">void</span> acsr_reset (VDevice *dev);
<a name="l00216"></a>00216
<a name="l00217"></a>00217 ACSR *
<a name="l00218"></a>00218 acsr_new (uint8_t func_mask)
<a name="l00219"></a>00219 {
<a name="l00220"></a>00220 ACSR *acsr;
<a name="l00221"></a>00221
<a name="l00222"></a>00222 acsr = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (ACSR, 1);
<a name="l00223"></a>00223 acsr_construct (acsr, func_mask);
<a name="l00224"></a>00224 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)acsr, acsr_destroy);
<a name="l00225"></a>00225
<a name="l00226"></a>00226 <span class="keywordflow">return</span> acsr;
<a name="l00227"></a>00227 }
<a name="l00228"></a>00228
<a name="l00229"></a>00229 <span class="keywordtype">void</span>
<a name="l00230"></a>00230 acsr_construct (ACSR *acsr, uint8_t func_mask)
<a name="l00231"></a>00231 {
<a name="l00232"></a>00232 <span class="keywordflow">if</span> (acsr == NULL)
<a name="l00233"></a>00233 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00234"></a>00234
<a name="l00235"></a>00235 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)acsr, acsr_read, acsr_write, acsr_reset,
<a name="l00236"></a>00236 <a class="code" href="device_8c.html#5cebfd18a219807f27e4a3f38da4a5d0" title="Default AddAddr method.">vdev_def_AddAddr</a>);
<a name="l00237"></a>00237
<a name="l00238"></a>00238 acsr-&gt;func_mask = func_mask;
<a name="l00239"></a>00239 acsr-&gt;acsr = 0;
<a name="l00240"></a>00240 }
<a name="l00241"></a>00241
<a name="l00242"></a>00242 <span class="keywordtype">void</span>
<a name="l00243"></a>00243 acsr_destroy (<span class="keywordtype">void</span> *acsr)
<a name="l00244"></a>00244 {
<a name="l00245"></a>00245 <span class="keywordflow">if</span> (acsr == NULL)
<a name="l00246"></a>00246 <span class="keywordflow">return</span>;
<a name="l00247"></a>00247
<a name="l00248"></a>00248 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (acsr);
<a name="l00249"></a>00249 }
<a name="l00250"></a>00250
<a name="l00251"></a>00251 <span class="keywordtype">int</span>
<a name="l00252"></a>00252 acsr_get_bit (ACSR *acsr, <span class="keywordtype">int</span> bit)
<a name="l00253"></a>00253 {
<a name="l00254"></a>00254 <span class="keywordflow">return</span> !!(acsr-&gt;acsr &amp; acsr-&gt;func_mask &amp; (1 &lt;&lt; bit));
<a name="l00255"></a>00255 }
<a name="l00256"></a>00256
<a name="l00257"></a>00257 <span class="keywordtype">void</span>
<a name="l00258"></a>00258 acsr_set_bit (ACSR *acsr, <span class="keywordtype">int</span> bit, <span class="keywordtype">int</span> val)
<a name="l00259"></a>00259 {
<a name="l00260"></a>00260 <span class="comment">/* the ACO bit is read only */</span>
<a name="l00261"></a>00261 acsr-&gt;acsr =
<a name="l00262"></a>00262 <a class="code" href="utils_8c.html#eb8ce7ee7e6e35ee3ec8d3539bb52519" title="Set a bit in src to 1 if val != 0, clears bit if val == 0.">set_bit_in_byte</a> (acsr-&gt;acsr, bit,
<a name="l00263"></a>00263 val) &amp; acsr-&gt;func_mask &amp; ~(mask_ACO);
<a name="l00264"></a>00264 }
<a name="l00265"></a>00265
<a name="l00266"></a>00266 <span class="keyword">static</span> uint8_t
<a name="l00267"></a>00267 acsr_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00268"></a>00268 {
<a name="l00269"></a>00269 ACSR *reg = (ACSR *)dev;
<a name="l00270"></a>00270
<a name="l00271"></a>00271 <span class="keywordflow">return</span> (reg-&gt;acsr &amp; reg-&gt;func_mask);
<a name="l00272"></a>00272 }
<a name="l00273"></a>00273
<a name="l00274"></a>00274 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00275"></a>00275 acsr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00276"></a>00276 {
<a name="l00277"></a>00277 ACSR *reg = (ACSR *)dev;
<a name="l00278"></a>00278
<a name="l00279"></a>00279 <span class="comment">/* the ACO bit is read only */</span>
<a name="l00280"></a>00280 reg-&gt;acsr = (val &amp; reg-&gt;func_mask &amp; ~(mask_ACO));
<a name="l00281"></a>00281 }
<a name="l00282"></a>00282
<a name="l00283"></a>00283 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00284"></a>00284 acsr_reset (VDevice *dev)
<a name="l00285"></a>00285 {
<a name="l00286"></a>00286 ((ACSR *)dev)-&gt;acsr = 0;
<a name="l00287"></a>00287 }
<a name="l00288"></a>00288
<a name="l00289"></a>00289 <span class="comment">/****************************************************************************\</span>
<a name="l00290"></a>00290 <span class="comment"> *</span>
<a name="l00291"></a>00291 <span class="comment"> * MCUCR(VDevice) : MCU general control register</span>
<a name="l00292"></a>00292 <span class="comment"> *</span>
<a name="l00293"></a>00293 <span class="comment">\****************************************************************************/</span>
<a name="l00294"></a>00294
<a name="l00295"></a>00295 <span class="keyword">static</span> uint8_t mcucr_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00296"></a>00296 <span class="keyword">static</span> <span class="keywordtype">void</span> mcucr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00297"></a>00297 <span class="keyword">static</span> <span class="keywordtype">void</span> mcucr_reset (VDevice *dev);
<a name="l00298"></a>00298
<a name="l00299"></a>00299 MCUCR *
<a name="l00300"></a>00300 mcucr_new (uint8_t func_mask)
<a name="l00301"></a>00301 {
<a name="l00302"></a>00302 MCUCR *mcucr;
<a name="l00303"></a>00303
<a name="l00304"></a>00304 mcucr = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (MCUCR, 1);
<a name="l00305"></a>00305 mcucr_construct (mcucr, func_mask);
<a name="l00306"></a>00306 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)mcucr, mcucr_destroy);
<a name="l00307"></a>00307
<a name="l00308"></a>00308 <span class="keywordflow">return</span> mcucr;
<a name="l00309"></a>00309 }
<a name="l00310"></a>00310
<a name="l00311"></a>00311 <span class="keywordtype">void</span>
<a name="l00312"></a>00312 mcucr_construct (MCUCR *mcucr, uint8_t func_mask)
<a name="l00313"></a>00313 {
<a name="l00314"></a>00314 <span class="keywordflow">if</span> (mcucr == NULL)
<a name="l00315"></a>00315 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00316"></a>00316
<a name="l00317"></a>00317 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)mcucr, mcucr_read, mcucr_write, mcucr_reset,
<a name="l00318"></a>00318 <a class="code" href="device_8c.html#5cebfd18a219807f27e4a3f38da4a5d0" title="Default AddAddr method.">vdev_def_AddAddr</a>);
<a name="l00319"></a>00319
<a name="l00320"></a>00320 mcucr-&gt;func_mask = func_mask;
<a name="l00321"></a>00321 mcucr-&gt;mcucr = 0;
<a name="l00322"></a>00322 }
<a name="l00323"></a>00323
<a name="l00324"></a>00324 <span class="keywordtype">void</span>
<a name="l00325"></a>00325 mcucr_destroy (<span class="keywordtype">void</span> *mcucr)
<a name="l00326"></a>00326 {
<a name="l00327"></a>00327 <span class="keywordflow">if</span> (mcucr == NULL)
<a name="l00328"></a>00328 <span class="keywordflow">return</span>;
<a name="l00329"></a>00329
<a name="l00330"></a>00330 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (mcucr);
<a name="l00331"></a>00331 }
<a name="l00332"></a>00332
<a name="l00333"></a>00333 <span class="keywordtype">int</span>
<a name="l00334"></a>00334 mcucr_get_bit (MCUCR *reg, <span class="keywordtype">int</span> bit)
<a name="l00335"></a>00335 {
<a name="l00336"></a>00336 <span class="keywordflow">return</span> !!(reg-&gt;mcucr &amp; reg-&gt;func_mask &amp; (1 &lt;&lt; bit));
<a name="l00337"></a>00337 }
<a name="l00338"></a>00338
<a name="l00339"></a>00339 <span class="keywordtype">void</span>
<a name="l00340"></a>00340 mcucr_set_bit (MCUCR *reg, <span class="keywordtype">int</span> bit, <span class="keywordtype">int</span> val)
<a name="l00341"></a>00341 {
<a name="l00342"></a>00342 reg-&gt;mcucr = <a class="code" href="utils_8c.html#eb8ce7ee7e6e35ee3ec8d3539bb52519" title="Set a bit in src to 1 if val != 0, clears bit if val == 0.">set_bit_in_byte</a> (reg-&gt;mcucr, bit, val) &amp; reg-&gt;func_mask;
<a name="l00343"></a>00343 }
<a name="l00344"></a>00344
<a name="l00345"></a>00345 <span class="keyword">static</span> uint8_t
<a name="l00346"></a>00346 mcucr_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00347"></a>00347 {
<a name="l00348"></a>00348 MCUCR *reg = (MCUCR *)dev;
<a name="l00349"></a>00349
<a name="l00350"></a>00350 <span class="keywordflow">return</span> (reg-&gt;mcucr &amp; reg-&gt;func_mask);
<a name="l00351"></a>00351 }
<a name="l00352"></a>00352
<a name="l00353"></a>00353 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00354"></a>00354 mcucr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00355"></a>00355 {
<a name="l00356"></a>00356 MCUCR *reg = (MCUCR *)dev;
<a name="l00357"></a>00357
<a name="l00358"></a>00358 reg-&gt;mcucr = (val &amp; reg-&gt;func_mask);
<a name="l00359"></a>00359 }
<a name="l00360"></a>00360
<a name="l00361"></a>00361 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00362"></a>00362 mcucr_reset (VDevice *dev)
<a name="l00363"></a>00363 {
<a name="l00364"></a>00364 ((MCUCR *)dev)-&gt;mcucr = 0;
<a name="l00365"></a>00365 }
<a name="l00366"></a>00366
<a name="l00367"></a>00367 <span class="comment">/****************************************************************************\</span>
<a name="l00368"></a>00368 <span class="comment"> *</span>
<a name="l00369"></a>00369 <span class="comment"> * WDTCR(VDevice) : Watchdog timer control register</span>
<a name="l00370"></a>00370 <span class="comment"> *</span>
<a name="l00371"></a>00371 <span class="comment">\****************************************************************************/</span>
<a name="l00372"></a>00372
<a name="l00373"></a>00373 <span class="comment">/* static int wdtcr_get_bit ( WDTCR *wdtcr, int bit ); */</span>
<a name="l00374"></a>00374 <span class="keyword">static</span> <span class="keywordtype">void</span> wdtcr_set_bit (WDTCR *wdtcr, <span class="keywordtype">int</span> bit, <span class="keywordtype">int</span> val);
<a name="l00375"></a>00375
<a name="l00376"></a>00376 <span class="keyword">static</span> uint8_t wdtcr_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00377"></a>00377 <span class="keyword">static</span> <span class="keywordtype">void</span> wdtcr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00378"></a>00378 <span class="keyword">static</span> <span class="keywordtype">void</span> wdtcr_reset (VDevice *dev);
<a name="l00379"></a>00379
<a name="l00380"></a>00380 <span class="keyword">static</span> <span class="keywordtype">int</span> wdtcr_timer_cb (uint64_t time, AvrClass *data);
<a name="l00381"></a>00381 <span class="keyword">static</span> <span class="keywordtype">int</span> wdtcr_toe_clr_cb (uint64_t time, AvrClass *data);
<a name="l00382"></a>00382
<a name="l00383"></a>00383 WDTCR *
<a name="l00384"></a>00384 wdtcr_new (uint8_t func_mask)
<a name="l00385"></a>00385 {
<a name="l00386"></a>00386 WDTCR *wdtcr;
<a name="l00387"></a>00387
<a name="l00388"></a>00388 wdtcr = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (WDTCR, 1);
<a name="l00389"></a>00389 wdtcr_construct (wdtcr, func_mask);
<a name="l00390"></a>00390 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)wdtcr, wdtcr_destroy);
<a name="l00391"></a>00391
<a name="l00392"></a>00392 <span class="keywordflow">return</span> wdtcr;
<a name="l00393"></a>00393 }
<a name="l00394"></a>00394
<a name="l00395"></a>00395 <span class="keywordtype">void</span>
<a name="l00396"></a>00396 wdtcr_construct (WDTCR *wdtcr, uint8_t func_mask)
<a name="l00397"></a>00397 {
<a name="l00398"></a>00398 <span class="keywordflow">if</span> (wdtcr == NULL)
<a name="l00399"></a>00399 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00400"></a>00400
<a name="l00401"></a>00401 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)wdtcr, wdtcr_read, wdtcr_write, wdtcr_reset,
<a name="l00402"></a>00402 <a class="code" href="device_8c.html#5cebfd18a219807f27e4a3f38da4a5d0" title="Default AddAddr method.">vdev_def_AddAddr</a>);
<a name="l00403"></a>00403
<a name="l00404"></a>00404 wdtcr-&gt;func_mask = func_mask;
<a name="l00405"></a>00405
<a name="l00406"></a>00406 wdtcr_reset ((VDevice *)wdtcr);
<a name="l00407"></a>00407 }
<a name="l00408"></a>00408
<a name="l00409"></a>00409 <span class="keywordtype">void</span>
<a name="l00410"></a>00410 wdtcr_destroy (<span class="keywordtype">void</span> *wdtcr)
<a name="l00411"></a>00411 {
<a name="l00412"></a>00412 <span class="keywordflow">if</span> (wdtcr == NULL)
<a name="l00413"></a>00413 <span class="keywordflow">return</span>;
<a name="l00414"></a>00414
<a name="l00415"></a>00415 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (wdtcr);
<a name="l00416"></a>00416 }
<a name="l00417"></a>00417
<a name="l00418"></a>00418 <span class="comment">/*</span>
<a name="l00419"></a>00419 <span class="comment"> * Function wdtcr_update: Called when the WDR instruction is issued</span>
<a name="l00420"></a>00420 <span class="comment"> */</span>
<a name="l00421"></a>00421 <span class="keywordtype">void</span>
<a name="l00422"></a>00422 wdtcr_update (WDTCR *wdtcr)
<a name="l00423"></a>00423 {
<a name="l00424"></a>00424 wdtcr-&gt;last_WDR = <a class="code" href="utils_8c.html#d71e2db9144e1b1d539e1326cbdcbf04" title="Return the number of milliseconds of elapsed program time.">get_program_time</a> ();
<a name="l00425"></a>00425 }
<a name="l00426"></a>00426
<a name="l00427"></a>00427 <span class="preprocessor">#if 0 </span><span class="comment">/* This doesn't seem to be used anywhere. */</span>
<a name="l00428"></a>00428 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00429"></a>00429 wdtcr_get_bit (WDTCR *reg, <span class="keywordtype">int</span> bit)
<a name="l00430"></a>00430 {
<a name="l00431"></a>00431 <span class="keywordflow">return</span> !!(reg-&gt;wdtcr &amp; reg-&gt;func_mask &amp; (1 &lt;&lt; bit));
<a name="l00432"></a>00432 }
<a name="l00433"></a>00433 <span class="preprocessor">#endif</span>
<a name="l00434"></a>00434 <span class="preprocessor"></span>
<a name="l00435"></a>00435 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00436"></a>00436 wdtcr_set_bit (WDTCR *reg, <span class="keywordtype">int</span> bit, <span class="keywordtype">int</span> val)
<a name="l00437"></a>00437 {
<a name="l00438"></a>00438 reg-&gt;wdtcr = <a class="code" href="utils_8c.html#eb8ce7ee7e6e35ee3ec8d3539bb52519" title="Set a bit in src to 1 if val != 0, clears bit if val == 0.">set_bit_in_byte</a> (reg-&gt;wdtcr, bit, val) &amp; reg-&gt;func_mask;
<a name="l00439"></a>00439 }
<a name="l00440"></a>00440
<a name="l00441"></a>00441 <span class="keyword">static</span> uint8_t
<a name="l00442"></a>00442 wdtcr_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00443"></a>00443 {
<a name="l00444"></a>00444 WDTCR *reg = (WDTCR *)dev;
<a name="l00445"></a>00445
<a name="l00446"></a>00446 <span class="keywordflow">return</span> (reg-&gt;wdtcr &amp; reg-&gt;func_mask);
<a name="l00447"></a>00447 }
<a name="l00448"></a>00448
<a name="l00449"></a>00449 <span class="comment">/*</span>
<a name="l00450"></a>00450 <span class="comment"> * FIXME: Should the wdtcr-&gt;toe_clk counter be reset to TOE_CLKS</span>
<a name="l00451"></a>00451 <span class="comment"> * every time a WDTOE is set 1? I.E. does the hw reset the 4 cycle</span>
<a name="l00452"></a>00452 <span class="comment"> * counter every time WDTOE is set? This code assumes it does.</span>
<a name="l00453"></a>00453 <span class="comment"> */</span>
<a name="l00454"></a>00454 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00455"></a>00455 wdtcr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00456"></a>00456 {
<a name="l00457"></a>00457 WDTCR *reg = (WDTCR *)dev;
<a name="l00458"></a>00458 uint8_t wd_enabled = (reg-&gt;wdtcr &amp; mask_WDE);
<a name="l00459"></a>00459
<a name="l00460"></a>00460 CallBack *cb;
<a name="l00461"></a>00461
<a name="l00462"></a>00462 <span class="keywordflow">if</span> (reg-&gt;func_mask &amp; mask_WDTOE)
<a name="l00463"></a>00463 { <span class="comment">/* Device has WDTOE functionality */</span>
<a name="l00464"></a>00464
<a name="l00465"></a>00465 <span class="keywordflow">if</span> ((reg-&gt;wdtcr &amp; mask_WDE) &amp;&amp; !(reg-&gt;wdtcr &amp; mask_WDTOE))
<a name="l00466"></a>00466 {
<a name="l00467"></a>00467 <span class="comment">/* WDE can _NOT_ be cleared if WDTOE is zero */</span>
<a name="l00468"></a>00468 val |= mask_WDE;
<a name="l00469"></a>00469 }
<a name="l00470"></a>00470
<a name="l00471"></a>00471 <span class="keywordflow">if</span> (val &amp; mask_WDTOE)
<a name="l00472"></a>00472 { <span class="comment">/* program has set WDTOE */</span>
<a name="l00473"></a>00473 reg-&gt;toe_clk = TOE_CLKS;
<a name="l00474"></a>00474
<a name="l00475"></a>00475 <span class="comment">/* create and install the callback if it not already installed */</span>
<a name="l00476"></a>00476 <span class="keywordflow">if</span> (reg-&gt;toe_cb == NULL)
<a name="l00477"></a>00477 {
<a name="l00478"></a>00478 cb = callback_new (wdtcr_toe_clr_cb, (AvrClass *)reg);
<a name="l00479"></a>00479 reg-&gt;toe_cb = cb;
<a name="l00480"></a>00480 <a class="code" href="avrcore_8c.html#3e755b8388c3c44ea514484ce53ace75" title="Add a new clock callback to list.">avr_core_clk_cb_add</a> ((AvrCore *)<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> (dev), cb);
<a name="l00481"></a>00481 }
<a name="l00482"></a>00482 }
<a name="l00483"></a>00483 }
<a name="l00484"></a>00484
<a name="l00485"></a>00485 reg-&gt;wdtcr = (val &amp; reg-&gt;func_mask);
<a name="l00486"></a>00486
<a name="l00487"></a>00487 <span class="keywordflow">if</span> ((wd_enabled == 0) &amp;&amp; (val &amp; mask_WDE) &amp;&amp; (reg-&gt;timer_cb == NULL))
<a name="l00488"></a>00488 {
<a name="l00489"></a>00489 <span class="comment">/* install the WD timer callback */</span>
<a name="l00490"></a>00490 cb = callback_new (wdtcr_timer_cb, (AvrClass *)reg);
<a name="l00491"></a>00491 reg-&gt;timer_cb = cb;
<a name="l00492"></a>00492 <a class="code" href="avrcore_8c.html#e821588464c39dbdcc9fb5eea45da0aa" title="Add a new asynchronous callback to list.">avr_core_async_cb_add</a> ((AvrCore *)<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> (dev), cb);
<a name="l00493"></a>00493 }
<a name="l00494"></a>00494
<a name="l00495"></a>00495 <span class="keywordflow">if</span> (wd_enabled &amp;&amp; ((val &amp; mask_WDE) == 0) &amp;&amp; (reg-&gt;timer_cb != NULL))
<a name="l00496"></a>00496 {
<a name="l00497"></a>00497 <span class="comment">/* tell callback to remove itself */</span>
<a name="l00498"></a>00498 reg-&gt;timer_cb = NULL;
<a name="l00499"></a>00499 }
<a name="l00500"></a>00500 }
<a name="l00501"></a>00501
<a name="l00502"></a>00502 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00503"></a>00503 wdtcr_reset (VDevice *dev)
<a name="l00504"></a>00504 {
<a name="l00505"></a>00505 WDTCR *wdtcr = (WDTCR *)dev;
<a name="l00506"></a>00506
<a name="l00507"></a>00507 wdtcr-&gt;wdtcr = 0;
<a name="l00508"></a>00508
<a name="l00509"></a>00509 wdtcr-&gt;last_WDR = <a class="code" href="utils_8c.html#d71e2db9144e1b1d539e1326cbdcbf04" title="Return the number of milliseconds of elapsed program time.">get_program_time</a> (); <span class="comment">/* FIXME: This might not be the</span>
<a name="l00510"></a>00510 <span class="comment"> right thing to do */</span>
<a name="l00511"></a>00511 wdtcr-&gt;timer_cb = NULL;
<a name="l00512"></a>00512
<a name="l00513"></a>00513 wdtcr-&gt;toe_clk = TOE_CLKS;
<a name="l00514"></a>00514 wdtcr-&gt;toe_cb = NULL;
<a name="l00515"></a>00515 }
<a name="l00516"></a>00516
<a name="l00517"></a>00517 <span class="comment">/*</span>
<a name="l00518"></a>00518 <span class="comment"> * Timer callback will remove itself if wdtcr-&gt;timer_cb is set NULL.</span>
<a name="l00519"></a>00519 <span class="comment"> */</span>
<a name="l00520"></a>00520 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00521"></a>00521 wdtcr_timer_cb (uint64_t time, AvrClass *data)
<a name="l00522"></a>00522 {
<a name="l00523"></a>00523 WDTCR *wdtcr = (WDTCR *)data;
<a name="l00524"></a>00524 uint64_t time_diff;
<a name="l00525"></a>00525 uint64_t time_out;
<a name="l00526"></a>00526
<a name="l00527"></a>00527 <span class="keywordflow">if</span> (wdtcr-&gt;timer_cb == NULL)
<a name="l00528"></a>00528 <span class="keywordflow">return</span> CB_RET_REMOVE;
<a name="l00529"></a>00529
<a name="l00530"></a>00530 time_diff = time - wdtcr-&gt;last_WDR;
<a name="l00531"></a>00531 time_out = TIMEOUT_BASE * (1 &lt;&lt; (wdtcr-&gt;wdtcr &amp; mask_WDP));
<a name="l00532"></a>00532
<a name="l00533"></a>00533 <span class="keywordflow">if</span> (time_diff &gt; time_out)
<a name="l00534"></a>00534 {
<a name="l00535"></a>00535 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"watchdog reset: time %lld\n"</span>, time_diff);
<a name="l00536"></a>00536
<a name="l00537"></a>00537 <span class="comment">/* reset the device, we timed out */</span>
<a name="l00538"></a>00538 <a class="code" href="avrcore_8c.html#90ca5d4a60478f9fccad81724a4be552" title="Raises an irq by adding it&amp;#39;s data to the irq_pending list.">avr_core_irq_raise</a> ((AvrCore *)<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)wdtcr),
<a name="l00539"></a>00539 irq_vect_table_index (RESET));
<a name="l00540"></a>00540 }
<a name="l00541"></a>00541
<a name="l00542"></a>00542 <span class="keywordflow">return</span> CB_RET_RETAIN;
<a name="l00543"></a>00543 }
<a name="l00544"></a>00544
<a name="l00545"></a>00545 <span class="comment">/*</span>
<a name="l00546"></a>00546 <span class="comment"> * The WDTOE is cleared by hardware after TOE_CLKS clock cycles.</span>
<a name="l00547"></a>00547 <span class="comment"> */</span>
<a name="l00548"></a>00548 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00549"></a>00549 wdtcr_toe_clr_cb (uint64_t time, AvrClass *data)
<a name="l00550"></a>00550 {
<a name="l00551"></a>00551 WDTCR *wdtcr = (WDTCR *)data;
<a name="l00552"></a>00552
<a name="l00553"></a>00553 <span class="keywordflow">if</span> (wdtcr-&gt;toe_cb == NULL)
<a name="l00554"></a>00554 <span class="keywordflow">return</span> CB_RET_REMOVE;
<a name="l00555"></a>00555
<a name="l00556"></a>00556 <span class="keywordflow">if</span> (wdtcr-&gt;toe_clk &gt; 0)
<a name="l00557"></a>00557 {
<a name="l00558"></a>00558 wdtcr-&gt;toe_clk--;
<a name="l00559"></a>00559 }
<a name="l00560"></a>00560 <span class="keywordflow">else</span>
<a name="l00561"></a>00561 {
<a name="l00562"></a>00562 wdtcr_set_bit (wdtcr, bit_WDTOE, 0);
<a name="l00563"></a>00563 wdtcr-&gt;toe_cb = NULL; <span class="comment">/* So we know that cb is not installed */</span>
<a name="l00564"></a>00564 <span class="keywordflow">return</span> CB_RET_REMOVE;
<a name="l00565"></a>00565 }
<a name="l00566"></a>00566
<a name="l00567"></a>00567 <span class="keywordflow">return</span> CB_RET_RETAIN;
<a name="l00568"></a>00568 }
<a name="l00569"></a>00569
<a name="l00570"></a>00570 <span class="comment">/****************************************************************************\</span>
<a name="l00571"></a>00571 <span class="comment"> *</span>
<a name="l00572"></a>00572 <span class="comment"> * RAMPZ(VDevice) : The RAMPZ register used by ELPM and ESPM instructions.</span>
<a name="l00573"></a>00573 <span class="comment"> *</span>
<a name="l00574"></a>00574 <span class="comment"> * Even though the rampz register is not available to all devices, we will</span>
<a name="l00575"></a>00575 <span class="comment"> * install it for all in the simulator. It just so much easier that way and</span>
<a name="l00576"></a>00576 <span class="comment"> * we're already assuming that the compiler generated the correct code in</span>
<a name="l00577"></a>00577 <span class="comment"> * many places anyways. Let's see if we get bit.</span>
<a name="l00578"></a>00578 <span class="comment"> *</span>
<a name="l00579"></a>00579 <span class="comment">\****************************************************************************/</span>
<a name="l00580"></a>00580
<a name="l00581"></a>00581 <span class="keyword">static</span> uint8_t rampz_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00582"></a>00582 <span class="keyword">static</span> <span class="keywordtype">void</span> rampz_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00583"></a>00583 <span class="keyword">static</span> <span class="keywordtype">void</span> rampz_reset (VDevice *dev);
<a name="l00584"></a>00584
<a name="l00585"></a>00585 VDevice *
<a name="l00586"></a>00586 rampz_create (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00587"></a>00587 {
<a name="l00588"></a>00588 <span class="keywordflow">return</span> (VDevice *)rampz_new ();
<a name="l00589"></a>00589 }
<a name="l00590"></a>00590
<a name="l00591"></a>00591 RAMPZ *
<a name="l00592"></a>00592 rampz_new (<span class="keywordtype">void</span>)
<a name="l00593"></a>00593 {
<a name="l00594"></a>00594 RAMPZ *rampz;
<a name="l00595"></a>00595
<a name="l00596"></a>00596 rampz = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (RAMPZ, 1);
<a name="l00597"></a>00597 rampz_construct (rampz);
<a name="l00598"></a>00598 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)rampz, rampz_destroy);
<a name="l00599"></a>00599
<a name="l00600"></a>00600 <span class="keywordflow">return</span> rampz;
<a name="l00601"></a>00601 }
<a name="l00602"></a>00602
<a name="l00603"></a>00603 <span class="keywordtype">void</span>
<a name="l00604"></a>00604 rampz_construct (RAMPZ *rampz)
<a name="l00605"></a>00605 {
<a name="l00606"></a>00606 <span class="keywordflow">if</span> (rampz == NULL)
<a name="l00607"></a>00607 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00608"></a>00608
<a name="l00609"></a>00609 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)rampz, rampz_read, rampz_write, rampz_reset,
<a name="l00610"></a>00610 <a class="code" href="device_8c.html#5cebfd18a219807f27e4a3f38da4a5d0" title="Default AddAddr method.">vdev_def_AddAddr</a>);
<a name="l00611"></a>00611
<a name="l00612"></a>00612 rampz-&gt;reg = 0;
<a name="l00613"></a>00613 }
<a name="l00614"></a>00614
<a name="l00615"></a>00615 <span class="keywordtype">void</span>
<a name="l00616"></a>00616 rampz_destroy (<span class="keywordtype">void</span> *rampz)
<a name="l00617"></a>00617 {
<a name="l00618"></a>00618 <span class="keywordflow">if</span> (rampz == NULL)
<a name="l00619"></a>00619 <span class="keywordflow">return</span>;
<a name="l00620"></a>00620
<a name="l00621"></a>00621 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (rampz);
<a name="l00622"></a>00622 }
<a name="l00623"></a>00623
<a name="l00624"></a>00624 uint8_t
<a name="l00625"></a>00625 rampz_get (RAMPZ *rampz)
<a name="l00626"></a>00626 {
<a name="l00627"></a>00627 <span class="keywordflow">return</span> rampz-&gt;reg;
<a name="l00628"></a>00628 }
<a name="l00629"></a>00629
<a name="l00630"></a>00630 <span class="keywordtype">void</span>
<a name="l00631"></a>00631 rampz_set (RAMPZ *rampz, uint8_t val)
<a name="l00632"></a>00632 {
<a name="l00633"></a>00633 rampz-&gt;reg = val;
<a name="l00634"></a>00634 }
<a name="l00635"></a>00635
<a name="l00636"></a>00636 <span class="keyword">static</span> uint8_t
<a name="l00637"></a>00637 rampz_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00638"></a>00638 {
<a name="l00639"></a>00639 <span class="keywordflow">return</span> rampz_get ((RAMPZ *)dev);
<a name="l00640"></a>00640 }
<a name="l00641"></a>00641
<a name="l00642"></a>00642 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00643"></a>00643 rampz_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00644"></a>00644 {
<a name="l00645"></a>00645 rampz_set ((RAMPZ *)dev, val);
<a name="l00646"></a>00646 }
<a name="l00647"></a>00647
<a name="l00648"></a>00648 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00649"></a>00649 rampz_reset (VDevice *dev)
<a name="l00650"></a>00650 {
<a name="l00651"></a>00651 <a class="code" href="display_8c.html#ed9707596c157777dc33fe1371ded7fc" title="Update an IO register in the display.">display_io_reg</a> (RAMPZ_IO_REG, 0);
<a name="l00652"></a>00652 ((RAMPZ *)dev)-&gt;reg = 0;
<a name="l00653"></a>00653 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,170 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>sig.c</h1><a href="sig_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: sig.c,v 1.6 2003/12/01 09:10:16 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/** </span>
<a name="l00027"></a>00027 <span class="comment"> * \file sig.c</span>
<a name="l00028"></a>00028 <span class="comment"> * \brief Public interface to signal handlers.</span>
<a name="l00029"></a>00029 <span class="comment"> *</span>
<a name="l00030"></a>00030 <span class="comment"> * This module provides a way for the simulator to process signals generated</span>
<a name="l00031"></a>00031 <span class="comment"> * by the native host system. Note that these signals in this context have</span>
<a name="l00032"></a>00032 <span class="comment"> * nothing to do with signals or interrupts as far as a program running in the</span>
<a name="l00033"></a>00033 <span class="comment"> * simulator is concerned. */</span>
<a name="l00034"></a>00034
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00036"></a>00036
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;errno.h&gt;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;signal.h&gt;</span>
<a name="l00042"></a>00042
<a name="l00043"></a>00043 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include "sig.h"</span>
<a name="l00045"></a>00045
<a name="l00046"></a>00046 <span class="keyword">static</span> <span class="keyword">volatile</span> <span class="keywordtype">int</span> global_got_sigint = 0;
<a name="l00047"></a>00047
<a name="l00048"></a>00048 <span class="comment">/*</span>
<a name="l00049"></a>00049 <span class="comment"> * Private.</span>
<a name="l00050"></a>00050 <span class="comment"> *</span>
<a name="l00051"></a>00051 <span class="comment"> * Handler for SIGINT signals. </span>
<a name="l00052"></a>00052 <span class="comment"> */</span>
<a name="l00053"></a>00053 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00054"></a>00054 signal_handle_sigint (<span class="keywordtype">int</span> signo)
<a name="l00055"></a>00055 {
<a name="l00056"></a>00056 global_got_sigint = 1;
<a name="l00057"></a>00057 }
<a name="l00058"></a>00058 <span class="comment"></span>
<a name="l00059"></a>00059 <span class="comment">/**</span>
<a name="l00060"></a>00060 <span class="comment"> * \brief Start watching for the occurrance of the given signal.</span>
<a name="l00061"></a>00061 <span class="comment"> *</span>
<a name="l00062"></a>00062 <span class="comment"> * This function will install a signal handler which will set a flag when the</span>
<a name="l00063"></a>00063 <span class="comment"> * signal occurs. Once the watch has been started, periodically call</span>
<a name="l00064"></a>00064 <span class="comment"> * signal_has_occurred() to check if the signal was raised. </span>
<a name="l00065"></a>00065 <span class="comment"> */</span>
<a name="l00066"></a>00066 <span class="keywordtype">void</span>
<a name="l00067"></a><a class="code" href="sig_8c.html#1a3fd779478f70244e210af9437c3ac5">00067</a> <a class="code" href="sig_8c.html#1a3fd779478f70244e210af9437c3ac5" title="Start watching for the occurrance of the given signal.">signal_watch_start</a> (<span class="keywordtype">int</span> signo)
<a name="l00068"></a>00068 {
<a name="l00069"></a>00069 <span class="keyword">struct </span>sigaction act, oact;
<a name="l00070"></a>00070
<a name="l00071"></a>00071 sigemptyset (&amp;act.sa_mask);
<a name="l00072"></a>00072 act.sa_flags = 0;
<a name="l00073"></a>00073
<a name="l00074"></a>00074 <span class="keywordflow">switch</span> (signo)
<a name="l00075"></a>00075 {
<a name="l00076"></a>00076 <span class="keywordflow">case</span> SIGINT:
<a name="l00077"></a>00077 global_got_sigint = 0;
<a name="l00078"></a>00078 act.sa_handler = signal_handle_sigint;
<a name="l00079"></a>00079 <span class="keywordflow">break</span>;
<a name="l00080"></a>00080 <span class="keywordflow">default</span>:
<a name="l00081"></a>00081 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"Invalid signal: %d\n"</span>, signo);
<a name="l00082"></a>00082 <span class="keywordflow">return</span>;
<a name="l00083"></a>00083 }
<a name="l00084"></a>00084
<a name="l00085"></a>00085 <span class="keywordflow">if</span> (sigaction (signo, &amp;act, &amp;oact) &lt; 0)
<a name="l00086"></a>00086 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"Failed to install signal handler: sig=%d: %s\n"</span>, signo,
<a name="l00087"></a>00087 strerror (errno));
<a name="l00088"></a>00088 }
<a name="l00089"></a>00089 <span class="comment"></span>
<a name="l00090"></a>00090 <span class="comment">/**</span>
<a name="l00091"></a>00091 <span class="comment"> * \brief Stop watching signal.</span>
<a name="l00092"></a>00092 <span class="comment"> *</span>
<a name="l00093"></a>00093 <span class="comment"> * Restores the default signal handler for the given signal and resets the</span>
<a name="l00094"></a>00094 <span class="comment"> * signal flag. </span>
<a name="l00095"></a>00095 <span class="comment"> */</span>
<a name="l00096"></a>00096 <span class="keywordtype">void</span>
<a name="l00097"></a><a class="code" href="sig_8c.html#4ef4dc91eb8d929844ea031c9cd85ede">00097</a> <a class="code" href="sig_8c.html#4ef4dc91eb8d929844ea031c9cd85ede" title="Stop watching signal.">signal_watch_stop</a> (<span class="keywordtype">int</span> signo)
<a name="l00098"></a>00098 {
<a name="l00099"></a>00099 <span class="keyword">struct </span>sigaction act, oact;
<a name="l00100"></a>00100
<a name="l00101"></a>00101 sigemptyset (&amp;act.sa_mask);
<a name="l00102"></a>00102 act.sa_flags = 0;
<a name="l00103"></a>00103 act.sa_handler = SIG_DFL;
<a name="l00104"></a>00104
<a name="l00105"></a>00105 <a class="code" href="sig_8c.html#fe45d9546c756459607ce4cbc98860e6" title="Clear the flag which indicates that a signal has ocurred.">signal_reset</a> (signo);
<a name="l00106"></a>00106
<a name="l00107"></a>00107 <span class="keywordflow">if</span> (sigaction (signo, &amp;act, &amp;oact) &lt; 0)
<a name="l00108"></a>00108 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"Failed to restore default signal handler: sig=%d: %s\n"</span>,
<a name="l00109"></a>00109 signo, strerror (errno));
<a name="l00110"></a>00110 }
<a name="l00111"></a>00111 <span class="comment"></span>
<a name="l00112"></a>00112 <span class="comment">/**</span>
<a name="l00113"></a>00113 <span class="comment"> * \brief Check to see if a signal has occurred.</span>
<a name="l00114"></a>00114 <span class="comment"> *</span>
<a name="l00115"></a>00115 <span class="comment"> * \return Non-zero if signal has occurred. The flag will always be reset</span>
<a name="l00116"></a>00116 <span class="comment"> * automatically. </span>
<a name="l00117"></a>00117 <span class="comment"> */</span>
<a name="l00118"></a>00118 <span class="keywordtype">int</span>
<a name="l00119"></a><a class="code" href="sig_8c.html#3aff57264b67d02a293d6e14a88b9c58">00119</a> <a class="code" href="sig_8c.html#3aff57264b67d02a293d6e14a88b9c58" title="Check to see if a signal has occurred.">signal_has_occurred</a> (<span class="keywordtype">int</span> signo)
<a name="l00120"></a>00120 {
<a name="l00121"></a>00121 <span class="keywordtype">int</span> res = 0;
<a name="l00122"></a>00122
<a name="l00123"></a>00123 <span class="keywordflow">switch</span> (signo)
<a name="l00124"></a>00124 {
<a name="l00125"></a>00125 <span class="keywordflow">case</span> SIGINT:
<a name="l00126"></a>00126 res = global_got_sigint;
<a name="l00127"></a>00127 global_got_sigint = 0;
<a name="l00128"></a>00128 <span class="keywordflow">break</span>;
<a name="l00129"></a>00129 <span class="keywordflow">default</span>:
<a name="l00130"></a>00130 <a class="code" href="avrerror_8c.html#0d89f34d142884b2f78e133c88c93170" title="Print a warning message to stderr.">avr_warning</a> (<span class="stringliteral">"Invalid signal: %d"</span>, signo);
<a name="l00131"></a>00131 }
<a name="l00132"></a>00132
<a name="l00133"></a>00133 <span class="keywordflow">return</span> res;
<a name="l00134"></a>00134 }
<a name="l00135"></a>00135 <span class="comment"></span>
<a name="l00136"></a>00136 <span class="comment">/**</span>
<a name="l00137"></a>00137 <span class="comment"> * \brief Clear the flag which indicates that a signal has ocurred.</span>
<a name="l00138"></a>00138 <span class="comment"> *</span>
<a name="l00139"></a>00139 <span class="comment"> * Use signal_reset to manually reset (i.e. clear) the flag.</span>
<a name="l00140"></a>00140 <span class="comment"> */</span>
<a name="l00141"></a>00141 <span class="keywordtype">void</span>
<a name="l00142"></a><a class="code" href="sig_8c.html#fe45d9546c756459607ce4cbc98860e6">00142</a> <a class="code" href="sig_8c.html#fe45d9546c756459607ce4cbc98860e6" title="Clear the flag which indicates that a signal has ocurred.">signal_reset</a> (<span class="keywordtype">int</span> signo)
<a name="l00143"></a>00143 {
<a name="l00144"></a>00144 <a class="code" href="sig_8c.html#3aff57264b67d02a293d6e14a88b9c58" title="Check to see if a signal has occurred.">signal_has_occurred</a> (signo);
<a name="l00145"></a>00145 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,162 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>sig.c File Reference</h1>Public interface to signal handlers. <a href="#_details">More...</a>
<p>
<p>
<a href="sig_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="sig_8c.html#1a3fd779478f70244e210af9437c3ac5">signal_watch_start</a> (int signo)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="sig_8c.html#4ef4dc91eb8d929844ea031c9cd85ede">signal_watch_stop</a> (int signo)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="sig_8c.html#3aff57264b67d02a293d6e14a88b9c58">signal_has_occurred</a> (int signo)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="sig_8c.html#fe45d9546c756459607ce4cbc98860e6">signal_reset</a> (int signo)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Public interface to signal handlers.
<p>
This module provides a way for the simulator to process signals generated by the native host system. Note that these signals in this context have nothing to do with signals or interrupts as far as a program running in the simulator is concerned.
<p>Definition in file <a class="el" href="sig_8c-source.html">sig.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="1a3fd779478f70244e210af9437c3ac5"></a><!-- doxytag: member="sig.c::signal_watch_start" ref="1a3fd779478f70244e210af9437c3ac5" args="(int signo)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void signal_watch_start </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>signo</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Start watching for the occurrance of the given signal.
<p>
This function will install a signal handler which will set a flag when the signal occurs. Once the watch has been started, periodically call <a class="el" href="sig_8c.html#3aff57264b67d02a293d6e14a88b9c58" title="Check to see if a signal has occurred.">signal_has_occurred()</a> to check if the signal was raised.
<p>Definition at line <a class="el" href="sig_8c-source.html#l00067">67</a> of file <a class="el" href="sig_8c-source.html">sig.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00046">avr_warning</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l01140">avr_core_run()</a>, and <a class="el" href="gdbserver_8c-source.html#l01320">gdb_interact()</a>.</p>
</div>
</div><p>
<a class="anchor" name="4ef4dc91eb8d929844ea031c9cd85ede"></a><!-- doxytag: member="sig.c::signal_watch_stop" ref="4ef4dc91eb8d929844ea031c9cd85ede" args="(int signo)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void signal_watch_stop </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>signo</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Stop watching signal.
<p>
Restores the default signal handler for the given signal and resets the signal flag.
<p>Definition at line <a class="el" href="sig_8c-source.html#l00097">97</a> of file <a class="el" href="sig_8c-source.html">sig.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00046">avr_warning</a>, and <a class="el" href="sig_8c-source.html#l00142">signal_reset()</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l01140">avr_core_run()</a>, and <a class="el" href="gdbserver_8c-source.html#l01320">gdb_interact()</a>.</p>
</div>
</div><p>
<a class="anchor" name="3aff57264b67d02a293d6e14a88b9c58"></a><!-- doxytag: member="sig.c::signal_has_occurred" ref="3aff57264b67d02a293d6e14a88b9c58" args="(int signo)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int signal_has_occurred </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>signo</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Check to see if a signal has occurred.
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>Non-zero if signal has occurred. The flag will always be reset automatically. </dd></dl>
<p>Definition at line <a class="el" href="sig_8c-source.html#l00119">119</a> of file <a class="el" href="sig_8c-source.html">sig.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00046">avr_warning</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l01140">avr_core_run()</a>, <a class="el" href="gdbserver_8c-source.html#l01320">gdb_interact()</a>, and <a class="el" href="sig_8c-source.html#l00142">signal_reset()</a>.</p>
</div>
</div><p>
<a class="anchor" name="fe45d9546c756459607ce4cbc98860e6"></a><!-- doxytag: member="sig.c::signal_reset" ref="fe45d9546c756459607ce4cbc98860e6" args="(int signo)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void signal_reset </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>signo</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Clear the flag which indicates that a signal has ocurred.
<p>
Use signal_reset to manually reset (i.e. clear) the flag.
<p>Definition at line <a class="el" href="sig_8c-source.html#l00142">142</a> of file <a class="el" href="sig_8c-source.html">sig.c</a>.</p>
<p>References <a class="el" href="sig_8c-source.html#l00119">signal_has_occurred()</a>.</p>
<p>Referenced by <a class="el" href="sig_8c-source.html#l00097">signal_watch_stop()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,519 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>spi.c</h1><a href="spi_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: spi.c,v 1.5 2004/03/13 19:55:34 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2003, 2004 Keith Gudger</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/**</span>
<a name="l00027"></a>00027 <span class="comment"> * \file spi.c</span>
<a name="l00028"></a>00028 <span class="comment"> * \brief Module to simulate the AVR's SPI module.</span>
<a name="l00029"></a>00029 <span class="comment"> *</span>
<a name="l00030"></a>00030 <span class="comment"> */</span>
<a name="l00031"></a>00031
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00033"></a>00033
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include "utils.h"</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include "callback.h"</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include "op_names.h"</span>
<a name="l00044"></a>00044
<a name="l00045"></a>00045 <span class="preprocessor">#include "storage.h"</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include "flash.h"</span>
<a name="l00047"></a>00047
<a name="l00048"></a>00048 <span class="preprocessor">#include "vdevs.h"</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include "memory.h"</span>
<a name="l00050"></a>00050 <span class="preprocessor">#include "stack.h"</span>
<a name="l00051"></a>00051 <span class="preprocessor">#include "register.h"</span>
<a name="l00052"></a>00052 <span class="preprocessor">#include "sram.h"</span>
<a name="l00053"></a>00053 <span class="preprocessor">#include "eeprom.h"</span>
<a name="l00054"></a>00054 <span class="preprocessor">#include "timers.h"</span>
<a name="l00055"></a>00055 <span class="preprocessor">#include "ports.h"</span>
<a name="l00056"></a>00056 <span class="preprocessor">#include "spi.h"</span>
<a name="l00057"></a>00057
<a name="l00058"></a>00058 <span class="preprocessor">#include "avrcore.h"</span>
<a name="l00059"></a>00059
<a name="l00060"></a>00060 <span class="preprocessor">#include "intvects.h"</span>
<a name="l00061"></a>00061
<a name="l00062"></a>00062 <span class="comment">/****************************************************************************\</span>
<a name="l00063"></a>00063 <span class="comment"> *</span>
<a name="l00064"></a>00064 <span class="comment"> * SPI Interrupts </span>
<a name="l00065"></a>00065 <span class="comment"> *</span>
<a name="l00066"></a>00066 <span class="comment">\****************************************************************************/</span>
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="keyword">static</span> <span class="keywordtype">void</span> spii_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr,
<a name="l00069"></a>00069 <span class="keywordtype">void</span> *data);
<a name="l00070"></a>00070 <span class="keyword">static</span> uint8_t spi_intr_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00071"></a>00071 <span class="keyword">static</span> <span class="keywordtype">void</span> spi_intr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00072"></a>00072 <span class="keyword">static</span> <span class="keywordtype">void</span> spi_intr_reset (VDevice *dev);
<a name="l00073"></a>00073 <span class="keyword">static</span> <span class="keywordtype">int</span> spi_intr_cb (uint64_t time, AvrClass *data);
<a name="l00074"></a>00074 <span class="comment"></span>
<a name="l00075"></a>00075 <span class="comment">/** \brief Allocate a new SPI interrupt */</span>
<a name="l00076"></a>00076
<a name="l00077"></a>00077 VDevice *
<a name="l00078"></a><a class="code" href="spi_8c.html#dce1c660a1d1605ba912d1c246ad38ae">00078</a> <a class="code" href="spi_8c.html#dce1c660a1d1605ba912d1c246ad38ae" title="Allocate a new SPI interrupt.">spii_create</a> (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00079"></a>00079 {
<a name="l00080"></a>00080 <span class="keywordflow">return</span> (VDevice *)spi_intr_new (addr, name);
<a name="l00081"></a>00081 }
<a name="l00082"></a>00082
<a name="l00083"></a>00083 SPIIntr_T *
<a name="l00084"></a>00084 spi_intr_new (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name)
<a name="l00085"></a>00085 {
<a name="l00086"></a>00086 SPIIntr_T *spi;
<a name="l00087"></a>00087
<a name="l00088"></a>00088 spi = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (SPIIntr_T, 1);
<a name="l00089"></a>00089 <a class="code" href="spi_8c.html#2d31cddf4f3c10bdb40e5aa74c98b87c" title="Constructor for spi interrupt object.">spi_intr_construct</a> (spi, addr, name);
<a name="l00090"></a>00090 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)spi, <a class="code" href="spi_8c.html#a7e63b808478f9afb300edaa7c6f1cd6" title="Destructor for spi interrupt object.">spi_intr_destroy</a>);
<a name="l00091"></a>00091
<a name="l00092"></a>00092 <span class="keywordflow">return</span> spi;
<a name="l00093"></a>00093 }
<a name="l00094"></a>00094 <span class="comment"></span>
<a name="l00095"></a>00095 <span class="comment">/** \brief Constructor for spi interrupt object. */</span>
<a name="l00096"></a>00096
<a name="l00097"></a>00097 <span class="keywordtype">void</span>
<a name="l00098"></a><a class="code" href="spi_8c.html#2d31cddf4f3c10bdb40e5aa74c98b87c">00098</a> <a class="code" href="spi_8c.html#2d31cddf4f3c10bdb40e5aa74c98b87c" title="Constructor for spi interrupt object.">spi_intr_construct</a> (SPIIntr_T *spi, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name)
<a name="l00099"></a>00099 {
<a name="l00100"></a>00100 <span class="keywordflow">if</span> (spi == NULL)
<a name="l00101"></a>00101 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00102"></a>00102
<a name="l00103"></a>00103 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)spi, spi_intr_read, spi_intr_write,
<a name="l00104"></a>00104 spi_intr_reset, spii_add_addr);
<a name="l00105"></a>00105
<a name="l00106"></a>00106 spii_add_addr ((VDevice *)spi, addr, name, 0, NULL);
<a name="l00107"></a>00107 spi_intr_reset ((VDevice *)spi);
<a name="l00108"></a>00108 }
<a name="l00109"></a>00109
<a name="l00110"></a>00110 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00111"></a>00111 spii_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00112"></a>00112 {
<a name="l00113"></a>00113 SPIIntr_T *spi = (SPIIntr_T *)vdev;
<a name="l00114"></a>00114
<a name="l00115"></a>00115 <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"SPCR"</span>, name, 4) == 0)
<a name="l00116"></a>00116 {
<a name="l00117"></a>00117 spi-&gt;spcr_addr = addr;
<a name="l00118"></a>00118 }
<a name="l00119"></a>00119
<a name="l00120"></a>00120 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"SPSR"</span>, name, 4) == 0)
<a name="l00121"></a>00121 {
<a name="l00122"></a>00122 spi-&gt;spsr_addr = addr;
<a name="l00123"></a>00123 }
<a name="l00124"></a>00124
<a name="l00125"></a>00125 <span class="keywordflow">else</span>
<a name="l00126"></a>00126 {
<a name="l00127"></a>00127 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"invalid ADC register name: '%s' @ 0x%04x"</span>, name, addr);
<a name="l00128"></a>00128 }
<a name="l00129"></a>00129 }
<a name="l00130"></a>00130 <span class="comment"></span>
<a name="l00131"></a>00131 <span class="comment">/** \brief Destructor for spi interrupt object. */</span>
<a name="l00132"></a>00132
<a name="l00133"></a>00133 <span class="keywordtype">void</span>
<a name="l00134"></a><a class="code" href="spi_8c.html#a7e63b808478f9afb300edaa7c6f1cd6">00134</a> <a class="code" href="spi_8c.html#a7e63b808478f9afb300edaa7c6f1cd6" title="Destructor for spi interrupt object.">spi_intr_destroy</a> (<span class="keywordtype">void</span> *spi)
<a name="l00135"></a>00135 {
<a name="l00136"></a>00136 <span class="keywordflow">if</span> (spi == NULL)
<a name="l00137"></a>00137 <span class="keywordflow">return</span>;
<a name="l00138"></a>00138
<a name="l00139"></a>00139 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (spi);
<a name="l00140"></a>00140 }
<a name="l00141"></a>00141
<a name="l00142"></a>00142 <span class="keyword">static</span> uint8_t
<a name="l00143"></a>00143 spi_intr_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00144"></a>00144 {
<a name="l00145"></a>00145 SPIIntr_T *spi = (SPIIntr_T *)dev;
<a name="l00146"></a>00146
<a name="l00147"></a>00147 <span class="keywordflow">if</span> (addr == spi-&gt;spcr_addr)
<a name="l00148"></a>00148 {
<a name="l00149"></a>00149 <span class="keywordflow">return</span> (spi-&gt;spcr);
<a name="l00150"></a>00150 }
<a name="l00151"></a>00151
<a name="l00152"></a>00152 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == spi-&gt;spsr_addr)
<a name="l00153"></a>00153 {
<a name="l00154"></a>00154 <span class="keywordflow">if</span> (spi-&gt;spsr &amp; mask_SPIF)
<a name="l00155"></a>00155 spi-&gt;spsr_read |= mask_SPIF;
<a name="l00156"></a>00156 <span class="keywordflow">if</span> (spi-&gt;spsr &amp; mask_WCOL)
<a name="l00157"></a>00157 spi-&gt;spsr_read |= mask_WCOL;
<a name="l00158"></a>00158 <span class="keywordflow">return</span> (spi-&gt;spsr);
<a name="l00159"></a>00159 }
<a name="l00160"></a>00160
<a name="l00161"></a>00161 <span class="keywordflow">else</span>
<a name="l00162"></a>00162 {
<a name="l00163"></a>00163 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00164"></a>00164 }
<a name="l00165"></a>00165
<a name="l00166"></a>00166 <span class="keywordflow">return</span> 0; <span class="comment">/* will never get here */</span>
<a name="l00167"></a>00167 }
<a name="l00168"></a>00168
<a name="l00169"></a>00169 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00170"></a>00170 spi_intr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00171"></a>00171 {
<a name="l00172"></a>00172 SPIIntr_T *spi = (SPIIntr_T *)dev;
<a name="l00173"></a>00173 CallBack *cb;
<a name="l00174"></a>00174
<a name="l00175"></a>00175 <span class="keywordflow">if</span> (addr == spi-&gt;spcr_addr)
<a name="l00176"></a>00176 {
<a name="l00177"></a>00177 spi-&gt;spcr = val;
<a name="l00178"></a>00178 <span class="keywordflow">if</span> (spi-&gt;spcr &amp; mask_SPE)
<a name="l00179"></a>00179 {
<a name="l00180"></a>00180 <span class="comment">/* we need to install the intr_cb function */</span>
<a name="l00181"></a>00181 cb = callback_new (spi_intr_cb, (AvrClass *)spi);
<a name="l00182"></a>00182 spi-&gt;intr_cb = cb;
<a name="l00183"></a>00183 <a class="code" href="avrcore_8c.html#e821588464c39dbdcc9fb5eea45da0aa" title="Add a new asynchronous callback to list.">avr_core_async_cb_add</a> ((AvrCore *)<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> (dev), cb);
<a name="l00184"></a>00184 }
<a name="l00185"></a>00185 <span class="keywordflow">else</span>
<a name="l00186"></a>00186 {
<a name="l00187"></a>00187 spi-&gt;intr_cb = NULL; <span class="comment">/* no interrupt are enabled, remove the</span>
<a name="l00188"></a>00188 <span class="comment"> callback */</span>
<a name="l00189"></a>00189 }
<a name="l00190"></a>00190 }
<a name="l00191"></a>00191
<a name="l00192"></a>00192 <span class="keywordflow">else</span>
<a name="l00193"></a>00193 {
<a name="l00194"></a>00194 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00195"></a>00195 }
<a name="l00196"></a>00196 }
<a name="l00197"></a>00197
<a name="l00198"></a>00198 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00199"></a>00199 spi_intr_reset (VDevice *dev)
<a name="l00200"></a>00200 {
<a name="l00201"></a>00201 SPIIntr_T *spi = (SPIIntr_T *)dev;
<a name="l00202"></a>00202
<a name="l00203"></a>00203 spi-&gt;intr_cb = NULL;
<a name="l00204"></a>00204
<a name="l00205"></a>00205 spi-&gt;spcr = 0;
<a name="l00206"></a>00206 spi-&gt;spsr = 0;
<a name="l00207"></a>00207 spi-&gt;spsr_read = 0;
<a name="l00208"></a>00208 }
<a name="l00209"></a>00209
<a name="l00210"></a>00210 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00211"></a>00211 spi_intr_cb (uint64_t time, AvrClass *data)
<a name="l00212"></a>00212 {
<a name="l00213"></a>00213 SPIIntr_T *spi = (SPIIntr_T *)data;
<a name="l00214"></a>00214
<a name="l00215"></a>00215 <span class="keywordflow">if</span> (spi-&gt;intr_cb == NULL)
<a name="l00216"></a>00216 <span class="keywordflow">return</span> CB_RET_REMOVE;
<a name="l00217"></a>00217
<a name="l00218"></a>00218 <span class="keywordflow">if</span> ((spi-&gt;spcr &amp; mask_SPE) &amp;&amp; (spi-&gt;spcr &amp; mask_SPIE)
<a name="l00219"></a>00219 &amp;&amp; (spi-&gt;spsr &amp; mask_SPIF))
<a name="l00220"></a>00220 {
<a name="l00221"></a>00221 <span class="comment">/* an enabled interrupt occured */</span>
<a name="l00222"></a>00222 AvrCore *core = (AvrCore *)<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)spi);
<a name="l00223"></a>00223 <a class="code" href="avrcore_8c.html#90ca5d4a60478f9fccad81724a4be552" title="Raises an irq by adding it&amp;#39;s data to the irq_pending list.">avr_core_irq_raise</a> (core, irq_vect_table_index (SPI_STC));
<a name="l00224"></a>00224 spi-&gt;spsr &amp;= ~mask_SPIF;
<a name="l00225"></a>00225 spi-&gt;spsr = 0;
<a name="l00226"></a>00226 }
<a name="l00227"></a>00227
<a name="l00228"></a>00228 <span class="keywordflow">return</span> CB_RET_RETAIN;
<a name="l00229"></a>00229 }
<a name="l00230"></a>00230
<a name="l00231"></a>00231 <span class="comment">/****************************************************************************\</span>
<a name="l00232"></a>00232 <span class="comment"> *</span>
<a name="l00233"></a>00233 <span class="comment"> * SPI </span>
<a name="l00234"></a>00234 <span class="comment"> *</span>
<a name="l00235"></a>00235 <span class="comment">\****************************************************************************/</span>
<a name="l00236"></a>00236
<a name="l00237"></a>00237 <span class="keyword">static</span> <span class="keywordtype">void</span> spi_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr,
<a name="l00238"></a>00238 <span class="keywordtype">void</span> *data);
<a name="l00239"></a>00239 <span class="keyword">static</span> uint8_t spi_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00240"></a>00240 <span class="keyword">static</span> <span class="keywordtype">void</span> spi_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00241"></a>00241 <span class="keyword">static</span> <span class="keywordtype">void</span> spi_reset (VDevice *dev);
<a name="l00242"></a>00242 <span class="keyword">static</span> <span class="keywordtype">int</span> spi_clk_incr_cb (uint64_t ck, AvrClass *data);
<a name="l00243"></a>00243 <span class="comment"></span>
<a name="l00244"></a>00244 <span class="comment">/** \brief Allocate a new SPI structure. */</span>
<a name="l00245"></a>00245
<a name="l00246"></a>00246 VDevice *
<a name="l00247"></a><a class="code" href="spi_8c.html#ef235e6fa60210d1f6c27d5884d0b23d">00247</a> <a class="code" href="spi_8c.html#ef235e6fa60210d1f6c27d5884d0b23d" title="Allocate a new SPI structure.">spi_create</a> (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00248"></a>00248 {
<a name="l00249"></a>00249 <span class="keywordflow">return</span> (VDevice *)spi_new (addr, name, rel_addr);
<a name="l00250"></a>00250 }
<a name="l00251"></a>00251
<a name="l00252"></a>00252 SPI_T *
<a name="l00253"></a>00253 spi_new (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr)
<a name="l00254"></a>00254 {
<a name="l00255"></a>00255 SPI_T *spi;
<a name="l00256"></a>00256
<a name="l00257"></a>00257 spi = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (SPI_T, 1);
<a name="l00258"></a>00258 <a class="code" href="spi_8c.html#d490c5d5f4d7e69e5d423ab461d66df5" title="Constructor for SPI object.">spi_construct</a> (spi, addr, name, rel_addr);
<a name="l00259"></a>00259 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)spi, <a class="code" href="spi_8c.html#9ef936c44048c70e2bc6227e64d27216" title="Destructor for SPI object.">spi_destroy</a>);
<a name="l00260"></a>00260
<a name="l00261"></a>00261 <span class="keywordflow">return</span> spi;
<a name="l00262"></a>00262 }
<a name="l00263"></a>00263 <span class="comment"></span>
<a name="l00264"></a>00264 <span class="comment">/** \brief Constructor for SPI object. */</span>
<a name="l00265"></a>00265
<a name="l00266"></a>00266 <span class="keywordtype">void</span>
<a name="l00267"></a><a class="code" href="spi_8c.html#d490c5d5f4d7e69e5d423ab461d66df5">00267</a> <a class="code" href="spi_8c.html#d490c5d5f4d7e69e5d423ab461d66df5" title="Constructor for SPI object.">spi_construct</a> (SPI_T *spi, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr)
<a name="l00268"></a>00268 {
<a name="l00269"></a>00269 <span class="keywordflow">if</span> (spi == NULL)
<a name="l00270"></a>00270 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00271"></a>00271
<a name="l00272"></a>00272 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)spi, spi_read, spi_write, spi_reset,
<a name="l00273"></a>00273 spi_add_addr);
<a name="l00274"></a>00274
<a name="l00275"></a>00275 spi_add_addr ((VDevice *)spi, addr, name, 0, NULL);
<a name="l00276"></a>00276 <span class="keywordflow">if</span> (rel_addr)
<a name="l00277"></a>00277 spi-&gt;rel_addr = rel_addr;
<a name="l00278"></a>00278 spi_reset ((VDevice *)spi);
<a name="l00279"></a>00279 }
<a name="l00280"></a>00280
<a name="l00281"></a>00281 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00282"></a>00282 spi_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> ref_addr, <span class="keywordtype">void</span> *data)
<a name="l00283"></a>00283 {
<a name="l00284"></a>00284 SPI_T *spi = (SPI_T *)vdev;
<a name="l00285"></a>00285
<a name="l00286"></a>00286 <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"SPDR"</span>, name, 4) == 0)
<a name="l00287"></a>00287 {
<a name="l00288"></a>00288 spi-&gt;spdr_addr = addr;
<a name="l00289"></a>00289 }
<a name="l00290"></a>00290
<a name="l00291"></a>00291 <span class="keywordflow">else</span>
<a name="l00292"></a>00292 {
<a name="l00293"></a>00293 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"invalid SPI register name: '%s' @ 0x%04x"</span>, name, addr);
<a name="l00294"></a>00294 }
<a name="l00295"></a>00295 }
<a name="l00296"></a>00296 <span class="comment"></span>
<a name="l00297"></a>00297 <span class="comment">/** \brief Destructor for SPI object. */</span>
<a name="l00298"></a>00298
<a name="l00299"></a>00299 <span class="keywordtype">void</span>
<a name="l00300"></a><a class="code" href="spi_8c.html#9ef936c44048c70e2bc6227e64d27216">00300</a> <a class="code" href="spi_8c.html#9ef936c44048c70e2bc6227e64d27216" title="Destructor for SPI object.">spi_destroy</a> (<span class="keywordtype">void</span> *spi)
<a name="l00301"></a>00301 {
<a name="l00302"></a>00302 <span class="keywordflow">if</span> (spi == NULL)
<a name="l00303"></a>00303 <span class="keywordflow">return</span>;
<a name="l00304"></a>00304
<a name="l00305"></a>00305 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (spi);
<a name="l00306"></a>00306 }
<a name="l00307"></a>00307
<a name="l00308"></a>00308 <span class="keyword">static</span> uint8_t
<a name="l00309"></a>00309 spi_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00310"></a>00310 {
<a name="l00311"></a>00311 SPI_T *spi = (SPI_T *)dev;
<a name="l00312"></a>00312 SPIIntr_T *spi_ti;
<a name="l00313"></a>00313
<a name="l00314"></a>00314 spi_ti =
<a name="l00315"></a>00315 (SPIIntr_T *)<a class="code" href="avrcore_8c.html#f0c70bc7f992dcacd8ab411993bea5b5" title="Returns the VDevice which handles the address addr.">avr_core_get_vdev_by_addr</a> ((AvrCore *)
<a name="l00316"></a>00316 <a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)
<a name="l00317"></a>00317 spi),
<a name="l00318"></a>00318 spi-&gt;rel_addr);
<a name="l00319"></a>00319
<a name="l00320"></a>00320 <span class="keywordflow">if</span> (addr == spi-&gt;spdr_addr)
<a name="l00321"></a>00321 {
<a name="l00322"></a>00322 <span class="keywordflow">if</span> (spi_ti-&gt;spsr_read)
<a name="l00323"></a>00323 {
<a name="l00324"></a>00324 spi_ti-&gt;spsr &amp;= ~spi_ti-&gt;spsr_read;
<a name="l00325"></a>00325 spi_ti-&gt;spsr_read = 0;
<a name="l00326"></a>00326 }
<a name="l00327"></a>00327 <span class="keywordflow">return</span> spi-&gt;spdr;
<a name="l00328"></a>00328
<a name="l00329"></a>00329 }
<a name="l00330"></a>00330
<a name="l00331"></a>00331 <span class="keywordflow">else</span>
<a name="l00332"></a>00332 {
<a name="l00333"></a>00333 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00334"></a>00334 }
<a name="l00335"></a>00335
<a name="l00336"></a>00336 <span class="keywordflow">return</span> 0; <span class="comment">/* will never get here */</span>
<a name="l00337"></a>00337 }
<a name="l00338"></a>00338
<a name="l00339"></a>00339 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00340"></a>00340 spi_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00341"></a>00341 {
<a name="l00342"></a>00342 SPI_T *spi = (SPI_T *)dev;
<a name="l00343"></a>00343 CallBack *cb;
<a name="l00344"></a>00344 SPIIntr_T *spi_ti;
<a name="l00345"></a>00345
<a name="l00346"></a>00346 spi_ti =
<a name="l00347"></a>00347 (SPIIntr_T *)<a class="code" href="avrcore_8c.html#f0c70bc7f992dcacd8ab411993bea5b5" title="Returns the VDevice which handles the address addr.">avr_core_get_vdev_by_addr</a> ((AvrCore *)
<a name="l00348"></a>00348 <a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)
<a name="l00349"></a>00349 spi),
<a name="l00350"></a>00350 spi-&gt;rel_addr);
<a name="l00351"></a>00351
<a name="l00352"></a>00352 <span class="keywordflow">if</span> (addr == spi-&gt;spdr_addr)
<a name="l00353"></a>00353 {
<a name="l00354"></a>00354 <span class="keywordflow">if</span> (spi_ti-&gt;spsr_read)
<a name="l00355"></a>00355 {
<a name="l00356"></a>00356 spi_ti-&gt;spsr &amp;= ~spi_ti-&gt;spsr_read;
<a name="l00357"></a>00357 spi_ti-&gt;spsr_read = 0;
<a name="l00358"></a>00358 }
<a name="l00359"></a>00359
<a name="l00360"></a>00360 <span class="keywordflow">if</span> (spi-&gt;tcnt != 0)
<a name="l00361"></a>00361 {
<a name="l00362"></a>00362 spi_ti-&gt;spsr |= mask_WCOL;
<a name="l00363"></a>00363 }
<a name="l00364"></a>00364
<a name="l00365"></a>00365 spi-&gt;spdr = val;
<a name="l00366"></a>00366
<a name="l00367"></a>00367 <span class="comment">/* When the user writes to SPDR, a callback is installed for either</span>
<a name="l00368"></a>00368 <span class="comment"> clock generated increments or externally generated increments. The</span>
<a name="l00369"></a>00369 <span class="comment"> two incrememtor callback are mutally exclusive, only one or the</span>
<a name="l00370"></a>00370 <span class="comment"> other can be installed at any given instant. */</span>
<a name="l00371"></a>00371
<a name="l00372"></a>00372 <span class="keywordflow">switch</span> ((spi_ti-&gt;spcr) &amp; (mask_SPR0 | mask_SPR1))
<a name="l00373"></a>00373 {
<a name="l00374"></a>00374 <span class="keywordflow">case</span> SPI_CK_4:
<a name="l00375"></a>00375 spi-&gt;divisor = 4;
<a name="l00376"></a>00376 <span class="keywordflow">break</span>;
<a name="l00377"></a>00377 <span class="keywordflow">case</span> SPI_CK_16:
<a name="l00378"></a>00378 spi-&gt;divisor = 16;
<a name="l00379"></a>00379 <span class="keywordflow">break</span>;
<a name="l00380"></a>00380 <span class="keywordflow">case</span> SPI_CK_64:
<a name="l00381"></a>00381 spi-&gt;divisor = 64;
<a name="l00382"></a>00382 <span class="keywordflow">break</span>;
<a name="l00383"></a>00383 <span class="keywordflow">case</span> SPI_CK_128:
<a name="l00384"></a>00384 spi-&gt;divisor = 128;
<a name="l00385"></a>00385 <span class="keywordflow">break</span>;
<a name="l00386"></a>00386 <span class="keywordflow">default</span>:
<a name="l00387"></a>00387 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"The impossible happened!"</span>);
<a name="l00388"></a>00388 }
<a name="l00389"></a>00389
<a name="l00390"></a>00390 <span class="comment">/* install the clock incrementor callback (with flair!) */</span>
<a name="l00391"></a>00391 <span class="keywordflow">if</span> (spi-&gt;clk_cb == NULL)
<a name="l00392"></a>00392 {
<a name="l00393"></a>00393 cb = callback_new (spi_clk_incr_cb, (AvrClass *)spi);
<a name="l00394"></a>00394 spi-&gt;clk_cb = cb;
<a name="l00395"></a>00395 <a class="code" href="avrcore_8c.html#3e755b8388c3c44ea514484ce53ace75" title="Add a new clock callback to list.">avr_core_clk_cb_add</a> ((AvrCore *)<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)spi),
<a name="l00396"></a>00396 cb);
<a name="l00397"></a>00397 }
<a name="l00398"></a>00398 spi-&gt;tcnt = 8; <span class="comment">/* set up timer for 8 clocks */</span>
<a name="l00399"></a>00399 spi-&gt;spdr_in = spi_port_rd (addr);
<a name="l00400"></a>00400 }
<a name="l00401"></a>00401 <span class="keywordflow">else</span>
<a name="l00402"></a>00402 {
<a name="l00403"></a>00403 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00404"></a>00404 }
<a name="l00405"></a>00405 }
<a name="l00406"></a>00406
<a name="l00407"></a>00407 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00408"></a>00408 spi_reset (VDevice *dev)
<a name="l00409"></a>00409 {
<a name="l00410"></a>00410 SPI_T *spi = (SPI_T *)dev;
<a name="l00411"></a>00411
<a name="l00412"></a>00412 spi-&gt;clk_cb = NULL;
<a name="l00413"></a>00413
<a name="l00414"></a>00414 spi-&gt;spdr = 0;
<a name="l00415"></a>00415 spi-&gt;tcnt = 0;
<a name="l00416"></a>00416
<a name="l00417"></a>00417 spi-&gt;divisor = 0;
<a name="l00418"></a>00418 }
<a name="l00419"></a>00419
<a name="l00420"></a>00420 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00421"></a>00421 spi_clk_incr_cb (uint64_t ck, AvrClass *data)
<a name="l00422"></a>00422 {
<a name="l00423"></a>00423 SPI_T *spi = (SPI_T *)data;
<a name="l00424"></a>00424 uint8_t last = spi-&gt;tcnt;
<a name="l00425"></a>00425 SPIIntr_T *spi_ti;
<a name="l00426"></a>00426
<a name="l00427"></a>00427 spi_ti =
<a name="l00428"></a>00428 (SPIIntr_T *)<a class="code" href="avrcore_8c.html#f0c70bc7f992dcacd8ab411993bea5b5" title="Returns the VDevice which handles the address addr.">avr_core_get_vdev_by_addr</a> ((AvrCore *)
<a name="l00429"></a>00429 <a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)
<a name="l00430"></a>00430 spi),
<a name="l00431"></a>00431 spi-&gt;rel_addr);
<a name="l00432"></a>00432
<a name="l00433"></a>00433 <span class="keywordflow">if</span> (spi-&gt;clk_cb == NULL)
<a name="l00434"></a>00434 <span class="keywordflow">return</span> CB_RET_REMOVE;
<a name="l00435"></a>00435
<a name="l00436"></a>00436 <span class="keywordflow">if</span> (spi-&gt;divisor &lt;= 0)
<a name="l00437"></a>00437 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad divisor value: %d"</span>, spi-&gt;divisor);
<a name="l00438"></a>00438
<a name="l00439"></a>00439 <span class="comment">/* Decrement clock if ck is a mutliple of divisor. Since divisor is always</span>
<a name="l00440"></a>00440 <span class="comment"> a power of 2, it's much faster to do the bitwise AND instead of using</span>
<a name="l00441"></a>00441 <span class="comment"> the integer modulus operator (%). */</span>
<a name="l00442"></a>00442 spi-&gt;tcnt -= ((ck &amp; (spi-&gt;divisor - 1)) == 0);
<a name="l00443"></a>00443
<a name="l00444"></a>00444 <span class="keywordflow">if</span> (spi-&gt;tcnt != last) <span class="comment">/* we've changed the counter */</span>
<a name="l00445"></a>00445 {
<a name="l00446"></a>00446 <span class="keywordflow">if</span> (spi-&gt;tcnt == 0)
<a name="l00447"></a>00447 {
<a name="l00448"></a>00448 spi_ti-&gt;spsr |= mask_SPIF; <span class="comment">/* spdr is not guaranteed until</span>
<a name="l00449"></a>00449 <span class="comment"> operation complete */</span>
<a name="l00450"></a>00450 spi_port_wr (spi-&gt;spdr); <span class="comment">/* tell what we wrote */</span>
<a name="l00451"></a>00451 spi-&gt;spdr = spi-&gt;spdr_in; <span class="comment">/* update spdr to what we read */</span>
<a name="l00452"></a>00452
<a name="l00453"></a>00453 spi-&gt;clk_cb = NULL;
<a name="l00454"></a>00454 <span class="keywordflow">return</span> CB_RET_REMOVE;
<a name="l00455"></a>00455 }
<a name="l00456"></a>00456 }
<a name="l00457"></a>00457
<a name="l00458"></a>00458 <span class="keywordflow">return</span> CB_RET_RETAIN;
<a name="l00459"></a>00459 }
<a name="l00460"></a>00460
<a name="l00461"></a>00461 <span class="comment">/* FIXME: TRoth/2003-11-28: These will eventually need to be plugged into an</span>
<a name="l00462"></a>00462 <span class="comment"> external connection interface. */</span>
<a name="l00463"></a>00463
<a name="l00464"></a>00464 uint8_t
<a name="l00465"></a>00465 spi_port_rd (<span class="keywordtype">int</span> addr)
<a name="l00466"></a>00466 {
<a name="l00467"></a>00467 <span class="keywordtype">int</span> data;
<a name="l00468"></a>00468 <span class="keywordtype">char</span> line[80];
<a name="l00469"></a>00469
<a name="l00470"></a>00470 <span class="keywordflow">while</span> (1)
<a name="l00471"></a>00471 {
<a name="l00472"></a>00472 fprintf (stderr,
<a name="l00473"></a>00473 <span class="stringliteral">"\nEnter a byte of hex data to read into the SPI at"</span>
<a name="l00474"></a>00474 <span class="stringliteral">" address 0x%04x: "</span>, addr);
<a name="l00475"></a>00475
<a name="l00476"></a>00476 <span class="comment">/* try to read in a line of input */</span>
<a name="l00477"></a>00477 <span class="keywordflow">if</span> (fgets (line, <span class="keyword">sizeof</span> (line), stdin) == NULL)
<a name="l00478"></a>00478 <span class="keywordflow">continue</span>;
<a name="l00479"></a>00479
<a name="l00480"></a>00480 <span class="comment">/* try to parse the line for a byte of data */</span>
<a name="l00481"></a>00481 <span class="keywordflow">if</span> (sscanf (line, <span class="stringliteral">"%x\n"</span>, &amp;data) != 1)
<a name="l00482"></a>00482 <span class="keywordflow">continue</span>;
<a name="l00483"></a>00483
<a name="l00484"></a>00484 <span class="keywordflow">break</span>;
<a name="l00485"></a>00485 }
<a name="l00486"></a>00486
<a name="l00487"></a>00487 <span class="keywordflow">return</span> (uint8_t) (data &amp; 0xff);
<a name="l00488"></a>00488 }
<a name="l00489"></a>00489
<a name="l00490"></a>00490 <span class="keywordtype">void</span>
<a name="l00491"></a>00491 spi_port_wr (uint8_t val)
<a name="l00492"></a>00492 {
<a name="l00493"></a>00493 fprintf (stderr, <span class="stringliteral">"wrote 0x%02x to SPI\n"</span>, val);
<a name="l00494"></a>00494 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,295 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>spi.c File Reference</h1>Module to simulate the AVR's SPI module. <a href="#_details">More...</a>
<p>
<p>
<a href="spi_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8c.html#dce1c660a1d1605ba912d1c246ad38ae">spii_create</a> (int addr, char *name, int rel_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="46d03eeb1cf40ce140257117cbcbc72b"></a><!-- doxytag: member="spi.c::spi_intr_new" ref="46d03eeb1cf40ce140257117cbcbc72b" args="(int addr, char *name)" -->
SPIIntr_T *&nbsp;</td><td class="memItemRight" valign="bottom"><b>spi_intr_new</b> (int addr, char *name)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8c.html#2d31cddf4f3c10bdb40e5aa74c98b87c">spi_intr_construct</a> (SPIIntr_T *spi, int addr, char *name)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8c.html#a7e63b808478f9afb300edaa7c6f1cd6">spi_intr_destroy</a> (void *spi)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8c.html#ef235e6fa60210d1f6c27d5884d0b23d">spi_create</a> (int addr, char *name, int rel_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="2dfe3896e22e58b962e83ef4314ffbe0"></a><!-- doxytag: member="spi.c::spi_new" ref="2dfe3896e22e58b962e83ef4314ffbe0" args="(int addr, char *name, int rel_addr)" -->
SPI_T *&nbsp;</td><td class="memItemRight" valign="bottom"><b>spi_new</b> (int addr, char *name, int rel_addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8c.html#d490c5d5f4d7e69e5d423ab461d66df5">spi_construct</a> (SPI_T *spi, int addr, char *name, int rel_addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="spi_8c.html#9ef936c44048c70e2bc6227e64d27216">spi_destroy</a> (void *spi)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="8746341763540108f5ef38863a70750d"></a><!-- doxytag: member="spi.c::spi_port_rd" ref="8746341763540108f5ef38863a70750d" args="(int addr)" -->
uint8_t&nbsp;</td><td class="memItemRight" valign="bottom"><b>spi_port_rd</b> (int addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="edbc629e959c45cb66ca20a4a2f36a3c"></a><!-- doxytag: member="spi.c::spi_port_wr" ref="edbc629e959c45cb66ca20a4a2f36a3c" args="(uint8_t val)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><b>spi_port_wr</b> (uint8_t val)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Module to simulate the AVR's SPI module.
<p>
<p>Definition in file <a class="el" href="spi_8c-source.html">spi.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="dce1c660a1d1605ba912d1c246ad38ae"></a><!-- doxytag: member="spi.c::spii_create" ref="dce1c660a1d1605ba912d1c246ad38ae" args="(int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* spii_create </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new SPI interrupt.
<p>
<p>Definition at line <a class="el" href="spi_8c-source.html#l00078">78</a> of file <a class="el" href="spi_8c-source.html">spi.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="2d31cddf4f3c10bdb40e5aa74c98b87c"></a><!-- doxytag: member="spi.c::spi_intr_construct" ref="2d31cddf4f3c10bdb40e5aa74c98b87c" args="(SPIIntr_T *spi, int addr, char *name)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void spi_intr_construct </td>
<td>(</td>
<td class="paramtype">SPIIntr_T *&nbsp;</td>
<td class="paramname"> <em>spi</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for spi interrupt object.
<p>
<p>Definition at line <a class="el" href="spi_8c-source.html#l00098">98</a> of file <a class="el" href="spi_8c-source.html">spi.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="a7e63b808478f9afb300edaa7c6f1cd6"></a><!-- doxytag: member="spi.c::spi_intr_destroy" ref="a7e63b808478f9afb300edaa7c6f1cd6" args="(void *spi)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void spi_intr_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>spi</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for spi interrupt object.
<p>
<p>Definition at line <a class="el" href="spi_8c-source.html#l00134">134</a> of file <a class="el" href="spi_8c-source.html">spi.c</a>.</p>
<p>References <a class="el" href="device_8c-source.html#l00105">vdev_destroy()</a>.</p>
</div>
</div><p>
<a class="anchor" name="ef235e6fa60210d1f6c27d5884d0b23d"></a><!-- doxytag: member="spi.c::spi_create" ref="ef235e6fa60210d1f6c27d5884d0b23d" args="(int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* spi_create </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new SPI structure.
<p>
<p>Definition at line <a class="el" href="spi_8c-source.html#l00247">247</a> of file <a class="el" href="spi_8c-source.html">spi.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="d490c5d5f4d7e69e5d423ab461d66df5"></a><!-- doxytag: member="spi.c::spi_construct" ref="d490c5d5f4d7e69e5d423ab461d66df5" args="(SPI_T *spi, int addr, char *name, int rel_addr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void spi_construct </td>
<td>(</td>
<td class="paramtype">SPI_T *&nbsp;</td>
<td class="paramname"> <em>spi</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for SPI object.
<p>
<p>Definition at line <a class="el" href="spi_8c-source.html#l00267">267</a> of file <a class="el" href="spi_8c-source.html">spi.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="9ef936c44048c70e2bc6227e64d27216"></a><!-- doxytag: member="spi.c::spi_destroy" ref="9ef936c44048c70e2bc6227e64d27216" args="(void *spi)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void spi_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>spi</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for SPI object.
<p>
<p>Definition at line <a class="el" href="spi_8c-source.html#l00300">300</a> of file <a class="el" href="spi_8c-source.html">spi.c</a>.</p>
<p>References <a class="el" href="device_8c-source.html#l00105">vdev_destroy()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,153 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>sram.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: sram.c,v 1.10 2004/01/30 07:09:56 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003, 2004 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00030"></a>00030
<a name="l00031"></a>00031 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include "utils.h"</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include "callback.h"</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include "op_names.h"</span>
<a name="l00037"></a>00037
<a name="l00038"></a>00038 <span class="preprocessor">#include "storage.h"</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include "flash.h"</span>
<a name="l00040"></a>00040
<a name="l00041"></a>00041 <span class="preprocessor">#include "vdevs.h"</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include "memory.h"</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include "stack.h"</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include "register.h"</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include "sram.h"</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include "eeprom.h"</span>
<a name="l00047"></a>00047 <span class="preprocessor">#include "timers.h"</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include "ports.h"</span>
<a name="l00049"></a>00049
<a name="l00050"></a>00050 <span class="preprocessor">#include "avrcore.h"</span>
<a name="l00051"></a>00051
<a name="l00052"></a>00052 <span class="preprocessor">#include "display.h"</span>
<a name="l00053"></a>00053
<a name="l00054"></a>00054 <span class="keyword">static</span> uint8_t sram_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00055"></a>00055 <span class="keyword">static</span> <span class="keywordtype">void</span> sram_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00056"></a>00056 <span class="keyword">static</span> <span class="keywordtype">void</span> sram_reset (VDevice *dev);
<a name="l00057"></a>00057
<a name="l00058"></a>00058 SRAM *
<a name="l00059"></a>00059 sram_new (<span class="keywordtype">int</span> base, <span class="keywordtype">int</span> size)
<a name="l00060"></a>00060 {
<a name="l00061"></a>00061 SRAM *sram;
<a name="l00062"></a>00062
<a name="l00063"></a>00063 sram = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (SRAM, 1);
<a name="l00064"></a>00064 sram_construct (sram, base, size);
<a name="l00065"></a>00065 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)sram, sram_destroy);
<a name="l00066"></a>00066
<a name="l00067"></a>00067 <span class="keywordflow">return</span> sram;
<a name="l00068"></a>00068 }
<a name="l00069"></a>00069
<a name="l00070"></a>00070 <span class="keywordtype">void</span>
<a name="l00071"></a>00071 sram_construct (SRAM *sram, <span class="keywordtype">int</span> base, <span class="keywordtype">int</span> size)
<a name="l00072"></a>00072 {
<a name="l00073"></a>00073 <span class="keywordflow">if</span> (sram == NULL)
<a name="l00074"></a>00074 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00075"></a>00075
<a name="l00076"></a>00076 sram-&gt;stor = storage_new (base, size);
<a name="l00077"></a>00077 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)sram, sram_read, sram_write, sram_reset,
<a name="l00078"></a>00078 <a class="code" href="device_8c.html#5cebfd18a219807f27e4a3f38da4a5d0" title="Default AddAddr method.">vdev_def_AddAddr</a>);
<a name="l00079"></a>00079 }
<a name="l00080"></a>00080
<a name="l00081"></a>00081 <span class="keywordtype">void</span>
<a name="l00082"></a>00082 sram_destroy (<span class="keywordtype">void</span> *sram)
<a name="l00083"></a>00083 {
<a name="l00084"></a>00084 SRAM *_sram = (SRAM *)sram;
<a name="l00085"></a>00085
<a name="l00086"></a>00086 <span class="keywordflow">if</span> (sram == NULL)
<a name="l00087"></a>00087 <span class="keywordflow">return</span>;
<a name="l00088"></a>00088
<a name="l00089"></a>00089 <a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a> ((AvrClass *)_sram-&gt;stor);
<a name="l00090"></a>00090
<a name="l00091"></a>00091 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (sram);
<a name="l00092"></a>00092 }
<a name="l00093"></a>00093
<a name="l00094"></a>00094 <span class="keywordtype">int</span>
<a name="l00095"></a>00095 sram_get_size (SRAM *sram)
<a name="l00096"></a>00096 {
<a name="l00097"></a>00097 <span class="keywordflow">return</span> storage_get_size (sram-&gt;stor);
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099
<a name="l00100"></a>00100 <span class="keywordtype">int</span>
<a name="l00101"></a>00101 sram_get_base (SRAM *sram)
<a name="l00102"></a>00102 {
<a name="l00103"></a>00103 <span class="keywordflow">return</span> storage_get_base (sram-&gt;stor);
<a name="l00104"></a>00104 }
<a name="l00105"></a>00105
<a name="l00106"></a>00106 <span class="keyword">static</span> uint8_t
<a name="l00107"></a>00107 sram_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00108"></a>00108 {
<a name="l00109"></a>00109 SRAM *sram = (SRAM *)dev;
<a name="l00110"></a>00110
<a name="l00111"></a>00111 <span class="keywordflow">return</span> storage_readb (sram-&gt;stor, addr);
<a name="l00112"></a>00112 }
<a name="l00113"></a>00113
<a name="l00114"></a>00114 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00115"></a>00115 sram_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00116"></a>00116 {
<a name="l00117"></a>00117 SRAM *sram = (SRAM *)dev;
<a name="l00118"></a>00118
<a name="l00119"></a>00119 <a class="code" href="display_8c.html#8cfda7ebd92c20bf3376e0355f80bebe" title="Update a block of sram addresses in the display.">display_sram</a> (addr, 1, &amp;val);
<a name="l00120"></a>00120
<a name="l00121"></a>00121 storage_writeb (sram-&gt;stor, addr, val);
<a name="l00122"></a>00122 }
<a name="l00123"></a>00123
<a name="l00124"></a>00124 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00125"></a>00125 sram_reset (VDevice *dev)
<a name="l00126"></a>00126 {
<a name="l00127"></a>00127 <span class="keywordflow">return</span>; <span class="comment">/* FIXME: should the array be cleared? */</span>
<a name="l00128"></a>00128 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,505 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>stack.c</h1><a href="stack_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: stack.c,v 1.15 2004/01/30 07:09:56 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003, 2004 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/** \file stack.c</span>
<a name="l00027"></a>00027 <span class="comment"> \brief Module for the definition of the stack. </span>
<a name="l00028"></a>00028 <span class="comment"></span>
<a name="l00029"></a>00029 <span class="comment"> Defines the classes stack, hw_stack, and mem_stack.</span>
<a name="l00030"></a>00030 <span class="comment"></span>
<a name="l00031"></a>00031 <span class="comment"> FIXME: Ted, I would really really really love to put in a description of</span>
<a name="l00032"></a>00032 <span class="comment"> what is the difference between these three classes and how they're used,</span>
<a name="l00033"></a>00033 <span class="comment"> but I don't understand it myself. */</span>
<a name="l00034"></a>00034
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00036"></a>00036
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00040"></a>00040
<a name="l00041"></a>00041 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include "utils.h"</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include "callback.h"</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include "op_names.h"</span>
<a name="l00047"></a>00047
<a name="l00048"></a>00048 <span class="preprocessor">#include "storage.h"</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include "flash.h"</span>
<a name="l00050"></a>00050
<a name="l00051"></a>00051 <span class="preprocessor">#include "vdevs.h"</span>
<a name="l00052"></a>00052 <span class="preprocessor">#include "memory.h"</span>
<a name="l00053"></a>00053 <span class="preprocessor">#include "stack.h"</span>
<a name="l00054"></a>00054 <span class="preprocessor">#include "register.h"</span>
<a name="l00055"></a>00055 <span class="preprocessor">#include "sram.h"</span>
<a name="l00056"></a>00056 <span class="preprocessor">#include "eeprom.h"</span>
<a name="l00057"></a>00057 <span class="preprocessor">#include "timers.h"</span>
<a name="l00058"></a>00058 <span class="preprocessor">#include "ports.h"</span>
<a name="l00059"></a>00059
<a name="l00060"></a>00060 <span class="preprocessor">#include "avrcore.h"</span>
<a name="l00061"></a>00061
<a name="l00062"></a>00062 <span class="preprocessor">#include "display.h"</span>
<a name="l00063"></a>00063
<a name="l00064"></a>00064 <span class="keyword">static</span> uint32_t hw_pop (Stack *stack, <span class="keywordtype">int</span> bytes);
<a name="l00065"></a>00065 <span class="keyword">static</span> <span class="keywordtype">void</span> hw_push (Stack *stack, <span class="keywordtype">int</span> bytes, uint32_t val);
<a name="l00066"></a>00066
<a name="l00067"></a>00067 <span class="keyword">static</span> uint32_t mem_pop (Stack *stack, <span class="keywordtype">int</span> bytes);
<a name="l00068"></a>00068 <span class="keyword">static</span> <span class="keywordtype">void</span> mem_push (Stack *stack, <span class="keywordtype">int</span> bytes, uint32_t val);
<a name="l00069"></a>00069
<a name="l00070"></a>00070 <span class="comment">/****************************************************************************\</span>
<a name="l00071"></a>00071 <span class="comment"> *</span>
<a name="l00072"></a>00072 <span class="comment"> * Stack(AvrClass) Definition. </span>
<a name="l00073"></a>00073 <span class="comment"> *</span>
<a name="l00074"></a>00074 <span class="comment">\****************************************************************************/</span>
<a name="l00075"></a>00075 <span class="comment"></span>
<a name="l00076"></a>00076 <span class="comment">/** \brief Allocates memory for a new Stack object</span>
<a name="l00077"></a>00077 <span class="comment"></span>
<a name="l00078"></a>00078 <span class="comment"> This is a virtual method for higher level stack implementations and as</span>
<a name="l00079"></a>00079 <span class="comment"> such should not be used directly. */</span>
<a name="l00080"></a>00080
<a name="l00081"></a>00081 Stack *
<a name="l00082"></a><a class="code" href="stack_8c.html#83de2962ed4166699cc8f40edcc1f380">00082</a> <a class="code" href="stack_8c.html#83de2962ed4166699cc8f40edcc1f380" title="Allocates memory for a new Stack object.">stack_new</a> (StackFP_Pop pop, StackFP_Push push)
<a name="l00083"></a>00083 {
<a name="l00084"></a>00084 Stack *st;
<a name="l00085"></a>00085
<a name="l00086"></a>00086 st = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (Stack, 1);
<a name="l00087"></a>00087 <a class="code" href="stack_8c.html#119a7d0b0be8ef37e798c8f9c6ae4722" title="Constructor for the Stack class.">stack_construct</a> (st, pop, push);
<a name="l00088"></a>00088 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)st, <a class="code" href="stack_8c.html#c6c460b2f72e2a2095cd70b4414d4933" title="Destructor for the Stack class.">stack_destroy</a>);
<a name="l00089"></a>00089
<a name="l00090"></a>00090 <span class="keywordflow">return</span> st;
<a name="l00091"></a>00091 }
<a name="l00092"></a>00092 <span class="comment"></span>
<a name="l00093"></a>00093 <span class="comment">/** \brief Constructor for the Stack class.</span>
<a name="l00094"></a>00094 <span class="comment"></span>
<a name="l00095"></a>00095 <span class="comment"> This is a virtual method for higher level stack implementations and as</span>
<a name="l00096"></a>00096 <span class="comment"> such should not be used directly. */</span>
<a name="l00097"></a>00097
<a name="l00098"></a>00098 <span class="keywordtype">void</span>
<a name="l00099"></a><a class="code" href="stack_8c.html#119a7d0b0be8ef37e798c8f9c6ae4722">00099</a> <a class="code" href="stack_8c.html#119a7d0b0be8ef37e798c8f9c6ae4722" title="Constructor for the Stack class.">stack_construct</a> (Stack *stack, StackFP_Pop pop, StackFP_Push push)
<a name="l00100"></a>00100 {
<a name="l00101"></a>00101 <span class="keywordflow">if</span> (stack == NULL)
<a name="l00102"></a>00102 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00103"></a>00103
<a name="l00104"></a>00104 <a class="code" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e" title="Initializes the AvrClass data structure.">class_construct</a> ((AvrClass *)stack);
<a name="l00105"></a>00105
<a name="l00106"></a>00106 stack-&gt;pop = pop;
<a name="l00107"></a>00107 stack-&gt;push = push;
<a name="l00108"></a>00108 }
<a name="l00109"></a>00109 <span class="comment"></span>
<a name="l00110"></a>00110 <span class="comment">/** \brief Destructor for the Stack class.</span>
<a name="l00111"></a>00111 <span class="comment"></span>
<a name="l00112"></a>00112 <span class="comment"> This is a virtual method for higher level stack implementations and as</span>
<a name="l00113"></a>00113 <span class="comment"> such should not be used directly. */</span>
<a name="l00114"></a>00114
<a name="l00115"></a>00115 <span class="keywordtype">void</span>
<a name="l00116"></a><a class="code" href="stack_8c.html#c6c460b2f72e2a2095cd70b4414d4933">00116</a> <a class="code" href="stack_8c.html#c6c460b2f72e2a2095cd70b4414d4933" title="Destructor for the Stack class.">stack_destroy</a> (<span class="keywordtype">void</span> *stack)
<a name="l00117"></a>00117 {
<a name="l00118"></a>00118 <span class="keywordflow">if</span> (stack == NULL)
<a name="l00119"></a>00119 <span class="keywordflow">return</span>;
<a name="l00120"></a>00120
<a name="l00121"></a>00121 <a class="code" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5" title="Releases resources allocated by class&amp;#39;s &amp;lt;klass&amp;gt;_new() function.">class_destroy</a> (stack);
<a name="l00122"></a>00122 }
<a name="l00123"></a>00123 <span class="comment"></span>
<a name="l00124"></a>00124 <span class="comment">/** \brief Pops a byte or a word off the stack and returns it.</span>
<a name="l00125"></a>00125 <span class="comment"> \param stack A pointer to the Stack object from which to pop</span>
<a name="l00126"></a>00126 <span class="comment"> \param bytes Number of bytes to pop off the stack (1 to 4 bytes).</span>
<a name="l00127"></a>00127 <span class="comment"></span>
<a name="l00128"></a>00128 <span class="comment"> \return The 1 to 4 bytes value popped from the stack. </span>
<a name="l00129"></a>00129 <span class="comment"></span>
<a name="l00130"></a>00130 <span class="comment"> This method provides access to the derived class's pop() method. */</span>
<a name="l00131"></a>00131
<a name="l00132"></a>00132 uint32_t
<a name="l00133"></a><a class="code" href="stack_8c.html#9077dfc6f98c4fe4b51b43db90055aaa">00133</a> <a class="code" href="stack_8c.html#9077dfc6f98c4fe4b51b43db90055aaa" title="Pops a byte or a word off the stack and returns it.">stack_pop</a> (Stack *stack, <span class="keywordtype">int</span> bytes)
<a name="l00134"></a>00134 {
<a name="l00135"></a>00135 <span class="keywordflow">return</span> stack-&gt;pop (stack, bytes);
<a name="l00136"></a>00136 }
<a name="l00137"></a>00137 <span class="comment"></span>
<a name="l00138"></a>00138 <span class="comment">/** \brief Pushes a byte or a word of data onto the stack.</span>
<a name="l00139"></a>00139 <span class="comment"> \param stack A pointer to the Stack object from which to pop.</span>
<a name="l00140"></a>00140 <span class="comment"> \param bytes Size of the value being pushed onto the stack (1 to 4 bytes).</span>
<a name="l00141"></a>00141 <span class="comment"> \param val The value to be pushed.</span>
<a name="l00142"></a>00142 <span class="comment"></span>
<a name="l00143"></a>00143 <span class="comment"> This method provides access to the derived class's push() method. */</span>
<a name="l00144"></a>00144
<a name="l00145"></a>00145 <span class="keywordtype">void</span>
<a name="l00146"></a><a class="code" href="stack_8c.html#bd76f1a4f5bfc1e2b8699f3787cf7af2">00146</a> <a class="code" href="stack_8c.html#bd76f1a4f5bfc1e2b8699f3787cf7af2" title="Pushes a byte or a word of data onto the stack.">stack_push</a> (Stack *stack, <span class="keywordtype">int</span> bytes, uint32_t val)
<a name="l00147"></a>00147 {
<a name="l00148"></a>00148 stack-&gt;push (stack, bytes, val);
<a name="l00149"></a>00149 }
<a name="l00150"></a>00150
<a name="l00151"></a>00151 <span class="comment">/****************************************************************************\</span>
<a name="l00152"></a>00152 <span class="comment"> *</span>
<a name="l00153"></a>00153 <span class="comment"> * HWStack(Stack) Definition.</span>
<a name="l00154"></a>00154 <span class="comment"> *</span>
<a name="l00155"></a>00155 <span class="comment">\****************************************************************************/</span>
<a name="l00156"></a>00156 <span class="comment"></span>
<a name="l00157"></a>00157 <span class="comment">/** \brief Allocate a new HWStack object</span>
<a name="l00158"></a>00158 <span class="comment"></span>
<a name="l00159"></a>00159 <span class="comment"> This is the stack implementation used by devices which lack SRAM and only</span>
<a name="l00160"></a>00160 <span class="comment"> have a fixed size hardware stack (e.i., the at90s1200) */</span>
<a name="l00161"></a>00161
<a name="l00162"></a>00162 HWStack *
<a name="l00163"></a><a class="code" href="stack_8c.html#f9b8a6ec32f0798480f4bd02733996b1">00163</a> <a class="code" href="stack_8c.html#f9b8a6ec32f0798480f4bd02733996b1" title="Allocate a new HWStack object.">hwstack_new</a> (<span class="keywordtype">int</span> depth)
<a name="l00164"></a>00164 {
<a name="l00165"></a>00165 HWStack *st;
<a name="l00166"></a>00166
<a name="l00167"></a>00167 st = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (HWStack, 1);
<a name="l00168"></a>00168 <a class="code" href="stack_8c.html#d02c1ea58dfb09cff13e4ad524bb8797" title="Constructor for HWStack object.">hwstack_construct</a> (st, depth);
<a name="l00169"></a>00169 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)st, <a class="code" href="stack_8c.html#837cbada76cb76af5aa46618d90ea00e" title="Destructor for HWStack object.">hwstack_destroy</a>);
<a name="l00170"></a>00170
<a name="l00171"></a>00171 <span class="keywordflow">return</span> st;
<a name="l00172"></a>00172 }
<a name="l00173"></a>00173 <span class="comment"></span>
<a name="l00174"></a>00174 <span class="comment">/** \brief Constructor for HWStack object */</span>
<a name="l00175"></a>00175
<a name="l00176"></a>00176 <span class="keywordtype">void</span>
<a name="l00177"></a><a class="code" href="stack_8c.html#d02c1ea58dfb09cff13e4ad524bb8797">00177</a> <a class="code" href="stack_8c.html#d02c1ea58dfb09cff13e4ad524bb8797" title="Constructor for HWStack object.">hwstack_construct</a> (HWStack *stack, <span class="keywordtype">int</span> depth)
<a name="l00178"></a>00178 {
<a name="l00179"></a>00179 <span class="keywordflow">if</span> (stack == NULL)
<a name="l00180"></a>00180 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00181"></a>00181
<a name="l00182"></a>00182 <a class="code" href="stack_8c.html#119a7d0b0be8ef37e798c8f9c6ae4722" title="Constructor for the Stack class.">stack_construct</a> ((Stack *)stack, hw_pop, hw_push);
<a name="l00183"></a>00183
<a name="l00184"></a>00184 stack-&gt;depth = depth;
<a name="l00185"></a>00185 stack-&gt;stack = <a class="code" href="avrmalloc_8c.html#ac6d810b48b67b90412badbd4b71f4e3" title="Macro for allocating memory and initializing it to zero.">avr_new0</a> (uint32_t, depth);
<a name="l00186"></a>00186 }
<a name="l00187"></a>00187 <span class="comment"></span>
<a name="l00188"></a>00188 <span class="comment">/** \brief Destructor for HWStack object */</span>
<a name="l00189"></a>00189
<a name="l00190"></a>00190 <span class="keywordtype">void</span>
<a name="l00191"></a><a class="code" href="stack_8c.html#837cbada76cb76af5aa46618d90ea00e">00191</a> <a class="code" href="stack_8c.html#837cbada76cb76af5aa46618d90ea00e" title="Destructor for HWStack object.">hwstack_destroy</a> (<span class="keywordtype">void</span> *stack)
<a name="l00192"></a>00192 {
<a name="l00193"></a>00193 <span class="keywordflow">if</span> (stack == NULL)
<a name="l00194"></a>00194 <span class="keywordflow">return</span>;
<a name="l00195"></a>00195
<a name="l00196"></a>00196 <a class="code" href="avrmalloc_8c.html#082a9d6d40f5e8bad64441ad950ec12c" title="Free malloc&amp;#39;d memory.">avr_free</a> (((HWStack *)stack)-&gt;stack);
<a name="l00197"></a>00197 <a class="code" href="stack_8c.html#c6c460b2f72e2a2095cd70b4414d4933" title="Destructor for the Stack class.">stack_destroy</a> (stack);
<a name="l00198"></a>00198 }
<a name="l00199"></a>00199
<a name="l00200"></a>00200 <span class="comment">/* The HWStack pop method. */</span>
<a name="l00201"></a>00201
<a name="l00202"></a>00202 <span class="keyword">static</span> uint32_t
<a name="l00203"></a>00203 hw_pop (Stack *stack, <span class="keywordtype">int</span> bytes)
<a name="l00204"></a>00204 {
<a name="l00205"></a>00205 HWStack *hwst = (HWStack *)stack;
<a name="l00206"></a>00206 <span class="keywordtype">int</span> i;
<a name="l00207"></a>00207 uint32_t val = hwst-&gt;stack[0];
<a name="l00208"></a>00208
<a name="l00209"></a>00209 <span class="keywordflow">for</span> (i = 0; i &lt; (hwst-&gt;depth - 1); i++)
<a name="l00210"></a>00210 {
<a name="l00211"></a>00211 hwst-&gt;stack[i] = hwst-&gt;stack[i + 1];
<a name="l00212"></a>00212 }
<a name="l00213"></a>00213
<a name="l00214"></a>00214 <span class="keywordflow">return</span> val;
<a name="l00215"></a>00215 }
<a name="l00216"></a>00216
<a name="l00217"></a>00217 <span class="comment">/* The HWStack push method. */</span>
<a name="l00218"></a>00218
<a name="l00219"></a>00219 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00220"></a>00220 hw_push (Stack *stack, <span class="keywordtype">int</span> bytes, uint32_t val)
<a name="l00221"></a>00221 {
<a name="l00222"></a>00222 HWStack *hwst = (HWStack *)stack;
<a name="l00223"></a>00223 <span class="keywordtype">int</span> i;
<a name="l00224"></a>00224
<a name="l00225"></a>00225 <span class="keywordflow">for</span> (i = (hwst-&gt;depth - 1); i; i--)
<a name="l00226"></a>00226 {
<a name="l00227"></a>00227 hwst-&gt;stack[i - 1] = hwst-&gt;stack[i];
<a name="l00228"></a>00228 }
<a name="l00229"></a>00229
<a name="l00230"></a>00230 hwst-&gt;stack[0] = val;
<a name="l00231"></a>00231 }
<a name="l00232"></a>00232
<a name="l00233"></a>00233 <span class="comment">/****************************************************************************\</span>
<a name="l00234"></a>00234 <span class="comment"> *</span>
<a name="l00235"></a>00235 <span class="comment"> * StackPointer(VDevice) Definition.</span>
<a name="l00236"></a>00236 <span class="comment"> *</span>
<a name="l00237"></a>00237 <span class="comment">\****************************************************************************/</span>
<a name="l00238"></a>00238
<a name="l00239"></a>00239 <span class="preprocessor">#ifndef DOXYGEN </span><span class="comment">/* don't expose to doxygen */</span>
<a name="l00240"></a>00240
<a name="l00241"></a>00241 <span class="keyword">typedef</span> <span class="keyword">struct </span>_StackPointer StackPointer;
<a name="l00242"></a>00242 <span class="keyword">struct </span>_StackPointer
<a name="l00243"></a>00243 {
<a name="l00244"></a>00244 VDevice parent;
<a name="l00245"></a>00245
<a name="l00246"></a>00246 uint16_t SPL_addr; <span class="comment">/* Since some devices don't have a SPH, we</span>
<a name="l00247"></a>00247 <span class="comment"> only track SPL address and assume the SPH</span>
<a name="l00248"></a>00248 <span class="comment"> address is SPL_addr + 1. */</span>
<a name="l00249"></a>00249
<a name="l00250"></a>00250 uint8_t SPL; <span class="comment">/* Low byte of stack pointer */</span>
<a name="l00251"></a>00251 uint8_t SPH; <span class="comment">/* High byte of stack pointer */</span>
<a name="l00252"></a>00252 };
<a name="l00253"></a>00253
<a name="l00254"></a>00254 <span class="preprocessor">#endif</span>
<a name="l00255"></a>00255 <span class="preprocessor"></span>
<a name="l00256"></a>00256 <span class="keyword">static</span> StackPointer *sp_new (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name);
<a name="l00257"></a>00257 <span class="keyword">static</span> <span class="keywordtype">void</span> sp_construct (StackPointer *sp, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name);
<a name="l00258"></a>00258 <span class="keyword">static</span> <span class="keywordtype">void</span> sp_destroy (<span class="keywordtype">void</span> *sp);
<a name="l00259"></a>00259 <span class="keyword">static</span> uint8_t sp_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00260"></a>00260 <span class="keyword">static</span> <span class="keywordtype">void</span> sp_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00261"></a>00261 <span class="keyword">static</span> <span class="keywordtype">void</span> sp_reset (VDevice *dev);
<a name="l00262"></a>00262 <span class="keyword">static</span> uint16_t sp_get (VDevice *sp);
<a name="l00263"></a>00263 <span class="keyword">static</span> <span class="keywordtype">void</span> sp_set (VDevice *sp, uint16_t val);
<a name="l00264"></a>00264 <span class="keyword">static</span> <span class="keywordtype">void</span> sp_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr,
<a name="l00265"></a>00265 <span class="keywordtype">void</span> *data);
<a name="l00266"></a>00266 <span class="comment"></span>
<a name="l00267"></a>00267 <span class="comment">/** \brief Create the Stack Pointer VDevice.</span>
<a name="l00268"></a>00268 <span class="comment"></span>
<a name="l00269"></a>00269 <span class="comment"> This should only be used in the DevSuppDefn io reg init structure. */</span>
<a name="l00270"></a>00270
<a name="l00271"></a>00271 VDevice *
<a name="l00272"></a><a class="code" href="stack_8c.html#6df53075eb6ae9223f833080bfc28b94">00272</a> <a class="code" href="stack_8c.html#6df53075eb6ae9223f833080bfc28b94" title="Create the Stack Pointer VDevice.">sp_create</a> (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00273"></a>00273 {
<a name="l00274"></a>00274 <span class="keywordflow">return</span> (VDevice *)sp_new (addr, name);
<a name="l00275"></a>00275 }
<a name="l00276"></a>00276
<a name="l00277"></a>00277 <span class="keyword">static</span> StackPointer *
<a name="l00278"></a>00278 sp_new (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name)
<a name="l00279"></a>00279 {
<a name="l00280"></a>00280 StackPointer *sp;
<a name="l00281"></a>00281
<a name="l00282"></a>00282 sp = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (StackPointer, 1);
<a name="l00283"></a>00283 sp_construct (sp, addr, name);
<a name="l00284"></a>00284 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)sp, sp_destroy);
<a name="l00285"></a>00285
<a name="l00286"></a>00286 <span class="keywordflow">return</span> sp;
<a name="l00287"></a>00287 }
<a name="l00288"></a>00288
<a name="l00289"></a>00289 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00290"></a>00290 sp_construct (StackPointer *sp, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name)
<a name="l00291"></a>00291 {
<a name="l00292"></a>00292 <span class="keywordflow">if</span> (sp == NULL)
<a name="l00293"></a>00293 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00294"></a>00294
<a name="l00295"></a>00295 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)sp, sp_read, sp_write, sp_reset, sp_add_addr);
<a name="l00296"></a>00296
<a name="l00297"></a>00297 sp_add_addr ((VDevice *)sp, addr, name, 0, NULL);
<a name="l00298"></a>00298
<a name="l00299"></a>00299 sp_reset ((VDevice *)sp);
<a name="l00300"></a>00300 }
<a name="l00301"></a>00301
<a name="l00302"></a>00302 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00303"></a>00303 sp_destroy (<span class="keywordtype">void</span> *sp)
<a name="l00304"></a>00304 {
<a name="l00305"></a>00305 <span class="keywordflow">if</span> (sp == NULL)
<a name="l00306"></a>00306 <span class="keywordflow">return</span>;
<a name="l00307"></a>00307
<a name="l00308"></a>00308 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (sp);
<a name="l00309"></a>00309 }
<a name="l00310"></a>00310
<a name="l00311"></a>00311 <span class="keyword">static</span> uint8_t
<a name="l00312"></a>00312 sp_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00313"></a>00313 {
<a name="l00314"></a>00314 StackPointer *sp = (StackPointer *)dev;
<a name="l00315"></a>00315
<a name="l00316"></a>00316 <span class="keywordflow">if</span> (addr == sp-&gt;SPL_addr)
<a name="l00317"></a>00317 <span class="keywordflow">return</span> sp-&gt;SPL;
<a name="l00318"></a>00318 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == (sp-&gt;SPL_addr + 1))
<a name="l00319"></a>00319 <span class="keywordflow">return</span> sp-&gt;SPH;
<a name="l00320"></a>00320 <span class="keywordflow">else</span>
<a name="l00321"></a>00321 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00322"></a>00322
<a name="l00323"></a>00323 <span class="keywordflow">return</span> 0;
<a name="l00324"></a>00324 }
<a name="l00325"></a>00325
<a name="l00326"></a>00326 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00327"></a>00327 sp_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00328"></a>00328 {
<a name="l00329"></a>00329 <span class="comment">/* Don't need display_io_reg() here since it's called higher up in mem</span>
<a name="l00330"></a>00330 <span class="comment"> chain. */</span>
<a name="l00331"></a>00331
<a name="l00332"></a>00332 StackPointer *sp = (StackPointer *)dev;
<a name="l00333"></a>00333
<a name="l00334"></a>00334 <span class="keywordflow">if</span> (addr == sp-&gt;SPL_addr)
<a name="l00335"></a>00335 sp-&gt;SPL = val;
<a name="l00336"></a>00336 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == (sp-&gt;SPL_addr + 1))
<a name="l00337"></a>00337 sp-&gt;SPH = val;
<a name="l00338"></a>00338 <span class="keywordflow">else</span>
<a name="l00339"></a>00339 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00340"></a>00340 }
<a name="l00341"></a>00341
<a name="l00342"></a>00342 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00343"></a>00343 sp_reset (VDevice *dev)
<a name="l00344"></a>00344 {
<a name="l00345"></a>00345 StackPointer *sp = (StackPointer *)dev;
<a name="l00346"></a>00346
<a name="l00347"></a>00347 <a class="code" href="display_8c.html#ed9707596c157777dc33fe1371ded7fc" title="Update an IO register in the display.">display_io_reg</a> (SPL_IO_REG, sp-&gt;SPL = 0);
<a name="l00348"></a>00348 <a class="code" href="display_8c.html#ed9707596c157777dc33fe1371ded7fc" title="Update an IO register in the display.">display_io_reg</a> (SPH_IO_REG, sp-&gt;SPH = 0);
<a name="l00349"></a>00349 }
<a name="l00350"></a>00350
<a name="l00351"></a>00351 <span class="keyword">static</span> uint16_t
<a name="l00352"></a>00352 sp_get (VDevice *sp)
<a name="l00353"></a>00353 {
<a name="l00354"></a>00354 <span class="keywordflow">return</span> (((StackPointer *)sp)-&gt;SPH &lt;&lt; 8) + ((StackPointer *)sp)-&gt;SPL;
<a name="l00355"></a>00355 }
<a name="l00356"></a>00356
<a name="l00357"></a>00357 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00358"></a>00358 sp_set (VDevice *sp, uint16_t val)
<a name="l00359"></a>00359 {
<a name="l00360"></a>00360 <a class="code" href="display_8c.html#ed9707596c157777dc33fe1371ded7fc" title="Update an IO register in the display.">display_io_reg</a> (SPL_IO_REG, ((StackPointer *)sp)-&gt;SPL = val &amp; 0xff);
<a name="l00361"></a>00361 <a class="code" href="display_8c.html#ed9707596c157777dc33fe1371ded7fc" title="Update an IO register in the display.">display_io_reg</a> (SPH_IO_REG, ((StackPointer *)sp)-&gt;SPH = val &gt;&gt; 8);
<a name="l00362"></a>00362 }
<a name="l00363"></a>00363
<a name="l00364"></a>00364 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00365"></a>00365 sp_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00366"></a>00366 {
<a name="l00367"></a>00367 StackPointer *sp = (StackPointer *)vdev;
<a name="l00368"></a>00368
<a name="l00369"></a>00369 <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"SPL"</span>, name, 3) == 0)
<a name="l00370"></a>00370 sp-&gt;SPL_addr = addr;
<a name="l00371"></a>00371
<a name="l00372"></a>00372 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"SPH"</span>, name, 3) == 0)
<a name="l00373"></a>00373 ;
<a name="l00374"></a>00374
<a name="l00375"></a>00375 <span class="keywordflow">else</span>
<a name="l00376"></a>00376 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00377"></a>00377 }
<a name="l00378"></a>00378
<a name="l00379"></a>00379 <span class="comment">/****************************************************************************\</span>
<a name="l00380"></a>00380 <span class="comment"> *</span>
<a name="l00381"></a>00381 <span class="comment"> * MemStack(Stack) Definition.</span>
<a name="l00382"></a>00382 <span class="comment"> *</span>
<a name="l00383"></a>00383 <span class="comment">\****************************************************************************/</span>
<a name="l00384"></a>00384 <span class="comment"></span>
<a name="l00385"></a>00385 <span class="comment">/** \brief Allocate a new MemStack object */</span>
<a name="l00386"></a>00386
<a name="l00387"></a>00387 MemStack *
<a name="l00388"></a><a class="code" href="stack_8c.html#7b2371560513634e9e008d0e3723e67e">00388</a> <a class="code" href="stack_8c.html#7b2371560513634e9e008d0e3723e67e" title="Allocate a new MemStack object.">memstack_new</a> (Memory *mem, <span class="keywordtype">int</span> spl_addr)
<a name="l00389"></a>00389 {
<a name="l00390"></a>00390 MemStack *st;
<a name="l00391"></a>00391
<a name="l00392"></a>00392 st = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (MemStack, 1);
<a name="l00393"></a>00393 <a class="code" href="stack_8c.html#46bd775c5dc8d6c19ec06b2c9da06a41" title="Constructor for MemStack object.">memstack_construct</a> (st, mem, spl_addr);
<a name="l00394"></a>00394 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)st, <a class="code" href="stack_8c.html#64cea8305fc14f82896e499e8fabbe15" title="Destructor for MemStack object.">memstack_destroy</a>);
<a name="l00395"></a>00395
<a name="l00396"></a>00396 <span class="keywordflow">return</span> st;
<a name="l00397"></a>00397 }
<a name="l00398"></a>00398 <span class="comment"></span>
<a name="l00399"></a>00399 <span class="comment">/** \brief Constructor for MemStack object */</span>
<a name="l00400"></a>00400
<a name="l00401"></a>00401 <span class="keywordtype">void</span>
<a name="l00402"></a><a class="code" href="stack_8c.html#46bd775c5dc8d6c19ec06b2c9da06a41">00402</a> <a class="code" href="stack_8c.html#46bd775c5dc8d6c19ec06b2c9da06a41" title="Constructor for MemStack object.">memstack_construct</a> (MemStack *stack, Memory *mem, <span class="keywordtype">int</span> spl_addr)
<a name="l00403"></a>00403 {
<a name="l00404"></a>00404 <span class="keywordflow">if</span> (stack == NULL)
<a name="l00405"></a>00405 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00406"></a>00406
<a name="l00407"></a>00407 <a class="code" href="stack_8c.html#119a7d0b0be8ef37e798c8f9c6ae4722" title="Constructor for the Stack class.">stack_construct</a> ((Stack *)stack, mem_pop, mem_push);
<a name="l00408"></a>00408
<a name="l00409"></a>00409 <a class="code" href="avrclass_8c.html#ff0f5b14bf2740f208041d515f3ba93f" title="Increments the reference count for the klass object.">class_ref</a> ((AvrClass *)mem);
<a name="l00410"></a>00410 stack-&gt;mem = mem;
<a name="l00411"></a>00411
<a name="l00412"></a>00412 stack-&gt;SP = <a class="code" href="memory_8c.html#c5dc450f9b9f874d58df945f1a27b9c4" title="Find the VDevice associated with the given address.">mem_get_vdevice_by_addr</a> (mem, spl_addr);
<a name="l00413"></a>00413 <span class="keywordflow">if</span> (stack-&gt;SP == NULL)
<a name="l00414"></a>00414 {
<a name="l00415"></a>00415 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"attempt to attach non-extistant SPL register"</span>);
<a name="l00416"></a>00416 }
<a name="l00417"></a>00417 <a class="code" href="avrclass_8c.html#ff0f5b14bf2740f208041d515f3ba93f" title="Increments the reference count for the klass object.">class_ref</a> ((AvrClass *)stack-&gt;SP);
<a name="l00418"></a>00418 }
<a name="l00419"></a>00419 <span class="comment"></span>
<a name="l00420"></a>00420 <span class="comment">/** \brief Destructor for MemStack object */</span>
<a name="l00421"></a>00421
<a name="l00422"></a>00422 <span class="keywordtype">void</span>
<a name="l00423"></a><a class="code" href="stack_8c.html#64cea8305fc14f82896e499e8fabbe15">00423</a> <a class="code" href="stack_8c.html#64cea8305fc14f82896e499e8fabbe15" title="Destructor for MemStack object.">memstack_destroy</a> (<span class="keywordtype">void</span> *stack)
<a name="l00424"></a>00424 {
<a name="l00425"></a>00425 MemStack *_stack = (MemStack *)stack;
<a name="l00426"></a>00426
<a name="l00427"></a>00427 <span class="keywordflow">if</span> (stack == NULL)
<a name="l00428"></a>00428 <span class="keywordflow">return</span>;
<a name="l00429"></a>00429
<a name="l00430"></a>00430 <a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a> ((AvrClass *)_stack-&gt;SP);
<a name="l00431"></a>00431 <a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a> ((AvrClass *)_stack-&gt;mem);
<a name="l00432"></a>00432
<a name="l00433"></a>00433 <a class="code" href="stack_8c.html#c6c460b2f72e2a2095cd70b4414d4933" title="Destructor for the Stack class.">stack_destroy</a> (stack);
<a name="l00434"></a>00434 }
<a name="l00435"></a>00435
<a name="l00436"></a>00436 <span class="comment">/* The MemStack pop method */</span>
<a name="l00437"></a>00437
<a name="l00438"></a>00438 <span class="keyword">static</span> uint32_t
<a name="l00439"></a>00439 mem_pop (Stack *stack, <span class="keywordtype">int</span> bytes)
<a name="l00440"></a>00440 {
<a name="l00441"></a>00441 MemStack *mst = (MemStack *)stack;
<a name="l00442"></a>00442 <span class="keywordtype">int</span> i;
<a name="l00443"></a>00443 uint32_t val = 0;
<a name="l00444"></a>00444 uint16_t sp = sp_get (mst-&gt;SP);
<a name="l00445"></a>00445
<a name="l00446"></a>00446 <span class="keywordflow">if</span> ((bytes &lt; 0) || (bytes &gt;= <span class="keyword">sizeof</span> (uint32_t)))
<a name="l00447"></a>00447 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"bytes out of bounds: %d"</span>, bytes);
<a name="l00448"></a>00448
<a name="l00449"></a>00449 <span class="keywordflow">for</span> (i = bytes - 1; i &gt;= 0; i--)
<a name="l00450"></a>00450 {
<a name="l00451"></a>00451 sp++;
<a name="l00452"></a>00452 val |= (<a class="code" href="memory_8c.html#7ebc4d26966257412b56ef78dd33ad51" title="Reads byte from memory and sanity-checks for valid address.">mem_read</a> (mst-&gt;mem, sp) &lt;&lt; (i * 8));
<a name="l00453"></a>00453 }
<a name="l00454"></a>00454
<a name="l00455"></a>00455 sp_set (mst-&gt;SP, sp);
<a name="l00456"></a>00456
<a name="l00457"></a>00457 <span class="keywordflow">return</span> val;
<a name="l00458"></a>00458 }
<a name="l00459"></a>00459
<a name="l00460"></a>00460 <span class="comment">/* The MemStack push method. */</span>
<a name="l00461"></a>00461
<a name="l00462"></a>00462 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00463"></a>00463 mem_push (Stack *stack, <span class="keywordtype">int</span> bytes, uint32_t val)
<a name="l00464"></a>00464 {
<a name="l00465"></a>00465 MemStack *mst = (MemStack *)stack;
<a name="l00466"></a>00466 <span class="keywordtype">int</span> i;
<a name="l00467"></a>00467 uint16_t sp = sp_get (mst-&gt;SP);
<a name="l00468"></a>00468
<a name="l00469"></a>00469 <span class="keywordflow">if</span> ((bytes &lt; 0) || (bytes &gt;= <span class="keyword">sizeof</span> (uint32_t)))
<a name="l00470"></a>00470 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"bytes out of bounds: %d"</span>, bytes);
<a name="l00471"></a>00471
<a name="l00472"></a>00472 <span class="keywordflow">for</span> (i = 0; i &lt; bytes; i++)
<a name="l00473"></a>00473 {
<a name="l00474"></a>00474 <a class="code" href="memory_8c.html#218836433955d34b6eabfbc3d48aedda" title="Writes byte to memory and updates display for io registers.">mem_write</a> (mst-&gt;mem, sp, val &amp; 0xff);
<a name="l00475"></a>00475 val &gt;&gt;= 8;
<a name="l00476"></a>00476 sp--;
<a name="l00477"></a>00477 }
<a name="l00478"></a>00478
<a name="l00479"></a>00479 sp_set (mst-&gt;SP, sp);
<a name="l00480"></a>00480 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,500 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>stack.c File Reference</h1>Module for the definition of the stack. <a href="#_details">More...</a>
<p>
<p>
<a href="stack_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">Stack *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8c.html#83de2962ed4166699cc8f40edcc1f380">stack_new</a> (StackFP_Pop pop, StackFP_Push push)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8c.html#119a7d0b0be8ef37e798c8f9c6ae4722">stack_construct</a> (Stack *stack, StackFP_Pop pop, StackFP_Push push)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8c.html#c6c460b2f72e2a2095cd70b4414d4933">stack_destroy</a> (void *stack)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">uint32_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8c.html#9077dfc6f98c4fe4b51b43db90055aaa">stack_pop</a> (Stack *stack, int bytes)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8c.html#bd76f1a4f5bfc1e2b8699f3787cf7af2">stack_push</a> (Stack *stack, int bytes, uint32_t val)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">HWStack *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8c.html#f9b8a6ec32f0798480f4bd02733996b1">hwstack_new</a> (int depth)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8c.html#d02c1ea58dfb09cff13e4ad524bb8797">hwstack_construct</a> (HWStack *stack, int depth)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8c.html#837cbada76cb76af5aa46618d90ea00e">hwstack_destroy</a> (void *stack)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8c.html#6df53075eb6ae9223f833080bfc28b94">sp_create</a> (int addr, char *name, int rel_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">MemStack *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8c.html#7b2371560513634e9e008d0e3723e67e">memstack_new</a> (Memory *mem, int spl_addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8c.html#46bd775c5dc8d6c19ec06b2c9da06a41">memstack_construct</a> (MemStack *stack, Memory *mem, int spl_addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="stack_8c.html#64cea8305fc14f82896e499e8fabbe15">memstack_destroy</a> (void *stack)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Module for the definition of the stack.
<p>
Defines the classes stack, hw_stack, and mem_stack.<p>
FIXME: Ted, I would really really really love to put in a description of what is the difference between these three classes and how they're used, but I don't understand it myself.
<p>Definition in file <a class="el" href="stack_8c-source.html">stack.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="83de2962ed4166699cc8f40edcc1f380"></a><!-- doxytag: member="stack.c::stack_new" ref="83de2962ed4166699cc8f40edcc1f380" args="(StackFP_Pop pop, StackFP_Push push)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">Stack* stack_new </td>
<td>(</td>
<td class="paramtype">StackFP_Pop&nbsp;</td>
<td class="paramname"> <em>pop</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">StackFP_Push&nbsp;</td>
<td class="paramname"> <em>push</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocates memory for a new Stack object.
<p>
This is a virtual method for higher level stack implementations and as such should not be used directly.
<p>Definition at line <a class="el" href="stack_8c-source.html#l00082">82</a> of file <a class="el" href="stack_8c-source.html">stack.c</a>.</p>
<p>References <a class="el" href="avrmalloc_8c-source.html#l00057">avr_new</a>, <a class="el" href="avrclass_8c-source.html#l00092">class_overload_destroy()</a>, <a class="el" href="stack_8c-source.html#l00099">stack_construct()</a>, and <a class="el" href="stack_8c-source.html#l00116">stack_destroy()</a>.</p>
</div>
</div><p>
<a class="anchor" name="119a7d0b0be8ef37e798c8f9c6ae4722"></a><!-- doxytag: member="stack.c::stack_construct" ref="119a7d0b0be8ef37e798c8f9c6ae4722" args="(Stack *stack, StackFP_Pop pop, StackFP_Push push)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void stack_construct </td>
<td>(</td>
<td class="paramtype">Stack *&nbsp;</td>
<td class="paramname"> <em>stack</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">StackFP_Pop&nbsp;</td>
<td class="paramname"> <em>pop</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">StackFP_Push&nbsp;</td>
<td class="paramname"> <em>push</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for the Stack class.
<p>
This is a virtual method for higher level stack implementations and as such should not be used directly.
<p>Definition at line <a class="el" href="stack_8c-source.html#l00099">99</a> of file <a class="el" href="stack_8c-source.html">stack.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="avrclass_8c-source.html#l00061">class_construct()</a>.</p>
<p>Referenced by <a class="el" href="stack_8c-source.html#l00177">hwstack_construct()</a>, <a class="el" href="stack_8c-source.html#l00402">memstack_construct()</a>, and <a class="el" href="stack_8c-source.html#l00082">stack_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="c6c460b2f72e2a2095cd70b4414d4933"></a><!-- doxytag: member="stack.c::stack_destroy" ref="c6c460b2f72e2a2095cd70b4414d4933" args="(void *stack)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void stack_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>stack</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for the Stack class.
<p>
This is a virtual method for higher level stack implementations and as such should not be used directly.
<p>Definition at line <a class="el" href="stack_8c-source.html#l00116">116</a> of file <a class="el" href="stack_8c-source.html">stack.c</a>.</p>
<p>References <a class="el" href="avrclass_8c-source.html#l00078">class_destroy()</a>.</p>
<p>Referenced by <a class="el" href="stack_8c-source.html#l00191">hwstack_destroy()</a>, <a class="el" href="stack_8c-source.html#l00423">memstack_destroy()</a>, and <a class="el" href="stack_8c-source.html#l00082">stack_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="9077dfc6f98c4fe4b51b43db90055aaa"></a><!-- doxytag: member="stack.c::stack_pop" ref="9077dfc6f98c4fe4b51b43db90055aaa" args="(Stack *stack, int bytes)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint32_t stack_pop </td>
<td>(</td>
<td class="paramtype">Stack *&nbsp;</td>
<td class="paramname"> <em>stack</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>bytes</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Pops a byte or a word off the stack and returns it.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>stack</em>&nbsp;</td><td>A pointer to the Stack object from which to pop </td></tr>
<tr><td valign="top"></td><td valign="top"><em>bytes</em>&nbsp;</td><td>Number of bytes to pop off the stack (1 to 4 bytes).</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>The 1 to 4 bytes value popped from the stack.</dd></dl>
This method provides access to the derived class's pop() method.
<p>Definition at line <a class="el" href="stack_8c-source.html#l00133">133</a> of file <a class="el" href="stack_8c-source.html">stack.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="bd76f1a4f5bfc1e2b8699f3787cf7af2"></a><!-- doxytag: member="stack.c::stack_push" ref="bd76f1a4f5bfc1e2b8699f3787cf7af2" args="(Stack *stack, int bytes, uint32_t val)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void stack_push </td>
<td>(</td>
<td class="paramtype">Stack *&nbsp;</td>
<td class="paramname"> <em>stack</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>bytes</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&nbsp;</td>
<td class="paramname"> <em>val</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Pushes a byte or a word of data onto the stack.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>stack</em>&nbsp;</td><td>A pointer to the Stack object from which to pop. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>bytes</em>&nbsp;</td><td>Size of the value being pushed onto the stack (1 to 4 bytes). </td></tr>
<tr><td valign="top"></td><td valign="top"><em>val</em>&nbsp;</td><td>The value to be pushed.</td></tr>
</table>
</dl>
This method provides access to the derived class's push() method.
<p>Definition at line <a class="el" href="stack_8c-source.html#l00146">146</a> of file <a class="el" href="stack_8c-source.html">stack.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="f9b8a6ec32f0798480f4bd02733996b1"></a><!-- doxytag: member="stack.c::hwstack_new" ref="f9b8a6ec32f0798480f4bd02733996b1" args="(int depth)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">HWStack* hwstack_new </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>depth</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new HWStack object.
<p>
This is the stack implementation used by devices which lack SRAM and only have a fixed size hardware stack (e.i., the at90s1200)
<p>Definition at line <a class="el" href="stack_8c-source.html#l00163">163</a> of file <a class="el" href="stack_8c-source.html">stack.c</a>.</p>
<p>References <a class="el" href="avrmalloc_8c-source.html#l00057">avr_new</a>, <a class="el" href="avrclass_8c-source.html#l00092">class_overload_destroy()</a>, <a class="el" href="stack_8c-source.html#l00177">hwstack_construct()</a>, and <a class="el" href="stack_8c-source.html#l00191">hwstack_destroy()</a>.</p>
</div>
</div><p>
<a class="anchor" name="d02c1ea58dfb09cff13e4ad524bb8797"></a><!-- doxytag: member="stack.c::hwstack_construct" ref="d02c1ea58dfb09cff13e4ad524bb8797" args="(HWStack *stack, int depth)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void hwstack_construct </td>
<td>(</td>
<td class="paramtype">HWStack *&nbsp;</td>
<td class="paramname"> <em>stack</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>depth</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for HWStack object.
<p>
<p>Definition at line <a class="el" href="stack_8c-source.html#l00177">177</a> of file <a class="el" href="stack_8c-source.html">stack.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, <a class="el" href="avrmalloc_8c-source.html#l00067">avr_new0</a>, and <a class="el" href="stack_8c-source.html#l00099">stack_construct()</a>.</p>
<p>Referenced by <a class="el" href="stack_8c-source.html#l00163">hwstack_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="837cbada76cb76af5aa46618d90ea00e"></a><!-- doxytag: member="stack.c::hwstack_destroy" ref="837cbada76cb76af5aa46618d90ea00e" args="(void *stack)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void hwstack_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>stack</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for HWStack object.
<p>
<p>Definition at line <a class="el" href="stack_8c-source.html#l00191">191</a> of file <a class="el" href="stack_8c-source.html">stack.c</a>.</p>
<p>References <a class="el" href="avrmalloc_8c-source.html#l00187">avr_free()</a>, and <a class="el" href="stack_8c-source.html#l00116">stack_destroy()</a>.</p>
<p>Referenced by <a class="el" href="stack_8c-source.html#l00163">hwstack_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="6df53075eb6ae9223f833080bfc28b94"></a><!-- doxytag: member="stack.c::sp_create" ref="6df53075eb6ae9223f833080bfc28b94" args="(int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* sp_create </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Create the Stack Pointer VDevice.
<p>
This should only be used in the DevSuppDefn io reg init structure.
<p>Definition at line <a class="el" href="stack_8c-source.html#l00272">272</a> of file <a class="el" href="stack_8c-source.html">stack.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="7b2371560513634e9e008d0e3723e67e"></a><!-- doxytag: member="stack.c::memstack_new" ref="7b2371560513634e9e008d0e3723e67e" args="(Memory *mem, int spl_addr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">MemStack* memstack_new </td>
<td>(</td>
<td class="paramtype">Memory *&nbsp;</td>
<td class="paramname"> <em>mem</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>spl_addr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new MemStack object.
<p>
<p>Definition at line <a class="el" href="stack_8c-source.html#l00388">388</a> of file <a class="el" href="stack_8c-source.html">stack.c</a>.</p>
<p>References <a class="el" href="avrmalloc_8c-source.html#l00057">avr_new</a>, <a class="el" href="avrclass_8c-source.html#l00092">class_overload_destroy()</a>, <a class="el" href="stack_8c-source.html#l00402">memstack_construct()</a>, and <a class="el" href="stack_8c-source.html#l00423">memstack_destroy()</a>.</p>
</div>
</div><p>
<a class="anchor" name="46bd775c5dc8d6c19ec06b2c9da06a41"></a><!-- doxytag: member="stack.c::memstack_construct" ref="46bd775c5dc8d6c19ec06b2c9da06a41" args="(MemStack *stack, Memory *mem, int spl_addr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void memstack_construct </td>
<td>(</td>
<td class="paramtype">MemStack *&nbsp;</td>
<td class="paramname"> <em>stack</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">Memory *&nbsp;</td>
<td class="paramname"> <em>mem</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>spl_addr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for MemStack object.
<p>
<p>Definition at line <a class="el" href="stack_8c-source.html#l00402">402</a> of file <a class="el" href="stack_8c-source.html">stack.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, <a class="el" href="avrclass_8c-source.html#l00106">class_ref()</a>, <a class="el" href="memory_8c-source.html#l00159">mem_get_vdevice_by_addr()</a>, and <a class="el" href="stack_8c-source.html#l00099">stack_construct()</a>.</p>
<p>Referenced by <a class="el" href="stack_8c-source.html#l00388">memstack_new()</a>.</p>
</div>
</div><p>
<a class="anchor" name="64cea8305fc14f82896e499e8fabbe15"></a><!-- doxytag: member="stack.c::memstack_destroy" ref="64cea8305fc14f82896e499e8fabbe15" args="(void *stack)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void memstack_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>stack</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for MemStack object.
<p>
<p>Definition at line <a class="el" href="stack_8c-source.html#l00423">423</a> of file <a class="el" href="stack_8c-source.html">stack.c</a>.</p>
<p>References <a class="el" href="avrclass_8c-source.html#l00120">class_unref()</a>, and <a class="el" href="stack_8c-source.html#l00116">stack_destroy()</a>.</p>
<p>Referenced by <a class="el" href="stack_8c-source.html#l00388">memstack_new()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,152 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>storage.c</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: storage.c,v 1.8 2003/12/02 08:25:00 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025
<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00030"></a>00030
<a name="l00031"></a>00031 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00033"></a>00033 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include "storage.h"</span>
<a name="l00035"></a>00035
<a name="l00036"></a>00036 <span class="comment">/***************************************************************************\</span>
<a name="l00037"></a>00037 <span class="comment"> *</span>
<a name="l00038"></a>00038 <span class="comment"> * Storage(AvrClass) Methods</span>
<a name="l00039"></a>00039 <span class="comment"> *</span>
<a name="l00040"></a>00040 <span class="comment">\***************************************************************************/</span>
<a name="l00041"></a>00041
<a name="l00042"></a>00042 Storage *
<a name="l00043"></a>00043 storage_new (<span class="keywordtype">int</span> base, <span class="keywordtype">int</span> size)
<a name="l00044"></a>00044 {
<a name="l00045"></a>00045 Storage *stor;
<a name="l00046"></a>00046
<a name="l00047"></a>00047 stor = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (Storage, 1);
<a name="l00048"></a>00048 storage_construct (stor, base, size);
<a name="l00049"></a>00049 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)stor, storage_destroy);
<a name="l00050"></a>00050
<a name="l00051"></a>00051 <span class="keywordflow">return</span> stor;
<a name="l00052"></a>00052 }
<a name="l00053"></a>00053
<a name="l00054"></a>00054 <span class="keywordtype">void</span>
<a name="l00055"></a>00055 storage_construct (Storage *stor, <span class="keywordtype">int</span> base, <span class="keywordtype">int</span> size)
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057 <span class="keywordflow">if</span> (stor == NULL)
<a name="l00058"></a>00058 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00059"></a>00059
<a name="l00060"></a>00060 <a class="code" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e" title="Initializes the AvrClass data structure.">class_construct</a> ((AvrClass *)stor);
<a name="l00061"></a>00061
<a name="l00062"></a>00062 stor-&gt;base = base; <span class="comment">/* address */</span>
<a name="l00063"></a>00063 stor-&gt;size = size; <span class="comment">/* bytes */</span>
<a name="l00064"></a>00064
<a name="l00065"></a>00065 stor-&gt;data = <a class="code" href="avrmalloc_8c.html#ac6d810b48b67b90412badbd4b71f4e3" title="Macro for allocating memory and initializing it to zero.">avr_new0</a> (uint8_t, size);
<a name="l00066"></a>00066 }
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="comment">/*</span>
<a name="l00069"></a>00069 <span class="comment"> * Not to be called directly, except by a derived class.</span>
<a name="l00070"></a>00070 <span class="comment"> * Called via class_unref.</span>
<a name="l00071"></a>00071 <span class="comment"> */</span>
<a name="l00072"></a>00072 <span class="keywordtype">void</span>
<a name="l00073"></a>00073 storage_destroy (<span class="keywordtype">void</span> *stor)
<a name="l00074"></a>00074 {
<a name="l00075"></a>00075 <span class="keywordflow">if</span> (stor == NULL)
<a name="l00076"></a>00076 <span class="keywordflow">return</span>;
<a name="l00077"></a>00077
<a name="l00078"></a>00078 <a class="code" href="avrmalloc_8c.html#082a9d6d40f5e8bad64441ad950ec12c" title="Free malloc&amp;#39;d memory.">avr_free</a> (((Storage *)stor)-&gt;data);
<a name="l00079"></a>00079 <a class="code" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5" title="Releases resources allocated by class&amp;#39;s &amp;lt;klass&amp;gt;_new() function.">class_destroy</a> (stor);
<a name="l00080"></a>00080 }
<a name="l00081"></a>00081
<a name="l00082"></a>00082 <span class="keyword">extern</span> <span class="keyword">inline</span> uint8_t
<a name="l00083"></a>00083 storage_readb (Storage *stor, <span class="keywordtype">int</span> addr);
<a name="l00084"></a>00084
<a name="l00085"></a>00085 <span class="keyword">extern</span> <span class="keyword">inline</span> uint16_t
<a name="l00086"></a>00086 storage_readw (Storage *stor, <span class="keywordtype">int</span> addr);
<a name="l00087"></a>00087
<a name="l00088"></a>00088 <span class="keywordtype">void</span>
<a name="l00089"></a>00089 storage_writeb (Storage *stor, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00090"></a>00090 {
<a name="l00091"></a>00091 <span class="keywordtype">int</span> _addr = addr - stor-&gt;base;
<a name="l00092"></a>00092
<a name="l00093"></a>00093 <span class="keywordflow">if</span> (stor == NULL)
<a name="l00094"></a>00094 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00095"></a>00095
<a name="l00096"></a>00096 <span class="keywordflow">if</span> ((_addr &lt; 0) || (_addr &gt;= stor-&gt;size))
<a name="l00097"></a>00097 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"address out of bounds: 0x%x"</span>, addr);
<a name="l00098"></a>00098
<a name="l00099"></a>00099 stor-&gt;data[_addr] = val;
<a name="l00100"></a>00100 }
<a name="l00101"></a>00101
<a name="l00102"></a>00102 <span class="keywordtype">void</span>
<a name="l00103"></a>00103 storage_writew (Storage *stor, <span class="keywordtype">int</span> addr, uint16_t val)
<a name="l00104"></a>00104 {
<a name="l00105"></a>00105 <span class="keywordtype">int</span> _addr = addr - stor-&gt;base;
<a name="l00106"></a>00106
<a name="l00107"></a>00107 <span class="keywordflow">if</span> (stor == NULL)
<a name="l00108"></a>00108 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00109"></a>00109
<a name="l00110"></a>00110 <span class="keywordflow">if</span> ((_addr &lt; 0) || (_addr &gt;= stor-&gt;size))
<a name="l00111"></a>00111 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"address out of bounds: 0x%x"</span>, addr);
<a name="l00112"></a>00112
<a name="l00113"></a>00113 stor-&gt;data[_addr] = (uint8_t) (val &gt;&gt; 8 &amp; 0xff);
<a name="l00114"></a>00114 stor-&gt;data[_addr + 1] = (uint8_t) (val &amp; 0xff);
<a name="l00115"></a>00115 }
<a name="l00116"></a>00116
<a name="l00117"></a>00117 <span class="keywordtype">int</span>
<a name="l00118"></a>00118 storage_get_size (Storage *stor)
<a name="l00119"></a>00119 {
<a name="l00120"></a>00120 <span class="keywordflow">return</span> stor-&gt;size;
<a name="l00121"></a>00121 }
<a name="l00122"></a>00122
<a name="l00123"></a>00123 <span class="keywordtype">int</span>
<a name="l00124"></a>00124 storage_get_base (Storage *stor)
<a name="l00125"></a>00125 {
<a name="l00126"></a>00126 <span class="keywordflow">return</span> stor-&gt;base;
<a name="l00127"></a>00127 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,102 @@
/* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */
DIV.tabs
{
float : left;
width : 100%;
background : url("tab_b.gif") repeat-x bottom;
margin-bottom : 4px;
}
DIV.tabs UL
{
margin : 0px;
padding-left : 10px;
list-style : none;
}
DIV.tabs LI, DIV.tabs FORM
{
display : inline;
margin : 0px;
padding : 0px;
}
DIV.tabs FORM
{
float : right;
}
DIV.tabs A
{
float : left;
background : url("tab_r.gif") no-repeat right top;
border-bottom : 1px solid #84B0C7;
font-size : x-small;
font-weight : bold;
text-decoration : none;
}
DIV.tabs A:hover
{
background-position: 100% -150px;
}
DIV.tabs A:link, DIV.tabs A:visited,
DIV.tabs A:active, DIV.tabs A:hover
{
color: #1A419D;
}
DIV.tabs SPAN
{
float : left;
display : block;
background : url("tab_l.gif") no-repeat left top;
padding : 5px 9px;
white-space : nowrap;
}
DIV.tabs INPUT
{
float : right;
display : inline;
font-size : 1em;
}
DIV.tabs TD
{
font-size : x-small;
font-weight : bold;
text-decoration : none;
}
/* Commented Backslash Hack hides rule from IE5-Mac \*/
DIV.tabs SPAN {float : none;}
/* End IE5-Mac hack */
DIV.tabs A:hover SPAN
{
background-position: 0% -150px;
}
DIV.tabs LI.current A
{
background-position: 100% -150px;
border-width : 0px;
}
DIV.tabs LI.current SPAN
{
background-position: 0% -150px;
padding-bottom : 6px;
}
DIV.navpath
{
background : none;
border : none;
border-bottom : 1px solid #84B0C7;
}

View file

@ -0,0 +1,514 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>timers.c File Reference</h1>Module to simulate the AVR's on-board timer/counters. <a href="#_details">More...</a>
<p>
<p>
<a href="timers_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="timers_8c.html#208259596835cc401b33bd60da45bf6a">timer_int_create</a> (int addr, char *name, int rel_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="cacaacf02f20e22828e6f557957f07bb"></a><!-- doxytag: member="timers.c::timer_intr_new" ref="cacaacf02f20e22828e6f557957f07bb" args="(int addr, char *name, uint8_t func_mask)" -->
TimerIntr_T *&nbsp;</td><td class="memItemRight" valign="bottom"><b>timer_intr_new</b> (int addr, char *name, uint8_t func_mask)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="timers_8c.html#b6a748a5044a9bad3e7d41bf93e80d41">timer_intr_construct</a> (TimerIntr_T *ti, int addr, char *name, uint8_t func_mask)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="timers_8c.html#527da83fda0848baaceb0929eb61815e">timer_intr_destroy</a> (void *ti)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="timers_8c.html#3bb4b9cbfa8d8ff090051f306d223bf2">timer0_create</a> (int addr, char *name, int rel_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="fdecd44457c77fc4f16310e8ed71b41b"></a><!-- doxytag: member="timers.c::timer0_new" ref="fdecd44457c77fc4f16310e8ed71b41b" args="(int addr, char *name, int rel_addr)" -->
Timer0_T *&nbsp;</td><td class="memItemRight" valign="bottom"><b>timer0_new</b> (int addr, char *name, int rel_addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="timers_8c.html#4aedd082ecfe36cc7c2a24e4bae44be3">timer0_construct</a> (Timer0_T *timer, int addr, char *name, int rel_addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="timers_8c.html#6d078109b034e0ca46d10df1caa6d7af">timer0_destroy</a> (void *timer)</td></tr>
<tr><td colspan="2"><div class="groupHeader">16 Bit Timer Functions</div></td></tr>
<tr><td colspan="2"><div class="groupText"><br><br></div></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="timers_8c.html#fc0ff9b70476bf2134ee7ea55b6da86d">timer16_create</a> (int addr, char *name, int rel_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="0abb8a14fddb2ca889e7758055d6f37a"></a><!-- doxytag: member="timers.c::timer16_new" ref="0abb8a14fddb2ca889e7758055d6f37a" args="(int addr, char *name, int rel_addr, Timer16Def timerdef)" -->
Timer16_T *&nbsp;</td><td class="memItemRight" valign="bottom"><b>timer16_new</b> (int addr, char *name, int rel_addr, Timer16Def timerdef)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="timers_8c.html#f614713078dc3bf66a7c765f409cf517">timer16_construct</a> (Timer16_T *timer, int addr, char *name, int rel_addr, Timer16Def timerdef)</td></tr>
<tr><td colspan="2"><div class="groupHeader">16 Bit Output Compare Register Functions</div></td></tr>
<tr><td colspan="2"><div class="groupText"><br><br></div></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="timers_8c.html#c8de7810ae4a9b1eea06d0ecf50a7a4b">ocreg16_create</a> (int addr, char *name, int rel_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="33a561a4994f24a7c068689f18132549"></a><!-- doxytag: member="timers.c::ocreg16_new" ref="33a561a4994f24a7c068689f18132549" args="(int addr, char *name, OCReg16Def ocrdef)" -->
OCReg16_T *&nbsp;</td><td class="memItemRight" valign="bottom"><b>ocreg16_new</b> (int addr, char *name, OCReg16Def ocrdef)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="timers_8c.html#62c8b38185dbc7ced00aa878a2b96590">ocreg16_construct</a> (OCReg16_T *ocreg, int addr, char *name, OCReg16Def ocrdef)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Module to simulate the AVR's on-board timer/counters.
<p>
This currently only implements the timer/counter 0.
<p>Definition in file <a class="el" href="timers_8c-source.html">timers.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="208259596835cc401b33bd60da45bf6a"></a><!-- doxytag: member="timers.c::timer_int_create" ref="208259596835cc401b33bd60da45bf6a" args="(int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* timer_int_create </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new timer interrupt.
<p>
<p>Definition at line <a class="el" href="timers_8c-source.html#l00138">138</a> of file <a class="el" href="timers_8c-source.html">timers.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
</div>
</div><p>
<a class="anchor" name="b6a748a5044a9bad3e7d41bf93e80d41"></a><!-- doxytag: member="timers.c::timer_intr_construct" ref="b6a748a5044a9bad3e7d41bf93e80d41" args="(TimerIntr_T *ti, int addr, char *name, uint8_t func_mask)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void timer_intr_construct </td>
<td>(</td>
<td class="paramtype">TimerIntr_T *&nbsp;</td>
<td class="paramname"> <em>ti</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&nbsp;</td>
<td class="paramname"> <em>func_mask</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for timer interrupt object.
<p>
<p>Definition at line <a class="el" href="timers_8c-source.html#l00163">163</a> of file <a class="el" href="timers_8c-source.html">timers.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="527da83fda0848baaceb0929eb61815e"></a><!-- doxytag: member="timers.c::timer_intr_destroy" ref="527da83fda0848baaceb0929eb61815e" args="(void *ti)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void timer_intr_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>ti</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for timer interrupt object.
<p>
<p>Definition at line <a class="el" href="timers_8c-source.html#l00205">205</a> of file <a class="el" href="timers_8c-source.html">timers.c</a>.</p>
<p>References <a class="el" href="device_8c-source.html#l00105">vdev_destroy()</a>.</p>
</div>
</div><p>
<a class="anchor" name="3bb4b9cbfa8d8ff090051f306d223bf2"></a><!-- doxytag: member="timers.c::timer0_create" ref="3bb4b9cbfa8d8ff090051f306d223bf2" args="(int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* timer0_create </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new timer/counter 0.
<p>
<p>Definition at line <a class="el" href="timers_8c-source.html#l00350">350</a> of file <a class="el" href="timers_8c-source.html">timers.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="4aedd082ecfe36cc7c2a24e4bae44be3"></a><!-- doxytag: member="timers.c::timer0_construct" ref="4aedd082ecfe36cc7c2a24e4bae44be3" args="(Timer0_T *timer, int addr, char *name, int rel_addr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void timer0_construct </td>
<td>(</td>
<td class="paramtype">Timer0_T *&nbsp;</td>
<td class="paramname"> <em>timer</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for timer/counter 0 object.
<p>
<p>Definition at line <a class="el" href="timers_8c-source.html#l00370">370</a> of file <a class="el" href="timers_8c-source.html">timers.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="6d078109b034e0ca46d10df1caa6d7af"></a><!-- doxytag: member="timers.c::timer0_destroy" ref="6d078109b034e0ca46d10df1caa6d7af" args="(void *timer)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void timer0_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>timer</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for timer/counter 0 object.
<p>
<p>Definition at line <a class="el" href="timers_8c-source.html#l00387">387</a> of file <a class="el" href="timers_8c-source.html">timers.c</a>.</p>
<p>References <a class="el" href="device_8c-source.html#l00105">vdev_destroy()</a>.</p>
</div>
</div><p>
<a class="anchor" name="fc0ff9b70476bf2134ee7ea55b6da86d"></a><!-- doxytag: member="timers.c::timer16_create" ref="fc0ff9b70476bf2134ee7ea55b6da86d" args="(int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* timer16_create </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new 16 bit timer/counter.
<p>
<p>Definition at line <a class="el" href="timers_8c-source.html#l00582">582</a> of file <a class="el" href="timers_8c-source.html">timers.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
</div>
</div><p>
<a class="anchor" name="f614713078dc3bf66a7c765f409cf517"></a><!-- doxytag: member="timers.c::timer16_construct" ref="f614713078dc3bf66a7c765f409cf517" args="(Timer16_T *timer, int addr, char *name, int rel_addr, Timer16Def timerdef)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void timer16_construct </td>
<td>(</td>
<td class="paramtype">Timer16_T *&nbsp;</td>
<td class="paramname"> <em>timer</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">Timer16Def&nbsp;</td>
<td class="paramname"> <em>timerdef</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for 16 bit timer/counter object.
<p>
<p>Definition at line <a class="el" href="timers_8c-source.html#l00608">608</a> of file <a class="el" href="timers_8c-source.html">timers.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="c8de7810ae4a9b1eea06d0ecf50a7a4b"></a><!-- doxytag: member="timers.c::ocreg16_create" ref="c8de7810ae4a9b1eea06d0ecf50a7a4b" args="(int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* ocreg16_create </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new 16 bit Output Compare Register.
<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>ocrdef</em>&nbsp;</td><td>The definition struct for the <em>OCR</em> to be created </td></tr>
</table>
</dl>
<p>Definition at line <a class="el" href="timers_8c-source.html#l00909">909</a> of file <a class="el" href="timers_8c-source.html">timers.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
</div>
</div><p>
<a class="anchor" name="62c8b38185dbc7ced00aa878a2b96590"></a><!-- doxytag: member="timers.c::ocreg16_construct" ref="62c8b38185dbc7ced00aa878a2b96590" args="(OCReg16_T *ocreg, int addr, char *name, OCReg16Def ocrdef)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void ocreg16_construct </td>
<td>(</td>
<td class="paramtype">OCReg16_T *&nbsp;</td>
<td class="paramname"> <em>ocreg</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">OCReg16Def&nbsp;</td>
<td class="paramname"> <em>ocrdef</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for 16 bit Output Compare Register object.
<p>
<p>Definition at line <a class="el" href="timers_8c-source.html#l00935">935</a> of file <a class="el" href="timers_8c-source.html">timers.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,36 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1><a class="anchor" name="todo">Todo List </a></h1><a class="anchor" name="_todo000001"></a> <dl>
<dt>Global <a class="el" href="avrcore_8c.html#40ce5b08150e1450aad33c78c11dfa5e">avr_core_run</a> </dt>
<dd>Should add some basic breakpoint handling here. Maybe allow continuing, and simple breakpoint management (disable, delete, set) </dd>
</dl>
<p>
<a class="anchor" name="_todo000002"></a> <dl>
<dt>File <a class="el" href="ports_8c.html">ports.c</a> </dt>
<dd>Remove the pins argument and the mask field. That's handled at a higher level so is obsolete here now. </dd>
</dl>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,111 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Language" content="en" />
<link rel="stylesheet" href="dox.css">
<title>TreeView</title>
<script type="text/javascript">
<!-- // Hide script from old browsers
function toggleFolder(id, imageNode)
{
var folder = document.getElementById(id);
var l = imageNode.src.length;
if (imageNode.src.substring(l-20,l)=="ftv2folderclosed.png" ||
imageNode.src.substring(l-18,l)=="ftv2folderopen.png")
{
imageNode = imageNode.previousSibling;
l = imageNode.src.length;
}
if (folder == null)
{
}
else if (folder.style.display == "block")
{
if (imageNode != null)
{
imageNode.nextSibling.src = "ftv2folderclosed.png";
if (imageNode.src.substring(l-13,l) == "ftv2mnode.png")
{
imageNode.src = "ftv2pnode.png";
}
else if (imageNode.src.substring(l-17,l) == "ftv2mlastnode.png")
{
imageNode.src = "ftv2plastnode.png";
}
}
folder.style.display = "none";
}
else
{
if (imageNode != null)
{
imageNode.nextSibling.src = "ftv2folderopen.png";
if (imageNode.src.substring(l-13,l) == "ftv2pnode.png")
{
imageNode.src = "ftv2mnode.png";
}
else if (imageNode.src.substring(l-17,l) == "ftv2plastnode.png")
{
imageNode.src = "ftv2mlastnode.png";
}
}
folder.style.display = "block";
}
}
// End script hiding -->
</script>
</head>
<body class="ftvtree">
<div class="directory">
<h3>Simulavr</h3>
<div style="display: block;">
<p><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="main.html" target="basefrm">Simulavr Internals</a></p>
<p><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="memory_management.html" target="basefrm">Memory Management</a></p>
<p><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="object_system.html" target="basefrm">Objects</a></p>
<p><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="insn_decoder.html" target="basefrm">Instruction Decoder</a></p>
<p><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="interrupts.html" target="basefrm">Interrupts</a></p>
<p><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="virtual_devs.html" target="basefrm">Virtual Devices</a></p>
<p><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="ext_devs.html" target="basefrm">External Devices</a></p>
<p><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="break_watch_pts.html" target="basefrm">Breakpoints and Watchpoints</a></p>
<p><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="todo.html" target="basefrm">Todo List</a></p>
<p><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="deprecated.html" target="basefrm">Deprecated List</a></p>
<p><img src="ftv2pnode.png" alt="o" width=16 height=22 onclick="toggleFolder('folder1', this)"/><img src="ftv2folderclosed.png" alt="+" width=24 height=22 onclick="toggleFolder('folder1', this)"/><a class="el" href="files.html" target="basefrm">File List</a></p>
<div id="folder1">
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="adc_8c.html" target="basefrm">adc.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="avrclass_8c.html" target="basefrm">avrclass.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="avrcore_8c.html" target="basefrm">avrcore.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="avrerror_8c.html" target="basefrm">avrerror.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="avrmalloc_8c.html" target="basefrm">avrmalloc.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><b>callback.c</b></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="decoder_8c.html" target="basefrm">decoder.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="device_8c.html" target="basefrm">device.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="devsupp_8c.html" target="basefrm">devsupp.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="display_8c.html" target="basefrm">display.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><b>eeprom.c</b></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="flash_8c.html" target="basefrm">flash.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="gdbserver_8c.html" target="basefrm">gdbserver.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><b>intvects.c</b></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><b>main.c</b></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="memory_8c.html" target="basefrm">memory.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><b>op_names.c</b></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="ports_8c.html" target="basefrm">ports.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><b>register.c</b></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="sig_8c.html" target="basefrm">sig.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="spi_8c.html" target="basefrm">spi.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><b>sram.c</b></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="stack_8c.html" target="basefrm">stack.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><b>storage.c</b></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="timers_8c.html" target="basefrm">timers.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="uart_8c.html" target="basefrm">uart.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2node.png" alt="o" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="usb_8c.html" target="basefrm">usb.c</a></p>
<p><img src="ftv2vertline.png" alt="|" width=16 height=22 /><img src="ftv2lastnode.png" alt="\" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="utils_8c.html" target="basefrm">utils.c</a></p>
</div>
<p><img src="ftv2lastnode.png" alt="\" width=16 height=22 /><img src="ftv2doc.png" alt="*" width=24 height=22 /><a class="el" href="globals.html" target="basefrm">Globals</a></p>
</div>
</div>
</body>
</html>

View file

@ -0,0 +1,607 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>uart.c</h1><a href="uart_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: uart.c,v 1.4 2008/03/16 21:14:08 joerg_wunsch Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2003, 2004 Keith Gudger</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/**</span>
<a name="l00027"></a>00027 <span class="comment"> * \file uart.c</span>
<a name="l00028"></a>00028 <span class="comment"> * \brief Module to simulate the AVR's uart module.</span>
<a name="l00029"></a>00029 <span class="comment"> */</span>
<a name="l00030"></a>00030
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00032"></a>00032
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00036"></a>00036
<a name="l00037"></a>00037 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include "utils.h"</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include "callback.h"</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include "op_names.h"</span>
<a name="l00043"></a>00043
<a name="l00044"></a>00044 <span class="preprocessor">#include "storage.h"</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include "flash.h"</span>
<a name="l00046"></a>00046
<a name="l00047"></a>00047 <span class="preprocessor">#include "vdevs.h"</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include "memory.h"</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include "stack.h"</span>
<a name="l00050"></a>00050 <span class="preprocessor">#include "register.h"</span>
<a name="l00051"></a>00051 <span class="preprocessor">#include "sram.h"</span>
<a name="l00052"></a>00052 <span class="preprocessor">#include "eeprom.h"</span>
<a name="l00053"></a>00053 <span class="preprocessor">#include "timers.h"</span>
<a name="l00054"></a>00054 <span class="preprocessor">#include "ports.h"</span>
<a name="l00055"></a>00055 <span class="preprocessor">#include "uart.h"</span>
<a name="l00056"></a>00056
<a name="l00057"></a>00057 <span class="preprocessor">#include "avrcore.h"</span>
<a name="l00058"></a>00058
<a name="l00059"></a>00059 <span class="preprocessor">#include "intvects.h"</span>
<a name="l00060"></a>00060
<a name="l00061"></a>00061 <span class="comment">/****************************************************************************\</span>
<a name="l00062"></a>00062 <span class="comment"> *</span>
<a name="l00063"></a>00063 <span class="comment"> * uart Interrupts </span>
<a name="l00064"></a>00064 <span class="comment"> *</span>
<a name="l00065"></a>00065 <span class="comment">\****************************************************************************/</span>
<a name="l00066"></a>00066
<a name="l00067"></a>00067 <span class="keyword">static</span> <span class="keywordtype">void</span> uart_iadd_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr,
<a name="l00068"></a>00068 <span class="keywordtype">void</span> *data);
<a name="l00069"></a>00069 <span class="keyword">static</span> uint8_t uart_intr_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00070"></a>00070 <span class="keyword">static</span> <span class="keywordtype">void</span> uart_intr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00071"></a>00071 <span class="keyword">static</span> <span class="keywordtype">void</span> uart_intr_reset (VDevice *dev);
<a name="l00072"></a>00072 <span class="keyword">static</span> <span class="keywordtype">int</span> uart_intr_cb (uint64_t time, AvrClass *data);
<a name="l00073"></a>00073
<a name="l00074"></a>00074 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> UART_Int_Table[] = {
<a name="l00075"></a>00075 irq_vect_table_index (UART_RX), <span class="comment">/* uart Rx complete */</span>
<a name="l00076"></a>00076 irq_vect_table_index (UART_UDRE), <span class="comment">/* uart data register empty */</span>
<a name="l00077"></a>00077 irq_vect_table_index (UART_TX) <span class="comment">/* uart Tx complete */</span>
<a name="l00078"></a>00078 };
<a name="l00079"></a>00079
<a name="l00080"></a>00080 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> UART0_Int_Table[] = {
<a name="l00081"></a>00081 irq_vect_table_index (USART0_RX), <span class="comment">/* uart Rx complete */</span>
<a name="l00082"></a>00082 irq_vect_table_index (USART0_UDRE), <span class="comment">/* uart data register empty */</span>
<a name="l00083"></a>00083 irq_vect_table_index (USART0_TX) <span class="comment">/* uart Tx complete */</span>
<a name="l00084"></a>00084 };
<a name="l00085"></a>00085
<a name="l00086"></a>00086 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> UART1_Int_Table[] = {
<a name="l00087"></a>00087 irq_vect_table_index (USART1_RX), <span class="comment">/* uart Rx complete */</span>
<a name="l00088"></a>00088 irq_vect_table_index (USART1_UDRE), <span class="comment">/* uart data register empty */</span>
<a name="l00089"></a>00089 irq_vect_table_index (USART1_TX) <span class="comment">/* uart Tx complete */</span>
<a name="l00090"></a>00090 };
<a name="l00091"></a>00091 <span class="comment"></span>
<a name="l00092"></a>00092 <span class="comment">/** \brief Allocate a new uart interrupt */</span>
<a name="l00093"></a>00093
<a name="l00094"></a>00094 VDevice *
<a name="l00095"></a><a class="code" href="uart_8c.html#d7ab0fb5b4d3fbec10a1777c2627c2f0">00095</a> <a class="code" href="uart_8c.html#d7ab0fb5b4d3fbec10a1777c2627c2f0" title="Allocate a new uart interrupt.">uart_int_create</a> (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00096"></a>00096 {
<a name="l00097"></a>00097 <span class="keywordflow">if</span> (data)
<a name="l00098"></a>00098 <span class="keywordflow">return</span> (VDevice *)uart_intr_new (addr, name, data);
<a name="l00099"></a>00099 <span class="keywordflow">else</span>
<a name="l00100"></a>00100 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Attempted UART create with NULL data pointer"</span>);
<a name="l00101"></a>00101 <span class="keywordflow">return</span> 0;
<a name="l00102"></a>00102 }
<a name="l00103"></a>00103
<a name="l00104"></a>00104 UARTIntr_T *
<a name="l00105"></a>00105 uart_intr_new (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">void</span> *data)
<a name="l00106"></a>00106 {
<a name="l00107"></a>00107 uint8_t *uart_num = (uint8_t *) data;
<a name="l00108"></a>00108 UARTIntr_T *uart;
<a name="l00109"></a>00109
<a name="l00110"></a>00110 uart = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (UARTIntr_T, 1);
<a name="l00111"></a>00111 <a class="code" href="uart_8c.html#673d5a70c22d5a19f244fe2a17fd6c1d" title="Constructor for uart interrupt object.">uart_intr_construct</a> (uart, addr, name);
<a name="l00112"></a>00112 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)uart, <a class="code" href="uart_8c.html#cc2bbf6f2d72e20d553521a554ab551a" title="Destructor for uart interrupt object.">uart_intr_destroy</a>);
<a name="l00113"></a>00113
<a name="l00114"></a>00114 <span class="keywordflow">if</span> (*uart_num == USART0)
<a name="l00115"></a>00115 uart-&gt;Int_Table = &amp;UART0_Int_Table[0];
<a name="l00116"></a>00116 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (*uart_num == USART1)
<a name="l00117"></a>00117 uart-&gt;Int_Table = &amp;UART1_Int_Table[0];
<a name="l00118"></a>00118 <span class="keywordflow">else</span>
<a name="l00119"></a>00119 uart-&gt;Int_Table = &amp;UART_Int_Table[0];
<a name="l00120"></a>00120
<a name="l00121"></a>00121 uart_iadd_addr ((VDevice *)uart, addr, name, 0, NULL);
<a name="l00122"></a>00122 <span class="keywordflow">return</span> uart;
<a name="l00123"></a>00123 }
<a name="l00124"></a>00124 <span class="comment"></span>
<a name="l00125"></a>00125 <span class="comment">/** \brief Constructor for uart interrupt object. */</span>
<a name="l00126"></a>00126
<a name="l00127"></a>00127 <span class="keywordtype">void</span>
<a name="l00128"></a><a class="code" href="uart_8c.html#673d5a70c22d5a19f244fe2a17fd6c1d">00128</a> <a class="code" href="uart_8c.html#673d5a70c22d5a19f244fe2a17fd6c1d" title="Constructor for uart interrupt object.">uart_intr_construct</a> (UARTIntr_T *uart, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name)
<a name="l00129"></a>00129 {
<a name="l00130"></a>00130 <span class="keywordflow">if</span> (uart == NULL)
<a name="l00131"></a>00131 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00132"></a>00132
<a name="l00133"></a>00133 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)uart, uart_intr_read, uart_intr_write,
<a name="l00134"></a>00134 uart_intr_reset, uart_iadd_addr);
<a name="l00135"></a>00135
<a name="l00136"></a>00136 uart_intr_reset ((VDevice *)uart);
<a name="l00137"></a>00137 }
<a name="l00138"></a>00138
<a name="l00139"></a>00139 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00140"></a>00140 uart_iadd_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00141"></a>00141 {
<a name="l00142"></a>00142 UARTIntr_T *uart = (UARTIntr_T *)vdev;
<a name="l00143"></a>00143
<a name="l00144"></a>00144 <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"UBRRH"</span>, name, 5) == 0)
<a name="l00145"></a>00145 {
<a name="l00146"></a>00146 uart-&gt;ubrrh_addr = addr;
<a name="l00147"></a>00147 }
<a name="l00148"></a>00148
<a name="l00149"></a>00149 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((strncmp (<span class="stringliteral">"UBRR"</span>, name, 4) == 0)
<a name="l00150"></a>00150 || (strncmp (<span class="stringliteral">"UBRR0"</span>, name, 5) == 0)
<a name="l00151"></a>00151 || (strncmp (<span class="stringliteral">"UBRR1"</span>, name, 5) == 0))
<a name="l00152"></a>00152 {
<a name="l00153"></a>00153 uart-&gt;ubrrl_addr = addr;
<a name="l00154"></a>00154 }
<a name="l00155"></a>00155
<a name="l00156"></a>00156 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((strncmp (<span class="stringliteral">"USR"</span>, name, 3) == 0)
<a name="l00157"></a>00157 || (strncmp (<span class="stringliteral">"UCSR0A"</span>, name, 6) == 0)
<a name="l00158"></a>00158 || (strncmp (<span class="stringliteral">"UCSR1A"</span>, name, 6) == 0))
<a name="l00159"></a>00159 {
<a name="l00160"></a>00160 uart-&gt;usr_addr = addr;
<a name="l00161"></a>00161 }
<a name="l00162"></a>00162
<a name="l00163"></a>00163 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((strncmp (<span class="stringliteral">"UCR"</span>, name, 3) == 0)
<a name="l00164"></a>00164 || (strncmp (<span class="stringliteral">"UCSR0B"</span>, name, 6) == 0)
<a name="l00165"></a>00165 || (strncmp (<span class="stringliteral">"UCSR1B"</span>, name, 6) == 0))
<a name="l00166"></a>00166 {
<a name="l00167"></a>00167 uart-&gt;ucr_addr = addr;
<a name="l00168"></a>00168 }
<a name="l00169"></a>00169
<a name="l00170"></a>00170 <span class="keywordflow">else</span>
<a name="l00171"></a>00171 {
<a name="l00172"></a>00172 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"invalid UART register name: '%s' @ 0x%04x"</span>, name, addr);
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174 }
<a name="l00175"></a>00175 <span class="comment"></span>
<a name="l00176"></a>00176 <span class="comment">/** \brief Destructor for uart interrupt object. */</span>
<a name="l00177"></a>00177
<a name="l00178"></a>00178 <span class="keywordtype">void</span>
<a name="l00179"></a><a class="code" href="uart_8c.html#cc2bbf6f2d72e20d553521a554ab551a">00179</a> <a class="code" href="uart_8c.html#cc2bbf6f2d72e20d553521a554ab551a" title="Destructor for uart interrupt object.">uart_intr_destroy</a> (<span class="keywordtype">void</span> *uart)
<a name="l00180"></a>00180 {
<a name="l00181"></a>00181 <span class="keywordflow">if</span> (uart == NULL)
<a name="l00182"></a>00182 <span class="keywordflow">return</span>;
<a name="l00183"></a>00183
<a name="l00184"></a>00184 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (uart);
<a name="l00185"></a>00185 }
<a name="l00186"></a>00186
<a name="l00187"></a>00187 <span class="keyword">static</span> uint8_t
<a name="l00188"></a>00188 uart_intr_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00189"></a>00189 {
<a name="l00190"></a>00190 UARTIntr_T *uart = (UARTIntr_T *)dev;
<a name="l00191"></a>00191
<a name="l00192"></a>00192 <span class="keywordflow">if</span> (addr == uart-&gt;ubrrl_addr)
<a name="l00193"></a>00193 {
<a name="l00194"></a>00194 <span class="keywordflow">return</span> (uart-&gt;ubrr &amp; 0xff);
<a name="l00195"></a>00195 }
<a name="l00196"></a>00196
<a name="l00197"></a>00197 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == uart-&gt;ubrrh_addr)
<a name="l00198"></a>00198 {
<a name="l00199"></a>00199 <span class="keywordflow">return</span> (uart-&gt;ubrr &gt;&gt; 8);
<a name="l00200"></a>00200 }
<a name="l00201"></a>00201
<a name="l00202"></a>00202 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == uart-&gt;ucr_addr)
<a name="l00203"></a>00203 {
<a name="l00204"></a>00204 <span class="keywordflow">return</span> (uart-&gt;ucr);
<a name="l00205"></a>00205 }
<a name="l00206"></a>00206
<a name="l00207"></a>00207 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == uart-&gt;usr_addr)
<a name="l00208"></a>00208 {
<a name="l00209"></a>00209 <span class="keywordflow">return</span> (uart-&gt;usr);
<a name="l00210"></a>00210 }
<a name="l00211"></a>00211
<a name="l00212"></a>00212 <span class="keywordflow">else</span>
<a name="l00213"></a>00213 {
<a name="l00214"></a>00214 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00215"></a>00215 }
<a name="l00216"></a>00216
<a name="l00217"></a>00217 <span class="keywordflow">return</span> 0; <span class="comment">/* will never get here */</span>
<a name="l00218"></a>00218 }
<a name="l00219"></a>00219
<a name="l00220"></a>00220 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00221"></a>00221 uart_intr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00222"></a>00222 {
<a name="l00223"></a>00223 UARTIntr_T *uart = (UARTIntr_T *)dev;
<a name="l00224"></a>00224 CallBack *cb;
<a name="l00225"></a>00225
<a name="l00226"></a>00226 <span class="keywordflow">if</span> (addr == uart-&gt;ubrrl_addr)
<a name="l00227"></a>00227 {
<a name="l00228"></a>00228 uart-&gt;ubrr = val + (uart-&gt;ubrr_temp &lt;&lt; 8);
<a name="l00229"></a>00229 }
<a name="l00230"></a>00230
<a name="l00231"></a>00231 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == uart-&gt;ubrrh_addr)
<a name="l00232"></a>00232 {
<a name="l00233"></a>00233 uart-&gt;ubrr_temp = val;
<a name="l00234"></a>00234 }
<a name="l00235"></a>00235
<a name="l00236"></a>00236 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == uart-&gt;usr)
<a name="l00237"></a>00237 {
<a name="l00238"></a>00238 <span class="keywordflow">if</span> (val &amp; mask_TXC)
<a name="l00239"></a>00239 uart-&gt;usr &amp;= ~mask_TXC;
<a name="l00240"></a>00240 }
<a name="l00241"></a>00241
<a name="l00242"></a>00242 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == uart-&gt;ucr_addr)
<a name="l00243"></a>00243 {
<a name="l00244"></a>00244 (uart-&gt;ucr = val); <span class="comment">/* look for interrupt enables */</span>
<a name="l00245"></a>00245
<a name="l00246"></a>00246 <span class="keywordflow">if</span> (((uart-&gt;ucr &amp; mask_TXEN) &amp;&amp; (uart-&gt;ucr &amp; mask_TXCIE))
<a name="l00247"></a>00247 || ((uart-&gt;ucr &amp; mask_RXEN) &amp;&amp; (uart-&gt;ucr &amp; mask_RXCIE))
<a name="l00248"></a>00248 || (uart-&gt;ucr &amp; mask_UDRIE))
<a name="l00249"></a>00249 {
<a name="l00250"></a>00250 <span class="keywordflow">if</span> (uart-&gt;intr_cb == NULL)
<a name="l00251"></a>00251 {
<a name="l00252"></a>00252 <span class="comment">/* we need to install the intr_cb function */</span>
<a name="l00253"></a>00253 cb = callback_new (uart_intr_cb, (AvrClass *)uart);
<a name="l00254"></a>00254 uart-&gt;intr_cb = cb;
<a name="l00255"></a>00255 <a class="code" href="avrcore_8c.html#e821588464c39dbdcc9fb5eea45da0aa" title="Add a new asynchronous callback to list.">avr_core_async_cb_add</a> ((AvrCore *)<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> (dev), cb);
<a name="l00256"></a>00256 }
<a name="l00257"></a>00257 }
<a name="l00258"></a>00258 <span class="keywordflow">else</span>
<a name="l00259"></a>00259 {
<a name="l00260"></a>00260 uart-&gt;intr_cb = NULL;
<a name="l00261"></a>00261 <span class="comment">/* no interrupt are enabled, remove the callback */</span>
<a name="l00262"></a>00262 }
<a name="l00263"></a>00263 }
<a name="l00264"></a>00264
<a name="l00265"></a>00265 <span class="keywordflow">else</span>
<a name="l00266"></a>00266 {
<a name="l00267"></a>00267 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00268"></a>00268 }
<a name="l00269"></a>00269 }
<a name="l00270"></a>00270
<a name="l00271"></a>00271 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00272"></a>00272 uart_intr_reset (VDevice *dev)
<a name="l00273"></a>00273 {
<a name="l00274"></a>00274 UARTIntr_T *uart = (UARTIntr_T *)dev;
<a name="l00275"></a>00275
<a name="l00276"></a>00276 uart-&gt;intr_cb = NULL;
<a name="l00277"></a>00277
<a name="l00278"></a>00278 uart-&gt;ubrr = 0;
<a name="l00279"></a>00279 uart-&gt;usr = 0;
<a name="l00280"></a>00280 uart-&gt;ucr = 0;
<a name="l00281"></a>00281 uart-&gt;usr_shadow = 0;
<a name="l00282"></a>00282 }
<a name="l00283"></a>00283
<a name="l00284"></a>00284 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00285"></a>00285 uart_intr_cb (uint64_t time, AvrClass *data)
<a name="l00286"></a>00286 {
<a name="l00287"></a>00287 UARTIntr_T *uart = (UARTIntr_T *)data;
<a name="l00288"></a>00288
<a name="l00289"></a>00289 <span class="keywordflow">if</span> (uart-&gt;intr_cb == NULL)
<a name="l00290"></a>00290 <span class="keywordflow">return</span> CB_RET_REMOVE;
<a name="l00291"></a>00291
<a name="l00292"></a>00292 <span class="keywordflow">if</span> ((uart-&gt;ucr &amp; mask_RXCIE) &amp;&amp; (uart-&gt;usr &amp; mask_RXC))
<a name="l00293"></a>00293 <span class="comment">/* an enabled interrupt occured */</span>
<a name="l00294"></a>00294 {
<a name="l00295"></a>00295 AvrCore *core = (AvrCore *)<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)uart);
<a name="l00296"></a>00296 <a class="code" href="avrcore_8c.html#90ca5d4a60478f9fccad81724a4be552" title="Raises an irq by adding it&amp;#39;s data to the irq_pending list.">avr_core_irq_raise</a> (core, (uart-&gt;Int_Table[URX]));
<a name="l00297"></a>00297 }
<a name="l00298"></a>00298
<a name="l00299"></a>00299 <span class="keywordflow">if</span> ((uart-&gt;ucr &amp; mask_TXCIE) &amp;&amp; (uart-&gt;usr &amp; mask_TXC))
<a name="l00300"></a>00300 <span class="comment">/* an enabled interrupt occured */</span>
<a name="l00301"></a>00301 {
<a name="l00302"></a>00302 AvrCore *core = (AvrCore *)<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)uart);
<a name="l00303"></a>00303 <a class="code" href="avrcore_8c.html#90ca5d4a60478f9fccad81724a4be552" title="Raises an irq by adding it&amp;#39;s data to the irq_pending list.">avr_core_irq_raise</a> (core, (uart-&gt;Int_Table[UTX]));
<a name="l00304"></a>00304 uart-&gt;usr &amp;= ~mask_TXC;
<a name="l00305"></a>00305 }
<a name="l00306"></a>00306
<a name="l00307"></a>00307 <span class="keywordflow">if</span> ((uart-&gt;ucr &amp; mask_UDRIE) &amp;&amp; (uart-&gt;usr &amp; mask_UDRE)
<a name="l00308"></a>00308 &amp;&amp; (uart-&gt;usr_shadow &amp; mask_UDRE))
<a name="l00309"></a>00309 <span class="comment">/* an enabled interrupt occured */</span>
<a name="l00310"></a>00310 {
<a name="l00311"></a>00311 AvrCore *core = (AvrCore *)<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)uart);
<a name="l00312"></a>00312 <a class="code" href="avrcore_8c.html#90ca5d4a60478f9fccad81724a4be552" title="Raises an irq by adding it&amp;#39;s data to the irq_pending list.">avr_core_irq_raise</a> (core, (uart-&gt;Int_Table[UUDRE]));
<a name="l00313"></a>00313 uart-&gt;usr_shadow &amp;= ~mask_UDRE; <span class="comment">/* only issue one interrupt / udre */</span>
<a name="l00314"></a>00314 }
<a name="l00315"></a>00315
<a name="l00316"></a>00316 <span class="keywordflow">return</span> CB_RET_RETAIN;
<a name="l00317"></a>00317 }
<a name="l00318"></a>00318
<a name="l00319"></a>00319 <span class="comment">/****************************************************************************\</span>
<a name="l00320"></a>00320 <span class="comment"> *</span>
<a name="l00321"></a>00321 <span class="comment"> * uart </span>
<a name="l00322"></a>00322 <span class="comment"> *</span>
<a name="l00323"></a>00323 <span class="comment">\****************************************************************************/</span>
<a name="l00324"></a>00324
<a name="l00325"></a>00325 <span class="keyword">static</span> <span class="keywordtype">void</span> uart_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr,
<a name="l00326"></a>00326 <span class="keywordtype">void</span> *data);
<a name="l00327"></a>00327 <span class="keyword">static</span> uint8_t uart_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00328"></a>00328 <span class="keyword">static</span> <span class="keywordtype">void</span> uart_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00329"></a>00329 <span class="keyword">static</span> <span class="keywordtype">void</span> uart_reset (VDevice *dev);
<a name="l00330"></a>00330 <span class="keyword">static</span> <span class="keywordtype">int</span> uart_clk_incr_cb (uint64_t ck, AvrClass *data);
<a name="l00331"></a>00331 <span class="comment"></span>
<a name="l00332"></a>00332 <span class="comment">/** \brief Allocate a new uart structure. */</span>
<a name="l00333"></a>00333
<a name="l00334"></a>00334 VDevice *
<a name="l00335"></a><a class="code" href="uart_8c.html#15018100db23349def4e37027d5a8932">00335</a> <a class="code" href="uart_8c.html#15018100db23349def4e37027d5a8932" title="Allocate a new uart structure.">uart_create</a> (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00336"></a>00336 {
<a name="l00337"></a>00337 <span class="keywordflow">return</span> (VDevice *)uart_new (addr, name, rel_addr);
<a name="l00338"></a>00338 }
<a name="l00339"></a>00339
<a name="l00340"></a>00340 UART_T *
<a name="l00341"></a>00341 uart_new (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr)
<a name="l00342"></a>00342 {
<a name="l00343"></a>00343 UART_T *uart;
<a name="l00344"></a>00344
<a name="l00345"></a>00345 uart = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (UART_T, 1);
<a name="l00346"></a>00346 <a class="code" href="uart_8c.html#bb93863003e66ea6b40400a4631656aa" title="Constructor for uart object.">uart_construct</a> (uart, addr, name, rel_addr);
<a name="l00347"></a>00347
<a name="l00348"></a>00348 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)uart, <a class="code" href="uart_8c.html#c80ec8e26d6b5ece2d7e4c57f371ac01" title="Destructor for uart object.">uart_destroy</a>);
<a name="l00349"></a>00349
<a name="l00350"></a>00350 <span class="keywordflow">return</span> uart;
<a name="l00351"></a>00351 }
<a name="l00352"></a>00352 <span class="comment"></span>
<a name="l00353"></a>00353 <span class="comment">/** \brief Constructor for uart object. */</span>
<a name="l00354"></a>00354
<a name="l00355"></a>00355 <span class="keywordtype">void</span>
<a name="l00356"></a><a class="code" href="uart_8c.html#bb93863003e66ea6b40400a4631656aa">00356</a> <a class="code" href="uart_8c.html#bb93863003e66ea6b40400a4631656aa" title="Constructor for uart object.">uart_construct</a> (UART_T *uart, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr)
<a name="l00357"></a>00357 {
<a name="l00358"></a>00358 <span class="keywordflow">if</span> (uart == NULL)
<a name="l00359"></a>00359 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00360"></a>00360
<a name="l00361"></a>00361 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)uart, uart_read, uart_write, uart_reset,
<a name="l00362"></a>00362 uart_add_addr);
<a name="l00363"></a>00363
<a name="l00364"></a>00364 uart_add_addr ((VDevice *)uart, addr, name, 0, NULL);
<a name="l00365"></a>00365 <span class="keywordflow">if</span> (rel_addr)
<a name="l00366"></a>00366 uart-&gt;related_addr = rel_addr;
<a name="l00367"></a>00367 uart_reset ((VDevice *)uart);
<a name="l00368"></a>00368 }
<a name="l00369"></a>00369
<a name="l00370"></a>00370 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00371"></a>00371 uart_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> ref_addr, <span class="keywordtype">void</span> *data)
<a name="l00372"></a>00372 {
<a name="l00373"></a>00373 UART_T *uart = (UART_T *)vdev;
<a name="l00374"></a>00374
<a name="l00375"></a>00375 <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"UDR"</span>, name, 3) == 0)
<a name="l00376"></a>00376 {
<a name="l00377"></a>00377 uart-&gt;udr_addr = addr;
<a name="l00378"></a>00378 }
<a name="l00379"></a>00379
<a name="l00380"></a>00380 <span class="keywordflow">else</span>
<a name="l00381"></a>00381 {
<a name="l00382"></a>00382 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"invalid SPI register name: '%s' @ 0x%04x"</span>, name, addr);
<a name="l00383"></a>00383 }
<a name="l00384"></a>00384 }
<a name="l00385"></a>00385 <span class="comment"></span>
<a name="l00386"></a>00386 <span class="comment">/** \brief Destructor for uart object. */</span>
<a name="l00387"></a>00387
<a name="l00388"></a>00388 <span class="keywordtype">void</span>
<a name="l00389"></a><a class="code" href="uart_8c.html#c80ec8e26d6b5ece2d7e4c57f371ac01">00389</a> <a class="code" href="uart_8c.html#c80ec8e26d6b5ece2d7e4c57f371ac01" title="Destructor for uart object.">uart_destroy</a> (<span class="keywordtype">void</span> *uart)
<a name="l00390"></a>00390 {
<a name="l00391"></a>00391 <span class="keywordflow">if</span> (uart == NULL)
<a name="l00392"></a>00392 <span class="keywordflow">return</span>;
<a name="l00393"></a>00393
<a name="l00394"></a>00394 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (uart);
<a name="l00395"></a>00395 }
<a name="l00396"></a>00396
<a name="l00397"></a>00397 <span class="keyword">static</span> uint8_t
<a name="l00398"></a>00398 uart_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00399"></a>00399 {
<a name="l00400"></a>00400 UART_T *uart = (UART_T *)dev;
<a name="l00401"></a>00401 UARTIntr_T *uart_t;
<a name="l00402"></a>00402 uint16_t udr_temp;
<a name="l00403"></a>00403
<a name="l00404"></a>00404 uart_t =
<a name="l00405"></a>00405 (UARTIntr_T *)<a class="code" href="avrcore_8c.html#f0c70bc7f992dcacd8ab411993bea5b5" title="Returns the VDevice which handles the address addr.">avr_core_get_vdev_by_addr</a> ((AvrCore *)
<a name="l00406"></a>00406 <a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)
<a name="l00407"></a>00407 uart),
<a name="l00408"></a>00408 uart-&gt;related_addr);
<a name="l00409"></a>00409
<a name="l00410"></a>00410 <span class="keywordflow">if</span> (addr == uart-&gt;udr_addr)
<a name="l00411"></a>00411 {
<a name="l00412"></a>00412 uart_t-&gt;usr &amp;= ~mask_RXC; <span class="comment">/* clear RXC bit in USR */</span>
<a name="l00413"></a>00413 <span class="keywordflow">if</span> (uart-&gt;clk_cb) <span class="comment">/* call back already installed */</span>
<a name="l00414"></a>00414 {
<a name="l00415"></a>00415 udr_temp = uart_port_rd (addr);
<a name="l00416"></a>00416 uart-&gt;udr_rx = (uint8_t) udr_temp; <span class="comment">/* lower 8 bits */</span>
<a name="l00417"></a>00417 <span class="keywordflow">if</span> ((uart_t-&gt;ucr &amp; mask_CHR9) &amp;&amp; <span class="comment">/* 9 bits rec'd */</span>
<a name="l00418"></a>00418 (udr_temp &amp; (1 &lt;&lt; 8))) <span class="comment">/* hi bit set */</span>
<a name="l00419"></a>00419 uart_t-&gt;ucr |= mask_RXB8;
<a name="l00420"></a>00420 <span class="keywordflow">else</span>
<a name="l00421"></a>00421 uart_t-&gt;ucr &amp;= ~mask_RXB8;
<a name="l00422"></a>00422 }
<a name="l00423"></a>00423 <span class="keywordflow">return</span> uart-&gt;udr_rx;
<a name="l00424"></a>00424 }
<a name="l00425"></a>00425
<a name="l00426"></a>00426 <span class="keywordflow">else</span>
<a name="l00427"></a>00427 {
<a name="l00428"></a>00428 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00429"></a>00429 }
<a name="l00430"></a>00430
<a name="l00431"></a>00431 <span class="keywordflow">return</span> 0; <span class="comment">/* will never get here */</span>
<a name="l00432"></a>00432 }
<a name="l00433"></a>00433
<a name="l00434"></a>00434 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00435"></a>00435 uart_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00436"></a>00436 {
<a name="l00437"></a>00437 UART_T *uart = (UART_T *)dev;
<a name="l00438"></a>00438 UARTIntr_T *uart_t;
<a name="l00439"></a>00439 CallBack *cb;
<a name="l00440"></a>00440
<a name="l00441"></a>00441 uart_t =
<a name="l00442"></a>00442 (UARTIntr_T *)<a class="code" href="avrcore_8c.html#f0c70bc7f992dcacd8ab411993bea5b5" title="Returns the VDevice which handles the address addr.">avr_core_get_vdev_by_addr</a> ((AvrCore *)
<a name="l00443"></a>00443 <a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)
<a name="l00444"></a>00444 uart),
<a name="l00445"></a>00445 uart-&gt;related_addr);
<a name="l00446"></a>00446
<a name="l00447"></a>00447 <span class="keywordflow">if</span> (addr == uart-&gt;udr_addr)
<a name="l00448"></a>00448 {
<a name="l00449"></a>00449 <span class="keywordflow">if</span> (uart_t-&gt;usr &amp; mask_UDRE)
<a name="l00450"></a>00450 {
<a name="l00451"></a>00451 uart_t-&gt;usr &amp;= ~mask_UDRE;
<a name="l00452"></a>00452 uart_t-&gt;usr_shadow &amp;= ~mask_UDRE;
<a name="l00453"></a>00453 }
<a name="l00454"></a>00454 <span class="keywordflow">else</span>
<a name="l00455"></a>00455 {
<a name="l00456"></a>00456 uart_t-&gt;usr |= mask_UDRE;
<a name="l00457"></a>00457 uart_t-&gt;usr_shadow |= mask_UDRE;
<a name="l00458"></a>00458 }
<a name="l00459"></a>00459 uart-&gt;udr_tx = val;
<a name="l00460"></a>00460
<a name="l00461"></a>00461 <span class="comment">/*</span>
<a name="l00462"></a>00462 <span class="comment"> * When the user writes to UDR, a callback is installed for </span>
<a name="l00463"></a>00463 <span class="comment"> * clock generated increments. </span>
<a name="l00464"></a>00464 <span class="comment"> */</span>
<a name="l00465"></a>00465
<a name="l00466"></a>00466 uart-&gt;divisor = (uart_t-&gt;ubrr + 1) * 16;
<a name="l00467"></a>00467
<a name="l00468"></a>00468 <span class="comment">/* install the clock incrementor callback (with flair!) */</span>
<a name="l00469"></a>00469
<a name="l00470"></a>00470 <span class="keywordflow">if</span> (uart-&gt;clk_cb == NULL)
<a name="l00471"></a>00471 {
<a name="l00472"></a>00472 cb = callback_new (uart_clk_incr_cb, (AvrClass *)uart);
<a name="l00473"></a>00473 uart-&gt;clk_cb = cb;
<a name="l00474"></a>00474 <a class="code" href="avrcore_8c.html#3e755b8388c3c44ea514484ce53ace75" title="Add a new clock callback to list.">avr_core_clk_cb_add</a> ((AvrCore *)<a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)uart),
<a name="l00475"></a>00475 cb);
<a name="l00476"></a>00476 }
<a name="l00477"></a>00477
<a name="l00478"></a>00478 <span class="comment">/* set up timer for 8 or 9 clocks based on ucr </span>
<a name="l00479"></a>00479 <span class="comment"> (includes start and stop bits) */</span>
<a name="l00480"></a>00480
<a name="l00481"></a>00481 uart-&gt;tcnt = (uart_t-&gt;ucr &amp; mask_CHR9) ? 11 : 10;
<a name="l00482"></a>00482 }
<a name="l00483"></a>00483
<a name="l00484"></a>00484 <span class="keywordflow">else</span>
<a name="l00485"></a>00485 {
<a name="l00486"></a>00486 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00487"></a>00487 }
<a name="l00488"></a>00488 }
<a name="l00489"></a>00489
<a name="l00490"></a>00490 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00491"></a>00491 uart_reset (VDevice *dev)
<a name="l00492"></a>00492 {
<a name="l00493"></a>00493 UART_T *uart = (UART_T *)dev;
<a name="l00494"></a>00494
<a name="l00495"></a>00495 uart-&gt;clk_cb = NULL;
<a name="l00496"></a>00496
<a name="l00497"></a>00497 uart-&gt;udr_rx = 0;
<a name="l00498"></a>00498 uart-&gt;udr_tx = 0;
<a name="l00499"></a>00499 uart-&gt;tcnt = 0;
<a name="l00500"></a>00500 uart-&gt;divisor = 0;
<a name="l00501"></a>00501 }
<a name="l00502"></a>00502
<a name="l00503"></a>00503 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00504"></a>00504 uart_clk_incr_cb (uint64_t ck, AvrClass *data)
<a name="l00505"></a>00505 {
<a name="l00506"></a>00506 UART_T *uart = (UART_T *)data;
<a name="l00507"></a>00507 UARTIntr_T *uart_t;
<a name="l00508"></a>00508 uint8_t last = uart-&gt;tcnt;
<a name="l00509"></a>00509
<a name="l00510"></a>00510 uart_t =
<a name="l00511"></a>00511 (UARTIntr_T *)<a class="code" href="avrcore_8c.html#f0c70bc7f992dcacd8ab411993bea5b5" title="Returns the VDevice which handles the address addr.">avr_core_get_vdev_by_addr</a> ((AvrCore *)
<a name="l00512"></a>00512 <a class="code" href="device_8c.html#b59809dd04174aca0940efa2505a3524" title="Get the core field.">vdev_get_core</a> ((VDevice *)
<a name="l00513"></a>00513 uart),
<a name="l00514"></a>00514 uart-&gt;related_addr);
<a name="l00515"></a>00515
<a name="l00516"></a>00516 <span class="keywordflow">if</span> (uart-&gt;clk_cb == NULL)
<a name="l00517"></a>00517 <span class="keywordflow">return</span> CB_RET_REMOVE;
<a name="l00518"></a>00518
<a name="l00519"></a>00519 <span class="keywordflow">if</span> (uart-&gt;divisor &lt;= 0)
<a name="l00520"></a>00520 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad divisor value: %d"</span>, uart-&gt;divisor);
<a name="l00521"></a>00521
<a name="l00522"></a>00522 <span class="comment">/* decrement clock if ck is a mutliple of divisor */</span>
<a name="l00523"></a>00523
<a name="l00524"></a>00524 uart-&gt;tcnt -= ((ck % uart-&gt;divisor) == 0);
<a name="l00525"></a>00525
<a name="l00526"></a>00526 <span class="keywordflow">if</span> (uart-&gt;tcnt != last) <span class="comment">/* we've changed the counter */</span>
<a name="l00527"></a>00527 {
<a name="l00528"></a>00528 <span class="keywordflow">if</span> (uart-&gt;tcnt == 0)
<a name="l00529"></a>00529 {
<a name="l00530"></a>00530 <span class="keywordflow">if</span> (uart_t-&gt;usr &amp; mask_UDRE) <span class="comment">/* data register empty */</span>
<a name="l00531"></a>00531 {
<a name="l00532"></a>00532 uart_t-&gt;usr |= mask_TXC;
<a name="l00533"></a>00533 uart-&gt;clk_cb = NULL;
<a name="l00534"></a>00534 <span class="keywordflow">return</span> CB_RET_REMOVE;
<a name="l00535"></a>00535 }
<a name="l00536"></a>00536 <span class="keywordflow">else</span> <span class="comment">/* there's a byte waiting to go */</span>
<a name="l00537"></a>00537 {
<a name="l00538"></a>00538 uart_t-&gt;usr |= mask_UDRE;
<a name="l00539"></a>00539 uart_t-&gt;usr_shadow |= mask_UDRE; <span class="comment">/* also write shadow */</span>
<a name="l00540"></a>00540
<a name="l00541"></a>00541 <span class="comment">/* set up timer for 8 or 9 clocks based on ucr,</span>
<a name="l00542"></a>00542 <span class="comment"> (includes start and stop bits) */</span>
<a name="l00543"></a>00543
<a name="l00544"></a>00544 uart-&gt;tcnt = (uart_t-&gt;ucr &amp; mask_CHR9) ? 11 : 10;
<a name="l00545"></a>00545 }
<a name="l00546"></a>00546 }
<a name="l00547"></a>00547 }
<a name="l00548"></a>00548
<a name="l00549"></a>00549 <span class="keywordflow">return</span> CB_RET_RETAIN;
<a name="l00550"></a>00550 }
<a name="l00551"></a>00551
<a name="l00552"></a>00552 uint16_t
<a name="l00553"></a>00553 uart_port_rd (<span class="keywordtype">int</span> addr)
<a name="l00554"></a>00554 {
<a name="l00555"></a>00555 <span class="keywordtype">int</span> data;
<a name="l00556"></a>00556 <span class="keywordtype">char</span> line[80];
<a name="l00557"></a>00557
<a name="l00558"></a>00558 <span class="keywordflow">while</span> (1)
<a name="l00559"></a>00559 {
<a name="l00560"></a>00560 fprintf (stderr,
<a name="l00561"></a>00561 <span class="stringliteral">"\nEnter 9 bits of hex data to read into the uart at "</span>
<a name="l00562"></a>00562 <span class="stringliteral">"address 0x%04x: "</span>, addr);
<a name="l00563"></a>00563
<a name="l00564"></a>00564 <span class="comment">/* try to read in a line of input */</span>
<a name="l00565"></a>00565 <span class="keywordflow">if</span> (fgets (line, <span class="keyword">sizeof</span> (line), stdin) == NULL)
<a name="l00566"></a>00566 <span class="keywordflow">continue</span>;
<a name="l00567"></a>00567
<a name="l00568"></a>00568 <span class="comment">/* try to parse the line for a byte of data */</span>
<a name="l00569"></a>00569 <span class="keywordflow">if</span> (sscanf (line, <span class="stringliteral">"%x\n"</span>, &amp;data) != 1)
<a name="l00570"></a>00570 <span class="keywordflow">continue</span>;
<a name="l00571"></a>00571
<a name="l00572"></a>00572 <span class="keywordflow">break</span>;
<a name="l00573"></a>00573 }
<a name="l00574"></a>00574
<a name="l00575"></a>00575 <span class="keywordflow">return</span> (uint16_t) (data &amp; 0x1ff);
<a name="l00576"></a>00576 }
<a name="l00577"></a>00577
<a name="l00578"></a>00578 <span class="keywordtype">void</span>
<a name="l00579"></a>00579 uart_port_wr (uint8_t val)
<a name="l00580"></a>00580 {
<a name="l00581"></a>00581 fprintf (stderr, <span class="stringliteral">"wrote 0x%02x to uart\n"</span>, val);
<a name="l00582"></a>00582 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,371 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>uart.c File Reference</h1>Module to simulate the AVR's uart module. <a href="#_details">More...</a>
<p>
<p>
<a href="uart_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="uart_8c.html#d7ab0fb5b4d3fbec10a1777c2627c2f0">uart_int_create</a> (int addr, char *name, int rel_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="c517a78bb2ebd280a3cd227a0c6890f5"></a><!-- doxytag: member="uart.c::uart_intr_new" ref="c517a78bb2ebd280a3cd227a0c6890f5" args="(int addr, char *name, void *data)" -->
UARTIntr_T *&nbsp;</td><td class="memItemRight" valign="bottom"><b>uart_intr_new</b> (int addr, char *name, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="uart_8c.html#673d5a70c22d5a19f244fe2a17fd6c1d">uart_intr_construct</a> (UARTIntr_T *uart, int addr, char *name)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="uart_8c.html#cc2bbf6f2d72e20d553521a554ab551a">uart_intr_destroy</a> (void *uart)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="uart_8c.html#15018100db23349def4e37027d5a8932">uart_create</a> (int addr, char *name, int rel_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="e226b240d65fe82cd84ebefeaa22066b"></a><!-- doxytag: member="uart.c::uart_new" ref="e226b240d65fe82cd84ebefeaa22066b" args="(int addr, char *name, int rel_addr)" -->
UART_T *&nbsp;</td><td class="memItemRight" valign="bottom"><b>uart_new</b> (int addr, char *name, int rel_addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="uart_8c.html#bb93863003e66ea6b40400a4631656aa">uart_construct</a> (UART_T *uart, int addr, char *name, int rel_addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="uart_8c.html#c80ec8e26d6b5ece2d7e4c57f371ac01">uart_destroy</a> (void *uart)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="4d45c995a8ed8cbd92d2300c81a3bf76"></a><!-- doxytag: member="uart.c::uart_port_rd" ref="4d45c995a8ed8cbd92d2300c81a3bf76" args="(int addr)" -->
uint16_t&nbsp;</td><td class="memItemRight" valign="bottom"><b>uart_port_rd</b> (int addr)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a5c722c153d0b7d91eb4e29849874103"></a><!-- doxytag: member="uart.c::uart_port_wr" ref="a5c722c153d0b7d91eb4e29849874103" args="(uint8_t val)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><b>uart_port_wr</b> (uint8_t val)</td></tr>
<tr><td colspan="2"><br><h2>Variables</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned int&nbsp;</td><td class="memItemRight" valign="bottom"><b>UART_Int_Table</b> []</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned int&nbsp;</td><td class="memItemRight" valign="bottom"><b>UART0_Int_Table</b> []</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned int&nbsp;</td><td class="memItemRight" valign="bottom"><b>UART1_Int_Table</b> []</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Module to simulate the AVR's uart module.
<p>
<p>Definition in file <a class="el" href="uart_8c-source.html">uart.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="d7ab0fb5b4d3fbec10a1777c2627c2f0"></a><!-- doxytag: member="uart.c::uart_int_create" ref="d7ab0fb5b4d3fbec10a1777c2627c2f0" args="(int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* uart_int_create </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new uart interrupt.
<p>
<p>Definition at line <a class="el" href="uart_8c-source.html#l00095">95</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
</div>
</div><p>
<a class="anchor" name="673d5a70c22d5a19f244fe2a17fd6c1d"></a><!-- doxytag: member="uart.c::uart_intr_construct" ref="673d5a70c22d5a19f244fe2a17fd6c1d" args="(UARTIntr_T *uart, int addr, char *name)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void uart_intr_construct </td>
<td>(</td>
<td class="paramtype">UARTIntr_T *&nbsp;</td>
<td class="paramname"> <em>uart</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for uart interrupt object.
<p>
<p>Definition at line <a class="el" href="uart_8c-source.html#l00128">128</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="cc2bbf6f2d72e20d553521a554ab551a"></a><!-- doxytag: member="uart.c::uart_intr_destroy" ref="cc2bbf6f2d72e20d553521a554ab551a" args="(void *uart)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void uart_intr_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>uart</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for uart interrupt object.
<p>
<p>Definition at line <a class="el" href="uart_8c-source.html#l00179">179</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.</p>
<p>References <a class="el" href="device_8c-source.html#l00105">vdev_destroy()</a>.</p>
</div>
</div><p>
<a class="anchor" name="15018100db23349def4e37027d5a8932"></a><!-- doxytag: member="uart.c::uart_create" ref="15018100db23349def4e37027d5a8932" args="(int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* uart_create </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new uart structure.
<p>
<p>Definition at line <a class="el" href="uart_8c-source.html#l00335">335</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="bb93863003e66ea6b40400a4631656aa"></a><!-- doxytag: member="uart.c::uart_construct" ref="bb93863003e66ea6b40400a4631656aa" args="(UART_T *uart, int addr, char *name, int rel_addr)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void uart_construct </td>
<td>(</td>
<td class="paramtype">UART_T *&nbsp;</td>
<td class="paramname"> <em>uart</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for uart object.
<p>
<p>Definition at line <a class="el" href="uart_8c-source.html#l00356">356</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="c80ec8e26d6b5ece2d7e4c57f371ac01"></a><!-- doxytag: member="uart.c::uart_destroy" ref="c80ec8e26d6b5ece2d7e4c57f371ac01" args="(void *uart)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void uart_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>uart</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for uart object.
<p>
<p>Definition at line <a class="el" href="uart_8c-source.html#l00389">389</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.</p>
<p>References <a class="el" href="device_8c-source.html#l00105">vdev_destroy()</a>.</p>
</div>
</div><p>
<hr><h2>Variable Documentation</h2>
<a class="anchor" name="764bc24746f5fd7b0f1adeb5c77d3850"></a><!-- doxytag: member="uart.c::UART_Int_Table" ref="764bc24746f5fd7b0f1adeb5c77d3850" args="[]" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">unsigned int UART_Int_Table[] </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
<b>Initial value:</b><div class="fragment"><pre class="fragment"> {
irq_vect_table_index (UART_RX),
irq_vect_table_index (UART_UDRE),
irq_vect_table_index (UART_TX)
}
</pre></div>
<p>Definition at line <a class="el" href="uart_8c-source.html#l00074">74</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="71b433164de17cd526dc2341fa7dc285"></a><!-- doxytag: member="uart.c::UART0_Int_Table" ref="71b433164de17cd526dc2341fa7dc285" args="[]" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">unsigned int UART0_Int_Table[] </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
<b>Initial value:</b><div class="fragment"><pre class="fragment"> {
irq_vect_table_index (USART0_RX),
irq_vect_table_index (USART0_UDRE),
irq_vect_table_index (USART0_TX)
}
</pre></div>
<p>Definition at line <a class="el" href="uart_8c-source.html#l00080">80</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="2faad9e60db8971d89787cee785f4b0e"></a><!-- doxytag: member="uart.c::UART1_Int_Table" ref="2faad9e60db8971d89787cee785f4b0e" args="[]" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">unsigned int UART1_Int_Table[] </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
<b>Initial value:</b><div class="fragment"><pre class="fragment"> {
irq_vect_table_index (USART1_RX),
irq_vect_table_index (USART1_UDRE),
irq_vect_table_index (USART1_TX)
}
</pre></div>
<p>Definition at line <a class="el" href="uart_8c-source.html#l00086">86</a> of file <a class="el" href="uart_8c-source.html">uart.c</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,968 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>usb.c</h1><a href="usb_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: usb.c,v 1.3 2004/03/13 19:55:34 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2003, 2004 Keith Gudger</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/**</span>
<a name="l00027"></a>00027 <span class="comment"> * \file usb.c</span>
<a name="l00028"></a>00028 <span class="comment"> * \brief Module to simulate the AVR's USB module.</span>
<a name="l00029"></a>00029 <span class="comment"> */</span>
<a name="l00030"></a>00030
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00032"></a>00032
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00036"></a>00036
<a name="l00037"></a>00037 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include "utils.h"</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include "callback.h"</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include "op_names.h"</span>
<a name="l00043"></a>00043
<a name="l00044"></a>00044 <span class="preprocessor">#include "storage.h"</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include "flash.h"</span>
<a name="l00046"></a>00046
<a name="l00047"></a>00047 <span class="preprocessor">#include "vdevs.h"</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include "memory.h"</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include "stack.h"</span>
<a name="l00050"></a>00050 <span class="preprocessor">#include "register.h"</span>
<a name="l00051"></a>00051 <span class="preprocessor">#include "sram.h"</span>
<a name="l00052"></a>00052 <span class="preprocessor">#include "usb.h"</span>
<a name="l00053"></a>00053
<a name="l00054"></a>00054 <span class="preprocessor">#include "intvects.h"</span>
<a name="l00055"></a>00055
<a name="l00056"></a>00056 <span class="keywordtype">void</span> usb_port_wr (<span class="keywordtype">char</span> *name, uint8_t val);
<a name="l00057"></a>00057 uint8_t usb_port_rd (<span class="keywordtype">char</span> *name);
<a name="l00058"></a>00058
<a name="l00059"></a>00059 <span class="comment">/*****************************************************************************\</span>
<a name="l00060"></a>00060 <span class="comment"> *</span>
<a name="l00061"></a>00061 <span class="comment"> * USB Interrupts </span>
<a name="l00062"></a>00062 <span class="comment"> *</span>
<a name="l00063"></a>00063 <span class="comment">\*****************************************************************************/</span>
<a name="l00064"></a>00064
<a name="l00065"></a>00065 <span class="keyword">static</span> <span class="keywordtype">void</span> usbi_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr,
<a name="l00066"></a>00066 <span class="keywordtype">void</span> *data);
<a name="l00067"></a>00067 <span class="keyword">static</span> uint8_t usb_intr_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00068"></a>00068 <span class="keyword">static</span> <span class="keywordtype">void</span> usb_intr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00069"></a>00069 <span class="keyword">static</span> <span class="keywordtype">void</span> usb_intr_reset (VDevice *dev);
<a name="l00070"></a>00070 <span class="keyword">static</span> <span class="keywordtype">char</span> *usb_intr_reg_name (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00071"></a>00071 <span class="comment"></span>
<a name="l00072"></a>00072 <span class="comment">/** \brief Allocate a new USB interrupt */</span>
<a name="l00073"></a>00073
<a name="l00074"></a>00074 <span class="comment">/* return (VDevice *)usb_intr_new (addr, name, (uint8_t) *data_ptr);</span>
<a name="l00075"></a>00075 <span class="comment"> }*/</span>
<a name="l00076"></a>00076
<a name="l00077"></a>00077 VDevice *
<a name="l00078"></a><a class="code" href="usb_8c.html#254a13da6e1f9dcda78a1a01c3324cd8">00078</a> <a class="code" href="usb_8c.html#254a13da6e1f9dcda78a1a01c3324cd8" title="Allocate a new USB interrupt.">usbi_create</a> (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00079"></a>00079 {
<a name="l00080"></a>00080 uint8_t *data_ptr = (uint8_t *) data;
<a name="l00081"></a>00081 <span class="keywordflow">if</span> (data)
<a name="l00082"></a>00082 <span class="keywordflow">return</span> (VDevice *)usb_intr_new (addr, name, (uint8_t) * data_ptr);
<a name="l00083"></a>00083 <span class="keywordflow">else</span>
<a name="l00084"></a>00084 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Attempted USB interrupt create with NULL data pointer"</span>);
<a name="l00085"></a>00085 <span class="keywordflow">return</span> 0;
<a name="l00086"></a>00086 }
<a name="l00087"></a>00087
<a name="l00088"></a>00088 USBInter_T *
<a name="l00089"></a>00089 usb_intr_new (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, uint8_t func_mask)
<a name="l00090"></a>00090 {
<a name="l00091"></a>00091 USBInter_T *usb;
<a name="l00092"></a>00092
<a name="l00093"></a>00093 usb = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (USBInter_T, 1);
<a name="l00094"></a>00094 <a class="code" href="usb_8c.html#bc59e75f4f846b5075470bb8b7d00cf0" title="Constructor for usb interrupt object.">usb_intr_construct</a> (usb, addr, name, func_mask);
<a name="l00095"></a>00095 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)usb, <a class="code" href="usb_8c.html#c02f3bf581c2e053d30b3c0e004713f5" title="Destructor for usb interrupt object.">usb_intr_destroy</a>);
<a name="l00096"></a>00096
<a name="l00097"></a>00097 <span class="keywordflow">return</span> usb;
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099 <span class="comment"></span>
<a name="l00100"></a>00100 <span class="comment">/** \brief Constructor for usb interrupt object. */</span>
<a name="l00101"></a>00101
<a name="l00102"></a>00102 <span class="keywordtype">void</span>
<a name="l00103"></a><a class="code" href="usb_8c.html#bc59e75f4f846b5075470bb8b7d00cf0">00103</a> <a class="code" href="usb_8c.html#bc59e75f4f846b5075470bb8b7d00cf0" title="Constructor for usb interrupt object.">usb_intr_construct</a> (USBInter_T *usb, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, uint8_t func_mask)
<a name="l00104"></a>00104 {
<a name="l00105"></a>00105 <span class="keywordflow">if</span> (usb == NULL)
<a name="l00106"></a>00106 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00107"></a>00107
<a name="l00108"></a>00108 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)usb, usb_intr_read, usb_intr_write,
<a name="l00109"></a>00109 usb_intr_reset, usbi_add_addr);
<a name="l00110"></a>00110
<a name="l00111"></a>00111 usb-&gt;func_mask = func_mask;
<a name="l00112"></a>00112 usbi_add_addr ((VDevice *)usb, addr, name, 0, NULL);
<a name="l00113"></a>00113 usb_intr_reset ((VDevice *)usb);
<a name="l00114"></a>00114 }
<a name="l00115"></a>00115
<a name="l00116"></a>00116 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00117"></a>00117 usbi_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00118"></a>00118 {
<a name="l00119"></a>00119 USBInter_T *usb = (USBInter_T *)vdev;
<a name="l00120"></a>00120
<a name="l00121"></a>00121 <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"UIER"</span>, name, 4) == 0)
<a name="l00122"></a>00122 {
<a name="l00123"></a>00123 usb-&gt;uier_addr = addr;
<a name="l00124"></a>00124 }
<a name="l00125"></a>00125
<a name="l00126"></a>00126 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"UIAR"</span>, name, 4) == 0)
<a name="l00127"></a>00127 {
<a name="l00128"></a>00128 usb-&gt;uiar_addr = addr;
<a name="l00129"></a>00129 }
<a name="l00130"></a>00130
<a name="l00131"></a>00131 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"UIMSK"</span>, name, 5) == 0)
<a name="l00132"></a>00132 {
<a name="l00133"></a>00133 usb-&gt;uimsk_addr = addr;
<a name="l00134"></a>00134 }
<a name="l00135"></a>00135
<a name="l00136"></a>00136 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"UISR"</span>, name, 4) == 0)
<a name="l00137"></a>00137 {
<a name="l00138"></a>00138 usb-&gt;uisr_addr = addr;
<a name="l00139"></a>00139 }
<a name="l00140"></a>00140
<a name="l00141"></a>00141 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"SPRSMSK"</span>, name, 7) == 0)
<a name="l00142"></a>00142 {
<a name="l00143"></a>00143 usb-&gt;sprsmsk_addr = addr;
<a name="l00144"></a>00144 }
<a name="l00145"></a>00145
<a name="l00146"></a>00146 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"SPRSIE"</span>, name, 6) == 0)
<a name="l00147"></a>00147 {
<a name="l00148"></a>00148 usb-&gt;sprsie_addr = addr;
<a name="l00149"></a>00149 }
<a name="l00150"></a>00150
<a name="l00151"></a>00151 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"SPRSR"</span>, name, 5) == 0)
<a name="l00152"></a>00152 {
<a name="l00153"></a>00153 usb-&gt;sprsr_addr = addr;
<a name="l00154"></a>00154 }
<a name="l00155"></a>00155
<a name="l00156"></a>00156 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"GLB_STATE"</span>, name, 9) == 0)
<a name="l00157"></a>00157 {
<a name="l00158"></a>00158 usb-&gt;glb_state_addr = addr;
<a name="l00159"></a>00159 }
<a name="l00160"></a>00160
<a name="l00161"></a>00161 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"FRM_NUM_L"</span>, name, 9) == 0)
<a name="l00162"></a>00162 {
<a name="l00163"></a>00163 usb-&gt;frm_num_l_addr = addr;
<a name="l00164"></a>00164 }
<a name="l00165"></a>00165
<a name="l00166"></a>00166 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"FRM_NUM_H"</span>, name, 9) == 0)
<a name="l00167"></a>00167 {
<a name="l00168"></a>00168 usb-&gt;frm_num_h_addr = addr;
<a name="l00169"></a>00169 }
<a name="l00170"></a>00170
<a name="l00171"></a>00171 <span class="keywordflow">else</span>
<a name="l00172"></a>00172 {
<a name="l00173"></a>00173 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"invalid USB Int register name: '%s' @ 0x%04x"</span>, name,
<a name="l00174"></a>00174 addr);
<a name="l00175"></a>00175 }
<a name="l00176"></a>00176 }
<a name="l00177"></a>00177 <span class="comment"></span>
<a name="l00178"></a>00178 <span class="comment">/** \brief Destructor for usb interrupt object. */</span>
<a name="l00179"></a>00179
<a name="l00180"></a>00180 <span class="keywordtype">void</span>
<a name="l00181"></a><a class="code" href="usb_8c.html#c02f3bf581c2e053d30b3c0e004713f5">00181</a> <a class="code" href="usb_8c.html#c02f3bf581c2e053d30b3c0e004713f5" title="Destructor for usb interrupt object.">usb_intr_destroy</a> (<span class="keywordtype">void</span> *usb)
<a name="l00182"></a>00182 {
<a name="l00183"></a>00183 <span class="keywordflow">if</span> (usb == NULL)
<a name="l00184"></a>00184 <span class="keywordflow">return</span>;
<a name="l00185"></a>00185
<a name="l00186"></a>00186 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (usb);
<a name="l00187"></a>00187 }
<a name="l00188"></a>00188
<a name="l00189"></a>00189 <span class="keyword">static</span> uint8_t
<a name="l00190"></a>00190 usb_intr_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00191"></a>00191 {
<a name="l00192"></a>00192 USBInter_T *usb = (USBInter_T *)dev;
<a name="l00193"></a>00193
<a name="l00194"></a>00194 <span class="keywordflow">if</span> (addr == usb-&gt;uier_addr)
<a name="l00195"></a>00195 <span class="keywordflow">return</span> (usb-&gt;uier);
<a name="l00196"></a>00196 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;uimsk_addr)
<a name="l00197"></a>00197 <span class="keywordflow">return</span> (usb-&gt;uimsk);
<a name="l00198"></a>00198 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;uisr_addr)
<a name="l00199"></a>00199 <span class="keywordflow">return</span> (usb-&gt;uisr =
<a name="l00200"></a>00200 usb_port_rd (usb_intr_reg_name ((VDevice *)usb, addr)));
<a name="l00201"></a>00201 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;sprsie_addr)
<a name="l00202"></a>00202 <span class="keywordflow">return</span> (usb-&gt;sprsie);
<a name="l00203"></a>00203 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;sprsr_addr)
<a name="l00204"></a>00204 <span class="keywordflow">return</span> (usb-&gt;sprsr =
<a name="l00205"></a>00205 usb_port_rd (usb_intr_reg_name ((VDevice *)usb, addr)));
<a name="l00206"></a>00206 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;glb_state_addr)
<a name="l00207"></a>00207 <span class="keywordflow">return</span> (usb-&gt;glb_state);
<a name="l00208"></a>00208 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;frm_num_l_addr)
<a name="l00209"></a>00209 <span class="keywordflow">return</span> (usb-&gt;frm_num_l);
<a name="l00210"></a>00210 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;frm_num_h_addr)
<a name="l00211"></a>00211 <span class="keywordflow">return</span> (usb-&gt;frm_num_h);
<a name="l00212"></a>00212 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;sprsmsk_addr)
<a name="l00213"></a>00213 <span class="keywordflow">return</span> (usb-&gt;sprsmsk);
<a name="l00214"></a>00214 <span class="keywordflow">else</span>
<a name="l00215"></a>00215 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00216"></a>00216
<a name="l00217"></a>00217 <span class="keywordflow">return</span> 0; <span class="comment">/* will never get here */</span>
<a name="l00218"></a>00218 }
<a name="l00219"></a>00219
<a name="l00220"></a>00220 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00221"></a>00221 usb_intr_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00222"></a>00222 {
<a name="l00223"></a>00223 USBInter_T *usb = (USBInter_T *)dev;
<a name="l00224"></a>00224
<a name="l00225"></a>00225 <span class="keywordflow">if</span> (addr == usb-&gt;uier_addr)
<a name="l00226"></a>00226 (usb-&gt;uier = val);
<a name="l00227"></a>00227 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;uimsk_addr)
<a name="l00228"></a>00228 (usb-&gt;uimsk = val);
<a name="l00229"></a>00229 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;sprsmsk_addr)
<a name="l00230"></a>00230 (usb-&gt;sprsmsk = val);
<a name="l00231"></a>00231 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;sprsie_addr)
<a name="l00232"></a>00232 (usb-&gt;sprsie = val);
<a name="l00233"></a>00233 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;uiar_addr)
<a name="l00234"></a>00234 (usb-&gt;uiar = val);
<a name="l00235"></a>00235 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;glb_state_addr)
<a name="l00236"></a>00236 (usb-&gt;glb_state = val);
<a name="l00237"></a>00237 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;frm_num_l_addr)
<a name="l00238"></a>00238 (usb-&gt;frm_num_l = val);
<a name="l00239"></a>00239 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;frm_num_h_addr)
<a name="l00240"></a>00240 (usb-&gt;frm_num_h = val);
<a name="l00241"></a>00241 <span class="keywordflow">else</span>
<a name="l00242"></a>00242 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00243"></a>00243 }
<a name="l00244"></a>00244
<a name="l00245"></a>00245 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00246"></a>00246 usb_intr_reset (VDevice *dev)
<a name="l00247"></a>00247 {
<a name="l00248"></a>00248 USBInter_T *usb = (USBInter_T *)dev;
<a name="l00249"></a>00249
<a name="l00250"></a>00250 usb-&gt;sprsr = 0;
<a name="l00251"></a>00251 usb-&gt;uisr = 0;
<a name="l00252"></a>00252 }
<a name="l00253"></a>00253
<a name="l00254"></a>00254 <span class="keyword">static</span> <span class="keywordtype">char</span> *
<a name="l00255"></a>00255 usb_intr_reg_name (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00256"></a>00256 {
<a name="l00257"></a>00257 USBInter_T *usb = (USBInter_T *)dev;
<a name="l00258"></a>00258
<a name="l00259"></a>00259 <span class="keywordflow">if</span> (addr == usb-&gt;uier_addr)
<a name="l00260"></a>00260 <span class="keywordflow">return</span> (<span class="stringliteral">"UIER"</span>);
<a name="l00261"></a>00261 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;uimsk_addr)
<a name="l00262"></a>00262 <span class="keywordflow">return</span> (<span class="stringliteral">"UIMSK"</span>);
<a name="l00263"></a>00263 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;uisr_addr)
<a name="l00264"></a>00264 <span class="keywordflow">return</span> (<span class="stringliteral">"UISR"</span>);
<a name="l00265"></a>00265 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;sprsie_addr)
<a name="l00266"></a>00266 <span class="keywordflow">return</span> (<span class="stringliteral">"SPRSIE"</span>);
<a name="l00267"></a>00267 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;sprsr_addr)
<a name="l00268"></a>00268 <span class="keywordflow">return</span> (<span class="stringliteral">"SPRSR"</span>);
<a name="l00269"></a>00269 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;glb_state_addr)
<a name="l00270"></a>00270 <span class="keywordflow">return</span> (<span class="stringliteral">"GLB_STATE"</span>);
<a name="l00271"></a>00271 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;frm_num_l_addr)
<a name="l00272"></a>00272 <span class="keywordflow">return</span> (<span class="stringliteral">"FRM_NUM_L"</span>);
<a name="l00273"></a>00273 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;frm_num_h_addr)
<a name="l00274"></a>00274 <span class="keywordflow">return</span> (<span class="stringliteral">"FRM_NUM_H"</span>);
<a name="l00275"></a>00275 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;sprsmsk_addr)
<a name="l00276"></a>00276 <span class="keywordflow">return</span> (<span class="stringliteral">"SPRSMSK"</span>);
<a name="l00277"></a>00277 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;uiar_addr)
<a name="l00278"></a>00278 <span class="keywordflow">return</span> (<span class="stringliteral">"UIAR"</span>);
<a name="l00279"></a>00279 <span class="keywordflow">else</span>
<a name="l00280"></a>00280 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00281"></a>00281
<a name="l00282"></a>00282 <span class="keywordflow">return</span> NULL; <span class="comment">/* will never get here */</span>
<a name="l00283"></a>00283 }
<a name="l00284"></a>00284
<a name="l00285"></a>00285 <span class="comment">/*****************************************************************************\</span>
<a name="l00286"></a>00286 <span class="comment"> *</span>
<a name="l00287"></a>00287 <span class="comment"> * USB </span>
<a name="l00288"></a>00288 <span class="comment"> *</span>
<a name="l00289"></a>00289 <span class="comment">\*****************************************************************************/</span>
<a name="l00290"></a>00290
<a name="l00291"></a>00291 <span class="keyword">static</span> <span class="keywordtype">void</span> usb_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr,
<a name="l00292"></a>00292 <span class="keywordtype">void</span> *data);
<a name="l00293"></a>00293 <span class="keyword">static</span> uint8_t usb_read (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00294"></a>00294 <span class="keyword">static</span> <span class="keywordtype">void</span> usb_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val);
<a name="l00295"></a>00295 <span class="keyword">static</span> <span class="keywordtype">void</span> usb_reset (VDevice *dev);
<a name="l00296"></a>00296 <span class="keyword">static</span> <span class="keywordtype">char</span> *usb_reg_name (VDevice *dev, <span class="keywordtype">int</span> addr);
<a name="l00297"></a>00297 <span class="comment"></span>
<a name="l00298"></a>00298 <span class="comment">/** \brief Allocate a new USB structure. */</span>
<a name="l00299"></a>00299
<a name="l00300"></a>00300 VDevice *
<a name="l00301"></a><a class="code" href="usb_8c.html#7b5bc9c47afcbe8cf57d75dd4ed47968">00301</a> <a class="code" href="usb_8c.html#7b5bc9c47afcbe8cf57d75dd4ed47968" title="Allocate a new USB structure.">usb_create</a> (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00302"></a>00302 {
<a name="l00303"></a>00303 <span class="keywordflow">return</span> (VDevice *)usb_new (addr, name);
<a name="l00304"></a>00304 }
<a name="l00305"></a>00305
<a name="l00306"></a>00306 USB_T *
<a name="l00307"></a>00307 usb_new (<span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name)
<a name="l00308"></a>00308 {
<a name="l00309"></a>00309 USB_T *usb;
<a name="l00310"></a>00310
<a name="l00311"></a>00311 usb = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (USB_T, 1);
<a name="l00312"></a>00312 <a class="code" href="usb_8c.html#b46dace89d6472ed1f0dc235d2b9e5c5" title="Constructor for new USB object.">usb_construct</a> (usb, addr, name);
<a name="l00313"></a>00313 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)usb, <a class="code" href="usb_8c.html#238a235b4fe1c88d56b67e65dc57274d" title="Destructor for USB object.">usb_destroy</a>);
<a name="l00314"></a>00314
<a name="l00315"></a>00315 <span class="keywordflow">return</span> usb;
<a name="l00316"></a>00316 }
<a name="l00317"></a>00317 <span class="comment"></span>
<a name="l00318"></a>00318 <span class="comment">/** \brief Constructor for new USB object. */</span>
<a name="l00319"></a>00319
<a name="l00320"></a>00320 <span class="keywordtype">void</span>
<a name="l00321"></a><a class="code" href="usb_8c.html#b46dace89d6472ed1f0dc235d2b9e5c5">00321</a> <a class="code" href="usb_8c.html#b46dace89d6472ed1f0dc235d2b9e5c5" title="Constructor for new USB object.">usb_construct</a> (USB_T *usb, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name)
<a name="l00322"></a>00322 {
<a name="l00323"></a>00323 <span class="keywordflow">if</span> (usb == NULL)
<a name="l00324"></a>00324 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00325"></a>00325
<a name="l00326"></a>00326 <a class="code" href="device_8c.html#c3488ff879caeddb12999256aaf7bfc4" title="Constructor for a VDevice.">vdev_construct</a> ((VDevice *)usb, usb_read, usb_write, usb_reset,
<a name="l00327"></a>00327 usb_add_addr);
<a name="l00328"></a>00328
<a name="l00329"></a>00329 usb_add_addr ((VDevice *)usb, addr, name, 0, NULL);
<a name="l00330"></a>00330 usb_reset ((VDevice *)usb);
<a name="l00331"></a>00331 }
<a name="l00332"></a>00332
<a name="l00333"></a>00333 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00334"></a>00334 usb_add_addr (VDevice *vdev, <span class="keywordtype">int</span> addr, <span class="keywordtype">char</span> *name, <span class="keywordtype">int</span> rel_addr, <span class="keywordtype">void</span> *data)
<a name="l00335"></a>00335 {
<a name="l00336"></a>00336 USB_T *usb = (USB_T *)vdev;
<a name="l00337"></a>00337
<a name="l00338"></a>00338 <span class="keywordflow">if</span> (strncmp (<span class="stringliteral">"FCAR5"</span>, name, 5) == 0)
<a name="l00339"></a>00339 usb-&gt;fcar5_addr = addr;
<a name="l00340"></a>00340 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FCAR4"</span>, name, 5) == 0)
<a name="l00341"></a>00341 usb-&gt;fcar4_addr = addr;
<a name="l00342"></a>00342 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FCAR3"</span>, name, 5) == 0)
<a name="l00343"></a>00343 usb-&gt;fcar3_addr = addr;
<a name="l00344"></a>00344 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FCAR2"</span>, name, 5) == 0)
<a name="l00345"></a>00345 usb-&gt;fcar2_addr = addr;
<a name="l00346"></a>00346 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FCAR1"</span>, name, 5) == 0)
<a name="l00347"></a>00347 usb-&gt;fcar1_addr = addr;
<a name="l00348"></a>00348 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FCAR0"</span>, name, 5) == 0)
<a name="l00349"></a>00349 usb-&gt;fcar0_addr = addr;
<a name="l00350"></a>00350 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HCAR0"</span>, name, 5) == 0)
<a name="l00351"></a>00351 usb-&gt;hcar0_addr = addr;
<a name="l00352"></a>00352 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"PSTATE1"</span>, name, 7) == 0)
<a name="l00353"></a>00353 usb-&gt;pstate1_addr = addr;
<a name="l00354"></a>00354 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"PSTATE2"</span>, name, 7) == 0)
<a name="l00355"></a>00355 usb-&gt;pstate2_addr = addr;
<a name="l00356"></a>00356 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"PSTATE3"</span>, name, 7) == 0)
<a name="l00357"></a>00357 usb-&gt;pstate3_addr = addr;
<a name="l00358"></a>00358 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"PSTATE4"</span>, name, 7) == 0)
<a name="l00359"></a>00359 usb-&gt;pstate4_addr = addr;
<a name="l00360"></a>00360 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"PSTATE5"</span>, name, 7) == 0)
<a name="l00361"></a>00361 usb-&gt;pstate5_addr = addr;
<a name="l00362"></a>00362 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"PSTATE6"</span>, name, 7) == 0)
<a name="l00363"></a>00363 usb-&gt;pstate6_addr = addr;
<a name="l00364"></a>00364 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"PSTATE7"</span>, name, 7) == 0)
<a name="l00365"></a>00365 usb-&gt;pstate7_addr = addr;
<a name="l00366"></a>00366 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"PSTATE8"</span>, name, 7) == 0)
<a name="l00367"></a>00367 usb-&gt;pstate8_addr = addr;
<a name="l00368"></a>00368 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSCR1"</span>, name, 6) == 0)
<a name="l00369"></a>00369 usb-&gt;hpscr1_addr = addr;
<a name="l00370"></a>00370 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSCR2"</span>, name, 6) == 0)
<a name="l00371"></a>00371 usb-&gt;hpscr2_addr = addr;
<a name="l00372"></a>00372 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSCR3"</span>, name, 6) == 0)
<a name="l00373"></a>00373 usb-&gt;hpscr3_addr = addr;
<a name="l00374"></a>00374 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSCR4"</span>, name, 6) == 0)
<a name="l00375"></a>00375 usb-&gt;hpscr4_addr = addr;
<a name="l00376"></a>00376 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSCR5"</span>, name, 6) == 0)
<a name="l00377"></a>00377 usb-&gt;hpscr5_addr = addr;
<a name="l00378"></a>00378 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSCR6"</span>, name, 6) == 0)
<a name="l00379"></a>00379 usb-&gt;hpscr6_addr = addr;
<a name="l00380"></a>00380 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSCR7"</span>, name, 6) == 0)
<a name="l00381"></a>00381 usb-&gt;hpscr7_addr = addr;
<a name="l00382"></a>00382 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSCR8"</span>, name, 6) == 0)
<a name="l00383"></a>00383 usb-&gt;hpscr8_addr = addr;
<a name="l00384"></a>00384 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSTAT1"</span>, name, 7) == 0)
<a name="l00385"></a>00385 usb-&gt;hpstat1_addr = addr;
<a name="l00386"></a>00386 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSTAT2"</span>, name, 7) == 0)
<a name="l00387"></a>00387 usb-&gt;hpstat2_addr = addr;
<a name="l00388"></a>00388 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSTAT3"</span>, name, 7) == 0)
<a name="l00389"></a>00389 usb-&gt;hpstat3_addr = addr;
<a name="l00390"></a>00390 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSTAT4"</span>, name, 7) == 0)
<a name="l00391"></a>00391 usb-&gt;hpstat4_addr = addr;
<a name="l00392"></a>00392 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSTAT5"</span>, name, 7) == 0)
<a name="l00393"></a>00393 usb-&gt;hpstat5_addr = addr;
<a name="l00394"></a>00394 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSTAT6"</span>, name, 7) == 0)
<a name="l00395"></a>00395 usb-&gt;hpstat6_addr = addr;
<a name="l00396"></a>00396 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSTAT7"</span>, name, 7) == 0)
<a name="l00397"></a>00397 usb-&gt;hpstat7_addr = addr;
<a name="l00398"></a>00398 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPSTAT8"</span>, name, 7) == 0)
<a name="l00399"></a>00399 usb-&gt;hpstat8_addr = addr;
<a name="l00400"></a>00400 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HPCON"</span>, name, 5) == 0)
<a name="l00401"></a>00401 usb-&gt;hpcon_addr = addr;
<a name="l00402"></a>00402 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HSTR"</span>, name, 4) == 0)
<a name="l00403"></a>00403 usb-&gt;hstr_addr = addr;
<a name="l00404"></a>00404 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FBYTE_CNT5"</span>, name, 10) == 0)
<a name="l00405"></a>00405 usb-&gt;fbyte_cnt5_addr = addr;
<a name="l00406"></a>00406 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FBYTE_CNT4"</span>, name, 10) == 0)
<a name="l00407"></a>00407 usb-&gt;fbyte_cnt4_addr = addr;
<a name="l00408"></a>00408 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FBYTE_CNT3"</span>, name, 10) == 0)
<a name="l00409"></a>00409 usb-&gt;fbyte_cnt3_addr = addr;
<a name="l00410"></a>00410 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FBYTE_CNT2"</span>, name, 10) == 0)
<a name="l00411"></a>00411 usb-&gt;fbyte_cnt2_addr = addr;
<a name="l00412"></a>00412 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FBYTE_CNT1"</span>, name, 10) == 0)
<a name="l00413"></a>00413 usb-&gt;fbyte_cnt1_addr = addr;
<a name="l00414"></a>00414 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FBYTE_CNT0"</span>, name, 10) == 0)
<a name="l00415"></a>00415 usb-&gt;fbyte_cnt0_addr = addr;
<a name="l00416"></a>00416 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HBYTE_CNT0"</span>, name, 10) == 0)
<a name="l00417"></a>00417 usb-&gt;hbyte_cnt0_addr = addr;
<a name="l00418"></a>00418 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FDR5"</span>, name, 4) == 0)
<a name="l00419"></a>00419 usb-&gt;fdr5_addr = addr;
<a name="l00420"></a>00420 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FDR4"</span>, name, 4) == 0)
<a name="l00421"></a>00421 usb-&gt;fdr4_addr = addr;
<a name="l00422"></a>00422 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FDR3"</span>, name, 4) == 0)
<a name="l00423"></a>00423 usb-&gt;fdr3_addr = addr;
<a name="l00424"></a>00424 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FDR2"</span>, name, 4) == 0)
<a name="l00425"></a>00425 usb-&gt;fdr2_addr = addr;
<a name="l00426"></a>00426 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FDR1"</span>, name, 4) == 0)
<a name="l00427"></a>00427 usb-&gt;fdr1_addr = addr;
<a name="l00428"></a>00428 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FDR0"</span>, name, 4) == 0)
<a name="l00429"></a>00429 usb-&gt;fdr0_addr = addr;
<a name="l00430"></a>00430 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HDR0"</span>, name, 4) == 0)
<a name="l00431"></a>00431 usb-&gt;hdr0_addr = addr;
<a name="l00432"></a>00432 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FCSR5"</span>, name, 5) == 0)
<a name="l00433"></a>00433 usb-&gt;fcsr5_addr = addr;
<a name="l00434"></a>00434 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FCSR4"</span>, name, 5) == 0)
<a name="l00435"></a>00435 usb-&gt;fcsr4_addr = addr;
<a name="l00436"></a>00436 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FCSR3"</span>, name, 5) == 0)
<a name="l00437"></a>00437 usb-&gt;fcsr3_addr = addr;
<a name="l00438"></a>00438 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FCSR2"</span>, name, 5) == 0)
<a name="l00439"></a>00439 usb-&gt;fcsr2_addr = addr;
<a name="l00440"></a>00440 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FCSR1"</span>, name, 5) == 0)
<a name="l00441"></a>00441 usb-&gt;fcsr1_addr = addr;
<a name="l00442"></a>00442 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FCSR0"</span>, name, 5) == 0)
<a name="l00443"></a>00443 usb-&gt;fcsr0_addr = addr;
<a name="l00444"></a>00444 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HCSR0"</span>, name, 5) == 0)
<a name="l00445"></a>00445 usb-&gt;hcsr0_addr = addr;
<a name="l00446"></a>00446 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FENDP5_CNTR"</span>, name, 11) == 0)
<a name="l00447"></a>00447 usb-&gt;fendp5_cntr_addr = addr;
<a name="l00448"></a>00448 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FENDP4_CNTR"</span>, name, 11) == 0)
<a name="l00449"></a>00449 usb-&gt;fendp4_cntr_addr = addr;
<a name="l00450"></a>00450 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FENDP3_CNTR"</span>, name, 11) == 0)
<a name="l00451"></a>00451 usb-&gt;fendp3_cntr_addr = addr;
<a name="l00452"></a>00452 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FENDP2_CNTR"</span>, name, 11) == 0)
<a name="l00453"></a>00453 usb-&gt;fendp2_cntr_addr = addr;
<a name="l00454"></a>00454 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FENDP1_CNTR"</span>, name, 11) == 0)
<a name="l00455"></a>00455 usb-&gt;fendp1_cntr_addr = addr;
<a name="l00456"></a>00456 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FENDP0_CNTR"</span>, name, 11) == 0)
<a name="l00457"></a>00457 usb-&gt;fendp0_cntr_addr = addr;
<a name="l00458"></a>00458 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HENDP1_CNTR"</span>, name, 11) == 0)
<a name="l00459"></a>00459 usb-&gt;hendp1_cntr_addr = addr;
<a name="l00460"></a>00460 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HENDP0_CNTR"</span>, name, 11) == 0)
<a name="l00461"></a>00461 usb-&gt;hendp0_cntr_addr = addr;
<a name="l00462"></a>00462 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"FADDR"</span>, name, 5) == 0)
<a name="l00463"></a>00463 usb-&gt;faddr_addr = addr;
<a name="l00464"></a>00464 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"HADDR"</span>, name, 5) == 0)
<a name="l00465"></a>00465 usb-&gt;haddr_addr = addr;
<a name="l00466"></a>00466 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"ISCR"</span>, name, 4) == 0)
<a name="l00467"></a>00467 usb-&gt;iscr_addr = addr;
<a name="l00468"></a>00468 <span class="keywordflow">else</span> if (strncmp (<span class="stringliteral">"UOVCER"</span>, name, 6) == 0)
<a name="l00469"></a>00469 usb-&gt;uovcer_addr = addr;
<a name="l00470"></a>00470 <span class="keywordflow">else</span>
<a name="l00471"></a>00471 {
<a name="l00472"></a>00472 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"invalid USB Int register name: '%s' @ 0x%04x"</span>, name,
<a name="l00473"></a>00473 addr);
<a name="l00474"></a>00474 }
<a name="l00475"></a>00475 }
<a name="l00476"></a>00476 <span class="comment"></span>
<a name="l00477"></a>00477 <span class="comment">/** \brief Destructor for USB object. */</span>
<a name="l00478"></a>00478
<a name="l00479"></a>00479 <span class="keywordtype">void</span>
<a name="l00480"></a><a class="code" href="usb_8c.html#238a235b4fe1c88d56b67e65dc57274d">00480</a> <a class="code" href="usb_8c.html#238a235b4fe1c88d56b67e65dc57274d" title="Destructor for USB object.">usb_destroy</a> (<span class="keywordtype">void</span> *usb)
<a name="l00481"></a>00481 {
<a name="l00482"></a>00482 <span class="keywordflow">if</span> (usb == NULL)
<a name="l00483"></a>00483 <span class="keywordflow">return</span>;
<a name="l00484"></a>00484
<a name="l00485"></a>00485 <a class="code" href="device_8c.html#abfe90d199261cef657cd6f0b0e674a9" title="Destructor for a VDevice.">vdev_destroy</a> (usb);
<a name="l00486"></a>00486 }
<a name="l00487"></a>00487
<a name="l00488"></a>00488 <span class="keyword">static</span> uint8_t
<a name="l00489"></a>00489 usb_read (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00490"></a>00490 {
<a name="l00491"></a>00491 USB_T *usb = (USB_T *)dev;
<a name="l00492"></a>00492
<a name="l00493"></a>00493 <span class="keywordflow">if</span> (addr == usb-&gt;uovcer_addr)
<a name="l00494"></a>00494 <span class="keywordflow">return</span> usb-&gt;uovcer;
<a name="l00495"></a>00495 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;haddr_addr)
<a name="l00496"></a>00496 <span class="keywordflow">return</span> usb-&gt;haddr;
<a name="l00497"></a>00497 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;faddr_addr)
<a name="l00498"></a>00498 <span class="keywordflow">return</span> usb-&gt;faddr;
<a name="l00499"></a>00499 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hstr_addr)
<a name="l00500"></a>00500 <span class="keywordflow">return</span> usb-&gt;hstr;
<a name="l00501"></a>00501 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpcon_addr)
<a name="l00502"></a>00502 <span class="keywordflow">return</span> usb-&gt;hpcon;
<a name="l00503"></a>00503 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;iscr_addr)
<a name="l00504"></a>00504 <span class="keywordflow">return</span> usb-&gt;iscr;
<a name="l00505"></a>00505 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp5_cntr_addr)
<a name="l00506"></a>00506 <span class="keywordflow">return</span> usb-&gt;fendp5_cntr;
<a name="l00507"></a>00507 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp4_cntr_addr)
<a name="l00508"></a>00508 <span class="keywordflow">return</span> usb-&gt;fendp4_cntr;
<a name="l00509"></a>00509 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp3_cntr_addr)
<a name="l00510"></a>00510 <span class="keywordflow">return</span> usb-&gt;fendp3_cntr;
<a name="l00511"></a>00511 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp2_cntr_addr)
<a name="l00512"></a>00512 <span class="keywordflow">return</span> usb-&gt;fendp2_cntr;
<a name="l00513"></a>00513 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp1_cntr_addr)
<a name="l00514"></a>00514 <span class="keywordflow">return</span> usb-&gt;fendp1_cntr;
<a name="l00515"></a>00515 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp0_cntr_addr)
<a name="l00516"></a>00516 <span class="keywordflow">return</span> usb-&gt;fendp0_cntr;
<a name="l00517"></a>00517 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hendp1_cntr_addr)
<a name="l00518"></a>00518 <span class="keywordflow">return</span> usb-&gt;hendp1_cntr;
<a name="l00519"></a>00519 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hendp0_cntr_addr)
<a name="l00520"></a>00520 <span class="keywordflow">return</span> usb-&gt;hendp0_cntr;
<a name="l00521"></a>00521 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcsr5_addr)
<a name="l00522"></a>00522 <span class="keywordflow">return</span> usb-&gt;fcsr5 = usb_port_rd (usb_reg_name ((VDevice *)usb, addr));
<a name="l00523"></a>00523 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcsr4_addr)
<a name="l00524"></a>00524 <span class="keywordflow">return</span> usb-&gt;fcsr4 = usb_port_rd (usb_reg_name ((VDevice *)usb, addr));
<a name="l00525"></a>00525 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcsr3_addr)
<a name="l00526"></a>00526 <span class="keywordflow">return</span> usb-&gt;fcsr3 = usb_port_rd (usb_reg_name ((VDevice *)usb, addr));
<a name="l00527"></a>00527 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcsr2_addr)
<a name="l00528"></a>00528 <span class="keywordflow">return</span> usb-&gt;fcsr2 = usb_port_rd (usb_reg_name ((VDevice *)usb, addr));
<a name="l00529"></a>00529 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcsr1_addr)
<a name="l00530"></a>00530 <span class="keywordflow">return</span> usb-&gt;fcsr1 = usb_port_rd (usb_reg_name ((VDevice *)usb, addr));
<a name="l00531"></a>00531 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcsr0_addr)
<a name="l00532"></a>00532 {
<a name="l00533"></a>00533 usb-&gt;fcsr0 = usb_port_rd (usb_reg_name ((VDevice *)usb, addr));
<a name="l00534"></a>00534 <span class="keywordflow">if</span> (usb-&gt;fcsr0 &amp; RX_SETUP)
<a name="l00535"></a>00535 usb-&gt;fbyte_cnt0 = 10;
<a name="l00536"></a>00536 <span class="keywordflow">return</span> usb-&gt;fcsr0;
<a name="l00537"></a>00537 }
<a name="l00538"></a>00538 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hcsr0_addr)
<a name="l00539"></a>00539 {
<a name="l00540"></a>00540 usb-&gt;hcsr0 = usb_port_rd (usb_reg_name ((VDevice *)usb, addr));
<a name="l00541"></a>00541 <span class="keywordflow">if</span> (usb-&gt;hcsr0 &amp; RX_SETUP)
<a name="l00542"></a>00542 usb-&gt;hbyte_cnt0 = 10;
<a name="l00543"></a>00543 <span class="keywordflow">return</span> usb-&gt;hcsr0;
<a name="l00544"></a>00544 }
<a name="l00545"></a>00545 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar5_addr)
<a name="l00546"></a>00546 <span class="keywordflow">return</span> usb-&gt;fcar5;
<a name="l00547"></a>00547 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar4_addr)
<a name="l00548"></a>00548 <span class="keywordflow">return</span> usb-&gt;fcar4;
<a name="l00549"></a>00549 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar3_addr)
<a name="l00550"></a>00550 <span class="keywordflow">return</span> usb-&gt;fcar3;
<a name="l00551"></a>00551 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar2_addr)
<a name="l00552"></a>00552 <span class="keywordflow">return</span> usb-&gt;fcar2;
<a name="l00553"></a>00553 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar1_addr)
<a name="l00554"></a>00554 <span class="keywordflow">return</span> usb-&gt;fcar1;
<a name="l00555"></a>00555 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar0_addr)
<a name="l00556"></a>00556 <span class="keywordflow">return</span> usb-&gt;fcar0;
<a name="l00557"></a>00557 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hcar0_addr)
<a name="l00558"></a>00558 <span class="keywordflow">return</span> usb-&gt;hcar0;
<a name="l00559"></a>00559 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat1_addr)
<a name="l00560"></a>00560 <span class="keywordflow">return</span> usb-&gt;hpstat1;
<a name="l00561"></a>00561 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat2_addr)
<a name="l00562"></a>00562 <span class="keywordflow">return</span> usb-&gt;hpstat2;
<a name="l00563"></a>00563 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat3_addr)
<a name="l00564"></a>00564 <span class="keywordflow">return</span> usb-&gt;hpstat3;
<a name="l00565"></a>00565 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat4_addr)
<a name="l00566"></a>00566 <span class="keywordflow">return</span> usb-&gt;hpstat4;
<a name="l00567"></a>00567 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat5_addr)
<a name="l00568"></a>00568 <span class="keywordflow">return</span> usb-&gt;hpstat5;
<a name="l00569"></a>00569 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat6_addr)
<a name="l00570"></a>00570 <span class="keywordflow">return</span> usb-&gt;hpstat6;
<a name="l00571"></a>00571 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat7_addr)
<a name="l00572"></a>00572 <span class="keywordflow">return</span> usb-&gt;hpstat7;
<a name="l00573"></a>00573 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat8_addr)
<a name="l00574"></a>00574 <span class="keywordflow">return</span> usb-&gt;hpstat8;
<a name="l00575"></a>00575 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate1_addr)
<a name="l00576"></a>00576 <span class="keywordflow">return</span> usb-&gt;pstate1;
<a name="l00577"></a>00577 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate2_addr)
<a name="l00578"></a>00578 <span class="keywordflow">return</span> usb-&gt;pstate2;
<a name="l00579"></a>00579 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate3_addr)
<a name="l00580"></a>00580 <span class="keywordflow">return</span> usb-&gt;pstate3;
<a name="l00581"></a>00581 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate4_addr)
<a name="l00582"></a>00582 <span class="keywordflow">return</span> usb-&gt;pstate4;
<a name="l00583"></a>00583 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate5_addr)
<a name="l00584"></a>00584 <span class="keywordflow">return</span> usb-&gt;pstate5;
<a name="l00585"></a>00585 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate6_addr)
<a name="l00586"></a>00586 <span class="keywordflow">return</span> usb-&gt;pstate6;
<a name="l00587"></a>00587 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate7_addr)
<a name="l00588"></a>00588 <span class="keywordflow">return</span> usb-&gt;pstate7;
<a name="l00589"></a>00589 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate8_addr)
<a name="l00590"></a>00590 <span class="keywordflow">return</span> usb-&gt;pstate8;
<a name="l00591"></a>00591 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr1_addr)
<a name="l00592"></a>00592 <span class="keywordflow">return</span> usb-&gt;hpscr1;
<a name="l00593"></a>00593 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr2_addr)
<a name="l00594"></a>00594 <span class="keywordflow">return</span> usb-&gt;hpscr2;
<a name="l00595"></a>00595 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr3_addr)
<a name="l00596"></a>00596 <span class="keywordflow">return</span> usb-&gt;hpscr3;
<a name="l00597"></a>00597 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr4_addr)
<a name="l00598"></a>00598 <span class="keywordflow">return</span> usb-&gt;hpscr4;
<a name="l00599"></a>00599 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr5_addr)
<a name="l00600"></a>00600 <span class="keywordflow">return</span> usb-&gt;hpscr5;
<a name="l00601"></a>00601 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr6_addr)
<a name="l00602"></a>00602 <span class="keywordflow">return</span> usb-&gt;hpscr6;
<a name="l00603"></a>00603 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr7_addr)
<a name="l00604"></a>00604 <span class="keywordflow">return</span> usb-&gt;hpscr7;
<a name="l00605"></a>00605 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr8_addr)
<a name="l00606"></a>00606 <span class="keywordflow">return</span> usb-&gt;hpscr8;
<a name="l00607"></a>00607 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fbyte_cnt5_addr)
<a name="l00608"></a>00608 <span class="keywordflow">return</span> usb-&gt;fbyte_cnt5;
<a name="l00609"></a>00609 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fbyte_cnt4_addr)
<a name="l00610"></a>00610 <span class="keywordflow">return</span> usb-&gt;fbyte_cnt4;
<a name="l00611"></a>00611 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fbyte_cnt3_addr)
<a name="l00612"></a>00612 <span class="keywordflow">return</span> usb-&gt;fbyte_cnt3;
<a name="l00613"></a>00613 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fbyte_cnt2_addr)
<a name="l00614"></a>00614 <span class="keywordflow">return</span> usb-&gt;fbyte_cnt2;
<a name="l00615"></a>00615 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fbyte_cnt1_addr)
<a name="l00616"></a>00616 <span class="keywordflow">return</span> usb-&gt;fbyte_cnt1;
<a name="l00617"></a>00617 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fbyte_cnt0_addr)
<a name="l00618"></a>00618 <span class="keywordflow">return</span> usb-&gt;fbyte_cnt0;
<a name="l00619"></a>00619 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hbyte_cnt0_addr)
<a name="l00620"></a>00620 <span class="keywordflow">return</span> usb-&gt;hbyte_cnt0;
<a name="l00621"></a>00621 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr5_addr)
<a name="l00622"></a>00622 <span class="keywordflow">return</span> usb-&gt;fdr5 = usb_port_rd (usb_reg_name ((VDevice *)usb, addr));
<a name="l00623"></a>00623 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr4_addr)
<a name="l00624"></a>00624 <span class="keywordflow">return</span> usb-&gt;fdr4 = usb_port_rd (usb_reg_name ((VDevice *)usb, addr));
<a name="l00625"></a>00625 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr3_addr)
<a name="l00626"></a>00626 <span class="keywordflow">return</span> usb-&gt;fdr3 = usb_port_rd (usb_reg_name ((VDevice *)usb, addr));
<a name="l00627"></a>00627 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr2_addr)
<a name="l00628"></a>00628 <span class="keywordflow">return</span> usb-&gt;fdr2 = usb_port_rd (usb_reg_name ((VDevice *)usb, addr));
<a name="l00629"></a>00629 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr1_addr)
<a name="l00630"></a>00630 <span class="keywordflow">return</span> usb-&gt;fdr1 = usb_port_rd (usb_reg_name ((VDevice *)usb, addr));
<a name="l00631"></a>00631 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr0_addr)
<a name="l00632"></a>00632 <span class="keywordflow">return</span> usb-&gt;fdr0 = usb_port_rd (usb_reg_name ((VDevice *)usb, addr));
<a name="l00633"></a>00633 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hdr0_addr)
<a name="l00634"></a>00634 <span class="keywordflow">return</span> usb-&gt;hdr0 = usb_port_rd (usb_reg_name ((VDevice *)usb, addr));
<a name="l00635"></a>00635 <span class="keywordflow">else</span>
<a name="l00636"></a>00636 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00637"></a>00637 <span class="keywordflow">return</span> 0; <span class="comment">/* will never get here */</span>
<a name="l00638"></a>00638 }
<a name="l00639"></a>00639
<a name="l00640"></a>00640 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00641"></a>00641 usb_write (VDevice *dev, <span class="keywordtype">int</span> addr, uint8_t val)
<a name="l00642"></a>00642 {
<a name="l00643"></a>00643 USB_T *usb = (USB_T *)dev;
<a name="l00644"></a>00644
<a name="l00645"></a>00645 <span class="keywordflow">if</span> (addr == usb-&gt;uovcer_addr)
<a name="l00646"></a>00646 (usb-&gt;uovcer = val);
<a name="l00647"></a>00647 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;haddr_addr)
<a name="l00648"></a>00648 (usb-&gt;haddr = val);
<a name="l00649"></a>00649 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;faddr_addr)
<a name="l00650"></a>00650 (usb-&gt;faddr = val);
<a name="l00651"></a>00651 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hstr_addr)
<a name="l00652"></a>00652 (usb-&gt;hstr = val);
<a name="l00653"></a>00653 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpcon_addr)
<a name="l00654"></a>00654 (usb-&gt;hpcon = val);
<a name="l00655"></a>00655 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp5_cntr_addr)
<a name="l00656"></a>00656 usb-&gt;fendp5_cntr = val;
<a name="l00657"></a>00657 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp4_cntr_addr)
<a name="l00658"></a>00658 usb-&gt;fendp4_cntr = val;
<a name="l00659"></a>00659 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp3_cntr_addr)
<a name="l00660"></a>00660 usb-&gt;fendp3_cntr = val;
<a name="l00661"></a>00661 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp2_cntr_addr)
<a name="l00662"></a>00662 usb-&gt;fendp2_cntr = val;
<a name="l00663"></a>00663 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp1_cntr_addr)
<a name="l00664"></a>00664 usb-&gt;fendp1_cntr = val;
<a name="l00665"></a>00665 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp0_cntr_addr)
<a name="l00666"></a>00666 usb-&gt;fendp0_cntr = val;
<a name="l00667"></a>00667 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hendp1_cntr_addr)
<a name="l00668"></a>00668 usb-&gt;hendp1_cntr = val;
<a name="l00669"></a>00669 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hendp0_cntr_addr)
<a name="l00670"></a>00670 usb-&gt;hendp0_cntr = val;
<a name="l00671"></a>00671 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar5_addr)
<a name="l00672"></a>00672 {
<a name="l00673"></a>00673 usb-&gt;fcar5 = val;
<a name="l00674"></a>00674 usb-&gt;fcsr5 &amp;= ~val;
<a name="l00675"></a>00675 (usb-&gt;fbyte_cnt5) = 0;
<a name="l00676"></a>00676 }
<a name="l00677"></a>00677 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar4_addr)
<a name="l00678"></a>00678 {
<a name="l00679"></a>00679 usb-&gt;fcar4 = val;
<a name="l00680"></a>00680 usb-&gt;fcsr4 &amp;= ~val;
<a name="l00681"></a>00681 (usb-&gt;fbyte_cnt4) = 0;
<a name="l00682"></a>00682 }
<a name="l00683"></a>00683 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar3_addr)
<a name="l00684"></a>00684 {
<a name="l00685"></a>00685 usb-&gt;fcar3 = val;
<a name="l00686"></a>00686 usb-&gt;fcsr3 &amp;= ~val;
<a name="l00687"></a>00687 (usb-&gt;fbyte_cnt3) = 0;
<a name="l00688"></a>00688 }
<a name="l00689"></a>00689 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar2_addr)
<a name="l00690"></a>00690 {
<a name="l00691"></a>00691 usb-&gt;fcar2 = val;
<a name="l00692"></a>00692 usb-&gt;fcsr2 &amp;= ~val;
<a name="l00693"></a>00693 (usb-&gt;fbyte_cnt2) = 0;
<a name="l00694"></a>00694 }
<a name="l00695"></a>00695 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar1_addr)
<a name="l00696"></a>00696 {
<a name="l00697"></a>00697 usb-&gt;fcar1 = val;
<a name="l00698"></a>00698 usb-&gt;fcsr1 &amp;= ~val;
<a name="l00699"></a>00699 (usb-&gt;fbyte_cnt1) = 0;
<a name="l00700"></a>00700 }
<a name="l00701"></a>00701 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar0_addr)
<a name="l00702"></a>00702 {
<a name="l00703"></a>00703 usb-&gt;fcar0 = val;
<a name="l00704"></a>00704 usb-&gt;fcsr0 &amp;= ~val;
<a name="l00705"></a>00705 (usb-&gt;fbyte_cnt0) = 0;
<a name="l00706"></a>00706 }
<a name="l00707"></a>00707 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hcar0_addr)
<a name="l00708"></a>00708 {
<a name="l00709"></a>00709 usb-&gt;hcar0 = val;
<a name="l00710"></a>00710 usb-&gt;hcsr0 &amp;= ~val;
<a name="l00711"></a>00711 (usb-&gt;hbyte_cnt0) = 0;
<a name="l00712"></a>00712 }
<a name="l00713"></a>00713 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr5_addr)
<a name="l00714"></a>00714 {
<a name="l00715"></a>00715 usb-&gt;fdr5 = val;
<a name="l00716"></a>00716 (usb-&gt;fbyte_cnt5)++;
<a name="l00717"></a>00717 usb_port_wr (usb_reg_name ((VDevice *)usb, addr), val);
<a name="l00718"></a>00718 }
<a name="l00719"></a>00719 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr4_addr)
<a name="l00720"></a>00720 {
<a name="l00721"></a>00721 usb-&gt;fdr4 = val;
<a name="l00722"></a>00722 (usb-&gt;fbyte_cnt4)++;
<a name="l00723"></a>00723 usb_port_wr (usb_reg_name ((VDevice *)usb, addr), val);
<a name="l00724"></a>00724 }
<a name="l00725"></a>00725 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr3_addr)
<a name="l00726"></a>00726 {
<a name="l00727"></a>00727 usb-&gt;fdr3 = val;
<a name="l00728"></a>00728 (usb-&gt;fbyte_cnt3)++;
<a name="l00729"></a>00729 usb_port_wr (usb_reg_name ((VDevice *)usb, addr), val);
<a name="l00730"></a>00730 }
<a name="l00731"></a>00731 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr2_addr)
<a name="l00732"></a>00732 {
<a name="l00733"></a>00733 usb-&gt;fdr2 = val;
<a name="l00734"></a>00734 (usb-&gt;fbyte_cnt2)++;
<a name="l00735"></a>00735 usb_port_wr (usb_reg_name ((VDevice *)usb, addr), val);
<a name="l00736"></a>00736 }
<a name="l00737"></a>00737 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr1_addr)
<a name="l00738"></a>00738 {
<a name="l00739"></a>00739 usb-&gt;fdr1 = val;
<a name="l00740"></a>00740 (usb-&gt;fbyte_cnt1)++;
<a name="l00741"></a>00741 usb_port_wr (usb_reg_name ((VDevice *)usb, addr), val);
<a name="l00742"></a>00742 }
<a name="l00743"></a>00743 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr0_addr)
<a name="l00744"></a>00744 {
<a name="l00745"></a>00745 usb-&gt;fdr0 = val;
<a name="l00746"></a>00746 (usb-&gt;fbyte_cnt0)++;
<a name="l00747"></a>00747 usb_port_wr (usb_reg_name ((VDevice *)usb, addr), val);
<a name="l00748"></a>00748 }
<a name="l00749"></a>00749 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hdr0_addr)
<a name="l00750"></a>00750 {
<a name="l00751"></a>00751 usb-&gt;hdr0 = val;
<a name="l00752"></a>00752 (usb-&gt;hbyte_cnt0)++;
<a name="l00753"></a>00753 usb_port_wr (usb_reg_name ((VDevice *)usb, addr), val);
<a name="l00754"></a>00754 }
<a name="l00755"></a>00755 <span class="keywordflow">else</span>
<a name="l00756"></a>00756 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00757"></a>00757 }
<a name="l00758"></a>00758
<a name="l00759"></a>00759 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00760"></a>00760 usb_reset (VDevice *dev)
<a name="l00761"></a>00761 {
<a name="l00762"></a>00762 USB_T *usb = (USB_T *)dev;
<a name="l00763"></a>00763
<a name="l00764"></a>00764 usb-&gt;haddr = 0;
<a name="l00765"></a>00765 usb-&gt;faddr = 0;
<a name="l00766"></a>00766
<a name="l00767"></a>00767 usb-&gt;hstr = 0;
<a name="l00768"></a>00768 usb-&gt;hpcon = 0;
<a name="l00769"></a>00769
<a name="l00770"></a>00770 usb-&gt;uovcer = 0;
<a name="l00771"></a>00771 }
<a name="l00772"></a>00772
<a name="l00773"></a>00773 <span class="keyword">static</span> <span class="keywordtype">char</span> *
<a name="l00774"></a>00774 usb_reg_name (VDevice *dev, <span class="keywordtype">int</span> addr)
<a name="l00775"></a>00775 {
<a name="l00776"></a>00776 USB_T *usb = (USB_T *)dev;
<a name="l00777"></a>00777
<a name="l00778"></a>00778 <span class="keywordflow">if</span> (addr == usb-&gt;fcar5_addr)
<a name="l00779"></a>00779 <span class="keywordflow">return</span> <span class="stringliteral">"FCAR5"</span>;
<a name="l00780"></a>00780 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar4_addr)
<a name="l00781"></a>00781 <span class="keywordflow">return</span> <span class="stringliteral">"FCAR4"</span>;
<a name="l00782"></a>00782 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar3_addr)
<a name="l00783"></a>00783 <span class="keywordflow">return</span> <span class="stringliteral">"FCAR3"</span>;
<a name="l00784"></a>00784 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar2_addr)
<a name="l00785"></a>00785 <span class="keywordflow">return</span> <span class="stringliteral">"FCAR2"</span>;
<a name="l00786"></a>00786 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar1_addr)
<a name="l00787"></a>00787 <span class="keywordflow">return</span> <span class="stringliteral">"FCAR1"</span>;
<a name="l00788"></a>00788 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcar0_addr)
<a name="l00789"></a>00789 <span class="keywordflow">return</span> <span class="stringliteral">"FCAR0"</span>;
<a name="l00790"></a>00790 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hcar0_addr)
<a name="l00791"></a>00791 <span class="keywordflow">return</span> <span class="stringliteral">"HCAR0"</span>;
<a name="l00792"></a>00792 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate1_addr)
<a name="l00793"></a>00793 <span class="keywordflow">return</span> <span class="stringliteral">"PSTATE1"</span>;
<a name="l00794"></a>00794 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate2_addr)
<a name="l00795"></a>00795 <span class="keywordflow">return</span> <span class="stringliteral">"PSTATE2"</span>;
<a name="l00796"></a>00796 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate3_addr)
<a name="l00797"></a>00797 <span class="keywordflow">return</span> <span class="stringliteral">"PSTATE3"</span>;
<a name="l00798"></a>00798 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate4_addr)
<a name="l00799"></a>00799 <span class="keywordflow">return</span> <span class="stringliteral">"PSTATE4"</span>;
<a name="l00800"></a>00800 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate5_addr)
<a name="l00801"></a>00801 <span class="keywordflow">return</span> <span class="stringliteral">"PSTATE5"</span>;
<a name="l00802"></a>00802 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate6_addr)
<a name="l00803"></a>00803 <span class="keywordflow">return</span> <span class="stringliteral">"PSTATE6"</span>;
<a name="l00804"></a>00804 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate7_addr)
<a name="l00805"></a>00805 <span class="keywordflow">return</span> <span class="stringliteral">"PSTATE7"</span>;
<a name="l00806"></a>00806 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;pstate8_addr)
<a name="l00807"></a>00807 <span class="keywordflow">return</span> <span class="stringliteral">"PSTATE8"</span>;
<a name="l00808"></a>00808 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr1_addr)
<a name="l00809"></a>00809 <span class="keywordflow">return</span> <span class="stringliteral">"HPSCR1"</span>;
<a name="l00810"></a>00810 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr2_addr)
<a name="l00811"></a>00811 <span class="keywordflow">return</span> <span class="stringliteral">"HPSCR2"</span>;
<a name="l00812"></a>00812 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr3_addr)
<a name="l00813"></a>00813 <span class="keywordflow">return</span> <span class="stringliteral">"HPSCR3"</span>;
<a name="l00814"></a>00814 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr4_addr)
<a name="l00815"></a>00815 <span class="keywordflow">return</span> <span class="stringliteral">"HPSCR4"</span>;
<a name="l00816"></a>00816 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr5_addr)
<a name="l00817"></a>00817 <span class="keywordflow">return</span> <span class="stringliteral">"HPSCR5"</span>;
<a name="l00818"></a>00818 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr6_addr)
<a name="l00819"></a>00819 <span class="keywordflow">return</span> <span class="stringliteral">"HPSCR6"</span>;
<a name="l00820"></a>00820 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr7_addr)
<a name="l00821"></a>00821 <span class="keywordflow">return</span> <span class="stringliteral">"HPSCR7"</span>;
<a name="l00822"></a>00822 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpscr8_addr)
<a name="l00823"></a>00823 <span class="keywordflow">return</span> <span class="stringliteral">"HPSCR8"</span>;
<a name="l00824"></a>00824 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat1_addr)
<a name="l00825"></a>00825 <span class="keywordflow">return</span> <span class="stringliteral">"HPSTAT1"</span>;
<a name="l00826"></a>00826 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat2_addr)
<a name="l00827"></a>00827 <span class="keywordflow">return</span> <span class="stringliteral">"HPSTAT2"</span>;
<a name="l00828"></a>00828 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat3_addr)
<a name="l00829"></a>00829 <span class="keywordflow">return</span> <span class="stringliteral">"HPSTAT3"</span>;
<a name="l00830"></a>00830 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat4_addr)
<a name="l00831"></a>00831 <span class="keywordflow">return</span> <span class="stringliteral">"HPSTAT4"</span>;
<a name="l00832"></a>00832 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat5_addr)
<a name="l00833"></a>00833 <span class="keywordflow">return</span> <span class="stringliteral">"HPSTAT5"</span>;
<a name="l00834"></a>00834 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat6_addr)
<a name="l00835"></a>00835 <span class="keywordflow">return</span> <span class="stringliteral">"HPSTAT6"</span>;
<a name="l00836"></a>00836 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat7_addr)
<a name="l00837"></a>00837 <span class="keywordflow">return</span> <span class="stringliteral">"HPSTAT7"</span>;
<a name="l00838"></a>00838 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpstat8_addr)
<a name="l00839"></a>00839 <span class="keywordflow">return</span> <span class="stringliteral">"HPSTAT8"</span>;
<a name="l00840"></a>00840 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hpcon_addr)
<a name="l00841"></a>00841 <span class="keywordflow">return</span> <span class="stringliteral">"HPCON"</span>;
<a name="l00842"></a>00842 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hstr_addr)
<a name="l00843"></a>00843 <span class="keywordflow">return</span> <span class="stringliteral">"HSTR"</span>;
<a name="l00844"></a>00844 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fbyte_cnt5_addr)
<a name="l00845"></a>00845 <span class="keywordflow">return</span> <span class="stringliteral">"FBYTE_CNT5"</span>;
<a name="l00846"></a>00846 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fbyte_cnt4_addr)
<a name="l00847"></a>00847 <span class="keywordflow">return</span> <span class="stringliteral">"FBYTE_CNT4"</span>;
<a name="l00848"></a>00848 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fbyte_cnt3_addr)
<a name="l00849"></a>00849 <span class="keywordflow">return</span> <span class="stringliteral">"FBYTE_CNT3"</span>;
<a name="l00850"></a>00850 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fbyte_cnt2_addr)
<a name="l00851"></a>00851 <span class="keywordflow">return</span> <span class="stringliteral">"FBYTE_CNT2"</span>;
<a name="l00852"></a>00852 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fbyte_cnt1_addr)
<a name="l00853"></a>00853 <span class="keywordflow">return</span> <span class="stringliteral">"FBYTE_CNT1"</span>;
<a name="l00854"></a>00854 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fbyte_cnt0_addr)
<a name="l00855"></a>00855 <span class="keywordflow">return</span> <span class="stringliteral">"FBYTE_CNT0"</span>;
<a name="l00856"></a>00856 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hbyte_cnt0_addr)
<a name="l00857"></a>00857 <span class="keywordflow">return</span> <span class="stringliteral">"HBYTE_CNT0"</span>;
<a name="l00858"></a>00858 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr5_addr)
<a name="l00859"></a>00859 <span class="keywordflow">return</span> <span class="stringliteral">"FDR5"</span>;
<a name="l00860"></a>00860 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr4_addr)
<a name="l00861"></a>00861 <span class="keywordflow">return</span> <span class="stringliteral">"FDR4"</span>;
<a name="l00862"></a>00862 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr3_addr)
<a name="l00863"></a>00863 <span class="keywordflow">return</span> <span class="stringliteral">"FDR3"</span>;
<a name="l00864"></a>00864 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr2_addr)
<a name="l00865"></a>00865 <span class="keywordflow">return</span> <span class="stringliteral">"FDR2"</span>;
<a name="l00866"></a>00866 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr1_addr)
<a name="l00867"></a>00867 <span class="keywordflow">return</span> <span class="stringliteral">"FDR1"</span>;
<a name="l00868"></a>00868 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fdr0_addr)
<a name="l00869"></a>00869 <span class="keywordflow">return</span> <span class="stringliteral">"FDR0"</span>;
<a name="l00870"></a>00870 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hdr0_addr)
<a name="l00871"></a>00871 <span class="keywordflow">return</span> <span class="stringliteral">"HDR0"</span>;
<a name="l00872"></a>00872 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcsr5_addr)
<a name="l00873"></a>00873 <span class="keywordflow">return</span> <span class="stringliteral">"FCSR5"</span>;
<a name="l00874"></a>00874 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcsr4_addr)
<a name="l00875"></a>00875 <span class="keywordflow">return</span> <span class="stringliteral">"FCSR4"</span>;
<a name="l00876"></a>00876 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcsr3_addr)
<a name="l00877"></a>00877 <span class="keywordflow">return</span> <span class="stringliteral">"FCSR3"</span>;
<a name="l00878"></a>00878 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcsr2_addr)
<a name="l00879"></a>00879 <span class="keywordflow">return</span> <span class="stringliteral">"FCSR2"</span>;
<a name="l00880"></a>00880 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcsr1_addr)
<a name="l00881"></a>00881 <span class="keywordflow">return</span> <span class="stringliteral">"FCSR1"</span>;
<a name="l00882"></a>00882 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fcsr0_addr)
<a name="l00883"></a>00883 <span class="keywordflow">return</span> <span class="stringliteral">"FCSR0"</span>;
<a name="l00884"></a>00884 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hcsr0_addr)
<a name="l00885"></a>00885 <span class="keywordflow">return</span> <span class="stringliteral">"HCSR0"</span>;
<a name="l00886"></a>00886 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp5_cntr_addr)
<a name="l00887"></a>00887 <span class="keywordflow">return</span> <span class="stringliteral">"FENDP5_CNTR"</span>;
<a name="l00888"></a>00888 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp4_cntr_addr)
<a name="l00889"></a>00889 <span class="keywordflow">return</span> <span class="stringliteral">"FENDP4_CNTR"</span>;
<a name="l00890"></a>00890 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp3_cntr_addr)
<a name="l00891"></a>00891 <span class="keywordflow">return</span> <span class="stringliteral">"FENDP3_CNTR"</span>;
<a name="l00892"></a>00892 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp2_cntr_addr)
<a name="l00893"></a>00893 <span class="keywordflow">return</span> <span class="stringliteral">"FENDP2_CNTR"</span>;
<a name="l00894"></a>00894 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp1_cntr_addr)
<a name="l00895"></a>00895 <span class="keywordflow">return</span> <span class="stringliteral">"FENDP1_CNTR"</span>;
<a name="l00896"></a>00896 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;fendp0_cntr_addr)
<a name="l00897"></a>00897 <span class="keywordflow">return</span> <span class="stringliteral">"FENDP0_CNTR"</span>;
<a name="l00898"></a>00898 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hendp1_cntr_addr)
<a name="l00899"></a>00899 <span class="keywordflow">return</span> <span class="stringliteral">"HENDP1_CNTR"</span>;
<a name="l00900"></a>00900 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;hendp0_cntr_addr)
<a name="l00901"></a>00901 <span class="keywordflow">return</span> <span class="stringliteral">"HENDP0_CNTR"</span>;
<a name="l00902"></a>00902 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;faddr_addr)
<a name="l00903"></a>00903 <span class="keywordflow">return</span> <span class="stringliteral">"FADDR"</span>;
<a name="l00904"></a>00904 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;haddr_addr)
<a name="l00905"></a>00905 <span class="keywordflow">return</span> <span class="stringliteral">"HADDR"</span>;
<a name="l00906"></a>00906 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;iscr_addr)
<a name="l00907"></a>00907 <span class="keywordflow">return</span> <span class="stringliteral">"ISCR"</span>;
<a name="l00908"></a>00908 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (addr == usb-&gt;uovcer_addr)
<a name="l00909"></a>00909 <span class="keywordflow">return</span> <span class="stringliteral">"UOVCER"</span>;
<a name="l00910"></a>00910 <span class="keywordflow">else</span>
<a name="l00911"></a>00911 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Bad address: 0x%04x"</span>, addr);
<a name="l00912"></a>00912 <span class="keywordflow">return</span> NULL;
<a name="l00913"></a>00913 }
<a name="l00914"></a>00914
<a name="l00915"></a>00915 uint8_t
<a name="l00916"></a>00916 usb_port_rd (<span class="keywordtype">char</span> *name)
<a name="l00917"></a>00917 {
<a name="l00918"></a>00918 <span class="keywordtype">int</span> data;
<a name="l00919"></a>00919 <span class="keywordtype">char</span> line[80];
<a name="l00920"></a>00920
<a name="l00921"></a>00921 <span class="keywordflow">while</span> (1)
<a name="l00922"></a>00922 {
<a name="l00923"></a>00923 fprintf (stderr, <span class="stringliteral">"\nEnter a byte of hex data to read into %s: "</span>,
<a name="l00924"></a>00924 name);
<a name="l00925"></a>00925
<a name="l00926"></a>00926 <span class="comment">/* try to read in a line of input */</span>
<a name="l00927"></a>00927 <span class="keywordflow">if</span> (fgets (line, <span class="keyword">sizeof</span> (line), stdin) == NULL)
<a name="l00928"></a>00928 <span class="keywordflow">continue</span>;
<a name="l00929"></a>00929
<a name="l00930"></a>00930 <span class="comment">/* try to parse the line for a byte of data */</span>
<a name="l00931"></a>00931 <span class="keywordflow">if</span> (sscanf (line, <span class="stringliteral">"%x\n"</span>, &amp;data) != 1)
<a name="l00932"></a>00932 <span class="keywordflow">continue</span>;
<a name="l00933"></a>00933
<a name="l00934"></a>00934 <span class="keywordflow">break</span>;
<a name="l00935"></a>00935 }
<a name="l00936"></a>00936 <span class="keywordflow">return</span> (uint8_t) (data &amp; 0xff);
<a name="l00937"></a>00937 }
<a name="l00938"></a>00938
<a name="l00939"></a>00939 <span class="keywordtype">void</span>
<a name="l00940"></a>00940 usb_port_wr (<span class="keywordtype">char</span> *name, uint8_t val)
<a name="l00941"></a>00941 {
<a name="l00942"></a>00942 fprintf (stderr, <span class="stringliteral">"wrote 0x%02x to %s\n"</span>, val, name);
<a name="l00943"></a>00943 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,297 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>usb.c File Reference</h1>Module to simulate the AVR's USB module. <a href="#_details">More...</a>
<p>
<p>
<a href="usb_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="6cf88939470548d7f8da8f3af555a2e8"></a><!-- doxytag: member="usb.c::usb_port_wr" ref="6cf88939470548d7f8da8f3af555a2e8" args="(char *name, uint8_t val)" -->
void&nbsp;</td><td class="memItemRight" valign="bottom"><b>usb_port_wr</b> (char *name, uint8_t val)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="9a8200096cab8c42b198e52fbf872c4f"></a><!-- doxytag: member="usb.c::usb_port_rd" ref="9a8200096cab8c42b198e52fbf872c4f" args="(char *name)" -->
uint8_t&nbsp;</td><td class="memItemRight" valign="bottom"><b>usb_port_rd</b> (char *name)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="usb_8c.html#254a13da6e1f9dcda78a1a01c3324cd8">usbi_create</a> (int addr, char *name, int rel_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="9195b1a127739fd755635037742a642b"></a><!-- doxytag: member="usb.c::usb_intr_new" ref="9195b1a127739fd755635037742a642b" args="(int addr, char *name, uint8_t func_mask)" -->
USBInter_T *&nbsp;</td><td class="memItemRight" valign="bottom"><b>usb_intr_new</b> (int addr, char *name, uint8_t func_mask)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="usb_8c.html#bc59e75f4f846b5075470bb8b7d00cf0">usb_intr_construct</a> (USBInter_T *usb, int addr, char *name, uint8_t func_mask)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="usb_8c.html#c02f3bf581c2e053d30b3c0e004713f5">usb_intr_destroy</a> (void *usb)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">VDevice *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="usb_8c.html#7b5bc9c47afcbe8cf57d75dd4ed47968">usb_create</a> (int addr, char *name, int rel_addr, void *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a8fdfdb05c2083d45c76d4dafffa0dd9"></a><!-- doxytag: member="usb.c::usb_new" ref="a8fdfdb05c2083d45c76d4dafffa0dd9" args="(int addr, char *name)" -->
USB_T *&nbsp;</td><td class="memItemRight" valign="bottom"><b>usb_new</b> (int addr, char *name)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="usb_8c.html#b46dace89d6472ed1f0dc235d2b9e5c5">usb_construct</a> (USB_T *usb, int addr, char *name)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="usb_8c.html#238a235b4fe1c88d56b67e65dc57274d">usb_destroy</a> (void *usb)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Module to simulate the AVR's USB module.
<p>
<p>Definition in file <a class="el" href="usb_8c-source.html">usb.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="254a13da6e1f9dcda78a1a01c3324cd8"></a><!-- doxytag: member="usb.c::usbi_create" ref="254a13da6e1f9dcda78a1a01c3324cd8" args="(int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* usbi_create </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new USB interrupt.
<p>
<p>Definition at line <a class="el" href="usb_8c-source.html#l00078">78</a> of file <a class="el" href="usb_8c-source.html">usb.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
</div>
</div><p>
<a class="anchor" name="bc59e75f4f846b5075470bb8b7d00cf0"></a><!-- doxytag: member="usb.c::usb_intr_construct" ref="bc59e75f4f846b5075470bb8b7d00cf0" args="(USBInter_T *usb, int addr, char *name, uint8_t func_mask)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void usb_intr_construct </td>
<td>(</td>
<td class="paramtype">USBInter_T *&nbsp;</td>
<td class="paramname"> <em>usb</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint8_t&nbsp;</td>
<td class="paramname"> <em>func_mask</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for usb interrupt object.
<p>
<p>Definition at line <a class="el" href="usb_8c-source.html#l00103">103</a> of file <a class="el" href="usb_8c-source.html">usb.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="c02f3bf581c2e053d30b3c0e004713f5"></a><!-- doxytag: member="usb.c::usb_intr_destroy" ref="c02f3bf581c2e053d30b3c0e004713f5" args="(void *usb)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void usb_intr_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>usb</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for usb interrupt object.
<p>
<p>Definition at line <a class="el" href="usb_8c-source.html#l00181">181</a> of file <a class="el" href="usb_8c-source.html">usb.c</a>.</p>
<p>References <a class="el" href="device_8c-source.html#l00105">vdev_destroy()</a>.</p>
</div>
</div><p>
<a class="anchor" name="7b5bc9c47afcbe8cf57d75dd4ed47968"></a><!-- doxytag: member="usb.c::usb_create" ref="7b5bc9c47afcbe8cf57d75dd4ed47968" args="(int addr, char *name, int rel_addr, void *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">VDevice* usb_create </td>
<td>(</td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>rel_addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Allocate a new USB structure.
<p>
<p>Definition at line <a class="el" href="usb_8c-source.html#l00301">301</a> of file <a class="el" href="usb_8c-source.html">usb.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="b46dace89d6472ed1f0dc235d2b9e5c5"></a><!-- doxytag: member="usb.c::usb_construct" ref="b46dace89d6472ed1f0dc235d2b9e5c5" args="(USB_T *usb, int addr, char *name)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void usb_construct </td>
<td>(</td>
<td class="paramtype">USB_T *&nbsp;</td>
<td class="paramname"> <em>usb</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>addr</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>name</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Constructor for new USB object.
<p>
<p>Definition at line <a class="el" href="usb_8c-source.html#l00321">321</a> of file <a class="el" href="usb_8c-source.html">usb.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="device_8c-source.html#l00089">vdev_construct()</a>.</p>
</div>
</div><p>
<a class="anchor" name="238a235b4fe1c88d56b67e65dc57274d"></a><!-- doxytag: member="usb.c::usb_destroy" ref="238a235b4fe1c88d56b67e65dc57274d" args="(void *usb)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void usb_destroy </td>
<td>(</td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>usb</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Destructor for USB object.
<p>
<p>Definition at line <a class="el" href="usb_8c-source.html#l00480">480</a> of file <a class="el" href="usb_8c-source.html">usb.c</a>.</p>
<p>References <a class="el" href="device_8c-source.html#l00105">vdev_destroy()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,401 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>utils.c</h1><a href="utils_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * $Id: utils.c,v 1.19 2003/12/01 09:10:17 troth Exp $</span>
<a name="l00003"></a>00003 <span class="comment"> *</span>
<a name="l00004"></a>00004 <span class="comment"> ****************************************************************************</span>
<a name="l00005"></a>00005 <span class="comment"> *</span>
<a name="l00006"></a>00006 <span class="comment"> * simulavr - A simulator for the Atmel AVR family of microcontrollers.</span>
<a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2001, 2002, 2003 Theodore A. Roth</span>
<a name="l00008"></a>00008 <span class="comment"> *</span>
<a name="l00009"></a>00009 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
<a name="l00010"></a>00010 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00011"></a>00011 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00012"></a>00012 <span class="comment"> * (at your option) any later version.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
<a name="l00015"></a>00015 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00016"></a>00016 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00017"></a>00017 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00018"></a>00018 <span class="comment"> *</span>
<a name="l00019"></a>00019 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00020"></a>00020 <span class="comment"> * along with this program; if not, write to the Free Software</span>
<a name="l00021"></a>00021 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> ****************************************************************************</span>
<a name="l00024"></a>00024 <span class="comment"> */</span>
<a name="l00025"></a>00025 <span class="comment"></span>
<a name="l00026"></a>00026 <span class="comment">/**</span>
<a name="l00027"></a>00027 <span class="comment"> * \file utils.c</span>
<a name="l00028"></a>00028 <span class="comment"> * \brief Utility functions.</span>
<a name="l00029"></a>00029 <span class="comment"> *</span>
<a name="l00030"></a>00030 <span class="comment"> * This module provides general purpose utilities.</span>
<a name="l00031"></a>00031 <span class="comment"> */</span>
<a name="l00032"></a>00032
<a name="l00033"></a>00033 <span class="preprocessor">#include &lt;config.h&gt;</span>
<a name="l00034"></a>00034
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;unistd.h&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;errno.h&gt;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;sys/time.h&gt;</span>
<a name="l00041"></a>00041
<a name="l00042"></a>00042 <span class="preprocessor">#include "avrerror.h"</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include "avrmalloc.h"</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include "avrclass.h"</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include "utils.h"</span>
<a name="l00046"></a>00046 <span class="comment"></span>
<a name="l00047"></a>00047 <span class="comment">/** \brief Utility function to convert a string to a FileFormatType code. */</span>
<a name="l00048"></a>00048
<a name="l00049"></a>00049 <span class="keywordtype">int</span>
<a name="l00050"></a><a class="code" href="utils_8c.html#5d306d06881ee5b68d679edec2e7fd75">00050</a> <a class="code" href="utils_8c.html#5d306d06881ee5b68d679edec2e7fd75" title="Utility function to convert a string to a FileFormatType code.">str2ffmt</a> (<span class="keywordtype">char</span> *str)
<a name="l00051"></a>00051 {
<a name="l00052"></a>00052 <span class="keywordflow">if</span> (strncmp (str, <span class="stringliteral">"bin"</span>, 3) == 0)
<a name="l00053"></a>00053 <span class="keywordflow">return</span> FFMT_BIN;
<a name="l00054"></a>00054 <span class="keywordflow">if</span> (strncmp (str, <span class="stringliteral">"ihex"</span>, 4) == 0)
<a name="l00055"></a>00055 <span class="keywordflow">return</span> FFMT_IHEX;
<a name="l00056"></a>00056 <span class="keywordflow">if</span> (strncmp (str, <span class="stringliteral">"elf"</span>, 3) == 0)
<a name="l00057"></a>00057 <span class="keywordflow">return</span> FFMT_ELF;
<a name="l00058"></a>00058
<a name="l00059"></a>00059 <span class="keywordflow">return</span> -1;
<a name="l00060"></a>00060 }
<a name="l00061"></a>00061 <span class="comment"></span>
<a name="l00062"></a>00062 <span class="comment">/** \brief Set a bit in src to 1 if val != 0, clears bit if val == 0. */</span>
<a name="l00063"></a>00063
<a name="l00064"></a>00064 <span class="keyword">extern</span> <span class="keyword">inline</span> uint8_t <a class="code" href="utils_8c.html#eb8ce7ee7e6e35ee3ec8d3539bb52519" title="Set a bit in src to 1 if val != 0, clears bit if val == 0.">set_bit_in_byte</a> (uint8_t src, <span class="keywordtype">int</span> bit, <span class="keywordtype">int</span> val);
<a name="l00065"></a>00065 <span class="comment"></span>
<a name="l00066"></a>00066 <span class="comment">/** \brief Set a bit in src to 1 if val != 0, clears bit if val == 0. */</span>
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="keyword">extern</span> <span class="keyword">inline</span> uint16_t <a class="code" href="utils_8c.html#4250710ef21e0fe21d15dcc6203e4298" title="Set a bit in src to 1 if val != 0, clears bit if val == 0.">set_bit_in_word</a> (uint16_t src, <span class="keywordtype">int</span> bit, <span class="keywordtype">int</span> val);
<a name="l00069"></a>00069 <span class="comment"></span>
<a name="l00070"></a>00070 <span class="comment">/** \brief Return the number of milliseconds of elapsed program time.</span>
<a name="l00071"></a>00071 <span class="comment"></span>
<a name="l00072"></a>00072 <span class="comment"> \return an unsigned 64 bit number. Time zero is not well</span>
<a name="l00073"></a>00073 <span class="comment"> defined, so only time differences should be used. */</span>
<a name="l00074"></a>00074
<a name="l00075"></a>00075 uint64_t
<a name="l00076"></a><a class="code" href="utils_8c.html#d71e2db9144e1b1d539e1326cbdcbf04">00076</a> <a class="code" href="utils_8c.html#d71e2db9144e1b1d539e1326cbdcbf04" title="Return the number of milliseconds of elapsed program time.">get_program_time</a> (<span class="keywordtype">void</span>)
<a name="l00077"></a>00077 {
<a name="l00078"></a>00078 uint64_t result;
<a name="l00079"></a>00079 <span class="keyword">struct </span>timeval tv;
<a name="l00080"></a>00080
<a name="l00081"></a>00081 <span class="keywordflow">if</span> (gettimeofday (&amp;tv, NULL) &lt; 0)
<a name="l00082"></a>00082 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"Failed to get program time."</span>);
<a name="l00083"></a>00083
<a name="l00084"></a>00084 result = ((uint64_t) tv.tv_sec * 1000) + ((uint64_t) tv.tv_usec / 1000);
<a name="l00085"></a>00085
<a name="l00086"></a>00086 <span class="keywordflow">return</span> result;
<a name="l00087"></a>00087 }
<a name="l00088"></a>00088
<a name="l00089"></a>00089 <span class="comment">/***************************************************************************\</span>
<a name="l00090"></a>00090 <span class="comment"> *</span>
<a name="l00091"></a>00091 <span class="comment"> * DList(AvrClass) Methods : A doubly linked list.</span>
<a name="l00092"></a>00092 <span class="comment"> *</span>
<a name="l00093"></a>00093 <span class="comment">\***************************************************************************/</span>
<a name="l00094"></a>00094
<a name="l00095"></a>00095 <span class="keyword">static</span> DList *dlist_new_node (AvrClass *data);
<a name="l00096"></a>00096 <span class="keyword">static</span> <span class="keywordtype">void</span> dlist_construct_node (DList *node, AvrClass *data);
<a name="l00097"></a>00097 <span class="keyword">static</span> <span class="keywordtype">void</span> dlist_destroy_node (<span class="keywordtype">void</span> *node);
<a name="l00098"></a>00098
<a name="l00099"></a>00099 <span class="preprocessor">#ifndef DOXYGEN </span><span class="comment">/* Don't expose to doxygen, structure is</span>
<a name="l00100"></a>00100 <span class="comment"> opaque. */</span>
<a name="l00101"></a>00101
<a name="l00102"></a>00102 <span class="keyword">struct </span>_DList
<a name="l00103"></a>00103 {
<a name="l00104"></a>00104 AvrClass parent;
<a name="l00105"></a>00105 <span class="keyword">struct </span>_DList *prev;
<a name="l00106"></a>00106 <span class="keyword">struct </span>_DList *next;
<a name="l00107"></a>00107 AvrClass *data;
<a name="l00108"></a>00108 };
<a name="l00109"></a>00109
<a name="l00110"></a>00110 <span class="preprocessor">#endif</span>
<a name="l00111"></a>00111 <span class="preprocessor"></span>
<a name="l00112"></a>00112 <span class="keyword">static</span> DList *
<a name="l00113"></a>00113 dlist_new_node (AvrClass *data)
<a name="l00114"></a>00114 {
<a name="l00115"></a>00115 DList *node;
<a name="l00116"></a>00116
<a name="l00117"></a>00117 node = <a class="code" href="avrmalloc_8c.html#a543f348351cdcaebdd8947d1a591578" title="Macro for allocating memory.">avr_new</a> (DList, 1);
<a name="l00118"></a>00118 dlist_construct_node (node, data);
<a name="l00119"></a>00119 <a class="code" href="avrclass_8c.html#82d397ff00a7f1c1447832dbff1856e1" title="Overload the default destroy method.">class_overload_destroy</a> ((AvrClass *)node, dlist_destroy_node);
<a name="l00120"></a>00120
<a name="l00121"></a>00121 <span class="keywordflow">return</span> node;
<a name="l00122"></a>00122 }
<a name="l00123"></a>00123
<a name="l00124"></a>00124 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00125"></a>00125 dlist_construct_node (DList *node, AvrClass *data)
<a name="l00126"></a>00126 {
<a name="l00127"></a>00127 <span class="keywordflow">if</span> (node == NULL)
<a name="l00128"></a>00128 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"passed null ptr"</span>);
<a name="l00129"></a>00129
<a name="l00130"></a>00130 <a class="code" href="avrclass_8c.html#ffeb66dd49a62ad1b7606cde0e3b039e" title="Initializes the AvrClass data structure.">class_construct</a> ((AvrClass *)node);
<a name="l00131"></a>00131
<a name="l00132"></a>00132 node-&gt;prev = NULL;
<a name="l00133"></a>00133 node-&gt;next = NULL;
<a name="l00134"></a>00134
<a name="l00135"></a>00135 node-&gt;data = data;
<a name="l00136"></a>00136 }
<a name="l00137"></a>00137
<a name="l00138"></a>00138 <span class="keyword">static</span> <span class="keywordtype">void</span>
<a name="l00139"></a>00139 dlist_destroy_node (<span class="keywordtype">void</span> *node)
<a name="l00140"></a>00140 {
<a name="l00141"></a>00141 DList *_node = (DList *)node;
<a name="l00142"></a>00142
<a name="l00143"></a>00143 <span class="keywordflow">if</span> (_node == NULL)
<a name="l00144"></a>00144 <span class="keywordflow">return</span>;
<a name="l00145"></a>00145
<a name="l00146"></a>00146 <a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a> (_node-&gt;data);
<a name="l00147"></a>00147
<a name="l00148"></a>00148 <a class="code" href="avrclass_8c.html#86e290a528dd1ed0bf5057056b5731e5" title="Releases resources allocated by class&amp;#39;s &amp;lt;klass&amp;gt;_new() function.">class_destroy</a> (node);
<a name="l00149"></a>00149 }
<a name="l00150"></a>00150 <span class="comment"></span>
<a name="l00151"></a>00151 <span class="comment">/** \brief Add a new node to the end of the list.</span>
<a name="l00152"></a>00152 <span class="comment"></span>
<a name="l00153"></a>00153 <span class="comment"> If cmp argument is not NULL, use cmp() to see if node already exists and</span>
<a name="l00154"></a>00154 <span class="comment"> don't add node if it exists.</span>
<a name="l00155"></a>00155 <span class="comment"></span>
<a name="l00156"></a>00156 <span class="comment"> It is the responsibility of this function to unref data if not added. */</span>
<a name="l00157"></a>00157
<a name="l00158"></a>00158 DList *
<a name="l00159"></a><a class="code" href="utils_8c.html#2f451be088e616a1c94508c1312e99ed">00159</a> <a class="code" href="utils_8c.html#2f451be088e616a1c94508c1312e99ed" title="Add a new node to the end of the list.">dlist_add</a> (DList *head, AvrClass *data, DListFP_Cmp cmp)
<a name="l00160"></a>00160 {
<a name="l00161"></a>00161 DList *node = head;
<a name="l00162"></a>00162
<a name="l00163"></a>00163 <span class="keywordflow">if</span> (head == NULL)
<a name="l00164"></a>00164 <span class="comment">/* The list is empty, make new node the head. */</span>
<a name="l00165"></a>00165 <span class="keywordflow">return</span> dlist_new_node (data);
<a name="l00166"></a>00166
<a name="l00167"></a>00167 <span class="comment">/* Walk the list to find the end */</span>
<a name="l00168"></a>00168
<a name="l00169"></a>00169 <span class="keywordflow">while</span> (node)
<a name="l00170"></a>00170 {
<a name="l00171"></a>00171 <span class="keywordflow">if</span> (cmp &amp;&amp; ((*cmp) (node-&gt;data, data) == 0))
<a name="l00172"></a>00172 {
<a name="l00173"></a>00173 <span class="comment">/* node already exists and we were asked to keep nodes unique */</span>
<a name="l00174"></a>00174 <a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a> (data);
<a name="l00175"></a>00175 <span class="keywordflow">break</span>;
<a name="l00176"></a>00176 }
<a name="l00177"></a>00177
<a name="l00178"></a>00178 <span class="keywordflow">if</span> (node-&gt;next == NULL)
<a name="l00179"></a>00179 {
<a name="l00180"></a>00180 <span class="comment">/* at the tail */</span>
<a name="l00181"></a>00181 node-&gt;next = dlist_new_node (data);
<a name="l00182"></a>00182 node-&gt;next-&gt;prev = node;
<a name="l00183"></a>00183 <span class="keywordflow">break</span>;
<a name="l00184"></a>00184 }
<a name="l00185"></a>00185
<a name="l00186"></a>00186 <span class="comment">/* move on to next node */</span>
<a name="l00187"></a>00187 node = node-&gt;next;
<a name="l00188"></a>00188 }
<a name="l00189"></a>00189
<a name="l00190"></a>00190 <span class="keywordflow">return</span> head;
<a name="l00191"></a>00191 }
<a name="l00192"></a>00192 <span class="comment"></span>
<a name="l00193"></a>00193 <span class="comment">/** \brief Add a new node at the head of the list. */</span>
<a name="l00194"></a>00194
<a name="l00195"></a>00195 DList *
<a name="l00196"></a><a class="code" href="utils_8c.html#46d7303de632a8f87f61f2bf555f1840">00196</a> <a class="code" href="utils_8c.html#46d7303de632a8f87f61f2bf555f1840" title="Add a new node at the head of the list.">dlist_add_head</a> (DList *head, AvrClass *data)
<a name="l00197"></a>00197 {
<a name="l00198"></a>00198 DList *node = dlist_new_node (data);;
<a name="l00199"></a>00199
<a name="l00200"></a>00200 <span class="keywordflow">if</span> (head)
<a name="l00201"></a>00201 {
<a name="l00202"></a>00202 head-&gt;prev = node;
<a name="l00203"></a>00203 node-&gt;next = head;
<a name="l00204"></a>00204 }
<a name="l00205"></a>00205
<a name="l00206"></a>00206 <span class="keywordflow">return</span> node;
<a name="l00207"></a>00207 }
<a name="l00208"></a>00208 <span class="comment"></span>
<a name="l00209"></a>00209 <span class="comment">/** \brief Conditionally delete a node from the list.</span>
<a name="l00210"></a>00210 <span class="comment"></span>
<a name="l00211"></a>00211 <span class="comment"> Delete a node from the list if the node's data matches the specified</span>
<a name="l00212"></a>00212 <span class="comment"> data. Returns the head of the modified list. */</span>
<a name="l00213"></a>00213
<a name="l00214"></a>00214 DList *
<a name="l00215"></a><a class="code" href="utils_8c.html#0be979713f40bde065ecf4c51b41fe0d">00215</a> <a class="code" href="utils_8c.html#0be979713f40bde065ecf4c51b41fe0d" title="Conditionally delete a node from the list.">dlist_delete</a> (DList *head, AvrClass *data, DListFP_Cmp cmp)
<a name="l00216"></a>00216 {
<a name="l00217"></a>00217 DList *node = head;
<a name="l00218"></a>00218
<a name="l00219"></a>00219 <span class="keywordflow">if</span> (cmp == NULL)
<a name="l00220"></a>00220 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"compare function not specified"</span>);
<a name="l00221"></a>00221
<a name="l00222"></a>00222 <span class="keywordflow">while</span> (node)
<a name="l00223"></a>00223 {
<a name="l00224"></a>00224 <span class="keywordflow">if</span> ((*cmp) (node-&gt;data, data) == 0)
<a name="l00225"></a>00225 {
<a name="l00226"></a>00226 <span class="keywordflow">if</span> ((node-&gt;prev == NULL) &amp;&amp; (node-&gt;next == NULL))
<a name="l00227"></a>00227 {
<a name="l00228"></a>00228 <span class="comment">/* deleting only node in list (node is head and tail) */</span>
<a name="l00229"></a>00229 head = NULL;
<a name="l00230"></a>00230 }
<a name="l00231"></a>00231 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (node-&gt;prev == NULL)
<a name="l00232"></a>00232 {
<a name="l00233"></a>00233 <span class="comment">/* node is head, but other nodes exist */</span>
<a name="l00234"></a>00234 node-&gt;next-&gt;prev = NULL;
<a name="l00235"></a>00235 head = node-&gt;next;
<a name="l00236"></a>00236 }
<a name="l00237"></a>00237 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (node-&gt;next == NULL)
<a name="l00238"></a>00238 {
<a name="l00239"></a>00239 <span class="comment">/* node is tail, but other nodes exist */</span>
<a name="l00240"></a>00240 node-&gt;prev-&gt;next = NULL;
<a name="l00241"></a>00241 }
<a name="l00242"></a>00242 <span class="keywordflow">else</span>
<a name="l00243"></a>00243 {
<a name="l00244"></a>00244 <span class="comment">/* node is not head nor tail */</span>
<a name="l00245"></a>00245 node-&gt;prev-&gt;next = node-&gt;next;
<a name="l00246"></a>00246 node-&gt;next-&gt;prev = node-&gt;prev;
<a name="l00247"></a>00247 }
<a name="l00248"></a>00248
<a name="l00249"></a>00249 <span class="comment">/* this will also unref the node-&gt;data */</span>
<a name="l00250"></a>00250 <a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a> ((AvrClass *)node);
<a name="l00251"></a>00251
<a name="l00252"></a>00252 <span class="keywordflow">return</span> head;
<a name="l00253"></a>00253 }
<a name="l00254"></a>00254
<a name="l00255"></a>00255 <span class="comment">/* move on to next node */</span>
<a name="l00256"></a>00256 node = node-&gt;next;
<a name="l00257"></a>00257 }
<a name="l00258"></a>00258
<a name="l00259"></a>00259 <span class="comment">/* if we get here, data wasn't found, just return original head */</span>
<a name="l00260"></a>00260 <span class="keywordflow">return</span> head;
<a name="l00261"></a>00261 }
<a name="l00262"></a>00262 <span class="comment"></span>
<a name="l00263"></a>00263 <span class="comment">/** \brief Blow away the entire list. */</span>
<a name="l00264"></a>00264
<a name="l00265"></a>00265 <span class="keywordtype">void</span>
<a name="l00266"></a><a class="code" href="utils_8c.html#67215034f68b284935138064aa2f9cd0">00266</a> <a class="code" href="utils_8c.html#67215034f68b284935138064aa2f9cd0" title="Blow away the entire list.">dlist_delete_all</a> (DList *head)
<a name="l00267"></a>00267 {
<a name="l00268"></a>00268 DList *node;
<a name="l00269"></a>00269
<a name="l00270"></a>00270 <span class="keywordflow">while</span> (head)
<a name="l00271"></a>00271 {
<a name="l00272"></a>00272 node = head;
<a name="l00273"></a>00273 head = head-&gt;next;
<a name="l00274"></a>00274
<a name="l00275"></a>00275 <a class="code" href="avrclass_8c.html#0e597261f2fe0c7c5a56de97ecc38693" title="Decrements the reference count for the klass object.">class_unref</a> ((AvrClass *)node);
<a name="l00276"></a>00276 }
<a name="l00277"></a>00277 }
<a name="l00278"></a>00278 <span class="comment"></span>
<a name="l00279"></a>00279 <span class="comment">/** \brief Lookup an item in the list.</span>
<a name="l00280"></a>00280 <span class="comment"></span>
<a name="l00281"></a>00281 <span class="comment"> Walk the list pointed to by head and return a pointer to the data if</span>
<a name="l00282"></a>00282 <span class="comment"> found. If not found, return NULL. </span>
<a name="l00283"></a>00283 <span class="comment"></span>
<a name="l00284"></a>00284 <span class="comment"> \param head The head of the list to be iterated.</span>
<a name="l00285"></a>00285 <span class="comment"> \param data The data to be passed to the func when it is applied.</span>
<a name="l00286"></a>00286 <span class="comment"> \param cmp A function to be used for comparing the items.</span>
<a name="l00287"></a>00287 <span class="comment"></span>
<a name="l00288"></a>00288 <span class="comment"> \return A pointer to the data found, or NULL if not found. */</span>
<a name="l00289"></a>00289
<a name="l00290"></a>00290 AvrClass *
<a name="l00291"></a><a class="code" href="utils_8c.html#d8319271cd9c519c6e97f381739497a3">00291</a> <a class="code" href="utils_8c.html#d8319271cd9c519c6e97f381739497a3" title="Lookup an item in the list.">dlist_lookup</a> (DList *head, AvrClass *data, DListFP_Cmp cmp)
<a name="l00292"></a>00292 {
<a name="l00293"></a>00293 DList *node = head;
<a name="l00294"></a>00294
<a name="l00295"></a>00295 <span class="keywordflow">if</span> (cmp == NULL)
<a name="l00296"></a>00296 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"compare function not specified"</span>);
<a name="l00297"></a>00297
<a name="l00298"></a>00298 <span class="keywordflow">while</span> (node)
<a name="l00299"></a>00299 {
<a name="l00300"></a>00300 <span class="keywordflow">if</span> ((*cmp) (node-&gt;data, data) == 0)
<a name="l00301"></a>00301 <span class="keywordflow">return</span> node-&gt;data;
<a name="l00302"></a>00302
<a name="l00303"></a>00303 node = node-&gt;next;
<a name="l00304"></a>00304 }
<a name="l00305"></a>00305
<a name="l00306"></a>00306 <span class="comment">/* If we get here, no node was found, return NULL. */</span>
<a name="l00307"></a>00307
<a name="l00308"></a>00308 <span class="keywordflow">return</span> NULL;
<a name="l00309"></a>00309 }
<a name="l00310"></a>00310 <span class="comment"></span>
<a name="l00311"></a>00311 <span class="comment">/** \brief Extract the data from the head of the list.</span>
<a name="l00312"></a>00312 <span class="comment"></span>
<a name="l00313"></a>00313 <span class="comment"> Returns the data element for the head of the list. If the list is empty,</span>
<a name="l00314"></a>00314 <span class="comment"> return a NULL pointer.</span>
<a name="l00315"></a>00315 <span class="comment"></span>
<a name="l00316"></a>00316 <span class="comment"> \param head The head of the list.</span>
<a name="l00317"></a>00317 <span class="comment"></span>
<a name="l00318"></a>00318 <span class="comment"> \return A pointer to the data found, or NULL if not found. */</span>
<a name="l00319"></a>00319
<a name="l00320"></a>00320 AvrClass *
<a name="l00321"></a><a class="code" href="utils_8c.html#7c8dfedd93ef4bc0b91d4c1c45c86f0c">00321</a> <a class="code" href="utils_8c.html#7c8dfedd93ef4bc0b91d4c1c45c86f0c" title="Extract the data from the head of the list.">dlist_get_head_data</a> (DList *head)
<a name="l00322"></a>00322 {
<a name="l00323"></a>00323
<a name="l00324"></a>00324 <span class="keywordflow">if</span> (head == NULL)
<a name="l00325"></a>00325 {
<a name="l00326"></a>00326 <span class="keywordflow">return</span> NULL;
<a name="l00327"></a>00327 }
<a name="l00328"></a>00328
<a name="l00329"></a>00329 <span class="keywordflow">return</span> head-&gt;data;
<a name="l00330"></a>00330 }
<a name="l00331"></a>00331
<a name="l00332"></a>00332 <span class="comment">/* a simple node compare function for the iterator. */</span>
<a name="l00333"></a>00333
<a name="l00334"></a>00334 <span class="keyword">static</span> <span class="keywordtype">int</span>
<a name="l00335"></a>00335 dlist_iterator_cmp (AvrClass *n1, AvrClass *n2)
<a name="l00336"></a>00336 {
<a name="l00337"></a>00337 <span class="comment">/* Since this is only used in the iterator, we are guaranteed that it is</span>
<a name="l00338"></a>00338 <span class="comment"> safe to compare data pointers because both n1 and n2 came from the</span>
<a name="l00339"></a>00339 <span class="comment"> list. */</span>
<a name="l00340"></a>00340
<a name="l00341"></a>00341 <span class="keywordflow">return</span> (<span class="keywordtype">int</span>)(n1 - n2);
<a name="l00342"></a>00342 }
<a name="l00343"></a>00343 <span class="comment"></span>
<a name="l00344"></a>00344 <span class="comment">/** \brief Iterate over all elements of the list.</span>
<a name="l00345"></a>00345 <span class="comment"></span>
<a name="l00346"></a>00346 <span class="comment"> For each element, call the user supplied iterator function and pass it the</span>
<a name="l00347"></a>00347 <span class="comment"> node data and the user_data. If the iterator function return non-zero,</span>
<a name="l00348"></a>00348 <span class="comment"> remove the node from the list.</span>
<a name="l00349"></a>00349 <span class="comment"></span>
<a name="l00350"></a>00350 <span class="comment"> \param head The head of the list to be iterated.</span>
<a name="l00351"></a>00351 <span class="comment"> \param func The function to be applied.</span>
<a name="l00352"></a>00352 <span class="comment"> \param user_data The data to be passed to the func when it is applied.</span>
<a name="l00353"></a>00353 <span class="comment"></span>
<a name="l00354"></a>00354 <span class="comment"> \return A pointer to the head of the possibly modified list. */</span>
<a name="l00355"></a>00355
<a name="l00356"></a>00356 DList *
<a name="l00357"></a><a class="code" href="utils_8c.html#bbba7ec7eefce4bdb4543e1096021186">00357</a> <a class="code" href="utils_8c.html#bbba7ec7eefce4bdb4543e1096021186" title="Iterate over all elements of the list.">dlist_iterator</a> (DList *head, DListFP_Iter func, <span class="keywordtype">void</span> *user_data)
<a name="l00358"></a>00358 {
<a name="l00359"></a>00359 DList *node = head;
<a name="l00360"></a>00360
<a name="l00361"></a>00361 <span class="keywordflow">if</span> (func == NULL)
<a name="l00362"></a>00362 <a class="code" href="avrerror_8c.html#4f6ec50114a7d63093baecafe47d7f1a" title="Print an error message to stderr and terminate program.">avr_error</a> (<span class="stringliteral">"no iteration func supplied"</span>);
<a name="l00363"></a>00363
<a name="l00364"></a>00364 <span class="keywordflow">while</span> (node)
<a name="l00365"></a>00365 {
<a name="l00366"></a>00366 <span class="keywordflow">if</span> ((*func) (node-&gt;data, user_data))
<a name="l00367"></a>00367 {
<a name="l00368"></a>00368 <span class="comment">/* remove node */</span>
<a name="l00369"></a>00369 head = <a class="code" href="utils_8c.html#0be979713f40bde065ecf4c51b41fe0d" title="Conditionally delete a node from the list.">dlist_delete</a> (head, node-&gt;data, dlist_iterator_cmp);
<a name="l00370"></a>00370 }
<a name="l00371"></a>00371
<a name="l00372"></a>00372 node = node-&gt;next;
<a name="l00373"></a>00373 }
<a name="l00374"></a>00374
<a name="l00375"></a>00375 <span class="keywordflow">return</span> head;
<a name="l00376"></a>00376 }
</pre></div></div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,469 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>utils.c File Reference</h1>Utility functions. <a href="#_details">More...</a>
<p>
<p>
<a href="utils_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8c.html#5d306d06881ee5b68d679edec2e7fd75">str2ffmt</a> (char *str)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">uint8_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8c.html#eb8ce7ee7e6e35ee3ec8d3539bb52519">set_bit_in_byte</a> (uint8_t src, int bit, int val)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">uint16_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8c.html#4250710ef21e0fe21d15dcc6203e4298">set_bit_in_word</a> (uint16_t src, int bit, int val)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">uint64_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8c.html#d71e2db9144e1b1d539e1326cbdcbf04">get_program_time</a> (void)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">DList *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8c.html#2f451be088e616a1c94508c1312e99ed">dlist_add</a> (DList *head, AvrClass *data, DListFP_Cmp cmp)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">DList *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8c.html#46d7303de632a8f87f61f2bf555f1840">dlist_add_head</a> (DList *head, AvrClass *data)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">DList *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8c.html#0be979713f40bde065ecf4c51b41fe0d">dlist_delete</a> (DList *head, AvrClass *data, DListFP_Cmp cmp)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8c.html#67215034f68b284935138064aa2f9cd0">dlist_delete_all</a> (DList *head)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">AvrClass *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8c.html#d8319271cd9c519c6e97f381739497a3">dlist_lookup</a> (DList *head, AvrClass *data, DListFP_Cmp cmp)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">AvrClass *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8c.html#7c8dfedd93ef4bc0b91d4c1c45c86f0c">dlist_get_head_data</a> (DList *head)</td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">DList *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="utils_8c.html#bbba7ec7eefce4bdb4543e1096021186">dlist_iterator</a> (DList *head, DListFP_Iter func, void *user_data)</td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Utility functions.
<p>
This module provides general purpose utilities.
<p>Definition in file <a class="el" href="utils_8c-source.html">utils.c</a>.</p>
<hr><h2>Function Documentation</h2>
<a class="anchor" name="5d306d06881ee5b68d679edec2e7fd75"></a><!-- doxytag: member="utils.c::str2ffmt" ref="5d306d06881ee5b68d679edec2e7fd75" args="(char *str)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int str2ffmt </td>
<td>(</td>
<td class="paramtype">char *&nbsp;</td>
<td class="paramname"> <em>str</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Utility function to convert a string to a FileFormatType code.
<p>
<p>Definition at line <a class="el" href="utils_8c-source.html#l00050">50</a> of file <a class="el" href="utils_8c-source.html">utils.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="eb8ce7ee7e6e35ee3ec8d3539bb52519"></a><!-- doxytag: member="utils.c::set_bit_in_byte" ref="eb8ce7ee7e6e35ee3ec8d3539bb52519" args="(uint8_t src, int bit, int val)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint8_t set_bit_in_byte </td>
<td>(</td>
<td class="paramtype">uint8_t&nbsp;</td>
<td class="paramname"> <em>src</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>bit</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>val</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Set a bit in src to 1 if val != 0, clears bit if val == 0.
<p>
</div>
</div><p>
<a class="anchor" name="4250710ef21e0fe21d15dcc6203e4298"></a><!-- doxytag: member="utils.c::set_bit_in_word" ref="4250710ef21e0fe21d15dcc6203e4298" args="(uint16_t src, int bit, int val)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint16_t set_bit_in_word </td>
<td>(</td>
<td class="paramtype">uint16_t&nbsp;</td>
<td class="paramname"> <em>src</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>bit</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int&nbsp;</td>
<td class="paramname"> <em>val</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Set a bit in src to 1 if val != 0, clears bit if val == 0.
<p>
</div>
</div><p>
<a class="anchor" name="d71e2db9144e1b1d539e1326cbdcbf04"></a><!-- doxytag: member="utils.c::get_program_time" ref="d71e2db9144e1b1d539e1326cbdcbf04" args="(void)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">uint64_t get_program_time </td>
<td>(</td>
<td class="paramtype">void&nbsp;</td>
<td class="paramname"> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Return the number of milliseconds of elapsed program time.
<p>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>an unsigned 64 bit number. Time zero is not well defined, so only time differences should be used. </dd></dl>
<p>Definition at line <a class="el" href="utils_8c-source.html#l00076">76</a> of file <a class="el" href="utils_8c-source.html">utils.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l01140">avr_core_run()</a>.</p>
</div>
</div><p>
<a class="anchor" name="2f451be088e616a1c94508c1312e99ed"></a><!-- doxytag: member="utils.c::dlist_add" ref="2f451be088e616a1c94508c1312e99ed" args="(DList *head, AvrClass *data, DListFP_Cmp cmp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">DList* dlist_add </td>
<td>(</td>
<td class="paramtype">DList *&nbsp;</td>
<td class="paramname"> <em>head</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">AvrClass *&nbsp;</td>
<td class="paramname"> <em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">DListFP_Cmp&nbsp;</td>
<td class="paramname"> <em>cmp</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Add a new node to the end of the list.
<p>
If cmp argument is not NULL, use cmp() to see if node already exists and don't add node if it exists.<p>
It is the responsibility of this function to unref data if not added.
<p>Definition at line <a class="el" href="utils_8c-source.html#l00159">159</a> of file <a class="el" href="utils_8c-source.html">utils.c</a>.</p>
<p>References <a class="el" href="avrclass_8c-source.html#l00120">class_unref()</a>.</p>
</div>
</div><p>
<a class="anchor" name="46d7303de632a8f87f61f2bf555f1840"></a><!-- doxytag: member="utils.c::dlist_add_head" ref="46d7303de632a8f87f61f2bf555f1840" args="(DList *head, AvrClass *data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">DList* dlist_add_head </td>
<td>(</td>
<td class="paramtype">DList *&nbsp;</td>
<td class="paramname"> <em>head</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">AvrClass *&nbsp;</td>
<td class="paramname"> <em>data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Add a new node at the head of the list.
<p>
<p>Definition at line <a class="el" href="utils_8c-source.html#l00196">196</a> of file <a class="el" href="utils_8c-source.html">utils.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="0be979713f40bde065ecf4c51b41fe0d"></a><!-- doxytag: member="utils.c::dlist_delete" ref="0be979713f40bde065ecf4c51b41fe0d" args="(DList *head, AvrClass *data, DListFP_Cmp cmp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">DList* dlist_delete </td>
<td>(</td>
<td class="paramtype">DList *&nbsp;</td>
<td class="paramname"> <em>head</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">AvrClass *&nbsp;</td>
<td class="paramname"> <em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">DListFP_Cmp&nbsp;</td>
<td class="paramname"> <em>cmp</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Conditionally delete a node from the list.
<p>
Delete a node from the list if the node's data matches the specified data. Returns the head of the modified list.
<p>Definition at line <a class="el" href="utils_8c-source.html#l00215">215</a> of file <a class="el" href="utils_8c-source.html">utils.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="avrclass_8c-source.html#l00120">class_unref()</a>.</p>
<p>Referenced by <a class="el" href="utils_8c-source.html#l00357">dlist_iterator()</a>.</p>
</div>
</div><p>
<a class="anchor" name="67215034f68b284935138064aa2f9cd0"></a><!-- doxytag: member="utils.c::dlist_delete_all" ref="67215034f68b284935138064aa2f9cd0" args="(DList *head)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void dlist_delete_all </td>
<td>(</td>
<td class="paramtype">DList *&nbsp;</td>
<td class="paramname"> <em>head</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Blow away the entire list.
<p>
<p>Definition at line <a class="el" href="utils_8c-source.html#l00266">266</a> of file <a class="el" href="utils_8c-source.html">utils.c</a>.</p>
<p>References <a class="el" href="avrclass_8c-source.html#l00120">class_unref()</a>.</p>
<p>Referenced by <a class="el" href="avrcore_8c-source.html#l00539">avr_core_destroy()</a>.</p>
</div>
</div><p>
<a class="anchor" name="d8319271cd9c519c6e97f381739497a3"></a><!-- doxytag: member="utils.c::dlist_lookup" ref="d8319271cd9c519c6e97f381739497a3" args="(DList *head, AvrClass *data, DListFP_Cmp cmp)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">AvrClass* dlist_lookup </td>
<td>(</td>
<td class="paramtype">DList *&nbsp;</td>
<td class="paramname"> <em>head</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">AvrClass *&nbsp;</td>
<td class="paramname"> <em>data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">DListFP_Cmp&nbsp;</td>
<td class="paramname"> <em>cmp</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Lookup an item in the list.
<p>
Walk the list pointed to by head and return a pointer to the data if found. If not found, return NULL.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>head</em>&nbsp;</td><td>The head of the list to be iterated. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>data</em>&nbsp;</td><td>The data to be passed to the func when it is applied. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>cmp</em>&nbsp;</td><td>A function to be used for comparing the items.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>A pointer to the data found, or NULL if not found. </dd></dl>
<p>Definition at line <a class="el" href="utils_8c-source.html#l00291">291</a> of file <a class="el" href="utils_8c-source.html">utils.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>.</p>
<p>Referenced by <a class="el" href="memory_8c-source.html#l00169">mem_get_vdevice_by_name()</a>.</p>
</div>
</div><p>
<a class="anchor" name="7c8dfedd93ef4bc0b91d4c1c45c86f0c"></a><!-- doxytag: member="utils.c::dlist_get_head_data" ref="7c8dfedd93ef4bc0b91d4c1c45c86f0c" args="(DList *head)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">AvrClass* dlist_get_head_data </td>
<td>(</td>
<td class="paramtype">DList *&nbsp;</td>
<td class="paramname"> <em>head</em> </td>
<td>&nbsp;)&nbsp;</td>
<td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Extract the data from the head of the list.
<p>
Returns the data element for the head of the list. If the list is empty, return a NULL pointer.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>head</em>&nbsp;</td><td>The head of the list.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>A pointer to the data found, or NULL if not found. </dd></dl>
<p>Definition at line <a class="el" href="utils_8c-source.html#l00321">321</a> of file <a class="el" href="utils_8c-source.html">utils.c</a>.</p>
</div>
</div><p>
<a class="anchor" name="bbba7ec7eefce4bdb4543e1096021186"></a><!-- doxytag: member="utils.c::dlist_iterator" ref="bbba7ec7eefce4bdb4543e1096021186" args="(DList *head, DListFP_Iter func, void *user_data)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">DList* dlist_iterator </td>
<td>(</td>
<td class="paramtype">DList *&nbsp;</td>
<td class="paramname"> <em>head</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">DListFP_Iter&nbsp;</td>
<td class="paramname"> <em>func</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">void *&nbsp;</td>
<td class="paramname"> <em>user_data</em></td><td>&nbsp;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td><td width="100%"></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Iterate over all elements of the list.
<p>
For each element, call the user supplied iterator function and pass it the node data and the user_data. If the iterator function return non-zero, remove the node from the list.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>head</em>&nbsp;</td><td>The head of the list to be iterated. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>func</em>&nbsp;</td><td>The function to be applied. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>user_data</em>&nbsp;</td><td>The data to be passed to the func when it is applied.</td></tr>
</table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>A pointer to the head of the possibly modified list. </dd></dl>
<p>Definition at line <a class="el" href="utils_8c-source.html#l00357">357</a> of file <a class="el" href="utils_8c-source.html">utils.c</a>.</p>
<p>References <a class="el" href="avrerror_8c-source.html#l00050">avr_error</a>, and <a class="el" href="utils_8c-source.html#l00215">dlist_delete()</a>.</p>
</div>
</div><p>
</div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>

View file

@ -0,0 +1,28 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Main Page</title>
<link href="dox.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#cfcfcf">
<!-- Generated by Doxygen 1.5.5 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
<li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1><a class="anchor" name="virtual_devs">Virtual Devices </a></h1><p>
<b>FIXME:</b> empty place holder </div>
<hr width="80%">
<p><center>Automatically generated by Doxygen 1.5.5 on 7 Nov 2008.</center></p>
</body>
</html>