Labs/Lab6/Watkins_William_Lab6_Part2.c
// <editor-fold defaultstate="collapsed" desc="sendNext()">
/******************************************************************************
 * sendNext function
 *
 * Sends the next byte to be transmitted over EUSART
 ******************************************************************************/

sendNext function

Sends the next byte to be transmitted over EUSART
sendNext function Sends the next byte to be transmitted over EUSART
void sendNext() {
    if(sendTEMP == 1 && sendI < 6)
    {
        TXREG1 = tempSend[sendI];   
        sendI++;                    
    }
    else if(sendPOT == 1 && sendI < 6)
    {
        TXREG1 = potSend[sendI];    
        sendI++;                    
    }
    else if(sendCONT == 1 && sendI < 18)
    {
        TXREG1 = contSend[sendI];    
        sendI++;                    
    }
    else
    {
        sendTEMP = 0;
        sendPOT = 0;
        sendI = 0;
        PIE1bits.TX1IE = 0;             
    }
}
void sendNext ( ) { if ( sendTEMP == 1 && sendI < 6 ) { TXREG1 = tempSend [ sendI ] ; sendI ++ ; } else if ( sendPOT == 1 && sendI < 6 ) { TXREG1 = potSend [ sendI ] ; sendI ++ ; } else if ( sendCONT == 1 && sendI < 18 ) { TXREG1 = contSend [ sendI ] ; sendI ++ ; } else { sendTEMP = 0 ; sendPOT = 0 ; sendI = 0 ; PIE1bits . TX1IE = 0 ; } }
<editor-fold defaultstate="collapsed" desc="sendNext()">
 sendNext function
<editor - fold defaultstate = " collapsed " desc = " sendNext () " > sendNext function
// Since one command is assumed at a time, if-else-if is used // sendI indicates the byte to be sent // Load next byte into TXREG1 // Increment location of next byte // Load next byte into TXREG1 // Increment location of next byte // Load next byte into TXREG1 // Increment location of next byte // reset everything - a little inefficient, but it works // Disable EUSART1 Transmit interrupts // ^ Needed because otherwise the flag will continue to be set bc reg is empty