Add a simple SPI driver

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2749 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2010-06-15 01:12:44 +00:00
parent fede8bba58
commit be6c6381f8
3 changed files with 602 additions and 4 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ CMN_CSRCS = up_assert.c up_blocktask.c up_copystate.c up_createstack.c \
CHIP_ASRCS =
CHIP_CSRCS = lpc17_allocateheap.c lpc17_clockconfig.c lpc17_gpio.c \
lpc17_gpioint.c lpc17_irq.c lpc17_lowputc.c lpc17_serial.c \
lpc17_ssp.c lpc17_start.c lpc17_timerisr.c
lpc17_spi.c lpc17_ssp.c lpc17_start.c lpc17_timerisr.c
# Configuration-dependent LPC17xx files
+596
View File
File diff suppressed because it is too large Load Diff
+5 -3
View File
@@ -42,6 +42,7 @@
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include <semaphore.h>
#include <errno.h>
#include <debug.h>
@@ -113,7 +114,7 @@ struct lpc17_sspdev_s
sem_t exclsem; /* Held while chip is selected for mutual exclusion */
uint32_t frequency; /* Requested clock frequency */
uint32_t actual; /* Actual clock frequency */
uint8_t nbits; /* Width of word in bits (8 or 16) */
uint8_t nbits; /* Width of word in bits (4 to 16) */
uint8_t mode; /* Mode 0,1,2,3 */
#endif
};
@@ -488,7 +489,7 @@ static void ssp_setbits(FAR struct spi_dev_s *dev, int nbits)
static uint16_t ssp_send(FAR struct spi_dev_s *dev, uint16_t wd)
{
FAR struct lpc17_sspdev_s *priv = (FAR struct lpc17_sspdev_s *)dev;
register uint16_t regval;
register uint32_t regval;
/* Wait while the TX FIFO is full */
@@ -607,6 +608,7 @@ static void ssp_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nw
uint32_t rxpending = 0;
/* While there is remaining to be sent (and no synchronization error has occurred) */
#warning "This only works with 8-bit transfers"
sspdbg("nwords: %d\n", nwords);
while (nwords || rxpending)
@@ -763,7 +765,7 @@ FAR struct spi_dev_s *up_spiinitialize(int port)
regval = ssp_getreg(priv, LPC17_SSP_CR1_OFFSET);
ssp_putreg(priv, LPC17_SSP_CR1_OFFSET, regval | SSP_CR1_SSE);
for (i = 0; i < 8; i++)
for (i = 0; i < LPC17_SSP_FIFOSZ; i++)
{
(void)ssp_getreg(priv, LPC17_SSP_DR_OFFSET);
}