; @(#) clckin8a.asm 1.2@(#) ; Delta date: 11/06/03 ; Author: Mark Mraz ; ; The clock_in_8_a function is used to clock in 8 bits using two pins on ; port A. To use it, set ci8a_data_pin_mask to (1 << DATA_PIN) and ; set ci8a_clock_pin_mask to (1 << CLOCK_PIN). Load W with the value to ; clock in. ; This function uses 5 bytes of temporary data. It calls no functions. ; Note: This function assumes that neither the data pin nor the clock ; pin are high to begin with. ; INCLUDE "include.inc" NUM_BITS EQU 8 ; Number of bits to clock in INNERMOST_DATA UDATA_OVR value RES 1 ci8a_data_pin_mask RES 1 ci8a_clock_pin_mask RES 1 cnt RES 1 porta_off RES 1 global ci8a_data_pin_mask, ci8a_clock_pin_mask CLOCKIN8A_CODE CODE clock_in_8_a global clock_in_8_a movwf value ; Save the value temporarily movf PORTA, w movwf porta_off ; Save the current value of PORTA movlw NUM_BITS movwf cnt ; Set up the bit counter loop movf porta_off, w ; Start with the "empty" mask btfsc value, NUM_BITS - 1 ; If the high order bit is 1, iorwf ci8a_data_pin_mask, w ; OR in the data pin to the "empty" mask movwf PORTA ; Move the new mask to PORTA iorwf ci8a_clock_pin_mask, w ; OR in the clock pin movwf PORTA ; Move the clock and data bits to PORTA rlf value, f ; Shift the next data bit into place for sending xorwf ci8a_clock_pin_mask, w ; Lower the clock pin movwf PORTA decfsz cnt, f goto loop the_end movf porta_off, w ; Restore the original value of PORTA movwf PORTA return end