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