[En-Nut-Discussion] Minor problem in At91SpiSetModeFlags?

Mark Meade mark at lakeshoremicro.com
Mon Jun 16 23:20:48 CEST 2008


In at91_spi.c, the At91SpiSetModeFlags function appears to be setting
the MODFDIS (mode fault detection) bit incorrectly.  If SPIMF_MFDETECT
is not requested, the mode fault detection disable should be set.

This may not cause a problem when using SPI chip select 0, but I was
unable to get a device on CS3 to work without the following change:

===================================================================
RCS file: /cvsroot/ethernut/nut/arch/arm/dev/at91_spi.c,v
retrieving revision 1.4
diff -u -b -B -d -r1.4 at91_spi.c
--- at91_spi.c  4 Oct 2007 19:50:41 -0000 1.4
+++ at91_spi.c  16 Jun 2008 20:38:38 -0000
@@ -426,8 +426,8 @@
     if (mode & SPIMF_PCSDEC) {
         mv |= SPI_PCSDEC;
     }
-    if (mode & SPIMF_MFDETECT) {
-        mv &= ~SPI_MODFDIS;
+    if (!(mode & SPIMF_MFDETECT)) {
+        mv |= SPI_MODFDIS;
     }
     if (mode & SPIMF_LOOPBACK) {
         mv |= SPI_LLB;

This problem would also cause At91SpiSetModeFlags to incorrectly return
-1 if SPIMF_MFDETECT was not requested, as the get mode flags function
handles the MODFDIS flag correctly.

Regards,

Mark






More information about the En-Nut-Discussion mailing list