diff --git a/share/examples/cube/Makefile b/share/examples/cube/Makefile index 9e84e58..e576ed9 100644 --- a/share/examples/cube/Makefile +++ b/share/examples/cube/Makefile @@ -1,5 +1,10 @@ PROG = all backlight cube demo -OBJS = gpio.o + +# Duinomite board +#OBJS = duinomite.o + +# Fubarino board +OBJS = fubarino.o all: $(PROG) diff --git a/share/examples/cube/Makefile-host b/share/examples/cube/Makefile-host index 044af79..216eaa4 100644 --- a/share/examples/cube/Makefile-host +++ b/share/examples/cube/Makefile-host @@ -6,8 +6,8 @@ LIBS += -lm #all: demo -demo: demo.o gpio.o - ${CC} ${LDFLAGS} -o demo.elf demo.o gpio.o ${LIBS} +demo: demo.o fubarino.o + ${CC} ${LDFLAGS} -o demo.elf demo.o fubarino.o ${LIBS} ${OBJDUMP} -S demo.elf > demo.dis ${SIZE} demo.elf ${ELF2AOUT} demo.elf $@ diff --git a/share/examples/cube/gpio.c b/share/examples/cube/duinomite.c similarity index 87% rename from share/examples/cube/gpio.c rename to share/examples/cube/duinomite.c index 5650f84..fdedadb 100644 --- a/share/examples/cube/gpio.c +++ b/share/examples/cube/duinomite.c @@ -112,7 +112,7 @@ void gpio_plane(unsigned char *data) int i, n, val; /* Send 8 bytes of tada to shift registers. */ - for (i=0; i<8; i++) { + for (i=0; i<8; i+=2) { val = *data++; for (n=0; n<8; n++) { /* SDI signal at RE5. */ @@ -127,5 +127,19 @@ void gpio_plane(unsigned char *data) val <<= 1; } + val = *data++; + for (n=0; n<8; n++) { + /* SDI signal at RE5. */ + if (val & 1) + ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 5); + else + ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 5); + + /* CLK signal at RE6. */ + ioctl(gpio, GPIO_PORTE | GPIO_SET, 1 << 6); + ioctl(gpio, GPIO_PORTE | GPIO_CLEAR, 1 << 6); + + val >>= 1; + } } } diff --git a/share/examples/cube/fubarino.c b/share/examples/cube/fubarino.c new file mode 100644 index 0000000..022da48 --- /dev/null +++ b/share/examples/cube/fubarino.c @@ -0,0 +1,143 @@ +/* + * Interface to LED cube 8x8x8. + * The cube is connected to pins 4-13 of Fubarino board. + * + * Pin PIC32 Function + * --------------- + * 4 RD0 Y0 \ + * 5 RC13 Y1 | Layer select + * 6 RC14 Y2 / + * 7 RD1 Y3 - Upper backlignt + * 8 RD2 Y4 - Lower backlight + * 9 RD3 SDI - Serial data \ + * 10 RD4 CLK - Clock | to shift registers + * 11 RD5 /LE - Latch enable | + * 12 RD6 /OE - Output enable / + * 13 RD7 EXT - Unknown + */ +#include +#include +#include +#include +#include "cube.h" + +static int gpio; + +void gpio_init() +{ + char *devname = "/dev/porta"; + + /* Open GPIO driver. */ + gpio = open(devname, 1); + if (gpio < 0) { + perror(devname); + exit(-1); + } + + /* Configure pins RD0-RD7, RC13 and RC14 as output. */ + ioctl(gpio, GPIO_PORTD | GPIO_CONFOUT, 0xff); + ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 0xff); + ioctl(gpio, GPIO_PORTC | GPIO_CONFOUT, 3 << 13); + ioctl(gpio, GPIO_PORTC | GPIO_CLEAR, 3 << 13); +} + +void gpio_ext(int on) +{ + /* EXT signal at RD7. */ + if (on) + ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 7); + else + ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 7); +} + +void gpio_oe(int active) +{ + /* /OE signal at RD6, active low. */ + if (active) + ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 6); + else + ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 6); +} + +void gpio_le(int active) +{ + /* /LE signal at RD5, active low. */ + if (active) + ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 5); + else + ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 5); +} + +void gpio_backlight_upper(int on) +{ + /* Y4 signal at RD2. */ + if (on) + ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 2); + else + ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 2); +} + +void gpio_backlight_lower(int on) +{ + /* Y3 signal at RD1. */ + if (on) + ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 1); + else + ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 1); +} + +void gpio_layer(int z) +{ + /* Y0-Y2 signals at RD0, RC13, RC14. */ + if (z & 1) + ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 0); + else + ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 0); + + if (z & 2) + ioctl(gpio, GPIO_PORTC | GPIO_CLEAR, 1 << 13); + else + ioctl(gpio, GPIO_PORTC | GPIO_SET, 1 << 13); + + if (z & 4) + ioctl(gpio, GPIO_PORTC | GPIO_CLEAR, 1 << 14); + else + ioctl(gpio, GPIO_PORTC | GPIO_SET, 1 << 14); +} + +void gpio_plane(unsigned char *data) +{ + int i, n, val; + + /* Send 8 bytes of tada to shift registers. */ + for (i=0; i<8; i+=2) { + val = *data++; + for (n=0; n<8; n++) { + /* SDI signal at RD3. */ + if (val & 0x80) + ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 3); + else + ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 3); + + /* CLK signal at RD4. */ + ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 4); + ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 4); + + val <<= 1; + } + val = *data++; + for (n=0; n<8; n++) { + /* SDI signal at RD3. */ + if (val & 1) + ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 3); + else + ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 3); + + /* CLK signal at RD4. */ + ioctl(gpio, GPIO_PORTD | GPIO_SET, 1 << 4); + ioctl(gpio, GPIO_PORTD | GPIO_CLEAR, 1 << 4); + + val >>= 1; + } + } +} diff --git a/tools/fsutil/fsutil.c b/tools/fsutil/fsutil.c index 86a4654..8b6ad24 100644 --- a/tools/fsutil/fsutil.c +++ b/tools/fsutil/fsutil.c @@ -825,7 +825,7 @@ int main (int argc, char **argv) return -1; } if (! fs_open (&fs, argv[i], (add + mount != 0), pindex)) { - fprintf (stderr, "%s: cannot open\n", argv[i]); + fprintf (stderr, "%s: cannot open filesystem\n", argv[i]); return -1; }