diff --git a/fw/example/.version b/fw/example/.version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/fw/example/.version @@ -0,0 +1 @@ +1 diff --git a/fw/example/Makefile b/fw/example/Makefile new file mode 100644 index 0000000..8209c60 --- /dev/null +++ b/fw/example/Makefile @@ -0,0 +1,20 @@ +# +# example/Makefile - Example application +# +# Written 2010 by Werner Almesberger +# Copyright 2010 Werner Almesberger +# +# 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. +# + +MAIN=example +OBJS=$(MAIN) version + +include ../common/Makefile.system +include ../common/Makefile.common + +CFLAGS += -I../include +LDFLAGS += --code-loc $(PAYLOAD_START) diff --git a/fw/example/example.c b/fw/example/example.c new file mode 100644 index 0000000..4ee5893 --- /dev/null +++ b/fw/example/example.c @@ -0,0 +1,56 @@ +/* + * example/example.c - Example application + * + * Written 2010 by Werner Almesberger + * Copyright 2010 Werner Almesberger + * + * 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. + */ + + +#include + +#include "regs.h" + + +static void count(void) +{ + union { + uint32_t n; + uint8_t a[3]; + } c; + + c.n = 0; + while (1) { + P0 = c.a[0]; + P2 = c.a[1]; + P3 = c.a[2]; + c.n++; + } +} + + +void main(void) +{ + /* + * VDD monitor enable sequence, section 7.2 + * + * - enable voltage monitor + * - wait for monitor to stabilize + * - enable VDD monitor reset + */ + + VDM0CN = VDMEN; + while (!(VDM0CN & VDDSTAT)); + RSTSRC = PORSF; + + /* + * Go to 24 Mhz + */ + OSCICN |= IFCN0 | IFCN1; + + count(); +} diff --git a/fw/example/version.h b/fw/example/version.h new file mode 100644 index 0000000..6080177 --- /dev/null +++ b/fw/example/version.h @@ -0,0 +1,26 @@ +/* + * boot/version.h - Automatically generated version string + * + * Written 2008 by Werner Almesberger + * Copyright 2008 Werner Almesberger + * + * 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. + */ + + +#ifndef VERSION_H +#define VERSION_H + +#include + +/* + * Oddly, sdcc seems to insist on the "extern" to mean "declaration". + */ + +extern const char *build_date; +extern const uint16_t build_number; + +#endif /* !VERSION_H */