1
0
mirror of git://projects.qi-hardware.com/f32xbase.git synced 2024-11-23 21:05:56 +02:00

fw/example/ - very simple demo application

This commit is contained in:
Werner Almesberger 2010-08-13 08:49:48 -03:00
parent e23181e40b
commit e038f87196
4 changed files with 103 additions and 0 deletions

1
fw/example/.version Normal file
View File

@ -0,0 +1 @@
1

20
fw/example/Makefile Normal file
View File

@ -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)

56
fw/example/example.c Normal file
View File

@ -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 <stdint.h>
#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();
}

26
fw/example/version.h Normal file
View File

@ -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 <stdint.h>
/*
* 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 */