serial_hw_int_cts

serial_hw_int_cts.jal. Interrupt driven buffered serial interface with flow control.

Author Rob Hamerling, Copyright (c) 2008..2009, all rights reserved.
Adapted-by Joep Suijs
Compiler =2.4h

Description

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


Notes

 - 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
       var  bit  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


Dependencies


Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

Private

Functions

  • 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 than 
              bytes 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)
    
    
    


Related samples

Here are the list of samples which use this library:

16f648a16f648a_serial_hw_int_cts.jal
16f877a16f877a_serial_hw_int_cts.jal
16f8816f88_serial_hw_int_cts.jal
16f8816f88_serial_hw_int_cts_echo.jal
18f245018f2450_serial_hw_int_cts.jal
18f455018f4550_serial_hw_int_cts.jal