chiark / gitweb /
Updated a technicality in softPwm, and added a suggested memset to zero
authorGordon Henderson <projects@drogon.net>
Thu, 29 Jan 2015 10:17:25 +0000 (10:17 +0000)
committerGordon Henderson <projects@drogon.net>
Thu, 29 Jan 2015 10:17:25 +0000 (10:17 +0000)
for the SPI code - it's mentioned in spidev.h but not used in the actual
kernel documentation example spi_test.c program )-:

wiringPi/softPwm.c
wiringPi/wiringPiSPI.c

index 3c79ba7b37a57f5c5bb67b131ed62b04396261f5..98b408f551517a54c63dc2138eb532df8ee8d688 100644 (file)
 
 #define        PULSE_TIME      100
 
-static int marks         [MAX_PINS] ;
-static int range         [MAX_PINS] ;
-static pthread_t threads [MAX_PINS] ;
-
-int newPin = -1 ;
+static volatile int marks         [MAX_PINS] ;
+static volatile int range         [MAX_PINS] ;
+static volatile pthread_t threads [MAX_PINS] ;
+static volatile int newPin = -1 ;
 
 
 /*
index 215a0277440813110c7dcf1c9f8e38efd015b452..002ee0185267992776dbc3275263e807ad90f554 100644 (file)
@@ -75,6 +75,11 @@ int wiringPiSPIDataRW (int channel, unsigned char *data, int len)
 
   channel &= 1 ;
 
+// Mentioned in spidev.h but not used in the original kernel documentation
+//     test program )-:
+
+  memset (&spi, 0, sizeof (spi)) ;
+
   spi.tx_buf        = (unsigned long)data ;
   spi.rx_buf        = (unsigned long)data ;
   spi.len           = len ;