mirror of
git://projects.qi-hardware.com/f32xbase.git
synced 2025-04-21 12:27:27 +03:00
fw/example/ - very simple demo application
This commit is contained in:
56
fw/example/example.c
Normal file
56
fw/example/example.c
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user