From: Nathael Pajani Date: Fri, 13 Dec 2013 10:18:58 +0000 (+0100) Subject: Export spi_transfer_single_frame() to "user" (code) space X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=de566c0ef3355d71fce43e638fcb8790119d41bf;p=soft%2Flpc122x%2Fcore Export spi_transfer_single_frame() to "user" (code) space --- diff --git a/drivers/ssp.c b/drivers/ssp.c index 574f6d2..d4dd498 100644 --- a/drivers/ssp.c +++ b/drivers/ssp.c @@ -114,7 +114,7 @@ uint16_t spi_transfer_single_frame(uint16_t data) struct lpc_ssp* ssp = LPC_SSP0; ssp->data = data; /* Wait until the busy bit is cleared */ - do {} while (ssp->status & LPC_SSP_ST_BUSY); + while (ssp->status & LPC_SSP_ST_BUSY); return ssp->data; } diff --git a/include/drivers/ssp.h b/include/drivers/ssp.h index cfc7e2e..a46463a 100644 --- a/include/drivers/ssp.h +++ b/include/drivers/ssp.h @@ -37,6 +37,18 @@ void spi_cs_pull_low(void); void spi_cs_release(void); + +/***************************************************************************** */ +/* This function is used to transfer a byte to AND from a device + * As the SPI bus is full duplex, data can flow in both directions, but the clock is + * always provided by the master. The SPI clock cannont be activated without sending + * data, which means we must send data to the device when we want to read data from + * the device. + * This function does not take care of the SPI chip select. + */ +uint16_t spi_transfer_single_frame(uint16_t data); + + /***************************************************************************** */ /* Write data to the SPI bus. * Any data received while sending is discarded.