X-Git-Url: http://cloudbase.mooo.com/gitweb/z180-stamp.git/blobdiff_plain/cd5ee5442821f283f6661befb24b885d944e4c5e..fecee2418b6aea15008ed6d3a856d202d59a5cdb:/avr/main.c diff --git a/avr/main.c b/avr/main.c index e7ebd5d..8bffef9 100644 --- a/avr/main.c +++ b/avr/main.c @@ -1,10 +1,11 @@ /* + * (C) Copyright 2014 Leo C. + * + * SPDX-License-Identifier: GPL-2.0+ */ #include "common.h" - -#include #include #include #include @@ -18,8 +19,10 @@ #include "timer.h" #include "cli.h" #include "env.h" - -#define udelay(n) _delay_us(n) +#include "z180-serv.h" +#include "gpio.h" +#include "time.h" +#include "rtc.h" static uint8_t mcusr; @@ -61,6 +64,16 @@ void print_reset_reason(void) #endif +ISR(INT5_vect) +{ + Stat |= S_MSG_PENDING; +} + +ISR(INT6_vect) +{ + Stat |= S_CON_PENDING; +} + static void setup_avr(void) { @@ -99,6 +112,14 @@ void setup_avr(void) OCR3A = F_CPU / 1000 - 1; /* Timer3: 1000Hz interval (OC3A) */ TCCR3B = (0b01<= 0) { if (tstc()) { /* we got a key press */ - (void) my_getchar(); /* consume input */ + (void) my_getchar(1); /* consume input */ my_puts_P(PSTR("\b\b\b 0")); abort = 1; /* don't auto boot */ } @@ -168,13 +199,13 @@ const char *bootdelay_process(void) char *s; int bootdelay; - bootdelay = (int) getenv_ulong(PSTR("bootdelay"), 10, CONFIG_BOOTDELAY); + bootdelay = (int) getenv_ulong(PSTR(ENV_BOOTDELAY), 10, CONFIG_BOOTDELAY); debug("### main_loop entered: bootdelay=%d\n\n", bootdelay); _delay_ms(20); - s = getenv(PSTR("bootcmd")); + s = getenv(PSTR(ENV_BOOTCMD)); stored_bootdelay = bootdelay; return s; } @@ -203,16 +234,19 @@ void main_loop(void) int main(void) { + extern void setup_mmc(void); + for (int i = 0; i < GPIO_MAX; i++) + gpio_config(i, INPUT_PULLUP); setup_avr(); + setup_mmc(); z80_setup_bus(); - env_init(); if (reset_reason_is_power_on()) _delay_ms(CONFIG_PWRON_DELAY); - serial_setup(getenv_ulong(PSTR("baudrate"), 10, CONFIG_BAUDRATE)); + serial_setup(getenv_ulong(PSTR(ENV_BAUDRATE), 10, CONFIG_BAUDRATE)); sei(); #if DEBUG @@ -227,9 +261,11 @@ int main(void) #else i2c_init(CONFIG_SYS_I2C_CLOCK); #endif + setup_system_time(); printf_P(PSTR("\nATMEGA1281+Z8S180 Stamp Monitor\n\n")); + setup_z180_serv(); main_loop(); }