…on a 68K Palm.
The description below applies to a lot of different platforms. But, for now, Redeye only uses this method on DragonBall (68K) based Palms. To print from other Palm devices, Redeye uses OrLib, a third-party library. (See Help!)
Redeye is able to send a carrier signal on hardware that was designed to send carrier-free IrDA. To do this, it does two things:
- Puts the UART into NRZ mode (to send full bit-time pulses instead of the 3/16th pulses used with IrDA)
- Disconnects the UART from the infrared diode during silent periods (to prevent start bits from interrupting the silence)
And the source code is portable! Just kidding.1 Palms use several different microprocessors, even switching from the original Motorola/Freescale DragonBall 68K architecture to newer ARM processors (such as Texas Instruments OMAP and Intel XScale). Also, different devices use different infrared transceiver modules (the actual hardware — an infrared LED emitter, an infrared phototransistor detector, and a little bit of circuitry). These transceiver modules may be connected to the microprocessor on different pins.
Redeye uses the Palm OS API's Serial Library to open the infrared port and initialize the UART's registers. But, it doesn't use the Serial Library to actually send any bytes. Instead, it manually feeds bytes into the UART's transmit FIFO (by writing them to the UTX register). This lets Redeye know exactly when each byte is sent. It can then silence out certain bytes by disconnecting the UART from the infrared diode.
An advantage of using the Serial Library to open the infrared port is that we only need to worry about one of the pins used to operate the infrared transceiver — the TxD pin on the DragonBall CPU. For example, we don't need to know what pin controls shutdown (SD), a power-saving mode that disables the whole transceiver module.
Using the UART means we don't have to set up and poll the timer registers. The UART takes care of all the timing, we merely need to set the baud rate in a call to SerOpen. We do lose a little flexibility though — we're limited to sending chunks of carrier signal that can be represented as a serial byte. For the 82240 printers though, this isn't a problem.