subtitle "uart_lib.h by L. Wyard-Scott" ;;; ********************************************************************* ;;; Filename: uart_lib.h ;;; Purpose: UART library routine headers and other library equates. ;;; Revision: 0.4 ;;; Date: 24 February 2005 ;;; Author: L. Wyard-Scott ;;; Copyright: Public Domain ;;; ********************************************************************* ;;; Revision History: ;;; 0.4 No update. ;;; 0.3 No update. ;;; 0.2 24 February 2005 - LWS ;;; - Updated to specify baudrates for various crystals. ;;; Now an "FXTAL" define is required on the command line. ;;; 0.1 No update. ;;; 0.0 20 October 2002 - LWS ;;; Creation. ;;; ********************************************************************* ;;; ********************************************************************* ;;; Ideas for future work: ;;; - add equates for baudrates with other crystals. ;;; ********************************************************************* ;;; Ensure that the crystal frequency has been specified on the ;;; assembler command line. ifndef FXTAL error "Timing element frequency not specified on command line." error "Possible values for FXTAL are:" error "3 --> 3.57945 MHz" error "4 --> 4.00 MHz" error "5 --> 5.0688 MHz" error "7 --> 7.15909 MHz" error "10 --> 10.00 MHz" error "12 --> 12.00 MHz" error "16 --> 16.00 MHz" error "20 --> 20.00 MHz" endif ;;; Since not all baudrates are supported at all timing element ;;; frequencies, not all of the rates are made available. This ;;; is the implicit checking of available baudrates, referred to ;;; in uart_lib.asm if (FXTAL == 3) BAUD_300 EQU 0 BAUD_1200 EQU 2 BAUD_2400 EQU 4 BAUD_4800 EQU 6 BAUD_9600 EQU 8 endif if (FXTAL == 4) BAUD_300 EQU 0 BAUD_1200 EQU 2 BAUD_2400 EQU 4 BAUD_4800 EQU 6 BAUD_9600 EQU 8 BAUD_19200 EQU 10 endif if (FXTAL == 5) BAUD_1200 EQU 2 BAUD_2400 EQU 4 BAUD_4800 EQU 6 BAUD_9600 EQU 8 endif if (FXTAL == 7) BAUD_1200 EQU 2 BAUD_2400 EQU 4 BAUD_4800 EQU 6 BAUD_9600 EQU 8 BAUD_19200 EQU 10 endif if (FXTAL == 10) BAUD_1200 EQU 2 BAUD_2400 EQU 4 BAUD_4800 EQU 6 BAUD_9600 EQU 8 BAUD_19200 EQU 10 BAUD_38400 EQU 14 BAUD_57600 EQU 16 endif if (FXTAL == 12) BAUD_1200 EQU 2 BAUD_2400 EQU 4 BAUD_4800 EQU 6 BAUD_9600 EQU 8 BAUD_19200 EQU 10 BAUD_33600 EQU 12 BAUD_57600 EQU 16 endif if (FXTAL == 16) BAUD_1200 EQU 2 BAUD_2400 EQU 4 BAUD_4800 EQU 6 BAUD_9600 EQU 8 BAUD_19200 EQU 10 BAUD_33600 EQU 12 BAUD_38400 EQU 14 endif if (FXTAL == 20) BAUD_1200 EQU 2 BAUD_2400 EQU 4 BAUD_4800 EQU 6 BAUD_9600 EQU 8 BAUD_19200 EQU 10 BAUD_33600 EQU 12 BAUD_38400 EQU 14 BAUD_57600 EQU 16 endif ;;; -------------------------------------------------------------------- ;;; Macros. (File-specific) ;;; -------------------------------------------------------------------- ;;; --------------------------------------------------------------------- ;;; Externally defined variables. ;;; --------------------------------------------------------------------- extern PTRHIGH ; Pointer passing for UART_TxStringKx extern PTRLOW ; string constant transmission. ;;; --------------------------------------------------------------------- ;;; Externally defined subroutines. ;;; --------------------------------------------------------------------- extern UART_Init ; Initialize the UART. extern UART_RxByte ; Receive a byte through the UART. extern UART_KbHit ; Determine if a byte has been received. extern UART_TxByte ; Transmit a byte through the UART. extern UART_TxStringK ; Transmit a NULL-terminated string ; constant. extern UART_TxStringKN ; Transmit N bytes of a string (or data). ; Will transmit a NULL, if encountered. extern UART_TxString ; Transmit a NULL-terminated string ; in RAM. extern UART_TxStringN ; Transmit N characters of a string ; out through the UART. Will transmit ; NULLS, if encountered. extern UART_RxString ; Receive and NULL-terminate a string.