|
| void | rifastseriallib_codeinit (void) |
| void | rifastseriallib_codefinit (void) |
| void | initserialio (void) |
| void | finitserialio (void) |
| void | setserialmode (void) |
| void | endserialio (void) |
| void | putserial (void) |
| void | putserial2 (void) |
| void | getserial (void) |
| void | getserial2 (void) |
| void | flushserialio (void) |
| void | syncserial (void) |
| void | doserialIO2 (void) |
| void | doserialIO (void) |
| void | setiobuf (void) |
| void | setiospeed (void) |
| void | setiosize (void) |
| void | checkserial (void) |
| void | syncput (void) |
| void | syncget (void) |
| static void | writebyte (UBYTE b) |
| static UBYTE | readbyte (void) |
| static ULONG | udiv (ULONG n, ULONG d) |
| static void | setbaud (ULONG baud) |
| void | c_codeinit (void) |
| | init: the state as at the load: slave, not initialised, no buffers.
|
| void | c_finitserialio (void) |
| | FinitSerialIO (and finit): end the serial I/O, switch TBE/RBF back on.
|
| void | c_doserialIO (UWORD n) |
| | DoSerialIO numbytes-1: exchange the buffers byte by byte.
|
| void | c_doserialIO2 (void) |
| | DoSerialIO: c_doserialIO() with the count of InitSerialIO/SetIOSize.
|
| ULONG | c_initserialio (ULONG baud, UWORD numbytes, UBYTE *inbuf, UBYTE *outbuf) |
| | InitSerialIO baud,numbytes,inbuf,outbuf: set up the serial port for the transfers.
|
| void | c_setserialmode (UBYTE mode) |
| | SetSerialMode mode: master (<> 0) or slave (0) for DoSerialIO.
|
| void | c_endserialio (void) |
| | EndSerialIO: "disable serial read/write" - does nothing (an RTS).
|
| void | c_putserial (UBYTE b) |
| | PutSerial byte: send one byte (through bytebuf).
|
| void | c_putserial2 (const UBYTE *p, ULONG n) |
| | PutSerial address,bytes: send a block of bytes.
|
| ULONG | c_checkserial (void) |
| | CheckSerial: the received byte, without waiting.
|
| ULONG | c_getserial (void) |
| | GetSerial: wait for a byte and return it (through bytebuf).
|
| ULONG | c_getserial2 (UBYTE *p, ULONG n) |
| | GetSerial address,bytes: receive a block of bytes.
|
| void | c_flushserialio (void) |
| | FlushSerialIO: "make sure serial port is empty" - acknowledge RBF in INTREQ.
|
| void | c_syncput (const UBYTE *p, ULONG n) |
| | SyncPut address,bytes: send bytes, each paced by the other side's answer.
|
| void | c_syncget (UBYTE *p, ULONG n) |
| | SyncGet address,bytes: receive bytes, answering each one.
|
| BB_BOOL | c_syncserial (UBYTE sync) |
| | SyncSerial syncbyte: synchronise with the other machine, deciding master and slave.
|
| void | c_setiospeed (UWORD baud) |
| | SetIOSpeed baudrate: a new baud rate (SERPER) if initialised.
|
| void | c_setiosize (UWORD n) |
| | SetIOSize bytes: the count of DoSerialIO without argument.
|
| void | c_setiobuf (UBYTE *in, UBYTE *out) |
| | SetIOBuffers inbuf,outbuf: the buffers of DoSerialIO.
|
init: the state as at the load: slave, not initialised, no buffers.
Fixed (#1159): the original's init was empty, so a second run of a program with the library still loaded (from the editor) started with the mode, count, buffers and saved INTENAR of the run before (a program that never calls SetSerialMode was the master in its second run if the first ended as master).
| void c_finitserialio |
( |
void | | ) |
|
FinitSerialIO (and finit): end the serial I/O, switch TBE/RBF back on.
Nothing if not initialised; else baud = 0 and the RBF (bit 11) and TBE (bit 0) interrupts that were on at InitSerialIO (the saved inten) are switched on again in INTENA. Fixed (#651, #648): the original saved the address of INTENAR ($F01C, bits 11 and 0 clear), so it never wrote, and its write went to the absolute address $9A instead of INTENA.
| ULONG c_initserialio |
( |
ULONG | baud, |
|
|
UWORD | numbytes, |
|
|
UBYTE * | inbuf, |
|
|
UBYTE * | outbuf ) |
InitSerialIO baud,numbytes,inbuf,outbuf: set up the serial port for the transfers.
Nothing if already initialised or the baud rate is not between 109 and 3546895 (fixed (#653): the original divided by 0 for baud 0, a rate above 3546895 gave SERPER $FFFF, one below 109 one in the 16th bit, the LONG flag). Switches the TBE and RBF interrupts off (INTENA $0801), sets SERPER = 3546895 / baud - 1 (fixed (#647): a division that works on a 68000, the original's DIVU.L is a 68020 instruction), and stores numbytes - 1 and the buffers (numbytes 0 gives NOBYTES: DoSerialIO without argument transfers nothing, fixed (#1164)). Fixed (#651): inten gets INTENAR's value, the original the immediate $F01C (the address of INTENAR). Fixed (#653): the library is initialised also with SERPER 0 (3546895 baud), which the original took for "not initialised".
- Parameters
-
- Returns
- d0: -1 when it set the port up, 0 when it did nothing (fixed (#650): the original returned the baud argument in both cases)
| void c_setiosize |
( |
UWORD | n | ) |
|
SetIOSize bytes: the count of DoSerialIO without argument.
Stored as count - 1 for DoSerialIO's DBRA loop, as InitSerialIO stores its numbytes. Fixed (#1158): the original stored the count as it is, so DoSerialIO transferred one byte more than SetIOSize said. A count of 0 gives NOBYTES: DoSerialIO without argument transfers nothing (fixed, #1164).
- Parameters
-
| void c_setiospeed |
( |
UWORD | baud | ) |
|
SetIOSpeed baudrate: a new baud rate (SERPER) if initialised.
Fixed (#653): nothing for a rate below 109 (the original wrote a SERPER with the LONG flag, or divided by 0), and the library is initialised also after SERPER 0. The division as in InitSerialIO (fixed, #647). Fixed (#654): it divides by the word argument alone, the original by all of d0, also its undefined upper word.
- Parameters
-
SyncSerial syncbyte: synchronise with the other machine, deciding master and slave.
A byte already waiting makes this side the slave: it waits for the sync byte, echoes it and reads until a 0 arrives. Otherwise it is the master: it sends the sync byte until it comes back, then sends 0 and flushes. BUG(orig) (#655), wontfix: two machines starting at the same time both become master (each takes the other's sync byte for the echo); see the file's head. BB_FALSE if not initialised (fixed (#652): the original ran on the port).
- Parameters
-
- Returns
- d0: BB_TRUE = master, BB_FALSE = slave (a word result)