git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4106 4a8a32a2...
[fw/sdcc] / device / include / tinibios.h
index 3e9bd3ccd9638bdf67e20d60e3ff0d6c8601290c..8c192745dcaa421447c83c460ca7ececa201cf66 100755 (executable)
@@ -3,6 +3,7 @@
 #define TINIBIOS_H
 
 #include <ds80c390.h>
+#include <time.h>
 
 #define Serial0GetChar getchar
 #define Serial0PutChar putchar
@@ -15,6 +16,8 @@ void Serial0Baud(unsigned long baud);
 void Serial0SendBreak(void);
 void Serial0Flush(void);
 
+void Serial0SwitchToBuffered(void); // ds400 only.
+
 void Serial1Init (unsigned long baud, unsigned char buffered);
 char Serial1GetChar(void);
 void Serial1PutChar(char);
@@ -35,7 +38,11 @@ void ClockMicroSecondsDelay(unsigned int us);
 #define SERIAL_1_RECEIVE_BUFFER_SIZE 64
 
 // I know someone is fooling with the crystals
-#define OSCILLATOR 18432000L
+#if defined(SDCC_ds400)
+# define OSCILLATOR 14745600L
+#else
+# define OSCILLATOR 18432000L
+#endif
 
 /* Set the cpu speed in clocks per machine cycle, valid values are:
    1024: Divide-by-1024 (power management) mode (screws ALL timers and serial)
@@ -50,13 +57,9 @@ void CpuSpeed(unsigned int speed);
 #define CPU_MOVX_STRETCH 0x01
 
 // from rtc390.c
-static struct RTCDate{
-  int year;
-  unsigned char month, day, weekDay, hour, minute, second, hundredth;
-};
-
-unsigned char RtcRead(struct RTCDate *rtcDate);
-void RtcWrite(struct RTCDate *rtcDate);
+#define HAVE_RTC
+unsigned char RtcRead(struct tm *rtcDate);
+void RtcWrite(struct tm *rtcDate);
 
 // from lcd390.c
 extern void LcdInit(void);
@@ -68,8 +71,8 @@ extern void LcdGoto(unsigned int collumnRow);
 extern void LcdPutChar(char c);
 extern void LcdPutString(char *string);
 extern void LcdLPutString(unsigned int collumnRow, char *string);
-extern void LcdPrintf(xdata const char *format, ...) reentrant;
-extern void LcdLPrintf(unsigned int collumnRow, xdata const char *format, ...) reentrant;
+extern void LcdPrintf(const char *format, ...) __reentrant;
+extern void LcdLPrintf(unsigned int collumnRow, const char *format, ...) __reentrant;
 
 // from i2c390.c
 #define I2C_BUFSIZE 128
@@ -94,9 +97,32 @@ extern char i2cReceiveBuffer[I2C_BUFSIZE];
 
 // internal functions used by tinibios.c
 unsigned char _sdcc_external_startup(void);
-void Serial0IrqHandler (void) interrupt 4;
-void Serial1IrqHandler (void) interrupt 7;
+void Serial0IrqHandler (void) __interrupt 4;
+void Serial1IrqHandler (void) __interrupt 7;
+
+#if !defined(SDCC_ds400)
 void ClockInit();
-void ClockIrqHandler (void) interrupt 1;
+void ClockIrqHandler (void) __interrupt 1 __naked;
+#endif
+
+#if defined(SDCC_ds400)
+// functions for dealing with the ds400 ROM firmware.
+
+// A wrapper which calls rom_init allocating all available RAM in CE0
+// to the heap, sets the serial port to SERIAL_0_BAUD, sets up the 
+// millisecond timer, and diddles the clock multiplier.
+
+// Values for the romInit "speed" parameter.
+#define SPEED_1X       0 /* no clock multiplier, normal speed. */
+#define SPEED_2X       1 /* 2x clock multiplier. */
+#define SPEED_4X       2 /* 4x clock, DOESN'T WORK ON TINIm400! */
+
+unsigned char romInit(unsigned char noisy,
+                     char speed);
+
+// Install an interrupt handler.
+void installInterrupt(void (*isrPtr)(void), unsigned char offset);
+#endif
+
 
-#endif TINIBIOS_H
+#endif /* TINIBIOS_H */