summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/ChangeLog2
-rw-r--r--nuttx/arch/arm/src/sam34/sam_spi.c24
-rw-r--r--nuttx/configs/sam4l-xplained/README.txt20
3 files changed, 33 insertions, 13 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 817e574e5..fa28b0eff 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -4998,4 +4998,6 @@
and data width are correct (2013-6-17).
* arch/arm/src/kinetis/kinetis_tsi.h: Corrections to the Kinetis
(2013-6-18)
+ * arch/arm/src/sam34/sam_spi.c: Fix SPI mode setting. In the SAM3/4
+ family, the clock phase control (CPHA) is inverted (NPHA) (2013-6-18).
diff --git a/nuttx/arch/arm/src/sam34/sam_spi.c b/nuttx/arch/arm/src/sam34/sam_spi.c
index 35160ff04..7582e9495 100644
--- a/nuttx/arch/arm/src/sam34/sam_spi.c
+++ b/nuttx/arch/arm/src/sam34/sam_spi.c
@@ -547,7 +547,15 @@ static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode)
if (mode != priv->mode)
{
#endif
- /* Yes... Set the mode appropriately */
+ /* Yes... Set the mode appropriately:
+ *
+ * SPI CPOL NCPHA
+ * MODE
+ * 0 0 1
+ * 1 0 0
+ * 2 1 1
+ * 3 1 0
+ */
regaddr = g_csraddr[priv->cs];
regval = getreg32(regaddr);
@@ -555,19 +563,19 @@ static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode)
switch (mode)
{
- case SPIDEV_MODE0: /* CPOL=0; NCPHA=0 */
+ case SPIDEV_MODE0: /* CPOL=0; NCPHA=1 */
+ regval |= SPI_CSR_NCPHA;
break;
- case SPIDEV_MODE1: /* CPOL=0; NCPHA=1 */
- regval |= SPI_CSR_NCPHA;
+ case SPIDEV_MODE1: /* CPOL=0; NCPHA=0 */
break;
- case SPIDEV_MODE2: /* CPOL=1; NCPHA=0 */
- regval |= SPI_CSR_CPOL;
+ case SPIDEV_MODE2: /* CPOL=1; NCPHA=1 */
+ regval |= (SPI_CSR_CPOL | SPI_CSR_NCPHA);
break;
- case SPIDEV_MODE3: /* CPOL=1; NCPHA=1 */
- regval |= (SPI_CSR_CPOL|SPI_CSR_NCPHA);
+ case SPIDEV_MODE3: /* CPOL=1; NCPHA=0 */
+ regval |= SPI_CSR_CPOL;
break;
default:
diff --git a/nuttx/configs/sam4l-xplained/README.txt b/nuttx/configs/sam4l-xplained/README.txt
index 906efdd10..bb7ffa71a 100644
--- a/nuttx/configs/sam4l-xplained/README.txt
+++ b/nuttx/configs/sam4l-xplained/README.txt
@@ -739,8 +739,18 @@ 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-16, the microSD slot on the I/O1 is not working.
- This could be an SPI communication issues, but it appears more like
- a card interfacing problems. The card does make some appropriate
- responses but also reports some other issues (erase reset) and will
- not exit IDLE most.
+ 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:
+
+ 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: