diff options
author | Leo C | 2014-09-17 22:23:17 +0200 |
---|---|---|
committer | Leo C | 2014-09-17 22:23:17 +0200 |
commit | 04a63b0d5660f1c0c0b7e8123e4f56d188e52a5d (patch) | |
tree | 6cecaf46786fe977dee58aa1b72948221c3fe837 /avr/z80-if.c | |
parent | 6035a17b2becc788c0daaf440deb6cc37d364029 (diff) | |
download | z180-stamp-04a63b0d5660f1c0c0b7e8123e4f56d188e52a5d.zip |
Disable all peripheral functions globally. Enable used functions when needed.
Diffstat (limited to 'avr/z80-if.c')
-rw-r--r-- | avr/z80-if.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/avr/z80-if.c b/avr/z80-if.c index c0f128e..dd0dd96 100644 --- a/avr/z80-if.c +++ b/avr/z80-if.c @@ -144,6 +144,7 @@ struct bits { #define MASK(n) ((1<<(n))-1) #define SMASK(w,s) (MASK(w) << (s)) +#define LOWSPEED 50000 typedef union { @@ -158,6 +159,13 @@ static zstate_t zstate; /*--------------------------------------------------------------------------*/ static +uint8_t is_lowspeed() +{ + return (TCCR1B & 7) < 2 && + OCR1A > (F_CPU / 2 / LOWSPEED); +} + +static void z80_setup_clock(void) { /* ZCLK: Output and low */ @@ -206,12 +214,10 @@ int z80_clock_set(unsigned long freq) TCCR1A = (0b01 << COM1C0) | (0b00 << WGM10); TCCR1B = (0b01 << WGM12) | ((prescale+1) << CS10); - if (ocrval == 0) { -// TCCR1C |= _BV(FOC1C); + if (ocrval == 0) ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { TCNT1 = 0xFFFF; } - } PINB |= _BV(6); /* Debug */ @@ -229,7 +235,6 @@ uint32_t z80_clock_get(void) else count *= 8; pre--; - } return F_CPU/count; |