Author | Stef Mientki, Copyright (c) 2002..2006, all rights reserved. |
Adapted-by | Sebastien Lelong. |
Compiler | >=2.4g |
USART2 hardware control. Routines for sending and receiving through the EUSART2 (2nd EUSART module) both asynchrone and synchrone 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.
serial_hw2_init()
serial_hw2_write(byte in data)
serial_hw2_enable()
serial_hw2_data_raw'put(byte in data)
serial_hw2_data'put(byte in data)
serial_hw2_write_word(word in data)
serial_hw2_disable()
serial_hw2_data_raw'get() return byte
serial_hw2_data'get() return byte
serial_hw2_read(byte out data) return bit
serial_hw2_init()
Initializes the serial port, calculates baudrate registers.
serial_hw2_write(byte in data)
Write char to serial port, blocking Asynchronuous serial send routine, using the TX pin Sends byte X (8 bit with no parity) to the serial port First checks (and waits if necessary) if transmit buffer is empty
serial_hw2_enable()
Enables USART
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)
Here Serial read and write are definied as pseudo variables so you use them as normal vars, like * wait for character being received, * then echo the inverted character {{{ serial_hw2_data = ! serial_hw2_data }}} these procedures will wait till they can perform their action therefore it's better to use to following construct {{{ if charater received, echo the inverted character if serial_hw2_data_available then serial_hw2_data = ! serial_hw2_data end if do other things }}}
serial_hw2_write_word(word in data)
like Serial_H_write, but then with a word as input The MSB is outputed first
serial_hw2_disable()
Disables USART so ports can be used (temporary) for other purposes. USART can be enabled again by calling serial_hw2_enable()
serial_hw2_data_raw'get() return byte
No documentation found
serial_hw2_data'get() return byte
No documentation found
serial_hw2_read(byte out data) return bit
Read char if available (non-blocking) Returns true if a character was received, otherwise returns false. Overrun error flag is cleared.
_serial_hw2_read(byte out data) return bit
Internal use only! (using this inline function for serial_hw2_data'get saves a stack level) Returns true if a character was received, otherwise returns false. Overrun error flag is cleared.
18f25k22 | 18f25k22_eusart2.jal |
18f27j53 | 18f27j53_pps_rx2tx2.jal |