BurstSPI fork

Fork of BurstSPI by Erik -

BurstSPI_LPC_1549.cpp

Committer:
Backstrom
Date:
2015-04-03
Revision:
13:36ac5fd058dd
Child:
14:c99022511536

File content as of revision 13:36ac5fd058dd:

#if defined(TARGET_LPC1549)
#include "BurstSPI.h"

void BurstSPI::fastWrite(int data) {
    while (!(_spi.spi->STAT & (1 << 1)));

    _spi.spi->TXDAT = (data & 0xffff);
    // end of transfer
    _spi.spi->TXCTL |= ((1 << 20) | (1 << 22));
}

void BurstSPI::clearRX( void ) {
    //Do it while either data in RX buffer, or while it is busy
    while((_spi.spi->STAT & ((1 << 2) + (1 << 0))) != 0) {
        //Wait until data in RX buffer
        while((_spi.spi->STAT & (1 << 2)) == 0);
        int dummy = _spi.spi->RXDAT & 0xffff;
    }
}

#endif