/ MCUME_teensy / teensy64 / Teensy64.h
Teensy64.h
  1  /*
  2    Copyright Frank Bösing, 2017
  3  
  4    This file is part of Teensy64.
  5  
  6      Teensy64 is free software: you can redistribute it and/or modify
  7      it under the terms of the GNU General Public License as published by
  8      the Free Software Foundation, either version 3 of the License, or
  9      (at your option) any later version.
 10  
 11      Teensy64 is distributed in the hope that it will be useful,
 12      but WITHOUT ANY WARRANTY; without even the implied warranty of
 13      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14      GNU General Public License for more details.
 15  
 16      You should have received a copy of the GNU General Public License
 17      along with Teensy64.  If not, see <http://www.gnu.org/licenses/>.
 18  
 19      Diese Datei ist Teil von Teensy64.
 20  
 21      Teensy64 ist Freie Software: Sie können es unter den Bedingungen
 22      der GNU General Public License, wie von der Free Software Foundation,
 23      Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren
 24      veröffentlichten Version, weiterverbreiten und/oder modifizieren.
 25  
 26      Teensy64 wird in der Hoffnung, dass es nützlich sein wird, aber
 27      OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
 28      Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
 29      Siehe die GNU General Public License für weitere Details.
 30  
 31      Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
 32      Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
 33  
 34  */
 35  #ifndef Teensy64_h_
 36  #define Teensy64_h_
 37  
 38  #include <stdint.h>
 39  #include <stdio.h>
 40  #include <string.h>
 41  
 42  
 43  //#define F_CPU 600000000.0
 44  #define F_BUS 600000000.0
 45  
 46  #include "settings.h"
 47  
 48  #define VERSION "09"
 49  #define NTSC (!PAL)
 50  #define USBHOST (!PS2KEYBOARD)
 51  
 52  
 53  extern "C" {
 54    #include "emuapi.h"
 55  }
 56  
 57  #ifdef HAS_T4_VGA
 58  #include "vga_t_dma.h"
 59  #else
 60  #include "tft_t_dma.h"
 61  #endif
 62  extern TFT_T_DMA tft;  
 63  
 64  
 65  void initMachine();
 66  void resetMachine() __attribute__ ((noreturn));
 67  void resetExternal();
 68  unsigned loadFile(const char *filename);
 69  
 70  
 71  #if PAL == 1
 72  #define CRYSTAL       	17734475.0f
 73  #define CLOCKSPEED      ( CRYSTAL / 18.0f) // 985248,61 Hz
 74  #define CYCLESPERRASTERLINE 63
 75  #define LINECNT         312 //Rasterlines
 76  #define VBLANK_FIRST    300
 77  #define VBLANK_LAST     15
 78  
 79  #else
 80  #define CRYSTAL       	14318180.0f
 81  #define CLOCKSPEED      ( CRYSTAL / 14.0f) // 1022727,14 Hz
 82  #define CYCLESPERRASTERLINE 64
 83  #define LINECNT       	263 //Rasterlines
 84  #define VBLANK_FIRST    13
 85  #define VBLANK_LAST     40
 86  #endif
 87  
 88  #define LINEFREQ      			(CLOCKSPEED / CYCLESPERRASTERLINE) //Hz
 89  #define REFRESHRATE       		(LINEFREQ / LINECNT) //Hz
 90  #define LINETIMER_DEFAULT_FREQ (1000000.0f/LINEFREQ)
 91  
 92  
 93  #define MCU_C64_RATIO   ((float)F_CPU / CLOCKSPEED) //MCU Cycles per C64 Cycle
 94  #define US_C64_CYCLE    (1000000.0f / CLOCKSPEED) // Duration (µs) of a C64 Cycle
 95  
 96  #define AUDIOSAMPLERATE     (LINEFREQ * 2)// (~32kHz)
 97  
 98  #define ISR_PRIORITY_RASTERLINE   255
 99  
100  
101  
102  #if 0
103  #define WRITE_ATN_CLK_DATA(value) { \
104      digitalWriteFast(PIN_SERIAL_ATN, (~value & 0x08));\//PTA13 IEC ATN 3
105  digitalWriteFast(PIN_SERIAL_CLK, (~value & 0x10)); \ //PTA14 IEC CLK 4
106  digitalWriteFast(PIN_SERIAL_DATA, (~value & 0x20)); \ //PTA15 IEC DATA 5
107  }
108  #define READ_CLK_DATA() \
109    ((digitalReadFast(PIN_SERIAL_CLK) << 6) | \
110     (digitalReadFast(PIN_SERIAL_DATA) << 7))
111  
112  #else
113  #define WRITE_ATN_CLK_DATA(value) {}
114  #define READ_CLK_DATA() (0)
115  #endif
116  
117  #include "output_dac.h"
118  #include "cpu.h"
119  #endif