Commits

Christopher De Vries committed 711ef9f

Changed makefile and source to make spi device configurable.

  • Participants
  • Parent commits 975c542

Comments (0)

Files changed (6)

+CC = gcc
 CFLAGS = -O3
-CC = gcc
 BUNDLE = Makefile README.txt LICENSE.txt tclled.h tclled.c tcl_speedtest.c blink_test.c simple_example.c blink_hsv.c rainbows.c
 VERSION = 1.1
 ARCHIVE = elinux-tcl
 LIBS = -lm
+# Uncomment the line below to compile for beaglebone
+CFLAGS += -DSPIFILE=\"/dev/spidev2.0\"
+# Uncomment the line below to compile for Raspberry Pi
+# CFLAGS += -DSPIFILE=\"/dev/spidev0.0\"
 
 all: tcl_speedtest blink_test simple_example blink_hsv rainbows
 
 
 rainbows: rainbows.o tclled.o
 	$(CC) $(CFLAGS) $(LIBS) -o $@ $^
-
+	
 tclled.o: tclled.h tclled.c
 #include <signal.h>
 #include <math.h>
 
-static const char *device = "/dev/spidev2.0";
+#ifndef SPIFILE
+#define SPIFILE "/dev/spidev2.0"
+#endif
+
+static const char *device = SPIFILE;
 static const int leds = 500;
 static int continue_looping;
 

File simple_example.c

 #include <unistd.h>
 #include <stdio.h>
 
+#ifndef SPIFILE
+#define SPIFILE "/dev/spidev2.0"
+#endif
+
+static const char *device = SPIFILE;
+
 int main(int argc, char *argv[]) {
   int fd;              /* SPI device file descriptor */
   const int leds = 50; /* 50 LEDs in the strand */
   int i;               /* Counting Integer */
 
   /* Open SPI device */
-  fd = open("/dev/spidev2.0",O_WRONLY);
+  fd = open(device,O_WRONLY);
   if(fd<0) {
       /* Open failed */
       fprintf(stderr, "Error: SPI device open failed.\n");

File tcl_speedtest.c

 #include <sys/time.h>
 #include <sys/types.h>
 
-static const char *device = "/dev/spidev2.0";
+#ifndef SPIFILE
+#define SPIFILE "/dev/spidev2.0"
+#endif
+
+static const char *device = SPIFILE;
 static const int leds = 1250;
 static const int frames = 10000;