parameters bits 3..0: baud
0: 9600, 1: 19200, 2: 38400, 3: 57600, 4: 115200
parameters bits 15..14: parity
0: no parity, 1: even parity, 2: odd parity
parameters bits 13..12: stop bits
0: one stop bit, 1: two stop bits
parameters bits 7..4: mode[0] (see 0x0418)
0: mode[0]=0, 1: mode[0]=1
returns
0 : no error
4 : comm already open
0x12 : invalid parameter
0x05 : serial already open
else 0x09
Opens the serial interface with 57600 baud, 8bit, even
par and 1 stop bit.
Resets the serial interrupt handlers to default and
disables the serial hardware.
Get serial interrupt handlers
type=0: return the pointer to the receive interrupt handler
type=1: return the pointer to the transmit interrupt handler
type=2: return the pointer to the reset receive errors interrupt
handler
type=3: return the pointer to the reset transmit errors interrupt
handler
actually the default error reset handlers are both identical.
Set serial interrupt handler
if handler is zero, the default handlers are installed.
type=0: install receive interrupt handler
type=1: install transmit interrupt handler
type=2: install reset receive errors interrupt handler
type=3: install reset transmit errors interrupt handler
returns the content of register SCSCR_2.
actually the default serial error reset handlers are both identical.
Fetches one byte from the serial receive buffer into
result.
returns
0 if successful,
1 if no byte is available
3 if the serial channel is not open.
Fetches at most max_size bytes from the serial
receive buffer into result.
The count of actually transferred bytes is reported in
actually_transferred.
returns
0 if successful,
1 if no byte is available
3 if the serial channel is not open.
Puts one byte into the serial transmit buffer.
returns
0 if successful,
2 if no space is available in the serial interrupt transmit buffer (256 bytes
max)
3 if the serial channel is not open.
Puts requested_count bytes from the array
bytes_to_transmit into the serial transmit buffer, if space allows.
returns
0 if successful,
2 if no space is available in the serial interrupt transmit buffer (256 bytes
max)
3 if the serial channel is not open.
Puts byte_to_transmit into the serial transmit
FIFO, if it is empty!
0 if successful,
1 if the FIFO is not empty
3 if the serial channel is not open.
returns the count of received bytes available.
returns the free space in the transmit buffer.
Clears the serial receive buffer.
returns
0 if successful,
3 if the serial channel is not open.
Remark: the serial interrupt receive buffer accepts 1024 bytes at most.
Clears the serial transmit buffer.
returns 0 in any case
mode points to an array that holds the 6 bytes
controlling the settings for the serial interface.
mode[0]: 0x00 (mode[0]!=0 sets some serial parameters like
baud and then quits with result=4;
at present I can't figure out the function of mode[0]!=0, possibly
the change of parameters of an open serial channel.
MayBe it is connected with the "set link settings"-command of the FX
communication protocol.
mode[1]: 0=300, 1=600, 2=1200, 3=2400, 4=4800, 5=9600, 6=19200,
7=38400, 8=57600, 9=115200 baud
mode[2]: parity: 0=no; 1=odd; 2=even
mode[3]: datalength: 0=8 bit; 1=7 bit
mode[4]: stop bits: 0=one; 1=two
mode[5]: this parameter is not used by 0x418 at present. Functions
inside the OS which use 0x418 set it to 0, though.
returns
0 if successful
3 if already open
4 if mode[0]!=0
Resets all buffers; disables the corresponding hardware
if mode=1 then Serial_Close does an immediate close, t. i. it does
not wait for pending transmissions.
if mode!=1 then Serial_Close quits returning code 5 if transmissions
are under way.
returns
0 if successful
5 if aware of pending transmissions and transmissions are under way
called via interrupt, usually not called directly
called via interrupt, usually not called directly
called via interrupt, usually not called directly
called via interrupt, usually not called directly
The byte at the position byteno_to_spy in the
serial receive buffer is returned in result.
byteno_to_spy starts at 0! This function spies, it does not remove
any byte.
returns
0 if successful,
1 if the required count of bytes is not available
3 if the serial channel is not open.
Fetches the serial status into serial_status.
ORER 0x40 overrun error
ER 0x01 receive error
TEND 0x02 transmit end
TDFE 0x04 transmit FIFO data empty
BRK 0x08 break detect
FER 0x10000 framing error
PER 0x20000 parity error
RDF 0x10 receive FIFO full
DR 0x20 receive data ready
returns 3 if not open
returns 1 if open
(02.06.2012 15:39:51)