Change to C source file, add simavr debug code.

This commit is contained in:
Andrew Makousky 2020-09-05 02:50:55 -05:00
parent 1e91a8b426
commit 9fe3c780dd
3 changed files with 26 additions and 7 deletions

View File

@ -1,2 +1,3 @@
Mac128kRTC.axf
MacPlusRTC.axf
avr_mcu_section.h

View File

@ -15,8 +15,19 @@
#include <avr/interrupt.h>
#include <avr/sleep.h>
#ifdef DO_SIMAVR
#include "avr_mcu_section.h"
AVR_MCU(32768, "attiny85");
AVR_MCU_SIMAVR_COMMAND (& GPIOR0 );
const struct avr_mmcu_vcd_trace_t _mytrace[] _MMCU_ =
{
{ AVR_MCU_VCD_SYMBOL("PORTB5"), .what = (void*)&PORTB, .mask = _BV(5) },
};
#endif
/********************************************************************/
// Simplified Arduino.h definitions.
typedef enum { false, true } bool;
typedef bool boolean;
typedef uint8_t byte;
@ -60,12 +71,14 @@ const int SERIAL_CLOCK_PIN = 2; // Serial clock input on PB2
#if NoXPRAM
// Models earlier than the Plus had 20 bytes of PRAM
const int PRAM_SIZE = 20;
//const int PRAM_SIZE = 20;
#define PRAM_SIZE 20
const int group1Base = 0x00;
const int group2Base = 0x10;
#else
// Mac Plus used the xPRAM chip with 256 bytes
const int PRAM_SIZE = 256;
//const int PRAM_SIZE = 256;
#define PRAM_SIZE 256
const int group1Base = 0x10;
const int group2Base = 0x08;
#endif
@ -77,7 +90,7 @@ enum SerialStateType { SERIAL_DISABLED, RECEIVING_COMMAND,
enum PramAddrResult { INVALID_CMD, SECONDS_CMD,
WRTEST_CMD, WRPROT_CMD, SUCCESS_ADDR };
volatile SerialStateType serialState = SERIAL_DISABLED;
volatile enum SerialStateType serialState = SERIAL_DISABLED;
volatile boolean lastSerClock = 0;
volatile byte serialBitNum = 0;
volatile byte address = 0;
@ -131,10 +144,15 @@ void setup() {
//set up timer
bitSet(GTCCR, TSM); // Turns off timers while we set it up
bitSet(TIMSK, TOIE0); // Set Timer/Counter0 Overflow Interrupt Enable
TCCR0B = 0b111; // Set prescaler, 32,768Hz/64 = 512Hz, fills up the 8-bit counter (256) once every half second
// NOTE: 0b111 external clock, 0b011, uses 1/64 prescaler on I/O clock.
TCCR0B = 0b011; // Set prescaler, 32,768Hz/64 = 512Hz, fills up the 8-bit counter (256) once every half second
TCNT0 = 0; // Clear the counter
bitClear(GTCCR, TSM); // Turns timers back on
#ifdef DO_SIMAVR
GPIOR0 = SIMAVR_CMD_VCD_START_TRACE;
#endif
sei(); //We're done setting up, enable those interrupts again
}
@ -413,7 +431,7 @@ int main(void) {
setup();
for (;;) {
loop();
//loop();
}
return 0;

View File

@ -1,9 +1,9 @@
all: Mac128kRTC.axf MacPlusRTC.axf
Mac128kRTC.axf: MacRTC.cpp
Mac128kRTC.axf: MacRTC.c
avr-gcc -o $@ -Os -mmcu=attiny85 -DNoXPRAM=1 $<
MacPlusRTC.axf: MacRTC.cpp
MacPlusRTC.axf: MacRTC.c
avr-gcc -o $@ -Os -mmcu=attiny85 $<
clean: