SAM3/4 SPI phase control (CPHA) is inverted

This commit is contained in:
Gregory Nutt 2013-06-18 09:29:55 -06:00
parent 15e846ad1d
commit 39dcedb0f1
3 changed files with 33 additions and 13 deletions

View File

@ -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).

View File

@ -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:

View File

@ -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: