From 69fc11bb718df3d563edc1873dcd17c40d3b0a01 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 18 Jun 2013 12:16:52 -0600 Subject: [PATCH] Fix test of NULL pointer in the SAM3/4 SPI driver --- ChangeLog | 3 +++ arch/arm/src/sam34/sam_spi.c | 11 ++++++++--- configs/sam3u-ek/README.txt | 4 ++-- configs/sam4l-xplained/README.txt | 13 ++++++------- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8cd045ec61..df2cb3f419 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5004,3 +5004,6 @@ definitions from Alan Carvalho de Assis (2013-6-18). * configs/freedom-kl25z/src/kl_tsi.c: Example TSI driver for the Freedom KL25Z board from Alan Carvalho de Assis (2013-6-18). + * arch/arm/src/sam34/sam_spi.c: Correct an incorrect pointer test. + Was checking if the wrong pointer was NULL (2013-6-18). + diff --git a/arch/arm/src/sam34/sam_spi.c b/arch/arm/src/sam34/sam_spi.c index 7582e94958..716cebb37b 100644 --- a/arch/arm/src/sam34/sam_spi.c +++ b/arch/arm/src/sam34/sam_spi.c @@ -758,7 +758,7 @@ static void spi_exchange(FAR struct spi_dev_s *dev, { /* Get the data to send (0xff if there is no data source) */ - if (rxptr) + if (txptr) { data = (uint32_t)*txptr++; } @@ -790,11 +790,16 @@ static void spi_exchange(FAR struct spi_dev_s *dev, putreg32(data, SAM_SPI_TDR); - /* Wait for the read data to be available in the RDR */ + /* Wait for the read data to be available in the RDR. + * TODO: Data transfer rates would be improved using the RX FIFO + * (and also DMA) + */ while ((getreg32(SAM_SPI_SR) & SPI_INT_RDRF) == 0); - /* Read the received data from the SPI Data Register */ + /* Read the received data from the SPI Data Register.. + * TODO: The following only works if nbits <= 8. + */ data = getreg32(SAM_SPI_RDR); if (rxptr) diff --git a/configs/sam3u-ek/README.txt b/configs/sam3u-ek/README.txt index 4bb8caa2e3..5c673f6b10 100644 --- a/configs/sam3u-ek/README.txt +++ b/configs/sam3u-ek/README.txt @@ -583,8 +583,8 @@ Configuration sub-directories CONFIG_ADS7843E_SPIDEV=2 : Use SPI CS 2 for communication CONFIG_ADS7843E_SPIMODE=0 : Use SPI mode 0 CONFIG_ADS7843E_FREQUENCY=1000000 : SPI BAUD 1MHz - CONFIG_ADS7843E_THRESHX=39 : These will probably need to be tuned - CONFIG_ADS7843E_THRESHY=51 + CONFIG_ADS7843E_THRESHX=51 : These will probably need to be tuned + CONFIG_ADS7843E_THRESHY=39 System Type -> Peripherals: CONFIG_SAM34_SPI=y : Enable support for SPI diff --git a/configs/sam4l-xplained/README.txt b/configs/sam4l-xplained/README.txt index bb7ffa71a2..1525a94e04 100644 --- a/configs/sam4l-xplained/README.txt +++ b/configs/sam4l-xplained/README.txt @@ -739,18 +739,17 @@ Configuration sub-directories an 'unsigned long int'. If this error occurs, then you may need to toggle the value of CONFIG_CXX_NEWLONG. - STATUS: As of 2013-6-18, the microSD slot on the I/O1 is marginally - functional but needs more TLC. It seems to behave poorly when - debug output is enabled -- know idea why. And writing to the SD card - does not work. Here is some example of the bad write behavior: + STATUS: As of 2013-6-18, this configuration appears completely + functional. Testing, however, has been very light. Example: NuttShell (NSH) NuttX-6.28 nsh> mount -t vfat /dev/mmcsd0 /mnt/stuff nsh> ls /mnt/stuff /mnt/stuff: - sharmanto.txt - nsh> cat /mnt/stuff/sharmanto.txt - Hi, from Sharmanto nsh> echo "This is a test" >/mnt/stuff/atest.txt nsh> ls /mnt/stuff /mnt/stuff: + atest.txt + nsh> cat /mnt/stuff/atest.txt + This is a test + nsh>