summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COPYING339
-rw-r--r--TODO1
-rw-r--r--avr/background.c16
-rw-r--r--avr/cli.c13
-rw-r--r--avr/cli_readline.c3
-rw-r--r--avr/cmd_boot.c8
-rw-r--r--avr/cmd_date.c2
-rw-r--r--avr/cmd_fat.c49
-rw-r--r--avr/cmd_gpio.c6
-rw-r--r--avr/cmd_help.c8
-rw-r--r--avr/cmd_mem.c2
-rw-r--r--avr/cmd_misc.c3
-rw-r--r--avr/cmd_sd.c6
-rw-r--r--avr/command.c9
-rw-r--r--avr/command_tbl.c7
-rw-r--r--avr/con-utils.c5
-rw-r--r--avr/debug.c7
-rw-r--r--avr/env.c7
-rw-r--r--avr/getopt-min.c9
-rw-r--r--avr/gpio.c7
-rw-r--r--avr/i2c.c8
-rw-r--r--avr/main.c4
-rw-r--r--avr/pcf8583.c6
-rw-r--r--avr/print-utils.c6
-rw-r--r--avr/serial.c9
-rw-r--r--avr/timer.c10
-rw-r--r--avr/xmalloc.c11
-rw-r--r--avr/z180-serv.c8
-rw-r--r--avr/z180-stamp-avr.c591
-rw-r--r--avr/z80-if.c7
-rw-r--r--include/background.h7
-rw-r--r--include/cli.h12
-rw-r--r--include/cli_readline.h3
-rw-r--r--include/cmd_mem.h7
-rw-r--r--include/command.h16
-rw-r--r--include/common.h8
-rw-r--r--include/con-utils.h14
-rw-r--r--include/config.h6
-rw-r--r--include/crc.h9
-rw-r--r--include/debug.h14
-rw-r--r--include/env.h9
-rw-r--r--include/ffconf.h1
-rw-r--r--include/getopt-min.h7
-rw-r--r--include/gpio.h7
-rw-r--r--include/i2c.h2
-rw-r--r--include/print-utils.h6
-rw-r--r--include/ring.h7
-rw-r--r--include/rtc.h5
-rw-r--r--include/serial.h6
-rw-r--r--include/spi.h5
-rw-r--r--include/timer.h9
-rw-r--r--include/z180-serv.h6
-rw-r--r--include/z80-if.h5
-rw-r--r--stm32/debug.h5
-rw-r--r--stm32/serial.c5
-rw-r--r--stm32/serial.h6
-rw-r--r--stm32/z180-stamp-stm32.c71
-rw-r--r--stm32/z80-if.c66
-rw-r--r--stm32/z80-if.h5
59 files changed, 774 insertions, 722 deletions
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..d159169
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser General
+Public License instead of this License.
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..7b8d92f
--- /dev/null
+++ b/TODO
@@ -0,0 +1 @@
+TODO: eliminate xmalloc
diff --git a/avr/background.c b/avr/background.c
index 0e1ca40..9c8b5a6 100644
--- a/avr/background.c
+++ b/avr/background.c
@@ -1,10 +1,16 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#include "common.h"
#include "background.h"
#define BG_FUNC_MAX 5
-static struct {
+static struct {
bg_func fct;
int param;
} func_tab[BG_FUNC_MAX];
@@ -13,7 +19,7 @@ static int_fast8_t fcount;
int bg_register(bg_func f, int initval)
{
- if (fcount < BG_FUNC_MAX) {
+ if (fcount < BG_FUNC_MAX) {
func_tab[fcount].fct = f;
func_tab[fcount].param = initval;
return ++fcount - 1;
@@ -27,7 +33,7 @@ int bg_setstat(int handle, int val)
func_tab[handle].param = val;
return 1;
}
-
+
return 0;
}
@@ -44,7 +50,7 @@ int bg_getstat(int handle)
void bg_shed(void)
{
static int_fast8_t current;
-
+
if (func_tab[current].fct) {
int v = func_tab[current].fct(func_tab[current].param);
func_tab[current].param = v;
@@ -52,5 +58,3 @@ void bg_shed(void)
if (++current >= fcount)
current = 0;
}
-
-
diff --git a/avr/cli.c b/avr/cli.c
index 046859c..52c85db 100644
--- a/avr/cli.c
+++ b/avr/cli.c
@@ -1,3 +1,16 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * Add to readline cmdline-editing by
+ * (C) Copyright 2005
+ * JinHua Luo, GuangDong Linux Center, <luo.jinhua@gd-linux.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#include "common.h"
#include <string.h>
diff --git a/avr/cli_readline.c b/avr/cli_readline.c
index 1dbc73b..04d32b1 100644
--- a/avr/cli_readline.c
+++ b/avr/cli_readline.c
@@ -1,4 +1,6 @@
/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
* (C) Copyright 2000
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
@@ -591,4 +593,3 @@ int cli_readline(const FLASH char *const prompt)
return cli_readline_into_buffer(prompt, console_buffer);
}
-
diff --git a/avr/cmd_boot.c b/avr/cmd_boot.c
index 4775b6e..301f4f5 100644
--- a/avr/cmd_boot.c
+++ b/avr/cmd_boot.c
@@ -1,3 +1,11 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * (C) Copyright 2000-2003
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
/*
* Misc boot support
diff --git a/avr/cmd_date.c b/avr/cmd_date.c
index 3beebee..efba858 100644
--- a/avr/cmd_date.c
+++ b/avr/cmd_date.c
@@ -1,4 +1,6 @@
/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
* (C) Copyright 2001
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
diff --git a/avr/cmd_fat.c b/avr/cmd_fat.c
index df2ae69..8ed7ae3 100644
--- a/avr/cmd_fat.c
+++ b/avr/cmd_fat.c
@@ -1,3 +1,13 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+/*
+ * FAT filesystem commands
+ */
+
#include "common.h"
#include <stdlib.h>
#include <string.h>
@@ -290,6 +300,39 @@ command_ret_t do_fat_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
return CMD_RET_SUCCESS;
}
+static
+FRESULT mkpath(TCHAR *path)
+{
+ /* TODO: */
+ (void) path;
+#if 0
+ FILINFO fd
+ TCHAR *p, *q;
+ FRESULT ret;
+
+#if _USE_LFN
+ fd.lfname = 0;
+#endif
+
+
+ res = f_stat (path, &fd)
+
+ p = strchr(path, ':');
+ if (p == NULL || *++p == '\0' || *p++ != '/')
+ return FR_OK;
+
+ while ((q = strchr(p, '/')) != NULL) {
+ *q = '\0';
+ ret = f_mkdir(path);
+ *q = '/';
+ if (ret != FR_OK && ret != FR_EXIST)
+ return ret;
+ p = q + 1;
+ }
+#endif
+
+ return FR_OK;
+}
/*
* fatread/write - load binary file to/from a dos filesystem
@@ -343,6 +386,12 @@ command_ret_t do_fat_rw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
}
res = f_mount(FatFs, argv[1], 0);
+
+ if (!res) {
+ if (dowrite) {
+ res = mkpath(argv[1]);
+ }
+ }
if (!res) {
res = f_open(&File, argv[1], dowrite ? FA_WRITE | FA_CREATE_ALWAYS
: FA_READ );
diff --git a/avr/cmd_gpio.c b/avr/cmd_gpio.c
index f448e36..e0d9b06 100644
--- a/avr/cmd_gpio.c
+++ b/avr/cmd_gpio.c
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#include "common.h"
#include <stdlib.h>
#include <string.h>
diff --git a/avr/cmd_help.c b/avr/cmd_help.c
index 8f81b2d..010339d 100644
--- a/avr/cmd_help.c
+++ b/avr/cmd_help.c
@@ -1,3 +1,11 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
#include "common.h"
#include "command.h"
diff --git a/avr/cmd_mem.c b/avr/cmd_mem.c
index 0bc5742..20a4412 100644
--- a/avr/cmd_mem.c
+++ b/avr/cmd_mem.c
@@ -1,4 +1,6 @@
/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
* (C) Copyright 2000
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
diff --git a/avr/cmd_misc.c b/avr/cmd_misc.c
index 315b959..b29aedd 100644
--- a/avr/cmd_misc.c
+++ b/avr/cmd_misc.c
@@ -1,4 +1,6 @@
/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
* Copyright 2000-2009
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
@@ -88,4 +90,3 @@ command_ret_t do_sleep(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
return CMD_RET_SUCCESS;
}
-
diff --git a/avr/cmd_sd.c b/avr/cmd_sd.c
index 46dbcfd..6b75d6e 100644
--- a/avr/cmd_sd.c
+++ b/avr/cmd_sd.c
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#include "common.h"
#include <stdlib.h>
diff --git a/avr/command.c b/avr/command.c
index c080527..b6fa418 100644
--- a/avr/command.c
+++ b/avr/command.c
@@ -1,4 +1,13 @@
/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+/*
* Command Processor Table
*/
diff --git a/avr/command_tbl.c b/avr/command_tbl.c
index e5c6567..b70c711 100644
--- a/avr/command_tbl.c
+++ b/avr/command_tbl.c
@@ -1,10 +1,13 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
#include "common.h"
-
#include "command.h"
#include "cmd_mem.h"
-
extern command_ret_t do_help(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_echo(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_sleep(cmd_tbl_t *, int, int, char * const []);
diff --git a/avr/con-utils.c b/avr/con-utils.c
index f4023ff..f20dbfe 100644
--- a/avr/con-utils.c
+++ b/avr/con-utils.c
@@ -1,3 +1,8 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
#include <string.h>
#include "common.h"
diff --git a/avr/debug.c b/avr/debug.c
index 796647b..5096d59 100644
--- a/avr/debug.c
+++ b/avr/debug.c
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#include "common.h"
#include <stdlib.h>
#include <string.h>
@@ -7,6 +13,7 @@
#include "command.h"
#include "print-utils.h"
#include "debug.h"
+
/*
* Debugging
*/
diff --git a/avr/env.c b/avr/env.c
index 017053c..7be7d03 100644
--- a/avr/env.c
+++ b/avr/env.c
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#include "common.h"
#include <string.h>
#include <stdlib.h>
@@ -8,7 +14,6 @@
#include "xmalloc.h"
#include "crc.h"
#include "command.h"
-
#include "env.h"
diff --git a/avr/getopt-min.c b/avr/getopt-min.c
index 8e5dd6c..f5ad912 100644
--- a/avr/getopt-min.c
+++ b/avr/getopt-min.c
@@ -1,6 +1,3 @@
-#include "common.h"
-
-
/*
* Minimum getopt, original version was:
*/
@@ -13,7 +10,8 @@
*/
/* $Id: getopt.c,v 1.2 1992/12/07 11:12:52 nickc Exp $ */
-#include <string.h>
+#include "common.h" /* definition of FLASH */
+#include <string.h>
int optind = 1; /* next argv[] index */
char *optarg; /* option parameter if any */
@@ -40,7 +38,7 @@ getopt( /* returns letter, '?', EOF */
)
return -1;
}
-
+
c = argv[optind][sp]; /* option letter */
osp = sp++; /* get ready for next letter */
@@ -72,4 +70,3 @@ getopt( /* returns letter, '?', EOF */
return c;
}
-
diff --git a/avr/gpio.c b/avr/gpio.c
index 31dbc21..73e9c39 100644
--- a/avr/gpio.c
+++ b/avr/gpio.c
@@ -1,10 +1,15 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#include "common.h"
#include <util/atomic.h>
#include <limits.h>
#include "debug.h"
#include "gpio.h"
-
/*
Pin Name Port Timer Mode max div max div min f [Hz]
diff --git a/avr/i2c.c b/avr/i2c.c
index d181ff6..ae2f8da 100644
--- a/avr/i2c.c
+++ b/avr/i2c.c
@@ -1,3 +1,8 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
/*
* I2C (TWI) master interface.
@@ -371,6 +376,3 @@ int i2c_read(uint8_t chip, unsigned int addr, uint_fast8_t alen,
return !((rc & (XMIT_DONE|DATA_ACK)) == (XMIT_DONE|DATA_ACK));
}
-
-
-
diff --git a/avr/main.c b/avr/main.c
index f601736..8bffef9 100644
--- a/avr/main.c
+++ b/avr/main.c
@@ -1,9 +1,11 @@
/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include "common.h"
-
#include <avr/interrupt.h>
#include <stdlib.h>
#include <stdio.h>
diff --git a/avr/pcf8583.c b/avr/pcf8583.c
index 7e9d749..169e4e9 100644
--- a/avr/pcf8583.c
+++ b/avr/pcf8583.c
@@ -1,4 +1,10 @@
/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+/*
* Date & Time support for Philips PCF8583 RTC
*/
diff --git a/avr/print-utils.c b/avr/print-utils.c
index 4205a90..3f48620 100644
--- a/avr/print-utils.c
+++ b/avr/print-utils.c
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#include "common.h"
#include <stdio.h>
#include <ctype.h>
diff --git a/avr/serial.c b/avr/serial.c
index e897c84..adbc3c4 100644
--- a/avr/serial.c
+++ b/avr/serial.c
@@ -1,4 +1,7 @@
/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <avr/io.h>
@@ -12,7 +15,7 @@
static int _write(char c, FILE *stream);
-static FILE mystdout = FDEV_SETUP_STREAM(_write,
+static FILE mystdout = FDEV_SETUP_STREAM(_write,
NULL, _FDEV_SETUP_WRITE);
@@ -24,7 +27,7 @@ static FILE mystdout = FDEV_SETUP_STREAM(_write,
#endif
#if ((BUFFER_SIZE) > 256)
-# error: BUFFER_SIZE
+# error: BUFFER_SIZE
#endif
struct ring rx_ring;
@@ -119,5 +122,3 @@ uint_fast8_t serial_tstc(void)
{
return !ring_is_empty(&rx_ring);
}
-
-
diff --git a/avr/timer.c b/avr/timer.c
index e222e68..f45f267 100644
--- a/avr/timer.c
+++ b/avr/timer.c
@@ -1,4 +1,7 @@
/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include "common.h"
@@ -12,10 +15,9 @@
static volatile
uint32_t timestamp;
-/*---------------------------------------------------------*/
-/* 1000Hz timer interrupt generated by OC3A */
-/*---------------------------------------------------------*/
-
+/*
+ * 1000Hz timer interrupt generated by OC3A
+ */
ISR(TIMER3_COMPA_vect)
{
static int_fast8_t tick_10ms;
diff --git a/avr/xmalloc.c b/avr/xmalloc.c
index 9bf2684..d42d5c9 100644
--- a/avr/xmalloc.c
+++ b/avr/xmalloc.c
@@ -1,5 +1,10 @@
-#include <stdlib.h>
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+#include <stdlib.h>
#include "debug.h"
#include "xmalloc.h"
@@ -11,7 +16,7 @@ void* xmalloc(size_t size)
if (p == NULL)
debug("*** Out of memory!\n");
-
+
return p;
}
@@ -22,6 +27,6 @@ void* xrealloc(void *p, size_t size)
if (p == NULL)
debug("*** Out of memory!\n");
-
+
return p;
}
diff --git a/avr/z180-serv.c b/avr/z180-serv.c
index e3bca16..e0b763f 100644
--- a/avr/z180-serv.c
+++ b/avr/z180-serv.c
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#include "common.h"
#include <util/atomic.h>
@@ -7,8 +13,6 @@
#include "debug.h"
#include "z180-serv.h"
-
-
/*--------------------------------------------------------------------------*/
diff --git a/avr/z180-stamp-avr.c b/avr/z180-stamp-avr.c
deleted file mode 100644
index e6edb33..0000000
--- a/avr/z180-stamp-avr.c
+++ /dev/null
@@ -1,591 +0,0 @@
-/*
- */
-
-
-#include <avr/io.h>
-//#include <avr/power.h>
-//#include <avr/pgmspace.h>
-#include <avr/interrupt.h>
-//#include <util/atomic.h>
-//#include <avr/sleep.h>
-//#include <string.h>
-
-#include <stdio.h>
-
-
-#include "debug.h"
-#include "serial.h"
-#include "z80-if.h"
-
-#define const const __flash
-#include "../z180/hdrom.h"
-#undef const
-
-#define FLASH __flash
-//#define FLASH
-
-#define ESCCHAR ('^'-0x40)
-
-#define S_10MS_TO (1<<0)
-
-
-volatile int_fast8_t timeout_1s;
-//volatile uint_least8_t Stat;
-#define Stat GPIOR0
-
-unsigned int to_counter;
-
-/****************************************************************/
-
-#define P_ADL PORTA
-#define P_ADH PORTC
-#define P_ADB PORTE
-#define PIN_ADB PINE
-
-#define ADB_WIDTH 3
-#define ADB_SHIFT 2
-//#define ADB_PORT GPIOE
-
-#define MASK(n) ((1<<(n))-1)
-#define SMASK(w,s) (MASK(w) << (s))
-
-typedef union {
- uint32_t l;
- uint16_t w[2];
- uint8_t b[4];
-} addr_t;
-
-
-
-/*--------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------*/
-/* 1000Hz timer interrupt generated by OC1A */
-/*---------------------------------------------------------*/
-
-ISR(TIMER1_COMPA_vect)
-{
- static int_fast8_t tick_10ms;
-// static int_fast16_t count_ms;
-
- int_fast8_t i;
-
-
- i = tick_10ms + 1;
- if (i == 10) {
- i = 0;
- Stat |= S_10MS_TO;
-
- /* Drive timer procedure of low level disk I/O module */
- //disk_timerproc();
- }
- tick_10ms = i;
-
-#if 0
- count_ms++;
- if (count_ms == 1000) {
- count_ms = 0;
-
- i = timeout_1s;
- if (i)
- timeout_1s = i - 1;
- }
-#endif
-}
-
-
-/*--------------------------------------------------------------------------*/
-
-static uint32_t z80_sram_cmp(uint32_t addr, uint32_t length, uint8_t wval, int inc)
-{
- uint8_t rval;
- int_fast8_t errors = 0;
-
- DBG_P(1, "SRAM: Check 0x%.5lx byte... ", length);
- while (length--) {
- if ((rval = z80_read(addr)) != wval) {
- if (errors == 0) {
- DBG_P(1, "\nSRAM: Address W R\n" \
- " ------------------\n");
- }
- errors++;
- if (errors > 20) {
- DBG_P(1, " ...\n");
- break;
- }
- DBG_P(1, " 0x%.5lx 0x%.2x 0x%.2x\n", addr, wval, rval);
- }
- addr++;
- wval += inc;
- }
- DBG_P(1, "Done.\n");
-
- return addr;
-}
-
-static void z80_sram_fill(uint32_t addr, uint32_t length, uint8_t startval, int inc)
-{
- printf("SRAM: Write 0x%.5lx byte... ", length);
- while (length--) {
- z80_write(addr, startval);
- ++addr;
- startval += inc;
- }
- printf("Done.\n");
-}
-
-
-#if 0
-void z80_sram_fill_string(uint32_t addr, int length, const char *text)
-{
- char c;
- const char *p = text;
-
- while (length--) {
- z80_write(addr++, c = *p++);
- if (c == 0)
- p = text;
- }
-}
-
-
-uint32_t z80_sram_cmp_string(uint32_t addr, int length, const char *text)
-{
- char c;
- const char *p = text;
-
- while (length--) {
- c = *p++;
- if (z80_read(addr) != c)
- break;
- ++addr;
- if (c == 0)
- p = text;
- }
- return addr;
-}
-
-const char * const qbfox = "Zhe quick brown fox jumps over the lazy dog!";
-const char * const qbcat = "Zhe quick brown fox jumps over the lazy cat!";
-
-#endif
-
-uint8_t z80_get_byte(uint32_t adr)
-{
- uint8_t data;
-
- z80_request_bus();
- data = z80_read(adr),
- z80_release_bus();
-
- return data;
-}
-
-
-/*--------------------------------------------------------------------------*/
-
-static void do_10ms(void)
-{
- if (to_counter)
- to_counter--;
-}
-
-/*--------------------------------------------------------------------------*/
-
-struct msg_item {
- uint8_t fct;
- uint8_t sub_min, sub_max;
- void (*func)(uint8_t, int, uint8_t *);
-};
-
-uint32_t msg_to_addr(uint8_t *msg)
-{
- union {
- uint32_t as32;
- uint8_t as8[4];
- } addr;
-
- addr.as8[0] = msg[0];
- addr.as8[1] = msg[1];
- addr.as8[2] = msg[2];
- addr.as8[3] = 0;
-
- return addr.as32;
-}
-
-void do_msg_ini_msgfifo(uint8_t subf, int len, uint8_t * msg)
-{
- (void)subf; (void)len;
-
- z80_init_msg_fifo(msg_to_addr(msg));
-}
-
-
-void do_msg_ini_memfifo(uint8_t subf, int len, uint8_t * msg)
-{
- (void)len;
-
- z80_memfifo_init(subf - 1, msg_to_addr(msg));
-}
-
-
-void do_msg_char_out(uint8_t subf, int len, uint8_t * msg)
-{
- (void)subf;
-
- while (len--)
- putchar(*msg++);
-}
-
-
-const FLASH struct msg_item z80_messages[] =
-{
- { 0, /* fct nr. */
- 0, 0, /* sub fct nr. from, to */
- do_msg_ini_msgfifo},
- { 0,
- 1, 2,
- do_msg_ini_memfifo},
- { 1,
- 1, 1,
- do_msg_char_out},
- { 0xff, /* end mark */
- 0, 0,
- 0},
-
-};
-
-
-
-
-void do_message(int len, uint8_t *msg)
-{
- uint8_t fct, sub_fct;
- int_fast8_t i = 0;
-
- if (len >= 2) {
- fct = *msg++;
- sub_fct = *msg++;
- len -= 2;
-
- while (fct != z80_messages[i].fct)
- ++i;
-
- if (z80_messages[i].fct == 0xff) {
- DBG_P(1, "do_message: Unknown function: %i, %i\n",
- fct, sub_fct);
- return; /* TODO: unknown message # */
- }
-
- while (fct == z80_messages[i].fct) {
- if (sub_fct >= z80_messages[i].sub_min && sub_fct <= z80_messages[i].sub_max )
- break;
- ++i;
- }
-
- if (z80_messages[i].fct != fct) {
- DBG_P(1, "do_message: Unknown sub function: %i, %i\n",
- fct, sub_fct);
- return; /* TODO: unknown message sub# */
- }
-
- (z80_messages[i].func)(sub_fct, len, msg);
-
-
- } else {
- /* TODO: error */
- DBG_P(1, "do_message: to few arguments (%i); this shouldn't happen!\n", len);
- }
-}
-
-
-
-#define CTRBUF_LEN 256
-
-void check_msg_fifo(void)
-{
- int ch;
- static int_fast8_t state;
- static int msglen,idx;
- static uint8_t buffer[CTRBUF_LEN];
-
- while (state != 3 && (ch = z80_msg_fifo_getc()) >= 0) {
- switch (state) {
- case 0: /* wait for start of message */
- if (ch == 0x81) {
- msglen = 0;
- idx = 0;
- state = 1;
- }
- break;
- case 1: /* get msg len */
- if (ch > 0 && ch <= CTRBUF_LEN) {
- msglen = ch;
- state = 2;
- } else
- state = 0;
- break;
- case 2: /* get message */
- buffer[idx++] = ch;
- if (idx == msglen)
- state = 3;
- break;
- }
- }
-
- if (state == 3) {
- do_message(msglen, buffer);
- state = 0;
- }
-}
-
-
-/*--------------------------------------------------------------------------*/
-
-void dump_mem(const __flash uint8_t *addr, uint32_t len)
-{
- DBG_P(1, "hdrom dump:");
- while (len) {
- DBG_P(1, "\n %.5x:", addr);
- for (unsigned i = 0; i<16; i++)
- DBG_P(1, " %.2x", *addr++);
- len -= len > 16 ? 16 : len;
- }
- DBG_P(1, "\n");
-}
-
-/*--------------------------------------------------------------------------*/
-
-void z80_load_mem(void)
-{
- unsigned sec = 0;
- uint32_t sec_base = hdrom_start;
-
- DBG_P(1, "Loading z80 memory... \n");
-
- while (sec < hdrom_sections) {
- DBG_P(2, " From: 0x%.5lX to: 0x%.5lX (%5li bytes)\n",
- hdrom_address[sec],
- hdrom_address[sec]+hdrom_length_of_sections[sec] - 1,
- hdrom_length_of_sections[sec]);
-
- z80_write_block((const __flash unsigned char *) &hdrom[sec_base], /* src */
- hdrom_address[sec], /* dest */
- hdrom_length_of_sections[sec]); /* len */
- sec_base+=hdrom_length_of_sections[sec];
- sec++;
- }
-}
-
-/*--------------------------------------------------------------------------*/
-
-void z80_dump_mem(uint32_t addr, uint32_t len)
-{
- DBG_P(1, "Memory dump:");
- while (len) {
- DBG_P(1, "\n %.5lx:", addr);
- for (unsigned i = 0; i<16; i++)
- DBG_P(1, " %.2x", z80_read(addr++));
- len -= len > 16 ? 16 : len;
- }
- DBG_P(1, "\n");
-}
-
-/*--------------------------------------------------------------------------*/
-
-void setup_rtc(void)
-{
- /* TODO: */
-}
-
-void setup_avr(void)
-{
- /* WD */
-
- /* CPU */
-
- /* Disable JTAG Interface regardless of the JTAGEN fuse setting. */
- MCUCR = _BV(JTD);
- MCUCR = _BV(JTD);
-
- /* disable unused periphels */
- PRR0 = _BV(PRTIM2) | _BV(PRTIM0) | _BV(PRADC);
- PRR1 = _BV(PRTIM5) | _BV(PRTIM4) | _BV(PRTIM3) |
- _BV(PRUSART3) | _BV(PRUSART2) | _BV(PRUSART1);
-
- /* disable analog comparator */
- ACSR = _BV(ACD);
- /* Ports */
-
- /* Clock */
- CLKPR = _BV(CLKPCE);
- CLKPR = 0;
-
- /* Timer */
-
- OCR1A = F_CPU / 8 / 1000 - 1; // Timer1: 1000Hz interval (OC1A)
- TCCR1B = 0b00001010;
- TIMSK1 = _BV(OCIE1A); // Enable TC1.oca interrupt
-}
-
-const __flash uint8_t iniprog[] = {
- 0xAF, // xor a
- 0xED, 0x39, 0x36, // out0 (rcr),a ;disable DRAM refresh
- 0x3E, 0x30, // ld a,030h
- 0xED, 0x39, 0x32 //out0 (dcntl),a ;0 mem, max i/0 wait states
-};
-
-const __flash uint8_t sertest[] = {
- 0xAF, // xor a
- 0xED, 0x39, 0x36, // out0 (rcr),a ;disable DRAM refresh
- 0x3E, 0x30, // ld a,030h
- 0xED, 0x39, 0x32, // out0 (dcntl),a ;0 mem, max i/0 wait states
- 0x3E, 0x80, // ld a,M_MPBT ;no MP, PS=10, DR=16, SS=0
- 0xED, 0x39, 0x03, // out0 (cntlb1),a
- 0x3E, 0x64, // ld a,M_RE + M_TE + M_MOD2 ;
- 0xED, 0x39, 0x01, // out0 (cntla1),a
- 0x3E, 0x00, // ld a,0
- 0xED, 0x39, 0x05, // out0 (stat1),a ;Enable rx interrupts
- 0xED, 0x38, 0x05, //l0:in0 a,(stat1)
- 0xE6, 0x80, // and 80h
- 0x28, 0xF9, // jr z,l0
- 0xED, 0x00, 0x09, // in0 b,(rdr1)
- 0xED, 0x38, 0x05, //l1:in0 a,(stat1)
- 0xE6, 0x02, // and 02h
- 0x28, 0xF9, // jr z,l1
- 0xED, 0x01, 0x07, // out0 (tdr1),b
- 0x18, 0xEA, // jr l0
-};
-
-const __flash uint8_t test1[] = {
- 0xAF, // xor a
- 0xED, 0x39, 0x36, // out0 (rcr),a ;disable DRAM refresh
- 0x3E, 0x30, // ld a,030h
- 0xED, 0x39, 0x32, // out0 (dcntl),a ;0 mem, max i/0 wait states
- 0x21, 0x1E, 0x00, // ld hl,dmclrt ;load DMA registers
- 0x06, 0x08, // ld b,dmct_e-dmclrt
- 0x0E, 0x20, // ld c,sar0l
- 0xED, 0x93, // otimr
- 0x3E, 0xC3, // ld a,0c3h ;dst +1, src +1, burst
- 0xED, 0x39, 0x31, // out0 (dmode),a ;
- 0x3E, 0x62, // ld a,062h ;enable dma0,
- 0xED, 0x39, 0x30, //cl_1: out0 (dstat),a ;copy 64k
- 0x18, 0xFB, // jr cl_1 ;
- 0x00, 0x00, //dmclrt: dw 0 ;src (inc)
- 0x00, // db 0 ;src
- 0x00, 0x00, // dw 0 ;dst (inc),
- 0x00, // db 0 ;dst
- 0x00, 0x00, // dw 0 ;count (64k)
-};
-
-
-int main(void)
-{
- int_fast8_t state = 0;
- int ch;
-
- setup_avr();
- serial_setup();
- setup_rtc();
- sei();
-
- printf_P(PSTR("\n(ATMEGA1281+HD64180)_stamp Tester\n"));
-
- DBG_P(1, "z80_setup_bus... ");
- z80_setup_msg_fifo();
- z80_setup_bus();
- DBG_P(1, "done.\n");
-
- DBG_P(1, "Get bus... ");
-/* Now done via S_Z180_RUNNING
- z80_busreq(LOW);
- z80_reset(HIGH);
-*/
- z80_request_bus();
- DBG_P(1, "got it!\n");
-
-// z80_sram_fill(0, (uint32_t)512 * 1024, 0x00, 3);
-// z80_sram_cmp(0, (uint32_t)512 * 1024, 0x00, 3);
-// z80_dump_mem(0, 0x400);
-
- z80_memset(0, 0x76, 0x80000);
-// z80_memset(0, 0x00, 0x80000);
-// z80_write_block(test1, 0, sizeof(test1));
-
-// z80_dump_mem(0, 0x100);
-
-// z80_sram_cmp(0, (uint32_t)512 * 1024, 0x76, 0);
-
- z80_load_mem();
-// z80_write(0, 0x76);
-// z80_dump_mem(0, 0x200);
-
-
-/* Now done via S_Z180_RUNNING
- z80_reset(LOW);
-*/
- z80_release_bus();
- DBG_P(1, "Bus released!\n");
- z80_reset(HIGH);
- DBG_P(1, "Reset released!\n");
-
- to_counter = 200;
-
- while (1) {
-
- if (Stat & S_10MS_TO) {
- Stat &= ~S_10MS_TO;
- do_10ms();
- }
-
-
- if ((ch = serial_getc()) >= 0) {
- switch (state) {
- case 0:
- if (ch == ESCCHAR) {
- state = 1;
- /* TODO: Timer starten */
- } else {
-// z80_memfifo_putc(fifo_out, ch);
- serial_putc(ch);
- if (ch == '\r')
- serial_putc('\n');
- }
- break;
- case 1:
- switch (ch) {
-
- case 'r':
- z80_reset_pulse();
- break;
-
- case 'b':
- z80_request_bus();
- z80_dump_mem(0, 0x2d20);
- z80_release_bus();
- break;
-
- case 'e':
- z80_request_bus();
- z80_dump_mem(0x80000-0x4000, 0x800);
- z80_dump_mem(0x80000-0x200, 0x200);
- z80_release_bus();
- break;
-
- case ESCCHAR:
- default:
-// z80_memfifo_putc(fifo_out, ch);
- serial_putc(ch);
- if (ch == '\r')
- serial_putc('\n');
- }
- state = 0;
- break;
- }
- }
-
-// check_msg_fifo();
- }
-
- return 0;
-}
diff --git a/avr/z80-if.c b/avr/z80-if.c
index cc0bab1..b64e755 100644
--- a/avr/z80-if.c
+++ b/avr/z80-if.c
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
/**
*
* Pin assignments
@@ -50,7 +56,6 @@
* | | P | | af1 OSC32 |
* | | P | | af1 OSC32 |
-
*/
diff --git a/include/background.h b/include/background.h
index 8a430b3..87e95e5 100644
--- a/include/background.h
+++ b/include/background.h
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#ifndef BACKGROUND_H
#define BACKGROUND_H
@@ -9,4 +15,3 @@ int bg_getstat(int handle);
void bg_shed(void);
#endif /* BACKGROUND_H */
-
diff --git a/include/cli.h b/include/cli.h
index 67ff63b..f6fb2ab 100644
--- a/include/cli.h
+++ b/include/cli.h
@@ -1,4 +1,13 @@
-#ifndef CLI_H
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * (C) Copyright 2014 Google, Inc
+ * Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef CLI_H
#define CLI_H
/**
@@ -61,4 +70,3 @@ int run_command_list(const char *cmd, int len);
#endif /* CLI_H */
-
diff --git a/include/cli_readline.h b/include/cli_readline.h
index 5b25762..b7dc938 100644
--- a/include/cli_readline.h
+++ b/include/cli_readline.h
@@ -1,4 +1,6 @@
/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
* (C) Copyright 2014 Google, Inc
* Simon Glass <sjg@chromium.org>
*
@@ -47,4 +49,3 @@ int cli_readline(const FLASH char *const prompt);
#endif /* CLI_READLINE_H */
-
diff --git a/include/cmd_mem.h b/include/cmd_mem.h
index 1802338..05227cc 100644
--- a/include/cmd_mem.h
+++ b/include/cmd_mem.h
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#ifndef CMD_MEM_H
#define CMD_MEM_H
@@ -25,4 +31,3 @@ extern command_ret_t do_mem_mwc(cmd_tbl_t *, int, int, char * const []);
#endif /* CONFIG_MX_CYCLIC */
#endif /* CMD_MEM_H */
-
diff --git a/include/command.h b/include/command.h
index d0933a0..5582fa5 100644
--- a/include/command.h
+++ b/include/command.h
@@ -1,3 +1,11 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
/*
* Definitions for Command Processor
@@ -37,11 +45,11 @@ typedef enum {
struct cmd_tbl_s {
const FLASH char *name; /* Command Name */
- int maxargs; /* maximum number of arguments */
- int repeatable; /* autorepeat allowed? */
- /* Implementation function */
+ int maxargs; /* maximum number of arguments */
+ int repeatable; /* autorepeat allowed? */
+ /* Implementation function */
command_ret_t (*cmd)(const FLASH struct cmd_tbl_s *, int, int, char * const []);
- const FLASH char *usage; /* Usage message (short) */
+ const FLASH char *usage; /* Usage message (short) */
#ifdef CONFIG_SYS_LONGHELP
const FLASH char *help; /* Help message (long) */
#endif
diff --git a/include/common.h b/include/common.h
index b0dd038..cfbbae5 100644
--- a/include/common.h
+++ b/include/common.h
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#ifndef COMMON_H
#define COMMON_H
@@ -53,7 +59,7 @@ struct bits {
extern volatile uint_least8_t Stat;
#endif /* __AVR__ */
-#define S_10MS_TO (1<<0)
+#define S_10MS_TO (1<<0)
#define S_MSG_PENDING (1<<1)
#define S_CON_PENDING (1<<2)
diff --git a/include/con-utils.h b/include/con-utils.h
index 15a3ce8..86c0df0 100644
--- a/include/con-utils.h
+++ b/include/con-utils.h
@@ -1,4 +1,14 @@
-#ifndef CON_UTILS_H
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+/*
+ * Console utilities
+ */
+
+#ifndef CON_UTILS_H
#define CON_UTILS_H
uint_fast8_t tstc(void);
@@ -18,5 +28,3 @@ uint_fast8_t had_ctrlc (void);
void clear_ctrlc(void);
#endif /* CON_UTILS_H */
-
-
diff --git a/include/config.h b/include/config.h
index d0749b3..f51ebe9 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#ifndef CONFIG_H
#define CONFIG_H
diff --git a/include/crc.h b/include/crc.h
index 927b5ff..89cde1f 100644
--- a/include/crc.h
+++ b/include/crc.h
@@ -1,14 +1,21 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#ifndef CRC_H
#define CRC_H
#ifdef __AVR__
#include <util/crc16.h>
static inline
-uint16_t crc16(uint16_t crc, uint8_t data)
+uint16_t crc16(uint16_t crc, uint8_t data)
{
return _crc_ccitt_update(crc, data);
}
#else /* !__AVR__ */
+ /* TODO */
#endif /* __AVR__ */
#endif /* CRC_H */
diff --git a/include/debug.h b/include/debug.h
index da8e9a0..39c15b0 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -1,3 +1,12 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#ifndef DEBUG_H_
#define DEBUG_H_
@@ -10,6 +19,11 @@
#define _DEBUG 0
#endif
+/*
+ * Output a debug text when condition "cond" is met. The "cond" should be
+ * computed by a preprocessor in the best case, allowing for the best
+ * optimization.
+ */
#define debug_cond(cond, fmt, args...) \
do { \
if (cond) \
diff --git a/include/env.h b/include/env.h
index 7c4fee9..da38c54 100644
--- a/include/env.h
+++ b/include/env.h
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#ifndef ENV_H
#define ENV_H
@@ -8,9 +14,8 @@ unsigned long getenv_ulong(const MEMX char *name, int base, unsigned long defaul
int setenv_ulong(const MEMX char *varname, unsigned long value);
int setenv_hex(const MEMX char *varname, unsigned long value);
-#if defined(CONFIG_AUTO_COMPLETE)
+#if defined(CONFIG_AUTO_COMPLETE)
int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf);
#endif
#endif /* ENV_H */
-
diff --git a/include/ffconf.h b/include/ffconf.h
index 1399dc2..9841d5b 100644
--- a/include/ffconf.h
+++ b/include/ffconf.h
@@ -1,4 +1,5 @@
#ifdef __AVR__
#include "avr/ffconf.h"
#else
+ /* TODO */
#endif
diff --git a/include/getopt-min.h b/include/getopt-min.h
index 9f7729e..6495ebf 100644
--- a/include/getopt-min.h
+++ b/include/getopt-min.h
@@ -1,12 +1,11 @@
#ifndef GETOPT_MIN_H
#define GETOPT_MIN_H
-int getopt( /* returns letter, '?', EOF */
- int argc, /* argument count from main */
- char *const argv[], /* argument vector from main */
+int getopt( /* returns letter, '?', EOF */
+ int argc, /* argument count from main */
+ char *const argv[], /* argument vector from main */
const FLASH char * optstring ); /* allowed args, e.g. "ab:c" */
extern int optind;
#endif /* GETOPT_MIN_H */
-
diff --git a/include/gpio.h b/include/gpio.h
index ac48045..1e0346d 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#ifndef GPIO_H
#define GPIO_H
@@ -14,4 +20,3 @@ int gpio_clockdiv_set(int pin, unsigned long divider);
long gpio_clockdiv_get(int pin);
#endif /* GPIO_H */
-
diff --git a/include/i2c.h b/include/i2c.h
index 50b1fd0..f39fa1d 100644
--- a/include/i2c.h
+++ b/include/i2c.h
@@ -1,4 +1,6 @@
/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
* Copyright (C) 2009 Sergey Kubushyn <ksi@koi8.net>
* Copyright (C) 2009 - 2013 Heiko Schocher <hs@denx.de>
* Changes for multibus/multiadapter I2C support.
diff --git a/include/print-utils.h b/include/print-utils.h
index 5604d3b..8acf975 100644
--- a/include/print-utils.h
+++ b/include/print-utils.h
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#ifndef PRINT_UTILS_H
#define PRINT_UTILS_H
diff --git a/include/ring.h b/include/ring.h
index d57f9aa..b64f462 100644
--- a/include/ring.h
+++ b/include/ring.h
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#ifndef RING_H
#define RING_H
@@ -71,4 +77,3 @@ int_fast8_t ring_is_empty(struct ring *ring)
}
#endif /* RING_H */
-
diff --git a/include/rtc.h b/include/rtc.h
index 6946660..ca4c068 100644
--- a/include/rtc.h
+++ b/include/rtc.h
@@ -1,6 +1,9 @@
/*
- * Generic RTC interface.
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
*/
+
#ifndef _RTC_H_
#define _RTC_H_
diff --git a/include/serial.h b/include/serial.h
index 40ac815..54c7211 100644
--- a/include/serial.h
+++ b/include/serial.h
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#ifndef SERIAL_H
#define SERIAL_H
diff --git a/include/spi.h b/include/spi.h
index 6358f62..1052569 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -1,8 +1,7 @@
/*
- * spi.h
+ * (C) Copyright 2009,2014 Leo C. <erbl259-lmu@yahoo.de>
*
- * Created on: 17.04.2009
- * Author: leo
+ * SPDX-License-Identifier: GPL-2.0+
*/
#ifndef SPI_H_
diff --git a/include/timer.h b/include/timer.h
index bed3eb0..c6d6053 100644
--- a/include/timer.h
+++ b/include/timer.h
@@ -1,7 +1,12 @@
-#ifndef TIMER_H
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#ifndef TIMER_H
#define TIMER_H
uint32_t get_timer(uint32_t);
#endif /* TIMER_H */
-
diff --git a/include/z180-serv.h b/include/z180-serv.h
index af4b1c0..424318f 100644
--- a/include/z180-serv.h
+++ b/include/z180-serv.h
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#ifndef Z180_SERV_H
#define Z180_SERV_H
diff --git a/include/z80-if.h b/include/z80-if.h
index d4ee57b..58790bd 100644
--- a/include/z80-if.h
+++ b/include/z80-if.h
@@ -1,3 +1,8 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
#define ZST_ACQUIRED 0x01
#define ZST_RUNNING 0x02
diff --git a/stm32/debug.h b/stm32/debug.h
index d542317..692c879 100644
--- a/stm32/debug.h
+++ b/stm32/debug.h
@@ -1,3 +1,8 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
#ifndef DEBUG_H_
#define DEBUG_H_
diff --git a/stm32/serial.c b/stm32/serial.c
index 9193005..d2f1a93 100644
--- a/stm32/serial.c
+++ b/stm32/serial.c
@@ -1,8 +1,7 @@
/*
- * serial.c
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
*
- * Created on: 04.05.2014
- * Author: leo
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <errno.h>
diff --git a/stm32/serial.h b/stm32/serial.h
index 1a0f510..62d95e2 100644
--- a/stm32/serial.h
+++ b/stm32/serial.h
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
#ifndef SERIAL_H
#define SERIAL_H
diff --git a/stm32/z180-stamp-stm32.c b/stm32/z180-stamp-stm32.c
index 15d732d..7000c53 100644
--- a/stm32/z180-stamp-stm32.c
+++ b/stm32/z180-stamp-stm32.c
@@ -1,4 +1,7 @@
/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
*/
#include <stdio.h>
@@ -86,26 +89,26 @@ static void clock_setup(void)
/* Enable clocks for:
GPIO port A (for GPIO_USART1_TX and Button)
- GPIO port C (LEDs)
+ GPIO port C (LEDs)
USART1
- TIM16 (RST-Pin)
+ TIM16 (RST-Pin)
TIM1 (IOCS1)
*/
- rcc_peripheral_enable_clock(&RCC_APB2ENR,
- RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPBEN
- | RCC_APB2ENR_IOPCEN | RCC_APB2ENR_IOPDEN
+ rcc_peripheral_enable_clock(&RCC_APB2ENR,
+ RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPBEN
+ | RCC_APB2ENR_IOPCEN | RCC_APB2ENR_IOPDEN
| RCC_APB2ENR_USART1EN | RCC_APB2ENR_AFIOEN
| RCC_APB2ENR_TIM1EN | RCC_APB2ENR_TIM16EN);
/* Enable clocks for:
TIM3
*/
- rcc_peripheral_enable_clock(&RCC_APB1ENR,
+ rcc_peripheral_enable_clock(&RCC_APB1ENR,
RCC_APB1ENR_TIM3EN);
/* Enable clocks for:
DMA1
*/
- rcc_peripheral_enable_clock(&RCC_AHBENR,
+ rcc_peripheral_enable_clock(&RCC_AHBENR,
RCC_AHBENR_DMA1EN);
}
@@ -129,19 +132,19 @@ static void nvic_setup(void)
static void tim3_setup(void)
{
TIM3_CR1 = TIM_CR1_CMS_EDGE | TIM_CR1_DIR_UP;
-
+
TIM3_CCMR2 = 0
- | TIM_CCMR2_OC4M_FORCE_LOW
+ | TIM_CCMR2_OC4M_FORCE_LOW
/* | TIM_CCMR2_OC4M_FORCE_HIGH */
/* | TIM_CCMR2_OC4M_PWM2 */
-
+
/* | TIM_CCMR2_OC4PE */
/* | TIM_CCMR2_OC4FE */
| TIM_CCMR2_CC4S_OUT;
-
+
TIM3_CCER = TIM_CCER_CC4E
| TIM_CCER_CC4P;
-
+
TIM3_ARR = 48; /* default */
TIM3_CCR4 = 1; /* */
}
@@ -154,7 +157,7 @@ static void gpio_setup(void)
Remap TIM3 (CH1/PC6, CH2/PC7, CH3/PC8, CH4/PC9)
Port D0/Port D1 mapping on OSC_IN/OSC_OUT
*/
- gpio_primary_remap(AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON,
+ gpio_primary_remap(AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON,
AFIO_MAPR_SPI1_REMAP
| AFIO_MAPR_TIM3_REMAP_FULL_REMAP
| AFIO_MAPR_PD01_REMAP);
@@ -174,7 +177,7 @@ static void gpio_setup(void)
void delay_systicks(int ticks)
{
int start, stop, now;
-
+
start = STK_CVR;
stop = start - ticks;
if (stop < 0) {
@@ -298,13 +301,13 @@ static void key_timerproc() {
// key_state = key_state & key_in | (key_state | key_in) & key_in_last;
key_state = c | ((key_in_last | key_in) & key_state);
-
+
// key_state = (key_state&key_in_last) | (key_state&key_in) | (key_in_last&key_in);
key_press |= c;
-
+
key_in_last = key_in;
-
+
if ((key_state & REPEAT_MASK) == 0) // check repeat function
rpt = REPEAT_START;
@@ -330,7 +333,7 @@ void sys_tick_handler(void)
Stat |= S_10MS_TO;
tick_10ms = 0;
-
+
i = led_timer[0];
if (i)
led_timer[0] = i - 1;
@@ -339,11 +342,11 @@ void sys_tick_handler(void)
led_timer[1] = i - 1;
key_timerproc();
-
+
/* Drive timer procedure of low level disk I/O module */
//disk_timerproc();
}
-
+
count_ms++;
if (count_ms == 1000) {
count_ms = 0;
@@ -366,7 +369,7 @@ void rtc_isr(void)
void tim3_set(int mode)
{
uint16_t cc_mode;
-
+
cc_mode = TIM_CCMR2_CC4S_OUT;
TIM3_CR1 = TIM_CR1_CMS_EDGE | TIM_CR1_DIR_UP /*| TIM_CR1_OPM */ ;
@@ -380,9 +383,9 @@ void tim3_set(int mode)
TIM3_CCR4 = mode/2;
cc_mode |= TIM_CCMR2_OC4M_PWM2;
}
-
+
TIM3_CCMR2 = cc_mode;
-
+
if (mode > 0)
TIM3_CR1 |= TIM_CR1_CEN;
}
@@ -393,17 +396,17 @@ static uint32_t z80_sram_cmp(uint32_t addr, uint32_t length, uint8_t wval, int i
{
uint8_t rval;
int_fast8_t errors = 0;
-
+
DBG_P(1, "SRAM: Check %#.5x byte... ", length);
while (length--) {
if ((rval = z80_read(addr)) != wval) {
- if (errors == 0) {
+ if (errors == 0) {
printf("\nSRAM: Address W R\n" \
" -------------\n");
// 12345 00 11
}
printf(" %.5lx %.2x %.2x\n", addr, wval, rval);
-
+
if (++errors > 16 )
break;
}
@@ -421,7 +424,7 @@ static void z80_sram_fill(uint32_t addr, int length, uint8_t startval, int inc)
printf("SRAM: Write %#.5x byte... ", length); //fflush(stdout);
while (length--) {
z80_write(addr, startval);
- ++addr;
+ ++addr;
startval += inc;
}
printf("Done.\n");
@@ -465,18 +468,18 @@ const char * const qbcat = "Zhe quick brown fox jumps over the lazy cat!";
uint8_t z80_get_byte(uint32_t adr)
{
uint8_t data;
-
+
z80_request_bus();
data = z80_read(adr),
z80_release_bus();
-
+
return data;
}
/*--------------------------------------------------------------------------*/
-static void do_10ms(void)
+static void do_10ms(void)
{
for (uint_fast8_t i = 0; i < 2; i++) {
switch (led_stat[i].mode) {
@@ -696,19 +699,19 @@ int main(void)
z80_reset(HIGH);
z80_request_bus();
DBG_P(1, "got it!\n");
-
+
z80_memset(0, 0x76, 0x80000);
//z80_sram_fill(0, 512 * 1024, 0x76, 0);
z80_sram_cmp(0, (uint32_t)512 * 1024, 0x76, 0);
-
+
z80_load_mem();
z80_reset(LOW);
DBG_P(1, "Bus released!\n");
z80_release_bus();
z80_reset(HIGH);
DBG_P(1, "Reset released!\n");
-
-
+
+
ledset(0, BLINK1, 50);
while (1) {
diff --git a/stm32/z80-if.c b/stm32/z80-if.c
index 171fea9..6c415d1 100644
--- a/stm32/z80-if.c
+++ b/stm32/z80-if.c
@@ -1,3 +1,9 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
/**
*
* Pin assignments
@@ -111,8 +117,8 @@ AFIO_MAPR_SPI1_REMAP
AFIO_MAPR2 =
-AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON (frees
-AFIO_MAPR_SPI1_REMAP
+AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON (frees
+AFIO_MAPR_SPI1_REMAP
*/
@@ -220,7 +226,7 @@ AFIO_MAPR_SPI1_REMAP
#define IOFIELD_GET(src, width, shift) \
((src>>shift) & MASK(width))
-
+
#define CNF_MODE_I_F (GPIO_CNF_INPUT_FLOAT<<2 |GPIO_MODE_INPUT)
#define CNF_MODE_O_PP (GPIO_CNF_OUTPUT_PUSHPULL<<2 | GPIO_MODE_OUTPUT_10_MHZ)
@@ -249,16 +255,16 @@ static void tim16_setup(void)
{
RCC_APB2RSTR |= RCC_APB2RSTR_TIM16RST;
RCC_APB2RSTR &= ~RCC_APB2RSTR_TIM16RST;
-
+
TIM16_BDTR = TIM_BDTR_MOE;
-
+
TIM16_CCMR1 = 0
- | TIM_CCMR1_OC1M_FORCE_LOW
+ | TIM_CCMR1_OC1M_FORCE_LOW
| TIM_CCMR1_CC1S_OUT;
-
+
TIM16_CCER = TIM_CCER_CC1NE
| TIM_CCER_CC1NP;
-
+
TIM16_ARR = 48; /* default */
TIM16_CCR1 = 1; /* */
}
@@ -268,7 +274,7 @@ static void tim16_setup(void)
static void tim16_set(int mode)
{
uint16_t cc_mode;
-
+
cc_mode = TIM_CCMR1_CC1S_OUT;
TIM16_CR1 = TIM_CR1_OPM;
@@ -281,9 +287,9 @@ static void tim16_set(int mode)
TIM16_ARR = mode;
cc_mode |= TIM_CCMR1_OC1M_PWM2;
}
-
+
TIM16_CCMR1 = cc_mode;
-
+
if (mode > 0)
TIM16_CR1 |= TIM_CR1_CEN;
}
@@ -292,44 +298,44 @@ static void tim16_set(int mode)
-/*
+/*
* A0..A6, A8..A13 are buffered. No need to disable.
* A7, A14..A18: set to input.
*/
-
+
static void z80_setup_adrbus_tristate(void)
{
#if 0
gpio_set_mode(ADunbuff1_PORT, GPIO_MODE_INPUT,
GPIO_CNF_INPUT_FLOAT, MASK(ADunbuff1_WIDTH) << ADunbuff1_SHIFT);
- gpio_set_mode(ADunbuff2_PORT, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT,
+ gpio_set_mode(ADunbuff2_PORT, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT,
(MASK(ADunbuff2_WIDTH) << ADunbuff2_SHIFT) | (MASK(ADunbuff3_WIDTH) << ADunbuff3_SHIFT));
#else
- GPIO_CRH(GPIOA) = (GPIO_CRH(GPIOA) & ~(0x0f << (4 * 0)))
+ GPIO_CRH(GPIOA) = (GPIO_CRH(GPIOA) & ~(0x0f << (4 * 0)))
| (CNF_MODE_I_F << (4 * 0));
GPIO_CRL(GPIOC) = (GPIO_CRL(GPIOC) & ~((0x0f << (4 * 6)) | (0x0f << (4 * 7))))
| ((CNF_MODE_I_F << (4 * 6)) | (CNF_MODE_I_F << (4 * 7)));
GPIO_CRH(GPIOC) = (GPIO_CRH(GPIOC) & ~((0x0f << (4*2)) | (0x0f << (4*3)) | (0x0f << (4*4))))
| ((CNF_MODE_I_F << (4*2)) | (CNF_MODE_I_F << (4*3)) | (CNF_MODE_I_F << (4*4)));
-#endif
+#endif
}
-
+
static void z80_setup_adrbus_active(void)
{
#if 0
gpio_set_mode(ADunbuff1_PORT, GPIO_MODE_OUTPUT_10_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, MASK(ADunbuff1_WIDTH) << ADunbuff1_SHIFT);
- gpio_set_mode(ADunbuff2_PORT, GPIO_MODE_OUTPUT_10_MHZ, GPIO_CNF_OUTPUT_PUSHPULL,
+ gpio_set_mode(ADunbuff2_PORT, GPIO_MODE_OUTPUT_10_MHZ, GPIO_CNF_OUTPUT_PUSHPULL,
(MASK(ADunbuff2_WIDTH) << ADunbuff2_SHIFT) | (MASK(ADunbuff3_WIDTH) << ADunbuff3_SHIFT));
#else
- GPIO_CRH(GPIOA) = (GPIO_CRH(GPIOA) & ~(0x0f << (4 * 0)))
+ GPIO_CRH(GPIOA) = (GPIO_CRH(GPIOA) & ~(0x0f << (4 * 0)))
| (CNF_MODE_O_PP << (4 * 0));
GPIO_CRL(GPIOC) = (GPIO_CRL(GPIOC) & ~((0x0f << (4 * 6)) | (0x0f << (4 * 7))))
| ((CNF_MODE_O_PP << (4 * 6)) | (CNF_MODE_O_PP << (4 * 7)));
GPIO_CRH(GPIOC) = (GPIO_CRH(GPIOC) & ~((0x0f << (4*2)) | (0x0f << (4*3)) | (0x0f << (4*4))))
| ((CNF_MODE_O_PP << (4*2)) | (CNF_MODE_O_PP << (4*3)) | (CNF_MODE_O_PP << (4*4)));
-#endif
+#endif
}
@@ -402,9 +408,9 @@ void z80_release_bus(void)
void z80_reset(level_t level)
{
int x = level ? -1 : 0;
-
+
tim16_set(x);
-
+
// Z80_O_RST = level;
}
@@ -469,7 +475,7 @@ void z80_memset(uint32_t addr, uint8_t data, int length)
void z80_write_block(uint8_t *src, uint32_t dest, uint32_t length)
{
uint8_t data;
-
+
z80_setup_dbus_out();
Z80_O_ME = 0;
while(length--) {
@@ -488,7 +494,7 @@ void z80_write_block(uint8_t *src, uint32_t dest, uint32_t length)
017B' rx.out_idx: ds 1 ;
017C' rx.buf: ds rx.buf_len ;
018B' rx.buf_end equ $-1 ; last byte (start+len-1)
-
+
018C' tx.bs_mask: ds 1 ; (buf_len - 1)
018D' tx.in_idx: ds 1 ;
018E' tx.out_idx: ds 1 ;
@@ -517,7 +523,7 @@ static struct {
idx_in,
mask;
} fifo_dsc[NUM_FIFOS];
-
+
void z80_memfifo_init(const fifo_t f, uint32_t adr)
{
@@ -557,7 +563,7 @@ int z80_memfifo_is_empty(const fifo_t f)
int z80_memfifo_is_full(const fifo_t f)
{
int rc = 1;
-
+
if (fifo_dsc[f].base != 0) {
z80_request_bus();
rc = ((fifo_dsc[f].idx_in + 1) & fifo_dsc[f].mask)
@@ -570,7 +576,7 @@ int z80_memfifo_is_full(const fifo_t f)
uint8_t z80_memfifo_getc(const fifo_t f)
{
uint8_t rc, idx;
-
+
while (z80_memfifo_is_empty(f))
;
@@ -580,7 +586,7 @@ uint8_t z80_memfifo_getc(const fifo_t f)
fifo_dsc[f].idx_out = ++idx & fifo_dsc[f].mask;
z80_write(fifo_dsc[f].base+FIFO_INDEX_OUT, fifo_dsc[f].idx_out);
z80_release_bus();
-
+
return rc;
}
@@ -588,7 +594,7 @@ uint8_t z80_memfifo_getc(const fifo_t f)
void z80_memfifo_putc(fifo_t f, uint8_t val)
{
int idx;
-
+
while (z80_memfifo_is_full(f))
;
@@ -714,7 +720,7 @@ DBG_P(1, "z80_init_msg_fifo: %lx\n", addr);
int z80_msg_fifo_getc(void)
{
int c = -1;
-
+
if (msg_fifo.count != (NELEMS(msg_fifo.buf) - DMA1_CNDTR4)) {
c = msg_fifo.buf[msg_fifo.count];
if (++msg_fifo.count == NELEMS(msg_fifo.buf))
diff --git a/stm32/z80-if.h b/stm32/z80-if.h
index d7c030d..e65f160 100644
--- a/stm32/z80-if.h
+++ b/stm32/z80-if.h
@@ -1,3 +1,8 @@
+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
typedef enum {LOW, HIGH} level_t;