Author | Rob Hamerling, Copyright (c) 2008..2009, all rights reserved. |
Adapted-by | Joep Suijs |
Compiler | =2.4h |
Serial communications: - receive and transmit data transfer is interrupt driven - receive and transmit data transfer uses circular buffers - automatic CTS flow control with spare free space for FiFo buffer
- For data transmit and receive the pins TX and RX are used automatically, these have not to be assigned by the application. - The selection of the CTS pin above is an example, any other pin which is configurable for output can be used. - When CTS flow control is not desired then assign serial_ctsinv to a dummy bit, for example: var bit dummy_cts_bit alias serial_ctsinv is dummy_cts_bit - The serial_overflow_discard flag may be dynamically changed (depending on how important the data is for the receiving party). - Do not touch the following interrupt bits: TXIE, RCIE, PEIE and GIE
var byte _serial_offsetxmthead -- offset next byte from appl
var byte _serial_rcvbuf[SERIAL_RCVBUFSIZE] -- circular input buffer
var byte _serial_offsetxmttail -- offset next byte to port
var byte _serial_offsetrcvhead -- offset next byte from port
var byte _serial_offsetrcvtail -- offset next byte to appl
var bit serial_send_success -- serial_send_success is used internally
var byte _serial_xmtbuf[SERIAL_XMTBUFSIZE] -- circular output buffer
serial_hw_read(byte out data) return bit
serial_hw_data'get() return byte
serial_receive_byte(byte out data) return bit
serial_send_byte(byte in data) return byte
var byte _serial_offsetxmthead -- offset next byte from appl
variable keeping track of next free position in transmit buffer
var byte _serial_rcvbuf[SERIAL_RCVBUFSIZE] -- circular input buffer
Local circular receive buffer
var byte _serial_offsetxmttail -- offset next byte to port
variable keeping track of next byte to be transmitted by interrupt handler
var byte _serial_offsetrcvhead -- offset next byte from port
variable keeping track of next free byte in receive buffer
var byte _serial_offsetrcvtail -- offset next byte to appl
variable keeping track of next byte available to application program
var bit serial_send_success -- serial_send_success is used internally
Flag indicating if transmission was successful
var byte _serial_xmtbuf[SERIAL_XMTBUFSIZE] -- circular output buffer
Local circular transmit buffer
serial_init()
Deprecated
serial_hw_data'put(byte in data)
Transmit byte
serial_hw_init()
serial_init - procedure to initialize library functionality
serial_hw_write(byte in data)
Transmit byte
_serial_transmit_interrupt_handler()
USART serial transmit interrupt handler
_serial_receive_interrupt_handler()
USART serial receive interrupt handler notes: - Sets CTS low when receive buffer has less thanbytes free space.
serial_hw_read(byte out data) return bit
Return byte (if any) from circular receive buffer for UART input: nothing output: received byte (if any) returns: TRUE when byte returned FALSE if no byte available notes: - Sets CTS high when receive buffer has more thanbytes free space after delivering byte to caller.
serial_hw_data'get() return byte
Return next received byte
serial_receive_byte(byte out data) return bit
Deprecated
serial_send_byte(byte in data) return byte
Put a single byte in circular transmit buffer for UART input: byte to transmit returns: transmitted byte (or 0x00 when data discarded) notes: - Activates transmit interrupt handler when data buffered - When buffer full act as indicated in 'serial_overflow_discard' * TRUE: discard data (and return 0x00 as data byte) * FALSE: wait for free buffer space (returns only after data has been stored in buffer)
16f648a | 16f648a_serial_hw_int_cts.jal |
16f723 | 16f723_serial_hw_int_cts.jal |
16f877a | 16f877a_serial_hw_int_cts.jal |
16f88 | 16f88_serial_hw_int_cts.jal |
16f88 | 16f88_serial_hw_int_cts_echo.jal |
18f14k50 | 18f14k50_serial_hw_int_cts.jal |
18f2450 | 18f2450_serial_hw_int_cts.jal |
18f4550 | 18f4550_serial_hw_int_cts.jal |