serial_hardware2

USART2 hardware control

Author Stef Mientki, Copyright © 2002..2006, all rights reserved.
Adapted-by Sebastien Lelong, Rob Hamerling.
Compiler 2.4o

Description

USART2 hardware control.
Routines for sending and receiving through the second [E]USART2


Notes

- See also the notes in serial_hardware library.
       - When the physical locations of pin_TX and pin_RX are configurable for
         a specific PIC, the device file will probably contain names like
         pin_TX2_RC2 and pin_RX2_RC1 and another pair with other pin suffixes.
         Depending for which pair of pins the USART is configured aliases
         without suffixes have to be specified, like:
             alias  pin_TX2            is  pin_TX2_RC2
             alias  pin_RX2            is  pin_RX2_RC1
             alias  pin_TX2_direction  is  pin_TX2_RC2_direction
             alias  pin_RX2_direction  is  pin_RX2_RC1_direction


Dependencies


Summary

Global variables/contants

Procedures

Functions

Private

API details

Global variables/contants

Procedures

  • serial_hw2_init()

    Title:     Initialize second serial port
    Arguments: (none)
    Returns:   (nothing)
    
    

  • serial_hw2_write(byte in data)

    Title:     Transmit character
    Arguments: Data (byte) to transmit
    Returns:   (nothing)
    Notes:     Hardware transmit buffer must be empty, wait if necessary
    
    

  • serial_hw2_enable()

    Title:     Enable USART2
    Arguments: (none)
    Returns:   (nothing)
    Title:     Re-enable USART after use of serial_hw2_disable()
    
    

  • serial_hw2_data_raw'put(byte in data)

    These are real raw procedures, declared as pseudo variables
    the user is totally responsible for testing the transmit/receive
    flag before using these functions
    

  • serial_hw2_data'put(byte in data)

    Title:     Transmit byte
    Arguments: Data (byte) to be transmitted
    Returns:   (nothing)
    Notes:     This pseudo variable allows a language construct like
    serial_hw2_data = 
    to transmit a byte to the seial port
    
    

  • serial_hw2_write_word(word in data)

    Title:     Transmit word
    Arguments: Data (word) to transmit
    Returns:   (nothing)
    Notes:     Send word as 2 bytes, Most Significant Byte first.
    See also serial_hw_write()
    
    

  • serial_hw2_disable()

    Title:     Disable USART2
    Arguments: (none)
    Returns:   (nothing)
    Notes:     Allows pins to be used (temporary) for other purposes.
    USART can be enabled again by calling serial_hw2_enable()
    
    

Functions

Private
  • _serial_hw2_read(byte out data) return bit

    Title:     Receive byte
    Arguments: (none)
    Returns:   bit:
      TRUE data available
      FALSE no data available
    Notes:     Using this inline function for serial_hw_data'get saves a stack level
    With overrun error the USART is reset (error(?)byte is returned!)
    
    



Related samples

Here are the list of samples which use this library:

16f194716f1947_serial_hardware2.jal
18f25k2218f25k22_eusart2.jal
18f27j5318f27j53_xbee_api_rx.jal
18f27j5318f27j53_pps_rx2tx2.jal
18f672218f6722_serial_hardware2.jal