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