]>
cloudbase.mooo.com Git - z180-stamp.git/blob - avr/main.c
7 #include <util/delay.h>
8 //#include <avr/power.h>
9 //#include <avr/pgmspace.h>
10 #include <avr/interrupt.h>
11 //#include <util/atomic.h>
12 //#include <avr/sleep.h>
15 #include <util/delay.h>
24 #include "con-utils.h"
30 /*--------------------------------------------------------------------------*/
38 /* Disable JTAG Interface regardless of the JTAGEN fuse setting. */
42 /* disable unused periphels */
43 PRR0
= _BV(PRTIM2
) | _BV(PRTIM0
) | _BV(PRADC
);
44 PRR1
= _BV(PRTIM5
) | _BV(PRTIM4
) | _BV(PRTIM3
) |
45 _BV(PRUSART3
) | _BV(PRUSART2
) | _BV(PRUSART1
);
47 /* disable analog comparator */
57 OCR1A
= F_CPU
/ 8 / 1000 - 1; // Timer1: 1000Hz interval (OC1A)
59 TIMSK1
= _BV(OCIE1A
); // Enable TC1.oca interrupt
64 /*******************************************************************************/
65 /*******************************************************************************/
67 #define udelay(n) _delay_us(n)
70 /* Stored value of bootdelay, used by autoboot_command() */
71 static int stored_bootdelay
;
74 /***************************************************************************
75 * Watch for 'delay' seconds for autoboot stop.
76 * returns: 0 - no key, allow autoboot
80 static int abortboot(int bootdelay
)
86 printf_P(PSTR("Hit any key to stop autoboot: %2d "), bootdelay
);
88 #if defined CONFIG_ZERO_BOOTDELAY_CHECK
90 * Check if key already pressed
91 * Don't check if bootdelay < 0
94 if (tstc()) { /* we got a key press */
95 (void) my_getchar(); /* consume input */
96 my_puts_P(PSTR("\b\b\b 0"));
97 abort
= 1; /* don't auto boot */
102 while ((bootdelay
> 0) && (!abort
)) {
107 if (tstc()) { /* we got a key press */
108 abort
= 1; /* don't auto boot */
109 bootdelay
= 0; /* no more delay */
113 } while (!abort
&& get_timer(ts
) < 1000);
115 printf_P(PSTR("\b\b\b%2d "), bootdelay
);
123 const char *bootdelay_process(void)
128 s
= getenv("bootdelay");
129 bootdelay
= s
? atoi(s
) : CONFIG_BOOTDELAY
;
132 debug("### main_loop entered: bootdelay=%d\n\n", bootdelay
);
135 s
= getenv("bootcmd");
136 stored_bootdelay
= bootdelay
;
140 void autoboot_command(const char *s
)
142 debug("### main_loop: bootcmd=\"%s\"\n", s
? s
: PSTR("<UNDEFINED>"));
145 if (stored_bootdelay
!= -1 && s
&& !abortboot(stored_bootdelay
)) {
146 run_command_list(s
, -1);
155 s
= bootdelay_process();
168 debug("\n=========================< (RE)START DEBUG >=========================\n");
172 printf_P(PSTR("\n(ATMEGA1281+HD64180)_stamp Tester\n"));