; ***************************************************************
; * Copyright (C) 2002, Embed Inc (http://www.embedinc.com) *
; * *
; * Permission to copy this file is granted as long as this *
; * copyright notice is included in its entirety at the *
; * beginning of the file, whether the file is copied in whole *
; * or in part and regardless of whether other information is *
; * added to the copy. *
; * *
; * The contents of this file may be used in any way, *
; * commercial or otherwise. This file is provided "as is", *
; * and Embed Inc makes no claims of suitability for a *
; * particular purpose nor assumes any liability resulting from *
; * its use. *
; ***************************************************************
;
; Include file for the HOS PIC application.
;
; This is a sample PIC application that communicates with a host
; computer. The host sends commands, and the PIC sends responses.
; See the CMD module for a list of the commands, their parameters,
; responses.
;
; The host communication is via RS-232, 115.2Kbaud, 8 data bits,
; 1 stop bit, no parity, no flow control.
;
include "hoslib.inc"
;
; Application configuration parameters
;
gbank equ 0 ;direct register bank for global variables
;
; Derived constants.
;
gbankadr equ bankadr(gbank) ;address within reg bank for global variables
;
; Response byte values. Responses are sent to the host over the serial
; line. Some of these may be sent asynchronously, and not really
; in response to anything sent by the host.
;
; Multi-byte numeric parameters following response codes are sent in
; least to most significant byte order.
;
rsp_ack equ 1 ;last command acknowledged, clear to send next
;
;**********
;
; Global flag bits. As many GFL0 thru GFLn variables as needed are
; automatically created by the /FLAG preprocessor directive. After all
; flags are defined, NFLAGB will be left indicating the number of GFLx
; variables created. For each flag, the following assembler symbols
; will be defined:
;
; flag_<name>_regn - 0-N GFLn variable number containing the flag
; flag_<name>_bit - 0-7 flag bit number within its GFLn variable
; flag_<name> - string substitution macro gfl<n>,<bit>. This
; symbol can be used directly with bit manupulation
; instructions.
;
; See the PREPIC documentation file for details of the /FLAG directive.
;
/flag sin ;a serial line input byte is available
/flag sout ;serial output can accept another byte
;
;**********
;
; I/O pin declarations. /INBIT and /OUTBIT are preprocessor
; directives. Each one defines a single I/O pin. See the PREPIC
; documentation file for details. Briefly, the directives are:
;
; /INBIT <name> <port> <bit>
; /OUTBIT <name> <port> <bit> [<initial value>]
;
; The following assembler symbols will be defined for each /INBIT
; and /OUTBIT:
;
; <name>_reg - Address of port register containing the bit.
; <name>_tris - Address of TRIS register for the port.
; <name>_bit - 0-7 bit number withing the port.
; <name>_pin - String substitution macro for the port register
; and the I/O bit number. This symbol can be used
; directly with bit manipulation instructions.
;
; The ports are initialized in the PORT module according to the I/O
; bit definitions here.
;
portbpullups equ true ;the port B weak pullups will be enabled
/inbit ex1 porta 0 ;example input bit, port A bit 0
/outbit ex2 porta 1 0 ;example output bit, port A bit 1, initial value = 0
/outbit led portb 0 1 ;0 = LED on, 1 = LED off
/inbit tx portc 6 ;UART output, must be declared as input
/inbit rx portc 7 ;UART input, must be declared as input
;
;***********************************************************************
;
; Macro PUTBYTE <bval>
;
; Send the byte BVAL to the host. This is a simple convenience wrapper
; that sets REG0 to the byte value, then calls UART_PUT. REG0 is trashed.
;
putbyte macro bval
movlw (bval) ;get the byte value into W
movwf reg0 ;pass it in REG0
gcall uart_put ;send it to the host
endm