8 #define Serial0GetChar getchar
9 #define Serial0PutChar putchar
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);
19 void Serial0SwitchToBuffered(void); // ds400 only.
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);
29 unsigned long ClockTicks();
30 void ClockMilliSecondsDelay(unsigned long ms);
31 void ClockMicroSecondsDelay(unsigned int us);
33 #define SERIAL_0_BAUD 115200L
34 #define SERIAL_1_BAUD 9600L
36 // these need to be binary numbers
37 #define SERIAL_0_RECEIVE_BUFFER_SIZE 1024
38 #define SERIAL_1_RECEIVE_BUFFER_SIZE 64
40 // I know someone is fooling with the crystals
41 #if defined(SDCC_ds400)
42 # define OSCILLATOR 14745600L
44 # define OSCILLATOR 18432000L
47 /* Set the cpu speed in clocks per machine cycle, valid values are:
48 1024: Divide-by-1024 (power management) mode (screws ALL timers and serial)
49 4: Standard 8051 divide-by-4 mode
50 2: Use 2x xtal multiplier
51 1: Use 4x xtal multiplier (Don't do this with a TINI at 18.432MHz)
54 void CpuSpeed(unsigned int speed);
56 // The MOVX stretch cycles, see datasheet
57 #define CPU_MOVX_STRETCH 0x01
61 unsigned char RtcRead(struct tm *rtcDate);
62 void RtcWrite(struct tm *rtcDate);
65 extern void LcdInit(void);
66 extern void LcdOn(void);
67 extern void LcdOff(void);
68 extern void LcdClear(void);
69 extern void LcdHome(void);
70 extern void LcdGoto(unsigned int collumnRow);
71 extern void LcdPutChar(char c);
72 extern void LcdPutString(char *string);
73 extern void LcdLPutString(unsigned int collumnRow, char *string);
74 extern void LcdPrintf(const char *format, ...) reentrant;
75 extern void LcdLPrintf(unsigned int collumnRow, const char *format, ...) reentrant;
78 #define I2C_BUFSIZE 128
79 extern char I2CReset(void);
80 extern char I2CStart(void);
81 extern char I2CStop(void);
82 extern char I2CSendStop(char addr, char count,
84 extern char I2CReceive(char addr, char count);
85 extern char I2CSendReceive(char addr, char tx_count,
87 //extern char I2CByteOut(char);
88 //extern void I2CDumpError(char);
90 /* global transfer buffers */
91 extern char i2cTransmitBuffer[I2C_BUFSIZE];
92 extern char i2cReceiveBuffer[I2C_BUFSIZE];
94 // Macro for normal send transfer ending with a stop condition
95 #define I2CSend(addr, count) I2CSendStop(addr, count, 1)
98 // internal functions used by tinibios.c
99 unsigned char _sdcc_external_startup(void);
100 void Serial0IrqHandler (void) interrupt 4;
101 void Serial1IrqHandler (void) interrupt 7;
103 #if !defined(SDCC_ds400)
105 void ClockIrqHandler (void) interrupt 1 _naked;
108 #if defined(SDCC_ds400)
109 // functions for dealing with the ds400 ROM firmware.
111 // A wrapper which calls rom_init allocating all available RAM in CE0
112 // to the heap, sets the serial port to SERIAL_0_BAUD, sets up the
113 // millisecond timer, and diddles the clock multiplier.
115 // Values for the romInit "speed" parameter.
116 #define SPEED_1X 0 /* no clock multiplier, normal speed. */
117 #define SPEED_2X 1 /* 2x clock multiplier. */
118 #define SPEED_4X 2 /* 4x clock, DOESN'T WORK ON TINIm400! */
120 unsigned char romInit(unsigned char noisy,
123 // Install an interrupt handler.
124 void installInterrupt(void (*isrPtr)(void), unsigned char offset);
128 #endif /* TINIBIOS_H */