예제 #1
0
void sendCommand2(unsigned short PESend, unsigned short SSSend)
{
    unsigned int sendVal;
    sendVal = (PESend << 16) | SSSend;

    while(SPI1STATbits.SPIBUSY);
    putcSPI1(sendVal);
}
예제 #2
0
/*********************************************************************
* Function:         BYTE SPIGet1(void)
*
* PreCondition:     SPI has been configured 
*
* Input:		    none
*
* Output:		    BYTE - the byte that was last received by the SPI
*
* Side Effects:	    none
*
* Overview:		    This function will read a byte over the SPI
*
* Note:			    None
********************************************************************/
BYTE SPIGet1(void)
{
    #if defined(__PIC32MX__)
        BYTE dummy;
        putcSPI1(0x00);
        dummy = (BYTE)getcSPI1();
        return(dummy);
    #else
        SPIPut1(0x00);
        return SPI1BUF;
    #endif  
}
예제 #3
0
/*********************************************************************
* Function:         void SPIPut1(BYTE v)
*
* PreCondition:     SPI has been configured 
*
* Input:		    v - is the byte that needs to be transfered
*
* Output:		    none
*
* Side Effects:	    SPI transmits the byte
*
* Overview:		    This function will send a byte over the SPI
*
* Note:			    None
********************************************************************/
void SPIPut1(BYTE v)
{
    BYTE dummy;
    
    #if defined(__PIC32MX__)
        putcSPI1(v);
        dummy = (BYTE)getcSPI1();        
    #else
        IFS0bits.SPI1IF = 0;
        dummy = SPI1BUF;
        SPI1BUF = v;
        while(IFS0bits.SPI1IF == 0){}
    #endif
}
예제 #4
0
파일: SPI.c 프로젝트: gpeal/Sherman
void WriteSPI(char c)
{
    int receive, i;
    //send character
    putcSPI1(c);
    //wait
    for(i = 0; i < 1000000; i++) {}
    ///Clear interrupt flags (Tx / Rx buffers empty)
    SpiChnClrIntFlags(1); 
    //Read SP1BUF (dummy read)
    receive = SPI1BUF;
    //Write SP1BUF- sets Tx flag, if not done read will not clock
    SPI1BUF = 0x0;
    //Generates clock and reads SDO
    receive = getcSPI1();
    
}