added stdc time support
[fw/sdcc] / device / include / tinibios.h
1 #ifndef TINIBIOS_H
2
3 #define TINIBIOS_H
4
5 #include <ds80c390.h>
6 #include <time.h>
7
8 #define Serial0GetChar getchar
9 #define Serial0PutChar putchar
10
11 void Serial0Init (unsigned long baud, unsigned char buffered);
12 char Serial0GetChar(void);
13 void Serial0PutChar(char);
14 char Serial0CharArrived(void);
15 void Serial0Baud(unsigned long baud);
16 void Serial0SendBreak(void);
17 void Serial0Flush(void);
18
19 void Serial1Init (unsigned long baud, unsigned char buffered);
20 char Serial1GetChar(void);
21 void Serial1PutChar(char);
22 char Serial1CharArrived(void);
23 void Serial1Baud(unsigned long baud);
24 void Serial1SendBreak(void);
25 void Serial1Flush(void);
26
27 unsigned long ClockTicks();
28 void ClockMilliSecondsDelay(unsigned long ms);
29 void ClockMicroSecondsDelay(unsigned int us);
30
31 #define SERIAL_0_BAUD 115200L
32 #define SERIAL_1_BAUD 9600L
33
34 // these need to be binary numbers
35 #define SERIAL_0_RECEIVE_BUFFER_SIZE 1024
36 #define SERIAL_1_RECEIVE_BUFFER_SIZE 64
37
38 // I know someone is fooling with the crystals
39 #define OSCILLATOR 18432000L
40
41 /* Set the cpu speed in clocks per machine cycle, valid values are:
42    1024: Divide-by-1024 (power management) mode (screws ALL timers and serial)
43       4: Standard 8051 divide-by-4 mode
44       2: Use 2x xtal multiplier 
45       1: Use 4x xtal multiplier (Don't do this with a TINI at 18.432MHz)
46 */
47 #define CPU_SPEED 2
48 void CpuSpeed(unsigned int speed);
49
50 // The MOVX stretch cycles, see datasheet
51 #define CPU_MOVX_STRETCH 0x01
52
53 // from rtc390.c
54 #define HAVE_RTC
55 unsigned char RtcRead(struct tm *rtcDate);
56 void RtcWrite(struct tm *rtcDate);
57
58 // from lcd390.c
59 extern void LcdInit(void);
60 extern void LcdOn(void);
61 extern void LcdOff(void);
62 extern void LcdClear(void);
63 extern void LcdHome(void);
64 extern void LcdGoto(unsigned int collumnRow);
65 extern void LcdPutChar(char c);
66 extern void LcdPutString(char *string);
67 extern void LcdLPutString(unsigned int collumnRow, char *string);
68 extern void LcdPrintf(xdata const char *format, ...) reentrant;
69 extern void LcdLPrintf(unsigned int collumnRow, xdata const char *format, ...) reentrant;
70
71 // from i2c390.c
72 #define I2C_BUFSIZE 128
73 extern char I2CReset(void);
74 extern char I2CStart(void);
75 extern char I2CStop(void);
76 extern char I2CSendStop(char addr, char count, 
77                         char send_stop);
78 extern char I2CReceive(char addr, char count);
79 extern char I2CSendReceive(char addr, char tx_count, 
80                            char rx_count);
81 //extern char I2CByteOut(char);
82 //extern void I2CDumpError(char);
83
84 /* global transfer buffers */
85 extern char i2cTransmitBuffer[I2C_BUFSIZE];
86 extern char i2cReceiveBuffer[I2C_BUFSIZE];
87
88 // Macro for normal send transfer ending with a stop condition
89 #define I2CSend(addr, count)   I2CSendStop(addr, count, 1)
90
91
92 // internal functions used by tinibios.c
93 unsigned char _sdcc_external_startup(void);
94 void Serial0IrqHandler (void) interrupt 4;
95 void Serial1IrqHandler (void) interrupt 7;
96 void ClockInit();
97 void ClockIrqHandler (void) interrupt 1;
98
99 #endif TINIBIOS_H