Author | Stef Mientki, Copyright © 2002..2006, all rights reserved. |
Adapted-by | Sebastien Lelong, Rob Hamerling |
Compiler | 2.4o |
USART hardware control. Routines for sending and receiving through the PIC-usart, both asynchronous and synchronous are supported. Baudrate can simply be set through a human constant, because the baudrate depending registers are calculated by this unit. Baudrate is calculated, starting at the high baudrate flag, which will ensure the highest possible accuracy. . TODO: should this be configurable ? Transmission parameters are 8 databits, 1 stopbit, no parity, no handshake.
- Pin selection is automatic: pin_TX and pin_RX. - Pin direction setting is taken care of by this 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_TX_RB2 and pin_RX_RB1 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_TX is pin_TX_RB2 alias pin_RX is pin_RX_RB1 alias pin_TX_direction is pin_TX_RB2_direction alias pin_RX_direction is pin_RX_RB1_direction
serial_hw_data'put(byte in data)
serial_hw_init()
serial_hw_write_word(word in data)
serial_hw_write(byte in data)
serial_hw_data_raw'put(byte in data)
serial_hw_enable()
serial_hw_disable()
serial_hw_read(byte out data) return bit
serial_hw_data'get() return byte
serial_hw_data_raw'get() return byte
serial_hw_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_hw_data =to transmit a byte to the seial port
serial_hw_init()
Title: Initialize the (first or only) serial port Arguments: (none) Returns: (nothing)
serial_hw_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_hw_write(byte in data)
Title: Transmit byte Arguments: Data (byte) to transmit Returns: (nothing) Notes: Hardware transmit buffer must be empty, wait if not
serial_hw_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_hw_enable()
Title: Enable USART Arguments: (none) Returns: (nothing) Notes: Re-enable USART after use of serial_hw_disable()
serial_hw_disable()
Title: Disable USART Arguments: (none) Returns: (nothing) Notes: Allows pins to be used (temporary) for other purposes. USART can be enabled again by calling serial_hw_enable()
serial_hw_read(byte out data) return bit
Title: Receive byte Arguments: (none) Returns: bit: TRUE data available FALSE no data available
serial_hw_data'get() return byte
Title: Receive byte Arguments: (none) Returns: Data (byte) received Notes: This pseudo variable allows a language construct like databyte = serial_hw_data to receive a byte from the serial port into variable 'databyte'
serial_hw_data_raw'get() return byte
No documentation found
_serial_hw_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!)