1 /**************************************************************************/
4 @author K. Townsend (microBuilder.eu)
8 Software License Agreement (BSD License)
10 Copyright (c) 2011, microBuilder SARL
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 1. Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 2. Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 3. Neither the name of the copyright holders nor the
21 names of its contributors may be used to endorse or promote products
22 derived from this software without specific prior written permission.
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 /**************************************************************************/
40 #include "projectconfig.h"
43 #include "core/gpio/gpio.h"
44 #include "core/systick/systick.h"
47 #include "core/cmd/cmd.h"
50 /**************************************************************************/
52 Approximates a 1 millisecond delay using "nop". This is less
53 accurate than a dedicated timer, but is useful in certain situations.
55 The number of ticks to delay depends on the optimisation level set
56 when compiling (-O). Depending on the compiler settings, one of the
57 two defined values for 'delay' should be used.
59 /**************************************************************************/
60 void delayms(uint32_t ms
)
62 uint32_t delay
= ms
* ((CFG_CPU_CCLK
/ 100) / 45); // Release Mode (-Os)
63 // uint32_t delay = ms * ((CFG_CPU_CCLK / 100) / 120); // Debug Mode (No optimisations)
67 __asm
volatile ("nop");
72 /**************************************************************************/
74 Main program entry point. After reset, normal code execution will
77 /**************************************************************************/
80 // Configure cpu and mandatory peripherals
83 uint32_t currentSecond
, lastSecond
;
84 currentSecond
= lastSecond
= 0;
88 // Toggle LED once per second ... rollover = 136 years :)
89 currentSecond
= systickGetSecondsActive();
90 if (currentSecond
!= lastSecond
)
92 lastSecond
= currentSecond
;
93 if (gpioGetValue(CFG_LED_PORT
, CFG_LED_PIN
) == CFG_LED_OFF
)
95 gpioSetValue (CFG_LED_PORT
, CFG_LED_PIN
, CFG_LED_ON
);
99 gpioSetValue (CFG_LED_PORT
, CFG_LED_PIN
, CFG_LED_OFF
);
103 // Poll for CLI input if CFG_INTERFACE is enabled in projectconfig.h
This page took 0.04638 seconds and 5 git commands to generate.